@quillmark/wasm 0.80.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 +35 -0
- package/bundler/wasm_bg.js +77 -0
- 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
|
@@ -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
|
*
|
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
|
*
|
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;
|