@quillmark/wasm 0.104.0 → 0.106.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +244 -27
- package/README.md +72 -206
- package/backends/pdfform/wasm.d.ts +465 -713
- package/backends/pdfform/wasm.js +365 -491
- package/backends/pdfform/wasm_bg.wasm +0 -0
- package/backends/pdfform/wasm_bg.wasm.d.ts +1 -0
- package/backends/typst/wasm.d.ts +465 -713
- package/backends/typst/wasm.js +365 -491
- package/backends/typst/wasm_bg.wasm +0 -0
- package/backends/typst/wasm_bg.wasm.d.ts +1 -0
- package/core/wasm.d.ts +337 -492
- package/core/wasm.js +310 -411
- package/core/wasm_bg.wasm +0 -0
- package/core/wasm_bg.wasm.d.ts +1 -0
- package/package.json +1 -1
- package/runtime/runtime.d.ts +181 -255
- package/runtime/runtime.js +190 -353
package/backends/pdfform/wasm.js
CHANGED
|
@@ -24,16 +24,12 @@ export class Document {
|
|
|
24
24
|
/**
|
|
25
25
|
* Build a composable card of `kind`, typed-commit `fields` onto it, set its
|
|
26
26
|
* body from optional markdown, and place it: the ABI under `writer.addCard`.
|
|
27
|
-
* `at`
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* same per-field diagnostic bundle as [`commitFields`](Self::commit_fields),
|
|
34
|
-
* including an `edit::unknown_field` per undeclared name; an invalid
|
|
35
|
-
* kind or body, or an out-of-range position, throws a single-entry bundle
|
|
36
|
-
* keyed `$kind` / `$body`.
|
|
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`.
|
|
37
33
|
* @param {Quill} quill
|
|
38
34
|
* @param {string} kind
|
|
39
35
|
* @param {Record<string, unknown>} [fields]
|
|
@@ -60,26 +56,22 @@ export class Document {
|
|
|
60
56
|
}
|
|
61
57
|
/**
|
|
62
58
|
* Typed field write at `addr`, resolving the field's schema `type` from
|
|
63
|
-
* `quill`: the stable ABI under the runtime `writer.set
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* use the encoding the seam already speaks: a content object or markdown
|
|
70
|
-
* string for richtext, a scalar/array/object otherwise.
|
|
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.
|
|
71
65
|
*
|
|
72
|
-
* A bare string is `Addr` shorthand for `{ field }
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* `edit::
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* `edit::
|
|
81
|
-
* on a typed mismatch, `edit::invalid_field_name` on a malformed name,
|
|
82
|
-
* and `edit::index_out_of_range` on an out-of-range card.
|
|
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.
|
|
83
75
|
*
|
|
84
76
|
* The `quill` handle is passed per call because a `Document` carries only a
|
|
85
77
|
* `$quill` reference, not the resolved schema.
|
|
@@ -103,15 +95,12 @@ export class Document {
|
|
|
103
95
|
}
|
|
104
96
|
/**
|
|
105
97
|
* Batched twin of [`commitField`](Document::commit_field): typed-commit
|
|
106
|
-
* several fields on the card `addr` targets atomically
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* including an `edit::unknown_field` for any name the schema does not
|
|
113
|
-
* declare, so a whole-form submit sees every typo in one pass. Throws on an
|
|
114
|
-
* out-of-range card.
|
|
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.
|
|
115
104
|
* @param {Quill} quill
|
|
116
105
|
* @param {CardAddr} addr
|
|
117
106
|
* @param {Record<string, unknown>} fields
|
|
@@ -132,21 +121,17 @@ export class Document {
|
|
|
132
121
|
}
|
|
133
122
|
/**
|
|
134
123
|
* Interpreted read at `addr`, resolving the field's declared `type` from
|
|
135
|
-
* `quill`: the stable ABI under the runtime `reader.get
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* meaning rather than by wire shape.
|
|
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.
|
|
140
128
|
*
|
|
141
129
|
* A bare string is `Addr` shorthand for `{ field }`; `{ card, field }`
|
|
142
|
-
* targets a composable card
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
* lacks: there an unknown name reads back `undefined`); a `richtext` field
|
|
148
|
-
* holding a value that does not decode throws `edit::field_decode`;
|
|
149
|
-
* an out-of-range `addr.card` throws.
|
|
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.
|
|
150
135
|
*
|
|
151
136
|
* The `quill` handle is passed per call because a `Document` carries only a
|
|
152
137
|
* `$quill` reference, not the resolved schema.
|
|
@@ -172,25 +157,19 @@ export class Document {
|
|
|
172
157
|
}
|
|
173
158
|
/**
|
|
174
159
|
* Interpreted **`Content`** read at `addr`: the stable ABI under the runtime
|
|
175
|
-
* `reader.getContent
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
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.
|
|
179
165
|
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
* absent `addr.field` reads the **body** `Content`, quill-free, mirroring
|
|
188
|
-
* [`getStored`](Self::get_stored). Throws `edit::unknown_field` for a name
|
|
189
|
-
* the schema does not declare, `edit::field_not_content` for a declared type
|
|
190
|
-
* that is not a content leaf (`array<richtext>` carries content and still has
|
|
191
|
-
* no one `Content`), `edit::field_decode` for a stored value
|
|
192
|
-
* that decodes under neither encoding, and `edit::index_out_of_range` for a
|
|
193
|
-
* bad `addr.card`.
|
|
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`.
|
|
194
173
|
* @param {Quill} quill
|
|
195
174
|
* @param {Addr | string} addr
|
|
196
175
|
* @returns {Content | undefined}
|
|
@@ -212,23 +191,59 @@ export class Document {
|
|
|
212
191
|
}
|
|
213
192
|
}
|
|
214
193
|
/**
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
* multi-block result with `edit::field_not_inline`. Returns the
|
|
222
|
-
* text `Delta`.
|
|
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.
|
|
223
200
|
*
|
|
224
|
-
* The codec is the declared type's
|
|
225
|
-
* the
|
|
201
|
+
* The codec is the leaf's declared type's, so the caller stops deciding
|
|
202
|
+
* what an element's stored bytes mean. Total over the storage form, as the
|
|
203
|
+
* whole-field read is.
|
|
204
|
+
*
|
|
205
|
+
* `undefined` when the field is absent **and when `path` names nothing in
|
|
206
|
+
* the stored value**: a repeater's row index goes stale between derive and
|
|
207
|
+
* read, and absence there is a read, not a fault. Throws
|
|
208
|
+
* `edit::unknown_field` for an undeclared name at any depth,
|
|
209
|
+
* `edit::field_not_content` when `path` resolves to no content leaf,
|
|
210
|
+
* `edit::field_decode` for a value that decodes under neither encoding
|
|
211
|
+
* (anchored at the addressed path), and `edit::index_out_of_range` for a
|
|
212
|
+
* bad `addr.card`. A body address throws: a body has no nested content
|
|
213
|
+
* address.
|
|
214
|
+
* @param {Quill} quill
|
|
215
|
+
* @param {Addr | string} addr
|
|
216
|
+
* @param {PathStep[]} path
|
|
217
|
+
* @returns {Content | undefined}
|
|
218
|
+
*/
|
|
219
|
+
_readerGetContentAt(quill, addr, path) {
|
|
220
|
+
try {
|
|
221
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
222
|
+
_assertClass(quill, Quill);
|
|
223
|
+
wasm.document__readerGetContentAt(retptr, this.__wbg_ptr, quill.__wbg_ptr, addHeapObject(addr), addHeapObject(path));
|
|
224
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
225
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
226
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
227
|
+
if (r2) {
|
|
228
|
+
throw takeObject(r1);
|
|
229
|
+
}
|
|
230
|
+
return takeObject(r0);
|
|
231
|
+
} finally {
|
|
232
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Revise the content field at `addr` from authored text, typed *and*
|
|
237
|
+
* anchor-preserving: the ABI under `writer.reviseField`. Surviving anchors
|
|
238
|
+
* rebase as in [`revise`](Self::revise), then the diffed result is
|
|
239
|
+
* schema-conformed, so a `richtext(inline)` field rejects a multi-block
|
|
240
|
+
* result with `edit::field_not_inline`. Returns the text `Delta`. The codec
|
|
241
|
+
* is the declared type's: `richtext` diffs markdown, `plaintext` literal
|
|
242
|
+
* text.
|
|
226
243
|
*
|
|
227
|
-
* `addr` must name a field
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
* on an out-of-range card. Hidden from the `.d.ts`; the visible verb is
|
|
231
|
-
* `writer.reviseField` in the runtime layer.
|
|
244
|
+
* `addr` must name a field; a body address throws, since a body carries no
|
|
245
|
+
* field schema (use [`revise`](Self::revise)). An undeclared name throws
|
|
246
|
+
* `edit::unknown_field`, an out-of-range card throws.
|
|
232
247
|
* @param {Quill} quill
|
|
233
248
|
* @param {Addr | string} addr
|
|
234
249
|
* @param {string} text
|
|
@@ -253,19 +268,16 @@ export class Document {
|
|
|
253
268
|
}
|
|
254
269
|
}
|
|
255
270
|
/**
|
|
256
|
-
* **Apply** a committed content edit `bundle`
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
* The island channel keeps a table or image edit on the op path: it moves
|
|
263
|
-
* the island alone, so the anchors elsewhere in the field survive an edit
|
|
271
|
+
* **Apply** a committed content edit `bundle` at `addr`, the editor splice:
|
|
272
|
+
* text delta first, then island ops, then line ops, then mark ops (mark
|
|
273
|
+
* ranges in final-text coordinates), all-or-nothing. An absent `addr.field`
|
|
274
|
+
* targets the body, an absent `addr.card` the main card. The island channel
|
|
275
|
+
* moves an island alone, so anchors elsewhere in the field survive an edit
|
|
264
276
|
* `overwrite` would clear.
|
|
265
277
|
*
|
|
266
278
|
* Throws on an out-of-range card, a field that is not richtext, a malformed
|
|
267
|
-
* bundle, or an op that applies out of bounds
|
|
268
|
-
* failed apply
|
|
279
|
+
* bundle, or an op that applies out of bounds; the value is unchanged on a
|
|
280
|
+
* failed apply.
|
|
269
281
|
* @param {Addr | string} addr
|
|
270
282
|
* @param {ChangeBundle} bundle
|
|
271
283
|
*/
|
|
@@ -283,10 +295,8 @@ export class Document {
|
|
|
283
295
|
}
|
|
284
296
|
}
|
|
285
297
|
/**
|
|
286
|
-
* Authoring-ergonomics header introducing a blueprint to an LLM/MCP
|
|
287
|
-
*
|
|
288
|
-
* JS consumers; any surface that draws from the same core source stays
|
|
289
|
-
* uniform.
|
|
298
|
+
* Authoring-ergonomics header introducing a blueprint to an LLM/MCP consumer
|
|
299
|
+
* for the given `quillName`, re-exposed from core.
|
|
290
300
|
* @param {string} quill_name
|
|
291
301
|
* @returns {string}
|
|
292
302
|
*/
|
|
@@ -309,15 +319,13 @@ export class Document {
|
|
|
309
319
|
}
|
|
310
320
|
}
|
|
311
321
|
/**
|
|
312
|
-
* The **body** markdown projection
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
* this read stays quill-free; a body is never absent.
|
|
322
|
+
* The **body** markdown projection: an on-demand, lossy export (content-only
|
|
323
|
+
* marks do not survive markdown). A body's type is a format fact, not a
|
|
324
|
+
* schema fact, so this read stays quill-free, and a body is never absent.
|
|
316
325
|
*
|
|
317
|
-
* `addr` is an optional
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
* type. An out-of-range `addr.card` throws.
|
|
326
|
+
* `addr` is an optional card address (absent = main). A present `field`
|
|
327
|
+
* throws: read a field's markdown through `quill.reader(doc).get(field)`,
|
|
328
|
+
* which interprets by declared type. An out-of-range `addr.card` throws.
|
|
321
329
|
* @param {CardAddr} [addr]
|
|
322
330
|
* @returns {string}
|
|
323
331
|
*/
|
|
@@ -337,11 +345,9 @@ export class Document {
|
|
|
337
345
|
}
|
|
338
346
|
}
|
|
339
347
|
/**
|
|
340
|
-
* A single composable card by index
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
* `index` throws `edit::index_out_of_range`, matching the card write
|
|
344
|
-
* verbs.
|
|
348
|
+
* A single composable card by index, so reading one need not materialize
|
|
349
|
+
* every card via [`cards`](Self::cards). An out-of-range `index` throws
|
|
350
|
+
* `edit::index_out_of_range`.
|
|
345
351
|
* @param {number} index
|
|
346
352
|
* @returns {Card}
|
|
347
353
|
*/
|
|
@@ -361,7 +367,7 @@ export class Document {
|
|
|
361
367
|
}
|
|
362
368
|
}
|
|
363
369
|
/**
|
|
364
|
-
* Number of composable cards
|
|
370
|
+
* Number of composable cards, excluding the main card.
|
|
365
371
|
* @returns {number}
|
|
366
372
|
*/
|
|
367
373
|
get cardCount() {
|
|
@@ -369,10 +375,10 @@ export class Document {
|
|
|
369
375
|
return ret >>> 0;
|
|
370
376
|
}
|
|
371
377
|
/**
|
|
372
|
-
* The composable card's own path, `cards.<kind>[index]`: the
|
|
373
|
-
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
378
|
+
* The composable card's own path, `cards.<kind>[index]`: the root
|
|
379
|
+
* [`pathFor`](Self::path_for) extends, for anchoring the card rather than
|
|
380
|
+
* one of its fields. Total on the index axis; out of range renders
|
|
381
|
+
* `cards[index]`.
|
|
376
382
|
* @param {number} index
|
|
377
383
|
* @returns {string}
|
|
378
384
|
*/
|
|
@@ -418,9 +424,8 @@ export class Document {
|
|
|
418
424
|
return Document.__wrap(ret);
|
|
419
425
|
}
|
|
420
426
|
/**
|
|
421
|
-
* Storage version this build writes via [`toJson`](Document::to_json).
|
|
422
|
-
*
|
|
423
|
-
* the tag advances only when the wire format changes, not on every release.
|
|
427
|
+
* Storage version this build writes via [`toJson`](Document::to_json). The
|
|
428
|
+
* tag advances only when the wire format changes, not on every release.
|
|
424
429
|
* @returns {string}
|
|
425
430
|
*/
|
|
426
431
|
static currentStorageVersion() {
|
|
@@ -440,8 +445,7 @@ export class Document {
|
|
|
440
445
|
}
|
|
441
446
|
}
|
|
442
447
|
/**
|
|
443
|
-
* Structural equality
|
|
444
|
-
* upstream prop updates instead of re-parsing on every keystroke.
|
|
448
|
+
* Structural equality, excluding parse-time `warnings`.
|
|
445
449
|
* @param {Document} other
|
|
446
450
|
* @returns {boolean}
|
|
447
451
|
*/
|
|
@@ -451,9 +455,8 @@ export class Document {
|
|
|
451
455
|
return ret !== 0;
|
|
452
456
|
}
|
|
453
457
|
/**
|
|
454
|
-
* Render a Diagnostic as the canonical pretty-printed text
|
|
455
|
-
*
|
|
456
|
-
* identical no matter which consumer surfaces it.
|
|
458
|
+
* Render a Diagnostic as the canonical pretty-printed text, so it looks
|
|
459
|
+
* identical whichever consumer surfaces it.
|
|
457
460
|
* @param {Diagnostic} diag
|
|
458
461
|
* @returns {string}
|
|
459
462
|
*/
|
|
@@ -474,11 +477,8 @@ export class Document {
|
|
|
474
477
|
}
|
|
475
478
|
}
|
|
476
479
|
/**
|
|
477
|
-
* Authoring-format rules for the card-yaml markdown surface
|
|
478
|
-
*
|
|
479
|
-
* here for JS consumers so it matches any other surface that draws from the
|
|
480
|
-
* same source. Read once at startup and cache; the value never changes
|
|
481
|
-
* between calls.
|
|
480
|
+
* Authoring-format rules for the card-yaml markdown surface, re-exposed from
|
|
481
|
+
* core. Constant across calls; read once and cache.
|
|
482
482
|
* @returns {string}
|
|
483
483
|
*/
|
|
484
484
|
static formatRules() {
|
|
@@ -498,10 +498,8 @@ export class Document {
|
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
500
|
/**
|
|
501
|
-
* Reconstruct a `Document` from a versioned storage DTO string produced
|
|
502
|
-
*
|
|
503
|
-
* The result carries no parse-time warnings (`.warnings` is always empty).
|
|
504
|
-
*
|
|
501
|
+
* Reconstruct a `Document` from a versioned storage DTO string produced by
|
|
502
|
+
* [`toJson`](Document::to_json). The result carries no parse-time warnings.
|
|
505
503
|
* Throws if `json` is not a valid storage DTO (malformed JSON, unknown
|
|
506
504
|
* `schema`, missing fields, or unparseable quill reference).
|
|
507
505
|
* @param {string} json
|
|
@@ -548,9 +546,9 @@ export class Document {
|
|
|
548
546
|
}
|
|
549
547
|
/**
|
|
550
548
|
* The whole `$ext` map at `addr` (a card address, absent `card` = main), or
|
|
551
|
-
* `undefined` when the card carries none
|
|
552
|
-
*
|
|
553
|
-
*
|
|
549
|
+
* `undefined` when the card carries none: the `$ext` read that avoids
|
|
550
|
+
* serializing the whole card. Throws on a present `field` or an
|
|
551
|
+
* out-of-range card.
|
|
554
552
|
* @param {CardAddr} [addr]
|
|
555
553
|
* @returns {Record<string, unknown> | undefined}
|
|
556
554
|
*/
|
|
@@ -571,9 +569,8 @@ export class Document {
|
|
|
571
569
|
}
|
|
572
570
|
/**
|
|
573
571
|
* The value stored under `$ext[ns]` at `addr` (a card address, absent `card`
|
|
574
|
-
* = main), or `undefined`.
|
|
575
|
-
*
|
|
576
|
-
* `removeExtNamespace`). Throws on a present `field` or an out-of-range card.
|
|
572
|
+
* = main), or `undefined`. Throws on a present `field` or an out-of-range
|
|
573
|
+
* card.
|
|
577
574
|
* @param {CardAddr} addr
|
|
578
575
|
* @param {string} ns
|
|
579
576
|
* @returns {unknown}
|
|
@@ -596,25 +593,20 @@ export class Document {
|
|
|
596
593
|
}
|
|
597
594
|
}
|
|
598
595
|
/**
|
|
599
|
-
* Read the **verbatim stored value** at `addr`:
|
|
600
|
-
*
|
|
601
|
-
*
|
|
602
|
-
*
|
|
603
|
-
*
|
|
604
|
-
*
|
|
605
|
-
*
|
|
606
|
-
* markdown projection use [`bodyMarkdown`](Self::get_markdown) (body) or
|
|
607
|
-
* `reader.get` (a field's declared type).
|
|
596
|
+
* Read the **verbatim stored value** at `addr`: a field's raw payload value,
|
|
597
|
+
* or the body content when `addr.field` is absent. A bare string is `Addr`
|
|
598
|
+
* shorthand for `{ field }`. Needs no schema: the read echo of the verbatim
|
|
599
|
+
* `store*` write, distinct from the interpreted
|
|
600
|
+
* [`reader.get`](Self::reader_get). Reads are total over the field axis — an
|
|
601
|
+
* absent field is `undefined` — and only an out-of-range `addr.card` throws
|
|
602
|
+
* `edit::index_out_of_range`.
|
|
608
603
|
*
|
|
609
|
-
*
|
|
610
|
-
*
|
|
611
|
-
* string. A document
|
|
612
|
-
*
|
|
613
|
-
*
|
|
614
|
-
*
|
|
615
|
-
* it is conformed, and this read reports what is there. For the `Content`
|
|
616
|
-
* either way, use the schema-plane `reader.getContent`, which decodes
|
|
617
|
-
* through the codec the field's declared type names.
|
|
604
|
+
* A content field at rest has one stored form per codec: a `richtext` field
|
|
605
|
+
* holds the canonical content object, a `plaintext` field its literal
|
|
606
|
+
* string. A document from the bound door (`quill.parse` / `quill.conform`)
|
|
607
|
+
* is at rest; one from the transport door may rest as authored until it is
|
|
608
|
+
* conformed, and this read reports what is there. For the `Content` either
|
|
609
|
+
* way use `reader.getContent`.
|
|
618
610
|
* @param {Addr | string} addr
|
|
619
611
|
* @returns {unknown}
|
|
620
612
|
*/
|
|
@@ -634,12 +626,10 @@ export class Document {
|
|
|
634
626
|
}
|
|
635
627
|
}
|
|
636
628
|
/**
|
|
637
|
-
* Insert a card
|
|
638
|
-
*
|
|
639
|
-
*
|
|
640
|
-
*
|
|
641
|
-
* (every returned `Card` is a valid `CardInput`). Throws if `card.kind` is
|
|
642
|
-
* not a valid kind name, or if `at` is out of range.
|
|
629
|
+
* Insert a card: `at` absent appends, a number inserts at that index (in
|
|
630
|
+
* `0..=cards.length`). Accepts any `CardInput`, including a card read back
|
|
631
|
+
* out of a document. Throws if `card.kind` is not a valid kind name, or if
|
|
632
|
+
* `at` is out of range.
|
|
643
633
|
* @param {CardInput} card
|
|
644
634
|
* @param {number} [at]
|
|
645
635
|
*/
|
|
@@ -658,9 +648,8 @@ export class Document {
|
|
|
658
648
|
}
|
|
659
649
|
/**
|
|
660
650
|
* Whether the field at `addr` is marked `!must_fill`. A bare string is `Addr`
|
|
661
|
-
* shorthand for `{ field }`. `false` for an absent field
|
|
662
|
-
*
|
|
663
|
-
* out-of-range `addr.card` throws.
|
|
651
|
+
* shorthand for `{ field }`. `false` for an absent field and for a body
|
|
652
|
+
* address; only an out-of-range `addr.card` throws.
|
|
664
653
|
* @param {Addr | string} addr
|
|
665
654
|
* @returns {boolean}
|
|
666
655
|
*/
|
|
@@ -680,15 +669,14 @@ export class Document {
|
|
|
680
669
|
}
|
|
681
670
|
}
|
|
682
671
|
/**
|
|
683
|
-
* Replace this document's contents **in place** from a versioned storage
|
|
684
|
-
*
|
|
685
|
-
*
|
|
686
|
-
*
|
|
672
|
+
* Replace this document's contents **in place** from a versioned storage DTO
|
|
673
|
+
* string: the mutating twin of [`fromJson`](Document::from_json). Parse-time
|
|
674
|
+
* `warnings` are cleared. Throws on an invalid DTO, leaving the document
|
|
675
|
+
* unchanged.
|
|
687
676
|
*
|
|
688
677
|
* The cross-WASM-memory `Document` bridge: mutate a document on a
|
|
689
|
-
* backend-memory clone, then write the
|
|
690
|
-
* canonical document
|
|
691
|
-
* the linear-memory seam without the caller re-binding its variable.
|
|
678
|
+
* backend-memory clone, then write the state back into the caller's
|
|
679
|
+
* canonical document, without the caller re-binding its variable.
|
|
692
680
|
* @param {string} json
|
|
693
681
|
*/
|
|
694
682
|
loadJson(json) {
|
|
@@ -707,8 +695,7 @@ export class Document {
|
|
|
707
695
|
}
|
|
708
696
|
}
|
|
709
697
|
/**
|
|
710
|
-
* The document's main (entry) card. Allocates and serializes on each
|
|
711
|
-
* call: cache locally if read in a hot loop.
|
|
698
|
+
* The document's main (entry) card. Allocates and serializes on each call.
|
|
712
699
|
* @returns {Card}
|
|
713
700
|
*/
|
|
714
701
|
get main() {
|
|
@@ -728,17 +715,12 @@ export class Document {
|
|
|
728
715
|
}
|
|
729
716
|
/**
|
|
730
717
|
* Build a fresh `Card` from a kind and a flat field map: the ergonomic
|
|
731
|
-
* constructor for `insertCard
|
|
732
|
-
*
|
|
733
|
-
*
|
|
718
|
+
* constructor for `insertCard`, which also takes any `Card` object
|
|
719
|
+
* directly. Each `fields` entry becomes a card field in insertion order;
|
|
720
|
+
* `body` defaults to `""`.
|
|
734
721
|
*
|
|
735
|
-
*
|
|
736
|
-
*
|
|
737
|
-
* here.
|
|
738
|
-
*
|
|
739
|
-
* Checks only what a detached card can decide alone: field-name grammar
|
|
740
|
-
* and value depth. Kind validity is positional (`main` is right for the
|
|
741
|
-
* root, reserved for a composable card) so `insertCard` is its gate, and
|
|
722
|
+
* Checks only what a detached card can decide alone: field-name grammar and
|
|
723
|
+
* value depth. Kind validity is positional, so `insertCard` is its gate and
|
|
742
724
|
* any kind string is accepted here.
|
|
743
725
|
* @param {string} kind
|
|
744
726
|
* @param {Record<string, unknown>} [fields]
|
|
@@ -783,12 +765,11 @@ export class Document {
|
|
|
783
765
|
}
|
|
784
766
|
}
|
|
785
767
|
/**
|
|
786
|
-
*
|
|
787
|
-
*
|
|
788
|
-
* blank
|
|
789
|
-
*
|
|
790
|
-
*
|
|
791
|
-
* Throws on an invalid quill reference. Mirrors Python `Document(quill_ref)`.
|
|
768
|
+
* A blank document: a main card carrying only `$quill`, an empty body, and
|
|
769
|
+
* no composable cards. Absent fields resolve at render time (`default`, else
|
|
770
|
+
* the field's blank), so nothing the caller did not set reaches the output.
|
|
771
|
+
* For an example-filled starter use `Quill.seedDocument()`. Throws on an
|
|
772
|
+
* invalid quill reference.
|
|
792
773
|
* @param {string} quill_ref
|
|
793
774
|
*/
|
|
794
775
|
constructor(quill_ref) {
|
|
@@ -811,15 +792,11 @@ export class Document {
|
|
|
811
792
|
}
|
|
812
793
|
}
|
|
813
794
|
/**
|
|
814
|
-
* **Overwrite** the content value at `addr`:
|
|
815
|
-
*
|
|
816
|
-
*
|
|
817
|
-
*
|
|
818
|
-
*
|
|
819
|
-
* [`applyChange`](Document::apply_change) preserves. An absent `addr.field`
|
|
820
|
-
* targets the body, an absent `addr.card` the main card. Cold-importing
|
|
821
|
-
* markdown is spelled `overwrite(addr, importMarkdown(md))` at the call
|
|
822
|
-
* site, where the anchor loss is visible.
|
|
795
|
+
* **Overwrite** the content value at `addr` with exactly `rt`: value
|
|
796
|
+
* semantics, so the identity anchors of any previous value are gone. By
|
|
797
|
+
* anchor fate `overwrite` destroys, [`revise`](Document::revise) rebases,
|
|
798
|
+
* and [`applyChange`](Document::apply_change) preserves. An absent
|
|
799
|
+
* `addr.field` targets the body, an absent `addr.card` the main card.
|
|
823
800
|
*
|
|
824
801
|
* Throws on an out-of-range card, a malformed field name, or an `rt` that is
|
|
825
802
|
* not a canonical content object.
|
|
@@ -840,26 +817,19 @@ export class Document {
|
|
|
840
817
|
}
|
|
841
818
|
}
|
|
842
819
|
/**
|
|
843
|
-
* `addr`'s canonical `DocPath` string, the anchor `Diagnostic.path`
|
|
844
|
-
*
|
|
845
|
-
* `pathFor({card: 2})` `cards.<kind>[2].body`.
|
|
846
|
-
* `Addr` mints one without restating the kind lookup, the `Addr` defaults
|
|
847
|
-
* or the range guard.
|
|
820
|
+
* `addr`'s canonical `DocPath` string, the anchor `Diagnostic.path` carries:
|
|
821
|
+
* `pathFor()` is `main.body`, `pathFor("intro")` `main.intro`,
|
|
822
|
+
* `pathFor({card: 2})` `cards.<kind>[2].body`.
|
|
848
823
|
*
|
|
849
|
-
* The kind is the card's stored `$kind` verbatim,
|
|
850
|
-
*
|
|
851
|
-
*
|
|
852
|
-
*
|
|
853
|
-
* `validate` diagnostic path differ for the same card.
|
|
824
|
+
* The kind is the card's stored `$kind` verbatim, not `validate`'s
|
|
825
|
+
* declared-kind filter, since a `Document` holds a `$quill` reference and no
|
|
826
|
+
* schema. That is the one edge where this path and a `validate` diagnostic
|
|
827
|
+
* path differ for the same card.
|
|
854
828
|
*
|
|
855
|
-
* **Total on the index axis**, unlike the `Addr` reads
|
|
856
|
-
* `
|
|
857
|
-
*
|
|
858
|
-
*
|
|
859
|
-
* `cards[7].from`, which parses back and resolves to nothing rather than
|
|
860
|
-
* mis-targeting. So a per-keystroke call needs no `try`; a caller wanting
|
|
861
|
-
* a drop-it guard has [`cardCount`](Self::card_count). Only a malformed
|
|
862
|
-
* address throws.
|
|
829
|
+
* **Total on the index axis**, unlike the `Addr` reads, which throw there:
|
|
830
|
+
* an out-of-range `{card: 7, field: "from"}` renders `cards[7].from`, which
|
|
831
|
+
* parses back and resolves to nothing rather than mis-targeting. Only a
|
|
832
|
+
* malformed address throws.
|
|
863
833
|
* @param {Addr | string} addr
|
|
864
834
|
* @returns {string}
|
|
865
835
|
*/
|
|
@@ -907,11 +877,9 @@ export class Document {
|
|
|
907
877
|
}
|
|
908
878
|
}
|
|
909
879
|
/**
|
|
910
|
-
* The canonical `$quill` reference grammar as author-facing text
|
|
911
|
-
* the
|
|
912
|
-
* messages from this instead of re-stating the rule
|
|
913
|
-
* `hint` on `parse::invalid_quill_reference`. Cache it; the value never
|
|
914
|
-
* changes.
|
|
880
|
+
* The canonical `$quill` reference grammar as author-facing text: the same
|
|
881
|
+
* text the `parse::invalid_quill_reference` hint carries. Drive validation
|
|
882
|
+
* messages from this instead of re-stating the rule.
|
|
915
883
|
* @returns {string}
|
|
916
884
|
*/
|
|
917
885
|
static quillRefHint() {
|
|
@@ -950,10 +918,9 @@ export class Document {
|
|
|
950
918
|
}
|
|
951
919
|
}
|
|
952
920
|
/**
|
|
953
|
-
* Remove the `$ext` map on the card `addr` targets
|
|
954
|
-
* previous map or `undefined
|
|
955
|
-
*
|
|
956
|
-
* (absent = main). Throws on a present `field` or an out-of-range card.
|
|
921
|
+
* Remove the `$ext` map on the card `addr` targets entirely, returning the
|
|
922
|
+
* previous map or `undefined`. Discards every namespace at once; prefer
|
|
923
|
+
* `removeExtNamespace`. Throws on a present `field` or an out-of-range card.
|
|
957
924
|
* @param {CardAddr} [addr]
|
|
958
925
|
* @returns {Record<string, unknown> | undefined}
|
|
959
926
|
*/
|
|
@@ -1000,9 +967,8 @@ export class Document {
|
|
|
1000
967
|
}
|
|
1001
968
|
/**
|
|
1002
969
|
* Remove a field at `addr`, returning the removed value or `undefined`. A
|
|
1003
|
-
* bare string is `Addr` shorthand for `{ field }`.
|
|
1004
|
-
*
|
|
1005
|
-
* a malformed name.
|
|
970
|
+
* bare string is `Addr` shorthand for `{ field }`. A body address throws, as
|
|
971
|
+
* does an out-of-range card or a malformed name.
|
|
1006
972
|
* @param {Addr | string} addr
|
|
1007
973
|
* @returns {any}
|
|
1008
974
|
*/
|
|
@@ -1022,9 +988,8 @@ export class Document {
|
|
|
1022
988
|
}
|
|
1023
989
|
}
|
|
1024
990
|
/**
|
|
1025
|
-
* Remove `cardKind` from the main card's `$seed` map, returning its
|
|
1026
|
-
*
|
|
1027
|
-
* survive. `$seed` is main-only, so this takes no address.
|
|
991
|
+
* Remove `cardKind` from the main card's `$seed` map, returning its overlay
|
|
992
|
+
* or `undefined`; drops `$seed` entirely once empty. Sibling kinds survive.
|
|
1028
993
|
* @param {string} card_kind
|
|
1029
994
|
* @returns {any}
|
|
1030
995
|
*/
|
|
@@ -1046,12 +1011,12 @@ export class Document {
|
|
|
1046
1011
|
}
|
|
1047
1012
|
}
|
|
1048
1013
|
/**
|
|
1049
|
-
* **Revise** the richtext value at `addr` from a markdown string:
|
|
1050
|
-
*
|
|
1051
|
-
*
|
|
1052
|
-
*
|
|
1053
|
-
*
|
|
1054
|
-
* absent
|
|
1014
|
+
* **Revise** the richtext value at `addr` from a markdown string: the
|
|
1015
|
+
* default write path. Imports the markdown, diffs it against the current
|
|
1016
|
+
* value, rebases surviving identity anchors, and returns the text `Delta` an
|
|
1017
|
+
* editor bridge maps its own positions through (`mapPos`). An absent
|
|
1018
|
+
* `addr.field` targets the body, an absent `addr.card` the main card; an
|
|
1019
|
+
* absent field cold-imports from empty.
|
|
1055
1020
|
*
|
|
1056
1021
|
* Throws on an out-of-range card, a malformed field name, a present
|
|
1057
1022
|
* non-content field value, or an over-nested markdown input.
|
|
@@ -1077,11 +1042,9 @@ export class Document {
|
|
|
1077
1042
|
}
|
|
1078
1043
|
}
|
|
1079
1044
|
/**
|
|
1080
|
-
* The main card's `$seed` overlay object
|
|
1081
|
-
*
|
|
1082
|
-
* `
|
|
1083
|
-
* via [`main`](Self::main) to fish out one key, and it keeps `seedCard`
|
|
1084
|
-
* pure: the quill still never reads the document.
|
|
1045
|
+
* The main card's `$seed[kind]` overlay object, or `undefined`. Feeds
|
|
1046
|
+
* `quill.seedCard(kind, overlay)` without serializing the whole main card,
|
|
1047
|
+
* and keeps `seedCard` pure: the quill never reads the document.
|
|
1085
1048
|
* @param {string} kind
|
|
1086
1049
|
* @returns {Record<string, unknown> | undefined}
|
|
1087
1050
|
*/
|
|
@@ -1144,15 +1107,11 @@ export class Document {
|
|
|
1144
1107
|
}
|
|
1145
1108
|
}
|
|
1146
1109
|
/**
|
|
1147
|
-
* Read the storage version tag from a raw storage DTO string without a
|
|
1148
|
-
*
|
|
1149
|
-
*
|
|
1150
|
-
*
|
|
1151
|
-
*
|
|
1152
|
-
* The storage version, not a field schema ([`schema`](Quill::schema) is the
|
|
1153
|
-
* quill's field declarations). The JSON key is spelled `"schema"`: it is
|
|
1154
|
-
* the DTO's serde tag, and retagging it would break the version dispatch
|
|
1155
|
-
* it drives.
|
|
1110
|
+
* Read the storage version tag from a raw storage DTO string without a full
|
|
1111
|
+
* parse, or `undefined`. Unknown future versions come back as-is, which
|
|
1112
|
+
* distinguishes "build too old" from "payload corrupt" when `fromJson`
|
|
1113
|
+
* throws. This is the storage version, not a field schema, though the JSON
|
|
1114
|
+
* key is spelled `"schema"`: that is the DTO's serde tag.
|
|
1156
1115
|
* @param {string} json
|
|
1157
1116
|
* @returns {string | undefined}
|
|
1158
1117
|
*/
|
|
@@ -1175,11 +1134,10 @@ export class Document {
|
|
|
1175
1134
|
}
|
|
1176
1135
|
}
|
|
1177
1136
|
/**
|
|
1178
|
-
* Replace the opaque `$ext` map on the card `addr` targets (
|
|
1179
|
-
*
|
|
1180
|
-
*
|
|
1181
|
-
*
|
|
1182
|
-
* `store` verb. Throws on a present `field` or an out-of-range card.
|
|
1137
|
+
* Replace the opaque `$ext` map on the card `addr` targets (absent `card` =
|
|
1138
|
+
* main). `value` must be a plain object. `$ext` carries out-of-band consumer
|
|
1139
|
+
* state and never reaches the rendered output. Throws on a present `field`
|
|
1140
|
+
* or an out-of-range card.
|
|
1183
1141
|
* @param {CardAddr} addr
|
|
1184
1142
|
* @param {any} value
|
|
1185
1143
|
*/
|
|
@@ -1198,9 +1156,8 @@ export class Document {
|
|
|
1198
1156
|
}
|
|
1199
1157
|
/**
|
|
1200
1158
|
* Merge `value` into `$ext[ns]` on the card `addr` targets, preserving
|
|
1201
|
-
* sibling namespaces: the recommended `$ext` write.
|
|
1202
|
-
*
|
|
1203
|
-
* Throws on a present `field` or an out-of-range card.
|
|
1159
|
+
* sibling namespaces: the recommended `$ext` write. Throws on a present
|
|
1160
|
+
* `field` or an out-of-range card.
|
|
1204
1161
|
* @param {CardAddr} addr
|
|
1205
1162
|
* @param {string} ns
|
|
1206
1163
|
* @param {any} value
|
|
@@ -1221,14 +1178,12 @@ export class Document {
|
|
|
1221
1178
|
}
|
|
1222
1179
|
}
|
|
1223
1180
|
/**
|
|
1224
|
-
* Store a field verbatim at `addr
|
|
1225
|
-
*
|
|
1226
|
-
*
|
|
1227
|
-
*
|
|
1228
|
-
*
|
|
1229
|
-
*
|
|
1230
|
-
* opaque; write it with `revise` / `overwrite` / `writer.reviseBody`. Throws on
|
|
1231
|
-
* an out-of-range card or a malformed name.
|
|
1181
|
+
* Store a field verbatim at `addr`, deferring coercion to render; the typed
|
|
1182
|
+
* write is [`commitField`](Document::commit_field). A bare string is `Addr`
|
|
1183
|
+
* shorthand for `{ field }`; `{ card: 2, field: "qty" }` targets a
|
|
1184
|
+
* composable card. Clears any `!must_fill` marker. A body address throws:
|
|
1185
|
+
* write a body with `revise` / `overwrite`. Throws on an out-of-range card
|
|
1186
|
+
* or a malformed name.
|
|
1232
1187
|
* @param {Addr | string} addr
|
|
1233
1188
|
* @param {any} value
|
|
1234
1189
|
*/
|
|
@@ -1246,14 +1201,11 @@ export class Document {
|
|
|
1246
1201
|
}
|
|
1247
1202
|
}
|
|
1248
1203
|
/**
|
|
1249
|
-
* Store several fields verbatim and atomically on the card `addr` targets
|
|
1250
|
-
*
|
|
1251
|
-
*
|
|
1252
|
-
*
|
|
1253
|
-
*
|
|
1254
|
-
* fields)` a composable one, never ambiguous with "set field `card`".
|
|
1255
|
-
* Nothing is applied on error; the thrown error's `diagnostics` carry one
|
|
1256
|
-
* entry per offending field. Throws on an out-of-range card.
|
|
1204
|
+
* Store several fields verbatim and atomically on the card `addr` targets.
|
|
1205
|
+
* `addr` is a **card address** (`{ card }`, absent = main) and comes first
|
|
1206
|
+
* because `card` is itself a legal field name; a present `field` throws.
|
|
1207
|
+
* Nothing is applied on error, and the thrown error's `diagnostics` carry
|
|
1208
|
+
* one entry per offending field. Throws on an out-of-range card.
|
|
1257
1209
|
* @param {CardAddr} addr
|
|
1258
1210
|
* @param {Record<string, unknown>} fields
|
|
1259
1211
|
*/
|
|
@@ -1271,10 +1223,8 @@ export class Document {
|
|
|
1271
1223
|
}
|
|
1272
1224
|
}
|
|
1273
1225
|
/**
|
|
1274
|
-
* Store a field verbatim at `addr` and mark it `!must_fill
|
|
1275
|
-
*
|
|
1276
|
-
* `{ card, field }` for a composable card). A body address throws. Same
|
|
1277
|
-
* validation as [`storeField`](Document::store_field).
|
|
1226
|
+
* Store a field verbatim at `addr` and mark it `!must_fill`. A body address
|
|
1227
|
+
* throws; same validation as [`storeField`](Document::store_field).
|
|
1278
1228
|
* @param {Addr | string} addr
|
|
1279
1229
|
* @param {any} value
|
|
1280
1230
|
*/
|
|
@@ -1293,10 +1243,9 @@ export class Document {
|
|
|
1293
1243
|
}
|
|
1294
1244
|
/**
|
|
1295
1245
|
* Merge a card-kind's seed `overlay` into the **main** card's `$seed` map
|
|
1296
|
-
* under `cardKind`, preserving sibling kinds
|
|
1297
|
-
*
|
|
1298
|
-
*
|
|
1299
|
-
* verb. Throws if `overlay` cannot be serialized or nests too deep.
|
|
1246
|
+
* under `cardKind`, preserving sibling kinds; `$seed` is main-only, so this
|
|
1247
|
+
* takes no address. Sets the starting values new cards of that kind spawn
|
|
1248
|
+
* with. Throws if `overlay` cannot be serialized or nests too deep.
|
|
1300
1249
|
* @param {string} card_kind
|
|
1301
1250
|
* @param {any} overlay
|
|
1302
1251
|
*/
|
|
@@ -1316,14 +1265,10 @@ export class Document {
|
|
|
1316
1265
|
}
|
|
1317
1266
|
}
|
|
1318
1267
|
/**
|
|
1319
|
-
* Serialize this document to a versioned storage DTO string.
|
|
1320
|
-
*
|
|
1321
|
-
*
|
|
1322
|
-
*
|
|
1323
|
-
* `warnings` are excluded from the DTO.
|
|
1324
|
-
*
|
|
1325
|
-
* Output is **byte-deterministic** within a `schema` version: equal
|
|
1326
|
-
* documents produce byte-equal output, safe for content-hash use cases.
|
|
1268
|
+
* Serialize this document to a versioned storage DTO string. Prefer it over
|
|
1269
|
+
* `toMarkdown` for persistence: the wire format is frozen per `schema`
|
|
1270
|
+
* version and the output is byte-deterministic within one, so equal
|
|
1271
|
+
* documents hash equal. Parse-time `warnings` are excluded.
|
|
1327
1272
|
* @returns {string}
|
|
1328
1273
|
*/
|
|
1329
1274
|
toJson() {
|
|
@@ -1364,11 +1309,9 @@ export class Document {
|
|
|
1364
1309
|
}
|
|
1365
1310
|
}
|
|
1366
1311
|
/**
|
|
1367
|
-
* Like [`fromJson`](Document::from_json) but returns `undefined` instead
|
|
1368
|
-
*
|
|
1369
|
-
*
|
|
1370
|
-
* `undefined` means "not a storage DTO"; `fromMarkdown` still throws on
|
|
1371
|
-
* genuinely malformed markdown.
|
|
1312
|
+
* Like [`fromJson`](Document::from_json) but returns `undefined` instead of
|
|
1313
|
+
* throwing when `json` is not a valid storage DTO, to discriminate format
|
|
1314
|
+
* without exceptions as control flow.
|
|
1372
1315
|
* @param {string} json
|
|
1373
1316
|
* @returns {Document | undefined}
|
|
1374
1317
|
*/
|
|
@@ -1380,9 +1323,9 @@ export class Document {
|
|
|
1380
1323
|
}
|
|
1381
1324
|
/**
|
|
1382
1325
|
* The non-fatal diagnostics of the load that produced this document: parse
|
|
1383
|
-
* warnings, plus
|
|
1384
|
-
*
|
|
1385
|
-
*
|
|
1326
|
+
* warnings, plus `conform::*` warnings when it came through `quill.parse`.
|
|
1327
|
+
* Session state, not document value: `equals` and the storage DTO exclude
|
|
1328
|
+
* it, and `fromJson` / `loadJson` clear it.
|
|
1386
1329
|
* @returns {Diagnostic[]}
|
|
1387
1330
|
*/
|
|
1388
1331
|
get warnings() {
|
|
@@ -1404,17 +1347,14 @@ export class Document {
|
|
|
1404
1347
|
if (Symbol.dispose) Document.prototype[Symbol.dispose] = Document.prototype.free;
|
|
1405
1348
|
|
|
1406
1349
|
/**
|
|
1407
|
-
* Live render session:
|
|
1408
|
-
*
|
|
1409
|
-
*
|
|
1410
|
-
*
|
|
1411
|
-
* compile; anchoring a caret across edits is the editor's job: re-read
|
|
1412
|
-
* geometry after each committed `apply`.
|
|
1350
|
+
* Live render session: every read serves the current compile. `apply(doc)`
|
|
1351
|
+
* recompiles a whole document in place, transactionally — on throw the reads
|
|
1352
|
+
* keep serving the last-good compile. Geometry is per-compile, so re-read it
|
|
1353
|
+
* after each committed `apply`.
|
|
1413
1354
|
*
|
|
1414
|
-
*
|
|
1415
|
-
*
|
|
1416
|
-
*
|
|
1417
|
-
* rather than catching the error.
|
|
1355
|
+
* A zero-page document yields a valid session (`pageCount === 0`) whose
|
|
1356
|
+
* `paint(ctx, 0)` and `pageSize(0)` throw; branch on `pageCount === 0` rather
|
|
1357
|
+
* than catching.
|
|
1418
1358
|
*/
|
|
1419
1359
|
export class LiveSession {
|
|
1420
1360
|
static __wrap(ptr) {
|
|
@@ -1455,15 +1395,12 @@ export class LiveSession {
|
|
|
1455
1395
|
}
|
|
1456
1396
|
}
|
|
1457
1397
|
/**
|
|
1458
|
-
* The schema field whose content is under a point on `page
|
|
1459
|
-
*
|
|
1460
|
-
*
|
|
1461
|
-
*
|
|
1462
|
-
*
|
|
1463
|
-
*
|
|
1464
|
-
* `FieldRegion`: `x = clickPx.x / renderScale`,
|
|
1465
|
-
* `y = pageHeightPt - clickPx.y / renderScale`. Unlike `regions()`,
|
|
1466
|
-
* *every* placement answers, not just the first.
|
|
1398
|
+
* The schema field whose content is under a point on `page`: the `DocPath`
|
|
1399
|
+
* address to focus in the editor, or `undefined` off any field's ink.
|
|
1400
|
+
* `x`/`y` are PDF points with a **bottom-left** origin, the same space as
|
|
1401
|
+
* `FieldRegion.rect`, so from a canvas click use
|
|
1402
|
+
* `x = clickPx.x / renderScale`, `y = pageHeightPt - clickPx.y / renderScale`.
|
|
1403
|
+
* Unlike `regions()`, *every* placement answers, not just the first.
|
|
1467
1404
|
* @param {number} page
|
|
1468
1405
|
* @param {number} x
|
|
1469
1406
|
* @param {number} y
|
|
@@ -1486,15 +1423,11 @@ export class LiveSession {
|
|
|
1486
1423
|
}
|
|
1487
1424
|
}
|
|
1488
1425
|
/**
|
|
1489
|
-
* The whole-field highlight boxes for `field`: one union rect per page
|
|
1490
|
-
*
|
|
1491
|
-
*
|
|
1492
|
-
*
|
|
1493
|
-
*
|
|
1494
|
-
* reimplementing it. **Content only**: a field placed solely as a scalar
|
|
1495
|
-
* reference or a bound widget carries no `span` and returns `[]`; its box
|
|
1496
|
-
* is a single `regions()` rect. Reflects the current compile, like
|
|
1497
|
-
* `regions()`.
|
|
1426
|
+
* The whole-field highlight boxes for `field`: one union rect per page over
|
|
1427
|
+
* the field's `span`-bearing content segments, the union `regions()` leaves
|
|
1428
|
+
* derived. **Content only**: a field placed solely as a scalar reference or
|
|
1429
|
+
* a bound widget carries no `span` and returns `[]`, its box being a single
|
|
1430
|
+
* `regions()` rect. Reflects the current compile.
|
|
1498
1431
|
* @param {string} field
|
|
1499
1432
|
* @returns {FieldRegion[]}
|
|
1500
1433
|
*/
|
|
@@ -1516,11 +1449,10 @@ export class LiveSession {
|
|
|
1516
1449
|
}
|
|
1517
1450
|
}
|
|
1518
1451
|
/**
|
|
1519
|
-
* A content position → **caret rect**, the reverse of `positionAt`:
|
|
1520
|
-
*
|
|
1521
|
-
*
|
|
1522
|
-
*
|
|
1523
|
-
* places no tracked content or the offset maps to no drawn glyph.
|
|
1452
|
+
* A content position → **caret rect**, the reverse of `positionAt`: the box
|
|
1453
|
+
* to draw a caret at, in the same bottom-left PDF-point space as
|
|
1454
|
+
* `FieldRegion.rect`, its `span` collapsed to `[pos, pos]`. `undefined` when
|
|
1455
|
+
* the field places no tracked content or the offset maps to no drawn glyph.
|
|
1524
1456
|
* @param {string} field
|
|
1525
1457
|
* @param {number} pos
|
|
1526
1458
|
* @returns {FieldRegion | undefined}
|
|
@@ -1563,17 +1495,16 @@ export class LiveSession {
|
|
|
1563
1495
|
* Paint `page` into a `CanvasRenderingContext2D` or
|
|
1564
1496
|
* `OffscreenCanvasRenderingContext2D`. The painter owns
|
|
1565
1497
|
* `canvas.width`/`height` (no `clearRect` needed); consumers own
|
|
1566
|
-
* `canvas.style.*`. If `layoutScale * densityScale` exceeds 16384 px
|
|
1567
|
-
*
|
|
1568
|
-
* `PaintResult.effectiveDensityScale` carries the density actually applied.
|
|
1498
|
+
* `canvas.style.*`. If `layoutScale * densityScale` exceeds 16384 px per
|
|
1499
|
+
* side, `densityScale` is clamped and `PaintResult` reports it.
|
|
1569
1500
|
*
|
|
1570
1501
|
* `put_image_data` writes the whole backing store, bypassing the 2D
|
|
1571
|
-
* context's transform, `globalAlpha`, and clip
|
|
1572
|
-
*
|
|
1573
|
-
*
|
|
1502
|
+
* context's transform, `globalAlpha`, and clip, so each visible page needs
|
|
1503
|
+
* its own `<canvas>`: no compositing, sub-rect, or transform reaches through
|
|
1504
|
+
* this call.
|
|
1574
1505
|
*
|
|
1575
|
-
* Throws if the backend has no canvas painter, `page` is out of range,
|
|
1576
|
-
*
|
|
1506
|
+
* Throws if the backend has no canvas painter, `page` is out of range, `ctx`
|
|
1507
|
+
* is the wrong type, or either scale is non-finite or `<= 0`.
|
|
1577
1508
|
* @param {CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D} ctx
|
|
1578
1509
|
* @param {number} page
|
|
1579
1510
|
* @param {PaintOptions | undefined} opts
|
|
@@ -1595,14 +1526,11 @@ export class LiveSession {
|
|
|
1595
1526
|
}
|
|
1596
1527
|
}
|
|
1597
1528
|
/**
|
|
1598
|
-
* A point → **content position
|
|
1599
|
-
*
|
|
1600
|
-
* `
|
|
1601
|
-
*
|
|
1602
|
-
*
|
|
1603
|
-
* cluster-exact and degrades to the containing segment's start on
|
|
1604
|
-
* origin-less ink (list markers, a code fence's interior). See
|
|
1605
|
-
* `ContentHit`.
|
|
1529
|
+
* A point → **content position**: the field *and* a USV offset into its
|
|
1530
|
+
* `Content`, for placing a caret or mapping a selection into the content
|
|
1531
|
+
* model, or `undefined` off all content ink. `x`/`y` are PDF points,
|
|
1532
|
+
* bottom-left origin, as in `fieldAt`. The offset is cluster-exact and
|
|
1533
|
+
* degrades to the containing segment's start on origin-less ink.
|
|
1606
1534
|
* @param {number} page
|
|
1607
1535
|
* @param {number} x
|
|
1608
1536
|
* @param {number} y
|
|
@@ -1615,13 +1543,10 @@ export class LiveSession {
|
|
|
1615
1543
|
/**
|
|
1616
1544
|
* Schema-field geometry for this compiled session: each content field's
|
|
1617
1545
|
* **first placement** (one region per page it touches) plus widget and
|
|
1618
|
-
* scalar-reference-site regions, keyed on the canonical `DocPath` address
|
|
1619
|
-
*
|
|
1620
|
-
*
|
|
1621
|
-
*
|
|
1622
|
-
* artifact. An interactive preview reads it to scroll to / highlight the
|
|
1623
|
-
* focused field over a `paint`-ed canvas; the click direction is `fieldAt`.
|
|
1624
|
-
* Empty for backends that place no schema fields.
|
|
1546
|
+
* scalar-reference-site regions, keyed on the canonical `DocPath` address. A
|
|
1547
|
+
* field may appear more than once, so group by `field` (see `FieldRegion`).
|
|
1548
|
+
* A session-level query: no render, no byte artifact. The click direction is
|
|
1549
|
+
* `fieldAt`. Empty for backends that place no schema fields.
|
|
1625
1550
|
* @returns {FieldRegion[]}
|
|
1626
1551
|
*/
|
|
1627
1552
|
regions() {
|
|
@@ -1659,9 +1584,7 @@ export class LiveSession {
|
|
|
1659
1584
|
}
|
|
1660
1585
|
}
|
|
1661
1586
|
/**
|
|
1662
|
-
* `true` iff `paint` and `pageSize` will succeed for this session.
|
|
1663
|
-
* from the session's canvas seam, so it reflects exactly what `paint` will
|
|
1664
|
-
* do: no separately captured flag.
|
|
1587
|
+
* `true` iff `paint` and `pageSize` will succeed for this session.
|
|
1665
1588
|
* @returns {boolean}
|
|
1666
1589
|
*/
|
|
1667
1590
|
get supportsCanvas() {
|
|
@@ -1669,16 +1592,14 @@ export class LiveSession {
|
|
|
1669
1592
|
return ret !== 0;
|
|
1670
1593
|
}
|
|
1671
1594
|
/**
|
|
1672
|
-
* Recompile the session against `doc`: the edit verb of a live preview.
|
|
1673
|
-
*
|
|
1674
|
-
*
|
|
1675
|
-
*
|
|
1676
|
-
*
|
|
1677
|
-
* success reads serve the new compile; repaint `dirtyPages ∩ visible`.
|
|
1595
|
+
* Recompile the session against `doc`: the edit verb of a live preview. The
|
|
1596
|
+
* document compiles through the same pipeline as `open`, then swaps in
|
|
1597
|
+
* transactionally — on throw every read keeps serving the last-good compile
|
|
1598
|
+
* and the session recovers on the next successful `update`. On success,
|
|
1599
|
+
* repaint `dirtyPages ∩ visible`.
|
|
1678
1600
|
*
|
|
1679
|
-
* Distinct from
|
|
1680
|
-
*
|
|
1681
|
-
* the caller already mutated.
|
|
1601
|
+
* Distinct from [`applyChange`](Document::apply_change), which splices ops
|
|
1602
|
+
* into a document; this recompiles a document the caller already mutated.
|
|
1682
1603
|
* @param {Document} doc
|
|
1683
1604
|
* @returns {ChangeSet}
|
|
1684
1605
|
*/
|
|
@@ -1699,10 +1620,9 @@ export class LiveSession {
|
|
|
1699
1620
|
}
|
|
1700
1621
|
}
|
|
1701
1622
|
/**
|
|
1702
|
-
* Non-fatal diagnostics of the session's **current compile
|
|
1703
|
-
*
|
|
1704
|
-
*
|
|
1705
|
-
* to `RenderResult.warnings` on each `render()` call.
|
|
1623
|
+
* Non-fatal diagnostics of the session's **current compile**, refreshed by
|
|
1624
|
+
* each committed `apply`; a failed apply keeps the last-good compile's.
|
|
1625
|
+
* Also appended to `RenderResult.warnings` on each `render()`.
|
|
1706
1626
|
* @returns {Diagnostic[]}
|
|
1707
1627
|
*/
|
|
1708
1628
|
get warnings() {
|
|
@@ -1742,9 +1662,8 @@ export class Quill {
|
|
|
1742
1662
|
wasm.__wbg_quill_free(ptr, 0);
|
|
1743
1663
|
}
|
|
1744
1664
|
/**
|
|
1745
|
-
* The *declared* backend identifier (
|
|
1746
|
-
*
|
|
1747
|
-
* `supportsCanvas`) is read from the engine.
|
|
1665
|
+
* The *declared* backend identifier (e.g. `"typst"`): intent, not a
|
|
1666
|
+
* resolved capability. Capability is read from the engine.
|
|
1748
1667
|
* @returns {string}
|
|
1749
1668
|
*/
|
|
1750
1669
|
get backendId() {
|
|
@@ -1784,19 +1703,15 @@ export class Quill {
|
|
|
1784
1703
|
}
|
|
1785
1704
|
/**
|
|
1786
1705
|
* Land `doc`'s declared content fields at their canonical rest **in
|
|
1787
|
-
* place**, returning the `conform::*` diagnostics for
|
|
1788
|
-
*
|
|
1706
|
+
* place**, returning the `conform::*` diagnostics for values that would not
|
|
1707
|
+
* commit. The read-repair verb for a document that arrived through the
|
|
1708
|
+
* transport door (`fromMarkdown`, `fromJson`, a stored row).
|
|
1789
1709
|
*
|
|
1790
|
-
*
|
|
1791
|
-
*
|
|
1792
|
-
*
|
|
1793
|
-
*
|
|
1794
|
-
*
|
|
1795
|
-
*
|
|
1796
|
-
* A `!must_fill` marker anywhere in a field's value skips that field (the
|
|
1797
|
-
* marker is the state), and a value the strict write refuses stays as
|
|
1798
|
-
* authored with a diagnostic. Throws when `doc` declares a different
|
|
1799
|
-
* `$quill`, before any mutation.
|
|
1710
|
+
* Idempotent: an equal value is not rewritten, so YAML comments and stored
|
|
1711
|
+
* bytes survive. A `!must_fill` marker anywhere in a field's value skips
|
|
1712
|
+
* that field, and a value the strict write refuses stays as authored with a
|
|
1713
|
+
* diagnostic. Throws when `doc` declares a different `$quill`, before any
|
|
1714
|
+
* mutation.
|
|
1800
1715
|
* @param {Document} doc
|
|
1801
1716
|
* @returns {Diagnostic[]}
|
|
1802
1717
|
*/
|
|
@@ -1817,13 +1732,9 @@ export class Quill {
|
|
|
1817
1732
|
}
|
|
1818
1733
|
}
|
|
1819
1734
|
/**
|
|
1820
|
-
* Build a quill from a file tree. Pure:
|
|
1821
|
-
*
|
|
1822
|
-
*
|
|
1823
|
-
* Accepts either a `Map<string, Uint8Array>` or a plain object
|
|
1824
|
-
* (`Record<string, Uint8Array>`). Plain objects are walked via
|
|
1825
|
-
* `Object.entries` at the boundary; the Rust side sees a single
|
|
1826
|
-
* canonical shape.
|
|
1735
|
+
* Build a quill from a file tree. Pure: the declared backend is resolved
|
|
1736
|
+
* later, at render time. Accepts a `Map<string, Uint8Array>` or a plain
|
|
1737
|
+
* object.
|
|
1827
1738
|
* @param {Map<string, Uint8Array>} tree
|
|
1828
1739
|
* @returns {Quill}
|
|
1829
1740
|
*/
|
|
@@ -1844,9 +1755,8 @@ export class Quill {
|
|
|
1844
1755
|
}
|
|
1845
1756
|
/**
|
|
1846
1757
|
* Identity snapshot of the `quill:` section of `Quill.yaml` plus any extra
|
|
1847
|
-
* `quill:` keys. Pure config:
|
|
1848
|
-
*
|
|
1849
|
-
* (`Quillmark.supportedFormats`), not part of this snapshot.
|
|
1758
|
+
* `quill:` keys. Pure config: output formats are a resolved-backend
|
|
1759
|
+
* capability read from `Quillmark.supportedFormats`, not part of this.
|
|
1850
1760
|
* @returns {QuillMetadata}
|
|
1851
1761
|
*/
|
|
1852
1762
|
get metadata() {
|
|
@@ -1865,18 +1775,16 @@ export class Quill {
|
|
|
1865
1775
|
}
|
|
1866
1776
|
}
|
|
1867
1777
|
/**
|
|
1868
|
-
* Parse `markdown` and conform it against this quill: the
|
|
1869
|
-
*
|
|
1870
|
-
*
|
|
1871
|
-
*
|
|
1872
|
-
*
|
|
1873
|
-
* field's declared codec rather than by how the document was built.
|
|
1778
|
+
* Parse `markdown` and conform it against this quill: the primary ingestion
|
|
1779
|
+
* path, and the bound twin of the schema-free `Document.fromMarkdown`. The
|
|
1780
|
+
* returned document rests at its canonical form (a `richtext` field as a
|
|
1781
|
+
* content object, a `plaintext` field as its literal string), so `getStored`
|
|
1782
|
+
* answers by the field's declared codec, not by how the document was built.
|
|
1874
1783
|
*
|
|
1875
1784
|
* Parse warnings and the `conform::*` diagnostics both land on
|
|
1876
1785
|
* `doc.warnings`. Throws on a parse failure, or when `markdown` declares a
|
|
1877
|
-
* `$quill` this quill does not answer to
|
|
1878
|
-
*
|
|
1879
|
-
* door (`Document.fromMarkdown`, `setQuillRef`, then `quill.conform`).
|
|
1786
|
+
* `$quill` this quill does not answer to. To open a document whose `$quill`
|
|
1787
|
+
* is stale, use `Document.fromMarkdown`, `setQuillRef`, then `quill.conform`.
|
|
1880
1788
|
* @param {string} markdown
|
|
1881
1789
|
* @returns {Document}
|
|
1882
1790
|
*/
|
|
@@ -1898,15 +1806,11 @@ export class Quill {
|
|
|
1898
1806
|
}
|
|
1899
1807
|
}
|
|
1900
1808
|
/**
|
|
1901
|
-
* The resolved-value view of `doc
|
|
1902
|
-
*
|
|
1903
|
-
*
|
|
1904
|
-
*
|
|
1905
|
-
*
|
|
1906
|
-
*
|
|
1907
|
-
* Value and provenance only: completeness and errors stay `validate`'s
|
|
1908
|
-
* (a consumer merges it with its own diagnostic producers regardless), and
|
|
1909
|
-
* schema guidance reads from `Quill.schema`.
|
|
1809
|
+
* The resolved-value view of `doc`: for every declared field, the value the
|
|
1810
|
+
* render projection would use and the `FieldSource` rung it came from
|
|
1811
|
+
* (`"authored" | "default" | "blank"`). The card body is a `body` sibling on
|
|
1812
|
+
* its card, never a row in `fields`, and `null` when the kind enables no
|
|
1813
|
+
* body. Value and provenance only; completeness stays `validate`'s.
|
|
1910
1814
|
* @param {Document} doc
|
|
1911
1815
|
* @returns {Resolved}
|
|
1912
1816
|
*/
|
|
@@ -1927,11 +1831,9 @@ export class Quill {
|
|
|
1927
1831
|
}
|
|
1928
1832
|
}
|
|
1929
1833
|
/**
|
|
1930
|
-
* Document schema for the quill: the user-fillable fields plus their
|
|
1931
|
-
*
|
|
1932
|
-
*
|
|
1933
|
-
* alike. Key order in `fields`/`properties` is declaration order: the
|
|
1934
|
-
* ordering contract. Returns the `QuillSchema` shape.
|
|
1834
|
+
* Document schema for the quill: the user-fillable fields plus their `ui`
|
|
1835
|
+
* hints. Key order in `fields`/`properties` is declaration order, the
|
|
1836
|
+
* ordering contract.
|
|
1935
1837
|
* @returns {QuillSchema}
|
|
1936
1838
|
*/
|
|
1937
1839
|
get schema() {
|
|
@@ -1951,15 +1853,13 @@ export class Quill {
|
|
|
1951
1853
|
}
|
|
1952
1854
|
/**
|
|
1953
1855
|
* Seed a starter composable `Card` of the given kind (carries `$kind`),
|
|
1954
|
-
* layering an optional per-kind seed `overlay` over the schema-example
|
|
1955
|
-
*
|
|
1956
|
-
*
|
|
1957
|
-
* straight into `Document.insertCard`.
|
|
1856
|
+
* layering an optional per-kind seed `overlay` over the schema-example base
|
|
1857
|
+
* (`overlay › example › absent`). `undefined` when `cardKind` is not
|
|
1858
|
+
* declared in this quill's schema.
|
|
1958
1859
|
*
|
|
1959
1860
|
* Pass `document.seedOverlay(cardKind)` as `overlay` so a card added to a
|
|
1960
1861
|
* template-derived document inherits its curated starting values; omit it
|
|
1961
|
-
*
|
|
1962
|
-
* plain object: this reads the document, it does not mutate it.
|
|
1862
|
+
* for the bare schema seed.
|
|
1963
1863
|
* @param {string} card_kind
|
|
1964
1864
|
* @param {Record<string, unknown> | undefined} overlay
|
|
1965
1865
|
* @returns {Card | undefined}
|
|
@@ -1982,12 +1882,10 @@ export class Quill {
|
|
|
1982
1882
|
}
|
|
1983
1883
|
}
|
|
1984
1884
|
/**
|
|
1985
|
-
* Seed a starter `Document` from the schema
|
|
1986
|
-
*
|
|
1987
|
-
*
|
|
1988
|
-
*
|
|
1989
|
-
* with both an `example` and a `default` renders its example. See
|
|
1990
|
-
* `prose/canon/SCHEMAS.md` § "Document seeding".
|
|
1885
|
+
* Seed a starter `Document` from the schema: the main card plus one instance
|
|
1886
|
+
* of each composable card kind, each committing its fields' `example:`
|
|
1887
|
+
* values and leaving every other field absent (interpolated at render as
|
|
1888
|
+
* `default:`, else the field's blank). A field with both renders its example.
|
|
1991
1889
|
* @returns {Document}
|
|
1992
1890
|
*/
|
|
1993
1891
|
seedDocument() {
|
|
@@ -1996,9 +1894,7 @@ export class Quill {
|
|
|
1996
1894
|
}
|
|
1997
1895
|
/**
|
|
1998
1896
|
* Seed a starter main `Card` (carries `$quill`) from the schema: the
|
|
1999
|
-
* `$kind: main` card of [`seedDocument`](Self::seed_document)
|
|
2000
|
-
* isolation, committing each field's `example:` value. Returns the same
|
|
2001
|
-
* `Card` shape as the `Document.main` getter.
|
|
1897
|
+
* `$kind: main` card of [`seedDocument`](Self::seed_document) alone.
|
|
2002
1898
|
* @returns {Card}
|
|
2003
1899
|
*/
|
|
2004
1900
|
seedMain() {
|
|
@@ -2017,16 +1913,13 @@ export class Quill {
|
|
|
2017
1913
|
}
|
|
2018
1914
|
}
|
|
2019
1915
|
/**
|
|
2020
|
-
* Flatten this quill back into its canonical file tree
|
|
2021
|
-
* [`fromTree`](Self::from_tree).
|
|
2022
|
-
* reproduces an equivalent quill.
|
|
1916
|
+
* Flatten this quill back into its canonical file tree, the inverse of
|
|
1917
|
+
* [`fromTree`](Self::from_tree). Keys are `"/"`-joined relative paths.
|
|
2023
1918
|
*
|
|
2024
1919
|
* This is how a quill crosses a WASM linear-memory boundary as data: a
|
|
2025
|
-
* `Quill` built in one build
|
|
2026
|
-
* cannot be passed to an engine in another (separate linear memories), so
|
|
1920
|
+
* `Quill` built in one build cannot be passed to an engine in another, so
|
|
2027
1921
|
* `@quillmark/wasm/runtime` re-feeds this tree to the backend build's
|
|
2028
|
-
* `Quill.fromTree` on demand.
|
|
2029
|
-
* matching what `fromTree` accepts.
|
|
1922
|
+
* `Quill.fromTree` on demand.
|
|
2030
1923
|
* @returns {Map<string, Uint8Array>}
|
|
2031
1924
|
*/
|
|
2032
1925
|
toTree() {
|
|
@@ -2035,14 +1928,9 @@ export class Quill {
|
|
|
2035
1928
|
}
|
|
2036
1929
|
/**
|
|
2037
1930
|
* Validate `doc` against this quill's schema, returning every diagnostic
|
|
2038
|
-
* (
|
|
2039
|
-
*
|
|
2040
|
-
*
|
|
2041
|
-
* `path`, and `hint` the engine emits) including the non-fatal
|
|
2042
|
-
* `validation::must_fill` warning for each `!must_fill` marker left in
|
|
2043
|
-
* the document. Field values, defaults, and order are not part of this
|
|
2044
|
-
* surface: read them from the `Document` payload and `Quill.schema`
|
|
2045
|
-
* (schema key order is display order).
|
|
1931
|
+
* (empty when the document is valid). Forwards the canonical
|
|
1932
|
+
* `validation::*` diagnostics the engine emits, including the non-fatal
|
|
1933
|
+
* `validation::must_fill` warning per `!must_fill` marker left behind.
|
|
2046
1934
|
* @param {Document} doc
|
|
2047
1935
|
* @returns {Diagnostic[]}
|
|
2048
1936
|
*/
|
|
@@ -2136,9 +2024,9 @@ export class Quillmark {
|
|
|
2136
2024
|
}
|
|
2137
2025
|
}
|
|
2138
2026
|
/**
|
|
2139
|
-
* The output formats `quill`'s backend can emit
|
|
2140
|
-
*
|
|
2141
|
-
*
|
|
2027
|
+
* The output formats `quill`'s backend can emit; resolves the backend but
|
|
2028
|
+
* compiles nothing. Throws `engine::backend_not_found` when no registered
|
|
2029
|
+
* backend matches the quill's declared one.
|
|
2142
2030
|
* @param {Quill} quill
|
|
2143
2031
|
* @returns {OutputFormat[]}
|
|
2144
2032
|
*/
|
|
@@ -2159,11 +2047,9 @@ export class Quillmark {
|
|
|
2159
2047
|
}
|
|
2160
2048
|
}
|
|
2161
2049
|
/**
|
|
2162
|
-
*
|
|
2163
|
-
*
|
|
2164
|
-
*
|
|
2165
|
-
* a canvas-based preview UI; the authoritative answer is the session's
|
|
2166
|
-
* `supportsCanvas` getter once `open()` has been called.
|
|
2050
|
+
* Whether `quill`'s backend can paint sessions to a canvas; `false` when the
|
|
2051
|
+
* backend is unsupported. A cheap probe before mounting a preview UI. The
|
|
2052
|
+
* authoritative answer is the session's `supportsCanvas` getter.
|
|
2167
2053
|
* @param {Quill} quill
|
|
2168
2054
|
* @returns {boolean}
|
|
2169
2055
|
*/
|
|
@@ -2176,8 +2062,7 @@ export class Quillmark {
|
|
|
2176
2062
|
if (Symbol.dispose) Quillmark.prototype[Symbol.dispose] = Quillmark.prototype.free;
|
|
2177
2063
|
|
|
2178
2064
|
/**
|
|
2179
|
-
* Export
|
|
2180
|
-
* on-demand codec behind `exportMarkdown(card.body)`. Throws if `rt` is not a
|
|
2065
|
+
* Export canonical `Content` to its markdown projection. Throws if `rt` is not
|
|
2181
2066
|
* canonical content.
|
|
2182
2067
|
* @param {Content} rt
|
|
2183
2068
|
* @returns {string}
|
|
@@ -2209,10 +2094,8 @@ export function exportMarkdown(rt) {
|
|
|
2209
2094
|
|
|
2210
2095
|
/**
|
|
2211
2096
|
* Serialize structured [`DocPathSeg`] segments back to the canonical path
|
|
2212
|
-
* string: the inverse of `parseDocPath
|
|
2213
|
-
*
|
|
2214
|
-
* and on an empty segment array (symmetric with `parseDocPath("")`, which
|
|
2215
|
-
* throws "empty path").
|
|
2097
|
+
* string: the inverse of `parseDocPath`. Throws on a segment array the
|
|
2098
|
+
* deserializer rejects, and on an empty one.
|
|
2216
2099
|
* @param {DocPathSeg[]} segs
|
|
2217
2100
|
* @returns {string}
|
|
2218
2101
|
*/
|
|
@@ -2242,10 +2125,9 @@ export function formatDocPath(segs) {
|
|
|
2242
2125
|
}
|
|
2243
2126
|
|
|
2244
2127
|
/**
|
|
2245
|
-
* Import a markdown string to
|
|
2246
|
-
*
|
|
2247
|
-
*
|
|
2248
|
-
* semantics. Throws on an over-nested input.
|
|
2128
|
+
* Import a markdown string to canonical `Content`: the pure, document-free
|
|
2129
|
+
* codec. `overwrite(addr, importMarkdown(md))` spells the cold, anchor-losing
|
|
2130
|
+
* write; prefer `revise` for edit semantics. Throws on an over-nested input.
|
|
2249
2131
|
* @param {string} markdown
|
|
2250
2132
|
* @returns {Content}
|
|
2251
2133
|
*/
|
|
@@ -2269,10 +2151,9 @@ export function importMarkdown(markdown) {
|
|
|
2269
2151
|
|
|
2270
2152
|
/**
|
|
2271
2153
|
* Map a base content position (a USV index into `Content.text`, not a UTF-16
|
|
2272
|
-
* offset) through a `delta` to its new
|
|
2273
|
-
*
|
|
2274
|
-
*
|
|
2275
|
-
* it). Throws on a malformed `delta`.
|
|
2154
|
+
* offset) through a `delta` to its new position, holding a caret stable across
|
|
2155
|
+
* a `revise`. `assoc` decides the side of a same-position insertion (`"after"`
|
|
2156
|
+
* moves past it). Throws on a malformed `delta`.
|
|
2276
2157
|
* @param {Delta} delta
|
|
2277
2158
|
* @param {number} pos
|
|
2278
2159
|
* @param {Assoc} assoc
|
|
@@ -2295,11 +2176,10 @@ export function mapPos(delta, pos, assoc) {
|
|
|
2295
2176
|
}
|
|
2296
2177
|
|
|
2297
2178
|
/**
|
|
2298
|
-
* Parse a canonical document-model `Diagnostic.path`
|
|
2299
|
-
*
|
|
2300
|
-
*
|
|
2301
|
-
*
|
|
2302
|
-
* the string. Throws on a malformed path.
|
|
2179
|
+
* Parse a canonical document-model `Diagnostic.path` (`cards.<kind>[<i>].<field>`,
|
|
2180
|
+
* `main.body`, `recipients[0].name`) into structured [`DocPathSeg`] segments, so
|
|
2181
|
+
* a consumer routes on segments instead of regexing the string. Throws on a
|
|
2182
|
+
* malformed path.
|
|
2303
2183
|
* @param {string} path
|
|
2304
2184
|
* @returns {DocPathSeg[]}
|
|
2305
2185
|
*/
|
|
@@ -2322,12 +2202,10 @@ export function parseDocPath(path) {
|
|
|
2322
2202
|
}
|
|
2323
2203
|
|
|
2324
2204
|
/**
|
|
2325
|
-
* Rebase `markdown` onto a `base` content
|
|
2326
|
-
*
|
|
2327
|
-
* text
|
|
2328
|
-
*
|
|
2329
|
-
* md)` fuses this with the store for atomicity. Throws on an over-nested
|
|
2330
|
-
* markdown input or a non-content `base`.
|
|
2205
|
+
* Rebase `markdown` onto a `base` content: the document-free twin of `revise`,
|
|
2206
|
+
* returning the new `content` and the text `delta` (offsets are USV indices into
|
|
2207
|
+
* `Content.text`, surviving anchors rebased). Throws on an over-nested markdown
|
|
2208
|
+
* input or a non-content `base`.
|
|
2331
2209
|
* @param {Content} base
|
|
2332
2210
|
* @param {string} markdown
|
|
2333
2211
|
* @returns {{ content: Content; delta: Delta }}
|
|
@@ -2351,13 +2229,9 @@ export function rebase(base, markdown) {
|
|
|
2351
2229
|
}
|
|
2352
2230
|
|
|
2353
2231
|
/**
|
|
2354
|
-
* Runs at instantiation
|
|
2355
|
-
*
|
|
2356
|
-
*
|
|
2357
|
-
*
|
|
2358
|
-
* Not the package's `init`. That name belongs to the hand-written runtime,
|
|
2359
|
-
* which owns instantiation itself (`runtime/runtime.js`); this runs as part of
|
|
2360
|
-
* the instantiation it awaits.
|
|
2232
|
+
* Runs at instantiation, so a Rust panic reaches the console as a stack trace
|
|
2233
|
+
* rather than `unreachable`. Not the package's `init` — that name belongs to
|
|
2234
|
+
* the hand-written runtime, which owns instantiation itself.
|
|
2361
2235
|
*/
|
|
2362
2236
|
export function start() {
|
|
2363
2237
|
wasm.start();
|