@quillmark/wasm 0.101.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 +105 -0
- package/README.md +68 -15
- package/backends/pdfform/wasm.d.ts +232 -68
- 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 +232 -68
- 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 +199 -59
- 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 +60 -26
- package/runtime/runtime.js +200 -41
- package/runtime/uninit.js +57 -0
- package/backends/pdfform/wasm_bg.js +0 -2863
- package/backends/typst/wasm_bg.js +0 -2887
- package/core/wasm_bg.js +0 -2359
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
|
|
@@ -411,7 +444,7 @@ export interface PaintResult {
|
|
|
411
444
|
|
|
412
445
|
/**
|
|
413
446
|
* Canonical contract every backend build must satisfy. Output of
|
|
414
|
-
* {@link LiveSession.
|
|
447
|
+
* {@link LiveSession.update}: `dirtyPages` lists the pages whose rendered
|
|
415
448
|
* content differs from the previous compile, including added pages; removed
|
|
416
449
|
* pages are implied by `pageCount`. Repaint `dirty ∩ visible`.
|
|
417
450
|
*/
|
|
@@ -463,7 +496,7 @@ export declare class Engine {
|
|
|
463
496
|
render(quill: Quill, doc: Document, options?: RenderOptions): Promise<RenderResult>;
|
|
464
497
|
|
|
465
498
|
/**
|
|
466
|
-
* Open a live render session (canvas preview / per-page paint / `
|
|
499
|
+
* Open a live render session (canvas preview / per-page paint / `update`).
|
|
467
500
|
* The `quill` and `doc` handles are read synchronously before the first
|
|
468
501
|
* await, so the caller may `free()` them as soon as this call returns; the
|
|
469
502
|
* caller owns the returned session and must `.free()` it.
|
|
@@ -524,10 +557,10 @@ export declare class LiveSession {
|
|
|
524
557
|
* Recompile the session against `doc`: the edit verb of a live preview.
|
|
525
558
|
* Transactional: on throw every read (`render`, `paint`, `pageSize`,
|
|
526
559
|
* `regions`) keeps serving the last-good compile, and the session recovers
|
|
527
|
-
* on the next successful `
|
|
560
|
+
* on the next successful `update`. On success reads serve the new compile;
|
|
528
561
|
* repaint `dirtyPages ∩ visible`.
|
|
529
562
|
*/
|
|
530
|
-
|
|
563
|
+
update(doc: Document): ChangeSet;
|
|
531
564
|
render(options?: RenderOptions): RenderResult;
|
|
532
565
|
/**
|
|
533
566
|
* Schema-field geometry for this compiled session, keyed on the canonical
|
|
@@ -642,7 +675,7 @@ declare module '../core/wasm.js' {
|
|
|
642
675
|
/**
|
|
643
676
|
* A `Document` bound to its `Quill` for typed writes: the schema-bound writer,
|
|
644
677
|
* constructed via {@link Quill.writer}. Speaks names, values, and markdown. Bare
|
|
645
|
-
* `set` / `setAll` / `
|
|
678
|
+
* `set` / `setAll` / `reviseBody` / `reviseField` / `addCard` / `card(i).set`
|
|
646
679
|
* instead of threading the `quill` handle through the underscored ABI. Holds both
|
|
647
680
|
* handles by reference and owns neither: nothing to `free()`.
|
|
648
681
|
*
|
|
@@ -669,11 +702,12 @@ export declare class DocumentWriter {
|
|
|
669
702
|
*/
|
|
670
703
|
setAll(fields: Record<string, unknown>): void;
|
|
671
704
|
/**
|
|
672
|
-
*
|
|
673
|
-
* the
|
|
674
|
-
*
|
|
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.
|
|
675
709
|
*/
|
|
676
|
-
|
|
710
|
+
reviseBody(markdown: string): Delta;
|
|
677
711
|
/**
|
|
678
712
|
* Revise the content main-card field `name` from authored text: typed *and*
|
|
679
713
|
* anchor-preserving. Surviving anchors rebase, then the diffed result is
|
|
@@ -725,8 +759,8 @@ export declare class CardWriter {
|
|
|
725
759
|
readonly kind: string;
|
|
726
760
|
set(name: string, value: unknown): void;
|
|
727
761
|
setAll(fields: Record<string, unknown>): void;
|
|
728
|
-
/**
|
|
729
|
-
|
|
762
|
+
/** Revise this card's body from markdown (edit semantics), returning the text `Delta`. */
|
|
763
|
+
reviseBody(markdown: string): Delta;
|
|
730
764
|
/**
|
|
731
765
|
* Revise the content field `name` on this card from authored text: typed *and*
|
|
732
766
|
* anchor-preserving; the card twin of {@link DocumentWriter.reviseField},
|
|
@@ -747,12 +781,12 @@ export declare class CardWriter {
|
|
|
747
781
|
* The schema authority is the point: unlike the quill-free transport `Document.getStored`,
|
|
748
782
|
* a name the schema does not declare throws `UnknownField` (a typo) rather than
|
|
749
783
|
* reading back `undefined`, and a content field holding a value that does not
|
|
750
|
-
* decode throws `
|
|
751
|
-
* 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
|
|
752
786
|
* is a format fact) and never throws.
|
|
753
787
|
*
|
|
754
788
|
* `getContent` is the same read at the other end of the codec, returning the
|
|
755
|
-
*
|
|
789
|
+
* `Content` rather than the projection. It binds the quill for the same reason
|
|
756
790
|
* `get` does: a `richtext` string is markdown and a `plaintext` string is
|
|
757
791
|
* literal text, so the same stored bytes decode two ways and only the declared
|
|
758
792
|
* type says which.
|
|
@@ -766,23 +800,23 @@ export declare class DocumentReader {
|
|
|
766
800
|
* to markdown, every other type verbatim. A bare string is `Addr` shorthand for
|
|
767
801
|
* `{ field }`; an absent `addr.field` reads the body markdown. `undefined` for
|
|
768
802
|
* an absent field; throws `UnknownField` for a name the schema does not declare,
|
|
769
|
-
* `
|
|
803
|
+
* `FieldDecode` for a richtext field holding an undecodable value, and
|
|
770
804
|
* `IndexOutOfRange` for a bad `addr.card`.
|
|
771
805
|
*/
|
|
772
806
|
get(addr: Addr | string): unknown;
|
|
773
807
|
/**
|
|
774
|
-
* Read the content field at `addr` as its canonical `Content
|
|
775
|
-
*
|
|
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
|
|
776
810
|
* declared type names (`richtext` as markdown, `plaintext` as literal text),
|
|
777
|
-
* 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
|
|
778
812
|
* storage form stops being the caller's business. An absent `addr.field`
|
|
779
|
-
* reads the body
|
|
813
|
+
* reads the body `Content`. `undefined` for an absent field; throws
|
|
780
814
|
* `UnknownField`, `FieldNotContent` for a declared type that is not a content
|
|
781
|
-
* leaf, `
|
|
815
|
+
* leaf, `FieldDecode` for an undecodable value, and `IndexOutOfRange`.
|
|
782
816
|
*/
|
|
783
817
|
getContent(addr: Addr | string): Content | undefined;
|
|
784
818
|
/** The main body's markdown: the quill-free body read. Equals `get({})`. */
|
|
785
|
-
|
|
819
|
+
bodyMarkdown(): string;
|
|
786
820
|
/**
|
|
787
821
|
* A {@link CardReader} for the composable card at `index`. Index validity is
|
|
788
822
|
* checked lazily at read time, so an out-of-range index does not throw here.
|
|
@@ -815,9 +849,9 @@ export declare class CardReader {
|
|
|
815
849
|
get(name: string): unknown;
|
|
816
850
|
/**
|
|
817
851
|
* Read the content field `name` on this card as its canonical `Content`
|
|
818
|
-
*
|
|
852
|
+
* `Content`: the card twin of {@link DocumentReader.getContent}.
|
|
819
853
|
*/
|
|
820
854
|
getContent(name: string): Content | undefined;
|
|
821
|
-
/** This card's body markdown: the card twin of {@link DocumentReader.
|
|
822
|
-
|
|
855
|
+
/** This card's body markdown: the card twin of {@link DocumentReader.bodyMarkdown}. */
|
|
856
|
+
bodyMarkdown(): string;
|
|
823
857
|
}
|