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