@betteroffice/docx 0.0.4 → 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 (61) hide show
  1. package/README.md +2 -1
  2. package/dist/chunk-24DL53QL.mjs +1 -0
  3. package/dist/chunk-5F6DLQZP.mjs +1 -0
  4. package/dist/{chunk-YTILOUAA.mjs → chunk-BUZ2X5CT.mjs} +1 -1
  5. package/dist/{chunk-B4IR6YP4.mjs → chunk-GHEHBYQK.mjs} +1 -1
  6. package/dist/{chunk-NJHOPXZW.mjs → chunk-HLDJMU3R.mjs} +1 -1
  7. package/dist/{chunk-4V6MDZIK.mjs → chunk-HTDNSQ44.mjs} +1 -1
  8. package/dist/{chunk-NTSSE5QK.mjs → chunk-PI2I3TO5.mjs} +1 -1
  9. package/dist/{chunk-6KDV6AIL.mjs → chunk-TMHG7OAZ.mjs} +1 -1
  10. package/dist/{chunk-NBSLB77E.mjs → chunk-VRGUAKOC.mjs} +1 -1
  11. package/dist/collaboration/index.d.mts +6 -6
  12. package/dist/{content-C3sTRz-u.d.mts → content-DrqzbIr7.d.mts} +67 -18
  13. package/dist/core.d.mts +7 -7
  14. package/dist/core.mjs +1 -1
  15. package/dist/{displayListQueries-DLzpvJV6.d.mts → displayListQueries-DGDR-OWc.d.mts} +87 -50
  16. package/dist/docx/index.d.mts +5 -5
  17. package/dist/docx/index.mjs +1 -1
  18. package/dist/editor/index.d.mts +8 -8
  19. package/dist/{fontLoader-CMH3bZ2Z.d.mts → fontLoader-DnixuYST.d.mts} +1 -1
  20. package/dist/{formatting-BEkIBePP.d.mts → formatting-BqrFPeev.d.mts} +8 -0
  21. package/dist/{frameDelta-B2kC6XiP.d.mts → frameDelta-DMgR8n13.d.mts} +15 -10
  22. package/dist/generated/edit/docx_edit_bg.wasm +0 -0
  23. package/dist/generated/layout/docx_layout_bg.wasm +0 -0
  24. package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
  25. package/dist/generated/parse/docx_parse_bg.wasm +0 -0
  26. package/dist/{index-2piKi4gO.d.mts → index-ImoMd0Ju.d.mts} +32 -65
  27. package/dist/layout/index.d.mts +40 -13
  28. package/dist/layout/index.mjs +1 -1
  29. package/dist/layout/pagination/index.d.mts +4 -4
  30. package/dist/layout/render/index.d.mts +33 -77
  31. package/dist/layout/render/index.mjs +1 -1
  32. package/dist/plugin-api/RenderedDomContext.d.mts +7 -7
  33. package/dist/plugin-api/index.d.mts +3 -3
  34. package/dist/plugin-api/resolveItemPositions.d.mts +3 -3
  35. package/dist/{rustDisplayList-B0M2eBkU.d.mts → rustDisplayList-B9dQoLHI.d.mts} +74 -50
  36. package/dist/{rustMeasureSource-D1KsQvVC.d.mts → rustMeasureSource-C0EZB055.d.mts} +5 -2
  37. package/dist/{selectiveSave-CVoajSKE.d.mts → selectiveSave-CRh-_Y_C.d.mts} +3 -3
  38. package/dist/styles/index.d.mts +3 -3
  39. package/dist/{styles-BK3Jecxs.d.mts → styles-CMybYYHS.d.mts} +1 -1
  40. package/dist/types/content.d.mts +2 -2
  41. package/dist/types/document.d.mts +7 -7
  42. package/dist/{types-C1rv3KM-.d.mts → types-CXLxVF1t.d.mts} +27 -23
  43. package/dist/utils/comments.d.mts +2 -2
  44. package/dist/utils/index.d.mts +11 -13
  45. package/dist/utils/index.mjs +1 -1
  46. package/dist/utils/stylePreview.d.mts +2 -2
  47. package/dist/wasm-CJHQHBDE.mjs +1 -0
  48. package/dist/{wasm-JE7B3ROD.mjs → wasm-T2CRCO7S.mjs} +1 -1
  49. package/dist/wasm-edit.d.mts +505 -173
  50. package/dist/wasm-edit.mjs +1 -1
  51. package/dist/wasm-layout.d.mts +31 -28
  52. package/dist/wasm-layout.mjs +1 -1
  53. package/dist/wasm-opc.mjs +1 -1
  54. package/dist/wasm-parse.mjs +1 -1
  55. package/dist/yrs/index.d.mts +5 -5
  56. package/dist/yrs/index.mjs +1 -1
  57. package/dist/yrs/residentEngineWorker.mjs +1 -1
  58. package/package.json +19 -2
  59. package/dist/chunk-GGEGIQRK.mjs +0 -1
  60. package/dist/chunk-T4EZMUXM.mjs +0 -1
  61. package/dist/wasm-F2ETFAYL.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,236 +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;
131
+ /**
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
+ */
85
139
  apply_update_with_inference(update: Uint8Array): string;
86
140
  /**
87
- * Binary FrameDelta v1 display output. The returned `Vec<u8>` is exposed
88
- * by wasm-bindgen as a transferable-friendly `Uint8Array`.
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.
89
146
  */
90
147
  build_display_list_frame(input: string, expected_frame_epoch: number): Uint8Array;
91
148
  /**
92
- * Build display primitives against the same resident font store used by
93
- * 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.
94
151
  */
95
152
  build_display_list_json(input: string): string;
153
+ /**
154
+ * Whether [`EditSession::redo`] would reapply something.
155
+ */
96
156
  can_redo(): boolean;
157
+ /**
158
+ * Whether [`EditSession::undo`] would revert something.
159
+ */
97
160
  can_undo(): boolean;
98
161
  /**
99
- * Resolves the current local cell selection, or `null` before the host
100
- * 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.
101
165
  */
102
166
  cell_selection(): string;
103
167
  /**
104
- * 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.
105
171
  */
106
172
  clear_content_control_value(embed_id: string): void;
107
173
  /**
108
- * Clears every direct formatting attribute over `[start, end)`, while
109
- * 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.
110
177
  */
111
178
  clear_formatting(story: string, start_para: string, start_offset: number, end_para: string, end_offset: number): void;
112
179
  /**
113
- * 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.
114
183
  */
115
184
  clear_measure_fonts(): void;
185
+ /**
186
+ * Stops queueing and discards anything not yet drained.
187
+ */
116
188
  clear_update_event_observation(): void;
117
189
  /**
118
190
  * Drops the update observer registered by [`EditSession::set_update_observer`].
119
191
  */
120
192
  clear_update_observer(): void;
193
+ /**
194
+ * This replica's client id, as passed to the constructor.
195
+ */
121
196
  client_id(): number;
122
197
  /**
123
- * Adds a story with one paragraph. Receipt: `{"paraId"}` (the final
124
- * 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.
125
202
  */
126
203
  create_story(story_id: string, initial_text: string, p_style: string, alignment: string): string;
127
204
  /**
128
- * 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.
129
207
  */
130
208
  delete_column(range_json: string): string;
131
209
  /**
132
- * Deletes `[start, end)` given as two Locs in one story. A range whose
133
- * ends sit in different paragraphs spans the boundary pilcrows, so the
134
- * plain delete also merges (the pilcrow-as-character dividend).
135
- * Suggesting mode retains the content with a `del` revision instead.
136
- * 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}`.
137
214
  */
138
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;
139
216
  /**
140
- * 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.
141
219
  */
142
220
  delete_row(range_json: string, author_name?: string | null, author_date?: string | null): string;
143
221
  /**
144
- * Removes one complete story (used for unreachable table-cell stories).
222
+ * Removes one complete story and its content. Errors on an unknown story.
145
223
  */
146
224
  delete_story(story_id: string): void;
147
225
  /**
148
- * 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`.
149
229
  */
150
230
  delete_table(table_json: string): string;
151
231
  /**
152
- * 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.
153
241
  */
154
242
  display_hit_test_regions_json(page_index: number, x: number, y: number): string;
155
243
  /**
156
- * 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.
157
248
  */
158
249
  display_range_rects_json(from: number, to: number): string;
159
250
  /**
160
- * 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.
161
268
  */
162
- display_range_rects_region_json(region: string, r_id: string, from: number, to: number): string;
163
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.
275
+ */
164
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
+ */
165
282
  encode_diff(remote_state_vector: Uint8Array): Uint8Array;
166
283
  /**
167
- * 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.
168
286
  */
169
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
+ */
170
292
  encode_state_vector(): Uint8Array;
171
293
  /**
172
- * Encodes one paragraph location as a sticky position.
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`].
173
298
  */
174
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
+ */
175
306
  encoded_selection(): string;
176
307
  /**
177
308
  * Applies a set-valued, tri-state inline formatting delta over
178
- * `[start, end)` in one transaction. Omitted fields are kept and `null`
179
- * 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.
180
329
  */
181
330
  format_range(story: string, start_para: string, start_offset: number, end_para: string, end_offset: number, delta_json: string): void;
182
331
  /**
183
- * 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.
184
334
  */
185
335
  insert_column(at_json: string, after: boolean): string;
186
336
  /**
187
- * 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.
188
342
  */
189
343
  insert_image(story: string, para_id: string, offset: number, payload_json: string, author_name?: string | null, author_date?: string | null): string;
190
344
  /**
191
- * 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.
192
347
  */
193
348
  insert_page_break(story: string, para_id: string, offset: number): void;
194
349
  /**
195
- * 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`].
196
352
  */
197
353
  insert_row(at_json: string, after: boolean, author_name?: string | null, author_date?: string | null): string;
198
354
  /**
199
- * 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.
200
358
  */
201
359
  insert_section_break(story: string, para_id: string, offset: number, break_type: string): void;
202
360
  /**
203
- * 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.
204
363
  */
205
364
  insert_table(story: string, para_id: string, offset: number, rows: number, columns: number, author_name?: string | null, author_date?: string | null): string;
206
365
  /**
207
- * Inserts paragraph-break-free text at `(story, para_id, offset)`.
208
- * 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.
209
372
  */
210
373
  insert_text(story: string, para_id: string, offset: number, text: string, author_name?: string | null, author_date?: string | null): string;
211
374
  /**
212
- * 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.
213
378
  */
214
379
  insert_watermark(story: string, para_id: string, offset: number, watermark_json: string): void;
215
380
  /**
216
- * Paginate and retain the measured input and Layout. The full JSON return
217
- * 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.
218
384
  */
219
385
  layout_document_json(input: string): string;
220
386
  /**
221
- * 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.
222
390
  */
223
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
+ */
224
396
  layout_font_requirements_json(input: string): string;
225
397
  /**
226
- * Every tracked-change run/paragraph-mark revision across all stories,
227
- * 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.
228
406
  */
229
407
  list_revisions(): string;
230
408
  /**
231
- * Hydrates this replica from an encoded yrs update (the bytes form of
232
- * `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.
233
413
  */
234
414
  load(update: Uint8Array): void;
235
415
  /**
236
- * Seeds stories from JSON (the json form of `load`):
416
+ * Seeds stories from JSON:
237
417
  * `[{"storyId","paragraphs":[{"text","pStyle"?,"alignment"?}, …]}, …]`.
238
- * Paragraph text must not contain paragraph breaks. Returns
239
- * `{storyId: [paraId, …]}` in document order. This is an S1 seeding
240
- * scaffold composed from public ops; the real `load(ParsedDocument)`
241
- * 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.
242
423
  */
243
424
  load_json(stories_json: string): string;
244
425
  /**
245
- * `{"start","end"}` — the paragraph's story span; `end` is its pilcrow's
246
- * 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`.
247
430
  */
248
431
  locate_paragraph(story: string, para_id: string): string;
249
432
  /**
250
- * Materializes the retained canonical package for compatibility APIs.
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.
251
437
  */
252
438
  materialize_docx(): string | undefined;
253
439
  /**
254
- * Paragraph-measure compatibility export on the resident engine module.
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.
255
444
  */
256
445
  measure_paragraph_json(input: string): string;
257
446
  /**
258
- * 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.
259
451
  */
260
452
  merge_cells(range_json: string): string;
261
453
  /**
262
454
  * Merges `para_id` with the FOLLOWING paragraph by deleting (plain) or
263
- * `del`-marking (suggesting) its pilcrow. Errors on the story's final
264
- * 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.
265
460
  */
266
461
  merge_paragraphs(story: string, para_id: string, author_name?: string | null, author_date?: string | null): string;
267
462
  /**
268
- * Creates a replica. `client_id` must be a non-negative safe integer —
269
- * 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.
270
466
  */
271
467
  constructor(client_id: number);
272
468
  /**
273
- * Parses a DOCX and optionally seeds its editable stories.
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.
274
480
  */
275
481
  open_docx(bytes: Uint8Array, seed_stories: boolean): string;
276
482
  /**
277
- * Resolve one glyph outline from the session's resident font store.
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.
278
488
  */
279
489
  outline_glyph_json(font_id: number, glyph_id: number): string;
280
490
  /**
281
- * Compact paragraph-position projection in one story traversal:
282
- * `[{"paraId","length"}]`. Length counts UTF-16 text and inline embed
283
- * units before each paragraph's pilcrow. The JS input shim uses this
284
- * 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.
285
496
  */
286
497
  paragraph_spans(story: string): string;
287
498
  /**
288
- * `[{"paraId","text","properties"}]` in document order. `properties`
289
- * 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.
290
503
  */
291
504
  paragraphs(story: string): string;
292
505
  /**
293
- * Reapplies the latest locally undone transaction.
506
+ * Reapplies the latest locally undone transaction and reports whether
507
+ * anything was reapplied.
294
508
  */
295
509
  redo(): boolean;
296
510
  /**
@@ -298,174 +512,289 @@ declare class EditSession {
298
512
  */
299
513
  redo_depth(): number;
300
514
  /**
301
- * Register font bytes in this editing wasm's resident measurement store.
302
- * 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.
303
518
  */
304
519
  register_measure_font(bytes: Uint8Array): number;
305
520
  /**
306
- * Rejects tracked changes — the inverse of [`EditSession::accept_change`]:
307
- * pending insertions roll back, pending deletions restore their text;
308
- * `pPrIns` marks join back with the following paragraph, `pPrDel` marks
309
- * 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.
310
527
  */
311
528
  reject_change(target_json: string): string;
312
529
  /**
313
- * Replaces `[start, end)` with text in one transaction. The inserted text
314
- * adopts the first replaced unit's formatting; in suggesting mode the
315
- * 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}`.
316
534
  */
317
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
+ */
318
542
  resident_caret_snapshot_json(): string;
319
543
  /**
320
- * Current offsets of a comment's sticky anchors:
321
- * `[{"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.
322
548
  */
323
549
  resolve_comment(comment_id: string): string;
550
+ /**
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
+ */
324
555
  resolve_encoded_selection(story: string, anchor: Uint8Array, head: Uint8Array): string;
325
556
  /**
326
- * Resolves one encoded sticky position to a paragraph location.
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`.
327
560
  */
328
561
  resolve_sticky_position(story: string, position: Uint8Array): string;
329
562
  /**
330
- * Parses a DOCX, seeds its stories, and returns thin host metadata.
563
+ * [`EditSession::open_docx`] with seeding always on.
331
564
  */
332
565
  seed_from_docx(bytes: Uint8Array): string;
333
566
  /**
334
- * Resolves this peer's current sticky selection as two public Locs, or
335
- * `null` before the host establishes an initial selection.
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.
336
570
  */
337
571
  selection(): string;
338
572
  /**
339
- * Aggregated toolbar/a11y state over one paragraph-addressed story
340
- * range. Toggle marks are `true`, `false`, or `"mixed"`; value marks
341
- * 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.
342
592
  */
343
593
  selection_context(story: string, start_para: string, start_offset: number, end_para: string, end_offset: number): string;
344
594
  /**
345
- * 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.
346
599
  */
347
600
  set_cell_borders(range_json: string, borders_json: string): string;
348
601
  /**
349
- * Stores a rectangular anchor-cell → head-cell selection outside the yrs
350
- * document. `range_json` is a [`TableRange`]. The table embed is held by a
351
- * 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.
352
609
  */
353
610
  set_cell_selection(range_json: string): void;
354
611
  /**
355
- * 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.
356
615
  */
357
616
  set_cell_shading(range_json: string, color?: string | null): string;
358
617
  /**
359
- * 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.
360
622
  */
361
623
  set_cell_text_format(range_json: string, patch_json: string): string;
362
624
  /**
363
- * 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.
364
628
  */
365
629
  set_column_width(at_json: string, width_twips: number): string;
366
630
  /**
367
- * 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.
368
634
  */
369
635
  set_content_control_value(embed_id: string, value_json: string): void;
370
636
  /**
371
- * Sets the authored `value` on a content-control embed at a paragraph-keyed
372
- * position. This is the fallback for valid controls that have no authored
373
- * `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.
374
642
  */
375
643
  set_content_control_value_at(story: string, para_id: string, offset: number, value_json: string): void;
376
644
  /**
377
- * Sets or clears the protected hyperlink attribute over `[start, end)`.
378
- * `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`.
379
650
  */
380
651
  set_hyperlink(story: string, start_para: string, start_offset: number, end_para: string, end_offset: number, hyperlink_json: string): void;
381
652
  /**
382
- * Commits image geometry fields to a stable-id image embed in one
383
- * 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.
384
659
  */
385
660
  set_image_geometry(embed_id: string, geometry_json: string): void;
386
661
  /**
387
- * Sets one paragraph property (any JSON value) on `para_id`'s pilcrow.
388
- * `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).
389
667
  */
390
668
  set_paragraph_attr(para_id: string, key: string, value_json: string): void;
391
669
  /**
392
670
  * Applies a tri-state paragraph-property delta to every paragraph
393
- * 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`.
394
684
  */
395
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;
396
686
  /**
397
- * Stores this peer's anchor/head as sticky positions. `Assoc::After`
398
- * 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.
399
692
  */
400
693
  set_selection(story: string, anchor_para: string, anchor_offset: number, head_para: string, head_offset: number): void;
401
694
  /**
402
- * 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.
403
698
  */
404
699
  set_table_width(table_json: string, width_twips: number): string;
405
700
  /**
406
- * Subscribes `callback(update: Uint8Array)` to every committed
407
- * transaction (v1 encoding — feed it straight to `apply_update` on a
408
- * peer). One observer per session; a second call replaces the first.
409
- * 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.
410
707
  */
411
708
  set_update_observer(callback: Function): void;
412
709
  /**
413
- * Splits the cell covering `at` into the requested grid. Omitted
414
- * 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.
415
716
  */
416
717
  split_cell(at_json: string, rows?: number | null, columns?: number | null): string;
417
718
  /**
418
719
  * Splits a paragraph at `(story, para_id, offset)` by inserting one
419
- * pilcrow. Under the S1 split the FIRST half keeps the original paraId and
420
- * 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:
421
725
  * `{"firstParaId","secondParaId","revisionId": string|null}`.
422
726
  */
423
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
+ */
424
733
  start_update_event_observation(): void;
425
734
  /**
426
- * The story's `canonical-stream-v1` FNV-1a checksum as a decimal string
427
- * (u64 exceeds JS safe-integer range). The coexistence watchdog compares
428
- * 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.
429
740
  */
430
741
  story_checksum(story: string): string;
431
742
  /**
432
- * 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.
433
745
  */
434
746
  story_ids(): string[];
435
747
  /**
436
- * 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.
437
750
  */
438
751
  story_len(story: string): number;
439
752
  /**
440
- * The raw formatted-segment view (the render bridge's input):
441
- * `[{"kind":"text","text",…} | {"kind":"pilcrow","paraId","properties",…}
442
- * | {"kind":"embed",…}]`, each with `"attributes"` (run marks plus
443
- * `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.
444
764
  */
445
765
  story_segments(story: string): string;
446
766
  /**
447
- * Applies one run mark over `[start, end)` (two Locs in one story). Simple
448
- * marks toggle; font/size/color set (see [`apply_mark`]). `mark_json`:
767
+ * Applies one run mark over `[start, end)`. `mark_json`:
449
768
  * `{"type":"bold"|"italic"|"underline"|"strike"|"superscript"|"subscript"} |
450
769
  * {"type":"fontFamily"|"color","value":string} |
451
- * {"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"`.
452
775
  */
453
776
  toggle_mark(story: string, start_para: string, start_offset: number, end_para: string, end_offset: number, mark_json: string): void;
454
777
  /**
455
- * Starts local undo tracking for a structural table transaction. Besides
456
- * the parent story (which owns the table embed), the stories root must be
457
- * 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.
458
784
  */
459
785
  track_table_undo(story: string): void;
460
786
  /**
461
- * Starts local-origin undo tracking for one story. Hosts call this lazily
462
- * after import/seeding but before the first direct input operation, so the
463
- * 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.
464
792
  */
465
793
  track_undo(story: string): void;
466
794
  /**
467
- * Reverts the latest local-origin transaction. Remote/system mirror
468
- * 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.
469
798
  */
470
799
  undo(): boolean;
471
800
  /**
@@ -473,11 +802,14 @@ declare class EditSession {
473
802
  */
474
803
  undo_depth(): number;
475
804
  /**
476
- * Lowers a story through the resident Rust bridge. Errors with an
477
- * unsupported-embed message on any non-native content until that class is
478
- * promoted to native.
479
- * `env_json` carries theme colors, the default tab stop, and list numeric
480
- * 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.
481
813
  */
482
814
  yrs_blocks_for_story(story: string, env_json: string): string;
483
815
  }