@quillmark/wasm 0.92.1 → 0.94.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
@@ -19,6 +19,64 @@ export class Document {
19
19
  const ptr = this.__destroy_into_raw();
20
20
  wasm.__wbg_document_free(ptr, 0);
21
21
  }
22
+ /**
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`.
32
+ * @param {Quill} quill
33
+ * @param {string} kind
34
+ * @param {Record<string, unknown>} [fields]
35
+ * @param {string} [body]
36
+ */
37
+ addCard(quill, kind, fields, body) {
38
+ try {
39
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
40
+ _assertClass(quill, Quill);
41
+ const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
42
+ const len0 = WASM_VECTOR_LEN;
43
+ var ptr1 = isLikeNone(body) ? 0 : passStringToWasm0(body, wasm.__wbindgen_export, wasm.__wbindgen_export2);
44
+ 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);
46
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
47
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
48
+ if (r1) {
49
+ throw takeObject(r0);
50
+ }
51
+ } finally {
52
+ wasm.__wbindgen_add_to_stack_pointer(16);
53
+ }
54
+ }
55
+ /**
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
+ *
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
66
+ */
67
+ applyChange(addr, bundle) {
68
+ try {
69
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
70
+ wasm.document_applyChange(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(bundle));
71
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
72
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
73
+ if (r1) {
74
+ throw takeObject(r0);
75
+ }
76
+ } finally {
77
+ wasm.__wbindgen_add_to_stack_pointer(16);
78
+ }
79
+ }
22
80
  /**
23
81
  * Authoring-ergonomics header introducing a blueprint to an LLM/MCP
24
82
  * consumer for the given `quillName`. Re-exposes core's canonical text for
@@ -78,6 +136,128 @@ export class Document {
78
136
  const ret = wasm.document_clone(this.__wbg_ptr);
79
137
  return Document.__wrap(ret);
80
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.
143
+ *
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).
148
+ * @param {Quill} quill
149
+ * @param {number} index
150
+ * @param {string} name
151
+ * @param {any} value
152
+ */
153
+ commitCardField(quill, index, name, value) {
154
+ try {
155
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
156
+ _assertClass(quill, Quill);
157
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
158
+ const len0 = WASM_VECTOR_LEN;
159
+ wasm.document_commitCardField(retptr, this.__wbg_ptr, quill.__wbg_ptr, index, ptr0, len0, addHeapObject(value));
160
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
161
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
162
+ if (r1) {
163
+ throw takeObject(r0);
164
+ }
165
+ } finally {
166
+ wasm.__wbindgen_add_to_stack_pointer(16);
167
+ }
168
+ }
169
+ /**
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
180
+ */
181
+ commitCardFields(quill, index, fields) {
182
+ try {
183
+ 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));
186
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
187
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
188
+ if (r1) {
189
+ throw takeObject(r0);
190
+ }
191
+ } finally {
192
+ wasm.__wbindgen_add_to_stack_pointer(16);
193
+ }
194
+ }
195
+ /**
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
219
+ */
220
+ commitField(quill, name, value) {
221
+ try {
222
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
223
+ _assertClass(quill, Quill);
224
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
225
+ const len0 = WASM_VECTOR_LEN;
226
+ wasm.document_commitField(retptr, this.__wbg_ptr, quill.__wbg_ptr, ptr0, len0, addHeapObject(value));
227
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
228
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
229
+ if (r1) {
230
+ throw takeObject(r0);
231
+ }
232
+ } finally {
233
+ wasm.__wbindgen_add_to_stack_pointer(16);
234
+ }
235
+ }
236
+ /**
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
246
+ */
247
+ commitFields(quill, fields) {
248
+ try {
249
+ 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));
252
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
253
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
254
+ if (r1) {
255
+ throw takeObject(r0);
256
+ }
257
+ } finally {
258
+ wasm.__wbindgen_add_to_stack_pointer(16);
259
+ }
260
+ }
81
261
  /**
82
262
  * Schema version this build writes via [`toJson`](Document::to_json).
83
263
  * Tracks the `Document` model version (not the running crate version):
@@ -207,11 +387,65 @@ export class Document {
207
387
  wasm.__wbindgen_add_to_stack_pointer(16);
208
388
  }
209
389
  }
390
+ /**
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}
398
+ */
399
+ get(name) {
400
+ try {
401
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
402
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
403
+ const len0 = WASM_VECTOR_LEN;
404
+ wasm.document_get(retptr, this.__wbg_ptr, ptr0, len0);
405
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
406
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
407
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
408
+ if (r2) {
409
+ throw takeObject(r1);
410
+ }
411
+ return takeObject(r0);
412
+ } finally {
413
+ wasm.__wbindgen_add_to_stack_pointer(16);
414
+ }
415
+ }
416
+ /**
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]
424
+ * @returns {string}
425
+ */
426
+ getMarkdown(name) {
427
+ let deferred2_0;
428
+ let deferred2_1;
429
+ try {
430
+ 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);
434
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
435
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
436
+ deferred2_0 = r0;
437
+ deferred2_1 = r1;
438
+ return getStringFromWasm0(r0, r1);
439
+ } finally {
440
+ wasm.__wbindgen_add_to_stack_pointer(16);
441
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
442
+ }
443
+ }
210
444
  /**
211
445
  * Insert a card at `index` (must be in `0..=cards.length`). Accepts a
212
- * `Card` (see [`pushCard`](Self::push_card)).
446
+ * `CardInput` (see [`pushCard`](Self::push_card)).
213
447
  * @param {number} index
214
- * @param {Card} card
448
+ * @param {CardInput} card
215
449
  */
216
450
  insertCard(index, card) {
217
451
  try {
@@ -226,6 +460,60 @@ export class Document {
226
460
  wasm.__wbindgen_add_to_stack_pointer(16);
227
461
  }
228
462
  }
463
+ /**
464
+ * **Install** a richtext value at `addr` — **value semantics**, corpus only.
465
+ * Stores exactly `rt` (a canonical `RichText` corpus object); the identity
466
+ * anchors of any previous value are gone. An absent `addr.field` targets the
467
+ * body, an absent `addr.card` the main card. For "here's new markdown," use
468
+ * [`revise`](Document::revise); the cold-import path is spelled at the call
469
+ * site as `install(addr, importMarkdown(md))`, so anchor loss is visible in
470
+ * source.
471
+ *
472
+ * 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
476
+ */
477
+ install(addr, rt) {
478
+ try {
479
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
480
+ wasm.document_install(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(rt));
481
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
482
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
483
+ if (r1) {
484
+ throw takeObject(r0);
485
+ }
486
+ } finally {
487
+ wasm.__wbindgen_add_to_stack_pointer(16);
488
+ }
489
+ }
490
+ /**
491
+ * Replace this document's contents **in place** from a versioned storage
492
+ * DTO string — the mutating twin of the static
493
+ * [`fromJson`](Document::from_json) constructor. Parse-time `warnings` are
494
+ * cleared. Throws (leaving the document unchanged) on an invalid DTO.
495
+ *
496
+ * The cross-WASM-memory `Document` bridge: mutate a document on a
497
+ * backend-memory clone, then write the mutated state back into the caller's
498
+ * canonical document with this — the one way to update a live handle across
499
+ * the linear-memory seam without the caller re-binding its variable.
500
+ * @param {string} json
501
+ */
502
+ loadJson(json) {
503
+ try {
504
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
505
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
506
+ const len0 = WASM_VECTOR_LEN;
507
+ wasm.document_loadJson(retptr, this.__wbg_ptr, ptr0, len0);
508
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
509
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
510
+ if (r1) {
511
+ throw takeObject(r0);
512
+ }
513
+ } finally {
514
+ wasm.__wbindgen_add_to_stack_pointer(16);
515
+ }
516
+ }
229
517
  /**
230
518
  * The document's main (entry) card. Allocates and serializes on each
231
519
  * call — cache locally if read in a hot loop.
@@ -295,11 +583,40 @@ export class Document {
295
583
  }
296
584
  }
297
585
  /**
298
- * Append a card to the end of the card list. Accepts a `Card` (the shape
299
- * returned by `cards` / `removeCard` / `quill.seedCard`); build a fresh
300
- * one with [`Document.makeCard`](Document::make_card). Throws if
301
- * `card.kind` is not a valid kind name.
302
- * @param {Card} card
586
+ * `new Document(quillRef)` a blank document: a main card carrying only
587
+ * `$quill`, an empty body, and no composable cards. The programmatic
588
+ * blank canvas: absent fields resolve at render time (`default`, else
589
+ * type-empty zero), so nothing the caller did not set reaches the
590
+ * output. For an example-filled starter use `Quill.seedDocument()`.
591
+ * Throws on an invalid quill reference. Mirrors Python `Document(quill_ref)`.
592
+ * @param {string} quill_ref
593
+ */
594
+ constructor(quill_ref) {
595
+ try {
596
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
597
+ const ptr0 = passStringToWasm0(quill_ref, wasm.__wbindgen_export, wasm.__wbindgen_export2);
598
+ const len0 = WASM_VECTOR_LEN;
599
+ wasm.document_new(retptr, ptr0, len0);
600
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
601
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
602
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
603
+ if (r2) {
604
+ throw takeObject(r1);
605
+ }
606
+ this.__wbg_ptr = r0 >>> 0;
607
+ DocumentFinalization.register(this, this.__wbg_ptr, this);
608
+ return this;
609
+ } finally {
610
+ wasm.__wbindgen_add_to_stack_pointer(16);
611
+ }
612
+ }
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
303
620
  */
304
621
  pushCard(card) {
305
622
  try {
@@ -542,12 +859,57 @@ export class Document {
542
859
  }
543
860
  }
544
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.
545
866
  * @param {string} body
546
867
  */
547
868
  replaceBody(body) {
548
- const ptr0 = passStringToWasm0(body, wasm.__wbindgen_export, wasm.__wbindgen_export2);
549
- const len0 = WASM_VECTOR_LEN;
550
- wasm.document_replaceBody(this.__wbg_ptr, ptr0, len0);
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
+ /**
884
+ * **Revise** the richtext value at `addr` from a markdown string — **edit
885
+ * semantics**, the default write path, returning the text [`Delta`]. Imports
886
+ * the markdown, diffs it against the current value, rebases surviving
887
+ * identity anchors, and returns the change an editor bridge maps its own
888
+ * positions through (`mapPos`). An absent `addr.field` targets the body, an
889
+ * absent `addr.card` the main card; an absent field cold-imports from empty.
890
+ *
891
+ * 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
894
+ * @param {string} markdown
895
+ * @returns {Delta}
896
+ */
897
+ revise(addr, markdown) {
898
+ try {
899
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
900
+ const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
901
+ const len0 = WASM_VECTOR_LEN;
902
+ wasm.document_revise(retptr, this.__wbg_ptr, addHeapObject(addr), ptr0, len0);
903
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
904
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
905
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
906
+ if (r2) {
907
+ throw takeObject(r1);
908
+ }
909
+ return takeObject(r0);
910
+ } finally {
911
+ wasm.__wbindgen_add_to_stack_pointer(16);
912
+ }
551
913
  }
552
914
  /**
553
915
  * Read the `schema` version tag from a raw storage DTO string without a
@@ -618,6 +980,50 @@ export class Document {
618
980
  wasm.__wbindgen_add_to_stack_pointer(16);
619
981
  }
620
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
990
+ */
991
+ setCardField(index, name, value) {
992
+ try {
993
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
994
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
995
+ 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));
1018
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1019
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1020
+ if (r1) {
1021
+ throw takeObject(r0);
1022
+ }
1023
+ } finally {
1024
+ wasm.__wbindgen_add_to_stack_pointer(16);
1025
+ }
1026
+ }
621
1027
  /**
622
1028
  * Replace the kind of the card at `index`. Payload and body are untouched;
623
1029
  * schema-aware migration is the caller's responsibility.
@@ -705,6 +1111,28 @@ export class Document {
705
1111
  wasm.__wbindgen_add_to_stack_pointer(16);
706
1112
  }
707
1113
  }
1114
+ /**
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
1122
+ */
1123
+ setFields(fields) {
1124
+ try {
1125
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1126
+ wasm.document_setFields(retptr, this.__wbg_ptr, addHeapObject(fields));
1127
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1128
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1129
+ if (r1) {
1130
+ throw takeObject(r0);
1131
+ }
1132
+ } finally {
1133
+ wasm.__wbindgen_add_to_stack_pointer(16);
1134
+ }
1135
+ }
708
1136
  /**
709
1137
  * Update a payload field on the main card and mark it as `!must_fill`.
710
1138
  * Throws on invalid name (see [`setField`](Document::set_field)).
@@ -831,48 +1259,6 @@ export class Document {
831
1259
  const ret = wasm.document_tryFromJson(ptr0, len0);
832
1260
  return ret === 0 ? undefined : Document.__wrap(ret);
833
1261
  }
834
- /**
835
- * Replace the body of the card at `index`. Throws if out of range.
836
- * @param {number} index
837
- * @param {string} body
838
- */
839
- updateCardBody(index, body) {
840
- try {
841
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
842
- const ptr0 = passStringToWasm0(body, wasm.__wbindgen_export, wasm.__wbindgen_export2);
843
- const len0 = WASM_VECTOR_LEN;
844
- wasm.document_updateCardBody(retptr, this.__wbg_ptr, index, ptr0, len0);
845
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
846
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
847
- if (r1) {
848
- throw takeObject(r0);
849
- }
850
- } finally {
851
- wasm.__wbindgen_add_to_stack_pointer(16);
852
- }
853
- }
854
- /**
855
- * Update a field on the card at `index`.
856
- * Throws if `index` is out of range, `name` is reserved or invalid.
857
- * @param {number} index
858
- * @param {string} name
859
- * @param {any} value
860
- */
861
- updateCardField(index, name, value) {
862
- try {
863
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
864
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
865
- const len0 = WASM_VECTOR_LEN;
866
- wasm.document_updateCardField(retptr, this.__wbg_ptr, index, ptr0, len0, addHeapObject(value));
867
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
868
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
869
- if (r1) {
870
- throw takeObject(r0);
871
- }
872
- } finally {
873
- wasm.__wbindgen_add_to_stack_pointer(16);
874
- }
875
- }
876
1262
  /**
877
1263
  * @returns {Diagnostic[]}
878
1264
  */
@@ -1003,9 +1389,10 @@ export class Quill {
1003
1389
  }
1004
1390
  /**
1005
1391
  * Document schema for the quill: the user-fillable fields plus their
1006
- * `ui` hints (group / order / showWhen). The single field-metadata
1007
- * surface — drives form editors and LLM/MCP consumers alike. Returns the
1008
- * `QuillSchema` shape.
1392
+ * `ui` hints (title / group / compact / multiline). The single
1393
+ * field-metadata surface — drives form editors and LLM/MCP consumers
1394
+ * alike. Key order in `fields`/`properties` is declaration order — the
1395
+ * ordering contract. Returns the `QuillSchema` shape.
1009
1396
  * @returns {QuillSchema}
1010
1397
  */
1011
1398
  get schema() {
@@ -1113,10 +1500,10 @@ export class Quill {
1113
1500
  *
1114
1501
  * Forwards the canonical `validation::*` diagnostics — same `code`,
1115
1502
  * `path`, and `hint` the engine emits — including the non-fatal
1116
- * `validation::field_absent` completeness signal that `render` demotes.
1117
- * Field values, defaults, and order are not part of this surface: read
1118
- * them from the `Document` payload and `Quill.schema` (fields carry
1119
- * `ui.order`).
1503
+ * `validation::must_fill` warning for each `!must_fill` marker left in
1504
+ * the document. Field values, defaults, and order are not part of this
1505
+ * surface: read them from the `Document` payload and `Quill.schema`
1506
+ * (schema key order is display order).
1120
1507
  * @param {Document} doc
1121
1508
  * @returns {Diagnostic[]}
1122
1509
  */
@@ -1139,16 +1526,132 @@ export class Quill {
1139
1526
  }
1140
1527
  if (Symbol.dispose) Quill.prototype[Symbol.dispose] = Quill.prototype.free;
1141
1528
 
1529
+ /**
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
1534
+ * @returns {string}
1535
+ */
1536
+ export function exportMarkdown(rt) {
1537
+ let deferred2_0;
1538
+ let deferred2_1;
1539
+ try {
1540
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1541
+ wasm.exportMarkdown(retptr, addHeapObject(rt));
1542
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1543
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1544
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1545
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1546
+ var ptr1 = r0;
1547
+ var len1 = r1;
1548
+ if (r3) {
1549
+ ptr1 = 0; len1 = 0;
1550
+ throw takeObject(r2);
1551
+ }
1552
+ deferred2_0 = ptr1;
1553
+ deferred2_1 = len1;
1554
+ return getStringFromWasm0(ptr1, len1);
1555
+ } finally {
1556
+ wasm.__wbindgen_add_to_stack_pointer(16);
1557
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
1558
+ }
1559
+ }
1560
+
1561
+ /**
1562
+ * Import a markdown string to a canonical `RichText` corpus — the pure,
1563
+ * document-free codec. Pair with `install(addr, importMarkdown(md))` to spell
1564
+ * the cold (anchor-losing) write at the call site; prefer `revise` for edit
1565
+ * semantics. Throws on an over-nested input.
1566
+ * @param {string} markdown
1567
+ * @returns {RichText}
1568
+ */
1569
+ export function importMarkdown(markdown) {
1570
+ try {
1571
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1572
+ const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1573
+ const len0 = WASM_VECTOR_LEN;
1574
+ wasm.importMarkdown(retptr, ptr0, len0);
1575
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1576
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1577
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1578
+ if (r2) {
1579
+ throw takeObject(r1);
1580
+ }
1581
+ return takeObject(r0);
1582
+ } finally {
1583
+ wasm.__wbindgen_add_to_stack_pointer(16);
1584
+ }
1585
+ }
1586
+
1142
1587
  /**
1143
1588
  * Initialize the WASM module with panic hooks for better error messages
1144
1589
  */
1145
1590
  export function init() {
1146
1591
  wasm.init();
1147
1592
  }
1593
+
1594
+ /**
1595
+ * Map a base corpus position through a `delta` to its new position — the pure
1596
+ * position-mapping codec an editor bridge composes to hold a caret stable
1597
+ * across a `revise`. `assoc` decides the side of a same-position insertion
1598
+ * (`"after"` moves past it). Throws on a malformed `delta`.
1599
+ * @param {Delta} delta
1600
+ * @param {number} pos
1601
+ * @param {Assoc} assoc
1602
+ * @returns {number}
1603
+ */
1604
+ export function mapPos(delta, pos, assoc) {
1605
+ try {
1606
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1607
+ wasm.mapPos(retptr, addHeapObject(delta), pos, addHeapObject(assoc));
1608
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1609
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1610
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1611
+ if (r2) {
1612
+ throw takeObject(r1);
1613
+ }
1614
+ return r0 >>> 0;
1615
+ } finally {
1616
+ wasm.__wbindgen_add_to_stack_pointer(16);
1617
+ }
1618
+ }
1619
+
1620
+ /**
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
1623
+ * text `delta` (surviving anchors rebased). Use it to compute a revise without
1624
+ * 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
1627
+ * @param {string} markdown
1628
+ * @returns {{ corpus: RichText; delta: Delta }}
1629
+ */
1630
+ export function rebase(base, markdown) {
1631
+ try {
1632
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1633
+ const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1634
+ const len0 = WASM_VECTOR_LEN;
1635
+ wasm.rebase(retptr, addHeapObject(base), ptr0, len0);
1636
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1637
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1638
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1639
+ if (r2) {
1640
+ throw takeObject(r1);
1641
+ }
1642
+ return takeObject(r0);
1643
+ } finally {
1644
+ wasm.__wbindgen_add_to_stack_pointer(16);
1645
+ }
1646
+ }
1148
1647
  export function __wbg_Error_960c155d3d49e4c2(arg0, arg1) {
1149
1648
  const ret = Error(getStringFromWasm0(arg0, arg1));
1150
1649
  return addHeapObject(ret);
1151
1650
  }
1651
+ export function __wbg_Number_32bf70a599af1d4b(arg0) {
1652
+ const ret = Number(getObject(arg0));
1653
+ return ret;
1654
+ }
1152
1655
  export function __wbg_String_8564e559799eccda(arg0, arg1) {
1153
1656
  const ret = String(getObject(arg1));
1154
1657
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);