@quillmark/wasm 0.65.1 → 0.66.1
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 +49 -6
- package/bundler/wasm.d.ts +23 -2
- package/bundler/wasm_bg.js +33 -2
- package/bundler/wasm_bg.wasm +0 -0
- package/bundler/wasm_bg.wasm.d.ts +2 -0
- package/node-esm/wasm.d.ts +23 -2
- package/node-esm/wasm.js +33 -2
- package/node-esm/wasm_bg.wasm +0 -0
- package/node-esm/wasm_bg.wasm.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,9 +11,12 @@ Use Quillmark in browsers/Node.js with explicit in-memory trees (`Map<string, Ui
|
|
|
11
11
|
## Build
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
|
|
14
|
+
bash scripts/build-wasm.sh
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
The script builds for `bundler` and `experimental-nodejs-module` targets with
|
|
18
|
+
`--weak-refs` enabled (see [Lifecycle](#lifecycle)).
|
|
19
|
+
|
|
17
20
|
## Test
|
|
18
21
|
|
|
19
22
|
```bash
|
|
@@ -51,11 +54,30 @@ Create engine.
|
|
|
51
54
|
Build + validate + attach backend. Returns a render-ready `Quill`.
|
|
52
55
|
|
|
53
56
|
### `Document.fromMarkdown(markdown)`
|
|
54
|
-
Parse markdown to parsed document.
|
|
57
|
+
Parse markdown to a parsed document. Throws a JS `Error` (with `.diagnostics`
|
|
58
|
+
attached, see [Errors](#errors)) on any parse failure, including missing
|
|
59
|
+
`QUILL`, malformed YAML, and inputs over the 10 MB `parse::input_too_large`
|
|
60
|
+
limit.
|
|
55
61
|
|
|
56
62
|
### `doc.toMarkdown()`
|
|
57
63
|
Emit canonical Quillmark Markdown. Type-fidelity round-trip safe:
|
|
58
|
-
`Document.fromMarkdown(doc.toMarkdown())` returns a document equal to `doc
|
|
64
|
+
`Document.fromMarkdown(doc.toMarkdown())` returns a document equal to `doc`
|
|
65
|
+
under [`doc.equals`](#docequalsother). The output is **not** guaranteed
|
|
66
|
+
byte-equal to the original source — YAML quoting, key ordering, and
|
|
67
|
+
whitespace are normalised. Use `equals` (not string comparison) to test
|
|
68
|
+
semantic equality.
|
|
69
|
+
|
|
70
|
+
### `doc.equals(other)`
|
|
71
|
+
Structural equality between two `Document` handles. Compares `main` and
|
|
72
|
+
`cards` by value; parse-time `warnings` are intentionally excluded.
|
|
73
|
+
|
|
74
|
+
Use this to debounce upstream prop updates: keep the last parsed `Document`
|
|
75
|
+
and compare instead of re-parsing on every keystroke.
|
|
76
|
+
|
|
77
|
+
### `doc.cardCount`
|
|
78
|
+
O(1) getter for the number of composable cards (excluding the main card).
|
|
79
|
+
Use this to validate indices before calling card mutators (`removeCard`,
|
|
80
|
+
`updateCardField`, etc.) without allocating the full `cards` array.
|
|
59
81
|
|
|
60
82
|
### `quill.render(parsed, opts?)`
|
|
61
83
|
Render with a pre-parsed `Document`.
|
|
@@ -65,15 +87,36 @@ Open once, render all or selected pages (`opts.pages`).
|
|
|
65
87
|
|
|
66
88
|
### Errors
|
|
67
89
|
|
|
68
|
-
Every method that can fail throws a JS `Error` with
|
|
90
|
+
Every method that can fail throws a JS `Error` with `.diagnostics` attached:
|
|
69
91
|
|
|
70
92
|
```ts
|
|
71
93
|
{ message: string, diagnostics: Diagnostic[] }
|
|
72
94
|
```
|
|
73
95
|
|
|
74
96
|
`diagnostics` is always non-empty — length 1 for most failures, length N for
|
|
75
|
-
backend compilation errors.
|
|
76
|
-
|
|
97
|
+
backend compilation errors. `message` is derived from `diagnostics`
|
|
98
|
+
(`diagnostics[0].message` for single-diagnostic errors; an aggregate
|
|
99
|
+
`"<N> error(s): <first.message>"` summary for compilation failures).
|
|
100
|
+
|
|
101
|
+
Read `err.diagnostics[0]` for the primary diagnostic; iterate the array for
|
|
102
|
+
compilation failures. The same shape applies to every throw site:
|
|
103
|
+
|
|
104
|
+
- `Document.fromMarkdown` — parse errors (missing `QUILL`, YAML errors,
|
|
105
|
+
`parse::input_too_large` for inputs > 10 MB).
|
|
106
|
+
- `Document` mutators (`setField`, `updateCardField`, etc.) — `EditError`
|
|
107
|
+
variants (`ReservedName`, `InvalidFieldName`, `InvalidTagName`,
|
|
108
|
+
`IndexOutOfRange`) appear in `diagnostics[0].message` with the
|
|
109
|
+
`[EditError::<Variant>]` prefix.
|
|
110
|
+
- `quill.render` / `session.render` — backend compilation failures and
|
|
111
|
+
validation errors.
|
|
112
|
+
|
|
113
|
+
### Lifecycle
|
|
114
|
+
|
|
115
|
+
The wasm bindings are built with `--weak-refs`, so dropped `Document`,
|
|
116
|
+
`Quill`, and `RenderSession` handles are reclaimed by `FinalizationRegistry`
|
|
117
|
+
without manual `.free()` discipline. `.free()` is still emitted as an eager
|
|
118
|
+
teardown hook for callers that want deterministic release. Requires
|
|
119
|
+
Node 14.6+ / current evergreen browsers (all supported targets).
|
|
77
120
|
|
|
78
121
|
## Notes
|
|
79
122
|
|
package/bundler/wasm.d.ts
CHANGED
|
@@ -88,6 +88,17 @@ export class Document {
|
|
|
88
88
|
* history of either handle.
|
|
89
89
|
*/
|
|
90
90
|
clone(): Document;
|
|
91
|
+
/**
|
|
92
|
+
* Structural equality against another `Document`.
|
|
93
|
+
*
|
|
94
|
+
* Compares `main` and `cards` by value (matching core's [`PartialEq`]).
|
|
95
|
+
* Parse-time `warnings` are intentionally excluded — they describe the
|
|
96
|
+
* source text, not the document's content.
|
|
97
|
+
*
|
|
98
|
+
* Use this to debounce upstream prop updates: keep the last parsed
|
|
99
|
+
* `Document` and compare instead of re-parsing on every keystroke.
|
|
100
|
+
*/
|
|
101
|
+
equals(other: Document): boolean;
|
|
91
102
|
/**
|
|
92
103
|
* Parse markdown into a typed Document.
|
|
93
104
|
*
|
|
@@ -228,6 +239,13 @@ export class Document {
|
|
|
228
239
|
* Mutators never modify `warnings`.
|
|
229
240
|
*/
|
|
230
241
|
updateCardField(index: number, name: string, value: any): void;
|
|
242
|
+
/**
|
|
243
|
+
* Number of composable cards (excludes the main card).
|
|
244
|
+
*
|
|
245
|
+
* O(1). Use this to validate indices before calling card mutators
|
|
246
|
+
* instead of allocating the full `cards` array.
|
|
247
|
+
*/
|
|
248
|
+
readonly cardCount: number;
|
|
231
249
|
/**
|
|
232
250
|
* Ordered list of composable card blocks as typed `Card` objects.
|
|
233
251
|
*/
|
|
@@ -321,8 +339,11 @@ export class Quill {
|
|
|
321
339
|
* optional `example`. `main` and each card under `card_types` share
|
|
322
340
|
* the same shape: `fields` (map keyed by field name), optional
|
|
323
341
|
* `title`, `description`, `ui`.
|
|
324
|
-
* - `backend`, `version`, `author` — quill identity
|
|
325
|
-
* `Quill.yaml`'s `quill:` section.
|
|
342
|
+
* - `backend`, `version`, `author`, `description` — quill identity
|
|
343
|
+
* declared in `Quill.yaml`'s `quill:` section. `description` describes
|
|
344
|
+
* the quill itself; if the author also declared `main.description` (the
|
|
345
|
+
* schema description of the entry-point card), it lives at
|
|
346
|
+
* `schema.main.description` and is independent.
|
|
326
347
|
* - `supportedFormats` — output formats the backend produces, as
|
|
327
348
|
* lowercase strings.
|
|
328
349
|
* - Any additional unstructured keys declared under `quill:`.
|
package/bundler/wasm_bg.js
CHANGED
|
@@ -29,6 +29,17 @@ export class Document {
|
|
|
29
29
|
const ptr = this.__destroy_into_raw();
|
|
30
30
|
wasm.__wbg_document_free(ptr, 0);
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Number of composable cards (excludes the main card).
|
|
34
|
+
*
|
|
35
|
+
* O(1). Use this to validate indices before calling card mutators
|
|
36
|
+
* instead of allocating the full `cards` array.
|
|
37
|
+
* @returns {number}
|
|
38
|
+
*/
|
|
39
|
+
get cardCount() {
|
|
40
|
+
const ret = wasm.document_cardCount(this.__wbg_ptr);
|
|
41
|
+
return ret >>> 0;
|
|
42
|
+
}
|
|
32
43
|
/**
|
|
33
44
|
* Ordered list of composable card blocks as typed `Card` objects.
|
|
34
45
|
* @returns {Card[]}
|
|
@@ -50,6 +61,23 @@ export class Document {
|
|
|
50
61
|
const ret = wasm.document_clone(this.__wbg_ptr);
|
|
51
62
|
return Document.__wrap(ret);
|
|
52
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Structural equality against another `Document`.
|
|
66
|
+
*
|
|
67
|
+
* Compares `main` and `cards` by value (matching core's [`PartialEq`]).
|
|
68
|
+
* Parse-time `warnings` are intentionally excluded — they describe the
|
|
69
|
+
* source text, not the document's content.
|
|
70
|
+
*
|
|
71
|
+
* Use this to debounce upstream prop updates: keep the last parsed
|
|
72
|
+
* `Document` and compare instead of re-parsing on every keystroke.
|
|
73
|
+
* @param {Document} other
|
|
74
|
+
* @returns {boolean}
|
|
75
|
+
*/
|
|
76
|
+
equals(other) {
|
|
77
|
+
_assertClass(other, Document);
|
|
78
|
+
const ret = wasm.document_equals(this.__wbg_ptr, other.__wbg_ptr);
|
|
79
|
+
return ret !== 0;
|
|
80
|
+
}
|
|
53
81
|
/**
|
|
54
82
|
* Parse markdown into a typed Document.
|
|
55
83
|
*
|
|
@@ -594,8 +622,11 @@ export class Quill {
|
|
|
594
622
|
* optional `example`. `main` and each card under `card_types` share
|
|
595
623
|
* the same shape: `fields` (map keyed by field name), optional
|
|
596
624
|
* `title`, `description`, `ui`.
|
|
597
|
-
* - `backend`, `version`, `author` — quill identity
|
|
598
|
-
* `Quill.yaml`'s `quill:` section.
|
|
625
|
+
* - `backend`, `version`, `author`, `description` — quill identity
|
|
626
|
+
* declared in `Quill.yaml`'s `quill:` section. `description` describes
|
|
627
|
+
* the quill itself; if the author also declared `main.description` (the
|
|
628
|
+
* schema description of the entry-point card), it lives at
|
|
629
|
+
* `schema.main.description` and is independent.
|
|
599
630
|
* - `supportedFormats` — output formats the backend produces, as
|
|
600
631
|
* lowercase strings.
|
|
601
632
|
* - Any additional unstructured keys declared under `quill:`.
|
package/bundler/wasm_bg.wasm
CHANGED
|
Binary file
|
|
@@ -5,8 +5,10 @@ export const __wbg_document_free: (a: number, b: number) => void;
|
|
|
5
5
|
export const __wbg_quill_free: (a: number, b: number) => void;
|
|
6
6
|
export const __wbg_quillmark_free: (a: number, b: number) => void;
|
|
7
7
|
export const __wbg_rendersession_free: (a: number, b: number) => void;
|
|
8
|
+
export const document_cardCount: (a: number) => number;
|
|
8
9
|
export const document_cards: (a: number) => number;
|
|
9
10
|
export const document_clone: (a: number) => number;
|
|
11
|
+
export const document_equals: (a: number, b: number) => number;
|
|
10
12
|
export const document_fromMarkdown: (a: number, b: number, c: number) => void;
|
|
11
13
|
export const document_insertCard: (a: number, b: number, c: number, d: number) => void;
|
|
12
14
|
export const document_main: (a: number) => number;
|
package/node-esm/wasm.d.ts
CHANGED
|
@@ -88,6 +88,17 @@ export class Document {
|
|
|
88
88
|
* history of either handle.
|
|
89
89
|
*/
|
|
90
90
|
clone(): Document;
|
|
91
|
+
/**
|
|
92
|
+
* Structural equality against another `Document`.
|
|
93
|
+
*
|
|
94
|
+
* Compares `main` and `cards` by value (matching core's [`PartialEq`]).
|
|
95
|
+
* Parse-time `warnings` are intentionally excluded — they describe the
|
|
96
|
+
* source text, not the document's content.
|
|
97
|
+
*
|
|
98
|
+
* Use this to debounce upstream prop updates: keep the last parsed
|
|
99
|
+
* `Document` and compare instead of re-parsing on every keystroke.
|
|
100
|
+
*/
|
|
101
|
+
equals(other: Document): boolean;
|
|
91
102
|
/**
|
|
92
103
|
* Parse markdown into a typed Document.
|
|
93
104
|
*
|
|
@@ -228,6 +239,13 @@ export class Document {
|
|
|
228
239
|
* Mutators never modify `warnings`.
|
|
229
240
|
*/
|
|
230
241
|
updateCardField(index: number, name: string, value: any): void;
|
|
242
|
+
/**
|
|
243
|
+
* Number of composable cards (excludes the main card).
|
|
244
|
+
*
|
|
245
|
+
* O(1). Use this to validate indices before calling card mutators
|
|
246
|
+
* instead of allocating the full `cards` array.
|
|
247
|
+
*/
|
|
248
|
+
readonly cardCount: number;
|
|
231
249
|
/**
|
|
232
250
|
* Ordered list of composable card blocks as typed `Card` objects.
|
|
233
251
|
*/
|
|
@@ -321,8 +339,11 @@ export class Quill {
|
|
|
321
339
|
* optional `example`. `main` and each card under `card_types` share
|
|
322
340
|
* the same shape: `fields` (map keyed by field name), optional
|
|
323
341
|
* `title`, `description`, `ui`.
|
|
324
|
-
* - `backend`, `version`, `author` — quill identity
|
|
325
|
-
* `Quill.yaml`'s `quill:` section.
|
|
342
|
+
* - `backend`, `version`, `author`, `description` — quill identity
|
|
343
|
+
* declared in `Quill.yaml`'s `quill:` section. `description` describes
|
|
344
|
+
* the quill itself; if the author also declared `main.description` (the
|
|
345
|
+
* schema description of the entry-point card), it lives at
|
|
346
|
+
* `schema.main.description` and is independent.
|
|
326
347
|
* - `supportedFormats` — output formats the backend produces, as
|
|
327
348
|
* lowercase strings.
|
|
328
349
|
* - Any additional unstructured keys declared under `quill:`.
|
package/node-esm/wasm.js
CHANGED
|
@@ -33,6 +33,17 @@ export class Document {
|
|
|
33
33
|
const ptr = this.__destroy_into_raw();
|
|
34
34
|
wasm.__wbg_document_free(ptr, 0);
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Number of composable cards (excludes the main card).
|
|
38
|
+
*
|
|
39
|
+
* O(1). Use this to validate indices before calling card mutators
|
|
40
|
+
* instead of allocating the full `cards` array.
|
|
41
|
+
* @returns {number}
|
|
42
|
+
*/
|
|
43
|
+
get cardCount() {
|
|
44
|
+
const ret = wasm.document_cardCount(this.__wbg_ptr);
|
|
45
|
+
return ret >>> 0;
|
|
46
|
+
}
|
|
36
47
|
/**
|
|
37
48
|
* Ordered list of composable card blocks as typed `Card` objects.
|
|
38
49
|
* @returns {Card[]}
|
|
@@ -54,6 +65,23 @@ export class Document {
|
|
|
54
65
|
const ret = wasm.document_clone(this.__wbg_ptr);
|
|
55
66
|
return Document.__wrap(ret);
|
|
56
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Structural equality against another `Document`.
|
|
70
|
+
*
|
|
71
|
+
* Compares `main` and `cards` by value (matching core's [`PartialEq`]).
|
|
72
|
+
* Parse-time `warnings` are intentionally excluded — they describe the
|
|
73
|
+
* source text, not the document's content.
|
|
74
|
+
*
|
|
75
|
+
* Use this to debounce upstream prop updates: keep the last parsed
|
|
76
|
+
* `Document` and compare instead of re-parsing on every keystroke.
|
|
77
|
+
* @param {Document} other
|
|
78
|
+
* @returns {boolean}
|
|
79
|
+
*/
|
|
80
|
+
equals(other) {
|
|
81
|
+
_assertClass(other, Document);
|
|
82
|
+
const ret = wasm.document_equals(this.__wbg_ptr, other.__wbg_ptr);
|
|
83
|
+
return ret !== 0;
|
|
84
|
+
}
|
|
57
85
|
/**
|
|
58
86
|
* Parse markdown into a typed Document.
|
|
59
87
|
*
|
|
@@ -598,8 +626,11 @@ export class Quill {
|
|
|
598
626
|
* optional `example`. `main` and each card under `card_types` share
|
|
599
627
|
* the same shape: `fields` (map keyed by field name), optional
|
|
600
628
|
* `title`, `description`, `ui`.
|
|
601
|
-
* - `backend`, `version`, `author` — quill identity
|
|
602
|
-
* `Quill.yaml`'s `quill:` section.
|
|
629
|
+
* - `backend`, `version`, `author`, `description` — quill identity
|
|
630
|
+
* declared in `Quill.yaml`'s `quill:` section. `description` describes
|
|
631
|
+
* the quill itself; if the author also declared `main.description` (the
|
|
632
|
+
* schema description of the entry-point card), it lives at
|
|
633
|
+
* `schema.main.description` and is independent.
|
|
603
634
|
* - `supportedFormats` — output formats the backend produces, as
|
|
604
635
|
* lowercase strings.
|
|
605
636
|
* - Any additional unstructured keys declared under `quill:`.
|
package/node-esm/wasm_bg.wasm
CHANGED
|
Binary file
|
|
@@ -5,8 +5,10 @@ export const __wbg_document_free: (a: number, b: number) => void;
|
|
|
5
5
|
export const __wbg_quill_free: (a: number, b: number) => void;
|
|
6
6
|
export const __wbg_quillmark_free: (a: number, b: number) => void;
|
|
7
7
|
export const __wbg_rendersession_free: (a: number, b: number) => void;
|
|
8
|
+
export const document_cardCount: (a: number) => number;
|
|
8
9
|
export const document_cards: (a: number) => number;
|
|
9
10
|
export const document_clone: (a: number) => number;
|
|
11
|
+
export const document_equals: (a: number, b: number) => number;
|
|
10
12
|
export const document_fromMarkdown: (a: number, b: number, c: number) => void;
|
|
11
13
|
export const document_insertCard: (a: number, b: number, c: number, d: number) => void;
|
|
12
14
|
export const document_main: (a: number) => number;
|