Commit Graph

37 Commits

Author SHA1 Message Date
aiongg 5cdcac4ace
fix(save): replace files atomically
Replace native engine saves and engine/MCP exports atomically, preserving private permissions during staging and cleaning up failed writes. Add regressions for long filenames and caught writer unwinding.

Fixes #436.

Co-authored-by: aiongg <aiongtaigi@gmail.com>
Co-authored-by: skylar taylor-barrick <hi@skylar.cc>
2026-10-12 09:19:36 -06:00
Brandon Thomas 48dfbcfd19 Merge origin/main into data-merge
Resolve conflicts keeping both sides: doc gains both `cjk` and
`datamerge` modules; file.open resolves data-merge sources and loads the
document's fonts; DocState keeps preview_stash/preview_record and fonts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 22:28:15 -04:00
aiongg c64e538de5 UI: the font menu groups fonts by script, CJK fonts by language
Font menus list Western (and other-script) families first, then
Japanese, Simplified Chinese, Traditional Chinese and Korean families,
each group alphabetical by the name shown, with a separator between
groups. The group comes from the font's own data, strongest signal
first: the meta table's dlng (else slng) languages, family names in a
CJK language (Windows and Macintosh language IDs), OS/2 code pages (JIS,
Chinese Simplified, Korean Wansung, Chinese Traditional, Korean Johab);
a font declaring none of these goes by what it covers (kana, Hangul,
ideographs). Ties go Japanese, Simplified, Traditional, Korean. Loaded faces are classified
once; installed fonts by the font scan, which also reads their OS/2 and
meta tables (and cmap only for fonts declaring nothing), capped.

CJK families show their family name in their language, the English
name on hover; Preferences > Type > Show Font Names in English
(prefs.set {showFontNamesInEnglish}, off by default) shows English
names. Search matches either name; documents store the English name.
The Character panel, Control bar, Properties, style dialogs, Find Font
and Glyphs panel lists all follow this order. The main font menu stays
open while searching or starring (it closed on any click inside).

Font previews don't draw DesignCraft's missing-glyph box for fonts
whose .notdef is empty.
2026-10-07 10:44:46 -04:00
aiongg 5f52150b31 CJK 1.9: document fonts belong to their document
The fonts in a document's Document Fonts folder are registered under a
font scope that the document holds while it is open (Document::font_scope,
runtime only; DocState keeps the scope alive and closes it when the last
copy of the state goes: file.close, closing a tab, revert, a book
chapter's export, the session ending). Composition, preflight, font.list,
Package and the font menus, Glyphs panel and previews look fonts up
through FontDb::scoped(scope): the document's own faces first, then the
shared ones. Other open documents don't see them, and two documents with
fonts of the same name each set text in their own. Composite fonts'
member fonts and the fallback for kenten marks are looked up the same
way.

Font files stay in memory for the session (FaceRef keeps faces for the
process); a document opened again reuses the faces of its unchanged files
(same path, length and modification time) instead of reading them again.
The composition cache's signature includes the scope; the word cache and
the outline and PDF font caches are keyed by face. Variable font
instances are kept per base face.

A family's installed faces join the shared fonts all at once, and a
face two lookups load at the same time is kept once, so a parallel
fallback lookup never takes a family's bold before its regular has
loaded.
2026-10-07 10:44:46 -04:00
Cameron Gilroy b41eba1cba Data merge: merge into a new document, with preview and tiling
Select, update, and remove a linked source. Placeholders cover text,
images, QR codes, and hyperlinks. Preview fills one record in the
session and is left out of save and recovery. Merge copies the template
into a new document, one record per page, or tiles frames on a single
non-facing page. A missing or changed file is marked and the cached
rows are still used. The template undo stack is left as it was.
2026-10-07 21:22:06 +11:00
Cameron Gilroy 4de93d1345 Snap: carry SnapView on the tool context 2026-10-06 09:05:59 -04:00
japbcoelho 7e69c82b89 Engine: commands given ids run without a selection
A command that documents ids (object.textFrameOptions, transform.rotate, ...)
acts on the objects a call names, yet its enabled check looked only at the
selection. With a text caret or nothing selected, {"ids": [5]} failed with:

  command `object.textFrameOptions` is not available right now: nothing selected

Execute now lets such a call through when every named object exists, and
says "no object with id N" when one doesn't. transform.set, object.arrange
and edit.stepAndRepeat, which already acted on ids, now document them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 09:04:22 -04:00
Brandon Thomas afdae89d68
Merge pull request #14 from storytold/pr/never-crash-guard
Never crash: last-resort guard around every command
2026-10-04 14:20:03 -04:00
Brandon Thomas f1662185de Never crash: last-resort guard around every command
Session::execute runs each command inside catch_unwind: a panic that escapes
(any edit, import or export, from the UI, CLI, MCP or control channel)
becomes EngineError::Internal, the document and selection are restored to
before the command, and crash recovery is saved when enabled. The first
Session installs a panic hook that logs the message and location.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 12:55:07 -04:00
Brandon Thomas f05bbfeea2 Never crash: engine, MCP and tools
Commands return errors instead of expect()/unreachable!() (book, library,
undo/redo, paste, find/replace, Pathfinder, tables, QR, select, swatches,
anchors, articles, transform again, XML import). The sample document builder
propagates errors. Commands that add a key to their parameters no longer
panic when a caller (control channel, MCP, script) passes an array or a
string, and corrupt crash-recovery metadata is ignored. engine, mcp and
tools now deny unwrap/expect/panic/unimplemented/todo/unreachable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 12:43:33 -04:00
storybored379 eee64ae7c9 Layers: the active layer falls back to the top layer when it is removed
The active layer lives on DocState, outside the undo snapshots, and
nothing re-checked it when the document's layers changed. After New
Layer → Undo (or Delete Layer / Delete Unused Layers / Merge Layers on
the active layer) it kept pointing at a layer that no longer exists, and
every object created next (frames, lines, placed images, pasted items)
was put on that phantom layer: not drawn on the canvas, missing from PDF
export, ItemLayer referencing an undefined layer in IDML, and preflight
reported nothing.

After each command, if the active layer is gone, make the top layer
active (as on opening a document).

Test: active_layer_survives_undoing_new_layer.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-04 09:52:29 -04:00
Brandon Thomas f888e6b061 X: DTDs — load, validate the structure, Tags panel
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 00:57:18 -04:00
Brandon Thomas 84476ffef4 P: live captions that follow their source's metadata
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 10:48:58 -04:00
Brandon Thomas d37d2e5237 T: math expressions — LaTeX subset typeset to SVG, inline or framed
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 08:30:11 -04:00
Brandon Thomas 23098f0bd3 W: Preferences — Dictionary, Spelling (dynamic spelling), Autocorrect, Notes, Track Changes, Story Editor, File Handling
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 07:33:15 -04:00
Brandon Thomas 60a8fefe37 L: books — continuous numbering, style sync, merged PDF (+ panel)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 03:49:25 -04:00
Brandon Thomas 4eed1d3177 Q: Content Collector and Placer
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 03:30:43 -04:00
Brandon Thomas c9785ae1ed U: Font menu with search, favourites and previews; persist engine preferences
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 00:27:52 -04:00
Brandon Thomas eb2e8d8b4f C: Appearance of Black — output rich black, Overprint [Black] at 100%
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 23:51:51 -04:00
Brandon Thomas 68e624cba4 O: Object Library — .dclib files of snippets, Library panel
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 23:39:11 -04:00
Brandon Thomas d11b23d805 T: endnotes — numbered references, generated endnote frame, options
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 23:10:36 -04:00
Brandon Thomas 98d8edf764 T: Composition highlights — keep and H&J violations, custom tracking/kerning
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 22:35:23 -04:00
Brandon Thomas 11212736f0 P: Page Numbering View (section/absolute) and Go to Page by name
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 22:21:30 -04:00
Brandon Thomas 240668e87d T: scale/rotation/shear fields, absolute transform values, Transformations are Totals
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 21:54:05 -04:00
Brandon Thomas faa2897ace T: drag and drop text editing (move, Alt copies)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 21:12:33 -04:00
Brandon Thomas 8bfbbe7187 A: Primary Text Frame and Smart Text Reflow
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 16:20:16 -04:00
Brandon Thomas 571e1043f7 O: Transform Again family, Clear Transformations, layer merge/unused/others, Break Link to Style
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 15:09:32 -04:00
Brandon Thomas 7143973f52 G: Preferences (⌘K), scale strokes, Dimensions Include Stroke Weight, Quick Apply (⌘Return)
prefs.set (application) and document.preferences (units, increments, grids; undoable).
Scaling applies to content: paths and placed graphics take the scale, stroke weights follow
with Include Stroke Weight. X/Y/W/H and transform.set measure the stroke's outer edge.
The command palette becomes Quick Apply and lists styles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 09:26:39 -04:00
Brandon Thomas 87727f279a D: Paste Into, Polygon Settings
- Edit › Paste Into (⌥⌘V): copied objects (with their stories and images) become the selected
  frame's content, clipped by it; Item::is_group / has_nested_items; renderer and PDF draw fill,
  clipped content, stroke; IDML nests the items inside the frame both ways (verified in
  InDesign 2026) (+ tests)
- Polygon Settings: sides and star inset as engine preferences used by the polygon tools and
  frame.create; double-click the Polygon tool (+ test)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 08:24:48 -04:00
Brandon Thomas 4696178f62 R: crash recovery, Revert, Save a Copy
- engine::recovery: unsaved documents written to a recovery folder (atomic write + metadata),
  reopened as unsaved documents that remember their files; entries dropped on save/close
  (+ tests); file.recovery.list/save/open, file.revert, file.saveACopy (+ test)
- app: recovery folder per platform, recovered on launch with a status message; UI writes
  recovery data every 30 s while documents are unsaved; File › Save a Copy…, Revert
- parity: recovery, revert, save a copy done

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 08:11:25 -04:00
Brandon Thomas 7145107896 Agents: command scripts with result references (CLI, MCP, app); parity estimate
- engine::script: parse scripts (lines, JSON lines, JSON arrays), resolve "$N.path" /
  "${N.path}" references to earlier results, run with a failure report (+ tests)
- CLI: script [FILE|-] (headless or --connect to the running app; --save/--export,
  --keep-going), app COMMAND [JSON] / --method, describe ID, commands FILTER, $N references in
  run --cmd (+ integration tests)
- MCP batch: references and a script-text alternative (+ test)
- docs/agents.md; docs/parity.md scored over 275 catalogue features with cargo xtask parity;
  ROADMAP: parity ~63% breadth / ~55% overall, ~600 agent-hours remaining

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 08:06:42 -04:00
Brandon Thomas 781c57ac5a M2: formatted text clipboard, Paste without Formatting, Change Case, special-character menus
- doc: Story::extract / insert_story carry formats, footnotes, cross-references, index markers
  and tables through copy and paste
- engine: edit.copy/cut on text keep a formatted slice; edit.paste uses it while the system
  clipboard matches (else plain text, no smart quotes); edit.pasteWithoutFormatting (⇧⌘V);
  type.changeCase (upper/lower/title/sentence, run formats kept)
- UI: canvas copy/cut/paste go through the engine; Type › Insert Special Character (Symbols,
  Markers, Hyphens and Dashes, Quotation Marks, Other), Insert White Space, Insert Break
  Character, Change Case; nested submenus in the menu parser (+ test)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 22:57:27 -04:00
Brandon Thomas 56cb9f5c65 M14: community links — Help menu (Discord, app page, GitHub, issues, website), About splash with ArtCraft mark, start-screen community card, app-bar Discord button, app.links/help.* commands, CLI 'links', MCP websiteUrl
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 14:19:13 -04:00
Brandon Thomas 77a23151ba M8: tables
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 12:44:45 -04:00
Brandon Thomas b070cc343c M6.2: IDML import/export
New crate designcraft-idml (L3, zip + quick-xml): export_idml/import_idml for
swatches (process/spot CMYK/RGB/Lab, tints, gradients), paragraph/character/
object styles with BasedOn and groups, fonts, preferences, layers, sections,
parent spreads, spreads/pages (spine/centre origin mapping), frames, groups,
corner options, wrap, transparency, embedded/linked images, formatted stories
with special characters, breaks and threading. Engine commands
file.exportIdml / file.openIdml, file.open/openBytes dispatch on IDML, CLI
--in/--export .idml, File > Export IDML..., open dialogs accept .idml.
Verified black-box in InDesign 2026 (exported files open with correct pages,
stories, threads, styles, swatches; InDesign-exported IDML imports).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 12:03:28 -04:00
Brandon Thomas 51045daf36 M5: loaded place cursor (place gun): click = actual size, drag = fit, click frame = place into
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 11:53:04 -04:00
Brandon Thomas 91ae2b3cc9 M0: engine, tools, egui UI, desktop app, CLI, sample document, docs
Engine with command registry (~100 commands), tool hosting with one-step
undo per gesture, InDesign-style egui frontend (app bar, Control panel,
Tools panel, rulers, guides, frame edges, ports/threads, Properties/Pages/
Layers dock, panels, dialogs), JSON control channel, headless CLI renderer,
generated sample magazine, README/AGENTS/ROADMAP/ASSETS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 10:39:15 -04:00