@betteroffice/docx 0.0.3 → 0.1.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 (73) hide show
  1. package/README.md +22 -8
  2. package/dist/chunk-24DL53QL.mjs +1 -0
  3. package/dist/chunk-5F6DLQZP.mjs +1 -0
  4. package/dist/chunk-BUZ2X5CT.mjs +16 -0
  5. package/dist/chunk-CTBUQRYQ.mjs +1 -0
  6. package/dist/{chunk-B4IR6YP4.mjs → chunk-GHEHBYQK.mjs} +1 -1
  7. package/dist/{chunk-NJHOPXZW.mjs → chunk-HLDJMU3R.mjs} +1 -1
  8. package/dist/chunk-HTDNSQ44.mjs +1 -0
  9. package/dist/{chunk-IFT6DUJX.mjs → chunk-LTVVQMHB.mjs} +1 -1
  10. package/dist/chunk-PI2I3TO5.mjs +57 -0
  11. package/dist/chunk-TMHG7OAZ.mjs +1 -0
  12. package/dist/chunk-VRGUAKOC.mjs +1 -0
  13. package/dist/collaboration/index.d.mts +32 -8
  14. package/dist/collaboration/index.mjs +1 -1
  15. package/dist/{content-MOZ6hKP4.d.mts → content-DrqzbIr7.d.mts} +582 -666
  16. package/dist/core.d.mts +7 -7
  17. package/dist/core.mjs +1 -1
  18. package/dist/{displayListQueries-BJlo7Jkz.d.mts → displayListQueries-DGDR-OWc.d.mts} +98 -50
  19. package/dist/docx/index.d.mts +5 -5
  20. package/dist/docx/index.mjs +1 -1
  21. package/dist/editor/index.d.mts +8 -8
  22. package/dist/{fontLoader-aSewHMKF.d.mts → fontLoader-DnixuYST.d.mts} +127 -2
  23. package/dist/{formatting-D1EPSaJP.d.mts → formatting-BqrFPeev.d.mts} +85 -203
  24. package/dist/{frameDelta-D965X8yK.d.mts → frameDelta-DMgR8n13.d.mts} +17 -10
  25. package/dist/generated/edit/docx_edit_bg.wasm +0 -0
  26. package/dist/generated/layout/docx_layout_bg.wasm +0 -0
  27. package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
  28. package/dist/generated/parse/docx_parse_bg.wasm +0 -0
  29. package/dist/{index-Dx4Z3lkz.d.mts → index-ImoMd0Ju.d.mts} +97 -67
  30. package/dist/layout/index.d.mts +40 -12
  31. package/dist/layout/index.mjs +1 -1
  32. package/dist/layout/pagination/index.d.mts +4 -4
  33. package/dist/layout/pagination/index.mjs +1 -1
  34. package/dist/layout/render/index.d.mts +33 -77
  35. package/dist/layout/render/index.mjs +1 -1
  36. package/dist/plugin-api/RenderedDomContext.d.mts +7 -7
  37. package/dist/plugin-api/index.d.mts +3 -3
  38. package/dist/plugin-api/resolveItemPositions.d.mts +3 -3
  39. package/dist/{rustDisplayList-BRuZBqdL.d.mts → rustDisplayList-B9dQoLHI.d.mts} +79 -50
  40. package/dist/{rustMeasureSource-D1KsQvVC.d.mts → rustMeasureSource-C0EZB055.d.mts} +5 -2
  41. package/dist/{selectiveSave-CVoajSKE.d.mts → selectiveSave-CRh-_Y_C.d.mts} +3 -3
  42. package/dist/styles/index.d.mts +3 -3
  43. package/dist/{styles-Dn_o3Vo5.d.mts → styles-CMybYYHS.d.mts} +1 -1
  44. package/dist/types/content.d.mts +2 -2
  45. package/dist/types/document.d.mts +7 -7
  46. package/dist/{types-BfqUl2h_.d.mts → types-CXLxVF1t.d.mts} +27 -23
  47. package/dist/utils/comments.d.mts +2 -2
  48. package/dist/utils/index.d.mts +11 -13
  49. package/dist/utils/index.mjs +1 -1
  50. package/dist/utils/stylePreview.d.mts +2 -2
  51. package/dist/utils/units.d.mts +4 -34
  52. package/dist/utils/units.mjs +1 -1
  53. package/dist/wasm-CJHQHBDE.mjs +1 -0
  54. package/dist/wasm-T2CRCO7S.mjs +1 -0
  55. package/dist/wasm-edit.d.mts +524 -168
  56. package/dist/wasm-edit.mjs +1 -1
  57. package/dist/wasm-layout.d.mts +35 -28
  58. package/dist/wasm-layout.mjs +1 -1
  59. package/dist/wasm-opc.mjs +1 -1
  60. package/dist/wasm-parse.mjs +1 -1
  61. package/dist/yrs/index.d.mts +6 -6
  62. package/dist/yrs/index.mjs +1 -1
  63. package/dist/yrs/residentEngineWorker.mjs +1 -1
  64. package/package.json +19 -3
  65. package/dist/chunk-3UBMCDME.mjs +0 -1
  66. package/dist/chunk-AEQOEQJ7.mjs +0 -57
  67. package/dist/chunk-AZ52IWB6.mjs +0 -16
  68. package/dist/chunk-GGEGIQRK.mjs +0 -1
  69. package/dist/chunk-T4EZMUXM.mjs +0 -1
  70. package/dist/chunk-WON6K4FY.mjs +0 -1
  71. package/dist/chunk-Y7RUNRU2.mjs +0 -1
  72. package/dist/wasm-DO3BUV7C.mjs +0 -1
  73. package/dist/wasm-NWXX4H5G.mjs +0 -1
@@ -13,45 +13,76 @@ declare class EditSession {
13
13
  free(): void;
14
14
  [Symbol.dispose](): void;
15
15
  /**
16
- * Accepts tracked changes (S4b): pending insertions become plain content,
17
- * pending deletions are carried out; `pPrIns` marks clear (the split
18
- * stays), `pPrDel` marks join with the following paragraph (its pPr
19
- * survives). `target_json`: `{"revisionId": string}` for one coalesced
20
- * revision (any story) or
21
- * `{"story","startPara","startOffset","endPara","endOffset"}` for a Loc
22
- * range. Receipt: `{"revisionIds": [string, …]}` — the revision ids
23
- * resolved. Resolving never stamps a new revision.
16
+ * Accepts tracked changes: pending insertions become plain content,
17
+ * pending deletions are carried out; `pPrIns` marks clear so the split
18
+ * stays, `pPrDel` marks join with the following paragraph, whose own
19
+ * properties survive.
20
+ *
21
+ * `target_json` is either `{"revisionId": string}`, resolving that one
22
+ * coalesced revision wherever it appears in any story, or
23
+ * `{"story","startPara","startOffset","endPara","endOffset"}`, resolving
24
+ * every tracked change overlapping that range regardless of revision id.
25
+ * Receipt: `{"revisionIds": [string, …]}` — the ids actually resolved, in
26
+ * resolution order and deduplicated. Resolving applies a revision rather
27
+ * than authoring one, so it never stamps a new revision and ignores
28
+ * suggesting mode. Errors on an empty range and on a `revisionId` that
29
+ * matches nothing.
24
30
  */
25
31
  accept_change(target_json: string): string;
26
32
  /**
27
- * Adds a sticky-anchored comment. `ranges_json`:
33
+ * Adds a comment anchored to one or more ranges. `ranges_json`:
28
34
  * `[{"story","startPara","startOffset","endPara","endOffset"}, …]`;
29
- * `body_json` is any JSON value. Receipt: `{"commentId"}`.
35
+ * `body_json` is any JSON value, stored as given. The anchors are sticky,
36
+ * so they follow the text they cover, and the comment lives outside the
37
+ * story rather than as an attribute on it. Receipt: `{"commentId"}` — a
38
+ * freshly minted id. Errors when `ranges_json` is not an array of
39
+ * well-formed ranges, or is empty.
30
40
  */
31
41
  add_comment(ranges_json: string, author: string, date: string, body_json: string): string;
32
42
  /**
33
- * Apply one ordinary collapsed character deletion (or adjacent paragraph
34
- * merge at a boundary) and return the resulting resident FrameDelta.
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.
47
+ *
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).
35
52
  */
36
53
  apply_delete(direction: string, expected_frame_epoch: number): Uint8Array;
37
54
  /**
38
- * Instrumented twin of `apply_delete`, used only by opt-in browser perf
39
- * traces. Keeping this separate leaves the production hot path timer-free.
55
+ * Instrumented twin of [`EditSession::apply_delete`]: identical arguments,
56
+ * result and error contract, but it also records stage timings for
57
+ * [`EditSession::apply_input_profile_json`].
40
58
  */
41
59
  apply_delete_profiled(direction: string, expected_frame_epoch: number): Uint8Array;
42
60
  /**
43
- * Apply one ordinary collapsed body-text insertion and return the
44
- * resulting FrameDelta. Selection, measurement inputs, pagination
45
- * checkpoints, and display state all remain resident in this session.
61
+ * Applies one ordinary insertion at this session's collapsed selection
62
+ * and returns the resulting binary `FrameDelta`. The inserted text
63
+ * inherits the formatting at the caret; selection, measurement inputs,
64
+ * pagination checkpoints and display state all stay resident, so nothing
65
+ * but the frame crosses the boundary.
66
+ *
67
+ * Errors when `text` is empty or contains `\r`/`\n`, when
68
+ * `expected_frame_epoch` is not a non-negative safe integer, when there is
69
+ * no resident selection or it no longer resolves, when the selection is
70
+ * not collapsed, or when the resident layout state cannot absorb an edit
71
+ * in that paragraph. The caller must then run the full layout path.
46
72
  */
47
73
  apply_input(text: string, expected_frame_epoch: number): Uint8Array;
48
74
  /**
49
- * Last opt-in `apply_input_profiled` stage timings as a compact JSON object.
75
+ * Stage timings of the last profiled apply, in milliseconds:
76
+ * `{"selectionMs","editMs","lowerMs","measureMs","paginateMs",
77
+ * "displayInputMs","displayBuildMs","displayFinalizeMs","displayMs",
78
+ * "encodeMs"}`. `{}` before the first profiled call.
50
79
  */
51
80
  apply_input_profile_json(): string;
52
81
  /**
53
- * Instrumented twin of `apply_input`, used only by opt-in browser perf
54
- * traces. Keeping this separate leaves the production hot path timer-free.
82
+ * Instrumented twin of [`EditSession::apply_input`]: identical arguments,
83
+ * result and error contract, but it also records stage timings for
84
+ * [`EditSession::apply_input_profile_json`]. Separate so the ordinary
85
+ * input path pays no timer calls.
55
86
  */
56
87
  apply_input_profiled(text: string, expected_frame_epoch: number): Uint8Array;
57
88
  /**
@@ -61,221 +92,419 @@ declare class EditSession {
61
92
  */
62
93
  apply_local_update(update: Uint8Array): void;
63
94
  /**
64
- * Applies a paragraph style id to every paragraph intersecting
65
- * `[start, end)`. With no host style resolver at this boundary, this is
66
- * the PM fallback path: write `pStyle` without fabricating a resolved
67
- * paragraph/run formatting projection.
95
+ * Writes `style_id` as the `pStyle` of every paragraph intersecting
96
+ * `[start, end)`. Only that key changes: this boundary has no style
97
+ * resolver, so it never fabricates the paragraph attributes or run marks
98
+ * the style definition would imply. In suggesting mode the property
99
+ * change is recorded as a `pPrChange` revision.
68
100
  */
69
101
  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;
70
102
  /**
71
- * Applies a batch of raw story mutations in ONE transaction — the
72
- * coexistence bridge's mirror-into-yrs path (not a user-intent op). `ops_json`
73
- * is `[{ "op":"insert"|"delete"|"format"|"insertEmbed"|"setEmbedAttr"
74
- * |"setComment"|"removeComment", "index", … }, …]`; each op's index (and each
75
- * `setComment` `[start, end)` range) is read against the story state after all
76
- * prior ops in the batch. Attributes/payloads are faithful mirrors of the
77
- * bridge's lowered PM state (tracked-change stamps arrive inside `attrs`;
78
- * comments are keyed by the PM comment id and anchored sticky, side-map only).
103
+ * Applies a batch of raw story mutations in ONE transaction. Unlike every
104
+ * other op here these carry no user intent: indices are story-global
105
+ * UTF-16 units, not Locs, and nothing is inferred or stamped on the
106
+ * caller's behalf. `ops_json` is an array of:
107
+ *
108
+ * - `{"op":"insert","index","text"?,"attrs"?}`
109
+ * - `{"op":"delete","index","len"}`
110
+ * - `{"op":"format","index","len","attrs"?}`
111
+ * - `{"op":"insertEmbed","index","kind"?,"payload"?,"attrs"?}`
112
+ * - `{"op":"setEmbedAttr","index","key","value"?}`
113
+ * - `{"op":"setComment","id","ranges":[[start,end], …],"author"?,"date"?,"body"?}`
114
+ * - `{"op":"removeComment","id"}`
115
+ *
116
+ * Each op's `index`, and each `setComment` range, is read against the
117
+ * story state AFTER every preceding op in the batch. `attrs` and
118
+ * `payload` are JSON objects written verbatim, so tracked-change stamps
119
+ * travel inside `attrs`; comments are keyed by the given id and anchored
120
+ * sticky. Errors on an unknown `"op"`, a missing or negative `"index"`,
121
+ * or a missing required field, and leaves the story untouched — parsing
122
+ * completes before the transaction opens.
79
123
  */
80
124
  apply_raw_ops(story: string, ops_json: string): void;
81
125
  /**
82
- * Applies a remote/incremental yrs v1 update.
126
+ * Applies a remote or incremental yrs v1 update. It commits without a
127
+ * local origin, so this replica's undo manager never claims it. Errors on
128
+ * a malformed update.
83
129
  */
84
130
  apply_update(update: Uint8Array): void;
85
131
  /**
86
- * Binary FrameDelta v1 display output. The returned `Vec<u8>` is exposed
87
- * by wasm-bindgen as a transferable-friendly `Uint8Array`.
132
+ * [`EditSession::apply_update`] plus an inference about where the peer
133
+ * that authored it is typing, for caret presence. Returns
134
+ * `{"clientId","story","paraId","endOffset"}` for the end of that peer's
135
+ * last text insertion, or `"null"` when the update carries work from more
136
+ * than one client, ends in a non-text insertion, or inserts nothing.
137
+ * Errors on a malformed update.
138
+ */
139
+ apply_update_with_inference(update: Uint8Array): string;
140
+ /**
141
+ * Display-only input JSON in, one binary `FrameDelta` v1 out (exposed as
142
+ * a transferable `Uint8Array`). `expected_frame_epoch` is the epoch of the
143
+ * frame the caller currently holds; pass `0` for the first frame. A
144
+ * mismatch makes the engine emit a full frame instead of a delta. Errors
145
+ * unless the epoch is a non-negative safe integer, and on build failure.
88
146
  */
89
147
  build_display_list_frame(input: string, expected_frame_epoch: number): Uint8Array;
90
148
  /**
91
- * Build display primitives against the same resident font store used by
92
- * this session's measurement path.
149
+ * `{ measured, options, layout }` JSON in, `DisplayList` JSON out, built
150
+ * against the same resident font store this session measures with.
93
151
  */
94
152
  build_display_list_json(input: string): string;
153
+ /**
154
+ * Whether [`EditSession::redo`] would reapply something.
155
+ */
95
156
  can_redo(): boolean;
157
+ /**
158
+ * Whether [`EditSession::undo`] would revert something.
159
+ */
96
160
  can_undo(): boolean;
97
161
  /**
98
- * Resolves the current local cell selection, or `null` before the host
99
- * establishes one. Deleted endpoints clamp to a surviving nearby cell.
162
+ * The current local cell selection as a [`TableRange`], or `"null"`
163
+ * before one is set. An endpoint whose cell was deleted clamps to a
164
+ * surviving nearby cell. Errors when the table itself no longer resolves.
100
165
  */
101
166
  cell_selection(): string;
102
167
  /**
103
- * Clears the authored `value` from a stable-id content-control embed.
168
+ * Removes the authored `value` from the content-control embed carrying
169
+ * `embed_id`, leaving the control itself in place. Errors when no embed
170
+ * has that id.
104
171
  */
105
172
  clear_content_control_value(embed_id: string): void;
106
173
  /**
107
- * Clears every direct formatting attribute over `[start, end)`, while
108
- * retaining hyperlinks and tracked-change stamps.
174
+ * Clears every direct run-formatting attribute over `[start, end)`.
175
+ * Protected attributes — hyperlinks and tracked-change stamps — survive,
176
+ * as do paragraph properties.
109
177
  */
110
178
  clear_formatting(story: string, start_para: string, start_offset: number, end_para: string, end_offset: number): void;
111
179
  /**
112
- * Clear this editing wasm's resident measurement fonts.
180
+ * Drops every registered measurement font (ids restart at zero) and
181
+ * invalidates the retained paragraph measurement templates, so the next
182
+ * edit must pass back through the full layout path.
113
183
  */
114
184
  clear_measure_fonts(): void;
185
+ /**
186
+ * Stops queueing and discards anything not yet drained.
187
+ */
115
188
  clear_update_event_observation(): void;
116
189
  /**
117
190
  * Drops the update observer registered by [`EditSession::set_update_observer`].
118
191
  */
119
192
  clear_update_observer(): void;
193
+ /**
194
+ * This replica's client id, as passed to the constructor.
195
+ */
120
196
  client_id(): number;
121
197
  /**
122
- * Adds a story with one paragraph. Receipt: `{"paraId"}` (the final
123
- * pilcrow's paragraph).
198
+ * Adds a story holding one paragraph with `initial_text` (which must not
199
+ * contain paragraph breaks), `p_style` and `alignment`. Receipt:
200
+ * `{"paraId"}` — the paragraph ending at the story's pilcrow. Errors when
201
+ * the story id already exists.
124
202
  */
125
203
  create_story(story_id: string, initial_text: string, p_style: string, alignment: string): string;
126
204
  /**
127
- * Deletes every column covered by an explicit cell range.
205
+ * Deletes every column the [`TableRange`] `range_json` covers, along with
206
+ * the stories of the cells removed. Always a plain local edit.
128
207
  */
129
208
  delete_column(range_json: string): string;
130
209
  /**
131
- * Deletes `[start, end)` given as two Locs in one story. A range whose
132
- * ends sit in different paragraphs spans the boundary pilcrows, so the
133
- * plain delete also merges (the pilcrow-as-character dividend).
134
- * Suggesting mode retains the content with a `del` revision instead.
135
- * Receipt: `{"revisionId": string|null}`.
210
+ * Deletes `[start, end)`. Because a range crossing a paragraph boundary
211
+ * includes the boundary pilcrow, a plain delete also merges those
212
+ * paragraphs. Suggesting mode removes nothing and stamps the content
213
+ * `del` instead. Receipt: `{"revisionId": string|null}`.
136
214
  */
137
215
  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;
138
216
  /**
139
- * Deletes every row covered by an explicit cell range.
217
+ * Deletes every row the [`TableRange`] `range_json` covers. In suggesting
218
+ * mode the rows are marked `trDel` instead of removed.
140
219
  */
141
220
  delete_row(range_json: string, author_name?: string | null, author_date?: string | null): string;
142
221
  /**
143
- * Removes one complete story (used for unreachable table-cell stories).
222
+ * Removes one complete story and its content. Errors on an unknown story.
144
223
  */
145
224
  delete_story(story_id: string): void;
146
225
  /**
147
- * Removes one complete table plus all of its reachable cell stories.
226
+ * Removes the table `table_json` ([`TableLocator`]) names plus every one
227
+ * of its reachable cell stories. Always a plain local edit; the receipt
228
+ * has `deletedTable: true`.
148
229
  */
149
230
  delete_table(table_json: string): string;
150
231
  /**
151
- * Hit-test without re-serializing the resident display list through JS.
232
+ * Region-aware hit test against the resident display list, so no
233
+ * display-list JSON crosses the boundary. `x`/`y` are page-local px.
234
+ * Returns
235
+ * `{"region":"body"|"header"|"footer"|"footnote"|"endnote","rId"?,`
236
+ * `"noteId"?,"pos":n|null,"target":"text"|"image"|"none"}`, or `"null"`
237
+ * for a page index outside the frame. A header/footer `pos` refers to
238
+ * that part's own document and a note `pos` to the `fn:{id}` / `en:{id}`
239
+ * story, never the body; `target` is what sits under the point, which is
240
+ * what a pointer cursor needs.
152
241
  */
153
242
  display_hit_test_regions_json(page_index: number, x: number, y: number): string;
154
243
  /**
155
- * Body range geometry without a display-list JSON round trip.
244
+ * Highlight rectangles for a body document range against the resident
245
+ * display list: a JSON array of `{pageIndex,x,y,width,height}` in
246
+ * page-local px, one entry per page the range touches. Body positions
247
+ * only. Errors when no display list is resident.
156
248
  */
157
249
  display_range_rects_json(from: number, to: number): string;
158
250
  /**
159
- * Region-scoped range geometry without a display-list JSON round trip.
251
+ * Same rectangles as [`EditSession::display_range_rects_json`], scoped to
252
+ * a region. `region` is `"body"`, `"header"`, `"footer"`, `"footnote"` or
253
+ * `"endnote"`; `part_id` names one header/footer part (an empty string
254
+ * matches any) or the note whose story the positions belong to.
255
+ * `from`/`to` are positions in THAT region's document, and a
256
+ * header/footer part paints on every page carrying it, so the result
257
+ * holds one rect set per such page, each tagged with its `pageIndex`.
258
+ * Errors on an unknown `region` and when no display list is resident.
259
+ */
260
+ display_range_rects_region_json(region: string, part_id: string, from: number, to: number): string;
261
+ /**
262
+ * Nearest caret position on the adjacent visual line. `direction` is
263
+ * `"up"` or `"down"`; `goal_x` is the page-local x the caret is trying to
264
+ * hold across successive moves (a non-finite value falls back to the
265
+ * caret's own x). Returns `{"position","goalX"}`, or `"null"` when there
266
+ * is no line in that direction. Errors on an unknown `direction` and when
267
+ * no display list is resident.
268
+ */
269
+ display_vertical_move_json(position: number, direction: string, goal_x: number): string;
270
+ /**
271
+ * Pops the oldest queued transaction, in arrival order. Byte 0 is `1`
272
+ * when the transaction had no local origin and `0` otherwise; the rest is
273
+ * the v1 update. Empty when the queue is drained or observation never
274
+ * started.
160
275
  */
161
- display_range_rects_region_json(region: string, r_id: string, from: number, to: number): string;
162
276
  drain_update_event(): Uint8Array;
277
+ /**
278
+ * The yrs v1 update carrying everything this replica has that the peer
279
+ * described by `remote_state_vector` does not. Errors on a malformed
280
+ * state vector.
281
+ */
163
282
  encode_diff(remote_state_vector: Uint8Array): Uint8Array;
164
283
  /**
165
- * Full document state as one yrs v1 update (Yjs wire format).
284
+ * The full document state as one yrs v1 update. Hand it to
285
+ * [`EditSession::load`] on a fresh replica to reproduce this document.
166
286
  */
167
287
  encode_state(): Uint8Array;
288
+ /**
289
+ * This replica's yrs v1 state vector — what a peer sends so
290
+ * [`EditSession::encode_diff`] can compute the update it is missing.
291
+ */
168
292
  encode_state_vector(): Uint8Array;
293
+ /**
294
+ * Encodes one Loc as opaque sticky-position bytes that keep pointing at
295
+ * the same content as the story is edited. Publish them over an awareness
296
+ * transport and resolve them with
297
+ * [`EditSession::resolve_sticky_position`].
298
+ */
299
+ encode_sticky_position(story: string, para_id: string, offset: number): Uint8Array;
300
+ /**
301
+ * This peer's selection in transportable form:
302
+ * `{"story","anchor":[byte, …],"head":[byte, …]}` with sticky-encoded
303
+ * endpoints, or `"null"` before a selection is set. A peer resolves it
304
+ * with [`EditSession::resolve_encoded_selection`].
305
+ */
306
+ encoded_selection(): string;
169
307
  /**
170
308
  * Applies a set-valued, tri-state inline formatting delta over
171
- * `[start, end)` in one transaction. Omitted fields are kept and `null`
172
- * fields are cleared.
309
+ * `[start, end)` in one transaction. An omitted key keeps the current
310
+ * value, `null` clears it, and any other value sets it. `delta_json`:
311
+ *
312
+ * ```json
313
+ * {
314
+ * "bold": true, "italic": true,
315
+ * "underline": true | {"style"?: string, "color"?: string},
316
+ * "strike": true | {"double"?: boolean},
317
+ * "color": {"rgb": string} | {"themeColor": string},
318
+ * "highlight": string,
319
+ * "fontSize": 12,
320
+ * "fontFamily": {"ascii": string, "hAnsi"?: string},
321
+ * "other": {"anyAttr": value}
322
+ * }
323
+ * ```
324
+ *
325
+ * `false` clears `bold`, `italic`, `underline` and `strike`. `color`
326
+ * takes exactly one of `rgb` or `themeColor`. `other` writes arbitrary
327
+ * run attributes, with `null` removing one. Always a plain local edit, so
328
+ * there is no receipt. Errors when a key carries a type not listed here.
173
329
  */
174
330
  format_range(story: string, start_para: string, start_offset: number, end_para: string, end_offset: number, delta_json: string): void;
175
331
  /**
176
- * Inserts a column left (`after = false`) or right (`after = true`) of a cell.
332
+ * Inserts a column left (`after = false`) or right (`after = true`) of
333
+ * the cell `at_json` ([`CellLoc`]) names. Always a plain local edit.
177
334
  */
178
335
  insert_column(at_json: string, after: boolean): string;
179
336
  /**
180
- * Inserts one native inline image embed at a paragraph-keyed location.
337
+ * Inserts one inline image embed at `(story, para_id, offset)`.
338
+ * `payload_json` is the image's authored payload object, stored as given.
339
+ * The embed occupies one story unit. Receipt:
340
+ * `{"revisionId": string|null}`. Errors when the payload is not an
341
+ * object.
181
342
  */
182
343
  insert_image(story: string, para_id: string, offset: number, payload_json: string, author_name?: string | null, author_date?: string | null): string;
183
344
  /**
184
- * Inserts a native page-break embed at a Loc.
345
+ * Inserts a page-break embed at `(story, para_id, offset)`, occupying one
346
+ * story unit. Always a plain local edit.
185
347
  */
186
348
  insert_page_break(story: string, para_id: string, offset: number): void;
187
349
  /**
188
- * Inserts a row above (`after = false`) or below (`after = true`) a cell.
350
+ * Inserts a row above (`after = false`) or below (`after = true`) the
351
+ * cell `at_json` names. `at_json` is a [`CellLoc`].
189
352
  */
190
353
  insert_row(at_json: string, after: boolean, author_name?: string | null, author_date?: string | null): string;
191
354
  /**
192
- * Inserts a native section-break embed at a Loc.
355
+ * Inserts a section-break embed at `(story, para_id, offset)`.
356
+ * `break_type` must be `"nextPage"`, `"continuous"`, `"oddPage"` or
357
+ * `"evenPage"`; anything else errors. Always a plain local edit.
193
358
  */
194
359
  insert_section_break(story: string, para_id: string, offset: number, break_type: string): void;
195
360
  /**
196
- * Inserts a rectangular structural table at a paragraph-keyed location.
361
+ * Inserts a `rows` x `columns` table at `(story, para_id, offset)`,
362
+ * creating one story per cell. Errors when either dimension is zero.
197
363
  */
198
364
  insert_table(story: string, para_id: string, offset: number, rows: number, columns: number, author_name?: string | null, author_date?: string | null): string;
199
365
  /**
200
- * Inserts paragraph-break-free text at `(story, para_id, offset)`.
201
- * Receipt: `{"revisionId": string|null}` (non-null in suggesting mode).
366
+ * Inserts `text` at `(story, para_id, offset)`. It must contain no
367
+ * paragraph or line breaks, and it inherits the formatting at the
368
+ * insertion point. Receipt: `{"revisionId": string|null}` — non-null in
369
+ * suggesting mode, where the text is stamped `ins` and coalesces into an
370
+ * adjacent insertion by the same author rather than opening a second
371
+ * revision.
202
372
  */
203
373
  insert_text(story: string, para_id: string, offset: number, text: string, author_name?: string | null, author_date?: string | null): string;
204
374
  /**
205
- * Inserts a typed watermark embed at a Loc.
375
+ * Inserts a watermark embed at `(story, para_id, offset)`, its payload
376
+ * taken verbatim from the `watermark_json` object. Always a plain local
377
+ * edit. Errors when the JSON is not an object.
206
378
  */
207
379
  insert_watermark(story: string, para_id: string, offset: number, watermark_json: string): void;
208
380
  /**
209
- * Paginate and retain the measured input and Layout. The full JSON return
210
- * remains the migration parity bridge until binary frames consume it.
381
+ * `{ measured, options }` JSON in, `Layout` JSON out. Both the measured
382
+ * input and the resulting layout are retained for the resident edit path.
383
+ * Errors on unparseable input or on layout failure.
211
384
  */
212
385
  layout_document_json(input: string): string;
213
386
  /**
214
- * Paginate and compose section/page regions inside the resident engine.
387
+ * Region-layout input JSON in, a paginated envelope with section and page
388
+ * regions already composed as JSON out — ready for the display builder
389
+ * with no host-side layout mutation. Retains the pass for resident edits.
215
390
  */
216
391
  layout_document_with_regions_json(input: string): string;
392
+ /**
393
+ * Region-layout input JSON in, the font families and sizes that input
394
+ * needs as JSON out, so the host can register fonts before laying out.
395
+ */
217
396
  layout_font_requirements_json(input: string): string;
218
397
  /**
219
- * Every tracked-change run/paragraph-mark revision across all stories,
220
- * in deterministic story/position order.
398
+ * Every pending tracked change across all stories, in deterministic
399
+ * story-then-position order:
400
+ * `[{"revisionId","author","date","kind","story","preview",
401
+ * "range":{"story","start":{"paraId","offset"},"end":{…}}}, …]`. `kind`
402
+ * is one of `"insertion"`, `"deletion"`, `"pPrIns"`, `"pPrDel"`,
403
+ * `"pPrChange"`, `"trIns"`, `"trDel"`, `"tableIns"` or `"tableDel"`.
404
+ * `preview` holds the first few characters of the affected text, and is
405
+ * empty for every structural kind, which covers no text.
221
406
  */
222
407
  list_revisions(): string;
223
408
  /**
224
- * Hydrates this replica from an encoded yrs update (the bytes form of
225
- * `load` — typically another replica's `encode_state()` output).
409
+ * Hydrates this replica from an encoded yrs v1 update, typically another
410
+ * replica's [`EditSession::encode_state`] output. Identical to
411
+ * [`EditSession::apply_update`]; the separate name marks the initial-load
412
+ * call site. Errors on a malformed update.
226
413
  */
227
414
  load(update: Uint8Array): void;
228
415
  /**
229
- * Seeds stories from JSON (the json form of `load`):
416
+ * Seeds stories from JSON:
230
417
  * `[{"storyId","paragraphs":[{"text","pStyle"?,"alignment"?}, …]}, …]`.
231
- * Paragraph text must not contain paragraph breaks. Returns
232
- * `{storyId: [paraId, …]}` in document order. This is an S1 seeding
233
- * scaffold composed from public ops; the real `load(ParsedDocument)`
234
- * belongs to the ops track.
418
+ * `pStyle` defaults to `"Normal"` and `alignment` to `"left"`; paragraph
419
+ * text must not contain paragraph breaks. Receipt:
420
+ * `{storyId: [paraId, …]}` with each story's paragraphs in document
421
+ * order. Errors when a story entry has no `storyId`, no `paragraphs`
422
+ * array, or an empty one, and when a story id already exists.
235
423
  */
236
424
  load_json(stories_json: string): string;
237
425
  /**
238
- * `{"start","end"}` — the paragraph's story span; `end` is its pilcrow's
239
- * index, so `end - start` is the paragraph length (`offset` domain).
426
+ * `{"start","end"}` — the paragraph's span in story-global UTF-16 units.
427
+ * `end` is the index of its own pilcrow, so `end - start` is the
428
+ * paragraph length and the upper bound of a Loc `offset` in it. Errors
429
+ * when the paragraph is not in `story`.
240
430
  */
241
431
  locate_paragraph(story: string, para_id: string): string;
242
432
  /**
243
- * Paragraph-measure compatibility export on the resident engine module.
433
+ * Re-parses the DOCX bytes retained by the last
434
+ * [`EditSession::open_docx`] and returns the COMPLETE package envelope as
435
+ * JSON, or `None` when no DOCX has been opened. Unlike `open_docx` this
436
+ * keeps every part; it reflects the source file, not later edits.
437
+ */
438
+ materialize_docx(): string | undefined;
439
+ /**
440
+ * Measurement input JSON in, `ParagraphExtent` JSON out. Also records the
441
+ * paragraph's immutable width/font envelope under its stable block id, so
442
+ * a later resident edit re-measures only the changed block. Errors with
443
+ * the engine's message for input it cannot measure.
244
444
  */
245
445
  measure_paragraph_json(input: string): string;
246
446
  /**
247
- * Merges a rectangular cell range into its top-left cell.
447
+ * Merges the rectangle the [`TableRange`] `range_json` covers into its
448
+ * top-left cell, whose story survives; the other cells' stories are
449
+ * deleted. Always a plain local edit. Errors when the range covers fewer
450
+ * than two cells or has no top-left anchor cell.
248
451
  */
249
452
  merge_cells(range_json: string): string;
250
453
  /**
251
454
  * Merges `para_id` with the FOLLOWING paragraph by deleting (plain) or
252
- * `del`-marking (suggesting) its pilcrow. Errors on the story's final
253
- * paragraph. Receipt: `{"revisionId": string|null}`.
455
+ * `del`- and `pPrDel`-marking (suggesting) its pilcrow. On a plain merge
456
+ * the survivor adopts the deleted mark's properties and paraId, so the
457
+ * earlier paragraph's identity wins. Receipt:
458
+ * `{"revisionId": string|null}`. Errors on the story's final paragraph,
459
+ * which has no following paragraph to merge with.
254
460
  */
255
461
  merge_paragraphs(story: string, para_id: string, author_name?: string | null, author_date?: string | null): string;
256
462
  /**
257
- * Creates a replica. `client_id` must be a non-negative safe integer —
258
- * the host allocates it (yjs-style random 32-bit ids are fine).
463
+ * Creates a replica. The host allocates `client_id` (a random 32-bit id
464
+ * is fine) and must keep it unique across the replicas that will merge.
465
+ * Errors unless it is a non-negative safe integer.
259
466
  */
260
467
  constructor(client_id: number);
261
468
  /**
262
- * Resolve one glyph outline from the session's resident font store.
469
+ * Parses a DOCX package, optionally seeds its editable stories into this
470
+ * replica, and retains the source bytes for
471
+ * [`EditSession::materialize_docx`].
472
+ *
473
+ * Returns `{"envelope","referencedFonts":[string, …]}`. The envelope is
474
+ * the parsed package with the parts the host does not need stripped —
475
+ * body content, header/footer and note content, numbering, media and
476
+ * charts are emptied, section entries keep only their properties — so
477
+ * styles, theme, settings, fonts and relationships still cross while the
478
+ * bulk of the document stays in Rust. Errors on bytes that are not a
479
+ * readable DOCX.
480
+ */
481
+ open_docx(bytes: Uint8Array, seed_stories: boolean): string;
482
+ /**
483
+ * One glyph outline from this session's resident font store:
484
+ * `{"upem":n,"cmds":[{"t":"M"|"L"|"Q"|"C"|"Z", …}]}` — commands in font
485
+ * units, y-up. `font_id` comes from
486
+ * [`EditSession::register_measure_font`] and `glyph_id` from shaping.
487
+ * Errors when the glyph cannot be extracted.
263
488
  */
264
489
  outline_glyph_json(font_id: number, glyph_id: number): string;
265
490
  /**
266
- * Compact paragraph-position projection in one story traversal:
267
- * `[{"paraId","length"}]`. Length counts UTF-16 text and inline embed
268
- * units before each paragraph's pilcrow. The JS input shim uses this
269
- * instead of crossing the wasm boundary once per paragraph.
491
+ * Compact paragraph-position projection built in one story traversal:
492
+ * `[{"paraId","length"}, …]` in document order, where `length` counts the
493
+ * UTF-16 text and inline embed units before that paragraph's pilcrow —
494
+ * exactly the `offset` domain of a Loc in it. One call replaces crossing
495
+ * the boundary once per paragraph. Errors on an unknown story.
270
496
  */
271
497
  paragraph_spans(story: string): string;
272
498
  /**
273
- * `[{"paraId","text","properties"}]` in document order. `properties`
274
- * carries pStyle/alignment plus any op-set extras.
499
+ * `[{"paraId","text","properties"}, …]` in document order. `text` is the
500
+ * paragraph's plain text without its pilcrow; `properties` is the
501
+ * pilcrow's authored property map (`pStyle`, `alignment` and whatever
502
+ * else has been set on it). Errors on an unknown story.
275
503
  */
276
504
  paragraphs(story: string): string;
277
505
  /**
278
- * Reapplies the latest locally undone transaction.
506
+ * Reapplies the latest locally undone transaction and reports whether
507
+ * anything was reapplied.
279
508
  */
280
509
  redo(): boolean;
281
510
  /**
@@ -283,165 +512,289 @@ declare class EditSession {
283
512
  */
284
513
  redo_depth(): number;
285
514
  /**
286
- * Register font bytes in this editing wasm's resident measurement store.
287
- * Returned ids are valid for measurement and display work in this module.
515
+ * Registers raw sfnt bytes in this session's resident measurement store
516
+ * and returns the font id that measurement and display inputs reference.
517
+ * Errors on bytes the font parser rejects.
288
518
  */
289
519
  register_measure_font(bytes: Uint8Array): number;
290
520
  /**
291
- * Rejects tracked changes — the inverse of [`EditSession::accept_change`]:
292
- * pending insertions roll back, pending deletions restore their text;
293
- * `pPrIns` marks join back with the following paragraph, `pPrDel` marks
294
- * clear (the split stays). Same target and receipt shapes.
521
+ * Rejects tracked changes — the inverse of
522
+ * [`EditSession::accept_change`]: pending insertions roll back, pending
523
+ * deletions restore their text; `pPrIns` marks join back with the
524
+ * following paragraph, `pPrDel` marks clear so the split stays, and a
525
+ * `pPrChange` restores the paragraph's previous properties. Same target,
526
+ * receipt and error contract.
295
527
  */
296
528
  reject_change(target_json: string): string;
297
529
  /**
298
- * Replaces `[start, end)` with text in one transaction. The inserted text
299
- * adopts the first replaced unit's formatting; in suggesting mode the
300
- * deletion and insertion share one revision id.
530
+ * Replaces `[start, end)` with `text` in one transaction. The inserted
531
+ * text adopts the first replaced unit's formatting; in suggesting mode
532
+ * the deletion and the insertion share one revision id. Receipt:
533
+ * `{"revisionId": string|null}`.
301
534
  */
302
535
  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;
536
+ /**
537
+ * `{"frameEpoch", "caretRect": {…}|null}` for the session's own collapsed
538
+ * body selection. `caretRect` is null whenever there is no selection, the
539
+ * selection is not a collapsed body caret, or the retained layout has no
540
+ * geometry for it. `frameEpoch` identifies the frame the rect belongs to.
541
+ */
303
542
  resident_caret_snapshot_json(): string;
304
543
  /**
305
- * Current offsets of a comment's sticky anchors:
306
- * `[{"story","start","end"}]`. Errors when an anchor no longer resolves.
544
+ * Where a comment's sticky anchors currently sit:
545
+ * `[{"story","start","end"}, …]`, one entry per anchored range, in
546
+ * story-global UTF-16 units. Errors on an unknown comment id and when an
547
+ * anchor no longer resolves.
307
548
  */
308
549
  resolve_comment(comment_id: string): string;
309
550
  /**
310
- * Resolves this peer's current sticky selection as two public Locs, or
311
- * `null` before the host establishes an initial selection.
551
+ * Resolves another peer's encoded selection against this replica's
552
+ * current state: `{"anchor":{"story","paraId","offset"},"head":{…}}`.
553
+ * Errors on malformed bytes or an endpoint that no longer resolves.
554
+ */
555
+ resolve_encoded_selection(story: string, anchor: Uint8Array, head: Uint8Array): string;
556
+ /**
557
+ * Resolves sticky bytes from [`EditSession::encode_sticky_position`] back
558
+ * to `{"story","paraId","offset"}`. Errors when the bytes are malformed
559
+ * or the position no longer resolves in `story`.
560
+ */
561
+ resolve_sticky_position(story: string, position: Uint8Array): string;
562
+ /**
563
+ * [`EditSession::open_docx`] with seeding always on.
564
+ */
565
+ seed_from_docx(bytes: Uint8Array): string;
566
+ /**
567
+ * This peer's current selection as `{"anchor":{"story","paraId","offset"},
568
+ * "head":{…}}`, or `"null"` before [`EditSession::set_selection`] is
569
+ * called. Errors when an endpoint no longer resolves.
312
570
  */
313
571
  selection(): string;
314
572
  /**
315
- * Aggregated toolbar/a11y state over one paragraph-addressed story
316
- * range. Toggle marks are `true`, `false`, or `"mixed"`; value marks
317
- * are their uniform value or `null` when absent/mixed.
573
+ * Aggregated toolbar and accessibility state over `[start, end)`:
574
+ *
575
+ * ```json
576
+ * {
577
+ * "bold": true | false | "mixed", "italic": …, "underline": …, "strike": …,
578
+ * "fontFamily": string|null, "fontSize": number|null, "color": string|null,
579
+ * "paraId": string, "styleId": string|null, "alignment": string|null,
580
+ * "paragraphProperties": {…},
581
+ * "hasSelection": bool, "isMultiParagraph": bool, "inTable": bool,
582
+ * "isSingleEmbed": bool, "embedKind": string|null, "isImage": bool,
583
+ * "inInsertion": bool, "inDeletion": bool
584
+ * }
585
+ * ```
586
+ *
587
+ * A toggle mark is `"mixed"` when the range disagrees about it; a value
588
+ * mark is `null` when it is absent OR not uniform, so the two cases are
589
+ * not distinguished. `isImage` is `embedKind == "image"`, and
590
+ * `inInsertion`/`inDeletion` report whether the range sits inside a
591
+ * pending tracked change.
318
592
  */
319
593
  selection_context(story: string, start_para: string, start_offset: number, end_para: string, end_offset: number): string;
320
594
  /**
321
- * Replaces the selected cells' complete border property object.
595
+ * Merges the sides of the JSON object `borders_json` into every selected
596
+ * cell's `tcPr.borders`; `insideH`/`insideV` resolve to the physical edges
597
+ * interior to the selection. `range_json` is a [`TableRange`]. Always a
598
+ * plain local edit.
322
599
  */
323
600
  set_cell_borders(range_json: string, borders_json: string): string;
324
601
  /**
325
- * Stores a rectangular anchor-cell → head-cell selection outside the yrs
326
- * document. `range_json` is a [`TableRange`]. The table embed is held by a
327
- * sticky index and the endpoints by stable cell-story identity.
602
+ * Stores a rectangular anchor-cell to head-cell selection outside the yrs
603
+ * document. `range_json` is a [`TableRange`]:
604
+ * `{"anchor":{"story","tableIndex","row","column"},"head":{…}}`. The table
605
+ * embed is held by a sticky index and each endpoint by its cell story's
606
+ * stable identity, so the selection survives unrelated edits and follows
607
+ * inserted or deleted rows and columns. Errors when the two endpoints are
608
+ * not in the same table, or when either cell does not resolve.
328
609
  */
329
610
  set_cell_selection(range_json: string): void;
330
611
  /**
331
- * Sets/clears selected cells' background color (hex without or with `#`).
612
+ * Sets every selected cell's background to `color` (hex, with or without
613
+ * a leading `#`), or clears it when `color` is absent. `range_json` is a
614
+ * [`TableRange`]. Always a plain local edit.
332
615
  */
333
616
  set_cell_shading(range_json: string, color?: string | null): string;
334
617
  /**
335
- * Merges a JSON cell-format patch into every selected cell's `tcPr`.
618
+ * Merges the JSON object `patch_json` into every selected cell's `tcPr`;
619
+ * a `null` value removes that key. `range_json` is a [`TableRange`].
620
+ * Always a plain local edit. Errors when the patch touches `rowspan`,
621
+ * `colspan`, `gridSpan` or `vMerge`, which only merge and split may set.
336
622
  */
337
623
  set_cell_text_format(range_json: string, patch_json: string): string;
338
624
  /**
339
- * Sets one grid-column width in twips.
625
+ * Sets the grid width, in twips, of the column holding the cell `at_json`
626
+ * ([`CellLoc`]) names. Always a plain local edit. Errors unless
627
+ * `width_twips` is finite and positive.
340
628
  */
341
629
  set_column_width(at_json: string, width_twips: number): string;
342
630
  /**
343
- * Sets the authored `value` on a stable-id content-control embed.
631
+ * Sets the authored `value` (any JSON) on the content-control embed
632
+ * carrying `embed_id`, searching every story. Errors when no embed has
633
+ * that id.
344
634
  */
345
635
  set_content_control_value(embed_id: string, value_json: string): void;
346
636
  /**
347
- * Sets the authored `value` on a content-control embed at a paragraph-keyed
348
- * position. This is the fallback for valid controls that have no authored
349
- * `w:id`/tag and therefore cannot be addressed by stable payload identity.
637
+ * Sets the authored `value` on the content-control embed at
638
+ * `(story, para_id, offset)` — the way to reach a control with no
639
+ * authored `w:id` or tag, which
640
+ * [`EditSession::set_content_control_value`] cannot address. Errors when
641
+ * that position holds no embed.
350
642
  */
351
643
  set_content_control_value_at(story: string, para_id: string, offset: number, value_json: string): void;
352
644
  /**
353
- * Sets or clears the protected hyperlink attribute over `[start, end)`.
354
- * `hyperlink_json` is an object (`{href, tooltip?, rId?}`) or `null`.
645
+ * Sets or clears the hyperlink attribute over `[start, end)`.
646
+ * `hyperlink_json` is `{"href", "tooltip"?, "rId"?}` or `null` to unlink.
647
+ * The attribute is protected: ordinary formatting ops cannot write or
648
+ * erase it, only this one. Errors when the JSON is neither an object nor
649
+ * `null`.
355
650
  */
356
651
  set_hyperlink(story: string, start_para: string, start_offset: number, end_para: string, end_offset: number, hyperlink_json: string): void;
357
652
  /**
358
- * Commits image geometry fields to a stable-id image embed in one
359
- * transaction. `null` fields clear; `other` is flattened into the payload.
653
+ * Writes geometry fields onto the image embed carrying `embed_id` in one
654
+ * transaction. Every key of the `geometry_json` object becomes a payload
655
+ * entry, with `null` clearing it; the entries of a nested `"other"`
656
+ * object are flattened into the payload alongside them. Errors when
657
+ * `geometry_json` or its `"other"` is not an object, and when no embed
658
+ * has that id.
360
659
  */
361
660
  set_image_geometry(embed_id: string, geometry_json: string): void;
362
661
  /**
363
- * Sets one paragraph property (any JSON value) on `para_id`'s pilcrow.
364
- * `paraId` / the embed discriminator are reserved.
662
+ * Sets one paragraph property to any JSON value on `para_id`'s pilcrow,
663
+ * searching every story. Unlike
664
+ * [`EditSession::set_paragraph_attrs`] this writes a single key and never
665
+ * records a revision. Errors when the paragraph is unknown and when `key`
666
+ * names schema-managed identity (`paraId` or the embed discriminator).
365
667
  */
366
668
  set_paragraph_attr(para_id: string, key: string, value_json: string): void;
367
669
  /**
368
670
  * Applies a tri-state paragraph-property delta to every paragraph
369
- * intersecting `[start, end)` in one transaction.
671
+ * intersecting `[start, end)` in one transaction. An omitted key keeps
672
+ * the current value and `null` clears it. `attrs_json` recognises
673
+ * `alignment`, `lineSpacing`, `lineSpacingRule`, `spaceBefore`,
674
+ * `spaceAfter`, `indentLeft`, `indentRight`, `indentFirstLine`,
675
+ * `hangingIndent`, `bidi`, `tabs`
676
+ * (`[{"position":number,"alignment":string,"leader"?:string}, …]`) and
677
+ * `defaultTextFormatting` (an object of run defaults). Any other key —
678
+ * whether written at the top level or nested under `"other"` — is stored
679
+ * as an opaque paragraph property. Spacing and indents are authored OOXML
680
+ * units (twips, line-spacing units), never pixels. In suggesting mode a
681
+ * change is recorded as a `pPrChange` revision. Errors when a recognised
682
+ * key carries the wrong type, and when a key names schema-managed
683
+ * identity such as `paraId`.
370
684
  */
371
685
  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;
372
686
  /**
373
- * Stores this peer's anchor/head as sticky positions. `Assoc::After`
374
- * makes a collapsed caret advance with text inserted at the caret.
687
+ * Stores this peer's anchor and head as sticky positions, replacing any
688
+ * previous selection. Both endpoints must lie in `story`. The positions
689
+ * live outside the yrs document, so they are never serialized as content
690
+ * or carried in an update. `Assoc::After` makes a collapsed caret advance
691
+ * with text inserted at it.
375
692
  */
376
693
  set_selection(story: string, anchor_para: string, anchor_offset: number, head_para: string, head_offset: number): void;
377
694
  /**
378
- * Sets the table-wide preferred width in twips.
695
+ * Sets the preferred width, in twips, of the table `table_json`
696
+ * ([`TableLocator`]) names. Always a plain local edit. Errors unless
697
+ * `width_twips` is finite and positive.
379
698
  */
380
699
  set_table_width(table_json: string, width_twips: number): string;
381
700
  /**
382
- * Subscribes `callback(update: Uint8Array)` to every committed
383
- * transaction (v1 encoding — feed it straight to `apply_update` on a
384
- * peer). One observer per session; a second call replaces the first.
385
- * The facade fans out to multiple JS listeners over this single hook.
701
+ * Subscribes `callback(update: Uint8Array, isRemote: 0|1)` to every
702
+ * committed transaction. `update` is v1-encoded — feed it straight to
703
+ * [`EditSession::apply_update`] on a peer — and is copied out of wasm
704
+ * memory, so JS may hold it across later edits. The second argument is
705
+ * `1` when the transaction had no local origin. One observer per session;
706
+ * a second call replaces the first, and a throwing callback is ignored.
386
707
  */
387
708
  set_update_observer(callback: Function): void;
388
709
  /**
389
- * Splits the cell covering `at` into the requested grid. Omitted
390
- * dimensions unmerge the cell into its existing covered slots.
710
+ * Splits the cell `at_json` ([`CellLoc`]) covers into a `rows` x
711
+ * `columns` grid; the original story stays in the top-left slot and every
712
+ * other slot gets a fresh one-paragraph cell story. Omitting both
713
+ * dimensions unmerges the cell into the slots it already covers, which
714
+ * then requires a merged cell. Always a plain local edit. Errors on a
715
+ * zero dimension or a grid smaller than the cell already covers.
391
716
  */
392
717
  split_cell(at_json: string, rows?: number | null, columns?: number | null): string;
393
718
  /**
394
719
  * Splits a paragraph at `(story, para_id, offset)` by inserting one
395
- * pilcrow. Under the S1 split the FIRST half keeps the original paraId and
396
- * the SECOND half is re-minted. Receipt:
720
+ * pilcrow. The FIRST half keeps the original paraId and the second is
721
+ * re-minted. A split at the paragraph end leaves the empty second half
722
+ * with only the inherited property subset; a mid-paragraph split keeps
723
+ * its properties. Paragraph borders are cleared either way. Suggesting
724
+ * mode stamps the new pilcrow `ins` and `pPrIns`. Receipt:
397
725
  * `{"firstParaId","secondParaId","revisionId": string|null}`.
398
726
  */
399
727
  split_paragraph(story: string, para_id: string, offset: number, author_name?: string | null, author_date?: string | null): string;
728
+ /**
729
+ * Starts queueing committed transactions for
730
+ * [`EditSession::drain_update_event`] instead of pushing them through a
731
+ * callback. Idempotent while observation is running.
732
+ */
400
733
  start_update_event_observation(): void;
401
734
  /**
402
- * The story's `canonical-stream-v1` FNV-1a checksum as a decimal string
403
- * (u64 exceeds JS safe-integer range). The coexistence watchdog compares
404
- * this against the PM projector's checksum after every mirrored edit.
735
+ * The story's `canonical-stream-v1` FNV-1a checksum (see
736
+ * [`crate::canonical`]) as a DECIMAL STRING, because a u64 exceeds the
737
+ * JavaScript safe-integer range. Two stories with the same authored
738
+ * content share a checksum even when their paragraph and comment ids
739
+ * differ. Errors on an unknown story.
405
740
  */
406
741
  story_checksum(story: string): string;
407
742
  /**
408
- * Story ids currently in the document, sorted for determinism.
743
+ * Every story id in the document, sorted so the order is stable across
744
+ * replicas.
409
745
  */
410
746
  story_ids(): string[];
411
747
  /**
412
- * Story length in UTF-16 units (every embed, pilcrows included, = 1).
748
+ * Story length in UTF-16 units, every embed (pilcrows included) counting
749
+ * as one. Errors on an unknown story.
413
750
  */
414
751
  story_len(story: string): number;
415
752
  /**
416
- * The raw formatted-segment view (the render bridge's input):
417
- * `[{"kind":"text","text",…} | {"kind":"pilcrow","paraId","properties",…}
418
- * | {"kind":"embed",…}]`, each with `"attributes"` (run marks plus
419
- * `ins`/`del` revision values).
753
+ * The story as an ordered run of formatted segments — the same view
754
+ * lowering reads:
755
+ *
756
+ * - `{"kind":"text","text","attributes"}`
757
+ * - `{"kind":"pilcrow","paraId","properties","attributes"}`
758
+ * - `{"kind":"embed","embedKind","payload","attributes"}`
759
+ *
760
+ * A text segment covers one maximal run of identically formatted
761
+ * characters; each pilcrow and embed is its own segment worth one unit.
762
+ * `attributes` holds the segment's run marks together with any `ins`/`del`
763
+ * tracked-change stamps. Errors on an unknown story.
420
764
  */
421
765
  story_segments(story: string): string;
422
766
  /**
423
- * Applies one run mark over `[start, end)` (two Locs in one story). Simple
424
- * marks toggle; font/size/color set (see [`apply_mark`]). `mark_json`:
767
+ * Applies one run mark over `[start, end)`. `mark_json`:
425
768
  * `{"type":"bold"|"italic"|"underline"|"strike"|"superscript"|"subscript"} |
426
769
  * {"type":"fontFamily"|"color","value":string} |
427
- * {"type":"fontSize","value":number}`.
770
+ * {"type":"fontSize","value":number}`. The six boolean types TOGGLE —
771
+ * they turn on unless the whole range already carries the mark — while
772
+ * font family, size and color SET. Formatting is always a plain local
773
+ * edit, never a tracked change, so there is no receipt. Errors on an
774
+ * unknown `"type"` or a missing/mistyped `"value"`.
428
775
  */
429
776
  toggle_mark(story: string, start_para: string, start_offset: number, end_para: string, end_offset: number, mark_json: string): void;
430
777
  /**
431
- * Starts local undo tracking for a structural table transaction. Besides
432
- * the parent story (which owns the table embed), the stories root must be
433
- * in scope so undo/redo also removes/restores cell-story map entries.
778
+ * Starts local undo tracking for a structural table edit in `story`.
779
+ * Besides the parent story, which owns the table embed, this widens the
780
+ * scope to the stories root so undo and redo also remove and restore the
781
+ * cell stories the edit created or destroyed. Tracked separately from
782
+ * [`EditSession::track_undo`] on the same story, so switching between
783
+ * them starts a fresh history. Errors on an unknown story.
434
784
  */
435
785
  track_table_undo(story: string): void;
436
786
  /**
437
- * Starts local-origin undo tracking for one story. Hosts call this lazily
438
- * after import/seeding but before the first direct input operation, so the
439
- * initial document is not an undo step.
787
+ * Starts local-origin undo tracking for one story, replacing any scope
788
+ * already tracked (and its history). Call this after import or seeding but
789
+ * before the first edit, so the initial document is not an undo step.
790
+ * Re-tracking the same story is a no-op that preserves the history.
791
+ * Errors on an unknown story.
440
792
  */
441
793
  track_undo(story: string): void;
442
794
  /**
443
- * Reverts the latest local-origin transaction. Remote/system mirror
444
- * transactions are excluded by `DocUndoManager`'s tracked-origin policy.
795
+ * Reverts the latest local-origin transaction and reports whether
796
+ * anything was reverted. Remote and system transactions are excluded by
797
+ * the manager's tracked-origin policy; `false` before a story is tracked.
445
798
  */
446
799
  undo(): boolean;
447
800
  /**
@@ -449,11 +802,14 @@ declare class EditSession {
449
802
  */
450
803
  undo_depth(): number;
451
804
  /**
452
- * Lowers a story through the resident Rust bridge. Errors with an
453
- * unsupported-embed message on any non-native content until that class is
454
- * promoted to native.
455
- * `env_json` carries theme colors, the default tab stop, and list numeric
456
- * ids (see [`parse_render_env`]).
805
+ * Lowers one story to a `LayoutBlock[]` JSON array — the block, run and
806
+ * table vocabulary the layout engine consumes. `env_json` supplies the
807
+ * document-level values lowering cannot read off the story:
808
+ * `{"themeColors":{slot: hex},"defaultTabStopTwips":number|null,
809
+ * "pageContentHeight":number|null,"numericIds":{yrsId: number}}`, all
810
+ * optional. Errors when the story does not end in a pilcrow, holds a
811
+ * malformed table, references itself through a cell story, or contains an
812
+ * embed lowering does not support.
457
813
  */
458
814
  yrs_blocks_for_story(story: string, env_json: string): string;
459
815
  }