@quillmark/wasm 0.94.0 → 0.95.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +77 -316
- package/README.md +58 -42
- package/backends/pdfform/wasm.d.ts +213 -246
- package/backends/pdfform/wasm_bg.js +436 -452
- package/backends/pdfform/wasm_bg.wasm +0 -0
- package/backends/pdfform/wasm_bg.wasm.d.ts +22 -25
- package/backends/typst/wasm.d.ts +213 -246
- package/backends/typst/wasm_bg.js +436 -452
- package/backends/typst/wasm_bg.wasm +0 -0
- package/backends/typst/wasm_bg.wasm.d.ts +22 -25
- package/core/wasm.d.ts +206 -239
- package/core/wasm_bg.js +430 -446
- package/core/wasm_bg.wasm +0 -0
- package/core/wasm_bg.wasm.d.ts +22 -25
- package/package.json +1 -1
- package/runtime/runtime.d.ts +154 -22
- package/runtime/runtime.js +210 -29
package/core/wasm.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type PayloadItem =
|
|
|
17
17
|
/**
|
|
18
18
|
* Paths to `!must_fill` markers nested *inside* `value` (the `value`
|
|
19
19
|
* projection itself is fill-free). Absent when the field has no nested
|
|
20
|
-
* placeholders. Preserved across `
|
|
20
|
+
* placeholders. Preserved across `insertCard` / `makeCard`.
|
|
21
21
|
*/
|
|
22
22
|
nestedFills?: PathStep[][];
|
|
23
23
|
}
|
|
@@ -27,7 +27,7 @@ export type PayloadItem =
|
|
|
27
27
|
* A single card block, as read back from a document: returned by
|
|
28
28
|
* `Document.main` / `Document.cards` / `Document.removeCard` / `Quill.seedCard`
|
|
29
29
|
* / `Document.makeCard`. To feed a card *into* a document use `CardInput`
|
|
30
|
-
* (which `
|
|
30
|
+
* (which `insertCard` accepts); every `Card` is a valid `CardInput`,
|
|
31
31
|
* so a card read from one document pushes straight into another.
|
|
32
32
|
*
|
|
33
33
|
* `$` system entries are hoisted to named fields: `kind` (the `$kind`, empty
|
|
@@ -44,19 +44,19 @@ export interface Card {
|
|
|
44
44
|
seed?: Record<string, unknown>;
|
|
45
45
|
payloadItems: PayloadItem[];
|
|
46
46
|
/**
|
|
47
|
-
* The card body as canonical `
|
|
48
|
-
* Always this
|
|
47
|
+
* The card body as canonical `Content` — the source-of-truth content model.
|
|
48
|
+
* Always this content shape on read, never a markdown string. For the markdown
|
|
49
49
|
* projection call the codec `exportMarkdown(card.body)`. Write a body back
|
|
50
50
|
* with `doc.install(addr, rt)` / `doc.revise(addr, md)`, or via `CardInput.body`.
|
|
51
51
|
*/
|
|
52
|
-
body:
|
|
52
|
+
body: Content;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* A card written *into* a document — the input twin of `Card`, accepted by
|
|
57
|
-
* `Document.
|
|
58
|
-
* takes a markdown `string` (imported to the
|
|
59
|
-
* needn't build the `
|
|
57
|
+
* `Document.insertCard`. Like `Card` but `body` also
|
|
58
|
+
* takes a markdown `string` (imported to the content, so a markdown / LLM writer
|
|
59
|
+
* needn't build the `Content` shape), and every field but `kind` is optional —
|
|
60
60
|
* an absent field defaults (no payload items, an empty body). Write one inline
|
|
61
61
|
* (`{ kind, body }`) or build it with `Document.makeCard`.
|
|
62
62
|
*/
|
|
@@ -67,26 +67,26 @@ export interface CardInput {
|
|
|
67
67
|
ext?: Record<string, unknown>;
|
|
68
68
|
seed?: Record<string, unknown>;
|
|
69
69
|
payloadItems?: PayloadItem[];
|
|
70
|
-
body?:
|
|
70
|
+
body?: Content | string;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
* Canonical richtext
|
|
74
|
+
* Canonical richtext content — the content model for a card body (and richtext
|
|
75
75
|
* fields). One text sequence over a single coordinate space (Unicode scalar
|
|
76
76
|
* values): `text` plus line attributes, anchored `marks`, and embedded
|
|
77
77
|
* `islands`. Every edit is a splice; markdown is a projection, not the model.
|
|
78
|
-
* Mirrors `
|
|
78
|
+
* Mirrors `quillmark_content::serial`'s canonical JSON encoding.
|
|
79
79
|
*/
|
|
80
|
-
export interface
|
|
80
|
+
export interface Content {
|
|
81
81
|
text: string;
|
|
82
|
-
lines:
|
|
83
|
-
marks:
|
|
84
|
-
islands:
|
|
82
|
+
lines: ContentLine[];
|
|
83
|
+
marks: ContentMark[];
|
|
84
|
+
islands: ContentIsland[];
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
/** One `\n`-separated segment of `
|
|
88
|
-
export type
|
|
89
|
-
containers:
|
|
87
|
+
/** One `\n`-separated segment of `Content.text`, in order. */
|
|
88
|
+
export type ContentLine = {
|
|
89
|
+
containers: ContentContainer[];
|
|
90
90
|
/** A within-block hard line break rather than a new block. Omitted (false) in the common case. */
|
|
91
91
|
continues?: boolean;
|
|
92
92
|
} & (
|
|
@@ -98,20 +98,20 @@ export type RichTextLine = {
|
|
|
98
98
|
);
|
|
99
99
|
|
|
100
100
|
/** An ancestor block a line nests inside, outermost first. */
|
|
101
|
-
export type
|
|
101
|
+
export type ContentContainer =
|
|
102
102
|
| { container: "list_item"; ordered: boolean; start: number; ordinal: number }
|
|
103
103
|
| { container: "quote" };
|
|
104
104
|
|
|
105
|
-
/** A mark over char range `[start, end)` into `
|
|
106
|
-
export type
|
|
105
|
+
/** A mark over char range `[start, end)` into `Content.text`. */
|
|
106
|
+
export type ContentMark = { start: number; end: number } & (
|
|
107
107
|
| { type: "strong" | "emph" | "underline" | "strike" | "code" }
|
|
108
108
|
| { type: "link"; url: string }
|
|
109
109
|
| { type: "anchor"; id: string }
|
|
110
110
|
| { type: string; attrs: unknown }
|
|
111
111
|
);
|
|
112
112
|
|
|
113
|
-
/** A structured object (table, figure, …) occupying one island slot in `
|
|
114
|
-
export interface
|
|
113
|
+
/** A structured object (table, figure, …) occupying one island slot in `Content.text`. */
|
|
114
|
+
export interface ContentIsland {
|
|
115
115
|
id: string;
|
|
116
116
|
type: string;
|
|
117
117
|
props: unknown;
|
|
@@ -120,10 +120,16 @@ export interface RichTextIsland {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
|
-
* A
|
|
124
|
-
* `
|
|
125
|
-
*
|
|
126
|
-
*
|
|
123
|
+
* A write address — one navigation concept for the whole `Document` surface. An
|
|
124
|
+
* absent `field` targets the card body; an absent `card` targets the main card.
|
|
125
|
+
* `{}` is the main-card body; `{ card: 2 }` the body of the composable card at
|
|
126
|
+
* index 2; `{ field: "intro" }` the main card's `intro` field; `{ card: 2,
|
|
127
|
+
* field: "intro" }` a card field.
|
|
128
|
+
*
|
|
129
|
+
* On the `Addr`-taking verbs a **bare string** is shorthand for `{ field: name }`
|
|
130
|
+
* — `doc.storeField("qty", 3)`, `doc.revise("intro", md)` — the one coercion
|
|
131
|
+
* rule. A bare number is *not* an addr (`{ card: 2 }` is the self-documenting
|
|
132
|
+
* spelling), so no third navigation idiom re-fragments the surface.
|
|
127
133
|
*/
|
|
128
134
|
export interface Addr {
|
|
129
135
|
card?: number;
|
|
@@ -131,7 +137,17 @@ export interface Addr {
|
|
|
131
137
|
}
|
|
132
138
|
|
|
133
139
|
/**
|
|
134
|
-
* A
|
|
140
|
+
* A card-only address — the axis the card-scoped verbs (`storeFields`,
|
|
141
|
+
* `storeExt`, `getExt`, `commitFields`, …) take. An absent `card` targets the
|
|
142
|
+
* main card. A present `field` throws: a card address takes only `card`, and a
|
|
143
|
+
* would-be nested write is a bug the error names rather than silently ignores.
|
|
144
|
+
*/
|
|
145
|
+
export interface CardAddr {
|
|
146
|
+
card?: number;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* A text-splice change set over the USV content (CodeMirror `ChangeSet`
|
|
135
151
|
* semantics) — plain, structured-clone-able data. Returned by `revise` and by
|
|
136
152
|
* the `rebase` codec; map a stored position through it with `mapPos`.
|
|
137
153
|
*/
|
|
@@ -143,9 +159,9 @@ export interface Delta {
|
|
|
143
159
|
export type Assoc = "before" | "after";
|
|
144
160
|
|
|
145
161
|
/**
|
|
146
|
-
* A mark edit in
|
|
147
|
-
* `
|
|
148
|
-
* anchor by id.
|
|
162
|
+
* A mark edit in final-text coordinates (post-delta, post-line-op). `add` /
|
|
163
|
+
* `remove` carry the `ContentMark` vocabulary (`{ type, … }`); `removeAnchor`
|
|
164
|
+
* drops one identity anchor by id.
|
|
149
165
|
*/
|
|
150
166
|
export type MarkOp =
|
|
151
167
|
| ({ op: "add" | "remove"; start: number; end: number } & (
|
|
@@ -156,7 +172,13 @@ export type MarkOp =
|
|
|
156
172
|
))
|
|
157
173
|
| { op: "removeAnchor"; id: string };
|
|
158
174
|
|
|
159
|
-
/**
|
|
175
|
+
/**
|
|
176
|
+
* A line/block edit. `split`/`join` splice `\n`; `setKind`/`setContainers`/
|
|
177
|
+
* `setContinues` touch metadata. `setContinues` sets/clears a line's within-block
|
|
178
|
+
* hard-break flag (`ContentLine.continues`) — the op-grained way to lower a
|
|
179
|
+
* Shift+Enter hard break or a new code-fence interior line; `continues: true` on
|
|
180
|
+
* line 0 is rejected (nothing precedes it to continue).
|
|
181
|
+
*/
|
|
160
182
|
export type LineOp =
|
|
161
183
|
| { op: "split"; at: number }
|
|
162
184
|
| { op: "join"; line: number }
|
|
@@ -165,10 +187,11 @@ export type LineOp =
|
|
|
165
187
|
| { kind: "heading"; level: number }
|
|
166
188
|
| { kind: "code"; lang?: string }
|
|
167
189
|
))
|
|
168
|
-
| { op: "setContainers"; line: number; containers:
|
|
190
|
+
| { op: "setContainers"; line: number; containers: ContentContainer[] }
|
|
191
|
+
| { op: "setContinues"; line: number; continues: boolean };
|
|
169
192
|
|
|
170
193
|
/**
|
|
171
|
-
* A committed
|
|
194
|
+
* A committed content edit bundle for `applyChange`: a text `delta` (default no
|
|
172
195
|
* text change), then `lineOps`, then `markOps` (mark ranges are in post-delta
|
|
173
196
|
* coordinates). Every field is optional.
|
|
174
197
|
*/
|
|
@@ -213,7 +236,7 @@ export interface QuillCardBody {
|
|
|
213
236
|
* zero-fills the field). There is no separate `required` axis.
|
|
214
237
|
*/
|
|
215
238
|
export interface QuillFieldSchema {
|
|
216
|
-
type: "string" | "number" | "integer" | "boolean" | "array" | "object" | "datetime" | "richtext" | "plaintext" | "enum";
|
|
239
|
+
type: "string" | "number" | "integer" | "boolean" | "array" | "object" | "date" | "datetime" | "richtext" | "plaintext" | "enum";
|
|
217
240
|
description?: string;
|
|
218
241
|
default?: unknown;
|
|
219
242
|
example?: unknown;
|
|
@@ -294,28 +317,16 @@ export class Document {
|
|
|
294
317
|
free(): void;
|
|
295
318
|
[Symbol.dispose](): void;
|
|
296
319
|
/**
|
|
297
|
-
*
|
|
298
|
-
* body from optional markdown, and append it — the ABI under
|
|
299
|
-
* `writer.addCard`. Fuses `makeCard` + typed commit + `pushCard`
|
|
300
|
-
* transactionally: the card is committed in full before it joins the
|
|
301
|
-
* document, so a rejected field (or an invalid kind or body) leaves the
|
|
302
|
-
* document untouched. Field errors throw the same per-field diagnostic
|
|
303
|
-
* bundle as [`commitFields`](Self::commit_fields), including an
|
|
304
|
-
* `[EditError::UnknownField]` per undeclared name; an invalid kind or body
|
|
305
|
-
* throws a single-entry bundle keyed `$kind` / `$body`.
|
|
306
|
-
*/
|
|
307
|
-
addCard(quill: Quill, kind: string, fields?: Record<string, unknown>, body?: string): void;
|
|
308
|
-
/**
|
|
309
|
-
* **Apply** a committed corpus edit `bundle` (`{ delta?, lineOps?, markOps? }`)
|
|
320
|
+
* **Apply** a committed content edit `bundle` (`{ delta?, lineOps?, markOps? }`)
|
|
310
321
|
* at `addr` — the editor splice: text delta first, then line ops, then mark
|
|
311
|
-
* ops (mark ranges in
|
|
322
|
+
* ops (mark ranges in final-text coordinates), each all-or-nothing. An absent
|
|
312
323
|
* `addr.field` targets the body, an absent `addr.card` the main card.
|
|
313
324
|
*
|
|
314
325
|
* Throws on an out-of-range card, a field that is not richtext, a malformed
|
|
315
326
|
* bundle, or an op that applies out of bounds (the value is unchanged on a
|
|
316
327
|
* failed apply).
|
|
317
328
|
*/
|
|
318
|
-
applyChange(addr: Addr, bundle: ChangeBundle): void;
|
|
329
|
+
applyChange(addr: Addr | string, bundle: ChangeBundle): void;
|
|
319
330
|
/**
|
|
320
331
|
* Authoring-ergonomics header introducing a blueprint to an LLM/MCP
|
|
321
332
|
* consumer for the given `quillName`. Re-exposes core's canonical text for
|
|
@@ -323,61 +334,22 @@ export class Document {
|
|
|
323
334
|
* uniform.
|
|
324
335
|
*/
|
|
325
336
|
static blueprintInstruction(quill_name: string): string;
|
|
326
|
-
clone(): Document;
|
|
327
337
|
/**
|
|
328
|
-
*
|
|
329
|
-
* twin of [`
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
* the same typed-mismatch / name errors as `commitField` — including
|
|
334
|
-
* `[EditError::UnknownField]` for a field the card-kind schema does not
|
|
335
|
-
* declare (an unknown `$kind` has no schema, so every field is undeclared).
|
|
336
|
-
*/
|
|
337
|
-
commitCardField(quill: Quill, index: number, name: string, value: any): void;
|
|
338
|
-
/**
|
|
339
|
-
* Batched twin of [`commitCardField`](Document::commit_card_field):
|
|
340
|
-
* typed-commit several fields on the card at `index` atomically, resolving
|
|
341
|
-
* each field's type from the card's `$kind` schema in `quill`. All-or-nothing
|
|
342
|
-
* with the same per-field-diagnostic contract as
|
|
343
|
-
* [`commitFields`](Document::commit_fields), including an
|
|
344
|
-
* `[EditError::UnknownField]` diagnostic per undeclared name. Throws
|
|
345
|
-
* `[EditError::IndexOutOfRange]` when `index` is out of range.
|
|
346
|
-
*/
|
|
347
|
-
commitCardFields(quill: Quill, index: number, fields: Record<string, unknown>): void;
|
|
348
|
-
/**
|
|
349
|
-
* Typed field write on the main card, resolving the field's schema `type`
|
|
350
|
-
* from `quill` — the one write verb for **every** field type (richtext,
|
|
351
|
-
* scalar, array, object). The schema carries the `inline` constraint, so no
|
|
352
|
-
* type token or flag is passed. A richtext-typed field stores the canonical
|
|
353
|
-
* corpus, so identity marks (anchors, island ids) and corpus-only marks
|
|
354
|
-
* (e.g. `underline`) live on it and survive compiles and the storage DTO.
|
|
355
|
-
* Values use the encoding the seam already speaks: a corpus object
|
|
356
|
-
* or markdown string for richtext, a scalar/array/object otherwise.
|
|
357
|
-
*
|
|
358
|
-
* A field declared in the schema is strict-committed — a mismatch throws
|
|
359
|
-
* now, not at render. A name the schema does not declare throws
|
|
360
|
-
* `[EditError::UnknownField]` rather than falling to the opaque store: on
|
|
361
|
-
* the typed path it is a typo. Use [`setField`](Document::set_field) when
|
|
362
|
-
* opaque storage is the intent. Also throws `[EditError::FieldConform]` /
|
|
363
|
-
* `[EditError::FieldRichtextDecode]` / `[EditError::FieldRichtextNotInline]`
|
|
364
|
-
* on a typed mismatch and `[EditError::InvalidFieldName]` on a malformed
|
|
365
|
-
* name.
|
|
366
|
-
*
|
|
367
|
-
* The `quill` handle is passed per call because a `Document` carries only a
|
|
368
|
-
* `$quill` reference, not the resolved schema.
|
|
338
|
+
* A single composable card by index — the whole `Card`, the card-indexed
|
|
339
|
+
* twin of the [`main`](Self::main) getter, so reading one card need not
|
|
340
|
+
* materialize every card via [`cards`](Self::cards). An out-of-range
|
|
341
|
+
* `index` throws `[EditError::IndexOutOfRange]`, matching the card write
|
|
342
|
+
* verbs.
|
|
369
343
|
*/
|
|
370
|
-
|
|
344
|
+
card(index: number): Card;
|
|
371
345
|
/**
|
|
372
|
-
*
|
|
373
|
-
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
* error and the thrown error's `diagnostics` carry one entry per offending
|
|
377
|
-
* field, including an `[EditError::UnknownField]` for any name the schema
|
|
378
|
-
* does not declare, so a whole-form submit sees every typo in one pass.
|
|
346
|
+
* The index of the first composable card whose `$id` equals `id`, or
|
|
347
|
+
* `undefined` when none carries it. Resolves the canonical durable address
|
|
348
|
+
* without a hand-rolled scan over [`cards`](Self::cards); `$id` is
|
|
349
|
+
* non-unique by design, so the first match wins.
|
|
379
350
|
*/
|
|
380
|
-
|
|
351
|
+
cardIndexById(id: string): number | undefined;
|
|
352
|
+
clone(): Document;
|
|
381
353
|
/**
|
|
382
354
|
* Schema version this build writes via [`toJson`](Document::to_json).
|
|
383
355
|
* Tracks the `Document` model version (not the running crate version):
|
|
@@ -417,30 +389,54 @@ export class Document {
|
|
|
417
389
|
*/
|
|
418
390
|
static fromMarkdown(markdown: string): Document;
|
|
419
391
|
/**
|
|
420
|
-
* Read
|
|
421
|
-
* object for a richtext field, a scalar/array/object otherwise), or
|
|
422
|
-
*
|
|
423
|
-
*
|
|
424
|
-
*
|
|
392
|
+
* Read the value at `addr` — the raw stored payload value of a field (a
|
|
393
|
+
* content object for a richtext field, a scalar/array/object otherwise), or
|
|
394
|
+
* the **body content** when `addr.field` is absent. A bare string is `Addr`
|
|
395
|
+
* shorthand for `{ field }`. Reads are total over the field axis: an absent
|
|
396
|
+
* field is `undefined`; only an out-of-range `addr.card` throws
|
|
397
|
+
* `[EditError::IndexOutOfRange]`. Reads need no schema, so they live on
|
|
398
|
+
* `Document`, not the typed writer; for the markdown projection of a
|
|
399
|
+
* richtext value use [`getMarkdown`](Self::get_markdown).
|
|
425
400
|
*/
|
|
426
|
-
get(
|
|
401
|
+
get(addr: Addr | string): unknown;
|
|
427
402
|
/**
|
|
428
|
-
* The
|
|
429
|
-
*
|
|
430
|
-
*
|
|
431
|
-
*
|
|
432
|
-
* `bodyMarkdown` getters dropped in #925; call it only when markdown is what
|
|
433
|
-
* you need out.
|
|
403
|
+
* The whole `$ext` map at `addr` (a card address, absent `card` = main), or
|
|
404
|
+
* `undefined` when the card carries none. The fine-grained `$ext` read —
|
|
405
|
+
* your own state without serializing the whole card. Throws on a present
|
|
406
|
+
* `field` (a card address takes only `card`) or an out-of-range card.
|
|
434
407
|
*/
|
|
435
|
-
|
|
408
|
+
getExt(addr?: CardAddr): Record<string, unknown> | undefined;
|
|
436
409
|
/**
|
|
437
|
-
*
|
|
438
|
-
* `
|
|
410
|
+
* The value stored under `$ext[ns]` at `addr` (a card address, absent `card`
|
|
411
|
+
* = main), or `undefined`. The namespace-scoped `$ext` read — your own slot
|
|
412
|
+
* without a whole-card serialize, and non-destructive (unlike
|
|
413
|
+
* `removeExtNamespace`). Throws on a present `field` or an out-of-range card.
|
|
414
|
+
*/
|
|
415
|
+
getExtNamespace(addr: CardAddr, ns: string): unknown;
|
|
416
|
+
/**
|
|
417
|
+
* The **body** markdown projection — the main body, or a composable card's
|
|
418
|
+
* body (`{ card }`) — the on-demand, lossy export (content-only marks do not
|
|
419
|
+
* survive markdown). A body's type is a format fact, not a schema fact, so
|
|
420
|
+
* this read stays quill-free; a body is never absent.
|
|
421
|
+
*
|
|
422
|
+
* `addr` is an optional **card address** (`{ card }`, absent = main). A
|
|
423
|
+
* present `field` throws — a field's markdown is read through the
|
|
424
|
+
* schema-plane `quill.view(doc).get(field)`, which interprets by declared
|
|
425
|
+
* type (#978). An out-of-range `addr.card` throws.
|
|
439
426
|
*/
|
|
440
|
-
|
|
427
|
+
getMarkdown(addr?: CardAddr): string;
|
|
441
428
|
/**
|
|
442
|
-
*
|
|
443
|
-
*
|
|
429
|
+
* Insert a card — the single insertion verb: `at` absent appends, a number
|
|
430
|
+
* inserts at that index (must be in `0..=cards.length`). Accepts a
|
|
431
|
+
* `CardInput` — a card read back (`cards` / `removeCard` / `quill.seedCard`),
|
|
432
|
+
* a [`makeCard`](Document::make_card) result, or a bare `{ kind, body }`
|
|
433
|
+
* (every returned `Card` is a valid `CardInput`). Throws if `card.kind` is
|
|
434
|
+
* not a valid kind name, or if `at` is out of range.
|
|
435
|
+
*/
|
|
436
|
+
insertCard(card: CardInput, at?: number): void;
|
|
437
|
+
/**
|
|
438
|
+
* **Install** a richtext value at `addr` — **value semantics**, content only.
|
|
439
|
+
* Stores exactly `rt` (a canonical `Content` content object); the identity
|
|
444
440
|
* anchors of any previous value are gone. An absent `addr.field` targets the
|
|
445
441
|
* body, an absent `addr.card` the main card. For "here's new markdown," use
|
|
446
442
|
* [`revise`](Document::revise); the cold-import path is spelled at the call
|
|
@@ -448,9 +444,16 @@ export class Document {
|
|
|
448
444
|
* source.
|
|
449
445
|
*
|
|
450
446
|
* Throws on an out-of-range card, a malformed field name, or an `rt` that is
|
|
451
|
-
* not a canonical
|
|
447
|
+
* not a canonical content object.
|
|
448
|
+
*/
|
|
449
|
+
install(addr: Addr | string, rt: Content): void;
|
|
450
|
+
/**
|
|
451
|
+
* Whether the field at `addr` is marked `!must_fill`. A bare string is `Addr`
|
|
452
|
+
* shorthand for `{ field }`. `false` for an absent field (truthful — it isn't
|
|
453
|
+
* marked) and for a body address (a body is never a fill). Only an
|
|
454
|
+
* out-of-range `addr.card` throws.
|
|
452
455
|
*/
|
|
453
|
-
|
|
456
|
+
isFill(addr: Addr | string): boolean;
|
|
454
457
|
/**
|
|
455
458
|
* Replace this document's contents **in place** from a versioned storage
|
|
456
459
|
* DTO string — the mutating twin of the static
|
|
@@ -465,10 +468,10 @@ export class Document {
|
|
|
465
468
|
loadJson(json: string): void;
|
|
466
469
|
/**
|
|
467
470
|
* Build a fresh `Card` from a kind and a flat field map — the ergonomic
|
|
468
|
-
* constructor for `
|
|
471
|
+
* constructor for `insertCard`. `fields` is an optional
|
|
469
472
|
* `Record<string, unknown>` (each entry becomes a card field, in
|
|
470
473
|
* insertion order); `body` defaults to `""`. Kind validity is checked by
|
|
471
|
-
* `
|
|
474
|
+
* `insertCard`, not here.
|
|
472
475
|
*/
|
|
473
476
|
static makeCard(kind: string, fields?: Record<string, unknown>, body?: string): Card;
|
|
474
477
|
/**
|
|
@@ -484,14 +487,6 @@ export class Document {
|
|
|
484
487
|
* Throws on an invalid quill reference. Mirrors Python `Document(quill_ref)`.
|
|
485
488
|
*/
|
|
486
489
|
constructor(quill_ref: string);
|
|
487
|
-
/**
|
|
488
|
-
* Append a card to the end of the card list. Accepts a `CardInput` — a card
|
|
489
|
-
* read back (`cards` / `removeCard` / `quill.seedCard`), a
|
|
490
|
-
* [`makeCard`](Document::make_card) result, or a bare `{ kind, body }`
|
|
491
|
-
* (every returned `Card` is a valid `CardInput`). Throws if `card.kind` is
|
|
492
|
-
* not a valid kind name.
|
|
493
|
-
*/
|
|
494
|
-
pushCard(card: CardInput): void;
|
|
495
490
|
/**
|
|
496
491
|
* The canonical `$quill` reference grammar as author-facing text. Core is
|
|
497
492
|
* the single source of truth: drive schema `describe` and validation
|
|
@@ -502,54 +497,32 @@ export class Document {
|
|
|
502
497
|
static quillRefHint(): string;
|
|
503
498
|
removeCard(index: number): Card | undefined;
|
|
504
499
|
/**
|
|
505
|
-
* Remove the `$ext` map
|
|
506
|
-
*
|
|
507
|
-
*
|
|
500
|
+
* Remove the `$ext` map on the card `addr` targets *entirely*, returning the
|
|
501
|
+
* previous map or `undefined` — a blunt escape hatch that discards every
|
|
502
|
+
* namespace at once (prefer `removeExtNamespace`). `addr` is a card address
|
|
503
|
+
* (absent = main). Throws on a present `field` or an out-of-range card.
|
|
508
504
|
*/
|
|
509
|
-
|
|
505
|
+
removeExt(addr?: CardAddr): Record<string, unknown> | undefined;
|
|
510
506
|
/**
|
|
511
|
-
* Remove `
|
|
512
|
-
*
|
|
513
|
-
*
|
|
507
|
+
* Remove `$ext[ns]` on the card `addr` targets, returning its value or
|
|
508
|
+
* `undefined`; drops `$ext` once empty. `addr` is a card address (absent =
|
|
509
|
+
* main). Preserves sibling namespaces. Throws on a present `field` or an
|
|
510
|
+
* out-of-range card.
|
|
514
511
|
*/
|
|
515
|
-
|
|
512
|
+
removeExtNamespace(addr: CardAddr, ns: string): any;
|
|
516
513
|
/**
|
|
517
|
-
* Remove a field
|
|
518
|
-
*
|
|
514
|
+
* Remove a field at `addr`, returning the removed value or `undefined`. A
|
|
515
|
+
* bare string is `Addr` shorthand for `{ field }`. One `remove` verb serves
|
|
516
|
+
* every write lane. A body address throws; throws on an out-of-range card or
|
|
517
|
+
* a malformed name.
|
|
519
518
|
*/
|
|
520
|
-
|
|
521
|
-
/**
|
|
522
|
-
* Remove the `$ext` map from the main card *entirely*, returning the
|
|
523
|
-
* previous map or `undefined`. This is a blunt escape hatch that discards
|
|
524
|
-
* every namespace at once — prefer `removeExtNamespace` to clear only your
|
|
525
|
-
* own slot while leaving sibling consumers' state intact.
|
|
526
|
-
*/
|
|
527
|
-
removeExt(): Record<string, unknown> | undefined;
|
|
528
|
-
/**
|
|
529
|
-
* Remove `namespace` from the main card's `$ext` map, returning the value
|
|
530
|
-
* stored there or `undefined`. This is the recommended way to clear `$ext`
|
|
531
|
-
* state: sibling namespaces survive, and when the last namespace is removed
|
|
532
|
-
* the `$ext` entry is dropped entirely (not left as `$ext: {}`).
|
|
533
|
-
*/
|
|
534
|
-
removeExtNamespace(namespace: string): any;
|
|
535
|
-
/**
|
|
536
|
-
* Remove a payload field on the main card, returning the removed value or
|
|
537
|
-
* `undefined`. Throws if `name` does not match `[A-Za-z_][A-Za-z0-9_]*`.
|
|
538
|
-
*/
|
|
539
|
-
removeField(name: string): any;
|
|
519
|
+
removeField(addr: Addr | string): any;
|
|
540
520
|
/**
|
|
541
521
|
* Remove `cardKind` from the main card's `$seed` map, returning its
|
|
542
|
-
* overlay or `undefined`; drops `$seed` entirely once empty. Sibling
|
|
543
|
-
*
|
|
522
|
+
* overlay or `undefined`; drops `$seed` entirely once empty. Sibling kinds
|
|
523
|
+
* survive. `$seed` is main-only, so this takes no address.
|
|
544
524
|
*/
|
|
545
525
|
removeSeedNamespace(card_kind: string): any;
|
|
546
|
-
/**
|
|
547
|
-
* **Deprecated** — alias for `revise({}, markdown)`, kept one release cycle.
|
|
548
|
-
* Revise the main card's body from a markdown string (edit semantics: a
|
|
549
|
-
* `diff_import` that rebases surviving anchors). Discards the text delta;
|
|
550
|
-
* call [`revise`](Document::revise) to receive it.
|
|
551
|
-
*/
|
|
552
|
-
replaceBody(body: string): void;
|
|
553
526
|
/**
|
|
554
527
|
* **Revise** the richtext value at `addr` from a markdown string — **edit
|
|
555
528
|
* semantics**, the default write path, returning the text [`Delta`]. Imports
|
|
@@ -559,9 +532,9 @@ export class Document {
|
|
|
559
532
|
* absent `addr.card` the main card; an absent field cold-imports from empty.
|
|
560
533
|
*
|
|
561
534
|
* Throws on an out-of-range card, a malformed field name, a present
|
|
562
|
-
* non-
|
|
535
|
+
* non-content field value, or an over-nested markdown input.
|
|
563
536
|
*/
|
|
564
|
-
revise(addr: Addr, markdown: string): Delta;
|
|
537
|
+
revise(addr: Addr | string, markdown: string): Delta;
|
|
565
538
|
/**
|
|
566
539
|
* Read the `schema` version tag from a raw storage DTO string without a
|
|
567
540
|
* full parse, or `undefined`. Returns unknown future versions as-is —
|
|
@@ -570,30 +543,13 @@ export class Document {
|
|
|
570
543
|
*/
|
|
571
544
|
static schemaVersionOf(json: string): string | undefined;
|
|
572
545
|
/**
|
|
573
|
-
*
|
|
574
|
-
*
|
|
575
|
-
*
|
|
546
|
+
* The main card's `$seed` overlay object for `kind` (the `$seed[kind]`
|
|
547
|
+
* entry), or `undefined` when absent. The cheap read that feeds
|
|
548
|
+
* `quill.seedCard(kind, overlay)` without serializing the whole main card
|
|
549
|
+
* via [`main`](Self::main) to fish out one key — and it keeps `seedCard`
|
|
550
|
+
* pure: the quill still never reads the document.
|
|
576
551
|
*/
|
|
577
|
-
|
|
578
|
-
/**
|
|
579
|
-
* Merge `value` into the composable card's `$ext` map under `namespace`,
|
|
580
|
-
* preserving sibling namespaces. The card-indexed twin of `setExtNamespace`.
|
|
581
|
-
* Throws if out of range or `value` cannot be serialized.
|
|
582
|
-
*/
|
|
583
|
-
setCardExtNamespace(index: number, namespace: string, value: any): void;
|
|
584
|
-
/**
|
|
585
|
-
* Set a field on the card at `index` — the card-indexed twin of
|
|
586
|
-
* [`setField`](Document::set_field). Stores the value opaquely.
|
|
587
|
-
* Throws if `index` is out of range, `name` is reserved or invalid.
|
|
588
|
-
*/
|
|
589
|
-
setCardField(index: number, name: string, value: any): void;
|
|
590
|
-
/**
|
|
591
|
-
* Batched twin of [`setCardField`](Document::set_card_field): set
|
|
592
|
-
* several fields on the card at `index` atomically. Same all-or-nothing,
|
|
593
|
-
* one-diagnostic-per-field contract as [`setFields`](Document::set_fields).
|
|
594
|
-
* Throws if `index` is out of range.
|
|
595
|
-
*/
|
|
596
|
-
setCardFields(index: number, fields: Record<string, unknown>): void;
|
|
552
|
+
seedOverlay(kind: string): Record<string, unknown> | undefined;
|
|
597
553
|
/**
|
|
598
554
|
* Replace the kind of the card at `index`. Payload and body are untouched;
|
|
599
555
|
* schema-aware migration is the caller's responsibility.
|
|
@@ -601,50 +557,61 @@ export class Document {
|
|
|
601
557
|
*/
|
|
602
558
|
setCardKind(index: number, new_kind: string): void;
|
|
603
559
|
/**
|
|
604
|
-
* Replace the
|
|
605
|
-
* object; throws otherwise. `$ext` carries out-of-band consumer state and
|
|
606
|
-
* never reaches the rendered output. Pass `{}` to record an explicit
|
|
607
|
-
* empty `$ext`.
|
|
560
|
+
* Replace the QUILL reference string. Throws if `ref_str` is invalid.
|
|
608
561
|
*/
|
|
609
|
-
|
|
562
|
+
setQuillRef(ref_str: string): void;
|
|
610
563
|
/**
|
|
611
|
-
*
|
|
612
|
-
*
|
|
613
|
-
*
|
|
614
|
-
* `$ext
|
|
564
|
+
* Replace the opaque `$ext` map on the card `addr` targets (a card address,
|
|
565
|
+
* absent `card` = main). `value` must be a plain object. `$ext` carries
|
|
566
|
+
* out-of-band consumer state and never reaches the rendered output; pass
|
|
567
|
+
* `{}` for an explicit empty `$ext`. Quill-free and verbatim — an opaque
|
|
568
|
+
* `store` verb. Throws on a present `field` or an out-of-range card.
|
|
615
569
|
*/
|
|
616
|
-
|
|
570
|
+
storeExt(addr: CardAddr, value: any): void;
|
|
617
571
|
/**
|
|
618
|
-
*
|
|
619
|
-
*
|
|
620
|
-
*
|
|
572
|
+
* Merge `value` into `$ext[ns]` on the card `addr` targets, preserving
|
|
573
|
+
* sibling namespaces — the recommended `$ext` write. `addr` is a card
|
|
574
|
+
* address (absent = main). Quill-free and verbatim — an opaque `store` verb.
|
|
575
|
+
* Throws on a present `field` or an out-of-range card.
|
|
621
576
|
*/
|
|
622
|
-
|
|
577
|
+
storeExtNamespace(addr: CardAddr, ns: string, value: any): void;
|
|
623
578
|
/**
|
|
624
|
-
*
|
|
625
|
-
*
|
|
626
|
-
*
|
|
627
|
-
*
|
|
628
|
-
*
|
|
629
|
-
*
|
|
579
|
+
* Store a field verbatim at `addr` — the opaque store (**store** = verbatim,
|
|
580
|
+
* coercion deferred to render; the typed write is
|
|
581
|
+
* [`commitField`](Document::commit_field)). A bare string is `Addr`
|
|
582
|
+
* shorthand for `{ field }`, so `doc.storeField("qty", 3)` reads as written;
|
|
583
|
+
* `{ card: 2, field: "qty" }` targets a composable card. Clears any
|
|
584
|
+
* `!must_fill` marker. A body address (no `field`) throws — a body is never
|
|
585
|
+
* opaque; write it with `revise` / `install` / `writer.setBody`. Throws on
|
|
586
|
+
* an out-of-range card or a malformed name.
|
|
630
587
|
*/
|
|
631
|
-
|
|
588
|
+
storeField(addr: Addr | string, value: any): void;
|
|
632
589
|
/**
|
|
633
|
-
*
|
|
634
|
-
*
|
|
590
|
+
* Store several fields verbatim and atomically on the card `addr` targets —
|
|
591
|
+
* the opaque store's batch. `addr` is a **card address** (`{ card }`, absent
|
|
592
|
+
* = main); a present `field` throws. The batch verb takes the address first
|
|
593
|
+
* and is never shape-overloaded, because `card` is a legal field name:
|
|
594
|
+
* `storeFields({}, fields)` is the main card, `storeFields({ card: 2 },
|
|
595
|
+
* fields)` a composable one — never ambiguous with "set field `card`".
|
|
596
|
+
* Nothing is applied on error; the thrown error's `diagnostics` carry one
|
|
597
|
+
* entry per offending field. Throws on an out-of-range card.
|
|
635
598
|
*/
|
|
636
|
-
|
|
599
|
+
storeFields(addr: CardAddr, fields: Record<string, unknown>): void;
|
|
637
600
|
/**
|
|
638
|
-
*
|
|
601
|
+
* Store a field verbatim at `addr` and mark it `!must_fill` — the opaque
|
|
602
|
+
* store's fill variant, card-capable (a bare string or `{ field }` for main,
|
|
603
|
+
* `{ card, field }` for a composable card). A body address throws. Same
|
|
604
|
+
* validation as [`storeField`](Document::store_field).
|
|
639
605
|
*/
|
|
640
|
-
|
|
606
|
+
storeFill(addr: Addr | string, value: any): void;
|
|
641
607
|
/**
|
|
642
|
-
* Merge a card-kind's seed `overlay` into the main card's `$seed` map
|
|
643
|
-
* under `cardKind`, preserving sibling kinds
|
|
644
|
-
*
|
|
645
|
-
*
|
|
608
|
+
* Merge a card-kind's seed `overlay` into the **main** card's `$seed` map
|
|
609
|
+
* under `cardKind`, preserving sibling kinds — `$seed` lives on the main
|
|
610
|
+
* card by model, so this takes no address. Sets the starting values new
|
|
611
|
+
* cards of that kind spawn with. Quill-free and verbatim — an opaque `store`
|
|
612
|
+
* verb. Throws if `overlay` cannot be serialized or nests too deep.
|
|
646
613
|
*/
|
|
647
|
-
|
|
614
|
+
storeSeedNamespace(card_kind: string, overlay: any): void;
|
|
648
615
|
/**
|
|
649
616
|
* Serialize this document to a versioned storage DTO string.
|
|
650
617
|
*
|
|
@@ -702,9 +669,9 @@ export class Quill {
|
|
|
702
669
|
* layering an optional per-kind seed `overlay` over the schema-example
|
|
703
670
|
* base (`overlay › example › absent`). Returns `undefined` if `cardKind`
|
|
704
671
|
* is not declared in this quill's schema, else a `Card` that feeds
|
|
705
|
-
* straight into `Document.
|
|
672
|
+
* straight into `Document.insertCard`.
|
|
706
673
|
*
|
|
707
|
-
* Pass `document.
|
|
674
|
+
* Pass `document.seedOverlay(cardKind)` as `overlay` so a card added to a
|
|
708
675
|
* template-derived document inherits its curated starting values; omit it
|
|
709
676
|
* (or pass `undefined` / `null`) for the bare schema seed. `overlay` is a
|
|
710
677
|
* plain object — this reads the document, it does not mutate it.
|
|
@@ -776,19 +743,19 @@ export class Quill {
|
|
|
776
743
|
}
|
|
777
744
|
|
|
778
745
|
/**
|
|
779
|
-
* Export a canonical `
|
|
780
|
-
* codec
|
|
781
|
-
*
|
|
746
|
+
* Export a canonical `Content` content to its markdown projection — the pure
|
|
747
|
+
* on-demand codec behind `exportMarkdown(card.body)`. Throws if `rt` is not a
|
|
748
|
+
* canonical content.
|
|
782
749
|
*/
|
|
783
|
-
export function exportMarkdown(rt:
|
|
750
|
+
export function exportMarkdown(rt: Content): string;
|
|
784
751
|
|
|
785
752
|
/**
|
|
786
|
-
* Import a markdown string to a canonical `
|
|
753
|
+
* Import a markdown string to a canonical `Content` content — the pure,
|
|
787
754
|
* document-free codec. Pair with `install(addr, importMarkdown(md))` to spell
|
|
788
755
|
* the cold (anchor-losing) write at the call site; prefer `revise` for edit
|
|
789
756
|
* semantics. Throws on an over-nested input.
|
|
790
757
|
*/
|
|
791
|
-
export function importMarkdown(markdown: string):
|
|
758
|
+
export function importMarkdown(markdown: string): Content;
|
|
792
759
|
|
|
793
760
|
/**
|
|
794
761
|
* Initialize the WASM module with panic hooks for better error messages
|
|
@@ -796,7 +763,7 @@ export function importMarkdown(markdown: string): RichText;
|
|
|
796
763
|
export function init(): void;
|
|
797
764
|
|
|
798
765
|
/**
|
|
799
|
-
* Map a base
|
|
766
|
+
* Map a base content position through a `delta` to its new position — the pure
|
|
800
767
|
* position-mapping codec an editor bridge composes to hold a caret stable
|
|
801
768
|
* across a `revise`. `assoc` decides the side of a same-position insertion
|
|
802
769
|
* (`"after"` moves past it). Throws on a malformed `delta`.
|
|
@@ -804,10 +771,10 @@ export function init(): void;
|
|
|
804
771
|
export function mapPos(delta: Delta, pos: number, assoc: Assoc): number;
|
|
805
772
|
|
|
806
773
|
/**
|
|
807
|
-
* Rebase `markdown` onto a `base`
|
|
808
|
-
* `revise`: cold-import + `diff_import`, returning the new `
|
|
774
|
+
* Rebase `markdown` onto a `base` content — the pure, document-free twin of
|
|
775
|
+
* `revise`: cold-import + `diff_import`, returning the new `content` and the
|
|
809
776
|
* text `delta` (surviving anchors rebased). Use it to compute a revise without
|
|
810
777
|
* a document in hand; `revise(addr, md)` fuses this with the store for
|
|
811
|
-
* atomicity. Throws on an over-nested markdown input or a non-
|
|
778
|
+
* atomicity. Throws on an over-nested markdown input or a non-content `base`.
|
|
812
779
|
*/
|
|
813
|
-
export function rebase(base:
|
|
780
|
+
export function rebase(base: Content, markdown: string): { content: Content; delta: Delta };
|