@quillmark/wasm 0.103.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.js CHANGED
@@ -24,16 +24,12 @@ export class Document {
24
24
  /**
25
25
  * Build a composable card of `kind`, typed-commit `fields` onto it, set its
26
26
  * body from optional markdown, and place it: the ABI under `writer.addCard`.
27
- * `at` picks the position: absent appends, a number inserts at that index
28
- * (`0..=cards.length`), so a positioned typed insert is one atomic call
29
- * rather than `addCard` + `moveCard`. Fuses `makeCard` + typed commit +
30
- * insertion transactionally: the card is committed in full before it joins
31
- * the document, so a rejected field (or an invalid kind, body, or
32
- * out-of-range `at`) leaves the document untouched. Field errors throw the
33
- * same per-field diagnostic bundle as [`commitFields`](Self::commit_fields),
34
- * including an `edit::unknown_field` per undeclared name; an invalid
35
- * kind or body, or an out-of-range position, throws a single-entry bundle
36
- * keyed `$kind` / `$body`.
27
+ * `at` absent appends, a number inserts at that index (`0..=cards.length`).
28
+ * Transactional: the card is committed in full before it joins the document,
29
+ * so a rejected field (or an invalid kind, body, or out-of-range `at`)
30
+ * leaves the document untouched. Field errors throw the same per-field
31
+ * bundle as [`commitFields`](Self::commit_fields); an invalid kind or body,
32
+ * or a bad position, throws a single-entry bundle keyed `$kind` / `$body`.
37
33
  * @param {Quill} quill
38
34
  * @param {string} kind
39
35
  * @param {Record<string, unknown>} [fields]
@@ -60,26 +56,22 @@ export class Document {
60
56
  }
61
57
  /**
62
58
  * Typed field write at `addr`, resolving the field's schema `type` from
63
- * `quill`: the stable ABI under the runtime `writer.set` / `writer.card(i).set`.
64
- * The one write verb for **every** field type (richtext, scalar, array,
65
- * object); the schema carries the `inline` constraint, so no type token or
66
- * flag is passed. A richtext-typed field stores the canonical content, so
67
- * identity marks (anchors, island ids) and content-only marks (e.g.
68
- * `underline`) live on it and survive compiles and the storage DTO. Values
69
- * use the encoding the seam already speaks: a content object or markdown
70
- * string for richtext, a scalar/array/object otherwise.
59
+ * `quill`: the stable ABI under the runtime `writer.set`. One verb for every
60
+ * field type; the schema carries the `inline` constraint, so no type token
61
+ * is passed. A richtext-typed field stores canonical content, so identity
62
+ * marks (anchors, island ids) and content-only marks survive compiles and
63
+ * the storage DTO. Values use the encoding the seam already speaks: content
64
+ * object or markdown string for richtext, scalar/array/object otherwise.
71
65
  *
72
- * A bare string is `Addr` shorthand for `{ field }`; `{ card, field }`
73
- * targets a composable card (its `$kind` resolves the schema). A body
74
- * address throws: a body has no field schema; write it with `writer.reviseBody`
75
- * / `revise`. A field declared in the schema is strict-committed (a mismatch
76
- * throws now, not at render); a name the schema does not declare throws
77
- * `edit::unknown_field` rather than falling to the opaque store: on
78
- * the typed path it is a typo. Use [`storeField`](Document::store_field) for
79
- * opaque storage. Also throws `edit::field_coercion_failed` /
80
- * `edit::field_decode` / `edit::field_not_inline`
81
- * on a typed mismatch, `edit::invalid_field_name` on a malformed name,
82
- * and `edit::index_out_of_range` on an out-of-range card.
66
+ * A bare string is `Addr` shorthand for `{ field }`. A body address throws,
67
+ * having no field schema. A declared field is strict-committed, so a
68
+ * mismatch throws now rather than at render, and an undeclared name throws
69
+ * `edit::unknown_field` rather than falling to the opaque store use
70
+ * [`storeField`](Document::store_field) for that. Also throws
71
+ * `edit::field_coercion_failed` / `edit::field_decode` /
72
+ * `edit::field_not_inline` on a typed mismatch,
73
+ * `edit::invalid_field_name` on a malformed name, and
74
+ * `edit::index_out_of_range` on an out-of-range card.
83
75
  *
84
76
  * The `quill` handle is passed per call because a `Document` carries only a
85
77
  * `$quill` reference, not the resolved schema.
@@ -103,15 +95,12 @@ export class Document {
103
95
  }
104
96
  /**
105
97
  * Batched twin of [`commitField`](Document::commit_field): typed-commit
106
- * several fields on the card `addr` targets atomically, resolving each
107
- * field's schema `type` from `quill`. `addr` is a **card address**
108
- * (`{ card }`, absent = main; a present `field` throws). All-or-nothing with
109
- * the same per-field-diagnostic error contract as
110
- * [`storeFields`](Document::store_fields): nothing is applied on error and
111
- * the thrown error's `diagnostics` carry one entry per offending field,
112
- * including an `edit::unknown_field` for any name the schema does not
113
- * declare, so a whole-form submit sees every typo in one pass. Throws on an
114
- * out-of-range card.
98
+ * several fields on the card `addr` targets atomically. `addr` is a **card
99
+ * address** (absent = main; a present `field` throws). Same per-field
100
+ * diagnostic contract as [`storeFields`](Document::store_fields) nothing
101
+ * applied on error, one `diagnostics` entry per offending field, including
102
+ * `edit::unknown_field` for undeclared names. Throws on an out-of-range
103
+ * card.
115
104
  * @param {Quill} quill
116
105
  * @param {CardAddr} addr
117
106
  * @param {Record<string, unknown>} fields
@@ -132,21 +121,17 @@ export class Document {
132
121
  }
133
122
  /**
134
123
  * Interpreted read at `addr`, resolving the field's declared `type` from
135
- * `quill`: the stable ABI under the runtime `reader.get` / `reader.card(i).get`.
136
- * The schema-plane twin of the quill-free [`getStored`](Self::get_stored): a `richtext`
137
- * field returns its markdown projection, every other declared type its
138
- * canonical value verbatim, so a consumer holding the quill reads by field
139
- * meaning rather than by wire shape.
124
+ * `quill`: the stable ABI under the runtime `reader.get`. The schema-plane
125
+ * twin of [`getStored`](Self::get_stored) a `richtext` field returns its
126
+ * markdown projection, every other declared type its canonical value
127
+ * verbatim.
140
128
  *
141
129
  * A bare string is `Addr` shorthand for `{ field }`; `{ card, field }`
142
- * targets a composable card (its `$kind` resolves the schema). Returns
143
- * `undefined` for an **absent** field. An absent `addr.field` reads the body
144
- * markdown: quill-free, mirroring [`bodyMarkdown`](Self::get_markdown), since
145
- * a body's type is a format fact, not a schema fact. A name the schema does
146
- * not declare throws `edit::unknown_field` (the authority `bodyMarkdown`
147
- * lacks: there an unknown name reads back `undefined`); a `richtext` field
148
- * holding a value that does not decode throws `edit::field_decode`;
149
- * an out-of-range `addr.card` throws.
130
+ * targets a composable card. An **absent** field returns `undefined`, and an
131
+ * absent `addr.field` reads the body markdown. An undeclared name throws
132
+ * `edit::unknown_field` (the authority `bodyMarkdown` lacks), a `richtext`
133
+ * value that does not decode throws `edit::field_decode`, and an
134
+ * out-of-range `addr.card` throws.
150
135
  *
151
136
  * The `quill` handle is passed per call because a `Document` carries only a
152
137
  * `$quill` reference, not the resolved schema.
@@ -172,25 +157,19 @@ export class Document {
172
157
  }
173
158
  /**
174
159
  * Interpreted **`Content`** read at `addr`: the stable ABI under the runtime
175
- * `reader.getContent` / `reader.card(i).getContent`. The `Content` twin of
176
- * [`reader.get`](Self::reader_get), which projects; this decodes the stored
177
- * value through the codec the field's declared type names (`richtext` as
178
- * markdown, `plaintext` as literal text) and returns the canonical `Content`.
160
+ * `reader.getContent`. Where [`reader.get`](Self::reader_get) projects, this
161
+ * decodes the stored value through the codec the field's declared type names
162
+ * and returns canonical `Content`. Total over the storage form: a committed
163
+ * field and a parsed one both read back as a `Content`, so a content editor
164
+ * stops branching on how the document was built.
179
165
  *
180
- * Total over the storage form: a committed field holds a content object and
181
- * a parsed one holds the authored string, and both read back as a `Content`
182
- * here, so a consumer mounting a content editor stops branching on how the
183
- * document was built.
184
- *
185
- * A bare string is `Addr` shorthand for `{ field }`; `{ card, field }`
186
- * targets a composable card. Returns `undefined` for an **absent** field. An
187
- * absent `addr.field` reads the **body** `Content`, quill-free, mirroring
188
- * [`getStored`](Self::get_stored). Throws `edit::unknown_field` for a name
189
- * the schema does not declare, `edit::field_not_content` for a declared type
190
- * that is not a content leaf (`array<richtext>` carries content and still has
191
- * no one `Content`), `edit::field_decode` for a stored value
192
- * that decodes under neither encoding, and `edit::index_out_of_range` for a
193
- * bad `addr.card`.
166
+ * A bare string is `Addr` shorthand for `{ field }`. An **absent** field
167
+ * returns `undefined`, and an absent `addr.field` reads the body `Content`.
168
+ * Throws `edit::unknown_field` for an undeclared name,
169
+ * `edit::field_not_content` for a declared type that is not a content leaf
170
+ * (`array<richtext>` carries content and still has no one `Content`),
171
+ * `edit::field_decode` for a value that decodes under neither encoding, and
172
+ * `edit::index_out_of_range` for a bad `addr.card`.
194
173
  * @param {Quill} quill
195
174
  * @param {Addr | string} addr
196
175
  * @returns {Content | undefined}
@@ -212,23 +191,59 @@ export class Document {
212
191
  }
213
192
  }
214
193
  /**
215
- * Revise the content field at `addr` from authored text, typed *and*
216
- * anchor-preserving: the ABI under `writer.reviseField`. Resolves the
217
- * field's schema from `quill` (main card, or the addressed card's `$kind`)
218
- * and defers to [`TypedWriter::revise_field`](quillmark_core::TypedWriter::revise_field):
219
- * surviving anchors rebase (as [`revise`](Self::revise)), then the diffed
220
- * result is schema-conformed, so a `richtext(inline)` field rejects a
221
- * multi-block result with `edit::field_not_inline`. Returns the
222
- * text `Delta`.
194
+ * Interpreted **`Content`** read of a value nested inside the composite
195
+ * field at `addr`: the stable ABI under the runtime `reader.getContentAt`,
196
+ * and [`reader.getContent`](Self::reader_get_content) with the path spelled
197
+ * out. `path` is a `PathStep[]` from the field to the leaf — `[0]` an
198
+ * element of an `array<richtext>`, `["motto"]` an `object`'s content
199
+ * property, `[1, "notes"]` a leaf under both.
223
200
  *
224
- * The codec is the declared type's: `richtext` diffs markdown, `plaintext`
225
- * the literal text.
201
+ * The codec is the leaf's declared type's, so the caller stops deciding
202
+ * what an element's stored bytes mean. Total over the storage form, as the
203
+ * whole-field read is.
226
204
  *
227
- * `addr` must name a field (a bare string is `{ field }`); a body address
228
- * throws (a body carries no field schema: use [`revise`](Self::revise)). A
229
- * name the schema does not declare throws `edit::unknown_field`. Throws
230
- * on an out-of-range card. Hidden from the `.d.ts`; the visible verb is
231
- * `writer.reviseField` in the runtime layer.
205
+ * `undefined` when the field is absent **and when `path` names nothing in
206
+ * the stored value**: a repeater's row index goes stale between derive and
207
+ * read, and absence there is a read, not a fault. Throws
208
+ * `edit::unknown_field` for an undeclared name at any depth,
209
+ * `edit::field_not_content` when `path` resolves to no content leaf,
210
+ * `edit::field_decode` for a value that decodes under neither encoding
211
+ * (anchored at the addressed path), and `edit::index_out_of_range` for a
212
+ * bad `addr.card`. A body address throws: a body has no nested content
213
+ * address.
214
+ * @param {Quill} quill
215
+ * @param {Addr | string} addr
216
+ * @param {PathStep[]} path
217
+ * @returns {Content | undefined}
218
+ */
219
+ _readerGetContentAt(quill, addr, path) {
220
+ try {
221
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
222
+ _assertClass(quill, Quill);
223
+ wasm.document__readerGetContentAt(retptr, this.__wbg_ptr, quill.__wbg_ptr, addHeapObject(addr), addHeapObject(path));
224
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
225
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
226
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
227
+ if (r2) {
228
+ throw takeObject(r1);
229
+ }
230
+ return takeObject(r0);
231
+ } finally {
232
+ wasm.__wbindgen_add_to_stack_pointer(16);
233
+ }
234
+ }
235
+ /**
236
+ * Revise the content field at `addr` from authored text, typed *and*
237
+ * anchor-preserving: the ABI under `writer.reviseField`. Surviving anchors
238
+ * rebase as in [`revise`](Self::revise), then the diffed result is
239
+ * schema-conformed, so a `richtext(inline)` field rejects a multi-block
240
+ * result with `edit::field_not_inline`. Returns the text `Delta`. The codec
241
+ * is the declared type's: `richtext` diffs markdown, `plaintext` literal
242
+ * text.
243
+ *
244
+ * `addr` must name a field; a body address throws, since a body carries no
245
+ * field schema (use [`revise`](Self::revise)). An undeclared name throws
246
+ * `edit::unknown_field`, an out-of-range card throws.
232
247
  * @param {Quill} quill
233
248
  * @param {Addr | string} addr
234
249
  * @param {string} text
@@ -253,19 +268,16 @@ export class Document {
253
268
  }
254
269
  }
255
270
  /**
256
- * **Apply** a committed content edit `bundle`
257
- * (`{ delta?, islandOps?, lineOps?, markOps? }`) at `addr`, the editor
258
- * splice: text delta first, then island ops, then line ops, then mark ops
259
- * (mark ranges in final-text coordinates), each all-or-nothing. An absent
260
- * `addr.field` targets the body, an absent `addr.card` the main card.
261
- *
262
- * The island channel keeps a table or image edit on the op path: it moves
263
- * the island alone, so the anchors elsewhere in the field survive an edit
271
+ * **Apply** a committed content edit `bundle` at `addr`, the editor splice:
272
+ * text delta first, then island ops, then line ops, then mark ops (mark
273
+ * ranges in final-text coordinates), all-or-nothing. An absent `addr.field`
274
+ * targets the body, an absent `addr.card` the main card. The island channel
275
+ * moves an island alone, so anchors elsewhere in the field survive an edit
264
276
  * `overwrite` would clear.
265
277
  *
266
278
  * Throws on an out-of-range card, a field that is not richtext, a malformed
267
- * bundle, or an op that applies out of bounds (the value is unchanged on a
268
- * failed apply).
279
+ * bundle, or an op that applies out of bounds; the value is unchanged on a
280
+ * failed apply.
269
281
  * @param {Addr | string} addr
270
282
  * @param {ChangeBundle} bundle
271
283
  */
@@ -283,10 +295,8 @@ export class Document {
283
295
  }
284
296
  }
285
297
  /**
286
- * Authoring-ergonomics header introducing a blueprint to an LLM/MCP
287
- * consumer for the given `quillName`. Re-exposes core's canonical text for
288
- * JS consumers; any surface that draws from the same core source stays
289
- * uniform.
298
+ * Authoring-ergonomics header introducing a blueprint to an LLM/MCP consumer
299
+ * for the given `quillName`, re-exposed from core.
290
300
  * @param {string} quill_name
291
301
  * @returns {string}
292
302
  */
@@ -309,15 +319,13 @@ export class Document {
309
319
  }
310
320
  }
311
321
  /**
312
- * The **body** markdown projection (the main body, or a composable card's
313
- * body (`{ card }`)) the on-demand, lossy export (content-only marks do not
314
- * survive markdown). A body's type is a format fact, not a schema fact, so
315
- * this read stays quill-free; a body is never absent.
322
+ * The **body** markdown projection: an on-demand, lossy export (content-only
323
+ * marks do not survive markdown). A body's type is a format fact, not a
324
+ * schema fact, so this read stays quill-free, and a body is never absent.
316
325
  *
317
- * `addr` is an optional **card address** (`{ card }`, absent = main). A
318
- * present `field` throws: a field's markdown is read through the
319
- * schema-plane `quill.reader(doc).get(field)`, which interprets by declared
320
- * type. An out-of-range `addr.card` throws.
326
+ * `addr` is an optional card address (absent = main). A present `field`
327
+ * throws: read a field's markdown through `quill.reader(doc).get(field)`,
328
+ * which interprets by declared type. An out-of-range `addr.card` throws.
321
329
  * @param {CardAddr} [addr]
322
330
  * @returns {string}
323
331
  */
@@ -337,11 +345,9 @@ export class Document {
337
345
  }
338
346
  }
339
347
  /**
340
- * A single composable card by index: the whole `Card`, the card-indexed
341
- * twin of the [`main`](Self::main) getter, so reading one card need not
342
- * materialize every card via [`cards`](Self::cards). An out-of-range
343
- * `index` throws `edit::index_out_of_range`, matching the card write
344
- * verbs.
348
+ * A single composable card by index, so reading one need not materialize
349
+ * every card via [`cards`](Self::cards). An out-of-range `index` throws
350
+ * `edit::index_out_of_range`.
345
351
  * @param {number} index
346
352
  * @returns {Card}
347
353
  */
@@ -361,13 +367,37 @@ export class Document {
361
367
  }
362
368
  }
363
369
  /**
364
- * Number of composable cards (excludes the main card). O(1).
370
+ * Number of composable cards, excluding the main card.
365
371
  * @returns {number}
366
372
  */
367
373
  get cardCount() {
368
374
  const ret = wasm.document_cardCount(this.__wbg_ptr);
369
375
  return ret >>> 0;
370
376
  }
377
+ /**
378
+ * The composable card's own path, `cards.<kind>[index]`: the root
379
+ * [`pathFor`](Self::path_for) extends, for anchoring the card rather than
380
+ * one of its fields. Total on the index axis; out of range renders
381
+ * `cards[index]`.
382
+ * @param {number} index
383
+ * @returns {string}
384
+ */
385
+ cardPath(index) {
386
+ let deferred1_0;
387
+ let deferred1_1;
388
+ try {
389
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
390
+ wasm.document_cardPath(retptr, this.__wbg_ptr, index);
391
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
392
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
393
+ deferred1_0 = r0;
394
+ deferred1_1 = r1;
395
+ return getStringFromWasm0(r0, r1);
396
+ } finally {
397
+ wasm.__wbindgen_add_to_stack_pointer(16);
398
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
399
+ }
400
+ }
371
401
  /**
372
402
  * @returns {Card[]}
373
403
  */
@@ -394,9 +424,8 @@ export class Document {
394
424
  return Document.__wrap(ret);
395
425
  }
396
426
  /**
397
- * Storage version this build writes via [`toJson`](Document::to_json).
398
- * Tracks the `Document` model version (not the running crate version):
399
- * the tag advances only when the wire format changes, not on every release.
427
+ * Storage version this build writes via [`toJson`](Document::to_json). The
428
+ * tag advances only when the wire format changes, not on every release.
400
429
  * @returns {string}
401
430
  */
402
431
  static currentStorageVersion() {
@@ -416,8 +445,7 @@ export class Document {
416
445
  }
417
446
  }
418
447
  /**
419
- * Structural equality (parse-time `warnings` excluded). Use to debounce
420
- * upstream prop updates instead of re-parsing on every keystroke.
448
+ * Structural equality, excluding parse-time `warnings`.
421
449
  * @param {Document} other
422
450
  * @returns {boolean}
423
451
  */
@@ -427,9 +455,8 @@ export class Document {
427
455
  return ret !== 0;
428
456
  }
429
457
  /**
430
- * Render a Diagnostic as the canonical pretty-printed text (core's
431
- * `Diagnostic::fmt_pretty`). Single source of truth so a Diagnostic looks
432
- * identical no matter which consumer surfaces it.
458
+ * Render a Diagnostic as the canonical pretty-printed text, so it looks
459
+ * identical whichever consumer surfaces it.
433
460
  * @param {Diagnostic} diag
434
461
  * @returns {string}
435
462
  */
@@ -450,11 +477,8 @@ export class Document {
450
477
  }
451
478
  }
452
479
  /**
453
- * Authoring-format rules for the card-yaml markdown surface. The canonical
454
- * text is core's (`quillmark_core::document::FORMAT_RULES`), re-exposed
455
- * here for JS consumers so it matches any other surface that draws from the
456
- * same source. Read once at startup and cache; the value never changes
457
- * between calls.
480
+ * Authoring-format rules for the card-yaml markdown surface, re-exposed from
481
+ * core. Constant across calls; read once and cache.
458
482
  * @returns {string}
459
483
  */
460
484
  static formatRules() {
@@ -474,10 +498,8 @@ export class Document {
474
498
  }
475
499
  }
476
500
  /**
477
- * Reconstruct a `Document` from a versioned storage DTO string produced
478
- * by [`toJson`](Document::to_json). Unknown `schema` tags are rejected.
479
- * The result carries no parse-time warnings (`.warnings` is always empty).
480
- *
501
+ * Reconstruct a `Document` from a versioned storage DTO string produced by
502
+ * [`toJson`](Document::to_json). The result carries no parse-time warnings.
481
503
  * Throws if `json` is not a valid storage DTO (malformed JSON, unknown
482
504
  * `schema`, missing fields, or unparseable quill reference).
483
505
  * @param {string} json
@@ -524,9 +546,9 @@ export class Document {
524
546
  }
525
547
  /**
526
548
  * The whole `$ext` map at `addr` (a card address, absent `card` = main), or
527
- * `undefined` when the card carries none. The fine-grained `$ext` read:
528
- * your own state without serializing the whole card. Throws on a present
529
- * `field` (a card address takes only `card`) or an out-of-range card.
549
+ * `undefined` when the card carries none: the `$ext` read that avoids
550
+ * serializing the whole card. Throws on a present `field` or an
551
+ * out-of-range card.
530
552
  * @param {CardAddr} [addr]
531
553
  * @returns {Record<string, unknown> | undefined}
532
554
  */
@@ -547,9 +569,8 @@ export class Document {
547
569
  }
548
570
  /**
549
571
  * The value stored under `$ext[ns]` at `addr` (a card address, absent `card`
550
- * = main), or `undefined`. The namespace-scoped `$ext` read: your own slot
551
- * without a whole-card serialize, and non-destructive (unlike
552
- * `removeExtNamespace`). Throws on a present `field` or an out-of-range card.
572
+ * = main), or `undefined`. Throws on a present `field` or an out-of-range
573
+ * card.
553
574
  * @param {CardAddr} addr
554
575
  * @param {string} ns
555
576
  * @returns {unknown}
@@ -572,25 +593,20 @@ export class Document {
572
593
  }
573
594
  }
574
595
  /**
575
- * Read the **verbatim stored value** at `addr`: the raw payload value of a
576
- * field, or the **body content** when `addr.field` is absent. A bare
577
- * string is `Addr` shorthand for `{ field }`. Reads are total over the field
578
- * axis: an absent field is `undefined`; only an out-of-range `addr.card`
579
- * throws `edit::index_out_of_range`. Needs no schema, so it lives on
580
- * `Document`: the read echo of the verbatim `store*` write, distinct from
581
- * the interpreted schema-plane [`reader.get`](Self::reader_get). For the
582
- * markdown projection use [`bodyMarkdown`](Self::get_markdown) (body) or
583
- * `reader.get` (a field's declared type).
596
+ * Read the **verbatim stored value** at `addr`: a field's raw payload value,
597
+ * or the body content when `addr.field` is absent. A bare string is `Addr`
598
+ * shorthand for `{ field }`. Needs no schema: the read echo of the verbatim
599
+ * `store*` write, distinct from the interpreted
600
+ * [`reader.get`](Self::reader_get). Reads are total over the field axis — an
601
+ * absent field is `undefined` and only an out-of-range `addr.card` throws
602
+ * `edit::index_out_of_range`.
584
603
  *
585
- * **A content field at rest has one stored form per codec**: a `richtext`
586
- * field holds the canonical content object, a `plaintext` field its literal
587
- * string. A document that came through the bound door (`quill.parse` /
588
- * `quill.conform`) is at rest, so this read no longer depends on which lane
589
- * built it. A document that came through the transport door
590
- * (`Document.fromMarkdown`, a legacy stored row) may rest as authored until
591
- * it is conformed, and this read reports what is there. For the `Content`
592
- * either way, use the schema-plane `reader.getContent`, which decodes
593
- * through the codec the field's declared type names.
604
+ * A content field at rest has one stored form per codec: a `richtext` field
605
+ * holds the canonical content object, a `plaintext` field its literal
606
+ * string. A document from the bound door (`quill.parse` / `quill.conform`)
607
+ * is at rest; one from the transport door may rest as authored until it is
608
+ * conformed, and this read reports what is there. For the `Content` either
609
+ * way use `reader.getContent`.
594
610
  * @param {Addr | string} addr
595
611
  * @returns {unknown}
596
612
  */
@@ -610,12 +626,10 @@ export class Document {
610
626
  }
611
627
  }
612
628
  /**
613
- * Insert a card, the single insertion verb: `at` absent appends, a number
614
- * inserts at that index (must be in `0..=cards.length`). Accepts a
615
- * `CardInput`: a card read back (`cards` / `removeCard` / `quill.seedCard`),
616
- * a [`makeCard`](Document::make_card) result, or a bare `{ kind, body }`
617
- * (every returned `Card` is a valid `CardInput`). Throws if `card.kind` is
618
- * not a valid kind name, or if `at` is out of range.
629
+ * Insert a card: `at` absent appends, a number inserts at that index (in
630
+ * `0..=cards.length`). Accepts any `CardInput`, including a card read back
631
+ * out of a document. Throws if `card.kind` is not a valid kind name, or if
632
+ * `at` is out of range.
619
633
  * @param {CardInput} card
620
634
  * @param {number} [at]
621
635
  */
@@ -634,9 +648,8 @@ export class Document {
634
648
  }
635
649
  /**
636
650
  * Whether the field at `addr` is marked `!must_fill`. A bare string is `Addr`
637
- * shorthand for `{ field }`. `false` for an absent field (truthful: it isn't
638
- * marked) and for a body address (a body is never a fill). Only an
639
- * out-of-range `addr.card` throws.
651
+ * shorthand for `{ field }`. `false` for an absent field and for a body
652
+ * address; only an out-of-range `addr.card` throws.
640
653
  * @param {Addr | string} addr
641
654
  * @returns {boolean}
642
655
  */
@@ -656,15 +669,14 @@ export class Document {
656
669
  }
657
670
  }
658
671
  /**
659
- * Replace this document's contents **in place** from a versioned storage
660
- * DTO string: the mutating twin of the static
661
- * [`fromJson`](Document::from_json) constructor. Parse-time `warnings` are
662
- * cleared. Throws (leaving the document unchanged) on an invalid DTO.
672
+ * Replace this document's contents **in place** from a versioned storage DTO
673
+ * string: the mutating twin of [`fromJson`](Document::from_json). Parse-time
674
+ * `warnings` are cleared. Throws on an invalid DTO, leaving the document
675
+ * unchanged.
663
676
  *
664
677
  * The cross-WASM-memory `Document` bridge: mutate a document on a
665
- * backend-memory clone, then write the mutated state back into the caller's
666
- * canonical document with this, the one way to update a live handle across
667
- * the linear-memory seam without the caller re-binding its variable.
678
+ * backend-memory clone, then write the state back into the caller's
679
+ * canonical document, without the caller re-binding its variable.
668
680
  * @param {string} json
669
681
  */
670
682
  loadJson(json) {
@@ -683,8 +695,7 @@ export class Document {
683
695
  }
684
696
  }
685
697
  /**
686
- * The document's main (entry) card. Allocates and serializes on each
687
- * call: cache locally if read in a hot loop.
698
+ * The document's main (entry) card. Allocates and serializes on each call.
688
699
  * @returns {Card}
689
700
  */
690
701
  get main() {
@@ -704,17 +715,12 @@ export class Document {
704
715
  }
705
716
  /**
706
717
  * Build a fresh `Card` from a kind and a flat field map: the ergonomic
707
- * constructor for `insertCard`. `fields` is an optional
708
- * `Record<string, unknown>` (each entry becomes a card field, in
709
- * insertion order); `body` defaults to `""`.
710
- *
711
- * Sugar, not a required step: `insertCard` takes any `Card` object, and
712
- * `removeCard` returns one, so a card round-trips without passing through
713
- * here.
718
+ * constructor for `insertCard`, which also takes any `Card` object
719
+ * directly. Each `fields` entry becomes a card field in insertion order;
720
+ * `body` defaults to `""`.
714
721
  *
715
- * Checks only what a detached card can decide alone: field-name grammar
716
- * and value depth. Kind validity is positional (`main` is right for the
717
- * root, reserved for a composable card) so `insertCard` is its gate, and
722
+ * Checks only what a detached card can decide alone: field-name grammar and
723
+ * value depth. Kind validity is positional, so `insertCard` is its gate and
718
724
  * any kind string is accepted here.
719
725
  * @param {string} kind
720
726
  * @param {Record<string, unknown>} [fields]
@@ -759,12 +765,11 @@ export class Document {
759
765
  }
760
766
  }
761
767
  /**
762
- * `new Document(quillRef)`, a blank document: a main card carrying only
763
- * `$quill`, an empty body, and no composable cards. The programmatic
764
- * blank canvas: absent fields resolve at render time (`default`, else
765
- * type-empty zero), so nothing the caller did not set reaches the
766
- * output. For an example-filled starter use `Quill.seedDocument()`.
767
- * Throws on an invalid quill reference. Mirrors Python `Document(quill_ref)`.
768
+ * A blank document: a main card carrying only `$quill`, an empty body, and
769
+ * no composable cards. Absent fields resolve at render time (`default`, else
770
+ * the field's blank), so nothing the caller did not set reaches the output.
771
+ * For an example-filled starter use `Quill.seedDocument()`. Throws on an
772
+ * invalid quill reference.
768
773
  * @param {string} quill_ref
769
774
  */
770
775
  constructor(quill_ref) {
@@ -787,15 +792,11 @@ export class Document {
787
792
  }
788
793
  }
789
794
  /**
790
- * **Overwrite** the content value at `addr`: **value semantics**, content
791
- * only. Stores exactly `rt` (a canonical `Content` content object); the
792
- * identity anchors of any previous value are gone. The bottom rung of the
793
- * content lane's ladder by anchor fate: `overwrite` destroys,
794
- * [`revise`](Document::revise) rebases,
795
- * [`applyChange`](Document::apply_change) preserves. An absent `addr.field`
796
- * targets the body, an absent `addr.card` the main card. Cold-importing
797
- * markdown is spelled `overwrite(addr, importMarkdown(md))` at the call
798
- * site, where the anchor loss is visible.
795
+ * **Overwrite** the content value at `addr` with exactly `rt`: value
796
+ * semantics, so the identity anchors of any previous value are gone. By
797
+ * anchor fate `overwrite` destroys, [`revise`](Document::revise) rebases,
798
+ * and [`applyChange`](Document::apply_change) preserves. An absent
799
+ * `addr.field` targets the body, an absent `addr.card` the main card.
799
800
  *
800
801
  * Throws on an out-of-range card, a malformed field name, or an `rt` that is
801
802
  * not a canonical content object.
@@ -815,6 +816,47 @@ export class Document {
815
816
  wasm.__wbindgen_add_to_stack_pointer(16);
816
817
  }
817
818
  }
819
+ /**
820
+ * `addr`'s canonical `DocPath` string, the anchor `Diagnostic.path` carries:
821
+ * `pathFor()` is `main.body`, `pathFor("intro")` `main.intro`,
822
+ * `pathFor({card: 2})` `cards.<kind>[2].body`.
823
+ *
824
+ * The kind is the card's stored `$kind` verbatim, not `validate`'s
825
+ * declared-kind filter, since a `Document` holds a `$quill` reference and no
826
+ * schema. That is the one edge where this path and a `validate` diagnostic
827
+ * path differ for the same card.
828
+ *
829
+ * **Total on the index axis**, unlike the `Addr` reads, which throw there:
830
+ * an out-of-range `{card: 7, field: "from"}` renders `cards[7].from`, which
831
+ * parses back and resolves to nothing rather than mis-targeting. Only a
832
+ * malformed address throws.
833
+ * @param {Addr | string} addr
834
+ * @returns {string}
835
+ */
836
+ pathFor(addr) {
837
+ let deferred2_0;
838
+ let deferred2_1;
839
+ try {
840
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
841
+ wasm.document_pathFor(retptr, this.__wbg_ptr, addHeapObject(addr));
842
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
843
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
844
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
845
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
846
+ var ptr1 = r0;
847
+ var len1 = r1;
848
+ if (r3) {
849
+ ptr1 = 0; len1 = 0;
850
+ throw takeObject(r2);
851
+ }
852
+ deferred2_0 = ptr1;
853
+ deferred2_1 = len1;
854
+ return getStringFromWasm0(ptr1, len1);
855
+ } finally {
856
+ wasm.__wbindgen_add_to_stack_pointer(16);
857
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
858
+ }
859
+ }
818
860
  /**
819
861
  * @returns {string}
820
862
  */
@@ -835,11 +877,9 @@ export class Document {
835
877
  }
836
878
  }
837
879
  /**
838
- * The canonical `$quill` reference grammar as author-facing text. Core is
839
- * the single source of truth: drive schema `describe` and validation
840
- * messages from this instead of re-stating the rule; it matches the
841
- * `hint` on `parse::invalid_quill_reference`. Cache it; the value never
842
- * changes.
880
+ * The canonical `$quill` reference grammar as author-facing text: the same
881
+ * text the `parse::invalid_quill_reference` hint carries. Drive validation
882
+ * messages from this instead of re-stating the rule.
843
883
  * @returns {string}
844
884
  */
845
885
  static quillRefHint() {
@@ -878,10 +918,9 @@ export class Document {
878
918
  }
879
919
  }
880
920
  /**
881
- * Remove the `$ext` map on the card `addr` targets *entirely*, returning the
882
- * previous map or `undefined`: a blunt escape hatch that discards every
883
- * namespace at once (prefer `removeExtNamespace`). `addr` is a card address
884
- * (absent = main). Throws on a present `field` or an out-of-range card.
921
+ * Remove the `$ext` map on the card `addr` targets entirely, returning the
922
+ * previous map or `undefined`. Discards every namespace at once; prefer
923
+ * `removeExtNamespace`. Throws on a present `field` or an out-of-range card.
885
924
  * @param {CardAddr} [addr]
886
925
  * @returns {Record<string, unknown> | undefined}
887
926
  */
@@ -928,9 +967,8 @@ export class Document {
928
967
  }
929
968
  /**
930
969
  * Remove a field at `addr`, returning the removed value or `undefined`. A
931
- * bare string is `Addr` shorthand for `{ field }`. One `remove` verb serves
932
- * every write lane. A body address throws; throws on an out-of-range card or
933
- * a malformed name.
970
+ * bare string is `Addr` shorthand for `{ field }`. A body address throws, as
971
+ * does an out-of-range card or a malformed name.
934
972
  * @param {Addr | string} addr
935
973
  * @returns {any}
936
974
  */
@@ -950,9 +988,8 @@ export class Document {
950
988
  }
951
989
  }
952
990
  /**
953
- * Remove `cardKind` from the main card's `$seed` map, returning its
954
- * overlay or `undefined`; drops `$seed` entirely once empty. Sibling kinds
955
- * survive. `$seed` is main-only, so this takes no address.
991
+ * Remove `cardKind` from the main card's `$seed` map, returning its overlay
992
+ * or `undefined`; drops `$seed` entirely once empty. Sibling kinds survive.
956
993
  * @param {string} card_kind
957
994
  * @returns {any}
958
995
  */
@@ -974,12 +1011,12 @@ export class Document {
974
1011
  }
975
1012
  }
976
1013
  /**
977
- * **Revise** the richtext value at `addr` from a markdown string: **edit
978
- * semantics**, the default write path, returning the text `Delta`. Imports
979
- * the markdown, diffs it against the current value, rebases surviving
980
- * identity anchors, and returns the change an editor bridge maps its own
981
- * positions through (`mapPos`). An absent `addr.field` targets the body, an
982
- * absent `addr.card` the main card; an absent field cold-imports from empty.
1014
+ * **Revise** the richtext value at `addr` from a markdown string: the
1015
+ * default write path. Imports the markdown, diffs it against the current
1016
+ * value, rebases surviving identity anchors, and returns the text `Delta` an
1017
+ * editor bridge maps its own positions through (`mapPos`). An absent
1018
+ * `addr.field` targets the body, an absent `addr.card` the main card; an
1019
+ * absent field cold-imports from empty.
983
1020
  *
984
1021
  * Throws on an out-of-range card, a malformed field name, a present
985
1022
  * non-content field value, or an over-nested markdown input.
@@ -1005,11 +1042,9 @@ export class Document {
1005
1042
  }
1006
1043
  }
1007
1044
  /**
1008
- * The main card's `$seed` overlay object for `kind` (the `$seed[kind]`
1009
- * entry), or `undefined` when absent. The cheap read that feeds
1010
- * `quill.seedCard(kind, overlay)` without serializing the whole main card
1011
- * via [`main`](Self::main) to fish out one key, and it keeps `seedCard`
1012
- * pure: the quill still never reads the document.
1045
+ * The main card's `$seed[kind]` overlay object, or `undefined`. Feeds
1046
+ * `quill.seedCard(kind, overlay)` without serializing the whole main card,
1047
+ * and keeps `seedCard` pure: the quill never reads the document.
1013
1048
  * @param {string} kind
1014
1049
  * @returns {Record<string, unknown> | undefined}
1015
1050
  */
@@ -1072,15 +1107,11 @@ export class Document {
1072
1107
  }
1073
1108
  }
1074
1109
  /**
1075
- * Read the storage version tag from a raw storage DTO string without a
1076
- * full parse, or `undefined`. Returns unknown future versions as-is:
1077
- * useful to distinguish "build too old" from "payload corrupt" when
1078
- * `fromJson` throws.
1079
- *
1080
- * The storage version, not a field schema ([`schema`](Quill::schema) is the
1081
- * quill's field declarations). The JSON key is spelled `"schema"`: it is
1082
- * the DTO's serde tag, and retagging it would break the version dispatch
1083
- * it drives.
1110
+ * Read the storage version tag from a raw storage DTO string without a full
1111
+ * parse, or `undefined`. Unknown future versions come back as-is, which
1112
+ * distinguishes "build too old" from "payload corrupt" when `fromJson`
1113
+ * throws. This is the storage version, not a field schema, though the JSON
1114
+ * key is spelled `"schema"`: that is the DTO's serde tag.
1084
1115
  * @param {string} json
1085
1116
  * @returns {string | undefined}
1086
1117
  */
@@ -1103,11 +1134,10 @@ export class Document {
1103
1134
  }
1104
1135
  }
1105
1136
  /**
1106
- * Replace the opaque `$ext` map on the card `addr` targets (a card address,
1107
- * absent `card` = main). `value` must be a plain object. `$ext` carries
1108
- * out-of-band consumer state and never reaches the rendered output; pass
1109
- * `{}` for an explicit empty `$ext`. Quill-free and verbatim: an opaque
1110
- * `store` verb. Throws on a present `field` or an out-of-range card.
1137
+ * Replace the opaque `$ext` map on the card `addr` targets (absent `card` =
1138
+ * main). `value` must be a plain object. `$ext` carries out-of-band consumer
1139
+ * state and never reaches the rendered output. Throws on a present `field`
1140
+ * or an out-of-range card.
1111
1141
  * @param {CardAddr} addr
1112
1142
  * @param {any} value
1113
1143
  */
@@ -1126,9 +1156,8 @@ export class Document {
1126
1156
  }
1127
1157
  /**
1128
1158
  * Merge `value` into `$ext[ns]` on the card `addr` targets, preserving
1129
- * sibling namespaces: the recommended `$ext` write. `addr` is a card
1130
- * address (absent = main). Quill-free and verbatim: an opaque `store` verb.
1131
- * Throws on a present `field` or an out-of-range card.
1159
+ * sibling namespaces: the recommended `$ext` write. Throws on a present
1160
+ * `field` or an out-of-range card.
1132
1161
  * @param {CardAddr} addr
1133
1162
  * @param {string} ns
1134
1163
  * @param {any} value
@@ -1149,14 +1178,12 @@ export class Document {
1149
1178
  }
1150
1179
  }
1151
1180
  /**
1152
- * Store a field verbatim at `addr`: the opaque store (**store** = verbatim,
1153
- * coercion deferred to render; the typed write is
1154
- * [`commitField`](Document::commit_field)). A bare string is `Addr`
1155
- * shorthand for `{ field }`, so `doc.storeField("qty", 3)` reads as written;
1156
- * `{ card: 2, field: "qty" }` targets a composable card. Clears any
1157
- * `!must_fill` marker. A body address (no `field`) throws: a body is never
1158
- * opaque; write it with `revise` / `overwrite` / `writer.reviseBody`. Throws on
1159
- * an out-of-range card or a malformed name.
1181
+ * Store a field verbatim at `addr`, deferring coercion to render; the typed
1182
+ * write is [`commitField`](Document::commit_field). A bare string is `Addr`
1183
+ * shorthand for `{ field }`; `{ card: 2, field: "qty" }` targets a
1184
+ * composable card. Clears any `!must_fill` marker. A body address throws:
1185
+ * write a body with `revise` / `overwrite`. Throws on an out-of-range card
1186
+ * or a malformed name.
1160
1187
  * @param {Addr | string} addr
1161
1188
  * @param {any} value
1162
1189
  */
@@ -1174,14 +1201,11 @@ export class Document {
1174
1201
  }
1175
1202
  }
1176
1203
  /**
1177
- * Store several fields verbatim and atomically on the card `addr` targets:
1178
- * the opaque store's batch. `addr` is a **card address** (`{ card }`, absent
1179
- * = main); a present `field` throws. The batch verb takes the address first
1180
- * and is never shape-overloaded, because `card` is a legal field name:
1181
- * `storeFields({}, fields)` is the main card, `storeFields({ card: 2 },
1182
- * fields)` a composable one, never ambiguous with "set field `card`".
1183
- * Nothing is applied on error; the thrown error's `diagnostics` carry one
1184
- * entry per offending field. Throws on an out-of-range card.
1204
+ * Store several fields verbatim and atomically on the card `addr` targets.
1205
+ * `addr` is a **card address** (`{ card }`, absent = main) and comes first
1206
+ * because `card` is itself a legal field name; a present `field` throws.
1207
+ * Nothing is applied on error, and the thrown error's `diagnostics` carry
1208
+ * one entry per offending field. Throws on an out-of-range card.
1185
1209
  * @param {CardAddr} addr
1186
1210
  * @param {Record<string, unknown>} fields
1187
1211
  */
@@ -1199,10 +1223,8 @@ export class Document {
1199
1223
  }
1200
1224
  }
1201
1225
  /**
1202
- * Store a field verbatim at `addr` and mark it `!must_fill`: the opaque
1203
- * store's fill variant, card-capable (a bare string or `{ field }` for main,
1204
- * `{ card, field }` for a composable card). A body address throws. Same
1205
- * validation as [`storeField`](Document::store_field).
1226
+ * Store a field verbatim at `addr` and mark it `!must_fill`. A body address
1227
+ * throws; same validation as [`storeField`](Document::store_field).
1206
1228
  * @param {Addr | string} addr
1207
1229
  * @param {any} value
1208
1230
  */
@@ -1221,10 +1243,9 @@ export class Document {
1221
1243
  }
1222
1244
  /**
1223
1245
  * Merge a card-kind's seed `overlay` into the **main** card's `$seed` map
1224
- * under `cardKind`, preserving sibling kinds: `$seed` lives on the main
1225
- * card by model, so this takes no address. Sets the starting values new
1226
- * cards of that kind spawn with. Quill-free and verbatim: an opaque `store`
1227
- * verb. Throws if `overlay` cannot be serialized or nests too deep.
1246
+ * under `cardKind`, preserving sibling kinds; `$seed` is main-only, so this
1247
+ * takes no address. Sets the starting values new cards of that kind spawn
1248
+ * with. Throws if `overlay` cannot be serialized or nests too deep.
1228
1249
  * @param {string} card_kind
1229
1250
  * @param {any} overlay
1230
1251
  */
@@ -1244,14 +1265,10 @@ export class Document {
1244
1265
  }
1245
1266
  }
1246
1267
  /**
1247
- * Serialize this document to a versioned storage DTO string.
1248
- *
1249
- * Prefer this over `toMarkdown` for persistence across restarts or crate
1250
- * upgrades: the wire format is frozen per `schema` version. Parse-time
1251
- * `warnings` are excluded from the DTO.
1252
- *
1253
- * Output is **byte-deterministic** within a `schema` version: equal
1254
- * documents produce byte-equal output, safe for content-hash use cases.
1268
+ * Serialize this document to a versioned storage DTO string. Prefer it over
1269
+ * `toMarkdown` for persistence: the wire format is frozen per `schema`
1270
+ * version and the output is byte-deterministic within one, so equal
1271
+ * documents hash equal. Parse-time `warnings` are excluded.
1255
1272
  * @returns {string}
1256
1273
  */
1257
1274
  toJson() {
@@ -1292,11 +1309,9 @@ export class Document {
1292
1309
  }
1293
1310
  }
1294
1311
  /**
1295
- * Like [`fromJson`](Document::from_json) but returns `undefined` instead
1296
- * of throwing when `json` is not a valid storage DTO: use to
1297
- * discriminate format without exceptions as control flow.
1298
- * `undefined` means "not a storage DTO"; `fromMarkdown` still throws on
1299
- * genuinely malformed markdown.
1312
+ * Like [`fromJson`](Document::from_json) but returns `undefined` instead of
1313
+ * throwing when `json` is not a valid storage DTO, to discriminate format
1314
+ * without exceptions as control flow.
1300
1315
  * @param {string} json
1301
1316
  * @returns {Document | undefined}
1302
1317
  */
@@ -1308,9 +1323,9 @@ export class Document {
1308
1323
  }
1309
1324
  /**
1310
1325
  * The non-fatal diagnostics of the load that produced this document: parse
1311
- * warnings, plus the `conform::*` warnings when it came through
1312
- * `quill.parse`. Session state, not document value: `equals` and the
1313
- * storage DTO exclude it, and `fromJson` / `loadJson` clear it.
1326
+ * warnings, plus `conform::*` warnings when it came through `quill.parse`.
1327
+ * Session state, not document value: `equals` and the storage DTO exclude
1328
+ * it, and `fromJson` / `loadJson` clear it.
1314
1329
  * @returns {Diagnostic[]}
1315
1330
  */
1316
1331
  get warnings() {
@@ -1350,9 +1365,8 @@ export class Quill {
1350
1365
  wasm.__wbg_quill_free(ptr, 0);
1351
1366
  }
1352
1367
  /**
1353
- * The *declared* backend identifier (`config.backend`, e.g. `"typst"`).
1354
- * Intent, not a resolved capability: capability (`supportedFormats` /
1355
- * `supportsCanvas`) is read from the engine.
1368
+ * The *declared* backend identifier (e.g. `"typst"`): intent, not a
1369
+ * resolved capability. Capability is read from the engine.
1356
1370
  * @returns {string}
1357
1371
  */
1358
1372
  get backendId() {
@@ -1392,19 +1406,15 @@ export class Quill {
1392
1406
  }
1393
1407
  /**
1394
1408
  * Land `doc`'s declared content fields at their canonical rest **in
1395
- * place**, returning the `conform::*` diagnostics for the values that would
1396
- * not commit (an empty array when everything rested).
1409
+ * place**, returning the `conform::*` diagnostics for values that would not
1410
+ * commit. The read-repair verb for a document that arrived through the
1411
+ * transport door (`fromMarkdown`, `fromJson`, a stored row).
1397
1412
  *
1398
- * The read-repair verb: a document that arrived through the transport door
1399
- * (`fromMarkdown`, `fromJson`, a stored row) converges here, and is then
1400
- * eligible for rewrite under its current schema tag. Idempotent, and a
1401
- * no-op on an already-canonical document: an equal value is not rewritten,
1402
- * so YAML comments and stored bytes survive.
1403
- *
1404
- * A `!must_fill` marker anywhere in a field's value skips that field (the
1405
- * marker is the state), and a value the strict write refuses stays as
1406
- * authored with a diagnostic. Throws when `doc` declares a different
1407
- * `$quill`, before any mutation.
1413
+ * Idempotent: an equal value is not rewritten, so YAML comments and stored
1414
+ * bytes survive. A `!must_fill` marker anywhere in a field's value skips
1415
+ * that field, and a value the strict write refuses stays as authored with a
1416
+ * diagnostic. Throws when `doc` declares a different `$quill`, before any
1417
+ * mutation.
1408
1418
  * @param {Document} doc
1409
1419
  * @returns {Diagnostic[]}
1410
1420
  */
@@ -1425,13 +1435,9 @@ export class Quill {
1425
1435
  }
1426
1436
  }
1427
1437
  /**
1428
- * Build a quill from a file tree. Pure: no backend, no engine; the
1429
- * declared backend is resolved later, at render time.
1430
- *
1431
- * Accepts either a `Map<string, Uint8Array>` or a plain object
1432
- * (`Record<string, Uint8Array>`). Plain objects are walked via
1433
- * `Object.entries` at the boundary; the Rust side sees a single
1434
- * canonical shape.
1438
+ * Build a quill from a file tree. Pure: the declared backend is resolved
1439
+ * later, at render time. Accepts a `Map<string, Uint8Array>` or a plain
1440
+ * object.
1435
1441
  * @param {Map<string, Uint8Array>} tree
1436
1442
  * @returns {Quill}
1437
1443
  */
@@ -1452,9 +1458,8 @@ export class Quill {
1452
1458
  }
1453
1459
  /**
1454
1460
  * Identity snapshot of the `quill:` section of `Quill.yaml` plus any extra
1455
- * `quill:` keys. Pure config: the backend's output formats are a
1456
- * resolved-backend capability read from the engine
1457
- * (`Quillmark.supportedFormats`), not part of this snapshot.
1461
+ * `quill:` keys. Pure config: output formats are a resolved-backend
1462
+ * capability read from `Quillmark.supportedFormats`, not part of this.
1458
1463
  * @returns {QuillMetadata}
1459
1464
  */
1460
1465
  get metadata() {
@@ -1473,18 +1478,16 @@ export class Quill {
1473
1478
  }
1474
1479
  }
1475
1480
  /**
1476
- * Parse `markdown` and conform it against this quill: the **primary
1477
- * ingestion path**, and the bound twin of the schema-free
1478
- * `Document.fromMarkdown`. The returned document rests at its canonical
1479
- * form (a `richtext` field as a content object, a `plaintext` field as its
1480
- * literal string), so `getStored` answers "content object or string?" by the
1481
- * field's declared codec rather than by how the document was built.
1481
+ * Parse `markdown` and conform it against this quill: the primary ingestion
1482
+ * path, and the bound twin of the schema-free `Document.fromMarkdown`. The
1483
+ * returned document rests at its canonical form (a `richtext` field as a
1484
+ * content object, a `plaintext` field as its literal string), so `getStored`
1485
+ * answers by the field's declared codec, not by how the document was built.
1482
1486
  *
1483
1487
  * Parse warnings and the `conform::*` diagnostics both land on
1484
1488
  * `doc.warnings`. Throws on a parse failure, or when `markdown` declares a
1485
- * `$quill` this quill does not answer to: nothing conforms under the wrong
1486
- * schema. To open a document whose `$quill` is stale, use the transport
1487
- * door (`Document.fromMarkdown`, `setQuillRef`, then `quill.conform`).
1489
+ * `$quill` this quill does not answer to. To open a document whose `$quill`
1490
+ * is stale, use `Document.fromMarkdown`, `setQuillRef`, then `quill.conform`.
1488
1491
  * @param {string} markdown
1489
1492
  * @returns {Document}
1490
1493
  */
@@ -1506,15 +1509,11 @@ export class Quill {
1506
1509
  }
1507
1510
  }
1508
1511
  /**
1509
- * The resolved-value view of `doc` against this quill's schema: for every
1510
- * declared field the value the render projection would use and the
1511
- * `FieldSource` rung it came from (`"authored" | "default" | "zero"`), in
1512
- * one call. The card body is a `body` sibling on its card (row `name`
1513
- * `"body"`), never a row in `fields`: `null` when the kind enables no body.
1514
- *
1515
- * Value and provenance only: completeness and errors stay `validate`'s
1516
- * (a consumer merges it with its own diagnostic producers regardless), and
1517
- * schema guidance reads from `Quill.schema`.
1512
+ * The resolved-value view of `doc`: for every declared field, the value the
1513
+ * render projection would use and the `FieldSource` rung it came from
1514
+ * (`"authored" | "default" | "blank"`). The card body is a `body` sibling on
1515
+ * its card, never a row in `fields`, and `null` when the kind enables no
1516
+ * body. Value and provenance only; completeness stays `validate`'s.
1518
1517
  * @param {Document} doc
1519
1518
  * @returns {Resolved}
1520
1519
  */
@@ -1535,11 +1534,9 @@ export class Quill {
1535
1534
  }
1536
1535
  }
1537
1536
  /**
1538
- * Document schema for the quill: the user-fillable fields plus their
1539
- * `ui` hints (title / group / compact / multiline). The single
1540
- * field-metadata surface: drives form editors and LLM/MCP consumers
1541
- * alike. Key order in `fields`/`properties` is declaration order: the
1542
- * ordering contract. Returns the `QuillSchema` shape.
1537
+ * Document schema for the quill: the user-fillable fields plus their `ui`
1538
+ * hints. Key order in `fields`/`properties` is declaration order, the
1539
+ * ordering contract.
1543
1540
  * @returns {QuillSchema}
1544
1541
  */
1545
1542
  get schema() {
@@ -1559,15 +1556,13 @@ export class Quill {
1559
1556
  }
1560
1557
  /**
1561
1558
  * Seed a starter composable `Card` of the given kind (carries `$kind`),
1562
- * layering an optional per-kind seed `overlay` over the schema-example
1563
- * base (`overlay › example › absent`). Returns `undefined` if `cardKind`
1564
- * is not declared in this quill's schema, else a `Card` that feeds
1565
- * straight into `Document.insertCard`.
1559
+ * layering an optional per-kind seed `overlay` over the schema-example base
1560
+ * (`overlay › example › absent`). `undefined` when `cardKind` is not
1561
+ * declared in this quill's schema.
1566
1562
  *
1567
1563
  * Pass `document.seedOverlay(cardKind)` as `overlay` so a card added to a
1568
1564
  * template-derived document inherits its curated starting values; omit it
1569
- * (or pass `undefined` / `null`) for the bare schema seed. `overlay` is a
1570
- * plain object: this reads the document, it does not mutate it.
1565
+ * for the bare schema seed.
1571
1566
  * @param {string} card_kind
1572
1567
  * @param {Record<string, unknown> | undefined} overlay
1573
1568
  * @returns {Card | undefined}
@@ -1590,12 +1585,10 @@ export class Quill {
1590
1585
  }
1591
1586
  }
1592
1587
  /**
1593
- * Seed a starter `Document` from the schema, the main card plus one
1594
- * instance of each composable card kind, each committing its fields'
1595
- * `example:` values and leaving every other field absent (interpolated at
1596
- * render: `default:`, else type-empty zero). Illustration-first: a field
1597
- * with both an `example` and a `default` renders its example. See
1598
- * `prose/canon/SCHEMAS.md` § "Document seeding".
1588
+ * Seed a starter `Document` from the schema: the main card plus one instance
1589
+ * of each composable card kind, each committing its fields' `example:`
1590
+ * values and leaving every other field absent (interpolated at render as
1591
+ * `default:`, else the field's blank). A field with both renders its example.
1599
1592
  * @returns {Document}
1600
1593
  */
1601
1594
  seedDocument() {
@@ -1604,9 +1597,7 @@ export class Quill {
1604
1597
  }
1605
1598
  /**
1606
1599
  * Seed a starter main `Card` (carries `$quill`) from the schema: the
1607
- * `$kind: main` card of [`seedDocument`](Self::seed_document) in
1608
- * isolation, committing each field's `example:` value. Returns the same
1609
- * `Card` shape as the `Document.main` getter.
1600
+ * `$kind: main` card of [`seedDocument`](Self::seed_document) alone.
1610
1601
  * @returns {Card}
1611
1602
  */
1612
1603
  seedMain() {
@@ -1625,16 +1616,13 @@ export class Quill {
1625
1616
  }
1626
1617
  }
1627
1618
  /**
1628
- * Flatten this quill back into its canonical file tree: the inverse of
1629
- * [`fromTree`](Self::from_tree). Round-trips: `Quill.fromTree(q.toTree())`
1630
- * reproduces an equivalent quill.
1619
+ * Flatten this quill back into its canonical file tree, the inverse of
1620
+ * [`fromTree`](Self::from_tree). Keys are `"/"`-joined relative paths.
1631
1621
  *
1632
1622
  * This is how a quill crosses a WASM linear-memory boundary as data: a
1633
- * `Quill` built in one build (e.g. the Typst-less `@quillmark/wasm/core`)
1634
- * cannot be passed to an engine in another (separate linear memories), so
1623
+ * `Quill` built in one build cannot be passed to an engine in another, so
1635
1624
  * `@quillmark/wasm/runtime` re-feeds this tree to the backend build's
1636
- * `Quill.fromTree` on demand. Keys are `"/"`-joined relative paths,
1637
- * matching what `fromTree` accepts.
1625
+ * `Quill.fromTree` on demand.
1638
1626
  * @returns {Map<string, Uint8Array>}
1639
1627
  */
1640
1628
  toTree() {
@@ -1643,14 +1631,9 @@ export class Quill {
1643
1631
  }
1644
1632
  /**
1645
1633
  * Validate `doc` against this quill's schema, returning every diagnostic
1646
- * (an empty array when the document is valid).
1647
- *
1648
- * Forwards the canonical `validation::*` diagnostics (same `code`,
1649
- * `path`, and `hint` the engine emits) including the non-fatal
1650
- * `validation::must_fill` warning for each `!must_fill` marker left in
1651
- * the document. Field values, defaults, and order are not part of this
1652
- * surface: read them from the `Document` payload and `Quill.schema`
1653
- * (schema key order is display order).
1634
+ * (empty when the document is valid). Forwards the canonical
1635
+ * `validation::*` diagnostics the engine emits, including the non-fatal
1636
+ * `validation::must_fill` warning per `!must_fill` marker left behind.
1654
1637
  * @param {Document} doc
1655
1638
  * @returns {Diagnostic[]}
1656
1639
  */
@@ -1674,8 +1657,7 @@ export class Quill {
1674
1657
  if (Symbol.dispose) Quill.prototype[Symbol.dispose] = Quill.prototype.free;
1675
1658
 
1676
1659
  /**
1677
- * Export a canonical `Content` content to its markdown projection: the pure
1678
- * on-demand codec behind `exportMarkdown(card.body)`. Throws if `rt` is not a
1660
+ * Export canonical `Content` to its markdown projection. Throws if `rt` is not
1679
1661
  * canonical content.
1680
1662
  * @param {Content} rt
1681
1663
  * @returns {string}
@@ -1707,10 +1689,8 @@ export function exportMarkdown(rt) {
1707
1689
 
1708
1690
  /**
1709
1691
  * Serialize structured [`DocPathSeg`] segments back to the canonical path
1710
- * string: the inverse of `parseDocPath`, for a consumer that builds a path
1711
- * rather than reads one. Throws on a segment array the deserializer rejects,
1712
- * and on an empty segment array (symmetric with `parseDocPath("")`, which
1713
- * throws "empty path").
1692
+ * string: the inverse of `parseDocPath`. Throws on a segment array the
1693
+ * deserializer rejects, and on an empty one.
1714
1694
  * @param {DocPathSeg[]} segs
1715
1695
  * @returns {string}
1716
1696
  */
@@ -1740,10 +1720,9 @@ export function formatDocPath(segs) {
1740
1720
  }
1741
1721
 
1742
1722
  /**
1743
- * Import a markdown string to a canonical `Content` content: the pure,
1744
- * document-free codec. Pair with `overwrite(addr, importMarkdown(md))` to spell
1745
- * the cold (anchor-losing) write at the call site; prefer `revise` for edit
1746
- * semantics. Throws on an over-nested input.
1723
+ * Import a markdown string to canonical `Content`: the pure, document-free
1724
+ * codec. `overwrite(addr, importMarkdown(md))` spells the cold, anchor-losing
1725
+ * write; prefer `revise` for edit semantics. Throws on an over-nested input.
1747
1726
  * @param {string} markdown
1748
1727
  * @returns {Content}
1749
1728
  */
@@ -1767,10 +1746,9 @@ export function importMarkdown(markdown) {
1767
1746
 
1768
1747
  /**
1769
1748
  * Map a base content position (a USV index into `Content.text`, not a UTF-16
1770
- * offset) through a `delta` to its new USV position: the pure position-mapping
1771
- * codec an editor bridge composes to hold a caret stable across a `revise`.
1772
- * `assoc` decides the side of a same-position insertion (`"after"` moves past
1773
- * it). Throws on a malformed `delta`.
1749
+ * offset) through a `delta` to its new position, holding a caret stable across
1750
+ * a `revise`. `assoc` decides the side of a same-position insertion (`"after"`
1751
+ * moves past it). Throws on a malformed `delta`.
1774
1752
  * @param {Delta} delta
1775
1753
  * @param {number} pos
1776
1754
  * @param {Assoc} assoc
@@ -1793,11 +1771,10 @@ export function mapPos(delta, pos, assoc) {
1793
1771
  }
1794
1772
 
1795
1773
  /**
1796
- * Parse a canonical document-model `Diagnostic.path`
1797
- * (`cards.<kind>[<i>].<field>`, `main.body`, `recipients[0].name`) into its
1798
- * structured [`DocPathSeg`] segments: the exported inverse of the engine's
1799
- * one path serializer, so a consumer routes on segments instead of regexing
1800
- * the string. Throws on a malformed path.
1774
+ * Parse a canonical document-model `Diagnostic.path` (`cards.<kind>[<i>].<field>`,
1775
+ * `main.body`, `recipients[0].name`) into structured [`DocPathSeg`] segments, so
1776
+ * a consumer routes on segments instead of regexing the string. Throws on a
1777
+ * malformed path.
1801
1778
  * @param {string} path
1802
1779
  * @returns {DocPathSeg[]}
1803
1780
  */
@@ -1820,12 +1797,10 @@ export function parseDocPath(path) {
1820
1797
  }
1821
1798
 
1822
1799
  /**
1823
- * Rebase `markdown` onto a `base` content, the pure, document-free twin of
1824
- * `revise`: cold-import + `diff_import`, returning the new `content` and the
1825
- * text `delta` (its offsets USV indices into `Content.text`, surviving anchors
1826
- * rebased). Use it to compute a revise without a document in hand; `revise(addr,
1827
- * md)` fuses this with the store for atomicity. Throws on an over-nested
1828
- * markdown input or a non-content `base`.
1800
+ * Rebase `markdown` onto a `base` content: the document-free twin of `revise`,
1801
+ * returning the new `content` and the text `delta` (offsets are USV indices into
1802
+ * `Content.text`, surviving anchors rebased). Throws on an over-nested markdown
1803
+ * input or a non-content `base`.
1829
1804
  * @param {Content} base
1830
1805
  * @param {string} markdown
1831
1806
  * @returns {{ content: Content; delta: Delta }}
@@ -1849,13 +1824,9 @@ export function rebase(base, markdown) {
1849
1824
  }
1850
1825
 
1851
1826
  /**
1852
- * Runs at instantiation (the wasm-bindgen start section): installs the panic
1853
- * hook, so a Rust panic reaches the console as a stack trace rather than
1854
- * `unreachable`.
1855
- *
1856
- * Not the package's `init`. That name belongs to the hand-written runtime,
1857
- * which owns instantiation itself (`runtime/runtime.js`); this runs as part of
1858
- * the instantiation it awaits.
1827
+ * Runs at instantiation, so a Rust panic reaches the console as a stack trace
1828
+ * rather than `unreachable`. Not the package's `init` that name belongs to
1829
+ * the hand-written runtime, which owns instantiation itself.
1859
1830
  */
1860
1831
  export function start() {
1861
1832
  wasm.start();