@quillmark/wasm 0.94.0 → 0.96.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_bg.js CHANGED
@@ -21,20 +21,24 @@ export class Document {
21
21
  }
22
22
  /**
23
23
  * Build a composable card of `kind`, typed-commit `fields` onto it, set its
24
- * body from optional markdown, and append it — the ABI under
25
- * `writer.addCard`. Fuses `makeCard` + typed commit + `pushCard`
26
- * transactionally: the card is committed in full before it joins the
27
- * document, so a rejected field (or an invalid kind or body) leaves the
28
- * document untouched. Field errors throw the same per-field diagnostic
29
- * bundle as [`commitFields`](Self::commit_fields), including an
30
- * `[EditError::UnknownField]` per undeclared name; an invalid kind or body
31
- * throws a single-entry bundle keyed `$kind` / `$body`.
24
+ * body from optional markdown, and place it — the ABI under `writer.addCard`.
25
+ * `at` picks the position: absent appends, a number inserts at that index
26
+ * (`0..=cards.length`), so a positioned typed insert is one atomic call
27
+ * rather than `addCard` + `moveCard`. Fuses `makeCard` + typed commit +
28
+ * insertion transactionally: the card is committed in full before it joins
29
+ * the document, so a rejected field (or an invalid kind, body, or
30
+ * out-of-range `at`) leaves the document untouched. Field errors throw the
31
+ * same per-field diagnostic bundle as [`commitFields`](Self::commit_fields),
32
+ * including an `edit::unknown_field` per undeclared name; an invalid
33
+ * kind or body, or an out-of-range position, throws a single-entry bundle
34
+ * keyed `$kind` / `$body`.
32
35
  * @param {Quill} quill
33
36
  * @param {string} kind
34
37
  * @param {Record<string, unknown>} [fields]
35
38
  * @param {string} [body]
39
+ * @param {number} [at]
36
40
  */
37
- addCard(quill, kind, fields, body) {
41
+ _addCard(quill, kind, fields, body, at) {
38
42
  try {
39
43
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
40
44
  _assertClass(quill, Quill);
@@ -42,7 +46,7 @@ export class Document {
42
46
  const len0 = WASM_VECTOR_LEN;
43
47
  var ptr1 = isLikeNone(body) ? 0 : passStringToWasm0(body, wasm.__wbindgen_export, wasm.__wbindgen_export2);
44
48
  var len1 = WASM_VECTOR_LEN;
45
- wasm.document_addCard(retptr, this.__wbg_ptr, quill.__wbg_ptr, ptr0, len0, isLikeNone(fields) ? 0 : addHeapObject(fields), ptr1, len1);
49
+ wasm.document__addCard(retptr, this.__wbg_ptr, quill.__wbg_ptr, ptr0, len0, isLikeNone(fields) ? 0 : addHeapObject(fields), ptr1, len1, isLikeNone(at) ? 0x100000001 : (at) >>> 0);
46
50
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
47
51
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
48
52
  if (r1) {
@@ -53,21 +57,39 @@ export class Document {
53
57
  }
54
58
  }
55
59
  /**
56
- * **Apply** a committed corpus edit `bundle` (`{ delta?, lineOps?, markOps? }`)
57
- * at `addr` — the editor splice: text delta first, then line ops, then mark
58
- * ops (mark ranges in post-delta coordinates), each all-or-nothing. An absent
59
- * `addr.field` targets the body, an absent `addr.card` the main card.
60
+ * Typed field write at `addr`, resolving the field's schema `type` from
61
+ * `quill` — the stable ABI under the runtime `writer.set` / `writer.card(i).set`.
62
+ * The one write verb for **every** field type (richtext, scalar, array,
63
+ * object); the schema carries the `inline` constraint, so no type token or
64
+ * flag is passed. A richtext-typed field stores the canonical content, so
65
+ * identity marks (anchors, island ids) and content-only marks (e.g.
66
+ * `underline`) live on it and survive compiles and the storage DTO. Values
67
+ * use the encoding the seam already speaks: a content object or markdown
68
+ * string for richtext, a scalar/array/object otherwise.
60
69
  *
61
- * Throws on an out-of-range card, a field that is not richtext, a malformed
62
- * bundle, or an op that applies out of bounds (the value is unchanged on a
63
- * failed apply).
64
- * @param {Addr} addr
65
- * @param {ChangeBundle} bundle
70
+ * A bare string is `Addr` shorthand for `{ field }`; `{ card, field }`
71
+ * targets a composable card (its `$kind` resolves the schema). A body
72
+ * address throws — a body has no field schema; write it with `writer.setBody`
73
+ * / `revise`. A field declared in the schema is strict-committed (a mismatch
74
+ * throws now, not at render); a name the schema does not declare throws
75
+ * `edit::unknown_field` rather than falling to the opaque store — on
76
+ * the typed path it is a typo. Use [`storeField`](Document::store_field) for
77
+ * opaque storage. Also throws `edit::field_conform` /
78
+ * `edit::field_richtext_decode` / `edit::field_richtext_not_inline`
79
+ * on a typed mismatch, `edit::invalid_field_name` on a malformed name,
80
+ * and `edit::index_out_of_range` on an out-of-range card.
81
+ *
82
+ * The `quill` handle is passed per call because a `Document` carries only a
83
+ * `$quill` reference, not the resolved schema.
84
+ * @param {Quill} quill
85
+ * @param {Addr | string} addr
86
+ * @param {any} value
66
87
  */
67
- applyChange(addr, bundle) {
88
+ _commitField(quill, addr, value) {
68
89
  try {
69
90
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
70
- wasm.document_applyChange(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(bundle));
91
+ _assertClass(quill, Quill);
92
+ wasm.document__commitField(retptr, this.__wbg_ptr, quill.__wbg_ptr, addHeapObject(addr), addHeapObject(value));
71
93
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
72
94
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
73
95
  if (r1) {
@@ -78,46 +100,63 @@ export class Document {
78
100
  }
79
101
  }
80
102
  /**
81
- * Authoring-ergonomics header introducing a blueprint to an LLM/MCP
82
- * consumer for the given `quillName`. Re-exposes core's canonical text for
83
- * JS consumers; any surface that draws from the same core source stays
84
- * uniform.
85
- * @param {string} quill_name
86
- * @returns {string}
103
+ * Batched twin of [`commitField`](Document::commit_field): typed-commit
104
+ * several fields on the card `addr` targets atomically, resolving each
105
+ * field's schema `type` from `quill`. `addr` is a **card address**
106
+ * (`{ card }`, absent = main; a present `field` throws). All-or-nothing with
107
+ * the same per-field-diagnostic error contract as
108
+ * [`storeFields`](Document::store_fields) — nothing is applied on error and
109
+ * the thrown error's `diagnostics` carry one entry per offending field,
110
+ * including an `edit::unknown_field` for any name the schema does not
111
+ * declare, so a whole-form submit sees every typo in one pass. Throws on an
112
+ * out-of-range card.
113
+ * @param {Quill} quill
114
+ * @param {CardAddr} addr
115
+ * @param {Record<string, unknown>} fields
87
116
  */
88
- static blueprintInstruction(quill_name) {
89
- let deferred2_0;
90
- let deferred2_1;
117
+ _commitFields(quill, addr, fields) {
91
118
  try {
92
119
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
93
- const ptr0 = passStringToWasm0(quill_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
94
- const len0 = WASM_VECTOR_LEN;
95
- wasm.document_blueprintInstruction(retptr, ptr0, len0);
120
+ _assertClass(quill, Quill);
121
+ wasm.document__commitFields(retptr, this.__wbg_ptr, quill.__wbg_ptr, addHeapObject(addr), addHeapObject(fields));
96
122
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
97
123
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
98
- deferred2_0 = r0;
99
- deferred2_1 = r1;
100
- return getStringFromWasm0(r0, r1);
124
+ if (r1) {
125
+ throw takeObject(r0);
126
+ }
101
127
  } finally {
102
128
  wasm.__wbindgen_add_to_stack_pointer(16);
103
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
104
129
  }
105
130
  }
106
131
  /**
107
- * Number of composable cards (excludes the main card). O(1).
108
- * @returns {number}
109
- */
110
- get cardCount() {
111
- const ret = wasm.document_cardCount(this.__wbg_ptr);
112
- return ret >>> 0;
113
- }
114
- /**
115
- * @returns {Card[]}
132
+ * Interpreted read at `addr`, resolving the field's declared `type` from
133
+ * `quill` — the stable ABI under the runtime `reader.get` / `reader.card(i).get`.
134
+ * The schema-plane twin of the quill-free [`get`](Self::get): a `richtext`
135
+ * field returns its markdown projection, every other declared type its
136
+ * canonical value verbatim, so a consumer holding the quill reads by field
137
+ * meaning rather than by wire shape.
138
+ *
139
+ * A bare string is `Addr` shorthand for `{ field }`; `{ card, field }`
140
+ * targets a composable card (its `$kind` resolves the schema). Returns
141
+ * `undefined` for an **absent** field. An absent `addr.field` reads the body
142
+ * markdown — quill-free, mirroring [`getMarkdown`](Self::get_markdown), since
143
+ * a body's type is a format fact, not a schema fact. A name the schema does
144
+ * not declare throws `edit::unknown_field` (the authority `getMarkdown`
145
+ * lacks — there an unknown name reads back `undefined`); a `richtext` field
146
+ * holding a value that does not decode throws `edit::field_richtext_decode`;
147
+ * an out-of-range `addr.card` throws.
148
+ *
149
+ * The `quill` handle is passed per call because a `Document` carries only a
150
+ * `$quill` reference, not the resolved schema.
151
+ * @param {Quill} quill
152
+ * @param {Addr | string} addr
153
+ * @returns {unknown}
116
154
  */
117
- get cards() {
155
+ _readerGet(quill, addr) {
118
156
  try {
119
157
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
120
- wasm.document_cards(retptr, this.__wbg_ptr);
158
+ _assertClass(quill, Quill);
159
+ wasm.document__readerGet(retptr, this.__wbg_ptr, quill.__wbg_ptr, addHeapObject(addr));
121
160
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
122
161
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
123
162
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -130,59 +169,59 @@ export class Document {
130
169
  }
131
170
  }
132
171
  /**
133
- * @returns {Document}
134
- */
135
- clone() {
136
- const ret = wasm.document_clone(this.__wbg_ptr);
137
- return Document.__wrap(ret);
138
- }
139
- /**
140
- * Typed field write on the composable card at `index` — the card-indexed
141
- * twin of [`commitField`](Document::commit_field). Resolves the field's
142
- * type from the card's `$kind` schema in `quill` and strict-commits it.
172
+ * Revise the richtext field at `addr` from markdown, typed *and*
173
+ * anchor-preserving — the ABI under `writer.reviseField`. Resolves the
174
+ * field's schema from `quill` (main card, or the addressed card's `$kind`)
175
+ * and defers to [`TypedWriter::revise_field`](quillmark_core::TypedWriter::revise_field):
176
+ * surviving anchors rebase (as [`revise`](Self::revise)), then the diffed
177
+ * result is schema-conformed, so a `richtext(inline)` field rejects a
178
+ * multi-block result with `edit::field_richtext_not_inline`. Returns the
179
+ * text [`Delta`].
143
180
  *
144
- * Throws `[EditError::IndexOutOfRange]` when `index` is out of range, and
145
- * the same typed-mismatch / name errors as `commitField` — including
146
- * `[EditError::UnknownField]` for a field the card-kind schema does not
147
- * declare (an unknown `$kind` has no schema, so every field is undeclared).
181
+ * `addr` must name a field (a bare string is `{ field }`); a body address
182
+ * throws (a body carries no field schema — use [`revise`](Self::revise)). A
183
+ * name the schema does not declare throws `edit::unknown_field`. Throws
184
+ * on an out-of-range card. Hidden from the `.d.ts`; the visible verb is
185
+ * `writer.reviseField` in the runtime layer.
148
186
  * @param {Quill} quill
149
- * @param {number} index
150
- * @param {string} name
151
- * @param {any} value
187
+ * @param {Addr | string} addr
188
+ * @param {string} markdown
189
+ * @returns {Delta}
152
190
  */
153
- commitCardField(quill, index, name, value) {
191
+ _reviseField(quill, addr, markdown) {
154
192
  try {
155
193
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
156
194
  _assertClass(quill, Quill);
157
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
195
+ const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
158
196
  const len0 = WASM_VECTOR_LEN;
159
- wasm.document_commitCardField(retptr, this.__wbg_ptr, quill.__wbg_ptr, index, ptr0, len0, addHeapObject(value));
197
+ wasm.document__reviseField(retptr, this.__wbg_ptr, quill.__wbg_ptr, addHeapObject(addr), ptr0, len0);
160
198
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
161
199
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
162
- if (r1) {
163
- throw takeObject(r0);
200
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
201
+ if (r2) {
202
+ throw takeObject(r1);
164
203
  }
204
+ return takeObject(r0);
165
205
  } finally {
166
206
  wasm.__wbindgen_add_to_stack_pointer(16);
167
207
  }
168
208
  }
169
209
  /**
170
- * Batched twin of [`commitCardField`](Document::commit_card_field):
171
- * typed-commit several fields on the card at `index` atomically, resolving
172
- * each field's type from the card's `$kind` schema in `quill`. All-or-nothing
173
- * with the same per-field-diagnostic contract as
174
- * [`commitFields`](Document::commit_fields), including an
175
- * `[EditError::UnknownField]` diagnostic per undeclared name. Throws
176
- * `[EditError::IndexOutOfRange]` when `index` is out of range.
177
- * @param {Quill} quill
178
- * @param {number} index
179
- * @param {Record<string, unknown>} fields
210
+ * **Apply** a committed content edit `bundle` (`{ delta?, lineOps?, markOps? }`)
211
+ * at `addr` the editor splice: text delta first, then line ops, then mark
212
+ * ops (mark ranges in final-text coordinates), each all-or-nothing. An absent
213
+ * `addr.field` targets the body, an absent `addr.card` the main card.
214
+ *
215
+ * Throws on an out-of-range card, a field that is not richtext, a malformed
216
+ * bundle, or an op that applies out of bounds (the value is unchanged on a
217
+ * failed apply).
218
+ * @param {Addr | string} addr
219
+ * @param {ChangeBundle} bundle
180
220
  */
181
- commitCardFields(quill, index, fields) {
221
+ applyChange(addr, bundle) {
182
222
  try {
183
223
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
184
- _assertClass(quill, Quill);
185
- wasm.document_commitCardFields(retptr, this.__wbg_ptr, quill.__wbg_ptr, index, addHeapObject(fields));
224
+ wasm.document_applyChange(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(bundle));
186
225
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
187
226
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
188
227
  if (r1) {
@@ -193,71 +232,102 @@ export class Document {
193
232
  }
194
233
  }
195
234
  /**
196
- * Typed field write on the main card, resolving the field's schema `type`
197
- * from `quill` the one write verb for **every** field type (richtext,
198
- * scalar, array, object). The schema carries the `inline` constraint, so no
199
- * type token or flag is passed. A richtext-typed field stores the canonical
200
- * corpus, so identity marks (anchors, island ids) and corpus-only marks
201
- * (e.g. `underline`) live on it and survive compiles and the storage DTO.
202
- * Values use the encoding the seam already speaks: a corpus object
203
- * or markdown string for richtext, a scalar/array/object otherwise.
204
- *
205
- * A field declared in the schema is strict-committed — a mismatch throws
206
- * now, not at render. A name the schema does not declare throws
207
- * `[EditError::UnknownField]` rather than falling to the opaque store: on
208
- * the typed path it is a typo. Use [`setField`](Document::set_field) when
209
- * opaque storage is the intent. Also throws `[EditError::FieldConform]` /
210
- * `[EditError::FieldRichtextDecode]` / `[EditError::FieldRichtextNotInline]`
211
- * on a typed mismatch and `[EditError::InvalidFieldName]` on a malformed
212
- * name.
213
- *
214
- * The `quill` handle is passed per call because a `Document` carries only a
215
- * `$quill` reference, not the resolved schema.
216
- * @param {Quill} quill
217
- * @param {string} name
218
- * @param {any} value
235
+ * Authoring-ergonomics header introducing a blueprint to an LLM/MCP
236
+ * consumer for the given `quillName`. Re-exposes core's canonical text for
237
+ * JS consumers; any surface that draws from the same core source stays
238
+ * uniform.
239
+ * @param {string} quill_name
240
+ * @returns {string}
219
241
  */
220
- commitField(quill, name, value) {
242
+ static blueprintInstruction(quill_name) {
243
+ let deferred2_0;
244
+ let deferred2_1;
221
245
  try {
222
246
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
223
- _assertClass(quill, Quill);
224
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
247
+ const ptr0 = passStringToWasm0(quill_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
225
248
  const len0 = WASM_VECTOR_LEN;
226
- wasm.document_commitField(retptr, this.__wbg_ptr, quill.__wbg_ptr, ptr0, len0, addHeapObject(value));
249
+ wasm.document_blueprintInstruction(retptr, ptr0, len0);
227
250
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
228
251
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
229
- if (r1) {
230
- throw takeObject(r0);
252
+ deferred2_0 = r0;
253
+ deferred2_1 = r1;
254
+ return getStringFromWasm0(r0, r1);
255
+ } finally {
256
+ wasm.__wbindgen_add_to_stack_pointer(16);
257
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
258
+ }
259
+ }
260
+ /**
261
+ * A single composable card by index — the whole `Card`, the card-indexed
262
+ * twin of the [`main`](Self::main) getter, so reading one card need not
263
+ * materialize every card via [`cards`](Self::cards). An out-of-range
264
+ * `index` throws `edit::index_out_of_range`, matching the card write
265
+ * verbs.
266
+ * @param {number} index
267
+ * @returns {Card}
268
+ */
269
+ card(index) {
270
+ try {
271
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
272
+ wasm.document_card(retptr, this.__wbg_ptr, index);
273
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
274
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
275
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
276
+ if (r2) {
277
+ throw takeObject(r1);
231
278
  }
279
+ return takeObject(r0);
232
280
  } finally {
233
281
  wasm.__wbindgen_add_to_stack_pointer(16);
234
282
  }
235
283
  }
236
284
  /**
237
- * Batched twin of [`commitField`](Document::commit_field): typed-commit
238
- * several main-card fields atomically, resolving each field's schema `type`
239
- * from `quill`. All-or-nothing with the same per-field-diagnostic error
240
- * contract as [`setFields`](Document::set_fields) — nothing is applied on
241
- * error and the thrown error's `diagnostics` carry one entry per offending
242
- * field, including an `[EditError::UnknownField]` for any name the schema
243
- * does not declare, so a whole-form submit sees every typo in one pass.
244
- * @param {Quill} quill
245
- * @param {Record<string, unknown>} fields
285
+ * Number of composable cards (excludes the main card). O(1).
286
+ * @returns {number}
287
+ */
288
+ get cardCount() {
289
+ const ret = wasm.document_cardCount(this.__wbg_ptr);
290
+ return ret >>> 0;
291
+ }
292
+ /**
293
+ * The index of the first composable card whose `$id` equals `id`, or
294
+ * `undefined` when none carries it. Resolves the canonical durable address
295
+ * without a hand-rolled scan over [`cards`](Self::cards); `$id` is
296
+ * non-unique by design, so the first match wins.
297
+ * @param {string} id
298
+ * @returns {number | undefined}
246
299
  */
247
- commitFields(quill, fields) {
300
+ cardIndexById(id) {
301
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
302
+ const len0 = WASM_VECTOR_LEN;
303
+ const ret = wasm.document_cardIndexById(this.__wbg_ptr, ptr0, len0);
304
+ return takeObject(ret);
305
+ }
306
+ /**
307
+ * @returns {Card[]}
308
+ */
309
+ get cards() {
248
310
  try {
249
311
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
250
- _assertClass(quill, Quill);
251
- wasm.document_commitFields(retptr, this.__wbg_ptr, quill.__wbg_ptr, addHeapObject(fields));
312
+ wasm.document_cards(retptr, this.__wbg_ptr);
252
313
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
253
314
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
254
- if (r1) {
255
- throw takeObject(r0);
315
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
316
+ if (r2) {
317
+ throw takeObject(r1);
256
318
  }
319
+ return takeObject(r0);
257
320
  } finally {
258
321
  wasm.__wbindgen_add_to_stack_pointer(16);
259
322
  }
260
323
  }
324
+ /**
325
+ * @returns {Document}
326
+ */
327
+ clone() {
328
+ const ret = wasm.document_clone(this.__wbg_ptr);
329
+ return Document.__wrap(ret);
330
+ }
261
331
  /**
262
332
  * Schema version this build writes via [`toJson`](Document::to_json).
263
333
  * Tracks the `Document` model version (not the running crate version):
@@ -388,20 +458,70 @@ export class Document {
388
458
  }
389
459
  }
390
460
  /**
391
- * Read a main-card field's stored value — the raw payload value (a corpus
392
- * object for a richtext field, a scalar/array/object otherwise), or
393
- * `undefined` when the field is absent. The quill-free read: reads need no
394
- * schema, so they live on `Document`, not the typed writer. For the markdown
395
- * projection of a richtext value use [`getMarkdown`](Self::get_markdown).
396
- * @param {string} name
397
- * @returns {any}
461
+ * Read the value at `addr` — the raw stored payload value of a field (a
462
+ * content object for a richtext field, a scalar/array/object otherwise), or
463
+ * the **body content** when `addr.field` is absent. A bare string is `Addr`
464
+ * shorthand for `{ field }`. Reads are total over the field axis: an absent
465
+ * field is `undefined`; only an out-of-range `addr.card` throws
466
+ * `edit::index_out_of_range`. Reads need no schema, so they live on
467
+ * `Document`, not the typed writer; for the markdown projection of a
468
+ * richtext value use [`getMarkdown`](Self::get_markdown).
469
+ * @param {Addr | string} addr
470
+ * @returns {unknown}
471
+ */
472
+ get(addr) {
473
+ try {
474
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
475
+ wasm.document_get(retptr, this.__wbg_ptr, addHeapObject(addr));
476
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
477
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
478
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
479
+ if (r2) {
480
+ throw takeObject(r1);
481
+ }
482
+ return takeObject(r0);
483
+ } finally {
484
+ wasm.__wbindgen_add_to_stack_pointer(16);
485
+ }
486
+ }
487
+ /**
488
+ * The whole `$ext` map at `addr` (a card address, absent `card` = main), or
489
+ * `undefined` when the card carries none. The fine-grained `$ext` read —
490
+ * your own state without serializing the whole card. Throws on a present
491
+ * `field` (a card address takes only `card`) or an out-of-range card.
492
+ * @param {CardAddr} [addr]
493
+ * @returns {Record<string, unknown> | undefined}
494
+ */
495
+ getExt(addr) {
496
+ try {
497
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
498
+ wasm.document_getExt(retptr, this.__wbg_ptr, addHeapObject(addr));
499
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
500
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
501
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
502
+ if (r2) {
503
+ throw takeObject(r1);
504
+ }
505
+ return takeObject(r0);
506
+ } finally {
507
+ wasm.__wbindgen_add_to_stack_pointer(16);
508
+ }
509
+ }
510
+ /**
511
+ * The value stored under `$ext[ns]` at `addr` (a card address, absent `card`
512
+ * = main), or `undefined`. The namespace-scoped `$ext` read — your own slot
513
+ * without a whole-card serialize, and non-destructive (unlike
514
+ * `removeExtNamespace`). Throws on a present `field` or an out-of-range card.
515
+ * @param {CardAddr} addr
516
+ * @param {string} ns
517
+ * @returns {unknown}
398
518
  */
399
- get(name) {
519
+ getExtNamespace(addr, ns) {
400
520
  try {
401
521
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
402
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
522
+ const ptr0 = passStringToWasm0(ns, wasm.__wbindgen_export, wasm.__wbindgen_export2);
403
523
  const len0 = WASM_VECTOR_LEN;
404
- wasm.document_get(retptr, this.__wbg_ptr, ptr0, len0);
524
+ wasm.document_getExtNamespace(retptr, this.__wbg_ptr, addHeapObject(addr), ptr0, len0);
405
525
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
406
526
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
407
527
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -414,43 +534,47 @@ export class Document {
414
534
  }
415
535
  }
416
536
  /**
417
- * The markdown projection of a main-card field (`name` given) or the main
418
- * body (`name` omitted) — the on-demand, lossy export (corpus-only marks do
419
- * not survive markdown), returning `""` for an absent field. Re-coins,
420
- * lazily and by name, the projection the eager `fieldMarkdown` /
421
- * `bodyMarkdown` getters dropped in #925; call it only when markdown is what
422
- * you need out.
423
- * @param {string} [name]
537
+ * The **body** markdown projection the main body, or a composable card's
538
+ * body (`{ card }`) — the on-demand, lossy export (content-only marks do not
539
+ * survive markdown). A body's type is a format fact, not a schema fact, so
540
+ * this read stays quill-free; a body is never absent.
541
+ *
542
+ * `addr` is an optional **card address** (`{ card }`, absent = main). A
543
+ * present `field` throws — a field's markdown is read through the
544
+ * schema-plane `quill.reader(doc).get(field)`, which interprets by declared
545
+ * type (#978). An out-of-range `addr.card` throws.
546
+ * @param {CardAddr} [addr]
424
547
  * @returns {string}
425
548
  */
426
- getMarkdown(name) {
427
- let deferred2_0;
428
- let deferred2_1;
549
+ getMarkdown(addr) {
429
550
  try {
430
551
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
431
- var ptr0 = isLikeNone(name) ? 0 : passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
432
- var len0 = WASM_VECTOR_LEN;
433
- wasm.document_getMarkdown(retptr, this.__wbg_ptr, ptr0, len0);
552
+ wasm.document_getMarkdown(retptr, this.__wbg_ptr, addHeapObject(addr));
434
553
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
435
554
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
436
- deferred2_0 = r0;
437
- deferred2_1 = r1;
438
- return getStringFromWasm0(r0, r1);
555
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
556
+ if (r2) {
557
+ throw takeObject(r1);
558
+ }
559
+ return takeObject(r0);
439
560
  } finally {
440
561
  wasm.__wbindgen_add_to_stack_pointer(16);
441
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
442
562
  }
443
563
  }
444
564
  /**
445
- * Insert a card at `index` (must be in `0..=cards.length`). Accepts a
446
- * `CardInput` (see [`pushCard`](Self::push_card)).
447
- * @param {number} index
565
+ * Insert a card the single insertion verb: `at` absent appends, a number
566
+ * inserts at that index (must be in `0..=cards.length`). Accepts a
567
+ * `CardInput` a card read back (`cards` / `removeCard` / `quill.seedCard`),
568
+ * a [`makeCard`](Document::make_card) result, or a bare `{ kind, body }`
569
+ * (every returned `Card` is a valid `CardInput`). Throws if `card.kind` is
570
+ * not a valid kind name, or if `at` is out of range.
448
571
  * @param {CardInput} card
572
+ * @param {number} [at]
449
573
  */
450
- insertCard(index, card) {
574
+ insertCard(card, at) {
451
575
  try {
452
576
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
453
- wasm.document_insertCard(retptr, this.__wbg_ptr, index, addHeapObject(card));
577
+ wasm.document_insertCard(retptr, this.__wbg_ptr, addHeapObject(card), isLikeNone(at) ? 0x100000001 : (at) >>> 0);
454
578
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
455
579
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
456
580
  if (r1) {
@@ -461,8 +585,8 @@ export class Document {
461
585
  }
462
586
  }
463
587
  /**
464
- * **Install** a richtext value at `addr` — **value semantics**, corpus only.
465
- * Stores exactly `rt` (a canonical `RichText` corpus object); the identity
588
+ * **Install** a richtext value at `addr` — **value semantics**, content only.
589
+ * Stores exactly `rt` (a canonical `Content` content object); the identity
466
590
  * anchors of any previous value are gone. An absent `addr.field` targets the
467
591
  * body, an absent `addr.card` the main card. For "here's new markdown," use
468
592
  * [`revise`](Document::revise); the cold-import path is spelled at the call
@@ -470,9 +594,9 @@ export class Document {
470
594
  * source.
471
595
  *
472
596
  * Throws on an out-of-range card, a malformed field name, or an `rt` that is
473
- * not a canonical corpus object.
474
- * @param {Addr} addr
475
- * @param {RichText} rt
597
+ * not a canonical content object.
598
+ * @param {Addr | string} addr
599
+ * @param {Content} rt
476
600
  */
477
601
  install(addr, rt) {
478
602
  try {
@@ -487,6 +611,29 @@ export class Document {
487
611
  wasm.__wbindgen_add_to_stack_pointer(16);
488
612
  }
489
613
  }
614
+ /**
615
+ * Whether the field at `addr` is marked `!must_fill`. A bare string is `Addr`
616
+ * shorthand for `{ field }`. `false` for an absent field (truthful — it isn't
617
+ * marked) and for a body address (a body is never a fill). Only an
618
+ * out-of-range `addr.card` throws.
619
+ * @param {Addr | string} addr
620
+ * @returns {boolean}
621
+ */
622
+ isFill(addr) {
623
+ try {
624
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
625
+ wasm.document_isFill(retptr, this.__wbg_ptr, addHeapObject(addr));
626
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
627
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
628
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
629
+ if (r2) {
630
+ throw takeObject(r1);
631
+ }
632
+ return r0 !== 0;
633
+ } finally {
634
+ wasm.__wbindgen_add_to_stack_pointer(16);
635
+ }
636
+ }
490
637
  /**
491
638
  * Replace this document's contents **in place** from a versioned storage
492
639
  * DTO string — the mutating twin of the static
@@ -536,10 +683,10 @@ export class Document {
536
683
  }
537
684
  /**
538
685
  * Build a fresh `Card` from a kind and a flat field map — the ergonomic
539
- * constructor for `pushCard` / `insertCard`. `fields` is an optional
686
+ * constructor for `insertCard`. `fields` is an optional
540
687
  * `Record<string, unknown>` (each entry becomes a card field, in
541
688
  * insertion order); `body` defaults to `""`. Kind validity is checked by
542
- * `pushCard` / `insertCard`, not here.
689
+ * `insertCard`, not here.
543
690
  * @param {string} kind
544
691
  * @param {Record<string, unknown>} [fields]
545
692
  * @param {string} [body]
@@ -610,27 +757,6 @@ export class Document {
610
757
  wasm.__wbindgen_add_to_stack_pointer(16);
611
758
  }
612
759
  }
613
- /**
614
- * Append a card to the end of the card list. Accepts a `CardInput` — a card
615
- * read back (`cards` / `removeCard` / `quill.seedCard`), a
616
- * [`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.
619
- * @param {CardInput} card
620
- */
621
- pushCard(card) {
622
- try {
623
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
624
- wasm.document_pushCard(retptr, this.__wbg_ptr, addHeapObject(card));
625
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
626
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
627
- if (r1) {
628
- throw takeObject(r0);
629
- }
630
- } finally {
631
- wasm.__wbindgen_add_to_stack_pointer(16);
632
- }
633
- }
634
760
  /**
635
761
  * @returns {string}
636
762
  */
@@ -694,87 +820,17 @@ export class Document {
694
820
  }
695
821
  }
696
822
  /**
697
- * Remove the `$ext` map from the composable card at `index` *entirely*,
698
- * returning the previous map or `undefined`. Throws if out of range.
699
- * Prefer `removeCardExtNamespace` to clear only one consumer's slot.
700
- * @param {number} index
701
- * @returns {Record<string, unknown> | undefined}
702
- */
703
- removeCardExt(index) {
704
- try {
705
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
706
- wasm.document_removeCardExt(retptr, this.__wbg_ptr, index);
707
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
708
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
709
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
710
- if (r2) {
711
- throw takeObject(r1);
712
- }
713
- return takeObject(r0);
714
- } finally {
715
- wasm.__wbindgen_add_to_stack_pointer(16);
716
- }
717
- }
718
- /**
719
- * Remove `namespace` from the composable card's `$ext` map, returning the
720
- * value stored there or `undefined`; clears `$ext` entirely once empty.
721
- * The card-indexed twin of `removeExtNamespace`. Throws if out of range.
722
- * @param {number} index
723
- * @param {string} namespace
724
- * @returns {any}
725
- */
726
- removeCardExtNamespace(index, namespace) {
727
- try {
728
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
729
- const ptr0 = passStringToWasm0(namespace, wasm.__wbindgen_export, wasm.__wbindgen_export2);
730
- const len0 = WASM_VECTOR_LEN;
731
- wasm.document_removeCardExtNamespace(retptr, this.__wbg_ptr, index, ptr0, len0);
732
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
733
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
734
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
735
- if (r2) {
736
- throw takeObject(r1);
737
- }
738
- return takeObject(r0);
739
- } finally {
740
- wasm.__wbindgen_add_to_stack_pointer(16);
741
- }
742
- }
743
- /**
744
- * Remove a field on the card at `index`. Returns the removed value or
745
- * `undefined`. Throws if `index` is out of range or `name` is invalid.
746
- * @param {number} index
747
- * @param {string} name
748
- * @returns {any}
749
- */
750
- removeCardField(index, name) {
751
- try {
752
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
753
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
754
- const len0 = WASM_VECTOR_LEN;
755
- wasm.document_removeCardField(retptr, this.__wbg_ptr, index, ptr0, len0);
756
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
757
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
758
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
759
- if (r2) {
760
- throw takeObject(r1);
761
- }
762
- return takeObject(r0);
763
- } finally {
764
- wasm.__wbindgen_add_to_stack_pointer(16);
765
- }
766
- }
767
- /**
768
- * Remove the `$ext` map from the main card *entirely*, returning the
769
- * previous map or `undefined`. This is a blunt escape hatch that discards
770
- * every namespace at once — prefer `removeExtNamespace` to clear only your
771
- * own slot while leaving sibling consumers' state intact.
823
+ * Remove the `$ext` map on the card `addr` targets *entirely*, returning the
824
+ * previous map or `undefined` a blunt escape hatch that discards every
825
+ * namespace at once (prefer `removeExtNamespace`). `addr` is a card address
826
+ * (absent = main). Throws on a present `field` or an out-of-range card.
827
+ * @param {CardAddr} [addr]
772
828
  * @returns {Record<string, unknown> | undefined}
773
829
  */
774
- removeExt() {
830
+ removeExt(addr) {
775
831
  try {
776
832
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
777
- wasm.document_removeExt(retptr, this.__wbg_ptr);
833
+ wasm.document_removeExt(retptr, this.__wbg_ptr, addHeapObject(addr));
778
834
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
779
835
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
780
836
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -787,19 +843,20 @@ export class Document {
787
843
  }
788
844
  }
789
845
  /**
790
- * Remove `namespace` from the main card's `$ext` map, returning the value
791
- * stored there or `undefined`. This is the recommended way to clear `$ext`
792
- * state: sibling namespaces survive, and when the last namespace is removed
793
- * the `$ext` entry is dropped entirely (not left as `$ext: {}`).
794
- * @param {string} namespace
846
+ * Remove `$ext[ns]` on the card `addr` targets, returning its value or
847
+ * `undefined`; drops `$ext` once empty. `addr` is a card address (absent =
848
+ * main). Preserves sibling namespaces. Throws on a present `field` or an
849
+ * out-of-range card.
850
+ * @param {CardAddr} addr
851
+ * @param {string} ns
795
852
  * @returns {any}
796
853
  */
797
- removeExtNamespace(namespace) {
854
+ removeExtNamespace(addr, ns) {
798
855
  try {
799
856
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
800
- const ptr0 = passStringToWasm0(namespace, wasm.__wbindgen_export, wasm.__wbindgen_export2);
857
+ const ptr0 = passStringToWasm0(ns, wasm.__wbindgen_export, wasm.__wbindgen_export2);
801
858
  const len0 = WASM_VECTOR_LEN;
802
- wasm.document_removeExtNamespace(retptr, this.__wbg_ptr, ptr0, len0);
859
+ wasm.document_removeExtNamespace(retptr, this.__wbg_ptr, addHeapObject(addr), ptr0, len0);
803
860
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
804
861
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
805
862
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -812,17 +869,17 @@ export class Document {
812
869
  }
813
870
  }
814
871
  /**
815
- * Remove a payload field on the main card, returning the removed value or
816
- * `undefined`. Throws if `name` does not match `[A-Za-z_][A-Za-z0-9_]*`.
817
- * @param {string} name
872
+ * Remove a field at `addr`, returning the removed value or `undefined`. A
873
+ * bare string is `Addr` shorthand for `{ field }`. One `remove` verb serves
874
+ * every write lane. A body address throws; throws on an out-of-range card or
875
+ * a malformed name.
876
+ * @param {Addr | string} addr
818
877
  * @returns {any}
819
878
  */
820
- removeField(name) {
879
+ removeField(addr) {
821
880
  try {
822
881
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
823
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
824
- const len0 = WASM_VECTOR_LEN;
825
- wasm.document_removeField(retptr, this.__wbg_ptr, ptr0, len0);
882
+ wasm.document_removeField(retptr, this.__wbg_ptr, addHeapObject(addr));
826
883
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
827
884
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
828
885
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -836,8 +893,8 @@ export class Document {
836
893
  }
837
894
  /**
838
895
  * Remove `cardKind` from the main card's `$seed` map, returning its
839
- * overlay or `undefined`; drops `$seed` entirely once empty. Sibling
840
- * kinds survive.
896
+ * overlay or `undefined`; drops `$seed` entirely once empty. Sibling kinds
897
+ * survive. `$seed` is main-only, so this takes no address.
841
898
  * @param {string} card_kind
842
899
  * @returns {any}
843
900
  */
@@ -858,28 +915,6 @@ export class Document {
858
915
  wasm.__wbindgen_add_to_stack_pointer(16);
859
916
  }
860
917
  }
861
- /**
862
- * **Deprecated** — alias for `revise({}, markdown)`, kept one release cycle.
863
- * Revise the main card's body from a markdown string (edit semantics: a
864
- * `diff_import` that rebases surviving anchors). Discards the text delta;
865
- * call [`revise`](Document::revise) to receive it.
866
- * @param {string} body
867
- */
868
- replaceBody(body) {
869
- try {
870
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
871
- const ptr0 = passStringToWasm0(body, wasm.__wbindgen_export, wasm.__wbindgen_export2);
872
- const len0 = WASM_VECTOR_LEN;
873
- wasm.document_replaceBody(retptr, this.__wbg_ptr, ptr0, len0);
874
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
875
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
876
- if (r1) {
877
- throw takeObject(r0);
878
- }
879
- } finally {
880
- wasm.__wbindgen_add_to_stack_pointer(16);
881
- }
882
- }
883
918
  /**
884
919
  * **Revise** the richtext value at `addr` from a markdown string — **edit
885
920
  * semantics**, the default write path, returning the text [`Delta`]. Imports
@@ -889,8 +924,8 @@ export class Document {
889
924
  * absent `addr.card` the main card; an absent field cold-imports from empty.
890
925
  *
891
926
  * Throws on an out-of-range card, a malformed field name, a present
892
- * non-corpus field value, or an over-nested markdown input.
893
- * @param {Addr} addr
927
+ * non-content field value, or an over-nested markdown input.
928
+ * @param {Addr | string} addr
894
929
  * @param {string} markdown
895
930
  * @returns {Delta}
896
931
  */
@@ -938,88 +973,27 @@ export class Document {
938
973
  }
939
974
  }
940
975
  /**
941
- * Replace the `$ext` map on the composable card at `index`. Throws if out
942
- * of range or `value` is not a plain object. Named to mirror `setExt` on
943
- * the main card; `setCardExtNamespace` is the sibling-safe alternative.
944
- * @param {number} index
945
- * @param {any} value
946
- */
947
- setCardExt(index, value) {
948
- try {
949
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
950
- wasm.document_setCardExt(retptr, this.__wbg_ptr, index, addHeapObject(value));
951
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
952
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
953
- if (r1) {
954
- throw takeObject(r0);
955
- }
956
- } finally {
957
- wasm.__wbindgen_add_to_stack_pointer(16);
958
- }
959
- }
960
- /**
961
- * Merge `value` into the composable card's `$ext` map under `namespace`,
962
- * preserving sibling namespaces. The card-indexed twin of `setExtNamespace`.
963
- * Throws if out of range or `value` cannot be serialized.
964
- * @param {number} index
965
- * @param {string} namespace
966
- * @param {any} value
967
- */
968
- setCardExtNamespace(index, namespace, value) {
969
- try {
970
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
971
- const ptr0 = passStringToWasm0(namespace, wasm.__wbindgen_export, wasm.__wbindgen_export2);
972
- const len0 = WASM_VECTOR_LEN;
973
- wasm.document_setCardExtNamespace(retptr, this.__wbg_ptr, index, ptr0, len0, addHeapObject(value));
974
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
975
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
976
- if (r1) {
977
- throw takeObject(r0);
978
- }
979
- } finally {
980
- wasm.__wbindgen_add_to_stack_pointer(16);
981
- }
982
- }
983
- /**
984
- * Set a field on the card at `index` — the card-indexed twin of
985
- * [`setField`](Document::set_field). Stores the value opaquely.
986
- * Throws if `index` is out of range, `name` is reserved or invalid.
987
- * @param {number} index
988
- * @param {string} name
989
- * @param {any} value
976
+ * The main card's `$seed` overlay object for `kind` (the `$seed[kind]`
977
+ * entry), or `undefined` when absent. The cheap read that feeds
978
+ * `quill.seedCard(kind, overlay)` without serializing the whole main card
979
+ * via [`main`](Self::main) to fish out one key — and it keeps `seedCard`
980
+ * pure: the quill still never reads the document.
981
+ * @param {string} kind
982
+ * @returns {Record<string, unknown> | undefined}
990
983
  */
991
- setCardField(index, name, value) {
984
+ seedOverlay(kind) {
992
985
  try {
993
986
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
994
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
987
+ const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
995
988
  const len0 = WASM_VECTOR_LEN;
996
- wasm.document_setCardField(retptr, this.__wbg_ptr, index, ptr0, len0, addHeapObject(value));
997
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
998
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
999
- if (r1) {
1000
- throw takeObject(r0);
1001
- }
1002
- } finally {
1003
- wasm.__wbindgen_add_to_stack_pointer(16);
1004
- }
1005
- }
1006
- /**
1007
- * Batched twin of [`setCardField`](Document::set_card_field): set
1008
- * several fields on the card at `index` atomically. Same all-or-nothing,
1009
- * one-diagnostic-per-field contract as [`setFields`](Document::set_fields).
1010
- * Throws if `index` is out of range.
1011
- * @param {number} index
1012
- * @param {Record<string, unknown>} fields
1013
- */
1014
- setCardFields(index, fields) {
1015
- try {
1016
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1017
- wasm.document_setCardFields(retptr, this.__wbg_ptr, index, addHeapObject(fields));
989
+ wasm.document_seedOverlay(retptr, this.__wbg_ptr, ptr0, len0);
1018
990
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1019
991
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1020
- if (r1) {
1021
- throw takeObject(r0);
992
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
993
+ if (r2) {
994
+ throw takeObject(r1);
1022
995
  }
996
+ return takeObject(r0);
1023
997
  } finally {
1024
998
  wasm.__wbindgen_add_to_stack_pointer(16);
1025
999
  }
@@ -1047,16 +1021,15 @@ export class Document {
1047
1021
  }
1048
1022
  }
1049
1023
  /**
1050
- * Replace the opaque `$ext` map on the main card. `value` must be a plain
1051
- * object; throws otherwise. `$ext` carries out-of-band consumer state and
1052
- * never reaches the rendered output. Pass `{}` to record an explicit
1053
- * empty `$ext`.
1054
- * @param {any} value
1024
+ * Replace the QUILL reference string. Throws if `ref_str` is invalid.
1025
+ * @param {string} ref_str
1055
1026
  */
1056
- setExt(value) {
1027
+ setQuillRef(ref_str) {
1057
1028
  try {
1058
1029
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1059
- wasm.document_setExt(retptr, this.__wbg_ptr, addHeapObject(value));
1030
+ const ptr0 = passStringToWasm0(ref_str, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1031
+ const len0 = WASM_VECTOR_LEN;
1032
+ wasm.document_setQuillRef(retptr, this.__wbg_ptr, ptr0, len0);
1060
1033
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1061
1034
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1062
1035
  if (r1) {
@@ -1067,19 +1040,18 @@ export class Document {
1067
1040
  }
1068
1041
  }
1069
1042
  /**
1070
- * Merge `value` into the main card's `$ext` map under `namespace`, creating
1071
- * the map when absent and replacing any existing value at that key. Sibling
1072
- * namespaces are preserved, so independent consumers (`$ext.editor`,
1073
- * `$ext.agent`, …) don't clobber each other.
1074
- * @param {string} namespace
1043
+ * Replace the opaque `$ext` map on the card `addr` targets (a card address,
1044
+ * absent `card` = main). `value` must be a plain object. `$ext` carries
1045
+ * out-of-band consumer state and never reaches the rendered output; pass
1046
+ * `{}` for an explicit empty `$ext`. Quill-free and verbatim an opaque
1047
+ * `store` verb. Throws on a present `field` or an out-of-range card.
1048
+ * @param {CardAddr} addr
1075
1049
  * @param {any} value
1076
1050
  */
1077
- setExtNamespace(namespace, value) {
1051
+ storeExt(addr, value) {
1078
1052
  try {
1079
1053
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1080
- const ptr0 = passStringToWasm0(namespace, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1081
- const len0 = WASM_VECTOR_LEN;
1082
- wasm.document_setExtNamespace(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(value));
1054
+ wasm.document_storeExt(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(value));
1083
1055
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1084
1056
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1085
1057
  if (r1) {
@@ -1090,18 +1062,20 @@ export class Document {
1090
1062
  }
1091
1063
  }
1092
1064
  /**
1093
- * Update a payload field on the main card. Clears any existing `!must_fill` marker.
1094
- *
1095
- * Throws if `name` does not match `[A-Za-z_][A-Za-z0-9_]*`.
1096
- * @param {string} name
1065
+ * Merge `value` into `$ext[ns]` on the card `addr` targets, preserving
1066
+ * sibling namespaces — the recommended `$ext` write. `addr` is a card
1067
+ * address (absent = main). Quill-free and verbatim — an opaque `store` verb.
1068
+ * Throws on a present `field` or an out-of-range card.
1069
+ * @param {CardAddr} addr
1070
+ * @param {string} ns
1097
1071
  * @param {any} value
1098
1072
  */
1099
- setField(name, value) {
1073
+ storeExtNamespace(addr, ns, value) {
1100
1074
  try {
1101
1075
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1102
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1076
+ const ptr0 = passStringToWasm0(ns, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1103
1077
  const len0 = WASM_VECTOR_LEN;
1104
- wasm.document_setField(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(value));
1078
+ wasm.document_storeExtNamespace(retptr, this.__wbg_ptr, addHeapObject(addr), ptr0, len0, addHeapObject(value));
1105
1079
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1106
1080
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1107
1081
  if (r1) {
@@ -1112,18 +1086,21 @@ export class Document {
1112
1086
  }
1113
1087
  }
1114
1088
  /**
1115
- * Set several main-card payload fields atomically from a plain object,
1116
- * clearing any `!must_fill` marker on each key. Nothing is applied on
1117
- * error; the thrown error's `diagnostics` array carries one entry per
1118
- * offending field (`path` = field name), so externally-sourced names
1119
- * (database columns, form keys) surface every violation in one pass.
1120
- * Mirrors Python `set_fields`.
1121
- * @param {Record<string, unknown>} fields
1089
+ * Store a field verbatim at `addr` the opaque store (**store** = verbatim,
1090
+ * coercion deferred to render; the typed write is
1091
+ * [`commitField`](Document::commit_field)). A bare string is `Addr`
1092
+ * shorthand for `{ field }`, so `doc.storeField("qty", 3)` reads as written;
1093
+ * `{ card: 2, field: "qty" }` targets a composable card. Clears any
1094
+ * `!must_fill` marker. A body address (no `field`) throws — a body is never
1095
+ * opaque; write it with `revise` / `install` / `writer.setBody`. Throws on
1096
+ * an out-of-range card or a malformed name.
1097
+ * @param {Addr | string} addr
1098
+ * @param {any} value
1122
1099
  */
1123
- setFields(fields) {
1100
+ storeField(addr, value) {
1124
1101
  try {
1125
1102
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1126
- wasm.document_setFields(retptr, this.__wbg_ptr, addHeapObject(fields));
1103
+ wasm.document_storeField(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(value));
1127
1104
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1128
1105
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1129
1106
  if (r1) {
@@ -1134,17 +1111,21 @@ export class Document {
1134
1111
  }
1135
1112
  }
1136
1113
  /**
1137
- * Update a payload field on the main card and mark it as `!must_fill`.
1138
- * Throws on invalid name (see [`setField`](Document::set_field)).
1139
- * @param {string} name
1140
- * @param {any} value
1114
+ * Store several fields verbatim and atomically on the card `addr` targets
1115
+ * the opaque store's batch. `addr` is a **card address** (`{ card }`, absent
1116
+ * = main); a present `field` throws. The batch verb takes the address first
1117
+ * and is never shape-overloaded, because `card` is a legal field name:
1118
+ * `storeFields({}, fields)` is the main card, `storeFields({ card: 2 },
1119
+ * fields)` a composable one — never ambiguous with "set field `card`".
1120
+ * Nothing is applied on error; the thrown error's `diagnostics` carry one
1121
+ * entry per offending field. Throws on an out-of-range card.
1122
+ * @param {CardAddr} addr
1123
+ * @param {Record<string, unknown>} fields
1141
1124
  */
1142
- setFill(name, value) {
1125
+ storeFields(addr, fields) {
1143
1126
  try {
1144
1127
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1145
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1146
- const len0 = WASM_VECTOR_LEN;
1147
- wasm.document_setFill(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(value));
1128
+ wasm.document_storeFields(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(fields));
1148
1129
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1149
1130
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1150
1131
  if (r1) {
@@ -1155,15 +1136,17 @@ export class Document {
1155
1136
  }
1156
1137
  }
1157
1138
  /**
1158
- * Replace the QUILL reference string. Throws if `ref_str` is invalid.
1159
- * @param {string} ref_str
1139
+ * Store a field verbatim at `addr` and mark it `!must_fill` the opaque
1140
+ * store's fill variant, card-capable (a bare string or `{ field }` for main,
1141
+ * `{ card, field }` for a composable card). A body address throws. Same
1142
+ * validation as [`storeField`](Document::store_field).
1143
+ * @param {Addr | string} addr
1144
+ * @param {any} value
1160
1145
  */
1161
- setQuillRef(ref_str) {
1146
+ storeFill(addr, value) {
1162
1147
  try {
1163
1148
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1164
- const ptr0 = passStringToWasm0(ref_str, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1165
- const len0 = WASM_VECTOR_LEN;
1166
- wasm.document_setQuillRef(retptr, this.__wbg_ptr, ptr0, len0);
1149
+ wasm.document_storeFill(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(value));
1167
1150
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1168
1151
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1169
1152
  if (r1) {
@@ -1174,19 +1157,20 @@ export class Document {
1174
1157
  }
1175
1158
  }
1176
1159
  /**
1177
- * Merge a card-kind's seed `overlay` into the main card's `$seed` map
1178
- * under `cardKind`, preserving sibling kinds. Sets the starting values
1179
- * new cards of that kind spawn with. Throws if `overlay` cannot be
1180
- * serialized or nests too deep.
1160
+ * Merge a card-kind's seed `overlay` into the **main** card's `$seed` map
1161
+ * under `cardKind`, preserving sibling kinds `$seed` lives on the main
1162
+ * card by model, so this takes no address. Sets the starting values new
1163
+ * cards of that kind spawn with. Quill-free and verbatim — an opaque `store`
1164
+ * verb. Throws if `overlay` cannot be serialized or nests too deep.
1181
1165
  * @param {string} card_kind
1182
1166
  * @param {any} overlay
1183
1167
  */
1184
- setSeedNamespace(card_kind, overlay) {
1168
+ storeSeedNamespace(card_kind, overlay) {
1185
1169
  try {
1186
1170
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1187
1171
  const ptr0 = passStringToWasm0(card_kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1188
1172
  const len0 = WASM_VECTOR_LEN;
1189
- wasm.document_setSeedNamespace(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(overlay));
1173
+ wasm.document_storeSeedNamespace(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(overlay));
1190
1174
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1191
1175
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1192
1176
  if (r1) {
@@ -1387,6 +1371,34 @@ export class Quill {
1387
1371
  wasm.__wbindgen_add_to_stack_pointer(16);
1388
1372
  }
1389
1373
  }
1374
+ /**
1375
+ * The resolved-value view of `doc` against this quill's schema — for every
1376
+ * declared field the value the render projection would use and the
1377
+ * `FieldSource` rung it came from (`"authored" | "default" | "zero"`), in
1378
+ * one call. The card body rides the `fields` map under the `$body` key.
1379
+ *
1380
+ * Value and provenance only: completeness and errors stay `validate`'s
1381
+ * (a consumer merges it with its own diagnostic producers regardless), and
1382
+ * schema guidance reads from `Quill.schema`.
1383
+ * @param {Document} doc
1384
+ * @returns {Resolved}
1385
+ */
1386
+ resolve(doc) {
1387
+ try {
1388
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1389
+ _assertClass(doc, Document);
1390
+ wasm.quill_resolve(retptr, this.__wbg_ptr, doc.__wbg_ptr);
1391
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1392
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1393
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1394
+ if (r2) {
1395
+ throw takeObject(r1);
1396
+ }
1397
+ return takeObject(r0);
1398
+ } finally {
1399
+ wasm.__wbindgen_add_to_stack_pointer(16);
1400
+ }
1401
+ }
1390
1402
  /**
1391
1403
  * Document schema for the quill: the user-fillable fields plus their
1392
1404
  * `ui` hints (title / group / compact / multiline). The single
@@ -1415,9 +1427,9 @@ export class Quill {
1415
1427
  * layering an optional per-kind seed `overlay` over the schema-example
1416
1428
  * base (`overlay › example › absent`). Returns `undefined` if `cardKind`
1417
1429
  * is not declared in this quill's schema, else a `Card` that feeds
1418
- * straight into `Document.pushCard` / `insertCard`.
1430
+ * straight into `Document.insertCard`.
1419
1431
  *
1420
- * Pass `document.main.seed?.[cardKind]` as `overlay` so a card added to a
1432
+ * Pass `document.seedOverlay(cardKind)` as `overlay` so a card added to a
1421
1433
  * template-derived document inherits its curated starting values; omit it
1422
1434
  * (or pass `undefined` / `null`) for the bare schema seed. `overlay` is a
1423
1435
  * plain object — this reads the document, it does not mutate it.
@@ -1527,10 +1539,10 @@ export class Quill {
1527
1539
  if (Symbol.dispose) Quill.prototype[Symbol.dispose] = Quill.prototype.free;
1528
1540
 
1529
1541
  /**
1530
- * Export a canonical `RichText` corpus to its markdown projection — the pure
1531
- * codec that replaces the eager `bodyMarkdown` / `fieldMarkdown` precomputes
1532
- * (`exportMarkdown(card.body)`). Throws if `rt` is not a canonical corpus.
1533
- * @param {RichText} rt
1542
+ * Export a canonical `Content` content to its markdown projection — the pure
1543
+ * on-demand codec behind `exportMarkdown(card.body)`. Throws if `rt` is not a
1544
+ * canonical content.
1545
+ * @param {Content} rt
1534
1546
  * @returns {string}
1535
1547
  */
1536
1548
  export function exportMarkdown(rt) {
@@ -1559,12 +1571,46 @@ export function exportMarkdown(rt) {
1559
1571
  }
1560
1572
 
1561
1573
  /**
1562
- * Import a markdown string to a canonical `RichText` corpus — the pure,
1574
+ * Serialize structured [`DocPathSeg`] segments back to the canonical path
1575
+ * string — the inverse of `parseDocPath`, for a consumer that builds a path
1576
+ * rather than reads one. Throws on a segment array the deserializer rejects,
1577
+ * and on an empty segment array (symmetric with `parseDocPath("")`, which
1578
+ * throws "empty path").
1579
+ * @param {DocPathSeg[]} segs
1580
+ * @returns {string}
1581
+ */
1582
+ export function formatDocPath(segs) {
1583
+ let deferred2_0;
1584
+ let deferred2_1;
1585
+ try {
1586
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1587
+ wasm.formatDocPath(retptr, addHeapObject(segs));
1588
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1589
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1590
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1591
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1592
+ var ptr1 = r0;
1593
+ var len1 = r1;
1594
+ if (r3) {
1595
+ ptr1 = 0; len1 = 0;
1596
+ throw takeObject(r2);
1597
+ }
1598
+ deferred2_0 = ptr1;
1599
+ deferred2_1 = len1;
1600
+ return getStringFromWasm0(ptr1, len1);
1601
+ } finally {
1602
+ wasm.__wbindgen_add_to_stack_pointer(16);
1603
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
1604
+ }
1605
+ }
1606
+
1607
+ /**
1608
+ * Import a markdown string to a canonical `Content` content — the pure,
1563
1609
  * document-free codec. Pair with `install(addr, importMarkdown(md))` to spell
1564
1610
  * the cold (anchor-losing) write at the call site; prefer `revise` for edit
1565
1611
  * semantics. Throws on an over-nested input.
1566
1612
  * @param {string} markdown
1567
- * @returns {RichText}
1613
+ * @returns {Content}
1568
1614
  */
1569
1615
  export function importMarkdown(markdown) {
1570
1616
  try {
@@ -1592,7 +1638,7 @@ export function init() {
1592
1638
  }
1593
1639
 
1594
1640
  /**
1595
- * Map a base corpus position through a `delta` to its new position — the pure
1641
+ * Map a base content position through a `delta` to its new position — the pure
1596
1642
  * position-mapping codec an editor bridge composes to hold a caret stable
1597
1643
  * across a `revise`. `assoc` decides the side of a same-position insertion
1598
1644
  * (`"after"` moves past it). Throws on a malformed `delta`.
@@ -1618,14 +1664,41 @@ export function mapPos(delta, pos, assoc) {
1618
1664
  }
1619
1665
 
1620
1666
  /**
1621
- * Rebase `markdown` onto a `base` corpus — the pure, document-free twin of
1622
- * `revise`: cold-import + `diff_import`, returning the new `corpus` and the
1667
+ * Parse a canonical document-model `Diagnostic.path`
1668
+ * (`cards.<kind>[<i>].<field>`, `main.body`, `recipients[0].name`) into its
1669
+ * structured [`DocPathSeg`] segments — the exported inverse of the engine's
1670
+ * one path serializer, so a consumer routes on segments instead of regexing
1671
+ * the string. Throws on a malformed path.
1672
+ * @param {string} path
1673
+ * @returns {DocPathSeg[]}
1674
+ */
1675
+ export function parseDocPath(path) {
1676
+ try {
1677
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1678
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1679
+ const len0 = WASM_VECTOR_LEN;
1680
+ wasm.parseDocPath(retptr, ptr0, len0);
1681
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1682
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1683
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1684
+ if (r2) {
1685
+ throw takeObject(r1);
1686
+ }
1687
+ return takeObject(r0);
1688
+ } finally {
1689
+ wasm.__wbindgen_add_to_stack_pointer(16);
1690
+ }
1691
+ }
1692
+
1693
+ /**
1694
+ * Rebase `markdown` onto a `base` content — the pure, document-free twin of
1695
+ * `revise`: cold-import + `diff_import`, returning the new `content` and the
1623
1696
  * text `delta` (surviving anchors rebased). Use it to compute a revise without
1624
1697
  * a document in hand; `revise(addr, md)` fuses this with the store for
1625
- * atomicity. Throws on an over-nested markdown input or a non-corpus `base`.
1626
- * @param {RichText} base
1698
+ * atomicity. Throws on an over-nested markdown input or a non-content `base`.
1699
+ * @param {Content} base
1627
1700
  * @param {string} markdown
1628
- * @returns {{ corpus: RichText; delta: Delta }}
1701
+ * @returns {{ content: Content; delta: Delta }}
1629
1702
  */
1630
1703
  export function rebase(base, markdown) {
1631
1704
  try {