@quillmark/wasm 0.88.0 → 0.90.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +127 -0
- package/README.md +79 -27
- package/{bundler → backends/typst}/wasm.d.ts +60 -24
- package/{bundler → backends/typst}/wasm_bg.js +119 -55
- package/{bundler → backends/typst}/wasm_bg.wasm +0 -0
- package/{bundler → backends/typst}/wasm_bg.wasm.d.ts +6 -4
- package/core/wasm.d.ts +439 -0
- package/core/wasm.js +9 -0
- package/core/wasm_bg.js +1496 -0
- package/core/wasm_bg.wasm +0 -0
- package/core/wasm_bg.wasm.d.ts +62 -0
- package/package.json +13 -13
- package/runtime/runtime.d.ts +212 -0
- package/runtime/runtime.js +378 -0
- /package/{bundler → backends/typst}/wasm.js +0 -0
|
Binary file
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_document_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_quill_free: (a: number, b: number) => void;
|
|
6
|
+
export const document_blueprintInstruction: (a: number, b: number, c: number) => void;
|
|
7
|
+
export const document_cardCount: (a: number) => number;
|
|
8
|
+
export const document_cards: (a: number) => number;
|
|
9
|
+
export const document_clone: (a: number) => number;
|
|
10
|
+
export const document_currentSchemaVersion: (a: number) => void;
|
|
11
|
+
export const document_equals: (a: number, b: number) => number;
|
|
12
|
+
export const document_formatDiagnostic: (a: number, b: number) => void;
|
|
13
|
+
export const document_formatRules: (a: number) => void;
|
|
14
|
+
export const document_fromJson: (a: number, b: number, c: number) => void;
|
|
15
|
+
export const document_fromMarkdown: (a: number, b: number, c: number) => void;
|
|
16
|
+
export const document_insertCard: (a: number, b: number, c: number, d: number) => void;
|
|
17
|
+
export const document_main: (a: number) => number;
|
|
18
|
+
export const document_makeCard: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
19
|
+
export const document_moveCard: (a: number, b: number, c: number, d: number) => void;
|
|
20
|
+
export const document_pushCard: (a: number, b: number, c: number) => void;
|
|
21
|
+
export const document_quillRef: (a: number, b: number) => void;
|
|
22
|
+
export const document_quillRefHint: (a: number) => void;
|
|
23
|
+
export const document_removeCard: (a: number, b: number) => number;
|
|
24
|
+
export const document_removeCardExt: (a: number, b: number, c: number) => void;
|
|
25
|
+
export const document_removeCardExtNamespace: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
26
|
+
export const document_removeCardField: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
27
|
+
export const document_removeExt: (a: number) => number;
|
|
28
|
+
export const document_removeExtNamespace: (a: number, b: number, c: number) => number;
|
|
29
|
+
export const document_removeField: (a: number, b: number, c: number, d: number) => void;
|
|
30
|
+
export const document_replaceBody: (a: number, b: number, c: number) => void;
|
|
31
|
+
export const document_schemaVersionOf: (a: number, b: number, c: number) => void;
|
|
32
|
+
export const document_setCardExt: (a: number, b: number, c: number, d: number) => void;
|
|
33
|
+
export const document_setCardExtNamespace: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
34
|
+
export const document_setCardKind: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
35
|
+
export const document_setExt: (a: number, b: number, c: number) => void;
|
|
36
|
+
export const document_setExtNamespace: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
37
|
+
export const document_setField: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
38
|
+
export const document_setFill: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
39
|
+
export const document_setQuillRef: (a: number, b: number, c: number, d: number) => void;
|
|
40
|
+
export const document_toJson: (a: number, b: number) => void;
|
|
41
|
+
export const document_toMarkdown: (a: number, b: number) => void;
|
|
42
|
+
export const document_tryFromJson: (a: number, b: number) => number;
|
|
43
|
+
export const document_updateCardBody: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
44
|
+
export const document_updateCardField: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
45
|
+
export const document_warnings: (a: number) => number;
|
|
46
|
+
export const init: () => void;
|
|
47
|
+
export const quill_backendId: (a: number, b: number) => void;
|
|
48
|
+
export const quill_blueprint: (a: number, b: number) => void;
|
|
49
|
+
export const quill_fromTree: (a: number, b: number) => void;
|
|
50
|
+
export const quill_metadata: (a: number) => number;
|
|
51
|
+
export const quill_schema: (a: number) => number;
|
|
52
|
+
export const quill_seedCard: (a: number, b: number, c: number) => number;
|
|
53
|
+
export const quill_seedDocument: (a: number) => number;
|
|
54
|
+
export const quill_seedMain: (a: number) => number;
|
|
55
|
+
export const quill_toTree: (a: number) => number;
|
|
56
|
+
export const quill_validate: (a: number, b: number, c: number) => void;
|
|
57
|
+
export const __wbindgen_export: (a: number, b: number) => number;
|
|
58
|
+
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
59
|
+
export const __wbindgen_export3: (a: number) => void;
|
|
60
|
+
export const __wbindgen_export4: (a: number, b: number, c: number) => void;
|
|
61
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
62
|
+
export const __wbindgen_start: () => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quillmark/wasm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.90.0",
|
|
4
4
|
"description": "WebAssembly bindings for quillmark",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT OR Apache-2.0",
|
|
@@ -12,24 +12,24 @@
|
|
|
12
12
|
"url": "git+https://github.com/quillmark-org/quillmark.git"
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"bundler/wasm.js",
|
|
19
|
-
"bundler/wasm.d.ts",
|
|
15
|
+
"core",
|
|
16
|
+
"backends",
|
|
17
|
+
"runtime",
|
|
20
18
|
"CHANGELOG.md"
|
|
21
19
|
],
|
|
22
|
-
"main": "./
|
|
23
|
-
"module": "./
|
|
24
|
-
"types": "./
|
|
20
|
+
"main": "./runtime/runtime.js",
|
|
21
|
+
"module": "./runtime/runtime.js",
|
|
22
|
+
"types": "./runtime/runtime.d.ts",
|
|
25
23
|
"exports": {
|
|
26
24
|
".": {
|
|
27
|
-
"types": "./
|
|
28
|
-
"import": "./
|
|
29
|
-
"default": "./
|
|
25
|
+
"types": "./runtime/runtime.d.ts",
|
|
26
|
+
"import": "./runtime/runtime.js",
|
|
27
|
+
"default": "./runtime/runtime.js"
|
|
30
28
|
}
|
|
31
29
|
},
|
|
32
30
|
"sideEffects": [
|
|
33
|
-
"./
|
|
31
|
+
"./core/wasm.js",
|
|
32
|
+
"./backends/typst/wasm.js",
|
|
33
|
+
"./runtime/runtime.js"
|
|
34
34
|
]
|
|
35
35
|
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
// @quillmark/wasm/runtime — canonical consumer API.
|
|
2
|
+
//
|
|
3
|
+
// `Quill`/`Document` are re-exported verbatim from the core build (their full
|
|
4
|
+
// surface, no drift). Render-side types (`RenderResult`, `RenderOptions`,
|
|
5
|
+
// `Artifact`, `OutputFormat`, `PageSize`, `PaintOptions`, `PaintResult`) are
|
|
6
|
+
// defined HERE as the canonical, backend-neutral render contract — NOT sourced
|
|
7
|
+
// from any one private backend build. A type-level drift guard
|
|
8
|
+
// (`runtime.types.test-d.ts`, via `npm run typecheck`) asserts they stay
|
|
9
|
+
// mutually assignable with the Typst backend's generated declarations. `Engine`
|
|
10
|
+
// is the render dispatcher that hides the cross-WASM-memory seam.
|
|
11
|
+
|
|
12
|
+
// CANONICAL INVARIANT: the root re-exports the core build's `Quill`/`Document`
|
|
13
|
+
// verbatim — they are the SAME classes, never wrappers. There is exactly one
|
|
14
|
+
// public entry point, so this is a structural fact. Replacing the re-export
|
|
15
|
+
// with a wrapper is a breaking design change, not a refactor. See runtime.js.
|
|
16
|
+
export { Quill, Document, init } from '../core/wasm.js';
|
|
17
|
+
|
|
18
|
+
// Core-build types consumers read off `Quill`/`Document`.
|
|
19
|
+
export type {
|
|
20
|
+
Card,
|
|
21
|
+
PayloadItem,
|
|
22
|
+
Diagnostic,
|
|
23
|
+
Location,
|
|
24
|
+
Severity,
|
|
25
|
+
QuillSchema,
|
|
26
|
+
QuillFieldSchema,
|
|
27
|
+
QuillCardSchema,
|
|
28
|
+
QuillCardBody,
|
|
29
|
+
QuillFieldUi,
|
|
30
|
+
QuillCardUi,
|
|
31
|
+
QuillMetadata
|
|
32
|
+
} from '../core/wasm.js';
|
|
33
|
+
|
|
34
|
+
// ── Error contract ──────────────────────────────────────────────────────────
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The error every fallible method in this package throws — parse
|
|
38
|
+
* (`Document.fromMarkdown`), document mutation, validation
|
|
39
|
+
* (`Quill.fromTree`, `quill.validate`), and rendering (`engine.render`,
|
|
40
|
+
* `engine.open`, `session.render`).
|
|
41
|
+
*
|
|
42
|
+
* This is a STRUCTURAL interface, not a class: the WASM layer throws a real
|
|
43
|
+
* `Error` and attaches `diagnostics` to it, so there is no constructor to
|
|
44
|
+
* `instanceof` against — narrow with {@link isQuillmarkError}. `diagnostics`
|
|
45
|
+
* is always non-empty; `message` is the first diagnostic's message (or an
|
|
46
|
+
* `"N error(s): …"` aggregate for multi-diagnostic failures), so iterate
|
|
47
|
+
* `diagnostics` for per-error detail. The shape is identical to
|
|
48
|
+
* `RenderResult.warnings` entries.
|
|
49
|
+
*/
|
|
50
|
+
export interface QuillmarkError extends Error {
|
|
51
|
+
diagnostics: Diagnostic[];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Narrow an unknown caught value to {@link QuillmarkError}. Structural
|
|
56
|
+
* (`Error` carrying a `diagnostics` array), so it works on errors from any
|
|
57
|
+
* build or WASM instance in the page — consistent with the package's
|
|
58
|
+
* duck-typed handling of handles.
|
|
59
|
+
*/
|
|
60
|
+
export declare function isQuillmarkError(e: unknown): e is QuillmarkError;
|
|
61
|
+
|
|
62
|
+
// ── Canonical render-side types ─────────────────────────────────────────────
|
|
63
|
+
// These are the BACKEND-NEUTRAL render contract of the plural-backend API. They
|
|
64
|
+
// are defined HERE (not re-exported from one private backend) because no single
|
|
65
|
+
// backend build owns the canonical API's types. Every backend build MUST satisfy
|
|
66
|
+
// these shapes; that they match the Typst backend's generated declarations is
|
|
67
|
+
// enforced by the type-level drift guard `crates/bindings/wasm/runtime.types.test-d.ts`
|
|
68
|
+
// (run via `npm run typecheck`), so these and the generated
|
|
69
|
+
// `pkg/backends/typst/wasm.d.ts` cannot silently diverge.
|
|
70
|
+
|
|
71
|
+
import type { Quill, Document } from '../core/wasm.js';
|
|
72
|
+
import type { Diagnostic } from '../core/wasm.js';
|
|
73
|
+
|
|
74
|
+
/** Canonical contract every backend build must satisfy. One emitted output. */
|
|
75
|
+
export interface Artifact {
|
|
76
|
+
format: OutputFormat;
|
|
77
|
+
bytes: Uint8Array;
|
|
78
|
+
mimeType: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Canonical contract every backend build must satisfy. Options for one render. */
|
|
82
|
+
export interface RenderOptions {
|
|
83
|
+
format?: OutputFormat;
|
|
84
|
+
ppi?: number;
|
|
85
|
+
pages?: number[];
|
|
86
|
+
producer?: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Canonical contract every backend build must satisfy. Result of one render. */
|
|
90
|
+
export interface RenderResult {
|
|
91
|
+
artifacts: Artifact[];
|
|
92
|
+
warnings: Diagnostic[];
|
|
93
|
+
outputFormat: OutputFormat;
|
|
94
|
+
renderTimeMs: number;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Canonical contract every backend build must satisfy. The emittable formats. */
|
|
98
|
+
export type OutputFormat = 'pdf' | 'svg' | 'txt' | 'png';
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Canonical contract every backend build must satisfy. Page geometry in pt.
|
|
102
|
+
* @experimental Part of the iterative-session/canvas surface — see {@link RenderSession}.
|
|
103
|
+
*/
|
|
104
|
+
export interface PageSize {
|
|
105
|
+
widthPt: number;
|
|
106
|
+
heightPt: number;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Canonical contract every backend build must satisfy. Inputs to `paint`.
|
|
111
|
+
* @experimental Part of the iterative-session/canvas surface — see {@link RenderSession}.
|
|
112
|
+
*/
|
|
113
|
+
export interface PaintOptions {
|
|
114
|
+
layoutScale?: number;
|
|
115
|
+
densityScale?: number;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Canonical contract every backend build must satisfy. Output of `paint`.
|
|
120
|
+
* @experimental Part of the iterative-session/canvas surface — see {@link RenderSession}.
|
|
121
|
+
*/
|
|
122
|
+
export interface PaintResult {
|
|
123
|
+
layoutWidth: number;
|
|
124
|
+
layoutHeight: number;
|
|
125
|
+
pixelWidth: number;
|
|
126
|
+
pixelHeight: number;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* A backend registry entry. `load` is the lazy thunk returning the dynamically-
|
|
131
|
+
* imported backend build module; `formats`/`canvas` are the REQUIRED static
|
|
132
|
+
* capability manifest. That manifest is what makes
|
|
133
|
+
* `Engine.supportedFormats`/`Engine.supportsCanvas` always FREE: they answer
|
|
134
|
+
* from it directly — no backend binary is loaded and no quill is cloned into
|
|
135
|
+
* backend memory. A malformed descriptor throws at `new Engine(...)`.
|
|
136
|
+
*/
|
|
137
|
+
export interface BackendDescriptor {
|
|
138
|
+
load: () => Promise<unknown>;
|
|
139
|
+
formats: OutputFormat[];
|
|
140
|
+
canvas: boolean;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface EngineOptions {
|
|
144
|
+
/**
|
|
145
|
+
* Extra or overriding backend descriptors, merged over the built-ins. Keys are
|
|
146
|
+
* backend ids (as declared by `Quill.yaml`'s `backend:` and reported by
|
|
147
|
+
* `Quill.backendId`). Each value is a `BackendDescriptor` — `formats`/`canvas`
|
|
148
|
+
* are required, so capability probes are ALWAYS free (no binary load, no quill
|
|
149
|
+
* clone). Malformed entries throw at construction. The default registry maps
|
|
150
|
+
* `"typst"` to the bundled Typst build.
|
|
151
|
+
*/
|
|
152
|
+
backends?: Record<string, BackendDescriptor>;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Render dispatcher over the canonical `Quill`/`Document`. Routes on
|
|
157
|
+
* `quill.backendId`, lazily loads that backend build, clones the quill and
|
|
158
|
+
* document into the backend's WASM memory on demand, renders, and frees the
|
|
159
|
+
* clones. The cross-memory crossing is invisible to callers.
|
|
160
|
+
*/
|
|
161
|
+
export declare class Engine {
|
|
162
|
+
constructor(options?: EngineOptions);
|
|
163
|
+
|
|
164
|
+
/** Render `doc` against `quill` in one shot. */
|
|
165
|
+
render(quill: Quill, doc: Document, options?: RenderOptions): Promise<RenderResult>;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Open an iterative render session (canvas preview / per-page paint).
|
|
169
|
+
* @experimental Ships ahead of its first production consumer (the designed
|
|
170
|
+
* canvas live-preview path — see `prose/canon/PREVIEW.md`). The session/paint
|
|
171
|
+
* surface may change in any 0.x release; `render()` is the stable path.
|
|
172
|
+
*/
|
|
173
|
+
open(quill: Quill, doc: Document): Promise<RenderSession>;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Output formats `quill`'s backend can emit. An ALWAYS-free pre-render probe:
|
|
177
|
+
* it answers from the descriptor's required `formats` manifest WITHOUT loading
|
|
178
|
+
* the backend binary or cloning the quill. Async for API stability.
|
|
179
|
+
*/
|
|
180
|
+
supportedFormats(quill: Quill): Promise<OutputFormat[]>;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Whether `quill`'s backend can paint sessions to a canvas. Same always-free
|
|
184
|
+
* probe as `supportedFormats`: answered from the descriptor's required
|
|
185
|
+
* `canvas` manifest, no binary load and no quill clone.
|
|
186
|
+
* @experimental Probes the experimental session/canvas surface — see {@link RenderSession}.
|
|
187
|
+
*/
|
|
188
|
+
supportsCanvas(quill: Quill): Promise<boolean>;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Iterative render session over a compiled snapshot. `free()` when done.
|
|
193
|
+
* @experimental The whole session/canvas-paint surface (`Engine.open`,
|
|
194
|
+
* `RenderSession`, `PaintOptions`, `PaintResult`, `PageSize`) ships ahead of
|
|
195
|
+
* its first production consumer and may change shape in any 0.x release.
|
|
196
|
+
* The stable render path is `Engine.render`.
|
|
197
|
+
*/
|
|
198
|
+
export declare class RenderSession {
|
|
199
|
+
private constructor();
|
|
200
|
+
readonly pageCount: number;
|
|
201
|
+
readonly backendId: string;
|
|
202
|
+
readonly supportsCanvas: boolean;
|
|
203
|
+
readonly warnings: Diagnostic[];
|
|
204
|
+
render(options?: RenderOptions): RenderResult;
|
|
205
|
+
pageSize(page: number): PageSize;
|
|
206
|
+
paint(
|
|
207
|
+
ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D,
|
|
208
|
+
page: number,
|
|
209
|
+
options?: PaintOptions
|
|
210
|
+
): PaintResult;
|
|
211
|
+
free(): void;
|
|
212
|
+
}
|