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