@quillmark/wasm 0.79.0 → 0.81.0-rc.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 +25 -0
- package/bundler/wasm.d.ts +45 -10
- package/bundler/wasm_bg.js +82 -5
- package/bundler/wasm_bg.wasm +0 -0
- package/bundler/wasm_bg.wasm.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -67,6 +67,31 @@ byte-equal to the original source — YAML quoting, key ordering, and
|
|
|
67
67
|
whitespace are normalised. Use `equals` (not string comparison) to test
|
|
68
68
|
semantic equality.
|
|
69
69
|
|
|
70
|
+
### `doc.toJson()`
|
|
71
|
+
Serialize the document to a versioned storage DTO — a JSON **string**
|
|
72
|
+
carrying a `schema` version tag. Use this (not `toMarkdown`) to persist a
|
|
73
|
+
document across a process restart or crate upgrade: the wire format is
|
|
74
|
+
frozen per `schema` version, whereas Markdown syntax evolves. Parse-time
|
|
75
|
+
`warnings` are not part of the DTO.
|
|
76
|
+
|
|
77
|
+
The string is produced inside the module by `serde_json`; the JS `JSON`
|
|
78
|
+
global is not involved. It is standard JSON text, so callers may
|
|
79
|
+
`JSON.parse` it to inspect it — but it is intended as an opaque blob you
|
|
80
|
+
persist and hand back.
|
|
81
|
+
|
|
82
|
+
### `Document.fromJson(json)`
|
|
83
|
+
Reconstruct a `Document` from a storage DTO string produced by `toJson`.
|
|
84
|
+
Round-trips losslessly:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
const stored = doc.toJson(); // persist this string
|
|
88
|
+
const restored = Document.fromJson(stored);
|
|
89
|
+
restored.equals(doc); // true
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Throws a JS `Error` on malformed JSON, an unknown `schema` tag, or a
|
|
93
|
+
malformed payload. The restored document has no parse-time `warnings`.
|
|
94
|
+
|
|
70
95
|
### `doc.equals(other)`
|
|
71
96
|
Structural equality between two `Document` handles. Compares `main` and
|
|
72
97
|
`cards` by value; parse-time `warnings` are intentionally excluded.
|
package/bundler/wasm.d.ts
CHANGED
|
@@ -93,14 +93,14 @@ export interface QuillFieldUi {
|
|
|
93
93
|
multiline?: boolean;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
/** UI layout hints for a card (main or named card
|
|
96
|
+
/** UI layout hints for a card (main or named card kind). */
|
|
97
97
|
export interface QuillCardUi {
|
|
98
98
|
title?: string;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
/** Body namespace for a card (main or named card
|
|
101
|
+
/** Body namespace for a card (main or named card kind). */
|
|
102
102
|
export interface QuillCardBody {
|
|
103
|
-
/** When false, consumers must not accept or store body content for this card
|
|
103
|
+
/** When false, consumers must not accept or store body content for this card kind. Defaults to true. */
|
|
104
104
|
enabled?: boolean;
|
|
105
105
|
/** Example body content embedded verbatim in the blueprint body region. Fallback is "Write <card> body here." */
|
|
106
106
|
example?: string;
|
|
@@ -119,7 +119,7 @@ export interface QuillFieldSchema {
|
|
|
119
119
|
items?: QuillFieldSchema;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
/** Schema entry for the main card or a named card
|
|
122
|
+
/** Schema entry for the main card or a named card kind. */
|
|
123
123
|
export interface QuillCardSchema {
|
|
124
124
|
description?: string;
|
|
125
125
|
fields: Record<string, QuillFieldSchema>;
|
|
@@ -130,13 +130,13 @@ export interface QuillCardSchema {
|
|
|
130
130
|
/**
|
|
131
131
|
* Document schema returned by `Quill.schema`. Includes optional `ui` keys.
|
|
132
132
|
*
|
|
133
|
-
* `main.fields.QUILL` and `
|
|
133
|
+
* `main.fields.QUILL` and `card_kinds[name].fields.CARD` are required
|
|
134
134
|
* sentinels with `const` values telling consumers what to write.
|
|
135
135
|
*/
|
|
136
136
|
export interface QuillSchema {
|
|
137
137
|
main: QuillCardSchema;
|
|
138
|
-
/** Present only when the quill declares at least one named card
|
|
139
|
-
|
|
138
|
+
/** Present only when the quill declares at least one named card kind. */
|
|
139
|
+
card_kinds?: Record<string, QuillCardSchema>;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
/**
|
|
@@ -280,6 +280,22 @@ export class Document {
|
|
|
280
280
|
* `Document` and compare instead of re-parsing on every keystroke.
|
|
281
281
|
*/
|
|
282
282
|
equals(other: Document): boolean;
|
|
283
|
+
/**
|
|
284
|
+
* Reconstruct a `Document` from its versioned storage DTO string.
|
|
285
|
+
*
|
|
286
|
+
* `json` must be a string produced by [`toJson`](Document::to_json) —
|
|
287
|
+
* the versioned storage DTO. Parsing and schema dispatch happen inside
|
|
288
|
+
* the module via `serde_json`; the JS `JSON` global is not involved.
|
|
289
|
+
* Unknown `schema` tags are rejected.
|
|
290
|
+
*
|
|
291
|
+
* The reconstructed document carries no parse-time warnings — the DTO
|
|
292
|
+
* describes content, not source text — so `.warnings` is always empty.
|
|
293
|
+
*
|
|
294
|
+
* Throws a JS `Error` if `json` is not a valid storage DTO (malformed
|
|
295
|
+
* JSON, unknown `schema`, missing fields, or an unparseable quill
|
|
296
|
+
* reference).
|
|
297
|
+
*/
|
|
298
|
+
static fromJson(json: string): Document;
|
|
283
299
|
/**
|
|
284
300
|
* Parse markdown into a typed Document.
|
|
285
301
|
*
|
|
@@ -393,6 +409,25 @@ export class Document {
|
|
|
393
409
|
* Mutators never modify `warnings`.
|
|
394
410
|
*/
|
|
395
411
|
setQuillRef(ref_str: string): void;
|
|
412
|
+
/**
|
|
413
|
+
* Serialize this document to a versioned storage DTO string.
|
|
414
|
+
*
|
|
415
|
+
* Returns the document as a JSON string carrying a `schema` version
|
|
416
|
+
* tag. The string is produced inside the module via `serde_json` and
|
|
417
|
+
* round-trips losslessly back to an equal `Document` via
|
|
418
|
+
* [`fromJson`](Document::from_json) — the JS `JSON` global is not
|
|
419
|
+
* involved in either direction.
|
|
420
|
+
*
|
|
421
|
+
* Use this — not [`toMarkdown`](Document::to_markdown) — to persist a
|
|
422
|
+
* document across a process restart or crate upgrade; the wire format
|
|
423
|
+
* is frozen per `schema` version, whereas Markdown syntax evolves.
|
|
424
|
+
* Parse-time `warnings` are not part of the DTO.
|
|
425
|
+
*
|
|
426
|
+
* The result is standard JSON text, so callers that want to inspect it
|
|
427
|
+
* may `JSON.parse` it — but treating it as an opaque blob is the
|
|
428
|
+
* intended use.
|
|
429
|
+
*/
|
|
430
|
+
toJson(): string;
|
|
396
431
|
/**
|
|
397
432
|
* Emit canonical Quillmark Markdown.
|
|
398
433
|
*
|
|
@@ -459,15 +494,15 @@ export class Quill {
|
|
|
459
494
|
free(): void;
|
|
460
495
|
[Symbol.dispose](): void;
|
|
461
496
|
/**
|
|
462
|
-
* A blank form for a card of the given
|
|
497
|
+
* A blank form for a card of the given kind — no document values supplied.
|
|
463
498
|
*
|
|
464
|
-
* Returns `null` if `
|
|
499
|
+
* Returns `null` if `cardKind` is not declared in this quill's schema.
|
|
465
500
|
* Otherwise returns a plain JS object shaped like a single entry in
|
|
466
501
|
* [`Form::cards`].
|
|
467
502
|
*
|
|
468
503
|
* [`Form::cards`]: quillmark::form::Form::cards
|
|
469
504
|
*/
|
|
470
|
-
blankCard(
|
|
505
|
+
blankCard(card_kind: string): FormCard | null;
|
|
471
506
|
/**
|
|
472
507
|
* A blank form for the main card — no document values supplied.
|
|
473
508
|
*
|
package/bundler/wasm_bg.js
CHANGED
|
@@ -78,6 +78,40 @@ export class Document {
|
|
|
78
78
|
const ret = wasm.document_equals(this.__wbg_ptr, other.__wbg_ptr);
|
|
79
79
|
return ret !== 0;
|
|
80
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Reconstruct a `Document` from its versioned storage DTO string.
|
|
83
|
+
*
|
|
84
|
+
* `json` must be a string produced by [`toJson`](Document::to_json) —
|
|
85
|
+
* the versioned storage DTO. Parsing and schema dispatch happen inside
|
|
86
|
+
* the module via `serde_json`; the JS `JSON` global is not involved.
|
|
87
|
+
* Unknown `schema` tags are rejected.
|
|
88
|
+
*
|
|
89
|
+
* The reconstructed document carries no parse-time warnings — the DTO
|
|
90
|
+
* describes content, not source text — so `.warnings` is always empty.
|
|
91
|
+
*
|
|
92
|
+
* Throws a JS `Error` if `json` is not a valid storage DTO (malformed
|
|
93
|
+
* JSON, unknown `schema`, missing fields, or an unparseable quill
|
|
94
|
+
* reference).
|
|
95
|
+
* @param {string} json
|
|
96
|
+
* @returns {Document}
|
|
97
|
+
*/
|
|
98
|
+
static fromJson(json) {
|
|
99
|
+
try {
|
|
100
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
101
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
102
|
+
const len0 = WASM_VECTOR_LEN;
|
|
103
|
+
wasm.document_fromJson(retptr, ptr0, len0);
|
|
104
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
105
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
106
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
107
|
+
if (r2) {
|
|
108
|
+
throw takeObject(r1);
|
|
109
|
+
}
|
|
110
|
+
return Document.__wrap(r0);
|
|
111
|
+
} finally {
|
|
112
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
81
115
|
/**
|
|
82
116
|
* Parse markdown into a typed Document.
|
|
83
117
|
*
|
|
@@ -394,6 +428,49 @@ export class Document {
|
|
|
394
428
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
395
429
|
}
|
|
396
430
|
}
|
|
431
|
+
/**
|
|
432
|
+
* Serialize this document to a versioned storage DTO string.
|
|
433
|
+
*
|
|
434
|
+
* Returns the document as a JSON string carrying a `schema` version
|
|
435
|
+
* tag. The string is produced inside the module via `serde_json` and
|
|
436
|
+
* round-trips losslessly back to an equal `Document` via
|
|
437
|
+
* [`fromJson`](Document::from_json) — the JS `JSON` global is not
|
|
438
|
+
* involved in either direction.
|
|
439
|
+
*
|
|
440
|
+
* Use this — not [`toMarkdown`](Document::to_markdown) — to persist a
|
|
441
|
+
* document across a process restart or crate upgrade; the wire format
|
|
442
|
+
* is frozen per `schema` version, whereas Markdown syntax evolves.
|
|
443
|
+
* Parse-time `warnings` are not part of the DTO.
|
|
444
|
+
*
|
|
445
|
+
* The result is standard JSON text, so callers that want to inspect it
|
|
446
|
+
* may `JSON.parse` it — but treating it as an opaque blob is the
|
|
447
|
+
* intended use.
|
|
448
|
+
* @returns {string}
|
|
449
|
+
*/
|
|
450
|
+
toJson() {
|
|
451
|
+
let deferred2_0;
|
|
452
|
+
let deferred2_1;
|
|
453
|
+
try {
|
|
454
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
455
|
+
wasm.document_toJson(retptr, this.__wbg_ptr);
|
|
456
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
457
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
458
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
459
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
460
|
+
var ptr1 = r0;
|
|
461
|
+
var len1 = r1;
|
|
462
|
+
if (r3) {
|
|
463
|
+
ptr1 = 0; len1 = 0;
|
|
464
|
+
throw takeObject(r2);
|
|
465
|
+
}
|
|
466
|
+
deferred2_0 = ptr1;
|
|
467
|
+
deferred2_1 = len1;
|
|
468
|
+
return getStringFromWasm0(ptr1, len1);
|
|
469
|
+
} finally {
|
|
470
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
471
|
+
wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
397
474
|
/**
|
|
398
475
|
* Emit canonical Quillmark Markdown.
|
|
399
476
|
*
|
|
@@ -523,20 +600,20 @@ export class Quill {
|
|
|
523
600
|
}
|
|
524
601
|
}
|
|
525
602
|
/**
|
|
526
|
-
* A blank form for a card of the given
|
|
603
|
+
* A blank form for a card of the given kind — no document values supplied.
|
|
527
604
|
*
|
|
528
|
-
* Returns `null` if `
|
|
605
|
+
* Returns `null` if `cardKind` is not declared in this quill's schema.
|
|
529
606
|
* Otherwise returns a plain JS object shaped like a single entry in
|
|
530
607
|
* [`Form::cards`].
|
|
531
608
|
*
|
|
532
609
|
* [`Form::cards`]: quillmark::form::Form::cards
|
|
533
|
-
* @param {string}
|
|
610
|
+
* @param {string} card_kind
|
|
534
611
|
* @returns {FormCard | null}
|
|
535
612
|
*/
|
|
536
|
-
blankCard(
|
|
613
|
+
blankCard(card_kind) {
|
|
537
614
|
try {
|
|
538
615
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
539
|
-
const ptr0 = passStringToWasm0(
|
|
616
|
+
const ptr0 = passStringToWasm0(card_kind, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
540
617
|
const len0 = WASM_VECTOR_LEN;
|
|
541
618
|
wasm.quill_blankCard(retptr, this.__wbg_ptr, ptr0, len0);
|
|
542
619
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
package/bundler/wasm_bg.wasm
CHANGED
|
Binary file
|
|
@@ -9,6 +9,7 @@ export const document_cardCount: (a: number) => number;
|
|
|
9
9
|
export const document_cards: (a: number) => number;
|
|
10
10
|
export const document_clone: (a: number) => number;
|
|
11
11
|
export const document_equals: (a: number, b: number) => number;
|
|
12
|
+
export const document_fromJson: (a: number, b: number, c: number) => void;
|
|
12
13
|
export const document_fromMarkdown: (a: number, b: number, c: number) => void;
|
|
13
14
|
export const document_insertCard: (a: number, b: number, c: number, d: number) => void;
|
|
14
15
|
export const document_main: (a: number) => number;
|
|
@@ -23,6 +24,7 @@ export const document_setCardTag: (a: number, b: number, c: number, d: number, e
|
|
|
23
24
|
export const document_setField: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
24
25
|
export const document_setFill: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
25
26
|
export const document_setQuillRef: (a: number, b: number, c: number, d: number) => void;
|
|
27
|
+
export const document_toJson: (a: number, b: number) => void;
|
|
26
28
|
export const document_toMarkdown: (a: number, b: number) => void;
|
|
27
29
|
export const document_updateCardBody: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
28
30
|
export const document_updateCardField: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|