@quillmark/wasm 0.103.0 → 0.105.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 +199 -26
- package/README.md +76 -210
- package/backends/pdfform/wasm.d.ts +484 -683
- package/backends/pdfform/wasm.js +415 -469
- package/backends/pdfform/wasm_bg.wasm +0 -0
- package/backends/pdfform/wasm_bg.wasm.d.ts +3 -0
- package/backends/typst/wasm.d.ts +484 -683
- package/backends/typst/wasm.js +415 -469
- package/backends/typst/wasm_bg.wasm +0 -0
- package/backends/typst/wasm_bg.wasm.d.ts +3 -0
- package/core/wasm.d.ts +356 -462
- package/core/wasm.js +360 -389
- package/core/wasm_bg.wasm +0 -0
- package/core/wasm_bg.wasm.d.ts +3 -0
- package/package.json +2 -2
- package/runtime/runtime.d.ts +181 -252
- package/runtime/runtime.js +191 -347
|
@@ -24,17 +24,13 @@ export type PayloadItem =
|
|
|
24
24
|
| { type: "comment"; text: string; inline?: boolean };
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* A single card block, as read back from a document
|
|
28
|
-
* `
|
|
29
|
-
* / `Document.makeCard`. To feed a card *into* a document use `CardInput`
|
|
30
|
-
* (which `insertCard` accepts); every `Card` is a valid `CardInput`,
|
|
31
|
-
* so a card read from one document pushes straight into another.
|
|
27
|
+
* A single card block, as read back from a document. Every `Card` is a valid
|
|
28
|
+
* `CardInput`, so a card read from one document pushes straight into another.
|
|
32
29
|
*
|
|
33
30
|
* `$` system entries are hoisted to named fields: `kind` (the `$kind`, empty
|
|
34
|
-
* string when none),
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* user fields and comments in order.
|
|
31
|
+
* string when none), `quill` (`$quill` `name@version`, main card only), `ext`
|
|
32
|
+
* (`$ext`), and `seed` (the `$seed` per-kind overlay map, main card only).
|
|
33
|
+
* `payloadItems` carries user fields and comments in order.
|
|
38
34
|
*/
|
|
39
35
|
export interface Card {
|
|
40
36
|
kind: string;
|
|
@@ -43,21 +39,16 @@ export interface Card {
|
|
|
43
39
|
seed?: Record<string, unknown>;
|
|
44
40
|
payloadItems: PayloadItem[];
|
|
45
41
|
/**
|
|
46
|
-
* The card body as canonical `Content
|
|
47
|
-
*
|
|
48
|
-
* projection call the codec `exportMarkdown(card.body)`. Write a body back
|
|
49
|
-
* with `doc.overwrite(addr, rt)` / `doc.revise(addr, md)`, or via `CardInput.body`.
|
|
42
|
+
* The card body as canonical `Content`, never a markdown string. For the
|
|
43
|
+
* markdown projection call `exportMarkdown(card.body)`.
|
|
50
44
|
*/
|
|
51
45
|
body: Content;
|
|
52
46
|
}
|
|
53
47
|
|
|
54
48
|
/**
|
|
55
|
-
* A card written *into* a document
|
|
56
|
-
* `
|
|
57
|
-
*
|
|
58
|
-
* needn't build the `Content` shape), and every field but `kind` is optional:
|
|
59
|
-
* an absent field defaults (no payload items, an empty body). Write one inline
|
|
60
|
-
* (`{ kind, body }`) or build it with `Document.makeCard`.
|
|
49
|
+
* A card written *into* a document, accepted by `Document.insertCard`. Like
|
|
50
|
+
* `Card`, but `body` also takes a markdown `string`, and every field but `kind`
|
|
51
|
+
* is optional (defaulting to no payload items and an empty body).
|
|
61
52
|
*/
|
|
62
53
|
export interface CardInput {
|
|
63
54
|
kind: string;
|
|
@@ -69,11 +60,10 @@ export interface CardInput {
|
|
|
69
60
|
}
|
|
70
61
|
|
|
71
62
|
/**
|
|
72
|
-
* Canonical richtext content: the
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* Mirrors `quillmark_content::serial`'s canonical JSON encoding.
|
|
63
|
+
* Canonical richtext content: the model behind a card body and richtext fields.
|
|
64
|
+
* One text sequence over a single coordinate space (Unicode scalar values):
|
|
65
|
+
* `text` plus line attributes, anchored `marks`, and embedded `islands`. Every
|
|
66
|
+
* edit is a splice; markdown is a projection, not the model.
|
|
77
67
|
*/
|
|
78
68
|
export interface Content {
|
|
79
69
|
text: string;
|
|
@@ -82,19 +72,17 @@ export interface Content {
|
|
|
82
72
|
islands: ContentIsland[];
|
|
83
73
|
}
|
|
84
74
|
|
|
85
|
-
/** One `\n`-separated segment of `Content.text`, in order. `kind` is an open set
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* narrowing, so read `level`/`lang` behind a check of the arm you want. */
|
|
75
|
+
/** One `\n`-separated segment of `Content.text`, in order. `kind` is an open set:
|
|
76
|
+
* an unknown role round-trips with opaque `attrs` and renders as a paragraph.
|
|
77
|
+
* The open arm blocks discriminant narrowing, so read `level`/`lang` behind a
|
|
78
|
+
* check of the arm you want. */
|
|
90
79
|
export type ContentLine = {
|
|
91
80
|
containers: ContentContainer[];
|
|
92
81
|
/** A within-block hard line break rather than a new block. Omitted (false) in the common case. */
|
|
93
82
|
continues?: boolean;
|
|
94
83
|
} & ContentLineKind;
|
|
95
84
|
|
|
96
|
-
/** A line's block role,
|
|
97
|
-
* a new role is one edit here, as for `ContentContainer`. */
|
|
85
|
+
/** A line's block role, shared by `ContentLine` and the `setKind` op. */
|
|
98
86
|
export type ContentLineKind =
|
|
99
87
|
| { kind: "para" }
|
|
100
88
|
| { kind: "heading"; level: number }
|
|
@@ -112,13 +100,12 @@ export type ContentContainer =
|
|
|
112
100
|
| { container: string; attrs: unknown };
|
|
113
101
|
|
|
114
102
|
/** A mark over char range `[start, end)` into `Content.text`. The open `type`
|
|
115
|
-
* arm blocks discriminant narrowing
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
* § Anchor-id identity. */
|
|
103
|
+
* arm blocks discriminant narrowing, so read a payload-carrying arm behind its
|
|
104
|
+
* guard: `isLinkMark` (`url`) / `isAnchorMark` (`id`), from
|
|
105
|
+
* `@quillmark/wasm/runtime`. An `anchor`'s `id` is a caller-supplied opaque
|
|
106
|
+
* handle, unique per `Content` and invariant while the mark lives (positions
|
|
107
|
+
* rebase, the id never does); it has no markdown projection and survives only
|
|
108
|
+
* through the edit lane. */
|
|
122
109
|
export type ContentMark = { start: number; end: number } & (
|
|
123
110
|
| { type: "strong" | "emph" | "underline" | "strike" | "code" }
|
|
124
111
|
| { type: "link"; url: string }
|
|
@@ -126,9 +113,8 @@ export type ContentMark = { start: number; end: number } & (
|
|
|
126
113
|
| { type: string; attrs: unknown }
|
|
127
114
|
);
|
|
128
115
|
|
|
129
|
-
/** A cell in a `TableProps
|
|
130
|
-
*
|
|
131
|
-
* are USV offsets into this cell's `text` (`0..text.length`), not into
|
|
116
|
+
/** A cell in a `TableProps`. `marks` rides the prose `ContentMark` shape, but
|
|
117
|
+
* each mark's `start`/`end` are USV offsets into this cell's `text`, not into
|
|
132
118
|
* `Content.text`. */
|
|
133
119
|
export interface TableCell {
|
|
134
120
|
text: string;
|
|
@@ -150,17 +136,15 @@ export interface ImageProps {
|
|
|
150
136
|
alt: string;
|
|
151
137
|
}
|
|
152
138
|
|
|
153
|
-
/**
|
|
154
|
-
*
|
|
155
|
-
* for `image`; an island of any other type round-trips with opaque `props`. Like
|
|
156
|
-
* `ContentMark`, the open `type` arm means a discriminant check does not itself
|
|
157
|
-
* narrow `props`: read `props` as the matching shape behind the `isTableIsland` /
|
|
158
|
-
* `isImageIsland` guards (from `@quillmark/wasm/runtime`), which narrow it. */
|
|
159
|
-
/** How faithfully the markdown projection can carry an island. Open like an
|
|
160
|
-
* island `type`: a class this build does not know round-trips verbatim, and
|
|
161
|
-
* reads as `unrepresentable`. */
|
|
139
|
+
/** How faithfully the markdown projection can carry an island. Open: an unknown
|
|
140
|
+
* class round-trips verbatim and reads as `unrepresentable`. */
|
|
162
141
|
export type ContentLossClass = "lossless" | "degraded" | "unrepresentable" | (string & {});
|
|
163
142
|
|
|
143
|
+
/** A structured object occupying one island slot in `Content.text`. `type` is an
|
|
144
|
+
* open set: `props` is `TableProps` for `table` and `ImageProps` for `image`,
|
|
145
|
+
* and any other type round-trips with opaque `props`. The open arm blocks
|
|
146
|
+
* narrowing, so read `props` behind the `isTableIsland` / `isImageIsland`
|
|
147
|
+
* guards (from `@quillmark/wasm/runtime`). */
|
|
164
148
|
export type ContentIsland = {
|
|
165
149
|
id: string;
|
|
166
150
|
loss: ContentLossClass;
|
|
@@ -178,9 +162,16 @@ export type ContentIsland = {
|
|
|
178
162
|
* field: "intro" }` a card field.
|
|
179
163
|
*
|
|
180
164
|
* On the `Addr`-taking verbs a **bare string** is shorthand for `{ field: name }`
|
|
181
|
-
* (`doc.storeField("qty", 3)
|
|
182
|
-
*
|
|
183
|
-
*
|
|
165
|
+
* (`doc.storeField("qty", 3)`); a bare number is *not* an addr.
|
|
166
|
+
*
|
|
167
|
+
* `doc.pathFor(addr)` mints the address as its canonical `DocPath` string, the
|
|
168
|
+
* anchor `Diagnostic.path` carries and `session.locate` / `session.fieldBoxes`
|
|
169
|
+
* take. A card path is kind-qualified, so a hand-built one needs the card's
|
|
170
|
+
* `$kind`, and a wrong-kind path matches nothing silently.
|
|
171
|
+
*
|
|
172
|
+
* An `Addr` names a field, never a value inside one: every verb that takes one
|
|
173
|
+
* would then carry an element axis it cannot answer. The one read that reaches
|
|
174
|
+
* inside takes the path as its own argument, `reader.getContentAt(addr, path)`.
|
|
184
175
|
*/
|
|
185
176
|
export interface Addr {
|
|
186
177
|
card?: number;
|
|
@@ -188,10 +179,9 @@ export interface Addr {
|
|
|
188
179
|
}
|
|
189
180
|
|
|
190
181
|
/**
|
|
191
|
-
* A card-only address
|
|
192
|
-
* `storeExt`, `getExt`, `commitFields`, …)
|
|
193
|
-
*
|
|
194
|
-
* would-be nested write is a bug the error names rather than silently ignores.
|
|
182
|
+
* A card-only address, taken by the card-scoped verbs (`storeFields`,
|
|
183
|
+
* `storeExt`, `getExt`, `commitFields`, …). An absent `card` targets the main
|
|
184
|
+
* card; a present `field` throws.
|
|
195
185
|
*/
|
|
196
186
|
export interface CardAddr {
|
|
197
187
|
card?: number;
|
|
@@ -199,8 +189,8 @@ export interface CardAddr {
|
|
|
199
189
|
|
|
200
190
|
/**
|
|
201
191
|
* A text-splice change set over the USV content (CodeMirror `ChangeSet`
|
|
202
|
-
* semantics)
|
|
203
|
-
*
|
|
192
|
+
* semantics), returned by `revise` and by the `rebase` codec. Map a stored
|
|
193
|
+
* position through it with `mapPos`.
|
|
204
194
|
*/
|
|
205
195
|
export interface Delta {
|
|
206
196
|
ops: ({ retain: number } | { insert: string } | { delete: number })[];
|
|
@@ -211,11 +201,9 @@ export type Assoc = "before" | "after";
|
|
|
211
201
|
|
|
212
202
|
/**
|
|
213
203
|
* A mark edit in final-text coordinates (post-delta, post-line-op). `add` /
|
|
214
|
-
* `remove` carry the `ContentMark` vocabulary
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
* (ids are caller-supplied and unique per `Content`; DOCUMENT_STORAGE
|
|
218
|
-
* § Anchor-id identity).
|
|
204
|
+
* `remove` carry the `ContentMark` vocabulary; `removeAnchor` drops one identity
|
|
205
|
+
* anchor by id. An `add` of an `anchor` requires a non-empty `id` not already
|
|
206
|
+
* live in the field; a collision or the empty id throws.
|
|
219
207
|
*/
|
|
220
208
|
export type MarkOp =
|
|
221
209
|
| ({ op: "add" | "remove"; start: number; end: number } & (
|
|
@@ -227,12 +215,10 @@ export type MarkOp =
|
|
|
227
215
|
| { op: "removeAnchor"; id: string };
|
|
228
216
|
|
|
229
217
|
/**
|
|
230
|
-
* A line/block edit. `split`/`join` splice `\n` in post-`delta`,
|
|
231
|
-
* coordinates; `setKind`/`setContainers`/`setContinues` touch
|
|
232
|
-
* `setContinues` sets
|
|
233
|
-
* (`ContentLine.continues`):
|
|
234
|
-
* break or a new code-fence interior line; `continues: true` on line 0 is
|
|
235
|
-
* rejected (nothing precedes it to continue).
|
|
218
|
+
* A line/block edit. `split`/`join` splice `\n` in post-`delta`,
|
|
219
|
+
* post-`islandOps` coordinates; `setKind`/`setContainers`/`setContinues` touch
|
|
220
|
+
* metadata. `setContinues` sets or clears a line's within-block hard-break flag
|
|
221
|
+
* (`ContentLine.continues`); `continues: true` on line 0 is rejected.
|
|
236
222
|
*/
|
|
237
223
|
export type LineOp =
|
|
238
224
|
| { op: "split"; at: number }
|
|
@@ -243,34 +229,25 @@ export type LineOp =
|
|
|
243
229
|
|
|
244
230
|
/**
|
|
245
231
|
* An island edit: the only channel that reaches an island's payload, a table's
|
|
246
|
-
* cells or an image's url.
|
|
247
|
-
*
|
|
248
|
-
* Both ops move one island entry and leave the field's text and marks alone, so
|
|
249
|
-
* an island edit keeps every identity anchor in the field. That is why a table
|
|
250
|
-
* edit lowers to `applyChange` rather than `overwrite`, which drops them all.
|
|
232
|
+
* cells or an image's url. Both ops leave the field's text and marks alone, so
|
|
233
|
+
* an island edit keeps every identity anchor in the field.
|
|
251
234
|
*
|
|
252
|
-
* `set` addresses an existing island by `id`; an `id`
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
* `
|
|
257
|
-
*
|
|
258
|
-
*
|
|
235
|
+
* `set` addresses an existing island by `id`; an unknown `id` throws. `insert`
|
|
236
|
+
* places a new island's slot at `at` together with its entry, so a slot never
|
|
237
|
+
* exists without an island behind it; its `id` must be non-empty and unused.
|
|
238
|
+
* `at` is a position in the text the `delta` and this bundle's earlier island
|
|
239
|
+
* ops left, so slots after `a` and `b` of `abc` go in at 1 and 3. A stale frame
|
|
240
|
+
* misplaces slots and never throws. A `delta` insert string may not carry a
|
|
241
|
+
* slot, which would orphan: split such a splice into the slot-free `delta` plus
|
|
242
|
+
* one `insert` per slot.
|
|
259
243
|
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
244
|
+
* Deleting an island needs no op: a `delta` that removes its slot drops the
|
|
245
|
+
* island whole, and a block island's line demotes to `para`. Re-landing it is an
|
|
246
|
+
* `insert` of the full island under its original id; a pasted copy of a live
|
|
247
|
+
* island mints a fresh one.
|
|
264
248
|
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
* full island under its original id, and only the producer that deleted it
|
|
268
|
-
* still holds that value. A pasted copy of a live island is new and mints fresh
|
|
269
|
-
* (DOCUMENT_STORAGE § Island-id determinism). A block island's line demotes to
|
|
270
|
-
* `para` when its slot goes, so re-landing one re-tags the line too.
|
|
271
|
-
*
|
|
272
|
-
* A `set` stores the `loss` it is given: nothing re-derives the class from the
|
|
273
|
-
* new `props`, so a write that changes what markdown can carry must say so.
|
|
249
|
+
* A `set` stores the `loss` it is given; nothing re-derives the class from the
|
|
250
|
+
* new `props`.
|
|
274
251
|
*
|
|
275
252
|
* An island is *inline* (a slot inside a paragraph) unless its line says
|
|
276
253
|
* otherwise. A **block** island is one bundle of all three channels, in the
|
|
@@ -283,13 +260,12 @@ export type IslandOp =
|
|
|
283
260
|
| ({ op: "insert"; at: number } & ContentIsland);
|
|
284
261
|
|
|
285
262
|
/**
|
|
286
|
-
* A committed content edit bundle for `applyChange
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
* optional.
|
|
263
|
+
* A committed content edit bundle for `applyChange`, applied in order: a text
|
|
264
|
+
* `delta`, then `islandOps`, then `lineOps`, then `markOps` (mark ranges are in
|
|
265
|
+
* final-text coordinates). Every field is optional.
|
|
290
266
|
*
|
|
291
|
-
* Within each channel ops apply in sequence
|
|
292
|
-
*
|
|
267
|
+
* Within each channel ops apply in sequence against the state the earlier ones
|
|
268
|
+
* left: an island `insert`'s `at` counts earlier ops' slots, and `lineOps`
|
|
293
269
|
* positions and indices renumber through earlier `split`/`join`.
|
|
294
270
|
*/
|
|
295
271
|
export interface ChangeBundle {
|
|
@@ -317,13 +293,9 @@ export type DocPathSeg =
|
|
|
317
293
|
|
|
318
294
|
|
|
319
295
|
/**
|
|
320
|
-
* Page dimensions in points (1 pt = 1/72 inch).
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
* Report-only: the painter sizes the canvas itself based on
|
|
324
|
-
* `PaintOptions`. `pageSize` is exposed for callers that need page
|
|
325
|
-
* geometry up-front (e.g. to lay out a scrollable list of canvases
|
|
326
|
-
* before any pixels are rendered).
|
|
296
|
+
* Page dimensions in points (1 pt = 1/72 inch). Report-only: the painter sizes
|
|
297
|
+
* the canvas itself from `PaintOptions`. `pageSize` is for callers that need
|
|
298
|
+
* page geometry up-front, e.g. to lay out a scrollable list of canvases.
|
|
327
299
|
*/
|
|
328
300
|
export interface PageSize {
|
|
329
301
|
widthPt: number;
|
|
@@ -331,25 +303,14 @@ export interface PageSize {
|
|
|
331
303
|
}
|
|
332
304
|
|
|
333
305
|
/**
|
|
334
|
-
* Inputs to `LiveSession.paint`. Both
|
|
335
|
-
* to
|
|
336
|
-
*
|
|
337
|
-
* - `layoutScale` (layout-space pixels per point (Typst point / PDF
|
|
338
|
-
* point) the same 1/72″ unit). For on-screen
|
|
339
|
-
* canvases this is CSS pixels per pt; the page's layout-pixel size is
|
|
340
|
-
* `widthPt * layoutScale × heightPt * layoutScale`. The painter
|
|
341
|
-
* surfaces these dimensions as `layoutWidth` / `layoutHeight` so
|
|
342
|
-
* consumers can drive `canvas.style.*` (or any layout system).
|
|
343
|
-
* - `densityScale`: backing-store density multiplier. Fold
|
|
344
|
-
* `window.devicePixelRatio`, in-app zoom, and `visualViewport.scale`
|
|
345
|
-
* (pinch-zoom) into a single value here. Defaults to `1`, which
|
|
346
|
-
* produces a non-retina backing store: pass `window.devicePixelRatio`
|
|
347
|
-
* for crisp output on high-DPI displays.
|
|
306
|
+
* Inputs to `LiveSession.paint`. Both default to `1`, must be finite and `> 0`,
|
|
307
|
+
* and multiply to the effective rasterization scale.
|
|
348
308
|
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
* `
|
|
309
|
+
* - `layoutScale`: layout-space pixels per point — CSS pixels per pt for an
|
|
310
|
+
* on-screen canvas — surfaced back as `layoutWidth` / `layoutHeight`.
|
|
311
|
+
* - `densityScale`: backing-store density. Fold `window.devicePixelRatio`,
|
|
312
|
+
* in-app zoom, and `visualViewport.scale` into this one value; the default
|
|
313
|
+
* `1` produces a non-retina backing store.
|
|
353
314
|
*/
|
|
354
315
|
export interface PaintOptions {
|
|
355
316
|
layoutScale?: number;
|
|
@@ -359,36 +320,21 @@ export interface PaintOptions {
|
|
|
359
320
|
/**
|
|
360
321
|
* Returned by `LiveSession.paint`.
|
|
361
322
|
*
|
|
362
|
-
* - `layoutWidth` / `layoutHeight`:
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
* `canvas.
|
|
366
|
-
*
|
|
367
|
-
* - `
|
|
368
|
-
*
|
|
369
|
-
*
|
|
370
|
-
* `round(layoutHeight * densityScale)` *unless* the requested backing
|
|
371
|
-
* exceeded the painter's safe maximum (16384 px per side), in which
|
|
372
|
-
* case `densityScale` was clamped to fit.
|
|
373
|
-
* - `clamped`: `true` when that 16384-px clamp fired, so the page is
|
|
374
|
-
* painted at fewer device pixels than requested and renders soft at the
|
|
375
|
-
* same `canvas.style` size. Reads the clamp off the return value instead
|
|
376
|
-
* of the `pixelWidth < round(layoutWidth * densityScale)` derivation.
|
|
377
|
-
* - `effectiveDensityScale`, the `densityScale` actually applied: the
|
|
378
|
-
* requested value unless `clamped`, then reduced proportionally.
|
|
379
|
-
* `layoutScale * effectiveDensityScale` is the scale the backing store
|
|
380
|
-
* was rasterized at.
|
|
323
|
+
* - `layoutWidth` / `layoutHeight`: the display box, in CSS pixels for an
|
|
324
|
+
* on-screen canvas, to drive `canvas.style.*`. Independent of `densityScale`.
|
|
325
|
+
* - `pixelWidth` / `pixelHeight`: the backing store the painter wrote to
|
|
326
|
+
* `canvas.width` / `canvas.height`, `round(layout * densityScale)` unless the
|
|
327
|
+
* request exceeded 16384 px per side and `densityScale` was clamped to fit.
|
|
328
|
+
* - `clamped`: `true` when that clamp fired, so the page renders soft at the
|
|
329
|
+
* same `canvas.style` size.
|
|
330
|
+
* - `effectiveDensityScale`: the `densityScale` actually applied.
|
|
381
331
|
*
|
|
382
|
-
* The painter owns `canvas.width` / `canvas.height
|
|
383
|
-
*
|
|
384
|
-
*
|
|
385
|
-
*
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
* For `OffscreenCanvasRenderingContext2D` (Worker rasterization, no
|
|
390
|
-
* DOM), `layoutWidth` / `layoutHeight` are informational: there's no
|
|
391
|
-
* CSS layout box to apply them to.
|
|
332
|
+
* The painter owns `canvas.width` / `canvas.height` and never touches
|
|
333
|
+
* `canvas.style.*`. The write is a whole-backing-store `putImageData`, which
|
|
334
|
+
* bypasses the 2D context transform, `globalAlpha`, and clip: give each visible
|
|
335
|
+
* page its own `<canvas>`, since no compositing, sub-rect, or transform reaches
|
|
336
|
+
* through `paint`. Under `OffscreenCanvasRenderingContext2D` the layout
|
|
337
|
+
* dimensions are informational — there is no CSS box to apply them to.
|
|
392
338
|
*/
|
|
393
339
|
export interface PaintResult {
|
|
394
340
|
layoutWidth: number;
|
|
@@ -402,14 +348,12 @@ export interface PaintResult {
|
|
|
402
348
|
|
|
403
349
|
|
|
404
350
|
/** The commitment-ladder rung that produced a `ResolvedField.value`. */
|
|
405
|
-
export type FieldSource = "authored" | "default" | "
|
|
351
|
+
export type FieldSource = "authored" | "default" | "blank";
|
|
406
352
|
|
|
407
353
|
/**
|
|
408
354
|
* One resolved row: its `name`, the value the render projection would use, and
|
|
409
|
-
* the `FieldSource` rung it came from. Rows are an ordered array
|
|
410
|
-
* order is structural
|
|
411
|
-
* on its card, never a row in `fields`. Diagnostics stay `Quill.validate`'s;
|
|
412
|
-
* schema guidance (`example:`, labels) reads from `Quill.schema`.
|
|
355
|
+
* the `FieldSource` rung it came from. Rows are an ordered array, so declaration
|
|
356
|
+
* order is structural rather than object-key order.
|
|
413
357
|
*/
|
|
414
358
|
export interface ResolvedField {
|
|
415
359
|
name: string;
|
|
@@ -439,9 +383,8 @@ export interface ResolvedCard {
|
|
|
439
383
|
}
|
|
440
384
|
|
|
441
385
|
/**
|
|
442
|
-
* The resolved-value view (`Quill.resolve`): the main card and every
|
|
443
|
-
*
|
|
444
|
-
* `Quill.validate`.
|
|
386
|
+
* The resolved-value view (`Quill.resolve`): the main card and every composable
|
|
387
|
+
* card. Value and provenance only; completeness stays `Quill.validate`'s.
|
|
445
388
|
*/
|
|
446
389
|
export interface Resolved {
|
|
447
390
|
main: ResolvedMain;
|
|
@@ -450,20 +393,21 @@ export interface Resolved {
|
|
|
450
393
|
|
|
451
394
|
|
|
452
395
|
|
|
453
|
-
/** UI layout hints for a single field.
|
|
454
|
-
*
|
|
455
|
-
* order, the ordering contract. */
|
|
396
|
+
/** UI layout hints for a single field. Display order is not a hint: key order
|
|
397
|
+
* in the schema's `fields`/`properties` objects is the ordering contract. */
|
|
456
398
|
export interface QuillFieldUi {
|
|
457
399
|
title?: string;
|
|
458
400
|
group?: string;
|
|
459
401
|
compact?: boolean;
|
|
460
402
|
multiline?: boolean;
|
|
403
|
+
/** Label for an `enum`'s blank option. Absent, the consumer supplies a
|
|
404
|
+
* conventional label of its own. */
|
|
405
|
+
blank_title?: string;
|
|
461
406
|
}
|
|
462
407
|
|
|
463
408
|
/** One entry in a card's `ui.groups` registry: a display-label override for the
|
|
464
|
-
* group id (the map key). An empty object carries no override
|
|
465
|
-
* derives the label from the id (`memo_for` → "Memo For")
|
|
466
|
-
* label from its key. */
|
|
409
|
+
* group id (the map key). An empty object carries no override, and the consumer
|
|
410
|
+
* derives the label from the id (`memo_for` → "Memo For"). */
|
|
467
411
|
export interface QuillGroupUi {
|
|
468
412
|
title?: string;
|
|
469
413
|
}
|
|
@@ -471,48 +415,61 @@ export interface QuillGroupUi {
|
|
|
471
415
|
/** UI layout hints for a card (main or named card kind). */
|
|
472
416
|
export interface QuillCardUi {
|
|
473
417
|
title?: string;
|
|
474
|
-
/** The
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
* `fields` key order carries. Absent when the card declares no groups (or
|
|
478
|
-
* uses the deprecated implicit-group form). */
|
|
418
|
+
/** The groups a field's `ui.group` may reference, keyed by group id. Key
|
|
419
|
+
* order is the display-order contract, as with `fields`. Absent when the
|
|
420
|
+
* card declares no groups. */
|
|
479
421
|
groups?: Record<string, QuillGroupUi>;
|
|
480
422
|
}
|
|
481
423
|
|
|
424
|
+
/** A block construct a body can hold. `paragraph` is the floor and cannot be
|
|
425
|
+
* declined, so it is absent. */
|
|
426
|
+
export type QuillBlockConstruct =
|
|
427
|
+
| "heading"
|
|
428
|
+
| "rule"
|
|
429
|
+
| "code"
|
|
430
|
+
| "list"
|
|
431
|
+
| "quote"
|
|
432
|
+
| "table"
|
|
433
|
+
| "image";
|
|
434
|
+
|
|
482
435
|
/** Body namespace for a card (main or named card kind). */
|
|
483
436
|
export interface QuillCardBody {
|
|
484
437
|
/** When false, consumers must not accept or store body content for this card kind. Defaults to true. */
|
|
485
438
|
enabled?: boolean;
|
|
486
439
|
/** Example body content embedded verbatim in the blueprint body region. Fallback is "Write <card> body here." */
|
|
487
440
|
example?: string;
|
|
441
|
+
/** Block constructs this quill's plate does not typeset in this body;
|
|
442
|
+
* absent or empty declines nothing. A body that holds one anyway draws a
|
|
443
|
+
* non-fatal `plate::unsupported_construct` warning. Nothing verifies the
|
|
444
|
+
* claim: absence from this list is not a promise the plate typesets it. */
|
|
445
|
+
unsupported?: QuillBlockConstruct[];
|
|
488
446
|
}
|
|
489
447
|
|
|
490
448
|
/** Schema entry for a single field declared in a quill's `Quill.yaml`.
|
|
491
449
|
*
|
|
492
|
-
*
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
* `!must_fill` marker
|
|
496
|
-
* `validation::must_fill`
|
|
497
|
-
*
|
|
450
|
+
* Two independent axes, and no separate `required` one. `default` and
|
|
451
|
+
* `example` say what the cell holds; `must_fill` says whether a human must
|
|
452
|
+
* author it, deriving from `default`'s absence when left unset. An obliged
|
|
453
|
+
* field carries a `!must_fill` marker in the blueprint and warns
|
|
454
|
+
* `validation::must_fill` while the document leaves it unauthored. Neither
|
|
455
|
+
* axis gates render: an absent field blank-fills.
|
|
498
456
|
*/
|
|
499
457
|
export interface QuillFieldSchema {
|
|
500
458
|
type: "string" | "number" | "integer" | "boolean" | "array" | "object" | "date" | "datetime" | "richtext" | "plaintext" | "enum";
|
|
501
459
|
description?: string;
|
|
502
460
|
default?: unknown;
|
|
503
461
|
example?: unknown;
|
|
504
|
-
/**
|
|
505
|
-
*
|
|
506
|
-
* release. Both round-trip through this field. */
|
|
507
|
-
enum?: string[];
|
|
508
|
-
/** Required on `type: "enum"`: the closed set of allowed string values. */
|
|
462
|
+
/** The closed set of allowed values. Required on `type: "enum"`, and valid
|
|
463
|
+
* nowhere else. */
|
|
509
464
|
values?: string[];
|
|
465
|
+
/** Whether a human must author the field. Absent, it derives from
|
|
466
|
+
* `default`: a defaulted field is unobliged, a defaultless one obliged. */
|
|
467
|
+
must_fill?: boolean;
|
|
510
468
|
ui?: QuillFieldUi;
|
|
511
469
|
properties?: Record<string, QuillFieldSchema>;
|
|
512
470
|
items?: QuillFieldSchema;
|
|
513
|
-
/**
|
|
514
|
-
*
|
|
515
|
-
* Core serializes `inline: true` into the schema JSON; absent otherwise. */
|
|
471
|
+
/** `true` on a `richtext` or `plaintext` field declared `inline`: the
|
|
472
|
+
* single-paragraph, container-free, island-free constraint. */
|
|
516
473
|
inline?: boolean;
|
|
517
474
|
}
|
|
518
475
|
|
|
@@ -525,10 +482,8 @@ export interface QuillCardSchema {
|
|
|
525
482
|
}
|
|
526
483
|
|
|
527
484
|
/**
|
|
528
|
-
* Document schema returned by `Quill.schema
|
|
529
|
-
*
|
|
530
|
-
* Describes only the user-fillable fields. The quill reference
|
|
531
|
-
* (constructed as `${metadata.name}@${metadata.version}`) and card-kind
|
|
485
|
+
* Document schema returned by `Quill.schema`: the user-fillable fields only.
|
|
486
|
+
* The quill reference (`${metadata.name}@${metadata.version}`) and card-kind
|
|
532
487
|
* discriminators are document-level metadata, not schema fields.
|
|
533
488
|
*/
|
|
534
489
|
export interface QuillSchema {
|
|
@@ -538,10 +493,9 @@ export interface QuillSchema {
|
|
|
538
493
|
}
|
|
539
494
|
|
|
540
495
|
/**
|
|
541
|
-
* Identity snapshot mirroring the `quill:` section of `Quill.yaml`.
|
|
542
|
-
*
|
|
543
|
-
*
|
|
544
|
-
* not part of this pure-config snapshot.
|
|
496
|
+
* Identity snapshot mirroring the `quill:` section of `Quill.yaml`. The schema
|
|
497
|
+
* lives on `Quill.schema`; output formats are a resolved-backend capability read
|
|
498
|
+
* from `Quillmark.supportedFormats`, not part of this config snapshot.
|
|
545
499
|
*/
|
|
546
500
|
export interface QuillMetadata {
|
|
547
501
|
name: string;
|
|
@@ -553,74 +507,56 @@ export interface QuillMetadata {
|
|
|
553
507
|
|
|
554
508
|
|
|
555
509
|
/**
|
|
556
|
-
* A
|
|
557
|
-
*
|
|
558
|
-
*
|
|
559
|
-
* references) and form-field widgets (pdfform AcroForm, Typst `form-field`).
|
|
560
|
-
* Consumers use it to scroll to / highlight the focused field; for the
|
|
561
|
-
* reverse click direction use `LiveSession.fieldAt`, which answers over any
|
|
562
|
-
* placement. Geometry only: the raster is already complete, so a region is
|
|
563
|
-
* never a compositing input.
|
|
564
|
-
*
|
|
565
|
-
* `field` is **not** unique: content fields surface one region **per segment**
|
|
566
|
-
* (paragraph, heading, whole code fence) and per page each touches, a scalar
|
|
567
|
-
* referenced at several plate sites surfaces each site, and tracked content
|
|
568
|
-
* plus a `field:`-bound widget yields both. Group by `field`: every entry
|
|
569
|
-
* routes to that field. The whole-field highlight is the **union of a page\'s
|
|
570
|
-
* `span`-bearing segment rects**, so inter-paragraph whitespace stays
|
|
571
|
-
* uncovered; `LiveSession.fieldBoxes(field)` owns that union so
|
|
572
|
-
* consumers need not derive it. Later placements of one content value are not
|
|
573
|
-
* enumerated; `fieldAt` / `positionAt` still resolve clicks on them.
|
|
510
|
+
* A resolved point → content position: the field a click landed in and the USV
|
|
511
|
+
* offset into its `Content`. The `LiveSession.positionAt` result, inverse of
|
|
512
|
+
* `locate`.
|
|
574
513
|
*/
|
|
575
|
-
export interface
|
|
514
|
+
export interface ContentHit {
|
|
576
515
|
/**
|
|
577
|
-
* Canonical `DocPath` field address (
|
|
578
|
-
* `\"cards.indorsement[1].from\"`, `\"main.body\"`): the same grammar
|
|
579
|
-
* `parseDocPath` reads and `Diagnostic.path` carries. The session resolves
|
|
580
|
-
* the backend\'s plate-space per-kind ordinal to this absolute-index form,
|
|
581
|
-
* so one parser routes every address. Feed it back to `fieldBoxes` /
|
|
582
|
-
* `locate`; hit-test the click direction with `fieldAt` / `positionAt`.
|
|
516
|
+
* Canonical `DocPath` field address (same grammar as `FieldRegion.field`).
|
|
583
517
|
*/
|
|
584
518
|
field: string;
|
|
585
519
|
/**
|
|
586
|
-
*
|
|
587
|
-
*/
|
|
588
|
-
page: number;
|
|
589
|
-
/**
|
|
590
|
-
* `[x0, y0, x1, y1]` in PDF points (1/72″), bottom-left origin.
|
|
520
|
+
* USV offset into the field\'s `Content`.
|
|
591
521
|
*/
|
|
592
|
-
|
|
522
|
+
pos: number;
|
|
593
523
|
/**
|
|
594
|
-
*
|
|
595
|
-
* `Content` for content ink (one segment), `undefined` for a scalar
|
|
596
|
-
* reference site or widget. Consumers key segment highlights on it;
|
|
597
|
-
* `fieldBoxes(field)` unions same-page segments for the whole-field box.
|
|
524
|
+
* `undefined` when the backend does not report granularity.
|
|
598
525
|
*/
|
|
599
|
-
|
|
526
|
+
granularity?: HitGranularity;
|
|
600
527
|
}
|
|
601
528
|
|
|
602
529
|
/**
|
|
603
|
-
* A
|
|
604
|
-
*
|
|
605
|
-
*
|
|
606
|
-
*
|
|
607
|
-
*
|
|
530
|
+
* A schema field address plus its geometry on the page, for scrolling to or
|
|
531
|
+
* highlighting a field; use `LiveSession.fieldAt` for the click direction.
|
|
532
|
+
*
|
|
533
|
+
* `field` is **not** unique: content fields surface one region per segment
|
|
534
|
+
* (paragraph, heading, whole code fence) and per page each touches, a scalar
|
|
535
|
+
* referenced at several plate sites surfaces each site, and tracked content
|
|
536
|
+
* plus a `field:`-bound widget yields both. Group by `field`. The whole-field
|
|
537
|
+
* highlight is the union of a page\'s `span`-bearing rects, so inter-paragraph
|
|
538
|
+
* whitespace stays uncovered; `LiveSession.fieldBoxes(field)` owns that union.
|
|
608
539
|
*/
|
|
609
|
-
export interface
|
|
540
|
+
export interface FieldRegion {
|
|
610
541
|
/**
|
|
611
|
-
* Canonical `DocPath` field address (
|
|
542
|
+
* Canonical `DocPath` field address (e.g. `\"cards.indorsement[1].from\"`):
|
|
543
|
+
* the grammar `parseDocPath` reads and `Diagnostic.path` carries. Feed it
|
|
544
|
+
* back to `fieldBoxes` / `locate`.
|
|
612
545
|
*/
|
|
613
546
|
field: string;
|
|
614
547
|
/**
|
|
615
|
-
*
|
|
548
|
+
* 0-based page index.
|
|
616
549
|
*/
|
|
617
|
-
|
|
550
|
+
page: number;
|
|
618
551
|
/**
|
|
619
|
-
*
|
|
620
|
-
* (`HitGranularity`). `undefined` when the backend does not report it.
|
|
621
|
-
* Additive-optional.
|
|
552
|
+
* `[x0, y0, x1, y1]` in PDF points (1/72″), bottom-left origin.
|
|
622
553
|
*/
|
|
623
|
-
|
|
554
|
+
rect: [number, number, number, number];
|
|
555
|
+
/**
|
|
556
|
+
* The slice this box covers: USV `[start, end)` into the field\'s `Content`
|
|
557
|
+
* for one content segment, `undefined` for a scalar site or widget.
|
|
558
|
+
*/
|
|
559
|
+
span?: [number, number];
|
|
624
560
|
}
|
|
625
561
|
|
|
626
562
|
/**
|
|
@@ -632,31 +568,25 @@ export interface Diagnostic {
|
|
|
632
568
|
message: string;
|
|
633
569
|
location?: Location;
|
|
634
570
|
/**
|
|
635
|
-
* Document-model path anchor (e.g. `\"cards.indorsement[0].signature_block\"`)
|
|
636
|
-
*
|
|
637
|
-
* Set on schema validation diagnostics; `undefined` otherwise. See the
|
|
638
|
-
* Rust `quillmark_core::error` module docs for the path grammar.
|
|
571
|
+
* Document-model path anchor (e.g. `\"cards.indorsement[0].signature_block\"`),
|
|
572
|
+
* set on schema validation diagnostics and `undefined` otherwise.
|
|
639
573
|
*/
|
|
640
574
|
path?: string;
|
|
641
575
|
hint?: string;
|
|
642
576
|
/**
|
|
643
|
-
* The facts `message` interpolates, keyed by name. With `code`,
|
|
644
|
-
*
|
|
645
|
-
* `prose/canon/ERROR.md` § \"Diagnostic args\" tabulates the keys per code.
|
|
577
|
+
* The facts `message` interpolates, keyed by name. With `code`, enough to
|
|
578
|
+
* word this diagnostic in another language.
|
|
646
579
|
*
|
|
647
|
-
* Declared optional explicitly
|
|
648
|
-
* `skip_serializing_if
|
|
649
|
-
* declared required. `sourceChain` carries that mismatch.
|
|
580
|
+
* Declared optional explicitly: `tsify` does not read
|
|
581
|
+
* `skip_serializing_if`, so an omitted field would be declared required.
|
|
650
582
|
*/
|
|
651
583
|
args?: Record<string, unknown>;
|
|
652
584
|
sourceChain?: string[];
|
|
653
585
|
}
|
|
654
586
|
|
|
655
587
|
/**
|
|
656
|
-
* How precisely a `ContentHit.pos` resolved
|
|
657
|
-
*
|
|
658
|
-
* finest this API offers, `segment` the floor it degrades to on origin-less
|
|
659
|
-
* ink.
|
|
588
|
+
* How precisely a `ContentHit.pos` resolved. Never sub-cluster: `cluster` is
|
|
589
|
+
* the finest this API offers, `segment` the floor it degrades to.
|
|
660
590
|
*/
|
|
661
591
|
export type HitGranularity = "cluster" | "segment";
|
|
662
592
|
|
|
@@ -666,43 +596,30 @@ export type HitGranularity = "cluster" | "segment";
|
|
|
666
596
|
export interface RenderOptions {
|
|
667
597
|
format?: OutputFormat;
|
|
668
598
|
/**
|
|
669
|
-
* Pixels per inch for
|
|
670
|
-
* Ignored for vector/document formats (PDF, SVG).
|
|
671
|
-
* Defaults to 144.0 (2x at 72pt/inch) when omitted.
|
|
599
|
+
* Pixels per inch for PNG; ignored for PDF and SVG. Defaults to 144.0.
|
|
672
600
|
*/
|
|
673
601
|
ppi?: number;
|
|
674
602
|
/**
|
|
675
|
-
*
|
|
676
|
-
*
|
|
677
|
-
*
|
|
678
|
-
* code: read `LiveSession.pageCount` first if validation is needed.
|
|
679
|
-
* **Not supported for PDF output**: passing `pages` with
|
|
680
|
-
* `format: \"pdf\"` throws with the
|
|
681
|
-
* `typst::pdf_page_selection_not_supported` code.
|
|
603
|
+
* 0-based page indices to render; `undefined` renders all pages. An index
|
|
604
|
+
* `>= pageCount` throws `typst::page_index_out_of_bounds`. Not supported
|
|
605
|
+
* for PDF output: throws `typst::pdf_page_selection_not_supported`.
|
|
682
606
|
*/
|
|
683
607
|
pages?: number[];
|
|
684
608
|
/**
|
|
685
|
-
*
|
|
686
|
-
* the default (`Quillmark <version>`). Applies to PDF output only.
|
|
609
|
+
* PDF `/Info` `/Producer` override; defaults to `Quillmark <version>`.
|
|
687
610
|
*/
|
|
688
611
|
producer?: string;
|
|
689
612
|
/**
|
|
690
|
-
* Populate `RenderResult.regions` with
|
|
691
|
-
*
|
|
692
|
-
*
|
|
693
|
-
* Defaults to `false`: exports pay no introspection cost. The sidecar
|
|
694
|
-
* always describes the whole document: page indices are document-space
|
|
695
|
-
* even when `pages` selects a subset.
|
|
613
|
+
* Populate `RenderResult.regions` with schema-field geometry, for consumers
|
|
614
|
+
* without a live session. Defaults to `false`. Page indices are
|
|
615
|
+
* document-space even when `pages` selects a subset.
|
|
696
616
|
*/
|
|
697
617
|
regions?: boolean;
|
|
698
618
|
}
|
|
699
619
|
|
|
700
620
|
/**
|
|
701
|
-
* Output formats supported by backends.
|
|
702
|
-
*
|
|
703
|
-
* Gated behind the engine surface (`typst` or `pdfform`) so tsify omits
|
|
704
|
-
* its `.d.ts` interface from the core bundle (`pkg/core/wasm.d.ts`), which
|
|
705
|
-
* has no rendering surface.
|
|
621
|
+
* Output formats supported by backends. Gated behind the engine surface so
|
|
622
|
+
* tsify omits it from the core bundle, which has no rendering surface.
|
|
706
623
|
*/
|
|
707
624
|
export type OutputFormat = "pdf" | "svg" | "png";
|
|
708
625
|
|
|
@@ -712,9 +629,7 @@ export type OutputFormat = "pdf" | "svg" | "png";
|
|
|
712
629
|
export interface Artifact {
|
|
713
630
|
format: OutputFormat;
|
|
714
631
|
/**
|
|
715
|
-
*
|
|
716
|
-
* `Uint8Array` at the boundary instead of a `number[]`. Without this
|
|
717
|
-
* annotation, the declared `Uint8Array` type would silently lie.
|
|
632
|
+
* `serde_bytes` so the boundary emits a real `Uint8Array`, not `number[]`.
|
|
718
633
|
*/
|
|
719
634
|
bytes: Uint8Array;
|
|
720
635
|
mimeType: string;
|
|
@@ -729,19 +644,12 @@ export interface RenderResult {
|
|
|
729
644
|
outputFormat: OutputFormat;
|
|
730
645
|
renderTimeMs: number;
|
|
731
646
|
/**
|
|
732
|
-
* Schema-field geometry
|
|
733
|
-
*
|
|
734
|
-
* `LiveSession.regions()` serves, for consumers without a live session.
|
|
735
|
-
* Page indices are document-space even under a `pages` subset render.
|
|
647
|
+
* Schema-field geometry, populated only when `RenderOptions.regions` asked
|
|
648
|
+
* for it. Page indices are document-space even under a `pages` subset.
|
|
736
649
|
*/
|
|
737
650
|
regions: FieldRegion[];
|
|
738
651
|
}
|
|
739
652
|
|
|
740
|
-
/**
|
|
741
|
-
* Severity levels for diagnostics
|
|
742
|
-
*/
|
|
743
|
-
export type Severity = "error" | "warning";
|
|
744
|
-
|
|
745
653
|
/**
|
|
746
654
|
* Source location for errors and warnings
|
|
747
655
|
*/
|
|
@@ -752,16 +660,17 @@ export interface Location {
|
|
|
752
660
|
}
|
|
753
661
|
|
|
754
662
|
/**
|
|
755
|
-
* What a committed `LiveSession.
|
|
756
|
-
*
|
|
757
|
-
*
|
|
758
|
-
* repaints `dirty ∩ visible` and nothing else.
|
|
663
|
+
* What a committed `LiveSession.update` changed. `dirtyPages` lists pages whose
|
|
664
|
+
* content differs from the previous compile, including pages the edit added;
|
|
665
|
+
* removed pages are implied by `pageCount`.
|
|
759
666
|
*/
|
|
760
667
|
export interface ChangeSet {
|
|
761
668
|
pageCount: number;
|
|
762
669
|
dirtyPages: number[];
|
|
763
670
|
}
|
|
764
671
|
|
|
672
|
+
export type Severity = "error" | "warning";
|
|
673
|
+
|
|
765
674
|
|
|
766
675
|
/**
|
|
767
676
|
* Typed in-memory Quillmark document.
|
|
@@ -770,79 +679,69 @@ export class Document {
|
|
|
770
679
|
free(): void;
|
|
771
680
|
[Symbol.dispose](): void;
|
|
772
681
|
/**
|
|
773
|
-
* **Apply** a committed content edit `bundle`
|
|
774
|
-
*
|
|
775
|
-
*
|
|
776
|
-
*
|
|
777
|
-
*
|
|
778
|
-
*
|
|
779
|
-
* The island channel keeps a table or image edit on the op path: it moves
|
|
780
|
-
* the island alone, so the anchors elsewhere in the field survive an edit
|
|
682
|
+
* **Apply** a committed content edit `bundle` at `addr`, the editor splice:
|
|
683
|
+
* text delta first, then island ops, then line ops, then mark ops (mark
|
|
684
|
+
* ranges in final-text coordinates), all-or-nothing. An absent `addr.field`
|
|
685
|
+
* targets the body, an absent `addr.card` the main card. The island channel
|
|
686
|
+
* moves an island alone, so anchors elsewhere in the field survive an edit
|
|
781
687
|
* `overwrite` would clear.
|
|
782
688
|
*
|
|
783
689
|
* Throws on an out-of-range card, a field that is not richtext, a malformed
|
|
784
|
-
* bundle, or an op that applies out of bounds
|
|
785
|
-
* failed apply
|
|
690
|
+
* bundle, or an op that applies out of bounds; the value is unchanged on a
|
|
691
|
+
* failed apply.
|
|
786
692
|
*/
|
|
787
693
|
applyChange(addr: Addr | string, bundle: ChangeBundle): void;
|
|
788
694
|
/**
|
|
789
|
-
* Authoring-ergonomics header introducing a blueprint to an LLM/MCP
|
|
790
|
-
*
|
|
791
|
-
* JS consumers; any surface that draws from the same core source stays
|
|
792
|
-
* uniform.
|
|
695
|
+
* Authoring-ergonomics header introducing a blueprint to an LLM/MCP consumer
|
|
696
|
+
* for the given `quillName`, re-exposed from core.
|
|
793
697
|
*/
|
|
794
698
|
static blueprintInstruction(quill_name: string): string;
|
|
795
699
|
/**
|
|
796
|
-
* The **body** markdown projection
|
|
797
|
-
*
|
|
798
|
-
*
|
|
799
|
-
* this read stays quill-free; a body is never absent.
|
|
700
|
+
* The **body** markdown projection: an on-demand, lossy export (content-only
|
|
701
|
+
* marks do not survive markdown). A body's type is a format fact, not a
|
|
702
|
+
* schema fact, so this read stays quill-free, and a body is never absent.
|
|
800
703
|
*
|
|
801
|
-
* `addr` is an optional
|
|
802
|
-
*
|
|
803
|
-
*
|
|
804
|
-
* type. An out-of-range `addr.card` throws.
|
|
704
|
+
* `addr` is an optional card address (absent = main). A present `field`
|
|
705
|
+
* throws: read a field's markdown through `quill.reader(doc).get(field)`,
|
|
706
|
+
* which interprets by declared type. An out-of-range `addr.card` throws.
|
|
805
707
|
*/
|
|
806
708
|
bodyMarkdown(addr?: CardAddr): string;
|
|
807
709
|
/**
|
|
808
|
-
* A single composable card by index
|
|
809
|
-
*
|
|
810
|
-
*
|
|
811
|
-
* `index` throws `edit::index_out_of_range`, matching the card write
|
|
812
|
-
* verbs.
|
|
710
|
+
* A single composable card by index, so reading one need not materialize
|
|
711
|
+
* every card via [`cards`](Self::cards). An out-of-range `index` throws
|
|
712
|
+
* `edit::index_out_of_range`.
|
|
813
713
|
*/
|
|
814
714
|
card(index: number): Card;
|
|
715
|
+
/**
|
|
716
|
+
* The composable card's own path, `cards.<kind>[index]`: the root
|
|
717
|
+
* [`pathFor`](Self::path_for) extends, for anchoring the card rather than
|
|
718
|
+
* one of its fields. Total on the index axis; out of range renders
|
|
719
|
+
* `cards[index]`.
|
|
720
|
+
*/
|
|
721
|
+
cardPath(index: number): string;
|
|
815
722
|
clone(): Document;
|
|
816
723
|
/**
|
|
817
|
-
* Storage version this build writes via [`toJson`](Document::to_json).
|
|
818
|
-
*
|
|
819
|
-
* the tag advances only when the wire format changes, not on every release.
|
|
724
|
+
* Storage version this build writes via [`toJson`](Document::to_json). The
|
|
725
|
+
* tag advances only when the wire format changes, not on every release.
|
|
820
726
|
*/
|
|
821
727
|
static currentStorageVersion(): string;
|
|
822
728
|
/**
|
|
823
|
-
* Structural equality
|
|
824
|
-
* upstream prop updates instead of re-parsing on every keystroke.
|
|
729
|
+
* Structural equality, excluding parse-time `warnings`.
|
|
825
730
|
*/
|
|
826
731
|
equals(other: Document): boolean;
|
|
827
732
|
/**
|
|
828
|
-
* Render a Diagnostic as the canonical pretty-printed text
|
|
829
|
-
*
|
|
830
|
-
* identical no matter which consumer surfaces it.
|
|
733
|
+
* Render a Diagnostic as the canonical pretty-printed text, so it looks
|
|
734
|
+
* identical whichever consumer surfaces it.
|
|
831
735
|
*/
|
|
832
736
|
static formatDiagnostic(diag: Diagnostic): string;
|
|
833
737
|
/**
|
|
834
|
-
* Authoring-format rules for the card-yaml markdown surface
|
|
835
|
-
*
|
|
836
|
-
* here for JS consumers so it matches any other surface that draws from the
|
|
837
|
-
* same source. Read once at startup and cache; the value never changes
|
|
838
|
-
* between calls.
|
|
738
|
+
* Authoring-format rules for the card-yaml markdown surface, re-exposed from
|
|
739
|
+
* core. Constant across calls; read once and cache.
|
|
839
740
|
*/
|
|
840
741
|
static formatRules(): string;
|
|
841
742
|
/**
|
|
842
|
-
* Reconstruct a `Document` from a versioned storage DTO string produced
|
|
843
|
-
*
|
|
844
|
-
* The result carries no parse-time warnings (`.warnings` is always empty).
|
|
845
|
-
*
|
|
743
|
+
* Reconstruct a `Document` from a versioned storage DTO string produced by
|
|
744
|
+
* [`toJson`](Document::to_json). The result carries no parse-time warnings.
|
|
846
745
|
* Throws if `json` is not a valid storage DTO (malformed JSON, unknown
|
|
847
746
|
* `schema`, missing fields, or unparseable quill reference).
|
|
848
747
|
*/
|
|
@@ -853,81 +752,66 @@ export class Document {
|
|
|
853
752
|
static fromMarkdown(markdown: string): Document;
|
|
854
753
|
/**
|
|
855
754
|
* The whole `$ext` map at `addr` (a card address, absent `card` = main), or
|
|
856
|
-
* `undefined` when the card carries none
|
|
857
|
-
*
|
|
858
|
-
*
|
|
755
|
+
* `undefined` when the card carries none: the `$ext` read that avoids
|
|
756
|
+
* serializing the whole card. Throws on a present `field` or an
|
|
757
|
+
* out-of-range card.
|
|
859
758
|
*/
|
|
860
759
|
getExt(addr?: CardAddr): Record<string, unknown> | undefined;
|
|
861
760
|
/**
|
|
862
761
|
* The value stored under `$ext[ns]` at `addr` (a card address, absent `card`
|
|
863
|
-
* = main), or `undefined`.
|
|
864
|
-
*
|
|
865
|
-
* `removeExtNamespace`). Throws on a present `field` or an out-of-range card.
|
|
762
|
+
* = main), or `undefined`. Throws on a present `field` or an out-of-range
|
|
763
|
+
* card.
|
|
866
764
|
*/
|
|
867
765
|
getExtNamespace(addr: CardAddr, ns: string): unknown;
|
|
868
766
|
/**
|
|
869
|
-
* Read the **verbatim stored value** at `addr`:
|
|
870
|
-
*
|
|
871
|
-
*
|
|
872
|
-
*
|
|
873
|
-
*
|
|
874
|
-
*
|
|
875
|
-
*
|
|
876
|
-
* markdown projection use [`bodyMarkdown`](Self::get_markdown) (body) or
|
|
877
|
-
* `reader.get` (a field's declared type).
|
|
767
|
+
* Read the **verbatim stored value** at `addr`: a field's raw payload value,
|
|
768
|
+
* or the body content when `addr.field` is absent. A bare string is `Addr`
|
|
769
|
+
* shorthand for `{ field }`. Needs no schema: the read echo of the verbatim
|
|
770
|
+
* `store*` write, distinct from the interpreted
|
|
771
|
+
* [`reader.get`](Self::reader_get). Reads are total over the field axis — an
|
|
772
|
+
* absent field is `undefined` — and only an out-of-range `addr.card` throws
|
|
773
|
+
* `edit::index_out_of_range`.
|
|
878
774
|
*
|
|
879
|
-
*
|
|
880
|
-
*
|
|
881
|
-
* string. A document
|
|
882
|
-
*
|
|
883
|
-
*
|
|
884
|
-
*
|
|
885
|
-
* it is conformed, and this read reports what is there. For the `Content`
|
|
886
|
-
* either way, use the schema-plane `reader.getContent`, which decodes
|
|
887
|
-
* through the codec the field's declared type names.
|
|
775
|
+
* A content field at rest has one stored form per codec: a `richtext` field
|
|
776
|
+
* holds the canonical content object, a `plaintext` field its literal
|
|
777
|
+
* string. A document from the bound door (`quill.parse` / `quill.conform`)
|
|
778
|
+
* is at rest; one from the transport door may rest as authored until it is
|
|
779
|
+
* conformed, and this read reports what is there. For the `Content` either
|
|
780
|
+
* way use `reader.getContent`.
|
|
888
781
|
*/
|
|
889
782
|
getStored(addr: Addr | string): unknown;
|
|
890
783
|
/**
|
|
891
|
-
* Insert a card
|
|
892
|
-
*
|
|
893
|
-
*
|
|
894
|
-
*
|
|
895
|
-
* (every returned `Card` is a valid `CardInput`). Throws if `card.kind` is
|
|
896
|
-
* not a valid kind name, or if `at` is out of range.
|
|
784
|
+
* Insert a card: `at` absent appends, a number inserts at that index (in
|
|
785
|
+
* `0..=cards.length`). Accepts any `CardInput`, including a card read back
|
|
786
|
+
* out of a document. Throws if `card.kind` is not a valid kind name, or if
|
|
787
|
+
* `at` is out of range.
|
|
897
788
|
*/
|
|
898
789
|
insertCard(card: CardInput, at?: number): void;
|
|
899
790
|
/**
|
|
900
791
|
* Whether the field at `addr` is marked `!must_fill`. A bare string is `Addr`
|
|
901
|
-
* shorthand for `{ field }`. `false` for an absent field
|
|
902
|
-
*
|
|
903
|
-
* out-of-range `addr.card` throws.
|
|
792
|
+
* shorthand for `{ field }`. `false` for an absent field and for a body
|
|
793
|
+
* address; only an out-of-range `addr.card` throws.
|
|
904
794
|
*/
|
|
905
795
|
isFill(addr: Addr | string): boolean;
|
|
906
796
|
/**
|
|
907
|
-
* Replace this document's contents **in place** from a versioned storage
|
|
908
|
-
*
|
|
909
|
-
*
|
|
910
|
-
*
|
|
797
|
+
* Replace this document's contents **in place** from a versioned storage DTO
|
|
798
|
+
* string: the mutating twin of [`fromJson`](Document::from_json). Parse-time
|
|
799
|
+
* `warnings` are cleared. Throws on an invalid DTO, leaving the document
|
|
800
|
+
* unchanged.
|
|
911
801
|
*
|
|
912
802
|
* The cross-WASM-memory `Document` bridge: mutate a document on a
|
|
913
|
-
* backend-memory clone, then write the
|
|
914
|
-
* canonical document
|
|
915
|
-
* the linear-memory seam without the caller re-binding its variable.
|
|
803
|
+
* backend-memory clone, then write the state back into the caller's
|
|
804
|
+
* canonical document, without the caller re-binding its variable.
|
|
916
805
|
*/
|
|
917
806
|
loadJson(json: string): void;
|
|
918
807
|
/**
|
|
919
808
|
* Build a fresh `Card` from a kind and a flat field map: the ergonomic
|
|
920
|
-
* constructor for `insertCard
|
|
921
|
-
*
|
|
922
|
-
*
|
|
923
|
-
*
|
|
924
|
-
* Sugar, not a required step: `insertCard` takes any `Card` object, and
|
|
925
|
-
* `removeCard` returns one, so a card round-trips without passing through
|
|
926
|
-
* here.
|
|
809
|
+
* constructor for `insertCard`, which also takes any `Card` object
|
|
810
|
+
* directly. Each `fields` entry becomes a card field in insertion order;
|
|
811
|
+
* `body` defaults to `""`.
|
|
927
812
|
*
|
|
928
|
-
* Checks only what a detached card can decide alone: field-name grammar
|
|
929
|
-
*
|
|
930
|
-
* root, reserved for a composable card) so `insertCard` is its gate, and
|
|
813
|
+
* Checks only what a detached card can decide alone: field-name grammar and
|
|
814
|
+
* value depth. Kind validity is positional, so `insertCard` is its gate and
|
|
931
815
|
* any kind string is accepted here.
|
|
932
816
|
*/
|
|
933
817
|
static makeCard(kind: string, fields?: Record<string, unknown>, body?: string): Card;
|
|
@@ -936,43 +820,51 @@ export class Document {
|
|
|
936
820
|
*/
|
|
937
821
|
moveCard(from: number, to: number): void;
|
|
938
822
|
/**
|
|
939
|
-
*
|
|
940
|
-
*
|
|
941
|
-
* blank
|
|
942
|
-
*
|
|
943
|
-
*
|
|
944
|
-
* Throws on an invalid quill reference. Mirrors Python `Document(quill_ref)`.
|
|
823
|
+
* A blank document: a main card carrying only `$quill`, an empty body, and
|
|
824
|
+
* no composable cards. Absent fields resolve at render time (`default`, else
|
|
825
|
+
* the field's blank), so nothing the caller did not set reaches the output.
|
|
826
|
+
* For an example-filled starter use `Quill.seedDocument()`. Throws on an
|
|
827
|
+
* invalid quill reference.
|
|
945
828
|
*/
|
|
946
829
|
constructor(quill_ref: string);
|
|
947
830
|
/**
|
|
948
|
-
* **Overwrite** the content value at `addr`:
|
|
949
|
-
*
|
|
950
|
-
*
|
|
951
|
-
*
|
|
952
|
-
*
|
|
953
|
-
* [`applyChange`](Document::apply_change) preserves. An absent `addr.field`
|
|
954
|
-
* targets the body, an absent `addr.card` the main card. Cold-importing
|
|
955
|
-
* markdown is spelled `overwrite(addr, importMarkdown(md))` at the call
|
|
956
|
-
* site, where the anchor loss is visible.
|
|
831
|
+
* **Overwrite** the content value at `addr` with exactly `rt`: value
|
|
832
|
+
* semantics, so the identity anchors of any previous value are gone. By
|
|
833
|
+
* anchor fate `overwrite` destroys, [`revise`](Document::revise) rebases,
|
|
834
|
+
* and [`applyChange`](Document::apply_change) preserves. An absent
|
|
835
|
+
* `addr.field` targets the body, an absent `addr.card` the main card.
|
|
957
836
|
*
|
|
958
837
|
* Throws on an out-of-range card, a malformed field name, or an `rt` that is
|
|
959
838
|
* not a canonical content object.
|
|
960
839
|
*/
|
|
961
840
|
overwrite(addr: Addr | string, rt: Content): void;
|
|
962
841
|
/**
|
|
963
|
-
*
|
|
964
|
-
*
|
|
965
|
-
*
|
|
966
|
-
*
|
|
967
|
-
*
|
|
842
|
+
* `addr`'s canonical `DocPath` string, the anchor `Diagnostic.path` carries:
|
|
843
|
+
* `pathFor()` is `main.body`, `pathFor("intro")` `main.intro`,
|
|
844
|
+
* `pathFor({card: 2})` `cards.<kind>[2].body`.
|
|
845
|
+
*
|
|
846
|
+
* The kind is the card's stored `$kind` verbatim, not `validate`'s
|
|
847
|
+
* declared-kind filter, since a `Document` holds a `$quill` reference and no
|
|
848
|
+
* schema. That is the one edge where this path and a `validate` diagnostic
|
|
849
|
+
* path differ for the same card.
|
|
850
|
+
*
|
|
851
|
+
* **Total on the index axis**, unlike the `Addr` reads, which throw there:
|
|
852
|
+
* an out-of-range `{card: 7, field: "from"}` renders `cards[7].from`, which
|
|
853
|
+
* parses back and resolves to nothing rather than mis-targeting. Only a
|
|
854
|
+
* malformed address throws.
|
|
855
|
+
*/
|
|
856
|
+
pathFor(addr: Addr | string): string;
|
|
857
|
+
/**
|
|
858
|
+
* The canonical `$quill` reference grammar as author-facing text: the same
|
|
859
|
+
* text the `parse::invalid_quill_reference` hint carries. Drive validation
|
|
860
|
+
* messages from this instead of re-stating the rule.
|
|
968
861
|
*/
|
|
969
862
|
static quillRefHint(): string;
|
|
970
863
|
removeCard(index: number): Card | undefined;
|
|
971
864
|
/**
|
|
972
|
-
* Remove the `$ext` map on the card `addr` targets
|
|
973
|
-
* previous map or `undefined
|
|
974
|
-
*
|
|
975
|
-
* (absent = main). Throws on a present `field` or an out-of-range card.
|
|
865
|
+
* Remove the `$ext` map on the card `addr` targets entirely, returning the
|
|
866
|
+
* previous map or `undefined`. Discards every namespace at once; prefer
|
|
867
|
+
* `removeExtNamespace`. Throws on a present `field` or an out-of-range card.
|
|
976
868
|
*/
|
|
977
869
|
removeExt(addr?: CardAddr): Record<string, unknown> | undefined;
|
|
978
870
|
/**
|
|
@@ -984,35 +876,31 @@ export class Document {
|
|
|
984
876
|
removeExtNamespace(addr: CardAddr, ns: string): any;
|
|
985
877
|
/**
|
|
986
878
|
* Remove a field at `addr`, returning the removed value or `undefined`. A
|
|
987
|
-
* bare string is `Addr` shorthand for `{ field }`.
|
|
988
|
-
*
|
|
989
|
-
* a malformed name.
|
|
879
|
+
* bare string is `Addr` shorthand for `{ field }`. A body address throws, as
|
|
880
|
+
* does an out-of-range card or a malformed name.
|
|
990
881
|
*/
|
|
991
882
|
removeField(addr: Addr | string): any;
|
|
992
883
|
/**
|
|
993
|
-
* Remove `cardKind` from the main card's `$seed` map, returning its
|
|
994
|
-
*
|
|
995
|
-
* survive. `$seed` is main-only, so this takes no address.
|
|
884
|
+
* Remove `cardKind` from the main card's `$seed` map, returning its overlay
|
|
885
|
+
* or `undefined`; drops `$seed` entirely once empty. Sibling kinds survive.
|
|
996
886
|
*/
|
|
997
887
|
removeSeedOverlay(card_kind: string): any;
|
|
998
888
|
/**
|
|
999
|
-
* **Revise** the richtext value at `addr` from a markdown string:
|
|
1000
|
-
*
|
|
1001
|
-
*
|
|
1002
|
-
*
|
|
1003
|
-
*
|
|
1004
|
-
* absent
|
|
889
|
+
* **Revise** the richtext value at `addr` from a markdown string: the
|
|
890
|
+
* default write path. Imports the markdown, diffs it against the current
|
|
891
|
+
* value, rebases surviving identity anchors, and returns the text `Delta` an
|
|
892
|
+
* editor bridge maps its own positions through (`mapPos`). An absent
|
|
893
|
+
* `addr.field` targets the body, an absent `addr.card` the main card; an
|
|
894
|
+
* absent field cold-imports from empty.
|
|
1005
895
|
*
|
|
1006
896
|
* Throws on an out-of-range card, a malformed field name, a present
|
|
1007
897
|
* non-content field value, or an over-nested markdown input.
|
|
1008
898
|
*/
|
|
1009
899
|
revise(addr: Addr | string, markdown: string): Delta;
|
|
1010
900
|
/**
|
|
1011
|
-
* The main card's `$seed` overlay object
|
|
1012
|
-
*
|
|
1013
|
-
* `
|
|
1014
|
-
* via [`main`](Self::main) to fish out one key, and it keeps `seedCard`
|
|
1015
|
-
* pure: the quill still never reads the document.
|
|
901
|
+
* The main card's `$seed[kind]` overlay object, or `undefined`. Feeds
|
|
902
|
+
* `quill.seedCard(kind, overlay)` without serializing the whole main card,
|
|
903
|
+
* and keeps `seedCard` pure: the quill never reads the document.
|
|
1016
904
|
*/
|
|
1017
905
|
seedOverlay(kind: string): Record<string, unknown> | undefined;
|
|
1018
906
|
/**
|
|
@@ -1026,78 +914,60 @@ export class Document {
|
|
|
1026
914
|
*/
|
|
1027
915
|
setQuillRef(ref_str: string): void;
|
|
1028
916
|
/**
|
|
1029
|
-
* Read the storage version tag from a raw storage DTO string without a
|
|
1030
|
-
*
|
|
1031
|
-
*
|
|
1032
|
-
*
|
|
1033
|
-
*
|
|
1034
|
-
* The storage version, not a field schema ([`schema`](Quill::schema) is the
|
|
1035
|
-
* quill's field declarations). The JSON key is spelled `"schema"`: it is
|
|
1036
|
-
* the DTO's serde tag, and retagging it would break the version dispatch
|
|
1037
|
-
* it drives.
|
|
917
|
+
* Read the storage version tag from a raw storage DTO string without a full
|
|
918
|
+
* parse, or `undefined`. Unknown future versions come back as-is, which
|
|
919
|
+
* distinguishes "build too old" from "payload corrupt" when `fromJson`
|
|
920
|
+
* throws. This is the storage version, not a field schema, though the JSON
|
|
921
|
+
* key is spelled `"schema"`: that is the DTO's serde tag.
|
|
1038
922
|
*/
|
|
1039
923
|
static storageVersionOf(json: string): string | undefined;
|
|
1040
924
|
/**
|
|
1041
|
-
* Replace the opaque `$ext` map on the card `addr` targets (
|
|
1042
|
-
*
|
|
1043
|
-
*
|
|
1044
|
-
*
|
|
1045
|
-
* `store` verb. Throws on a present `field` or an out-of-range card.
|
|
925
|
+
* Replace the opaque `$ext` map on the card `addr` targets (absent `card` =
|
|
926
|
+
* main). `value` must be a plain object. `$ext` carries out-of-band consumer
|
|
927
|
+
* state and never reaches the rendered output. Throws on a present `field`
|
|
928
|
+
* or an out-of-range card.
|
|
1046
929
|
*/
|
|
1047
930
|
storeExt(addr: CardAddr, value: any): void;
|
|
1048
931
|
/**
|
|
1049
932
|
* Merge `value` into `$ext[ns]` on the card `addr` targets, preserving
|
|
1050
|
-
* sibling namespaces: the recommended `$ext` write.
|
|
1051
|
-
*
|
|
1052
|
-
* Throws on a present `field` or an out-of-range card.
|
|
933
|
+
* sibling namespaces: the recommended `$ext` write. Throws on a present
|
|
934
|
+
* `field` or an out-of-range card.
|
|
1053
935
|
*/
|
|
1054
936
|
storeExtNamespace(addr: CardAddr, ns: string, value: any): void;
|
|
1055
937
|
/**
|
|
1056
|
-
* Store a field verbatim at `addr
|
|
1057
|
-
*
|
|
1058
|
-
*
|
|
1059
|
-
*
|
|
1060
|
-
*
|
|
1061
|
-
*
|
|
1062
|
-
* opaque; write it with `revise` / `overwrite` / `writer.reviseBody`. Throws on
|
|
1063
|
-
* an out-of-range card or a malformed name.
|
|
938
|
+
* Store a field verbatim at `addr`, deferring coercion to render; the typed
|
|
939
|
+
* write is [`commitField`](Document::commit_field). A bare string is `Addr`
|
|
940
|
+
* shorthand for `{ field }`; `{ card: 2, field: "qty" }` targets a
|
|
941
|
+
* composable card. Clears any `!must_fill` marker. A body address throws:
|
|
942
|
+
* write a body with `revise` / `overwrite`. Throws on an out-of-range card
|
|
943
|
+
* or a malformed name.
|
|
1064
944
|
*/
|
|
1065
945
|
storeField(addr: Addr | string, value: any): void;
|
|
1066
946
|
/**
|
|
1067
|
-
* Store several fields verbatim and atomically on the card `addr` targets
|
|
1068
|
-
*
|
|
1069
|
-
*
|
|
1070
|
-
*
|
|
1071
|
-
*
|
|
1072
|
-
* fields)` a composable one, never ambiguous with "set field `card`".
|
|
1073
|
-
* Nothing is applied on error; the thrown error's `diagnostics` carry one
|
|
1074
|
-
* entry per offending field. Throws on an out-of-range card.
|
|
947
|
+
* Store several fields verbatim and atomically on the card `addr` targets.
|
|
948
|
+
* `addr` is a **card address** (`{ card }`, absent = main) and comes first
|
|
949
|
+
* because `card` is itself a legal field name; a present `field` throws.
|
|
950
|
+
* Nothing is applied on error, and the thrown error's `diagnostics` carry
|
|
951
|
+
* one entry per offending field. Throws on an out-of-range card.
|
|
1075
952
|
*/
|
|
1076
953
|
storeFields(addr: CardAddr, fields: Record<string, unknown>): void;
|
|
1077
954
|
/**
|
|
1078
|
-
* Store a field verbatim at `addr` and mark it `!must_fill
|
|
1079
|
-
*
|
|
1080
|
-
* `{ card, field }` for a composable card). A body address throws. Same
|
|
1081
|
-
* validation as [`storeField`](Document::store_field).
|
|
955
|
+
* Store a field verbatim at `addr` and mark it `!must_fill`. A body address
|
|
956
|
+
* throws; same validation as [`storeField`](Document::store_field).
|
|
1082
957
|
*/
|
|
1083
958
|
storeFill(addr: Addr | string, value: any): void;
|
|
1084
959
|
/**
|
|
1085
960
|
* Merge a card-kind's seed `overlay` into the **main** card's `$seed` map
|
|
1086
|
-
* under `cardKind`, preserving sibling kinds
|
|
1087
|
-
*
|
|
1088
|
-
*
|
|
1089
|
-
* verb. Throws if `overlay` cannot be serialized or nests too deep.
|
|
961
|
+
* under `cardKind`, preserving sibling kinds; `$seed` is main-only, so this
|
|
962
|
+
* takes no address. Sets the starting values new cards of that kind spawn
|
|
963
|
+
* with. Throws if `overlay` cannot be serialized or nests too deep.
|
|
1090
964
|
*/
|
|
1091
965
|
storeSeedOverlay(card_kind: string, overlay: any): void;
|
|
1092
966
|
/**
|
|
1093
|
-
* Serialize this document to a versioned storage DTO string.
|
|
1094
|
-
*
|
|
1095
|
-
*
|
|
1096
|
-
*
|
|
1097
|
-
* `warnings` are excluded from the DTO.
|
|
1098
|
-
*
|
|
1099
|
-
* Output is **byte-deterministic** within a `schema` version: equal
|
|
1100
|
-
* documents produce byte-equal output, safe for content-hash use cases.
|
|
967
|
+
* Serialize this document to a versioned storage DTO string. Prefer it over
|
|
968
|
+
* `toMarkdown` for persistence: the wire format is frozen per `schema`
|
|
969
|
+
* version and the output is byte-deterministic within one, so equal
|
|
970
|
+
* documents hash equal. Parse-time `warnings` are excluded.
|
|
1101
971
|
*/
|
|
1102
972
|
toJson(): string;
|
|
1103
973
|
/**
|
|
@@ -1106,80 +976,66 @@ export class Document {
|
|
|
1106
976
|
*/
|
|
1107
977
|
toMarkdown(): string;
|
|
1108
978
|
/**
|
|
1109
|
-
* Like [`fromJson`](Document::from_json) but returns `undefined` instead
|
|
1110
|
-
*
|
|
1111
|
-
*
|
|
1112
|
-
* `undefined` means "not a storage DTO"; `fromMarkdown` still throws on
|
|
1113
|
-
* genuinely malformed markdown.
|
|
979
|
+
* Like [`fromJson`](Document::from_json) but returns `undefined` instead of
|
|
980
|
+
* throwing when `json` is not a valid storage DTO, to discriminate format
|
|
981
|
+
* without exceptions as control flow.
|
|
1114
982
|
*/
|
|
1115
983
|
static tryFromJson(json: string): Document | undefined;
|
|
1116
984
|
/**
|
|
1117
|
-
* Number of composable cards
|
|
985
|
+
* Number of composable cards, excluding the main card.
|
|
1118
986
|
*/
|
|
1119
987
|
readonly cardCount: number;
|
|
1120
988
|
readonly cards: Card[];
|
|
1121
989
|
/**
|
|
1122
|
-
* The document's main (entry) card. Allocates and serializes on each
|
|
1123
|
-
* call: cache locally if read in a hot loop.
|
|
990
|
+
* The document's main (entry) card. Allocates and serializes on each call.
|
|
1124
991
|
*/
|
|
1125
992
|
readonly main: Card;
|
|
1126
993
|
readonly quillRef: string;
|
|
1127
994
|
/**
|
|
1128
995
|
* The non-fatal diagnostics of the load that produced this document: parse
|
|
1129
|
-
* warnings, plus
|
|
1130
|
-
*
|
|
1131
|
-
*
|
|
996
|
+
* warnings, plus `conform::*` warnings when it came through `quill.parse`.
|
|
997
|
+
* Session state, not document value: `equals` and the storage DTO exclude
|
|
998
|
+
* it, and `fromJson` / `loadJson` clear it.
|
|
1132
999
|
*/
|
|
1133
1000
|
readonly warnings: Diagnostic[];
|
|
1134
1001
|
}
|
|
1135
1002
|
|
|
1136
1003
|
/**
|
|
1137
|
-
* Live render session:
|
|
1138
|
-
*
|
|
1139
|
-
*
|
|
1140
|
-
*
|
|
1141
|
-
* compile; anchoring a caret across edits is the editor's job: re-read
|
|
1142
|
-
* geometry after each committed `apply`.
|
|
1004
|
+
* Live render session: every read serves the current compile. `apply(doc)`
|
|
1005
|
+
* recompiles a whole document in place, transactionally — on throw the reads
|
|
1006
|
+
* keep serving the last-good compile. Geometry is per-compile, so re-read it
|
|
1007
|
+
* after each committed `apply`.
|
|
1143
1008
|
*
|
|
1144
|
-
*
|
|
1145
|
-
*
|
|
1146
|
-
*
|
|
1147
|
-
* rather than catching the error.
|
|
1009
|
+
* A zero-page document yields a valid session (`pageCount === 0`) whose
|
|
1010
|
+
* `paint(ctx, 0)` and `pageSize(0)` throw; branch on `pageCount === 0` rather
|
|
1011
|
+
* than catching.
|
|
1148
1012
|
*/
|
|
1149
1013
|
export class LiveSession {
|
|
1150
1014
|
private constructor();
|
|
1151
1015
|
free(): void;
|
|
1152
1016
|
[Symbol.dispose](): void;
|
|
1153
1017
|
/**
|
|
1154
|
-
* The schema field whose content is under a point on `page
|
|
1155
|
-
*
|
|
1156
|
-
*
|
|
1157
|
-
*
|
|
1158
|
-
*
|
|
1159
|
-
*
|
|
1160
|
-
* `FieldRegion`: `x = clickPx.x / renderScale`,
|
|
1161
|
-
* `y = pageHeightPt - clickPx.y / renderScale`. Unlike `regions()`,
|
|
1162
|
-
* *every* placement answers, not just the first.
|
|
1018
|
+
* The schema field whose content is under a point on `page`: the `DocPath`
|
|
1019
|
+
* address to focus in the editor, or `undefined` off any field's ink.
|
|
1020
|
+
* `x`/`y` are PDF points with a **bottom-left** origin, the same space as
|
|
1021
|
+
* `FieldRegion.rect`, so from a canvas click use
|
|
1022
|
+
* `x = clickPx.x / renderScale`, `y = pageHeightPt - clickPx.y / renderScale`.
|
|
1023
|
+
* Unlike `regions()`, *every* placement answers, not just the first.
|
|
1163
1024
|
*/
|
|
1164
1025
|
fieldAt(page: number, x: number, y: number): string | undefined;
|
|
1165
1026
|
/**
|
|
1166
|
-
* The whole-field highlight boxes for `field`: one union rect per page
|
|
1167
|
-
*
|
|
1168
|
-
*
|
|
1169
|
-
*
|
|
1170
|
-
*
|
|
1171
|
-
* reimplementing it. **Content only**: a field placed solely as a scalar
|
|
1172
|
-
* reference or a bound widget carries no `span` and returns `[]`; its box
|
|
1173
|
-
* is a single `regions()` rect. Reflects the current compile, like
|
|
1174
|
-
* `regions()`.
|
|
1027
|
+
* The whole-field highlight boxes for `field`: one union rect per page over
|
|
1028
|
+
* the field's `span`-bearing content segments, the union `regions()` leaves
|
|
1029
|
+
* derived. **Content only**: a field placed solely as a scalar reference or
|
|
1030
|
+
* a bound widget carries no `span` and returns `[]`, its box being a single
|
|
1031
|
+
* `regions()` rect. Reflects the current compile.
|
|
1175
1032
|
*/
|
|
1176
1033
|
fieldBoxes(field: string): FieldRegion[];
|
|
1177
1034
|
/**
|
|
1178
|
-
* A content position → **caret rect**, the reverse of `positionAt`:
|
|
1179
|
-
*
|
|
1180
|
-
*
|
|
1181
|
-
*
|
|
1182
|
-
* places no tracked content or the offset maps to no drawn glyph.
|
|
1035
|
+
* A content position → **caret rect**, the reverse of `positionAt`: the box
|
|
1036
|
+
* to draw a caret at, in the same bottom-left PDF-point space as
|
|
1037
|
+
* `FieldRegion.rect`, its `span` collapsed to `[pos, pos]`. `undefined` when
|
|
1038
|
+
* the field places no tracked content or the offset maps to no drawn glyph.
|
|
1183
1039
|
*/
|
|
1184
1040
|
locate(field: string, pos: number): FieldRegion | undefined;
|
|
1185
1041
|
/**
|
|
@@ -1191,54 +1047,45 @@ export class LiveSession {
|
|
|
1191
1047
|
* Paint `page` into a `CanvasRenderingContext2D` or
|
|
1192
1048
|
* `OffscreenCanvasRenderingContext2D`. The painter owns
|
|
1193
1049
|
* `canvas.width`/`height` (no `clearRect` needed); consumers own
|
|
1194
|
-
* `canvas.style.*`. If `layoutScale * densityScale` exceeds 16384 px
|
|
1195
|
-
*
|
|
1196
|
-
* `PaintResult.effectiveDensityScale` carries the density actually applied.
|
|
1050
|
+
* `canvas.style.*`. If `layoutScale * densityScale` exceeds 16384 px per
|
|
1051
|
+
* side, `densityScale` is clamped and `PaintResult` reports it.
|
|
1197
1052
|
*
|
|
1198
1053
|
* `put_image_data` writes the whole backing store, bypassing the 2D
|
|
1199
|
-
* context's transform, `globalAlpha`, and clip
|
|
1200
|
-
*
|
|
1201
|
-
*
|
|
1054
|
+
* context's transform, `globalAlpha`, and clip, so each visible page needs
|
|
1055
|
+
* its own `<canvas>`: no compositing, sub-rect, or transform reaches through
|
|
1056
|
+
* this call.
|
|
1202
1057
|
*
|
|
1203
|
-
* Throws if the backend has no canvas painter, `page` is out of range,
|
|
1204
|
-
*
|
|
1058
|
+
* Throws if the backend has no canvas painter, `page` is out of range, `ctx`
|
|
1059
|
+
* is the wrong type, or either scale is non-finite or `<= 0`.
|
|
1205
1060
|
*/
|
|
1206
1061
|
paint(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, page: number, opts: PaintOptions | undefined): PaintResult;
|
|
1207
1062
|
/**
|
|
1208
|
-
* A point → **content position
|
|
1209
|
-
*
|
|
1210
|
-
* `
|
|
1211
|
-
*
|
|
1212
|
-
*
|
|
1213
|
-
* cluster-exact and degrades to the containing segment's start on
|
|
1214
|
-
* origin-less ink (list markers, a code fence's interior). See
|
|
1215
|
-
* `ContentHit`.
|
|
1063
|
+
* A point → **content position**: the field *and* a USV offset into its
|
|
1064
|
+
* `Content`, for placing a caret or mapping a selection into the content
|
|
1065
|
+
* model, or `undefined` off all content ink. `x`/`y` are PDF points,
|
|
1066
|
+
* bottom-left origin, as in `fieldAt`. The offset is cluster-exact and
|
|
1067
|
+
* degrades to the containing segment's start on origin-less ink.
|
|
1216
1068
|
*/
|
|
1217
1069
|
positionAt(page: number, x: number, y: number): ContentHit | undefined;
|
|
1218
1070
|
/**
|
|
1219
1071
|
* Schema-field geometry for this compiled session: each content field's
|
|
1220
1072
|
* **first placement** (one region per page it touches) plus widget and
|
|
1221
|
-
* scalar-reference-site regions, keyed on the canonical `DocPath` address
|
|
1222
|
-
*
|
|
1223
|
-
*
|
|
1224
|
-
*
|
|
1225
|
-
* artifact. An interactive preview reads it to scroll to / highlight the
|
|
1226
|
-
* focused field over a `paint`-ed canvas; the click direction is `fieldAt`.
|
|
1227
|
-
* Empty for backends that place no schema fields.
|
|
1073
|
+
* scalar-reference-site regions, keyed on the canonical `DocPath` address. A
|
|
1074
|
+
* field may appear more than once, so group by `field` (see `FieldRegion`).
|
|
1075
|
+
* A session-level query: no render, no byte artifact. The click direction is
|
|
1076
|
+
* `fieldAt`. Empty for backends that place no schema fields.
|
|
1228
1077
|
*/
|
|
1229
1078
|
regions(): FieldRegion[];
|
|
1230
1079
|
render(opts?: RenderOptions | null): RenderResult;
|
|
1231
1080
|
/**
|
|
1232
|
-
* Recompile the session against `doc`: the edit verb of a live preview.
|
|
1233
|
-
*
|
|
1234
|
-
*
|
|
1235
|
-
*
|
|
1236
|
-
*
|
|
1237
|
-
* success reads serve the new compile; repaint `dirtyPages ∩ visible`.
|
|
1081
|
+
* Recompile the session against `doc`: the edit verb of a live preview. The
|
|
1082
|
+
* document compiles through the same pipeline as `open`, then swaps in
|
|
1083
|
+
* transactionally — on throw every read keeps serving the last-good compile
|
|
1084
|
+
* and the session recovers on the next successful `update`. On success,
|
|
1085
|
+
* repaint `dirtyPages ∩ visible`.
|
|
1238
1086
|
*
|
|
1239
|
-
* Distinct from
|
|
1240
|
-
*
|
|
1241
|
-
* the caller already mutated.
|
|
1087
|
+
* Distinct from [`applyChange`](Document::apply_change), which splices ops
|
|
1088
|
+
* into a document; this recompiles a document the caller already mutated.
|
|
1242
1089
|
*/
|
|
1243
1090
|
update(doc: Document): ChangeSet;
|
|
1244
1091
|
/**
|
|
@@ -1247,16 +1094,13 @@ export class LiveSession {
|
|
|
1247
1094
|
readonly backendId: string;
|
|
1248
1095
|
readonly pageCount: number;
|
|
1249
1096
|
/**
|
|
1250
|
-
* `true` iff `paint` and `pageSize` will succeed for this session.
|
|
1251
|
-
* from the session's canvas seam, so it reflects exactly what `paint` will
|
|
1252
|
-
* do: no separately captured flag.
|
|
1097
|
+
* `true` iff `paint` and `pageSize` will succeed for this session.
|
|
1253
1098
|
*/
|
|
1254
1099
|
readonly supportsCanvas: boolean;
|
|
1255
1100
|
/**
|
|
1256
|
-
* Non-fatal diagnostics of the session's **current compile
|
|
1257
|
-
*
|
|
1258
|
-
*
|
|
1259
|
-
* to `RenderResult.warnings` on each `render()` call.
|
|
1101
|
+
* Non-fatal diagnostics of the session's **current compile**, refreshed by
|
|
1102
|
+
* each committed `apply`; a failed apply keeps the last-good compile's.
|
|
1103
|
+
* Also appended to `RenderResult.warnings` on each `render()`.
|
|
1260
1104
|
*/
|
|
1261
1105
|
readonly warnings: Diagnostic[];
|
|
1262
1106
|
}
|
|
@@ -1267,132 +1111,100 @@ export class Quill {
|
|
|
1267
1111
|
[Symbol.dispose](): void;
|
|
1268
1112
|
/**
|
|
1269
1113
|
* Land `doc`'s declared content fields at their canonical rest **in
|
|
1270
|
-
* place**, returning the `conform::*` diagnostics for
|
|
1271
|
-
*
|
|
1272
|
-
*
|
|
1273
|
-
* The read-repair verb: a document that arrived through the transport door
|
|
1274
|
-
* (`fromMarkdown`, `fromJson`, a stored row) converges here, and is then
|
|
1275
|
-
* eligible for rewrite under its current schema tag. Idempotent, and a
|
|
1276
|
-
* no-op on an already-canonical document: an equal value is not rewritten,
|
|
1277
|
-
* so YAML comments and stored bytes survive.
|
|
1114
|
+
* place**, returning the `conform::*` diagnostics for values that would not
|
|
1115
|
+
* commit. The read-repair verb for a document that arrived through the
|
|
1116
|
+
* transport door (`fromMarkdown`, `fromJson`, a stored row).
|
|
1278
1117
|
*
|
|
1279
|
-
*
|
|
1280
|
-
*
|
|
1281
|
-
*
|
|
1282
|
-
* `$quill`, before any
|
|
1118
|
+
* Idempotent: an equal value is not rewritten, so YAML comments and stored
|
|
1119
|
+
* bytes survive. A `!must_fill` marker anywhere in a field's value skips
|
|
1120
|
+
* that field, and a value the strict write refuses stays as authored with a
|
|
1121
|
+
* diagnostic. Throws when `doc` declares a different `$quill`, before any
|
|
1122
|
+
* mutation.
|
|
1283
1123
|
*/
|
|
1284
1124
|
conform(doc: Document): Diagnostic[];
|
|
1285
1125
|
/**
|
|
1286
|
-
* Build a quill from a file tree. Pure:
|
|
1287
|
-
*
|
|
1288
|
-
*
|
|
1289
|
-
* Accepts either a `Map<string, Uint8Array>` or a plain object
|
|
1290
|
-
* (`Record<string, Uint8Array>`). Plain objects are walked via
|
|
1291
|
-
* `Object.entries` at the boundary; the Rust side sees a single
|
|
1292
|
-
* canonical shape.
|
|
1126
|
+
* Build a quill from a file tree. Pure: the declared backend is resolved
|
|
1127
|
+
* later, at render time. Accepts a `Map<string, Uint8Array>` or a plain
|
|
1128
|
+
* object.
|
|
1293
1129
|
*/
|
|
1294
1130
|
static fromTree(tree: Map<string, Uint8Array>): Quill;
|
|
1295
1131
|
/**
|
|
1296
|
-
* Parse `markdown` and conform it against this quill: the
|
|
1297
|
-
*
|
|
1298
|
-
*
|
|
1299
|
-
*
|
|
1300
|
-
*
|
|
1301
|
-
* field's declared codec rather than by how the document was built.
|
|
1132
|
+
* Parse `markdown` and conform it against this quill: the primary ingestion
|
|
1133
|
+
* path, and the bound twin of the schema-free `Document.fromMarkdown`. The
|
|
1134
|
+
* returned document rests at its canonical form (a `richtext` field as a
|
|
1135
|
+
* content object, a `plaintext` field as its literal string), so `getStored`
|
|
1136
|
+
* answers by the field's declared codec, not by how the document was built.
|
|
1302
1137
|
*
|
|
1303
1138
|
* Parse warnings and the `conform::*` diagnostics both land on
|
|
1304
1139
|
* `doc.warnings`. Throws on a parse failure, or when `markdown` declares a
|
|
1305
|
-
* `$quill` this quill does not answer to
|
|
1306
|
-
*
|
|
1307
|
-
* door (`Document.fromMarkdown`, `setQuillRef`, then `quill.conform`).
|
|
1140
|
+
* `$quill` this quill does not answer to. To open a document whose `$quill`
|
|
1141
|
+
* is stale, use `Document.fromMarkdown`, `setQuillRef`, then `quill.conform`.
|
|
1308
1142
|
*/
|
|
1309
1143
|
parse(markdown: string): Document;
|
|
1310
1144
|
/**
|
|
1311
|
-
* The resolved-value view of `doc
|
|
1312
|
-
*
|
|
1313
|
-
*
|
|
1314
|
-
*
|
|
1315
|
-
*
|
|
1316
|
-
*
|
|
1317
|
-
* Value and provenance only: completeness and errors stay `validate`'s
|
|
1318
|
-
* (a consumer merges it with its own diagnostic producers regardless), and
|
|
1319
|
-
* schema guidance reads from `Quill.schema`.
|
|
1145
|
+
* The resolved-value view of `doc`: for every declared field, the value the
|
|
1146
|
+
* render projection would use and the `FieldSource` rung it came from
|
|
1147
|
+
* (`"authored" | "default" | "blank"`). The card body is a `body` sibling on
|
|
1148
|
+
* its card, never a row in `fields`, and `null` when the kind enables no
|
|
1149
|
+
* body. Value and provenance only; completeness stays `validate`'s.
|
|
1320
1150
|
*/
|
|
1321
1151
|
resolve(doc: Document): Resolved;
|
|
1322
1152
|
/**
|
|
1323
1153
|
* Seed a starter composable `Card` of the given kind (carries `$kind`),
|
|
1324
|
-
* layering an optional per-kind seed `overlay` over the schema-example
|
|
1325
|
-
*
|
|
1326
|
-
*
|
|
1327
|
-
* straight into `Document.insertCard`.
|
|
1154
|
+
* layering an optional per-kind seed `overlay` over the schema-example base
|
|
1155
|
+
* (`overlay › example › absent`). `undefined` when `cardKind` is not
|
|
1156
|
+
* declared in this quill's schema.
|
|
1328
1157
|
*
|
|
1329
1158
|
* Pass `document.seedOverlay(cardKind)` as `overlay` so a card added to a
|
|
1330
1159
|
* template-derived document inherits its curated starting values; omit it
|
|
1331
|
-
*
|
|
1332
|
-
* plain object: this reads the document, it does not mutate it.
|
|
1160
|
+
* for the bare schema seed.
|
|
1333
1161
|
*/
|
|
1334
1162
|
seedCard(card_kind: string, overlay: Record<string, unknown> | undefined): Card | undefined;
|
|
1335
1163
|
/**
|
|
1336
|
-
* Seed a starter `Document` from the schema
|
|
1337
|
-
*
|
|
1338
|
-
*
|
|
1339
|
-
*
|
|
1340
|
-
* with both an `example` and a `default` renders its example. See
|
|
1341
|
-
* `prose/canon/SCHEMAS.md` § "Document seeding".
|
|
1164
|
+
* Seed a starter `Document` from the schema: the main card plus one instance
|
|
1165
|
+
* of each composable card kind, each committing its fields' `example:`
|
|
1166
|
+
* values and leaving every other field absent (interpolated at render as
|
|
1167
|
+
* `default:`, else the field's blank). A field with both renders its example.
|
|
1342
1168
|
*/
|
|
1343
1169
|
seedDocument(): Document;
|
|
1344
1170
|
/**
|
|
1345
1171
|
* Seed a starter main `Card` (carries `$quill`) from the schema: the
|
|
1346
|
-
* `$kind: main` card of [`seedDocument`](Self::seed_document)
|
|
1347
|
-
* isolation, committing each field's `example:` value. Returns the same
|
|
1348
|
-
* `Card` shape as the `Document.main` getter.
|
|
1172
|
+
* `$kind: main` card of [`seedDocument`](Self::seed_document) alone.
|
|
1349
1173
|
*/
|
|
1350
1174
|
seedMain(): Card;
|
|
1351
1175
|
/**
|
|
1352
|
-
* Flatten this quill back into its canonical file tree
|
|
1353
|
-
* [`fromTree`](Self::from_tree).
|
|
1354
|
-
* reproduces an equivalent quill.
|
|
1176
|
+
* Flatten this quill back into its canonical file tree, the inverse of
|
|
1177
|
+
* [`fromTree`](Self::from_tree). Keys are `"/"`-joined relative paths.
|
|
1355
1178
|
*
|
|
1356
1179
|
* This is how a quill crosses a WASM linear-memory boundary as data: a
|
|
1357
|
-
* `Quill` built in one build
|
|
1358
|
-
* cannot be passed to an engine in another (separate linear memories), so
|
|
1180
|
+
* `Quill` built in one build cannot be passed to an engine in another, so
|
|
1359
1181
|
* `@quillmark/wasm/runtime` re-feeds this tree to the backend build's
|
|
1360
|
-
* `Quill.fromTree` on demand.
|
|
1361
|
-
* matching what `fromTree` accepts.
|
|
1182
|
+
* `Quill.fromTree` on demand.
|
|
1362
1183
|
*/
|
|
1363
1184
|
toTree(): Map<string, Uint8Array>;
|
|
1364
1185
|
/**
|
|
1365
1186
|
* Validate `doc` against this quill's schema, returning every diagnostic
|
|
1366
|
-
* (
|
|
1367
|
-
*
|
|
1368
|
-
*
|
|
1369
|
-
* `path`, and `hint` the engine emits) including the non-fatal
|
|
1370
|
-
* `validation::must_fill` warning for each `!must_fill` marker left in
|
|
1371
|
-
* the document. Field values, defaults, and order are not part of this
|
|
1372
|
-
* surface: read them from the `Document` payload and `Quill.schema`
|
|
1373
|
-
* (schema key order is display order).
|
|
1187
|
+
* (empty when the document is valid). Forwards the canonical
|
|
1188
|
+
* `validation::*` diagnostics the engine emits, including the non-fatal
|
|
1189
|
+
* `validation::must_fill` warning per `!must_fill` marker left behind.
|
|
1374
1190
|
*/
|
|
1375
1191
|
validate(doc: Document): Diagnostic[];
|
|
1376
1192
|
/**
|
|
1377
|
-
* The *declared* backend identifier (
|
|
1378
|
-
*
|
|
1379
|
-
* `supportsCanvas`) is read from the engine.
|
|
1193
|
+
* The *declared* backend identifier (e.g. `"typst"`): intent, not a
|
|
1194
|
+
* resolved capability. Capability is read from the engine.
|
|
1380
1195
|
*/
|
|
1381
1196
|
readonly backendId: string;
|
|
1382
1197
|
readonly blueprint: string;
|
|
1383
1198
|
/**
|
|
1384
1199
|
* Identity snapshot of the `quill:` section of `Quill.yaml` plus any extra
|
|
1385
|
-
* `quill:` keys. Pure config:
|
|
1386
|
-
*
|
|
1387
|
-
* (`Quillmark.supportedFormats`), not part of this snapshot.
|
|
1200
|
+
* `quill:` keys. Pure config: output formats are a resolved-backend
|
|
1201
|
+
* capability read from `Quillmark.supportedFormats`, not part of this.
|
|
1388
1202
|
*/
|
|
1389
1203
|
readonly metadata: QuillMetadata;
|
|
1390
1204
|
/**
|
|
1391
|
-
* Document schema for the quill: the user-fillable fields plus their
|
|
1392
|
-
*
|
|
1393
|
-
*
|
|
1394
|
-
* alike. Key order in `fields`/`properties` is declaration order: the
|
|
1395
|
-
* ordering contract. Returns the `QuillSchema` shape.
|
|
1205
|
+
* Document schema for the quill: the user-fillable fields plus their `ui`
|
|
1206
|
+
* hints. Key order in `fields`/`properties` is declaration order, the
|
|
1207
|
+
* ordering contract.
|
|
1396
1208
|
*/
|
|
1397
1209
|
readonly schema: QuillSchema;
|
|
1398
1210
|
}
|
|
@@ -1416,81 +1228,67 @@ export class Quillmark {
|
|
|
1416
1228
|
*/
|
|
1417
1229
|
render(quill: Quill, doc: Document, opts?: RenderOptions | null): RenderResult;
|
|
1418
1230
|
/**
|
|
1419
|
-
* The output formats `quill`'s backend can emit
|
|
1420
|
-
*
|
|
1421
|
-
*
|
|
1231
|
+
* The output formats `quill`'s backend can emit; resolves the backend but
|
|
1232
|
+
* compiles nothing. Throws `engine::backend_not_found` when no registered
|
|
1233
|
+
* backend matches the quill's declared one.
|
|
1422
1234
|
*/
|
|
1423
1235
|
supportedFormats(quill: Quill): OutputFormat[];
|
|
1424
1236
|
/**
|
|
1425
|
-
*
|
|
1426
|
-
*
|
|
1427
|
-
*
|
|
1428
|
-
* a canvas-based preview UI; the authoritative answer is the session's
|
|
1429
|
-
* `supportsCanvas` getter once `open()` has been called.
|
|
1237
|
+
* Whether `quill`'s backend can paint sessions to a canvas; `false` when the
|
|
1238
|
+
* backend is unsupported. A cheap probe before mounting a preview UI. The
|
|
1239
|
+
* authoritative answer is the session's `supportsCanvas` getter.
|
|
1430
1240
|
*/
|
|
1431
1241
|
supportsCanvas(quill: Quill): boolean;
|
|
1432
1242
|
}
|
|
1433
1243
|
|
|
1434
1244
|
/**
|
|
1435
|
-
* Export
|
|
1436
|
-
* on-demand codec behind `exportMarkdown(card.body)`. Throws if `rt` is not a
|
|
1245
|
+
* Export canonical `Content` to its markdown projection. Throws if `rt` is not
|
|
1437
1246
|
* canonical content.
|
|
1438
1247
|
*/
|
|
1439
1248
|
export function exportMarkdown(rt: Content): string;
|
|
1440
1249
|
|
|
1441
1250
|
/**
|
|
1442
1251
|
* Serialize structured [`DocPathSeg`] segments back to the canonical path
|
|
1443
|
-
* string: the inverse of `parseDocPath
|
|
1444
|
-
*
|
|
1445
|
-
* and on an empty segment array (symmetric with `parseDocPath("")`, which
|
|
1446
|
-
* throws "empty path").
|
|
1252
|
+
* string: the inverse of `parseDocPath`. Throws on a segment array the
|
|
1253
|
+
* deserializer rejects, and on an empty one.
|
|
1447
1254
|
*/
|
|
1448
1255
|
export function formatDocPath(segs: DocPathSeg[]): string;
|
|
1449
1256
|
|
|
1450
1257
|
/**
|
|
1451
|
-
* Import a markdown string to
|
|
1452
|
-
*
|
|
1453
|
-
*
|
|
1454
|
-
* semantics. Throws on an over-nested input.
|
|
1258
|
+
* Import a markdown string to canonical `Content`: the pure, document-free
|
|
1259
|
+
* codec. `overwrite(addr, importMarkdown(md))` spells the cold, anchor-losing
|
|
1260
|
+
* write; prefer `revise` for edit semantics. Throws on an over-nested input.
|
|
1455
1261
|
*/
|
|
1456
1262
|
export function importMarkdown(markdown: string): Content;
|
|
1457
1263
|
|
|
1458
1264
|
/**
|
|
1459
1265
|
* Map a base content position (a USV index into `Content.text`, not a UTF-16
|
|
1460
|
-
* offset) through a `delta` to its new
|
|
1461
|
-
*
|
|
1462
|
-
*
|
|
1463
|
-
* it). Throws on a malformed `delta`.
|
|
1266
|
+
* offset) through a `delta` to its new position, holding a caret stable across
|
|
1267
|
+
* a `revise`. `assoc` decides the side of a same-position insertion (`"after"`
|
|
1268
|
+
* moves past it). Throws on a malformed `delta`.
|
|
1464
1269
|
*/
|
|
1465
1270
|
export function mapPos(delta: Delta, pos: number, assoc: Assoc): number;
|
|
1466
1271
|
|
|
1467
1272
|
/**
|
|
1468
|
-
* Parse a canonical document-model `Diagnostic.path`
|
|
1469
|
-
*
|
|
1470
|
-
*
|
|
1471
|
-
*
|
|
1472
|
-
* the string. Throws on a malformed path.
|
|
1273
|
+
* Parse a canonical document-model `Diagnostic.path` (`cards.<kind>[<i>].<field>`,
|
|
1274
|
+
* `main.body`, `recipients[0].name`) into structured [`DocPathSeg`] segments, so
|
|
1275
|
+
* a consumer routes on segments instead of regexing the string. Throws on a
|
|
1276
|
+
* malformed path.
|
|
1473
1277
|
*/
|
|
1474
1278
|
export function parseDocPath(path: string): DocPathSeg[];
|
|
1475
1279
|
|
|
1476
1280
|
/**
|
|
1477
|
-
* Rebase `markdown` onto a `base` content
|
|
1478
|
-
*
|
|
1479
|
-
* text
|
|
1480
|
-
*
|
|
1481
|
-
* md)` fuses this with the store for atomicity. Throws on an over-nested
|
|
1482
|
-
* markdown input or a non-content `base`.
|
|
1281
|
+
* Rebase `markdown` onto a `base` content: the document-free twin of `revise`,
|
|
1282
|
+
* returning the new `content` and the text `delta` (offsets are USV indices into
|
|
1283
|
+
* `Content.text`, surviving anchors rebased). Throws on an over-nested markdown
|
|
1284
|
+
* input or a non-content `base`.
|
|
1483
1285
|
*/
|
|
1484
1286
|
export function rebase(base: Content, markdown: string): { content: Content; delta: Delta };
|
|
1485
1287
|
|
|
1486
1288
|
/**
|
|
1487
|
-
* Runs at instantiation
|
|
1488
|
-
*
|
|
1489
|
-
*
|
|
1490
|
-
*
|
|
1491
|
-
* Not the package's `init`. That name belongs to the hand-written runtime,
|
|
1492
|
-
* which owns instantiation itself (`runtime/runtime.js`); this runs as part of
|
|
1493
|
-
* the instantiation it awaits.
|
|
1289
|
+
* Runs at instantiation, so a Rust panic reaches the console as a stack trace
|
|
1290
|
+
* rather than `unreachable`. Not the package's `init` — that name belongs to
|
|
1291
|
+
* the hand-written runtime, which owns instantiation itself.
|
|
1494
1292
|
*/
|
|
1495
1293
|
export function start(): void;
|
|
1496
1294
|
|
|
@@ -1507,12 +1305,14 @@ export interface InitOutput {
|
|
|
1507
1305
|
readonly document__commitFields: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
1508
1306
|
readonly document__readerGet: (a: number, b: number, c: number, d: number) => void;
|
|
1509
1307
|
readonly document__readerGetContent: (a: number, b: number, c: number, d: number) => void;
|
|
1308
|
+
readonly document__readerGetContentAt: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
1510
1309
|
readonly document__reviseField: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
1511
1310
|
readonly document_applyChange: (a: number, b: number, c: number, d: number) => void;
|
|
1512
1311
|
readonly document_blueprintInstruction: (a: number, b: number, c: number) => void;
|
|
1513
1312
|
readonly document_bodyMarkdown: (a: number, b: number, c: number) => void;
|
|
1514
1313
|
readonly document_card: (a: number, b: number, c: number) => void;
|
|
1515
1314
|
readonly document_cardCount: (a: number) => number;
|
|
1315
|
+
readonly document_cardPath: (a: number, b: number, c: number) => void;
|
|
1516
1316
|
readonly document_cards: (a: number, b: number) => void;
|
|
1517
1317
|
readonly document_clone: (a: number) => number;
|
|
1518
1318
|
readonly document_currentStorageVersion: (a: number) => void;
|
|
@@ -1532,6 +1332,7 @@ export interface InitOutput {
|
|
|
1532
1332
|
readonly document_moveCard: (a: number, b: number, c: number, d: number) => void;
|
|
1533
1333
|
readonly document_new: (a: number, b: number, c: number) => void;
|
|
1534
1334
|
readonly document_overwrite: (a: number, b: number, c: number, d: number) => void;
|
|
1335
|
+
readonly document_pathFor: (a: number, b: number, c: number) => void;
|
|
1535
1336
|
readonly document_quillRef: (a: number, b: number) => void;
|
|
1536
1337
|
readonly document_quillRefHint: (a: number) => void;
|
|
1537
1338
|
readonly document_removeCard: (a: number, b: number, c: number) => void;
|