@betteroffice/docx 0.4.3 → 0.5.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.
Files changed (124) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +108 -598
  3. package/dist/chunk-25WGDXBF.mjs +1 -0
  4. package/dist/chunk-2CCPNW44.mjs +1 -0
  5. package/dist/chunk-32A4I3T4.mjs +1 -0
  6. package/dist/chunk-4LO3PSLZ.mjs +2 -0
  7. package/dist/chunk-67MGRMP3.mjs +1 -0
  8. package/dist/chunk-6AUR4AA2.mjs +1 -0
  9. package/dist/chunk-6WT6HKAY.mjs +1 -0
  10. package/dist/chunk-77ZWGQZN.mjs +1 -0
  11. package/dist/chunk-7C3Y7LIH.mjs +1 -0
  12. package/dist/chunk-7WIUNGQW.mjs +1 -0
  13. package/dist/chunk-7WWFGMMF.mjs +1 -0
  14. package/dist/chunk-AK2NG7PT.mjs +1 -0
  15. package/dist/chunk-BR5BFOHF.mjs +1 -0
  16. package/dist/chunk-CDNWHQH2.mjs +1 -0
  17. package/dist/chunk-CRTTEHZN.mjs +1 -0
  18. package/dist/chunk-ETDMQ5GE.mjs +1 -0
  19. package/dist/{wasm-KSZTTO3B.mjs → chunk-GBOHQ3CJ.mjs} +1 -1
  20. package/dist/chunk-H7K4SJKK.mjs +1 -0
  21. package/dist/chunk-ICJH7QUY.mjs +1 -0
  22. package/dist/chunk-IHETKRDA.mjs +1 -0
  23. package/dist/chunk-ISBZLVIF.mjs +1 -0
  24. package/dist/chunk-JSYH6HNV.mjs +2 -0
  25. package/dist/chunk-KICHSQFN.mjs +1 -0
  26. package/dist/chunk-KXIGXLFA.mjs +5 -0
  27. package/dist/chunk-KXLTK7AT.mjs +57 -0
  28. package/dist/chunk-L3JRNJ34.mjs +1 -0
  29. package/dist/chunk-LKDHP22R.mjs +1 -0
  30. package/dist/chunk-LPOEM5WH.mjs +1 -0
  31. package/dist/chunk-M44BABH2.mjs +1 -0
  32. package/dist/chunk-MAYPJU23.mjs +1 -0
  33. package/dist/chunk-N5RE2S3U.mjs +2 -0
  34. package/dist/chunk-NLYHFVF5.mjs +1 -0
  35. package/dist/chunk-ONYCW7VV.mjs +4 -0
  36. package/dist/chunk-QGZ2AB3M.mjs +1 -0
  37. package/dist/chunk-QWHU7YIW.mjs +2 -0
  38. package/dist/{chunk-VH7P4734.mjs → chunk-QX2CDKPG.mjs} +1 -1
  39. package/dist/chunk-RGDE6YQB.mjs +1 -0
  40. package/dist/chunk-TE3AU2JK.mjs +1 -0
  41. package/dist/chunk-UDVEZ722.mjs +1 -0
  42. package/dist/chunk-UQSVFDRV.mjs +2 -0
  43. package/dist/chunk-VHOOSS4D.mjs +1 -0
  44. package/dist/chunk-WIDM4EMT.mjs +1 -0
  45. package/dist/chunk-YITJ4QAO.mjs +1 -0
  46. package/dist/collaboration/index.d.mts +111 -11
  47. package/dist/collaboration/index.mjs +1 -1
  48. package/dist/{content-DSb-6a9T.d.mts → content-DVT06V_6.d.mts} +24 -3
  49. package/dist/core.d.mts +9 -9
  50. package/dist/core.mjs +1 -1
  51. package/dist/displayListQueries-6XjS7B5e.d.mts +1473 -0
  52. package/dist/docx/index.d.mts +8 -7
  53. package/dist/docx/index.mjs +1 -2
  54. package/dist/docxWorker.mjs +1 -0
  55. package/dist/editor/index.d.mts +14 -12
  56. package/dist/editor/index.mjs +1 -1
  57. package/dist/{fontLoader-BNSs0E8K.d.mts → fontLoader-CBkmh4ps.d.mts} +1 -1
  58. package/dist/{formatting-gqLFeJ9X.d.mts → formatting-p5MneNuy.d.mts} +32 -1
  59. package/dist/generated/edit/docx_edit_bg.wasm +0 -0
  60. package/dist/generated/layout/docx_layout_bg.wasm +0 -0
  61. package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
  62. package/dist/generated/parse/docx_parse_bg.wasm +0 -0
  63. package/dist/index-C-KKULi5.d.mts +5596 -0
  64. package/dist/layout/index.d.mts +4 -4
  65. package/dist/layout/index.mjs +1 -1
  66. package/dist/layout/pagination/index.d.mts +4 -4
  67. package/dist/layout/render/index.d.mts +37 -53
  68. package/dist/layout/render/index.mjs +3 -1
  69. package/dist/{pagedExport-BmSlEhoP.d.mts → pagedExport-DDgA5O7E.d.mts} +92 -9
  70. package/dist/plugin-api/RenderedDomContext.d.mts +5 -7
  71. package/dist/plugin-api/index.d.mts +3 -3
  72. package/dist/plugin-api/resolveItemPositions.d.mts +3 -3
  73. package/dist/{rezip-Bxiq4Z_R.d.mts → rezip-CfwAYdV4.d.mts} +7 -1
  74. package/dist/styles/index.d.mts +3 -3
  75. package/dist/styles/index.mjs +1 -1
  76. package/dist/{styles-AryxLAhx.d.mts → styles-DZZz2oRy.d.mts} +2 -2
  77. package/dist/types/content.d.mts +2 -2
  78. package/dist/types/document.d.mts +6 -6
  79. package/dist/{types-Cz7S77Ut.d.mts → types-bvPg3KsF.d.mts} +16 -3
  80. package/dist/utils/comments.d.mts +2 -2
  81. package/dist/utils/findReplace.mjs +1 -2
  82. package/dist/utils/index.d.mts +5 -5
  83. package/dist/utils/index.mjs +1 -1
  84. package/dist/utils/listState.d.mts +2 -5
  85. package/dist/utils/stylePreview.d.mts +2 -2
  86. package/dist/utils/stylePreview.mjs +1 -1
  87. package/dist/wasm-edit.d.mts +233 -48
  88. package/dist/wasm-edit.mjs +1 -1
  89. package/dist/wasm-layout.d.mts +7 -1
  90. package/dist/wasm-layout.mjs +1 -1
  91. package/dist/wasm-opc.mjs +1 -1
  92. package/dist/wasm-parse.d.mts +7 -1
  93. package/dist/wasm-parse.mjs +1 -1
  94. package/dist/worker.d.mts +60 -0
  95. package/dist/worker.mjs +1 -0
  96. package/dist/yrs/docxWorker.d.mts +20 -0
  97. package/dist/yrs/docxWorker.mjs +3 -0
  98. package/dist/yrs/index.d.mts +12 -7
  99. package/dist/yrs/index.mjs +1 -1
  100. package/package.json +14 -4
  101. package/dist/chunk-3RPZ44TT.mjs +0 -1
  102. package/dist/chunk-47Q2FMFF.mjs +0 -1
  103. package/dist/chunk-5Z22FORG.mjs +0 -1
  104. package/dist/chunk-7ZV6P6NZ.mjs +0 -57
  105. package/dist/chunk-AXFMDV66.mjs +0 -1
  106. package/dist/chunk-EBYC3CX7.mjs +0 -1
  107. package/dist/chunk-FK7X7557.mjs +0 -1
  108. package/dist/chunk-GKWXOZZH.mjs +0 -1
  109. package/dist/chunk-LIOWZSE7.mjs +0 -1
  110. package/dist/chunk-ML6E23W2.mjs +0 -1
  111. package/dist/chunk-MLEMGJP7.mjs +0 -1
  112. package/dist/chunk-QBMNRD5V.mjs +0 -2
  113. package/dist/chunk-SHVHVJUB.mjs +0 -1
  114. package/dist/compareDocx-URPCPAQT.mjs +0 -1
  115. package/dist/computeLayout-ZTO6TBWX.mjs +0 -1
  116. package/dist/displayListQueries-BVBDVXoP.d.mts +0 -306
  117. package/dist/frameDelta-CLeO7K5z.d.mts +0 -807
  118. package/dist/index-DzZVJC8-.d.mts +0 -2467
  119. package/dist/parseWasm-BESKFFA3.mjs +0 -1
  120. package/dist/rustDisplayList-B7uPoItK.d.mts +0 -315
  121. package/dist/wasm-JPDPN2B2.mjs +0 -1
  122. package/dist/wasm-QI7MWC5D.mjs +0 -1
  123. package/dist/yrs/residentEngineWorker.d.mts +0 -2
  124. package/dist/yrs/residentEngineWorker.mjs +0 -1
@@ -112,11 +112,8 @@ declare class EditSession {
112
112
  */
113
113
  apply_local_update(update: Uint8Array): void;
114
114
  /**
115
- * Writes `style_id` as the `pStyle` of every paragraph intersecting
116
- * `[start, end)`. Only that key changes: this boundary has no style
117
- * resolver, so it never fabricates the paragraph attributes or run marks
118
- * the style definition would imply. In suggesting mode the property
119
- * change is recorded as a `pPrChange` revision.
115
+ * Applies a paragraph style and rebases inherited character formatting, preserving direct
116
+ * formatting. Without a source package, only `pStyle` changes.
120
117
  */
121
118
  apply_paragraph_style(story: string, start_para: string, start_offset: number, end_para: string, end_offset: number, style_id: string, author_name?: string | null, author_date?: string | null): void;
122
119
  /**
@@ -146,6 +143,13 @@ declare class EditSession {
146
143
  * Applies seed raw operations with deterministic item ordering.
147
144
  */
148
145
  apply_seed_raw_ops(story: string, ops_json: string): void;
146
+ /**
147
+ * Applies the ordered updates of one sync in a single remote transaction,
148
+ * so the result matches [`EditSession::apply_update`] on the whole diff.
149
+ * Errors on a non-`Uint8Array` entry or a malformed or oversized update,
150
+ * before applying any.
151
+ */
152
+ apply_update_chunks(updates: Array<any>): void;
149
153
  /**
150
154
  * Applies a remote or incremental yrs v1 update. It commits without a
151
155
  * local origin, so this replica's undo manager never claims it. Errors on
@@ -175,6 +179,7 @@ declare class EditSession {
175
179
  * Until the matching `end_shared_reads`, committed reads share story projections of each document state.
176
180
  */
177
181
  begin_shared_reads(): void;
182
+ bootstrap_peer(state: Uint8Array, metadata: Uint8Array, source?: Uint8Array | null): void;
178
183
  /**
179
184
  * Display-only input JSON in, one binary `FrameDelta` v1 out (exposed as
180
185
  * a transferable `Uint8Array`). `expected_frame_epoch` is the epoch of the
@@ -209,6 +214,7 @@ declare class EditSession {
209
214
  * surviving nearby cell. Errors when the table itself no longer resolves.
210
215
  */
211
216
  cell_selection(): string;
217
+ clear_cell_selection(): string | undefined;
212
218
  /**
213
219
  * Removes the authored `value` from the content-control embed carrying
214
220
  * `embed_id`, leaving the control and its content in place: it never
@@ -227,6 +233,10 @@ declare class EditSession {
227
233
  * edit must pass back through the full layout path.
228
234
  */
229
235
  clear_measure_fonts(): void;
236
+ /**
237
+ * Clears the pinned input span.
238
+ */
239
+ clear_undo_input_time(): void;
230
240
  /**
231
241
  * Stops queueing and discards anything not yet drained.
232
242
  */
@@ -259,6 +269,7 @@ declare class EditSession {
259
269
  * failures throw.
260
270
  */
261
271
  compare_docx_json(original: Uint8Array, revised: Uint8Array, options: string): string;
272
+ content_control_targets_json(): string;
262
273
  /**
263
274
  * Adds a story holding one paragraph with `initial_text` (which must not
264
275
  * contain paragraph breaks), `p_style` and `alignment`. Receipt:
@@ -266,6 +277,7 @@ declare class EditSession {
266
277
  * the story id already exists.
267
278
  */
268
279
  create_story(story_id: string, initial_text: string, p_style: string, alignment: string): string;
280
+ decode_font(bytes: Uint8Array): Uint8Array;
269
281
  /**
270
282
  * Deletes every column the [`TableRange`] `range_json` covers, along with
271
283
  * the stories of the cells removed. Always a plain local edit.
@@ -275,7 +287,8 @@ declare class EditSession {
275
287
  * Deletes `[start, end)`. Because a range crossing a paragraph boundary
276
288
  * includes the boundary pilcrow, a plain delete also merges those
277
289
  * paragraphs. Suggesting mode removes nothing and stamps the content
278
- * `del` instead. Receipt: `{"revisionId": string|null}`.
290
+ * `del` instead. Receipt: `{"revisionId": string|null, "range"}`, the
291
+ * range being what the delete left.
279
292
  */
280
293
  delete_range(story: string, start_para: string, start_offset: number, end_para: string, end_offset: number, author_name?: string | null, author_date?: string | null): string;
281
294
  /**
@@ -309,6 +322,12 @@ declare class EditSession {
309
322
  * what a pointer cursor needs.
310
323
  */
311
324
  display_hit_test_regions_json(page_index: number, x: number, y: number): string;
325
+ /**
326
+ * [`EditSession::display_range_rects_region_json`] for many ranges, given as flat
327
+ * `[from, to, from, to, ...]` pairs. Per range, in order: its rect count, then
328
+ * `pageIndex, x, y, width, height` for each rect.
329
+ */
330
+ display_range_rects_batch(region: string, part_id: string, ranges: Float64Array): Float64Array;
312
331
  /**
313
332
  * Highlight rectangles for a body document range against the resident
314
333
  * display list: a JSON array of `{pageIndex,x,y,width,height}` in
@@ -316,6 +335,10 @@ declare class EditSession {
316
335
  * only. Errors when no display list is resident.
317
336
  */
318
337
  display_range_rects_json(from: number, to: number): string;
338
+ /**
339
+ * @internal
340
+ */
341
+ display_range_rects_on_pages_json(from: number, to: number, first_page: number, last_page: number): string;
319
342
  /**
320
343
  * Same rectangles as [`EditSession::display_range_rects_json`], scoped to
321
344
  * a region. `region` is `"body"`, `"header"`, `"footer"`, `"footnote"` or
@@ -336,6 +359,7 @@ declare class EditSession {
336
359
  * no display list is resident.
337
360
  */
338
361
  display_vertical_move_json(position: number, direction: string, goal_x: number): string;
362
+ document_properties_json(): string;
339
363
  /**
340
364
  * Pops the oldest queued transaction, in arrival order. Byte 0 is `1`
341
365
  * when the transaction had no local origin and `0` otherwise; the rest is
@@ -343,12 +367,40 @@ declare class EditSession {
343
367
  * started.
344
368
  */
345
369
  drain_update_event(): Uint8Array;
370
+ /**
371
+ * Typing echo model of one font at one shaping size from this session's
372
+ * resident font store: `{"horizontal","glyphIds","advances","kerning",
373
+ * "unsafePairs"}`, indexed by the characters of `alphabet`. `kern` is the
374
+ * run's kerning gate. Errors for an unknown font or a non-positive size.
375
+ */
376
+ echo_glyph_set_json(font_id: number, size: number, kern: boolean, alphabet: string): string;
377
+ /**
378
+ * A plain local text edit that the resident lowering records, so the next
379
+ * [`Self::layout_document_with_regions_after_edit`] re-lowers and
380
+ * re-measures only its paragraph: inserts `text` at the collapsed range,
381
+ * or deletes `[start, end)` without it. The document changes exactly as
382
+ * through [`Self::insert_text`] or [`Self::delete_range`] without an
383
+ * author, and the receipt is theirs. An empty insertion, an edit that
384
+ * spans paragraphs, or one whose paragraph resident input is not ready
385
+ * for goes through them instead and records nothing for the relayout.
386
+ */
387
+ edit_text_resident(story: string, start_para: string, start_offset: number, end_para: string, end_offset: number, text?: string | null): string;
388
+ /**
389
+ * [`EditSession::encode_diff`] as ordered updates for a sync that must
390
+ * travel in bounded frames: the whole diff when it fits
391
+ * `max_chunk_bytes`, otherwise causally ordered struct updates followed
392
+ * by the delete set alone. Each fits the limit except one that carries a
393
+ * single larger struct. Errors on a malformed state vector or a zero
394
+ * limit.
395
+ */
396
+ encode_diff_chunks(remote_state_vector: Uint8Array, max_chunk_bytes: number): Array<any>;
346
397
  /**
347
398
  * The yrs v1 update carrying everything this replica has that the peer
348
399
  * described by `remote_state_vector` does not. Errors on a malformed
349
400
  * state vector.
350
401
  */
351
402
  encode_diff(remote_state_vector: Uint8Array): Uint8Array;
403
+ encode_peer_metadata(): Uint8Array;
352
404
  /**
353
405
  * The full document state as one yrs v1 update. Hand it to
354
406
  * [`EditSession::load`] on a fresh replica to reproduce this document.
@@ -460,10 +512,18 @@ declare class EditSession {
460
512
  */
461
513
  format_text_target_json(target_json: string, delta_json: string): string;
462
514
  geometry_position_outline_json(root: string): string;
515
+ /**
516
+ * Whether a remote update is waiting on one that has not arrived yet.
517
+ */
518
+ has_pending_update(): boolean;
463
519
  /**
464
520
  * Whether the document has a story with this id.
465
521
  */
466
522
  has_story(story: string): boolean;
523
+ /**
524
+ * Returns active alias-to-canonical relationship ids as a JSON object.
525
+ */
526
+ header_footer_aliases_json(): string;
467
527
  /**
468
528
  * The headings of `story` in document order, classified as the structured export
469
529
  * classifies them: `[{"paraId","heading":{"outlineLevel","source"}}]`.
@@ -480,12 +540,12 @@ declare class EditSession {
480
540
  insert_column(at_json: string, after: boolean): string;
481
541
  /**
482
542
  * Inserts one inline image embed at `(story, para_id, offset)`.
483
- * `payload_json` is the image's authored payload object, stored as given.
484
543
  * The embed occupies one story unit. Receipt:
485
- * `{"revisionId": string|null}`. Errors when the payload is not an
486
- * object.
544
+ * `{"revisionId": string|null, "range"}`, the range being where the image
545
+ * landed. Errors when the payload is not an object.
487
546
  */
488
547
  insert_image(story: string, para_id: string, offset: number, payload_json: string, author_name?: string | null, author_date?: string | null): string;
548
+ insert_line_break(story: string, para_id: string, offset: number, author_name?: string | null, author_date?: string | null): string;
489
549
  /**
490
550
  * Inserts a page-break embed at `(story, para_id, offset)`, occupying one
491
551
  * story unit. Always a plain local edit.
@@ -507,13 +567,20 @@ declare class EditSession {
507
567
  * creating one story per cell. Errors when either dimension is zero.
508
568
  */
509
569
  insert_table(story: string, para_id: string, offset: number, rows: number, columns: number, author_name?: string | null, author_date?: string | null): string;
570
+ /**
571
+ * Inserts a clipboard table fragment at `(story, para_id, offset)`.
572
+ * `fragment_json` is a [`DocxTableFragment`] (`packages/docx/src/yrs/clipboardFragment.ts`).
573
+ * Returns the [`TableFragmentReceipt`] JSON, with `after` carrying the
574
+ * caret right after the inserted table embed.
575
+ */
576
+ insert_table_fragment(story: string, para_id: string, offset: number, fragment_json: string, author_name?: string | null, author_date?: string | null): string;
510
577
  /**
511
578
  * Inserts `text` at `(story, para_id, offset)`. It must contain no
512
579
  * paragraph or line breaks, and it inherits the formatting at the
513
- * insertion point. Receipt: `{"revisionId": string|null}` — non-null in
514
- * suggesting mode, where the text is stamped `ins` and coalesces into an
515
- * adjacent insertion by the same author rather than opening a second
516
- * revision.
580
+ * insertion point. Receipt: `{"revisionId": string|null, "range"}` —
581
+ * the id is non-null in suggesting mode, where the text is stamped `ins`
582
+ * and coalesces into an adjacent insertion by the same author rather than
583
+ * opening a second revision; the range is where the text landed.
517
584
  */
518
585
  insert_text(story: string, para_id: string, offset: number, text: string, author_name?: string | null, author_date?: string | null): string;
519
586
  /**
@@ -528,6 +595,19 @@ declare class EditSession {
528
595
  * Errors on unparseable input or on layout failure.
529
596
  */
530
597
  layout_document_json(input: string): string;
598
+ /**
599
+ * [`Self::layout_document_with_regions_retained`] after one edit: the
600
+ * resident path when that edit was the [`Self::edit_text_resident`] taken
601
+ * last; see `EngineSession::layout_document_with_regions_after_edit`.
602
+ */
603
+ layout_document_with_regions_after_edit(input: string): void;
604
+ /**
605
+ * The retained region layout of exactly the first `pages` pages when no
606
+ * later content can change them, and of the whole document otherwise; see
607
+ * `EngineSession::layout_document_with_regions_exact_prefix_retained`.
608
+ * Returns `{ provisional, pages, documentWidth? }` as JSON.
609
+ */
610
+ layout_document_with_regions_exact_prefix_retained(input: string, pages: number): string;
531
611
  /**
532
612
  * Region-layout input JSON in, a paginated envelope with section and page
533
613
  * regions already composed as JSON out — ready for the display builder
@@ -551,6 +631,7 @@ declare class EditSession {
551
631
  * via [`Self::retained_kernel_inputs_json`].
552
632
  */
553
633
  layout_document_with_regions_retained_json(input: string): string;
634
+ layout_document_with_regions_retained_meta(input: string): RetainedLayoutMeta;
554
635
  /**
555
636
  * Region-layout input JSON in, the font families and sizes that input
556
637
  * needs as JSON out, so the host can register fonts before laying out.
@@ -580,11 +661,15 @@ declare class EditSession {
580
661
  * empty for every structural kind, which covers no text.
581
662
  */
582
663
  list_revisions(): string;
664
+ list_sections_json(): string;
583
665
  /**
584
- * Hydrates this replica from an encoded yrs v1 update, typically another
585
- * replica's [`EditSession::encode_state`] output. Identical to
586
- * [`EditSession::apply_update`]; the separate name marks the initial-load
587
- * call site. Errors on a malformed update.
666
+ * Every story: `{"ok":true,"version","stories":[{"story","kind","parent"?,"root","part"?,
667
+ * "uses"?}]}`, sorted by id.
668
+ */
669
+ list_stories_json(): string;
670
+ /**
671
+ * Hydrates from a yrs v1 update. The first load after an unseeded open retains prior
672
+ * comment writes and marks loaded fields differing from seed placeholders as authored.
588
673
  */
589
674
  load(update: Uint8Array): void;
590
675
  /**
@@ -604,6 +689,10 @@ declare class EditSession {
604
689
  * another replica seeded them from.
605
690
  */
606
691
  load_media_sources(json: string): void;
692
+ /**
693
+ * Loads separator notes from a yrs v1 update; empty clears them.
694
+ */
695
+ load_note_separators(state: Uint8Array): void;
607
696
  /**
608
697
  * `{"start","end"}` — the paragraph's span in story-global UTF-16 units.
609
698
  * `end` is the index of its own pilcrow, so `end - start` is the
@@ -661,12 +750,26 @@ declare class EditSession {
661
750
  * which has no following paragraph to merge with.
662
751
  */
663
752
  merge_paragraphs(story: string, para_id: string, author_name?: string | null, author_date?: string | null): string;
753
+ /**
754
+ * Moves one inline embed in one local transaction.
755
+ */
756
+ move_embed(story: string, para_id: string, offset: number, to_story: string, to_para_id: string, to_offset: number): string;
664
757
  /**
665
758
  * Creates a replica. The host allocates `client_id` (a random 32-bit id
666
759
  * is fine) and must keep it unique across the replicas that will merge.
667
760
  * Errors unless it is a non-negative safe integer.
668
761
  */
669
762
  constructor(client_id: number);
763
+ /**
764
+ * The style a paragraph break at `(story, para_id, offset)` gives the new paragraph: the
765
+ * paragraph style's `w:next` when the break falls at the paragraph end and `w:next` names
766
+ * another paragraph style. `None` otherwise, and for a session without a source package.
767
+ */
768
+ next_paragraph_style(story: string, para_id: string, offset: number): string | undefined;
769
+ /**
770
+ * The separator notes for another replica; empty when the package has none.
771
+ */
772
+ note_separators_state(): Uint8Array;
670
773
  /**
671
774
  * Parses a DOCX package, optionally seeds its editable stories into this
672
775
  * replica, and retains the source bytes for
@@ -697,6 +800,7 @@ declare class EditSession {
697
800
  * refuses, which opens with [`EditSession::open_docx`] instead.
698
801
  */
699
802
  open_docx_preview(bytes: Uint8Array, blocks: number): string | undefined;
803
+ open_docx_preview_with_budget(bytes: Uint8Array, blocks: number, paragraph_budget?: number | null): string | undefined;
700
804
  /**
701
805
  * One glyph outline from this session's resident font store:
702
806
  * `{"upem":n,"cmds":[{"t":"M"|"L"|"Q"|"C"|"Z", …}]}` — commands in font
@@ -723,8 +827,9 @@ declare class EditSession {
723
827
  * `paragraphIds` request field: `{"assignments":[{"part","ordinal",
724
828
  * "paraId"}],"patchedParts":[{"part","paraIds":[[ordinal,"ID"]]}]}`,
725
829
  * plus `"splicedParts":[{"part","sha256","paragraphs":[[ordinal,"key"]],
726
- * "changed":[ordinal]}]`, whose session keys the caller resolves to the
727
- * model paragraphs it marks with their ordinals.
830
+ * "changed":[ordinal],"inserted":[{"before"|"after":ordinal}],"removed":[ordinal]}]`,
831
+ * whose session keys the caller resolves to the model paragraphs it marks
832
+ * with their ordinals.
728
833
  */
729
834
  paragraph_save_plan(): string;
730
835
  /**
@@ -735,6 +840,11 @@ declare class EditSession {
735
840
  * the boundary once per paragraph. Errors on an unknown story.
736
841
  */
737
842
  paragraph_spans(story: string): string;
843
+ /**
844
+ * The index of the first paragraph of `story` that carries `para_id`, in
845
+ * `paragraph_spans` order, or -1. Errors on an unknown story.
846
+ */
847
+ paragraph_unit(story: string, para_id: string): number;
738
848
  /**
739
849
  * `[{"paraId","text","properties"}, …]` in document order. `text` is the
740
850
  * paragraph's plain text without its pilcrow; `properties` is the
@@ -742,6 +852,7 @@ declare class EditSession {
742
852
  * else has been set on it). Errors on an unknown story.
743
853
  */
744
854
  paragraphs(story: string): string;
855
+ part_metadata_json(): string;
745
856
  /**
746
857
  * Gives every paragraph that saves without a Word paragraph ID a fresh
747
858
  * one and repairs duplicates; see [`EditingDoc::persist_paragraph_ids`].
@@ -760,6 +871,13 @@ declare class EditSession {
760
871
  * U+FFFC in `text`.
761
872
  */
762
873
  read_paragraphs_json(request: string): string;
874
+ /**
875
+ * Paragraph texts of selected stories in one read:
876
+ * `{"stories"?:"all"|[kind|id…],"byRoot"?,"view","expectVersion"?}` -> `{"ok":true,
877
+ * "version","view","truncated","stories":[{"story","ok":true,"paragraphs"}|{"story",
878
+ * "ok":false,"failure"}]}`. Listed entries keep their order; a kind expands in id order.
879
+ */
880
+ read_stories_json(request: string): string;
763
881
  /**
764
882
  * Reconciles and publishes the `[owner, paraId]` pairs a save captured,
765
883
  * an owner being a session key or a source occurrence's
@@ -798,6 +916,7 @@ declare class EditSession {
798
916
  * Release display pages; an empty result means the request was superseded.
799
917
  */
800
918
  release_display_pages_frame(pages: Uint32Array, expected_frame_epoch: number): Uint8Array;
919
+ repeat_content_control_at(story: string, index: number, remove: boolean): boolean;
801
920
  /**
802
921
  * Replaces `[start, end)` with `text` in one transaction. The inserted
803
922
  * text adopts the first replaced unit's formatting; in suggesting mode
@@ -821,6 +940,8 @@ declare class EditSession {
821
940
  * Characters the last [`EditSession::apply_delete`] removed.
822
941
  */
823
942
  resident_deleted_units(): number;
943
+ resident_geometry_json(root: string, request: string): string;
944
+ resident_section_revision(): string;
824
945
  /**
825
946
  * Where a comment's sticky anchors currently sit:
826
947
  * `[{"story","start","end"}, …]`, one entry per anchored range, in
@@ -864,11 +985,29 @@ declare class EditSession {
864
985
  * fallback after a retained-only region layout.
865
986
  */
866
987
  retained_kernel_inputs_json(): string;
988
+ retained_layout_json(): string;
989
+ /**
990
+ * Ids of the tracked changes of `story` whose range holds the caret at
991
+ * `para_id`/`offset`, in `list_revisions` order: `["id", …]`. The caret
992
+ * and both range ends resolve through their paragraph's span start as
993
+ * `locate_paragraph` gives it; a range whose paragraph does not resolve
994
+ * holds nothing. Reads only `story`, unlike `list_revisions`.
995
+ */
996
+ revision_ids_at(story: string, para_id: string, offset: number): string;
867
997
  /**
868
998
  * Author and date stamps for the requested revision ids.
869
999
  */
870
1000
  revision_stamps_json(ids_json: string): string;
1001
+ /**
1002
+ * Resolves what runs inherit under `styles_json`, a package's style definitions or `null`.
1003
+ */
1004
+ run_inheritance(styles_json: string): RunInheritance;
871
1005
  search_text(query: string, case_sensitive: boolean, limit?: number | null): string;
1006
+ section_margins_json(): string;
1007
+ /**
1008
+ * Initializes imported metadata, creating an unanchored comment when absent.
1009
+ */
1010
+ seed_comment_metadata_json(comment_id: string, patch_json: string): void;
872
1011
  /**
873
1012
  * [`EditSession::open_docx`] with seeding always on.
874
1013
  */
@@ -881,12 +1020,6 @@ declare class EditSession {
881
1020
  * Selects a story, closing capture unless manual grouping is selected.
882
1021
  */
883
1022
  select_story(story: string): void;
884
- /**
885
- * This peer's current selection as `{"anchor":{"story","paraId","offset"},
886
- * "head":{…}}`, or `"null"` before [`EditSession::set_selection`] is
887
- * called. Errors when an endpoint no longer resolves.
888
- */
889
- selection(): string;
890
1023
  /**
891
1024
  * Aggregated toolbar and accessibility state over `[start, end)`:
892
1025
  *
@@ -911,6 +1044,12 @@ declare class EditSession {
911
1044
  * pending tracked change.
912
1045
  */
913
1046
  selection_context(story: string, start_para: string, start_offset: number, end_para: string, end_offset: number): string;
1047
+ /**
1048
+ * This peer's current selection as `{"anchor":{"story","paraId","offset"},
1049
+ * "head":{…}}`, or `"null"` before [`EditSession::set_selection`] is
1050
+ * called. Errors when an endpoint no longer resolves.
1051
+ */
1052
+ selection(): string;
914
1053
  /**
915
1054
  * Accepted-view texts around a paragraph-keyed selection:
916
1055
  * `{"paraId","selectedText","paragraphText","before","after"}`, with
@@ -957,14 +1096,6 @@ declare class EditSession {
957
1096
  * Reanchors an existing comment without changing its metadata.
958
1097
  */
959
1098
  set_comment_ranges(comment_id: string, ranges_json: string): void;
960
- /**
961
- * Sets the authored `value` (any JSON) on the content-control embed
962
- * carrying `embed_id`, searching every story. A plain- or rich-text
963
- * control takes a string, which fills its content as one
964
- * version-checked batch step instead. Errors when no embed has that id
965
- * and when a fill is refused.
966
- */
967
- set_content_control_value(embed_id: string, value_json: string): void;
968
1099
  /**
969
1100
  * Sets the authored `value` on the content-control embed at
970
1101
  * `(story, para_id, offset)` — the way to reach a control with no
@@ -974,6 +1105,15 @@ declare class EditSession {
974
1105
  * position holds no embed.
975
1106
  */
976
1107
  set_content_control_value_at(story: string, para_id: string, offset: number, value_json: string): void;
1108
+ /**
1109
+ * Sets the authored `value` (any JSON) on the content-control embed
1110
+ * carrying `embed_id`, searching every story. A plain- or rich-text
1111
+ * control takes a string, which fills its content as one
1112
+ * version-checked batch step instead. Errors when no embed has that id
1113
+ * and when a fill is refused.
1114
+ */
1115
+ set_content_control_value(embed_id: string, value_json: string): void;
1116
+ set_content_control_value_index(story: string, index: number, json: string): void;
977
1117
  /**
978
1118
  * Apply admitted paragraph-local text batches directly. Off by default.
979
1119
  */
@@ -988,6 +1128,11 @@ declare class EditSession {
988
1128
  * until [`Self::build_display_pages_frame`] builds them.
989
1129
  */
990
1130
  set_display_window(start: number, end: number): void;
1131
+ set_document_property(key: string, json: string): boolean;
1132
+ /**
1133
+ * Declares header/footer alias groups before host-side seeding.
1134
+ */
1135
+ set_header_footer_aliases(json: string): void;
991
1136
  /**
992
1137
  * Sets or clears the hyperlink attribute over `[start, end)`.
993
1138
  * `hyperlink_json` is `{"href", "tooltip"?, "rId"?}` or `null` to unlink.
@@ -996,6 +1141,13 @@ declare class EditSession {
996
1141
  * `null`.
997
1142
  */
998
1143
  set_hyperlink(story: string, start_para: string, start_offset: number, end_para: string, end_offset: number, hyperlink_json: string): void;
1144
+ /**
1145
+ * [`EditSession::set_image_geometry`] for the image embed at
1146
+ * `(story, para_id, offset)` — the way to reach one of several images
1147
+ * sharing a relationship id, which the id variant resolves to the first.
1148
+ * Errors when that position holds no image.
1149
+ */
1150
+ set_image_geometry_at(story: string, para_id: string, offset: number, geometry_json: string): void;
999
1151
  /**
1000
1152
  * Writes geometry fields onto the image embed carrying `embed_id` in one
1001
1153
  * transaction. Every key of the `geometry_json` object becomes a payload
@@ -1005,13 +1157,6 @@ declare class EditSession {
1005
1157
  * has that id.
1006
1158
  */
1007
1159
  set_image_geometry(embed_id: string, geometry_json: string): void;
1008
- /**
1009
- * [`EditSession::set_image_geometry`] for the image embed at
1010
- * `(story, para_id, offset)` — the way to reach one of several images
1011
- * sharing a relationship id, which the id variant resolves to the first.
1012
- * Errors when that position holds no image.
1013
- */
1014
- set_image_geometry_at(story: string, para_id: string, offset: number, geometry_json: string): void;
1015
1160
  /**
1016
1161
  * Let an eligible resident text edit re-lower only its paragraph. Off by default.
1017
1162
  */
@@ -1047,11 +1192,13 @@ declare class EditSession {
1047
1192
  * identity such as `paraId`.
1048
1193
  */
1049
1194
  set_paragraph_attrs(story: string, start_para: string, start_offset: number, end_para: string, end_offset: number, attrs_json: string, author_name?: string | null, author_date?: string | null): void;
1195
+ set_part_metadata(json: string, remove_json: string): boolean;
1050
1196
  /**
1051
1197
  * Marks whether the session's document is part of a package, as a
1052
1198
  * replica of a preview is: its layouts render NUMPAGES empty.
1053
1199
  */
1054
1200
  set_partial_document(partial: boolean): void;
1201
+ set_section_margins(section: string, json: string): boolean;
1055
1202
  /**
1056
1203
  * Stores this peer's anchor and head as sticky positions, replacing any
1057
1204
  * previous selection. Both endpoints must lie in `story`. The positions
@@ -1060,6 +1207,7 @@ declare class EditSession {
1060
1207
  * with text inserted at it.
1061
1208
  */
1062
1209
  set_selection(story: string, anchor_para: string, anchor_offset: number, head_para: string, head_offset: number): void;
1210
+ set_table_properties(table_json: string, patch_json: string): string;
1063
1211
  /**
1064
1212
  * Sets the preferred width, in twips, of the table `table_json`
1065
1213
  * ([`TableLocator`]) names. Always a plain local edit. Errors unless
@@ -1070,13 +1218,19 @@ declare class EditSession {
1070
1218
  * Changes grouping policy while retaining undo and redo history.
1071
1219
  */
1072
1220
  set_undo_capture_mode(mode: string): void;
1221
+ /**
1222
+ * Pins the input span used to measure the next capture gap.
1223
+ */
1224
+ set_undo_input_time(first: number, last: number): void;
1073
1225
  /**
1074
1226
  * Subscribes `callback(update: Uint8Array, isRemote: 0|1)` to every
1075
1227
  * committed transaction. `update` is v1-encoded — feed it straight to
1076
1228
  * [`EditSession::apply_update`] on a peer — and is copied out of wasm
1077
1229
  * memory, so JS may hold it across later edits. The second argument is
1078
- * `1` when the transaction had no local origin. One observer per session;
1079
- * a second call replaces the first, and a throwing callback is ignored.
1230
+ * `1` when the transaction had no local origin; a remote update's own
1231
+ * formatting cleanup follows it as a `0` update to forward. One observer
1232
+ * per session; a second call replaces the first, and a throwing callback
1233
+ * is ignored.
1080
1234
  */
1081
1235
  set_update_observer(callback: Function): void;
1082
1236
  /**
@@ -1085,8 +1239,9 @@ declare class EditSession {
1085
1239
  set_windowed_incremental_builds(enabled: boolean): void;
1086
1240
  /**
1087
1241
  * Resolves tracked changes by revision id outside undo history:
1088
- * `{"accept":[string, …],"reject":[string, …]}` -> `{"revisionIds":[string, …]}`, the ids
1089
- * resolved. An id that matches nothing is skipped. See [`EditingDoc::settle_revisions`].
1242
+ * `{"accept":[string, …],"reject":[string, …]}` -> `{"ok":true,"revisionIds":[string, …]}`,
1243
+ * the ids resolved, or `{"ok":false,"version","failure"}`. An id that matches nothing is
1244
+ * skipped. See [`EditingDoc::settle_revisions`].
1090
1245
  */
1091
1246
  settle_revisions_json(request: string): string;
1092
1247
  /**
@@ -1190,21 +1345,23 @@ declare class EditSession {
1190
1345
  * not an undo step; later calls keep the history.
1191
1346
  */
1192
1347
  track_undo(): void;
1348
+ /**
1349
+ * Current undo grouping policy.
1350
+ */
1351
+ undo_capture_mode(): string;
1193
1352
  /**
1194
1353
  * Reverts the latest local-origin step and reports whether anything was
1195
1354
  * reverted. Remote and system transactions are excluded by the manager's
1196
1355
  * tracked-origin policy; `false` before tracking starts.
1197
1356
  */
1198
1357
  undo(): boolean;
1199
- /**
1200
- * Current undo grouping policy.
1201
- */
1202
- undo_capture_mode(): string;
1358
+ update_comment_metadata_json(comment_id: string, patch_json: string): void;
1203
1359
  /**
1204
1360
  * Runs every check of [`EditSession::apply_edits_json`], staging included,
1205
1361
  * without changing anything: `{"ok":true,"baseVersion","wouldApply","previews"}`.
1206
1362
  */
1207
1363
  validate_edits_json(request: string): string;
1364
+ validate_table_fragment(fragment_json: string): void;
1208
1365
  /**
1209
1366
  * The session-scoped version token of the committed document state. It
1210
1367
  * changes on every committed change, local or remote, and when the
@@ -1232,6 +1389,34 @@ declare class EditSession {
1232
1389
  yrs_blocks_for_story(story: string, env_json: string): string;
1233
1390
  }
1234
1391
 
1392
+ declare class RetainedLayoutMeta {
1393
+ private constructor();
1394
+ free(): void;
1395
+ [Symbol.dispose](): void;
1396
+ layout_shell_json(): string;
1397
+ page_sizes(): Float64Array;
1398
+ readonly notes_converged: boolean;
1399
+ readonly page_count: number;
1400
+ readonly partial: boolean;
1401
+ readonly provisional: boolean;
1402
+ }
1403
+
1404
+ /**
1405
+ * What runs inherit under one package's styles; see [`EditSession::run_inheritance`].
1406
+ */
1407
+ declare class RunInheritance {
1408
+ private constructor();
1409
+ free(): void;
1410
+ [Symbol.dispose](): void;
1411
+ /**
1412
+ * The attributes, as a JSON object, that seeding merges into the marks of a run of
1413
+ * `run_style` in a paragraph of `paragraph_style` before the run's direct formatting.
1414
+ */
1415
+ attributes(paragraph_style?: string | null, run_style?: string | null, table_run_json?: string | null): string;
1416
+ paragraph_formatting(paragraph_style: string | null | undefined, table_formatting_json: string): string;
1417
+ table_attributes(table_json: string): string;
1418
+ }
1419
+
1235
1420
  /**
1236
1421
  * Loader for the docx-edit wasm (the Rust yrs editing core + resident layout
1237
1422
  * engine). External-asset pattern — see ./loadWasmAsset.ts for the init
@@ -1 +1 @@
1
- export{e as createEditSession,b as editWasmModule,g as exportDocxMarkdownJson,f as exportDocxStructuredJson,j as findDocxContentControlsJson,i as listDocxContentControlsJson,a as preloadEditWasm,c as preloadEditWasmFrom,h as renderDocxMarkdownJson,k as renderDocxMarkdownWithPagesJson,d as setEditWasmHeapLimit}from'./chunk-SHVHVJUB.mjs';import'./chunk-HGKSOBXK.mjs';import'./chunk-TTRUPDAB.mjs';
1
+ export{e as createEditSession,b as editWasmModule,g as exportDocxMarkdownJson,f as exportDocxStructuredJson,j as findDocxContentControlsJson,i as listDocxContentControlsJson,a as preloadEditWasm,c as preloadEditWasmFrom,h as renderDocxMarkdownJson,k as renderDocxMarkdownWithPagesJson,d as setEditWasmHeapLimit}from'./chunk-CRTTEHZN.mjs';import'./chunk-HGKSOBXK.mjs';import'./chunk-TTRUPDAB.mjs';
@@ -28,11 +28,15 @@ declare function hitTestRegionsJson(displayList: string, pageIndex: number, x: n
28
28
  * positions live in different docs and are never consulted.
29
29
  */
30
30
  declare function rangeRectsJson(displayList: string, from: number, to: number): string;
31
+ /** @internal */
32
+ declare function rangeRectsOnPagesJson(displayList: string, from: number, to: number, firstPage: number, lastPage: number): string;
31
33
  /**
32
34
  * True when the embedded layout wasm carries the session-handle query exports.
33
35
  * Callers gate the handle path on this and otherwise use the JSON-arg exports.
34
36
  */
35
37
  declare function hasDisplayListSession(): boolean;
38
+ /** @internal */
39
+ declare function hasRangeRectsOnPages(): boolean;
36
40
  /**
37
41
  * True when the embedded layout wasm carries the region-aware range-rect
38
42
  * exports (`range_rects_region_json` and its by-handle twin). Callers gate
@@ -78,6 +82,8 @@ declare function verticalMoveByHandle(handle: number, position: number, directio
78
82
  * Throws when the export is absent or the handle is unknown/closed.
79
83
  */
80
84
  declare function rangeRectsByHandle(handle: number, from: number, to: number): string;
85
+ /** @internal */
86
+ declare function rangeRectsOnPagesByHandle(handle: number, from: number, to: number, firstPage: number, lastPage: number): string;
81
87
  /**
82
88
  * Region-aware highlight rects: `region` is `"body" | "header" | "footer"`,
83
89
  * and `rId` scopes a header/footer to one part (empty string for body, or to
@@ -132,4 +138,4 @@ declare function measureParagraphJson(input: string): string;
132
138
  */
133
139
  declare function outlineGlyphJson(fontId: number, glyphId: number): string;
134
140
 
135
- export { buildDisplayListJson, clearMeasureFonts, closeDisplayList, hasDisplayListSession, hasDisplayListUpdate, hasRangeRectsRegion, hitTestRegionsByHandle, hitTestRegionsJson, layoutDocumentJson, measureParagraphJson, openDisplayList, outlineGlyphJson, preloadLayoutWasm, rangeRectsByHandle, rangeRectsJson, rangeRectsRegionByHandle, rangeRectsRegionJson, registerMeasureFont, registerSubstituteMeasureFont, updateDisplayList, verticalMoveByHandle, verticalMoveJson };
141
+ export { buildDisplayListJson, clearMeasureFonts, closeDisplayList, hasDisplayListSession, hasDisplayListUpdate, hasRangeRectsOnPages, hasRangeRectsRegion, hitTestRegionsByHandle, hitTestRegionsJson, layoutDocumentJson, measureParagraphJson, openDisplayList, outlineGlyphJson, preloadLayoutWasm, rangeRectsByHandle, rangeRectsJson, rangeRectsOnPagesByHandle, rangeRectsOnPagesJson, rangeRectsRegionByHandle, rangeRectsRegionJson, registerMeasureFont, registerSubstituteMeasureFont, updateDisplayList, verticalMoveByHandle, verticalMoveJson };
@@ -1 +1 @@
1
- export{p as buildDisplayListJson,t as clearMeasureFonts,g as closeDisplayList,d as hasDisplayListSession,i as hasDisplayListUpdate,e as hasRangeRectsRegion,j as hitTestRegionsByHandle,b as hitTestRegionsJson,q as layoutDocumentJson,u as measureParagraphJson,f as openDisplayList,v as outlineGlyphJson,a as preloadLayoutWasm,m as rangeRectsByHandle,c as rangeRectsJson,o as rangeRectsRegionByHandle,n as rangeRectsRegionJson,r as registerMeasureFont,s as registerSubstituteMeasureFont,h as updateDisplayList,l as verticalMoveByHandle,k as verticalMoveJson}from'./chunk-3RPZ44TT.mjs';import'./chunk-HGKSOBXK.mjs';import'./chunk-TTRUPDAB.mjs';
1
+ export{s as buildDisplayListJson,w as clearMeasureFonts,i as closeDisplayList,e as hasDisplayListSession,k as hasDisplayListUpdate,f as hasRangeRectsOnPages,g as hasRangeRectsRegion,l as hitTestRegionsByHandle,b as hitTestRegionsJson,t as layoutDocumentJson,x as measureParagraphJson,h as openDisplayList,y as outlineGlyphJson,a as preloadLayoutWasm,o as rangeRectsByHandle,c as rangeRectsJson,p as rangeRectsOnPagesByHandle,d as rangeRectsOnPagesJson,r as rangeRectsRegionByHandle,q as rangeRectsRegionJson,u as registerMeasureFont,v as registerSubstituteMeasureFont,j as updateDisplayList,n as verticalMoveByHandle,m as verticalMoveJson}from'./chunk-WIDM4EMT.mjs';import'./chunk-HGKSOBXK.mjs';import'./chunk-TTRUPDAB.mjs';
package/dist/wasm-opc.mjs CHANGED
@@ -1 +1 @@
1
- export{a as preloadOpcWasm,c as rezipContainer,b as unzipContainer}from'./chunk-AXFMDV66.mjs';import'./chunk-HGKSOBXK.mjs';import'./chunk-TTRUPDAB.mjs';
1
+ export{a as preloadOpcWasm,c as rezipContainer,b as unzipContainer}from'./chunk-7WIUNGQW.mjs';import'./chunk-HGKSOBXK.mjs';import'./chunk-TTRUPDAB.mjs';