@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/core/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.
392
+ * @param {Addr | string} addr
393
+ * @param {string} markdown
394
+ * @param {BaseOptions} [opts]
395
+ * @returns {Revised}
396
+ */
397
+ _revise(addr, markdown, opts) {
398
+ try {
399
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
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));
403
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
404
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
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`.
322
464
  * @param {Addr | string} addr
323
- * @param {ChangeBundle} bundle
465
+ * @returns {AnnotatedMarkdown}
324
466
  */
325
- applyChange(addr, bundle) {
467
+ annotatedAt(addr) {
326
468
  try {
327
469
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
328
- wasm.document_applyChange(retptr, this.__wbg_ptr, addHeapObject(addr), addHeapObject(bundle));
470
+ wasm.document_annotatedAt(retptr, this.__wbg_ptr, addHeapObject(addr));
329
471
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
330
472
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
331
- if (r1) {
332
- throw takeObject(r0);
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);
333
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);
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
  */
@@ -818,6 +1018,65 @@ export class Document {
818
1018
  wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
819
1019
  }
820
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);
1042
+ }
1043
+ }
1044
+ /**
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}
1064
+ */
1065
+ reattach(selectors, deltas) {
1066
+ try {
1067
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1068
+ wasm.document_reattach(retptr, this.__wbg_ptr, addHeapObject(selectors), addHeapObject(deltas));
1069
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1070
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1071
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1072
+ if (r2) {
1073
+ throw takeObject(r1);
1074
+ }
1075
+ return takeObject(r0);
1076
+ } finally {
1077
+ wasm.__wbindgen_add_to_stack_pointer(16);
1078
+ }
1079
+ }
821
1080
  /**
822
1081
  * @param {number} index
823
1082
  * @returns {Card | undefined}
@@ -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() {
@@ -1239,35 +1498,38 @@ export class Quill {
1239
1498
  }
1240
1499
  }
1241
1500
  /**
1242
- * The *declared* backend identifier (e.g. `"typst"`): intent, not a
1243
- * resolved capability. Capability is read from the engine.
1244
- * @returns {string}
1501
+ * JSON Schema (draft 2020-12) of the quill's authoring document: the
1502
+ * shape `fromAuthoring` takes and `toAuthoring` returns, every content
1503
+ * leaf a Markdown or literal string, each card kind under `$defs`
1504
+ * selected by `kind`.
1505
+ * @returns {Record<string, unknown>}
1245
1506
  */
1246
- get backendId() {
1247
- let deferred1_0;
1248
- let deferred1_1;
1507
+ get authoringSchema() {
1249
1508
  try {
1250
1509
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1251
- wasm.quill_backendId(retptr, this.__wbg_ptr);
1510
+ wasm.quill_authoringSchema(retptr, this.__wbg_ptr);
1252
1511
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1253
1512
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1254
- deferred1_0 = r0;
1255
- deferred1_1 = r1;
1256
- return getStringFromWasm0(r0, r1);
1513
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1514
+ if (r2) {
1515
+ throw takeObject(r1);
1516
+ }
1517
+ return takeObject(r0);
1257
1518
  } finally {
1258
1519
  wasm.__wbindgen_add_to_stack_pointer(16);
1259
- wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1260
1520
  }
1261
1521
  }
1262
1522
  /**
1523
+ * The *declared* backend identifier (e.g. `"typst"`): intent, not a
1524
+ * resolved capability. Capability is read from the engine.
1263
1525
  * @returns {string}
1264
1526
  */
1265
- get blueprint() {
1527
+ get backendId() {
1266
1528
  let deferred1_0;
1267
1529
  let deferred1_1;
1268
1530
  try {
1269
1531
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1270
- wasm.quill_blueprint(retptr, this.__wbg_ptr);
1532
+ wasm.quill_backendId(retptr, this.__wbg_ptr);
1271
1533
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1272
1534
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1273
1535
  deferred1_0 = r0;
@@ -1311,7 +1573,7 @@ export class Quill {
1311
1573
  * The empty document: a main card carrying this quill's `$quill` and
1312
1574
  * `$kind: main`, no field committed, no composable card, no body. The
1313
1575
  * type-minimal valid input, and the document a plate is bound to render
1314
- * (the quill authoring contract). `new Document(ref)` is the same document
1576
+ * (the plate contract). `new Document(ref)` is the same document
1315
1577
  * reached by spelling the reference.
1316
1578
  * @returns {Document}
1317
1579
  */
@@ -1320,25 +1582,39 @@ export class Quill {
1320
1582
  return Document.__wrap(ret);
1321
1583
  }
1322
1584
  /**
1323
- * The quill's example document, `undefined` when the quill has no
1324
- * `example.md` at its root: a filled-in page whose values are made up to show the
1325
- * quill in use, never kept. It comes back pinned to this quill's
1326
- * `name@MAJOR.MINOR` and conformed as `parse` conforms, its parse and
1327
- * `conform::*` warnings on `doc.warnings`. Throws when the file does not
1328
- * parse or its `$quill` is not this quill's bare name.
1585
+ * The quill's example document, `undefined` when no slot or body declares
1586
+ * an example: the seeded document with every declared `example` committed
1587
+ * as its cell's value and each kind's `body.example` as its body. A
1588
+ * filled-in page whose values are made up to show the quill in use, never
1589
+ * kept.
1329
1590
  * @returns {Document | undefined}
1330
1591
  */
1331
1592
  exampleDocument() {
1593
+ const ret = wasm.quill_exampleDocument(this.__wbg_ptr);
1594
+ return ret === 0 ? undefined : Document.__wrap(ret);
1595
+ }
1596
+ /**
1597
+ * A document from an authoring document, conformed against this quill:
1598
+ * the JSON twin of `parse`. A `null` is absent; the document carries this
1599
+ * quill's `$quill`. A value the schema refuses lands with a `conform::*`
1600
+ * warning on `doc.warnings`, and `validate` reports the rest at document
1601
+ * paths. Throws, with every error found, on a value that is not the
1602
+ * authoring document's shape (`authoring::invalid_shape`) or a name or
1603
+ * kind no card can store (`edit::*`).
1604
+ * @param {AuthoringDocument} value
1605
+ * @returns {Document}
1606
+ */
1607
+ fromAuthoring(value) {
1332
1608
  try {
1333
1609
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1334
- wasm.quill_exampleDocument(retptr, this.__wbg_ptr);
1610
+ wasm.quill_fromAuthoring(retptr, this.__wbg_ptr, addHeapObject(value));
1335
1611
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1336
1612
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1337
1613
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1338
1614
  if (r2) {
1339
1615
  throw takeObject(r1);
1340
1616
  }
1341
- return r0 === 0 ? undefined : Document.__wrap(r0);
1617
+ return Document.__wrap(r0);
1342
1618
  } finally {
1343
1619
  wasm.__wbindgen_add_to_stack_pointer(16);
1344
1620
  }
@@ -1504,14 +1780,18 @@ export class Quill {
1504
1780
  return Document.__wrap(ret);
1505
1781
  }
1506
1782
  /**
1507
- * Seed a starter main `Card` (carries `$quill`) from the schema: the
1508
- * `$kind: main` card of [`seedDocument`](Self::seed_document) alone.
1509
- * @returns {Card}
1783
+ * `doc` as an authoring document: every field in the values form (each
1784
+ * content leaf its codec's text), every body as Markdown, each card
1785
+ * `{kind, fields, body}`. Sparse: an absent or `null` field stays absent. A
1786
+ * content leaf that decodes under neither encoding exports as stored.
1787
+ * @param {Document} doc
1788
+ * @returns {AuthoringDocument}
1510
1789
  */
1511
- seedMain() {
1790
+ toAuthoring(doc) {
1512
1791
  try {
1513
1792
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1514
- wasm.quill_seedMain(retptr, this.__wbg_ptr);
1793
+ _assertClass(doc, Document);
1794
+ wasm.quill_toAuthoring(retptr, this.__wbg_ptr, doc.__wbg_ptr);
1515
1795
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1516
1796
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1517
1797
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1608,6 +1888,55 @@ export class Quill {
1608
1888
  }
1609
1889
  if (Symbol.dispose) Quill.prototype[Symbol.dispose] = Quill.prototype.free;
1610
1890
 
1891
+ /**
1892
+ * Deleting `[start, end)`: the splice, and where the range runs from a
1893
+ * block's start into a later block, the `setBlock` giving the block that
1894
+ * keeps the text the shape of the block the range ends in.
1895
+ * @param {Content} content
1896
+ * @param {number} start
1897
+ * @param {number} end
1898
+ * @returns {Change}
1899
+ */
1900
+ export function deleteRange(content, start, end) {
1901
+ try {
1902
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1903
+ wasm.deleteRange(retptr, addHeapObject(content), start, end);
1904
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1905
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1906
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1907
+ if (r2) {
1908
+ throw takeObject(r1);
1909
+ }
1910
+ return takeObject(r0);
1911
+ } finally {
1912
+ wasm.__wbindgen_add_to_stack_pointer(16);
1913
+ }
1914
+ }
1915
+
1916
+ /**
1917
+ * A change taking `before` to `after`, word-aligned, for a writer with no
1918
+ * steps of its own. Throws `edit::content_apply` where `after` is not a
1919
+ * valid value.
1920
+ * @param {Content} before
1921
+ * @param {Content} after
1922
+ * @returns {Change}
1923
+ */
1924
+ export function diff(before, after) {
1925
+ try {
1926
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1927
+ wasm.diff(retptr, addHeapObject(before), addHeapObject(after));
1928
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1929
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1930
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1931
+ if (r2) {
1932
+ throw takeObject(r1);
1933
+ }
1934
+ return takeObject(r0);
1935
+ } finally {
1936
+ wasm.__wbindgen_add_to_stack_pointer(16);
1937
+ }
1938
+ }
1939
+
1611
1940
  /**
1612
1941
  * Export canonical `Content` to its markdown projection. Throws if `rt` is not
1613
1942
  * canonical content.
@@ -1710,10 +2039,10 @@ export function formatDocPath(segs) {
1710
2039
  }
1711
2040
 
1712
2041
  /**
1713
- * Import a markdown string: the pure, document-free codec. Returns the
2042
+ * Import a markdown string: the markdown codec's import, pure and document-free. Returns the
1714
2043
  * canonical `content` and a `parse::dropped_construct` warning per construct
1715
- * the import dropped, with no `path`. `overwrite(addr, importMarkdown(md).content)`
1716
- * spells the cold, anchor-losing write; prefer `revise` for edit semantics.
2044
+ * the import dropped, with no `path`. `replace(addr, importMarkdown(md).content)`
2045
+ * spells the cold write; prefer `revise` for edit semantics.
1717
2046
  * Throws on an over-nested input.
1718
2047
  * @param {string} markdown
1719
2048
  * @returns {Imported}
@@ -1736,6 +2065,83 @@ export function importMarkdown(markdown) {
1736
2065
  }
1737
2066
  }
1738
2067
 
2068
+ /**
2069
+ * Tab over the blocks `first` to `last` (`first` alone when absent): the
2070
+ * change nesting their items under the item before them. Throws
2071
+ * `edit::content_apply` where `first` is in no item, the range leaves its
2072
+ * list, or its first item is the list's first.
2073
+ * @param {Content} content
2074
+ * @param {string} first
2075
+ * @param {string | null} [last]
2076
+ * @returns {Change}
2077
+ */
2078
+ export function indent(content, first, last) {
2079
+ try {
2080
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2081
+ const ptr0 = passStringToWasm0(first, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2082
+ const len0 = WASM_VECTOR_LEN;
2083
+ var ptr1 = isLikeNone(last) ? 0 : passStringToWasm0(last, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2084
+ var len1 = WASM_VECTOR_LEN;
2085
+ wasm.indent(retptr, addHeapObject(content), ptr0, len0, ptr1, len1);
2086
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2087
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2088
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2089
+ if (r2) {
2090
+ throw takeObject(r1);
2091
+ }
2092
+ return takeObject(r0);
2093
+ } finally {
2094
+ wasm.__wbindgen_add_to_stack_pointer(16);
2095
+ }
2096
+ }
2097
+
2098
+ /**
2099
+ * Typing at `at`: the formatting the typed text carries, for a splice's
2100
+ * `marks`, in canonical order. Throws `edit::content_apply` where `at` is
2101
+ * past the text.
2102
+ * @param {Content} content
2103
+ * @param {number} at
2104
+ * @returns {ContentMarkKind[]}
2105
+ */
2106
+ export function inheritedMarks(content, at) {
2107
+ try {
2108
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2109
+ wasm.inheritedMarks(retptr, addHeapObject(content), at);
2110
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2111
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2112
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2113
+ if (r2) {
2114
+ throw takeObject(r1);
2115
+ }
2116
+ return takeObject(r0);
2117
+ } finally {
2118
+ wasm.__wbindgen_add_to_stack_pointer(16);
2119
+ }
2120
+ }
2121
+
2122
+ /**
2123
+ * The change that undoes `change` on `before`. Throws `edit::content_apply`
2124
+ * where `change` does not apply to `before`.
2125
+ * @param {Change} change
2126
+ * @param {Content} before
2127
+ * @returns {Change}
2128
+ */
2129
+ export function invert(change, before) {
2130
+ try {
2131
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2132
+ wasm.invert(retptr, addHeapObject(change), addHeapObject(before));
2133
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2134
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2135
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2136
+ if (r2) {
2137
+ throw takeObject(r1);
2138
+ }
2139
+ return takeObject(r0);
2140
+ } finally {
2141
+ wasm.__wbindgen_add_to_stack_pointer(16);
2142
+ }
2143
+ }
2144
+
1739
2145
  /**
1740
2146
  * Whether `content` satisfies the one-line constraint of `text` and
1741
2147
  * `richtext`: one `Para` line, in no container, with no islands. Judged on
@@ -1785,26 +2191,45 @@ export function isPlain(content) {
1785
2191
  }
1786
2192
 
1787
2193
  /**
1788
- * Where `bundle`'s text-moving channels (`delta`, then `islandOps`, then
1789
- * `lineOps`) leave `content`'s marks: the final-text coordinates the bundle's
1790
- * `markOps` are written in, under the rebase rule stated on `ChangeBundle`.
1791
- * The document-free read an editor diffs against to decide which `markOps` to
1792
- * emit, rather than reproducing that rule in its own language.
1793
- *
1794
- * `bundle.markOps` are ignored. The answer is normalized, as the store's is:
1795
- * marks a text move drops (out of range, zero-width formatting) are absent,
1796
- * and same-kind runs a move left adjacent arrive already unioned, so a bundle
1797
- * carrying no `markOps` names the marks the field will hold.
1798
- * Throws on a non-content `content`, a malformed bundle, or an op that applies
1799
- * out of bounds: `applyChange`'s errors on the same ops.
2194
+ * Backspace at the start of block `id`: the change joining it onto the block
2195
+ * before it, under that block's record. Throws `edit::content_apply` for the
2196
+ * first block or an id no block holds.
1800
2197
  * @param {Content} content
1801
- * @param {ChangeBundle} bundle
1802
- * @returns {ContentMark[]}
2198
+ * @param {string} id
2199
+ * @returns {Change}
2200
+ */
2201
+ export function joinBlocks(content, id) {
2202
+ try {
2203
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2204
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2205
+ const len0 = WASM_VECTOR_LEN;
2206
+ wasm.joinBlocks(retptr, addHeapObject(content), ptr0, len0);
2207
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2208
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2209
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2210
+ if (r2) {
2211
+ throw takeObject(r1);
2212
+ }
2213
+ return takeObject(r0);
2214
+ } finally {
2215
+ wasm.__wbindgen_add_to_stack_pointer(16);
2216
+ }
2217
+ }
2218
+
2219
+ /**
2220
+ * Where `pos` lands after `change`, and what around it the change deleted;
2221
+ * `assoc` (`"after"` by default) picks the side of text inserted at it.
2222
+ * Throws `edit::content_apply` where a splice deletes an island and names
2223
+ * none in `removed`, as the receipt's `applied` always does.
2224
+ * @param {Change} change
2225
+ * @param {Pos} pos
2226
+ * @param {"before" | "after"} [assoc]
2227
+ * @returns {MapResult}
1803
2228
  */
1804
- export function mapMarks(content, bundle) {
2229
+ export function mapPos(change, pos, assoc) {
1805
2230
  try {
1806
2231
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1807
- wasm.mapMarks(retptr, addHeapObject(content), addHeapObject(bundle));
2232
+ wasm.mapPos(retptr, addHeapObject(change), addHeapObject(pos), addHeapObject(assoc));
1808
2233
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1809
2234
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1810
2235
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1818,30 +2243,54 @@ export function mapMarks(content, bundle) {
1818
2243
  }
1819
2244
 
1820
2245
  /**
1821
- * Map a base content position (a USV index into `Content.text`, not a UTF-16
1822
- * offset) through a `delta` to its new position, holding a caret stable across
1823
- * a `revise`. `assoc` decides the side of a same-position insertion (`"after"`
1824
- * moves past it). Throws on a malformed `delta`.
1825
- *
1826
- * This maps a position the *caller* holds. For the marks already in a field,
1827
- * `mapMarks` applies the store's own assoc rule across every channel of a
1828
- * `ChangeBundle`.
1829
- * @param {Delta} delta
1830
- * @param {number} pos
1831
- * @param {Assoc} assoc
1832
- * @returns {number}
2246
+ * The canonical form of `rt`: the content `replace` stores from it, read
2247
+ * without a document. Normalizing rewrites structure, never the text, so the
2248
+ * answer's `text` is `rt.text`. Throws where `replace` would, with the same
2249
+ * error under this verb's name.
2250
+ * @param {Content} rt
2251
+ * @returns {Content}
1833
2252
  */
1834
- export function mapPos(delta, pos, assoc) {
2253
+ export function normalize(rt) {
1835
2254
  try {
1836
2255
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1837
- wasm.mapPos(retptr, addHeapObject(delta), pos, addHeapObject(assoc));
2256
+ wasm.normalize(retptr, addHeapObject(rt));
1838
2257
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1839
2258
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1840
2259
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1841
2260
  if (r2) {
1842
2261
  throw takeObject(r1);
1843
2262
  }
1844
- return r0 >>> 0;
2263
+ return takeObject(r0);
2264
+ } finally {
2265
+ wasm.__wbindgen_add_to_stack_pointer(16);
2266
+ }
2267
+ }
2268
+
2269
+ /**
2270
+ * Shift-Tab over the blocks `first` to `last` (`first` alone when absent):
2271
+ * the change lifting them out of the innermost item or quote holding
2272
+ * `first`. Throws `edit::content_apply` where `first` is in neither or the
2273
+ * range leaves it.
2274
+ * @param {Content} content
2275
+ * @param {string} first
2276
+ * @param {string | null} [last]
2277
+ * @returns {Change}
2278
+ */
2279
+ export function outdent(content, first, last) {
2280
+ try {
2281
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2282
+ const ptr0 = passStringToWasm0(first, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2283
+ const len0 = WASM_VECTOR_LEN;
2284
+ var ptr1 = isLikeNone(last) ? 0 : passStringToWasm0(last, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2285
+ var len1 = WASM_VECTOR_LEN;
2286
+ wasm.outdent(retptr, addHeapObject(content), ptr0, len0, ptr1, len1);
2287
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2288
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2289
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2290
+ if (r2) {
2291
+ throw takeObject(r1);
2292
+ }
2293
+ return takeObject(r0);
1845
2294
  } finally {
1846
2295
  wasm.__wbindgen_add_to_stack_pointer(16);
1847
2296
  }
@@ -1874,21 +2323,20 @@ export function parseDocPath(path) {
1874
2323
  }
1875
2324
 
1876
2325
  /**
1877
- * Rebase `markdown` onto a `base` content: the document-free twin of `revise`,
1878
- * returning the new `content`, the text `delta` (offsets are USV indices into
1879
- * `Content.text`, surviving anchors rebased), and the import's
1880
- * `parse::dropped_construct` warnings, with no `path`. Throws on an
1881
- * over-nested markdown input or a non-content `base`.
1882
- * @param {Content} base
1883
- * @param {string} markdown
1884
- * @returns {{ content: Content; delta: Delta; warnings: Diagnostic[] }}
2326
+ * Enter at `at`: the change splitting the block holding `at` there, the new
2327
+ * block `newId` and the text keeping its id. Throws `edit::content_apply`
2328
+ * where `at` is past the text.
2329
+ * @param {Content} content
2330
+ * @param {number} at
2331
+ * @param {string} newId
2332
+ * @returns {Change}
1885
2333
  */
1886
- export function rebase(base, markdown) {
2334
+ export function splitBlock(content, at, newId) {
1887
2335
  try {
1888
2336
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1889
- const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2337
+ const ptr0 = passStringToWasm0(newId, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1890
2338
  const len0 = WASM_VECTOR_LEN;
1891
- wasm.rebase(retptr, addHeapObject(base), ptr0, len0);
2339
+ wasm.splitBlock(retptr, addHeapObject(content), at, ptr0, len0);
1892
2340
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1893
2341
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1894
2342
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1909,6 +2357,36 @@ export function rebase(base, markdown) {
1909
2357
  export function start() {
1910
2358
  wasm.start();
1911
2359
  }
2360
+
2361
+ /**
2362
+ * The change wrapping the blocks `first` to `last` in a quote or a list,
2363
+ * around the children of their innermost shared item or quote that the range
2364
+ * touches; a list the range sits in is wrapped whole.
2365
+ * @param {Content} content
2366
+ * @param {string} first
2367
+ * @param {string} last
2368
+ * @param {WrapKind} kind
2369
+ * @returns {Change}
2370
+ */
2371
+ export function wrap(content, first, last, kind) {
2372
+ try {
2373
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2374
+ const ptr0 = passStringToWasm0(first, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2375
+ const len0 = WASM_VECTOR_LEN;
2376
+ const ptr1 = passStringToWasm0(last, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2377
+ const len1 = WASM_VECTOR_LEN;
2378
+ wasm.wrap(retptr, addHeapObject(content), ptr0, len0, ptr1, len1, addHeapObject(kind));
2379
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2380
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2381
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2382
+ if (r2) {
2383
+ throw takeObject(r1);
2384
+ }
2385
+ return takeObject(r0);
2386
+ } finally {
2387
+ wasm.__wbindgen_add_to_stack_pointer(16);
2388
+ }
2389
+ }
1912
2390
  function __wbg_get_imports() {
1913
2391
  const import0 = {
1914
2392
  __proto__: null,
@@ -2046,6 +2524,10 @@ function __wbg_get_imports() {
2046
2524
  const ret = Reflect.getPrototypeOf(getObject(arg0));
2047
2525
  return addHeapObject(ret);
2048
2526
  }, arguments); },
2527
+ __wbg_get_31af05bd4842a84f: function() { return handleError(function (arg0, arg1) {
2528
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
2529
+ return addHeapObject(ret);
2530
+ }, arguments); },
2049
2531
  __wbg_get_658f6698067d9515: function() { return handleError(function (arg0, arg1) {
2050
2532
  const ret = Reflect.get(getObject(arg0), getObject(arg1));
2051
2533
  return addHeapObject(ret);
@@ -2062,6 +2544,10 @@ function __wbg_get_imports() {
2062
2544
  const ret = getObject(arg0)[getObject(arg1)];
2063
2545
  return addHeapObject(ret);
2064
2546
  },
2547
+ __wbg_has_5d6706e5209576c1: function() { return handleError(function (arg0, arg1) {
2548
+ const ret = Reflect.has(getObject(arg0), getObject(arg1));
2549
+ return ret;
2550
+ }, arguments); },
2065
2551
  __wbg_instanceof_ArrayBuffer_a99f175873e5d9b8: function(arg0) {
2066
2552
  let result;
2067
2553
  try {