@quillmark/wasm 0.98.0 → 0.99.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 +222 -0
- package/LICENSE +13 -0
- package/README.md +63 -60
- package/backends/pdfform/wasm.d.ts +276 -134
- package/backends/pdfform/wasm_bg.js +93 -102
- package/backends/pdfform/wasm_bg.wasm +0 -0
- package/backends/typst/wasm.d.ts +276 -134
- package/backends/typst/wasm_bg.js +93 -102
- package/backends/typst/wasm_bg.wasm +0 -0
- package/core/wasm.d.ts +103 -84
- package/core/wasm_bg.js +76 -82
- package/core/wasm_bg.wasm +0 -0
- package/package.json +2 -2
- package/runtime/runtime.d.ts +120 -71
- package/runtime/runtime.js +341 -89
|
Binary file
|
package/core/wasm.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ export interface Card {
|
|
|
44
44
|
seed?: Record<string, unknown>;
|
|
45
45
|
payloadItems: PayloadItem[];
|
|
46
46
|
/**
|
|
47
|
-
* The card body as canonical `Content
|
|
47
|
+
* The card body as canonical `Content`: the source-of-truth content model.
|
|
48
48
|
* Always this content shape on read, never a markdown string. For the markdown
|
|
49
49
|
* projection call the codec `exportMarkdown(card.body)`. Write a body back
|
|
50
50
|
* with `doc.install(addr, rt)` / `doc.revise(addr, md)`, or via `CardInput.body`.
|
|
@@ -53,10 +53,10 @@ export interface Card {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
|
-
* A card written *into* a document
|
|
56
|
+
* A card written *into* a document: the input twin of `Card`, accepted by
|
|
57
57
|
* `Document.insertCard`. Like `Card` but `body` also
|
|
58
58
|
* takes a markdown `string` (imported to the content, so a markdown / LLM writer
|
|
59
|
-
* needn't build the `Content` shape), and every field but `kind` is optional
|
|
59
|
+
* needn't build the `Content` shape), and every field but `kind` is optional:
|
|
60
60
|
* an absent field defaults (no payload items, an empty body). Write one inline
|
|
61
61
|
* (`{ kind, body }`) or build it with `Document.makeCard`.
|
|
62
62
|
*/
|
|
@@ -71,7 +71,7 @@ export interface CardInput {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
* Canonical richtext content
|
|
74
|
+
* Canonical richtext content: the content model for a card body (and richtext
|
|
75
75
|
* fields). One text sequence over a single coordinate space (Unicode scalar
|
|
76
76
|
* values): `text` plus line attributes, anchored `marks`, and embedded
|
|
77
77
|
* `islands`. Every edit is a splice; markdown is a projection, not the model.
|
|
@@ -95,7 +95,7 @@ export type ContentLine = {
|
|
|
95
95
|
continues?: boolean;
|
|
96
96
|
} & ContentLineKind;
|
|
97
97
|
|
|
98
|
-
/** A line's block role, declared once for `ContentLine` and the `setKind` op
|
|
98
|
+
/** A line's block role, declared once for `ContentLine` and the `setKind` op:
|
|
99
99
|
* a new role is one edit here, as for `ContentContainer`. */
|
|
100
100
|
export type ContentLineKind =
|
|
101
101
|
| { kind: "para" }
|
|
@@ -115,7 +115,7 @@ export type ContentContainer =
|
|
|
115
115
|
|
|
116
116
|
/** A mark over char range `[start, end)` into `Content.text`. The open `type`
|
|
117
117
|
* arm blocks discriminant narrowing (as on `ContentIsland`), so read a
|
|
118
|
-
* payload-carrying arm behind its guard
|
|
118
|
+
* payload-carrying arm behind its guard: `isLinkMark` (`url`) / `isAnchorMark`
|
|
119
119
|
* (`id`), from `@quillmark/wasm/runtime`; the bare arms carry no payload. An
|
|
120
120
|
* `anchor`'s `id` is a caller-supplied, opaque handle, unique per `Content` and
|
|
121
121
|
* invariant while the mark lives (positions rebase, the id never does); it has no
|
|
@@ -128,7 +128,7 @@ export type ContentMark = { start: number; end: number } & (
|
|
|
128
128
|
| { type: string; attrs: unknown }
|
|
129
129
|
);
|
|
130
130
|
|
|
131
|
-
/** A cell in a `TableProps
|
|
131
|
+
/** A cell in a `TableProps`: its plain `text` plus the `marks` over it. `marks`
|
|
132
132
|
* rides the same wire shape as prose `ContentMark`, but each mark's `start`/`end`
|
|
133
133
|
* are USV offsets into this cell's `text` (`0..text.length`), not into
|
|
134
134
|
* `Content.text`. */
|
|
@@ -156,12 +156,16 @@ export interface ImageProps {
|
|
|
156
156
|
* open set: the engine pins `props` as `TableProps` for `table` and `ImageProps`
|
|
157
157
|
* for `image`; an island of any other type round-trips with opaque `props`. Like
|
|
158
158
|
* `ContentMark`, the open `type` arm means a discriminant check does not itself
|
|
159
|
-
* narrow `props
|
|
159
|
+
* narrow `props`: read `props` as the matching shape behind the `isTableIsland` /
|
|
160
160
|
* `isImageIsland` guards (from `@quillmark/wasm/runtime`), which narrow it. */
|
|
161
|
+
/** How faithfully the markdown projection can carry an island. Open like an
|
|
162
|
+
* island `type`: a class this build does not know round-trips verbatim, and
|
|
163
|
+
* reads as `unrepresentable`. */
|
|
164
|
+
export type ContentLossClass = "lossless" | "degraded" | "unrepresentable" | (string & {});
|
|
165
|
+
|
|
161
166
|
export type ContentIsland = {
|
|
162
167
|
id: string;
|
|
163
|
-
|
|
164
|
-
loss: "lossless" | "degraded" | "unrepresentable";
|
|
168
|
+
loss: ContentLossClass;
|
|
165
169
|
} & (
|
|
166
170
|
| { type: "table"; props: TableProps }
|
|
167
171
|
| { type: "image"; props: ImageProps }
|
|
@@ -169,14 +173,14 @@ export type ContentIsland = {
|
|
|
169
173
|
);
|
|
170
174
|
|
|
171
175
|
/**
|
|
172
|
-
* A write address
|
|
176
|
+
* A write address: one navigation concept for the whole `Document` surface. An
|
|
173
177
|
* absent `field` targets the card body; an absent `card` targets the main card.
|
|
174
178
|
* `{}` is the main-card body; `{ card: 2 }` the body of the composable card at
|
|
175
179
|
* index 2; `{ field: "intro" }` the main card's `intro` field; `{ card: 2,
|
|
176
180
|
* field: "intro" }` a card field.
|
|
177
181
|
*
|
|
178
182
|
* On the `Addr`-taking verbs a **bare string** is shorthand for `{ field: name }`
|
|
179
|
-
*
|
|
183
|
+
* (`doc.storeField("qty", 3)`, `doc.revise("intro", md)`) the one coercion
|
|
180
184
|
* rule. A bare number is *not* an addr (`{ card: 2 }` is the self-documenting
|
|
181
185
|
* spelling), so no third navigation idiom re-fragments the surface.
|
|
182
186
|
*/
|
|
@@ -186,7 +190,7 @@ export interface Addr {
|
|
|
186
190
|
}
|
|
187
191
|
|
|
188
192
|
/**
|
|
189
|
-
* A card-only address
|
|
193
|
+
* A card-only address: the axis the card-scoped verbs (`storeFields`,
|
|
190
194
|
* `storeExt`, `getExt`, `commitFields`, …) take. An absent `card` targets the
|
|
191
195
|
* main card. A present `field` throws: a card address takes only `card`, and a
|
|
192
196
|
* would-be nested write is a bug the error names rather than silently ignores.
|
|
@@ -197,7 +201,7 @@ export interface CardAddr {
|
|
|
197
201
|
|
|
198
202
|
/**
|
|
199
203
|
* A text-splice change set over the USV content (CodeMirror `ChangeSet`
|
|
200
|
-
* semantics)
|
|
204
|
+
* semantics): plain, structured-clone-able data. Returned by `revise` and by
|
|
201
205
|
* the `rebase` codec; map a stored position through it with `mapPos`.
|
|
202
206
|
*/
|
|
203
207
|
export interface Delta {
|
|
@@ -211,7 +215,7 @@ export type Assoc = "before" | "after";
|
|
|
211
215
|
* A mark edit in final-text coordinates (post-delta, post-line-op). `add` /
|
|
212
216
|
* `remove` carry the `ContentMark` vocabulary (`{ type, … }`); `removeAnchor`
|
|
213
217
|
* drops one identity anchor by id. An `add` of an `anchor` requires a non-empty
|
|
214
|
-
* `id` not already live in the field
|
|
218
|
+
* `id` not already live in the field: a collision or the empty id throws
|
|
215
219
|
* (ids are caller-supplied and unique per `Content`; DOCUMENT_STORAGE
|
|
216
220
|
* § Anchor-id identity).
|
|
217
221
|
*/
|
|
@@ -227,7 +231,7 @@ export type MarkOp =
|
|
|
227
231
|
/**
|
|
228
232
|
* A line/block edit. `split`/`join` splice `\n`; `setKind`/`setContainers`/
|
|
229
233
|
* `setContinues` touch metadata. `setContinues` sets/clears a line's within-block
|
|
230
|
-
* hard-break flag (`ContentLine.continues`)
|
|
234
|
+
* hard-break flag (`ContentLine.continues`): the op-grained way to lower a
|
|
231
235
|
* Shift+Enter hard break or a new code-fence interior line; `continues: true` on
|
|
232
236
|
* line 0 is rejected (nothing precedes it to continue).
|
|
233
237
|
*/
|
|
@@ -253,7 +257,7 @@ export interface ChangeBundle {
|
|
|
253
257
|
|
|
254
258
|
/**
|
|
255
259
|
* One segment of a parsed `Diagnostic.path` (see `parseDocPath`). The head
|
|
256
|
-
* carries the document-model root
|
|
260
|
+
* carries the document-model root: `main` (only before `body`), a `card`
|
|
257
261
|
* (`kind: null` is the unknown-kind `cards[i]` form), or a `field`; the tail is
|
|
258
262
|
* `field` / `index` / a terminal `body`.
|
|
259
263
|
*/
|
|
@@ -271,7 +275,7 @@ export type FieldSource = "authored" | "default" | "zero";
|
|
|
271
275
|
|
|
272
276
|
/**
|
|
273
277
|
* One resolved row: its `name`, the value the render projection would use, and
|
|
274
|
-
* the `FieldSource` rung it came from. Rows are an ordered array
|
|
278
|
+
* the `FieldSource` rung it came from. Rows are an ordered array: declaration
|
|
275
279
|
* order is structural, not object-key order. The card body is a `body` sibling
|
|
276
280
|
* on its card, never a row in `fields`. Diagnostics stay `Quill.validate`'s;
|
|
277
281
|
* schema guidance (`example:`, labels) reads from `Quill.schema`.
|
|
@@ -283,7 +287,7 @@ export interface ResolvedField {
|
|
|
283
287
|
}
|
|
284
288
|
|
|
285
289
|
/**
|
|
286
|
-
* The main card's resolved rows in declaration order, plus its body row
|
|
290
|
+
* The main card's resolved rows in declaration order, plus its body row:
|
|
287
291
|
* `null` when the main enables no body.
|
|
288
292
|
*/
|
|
289
293
|
export interface ResolvedMain {
|
|
@@ -294,7 +298,7 @@ export interface ResolvedMain {
|
|
|
294
298
|
/**
|
|
295
299
|
* One composable card's resolved rows in declaration order, with its authored
|
|
296
300
|
* `kind` (`null` for an unknown-kind card), its document-array `index`, and its
|
|
297
|
-
* body row
|
|
301
|
+
* body row: `null` when the kind enables no body.
|
|
298
302
|
*/
|
|
299
303
|
export interface ResolvedCard {
|
|
300
304
|
kind: string | null;
|
|
@@ -305,7 +309,7 @@ export interface ResolvedCard {
|
|
|
305
309
|
|
|
306
310
|
/**
|
|
307
311
|
* The resolved-value view (`Quill.resolve`): the main card and every
|
|
308
|
-
* composable card. Value and provenance only
|
|
312
|
+
* composable card. Value and provenance only: completeness and errors stay
|
|
309
313
|
* `Quill.validate`.
|
|
310
314
|
*/
|
|
311
315
|
export interface Resolved {
|
|
@@ -326,7 +330,7 @@ export interface QuillFieldUi {
|
|
|
326
330
|
}
|
|
327
331
|
|
|
328
332
|
/** One entry in a card's `ui.groups` registry: a display-label override for the
|
|
329
|
-
* group id (the map key). An empty object carries no override
|
|
333
|
+
* group id (the map key). An empty object carries no override: the consumer
|
|
330
334
|
* derives the label from the id (`memo_for` → "Memo For"), as it does a field
|
|
331
335
|
* label from its key. */
|
|
332
336
|
export interface QuillGroupUi {
|
|
@@ -338,7 +342,7 @@ export interface QuillCardUi {
|
|
|
338
342
|
title?: string;
|
|
339
343
|
/** The card's group registry: the ordered table of contents naming every
|
|
340
344
|
* group a field's `ui.group` may reference. The map key is the group id, and
|
|
341
|
-
* key order is declaration order
|
|
345
|
+
* key order is declaration order: the display-order contract, the same one
|
|
342
346
|
* `fields` key order carries. Absent when the card declares no groups (or
|
|
343
347
|
* uses the deprecated implicit-group form). */
|
|
344
348
|
groups?: Record<string, QuillGroupUi>;
|
|
@@ -376,7 +380,7 @@ export interface QuillFieldSchema {
|
|
|
376
380
|
properties?: Record<string, QuillFieldSchema>;
|
|
377
381
|
items?: QuillFieldSchema;
|
|
378
382
|
/** Present (and `true`) on a `richtext` or `plaintext` field declared
|
|
379
|
-
* `inline
|
|
383
|
+
* `inline`: the single-paragraph, container-free, island-free constraint.
|
|
380
384
|
* Core serializes `inline: true` into the schema JSON; absent otherwise. */
|
|
381
385
|
inline?: boolean;
|
|
382
386
|
}
|
|
@@ -417,24 +421,39 @@ export interface QuillMetadata {
|
|
|
417
421
|
}
|
|
418
422
|
|
|
419
423
|
|
|
424
|
+
/**
|
|
425
|
+
* Diagnostic message (error or warning)
|
|
426
|
+
*/
|
|
420
427
|
export interface Diagnostic {
|
|
421
428
|
severity: Severity;
|
|
422
429
|
code?: string;
|
|
423
430
|
message: string;
|
|
424
431
|
location?: Location;
|
|
432
|
+
/**
|
|
433
|
+
* Document-model path anchor (e.g. `\"cards.indorsement[0].signature_block\"`).
|
|
434
|
+
*
|
|
435
|
+
* Set on schema validation diagnostics; `undefined` otherwise. See the
|
|
436
|
+
* Rust `quillmark_core::error` module docs for the path grammar.
|
|
437
|
+
*/
|
|
425
438
|
path?: string;
|
|
426
439
|
hint?: string;
|
|
427
440
|
sourceChain?: string[];
|
|
428
441
|
}
|
|
429
442
|
|
|
443
|
+
/**
|
|
444
|
+
* Severity levels for diagnostics
|
|
445
|
+
*/
|
|
446
|
+
export type Severity = "error" | "warning";
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Source location for errors and warnings
|
|
450
|
+
*/
|
|
430
451
|
export interface Location {
|
|
431
452
|
file: string;
|
|
432
453
|
line: number;
|
|
433
454
|
column: number;
|
|
434
455
|
}
|
|
435
456
|
|
|
436
|
-
export type Severity = "error" | "warning";
|
|
437
|
-
|
|
438
457
|
|
|
439
458
|
/**
|
|
440
459
|
* Typed in-memory Quillmark document.
|
|
@@ -444,7 +463,7 @@ export class Document {
|
|
|
444
463
|
[Symbol.dispose](): void;
|
|
445
464
|
/**
|
|
446
465
|
* **Apply** a committed content edit `bundle` (`{ delta?, lineOps?, markOps? }`)
|
|
447
|
-
* at `addr
|
|
466
|
+
* at `addr`, the editor splice: text delta first, then line ops, then mark
|
|
448
467
|
* ops (mark ranges in final-text coordinates), each all-or-nothing. An absent
|
|
449
468
|
* `addr.field` targets the body, an absent `addr.card` the main card.
|
|
450
469
|
*
|
|
@@ -461,7 +480,7 @@ export class Document {
|
|
|
461
480
|
*/
|
|
462
481
|
static blueprintInstruction(quill_name: string): string;
|
|
463
482
|
/**
|
|
464
|
-
* A single composable card by index
|
|
483
|
+
* A single composable card by index: the whole `Card`, the card-indexed
|
|
465
484
|
* twin of the [`main`](Self::main) getter, so reading one card need not
|
|
466
485
|
* materialize every card via [`cards`](Self::cards). An out-of-range
|
|
467
486
|
* `index` throws `edit::index_out_of_range`, matching the card write
|
|
@@ -516,54 +535,54 @@ export class Document {
|
|
|
516
535
|
static fromMarkdown(markdown: string): Document;
|
|
517
536
|
/**
|
|
518
537
|
* The whole `$ext` map at `addr` (a card address, absent `card` = main), or
|
|
519
|
-
* `undefined` when the card carries none. The fine-grained `$ext` read
|
|
538
|
+
* `undefined` when the card carries none. The fine-grained `$ext` read:
|
|
520
539
|
* your own state without serializing the whole card. Throws on a present
|
|
521
540
|
* `field` (a card address takes only `card`) or an out-of-range card.
|
|
522
541
|
*/
|
|
523
542
|
getExt(addr?: CardAddr): Record<string, unknown> | undefined;
|
|
524
543
|
/**
|
|
525
544
|
* The value stored under `$ext[ns]` at `addr` (a card address, absent `card`
|
|
526
|
-
* = main), or `undefined`. The namespace-scoped `$ext` read
|
|
545
|
+
* = main), or `undefined`. The namespace-scoped `$ext` read: your own slot
|
|
527
546
|
* without a whole-card serialize, and non-destructive (unlike
|
|
528
547
|
* `removeExtNamespace`). Throws on a present `field` or an out-of-range card.
|
|
529
548
|
*/
|
|
530
549
|
getExtNamespace(addr: CardAddr, ns: string): unknown;
|
|
531
550
|
/**
|
|
532
|
-
* The **body** markdown projection
|
|
533
|
-
* body (`{ card }`)
|
|
551
|
+
* The **body** markdown projection (the main body, or a composable card's
|
|
552
|
+
* body (`{ card }`)) the on-demand, lossy export (content-only marks do not
|
|
534
553
|
* survive markdown). A body's type is a format fact, not a schema fact, so
|
|
535
554
|
* this read stays quill-free; a body is never absent.
|
|
536
555
|
*
|
|
537
556
|
* `addr` is an optional **card address** (`{ card }`, absent = main). A
|
|
538
|
-
* present `field` throws
|
|
557
|
+
* present `field` throws: a field's markdown is read through the
|
|
539
558
|
* schema-plane `quill.reader(doc).get(field)`, which interprets by declared
|
|
540
|
-
* type
|
|
559
|
+
* type. An out-of-range `addr.card` throws.
|
|
541
560
|
*/
|
|
542
561
|
getMarkdown(addr?: CardAddr): string;
|
|
543
562
|
/**
|
|
544
|
-
* Read the **verbatim stored value** at `addr
|
|
563
|
+
* Read the **verbatim stored value** at `addr`: the raw payload value of a
|
|
545
564
|
* field (a content object for a richtext field, a scalar/array/object
|
|
546
565
|
* otherwise), or the **body content** when `addr.field` is absent. A bare
|
|
547
566
|
* string is `Addr` shorthand for `{ field }`. Reads are total over the field
|
|
548
567
|
* axis: an absent field is `undefined`; only an out-of-range `addr.card`
|
|
549
568
|
* throws `edit::index_out_of_range`. Needs no schema, so it lives on
|
|
550
|
-
* `Document
|
|
569
|
+
* `Document`: the read echo of the verbatim `store*` write, distinct from
|
|
551
570
|
* the interpreted schema-plane [`reader.get`](Self::reader_get). For the
|
|
552
571
|
* markdown projection use [`getMarkdown`](Self::get_markdown) (body) or
|
|
553
572
|
* `reader.get` (a field's declared type).
|
|
554
573
|
*/
|
|
555
574
|
getStored(addr: Addr | string): unknown;
|
|
556
575
|
/**
|
|
557
|
-
* Insert a card
|
|
576
|
+
* Insert a card, the single insertion verb: `at` absent appends, a number
|
|
558
577
|
* inserts at that index (must be in `0..=cards.length`). Accepts a
|
|
559
|
-
* `CardInput
|
|
578
|
+
* `CardInput`: a card read back (`cards` / `removeCard` / `quill.seedCard`),
|
|
560
579
|
* a [`makeCard`](Document::make_card) result, or a bare `{ kind, body }`
|
|
561
580
|
* (every returned `Card` is a valid `CardInput`). Throws if `card.kind` is
|
|
562
581
|
* not a valid kind name, or if `at` is out of range.
|
|
563
582
|
*/
|
|
564
583
|
insertCard(card: CardInput, at?: number): void;
|
|
565
584
|
/**
|
|
566
|
-
* **Install** a richtext value at `addr
|
|
585
|
+
* **Install** a richtext value at `addr`: **value semantics**, content only.
|
|
567
586
|
* Stores exactly `rt` (a canonical `Content` content object); the identity
|
|
568
587
|
* anchors of any previous value are gone. An absent `addr.field` targets the
|
|
569
588
|
* body, an absent `addr.card` the main card. For "here's new markdown," use
|
|
@@ -577,25 +596,25 @@ export class Document {
|
|
|
577
596
|
install(addr: Addr | string, rt: Content): void;
|
|
578
597
|
/**
|
|
579
598
|
* Whether the field at `addr` is marked `!must_fill`. A bare string is `Addr`
|
|
580
|
-
* shorthand for `{ field }`. `false` for an absent field (truthful
|
|
599
|
+
* shorthand for `{ field }`. `false` for an absent field (truthful: it isn't
|
|
581
600
|
* marked) and for a body address (a body is never a fill). Only an
|
|
582
601
|
* out-of-range `addr.card` throws.
|
|
583
602
|
*/
|
|
584
603
|
isFill(addr: Addr | string): boolean;
|
|
585
604
|
/**
|
|
586
605
|
* Replace this document's contents **in place** from a versioned storage
|
|
587
|
-
* DTO string
|
|
606
|
+
* DTO string: the mutating twin of the static
|
|
588
607
|
* [`fromJson`](Document::from_json) constructor. Parse-time `warnings` are
|
|
589
608
|
* cleared. Throws (leaving the document unchanged) on an invalid DTO.
|
|
590
609
|
*
|
|
591
610
|
* The cross-WASM-memory `Document` bridge: mutate a document on a
|
|
592
611
|
* backend-memory clone, then write the mutated state back into the caller's
|
|
593
|
-
* canonical document with this
|
|
612
|
+
* canonical document with this, the one way to update a live handle across
|
|
594
613
|
* the linear-memory seam without the caller re-binding its variable.
|
|
595
614
|
*/
|
|
596
615
|
loadJson(json: string): void;
|
|
597
616
|
/**
|
|
598
|
-
* Build a fresh `Card` from a kind and a flat field map
|
|
617
|
+
* Build a fresh `Card` from a kind and a flat field map: the ergonomic
|
|
599
618
|
* constructor for `insertCard`. `fields` is an optional
|
|
600
619
|
* `Record<string, unknown>` (each entry becomes a card field, in
|
|
601
620
|
* insertion order); `body` defaults to `""`.
|
|
@@ -605,8 +624,8 @@ export class Document {
|
|
|
605
624
|
* here.
|
|
606
625
|
*
|
|
607
626
|
* Checks only what a detached card can decide alone: field-name grammar
|
|
608
|
-
* and value depth. Kind validity is positional
|
|
609
|
-
* root, reserved for a composable card
|
|
627
|
+
* and value depth. Kind validity is positional (`main` is right for the
|
|
628
|
+
* root, reserved for a composable card) so `insertCard` is its gate, and
|
|
610
629
|
* any kind string is accepted here.
|
|
611
630
|
*/
|
|
612
631
|
static makeCard(kind: string, fields?: Record<string, unknown>, body?: string): Card;
|
|
@@ -615,7 +634,7 @@ export class Document {
|
|
|
615
634
|
*/
|
|
616
635
|
moveCard(from: number, to: number): void;
|
|
617
636
|
/**
|
|
618
|
-
* `new Document(quillRef)
|
|
637
|
+
* `new Document(quillRef)`, a blank document: a main card carrying only
|
|
619
638
|
* `$quill`, an empty body, and no composable cards. The programmatic
|
|
620
639
|
* blank canvas: absent fields resolve at render time (`default`, else
|
|
621
640
|
* type-empty zero), so nothing the caller did not set reaches the
|
|
@@ -626,7 +645,7 @@ export class Document {
|
|
|
626
645
|
/**
|
|
627
646
|
* The canonical `$quill` reference grammar as author-facing text. Core is
|
|
628
647
|
* the single source of truth: drive schema `describe` and validation
|
|
629
|
-
* messages from this instead of re-stating the rule
|
|
648
|
+
* messages from this instead of re-stating the rule; it matches the
|
|
630
649
|
* `hint` on `parse::invalid_quill_reference`. Cache it; the value never
|
|
631
650
|
* changes.
|
|
632
651
|
*/
|
|
@@ -634,7 +653,7 @@ export class Document {
|
|
|
634
653
|
removeCard(index: number): Card | undefined;
|
|
635
654
|
/**
|
|
636
655
|
* Remove the `$ext` map on the card `addr` targets *entirely*, returning the
|
|
637
|
-
* previous map or `undefined
|
|
656
|
+
* previous map or `undefined`: a blunt escape hatch that discards every
|
|
638
657
|
* namespace at once (prefer `removeExtNamespace`). `addr` is a card address
|
|
639
658
|
* (absent = main). Throws on a present `field` or an out-of-range card.
|
|
640
659
|
*/
|
|
@@ -660,7 +679,7 @@ export class Document {
|
|
|
660
679
|
*/
|
|
661
680
|
removeSeedNamespace(card_kind: string): any;
|
|
662
681
|
/**
|
|
663
|
-
* **Revise** the richtext value at `addr` from a markdown string
|
|
682
|
+
* **Revise** the richtext value at `addr` from a markdown string: **edit
|
|
664
683
|
* semantics**, the default write path, returning the text `Delta`. Imports
|
|
665
684
|
* the markdown, diffs it against the current value, rebases surviving
|
|
666
685
|
* identity anchors, and returns the change an editor bridge maps its own
|
|
@@ -673,7 +692,7 @@ export class Document {
|
|
|
673
692
|
revise(addr: Addr | string, markdown: string): Delta;
|
|
674
693
|
/**
|
|
675
694
|
* Read the `schema` version tag from a raw storage DTO string without a
|
|
676
|
-
* full parse, or `undefined`. Returns unknown future versions as-is
|
|
695
|
+
* full parse, or `undefined`. Returns unknown future versions as-is:
|
|
677
696
|
* useful to distinguish "build too old" from "payload corrupt" when
|
|
678
697
|
* `fromJson` throws.
|
|
679
698
|
*/
|
|
@@ -682,7 +701,7 @@ export class Document {
|
|
|
682
701
|
* The main card's `$seed` overlay object for `kind` (the `$seed[kind]`
|
|
683
702
|
* entry), or `undefined` when absent. The cheap read that feeds
|
|
684
703
|
* `quill.seedCard(kind, overlay)` without serializing the whole main card
|
|
685
|
-
* via [`main`](Self::main) to fish out one key
|
|
704
|
+
* via [`main`](Self::main) to fish out one key, and it keeps `seedCard`
|
|
686
705
|
* pure: the quill still never reads the document.
|
|
687
706
|
*/
|
|
688
707
|
seedOverlay(kind: string): Record<string, unknown> | undefined;
|
|
@@ -700,41 +719,41 @@ export class Document {
|
|
|
700
719
|
* Replace the opaque `$ext` map on the card `addr` targets (a card address,
|
|
701
720
|
* absent `card` = main). `value` must be a plain object. `$ext` carries
|
|
702
721
|
* out-of-band consumer state and never reaches the rendered output; pass
|
|
703
|
-
* `{}` for an explicit empty `$ext`. Quill-free and verbatim
|
|
722
|
+
* `{}` for an explicit empty `$ext`. Quill-free and verbatim: an opaque
|
|
704
723
|
* `store` verb. Throws on a present `field` or an out-of-range card.
|
|
705
724
|
*/
|
|
706
725
|
storeExt(addr: CardAddr, value: any): void;
|
|
707
726
|
/**
|
|
708
727
|
* Merge `value` into `$ext[ns]` on the card `addr` targets, preserving
|
|
709
|
-
* sibling namespaces
|
|
710
|
-
* address (absent = main). Quill-free and verbatim
|
|
728
|
+
* sibling namespaces: the recommended `$ext` write. `addr` is a card
|
|
729
|
+
* address (absent = main). Quill-free and verbatim: an opaque `store` verb.
|
|
711
730
|
* Throws on a present `field` or an out-of-range card.
|
|
712
731
|
*/
|
|
713
732
|
storeExtNamespace(addr: CardAddr, ns: string, value: any): void;
|
|
714
733
|
/**
|
|
715
|
-
* Store a field verbatim at `addr
|
|
734
|
+
* Store a field verbatim at `addr`: the opaque store (**store** = verbatim,
|
|
716
735
|
* coercion deferred to render; the typed write is
|
|
717
736
|
* [`commitField`](Document::commit_field)). A bare string is `Addr`
|
|
718
737
|
* shorthand for `{ field }`, so `doc.storeField("qty", 3)` reads as written;
|
|
719
738
|
* `{ card: 2, field: "qty" }` targets a composable card. Clears any
|
|
720
|
-
* `!must_fill` marker. A body address (no `field`) throws
|
|
739
|
+
* `!must_fill` marker. A body address (no `field`) throws: a body is never
|
|
721
740
|
* opaque; write it with `revise` / `install` / `writer.setBody`. Throws on
|
|
722
741
|
* an out-of-range card or a malformed name.
|
|
723
742
|
*/
|
|
724
743
|
storeField(addr: Addr | string, value: any): void;
|
|
725
744
|
/**
|
|
726
|
-
* Store several fields verbatim and atomically on the card `addr` targets
|
|
745
|
+
* Store several fields verbatim and atomically on the card `addr` targets:
|
|
727
746
|
* the opaque store's batch. `addr` is a **card address** (`{ card }`, absent
|
|
728
747
|
* = main); a present `field` throws. The batch verb takes the address first
|
|
729
748
|
* and is never shape-overloaded, because `card` is a legal field name:
|
|
730
749
|
* `storeFields({}, fields)` is the main card, `storeFields({ card: 2 },
|
|
731
|
-
* fields)` a composable one
|
|
750
|
+
* fields)` a composable one, never ambiguous with "set field `card`".
|
|
732
751
|
* Nothing is applied on error; the thrown error's `diagnostics` carry one
|
|
733
752
|
* entry per offending field. Throws on an out-of-range card.
|
|
734
753
|
*/
|
|
735
754
|
storeFields(addr: CardAddr, fields: Record<string, unknown>): void;
|
|
736
755
|
/**
|
|
737
|
-
* Store a field verbatim at `addr` and mark it `!must_fill
|
|
756
|
+
* Store a field verbatim at `addr` and mark it `!must_fill`: the opaque
|
|
738
757
|
* store's fill variant, card-capable (a bare string or `{ field }` for main,
|
|
739
758
|
* `{ card, field }` for a composable card). A body address throws. Same
|
|
740
759
|
* validation as [`storeField`](Document::store_field).
|
|
@@ -742,9 +761,9 @@ export class Document {
|
|
|
742
761
|
storeFill(addr: Addr | string, value: any): void;
|
|
743
762
|
/**
|
|
744
763
|
* Merge a card-kind's seed `overlay` into the **main** card's `$seed` map
|
|
745
|
-
* under `cardKind`, preserving sibling kinds
|
|
764
|
+
* under `cardKind`, preserving sibling kinds: `$seed` lives on the main
|
|
746
765
|
* card by model, so this takes no address. Sets the starting values new
|
|
747
|
-
* cards of that kind spawn with. Quill-free and verbatim
|
|
766
|
+
* cards of that kind spawn with. Quill-free and verbatim: an opaque `store`
|
|
748
767
|
* verb. Throws if `overlay` cannot be serialized or nests too deep.
|
|
749
768
|
*/
|
|
750
769
|
storeSeedNamespace(card_kind: string, overlay: any): void;
|
|
@@ -752,7 +771,7 @@ export class Document {
|
|
|
752
771
|
* Serialize this document to a versioned storage DTO string.
|
|
753
772
|
*
|
|
754
773
|
* Prefer this over `toMarkdown` for persistence across restarts or crate
|
|
755
|
-
* upgrades
|
|
774
|
+
* upgrades: the wire format is frozen per `schema` version. Parse-time
|
|
756
775
|
* `warnings` are excluded from the DTO.
|
|
757
776
|
*
|
|
758
777
|
* Output is **byte-deterministic** within a `schema` version: equal
|
|
@@ -766,7 +785,7 @@ export class Document {
|
|
|
766
785
|
toMarkdown(): string;
|
|
767
786
|
/**
|
|
768
787
|
* Like [`fromJson`](Document::from_json) but returns `undefined` instead
|
|
769
|
-
* of throwing when `json` is not a valid storage DTO
|
|
788
|
+
* of throwing when `json` is not a valid storage DTO: use to
|
|
770
789
|
* discriminate format without exceptions as control flow.
|
|
771
790
|
* `undefined` means "not a storage DTO"; `fromMarkdown` still throws on
|
|
772
791
|
* genuinely malformed markdown.
|
|
@@ -779,7 +798,7 @@ export class Document {
|
|
|
779
798
|
readonly cards: Card[];
|
|
780
799
|
/**
|
|
781
800
|
* The document's main (entry) card. Allocates and serializes on each
|
|
782
|
-
* call
|
|
801
|
+
* call: cache locally if read in a hot loop.
|
|
783
802
|
*/
|
|
784
803
|
readonly main: Card;
|
|
785
804
|
readonly quillRef: string;
|
|
@@ -791,7 +810,7 @@ export class Quill {
|
|
|
791
810
|
free(): void;
|
|
792
811
|
[Symbol.dispose](): void;
|
|
793
812
|
/**
|
|
794
|
-
* Build a quill from a file tree. Pure
|
|
813
|
+
* Build a quill from a file tree. Pure: no backend, no engine; the
|
|
795
814
|
* declared backend is resolved later, at render time.
|
|
796
815
|
*
|
|
797
816
|
* Accepts either a `Map<string, Uint8Array>` or a plain object
|
|
@@ -801,11 +820,11 @@ export class Quill {
|
|
|
801
820
|
*/
|
|
802
821
|
static fromTree(tree: Map<string, Uint8Array>): Quill;
|
|
803
822
|
/**
|
|
804
|
-
* The resolved-value view of `doc` against this quill's schema
|
|
823
|
+
* The resolved-value view of `doc` against this quill's schema: for every
|
|
805
824
|
* declared field the value the render projection would use and the
|
|
806
825
|
* `FieldSource` rung it came from (`"authored" | "default" | "zero"`), in
|
|
807
826
|
* one call. The card body is a `body` sibling on its card (row `name`
|
|
808
|
-
* `"body"`), never a row in `fields
|
|
827
|
+
* `"body"`), never a row in `fields`: `null` when the kind enables no body.
|
|
809
828
|
*
|
|
810
829
|
* Value and provenance only: completeness and errors stay `validate`'s
|
|
811
830
|
* (a consumer merges it with its own diagnostic producers regardless), and
|
|
@@ -822,11 +841,11 @@ export class Quill {
|
|
|
822
841
|
* Pass `document.seedOverlay(cardKind)` as `overlay` so a card added to a
|
|
823
842
|
* template-derived document inherits its curated starting values; omit it
|
|
824
843
|
* (or pass `undefined` / `null`) for the bare schema seed. `overlay` is a
|
|
825
|
-
* plain object
|
|
844
|
+
* plain object: this reads the document, it does not mutate it.
|
|
826
845
|
*/
|
|
827
846
|
seedCard(card_kind: string, overlay: Record<string, unknown> | undefined): Card | undefined;
|
|
828
847
|
/**
|
|
829
|
-
* Seed a starter `Document` from the schema
|
|
848
|
+
* Seed a starter `Document` from the schema, the main card plus one
|
|
830
849
|
* instance of each composable card kind, each committing its fields'
|
|
831
850
|
* `example:` values and leaving every other field absent (interpolated at
|
|
832
851
|
* render: `default:`, else type-empty zero). Illustration-first: a field
|
|
@@ -835,14 +854,14 @@ export class Quill {
|
|
|
835
854
|
*/
|
|
836
855
|
seedDocument(): Document;
|
|
837
856
|
/**
|
|
838
|
-
* Seed a starter main `Card` (carries `$quill`) from the schema
|
|
857
|
+
* Seed a starter main `Card` (carries `$quill`) from the schema: the
|
|
839
858
|
* `$kind: main` card of [`seedDocument`](Self::seed_document) in
|
|
840
859
|
* isolation, committing each field's `example:` value. Returns the same
|
|
841
860
|
* `Card` shape as the `Document.main` getter.
|
|
842
861
|
*/
|
|
843
862
|
seedMain(): Card;
|
|
844
863
|
/**
|
|
845
|
-
* Flatten this quill back into its canonical file tree
|
|
864
|
+
* Flatten this quill back into its canonical file tree: the inverse of
|
|
846
865
|
* [`fromTree`](Self::from_tree). Round-trips: `Quill.fromTree(q.toTree())`
|
|
847
866
|
* reproduces an equivalent quill.
|
|
848
867
|
*
|
|
@@ -858,8 +877,8 @@ export class Quill {
|
|
|
858
877
|
* Validate `doc` against this quill's schema, returning every diagnostic
|
|
859
878
|
* (an empty array when the document is valid).
|
|
860
879
|
*
|
|
861
|
-
* Forwards the canonical `validation::*` diagnostics
|
|
862
|
-
* `path`, and `hint` the engine emits
|
|
880
|
+
* Forwards the canonical `validation::*` diagnostics (same `code`,
|
|
881
|
+
* `path`, and `hint` the engine emits) including the non-fatal
|
|
863
882
|
* `validation::must_fill` warning for each `!must_fill` marker left in
|
|
864
883
|
* the document. Field values, defaults, and order are not part of this
|
|
865
884
|
* surface: read them from the `Document` payload and `Quill.schema`
|
|
@@ -868,14 +887,14 @@ export class Quill {
|
|
|
868
887
|
validate(doc: Document): Diagnostic[];
|
|
869
888
|
/**
|
|
870
889
|
* The *declared* backend identifier (`config.backend`, e.g. `"typst"`).
|
|
871
|
-
* Intent, not a resolved capability
|
|
890
|
+
* Intent, not a resolved capability: capability (`supportedFormats` /
|
|
872
891
|
* `supportsCanvas`) is read from the engine.
|
|
873
892
|
*/
|
|
874
893
|
readonly backendId: string;
|
|
875
894
|
readonly blueprint: string;
|
|
876
895
|
/**
|
|
877
896
|
* Identity snapshot of the `quill:` section of `Quill.yaml` plus any extra
|
|
878
|
-
* `quill:` keys. Pure config
|
|
897
|
+
* `quill:` keys. Pure config: the backend's output formats are a
|
|
879
898
|
* resolved-backend capability read from the engine
|
|
880
899
|
* (`Quillmark.supportedFormats`), not part of this snapshot.
|
|
881
900
|
*/
|
|
@@ -883,15 +902,15 @@ export class Quill {
|
|
|
883
902
|
/**
|
|
884
903
|
* Document schema for the quill: the user-fillable fields plus their
|
|
885
904
|
* `ui` hints (title / group / compact / multiline). The single
|
|
886
|
-
* field-metadata surface
|
|
887
|
-
* alike. Key order in `fields`/`properties` is declaration order
|
|
905
|
+
* field-metadata surface: drives form editors and LLM/MCP consumers
|
|
906
|
+
* alike. Key order in `fields`/`properties` is declaration order: the
|
|
888
907
|
* ordering contract. Returns the `QuillSchema` shape.
|
|
889
908
|
*/
|
|
890
909
|
readonly schema: QuillSchema;
|
|
891
910
|
}
|
|
892
911
|
|
|
893
912
|
/**
|
|
894
|
-
* Export a canonical `Content` content to its markdown projection
|
|
913
|
+
* Export a canonical `Content` content to its markdown projection: the pure
|
|
895
914
|
* on-demand codec behind `exportMarkdown(card.body)`. Throws if `rt` is not a
|
|
896
915
|
* canonical content.
|
|
897
916
|
*/
|
|
@@ -899,7 +918,7 @@ export function exportMarkdown(rt: Content): string;
|
|
|
899
918
|
|
|
900
919
|
/**
|
|
901
920
|
* Serialize structured [`DocPathSeg`] segments back to the canonical path
|
|
902
|
-
* string
|
|
921
|
+
* string: the inverse of `parseDocPath`, for a consumer that builds a path
|
|
903
922
|
* rather than reads one. Throws on a segment array the deserializer rejects,
|
|
904
923
|
* and on an empty segment array (symmetric with `parseDocPath("")`, which
|
|
905
924
|
* throws "empty path").
|
|
@@ -907,7 +926,7 @@ export function exportMarkdown(rt: Content): string;
|
|
|
907
926
|
export function formatDocPath(segs: DocPathSeg[]): string;
|
|
908
927
|
|
|
909
928
|
/**
|
|
910
|
-
* Import a markdown string to a canonical `Content` content
|
|
929
|
+
* Import a markdown string to a canonical `Content` content: the pure,
|
|
911
930
|
* document-free codec. Pair with `install(addr, importMarkdown(md))` to spell
|
|
912
931
|
* the cold (anchor-losing) write at the call site; prefer `revise` for edit
|
|
913
932
|
* semantics. Throws on an over-nested input.
|
|
@@ -920,8 +939,8 @@ export function importMarkdown(markdown: string): Content;
|
|
|
920
939
|
export function init(): void;
|
|
921
940
|
|
|
922
941
|
/**
|
|
923
|
-
* Map a base content position
|
|
924
|
-
* offset
|
|
942
|
+
* Map a base content position (a USV index into `Content.text`, not a UTF-16
|
|
943
|
+
* offset) through a `delta` to its new USV position: the pure position-mapping
|
|
925
944
|
* codec an editor bridge composes to hold a caret stable across a `revise`.
|
|
926
945
|
* `assoc` decides the side of a same-position insertion (`"after"` moves past
|
|
927
946
|
* it). Throws on a malformed `delta`.
|
|
@@ -931,14 +950,14 @@ export function mapPos(delta: Delta, pos: number, assoc: Assoc): number;
|
|
|
931
950
|
/**
|
|
932
951
|
* Parse a canonical document-model `Diagnostic.path`
|
|
933
952
|
* (`cards.<kind>[<i>].<field>`, `main.body`, `recipients[0].name`) into its
|
|
934
|
-
* structured [`DocPathSeg`] segments
|
|
953
|
+
* structured [`DocPathSeg`] segments: the exported inverse of the engine's
|
|
935
954
|
* one path serializer, so a consumer routes on segments instead of regexing
|
|
936
955
|
* the string. Throws on a malformed path.
|
|
937
956
|
*/
|
|
938
957
|
export function parseDocPath(path: string): DocPathSeg[];
|
|
939
958
|
|
|
940
959
|
/**
|
|
941
|
-
* Rebase `markdown` onto a `base` content
|
|
960
|
+
* Rebase `markdown` onto a `base` content, the pure, document-free twin of
|
|
942
961
|
* `revise`: cold-import + `diff_import`, returning the new `content` and the
|
|
943
962
|
* text `delta` (its offsets USV indices into `Content.text`, surviving anchors
|
|
944
963
|
* rebased). Use it to compute a revise without a document in hand; `revise(addr,
|