@quillmark/wasm 0.55.0 → 0.58.2-rc.4

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.
Binary file
@@ -1,23 +1,36 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
- export const __wbg_compileddocument_free: (a: number, b: number) => void;
4
+ export const __wbg_document_free: (a: number, b: number) => void;
5
+ export const __wbg_quill_free: (a: number, b: number) => void;
5
6
  export const __wbg_quillmark_free: (a: number, b: number) => void;
6
- export const compileddocument_pageCount: (a: number) => number;
7
- export const compileddocument_renderPages: (a: number, b: number, c: number, d: number, e: number) => void;
7
+ export const __wbg_rendersession_free: (a: number, b: number) => void;
8
+ export const document_body: (a: number, b: number) => void;
9
+ export const document_cards: (a: number) => number;
10
+ export const document_fromMarkdown: (a: number, b: number, c: number) => void;
11
+ export const document_frontmatter: (a: number) => number;
12
+ export const document_insertCard: (a: number, b: number, c: number, d: number) => void;
13
+ export const document_moveCard: (a: number, b: number, c: number, d: number) => void;
14
+ export const document_pushCard: (a: number, b: number, c: number) => void;
15
+ export const document_quillRef: (a: number, b: number) => void;
16
+ export const document_removeCard: (a: number, b: number) => number;
17
+ export const document_removeField: (a: number, b: number, c: number) => number;
18
+ export const document_replaceBody: (a: number, b: number, c: number) => void;
19
+ export const document_setField: (a: number, b: number, c: number, d: number, e: number) => void;
20
+ export const document_setQuillRef: (a: number, b: number, c: number, d: number) => void;
21
+ export const document_toMarkdown: (a: number, b: number) => void;
22
+ export const document_updateCardBody: (a: number, b: number, c: number, d: number, e: number) => void;
23
+ export const document_updateCardField: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
24
+ export const document_warnings: (a: number) => number;
8
25
  export const init: () => void;
9
- export const quillmark_compile: (a: number, b: number, c: number, d: number) => void;
10
- export const quillmark_compileData: (a: number, b: number, c: number, d: number) => void;
11
- export const quillmark_dryRun: (a: number, b: number, c: number, d: number) => void;
12
- export const quillmark_getQuillInfo: (a: number, b: number, c: number, d: number) => void;
13
- export const quillmark_getQuillSchema: (a: number, b: number, c: number, d: number) => void;
14
- export const quillmark_listQuills: (a: number, b: number) => void;
26
+ export const quill_backendId: (a: number, b: number) => void;
27
+ export const quill_open: (a: number, b: number, c: number) => void;
28
+ export const quill_projectForm: (a: number, b: number, c: number) => void;
29
+ export const quill_render: (a: number, b: number, c: number, d: number) => void;
15
30
  export const quillmark_new: () => number;
16
- export const quillmark_parseMarkdown: (a: number, b: number, c: number) => void;
17
- export const quillmark_registerQuill: (a: number, b: number, c: number) => void;
18
- export const quillmark_render: (a: number, b: number, c: number, d: number) => void;
19
- export const quillmark_resolveQuill: (a: number, b: number, c: number) => number;
20
- export const quillmark_unregisterQuill: (a: number, b: number, c: number) => number;
31
+ export const quillmark_quill: (a: number, b: number, c: number) => void;
32
+ export const rendersession_pageCount: (a: number) => number;
33
+ export const rendersession_render: (a: number, b: number, c: number) => void;
21
34
  export const lut_inverse_interp16: (a: number, b: number, c: number) => number;
22
35
  export const qcms_profile_precache_output_transform: (a: number) => void;
23
36
  export const qcms_white_point_sRGB: (a: number) => void;
@@ -6,7 +6,11 @@ export interface Artifact {
6
6
  mimeType: string;
7
7
  }
8
8
 
9
- export interface CompileOptions {}
9
+ export interface Card {
10
+ tag: string;
11
+ fields: Record<string, unknown>;
12
+ body: string;
13
+ }
10
14
 
11
15
  export interface Diagnostic {
12
16
  severity: Severity;
@@ -23,31 +27,10 @@ export interface Location {
23
27
  column: number;
24
28
  }
25
29
 
26
- export interface ParsedDocument {
27
- fields: Record<string, any>;
28
- quillRef: string;
29
- }
30
-
31
- export interface QuillInfo {
32
- name: string;
33
- backend: string;
34
- metadata: Record<string, any>;
35
- example?: string;
36
- schema: string;
37
- defaults: Record<string, any>;
38
- examples: Record<string, any[]>;
39
- supportedFormats: OutputFormat[];
40
- }
41
-
42
30
  export interface RenderOptions {
43
31
  format?: OutputFormat;
44
- assets?: Record<string, Uint8Array | number[]>;
45
- ppi?: number;
46
- }
47
-
48
- export interface RenderPagesOptions {
49
- format: OutputFormat;
50
32
  ppi?: number;
33
+ pages?: number[];
51
34
  }
52
35
 
53
36
  export interface RenderResult {
@@ -62,108 +45,220 @@ export type OutputFormat = "pdf" | "svg" | "txt" | "png";
62
45
  export type Severity = "error" | "warning" | "note";
63
46
 
64
47
 
65
- export class CompiledDocument {
48
+ /**
49
+ * Typed in-memory Quillmark document.
50
+ *
51
+ * Created via `Document.fromMarkdown(markdown)`. Exposes:
52
+ * - `quillRef` (string)
53
+ * - `frontmatter` (JS object/Record)
54
+ * - `body` (string)
55
+ * - `cards` (array of Card objects)
56
+ * - `warnings` (array of Diagnostic objects)
57
+ *
58
+ * `toMarkdown()` emits canonical Quillmark Markdown that round-trips back to
59
+ * an equal `Document` by value and by type.
60
+ */
61
+ export class Document {
66
62
  private constructor();
67
63
  free(): void;
68
64
  [Symbol.dispose](): void;
69
65
  /**
70
- * Render selected pages. `pages = null/undefined` renders all pages.
66
+ * Parse markdown into a typed Document.
67
+ *
68
+ * Returns the document with any parse-time warnings accessible via `.warnings`.
69
+ * Throws on parse errors.
71
70
  */
72
- renderPages(pages: Uint32Array | null | undefined, opts: RenderPagesOptions): RenderResult;
71
+ static fromMarkdown(markdown: string): Document;
73
72
  /**
74
- * Number of pages in this compiled document.
73
+ * Insert a card at the given index.
74
+ *
75
+ * `index` must be in `0..=cards.length`. Out-of-range throws an `Error`.
76
+ *
77
+ * Mutators never modify `warnings`.
75
78
  */
76
- readonly pageCount: number;
77
- }
78
-
79
- /**
80
- * Quillmark WASM Engine
81
- *
82
- * Create once, register Quills, render markdown. That's it.
83
- */
84
- export class Quillmark {
85
- free(): void;
86
- [Symbol.dispose](): void;
79
+ insertCard(index: number, card: any): void;
87
80
  /**
88
- * Compile a parsed document into an opaque compiled document handle.
81
+ * Move the card at `from` to position `to`.
82
+ *
83
+ * `from == to` is a no-op. Both indices must be in `0..cards.length`.
84
+ * Out-of-range throws an `Error`.
85
+ *
86
+ * Mutators never modify `warnings`.
89
87
  */
90
- compile(parsed: ParsedDocument, opts?: CompileOptions | null): CompiledDocument;
88
+ moveCard(from: number, to: number): void;
91
89
  /**
92
- * Compile markdown to JSON data without rendering artifacts.
90
+ * Append a card to the end of the card list.
91
+ *
92
+ * `card` must be a JS object with a `tag` string field and optional
93
+ * `fields` (object) and `body` (string).
93
94
  *
94
- * This exposes the intermediate data structure that would be passed to the backend.
95
- * Useful for debugging and validation.
95
+ * Throws an `Error` if `card.tag` is not a valid tag name.
96
+ *
97
+ * Mutators never modify `warnings`.
96
98
  */
97
- compileData(markdown: string): any;
99
+ pushCard(card: any): void;
98
100
  /**
99
- * Perform a dry run validation without backend compilation.
100
- *
101
- * Executes parsing, schema validation, and template composition to
102
- * surface input errors quickly. Returns successfully on valid input,
103
- * or throws an error with diagnostic payload on failure.
101
+ * Remove the card at `index` and return it, or `undefined` if out of range.
104
102
  *
105
- * The quill name is read from the markdown's required QUILL tag.
103
+ * Mutators never modify `warnings`.
104
+ */
105
+ removeCard(index: number): any;
106
+ /**
107
+ * Remove a frontmatter field, returning the removed value or `undefined`.
106
108
  *
107
- * This is useful for fast feedback loops in LLM-driven document generation.
109
+ * Mutators never modify `warnings`.
108
110
  */
109
- dryRun(markdown: string): void;
111
+ removeField(name: string): any;
110
112
  /**
111
- * Get shallow information about a registered Quill
113
+ * Replace the global Markdown body.
112
114
  *
113
- * This returns metadata, backend info, field schemas, and supported formats
114
- * that consumers need to configure render options for the next step.
115
+ * Mutators never modify `warnings`.
115
116
  */
116
- getQuillInfo(name: string): QuillInfo;
117
+ replaceBody(body: string): void;
117
118
  /**
118
- * Get the public YAML schema contract for a registered quill.
119
+ * Set a frontmatter field.
120
+ *
121
+ * Throws an `Error` whose message includes the `EditError` variant name and
122
+ * details if `name` is reserved (`BODY`, `CARDS`, `QUILL`, `CARD`) or does
123
+ * not match `[a-z_][a-z0-9_]*`.
124
+ *
125
+ * Mutators never modify `warnings`.
119
126
  */
120
- getQuillSchema(name: string): string;
127
+ setField(name: string, value: any): void;
121
128
  /**
122
- * List registered Quills with their exact versions
129
+ * Replace the QUILL reference string.
130
+ *
131
+ * Throws if `ref_str` is not a valid `QuillReference`.
123
132
  *
124
- * Returns strings in the format "name@version" (e.g. "resume-template@2.1.0")
133
+ * Mutators never modify `warnings`.
125
134
  */
126
- listQuills(): string[];
135
+ setQuillRef(ref_str: string): void;
127
136
  /**
128
- * JavaScript constructor: `new Quillmark()`
137
+ * Emit canonical Quillmark Markdown.
138
+ *
139
+ * Returns the document serialised as a Quillmark Markdown string.
140
+ * The output is type-fidelity round-trip safe: re-parsing the result
141
+ * produces a `Document` equal to `self` by value and by type.
129
142
  */
130
- constructor();
143
+ toMarkdown(): string;
131
144
  /**
132
- * Parse markdown into a ParsedDocument
145
+ * Replace the body of the card at `index`.
146
+ *
147
+ * Throws if `index` is out of range.
133
148
  *
134
- * This is the first step in the workflow. The returned ParsedDocument contains
135
- * the parsed YAML frontmatter fields and the quill_ref from QUILL.
149
+ * Mutators never modify `warnings`.
136
150
  */
137
- static parseMarkdown(markdown: string): ParsedDocument;
151
+ updateCardBody(index: number, body: string): void;
138
152
  /**
139
- * Register a Quill template bundle
153
+ * Update a field on the card at `index`.
140
154
  *
141
- * Accepts either a JSON string or a JsValue object representing the Quill file tree.
142
- * Validation happens automatically on registration.
155
+ * Convenience method: equivalent to `doc.card_mut(index)?.set_field(name, value)`.
156
+ *
157
+ * Throws if `index` is out of range, `name` is reserved or invalid, or
158
+ * `value` cannot be serialized.
159
+ *
160
+ * Mutators never modify `warnings`.
143
161
  */
144
- registerQuill(quill_json: any): QuillInfo;
162
+ updateCardField(index: number, name: string, value: any): void;
145
163
  /**
146
- * Render a ParsedDocument to final artifacts (PDF, SVG, TXT)
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.
147
168
  *
148
- * Uses the Quill specified in the ParsedDocument's quill_ref field.
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`.
149
174
  */
150
- render(parsed: ParsedDocument, opts: RenderOptions): RenderResult;
175
+ readonly cards: any;
151
176
  /**
152
- * Resolve a Quill reference to a registered Quill, or null if not available
177
+ * Typed YAML frontmatter fields as a JS object (no QUILL, BODY, or CARDS keys).
178
+ */
179
+ readonly frontmatter: any;
180
+ /**
181
+ * The QUILL reference string (e.g. `"usaf_memo@0.1"`).
182
+ */
183
+ readonly quillRef: string;
184
+ /**
185
+ * Non-fatal parse-time warnings as a JS array of Diagnostic objects.
186
+ */
187
+ readonly warnings: any;
188
+ }
189
+
190
+ /**
191
+ * Opaque, shareable Quill handle.
192
+ */
193
+ export class Quill {
194
+ private constructor();
195
+ free(): void;
196
+ [Symbol.dispose](): void;
197
+ /**
198
+ * Open an iterative render session for page-selective rendering.
199
+ */
200
+ open(doc: Document): RenderSession;
201
+ /**
202
+ * Project a document through this quill's schema.
203
+ *
204
+ * Returns a plain JS object (not a class) that is immediately
205
+ * `JSON.stringify`-able. The shape mirrors [`FormProjection`]:
206
+ *
207
+ * ```json
208
+ * {
209
+ * "main": { "schema": {...}, "values": { "field": {...} } },
210
+ * "cards": [ ... ],
211
+ * "diagnostics": [ ... ]
212
+ * }
213
+ * ```
153
214
  *
154
- * Accepts a quill reference string like "resume-template", "resume-template@2",
155
- * or "resume-template@2.1.0". Returns QuillInfo if the engine can resolve it
156
- * locally, or null if an external fetch is needed.
215
+ * **Snapshot semantics.** This is a read-only snapshot of the document
216
+ * at call time. Subsequent edits to `doc` require calling `projectForm`
217
+ * again.
218
+ *
219
+ * [`FormProjection`]: quillmark::form::FormProjection
220
+ */
221
+ projectForm(doc: Document): any;
222
+ /**
223
+ * Render a document to final artifacts.
224
+ */
225
+ render(doc: Document, opts?: RenderOptions | null): RenderResult;
226
+ /**
227
+ * The resolved backend identifier (e.g. `"typst"`).
157
228
  */
158
- resolveQuill(quill_ref: string): any;
229
+ readonly backendId: string;
230
+ }
231
+
232
+ /**
233
+ * Quillmark WASM Engine
234
+ */
235
+ export class Quillmark {
236
+ free(): void;
237
+ [Symbol.dispose](): void;
238
+ /**
239
+ * JavaScript constructor: `new Quillmark()`
240
+ */
241
+ constructor();
159
242
  /**
160
- * Unregister a Quill by name or specific version
243
+ * Load a quill from a file tree and attach the appropriate backend.
161
244
  *
162
- * If a base name is provided (e.g., "my-quill"), all versions of that quill are freed.
163
- * If a versioned name is provided (e.g., "my-quill@2.1.0"), only that specific version is freed.
164
- * Returns true if something was unregistered, false if not found.
245
+ * The tree must be a `Map<string, Uint8Array>`.
165
246
  */
166
- unregisterQuill(name_or_ref: string): boolean;
247
+ quill(tree: any): Quill;
248
+ }
249
+
250
+ export class RenderSession {
251
+ private constructor();
252
+ free(): void;
253
+ [Symbol.dispose](): void;
254
+ /**
255
+ * Render all or selected pages from this session.
256
+ */
257
+ render(opts?: RenderOptions | null): RenderResult;
258
+ /**
259
+ * Number of pages in this render session.
260
+ */
261
+ readonly pageCount: number;
167
262
  }
168
263
 
169
264
  /**