@betteroffice/docx 0.2.1 → 0.4.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 (91) hide show
  1. package/README.md +586 -3
  2. package/dist/chunk-24Z6ZVFZ.mjs +1 -0
  3. package/dist/chunk-2QHGQA3V.mjs +1 -0
  4. package/dist/{chunk-ACGKK7IB.mjs → chunk-3CYO46ML.mjs} +1 -1
  5. package/dist/chunk-6CHGYCFU.mjs +1 -0
  6. package/dist/chunk-AOWJ4WDE.mjs +1 -0
  7. package/dist/chunk-DLXIZBB6.mjs +1 -0
  8. package/dist/chunk-F2VBW6RB.mjs +1 -0
  9. package/dist/chunk-HPZFJGGM.mjs +0 -0
  10. package/dist/chunk-L2ML3DDI.mjs +1 -0
  11. package/dist/chunk-LIGZ75FP.mjs +1 -0
  12. package/dist/chunk-LT2GCWZ3.mjs +0 -0
  13. package/dist/chunk-ND3FBCB3.mjs +16 -0
  14. package/dist/chunk-NMDQHUQB.mjs +57 -0
  15. package/dist/chunk-NVN26RHH.mjs +1 -0
  16. package/dist/chunk-OK5UFGX3.mjs +1 -0
  17. package/dist/chunk-RZQ3OXZY.mjs +2 -0
  18. package/dist/chunk-YLFKV2NT.mjs +1 -0
  19. package/dist/collaboration/index.d.mts +9 -6
  20. package/dist/compareDocx-IHFPGIGV.mjs +1 -0
  21. package/dist/computeLayout-4MNWHE2T.mjs +1 -0
  22. package/dist/{content-CvEtPl0c.d.mts → content-BzoC6bSz.d.mts} +48 -8
  23. package/dist/core.d.mts +172 -9
  24. package/dist/core.mjs +1 -1
  25. package/dist/{displayListQueries-DF8F6fMl.d.mts → displayListQueries-H5YnU_hX.d.mts} +23 -5
  26. package/dist/docx/index.d.mts +5 -4
  27. package/dist/docx/index.mjs +1 -1
  28. package/dist/editor/index.d.mts +19 -9
  29. package/dist/editor/index.mjs +1 -1
  30. package/dist/{fontLoader-b8eicJKV.d.mts → fontLoader-BNSs0E8K.d.mts} +55 -2
  31. package/dist/{formatting-7zKCTu5a.d.mts → formatting-gqLFeJ9X.d.mts} +8 -0
  32. package/dist/{frameDelta-pA4jrQ1G.d.mts → frameDelta-ByU7HBuB.d.mts} +34 -3
  33. package/dist/generated/edit/docx_edit_bg.wasm +0 -0
  34. package/dist/generated/layout/docx_layout_bg.wasm +0 -0
  35. package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
  36. package/dist/generated/parse/docx_parse_bg.wasm +0 -0
  37. package/dist/index-CHy6_Yuo.d.mts +2026 -0
  38. package/dist/layout/index.d.mts +6 -6
  39. package/dist/layout/index.mjs +1 -1
  40. package/dist/layout/pagination/index.d.mts +4 -4
  41. package/dist/layout/render/index.d.mts +122 -33
  42. package/dist/layout/render/index.mjs +1 -1
  43. package/dist/loadWasmAsset-Cr95TImt.d.mts +25 -0
  44. package/dist/pagedExport---0Dlmzo.d.mts +907 -0
  45. package/dist/parseWasm-NLAG22EU.mjs +1 -0
  46. package/dist/plugin-api/RenderedDomContext.d.mts +12 -9
  47. package/dist/plugin-api/RenderedDomContext.mjs +1 -1
  48. package/dist/plugin-api/index.d.mts +21 -4
  49. package/dist/plugin-api/resolveItemPositions.d.mts +3 -3
  50. package/dist/rezip-Bxiq4Z_R.d.mts +24 -0
  51. package/dist/{rustDisplayList-BJqaN9tt.d.mts → rustDisplayList-LcRZHCSL.d.mts} +12 -4
  52. package/dist/{rustMeasureSource-C0EZB055.d.mts → rustMeasureSource-BkCx1FDx.d.mts} +14 -4
  53. package/dist/{selectiveSave-CRh-_Y_C.d.mts → selectiveSave-r-NMK6aI.d.mts} +1 -22
  54. package/dist/styles/index.d.mts +2 -2
  55. package/dist/{styles-7e-mq3c-.d.mts → styles-AryxLAhx.d.mts} +1 -1
  56. package/dist/types/content.d.mts +2 -2
  57. package/dist/types/document.d.mts +9 -6
  58. package/dist/{types-C4A8mWjU.d.mts → types-D6Pra38E.d.mts} +31 -5
  59. package/dist/utils/comments.d.mts +2 -2
  60. package/dist/utils/index.d.mts +20 -5
  61. package/dist/utils/index.mjs +1 -1
  62. package/dist/utils/stylePreview.d.mts +2 -2
  63. package/dist/wasm-GSI2XMOH.mjs +1 -0
  64. package/dist/wasm-K6DRABAA.mjs +1 -0
  65. package/dist/wasm-NF6B3AH7.mjs +1 -0
  66. package/dist/wasm-edit.d.mts +420 -28
  67. package/dist/wasm-edit.mjs +1 -1
  68. package/dist/wasm-layout.d.mts +9 -2
  69. package/dist/wasm-layout.mjs +1 -1
  70. package/dist/wasm-opc.d.mts +1 -1
  71. package/dist/wasm-opc.mjs +1 -1
  72. package/dist/wasm-parse.d.mts +1 -1
  73. package/dist/wasm-parse.mjs +1 -1
  74. package/dist/yrs/index.d.mts +8 -5
  75. package/dist/yrs/index.mjs +1 -1
  76. package/dist/yrs/residentEngineWorker.mjs +1 -1
  77. package/package.json +2 -2
  78. package/dist/chunk-5F6DLQZP.mjs +0 -1
  79. package/dist/chunk-6LQJAKOC.mjs +0 -1
  80. package/dist/chunk-AFMVSI4Z.mjs +0 -57
  81. package/dist/chunk-GD4VNJ64.mjs +0 -1
  82. package/dist/chunk-HLDJMU3R.mjs +0 -1
  83. package/dist/chunk-J7LNO6SM.mjs +0 -1
  84. package/dist/chunk-JHJLG4I6.mjs +0 -16
  85. package/dist/chunk-PGMXWI5X.mjs +0 -1
  86. package/dist/chunk-WRWRCBLK.mjs +0 -1
  87. package/dist/chunk-WTFRNX5K.mjs +0 -1
  88. package/dist/index-CHl2zLJ7.d.mts +0 -1142
  89. package/dist/loadWasmAsset-CMvnVkfA.d.mts +0 -3
  90. package/dist/wasm-7SOSHNGP.mjs +0 -1
  91. package/dist/wasm-ZQAVP7P2.mjs +0 -1
@@ -1,4 +1,4 @@
1
- import { W as WasmAsyncInput } from './loadWasmAsset-CMvnVkfA.mjs';
1
+ import { W as WasmAsyncInput } from './loadWasmAsset-Cr95TImt.mjs';
2
2
 
3
3
  /* tslint:disable */
4
4
  /* eslint-disable */
@@ -40,23 +40,38 @@ declare class EditSession {
40
40
  */
41
41
  add_comment(ranges_json: string, author: string, date: string, body_json: string): string;
42
42
  /**
43
- * Deletes one character at this session's collapsed selection and returns
44
- * the resulting binary `FrameDelta`. `direction` is `"backward"` or
45
- * `"forward"`; a surrogate pair is removed whole. At a paragraph boundary
46
- * this merges with the neighbouring paragraph instead.
43
+ * Closes the current undo capture without adding an empty step.
44
+ */
45
+ add_undo_boundary(): void;
46
+ /**
47
+ * Deletes up to `count` characters at this session's collapsed selection,
48
+ * lays out once, and returns the resulting binary `FrameDelta`.
49
+ * `direction` is `"backward"` or `"forward"`; a surrogate pair is removed
50
+ * whole. At a paragraph boundary a deletion merges with the neighbouring
51
+ * paragraph instead. Deleting stops early at the document start or end,
52
+ * before a second paragraph merge, or at a paragraph the resident state
53
+ * cannot absorb; [`EditSession::resident_deleted_units`] reports how many
54
+ * were removed.
47
55
  *
48
- * Errors on an unknown `direction`, when `expected_frame_epoch` is not a
49
- * non-negative safe integer, under the same selection and readiness
50
- * conditions as [`EditSession::apply_input`], and when there is no
51
- * character to delete in that direction (document start or end).
56
+ * Errors on an unknown `direction`, a zero `count`, when
57
+ * `expected_frame_epoch` is not a non-negative safe integer, under the
58
+ * same selection and readiness conditions as [`EditSession::apply_input`],
59
+ * and when there is no character to delete in that direction.
52
60
  */
53
- apply_delete(direction: string, expected_frame_epoch: number): Uint8Array;
61
+ apply_delete(direction: string, expected_frame_epoch: number, count: number): Uint8Array;
54
62
  /**
55
63
  * Instrumented twin of [`EditSession::apply_delete`]: identical arguments,
56
64
  * result and error contract, but it also records stage timings for
57
65
  * [`EditSession::apply_input_profile_json`].
58
66
  */
59
- apply_delete_profiled(direction: string, expected_frame_epoch: number): Uint8Array;
67
+ apply_delete_profiled(direction: string, expected_frame_epoch: number, count: number): Uint8Array;
68
+ /**
69
+ * Applies an edit batch all-or-nothing:
70
+ * `{"ok":true,"baseVersion","version","applied","source","changedStories",
71
+ * "receipts"}`. An applied batch commits one transaction; `history`
72
+ * `"separate"` makes it exactly one undo step.
73
+ */
74
+ apply_edits_json(request: string): string;
60
75
  /**
61
76
  * Applies one ordinary insertion at this session's collapsed selection
62
77
  * and returns the resulting binary `FrameDelta`. The inserted text
@@ -141,11 +156,26 @@ declare class EditSession {
141
156
  * Errors on a malformed update.
142
157
  */
143
158
  apply_update_with_inference(update: Uint8Array): string;
159
+ /**
160
+ * Starts a new opening of the document; see [`EditingDoc::begin_opening`].
161
+ */
162
+ begin_opening(generation?: string | null): void;
163
+ /**
164
+ * Begins `layout_document_with_regions_retained_json` as a pass measured a
165
+ * step at a time; see `EngineSession::begin_region_layout`. Returns the
166
+ * progress JSON, with `layoutJson` once the pass is complete.
167
+ */
168
+ begin_region_layout(input: string): string;
169
+ /**
170
+ * Until the matching `end_shared_reads`, committed reads share story projections of each document state.
171
+ */
172
+ begin_shared_reads(): void;
144
173
  /**
145
174
  * Display-only input JSON in, one binary `FrameDelta` v1 out (exposed as
146
175
  * a transferable `Uint8Array`). `expected_frame_epoch` is the epoch of the
147
176
  * frame the caller currently holds; pass `0` for the first frame. A
148
- * mismatch makes the engine emit a full frame instead of a delta. Errors
177
+ * mismatch makes the engine emit a full frame instead of a delta, and the
178
+ * returned frame's epoch is always greater than `expected_frame_epoch`. Errors
149
179
  * unless the epoch is a non-negative safe integer, and on build failure.
150
180
  */
151
181
  build_display_list_frame(input: string, expected_frame_epoch: number): Uint8Array;
@@ -154,6 +184,12 @@ declare class EditSession {
154
184
  * against the same resident font store this session measures with.
155
185
  */
156
186
  build_display_list_json(input: string): string;
187
+ /**
188
+ * Build the listed pages that are still unbuilt and return a FrameDelta
189
+ * v1 carrying them; `expected_frame_epoch` works as for
190
+ * [`Self::build_display_list_frame`].
191
+ */
192
+ build_display_pages_frame(pages: Uint32Array, expected_frame_epoch: number): Uint8Array;
157
193
  /**
158
194
  * Whether [`EditSession::redo`] would reapply something.
159
195
  */
@@ -170,8 +206,8 @@ declare class EditSession {
170
206
  cell_selection(): string;
171
207
  /**
172
208
  * Removes the authored `value` from the content-control embed carrying
173
- * `embed_id`, leaving the control itself in place. Errors when no embed
174
- * has that id.
209
+ * `embed_id`, leaving the control and its content in place: it never
210
+ * erases a text control's text. Errors when no embed has that id.
175
211
  */
176
212
  clear_content_control_value(embed_id: string): void;
177
213
  /**
@@ -198,6 +234,26 @@ declare class EditSession {
198
234
  * This replica's client id, as passed to the constructor.
199
235
  */
200
236
  client_id(): number;
237
+ /**
238
+ * Resolves a text target and anchors a side-map comment over it in one
239
+ * call (legacy agent helpers). `comment_json`:
240
+ * `{"id","author","date","body"?}`. Returns `{"ok":true,"version"}` or a
241
+ * refusal.
242
+ */
243
+ comment_text_target_json(target_json: string, comment_json: string): string;
244
+ /**
245
+ * Compares two DOCX packages into this session, which must hold no document: the original
246
+ * is opened here and the revised body text differences are applied as tracked changes,
247
+ * outside undo history.
248
+ *
249
+ * `options` is `{"author","date","granularity"?,"unsupported"?,"limits"?}`. Returns a final
250
+ * `{"ok":false,"diagnostics"}` or `{"ok":true,"noop":true,"changes":[],"diagnostics"}`, or
251
+ * `{"ok":true,"noop":false,"save"}` naming what a save of the applied changes may write:
252
+ * then pass the saved bytes to [`EditSession::finish_compared_docx_json`], or the save
253
+ * failure to [`EditSession::fail_compared_docx_json`]. Malformed options and internal
254
+ * failures throw.
255
+ */
256
+ compare_docx_json(original: Uint8Array, revised: Uint8Array, options: string): string;
201
257
  /**
202
258
  * Adds a story holding one paragraph with `initial_text` (which must not
203
259
  * contain paragraph breaks), `p_style` and `alignment`. Receipt:
@@ -308,6 +364,62 @@ declare class EditSession {
308
364
  * with [`EditSession::resolve_encoded_selection`].
309
365
  */
310
366
  encoded_selection(): string;
367
+ /**
368
+ * Ends a shared-read scope, dropping shared story projections when the last scope ends.
369
+ */
370
+ end_shared_reads(): void;
371
+ /**
372
+ * [`EditSession::export_structured_json`] rendered as Markdown from the same read:
373
+ * `{"ok":true,"version","content":{"markdown","anchors","diagnostics","truncated"}}`.
374
+ */
375
+ export_markdown_json(options: string): string;
376
+ /**
377
+ * Lays this private session out with its own fonts and exports it with pages as a
378
+ * snapshot. `fonts` holds the font files back to back, `font_lengths` their byte lengths;
379
+ * `request` is a region layout request whose font chains name fonts by their index. The
380
+ * reply is `{"ok":true,"content"}` or `{"ok":false,"failure"}`; a rejected font or an
381
+ * unusable request throws. The session's measurement fonts are left untouched.
382
+ */
383
+ export_snapshot_with_private_fonts_json(fonts: Uint8Array, font_lengths: Uint32Array, request: string, options: string): string;
384
+ /**
385
+ * Structured export of the committed document state:
386
+ * `{"revisionView","stories"?,"includeFormatting"?,"maxBlocks"?,"maxBytes"?}` ->
387
+ * `{"ok":true,"version","content"}` or `{"ok":false,"version","failure"}`. Anchors are scoped
388
+ * to the returned version. Reads only: nothing is committed, minted or published.
389
+ */
390
+ export_structured_json(options: string): string;
391
+ /**
392
+ * [`EditSession::export_structured_json`] with the page map of the retained region
393
+ * layout. `options` adds `"includeGeometry"?`, `"expectLayoutVersion"?`,
394
+ * `"maxFragments"?` and `"maxLayoutBytes"?`; the reply is
395
+ * `{"ok":true,"version","content":{"structured","layout"}}` or a refusal. An editor passes
396
+ * the region layout request it would lay the document out with now as `current_request`,
397
+ * and the layout must have been computed from the same inputs. Lays nothing out and changes
398
+ * nothing.
399
+ */
400
+ export_structured_with_pages_json(options: string, current_request?: string | null): string;
401
+ /**
402
+ * The final comparison result when saving the applied changes failed with `message`.
403
+ */
404
+ fail_compared_docx_json(message: string): string;
405
+ /**
406
+ * [`EditSession::list_content_controls_json`] keeping the controls that match `query`
407
+ * (`{"kind":"id","controlId"}`, `{"kind":"tag","tag"}`, `{"kind":"ooxmlId","ooxmlId"}` or
408
+ * `{"kind":"alias","alias"}`) exactly.
409
+ */
410
+ find_content_controls_json(query: string, options: string): string;
411
+ /**
412
+ * Exact, case-sensitive, paragraph-local search:
413
+ * `{"text","within","view","limit"?}` ->
414
+ * `{"ok":true,"version","matches":[{"text","range"}],"truncated"}`.
415
+ */
416
+ find_text_json(request: string): string;
417
+ /**
418
+ * The final comparison result for `bytes`, the saved applied changes, verified against both
419
+ * inputs: `{"ok":true,"changes","diagnostics"}` or `{"ok":false,"diagnostics"}`. Throws
420
+ * when no comparison awaits its saved bytes.
421
+ */
422
+ finish_compared_docx_json(bytes: Uint8Array): string;
311
423
  /**
312
424
  * Applies a set-valued, tri-state inline formatting delta over
313
425
  * `[start, end)` in one transaction. An omitted key keeps the current
@@ -332,6 +444,21 @@ declare class EditSession {
332
444
  * there is no receipt. Errors when a key carries a type not listed here.
333
445
  */
334
446
  format_range(story: string, start_para: string, start_offset: number, end_para: string, end_offset: number, delta_json: string): void;
447
+ /**
448
+ * Resolves a text target and formats it in one call (legacy agent
449
+ * helpers). `delta_json` is the [`EditSession::format_range`] delta.
450
+ * Returns `{"ok":true,"version"}` or a refusal.
451
+ */
452
+ format_text_target_json(target_json: string, delta_json: string): string;
453
+ /**
454
+ * Whether the document has a story with this id.
455
+ */
456
+ has_story(story: string): boolean;
457
+ /**
458
+ * The headings of `story` in document order, classified as the structured export
459
+ * classifies them: `[{"paraId","heading":{"outlineLevel","source"}}]`.
460
+ */
461
+ headings_json(story: string): string;
335
462
  /**
336
463
  * Stories changed by the latest undo or redo, sorted.
337
464
  */
@@ -397,6 +524,16 @@ declare class EditSession {
397
524
  * with no host-side layout mutation. Retains the pass for resident edits.
398
525
  */
399
526
  layout_document_with_regions_json(input: string): string;
527
+ /**
528
+ * The retained region layout of the first `pages` pages only; see
529
+ * `EngineSession::layout_document_with_regions_prefix_retained_json`.
530
+ */
531
+ layout_document_with_regions_prefix_retained_json(input: string, pages: number): string;
532
+ /**
533
+ * [`Self::layout_document_with_regions_retained_json`] without the reply,
534
+ * for a caller that reads only the retained state.
535
+ */
536
+ layout_document_with_regions_retained(input: string): void;
400
537
  /**
401
538
  * Same full region pass as [`Self::layout_document_with_regions_json`],
402
539
  * but the reply carries only `{ layout, headersFooters?, notesConverged }`
@@ -409,6 +546,19 @@ declare class EditSession {
409
546
  * needs as JSON out, so the host can register fonts before laying out.
410
547
  */
411
548
  layout_font_requirements_json(input: string): string;
549
+ /**
550
+ * Every comment the session holds, sorted by id:
551
+ * `[{"id","author","date","done","parentId","body"}, …]`, `parentId`
552
+ * null for a top-level comment and `body` the JSON value it was given.
553
+ */
554
+ list_comments(): string;
555
+ /**
556
+ * The content controls of the committed state:
557
+ * `{"stories"?,"maxControls"?,"maxBytes"?}` -> `{"ok":true,"version","content"}` or
558
+ * `{"ok":false,"version","failure"}`. Control ids and anchors are scoped to the returned
559
+ * version. Reads only.
560
+ */
561
+ list_content_controls_json(options: string): string;
412
562
  /**
413
563
  * Every pending tracked change across all stories, in deterministic
414
564
  * story-then-position order:
@@ -434,9 +584,16 @@ declare class EditSession {
434
584
  * text must not contain paragraph breaks. Receipt:
435
585
  * `{storyId: [paraId, …]}` with each story's paragraphs in document
436
586
  * order. Errors when a story entry has no `storyId`, no `paragraphs`
437
- * array, or an empty one, and when a story id already exists.
587
+ * array, or an empty one, and when a story id already exists. Seeding a
588
+ * document that has no opening yet starts one; see
589
+ * [`EditingDoc::begin_opening`].
438
590
  */
439
591
  load_json(stories_json: string): string;
592
+ /**
593
+ * Lays this replica's `data:` image sources out as the `media:{n}` tokens
594
+ * another replica seeded them from.
595
+ */
596
+ load_media_sources(json: string): void;
440
597
  /**
441
598
  * `{"start","end"}` — the paragraph's span in story-global UTF-16 units.
442
599
  * `end` is the index of its own pilcrow, so `end - start` is the
@@ -458,6 +615,26 @@ declare class EditSession {
458
615
  * the engine's message for input it cannot measure.
459
616
  */
460
617
  measure_paragraph_json(input: string): string;
618
+ /**
619
+ * The bytes a `media:{n}` image source displays, as the part's
620
+ * [`EditSession::media_type`]; `undefined` for any other source or a
621
+ * part that cannot be read.
622
+ */
623
+ media_bytes(token: string): Uint8Array | undefined;
624
+ /**
625
+ * The `data:` URL a `media:{n}` image source stands for.
626
+ */
627
+ media_data_url(token: string): string | undefined;
628
+ /**
629
+ * The digests mapping the `data:` URLs this replica seeded to
630
+ * `media:{n}` tokens, for [`EditSession::load_media_sources`]; empty
631
+ * when it seeded none.
632
+ */
633
+ media_sources_json(): string;
634
+ /**
635
+ * The media type of [`EditSession::media_bytes`].
636
+ */
637
+ media_type(token: string): string | undefined;
461
638
  /**
462
639
  * Merges the rectangle the [`TableRange`] `range_json` covers into its
463
640
  * top-left cell, whose story survives; the other cells' stories are
@@ -483,17 +660,33 @@ declare class EditSession {
483
660
  /**
484
661
  * Parses a DOCX package, optionally seeds its editable stories into this
485
662
  * replica, and retains the source bytes for
486
- * [`EditSession::materialize_docx`].
663
+ * [`EditSession::materialize_docx`] and paragraph identity reads.
664
+ * Seeding starts a new opening, with `generation` or a fresh one, so its
665
+ * session anchors are its own; see [`EditingDoc::begin_opening`].
487
666
  *
488
- * Returns `{"envelope","referencedFonts":[string, …]}`. The envelope is
667
+ * Returns `{"envelope","referencedFonts":[string, …],"unusedScriptFonts":[string, …]}`:
668
+ * `unusedScriptFonts` are the referenced fonts a seeded package names only
669
+ * for East Asian or complex-script text it does not contain. The envelope is
489
670
  * the parsed package with the parts the host does not need stripped —
490
671
  * body content, header/footer and note content, numbering, media and
491
672
  * charts are emptied, section entries keep only their properties — so
492
673
  * styles, theme, settings, fonts and relationships still cross while the
493
674
  * bulk of the document stays in Rust. Errors on bytes that are not a
494
675
  * readable DOCX.
676
+ * `digest`, when given, must be the SHA-256 of `bytes` in lowercase hex,
677
+ * as a host that hashed them off this thread already knows it.
495
678
  */
496
- open_docx(bytes: Uint8Array, seed_stories: boolean): string;
679
+ open_docx(bytes: Uint8Array, seed_stories: boolean, generation?: string | null, digest?: string | null): string;
680
+ /**
681
+ * Opens `bytes` for display only, seeded from the body's first `blocks`
682
+ * blocks (see `seed::seed_docx_preview`): the reply is the host metadata
683
+ * of that parse, as [`EditSession::open_docx`] replies, with the
684
+ * `unusedScriptFonts` of its cut. The session keeps no source package, so
685
+ * it cannot save.
686
+ * Opens nothing and replies with nothing for a document the preview
687
+ * refuses, which opens with [`EditSession::open_docx`] instead.
688
+ */
689
+ open_docx_preview(bytes: Uint8Array, blocks: number): string | undefined;
497
690
  /**
498
691
  * One glyph outline from this session's resident font store:
499
692
  * `{"upem":n,"cmds":[{"t":"M"|"L"|"Q"|"C"|"Z", …}]}` — commands in font
@@ -502,6 +695,20 @@ declare class EditSession {
502
695
  * Errors when the glyph cannot be extracted.
503
696
  */
504
697
  outline_glyph_json(font_id: number, glyph_id: number): string;
698
+ /**
699
+ * Every paragraph's identities: `{"sessionId","packageSha256",
700
+ * "paragraphs":[{"session","origin","ooxmlParaId","idOrigin",
701
+ * "persisted","source"}]}`, session paragraphs with stories sorted and
702
+ * in document order, then source paragraphs outside the stories, whose
703
+ * `session` is `null`. Reads only.
704
+ */
705
+ paragraph_identities(): string;
706
+ /**
707
+ * The paragraph IDs a save applies, as the package writer's
708
+ * `paragraphIds` request field: `{"assignments":[{"part","ordinal",
709
+ * "paraId"}],"patchedParts":[{"part","paraIds":[[ordinal,"ID"]]}]}`.
710
+ */
711
+ paragraph_save_plan(): string;
505
712
  /**
506
713
  * Compact paragraph-position projection built in one story traversal:
507
714
  * `[{"paraId","length"}, …]` in document order, where `length` counts the
@@ -517,6 +724,30 @@ declare class EditSession {
517
724
  * else has been set on it). Errors on an unknown story.
518
725
  */
519
726
  paragraphs(story: string): string;
727
+ /**
728
+ * Gives every paragraph that saves without a Word paragraph ID a fresh
729
+ * one and repairs duplicates; see [`EditingDoc::persist_paragraph_ids`].
730
+ * Receipt: `{"status":"applied","assignments":[{"paragraph",
731
+ * "replacedParaId","previousOoxmlParaId","ooxmlParaId","idOrigin",
732
+ * "persisted"}],"diagnostics":[…]}`, or `{"status":"refused","refusal"}`
733
+ * when nothing was changed.
734
+ */
735
+ persist_paragraph_ids(): string;
736
+ /**
737
+ * Versioned paragraph texts:
738
+ * `{"story"?,"paraIds"?,"view":"accepted"|"original"}` ->
739
+ * `{"ok":true,"version","view","paragraphs":[{"story","paraId","text",
740
+ * "styleId"?,"atoms":[{"offset","kind"}]}]}`. Each inline atom occupies one
741
+ * U+FFFC in `text`.
742
+ */
743
+ read_paragraphs_json(request: string): string;
744
+ /**
745
+ * Reconciles and publishes the `[owner, paraId]` pairs a save captured,
746
+ * an owner being a session key or a source occurrence's
747
+ * `{partUri}#{ordinal}`; returns the stale pairs as the same JSON shape.
748
+ * See [`EditingDoc::record_saved_paragraph_ids`].
749
+ */
750
+ record_saved_paragraph_ids(saved_json: string): string;
520
751
  /**
521
752
  * Reapplies the latest locally undone transaction and reports whether
522
753
  * anything was reapplied.
@@ -528,6 +759,13 @@ declare class EditSession {
528
759
  * Errors on bytes the font parser rejects.
529
760
  */
530
761
  register_measure_font(bytes: Uint8Array): number;
762
+ /**
763
+ * Registers a measurement view of `base` carrying the vertical metrics
764
+ * and advance pitch Word measures `requested_family` with — for a face
765
+ * this host had to substitute. Returns `base` for a family whose metrics
766
+ * are unknown.
767
+ */
768
+ register_substitute_measure_font(base: number, requested_family: string): number;
531
769
  /**
532
770
  * Rejects tracked changes — the inverse of
533
771
  * [`EditSession::accept_change`]: pending insertions roll back, pending
@@ -541,9 +779,14 @@ declare class EditSession {
541
779
  * Replaces `[start, end)` with `text` in one transaction. The inserted
542
780
  * text adopts the first replaced unit's formatting; in suggesting mode
543
781
  * the deletion and the insertion share one revision id. Receipt:
544
- * `{"revisionId": string|null}`.
782
+ * `{"revisionId": string|null, "range": {"story", "start": {"paraId", "offset"}, "end": {"paraId", "offset"}}}`.
545
783
  */
546
784
  replace_range(story: string, start_para: string, start_offset: number, end_para: string, end_offset: number, text: string, author_name?: string | null, author_date?: string | null): string;
785
+ /**
786
+ * Makes the next display frame a full one whatever epoch its caller
787
+ * passes, for a host that switches to this engine from another.
788
+ */
789
+ reset_frame_base(): void;
547
790
  /**
548
791
  * `{"frameEpoch", "caretRect": {…}|null}` for the session's own collapsed
549
792
  * body selection. `caretRect` is null whenever there is no selection, the
@@ -551,6 +794,10 @@ declare class EditSession {
551
794
  * geometry for it. `frameEpoch` identifies the frame the rect belongs to.
552
795
  */
553
796
  resident_caret_snapshot_json(): string;
797
+ /**
798
+ * Characters the last [`EditSession::apply_delete`] removed.
799
+ */
800
+ resident_deleted_units(): number;
554
801
  /**
555
802
  * Where a comment's sticky anchors currently sit:
556
803
  * `[{"story","start","end"}, …]`, one entry per anchored range, in
@@ -564,24 +811,47 @@ declare class EditSession {
564
811
  * Errors on malformed bytes or an endpoint that no longer resolves.
565
812
  */
566
813
  resolve_encoded_selection(story: string, anchor: Uint8Array, head: Uint8Array): string;
814
+ /**
815
+ * Resolves a `session`, `source` or `persisted` anchor JSON against the
816
+ * current state: `{"status":"found","anchor"}`, `{"status":"missing"}`,
817
+ * `{"status":"ambiguous","candidates"}` or `{"status":"unsupported",
818
+ * "reason"}` with a `foreign-session`, `foreign-package` or
819
+ * `no-source-package` reason. A found source paragraph outside the
820
+ * session stories comes back as its source anchor. Errors on a malformed
821
+ * anchor.
822
+ */
823
+ resolve_paragraph_anchor(anchor_json: string): string;
567
824
  /**
568
825
  * Resolves sticky bytes from [`EditSession::encode_sticky_position`] back
569
826
  * to `{"story","paraId","offset"}`. Errors when the bytes are malformed
570
827
  * or the position no longer resolves in `story`.
571
828
  */
572
829
  resolve_sticky_position(story: string, position: Uint8Array): string;
830
+ /**
831
+ * Measures up to `blocks` more body blocks of the begun pass; see
832
+ * `EngineSession::resume_region_layout`.
833
+ */
834
+ resume_region_layout(blocks: number): string;
835
+ /**
836
+ * The retained region layout's `headersFooters` JSON, when it has any.
837
+ */
838
+ retained_headers_footers_json(): string | undefined;
573
839
  /**
574
840
  * Retained `{ measured, options }` for the main-thread display-list
575
841
  * fallback after a retained-only region layout.
576
842
  */
577
843
  retained_kernel_inputs_json(): string;
844
+ search_text(query: string, case_sensitive: boolean, limit?: number | null): string;
578
845
  /**
579
846
  * [`EditSession::open_docx`] with seeding always on.
580
847
  */
581
- seed_from_docx(bytes: Uint8Array): string;
848
+ seed_from_docx(bytes: Uint8Array, generation?: string | null): string;
849
+ /**
850
+ * Unions seeded opaque sequence names into document state.
851
+ */
852
+ seed_opaque_sequences(names_json: string): void;
582
853
  /**
583
- * Notes the story a direct operation is about to edit; a different story
584
- * than the previous edit or caret closes the current undo step.
854
+ * Selects a story, closing capture unless manual grouping is selected.
585
855
  */
586
856
  select_story(story: string): void;
587
857
  /**
@@ -596,7 +866,9 @@ declare class EditSession {
596
866
  * ```json
597
867
  * {
598
868
  * "bold": true | false | "mixed", "italic": …, "underline": …, "strike": …,
869
+ * "superscript": …, "subscript": …,
599
870
  * "fontFamily": string|null, "fontSize": number|null, "color": string|null,
871
+ * "highlight": string|null,
600
872
  * "paraId": string, "styleId": string|null, "alignment": string|null,
601
873
  * "paragraphProperties": {…},
602
874
  * "hasSelection": bool, "isMultiParagraph": bool, "inTable": bool,
@@ -612,6 +884,12 @@ declare class EditSession {
612
884
  * pending tracked change.
613
885
  */
614
886
  selection_context(story: string, start_para: string, start_offset: number, end_para: string, end_offset: number): string;
887
+ /**
888
+ * Accepted-view texts around a paragraph-keyed selection:
889
+ * `{"paraId","selectedText","paragraphText","before","after"}`, with
890
+ * `\n` between paragraphs and U+FFFC for each inline atom.
891
+ */
892
+ selection_text_json(story: string, start_para: string, start_offset: number, end_para: string, end_offset: number): string;
615
893
  /**
616
894
  * Merges the sides of the JSON object `borders_json` into every selected
617
895
  * cell's `tcPr.borders`; `insideH`/`insideV` resolve to the physical edges
@@ -648,20 +926,37 @@ declare class EditSession {
648
926
  * `width_twips` is finite and positive.
649
927
  */
650
928
  set_column_width(at_json: string, width_twips: number): string;
929
+ /**
930
+ * Reanchors an existing comment without changing its metadata.
931
+ */
932
+ set_comment_ranges(comment_id: string, ranges_json: string): void;
651
933
  /**
652
934
  * Sets the authored `value` (any JSON) on the content-control embed
653
- * carrying `embed_id`, searching every story. Errors when no embed has
654
- * that id.
935
+ * carrying `embed_id`, searching every story. A plain- or rich-text
936
+ * control takes a string, which fills its content as one
937
+ * version-checked batch step instead. Errors when no embed has that id
938
+ * and when a fill is refused.
655
939
  */
656
940
  set_content_control_value(embed_id: string, value_json: string): void;
657
941
  /**
658
942
  * Sets the authored `value` on the content-control embed at
659
943
  * `(story, para_id, offset)` — the way to reach a control with no
660
944
  * authored `w:id` or tag, which
661
- * [`EditSession::set_content_control_value`] cannot address. Errors when
662
- * that position holds no embed.
945
+ * [`EditSession::set_content_control_value`] cannot address. A text
946
+ * control's string value fills it as that method does. Errors when that
947
+ * position holds no embed.
663
948
  */
664
949
  set_content_control_value_at(story: string, para_id: string, offset: number, value_json: string): void;
950
+ /**
951
+ * Keep every previously built page while windowed builds are on.
952
+ */
953
+ set_display_retain_built_pages(retain: boolean): void;
954
+ /**
955
+ * Limit full display builds to pages `start..end` plus the pages already
956
+ * built; the others stay unbuilt placeholders carrying their geometry
957
+ * until [`Self::build_display_pages_frame`] builds them.
958
+ */
959
+ set_display_window(start: number, end: number): void;
665
960
  /**
666
961
  * Sets or clears the hyperlink attribute over `[start, end)`.
667
962
  * `hyperlink_json` is `{"href", "tooltip"?, "rId"?}` or `null` to unlink.
@@ -679,6 +974,19 @@ declare class EditSession {
679
974
  * has that id.
680
975
  */
681
976
  set_image_geometry(embed_id: string, geometry_json: string): void;
977
+ /**
978
+ * [`EditSession::set_image_geometry`] for the image embed at
979
+ * `(story, para_id, offset)` — the way to reach one of several images
980
+ * sharing a relationship id, which the id variant resolves to the first.
981
+ * Errors when that position holds no image.
982
+ */
983
+ set_image_geometry_at(story: string, para_id: string, offset: number, geometry_json: string): void;
984
+ /**
985
+ * Whether [`EditSession::open_docx`] seeds images as `media:{n}` tokens,
986
+ * which only a replica opened from the same package resolves, instead of
987
+ * `data:` URLs. Off by default.
988
+ */
989
+ set_media_tokens(enabled: boolean): void;
682
990
  /**
683
991
  * Sets one paragraph property to any JSON value on `para_id`'s pilcrow,
684
992
  * searching every story. Unlike
@@ -704,6 +1012,11 @@ declare class EditSession {
704
1012
  * identity such as `paraId`.
705
1013
  */
706
1014
  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;
1015
+ /**
1016
+ * Marks whether the session's document is part of a package, as a
1017
+ * replica of a preview is: its layouts render NUMPAGES empty.
1018
+ */
1019
+ set_partial_document(partial: boolean): void;
707
1020
  /**
708
1021
  * Stores this peer's anchor and head as sticky positions, replacing any
709
1022
  * previous selection. Both endpoints must lie in `story`. The positions
@@ -718,6 +1031,10 @@ declare class EditSession {
718
1031
  * `width_twips` is finite and positive.
719
1032
  */
720
1033
  set_table_width(table_json: string, width_twips: number): string;
1034
+ /**
1035
+ * Changes grouping policy while retaining undo and redo history.
1036
+ */
1037
+ set_undo_capture_mode(mode: string): void;
721
1038
  /**
722
1039
  * Subscribes `callback(update: Uint8Array, isRemote: 0|1)` to every
723
1040
  * committed transaction. `update` is v1-encoded — feed it straight to
@@ -727,6 +1044,16 @@ declare class EditSession {
727
1044
  * a second call replaces the first, and a throwing callback is ignored.
728
1045
  */
729
1046
  set_update_observer(callback: Function): void;
1047
+ /**
1048
+ * Limit incremental rebuilds to the display window and caret pages. Off by default.
1049
+ */
1050
+ set_windowed_incremental_builds(enabled: boolean): void;
1051
+ /**
1052
+ * Resolves tracked changes by revision id outside undo history:
1053
+ * `{"accept":[string, …],"reject":[string, …]}` -> `{"revisionIds":[string, …]}`, the ids
1054
+ * resolved. An id that matches nothing is skipped. See [`EditingDoc::settle_revisions`].
1055
+ */
1056
+ settle_revisions_json(request: string): string;
730
1057
  /**
731
1058
  * Splits the cell `at_json` ([`CellLoc`]) covers into a `rows` x
732
1059
  * `columns` grid; the original story stays in the top-left slot and every
@@ -752,6 +1079,11 @@ declare class EditSession {
752
1079
  * callback. Idempotent while observation is running.
753
1080
  */
754
1081
  start_update_event_observation(): void;
1082
+ /**
1083
+ * `{"revision","stories":[…]}`: the current story revision and the sorted
1084
+ * ids of the stories created, edited, or deleted after revision `since`.
1085
+ */
1086
+ stories_changed_since(since: number): string;
755
1087
  /**
756
1088
  * The story's `canonical-stream-v1` FNV-1a checksum (see
757
1089
  * [`crate::canonical`]) as a DECIMAL STRING, because a u64 exceeds the
@@ -770,6 +1102,22 @@ declare class EditSession {
770
1102
  * as one. Errors on an unknown story.
771
1103
  */
772
1104
  story_len(story: string): number;
1105
+ /**
1106
+ * The Word paragraph ID each paragraph of `story` saves with, as a JSON
1107
+ * array of strings or `null` in document order. Errors on an unknown story.
1108
+ */
1109
+ story_paragraph_ids(story: string): string;
1110
+ /**
1111
+ * `story_segments` split after each pilcrow into units, as one hex digest
1112
+ * per unit: `["digest", …]`. Equal digests mean equal segments.
1113
+ */
1114
+ story_segment_unit_digests(story: string): string;
1115
+ /**
1116
+ * The segments of the listed units (indices into
1117
+ * `story_segment_unit_digests`), each as `story_segments` gives them:
1118
+ * `[[segment, …], …]`. Errors on an index past the last unit.
1119
+ */
1120
+ story_segment_units(story: string, units: Uint32Array): string;
773
1121
  /**
774
1122
  * The story as an ordered run of formatted segments — the same view
775
1123
  * lowering reads:
@@ -784,6 +1132,12 @@ declare class EditSession {
784
1132
  * tracked-change stamps. Errors on an unknown story.
785
1133
  */
786
1134
  story_segments(story: string): string;
1135
+ /**
1136
+ * The `payload` of the story's `table_index`-th table embed, as
1137
+ * `story_segments` gives it, or `None` when the story has no such
1138
+ * table. Errors on an unknown story.
1139
+ */
1140
+ table_payload(story: string, table_index: number): string | undefined;
787
1141
  /**
788
1142
  * Applies one run mark over `[start, end)`. `mark_json`:
789
1143
  * `{"type":"bold"|"italic"|"underline"|"strike"|"superscript"|"subscript"} |
@@ -807,6 +1161,26 @@ declare class EditSession {
807
1161
  * tracked-origin policy; `false` before tracking starts.
808
1162
  */
809
1163
  undo(): boolean;
1164
+ /**
1165
+ * Current undo grouping policy.
1166
+ */
1167
+ undo_capture_mode(): string;
1168
+ /**
1169
+ * Runs every check of [`EditSession::apply_edits_json`], staging included,
1170
+ * without changing anything: `{"ok":true,"baseVersion","wouldApply","previews"}`.
1171
+ */
1172
+ validate_edits_json(request: string): string;
1173
+ /**
1174
+ * The session-scoped version token of the committed document state. It
1175
+ * changes on every committed change, local or remote, and when the
1176
+ * document or its retained source is replaced.
1177
+ */
1178
+ version(): string;
1179
+ /**
1180
+ * The Word paragraph IDs a DOCX package holds, as JSON mapping each XML
1181
+ * part URI to its paragraphs' IDs in document order, in canonical form.
1182
+ */
1183
+ written_paragraph_ids(bytes: Uint8Array): string;
810
1184
  /**
811
1185
  * Lowers one story to a `LayoutBlock[]` JSON array — the block, run and
812
1186
  * table vocabulary the layout engine consumes. `env_json` supplies the
@@ -814,7 +1188,8 @@ declare class EditSession {
814
1188
  * `{"themeColors":{slot: hex},"defaultTabStopTwips":number|null,
815
1189
  * "pageContentHeight":number|null,"numericIds":{yrsId: number},
816
1190
  * "tocStyleIds":[styleId],"showHiddenText":bool,
817
- * "defaultParagraphStyleId":string}`, all
1191
+ * "defaultParagraphStyleId":string,
1192
+ * "revisionPreview":{revisionId: "accepted"|"rejected"}}`, all
818
1193
  * optional. Errors when the story does not end in a pilcrow, holds a
819
1194
  * malformed table, references itself through a cell story, or contains an
820
1195
  * embed lowering does not support.
@@ -836,11 +1211,28 @@ declare class EditSession {
836
1211
 
837
1212
  /** Load + instantiate the editing-core wasm (browser path). Idempotent. */
838
1213
  declare function preloadEditWasm(input?: WasmAsyncInput): Promise<void>;
1214
+ /**
1215
+ * Caps the bytes the editing core in this thread may allocate at once; an
1216
+ * allocation past the cap fails as if the memory were full. Undefined removes it.
1217
+ */
1218
+ declare function setEditWasmHeapLimit(bytes: number | undefined): void;
839
1219
  /**
840
1220
  * Constructs a raw wasm `EditSession` replica after ensuring the module is
841
1221
  * initialized. The `src/yrs/` facade wraps this in the typed `YrsSession`
842
1222
  * surface — nothing else should call it.
843
1223
  */
844
1224
  declare function createEditSession(clientId: number): EditSession;
1225
+ /** Structured export of DOCX bytes: `{ok: true, content}` or `{ok: false, failure}` JSON. */
1226
+ declare function exportDocxStructuredJson(bytes: Uint8Array, options: string): string;
1227
+ /** {@link exportDocxStructuredJson} rendered as Markdown. */
1228
+ declare function exportDocxMarkdownJson(bytes: Uint8Array, options: string): string;
1229
+ /** Markdown rendering of structured content JSON. */
1230
+ declare function renderDocxMarkdownJson(content: string, options: string): string;
1231
+ /** Content controls of DOCX bytes: `{ok: true, content}` or `{ok: false, failure}` JSON. */
1232
+ declare function listDocxContentControlsJson(bytes: Uint8Array, options: string): string;
1233
+ /** The content controls of DOCX bytes matching a query, as {@link listDocxContentControlsJson}. */
1234
+ declare function findDocxContentControlsJson(bytes: Uint8Array, query: string, options: string): string;
1235
+ /** Markdown rendering of a paged export's JSON, with optional page markers. */
1236
+ declare function renderDocxMarkdownWithPagesJson(content: string, options: string): string;
845
1237
 
846
- export { EditSession, createEditSession, preloadEditWasm };
1238
+ export { EditSession, createEditSession, exportDocxMarkdownJson, exportDocxStructuredJson, findDocxContentControlsJson, listDocxContentControlsJson, preloadEditWasm, renderDocxMarkdownJson, renderDocxMarkdownWithPagesJson, setEditWasmHeapLimit };