@quillmark/wasm 0.11.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/README.md ADDED
@@ -0,0 +1,176 @@
1
+ # Quillmark WASM
2
+
3
+ WebAssembly bindings for the Quillmark markdown rendering engine.
4
+
5
+ ## Overview
6
+
7
+ This crate provides WASM bindings for Quillmark, enabling use in web browsers, Node.js, and other JavaScript/TypeScript environments. All data exchange uses JSON serialization, and JavaScript is responsible for all I/O operations.
8
+
9
+ ## Building
10
+
11
+ ### For Web (bundler)
12
+
13
+ ```bash
14
+ wasm-pack build --target bundler --scope quillmark
15
+ ```
16
+
17
+ ### For Node.js
18
+
19
+ ```bash
20
+ wasm-pack build --target nodejs --scope quillmark
21
+ ```
22
+
23
+ ### All targets
24
+
25
+ ```bash
26
+ bash scripts/build-wasm.sh
27
+ ```
28
+
29
+ ## Testing
30
+
31
+ Minimal smoke tests validate the core WASM functionality:
32
+
33
+ ```bash
34
+ # Build WASM module first
35
+ bash scripts/build-wasm.sh
36
+
37
+ # Run tests
38
+ cd quillmark-wasm
39
+ npm install
40
+ npm test
41
+ ```
42
+
43
+ The test suite includes:
44
+ - `basic.test.js` - Core WASM API functionality tests
45
+ - `tests/usaf_memo.test.js` - Smoke test that verifies WASM PDF output is functionally identical to native cargo output for the `usaf_memo` example (Typst backend)
46
+ - `tests/usaf_form_8.test.js` - Smoke test that verifies WASM PDF output is byte-for-byte identical to native cargo output for the `usaf_form_8` example (Acroform backend)
47
+
48
+ ## Usage
49
+
50
+ ```typescript
51
+ import { Quillmark } from '@quillmark-test/wasm';
52
+
53
+ // Step 1: Parse markdown
54
+ const markdown = `---
55
+ title: My Document
56
+ author: Alice
57
+ QUILL: my-quill
58
+ ---
59
+
60
+ # Hello World
61
+
62
+ This is my document.
63
+ `;
64
+
65
+ const parsed = Quillmark.parseMarkdown(markdown);
66
+
67
+ // Step 2: Create engine and register Quill
68
+ const engine = new Quillmark();
69
+
70
+ const quillJson = {
71
+ files: {
72
+ 'Quill.toml': {
73
+ contents: '[Quill]\nname = "my-quill"\nbackend = "typst"\nglue_file = "glue.typ"\ndescription = "My template"\n'
74
+ },
75
+ 'glue.typ': {
76
+ contents: '= {{ title }}\n\n{{ body | Content }}'
77
+ }
78
+ }
79
+ };
80
+
81
+ engine.registerQuill(quillJson);
82
+
83
+ // Step 3: Get Quill info (optional)
84
+ const info = engine.getQuillInfo('my-quill');
85
+ console.log('Supported formats:', info.supportedFormats);
86
+ console.log('Field schemas:', info.fieldSchemas);
87
+
88
+ // Step 4: Render
89
+ const result = engine.render(parsed, { format: 'pdf' });
90
+
91
+ // Access the PDF bytes
92
+ const pdfArtifact = result.artifacts[0];
93
+ const blob = new Blob([pdfArtifact.bytes], { type: pdfArtifact.mimeType });
94
+ const url = URL.createObjectURL(blob);
95
+ window.open(url);
96
+ ```
97
+
98
+ ## API
99
+
100
+ The `Quillmark` class provides the following methods:
101
+
102
+ ### Workflow Methods
103
+
104
+ The main workflow for rendering documents:
105
+
106
+ - `static parseMarkdown(markdown)` - Parse markdown into a ParsedDocument (Step 1)
107
+ - `registerQuill(quillJson)` - Register a Quill template bundle from JSON (Step 2)
108
+ - `getQuillInfo(name)` - Get shallow Quill metadata and configuration options (Step 3)
109
+ - `render(parsedDoc, options)` - Render a ParsedDocument to final artifacts (Step 4)
110
+
111
+ ### Utility Methods
112
+
113
+ Additional methods for managing the engine and debugging:
114
+
115
+ - `new Quillmark()` - Create a new engine instance
116
+ - `processGlue(quillName, markdown)` - Debug helper that processes markdown through the template engine and returns the intermediate template source code (e.g., Typst, LaTeX) without compiling to final artifacts. Useful for inspecting template output during development.
117
+ - `listQuills()` - List all registered Quill names
118
+ - `unregisterQuill(name)` - Unregister a Quill to free memory
119
+
120
+ ### Render Options
121
+
122
+ ```typescript
123
+ {
124
+ format?: 'pdf' | 'svg' | 'txt', // Output format (default: 'pdf')
125
+ assets?: Record<string, Uint8Array>, // Additional assets to inject as plain object (not Map)
126
+ quillName?: string // Override quill_tag from ParsedDocument
127
+ }
128
+ ```
129
+
130
+ ### ParsedDocument
131
+
132
+ Returned by `parseMarkdown()`:
133
+
134
+ ```typescript
135
+ {
136
+ fields: object, // YAML frontmatter fields
137
+ quillTag?: string // Value of QUILL field (if present)
138
+ }
139
+ ```
140
+
141
+ ### QuillInfo
142
+
143
+ Returned by `getQuillInfo()`:
144
+
145
+ ```typescript
146
+ {
147
+ name: string,
148
+ backend: string, // e.g., "typst"
149
+ metadata: object, // Quill metadata from Quill.toml
150
+ example?: string, // Example markdown (if available)
151
+ fieldSchemas: object, // Field schema definitions
152
+ supportedFormats: Array<'pdf' | 'svg' | 'txt'> // Formats this backend supports
153
+ }
154
+ ```
155
+
156
+ ## WASM Boundary Types
157
+
158
+ Data crossing the JavaScript ↔ WebAssembly boundary:
159
+
160
+ - **Enums**: Serialized as lowercase strings (`"pdf"`, `"svg"`, `"txt"`)
161
+ - **Binary data**: `Vec<u8>` maps to `Uint8Array`
162
+ - **Collections**: `Vec<T>` maps to JS arrays; object types use plain JS objects `{}`
163
+ - **Option**: `Option<T>` maps to `T | null`
164
+ - **Errors**: Thrown as exceptions using `SerializableDiagnostic` from core, containing structured diagnostic information (severity, message, location, hint, source chain)
165
+
166
+ ## Design Principles
167
+
168
+ - **JSON-Only Data Exchange**: All structured data uses `serde-wasm-bindgen`
169
+ - **JavaScript Handles I/O**: WASM layer only handles rendering
170
+ - **Synchronous Operations**: Rendering is fast enough (<100ms typically)
171
+ - **No File System Abstractions**: JavaScript prepares all data
172
+ - **Error Delegation**: Error handling delegated to core types (`SerializableDiagnostic`) for consistency with Python bindings
173
+
174
+ ## License
175
+
176
+ Licensed under the Apache License, Version 2.0.
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@quillmark/wasm",
3
+ "version": "0.11.0",
4
+ "description": "WebAssembly bindings for quillmark",
5
+ "type": "module",
6
+ "license": "MIT OR Apache-2.0",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/nibsbin/quillmark"
10
+ },
11
+ "files": [
12
+ "wasm_bg.wasm",
13
+ "wasm_bg.js",
14
+ "wasm_bg.wasm.d.ts",
15
+ "wasm.js",
16
+ "wasm.d.ts"
17
+ ],
18
+ "main": "./wasm.js",
19
+ "module": "./wasm.js",
20
+ "types": "./wasm.d.ts",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./wasm.d.ts",
24
+ "import": "./wasm.js",
25
+ "default": "./wasm.js"
26
+ }
27
+ },
28
+ "sideEffects": [
29
+ "./wasm.js"
30
+ ]
31
+ }
package/wasm.d.ts ADDED
@@ -0,0 +1,115 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Initialize the WASM module with panic hooks for better error messages
5
+ */
6
+ export function init(): void;
7
+ export type OutputFormat = "pdf" | "svg" | "txt";
8
+
9
+ export type Severity = "error" | "warning" | "note";
10
+
11
+ export interface Location {
12
+ file: string;
13
+ line: number;
14
+ column: number;
15
+ }
16
+
17
+ export interface Diagnostic {
18
+ severity: Severity;
19
+ code?: string;
20
+ message: string;
21
+ location?: Location;
22
+ hint?: string;
23
+ sourceChain: string[];
24
+ }
25
+
26
+ export interface Artifact {
27
+ format: OutputFormat;
28
+ bytes: Uint8Array;
29
+ mimeType: string;
30
+ }
31
+
32
+ export interface RenderResult {
33
+ artifacts: Artifact[];
34
+ warnings: Diagnostic[];
35
+ outputFormat: OutputFormat;
36
+ renderTimeMs: number;
37
+ }
38
+
39
+ export interface QuillInfo {
40
+ name: string;
41
+ backend: string;
42
+ metadata: Record<string, any>;
43
+ example?: string;
44
+ schema: Record<string, any>;
45
+ defaults: Record<string, any>;
46
+ examples: Record<string, any[]>;
47
+ supportedFormats: OutputFormat[];
48
+ }
49
+
50
+ export interface ParsedDocument {
51
+ fields: Record<string, any>;
52
+ quillTag: string;
53
+ }
54
+
55
+ export interface RenderOptions {
56
+ format?: OutputFormat;
57
+ assets?: Record<string, Uint8Array | number[]>;
58
+ quillName?: string;
59
+ }
60
+
61
+ /**
62
+ * Quillmark WASM Engine
63
+ *
64
+ * Create once, register Quills, render markdown. That's it.
65
+ */
66
+ export class Quillmark {
67
+ free(): void;
68
+ [Symbol.dispose](): void;
69
+ /**
70
+ * JavaScript constructor: `new Quillmark()`
71
+ */
72
+ constructor();
73
+ /**
74
+ * Parse markdown into a ParsedDocument
75
+ *
76
+ * This is the first step in the workflow. The returned ParsedDocument contains
77
+ * the parsed YAML frontmatter fields and the quill_tag (from QUILL field or "__default__").
78
+ */
79
+ static parseMarkdown(markdown: string): ParsedDocument;
80
+ /**
81
+ * Register a Quill template bundle
82
+ *
83
+ * Accepts either a JSON string or a JsValue object representing the Quill file tree.
84
+ * Validation happens automatically on registration.
85
+ */
86
+ registerQuill(quill_json: any): QuillInfo;
87
+ /**
88
+ * Get shallow information about a registered Quill
89
+ *
90
+ * This returns metadata, backend info, field schemas, and supported formats
91
+ * that consumers need to configure render options for the next step.
92
+ */
93
+ getQuillInfo(name: string): QuillInfo;
94
+ /**
95
+ * Process markdown through template engine (debugging)
96
+ *
97
+ * Returns template source code (Typst, LaTeX, etc.)
98
+ */
99
+ processPlate(quill_name: string, markdown: string): string;
100
+ /**
101
+ * Render a ParsedDocument to final artifacts (PDF, SVG, TXT)
102
+ *
103
+ * Uses the Quill specified in options.quill_name if provided,
104
+ * otherwise infers it from the ParsedDocument's quill_tag field.
105
+ */
106
+ render(parsed_wasm: ParsedDocument, opts: RenderOptions): RenderResult;
107
+ /**
108
+ * List registered Quill names
109
+ */
110
+ listQuills(): string[];
111
+ /**
112
+ * Unregister a Quill (free memory)
113
+ */
114
+ unregisterQuill(name: string): void;
115
+ }
package/wasm.js ADDED
@@ -0,0 +1,5 @@
1
+ import * as wasm from "./wasm_bg.wasm";
2
+ export * from "./wasm_bg.js";
3
+ import { __wbg_set_wasm } from "./wasm_bg.js";
4
+ __wbg_set_wasm(wasm);
5
+ wasm.__wbindgen_start();
package/wasm_bg.js ADDED
@@ -0,0 +1,748 @@
1
+ let wasm;
2
+ export function __wbg_set_wasm(val) {
3
+ wasm = val;
4
+ }
5
+
6
+
7
+ let cachedUint8ArrayMemory0 = null;
8
+
9
+ function getUint8ArrayMemory0() {
10
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
11
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
12
+ }
13
+ return cachedUint8ArrayMemory0;
14
+ }
15
+
16
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
17
+
18
+ cachedTextDecoder.decode();
19
+
20
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
21
+ let numBytesDecoded = 0;
22
+ function decodeText(ptr, len) {
23
+ numBytesDecoded += len;
24
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
25
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
26
+ cachedTextDecoder.decode();
27
+ numBytesDecoded = len;
28
+ }
29
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
30
+ }
31
+
32
+ function getStringFromWasm0(ptr, len) {
33
+ ptr = ptr >>> 0;
34
+ return decodeText(ptr, len);
35
+ }
36
+
37
+ let heap = new Array(128).fill(undefined);
38
+
39
+ heap.push(undefined, null, true, false);
40
+
41
+ let heap_next = heap.length;
42
+
43
+ function addHeapObject(obj) {
44
+ if (heap_next === heap.length) heap.push(heap.length + 1);
45
+ const idx = heap_next;
46
+ heap_next = heap[idx];
47
+
48
+ heap[idx] = obj;
49
+ return idx;
50
+ }
51
+
52
+ function getObject(idx) { return heap[idx]; }
53
+
54
+ let WASM_VECTOR_LEN = 0;
55
+
56
+ const cachedTextEncoder = new TextEncoder();
57
+
58
+ if (!('encodeInto' in cachedTextEncoder)) {
59
+ cachedTextEncoder.encodeInto = function (arg, view) {
60
+ const buf = cachedTextEncoder.encode(arg);
61
+ view.set(buf);
62
+ return {
63
+ read: arg.length,
64
+ written: buf.length
65
+ };
66
+ }
67
+ }
68
+
69
+ function passStringToWasm0(arg, malloc, realloc) {
70
+
71
+ if (realloc === undefined) {
72
+ const buf = cachedTextEncoder.encode(arg);
73
+ const ptr = malloc(buf.length, 1) >>> 0;
74
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
75
+ WASM_VECTOR_LEN = buf.length;
76
+ return ptr;
77
+ }
78
+
79
+ let len = arg.length;
80
+ let ptr = malloc(len, 1) >>> 0;
81
+
82
+ const mem = getUint8ArrayMemory0();
83
+
84
+ let offset = 0;
85
+
86
+ for (; offset < len; offset++) {
87
+ const code = arg.charCodeAt(offset);
88
+ if (code > 0x7F) break;
89
+ mem[ptr + offset] = code;
90
+ }
91
+
92
+ if (offset !== len) {
93
+ if (offset !== 0) {
94
+ arg = arg.slice(offset);
95
+ }
96
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
97
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
98
+ const ret = cachedTextEncoder.encodeInto(arg, view);
99
+
100
+ offset += ret.written;
101
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
102
+ }
103
+
104
+ WASM_VECTOR_LEN = offset;
105
+ return ptr;
106
+ }
107
+
108
+ let cachedDataViewMemory0 = null;
109
+
110
+ function getDataViewMemory0() {
111
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
112
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
113
+ }
114
+ return cachedDataViewMemory0;
115
+ }
116
+
117
+ function handleError(f, args) {
118
+ try {
119
+ return f.apply(this, args);
120
+ } catch (e) {
121
+ wasm.__wbindgen_export_2(addHeapObject(e));
122
+ }
123
+ }
124
+
125
+ function getArrayU8FromWasm0(ptr, len) {
126
+ ptr = ptr >>> 0;
127
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
128
+ }
129
+
130
+ function dropObject(idx) {
131
+ if (idx < 132) return;
132
+ heap[idx] = heap_next;
133
+ heap_next = idx;
134
+ }
135
+
136
+ function takeObject(idx) {
137
+ const ret = getObject(idx);
138
+ dropObject(idx);
139
+ return ret;
140
+ }
141
+
142
+ function isLikeNone(x) {
143
+ return x === undefined || x === null;
144
+ }
145
+
146
+ function debugString(val) {
147
+ // primitive types
148
+ const type = typeof val;
149
+ if (type == 'number' || type == 'boolean' || val == null) {
150
+ return `${val}`;
151
+ }
152
+ if (type == 'string') {
153
+ return `"${val}"`;
154
+ }
155
+ if (type == 'symbol') {
156
+ const description = val.description;
157
+ if (description == null) {
158
+ return 'Symbol';
159
+ } else {
160
+ return `Symbol(${description})`;
161
+ }
162
+ }
163
+ if (type == 'function') {
164
+ const name = val.name;
165
+ if (typeof name == 'string' && name.length > 0) {
166
+ return `Function(${name})`;
167
+ } else {
168
+ return 'Function';
169
+ }
170
+ }
171
+ // objects
172
+ if (Array.isArray(val)) {
173
+ const length = val.length;
174
+ let debug = '[';
175
+ if (length > 0) {
176
+ debug += debugString(val[0]);
177
+ }
178
+ for(let i = 1; i < length; i++) {
179
+ debug += ', ' + debugString(val[i]);
180
+ }
181
+ debug += ']';
182
+ return debug;
183
+ }
184
+ // Test for built-in
185
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
186
+ let className;
187
+ if (builtInMatches && builtInMatches.length > 1) {
188
+ className = builtInMatches[1];
189
+ } else {
190
+ // Failed to match the standard '[object ClassName]'
191
+ return toString.call(val);
192
+ }
193
+ if (className == 'Object') {
194
+ // we're a user defined class or Object
195
+ // JSON.stringify avoids problems with cycles, and is generally much
196
+ // easier than looping through ownProperties of `val`.
197
+ try {
198
+ return 'Object(' + JSON.stringify(val) + ')';
199
+ } catch (_) {
200
+ return 'Object';
201
+ }
202
+ }
203
+ // errors
204
+ if (val instanceof Error) {
205
+ return `${val.name}: ${val.message}\n${val.stack}`;
206
+ }
207
+ // TODO we could test for more things here, like `Set`s and `Map`s.
208
+ return className;
209
+ }
210
+
211
+ function getArrayJsValueFromWasm0(ptr, len) {
212
+ ptr = ptr >>> 0;
213
+ const mem = getDataViewMemory0();
214
+ const result = [];
215
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
216
+ result.push(takeObject(mem.getUint32(i, true)));
217
+ }
218
+ return result;
219
+ }
220
+ /**
221
+ * Initialize the WASM module with panic hooks for better error messages
222
+ */
223
+ export function init() {
224
+ wasm.init();
225
+ }
226
+
227
+ const QuillmarkFinalization = (typeof FinalizationRegistry === 'undefined')
228
+ ? { register: () => {}, unregister: () => {} }
229
+ : new FinalizationRegistry(ptr => wasm.__wbg_quillmark_free(ptr >>> 0, 1));
230
+ /**
231
+ * Quillmark WASM Engine
232
+ *
233
+ * Create once, register Quills, render markdown. That's it.
234
+ */
235
+ export class Quillmark {
236
+
237
+ __destroy_into_raw() {
238
+ const ptr = this.__wbg_ptr;
239
+ this.__wbg_ptr = 0;
240
+ QuillmarkFinalization.unregister(this);
241
+ return ptr;
242
+ }
243
+
244
+ free() {
245
+ const ptr = this.__destroy_into_raw();
246
+ wasm.__wbg_quillmark_free(ptr, 0);
247
+ }
248
+ /**
249
+ * JavaScript constructor: `new Quillmark()`
250
+ */
251
+ constructor() {
252
+ const ret = wasm.quillmark_new();
253
+ this.__wbg_ptr = ret >>> 0;
254
+ QuillmarkFinalization.register(this, this.__wbg_ptr, this);
255
+ return this;
256
+ }
257
+ /**
258
+ * Parse markdown into a ParsedDocument
259
+ *
260
+ * This is the first step in the workflow. The returned ParsedDocument contains
261
+ * the parsed YAML frontmatter fields and the quill_tag (from QUILL field or "__default__").
262
+ * @param {string} markdown
263
+ * @returns {ParsedDocument}
264
+ */
265
+ static parseMarkdown(markdown) {
266
+ try {
267
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
268
+ const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
269
+ const len0 = WASM_VECTOR_LEN;
270
+ wasm.quillmark_parseMarkdown(retptr, ptr0, len0);
271
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
272
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
273
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
274
+ if (r2) {
275
+ throw takeObject(r1);
276
+ }
277
+ return takeObject(r0);
278
+ } finally {
279
+ wasm.__wbindgen_add_to_stack_pointer(16);
280
+ }
281
+ }
282
+ /**
283
+ * Register a Quill template bundle
284
+ *
285
+ * Accepts either a JSON string or a JsValue object representing the Quill file tree.
286
+ * Validation happens automatically on registration.
287
+ * @param {any} quill_json
288
+ * @returns {QuillInfo}
289
+ */
290
+ registerQuill(quill_json) {
291
+ try {
292
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
293
+ wasm.quillmark_registerQuill(retptr, this.__wbg_ptr, addHeapObject(quill_json));
294
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
295
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
296
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
297
+ if (r2) {
298
+ throw takeObject(r1);
299
+ }
300
+ return takeObject(r0);
301
+ } finally {
302
+ wasm.__wbindgen_add_to_stack_pointer(16);
303
+ }
304
+ }
305
+ /**
306
+ * Get shallow information about a registered Quill
307
+ *
308
+ * This returns metadata, backend info, field schemas, and supported formats
309
+ * that consumers need to configure render options for the next step.
310
+ * @param {string} name
311
+ * @returns {QuillInfo}
312
+ */
313
+ getQuillInfo(name) {
314
+ try {
315
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
316
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
317
+ const len0 = WASM_VECTOR_LEN;
318
+ wasm.quillmark_getQuillInfo(retptr, this.__wbg_ptr, ptr0, len0);
319
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
320
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
321
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
322
+ if (r2) {
323
+ throw takeObject(r1);
324
+ }
325
+ return takeObject(r0);
326
+ } finally {
327
+ wasm.__wbindgen_add_to_stack_pointer(16);
328
+ }
329
+ }
330
+ /**
331
+ * Process markdown through template engine (debugging)
332
+ *
333
+ * Returns template source code (Typst, LaTeX, etc.)
334
+ * @param {string} quill_name
335
+ * @param {string} markdown
336
+ * @returns {string}
337
+ */
338
+ processPlate(quill_name, markdown) {
339
+ let deferred4_0;
340
+ let deferred4_1;
341
+ try {
342
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
343
+ const ptr0 = passStringToWasm0(quill_name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
344
+ const len0 = WASM_VECTOR_LEN;
345
+ const ptr1 = passStringToWasm0(markdown, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
346
+ const len1 = WASM_VECTOR_LEN;
347
+ wasm.quillmark_processPlate(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
348
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
349
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
350
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
351
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
352
+ var ptr3 = r0;
353
+ var len3 = r1;
354
+ if (r3) {
355
+ ptr3 = 0; len3 = 0;
356
+ throw takeObject(r2);
357
+ }
358
+ deferred4_0 = ptr3;
359
+ deferred4_1 = len3;
360
+ return getStringFromWasm0(ptr3, len3);
361
+ } finally {
362
+ wasm.__wbindgen_add_to_stack_pointer(16);
363
+ wasm.__wbindgen_export_3(deferred4_0, deferred4_1, 1);
364
+ }
365
+ }
366
+ /**
367
+ * Render a ParsedDocument to final artifacts (PDF, SVG, TXT)
368
+ *
369
+ * Uses the Quill specified in options.quill_name if provided,
370
+ * otherwise infers it from the ParsedDocument's quill_tag field.
371
+ * @param {ParsedDocument} parsed_wasm
372
+ * @param {RenderOptions} opts
373
+ * @returns {RenderResult}
374
+ */
375
+ render(parsed_wasm, opts) {
376
+ try {
377
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
378
+ wasm.quillmark_render(retptr, this.__wbg_ptr, addHeapObject(parsed_wasm), addHeapObject(opts));
379
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
380
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
381
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
382
+ if (r2) {
383
+ throw takeObject(r1);
384
+ }
385
+ return takeObject(r0);
386
+ } finally {
387
+ wasm.__wbindgen_add_to_stack_pointer(16);
388
+ }
389
+ }
390
+ /**
391
+ * List registered Quill names
392
+ * @returns {string[]}
393
+ */
394
+ listQuills() {
395
+ try {
396
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
397
+ wasm.quillmark_listQuills(retptr, this.__wbg_ptr);
398
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
399
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
400
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
401
+ wasm.__wbindgen_export_3(r0, r1 * 4, 4);
402
+ return v1;
403
+ } finally {
404
+ wasm.__wbindgen_add_to_stack_pointer(16);
405
+ }
406
+ }
407
+ /**
408
+ * Unregister a Quill (free memory)
409
+ * @param {string} name
410
+ */
411
+ unregisterQuill(name) {
412
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
413
+ const len0 = WASM_VECTOR_LEN;
414
+ wasm.quillmark_unregisterQuill(this.__wbg_ptr, ptr0, len0);
415
+ }
416
+ }
417
+ if (Symbol.dispose) Quillmark.prototype[Symbol.dispose] = Quillmark.prototype.free;
418
+
419
+ export function __wbg_Error_e17e777aac105295(arg0, arg1) {
420
+ const ret = Error(getStringFromWasm0(arg0, arg1));
421
+ return addHeapObject(ret);
422
+ };
423
+
424
+ export function __wbg_String_eecc4a11987127d6(arg0, arg1) {
425
+ const ret = String(getObject(arg1));
426
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
427
+ const len1 = WASM_VECTOR_LEN;
428
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
429
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
430
+ };
431
+
432
+ export function __wbg_call_13410aac570ffff7() { return handleError(function (arg0, arg1) {
433
+ const ret = getObject(arg0).call(getObject(arg1));
434
+ return addHeapObject(ret);
435
+ }, arguments) };
436
+
437
+ export function __wbg_done_75ed0ee6dd243d9d(arg0) {
438
+ const ret = getObject(arg0).done;
439
+ return ret;
440
+ };
441
+
442
+ export function __wbg_entries_2be2f15bd5554996(arg0) {
443
+ const ret = Object.entries(getObject(arg0));
444
+ return addHeapObject(ret);
445
+ };
446
+
447
+ export function __wbg_error_7534b8e9a36f1ab4(arg0, arg1) {
448
+ let deferred0_0;
449
+ let deferred0_1;
450
+ try {
451
+ deferred0_0 = arg0;
452
+ deferred0_1 = arg1;
453
+ console.error(getStringFromWasm0(arg0, arg1));
454
+ } finally {
455
+ wasm.__wbindgen_export_3(deferred0_0, deferred0_1, 1);
456
+ }
457
+ };
458
+
459
+ export function __wbg_getRandomValues_1c61fac11405ffdc() { return handleError(function (arg0, arg1) {
460
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
461
+ }, arguments) };
462
+
463
+ export function __wbg_getTime_6bb3f64e0f18f817(arg0) {
464
+ const ret = getObject(arg0).getTime();
465
+ return ret;
466
+ };
467
+
468
+ export function __wbg_getUTCDate_e0a363240ba1c112(arg0) {
469
+ const ret = getObject(arg0).getUTCDate();
470
+ return ret;
471
+ };
472
+
473
+ export function __wbg_getUTCFullYear_811e319dd2642ac0(arg0) {
474
+ const ret = getObject(arg0).getUTCFullYear();
475
+ return ret;
476
+ };
477
+
478
+ export function __wbg_getUTCMonth_ed74da16cf6f6c98(arg0) {
479
+ const ret = getObject(arg0).getUTCMonth();
480
+ return ret;
481
+ };
482
+
483
+ export function __wbg_get_0da715ceaecea5c8(arg0, arg1) {
484
+ const ret = getObject(arg0)[arg1 >>> 0];
485
+ return addHeapObject(ret);
486
+ };
487
+
488
+ export function __wbg_get_458e874b43b18b25() { return handleError(function (arg0, arg1) {
489
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
490
+ return addHeapObject(ret);
491
+ }, arguments) };
492
+
493
+ export function __wbg_getwithrefkey_6550b2c093d2eb18(arg0, arg1) {
494
+ const ret = getObject(arg0)[getObject(arg1)];
495
+ return addHeapObject(ret);
496
+ };
497
+
498
+ export function __wbg_instanceof_ArrayBuffer_67f3012529f6a2dd(arg0) {
499
+ let result;
500
+ try {
501
+ result = getObject(arg0) instanceof ArrayBuffer;
502
+ } catch (_) {
503
+ result = false;
504
+ }
505
+ const ret = result;
506
+ return ret;
507
+ };
508
+
509
+ export function __wbg_instanceof_Uint8Array_9a8378d955933db7(arg0) {
510
+ let result;
511
+ try {
512
+ result = getObject(arg0) instanceof Uint8Array;
513
+ } catch (_) {
514
+ result = false;
515
+ }
516
+ const ret = result;
517
+ return ret;
518
+ };
519
+
520
+ export function __wbg_isArray_030cce220591fb41(arg0) {
521
+ const ret = Array.isArray(getObject(arg0));
522
+ return ret;
523
+ };
524
+
525
+ export function __wbg_isSafeInteger_1c0d1af5542e102a(arg0) {
526
+ const ret = Number.isSafeInteger(getObject(arg0));
527
+ return ret;
528
+ };
529
+
530
+ export function __wbg_iterator_f370b34483c71a1c() {
531
+ const ret = Symbol.iterator;
532
+ return addHeapObject(ret);
533
+ };
534
+
535
+ export function __wbg_length_186546c51cd61acd(arg0) {
536
+ const ret = getObject(arg0).length;
537
+ return ret;
538
+ };
539
+
540
+ export function __wbg_length_6bb7e81f9d7713e4(arg0) {
541
+ const ret = getObject(arg0).length;
542
+ return ret;
543
+ };
544
+
545
+ export function __wbg_new0_b0a0a38c201e6df5() {
546
+ const ret = new Date();
547
+ return addHeapObject(ret);
548
+ };
549
+
550
+ export function __wbg_new_19c25a3f2fa63a02() {
551
+ const ret = new Object();
552
+ return addHeapObject(ret);
553
+ };
554
+
555
+ export function __wbg_new_1f3a344cf3123716() {
556
+ const ret = new Array();
557
+ return addHeapObject(ret);
558
+ };
559
+
560
+ export function __wbg_new_2ff1f68f3676ea53() {
561
+ const ret = new Map();
562
+ return addHeapObject(ret);
563
+ };
564
+
565
+ export function __wbg_new_5a2ae4557f92b50e(arg0) {
566
+ const ret = new Date(getObject(arg0));
567
+ return addHeapObject(ret);
568
+ };
569
+
570
+ export function __wbg_new_638ebfaedbf32a5e(arg0) {
571
+ const ret = new Uint8Array(getObject(arg0));
572
+ return addHeapObject(ret);
573
+ };
574
+
575
+ export function __wbg_new_8a6f238a6ece86ea() {
576
+ const ret = new Error();
577
+ return addHeapObject(ret);
578
+ };
579
+
580
+ export function __wbg_next_5b3530e612fde77d(arg0) {
581
+ const ret = getObject(arg0).next;
582
+ return addHeapObject(ret);
583
+ };
584
+
585
+ export function __wbg_next_692e82279131b03c() { return handleError(function (arg0) {
586
+ const ret = getObject(arg0).next();
587
+ return addHeapObject(ret);
588
+ }, arguments) };
589
+
590
+ export function __wbg_now_1e80617bcee43265() {
591
+ const ret = Date.now();
592
+ return ret;
593
+ };
594
+
595
+ export function __wbg_prototypesetcall_3d4a26c1ed734349(arg0, arg1, arg2) {
596
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
597
+ };
598
+
599
+ export function __wbg_set_3807d5f0bfc24aa7(arg0, arg1, arg2) {
600
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
601
+ };
602
+
603
+ export function __wbg_set_3f1d0b984ed272ed(arg0, arg1, arg2) {
604
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
605
+ };
606
+
607
+ export function __wbg_set_90f6c0f7bd8c0415(arg0, arg1, arg2) {
608
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
609
+ };
610
+
611
+ export function __wbg_set_b7f1cf4fae26fe2a(arg0, arg1, arg2) {
612
+ const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
613
+ return addHeapObject(ret);
614
+ };
615
+
616
+ export function __wbg_stack_0ed75d68575b0f3c(arg0, arg1) {
617
+ const ret = getObject(arg1).stack;
618
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
619
+ const len1 = WASM_VECTOR_LEN;
620
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
621
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
622
+ };
623
+
624
+ export function __wbg_stringify_b98c93d0a190446a() { return handleError(function (arg0) {
625
+ const ret = JSON.stringify(getObject(arg0));
626
+ return addHeapObject(ret);
627
+ }, arguments) };
628
+
629
+ export function __wbg_value_dd9372230531eade(arg0) {
630
+ const ret = getObject(arg0).value;
631
+ return addHeapObject(ret);
632
+ };
633
+
634
+ export function __wbg_wbindgenbigintgetasi64_ac743ece6ab9bba1(arg0, arg1) {
635
+ const v = getObject(arg1);
636
+ const ret = typeof(v) === 'bigint' ? v : undefined;
637
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
638
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
639
+ };
640
+
641
+ export function __wbg_wbindgenbooleanget_3fe6f642c7d97746(arg0) {
642
+ const v = getObject(arg0);
643
+ const ret = typeof(v) === 'boolean' ? v : undefined;
644
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
645
+ };
646
+
647
+ export function __wbg_wbindgendebugstring_99ef257a3ddda34d(arg0, arg1) {
648
+ const ret = debugString(getObject(arg1));
649
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
650
+ const len1 = WASM_VECTOR_LEN;
651
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
652
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
653
+ };
654
+
655
+ export function __wbg_wbindgenin_d7a1ee10933d2d55(arg0, arg1) {
656
+ const ret = getObject(arg0) in getObject(arg1);
657
+ return ret;
658
+ };
659
+
660
+ export function __wbg_wbindgenisbigint_ecb90cc08a5a9154(arg0) {
661
+ const ret = typeof(getObject(arg0)) === 'bigint';
662
+ return ret;
663
+ };
664
+
665
+ export function __wbg_wbindgenisfunction_8cee7dce3725ae74(arg0) {
666
+ const ret = typeof(getObject(arg0)) === 'function';
667
+ return ret;
668
+ };
669
+
670
+ export function __wbg_wbindgenisobject_307a53c6bd97fbf8(arg0) {
671
+ const val = getObject(arg0);
672
+ const ret = typeof(val) === 'object' && val !== null;
673
+ return ret;
674
+ };
675
+
676
+ export function __wbg_wbindgenisstring_d4fa939789f003b0(arg0) {
677
+ const ret = typeof(getObject(arg0)) === 'string';
678
+ return ret;
679
+ };
680
+
681
+ export function __wbg_wbindgenisundefined_c4b71d073b92f3c5(arg0) {
682
+ const ret = getObject(arg0) === undefined;
683
+ return ret;
684
+ };
685
+
686
+ export function __wbg_wbindgenjsvaleq_e6f2ad59ccae1b58(arg0, arg1) {
687
+ const ret = getObject(arg0) === getObject(arg1);
688
+ return ret;
689
+ };
690
+
691
+ export function __wbg_wbindgenjsvallooseeq_9bec8c9be826bed1(arg0, arg1) {
692
+ const ret = getObject(arg0) == getObject(arg1);
693
+ return ret;
694
+ };
695
+
696
+ export function __wbg_wbindgennumberget_f74b4c7525ac05cb(arg0, arg1) {
697
+ const obj = getObject(arg1);
698
+ const ret = typeof(obj) === 'number' ? obj : undefined;
699
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
700
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
701
+ };
702
+
703
+ export function __wbg_wbindgenstringget_0f16a6ddddef376f(arg0, arg1) {
704
+ const obj = getObject(arg1);
705
+ const ret = typeof(obj) === 'string' ? obj : undefined;
706
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
707
+ var len1 = WASM_VECTOR_LEN;
708
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
709
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
710
+ };
711
+
712
+ export function __wbg_wbindgenthrow_451ec1a8469d7eb6(arg0, arg1) {
713
+ throw new Error(getStringFromWasm0(arg0, arg1));
714
+ };
715
+
716
+ export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
717
+ // Cast intrinsic for `Ref(String) -> Externref`.
718
+ const ret = getStringFromWasm0(arg0, arg1);
719
+ return addHeapObject(ret);
720
+ };
721
+
722
+ export function __wbindgen_cast_4625c577ab2ec9ee(arg0) {
723
+ // Cast intrinsic for `U64 -> Externref`.
724
+ const ret = BigInt.asUintN(64, arg0);
725
+ return addHeapObject(ret);
726
+ };
727
+
728
+ export function __wbindgen_cast_9ae0607507abb057(arg0) {
729
+ // Cast intrinsic for `I64 -> Externref`.
730
+ const ret = arg0;
731
+ return addHeapObject(ret);
732
+ };
733
+
734
+ export function __wbindgen_cast_d6cd19b81560fd6e(arg0) {
735
+ // Cast intrinsic for `F64 -> Externref`.
736
+ const ret = arg0;
737
+ return addHeapObject(ret);
738
+ };
739
+
740
+ export function __wbindgen_object_clone_ref(arg0) {
741
+ const ret = getObject(arg0);
742
+ return addHeapObject(ret);
743
+ };
744
+
745
+ export function __wbindgen_object_drop_ref(arg0) {
746
+ takeObject(arg0);
747
+ };
748
+
package/wasm_bg.wasm ADDED
Binary file
@@ -0,0 +1,32 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const __wbg_quillmark_free: (a: number, b: number) => void;
5
+ export const quillmark_new: () => number;
6
+ export const quillmark_parseMarkdown: (a: number, b: number, c: number) => void;
7
+ export const quillmark_registerQuill: (a: number, b: number, c: number) => void;
8
+ export const quillmark_getQuillInfo: (a: number, b: number, c: number, d: number) => void;
9
+ export const quillmark_processPlate: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
10
+ export const quillmark_render: (a: number, b: number, c: number, d: number) => void;
11
+ export const quillmark_listQuills: (a: number, b: number) => void;
12
+ export const quillmark_unregisterQuill: (a: number, b: number, c: number) => void;
13
+ export const init: () => void;
14
+ export const qcms_profile_is_bogus: (a: number) => number;
15
+ export const qcms_white_point_sRGB: (a: number) => void;
16
+ export const qcms_profile_precache_output_transform: (a: number) => void;
17
+ export const qcms_transform_data_rgb_out_lut_precache: (a: number, b: number, c: number, d: number) => void;
18
+ export const qcms_transform_data_rgba_out_lut_precache: (a: number, b: number, c: number, d: number) => void;
19
+ export const qcms_transform_data_bgra_out_lut_precache: (a: number, b: number, c: number, d: number) => void;
20
+ export const qcms_transform_data_rgb_out_lut: (a: number, b: number, c: number, d: number) => void;
21
+ export const qcms_transform_data_rgba_out_lut: (a: number, b: number, c: number, d: number) => void;
22
+ export const qcms_transform_data_bgra_out_lut: (a: number, b: number, c: number, d: number) => void;
23
+ export const qcms_transform_release: (a: number) => void;
24
+ export const qcms_enable_iccv4: () => void;
25
+ export const lut_interp_linear16: (a: number, b: number, c: number) => number;
26
+ export const lut_inverse_interp16: (a: number, b: number, c: number) => number;
27
+ export const __wbindgen_export_0: (a: number, b: number) => number;
28
+ export const __wbindgen_export_1: (a: number, b: number, c: number, d: number) => number;
29
+ export const __wbindgen_export_2: (a: number) => void;
30
+ export const __wbindgen_export_3: (a: number, b: number, c: number) => void;
31
+ export const __wbindgen_add_to_stack_pointer: (a: number) => number;
32
+ export const __wbindgen_start: () => void;