@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.
@@ -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.
200
+ *
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.
223
204
  *
224
- * The codec is the declared type's: `richtext` diffs markdown, `plaintext`
225
- * the literal text.
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.
226
243
  *
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.
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 `""`.
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 `""`.
710
721
  *
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.
714
- *
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() {
@@ -1332,17 +1347,14 @@ export class Document {
1332
1347
  if (Symbol.dispose) Document.prototype[Symbol.dispose] = Document.prototype.free;
1333
1348
 
1334
1349
  /**
1335
- * Live render session: reads (`render`, `paint`, `pageSize`, `regions`,
1336
- * `fieldAt`, `positionAt`, `locate`) serve the current compile. `apply(doc)`
1337
- * recompiles a whole document in place, transactionally (on throw every read
1338
- * keeps serving the last-good compile). Geometry reads reflect the current
1339
- * compile; anchoring a caret across edits is the editor's job: re-read
1340
- * geometry after each committed `apply`.
1350
+ * Live render session: every read serves the current compile. `apply(doc)`
1351
+ * recompiles a whole document in place, transactionally — on throw the reads
1352
+ * keep serving the last-good compile. Geometry is per-compile, so re-read it
1353
+ * after each committed `apply`.
1341
1354
  *
1342
- * **Empty documents.** A zero-page document yields a valid session
1343
- * (`pageCount === 0`); `paint(ctx, 0)` or `pageSize(0)` throws with
1344
- * `"page index 0 out of range (pageCount=0)"`. Branch on `pageCount === 0`
1345
- * rather than catching the error.
1355
+ * A zero-page document yields a valid session (`pageCount === 0`) whose
1356
+ * `paint(ctx, 0)` and `pageSize(0)` throw; branch on `pageCount === 0` rather
1357
+ * than catching.
1346
1358
  */
1347
1359
  export class LiveSession {
1348
1360
  static __wrap(ptr) {
@@ -1383,15 +1395,12 @@ export class LiveSession {
1383
1395
  }
1384
1396
  }
1385
1397
  /**
1386
- * The schema field whose content is under a point on `page`, the
1387
- * forward (click field) direction: hit-test a click against the
1388
- * compiled document and get back the `DocPath` field address to focus in
1389
- * the editor, or `undefined` off any field's ink. `x`/`y` are PDF points
1390
- * with a **bottom-left** origin, the same space as `FieldRegion.rect`,
1391
- * from a canvas click, invert the overlay transform documented on
1392
- * `FieldRegion`: `x = clickPx.x / renderScale`,
1393
- * `y = pageHeightPt - clickPx.y / renderScale`. Unlike `regions()`,
1394
- * *every* placement answers, not just the first.
1398
+ * The schema field whose content is under a point on `page`: the `DocPath`
1399
+ * address to focus in the editor, or `undefined` off any field's ink.
1400
+ * `x`/`y` are PDF points with a **bottom-left** origin, the same space as
1401
+ * `FieldRegion.rect`, so from a canvas click use
1402
+ * `x = clickPx.x / renderScale`, `y = pageHeightPt - clickPx.y / renderScale`.
1403
+ * Unlike `regions()`, *every* placement answers, not just the first.
1395
1404
  * @param {number} page
1396
1405
  * @param {number} x
1397
1406
  * @param {number} y
@@ -1414,15 +1423,11 @@ export class LiveSession {
1414
1423
  }
1415
1424
  }
1416
1425
  /**
1417
- * The whole-field highlight boxes for `field`: one union rect per page,
1418
- * over the field's `span`-bearing content segments. The convenience that
1419
- * owns the union `regions()` leaves derived: it keeps `regions()` the
1420
- * low-level disjoint truth and folds the span-filter + per-page
1421
- * union here, so a "highlight the focused field" consumer stops
1422
- * reimplementing it. **Content only**: a field placed solely as a scalar
1423
- * reference or a bound widget carries no `span` and returns `[]`; its box
1424
- * is a single `regions()` rect. Reflects the current compile, like
1425
- * `regions()`.
1426
+ * The whole-field highlight boxes for `field`: one union rect per page over
1427
+ * the field's `span`-bearing content segments, the union `regions()` leaves
1428
+ * derived. **Content only**: a field placed solely as a scalar reference or
1429
+ * a bound widget carries no `span` and returns `[]`, its box being a single
1430
+ * `regions()` rect. Reflects the current compile.
1426
1431
  * @param {string} field
1427
1432
  * @returns {FieldRegion[]}
1428
1433
  */
@@ -1444,11 +1449,10 @@ export class LiveSession {
1444
1449
  }
1445
1450
  }
1446
1451
  /**
1447
- * A content position → **caret rect**, the reverse of `positionAt`: given
1448
- * a field and a USV offset into its `Content`, return the box (in the
1449
- * same bottom-left PDF-point space as `FieldRegion.rect`) to draw a caret
1450
- * at, its `span` collapsed to `[pos, pos]`; `undefined` when the field
1451
- * places no tracked content or the offset maps to no drawn glyph.
1452
+ * A content position → **caret rect**, the reverse of `positionAt`: the box
1453
+ * to draw a caret at, in the same bottom-left PDF-point space as
1454
+ * `FieldRegion.rect`, its `span` collapsed to `[pos, pos]`. `undefined` when
1455
+ * the field places no tracked content or the offset maps to no drawn glyph.
1452
1456
  * @param {string} field
1453
1457
  * @param {number} pos
1454
1458
  * @returns {FieldRegion | undefined}
@@ -1491,17 +1495,16 @@ export class LiveSession {
1491
1495
  * Paint `page` into a `CanvasRenderingContext2D` or
1492
1496
  * `OffscreenCanvasRenderingContext2D`. The painter owns
1493
1497
  * `canvas.width`/`height` (no `clearRect` needed); consumers own
1494
- * `canvas.style.*`. If `layoutScale * densityScale` exceeds 16384 px
1495
- * per side, `densityScale` is clamped: `PaintResult.clamped` reports it and
1496
- * `PaintResult.effectiveDensityScale` carries the density actually applied.
1498
+ * `canvas.style.*`. If `layoutScale * densityScale` exceeds 16384 px per
1499
+ * side, `densityScale` is clamped and `PaintResult` reports it.
1497
1500
  *
1498
1501
  * `put_image_data` writes the whole backing store, bypassing the 2D
1499
- * context's transform, `globalAlpha`, and clip: the painter owns the entire
1500
- * canvas, so each visible page needs its own `<canvas>`; you cannot composite
1501
- * two pages, a sub-rect, or a context transform through this call.
1502
+ * context's transform, `globalAlpha`, and clip, so each visible page needs
1503
+ * its own `<canvas>`: no compositing, sub-rect, or transform reaches through
1504
+ * this call.
1502
1505
  *
1503
- * Throws if the backend has no canvas painter, `page` is out of range,
1504
- * `ctx` is the wrong type, or either scale is non-finite or `<= 0`.
1506
+ * Throws if the backend has no canvas painter, `page` is out of range, `ctx`
1507
+ * is the wrong type, or either scale is non-finite or `<= 0`.
1505
1508
  * @param {CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D} ctx
1506
1509
  * @param {number} page
1507
1510
  * @param {PaintOptions | undefined} opts
@@ -1523,14 +1526,11 @@ export class LiveSession {
1523
1526
  }
1524
1527
  }
1525
1528
  /**
1526
- * A point → **content position**, the fine-grained click direction:
1527
- * hit-test a point and get back the field *and* a USV offset into its
1528
- * `Content` (for placing a caret or mapping a selection into the content
1529
- * model), or `undefined` off all content ink. `x`/`y` are PDF points,
1530
- * bottom-left origin: the same space as `fieldAt`. The offset is
1531
- * cluster-exact and degrades to the containing segment's start on
1532
- * origin-less ink (list markers, a code fence's interior). See
1533
- * `ContentHit`.
1529
+ * A point → **content position**: the field *and* a USV offset into its
1530
+ * `Content`, for placing a caret or mapping a selection into the content
1531
+ * model, or `undefined` off all content ink. `x`/`y` are PDF points,
1532
+ * bottom-left origin, as in `fieldAt`. The offset is cluster-exact and
1533
+ * degrades to the containing segment's start on origin-less ink.
1534
1534
  * @param {number} page
1535
1535
  * @param {number} x
1536
1536
  * @param {number} y
@@ -1543,13 +1543,10 @@ export class LiveSession {
1543
1543
  /**
1544
1544
  * Schema-field geometry for this compiled session: each content field's
1545
1545
  * **first placement** (one region per page it touches) plus widget and
1546
- * scalar-reference-site regions, keyed on the canonical `DocPath` address
1547
- * (`parseDocPath`-routable; the session resolves the backend's plate-space
1548
- * per-kind ordinal to it); a field may still appear more than once (group
1549
- * by `field`, see `FieldRegion`). A session-level query: no render, no byte
1550
- * artifact. An interactive preview reads it to scroll to / highlight the
1551
- * focused field over a `paint`-ed canvas; the click direction is `fieldAt`.
1552
- * Empty for backends that place no schema fields.
1546
+ * scalar-reference-site regions, keyed on the canonical `DocPath` address. A
1547
+ * field may appear more than once, so group by `field` (see `FieldRegion`).
1548
+ * A session-level query: no render, no byte artifact. The click direction is
1549
+ * `fieldAt`. Empty for backends that place no schema fields.
1553
1550
  * @returns {FieldRegion[]}
1554
1551
  */
1555
1552
  regions() {
@@ -1587,9 +1584,7 @@ export class LiveSession {
1587
1584
  }
1588
1585
  }
1589
1586
  /**
1590
- * `true` iff `paint` and `pageSize` will succeed for this session. Derived
1591
- * from the session's canvas seam, so it reflects exactly what `paint` will
1592
- * do: no separately captured flag.
1587
+ * `true` iff `paint` and `pageSize` will succeed for this session.
1593
1588
  * @returns {boolean}
1594
1589
  */
1595
1590
  get supportsCanvas() {
@@ -1597,16 +1592,14 @@ export class LiveSession {
1597
1592
  return ret !== 0;
1598
1593
  }
1599
1594
  /**
1600
- * Recompile the session against `doc`: the edit verb of a live preview.
1601
- * The document is compiled through the same schema pipeline as `open`
1602
- * (same quill), then swapped in transactionally: on throw every read
1603
- * (`render`, `paint`, `pageSize`, `regions`, `fieldAt`) keeps serving the last-good
1604
- * compile, and the session recovers on the next successful `update`. On
1605
- * success reads serve the new compile; repaint `dirtyPages ∩ visible`.
1595
+ * Recompile the session against `doc`: the edit verb of a live preview. The
1596
+ * document compiles through the same pipeline as `open`, then swaps in
1597
+ * transactionally on throw every read keeps serving the last-good compile
1598
+ * and the session recovers on the next successful `update`. On success,
1599
+ * repaint `dirtyPages visible`.
1606
1600
  *
1607
- * Distinct from the content lane's [`applyChange`](Document::apply_change),
1608
- * which splices ops into a document: this one recompiles a whole document
1609
- * the caller already mutated.
1601
+ * Distinct from [`applyChange`](Document::apply_change), which splices ops
1602
+ * into a document; this recompiles a document the caller already mutated.
1610
1603
  * @param {Document} doc
1611
1604
  * @returns {ChangeSet}
1612
1605
  */
@@ -1627,10 +1620,9 @@ export class LiveSession {
1627
1620
  }
1628
1621
  }
1629
1622
  /**
1630
- * Non-fatal diagnostics of the session's **current compile** (e.g. Typst
1631
- * font fallback): set at open and refreshed by each committed `apply`;
1632
- * a failed apply keeps the last-good compile's warnings. Also appended
1633
- * to `RenderResult.warnings` on each `render()` call.
1623
+ * Non-fatal diagnostics of the session's **current compile**, refreshed by
1624
+ * each committed `apply`; a failed apply keeps the last-good compile's.
1625
+ * Also appended to `RenderResult.warnings` on each `render()`.
1634
1626
  * @returns {Diagnostic[]}
1635
1627
  */
1636
1628
  get warnings() {
@@ -1670,9 +1662,8 @@ export class Quill {
1670
1662
  wasm.__wbg_quill_free(ptr, 0);
1671
1663
  }
1672
1664
  /**
1673
- * The *declared* backend identifier (`config.backend`, e.g. `"typst"`).
1674
- * Intent, not a resolved capability: capability (`supportedFormats` /
1675
- * `supportsCanvas`) is read from the engine.
1665
+ * The *declared* backend identifier (e.g. `"typst"`): intent, not a
1666
+ * resolved capability. Capability is read from the engine.
1676
1667
  * @returns {string}
1677
1668
  */
1678
1669
  get backendId() {
@@ -1712,19 +1703,15 @@ export class Quill {
1712
1703
  }
1713
1704
  /**
1714
1705
  * Land `doc`'s declared content fields at their canonical rest **in
1715
- * place**, returning the `conform::*` diagnostics for the values that would
1716
- * not commit (an empty array when everything rested).
1717
- *
1718
- * The read-repair verb: a document that arrived through the transport door
1719
- * (`fromMarkdown`, `fromJson`, a stored row) converges here, and is then
1720
- * eligible for rewrite under its current schema tag. Idempotent, and a
1721
- * no-op on an already-canonical document: an equal value is not rewritten,
1722
- * so YAML comments and stored bytes survive.
1706
+ * place**, returning the `conform::*` diagnostics for values that would not
1707
+ * commit. The read-repair verb for a document that arrived through the
1708
+ * transport door (`fromMarkdown`, `fromJson`, a stored row).
1723
1709
  *
1724
- * A `!must_fill` marker anywhere in a field's value skips that field (the
1725
- * marker is the state), and a value the strict write refuses stays as
1726
- * authored with a diagnostic. Throws when `doc` declares a different
1727
- * `$quill`, before any mutation.
1710
+ * Idempotent: an equal value is not rewritten, so YAML comments and stored
1711
+ * bytes survive. A `!must_fill` marker anywhere in a field's value skips
1712
+ * that field, and a value the strict write refuses stays as authored with a
1713
+ * diagnostic. Throws when `doc` declares a different `$quill`, before any
1714
+ * mutation.
1728
1715
  * @param {Document} doc
1729
1716
  * @returns {Diagnostic[]}
1730
1717
  */
@@ -1745,13 +1732,9 @@ export class Quill {
1745
1732
  }
1746
1733
  }
1747
1734
  /**
1748
- * Build a quill from a file tree. Pure: no backend, no engine; the
1749
- * declared backend is resolved later, at render time.
1750
- *
1751
- * Accepts either a `Map<string, Uint8Array>` or a plain object
1752
- * (`Record<string, Uint8Array>`). Plain objects are walked via
1753
- * `Object.entries` at the boundary; the Rust side sees a single
1754
- * canonical shape.
1735
+ * Build a quill from a file tree. Pure: the declared backend is resolved
1736
+ * later, at render time. Accepts a `Map<string, Uint8Array>` or a plain
1737
+ * object.
1755
1738
  * @param {Map<string, Uint8Array>} tree
1756
1739
  * @returns {Quill}
1757
1740
  */
@@ -1772,9 +1755,8 @@ export class Quill {
1772
1755
  }
1773
1756
  /**
1774
1757
  * Identity snapshot of the `quill:` section of `Quill.yaml` plus any extra
1775
- * `quill:` keys. Pure config: the backend's output formats are a
1776
- * resolved-backend capability read from the engine
1777
- * (`Quillmark.supportedFormats`), not part of this snapshot.
1758
+ * `quill:` keys. Pure config: output formats are a resolved-backend
1759
+ * capability read from `Quillmark.supportedFormats`, not part of this.
1778
1760
  * @returns {QuillMetadata}
1779
1761
  */
1780
1762
  get metadata() {
@@ -1793,18 +1775,16 @@ export class Quill {
1793
1775
  }
1794
1776
  }
1795
1777
  /**
1796
- * Parse `markdown` and conform it against this quill: the **primary
1797
- * ingestion path**, and the bound twin of the schema-free
1798
- * `Document.fromMarkdown`. The returned document rests at its canonical
1799
- * form (a `richtext` field as a content object, a `plaintext` field as its
1800
- * literal string), so `getStored` answers "content object or string?" by the
1801
- * field's declared codec rather than by how the document was built.
1778
+ * Parse `markdown` and conform it against this quill: the primary ingestion
1779
+ * path, and the bound twin of the schema-free `Document.fromMarkdown`. The
1780
+ * returned document rests at its canonical form (a `richtext` field as a
1781
+ * content object, a `plaintext` field as its literal string), so `getStored`
1782
+ * answers by the field's declared codec, not by how the document was built.
1802
1783
  *
1803
1784
  * Parse warnings and the `conform::*` diagnostics both land on
1804
1785
  * `doc.warnings`. Throws on a parse failure, or when `markdown` declares a
1805
- * `$quill` this quill does not answer to: nothing conforms under the wrong
1806
- * schema. To open a document whose `$quill` is stale, use the transport
1807
- * door (`Document.fromMarkdown`, `setQuillRef`, then `quill.conform`).
1786
+ * `$quill` this quill does not answer to. To open a document whose `$quill`
1787
+ * is stale, use `Document.fromMarkdown`, `setQuillRef`, then `quill.conform`.
1808
1788
  * @param {string} markdown
1809
1789
  * @returns {Document}
1810
1790
  */
@@ -1826,15 +1806,11 @@ export class Quill {
1826
1806
  }
1827
1807
  }
1828
1808
  /**
1829
- * The resolved-value view of `doc` against this quill's schema: for every
1830
- * declared field the value the render projection would use and the
1831
- * `FieldSource` rung it came from (`"authored" | "default" | "zero"`), in
1832
- * one call. The card body is a `body` sibling on its card (row `name`
1833
- * `"body"`), never a row in `fields`: `null` when the kind enables no body.
1834
- *
1835
- * Value and provenance only: completeness and errors stay `validate`'s
1836
- * (a consumer merges it with its own diagnostic producers regardless), and
1837
- * schema guidance reads from `Quill.schema`.
1809
+ * The resolved-value view of `doc`: for every declared field, the value the
1810
+ * render projection would use and the `FieldSource` rung it came from
1811
+ * (`"authored" | "default" | "blank"`). The card body is a `body` sibling on
1812
+ * its card, never a row in `fields`, and `null` when the kind enables no
1813
+ * body. Value and provenance only; completeness stays `validate`'s.
1838
1814
  * @param {Document} doc
1839
1815
  * @returns {Resolved}
1840
1816
  */
@@ -1855,11 +1831,9 @@ export class Quill {
1855
1831
  }
1856
1832
  }
1857
1833
  /**
1858
- * Document schema for the quill: the user-fillable fields plus their
1859
- * `ui` hints (title / group / compact / multiline). The single
1860
- * field-metadata surface: drives form editors and LLM/MCP consumers
1861
- * alike. Key order in `fields`/`properties` is declaration order: the
1862
- * ordering contract. Returns the `QuillSchema` shape.
1834
+ * Document schema for the quill: the user-fillable fields plus their `ui`
1835
+ * hints. Key order in `fields`/`properties` is declaration order, the
1836
+ * ordering contract.
1863
1837
  * @returns {QuillSchema}
1864
1838
  */
1865
1839
  get schema() {
@@ -1879,15 +1853,13 @@ export class Quill {
1879
1853
  }
1880
1854
  /**
1881
1855
  * Seed a starter composable `Card` of the given kind (carries `$kind`),
1882
- * layering an optional per-kind seed `overlay` over the schema-example
1883
- * base (`overlay › example › absent`). Returns `undefined` if `cardKind`
1884
- * is not declared in this quill's schema, else a `Card` that feeds
1885
- * straight into `Document.insertCard`.
1856
+ * layering an optional per-kind seed `overlay` over the schema-example base
1857
+ * (`overlay › example › absent`). `undefined` when `cardKind` is not
1858
+ * declared in this quill's schema.
1886
1859
  *
1887
1860
  * Pass `document.seedOverlay(cardKind)` as `overlay` so a card added to a
1888
1861
  * template-derived document inherits its curated starting values; omit it
1889
- * (or pass `undefined` / `null`) for the bare schema seed. `overlay` is a
1890
- * plain object: this reads the document, it does not mutate it.
1862
+ * for the bare schema seed.
1891
1863
  * @param {string} card_kind
1892
1864
  * @param {Record<string, unknown> | undefined} overlay
1893
1865
  * @returns {Card | undefined}
@@ -1910,12 +1882,10 @@ export class Quill {
1910
1882
  }
1911
1883
  }
1912
1884
  /**
1913
- * Seed a starter `Document` from the schema, the main card plus one
1914
- * instance of each composable card kind, each committing its fields'
1915
- * `example:` values and leaving every other field absent (interpolated at
1916
- * render: `default:`, else type-empty zero). Illustration-first: a field
1917
- * with both an `example` and a `default` renders its example. See
1918
- * `prose/canon/SCHEMAS.md` § "Document seeding".
1885
+ * Seed a starter `Document` from the schema: the main card plus one instance
1886
+ * of each composable card kind, each committing its fields' `example:`
1887
+ * values and leaving every other field absent (interpolated at render as
1888
+ * `default:`, else the field's blank). A field with both renders its example.
1919
1889
  * @returns {Document}
1920
1890
  */
1921
1891
  seedDocument() {
@@ -1924,9 +1894,7 @@ export class Quill {
1924
1894
  }
1925
1895
  /**
1926
1896
  * Seed a starter main `Card` (carries `$quill`) from the schema: the
1927
- * `$kind: main` card of [`seedDocument`](Self::seed_document) in
1928
- * isolation, committing each field's `example:` value. Returns the same
1929
- * `Card` shape as the `Document.main` getter.
1897
+ * `$kind: main` card of [`seedDocument`](Self::seed_document) alone.
1930
1898
  * @returns {Card}
1931
1899
  */
1932
1900
  seedMain() {
@@ -1945,16 +1913,13 @@ export class Quill {
1945
1913
  }
1946
1914
  }
1947
1915
  /**
1948
- * Flatten this quill back into its canonical file tree: the inverse of
1949
- * [`fromTree`](Self::from_tree). Round-trips: `Quill.fromTree(q.toTree())`
1950
- * reproduces an equivalent quill.
1916
+ * Flatten this quill back into its canonical file tree, the inverse of
1917
+ * [`fromTree`](Self::from_tree). Keys are `"/"`-joined relative paths.
1951
1918
  *
1952
1919
  * This is how a quill crosses a WASM linear-memory boundary as data: a
1953
- * `Quill` built in one build (e.g. the Typst-less `@quillmark/wasm/core`)
1954
- * cannot be passed to an engine in another (separate linear memories), so
1920
+ * `Quill` built in one build cannot be passed to an engine in another, so
1955
1921
  * `@quillmark/wasm/runtime` re-feeds this tree to the backend build's
1956
- * `Quill.fromTree` on demand. Keys are `"/"`-joined relative paths,
1957
- * matching what `fromTree` accepts.
1922
+ * `Quill.fromTree` on demand.
1958
1923
  * @returns {Map<string, Uint8Array>}
1959
1924
  */
1960
1925
  toTree() {
@@ -1963,14 +1928,9 @@ export class Quill {
1963
1928
  }
1964
1929
  /**
1965
1930
  * Validate `doc` against this quill's schema, returning every diagnostic
1966
- * (an empty array when the document is valid).
1967
- *
1968
- * Forwards the canonical `validation::*` diagnostics (same `code`,
1969
- * `path`, and `hint` the engine emits) including the non-fatal
1970
- * `validation::must_fill` warning for each `!must_fill` marker left in
1971
- * the document. Field values, defaults, and order are not part of this
1972
- * surface: read them from the `Document` payload and `Quill.schema`
1973
- * (schema key order is display order).
1931
+ * (empty when the document is valid). Forwards the canonical
1932
+ * `validation::*` diagnostics the engine emits, including the non-fatal
1933
+ * `validation::must_fill` warning per `!must_fill` marker left behind.
1974
1934
  * @param {Document} doc
1975
1935
  * @returns {Diagnostic[]}
1976
1936
  */
@@ -2064,9 +2024,9 @@ export class Quillmark {
2064
2024
  }
2065
2025
  }
2066
2026
  /**
2067
- * The output formats `quill`'s backend can emit. Static capability:
2068
- * resolves the backend but compiles nothing. Throws `engine::backend_not_found`
2069
- * if no registered backend matches the quill's declared backend.
2027
+ * The output formats `quill`'s backend can emit; resolves the backend but
2028
+ * compiles nothing. Throws `engine::backend_not_found` when no registered
2029
+ * backend matches the quill's declared one.
2070
2030
  * @param {Quill} quill
2071
2031
  * @returns {OutputFormat[]}
2072
2032
  */
@@ -2087,11 +2047,9 @@ export class Quillmark {
2087
2047
  }
2088
2048
  }
2089
2049
  /**
2090
- * Pre-session hint: `true` iff `quill`'s backend can paint sessions to a
2091
- * canvas, derived from the backend's output formats; `false` when the
2092
- * backend is unsupported. Use as a cheap precondition probe before mounting
2093
- * a canvas-based preview UI; the authoritative answer is the session's
2094
- * `supportsCanvas` getter once `open()` has been called.
2050
+ * Whether `quill`'s backend can paint sessions to a canvas; `false` when the
2051
+ * backend is unsupported. A cheap probe before mounting a preview UI. The
2052
+ * authoritative answer is the session's `supportsCanvas` getter.
2095
2053
  * @param {Quill} quill
2096
2054
  * @returns {boolean}
2097
2055
  */
@@ -2104,8 +2062,7 @@ export class Quillmark {
2104
2062
  if (Symbol.dispose) Quillmark.prototype[Symbol.dispose] = Quillmark.prototype.free;
2105
2063
 
2106
2064
  /**
2107
- * Export a canonical `Content` content to its markdown projection: the pure
2108
- * on-demand codec behind `exportMarkdown(card.body)`. Throws if `rt` is not a
2065
+ * Export canonical `Content` to its markdown projection. Throws if `rt` is not
2109
2066
  * canonical content.
2110
2067
  * @param {Content} rt
2111
2068
  * @returns {string}
@@ -2137,10 +2094,8 @@ export function exportMarkdown(rt) {
2137
2094
 
2138
2095
  /**
2139
2096
  * Serialize structured [`DocPathSeg`] segments back to the canonical path
2140
- * string: the inverse of `parseDocPath`, for a consumer that builds a path
2141
- * rather than reads one. Throws on a segment array the deserializer rejects,
2142
- * and on an empty segment array (symmetric with `parseDocPath("")`, which
2143
- * throws "empty path").
2097
+ * string: the inverse of `parseDocPath`. Throws on a segment array the
2098
+ * deserializer rejects, and on an empty one.
2144
2099
  * @param {DocPathSeg[]} segs
2145
2100
  * @returns {string}
2146
2101
  */
@@ -2170,10 +2125,9 @@ export function formatDocPath(segs) {
2170
2125
  }
2171
2126
 
2172
2127
  /**
2173
- * Import a markdown string to a canonical `Content` content: the pure,
2174
- * document-free codec. Pair with `overwrite(addr, importMarkdown(md))` to spell
2175
- * the cold (anchor-losing) write at the call site; prefer `revise` for edit
2176
- * semantics. Throws on an over-nested input.
2128
+ * Import a markdown string to canonical `Content`: the pure, document-free
2129
+ * codec. `overwrite(addr, importMarkdown(md))` spells the cold, anchor-losing
2130
+ * write; prefer `revise` for edit semantics. Throws on an over-nested input.
2177
2131
  * @param {string} markdown
2178
2132
  * @returns {Content}
2179
2133
  */
@@ -2197,10 +2151,9 @@ export function importMarkdown(markdown) {
2197
2151
 
2198
2152
  /**
2199
2153
  * Map a base content position (a USV index into `Content.text`, not a UTF-16
2200
- * offset) through a `delta` to its new USV position: the pure position-mapping
2201
- * codec an editor bridge composes to hold a caret stable across a `revise`.
2202
- * `assoc` decides the side of a same-position insertion (`"after"` moves past
2203
- * it). Throws on a malformed `delta`.
2154
+ * offset) through a `delta` to its new position, holding a caret stable across
2155
+ * a `revise`. `assoc` decides the side of a same-position insertion (`"after"`
2156
+ * moves past it). Throws on a malformed `delta`.
2204
2157
  * @param {Delta} delta
2205
2158
  * @param {number} pos
2206
2159
  * @param {Assoc} assoc
@@ -2223,11 +2176,10 @@ export function mapPos(delta, pos, assoc) {
2223
2176
  }
2224
2177
 
2225
2178
  /**
2226
- * Parse a canonical document-model `Diagnostic.path`
2227
- * (`cards.<kind>[<i>].<field>`, `main.body`, `recipients[0].name`) into its
2228
- * structured [`DocPathSeg`] segments: the exported inverse of the engine's
2229
- * one path serializer, so a consumer routes on segments instead of regexing
2230
- * the string. Throws on a malformed path.
2179
+ * Parse a canonical document-model `Diagnostic.path` (`cards.<kind>[<i>].<field>`,
2180
+ * `main.body`, `recipients[0].name`) into structured [`DocPathSeg`] segments, so
2181
+ * a consumer routes on segments instead of regexing the string. Throws on a
2182
+ * malformed path.
2231
2183
  * @param {string} path
2232
2184
  * @returns {DocPathSeg[]}
2233
2185
  */
@@ -2250,12 +2202,10 @@ export function parseDocPath(path) {
2250
2202
  }
2251
2203
 
2252
2204
  /**
2253
- * Rebase `markdown` onto a `base` content, the pure, document-free twin of
2254
- * `revise`: cold-import + `diff_import`, returning the new `content` and the
2255
- * text `delta` (its offsets USV indices into `Content.text`, surviving anchors
2256
- * rebased). Use it to compute a revise without a document in hand; `revise(addr,
2257
- * md)` fuses this with the store for atomicity. Throws on an over-nested
2258
- * markdown input or a non-content `base`.
2205
+ * Rebase `markdown` onto a `base` content: the document-free twin of `revise`,
2206
+ * returning the new `content` and the text `delta` (offsets are USV indices into
2207
+ * `Content.text`, surviving anchors rebased). Throws on an over-nested markdown
2208
+ * input or a non-content `base`.
2259
2209
  * @param {Content} base
2260
2210
  * @param {string} markdown
2261
2211
  * @returns {{ content: Content; delta: Delta }}
@@ -2279,13 +2229,9 @@ export function rebase(base, markdown) {
2279
2229
  }
2280
2230
 
2281
2231
  /**
2282
- * Runs at instantiation (the wasm-bindgen start section): installs the panic
2283
- * hook, so a Rust panic reaches the console as a stack trace rather than
2284
- * `unreachable`.
2285
- *
2286
- * Not the package's `init`. That name belongs to the hand-written runtime,
2287
- * which owns instantiation itself (`runtime/runtime.js`); this runs as part of
2288
- * the instantiation it awaits.
2232
+ * Runs at instantiation, so a Rust panic reaches the console as a stack trace
2233
+ * rather than `unreachable`. Not the package's `init` that name belongs to
2234
+ * the hand-written runtime, which owns instantiation itself.
2289
2235
  */
2290
2236
  export function start() {
2291
2237
  wasm.start();