@quillmark/wasm 0.94.0 → 0.95.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/core/wasm_bg.wasm CHANGED
Binary file
@@ -3,57 +3,54 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const __wbg_document_free: (a: number, b: number) => void;
5
5
  export const __wbg_quill_free: (a: number, b: number) => void;
6
- export const document_addCard: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
6
+ export const document__addCard: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
7
+ export const document__commitField: (a: number, b: number, c: number, d: number, e: number) => void;
8
+ export const document__commitFields: (a: number, b: number, c: number, d: number, e: number) => void;
9
+ export const document__reviseField: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
10
+ export const document__viewGet: (a: number, b: number, c: number, d: number) => void;
7
11
  export const document_applyChange: (a: number, b: number, c: number, d: number) => void;
8
12
  export const document_blueprintInstruction: (a: number, b: number, c: number) => void;
13
+ export const document_card: (a: number, b: number, c: number) => void;
9
14
  export const document_cardCount: (a: number) => number;
15
+ export const document_cardIndexById: (a: number, b: number, c: number) => number;
10
16
  export const document_cards: (a: number, b: number) => void;
11
17
  export const document_clone: (a: number) => number;
12
- export const document_commitCardField: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
13
- export const document_commitCardFields: (a: number, b: number, c: number, d: number, e: number) => void;
14
- export const document_commitField: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
15
- export const document_commitFields: (a: number, b: number, c: number, d: number) => void;
16
18
  export const document_currentSchemaVersion: (a: number) => void;
17
19
  export const document_equals: (a: number, b: number) => number;
18
20
  export const document_formatDiagnostic: (a: number, b: number) => void;
19
21
  export const document_formatRules: (a: number) => void;
20
22
  export const document_fromJson: (a: number, b: number, c: number) => void;
21
23
  export const document_fromMarkdown: (a: number, b: number, c: number) => void;
22
- export const document_get: (a: number, b: number, c: number, d: number) => void;
23
- export const document_getMarkdown: (a: number, b: number, c: number, d: number) => void;
24
+ export const document_get: (a: number, b: number, c: number) => void;
25
+ export const document_getExt: (a: number, b: number, c: number) => void;
26
+ export const document_getExtNamespace: (a: number, b: number, c: number, d: number, e: number) => void;
27
+ export const document_getMarkdown: (a: number, b: number, c: number) => void;
24
28
  export const document_insertCard: (a: number, b: number, c: number, d: number) => void;
25
29
  export const document_install: (a: number, b: number, c: number, d: number) => void;
30
+ export const document_isFill: (a: number, b: number, c: number) => void;
26
31
  export const document_loadJson: (a: number, b: number, c: number, d: number) => void;
27
32
  export const document_main: (a: number, b: number) => void;
28
33
  export const document_makeCard: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
29
34
  export const document_moveCard: (a: number, b: number, c: number, d: number) => void;
30
35
  export const document_new: (a: number, b: number, c: number) => void;
31
- export const document_pushCard: (a: number, b: number, c: number) => void;
32
36
  export const document_quillRef: (a: number, b: number) => void;
33
37
  export const document_quillRefHint: (a: number) => void;
34
38
  export const document_removeCard: (a: number, b: number, c: number) => void;
35
- export const document_removeCardExt: (a: number, b: number, c: number) => void;
36
- export const document_removeCardExtNamespace: (a: number, b: number, c: number, d: number, e: number) => void;
37
- export const document_removeCardField: (a: number, b: number, c: number, d: number, e: number) => void;
38
- export const document_removeExt: (a: number, b: number) => void;
39
- export const document_removeExtNamespace: (a: number, b: number, c: number, d: number) => void;
40
- export const document_removeField: (a: number, b: number, c: number, d: number) => void;
39
+ export const document_removeExt: (a: number, b: number, c: number) => void;
40
+ export const document_removeExtNamespace: (a: number, b: number, c: number, d: number, e: number) => void;
41
+ export const document_removeField: (a: number, b: number, c: number) => void;
41
42
  export const document_removeSeedNamespace: (a: number, b: number, c: number, d: number) => void;
42
- export const document_replaceBody: (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
44
  export const document_schemaVersionOf: (a: number, b: number, c: number) => void;
45
- export const document_setCardExt: (a: number, b: number, c: number, d: number) => void;
46
- export const document_setCardExtNamespace: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
47
- export const document_setCardField: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
48
- export const document_setCardFields: (a: number, b: number, c: number, d: number) => void;
45
+ export const document_seedOverlay: (a: number, b: number, c: number, d: number) => void;
49
46
  export const document_setCardKind: (a: number, b: number, c: number, d: number, e: number) => void;
50
- export const document_setExt: (a: number, b: number, c: number) => void;
51
- export const document_setExtNamespace: (a: number, b: number, c: number, d: number, e: number) => void;
52
- export const document_setField: (a: number, b: number, c: number, d: number, e: number) => void;
53
- export const document_setFields: (a: number, b: number, c: number) => void;
54
- export const document_setFill: (a: number, b: number, c: number, d: number, e: number) => void;
55
47
  export const document_setQuillRef: (a: number, b: number, c: number, d: number) => void;
56
- export const document_setSeedNamespace: (a: number, b: number, c: number, d: number, e: number) => void;
48
+ export const document_storeExt: (a: number, b: number, c: number, d: number) => void;
49
+ export const document_storeExtNamespace: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
50
+ export const document_storeField: (a: number, b: number, c: number, d: number) => void;
51
+ export const document_storeFields: (a: number, b: number, c: number, d: number) => void;
52
+ export const document_storeFill: (a: number, b: number, c: number, d: number) => void;
53
+ export const document_storeSeedNamespace: (a: number, b: number, c: number, d: number, e: number) => void;
57
54
  export const document_toJson: (a: number, b: number) => void;
58
55
  export const document_toMarkdown: (a: number, b: number) => void;
59
56
  export const document_tryFromJson: (a: number, b: number) => number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillmark/wasm",
3
- "version": "0.94.0",
3
+ "version": "0.95.1",
4
4
  "description": "WebAssembly bindings for Quillmark, a schema-driven document engine",
5
5
  "type": "module",
6
6
  "license": "MIT OR Apache-2.0",
@@ -14,9 +14,21 @@
14
14
  // public entry point, so this is a structural fact. Replacing the re-export
15
15
  // with a wrapper is a breaking design change, not a refactor. See runtime.js.
16
16
  export { Quill, Document, init } from '../core/wasm.js';
17
- // The document-free corpus codec, re-exported from the core build.
17
+ // The document-free content codec, re-exported from the core build.
18
18
  export { importMarkdown, exportMarkdown, rebase, mapPos } from '../core/wasm.js';
19
19
 
20
+ import type { CardAddr } from '../core/wasm.js';
21
+
22
+ /**
23
+ * The main card's address — the default target of the card-scoped verbs
24
+ * (`storeFields` / `storeExt` / `commitFields` / …). A named, {@link CardAddr}-typed
25
+ * alias for the empty address `{}`, so a main-card write names its target:
26
+ * `doc.storeFields(MAIN_CARD_ADDR, fields)`. It IS `{}` (frozen at runtime), a
27
+ * pure alias — `{}` and `undefined` stay equally valid. A card selector only,
28
+ * never a field address.
29
+ */
30
+ export declare const MAIN_CARD_ADDR: CardAddr;
31
+
20
32
  // Core-build types consumers read off `Quill`/`Document`.
21
33
  export type {
22
34
  Card,
@@ -33,6 +45,31 @@ export type {
33
45
  QuillMetadata
34
46
  } from '../core/wasm.js';
35
47
 
48
+ // Content edit vocabulary — the op-grained content model `Document`'s methods
49
+ // speak (`applyChange(addr, bundle)`, `install(addr, rt)`, `revise(…) => Delta`).
50
+ // Declared in the core build; re-exported here so the single public entry point
51
+ // names every type its own re-exported surface already references — `Card.body`
52
+ // is a `Content`, `PayloadItem.nestedFills` a `PathStep[][]`, `CardInput.body` a
53
+ // `Content | string` — rather than forcing consumers to derive them structurally
54
+ // off the `Document` handle. The content write path (a ProseMirror↔content codec)
55
+ // must name all of them; they are its correctness core, not edge types.
56
+ export type {
57
+ Content,
58
+ ContentLine,
59
+ ContentContainer,
60
+ ContentMark,
61
+ ContentIsland,
62
+ CardInput,
63
+ PathStep,
64
+ Addr,
65
+ CardAddr,
66
+ Delta,
67
+ Assoc,
68
+ LineOp,
69
+ MarkOp,
70
+ ChangeBundle
71
+ } from '../core/wasm.js';
72
+
36
73
  // ── Error contract ──────────────────────────────────────────────────────────
37
74
 
38
75
  /**
@@ -96,11 +133,11 @@ export interface RenderOptions {
96
133
  }
97
134
 
98
135
  /**
99
- * How precisely a {@link CorpusHit.pos} resolved — the marker a caret UI reads
136
+ * How precisely a {@link ContentHit.pos} resolved — the marker a caret UI reads
100
137
  * to decide whether to trust the offset. Never sub-cluster: `'cluster'` is the
101
138
  * finest, `'segment'` the floor it degrades to on origin-less ink.
102
139
  *
103
- * - `'cluster'` — `pos` is the first corpus char of the cluster under the point
140
+ * - `'cluster'` — `pos` is the first content char of the cluster under the point
104
141
  * (an escaped/CJK/shaping cluster floors to its first char). Place the caret
105
142
  * at `pos` directly.
106
143
  * - `'segment'` — the point hit origin-less ink (list markers, numbering, a
@@ -109,8 +146,8 @@ export interface RenderOptions {
109
146
  */
110
147
  export type HitGranularity = 'cluster' | 'segment';
111
148
 
112
- /** A click resolved to a field and USV offset into its RichText. */
113
- export interface CorpusHit {
149
+ /** A click resolved to a field and USV offset into its Content. */
150
+ export interface ContentHit {
114
151
  field: string;
115
152
  pos: number;
116
153
  /**
@@ -165,8 +202,8 @@ export interface FieldRegion {
165
202
  /** `[x0, y0, x1, y1]` in PDF points (1/72″), bottom-left origin. */
166
203
  rect: [number, number, number, number];
167
204
  /**
168
- * The corpus slice this box covers — USV `[start, end)` into the field's
169
- * `RichText` for content ink (one segment), absent for a scalar reference
205
+ * The content slice this box covers — USV `[start, end)` into the field's
206
+ * `Content` for content ink (one segment), absent for a scalar reference
170
207
  * site or widget. Consumers key segment highlights on it;
171
208
  * {@link LiveSession.fieldBoxes} unions same-page segments for the
172
209
  * whole-field box.
@@ -393,11 +430,11 @@ export declare class LiveSession {
393
430
  */
394
431
  fieldAt(page: number, x: number, y: number): string | undefined;
395
432
  /**
396
- * Fine-grained click → corpus position (caret placement). Same PDF-point
433
+ * Fine-grained click → content position (caret placement). Same PDF-point
397
434
  * space as {@link fieldAt}; `undefined` off all content ink.
398
435
  */
399
- positionAt(page: number, x: number, y: number): CorpusHit | undefined;
400
- /** Corpus position → caret rect — reverse of {@link positionAt}. */
436
+ positionAt(page: number, x: number, y: number): ContentHit | undefined;
437
+ /** Content position → caret rect — reverse of {@link positionAt}. */
401
438
  locate(field: string, pos: number): FieldRegion | undefined;
402
439
  /** Page geometry in points (1/72″). Report-only; the painter sizes the canvas. */
403
440
  pageSize(page: number): PageSize;
@@ -429,7 +466,7 @@ export declare class LiveSession {
429
466
  free(): void;
430
467
  }
431
468
 
432
- // ── Typed writer — the tier-1 front door ────────────────────────────────────
469
+ // ── Typed writer — the schema-bound front door ───────────────────────────────
433
470
 
434
471
  // `quill.writer(doc)` is patched onto the re-exported `Quill` prototype (the
435
472
  // class is re-exported verbatim, so the method is declared by merging into the
@@ -444,21 +481,30 @@ declare module '../core/wasm.js' {
444
481
  * ephemeral by convention — bind, write, discard.
445
482
  */
446
483
  writer(doc: Document): DocumentWriter;
484
+ /**
485
+ * Bind this quill's schema to `doc` for interpreted reads — the read twin of
486
+ * {@link Quill.writer}, mirroring core's `quill.view(&doc)`. Each field is
487
+ * read by its declared type (a richtext field to markdown, every other type
488
+ * verbatim) with schema authority, so a name the schema does not declare
489
+ * throws rather than reading back `undefined`. Holds both handles by
490
+ * reference and owns neither (nothing to `free()`); ephemeral by convention —
491
+ * bind, read, discard.
492
+ */
493
+ view(doc: Document): DocumentView;
447
494
  }
448
495
  }
449
496
 
450
497
  /**
451
- * A `Document` bound to its `Quill` for typed writes — the tier-1 default,
452
- * constructed via {@link Quill.writer}. Speaks names, values, and markdown; a
453
- * consumer here never meets an `Addr`, a corpus object, or a `Delta`. Bare
454
- * `set` / `setAll` / `setBody` / `addCard` / `card(i).set` instead of threading
455
- * the `quill` handle through every `commit*` call. Holds both handles by
456
- * reference and owns neither — nothing to `free()`.
498
+ * A `Document` bound to its `Quill` for typed writes — the schema-bound writer,
499
+ * constructed via {@link Quill.writer}. Speaks names, values, and markdown. Bare
500
+ * `set` / `setAll` / `setBody` / `reviseField` / `addCard` / `card(i).set`
501
+ * instead of threading the `quill` handle through the underscored ABI. Holds both
502
+ * handles by reference and owns neither nothing to `free()`.
457
503
  *
458
504
  * Typed commit is the default whenever a quill is in hand: it resolves each
459
505
  * field's schema type and strict-commits it, throwing `UnknownField` for a name
460
506
  * the schema does not declare — on the typed path an undeclared name is a typo,
461
- * not a fallback. The raw `Document.setField` / `setFields` verbs remain the
507
+ * not a fallback. The raw `Document.storeField` / `storeFields` verbs remain the
462
508
  * deliberate quill-free primitive (standalone data, storage/migration infra, or
463
509
  * holding not-yet-conforming in-progress input).
464
510
  */
@@ -483,13 +529,23 @@ export declare class DocumentWriter {
483
529
  * `Delta` receipt.
484
530
  */
485
531
  setBody(markdown: string): void;
532
+ /**
533
+ * Revise the richtext main-card field `name` from markdown — typed *and*
534
+ * anchor-preserving. Surviving anchors rebase, then the diffed result is
535
+ * schema-conformed (`richtext(inline)` rejects a multi-block result). Throws
536
+ * `UnknownField` for a name the schema does not declare. Returns the `Delta`.
537
+ */
538
+ reviseField(name: string, markdown: string): Delta;
486
539
  /**
487
540
  * Build a composable card of `kind`, typed-commit `fields` onto it, set its
488
- * body from optional markdown, and append it — the fused `makeCard` + typed
489
- * commit + `pushCard`. Transactional: a rejected field (throws a per-field
490
- * diagnostic bundle) or an invalid kind/body leaves the document untouched.
541
+ * body from optional markdown, and place it — the fused `makeCard` + typed
542
+ * commit + insertion. `at` picks the position: omitted appends, a number
543
+ * inserts at that index, so a positioned typed insert is one atomic call
544
+ * rather than `addCard` + `moveCard`. Transactional: a rejected field (throws
545
+ * a per-field diagnostic bundle) or an invalid kind/body/position leaves the
546
+ * document untouched.
491
547
  */
492
- addCard(kind: string, fields?: Record<string, unknown>, body?: string): void;
548
+ addCard(kind: string, fields?: Record<string, unknown>, body?: string, at?: number): void;
493
549
  /** Remove the composable card at `index`, returning it (or `undefined`). */
494
550
  removeCard(index: number): Card | undefined;
495
551
  /**
@@ -511,8 +567,84 @@ export declare class CardWriter {
511
567
  constructor(quill: Quill, doc: Document, index: number);
512
568
  /** The bound card index. */
513
569
  readonly index: number;
570
+ /**
571
+ * The bound card's `$kind` (empty string when it carries none), read through
572
+ * the document — mirrors core `CardWriter::kind()`. Throws `IndexOutOfRange`
573
+ * if the bound index is out of range.
574
+ */
575
+ readonly kind: string;
514
576
  set(name: string, value: unknown): void;
515
577
  setAll(fields: Record<string, unknown>): void;
516
578
  /** Set this card's body from markdown (edit semantics), discarding the delta. */
517
579
  setBody(markdown: string): void;
580
+ /**
581
+ * Revise the richtext field `name` on this card from markdown — typed *and*
582
+ * anchor-preserving; the card twin of {@link DocumentWriter.reviseField}.
583
+ * Throws `UnknownField` for an undeclared name and `IndexOutOfRange` if the
584
+ * bound index is out of range. Returns the `Delta`.
585
+ */
586
+ reviseField(name: string, markdown: string): Delta;
587
+ }
588
+
589
+ /**
590
+ * A `Document` bound to its `Quill` for interpreted reads — the schema-plane read
591
+ * view, constructed via {@link Quill.view} and the read twin of
592
+ * {@link DocumentWriter}. One `get` reads each field by its declared type: a
593
+ * richtext field to its markdown projection, a plaintext field to its literal
594
+ * text, every other type its canonical value verbatim. Holds both handles by
595
+ * reference and owns neither — nothing to `free()`.
596
+ *
597
+ * The schema authority is the point: unlike the quill-free transport `Document.get`,
598
+ * a name the schema does not declare throws `UnknownField` (a typo) rather than
599
+ * reading back `undefined`, and a content field holding a value that does not
600
+ * decode throws `FieldRichtextDecode`. A field's markdown lives here, not on the
601
+ * body-only `Document.getMarkdown`. The body read stays quill-free (a body's type
602
+ * is a format fact) and never throws.
603
+ */
604
+ export declare class DocumentView {
605
+ constructor(quill: Quill, doc: Document);
606
+ /** The bound document — the instance passed in. */
607
+ readonly document: Document;
608
+ /**
609
+ * Read the value at `addr`, interpreted by its declared type: a richtext field
610
+ * to markdown, every other type verbatim. A bare string is `Addr` shorthand for
611
+ * `{ field }`; an absent `addr.field` reads the body markdown. `undefined` for
612
+ * an absent field; throws `UnknownField` for a name the schema does not declare,
613
+ * `FieldRichtextDecode` for a richtext field holding an undecodable value, and
614
+ * `IndexOutOfRange` for a bad `addr.card`.
615
+ */
616
+ get(addr: Addr | string): unknown;
617
+ /** The main body's markdown — the quill-free body read. Equals `get({})`. */
618
+ getBody(): string;
619
+ /**
620
+ * A {@link CardView} for the composable card at `index`. Index validity is
621
+ * checked lazily at read time, so this never throws. The cursor is ephemeral —
622
+ * a `removeCard`/`addCard` between binding and reading silently retargets it.
623
+ */
624
+ card(index: number): CardView;
625
+ }
626
+
627
+ /**
628
+ * A composable card bound to its `Quill` for interpreted reads, from
629
+ * {@link DocumentView.card}. Same verbs as {@link DocumentView}, reading the card
630
+ * at its bound index; each read throws `IndexOutOfRange` if that index is out of
631
+ * range.
632
+ */
633
+ export declare class CardView {
634
+ constructor(quill: Quill, doc: Document, index: number);
635
+ /** The bound card index. */
636
+ readonly index: number;
637
+ /**
638
+ * The bound card's `$kind` (empty string when it carries none). Throws
639
+ * `IndexOutOfRange` if the bound index is out of range.
640
+ */
641
+ readonly kind: string;
642
+ /**
643
+ * Read the field `name` on this card, interpreted by its declared type.
644
+ * `undefined` when absent; throws `UnknownField` for an undeclared name and
645
+ * `IndexOutOfRange` for a bad index.
646
+ */
647
+ get(name: string): unknown;
648
+ /** This card's body markdown — the card twin of {@link DocumentView.getBody}. */
649
+ getBody(): string;
518
650
  }