@quillmark/wasm 0.132.0 → 0.134.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.
package/render/wasm.js CHANGED
@@ -100,9 +100,9 @@ export class Document {
100
100
  /**
101
101
  * Batched twin of [`commitField`](Document::commit_field): typed-commit
102
102
  * several fields on the card `addr` targets atomically. `addr` is a **card
103
- * address** (absent = main; a present `field` throws). Same per-field
104
- * diagnostic contract as [`storeFields`](Document::store_fields) — nothing
105
- * applied on error, one `diagnostics` entry per offending field, including
103
+ * address** (absent = main; a present `field` throws). Nothing is
104
+ * applied on error, and the thrown error carries one `diagnostics` entry per
105
+ * offending field, including
106
106
  * `edit::unknown_field` for undeclared names. Throws on an out-of-range
107
107
  * card. Returns [`commitField`](Document::commit_field)'s warnings for
108
108
  * every field, in batch order.
@@ -127,6 +127,73 @@ export class Document {
127
127
  wasm.__wbindgen_add_to_stack_pointer(16);
128
128
  }
129
129
  }
130
+ /**
131
+ * The ABI under `writer.hashAt`: the body's hash, or a field's through its
132
+ * schema (a `richtext` field its content however it rests, a `text` field
133
+ * its literal text, any other type its stored value), the `baseHash` the
134
+ * writer's `reviseBody` / `reviseField` check. An undeclared name throws
135
+ * `edit::unknown_field`, an out-of-range card throws.
136
+ * @param {Quill} quill
137
+ * @param {Addr | string} addr
138
+ * @returns {string}
139
+ */
140
+ _hashAt(quill, addr) {
141
+ let deferred2_0;
142
+ let deferred2_1;
143
+ try {
144
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
145
+ _assertClass(quill, Quill);
146
+ wasm.document__hashAt(retptr, this.__wbg_ptr, quill.__wbg_ptr, addHeapObject(addr));
147
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
148
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
149
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
150
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
151
+ var ptr1 = r0;
152
+ var len1 = r1;
153
+ if (r3) {
154
+ ptr1 = 0; len1 = 0;
155
+ throw takeObject(r2);
156
+ }
157
+ deferred2_0 = ptr1;
158
+ deferred2_1 = len1;
159
+ return getStringFromWasm0(ptr1, len1);
160
+ } finally {
161
+ wasm.__wbindgen_add_to_stack_pointer(16);
162
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
163
+ }
164
+ }
165
+ /**
166
+ * The ABI under `writer.hash`: the hash of the document as `quill`
167
+ * conforms it, the `baseHash` `writer.reviseDocument` checks. Throws when
168
+ * the document declares a `$quill` this quill does not answer to.
169
+ * @param {Quill} quill
170
+ * @returns {string}
171
+ */
172
+ _hash(quill) {
173
+ let deferred2_0;
174
+ let deferred2_1;
175
+ try {
176
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
177
+ _assertClass(quill, Quill);
178
+ wasm.document__hash(retptr, this.__wbg_ptr, quill.__wbg_ptr);
179
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
180
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
181
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
182
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
183
+ var ptr1 = r0;
184
+ var len1 = r1;
185
+ if (r3) {
186
+ ptr1 = 0; len1 = 0;
187
+ throw takeObject(r2);
188
+ }
189
+ deferred2_0 = ptr1;
190
+ deferred2_1 = len1;
191
+ return getStringFromWasm0(ptr1, len1);
192
+ } finally {
193
+ wasm.__wbindgen_add_to_stack_pointer(16);
194
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
195
+ }
196
+ }
130
197
  /**
131
198
  * Interpreted **`Content`** read of a value nested inside the composite
132
199
  * field at `addr`: the stable ABI under the runtime `reader.getContentAt`,
@@ -249,15 +316,16 @@ export class Document {
249
316
  * does not answer to, before any mutation.
250
317
  * @param {Quill} quill
251
318
  * @param {string} markdown
319
+ * @param {any} opts
252
320
  * @returns {DocumentRevised}
253
321
  */
254
- _reviseDocument(quill, markdown) {
322
+ _reviseDocument(quill, markdown, opts) {
255
323
  try {
256
324
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
257
325
  _assertClass(quill, Quill);
258
326
  const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
259
327
  const len0 = WASM_VECTOR_LEN;
260
- wasm.document__reviseDocument(retptr, this.__wbg_ptr, quill.__wbg_ptr, ptr0, len0);
328
+ wasm.document__reviseDocument(retptr, this.__wbg_ptr, quill.__wbg_ptr, ptr0, len0, addHeapObject(opts));
261
329
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
262
330
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
263
331
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -284,15 +352,16 @@ export class Document {
284
352
  * @param {Quill} quill
285
353
  * @param {Addr | string} addr
286
354
  * @param {string} text
355
+ * @param {any} opts
287
356
  * @returns {Revised}
288
357
  */
289
- _reviseField(quill, addr, text) {
358
+ _reviseField(quill, addr, text, opts) {
290
359
  try {
291
360
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
292
361
  _assertClass(quill, Quill);
293
362
  const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
294
363
  const len0 = WASM_VECTOR_LEN;
295
- wasm.document__reviseField(retptr, this.__wbg_ptr, quill.__wbg_ptr, addHeapObject(addr), ptr0, len0);
364
+ wasm.document__reviseField(retptr, this.__wbg_ptr, quill.__wbg_ptr, addHeapObject(addr), ptr0, len0, addHeapObject(opts));
296
365
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
297
366
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
298
367
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -305,32 +374,166 @@ export class Document {
305
374
  }
306
375
  }
307
376
  /**
308
- * **Apply** a committed content edit `bundle` at `addr`, the editor splice:
309
- * text delta first, then island ops, then line ops, then mark ops (mark
310
- * ranges in final-text coordinates), all-or-nothing. An absent `addr.field`
311
- * targets the body, an absent `addr.card` the main card. The island channel
312
- * moves an island alone, so anchors elsewhere in the field survive an edit
313
- * `overwrite` would clear.
377
+ * The ABI under `writer.reviseBody`: **revise** the richtext value at
378
+ * `addr` from a markdown string. Imports the markdown, diffs it against the current
379
+ * value, rebases surviving identity anchors, and returns the `Revised`
380
+ * receipt: the text `delta` an editor bridge maps its own positions through,
381
+ * and a `parse::dropped_construct` warning per construct the
382
+ * import dropped, its `path` the address written. An absent `addr.field`
383
+ * targets the body, an absent `addr.card` the main card; an absent field
384
+ * cold-imports from empty.
314
385
  *
315
- * Throws on an out-of-range card, a field that is not richtext, a malformed
316
- * bundle, or an op that applies out of bounds; the value is unchanged on a
317
- * failed apply.
386
+ * `opts` names what the writer read (`BaseOptions`): a stale `baseHash`
387
+ * throws `edit::stale_base`, and a `baseMarkdown` the value has moved on
388
+ * from merges, throwing `edit::rebase_conflict` where both changed a line.
318
389
  *
319
- * Each text-moving channel rebases the marks already in the field, by the
320
- * rule on `ChangeBundle`; `mapMarks` answers where they land, so a caller
321
- * building `markOps` need not predict it.
390
+ * Throws on an out-of-range card, a malformed field name, a present
391
+ * non-content field value, or an over-nested markdown input.
322
392
  * @param {Addr | string} addr
323
- * @param {ChangeBundle} bundle
393
+ * @param {string} markdown
394
+ * @param {BaseOptions} [opts]
395
+ * @returns {Revised}
324
396
  */
325
- applyChange(addr, bundle) {
397
+ _revise(addr, markdown, opts) {
326
398
  try {
327
399
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
328
- wasm.document_applyChange(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(bundle));
400
+ const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
401
+ const len0 = WASM_VECTOR_LEN;
402
+ wasm.document__revise(retptr, this.__wbg_ptr, addHeapObject(addr), ptr0, len0, addHeapObject(opts));
329
403
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
330
404
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
331
- if (r1) {
332
- throw takeObject(r0);
405
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
406
+ if (r2) {
407
+ throw takeObject(r1);
408
+ }
409
+ return takeObject(r0);
410
+ } finally {
411
+ wasm.__wbindgen_add_to_stack_pointer(16);
412
+ }
413
+ }
414
+ /**
415
+ * The context of the anchor `id`, or `undefined` where no body or
416
+ * content value holds one.
417
+ * @param {string} id
418
+ * @returns {AnchorContext | undefined}
419
+ */
420
+ anchorContext(id) {
421
+ try {
422
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
423
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
424
+ const len0 = WASM_VECTOR_LEN;
425
+ wasm.document_anchorContext(retptr, this.__wbg_ptr, ptr0, len0);
426
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
427
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
428
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
429
+ if (r2) {
430
+ throw takeObject(r1);
431
+ }
432
+ return takeObject(r0);
433
+ } finally {
434
+ wasm.__wbindgen_add_to_stack_pointer(16);
435
+ }
436
+ }
437
+ /**
438
+ * Every anchor of every body and content value with its context, a table
439
+ * cell's or a note's included, in the order `toAnnotatedMarkdown` lists
440
+ * anchors: the selector a host stores beside a comment thread and hands
441
+ * back to `reattach`.
442
+ * @returns {AnchorContext[]}
443
+ */
444
+ anchorContexts() {
445
+ try {
446
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
447
+ wasm.document_anchorContexts(retptr, this.__wbg_ptr);
448
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
449
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
450
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
451
+ if (r2) {
452
+ throw takeObject(r1);
453
+ }
454
+ return takeObject(r0);
455
+ } finally {
456
+ wasm.__wbindgen_add_to_stack_pointer(16);
457
+ }
458
+ }
459
+ /**
460
+ * The annotated read of the body or richtext field at `addr` alone: the
461
+ * scoped twin of `toAnnotatedMarkdown`, what a revise at `addr` reads
462
+ * back and the `baseMarkdown` it merges against. Each anchor names `addr`'s
463
+ * path. An absent field reads as the empty content. Throws as `hashAt`.
464
+ * @param {Addr | string} addr
465
+ * @returns {AnnotatedMarkdown}
466
+ */
467
+ annotatedAt(addr) {
468
+ try {
469
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
470
+ wasm.document_annotatedAt(retptr, this.__wbg_ptr, addHeapObject(addr));
471
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
472
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
473
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
474
+ if (r2) {
475
+ throw takeObject(r1);
476
+ }
477
+ return takeObject(r0);
478
+ } finally {
479
+ wasm.__wbindgen_add_to_stack_pointer(16);
480
+ }
481
+ }
482
+ /**
483
+ * The markdown at `addr` with a `qm-*` tag for each anchor and island id
484
+ * its lines can hold: what `revise` reads back. Throws as `read`.
485
+ * @param {Addr | string} addr
486
+ * @returns {string}
487
+ */
488
+ annotated(addr) {
489
+ let deferred2_0;
490
+ let deferred2_1;
491
+ try {
492
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
493
+ wasm.document_annotated(retptr, this.__wbg_ptr, addHeapObject(addr));
494
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
495
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
496
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
497
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
498
+ var ptr1 = r0;
499
+ var len1 = r1;
500
+ if (r3) {
501
+ ptr1 = 0; len1 = 0;
502
+ throw takeObject(r2);
503
+ }
504
+ deferred2_0 = ptr1;
505
+ deferred2_1 = len1;
506
+ return getStringFromWasm0(ptr1, len1);
507
+ } finally {
508
+ wasm.__wbindgen_add_to_stack_pointer(16);
509
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
510
+ }
511
+ }
512
+ /**
513
+ * **Apply** `change` to the value at `addr`, all its steps or none, and
514
+ * answer the `Receipt`. `opts.base` is the hash the writer read
515
+ * (`hash(addr)`), and the change's offsets are into the value it names:
516
+ * one the value has moved on from rebases the change over the change
517
+ * since, throwing `edit::rebase_conflict` where they touch the same text or
518
+ * record and `edit::stale_base` where the document no longer holds the change
519
+ * since. A refused change throws `edit::content_apply` and writes
520
+ * nothing.
521
+ * @param {Addr | string} addr
522
+ * @param {Change} change
523
+ * @param {WriteOptions} [opts]
524
+ * @returns {Receipt}
525
+ */
526
+ apply(addr, change, opts) {
527
+ try {
528
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
529
+ wasm.document_apply(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(change), addHeapObject(opts));
530
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
531
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
532
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
533
+ if (r2) {
534
+ throw takeObject(r1);
333
535
  }
536
+ return takeObject(r0);
334
537
  } finally {
335
538
  wasm.__wbindgen_add_to_stack_pointer(16);
336
539
  }
@@ -442,11 +645,10 @@ export class Document {
442
645
  }
443
646
  /**
444
647
  * The newest storage version this build writes via
445
- * [`toStored`](Document::to_stored): a document spelling a font mark, a
446
- * `table` element, a merged table cell or a table head 0.130 cannot draw
447
- * carries it, every other the tag before it, which a 0.130 build reads.
448
- * The tag advances only when the wire format changes, not on every
449
- * release.
648
+ * [`toStored`](Document::to_stored): a document holding a composable
649
+ * card, each carrying its `$id`, carries it. A document of the main card
650
+ * alone carries the oldest tag that holds its content. The tag advances
651
+ * only when the wire format changes, not on every release.
450
652
  * @returns {string}
451
653
  */
452
654
  static currentStorageVersion() {
@@ -499,7 +701,7 @@ export class Document {
499
701
  }
500
702
  /**
501
703
  * Reconstruct a `Document` from a versioned storage DTO string produced by
502
- * [`toStored`](Document::to_stored). The result carries no parse-time warnings.
704
+ * [`toStored`](Document::to_stored), with no `warnings`.
503
705
  * Throws if `json` is not a valid storage DTO (malformed JSON, unknown
504
706
  * `schema`, missing fields, or unparseable quill reference).
505
707
  * @param {string} json
@@ -582,88 +784,111 @@ export class Document {
582
784
  }
583
785
  }
584
786
  /**
585
- * Insert a card: `at` absent appends, a number inserts at that index (in
586
- * `0..=cards.length`). Accepts any `CardInput`, including a card read back
587
- * out of a document. Throws if `card.kind` is not a valid kind name, if
588
- * `at` is out of range, or `edit::too_many_cards` if the document holds
589
- * 1,000 cards.
590
- * @param {CardInput} card
591
- * @param {number} [at]
787
+ * The hash of the body or richtext field at `addr`, the `baseHash` a
788
+ * revise at `addr` checks: the hash of its content, an absent field the
789
+ * empty content. An absent `addr.field` reads the body, an absent
790
+ * `addr.card` the main card. Richtext only; the
791
+ * typed `writer.hashAt` reads a field of any type through its schema.
792
+ * Throws on an out-of-range card, a malformed field name, or a present
793
+ * non-content field value.
794
+ * @param {Addr | string} addr
795
+ * @returns {string}
592
796
  */
593
- insertCard(card, at) {
797
+ hashAt(addr) {
798
+ let deferred2_0;
799
+ let deferred2_1;
594
800
  try {
595
801
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
596
- wasm.document_insertCard(retptr, this.__wbg_ptr, addHeapObject(card), isLikeNone(at) ? Number.MAX_SAFE_INTEGER : (at) >>> 0);
802
+ wasm.document_hashAt(retptr, this.__wbg_ptr, addHeapObject(addr));
597
803
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
598
804
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
599
- if (r1) {
600
- throw takeObject(r0);
805
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
806
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
807
+ var ptr1 = r0;
808
+ var len1 = r1;
809
+ if (r3) {
810
+ ptr1 = 0; len1 = 0;
811
+ throw takeObject(r2);
601
812
  }
813
+ deferred2_0 = ptr1;
814
+ deferred2_1 = len1;
815
+ return getStringFromWasm0(ptr1, len1);
602
816
  } finally {
603
817
  wasm.__wbindgen_add_to_stack_pointer(16);
818
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
604
819
  }
605
820
  }
606
821
  /**
607
- * Replace this document's contents **in place** from a versioned storage DTO
608
- * string: the mutating twin of [`fromStored`](Document::from_stored).
609
- * Parse-time `warnings` are cleared. Throws on an invalid DTO, leaving the
610
- * document unchanged. A caller holding the document need not re-bind its
611
- * variable.
612
- * @param {string} json
822
+ * With no `addr`, the hash of the document's stored form, the quill-free
823
+ * twin of `writer.hash()`: equal documents hash alike, whatever order a
824
+ * store kept their keys in. With one, the hash of the `Content` at
825
+ * `addr`, the `base` a write to it names. Throws as `read`.
826
+ * @param {Addr | string} [addr]
827
+ * @returns {string}
613
828
  */
614
- loadStored(json) {
829
+ hash(addr) {
830
+ let deferred2_0;
831
+ let deferred2_1;
615
832
  try {
616
833
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
617
- const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
618
- const len0 = WASM_VECTOR_LEN;
619
- wasm.document_loadStored(retptr, this.__wbg_ptr, ptr0, len0);
834
+ wasm.document_hash(retptr, this.__wbg_ptr, addHeapObject(addr));
620
835
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
621
836
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
622
- if (r1) {
623
- throw takeObject(r0);
837
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
838
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
839
+ var ptr1 = r0;
840
+ var len1 = r1;
841
+ if (r3) {
842
+ ptr1 = 0; len1 = 0;
843
+ throw takeObject(r2);
624
844
  }
845
+ deferred2_0 = ptr1;
846
+ deferred2_1 = len1;
847
+ return getStringFromWasm0(ptr1, len1);
625
848
  } finally {
626
849
  wasm.__wbindgen_add_to_stack_pointer(16);
850
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
627
851
  }
628
852
  }
629
853
  /**
630
- * The document's main (entry) card. Allocates and serializes on each call.
631
- * @returns {Card}
854
+ * Insert a card: `at` absent appends, a number inserts at that index (in
855
+ * `0..=cards.length`). Accepts any `CardInput`, including a card read back
856
+ * out of a document. Throws if `card.kind` is not a valid kind name, if
857
+ * `at` is out of range, or `edit::too_many_cards` if the document holds
858
+ * 1,000 cards.
859
+ * @param {CardInput} card
860
+ * @param {number} [at]
632
861
  */
633
- get main() {
862
+ insertCard(card, at) {
634
863
  try {
635
864
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
636
- wasm.document_main(retptr, this.__wbg_ptr);
865
+ wasm.document_insertCard(retptr, this.__wbg_ptr, addHeapObject(card), isLikeNone(at) ? Number.MAX_SAFE_INTEGER : (at) >>> 0);
637
866
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
638
867
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
639
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
640
- if (r2) {
641
- throw takeObject(r1);
868
+ if (r1) {
869
+ throw takeObject(r0);
642
870
  }
643
- return takeObject(r0);
644
871
  } finally {
645
872
  wasm.__wbindgen_add_to_stack_pointer(16);
646
873
  }
647
874
  }
648
875
  /**
649
- * The Quillmark Markdown rules, re-exposed from core. Constant across
650
- * calls; read once and cache.
651
- * @returns {string}
876
+ * The document's main (entry) card. Allocates and serializes on each call.
877
+ * @returns {Card}
652
878
  */
653
- static markdownRules() {
654
- let deferred1_0;
655
- let deferred1_1;
879
+ get main() {
656
880
  try {
657
881
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
658
- wasm.document_markdownRules(retptr);
882
+ wasm.document_main(retptr, this.__wbg_ptr);
659
883
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
660
884
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
661
- deferred1_0 = r0;
662
- deferred1_1 = r1;
663
- return getStringFromWasm0(r0, r1);
885
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
886
+ if (r2) {
887
+ throw takeObject(r1);
888
+ }
889
+ return takeObject(r0);
664
890
  } finally {
665
891
  wasm.__wbindgen_add_to_stack_pointer(16);
666
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
667
892
  }
668
893
  }
669
894
  /**
@@ -711,31 +936,6 @@ export class Document {
711
936
  wasm.__wbindgen_add_to_stack_pointer(16);
712
937
  }
713
938
  }
714
- /**
715
- * **Overwrite** the content value at `addr` with exactly `rt`: value
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
719
- * `addr.field` targets the body, an absent `addr.card` the main card.
720
- *
721
- * Throws on an out-of-range card, a malformed field name, or an `rt` that is
722
- * not a canonical content object.
723
- * @param {Addr | string} addr
724
- * @param {Content} rt
725
- */
726
- overwrite(addr, rt) {
727
- try {
728
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
729
- wasm.document_overwrite(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(rt));
730
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
731
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
732
- if (r1) {
733
- throw takeObject(r0);
734
- }
735
- } finally {
736
- wasm.__wbindgen_add_to_stack_pointer(16);
737
- }
738
- }
739
939
  /**
740
940
  * `addr`'s canonical `DocPath` string, the anchor `Diagnostic.path` carries:
741
941
  * `pathFor()` is `main.body`, `pathFor("intro")` `main.intro`,
@@ -749,7 +949,7 @@ export class Document {
749
949
  * **Total on the index axis**, unlike the `Addr` reads, which throw there:
750
950
  * an out-of-range `{card: 7, field: "from"}` renders `cards[7].from`, which
751
951
  * parses back and resolves to nothing rather than mis-targeting. Only a
752
- * malformed address throws.
952
+ * malformed address throws, or a card id no card holds.
753
953
  * @param {Addr | string} addr
754
954
  * @returns {string}
755
955
  */
@@ -796,26 +996,85 @@ export class Document {
796
996
  return getStringFromWasm0(r0, r1);
797
997
  } finally {
798
998
  wasm.__wbindgen_add_to_stack_pointer(16);
799
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
999
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1000
+ }
1001
+ }
1002
+ /**
1003
+ * @returns {string}
1004
+ */
1005
+ get quillRef() {
1006
+ let deferred1_0;
1007
+ let deferred1_1;
1008
+ try {
1009
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1010
+ wasm.document_quillRef(retptr, this.__wbg_ptr);
1011
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1012
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1013
+ deferred1_0 = r0;
1014
+ deferred1_1 = r1;
1015
+ return getStringFromWasm0(r0, r1);
1016
+ } finally {
1017
+ wasm.__wbindgen_add_to_stack_pointer(16);
1018
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1019
+ }
1020
+ }
1021
+ /**
1022
+ * The `Content` at `addr`: an absent `addr.field` reads the body, an
1023
+ * absent `addr.card` the main card, and an absent field the empty
1024
+ * content. Throws on an out-of-range card, a malformed field name, or a
1025
+ * present field value that is not content.
1026
+ * @param {Addr | string} addr
1027
+ * @returns {Content}
1028
+ */
1029
+ read(addr) {
1030
+ try {
1031
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1032
+ wasm.document_read(retptr, this.__wbg_ptr, addHeapObject(addr));
1033
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1034
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1035
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1036
+ if (r2) {
1037
+ throw takeObject(r1);
1038
+ }
1039
+ return takeObject(r0);
1040
+ } finally {
1041
+ wasm.__wbindgen_add_to_stack_pointer(16);
800
1042
  }
801
1043
  }
802
1044
  /**
803
- * @returns {string}
1045
+ * Re-add anchors a write dropped, each at the `path` its selector names,
1046
+ * where its `quote` is found exactly once with its context agreeing: four
1047
+ * scalar values of quote or more, or a table's slot alone, eight of
1048
+ * context on each side or the whole context where the value's edge cut
1049
+ * it, and an empty quote a point where the two meet. Never a nearest match. Returns the `Reattached`
1050
+ * receipt.
1051
+ *
1052
+ * A path naming no body or content value orphans its selector, and
1053
+ * nothing remaps a card index. An id live anywhere in the document, a
1054
+ * table cell's included, is answered as reattached and not written. Each
1055
+ * id is answered once, by its first selector. `deltas` maps a path to the
1056
+ * `delta` of the revise that dropped its anchors, and a match there must
1057
+ * overlap text that revise inserted.
1058
+ *
1059
+ * Throws on a selector or delta that is not one, or a `path` that does
1060
+ * not parse.
1061
+ * @param {AnchorContext[]} selectors
1062
+ * @param {Record<string, Delta>} [deltas]
1063
+ * @returns {Reattached}
804
1064
  */
805
- get quillRef() {
806
- let deferred1_0;
807
- let deferred1_1;
1065
+ reattach(selectors, deltas) {
808
1066
  try {
809
1067
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
810
- wasm.document_quillRef(retptr, this.__wbg_ptr);
1068
+ wasm.document_reattach(retptr, this.__wbg_ptr, addHeapObject(selectors), addHeapObject(deltas));
811
1069
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
812
1070
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
813
- deferred1_0 = r0;
814
- deferred1_1 = r1;
815
- return getStringFromWasm0(r0, r1);
1071
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1072
+ if (r2) {
1073
+ throw takeObject(r1);
1074
+ }
1075
+ return takeObject(r0);
816
1076
  } finally {
817
1077
  wasm.__wbindgen_add_to_stack_pointer(16);
818
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
819
1078
  }
820
1079
  }
821
1080
  /**
@@ -905,27 +1164,47 @@ export class Document {
905
1164
  }
906
1165
  }
907
1166
  /**
908
- * **Revise** the richtext value at `addr` from a markdown string: the
909
- * default write path. Imports the markdown, diffs it against the current
910
- * value, rebases surviving identity anchors, and returns the `Revised`
911
- * receipt: the text `delta` an editor bridge maps its own positions through
912
- * (`mapPos`), and a `parse::dropped_construct` warning per construct the
913
- * import dropped, its `path` the address written. An absent `addr.field`
914
- * targets the body, an absent `addr.card` the main card; an absent field
915
- * cold-imports from empty.
916
- *
917
- * Throws on an out-of-range card, a malformed field name, a present
918
- * non-content field value, or an over-nested markdown input.
1167
+ * Write `content` over the value at `addr`, carrying each anchor it does
1168
+ * not name where a diff keeps its text and reporting the rest in
1169
+ * `droppedAnchors`. Throws as `apply`, and on a `content` that is not a
1170
+ * `Content`.
1171
+ * @param {Addr | string} addr
1172
+ * @param {Content} content
1173
+ * @param {WriteOptions} [opts]
1174
+ * @returns {Receipt}
1175
+ */
1176
+ replace(addr, content, opts) {
1177
+ try {
1178
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1179
+ wasm.document_replace(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(content), addHeapObject(opts));
1180
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1181
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1182
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1183
+ if (r2) {
1184
+ throw takeObject(r1);
1185
+ }
1186
+ return takeObject(r0);
1187
+ } finally {
1188
+ wasm.__wbindgen_add_to_stack_pointer(16);
1189
+ }
1190
+ }
1191
+ /**
1192
+ * Rewrite the value at `addr` as `markdown`: the anchors and islands
1193
+ * whose `qm-*` tags it keeps (`annotated(addr)` spells them) stay put,
1194
+ * and the rest keeps what a word-aligned diff keeps. Answers the
1195
+ * `Receipt`, its `warnings` the import's. Throws as `apply`, and on an
1196
+ * over-nested markdown input.
919
1197
  * @param {Addr | string} addr
920
1198
  * @param {string} markdown
921
- * @returns {Revised}
1199
+ * @param {WriteOptions} [opts]
1200
+ * @returns {Receipt}
922
1201
  */
923
- revise(addr, markdown) {
1202
+ revise(addr, markdown, opts) {
924
1203
  try {
925
1204
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
926
1205
  const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
927
1206
  const len0 = WASM_VECTOR_LEN;
928
- wasm.document_revise(retptr, this.__wbg_ptr, addHeapObject(addr), ptr0, len0);
1207
+ wasm.document_revise(retptr, this.__wbg_ptr, addHeapObject(addr), ptr0, len0, addHeapObject(opts));
929
1208
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
930
1209
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
931
1210
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1035,7 +1314,7 @@ export class Document {
1035
1314
  * write is [`commitField`](Document::commit_field). A bare string is `Addr`
1036
1315
  * shorthand for `{ field }`; `{ card: 2, field: "qty" }` targets a
1037
1316
  * composable card. A body address throws:
1038
- * write a body with `revise` / `overwrite`. Throws on an out-of-range card
1317
+ * write a body with `writer.reviseBody` / `replace`. Throws on an out-of-range card
1039
1318
  * or a malformed name.
1040
1319
  * @param {Addr | string} addr
1041
1320
  * @param {any} value
@@ -1053,28 +1332,6 @@ export class Document {
1053
1332
  wasm.__wbindgen_add_to_stack_pointer(16);
1054
1333
  }
1055
1334
  }
1056
- /**
1057
- * Store several fields verbatim and atomically on the card `addr` targets.
1058
- * `addr` is a **card address** (`{ card }`, absent = main) and comes first
1059
- * because `card` is itself a legal field name; a present `field` throws.
1060
- * Nothing is applied on error, and the thrown error's `diagnostics` carry
1061
- * one entry per offending field. Throws on an out-of-range card.
1062
- * @param {CardAddr} addr
1063
- * @param {Record<string, unknown>} fields
1064
- */
1065
- storeFields(addr, fields) {
1066
- try {
1067
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1068
- wasm.document_storeFields(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(fields));
1069
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1070
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1071
- if (r1) {
1072
- throw takeObject(r0);
1073
- }
1074
- } finally {
1075
- wasm.__wbindgen_add_to_stack_pointer(16);
1076
- }
1077
- }
1078
1335
  /**
1079
1336
  * Merge a card-kind's seed `overlay` into the **main** card's `$seed` map
1080
1337
  * under `cardKind`, preserving sibling kinds; `$seed` is main-only, so this
@@ -1100,10 +1357,11 @@ export class Document {
1100
1357
  }
1101
1358
  /**
1102
1359
  * `toMarkdown` with each prose anchor of every body and content field
1103
- * spelled read-only at its start where its line can hold the tag, and
1104
- * listed with its field's path and line either way. An import drops every
1105
- * tag, so `writer.reviseDocument` with the markdown keeps the anchors it keeps
1106
- * with `toMarkdown`'s.
1360
+ * spelled at its start where its line can hold the tag, every anchor,
1361
+ * a cell's too, listed with its field's path and line, and each island whose markdown
1362
+ * does not read back spelled as its token. `writer.reviseDocument` reads
1363
+ * both back: a kept tag pins its anchor, and a token keeps its island as
1364
+ * stored.
1107
1365
  * @returns {AnnotatedMarkdown}
1108
1366
  */
1109
1367
  toAnnotatedMarkdown() {
@@ -1171,7 +1429,8 @@ export class Document {
1171
1429
  * The non-fatal diagnostics of the load that produced this document: parse
1172
1430
  * warnings, plus `conform::*` warnings when it came through `quill.parse`.
1173
1431
  * Session state, not document value: `equals` and the storage DTO exclude
1174
- * it, and `fromStored` / `loadStored` / `writer.reviseDocument` clear it.
1432
+ * it. `fromStored` sets it to the stored value's anchor id
1433
+ * collisions, and `writer.reviseDocument` clears it.
1175
1434
  * @returns {Diagnostic[]}
1176
1435
  */
1177
1436
  get warnings() {
@@ -1364,26 +1623,6 @@ export class LiveSession {
1364
1623
  const ptr = this.__destroy_into_raw();
1365
1624
  wasm.__wbg_livesession_free(ptr, 0);
1366
1625
  }
1367
- /**
1368
- * The backend that produced this session (e.g. `"typst"`).
1369
- * @returns {string}
1370
- */
1371
- get backendId() {
1372
- let deferred1_0;
1373
- let deferred1_1;
1374
- try {
1375
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1376
- wasm.livesession_backendId(retptr, this.__wbg_ptr);
1377
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1378
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1379
- deferred1_0 = r0;
1380
- deferred1_1 = r1;
1381
- return getStringFromWasm0(r0, r1);
1382
- } finally {
1383
- wasm.__wbindgen_add_to_stack_pointer(16);
1384
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1385
- }
1386
- }
1387
1626
  /**
1388
1627
  * Each address the current compile fills that a reader could want to
1389
1628
  * click, and the `DocPath` of the region reaching it: the address itself,
@@ -1472,8 +1711,10 @@ export class LiveSession {
1472
1711
  /**
1473
1712
  * A content position → **caret rect**, the reverse of `positionAt`: the box
1474
1713
  * to draw a caret at, in the same bottom-left PDF-point space as
1475
- * `FieldRegion.rect`, its `span` collapsed to `[pos, pos]`. `undefined` when
1476
- * the field places no tracked content or the offset maps to no drawn glyph.
1714
+ * `FieldRegion.rect`, its `span` collapsed to `[pos, pos]`. `pos` is a
1715
+ * UTF-16 offset into the field's `Content`. `undefined` when the field
1716
+ * places no tracked content, the offset falls inside a character, or it
1717
+ * maps to no drawn glyph.
1477
1718
  * @param {string} field
1478
1719
  * @param {number} pos
1479
1720
  * @returns {FieldRegion | undefined}
@@ -1556,8 +1797,8 @@ export class LiveSession {
1556
1797
  }
1557
1798
  }
1558
1799
  /**
1559
- * A point → **content position**: the field *and* a USV offset into its
1560
- * `Content`, for placing a caret or mapping a selection into the content
1800
+ * A point → **content position**: the field *and* a UTF-16 offset into
1801
+ * its `Content`, for placing a caret or mapping a selection into the content
1561
1802
  * model, or `undefined` off all content ink. `x`/`y`/`tolPt` are PDF
1562
1803
  * points, bottom-left origin, as in `fieldAt`. The offset is cluster-exact
1563
1804
  * and degrades to the containing segment's start on origin-less ink.
@@ -1636,8 +1877,8 @@ export class LiveSession {
1636
1877
  * and the session recovers on the next successful `update`. On success,
1637
1878
  * repaint `dirtyPages ∩ visible`.
1638
1879
  *
1639
- * Distinct from [`applyChange`](Document::apply_change), which splices ops
1640
- * into a document; this recompiles a document the caller already mutated.
1880
+ * Distinct from [`apply`](Document::apply), which edits a document's
1881
+ * content; this recompiles a document the caller already mutated.
1641
1882
  * @param {Document} doc
1642
1883
  * @returns {ChangeSet}
1643
1884
  */
@@ -1728,35 +1969,38 @@ export class Quill {
1728
1969
  }
1729
1970
  }
1730
1971
  /**
1731
- * The *declared* backend identifier (e.g. `"typst"`): intent, not a
1732
- * resolved capability. Capability is read from the engine.
1733
- * @returns {string}
1972
+ * JSON Schema (draft 2020-12) of the quill's authoring document: the
1973
+ * shape `fromAuthoring` takes and `toAuthoring` returns, every content
1974
+ * leaf a Markdown or literal string, each card kind under `$defs`
1975
+ * selected by `kind`.
1976
+ * @returns {Record<string, unknown>}
1734
1977
  */
1735
- get backendId() {
1736
- let deferred1_0;
1737
- let deferred1_1;
1978
+ get authoringSchema() {
1738
1979
  try {
1739
1980
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1740
- wasm.quill_backendId(retptr, this.__wbg_ptr);
1981
+ wasm.quill_authoringSchema(retptr, this.__wbg_ptr);
1741
1982
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1742
1983
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1743
- deferred1_0 = r0;
1744
- deferred1_1 = r1;
1745
- return getStringFromWasm0(r0, r1);
1984
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1985
+ if (r2) {
1986
+ throw takeObject(r1);
1987
+ }
1988
+ return takeObject(r0);
1746
1989
  } finally {
1747
1990
  wasm.__wbindgen_add_to_stack_pointer(16);
1748
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1749
1991
  }
1750
1992
  }
1751
1993
  /**
1994
+ * The *declared* backend identifier (e.g. `"typst"`): intent, not a
1995
+ * resolved capability. Capability is read from the engine.
1752
1996
  * @returns {string}
1753
1997
  */
1754
- get blueprint() {
1998
+ get backendId() {
1755
1999
  let deferred1_0;
1756
2000
  let deferred1_1;
1757
2001
  try {
1758
2002
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1759
- wasm.quill_blueprint(retptr, this.__wbg_ptr);
2003
+ wasm.quill_backendId(retptr, this.__wbg_ptr);
1760
2004
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1761
2005
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1762
2006
  deferred1_0 = r0;
@@ -1800,7 +2044,7 @@ export class Quill {
1800
2044
  * The empty document: a main card carrying this quill's `$quill` and
1801
2045
  * `$kind: main`, no field committed, no composable card, no body. The
1802
2046
  * 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
2047
+ * (the plate contract). `new Document(ref)` is the same document
1804
2048
  * reached by spelling the reference.
1805
2049
  * @returns {Document}
1806
2050
  */
@@ -1809,25 +2053,39 @@ export class Quill {
1809
2053
  return Document.__wrap(ret);
1810
2054
  }
1811
2055
  /**
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.
2056
+ * The quill's example document, `undefined` when no slot or body declares
2057
+ * an example: the seeded document with every declared `example` committed
2058
+ * as its cell's value and each kind's `body.example` as its body. A
2059
+ * filled-in page whose values are made up to show the quill in use, never
2060
+ * kept.
1818
2061
  * @returns {Document | undefined}
1819
2062
  */
1820
2063
  exampleDocument() {
2064
+ const ret = wasm.quill_exampleDocument(this.__wbg_ptr);
2065
+ return ret === 0 ? undefined : Document.__wrap(ret);
2066
+ }
2067
+ /**
2068
+ * A document from an authoring document, conformed against this quill:
2069
+ * the JSON twin of `parse`. A `null` is absent; the document carries this
2070
+ * quill's `$quill`. A value the schema refuses lands with a `conform::*`
2071
+ * warning on `doc.warnings`, and `validate` reports the rest at document
2072
+ * paths. Throws, with every error found, on a value that is not the
2073
+ * authoring document's shape (`authoring::invalid_shape`) or a name or
2074
+ * kind no card can store (`edit::*`).
2075
+ * @param {AuthoringDocument} value
2076
+ * @returns {Document}
2077
+ */
2078
+ fromAuthoring(value) {
1821
2079
  try {
1822
2080
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1823
- wasm.quill_exampleDocument(retptr, this.__wbg_ptr);
2081
+ wasm.quill_fromAuthoring(retptr, this.__wbg_ptr, addHeapObject(value));
1824
2082
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1825
2083
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1826
2084
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1827
2085
  if (r2) {
1828
2086
  throw takeObject(r1);
1829
2087
  }
1830
- return r0 === 0 ? undefined : Document.__wrap(r0);
2088
+ return Document.__wrap(r0);
1831
2089
  } finally {
1832
2090
  wasm.__wbindgen_add_to_stack_pointer(16);
1833
2091
  }
@@ -1993,14 +2251,18 @@ export class Quill {
1993
2251
  return Document.__wrap(ret);
1994
2252
  }
1995
2253
  /**
1996
- * Seed a starter main `Card` (carries `$quill`) from the schema: the
1997
- * `$kind: main` card of [`seedDocument`](Self::seed_document) alone.
1998
- * @returns {Card}
2254
+ * `doc` as an authoring document: every field in the values form (each
2255
+ * content leaf its codec's text), every body as Markdown, each card
2256
+ * `{kind, fields, body}`. Sparse: an absent or `null` field stays absent. A
2257
+ * content leaf that decodes under neither encoding exports as stored.
2258
+ * @param {Document} doc
2259
+ * @returns {AuthoringDocument}
1999
2260
  */
2000
- seedMain() {
2261
+ toAuthoring(doc) {
2001
2262
  try {
2002
2263
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2003
- wasm.quill_seedMain(retptr, this.__wbg_ptr);
2264
+ _assertClass(doc, Document);
2265
+ wasm.quill_toAuthoring(retptr, this.__wbg_ptr, doc.__wbg_ptr);
2004
2266
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2005
2267
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2006
2268
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -2097,6 +2359,55 @@ export class Quill {
2097
2359
  }
2098
2360
  if (Symbol.dispose) Quill.prototype[Symbol.dispose] = Quill.prototype.free;
2099
2361
 
2362
+ /**
2363
+ * Deleting `[start, end)`: the splice, and where the range runs from a
2364
+ * block's start into a later block, the `setBlock` giving the block that
2365
+ * keeps the text the shape of the block the range ends in.
2366
+ * @param {Content} content
2367
+ * @param {number} start
2368
+ * @param {number} end
2369
+ * @returns {Change}
2370
+ */
2371
+ export function deleteRange(content, start, end) {
2372
+ try {
2373
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2374
+ wasm.deleteRange(retptr, addHeapObject(content), start, end);
2375
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2376
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2377
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2378
+ if (r2) {
2379
+ throw takeObject(r1);
2380
+ }
2381
+ return takeObject(r0);
2382
+ } finally {
2383
+ wasm.__wbindgen_add_to_stack_pointer(16);
2384
+ }
2385
+ }
2386
+
2387
+ /**
2388
+ * A change taking `before` to `after`, word-aligned, for a writer with no
2389
+ * steps of its own. Throws `edit::content_apply` where `after` is not a
2390
+ * valid value.
2391
+ * @param {Content} before
2392
+ * @param {Content} after
2393
+ * @returns {Change}
2394
+ */
2395
+ export function diff(before, after) {
2396
+ try {
2397
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2398
+ wasm.diff(retptr, addHeapObject(before), addHeapObject(after));
2399
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2400
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2401
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2402
+ if (r2) {
2403
+ throw takeObject(r1);
2404
+ }
2405
+ return takeObject(r0);
2406
+ } finally {
2407
+ wasm.__wbindgen_add_to_stack_pointer(16);
2408
+ }
2409
+ }
2410
+
2100
2411
  /**
2101
2412
  * Export canonical `Content` to its markdown projection. Throws if `rt` is not
2102
2413
  * canonical content.
@@ -2199,10 +2510,10 @@ export function formatDocPath(segs) {
2199
2510
  }
2200
2511
 
2201
2512
  /**
2202
- * Import a markdown string: the pure, document-free codec. Returns the
2513
+ * Import a markdown string: the markdown codec's import, pure and document-free. Returns the
2203
2514
  * canonical `content` and a `parse::dropped_construct` warning per construct
2204
- * the import dropped, with no `path`. `overwrite(addr, importMarkdown(md).content)`
2205
- * spells the cold, anchor-losing write; prefer `revise` for edit semantics.
2515
+ * the import dropped, with no `path`. `replace(addr, importMarkdown(md).content)`
2516
+ * spells the cold write; prefer `revise` for edit semantics.
2206
2517
  * Throws on an over-nested input.
2207
2518
  * @param {string} markdown
2208
2519
  * @returns {Imported}
@@ -2225,6 +2536,83 @@ export function importMarkdown(markdown) {
2225
2536
  }
2226
2537
  }
2227
2538
 
2539
+ /**
2540
+ * Tab over the blocks `first` to `last` (`first` alone when absent): the
2541
+ * change nesting their items under the item before them. Throws
2542
+ * `edit::content_apply` where `first` is in no item, the range leaves its
2543
+ * list, or its first item is the list's first.
2544
+ * @param {Content} content
2545
+ * @param {string} first
2546
+ * @param {string | null} [last]
2547
+ * @returns {Change}
2548
+ */
2549
+ export function indent(content, first, last) {
2550
+ try {
2551
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2552
+ const ptr0 = passStringToWasm0(first, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2553
+ const len0 = WASM_VECTOR_LEN;
2554
+ var ptr1 = isLikeNone(last) ? 0 : passStringToWasm0(last, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2555
+ var len1 = WASM_VECTOR_LEN;
2556
+ wasm.indent(retptr, addHeapObject(content), ptr0, len0, ptr1, len1);
2557
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2558
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2559
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2560
+ if (r2) {
2561
+ throw takeObject(r1);
2562
+ }
2563
+ return takeObject(r0);
2564
+ } finally {
2565
+ wasm.__wbindgen_add_to_stack_pointer(16);
2566
+ }
2567
+ }
2568
+
2569
+ /**
2570
+ * Typing at `at`: the formatting the typed text carries, for a splice's
2571
+ * `marks`, in canonical order. Throws `edit::content_apply` where `at` is
2572
+ * past the text.
2573
+ * @param {Content} content
2574
+ * @param {number} at
2575
+ * @returns {ContentMarkKind[]}
2576
+ */
2577
+ export function inheritedMarks(content, at) {
2578
+ try {
2579
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2580
+ wasm.inheritedMarks(retptr, addHeapObject(content), at);
2581
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2582
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2583
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2584
+ if (r2) {
2585
+ throw takeObject(r1);
2586
+ }
2587
+ return takeObject(r0);
2588
+ } finally {
2589
+ wasm.__wbindgen_add_to_stack_pointer(16);
2590
+ }
2591
+ }
2592
+
2593
+ /**
2594
+ * The change that undoes `change` on `before`. Throws `edit::content_apply`
2595
+ * where `change` does not apply to `before`.
2596
+ * @param {Change} change
2597
+ * @param {Content} before
2598
+ * @returns {Change}
2599
+ */
2600
+ export function invert(change, before) {
2601
+ try {
2602
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2603
+ wasm.invert(retptr, addHeapObject(change), addHeapObject(before));
2604
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2605
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2606
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2607
+ if (r2) {
2608
+ throw takeObject(r1);
2609
+ }
2610
+ return takeObject(r0);
2611
+ } finally {
2612
+ wasm.__wbindgen_add_to_stack_pointer(16);
2613
+ }
2614
+ }
2615
+
2228
2616
  /**
2229
2617
  * Whether `content` satisfies the one-line constraint of `text` and
2230
2618
  * `richtext`: one `Para` line, in no container, with no islands. Judged on
@@ -2274,26 +2662,19 @@ export function isPlain(content) {
2274
2662
  }
2275
2663
 
2276
2664
  /**
2277
- * Where `bundle`'s text-moving channels (`delta`, then `islandOps`, then
2278
- * `lineOps`) leave `content`'s marks: the final-text coordinates the bundle's
2279
- * `markOps` are written in, under the rebase rule stated on `ChangeBundle`.
2280
- * The document-free read an editor diffs against to decide which `markOps` to
2281
- * emit, rather than reproducing that rule in its own language.
2282
- *
2283
- * `bundle.markOps` are ignored. The answer is normalized, as the store's is:
2284
- * marks a text move drops (out of range, zero-width formatting) are absent,
2285
- * and same-kind runs a move left adjacent arrive already unioned, so a bundle
2286
- * carrying no `markOps` names the marks the field will hold.
2287
- * Throws on a non-content `content`, a malformed bundle, or an op that applies
2288
- * out of bounds: `applyChange`'s errors on the same ops.
2665
+ * Backspace at the start of block `id`: the change joining it onto the block
2666
+ * before it, under that block's record. Throws `edit::content_apply` for the
2667
+ * first block or an id no block holds.
2289
2668
  * @param {Content} content
2290
- * @param {ChangeBundle} bundle
2291
- * @returns {ContentMark[]}
2669
+ * @param {string} id
2670
+ * @returns {Change}
2292
2671
  */
2293
- export function mapMarks(content, bundle) {
2672
+ export function joinBlocks(content, id) {
2294
2673
  try {
2295
2674
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2296
- wasm.mapMarks(retptr, addHeapObject(content), addHeapObject(bundle));
2675
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2676
+ const len0 = WASM_VECTOR_LEN;
2677
+ wasm.joinBlocks(retptr, addHeapObject(content), ptr0, len0);
2297
2678
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2298
2679
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2299
2680
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -2307,30 +2688,80 @@ export function mapMarks(content, bundle) {
2307
2688
  }
2308
2689
 
2309
2690
  /**
2310
- * Map a base content position (a USV index into `Content.text`, not a UTF-16
2311
- * offset) through a `delta` to its new position, holding a caret stable across
2312
- * a `revise`. `assoc` decides the side of a same-position insertion (`"after"`
2313
- * moves past it). Throws on a malformed `delta`.
2314
- *
2315
- * This maps a position the *caller* holds. For the marks already in a field,
2316
- * `mapMarks` applies the store's own assoc rule across every channel of a
2317
- * `ChangeBundle`.
2318
- * @param {Delta} delta
2319
- * @param {number} pos
2320
- * @param {Assoc} assoc
2321
- * @returns {number}
2691
+ * Where `pos` lands after `change`, and what around it the change deleted;
2692
+ * `assoc` (`"after"` by default) picks the side of text inserted at it.
2693
+ * Throws `edit::content_apply` where a splice deletes an island and names
2694
+ * none in `removed`, as the receipt's `applied` always does.
2695
+ * @param {Change} change
2696
+ * @param {Pos} pos
2697
+ * @param {"before" | "after"} [assoc]
2698
+ * @returns {MapResult}
2699
+ */
2700
+ export function mapPos(change, pos, assoc) {
2701
+ try {
2702
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2703
+ wasm.mapPos(retptr, addHeapObject(change), addHeapObject(pos), addHeapObject(assoc));
2704
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2705
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2706
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2707
+ if (r2) {
2708
+ throw takeObject(r1);
2709
+ }
2710
+ return takeObject(r0);
2711
+ } finally {
2712
+ wasm.__wbindgen_add_to_stack_pointer(16);
2713
+ }
2714
+ }
2715
+
2716
+ /**
2717
+ * The canonical form of `rt`: the content `replace` stores from it, read
2718
+ * without a document. Normalizing rewrites structure, never the text, so the
2719
+ * answer's `text` is `rt.text`. Throws where `replace` would, with the same
2720
+ * error under this verb's name.
2721
+ * @param {Content} rt
2722
+ * @returns {Content}
2723
+ */
2724
+ export function normalize(rt) {
2725
+ try {
2726
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2727
+ wasm.normalize(retptr, addHeapObject(rt));
2728
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2729
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2730
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2731
+ if (r2) {
2732
+ throw takeObject(r1);
2733
+ }
2734
+ return takeObject(r0);
2735
+ } finally {
2736
+ wasm.__wbindgen_add_to_stack_pointer(16);
2737
+ }
2738
+ }
2739
+
2740
+ /**
2741
+ * Shift-Tab over the blocks `first` to `last` (`first` alone when absent):
2742
+ * the change lifting them out of the innermost item or quote holding
2743
+ * `first`. Throws `edit::content_apply` where `first` is in neither or the
2744
+ * range leaves it.
2745
+ * @param {Content} content
2746
+ * @param {string} first
2747
+ * @param {string | null} [last]
2748
+ * @returns {Change}
2322
2749
  */
2323
- export function mapPos(delta, pos, assoc) {
2750
+ export function outdent(content, first, last) {
2324
2751
  try {
2325
2752
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2326
- wasm.mapPos(retptr, addHeapObject(delta), pos, addHeapObject(assoc));
2753
+ const ptr0 = passStringToWasm0(first, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2754
+ const len0 = WASM_VECTOR_LEN;
2755
+ var ptr1 = isLikeNone(last) ? 0 : passStringToWasm0(last, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2756
+ var len1 = WASM_VECTOR_LEN;
2757
+ wasm.outdent(retptr, addHeapObject(content), ptr0, len0, ptr1, len1);
2327
2758
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2328
2759
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2329
2760
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2330
2761
  if (r2) {
2331
2762
  throw takeObject(r1);
2332
2763
  }
2333
- return r0 >>> 0;
2764
+ return takeObject(r0);
2334
2765
  } finally {
2335
2766
  wasm.__wbindgen_add_to_stack_pointer(16);
2336
2767
  }
@@ -2363,21 +2794,20 @@ export function parseDocPath(path) {
2363
2794
  }
2364
2795
 
2365
2796
  /**
2366
- * Rebase `markdown` onto a `base` content: the document-free twin of `revise`,
2367
- * returning the new `content`, the text `delta` (offsets are USV indices into
2368
- * `Content.text`, surviving anchors rebased), and the import's
2369
- * `parse::dropped_construct` warnings, with no `path`. Throws on an
2370
- * over-nested markdown input or a non-content `base`.
2371
- * @param {Content} base
2372
- * @param {string} markdown
2373
- * @returns {{ content: Content; delta: Delta; warnings: Diagnostic[] }}
2797
+ * Enter at `at`: the change splitting the block holding `at` there, the new
2798
+ * block `newId` and the text keeping its id. Throws `edit::content_apply`
2799
+ * where `at` is past the text.
2800
+ * @param {Content} content
2801
+ * @param {number} at
2802
+ * @param {string} newId
2803
+ * @returns {Change}
2374
2804
  */
2375
- export function rebase(base, markdown) {
2805
+ export function splitBlock(content, at, newId) {
2376
2806
  try {
2377
2807
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2378
- const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2808
+ const ptr0 = passStringToWasm0(newId, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2379
2809
  const len0 = WASM_VECTOR_LEN;
2380
- wasm.rebase(retptr, addHeapObject(base), ptr0, len0);
2810
+ wasm.splitBlock(retptr, addHeapObject(content), at, ptr0, len0);
2381
2811
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2382
2812
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2383
2813
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -2398,6 +2828,36 @@ export function rebase(base, markdown) {
2398
2828
  export function start() {
2399
2829
  wasm.start();
2400
2830
  }
2831
+
2832
+ /**
2833
+ * The change wrapping the blocks `first` to `last` in a quote or a list,
2834
+ * around the children of their innermost shared item or quote that the range
2835
+ * touches; a list the range sits in is wrapped whole.
2836
+ * @param {Content} content
2837
+ * @param {string} first
2838
+ * @param {string} last
2839
+ * @param {WrapKind} kind
2840
+ * @returns {Change}
2841
+ */
2842
+ export function wrap(content, first, last, kind) {
2843
+ try {
2844
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2845
+ const ptr0 = passStringToWasm0(first, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2846
+ const len0 = WASM_VECTOR_LEN;
2847
+ const ptr1 = passStringToWasm0(last, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2848
+ const len1 = WASM_VECTOR_LEN;
2849
+ wasm.wrap(retptr, addHeapObject(content), ptr0, len0, ptr1, len1, addHeapObject(kind));
2850
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2851
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2852
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2853
+ if (r2) {
2854
+ throw takeObject(r1);
2855
+ }
2856
+ return takeObject(r0);
2857
+ } finally {
2858
+ wasm.__wbindgen_add_to_stack_pointer(16);
2859
+ }
2860
+ }
2401
2861
  function __wbg_get_imports() {
2402
2862
  const import0 = {
2403
2863
  __proto__: null,
@@ -2546,6 +3006,10 @@ function __wbg_get_imports() {
2546
3006
  __wbg_getRandomValues_436a51d0629d84e1: function() { return handleError(function (arg0, arg1) {
2547
3007
  globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
2548
3008
  }, arguments); },
3009
+ __wbg_get_31af05bd4842a84f: function() { return handleError(function (arg0, arg1) {
3010
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
3011
+ return addHeapObject(ret);
3012
+ }, arguments); },
2549
3013
  __wbg_get_658f6698067d9515: function() { return handleError(function (arg0, arg1) {
2550
3014
  const ret = Reflect.get(getObject(arg0), getObject(arg1));
2551
3015
  return addHeapObject(ret);
@@ -2562,6 +3026,10 @@ function __wbg_get_imports() {
2562
3026
  const ret = getObject(arg0)[getObject(arg1)];
2563
3027
  return addHeapObject(ret);
2564
3028
  },
3029
+ __wbg_has_5d6706e5209576c1: function() { return handleError(function (arg0, arg1) {
3030
+ const ret = Reflect.has(getObject(arg0), getObject(arg1));
3031
+ return ret;
3032
+ }, arguments); },
2565
3033
  __wbg_instanceof_ArrayBuffer_a99f175873e5d9b8: function(arg0) {
2566
3034
  let result;
2567
3035
  try {