@quillmark/wasm 0.104.0 → 0.105.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/core/wasm.d.ts CHANGED
@@ -24,17 +24,13 @@ export type PayloadItem =
24
24
  | { type: "comment"; text: string; inline?: boolean };
25
25
 
26
26
  /**
27
- * A single card block, as read back from a document: returned by
28
- * `Document.main` / `Document.cards` / `Document.removeCard` / `Quill.seedCard`
29
- * / `Document.makeCard`. To feed a card *into* a document use `CardInput`
30
- * (which `insertCard` accepts); every `Card` is a valid `CardInput`,
31
- * so a card read from one document pushes straight into another.
27
+ * A single card block, as read back from a document. Every `Card` is a valid
28
+ * `CardInput`, so a card read from one document pushes straight into another.
32
29
  *
33
30
  * `$` system entries are hoisted to named fields: `kind` (the `$kind`, empty
34
- * string when none), optional `quill` (the `$quill` `name@version`, main card
35
- * only), optional `ext` (`$ext`), and optional `seed`
36
- * (the `$seed` per-kind overlay map, main card only). `payloadItems` carries
37
- * user fields and comments in order.
31
+ * string when none), `quill` (`$quill` `name@version`, main card only), `ext`
32
+ * (`$ext`), and `seed` (the `$seed` per-kind overlay map, main card only).
33
+ * `payloadItems` carries user fields and comments in order.
38
34
  */
39
35
  export interface Card {
40
36
  kind: string;
@@ -43,21 +39,16 @@ export interface Card {
43
39
  seed?: Record<string, unknown>;
44
40
  payloadItems: PayloadItem[];
45
41
  /**
46
- * The card body as canonical `Content`: the source-of-truth content model.
47
- * Always this content shape on read, never a markdown string. For the markdown
48
- * projection call the codec `exportMarkdown(card.body)`. Write a body back
49
- * with `doc.overwrite(addr, rt)` / `doc.revise(addr, md)`, or via `CardInput.body`.
42
+ * The card body as canonical `Content`, never a markdown string. For the
43
+ * markdown projection call `exportMarkdown(card.body)`.
50
44
  */
51
45
  body: Content;
52
46
  }
53
47
 
54
48
  /**
55
- * A card written *into* a document: the input twin of `Card`, accepted by
56
- * `Document.insertCard`. Like `Card` but `body` also
57
- * takes a markdown `string` (imported to the content, so a markdown / LLM writer
58
- * needn't build the `Content` shape), and every field but `kind` is optional:
59
- * an absent field defaults (no payload items, an empty body). Write one inline
60
- * (`{ kind, body }`) or build it with `Document.makeCard`.
49
+ * A card written *into* a document, accepted by `Document.insertCard`. Like
50
+ * `Card`, but `body` also takes a markdown `string`, and every field but `kind`
51
+ * is optional (defaulting to no payload items and an empty body).
61
52
  */
62
53
  export interface CardInput {
63
54
  kind: string;
@@ -69,11 +60,10 @@ export interface CardInput {
69
60
  }
70
61
 
71
62
  /**
72
- * Canonical richtext content: the content model for a card body (and richtext
73
- * fields). One text sequence over a single coordinate space (Unicode scalar
74
- * values): `text` plus line attributes, anchored `marks`, and embedded
75
- * `islands`. Every edit is a splice; markdown is a projection, not the model.
76
- * Mirrors `quillmark_content::serial`'s canonical JSON encoding.
63
+ * Canonical richtext content: the model behind a card body and richtext fields.
64
+ * One text sequence over a single coordinate space (Unicode scalar values):
65
+ * `text` plus line attributes, anchored `marks`, and embedded `islands`. Every
66
+ * edit is a splice; markdown is a projection, not the model.
77
67
  */
78
68
  export interface Content {
79
69
  text: string;
@@ -82,19 +72,17 @@ export interface Content {
82
72
  islands: ContentIsland[];
83
73
  }
84
74
 
85
- /** One `\n`-separated segment of `Content.text`, in order. `kind` is an open set
86
- * (as on `ContentIsland` and `ContentMark`): a role this build does not know
87
- * round-trips with opaque `attrs` and renders as a paragraph, so a document
88
- * carrying a future block construct still opens. The open arm blocks discriminant
89
- * narrowing, so read `level`/`lang` behind a check of the arm you want. */
75
+ /** One `\n`-separated segment of `Content.text`, in order. `kind` is an open set:
76
+ * an unknown role round-trips with opaque `attrs` and renders as a paragraph.
77
+ * The open arm blocks discriminant narrowing, so read `level`/`lang` behind a
78
+ * check of the arm you want. */
90
79
  export type ContentLine = {
91
80
  containers: ContentContainer[];
92
81
  /** A within-block hard line break rather than a new block. Omitted (false) in the common case. */
93
82
  continues?: boolean;
94
83
  } & ContentLineKind;
95
84
 
96
- /** A line's block role, declared once for `ContentLine` and the `setKind` op:
97
- * a new role is one edit here, as for `ContentContainer`. */
85
+ /** A line's block role, shared by `ContentLine` and the `setKind` op. */
98
86
  export type ContentLineKind =
99
87
  | { kind: "para" }
100
88
  | { kind: "heading"; level: number }
@@ -112,13 +100,12 @@ export type ContentContainer =
112
100
  | { container: string; attrs: unknown };
113
101
 
114
102
  /** A mark over char range `[start, end)` into `Content.text`. The open `type`
115
- * arm blocks discriminant narrowing (as on `ContentIsland`), so read a
116
- * payload-carrying arm behind its guard: `isLinkMark` (`url`) / `isAnchorMark`
117
- * (`id`), from `@quillmark/wasm/runtime`; the bare arms carry no payload. An
118
- * `anchor`'s `id` is a caller-supplied, opaque handle, unique per `Content` and
119
- * invariant while the mark lives (positions rebase, the id never does); it has no
120
- * markdown projection and survives only through the edit lane. See DOCUMENT_STORAGE
121
- * § Anchor-id identity. */
103
+ * arm blocks discriminant narrowing, so read a payload-carrying arm behind its
104
+ * guard: `isLinkMark` (`url`) / `isAnchorMark` (`id`), from
105
+ * `@quillmark/wasm/runtime`. An `anchor`'s `id` is a caller-supplied opaque
106
+ * handle, unique per `Content` and invariant while the mark lives (positions
107
+ * rebase, the id never does); it has no markdown projection and survives only
108
+ * through the edit lane. */
122
109
  export type ContentMark = { start: number; end: number } & (
123
110
  | { type: "strong" | "emph" | "underline" | "strike" | "code" }
124
111
  | { type: "link"; url: string }
@@ -126,9 +113,8 @@ export type ContentMark = { start: number; end: number } & (
126
113
  | { type: string; attrs: unknown }
127
114
  );
128
115
 
129
- /** A cell in a `TableProps`: its plain `text` plus the `marks` over it. `marks`
130
- * rides the same wire shape as prose `ContentMark`, but each mark's `start`/`end`
131
- * are USV offsets into this cell's `text` (`0..text.length`), not into
116
+ /** A cell in a `TableProps`. `marks` rides the prose `ContentMark` shape, but
117
+ * each mark's `start`/`end` are USV offsets into this cell's `text`, not into
132
118
  * `Content.text`. */
133
119
  export interface TableCell {
134
120
  text: string;
@@ -150,17 +136,15 @@ export interface ImageProps {
150
136
  alt: string;
151
137
  }
152
138
 
153
- /** A structured object occupying one island slot in `Content.text`. `type` is an
154
- * open set: the engine pins `props` as `TableProps` for `table` and `ImageProps`
155
- * for `image`; an island of any other type round-trips with opaque `props`. Like
156
- * `ContentMark`, the open `type` arm means a discriminant check does not itself
157
- * narrow `props`: read `props` as the matching shape behind the `isTableIsland` /
158
- * `isImageIsland` guards (from `@quillmark/wasm/runtime`), which narrow it. */
159
- /** How faithfully the markdown projection can carry an island. Open like an
160
- * island `type`: a class this build does not know round-trips verbatim, and
161
- * reads as `unrepresentable`. */
139
+ /** How faithfully the markdown projection can carry an island. Open: an unknown
140
+ * class round-trips verbatim and reads as `unrepresentable`. */
162
141
  export type ContentLossClass = "lossless" | "degraded" | "unrepresentable" | (string & {});
163
142
 
143
+ /** A structured object occupying one island slot in `Content.text`. `type` is an
144
+ * open set: `props` is `TableProps` for `table` and `ImageProps` for `image`,
145
+ * and any other type round-trips with opaque `props`. The open arm blocks
146
+ * narrowing, so read `props` behind the `isTableIsland` / `isImageIsland`
147
+ * guards (from `@quillmark/wasm/runtime`). */
164
148
  export type ContentIsland = {
165
149
  id: string;
166
150
  loss: ContentLossClass;
@@ -178,14 +162,16 @@ export type ContentIsland = {
178
162
  * field: "intro" }` a card field.
179
163
  *
180
164
  * On the `Addr`-taking verbs a **bare string** is shorthand for `{ field: name }`
181
- * (`doc.storeField("qty", 3)`, `doc.revise("intro", md)`) the one coercion
182
- * rule. A bare number is *not* an addr (`{ card: 2 }` is the self-documenting
183
- * spelling), so no third navigation idiom re-fragments the surface.
165
+ * (`doc.storeField("qty", 3)`); a bare number is *not* an addr.
184
166
  *
185
167
  * `doc.pathFor(addr)` mints the address as its canonical `DocPath` string, the
186
168
  * anchor `Diagnostic.path` carries and `session.locate` / `session.fieldBoxes`
187
- * take: a card path is kind-qualified, so building one by hand needs the card's
169
+ * take. A card path is kind-qualified, so a hand-built one needs the card's
188
170
  * `$kind`, and a wrong-kind path matches nothing silently.
171
+ *
172
+ * An `Addr` names a field, never a value inside one: every verb that takes one
173
+ * would then carry an element axis it cannot answer. The one read that reaches
174
+ * inside takes the path as its own argument, `reader.getContentAt(addr, path)`.
189
175
  */
190
176
  export interface Addr {
191
177
  card?: number;
@@ -193,10 +179,9 @@ export interface Addr {
193
179
  }
194
180
 
195
181
  /**
196
- * A card-only address: the axis the card-scoped verbs (`storeFields`,
197
- * `storeExt`, `getExt`, `commitFields`, …) take. An absent `card` targets the
198
- * main card. A present `field` throws: a card address takes only `card`, and a
199
- * would-be nested write is a bug the error names rather than silently ignores.
182
+ * A card-only address, taken by the card-scoped verbs (`storeFields`,
183
+ * `storeExt`, `getExt`, `commitFields`, …). An absent `card` targets the main
184
+ * card; a present `field` throws.
200
185
  */
201
186
  export interface CardAddr {
202
187
  card?: number;
@@ -204,8 +189,8 @@ export interface CardAddr {
204
189
 
205
190
  /**
206
191
  * A text-splice change set over the USV content (CodeMirror `ChangeSet`
207
- * semantics): plain, structured-clone-able data. Returned by `revise` and by
208
- * the `rebase` codec; map a stored position through it with `mapPos`.
192
+ * semantics), returned by `revise` and by the `rebase` codec. Map a stored
193
+ * position through it with `mapPos`.
209
194
  */
210
195
  export interface Delta {
211
196
  ops: ({ retain: number } | { insert: string } | { delete: number })[];
@@ -216,11 +201,9 @@ export type Assoc = "before" | "after";
216
201
 
217
202
  /**
218
203
  * A mark edit in final-text coordinates (post-delta, post-line-op). `add` /
219
- * `remove` carry the `ContentMark` vocabulary (`{ type, }`); `removeAnchor`
220
- * drops one identity anchor by id. An `add` of an `anchor` requires a non-empty
221
- * `id` not already live in the field: a collision or the empty id throws
222
- * (ids are caller-supplied and unique per `Content`; DOCUMENT_STORAGE
223
- * § Anchor-id identity).
204
+ * `remove` carry the `ContentMark` vocabulary; `removeAnchor` drops one identity
205
+ * anchor by id. An `add` of an `anchor` requires a non-empty `id` not already
206
+ * live in the field; a collision or the empty id throws.
224
207
  */
225
208
  export type MarkOp =
226
209
  | ({ op: "add" | "remove"; start: number; end: number } & (
@@ -232,12 +215,10 @@ export type MarkOp =
232
215
  | { op: "removeAnchor"; id: string };
233
216
 
234
217
  /**
235
- * A line/block edit. `split`/`join` splice `\n` in post-`delta`, post-`islandOps`
236
- * coordinates; `setKind`/`setContainers`/`setContinues` touch metadata.
237
- * `setContinues` sets/clears a line's within-block hard-break flag
238
- * (`ContentLine.continues`): the op-grained way to lower a Shift+Enter hard
239
- * break or a new code-fence interior line; `continues: true` on line 0 is
240
- * rejected (nothing precedes it to continue).
218
+ * A line/block edit. `split`/`join` splice `\n` in post-`delta`,
219
+ * post-`islandOps` coordinates; `setKind`/`setContainers`/`setContinues` touch
220
+ * metadata. `setContinues` sets or clears a line's within-block hard-break flag
221
+ * (`ContentLine.continues`); `continues: true` on line 0 is rejected.
241
222
  */
242
223
  export type LineOp =
243
224
  | { op: "split"; at: number }
@@ -248,34 +229,25 @@ export type LineOp =
248
229
 
249
230
  /**
250
231
  * An island edit: the only channel that reaches an island's payload, a table's
251
- * cells or an image's url.
252
- *
253
- * Both ops move one island entry and leave the field's text and marks alone, so
254
- * an island edit keeps every identity anchor in the field. That is why a table
255
- * edit lowers to `applyChange` rather than `overwrite`, which drops them all.
232
+ * cells or an image's url. Both ops leave the field's text and marks alone, so
233
+ * an island edit keeps every identity anchor in the field.
256
234
  *
257
- * `set` addresses an existing island by `id`; an `id` no island carries throws
258
- * rather than passing silently. `insert` places a new island's slot at `at`
259
- * together with its entry, so a slot never exists without an island behind it;
260
- * its `id` must be non-empty and unused. `at` is a position in the text the
261
- * `delta` and this bundle's earlier island ops left: each insert splices its
262
- * slot before the next op reads the text, so slots after `a` and `b` of `abc`
263
- * go in at 1 and 3. A stale frame misplaces slots and never throws.
235
+ * `set` addresses an existing island by `id`; an unknown `id` throws. `insert`
236
+ * places a new island's slot at `at` together with its entry, so a slot never
237
+ * exists without an island behind it; its `id` must be non-empty and unused.
238
+ * `at` is a position in the text the `delta` and this bundle's earlier island
239
+ * ops left, so slots after `a` and `b` of `abc` go in at 1 and 3. A stale frame
240
+ * misplaces slots and never throws. A `delta` insert string may not carry a
241
+ * slot, which would orphan: split such a splice into the slot-free `delta` plus
242
+ * one `insert` per slot.
264
243
  *
265
- * A `delta` insert string may not carry a slot, which would orphan. A producer
266
- * that computes one splice over the whole field text carries slots in it on any
267
- * paste of an island or undo of a deletion; that splice splits into the
268
- * slot-free `delta` plus one `insert` per slot.
244
+ * Deleting an island needs no op: a `delta` that removes its slot drops the
245
+ * island whole, and a block island's line demotes to `para`. Re-landing it is an
246
+ * `insert` of the full island under its original id; a pasted copy of a live
247
+ * island mints a fresh one.
269
248
  *
270
- * Deleting an island needs no op, and the drop is whole: a `delta` that removes
271
- * its slot drops the island from the store. Re-landing it is an `insert` of the
272
- * full island under its original id, and only the producer that deleted it
273
- * still holds that value. A pasted copy of a live island is new and mints fresh
274
- * (DOCUMENT_STORAGE § Island-id determinism). A block island's line demotes to
275
- * `para` when its slot goes, so re-landing one re-tags the line too.
276
- *
277
- * A `set` stores the `loss` it is given: nothing re-derives the class from the
278
- * new `props`, so a write that changes what markdown can carry must say so.
249
+ * A `set` stores the `loss` it is given; nothing re-derives the class from the
250
+ * new `props`.
279
251
  *
280
252
  * An island is *inline* (a slot inside a paragraph) unless its line says
281
253
  * otherwise. A **block** island is one bundle of all three channels, in the
@@ -288,13 +260,12 @@ export type IslandOp =
288
260
  | ({ op: "insert"; at: number } & ContentIsland);
289
261
 
290
262
  /**
291
- * A committed content edit bundle for `applyChange`: a text `delta` (default no
292
- * text change), then `islandOps`, then `lineOps`, then `markOps` (mark ranges
293
- * are in final-text coordinates: every earlier channel applied). Every field is
294
- * optional.
263
+ * A committed content edit bundle for `applyChange`, applied in order: a text
264
+ * `delta`, then `islandOps`, then `lineOps`, then `markOps` (mark ranges are in
265
+ * final-text coordinates). Every field is optional.
295
266
  *
296
- * Within each channel ops apply in sequence, each against the state the earlier
297
- * ones left: an island `insert`'s `at` counts earlier ops' slots, and `lineOps`
267
+ * Within each channel ops apply in sequence against the state the earlier ones
268
+ * left: an island `insert`'s `at` counts earlier ops' slots, and `lineOps`
298
269
  * positions and indices renumber through earlier `split`/`join`.
299
270
  */
300
271
  export interface ChangeBundle {
@@ -322,14 +293,12 @@ export type DocPathSeg =
322
293
 
323
294
 
324
295
  /** The commitment-ladder rung that produced a `ResolvedField.value`. */
325
- export type FieldSource = "authored" | "default" | "zero";
296
+ export type FieldSource = "authored" | "default" | "blank";
326
297
 
327
298
  /**
328
299
  * One resolved row: its `name`, the value the render projection would use, and
329
- * the `FieldSource` rung it came from. Rows are an ordered array: declaration
330
- * order is structural, not object-key order. The card body is a `body` sibling
331
- * on its card, never a row in `fields`. Diagnostics stay `Quill.validate`'s;
332
- * schema guidance (`example:`, labels) reads from `Quill.schema`.
300
+ * the `FieldSource` rung it came from. Rows are an ordered array, so declaration
301
+ * order is structural rather than object-key order.
333
302
  */
334
303
  export interface ResolvedField {
335
304
  name: string;
@@ -359,9 +328,8 @@ export interface ResolvedCard {
359
328
  }
360
329
 
361
330
  /**
362
- * The resolved-value view (`Quill.resolve`): the main card and every
363
- * composable card. Value and provenance only: completeness and errors stay
364
- * `Quill.validate`.
331
+ * The resolved-value view (`Quill.resolve`): the main card and every composable
332
+ * card. Value and provenance only; completeness stays `Quill.validate`'s.
365
333
  */
366
334
  export interface Resolved {
367
335
  main: ResolvedMain;
@@ -370,20 +338,21 @@ export interface Resolved {
370
338
 
371
339
 
372
340
 
373
- /** UI layout hints for a single field. Field display order is not a hint:
374
- * key order in the schema's `fields`/`properties` objects is declaration
375
- * order, the ordering contract. */
341
+ /** UI layout hints for a single field. Display order is not a hint: key order
342
+ * in the schema's `fields`/`properties` objects is the ordering contract. */
376
343
  export interface QuillFieldUi {
377
344
  title?: string;
378
345
  group?: string;
379
346
  compact?: boolean;
380
347
  multiline?: boolean;
348
+ /** Label for an `enum`'s blank option. Absent, the consumer supplies a
349
+ * conventional label of its own. */
350
+ blank_title?: string;
381
351
  }
382
352
 
383
353
  /** One entry in a card's `ui.groups` registry: a display-label override for the
384
- * group id (the map key). An empty object carries no override: the consumer
385
- * derives the label from the id (`memo_for` → "Memo For"), as it does a field
386
- * label from its key. */
354
+ * group id (the map key). An empty object carries no override, and the consumer
355
+ * derives the label from the id (`memo_for` → "Memo For"). */
387
356
  export interface QuillGroupUi {
388
357
  title?: string;
389
358
  }
@@ -391,16 +360,14 @@ export interface QuillGroupUi {
391
360
  /** UI layout hints for a card (main or named card kind). */
392
361
  export interface QuillCardUi {
393
362
  title?: string;
394
- /** The card's group registry: the ordered table of contents naming every
395
- * group a field's `ui.group` may reference. The map key is the group id, and
396
- * key order is declaration order: the display-order contract, the same one
397
- * `fields` key order carries. Absent when the card declares no groups (or
398
- * uses the deprecated implicit-group form). */
363
+ /** The groups a field's `ui.group` may reference, keyed by group id. Key
364
+ * order is the display-order contract, as with `fields`. Absent when the
365
+ * card declares no groups. */
399
366
  groups?: Record<string, QuillGroupUi>;
400
367
  }
401
368
 
402
- /** A block construct a body can hold. `paragraph` is absent on purpose: it is
403
- * the floor and cannot be declined. */
369
+ /** A block construct a body can hold. `paragraph` is the floor and cannot be
370
+ * declined, so it is absent. */
404
371
  export type QuillBlockConstruct =
405
372
  | "heading"
406
373
  | "rule"
@@ -416,40 +383,38 @@ export interface QuillCardBody {
416
383
  enabled?: boolean;
417
384
  /** Example body content embedded verbatim in the blueprint body region. Fallback is "Write <card> body here." */
418
385
  example?: string;
419
- /** Block constructs this quill's plate does not typeset in this body.
420
- *
421
- * Absent or empty means it declines nothing, which is the default. An
422
- * editor reads this to decline a gesture before the author makes it; a body
423
- * that holds one anyway draws a non-fatal `plate::unsupported_construct`
424
- * warning carrying the construct and a count. It is the quill's claim about
425
- * its own plate, and nothing verifies it: a construct absent from this list
426
- * is not a promise that the plate typesets it. */
386
+ /** Block constructs this quill's plate does not typeset in this body;
387
+ * absent or empty declines nothing. A body that holds one anyway draws a
388
+ * non-fatal `plate::unsupported_construct` warning. Nothing verifies the
389
+ * claim: absence from this list is not a promise the plate typesets it. */
427
390
  unsupported?: QuillBlockConstruct[];
428
391
  }
429
392
 
430
393
  /** Schema entry for a single field declared in a quill's `Quill.yaml`.
431
394
  *
432
- * A field's *cell* is determined by `default`: a field with a `default`
433
- * is **Endorsed** (the rendered value is shippable as-is), while a field
434
- * without a `default` is **Unendorsed** (the blueprint carries a
435
- * `!must_fill` marker; a marker left in the document yields the non-fatal
436
- * `validation::must_fill` warning from validate, and the render path
437
- * zero-fills the field). There is no separate `required` axis.
395
+ * Two independent axes, and no separate `required` one. `default` and
396
+ * `example` say what the cell holds; `must_fill` says whether a human must
397
+ * author it, deriving from `default`'s absence when left unset. An obliged
398
+ * field carries a `!must_fill` marker in the blueprint and warns
399
+ * `validation::must_fill` while the document leaves it unauthored. Neither
400
+ * axis gates render: an absent field blank-fills.
438
401
  */
439
402
  export interface QuillFieldSchema {
440
403
  type: "string" | "number" | "integer" | "boolean" | "array" | "object" | "date" | "datetime" | "richtext" | "plaintext" | "enum";
441
404
  description?: string;
442
405
  default?: unknown;
443
406
  example?: unknown;
444
- /** Required on `type: "enum"`, and valid nowhere else: the closed set of
445
- * allowed string values. */
407
+ /** The closed set of allowed values. Required on `type: "enum"`, and valid
408
+ * nowhere else. */
446
409
  values?: string[];
410
+ /** Whether a human must author the field. Absent, it derives from
411
+ * `default`: a defaulted field is unobliged, a defaultless one obliged. */
412
+ must_fill?: boolean;
447
413
  ui?: QuillFieldUi;
448
414
  properties?: Record<string, QuillFieldSchema>;
449
415
  items?: QuillFieldSchema;
450
- /** Present (and `true`) on a `richtext` or `plaintext` field declared
451
- * `inline`: the single-paragraph, container-free, island-free constraint.
452
- * Core serializes `inline: true` into the schema JSON; absent otherwise. */
416
+ /** `true` on a `richtext` or `plaintext` field declared `inline`: the
417
+ * single-paragraph, container-free, island-free constraint. */
453
418
  inline?: boolean;
454
419
  }
455
420
 
@@ -462,10 +427,8 @@ export interface QuillCardSchema {
462
427
  }
463
428
 
464
429
  /**
465
- * Document schema returned by `Quill.schema`. Includes optional `ui` keys.
466
- *
467
- * Describes only the user-fillable fields. The quill reference
468
- * (constructed as `${metadata.name}@${metadata.version}`) and card-kind
430
+ * Document schema returned by `Quill.schema`: the user-fillable fields only.
431
+ * The quill reference (`${metadata.name}@${metadata.version}`) and card-kind
469
432
  * discriminators are document-level metadata, not schema fields.
470
433
  */
471
434
  export interface QuillSchema {
@@ -475,10 +438,9 @@ export interface QuillSchema {
475
438
  }
476
439
 
477
440
  /**
478
- * Identity snapshot mirroring the `quill:` section of `Quill.yaml`.
479
- * The schema lives on `Quill.schema`; the backend's output formats are a
480
- * resolved-backend capability read from the engine (`Quillmark.supportedFormats`),
481
- * not part of this pure-config snapshot.
441
+ * Identity snapshot mirroring the `quill:` section of `Quill.yaml`. The schema
442
+ * lives on `Quill.schema`; output formats are a resolved-backend capability read
443
+ * from `Quillmark.supportedFormats`, not part of this config snapshot.
482
444
  */
483
445
  export interface QuillMetadata {
484
446
  name: string;
@@ -498,31 +460,22 @@ export interface Diagnostic {
498
460
  message: string;
499
461
  location?: Location;
500
462
  /**
501
- * Document-model path anchor (e.g. `\"cards.indorsement[0].signature_block\"`).
502
- *
503
- * Set on schema validation diagnostics; `undefined` otherwise. See the
504
- * Rust `quillmark_core::error` module docs for the path grammar.
463
+ * Document-model path anchor (e.g. `\"cards.indorsement[0].signature_block\"`),
464
+ * set on schema validation diagnostics and `undefined` otherwise.
505
465
  */
506
466
  path?: string;
507
467
  hint?: string;
508
468
  /**
509
- * The facts `message` interpolates, keyed by name. With `code`, the
510
- * substitution unit needed to word this diagnostic in another language;
511
- * `prose/canon/ERROR.md` § \"Diagnostic args\" tabulates the keys per code.
469
+ * The facts `message` interpolates, keyed by name. With `code`, enough to
470
+ * word this diagnostic in another language.
512
471
  *
513
- * Declared optional explicitly because `tsify` does not read
514
- * `skip_serializing_if`: without this, a field the runtime omits is
515
- * declared required. `sourceChain` carries that mismatch.
472
+ * Declared optional explicitly: `tsify` does not read
473
+ * `skip_serializing_if`, so an omitted field would be declared required.
516
474
  */
517
475
  args?: Record<string, unknown>;
518
476
  sourceChain?: string[];
519
477
  }
520
478
 
521
- /**
522
- * Severity levels for diagnostics
523
- */
524
- export type Severity = "error" | "warning";
525
-
526
479
  /**
527
480
  * Source location for errors and warnings
528
481
  */
@@ -532,6 +485,8 @@ export interface Location {
532
485
  column: number;
533
486
  }
534
487
 
488
+ export type Severity = "error" | "warning";
489
+
535
490
 
536
491
  /**
537
492
  * Typed in-memory Quillmark document.
@@ -540,86 +495,69 @@ export class Document {
540
495
  free(): void;
541
496
  [Symbol.dispose](): void;
542
497
  /**
543
- * **Apply** a committed content edit `bundle`
544
- * (`{ delta?, islandOps?, lineOps?, markOps? }`) at `addr`, the editor
545
- * splice: text delta first, then island ops, then line ops, then mark ops
546
- * (mark ranges in final-text coordinates), each all-or-nothing. An absent
547
- * `addr.field` targets the body, an absent `addr.card` the main card.
548
- *
549
- * The island channel keeps a table or image edit on the op path: it moves
550
- * the island alone, so the anchors elsewhere in the field survive an edit
498
+ * **Apply** a committed content edit `bundle` at `addr`, the editor splice:
499
+ * text delta first, then island ops, then line ops, then mark ops (mark
500
+ * ranges in final-text coordinates), all-or-nothing. An absent `addr.field`
501
+ * targets the body, an absent `addr.card` the main card. The island channel
502
+ * moves an island alone, so anchors elsewhere in the field survive an edit
551
503
  * `overwrite` would clear.
552
504
  *
553
505
  * Throws on an out-of-range card, a field that is not richtext, a malformed
554
- * bundle, or an op that applies out of bounds (the value is unchanged on a
555
- * failed apply).
506
+ * bundle, or an op that applies out of bounds; the value is unchanged on a
507
+ * failed apply.
556
508
  */
557
509
  applyChange(addr: Addr | string, bundle: ChangeBundle): void;
558
510
  /**
559
- * Authoring-ergonomics header introducing a blueprint to an LLM/MCP
560
- * consumer for the given `quillName`. Re-exposes core's canonical text for
561
- * JS consumers; any surface that draws from the same core source stays
562
- * uniform.
511
+ * Authoring-ergonomics header introducing a blueprint to an LLM/MCP consumer
512
+ * for the given `quillName`, re-exposed from core.
563
513
  */
564
514
  static blueprintInstruction(quill_name: string): string;
565
515
  /**
566
- * The **body** markdown projection (the main body, or a composable card's
567
- * body (`{ card }`)) the on-demand, lossy export (content-only marks do not
568
- * survive markdown). A body's type is a format fact, not a schema fact, so
569
- * this read stays quill-free; a body is never absent.
516
+ * The **body** markdown projection: an on-demand, lossy export (content-only
517
+ * marks do not survive markdown). A body's type is a format fact, not a
518
+ * schema fact, so this read stays quill-free, and a body is never absent.
570
519
  *
571
- * `addr` is an optional **card address** (`{ card }`, absent = main). A
572
- * present `field` throws: a field's markdown is read through the
573
- * schema-plane `quill.reader(doc).get(field)`, which interprets by declared
574
- * type. An out-of-range `addr.card` throws.
520
+ * `addr` is an optional card address (absent = main). A present `field`
521
+ * throws: read a field's markdown through `quill.reader(doc).get(field)`,
522
+ * which interprets by declared type. An out-of-range `addr.card` throws.
575
523
  */
576
524
  bodyMarkdown(addr?: CardAddr): string;
577
525
  /**
578
- * A single composable card by index: the whole `Card`, the card-indexed
579
- * twin of the [`main`](Self::main) getter, so reading one card need not
580
- * materialize every card via [`cards`](Self::cards). An out-of-range
581
- * `index` throws `edit::index_out_of_range`, matching the card write
582
- * verbs.
526
+ * A single composable card by index, so reading one need not materialize
527
+ * every card via [`cards`](Self::cards). An out-of-range `index` throws
528
+ * `edit::index_out_of_range`.
583
529
  */
584
530
  card(index: number): Card;
585
531
  /**
586
- * The composable card's own path, `cards.<kind>[index]`: the whole-card
587
- * root [`pathFor`](Self::path_for) extends, for a consumer anchoring the
588
- * card rather than one of its fields. Total on the index axis for the same
589
- * reason, out of range renders `cards[index]`.
532
+ * The composable card's own path, `cards.<kind>[index]`: the root
533
+ * [`pathFor`](Self::path_for) extends, for anchoring the card rather than
534
+ * one of its fields. Total on the index axis; out of range renders
535
+ * `cards[index]`.
590
536
  */
591
537
  cardPath(index: number): string;
592
538
  clone(): Document;
593
539
  /**
594
- * Storage version this build writes via [`toJson`](Document::to_json).
595
- * Tracks the `Document` model version (not the running crate version):
596
- * the tag advances only when the wire format changes, not on every release.
540
+ * Storage version this build writes via [`toJson`](Document::to_json). The
541
+ * tag advances only when the wire format changes, not on every release.
597
542
  */
598
543
  static currentStorageVersion(): string;
599
544
  /**
600
- * Structural equality (parse-time `warnings` excluded). Use to debounce
601
- * upstream prop updates instead of re-parsing on every keystroke.
545
+ * Structural equality, excluding parse-time `warnings`.
602
546
  */
603
547
  equals(other: Document): boolean;
604
548
  /**
605
- * Render a Diagnostic as the canonical pretty-printed text (core's
606
- * `Diagnostic::fmt_pretty`). Single source of truth so a Diagnostic looks
607
- * identical no matter which consumer surfaces it.
549
+ * Render a Diagnostic as the canonical pretty-printed text, so it looks
550
+ * identical whichever consumer surfaces it.
608
551
  */
609
552
  static formatDiagnostic(diag: Diagnostic): string;
610
553
  /**
611
- * Authoring-format rules for the card-yaml markdown surface. The canonical
612
- * text is core's (`quillmark_core::document::FORMAT_RULES`), re-exposed
613
- * here for JS consumers so it matches any other surface that draws from the
614
- * same source. Read once at startup and cache; the value never changes
615
- * between calls.
554
+ * Authoring-format rules for the card-yaml markdown surface, re-exposed from
555
+ * core. Constant across calls; read once and cache.
616
556
  */
617
557
  static formatRules(): string;
618
558
  /**
619
- * Reconstruct a `Document` from a versioned storage DTO string produced
620
- * by [`toJson`](Document::to_json). Unknown `schema` tags are rejected.
621
- * The result carries no parse-time warnings (`.warnings` is always empty).
622
- *
559
+ * Reconstruct a `Document` from a versioned storage DTO string produced by
560
+ * [`toJson`](Document::to_json). The result carries no parse-time warnings.
623
561
  * Throws if `json` is not a valid storage DTO (malformed JSON, unknown
624
562
  * `schema`, missing fields, or unparseable quill reference).
625
563
  */
@@ -630,81 +568,66 @@ export class Document {
630
568
  static fromMarkdown(markdown: string): Document;
631
569
  /**
632
570
  * The whole `$ext` map at `addr` (a card address, absent `card` = main), or
633
- * `undefined` when the card carries none. The fine-grained `$ext` read:
634
- * your own state without serializing the whole card. Throws on a present
635
- * `field` (a card address takes only `card`) or an out-of-range card.
571
+ * `undefined` when the card carries none: the `$ext` read that avoids
572
+ * serializing the whole card. Throws on a present `field` or an
573
+ * out-of-range card.
636
574
  */
637
575
  getExt(addr?: CardAddr): Record<string, unknown> | undefined;
638
576
  /**
639
577
  * The value stored under `$ext[ns]` at `addr` (a card address, absent `card`
640
- * = main), or `undefined`. The namespace-scoped `$ext` read: your own slot
641
- * without a whole-card serialize, and non-destructive (unlike
642
- * `removeExtNamespace`). Throws on a present `field` or an out-of-range card.
578
+ * = main), or `undefined`. Throws on a present `field` or an out-of-range
579
+ * card.
643
580
  */
644
581
  getExtNamespace(addr: CardAddr, ns: string): unknown;
645
582
  /**
646
- * Read the **verbatim stored value** at `addr`: the raw payload value of a
647
- * field, or the **body content** when `addr.field` is absent. A bare
648
- * string is `Addr` shorthand for `{ field }`. Reads are total over the field
649
- * axis: an absent field is `undefined`; only an out-of-range `addr.card`
650
- * throws `edit::index_out_of_range`. Needs no schema, so it lives on
651
- * `Document`: the read echo of the verbatim `store*` write, distinct from
652
- * the interpreted schema-plane [`reader.get`](Self::reader_get). For the
653
- * markdown projection use [`bodyMarkdown`](Self::get_markdown) (body) or
654
- * `reader.get` (a field's declared type).
583
+ * Read the **verbatim stored value** at `addr`: a field's raw payload value,
584
+ * or the body content when `addr.field` is absent. A bare string is `Addr`
585
+ * shorthand for `{ field }`. Needs no schema: the read echo of the verbatim
586
+ * `store*` write, distinct from the interpreted
587
+ * [`reader.get`](Self::reader_get). Reads are total over the field axis — an
588
+ * absent field is `undefined` and only an out-of-range `addr.card` throws
589
+ * `edit::index_out_of_range`.
655
590
  *
656
- * **A content field at rest has one stored form per codec**: a `richtext`
657
- * field holds the canonical content object, a `plaintext` field its literal
658
- * string. A document that came through the bound door (`quill.parse` /
659
- * `quill.conform`) is at rest, so this read no longer depends on which lane
660
- * built it. A document that came through the transport door
661
- * (`Document.fromMarkdown`, a legacy stored row) may rest as authored until
662
- * it is conformed, and this read reports what is there. For the `Content`
663
- * either way, use the schema-plane `reader.getContent`, which decodes
664
- * through the codec the field's declared type names.
591
+ * A content field at rest has one stored form per codec: a `richtext` field
592
+ * holds the canonical content object, a `plaintext` field its literal
593
+ * string. A document from the bound door (`quill.parse` / `quill.conform`)
594
+ * is at rest; one from the transport door may rest as authored until it is
595
+ * conformed, and this read reports what is there. For the `Content` either
596
+ * way use `reader.getContent`.
665
597
  */
666
598
  getStored(addr: Addr | string): unknown;
667
599
  /**
668
- * Insert a card, the single insertion verb: `at` absent appends, a number
669
- * inserts at that index (must be in `0..=cards.length`). Accepts a
670
- * `CardInput`: a card read back (`cards` / `removeCard` / `quill.seedCard`),
671
- * a [`makeCard`](Document::make_card) result, or a bare `{ kind, body }`
672
- * (every returned `Card` is a valid `CardInput`). Throws if `card.kind` is
673
- * not a valid kind name, or if `at` is out of range.
600
+ * Insert a card: `at` absent appends, a number inserts at that index (in
601
+ * `0..=cards.length`). Accepts any `CardInput`, including a card read back
602
+ * out of a document. Throws if `card.kind` is not a valid kind name, or if
603
+ * `at` is out of range.
674
604
  */
675
605
  insertCard(card: CardInput, at?: number): void;
676
606
  /**
677
607
  * Whether the field at `addr` is marked `!must_fill`. A bare string is `Addr`
678
- * shorthand for `{ field }`. `false` for an absent field (truthful: it isn't
679
- * marked) and for a body address (a body is never a fill). Only an
680
- * out-of-range `addr.card` throws.
608
+ * shorthand for `{ field }`. `false` for an absent field and for a body
609
+ * address; only an out-of-range `addr.card` throws.
681
610
  */
682
611
  isFill(addr: Addr | string): boolean;
683
612
  /**
684
- * Replace this document's contents **in place** from a versioned storage
685
- * DTO string: the mutating twin of the static
686
- * [`fromJson`](Document::from_json) constructor. Parse-time `warnings` are
687
- * cleared. Throws (leaving the document unchanged) on an invalid DTO.
613
+ * Replace this document's contents **in place** from a versioned storage DTO
614
+ * string: the mutating twin of [`fromJson`](Document::from_json). Parse-time
615
+ * `warnings` are cleared. Throws on an invalid DTO, leaving the document
616
+ * unchanged.
688
617
  *
689
618
  * The cross-WASM-memory `Document` bridge: mutate a document on a
690
- * backend-memory clone, then write the mutated state back into the caller's
691
- * canonical document with this, the one way to update a live handle across
692
- * the linear-memory seam without the caller re-binding its variable.
619
+ * backend-memory clone, then write the state back into the caller's
620
+ * canonical document, without the caller re-binding its variable.
693
621
  */
694
622
  loadJson(json: string): void;
695
623
  /**
696
624
  * Build a fresh `Card` from a kind and a flat field map: the ergonomic
697
- * constructor for `insertCard`. `fields` is an optional
698
- * `Record<string, unknown>` (each entry becomes a card field, in
699
- * insertion order); `body` defaults to `""`.
625
+ * constructor for `insertCard`, which also takes any `Card` object
626
+ * directly. Each `fields` entry becomes a card field in insertion order;
627
+ * `body` defaults to `""`.
700
628
  *
701
- * Sugar, not a required step: `insertCard` takes any `Card` object, and
702
- * `removeCard` returns one, so a card round-trips without passing through
703
- * here.
704
- *
705
- * Checks only what a detached card can decide alone: field-name grammar
706
- * and value depth. Kind validity is positional (`main` is right for the
707
- * root, reserved for a composable card) so `insertCard` is its gate, and
629
+ * Checks only what a detached card can decide alone: field-name grammar and
630
+ * value depth. Kind validity is positional, so `insertCard` is its gate and
708
631
  * any kind string is accepted here.
709
632
  */
710
633
  static makeCard(kind: string, fields?: Record<string, unknown>, body?: string): Card;
@@ -713,66 +636,51 @@ export class Document {
713
636
  */
714
637
  moveCard(from: number, to: number): void;
715
638
  /**
716
- * `new Document(quillRef)`, a blank document: a main card carrying only
717
- * `$quill`, an empty body, and no composable cards. The programmatic
718
- * blank canvas: absent fields resolve at render time (`default`, else
719
- * type-empty zero), so nothing the caller did not set reaches the
720
- * output. For an example-filled starter use `Quill.seedDocument()`.
721
- * Throws on an invalid quill reference. Mirrors Python `Document(quill_ref)`.
639
+ * A blank document: a main card carrying only `$quill`, an empty body, and
640
+ * no composable cards. Absent fields resolve at render time (`default`, else
641
+ * the field's blank), so nothing the caller did not set reaches the output.
642
+ * For an example-filled starter use `Quill.seedDocument()`. Throws on an
643
+ * invalid quill reference.
722
644
  */
723
645
  constructor(quill_ref: string);
724
646
  /**
725
- * **Overwrite** the content value at `addr`: **value semantics**, content
726
- * only. Stores exactly `rt` (a canonical `Content` content object); the
727
- * identity anchors of any previous value are gone. The bottom rung of the
728
- * content lane's ladder by anchor fate: `overwrite` destroys,
729
- * [`revise`](Document::revise) rebases,
730
- * [`applyChange`](Document::apply_change) preserves. An absent `addr.field`
731
- * targets the body, an absent `addr.card` the main card. Cold-importing
732
- * markdown is spelled `overwrite(addr, importMarkdown(md))` at the call
733
- * site, where the anchor loss is visible.
647
+ * **Overwrite** the content value at `addr` with exactly `rt`: value
648
+ * semantics, so the identity anchors of any previous value are gone. By
649
+ * anchor fate `overwrite` destroys, [`revise`](Document::revise) rebases,
650
+ * and [`applyChange`](Document::apply_change) preserves. An absent
651
+ * `addr.field` targets the body, an absent `addr.card` the main card.
734
652
  *
735
653
  * Throws on an out-of-range card, a malformed field name, or an `rt` that is
736
654
  * not a canonical content object.
737
655
  */
738
656
  overwrite(addr: Addr | string, rt: Content): void;
739
657
  /**
740
- * `addr`'s canonical `DocPath` string, the anchor `Diagnostic.path`
741
- * carries: `pathFor()` is `main.body`, `pathFor("intro")` `main.intro`,
742
- * `pathFor({card: 2})` `cards.<kind>[2].body`. A consumer holding an
743
- * `Addr` mints one without restating the kind lookup, the `Addr` defaults
744
- * or the range guard.
658
+ * `addr`'s canonical `DocPath` string, the anchor `Diagnostic.path` carries:
659
+ * `pathFor()` is `main.body`, `pathFor("intro")` `main.intro`,
660
+ * `pathFor({card: 2})` `cards.<kind>[2].body`.
745
661
  *
746
- * The kind is the card's stored `$kind` verbatim, the quill-free rule the
747
- * addressed mutators anchor with and the geometry translation uses, not
748
- * `validate`'s declared-kind filter: a `Document` holds a `$quill`
749
- * reference and no schema. That is the one edge where this path and a
750
- * `validate` diagnostic path differ for the same card.
662
+ * The kind is the card's stored `$kind` verbatim, not `validate`'s
663
+ * declared-kind filter, since a `Document` holds a `$quill` reference and no
664
+ * schema. That is the one edge where this path and a `validate` diagnostic
665
+ * path differ for the same card.
751
666
  *
752
- * **Total on the index axis**, unlike the `Addr` reads (`getStored`,
753
- * `isFill`, `bodyMarkdown`), which throw there: a path is an anchor, not
754
- * a read. An out-of-range `{card: 7, field: "from"}` extends the
755
- * unknown-kind root `edit::index_out_of_range` anchors at, rendering
756
- * `cards[7].from`, which parses back and resolves to nothing rather than
757
- * mis-targeting. So a per-keystroke call needs no `try`; a caller wanting
758
- * a drop-it guard has [`cardCount`](Self::card_count). Only a malformed
759
- * address throws.
667
+ * **Total on the index axis**, unlike the `Addr` reads, which throw there:
668
+ * an out-of-range `{card: 7, field: "from"}` renders `cards[7].from`, which
669
+ * parses back and resolves to nothing rather than mis-targeting. Only a
670
+ * malformed address throws.
760
671
  */
761
672
  pathFor(addr: Addr | string): string;
762
673
  /**
763
- * The canonical `$quill` reference grammar as author-facing text. Core is
764
- * the single source of truth: drive schema `describe` and validation
765
- * messages from this instead of re-stating the rule; it matches the
766
- * `hint` on `parse::invalid_quill_reference`. Cache it; the value never
767
- * changes.
674
+ * The canonical `$quill` reference grammar as author-facing text: the same
675
+ * text the `parse::invalid_quill_reference` hint carries. Drive validation
676
+ * messages from this instead of re-stating the rule.
768
677
  */
769
678
  static quillRefHint(): string;
770
679
  removeCard(index: number): Card | undefined;
771
680
  /**
772
- * Remove the `$ext` map on the card `addr` targets *entirely*, returning the
773
- * previous map or `undefined`: a blunt escape hatch that discards every
774
- * namespace at once (prefer `removeExtNamespace`). `addr` is a card address
775
- * (absent = main). Throws on a present `field` or an out-of-range card.
681
+ * Remove the `$ext` map on the card `addr` targets entirely, returning the
682
+ * previous map or `undefined`. Discards every namespace at once; prefer
683
+ * `removeExtNamespace`. Throws on a present `field` or an out-of-range card.
776
684
  */
777
685
  removeExt(addr?: CardAddr): Record<string, unknown> | undefined;
778
686
  /**
@@ -784,35 +692,31 @@ export class Document {
784
692
  removeExtNamespace(addr: CardAddr, ns: string): any;
785
693
  /**
786
694
  * Remove a field at `addr`, returning the removed value or `undefined`. A
787
- * bare string is `Addr` shorthand for `{ field }`. One `remove` verb serves
788
- * every write lane. A body address throws; throws on an out-of-range card or
789
- * a malformed name.
695
+ * bare string is `Addr` shorthand for `{ field }`. A body address throws, as
696
+ * does an out-of-range card or a malformed name.
790
697
  */
791
698
  removeField(addr: Addr | string): any;
792
699
  /**
793
- * Remove `cardKind` from the main card's `$seed` map, returning its
794
- * overlay or `undefined`; drops `$seed` entirely once empty. Sibling kinds
795
- * survive. `$seed` is main-only, so this takes no address.
700
+ * Remove `cardKind` from the main card's `$seed` map, returning its overlay
701
+ * or `undefined`; drops `$seed` entirely once empty. Sibling kinds survive.
796
702
  */
797
703
  removeSeedOverlay(card_kind: string): any;
798
704
  /**
799
- * **Revise** the richtext value at `addr` from a markdown string: **edit
800
- * semantics**, the default write path, returning the text `Delta`. Imports
801
- * the markdown, diffs it against the current value, rebases surviving
802
- * identity anchors, and returns the change an editor bridge maps its own
803
- * positions through (`mapPos`). An absent `addr.field` targets the body, an
804
- * absent `addr.card` the main card; an absent field cold-imports from empty.
705
+ * **Revise** the richtext value at `addr` from a markdown string: the
706
+ * default write path. Imports the markdown, diffs it against the current
707
+ * value, rebases surviving identity anchors, and returns the text `Delta` an
708
+ * editor bridge maps its own positions through (`mapPos`). An absent
709
+ * `addr.field` targets the body, an absent `addr.card` the main card; an
710
+ * absent field cold-imports from empty.
805
711
  *
806
712
  * Throws on an out-of-range card, a malformed field name, a present
807
713
  * non-content field value, or an over-nested markdown input.
808
714
  */
809
715
  revise(addr: Addr | string, markdown: string): Delta;
810
716
  /**
811
- * The main card's `$seed` overlay object for `kind` (the `$seed[kind]`
812
- * entry), or `undefined` when absent. The cheap read that feeds
813
- * `quill.seedCard(kind, overlay)` without serializing the whole main card
814
- * via [`main`](Self::main) to fish out one key, and it keeps `seedCard`
815
- * pure: the quill still never reads the document.
717
+ * The main card's `$seed[kind]` overlay object, or `undefined`. Feeds
718
+ * `quill.seedCard(kind, overlay)` without serializing the whole main card,
719
+ * and keeps `seedCard` pure: the quill never reads the document.
816
720
  */
817
721
  seedOverlay(kind: string): Record<string, unknown> | undefined;
818
722
  /**
@@ -826,78 +730,60 @@ export class Document {
826
730
  */
827
731
  setQuillRef(ref_str: string): void;
828
732
  /**
829
- * Read the storage version tag from a raw storage DTO string without a
830
- * full parse, or `undefined`. Returns unknown future versions as-is:
831
- * useful to distinguish "build too old" from "payload corrupt" when
832
- * `fromJson` throws.
833
- *
834
- * The storage version, not a field schema ([`schema`](Quill::schema) is the
835
- * quill's field declarations). The JSON key is spelled `"schema"`: it is
836
- * the DTO's serde tag, and retagging it would break the version dispatch
837
- * it drives.
733
+ * Read the storage version tag from a raw storage DTO string without a full
734
+ * parse, or `undefined`. Unknown future versions come back as-is, which
735
+ * distinguishes "build too old" from "payload corrupt" when `fromJson`
736
+ * throws. This is the storage version, not a field schema, though the JSON
737
+ * key is spelled `"schema"`: that is the DTO's serde tag.
838
738
  */
839
739
  static storageVersionOf(json: string): string | undefined;
840
740
  /**
841
- * Replace the opaque `$ext` map on the card `addr` targets (a card address,
842
- * absent `card` = main). `value` must be a plain object. `$ext` carries
843
- * out-of-band consumer state and never reaches the rendered output; pass
844
- * `{}` for an explicit empty `$ext`. Quill-free and verbatim: an opaque
845
- * `store` verb. Throws on a present `field` or an out-of-range card.
741
+ * Replace the opaque `$ext` map on the card `addr` targets (absent `card` =
742
+ * main). `value` must be a plain object. `$ext` carries out-of-band consumer
743
+ * state and never reaches the rendered output. Throws on a present `field`
744
+ * or an out-of-range card.
846
745
  */
847
746
  storeExt(addr: CardAddr, value: any): void;
848
747
  /**
849
748
  * Merge `value` into `$ext[ns]` on the card `addr` targets, preserving
850
- * sibling namespaces: the recommended `$ext` write. `addr` is a card
851
- * address (absent = main). Quill-free and verbatim: an opaque `store` verb.
852
- * Throws on a present `field` or an out-of-range card.
749
+ * sibling namespaces: the recommended `$ext` write. Throws on a present
750
+ * `field` or an out-of-range card.
853
751
  */
854
752
  storeExtNamespace(addr: CardAddr, ns: string, value: any): void;
855
753
  /**
856
- * Store a field verbatim at `addr`: the opaque store (**store** = verbatim,
857
- * coercion deferred to render; the typed write is
858
- * [`commitField`](Document::commit_field)). A bare string is `Addr`
859
- * shorthand for `{ field }`, so `doc.storeField("qty", 3)` reads as written;
860
- * `{ card: 2, field: "qty" }` targets a composable card. Clears any
861
- * `!must_fill` marker. A body address (no `field`) throws: a body is never
862
- * opaque; write it with `revise` / `overwrite` / `writer.reviseBody`. Throws on
863
- * an out-of-range card or a malformed name.
754
+ * Store a field verbatim at `addr`, deferring coercion to render; the typed
755
+ * write is [`commitField`](Document::commit_field). A bare string is `Addr`
756
+ * shorthand for `{ field }`; `{ card: 2, field: "qty" }` targets a
757
+ * composable card. Clears any `!must_fill` marker. A body address throws:
758
+ * write a body with `revise` / `overwrite`. Throws on an out-of-range card
759
+ * or a malformed name.
864
760
  */
865
761
  storeField(addr: Addr | string, value: any): void;
866
762
  /**
867
- * Store several fields verbatim and atomically on the card `addr` targets:
868
- * the opaque store's batch. `addr` is a **card address** (`{ card }`, absent
869
- * = main); a present `field` throws. The batch verb takes the address first
870
- * and is never shape-overloaded, because `card` is a legal field name:
871
- * `storeFields({}, fields)` is the main card, `storeFields({ card: 2 },
872
- * fields)` a composable one, never ambiguous with "set field `card`".
873
- * Nothing is applied on error; the thrown error's `diagnostics` carry one
874
- * entry per offending field. Throws on an out-of-range card.
763
+ * Store several fields verbatim and atomically on the card `addr` targets.
764
+ * `addr` is a **card address** (`{ card }`, absent = main) and comes first
765
+ * because `card` is itself a legal field name; a present `field` throws.
766
+ * Nothing is applied on error, and the thrown error's `diagnostics` carry
767
+ * one entry per offending field. Throws on an out-of-range card.
875
768
  */
876
769
  storeFields(addr: CardAddr, fields: Record<string, unknown>): void;
877
770
  /**
878
- * Store a field verbatim at `addr` and mark it `!must_fill`: the opaque
879
- * store's fill variant, card-capable (a bare string or `{ field }` for main,
880
- * `{ card, field }` for a composable card). A body address throws. Same
881
- * validation as [`storeField`](Document::store_field).
771
+ * Store a field verbatim at `addr` and mark it `!must_fill`. A body address
772
+ * throws; same validation as [`storeField`](Document::store_field).
882
773
  */
883
774
  storeFill(addr: Addr | string, value: any): void;
884
775
  /**
885
776
  * Merge a card-kind's seed `overlay` into the **main** card's `$seed` map
886
- * under `cardKind`, preserving sibling kinds: `$seed` lives on the main
887
- * card by model, so this takes no address. Sets the starting values new
888
- * cards of that kind spawn with. Quill-free and verbatim: an opaque `store`
889
- * verb. Throws if `overlay` cannot be serialized or nests too deep.
777
+ * under `cardKind`, preserving sibling kinds; `$seed` is main-only, so this
778
+ * takes no address. Sets the starting values new cards of that kind spawn
779
+ * with. Throws if `overlay` cannot be serialized or nests too deep.
890
780
  */
891
781
  storeSeedOverlay(card_kind: string, overlay: any): void;
892
782
  /**
893
- * Serialize this document to a versioned storage DTO string.
894
- *
895
- * Prefer this over `toMarkdown` for persistence across restarts or crate
896
- * upgrades: the wire format is frozen per `schema` version. Parse-time
897
- * `warnings` are excluded from the DTO.
898
- *
899
- * Output is **byte-deterministic** within a `schema` version: equal
900
- * documents produce byte-equal output, safe for content-hash use cases.
783
+ * Serialize this document to a versioned storage DTO string. Prefer it over
784
+ * `toMarkdown` for persistence: the wire format is frozen per `schema`
785
+ * version and the output is byte-deterministic within one, so equal
786
+ * documents hash equal. Parse-time `warnings` are excluded.
901
787
  */
902
788
  toJson(): string;
903
789
  /**
@@ -906,29 +792,26 @@ export class Document {
906
792
  */
907
793
  toMarkdown(): string;
908
794
  /**
909
- * Like [`fromJson`](Document::from_json) but returns `undefined` instead
910
- * of throwing when `json` is not a valid storage DTO: use to
911
- * discriminate format without exceptions as control flow.
912
- * `undefined` means "not a storage DTO"; `fromMarkdown` still throws on
913
- * genuinely malformed markdown.
795
+ * Like [`fromJson`](Document::from_json) but returns `undefined` instead of
796
+ * throwing when `json` is not a valid storage DTO, to discriminate format
797
+ * without exceptions as control flow.
914
798
  */
915
799
  static tryFromJson(json: string): Document | undefined;
916
800
  /**
917
- * Number of composable cards (excludes the main card). O(1).
801
+ * Number of composable cards, excluding the main card.
918
802
  */
919
803
  readonly cardCount: number;
920
804
  readonly cards: Card[];
921
805
  /**
922
- * The document's main (entry) card. Allocates and serializes on each
923
- * call: cache locally if read in a hot loop.
806
+ * The document's main (entry) card. Allocates and serializes on each call.
924
807
  */
925
808
  readonly main: Card;
926
809
  readonly quillRef: string;
927
810
  /**
928
811
  * The non-fatal diagnostics of the load that produced this document: parse
929
- * warnings, plus the `conform::*` warnings when it came through
930
- * `quill.parse`. Session state, not document value: `equals` and the
931
- * storage DTO exclude it, and `fromJson` / `loadJson` clear it.
812
+ * warnings, plus `conform::*` warnings when it came through `quill.parse`.
813
+ * Session state, not document value: `equals` and the storage DTO exclude
814
+ * it, and `fromJson` / `loadJson` clear it.
932
815
  */
933
816
  readonly warnings: Diagnostic[];
934
817
  }
@@ -939,196 +822,152 @@ export class Quill {
939
822
  [Symbol.dispose](): void;
940
823
  /**
941
824
  * Land `doc`'s declared content fields at their canonical rest **in
942
- * place**, returning the `conform::*` diagnostics for the values that would
943
- * not commit (an empty array when everything rested).
825
+ * place**, returning the `conform::*` diagnostics for values that would not
826
+ * commit. The read-repair verb for a document that arrived through the
827
+ * transport door (`fromMarkdown`, `fromJson`, a stored row).
944
828
  *
945
- * The read-repair verb: a document that arrived through the transport door
946
- * (`fromMarkdown`, `fromJson`, a stored row) converges here, and is then
947
- * eligible for rewrite under its current schema tag. Idempotent, and a
948
- * no-op on an already-canonical document: an equal value is not rewritten,
949
- * so YAML comments and stored bytes survive.
950
- *
951
- * A `!must_fill` marker anywhere in a field's value skips that field (the
952
- * marker is the state), and a value the strict write refuses stays as
953
- * authored with a diagnostic. Throws when `doc` declares a different
954
- * `$quill`, before any mutation.
829
+ * Idempotent: an equal value is not rewritten, so YAML comments and stored
830
+ * bytes survive. A `!must_fill` marker anywhere in a field's value skips
831
+ * that field, and a value the strict write refuses stays as authored with a
832
+ * diagnostic. Throws when `doc` declares a different `$quill`, before any
833
+ * mutation.
955
834
  */
956
835
  conform(doc: Document): Diagnostic[];
957
836
  /**
958
- * Build a quill from a file tree. Pure: no backend, no engine; the
959
- * declared backend is resolved later, at render time.
960
- *
961
- * Accepts either a `Map<string, Uint8Array>` or a plain object
962
- * (`Record<string, Uint8Array>`). Plain objects are walked via
963
- * `Object.entries` at the boundary; the Rust side sees a single
964
- * canonical shape.
837
+ * Build a quill from a file tree. Pure: the declared backend is resolved
838
+ * later, at render time. Accepts a `Map<string, Uint8Array>` or a plain
839
+ * object.
965
840
  */
966
841
  static fromTree(tree: Map<string, Uint8Array>): Quill;
967
842
  /**
968
- * Parse `markdown` and conform it against this quill: the **primary
969
- * ingestion path**, and the bound twin of the schema-free
970
- * `Document.fromMarkdown`. The returned document rests at its canonical
971
- * form (a `richtext` field as a content object, a `plaintext` field as its
972
- * literal string), so `getStored` answers "content object or string?" by the
973
- * field's declared codec rather than by how the document was built.
843
+ * Parse `markdown` and conform it against this quill: the primary ingestion
844
+ * path, and the bound twin of the schema-free `Document.fromMarkdown`. The
845
+ * returned document rests at its canonical form (a `richtext` field as a
846
+ * content object, a `plaintext` field as its literal string), so `getStored`
847
+ * answers by the field's declared codec, not by how the document was built.
974
848
  *
975
849
  * Parse warnings and the `conform::*` diagnostics both land on
976
850
  * `doc.warnings`. Throws on a parse failure, or when `markdown` declares a
977
- * `$quill` this quill does not answer to: nothing conforms under the wrong
978
- * schema. To open a document whose `$quill` is stale, use the transport
979
- * door (`Document.fromMarkdown`, `setQuillRef`, then `quill.conform`).
851
+ * `$quill` this quill does not answer to. To open a document whose `$quill`
852
+ * is stale, use `Document.fromMarkdown`, `setQuillRef`, then `quill.conform`.
980
853
  */
981
854
  parse(markdown: string): Document;
982
855
  /**
983
- * The resolved-value view of `doc` against this quill's schema: for every
984
- * declared field the value the render projection would use and the
985
- * `FieldSource` rung it came from (`"authored" | "default" | "zero"`), in
986
- * one call. The card body is a `body` sibling on its card (row `name`
987
- * `"body"`), never a row in `fields`: `null` when the kind enables no body.
988
- *
989
- * Value and provenance only: completeness and errors stay `validate`'s
990
- * (a consumer merges it with its own diagnostic producers regardless), and
991
- * schema guidance reads from `Quill.schema`.
856
+ * The resolved-value view of `doc`: for every declared field, the value the
857
+ * render projection would use and the `FieldSource` rung it came from
858
+ * (`"authored" | "default" | "blank"`). The card body is a `body` sibling on
859
+ * its card, never a row in `fields`, and `null` when the kind enables no
860
+ * body. Value and provenance only; completeness stays `validate`'s.
992
861
  */
993
862
  resolve(doc: Document): Resolved;
994
863
  /**
995
864
  * Seed a starter composable `Card` of the given kind (carries `$kind`),
996
- * layering an optional per-kind seed `overlay` over the schema-example
997
- * base (`overlay › example › absent`). Returns `undefined` if `cardKind`
998
- * is not declared in this quill's schema, else a `Card` that feeds
999
- * straight into `Document.insertCard`.
865
+ * layering an optional per-kind seed `overlay` over the schema-example base
866
+ * (`overlay › example › absent`). `undefined` when `cardKind` is not
867
+ * declared in this quill's schema.
1000
868
  *
1001
869
  * Pass `document.seedOverlay(cardKind)` as `overlay` so a card added to a
1002
870
  * template-derived document inherits its curated starting values; omit it
1003
- * (or pass `undefined` / `null`) for the bare schema seed. `overlay` is a
1004
- * plain object: this reads the document, it does not mutate it.
871
+ * for the bare schema seed.
1005
872
  */
1006
873
  seedCard(card_kind: string, overlay: Record<string, unknown> | undefined): Card | undefined;
1007
874
  /**
1008
- * Seed a starter `Document` from the schema, the main card plus one
1009
- * instance of each composable card kind, each committing its fields'
1010
- * `example:` values and leaving every other field absent (interpolated at
1011
- * render: `default:`, else type-empty zero). Illustration-first: a field
1012
- * with both an `example` and a `default` renders its example. See
1013
- * `prose/canon/SCHEMAS.md` § "Document seeding".
875
+ * Seed a starter `Document` from the schema: the main card plus one instance
876
+ * of each composable card kind, each committing its fields' `example:`
877
+ * values and leaving every other field absent (interpolated at render as
878
+ * `default:`, else the field's blank). A field with both renders its example.
1014
879
  */
1015
880
  seedDocument(): Document;
1016
881
  /**
1017
882
  * Seed a starter main `Card` (carries `$quill`) from the schema: the
1018
- * `$kind: main` card of [`seedDocument`](Self::seed_document) in
1019
- * isolation, committing each field's `example:` value. Returns the same
1020
- * `Card` shape as the `Document.main` getter.
883
+ * `$kind: main` card of [`seedDocument`](Self::seed_document) alone.
1021
884
  */
1022
885
  seedMain(): Card;
1023
886
  /**
1024
- * Flatten this quill back into its canonical file tree: the inverse of
1025
- * [`fromTree`](Self::from_tree). Round-trips: `Quill.fromTree(q.toTree())`
1026
- * reproduces an equivalent quill.
887
+ * Flatten this quill back into its canonical file tree, the inverse of
888
+ * [`fromTree`](Self::from_tree). Keys are `"/"`-joined relative paths.
1027
889
  *
1028
890
  * This is how a quill crosses a WASM linear-memory boundary as data: a
1029
- * `Quill` built in one build (e.g. the Typst-less `@quillmark/wasm/core`)
1030
- * cannot be passed to an engine in another (separate linear memories), so
891
+ * `Quill` built in one build cannot be passed to an engine in another, so
1031
892
  * `@quillmark/wasm/runtime` re-feeds this tree to the backend build's
1032
- * `Quill.fromTree` on demand. Keys are `"/"`-joined relative paths,
1033
- * matching what `fromTree` accepts.
893
+ * `Quill.fromTree` on demand.
1034
894
  */
1035
895
  toTree(): Map<string, Uint8Array>;
1036
896
  /**
1037
897
  * Validate `doc` against this quill's schema, returning every diagnostic
1038
- * (an empty array when the document is valid).
1039
- *
1040
- * Forwards the canonical `validation::*` diagnostics (same `code`,
1041
- * `path`, and `hint` the engine emits) including the non-fatal
1042
- * `validation::must_fill` warning for each `!must_fill` marker left in
1043
- * the document. Field values, defaults, and order are not part of this
1044
- * surface: read them from the `Document` payload and `Quill.schema`
1045
- * (schema key order is display order).
898
+ * (empty when the document is valid). Forwards the canonical
899
+ * `validation::*` diagnostics the engine emits, including the non-fatal
900
+ * `validation::must_fill` warning per `!must_fill` marker left behind.
1046
901
  */
1047
902
  validate(doc: Document): Diagnostic[];
1048
903
  /**
1049
- * The *declared* backend identifier (`config.backend`, e.g. `"typst"`).
1050
- * Intent, not a resolved capability: capability (`supportedFormats` /
1051
- * `supportsCanvas`) is read from the engine.
904
+ * The *declared* backend identifier (e.g. `"typst"`): intent, not a
905
+ * resolved capability. Capability is read from the engine.
1052
906
  */
1053
907
  readonly backendId: string;
1054
908
  readonly blueprint: string;
1055
909
  /**
1056
910
  * Identity snapshot of the `quill:` section of `Quill.yaml` plus any extra
1057
- * `quill:` keys. Pure config: the backend's output formats are a
1058
- * resolved-backend capability read from the engine
1059
- * (`Quillmark.supportedFormats`), not part of this snapshot.
911
+ * `quill:` keys. Pure config: output formats are a resolved-backend
912
+ * capability read from `Quillmark.supportedFormats`, not part of this.
1060
913
  */
1061
914
  readonly metadata: QuillMetadata;
1062
915
  /**
1063
- * Document schema for the quill: the user-fillable fields plus their
1064
- * `ui` hints (title / group / compact / multiline). The single
1065
- * field-metadata surface: drives form editors and LLM/MCP consumers
1066
- * alike. Key order in `fields`/`properties` is declaration order: the
1067
- * ordering contract. Returns the `QuillSchema` shape.
916
+ * Document schema for the quill: the user-fillable fields plus their `ui`
917
+ * hints. Key order in `fields`/`properties` is declaration order, the
918
+ * ordering contract.
1068
919
  */
1069
920
  readonly schema: QuillSchema;
1070
921
  }
1071
922
 
1072
923
  /**
1073
- * Export a canonical `Content` content to its markdown projection: the pure
1074
- * on-demand codec behind `exportMarkdown(card.body)`. Throws if `rt` is not a
924
+ * Export canonical `Content` to its markdown projection. Throws if `rt` is not
1075
925
  * canonical content.
1076
926
  */
1077
927
  export function exportMarkdown(rt: Content): string;
1078
928
 
1079
929
  /**
1080
930
  * Serialize structured [`DocPathSeg`] segments back to the canonical path
1081
- * string: the inverse of `parseDocPath`, for a consumer that builds a path
1082
- * rather than reads one. Throws on a segment array the deserializer rejects,
1083
- * and on an empty segment array (symmetric with `parseDocPath("")`, which
1084
- * throws "empty path").
931
+ * string: the inverse of `parseDocPath`. Throws on a segment array the
932
+ * deserializer rejects, and on an empty one.
1085
933
  */
1086
934
  export function formatDocPath(segs: DocPathSeg[]): string;
1087
935
 
1088
936
  /**
1089
- * Import a markdown string to a canonical `Content` content: the pure,
1090
- * document-free codec. Pair with `overwrite(addr, importMarkdown(md))` to spell
1091
- * the cold (anchor-losing) write at the call site; prefer `revise` for edit
1092
- * semantics. Throws on an over-nested input.
937
+ * Import a markdown string to canonical `Content`: the pure, document-free
938
+ * codec. `overwrite(addr, importMarkdown(md))` spells the cold, anchor-losing
939
+ * write; prefer `revise` for edit semantics. Throws on an over-nested input.
1093
940
  */
1094
941
  export function importMarkdown(markdown: string): Content;
1095
942
 
1096
943
  /**
1097
944
  * Map a base content position (a USV index into `Content.text`, not a UTF-16
1098
- * offset) through a `delta` to its new USV position: the pure position-mapping
1099
- * codec an editor bridge composes to hold a caret stable across a `revise`.
1100
- * `assoc` decides the side of a same-position insertion (`"after"` moves past
1101
- * it). Throws on a malformed `delta`.
945
+ * offset) through a `delta` to its new position, holding a caret stable across
946
+ * a `revise`. `assoc` decides the side of a same-position insertion (`"after"`
947
+ * moves past it). Throws on a malformed `delta`.
1102
948
  */
1103
949
  export function mapPos(delta: Delta, pos: number, assoc: Assoc): number;
1104
950
 
1105
951
  /**
1106
- * Parse a canonical document-model `Diagnostic.path`
1107
- * (`cards.<kind>[<i>].<field>`, `main.body`, `recipients[0].name`) into its
1108
- * structured [`DocPathSeg`] segments: the exported inverse of the engine's
1109
- * one path serializer, so a consumer routes on segments instead of regexing
1110
- * the string. Throws on a malformed path.
952
+ * Parse a canonical document-model `Diagnostic.path` (`cards.<kind>[<i>].<field>`,
953
+ * `main.body`, `recipients[0].name`) into structured [`DocPathSeg`] segments, so
954
+ * a consumer routes on segments instead of regexing the string. Throws on a
955
+ * malformed path.
1111
956
  */
1112
957
  export function parseDocPath(path: string): DocPathSeg[];
1113
958
 
1114
959
  /**
1115
- * Rebase `markdown` onto a `base` content, the pure, document-free twin of
1116
- * `revise`: cold-import + `diff_import`, returning the new `content` and the
1117
- * text `delta` (its offsets USV indices into `Content.text`, surviving anchors
1118
- * rebased). Use it to compute a revise without a document in hand; `revise(addr,
1119
- * md)` fuses this with the store for atomicity. Throws on an over-nested
1120
- * markdown input or a non-content `base`.
960
+ * Rebase `markdown` onto a `base` content: the document-free twin of `revise`,
961
+ * returning the new `content` and the text `delta` (offsets are USV indices into
962
+ * `Content.text`, surviving anchors rebased). Throws on an over-nested markdown
963
+ * input or a non-content `base`.
1121
964
  */
1122
965
  export function rebase(base: Content, markdown: string): { content: Content; delta: Delta };
1123
966
 
1124
967
  /**
1125
- * Runs at instantiation (the wasm-bindgen start section): installs the panic
1126
- * hook, so a Rust panic reaches the console as a stack trace rather than
1127
- * `unreachable`.
1128
- *
1129
- * Not the package's `init`. That name belongs to the hand-written runtime,
1130
- * which owns instantiation itself (`runtime/runtime.js`); this runs as part of
1131
- * the instantiation it awaits.
968
+ * Runs at instantiation, so a Rust panic reaches the console as a stack trace
969
+ * rather than `unreachable`. Not the package's `init` that name belongs to
970
+ * the hand-written runtime, which owns instantiation itself.
1132
971
  */
1133
972
  export function start(): void;
1134
973
 
@@ -1143,6 +982,7 @@ export interface InitOutput {
1143
982
  readonly document__commitFields: (a: number, b: number, c: number, d: number, e: number) => void;
1144
983
  readonly document__readerGet: (a: number, b: number, c: number, d: number) => void;
1145
984
  readonly document__readerGetContent: (a: number, b: number, c: number, d: number) => void;
985
+ readonly document__readerGetContentAt: (a: number, b: number, c: number, d: number, e: number) => void;
1146
986
  readonly document__reviseField: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
1147
987
  readonly document_applyChange: (a: number, b: number, c: number, d: number) => void;
1148
988
  readonly document_blueprintInstruction: (a: number, b: number, c: number) => void;