@quillmark/wasm 0.92.1 → 0.95.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +301 -4
- package/README.md +167 -66
- package/backends/pdfform/wasm.d.ts +1066 -0
- package/backends/pdfform/wasm.js +9 -0
- package/backends/pdfform/wasm_bg.js +2654 -0
- package/backends/pdfform/wasm_bg.wasm +0 -0
- package/backends/pdfform/wasm_bg.wasm.d.ts +98 -0
- package/backends/typst/wasm.d.ts +584 -167
- package/backends/typst/wasm.js +1 -1
- package/backends/typst/wasm_bg.js +1047 -397
- package/backends/typst/wasm_bg.wasm +0 -0
- package/backends/typst/wasm_bg.wasm.d.ts +45 -25
- package/core/wasm.d.ts +412 -110
- package/core/wasm.js +1 -1
- package/core/wasm_bg.js +713 -226
- package/core/wasm_bg.wasm +0 -0
- package/core/wasm_bg.wasm.d.ts +31 -17
- package/package.json +4 -3
- package/runtime/runtime.d.ts +459 -21
- package/runtime/runtime.js +536 -30
|
@@ -19,6 +19,218 @@ export class Document {
|
|
|
19
19
|
const ptr = this.__destroy_into_raw();
|
|
20
20
|
wasm.__wbg_document_free(ptr, 0);
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Build a composable card of `kind`, typed-commit `fields` onto it, set its
|
|
24
|
+
* body from optional markdown, and place it — the ABI under `writer.addCard`.
|
|
25
|
+
* `at` picks the position: absent appends, a number inserts at that index
|
|
26
|
+
* (`0..=cards.length`), so a positioned typed insert is one atomic call
|
|
27
|
+
* rather than `addCard` + `moveCard`. Fuses `makeCard` + typed commit +
|
|
28
|
+
* insertion transactionally: the card is committed in full before it joins
|
|
29
|
+
* the document, so a rejected field (or an invalid kind, body, or
|
|
30
|
+
* out-of-range `at`) leaves the document untouched. Field errors throw the
|
|
31
|
+
* same per-field diagnostic bundle as [`commitFields`](Self::commit_fields),
|
|
32
|
+
* including an `[EditError::UnknownField]` per undeclared name; an invalid
|
|
33
|
+
* kind or body, or an out-of-range position, throws a single-entry bundle
|
|
34
|
+
* keyed `$kind` / `$body`.
|
|
35
|
+
* @param {Quill} quill
|
|
36
|
+
* @param {string} kind
|
|
37
|
+
* @param {Record<string, unknown>} [fields]
|
|
38
|
+
* @param {string} [body]
|
|
39
|
+
* @param {number} [at]
|
|
40
|
+
*/
|
|
41
|
+
_addCard(quill, kind, fields, body, at) {
|
|
42
|
+
try {
|
|
43
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
44
|
+
_assertClass(quill, Quill);
|
|
45
|
+
const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
46
|
+
const len0 = WASM_VECTOR_LEN;
|
|
47
|
+
var ptr1 = isLikeNone(body) ? 0 : passStringToWasm0(body, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
48
|
+
var len1 = WASM_VECTOR_LEN;
|
|
49
|
+
wasm.document__addCard(retptr, this.__wbg_ptr, quill.__wbg_ptr, ptr0, len0, isLikeNone(fields) ? 0 : addHeapObject(fields), ptr1, len1, isLikeNone(at) ? 0x100000001 : (at) >>> 0);
|
|
50
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
51
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
52
|
+
if (r1) {
|
|
53
|
+
throw takeObject(r0);
|
|
54
|
+
}
|
|
55
|
+
} finally {
|
|
56
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Typed field write at `addr`, resolving the field's schema `type` from
|
|
61
|
+
* `quill` — the stable ABI under the runtime `writer.set` / `writer.card(i).set`.
|
|
62
|
+
* The one write verb for **every** field type (richtext, scalar, array,
|
|
63
|
+
* object); the schema carries the `inline` constraint, so no type token or
|
|
64
|
+
* flag is passed. A richtext-typed field stores the canonical content, so
|
|
65
|
+
* identity marks (anchors, island ids) and content-only marks (e.g.
|
|
66
|
+
* `underline`) live on it and survive compiles and the storage DTO. Values
|
|
67
|
+
* use the encoding the seam already speaks: a content object or markdown
|
|
68
|
+
* string for richtext, a scalar/array/object otherwise.
|
|
69
|
+
*
|
|
70
|
+
* A bare string is `Addr` shorthand for `{ field }`; `{ card, field }`
|
|
71
|
+
* targets a composable card (its `$kind` resolves the schema). A body
|
|
72
|
+
* address throws — a body has no field schema; write it with `writer.setBody`
|
|
73
|
+
* / `revise`. A field declared in the schema is strict-committed (a mismatch
|
|
74
|
+
* throws now, not at render); a name the schema does not declare throws
|
|
75
|
+
* `[EditError::UnknownField]` rather than falling to the opaque store — on
|
|
76
|
+
* the typed path it is a typo. Use [`storeField`](Document::store_field) for
|
|
77
|
+
* opaque storage. Also throws `[EditError::FieldConform]` /
|
|
78
|
+
* `[EditError::FieldRichtextDecode]` / `[EditError::FieldRichtextNotInline]`
|
|
79
|
+
* on a typed mismatch, `[EditError::InvalidFieldName]` on a malformed name,
|
|
80
|
+
* and `[EditError::IndexOutOfRange]` on an out-of-range card.
|
|
81
|
+
*
|
|
82
|
+
* The `quill` handle is passed per call because a `Document` carries only a
|
|
83
|
+
* `$quill` reference, not the resolved schema.
|
|
84
|
+
* @param {Quill} quill
|
|
85
|
+
* @param {Addr | string} addr
|
|
86
|
+
* @param {any} value
|
|
87
|
+
*/
|
|
88
|
+
_commitField(quill, addr, value) {
|
|
89
|
+
try {
|
|
90
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
91
|
+
_assertClass(quill, Quill);
|
|
92
|
+
wasm.document__commitField(retptr, this.__wbg_ptr, quill.__wbg_ptr, addHeapObject(addr), addHeapObject(value));
|
|
93
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
94
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
95
|
+
if (r1) {
|
|
96
|
+
throw takeObject(r0);
|
|
97
|
+
}
|
|
98
|
+
} finally {
|
|
99
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Batched twin of [`commitField`](Document::commit_field): typed-commit
|
|
104
|
+
* several fields on the card `addr` targets atomically, resolving each
|
|
105
|
+
* field's schema `type` from `quill`. `addr` is a **card address**
|
|
106
|
+
* (`{ card }`, absent = main; a present `field` throws). All-or-nothing with
|
|
107
|
+
* the same per-field-diagnostic error contract as
|
|
108
|
+
* [`storeFields`](Document::store_fields) — nothing is applied on error and
|
|
109
|
+
* the thrown error's `diagnostics` carry one entry per offending field,
|
|
110
|
+
* including an `[EditError::UnknownField]` for any name the schema does not
|
|
111
|
+
* declare, so a whole-form submit sees every typo in one pass. Throws on an
|
|
112
|
+
* out-of-range card.
|
|
113
|
+
* @param {Quill} quill
|
|
114
|
+
* @param {CardAddr} addr
|
|
115
|
+
* @param {Record<string, unknown>} fields
|
|
116
|
+
*/
|
|
117
|
+
_commitFields(quill, addr, fields) {
|
|
118
|
+
try {
|
|
119
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
120
|
+
_assertClass(quill, Quill);
|
|
121
|
+
wasm.document__commitFields(retptr, this.__wbg_ptr, quill.__wbg_ptr, addHeapObject(addr), addHeapObject(fields));
|
|
122
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
123
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
124
|
+
if (r1) {
|
|
125
|
+
throw takeObject(r0);
|
|
126
|
+
}
|
|
127
|
+
} finally {
|
|
128
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Revise the richtext field at `addr` from markdown, typed *and*
|
|
133
|
+
* anchor-preserving — the ABI under `writer.reviseField`. Resolves the
|
|
134
|
+
* field's schema from `quill` (main card, or the addressed card's `$kind`)
|
|
135
|
+
* and defers to [`TypedWriter::revise_field`](quillmark_core::TypedWriter::revise_field):
|
|
136
|
+
* surviving anchors rebase (as [`revise`](Self::revise)), then the diffed
|
|
137
|
+
* result is schema-conformed, so a `richtext(inline)` field rejects a
|
|
138
|
+
* multi-block result with `[EditError::FieldRichtextNotInline]`. Returns the
|
|
139
|
+
* text [`Delta`].
|
|
140
|
+
*
|
|
141
|
+
* `addr` must name a field (a bare string is `{ field }`); a body address
|
|
142
|
+
* throws (a body carries no field schema — use [`revise`](Self::revise)). A
|
|
143
|
+
* name the schema does not declare throws `[EditError::UnknownField]`. Throws
|
|
144
|
+
* on an out-of-range card. Hidden from the `.d.ts`; the visible verb is
|
|
145
|
+
* `writer.reviseField` in the runtime layer.
|
|
146
|
+
* @param {Quill} quill
|
|
147
|
+
* @param {Addr | string} addr
|
|
148
|
+
* @param {string} markdown
|
|
149
|
+
* @returns {Delta}
|
|
150
|
+
*/
|
|
151
|
+
_reviseField(quill, addr, markdown) {
|
|
152
|
+
try {
|
|
153
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
154
|
+
_assertClass(quill, Quill);
|
|
155
|
+
const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
156
|
+
const len0 = WASM_VECTOR_LEN;
|
|
157
|
+
wasm.document__reviseField(retptr, this.__wbg_ptr, quill.__wbg_ptr, addHeapObject(addr), ptr0, len0);
|
|
158
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
159
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
160
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
161
|
+
if (r2) {
|
|
162
|
+
throw takeObject(r1);
|
|
163
|
+
}
|
|
164
|
+
return takeObject(r0);
|
|
165
|
+
} finally {
|
|
166
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Interpreted read at `addr`, resolving the field's declared `type` from
|
|
171
|
+
* `quill` — the stable ABI under the runtime `view.get` / `view.card(i).get`.
|
|
172
|
+
* The schema-plane twin of the quill-free [`get`](Self::get): a `richtext`
|
|
173
|
+
* field returns its markdown projection, every other declared type its
|
|
174
|
+
* canonical value verbatim, so a consumer holding the quill reads by field
|
|
175
|
+
* meaning rather than by wire shape.
|
|
176
|
+
*
|
|
177
|
+
* A bare string is `Addr` shorthand for `{ field }`; `{ card, field }`
|
|
178
|
+
* targets a composable card (its `$kind` resolves the schema). Returns
|
|
179
|
+
* `undefined` for an **absent** field. An absent `addr.field` reads the body
|
|
180
|
+
* markdown — quill-free, mirroring [`getMarkdown`](Self::get_markdown), since
|
|
181
|
+
* a body's type is a format fact, not a schema fact. A name the schema does
|
|
182
|
+
* not declare throws `[EditError::UnknownField]` (the authority `getMarkdown`
|
|
183
|
+
* lacks — there an unknown name reads back `undefined`); a `richtext` field
|
|
184
|
+
* holding a value that does not decode throws `[EditError::FieldRichtextDecode]`;
|
|
185
|
+
* an out-of-range `addr.card` throws.
|
|
186
|
+
*
|
|
187
|
+
* The `quill` handle is passed per call because a `Document` carries only a
|
|
188
|
+
* `$quill` reference, not the resolved schema.
|
|
189
|
+
* @param {Quill} quill
|
|
190
|
+
* @param {Addr | string} addr
|
|
191
|
+
* @returns {unknown}
|
|
192
|
+
*/
|
|
193
|
+
_viewGet(quill, addr) {
|
|
194
|
+
try {
|
|
195
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
196
|
+
_assertClass(quill, Quill);
|
|
197
|
+
wasm.document__viewGet(retptr, this.__wbg_ptr, quill.__wbg_ptr, addHeapObject(addr));
|
|
198
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
199
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
200
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
201
|
+
if (r2) {
|
|
202
|
+
throw takeObject(r1);
|
|
203
|
+
}
|
|
204
|
+
return takeObject(r0);
|
|
205
|
+
} finally {
|
|
206
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* **Apply** a committed content edit `bundle` (`{ delta?, lineOps?, markOps? }`)
|
|
211
|
+
* at `addr` — the editor splice: text delta first, then line ops, then mark
|
|
212
|
+
* ops (mark ranges in final-text coordinates), each all-or-nothing. An absent
|
|
213
|
+
* `addr.field` targets the body, an absent `addr.card` the main card.
|
|
214
|
+
*
|
|
215
|
+
* Throws on an out-of-range card, a field that is not richtext, a malformed
|
|
216
|
+
* bundle, or an op that applies out of bounds (the value is unchanged on a
|
|
217
|
+
* failed apply).
|
|
218
|
+
* @param {Addr | string} addr
|
|
219
|
+
* @param {ChangeBundle} bundle
|
|
220
|
+
*/
|
|
221
|
+
applyChange(addr, bundle) {
|
|
222
|
+
try {
|
|
223
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
224
|
+
wasm.document_applyChange(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(bundle));
|
|
225
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
226
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
227
|
+
if (r1) {
|
|
228
|
+
throw takeObject(r0);
|
|
229
|
+
}
|
|
230
|
+
} finally {
|
|
231
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
22
234
|
/**
|
|
23
235
|
* Authoring-ergonomics header introducing a blueprint to an LLM/MCP
|
|
24
236
|
* consumer for the given `quillName`. Re-exposes core's canonical text for
|
|
@@ -45,6 +257,30 @@ export class Document {
|
|
|
45
257
|
wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
46
258
|
}
|
|
47
259
|
}
|
|
260
|
+
/**
|
|
261
|
+
* A single composable card by index — the whole `Card`, the card-indexed
|
|
262
|
+
* twin of the [`main`](Self::main) getter, so reading one card need not
|
|
263
|
+
* materialize every card via [`cards`](Self::cards). An out-of-range
|
|
264
|
+
* `index` throws `[EditError::IndexOutOfRange]`, matching the card write
|
|
265
|
+
* verbs.
|
|
266
|
+
* @param {number} index
|
|
267
|
+
* @returns {Card}
|
|
268
|
+
*/
|
|
269
|
+
card(index) {
|
|
270
|
+
try {
|
|
271
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
272
|
+
wasm.document_card(retptr, this.__wbg_ptr, index);
|
|
273
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
274
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
275
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
276
|
+
if (r2) {
|
|
277
|
+
throw takeObject(r1);
|
|
278
|
+
}
|
|
279
|
+
return takeObject(r0);
|
|
280
|
+
} finally {
|
|
281
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
48
284
|
/**
|
|
49
285
|
* Number of composable cards (excludes the main card). O(1).
|
|
50
286
|
* @returns {number}
|
|
@@ -53,6 +289,20 @@ export class Document {
|
|
|
53
289
|
const ret = wasm.document_cardCount(this.__wbg_ptr);
|
|
54
290
|
return ret >>> 0;
|
|
55
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* The index of the first composable card whose `$id` equals `id`, or
|
|
294
|
+
* `undefined` when none carries it. Resolves the canonical durable address
|
|
295
|
+
* without a hand-rolled scan over [`cards`](Self::cards); `$id` is
|
|
296
|
+
* non-unique by design, so the first match wins.
|
|
297
|
+
* @param {string} id
|
|
298
|
+
* @returns {number | undefined}
|
|
299
|
+
*/
|
|
300
|
+
cardIndexById(id) {
|
|
301
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
302
|
+
const len0 = WASM_VECTOR_LEN;
|
|
303
|
+
const ret = wasm.document_cardIndexById(this.__wbg_ptr, ptr0, len0);
|
|
304
|
+
return takeObject(ret);
|
|
305
|
+
}
|
|
56
306
|
/**
|
|
57
307
|
* @returns {Card[]}
|
|
58
308
|
*/
|
|
@@ -208,15 +458,200 @@ export class Document {
|
|
|
208
458
|
}
|
|
209
459
|
}
|
|
210
460
|
/**
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
461
|
+
* Read the value at `addr` — the raw stored payload value of a field (a
|
|
462
|
+
* content object for a richtext field, a scalar/array/object otherwise), or
|
|
463
|
+
* the **body content** when `addr.field` is absent. A bare string is `Addr`
|
|
464
|
+
* shorthand for `{ field }`. Reads are total over the field axis: an absent
|
|
465
|
+
* field is `undefined`; only an out-of-range `addr.card` throws
|
|
466
|
+
* `[EditError::IndexOutOfRange]`. Reads need no schema, so they live on
|
|
467
|
+
* `Document`, not the typed writer; for the markdown projection of a
|
|
468
|
+
* richtext value use [`getMarkdown`](Self::get_markdown).
|
|
469
|
+
* @param {Addr | string} addr
|
|
470
|
+
* @returns {unknown}
|
|
471
|
+
*/
|
|
472
|
+
get(addr) {
|
|
473
|
+
try {
|
|
474
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
475
|
+
wasm.document_get(retptr, this.__wbg_ptr, addHeapObject(addr));
|
|
476
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
477
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
478
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
479
|
+
if (r2) {
|
|
480
|
+
throw takeObject(r1);
|
|
481
|
+
}
|
|
482
|
+
return takeObject(r0);
|
|
483
|
+
} finally {
|
|
484
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* The whole `$ext` map at `addr` (a card address, absent `card` = main), or
|
|
489
|
+
* `undefined` when the card carries none. The fine-grained `$ext` read —
|
|
490
|
+
* your own state without serializing the whole card. Throws on a present
|
|
491
|
+
* `field` (a card address takes only `card`) or an out-of-range card.
|
|
492
|
+
* @param {CardAddr} [addr]
|
|
493
|
+
* @returns {Record<string, unknown> | undefined}
|
|
494
|
+
*/
|
|
495
|
+
getExt(addr) {
|
|
496
|
+
try {
|
|
497
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
498
|
+
wasm.document_getExt(retptr, this.__wbg_ptr, addHeapObject(addr));
|
|
499
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
500
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
501
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
502
|
+
if (r2) {
|
|
503
|
+
throw takeObject(r1);
|
|
504
|
+
}
|
|
505
|
+
return takeObject(r0);
|
|
506
|
+
} finally {
|
|
507
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* The value stored under `$ext[ns]` at `addr` (a card address, absent `card`
|
|
512
|
+
* = main), or `undefined`. The namespace-scoped `$ext` read — your own slot
|
|
513
|
+
* without a whole-card serialize, and non-destructive (unlike
|
|
514
|
+
* `removeExtNamespace`). Throws on a present `field` or an out-of-range card.
|
|
515
|
+
* @param {CardAddr} addr
|
|
516
|
+
* @param {string} ns
|
|
517
|
+
* @returns {unknown}
|
|
518
|
+
*/
|
|
519
|
+
getExtNamespace(addr, ns) {
|
|
520
|
+
try {
|
|
521
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
522
|
+
const ptr0 = passStringToWasm0(ns, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
523
|
+
const len0 = WASM_VECTOR_LEN;
|
|
524
|
+
wasm.document_getExtNamespace(retptr, this.__wbg_ptr, addHeapObject(addr), ptr0, len0);
|
|
525
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
526
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
527
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
528
|
+
if (r2) {
|
|
529
|
+
throw takeObject(r1);
|
|
530
|
+
}
|
|
531
|
+
return takeObject(r0);
|
|
532
|
+
} finally {
|
|
533
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* The **body** markdown projection — the main body, or a composable card's
|
|
538
|
+
* body (`{ card }`) — the on-demand, lossy export (content-only marks do not
|
|
539
|
+
* survive markdown). A body's type is a format fact, not a schema fact, so
|
|
540
|
+
* this read stays quill-free; a body is never absent.
|
|
541
|
+
*
|
|
542
|
+
* `addr` is an optional **card address** (`{ card }`, absent = main). A
|
|
543
|
+
* present `field` throws — a field's markdown is read through the
|
|
544
|
+
* schema-plane `quill.view(doc).get(field)`, which interprets by declared
|
|
545
|
+
* type (#978). An out-of-range `addr.card` throws.
|
|
546
|
+
* @param {CardAddr} [addr]
|
|
547
|
+
* @returns {string}
|
|
548
|
+
*/
|
|
549
|
+
getMarkdown(addr) {
|
|
550
|
+
try {
|
|
551
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
552
|
+
wasm.document_getMarkdown(retptr, this.__wbg_ptr, addHeapObject(addr));
|
|
553
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
554
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
555
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
556
|
+
if (r2) {
|
|
557
|
+
throw takeObject(r1);
|
|
558
|
+
}
|
|
559
|
+
return takeObject(r0);
|
|
560
|
+
} finally {
|
|
561
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Insert a card — the single insertion verb: `at` absent appends, a number
|
|
566
|
+
* inserts at that index (must be in `0..=cards.length`). Accepts a
|
|
567
|
+
* `CardInput` — a card read back (`cards` / `removeCard` / `quill.seedCard`),
|
|
568
|
+
* a [`makeCard`](Document::make_card) result, or a bare `{ kind, body }`
|
|
569
|
+
* (every returned `Card` is a valid `CardInput`). Throws if `card.kind` is
|
|
570
|
+
* not a valid kind name, or if `at` is out of range.
|
|
571
|
+
* @param {CardInput} card
|
|
572
|
+
* @param {number} [at]
|
|
573
|
+
*/
|
|
574
|
+
insertCard(card, at) {
|
|
575
|
+
try {
|
|
576
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
577
|
+
wasm.document_insertCard(retptr, this.__wbg_ptr, addHeapObject(card), isLikeNone(at) ? 0x100000001 : (at) >>> 0);
|
|
578
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
579
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
580
|
+
if (r1) {
|
|
581
|
+
throw takeObject(r0);
|
|
582
|
+
}
|
|
583
|
+
} finally {
|
|
584
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* **Install** a richtext value at `addr` — **value semantics**, content only.
|
|
589
|
+
* Stores exactly `rt` (a canonical `Content` content object); the identity
|
|
590
|
+
* anchors of any previous value are gone. An absent `addr.field` targets the
|
|
591
|
+
* body, an absent `addr.card` the main card. For "here's new markdown," use
|
|
592
|
+
* [`revise`](Document::revise); the cold-import path is spelled at the call
|
|
593
|
+
* site as `install(addr, importMarkdown(md))`, so anchor loss is visible in
|
|
594
|
+
* source.
|
|
595
|
+
*
|
|
596
|
+
* Throws on an out-of-range card, a malformed field name, or an `rt` that is
|
|
597
|
+
* not a canonical content object.
|
|
598
|
+
* @param {Addr | string} addr
|
|
599
|
+
* @param {Content} rt
|
|
600
|
+
*/
|
|
601
|
+
install(addr, rt) {
|
|
602
|
+
try {
|
|
603
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
604
|
+
wasm.document_install(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(rt));
|
|
605
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
606
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
607
|
+
if (r1) {
|
|
608
|
+
throw takeObject(r0);
|
|
609
|
+
}
|
|
610
|
+
} finally {
|
|
611
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Whether the field at `addr` is marked `!must_fill`. A bare string is `Addr`
|
|
616
|
+
* shorthand for `{ field }`. `false` for an absent field (truthful — it isn't
|
|
617
|
+
* marked) and for a body address (a body is never a fill). Only an
|
|
618
|
+
* out-of-range `addr.card` throws.
|
|
619
|
+
* @param {Addr | string} addr
|
|
620
|
+
* @returns {boolean}
|
|
215
621
|
*/
|
|
216
|
-
|
|
622
|
+
isFill(addr) {
|
|
217
623
|
try {
|
|
218
624
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
219
|
-
wasm.
|
|
625
|
+
wasm.document_isFill(retptr, this.__wbg_ptr, addHeapObject(addr));
|
|
626
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
627
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
628
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
629
|
+
if (r2) {
|
|
630
|
+
throw takeObject(r1);
|
|
631
|
+
}
|
|
632
|
+
return r0 !== 0;
|
|
633
|
+
} finally {
|
|
634
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Replace this document's contents **in place** from a versioned storage
|
|
639
|
+
* DTO string — the mutating twin of the static
|
|
640
|
+
* [`fromJson`](Document::from_json) constructor. Parse-time `warnings` are
|
|
641
|
+
* cleared. Throws (leaving the document unchanged) on an invalid DTO.
|
|
642
|
+
*
|
|
643
|
+
* The cross-WASM-memory `Document` bridge: mutate a document on a
|
|
644
|
+
* backend-memory clone, then write the mutated state back into the caller's
|
|
645
|
+
* canonical document with this — the one way to update a live handle across
|
|
646
|
+
* the linear-memory seam without the caller re-binding its variable.
|
|
647
|
+
* @param {string} json
|
|
648
|
+
*/
|
|
649
|
+
loadJson(json) {
|
|
650
|
+
try {
|
|
651
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
652
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
653
|
+
const len0 = WASM_VECTOR_LEN;
|
|
654
|
+
wasm.document_loadJson(retptr, this.__wbg_ptr, ptr0, len0);
|
|
220
655
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
221
656
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
222
657
|
if (r1) {
|
|
@@ -248,10 +683,10 @@ export class Document {
|
|
|
248
683
|
}
|
|
249
684
|
/**
|
|
250
685
|
* Build a fresh `Card` from a kind and a flat field map — the ergonomic
|
|
251
|
-
* constructor for `
|
|
686
|
+
* constructor for `insertCard`. `fields` is an optional
|
|
252
687
|
* `Record<string, unknown>` (each entry becomes a card field, in
|
|
253
688
|
* insertion order); `body` defaults to `""`. Kind validity is checked by
|
|
254
|
-
* `
|
|
689
|
+
* `insertCard`, not here.
|
|
255
690
|
* @param {string} kind
|
|
256
691
|
* @param {Record<string, unknown>} [fields]
|
|
257
692
|
* @param {string} [body]
|
|
@@ -295,21 +730,29 @@ export class Document {
|
|
|
295
730
|
}
|
|
296
731
|
}
|
|
297
732
|
/**
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
733
|
+
* `new Document(quillRef)` — a blank document: a main card carrying only
|
|
734
|
+
* `$quill`, an empty body, and no composable cards. The programmatic
|
|
735
|
+
* blank canvas: absent fields resolve at render time (`default`, else
|
|
736
|
+
* type-empty zero), so nothing the caller did not set reaches the
|
|
737
|
+
* output. For an example-filled starter use `Quill.seedDocument()`.
|
|
738
|
+
* Throws on an invalid quill reference. Mirrors Python `Document(quill_ref)`.
|
|
739
|
+
* @param {string} quill_ref
|
|
303
740
|
*/
|
|
304
|
-
|
|
741
|
+
constructor(quill_ref) {
|
|
305
742
|
try {
|
|
306
743
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
307
|
-
|
|
744
|
+
const ptr0 = passStringToWasm0(quill_ref, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
745
|
+
const len0 = WASM_VECTOR_LEN;
|
|
746
|
+
wasm.document_new(retptr, ptr0, len0);
|
|
308
747
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
309
748
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
310
|
-
|
|
311
|
-
|
|
749
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
750
|
+
if (r2) {
|
|
751
|
+
throw takeObject(r1);
|
|
312
752
|
}
|
|
753
|
+
this.__wbg_ptr = r0 >>> 0;
|
|
754
|
+
DocumentFinalization.register(this, this.__wbg_ptr, this);
|
|
755
|
+
return this;
|
|
313
756
|
} finally {
|
|
314
757
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
315
758
|
}
|
|
@@ -377,16 +820,17 @@ export class Document {
|
|
|
377
820
|
}
|
|
378
821
|
}
|
|
379
822
|
/**
|
|
380
|
-
* Remove the `$ext` map
|
|
381
|
-
*
|
|
382
|
-
*
|
|
383
|
-
*
|
|
823
|
+
* Remove the `$ext` map on the card `addr` targets *entirely*, returning the
|
|
824
|
+
* previous map or `undefined` — a blunt escape hatch that discards every
|
|
825
|
+
* namespace at once (prefer `removeExtNamespace`). `addr` is a card address
|
|
826
|
+
* (absent = main). Throws on a present `field` or an out-of-range card.
|
|
827
|
+
* @param {CardAddr} [addr]
|
|
384
828
|
* @returns {Record<string, unknown> | undefined}
|
|
385
829
|
*/
|
|
386
|
-
|
|
830
|
+
removeExt(addr) {
|
|
387
831
|
try {
|
|
388
832
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
389
|
-
wasm.
|
|
833
|
+
wasm.document_removeExt(retptr, this.__wbg_ptr, addHeapObject(addr));
|
|
390
834
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
391
835
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
392
836
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -399,19 +843,20 @@ export class Document {
|
|
|
399
843
|
}
|
|
400
844
|
}
|
|
401
845
|
/**
|
|
402
|
-
* Remove `
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
* @param {
|
|
846
|
+
* Remove `$ext[ns]` on the card `addr` targets, returning its value or
|
|
847
|
+
* `undefined`; drops `$ext` once empty. `addr` is a card address (absent =
|
|
848
|
+
* main). Preserves sibling namespaces. Throws on a present `field` or an
|
|
849
|
+
* out-of-range card.
|
|
850
|
+
* @param {CardAddr} addr
|
|
851
|
+
* @param {string} ns
|
|
407
852
|
* @returns {any}
|
|
408
853
|
*/
|
|
409
|
-
|
|
854
|
+
removeExtNamespace(addr, ns) {
|
|
410
855
|
try {
|
|
411
856
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
412
|
-
const ptr0 = passStringToWasm0(
|
|
857
|
+
const ptr0 = passStringToWasm0(ns, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
413
858
|
const len0 = WASM_VECTOR_LEN;
|
|
414
|
-
wasm.
|
|
859
|
+
wasm.document_removeExtNamespace(retptr, this.__wbg_ptr, addHeapObject(addr), ptr0, len0);
|
|
415
860
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
416
861
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
417
862
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -424,18 +869,17 @@ export class Document {
|
|
|
424
869
|
}
|
|
425
870
|
}
|
|
426
871
|
/**
|
|
427
|
-
* Remove a field
|
|
428
|
-
*
|
|
429
|
-
*
|
|
430
|
-
*
|
|
872
|
+
* Remove a field at `addr`, returning the removed value or `undefined`. A
|
|
873
|
+
* bare string is `Addr` shorthand for `{ field }`. One `remove` verb serves
|
|
874
|
+
* every write lane. A body address throws; throws on an out-of-range card or
|
|
875
|
+
* a malformed name.
|
|
876
|
+
* @param {Addr | string} addr
|
|
431
877
|
* @returns {any}
|
|
432
878
|
*/
|
|
433
|
-
|
|
879
|
+
removeField(addr) {
|
|
434
880
|
try {
|
|
435
881
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
436
|
-
|
|
437
|
-
const len0 = WASM_VECTOR_LEN;
|
|
438
|
-
wasm.document_removeCardField(retptr, this.__wbg_ptr, index, ptr0, len0);
|
|
882
|
+
wasm.document_removeField(retptr, this.__wbg_ptr, addHeapObject(addr));
|
|
439
883
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
440
884
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
441
885
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -448,16 +892,18 @@ export class Document {
|
|
|
448
892
|
}
|
|
449
893
|
}
|
|
450
894
|
/**
|
|
451
|
-
* Remove
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
*
|
|
455
|
-
* @returns {
|
|
895
|
+
* Remove `cardKind` from the main card's `$seed` map, returning its
|
|
896
|
+
* overlay or `undefined`; drops `$seed` entirely once empty. Sibling kinds
|
|
897
|
+
* survive. `$seed` is main-only, so this takes no address.
|
|
898
|
+
* @param {string} card_kind
|
|
899
|
+
* @returns {any}
|
|
456
900
|
*/
|
|
457
|
-
|
|
901
|
+
removeSeedNamespace(card_kind) {
|
|
458
902
|
try {
|
|
459
903
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
460
|
-
wasm.
|
|
904
|
+
const ptr0 = passStringToWasm0(card_kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
905
|
+
const len0 = WASM_VECTOR_LEN;
|
|
906
|
+
wasm.document_removeSeedNamespace(retptr, this.__wbg_ptr, ptr0, len0);
|
|
461
907
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
462
908
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
463
909
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -470,19 +916,25 @@ export class Document {
|
|
|
470
916
|
}
|
|
471
917
|
}
|
|
472
918
|
/**
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
*
|
|
478
|
-
*
|
|
919
|
+
* **Revise** the richtext value at `addr` from a markdown string — **edit
|
|
920
|
+
* semantics**, the default write path, returning the text [`Delta`]. Imports
|
|
921
|
+
* the markdown, diffs it against the current value, rebases surviving
|
|
922
|
+
* identity anchors, and returns the change an editor bridge maps its own
|
|
923
|
+
* positions through (`mapPos`). An absent `addr.field` targets the body, an
|
|
924
|
+
* absent `addr.card` the main card; an absent field cold-imports from empty.
|
|
925
|
+
*
|
|
926
|
+
* Throws on an out-of-range card, a malformed field name, a present
|
|
927
|
+
* non-content field value, or an over-nested markdown input.
|
|
928
|
+
* @param {Addr | string} addr
|
|
929
|
+
* @param {string} markdown
|
|
930
|
+
* @returns {Delta}
|
|
479
931
|
*/
|
|
480
|
-
|
|
932
|
+
revise(addr, markdown) {
|
|
481
933
|
try {
|
|
482
934
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
483
|
-
const ptr0 = passStringToWasm0(
|
|
935
|
+
const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
484
936
|
const len0 = WASM_VECTOR_LEN;
|
|
485
|
-
wasm.
|
|
937
|
+
wasm.document_revise(retptr, this.__wbg_ptr, addHeapObject(addr), ptr0, len0);
|
|
486
938
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
487
939
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
488
940
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -495,41 +947,46 @@ export class Document {
|
|
|
495
947
|
}
|
|
496
948
|
}
|
|
497
949
|
/**
|
|
498
|
-
*
|
|
499
|
-
* `undefined`.
|
|
500
|
-
*
|
|
501
|
-
*
|
|
950
|
+
* Read the `schema` version tag from a raw storage DTO string without a
|
|
951
|
+
* full parse, or `undefined`. Returns unknown future versions as-is —
|
|
952
|
+
* useful to distinguish "build too old" from "payload corrupt" when
|
|
953
|
+
* `fromJson` throws.
|
|
954
|
+
* @param {string} json
|
|
955
|
+
* @returns {string | undefined}
|
|
502
956
|
*/
|
|
503
|
-
|
|
957
|
+
static schemaVersionOf(json) {
|
|
504
958
|
try {
|
|
505
959
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
506
|
-
const ptr0 = passStringToWasm0(
|
|
960
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
507
961
|
const len0 = WASM_VECTOR_LEN;
|
|
508
|
-
wasm.
|
|
962
|
+
wasm.document_schemaVersionOf(retptr, ptr0, len0);
|
|
509
963
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
510
964
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
511
|
-
|
|
512
|
-
if (
|
|
513
|
-
|
|
965
|
+
let v2;
|
|
966
|
+
if (r0 !== 0) {
|
|
967
|
+
v2 = getStringFromWasm0(r0, r1).slice();
|
|
968
|
+
wasm.__wbindgen_export4(r0, r1 * 1, 1);
|
|
514
969
|
}
|
|
515
|
-
return
|
|
970
|
+
return v2;
|
|
516
971
|
} finally {
|
|
517
972
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
518
973
|
}
|
|
519
974
|
}
|
|
520
975
|
/**
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
*
|
|
524
|
-
*
|
|
525
|
-
*
|
|
976
|
+
* The main card's `$seed` overlay object for `kind` (the `$seed[kind]`
|
|
977
|
+
* entry), or `undefined` when absent. The cheap read that feeds
|
|
978
|
+
* `quill.seedCard(kind, overlay)` without serializing the whole main card
|
|
979
|
+
* via [`main`](Self::main) to fish out one key — and it keeps `seedCard`
|
|
980
|
+
* pure: the quill still never reads the document.
|
|
981
|
+
* @param {string} kind
|
|
982
|
+
* @returns {Record<string, unknown> | undefined}
|
|
526
983
|
*/
|
|
527
|
-
|
|
984
|
+
seedOverlay(kind) {
|
|
528
985
|
try {
|
|
529
986
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
530
|
-
const ptr0 = passStringToWasm0(
|
|
987
|
+
const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
531
988
|
const len0 = WASM_VECTOR_LEN;
|
|
532
|
-
wasm.
|
|
989
|
+
wasm.document_seedOverlay(retptr, this.__wbg_ptr, ptr0, len0);
|
|
533
990
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
534
991
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
535
992
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -542,50 +999,59 @@ export class Document {
|
|
|
542
999
|
}
|
|
543
1000
|
}
|
|
544
1001
|
/**
|
|
545
|
-
*
|
|
1002
|
+
* Replace the kind of the card at `index`. Payload and body are untouched;
|
|
1003
|
+
* schema-aware migration is the caller's responsibility.
|
|
1004
|
+
* Throws if `index` is out of range or `newKind` is invalid.
|
|
1005
|
+
* @param {number} index
|
|
1006
|
+
* @param {string} new_kind
|
|
546
1007
|
*/
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
1008
|
+
setCardKind(index, new_kind) {
|
|
1009
|
+
try {
|
|
1010
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1011
|
+
const ptr0 = passStringToWasm0(new_kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1012
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1013
|
+
wasm.document_setCardKind(retptr, this.__wbg_ptr, index, ptr0, len0);
|
|
1014
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1015
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1016
|
+
if (r1) {
|
|
1017
|
+
throw takeObject(r0);
|
|
1018
|
+
}
|
|
1019
|
+
} finally {
|
|
1020
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1021
|
+
}
|
|
551
1022
|
}
|
|
552
1023
|
/**
|
|
553
|
-
*
|
|
554
|
-
*
|
|
555
|
-
* useful to distinguish "build too old" from "payload corrupt" when
|
|
556
|
-
* `fromJson` throws.
|
|
557
|
-
* @param {string} json
|
|
558
|
-
* @returns {string | undefined}
|
|
1024
|
+
* Replace the QUILL reference string. Throws if `ref_str` is invalid.
|
|
1025
|
+
* @param {string} ref_str
|
|
559
1026
|
*/
|
|
560
|
-
|
|
1027
|
+
setQuillRef(ref_str) {
|
|
561
1028
|
try {
|
|
562
1029
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
563
|
-
const ptr0 = passStringToWasm0(
|
|
1030
|
+
const ptr0 = passStringToWasm0(ref_str, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
564
1031
|
const len0 = WASM_VECTOR_LEN;
|
|
565
|
-
wasm.
|
|
1032
|
+
wasm.document_setQuillRef(retptr, this.__wbg_ptr, ptr0, len0);
|
|
566
1033
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
567
1034
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
v2 = getStringFromWasm0(r0, r1).slice();
|
|
571
|
-
wasm.__wbindgen_export4(r0, r1 * 1, 1);
|
|
1035
|
+
if (r1) {
|
|
1036
|
+
throw takeObject(r0);
|
|
572
1037
|
}
|
|
573
|
-
return v2;
|
|
574
1038
|
} finally {
|
|
575
1039
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
576
1040
|
}
|
|
577
1041
|
}
|
|
578
1042
|
/**
|
|
579
|
-
* Replace the `$ext` map on the
|
|
580
|
-
*
|
|
581
|
-
*
|
|
582
|
-
*
|
|
1043
|
+
* Replace the opaque `$ext` map on the card `addr` targets (a card address,
|
|
1044
|
+
* absent `card` = main). `value` must be a plain object. `$ext` carries
|
|
1045
|
+
* out-of-band consumer state and never reaches the rendered output; pass
|
|
1046
|
+
* `{}` for an explicit empty `$ext`. Quill-free and verbatim — an opaque
|
|
1047
|
+
* `store` verb. Throws on a present `field` or an out-of-range card.
|
|
1048
|
+
* @param {CardAddr} addr
|
|
583
1049
|
* @param {any} value
|
|
584
1050
|
*/
|
|
585
|
-
|
|
1051
|
+
storeExt(addr, value) {
|
|
586
1052
|
try {
|
|
587
1053
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
588
|
-
wasm.
|
|
1054
|
+
wasm.document_storeExt(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(value));
|
|
589
1055
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
590
1056
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
591
1057
|
if (r1) {
|
|
@@ -596,19 +1062,20 @@ export class Document {
|
|
|
596
1062
|
}
|
|
597
1063
|
}
|
|
598
1064
|
/**
|
|
599
|
-
* Merge `value` into the
|
|
600
|
-
*
|
|
601
|
-
*
|
|
602
|
-
*
|
|
603
|
-
* @param {
|
|
1065
|
+
* Merge `value` into `$ext[ns]` on the card `addr` targets, preserving
|
|
1066
|
+
* sibling namespaces — the recommended `$ext` write. `addr` is a card
|
|
1067
|
+
* address (absent = main). Quill-free and verbatim — an opaque `store` verb.
|
|
1068
|
+
* Throws on a present `field` or an out-of-range card.
|
|
1069
|
+
* @param {CardAddr} addr
|
|
1070
|
+
* @param {string} ns
|
|
604
1071
|
* @param {any} value
|
|
605
1072
|
*/
|
|
606
|
-
|
|
1073
|
+
storeExtNamespace(addr, ns, value) {
|
|
607
1074
|
try {
|
|
608
1075
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
609
|
-
const ptr0 = passStringToWasm0(
|
|
1076
|
+
const ptr0 = passStringToWasm0(ns, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
610
1077
|
const len0 = WASM_VECTOR_LEN;
|
|
611
|
-
wasm.
|
|
1078
|
+
wasm.document_storeExtNamespace(retptr, this.__wbg_ptr, addHeapObject(addr), ptr0, len0, addHeapObject(value));
|
|
612
1079
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
613
1080
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
614
1081
|
if (r1) {
|
|
@@ -619,18 +1086,21 @@ export class Document {
|
|
|
619
1086
|
}
|
|
620
1087
|
}
|
|
621
1088
|
/**
|
|
622
|
-
*
|
|
623
|
-
*
|
|
624
|
-
*
|
|
625
|
-
*
|
|
626
|
-
*
|
|
1089
|
+
* Store a field verbatim at `addr` — the opaque store (**store** = verbatim,
|
|
1090
|
+
* coercion deferred to render; the typed write is
|
|
1091
|
+
* [`commitField`](Document::commit_field)). A bare string is `Addr`
|
|
1092
|
+
* shorthand for `{ field }`, so `doc.storeField("qty", 3)` reads as written;
|
|
1093
|
+
* `{ card: 2, field: "qty" }` targets a composable card. Clears any
|
|
1094
|
+
* `!must_fill` marker. A body address (no `field`) throws — a body is never
|
|
1095
|
+
* opaque; write it with `revise` / `install` / `writer.setBody`. Throws on
|
|
1096
|
+
* an out-of-range card or a malformed name.
|
|
1097
|
+
* @param {Addr | string} addr
|
|
1098
|
+
* @param {any} value
|
|
627
1099
|
*/
|
|
628
|
-
|
|
1100
|
+
storeField(addr, value) {
|
|
629
1101
|
try {
|
|
630
1102
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
631
|
-
|
|
632
|
-
const len0 = WASM_VECTOR_LEN;
|
|
633
|
-
wasm.document_setCardKind(retptr, this.__wbg_ptr, index, ptr0, len0);
|
|
1103
|
+
wasm.document_storeField(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(value));
|
|
634
1104
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
635
1105
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
636
1106
|
if (r1) {
|
|
@@ -641,16 +1111,21 @@ export class Document {
|
|
|
641
1111
|
}
|
|
642
1112
|
}
|
|
643
1113
|
/**
|
|
644
|
-
*
|
|
645
|
-
*
|
|
646
|
-
*
|
|
647
|
-
*
|
|
648
|
-
*
|
|
1114
|
+
* Store several fields verbatim and atomically on the card `addr` targets —
|
|
1115
|
+
* the opaque store's batch. `addr` is a **card address** (`{ card }`, absent
|
|
1116
|
+
* = main); a present `field` throws. The batch verb takes the address first
|
|
1117
|
+
* and is never shape-overloaded, because `card` is a legal field name:
|
|
1118
|
+
* `storeFields({}, fields)` is the main card, `storeFields({ card: 2 },
|
|
1119
|
+
* fields)` a composable one — never ambiguous with "set field `card`".
|
|
1120
|
+
* Nothing is applied on error; the thrown error's `diagnostics` carry one
|
|
1121
|
+
* entry per offending field. Throws on an out-of-range card.
|
|
1122
|
+
* @param {CardAddr} addr
|
|
1123
|
+
* @param {Record<string, unknown>} fields
|
|
649
1124
|
*/
|
|
650
|
-
|
|
1125
|
+
storeFields(addr, fields) {
|
|
651
1126
|
try {
|
|
652
1127
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
653
|
-
wasm.
|
|
1128
|
+
wasm.document_storeFields(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(fields));
|
|
654
1129
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
655
1130
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
656
1131
|
if (r1) {
|
|
@@ -661,19 +1136,17 @@ export class Document {
|
|
|
661
1136
|
}
|
|
662
1137
|
}
|
|
663
1138
|
/**
|
|
664
|
-
*
|
|
665
|
-
*
|
|
666
|
-
*
|
|
667
|
-
*
|
|
668
|
-
* @param {string}
|
|
1139
|
+
* Store a field verbatim at `addr` and mark it `!must_fill` — the opaque
|
|
1140
|
+
* store's fill variant, card-capable (a bare string or `{ field }` for main,
|
|
1141
|
+
* `{ card, field }` for a composable card). A body address throws. Same
|
|
1142
|
+
* validation as [`storeField`](Document::store_field).
|
|
1143
|
+
* @param {Addr | string} addr
|
|
669
1144
|
* @param {any} value
|
|
670
1145
|
*/
|
|
671
|
-
|
|
1146
|
+
storeFill(addr, value) {
|
|
672
1147
|
try {
|
|
673
1148
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
674
|
-
|
|
675
|
-
const len0 = WASM_VECTOR_LEN;
|
|
676
|
-
wasm.document_setExtNamespace(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(value));
|
|
1149
|
+
wasm.document_storeFill(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(value));
|
|
677
1150
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
678
1151
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
679
1152
|
if (r1) {
|
|
@@ -684,18 +1157,20 @@ export class Document {
|
|
|
684
1157
|
}
|
|
685
1158
|
}
|
|
686
1159
|
/**
|
|
687
|
-
*
|
|
688
|
-
*
|
|
689
|
-
*
|
|
690
|
-
*
|
|
691
|
-
*
|
|
1160
|
+
* Merge a card-kind's seed `overlay` into the **main** card's `$seed` map
|
|
1161
|
+
* under `cardKind`, preserving sibling kinds — `$seed` lives on the main
|
|
1162
|
+
* card by model, so this takes no address. Sets the starting values new
|
|
1163
|
+
* cards of that kind spawn with. Quill-free and verbatim — an opaque `store`
|
|
1164
|
+
* verb. Throws if `overlay` cannot be serialized or nests too deep.
|
|
1165
|
+
* @param {string} card_kind
|
|
1166
|
+
* @param {any} overlay
|
|
692
1167
|
*/
|
|
693
|
-
|
|
1168
|
+
storeSeedNamespace(card_kind, overlay) {
|
|
694
1169
|
try {
|
|
695
1170
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
696
|
-
const ptr0 = passStringToWasm0(
|
|
1171
|
+
const ptr0 = passStringToWasm0(card_kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
697
1172
|
const len0 = WASM_VECTOR_LEN;
|
|
698
|
-
wasm.
|
|
1173
|
+
wasm.document_storeSeedNamespace(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(overlay));
|
|
699
1174
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
700
1175
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
701
1176
|
if (r1) {
|
|
@@ -706,180 +1181,390 @@ export class Document {
|
|
|
706
1181
|
}
|
|
707
1182
|
}
|
|
708
1183
|
/**
|
|
709
|
-
*
|
|
710
|
-
*
|
|
711
|
-
*
|
|
712
|
-
*
|
|
1184
|
+
* Serialize this document to a versioned storage DTO string.
|
|
1185
|
+
*
|
|
1186
|
+
* Prefer this over `toMarkdown` for persistence across restarts or crate
|
|
1187
|
+
* upgrades — the wire format is frozen per `schema` version. Parse-time
|
|
1188
|
+
* `warnings` are excluded from the DTO.
|
|
1189
|
+
*
|
|
1190
|
+
* Output is **byte-deterministic** within a `schema` version: equal
|
|
1191
|
+
* documents produce byte-equal output, safe for content-hash use cases.
|
|
1192
|
+
* @returns {string}
|
|
713
1193
|
*/
|
|
714
|
-
|
|
1194
|
+
toJson() {
|
|
1195
|
+
let deferred1_0;
|
|
1196
|
+
let deferred1_1;
|
|
715
1197
|
try {
|
|
716
1198
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
717
|
-
|
|
718
|
-
const len0 = WASM_VECTOR_LEN;
|
|
719
|
-
wasm.document_setFill(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(value));
|
|
1199
|
+
wasm.document_toJson(retptr, this.__wbg_ptr);
|
|
720
1200
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
721
1201
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
722
|
-
|
|
723
|
-
|
|
1202
|
+
deferred1_0 = r0;
|
|
1203
|
+
deferred1_1 = r1;
|
|
1204
|
+
return getStringFromWasm0(r0, r1);
|
|
1205
|
+
} finally {
|
|
1206
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1207
|
+
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
/**
|
|
1211
|
+
* Emit canonical Quillmark Markdown. Round-trip safe: re-parsing the
|
|
1212
|
+
* result produces a `Document` equal to `self` by value and by type.
|
|
1213
|
+
* @returns {string}
|
|
1214
|
+
*/
|
|
1215
|
+
toMarkdown() {
|
|
1216
|
+
let deferred1_0;
|
|
1217
|
+
let deferred1_1;
|
|
1218
|
+
try {
|
|
1219
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1220
|
+
wasm.document_toMarkdown(retptr, this.__wbg_ptr);
|
|
1221
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1222
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1223
|
+
deferred1_0 = r0;
|
|
1224
|
+
deferred1_1 = r1;
|
|
1225
|
+
return getStringFromWasm0(r0, r1);
|
|
1226
|
+
} finally {
|
|
1227
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1228
|
+
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
/**
|
|
1232
|
+
* Like [`fromJson`](Document::from_json) but returns `undefined` instead
|
|
1233
|
+
* of throwing when `json` is not a valid storage DTO — use to
|
|
1234
|
+
* discriminate format without exceptions as control flow.
|
|
1235
|
+
* `undefined` means "not a storage DTO"; `fromMarkdown` still throws on
|
|
1236
|
+
* genuinely malformed markdown.
|
|
1237
|
+
* @param {string} json
|
|
1238
|
+
* @returns {Document | undefined}
|
|
1239
|
+
*/
|
|
1240
|
+
static tryFromJson(json) {
|
|
1241
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1242
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1243
|
+
const ret = wasm.document_tryFromJson(ptr0, len0);
|
|
1244
|
+
return ret === 0 ? undefined : Document.__wrap(ret);
|
|
1245
|
+
}
|
|
1246
|
+
/**
|
|
1247
|
+
* @returns {Diagnostic[]}
|
|
1248
|
+
*/
|
|
1249
|
+
get warnings() {
|
|
1250
|
+
try {
|
|
1251
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1252
|
+
wasm.document_warnings(retptr, this.__wbg_ptr);
|
|
1253
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1254
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1255
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1256
|
+
if (r2) {
|
|
1257
|
+
throw takeObject(r1);
|
|
724
1258
|
}
|
|
1259
|
+
return takeObject(r0);
|
|
725
1260
|
} finally {
|
|
726
1261
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
727
1262
|
}
|
|
728
1263
|
}
|
|
1264
|
+
}
|
|
1265
|
+
if (Symbol.dispose) Document.prototype[Symbol.dispose] = Document.prototype.free;
|
|
1266
|
+
|
|
1267
|
+
/**
|
|
1268
|
+
* Live render session: reads (`render`, `paint`, `pageSize`, `regions`,
|
|
1269
|
+
* `fieldAt`, `positionAt`, `locate`) serve the current compile. `apply(doc)`
|
|
1270
|
+
* recompiles a whole document in place, transactionally (on throw every read
|
|
1271
|
+
* keeps serving the last-good compile). Geometry reads reflect the current
|
|
1272
|
+
* compile; anchoring a caret across edits is the editor's job — re-read
|
|
1273
|
+
* geometry after each committed `apply`.
|
|
1274
|
+
*
|
|
1275
|
+
* **Empty documents.** A zero-page document yields a valid session
|
|
1276
|
+
* (`pageCount === 0`); `paint(ctx, 0)` or `pageSize(0)` throws with
|
|
1277
|
+
* `"page index 0 out of range (pageCount=0)"`. Branch on `pageCount === 0`
|
|
1278
|
+
* rather than catching the error.
|
|
1279
|
+
*/
|
|
1280
|
+
export class LiveSession {
|
|
1281
|
+
static __wrap(ptr) {
|
|
1282
|
+
ptr = ptr >>> 0;
|
|
1283
|
+
const obj = Object.create(LiveSession.prototype);
|
|
1284
|
+
obj.__wbg_ptr = ptr;
|
|
1285
|
+
LiveSessionFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1286
|
+
return obj;
|
|
1287
|
+
}
|
|
1288
|
+
__destroy_into_raw() {
|
|
1289
|
+
const ptr = this.__wbg_ptr;
|
|
1290
|
+
this.__wbg_ptr = 0;
|
|
1291
|
+
LiveSessionFinalization.unregister(this);
|
|
1292
|
+
return ptr;
|
|
1293
|
+
}
|
|
1294
|
+
free() {
|
|
1295
|
+
const ptr = this.__destroy_into_raw();
|
|
1296
|
+
wasm.__wbg_livesession_free(ptr, 0);
|
|
1297
|
+
}
|
|
729
1298
|
/**
|
|
730
|
-
*
|
|
731
|
-
*
|
|
1299
|
+
* Recompile the session against `doc` — the edit verb of a live preview.
|
|
1300
|
+
* The document is compiled through the same schema pipeline as `open`
|
|
1301
|
+
* (same quill), then applied transactionally: on throw every read
|
|
1302
|
+
* (`render`, `paint`, `pageSize`, `regions`, `fieldAt`) keeps serving the last-good
|
|
1303
|
+
* compile, and the session recovers on the next successful `apply`. On
|
|
1304
|
+
* success reads serve the new compile; repaint `dirtyPages ∩ visible`.
|
|
1305
|
+
* @param {Document} doc
|
|
1306
|
+
* @returns {ChangeSet}
|
|
732
1307
|
*/
|
|
733
|
-
|
|
1308
|
+
apply(doc) {
|
|
734
1309
|
try {
|
|
735
1310
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
wasm.document_setQuillRef(retptr, this.__wbg_ptr, ptr0, len0);
|
|
1311
|
+
_assertClass(doc, Document);
|
|
1312
|
+
wasm.livesession_apply(retptr, this.__wbg_ptr, doc.__wbg_ptr);
|
|
739
1313
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
740
1314
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
741
|
-
|
|
742
|
-
|
|
1315
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1316
|
+
if (r2) {
|
|
1317
|
+
throw takeObject(r1);
|
|
743
1318
|
}
|
|
1319
|
+
return takeObject(r0);
|
|
744
1320
|
} finally {
|
|
745
1321
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
746
1322
|
}
|
|
747
1323
|
}
|
|
748
1324
|
/**
|
|
749
|
-
*
|
|
750
|
-
*
|
|
751
|
-
* new cards of that kind spawn with. Throws if `overlay` cannot be
|
|
752
|
-
* serialized or nests too deep.
|
|
753
|
-
* @param {string} card_kind
|
|
754
|
-
* @param {any} overlay
|
|
1325
|
+
* The backend that produced this session (e.g. `"typst"`).
|
|
1326
|
+
* @returns {string}
|
|
755
1327
|
*/
|
|
756
|
-
|
|
1328
|
+
get backendId() {
|
|
1329
|
+
let deferred1_0;
|
|
1330
|
+
let deferred1_1;
|
|
757
1331
|
try {
|
|
758
1332
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
759
|
-
|
|
1333
|
+
wasm.livesession_backendId(retptr, this.__wbg_ptr);
|
|
1334
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1335
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1336
|
+
deferred1_0 = r0;
|
|
1337
|
+
deferred1_1 = r1;
|
|
1338
|
+
return getStringFromWasm0(r0, r1);
|
|
1339
|
+
} finally {
|
|
1340
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1341
|
+
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
/**
|
|
1345
|
+
* The schema field whose content is under a point on `page` — the
|
|
1346
|
+
* forward (click → field) direction: hit-test a click against the
|
|
1347
|
+
* compiled document and get back the field address to focus in the
|
|
1348
|
+
* editor, or `undefined` off any field's ink. `x`/`y` are PDF points
|
|
1349
|
+
* with a **bottom-left** origin, the same space as `FieldRegion.rect` —
|
|
1350
|
+
* from a canvas click, invert the overlay transform documented on
|
|
1351
|
+
* `FieldRegion`: `x = clickPx.x / renderScale`,
|
|
1352
|
+
* `y = pageHeightPt - clickPx.y / renderScale`. Unlike `regions()`,
|
|
1353
|
+
* *every* placement answers, not just the first.
|
|
1354
|
+
* @param {number} page
|
|
1355
|
+
* @param {number} x
|
|
1356
|
+
* @param {number} y
|
|
1357
|
+
* @returns {string | undefined}
|
|
1358
|
+
*/
|
|
1359
|
+
fieldAt(page, x, y) {
|
|
1360
|
+
try {
|
|
1361
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1362
|
+
wasm.livesession_fieldAt(retptr, this.__wbg_ptr, page, x, y);
|
|
1363
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1364
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1365
|
+
let v1;
|
|
1366
|
+
if (r0 !== 0) {
|
|
1367
|
+
v1 = getStringFromWasm0(r0, r1).slice();
|
|
1368
|
+
wasm.__wbindgen_export4(r0, r1 * 1, 1);
|
|
1369
|
+
}
|
|
1370
|
+
return v1;
|
|
1371
|
+
} finally {
|
|
1372
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
/**
|
|
1376
|
+
* The whole-field highlight boxes for `field` — one union rect per page,
|
|
1377
|
+
* over the field's `span`-bearing content segments. The convenience that
|
|
1378
|
+
* owns the union `regions()` leaves derived: it keeps `regions()` the
|
|
1379
|
+
* low-level disjoint truth (#829) and folds the span-filter + per-page
|
|
1380
|
+
* union here, so a "highlight the focused field" consumer stops
|
|
1381
|
+
* reimplementing it. **Content only** — a field placed solely as a scalar
|
|
1382
|
+
* reference or a bound widget carries no `span` and returns `[]`; its box
|
|
1383
|
+
* is a single `regions()` rect. Reflects the current compile, like
|
|
1384
|
+
* `regions()`.
|
|
1385
|
+
* @param {string} field
|
|
1386
|
+
* @returns {FieldRegion[]}
|
|
1387
|
+
*/
|
|
1388
|
+
fieldBoxes(field) {
|
|
1389
|
+
try {
|
|
1390
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1391
|
+
const ptr0 = passStringToWasm0(field, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
760
1392
|
const len0 = WASM_VECTOR_LEN;
|
|
761
|
-
wasm.
|
|
1393
|
+
wasm.livesession_fieldBoxes(retptr, this.__wbg_ptr, ptr0, len0);
|
|
762
1394
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
763
1395
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
764
|
-
|
|
765
|
-
|
|
1396
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1397
|
+
if (r2) {
|
|
1398
|
+
throw takeObject(r1);
|
|
766
1399
|
}
|
|
1400
|
+
return takeObject(r0);
|
|
767
1401
|
} finally {
|
|
768
1402
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
769
1403
|
}
|
|
770
1404
|
}
|
|
771
1405
|
/**
|
|
772
|
-
*
|
|
773
|
-
*
|
|
774
|
-
*
|
|
775
|
-
*
|
|
776
|
-
*
|
|
777
|
-
*
|
|
778
|
-
*
|
|
779
|
-
*
|
|
780
|
-
|
|
1406
|
+
* A content position → **caret rect** — the reverse of `positionAt`: given
|
|
1407
|
+
* a field and a USV offset into its `Content`, return the box (in the
|
|
1408
|
+
* same bottom-left PDF-point space as `FieldRegion.rect`) to draw a caret
|
|
1409
|
+
* at, its `span` collapsed to `[pos, pos]`; `undefined` when the field
|
|
1410
|
+
* places no tracked content or the offset maps to no drawn glyph.
|
|
1411
|
+
* @param {string} field
|
|
1412
|
+
* @param {number} pos
|
|
1413
|
+
* @returns {FieldRegion | undefined}
|
|
1414
|
+
*/
|
|
1415
|
+
locate(field, pos) {
|
|
1416
|
+
const ptr0 = passStringToWasm0(field, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1417
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1418
|
+
const ret = wasm.livesession_locate(this.__wbg_ptr, ptr0, len0, pos);
|
|
1419
|
+
return takeObject(ret);
|
|
1420
|
+
}
|
|
1421
|
+
/**
|
|
1422
|
+
* @returns {number}
|
|
1423
|
+
*/
|
|
1424
|
+
get pageCount() {
|
|
1425
|
+
const ret = wasm.livesession_pageCount(this.__wbg_ptr);
|
|
1426
|
+
return ret >>> 0;
|
|
1427
|
+
}
|
|
1428
|
+
/**
|
|
1429
|
+
* Page dimensions in points (1 pt = 1/72 inch).
|
|
1430
|
+
* Throws if the backend has no canvas painter or `page` is out of range.
|
|
1431
|
+
* @param {number} page
|
|
1432
|
+
* @returns {PageSize}
|
|
781
1433
|
*/
|
|
782
|
-
|
|
783
|
-
let deferred1_0;
|
|
784
|
-
let deferred1_1;
|
|
1434
|
+
pageSize(page) {
|
|
785
1435
|
try {
|
|
786
1436
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
787
|
-
wasm.
|
|
1437
|
+
wasm.livesession_pageSize(retptr, this.__wbg_ptr, page);
|
|
788
1438
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
789
1439
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
1440
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1441
|
+
if (r2) {
|
|
1442
|
+
throw takeObject(r1);
|
|
1443
|
+
}
|
|
1444
|
+
return takeObject(r0);
|
|
793
1445
|
} finally {
|
|
794
1446
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
795
|
-
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
796
1447
|
}
|
|
797
1448
|
}
|
|
798
1449
|
/**
|
|
799
|
-
*
|
|
800
|
-
*
|
|
801
|
-
*
|
|
1450
|
+
* Paint `page` into a `CanvasRenderingContext2D` or
|
|
1451
|
+
* `OffscreenCanvasRenderingContext2D`. The painter owns
|
|
1452
|
+
* `canvas.width`/`height` (no `clearRect` needed); consumers own
|
|
1453
|
+
* `canvas.style.*`. If `layoutScale * densityScale` exceeds 16384 px
|
|
1454
|
+
* per side, `densityScale` is clamped — `PaintResult.clamped` reports it and
|
|
1455
|
+
* `PaintResult.effectiveDensityScale` carries the density actually applied.
|
|
1456
|
+
*
|
|
1457
|
+
* `put_image_data` writes the whole backing store, bypassing the 2D
|
|
1458
|
+
* context's transform, `globalAlpha`, and clip: the painter owns the entire
|
|
1459
|
+
* canvas, so each visible page needs its own `` — you cannot composite
|
|
1460
|
+
* two pages, a sub-rect, or a context transform through this call.
|
|
1461
|
+
*
|
|
1462
|
+
* Throws if the backend has no canvas painter, `page` is out of range,
|
|
1463
|
+
* `ctx` is the wrong type, or either scale is non-finite or `<= 0`.
|
|
1464
|
+
* @param {CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D} ctx
|
|
1465
|
+
* @param {number} page
|
|
1466
|
+
* @param {PaintOptions | undefined} opts
|
|
1467
|
+
* @returns {PaintResult}
|
|
802
1468
|
*/
|
|
803
|
-
|
|
804
|
-
let deferred1_0;
|
|
805
|
-
let deferred1_1;
|
|
1469
|
+
paint(ctx, page, opts) {
|
|
806
1470
|
try {
|
|
807
1471
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
808
|
-
wasm.
|
|
1472
|
+
wasm.livesession_paint(retptr, this.__wbg_ptr, addHeapObject(ctx), page, addHeapObject(opts));
|
|
809
1473
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
810
1474
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
1475
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1476
|
+
if (r2) {
|
|
1477
|
+
throw takeObject(r1);
|
|
1478
|
+
}
|
|
1479
|
+
return takeObject(r0);
|
|
814
1480
|
} finally {
|
|
815
1481
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
816
|
-
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
817
1482
|
}
|
|
818
1483
|
}
|
|
819
1484
|
/**
|
|
820
|
-
*
|
|
821
|
-
*
|
|
822
|
-
*
|
|
823
|
-
* `undefined`
|
|
824
|
-
*
|
|
825
|
-
*
|
|
826
|
-
*
|
|
1485
|
+
* A point → **content position** — the fine-grained click direction:
|
|
1486
|
+
* hit-test a point and get back the field *and* a USV offset into its
|
|
1487
|
+
* `Content` (for placing a caret or mapping a selection into the content
|
|
1488
|
+
* model), or `undefined` off all content ink. `x`/`y` are PDF points,
|
|
1489
|
+
* bottom-left origin — the same space as `fieldAt`. The offset is
|
|
1490
|
+
* cluster-exact and degrades to the containing segment's start on
|
|
1491
|
+
* origin-less ink (list markers, a code fence's interior). See
|
|
1492
|
+
* `ContentHit`.
|
|
1493
|
+
* @param {number} page
|
|
1494
|
+
* @param {number} x
|
|
1495
|
+
* @param {number} y
|
|
1496
|
+
* @returns {ContentHit | undefined}
|
|
827
1497
|
*/
|
|
828
|
-
|
|
829
|
-
const
|
|
830
|
-
|
|
831
|
-
const ret = wasm.document_tryFromJson(ptr0, len0);
|
|
832
|
-
return ret === 0 ? undefined : Document.__wrap(ret);
|
|
1498
|
+
positionAt(page, x, y) {
|
|
1499
|
+
const ret = wasm.livesession_positionAt(this.__wbg_ptr, page, x, y);
|
|
1500
|
+
return takeObject(ret);
|
|
833
1501
|
}
|
|
834
1502
|
/**
|
|
835
|
-
*
|
|
836
|
-
*
|
|
837
|
-
*
|
|
1503
|
+
* Schema-field geometry for this compiled session — each content field's
|
|
1504
|
+
* **first placement** (one region per page it touches) plus widget and
|
|
1505
|
+
* scalar-reference-site regions, keyed on the quill schema field path; a
|
|
1506
|
+
* field may still appear more than once (group by `field`, see
|
|
1507
|
+
* `FieldRegion`). A session-level query: no render, no byte artifact. An
|
|
1508
|
+
* interactive preview reads it to scroll to / highlight the focused
|
|
1509
|
+
* field over a `paint`-ed canvas; the click direction is `fieldAt`.
|
|
1510
|
+
* Empty for backends that place no schema fields.
|
|
1511
|
+
* @returns {FieldRegion[]}
|
|
838
1512
|
*/
|
|
839
|
-
|
|
1513
|
+
regions() {
|
|
840
1514
|
try {
|
|
841
1515
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
842
|
-
|
|
843
|
-
const len0 = WASM_VECTOR_LEN;
|
|
844
|
-
wasm.document_updateCardBody(retptr, this.__wbg_ptr, index, ptr0, len0);
|
|
1516
|
+
wasm.livesession_regions(retptr, this.__wbg_ptr);
|
|
845
1517
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
846
1518
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
847
|
-
|
|
848
|
-
|
|
1519
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1520
|
+
if (r2) {
|
|
1521
|
+
throw takeObject(r1);
|
|
849
1522
|
}
|
|
1523
|
+
return takeObject(r0);
|
|
850
1524
|
} finally {
|
|
851
1525
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
852
1526
|
}
|
|
853
1527
|
}
|
|
854
1528
|
/**
|
|
855
|
-
*
|
|
856
|
-
*
|
|
857
|
-
* @param {number} index
|
|
858
|
-
* @param {string} name
|
|
859
|
-
* @param {any} value
|
|
1529
|
+
* @param {RenderOptions | null} [opts]
|
|
1530
|
+
* @returns {RenderResult}
|
|
860
1531
|
*/
|
|
861
|
-
|
|
1532
|
+
render(opts) {
|
|
862
1533
|
try {
|
|
863
1534
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
864
|
-
|
|
865
|
-
const len0 = WASM_VECTOR_LEN;
|
|
866
|
-
wasm.document_updateCardField(retptr, this.__wbg_ptr, index, ptr0, len0, addHeapObject(value));
|
|
1535
|
+
wasm.livesession_render(retptr, this.__wbg_ptr, isLikeNone(opts) ? 0 : addHeapObject(opts));
|
|
867
1536
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
868
1537
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
869
|
-
|
|
870
|
-
|
|
1538
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1539
|
+
if (r2) {
|
|
1540
|
+
throw takeObject(r1);
|
|
871
1541
|
}
|
|
1542
|
+
return takeObject(r0);
|
|
872
1543
|
} finally {
|
|
873
1544
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
874
1545
|
}
|
|
875
1546
|
}
|
|
876
1547
|
/**
|
|
1548
|
+
* `true` iff `paint` and `pageSize` will succeed for this session. Derived
|
|
1549
|
+
* from the session's canvas seam, so it reflects exactly what `paint` will
|
|
1550
|
+
* do — no separately captured flag.
|
|
1551
|
+
* @returns {boolean}
|
|
1552
|
+
*/
|
|
1553
|
+
get supportsCanvas() {
|
|
1554
|
+
const ret = wasm.livesession_supportsCanvas(this.__wbg_ptr);
|
|
1555
|
+
return ret !== 0;
|
|
1556
|
+
}
|
|
1557
|
+
/**
|
|
1558
|
+
* Non-fatal diagnostics of the session's **current compile** (e.g. Typst
|
|
1559
|
+
* font fallback) — set at open and refreshed by each committed `apply`;
|
|
1560
|
+
* a failed apply keeps the last-good compile's warnings. Also appended
|
|
1561
|
+
* to `RenderResult.warnings` on each `render()` call.
|
|
877
1562
|
* @returns {Diagnostic[]}
|
|
878
1563
|
*/
|
|
879
1564
|
get warnings() {
|
|
880
1565
|
try {
|
|
881
1566
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
882
|
-
wasm.
|
|
1567
|
+
wasm.livesession_warnings(retptr, this.__wbg_ptr);
|
|
883
1568
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
884
1569
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
885
1570
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -892,7 +1577,7 @@ export class Document {
|
|
|
892
1577
|
}
|
|
893
1578
|
}
|
|
894
1579
|
}
|
|
895
|
-
if (Symbol.dispose)
|
|
1580
|
+
if (Symbol.dispose) LiveSession.prototype[Symbol.dispose] = LiveSession.prototype.free;
|
|
896
1581
|
|
|
897
1582
|
export class Quill {
|
|
898
1583
|
static __wrap(ptr) {
|
|
@@ -1003,9 +1688,10 @@ export class Quill {
|
|
|
1003
1688
|
}
|
|
1004
1689
|
/**
|
|
1005
1690
|
* Document schema for the quill: the user-fillable fields plus their
|
|
1006
|
-
* `ui` hints (group /
|
|
1007
|
-
* surface — drives form editors and LLM/MCP consumers
|
|
1008
|
-
* `
|
|
1691
|
+
* `ui` hints (title / group / compact / multiline). The single
|
|
1692
|
+
* field-metadata surface — drives form editors and LLM/MCP consumers
|
|
1693
|
+
* alike. Key order in `fields`/`properties` is declaration order — the
|
|
1694
|
+
* ordering contract. Returns the `QuillSchema` shape.
|
|
1009
1695
|
* @returns {QuillSchema}
|
|
1010
1696
|
*/
|
|
1011
1697
|
get schema() {
|
|
@@ -1028,9 +1714,9 @@ export class Quill {
|
|
|
1028
1714
|
* layering an optional per-kind seed `overlay` over the schema-example
|
|
1029
1715
|
* base (`overlay › example › absent`). Returns `undefined` if `cardKind`
|
|
1030
1716
|
* is not declared in this quill's schema, else a `Card` that feeds
|
|
1031
|
-
* straight into `Document.
|
|
1717
|
+
* straight into `Document.insertCard`.
|
|
1032
1718
|
*
|
|
1033
|
-
* Pass `document.
|
|
1719
|
+
* Pass `document.seedOverlay(cardKind)` as `overlay` so a card added to a
|
|
1034
1720
|
* template-derived document inherits its curated starting values; omit it
|
|
1035
1721
|
* (or pass `undefined` / `null`) for the bare schema seed. `overlay` is a
|
|
1036
1722
|
* plain object — this reads the document, it does not mutate it.
|
|
@@ -1113,10 +1799,10 @@ export class Quill {
|
|
|
1113
1799
|
*
|
|
1114
1800
|
* Forwards the canonical `validation::*` diagnostics — same `code`,
|
|
1115
1801
|
* `path`, and `hint` the engine emits — including the non-fatal
|
|
1116
|
-
* `validation::
|
|
1117
|
-
* Field values, defaults, and order are not part of this
|
|
1118
|
-
* them from the `Document` payload and `Quill.schema`
|
|
1119
|
-
*
|
|
1802
|
+
* `validation::must_fill` warning for each `!must_fill` marker left in
|
|
1803
|
+
* the document. Field values, defaults, and order are not part of this
|
|
1804
|
+
* surface: read them from the `Document` payload and `Quill.schema`
|
|
1805
|
+
* (schema key order is display order).
|
|
1120
1806
|
* @param {Document} doc
|
|
1121
1807
|
* @returns {Diagnostic[]}
|
|
1122
1808
|
*/
|
|
@@ -1161,10 +1847,10 @@ export class Quillmark {
|
|
|
1161
1847
|
return this;
|
|
1162
1848
|
}
|
|
1163
1849
|
/**
|
|
1164
|
-
* Open
|
|
1850
|
+
* Open a live render session for `doc` against `quill`'s backend.
|
|
1165
1851
|
* @param {Quill} quill
|
|
1166
1852
|
* @param {Document} doc
|
|
1167
|
-
* @returns {
|
|
1853
|
+
* @returns {LiveSession}
|
|
1168
1854
|
*/
|
|
1169
1855
|
open(quill, doc) {
|
|
1170
1856
|
try {
|
|
@@ -1178,14 +1864,14 @@ export class Quillmark {
|
|
|
1178
1864
|
if (r2) {
|
|
1179
1865
|
throw takeObject(r1);
|
|
1180
1866
|
}
|
|
1181
|
-
return
|
|
1867
|
+
return LiveSession.__wrap(r0);
|
|
1182
1868
|
} finally {
|
|
1183
1869
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1184
1870
|
}
|
|
1185
1871
|
}
|
|
1186
1872
|
/**
|
|
1187
1873
|
* Render `doc` against `quill` in one shot. Convenience over `open` +
|
|
1188
|
-
* `
|
|
1874
|
+
* `LiveSession.render`: an unset `output_format` falls back to the
|
|
1189
1875
|
* backend's first supported format.
|
|
1190
1876
|
* @param {Quill} quill
|
|
1191
1877
|
* @param {Document} doc
|
|
@@ -1211,7 +1897,7 @@ export class Quillmark {
|
|
|
1211
1897
|
}
|
|
1212
1898
|
/**
|
|
1213
1899
|
* The output formats `quill`'s backend can emit. Static capability —
|
|
1214
|
-
* resolves the backend but compiles nothing. Throws `
|
|
1900
|
+
* resolves the backend but compiles nothing. Throws `engine::backend_not_found`
|
|
1215
1901
|
* if no registered backend matches the quill's declared backend.
|
|
1216
1902
|
* @param {Quill} quill
|
|
1217
1903
|
* @returns {OutputFormat[]}
|
|
@@ -1233,9 +1919,11 @@ export class Quillmark {
|
|
|
1233
1919
|
}
|
|
1234
1920
|
}
|
|
1235
1921
|
/**
|
|
1236
|
-
* `true` iff `quill`'s backend can paint sessions to a
|
|
1237
|
-
* the
|
|
1238
|
-
* Use as a precondition probe before mounting
|
|
1922
|
+
* Pre-session hint: `true` iff `quill`'s backend can paint sessions to a
|
|
1923
|
+
* canvas, derived from the backend's output formats; `false` when the
|
|
1924
|
+
* backend is unsupported. Use as a cheap precondition probe before mounting
|
|
1925
|
+
* a canvas-based preview UI; the authoritative answer is the session's
|
|
1926
|
+
* `supportsCanvas` getter once `open()` has been called.
|
|
1239
1927
|
* @param {Quill} quill
|
|
1240
1928
|
* @returns {boolean}
|
|
1241
1929
|
*/
|
|
@@ -1248,158 +1936,62 @@ export class Quillmark {
|
|
|
1248
1936
|
if (Symbol.dispose) Quillmark.prototype[Symbol.dispose] = Quillmark.prototype.free;
|
|
1249
1937
|
|
|
1250
1938
|
/**
|
|
1251
|
-
*
|
|
1252
|
-
*
|
|
1253
|
-
*
|
|
1254
|
-
*
|
|
1255
|
-
*
|
|
1256
|
-
* rather than catching the error.
|
|
1939
|
+
* Export a canonical `Content` content to its markdown projection — the pure
|
|
1940
|
+
* on-demand codec behind `exportMarkdown(card.body)`. Throws if `rt` is not a
|
|
1941
|
+
* canonical content.
|
|
1942
|
+
* @param {Content} rt
|
|
1943
|
+
* @returns {string}
|
|
1257
1944
|
*/
|
|
1258
|
-
export
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
const ptr = this.__destroy_into_raw();
|
|
1274
|
-
wasm.__wbg_rendersession_free(ptr, 0);
|
|
1275
|
-
}
|
|
1276
|
-
/**
|
|
1277
|
-
* The backend that produced this session (e.g. `"typst"`).
|
|
1278
|
-
* @returns {string}
|
|
1279
|
-
*/
|
|
1280
|
-
get backendId() {
|
|
1281
|
-
let deferred1_0;
|
|
1282
|
-
let deferred1_1;
|
|
1283
|
-
try {
|
|
1284
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1285
|
-
wasm.rendersession_backendId(retptr, this.__wbg_ptr);
|
|
1286
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1287
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1288
|
-
deferred1_0 = r0;
|
|
1289
|
-
deferred1_1 = r1;
|
|
1290
|
-
return getStringFromWasm0(r0, r1);
|
|
1291
|
-
} finally {
|
|
1292
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1293
|
-
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
1294
|
-
}
|
|
1295
|
-
}
|
|
1296
|
-
/**
|
|
1297
|
-
* @returns {number}
|
|
1298
|
-
*/
|
|
1299
|
-
get pageCount() {
|
|
1300
|
-
const ret = wasm.rendersession_pageCount(this.__wbg_ptr);
|
|
1301
|
-
return ret >>> 0;
|
|
1302
|
-
}
|
|
1303
|
-
/**
|
|
1304
|
-
* Page dimensions in Typst points (1 pt = 1/72 inch).
|
|
1305
|
-
* Throws if the backend has no canvas painter or `page` is out of range.
|
|
1306
|
-
* @param {number} page
|
|
1307
|
-
* @returns {PageSize}
|
|
1308
|
-
*/
|
|
1309
|
-
pageSize(page) {
|
|
1310
|
-
try {
|
|
1311
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1312
|
-
wasm.rendersession_pageSize(retptr, this.__wbg_ptr, page);
|
|
1313
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1314
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1315
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1316
|
-
if (r2) {
|
|
1317
|
-
throw takeObject(r1);
|
|
1318
|
-
}
|
|
1319
|
-
return takeObject(r0);
|
|
1320
|
-
} finally {
|
|
1321
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1322
|
-
}
|
|
1323
|
-
}
|
|
1324
|
-
/**
|
|
1325
|
-
* Paint `page` into a `CanvasRenderingContext2D` or
|
|
1326
|
-
* `OffscreenCanvasRenderingContext2D`. The painter owns
|
|
1327
|
-
* `canvas.width`/`height` (no `clearRect` needed); consumers own
|
|
1328
|
-
* `canvas.style.*`. If `layoutScale * densityScale` exceeds 16384 px
|
|
1329
|
-
* per side, `densityScale` is clamped — detect via `PaintResult.pixelWidth`.
|
|
1330
|
-
*
|
|
1331
|
-
* Throws if the backend has no canvas painter, `page` is out of range,
|
|
1332
|
-
* `ctx` is the wrong type, or either scale is non-finite or `<= 0`.
|
|
1333
|
-
* @param {CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D} ctx
|
|
1334
|
-
* @param {number} page
|
|
1335
|
-
* @param {PaintOptions | undefined} opts
|
|
1336
|
-
* @returns {PaintResult}
|
|
1337
|
-
*/
|
|
1338
|
-
paint(ctx, page, opts) {
|
|
1339
|
-
try {
|
|
1340
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1341
|
-
wasm.rendersession_paint(retptr, this.__wbg_ptr, addHeapObject(ctx), page, addHeapObject(opts));
|
|
1342
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1343
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1344
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1345
|
-
if (r2) {
|
|
1346
|
-
throw takeObject(r1);
|
|
1347
|
-
}
|
|
1348
|
-
return takeObject(r0);
|
|
1349
|
-
} finally {
|
|
1350
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
/**
|
|
1354
|
-
* @param {RenderOptions | null} [opts]
|
|
1355
|
-
* @returns {RenderResult}
|
|
1356
|
-
*/
|
|
1357
|
-
render(opts) {
|
|
1358
|
-
try {
|
|
1359
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1360
|
-
wasm.rendersession_render(retptr, this.__wbg_ptr, isLikeNone(opts) ? 0 : addHeapObject(opts));
|
|
1361
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1362
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1363
|
-
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1364
|
-
if (r2) {
|
|
1365
|
-
throw takeObject(r1);
|
|
1366
|
-
}
|
|
1367
|
-
return takeObject(r0);
|
|
1368
|
-
} finally {
|
|
1369
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1945
|
+
export function exportMarkdown(rt) {
|
|
1946
|
+
let deferred2_0;
|
|
1947
|
+
let deferred2_1;
|
|
1948
|
+
try {
|
|
1949
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1950
|
+
wasm.exportMarkdown(retptr, addHeapObject(rt));
|
|
1951
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1952
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1953
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1954
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
1955
|
+
var ptr1 = r0;
|
|
1956
|
+
var len1 = r1;
|
|
1957
|
+
if (r3) {
|
|
1958
|
+
ptr1 = 0; len1 = 0;
|
|
1959
|
+
throw takeObject(r2);
|
|
1370
1960
|
}
|
|
1961
|
+
deferred2_0 = ptr1;
|
|
1962
|
+
deferred2_1 = len1;
|
|
1963
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1964
|
+
} finally {
|
|
1965
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1966
|
+
wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
1371
1967
|
}
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
if (r2) {
|
|
1394
|
-
throw takeObject(r1);
|
|
1395
|
-
}
|
|
1396
|
-
return takeObject(r0);
|
|
1397
|
-
} finally {
|
|
1398
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
/**
|
|
1971
|
+
* Import a markdown string to a canonical `Content` content — the pure,
|
|
1972
|
+
* document-free codec. Pair with `install(addr, importMarkdown(md))` to spell
|
|
1973
|
+
* the cold (anchor-losing) write at the call site; prefer `revise` for edit
|
|
1974
|
+
* semantics. Throws on an over-nested input.
|
|
1975
|
+
* @param {string} markdown
|
|
1976
|
+
* @returns {Content}
|
|
1977
|
+
*/
|
|
1978
|
+
export function importMarkdown(markdown) {
|
|
1979
|
+
try {
|
|
1980
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1981
|
+
const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1982
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1983
|
+
wasm.importMarkdown(retptr, ptr0, len0);
|
|
1984
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1985
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1986
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1987
|
+
if (r2) {
|
|
1988
|
+
throw takeObject(r1);
|
|
1399
1989
|
}
|
|
1990
|
+
return takeObject(r0);
|
|
1991
|
+
} finally {
|
|
1992
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1400
1993
|
}
|
|
1401
1994
|
}
|
|
1402
|
-
if (Symbol.dispose) RenderSession.prototype[Symbol.dispose] = RenderSession.prototype.free;
|
|
1403
1995
|
|
|
1404
1996
|
/**
|
|
1405
1997
|
* Initialize the WASM module with panic hooks for better error messages
|
|
@@ -1407,10 +1999,68 @@ if (Symbol.dispose) RenderSession.prototype[Symbol.dispose] = RenderSession.prot
|
|
|
1407
1999
|
export function init() {
|
|
1408
2000
|
wasm.init();
|
|
1409
2001
|
}
|
|
2002
|
+
|
|
2003
|
+
/**
|
|
2004
|
+
* Map a base content position through a `delta` to its new position — the pure
|
|
2005
|
+
* position-mapping codec an editor bridge composes to hold a caret stable
|
|
2006
|
+
* across a `revise`. `assoc` decides the side of a same-position insertion
|
|
2007
|
+
* (`"after"` moves past it). Throws on a malformed `delta`.
|
|
2008
|
+
* @param {Delta} delta
|
|
2009
|
+
* @param {number} pos
|
|
2010
|
+
* @param {Assoc} assoc
|
|
2011
|
+
* @returns {number}
|
|
2012
|
+
*/
|
|
2013
|
+
export function mapPos(delta, pos, assoc) {
|
|
2014
|
+
try {
|
|
2015
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2016
|
+
wasm.mapPos(retptr, addHeapObject(delta), pos, addHeapObject(assoc));
|
|
2017
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2018
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2019
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2020
|
+
if (r2) {
|
|
2021
|
+
throw takeObject(r1);
|
|
2022
|
+
}
|
|
2023
|
+
return r0 >>> 0;
|
|
2024
|
+
} finally {
|
|
2025
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2026
|
+
}
|
|
2027
|
+
}
|
|
2028
|
+
|
|
2029
|
+
/**
|
|
2030
|
+
* Rebase `markdown` onto a `base` content — the pure, document-free twin of
|
|
2031
|
+
* `revise`: cold-import + `diff_import`, returning the new `content` and the
|
|
2032
|
+
* text `delta` (surviving anchors rebased). Use it to compute a revise without
|
|
2033
|
+
* a document in hand; `revise(addr, md)` fuses this with the store for
|
|
2034
|
+
* atomicity. Throws on an over-nested markdown input or a non-content `base`.
|
|
2035
|
+
* @param {Content} base
|
|
2036
|
+
* @param {string} markdown
|
|
2037
|
+
* @returns {{ content: Content; delta: Delta }}
|
|
2038
|
+
*/
|
|
2039
|
+
export function rebase(base, markdown) {
|
|
2040
|
+
try {
|
|
2041
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2042
|
+
const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
2043
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2044
|
+
wasm.rebase(retptr, addHeapObject(base), ptr0, len0);
|
|
2045
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2046
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2047
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
2048
|
+
if (r2) {
|
|
2049
|
+
throw takeObject(r1);
|
|
2050
|
+
}
|
|
2051
|
+
return takeObject(r0);
|
|
2052
|
+
} finally {
|
|
2053
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
1410
2056
|
export function __wbg_Error_960c155d3d49e4c2(arg0, arg1) {
|
|
1411
2057
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
1412
2058
|
return addHeapObject(ret);
|
|
1413
2059
|
}
|
|
2060
|
+
export function __wbg_Number_32bf70a599af1d4b(arg0) {
|
|
2061
|
+
const ret = Number(getObject(arg0));
|
|
2062
|
+
return ret;
|
|
2063
|
+
}
|
|
1414
2064
|
export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
1415
2065
|
const ret = String(getObject(arg1));
|
|
1416
2066
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
@@ -1795,15 +2445,15 @@ export function __wbindgen_object_drop_ref(arg0) {
|
|
|
1795
2445
|
const DocumentFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1796
2446
|
? { register: () => {}, unregister: () => {} }
|
|
1797
2447
|
: new FinalizationRegistry(ptr => wasm.__wbg_document_free(ptr >>> 0, 1));
|
|
2448
|
+
const LiveSessionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2449
|
+
? { register: () => {}, unregister: () => {} }
|
|
2450
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_livesession_free(ptr >>> 0, 1));
|
|
1798
2451
|
const QuillFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1799
2452
|
? { register: () => {}, unregister: () => {} }
|
|
1800
2453
|
: new FinalizationRegistry(ptr => wasm.__wbg_quill_free(ptr >>> 0, 1));
|
|
1801
2454
|
const QuillmarkFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1802
2455
|
? { register: () => {}, unregister: () => {} }
|
|
1803
2456
|
: new FinalizationRegistry(ptr => wasm.__wbg_quillmark_free(ptr >>> 0, 1));
|
|
1804
|
-
const RenderSessionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1805
|
-
? { register: () => {}, unregister: () => {} }
|
|
1806
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_rendersession_free(ptr >>> 0, 1));
|
|
1807
2457
|
|
|
1808
2458
|
function addHeapObject(obj) {
|
|
1809
2459
|
if (heap_next === heap.length) heap.push(heap.length + 1);
|