@quillmark/wasm 0.92.1 → 0.95.1

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,2654 @@
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 place it — the ABI under `writer.addCard`.
25
+ * `at` picks the position: absent appends, a number inserts at that index
26
+ * (`0..=cards.length`), so a positioned typed insert is one atomic call
27
+ * rather than `addCard` + `moveCard`. Fuses `makeCard` + typed commit +
28
+ * insertion transactionally: the card is committed in full before it joins
29
+ * the document, so a rejected field (or an invalid kind, body, or
30
+ * out-of-range `at`) leaves the document untouched. Field errors throw the
31
+ * same per-field diagnostic bundle as [`commitFields`](Self::commit_fields),
32
+ * including an `[EditError::UnknownField]` per undeclared name; an invalid
33
+ * kind or body, or an out-of-range position, throws a single-entry bundle
34
+ * keyed `$kind` / `$body`.
35
+ * @param {Quill} quill
36
+ * @param {string} kind
37
+ * @param {Record<string, unknown>} [fields]
38
+ * @param {string} [body]
39
+ * @param {number} [at]
40
+ */
41
+ _addCard(quill, kind, fields, body, at) {
42
+ try {
43
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
44
+ _assertClass(quill, Quill);
45
+ const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
46
+ const len0 = WASM_VECTOR_LEN;
47
+ var ptr1 = isLikeNone(body) ? 0 : passStringToWasm0(body, wasm.__wbindgen_export, wasm.__wbindgen_export2);
48
+ var len1 = WASM_VECTOR_LEN;
49
+ wasm.document__addCard(retptr, this.__wbg_ptr, quill.__wbg_ptr, ptr0, len0, isLikeNone(fields) ? 0 : addHeapObject(fields), ptr1, len1, isLikeNone(at) ? 0x100000001 : (at) >>> 0);
50
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
51
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
52
+ if (r1) {
53
+ throw takeObject(r0);
54
+ }
55
+ } finally {
56
+ wasm.__wbindgen_add_to_stack_pointer(16);
57
+ }
58
+ }
59
+ /**
60
+ * Typed field write at `addr`, resolving the field's schema `type` from
61
+ * `quill` — the stable ABI under the runtime `writer.set` / `writer.card(i).set`.
62
+ * The one write verb for **every** field type (richtext, scalar, array,
63
+ * object); the schema carries the `inline` constraint, so no type token or
64
+ * flag is passed. A richtext-typed field stores the canonical content, so
65
+ * identity marks (anchors, island ids) and content-only marks (e.g.
66
+ * `underline`) live on it and survive compiles and the storage DTO. Values
67
+ * use the encoding the seam already speaks: a content object or markdown
68
+ * string for richtext, a scalar/array/object otherwise.
69
+ *
70
+ * A bare string is `Addr` shorthand for `{ field }`; `{ card, field }`
71
+ * targets a composable card (its `$kind` resolves the schema). A body
72
+ * address throws — a body has no field schema; write it with `writer.setBody`
73
+ * / `revise`. A field declared in the schema is strict-committed (a mismatch
74
+ * throws now, not at render); a name the schema does not declare throws
75
+ * `[EditError::UnknownField]` rather than falling to the opaque store — on
76
+ * the typed path it is a typo. Use [`storeField`](Document::store_field) for
77
+ * opaque storage. Also throws `[EditError::FieldConform]` /
78
+ * `[EditError::FieldRichtextDecode]` / `[EditError::FieldRichtextNotInline]`
79
+ * on a typed mismatch, `[EditError::InvalidFieldName]` on a malformed name,
80
+ * and `[EditError::IndexOutOfRange]` on an out-of-range card.
81
+ *
82
+ * The `quill` handle is passed per call because a `Document` carries only a
83
+ * `$quill` reference, not the resolved schema.
84
+ * @param {Quill} quill
85
+ * @param {Addr | string} addr
86
+ * @param {any} value
87
+ */
88
+ _commitField(quill, addr, value) {
89
+ try {
90
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
91
+ _assertClass(quill, Quill);
92
+ wasm.document__commitField(retptr, this.__wbg_ptr, quill.__wbg_ptr, addHeapObject(addr), addHeapObject(value));
93
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
94
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
95
+ if (r1) {
96
+ throw takeObject(r0);
97
+ }
98
+ } finally {
99
+ wasm.__wbindgen_add_to_stack_pointer(16);
100
+ }
101
+ }
102
+ /**
103
+ * Batched twin of [`commitField`](Document::commit_field): typed-commit
104
+ * several fields on the card `addr` targets atomically, resolving each
105
+ * field's schema `type` from `quill`. `addr` is a **card address**
106
+ * (`{ card }`, absent = main; a present `field` throws). All-or-nothing with
107
+ * the same per-field-diagnostic error contract as
108
+ * [`storeFields`](Document::store_fields) — nothing is applied on error and
109
+ * the thrown error's `diagnostics` carry one entry per offending field,
110
+ * including an `[EditError::UnknownField]` for any name the schema does not
111
+ * declare, so a whole-form submit sees every typo in one pass. Throws on an
112
+ * out-of-range card.
113
+ * @param {Quill} quill
114
+ * @param {CardAddr} addr
115
+ * @param {Record<string, unknown>} fields
116
+ */
117
+ _commitFields(quill, addr, fields) {
118
+ try {
119
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
120
+ _assertClass(quill, Quill);
121
+ wasm.document__commitFields(retptr, this.__wbg_ptr, quill.__wbg_ptr, addHeapObject(addr), addHeapObject(fields));
122
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
123
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
124
+ if (r1) {
125
+ throw takeObject(r0);
126
+ }
127
+ } finally {
128
+ wasm.__wbindgen_add_to_stack_pointer(16);
129
+ }
130
+ }
131
+ /**
132
+ * Revise the richtext field at `addr` from markdown, typed *and*
133
+ * anchor-preserving — the ABI under `writer.reviseField`. Resolves the
134
+ * field's schema from `quill` (main card, or the addressed card's `$kind`)
135
+ * and defers to [`TypedWriter::revise_field`](quillmark_core::TypedWriter::revise_field):
136
+ * surviving anchors rebase (as [`revise`](Self::revise)), then the diffed
137
+ * result is schema-conformed, so a `richtext(inline)` field rejects a
138
+ * multi-block result with `[EditError::FieldRichtextNotInline]`. Returns the
139
+ * text [`Delta`].
140
+ *
141
+ * `addr` must name a field (a bare string is `{ field }`); a body address
142
+ * throws (a body carries no field schema — use [`revise`](Self::revise)). A
143
+ * name the schema does not declare throws `[EditError::UnknownField]`. Throws
144
+ * on an out-of-range card. Hidden from the `.d.ts`; the visible verb is
145
+ * `writer.reviseField` in the runtime layer.
146
+ * @param {Quill} quill
147
+ * @param {Addr | string} addr
148
+ * @param {string} markdown
149
+ * @returns {Delta}
150
+ */
151
+ _reviseField(quill, addr, markdown) {
152
+ try {
153
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
154
+ _assertClass(quill, Quill);
155
+ const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
156
+ const len0 = WASM_VECTOR_LEN;
157
+ wasm.document__reviseField(retptr, this.__wbg_ptr, quill.__wbg_ptr, addHeapObject(addr), ptr0, len0);
158
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
159
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
160
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
161
+ if (r2) {
162
+ throw takeObject(r1);
163
+ }
164
+ return takeObject(r0);
165
+ } finally {
166
+ wasm.__wbindgen_add_to_stack_pointer(16);
167
+ }
168
+ }
169
+ /**
170
+ * Interpreted read at `addr`, resolving the field's declared `type` from
171
+ * `quill` — the stable ABI under the runtime `view.get` / `view.card(i).get`.
172
+ * The schema-plane twin of the quill-free [`get`](Self::get): a `richtext`
173
+ * field returns its markdown projection, every other declared type its
174
+ * canonical value verbatim, so a consumer holding the quill reads by field
175
+ * meaning rather than by wire shape.
176
+ *
177
+ * A bare string is `Addr` shorthand for `{ field }`; `{ card, field }`
178
+ * targets a composable card (its `$kind` resolves the schema). Returns
179
+ * `undefined` for an **absent** field. An absent `addr.field` reads the body
180
+ * markdown — quill-free, mirroring [`getMarkdown`](Self::get_markdown), since
181
+ * a body's type is a format fact, not a schema fact. A name the schema does
182
+ * not declare throws `[EditError::UnknownField]` (the authority `getMarkdown`
183
+ * lacks — there an unknown name reads back `undefined`); a `richtext` field
184
+ * holding a value that does not decode throws `[EditError::FieldRichtextDecode]`;
185
+ * an out-of-range `addr.card` throws.
186
+ *
187
+ * The `quill` handle is passed per call because a `Document` carries only a
188
+ * `$quill` reference, not the resolved schema.
189
+ * @param {Quill} quill
190
+ * @param {Addr | string} addr
191
+ * @returns {unknown}
192
+ */
193
+ _viewGet(quill, addr) {
194
+ try {
195
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
196
+ _assertClass(quill, Quill);
197
+ wasm.document__viewGet(retptr, this.__wbg_ptr, quill.__wbg_ptr, addHeapObject(addr));
198
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
199
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
200
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
201
+ if (r2) {
202
+ throw takeObject(r1);
203
+ }
204
+ return takeObject(r0);
205
+ } finally {
206
+ wasm.__wbindgen_add_to_stack_pointer(16);
207
+ }
208
+ }
209
+ /**
210
+ * **Apply** a committed content edit `bundle` (`{ delta?, lineOps?, markOps? }`)
211
+ * at `addr` — the editor splice: text delta first, then line ops, then mark
212
+ * ops (mark ranges in final-text coordinates), each all-or-nothing. An absent
213
+ * `addr.field` targets the body, an absent `addr.card` the main card.
214
+ *
215
+ * Throws on an out-of-range card, a field that is not richtext, a malformed
216
+ * bundle, or an op that applies out of bounds (the value is unchanged on a
217
+ * failed apply).
218
+ * @param {Addr | string} addr
219
+ * @param {ChangeBundle} bundle
220
+ */
221
+ applyChange(addr, bundle) {
222
+ try {
223
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
224
+ wasm.document_applyChange(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(bundle));
225
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
226
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
227
+ if (r1) {
228
+ throw takeObject(r0);
229
+ }
230
+ } finally {
231
+ wasm.__wbindgen_add_to_stack_pointer(16);
232
+ }
233
+ }
234
+ /**
235
+ * Authoring-ergonomics header introducing a blueprint to an LLM/MCP
236
+ * consumer for the given `quillName`. Re-exposes core's canonical text for
237
+ * JS consumers; any surface that draws from the same core source stays
238
+ * uniform.
239
+ * @param {string} quill_name
240
+ * @returns {string}
241
+ */
242
+ static blueprintInstruction(quill_name) {
243
+ let deferred2_0;
244
+ let deferred2_1;
245
+ try {
246
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
247
+ const ptr0 = passStringToWasm0(quill_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
248
+ const len0 = WASM_VECTOR_LEN;
249
+ wasm.document_blueprintInstruction(retptr, ptr0, len0);
250
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
251
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
252
+ deferred2_0 = r0;
253
+ deferred2_1 = r1;
254
+ return getStringFromWasm0(r0, r1);
255
+ } finally {
256
+ wasm.__wbindgen_add_to_stack_pointer(16);
257
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
258
+ }
259
+ }
260
+ /**
261
+ * A single composable card by index — the whole `Card`, the card-indexed
262
+ * twin of the [`main`](Self::main) getter, so reading one card need not
263
+ * materialize every card via [`cards`](Self::cards). An out-of-range
264
+ * `index` throws `[EditError::IndexOutOfRange]`, matching the card write
265
+ * verbs.
266
+ * @param {number} index
267
+ * @returns {Card}
268
+ */
269
+ card(index) {
270
+ try {
271
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
272
+ wasm.document_card(retptr, this.__wbg_ptr, index);
273
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
274
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
275
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
276
+ if (r2) {
277
+ throw takeObject(r1);
278
+ }
279
+ return takeObject(r0);
280
+ } finally {
281
+ wasm.__wbindgen_add_to_stack_pointer(16);
282
+ }
283
+ }
284
+ /**
285
+ * Number of composable cards (excludes the main card). O(1).
286
+ * @returns {number}
287
+ */
288
+ get cardCount() {
289
+ const ret = wasm.document_cardCount(this.__wbg_ptr);
290
+ return ret >>> 0;
291
+ }
292
+ /**
293
+ * The index of the first composable card whose `$id` equals `id`, or
294
+ * `undefined` when none carries it. Resolves the canonical durable address
295
+ * without a hand-rolled scan over [`cards`](Self::cards); `$id` is
296
+ * non-unique by design, so the first match wins.
297
+ * @param {string} id
298
+ * @returns {number | undefined}
299
+ */
300
+ cardIndexById(id) {
301
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
302
+ const len0 = WASM_VECTOR_LEN;
303
+ const ret = wasm.document_cardIndexById(this.__wbg_ptr, ptr0, len0);
304
+ return takeObject(ret);
305
+ }
306
+ /**
307
+ * @returns {Card[]}
308
+ */
309
+ get cards() {
310
+ try {
311
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
312
+ wasm.document_cards(retptr, this.__wbg_ptr);
313
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
314
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
315
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
316
+ if (r2) {
317
+ throw takeObject(r1);
318
+ }
319
+ return takeObject(r0);
320
+ } finally {
321
+ wasm.__wbindgen_add_to_stack_pointer(16);
322
+ }
323
+ }
324
+ /**
325
+ * @returns {Document}
326
+ */
327
+ clone() {
328
+ const ret = wasm.document_clone(this.__wbg_ptr);
329
+ return Document.__wrap(ret);
330
+ }
331
+ /**
332
+ * Schema version this build writes via [`toJson`](Document::to_json).
333
+ * Tracks the `Document` model version (not the running crate version):
334
+ * the tag advances only when the wire format changes, not on every release.
335
+ * @returns {string}
336
+ */
337
+ static currentSchemaVersion() {
338
+ let deferred1_0;
339
+ let deferred1_1;
340
+ try {
341
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
342
+ wasm.document_currentSchemaVersion(retptr);
343
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
344
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
345
+ deferred1_0 = r0;
346
+ deferred1_1 = r1;
347
+ return getStringFromWasm0(r0, r1);
348
+ } finally {
349
+ wasm.__wbindgen_add_to_stack_pointer(16);
350
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
351
+ }
352
+ }
353
+ /**
354
+ * Structural equality (parse-time `warnings` excluded). Use to debounce
355
+ * upstream prop updates instead of re-parsing on every keystroke.
356
+ * @param {Document} other
357
+ * @returns {boolean}
358
+ */
359
+ equals(other) {
360
+ _assertClass(other, Document);
361
+ const ret = wasm.document_equals(this.__wbg_ptr, other.__wbg_ptr);
362
+ return ret !== 0;
363
+ }
364
+ /**
365
+ * Render a Diagnostic as the canonical pretty-printed text (core's
366
+ * `Diagnostic::fmt_pretty`). Single source of truth so a Diagnostic looks
367
+ * identical no matter which consumer surfaces it.
368
+ * @param {Diagnostic} diag
369
+ * @returns {string}
370
+ */
371
+ static formatDiagnostic(diag) {
372
+ let deferred1_0;
373
+ let deferred1_1;
374
+ try {
375
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
376
+ wasm.document_formatDiagnostic(retptr, addHeapObject(diag));
377
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
378
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
379
+ deferred1_0 = r0;
380
+ deferred1_1 = r1;
381
+ return getStringFromWasm0(r0, r1);
382
+ } finally {
383
+ wasm.__wbindgen_add_to_stack_pointer(16);
384
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
385
+ }
386
+ }
387
+ /**
388
+ * Authoring-format rules for the card-yaml markdown surface. The canonical
389
+ * text is core's (`quillmark_core::document::FORMAT_RULES`), re-exposed
390
+ * here for JS consumers so it matches any other surface that draws from the
391
+ * same source. Read once at startup and cache; the value never changes
392
+ * between calls.
393
+ * @returns {string}
394
+ */
395
+ static formatRules() {
396
+ let deferred1_0;
397
+ let deferred1_1;
398
+ try {
399
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
400
+ wasm.document_formatRules(retptr);
401
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
402
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
403
+ deferred1_0 = r0;
404
+ deferred1_1 = r1;
405
+ return getStringFromWasm0(r0, r1);
406
+ } finally {
407
+ wasm.__wbindgen_add_to_stack_pointer(16);
408
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
409
+ }
410
+ }
411
+ /**
412
+ * Reconstruct a `Document` from a versioned storage DTO string produced
413
+ * by [`toJson`](Document::to_json). Unknown `schema` tags are rejected.
414
+ * The result carries no parse-time warnings (`.warnings` is always empty).
415
+ *
416
+ * Throws if `json` is not a valid storage DTO (malformed JSON, unknown
417
+ * `schema`, missing fields, or unparseable quill reference).
418
+ * @param {string} json
419
+ * @returns {Document}
420
+ */
421
+ static fromJson(json) {
422
+ try {
423
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
424
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
425
+ const len0 = WASM_VECTOR_LEN;
426
+ wasm.document_fromJson(retptr, ptr0, len0);
427
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
428
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
429
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
430
+ if (r2) {
431
+ throw takeObject(r1);
432
+ }
433
+ return Document.__wrap(r0);
434
+ } finally {
435
+ wasm.__wbindgen_add_to_stack_pointer(16);
436
+ }
437
+ }
438
+ /**
439
+ * Parse markdown into a typed Document. Throws on parse errors.
440
+ * @param {string} markdown
441
+ * @returns {Document}
442
+ */
443
+ static fromMarkdown(markdown) {
444
+ try {
445
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
446
+ const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
447
+ const len0 = WASM_VECTOR_LEN;
448
+ wasm.document_fromMarkdown(retptr, ptr0, len0);
449
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
450
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
451
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
452
+ if (r2) {
453
+ throw takeObject(r1);
454
+ }
455
+ return Document.__wrap(r0);
456
+ } finally {
457
+ wasm.__wbindgen_add_to_stack_pointer(16);
458
+ }
459
+ }
460
+ /**
461
+ * Read the value at `addr` — the raw stored payload value of a field (a
462
+ * content object for a richtext field, a scalar/array/object otherwise), or
463
+ * the **body content** when `addr.field` is absent. A bare string is `Addr`
464
+ * shorthand for `{ field }`. Reads are total over the field axis: an absent
465
+ * field is `undefined`; only an out-of-range `addr.card` throws
466
+ * `[EditError::IndexOutOfRange]`. Reads need no schema, so they live on
467
+ * `Document`, not the typed writer; for the markdown projection of a
468
+ * richtext value use [`getMarkdown`](Self::get_markdown).
469
+ * @param {Addr | string} addr
470
+ * @returns {unknown}
471
+ */
472
+ get(addr) {
473
+ try {
474
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
475
+ wasm.document_get(retptr, this.__wbg_ptr, addHeapObject(addr));
476
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
477
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
478
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
479
+ if (r2) {
480
+ throw takeObject(r1);
481
+ }
482
+ return takeObject(r0);
483
+ } finally {
484
+ wasm.__wbindgen_add_to_stack_pointer(16);
485
+ }
486
+ }
487
+ /**
488
+ * The whole `$ext` map at `addr` (a card address, absent `card` = main), or
489
+ * `undefined` when the card carries none. The fine-grained `$ext` read —
490
+ * your own state without serializing the whole card. Throws on a present
491
+ * `field` (a card address takes only `card`) or an out-of-range card.
492
+ * @param {CardAddr} [addr]
493
+ * @returns {Record<string, unknown> | undefined}
494
+ */
495
+ getExt(addr) {
496
+ try {
497
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
498
+ wasm.document_getExt(retptr, this.__wbg_ptr, addHeapObject(addr));
499
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
500
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
501
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
502
+ if (r2) {
503
+ throw takeObject(r1);
504
+ }
505
+ return takeObject(r0);
506
+ } finally {
507
+ wasm.__wbindgen_add_to_stack_pointer(16);
508
+ }
509
+ }
510
+ /**
511
+ * The value stored under `$ext[ns]` at `addr` (a card address, absent `card`
512
+ * = main), or `undefined`. The namespace-scoped `$ext` read — your own slot
513
+ * without a whole-card serialize, and non-destructive (unlike
514
+ * `removeExtNamespace`). Throws on a present `field` or an out-of-range card.
515
+ * @param {CardAddr} addr
516
+ * @param {string} ns
517
+ * @returns {unknown}
518
+ */
519
+ getExtNamespace(addr, ns) {
520
+ try {
521
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
522
+ const ptr0 = passStringToWasm0(ns, wasm.__wbindgen_export, wasm.__wbindgen_export2);
523
+ const len0 = WASM_VECTOR_LEN;
524
+ wasm.document_getExtNamespace(retptr, this.__wbg_ptr, addHeapObject(addr), ptr0, len0);
525
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
526
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
527
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
528
+ if (r2) {
529
+ throw takeObject(r1);
530
+ }
531
+ return takeObject(r0);
532
+ } finally {
533
+ wasm.__wbindgen_add_to_stack_pointer(16);
534
+ }
535
+ }
536
+ /**
537
+ * The **body** markdown projection — the main body, or a composable card's
538
+ * body (`{ card }`) — the on-demand, lossy export (content-only marks do not
539
+ * survive markdown). A body's type is a format fact, not a schema fact, so
540
+ * this read stays quill-free; a body is never absent.
541
+ *
542
+ * `addr` is an optional **card address** (`{ card }`, absent = main). A
543
+ * present `field` throws — a field's markdown is read through the
544
+ * schema-plane `quill.view(doc).get(field)`, which interprets by declared
545
+ * type (#978). An out-of-range `addr.card` throws.
546
+ * @param {CardAddr} [addr]
547
+ * @returns {string}
548
+ */
549
+ getMarkdown(addr) {
550
+ try {
551
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
552
+ wasm.document_getMarkdown(retptr, this.__wbg_ptr, addHeapObject(addr));
553
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
554
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
555
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
556
+ if (r2) {
557
+ throw takeObject(r1);
558
+ }
559
+ return takeObject(r0);
560
+ } finally {
561
+ wasm.__wbindgen_add_to_stack_pointer(16);
562
+ }
563
+ }
564
+ /**
565
+ * Insert a card — the single insertion verb: `at` absent appends, a number
566
+ * inserts at that index (must be in `0..=cards.length`). Accepts a
567
+ * `CardInput` — a card read back (`cards` / `removeCard` / `quill.seedCard`),
568
+ * a [`makeCard`](Document::make_card) result, or a bare `{ kind, body }`
569
+ * (every returned `Card` is a valid `CardInput`). Throws if `card.kind` is
570
+ * not a valid kind name, or if `at` is out of range.
571
+ * @param {CardInput} card
572
+ * @param {number} [at]
573
+ */
574
+ insertCard(card, at) {
575
+ try {
576
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
577
+ wasm.document_insertCard(retptr, this.__wbg_ptr, addHeapObject(card), isLikeNone(at) ? 0x100000001 : (at) >>> 0);
578
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
579
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
580
+ if (r1) {
581
+ throw takeObject(r0);
582
+ }
583
+ } finally {
584
+ wasm.__wbindgen_add_to_stack_pointer(16);
585
+ }
586
+ }
587
+ /**
588
+ * **Install** a richtext value at `addr` — **value semantics**, content only.
589
+ * Stores exactly `rt` (a canonical `Content` content object); the identity
590
+ * anchors of any previous value are gone. An absent `addr.field` targets the
591
+ * body, an absent `addr.card` the main card. For "here's new markdown," use
592
+ * [`revise`](Document::revise); the cold-import path is spelled at the call
593
+ * site as `install(addr, importMarkdown(md))`, so anchor loss is visible in
594
+ * source.
595
+ *
596
+ * Throws on an out-of-range card, a malformed field name, or an `rt` that is
597
+ * not a canonical content object.
598
+ * @param {Addr | string} addr
599
+ * @param {Content} rt
600
+ */
601
+ install(addr, rt) {
602
+ try {
603
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
604
+ wasm.document_install(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(rt));
605
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
606
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
607
+ if (r1) {
608
+ throw takeObject(r0);
609
+ }
610
+ } finally {
611
+ wasm.__wbindgen_add_to_stack_pointer(16);
612
+ }
613
+ }
614
+ /**
615
+ * Whether the field at `addr` is marked `!must_fill`. A bare string is `Addr`
616
+ * shorthand for `{ field }`. `false` for an absent field (truthful — it isn't
617
+ * marked) and for a body address (a body is never a fill). Only an
618
+ * out-of-range `addr.card` throws.
619
+ * @param {Addr | string} addr
620
+ * @returns {boolean}
621
+ */
622
+ isFill(addr) {
623
+ try {
624
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
625
+ wasm.document_isFill(retptr, this.__wbg_ptr, addHeapObject(addr));
626
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
627
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
628
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
629
+ if (r2) {
630
+ throw takeObject(r1);
631
+ }
632
+ return r0 !== 0;
633
+ } finally {
634
+ wasm.__wbindgen_add_to_stack_pointer(16);
635
+ }
636
+ }
637
+ /**
638
+ * Replace this document's contents **in place** from a versioned storage
639
+ * DTO string — the mutating twin of the static
640
+ * [`fromJson`](Document::from_json) constructor. Parse-time `warnings` are
641
+ * cleared. Throws (leaving the document unchanged) on an invalid DTO.
642
+ *
643
+ * The cross-WASM-memory `Document` bridge: mutate a document on a
644
+ * backend-memory clone, then write the mutated state back into the caller's
645
+ * canonical document with this — the one way to update a live handle across
646
+ * the linear-memory seam without the caller re-binding its variable.
647
+ * @param {string} json
648
+ */
649
+ loadJson(json) {
650
+ try {
651
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
652
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
653
+ const len0 = WASM_VECTOR_LEN;
654
+ wasm.document_loadJson(retptr, this.__wbg_ptr, ptr0, len0);
655
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
656
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
657
+ if (r1) {
658
+ throw takeObject(r0);
659
+ }
660
+ } finally {
661
+ wasm.__wbindgen_add_to_stack_pointer(16);
662
+ }
663
+ }
664
+ /**
665
+ * The document's main (entry) card. Allocates and serializes on each
666
+ * call — cache locally if read in a hot loop.
667
+ * @returns {Card}
668
+ */
669
+ get main() {
670
+ try {
671
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
672
+ wasm.document_main(retptr, this.__wbg_ptr);
673
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
674
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
675
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
676
+ if (r2) {
677
+ throw takeObject(r1);
678
+ }
679
+ return takeObject(r0);
680
+ } finally {
681
+ wasm.__wbindgen_add_to_stack_pointer(16);
682
+ }
683
+ }
684
+ /**
685
+ * Build a fresh `Card` from a kind and a flat field map — the ergonomic
686
+ * constructor for `insertCard`. `fields` is an optional
687
+ * `Record<string, unknown>` (each entry becomes a card field, in
688
+ * insertion order); `body` defaults to `""`. Kind validity is checked by
689
+ * `insertCard`, not here.
690
+ * @param {string} kind
691
+ * @param {Record<string, unknown>} [fields]
692
+ * @param {string} [body]
693
+ * @returns {Card}
694
+ */
695
+ static makeCard(kind, fields, body) {
696
+ try {
697
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
698
+ const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
699
+ const len0 = WASM_VECTOR_LEN;
700
+ var ptr1 = isLikeNone(body) ? 0 : passStringToWasm0(body, wasm.__wbindgen_export, wasm.__wbindgen_export2);
701
+ var len1 = WASM_VECTOR_LEN;
702
+ wasm.document_makeCard(retptr, ptr0, len0, isLikeNone(fields) ? 0 : addHeapObject(fields), ptr1, len1);
703
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
704
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
705
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
706
+ if (r2) {
707
+ throw takeObject(r1);
708
+ }
709
+ return takeObject(r0);
710
+ } finally {
711
+ wasm.__wbindgen_add_to_stack_pointer(16);
712
+ }
713
+ }
714
+ /**
715
+ * Move the card at `from` to position `to`. `from == to` is a no-op.
716
+ * @param {number} from
717
+ * @param {number} to
718
+ */
719
+ moveCard(from, to) {
720
+ try {
721
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
722
+ wasm.document_moveCard(retptr, this.__wbg_ptr, from, to);
723
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
724
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
725
+ if (r1) {
726
+ throw takeObject(r0);
727
+ }
728
+ } finally {
729
+ wasm.__wbindgen_add_to_stack_pointer(16);
730
+ }
731
+ }
732
+ /**
733
+ * `new Document(quillRef)` — a blank document: a main card carrying only
734
+ * `$quill`, an empty body, and no composable cards. The programmatic
735
+ * blank canvas: absent fields resolve at render time (`default`, else
736
+ * type-empty zero), so nothing the caller did not set reaches the
737
+ * output. For an example-filled starter use `Quill.seedDocument()`.
738
+ * Throws on an invalid quill reference. Mirrors Python `Document(quill_ref)`.
739
+ * @param {string} quill_ref
740
+ */
741
+ constructor(quill_ref) {
742
+ try {
743
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
744
+ const ptr0 = passStringToWasm0(quill_ref, wasm.__wbindgen_export, wasm.__wbindgen_export2);
745
+ const len0 = WASM_VECTOR_LEN;
746
+ wasm.document_new(retptr, ptr0, len0);
747
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
748
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
749
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
750
+ if (r2) {
751
+ throw takeObject(r1);
752
+ }
753
+ this.__wbg_ptr = r0 >>> 0;
754
+ DocumentFinalization.register(this, this.__wbg_ptr, this);
755
+ return this;
756
+ } finally {
757
+ wasm.__wbindgen_add_to_stack_pointer(16);
758
+ }
759
+ }
760
+ /**
761
+ * @returns {string}
762
+ */
763
+ get quillRef() {
764
+ let deferred1_0;
765
+ let deferred1_1;
766
+ try {
767
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
768
+ wasm.document_quillRef(retptr, this.__wbg_ptr);
769
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
770
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
771
+ deferred1_0 = r0;
772
+ deferred1_1 = r1;
773
+ return getStringFromWasm0(r0, r1);
774
+ } finally {
775
+ wasm.__wbindgen_add_to_stack_pointer(16);
776
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
777
+ }
778
+ }
779
+ /**
780
+ * The canonical `$quill` reference grammar as author-facing text. Core is
781
+ * the single source of truth: drive schema `describe` and validation
782
+ * messages from this instead of re-stating the rule — it matches the
783
+ * `hint` on `parse::invalid_quill_reference`. Cache it; the value never
784
+ * changes.
785
+ * @returns {string}
786
+ */
787
+ static quillRefHint() {
788
+ let deferred1_0;
789
+ let deferred1_1;
790
+ try {
791
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
792
+ wasm.document_quillRefHint(retptr);
793
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
794
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
795
+ deferred1_0 = r0;
796
+ deferred1_1 = r1;
797
+ return getStringFromWasm0(r0, r1);
798
+ } finally {
799
+ wasm.__wbindgen_add_to_stack_pointer(16);
800
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
801
+ }
802
+ }
803
+ /**
804
+ * @param {number} index
805
+ * @returns {Card | undefined}
806
+ */
807
+ removeCard(index) {
808
+ try {
809
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
810
+ wasm.document_removeCard(retptr, this.__wbg_ptr, index);
811
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
812
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
813
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
814
+ if (r2) {
815
+ throw takeObject(r1);
816
+ }
817
+ return takeObject(r0);
818
+ } finally {
819
+ wasm.__wbindgen_add_to_stack_pointer(16);
820
+ }
821
+ }
822
+ /**
823
+ * Remove the `$ext` map on the card `addr` targets *entirely*, returning the
824
+ * previous map or `undefined` — a blunt escape hatch that discards every
825
+ * namespace at once (prefer `removeExtNamespace`). `addr` is a card address
826
+ * (absent = main). Throws on a present `field` or an out-of-range card.
827
+ * @param {CardAddr} [addr]
828
+ * @returns {Record<string, unknown> | undefined}
829
+ */
830
+ removeExt(addr) {
831
+ try {
832
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
833
+ wasm.document_removeExt(retptr, this.__wbg_ptr, addHeapObject(addr));
834
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
835
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
836
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
837
+ if (r2) {
838
+ throw takeObject(r1);
839
+ }
840
+ return takeObject(r0);
841
+ } finally {
842
+ wasm.__wbindgen_add_to_stack_pointer(16);
843
+ }
844
+ }
845
+ /**
846
+ * Remove `$ext[ns]` on the card `addr` targets, returning its value or
847
+ * `undefined`; drops `$ext` once empty. `addr` is a card address (absent =
848
+ * main). Preserves sibling namespaces. Throws on a present `field` or an
849
+ * out-of-range card.
850
+ * @param {CardAddr} addr
851
+ * @param {string} ns
852
+ * @returns {any}
853
+ */
854
+ removeExtNamespace(addr, ns) {
855
+ try {
856
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
857
+ const ptr0 = passStringToWasm0(ns, wasm.__wbindgen_export, wasm.__wbindgen_export2);
858
+ const len0 = WASM_VECTOR_LEN;
859
+ wasm.document_removeExtNamespace(retptr, this.__wbg_ptr, addHeapObject(addr), ptr0, len0);
860
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
861
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
862
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
863
+ if (r2) {
864
+ throw takeObject(r1);
865
+ }
866
+ return takeObject(r0);
867
+ } finally {
868
+ wasm.__wbindgen_add_to_stack_pointer(16);
869
+ }
870
+ }
871
+ /**
872
+ * Remove a field at `addr`, returning the removed value or `undefined`. A
873
+ * bare string is `Addr` shorthand for `{ field }`. One `remove` verb serves
874
+ * every write lane. A body address throws; throws on an out-of-range card or
875
+ * a malformed name.
876
+ * @param {Addr | string} addr
877
+ * @returns {any}
878
+ */
879
+ removeField(addr) {
880
+ try {
881
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
882
+ wasm.document_removeField(retptr, this.__wbg_ptr, addHeapObject(addr));
883
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
884
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
885
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
886
+ if (r2) {
887
+ throw takeObject(r1);
888
+ }
889
+ return takeObject(r0);
890
+ } finally {
891
+ wasm.__wbindgen_add_to_stack_pointer(16);
892
+ }
893
+ }
894
+ /**
895
+ * Remove `cardKind` from the main card's `$seed` map, returning its
896
+ * overlay or `undefined`; drops `$seed` entirely once empty. Sibling kinds
897
+ * survive. `$seed` is main-only, so this takes no address.
898
+ * @param {string} card_kind
899
+ * @returns {any}
900
+ */
901
+ removeSeedNamespace(card_kind) {
902
+ try {
903
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
904
+ const ptr0 = passStringToWasm0(card_kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
905
+ const len0 = WASM_VECTOR_LEN;
906
+ wasm.document_removeSeedNamespace(retptr, this.__wbg_ptr, ptr0, len0);
907
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
908
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
909
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
910
+ if (r2) {
911
+ throw takeObject(r1);
912
+ }
913
+ return takeObject(r0);
914
+ } finally {
915
+ wasm.__wbindgen_add_to_stack_pointer(16);
916
+ }
917
+ }
918
+ /**
919
+ * **Revise** the richtext value at `addr` from a markdown string — **edit
920
+ * semantics**, the default write path, returning the text [`Delta`]. Imports
921
+ * the markdown, diffs it against the current value, rebases surviving
922
+ * identity anchors, and returns the change an editor bridge maps its own
923
+ * positions through (`mapPos`). An absent `addr.field` targets the body, an
924
+ * absent `addr.card` the main card; an absent field cold-imports from empty.
925
+ *
926
+ * Throws on an out-of-range card, a malformed field name, a present
927
+ * non-content field value, or an over-nested markdown input.
928
+ * @param {Addr | string} addr
929
+ * @param {string} markdown
930
+ * @returns {Delta}
931
+ */
932
+ revise(addr, markdown) {
933
+ try {
934
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
935
+ const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
936
+ const len0 = WASM_VECTOR_LEN;
937
+ wasm.document_revise(retptr, this.__wbg_ptr, addHeapObject(addr), ptr0, len0);
938
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
939
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
940
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
941
+ if (r2) {
942
+ throw takeObject(r1);
943
+ }
944
+ return takeObject(r0);
945
+ } finally {
946
+ wasm.__wbindgen_add_to_stack_pointer(16);
947
+ }
948
+ }
949
+ /**
950
+ * Read the `schema` version tag from a raw storage DTO string without a
951
+ * full parse, or `undefined`. Returns unknown future versions as-is —
952
+ * useful to distinguish "build too old" from "payload corrupt" when
953
+ * `fromJson` throws.
954
+ * @param {string} json
955
+ * @returns {string | undefined}
956
+ */
957
+ static schemaVersionOf(json) {
958
+ try {
959
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
960
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
961
+ const len0 = WASM_VECTOR_LEN;
962
+ wasm.document_schemaVersionOf(retptr, ptr0, len0);
963
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
964
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
965
+ let v2;
966
+ if (r0 !== 0) {
967
+ v2 = getStringFromWasm0(r0, r1).slice();
968
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
969
+ }
970
+ return v2;
971
+ } finally {
972
+ wasm.__wbindgen_add_to_stack_pointer(16);
973
+ }
974
+ }
975
+ /**
976
+ * The main card's `$seed` overlay object for `kind` (the `$seed[kind]`
977
+ * entry), or `undefined` when absent. The cheap read that feeds
978
+ * `quill.seedCard(kind, overlay)` without serializing the whole main card
979
+ * via [`main`](Self::main) to fish out one key — and it keeps `seedCard`
980
+ * pure: the quill still never reads the document.
981
+ * @param {string} kind
982
+ * @returns {Record<string, unknown> | undefined}
983
+ */
984
+ seedOverlay(kind) {
985
+ try {
986
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
987
+ const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
988
+ const len0 = WASM_VECTOR_LEN;
989
+ wasm.document_seedOverlay(retptr, this.__wbg_ptr, ptr0, len0);
990
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
991
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
992
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
993
+ if (r2) {
994
+ throw takeObject(r1);
995
+ }
996
+ return takeObject(r0);
997
+ } finally {
998
+ wasm.__wbindgen_add_to_stack_pointer(16);
999
+ }
1000
+ }
1001
+ /**
1002
+ * Replace the kind of the card at `index`. Payload and body are untouched;
1003
+ * schema-aware migration is the caller's responsibility.
1004
+ * Throws if `index` is out of range or `newKind` is invalid.
1005
+ * @param {number} index
1006
+ * @param {string} new_kind
1007
+ */
1008
+ setCardKind(index, new_kind) {
1009
+ try {
1010
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1011
+ const ptr0 = passStringToWasm0(new_kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1012
+ const len0 = WASM_VECTOR_LEN;
1013
+ wasm.document_setCardKind(retptr, this.__wbg_ptr, index, ptr0, len0);
1014
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1015
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1016
+ if (r1) {
1017
+ throw takeObject(r0);
1018
+ }
1019
+ } finally {
1020
+ wasm.__wbindgen_add_to_stack_pointer(16);
1021
+ }
1022
+ }
1023
+ /**
1024
+ * Replace the QUILL reference string. Throws if `ref_str` is invalid.
1025
+ * @param {string} ref_str
1026
+ */
1027
+ setQuillRef(ref_str) {
1028
+ try {
1029
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1030
+ const ptr0 = passStringToWasm0(ref_str, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1031
+ const len0 = WASM_VECTOR_LEN;
1032
+ wasm.document_setQuillRef(retptr, this.__wbg_ptr, ptr0, len0);
1033
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1034
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1035
+ if (r1) {
1036
+ throw takeObject(r0);
1037
+ }
1038
+ } finally {
1039
+ wasm.__wbindgen_add_to_stack_pointer(16);
1040
+ }
1041
+ }
1042
+ /**
1043
+ * Replace the opaque `$ext` map on the card `addr` targets (a card address,
1044
+ * absent `card` = main). `value` must be a plain object. `$ext` carries
1045
+ * out-of-band consumer state and never reaches the rendered output; pass
1046
+ * `{}` for an explicit empty `$ext`. Quill-free and verbatim — an opaque
1047
+ * `store` verb. Throws on a present `field` or an out-of-range card.
1048
+ * @param {CardAddr} addr
1049
+ * @param {any} value
1050
+ */
1051
+ storeExt(addr, value) {
1052
+ try {
1053
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1054
+ wasm.document_storeExt(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(value));
1055
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1056
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1057
+ if (r1) {
1058
+ throw takeObject(r0);
1059
+ }
1060
+ } finally {
1061
+ wasm.__wbindgen_add_to_stack_pointer(16);
1062
+ }
1063
+ }
1064
+ /**
1065
+ * Merge `value` into `$ext[ns]` on the card `addr` targets, preserving
1066
+ * sibling namespaces — the recommended `$ext` write. `addr` is a card
1067
+ * address (absent = main). Quill-free and verbatim — an opaque `store` verb.
1068
+ * Throws on a present `field` or an out-of-range card.
1069
+ * @param {CardAddr} addr
1070
+ * @param {string} ns
1071
+ * @param {any} value
1072
+ */
1073
+ storeExtNamespace(addr, ns, value) {
1074
+ try {
1075
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1076
+ const ptr0 = passStringToWasm0(ns, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1077
+ const len0 = WASM_VECTOR_LEN;
1078
+ wasm.document_storeExtNamespace(retptr, this.__wbg_ptr, addHeapObject(addr), ptr0, len0, addHeapObject(value));
1079
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1080
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1081
+ if (r1) {
1082
+ throw takeObject(r0);
1083
+ }
1084
+ } finally {
1085
+ wasm.__wbindgen_add_to_stack_pointer(16);
1086
+ }
1087
+ }
1088
+ /**
1089
+ * Store a field verbatim at `addr` — the opaque store (**store** = verbatim,
1090
+ * coercion deferred to render; the typed write is
1091
+ * [`commitField`](Document::commit_field)). A bare string is `Addr`
1092
+ * shorthand for `{ field }`, so `doc.storeField("qty", 3)` reads as written;
1093
+ * `{ card: 2, field: "qty" }` targets a composable card. Clears any
1094
+ * `!must_fill` marker. A body address (no `field`) throws — a body is never
1095
+ * opaque; write it with `revise` / `install` / `writer.setBody`. Throws on
1096
+ * an out-of-range card or a malformed name.
1097
+ * @param {Addr | string} addr
1098
+ * @param {any} value
1099
+ */
1100
+ storeField(addr, value) {
1101
+ try {
1102
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1103
+ wasm.document_storeField(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(value));
1104
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1105
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1106
+ if (r1) {
1107
+ throw takeObject(r0);
1108
+ }
1109
+ } finally {
1110
+ wasm.__wbindgen_add_to_stack_pointer(16);
1111
+ }
1112
+ }
1113
+ /**
1114
+ * Store several fields verbatim and atomically on the card `addr` targets —
1115
+ * the opaque store's batch. `addr` is a **card address** (`{ card }`, absent
1116
+ * = main); a present `field` throws. The batch verb takes the address first
1117
+ * and is never shape-overloaded, because `card` is a legal field name:
1118
+ * `storeFields({}, fields)` is the main card, `storeFields({ card: 2 },
1119
+ * fields)` a composable one — never ambiguous with "set field `card`".
1120
+ * Nothing is applied on error; the thrown error's `diagnostics` carry one
1121
+ * entry per offending field. Throws on an out-of-range card.
1122
+ * @param {CardAddr} addr
1123
+ * @param {Record<string, unknown>} fields
1124
+ */
1125
+ storeFields(addr, fields) {
1126
+ try {
1127
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1128
+ wasm.document_storeFields(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(fields));
1129
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1130
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1131
+ if (r1) {
1132
+ throw takeObject(r0);
1133
+ }
1134
+ } finally {
1135
+ wasm.__wbindgen_add_to_stack_pointer(16);
1136
+ }
1137
+ }
1138
+ /**
1139
+ * Store a field verbatim at `addr` and mark it `!must_fill` — the opaque
1140
+ * store's fill variant, card-capable (a bare string or `{ field }` for main,
1141
+ * `{ card, field }` for a composable card). A body address throws. Same
1142
+ * validation as [`storeField`](Document::store_field).
1143
+ * @param {Addr | string} addr
1144
+ * @param {any} value
1145
+ */
1146
+ storeFill(addr, value) {
1147
+ try {
1148
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1149
+ wasm.document_storeFill(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(value));
1150
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1151
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1152
+ if (r1) {
1153
+ throw takeObject(r0);
1154
+ }
1155
+ } finally {
1156
+ wasm.__wbindgen_add_to_stack_pointer(16);
1157
+ }
1158
+ }
1159
+ /**
1160
+ * Merge a card-kind's seed `overlay` into the **main** card's `$seed` map
1161
+ * under `cardKind`, preserving sibling kinds — `$seed` lives on the main
1162
+ * card by model, so this takes no address. Sets the starting values new
1163
+ * cards of that kind spawn with. Quill-free and verbatim — an opaque `store`
1164
+ * verb. Throws if `overlay` cannot be serialized or nests too deep.
1165
+ * @param {string} card_kind
1166
+ * @param {any} overlay
1167
+ */
1168
+ storeSeedNamespace(card_kind, overlay) {
1169
+ try {
1170
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1171
+ const ptr0 = passStringToWasm0(card_kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1172
+ const len0 = WASM_VECTOR_LEN;
1173
+ wasm.document_storeSeedNamespace(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(overlay));
1174
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1175
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1176
+ if (r1) {
1177
+ throw takeObject(r0);
1178
+ }
1179
+ } finally {
1180
+ wasm.__wbindgen_add_to_stack_pointer(16);
1181
+ }
1182
+ }
1183
+ /**
1184
+ * Serialize this document to a versioned storage DTO string.
1185
+ *
1186
+ * Prefer this over `toMarkdown` for persistence across restarts or crate
1187
+ * upgrades — the wire format is frozen per `schema` version. Parse-time
1188
+ * `warnings` are excluded from the DTO.
1189
+ *
1190
+ * Output is **byte-deterministic** within a `schema` version: equal
1191
+ * documents produce byte-equal output, safe for content-hash use cases.
1192
+ * @returns {string}
1193
+ */
1194
+ toJson() {
1195
+ let deferred1_0;
1196
+ let deferred1_1;
1197
+ try {
1198
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1199
+ wasm.document_toJson(retptr, this.__wbg_ptr);
1200
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1201
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1202
+ deferred1_0 = r0;
1203
+ deferred1_1 = r1;
1204
+ return getStringFromWasm0(r0, r1);
1205
+ } finally {
1206
+ wasm.__wbindgen_add_to_stack_pointer(16);
1207
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1208
+ }
1209
+ }
1210
+ /**
1211
+ * Emit canonical Quillmark Markdown. Round-trip safe: re-parsing the
1212
+ * result produces a `Document` equal to `self` by value and by type.
1213
+ * @returns {string}
1214
+ */
1215
+ toMarkdown() {
1216
+ let deferred1_0;
1217
+ let deferred1_1;
1218
+ try {
1219
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1220
+ wasm.document_toMarkdown(retptr, this.__wbg_ptr);
1221
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1222
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1223
+ deferred1_0 = r0;
1224
+ deferred1_1 = r1;
1225
+ return getStringFromWasm0(r0, r1);
1226
+ } finally {
1227
+ wasm.__wbindgen_add_to_stack_pointer(16);
1228
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1229
+ }
1230
+ }
1231
+ /**
1232
+ * Like [`fromJson`](Document::from_json) but returns `undefined` instead
1233
+ * of throwing when `json` is not a valid storage DTO — use to
1234
+ * discriminate format without exceptions as control flow.
1235
+ * `undefined` means "not a storage DTO"; `fromMarkdown` still throws on
1236
+ * genuinely malformed markdown.
1237
+ * @param {string} json
1238
+ * @returns {Document | undefined}
1239
+ */
1240
+ static tryFromJson(json) {
1241
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1242
+ const len0 = WASM_VECTOR_LEN;
1243
+ const ret = wasm.document_tryFromJson(ptr0, len0);
1244
+ return ret === 0 ? undefined : Document.__wrap(ret);
1245
+ }
1246
+ /**
1247
+ * @returns {Diagnostic[]}
1248
+ */
1249
+ get warnings() {
1250
+ try {
1251
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1252
+ wasm.document_warnings(retptr, this.__wbg_ptr);
1253
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1254
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1255
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1256
+ if (r2) {
1257
+ throw takeObject(r1);
1258
+ }
1259
+ return takeObject(r0);
1260
+ } finally {
1261
+ wasm.__wbindgen_add_to_stack_pointer(16);
1262
+ }
1263
+ }
1264
+ }
1265
+ if (Symbol.dispose) Document.prototype[Symbol.dispose] = Document.prototype.free;
1266
+
1267
+ /**
1268
+ * Live render session: reads (`render`, `paint`, `pageSize`, `regions`,
1269
+ * `fieldAt`, `positionAt`, `locate`) serve the current compile. `apply(doc)`
1270
+ * recompiles a whole document in place, transactionally (on throw every read
1271
+ * keeps serving the last-good compile). Geometry reads reflect the current
1272
+ * compile; anchoring a caret across edits is the editor's job — re-read
1273
+ * geometry after each committed `apply`.
1274
+ *
1275
+ * **Empty documents.** A zero-page document yields a valid session
1276
+ * (`pageCount === 0`); `paint(ctx, 0)` or `pageSize(0)` throws with
1277
+ * `"page index 0 out of range (pageCount=0)"`. Branch on `pageCount === 0`
1278
+ * rather than catching the error.
1279
+ */
1280
+ export class LiveSession {
1281
+ static __wrap(ptr) {
1282
+ ptr = ptr >>> 0;
1283
+ const obj = Object.create(LiveSession.prototype);
1284
+ obj.__wbg_ptr = ptr;
1285
+ LiveSessionFinalization.register(obj, obj.__wbg_ptr, obj);
1286
+ return obj;
1287
+ }
1288
+ __destroy_into_raw() {
1289
+ const ptr = this.__wbg_ptr;
1290
+ this.__wbg_ptr = 0;
1291
+ LiveSessionFinalization.unregister(this);
1292
+ return ptr;
1293
+ }
1294
+ free() {
1295
+ const ptr = this.__destroy_into_raw();
1296
+ wasm.__wbg_livesession_free(ptr, 0);
1297
+ }
1298
+ /**
1299
+ * Recompile the session against `doc` — the edit verb of a live preview.
1300
+ * The document is compiled through the same schema pipeline as `open`
1301
+ * (same quill), then applied transactionally: on throw every read
1302
+ * (`render`, `paint`, `pageSize`, `regions`, `fieldAt`) keeps serving the last-good
1303
+ * compile, and the session recovers on the next successful `apply`. On
1304
+ * success reads serve the new compile; repaint `dirtyPages ∩ visible`.
1305
+ * @param {Document} doc
1306
+ * @returns {ChangeSet}
1307
+ */
1308
+ apply(doc) {
1309
+ try {
1310
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1311
+ _assertClass(doc, Document);
1312
+ wasm.livesession_apply(retptr, this.__wbg_ptr, doc.__wbg_ptr);
1313
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1314
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1315
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1316
+ if (r2) {
1317
+ throw takeObject(r1);
1318
+ }
1319
+ return takeObject(r0);
1320
+ } finally {
1321
+ wasm.__wbindgen_add_to_stack_pointer(16);
1322
+ }
1323
+ }
1324
+ /**
1325
+ * The backend that produced this session (e.g. `"typst"`).
1326
+ * @returns {string}
1327
+ */
1328
+ get backendId() {
1329
+ let deferred1_0;
1330
+ let deferred1_1;
1331
+ try {
1332
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1333
+ wasm.livesession_backendId(retptr, this.__wbg_ptr);
1334
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1335
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1336
+ deferred1_0 = r0;
1337
+ deferred1_1 = r1;
1338
+ return getStringFromWasm0(r0, r1);
1339
+ } finally {
1340
+ wasm.__wbindgen_add_to_stack_pointer(16);
1341
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1342
+ }
1343
+ }
1344
+ /**
1345
+ * The schema field whose content is under a point on `page` — the
1346
+ * forward (click → field) direction: hit-test a click against the
1347
+ * compiled document and get back the field address to focus in the
1348
+ * editor, or `undefined` off any field's ink. `x`/`y` are PDF points
1349
+ * with a **bottom-left** origin, the same space as `FieldRegion.rect` —
1350
+ * from a canvas click, invert the overlay transform documented on
1351
+ * `FieldRegion`: `x = clickPx.x / renderScale`,
1352
+ * `y = pageHeightPt - clickPx.y / renderScale`. Unlike `regions()`,
1353
+ * *every* placement answers, not just the first.
1354
+ * @param {number} page
1355
+ * @param {number} x
1356
+ * @param {number} y
1357
+ * @returns {string | undefined}
1358
+ */
1359
+ fieldAt(page, x, y) {
1360
+ try {
1361
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1362
+ wasm.livesession_fieldAt(retptr, this.__wbg_ptr, page, x, y);
1363
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1364
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1365
+ let v1;
1366
+ if (r0 !== 0) {
1367
+ v1 = getStringFromWasm0(r0, r1).slice();
1368
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
1369
+ }
1370
+ return v1;
1371
+ } finally {
1372
+ wasm.__wbindgen_add_to_stack_pointer(16);
1373
+ }
1374
+ }
1375
+ /**
1376
+ * The whole-field highlight boxes for `field` — one union rect per page,
1377
+ * over the field's `span`-bearing content segments. The convenience that
1378
+ * owns the union `regions()` leaves derived: it keeps `regions()` the
1379
+ * low-level disjoint truth (#829) and folds the span-filter + per-page
1380
+ * union here, so a "highlight the focused field" consumer stops
1381
+ * reimplementing it. **Content only** — a field placed solely as a scalar
1382
+ * reference or a bound widget carries no `span` and returns `[]`; its box
1383
+ * is a single `regions()` rect. Reflects the current compile, like
1384
+ * `regions()`.
1385
+ * @param {string} field
1386
+ * @returns {FieldRegion[]}
1387
+ */
1388
+ fieldBoxes(field) {
1389
+ try {
1390
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1391
+ const ptr0 = passStringToWasm0(field, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1392
+ const len0 = WASM_VECTOR_LEN;
1393
+ wasm.livesession_fieldBoxes(retptr, this.__wbg_ptr, ptr0, len0);
1394
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1395
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1396
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1397
+ if (r2) {
1398
+ throw takeObject(r1);
1399
+ }
1400
+ return takeObject(r0);
1401
+ } finally {
1402
+ wasm.__wbindgen_add_to_stack_pointer(16);
1403
+ }
1404
+ }
1405
+ /**
1406
+ * A content position → **caret rect** — the reverse of `positionAt`: given
1407
+ * a field and a USV offset into its `Content`, return the box (in the
1408
+ * same bottom-left PDF-point space as `FieldRegion.rect`) to draw a caret
1409
+ * at, its `span` collapsed to `[pos, pos]`; `undefined` when the field
1410
+ * places no tracked content or the offset maps to no drawn glyph.
1411
+ * @param {string} field
1412
+ * @param {number} pos
1413
+ * @returns {FieldRegion | undefined}
1414
+ */
1415
+ locate(field, pos) {
1416
+ const ptr0 = passStringToWasm0(field, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1417
+ const len0 = WASM_VECTOR_LEN;
1418
+ const ret = wasm.livesession_locate(this.__wbg_ptr, ptr0, len0, pos);
1419
+ return takeObject(ret);
1420
+ }
1421
+ /**
1422
+ * @returns {number}
1423
+ */
1424
+ get pageCount() {
1425
+ const ret = wasm.livesession_pageCount(this.__wbg_ptr);
1426
+ return ret >>> 0;
1427
+ }
1428
+ /**
1429
+ * Page dimensions in points (1 pt = 1/72 inch).
1430
+ * Throws if the backend has no canvas painter or `page` is out of range.
1431
+ * @param {number} page
1432
+ * @returns {PageSize}
1433
+ */
1434
+ pageSize(page) {
1435
+ try {
1436
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1437
+ wasm.livesession_pageSize(retptr, this.__wbg_ptr, page);
1438
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1439
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1440
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1441
+ if (r2) {
1442
+ throw takeObject(r1);
1443
+ }
1444
+ return takeObject(r0);
1445
+ } finally {
1446
+ wasm.__wbindgen_add_to_stack_pointer(16);
1447
+ }
1448
+ }
1449
+ /**
1450
+ * Paint `page` into a `CanvasRenderingContext2D` or
1451
+ * `OffscreenCanvasRenderingContext2D`. The painter owns
1452
+ * `canvas.width`/`height` (no `clearRect` needed); consumers own
1453
+ * `canvas.style.*`. If `layoutScale * densityScale` exceeds 16384 px
1454
+ * per side, `densityScale` is clamped — `PaintResult.clamped` reports it and
1455
+ * `PaintResult.effectiveDensityScale` carries the density actually applied.
1456
+ *
1457
+ * `put_image_data` writes the whole backing store, bypassing the 2D
1458
+ * context's transform, `globalAlpha`, and clip: the painter owns the entire
1459
+ * canvas, so each visible page needs its own `` — you cannot composite
1460
+ * two pages, a sub-rect, or a context transform through this call.
1461
+ *
1462
+ * Throws if the backend has no canvas painter, `page` is out of range,
1463
+ * `ctx` is the wrong type, or either scale is non-finite or `<= 0`.
1464
+ * @param {CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D} ctx
1465
+ * @param {number} page
1466
+ * @param {PaintOptions | undefined} opts
1467
+ * @returns {PaintResult}
1468
+ */
1469
+ paint(ctx, page, opts) {
1470
+ try {
1471
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1472
+ wasm.livesession_paint(retptr, this.__wbg_ptr, addHeapObject(ctx), page, addHeapObject(opts));
1473
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1474
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1475
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1476
+ if (r2) {
1477
+ throw takeObject(r1);
1478
+ }
1479
+ return takeObject(r0);
1480
+ } finally {
1481
+ wasm.__wbindgen_add_to_stack_pointer(16);
1482
+ }
1483
+ }
1484
+ /**
1485
+ * A point → **content position** — the fine-grained click direction:
1486
+ * hit-test a point and get back the field *and* a USV offset into its
1487
+ * `Content` (for placing a caret or mapping a selection into the content
1488
+ * model), or `undefined` off all content ink. `x`/`y` are PDF points,
1489
+ * bottom-left origin — the same space as `fieldAt`. The offset is
1490
+ * cluster-exact and degrades to the containing segment's start on
1491
+ * origin-less ink (list markers, a code fence's interior). See
1492
+ * `ContentHit`.
1493
+ * @param {number} page
1494
+ * @param {number} x
1495
+ * @param {number} y
1496
+ * @returns {ContentHit | undefined}
1497
+ */
1498
+ positionAt(page, x, y) {
1499
+ const ret = wasm.livesession_positionAt(this.__wbg_ptr, page, x, y);
1500
+ return takeObject(ret);
1501
+ }
1502
+ /**
1503
+ * Schema-field geometry for this compiled session — each content field's
1504
+ * **first placement** (one region per page it touches) plus widget and
1505
+ * scalar-reference-site regions, keyed on the quill schema field path; a
1506
+ * field may still appear more than once (group by `field`, see
1507
+ * `FieldRegion`). A session-level query: no render, no byte artifact. An
1508
+ * interactive preview reads it to scroll to / highlight the focused
1509
+ * field over a `paint`-ed canvas; the click direction is `fieldAt`.
1510
+ * Empty for backends that place no schema fields.
1511
+ * @returns {FieldRegion[]}
1512
+ */
1513
+ regions() {
1514
+ try {
1515
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1516
+ wasm.livesession_regions(retptr, this.__wbg_ptr);
1517
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1518
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1519
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1520
+ if (r2) {
1521
+ throw takeObject(r1);
1522
+ }
1523
+ return takeObject(r0);
1524
+ } finally {
1525
+ wasm.__wbindgen_add_to_stack_pointer(16);
1526
+ }
1527
+ }
1528
+ /**
1529
+ * @param {RenderOptions | null} [opts]
1530
+ * @returns {RenderResult}
1531
+ */
1532
+ render(opts) {
1533
+ try {
1534
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1535
+ wasm.livesession_render(retptr, this.__wbg_ptr, isLikeNone(opts) ? 0 : addHeapObject(opts));
1536
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1537
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1538
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1539
+ if (r2) {
1540
+ throw takeObject(r1);
1541
+ }
1542
+ return takeObject(r0);
1543
+ } finally {
1544
+ wasm.__wbindgen_add_to_stack_pointer(16);
1545
+ }
1546
+ }
1547
+ /**
1548
+ * `true` iff `paint` and `pageSize` will succeed for this session. Derived
1549
+ * from the session's canvas seam, so it reflects exactly what `paint` will
1550
+ * do — no separately captured flag.
1551
+ * @returns {boolean}
1552
+ */
1553
+ get supportsCanvas() {
1554
+ const ret = wasm.livesession_supportsCanvas(this.__wbg_ptr);
1555
+ return ret !== 0;
1556
+ }
1557
+ /**
1558
+ * Non-fatal diagnostics of the session's **current compile** (e.g. Typst
1559
+ * font fallback) — set at open and refreshed by each committed `apply`;
1560
+ * a failed apply keeps the last-good compile's warnings. Also appended
1561
+ * to `RenderResult.warnings` on each `render()` call.
1562
+ * @returns {Diagnostic[]}
1563
+ */
1564
+ get warnings() {
1565
+ try {
1566
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1567
+ wasm.livesession_warnings(retptr, this.__wbg_ptr);
1568
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1569
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1570
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1571
+ if (r2) {
1572
+ throw takeObject(r1);
1573
+ }
1574
+ return takeObject(r0);
1575
+ } finally {
1576
+ wasm.__wbindgen_add_to_stack_pointer(16);
1577
+ }
1578
+ }
1579
+ }
1580
+ if (Symbol.dispose) LiveSession.prototype[Symbol.dispose] = LiveSession.prototype.free;
1581
+
1582
+ export class Quill {
1583
+ static __wrap(ptr) {
1584
+ ptr = ptr >>> 0;
1585
+ const obj = Object.create(Quill.prototype);
1586
+ obj.__wbg_ptr = ptr;
1587
+ QuillFinalization.register(obj, obj.__wbg_ptr, obj);
1588
+ return obj;
1589
+ }
1590
+ __destroy_into_raw() {
1591
+ const ptr = this.__wbg_ptr;
1592
+ this.__wbg_ptr = 0;
1593
+ QuillFinalization.unregister(this);
1594
+ return ptr;
1595
+ }
1596
+ free() {
1597
+ const ptr = this.__destroy_into_raw();
1598
+ wasm.__wbg_quill_free(ptr, 0);
1599
+ }
1600
+ /**
1601
+ * The *declared* backend identifier (`config.backend`, e.g. `"typst"`).
1602
+ * Intent, not a resolved capability — capability (`supportedFormats` /
1603
+ * `supportsCanvas`) is read from the engine.
1604
+ * @returns {string}
1605
+ */
1606
+ get backendId() {
1607
+ let deferred1_0;
1608
+ let deferred1_1;
1609
+ try {
1610
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1611
+ wasm.quill_backendId(retptr, this.__wbg_ptr);
1612
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1613
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1614
+ deferred1_0 = r0;
1615
+ deferred1_1 = r1;
1616
+ return getStringFromWasm0(r0, r1);
1617
+ } finally {
1618
+ wasm.__wbindgen_add_to_stack_pointer(16);
1619
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1620
+ }
1621
+ }
1622
+ /**
1623
+ * @returns {string}
1624
+ */
1625
+ get blueprint() {
1626
+ let deferred1_0;
1627
+ let deferred1_1;
1628
+ try {
1629
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1630
+ wasm.quill_blueprint(retptr, this.__wbg_ptr);
1631
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1632
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1633
+ deferred1_0 = r0;
1634
+ deferred1_1 = r1;
1635
+ return getStringFromWasm0(r0, r1);
1636
+ } finally {
1637
+ wasm.__wbindgen_add_to_stack_pointer(16);
1638
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1639
+ }
1640
+ }
1641
+ /**
1642
+ * Build a quill from a file tree. Pure — no backend, no engine; the
1643
+ * declared backend is resolved later, at render time.
1644
+ *
1645
+ * Accepts either a `Map<string, Uint8Array>` or a plain object
1646
+ * (`Record<string, Uint8Array>`). Plain objects are walked via
1647
+ * `Object.entries` at the boundary; the Rust side sees a single
1648
+ * canonical shape.
1649
+ * @param {Map<string, Uint8Array>} tree
1650
+ * @returns {Quill}
1651
+ */
1652
+ static fromTree(tree) {
1653
+ try {
1654
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1655
+ wasm.quill_fromTree(retptr, addHeapObject(tree));
1656
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1657
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1658
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1659
+ if (r2) {
1660
+ throw takeObject(r1);
1661
+ }
1662
+ return Quill.__wrap(r0);
1663
+ } finally {
1664
+ wasm.__wbindgen_add_to_stack_pointer(16);
1665
+ }
1666
+ }
1667
+ /**
1668
+ * Identity snapshot of the `quill:` section of `Quill.yaml` plus any extra
1669
+ * `quill:` keys. Pure config — the backend's output formats are a
1670
+ * resolved-backend capability read from the engine
1671
+ * (`Quillmark.supportedFormats`), not part of this snapshot.
1672
+ * @returns {QuillMetadata}
1673
+ */
1674
+ get metadata() {
1675
+ try {
1676
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1677
+ wasm.quill_metadata(retptr, this.__wbg_ptr);
1678
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1679
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1680
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1681
+ if (r2) {
1682
+ throw takeObject(r1);
1683
+ }
1684
+ return takeObject(r0);
1685
+ } finally {
1686
+ wasm.__wbindgen_add_to_stack_pointer(16);
1687
+ }
1688
+ }
1689
+ /**
1690
+ * Document schema for the quill: the user-fillable fields plus their
1691
+ * `ui` hints (title / group / compact / multiline). The single
1692
+ * field-metadata surface — drives form editors and LLM/MCP consumers
1693
+ * alike. Key order in `fields`/`properties` is declaration order — the
1694
+ * ordering contract. Returns the `QuillSchema` shape.
1695
+ * @returns {QuillSchema}
1696
+ */
1697
+ get schema() {
1698
+ try {
1699
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1700
+ wasm.quill_schema(retptr, this.__wbg_ptr);
1701
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1702
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1703
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1704
+ if (r2) {
1705
+ throw takeObject(r1);
1706
+ }
1707
+ return takeObject(r0);
1708
+ } finally {
1709
+ wasm.__wbindgen_add_to_stack_pointer(16);
1710
+ }
1711
+ }
1712
+ /**
1713
+ * Seed a starter composable `Card` of the given kind (carries `$kind`),
1714
+ * layering an optional per-kind seed `overlay` over the schema-example
1715
+ * base (`overlay › example › absent`). Returns `undefined` if `cardKind`
1716
+ * is not declared in this quill's schema, else a `Card` that feeds
1717
+ * straight into `Document.insertCard`.
1718
+ *
1719
+ * Pass `document.seedOverlay(cardKind)` as `overlay` so a card added to a
1720
+ * template-derived document inherits its curated starting values; omit it
1721
+ * (or pass `undefined` / `null`) for the bare schema seed. `overlay` is a
1722
+ * plain object — this reads the document, it does not mutate it.
1723
+ * @param {string} card_kind
1724
+ * @param {Record<string, unknown> | undefined} overlay
1725
+ * @returns {Card | undefined}
1726
+ */
1727
+ seedCard(card_kind, overlay) {
1728
+ try {
1729
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1730
+ const ptr0 = passStringToWasm0(card_kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1731
+ const len0 = WASM_VECTOR_LEN;
1732
+ wasm.quill_seedCard(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(overlay));
1733
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1734
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1735
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1736
+ if (r2) {
1737
+ throw takeObject(r1);
1738
+ }
1739
+ return takeObject(r0);
1740
+ } finally {
1741
+ wasm.__wbindgen_add_to_stack_pointer(16);
1742
+ }
1743
+ }
1744
+ /**
1745
+ * Seed a starter `Document` from the schema — the main card plus one
1746
+ * instance of each composable card kind, each committing its fields'
1747
+ * `example:` values and leaving every other field absent (interpolated at
1748
+ * render: `default:`, else type-empty zero). Illustration-first: a field
1749
+ * with both an `example` and a `default` renders its example. See
1750
+ * `prose/canon/SCHEMAS.md` § "Document seeding".
1751
+ * @returns {Document}
1752
+ */
1753
+ seedDocument() {
1754
+ const ret = wasm.quill_seedDocument(this.__wbg_ptr);
1755
+ return Document.__wrap(ret);
1756
+ }
1757
+ /**
1758
+ * Seed a starter main `Card` (carries `$quill`) from the schema — the
1759
+ * `$kind: main` card of [`seedDocument`](Self::seed_document) in
1760
+ * isolation, committing each field's `example:` value. Returns the same
1761
+ * `Card` shape as the `Document.main` getter.
1762
+ * @returns {Card}
1763
+ */
1764
+ seedMain() {
1765
+ try {
1766
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1767
+ wasm.quill_seedMain(retptr, this.__wbg_ptr);
1768
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1769
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1770
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1771
+ if (r2) {
1772
+ throw takeObject(r1);
1773
+ }
1774
+ return takeObject(r0);
1775
+ } finally {
1776
+ wasm.__wbindgen_add_to_stack_pointer(16);
1777
+ }
1778
+ }
1779
+ /**
1780
+ * Flatten this quill back into its canonical file tree — the inverse of
1781
+ * [`fromTree`](Self::from_tree). Round-trips: `Quill.fromTree(q.toTree())`
1782
+ * reproduces an equivalent quill.
1783
+ *
1784
+ * This is how a quill crosses a WASM linear-memory boundary as data: a
1785
+ * `Quill` built in one build (e.g. the Typst-less `@quillmark/wasm/core`)
1786
+ * cannot be passed to an engine in another (separate linear memories), so
1787
+ * `@quillmark/wasm/runtime` re-feeds this tree to the backend build's
1788
+ * `Quill.fromTree` on demand. Keys are `"/"`-joined relative paths,
1789
+ * matching what `fromTree` accepts.
1790
+ * @returns {Map<string, Uint8Array>}
1791
+ */
1792
+ toTree() {
1793
+ const ret = wasm.quill_toTree(this.__wbg_ptr);
1794
+ return takeObject(ret);
1795
+ }
1796
+ /**
1797
+ * Validate `doc` against this quill's schema, returning every diagnostic
1798
+ * (an empty array when the document is valid).
1799
+ *
1800
+ * Forwards the canonical `validation::*` diagnostics — same `code`,
1801
+ * `path`, and `hint` the engine emits — including the non-fatal
1802
+ * `validation::must_fill` warning for each `!must_fill` marker left in
1803
+ * the document. Field values, defaults, and order are not part of this
1804
+ * surface: read them from the `Document` payload and `Quill.schema`
1805
+ * (schema key order is display order).
1806
+ * @param {Document} doc
1807
+ * @returns {Diagnostic[]}
1808
+ */
1809
+ validate(doc) {
1810
+ try {
1811
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1812
+ _assertClass(doc, Document);
1813
+ wasm.quill_validate(retptr, this.__wbg_ptr, doc.__wbg_ptr);
1814
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1815
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1816
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1817
+ if (r2) {
1818
+ throw takeObject(r1);
1819
+ }
1820
+ return takeObject(r0);
1821
+ } finally {
1822
+ wasm.__wbindgen_add_to_stack_pointer(16);
1823
+ }
1824
+ }
1825
+ }
1826
+ if (Symbol.dispose) Quill.prototype[Symbol.dispose] = Quill.prototype.free;
1827
+
1828
+ /**
1829
+ * Render engine: a backend registry and render dispatcher. Render build only —
1830
+ * the core build constructs and validates quills without it.
1831
+ */
1832
+ export class Quillmark {
1833
+ __destroy_into_raw() {
1834
+ const ptr = this.__wbg_ptr;
1835
+ this.__wbg_ptr = 0;
1836
+ QuillmarkFinalization.unregister(this);
1837
+ return ptr;
1838
+ }
1839
+ free() {
1840
+ const ptr = this.__destroy_into_raw();
1841
+ wasm.__wbg_quillmark_free(ptr, 0);
1842
+ }
1843
+ constructor() {
1844
+ const ret = wasm.quillmark_new();
1845
+ this.__wbg_ptr = ret >>> 0;
1846
+ QuillmarkFinalization.register(this, this.__wbg_ptr, this);
1847
+ return this;
1848
+ }
1849
+ /**
1850
+ * Open a live render session for `doc` against `quill`'s backend.
1851
+ * @param {Quill} quill
1852
+ * @param {Document} doc
1853
+ * @returns {LiveSession}
1854
+ */
1855
+ open(quill, doc) {
1856
+ try {
1857
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1858
+ _assertClass(quill, Quill);
1859
+ _assertClass(doc, Document);
1860
+ wasm.quillmark_open(retptr, this.__wbg_ptr, quill.__wbg_ptr, doc.__wbg_ptr);
1861
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1862
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1863
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1864
+ if (r2) {
1865
+ throw takeObject(r1);
1866
+ }
1867
+ return LiveSession.__wrap(r0);
1868
+ } finally {
1869
+ wasm.__wbindgen_add_to_stack_pointer(16);
1870
+ }
1871
+ }
1872
+ /**
1873
+ * Render `doc` against `quill` in one shot. Convenience over `open` +
1874
+ * `LiveSession.render`: an unset `output_format` falls back to the
1875
+ * backend's first supported format.
1876
+ * @param {Quill} quill
1877
+ * @param {Document} doc
1878
+ * @param {RenderOptions | null} [opts]
1879
+ * @returns {RenderResult}
1880
+ */
1881
+ render(quill, doc, opts) {
1882
+ try {
1883
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1884
+ _assertClass(quill, Quill);
1885
+ _assertClass(doc, Document);
1886
+ wasm.quillmark_render(retptr, this.__wbg_ptr, quill.__wbg_ptr, doc.__wbg_ptr, isLikeNone(opts) ? 0 : addHeapObject(opts));
1887
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1888
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1889
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1890
+ if (r2) {
1891
+ throw takeObject(r1);
1892
+ }
1893
+ return takeObject(r0);
1894
+ } finally {
1895
+ wasm.__wbindgen_add_to_stack_pointer(16);
1896
+ }
1897
+ }
1898
+ /**
1899
+ * The output formats `quill`'s backend can emit. Static capability —
1900
+ * resolves the backend but compiles nothing. Throws `engine::backend_not_found`
1901
+ * if no registered backend matches the quill's declared backend.
1902
+ * @param {Quill} quill
1903
+ * @returns {OutputFormat[]}
1904
+ */
1905
+ supportedFormats(quill) {
1906
+ try {
1907
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1908
+ _assertClass(quill, Quill);
1909
+ wasm.quillmark_supportedFormats(retptr, this.__wbg_ptr, quill.__wbg_ptr);
1910
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1911
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1912
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1913
+ if (r2) {
1914
+ throw takeObject(r1);
1915
+ }
1916
+ return takeObject(r0);
1917
+ } finally {
1918
+ wasm.__wbindgen_add_to_stack_pointer(16);
1919
+ }
1920
+ }
1921
+ /**
1922
+ * Pre-session hint: `true` iff `quill`'s backend can paint sessions to a
1923
+ * canvas, derived from the backend's output formats; `false` when the
1924
+ * backend is unsupported. Use as a cheap precondition probe before mounting
1925
+ * a canvas-based preview UI; the authoritative answer is the session's
1926
+ * `supportsCanvas` getter once `open()` has been called.
1927
+ * @param {Quill} quill
1928
+ * @returns {boolean}
1929
+ */
1930
+ supportsCanvas(quill) {
1931
+ _assertClass(quill, Quill);
1932
+ const ret = wasm.quillmark_supportsCanvas(this.__wbg_ptr, quill.__wbg_ptr);
1933
+ return ret !== 0;
1934
+ }
1935
+ }
1936
+ if (Symbol.dispose) Quillmark.prototype[Symbol.dispose] = Quillmark.prototype.free;
1937
+
1938
+ /**
1939
+ * Export a canonical `Content` content to its markdown projection — the pure
1940
+ * on-demand codec behind `exportMarkdown(card.body)`. Throws if `rt` is not a
1941
+ * canonical content.
1942
+ * @param {Content} rt
1943
+ * @returns {string}
1944
+ */
1945
+ export function exportMarkdown(rt) {
1946
+ let deferred2_0;
1947
+ let deferred2_1;
1948
+ try {
1949
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1950
+ wasm.exportMarkdown(retptr, addHeapObject(rt));
1951
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1952
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1953
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1954
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1955
+ var ptr1 = r0;
1956
+ var len1 = r1;
1957
+ if (r3) {
1958
+ ptr1 = 0; len1 = 0;
1959
+ throw takeObject(r2);
1960
+ }
1961
+ deferred2_0 = ptr1;
1962
+ deferred2_1 = len1;
1963
+ return getStringFromWasm0(ptr1, len1);
1964
+ } finally {
1965
+ wasm.__wbindgen_add_to_stack_pointer(16);
1966
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
1967
+ }
1968
+ }
1969
+
1970
+ /**
1971
+ * Import a markdown string to a canonical `Content` content — the pure,
1972
+ * document-free codec. Pair with `install(addr, importMarkdown(md))` to spell
1973
+ * the cold (anchor-losing) write at the call site; prefer `revise` for edit
1974
+ * semantics. Throws on an over-nested input.
1975
+ * @param {string} markdown
1976
+ * @returns {Content}
1977
+ */
1978
+ export function importMarkdown(markdown) {
1979
+ try {
1980
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1981
+ const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1982
+ const len0 = WASM_VECTOR_LEN;
1983
+ wasm.importMarkdown(retptr, ptr0, len0);
1984
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1985
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1986
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1987
+ if (r2) {
1988
+ throw takeObject(r1);
1989
+ }
1990
+ return takeObject(r0);
1991
+ } finally {
1992
+ wasm.__wbindgen_add_to_stack_pointer(16);
1993
+ }
1994
+ }
1995
+
1996
+ /**
1997
+ * Initialize the WASM module with panic hooks for better error messages
1998
+ */
1999
+ export function init() {
2000
+ wasm.init();
2001
+ }
2002
+
2003
+ /**
2004
+ * Map a base content position through a `delta` to its new position — the pure
2005
+ * position-mapping codec an editor bridge composes to hold a caret stable
2006
+ * across a `revise`. `assoc` decides the side of a same-position insertion
2007
+ * (`"after"` moves past it). Throws on a malformed `delta`.
2008
+ * @param {Delta} delta
2009
+ * @param {number} pos
2010
+ * @param {Assoc} assoc
2011
+ * @returns {number}
2012
+ */
2013
+ export function mapPos(delta, pos, assoc) {
2014
+ try {
2015
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2016
+ wasm.mapPos(retptr, addHeapObject(delta), pos, addHeapObject(assoc));
2017
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2018
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2019
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2020
+ if (r2) {
2021
+ throw takeObject(r1);
2022
+ }
2023
+ return r0 >>> 0;
2024
+ } finally {
2025
+ wasm.__wbindgen_add_to_stack_pointer(16);
2026
+ }
2027
+ }
2028
+
2029
+ /**
2030
+ * Rebase `markdown` onto a `base` content — the pure, document-free twin of
2031
+ * `revise`: cold-import + `diff_import`, returning the new `content` and the
2032
+ * text `delta` (surviving anchors rebased). Use it to compute a revise without
2033
+ * a document in hand; `revise(addr, md)` fuses this with the store for
2034
+ * atomicity. Throws on an over-nested markdown input or a non-content `base`.
2035
+ * @param {Content} base
2036
+ * @param {string} markdown
2037
+ * @returns {{ content: Content; delta: Delta }}
2038
+ */
2039
+ export function rebase(base, markdown) {
2040
+ try {
2041
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2042
+ const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2043
+ const len0 = WASM_VECTOR_LEN;
2044
+ wasm.rebase(retptr, addHeapObject(base), ptr0, len0);
2045
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2046
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2047
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2048
+ if (r2) {
2049
+ throw takeObject(r1);
2050
+ }
2051
+ return takeObject(r0);
2052
+ } finally {
2053
+ wasm.__wbindgen_add_to_stack_pointer(16);
2054
+ }
2055
+ }
2056
+ export function __wbg_Error_960c155d3d49e4c2(arg0, arg1) {
2057
+ const ret = Error(getStringFromWasm0(arg0, arg1));
2058
+ return addHeapObject(ret);
2059
+ }
2060
+ export function __wbg_Number_32bf70a599af1d4b(arg0) {
2061
+ const ret = Number(getObject(arg0));
2062
+ return ret;
2063
+ }
2064
+ export function __wbg_String_8564e559799eccda(arg0, arg1) {
2065
+ const ret = String(getObject(arg1));
2066
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2067
+ const len1 = WASM_VECTOR_LEN;
2068
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2069
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2070
+ }
2071
+ export function __wbg_String_b51de6b05a10845b(arg0, arg1) {
2072
+ const ret = String(getObject(arg1));
2073
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2074
+ const len1 = WASM_VECTOR_LEN;
2075
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2076
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2077
+ }
2078
+ export function __wbg___wbindgen_bigint_get_as_i64_3d3aba5d616c6a51(arg0, arg1) {
2079
+ const v = getObject(arg1);
2080
+ const ret = typeof(v) === 'bigint' ? v : undefined;
2081
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
2082
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2083
+ }
2084
+ export function __wbg___wbindgen_boolean_get_6ea149f0a8dcc5ff(arg0) {
2085
+ const v = getObject(arg0);
2086
+ const ret = typeof(v) === 'boolean' ? v : undefined;
2087
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
2088
+ }
2089
+ export function __wbg___wbindgen_debug_string_ab4b34d23d6778bd(arg0, arg1) {
2090
+ const ret = debugString(getObject(arg1));
2091
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2092
+ const len1 = WASM_VECTOR_LEN;
2093
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2094
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2095
+ }
2096
+ export function __wbg___wbindgen_in_a5d8b22e52b24dd1(arg0, arg1) {
2097
+ const ret = getObject(arg0) in getObject(arg1);
2098
+ return ret;
2099
+ }
2100
+ export function __wbg___wbindgen_is_bigint_ec25c7f91b4d9e93(arg0) {
2101
+ const ret = typeof(getObject(arg0)) === 'bigint';
2102
+ return ret;
2103
+ }
2104
+ export function __wbg___wbindgen_is_function_3baa9db1a987f47d(arg0) {
2105
+ const ret = typeof(getObject(arg0)) === 'function';
2106
+ return ret;
2107
+ }
2108
+ export function __wbg___wbindgen_is_null_52ff4ec04186736f(arg0) {
2109
+ const ret = getObject(arg0) === null;
2110
+ return ret;
2111
+ }
2112
+ export function __wbg___wbindgen_is_object_63322ec0cd6ea4ef(arg0) {
2113
+ const val = getObject(arg0);
2114
+ const ret = typeof(val) === 'object' && val !== null;
2115
+ return ret;
2116
+ }
2117
+ export function __wbg___wbindgen_is_string_6df3bf7ef1164ed3(arg0) {
2118
+ const ret = typeof(getObject(arg0)) === 'string';
2119
+ return ret;
2120
+ }
2121
+ export function __wbg___wbindgen_is_undefined_29a43b4d42920abd(arg0) {
2122
+ const ret = getObject(arg0) === undefined;
2123
+ return ret;
2124
+ }
2125
+ export function __wbg___wbindgen_jsval_eq_d3465d8a07697228(arg0, arg1) {
2126
+ const ret = getObject(arg0) === getObject(arg1);
2127
+ return ret;
2128
+ }
2129
+ export function __wbg___wbindgen_jsval_loose_eq_cac3565e89b4134c(arg0, arg1) {
2130
+ const ret = getObject(arg0) == getObject(arg1);
2131
+ return ret;
2132
+ }
2133
+ export function __wbg___wbindgen_number_get_c7f42aed0525c451(arg0, arg1) {
2134
+ const obj = getObject(arg1);
2135
+ const ret = typeof(obj) === 'number' ? obj : undefined;
2136
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
2137
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2138
+ }
2139
+ export function __wbg___wbindgen_string_get_7ed5322991caaec5(arg0, arg1) {
2140
+ const obj = getObject(arg1);
2141
+ const ret = typeof(obj) === 'string' ? obj : undefined;
2142
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2143
+ var len1 = WASM_VECTOR_LEN;
2144
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2145
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2146
+ }
2147
+ export function __wbg___wbindgen_throw_6b64449b9b9ed33c(arg0, arg1) {
2148
+ throw new Error(getStringFromWasm0(arg0, arg1));
2149
+ }
2150
+ export function __wbg_call_14b169f759b26747() { return handleError(function (arg0, arg1) {
2151
+ const ret = getObject(arg0).call(getObject(arg1));
2152
+ return addHeapObject(ret);
2153
+ }, arguments); }
2154
+ export function __wbg_canvas_2c0c6d263d4c52ad(arg0) {
2155
+ const ret = getObject(arg0).canvas;
2156
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2157
+ }
2158
+ export function __wbg_canvas_374da9f3c5b3dd0e(arg0) {
2159
+ const ret = getObject(arg0).canvas;
2160
+ return addHeapObject(ret);
2161
+ }
2162
+ export function __wbg_done_9158f7cc8751ba32(arg0) {
2163
+ const ret = getObject(arg0).done;
2164
+ return ret;
2165
+ }
2166
+ export function __wbg_entries_2bf997cf82353e47(arg0) {
2167
+ const ret = getObject(arg0).entries();
2168
+ return addHeapObject(ret);
2169
+ }
2170
+ export function __wbg_entries_e0b73aa8571ddb56(arg0) {
2171
+ const ret = Object.entries(getObject(arg0));
2172
+ return addHeapObject(ret);
2173
+ }
2174
+ export function __wbg_error_a6fa202b58aa1cd3(arg0, arg1) {
2175
+ let deferred0_0;
2176
+ let deferred0_1;
2177
+ try {
2178
+ deferred0_0 = arg0;
2179
+ deferred0_1 = arg1;
2180
+ console.error(getStringFromWasm0(arg0, arg1));
2181
+ } finally {
2182
+ wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
2183
+ }
2184
+ }
2185
+ export function __wbg_from_0dbf29f09e7fb200(arg0) {
2186
+ const ret = Array.from(getObject(arg0));
2187
+ return addHeapObject(ret);
2188
+ }
2189
+ export function __wbg_getRandomValues_3f44b700395062e5() { return handleError(function (arg0, arg1) {
2190
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
2191
+ }, arguments); }
2192
+ export function __wbg_get_1affdbdd5573b16a() { return handleError(function (arg0, arg1) {
2193
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
2194
+ return addHeapObject(ret);
2195
+ }, arguments); }
2196
+ export function __wbg_get_8360291721e2339f(arg0, arg1) {
2197
+ const ret = getObject(arg0)[arg1 >>> 0];
2198
+ return addHeapObject(ret);
2199
+ }
2200
+ export function __wbg_get_unchecked_17f53dad852b9588(arg0, arg1) {
2201
+ const ret = getObject(arg0)[arg1 >>> 0];
2202
+ return addHeapObject(ret);
2203
+ }
2204
+ export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) {
2205
+ const ret = getObject(arg0)[getObject(arg1)];
2206
+ return addHeapObject(ret);
2207
+ }
2208
+ export function __wbg_get_with_ref_key_f64427178466f623(arg0, arg1) {
2209
+ const ret = getObject(arg0)[getObject(arg1)];
2210
+ return addHeapObject(ret);
2211
+ }
2212
+ export function __wbg_instanceof_ArrayBuffer_7c8433c6ed14ffe3(arg0) {
2213
+ let result;
2214
+ try {
2215
+ result = getObject(arg0) instanceof ArrayBuffer;
2216
+ } catch (_) {
2217
+ result = false;
2218
+ }
2219
+ const ret = result;
2220
+ return ret;
2221
+ }
2222
+ export function __wbg_instanceof_CanvasRenderingContext2d_24a3fe06e62b98d7(arg0) {
2223
+ let result;
2224
+ try {
2225
+ result = getObject(arg0) instanceof CanvasRenderingContext2D;
2226
+ } catch (_) {
2227
+ result = false;
2228
+ }
2229
+ const ret = result;
2230
+ return ret;
2231
+ }
2232
+ export function __wbg_instanceof_Map_1b76fd4635be43eb(arg0) {
2233
+ let result;
2234
+ try {
2235
+ result = getObject(arg0) instanceof Map;
2236
+ } catch (_) {
2237
+ result = false;
2238
+ }
2239
+ const ret = result;
2240
+ return ret;
2241
+ }
2242
+ export function __wbg_instanceof_Object_7c99480a1cdfb911(arg0) {
2243
+ let result;
2244
+ try {
2245
+ result = getObject(arg0) instanceof Object;
2246
+ } catch (_) {
2247
+ result = false;
2248
+ }
2249
+ const ret = result;
2250
+ return ret;
2251
+ }
2252
+ export function __wbg_instanceof_OffscreenCanvasRenderingContext2d_285a274020b4f230(arg0) {
2253
+ let result;
2254
+ try {
2255
+ result = getObject(arg0) instanceof OffscreenCanvasRenderingContext2D;
2256
+ } catch (_) {
2257
+ result = false;
2258
+ }
2259
+ const ret = result;
2260
+ return ret;
2261
+ }
2262
+ export function __wbg_instanceof_Uint8Array_152ba1f289edcf3f(arg0) {
2263
+ let result;
2264
+ try {
2265
+ result = getObject(arg0) instanceof Uint8Array;
2266
+ } catch (_) {
2267
+ result = false;
2268
+ }
2269
+ const ret = result;
2270
+ return ret;
2271
+ }
2272
+ export function __wbg_isArray_c3109d14ffc06469(arg0) {
2273
+ const ret = Array.isArray(getObject(arg0));
2274
+ return ret;
2275
+ }
2276
+ export function __wbg_isSafeInteger_4fc213d1989d6d2a(arg0) {
2277
+ const ret = Number.isSafeInteger(getObject(arg0));
2278
+ return ret;
2279
+ }
2280
+ export function __wbg_iterator_013bc09ec998c2a7() {
2281
+ const ret = Symbol.iterator;
2282
+ return addHeapObject(ret);
2283
+ }
2284
+ export function __wbg_keys_2fd1bfdda7e278ca(arg0) {
2285
+ const ret = Object.keys(getObject(arg0));
2286
+ return addHeapObject(ret);
2287
+ }
2288
+ export function __wbg_length_3d4ecd04bd8d22f1(arg0) {
2289
+ const ret = getObject(arg0).length;
2290
+ return ret;
2291
+ }
2292
+ export function __wbg_length_9f1775224cf1d815(arg0) {
2293
+ const ret = getObject(arg0).length;
2294
+ return ret;
2295
+ }
2296
+ export function __wbg_new_0c7403db6e782f19(arg0) {
2297
+ const ret = new Uint8Array(getObject(arg0));
2298
+ return addHeapObject(ret);
2299
+ }
2300
+ export function __wbg_new_227d7c05414eb861() {
2301
+ const ret = new Error();
2302
+ return addHeapObject(ret);
2303
+ }
2304
+ export function __wbg_new_34d45cc8e36aaead() {
2305
+ const ret = new Map();
2306
+ return addHeapObject(ret);
2307
+ }
2308
+ export function __wbg_new_5e360d2ff7b9e1c3(arg0, arg1) {
2309
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
2310
+ return addHeapObject(ret);
2311
+ }
2312
+ export function __wbg_new_682678e2f47e32bc() {
2313
+ const ret = new Array();
2314
+ return addHeapObject(ret);
2315
+ }
2316
+ export function __wbg_new_aa8d0fa9762c29bd() {
2317
+ const ret = new Object();
2318
+ return addHeapObject(ret);
2319
+ }
2320
+ export function __wbg_new_from_slice_b5ea43e23f6008c0(arg0, arg1) {
2321
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
2322
+ return addHeapObject(ret);
2323
+ }
2324
+ export function __wbg_new_with_u8_clamped_array_and_sh_fe957411824b5158() { return handleError(function (arg0, arg1, arg2, arg3) {
2325
+ const ret = new ImageData(getClampedArrayU8FromWasm0(arg0, arg1), arg2 >>> 0, arg3 >>> 0);
2326
+ return addHeapObject(ret);
2327
+ }, arguments); }
2328
+ export function __wbg_next_0340c4ae324393c3() { return handleError(function (arg0) {
2329
+ const ret = getObject(arg0).next();
2330
+ return addHeapObject(ret);
2331
+ }, arguments); }
2332
+ export function __wbg_next_7646edaa39458ef7(arg0) {
2333
+ const ret = getObject(arg0).next;
2334
+ return addHeapObject(ret);
2335
+ }
2336
+ export function __wbg_now_a9b7df1cbee90986() {
2337
+ const ret = Date.now();
2338
+ return ret;
2339
+ }
2340
+ export function __wbg_prototypesetcall_a6b02eb00b0f4ce2(arg0, arg1, arg2) {
2341
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
2342
+ }
2343
+ export function __wbg_putImageData_c810e62ea70e761d() { return handleError(function (arg0, arg1, arg2, arg3) {
2344
+ getObject(arg0).putImageData(getObject(arg1), arg2, arg3);
2345
+ }, arguments); }
2346
+ export function __wbg_putImageData_cb4de9afd58963be() { return handleError(function (arg0, arg1, arg2, arg3) {
2347
+ getObject(arg0).putImageData(getObject(arg1), arg2, arg3);
2348
+ }, arguments); }
2349
+ export function __wbg_set_022bee52d0b05b19() { return handleError(function (arg0, arg1, arg2) {
2350
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
2351
+ return ret;
2352
+ }, arguments); }
2353
+ export function __wbg_set_3bf1de9fab0cd644(arg0, arg1, arg2) {
2354
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
2355
+ }
2356
+ export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
2357
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
2358
+ }
2359
+ export function __wbg_set_f071dbb3bd088e0e(arg0, arg1, arg2) {
2360
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
2361
+ }
2362
+ export function __wbg_set_fde2cec06c23692b(arg0, arg1, arg2) {
2363
+ const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
2364
+ return addHeapObject(ret);
2365
+ }
2366
+ export function __wbg_set_height_24d07d982f176ac6(arg0, arg1) {
2367
+ getObject(arg0).height = arg1 >>> 0;
2368
+ }
2369
+ export function __wbg_set_height_be9b2b920bd68401(arg0, arg1) {
2370
+ getObject(arg0).height = arg1 >>> 0;
2371
+ }
2372
+ export function __wbg_set_width_5cda41d4d06a14dd(arg0, arg1) {
2373
+ getObject(arg0).width = arg1 >>> 0;
2374
+ }
2375
+ export function __wbg_set_width_adc925bca9c5351a(arg0, arg1) {
2376
+ getObject(arg0).width = arg1 >>> 0;
2377
+ }
2378
+ export function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) {
2379
+ const ret = getObject(arg1).stack;
2380
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2381
+ const len1 = WASM_VECTOR_LEN;
2382
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2383
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2384
+ }
2385
+ export function __wbg_value_ee3a06f4579184fa(arg0) {
2386
+ const ret = getObject(arg0).value;
2387
+ return addHeapObject(ret);
2388
+ }
2389
+ export function __wbindgen_cast_0000000000000001(arg0) {
2390
+ // Cast intrinsic for `F64 -> Externref`.
2391
+ const ret = arg0;
2392
+ return addHeapObject(ret);
2393
+ }
2394
+ export function __wbindgen_cast_0000000000000002(arg0) {
2395
+ // Cast intrinsic for `I64 -> Externref`.
2396
+ const ret = arg0;
2397
+ return addHeapObject(ret);
2398
+ }
2399
+ export function __wbindgen_cast_0000000000000003(arg0, arg1) {
2400
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
2401
+ const ret = getArrayU8FromWasm0(arg0, arg1);
2402
+ return addHeapObject(ret);
2403
+ }
2404
+ export function __wbindgen_cast_0000000000000004(arg0, arg1) {
2405
+ // Cast intrinsic for `Ref(String) -> Externref`.
2406
+ const ret = getStringFromWasm0(arg0, arg1);
2407
+ return addHeapObject(ret);
2408
+ }
2409
+ export function __wbindgen_cast_0000000000000005(arg0) {
2410
+ // Cast intrinsic for `U64 -> Externref`.
2411
+ const ret = BigInt.asUintN(64, arg0);
2412
+ return addHeapObject(ret);
2413
+ }
2414
+ export function __wbindgen_object_clone_ref(arg0) {
2415
+ const ret = getObject(arg0);
2416
+ return addHeapObject(ret);
2417
+ }
2418
+ export function __wbindgen_object_drop_ref(arg0) {
2419
+ takeObject(arg0);
2420
+ }
2421
+ const DocumentFinalization = (typeof FinalizationRegistry === 'undefined')
2422
+ ? { register: () => {}, unregister: () => {} }
2423
+ : new FinalizationRegistry(ptr => wasm.__wbg_document_free(ptr >>> 0, 1));
2424
+ const LiveSessionFinalization = (typeof FinalizationRegistry === 'undefined')
2425
+ ? { register: () => {}, unregister: () => {} }
2426
+ : new FinalizationRegistry(ptr => wasm.__wbg_livesession_free(ptr >>> 0, 1));
2427
+ const QuillFinalization = (typeof FinalizationRegistry === 'undefined')
2428
+ ? { register: () => {}, unregister: () => {} }
2429
+ : new FinalizationRegistry(ptr => wasm.__wbg_quill_free(ptr >>> 0, 1));
2430
+ const QuillmarkFinalization = (typeof FinalizationRegistry === 'undefined')
2431
+ ? { register: () => {}, unregister: () => {} }
2432
+ : new FinalizationRegistry(ptr => wasm.__wbg_quillmark_free(ptr >>> 0, 1));
2433
+
2434
+ function addHeapObject(obj) {
2435
+ if (heap_next === heap.length) heap.push(heap.length + 1);
2436
+ const idx = heap_next;
2437
+ heap_next = heap[idx];
2438
+
2439
+ heap[idx] = obj;
2440
+ return idx;
2441
+ }
2442
+
2443
+ function _assertClass(instance, klass) {
2444
+ if (!(instance instanceof klass)) {
2445
+ throw new Error(`expected instance of ${klass.name}`);
2446
+ }
2447
+ }
2448
+
2449
+ function debugString(val) {
2450
+ // primitive types
2451
+ const type = typeof val;
2452
+ if (type == 'number' || type == 'boolean' || val == null) {
2453
+ return `${val}`;
2454
+ }
2455
+ if (type == 'string') {
2456
+ return `"${val}"`;
2457
+ }
2458
+ if (type == 'symbol') {
2459
+ const description = val.description;
2460
+ if (description == null) {
2461
+ return 'Symbol';
2462
+ } else {
2463
+ return `Symbol(${description})`;
2464
+ }
2465
+ }
2466
+ if (type == 'function') {
2467
+ const name = val.name;
2468
+ if (typeof name == 'string' && name.length > 0) {
2469
+ return `Function(${name})`;
2470
+ } else {
2471
+ return 'Function';
2472
+ }
2473
+ }
2474
+ // objects
2475
+ if (Array.isArray(val)) {
2476
+ const length = val.length;
2477
+ let debug = '[';
2478
+ if (length > 0) {
2479
+ debug += debugString(val[0]);
2480
+ }
2481
+ for(let i = 1; i < length; i++) {
2482
+ debug += ', ' + debugString(val[i]);
2483
+ }
2484
+ debug += ']';
2485
+ return debug;
2486
+ }
2487
+ // Test for built-in
2488
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
2489
+ let className;
2490
+ if (builtInMatches && builtInMatches.length > 1) {
2491
+ className = builtInMatches[1];
2492
+ } else {
2493
+ // Failed to match the standard '[object ClassName]'
2494
+ return toString.call(val);
2495
+ }
2496
+ if (className == 'Object') {
2497
+ // we're a user defined class or Object
2498
+ // JSON.stringify avoids problems with cycles, and is generally much
2499
+ // easier than looping through ownProperties of `val`.
2500
+ try {
2501
+ return 'Object(' + JSON.stringify(val) + ')';
2502
+ } catch (_) {
2503
+ return 'Object';
2504
+ }
2505
+ }
2506
+ // errors
2507
+ if (val instanceof Error) {
2508
+ return `${val.name}: ${val.message}\n${val.stack}`;
2509
+ }
2510
+ // TODO we could test for more things here, like `Set`s and `Map`s.
2511
+ return className;
2512
+ }
2513
+
2514
+ function dropObject(idx) {
2515
+ if (idx < 1028) return;
2516
+ heap[idx] = heap_next;
2517
+ heap_next = idx;
2518
+ }
2519
+
2520
+ function getArrayU8FromWasm0(ptr, len) {
2521
+ ptr = ptr >>> 0;
2522
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
2523
+ }
2524
+
2525
+ function getClampedArrayU8FromWasm0(ptr, len) {
2526
+ ptr = ptr >>> 0;
2527
+ return getUint8ClampedArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
2528
+ }
2529
+
2530
+ let cachedDataViewMemory0 = null;
2531
+ function getDataViewMemory0() {
2532
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
2533
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
2534
+ }
2535
+ return cachedDataViewMemory0;
2536
+ }
2537
+
2538
+ function getStringFromWasm0(ptr, len) {
2539
+ ptr = ptr >>> 0;
2540
+ return decodeText(ptr, len);
2541
+ }
2542
+
2543
+ let cachedUint8ArrayMemory0 = null;
2544
+ function getUint8ArrayMemory0() {
2545
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
2546
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
2547
+ }
2548
+ return cachedUint8ArrayMemory0;
2549
+ }
2550
+
2551
+ let cachedUint8ClampedArrayMemory0 = null;
2552
+ function getUint8ClampedArrayMemory0() {
2553
+ if (cachedUint8ClampedArrayMemory0 === null || cachedUint8ClampedArrayMemory0.byteLength === 0) {
2554
+ cachedUint8ClampedArrayMemory0 = new Uint8ClampedArray(wasm.memory.buffer);
2555
+ }
2556
+ return cachedUint8ClampedArrayMemory0;
2557
+ }
2558
+
2559
+ function getObject(idx) { return heap[idx]; }
2560
+
2561
+ function handleError(f, args) {
2562
+ try {
2563
+ return f.apply(this, args);
2564
+ } catch (e) {
2565
+ wasm.__wbindgen_export3(addHeapObject(e));
2566
+ }
2567
+ }
2568
+
2569
+ let heap = new Array(1024).fill(undefined);
2570
+ heap.push(undefined, null, true, false);
2571
+
2572
+ let heap_next = heap.length;
2573
+
2574
+ function isLikeNone(x) {
2575
+ return x === undefined || x === null;
2576
+ }
2577
+
2578
+ function passStringToWasm0(arg, malloc, realloc) {
2579
+ if (realloc === undefined) {
2580
+ const buf = cachedTextEncoder.encode(arg);
2581
+ const ptr = malloc(buf.length, 1) >>> 0;
2582
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
2583
+ WASM_VECTOR_LEN = buf.length;
2584
+ return ptr;
2585
+ }
2586
+
2587
+ let len = arg.length;
2588
+ let ptr = malloc(len, 1) >>> 0;
2589
+
2590
+ const mem = getUint8ArrayMemory0();
2591
+
2592
+ let offset = 0;
2593
+
2594
+ for (; offset < len; offset++) {
2595
+ const code = arg.charCodeAt(offset);
2596
+ if (code > 0x7F) break;
2597
+ mem[ptr + offset] = code;
2598
+ }
2599
+ if (offset !== len) {
2600
+ if (offset !== 0) {
2601
+ arg = arg.slice(offset);
2602
+ }
2603
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
2604
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
2605
+ const ret = cachedTextEncoder.encodeInto(arg, view);
2606
+
2607
+ offset += ret.written;
2608
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
2609
+ }
2610
+
2611
+ WASM_VECTOR_LEN = offset;
2612
+ return ptr;
2613
+ }
2614
+
2615
+ function takeObject(idx) {
2616
+ const ret = getObject(idx);
2617
+ dropObject(idx);
2618
+ return ret;
2619
+ }
2620
+
2621
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
2622
+ cachedTextDecoder.decode();
2623
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
2624
+ let numBytesDecoded = 0;
2625
+ function decodeText(ptr, len) {
2626
+ numBytesDecoded += len;
2627
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
2628
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
2629
+ cachedTextDecoder.decode();
2630
+ numBytesDecoded = len;
2631
+ }
2632
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
2633
+ }
2634
+
2635
+ const cachedTextEncoder = new TextEncoder();
2636
+
2637
+ if (!('encodeInto' in cachedTextEncoder)) {
2638
+ cachedTextEncoder.encodeInto = function (arg, view) {
2639
+ const buf = cachedTextEncoder.encode(arg);
2640
+ view.set(buf);
2641
+ return {
2642
+ read: arg.length,
2643
+ written: buf.length
2644
+ };
2645
+ };
2646
+ }
2647
+
2648
+ let WASM_VECTOR_LEN = 0;
2649
+
2650
+
2651
+ let wasm;
2652
+ export function __wbg_set_wasm(val) {
2653
+ wasm = val;
2654
+ }