@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.
@@ -1,2882 +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
- /**
1321
- * Live render session: reads (`render`, `paint`, `pageSize`, `regions`,
1322
- * `fieldAt`, `positionAt`, `locate`) serve the current compile. `apply(doc)`
1323
- * recompiles a whole document in place, transactionally (on throw every read
1324
- * keeps serving the last-good compile). Geometry reads reflect the current
1325
- * compile; anchoring a caret across edits is the editor's job: re-read
1326
- * geometry after each committed `apply`.
1327
- *
1328
- * **Empty documents.** A zero-page document yields a valid session
1329
- * (`pageCount === 0`); `paint(ctx, 0)` or `pageSize(0)` throws with
1330
- * `"page index 0 out of range (pageCount=0)"`. Branch on `pageCount === 0`
1331
- * rather than catching the error.
1332
- */
1333
- export class LiveSession {
1334
- static __wrap(ptr) {
1335
- ptr = ptr >>> 0;
1336
- const obj = Object.create(LiveSession.prototype);
1337
- obj.__wbg_ptr = ptr;
1338
- LiveSessionFinalization.register(obj, obj.__wbg_ptr, obj);
1339
- return obj;
1340
- }
1341
- __destroy_into_raw() {
1342
- const ptr = this.__wbg_ptr;
1343
- this.__wbg_ptr = 0;
1344
- LiveSessionFinalization.unregister(this);
1345
- return ptr;
1346
- }
1347
- free() {
1348
- const ptr = this.__destroy_into_raw();
1349
- wasm.__wbg_livesession_free(ptr, 0);
1350
- }
1351
- /**
1352
- * Recompile the session against `doc`: the edit verb of a live preview.
1353
- * The document is compiled through the same schema pipeline as `open`
1354
- * (same quill), then applied transactionally: on throw every read
1355
- * (`render`, `paint`, `pageSize`, `regions`, `fieldAt`) keeps serving the last-good
1356
- * compile, and the session recovers on the next successful `apply`. On
1357
- * success reads serve the new compile; repaint `dirtyPages ∩ visible`.
1358
- * @param {Document} doc
1359
- * @returns {ChangeSet}
1360
- */
1361
- apply(doc) {
1362
- try {
1363
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1364
- _assertClass(doc, Document);
1365
- wasm.livesession_apply(retptr, this.__wbg_ptr, doc.__wbg_ptr);
1366
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1367
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1368
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1369
- if (r2) {
1370
- throw takeObject(r1);
1371
- }
1372
- return takeObject(r0);
1373
- } finally {
1374
- wasm.__wbindgen_add_to_stack_pointer(16);
1375
- }
1376
- }
1377
- /**
1378
- * The backend that produced this session (e.g. `"typst"`).
1379
- * @returns {string}
1380
- */
1381
- get backendId() {
1382
- let deferred1_0;
1383
- let deferred1_1;
1384
- try {
1385
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1386
- wasm.livesession_backendId(retptr, this.__wbg_ptr);
1387
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1388
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1389
- deferred1_0 = r0;
1390
- deferred1_1 = r1;
1391
- return getStringFromWasm0(r0, r1);
1392
- } finally {
1393
- wasm.__wbindgen_add_to_stack_pointer(16);
1394
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1395
- }
1396
- }
1397
- /**
1398
- * The schema field whose content is under a point on `page`, the
1399
- * forward (click → field) direction: hit-test a click against the
1400
- * compiled document and get back the `DocPath` field address to focus in
1401
- * the editor, or `undefined` off any field's ink. `x`/`y` are PDF points
1402
- * with a **bottom-left** origin, the same space as `FieldRegion.rect`,
1403
- * from a canvas click, invert the overlay transform documented on
1404
- * `FieldRegion`: `x = clickPx.x / renderScale`,
1405
- * `y = pageHeightPt - clickPx.y / renderScale`. Unlike `regions()`,
1406
- * *every* placement answers, not just the first.
1407
- * @param {number} page
1408
- * @param {number} x
1409
- * @param {number} y
1410
- * @returns {string | undefined}
1411
- */
1412
- fieldAt(page, x, y) {
1413
- try {
1414
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1415
- wasm.livesession_fieldAt(retptr, this.__wbg_ptr, page, x, y);
1416
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1417
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1418
- let v1;
1419
- if (r0 !== 0) {
1420
- v1 = getStringFromWasm0(r0, r1).slice();
1421
- wasm.__wbindgen_export4(r0, r1 * 1, 1);
1422
- }
1423
- return v1;
1424
- } finally {
1425
- wasm.__wbindgen_add_to_stack_pointer(16);
1426
- }
1427
- }
1428
- /**
1429
- * The whole-field highlight boxes for `field`: one union rect per page,
1430
- * over the field's `span`-bearing content segments. The convenience that
1431
- * owns the union `regions()` leaves derived: it keeps `regions()` the
1432
- * low-level disjoint truth and folds the span-filter + per-page
1433
- * union here, so a "highlight the focused field" consumer stops
1434
- * reimplementing it. **Content only**: a field placed solely as a scalar
1435
- * reference or a bound widget carries no `span` and returns `[]`; its box
1436
- * is a single `regions()` rect. Reflects the current compile, like
1437
- * `regions()`.
1438
- * @param {string} field
1439
- * @returns {FieldRegion[]}
1440
- */
1441
- fieldBoxes(field) {
1442
- try {
1443
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1444
- const ptr0 = passStringToWasm0(field, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1445
- const len0 = WASM_VECTOR_LEN;
1446
- wasm.livesession_fieldBoxes(retptr, this.__wbg_ptr, ptr0, len0);
1447
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1448
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1449
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1450
- if (r2) {
1451
- throw takeObject(r1);
1452
- }
1453
- return takeObject(r0);
1454
- } finally {
1455
- wasm.__wbindgen_add_to_stack_pointer(16);
1456
- }
1457
- }
1458
- /**
1459
- * A content position → **caret rect**, the reverse of `positionAt`: given
1460
- * a field and a USV offset into its `Content`, return the box (in the
1461
- * same bottom-left PDF-point space as `FieldRegion.rect`) to draw a caret
1462
- * at, its `span` collapsed to `[pos, pos]`; `undefined` when the field
1463
- * places no tracked content or the offset maps to no drawn glyph.
1464
- * @param {string} field
1465
- * @param {number} pos
1466
- * @returns {FieldRegion | undefined}
1467
- */
1468
- locate(field, pos) {
1469
- const ptr0 = passStringToWasm0(field, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1470
- const len0 = WASM_VECTOR_LEN;
1471
- const ret = wasm.livesession_locate(this.__wbg_ptr, ptr0, len0, pos);
1472
- return takeObject(ret);
1473
- }
1474
- /**
1475
- * @returns {number}
1476
- */
1477
- get pageCount() {
1478
- const ret = wasm.livesession_pageCount(this.__wbg_ptr);
1479
- return ret >>> 0;
1480
- }
1481
- /**
1482
- * Page dimensions in points (1 pt = 1/72 inch).
1483
- * Throws if the backend has no canvas painter or `page` is out of range.
1484
- * @param {number} page
1485
- * @returns {PageSize}
1486
- */
1487
- pageSize(page) {
1488
- try {
1489
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1490
- wasm.livesession_pageSize(retptr, this.__wbg_ptr, page);
1491
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1492
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1493
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1494
- if (r2) {
1495
- throw takeObject(r1);
1496
- }
1497
- return takeObject(r0);
1498
- } finally {
1499
- wasm.__wbindgen_add_to_stack_pointer(16);
1500
- }
1501
- }
1502
- /**
1503
- * Paint `page` into a `CanvasRenderingContext2D` or
1504
- * `OffscreenCanvasRenderingContext2D`. The painter owns
1505
- * `canvas.width`/`height` (no `clearRect` needed); consumers own
1506
- * `canvas.style.*`. If `layoutScale * densityScale` exceeds 16384 px
1507
- * per side, `densityScale` is clamped: `PaintResult.clamped` reports it and
1508
- * `PaintResult.effectiveDensityScale` carries the density actually applied.
1509
- *
1510
- * `put_image_data` writes the whole backing store, bypassing the 2D
1511
- * context's transform, `globalAlpha`, and clip: the painter owns the entire
1512
- * canvas, so each visible page needs its own `<canvas>`; you cannot composite
1513
- * two pages, a sub-rect, or a context transform through this call.
1514
- *
1515
- * Throws if the backend has no canvas painter, `page` is out of range,
1516
- * `ctx` is the wrong type, or either scale is non-finite or `<= 0`.
1517
- * @param {CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D} ctx
1518
- * @param {number} page
1519
- * @param {PaintOptions | undefined} opts
1520
- * @returns {PaintResult}
1521
- */
1522
- paint(ctx, page, opts) {
1523
- try {
1524
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1525
- wasm.livesession_paint(retptr, this.__wbg_ptr, addHeapObject(ctx), page, addHeapObject(opts));
1526
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1527
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1528
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1529
- if (r2) {
1530
- throw takeObject(r1);
1531
- }
1532
- return takeObject(r0);
1533
- } finally {
1534
- wasm.__wbindgen_add_to_stack_pointer(16);
1535
- }
1536
- }
1537
- /**
1538
- * A point → **content position**, the fine-grained click direction:
1539
- * hit-test a point and get back the field *and* a USV offset into its
1540
- * `Content` (for placing a caret or mapping a selection into the content
1541
- * model), or `undefined` off all content ink. `x`/`y` are PDF points,
1542
- * bottom-left origin: the same space as `fieldAt`. The offset is
1543
- * cluster-exact and degrades to the containing segment's start on
1544
- * origin-less ink (list markers, a code fence's interior). See
1545
- * `ContentHit`.
1546
- * @param {number} page
1547
- * @param {number} x
1548
- * @param {number} y
1549
- * @returns {ContentHit | undefined}
1550
- */
1551
- positionAt(page, x, y) {
1552
- const ret = wasm.livesession_positionAt(this.__wbg_ptr, page, x, y);
1553
- return takeObject(ret);
1554
- }
1555
- /**
1556
- * Schema-field geometry for this compiled session: each content field's
1557
- * **first placement** (one region per page it touches) plus widget and
1558
- * scalar-reference-site regions, keyed on the canonical `DocPath` address
1559
- * (`parseDocPath`-routable; the session resolves the backend's plate-space
1560
- * per-kind ordinal to it); a field may still appear more than once (group
1561
- * by `field`, see `FieldRegion`). A session-level query: no render, no byte
1562
- * artifact. An interactive preview reads it to scroll to / highlight the
1563
- * focused field over a `paint`-ed canvas; the click direction is `fieldAt`.
1564
- * Empty for backends that place no schema fields.
1565
- * @returns {FieldRegion[]}
1566
- */
1567
- regions() {
1568
- try {
1569
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1570
- wasm.livesession_regions(retptr, this.__wbg_ptr);
1571
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1572
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1573
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1574
- if (r2) {
1575
- throw takeObject(r1);
1576
- }
1577
- return takeObject(r0);
1578
- } finally {
1579
- wasm.__wbindgen_add_to_stack_pointer(16);
1580
- }
1581
- }
1582
- /**
1583
- * @param {RenderOptions | null} [opts]
1584
- * @returns {RenderResult}
1585
- */
1586
- render(opts) {
1587
- try {
1588
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1589
- wasm.livesession_render(retptr, this.__wbg_ptr, isLikeNone(opts) ? 0 : addHeapObject(opts));
1590
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1591
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1592
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1593
- if (r2) {
1594
- throw takeObject(r1);
1595
- }
1596
- return takeObject(r0);
1597
- } finally {
1598
- wasm.__wbindgen_add_to_stack_pointer(16);
1599
- }
1600
- }
1601
- /**
1602
- * `true` iff `paint` and `pageSize` will succeed for this session. Derived
1603
- * from the session's canvas seam, so it reflects exactly what `paint` will
1604
- * do: no separately captured flag.
1605
- * @returns {boolean}
1606
- */
1607
- get supportsCanvas() {
1608
- const ret = wasm.livesession_supportsCanvas(this.__wbg_ptr);
1609
- return ret !== 0;
1610
- }
1611
- /**
1612
- * Non-fatal diagnostics of the session's **current compile** (e.g. Typst
1613
- * font fallback): set at open and refreshed by each committed `apply`;
1614
- * a failed apply keeps the last-good compile's warnings. Also appended
1615
- * to `RenderResult.warnings` on each `render()` call.
1616
- * @returns {Diagnostic[]}
1617
- */
1618
- get warnings() {
1619
- try {
1620
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1621
- wasm.livesession_warnings(retptr, this.__wbg_ptr);
1622
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1623
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1624
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1625
- if (r2) {
1626
- throw takeObject(r1);
1627
- }
1628
- return takeObject(r0);
1629
- } finally {
1630
- wasm.__wbindgen_add_to_stack_pointer(16);
1631
- }
1632
- }
1633
- }
1634
- if (Symbol.dispose) LiveSession.prototype[Symbol.dispose] = LiveSession.prototype.free;
1635
-
1636
- export class Quill {
1637
- static __wrap(ptr) {
1638
- ptr = ptr >>> 0;
1639
- const obj = Object.create(Quill.prototype);
1640
- obj.__wbg_ptr = ptr;
1641
- QuillFinalization.register(obj, obj.__wbg_ptr, obj);
1642
- return obj;
1643
- }
1644
- __destroy_into_raw() {
1645
- const ptr = this.__wbg_ptr;
1646
- this.__wbg_ptr = 0;
1647
- QuillFinalization.unregister(this);
1648
- return ptr;
1649
- }
1650
- free() {
1651
- const ptr = this.__destroy_into_raw();
1652
- wasm.__wbg_quill_free(ptr, 0);
1653
- }
1654
- /**
1655
- * The *declared* backend identifier (`config.backend`, e.g. `"typst"`).
1656
- * Intent, not a resolved capability: capability (`supportedFormats` /
1657
- * `supportsCanvas`) is read from the engine.
1658
- * @returns {string}
1659
- */
1660
- get backendId() {
1661
- let deferred1_0;
1662
- let deferred1_1;
1663
- try {
1664
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1665
- wasm.quill_backendId(retptr, this.__wbg_ptr);
1666
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1667
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1668
- deferred1_0 = r0;
1669
- deferred1_1 = r1;
1670
- return getStringFromWasm0(r0, r1);
1671
- } finally {
1672
- wasm.__wbindgen_add_to_stack_pointer(16);
1673
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1674
- }
1675
- }
1676
- /**
1677
- * @returns {string}
1678
- */
1679
- get blueprint() {
1680
- let deferred1_0;
1681
- let deferred1_1;
1682
- try {
1683
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1684
- wasm.quill_blueprint(retptr, this.__wbg_ptr);
1685
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1686
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1687
- deferred1_0 = r0;
1688
- deferred1_1 = r1;
1689
- return getStringFromWasm0(r0, r1);
1690
- } finally {
1691
- wasm.__wbindgen_add_to_stack_pointer(16);
1692
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1693
- }
1694
- }
1695
- /**
1696
- * Land `doc`'s declared content fields at their canonical rest **in
1697
- * place**, returning the `conform::*` diagnostics for the values that would
1698
- * not commit (an empty array when everything rested).
1699
- *
1700
- * The read-repair verb: a document that arrived through the transport door
1701
- * (`fromMarkdown`, `fromJson`, a stored row) converges here, and is then
1702
- * eligible for rewrite under its current schema tag. Idempotent, and a
1703
- * no-op on an already-canonical document: an equal value is not rewritten,
1704
- * so YAML comments and stored bytes survive.
1705
- *
1706
- * A `!must_fill` marker anywhere in a field's value skips that field (the
1707
- * marker is the state), and a value the strict write refuses stays as
1708
- * authored with a diagnostic. Throws when `doc` declares a different
1709
- * `$quill`, before any mutation.
1710
- * @param {Document} doc
1711
- * @returns {Diagnostic[]}
1712
- */
1713
- conform(doc) {
1714
- try {
1715
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1716
- _assertClass(doc, Document);
1717
- wasm.quill_conform(retptr, this.__wbg_ptr, doc.__wbg_ptr);
1718
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1719
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1720
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1721
- if (r2) {
1722
- throw takeObject(r1);
1723
- }
1724
- return takeObject(r0);
1725
- } finally {
1726
- wasm.__wbindgen_add_to_stack_pointer(16);
1727
- }
1728
- }
1729
- /**
1730
- * Build a quill from a file tree. Pure: no backend, no engine; the
1731
- * declared backend is resolved later, at render time.
1732
- *
1733
- * Accepts either a `Map<string, Uint8Array>` or a plain object
1734
- * (`Record<string, Uint8Array>`). Plain objects are walked via
1735
- * `Object.entries` at the boundary; the Rust side sees a single
1736
- * canonical shape.
1737
- * @param {Map<string, Uint8Array>} tree
1738
- * @returns {Quill}
1739
- */
1740
- static fromTree(tree) {
1741
- try {
1742
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1743
- wasm.quill_fromTree(retptr, addHeapObject(tree));
1744
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1745
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1746
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1747
- if (r2) {
1748
- throw takeObject(r1);
1749
- }
1750
- return Quill.__wrap(r0);
1751
- } finally {
1752
- wasm.__wbindgen_add_to_stack_pointer(16);
1753
- }
1754
- }
1755
- /**
1756
- * Identity snapshot of the `quill:` section of `Quill.yaml` plus any extra
1757
- * `quill:` keys. Pure config: the backend's output formats are a
1758
- * resolved-backend capability read from the engine
1759
- * (`Quillmark.supportedFormats`), not part of this snapshot.
1760
- * @returns {QuillMetadata}
1761
- */
1762
- get metadata() {
1763
- try {
1764
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1765
- wasm.quill_metadata(retptr, this.__wbg_ptr);
1766
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1767
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1768
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1769
- if (r2) {
1770
- throw takeObject(r1);
1771
- }
1772
- return takeObject(r0);
1773
- } finally {
1774
- wasm.__wbindgen_add_to_stack_pointer(16);
1775
- }
1776
- }
1777
- /**
1778
- * Parse `markdown` and conform it against this quill: the **primary
1779
- * ingestion path**, and the bound twin of the schema-free
1780
- * `Document.fromMarkdown`. The returned document rests at its canonical
1781
- * form (a `richtext` field as a content object, a `plaintext` field as its
1782
- * literal string), so `getStored` no longer answers "corpus or string?"
1783
- * with "depends how this document was built".
1784
- *
1785
- * Parse warnings and the `conform::*` diagnostics both land on
1786
- * `doc.warnings`. Throws on a parse failure, or when `markdown` declares a
1787
- * `$quill` this quill does not answer to: nothing conforms under the wrong
1788
- * schema. To open a document whose `$quill` is stale, use the transport
1789
- * door (`Document.fromMarkdown`, `setQuillRef`, then `quill.conform`).
1790
- * @param {string} markdown
1791
- * @returns {Document}
1792
- */
1793
- parse(markdown) {
1794
- try {
1795
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1796
- const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1797
- const len0 = WASM_VECTOR_LEN;
1798
- wasm.quill_parse(retptr, this.__wbg_ptr, ptr0, len0);
1799
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1800
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1801
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1802
- if (r2) {
1803
- throw takeObject(r1);
1804
- }
1805
- return Document.__wrap(r0);
1806
- } finally {
1807
- wasm.__wbindgen_add_to_stack_pointer(16);
1808
- }
1809
- }
1810
- /**
1811
- * The resolved-value view of `doc` against this quill's schema: for every
1812
- * declared field the value the render projection would use and the
1813
- * `FieldSource` rung it came from (`"authored" | "default" | "zero"`), in
1814
- * one call. The card body is a `body` sibling on its card (row `name`
1815
- * `"body"`), never a row in `fields`: `null` when the kind enables no body.
1816
- *
1817
- * Value and provenance only: completeness and errors stay `validate`'s
1818
- * (a consumer merges it with its own diagnostic producers regardless), and
1819
- * schema guidance reads from `Quill.schema`.
1820
- * @param {Document} doc
1821
- * @returns {Resolved}
1822
- */
1823
- resolve(doc) {
1824
- try {
1825
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1826
- _assertClass(doc, Document);
1827
- wasm.quill_resolve(retptr, this.__wbg_ptr, doc.__wbg_ptr);
1828
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1829
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1830
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1831
- if (r2) {
1832
- throw takeObject(r1);
1833
- }
1834
- return takeObject(r0);
1835
- } finally {
1836
- wasm.__wbindgen_add_to_stack_pointer(16);
1837
- }
1838
- }
1839
- /**
1840
- * Document schema for the quill: the user-fillable fields plus their
1841
- * `ui` hints (title / group / compact / multiline). The single
1842
- * field-metadata surface: drives form editors and LLM/MCP consumers
1843
- * alike. Key order in `fields`/`properties` is declaration order: the
1844
- * ordering contract. Returns the `QuillSchema` shape.
1845
- * @returns {QuillSchema}
1846
- */
1847
- get schema() {
1848
- try {
1849
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1850
- wasm.quill_schema(retptr, this.__wbg_ptr);
1851
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1852
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1853
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1854
- if (r2) {
1855
- throw takeObject(r1);
1856
- }
1857
- return takeObject(r0);
1858
- } finally {
1859
- wasm.__wbindgen_add_to_stack_pointer(16);
1860
- }
1861
- }
1862
- /**
1863
- * Seed a starter composable `Card` of the given kind (carries `$kind`),
1864
- * layering an optional per-kind seed `overlay` over the schema-example
1865
- * base (`overlay › example › absent`). Returns `undefined` if `cardKind`
1866
- * is not declared in this quill's schema, else a `Card` that feeds
1867
- * straight into `Document.insertCard`.
1868
- *
1869
- * Pass `document.seedOverlay(cardKind)` as `overlay` so a card added to a
1870
- * template-derived document inherits its curated starting values; omit it
1871
- * (or pass `undefined` / `null`) for the bare schema seed. `overlay` is a
1872
- * plain object: this reads the document, it does not mutate it.
1873
- * @param {string} card_kind
1874
- * @param {Record<string, unknown> | undefined} overlay
1875
- * @returns {Card | undefined}
1876
- */
1877
- seedCard(card_kind, overlay) {
1878
- try {
1879
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1880
- const ptr0 = passStringToWasm0(card_kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1881
- const len0 = WASM_VECTOR_LEN;
1882
- wasm.quill_seedCard(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(overlay));
1883
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1884
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1885
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1886
- if (r2) {
1887
- throw takeObject(r1);
1888
- }
1889
- return takeObject(r0);
1890
- } finally {
1891
- wasm.__wbindgen_add_to_stack_pointer(16);
1892
- }
1893
- }
1894
- /**
1895
- * Seed a starter `Document` from the schema, the main card plus one
1896
- * instance of each composable card kind, each committing its fields'
1897
- * `example:` values and leaving every other field absent (interpolated at
1898
- * render: `default:`, else type-empty zero). Illustration-first: a field
1899
- * with both an `example` and a `default` renders its example. See
1900
- * `prose/canon/SCHEMAS.md` § "Document seeding".
1901
- * @returns {Document}
1902
- */
1903
- seedDocument() {
1904
- const ret = wasm.quill_seedDocument(this.__wbg_ptr);
1905
- return Document.__wrap(ret);
1906
- }
1907
- /**
1908
- * Seed a starter main `Card` (carries `$quill`) from the schema: the
1909
- * `$kind: main` card of [`seedDocument`](Self::seed_document) in
1910
- * isolation, committing each field's `example:` value. Returns the same
1911
- * `Card` shape as the `Document.main` getter.
1912
- * @returns {Card}
1913
- */
1914
- seedMain() {
1915
- try {
1916
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1917
- wasm.quill_seedMain(retptr, this.__wbg_ptr);
1918
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1919
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1920
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1921
- if (r2) {
1922
- throw takeObject(r1);
1923
- }
1924
- return takeObject(r0);
1925
- } finally {
1926
- wasm.__wbindgen_add_to_stack_pointer(16);
1927
- }
1928
- }
1929
- /**
1930
- * Flatten this quill back into its canonical file tree: the inverse of
1931
- * [`fromTree`](Self::from_tree). Round-trips: `Quill.fromTree(q.toTree())`
1932
- * reproduces an equivalent quill.
1933
- *
1934
- * This is how a quill crosses a WASM linear-memory boundary as data: a
1935
- * `Quill` built in one build (e.g. the Typst-less `@quillmark/wasm/core`)
1936
- * cannot be passed to an engine in another (separate linear memories), so
1937
- * `@quillmark/wasm/runtime` re-feeds this tree to the backend build's
1938
- * `Quill.fromTree` on demand. Keys are `"/"`-joined relative paths,
1939
- * matching what `fromTree` accepts.
1940
- * @returns {Map<string, Uint8Array>}
1941
- */
1942
- toTree() {
1943
- const ret = wasm.quill_toTree(this.__wbg_ptr);
1944
- return takeObject(ret);
1945
- }
1946
- /**
1947
- * Validate `doc` against this quill's schema, returning every diagnostic
1948
- * (an empty array when the document is valid).
1949
- *
1950
- * Forwards the canonical `validation::*` diagnostics (same `code`,
1951
- * `path`, and `hint` the engine emits) including the non-fatal
1952
- * `validation::must_fill` warning for each `!must_fill` marker left in
1953
- * the document. Field values, defaults, and order are not part of this
1954
- * surface: read them from the `Document` payload and `Quill.schema`
1955
- * (schema key order is display order).
1956
- * @param {Document} doc
1957
- * @returns {Diagnostic[]}
1958
- */
1959
- validate(doc) {
1960
- try {
1961
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1962
- _assertClass(doc, Document);
1963
- wasm.quill_validate(retptr, this.__wbg_ptr, doc.__wbg_ptr);
1964
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1965
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1966
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1967
- if (r2) {
1968
- throw takeObject(r1);
1969
- }
1970
- return takeObject(r0);
1971
- } finally {
1972
- wasm.__wbindgen_add_to_stack_pointer(16);
1973
- }
1974
- }
1975
- }
1976
- if (Symbol.dispose) Quill.prototype[Symbol.dispose] = Quill.prototype.free;
1977
-
1978
- /**
1979
- * Render engine: a backend registry and render dispatcher. Render build only:
1980
- * the core build constructs and validates quills without it.
1981
- */
1982
- export class Quillmark {
1983
- __destroy_into_raw() {
1984
- const ptr = this.__wbg_ptr;
1985
- this.__wbg_ptr = 0;
1986
- QuillmarkFinalization.unregister(this);
1987
- return ptr;
1988
- }
1989
- free() {
1990
- const ptr = this.__destroy_into_raw();
1991
- wasm.__wbg_quillmark_free(ptr, 0);
1992
- }
1993
- constructor() {
1994
- const ret = wasm.quillmark_new();
1995
- this.__wbg_ptr = ret >>> 0;
1996
- QuillmarkFinalization.register(this, this.__wbg_ptr, this);
1997
- return this;
1998
- }
1999
- /**
2000
- * Open a live render session for `doc` against `quill`'s backend.
2001
- * @param {Quill} quill
2002
- * @param {Document} doc
2003
- * @returns {LiveSession}
2004
- */
2005
- open(quill, doc) {
2006
- try {
2007
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2008
- _assertClass(quill, Quill);
2009
- _assertClass(doc, Document);
2010
- wasm.quillmark_open(retptr, this.__wbg_ptr, quill.__wbg_ptr, doc.__wbg_ptr);
2011
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2012
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2013
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2014
- if (r2) {
2015
- throw takeObject(r1);
2016
- }
2017
- return LiveSession.__wrap(r0);
2018
- } finally {
2019
- wasm.__wbindgen_add_to_stack_pointer(16);
2020
- }
2021
- }
2022
- /**
2023
- * Render `doc` against `quill` in one shot. Convenience over `open` +
2024
- * `LiveSession.render`: an unset `output_format` falls back to the
2025
- * backend's first supported format.
2026
- * @param {Quill} quill
2027
- * @param {Document} doc
2028
- * @param {RenderOptions | null} [opts]
2029
- * @returns {RenderResult}
2030
- */
2031
- render(quill, doc, opts) {
2032
- try {
2033
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2034
- _assertClass(quill, Quill);
2035
- _assertClass(doc, Document);
2036
- wasm.quillmark_render(retptr, this.__wbg_ptr, quill.__wbg_ptr, doc.__wbg_ptr, isLikeNone(opts) ? 0 : addHeapObject(opts));
2037
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2038
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2039
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2040
- if (r2) {
2041
- throw takeObject(r1);
2042
- }
2043
- return takeObject(r0);
2044
- } finally {
2045
- wasm.__wbindgen_add_to_stack_pointer(16);
2046
- }
2047
- }
2048
- /**
2049
- * The output formats `quill`'s backend can emit. Static capability:
2050
- * resolves the backend but compiles nothing. Throws `engine::backend_not_found`
2051
- * if no registered backend matches the quill's declared backend.
2052
- * @param {Quill} quill
2053
- * @returns {OutputFormat[]}
2054
- */
2055
- supportedFormats(quill) {
2056
- try {
2057
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2058
- _assertClass(quill, Quill);
2059
- wasm.quillmark_supportedFormats(retptr, this.__wbg_ptr, quill.__wbg_ptr);
2060
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2061
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2062
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2063
- if (r2) {
2064
- throw takeObject(r1);
2065
- }
2066
- return takeObject(r0);
2067
- } finally {
2068
- wasm.__wbindgen_add_to_stack_pointer(16);
2069
- }
2070
- }
2071
- /**
2072
- * Pre-session hint: `true` iff `quill`'s backend can paint sessions to a
2073
- * canvas, derived from the backend's output formats; `false` when the
2074
- * backend is unsupported. Use as a cheap precondition probe before mounting
2075
- * a canvas-based preview UI; the authoritative answer is the session's
2076
- * `supportsCanvas` getter once `open()` has been called.
2077
- * @param {Quill} quill
2078
- * @returns {boolean}
2079
- */
2080
- supportsCanvas(quill) {
2081
- _assertClass(quill, Quill);
2082
- const ret = wasm.quillmark_supportsCanvas(this.__wbg_ptr, quill.__wbg_ptr);
2083
- return ret !== 0;
2084
- }
2085
- }
2086
- if (Symbol.dispose) Quillmark.prototype[Symbol.dispose] = Quillmark.prototype.free;
2087
-
2088
- /**
2089
- * Export a canonical `Content` content to its markdown projection: the pure
2090
- * on-demand codec behind `exportMarkdown(card.body)`. Throws if `rt` is not a
2091
- * canonical content.
2092
- * @param {Content} rt
2093
- * @returns {string}
2094
- */
2095
- export function exportMarkdown(rt) {
2096
- let deferred2_0;
2097
- let deferred2_1;
2098
- try {
2099
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2100
- wasm.exportMarkdown(retptr, addHeapObject(rt));
2101
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2102
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2103
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2104
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2105
- var ptr1 = r0;
2106
- var len1 = r1;
2107
- if (r3) {
2108
- ptr1 = 0; len1 = 0;
2109
- throw takeObject(r2);
2110
- }
2111
- deferred2_0 = ptr1;
2112
- deferred2_1 = len1;
2113
- return getStringFromWasm0(ptr1, len1);
2114
- } finally {
2115
- wasm.__wbindgen_add_to_stack_pointer(16);
2116
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
2117
- }
2118
- }
2119
-
2120
- /**
2121
- * Serialize structured [`DocPathSeg`] segments back to the canonical path
2122
- * string: the inverse of `parseDocPath`, for a consumer that builds a path
2123
- * rather than reads one. Throws on a segment array the deserializer rejects,
2124
- * and on an empty segment array (symmetric with `parseDocPath("")`, which
2125
- * throws "empty path").
2126
- * @param {DocPathSeg[]} segs
2127
- * @returns {string}
2128
- */
2129
- export function formatDocPath(segs) {
2130
- let deferred2_0;
2131
- let deferred2_1;
2132
- try {
2133
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2134
- wasm.formatDocPath(retptr, addHeapObject(segs));
2135
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2136
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2137
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2138
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
2139
- var ptr1 = r0;
2140
- var len1 = r1;
2141
- if (r3) {
2142
- ptr1 = 0; len1 = 0;
2143
- throw takeObject(r2);
2144
- }
2145
- deferred2_0 = ptr1;
2146
- deferred2_1 = len1;
2147
- return getStringFromWasm0(ptr1, len1);
2148
- } finally {
2149
- wasm.__wbindgen_add_to_stack_pointer(16);
2150
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
2151
- }
2152
- }
2153
-
2154
- /**
2155
- * Import a markdown string to a canonical `Content` content: the pure,
2156
- * document-free codec. Pair with `install(addr, importMarkdown(md))` to spell
2157
- * the cold (anchor-losing) write at the call site; prefer `revise` for edit
2158
- * semantics. Throws on an over-nested input.
2159
- * @param {string} markdown
2160
- * @returns {Content}
2161
- */
2162
- export function importMarkdown(markdown) {
2163
- try {
2164
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2165
- const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2166
- const len0 = WASM_VECTOR_LEN;
2167
- wasm.importMarkdown(retptr, ptr0, len0);
2168
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2169
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2170
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2171
- if (r2) {
2172
- throw takeObject(r1);
2173
- }
2174
- return takeObject(r0);
2175
- } finally {
2176
- wasm.__wbindgen_add_to_stack_pointer(16);
2177
- }
2178
- }
2179
-
2180
- /**
2181
- * Initialize the WASM module with panic hooks for better error messages
2182
- */
2183
- export function init() {
2184
- wasm.init();
2185
- }
2186
-
2187
- /**
2188
- * Map a base content position (a USV index into `Content.text`, not a UTF-16
2189
- * offset) through a `delta` to its new USV position: the pure position-mapping
2190
- * codec an editor bridge composes to hold a caret stable across a `revise`.
2191
- * `assoc` decides the side of a same-position insertion (`"after"` moves past
2192
- * it). Throws on a malformed `delta`.
2193
- * @param {Delta} delta
2194
- * @param {number} pos
2195
- * @param {Assoc} assoc
2196
- * @returns {number}
2197
- */
2198
- export function mapPos(delta, pos, assoc) {
2199
- try {
2200
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2201
- wasm.mapPos(retptr, addHeapObject(delta), pos, addHeapObject(assoc));
2202
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2203
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2204
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2205
- if (r2) {
2206
- throw takeObject(r1);
2207
- }
2208
- return r0 >>> 0;
2209
- } finally {
2210
- wasm.__wbindgen_add_to_stack_pointer(16);
2211
- }
2212
- }
2213
-
2214
- /**
2215
- * Parse a canonical document-model `Diagnostic.path`
2216
- * (`cards.<kind>[<i>].<field>`, `main.body`, `recipients[0].name`) into its
2217
- * structured [`DocPathSeg`] segments: the exported inverse of the engine's
2218
- * one path serializer, so a consumer routes on segments instead of regexing
2219
- * the string. Throws on a malformed path.
2220
- * @param {string} path
2221
- * @returns {DocPathSeg[]}
2222
- */
2223
- export function parseDocPath(path) {
2224
- try {
2225
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2226
- const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2227
- const len0 = WASM_VECTOR_LEN;
2228
- wasm.parseDocPath(retptr, ptr0, len0);
2229
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2230
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2231
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2232
- if (r2) {
2233
- throw takeObject(r1);
2234
- }
2235
- return takeObject(r0);
2236
- } finally {
2237
- wasm.__wbindgen_add_to_stack_pointer(16);
2238
- }
2239
- }
2240
-
2241
- /**
2242
- * Rebase `markdown` onto a `base` content, the pure, document-free twin of
2243
- * `revise`: cold-import + `diff_import`, returning the new `content` and the
2244
- * text `delta` (its offsets USV indices into `Content.text`, surviving anchors
2245
- * rebased). Use it to compute a revise without a document in hand; `revise(addr,
2246
- * md)` fuses this with the store for atomicity. Throws on an over-nested
2247
- * markdown input or a non-content `base`.
2248
- * @param {Content} base
2249
- * @param {string} markdown
2250
- * @returns {{ content: Content; delta: Delta }}
2251
- */
2252
- export function rebase(base, markdown) {
2253
- try {
2254
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2255
- const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2256
- const len0 = WASM_VECTOR_LEN;
2257
- wasm.rebase(retptr, addHeapObject(base), ptr0, len0);
2258
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2259
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2260
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2261
- if (r2) {
2262
- throw takeObject(r1);
2263
- }
2264
- return takeObject(r0);
2265
- } finally {
2266
- wasm.__wbindgen_add_to_stack_pointer(16);
2267
- }
2268
- }
2269
- export function __wbg_Error_960c155d3d49e4c2(arg0, arg1) {
2270
- const ret = Error(getStringFromWasm0(arg0, arg1));
2271
- return addHeapObject(ret);
2272
- }
2273
- export function __wbg_Number_32bf70a599af1d4b(arg0) {
2274
- const ret = Number(getObject(arg0));
2275
- return ret;
2276
- }
2277
- export function __wbg_String_8564e559799eccda(arg0, arg1) {
2278
- const ret = String(getObject(arg1));
2279
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2280
- const len1 = WASM_VECTOR_LEN;
2281
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2282
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2283
- }
2284
- export function __wbg___wbindgen_bigint_get_as_i64_3d3aba5d616c6a51(arg0, arg1) {
2285
- const v = getObject(arg1);
2286
- const ret = typeof(v) === 'bigint' ? v : undefined;
2287
- getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
2288
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2289
- }
2290
- export function __wbg___wbindgen_boolean_get_6ea149f0a8dcc5ff(arg0) {
2291
- const v = getObject(arg0);
2292
- const ret = typeof(v) === 'boolean' ? v : undefined;
2293
- return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
2294
- }
2295
- export function __wbg___wbindgen_debug_string_ab4b34d23d6778bd(arg0, arg1) {
2296
- const ret = debugString(getObject(arg1));
2297
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2298
- const len1 = WASM_VECTOR_LEN;
2299
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2300
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2301
- }
2302
- export function __wbg___wbindgen_in_a5d8b22e52b24dd1(arg0, arg1) {
2303
- const ret = getObject(arg0) in getObject(arg1);
2304
- return ret;
2305
- }
2306
- export function __wbg___wbindgen_is_bigint_ec25c7f91b4d9e93(arg0) {
2307
- const ret = typeof(getObject(arg0)) === 'bigint';
2308
- return ret;
2309
- }
2310
- export function __wbg___wbindgen_is_function_3baa9db1a987f47d(arg0) {
2311
- const ret = typeof(getObject(arg0)) === 'function';
2312
- return ret;
2313
- }
2314
- export function __wbg___wbindgen_is_null_52ff4ec04186736f(arg0) {
2315
- const ret = getObject(arg0) === null;
2316
- return ret;
2317
- }
2318
- export function __wbg___wbindgen_is_object_63322ec0cd6ea4ef(arg0) {
2319
- const val = getObject(arg0);
2320
- const ret = typeof(val) === 'object' && val !== null;
2321
- return ret;
2322
- }
2323
- export function __wbg___wbindgen_is_string_6df3bf7ef1164ed3(arg0) {
2324
- const ret = typeof(getObject(arg0)) === 'string';
2325
- return ret;
2326
- }
2327
- export function __wbg___wbindgen_is_undefined_29a43b4d42920abd(arg0) {
2328
- const ret = getObject(arg0) === undefined;
2329
- return ret;
2330
- }
2331
- export function __wbg___wbindgen_jsval_eq_d3465d8a07697228(arg0, arg1) {
2332
- const ret = getObject(arg0) === getObject(arg1);
2333
- return ret;
2334
- }
2335
- export function __wbg___wbindgen_jsval_loose_eq_cac3565e89b4134c(arg0, arg1) {
2336
- const ret = getObject(arg0) == getObject(arg1);
2337
- return ret;
2338
- }
2339
- export function __wbg___wbindgen_number_get_c7f42aed0525c451(arg0, arg1) {
2340
- const obj = getObject(arg1);
2341
- const ret = typeof(obj) === 'number' ? obj : undefined;
2342
- getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
2343
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2344
- }
2345
- export function __wbg___wbindgen_string_get_7ed5322991caaec5(arg0, arg1) {
2346
- const obj = getObject(arg1);
2347
- const ret = typeof(obj) === 'string' ? obj : undefined;
2348
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2349
- var len1 = WASM_VECTOR_LEN;
2350
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2351
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2352
- }
2353
- export function __wbg___wbindgen_throw_6b64449b9b9ed33c(arg0, arg1) {
2354
- throw new Error(getStringFromWasm0(arg0, arg1));
2355
- }
2356
- export function __wbg_call_14b169f759b26747() { return handleError(function (arg0, arg1) {
2357
- const ret = getObject(arg0).call(getObject(arg1));
2358
- return addHeapObject(ret);
2359
- }, arguments); }
2360
- export function __wbg_canvas_2c0c6d263d4c52ad(arg0) {
2361
- const ret = getObject(arg0).canvas;
2362
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
2363
- }
2364
- export function __wbg_canvas_374da9f3c5b3dd0e(arg0) {
2365
- const ret = getObject(arg0).canvas;
2366
- return addHeapObject(ret);
2367
- }
2368
- export function __wbg_done_9158f7cc8751ba32(arg0) {
2369
- const ret = getObject(arg0).done;
2370
- return ret;
2371
- }
2372
- export function __wbg_entries_2bf997cf82353e47(arg0) {
2373
- const ret = getObject(arg0).entries();
2374
- return addHeapObject(ret);
2375
- }
2376
- export function __wbg_entries_e0b73aa8571ddb56(arg0) {
2377
- const ret = Object.entries(getObject(arg0));
2378
- return addHeapObject(ret);
2379
- }
2380
- export function __wbg_error_a6fa202b58aa1cd3(arg0, arg1) {
2381
- let deferred0_0;
2382
- let deferred0_1;
2383
- try {
2384
- deferred0_0 = arg0;
2385
- deferred0_1 = arg1;
2386
- console.error(getStringFromWasm0(arg0, arg1));
2387
- } finally {
2388
- wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
2389
- }
2390
- }
2391
- export function __wbg_from_0dbf29f09e7fb200(arg0) {
2392
- const ret = Array.from(getObject(arg0));
2393
- return addHeapObject(ret);
2394
- }
2395
- export function __wbg_getTime_da7c55f52b71e8c6(arg0) {
2396
- const ret = getObject(arg0).getTime();
2397
- return ret;
2398
- }
2399
- export function __wbg_getUTCDate_5cd8b68e971333f7(arg0) {
2400
- const ret = getObject(arg0).getUTCDate();
2401
- return ret;
2402
- }
2403
- export function __wbg_getUTCFullYear_f3b3950a0ccb9165(arg0) {
2404
- const ret = getObject(arg0).getUTCFullYear();
2405
- return ret;
2406
- }
2407
- export function __wbg_getUTCMonth_62fa72a7522ef806(arg0) {
2408
- const ret = getObject(arg0).getUTCMonth();
2409
- return ret;
2410
- }
2411
- export function __wbg_get_1affdbdd5573b16a() { return handleError(function (arg0, arg1) {
2412
- const ret = Reflect.get(getObject(arg0), getObject(arg1));
2413
- return addHeapObject(ret);
2414
- }, arguments); }
2415
- export function __wbg_get_8360291721e2339f(arg0, arg1) {
2416
- const ret = getObject(arg0)[arg1 >>> 0];
2417
- return addHeapObject(ret);
2418
- }
2419
- export function __wbg_get_unchecked_17f53dad852b9588(arg0, arg1) {
2420
- const ret = getObject(arg0)[arg1 >>> 0];
2421
- return addHeapObject(ret);
2422
- }
2423
- export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) {
2424
- const ret = getObject(arg0)[getObject(arg1)];
2425
- return addHeapObject(ret);
2426
- }
2427
- export function __wbg_instanceof_ArrayBuffer_7c8433c6ed14ffe3(arg0) {
2428
- let result;
2429
- try {
2430
- result = getObject(arg0) instanceof ArrayBuffer;
2431
- } catch (_) {
2432
- result = false;
2433
- }
2434
- const ret = result;
2435
- return ret;
2436
- }
2437
- export function __wbg_instanceof_CanvasRenderingContext2d_24a3fe06e62b98d7(arg0) {
2438
- let result;
2439
- try {
2440
- result = getObject(arg0) instanceof CanvasRenderingContext2D;
2441
- } catch (_) {
2442
- result = false;
2443
- }
2444
- const ret = result;
2445
- return ret;
2446
- }
2447
- export function __wbg_instanceof_Map_1b76fd4635be43eb(arg0) {
2448
- let result;
2449
- try {
2450
- result = getObject(arg0) instanceof Map;
2451
- } catch (_) {
2452
- result = false;
2453
- }
2454
- const ret = result;
2455
- return ret;
2456
- }
2457
- export function __wbg_instanceof_Object_7c99480a1cdfb911(arg0) {
2458
- let result;
2459
- try {
2460
- result = getObject(arg0) instanceof Object;
2461
- } catch (_) {
2462
- result = false;
2463
- }
2464
- const ret = result;
2465
- return ret;
2466
- }
2467
- export function __wbg_instanceof_OffscreenCanvasRenderingContext2d_285a274020b4f230(arg0) {
2468
- let result;
2469
- try {
2470
- result = getObject(arg0) instanceof OffscreenCanvasRenderingContext2D;
2471
- } catch (_) {
2472
- result = false;
2473
- }
2474
- const ret = result;
2475
- return ret;
2476
- }
2477
- export function __wbg_instanceof_Uint8Array_152ba1f289edcf3f(arg0) {
2478
- let result;
2479
- try {
2480
- result = getObject(arg0) instanceof Uint8Array;
2481
- } catch (_) {
2482
- result = false;
2483
- }
2484
- const ret = result;
2485
- return ret;
2486
- }
2487
- export function __wbg_isArray_c3109d14ffc06469(arg0) {
2488
- const ret = Array.isArray(getObject(arg0));
2489
- return ret;
2490
- }
2491
- export function __wbg_isSafeInteger_4fc213d1989d6d2a(arg0) {
2492
- const ret = Number.isSafeInteger(getObject(arg0));
2493
- return ret;
2494
- }
2495
- export function __wbg_iterator_013bc09ec998c2a7() {
2496
- const ret = Symbol.iterator;
2497
- return addHeapObject(ret);
2498
- }
2499
- export function __wbg_keys_2fd1bfdda7e278ca(arg0) {
2500
- const ret = Object.keys(getObject(arg0));
2501
- return addHeapObject(ret);
2502
- }
2503
- export function __wbg_length_3d4ecd04bd8d22f1(arg0) {
2504
- const ret = getObject(arg0).length;
2505
- return ret;
2506
- }
2507
- export function __wbg_length_9f1775224cf1d815(arg0) {
2508
- const ret = getObject(arg0).length;
2509
- return ret;
2510
- }
2511
- export function __wbg_new_0_4d657201ced14de3() {
2512
- const ret = new Date();
2513
- return addHeapObject(ret);
2514
- }
2515
- export function __wbg_new_0c7403db6e782f19(arg0) {
2516
- const ret = new Uint8Array(getObject(arg0));
2517
- return addHeapObject(ret);
2518
- }
2519
- export function __wbg_new_227d7c05414eb861() {
2520
- const ret = new Error();
2521
- return addHeapObject(ret);
2522
- }
2523
- export function __wbg_new_34d45cc8e36aaead() {
2524
- const ret = new Map();
2525
- return addHeapObject(ret);
2526
- }
2527
- export function __wbg_new_5e360d2ff7b9e1c3(arg0, arg1) {
2528
- const ret = new Error(getStringFromWasm0(arg0, arg1));
2529
- return addHeapObject(ret);
2530
- }
2531
- export function __wbg_new_682678e2f47e32bc() {
2532
- const ret = new Array();
2533
- return addHeapObject(ret);
2534
- }
2535
- export function __wbg_new_7913666fe5070684(arg0) {
2536
- const ret = new Date(getObject(arg0));
2537
- return addHeapObject(ret);
2538
- }
2539
- export function __wbg_new_aa8d0fa9762c29bd() {
2540
- const ret = new Object();
2541
- return addHeapObject(ret);
2542
- }
2543
- export function __wbg_new_from_slice_b5ea43e23f6008c0(arg0, arg1) {
2544
- const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
2545
- return addHeapObject(ret);
2546
- }
2547
- export function __wbg_new_with_u8_clamped_array_and_sh_fe957411824b5158() { return handleError(function (arg0, arg1, arg2, arg3) {
2548
- const ret = new ImageData(getClampedArrayU8FromWasm0(arg0, arg1), arg2 >>> 0, arg3 >>> 0);
2549
- return addHeapObject(ret);
2550
- }, arguments); }
2551
- export function __wbg_next_0340c4ae324393c3() { return handleError(function (arg0) {
2552
- const ret = getObject(arg0).next();
2553
- return addHeapObject(ret);
2554
- }, arguments); }
2555
- export function __wbg_next_7646edaa39458ef7(arg0) {
2556
- const ret = getObject(arg0).next;
2557
- return addHeapObject(ret);
2558
- }
2559
- export function __wbg_now_a9b7df1cbee90986() {
2560
- const ret = Date.now();
2561
- return ret;
2562
- }
2563
- export function __wbg_prototypesetcall_a6b02eb00b0f4ce2(arg0, arg1, arg2) {
2564
- Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
2565
- }
2566
- export function __wbg_putImageData_c810e62ea70e761d() { return handleError(function (arg0, arg1, arg2, arg3) {
2567
- getObject(arg0).putImageData(getObject(arg1), arg2, arg3);
2568
- }, arguments); }
2569
- export function __wbg_putImageData_cb4de9afd58963be() { return handleError(function (arg0, arg1, arg2, arg3) {
2570
- getObject(arg0).putImageData(getObject(arg1), arg2, arg3);
2571
- }, arguments); }
2572
- export function __wbg_set_022bee52d0b05b19() { return handleError(function (arg0, arg1, arg2) {
2573
- const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
2574
- return ret;
2575
- }, arguments); }
2576
- export function __wbg_set_3bf1de9fab0cd644(arg0, arg1, arg2) {
2577
- getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
2578
- }
2579
- export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
2580
- getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
2581
- }
2582
- export function __wbg_set_fde2cec06c23692b(arg0, arg1, arg2) {
2583
- const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
2584
- return addHeapObject(ret);
2585
- }
2586
- export function __wbg_set_height_24d07d982f176ac6(arg0, arg1) {
2587
- getObject(arg0).height = arg1 >>> 0;
2588
- }
2589
- export function __wbg_set_height_be9b2b920bd68401(arg0, arg1) {
2590
- getObject(arg0).height = arg1 >>> 0;
2591
- }
2592
- export function __wbg_set_width_5cda41d4d06a14dd(arg0, arg1) {
2593
- getObject(arg0).width = arg1 >>> 0;
2594
- }
2595
- export function __wbg_set_width_adc925bca9c5351a(arg0, arg1) {
2596
- getObject(arg0).width = arg1 >>> 0;
2597
- }
2598
- export function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) {
2599
- const ret = getObject(arg1).stack;
2600
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2601
- const len1 = WASM_VECTOR_LEN;
2602
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2603
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2604
- }
2605
- export function __wbg_value_ee3a06f4579184fa(arg0) {
2606
- const ret = getObject(arg0).value;
2607
- return addHeapObject(ret);
2608
- }
2609
- export function __wbg_values_1e6d547ce555ce44(arg0) {
2610
- const ret = getObject(arg0).values();
2611
- return addHeapObject(ret);
2612
- }
2613
- export function __wbg_values_301a77363cf6c773(arg0) {
2614
- const ret = Object.values(getObject(arg0));
2615
- return addHeapObject(ret);
2616
- }
2617
- export function __wbindgen_cast_0000000000000001(arg0) {
2618
- // Cast intrinsic for `F64 -> Externref`.
2619
- const ret = arg0;
2620
- return addHeapObject(ret);
2621
- }
2622
- export function __wbindgen_cast_0000000000000002(arg0) {
2623
- // Cast intrinsic for `I64 -> Externref`.
2624
- const ret = arg0;
2625
- return addHeapObject(ret);
2626
- }
2627
- export function __wbindgen_cast_0000000000000003(arg0, arg1) {
2628
- // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
2629
- const ret = getArrayU8FromWasm0(arg0, arg1);
2630
- return addHeapObject(ret);
2631
- }
2632
- export function __wbindgen_cast_0000000000000004(arg0, arg1) {
2633
- // Cast intrinsic for `Ref(String) -> Externref`.
2634
- const ret = getStringFromWasm0(arg0, arg1);
2635
- return addHeapObject(ret);
2636
- }
2637
- export function __wbindgen_cast_0000000000000005(arg0) {
2638
- // Cast intrinsic for `U64 -> Externref`.
2639
- const ret = BigInt.asUintN(64, arg0);
2640
- return addHeapObject(ret);
2641
- }
2642
- export function __wbindgen_object_clone_ref(arg0) {
2643
- const ret = getObject(arg0);
2644
- return addHeapObject(ret);
2645
- }
2646
- export function __wbindgen_object_drop_ref(arg0) {
2647
- takeObject(arg0);
2648
- }
2649
- const DocumentFinalization = (typeof FinalizationRegistry === 'undefined')
2650
- ? { register: () => {}, unregister: () => {} }
2651
- : new FinalizationRegistry(ptr => wasm.__wbg_document_free(ptr >>> 0, 1));
2652
- const LiveSessionFinalization = (typeof FinalizationRegistry === 'undefined')
2653
- ? { register: () => {}, unregister: () => {} }
2654
- : new FinalizationRegistry(ptr => wasm.__wbg_livesession_free(ptr >>> 0, 1));
2655
- const QuillFinalization = (typeof FinalizationRegistry === 'undefined')
2656
- ? { register: () => {}, unregister: () => {} }
2657
- : new FinalizationRegistry(ptr => wasm.__wbg_quill_free(ptr >>> 0, 1));
2658
- const QuillmarkFinalization = (typeof FinalizationRegistry === 'undefined')
2659
- ? { register: () => {}, unregister: () => {} }
2660
- : new FinalizationRegistry(ptr => wasm.__wbg_quillmark_free(ptr >>> 0, 1));
2661
-
2662
- function addHeapObject(obj) {
2663
- if (heap_next === heap.length) heap.push(heap.length + 1);
2664
- const idx = heap_next;
2665
- heap_next = heap[idx];
2666
-
2667
- heap[idx] = obj;
2668
- return idx;
2669
- }
2670
-
2671
- function _assertClass(instance, klass) {
2672
- if (!(instance instanceof klass)) {
2673
- throw new Error(`expected instance of ${klass.name}`);
2674
- }
2675
- }
2676
-
2677
- function debugString(val) {
2678
- // primitive types
2679
- const type = typeof val;
2680
- if (type == 'number' || type == 'boolean' || val == null) {
2681
- return `${val}`;
2682
- }
2683
- if (type == 'string') {
2684
- return `"${val}"`;
2685
- }
2686
- if (type == 'symbol') {
2687
- const description = val.description;
2688
- if (description == null) {
2689
- return 'Symbol';
2690
- } else {
2691
- return `Symbol(${description})`;
2692
- }
2693
- }
2694
- if (type == 'function') {
2695
- const name = val.name;
2696
- if (typeof name == 'string' && name.length > 0) {
2697
- return `Function(${name})`;
2698
- } else {
2699
- return 'Function';
2700
- }
2701
- }
2702
- // objects
2703
- if (Array.isArray(val)) {
2704
- const length = val.length;
2705
- let debug = '[';
2706
- if (length > 0) {
2707
- debug += debugString(val[0]);
2708
- }
2709
- for(let i = 1; i < length; i++) {
2710
- debug += ', ' + debugString(val[i]);
2711
- }
2712
- debug += ']';
2713
- return debug;
2714
- }
2715
- // Test for built-in
2716
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
2717
- let className;
2718
- if (builtInMatches && builtInMatches.length > 1) {
2719
- className = builtInMatches[1];
2720
- } else {
2721
- // Failed to match the standard '[object ClassName]'
2722
- return toString.call(val);
2723
- }
2724
- if (className == 'Object') {
2725
- // we're a user defined class or Object
2726
- // JSON.stringify avoids problems with cycles, and is generally much
2727
- // easier than looping through ownProperties of `val`.
2728
- try {
2729
- return 'Object(' + JSON.stringify(val) + ')';
2730
- } catch (_) {
2731
- return 'Object';
2732
- }
2733
- }
2734
- // errors
2735
- if (val instanceof Error) {
2736
- return `${val.name}: ${val.message}\n${val.stack}`;
2737
- }
2738
- // TODO we could test for more things here, like `Set`s and `Map`s.
2739
- return className;
2740
- }
2741
-
2742
- function dropObject(idx) {
2743
- if (idx < 1028) return;
2744
- heap[idx] = heap_next;
2745
- heap_next = idx;
2746
- }
2747
-
2748
- function getArrayU8FromWasm0(ptr, len) {
2749
- ptr = ptr >>> 0;
2750
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
2751
- }
2752
-
2753
- function getClampedArrayU8FromWasm0(ptr, len) {
2754
- ptr = ptr >>> 0;
2755
- return getUint8ClampedArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
2756
- }
2757
-
2758
- let cachedDataViewMemory0 = null;
2759
- function getDataViewMemory0() {
2760
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
2761
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
2762
- }
2763
- return cachedDataViewMemory0;
2764
- }
2765
-
2766
- function getStringFromWasm0(ptr, len) {
2767
- ptr = ptr >>> 0;
2768
- return decodeText(ptr, len);
2769
- }
2770
-
2771
- let cachedUint8ArrayMemory0 = null;
2772
- function getUint8ArrayMemory0() {
2773
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
2774
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
2775
- }
2776
- return cachedUint8ArrayMemory0;
2777
- }
2778
-
2779
- let cachedUint8ClampedArrayMemory0 = null;
2780
- function getUint8ClampedArrayMemory0() {
2781
- if (cachedUint8ClampedArrayMemory0 === null || cachedUint8ClampedArrayMemory0.byteLength === 0) {
2782
- cachedUint8ClampedArrayMemory0 = new Uint8ClampedArray(wasm.memory.buffer);
2783
- }
2784
- return cachedUint8ClampedArrayMemory0;
2785
- }
2786
-
2787
- function getObject(idx) { return heap[idx]; }
2788
-
2789
- function handleError(f, args) {
2790
- try {
2791
- return f.apply(this, args);
2792
- } catch (e) {
2793
- wasm.__wbindgen_export3(addHeapObject(e));
2794
- }
2795
- }
2796
-
2797
- let heap = new Array(1024).fill(undefined);
2798
- heap.push(undefined, null, true, false);
2799
-
2800
- let heap_next = heap.length;
2801
-
2802
- function isLikeNone(x) {
2803
- return x === undefined || x === null;
2804
- }
2805
-
2806
- function passStringToWasm0(arg, malloc, realloc) {
2807
- if (realloc === undefined) {
2808
- const buf = cachedTextEncoder.encode(arg);
2809
- const ptr = malloc(buf.length, 1) >>> 0;
2810
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
2811
- WASM_VECTOR_LEN = buf.length;
2812
- return ptr;
2813
- }
2814
-
2815
- let len = arg.length;
2816
- let ptr = malloc(len, 1) >>> 0;
2817
-
2818
- const mem = getUint8ArrayMemory0();
2819
-
2820
- let offset = 0;
2821
-
2822
- for (; offset < len; offset++) {
2823
- const code = arg.charCodeAt(offset);
2824
- if (code > 0x7F) break;
2825
- mem[ptr + offset] = code;
2826
- }
2827
- if (offset !== len) {
2828
- if (offset !== 0) {
2829
- arg = arg.slice(offset);
2830
- }
2831
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
2832
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
2833
- const ret = cachedTextEncoder.encodeInto(arg, view);
2834
-
2835
- offset += ret.written;
2836
- ptr = realloc(ptr, len, offset, 1) >>> 0;
2837
- }
2838
-
2839
- WASM_VECTOR_LEN = offset;
2840
- return ptr;
2841
- }
2842
-
2843
- function takeObject(idx) {
2844
- const ret = getObject(idx);
2845
- dropObject(idx);
2846
- return ret;
2847
- }
2848
-
2849
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
2850
- cachedTextDecoder.decode();
2851
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
2852
- let numBytesDecoded = 0;
2853
- function decodeText(ptr, len) {
2854
- numBytesDecoded += len;
2855
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
2856
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
2857
- cachedTextDecoder.decode();
2858
- numBytesDecoded = len;
2859
- }
2860
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
2861
- }
2862
-
2863
- const cachedTextEncoder = new TextEncoder();
2864
-
2865
- if (!('encodeInto' in cachedTextEncoder)) {
2866
- cachedTextEncoder.encodeInto = function (arg, view) {
2867
- const buf = cachedTextEncoder.encode(arg);
2868
- view.set(buf);
2869
- return {
2870
- read: arg.length,
2871
- written: buf.length
2872
- };
2873
- };
2874
- }
2875
-
2876
- let WASM_VECTOR_LEN = 0;
2877
-
2878
-
2879
- let wasm;
2880
- export function __wbg_set_wasm(val) {
2881
- wasm = val;
2882
- }