@quillmark/wasm 0.101.0 → 0.103.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/core/wasm_bg.js DELETED
@@ -1,2359 +0,0 @@
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 `edit::unknown_field` per undeclared name; an invalid
33
- * kind or body, or an out-of-range position, throws a single-entry bundle
34
- * keyed `$kind` / `$body`.
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
- * `edit::unknown_field` rather than falling to the opaque store: on
76
- * the typed path it is a typo. Use [`storeField`](Document::store_field) for
77
- * opaque storage. Also throws `edit::field_conform` /
78
- * `edit::field_richtext_decode` / `edit::field_richtext_not_inline`
79
- * on a typed mismatch, `edit::invalid_field_name` on a malformed name,
80
- * and `edit::index_out_of_range` on an out-of-range card.
81
- *
82
- * The `quill` handle is passed per call because a `Document` carries only a
83
- * `$quill` reference, not the resolved schema.
84
- * @param {Quill} quill
85
- * @param {Addr | string} addr
86
- * @param {any} value
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 `edit::unknown_field` for any name the schema does not
111
- * declare, so a whole-form submit sees every typo in one pass. Throws on an
112
- * out-of-range card.
113
- * @param {Quill} quill
114
- * @param {CardAddr} addr
115
- * @param {Record<string, unknown>} fields
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
- * Interpreted read at `addr`, resolving the field's declared `type` from
133
- * `quill`: the stable ABI under the runtime `reader.get` / `reader.card(i).get`.
134
- * The schema-plane twin of the quill-free [`getStored`](Self::get_stored): a `richtext`
135
- * field returns its markdown projection, every other declared type its
136
- * canonical value verbatim, so a consumer holding the quill reads by field
137
- * meaning rather than by wire shape.
138
- *
139
- * A bare string is `Addr` shorthand for `{ field }`; `{ card, field }`
140
- * targets a composable card (its `$kind` resolves the schema). Returns
141
- * `undefined` for an **absent** field. An absent `addr.field` reads the body
142
- * markdown: quill-free, mirroring [`getMarkdown`](Self::get_markdown), since
143
- * a body's type is a format fact, not a schema fact. A name the schema does
144
- * not declare throws `edit::unknown_field` (the authority `getMarkdown`
145
- * lacks: there an unknown name reads back `undefined`); a `richtext` field
146
- * holding a value that does not decode throws `edit::field_richtext_decode`;
147
- * an out-of-range `addr.card` throws.
148
- *
149
- * The `quill` handle is passed per call because a `Document` carries only a
150
- * `$quill` reference, not the resolved schema.
151
- * @param {Quill} quill
152
- * @param {Addr | string} addr
153
- * @returns {unknown}
154
- */
155
- _readerGet(quill, addr) {
156
- try {
157
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
158
- _assertClass(quill, Quill);
159
- wasm.document__readerGet(retptr, this.__wbg_ptr, quill.__wbg_ptr, addHeapObject(addr));
160
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
161
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
162
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
163
- if (r2) {
164
- throw takeObject(r1);
165
- }
166
- return takeObject(r0);
167
- } finally {
168
- wasm.__wbindgen_add_to_stack_pointer(16);
169
- }
170
- }
171
- /**
172
- * Interpreted **corpus** read at `addr`: the stable ABI under the runtime
173
- * `reader.getContent` / `reader.card(i).getContent`. The corpus twin of
174
- * [`reader.get`](Self::reader_get), which projects; this decodes the stored
175
- * value through the codec the field's declared type names (`richtext` as
176
- * markdown, `plaintext` as literal text) and returns the canonical `Content`.
177
- *
178
- * Total over the storage form: a committed field holds a content object and
179
- * a parsed one holds the authored string, and both read back as a corpus
180
- * here, so a consumer mounting a corpus editor stops branching on how the
181
- * document was built.
182
- *
183
- * A bare string is `Addr` shorthand for `{ field }`; `{ card, field }`
184
- * targets a composable card. Returns `undefined` for an **absent** field. An
185
- * absent `addr.field` reads the **body** corpus, quill-free, mirroring
186
- * [`getStored`](Self::get_stored). Throws `edit::unknown_field` for a name
187
- * the schema does not declare, `edit::field_not_content` for a declared type
188
- * that is not a content leaf (`array<richtext>` carries content and still has
189
- * no one corpus), `edit::field_richtext_decode` for a stored value
190
- * that decodes under neither encoding, and `edit::index_out_of_range` for a
191
- * bad `addr.card`.
192
- * @param {Quill} quill
193
- * @param {Addr | string} addr
194
- * @returns {Content | undefined}
195
- */
196
- _readerGetContent(quill, addr) {
197
- try {
198
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
199
- _assertClass(quill, Quill);
200
- wasm.document__readerGetContent(retptr, this.__wbg_ptr, quill.__wbg_ptr, addHeapObject(addr));
201
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
202
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
203
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
204
- if (r2) {
205
- throw takeObject(r1);
206
- }
207
- return takeObject(r0);
208
- } finally {
209
- wasm.__wbindgen_add_to_stack_pointer(16);
210
- }
211
- }
212
- /**
213
- * Revise the content field at `addr` from authored text, typed *and*
214
- * anchor-preserving: the ABI under `writer.reviseField`. Resolves the
215
- * field's schema from `quill` (main card, or the addressed card's `$kind`)
216
- * and defers to [`TypedWriter::revise_field`](quillmark_core::TypedWriter::revise_field):
217
- * surviving anchors rebase (as [`revise`](Self::revise)), then the diffed
218
- * result is schema-conformed, so a `richtext(inline)` field rejects a
219
- * multi-block result with `edit::field_richtext_not_inline`. Returns the
220
- * text `Delta`.
221
- *
222
- * The codec is the declared type's: `richtext` diffs markdown, `plaintext`
223
- * the literal text.
224
- *
225
- * `addr` must name a field (a bare string is `{ field }`); a body address
226
- * throws (a body carries no field schema: use [`revise`](Self::revise)). A
227
- * name the schema does not declare throws `edit::unknown_field`. Throws
228
- * on an out-of-range card. Hidden from the `.d.ts`; the visible verb is
229
- * `writer.reviseField` in the runtime layer.
230
- * @param {Quill} quill
231
- * @param {Addr | string} addr
232
- * @param {string} text
233
- * @returns {Delta}
234
- */
235
- _reviseField(quill, addr, text) {
236
- try {
237
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
238
- _assertClass(quill, Quill);
239
- const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
240
- const len0 = WASM_VECTOR_LEN;
241
- wasm.document__reviseField(retptr, this.__wbg_ptr, quill.__wbg_ptr, addHeapObject(addr), ptr0, len0);
242
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
243
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
244
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
245
- if (r2) {
246
- throw takeObject(r1);
247
- }
248
- return takeObject(r0);
249
- } finally {
250
- wasm.__wbindgen_add_to_stack_pointer(16);
251
- }
252
- }
253
- /**
254
- * **Apply** a committed content edit `bundle`
255
- * (`{ delta?, islandOps?, lineOps?, markOps? }`) at `addr`, the editor
256
- * splice: text delta first, then island ops, then line ops, then mark ops
257
- * (mark ranges in final-text coordinates), each all-or-nothing. An absent
258
- * `addr.field` targets the body, an absent `addr.card` the main card.
259
- *
260
- * The island channel keeps a table or image edit on the op path: it moves
261
- * the island alone, so the anchors elsewhere in the field survive an edit
262
- * `install` would clear.
263
- *
264
- * Throws on an out-of-range card, a field that is not richtext, a malformed
265
- * bundle, or an op that applies out of bounds (the value is unchanged on a
266
- * failed apply).
267
- * @param {Addr | string} addr
268
- * @param {ChangeBundle} bundle
269
- */
270
- applyChange(addr, bundle) {
271
- try {
272
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
273
- wasm.document_applyChange(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(bundle));
274
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
275
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
276
- if (r1) {
277
- throw takeObject(r0);
278
- }
279
- } finally {
280
- wasm.__wbindgen_add_to_stack_pointer(16);
281
- }
282
- }
283
- /**
284
- * Authoring-ergonomics header introducing a blueprint to an LLM/MCP
285
- * consumer for the given `quillName`. Re-exposes core's canonical text for
286
- * JS consumers; any surface that draws from the same core source stays
287
- * uniform.
288
- * @param {string} quill_name
289
- * @returns {string}
290
- */
291
- static blueprintInstruction(quill_name) {
292
- let deferred2_0;
293
- let deferred2_1;
294
- try {
295
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
296
- const ptr0 = passStringToWasm0(quill_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
297
- const len0 = WASM_VECTOR_LEN;
298
- wasm.document_blueprintInstruction(retptr, ptr0, len0);
299
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
300
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
301
- deferred2_0 = r0;
302
- deferred2_1 = r1;
303
- return getStringFromWasm0(r0, r1);
304
- } finally {
305
- wasm.__wbindgen_add_to_stack_pointer(16);
306
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
307
- }
308
- }
309
- /**
310
- * A single composable card by index: the whole `Card`, the card-indexed
311
- * twin of the [`main`](Self::main) getter, so reading one card need not
312
- * materialize every card via [`cards`](Self::cards). An out-of-range
313
- * `index` throws `edit::index_out_of_range`, matching the card write
314
- * verbs.
315
- * @param {number} index
316
- * @returns {Card}
317
- */
318
- card(index) {
319
- try {
320
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
321
- wasm.document_card(retptr, this.__wbg_ptr, index);
322
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
323
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
324
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
325
- if (r2) {
326
- throw takeObject(r1);
327
- }
328
- return takeObject(r0);
329
- } finally {
330
- wasm.__wbindgen_add_to_stack_pointer(16);
331
- }
332
- }
333
- /**
334
- * Number of composable cards (excludes the main card). O(1).
335
- * @returns {number}
336
- */
337
- get cardCount() {
338
- const ret = wasm.document_cardCount(this.__wbg_ptr);
339
- return ret >>> 0;
340
- }
341
- /**
342
- * @returns {Card[]}
343
- */
344
- get cards() {
345
- try {
346
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
347
- wasm.document_cards(retptr, this.__wbg_ptr);
348
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
349
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
350
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
351
- if (r2) {
352
- throw takeObject(r1);
353
- }
354
- return takeObject(r0);
355
- } finally {
356
- wasm.__wbindgen_add_to_stack_pointer(16);
357
- }
358
- }
359
- /**
360
- * @returns {Document}
361
- */
362
- clone() {
363
- const ret = wasm.document_clone(this.__wbg_ptr);
364
- return Document.__wrap(ret);
365
- }
366
- /**
367
- * Schema version this build writes via [`toJson`](Document::to_json).
368
- * Tracks the `Document` model version (not the running crate version):
369
- * the tag advances only when the wire format changes, not on every release.
370
- * @returns {string}
371
- */
372
- static currentSchemaVersion() {
373
- let deferred1_0;
374
- let deferred1_1;
375
- try {
376
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
377
- wasm.document_currentSchemaVersion(retptr);
378
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
379
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
380
- deferred1_0 = r0;
381
- deferred1_1 = r1;
382
- return getStringFromWasm0(r0, r1);
383
- } finally {
384
- wasm.__wbindgen_add_to_stack_pointer(16);
385
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
386
- }
387
- }
388
- /**
389
- * Structural equality (parse-time `warnings` excluded). Use to debounce
390
- * upstream prop updates instead of re-parsing on every keystroke.
391
- * @param {Document} other
392
- * @returns {boolean}
393
- */
394
- equals(other) {
395
- _assertClass(other, Document);
396
- const ret = wasm.document_equals(this.__wbg_ptr, other.__wbg_ptr);
397
- return ret !== 0;
398
- }
399
- /**
400
- * Render a Diagnostic as the canonical pretty-printed text (core's
401
- * `Diagnostic::fmt_pretty`). Single source of truth so a Diagnostic looks
402
- * identical no matter which consumer surfaces it.
403
- * @param {Diagnostic} diag
404
- * @returns {string}
405
- */
406
- static formatDiagnostic(diag) {
407
- let deferred1_0;
408
- let deferred1_1;
409
- try {
410
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
411
- wasm.document_formatDiagnostic(retptr, addHeapObject(diag));
412
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
413
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
414
- deferred1_0 = r0;
415
- deferred1_1 = r1;
416
- return getStringFromWasm0(r0, r1);
417
- } finally {
418
- wasm.__wbindgen_add_to_stack_pointer(16);
419
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
420
- }
421
- }
422
- /**
423
- * Authoring-format rules for the card-yaml markdown surface. The canonical
424
- * text is core's (`quillmark_core::document::FORMAT_RULES`), re-exposed
425
- * here for JS consumers so it matches any other surface that draws from the
426
- * same source. Read once at startup and cache; the value never changes
427
- * between calls.
428
- * @returns {string}
429
- */
430
- static formatRules() {
431
- let deferred1_0;
432
- let deferred1_1;
433
- try {
434
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
435
- wasm.document_formatRules(retptr);
436
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
437
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
438
- deferred1_0 = r0;
439
- deferred1_1 = r1;
440
- return getStringFromWasm0(r0, r1);
441
- } finally {
442
- wasm.__wbindgen_add_to_stack_pointer(16);
443
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
444
- }
445
- }
446
- /**
447
- * Reconstruct a `Document` from a versioned storage DTO string produced
448
- * by [`toJson`](Document::to_json). Unknown `schema` tags are rejected.
449
- * The result carries no parse-time warnings (`.warnings` is always empty).
450
- *
451
- * Throws if `json` is not a valid storage DTO (malformed JSON, unknown
452
- * `schema`, missing fields, or unparseable quill reference).
453
- * @param {string} json
454
- * @returns {Document}
455
- */
456
- static fromJson(json) {
457
- try {
458
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
459
- const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
460
- const len0 = WASM_VECTOR_LEN;
461
- wasm.document_fromJson(retptr, ptr0, len0);
462
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
463
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
464
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
465
- if (r2) {
466
- throw takeObject(r1);
467
- }
468
- return Document.__wrap(r0);
469
- } finally {
470
- wasm.__wbindgen_add_to_stack_pointer(16);
471
- }
472
- }
473
- /**
474
- * Parse markdown into a typed Document. Throws on parse errors.
475
- * @param {string} markdown
476
- * @returns {Document}
477
- */
478
- static fromMarkdown(markdown) {
479
- try {
480
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
481
- const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
482
- const len0 = WASM_VECTOR_LEN;
483
- wasm.document_fromMarkdown(retptr, ptr0, len0);
484
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
485
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
486
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
487
- if (r2) {
488
- throw takeObject(r1);
489
- }
490
- return Document.__wrap(r0);
491
- } finally {
492
- wasm.__wbindgen_add_to_stack_pointer(16);
493
- }
494
- }
495
- /**
496
- * The whole `$ext` map at `addr` (a card address, absent `card` = main), or
497
- * `undefined` when the card carries none. The fine-grained `$ext` read:
498
- * your own state without serializing the whole card. Throws on a present
499
- * `field` (a card address takes only `card`) or an out-of-range card.
500
- * @param {CardAddr} [addr]
501
- * @returns {Record<string, unknown> | undefined}
502
- */
503
- getExt(addr) {
504
- try {
505
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
506
- wasm.document_getExt(retptr, this.__wbg_ptr, addHeapObject(addr));
507
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
508
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
509
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
510
- if (r2) {
511
- throw takeObject(r1);
512
- }
513
- return takeObject(r0);
514
- } finally {
515
- wasm.__wbindgen_add_to_stack_pointer(16);
516
- }
517
- }
518
- /**
519
- * The value stored under `$ext[ns]` at `addr` (a card address, absent `card`
520
- * = main), or `undefined`. The namespace-scoped `$ext` read: your own slot
521
- * without a whole-card serialize, and non-destructive (unlike
522
- * `removeExtNamespace`). Throws on a present `field` or an out-of-range card.
523
- * @param {CardAddr} addr
524
- * @param {string} ns
525
- * @returns {unknown}
526
- */
527
- getExtNamespace(addr, ns) {
528
- try {
529
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
530
- const ptr0 = passStringToWasm0(ns, wasm.__wbindgen_export, wasm.__wbindgen_export2);
531
- const len0 = WASM_VECTOR_LEN;
532
- wasm.document_getExtNamespace(retptr, this.__wbg_ptr, addHeapObject(addr), ptr0, len0);
533
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
534
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
535
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
536
- if (r2) {
537
- throw takeObject(r1);
538
- }
539
- return takeObject(r0);
540
- } finally {
541
- wasm.__wbindgen_add_to_stack_pointer(16);
542
- }
543
- }
544
- /**
545
- * The **body** markdown projection (the main body, or a composable card's
546
- * body (`{ card }`)) the on-demand, lossy export (content-only marks do not
547
- * survive markdown). A body's type is a format fact, not a schema fact, so
548
- * this read stays quill-free; a body is never absent.
549
- *
550
- * `addr` is an optional **card address** (`{ card }`, absent = main). A
551
- * present `field` throws: a field's markdown is read through the
552
- * schema-plane `quill.reader(doc).get(field)`, which interprets by declared
553
- * type. An out-of-range `addr.card` throws.
554
- * @param {CardAddr} [addr]
555
- * @returns {string}
556
- */
557
- getMarkdown(addr) {
558
- try {
559
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
560
- wasm.document_getMarkdown(retptr, this.__wbg_ptr, addHeapObject(addr));
561
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
562
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
563
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
564
- if (r2) {
565
- throw takeObject(r1);
566
- }
567
- return takeObject(r0);
568
- } finally {
569
- wasm.__wbindgen_add_to_stack_pointer(16);
570
- }
571
- }
572
- /**
573
- * Read the **verbatim stored value** at `addr`: the raw payload value of a
574
- * field, or the **body content** when `addr.field` is absent. A bare
575
- * string is `Addr` shorthand for `{ field }`. Reads are total over the field
576
- * axis: an absent field is `undefined`; only an out-of-range `addr.card`
577
- * throws `edit::index_out_of_range`. Needs no schema, so it lives on
578
- * `Document`: the read echo of the verbatim `store*` write, distinct from
579
- * the interpreted schema-plane [`reader.get`](Self::reader_get). For the
580
- * markdown projection use [`getMarkdown`](Self::get_markdown) (body) or
581
- * `reader.get` (a field's declared type).
582
- *
583
- * **A content field at rest has one stored form per codec**: a `richtext`
584
- * field holds the canonical content object, a `plaintext` field its literal
585
- * string. A document that came through the bound door (`quill.parse` /
586
- * `quill.conform`) is at rest, so this read no longer depends on which lane
587
- * built it. A document that came through the transport door
588
- * (`Document.fromMarkdown`, a legacy stored row) may rest as authored until
589
- * it is conformed, and this read reports what is there. For the corpus
590
- * either way, use the schema-plane `reader.getContent`, which decodes
591
- * through the codec the field's declared type names.
592
- * @param {Addr | string} addr
593
- * @returns {unknown}
594
- */
595
- getStored(addr) {
596
- try {
597
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
598
- wasm.document_getStored(retptr, this.__wbg_ptr, addHeapObject(addr));
599
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
600
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
601
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
602
- if (r2) {
603
- throw takeObject(r1);
604
- }
605
- return takeObject(r0);
606
- } finally {
607
- wasm.__wbindgen_add_to_stack_pointer(16);
608
- }
609
- }
610
- /**
611
- * Insert a card, the single insertion verb: `at` absent appends, a number
612
- * inserts at that index (must be in `0..=cards.length`). Accepts a
613
- * `CardInput`: a card read back (`cards` / `removeCard` / `quill.seedCard`),
614
- * a [`makeCard`](Document::make_card) result, or a bare `{ kind, body }`
615
- * (every returned `Card` is a valid `CardInput`). Throws if `card.kind` is
616
- * not a valid kind name, or if `at` is out of range.
617
- * @param {CardInput} card
618
- * @param {number} [at]
619
- */
620
- insertCard(card, at) {
621
- try {
622
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
623
- wasm.document_insertCard(retptr, this.__wbg_ptr, addHeapObject(card), isLikeNone(at) ? 0x100000001 : (at) >>> 0);
624
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
625
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
626
- if (r1) {
627
- throw takeObject(r0);
628
- }
629
- } finally {
630
- wasm.__wbindgen_add_to_stack_pointer(16);
631
- }
632
- }
633
- /**
634
- * **Install** a richtext value at `addr`: **value semantics**, content only.
635
- * Stores exactly `rt` (a canonical `Content` content object); the identity
636
- * anchors of any previous value are gone. An absent `addr.field` targets the
637
- * body, an absent `addr.card` the main card. For "here's new markdown," use
638
- * [`revise`](Document::revise); the cold-import path is spelled at the call
639
- * site as `install(addr, importMarkdown(md))`, so anchor loss is visible in
640
- * source.
641
- *
642
- * Throws on an out-of-range card, a malformed field name, or an `rt` that is
643
- * not a canonical content object.
644
- * @param {Addr | string} addr
645
- * @param {Content} rt
646
- */
647
- install(addr, rt) {
648
- try {
649
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
650
- wasm.document_install(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(rt));
651
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
652
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
653
- if (r1) {
654
- throw takeObject(r0);
655
- }
656
- } finally {
657
- wasm.__wbindgen_add_to_stack_pointer(16);
658
- }
659
- }
660
- /**
661
- * Whether the field at `addr` is marked `!must_fill`. A bare string is `Addr`
662
- * shorthand for `{ field }`. `false` for an absent field (truthful: it isn't
663
- * marked) and for a body address (a body is never a fill). Only an
664
- * out-of-range `addr.card` throws.
665
- * @param {Addr | string} addr
666
- * @returns {boolean}
667
- */
668
- isFill(addr) {
669
- try {
670
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
671
- wasm.document_isFill(retptr, this.__wbg_ptr, addHeapObject(addr));
672
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
673
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
674
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
675
- if (r2) {
676
- throw takeObject(r1);
677
- }
678
- return r0 !== 0;
679
- } finally {
680
- wasm.__wbindgen_add_to_stack_pointer(16);
681
- }
682
- }
683
- /**
684
- * Replace this document's contents **in place** from a versioned storage
685
- * DTO string: the mutating twin of the static
686
- * [`fromJson`](Document::from_json) constructor. Parse-time `warnings` are
687
- * cleared. Throws (leaving the document unchanged) on an invalid DTO.
688
- *
689
- * The cross-WASM-memory `Document` bridge: mutate a document on a
690
- * backend-memory clone, then write the mutated state back into the caller's
691
- * canonical document with this, the one way to update a live handle across
692
- * the linear-memory seam without the caller re-binding its variable.
693
- * @param {string} json
694
- */
695
- loadJson(json) {
696
- try {
697
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
698
- const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
699
- const len0 = WASM_VECTOR_LEN;
700
- wasm.document_loadJson(retptr, this.__wbg_ptr, ptr0, len0);
701
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
702
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
703
- if (r1) {
704
- throw takeObject(r0);
705
- }
706
- } finally {
707
- wasm.__wbindgen_add_to_stack_pointer(16);
708
- }
709
- }
710
- /**
711
- * The document's main (entry) card. Allocates and serializes on each
712
- * call: cache locally if read in a hot loop.
713
- * @returns {Card}
714
- */
715
- get main() {
716
- try {
717
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
718
- wasm.document_main(retptr, this.__wbg_ptr);
719
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
720
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
721
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
722
- if (r2) {
723
- throw takeObject(r1);
724
- }
725
- return takeObject(r0);
726
- } finally {
727
- wasm.__wbindgen_add_to_stack_pointer(16);
728
- }
729
- }
730
- /**
731
- * Build a fresh `Card` from a kind and a flat field map: the ergonomic
732
- * constructor for `insertCard`. `fields` is an optional
733
- * `Record<string, unknown>` (each entry becomes a card field, in
734
- * insertion order); `body` defaults to `""`.
735
- *
736
- * Sugar, not a required step: `insertCard` takes any `Card` object, and
737
- * `removeCard` returns one, so a card round-trips without passing through
738
- * here.
739
- *
740
- * Checks only what a detached card can decide alone: field-name grammar
741
- * and value depth. Kind validity is positional (`main` is right for the
742
- * root, reserved for a composable card) so `insertCard` is its gate, and
743
- * any kind string is accepted here.
744
- * @param {string} kind
745
- * @param {Record<string, unknown>} [fields]
746
- * @param {string} [body]
747
- * @returns {Card}
748
- */
749
- static makeCard(kind, fields, body) {
750
- try {
751
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
752
- const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
753
- const len0 = WASM_VECTOR_LEN;
754
- var ptr1 = isLikeNone(body) ? 0 : passStringToWasm0(body, wasm.__wbindgen_export, wasm.__wbindgen_export2);
755
- var len1 = WASM_VECTOR_LEN;
756
- wasm.document_makeCard(retptr, ptr0, len0, isLikeNone(fields) ? 0 : addHeapObject(fields), ptr1, len1);
757
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
758
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
759
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
760
- if (r2) {
761
- throw takeObject(r1);
762
- }
763
- return takeObject(r0);
764
- } finally {
765
- wasm.__wbindgen_add_to_stack_pointer(16);
766
- }
767
- }
768
- /**
769
- * Move the card at `from` to position `to`. `from == to` is a no-op.
770
- * @param {number} from
771
- * @param {number} to
772
- */
773
- moveCard(from, to) {
774
- try {
775
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
776
- wasm.document_moveCard(retptr, this.__wbg_ptr, from, to);
777
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
778
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
779
- if (r1) {
780
- throw takeObject(r0);
781
- }
782
- } finally {
783
- wasm.__wbindgen_add_to_stack_pointer(16);
784
- }
785
- }
786
- /**
787
- * `new Document(quillRef)`, a blank document: a main card carrying only
788
- * `$quill`, an empty body, and no composable cards. The programmatic
789
- * blank canvas: absent fields resolve at render time (`default`, else
790
- * type-empty zero), so nothing the caller did not set reaches the
791
- * output. For an example-filled starter use `Quill.seedDocument()`.
792
- * Throws on an invalid quill reference. Mirrors Python `Document(quill_ref)`.
793
- * @param {string} quill_ref
794
- */
795
- constructor(quill_ref) {
796
- try {
797
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
798
- const ptr0 = passStringToWasm0(quill_ref, wasm.__wbindgen_export, wasm.__wbindgen_export2);
799
- const len0 = WASM_VECTOR_LEN;
800
- wasm.document_new(retptr, ptr0, len0);
801
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
802
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
803
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
804
- if (r2) {
805
- throw takeObject(r1);
806
- }
807
- this.__wbg_ptr = r0 >>> 0;
808
- DocumentFinalization.register(this, this.__wbg_ptr, this);
809
- return this;
810
- } finally {
811
- wasm.__wbindgen_add_to_stack_pointer(16);
812
- }
813
- }
814
- /**
815
- * @returns {string}
816
- */
817
- get quillRef() {
818
- let deferred1_0;
819
- let deferred1_1;
820
- try {
821
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
822
- wasm.document_quillRef(retptr, this.__wbg_ptr);
823
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
824
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
825
- deferred1_0 = r0;
826
- deferred1_1 = r1;
827
- return getStringFromWasm0(r0, r1);
828
- } finally {
829
- wasm.__wbindgen_add_to_stack_pointer(16);
830
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
831
- }
832
- }
833
- /**
834
- * The canonical `$quill` reference grammar as author-facing text. Core is
835
- * the single source of truth: drive schema `describe` and validation
836
- * messages from this instead of re-stating the rule; it matches the
837
- * `hint` on `parse::invalid_quill_reference`. Cache it; the value never
838
- * changes.
839
- * @returns {string}
840
- */
841
- static quillRefHint() {
842
- let deferred1_0;
843
- let deferred1_1;
844
- try {
845
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
846
- wasm.document_quillRefHint(retptr);
847
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
848
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
849
- deferred1_0 = r0;
850
- deferred1_1 = r1;
851
- return getStringFromWasm0(r0, r1);
852
- } finally {
853
- wasm.__wbindgen_add_to_stack_pointer(16);
854
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
855
- }
856
- }
857
- /**
858
- * @param {number} index
859
- * @returns {Card | undefined}
860
- */
861
- removeCard(index) {
862
- try {
863
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
864
- wasm.document_removeCard(retptr, this.__wbg_ptr, index);
865
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
866
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
867
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
868
- if (r2) {
869
- throw takeObject(r1);
870
- }
871
- return takeObject(r0);
872
- } finally {
873
- wasm.__wbindgen_add_to_stack_pointer(16);
874
- }
875
- }
876
- /**
877
- * Remove the `$ext` map on the card `addr` targets *entirely*, returning the
878
- * previous map or `undefined`: a blunt escape hatch that discards every
879
- * namespace at once (prefer `removeExtNamespace`). `addr` is a card address
880
- * (absent = main). Throws on a present `field` or an out-of-range card.
881
- * @param {CardAddr} [addr]
882
- * @returns {Record<string, unknown> | undefined}
883
- */
884
- removeExt(addr) {
885
- try {
886
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
887
- wasm.document_removeExt(retptr, this.__wbg_ptr, addHeapObject(addr));
888
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
889
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
890
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
891
- if (r2) {
892
- throw takeObject(r1);
893
- }
894
- return takeObject(r0);
895
- } finally {
896
- wasm.__wbindgen_add_to_stack_pointer(16);
897
- }
898
- }
899
- /**
900
- * Remove `$ext[ns]` on the card `addr` targets, returning its value or
901
- * `undefined`; drops `$ext` once empty. `addr` is a card address (absent =
902
- * main). Preserves sibling namespaces. Throws on a present `field` or an
903
- * out-of-range card.
904
- * @param {CardAddr} addr
905
- * @param {string} ns
906
- * @returns {any}
907
- */
908
- removeExtNamespace(addr, ns) {
909
- try {
910
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
911
- const ptr0 = passStringToWasm0(ns, wasm.__wbindgen_export, wasm.__wbindgen_export2);
912
- const len0 = WASM_VECTOR_LEN;
913
- wasm.document_removeExtNamespace(retptr, this.__wbg_ptr, addHeapObject(addr), ptr0, len0);
914
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
915
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
916
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
917
- if (r2) {
918
- throw takeObject(r1);
919
- }
920
- return takeObject(r0);
921
- } finally {
922
- wasm.__wbindgen_add_to_stack_pointer(16);
923
- }
924
- }
925
- /**
926
- * Remove a field at `addr`, returning the removed value or `undefined`. A
927
- * bare string is `Addr` shorthand for `{ field }`. One `remove` verb serves
928
- * every write lane. A body address throws; throws on an out-of-range card or
929
- * a malformed name.
930
- * @param {Addr | string} addr
931
- * @returns {any}
932
- */
933
- removeField(addr) {
934
- try {
935
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
936
- wasm.document_removeField(retptr, this.__wbg_ptr, addHeapObject(addr));
937
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
938
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
939
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
940
- if (r2) {
941
- throw takeObject(r1);
942
- }
943
- return takeObject(r0);
944
- } finally {
945
- wasm.__wbindgen_add_to_stack_pointer(16);
946
- }
947
- }
948
- /**
949
- * Remove `cardKind` from the main card's `$seed` map, returning its
950
- * overlay or `undefined`; drops `$seed` entirely once empty. Sibling kinds
951
- * survive. `$seed` is main-only, so this takes no address.
952
- * @param {string} card_kind
953
- * @returns {any}
954
- */
955
- removeSeedNamespace(card_kind) {
956
- try {
957
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
958
- const ptr0 = passStringToWasm0(card_kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
959
- const len0 = WASM_VECTOR_LEN;
960
- wasm.document_removeSeedNamespace(retptr, this.__wbg_ptr, ptr0, len0);
961
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
962
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
963
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
964
- if (r2) {
965
- throw takeObject(r1);
966
- }
967
- return takeObject(r0);
968
- } finally {
969
- wasm.__wbindgen_add_to_stack_pointer(16);
970
- }
971
- }
972
- /**
973
- * **Revise** the richtext value at `addr` from a markdown string: **edit
974
- * semantics**, the default write path, returning the text `Delta`. Imports
975
- * the markdown, diffs it against the current value, rebases surviving
976
- * identity anchors, and returns the change an editor bridge maps its own
977
- * positions through (`mapPos`). An absent `addr.field` targets the body, an
978
- * absent `addr.card` the main card; an absent field cold-imports from empty.
979
- *
980
- * Throws on an out-of-range card, a malformed field name, a present
981
- * non-content field value, or an over-nested markdown input.
982
- * @param {Addr | string} addr
983
- * @param {string} markdown
984
- * @returns {Delta}
985
- */
986
- revise(addr, markdown) {
987
- try {
988
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
989
- const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
990
- const len0 = WASM_VECTOR_LEN;
991
- wasm.document_revise(retptr, this.__wbg_ptr, addHeapObject(addr), ptr0, len0);
992
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
993
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
994
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
995
- if (r2) {
996
- throw takeObject(r1);
997
- }
998
- return takeObject(r0);
999
- } finally {
1000
- wasm.__wbindgen_add_to_stack_pointer(16);
1001
- }
1002
- }
1003
- /**
1004
- * Read the `schema` version tag from a raw storage DTO string without a
1005
- * full parse, or `undefined`. Returns unknown future versions as-is:
1006
- * useful to distinguish "build too old" from "payload corrupt" when
1007
- * `fromJson` throws.
1008
- * @param {string} json
1009
- * @returns {string | undefined}
1010
- */
1011
- static schemaVersionOf(json) {
1012
- try {
1013
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1014
- const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1015
- const len0 = WASM_VECTOR_LEN;
1016
- wasm.document_schemaVersionOf(retptr, ptr0, len0);
1017
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1018
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1019
- let v2;
1020
- if (r0 !== 0) {
1021
- v2 = getStringFromWasm0(r0, r1).slice();
1022
- wasm.__wbindgen_export4(r0, r1 * 1, 1);
1023
- }
1024
- return v2;
1025
- } finally {
1026
- wasm.__wbindgen_add_to_stack_pointer(16);
1027
- }
1028
- }
1029
- /**
1030
- * The main card's `$seed` overlay object for `kind` (the `$seed[kind]`
1031
- * entry), or `undefined` when absent. The cheap read that feeds
1032
- * `quill.seedCard(kind, overlay)` without serializing the whole main card
1033
- * via [`main`](Self::main) to fish out one key, and it keeps `seedCard`
1034
- * pure: the quill still never reads the document.
1035
- * @param {string} kind
1036
- * @returns {Record<string, unknown> | undefined}
1037
- */
1038
- seedOverlay(kind) {
1039
- try {
1040
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1041
- const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1042
- const len0 = WASM_VECTOR_LEN;
1043
- wasm.document_seedOverlay(retptr, this.__wbg_ptr, ptr0, len0);
1044
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1045
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1046
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1047
- if (r2) {
1048
- throw takeObject(r1);
1049
- }
1050
- return takeObject(r0);
1051
- } finally {
1052
- wasm.__wbindgen_add_to_stack_pointer(16);
1053
- }
1054
- }
1055
- /**
1056
- * Replace the kind of the card at `index`. Payload and body are untouched;
1057
- * schema-aware migration is the caller's responsibility.
1058
- * Throws if `index` is out of range or `newKind` is invalid.
1059
- * @param {number} index
1060
- * @param {string} new_kind
1061
- */
1062
- setCardKind(index, new_kind) {
1063
- try {
1064
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1065
- const ptr0 = passStringToWasm0(new_kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1066
- const len0 = WASM_VECTOR_LEN;
1067
- wasm.document_setCardKind(retptr, this.__wbg_ptr, index, ptr0, len0);
1068
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1069
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1070
- if (r1) {
1071
- throw takeObject(r0);
1072
- }
1073
- } finally {
1074
- wasm.__wbindgen_add_to_stack_pointer(16);
1075
- }
1076
- }
1077
- /**
1078
- * Replace the QUILL reference string. Throws if `ref_str` is invalid.
1079
- * @param {string} ref_str
1080
- */
1081
- setQuillRef(ref_str) {
1082
- try {
1083
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1084
- const ptr0 = passStringToWasm0(ref_str, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1085
- const len0 = WASM_VECTOR_LEN;
1086
- wasm.document_setQuillRef(retptr, this.__wbg_ptr, ptr0, len0);
1087
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1088
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1089
- if (r1) {
1090
- throw takeObject(r0);
1091
- }
1092
- } finally {
1093
- wasm.__wbindgen_add_to_stack_pointer(16);
1094
- }
1095
- }
1096
- /**
1097
- * Replace the opaque `$ext` map on the card `addr` targets (a card address,
1098
- * absent `card` = main). `value` must be a plain object. `$ext` carries
1099
- * out-of-band consumer state and never reaches the rendered output; pass
1100
- * `{}` for an explicit empty `$ext`. Quill-free and verbatim: an opaque
1101
- * `store` verb. Throws on a present `field` or an out-of-range card.
1102
- * @param {CardAddr} addr
1103
- * @param {any} value
1104
- */
1105
- storeExt(addr, value) {
1106
- try {
1107
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1108
- wasm.document_storeExt(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(value));
1109
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1110
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1111
- if (r1) {
1112
- throw takeObject(r0);
1113
- }
1114
- } finally {
1115
- wasm.__wbindgen_add_to_stack_pointer(16);
1116
- }
1117
- }
1118
- /**
1119
- * Merge `value` into `$ext[ns]` on the card `addr` targets, preserving
1120
- * sibling namespaces: the recommended `$ext` write. `addr` is a card
1121
- * address (absent = main). Quill-free and verbatim: an opaque `store` verb.
1122
- * Throws on a present `field` or an out-of-range card.
1123
- * @param {CardAddr} addr
1124
- * @param {string} ns
1125
- * @param {any} value
1126
- */
1127
- storeExtNamespace(addr, ns, value) {
1128
- try {
1129
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1130
- const ptr0 = passStringToWasm0(ns, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1131
- const len0 = WASM_VECTOR_LEN;
1132
- wasm.document_storeExtNamespace(retptr, this.__wbg_ptr, addHeapObject(addr), ptr0, len0, addHeapObject(value));
1133
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1134
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1135
- if (r1) {
1136
- throw takeObject(r0);
1137
- }
1138
- } finally {
1139
- wasm.__wbindgen_add_to_stack_pointer(16);
1140
- }
1141
- }
1142
- /**
1143
- * Store a field verbatim at `addr`: the opaque store (**store** = verbatim,
1144
- * coercion deferred to render; the typed write is
1145
- * [`commitField`](Document::commit_field)). A bare string is `Addr`
1146
- * shorthand for `{ field }`, so `doc.storeField("qty", 3)` reads as written;
1147
- * `{ card: 2, field: "qty" }` targets a composable card. Clears any
1148
- * `!must_fill` marker. A body address (no `field`) throws: a body is never
1149
- * opaque; write it with `revise` / `install` / `writer.setBody`. Throws on
1150
- * an out-of-range card or a malformed name.
1151
- * @param {Addr | string} addr
1152
- * @param {any} value
1153
- */
1154
- storeField(addr, value) {
1155
- try {
1156
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1157
- wasm.document_storeField(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(value));
1158
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1159
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1160
- if (r1) {
1161
- throw takeObject(r0);
1162
- }
1163
- } finally {
1164
- wasm.__wbindgen_add_to_stack_pointer(16);
1165
- }
1166
- }
1167
- /**
1168
- * Store several fields verbatim and atomically on the card `addr` targets:
1169
- * the opaque store's batch. `addr` is a **card address** (`{ card }`, absent
1170
- * = main); a present `field` throws. The batch verb takes the address first
1171
- * and is never shape-overloaded, because `card` is a legal field name:
1172
- * `storeFields({}, fields)` is the main card, `storeFields({ card: 2 },
1173
- * fields)` a composable one, never ambiguous with "set field `card`".
1174
- * Nothing is applied on error; the thrown error's `diagnostics` carry one
1175
- * entry per offending field. Throws on an out-of-range card.
1176
- * @param {CardAddr} addr
1177
- * @param {Record<string, unknown>} fields
1178
- */
1179
- storeFields(addr, fields) {
1180
- try {
1181
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1182
- wasm.document_storeFields(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(fields));
1183
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1184
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1185
- if (r1) {
1186
- throw takeObject(r0);
1187
- }
1188
- } finally {
1189
- wasm.__wbindgen_add_to_stack_pointer(16);
1190
- }
1191
- }
1192
- /**
1193
- * Store a field verbatim at `addr` and mark it `!must_fill`: the opaque
1194
- * store's fill variant, card-capable (a bare string or `{ field }` for main,
1195
- * `{ card, field }` for a composable card). A body address throws. Same
1196
- * validation as [`storeField`](Document::store_field).
1197
- * @param {Addr | string} addr
1198
- * @param {any} value
1199
- */
1200
- storeFill(addr, value) {
1201
- try {
1202
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1203
- wasm.document_storeFill(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(value));
1204
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1205
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1206
- if (r1) {
1207
- throw takeObject(r0);
1208
- }
1209
- } finally {
1210
- wasm.__wbindgen_add_to_stack_pointer(16);
1211
- }
1212
- }
1213
- /**
1214
- * Merge a card-kind's seed `overlay` into the **main** card's `$seed` map
1215
- * under `cardKind`, preserving sibling kinds: `$seed` lives on the main
1216
- * card by model, so this takes no address. Sets the starting values new
1217
- * cards of that kind spawn with. Quill-free and verbatim: an opaque `store`
1218
- * verb. Throws if `overlay` cannot be serialized or nests too deep.
1219
- * @param {string} card_kind
1220
- * @param {any} overlay
1221
- */
1222
- storeSeedNamespace(card_kind, overlay) {
1223
- try {
1224
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1225
- const ptr0 = passStringToWasm0(card_kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1226
- const len0 = WASM_VECTOR_LEN;
1227
- wasm.document_storeSeedNamespace(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(overlay));
1228
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1229
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1230
- if (r1) {
1231
- throw takeObject(r0);
1232
- }
1233
- } finally {
1234
- wasm.__wbindgen_add_to_stack_pointer(16);
1235
- }
1236
- }
1237
- /**
1238
- * Serialize this document to a versioned storage DTO string.
1239
- *
1240
- * Prefer this over `toMarkdown` for persistence across restarts or crate
1241
- * upgrades: the wire format is frozen per `schema` version. Parse-time
1242
- * `warnings` are excluded from the DTO.
1243
- *
1244
- * Output is **byte-deterministic** within a `schema` version: equal
1245
- * documents produce byte-equal output, safe for content-hash use cases.
1246
- * @returns {string}
1247
- */
1248
- toJson() {
1249
- let deferred1_0;
1250
- let deferred1_1;
1251
- try {
1252
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1253
- wasm.document_toJson(retptr, this.__wbg_ptr);
1254
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1255
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1256
- deferred1_0 = r0;
1257
- deferred1_1 = r1;
1258
- return getStringFromWasm0(r0, r1);
1259
- } finally {
1260
- wasm.__wbindgen_add_to_stack_pointer(16);
1261
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1262
- }
1263
- }
1264
- /**
1265
- * Emit canonical Quillmark Markdown. Round-trip safe: re-parsing the
1266
- * result produces a `Document` equal to `self` by value and by type.
1267
- * @returns {string}
1268
- */
1269
- toMarkdown() {
1270
- let deferred1_0;
1271
- let deferred1_1;
1272
- try {
1273
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1274
- wasm.document_toMarkdown(retptr, this.__wbg_ptr);
1275
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1276
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1277
- deferred1_0 = r0;
1278
- deferred1_1 = r1;
1279
- return getStringFromWasm0(r0, r1);
1280
- } finally {
1281
- wasm.__wbindgen_add_to_stack_pointer(16);
1282
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1283
- }
1284
- }
1285
- /**
1286
- * Like [`fromJson`](Document::from_json) but returns `undefined` instead
1287
- * of throwing when `json` is not a valid storage DTO: use to
1288
- * discriminate format without exceptions as control flow.
1289
- * `undefined` means "not a storage DTO"; `fromMarkdown` still throws on
1290
- * genuinely malformed markdown.
1291
- * @param {string} json
1292
- * @returns {Document | undefined}
1293
- */
1294
- static tryFromJson(json) {
1295
- const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1296
- const len0 = WASM_VECTOR_LEN;
1297
- const ret = wasm.document_tryFromJson(ptr0, len0);
1298
- return ret === 0 ? undefined : Document.__wrap(ret);
1299
- }
1300
- /**
1301
- * The non-fatal diagnostics of the load that produced this document: parse
1302
- * warnings, plus the `conform::*` warnings when it came through
1303
- * `quill.parse`. Session state, not document value: `equals` and the
1304
- * storage DTO exclude it, and `fromJson` / `loadJson` clear it.
1305
- * @returns {Diagnostic[]}
1306
- */
1307
- get warnings() {
1308
- try {
1309
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1310
- wasm.document_warnings(retptr, this.__wbg_ptr);
1311
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1312
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1313
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1314
- if (r2) {
1315
- throw takeObject(r1);
1316
- }
1317
- return takeObject(r0);
1318
- } finally {
1319
- wasm.__wbindgen_add_to_stack_pointer(16);
1320
- }
1321
- }
1322
- }
1323
- if (Symbol.dispose) Document.prototype[Symbol.dispose] = Document.prototype.free;
1324
-
1325
- export class Quill {
1326
- static __wrap(ptr) {
1327
- ptr = ptr >>> 0;
1328
- const obj = Object.create(Quill.prototype);
1329
- obj.__wbg_ptr = ptr;
1330
- QuillFinalization.register(obj, obj.__wbg_ptr, obj);
1331
- return obj;
1332
- }
1333
- __destroy_into_raw() {
1334
- const ptr = this.__wbg_ptr;
1335
- this.__wbg_ptr = 0;
1336
- QuillFinalization.unregister(this);
1337
- return ptr;
1338
- }
1339
- free() {
1340
- const ptr = this.__destroy_into_raw();
1341
- wasm.__wbg_quill_free(ptr, 0);
1342
- }
1343
- /**
1344
- * The *declared* backend identifier (`config.backend`, e.g. `"typst"`).
1345
- * Intent, not a resolved capability: capability (`supportedFormats` /
1346
- * `supportsCanvas`) is read from the engine.
1347
- * @returns {string}
1348
- */
1349
- get backendId() {
1350
- let deferred1_0;
1351
- let deferred1_1;
1352
- try {
1353
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1354
- wasm.quill_backendId(retptr, this.__wbg_ptr);
1355
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1356
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1357
- deferred1_0 = r0;
1358
- deferred1_1 = r1;
1359
- return getStringFromWasm0(r0, r1);
1360
- } finally {
1361
- wasm.__wbindgen_add_to_stack_pointer(16);
1362
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1363
- }
1364
- }
1365
- /**
1366
- * @returns {string}
1367
- */
1368
- get blueprint() {
1369
- let deferred1_0;
1370
- let deferred1_1;
1371
- try {
1372
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1373
- wasm.quill_blueprint(retptr, this.__wbg_ptr);
1374
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1375
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1376
- deferred1_0 = r0;
1377
- deferred1_1 = r1;
1378
- return getStringFromWasm0(r0, r1);
1379
- } finally {
1380
- wasm.__wbindgen_add_to_stack_pointer(16);
1381
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1382
- }
1383
- }
1384
- /**
1385
- * Land `doc`'s declared content fields at their canonical rest **in
1386
- * place**, returning the `conform::*` diagnostics for the values that would
1387
- * not commit (an empty array when everything rested).
1388
- *
1389
- * The read-repair verb: a document that arrived through the transport door
1390
- * (`fromMarkdown`, `fromJson`, a stored row) converges here, and is then
1391
- * eligible for rewrite under its current schema tag. Idempotent, and a
1392
- * no-op on an already-canonical document: an equal value is not rewritten,
1393
- * so YAML comments and stored bytes survive.
1394
- *
1395
- * A `!must_fill` marker anywhere in a field's value skips that field (the
1396
- * marker is the state), and a value the strict write refuses stays as
1397
- * authored with a diagnostic. Throws when `doc` declares a different
1398
- * `$quill`, before any mutation.
1399
- * @param {Document} doc
1400
- * @returns {Diagnostic[]}
1401
- */
1402
- conform(doc) {
1403
- try {
1404
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1405
- _assertClass(doc, Document);
1406
- wasm.quill_conform(retptr, this.__wbg_ptr, doc.__wbg_ptr);
1407
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1408
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1409
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1410
- if (r2) {
1411
- throw takeObject(r1);
1412
- }
1413
- return takeObject(r0);
1414
- } finally {
1415
- wasm.__wbindgen_add_to_stack_pointer(16);
1416
- }
1417
- }
1418
- /**
1419
- * Build a quill from a file tree. Pure: no backend, no engine; the
1420
- * declared backend is resolved later, at render time.
1421
- *
1422
- * Accepts either a `Map<string, Uint8Array>` or a plain object
1423
- * (`Record<string, Uint8Array>`). Plain objects are walked via
1424
- * `Object.entries` at the boundary; the Rust side sees a single
1425
- * canonical shape.
1426
- * @param {Map<string, Uint8Array>} tree
1427
- * @returns {Quill}
1428
- */
1429
- static fromTree(tree) {
1430
- try {
1431
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1432
- wasm.quill_fromTree(retptr, addHeapObject(tree));
1433
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1434
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1435
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1436
- if (r2) {
1437
- throw takeObject(r1);
1438
- }
1439
- return Quill.__wrap(r0);
1440
- } finally {
1441
- wasm.__wbindgen_add_to_stack_pointer(16);
1442
- }
1443
- }
1444
- /**
1445
- * Identity snapshot of the `quill:` section of `Quill.yaml` plus any extra
1446
- * `quill:` keys. Pure config: the backend's output formats are a
1447
- * resolved-backend capability read from the engine
1448
- * (`Quillmark.supportedFormats`), not part of this snapshot.
1449
- * @returns {QuillMetadata}
1450
- */
1451
- get metadata() {
1452
- try {
1453
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1454
- wasm.quill_metadata(retptr, this.__wbg_ptr);
1455
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1456
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1457
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1458
- if (r2) {
1459
- throw takeObject(r1);
1460
- }
1461
- return takeObject(r0);
1462
- } finally {
1463
- wasm.__wbindgen_add_to_stack_pointer(16);
1464
- }
1465
- }
1466
- /**
1467
- * Parse `markdown` and conform it against this quill: the **primary
1468
- * ingestion path**, and the bound twin of the schema-free
1469
- * `Document.fromMarkdown`. The returned document rests at its canonical
1470
- * form (a `richtext` field as a content object, a `plaintext` field as its
1471
- * literal string), so `getStored` no longer answers "corpus or string?"
1472
- * with "depends how this document was built".
1473
- *
1474
- * Parse warnings and the `conform::*` diagnostics both land on
1475
- * `doc.warnings`. Throws on a parse failure, or when `markdown` declares a
1476
- * `$quill` this quill does not answer to: nothing conforms under the wrong
1477
- * schema. To open a document whose `$quill` is stale, use the transport
1478
- * door (`Document.fromMarkdown`, `setQuillRef`, then `quill.conform`).
1479
- * @param {string} markdown
1480
- * @returns {Document}
1481
- */
1482
- parse(markdown) {
1483
- try {
1484
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1485
- const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1486
- const len0 = WASM_VECTOR_LEN;
1487
- wasm.quill_parse(retptr, this.__wbg_ptr, ptr0, len0);
1488
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1489
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1490
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1491
- if (r2) {
1492
- throw takeObject(r1);
1493
- }
1494
- return Document.__wrap(r0);
1495
- } finally {
1496
- wasm.__wbindgen_add_to_stack_pointer(16);
1497
- }
1498
- }
1499
- /**
1500
- * The resolved-value view of `doc` against this quill's schema: for every
1501
- * declared field the value the render projection would use and the
1502
- * `FieldSource` rung it came from (`"authored" | "default" | "zero"`), in
1503
- * one call. The card body is a `body` sibling on its card (row `name`
1504
- * `"body"`), never a row in `fields`: `null` when the kind enables no body.
1505
- *
1506
- * Value and provenance only: completeness and errors stay `validate`'s
1507
- * (a consumer merges it with its own diagnostic producers regardless), and
1508
- * schema guidance reads from `Quill.schema`.
1509
- * @param {Document} doc
1510
- * @returns {Resolved}
1511
- */
1512
- resolve(doc) {
1513
- try {
1514
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1515
- _assertClass(doc, Document);
1516
- wasm.quill_resolve(retptr, this.__wbg_ptr, doc.__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
- * Document schema for the quill: the user-fillable fields plus their
1530
- * `ui` hints (title / group / compact / multiline). The single
1531
- * field-metadata surface: drives form editors and LLM/MCP consumers
1532
- * alike. Key order in `fields`/`properties` is declaration order: the
1533
- * ordering contract. Returns the `QuillSchema` shape.
1534
- * @returns {QuillSchema}
1535
- */
1536
- get schema() {
1537
- try {
1538
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1539
- wasm.quill_schema(retptr, this.__wbg_ptr);
1540
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1541
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1542
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1543
- if (r2) {
1544
- throw takeObject(r1);
1545
- }
1546
- return takeObject(r0);
1547
- } finally {
1548
- wasm.__wbindgen_add_to_stack_pointer(16);
1549
- }
1550
- }
1551
- /**
1552
- * Seed a starter composable `Card` of the given kind (carries `$kind`),
1553
- * layering an optional per-kind seed `overlay` over the schema-example
1554
- * base (`overlay › example › absent`). Returns `undefined` if `cardKind`
1555
- * is not declared in this quill's schema, else a `Card` that feeds
1556
- * straight into `Document.insertCard`.
1557
- *
1558
- * Pass `document.seedOverlay(cardKind)` as `overlay` so a card added to a
1559
- * template-derived document inherits its curated starting values; omit it
1560
- * (or pass `undefined` / `null`) for the bare schema seed. `overlay` is a
1561
- * plain object: this reads the document, it does not mutate it.
1562
- * @param {string} card_kind
1563
- * @param {Record<string, unknown> | undefined} overlay
1564
- * @returns {Card | undefined}
1565
- */
1566
- seedCard(card_kind, overlay) {
1567
- try {
1568
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1569
- const ptr0 = passStringToWasm0(card_kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1570
- const len0 = WASM_VECTOR_LEN;
1571
- wasm.quill_seedCard(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(overlay));
1572
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1573
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1574
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1575
- if (r2) {
1576
- throw takeObject(r1);
1577
- }
1578
- return takeObject(r0);
1579
- } finally {
1580
- wasm.__wbindgen_add_to_stack_pointer(16);
1581
- }
1582
- }
1583
- /**
1584
- * Seed a starter `Document` from the schema, the main card plus one
1585
- * instance of each composable card kind, each committing its fields'
1586
- * `example:` values and leaving every other field absent (interpolated at
1587
- * render: `default:`, else type-empty zero). Illustration-first: a field
1588
- * with both an `example` and a `default` renders its example. See
1589
- * `prose/canon/SCHEMAS.md` § "Document seeding".
1590
- * @returns {Document}
1591
- */
1592
- seedDocument() {
1593
- const ret = wasm.quill_seedDocument(this.__wbg_ptr);
1594
- return Document.__wrap(ret);
1595
- }
1596
- /**
1597
- * Seed a starter main `Card` (carries `$quill`) from the schema: the
1598
- * `$kind: main` card of [`seedDocument`](Self::seed_document) in
1599
- * isolation, committing each field's `example:` value. Returns the same
1600
- * `Card` shape as the `Document.main` getter.
1601
- * @returns {Card}
1602
- */
1603
- seedMain() {
1604
- try {
1605
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1606
- wasm.quill_seedMain(retptr, this.__wbg_ptr);
1607
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1608
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1609
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1610
- if (r2) {
1611
- throw takeObject(r1);
1612
- }
1613
- return takeObject(r0);
1614
- } finally {
1615
- wasm.__wbindgen_add_to_stack_pointer(16);
1616
- }
1617
- }
1618
- /**
1619
- * Flatten this quill back into its canonical file tree: the inverse of
1620
- * [`fromTree`](Self::from_tree). Round-trips: `Quill.fromTree(q.toTree())`
1621
- * reproduces an equivalent quill.
1622
- *
1623
- * This is how a quill crosses a WASM linear-memory boundary as data: a
1624
- * `Quill` built in one build (e.g. the Typst-less `@quillmark/wasm/core`)
1625
- * cannot be passed to an engine in another (separate linear memories), so
1626
- * `@quillmark/wasm/runtime` re-feeds this tree to the backend build's
1627
- * `Quill.fromTree` on demand. Keys are `"/"`-joined relative paths,
1628
- * matching what `fromTree` accepts.
1629
- * @returns {Map<string, Uint8Array>}
1630
- */
1631
- toTree() {
1632
- const ret = wasm.quill_toTree(this.__wbg_ptr);
1633
- return takeObject(ret);
1634
- }
1635
- /**
1636
- * Validate `doc` against this quill's schema, returning every diagnostic
1637
- * (an empty array when the document is valid).
1638
- *
1639
- * Forwards the canonical `validation::*` diagnostics (same `code`,
1640
- * `path`, and `hint` the engine emits) including the non-fatal
1641
- * `validation::must_fill` warning for each `!must_fill` marker left in
1642
- * the document. Field values, defaults, and order are not part of this
1643
- * surface: read them from the `Document` payload and `Quill.schema`
1644
- * (schema key order is display order).
1645
- * @param {Document} doc
1646
- * @returns {Diagnostic[]}
1647
- */
1648
- validate(doc) {
1649
- try {
1650
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1651
- _assertClass(doc, Document);
1652
- wasm.quill_validate(retptr, this.__wbg_ptr, doc.__wbg_ptr);
1653
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1654
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1655
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1656
- if (r2) {
1657
- throw takeObject(r1);
1658
- }
1659
- return takeObject(r0);
1660
- } finally {
1661
- wasm.__wbindgen_add_to_stack_pointer(16);
1662
- }
1663
- }
1664
- }
1665
- if (Symbol.dispose) Quill.prototype[Symbol.dispose] = Quill.prototype.free;
1666
-
1667
- /**
1668
- * Export a canonical `Content` content to its markdown projection: the pure
1669
- * on-demand codec behind `exportMarkdown(card.body)`. Throws if `rt` is not a
1670
- * canonical content.
1671
- * @param {Content} rt
1672
- * @returns {string}
1673
- */
1674
- export function exportMarkdown(rt) {
1675
- let deferred2_0;
1676
- let deferred2_1;
1677
- try {
1678
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1679
- wasm.exportMarkdown(retptr, addHeapObject(rt));
1680
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1681
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1682
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1683
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1684
- var ptr1 = r0;
1685
- var len1 = r1;
1686
- if (r3) {
1687
- ptr1 = 0; len1 = 0;
1688
- throw takeObject(r2);
1689
- }
1690
- deferred2_0 = ptr1;
1691
- deferred2_1 = len1;
1692
- return getStringFromWasm0(ptr1, len1);
1693
- } finally {
1694
- wasm.__wbindgen_add_to_stack_pointer(16);
1695
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
1696
- }
1697
- }
1698
-
1699
- /**
1700
- * Serialize structured [`DocPathSeg`] segments back to the canonical path
1701
- * string: the inverse of `parseDocPath`, for a consumer that builds a path
1702
- * rather than reads one. Throws on a segment array the deserializer rejects,
1703
- * and on an empty segment array (symmetric with `parseDocPath("")`, which
1704
- * throws "empty path").
1705
- * @param {DocPathSeg[]} segs
1706
- * @returns {string}
1707
- */
1708
- export function formatDocPath(segs) {
1709
- let deferred2_0;
1710
- let deferred2_1;
1711
- try {
1712
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1713
- wasm.formatDocPath(retptr, addHeapObject(segs));
1714
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1715
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1716
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1717
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1718
- var ptr1 = r0;
1719
- var len1 = r1;
1720
- if (r3) {
1721
- ptr1 = 0; len1 = 0;
1722
- throw takeObject(r2);
1723
- }
1724
- deferred2_0 = ptr1;
1725
- deferred2_1 = len1;
1726
- return getStringFromWasm0(ptr1, len1);
1727
- } finally {
1728
- wasm.__wbindgen_add_to_stack_pointer(16);
1729
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
1730
- }
1731
- }
1732
-
1733
- /**
1734
- * Import a markdown string to a canonical `Content` content: the pure,
1735
- * document-free codec. Pair with `install(addr, importMarkdown(md))` to spell
1736
- * the cold (anchor-losing) write at the call site; prefer `revise` for edit
1737
- * semantics. Throws on an over-nested input.
1738
- * @param {string} markdown
1739
- * @returns {Content}
1740
- */
1741
- export function importMarkdown(markdown) {
1742
- try {
1743
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1744
- const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1745
- const len0 = WASM_VECTOR_LEN;
1746
- wasm.importMarkdown(retptr, ptr0, len0);
1747
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1748
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1749
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1750
- if (r2) {
1751
- throw takeObject(r1);
1752
- }
1753
- return takeObject(r0);
1754
- } finally {
1755
- wasm.__wbindgen_add_to_stack_pointer(16);
1756
- }
1757
- }
1758
-
1759
- /**
1760
- * Initialize the WASM module with panic hooks for better error messages
1761
- */
1762
- export function init() {
1763
- wasm.init();
1764
- }
1765
-
1766
- /**
1767
- * Map a base content position (a USV index into `Content.text`, not a UTF-16
1768
- * offset) through a `delta` to its new USV position: the pure position-mapping
1769
- * codec an editor bridge composes to hold a caret stable across a `revise`.
1770
- * `assoc` decides the side of a same-position insertion (`"after"` moves past
1771
- * it). Throws on a malformed `delta`.
1772
- * @param {Delta} delta
1773
- * @param {number} pos
1774
- * @param {Assoc} assoc
1775
- * @returns {number}
1776
- */
1777
- export function mapPos(delta, pos, assoc) {
1778
- try {
1779
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1780
- wasm.mapPos(retptr, addHeapObject(delta), pos, addHeapObject(assoc));
1781
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1782
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1783
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1784
- if (r2) {
1785
- throw takeObject(r1);
1786
- }
1787
- return r0 >>> 0;
1788
- } finally {
1789
- wasm.__wbindgen_add_to_stack_pointer(16);
1790
- }
1791
- }
1792
-
1793
- /**
1794
- * Parse a canonical document-model `Diagnostic.path`
1795
- * (`cards.<kind>[<i>].<field>`, `main.body`, `recipients[0].name`) into its
1796
- * structured [`DocPathSeg`] segments: the exported inverse of the engine's
1797
- * one path serializer, so a consumer routes on segments instead of regexing
1798
- * the string. Throws on a malformed path.
1799
- * @param {string} path
1800
- * @returns {DocPathSeg[]}
1801
- */
1802
- export function parseDocPath(path) {
1803
- try {
1804
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1805
- const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1806
- const len0 = WASM_VECTOR_LEN;
1807
- wasm.parseDocPath(retptr, ptr0, len0);
1808
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1809
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1810
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1811
- if (r2) {
1812
- throw takeObject(r1);
1813
- }
1814
- return takeObject(r0);
1815
- } finally {
1816
- wasm.__wbindgen_add_to_stack_pointer(16);
1817
- }
1818
- }
1819
-
1820
- /**
1821
- * Rebase `markdown` onto a `base` content, the pure, document-free twin of
1822
- * `revise`: cold-import + `diff_import`, returning the new `content` and the
1823
- * text `delta` (its offsets USV indices into `Content.text`, surviving anchors
1824
- * rebased). Use it to compute a revise without a document in hand; `revise(addr,
1825
- * md)` fuses this with the store for atomicity. Throws on an over-nested
1826
- * markdown input or a non-content `base`.
1827
- * @param {Content} base
1828
- * @param {string} markdown
1829
- * @returns {{ content: Content; delta: Delta }}
1830
- */
1831
- export function rebase(base, markdown) {
1832
- try {
1833
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1834
- const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1835
- const len0 = WASM_VECTOR_LEN;
1836
- wasm.rebase(retptr, addHeapObject(base), ptr0, len0);
1837
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1838
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1839
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1840
- if (r2) {
1841
- throw takeObject(r1);
1842
- }
1843
- return takeObject(r0);
1844
- } finally {
1845
- wasm.__wbindgen_add_to_stack_pointer(16);
1846
- }
1847
- }
1848
- export function __wbg_Error_960c155d3d49e4c2(arg0, arg1) {
1849
- const ret = Error(getStringFromWasm0(arg0, arg1));
1850
- return addHeapObject(ret);
1851
- }
1852
- export function __wbg_Number_32bf70a599af1d4b(arg0) {
1853
- const ret = Number(getObject(arg0));
1854
- return ret;
1855
- }
1856
- export function __wbg_String_8564e559799eccda(arg0, arg1) {
1857
- const ret = String(getObject(arg1));
1858
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1859
- const len1 = WASM_VECTOR_LEN;
1860
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1861
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1862
- }
1863
- export function __wbg___wbindgen_bigint_get_as_i64_3d3aba5d616c6a51(arg0, arg1) {
1864
- const v = getObject(arg1);
1865
- const ret = typeof(v) === 'bigint' ? v : undefined;
1866
- getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
1867
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1868
- }
1869
- export function __wbg___wbindgen_boolean_get_6ea149f0a8dcc5ff(arg0) {
1870
- const v = getObject(arg0);
1871
- const ret = typeof(v) === 'boolean' ? v : undefined;
1872
- return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
1873
- }
1874
- export function __wbg___wbindgen_debug_string_ab4b34d23d6778bd(arg0, arg1) {
1875
- const ret = debugString(getObject(arg1));
1876
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1877
- const len1 = WASM_VECTOR_LEN;
1878
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1879
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1880
- }
1881
- export function __wbg___wbindgen_in_a5d8b22e52b24dd1(arg0, arg1) {
1882
- const ret = getObject(arg0) in getObject(arg1);
1883
- return ret;
1884
- }
1885
- export function __wbg___wbindgen_is_bigint_ec25c7f91b4d9e93(arg0) {
1886
- const ret = typeof(getObject(arg0)) === 'bigint';
1887
- return ret;
1888
- }
1889
- export function __wbg___wbindgen_is_function_3baa9db1a987f47d(arg0) {
1890
- const ret = typeof(getObject(arg0)) === 'function';
1891
- return ret;
1892
- }
1893
- export function __wbg___wbindgen_is_null_52ff4ec04186736f(arg0) {
1894
- const ret = getObject(arg0) === null;
1895
- return ret;
1896
- }
1897
- export function __wbg___wbindgen_is_object_63322ec0cd6ea4ef(arg0) {
1898
- const val = getObject(arg0);
1899
- const ret = typeof(val) === 'object' && val !== null;
1900
- return ret;
1901
- }
1902
- export function __wbg___wbindgen_is_string_6df3bf7ef1164ed3(arg0) {
1903
- const ret = typeof(getObject(arg0)) === 'string';
1904
- return ret;
1905
- }
1906
- export function __wbg___wbindgen_is_undefined_29a43b4d42920abd(arg0) {
1907
- const ret = getObject(arg0) === undefined;
1908
- return ret;
1909
- }
1910
- export function __wbg___wbindgen_jsval_eq_d3465d8a07697228(arg0, arg1) {
1911
- const ret = getObject(arg0) === getObject(arg1);
1912
- return ret;
1913
- }
1914
- export function __wbg___wbindgen_jsval_loose_eq_cac3565e89b4134c(arg0, arg1) {
1915
- const ret = getObject(arg0) == getObject(arg1);
1916
- return ret;
1917
- }
1918
- export function __wbg___wbindgen_number_get_c7f42aed0525c451(arg0, arg1) {
1919
- const obj = getObject(arg1);
1920
- const ret = typeof(obj) === 'number' ? obj : undefined;
1921
- getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
1922
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1923
- }
1924
- export function __wbg___wbindgen_string_get_7ed5322991caaec5(arg0, arg1) {
1925
- const obj = getObject(arg1);
1926
- const ret = typeof(obj) === 'string' ? obj : undefined;
1927
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1928
- var len1 = WASM_VECTOR_LEN;
1929
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1930
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1931
- }
1932
- export function __wbg___wbindgen_throw_6b64449b9b9ed33c(arg0, arg1) {
1933
- throw new Error(getStringFromWasm0(arg0, arg1));
1934
- }
1935
- export function __wbg_call_14b169f759b26747() { return handleError(function (arg0, arg1) {
1936
- const ret = getObject(arg0).call(getObject(arg1));
1937
- return addHeapObject(ret);
1938
- }, arguments); }
1939
- export function __wbg_done_9158f7cc8751ba32(arg0) {
1940
- const ret = getObject(arg0).done;
1941
- return ret;
1942
- }
1943
- export function __wbg_entries_2bf997cf82353e47(arg0) {
1944
- const ret = getObject(arg0).entries();
1945
- return addHeapObject(ret);
1946
- }
1947
- export function __wbg_entries_e0b73aa8571ddb56(arg0) {
1948
- const ret = Object.entries(getObject(arg0));
1949
- return addHeapObject(ret);
1950
- }
1951
- export function __wbg_error_a6fa202b58aa1cd3(arg0, arg1) {
1952
- let deferred0_0;
1953
- let deferred0_1;
1954
- try {
1955
- deferred0_0 = arg0;
1956
- deferred0_1 = arg1;
1957
- console.error(getStringFromWasm0(arg0, arg1));
1958
- } finally {
1959
- wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
1960
- }
1961
- }
1962
- export function __wbg_from_0dbf29f09e7fb200(arg0) {
1963
- const ret = Array.from(getObject(arg0));
1964
- return addHeapObject(ret);
1965
- }
1966
- export function __wbg_get_1affdbdd5573b16a() { return handleError(function (arg0, arg1) {
1967
- const ret = Reflect.get(getObject(arg0), getObject(arg1));
1968
- return addHeapObject(ret);
1969
- }, arguments); }
1970
- export function __wbg_get_8360291721e2339f(arg0, arg1) {
1971
- const ret = getObject(arg0)[arg1 >>> 0];
1972
- return addHeapObject(ret);
1973
- }
1974
- export function __wbg_get_unchecked_17f53dad852b9588(arg0, arg1) {
1975
- const ret = getObject(arg0)[arg1 >>> 0];
1976
- return addHeapObject(ret);
1977
- }
1978
- export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) {
1979
- const ret = getObject(arg0)[getObject(arg1)];
1980
- return addHeapObject(ret);
1981
- }
1982
- export function __wbg_instanceof_ArrayBuffer_7c8433c6ed14ffe3(arg0) {
1983
- let result;
1984
- try {
1985
- result = getObject(arg0) instanceof ArrayBuffer;
1986
- } catch (_) {
1987
- result = false;
1988
- }
1989
- const ret = result;
1990
- return ret;
1991
- }
1992
- export function __wbg_instanceof_Map_1b76fd4635be43eb(arg0) {
1993
- let result;
1994
- try {
1995
- result = getObject(arg0) instanceof Map;
1996
- } catch (_) {
1997
- result = false;
1998
- }
1999
- const ret = result;
2000
- return ret;
2001
- }
2002
- export function __wbg_instanceof_Object_7c99480a1cdfb911(arg0) {
2003
- let result;
2004
- try {
2005
- result = getObject(arg0) instanceof Object;
2006
- } catch (_) {
2007
- result = false;
2008
- }
2009
- const ret = result;
2010
- return ret;
2011
- }
2012
- export function __wbg_instanceof_Uint8Array_152ba1f289edcf3f(arg0) {
2013
- let result;
2014
- try {
2015
- result = getObject(arg0) instanceof Uint8Array;
2016
- } catch (_) {
2017
- result = false;
2018
- }
2019
- const ret = result;
2020
- return ret;
2021
- }
2022
- export function __wbg_isArray_c3109d14ffc06469(arg0) {
2023
- const ret = Array.isArray(getObject(arg0));
2024
- return ret;
2025
- }
2026
- export function __wbg_isSafeInteger_4fc213d1989d6d2a(arg0) {
2027
- const ret = Number.isSafeInteger(getObject(arg0));
2028
- return ret;
2029
- }
2030
- export function __wbg_iterator_013bc09ec998c2a7() {
2031
- const ret = Symbol.iterator;
2032
- return addHeapObject(ret);
2033
- }
2034
- export function __wbg_keys_2fd1bfdda7e278ca(arg0) {
2035
- const ret = Object.keys(getObject(arg0));
2036
- return addHeapObject(ret);
2037
- }
2038
- export function __wbg_length_3d4ecd04bd8d22f1(arg0) {
2039
- const ret = getObject(arg0).length;
2040
- return ret;
2041
- }
2042
- export function __wbg_length_9f1775224cf1d815(arg0) {
2043
- const ret = getObject(arg0).length;
2044
- return ret;
2045
- }
2046
- export function __wbg_new_0c7403db6e782f19(arg0) {
2047
- const ret = new Uint8Array(getObject(arg0));
2048
- return addHeapObject(ret);
2049
- }
2050
- export function __wbg_new_227d7c05414eb861() {
2051
- const ret = new Error();
2052
- return addHeapObject(ret);
2053
- }
2054
- export function __wbg_new_34d45cc8e36aaead() {
2055
- const ret = new Map();
2056
- return addHeapObject(ret);
2057
- }
2058
- export function __wbg_new_5e360d2ff7b9e1c3(arg0, arg1) {
2059
- const ret = new Error(getStringFromWasm0(arg0, arg1));
2060
- return addHeapObject(ret);
2061
- }
2062
- export function __wbg_new_682678e2f47e32bc() {
2063
- const ret = new Array();
2064
- return addHeapObject(ret);
2065
- }
2066
- export function __wbg_new_aa8d0fa9762c29bd() {
2067
- const ret = new Object();
2068
- return addHeapObject(ret);
2069
- }
2070
- export function __wbg_new_from_slice_b5ea43e23f6008c0(arg0, arg1) {
2071
- const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
2072
- return addHeapObject(ret);
2073
- }
2074
- export function __wbg_next_0340c4ae324393c3() { return handleError(function (arg0) {
2075
- const ret = getObject(arg0).next();
2076
- return addHeapObject(ret);
2077
- }, arguments); }
2078
- export function __wbg_next_7646edaa39458ef7(arg0) {
2079
- const ret = getObject(arg0).next;
2080
- return addHeapObject(ret);
2081
- }
2082
- export function __wbg_prototypesetcall_a6b02eb00b0f4ce2(arg0, arg1, arg2) {
2083
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
2084
- }
2085
- export function __wbg_set_022bee52d0b05b19() { return handleError(function (arg0, arg1, arg2) {
2086
- const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
2087
- return ret;
2088
- }, arguments); }
2089
- export function __wbg_set_3bf1de9fab0cd644(arg0, arg1, arg2) {
2090
- getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
2091
- }
2092
- export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
2093
- getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
2094
- }
2095
- export function __wbg_set_fde2cec06c23692b(arg0, arg1, arg2) {
2096
- const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
2097
- return addHeapObject(ret);
2098
- }
2099
- export function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) {
2100
- const ret = getObject(arg1).stack;
2101
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2102
- const len1 = WASM_VECTOR_LEN;
2103
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2104
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2105
- }
2106
- export function __wbg_value_ee3a06f4579184fa(arg0) {
2107
- const ret = getObject(arg0).value;
2108
- return addHeapObject(ret);
2109
- }
2110
- export function __wbg_values_1e6d547ce555ce44(arg0) {
2111
- const ret = getObject(arg0).values();
2112
- return addHeapObject(ret);
2113
- }
2114
- export function __wbg_values_301a77363cf6c773(arg0) {
2115
- const ret = Object.values(getObject(arg0));
2116
- return addHeapObject(ret);
2117
- }
2118
- export function __wbindgen_cast_0000000000000001(arg0) {
2119
- // Cast intrinsic for `F64 -> Externref`.
2120
- const ret = arg0;
2121
- return addHeapObject(ret);
2122
- }
2123
- export function __wbindgen_cast_0000000000000002(arg0) {
2124
- // Cast intrinsic for `I64 -> Externref`.
2125
- const ret = arg0;
2126
- return addHeapObject(ret);
2127
- }
2128
- export function __wbindgen_cast_0000000000000003(arg0, arg1) {
2129
- // Cast intrinsic for `Ref(String) -> Externref`.
2130
- const ret = getStringFromWasm0(arg0, arg1);
2131
- return addHeapObject(ret);
2132
- }
2133
- export function __wbindgen_cast_0000000000000004(arg0) {
2134
- // Cast intrinsic for `U64 -> Externref`.
2135
- const ret = BigInt.asUintN(64, arg0);
2136
- return addHeapObject(ret);
2137
- }
2138
- export function __wbindgen_object_clone_ref(arg0) {
2139
- const ret = getObject(arg0);
2140
- return addHeapObject(ret);
2141
- }
2142
- export function __wbindgen_object_drop_ref(arg0) {
2143
- takeObject(arg0);
2144
- }
2145
- const DocumentFinalization = (typeof FinalizationRegistry === 'undefined')
2146
- ? { register: () => {}, unregister: () => {} }
2147
- : new FinalizationRegistry(ptr => wasm.__wbg_document_free(ptr >>> 0, 1));
2148
- const QuillFinalization = (typeof FinalizationRegistry === 'undefined')
2149
- ? { register: () => {}, unregister: () => {} }
2150
- : new FinalizationRegistry(ptr => wasm.__wbg_quill_free(ptr >>> 0, 1));
2151
-
2152
- function addHeapObject(obj) {
2153
- if (heap_next === heap.length) heap.push(heap.length + 1);
2154
- const idx = heap_next;
2155
- heap_next = heap[idx];
2156
-
2157
- heap[idx] = obj;
2158
- return idx;
2159
- }
2160
-
2161
- function _assertClass(instance, klass) {
2162
- if (!(instance instanceof klass)) {
2163
- throw new Error(`expected instance of ${klass.name}`);
2164
- }
2165
- }
2166
-
2167
- function debugString(val) {
2168
- // primitive types
2169
- const type = typeof val;
2170
- if (type == 'number' || type == 'boolean' || val == null) {
2171
- return `${val}`;
2172
- }
2173
- if (type == 'string') {
2174
- return `"${val}"`;
2175
- }
2176
- if (type == 'symbol') {
2177
- const description = val.description;
2178
- if (description == null) {
2179
- return 'Symbol';
2180
- } else {
2181
- return `Symbol(${description})`;
2182
- }
2183
- }
2184
- if (type == 'function') {
2185
- const name = val.name;
2186
- if (typeof name == 'string' && name.length > 0) {
2187
- return `Function(${name})`;
2188
- } else {
2189
- return 'Function';
2190
- }
2191
- }
2192
- // objects
2193
- if (Array.isArray(val)) {
2194
- const length = val.length;
2195
- let debug = '[';
2196
- if (length > 0) {
2197
- debug += debugString(val[0]);
2198
- }
2199
- for(let i = 1; i < length; i++) {
2200
- debug += ', ' + debugString(val[i]);
2201
- }
2202
- debug += ']';
2203
- return debug;
2204
- }
2205
- // Test for built-in
2206
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
2207
- let className;
2208
- if (builtInMatches && builtInMatches.length > 1) {
2209
- className = builtInMatches[1];
2210
- } else {
2211
- // Failed to match the standard '[object ClassName]'
2212
- return toString.call(val);
2213
- }
2214
- if (className == 'Object') {
2215
- // we're a user defined class or Object
2216
- // JSON.stringify avoids problems with cycles, and is generally much
2217
- // easier than looping through ownProperties of `val`.
2218
- try {
2219
- return 'Object(' + JSON.stringify(val) + ')';
2220
- } catch (_) {
2221
- return 'Object';
2222
- }
2223
- }
2224
- // errors
2225
- if (val instanceof Error) {
2226
- return `${val.name}: ${val.message}\n${val.stack}`;
2227
- }
2228
- // TODO we could test for more things here, like `Set`s and `Map`s.
2229
- return className;
2230
- }
2231
-
2232
- function dropObject(idx) {
2233
- if (idx < 1028) return;
2234
- heap[idx] = heap_next;
2235
- heap_next = idx;
2236
- }
2237
-
2238
- function getArrayU8FromWasm0(ptr, len) {
2239
- ptr = ptr >>> 0;
2240
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
2241
- }
2242
-
2243
- let cachedDataViewMemory0 = null;
2244
- function getDataViewMemory0() {
2245
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
2246
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
2247
- }
2248
- return cachedDataViewMemory0;
2249
- }
2250
-
2251
- function getStringFromWasm0(ptr, len) {
2252
- ptr = ptr >>> 0;
2253
- return decodeText(ptr, len);
2254
- }
2255
-
2256
- let cachedUint8ArrayMemory0 = null;
2257
- function getUint8ArrayMemory0() {
2258
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
2259
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
2260
- }
2261
- return cachedUint8ArrayMemory0;
2262
- }
2263
-
2264
- function getObject(idx) { return heap[idx]; }
2265
-
2266
- function handleError(f, args) {
2267
- try {
2268
- return f.apply(this, args);
2269
- } catch (e) {
2270
- wasm.__wbindgen_export3(addHeapObject(e));
2271
- }
2272
- }
2273
-
2274
- let heap = new Array(1024).fill(undefined);
2275
- heap.push(undefined, null, true, false);
2276
-
2277
- let heap_next = heap.length;
2278
-
2279
- function isLikeNone(x) {
2280
- return x === undefined || x === null;
2281
- }
2282
-
2283
- function passStringToWasm0(arg, malloc, realloc) {
2284
- if (realloc === undefined) {
2285
- const buf = cachedTextEncoder.encode(arg);
2286
- const ptr = malloc(buf.length, 1) >>> 0;
2287
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
2288
- WASM_VECTOR_LEN = buf.length;
2289
- return ptr;
2290
- }
2291
-
2292
- let len = arg.length;
2293
- let ptr = malloc(len, 1) >>> 0;
2294
-
2295
- const mem = getUint8ArrayMemory0();
2296
-
2297
- let offset = 0;
2298
-
2299
- for (; offset < len; offset++) {
2300
- const code = arg.charCodeAt(offset);
2301
- if (code > 0x7F) break;
2302
- mem[ptr + offset] = code;
2303
- }
2304
- if (offset !== len) {
2305
- if (offset !== 0) {
2306
- arg = arg.slice(offset);
2307
- }
2308
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
2309
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
2310
- const ret = cachedTextEncoder.encodeInto(arg, view);
2311
-
2312
- offset += ret.written;
2313
- ptr = realloc(ptr, len, offset, 1) >>> 0;
2314
- }
2315
-
2316
- WASM_VECTOR_LEN = offset;
2317
- return ptr;
2318
- }
2319
-
2320
- function takeObject(idx) {
2321
- const ret = getObject(idx);
2322
- dropObject(idx);
2323
- return ret;
2324
- }
2325
-
2326
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
2327
- cachedTextDecoder.decode();
2328
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
2329
- let numBytesDecoded = 0;
2330
- function decodeText(ptr, len) {
2331
- numBytesDecoded += len;
2332
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
2333
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
2334
- cachedTextDecoder.decode();
2335
- numBytesDecoded = len;
2336
- }
2337
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
2338
- }
2339
-
2340
- const cachedTextEncoder = new TextEncoder();
2341
-
2342
- if (!('encodeInto' in cachedTextEncoder)) {
2343
- cachedTextEncoder.encodeInto = function (arg, view) {
2344
- const buf = cachedTextEncoder.encode(arg);
2345
- view.set(buf);
2346
- return {
2347
- read: arg.length,
2348
- written: buf.length
2349
- };
2350
- };
2351
- }
2352
-
2353
- let WASM_VECTOR_LEN = 0;
2354
-
2355
-
2356
- let wasm;
2357
- export function __wbg_set_wasm(val) {
2358
- wasm = val;
2359
- }