@quillmark/wasm 0.58.2-rc.6 → 0.59.0-rc.2

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/bundler/wasm.d.ts CHANGED
@@ -1,5 +1,18 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+
4
+ /**
5
+ * Input shape for `Document.pushCard` and `Document.insertCard`.
6
+ *
7
+ * Only `tag` is required. `fields` defaults to `{}`, `body` to `""`.
8
+ */
9
+ export interface CardInput {
10
+ tag: string;
11
+ fields?: Record<string, unknown>;
12
+ body?: string;
13
+ }
14
+
15
+
3
16
  export interface Artifact {
4
17
  format: OutputFormat;
5
18
  bytes: Uint8Array;
@@ -7,8 +20,10 @@ export interface Artifact {
7
20
  }
8
21
 
9
22
  export interface Card {
23
+ sentinel: string;
10
24
  tag: string;
11
- fields: Record<string, unknown>;
25
+ frontmatter: Record<string, unknown>;
26
+ frontmatterItems: FrontmatterItem[];
12
27
  body: string;
13
28
  }
14
29
 
@@ -40,6 +55,8 @@ export interface RenderResult {
40
55
  renderTimeMs: number;
41
56
  }
42
57
 
58
+ export type FrontmatterItem = { kind: "field"; key: string; value: unknown; fill?: boolean } | { kind: "comment"; text: string };
59
+
43
60
  export type OutputFormat = "pdf" | "svg" | "txt" | "png";
44
61
 
45
62
  export type Severity = "error" | "warning" | "note";
@@ -62,6 +79,15 @@ export class Document {
62
79
  private constructor();
63
80
  free(): void;
64
81
  [Symbol.dispose](): void;
82
+ /**
83
+ * Return a fresh `Document` handle with the same parse state.
84
+ *
85
+ * Mutations on the returned handle do not affect the original and
86
+ * vice versa. Parse-time warnings are snapshotted alongside the
87
+ * document — they describe the original parse, not the edit
88
+ * history of either handle.
89
+ */
90
+ clone(): Document;
65
91
  /**
66
92
  * Parse markdown into a typed Document.
67
93
  *
@@ -76,7 +102,7 @@ export class Document {
76
102
  *
77
103
  * Mutators never modify `warnings`.
78
104
  */
79
- insertCard(index: number, card: any): void;
105
+ insertCard(index: number, card: CardInput): void;
80
106
  /**
81
107
  * Move the card at `from` to position `to`.
82
108
  *
@@ -96,27 +122,30 @@ export class Document {
96
122
  *
97
123
  * Mutators never modify `warnings`.
98
124
  */
99
- pushCard(card: any): void;
125
+ pushCard(card: CardInput): void;
100
126
  /**
101
127
  * Remove the card at `index` and return it, or `undefined` if out of range.
102
128
  *
103
129
  * Mutators never modify `warnings`.
104
130
  */
105
- removeCard(index: number): any;
131
+ removeCard(index: number): Card | undefined;
106
132
  /**
107
- * Remove a frontmatter field, returning the removed value or `undefined`.
133
+ * Remove a frontmatter field on the main card, returning the removed value or `undefined`.
108
134
  *
109
135
  * Mutators never modify `warnings`.
110
136
  */
111
137
  removeField(name: string): any;
112
138
  /**
113
- * Replace the global Markdown body.
139
+ * Replace the main card's body (the global Markdown body).
114
140
  *
115
141
  * Mutators never modify `warnings`.
116
142
  */
117
143
  replaceBody(body: string): void;
118
144
  /**
119
- * Set a frontmatter field.
145
+ * Update a frontmatter field on the main card.
146
+ *
147
+ * Convenience method: equivalent to `doc.mainMut().setField(name, value)`.
148
+ * Clears any existing `!fill` marker on the field.
120
149
  *
121
150
  * Throws an `Error` whose message includes the `EditError` variant name and
122
151
  * details if `name` is reserved (`BODY`, `CARDS`, `QUILL`, `CARD`) or does
@@ -125,6 +154,16 @@ export class Document {
125
154
  * Mutators never modify `warnings`.
126
155
  */
127
156
  setField(name: string, value: any): void;
157
+ /**
158
+ * Update a frontmatter field on the main card AND mark it as `!fill`.
159
+ *
160
+ * Convenience method: equivalent to `doc.mainMut().setFill(name, value)`.
161
+ *
162
+ * Throws on invalid name (see [`setField`](Document::set_field)).
163
+ *
164
+ * Mutators never modify `warnings`.
165
+ */
166
+ setFill(name: string, value: any): void;
128
167
  /**
129
168
  * Replace the QUILL reference string.
130
169
  *
@@ -161,30 +200,27 @@ export class Document {
161
200
  */
162
201
  updateCardField(index: number, name: string, value: any): void;
163
202
  /**
164
- * Global Markdown body between frontmatter and the first card.
165
- *
166
- * Trailing newlines are stripped — those are structural separators in
167
- * the Markdown wire format, not content the consumer wrote.
168
- *
169
- * Empty string when no body is present.
170
- */
171
- readonly body: string;
172
- /**
173
- * Ordered list of card blocks as JS objects with `tag`, `fields`, and `body`.
203
+ * Ordered list of composable card blocks as typed `Card` objects.
174
204
  */
175
- readonly cards: any;
205
+ readonly cards: Card[];
176
206
  /**
177
- * Typed YAML frontmatter fields as a JS object (no QUILL, BODY, or CARDS keys).
207
+ * The document's main (entry) card.
208
+ *
209
+ * Carries the QUILL sentinel, the document-level frontmatter, and the
210
+ * global body. Frontmatter/body reads and mutations go through this
211
+ * handle — there are no document-level shortcuts after the rework.
212
+ *
213
+ * Allocates and serializes on each call — cache locally if read in a hot loop.
178
214
  */
179
- readonly frontmatter: any;
215
+ readonly main: Card;
180
216
  /**
181
217
  * The QUILL reference string (e.g. `"usaf_memo@0.1"`).
182
218
  */
183
219
  readonly quillRef: string;
184
220
  /**
185
- * Non-fatal parse-time warnings as a JS array of Diagnostic objects.
221
+ * Non-fatal parse-time warnings as an array of typed `Diagnostic` objects.
186
222
  */
187
- readonly warnings: any;
223
+ readonly warnings: Diagnostic[];
188
224
  }
189
225
 
190
226
  /**
@@ -227,6 +263,21 @@ export class Quill {
227
263
  * The resolved backend identifier (e.g. `"typst"`).
228
264
  */
229
265
  readonly backendId: string;
266
+ /**
267
+ * Read-only snapshot of the loaded `Quill.yaml`.
268
+ *
269
+ * Returns a plain JS object with `name`, `backend`, `description`,
270
+ * `version`, `author`, optional `example` (content of the example
271
+ * markdown, when the quill ships one), `supportedFormats` (backend's
272
+ * output formats as lowercase strings), `schema` (the raw main-card
273
+ * field schema as parsed from YAML — consumers that need validation
274
+ * run their own validator against this), and any additional
275
+ * unstructured keys declared inside the `quill:` section.
276
+ *
277
+ * Equivalent by value for the lifetime of the handle; the quill is
278
+ * immutable once constructed.
279
+ */
280
+ readonly metadata: any;
230
281
  }
231
282
 
232
283
  /**
@@ -242,9 +293,12 @@ export class Quillmark {
242
293
  /**
243
294
  * Load a quill from a file tree and attach the appropriate backend.
244
295
  *
245
- * The tree must be a `Map<string, Uint8Array>`.
296
+ * Accepts either a `Map<string, Uint8Array>` or a plain object
297
+ * (`Record<string, Uint8Array>`). Plain objects are walked via
298
+ * `Object.entries` at the boundary; the Rust side sees a single
299
+ * canonical shape.
246
300
  */
247
- quill(tree: any): Quill;
301
+ quill(tree: Map<string, Uint8Array>): Quill;
248
302
  }
249
303
 
250
304
  export class RenderSession {
@@ -30,38 +30,26 @@ export class Document {
30
30
  wasm.__wbg_document_free(ptr, 0);
31
31
  }
32
32
  /**
33
- * Global Markdown body between frontmatter and the first card.
34
- *
35
- * Trailing newlines are stripped — those are structural separators in
36
- * the Markdown wire format, not content the consumer wrote.
37
- *
38
- * Empty string when no body is present.
39
- * @returns {string}
40
- */
41
- get body() {
42
- let deferred1_0;
43
- let deferred1_1;
44
- try {
45
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
46
- wasm.document_body(retptr, this.__wbg_ptr);
47
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
48
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
49
- deferred1_0 = r0;
50
- deferred1_1 = r1;
51
- return getStringFromWasm0(r0, r1);
52
- } finally {
53
- wasm.__wbindgen_add_to_stack_pointer(16);
54
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
55
- }
56
- }
57
- /**
58
- * Ordered list of card blocks as JS objects with `tag`, `fields`, and `body`.
59
- * @returns {any}
33
+ * Ordered list of composable card blocks as typed `Card` objects.
34
+ * @returns {Card[]}
60
35
  */
61
36
  get cards() {
62
37
  const ret = wasm.document_cards(this.__wbg_ptr);
63
38
  return takeObject(ret);
64
39
  }
40
+ /**
41
+ * Return a fresh `Document` handle with the same parse state.
42
+ *
43
+ * Mutations on the returned handle do not affect the original and
44
+ * vice versa. Parse-time warnings are snapshotted alongside the
45
+ * document — they describe the original parse, not the edit
46
+ * history of either handle.
47
+ * @returns {Document}
48
+ */
49
+ clone() {
50
+ const ret = wasm.document_clone(this.__wbg_ptr);
51
+ return Document.__wrap(ret);
52
+ }
65
53
  /**
66
54
  * Parse markdown into a typed Document.
67
55
  *
@@ -87,14 +75,6 @@ export class Document {
87
75
  wasm.__wbindgen_add_to_stack_pointer(16);
88
76
  }
89
77
  }
90
- /**
91
- * Typed YAML frontmatter fields as a JS object (no QUILL, BODY, or CARDS keys).
92
- * @returns {any}
93
- */
94
- get frontmatter() {
95
- const ret = wasm.document_frontmatter(this.__wbg_ptr);
96
- return takeObject(ret);
97
- }
98
78
  /**
99
79
  * Insert a card at the given index.
100
80
  *
@@ -102,7 +82,7 @@ export class Document {
102
82
  *
103
83
  * Mutators never modify `warnings`.
104
84
  * @param {number} index
105
- * @param {any} card
85
+ * @param {CardInput} card
106
86
  */
107
87
  insertCard(index, card) {
108
88
  try {
@@ -117,6 +97,20 @@ export class Document {
117
97
  wasm.__wbindgen_add_to_stack_pointer(16);
118
98
  }
119
99
  }
100
+ /**
101
+ * The document's main (entry) card.
102
+ *
103
+ * Carries the QUILL sentinel, the document-level frontmatter, and the
104
+ * global body. Frontmatter/body reads and mutations go through this
105
+ * handle — there are no document-level shortcuts after the rework.
106
+ *
107
+ * Allocates and serializes on each call — cache locally if read in a hot loop.
108
+ * @returns {Card}
109
+ */
110
+ get main() {
111
+ const ret = wasm.document_main(this.__wbg_ptr);
112
+ return takeObject(ret);
113
+ }
120
114
  /**
121
115
  * Move the card at `from` to position `to`.
122
116
  *
@@ -149,7 +143,7 @@ export class Document {
149
143
  * Throws an `Error` if `card.tag` is not a valid tag name.
150
144
  *
151
145
  * Mutators never modify `warnings`.
152
- * @param {any} card
146
+ * @param {CardInput} card
153
147
  */
154
148
  pushCard(card) {
155
149
  try {
@@ -189,14 +183,14 @@ export class Document {
189
183
  *
190
184
  * Mutators never modify `warnings`.
191
185
  * @param {number} index
192
- * @returns {any}
186
+ * @returns {Card | undefined}
193
187
  */
194
188
  removeCard(index) {
195
189
  const ret = wasm.document_removeCard(this.__wbg_ptr, index);
196
190
  return takeObject(ret);
197
191
  }
198
192
  /**
199
- * Remove a frontmatter field, returning the removed value or `undefined`.
193
+ * Remove a frontmatter field on the main card, returning the removed value or `undefined`.
200
194
  *
201
195
  * Mutators never modify `warnings`.
202
196
  * @param {string} name
@@ -209,7 +203,7 @@ export class Document {
209
203
  return takeObject(ret);
210
204
  }
211
205
  /**
212
- * Replace the global Markdown body.
206
+ * Replace the main card's body (the global Markdown body).
213
207
  *
214
208
  * Mutators never modify `warnings`.
215
209
  * @param {string} body
@@ -220,7 +214,10 @@ export class Document {
220
214
  wasm.document_replaceBody(this.__wbg_ptr, ptr0, len0);
221
215
  }
222
216
  /**
223
- * Set a frontmatter field.
217
+ * Update a frontmatter field on the main card.
218
+ *
219
+ * Convenience method: equivalent to `doc.mainMut().setField(name, value)`.
220
+ * Clears any existing `!fill` marker on the field.
224
221
  *
225
222
  * Throws an `Error` whose message includes the `EditError` variant name and
226
223
  * details if `name` is reserved (`BODY`, `CARDS`, `QUILL`, `CARD`) or does
@@ -245,6 +242,32 @@ export class Document {
245
242
  wasm.__wbindgen_add_to_stack_pointer(16);
246
243
  }
247
244
  }
245
+ /**
246
+ * Update a frontmatter field on the main card AND mark it as `!fill`.
247
+ *
248
+ * Convenience method: equivalent to `doc.mainMut().setFill(name, value)`.
249
+ *
250
+ * Throws on invalid name (see [`setField`](Document::set_field)).
251
+ *
252
+ * Mutators never modify `warnings`.
253
+ * @param {string} name
254
+ * @param {any} value
255
+ */
256
+ setFill(name, value) {
257
+ try {
258
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
259
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
260
+ const len0 = WASM_VECTOR_LEN;
261
+ wasm.document_setFill(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(value));
262
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
263
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
264
+ if (r1) {
265
+ throw takeObject(r0);
266
+ }
267
+ } finally {
268
+ wasm.__wbindgen_add_to_stack_pointer(16);
269
+ }
270
+ }
248
271
  /**
249
272
  * Replace the QUILL reference string.
250
273
  *
@@ -345,8 +368,8 @@ export class Document {
345
368
  }
346
369
  }
347
370
  /**
348
- * Non-fatal parse-time warnings as a JS array of Diagnostic objects.
349
- * @returns {any}
371
+ * Non-fatal parse-time warnings as an array of typed `Diagnostic` objects.
372
+ * @returns {Diagnostic[]}
350
373
  */
351
374
  get warnings() {
352
375
  const ret = wasm.document_warnings(this.__wbg_ptr);
@@ -396,6 +419,25 @@ export class Quill {
396
419
  wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
397
420
  }
398
421
  }
422
+ /**
423
+ * Read-only snapshot of the loaded `Quill.yaml`.
424
+ *
425
+ * Returns a plain JS object with `name`, `backend`, `description`,
426
+ * `version`, `author`, optional `example` (content of the example
427
+ * markdown, when the quill ships one), `supportedFormats` (backend's
428
+ * output formats as lowercase strings), `schema` (the raw main-card
429
+ * field schema as parsed from YAML — consumers that need validation
430
+ * run their own validator against this), and any additional
431
+ * unstructured keys declared inside the `quill:` section.
432
+ *
433
+ * Equivalent by value for the lifetime of the handle; the quill is
434
+ * immutable once constructed.
435
+ * @returns {any}
436
+ */
437
+ get metadata() {
438
+ const ret = wasm.quill_metadata(this.__wbg_ptr);
439
+ return takeObject(ret);
440
+ }
399
441
  /**
400
442
  * Open an iterative render session for page-selective rendering.
401
443
  * @param {Document} doc
@@ -506,8 +548,11 @@ export class Quillmark {
506
548
  /**
507
549
  * Load a quill from a file tree and attach the appropriate backend.
508
550
  *
509
- * The tree must be a `Map<string, Uint8Array>`.
510
- * @param {any} tree
551
+ * Accepts either a `Map<string, Uint8Array>` or a plain object
552
+ * (`Record<string, Uint8Array>`). Plain objects are walked via
553
+ * `Object.entries` at the boundary; the Rust side sees a single
554
+ * canonical shape.
555
+ * @param {Map<string, Uint8Array>} tree
511
556
  * @returns {Quill}
512
557
  */
513
558
  quill(tree) {
@@ -635,6 +680,10 @@ export function __wbg___wbindgen_is_function_3baa9db1a987f47d(arg0) {
635
680
  const ret = typeof(getObject(arg0)) === 'function';
636
681
  return ret;
637
682
  }
683
+ export function __wbg___wbindgen_is_null_52ff4ec04186736f(arg0) {
684
+ const ret = getObject(arg0) === null;
685
+ return ret;
686
+ }
638
687
  export function __wbg___wbindgen_is_object_63322ec0cd6ea4ef(arg0) {
639
688
  const val = getObject(arg0);
640
689
  const ret = typeof(val) === 'object' && val !== null;
Binary file
@@ -5,11 +5,11 @@ export const __wbg_document_free: (a: number, b: number) => void;
5
5
  export const __wbg_quill_free: (a: number, b: number) => void;
6
6
  export const __wbg_quillmark_free: (a: number, b: number) => void;
7
7
  export const __wbg_rendersession_free: (a: number, b: number) => void;
8
- export const document_body: (a: number, b: number) => void;
9
8
  export const document_cards: (a: number) => number;
9
+ export const document_clone: (a: number) => number;
10
10
  export const document_fromMarkdown: (a: number, b: number, c: number) => void;
11
- export const document_frontmatter: (a: number) => number;
12
11
  export const document_insertCard: (a: number, b: number, c: number, d: number) => void;
12
+ export const document_main: (a: number) => number;
13
13
  export const document_moveCard: (a: number, b: number, c: number, d: number) => void;
14
14
  export const document_pushCard: (a: number, b: number, c: number) => void;
15
15
  export const document_quillRef: (a: number, b: number) => void;
@@ -17,6 +17,7 @@ export const document_removeCard: (a: number, b: number) => number;
17
17
  export const document_removeField: (a: number, b: number, c: number) => number;
18
18
  export const document_replaceBody: (a: number, b: number, c: number) => void;
19
19
  export const document_setField: (a: number, b: number, c: number, d: number, e: number) => void;
20
+ export const document_setFill: (a: number, b: number, c: number, d: number, e: number) => void;
20
21
  export const document_setQuillRef: (a: number, b: number, c: number, d: number) => void;
21
22
  export const document_toMarkdown: (a: number, b: number) => void;
22
23
  export const document_updateCardBody: (a: number, b: number, c: number, d: number, e: number) => void;
@@ -24,6 +25,7 @@ export const document_updateCardField: (a: number, b: number, c: number, d: numb
24
25
  export const document_warnings: (a: number) => number;
25
26
  export const init: () => void;
26
27
  export const quill_backendId: (a: number, b: number) => void;
28
+ export const quill_metadata: (a: number) => number;
27
29
  export const quill_open: (a: number, b: number, c: number) => void;
28
30
  export const quill_projectForm: (a: number, b: number, c: number) => void;
29
31
  export const quill_render: (a: number, b: number, c: number, d: number) => void;
@@ -1,5 +1,18 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+
4
+ /**
5
+ * Input shape for `Document.pushCard` and `Document.insertCard`.
6
+ *
7
+ * Only `tag` is required. `fields` defaults to `{}`, `body` to `""`.
8
+ */
9
+ export interface CardInput {
10
+ tag: string;
11
+ fields?: Record<string, unknown>;
12
+ body?: string;
13
+ }
14
+
15
+
3
16
  export interface Artifact {
4
17
  format: OutputFormat;
5
18
  bytes: Uint8Array;
@@ -7,8 +20,10 @@ export interface Artifact {
7
20
  }
8
21
 
9
22
  export interface Card {
23
+ sentinel: string;
10
24
  tag: string;
11
- fields: Record<string, unknown>;
25
+ frontmatter: Record<string, unknown>;
26
+ frontmatterItems: FrontmatterItem[];
12
27
  body: string;
13
28
  }
14
29
 
@@ -40,6 +55,8 @@ export interface RenderResult {
40
55
  renderTimeMs: number;
41
56
  }
42
57
 
58
+ export type FrontmatterItem = { kind: "field"; key: string; value: unknown; fill?: boolean } | { kind: "comment"; text: string };
59
+
43
60
  export type OutputFormat = "pdf" | "svg" | "txt" | "png";
44
61
 
45
62
  export type Severity = "error" | "warning" | "note";
@@ -62,6 +79,15 @@ export class Document {
62
79
  private constructor();
63
80
  free(): void;
64
81
  [Symbol.dispose](): void;
82
+ /**
83
+ * Return a fresh `Document` handle with the same parse state.
84
+ *
85
+ * Mutations on the returned handle do not affect the original and
86
+ * vice versa. Parse-time warnings are snapshotted alongside the
87
+ * document — they describe the original parse, not the edit
88
+ * history of either handle.
89
+ */
90
+ clone(): Document;
65
91
  /**
66
92
  * Parse markdown into a typed Document.
67
93
  *
@@ -76,7 +102,7 @@ export class Document {
76
102
  *
77
103
  * Mutators never modify `warnings`.
78
104
  */
79
- insertCard(index: number, card: any): void;
105
+ insertCard(index: number, card: CardInput): void;
80
106
  /**
81
107
  * Move the card at `from` to position `to`.
82
108
  *
@@ -96,27 +122,30 @@ export class Document {
96
122
  *
97
123
  * Mutators never modify `warnings`.
98
124
  */
99
- pushCard(card: any): void;
125
+ pushCard(card: CardInput): void;
100
126
  /**
101
127
  * Remove the card at `index` and return it, or `undefined` if out of range.
102
128
  *
103
129
  * Mutators never modify `warnings`.
104
130
  */
105
- removeCard(index: number): any;
131
+ removeCard(index: number): Card | undefined;
106
132
  /**
107
- * Remove a frontmatter field, returning the removed value or `undefined`.
133
+ * Remove a frontmatter field on the main card, returning the removed value or `undefined`.
108
134
  *
109
135
  * Mutators never modify `warnings`.
110
136
  */
111
137
  removeField(name: string): any;
112
138
  /**
113
- * Replace the global Markdown body.
139
+ * Replace the main card's body (the global Markdown body).
114
140
  *
115
141
  * Mutators never modify `warnings`.
116
142
  */
117
143
  replaceBody(body: string): void;
118
144
  /**
119
- * Set a frontmatter field.
145
+ * Update a frontmatter field on the main card.
146
+ *
147
+ * Convenience method: equivalent to `doc.mainMut().setField(name, value)`.
148
+ * Clears any existing `!fill` marker on the field.
120
149
  *
121
150
  * Throws an `Error` whose message includes the `EditError` variant name and
122
151
  * details if `name` is reserved (`BODY`, `CARDS`, `QUILL`, `CARD`) or does
@@ -125,6 +154,16 @@ export class Document {
125
154
  * Mutators never modify `warnings`.
126
155
  */
127
156
  setField(name: string, value: any): void;
157
+ /**
158
+ * Update a frontmatter field on the main card AND mark it as `!fill`.
159
+ *
160
+ * Convenience method: equivalent to `doc.mainMut().setFill(name, value)`.
161
+ *
162
+ * Throws on invalid name (see [`setField`](Document::set_field)).
163
+ *
164
+ * Mutators never modify `warnings`.
165
+ */
166
+ setFill(name: string, value: any): void;
128
167
  /**
129
168
  * Replace the QUILL reference string.
130
169
  *
@@ -161,30 +200,27 @@ export class Document {
161
200
  */
162
201
  updateCardField(index: number, name: string, value: any): void;
163
202
  /**
164
- * Global Markdown body between frontmatter and the first card.
165
- *
166
- * Trailing newlines are stripped — those are structural separators in
167
- * the Markdown wire format, not content the consumer wrote.
168
- *
169
- * Empty string when no body is present.
170
- */
171
- readonly body: string;
172
- /**
173
- * Ordered list of card blocks as JS objects with `tag`, `fields`, and `body`.
203
+ * Ordered list of composable card blocks as typed `Card` objects.
174
204
  */
175
- readonly cards: any;
205
+ readonly cards: Card[];
176
206
  /**
177
- * Typed YAML frontmatter fields as a JS object (no QUILL, BODY, or CARDS keys).
207
+ * The document's main (entry) card.
208
+ *
209
+ * Carries the QUILL sentinel, the document-level frontmatter, and the
210
+ * global body. Frontmatter/body reads and mutations go through this
211
+ * handle — there are no document-level shortcuts after the rework.
212
+ *
213
+ * Allocates and serializes on each call — cache locally if read in a hot loop.
178
214
  */
179
- readonly frontmatter: any;
215
+ readonly main: Card;
180
216
  /**
181
217
  * The QUILL reference string (e.g. `"usaf_memo@0.1"`).
182
218
  */
183
219
  readonly quillRef: string;
184
220
  /**
185
- * Non-fatal parse-time warnings as a JS array of Diagnostic objects.
221
+ * Non-fatal parse-time warnings as an array of typed `Diagnostic` objects.
186
222
  */
187
- readonly warnings: any;
223
+ readonly warnings: Diagnostic[];
188
224
  }
189
225
 
190
226
  /**
@@ -227,6 +263,21 @@ export class Quill {
227
263
  * The resolved backend identifier (e.g. `"typst"`).
228
264
  */
229
265
  readonly backendId: string;
266
+ /**
267
+ * Read-only snapshot of the loaded `Quill.yaml`.
268
+ *
269
+ * Returns a plain JS object with `name`, `backend`, `description`,
270
+ * `version`, `author`, optional `example` (content of the example
271
+ * markdown, when the quill ships one), `supportedFormats` (backend's
272
+ * output formats as lowercase strings), `schema` (the raw main-card
273
+ * field schema as parsed from YAML — consumers that need validation
274
+ * run their own validator against this), and any additional
275
+ * unstructured keys declared inside the `quill:` section.
276
+ *
277
+ * Equivalent by value for the lifetime of the handle; the quill is
278
+ * immutable once constructed.
279
+ */
280
+ readonly metadata: any;
230
281
  }
231
282
 
232
283
  /**
@@ -242,9 +293,12 @@ export class Quillmark {
242
293
  /**
243
294
  * Load a quill from a file tree and attach the appropriate backend.
244
295
  *
245
- * The tree must be a `Map<string, Uint8Array>`.
296
+ * Accepts either a `Map<string, Uint8Array>` or a plain object
297
+ * (`Record<string, Uint8Array>`). Plain objects are walked via
298
+ * `Object.entries` at the boundary; the Rust side sees a single
299
+ * canonical shape.
246
300
  */
247
- quill(tree: any): Quill;
301
+ quill(tree: Map<string, Uint8Array>): Quill;
248
302
  }
249
303
 
250
304
  export class RenderSession {
package/node-esm/wasm.js CHANGED
@@ -34,38 +34,26 @@ export class Document {
34
34
  wasm.__wbg_document_free(ptr, 0);
35
35
  }
36
36
  /**
37
- * Global Markdown body between frontmatter and the first card.
38
- *
39
- * Trailing newlines are stripped — those are structural separators in
40
- * the Markdown wire format, not content the consumer wrote.
41
- *
42
- * Empty string when no body is present.
43
- * @returns {string}
44
- */
45
- get body() {
46
- let deferred1_0;
47
- let deferred1_1;
48
- try {
49
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
50
- wasm.document_body(retptr, this.__wbg_ptr);
51
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
52
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
53
- deferred1_0 = r0;
54
- deferred1_1 = r1;
55
- return getStringFromWasm0(r0, r1);
56
- } finally {
57
- wasm.__wbindgen_add_to_stack_pointer(16);
58
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
59
- }
60
- }
61
- /**
62
- * Ordered list of card blocks as JS objects with `tag`, `fields`, and `body`.
63
- * @returns {any}
37
+ * Ordered list of composable card blocks as typed `Card` objects.
38
+ * @returns {Card[]}
64
39
  */
65
40
  get cards() {
66
41
  const ret = wasm.document_cards(this.__wbg_ptr);
67
42
  return takeObject(ret);
68
43
  }
44
+ /**
45
+ * Return a fresh `Document` handle with the same parse state.
46
+ *
47
+ * Mutations on the returned handle do not affect the original and
48
+ * vice versa. Parse-time warnings are snapshotted alongside the
49
+ * document — they describe the original parse, not the edit
50
+ * history of either handle.
51
+ * @returns {Document}
52
+ */
53
+ clone() {
54
+ const ret = wasm.document_clone(this.__wbg_ptr);
55
+ return Document.__wrap(ret);
56
+ }
69
57
  /**
70
58
  * Parse markdown into a typed Document.
71
59
  *
@@ -91,14 +79,6 @@ export class Document {
91
79
  wasm.__wbindgen_add_to_stack_pointer(16);
92
80
  }
93
81
  }
94
- /**
95
- * Typed YAML frontmatter fields as a JS object (no QUILL, BODY, or CARDS keys).
96
- * @returns {any}
97
- */
98
- get frontmatter() {
99
- const ret = wasm.document_frontmatter(this.__wbg_ptr);
100
- return takeObject(ret);
101
- }
102
82
  /**
103
83
  * Insert a card at the given index.
104
84
  *
@@ -106,7 +86,7 @@ export class Document {
106
86
  *
107
87
  * Mutators never modify `warnings`.
108
88
  * @param {number} index
109
- * @param {any} card
89
+ * @param {CardInput} card
110
90
  */
111
91
  insertCard(index, card) {
112
92
  try {
@@ -121,6 +101,20 @@ export class Document {
121
101
  wasm.__wbindgen_add_to_stack_pointer(16);
122
102
  }
123
103
  }
104
+ /**
105
+ * The document's main (entry) card.
106
+ *
107
+ * Carries the QUILL sentinel, the document-level frontmatter, and the
108
+ * global body. Frontmatter/body reads and mutations go through this
109
+ * handle — there are no document-level shortcuts after the rework.
110
+ *
111
+ * Allocates and serializes on each call — cache locally if read in a hot loop.
112
+ * @returns {Card}
113
+ */
114
+ get main() {
115
+ const ret = wasm.document_main(this.__wbg_ptr);
116
+ return takeObject(ret);
117
+ }
124
118
  /**
125
119
  * Move the card at `from` to position `to`.
126
120
  *
@@ -153,7 +147,7 @@ export class Document {
153
147
  * Throws an `Error` if `card.tag` is not a valid tag name.
154
148
  *
155
149
  * Mutators never modify `warnings`.
156
- * @param {any} card
150
+ * @param {CardInput} card
157
151
  */
158
152
  pushCard(card) {
159
153
  try {
@@ -193,14 +187,14 @@ export class Document {
193
187
  *
194
188
  * Mutators never modify `warnings`.
195
189
  * @param {number} index
196
- * @returns {any}
190
+ * @returns {Card | undefined}
197
191
  */
198
192
  removeCard(index) {
199
193
  const ret = wasm.document_removeCard(this.__wbg_ptr, index);
200
194
  return takeObject(ret);
201
195
  }
202
196
  /**
203
- * Remove a frontmatter field, returning the removed value or `undefined`.
197
+ * Remove a frontmatter field on the main card, returning the removed value or `undefined`.
204
198
  *
205
199
  * Mutators never modify `warnings`.
206
200
  * @param {string} name
@@ -213,7 +207,7 @@ export class Document {
213
207
  return takeObject(ret);
214
208
  }
215
209
  /**
216
- * Replace the global Markdown body.
210
+ * Replace the main card's body (the global Markdown body).
217
211
  *
218
212
  * Mutators never modify `warnings`.
219
213
  * @param {string} body
@@ -224,7 +218,10 @@ export class Document {
224
218
  wasm.document_replaceBody(this.__wbg_ptr, ptr0, len0);
225
219
  }
226
220
  /**
227
- * Set a frontmatter field.
221
+ * Update a frontmatter field on the main card.
222
+ *
223
+ * Convenience method: equivalent to `doc.mainMut().setField(name, value)`.
224
+ * Clears any existing `!fill` marker on the field.
228
225
  *
229
226
  * Throws an `Error` whose message includes the `EditError` variant name and
230
227
  * details if `name` is reserved (`BODY`, `CARDS`, `QUILL`, `CARD`) or does
@@ -249,6 +246,32 @@ export class Document {
249
246
  wasm.__wbindgen_add_to_stack_pointer(16);
250
247
  }
251
248
  }
249
+ /**
250
+ * Update a frontmatter field on the main card AND mark it as `!fill`.
251
+ *
252
+ * Convenience method: equivalent to `doc.mainMut().setFill(name, value)`.
253
+ *
254
+ * Throws on invalid name (see [`setField`](Document::set_field)).
255
+ *
256
+ * Mutators never modify `warnings`.
257
+ * @param {string} name
258
+ * @param {any} value
259
+ */
260
+ setFill(name, value) {
261
+ try {
262
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
263
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
264
+ const len0 = WASM_VECTOR_LEN;
265
+ wasm.document_setFill(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(value));
266
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
267
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
268
+ if (r1) {
269
+ throw takeObject(r0);
270
+ }
271
+ } finally {
272
+ wasm.__wbindgen_add_to_stack_pointer(16);
273
+ }
274
+ }
252
275
  /**
253
276
  * Replace the QUILL reference string.
254
277
  *
@@ -349,8 +372,8 @@ export class Document {
349
372
  }
350
373
  }
351
374
  /**
352
- * Non-fatal parse-time warnings as a JS array of Diagnostic objects.
353
- * @returns {any}
375
+ * Non-fatal parse-time warnings as an array of typed `Diagnostic` objects.
376
+ * @returns {Diagnostic[]}
354
377
  */
355
378
  get warnings() {
356
379
  const ret = wasm.document_warnings(this.__wbg_ptr);
@@ -400,6 +423,25 @@ export class Quill {
400
423
  wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
401
424
  }
402
425
  }
426
+ /**
427
+ * Read-only snapshot of the loaded `Quill.yaml`.
428
+ *
429
+ * Returns a plain JS object with `name`, `backend`, `description`,
430
+ * `version`, `author`, optional `example` (content of the example
431
+ * markdown, when the quill ships one), `supportedFormats` (backend's
432
+ * output formats as lowercase strings), `schema` (the raw main-card
433
+ * field schema as parsed from YAML — consumers that need validation
434
+ * run their own validator against this), and any additional
435
+ * unstructured keys declared inside the `quill:` section.
436
+ *
437
+ * Equivalent by value for the lifetime of the handle; the quill is
438
+ * immutable once constructed.
439
+ * @returns {any}
440
+ */
441
+ get metadata() {
442
+ const ret = wasm.quill_metadata(this.__wbg_ptr);
443
+ return takeObject(ret);
444
+ }
403
445
  /**
404
446
  * Open an iterative render session for page-selective rendering.
405
447
  * @param {Document} doc
@@ -510,8 +552,11 @@ export class Quillmark {
510
552
  /**
511
553
  * Load a quill from a file tree and attach the appropriate backend.
512
554
  *
513
- * The tree must be a `Map<string, Uint8Array>`.
514
- * @param {any} tree
555
+ * Accepts either a `Map<string, Uint8Array>` or a plain object
556
+ * (`Record<string, Uint8Array>`). Plain objects are walked via
557
+ * `Object.entries` at the boundary; the Rust side sees a single
558
+ * canonical shape.
559
+ * @param {Map<string, Uint8Array>} tree
515
560
  * @returns {Quill}
516
561
  */
517
562
  quill(tree) {
@@ -642,6 +687,10 @@ function __wbg_get_imports() {
642
687
  const ret = typeof(getObject(arg0)) === 'function';
643
688
  return ret;
644
689
  },
690
+ __wbg___wbindgen_is_null_52ff4ec04186736f: function(arg0) {
691
+ const ret = getObject(arg0) === null;
692
+ return ret;
693
+ },
645
694
  __wbg___wbindgen_is_object_63322ec0cd6ea4ef: function(arg0) {
646
695
  const val = getObject(arg0);
647
696
  const ret = typeof(val) === 'object' && val !== null;
Binary file
@@ -5,11 +5,11 @@ export const __wbg_document_free: (a: number, b: number) => void;
5
5
  export const __wbg_quill_free: (a: number, b: number) => void;
6
6
  export const __wbg_quillmark_free: (a: number, b: number) => void;
7
7
  export const __wbg_rendersession_free: (a: number, b: number) => void;
8
- export const document_body: (a: number, b: number) => void;
9
8
  export const document_cards: (a: number) => number;
9
+ export const document_clone: (a: number) => number;
10
10
  export const document_fromMarkdown: (a: number, b: number, c: number) => void;
11
- export const document_frontmatter: (a: number) => number;
12
11
  export const document_insertCard: (a: number, b: number, c: number, d: number) => void;
12
+ export const document_main: (a: number) => number;
13
13
  export const document_moveCard: (a: number, b: number, c: number, d: number) => void;
14
14
  export const document_pushCard: (a: number, b: number, c: number) => void;
15
15
  export const document_quillRef: (a: number, b: number) => void;
@@ -17,6 +17,7 @@ export const document_removeCard: (a: number, b: number) => number;
17
17
  export const document_removeField: (a: number, b: number, c: number) => number;
18
18
  export const document_replaceBody: (a: number, b: number, c: number) => void;
19
19
  export const document_setField: (a: number, b: number, c: number, d: number, e: number) => void;
20
+ export const document_setFill: (a: number, b: number, c: number, d: number, e: number) => void;
20
21
  export const document_setQuillRef: (a: number, b: number, c: number, d: number) => void;
21
22
  export const document_toMarkdown: (a: number, b: number) => void;
22
23
  export const document_updateCardBody: (a: number, b: number, c: number, d: number, e: number) => void;
@@ -24,6 +25,7 @@ export const document_updateCardField: (a: number, b: number, c: number, d: numb
24
25
  export const document_warnings: (a: number) => number;
25
26
  export const init: () => void;
26
27
  export const quill_backendId: (a: number, b: number) => void;
28
+ export const quill_metadata: (a: number) => number;
27
29
  export const quill_open: (a: number, b: number, c: number) => void;
28
30
  export const quill_projectForm: (a: number, b: number, c: number) => void;
29
31
  export const quill_render: (a: number, b: number, c: number, d: number) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillmark/wasm",
3
- "version": "0.58.2-rc.6",
3
+ "version": "0.59.0-rc.2",
4
4
  "description": "WebAssembly bindings for quillmark",
5
5
  "type": "module",
6
6
  "license": "MIT OR Apache-2.0",