@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.
@@ -0,0 +1,2670 @@
1
+ /**
2
+ * Typed in-memory Quillmark document.
3
+ */
4
+ export class Document {
5
+ static __wrap(ptr) {
6
+ ptr = ptr >>> 0;
7
+ const obj = Object.create(Document.prototype);
8
+ obj.__wbg_ptr = ptr;
9
+ DocumentFinalization.register(obj, obj.__wbg_ptr, obj);
10
+ return obj;
11
+ }
12
+ __destroy_into_raw() {
13
+ const ptr = this.__wbg_ptr;
14
+ this.__wbg_ptr = 0;
15
+ DocumentFinalization.unregister(this);
16
+ return ptr;
17
+ }
18
+ free() {
19
+ const ptr = this.__destroy_into_raw();
20
+ wasm.__wbg_document_free(ptr, 0);
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
+ }
80
+ /**
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}
87
+ */
88
+ static blueprintInstruction(quill_name) {
89
+ let deferred2_0;
90
+ let deferred2_1;
91
+ try {
92
+ 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);
96
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
97
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
98
+ deferred2_0 = r0;
99
+ deferred2_1 = r1;
100
+ return getStringFromWasm0(r0, r1);
101
+ } finally {
102
+ wasm.__wbindgen_add_to_stack_pointer(16);
103
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
104
+ }
105
+ }
106
+ /**
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[]}
116
+ */
117
+ get cards() {
118
+ try {
119
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
120
+ wasm.document_cards(retptr, this.__wbg_ptr);
121
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
122
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
123
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
124
+ if (r2) {
125
+ throw takeObject(r1);
126
+ }
127
+ return takeObject(r0);
128
+ } finally {
129
+ wasm.__wbindgen_add_to_stack_pointer(16);
130
+ }
131
+ }
132
+ /**
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.
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
+ }
261
+ /**
262
+ * Schema version this build writes via [`toJson`](Document::to_json).
263
+ * Tracks the `Document` model version (not the running crate version):
264
+ * the tag advances only when the wire format changes, not on every release.
265
+ * @returns {string}
266
+ */
267
+ static currentSchemaVersion() {
268
+ let deferred1_0;
269
+ let deferred1_1;
270
+ try {
271
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
272
+ wasm.document_currentSchemaVersion(retptr);
273
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
274
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
275
+ deferred1_0 = r0;
276
+ deferred1_1 = r1;
277
+ return getStringFromWasm0(r0, r1);
278
+ } finally {
279
+ wasm.__wbindgen_add_to_stack_pointer(16);
280
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
281
+ }
282
+ }
283
+ /**
284
+ * Structural equality (parse-time `warnings` excluded). Use to debounce
285
+ * upstream prop updates instead of re-parsing on every keystroke.
286
+ * @param {Document} other
287
+ * @returns {boolean}
288
+ */
289
+ equals(other) {
290
+ _assertClass(other, Document);
291
+ const ret = wasm.document_equals(this.__wbg_ptr, other.__wbg_ptr);
292
+ return ret !== 0;
293
+ }
294
+ /**
295
+ * Render a Diagnostic as the canonical pretty-printed text (core's
296
+ * `Diagnostic::fmt_pretty`). Single source of truth so a Diagnostic looks
297
+ * identical no matter which consumer surfaces it.
298
+ * @param {Diagnostic} diag
299
+ * @returns {string}
300
+ */
301
+ static formatDiagnostic(diag) {
302
+ let deferred1_0;
303
+ let deferred1_1;
304
+ try {
305
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
306
+ wasm.document_formatDiagnostic(retptr, addHeapObject(diag));
307
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
308
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
309
+ deferred1_0 = r0;
310
+ deferred1_1 = r1;
311
+ return getStringFromWasm0(r0, r1);
312
+ } finally {
313
+ wasm.__wbindgen_add_to_stack_pointer(16);
314
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
315
+ }
316
+ }
317
+ /**
318
+ * Authoring-format rules for the card-yaml markdown surface. The canonical
319
+ * text is core's (`quillmark_core::document::FORMAT_RULES`), re-exposed
320
+ * here for JS consumers so it matches any other surface that draws from the
321
+ * same source. Read once at startup and cache; the value never changes
322
+ * between calls.
323
+ * @returns {string}
324
+ */
325
+ static formatRules() {
326
+ let deferred1_0;
327
+ let deferred1_1;
328
+ try {
329
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
330
+ wasm.document_formatRules(retptr);
331
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
332
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
333
+ deferred1_0 = r0;
334
+ deferred1_1 = r1;
335
+ return getStringFromWasm0(r0, r1);
336
+ } finally {
337
+ wasm.__wbindgen_add_to_stack_pointer(16);
338
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
339
+ }
340
+ }
341
+ /**
342
+ * Reconstruct a `Document` from a versioned storage DTO string produced
343
+ * by [`toJson`](Document::to_json). Unknown `schema` tags are rejected.
344
+ * The result carries no parse-time warnings (`.warnings` is always empty).
345
+ *
346
+ * Throws if `json` is not a valid storage DTO (malformed JSON, unknown
347
+ * `schema`, missing fields, or unparseable quill reference).
348
+ * @param {string} json
349
+ * @returns {Document}
350
+ */
351
+ static fromJson(json) {
352
+ try {
353
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
354
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
355
+ const len0 = WASM_VECTOR_LEN;
356
+ wasm.document_fromJson(retptr, ptr0, len0);
357
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
358
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
359
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
360
+ if (r2) {
361
+ throw takeObject(r1);
362
+ }
363
+ return Document.__wrap(r0);
364
+ } finally {
365
+ wasm.__wbindgen_add_to_stack_pointer(16);
366
+ }
367
+ }
368
+ /**
369
+ * Parse markdown into a typed Document. Throws on parse errors.
370
+ * @param {string} markdown
371
+ * @returns {Document}
372
+ */
373
+ static fromMarkdown(markdown) {
374
+ try {
375
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
376
+ const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
377
+ const len0 = WASM_VECTOR_LEN;
378
+ wasm.document_fromMarkdown(retptr, ptr0, len0);
379
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
380
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
381
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
382
+ if (r2) {
383
+ throw takeObject(r1);
384
+ }
385
+ return Document.__wrap(r0);
386
+ } finally {
387
+ wasm.__wbindgen_add_to_stack_pointer(16);
388
+ }
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
+ }
444
+ /**
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
448
+ * @param {CardInput} card
449
+ */
450
+ insertCard(index, card) {
451
+ try {
452
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
453
+ wasm.document_insertCard(retptr, this.__wbg_ptr, index, addHeapObject(card));
454
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
455
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
456
+ if (r1) {
457
+ throw takeObject(r0);
458
+ }
459
+ } finally {
460
+ wasm.__wbindgen_add_to_stack_pointer(16);
461
+ }
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
+ }
517
+ /**
518
+ * The document's main (entry) card. Allocates and serializes on each
519
+ * call — cache locally if read in a hot loop.
520
+ * @returns {Card}
521
+ */
522
+ get main() {
523
+ try {
524
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
525
+ wasm.document_main(retptr, this.__wbg_ptr);
526
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
527
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
528
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
529
+ if (r2) {
530
+ throw takeObject(r1);
531
+ }
532
+ return takeObject(r0);
533
+ } finally {
534
+ wasm.__wbindgen_add_to_stack_pointer(16);
535
+ }
536
+ }
537
+ /**
538
+ * Build a fresh `Card` from a kind and a flat field map — the ergonomic
539
+ * constructor for `pushCard` / `insertCard`. `fields` is an optional
540
+ * `Record<string, unknown>` (each entry becomes a card field, in
541
+ * insertion order); `body` defaults to `""`. Kind validity is checked by
542
+ * `pushCard` / `insertCard`, not here.
543
+ * @param {string} kind
544
+ * @param {Record<string, unknown>} [fields]
545
+ * @param {string} [body]
546
+ * @returns {Card}
547
+ */
548
+ static makeCard(kind, fields, body) {
549
+ try {
550
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
551
+ const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
552
+ const len0 = WASM_VECTOR_LEN;
553
+ var ptr1 = isLikeNone(body) ? 0 : passStringToWasm0(body, wasm.__wbindgen_export, wasm.__wbindgen_export2);
554
+ var len1 = WASM_VECTOR_LEN;
555
+ wasm.document_makeCard(retptr, ptr0, len0, isLikeNone(fields) ? 0 : addHeapObject(fields), ptr1, len1);
556
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
557
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
558
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
559
+ if (r2) {
560
+ throw takeObject(r1);
561
+ }
562
+ return takeObject(r0);
563
+ } finally {
564
+ wasm.__wbindgen_add_to_stack_pointer(16);
565
+ }
566
+ }
567
+ /**
568
+ * Move the card at `from` to position `to`. `from == to` is a no-op.
569
+ * @param {number} from
570
+ * @param {number} to
571
+ */
572
+ moveCard(from, to) {
573
+ try {
574
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
575
+ wasm.document_moveCard(retptr, this.__wbg_ptr, from, to);
576
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
577
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
578
+ if (r1) {
579
+ throw takeObject(r0);
580
+ }
581
+ } finally {
582
+ wasm.__wbindgen_add_to_stack_pointer(16);
583
+ }
584
+ }
585
+ /**
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
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
+ /**
635
+ * @returns {string}
636
+ */
637
+ get quillRef() {
638
+ let deferred1_0;
639
+ let deferred1_1;
640
+ try {
641
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
642
+ wasm.document_quillRef(retptr, this.__wbg_ptr);
643
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
644
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
645
+ deferred1_0 = r0;
646
+ deferred1_1 = r1;
647
+ return getStringFromWasm0(r0, r1);
648
+ } finally {
649
+ wasm.__wbindgen_add_to_stack_pointer(16);
650
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
651
+ }
652
+ }
653
+ /**
654
+ * The canonical `$quill` reference grammar as author-facing text. Core is
655
+ * the single source of truth: drive schema `describe` and validation
656
+ * messages from this instead of re-stating the rule — it matches the
657
+ * `hint` on `parse::invalid_quill_reference`. Cache it; the value never
658
+ * changes.
659
+ * @returns {string}
660
+ */
661
+ static quillRefHint() {
662
+ let deferred1_0;
663
+ let deferred1_1;
664
+ try {
665
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
666
+ wasm.document_quillRefHint(retptr);
667
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
668
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
669
+ deferred1_0 = r0;
670
+ deferred1_1 = r1;
671
+ return getStringFromWasm0(r0, r1);
672
+ } finally {
673
+ wasm.__wbindgen_add_to_stack_pointer(16);
674
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
675
+ }
676
+ }
677
+ /**
678
+ * @param {number} index
679
+ * @returns {Card | undefined}
680
+ */
681
+ removeCard(index) {
682
+ try {
683
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
684
+ wasm.document_removeCard(retptr, this.__wbg_ptr, index);
685
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
686
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
687
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
688
+ if (r2) {
689
+ throw takeObject(r1);
690
+ }
691
+ return takeObject(r0);
692
+ } finally {
693
+ wasm.__wbindgen_add_to_stack_pointer(16);
694
+ }
695
+ }
696
+ /**
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.
772
+ * @returns {Record<string, unknown> | undefined}
773
+ */
774
+ removeExt() {
775
+ try {
776
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
777
+ wasm.document_removeExt(retptr, this.__wbg_ptr);
778
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
779
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
780
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
781
+ if (r2) {
782
+ throw takeObject(r1);
783
+ }
784
+ return takeObject(r0);
785
+ } finally {
786
+ wasm.__wbindgen_add_to_stack_pointer(16);
787
+ }
788
+ }
789
+ /**
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
795
+ * @returns {any}
796
+ */
797
+ removeExtNamespace(namespace) {
798
+ try {
799
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
800
+ const ptr0 = passStringToWasm0(namespace, wasm.__wbindgen_export, wasm.__wbindgen_export2);
801
+ const len0 = WASM_VECTOR_LEN;
802
+ wasm.document_removeExtNamespace(retptr, this.__wbg_ptr, ptr0, len0);
803
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
804
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
805
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
806
+ if (r2) {
807
+ throw takeObject(r1);
808
+ }
809
+ return takeObject(r0);
810
+ } finally {
811
+ wasm.__wbindgen_add_to_stack_pointer(16);
812
+ }
813
+ }
814
+ /**
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
818
+ * @returns {any}
819
+ */
820
+ removeField(name) {
821
+ try {
822
+ 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);
826
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
827
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
828
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
829
+ if (r2) {
830
+ throw takeObject(r1);
831
+ }
832
+ return takeObject(r0);
833
+ } finally {
834
+ wasm.__wbindgen_add_to_stack_pointer(16);
835
+ }
836
+ }
837
+ /**
838
+ * Remove `cardKind` from the main card's `$seed` map, returning its
839
+ * overlay or `undefined`; drops `$seed` entirely once empty. Sibling
840
+ * kinds survive.
841
+ * @param {string} card_kind
842
+ * @returns {any}
843
+ */
844
+ removeSeedNamespace(card_kind) {
845
+ try {
846
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
847
+ const ptr0 = passStringToWasm0(card_kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
848
+ const len0 = WASM_VECTOR_LEN;
849
+ wasm.document_removeSeedNamespace(retptr, this.__wbg_ptr, ptr0, len0);
850
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
851
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
852
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
853
+ if (r2) {
854
+ throw takeObject(r1);
855
+ }
856
+ return takeObject(r0);
857
+ } finally {
858
+ wasm.__wbindgen_add_to_stack_pointer(16);
859
+ }
860
+ }
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
+ /**
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
+ }
913
+ }
914
+ /**
915
+ * Read the `schema` version tag from a raw storage DTO string without a
916
+ * full parse, or `undefined`. Returns unknown future versions as-is —
917
+ * useful to distinguish "build too old" from "payload corrupt" when
918
+ * `fromJson` throws.
919
+ * @param {string} json
920
+ * @returns {string | undefined}
921
+ */
922
+ static schemaVersionOf(json) {
923
+ try {
924
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
925
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
926
+ const len0 = WASM_VECTOR_LEN;
927
+ wasm.document_schemaVersionOf(retptr, ptr0, len0);
928
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
929
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
930
+ let v2;
931
+ if (r0 !== 0) {
932
+ v2 = getStringFromWasm0(r0, r1).slice();
933
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
934
+ }
935
+ return v2;
936
+ } finally {
937
+ wasm.__wbindgen_add_to_stack_pointer(16);
938
+ }
939
+ }
940
+ /**
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
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
+ }
1027
+ /**
1028
+ * Replace the kind of the card at `index`. Payload and body are untouched;
1029
+ * schema-aware migration is the caller's responsibility.
1030
+ * Throws if `index` is out of range or `newKind` is invalid.
1031
+ * @param {number} index
1032
+ * @param {string} new_kind
1033
+ */
1034
+ setCardKind(index, new_kind) {
1035
+ try {
1036
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1037
+ const ptr0 = passStringToWasm0(new_kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1038
+ const len0 = WASM_VECTOR_LEN;
1039
+ wasm.document_setCardKind(retptr, this.__wbg_ptr, index, ptr0, len0);
1040
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1041
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1042
+ if (r1) {
1043
+ throw takeObject(r0);
1044
+ }
1045
+ } finally {
1046
+ wasm.__wbindgen_add_to_stack_pointer(16);
1047
+ }
1048
+ }
1049
+ /**
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
1055
+ */
1056
+ setExt(value) {
1057
+ try {
1058
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1059
+ wasm.document_setExt(retptr, this.__wbg_ptr, addHeapObject(value));
1060
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1061
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1062
+ if (r1) {
1063
+ throw takeObject(r0);
1064
+ }
1065
+ } finally {
1066
+ wasm.__wbindgen_add_to_stack_pointer(16);
1067
+ }
1068
+ }
1069
+ /**
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
1075
+ * @param {any} value
1076
+ */
1077
+ setExtNamespace(namespace, value) {
1078
+ try {
1079
+ 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));
1083
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1084
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1085
+ if (r1) {
1086
+ throw takeObject(r0);
1087
+ }
1088
+ } finally {
1089
+ wasm.__wbindgen_add_to_stack_pointer(16);
1090
+ }
1091
+ }
1092
+ /**
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
1097
+ * @param {any} value
1098
+ */
1099
+ setField(name, value) {
1100
+ try {
1101
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1102
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1103
+ const len0 = WASM_VECTOR_LEN;
1104
+ wasm.document_setField(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(value));
1105
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1106
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1107
+ if (r1) {
1108
+ throw takeObject(r0);
1109
+ }
1110
+ } finally {
1111
+ wasm.__wbindgen_add_to_stack_pointer(16);
1112
+ }
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
+ }
1136
+ /**
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
1141
+ */
1142
+ setFill(name, value) {
1143
+ try {
1144
+ 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));
1148
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1149
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1150
+ if (r1) {
1151
+ throw takeObject(r0);
1152
+ }
1153
+ } finally {
1154
+ wasm.__wbindgen_add_to_stack_pointer(16);
1155
+ }
1156
+ }
1157
+ /**
1158
+ * Replace the QUILL reference string. Throws if `ref_str` is invalid.
1159
+ * @param {string} ref_str
1160
+ */
1161
+ setQuillRef(ref_str) {
1162
+ try {
1163
+ 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);
1167
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1168
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1169
+ if (r1) {
1170
+ throw takeObject(r0);
1171
+ }
1172
+ } finally {
1173
+ wasm.__wbindgen_add_to_stack_pointer(16);
1174
+ }
1175
+ }
1176
+ /**
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.
1181
+ * @param {string} card_kind
1182
+ * @param {any} overlay
1183
+ */
1184
+ setSeedNamespace(card_kind, overlay) {
1185
+ try {
1186
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1187
+ const ptr0 = passStringToWasm0(card_kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1188
+ const len0 = WASM_VECTOR_LEN;
1189
+ wasm.document_setSeedNamespace(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(overlay));
1190
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1191
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1192
+ if (r1) {
1193
+ throw takeObject(r0);
1194
+ }
1195
+ } finally {
1196
+ wasm.__wbindgen_add_to_stack_pointer(16);
1197
+ }
1198
+ }
1199
+ /**
1200
+ * Serialize this document to a versioned storage DTO string.
1201
+ *
1202
+ * Prefer this over `toMarkdown` for persistence across restarts or crate
1203
+ * upgrades — the wire format is frozen per `schema` version. Parse-time
1204
+ * `warnings` are excluded from the DTO.
1205
+ *
1206
+ * Output is **byte-deterministic** within a `schema` version: equal
1207
+ * documents produce byte-equal output, safe for content-hash use cases.
1208
+ * @returns {string}
1209
+ */
1210
+ toJson() {
1211
+ let deferred1_0;
1212
+ let deferred1_1;
1213
+ try {
1214
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1215
+ wasm.document_toJson(retptr, this.__wbg_ptr);
1216
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1217
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1218
+ deferred1_0 = r0;
1219
+ deferred1_1 = r1;
1220
+ return getStringFromWasm0(r0, r1);
1221
+ } finally {
1222
+ wasm.__wbindgen_add_to_stack_pointer(16);
1223
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1224
+ }
1225
+ }
1226
+ /**
1227
+ * Emit canonical Quillmark Markdown. Round-trip safe: re-parsing the
1228
+ * result produces a `Document` equal to `self` by value and by type.
1229
+ * @returns {string}
1230
+ */
1231
+ toMarkdown() {
1232
+ let deferred1_0;
1233
+ let deferred1_1;
1234
+ try {
1235
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1236
+ wasm.document_toMarkdown(retptr, this.__wbg_ptr);
1237
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1238
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1239
+ deferred1_0 = r0;
1240
+ deferred1_1 = r1;
1241
+ return getStringFromWasm0(r0, r1);
1242
+ } finally {
1243
+ wasm.__wbindgen_add_to_stack_pointer(16);
1244
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1245
+ }
1246
+ }
1247
+ /**
1248
+ * Like [`fromJson`](Document::from_json) but returns `undefined` instead
1249
+ * of throwing when `json` is not a valid storage DTO — use to
1250
+ * discriminate format without exceptions as control flow.
1251
+ * `undefined` means "not a storage DTO"; `fromMarkdown` still throws on
1252
+ * genuinely malformed markdown.
1253
+ * @param {string} json
1254
+ * @returns {Document | undefined}
1255
+ */
1256
+ static tryFromJson(json) {
1257
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1258
+ const len0 = WASM_VECTOR_LEN;
1259
+ const ret = wasm.document_tryFromJson(ptr0, len0);
1260
+ return ret === 0 ? undefined : Document.__wrap(ret);
1261
+ }
1262
+ /**
1263
+ * @returns {Diagnostic[]}
1264
+ */
1265
+ get warnings() {
1266
+ try {
1267
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1268
+ wasm.document_warnings(retptr, this.__wbg_ptr);
1269
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1270
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1271
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1272
+ if (r2) {
1273
+ throw takeObject(r1);
1274
+ }
1275
+ return takeObject(r0);
1276
+ } finally {
1277
+ wasm.__wbindgen_add_to_stack_pointer(16);
1278
+ }
1279
+ }
1280
+ }
1281
+ if (Symbol.dispose) Document.prototype[Symbol.dispose] = Document.prototype.free;
1282
+
1283
+ /**
1284
+ * Live render session: reads (`render`, `paint`, `pageSize`, `regions`,
1285
+ * `fieldAt`, `positionAt`, `locate`) serve the current compile. `apply(doc)`
1286
+ * recompiles a whole document in place, transactionally (on throw every read
1287
+ * keeps serving the last-good compile). Geometry reads reflect the current
1288
+ * compile; anchoring a caret across edits is the editor's job — re-read
1289
+ * geometry after each committed `apply`.
1290
+ *
1291
+ * **Empty documents.** A zero-page document yields a valid session
1292
+ * (`pageCount === 0`); `paint(ctx, 0)` or `pageSize(0)` throws with
1293
+ * `"page index 0 out of range (pageCount=0)"`. Branch on `pageCount === 0`
1294
+ * rather than catching the error.
1295
+ */
1296
+ export class LiveSession {
1297
+ static __wrap(ptr) {
1298
+ ptr = ptr >>> 0;
1299
+ const obj = Object.create(LiveSession.prototype);
1300
+ obj.__wbg_ptr = ptr;
1301
+ LiveSessionFinalization.register(obj, obj.__wbg_ptr, obj);
1302
+ return obj;
1303
+ }
1304
+ __destroy_into_raw() {
1305
+ const ptr = this.__wbg_ptr;
1306
+ this.__wbg_ptr = 0;
1307
+ LiveSessionFinalization.unregister(this);
1308
+ return ptr;
1309
+ }
1310
+ free() {
1311
+ const ptr = this.__destroy_into_raw();
1312
+ wasm.__wbg_livesession_free(ptr, 0);
1313
+ }
1314
+ /**
1315
+ * Recompile the session against `doc` — the edit verb of a live preview.
1316
+ * The document is compiled through the same schema pipeline as `open`
1317
+ * (same quill), then applied transactionally: on throw every read
1318
+ * (`render`, `paint`, `pageSize`, `regions`, `fieldAt`) keeps serving the last-good
1319
+ * compile, and the session recovers on the next successful `apply`. On
1320
+ * success reads serve the new compile; repaint `dirtyPages ∩ visible`.
1321
+ * @param {Document} doc
1322
+ * @returns {ChangeSet}
1323
+ */
1324
+ apply(doc) {
1325
+ try {
1326
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1327
+ _assertClass(doc, Document);
1328
+ wasm.livesession_apply(retptr, this.__wbg_ptr, doc.__wbg_ptr);
1329
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1330
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1331
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1332
+ if (r2) {
1333
+ throw takeObject(r1);
1334
+ }
1335
+ return takeObject(r0);
1336
+ } finally {
1337
+ wasm.__wbindgen_add_to_stack_pointer(16);
1338
+ }
1339
+ }
1340
+ /**
1341
+ * The backend that produced this session (e.g. `"typst"`).
1342
+ * @returns {string}
1343
+ */
1344
+ get backendId() {
1345
+ let deferred1_0;
1346
+ let deferred1_1;
1347
+ try {
1348
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1349
+ wasm.livesession_backendId(retptr, this.__wbg_ptr);
1350
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1351
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1352
+ deferred1_0 = r0;
1353
+ deferred1_1 = r1;
1354
+ return getStringFromWasm0(r0, r1);
1355
+ } finally {
1356
+ wasm.__wbindgen_add_to_stack_pointer(16);
1357
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1358
+ }
1359
+ }
1360
+ /**
1361
+ * The schema field whose content is under a point on `page` — the
1362
+ * forward (click → field) direction: hit-test a click against the
1363
+ * compiled document and get back the field address to focus in the
1364
+ * editor, or `undefined` off any field's ink. `x`/`y` are PDF points
1365
+ * with a **bottom-left** origin, the same space as `FieldRegion.rect` —
1366
+ * from a canvas click, invert the overlay transform documented on
1367
+ * `FieldRegion`: `x = clickPx.x / renderScale`,
1368
+ * `y = pageHeightPt - clickPx.y / renderScale`. Unlike `regions()`,
1369
+ * *every* placement answers, not just the first.
1370
+ * @param {number} page
1371
+ * @param {number} x
1372
+ * @param {number} y
1373
+ * @returns {string | undefined}
1374
+ */
1375
+ fieldAt(page, x, y) {
1376
+ try {
1377
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1378
+ wasm.livesession_fieldAt(retptr, this.__wbg_ptr, page, x, y);
1379
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1380
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1381
+ let v1;
1382
+ if (r0 !== 0) {
1383
+ v1 = getStringFromWasm0(r0, r1).slice();
1384
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
1385
+ }
1386
+ return v1;
1387
+ } finally {
1388
+ wasm.__wbindgen_add_to_stack_pointer(16);
1389
+ }
1390
+ }
1391
+ /**
1392
+ * The whole-field highlight boxes for `field` — one union rect per page,
1393
+ * over the field's `span`-bearing content segments. The convenience that
1394
+ * owns the union `regions()` leaves derived: it keeps `regions()` the
1395
+ * low-level disjoint truth (#829) and folds the span-filter + per-page
1396
+ * union here, so a "highlight the focused field" consumer stops
1397
+ * reimplementing it. **Content only** — a field placed solely as a scalar
1398
+ * reference or a bound widget carries no `span` and returns `[]`; its box
1399
+ * is a single `regions()` rect. Reflects the current compile, like
1400
+ * `regions()`.
1401
+ * @param {string} field
1402
+ * @returns {FieldRegion[]}
1403
+ */
1404
+ fieldBoxes(field) {
1405
+ try {
1406
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1407
+ const ptr0 = passStringToWasm0(field, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1408
+ const len0 = WASM_VECTOR_LEN;
1409
+ wasm.livesession_fieldBoxes(retptr, this.__wbg_ptr, ptr0, len0);
1410
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1411
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1412
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1413
+ if (r2) {
1414
+ throw takeObject(r1);
1415
+ }
1416
+ return takeObject(r0);
1417
+ } finally {
1418
+ wasm.__wbindgen_add_to_stack_pointer(16);
1419
+ }
1420
+ }
1421
+ /**
1422
+ * A corpus position → **caret rect** — the reverse of `positionAt`: given
1423
+ * a field and a USV offset into its `RichText`, return the box (in the
1424
+ * same bottom-left PDF-point space as `FieldRegion.rect`) to draw a caret
1425
+ * at, its `span` collapsed to `[pos, pos]`; `undefined` when the field
1426
+ * places no tracked content or the offset maps to no drawn glyph.
1427
+ * @param {string} field
1428
+ * @param {number} pos
1429
+ * @returns {FieldRegion | undefined}
1430
+ */
1431
+ locate(field, pos) {
1432
+ const ptr0 = passStringToWasm0(field, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1433
+ const len0 = WASM_VECTOR_LEN;
1434
+ const ret = wasm.livesession_locate(this.__wbg_ptr, ptr0, len0, pos);
1435
+ return takeObject(ret);
1436
+ }
1437
+ /**
1438
+ * @returns {number}
1439
+ */
1440
+ get pageCount() {
1441
+ const ret = wasm.livesession_pageCount(this.__wbg_ptr);
1442
+ return ret >>> 0;
1443
+ }
1444
+ /**
1445
+ * Page dimensions in points (1 pt = 1/72 inch).
1446
+ * Throws if the backend has no canvas painter or `page` is out of range.
1447
+ * @param {number} page
1448
+ * @returns {PageSize}
1449
+ */
1450
+ pageSize(page) {
1451
+ try {
1452
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1453
+ wasm.livesession_pageSize(retptr, this.__wbg_ptr, page);
1454
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1455
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1456
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1457
+ if (r2) {
1458
+ throw takeObject(r1);
1459
+ }
1460
+ return takeObject(r0);
1461
+ } finally {
1462
+ wasm.__wbindgen_add_to_stack_pointer(16);
1463
+ }
1464
+ }
1465
+ /**
1466
+ * Paint `page` into a `CanvasRenderingContext2D` or
1467
+ * `OffscreenCanvasRenderingContext2D`. The painter owns
1468
+ * `canvas.width`/`height` (no `clearRect` needed); consumers own
1469
+ * `canvas.style.*`. If `layoutScale * densityScale` exceeds 16384 px
1470
+ * per side, `densityScale` is clamped — `PaintResult.clamped` reports it and
1471
+ * `PaintResult.effectiveDensityScale` carries the density actually applied.
1472
+ *
1473
+ * `put_image_data` writes the whole backing store, bypassing the 2D
1474
+ * context's transform, `globalAlpha`, and clip: the painter owns the entire
1475
+ * canvas, so each visible page needs its own `` — you cannot composite
1476
+ * two pages, a sub-rect, or a context transform through this call.
1477
+ *
1478
+ * Throws if the backend has no canvas painter, `page` is out of range,
1479
+ * `ctx` is the wrong type, or either scale is non-finite or `<= 0`.
1480
+ * @param {CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D} ctx
1481
+ * @param {number} page
1482
+ * @param {PaintOptions | undefined} opts
1483
+ * @returns {PaintResult}
1484
+ */
1485
+ paint(ctx, page, opts) {
1486
+ try {
1487
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1488
+ wasm.livesession_paint(retptr, this.__wbg_ptr, addHeapObject(ctx), page, addHeapObject(opts));
1489
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1490
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1491
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1492
+ if (r2) {
1493
+ throw takeObject(r1);
1494
+ }
1495
+ return takeObject(r0);
1496
+ } finally {
1497
+ wasm.__wbindgen_add_to_stack_pointer(16);
1498
+ }
1499
+ }
1500
+ /**
1501
+ * A point → **corpus position** — the fine-grained click direction:
1502
+ * hit-test a point and get back the field *and* a USV offset into its
1503
+ * `RichText` (for placing a caret or mapping a selection into the content
1504
+ * model), or `undefined` off all content ink. `x`/`y` are PDF points,
1505
+ * bottom-left origin — the same space as `fieldAt`. The offset is
1506
+ * cluster-exact and degrades to the containing segment's start on
1507
+ * origin-less ink (list markers, a code fence's interior). See
1508
+ * `CorpusHit`.
1509
+ * @param {number} page
1510
+ * @param {number} x
1511
+ * @param {number} y
1512
+ * @returns {CorpusHit | undefined}
1513
+ */
1514
+ positionAt(page, x, y) {
1515
+ const ret = wasm.livesession_positionAt(this.__wbg_ptr, page, x, y);
1516
+ return takeObject(ret);
1517
+ }
1518
+ /**
1519
+ * Schema-field geometry for this compiled session — each content field's
1520
+ * **first placement** (one region per page it touches) plus widget and
1521
+ * scalar-reference-site regions, keyed on the quill schema field path; a
1522
+ * field may still appear more than once (group by `field`, see
1523
+ * `FieldRegion`). A session-level query: no render, no byte artifact. An
1524
+ * interactive preview reads it to scroll to / highlight the focused
1525
+ * field over a `paint`-ed canvas; the click direction is `fieldAt`.
1526
+ * Empty for backends that place no schema fields.
1527
+ * @returns {FieldRegion[]}
1528
+ */
1529
+ regions() {
1530
+ try {
1531
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1532
+ wasm.livesession_regions(retptr, this.__wbg_ptr);
1533
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1534
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1535
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1536
+ if (r2) {
1537
+ throw takeObject(r1);
1538
+ }
1539
+ return takeObject(r0);
1540
+ } finally {
1541
+ wasm.__wbindgen_add_to_stack_pointer(16);
1542
+ }
1543
+ }
1544
+ /**
1545
+ * @param {RenderOptions | null} [opts]
1546
+ * @returns {RenderResult}
1547
+ */
1548
+ render(opts) {
1549
+ try {
1550
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1551
+ wasm.livesession_render(retptr, this.__wbg_ptr, isLikeNone(opts) ? 0 : addHeapObject(opts));
1552
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1553
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1554
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1555
+ if (r2) {
1556
+ throw takeObject(r1);
1557
+ }
1558
+ return takeObject(r0);
1559
+ } finally {
1560
+ wasm.__wbindgen_add_to_stack_pointer(16);
1561
+ }
1562
+ }
1563
+ /**
1564
+ * `true` iff `paint` and `pageSize` will succeed for this session. Derived
1565
+ * from the session's canvas seam, so it reflects exactly what `paint` will
1566
+ * do — no separately captured flag.
1567
+ * @returns {boolean}
1568
+ */
1569
+ get supportsCanvas() {
1570
+ const ret = wasm.livesession_supportsCanvas(this.__wbg_ptr);
1571
+ return ret !== 0;
1572
+ }
1573
+ /**
1574
+ * Non-fatal diagnostics of the session's **current compile** (e.g. Typst
1575
+ * font fallback) — set at open and refreshed by each committed `apply`;
1576
+ * a failed apply keeps the last-good compile's warnings. Also appended
1577
+ * to `RenderResult.warnings` on each `render()` call.
1578
+ * @returns {Diagnostic[]}
1579
+ */
1580
+ get warnings() {
1581
+ try {
1582
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1583
+ wasm.livesession_warnings(retptr, this.__wbg_ptr);
1584
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1585
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1586
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1587
+ if (r2) {
1588
+ throw takeObject(r1);
1589
+ }
1590
+ return takeObject(r0);
1591
+ } finally {
1592
+ wasm.__wbindgen_add_to_stack_pointer(16);
1593
+ }
1594
+ }
1595
+ }
1596
+ if (Symbol.dispose) LiveSession.prototype[Symbol.dispose] = LiveSession.prototype.free;
1597
+
1598
+ export class Quill {
1599
+ static __wrap(ptr) {
1600
+ ptr = ptr >>> 0;
1601
+ const obj = Object.create(Quill.prototype);
1602
+ obj.__wbg_ptr = ptr;
1603
+ QuillFinalization.register(obj, obj.__wbg_ptr, obj);
1604
+ return obj;
1605
+ }
1606
+ __destroy_into_raw() {
1607
+ const ptr = this.__wbg_ptr;
1608
+ this.__wbg_ptr = 0;
1609
+ QuillFinalization.unregister(this);
1610
+ return ptr;
1611
+ }
1612
+ free() {
1613
+ const ptr = this.__destroy_into_raw();
1614
+ wasm.__wbg_quill_free(ptr, 0);
1615
+ }
1616
+ /**
1617
+ * The *declared* backend identifier (`config.backend`, e.g. `"typst"`).
1618
+ * Intent, not a resolved capability — capability (`supportedFormats` /
1619
+ * `supportsCanvas`) is read from the engine.
1620
+ * @returns {string}
1621
+ */
1622
+ get backendId() {
1623
+ let deferred1_0;
1624
+ let deferred1_1;
1625
+ try {
1626
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1627
+ wasm.quill_backendId(retptr, this.__wbg_ptr);
1628
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1629
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1630
+ deferred1_0 = r0;
1631
+ deferred1_1 = r1;
1632
+ return getStringFromWasm0(r0, r1);
1633
+ } finally {
1634
+ wasm.__wbindgen_add_to_stack_pointer(16);
1635
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1636
+ }
1637
+ }
1638
+ /**
1639
+ * @returns {string}
1640
+ */
1641
+ get blueprint() {
1642
+ let deferred1_0;
1643
+ let deferred1_1;
1644
+ try {
1645
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1646
+ wasm.quill_blueprint(retptr, this.__wbg_ptr);
1647
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1648
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1649
+ deferred1_0 = r0;
1650
+ deferred1_1 = r1;
1651
+ return getStringFromWasm0(r0, r1);
1652
+ } finally {
1653
+ wasm.__wbindgen_add_to_stack_pointer(16);
1654
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1655
+ }
1656
+ }
1657
+ /**
1658
+ * Build a quill from a file tree. Pure — no backend, no engine; the
1659
+ * declared backend is resolved later, at render time.
1660
+ *
1661
+ * Accepts either a `Map<string, Uint8Array>` or a plain object
1662
+ * (`Record<string, Uint8Array>`). Plain objects are walked via
1663
+ * `Object.entries` at the boundary; the Rust side sees a single
1664
+ * canonical shape.
1665
+ * @param {Map<string, Uint8Array>} tree
1666
+ * @returns {Quill}
1667
+ */
1668
+ static fromTree(tree) {
1669
+ try {
1670
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1671
+ wasm.quill_fromTree(retptr, addHeapObject(tree));
1672
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1673
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1674
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1675
+ if (r2) {
1676
+ throw takeObject(r1);
1677
+ }
1678
+ return Quill.__wrap(r0);
1679
+ } finally {
1680
+ wasm.__wbindgen_add_to_stack_pointer(16);
1681
+ }
1682
+ }
1683
+ /**
1684
+ * Identity snapshot of the `quill:` section of `Quill.yaml` plus any extra
1685
+ * `quill:` keys. Pure config — the backend's output formats are a
1686
+ * resolved-backend capability read from the engine
1687
+ * (`Quillmark.supportedFormats`), not part of this snapshot.
1688
+ * @returns {QuillMetadata}
1689
+ */
1690
+ get metadata() {
1691
+ try {
1692
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1693
+ wasm.quill_metadata(retptr, this.__wbg_ptr);
1694
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1695
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1696
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1697
+ if (r2) {
1698
+ throw takeObject(r1);
1699
+ }
1700
+ return takeObject(r0);
1701
+ } finally {
1702
+ wasm.__wbindgen_add_to_stack_pointer(16);
1703
+ }
1704
+ }
1705
+ /**
1706
+ * Document schema for the quill: the user-fillable fields plus their
1707
+ * `ui` hints (title / group / compact / multiline). The single
1708
+ * field-metadata surface — drives form editors and LLM/MCP consumers
1709
+ * alike. Key order in `fields`/`properties` is declaration order — the
1710
+ * ordering contract. Returns the `QuillSchema` shape.
1711
+ * @returns {QuillSchema}
1712
+ */
1713
+ get schema() {
1714
+ try {
1715
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1716
+ wasm.quill_schema(retptr, this.__wbg_ptr);
1717
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1718
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1719
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1720
+ if (r2) {
1721
+ throw takeObject(r1);
1722
+ }
1723
+ return takeObject(r0);
1724
+ } finally {
1725
+ wasm.__wbindgen_add_to_stack_pointer(16);
1726
+ }
1727
+ }
1728
+ /**
1729
+ * Seed a starter composable `Card` of the given kind (carries `$kind`),
1730
+ * layering an optional per-kind seed `overlay` over the schema-example
1731
+ * base (`overlay › example › absent`). Returns `undefined` if `cardKind`
1732
+ * is not declared in this quill's schema, else a `Card` that feeds
1733
+ * straight into `Document.pushCard` / `insertCard`.
1734
+ *
1735
+ * Pass `document.main.seed?.[cardKind]` as `overlay` so a card added to a
1736
+ * template-derived document inherits its curated starting values; omit it
1737
+ * (or pass `undefined` / `null`) for the bare schema seed. `overlay` is a
1738
+ * plain object — this reads the document, it does not mutate it.
1739
+ * @param {string} card_kind
1740
+ * @param {Record<string, unknown> | undefined} overlay
1741
+ * @returns {Card | undefined}
1742
+ */
1743
+ seedCard(card_kind, overlay) {
1744
+ try {
1745
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1746
+ const ptr0 = passStringToWasm0(card_kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1747
+ const len0 = WASM_VECTOR_LEN;
1748
+ wasm.quill_seedCard(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(overlay));
1749
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1750
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1751
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1752
+ if (r2) {
1753
+ throw takeObject(r1);
1754
+ }
1755
+ return takeObject(r0);
1756
+ } finally {
1757
+ wasm.__wbindgen_add_to_stack_pointer(16);
1758
+ }
1759
+ }
1760
+ /**
1761
+ * Seed a starter `Document` from the schema — the main card plus one
1762
+ * instance of each composable card kind, each committing its fields'
1763
+ * `example:` values and leaving every other field absent (interpolated at
1764
+ * render: `default:`, else type-empty zero). Illustration-first: a field
1765
+ * with both an `example` and a `default` renders its example. See
1766
+ * `prose/canon/SCHEMAS.md` § "Document seeding".
1767
+ * @returns {Document}
1768
+ */
1769
+ seedDocument() {
1770
+ const ret = wasm.quill_seedDocument(this.__wbg_ptr);
1771
+ return Document.__wrap(ret);
1772
+ }
1773
+ /**
1774
+ * Seed a starter main `Card` (carries `$quill`) from the schema — the
1775
+ * `$kind: main` card of [`seedDocument`](Self::seed_document) in
1776
+ * isolation, committing each field's `example:` value. Returns the same
1777
+ * `Card` shape as the `Document.main` getter.
1778
+ * @returns {Card}
1779
+ */
1780
+ seedMain() {
1781
+ try {
1782
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1783
+ wasm.quill_seedMain(retptr, this.__wbg_ptr);
1784
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1785
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1786
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1787
+ if (r2) {
1788
+ throw takeObject(r1);
1789
+ }
1790
+ return takeObject(r0);
1791
+ } finally {
1792
+ wasm.__wbindgen_add_to_stack_pointer(16);
1793
+ }
1794
+ }
1795
+ /**
1796
+ * Flatten this quill back into its canonical file tree — the inverse of
1797
+ * [`fromTree`](Self::from_tree). Round-trips: `Quill.fromTree(q.toTree())`
1798
+ * reproduces an equivalent quill.
1799
+ *
1800
+ * This is how a quill crosses a WASM linear-memory boundary as data: a
1801
+ * `Quill` built in one build (e.g. the Typst-less `@quillmark/wasm/core`)
1802
+ * cannot be passed to an engine in another (separate linear memories), so
1803
+ * `@quillmark/wasm/runtime` re-feeds this tree to the backend build's
1804
+ * `Quill.fromTree` on demand. Keys are `"/"`-joined relative paths,
1805
+ * matching what `fromTree` accepts.
1806
+ * @returns {Map<string, Uint8Array>}
1807
+ */
1808
+ toTree() {
1809
+ const ret = wasm.quill_toTree(this.__wbg_ptr);
1810
+ return takeObject(ret);
1811
+ }
1812
+ /**
1813
+ * Validate `doc` against this quill's schema, returning every diagnostic
1814
+ * (an empty array when the document is valid).
1815
+ *
1816
+ * Forwards the canonical `validation::*` diagnostics — same `code`,
1817
+ * `path`, and `hint` the engine emits — including the non-fatal
1818
+ * `validation::must_fill` warning for each `!must_fill` marker left in
1819
+ * the document. Field values, defaults, and order are not part of this
1820
+ * surface: read them from the `Document` payload and `Quill.schema`
1821
+ * (schema key order is display order).
1822
+ * @param {Document} doc
1823
+ * @returns {Diagnostic[]}
1824
+ */
1825
+ validate(doc) {
1826
+ try {
1827
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1828
+ _assertClass(doc, Document);
1829
+ wasm.quill_validate(retptr, this.__wbg_ptr, doc.__wbg_ptr);
1830
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1831
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1832
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1833
+ if (r2) {
1834
+ throw takeObject(r1);
1835
+ }
1836
+ return takeObject(r0);
1837
+ } finally {
1838
+ wasm.__wbindgen_add_to_stack_pointer(16);
1839
+ }
1840
+ }
1841
+ }
1842
+ if (Symbol.dispose) Quill.prototype[Symbol.dispose] = Quill.prototype.free;
1843
+
1844
+ /**
1845
+ * Render engine: a backend registry and render dispatcher. Render build only —
1846
+ * the core build constructs and validates quills without it.
1847
+ */
1848
+ export class Quillmark {
1849
+ __destroy_into_raw() {
1850
+ const ptr = this.__wbg_ptr;
1851
+ this.__wbg_ptr = 0;
1852
+ QuillmarkFinalization.unregister(this);
1853
+ return ptr;
1854
+ }
1855
+ free() {
1856
+ const ptr = this.__destroy_into_raw();
1857
+ wasm.__wbg_quillmark_free(ptr, 0);
1858
+ }
1859
+ constructor() {
1860
+ const ret = wasm.quillmark_new();
1861
+ this.__wbg_ptr = ret >>> 0;
1862
+ QuillmarkFinalization.register(this, this.__wbg_ptr, this);
1863
+ return this;
1864
+ }
1865
+ /**
1866
+ * Open a live render session for `doc` against `quill`'s backend.
1867
+ * @param {Quill} quill
1868
+ * @param {Document} doc
1869
+ * @returns {LiveSession}
1870
+ */
1871
+ open(quill, doc) {
1872
+ try {
1873
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1874
+ _assertClass(quill, Quill);
1875
+ _assertClass(doc, Document);
1876
+ wasm.quillmark_open(retptr, this.__wbg_ptr, quill.__wbg_ptr, doc.__wbg_ptr);
1877
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1878
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1879
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1880
+ if (r2) {
1881
+ throw takeObject(r1);
1882
+ }
1883
+ return LiveSession.__wrap(r0);
1884
+ } finally {
1885
+ wasm.__wbindgen_add_to_stack_pointer(16);
1886
+ }
1887
+ }
1888
+ /**
1889
+ * Render `doc` against `quill` in one shot. Convenience over `open` +
1890
+ * `LiveSession.render`: an unset `output_format` falls back to the
1891
+ * backend's first supported format.
1892
+ * @param {Quill} quill
1893
+ * @param {Document} doc
1894
+ * @param {RenderOptions | null} [opts]
1895
+ * @returns {RenderResult}
1896
+ */
1897
+ render(quill, doc, opts) {
1898
+ try {
1899
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1900
+ _assertClass(quill, Quill);
1901
+ _assertClass(doc, Document);
1902
+ wasm.quillmark_render(retptr, this.__wbg_ptr, quill.__wbg_ptr, doc.__wbg_ptr, isLikeNone(opts) ? 0 : addHeapObject(opts));
1903
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1904
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1905
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1906
+ if (r2) {
1907
+ throw takeObject(r1);
1908
+ }
1909
+ return takeObject(r0);
1910
+ } finally {
1911
+ wasm.__wbindgen_add_to_stack_pointer(16);
1912
+ }
1913
+ }
1914
+ /**
1915
+ * The output formats `quill`'s backend can emit. Static capability —
1916
+ * resolves the backend but compiles nothing. Throws `engine::backend_not_found`
1917
+ * if no registered backend matches the quill's declared backend.
1918
+ * @param {Quill} quill
1919
+ * @returns {OutputFormat[]}
1920
+ */
1921
+ supportedFormats(quill) {
1922
+ try {
1923
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1924
+ _assertClass(quill, Quill);
1925
+ wasm.quillmark_supportedFormats(retptr, this.__wbg_ptr, quill.__wbg_ptr);
1926
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1927
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1928
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1929
+ if (r2) {
1930
+ throw takeObject(r1);
1931
+ }
1932
+ return takeObject(r0);
1933
+ } finally {
1934
+ wasm.__wbindgen_add_to_stack_pointer(16);
1935
+ }
1936
+ }
1937
+ /**
1938
+ * Pre-session hint: `true` iff `quill`'s backend can paint sessions to a
1939
+ * canvas, derived from the backend's output formats; `false` when the
1940
+ * backend is unsupported. Use as a cheap precondition probe before mounting
1941
+ * a canvas-based preview UI; the authoritative answer is the session's
1942
+ * `supportsCanvas` getter once `open()` has been called.
1943
+ * @param {Quill} quill
1944
+ * @returns {boolean}
1945
+ */
1946
+ supportsCanvas(quill) {
1947
+ _assertClass(quill, Quill);
1948
+ const ret = wasm.quillmark_supportsCanvas(this.__wbg_ptr, quill.__wbg_ptr);
1949
+ return ret !== 0;
1950
+ }
1951
+ }
1952
+ if (Symbol.dispose) Quillmark.prototype[Symbol.dispose] = Quillmark.prototype.free;
1953
+
1954
+ /**
1955
+ * Export a canonical `RichText` corpus to its markdown projection — the pure
1956
+ * codec that replaces the eager `bodyMarkdown` / `fieldMarkdown` precomputes
1957
+ * (`exportMarkdown(card.body)`). Throws if `rt` is not a canonical corpus.
1958
+ * @param {RichText} rt
1959
+ * @returns {string}
1960
+ */
1961
+ export function exportMarkdown(rt) {
1962
+ let deferred2_0;
1963
+ let deferred2_1;
1964
+ try {
1965
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1966
+ wasm.exportMarkdown(retptr, addHeapObject(rt));
1967
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1968
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1969
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1970
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1971
+ var ptr1 = r0;
1972
+ var len1 = r1;
1973
+ if (r3) {
1974
+ ptr1 = 0; len1 = 0;
1975
+ throw takeObject(r2);
1976
+ }
1977
+ deferred2_0 = ptr1;
1978
+ deferred2_1 = len1;
1979
+ return getStringFromWasm0(ptr1, len1);
1980
+ } finally {
1981
+ wasm.__wbindgen_add_to_stack_pointer(16);
1982
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
1983
+ }
1984
+ }
1985
+
1986
+ /**
1987
+ * Import a markdown string to a canonical `RichText` corpus — the pure,
1988
+ * document-free codec. Pair with `install(addr, importMarkdown(md))` to spell
1989
+ * the cold (anchor-losing) write at the call site; prefer `revise` for edit
1990
+ * semantics. Throws on an over-nested input.
1991
+ * @param {string} markdown
1992
+ * @returns {RichText}
1993
+ */
1994
+ export function importMarkdown(markdown) {
1995
+ try {
1996
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1997
+ const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1998
+ const len0 = WASM_VECTOR_LEN;
1999
+ wasm.importMarkdown(retptr, ptr0, len0);
2000
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2001
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2002
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2003
+ if (r2) {
2004
+ throw takeObject(r1);
2005
+ }
2006
+ return takeObject(r0);
2007
+ } finally {
2008
+ wasm.__wbindgen_add_to_stack_pointer(16);
2009
+ }
2010
+ }
2011
+
2012
+ /**
2013
+ * Initialize the WASM module with panic hooks for better error messages
2014
+ */
2015
+ export function init() {
2016
+ wasm.init();
2017
+ }
2018
+
2019
+ /**
2020
+ * Map a base corpus position through a `delta` to its new position — the pure
2021
+ * position-mapping codec an editor bridge composes to hold a caret stable
2022
+ * across a `revise`. `assoc` decides the side of a same-position insertion
2023
+ * (`"after"` moves past it). Throws on a malformed `delta`.
2024
+ * @param {Delta} delta
2025
+ * @param {number} pos
2026
+ * @param {Assoc} assoc
2027
+ * @returns {number}
2028
+ */
2029
+ export function mapPos(delta, pos, assoc) {
2030
+ try {
2031
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2032
+ wasm.mapPos(retptr, addHeapObject(delta), pos, addHeapObject(assoc));
2033
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2034
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2035
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2036
+ if (r2) {
2037
+ throw takeObject(r1);
2038
+ }
2039
+ return r0 >>> 0;
2040
+ } finally {
2041
+ wasm.__wbindgen_add_to_stack_pointer(16);
2042
+ }
2043
+ }
2044
+
2045
+ /**
2046
+ * Rebase `markdown` onto a `base` corpus — the pure, document-free twin of
2047
+ * `revise`: cold-import + `diff_import`, returning the new `corpus` and the
2048
+ * text `delta` (surviving anchors rebased). Use it to compute a revise without
2049
+ * a document in hand; `revise(addr, md)` fuses this with the store for
2050
+ * atomicity. Throws on an over-nested markdown input or a non-corpus `base`.
2051
+ * @param {RichText} base
2052
+ * @param {string} markdown
2053
+ * @returns {{ corpus: RichText; delta: Delta }}
2054
+ */
2055
+ export function rebase(base, markdown) {
2056
+ try {
2057
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2058
+ const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2059
+ const len0 = WASM_VECTOR_LEN;
2060
+ wasm.rebase(retptr, addHeapObject(base), ptr0, len0);
2061
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2062
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2063
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2064
+ if (r2) {
2065
+ throw takeObject(r1);
2066
+ }
2067
+ return takeObject(r0);
2068
+ } finally {
2069
+ wasm.__wbindgen_add_to_stack_pointer(16);
2070
+ }
2071
+ }
2072
+ export function __wbg_Error_960c155d3d49e4c2(arg0, arg1) {
2073
+ const ret = Error(getStringFromWasm0(arg0, arg1));
2074
+ return addHeapObject(ret);
2075
+ }
2076
+ export function __wbg_Number_32bf70a599af1d4b(arg0) {
2077
+ const ret = Number(getObject(arg0));
2078
+ return ret;
2079
+ }
2080
+ export function __wbg_String_8564e559799eccda(arg0, arg1) {
2081
+ const ret = String(getObject(arg1));
2082
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2083
+ const len1 = WASM_VECTOR_LEN;
2084
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2085
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2086
+ }
2087
+ export function __wbg_String_b51de6b05a10845b(arg0, arg1) {
2088
+ const ret = String(getObject(arg1));
2089
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2090
+ const len1 = WASM_VECTOR_LEN;
2091
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2092
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2093
+ }
2094
+ export function __wbg___wbindgen_bigint_get_as_i64_3d3aba5d616c6a51(arg0, arg1) {
2095
+ const v = getObject(arg1);
2096
+ const ret = typeof(v) === 'bigint' ? v : undefined;
2097
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
2098
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2099
+ }
2100
+ export function __wbg___wbindgen_boolean_get_6ea149f0a8dcc5ff(arg0) {
2101
+ const v = getObject(arg0);
2102
+ const ret = typeof(v) === 'boolean' ? v : undefined;
2103
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
2104
+ }
2105
+ export function __wbg___wbindgen_debug_string_ab4b34d23d6778bd(arg0, arg1) {
2106
+ const ret = debugString(getObject(arg1));
2107
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2108
+ const len1 = WASM_VECTOR_LEN;
2109
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2110
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2111
+ }
2112
+ export function __wbg___wbindgen_in_a5d8b22e52b24dd1(arg0, arg1) {
2113
+ const ret = getObject(arg0) in getObject(arg1);
2114
+ return ret;
2115
+ }
2116
+ export function __wbg___wbindgen_is_bigint_ec25c7f91b4d9e93(arg0) {
2117
+ const ret = typeof(getObject(arg0)) === 'bigint';
2118
+ return ret;
2119
+ }
2120
+ export function __wbg___wbindgen_is_function_3baa9db1a987f47d(arg0) {
2121
+ const ret = typeof(getObject(arg0)) === 'function';
2122
+ return ret;
2123
+ }
2124
+ export function __wbg___wbindgen_is_null_52ff4ec04186736f(arg0) {
2125
+ const ret = getObject(arg0) === null;
2126
+ return ret;
2127
+ }
2128
+ export function __wbg___wbindgen_is_object_63322ec0cd6ea4ef(arg0) {
2129
+ const val = getObject(arg0);
2130
+ const ret = typeof(val) === 'object' && val !== null;
2131
+ return ret;
2132
+ }
2133
+ export function __wbg___wbindgen_is_string_6df3bf7ef1164ed3(arg0) {
2134
+ const ret = typeof(getObject(arg0)) === 'string';
2135
+ return ret;
2136
+ }
2137
+ export function __wbg___wbindgen_is_undefined_29a43b4d42920abd(arg0) {
2138
+ const ret = getObject(arg0) === undefined;
2139
+ return ret;
2140
+ }
2141
+ export function __wbg___wbindgen_jsval_eq_d3465d8a07697228(arg0, arg1) {
2142
+ const ret = getObject(arg0) === getObject(arg1);
2143
+ return ret;
2144
+ }
2145
+ export function __wbg___wbindgen_jsval_loose_eq_cac3565e89b4134c(arg0, arg1) {
2146
+ const ret = getObject(arg0) == getObject(arg1);
2147
+ return ret;
2148
+ }
2149
+ export function __wbg___wbindgen_number_get_c7f42aed0525c451(arg0, arg1) {
2150
+ const obj = getObject(arg1);
2151
+ const ret = typeof(obj) === 'number' ? obj : undefined;
2152
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
2153
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2154
+ }
2155
+ export function __wbg___wbindgen_string_get_7ed5322991caaec5(arg0, arg1) {
2156
+ const obj = getObject(arg1);
2157
+ const ret = typeof(obj) === 'string' ? obj : undefined;
2158
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2159
+ var len1 = WASM_VECTOR_LEN;
2160
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2161
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2162
+ }
2163
+ export function __wbg___wbindgen_throw_6b64449b9b9ed33c(arg0, arg1) {
2164
+ throw new Error(getStringFromWasm0(arg0, arg1));
2165
+ }
2166
+ export function __wbg_call_14b169f759b26747() { return handleError(function (arg0, arg1) {
2167
+ const ret = getObject(arg0).call(getObject(arg1));
2168
+ return addHeapObject(ret);
2169
+ }, arguments); }
2170
+ export function __wbg_canvas_2c0c6d263d4c52ad(arg0) {
2171
+ const ret = getObject(arg0).canvas;
2172
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2173
+ }
2174
+ export function __wbg_canvas_374da9f3c5b3dd0e(arg0) {
2175
+ const ret = getObject(arg0).canvas;
2176
+ return addHeapObject(ret);
2177
+ }
2178
+ export function __wbg_done_9158f7cc8751ba32(arg0) {
2179
+ const ret = getObject(arg0).done;
2180
+ return ret;
2181
+ }
2182
+ export function __wbg_entries_2bf997cf82353e47(arg0) {
2183
+ const ret = getObject(arg0).entries();
2184
+ return addHeapObject(ret);
2185
+ }
2186
+ export function __wbg_entries_e0b73aa8571ddb56(arg0) {
2187
+ const ret = Object.entries(getObject(arg0));
2188
+ return addHeapObject(ret);
2189
+ }
2190
+ export function __wbg_error_a6fa202b58aa1cd3(arg0, arg1) {
2191
+ let deferred0_0;
2192
+ let deferred0_1;
2193
+ try {
2194
+ deferred0_0 = arg0;
2195
+ deferred0_1 = arg1;
2196
+ console.error(getStringFromWasm0(arg0, arg1));
2197
+ } finally {
2198
+ wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
2199
+ }
2200
+ }
2201
+ export function __wbg_from_0dbf29f09e7fb200(arg0) {
2202
+ const ret = Array.from(getObject(arg0));
2203
+ return addHeapObject(ret);
2204
+ }
2205
+ export function __wbg_getRandomValues_3f44b700395062e5() { return handleError(function (arg0, arg1) {
2206
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
2207
+ }, arguments); }
2208
+ export function __wbg_get_1affdbdd5573b16a() { return handleError(function (arg0, arg1) {
2209
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
2210
+ return addHeapObject(ret);
2211
+ }, arguments); }
2212
+ export function __wbg_get_8360291721e2339f(arg0, arg1) {
2213
+ const ret = getObject(arg0)[arg1 >>> 0];
2214
+ return addHeapObject(ret);
2215
+ }
2216
+ export function __wbg_get_unchecked_17f53dad852b9588(arg0, arg1) {
2217
+ const ret = getObject(arg0)[arg1 >>> 0];
2218
+ return addHeapObject(ret);
2219
+ }
2220
+ export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) {
2221
+ const ret = getObject(arg0)[getObject(arg1)];
2222
+ return addHeapObject(ret);
2223
+ }
2224
+ export function __wbg_get_with_ref_key_f64427178466f623(arg0, arg1) {
2225
+ const ret = getObject(arg0)[getObject(arg1)];
2226
+ return addHeapObject(ret);
2227
+ }
2228
+ export function __wbg_instanceof_ArrayBuffer_7c8433c6ed14ffe3(arg0) {
2229
+ let result;
2230
+ try {
2231
+ result = getObject(arg0) instanceof ArrayBuffer;
2232
+ } catch (_) {
2233
+ result = false;
2234
+ }
2235
+ const ret = result;
2236
+ return ret;
2237
+ }
2238
+ export function __wbg_instanceof_CanvasRenderingContext2d_24a3fe06e62b98d7(arg0) {
2239
+ let result;
2240
+ try {
2241
+ result = getObject(arg0) instanceof CanvasRenderingContext2D;
2242
+ } catch (_) {
2243
+ result = false;
2244
+ }
2245
+ const ret = result;
2246
+ return ret;
2247
+ }
2248
+ export function __wbg_instanceof_Map_1b76fd4635be43eb(arg0) {
2249
+ let result;
2250
+ try {
2251
+ result = getObject(arg0) instanceof Map;
2252
+ } catch (_) {
2253
+ result = false;
2254
+ }
2255
+ const ret = result;
2256
+ return ret;
2257
+ }
2258
+ export function __wbg_instanceof_Object_7c99480a1cdfb911(arg0) {
2259
+ let result;
2260
+ try {
2261
+ result = getObject(arg0) instanceof Object;
2262
+ } catch (_) {
2263
+ result = false;
2264
+ }
2265
+ const ret = result;
2266
+ return ret;
2267
+ }
2268
+ export function __wbg_instanceof_OffscreenCanvasRenderingContext2d_285a274020b4f230(arg0) {
2269
+ let result;
2270
+ try {
2271
+ result = getObject(arg0) instanceof OffscreenCanvasRenderingContext2D;
2272
+ } catch (_) {
2273
+ result = false;
2274
+ }
2275
+ const ret = result;
2276
+ return ret;
2277
+ }
2278
+ export function __wbg_instanceof_Uint8Array_152ba1f289edcf3f(arg0) {
2279
+ let result;
2280
+ try {
2281
+ result = getObject(arg0) instanceof Uint8Array;
2282
+ } catch (_) {
2283
+ result = false;
2284
+ }
2285
+ const ret = result;
2286
+ return ret;
2287
+ }
2288
+ export function __wbg_isArray_c3109d14ffc06469(arg0) {
2289
+ const ret = Array.isArray(getObject(arg0));
2290
+ return ret;
2291
+ }
2292
+ export function __wbg_isSafeInteger_4fc213d1989d6d2a(arg0) {
2293
+ const ret = Number.isSafeInteger(getObject(arg0));
2294
+ return ret;
2295
+ }
2296
+ export function __wbg_iterator_013bc09ec998c2a7() {
2297
+ const ret = Symbol.iterator;
2298
+ return addHeapObject(ret);
2299
+ }
2300
+ export function __wbg_keys_2fd1bfdda7e278ca(arg0) {
2301
+ const ret = Object.keys(getObject(arg0));
2302
+ return addHeapObject(ret);
2303
+ }
2304
+ export function __wbg_length_3d4ecd04bd8d22f1(arg0) {
2305
+ const ret = getObject(arg0).length;
2306
+ return ret;
2307
+ }
2308
+ export function __wbg_length_9f1775224cf1d815(arg0) {
2309
+ const ret = getObject(arg0).length;
2310
+ return ret;
2311
+ }
2312
+ export function __wbg_new_0c7403db6e782f19(arg0) {
2313
+ const ret = new Uint8Array(getObject(arg0));
2314
+ return addHeapObject(ret);
2315
+ }
2316
+ export function __wbg_new_227d7c05414eb861() {
2317
+ const ret = new Error();
2318
+ return addHeapObject(ret);
2319
+ }
2320
+ export function __wbg_new_34d45cc8e36aaead() {
2321
+ const ret = new Map();
2322
+ return addHeapObject(ret);
2323
+ }
2324
+ export function __wbg_new_5e360d2ff7b9e1c3(arg0, arg1) {
2325
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
2326
+ return addHeapObject(ret);
2327
+ }
2328
+ export function __wbg_new_682678e2f47e32bc() {
2329
+ const ret = new Array();
2330
+ return addHeapObject(ret);
2331
+ }
2332
+ export function __wbg_new_aa8d0fa9762c29bd() {
2333
+ const ret = new Object();
2334
+ return addHeapObject(ret);
2335
+ }
2336
+ export function __wbg_new_from_slice_b5ea43e23f6008c0(arg0, arg1) {
2337
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
2338
+ return addHeapObject(ret);
2339
+ }
2340
+ export function __wbg_new_with_u8_clamped_array_and_sh_fe957411824b5158() { return handleError(function (arg0, arg1, arg2, arg3) {
2341
+ const ret = new ImageData(getClampedArrayU8FromWasm0(arg0, arg1), arg2 >>> 0, arg3 >>> 0);
2342
+ return addHeapObject(ret);
2343
+ }, arguments); }
2344
+ export function __wbg_next_0340c4ae324393c3() { return handleError(function (arg0) {
2345
+ const ret = getObject(arg0).next();
2346
+ return addHeapObject(ret);
2347
+ }, arguments); }
2348
+ export function __wbg_next_7646edaa39458ef7(arg0) {
2349
+ const ret = getObject(arg0).next;
2350
+ return addHeapObject(ret);
2351
+ }
2352
+ export function __wbg_now_a9b7df1cbee90986() {
2353
+ const ret = Date.now();
2354
+ return ret;
2355
+ }
2356
+ export function __wbg_prototypesetcall_a6b02eb00b0f4ce2(arg0, arg1, arg2) {
2357
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
2358
+ }
2359
+ export function __wbg_putImageData_c810e62ea70e761d() { return handleError(function (arg0, arg1, arg2, arg3) {
2360
+ getObject(arg0).putImageData(getObject(arg1), arg2, arg3);
2361
+ }, arguments); }
2362
+ export function __wbg_putImageData_cb4de9afd58963be() { return handleError(function (arg0, arg1, arg2, arg3) {
2363
+ getObject(arg0).putImageData(getObject(arg1), arg2, arg3);
2364
+ }, arguments); }
2365
+ export function __wbg_set_022bee52d0b05b19() { return handleError(function (arg0, arg1, arg2) {
2366
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
2367
+ return ret;
2368
+ }, arguments); }
2369
+ export function __wbg_set_3bf1de9fab0cd644(arg0, arg1, arg2) {
2370
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
2371
+ }
2372
+ export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
2373
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
2374
+ }
2375
+ export function __wbg_set_f071dbb3bd088e0e(arg0, arg1, arg2) {
2376
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
2377
+ }
2378
+ export function __wbg_set_fde2cec06c23692b(arg0, arg1, arg2) {
2379
+ const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
2380
+ return addHeapObject(ret);
2381
+ }
2382
+ export function __wbg_set_height_24d07d982f176ac6(arg0, arg1) {
2383
+ getObject(arg0).height = arg1 >>> 0;
2384
+ }
2385
+ export function __wbg_set_height_be9b2b920bd68401(arg0, arg1) {
2386
+ getObject(arg0).height = arg1 >>> 0;
2387
+ }
2388
+ export function __wbg_set_width_5cda41d4d06a14dd(arg0, arg1) {
2389
+ getObject(arg0).width = arg1 >>> 0;
2390
+ }
2391
+ export function __wbg_set_width_adc925bca9c5351a(arg0, arg1) {
2392
+ getObject(arg0).width = arg1 >>> 0;
2393
+ }
2394
+ export function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) {
2395
+ const ret = getObject(arg1).stack;
2396
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2397
+ const len1 = WASM_VECTOR_LEN;
2398
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2399
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2400
+ }
2401
+ export function __wbg_value_ee3a06f4579184fa(arg0) {
2402
+ const ret = getObject(arg0).value;
2403
+ return addHeapObject(ret);
2404
+ }
2405
+ export function __wbindgen_cast_0000000000000001(arg0) {
2406
+ // Cast intrinsic for `F64 -> Externref`.
2407
+ const ret = arg0;
2408
+ return addHeapObject(ret);
2409
+ }
2410
+ export function __wbindgen_cast_0000000000000002(arg0) {
2411
+ // Cast intrinsic for `I64 -> Externref`.
2412
+ const ret = arg0;
2413
+ return addHeapObject(ret);
2414
+ }
2415
+ export function __wbindgen_cast_0000000000000003(arg0, arg1) {
2416
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
2417
+ const ret = getArrayU8FromWasm0(arg0, arg1);
2418
+ return addHeapObject(ret);
2419
+ }
2420
+ export function __wbindgen_cast_0000000000000004(arg0, arg1) {
2421
+ // Cast intrinsic for `Ref(String) -> Externref`.
2422
+ const ret = getStringFromWasm0(arg0, arg1);
2423
+ return addHeapObject(ret);
2424
+ }
2425
+ export function __wbindgen_cast_0000000000000005(arg0) {
2426
+ // Cast intrinsic for `U64 -> Externref`.
2427
+ const ret = BigInt.asUintN(64, arg0);
2428
+ return addHeapObject(ret);
2429
+ }
2430
+ export function __wbindgen_object_clone_ref(arg0) {
2431
+ const ret = getObject(arg0);
2432
+ return addHeapObject(ret);
2433
+ }
2434
+ export function __wbindgen_object_drop_ref(arg0) {
2435
+ takeObject(arg0);
2436
+ }
2437
+ const DocumentFinalization = (typeof FinalizationRegistry === 'undefined')
2438
+ ? { register: () => {}, unregister: () => {} }
2439
+ : new FinalizationRegistry(ptr => wasm.__wbg_document_free(ptr >>> 0, 1));
2440
+ const LiveSessionFinalization = (typeof FinalizationRegistry === 'undefined')
2441
+ ? { register: () => {}, unregister: () => {} }
2442
+ : new FinalizationRegistry(ptr => wasm.__wbg_livesession_free(ptr >>> 0, 1));
2443
+ const QuillFinalization = (typeof FinalizationRegistry === 'undefined')
2444
+ ? { register: () => {}, unregister: () => {} }
2445
+ : new FinalizationRegistry(ptr => wasm.__wbg_quill_free(ptr >>> 0, 1));
2446
+ const QuillmarkFinalization = (typeof FinalizationRegistry === 'undefined')
2447
+ ? { register: () => {}, unregister: () => {} }
2448
+ : new FinalizationRegistry(ptr => wasm.__wbg_quillmark_free(ptr >>> 0, 1));
2449
+
2450
+ function addHeapObject(obj) {
2451
+ if (heap_next === heap.length) heap.push(heap.length + 1);
2452
+ const idx = heap_next;
2453
+ heap_next = heap[idx];
2454
+
2455
+ heap[idx] = obj;
2456
+ return idx;
2457
+ }
2458
+
2459
+ function _assertClass(instance, klass) {
2460
+ if (!(instance instanceof klass)) {
2461
+ throw new Error(`expected instance of ${klass.name}`);
2462
+ }
2463
+ }
2464
+
2465
+ function debugString(val) {
2466
+ // primitive types
2467
+ const type = typeof val;
2468
+ if (type == 'number' || type == 'boolean' || val == null) {
2469
+ return `${val}`;
2470
+ }
2471
+ if (type == 'string') {
2472
+ return `"${val}"`;
2473
+ }
2474
+ if (type == 'symbol') {
2475
+ const description = val.description;
2476
+ if (description == null) {
2477
+ return 'Symbol';
2478
+ } else {
2479
+ return `Symbol(${description})`;
2480
+ }
2481
+ }
2482
+ if (type == 'function') {
2483
+ const name = val.name;
2484
+ if (typeof name == 'string' && name.length > 0) {
2485
+ return `Function(${name})`;
2486
+ } else {
2487
+ return 'Function';
2488
+ }
2489
+ }
2490
+ // objects
2491
+ if (Array.isArray(val)) {
2492
+ const length = val.length;
2493
+ let debug = '[';
2494
+ if (length > 0) {
2495
+ debug += debugString(val[0]);
2496
+ }
2497
+ for(let i = 1; i < length; i++) {
2498
+ debug += ', ' + debugString(val[i]);
2499
+ }
2500
+ debug += ']';
2501
+ return debug;
2502
+ }
2503
+ // Test for built-in
2504
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
2505
+ let className;
2506
+ if (builtInMatches && builtInMatches.length > 1) {
2507
+ className = builtInMatches[1];
2508
+ } else {
2509
+ // Failed to match the standard '[object ClassName]'
2510
+ return toString.call(val);
2511
+ }
2512
+ if (className == 'Object') {
2513
+ // we're a user defined class or Object
2514
+ // JSON.stringify avoids problems with cycles, and is generally much
2515
+ // easier than looping through ownProperties of `val`.
2516
+ try {
2517
+ return 'Object(' + JSON.stringify(val) + ')';
2518
+ } catch (_) {
2519
+ return 'Object';
2520
+ }
2521
+ }
2522
+ // errors
2523
+ if (val instanceof Error) {
2524
+ return `${val.name}: ${val.message}\n${val.stack}`;
2525
+ }
2526
+ // TODO we could test for more things here, like `Set`s and `Map`s.
2527
+ return className;
2528
+ }
2529
+
2530
+ function dropObject(idx) {
2531
+ if (idx < 1028) return;
2532
+ heap[idx] = heap_next;
2533
+ heap_next = idx;
2534
+ }
2535
+
2536
+ function getArrayU8FromWasm0(ptr, len) {
2537
+ ptr = ptr >>> 0;
2538
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
2539
+ }
2540
+
2541
+ function getClampedArrayU8FromWasm0(ptr, len) {
2542
+ ptr = ptr >>> 0;
2543
+ return getUint8ClampedArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
2544
+ }
2545
+
2546
+ let cachedDataViewMemory0 = null;
2547
+ function getDataViewMemory0() {
2548
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
2549
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
2550
+ }
2551
+ return cachedDataViewMemory0;
2552
+ }
2553
+
2554
+ function getStringFromWasm0(ptr, len) {
2555
+ ptr = ptr >>> 0;
2556
+ return decodeText(ptr, len);
2557
+ }
2558
+
2559
+ let cachedUint8ArrayMemory0 = null;
2560
+ function getUint8ArrayMemory0() {
2561
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
2562
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
2563
+ }
2564
+ return cachedUint8ArrayMemory0;
2565
+ }
2566
+
2567
+ let cachedUint8ClampedArrayMemory0 = null;
2568
+ function getUint8ClampedArrayMemory0() {
2569
+ if (cachedUint8ClampedArrayMemory0 === null || cachedUint8ClampedArrayMemory0.byteLength === 0) {
2570
+ cachedUint8ClampedArrayMemory0 = new Uint8ClampedArray(wasm.memory.buffer);
2571
+ }
2572
+ return cachedUint8ClampedArrayMemory0;
2573
+ }
2574
+
2575
+ function getObject(idx) { return heap[idx]; }
2576
+
2577
+ function handleError(f, args) {
2578
+ try {
2579
+ return f.apply(this, args);
2580
+ } catch (e) {
2581
+ wasm.__wbindgen_export3(addHeapObject(e));
2582
+ }
2583
+ }
2584
+
2585
+ let heap = new Array(1024).fill(undefined);
2586
+ heap.push(undefined, null, true, false);
2587
+
2588
+ let heap_next = heap.length;
2589
+
2590
+ function isLikeNone(x) {
2591
+ return x === undefined || x === null;
2592
+ }
2593
+
2594
+ function passStringToWasm0(arg, malloc, realloc) {
2595
+ if (realloc === undefined) {
2596
+ const buf = cachedTextEncoder.encode(arg);
2597
+ const ptr = malloc(buf.length, 1) >>> 0;
2598
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
2599
+ WASM_VECTOR_LEN = buf.length;
2600
+ return ptr;
2601
+ }
2602
+
2603
+ let len = arg.length;
2604
+ let ptr = malloc(len, 1) >>> 0;
2605
+
2606
+ const mem = getUint8ArrayMemory0();
2607
+
2608
+ let offset = 0;
2609
+
2610
+ for (; offset < len; offset++) {
2611
+ const code = arg.charCodeAt(offset);
2612
+ if (code > 0x7F) break;
2613
+ mem[ptr + offset] = code;
2614
+ }
2615
+ if (offset !== len) {
2616
+ if (offset !== 0) {
2617
+ arg = arg.slice(offset);
2618
+ }
2619
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
2620
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
2621
+ const ret = cachedTextEncoder.encodeInto(arg, view);
2622
+
2623
+ offset += ret.written;
2624
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
2625
+ }
2626
+
2627
+ WASM_VECTOR_LEN = offset;
2628
+ return ptr;
2629
+ }
2630
+
2631
+ function takeObject(idx) {
2632
+ const ret = getObject(idx);
2633
+ dropObject(idx);
2634
+ return ret;
2635
+ }
2636
+
2637
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
2638
+ cachedTextDecoder.decode();
2639
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
2640
+ let numBytesDecoded = 0;
2641
+ function decodeText(ptr, len) {
2642
+ numBytesDecoded += len;
2643
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
2644
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
2645
+ cachedTextDecoder.decode();
2646
+ numBytesDecoded = len;
2647
+ }
2648
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
2649
+ }
2650
+
2651
+ const cachedTextEncoder = new TextEncoder();
2652
+
2653
+ if (!('encodeInto' in cachedTextEncoder)) {
2654
+ cachedTextEncoder.encodeInto = function (arg, view) {
2655
+ const buf = cachedTextEncoder.encode(arg);
2656
+ view.set(buf);
2657
+ return {
2658
+ read: arg.length,
2659
+ written: buf.length
2660
+ };
2661
+ };
2662
+ }
2663
+
2664
+ let WASM_VECTOR_LEN = 0;
2665
+
2666
+
2667
+ let wasm;
2668
+ export function __wbg_set_wasm(val) {
2669
+ wasm = val;
2670
+ }