@quillmark/wasm 0.132.0 → 0.133.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.
@@ -39,6 +39,7 @@ export const document_removeExt: (a: number, b: number, c: number) => void;
39
39
  export const document_removeField: (a: number, b: number, c: number) => void;
40
40
  export const document_removeSeedOverlay: (a: number, b: number, c: number, d: number) => void;
41
41
  export const document_revise: (a: number, b: number, c: number, d: number, e: number) => void;
42
+ export const document_reviseContent: (a: number, b: number, c: number, d: number) => void;
42
43
  export const document_seedOverlay: (a: number, b: number, c: number, d: number) => void;
43
44
  export const document_setQuillRef: (a: number, b: number, c: number, d: number) => void;
44
45
  export const document_storageVersionOf: (a: number, b: number, c: number) => void;
@@ -58,13 +59,15 @@ export const isInline: (a: number, b: number) => void;
58
59
  export const isPlain: (a: number, b: number) => void;
59
60
  export const mapMarks: (a: number, b: number, c: number) => void;
60
61
  export const mapPos: (a: number, b: number, c: number, d: number) => void;
62
+ export const normalize: (a: number, b: number) => void;
61
63
  export const parseDocPath: (a: number, b: number, c: number) => void;
62
64
  export const quill__resolve: (a: number, b: number, c: number, d: number, e: number) => void;
65
+ export const quill_authoringSchema: (a: number, b: number) => void;
63
66
  export const quill_backendId: (a: number, b: number) => void;
64
- export const quill_blueprint: (a: number, b: number) => void;
65
67
  export const quill_conform: (a: number, b: number, c: number) => void;
66
68
  export const quill_emptyDocument: (a: number) => number;
67
- export const quill_exampleDocument: (a: number, b: number) => void;
69
+ export const quill_exampleDocument: (a: number) => number;
70
+ export const quill_fromAuthoring: (a: number, b: number, c: number) => void;
68
71
  export const quill_fromBundle: (a: number, b: number, c: number) => void;
69
72
  export const quill_fromTree: (a: number, b: number) => void;
70
73
  export const quill_metadata: (a: number, b: number) => void;
@@ -73,6 +76,7 @@ export const quill_schema: (a: number, b: number) => void;
73
76
  export const quill_seedCard: (a: number, b: number, c: number, d: number, e: number) => void;
74
77
  export const quill_seedDocument: (a: number) => number;
75
78
  export const quill_seedMain: (a: number, b: number) => void;
79
+ export const quill_toAuthoring: (a: number, b: number, c: number) => void;
76
80
  export const quill_toBundle: (a: number, b: number) => void;
77
81
  export const quill_toTree: (a: number) => number;
78
82
  export const quill_validate: (a: number, b: number, c: number) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillmark/wasm",
3
- "version": "0.132.0",
3
+ "version": "0.133.0",
4
4
  "description": "WebAssembly bindings for Quillmark, a schema-driven document framework",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
package/render/wasm.d.ts CHANGED
@@ -243,9 +243,10 @@ export interface Delta {
243
243
  }
244
244
 
245
245
  /**
246
- * The receipt of a markdown revise (`revise`, `writer.reviseBody`,
246
+ * The receipt of a revise (`revise`, `reviseContent`, `writer.reviseBody`,
247
247
  * `writer.reviseField`): the text `delta`, and one `parse::dropped_construct`
248
- * warning per construct the import dropped, anchored at the revised address.
248
+ * warning per construct a markdown import dropped, anchored at the revised
249
+ * address. `reviseContent` imports nothing, so its `warnings` is empty.
249
250
  */
250
251
  export interface Revised {
251
252
  delta: Delta;
@@ -357,7 +358,9 @@ export type LineOp =
357
358
  *
358
359
  * A `table` has no inline placement: markdown writes it as a block, so an
359
360
  * `insert` whose `at` is not an empty line throws, as does a `set` retyping an
360
- * inline island into one.
361
+ * inline island into one. A table already sharing its line, as a `join` or an
362
+ * `overwrite` of merged edits leaves one, stays there and takes its `set`;
363
+ * markdown writes it on a line of its own.
361
364
  */
362
365
  export type IslandOp =
363
366
  | ({ op: "set" } & ContentIsland)
@@ -524,6 +527,11 @@ export interface QuillCardUi {
524
527
  export interface QuillCardBody {
525
528
  /** When false, consumers must not accept or store body content for this card kind. Defaults to true. */
526
529
  enabled?: boolean;
530
+ /** What the body holds, for the writer. Never beside `enabled: false`. */
531
+ description?: string;
532
+ /** A made-up body in markdown, which `exampleDocument()` commits. Never
533
+ * beside `enabled: false`. */
534
+ example?: string;
527
535
  }
528
536
 
529
537
  export type QuillFieldType = "number" | "integer" | "boolean" | "array" | "object" | "date" | "datetime" | "text" | "richtext" | "enum" | "matrix";
@@ -531,7 +539,8 @@ export type QuillFieldType = "number" | "integer" | "boolean" | "array" | "objec
531
539
  /** Schema entry for a single field declared in a quill's `Quill.yaml`.
532
540
  *
533
541
  * `default` is the value an unanswered cell renders. An absent field without a
534
- * `default` blank-fills.
542
+ * `default` blank-fills. `example` is a made-up value of the same type, which
543
+ * answers no cell: `exampleDocument()` commits it.
535
544
  */
536
545
  export interface QuillFieldSchema {
537
546
  /** A trailing `?` marks the cell optional: unanswered, it renders `none`
@@ -543,6 +552,7 @@ export interface QuillFieldSchema {
543
552
  title?: string;
544
553
  description?: string;
545
554
  default?: unknown;
555
+ example?: unknown;
546
556
  /** The closed set of allowed values. Required on `type: "enum"`, and valid
547
557
  * nowhere else. */
548
558
  values?: string[];
@@ -607,6 +617,26 @@ export interface QuillSchema {
607
617
  card_kinds?: Record<string, QuillCardSchema>;
608
618
  }
609
619
 
620
+ /**
621
+ * One card of an `AuthoringDocument`: its kind, its fields in the values form,
622
+ * and its body as Markdown. `null` anywhere a value goes is absent.
623
+ */
624
+ export interface AuthoringCard {
625
+ kind: string;
626
+ fields?: Record<string, unknown> | null;
627
+ body?: string | null;
628
+ }
629
+
630
+ /**
631
+ * The JSON a model reads and writes, described by `Quill.authoringSchema`:
632
+ * the main card's fields and body, and the composable cards in order.
633
+ */
634
+ export interface AuthoringDocument {
635
+ fields?: Record<string, unknown> | null;
636
+ body?: string | null;
637
+ cards?: AuthoringCard[] | null;
638
+ }
639
+
610
640
  /**
611
641
  * Identity snapshot mirroring the `quill:` section of `Quill.yaml`. The schema
612
642
  * lives on `Quill.schema`; output formats are a resolved-backend capability read
@@ -918,8 +948,9 @@ export class Document {
918
948
  /**
919
949
  * **Overwrite** the content value at `addr` with exactly `rt`: value
920
950
  * semantics, so the identity anchors of any previous value are gone. By
921
- * anchor fate `overwrite` destroys, [`revise`](Document::revise) rebases,
922
- * and [`applyChange`](Document::apply_change) preserves. An absent
951
+ * anchor fate `overwrite` destroys, [`revise`](Document::revise) and
952
+ * [`reviseContent`](Document::revise_content) rebase, and
953
+ * [`applyChange`](Document::apply_change) preserves. An absent
923
954
  * `addr.field` targets the body, an absent `addr.card` the main card.
924
955
  *
925
956
  * Throws on an out-of-range card, a malformed field name, or an `rt` that is
@@ -966,6 +997,23 @@ export class Document {
966
997
  * or `undefined`; drops `$seed` entirely once empty. Sibling kinds survive.
967
998
  */
968
999
  removeSeedOverlay(card_kind: string): any;
1000
+ /**
1001
+ * **Revise** the richtext value at `addr` to `rt`, keeping each stored prose
1002
+ * anchor whose id `rt` does not hold: the content twin of
1003
+ * [`revise`](Document::revise), for a value built elsewhere such as a
1004
+ * merge's projection. Diffs `rt` against the current value, carries those
1005
+ * anchors through the diff, and returns the
1006
+ * `Revised` receipt, whose `delta` an editor bridge maps its own positions
1007
+ * through and whose `warnings` is empty. `rt`'s own anchors and island ids
1008
+ * land as they are. An absent `addr.field` targets the body, an absent
1009
+ * `addr.card` the main card; an absent field diffs from empty. Richtext
1010
+ * only: a `text` field takes `overwrite`.
1011
+ *
1012
+ * Throws on an out-of-range card, a malformed field name, a present
1013
+ * non-content field value, or an `rt` that is not a canonical content
1014
+ * object.
1015
+ */
1016
+ reviseContent(addr: Addr | string, rt: Content): Revised;
969
1017
  /**
970
1018
  * **Revise** the richtext value at `addr` from a markdown string: the
971
1019
  * default write path. Imports the markdown, diffs it against the current
@@ -1253,19 +1301,28 @@ export class Quill {
1253
1301
  * The empty document: a main card carrying this quill's `$quill` and
1254
1302
  * `$kind: main`, no field committed, no composable card, no body. The
1255
1303
  * type-minimal valid input, and the document a plate is bound to render
1256
- * (the quill authoring contract). `new Document(ref)` is the same document
1304
+ * (the plate contract). `new Document(ref)` is the same document
1257
1305
  * reached by spelling the reference.
1258
1306
  */
1259
1307
  emptyDocument(): Document;
1260
1308
  /**
1261
- * The quill's example document, `undefined` when the quill has no
1262
- * `example.md` at its root: a filled-in page whose values are made up to show the
1263
- * quill in use, never kept. It comes back pinned to this quill's
1264
- * `name@MAJOR.MINOR` and conformed as `parse` conforms, its parse and
1265
- * `conform::*` warnings on `doc.warnings`. Throws when the file does not
1266
- * parse or its `$quill` is not this quill's bare name.
1309
+ * The quill's example document, `undefined` when no slot or body declares
1310
+ * an example: the seeded document with every declared `example` committed
1311
+ * as its cell's value and each kind's `body.example` as its body. A
1312
+ * filled-in page whose values are made up to show the quill in use, never
1313
+ * kept.
1267
1314
  */
1268
1315
  exampleDocument(): Document | undefined;
1316
+ /**
1317
+ * A document from an authoring document, conformed against this quill:
1318
+ * the JSON twin of `parse`. A `null` is absent; the document carries this
1319
+ * quill's `$quill`. A value the schema refuses lands with a `conform::*`
1320
+ * warning on `doc.warnings`, and `validate` reports the rest at document
1321
+ * paths. Throws, with every error found, on a value that is not the
1322
+ * authoring document's shape (`authoring::invalid_shape`) or a name or
1323
+ * kind no card can store (`edit::*`).
1324
+ */
1325
+ fromAuthoring(value: AuthoringDocument): Document;
1269
1326
  /**
1270
1327
  * Read a `.quill` bundle, the zip archive holding one quill's file tree.
1271
1328
  * Pure, as [`fromTree`](Self::from_tree) is. A bundle outside the format
@@ -1314,6 +1371,13 @@ export class Quill {
1314
1371
  * `$kind: main` card of [`seedDocument`](Self::seed_document) alone.
1315
1372
  */
1316
1373
  seedMain(): Card;
1374
+ /**
1375
+ * `doc` as an authoring document: every field in the values form (each
1376
+ * content leaf its codec's text), every body as Markdown, each card
1377
+ * `{kind, fields, body}`. Sparse: an absent or `null` field stays absent. A
1378
+ * content leaf that decodes under neither encoding exports as stored.
1379
+ */
1380
+ toAuthoring(doc: Document): AuthoringDocument;
1317
1381
  /**
1318
1382
  * This quill's file tree as a `.quill` bundle, the bytes
1319
1383
  * [`fromBundle`](Self::from_bundle) reads.
@@ -1336,12 +1400,18 @@ export class Quill {
1336
1400
  * backend's `backend::declined_construct`.
1337
1401
  */
1338
1402
  validate(doc: Document): Diagnostic[];
1403
+ /**
1404
+ * JSON Schema (draft 2020-12) of the quill's authoring document: the
1405
+ * shape `fromAuthoring` takes and `toAuthoring` returns, every content
1406
+ * leaf a Markdown or literal string, each card kind under `$defs`
1407
+ * selected by `kind`.
1408
+ */
1409
+ readonly authoringSchema: Record<string, unknown>;
1339
1410
  /**
1340
1411
  * The *declared* backend identifier (e.g. `"typst"`): intent, not a
1341
1412
  * resolved capability. Capability is read from the engine.
1342
1413
  */
1343
1414
  readonly backendId: string;
1344
- readonly blueprint: string;
1345
1415
  /**
1346
1416
  * Identity snapshot of the `quill:` section of `Quill.yaml`. Pure config:
1347
1417
  * output formats are a resolved-backend capability read from
@@ -1441,6 +1511,14 @@ export function mapMarks(content: Content, bundle: ChangeBundle): ContentMark[];
1441
1511
  */
1442
1512
  export function mapPos(delta: Delta, pos: number, assoc: Assoc): number;
1443
1513
 
1514
+ /**
1515
+ * The canonical form of `rt`: the content `overwrite` stores from it, read
1516
+ * without a document. Normalizing rewrites structure, never the text, so the
1517
+ * answer's `text` is `rt.text`. Throws where `overwrite` would, with the same
1518
+ * error under this verb's name.
1519
+ */
1520
+ export function normalize(rt: Content): Content;
1521
+
1444
1522
  /**
1445
1523
  * Parse a canonical document-model `Diagnostic.path` (`cards.<kind>[<i>].<field>`,
1446
1524
  * `main.body`, `recipients[0].name`) into structured `DocPathSeg` segments, so
@@ -1509,6 +1587,7 @@ export interface InitOutput {
1509
1587
  readonly document_removeField: (a: number, b: number, c: number) => void;
1510
1588
  readonly document_removeSeedOverlay: (a: number, b: number, c: number, d: number) => void;
1511
1589
  readonly document_revise: (a: number, b: number, c: number, d: number, e: number) => void;
1590
+ readonly document_reviseContent: (a: number, b: number, c: number, d: number) => void;
1512
1591
  readonly document_seedOverlay: (a: number, b: number, c: number, d: number) => void;
1513
1592
  readonly document_setQuillRef: (a: number, b: number, c: number, d: number) => void;
1514
1593
  readonly document_storageVersionOf: (a: number, b: number, c: number) => void;
@@ -1546,13 +1625,15 @@ export interface InitOutput {
1546
1625
  readonly livesession_warnings: (a: number, b: number) => void;
1547
1626
  readonly mapMarks: (a: number, b: number, c: number) => void;
1548
1627
  readonly mapPos: (a: number, b: number, c: number, d: number) => void;
1628
+ readonly normalize: (a: number, b: number) => void;
1549
1629
  readonly parseDocPath: (a: number, b: number, c: number) => void;
1550
1630
  readonly quill__resolve: (a: number, b: number, c: number, d: number, e: number) => void;
1631
+ readonly quill_authoringSchema: (a: number, b: number) => void;
1551
1632
  readonly quill_backendId: (a: number, b: number) => void;
1552
- readonly quill_blueprint: (a: number, b: number) => void;
1553
1633
  readonly quill_conform: (a: number, b: number, c: number) => void;
1554
1634
  readonly quill_emptyDocument: (a: number) => number;
1555
- readonly quill_exampleDocument: (a: number, b: number) => void;
1635
+ readonly quill_exampleDocument: (a: number) => number;
1636
+ readonly quill_fromAuthoring: (a: number, b: number, c: number) => void;
1556
1637
  readonly quill_fromBundle: (a: number, b: number, c: number) => void;
1557
1638
  readonly quill_fromTree: (a: number, b: number) => void;
1558
1639
  readonly quill_metadata: (a: number, b: number) => void;
@@ -1561,6 +1642,7 @@ export interface InitOutput {
1561
1642
  readonly quill_seedCard: (a: number, b: number, c: number, d: number, e: number) => void;
1562
1643
  readonly quill_seedDocument: (a: number) => number;
1563
1644
  readonly quill_seedMain: (a: number, b: number) => void;
1645
+ readonly quill_toAuthoring: (a: number, b: number, c: number) => void;
1564
1646
  readonly quill_toBundle: (a: number, b: number) => void;
1565
1647
  readonly quill_toTree: (a: number) => number;
1566
1648
  readonly quill_validate: (a: number, b: number, c: number) => void;
package/render/wasm.js CHANGED
@@ -714,8 +714,9 @@ export class Document {
714
714
  /**
715
715
  * **Overwrite** the content value at `addr` with exactly `rt`: value
716
716
  * semantics, so the identity anchors of any previous value are gone. By
717
- * anchor fate `overwrite` destroys, [`revise`](Document::revise) rebases,
718
- * and [`applyChange`](Document::apply_change) preserves. An absent
717
+ * anchor fate `overwrite` destroys, [`revise`](Document::revise) and
718
+ * [`reviseContent`](Document::revise_content) rebase, and
719
+ * [`applyChange`](Document::apply_change) preserves. An absent
719
720
  * `addr.field` targets the body, an absent `addr.card` the main card.
720
721
  *
721
722
  * Throws on an out-of-range card, a malformed field name, or an `rt` that is
@@ -904,6 +905,40 @@ export class Document {
904
905
  wasm.__wbindgen_add_to_stack_pointer(16);
905
906
  }
906
907
  }
908
+ /**
909
+ * **Revise** the richtext value at `addr` to `rt`, keeping each stored prose
910
+ * anchor whose id `rt` does not hold: the content twin of
911
+ * [`revise`](Document::revise), for a value built elsewhere such as a
912
+ * merge's projection. Diffs `rt` against the current value, carries those
913
+ * anchors through the diff, and returns the
914
+ * `Revised` receipt, whose `delta` an editor bridge maps its own positions
915
+ * through and whose `warnings` is empty. `rt`'s own anchors and island ids
916
+ * land as they are. An absent `addr.field` targets the body, an absent
917
+ * `addr.card` the main card; an absent field diffs from empty. Richtext
918
+ * only: a `text` field takes `overwrite`.
919
+ *
920
+ * Throws on an out-of-range card, a malformed field name, a present
921
+ * non-content field value, or an `rt` that is not a canonical content
922
+ * object.
923
+ * @param {Addr | string} addr
924
+ * @param {Content} rt
925
+ * @returns {Revised}
926
+ */
927
+ reviseContent(addr, rt) {
928
+ try {
929
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
930
+ wasm.document_reviseContent(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(rt));
931
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
932
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
933
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
934
+ if (r2) {
935
+ throw takeObject(r1);
936
+ }
937
+ return takeObject(r0);
938
+ } finally {
939
+ wasm.__wbindgen_add_to_stack_pointer(16);
940
+ }
941
+ }
907
942
  /**
908
943
  * **Revise** the richtext value at `addr` from a markdown string: the
909
944
  * default write path. Imports the markdown, diffs it against the current
@@ -1728,35 +1763,38 @@ export class Quill {
1728
1763
  }
1729
1764
  }
1730
1765
  /**
1731
- * The *declared* backend identifier (e.g. `"typst"`): intent, not a
1732
- * resolved capability. Capability is read from the engine.
1733
- * @returns {string}
1766
+ * JSON Schema (draft 2020-12) of the quill's authoring document: the
1767
+ * shape `fromAuthoring` takes and `toAuthoring` returns, every content
1768
+ * leaf a Markdown or literal string, each card kind under `$defs`
1769
+ * selected by `kind`.
1770
+ * @returns {Record<string, unknown>}
1734
1771
  */
1735
- get backendId() {
1736
- let deferred1_0;
1737
- let deferred1_1;
1772
+ get authoringSchema() {
1738
1773
  try {
1739
1774
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1740
- wasm.quill_backendId(retptr, this.__wbg_ptr);
1775
+ wasm.quill_authoringSchema(retptr, this.__wbg_ptr);
1741
1776
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1742
1777
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1743
- deferred1_0 = r0;
1744
- deferred1_1 = r1;
1745
- return getStringFromWasm0(r0, r1);
1778
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1779
+ if (r2) {
1780
+ throw takeObject(r1);
1781
+ }
1782
+ return takeObject(r0);
1746
1783
  } finally {
1747
1784
  wasm.__wbindgen_add_to_stack_pointer(16);
1748
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1749
1785
  }
1750
1786
  }
1751
1787
  /**
1788
+ * The *declared* backend identifier (e.g. `"typst"`): intent, not a
1789
+ * resolved capability. Capability is read from the engine.
1752
1790
  * @returns {string}
1753
1791
  */
1754
- get blueprint() {
1792
+ get backendId() {
1755
1793
  let deferred1_0;
1756
1794
  let deferred1_1;
1757
1795
  try {
1758
1796
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1759
- wasm.quill_blueprint(retptr, this.__wbg_ptr);
1797
+ wasm.quill_backendId(retptr, this.__wbg_ptr);
1760
1798
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1761
1799
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1762
1800
  deferred1_0 = r0;
@@ -1800,7 +1838,7 @@ export class Quill {
1800
1838
  * The empty document: a main card carrying this quill's `$quill` and
1801
1839
  * `$kind: main`, no field committed, no composable card, no body. The
1802
1840
  * type-minimal valid input, and the document a plate is bound to render
1803
- * (the quill authoring contract). `new Document(ref)` is the same document
1841
+ * (the plate contract). `new Document(ref)` is the same document
1804
1842
  * reached by spelling the reference.
1805
1843
  * @returns {Document}
1806
1844
  */
@@ -1809,25 +1847,39 @@ export class Quill {
1809
1847
  return Document.__wrap(ret);
1810
1848
  }
1811
1849
  /**
1812
- * The quill's example document, `undefined` when the quill has no
1813
- * `example.md` at its root: a filled-in page whose values are made up to show the
1814
- * quill in use, never kept. It comes back pinned to this quill's
1815
- * `name@MAJOR.MINOR` and conformed as `parse` conforms, its parse and
1816
- * `conform::*` warnings on `doc.warnings`. Throws when the file does not
1817
- * parse or its `$quill` is not this quill's bare name.
1850
+ * The quill's example document, `undefined` when no slot or body declares
1851
+ * an example: the seeded document with every declared `example` committed
1852
+ * as its cell's value and each kind's `body.example` as its body. A
1853
+ * filled-in page whose values are made up to show the quill in use, never
1854
+ * kept.
1818
1855
  * @returns {Document | undefined}
1819
1856
  */
1820
1857
  exampleDocument() {
1858
+ const ret = wasm.quill_exampleDocument(this.__wbg_ptr);
1859
+ return ret === 0 ? undefined : Document.__wrap(ret);
1860
+ }
1861
+ /**
1862
+ * A document from an authoring document, conformed against this quill:
1863
+ * the JSON twin of `parse`. A `null` is absent; the document carries this
1864
+ * quill's `$quill`. A value the schema refuses lands with a `conform::*`
1865
+ * warning on `doc.warnings`, and `validate` reports the rest at document
1866
+ * paths. Throws, with every error found, on a value that is not the
1867
+ * authoring document's shape (`authoring::invalid_shape`) or a name or
1868
+ * kind no card can store (`edit::*`).
1869
+ * @param {AuthoringDocument} value
1870
+ * @returns {Document}
1871
+ */
1872
+ fromAuthoring(value) {
1821
1873
  try {
1822
1874
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1823
- wasm.quill_exampleDocument(retptr, this.__wbg_ptr);
1875
+ wasm.quill_fromAuthoring(retptr, this.__wbg_ptr, addHeapObject(value));
1824
1876
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1825
1877
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1826
1878
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1827
1879
  if (r2) {
1828
1880
  throw takeObject(r1);
1829
1881
  }
1830
- return r0 === 0 ? undefined : Document.__wrap(r0);
1882
+ return Document.__wrap(r0);
1831
1883
  } finally {
1832
1884
  wasm.__wbindgen_add_to_stack_pointer(16);
1833
1885
  }
@@ -2012,6 +2064,30 @@ export class Quill {
2012
2064
  wasm.__wbindgen_add_to_stack_pointer(16);
2013
2065
  }
2014
2066
  }
2067
+ /**
2068
+ * `doc` as an authoring document: every field in the values form (each
2069
+ * content leaf its codec's text), every body as Markdown, each card
2070
+ * `{kind, fields, body}`. Sparse: an absent or `null` field stays absent. A
2071
+ * content leaf that decodes under neither encoding exports as stored.
2072
+ * @param {Document} doc
2073
+ * @returns {AuthoringDocument}
2074
+ */
2075
+ toAuthoring(doc) {
2076
+ try {
2077
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2078
+ _assertClass(doc, Document);
2079
+ wasm.quill_toAuthoring(retptr, this.__wbg_ptr, doc.__wbg_ptr);
2080
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2081
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2082
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2083
+ if (r2) {
2084
+ throw takeObject(r1);
2085
+ }
2086
+ return takeObject(r0);
2087
+ } finally {
2088
+ wasm.__wbindgen_add_to_stack_pointer(16);
2089
+ }
2090
+ }
2015
2091
  /**
2016
2092
  * This quill's file tree as a `.quill` bundle, the bytes
2017
2093
  * [`fromBundle`](Self::from_bundle) reads.
@@ -2336,6 +2412,30 @@ export function mapPos(delta, pos, assoc) {
2336
2412
  }
2337
2413
  }
2338
2414
 
2415
+ /**
2416
+ * The canonical form of `rt`: the content `overwrite` stores from it, read
2417
+ * without a document. Normalizing rewrites structure, never the text, so the
2418
+ * answer's `text` is `rt.text`. Throws where `overwrite` would, with the same
2419
+ * error under this verb's name.
2420
+ * @param {Content} rt
2421
+ * @returns {Content}
2422
+ */
2423
+ export function normalize(rt) {
2424
+ try {
2425
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2426
+ wasm.normalize(retptr, addHeapObject(rt));
2427
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2428
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2429
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2430
+ if (r2) {
2431
+ throw takeObject(r1);
2432
+ }
2433
+ return takeObject(r0);
2434
+ } finally {
2435
+ wasm.__wbindgen_add_to_stack_pointer(16);
2436
+ }
2437
+ }
2438
+
2339
2439
  /**
2340
2440
  * Parse a canonical document-model `Diagnostic.path` (`cards.<kind>[<i>].<field>`,
2341
2441
  * `main.body`, `recipients[0].name`) into structured `DocPathSeg` segments, so
Binary file
@@ -41,6 +41,7 @@ export const document_removeExt: (a: number, b: number, c: number) => void;
41
41
  export const document_removeField: (a: number, b: number, c: number) => void;
42
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_reviseContent: (a: number, b: number, c: number, d: number) => void;
44
45
  export const document_seedOverlay: (a: number, b: number, c: number, d: number) => void;
45
46
  export const document_setQuillRef: (a: number, b: number, c: number, d: number) => void;
46
47
  export const document_storageVersionOf: (a: number, b: number, c: number) => void;
@@ -78,13 +79,15 @@ export const livesession_update: (a: number, b: number, c: number) => void;
78
79
  export const livesession_warnings: (a: number, b: number) => void;
79
80
  export const mapMarks: (a: number, b: number, c: number) => void;
80
81
  export const mapPos: (a: number, b: number, c: number, d: number) => void;
82
+ export const normalize: (a: number, b: number) => void;
81
83
  export const parseDocPath: (a: number, b: number, c: number) => void;
82
84
  export const quill__resolve: (a: number, b: number, c: number, d: number, e: number) => void;
85
+ export const quill_authoringSchema: (a: number, b: number) => void;
83
86
  export const quill_backendId: (a: number, b: number) => void;
84
- export const quill_blueprint: (a: number, b: number) => void;
85
87
  export const quill_conform: (a: number, b: number, c: number) => void;
86
88
  export const quill_emptyDocument: (a: number) => number;
87
- export const quill_exampleDocument: (a: number, b: number) => void;
89
+ export const quill_exampleDocument: (a: number) => number;
90
+ export const quill_fromAuthoring: (a: number, b: number, c: number) => void;
88
91
  export const quill_fromBundle: (a: number, b: number, c: number) => void;
89
92
  export const quill_fromTree: (a: number, b: number) => void;
90
93
  export const quill_metadata: (a: number, b: number) => void;
@@ -93,6 +96,7 @@ export const quill_schema: (a: number, b: number) => void;
93
96
  export const quill_seedCard: (a: number, b: number, c: number, d: number, e: number) => void;
94
97
  export const quill_seedDocument: (a: number) => number;
95
98
  export const quill_seedMain: (a: number, b: number) => void;
99
+ export const quill_toAuthoring: (a: number, b: number, c: number) => void;
96
100
  export const quill_toBundle: (a: number, b: number) => void;
97
101
  export const quill_toTree: (a: number) => number;
98
102
  export const quill_validate: (a: number, b: number, c: number) => void;
@@ -18,6 +18,7 @@ import type {
18
18
  Document as CoreDocument,
19
19
  importMarkdown,
20
20
  exportMarkdown,
21
+ normalize,
21
22
  rebase,
22
23
  mapPos,
23
24
  mapMarks,
@@ -40,6 +41,7 @@ export interface CoreSurface {
40
41
  Document: typeof CoreDocument;
41
42
  importMarkdown: typeof importMarkdown;
42
43
  exportMarkdown: typeof exportMarkdown;
44
+ normalize: typeof normalize;
43
45
  rebase: typeof rebase;
44
46
  mapPos: typeof mapPos;
45
47
  mapMarks: typeof mapMarks;
@@ -113,7 +115,9 @@ export type {
113
115
  QuillFieldUi,
114
116
  QuillCardUi,
115
117
  QuillGroupUi,
116
- QuillMetadata
118
+ QuillMetadata,
119
+ AuthoringDocument,
120
+ AuthoringCard
117
121
  } from '../core/wasm.js';
118
122
 
119
123
  // Content edit vocabulary: the op-grained content model `Document`'s methods
@@ -19,7 +19,7 @@ import initCore, { Quill, Document } from '../core/wasm.js';
19
19
  // itself), a `node:fs` read under Node, whose `fetch` rejects `file:` URLs.
20
20
  // Resolution-time, so `node:fs` never enters a browser graph.
21
21
  import { toModuleSource } from '#quillmark-env';
22
- import { importMarkdown, exportMarkdown, rebase, mapPos, mapMarks } from '../core/wasm.js';
22
+ import { importMarkdown, exportMarkdown, normalize, rebase, mapPos, mapMarks } from '../core/wasm.js';
23
23
  import { isInline, isPlain } from '../core/wasm.js';
24
24
  import { parseDocPath, formatDocPath, formatDiagnostic } from '../core/wasm.js';
25
25
 
@@ -47,6 +47,7 @@ const CORE_SURFACE = Object.freeze({
47
47
  Document,
48
48
  importMarkdown,
49
49
  exportMarkdown,
50
+ normalize,
50
51
  rebase,
51
52
  mapPos,
52
53
  mapMarks,
@@ -278,7 +279,7 @@ const HANDLE_KINDS = {
278
279
  },
279
280
  Document: {
280
281
  code: 'runtime::not_a_document',
281
- hint: 'Pass a Document built by Document.fromMarkdown / fromStored or quill.seedDocument / emptyDocument. A Document from another copy of @quillmark/wasm is refused too — each copy is its own WASM linear memory and its own class — so run `npm ls @quillmark/wasm` and dedupe to one.'
282
+ hint: 'Pass a Document built by Document.fromMarkdown / fromStored or quill.seedDocument / emptyDocument / fromAuthoring. A Document from another copy of @quillmark/wasm is refused too — each copy is its own WASM linear memory and its own class — so run `npm ls @quillmark/wasm` and dedupe to one.'
282
283
  }
283
284
  };
284
285