@quillmark/wasm 0.100.0 → 0.102.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 +124 -0
- package/README.md +68 -15
- package/backends/pdfform/wasm.d.ts +265 -67
- package/backends/pdfform/wasm.js +2980 -8
- package/backends/pdfform/wasm_bg.wasm +0 -0
- package/backends/pdfform/wasm_bg.wasm.d.ts +8 -8
- package/backends/typst/wasm.d.ts +265 -67
- package/backends/typst/wasm.js +3004 -8
- package/backends/typst/wasm_bg.wasm +0 -0
- package/backends/typst/wasm_bg.wasm.d.ts +8 -8
- package/core/wasm.d.ts +232 -58
- package/core/wasm.js +2471 -8
- package/core/wasm_bg.wasm +0 -0
- package/core/wasm_bg.wasm.d.ts +7 -7
- package/package.json +7 -4
- package/runtime/env-node.js +20 -0
- package/runtime/env-web.js +19 -0
- package/runtime/runtime.d.ts +61 -26
- package/runtime/runtime.js +200 -41
- package/runtime/uninit.js +57 -0
- package/backends/pdfform/wasm_bg.js +0 -2858
- package/backends/typst/wasm_bg.js +0 -2882
- package/core/wasm_bg.js +0 -2354
package/core/wasm_bg.wasm
CHANGED
|
Binary file
|
package/core/wasm_bg.wasm.d.ts
CHANGED
|
@@ -11,11 +11,12 @@ export const document__readerGetContent: (a: number, b: number, c: number, d: nu
|
|
|
11
11
|
export const document__reviseField: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
12
12
|
export const document_applyChange: (a: number, b: number, c: number, d: number) => void;
|
|
13
13
|
export const document_blueprintInstruction: (a: number, b: number, c: number) => void;
|
|
14
|
+
export const document_bodyMarkdown: (a: number, b: number, c: number) => void;
|
|
14
15
|
export const document_card: (a: number, b: number, c: number) => void;
|
|
15
16
|
export const document_cardCount: (a: number) => number;
|
|
16
17
|
export const document_cards: (a: number, b: number) => void;
|
|
17
18
|
export const document_clone: (a: number) => number;
|
|
18
|
-
export const
|
|
19
|
+
export const document_currentStorageVersion: (a: number) => void;
|
|
19
20
|
export const document_equals: (a: number, b: number) => number;
|
|
20
21
|
export const document_formatDiagnostic: (a: number, b: number) => void;
|
|
21
22
|
export const document_formatRules: (a: number) => void;
|
|
@@ -23,34 +24,33 @@ export const document_fromJson: (a: number, b: number, c: number) => void;
|
|
|
23
24
|
export const document_fromMarkdown: (a: number, b: number, c: number) => void;
|
|
24
25
|
export const document_getExt: (a: number, b: number, c: number) => void;
|
|
25
26
|
export const document_getExtNamespace: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
26
|
-
export const document_getMarkdown: (a: number, b: number, c: number) => void;
|
|
27
27
|
export const document_getStored: (a: number, b: number, c: number) => void;
|
|
28
28
|
export const document_insertCard: (a: number, b: number, c: number, d: number) => void;
|
|
29
|
-
export const document_install: (a: number, b: number, c: number, d: number) => void;
|
|
30
29
|
export const document_isFill: (a: number, b: number, c: number) => void;
|
|
31
30
|
export const document_loadJson: (a: number, b: number, c: number, d: number) => void;
|
|
32
31
|
export const document_main: (a: number, b: number) => void;
|
|
33
32
|
export const document_makeCard: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
34
33
|
export const document_moveCard: (a: number, b: number, c: number, d: number) => void;
|
|
35
34
|
export const document_new: (a: number, b: number, c: number) => void;
|
|
35
|
+
export const document_overwrite: (a: number, b: number, c: number, d: number) => void;
|
|
36
36
|
export const document_quillRef: (a: number, b: number) => void;
|
|
37
37
|
export const document_quillRefHint: (a: number) => void;
|
|
38
38
|
export const document_removeCard: (a: number, b: number, c: number) => void;
|
|
39
39
|
export const document_removeExt: (a: number, b: number, c: number) => void;
|
|
40
40
|
export const document_removeExtNamespace: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
41
41
|
export const document_removeField: (a: number, b: number, c: number) => void;
|
|
42
|
-
export const
|
|
42
|
+
export const document_removeSeedOverlay: (a: number, b: number, c: number, d: number) => void;
|
|
43
43
|
export const document_revise: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
44
|
-
export const document_schemaVersionOf: (a: number, b: number, c: number) => void;
|
|
45
44
|
export const document_seedOverlay: (a: number, b: number, c: number, d: number) => void;
|
|
46
45
|
export const document_setCardKind: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
47
46
|
export const document_setQuillRef: (a: number, b: number, c: number, d: number) => void;
|
|
47
|
+
export const document_storageVersionOf: (a: number, b: number, c: number) => void;
|
|
48
48
|
export const document_storeExt: (a: number, b: number, c: number, d: number) => void;
|
|
49
49
|
export const document_storeExtNamespace: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
50
50
|
export const document_storeField: (a: number, b: number, c: number, d: number) => void;
|
|
51
51
|
export const document_storeFields: (a: number, b: number, c: number, d: number) => void;
|
|
52
52
|
export const document_storeFill: (a: number, b: number, c: number, d: number) => void;
|
|
53
|
-
export const
|
|
53
|
+
export const document_storeSeedOverlay: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
54
54
|
export const document_toJson: (a: number, b: number) => void;
|
|
55
55
|
export const document_toMarkdown: (a: number, b: number) => void;
|
|
56
56
|
export const document_tryFromJson: (a: number, b: number) => number;
|
|
@@ -58,7 +58,6 @@ export const document_warnings: (a: number, b: number) => void;
|
|
|
58
58
|
export const exportMarkdown: (a: number, b: number) => void;
|
|
59
59
|
export const formatDocPath: (a: number, b: number) => void;
|
|
60
60
|
export const importMarkdown: (a: number, b: number, c: number) => void;
|
|
61
|
-
export const init: () => void;
|
|
62
61
|
export const mapPos: (a: number, b: number, c: number, d: number) => void;
|
|
63
62
|
export const parseDocPath: (a: number, b: number, c: number) => void;
|
|
64
63
|
export const quill_backendId: (a: number, b: number) => void;
|
|
@@ -75,6 +74,7 @@ export const quill_seedMain: (a: number, b: number) => void;
|
|
|
75
74
|
export const quill_toTree: (a: number) => number;
|
|
76
75
|
export const quill_validate: (a: number, b: number, c: number) => void;
|
|
77
76
|
export const rebase: (a: number, b: number, c: number, d: number) => void;
|
|
77
|
+
export const start: () => void;
|
|
78
78
|
export const __wbindgen_export: (a: number, b: number) => number;
|
|
79
79
|
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
80
80
|
export const __wbindgen_export3: (a: number) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quillmark/wasm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.102.0",
|
|
4
4
|
"description": "WebAssembly bindings for Quillmark, a schema-driven document engine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -27,10 +27,13 @@
|
|
|
27
27
|
"default": "./runtime/runtime.js"
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
|
+
"imports": {
|
|
31
|
+
"#quillmark-env": {
|
|
32
|
+
"node": "./runtime/env-node.js",
|
|
33
|
+
"default": "./runtime/env-web.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
30
36
|
"sideEffects": [
|
|
31
|
-
"./core/wasm.js",
|
|
32
|
-
"./backends/typst/wasm.js",
|
|
33
|
-
"./backends/pdfform/wasm.js",
|
|
34
37
|
"./runtime/runtime.js"
|
|
35
38
|
]
|
|
36
39
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// The Node half of the `#quillmark-env` seam (package.json `imports`). See
|
|
2
|
+
// env-web.js for why the seam is resolution-time rather than a runtime branch.
|
|
3
|
+
//
|
|
4
|
+
// Node's `fetch` rejects `file:` URLs, so the default source (a `file:` URL
|
|
5
|
+
// pointing at the binary beside this package) is read off disk into bytes.
|
|
6
|
+
// Everything else (caller-supplied bytes, a `Response`, a `WebAssembly.Module`,
|
|
7
|
+
// an `http:` URL) passes through to the generated glue untouched.
|
|
8
|
+
|
|
9
|
+
import { readFile } from 'node:fs/promises';
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param {unknown} source
|
|
14
|
+
* @returns {Promise<unknown> | unknown} bytes for a `file:` URL, else `source`
|
|
15
|
+
*/
|
|
16
|
+
export function toModuleSource(source) {
|
|
17
|
+
return source instanceof URL && source.protocol === 'file:'
|
|
18
|
+
? readFile(fileURLToPath(source))
|
|
19
|
+
: source;
|
|
20
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// The browser half of the `#quillmark-env` seam (package.json `imports`): the
|
|
2
|
+
// wasm byte source, resolved per environment at module resolution rather than
|
|
3
|
+
// by sniffing globals at runtime.
|
|
4
|
+
//
|
|
5
|
+
// A pass-through here. wasm-bindgen's `--target web` glue accepts a URL and
|
|
6
|
+
// fetches it itself (`WebAssembly.instantiateStreaming`), the streaming path.
|
|
7
|
+
//
|
|
8
|
+
// The seam exists for the Node half, which cannot, and `node:fs` must never
|
|
9
|
+
// reach a browser graph. Static resolution keeps it out: no `typeof process`
|
|
10
|
+
// branch for a bundler to trip over, no dynamic `import('node:fs')` to warn
|
|
11
|
+
// about.
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {unknown} source
|
|
15
|
+
* @returns {unknown} `source` unchanged
|
|
16
|
+
*/
|
|
17
|
+
export function toModuleSource(source) {
|
|
18
|
+
return source;
|
|
19
|
+
}
|
package/runtime/runtime.d.ts
CHANGED
|
@@ -18,7 +18,40 @@
|
|
|
18
18
|
// and two `Quill`/`Document` classes. Every method taking a handle refuses one
|
|
19
19
|
// belonging to another copy, with a `QuillmarkError` naming `npm ls
|
|
20
20
|
// @quillmark/wasm`. Errors are the exception: `isQuillmarkError` is structural.
|
|
21
|
-
export { Quill, Document
|
|
21
|
+
export { Quill, Document } from '../core/wasm.js';
|
|
22
|
+
|
|
23
|
+
import type { InitInput } from '../core/wasm.js';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Instantiate the core WASM build. Call once at startup, before any other
|
|
27
|
+
* export is used; extra calls are free.
|
|
28
|
+
*
|
|
29
|
+
* ```js
|
|
30
|
+
* import { init, Quill, Engine } from '@quillmark/wasm';
|
|
31
|
+
* await init();
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* The builds are `--target web`: classes export synchronously, the instance
|
|
35
|
+
* behind them arrives here. Identical in every environment: the binary is
|
|
36
|
+
* fetched and streamed in a browser, read off disk under Node, and the call
|
|
37
|
+
* site is the same line. Reaching a class before this resolves throws
|
|
38
|
+
* `runtime::not_initialized` naming the fix.
|
|
39
|
+
*
|
|
40
|
+
* Idempotent and concurrency-safe: every call returns the same promise, so
|
|
41
|
+
* `await init()` at several entry points costs one instantiation. A failed init
|
|
42
|
+
* clears the memo, so a retry is possible. Per realm: a Worker loads and
|
|
43
|
+
* initializes its own copy.
|
|
44
|
+
*
|
|
45
|
+
* Backends are NOT initialized here. `Engine` instantiates a backend inside its
|
|
46
|
+
* lazy load, on first render against it.
|
|
47
|
+
*
|
|
48
|
+
* @param source override the binary's source (bytes, a `Response`, a
|
|
49
|
+
* `WebAssembly.Module`, a URL) for hosts that route assets themselves or
|
|
50
|
+
* embed the binary. Pass it on the FIRST call; a later call passing a
|
|
51
|
+
* different source throws `runtime::init_conflict` rather than silently
|
|
52
|
+
* ignoring it. Passing the same value again is fine.
|
|
53
|
+
*/
|
|
54
|
+
export declare function init(source?: InitInput): Promise<void>;
|
|
22
55
|
// The document-free content codec, re-exported from the core build.
|
|
23
56
|
export { importMarkdown, exportMarkdown, rebase, mapPos } from '../core/wasm.js';
|
|
24
57
|
// The document-model path parser/serializer: route on `Diagnostic.path`
|
|
@@ -55,7 +88,7 @@ export type {
|
|
|
55
88
|
} from '../core/wasm.js';
|
|
56
89
|
|
|
57
90
|
// Content edit vocabulary: the op-grained content model `Document`'s methods
|
|
58
|
-
// speak (`applyChange(addr, bundle)`, `
|
|
91
|
+
// speak (`applyChange(addr, bundle)`, `overwrite(addr, rt)`, `revise(…) => Delta`).
|
|
59
92
|
// Declared in the core build; re-exported here so the single public entry point
|
|
60
93
|
// names every type its own re-exported surface already references: `Card.body`
|
|
61
94
|
// is a `Content`, `PayloadItem.nestedFills` a `PathStep[][]`, `CardInput.body` a
|
|
@@ -84,6 +117,7 @@ export type {
|
|
|
84
117
|
CardAddr,
|
|
85
118
|
Delta,
|
|
86
119
|
Assoc,
|
|
120
|
+
IslandOp,
|
|
87
121
|
LineOp,
|
|
88
122
|
MarkOp,
|
|
89
123
|
ChangeBundle,
|
|
@@ -410,7 +444,7 @@ export interface PaintResult {
|
|
|
410
444
|
|
|
411
445
|
/**
|
|
412
446
|
* Canonical contract every backend build must satisfy. Output of
|
|
413
|
-
* {@link LiveSession.
|
|
447
|
+
* {@link LiveSession.update}: `dirtyPages` lists the pages whose rendered
|
|
414
448
|
* content differs from the previous compile, including added pages; removed
|
|
415
449
|
* pages are implied by `pageCount`. Repaint `dirty ∩ visible`.
|
|
416
450
|
*/
|
|
@@ -462,7 +496,7 @@ export declare class Engine {
|
|
|
462
496
|
render(quill: Quill, doc: Document, options?: RenderOptions): Promise<RenderResult>;
|
|
463
497
|
|
|
464
498
|
/**
|
|
465
|
-
* Open a live render session (canvas preview / per-page paint / `
|
|
499
|
+
* Open a live render session (canvas preview / per-page paint / `update`).
|
|
466
500
|
* The `quill` and `doc` handles are read synchronously before the first
|
|
467
501
|
* await, so the caller may `free()` them as soon as this call returns; the
|
|
468
502
|
* caller owns the returned session and must `.free()` it.
|
|
@@ -523,10 +557,10 @@ export declare class LiveSession {
|
|
|
523
557
|
* Recompile the session against `doc`: the edit verb of a live preview.
|
|
524
558
|
* Transactional: on throw every read (`render`, `paint`, `pageSize`,
|
|
525
559
|
* `regions`) keeps serving the last-good compile, and the session recovers
|
|
526
|
-
* on the next successful `
|
|
560
|
+
* on the next successful `update`. On success reads serve the new compile;
|
|
527
561
|
* repaint `dirtyPages ∩ visible`.
|
|
528
562
|
*/
|
|
529
|
-
|
|
563
|
+
update(doc: Document): ChangeSet;
|
|
530
564
|
render(options?: RenderOptions): RenderResult;
|
|
531
565
|
/**
|
|
532
566
|
* Schema-field geometry for this compiled session, keyed on the canonical
|
|
@@ -641,7 +675,7 @@ declare module '../core/wasm.js' {
|
|
|
641
675
|
/**
|
|
642
676
|
* A `Document` bound to its `Quill` for typed writes: the schema-bound writer,
|
|
643
677
|
* constructed via {@link Quill.writer}. Speaks names, values, and markdown. Bare
|
|
644
|
-
* `set` / `setAll` / `
|
|
678
|
+
* `set` / `setAll` / `reviseBody` / `reviseField` / `addCard` / `card(i).set`
|
|
645
679
|
* instead of threading the `quill` handle through the underscored ABI. Holds both
|
|
646
680
|
* handles by reference and owns neither: nothing to `free()`.
|
|
647
681
|
*
|
|
@@ -668,11 +702,12 @@ export declare class DocumentWriter {
|
|
|
668
702
|
*/
|
|
669
703
|
setAll(fields: Record<string, unknown>): void;
|
|
670
704
|
/**
|
|
671
|
-
*
|
|
672
|
-
* the
|
|
673
|
-
*
|
|
705
|
+
* Revise the main body from markdown (edit semantics: anchors rebase),
|
|
706
|
+
* returning the text `Delta`. The content lane's `revise` reached through the
|
|
707
|
+
* writer: a body carries no field schema to type against, so the receipt is
|
|
708
|
+
* the content lane's.
|
|
674
709
|
*/
|
|
675
|
-
|
|
710
|
+
reviseBody(markdown: string): Delta;
|
|
676
711
|
/**
|
|
677
712
|
* Revise the content main-card field `name` from authored text: typed *and*
|
|
678
713
|
* anchor-preserving. Surviving anchors rebase, then the diffed result is
|
|
@@ -724,8 +759,8 @@ export declare class CardWriter {
|
|
|
724
759
|
readonly kind: string;
|
|
725
760
|
set(name: string, value: unknown): void;
|
|
726
761
|
setAll(fields: Record<string, unknown>): void;
|
|
727
|
-
/**
|
|
728
|
-
|
|
762
|
+
/** Revise this card's body from markdown (edit semantics), returning the text `Delta`. */
|
|
763
|
+
reviseBody(markdown: string): Delta;
|
|
729
764
|
/**
|
|
730
765
|
* Revise the content field `name` on this card from authored text: typed *and*
|
|
731
766
|
* anchor-preserving; the card twin of {@link DocumentWriter.reviseField},
|
|
@@ -746,12 +781,12 @@ export declare class CardWriter {
|
|
|
746
781
|
* The schema authority is the point: unlike the quill-free transport `Document.getStored`,
|
|
747
782
|
* a name the schema does not declare throws `UnknownField` (a typo) rather than
|
|
748
783
|
* reading back `undefined`, and a content field holding a value that does not
|
|
749
|
-
* decode throws `
|
|
750
|
-
* body-only `Document.
|
|
784
|
+
* decode throws `FieldDecode`. A field's markdown lives here, not on the
|
|
785
|
+
* body-only `Document.bodyMarkdown`. The body read stays quill-free (a body's type
|
|
751
786
|
* is a format fact) and never throws.
|
|
752
787
|
*
|
|
753
788
|
* `getContent` is the same read at the other end of the codec, returning the
|
|
754
|
-
*
|
|
789
|
+
* `Content` rather than the projection. It binds the quill for the same reason
|
|
755
790
|
* `get` does: a `richtext` string is markdown and a `plaintext` string is
|
|
756
791
|
* literal text, so the same stored bytes decode two ways and only the declared
|
|
757
792
|
* type says which.
|
|
@@ -765,23 +800,23 @@ export declare class DocumentReader {
|
|
|
765
800
|
* to markdown, every other type verbatim. A bare string is `Addr` shorthand for
|
|
766
801
|
* `{ field }`; an absent `addr.field` reads the body markdown. `undefined` for
|
|
767
802
|
* an absent field; throws `UnknownField` for a name the schema does not declare,
|
|
768
|
-
* `
|
|
803
|
+
* `FieldDecode` for a richtext field holding an undecodable value, and
|
|
769
804
|
* `IndexOutOfRange` for a bad `addr.card`.
|
|
770
805
|
*/
|
|
771
806
|
get(addr: Addr | string): unknown;
|
|
772
807
|
/**
|
|
773
|
-
* Read the content field at `addr` as its canonical `Content
|
|
774
|
-
*
|
|
808
|
+
* Read the content field at `addr` as its canonical `Content`: the
|
|
809
|
+
* `Content` twin of {@link get}, which projects. Decodes through the codec the
|
|
775
810
|
* declared type names (`richtext` as markdown, `plaintext` as literal text),
|
|
776
|
-
* so a committed field and a parsed one read back the same
|
|
811
|
+
* so a committed field and a parsed one read back the same `Content` and the
|
|
777
812
|
* storage form stops being the caller's business. An absent `addr.field`
|
|
778
|
-
* reads the body
|
|
813
|
+
* reads the body `Content`. `undefined` for an absent field; throws
|
|
779
814
|
* `UnknownField`, `FieldNotContent` for a declared type that is not a content
|
|
780
|
-
* leaf, `
|
|
815
|
+
* leaf, `FieldDecode` for an undecodable value, and `IndexOutOfRange`.
|
|
781
816
|
*/
|
|
782
817
|
getContent(addr: Addr | string): Content | undefined;
|
|
783
818
|
/** The main body's markdown: the quill-free body read. Equals `get({})`. */
|
|
784
|
-
|
|
819
|
+
bodyMarkdown(): string;
|
|
785
820
|
/**
|
|
786
821
|
* A {@link CardReader} for the composable card at `index`. Index validity is
|
|
787
822
|
* checked lazily at read time, so an out-of-range index does not throw here.
|
|
@@ -814,9 +849,9 @@ export declare class CardReader {
|
|
|
814
849
|
get(name: string): unknown;
|
|
815
850
|
/**
|
|
816
851
|
* Read the content field `name` on this card as its canonical `Content`
|
|
817
|
-
*
|
|
852
|
+
* `Content`: the card twin of {@link DocumentReader.getContent}.
|
|
818
853
|
*/
|
|
819
854
|
getContent(name: string): Content | undefined;
|
|
820
|
-
/** This card's body markdown: the card twin of {@link DocumentReader.
|
|
821
|
-
|
|
855
|
+
/** This card's body markdown: the card twin of {@link DocumentReader.bodyMarkdown}. */
|
|
856
|
+
bodyMarkdown(): string;
|
|
822
857
|
}
|