@betteroffice/docx 0.4.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +108 -598
- package/dist/chunk-25WGDXBF.mjs +1 -0
- package/dist/chunk-2CCPNW44.mjs +1 -0
- package/dist/chunk-32A4I3T4.mjs +1 -0
- package/dist/chunk-4LO3PSLZ.mjs +2 -0
- package/dist/chunk-67MGRMP3.mjs +1 -0
- package/dist/chunk-6AUR4AA2.mjs +1 -0
- package/dist/chunk-6WT6HKAY.mjs +1 -0
- package/dist/chunk-77ZWGQZN.mjs +1 -0
- package/dist/chunk-7C3Y7LIH.mjs +1 -0
- package/dist/chunk-7WIUNGQW.mjs +1 -0
- package/dist/chunk-7WWFGMMF.mjs +1 -0
- package/dist/chunk-AK2NG7PT.mjs +1 -0
- package/dist/chunk-BR5BFOHF.mjs +1 -0
- package/dist/chunk-CDNWHQH2.mjs +1 -0
- package/dist/chunk-CRTTEHZN.mjs +1 -0
- package/dist/chunk-ETDMQ5GE.mjs +1 -0
- package/dist/{wasm-KSZTTO3B.mjs → chunk-GBOHQ3CJ.mjs} +1 -1
- package/dist/chunk-H7K4SJKK.mjs +1 -0
- package/dist/chunk-ICJH7QUY.mjs +1 -0
- package/dist/chunk-IHETKRDA.mjs +1 -0
- package/dist/chunk-ISBZLVIF.mjs +1 -0
- package/dist/chunk-JSYH6HNV.mjs +2 -0
- package/dist/chunk-KICHSQFN.mjs +1 -0
- package/dist/chunk-KXIGXLFA.mjs +5 -0
- package/dist/chunk-KXLTK7AT.mjs +57 -0
- package/dist/chunk-L3JRNJ34.mjs +1 -0
- package/dist/chunk-LKDHP22R.mjs +1 -0
- package/dist/chunk-LPOEM5WH.mjs +1 -0
- package/dist/chunk-M44BABH2.mjs +1 -0
- package/dist/chunk-MAYPJU23.mjs +1 -0
- package/dist/chunk-N5RE2S3U.mjs +2 -0
- package/dist/chunk-NLYHFVF5.mjs +1 -0
- package/dist/chunk-ONYCW7VV.mjs +4 -0
- package/dist/chunk-QGZ2AB3M.mjs +1 -0
- package/dist/chunk-QWHU7YIW.mjs +2 -0
- package/dist/{chunk-VH7P4734.mjs → chunk-QX2CDKPG.mjs} +1 -1
- package/dist/chunk-RGDE6YQB.mjs +1 -0
- package/dist/chunk-TE3AU2JK.mjs +1 -0
- package/dist/chunk-UDVEZ722.mjs +1 -0
- package/dist/chunk-UQSVFDRV.mjs +2 -0
- package/dist/chunk-VHOOSS4D.mjs +1 -0
- package/dist/chunk-WIDM4EMT.mjs +1 -0
- package/dist/chunk-YITJ4QAO.mjs +1 -0
- package/dist/collaboration/index.d.mts +111 -11
- package/dist/collaboration/index.mjs +1 -1
- package/dist/{content-DSb-6a9T.d.mts → content-DVT06V_6.d.mts} +24 -3
- package/dist/core.d.mts +9 -9
- package/dist/core.mjs +1 -1
- package/dist/displayListQueries-6XjS7B5e.d.mts +1473 -0
- package/dist/docx/index.d.mts +8 -7
- package/dist/docx/index.mjs +1 -2
- package/dist/docxWorker.mjs +1 -0
- package/dist/editor/index.d.mts +14 -12
- package/dist/editor/index.mjs +1 -1
- package/dist/{fontLoader-BNSs0E8K.d.mts → fontLoader-CBkmh4ps.d.mts} +1 -1
- package/dist/{formatting-gqLFeJ9X.d.mts → formatting-p5MneNuy.d.mts} +32 -1
- package/dist/generated/edit/docx_edit_bg.wasm +0 -0
- package/dist/generated/layout/docx_layout_bg.wasm +0 -0
- package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
- package/dist/generated/parse/docx_parse_bg.wasm +0 -0
- package/dist/index-C-KKULi5.d.mts +5596 -0
- package/dist/layout/index.d.mts +4 -4
- package/dist/layout/index.mjs +1 -1
- package/dist/layout/pagination/index.d.mts +4 -4
- package/dist/layout/render/index.d.mts +37 -53
- package/dist/layout/render/index.mjs +3 -1
- package/dist/{pagedExport-BmSlEhoP.d.mts → pagedExport-DDgA5O7E.d.mts} +92 -9
- package/dist/plugin-api/RenderedDomContext.d.mts +5 -7
- package/dist/plugin-api/index.d.mts +3 -3
- package/dist/plugin-api/resolveItemPositions.d.mts +3 -3
- package/dist/{rezip-Bxiq4Z_R.d.mts → rezip-CfwAYdV4.d.mts} +7 -1
- package/dist/styles/index.d.mts +3 -3
- package/dist/styles/index.mjs +1 -1
- package/dist/{styles-AryxLAhx.d.mts → styles-DZZz2oRy.d.mts} +2 -2
- package/dist/types/content.d.mts +2 -2
- package/dist/types/document.d.mts +6 -6
- package/dist/{types-Cz7S77Ut.d.mts → types-bvPg3KsF.d.mts} +16 -3
- package/dist/utils/comments.d.mts +2 -2
- package/dist/utils/findReplace.mjs +1 -2
- package/dist/utils/index.d.mts +5 -5
- package/dist/utils/index.mjs +1 -1
- package/dist/utils/listState.d.mts +2 -5
- package/dist/utils/stylePreview.d.mts +2 -2
- package/dist/utils/stylePreview.mjs +1 -1
- package/dist/wasm-edit.d.mts +233 -48
- package/dist/wasm-edit.mjs +1 -1
- package/dist/wasm-layout.d.mts +7 -1
- package/dist/wasm-layout.mjs +1 -1
- package/dist/wasm-opc.mjs +1 -1
- package/dist/wasm-parse.d.mts +7 -1
- package/dist/wasm-parse.mjs +1 -1
- package/dist/worker.d.mts +60 -0
- package/dist/worker.mjs +1 -0
- package/dist/yrs/docxWorker.d.mts +20 -0
- package/dist/yrs/docxWorker.mjs +3 -0
- package/dist/yrs/index.d.mts +12 -7
- package/dist/yrs/index.mjs +1 -1
- package/package.json +14 -4
- package/dist/chunk-3RPZ44TT.mjs +0 -1
- package/dist/chunk-47Q2FMFF.mjs +0 -1
- package/dist/chunk-5Z22FORG.mjs +0 -1
- package/dist/chunk-7ZV6P6NZ.mjs +0 -57
- package/dist/chunk-AXFMDV66.mjs +0 -1
- package/dist/chunk-EBYC3CX7.mjs +0 -1
- package/dist/chunk-FK7X7557.mjs +0 -1
- package/dist/chunk-GKWXOZZH.mjs +0 -1
- package/dist/chunk-LIOWZSE7.mjs +0 -1
- package/dist/chunk-ML6E23W2.mjs +0 -1
- package/dist/chunk-MLEMGJP7.mjs +0 -1
- package/dist/chunk-QBMNRD5V.mjs +0 -2
- package/dist/chunk-SHVHVJUB.mjs +0 -1
- package/dist/compareDocx-URPCPAQT.mjs +0 -1
- package/dist/computeLayout-ZTO6TBWX.mjs +0 -1
- package/dist/displayListQueries-BVBDVXoP.d.mts +0 -306
- package/dist/frameDelta-CLeO7K5z.d.mts +0 -807
- package/dist/index-DzZVJC8-.d.mts +0 -2467
- package/dist/parseWasm-BESKFFA3.mjs +0 -1
- package/dist/rustDisplayList-B7uPoItK.d.mts +0 -315
- package/dist/wasm-JPDPN2B2.mjs +0 -1
- package/dist/wasm-QI7MWC5D.mjs +0 -1
- package/dist/yrs/residentEngineWorker.d.mts +0 -2
- package/dist/yrs/residentEngineWorker.mjs +0 -1
|
@@ -1,2467 +0,0 @@
|
|
|
1
|
-
import { C as ColorValue } from './formatting-gqLFeJ9X.mjs';
|
|
2
|
-
import { Document, CompatibilityFlags } from './types/document.mjs';
|
|
3
|
-
import { a0 as DocxEditSuggestion, a1 as DocxEditFailure, a2 as DocxEditFailureCode, a3 as DocxTextRange, a4 as DocxReadParagraphsRequest, a5 as DocxReadParagraphsResult, a6 as DocxFindTextRequest, a7 as DocxFindTextResult, a8 as DocxEditRequest, a9 as DocxValidationResult, aa as DocxEditResult, ab as DocxTextTarget, ac as DocxEditRefusal, a as DocxExportOptions, H as DocxExportResult, c as DocxStructuredContent, b as DocxMarkdownContent, d as DocxPageExportOptions, f as DocxPagedStructuredContent, i as DocxLayoutMap, g as DocxSnapshotLayoutMap, D as DocxExportFailure, V as DocxParagraphHeading, m as DocxContentControlsOptions, w as DocxContentControlsResult, l as DocxContentControlQuery } from './pagedExport-BmSlEhoP.mjs';
|
|
4
|
-
import { R as RetainedFrame } from './frameDelta-CLeO7K5z.mjs';
|
|
5
|
-
import { a as WasmModuleMemory } from './loadWasmAsset-Cr95TImt.mjs';
|
|
6
|
-
import { PointPosition } from './plugin-api/index.mjs';
|
|
7
|
-
import { B as BlockContent, e as Comment } from './content-DSb-6a9T.mjs';
|
|
8
|
-
import { R as RepackOptions } from './rezip-Bxiq4Z_R.mjs';
|
|
9
|
-
|
|
10
|
-
type CollaborationUpdateOrigin = 'local' | 'remote';
|
|
11
|
-
interface CollaborationReplica {
|
|
12
|
-
readonly clientId: number;
|
|
13
|
-
encodeStateVector(): Uint8Array;
|
|
14
|
-
encodeStateAsUpdate(remoteStateVector?: Uint8Array): Uint8Array;
|
|
15
|
-
applyUpdate(update: Uint8Array): unknown;
|
|
16
|
-
onUpdate(listener: (update: Uint8Array, origin: CollaborationUpdateOrigin) => void): () => void;
|
|
17
|
-
}
|
|
18
|
-
type CollaborationTransportEvent = {
|
|
19
|
-
type: 'open';
|
|
20
|
-
} | {
|
|
21
|
-
type: 'message';
|
|
22
|
-
data: Uint8Array;
|
|
23
|
-
} | {
|
|
24
|
-
type: 'close';
|
|
25
|
-
reason?: string;
|
|
26
|
-
} | {
|
|
27
|
-
type: 'error';
|
|
28
|
-
error: unknown;
|
|
29
|
-
} | {
|
|
30
|
-
type: 'drain';
|
|
31
|
-
};
|
|
32
|
-
interface CollaborationTransport {
|
|
33
|
-
/** Starts one connection attempt; transports may also reopen while still subscribed. */
|
|
34
|
-
connect(): void | Promise<void>;
|
|
35
|
-
disconnect(): void | Promise<void>;
|
|
36
|
-
/** Returns true only when the owned frame was accepted; false requires a later drain event. */
|
|
37
|
-
send(data: Uint8Array): boolean;
|
|
38
|
-
onEvent(listener: (event: CollaborationTransportEvent) => void): () => void;
|
|
39
|
-
}
|
|
40
|
-
type CollaborationStatus = 'disconnected' | 'connecting' | 'connected' | 'destroyed';
|
|
41
|
-
interface CollaborationStatusChange {
|
|
42
|
-
status: CollaborationStatus;
|
|
43
|
-
synced: boolean;
|
|
44
|
-
}
|
|
45
|
-
type CollaborationErrorCode = 'backpressure' | 'protocol' | 'replica' | 'transport';
|
|
46
|
-
declare class CollaborationError extends Error {
|
|
47
|
-
readonly code: CollaborationErrorCode;
|
|
48
|
-
readonly cause: unknown;
|
|
49
|
-
constructor(code: CollaborationErrorCode, message: string, cause?: unknown);
|
|
50
|
-
}
|
|
51
|
-
interface CollaborationProviderOptions {
|
|
52
|
-
maxFrameBytes?: number;
|
|
53
|
-
maxMessagesPerFrame?: number;
|
|
54
|
-
maxPendingBytes?: number;
|
|
55
|
-
user?: CollaborationUser;
|
|
56
|
-
}
|
|
57
|
-
interface CollaborationUser {
|
|
58
|
-
name: string;
|
|
59
|
-
color?: string;
|
|
60
|
-
}
|
|
61
|
-
interface CollaborationResolvedUser {
|
|
62
|
-
name: string;
|
|
63
|
-
color: string;
|
|
64
|
-
}
|
|
65
|
-
interface CollaborationCursor {
|
|
66
|
-
story: string;
|
|
67
|
-
anchor: Uint8Array;
|
|
68
|
-
head: Uint8Array;
|
|
69
|
-
}
|
|
70
|
-
interface CollaborationTextInsertion {
|
|
71
|
-
clientId: number;
|
|
72
|
-
story: string;
|
|
73
|
-
paraId: string;
|
|
74
|
-
endOffset: number;
|
|
75
|
-
}
|
|
76
|
-
interface CollaborationAwarenessState {
|
|
77
|
-
clientId: number;
|
|
78
|
-
clock: number;
|
|
79
|
-
user: CollaborationResolvedUser;
|
|
80
|
-
cursor: CollaborationCursor | null;
|
|
81
|
-
}
|
|
82
|
-
interface CollaborationPeer extends CollaborationAwarenessState {
|
|
83
|
-
lastSeenAt: number;
|
|
84
|
-
cursorMovedAt: number;
|
|
85
|
-
inferredCursor: CollaborationTextInsertion | null;
|
|
86
|
-
}
|
|
87
|
-
type CollaborationPeerListener = (peers: readonly CollaborationPeer[]) => void;
|
|
88
|
-
interface CollaborationPresence {
|
|
89
|
-
readonly peers: readonly CollaborationPeer[];
|
|
90
|
-
setCursor(cursor: CollaborationCursor | null, broadcast?: boolean): void;
|
|
91
|
-
onPeers(listener: CollaborationPeerListener): () => void;
|
|
92
|
-
}
|
|
93
|
-
type CollaborationStatusListener = (change: CollaborationStatusChange) => void;
|
|
94
|
-
type CollaborationErrorListener = (error: CollaborationError) => void;
|
|
95
|
-
|
|
96
|
-
/** Typed TypeScript boundary for the Rust package writer. */
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Paragraph IDs a session save applies: IDs for source paragraphs outside
|
|
100
|
-
* the edited stories by part and `w:p` occurrence, and parts written as their
|
|
101
|
-
* source bytes with only these IDs patched in.
|
|
102
|
-
*/
|
|
103
|
-
interface RustParagraphIds {
|
|
104
|
-
assignments: Array<{
|
|
105
|
-
part: string;
|
|
106
|
-
ordinal: number;
|
|
107
|
-
paraId: string;
|
|
108
|
-
}>;
|
|
109
|
-
patchedParts: Array<{
|
|
110
|
-
part: string;
|
|
111
|
-
paraIds: Array<[number, string]>;
|
|
112
|
-
}>;
|
|
113
|
-
/**
|
|
114
|
-
* Story parts written as their source bytes with only some paragraphs
|
|
115
|
-
* re-serialized: those whose `sourceOrdinal` is in `changed`, or whose
|
|
116
|
-
* written comments, revisions, notes or relationships differ from their
|
|
117
|
-
* source. `paragraphs` lists every `sourceOrdinal` the model holds for the
|
|
118
|
-
* part, `sha256` the source part it addresses.
|
|
119
|
-
*/
|
|
120
|
-
splicedParts?: Array<{
|
|
121
|
-
part: string;
|
|
122
|
-
sha256: string;
|
|
123
|
-
paragraphs: number[];
|
|
124
|
-
changed: number[];
|
|
125
|
-
}>;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Paragraph identity DTOs for `YrsSession` identity reads and saves.
|
|
130
|
-
*
|
|
131
|
-
* A session key (`YrsLoc.paraId`) addresses a paragraph in one collaborative
|
|
132
|
-
* document session. A Word paragraph ID (`w14:paraId`) is saved in the file;
|
|
133
|
-
* a paragraph has one once its source carried it, it was authored in a
|
|
134
|
-
* session, or the host called `YrsSession.persistParagraphIds()`.
|
|
135
|
-
*/
|
|
136
|
-
/** A Word story qualified by the package part it is read from. */
|
|
137
|
-
type DocxSourceStory = {
|
|
138
|
-
partUri: string;
|
|
139
|
-
kind: 'body' | 'header' | 'footer';
|
|
140
|
-
} | {
|
|
141
|
-
partUri: string;
|
|
142
|
-
kind: 'footnote' | 'endnote' | 'comment';
|
|
143
|
-
itemId: string;
|
|
144
|
-
};
|
|
145
|
-
/** A paragraph in one collaborative document session, on any of its replicas. */
|
|
146
|
-
interface DocxSessionParagraphAnchor {
|
|
147
|
-
kind: 'session';
|
|
148
|
-
sessionId: string;
|
|
149
|
-
story: string;
|
|
150
|
-
paraId: string;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* A `w:p` occurrence in the exact source package the session was opened
|
|
154
|
-
* from: its zero-based position among the part's paragraphs, nested ones
|
|
155
|
-
* included, as the source bytes hold them rather than as edited since.
|
|
156
|
-
*/
|
|
157
|
-
interface DocxSourceParagraphAnchor {
|
|
158
|
-
kind: 'source';
|
|
159
|
-
packageSha256: string;
|
|
160
|
-
/** OPC part name, such as `/word/document.xml`. */
|
|
161
|
-
partUri: string;
|
|
162
|
-
paragraphOrdinal: number;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* A saved Word paragraph ID within its source story. It resolves after the
|
|
166
|
-
* saved file is reopened, but it is scoped to a document the host chose: an
|
|
167
|
-
* eight-digit ID is not a document identifier.
|
|
168
|
-
*/
|
|
169
|
-
interface DocxPersistedParagraphAnchor {
|
|
170
|
-
kind: 'persisted';
|
|
171
|
-
story: DocxSourceStory;
|
|
172
|
-
paraId: string;
|
|
173
|
-
}
|
|
174
|
-
type DocxParagraphAnchor = DocxSessionParagraphAnchor | DocxSourceParagraphAnchor | DocxPersistedParagraphAnchor;
|
|
175
|
-
/** A paragraph a resolution, assignment or diagnostic names. */
|
|
176
|
-
type DocxParagraphRef = DocxSessionParagraphAnchor | DocxSourceParagraphAnchor;
|
|
177
|
-
/**
|
|
178
|
-
* Where a Word paragraph ID comes from: `source` IDs are already in the source
|
|
179
|
-
* package; the others are prepared by the session and appear on save.
|
|
180
|
-
*/
|
|
181
|
-
type DocxParagraphIdOrigin = 'source' | 'authored' | 'persisted' | 'repaired';
|
|
182
|
-
/** Where a paragraph comes from; `synthetic` ones are editor-only until authored into. */
|
|
183
|
-
type DocxParagraphOrigin = 'source' | 'authored' | 'synthetic';
|
|
184
|
-
interface DocxParagraphIdentity {
|
|
185
|
-
/** `null` for a source paragraph outside the session stories. */
|
|
186
|
-
session: DocxSessionParagraphAnchor | null;
|
|
187
|
-
origin: DocxParagraphOrigin;
|
|
188
|
-
/** The Word paragraph ID the paragraph saves with, or `null` when it saves without one. */
|
|
189
|
-
ooxmlParaId: string | null;
|
|
190
|
-
idOrigin: DocxParagraphIdOrigin | null;
|
|
191
|
-
/** `null` without a Word paragraph ID or a source story. */
|
|
192
|
-
persisted: DocxPersistedParagraphAnchor | null;
|
|
193
|
-
/** `null` unless the paragraph occurs in the retained source package. */
|
|
194
|
-
source: DocxSourceParagraphAnchor | null;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Every paragraph's identities: session paragraphs with stories sorted and in
|
|
198
|
-
* document order, then source paragraphs outside the stories in package order.
|
|
199
|
-
*/
|
|
200
|
-
interface DocxParagraphIdentitySnapshot {
|
|
201
|
-
sessionId: string;
|
|
202
|
-
/** SHA-256 of the retained source package, or `null` without one. */
|
|
203
|
-
packageSha256: string | null;
|
|
204
|
-
paragraphs: DocxParagraphIdentity[];
|
|
205
|
-
}
|
|
206
|
-
/** A paragraph `YrsSession.persistParagraphIds()` gave a Word paragraph ID. */
|
|
207
|
-
interface DocxParagraphIdAssignment {
|
|
208
|
-
paragraph: DocxParagraphRef;
|
|
209
|
-
/** The duplicate session key the paragraph carried before repair. */
|
|
210
|
-
replacedParaId: string | null;
|
|
211
|
-
/** The duplicate Word paragraph ID it replaces. */
|
|
212
|
-
previousOoxmlParaId: string | null;
|
|
213
|
-
ooxmlParaId: string;
|
|
214
|
-
idOrigin: 'persisted' | 'repaired';
|
|
215
|
-
/** `null` when the paragraph has no source story. */
|
|
216
|
-
persisted: DocxPersistedParagraphAnchor | null;
|
|
217
|
-
}
|
|
218
|
-
type DocxParagraphIdDiagnostic = {
|
|
219
|
-
/** Saved claims to one ID conflict; the paragraphs keep it and resolve as ambiguous. */
|
|
220
|
-
kind: 'conflicting-saved-ids';
|
|
221
|
-
ooxmlParaId: string;
|
|
222
|
-
paragraphs: DocxParagraphRef[];
|
|
223
|
-
} | {
|
|
224
|
-
/** No retained source package, so source paragraphs outside the stories were not covered. */
|
|
225
|
-
kind: 'no-source-package';
|
|
226
|
-
};
|
|
227
|
-
/**
|
|
228
|
-
* Why `YrsSession.persistParagraphIds()` changed nothing: a duplicated
|
|
229
|
-
* comment paragraph ID the comment companion parts reference, where which
|
|
230
|
-
* comment they mean is ambiguous.
|
|
231
|
-
*/
|
|
232
|
-
interface DocxParagraphIdRefusal {
|
|
233
|
-
kind: 'ambiguous-comment-reference';
|
|
234
|
-
ooxmlParaId: string;
|
|
235
|
-
commentIds: string[];
|
|
236
|
-
}
|
|
237
|
-
type DocxParagraphIdentityReceipt = {
|
|
238
|
-
status: 'applied';
|
|
239
|
-
assignments: DocxParagraphIdAssignment[];
|
|
240
|
-
diagnostics: DocxParagraphIdDiagnostic[];
|
|
241
|
-
} | {
|
|
242
|
-
status: 'refused';
|
|
243
|
-
refusal: DocxParagraphIdRefusal;
|
|
244
|
-
};
|
|
245
|
-
type DocxParagraphAnchorResult = {
|
|
246
|
-
status: 'found';
|
|
247
|
-
anchor: DocxParagraphRef;
|
|
248
|
-
} | {
|
|
249
|
-
status: 'missing';
|
|
250
|
-
} | {
|
|
251
|
-
status: 'ambiguous';
|
|
252
|
-
candidates: DocxParagraphRef[];
|
|
253
|
-
} | {
|
|
254
|
-
status: 'unsupported';
|
|
255
|
-
reason: 'foreign-session' | 'foreign-package' | 'no-source-package';
|
|
256
|
-
};
|
|
257
|
-
/**
|
|
258
|
-
* The paragraph IDs a session save applies, as the package writer's
|
|
259
|
-
* `paragraphIds`, with each spliced part's paragraphs as `[ordinal, session key]`. @internal
|
|
260
|
-
*/
|
|
261
|
-
interface DocxParagraphSavePlan extends Omit<RustParagraphIds, 'splicedParts'> {
|
|
262
|
-
splicedParts?: Array<{
|
|
263
|
-
part: string;
|
|
264
|
-
sha256: string;
|
|
265
|
-
paragraphs: Array<[number, string]>;
|
|
266
|
-
changed: number[];
|
|
267
|
-
}>;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Host proposals: tracked changes a host proposes by paragraph anchor and search, grouped by the
|
|
272
|
-
* host's proposal ids. A round resolves against one version and applies as one atomic batch
|
|
273
|
-
* outside undo history. Decisions only change how the proposals' revisions render: the
|
|
274
|
-
* revisions stay in the document, and the document version and history are untouched until the
|
|
275
|
-
* host withdraws the proposals.
|
|
276
|
-
*/
|
|
277
|
-
|
|
278
|
-
type DocxProposalState = 'proposed' | 'accepted' | 'rejected';
|
|
279
|
-
/** Which non-overlapping matches of a search a proposal replaces; numbers count from 1. */
|
|
280
|
-
type DocxOccurrence = 'first' | 'all' | number;
|
|
281
|
-
/**
|
|
282
|
-
* One proposal. `replaceText` with `replaceWith: ''` deletes; with `search: ''` it fills a
|
|
283
|
-
* paragraph whose accepted text is empty (an inline atom counts as text), where the empty search
|
|
284
|
-
* matches once, at offset 0. `insertText` offsets are UTF-16 units of the paragraph's accepted
|
|
285
|
-
* text.
|
|
286
|
-
*/
|
|
287
|
-
type DocxProposalInput = {
|
|
288
|
-
id: string;
|
|
289
|
-
paragraph: DocxParagraphAnchor;
|
|
290
|
-
suggest: DocxEditSuggestion;
|
|
291
|
-
} & ({
|
|
292
|
-
op: 'replaceText';
|
|
293
|
-
search: string;
|
|
294
|
-
replaceWith: string;
|
|
295
|
-
occurrence?: DocxOccurrence;
|
|
296
|
-
} | {
|
|
297
|
-
op: 'insertText';
|
|
298
|
-
at: 'start' | 'end' | {
|
|
299
|
-
offset: number;
|
|
300
|
-
};
|
|
301
|
-
text: string;
|
|
302
|
-
});
|
|
303
|
-
interface DocxProposalRequest {
|
|
304
|
-
expectVersion: string;
|
|
305
|
-
proposals: readonly DocxProposalInput[];
|
|
306
|
-
}
|
|
307
|
-
interface DocxProposalRecord {
|
|
308
|
-
id: string;
|
|
309
|
-
state: DocxProposalState;
|
|
310
|
-
paragraph: DocxSessionParagraphAnchor;
|
|
311
|
-
revisionIds: readonly string[];
|
|
312
|
-
changed: boolean;
|
|
313
|
-
}
|
|
314
|
-
interface DocxProposalSnapshot {
|
|
315
|
-
version: string;
|
|
316
|
-
/** Increments whenever a decision changes. */
|
|
317
|
-
previewVersion: number;
|
|
318
|
-
proposals: readonly DocxProposalRecord[];
|
|
319
|
-
}
|
|
320
|
-
/** @internal */
|
|
321
|
-
interface DocxProposalRegistryState {
|
|
322
|
-
previewVersion: number;
|
|
323
|
-
entries: {
|
|
324
|
-
record: DocxProposalRecord;
|
|
325
|
-
key: string;
|
|
326
|
-
suggest: {
|
|
327
|
-
author: string;
|
|
328
|
-
date: string;
|
|
329
|
-
};
|
|
330
|
-
}[];
|
|
331
|
-
}
|
|
332
|
-
type DocxProposalFailure = Omit<DocxEditFailure, 'code'> & {
|
|
333
|
-
code: DocxEditFailureCode | 'stale-preview' | 'unknown-proposal' | 'proposal-id-conflict';
|
|
334
|
-
proposalId?: string;
|
|
335
|
-
};
|
|
336
|
-
type DocxProposalResult = {
|
|
337
|
-
ok: true;
|
|
338
|
-
snapshot: DocxProposalSnapshot;
|
|
339
|
-
} | {
|
|
340
|
-
ok: false;
|
|
341
|
-
version: string;
|
|
342
|
-
failure: DocxProposalFailure;
|
|
343
|
-
};
|
|
344
|
-
/** Ids that name no proposal are ignored, so a retried withdrawal changes nothing. */
|
|
345
|
-
interface DocxProposalWithdrawRequest {
|
|
346
|
-
expectVersion: string;
|
|
347
|
-
ids: readonly string[];
|
|
348
|
-
}
|
|
349
|
-
interface DocxProposalStateRequest {
|
|
350
|
-
expectVersion: string;
|
|
351
|
-
expectPreviewVersion: number;
|
|
352
|
-
changes: readonly {
|
|
353
|
-
id: string;
|
|
354
|
-
state: DocxProposalState;
|
|
355
|
-
}[];
|
|
356
|
-
}
|
|
357
|
-
/** The revision decisions a snapshot shows, for `YrsRenderEnv.revisionPreview`. */
|
|
358
|
-
declare function proposalRevisionPreview(snapshot: DocxProposalSnapshot): Readonly<Record<string, 'accepted' | 'rejected'>> | undefined;
|
|
359
|
-
|
|
360
|
-
/** One native paragraph in the yrs-backed display-position projection. */
|
|
361
|
-
interface YrsInputParagraphSpan {
|
|
362
|
-
paraId: string;
|
|
363
|
-
/** Number of UTF-16/inline units before the paragraph's pilcrow. */
|
|
364
|
-
length: number;
|
|
365
|
-
/** Block start emitted by the yrs display-position projection. */
|
|
366
|
-
displayStart: number;
|
|
367
|
-
}
|
|
368
|
-
/**
|
|
369
|
-
* Live converter between display-list positions and public yrs Locs.
|
|
370
|
-
*
|
|
371
|
-
* A native paragraph of length N occupies N+2 display positions (open token,
|
|
372
|
-
* content, close token), so this map can be rebuilt directly from the live yrs
|
|
373
|
-
* paragraph spans after every structural edit.
|
|
374
|
-
*/
|
|
375
|
-
interface YrsInputPositionMap {
|
|
376
|
-
story: string;
|
|
377
|
-
paragraphs: readonly YrsInputParagraphSpan[];
|
|
378
|
-
}
|
|
379
|
-
interface YrsInputParagraphSeed {
|
|
380
|
-
paraId: string;
|
|
381
|
-
length: number;
|
|
382
|
-
}
|
|
383
|
-
declare function createYrsInputPositionMap(story: string, seeds: readonly YrsInputParagraphSeed[]): YrsInputPositionMap;
|
|
384
|
-
/** Convert a live yrs location to the position used by display-list geometry. */
|
|
385
|
-
declare function yrsLocToDisplayPosition(map: YrsInputPositionMap, loc: YrsLoc): number;
|
|
386
|
-
/** Convert a display-list hit position to a paragraph-keyed yrs location. */
|
|
387
|
-
declare function displayPositionToYrsLoc(map: YrsInputPositionMap, position: number): YrsLoc | null;
|
|
388
|
-
/** Compare two Locs in document order using one live map. */
|
|
389
|
-
declare function compareYrsLocs(map: YrsInputPositionMap, a: YrsLoc, b: YrsLoc): number;
|
|
390
|
-
|
|
391
|
-
/** Resolved styling for the worker-painted caret (the worker cannot read CSS vars). */
|
|
392
|
-
interface ResidentCaretPaintStyle {
|
|
393
|
-
color: string;
|
|
394
|
-
/** CSS-px stroke width, matching the DOM caret's un-zoomed width. */
|
|
395
|
-
width: number;
|
|
396
|
-
}
|
|
397
|
-
/** Device-px caret rect: geometry scales by dpr*zoom, stroke width by dpr only
|
|
398
|
-
* (the DOM caret keeps its CSS-px width across zoom levels). */
|
|
399
|
-
declare function residentCaretDeviceRect(rect: Pick<YrsResidentCaretRect, 'x' | 'y' | 'height'>, style: ResidentCaretPaintStyle, devicePixelRatio: number, zoom: number): {
|
|
400
|
-
x: number;
|
|
401
|
-
y: number;
|
|
402
|
-
width: number;
|
|
403
|
-
height: number;
|
|
404
|
-
};
|
|
405
|
-
declare function residentCaretSnapshotForFrame(snapshot: YrsResidentCaretSnapshot, frame: RetainedFrame): YrsResidentCaretSnapshot | null;
|
|
406
|
-
|
|
407
|
-
type PositionReader = Pick<YrsSession, 'hasStory' | 'storySegments'>;
|
|
408
|
-
type YrsLocProjection = Pick<YrsPositionProjection, 'positionForLoc'>;
|
|
409
|
-
type YrsPositionOutline = Record<string, {
|
|
410
|
-
contentStart: number;
|
|
411
|
-
size: number;
|
|
412
|
-
paragraphs: Array<{
|
|
413
|
-
paraId: string;
|
|
414
|
-
displayStart: number;
|
|
415
|
-
length: number;
|
|
416
|
-
leading: number;
|
|
417
|
-
}>;
|
|
418
|
-
}>;
|
|
419
|
-
declare function createYrsLocProjectionFromOutline(outline: YrsPositionOutline): YrsLocProjection;
|
|
420
|
-
/** @internal */
|
|
421
|
-
interface YrsProjectedNode {
|
|
422
|
-
kind: string;
|
|
423
|
-
start: number;
|
|
424
|
-
nodeSize: number;
|
|
425
|
-
attrs: Record<string, unknown>;
|
|
426
|
-
story: string;
|
|
427
|
-
}
|
|
428
|
-
/** @internal */
|
|
429
|
-
interface YrsProjectedTable extends YrsProjectedNode {
|
|
430
|
-
kind: 'table';
|
|
431
|
-
tableIndex: number;
|
|
432
|
-
widthsTwips: number[];
|
|
433
|
-
rowCount: number;
|
|
434
|
-
cells: YrsProjectedCell[];
|
|
435
|
-
}
|
|
436
|
-
/** @internal */
|
|
437
|
-
interface YrsProjectedCell {
|
|
438
|
-
row: number;
|
|
439
|
-
column: number;
|
|
440
|
-
rowspan: number;
|
|
441
|
-
colspan: number;
|
|
442
|
-
story: string;
|
|
443
|
-
start: number;
|
|
444
|
-
contentStart: number;
|
|
445
|
-
nodeSize: number;
|
|
446
|
-
attrs: Record<string, unknown>;
|
|
447
|
-
}
|
|
448
|
-
/** @internal */
|
|
449
|
-
interface YrsPointerProjectionTarget {
|
|
450
|
-
story: string;
|
|
451
|
-
displayPosition: number;
|
|
452
|
-
cell?: YrsCellLoc;
|
|
453
|
-
}
|
|
454
|
-
/** @internal */
|
|
455
|
-
interface YrsStorySegmentSource {
|
|
456
|
-
segments(story: string): YrsStorySegment[];
|
|
457
|
-
}
|
|
458
|
-
/** @internal */
|
|
459
|
-
declare function createYrsPositionProjection(session: PositionReader, rootStory: string, source?: YrsStorySegmentSource): YrsPositionProjection | null;
|
|
460
|
-
/** @internal */
|
|
461
|
-
declare function projectYrsDisplayPosition(position: number | PointPosition, getProjection: (rootStory: string) => YrsPositionProjection | null): YrsPointerProjectionTarget | null;
|
|
462
|
-
/** @internal */
|
|
463
|
-
declare class YrsPositionProjection {
|
|
464
|
-
readonly rootStory: string;
|
|
465
|
-
private readonly stories;
|
|
466
|
-
private readonly nodes;
|
|
467
|
-
private readonly tables;
|
|
468
|
-
private readonly source;
|
|
469
|
-
private readonly paragraphsById;
|
|
470
|
-
constructor(session: Pick<YrsSession, 'storySegments'>, rootStory: string, source?: YrsStorySegmentSource);
|
|
471
|
-
get size(): number;
|
|
472
|
-
nodeAt(position: number): YrsProjectedNode | null;
|
|
473
|
-
tableAtPosition(position: number): YrsProjectedTable | null;
|
|
474
|
-
tableAtStart(start: number): YrsProjectedTable | null;
|
|
475
|
-
tableStartForLoc(at: YrsCellLoc): number | null;
|
|
476
|
-
cellPosition(tableStart: number, row: number, column: number): number | null;
|
|
477
|
-
targetAt(position: number): YrsPointerProjectionTarget;
|
|
478
|
-
positionForLoc(loc: YrsLoc): number | null;
|
|
479
|
-
/** First paragraph for each paraId. */
|
|
480
|
-
private paragraphIndex;
|
|
481
|
-
bookmarkPosition(name: string): number | null;
|
|
482
|
-
private buildStory;
|
|
483
|
-
private inputPositionAt;
|
|
484
|
-
private buildTable;
|
|
485
|
-
}
|
|
486
|
-
/** @internal */
|
|
487
|
-
declare function yrsLocToProjectedDisplayPosition(reader: Pick<YrsSession, 'hasStory' | 'paragraphSpans'>, projectionFor: (rootStory: string) => YrsLocProjection | null, loc: YrsLoc, activeRootStory?: string, inputMap?: (story: string) => YrsInputPositionMap | null): number | null;
|
|
488
|
-
|
|
489
|
-
/** @internal */
|
|
490
|
-
interface ResidentSearchMatch {
|
|
491
|
-
story: string;
|
|
492
|
-
paraId: string;
|
|
493
|
-
start: number;
|
|
494
|
-
displayFrom: number;
|
|
495
|
-
displayTo: number;
|
|
496
|
-
}
|
|
497
|
-
/** @internal */
|
|
498
|
-
interface ResidentSearchResult {
|
|
499
|
-
matches: ResidentSearchMatch[];
|
|
500
|
-
carried: number;
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
/** @internal */
|
|
504
|
-
interface AnchorResolutionFailure {
|
|
505
|
-
ok: false;
|
|
506
|
-
failure: {
|
|
507
|
-
code: 'stale-version' | 'missing-target' | 'ambiguous-target' | 'layout-unavailable' | 'unsupported' | 'unknown-proposal';
|
|
508
|
-
message: string;
|
|
509
|
-
};
|
|
510
|
-
}
|
|
511
|
-
/** @internal */
|
|
512
|
-
type AnchorReader = Pick<YrsSession, 'resolveParagraphAnchor' | 'hasStory' | 'paragraphSpans' | 'storySegments' | 'findText' | 'listRevisions'>;
|
|
513
|
-
/** @internal */
|
|
514
|
-
type ProposalGeometryReader = AnchorReader & Pick<YrsSession, 'storyIds' | 'paragraphs' | 'paragraphIdCount' | 'locateParagraph' | 'version'> & {
|
|
515
|
-
proposalRevisions?(ids: readonly string[]): readonly ProposalGeometryRevision[];
|
|
516
|
-
positionOutline?(root: string): YrsPositionOutline | null;
|
|
517
|
-
};
|
|
518
|
-
/** @internal */
|
|
519
|
-
type ProposalGeometryRevision = Pick<ReturnType<AnchorReader['listRevisions']>[number], 'revisionId' | 'kind' | 'story' | 'range'>;
|
|
520
|
-
/** @internal */
|
|
521
|
-
type AnchorGeometryTarget = {
|
|
522
|
-
kind: 'proposal';
|
|
523
|
-
id: string;
|
|
524
|
-
} | {
|
|
525
|
-
kind: 'revision';
|
|
526
|
-
revisionId: string;
|
|
527
|
-
} | {
|
|
528
|
-
kind: 'paragraph';
|
|
529
|
-
paragraph: DocxParagraphAnchor;
|
|
530
|
-
} | {
|
|
531
|
-
kind: 'search';
|
|
532
|
-
paragraph: DocxParagraphAnchor;
|
|
533
|
-
text: string;
|
|
534
|
-
occurrence?: DocxOccurrence;
|
|
535
|
-
} | {
|
|
536
|
-
kind: 'range';
|
|
537
|
-
version: string;
|
|
538
|
-
range: DocxTextRange;
|
|
539
|
-
};
|
|
540
|
-
/** @internal */
|
|
541
|
-
interface RawAnchorRange {
|
|
542
|
-
start: YrsLoc;
|
|
543
|
-
end: YrsLoc;
|
|
544
|
-
}
|
|
545
|
-
type AnchorResolution = {
|
|
546
|
-
ok: true;
|
|
547
|
-
ranges: RawAnchorRange[];
|
|
548
|
-
paragraph: YrsLoc;
|
|
549
|
-
} | AnchorResolutionFailure;
|
|
550
|
-
/** @internal */
|
|
551
|
-
declare function anchorFailure(code: AnchorResolutionFailure['failure']['code'], message: string): AnchorResolutionFailure;
|
|
552
|
-
/** @internal */
|
|
553
|
-
declare function isBodyStory(story: string): boolean;
|
|
554
|
-
/** @internal */
|
|
555
|
-
declare function textRangeToRaw(segments: readonly YrsStorySegment[], range: DocxTextRange): {
|
|
556
|
-
ok: true;
|
|
557
|
-
range: RawAnchorRange;
|
|
558
|
-
} | AnchorResolutionFailure;
|
|
559
|
-
/** @internal */
|
|
560
|
-
declare function hiddenRanges(session: AnchorReader, version: string, snapshot: DocxProposalSnapshot | null, revisions?: readonly ProposalGeometryRevision[]): RawAnchorRange[];
|
|
561
|
-
/** @internal */
|
|
562
|
-
declare function resolveAnchorTarget(session: AnchorReader, target: AnchorGeometryTarget, version: string, snapshot?: DocxProposalSnapshot | null, proposalRevisions?: readonly ProposalGeometryRevision[]): AnchorResolution;
|
|
563
|
-
/** @internal */
|
|
564
|
-
interface ProposalDisplayTarget {
|
|
565
|
-
ranges: {
|
|
566
|
-
from: number;
|
|
567
|
-
to: number;
|
|
568
|
-
}[];
|
|
569
|
-
paragraph: number | null;
|
|
570
|
-
}
|
|
571
|
-
/** @internal */
|
|
572
|
-
type ProposalGeometryTarget = ({
|
|
573
|
-
ok: true;
|
|
574
|
-
} & ProposalDisplayTarget) | AnchorResolutionFailure;
|
|
575
|
-
/** @internal */
|
|
576
|
-
interface ProposalGeometryMirror {
|
|
577
|
-
version: string;
|
|
578
|
-
previewVersion: number;
|
|
579
|
-
proposals: string;
|
|
580
|
-
targets: Record<string, ProposalGeometryTarget>;
|
|
581
|
-
navigationTargets?: Record<string, ReturnType<typeof resolveNavigationTarget>>;
|
|
582
|
-
hidden: {
|
|
583
|
-
from: number;
|
|
584
|
-
to: number;
|
|
585
|
-
}[];
|
|
586
|
-
}
|
|
587
|
-
/** @internal */
|
|
588
|
-
declare function proposalSetIdentity(snapshot: DocxProposalSnapshot): string;
|
|
589
|
-
/** @internal */
|
|
590
|
-
declare function computeProposalGeometryMirror(reader: ProposalGeometryReader, snapshot: DocxProposalSnapshot, includeNavigationTargets?: boolean): ProposalGeometryMirror;
|
|
591
|
-
/** @internal */
|
|
592
|
-
declare function resolveMirroredNavigationTarget(mirror: ProposalGeometryMirror | null, snapshot: DocxProposalSnapshot, story: string, paraId: string): ReturnType<typeof resolveNavigationTarget> | null;
|
|
593
|
-
/** @internal */
|
|
594
|
-
declare function resolveNavigationTarget(reader: ProposalGeometryReader, story: string, paraId: string): {
|
|
595
|
-
loc: YrsLoc;
|
|
596
|
-
position: number;
|
|
597
|
-
} | 'missing-target' | 'ambiguous-target' | 'unsupported';
|
|
598
|
-
|
|
599
|
-
/** @internal */
|
|
600
|
-
type ResidentProposalOperation = {
|
|
601
|
-
kind: 'propose';
|
|
602
|
-
request: DocxProposalRequest;
|
|
603
|
-
} | {
|
|
604
|
-
kind: 'setStates';
|
|
605
|
-
request: DocxProposalStateRequest;
|
|
606
|
-
} | {
|
|
607
|
-
kind: 'withdraw';
|
|
608
|
-
request: DocxProposalWithdrawRequest;
|
|
609
|
-
} | {
|
|
610
|
-
kind: 'snapshot';
|
|
611
|
-
};
|
|
612
|
-
/** @internal */
|
|
613
|
-
interface ResidentProposalResponse {
|
|
614
|
-
result?: DocxProposalResult;
|
|
615
|
-
mirror: {
|
|
616
|
-
version: string;
|
|
617
|
-
proposals: DocxProposalRegistryState;
|
|
618
|
-
};
|
|
619
|
-
changedStories: string[];
|
|
620
|
-
updates: ArrayBuffer[];
|
|
621
|
-
stateVector: ArrayBuffer;
|
|
622
|
-
geometry: ProposalGeometryMirror;
|
|
623
|
-
fontRequirements?: {
|
|
624
|
-
layoutInput: string;
|
|
625
|
-
requirementsJson: string;
|
|
626
|
-
};
|
|
627
|
-
}
|
|
628
|
-
/** @internal */
|
|
629
|
-
type ResidentDocumentRead = {
|
|
630
|
-
kind: 'paragraphIdentities';
|
|
631
|
-
} | {
|
|
632
|
-
kind: 'resolveParagraphAnchors';
|
|
633
|
-
anchors: DocxParagraphAnchor[];
|
|
634
|
-
} | {
|
|
635
|
-
kind: 'readParagraphs';
|
|
636
|
-
request: DocxReadParagraphsRequest;
|
|
637
|
-
} | {
|
|
638
|
-
kind: 'searchText';
|
|
639
|
-
query: string;
|
|
640
|
-
caseSensitive: boolean;
|
|
641
|
-
carry?: YrsStickyPosition | null;
|
|
642
|
-
} | {
|
|
643
|
-
kind: 'stickyAnchors';
|
|
644
|
-
locs: YrsLoc[];
|
|
645
|
-
version: string;
|
|
646
|
-
} | {
|
|
647
|
-
kind: 'navigationTarget';
|
|
648
|
-
story: string;
|
|
649
|
-
paraId: string;
|
|
650
|
-
};
|
|
651
|
-
/** @internal */
|
|
652
|
-
interface ResidentDocumentReadValues {
|
|
653
|
-
paragraphIdentities: DocxParagraphIdentitySnapshot;
|
|
654
|
-
resolveParagraphAnchors: {
|
|
655
|
-
results: DocxParagraphAnchorResult[];
|
|
656
|
-
};
|
|
657
|
-
readParagraphs: DocxReadParagraphsResult;
|
|
658
|
-
navigationTarget: ReturnType<typeof resolveNavigationTarget>;
|
|
659
|
-
searchText: ResidentSearchResult;
|
|
660
|
-
stickyAnchors: Array<YrsStickyPosition | null>;
|
|
661
|
-
}
|
|
662
|
-
/** @internal */
|
|
663
|
-
type ResidentEngineWorkerHostModule = {
|
|
664
|
-
type: 'editModule';
|
|
665
|
-
module: WebAssembly.Module | null;
|
|
666
|
-
};
|
|
667
|
-
type ResidentEngineWorkerRequest = {
|
|
668
|
-
id: number;
|
|
669
|
-
type: 'warm';
|
|
670
|
-
hostModule?: true;
|
|
671
|
-
} | {
|
|
672
|
-
id: number;
|
|
673
|
-
type: 'bootstrap';
|
|
674
|
-
snapshot: YrsResidentWorkerSnapshot;
|
|
675
|
-
extras: string;
|
|
676
|
-
expectedFrameEpoch: number;
|
|
677
|
-
layoutExtras?: string;
|
|
678
|
-
/** Pages `[start, end)` a full build compiles; the rest stay unbuilt. */
|
|
679
|
-
displayWindow?: [number, number];
|
|
680
|
-
retainBuiltPages?: boolean;
|
|
681
|
-
/**
|
|
682
|
-
* Lay out only as much of the body as fills this many pages; a reply
|
|
683
|
-
* marked `layoutProvisional` is finished by `completeLayout`.
|
|
684
|
-
*/
|
|
685
|
-
provisionalPages?: number;
|
|
686
|
-
/**
|
|
687
|
-
* The document replaces the one this worker showed, which the host
|
|
688
|
-
* hands over from: keep the attached page surfaces for its pages.
|
|
689
|
-
*/
|
|
690
|
-
keepSurfaces?: boolean;
|
|
691
|
-
/** Lay out the document `open` seeded here, not the snapshot's state. */
|
|
692
|
-
opened?: boolean;
|
|
693
|
-
/** The most the worker's editing core may allocate at once. */
|
|
694
|
-
heapLimitBytes?: number;
|
|
695
|
-
} | {
|
|
696
|
-
id: number;
|
|
697
|
-
type: 'open';
|
|
698
|
-
/** The DOCX package, parsed and seeded in a fresh session here. */
|
|
699
|
-
bytes: ArrayBuffer;
|
|
700
|
-
/** The package's SHA-256, when the caller already took it. */
|
|
701
|
-
digest?: string;
|
|
702
|
-
generation?: string;
|
|
703
|
-
/** The most the worker's editing core may allocate at once. */
|
|
704
|
-
heapLimitBytes?: number;
|
|
705
|
-
/**
|
|
706
|
-
* Opens a display-only preview of the first `previewBlocks` body blocks instead. A later
|
|
707
|
-
* `open` of the whole document replaces it.
|
|
708
|
-
*/
|
|
709
|
-
previewBlocks?: number;
|
|
710
|
-
} | {
|
|
711
|
-
id: number;
|
|
712
|
-
type: 'fontRequirements';
|
|
713
|
-
layoutInput: string;
|
|
714
|
-
} | {
|
|
715
|
-
id: number;
|
|
716
|
-
type: 'encodeState';
|
|
717
|
-
} | {
|
|
718
|
-
id: number;
|
|
719
|
-
type: 'revisionCount';
|
|
720
|
-
} | {
|
|
721
|
-
id: number;
|
|
722
|
-
type: 'proposal';
|
|
723
|
-
operation: ResidentProposalOperation;
|
|
724
|
-
} | {
|
|
725
|
-
id: number;
|
|
726
|
-
type: 'documentRead';
|
|
727
|
-
read: ResidentDocumentRead;
|
|
728
|
-
} | {
|
|
729
|
-
id: number;
|
|
730
|
-
type: 'sync';
|
|
731
|
-
snapshot: YrsResidentWorkerSnapshot;
|
|
732
|
-
extras: string;
|
|
733
|
-
expectedFrameEpoch: number;
|
|
734
|
-
paintCaret: boolean;
|
|
735
|
-
/**
|
|
736
|
-
* Display extras without the header/footer payload. When present, the
|
|
737
|
-
* snapshot's layout is authoritative: the worker completes the extras
|
|
738
|
-
* from the layout it runs and returns that layout as `layoutJson`.
|
|
739
|
-
*/
|
|
740
|
-
layoutExtras?: string;
|
|
741
|
-
displayWindow?: [number, number];
|
|
742
|
-
retainBuiltPages?: boolean;
|
|
743
|
-
provisionalPages?: number;
|
|
744
|
-
} | {
|
|
745
|
-
id: number;
|
|
746
|
-
type: 'buildPages';
|
|
747
|
-
pages: number[];
|
|
748
|
-
expectedFrameEpoch: number;
|
|
749
|
-
paintCaret: boolean;
|
|
750
|
-
background?: boolean;
|
|
751
|
-
} | {
|
|
752
|
-
id: number;
|
|
753
|
-
type: 'releasePages';
|
|
754
|
-
pages: Array<{
|
|
755
|
-
index: number;
|
|
756
|
-
pageId: string;
|
|
757
|
-
}>;
|
|
758
|
-
expectedFrameEpoch: number;
|
|
759
|
-
paintCaret: boolean;
|
|
760
|
-
} | {
|
|
761
|
-
id: number;
|
|
762
|
-
type: 'completeLayout';
|
|
763
|
-
expectedFrameEpoch: number;
|
|
764
|
-
paintCaret: boolean;
|
|
765
|
-
/**
|
|
766
|
-
* Measure the rest this many body blocks a step to start with, letting
|
|
767
|
-
* requests that arrive meanwhile run between steps; absent, in one step.
|
|
768
|
-
*/
|
|
769
|
-
sliceBlocks?: number;
|
|
770
|
-
} | {
|
|
771
|
-
id: number;
|
|
772
|
-
type: 'buildFrame';
|
|
773
|
-
extras: string;
|
|
774
|
-
expectedFrameEpoch: number;
|
|
775
|
-
paintCaret: boolean;
|
|
776
|
-
displayWindow?: [number, number];
|
|
777
|
-
retainBuiltPages?: boolean;
|
|
778
|
-
} | {
|
|
779
|
-
id: number;
|
|
780
|
-
type: 'applyInput';
|
|
781
|
-
text: string;
|
|
782
|
-
selection: YrsSelection;
|
|
783
|
-
expectedFrameEpoch: number;
|
|
784
|
-
profile: boolean;
|
|
785
|
-
paintCaret: boolean;
|
|
786
|
-
displayWindow?: [number, number];
|
|
787
|
-
retainBuiltPages?: boolean;
|
|
788
|
-
} | {
|
|
789
|
-
id: number;
|
|
790
|
-
type: 'applyDelete';
|
|
791
|
-
direction: 'backward' | 'forward';
|
|
792
|
-
count: number;
|
|
793
|
-
selection: YrsSelection;
|
|
794
|
-
expectedFrameEpoch: number;
|
|
795
|
-
profile: boolean;
|
|
796
|
-
paintCaret: boolean;
|
|
797
|
-
displayWindow?: [number, number];
|
|
798
|
-
retainBuiltPages?: boolean;
|
|
799
|
-
} | {
|
|
800
|
-
id: number;
|
|
801
|
-
type: 'applyUpdate';
|
|
802
|
-
update: Uint8Array;
|
|
803
|
-
selection: YrsSelection | null;
|
|
804
|
-
} | {
|
|
805
|
-
id: number;
|
|
806
|
-
type: 'attachCanvases';
|
|
807
|
-
pages: Array<{
|
|
808
|
-
pageId: string;
|
|
809
|
-
canvas: OffscreenCanvas;
|
|
810
|
-
}>;
|
|
811
|
-
activePageIds: string[];
|
|
812
|
-
devicePixelRatio: number;
|
|
813
|
-
zoom: number;
|
|
814
|
-
caretStyle: ResidentCaretPaintStyle;
|
|
815
|
-
} | {
|
|
816
|
-
id: number;
|
|
817
|
-
type: 'eraseCaret';
|
|
818
|
-
} | {
|
|
819
|
-
id: number;
|
|
820
|
-
type: 'destroy';
|
|
821
|
-
};
|
|
822
|
-
type ResidentEngineWorkerResponse = ({
|
|
823
|
-
id: number;
|
|
824
|
-
ok: true;
|
|
825
|
-
frame?: ArrayBuffer;
|
|
826
|
-
pageFrames?: ArrayBuffer[];
|
|
827
|
-
pageBuildSuperseded?: boolean;
|
|
828
|
-
superseded?: true;
|
|
829
|
-
updates?: ArrayBuffer[];
|
|
830
|
-
engineMs?: number;
|
|
831
|
-
workerTotalMs?: number;
|
|
832
|
-
engineProfile?: YrsEngineApplyProfile;
|
|
833
|
-
caret?: YrsResidentCaretSnapshot;
|
|
834
|
-
selection?: YrsSelection | null;
|
|
835
|
-
/** The presented frame carries the worker-painted caret line. */
|
|
836
|
-
caretPainted?: boolean;
|
|
837
|
-
replayMs?: number;
|
|
838
|
-
replayedPages?: number;
|
|
839
|
-
layoutRevision?: number;
|
|
840
|
-
/** Characters an applyDelete removed. */
|
|
841
|
-
deletedUnits?: number;
|
|
842
|
-
/** The worker replica's yrs state vector after this operation, so the
|
|
843
|
-
* next sync can ship a diff instead of the whole document state. */
|
|
844
|
-
stateVector?: ArrayBuffer;
|
|
845
|
-
/** The region layout the worker ran, for a request carrying `layoutExtras`. */
|
|
846
|
-
layoutJson?: string;
|
|
847
|
-
/** `layoutJson` covers only the first pages of the body. */
|
|
848
|
-
layoutProvisional?: boolean;
|
|
849
|
-
/** An `open` reply: the opened package's host metadata JSON. */
|
|
850
|
-
hostJson?: string;
|
|
851
|
-
/** An `open` reply: the package cannot open as a preview; nothing was opened. */
|
|
852
|
-
previewRefused?: boolean;
|
|
853
|
-
/** A `fontRequirements` reply. */
|
|
854
|
-
requirementsJson?: string;
|
|
855
|
-
/** An `encodeState` reply: the document state as one yrs v1 update. */
|
|
856
|
-
state?: ArrayBuffer;
|
|
857
|
-
revisionCount?: number;
|
|
858
|
-
/** @internal */
|
|
859
|
-
proposals?: DocxProposalRegistryState;
|
|
860
|
-
/** @internal */
|
|
861
|
-
version?: string;
|
|
862
|
-
/** @internal */
|
|
863
|
-
proposal?: ResidentProposalResponse;
|
|
864
|
-
/** @internal */
|
|
865
|
-
read?: {
|
|
866
|
-
version: string;
|
|
867
|
-
value: unknown;
|
|
868
|
-
};
|
|
869
|
-
} | {
|
|
870
|
-
id: number;
|
|
871
|
-
ok: false;
|
|
872
|
-
error: string;
|
|
873
|
-
residentUnavailable?: boolean;
|
|
874
|
-
/** A wasm trap poisoned the worker; it refuses every later request. */
|
|
875
|
-
terminal?: boolean;
|
|
876
|
-
/** The trap followed an allocation the worker's memory could not satisfy. */
|
|
877
|
-
outOfMemory?: boolean;
|
|
878
|
-
}) & {
|
|
879
|
-
/** The worker's wasm memories as the reply left. */
|
|
880
|
-
memory?: WasmModuleMemory[];
|
|
881
|
-
};
|
|
882
|
-
|
|
883
|
-
/** @internal */
|
|
884
|
-
interface ResidentProposalReply extends Omit<ResidentProposalResponse, 'updates' | 'stateVector'> {
|
|
885
|
-
updates: Uint8Array[];
|
|
886
|
-
stateVector: Uint8Array;
|
|
887
|
-
}
|
|
888
|
-
interface ResidentEngineWorkerFrame {
|
|
889
|
-
frame: Uint8Array;
|
|
890
|
-
pageFrames?: Uint8Array[];
|
|
891
|
-
updates: Uint8Array[];
|
|
892
|
-
engineMs: number;
|
|
893
|
-
workerTotalMs: number;
|
|
894
|
-
engineProfile?: YrsEngineApplyProfile;
|
|
895
|
-
caret: YrsResidentCaretSnapshot;
|
|
896
|
-
selection: YrsSelection | null;
|
|
897
|
-
/** The presented frame carries the worker-painted caret line. */
|
|
898
|
-
caretPainted: boolean;
|
|
899
|
-
replayMs: number;
|
|
900
|
-
replayedPages: number;
|
|
901
|
-
layoutRevision: number;
|
|
902
|
-
/** Characters an applyDelete removed. */
|
|
903
|
-
deletedUnits: number;
|
|
904
|
-
/** The region layout the worker ran, when the request handed it the layout. */
|
|
905
|
-
layoutJson?: string;
|
|
906
|
-
/** `layoutJson` covers only the first pages; `completeLayout` finishes it. */
|
|
907
|
-
layoutProvisional?: boolean;
|
|
908
|
-
}
|
|
909
|
-
/** A bootstrap/sync whose snapshot layout the worker runs as the only layout. */
|
|
910
|
-
interface ResidentEngineWorkerLayoutOptions {
|
|
911
|
-
/** Display extras minus the header/footer payload the worker's layout supplies. */
|
|
912
|
-
layoutExtras?: string;
|
|
913
|
-
/** The host state vector the snapshot brings the worker to. */
|
|
914
|
-
stateVector?: Uint8Array;
|
|
915
|
-
/** Lay out just the body's first pages before replying. */
|
|
916
|
-
provisionalPages?: number;
|
|
917
|
-
/** Bootstrap only: lay out the document {@link ResidentEngineWorkerClient.open} opened. */
|
|
918
|
-
opened?: boolean;
|
|
919
|
-
/** Bootstrap only: the epoch of the frame the host shows; the worker's frames follow it. */
|
|
920
|
-
frameEpoch?: number;
|
|
921
|
-
/**
|
|
922
|
-
* Bootstrap only: the most the worker's editing core may allocate at once.
|
|
923
|
-
* An allocation past it stops the worker with {@link ResidentWorkerOutOfMemoryError}.
|
|
924
|
-
*/
|
|
925
|
-
heapLimitBytes?: number;
|
|
926
|
-
}
|
|
927
|
-
/** What an {@link ResidentEngineWorkerClient.open} seeded in the worker. */
|
|
928
|
-
interface ResidentEngineWorkerOpened {
|
|
929
|
-
/** The package's host metadata JSON, for `decodeDocxHostJson`. */
|
|
930
|
-
hostJson: string;
|
|
931
|
-
/** The worker replica's state vector once seeded. */
|
|
932
|
-
stateVector: Uint8Array;
|
|
933
|
-
}
|
|
934
|
-
/** How a bootstrap or sync builds its frame. */
|
|
935
|
-
interface ResidentEngineWorkerSnapshotOptions {
|
|
936
|
-
/** Pages `[start, end)` the frame builds; the rest stay unbuilt. */
|
|
937
|
-
displayWindow?: [number, number];
|
|
938
|
-
}
|
|
939
|
-
interface ResidentEngineOffscreenPage {
|
|
940
|
-
pageId: string;
|
|
941
|
-
canvas: OffscreenCanvas;
|
|
942
|
-
}
|
|
943
|
-
interface ResidentEngineWorkerApplyResult extends ResidentEngineWorkerFrame {
|
|
944
|
-
applied: true;
|
|
945
|
-
}
|
|
946
|
-
interface ResidentEngineWorkerPort {
|
|
947
|
-
onmessage: ((event: MessageEvent<ResidentEngineWorkerResponse>) => void) | null;
|
|
948
|
-
onerror: ((event: ErrorEvent) => void) | null;
|
|
949
|
-
onmessageerror: ((event: MessageEvent) => void) | null;
|
|
950
|
-
postMessage(message: ResidentEngineWorkerRequest | ResidentEngineWorkerHostModule, transfer?: Transferable[]): void;
|
|
951
|
-
terminate(): void;
|
|
952
|
-
}
|
|
953
|
-
/** Dedicated-worker owner for resident input, pagination, and FrameDelta output. */
|
|
954
|
-
declare class ResidentEngineWorkerClient {
|
|
955
|
-
private readonly worker;
|
|
956
|
-
private readonly pending;
|
|
957
|
-
private watchdog;
|
|
958
|
-
private nextId;
|
|
959
|
-
private terminalError;
|
|
960
|
-
private ready;
|
|
961
|
-
private revision;
|
|
962
|
-
private remoteVector;
|
|
963
|
-
private appliedFontsRevision;
|
|
964
|
-
private bootstrapped;
|
|
965
|
-
/** Set once `open` is sent, with the heap limit it opened under. */
|
|
966
|
-
private openedHeapLimit;
|
|
967
|
-
private bootstraps;
|
|
968
|
-
/** The font-requirements read still in flight, shared while nothing was posted after it. */
|
|
969
|
-
private fontRead;
|
|
970
|
-
/** Id of the last snapshot request sent; replies to earlier requests must
|
|
971
|
-
* not replace the state it recorded. */
|
|
972
|
-
private lastSnapshotId;
|
|
973
|
-
private keepSurfaces;
|
|
974
|
-
private bootstrapWaiters;
|
|
975
|
-
private lastMemory;
|
|
976
|
-
private answeredFrameEpoch;
|
|
977
|
-
private retainBuiltPages;
|
|
978
|
-
private failureListener;
|
|
979
|
-
constructor(worker?: ResidentEngineWorkerPort);
|
|
980
|
-
isReady(): boolean;
|
|
981
|
-
/** @internal */
|
|
982
|
-
hasFailed(): boolean;
|
|
983
|
-
/** The worker's wasm memories as of its latest reply; null before one. */
|
|
984
|
-
memory(): WasmModuleMemory[] | null;
|
|
985
|
-
layoutRevision(): number;
|
|
986
|
-
/** @internal The newest frame epoch a reply carried; 0 before any frame. */
|
|
987
|
-
answeredFrame(): number;
|
|
988
|
-
/** @internal */
|
|
989
|
-
setRetainBuiltPages(retain: boolean): void;
|
|
990
|
-
/** @internal Called once when the worker fails, whether or not a request was waiting; not on `destroy`. */
|
|
991
|
-
onFailure(listener: ((error: Error) => void) | null): void;
|
|
992
|
-
/** @internal Whether foreground document or frame work awaits its reply. */
|
|
993
|
-
frameRequestPending(): boolean;
|
|
994
|
-
/** The worker replica's last reported yrs state vector (null before any). */
|
|
995
|
-
remoteStateVector(): Uint8Array | null;
|
|
996
|
-
/** The fonts revision this worker last applied (null before bootstrap). */
|
|
997
|
-
syncedFontsRevision(): number | null;
|
|
998
|
-
/** A bootstrap was sent; later snapshots go as syncs queued behind it. */
|
|
999
|
-
bootstrapSent(): boolean;
|
|
1000
|
-
/** Resolves once a bootstrap is sent, at once when one was. */
|
|
1001
|
-
whenBootstrapSent(): Promise<void>;
|
|
1002
|
-
/**
|
|
1003
|
-
* Starts over with another document in the same worker: the next request
|
|
1004
|
-
* is a bootstrap, which keeps the page surfaces already attached so the
|
|
1005
|
-
* new document's pages paint where the old ones were.
|
|
1006
|
-
*/
|
|
1007
|
-
rebootstrap(): void;
|
|
1008
|
-
/**
|
|
1009
|
-
* Parses and seeds a DOCX in the worker, which then holds the document:
|
|
1010
|
-
* its first layout is a bootstrap with `opened`, and the main replica loads
|
|
1011
|
-
* {@link encodeState}. A copy of `bytes` is transferred.
|
|
1012
|
-
*/
|
|
1013
|
-
open(bytes: Uint8Array, options?: {
|
|
1014
|
-
digest?: string;
|
|
1015
|
-
generation?: string;
|
|
1016
|
-
heapLimitBytes?: number;
|
|
1017
|
-
}): Promise<ResidentEngineWorkerOpened>;
|
|
1018
|
-
/**
|
|
1019
|
-
* Opens a display-only preview of the first `blocks` body blocks of a DOCX in the worker, or
|
|
1020
|
-
* resolves null when the package cannot open as a preview. Its first layout is a bootstrap
|
|
1021
|
-
* with `opened`; {@link rebootstrap} then lets {@link open} replace it with the whole document.
|
|
1022
|
-
* A copy of `bytes` is transferred.
|
|
1023
|
-
*/
|
|
1024
|
-
openPreview(bytes: Uint8Array, blocks: number, options?: {
|
|
1025
|
-
heapLimitBytes?: number;
|
|
1026
|
-
}): Promise<ResidentEngineWorkerOpened | null>;
|
|
1027
|
-
/** The font requirements of a region layout request, read from the opened document. */
|
|
1028
|
-
fontRequirements(layoutInput: string): Promise<string>;
|
|
1029
|
-
/** @internal */
|
|
1030
|
-
proposal(operation: ResidentProposalOperation): Promise<ResidentProposalReply>;
|
|
1031
|
-
/** @internal */
|
|
1032
|
-
documentRead<K extends ResidentDocumentRead['kind']>(read: ResidentDocumentRead & {
|
|
1033
|
-
kind: K;
|
|
1034
|
-
}): Promise<{
|
|
1035
|
-
version: string;
|
|
1036
|
-
value: ResidentDocumentReadValues[K];
|
|
1037
|
-
}>;
|
|
1038
|
-
/** @internal */
|
|
1039
|
-
handOver(): Promise<{
|
|
1040
|
-
state: Uint8Array;
|
|
1041
|
-
version: string;
|
|
1042
|
-
proposals: DocxProposalRegistryState;
|
|
1043
|
-
}>;
|
|
1044
|
-
/** The worker's whole document state as one yrs v1 update. */
|
|
1045
|
-
encodeState(): Promise<Uint8Array>;
|
|
1046
|
-
revisionCount(): Promise<number>;
|
|
1047
|
-
warm(): Promise<void>;
|
|
1048
|
-
bootstrap(snapshot: YrsResidentWorkerSnapshot, extras: string, options?: ResidentEngineWorkerLayoutOptions & ResidentEngineWorkerSnapshotOptions): Promise<ResidentEngineWorkerFrame>;
|
|
1049
|
-
sync(snapshot: YrsResidentWorkerSnapshot, extras: string, expectedFrameEpoch: number, paintCaret?: boolean, options?: ResidentEngineWorkerLayoutOptions & ResidentEngineWorkerSnapshotOptions): Promise<ResidentEngineWorkerFrame>;
|
|
1050
|
-
/**
|
|
1051
|
-
* Lay out the rest of a provisional bootstrap layout: its frame and full
|
|
1052
|
-
* layout, or null when a later snapshot already replaced it.
|
|
1053
|
-
*/
|
|
1054
|
-
completeLayout(expectedFrameEpoch: number, paintCaret?: boolean, sliceBlocks?: number): Promise<ResidentEngineWorkerFrame | null>;
|
|
1055
|
-
buildFrame(extras: string, expectedFrameEpoch: number, paintCaret?: boolean, displayWindow?: [number, number]): Promise<ResidentEngineWorkerFrame>;
|
|
1056
|
-
/** Build unbuilt display pages; the reply frame carries them. */
|
|
1057
|
-
buildPages(pages: number[], expectedFrameEpoch: number, paintCaret?: boolean): Promise<ResidentEngineWorkerFrame>;
|
|
1058
|
-
/** @internal */
|
|
1059
|
-
buildPages(pages: number[], expectedFrameEpoch: number, paintCaret: boolean, background: boolean): Promise<ResidentEngineWorkerFrame | null>;
|
|
1060
|
-
releasePages(pages: Array<{
|
|
1061
|
-
index: number;
|
|
1062
|
-
pageId: string;
|
|
1063
|
-
}>, expectedFrameEpoch: number, paintCaret?: boolean): Promise<ResidentEngineWorkerFrame | {
|
|
1064
|
-
superseded: true;
|
|
1065
|
-
}>;
|
|
1066
|
-
applyInput(text: string, selection: YrsSelection, expectedFrameEpoch: number, profile?: boolean, paintCaret?: boolean, displayWindow?: [number, number]): Promise<ResidentEngineWorkerApplyResult | {
|
|
1067
|
-
applied: false;
|
|
1068
|
-
}>;
|
|
1069
|
-
applyDelete(direction: 'backward' | 'forward', selection: YrsSelection, expectedFrameEpoch: number, profile?: boolean, paintCaret?: boolean, count?: number, displayWindow?: [number, number]): Promise<ResidentEngineWorkerApplyResult | {
|
|
1070
|
-
applied: false;
|
|
1071
|
-
}>;
|
|
1072
|
-
/** Drop the worker-painted caret line by re-presenting the caret page's
|
|
1073
|
-
* retained raster. Fire-and-forget and idempotent. */
|
|
1074
|
-
eraseCaret(): void;
|
|
1075
|
-
invalidate(update: Uint8Array, selection: YrsSelection | null): void;
|
|
1076
|
-
attachCanvases(pages: ResidentEngineOffscreenPage[], activePageIds: string[], devicePixelRatio: number, zoom: number, caretStyle: ResidentCaretPaintStyle): Promise<void>;
|
|
1077
|
-
destroy(): void;
|
|
1078
|
-
private request;
|
|
1079
|
-
/**
|
|
1080
|
-
* Requests run in order, so once a snapshot is sent every later request
|
|
1081
|
-
* finds its state and fonts in the worker: the next sync can diff against
|
|
1082
|
-
* them before this one answers.
|
|
1083
|
-
*/
|
|
1084
|
-
private recordSent;
|
|
1085
|
-
/** Restarted by every message, so a queue of slow but answered requests never trips it. */
|
|
1086
|
-
private armWatchdog;
|
|
1087
|
-
private disarmWatchdog;
|
|
1088
|
-
/** Record a successfully applied bootstrap/sync payload's fonts revision.
|
|
1089
|
-
* The state vector is tracked centrally in `onmessage`. */
|
|
1090
|
-
private recordSync;
|
|
1091
|
-
private fail;
|
|
1092
|
-
}
|
|
1093
|
-
declare class ResidentWorkerUnavailableError extends Error {
|
|
1094
|
-
}
|
|
1095
|
-
/** The worker itself failed (crash, timeout, torn-down, corrupt reply). */
|
|
1096
|
-
declare class ResidentWorkerFailureError extends Error {
|
|
1097
|
-
}
|
|
1098
|
-
/** The worker trapped because its wasm memory could not grow any further. */
|
|
1099
|
-
declare class ResidentWorkerOutOfMemoryError extends ResidentWorkerUnavailableError {
|
|
1100
|
-
/** The worker's wasm memories when it trapped. */
|
|
1101
|
-
readonly memory: WasmModuleMemory[];
|
|
1102
|
-
constructor(message: string,
|
|
1103
|
-
/** The worker's wasm memories when it trapped. */
|
|
1104
|
-
memory: WasmModuleMemory[]);
|
|
1105
|
-
}
|
|
1106
|
-
declare function canUseResidentEngineWorker(): boolean;
|
|
1107
|
-
/** @internal */
|
|
1108
|
-
declare function preloadResidentEngineWorker(): Promise<void>;
|
|
1109
|
-
/** @internal */
|
|
1110
|
-
declare function retainPreloadedResidentEngineWorker(): () => void;
|
|
1111
|
-
/** @internal */
|
|
1112
|
-
declare function takePreloadedResidentEngineWorker(): ResidentEngineWorkerClient | null;
|
|
1113
|
-
|
|
1114
|
-
/**
|
|
1115
|
-
* Preload the editing engine and one spare resident worker. Opt-in.
|
|
1116
|
-
* @experimental
|
|
1117
|
-
*/
|
|
1118
|
-
declare function preloadDocxEngine(): Promise<void>;
|
|
1119
|
-
|
|
1120
|
-
/** Direct Document-to-yrs load projection. */
|
|
1121
|
-
|
|
1122
|
-
/**
|
|
1123
|
-
* Seeds every yrs-owned editable story directly from a parsed Document.
|
|
1124
|
-
*
|
|
1125
|
-
* Stories are `body`, `hf:{rId}`, `fn:{id}`, `en:{id}`, and recursively generated table
|
|
1126
|
-
* cell / block-SDT stories. The target session must not already contain any of
|
|
1127
|
-
* those story ids. Seeding starts a new opening; see {@link YrsSession.beginOpening}.
|
|
1128
|
-
*
|
|
1129
|
-
* @public
|
|
1130
|
-
*/
|
|
1131
|
-
declare function documentToYrs(session: YrsSession, document: Document, options?: YrsOpeningOptions): void;
|
|
1132
|
-
|
|
1133
|
-
/** yrs-to-OOXML save projection. */
|
|
1134
|
-
|
|
1135
|
-
/**
|
|
1136
|
-
* `blocks` with paragraphs of their own, in table cells too, each still the
|
|
1137
|
-
* session paragraph it was projected from: a save edits these, not the
|
|
1138
|
-
* projection the next one reuses. @internal
|
|
1139
|
-
*/
|
|
1140
|
-
declare function ownProjectedParagraphs(blocks: readonly BlockContent[]): BlockContent[];
|
|
1141
|
-
/**
|
|
1142
|
-
* Rebuild all yrs-owned editable stories into the serializer-facing Document
|
|
1143
|
-
* while preserving every package part the editor does not own.
|
|
1144
|
-
*/
|
|
1145
|
-
interface YrsToDocumentOptions {
|
|
1146
|
-
/**
|
|
1147
|
-
* Root stories to project. Omit to rebuild every editable story. A `body`
|
|
1148
|
-
* projection includes its nested table/content-control stories.
|
|
1149
|
-
*/
|
|
1150
|
-
storyIds?: ReadonlySet<string>;
|
|
1151
|
-
/**
|
|
1152
|
-
* The session comment id of each comment in `base` whose OOXML id is not
|
|
1153
|
-
* that id, such as one added with {@link YrsSession.addComment}. @internal
|
|
1154
|
-
*/
|
|
1155
|
-
commentIds?: ReadonlyMap<number, string>;
|
|
1156
|
-
}
|
|
1157
|
-
declare function yrsToDocument(session: YrsSession, base: Document, options?: YrsToDocumentOptions): Document;
|
|
1158
|
-
|
|
1159
|
-
/** Session save that reports where each saved paragraph can be found after reopening. */
|
|
1160
|
-
|
|
1161
|
-
/** A saved paragraph's session anchor and the persisted anchor that resolves to it once reopened. */
|
|
1162
|
-
interface DocxSavedParagraph {
|
|
1163
|
-
session: DocxSessionParagraphAnchor;
|
|
1164
|
-
persisted: DocxPersistedParagraphAnchor;
|
|
1165
|
-
}
|
|
1166
|
-
interface DocxSavedDocument {
|
|
1167
|
-
bytes: Uint8Array;
|
|
1168
|
-
/**
|
|
1169
|
-
* Every session paragraph the bytes hold with a Word paragraph ID, in
|
|
1170
|
-
* document order. Stories that share a part are views of its paragraphs:
|
|
1171
|
-
* each view the part holds is listed, and its persisted anchor resolves to
|
|
1172
|
-
* the first story's view once reopened.
|
|
1173
|
-
*/
|
|
1174
|
-
paragraphs: DocxSavedParagraph[];
|
|
1175
|
-
/**
|
|
1176
|
-
* Saved paragraphs whose Word paragraph ID the live session reassigned
|
|
1177
|
-
* while the save was written, such as by a duplicate repair after a remote
|
|
1178
|
-
* update: their persisted anchor finds them in these bytes, not in the
|
|
1179
|
-
* live session.
|
|
1180
|
-
*/
|
|
1181
|
-
conflicts: DocxSavedParagraph[];
|
|
1182
|
-
}
|
|
1183
|
-
/** The identities and paragraph ID plan a session save applies. @internal */
|
|
1184
|
-
interface DocxSessionSave {
|
|
1185
|
-
identities: DocxParagraphIdentitySnapshot;
|
|
1186
|
-
plan: DocxParagraphSavePlan;
|
|
1187
|
-
}
|
|
1188
|
-
/** Captures a save of `session`, in the task that projects the saved document. @internal */
|
|
1189
|
-
declare function captureSessionSave(session: YrsSession): DocxSessionSave;
|
|
1190
|
-
/**
|
|
1191
|
-
* Writes `document`, projected from `session` when `capture` was taken, and
|
|
1192
|
-
* records the Word paragraph IDs the bytes hold as saved. `patches` selects
|
|
1193
|
-
* the planned parts written as `originalBuffer`'s bytes with IDs patched in,
|
|
1194
|
-
* and `splices` the story parts written as its bytes with only the
|
|
1195
|
-
* paragraphs that need it re-serialized; each selects none unless
|
|
1196
|
-
* `originalBuffer` is the session's source package.
|
|
1197
|
-
* @internal
|
|
1198
|
-
*/
|
|
1199
|
-
declare function writeSessionSave(session: YrsSession, document: Document, capture: DocxSessionSave, originalBuffer: ArrayBuffer, options?: RepackOptions, patches?: (part: string) => boolean, skipMutations?: boolean, splices?: (part: string) => boolean): Promise<DocxSavedDocument>;
|
|
1200
|
-
/**
|
|
1201
|
-
* Saves a session opened from DOCX bytes and reports each saved paragraph's
|
|
1202
|
-
* persisted anchor, read from the same projection the bytes are written
|
|
1203
|
-
* from and kept only where the written part holds its Word paragraph ID.
|
|
1204
|
-
* Parts whose stories are unchanged since the session opened keep
|
|
1205
|
-
* their source bytes, paragraph IDs aside. The comments the session holds
|
|
1206
|
-
* are saved with their anchors, those added to it included; replies and
|
|
1207
|
-
* resolution are saved as the source package has them. A source paragraph without a
|
|
1208
|
-
* Word paragraph ID saves without one unless the host called
|
|
1209
|
-
* `persistParagraphIds()` first; the IDs a save writes are recorded as
|
|
1210
|
-
* saved, so they keep them against unsaved claims from other replicas, once
|
|
1211
|
-
* reconciled with the live session.
|
|
1212
|
-
*/
|
|
1213
|
-
declare function saveYrsDocx(session: YrsSession, options?: RepackOptions): Promise<DocxSavedDocument>;
|
|
1214
|
-
|
|
1215
|
-
/** @internal */
|
|
1216
|
-
declare function editorSaveKeys(document: Document, comments?: readonly Comment[]): {
|
|
1217
|
-
metadata: string;
|
|
1218
|
-
comments: string;
|
|
1219
|
-
commentIds: number[];
|
|
1220
|
-
};
|
|
1221
|
-
|
|
1222
|
-
/** Engine operations the package runs on sessions it creates itself; not public API. */
|
|
1223
|
-
|
|
1224
|
-
/** Returns the session's opened source package when available. @internal */
|
|
1225
|
-
declare function sessionSourcePackage(session: YrsSession): {
|
|
1226
|
-
buffer: ArrayBuffer;
|
|
1227
|
-
keys: ReturnType<typeof editorSaveKeys>;
|
|
1228
|
-
} | null;
|
|
1229
|
-
|
|
1230
|
-
interface YrsDocxHost {
|
|
1231
|
-
document: Document;
|
|
1232
|
-
referencedFonts: string[];
|
|
1233
|
-
/**
|
|
1234
|
-
* The `referencedFonts` a document seeded from its package names only for
|
|
1235
|
-
* East Asian or complex-script text it does not contain, so no text is
|
|
1236
|
-
* measured or drawn with them. Empty when its stories were not seeded; a
|
|
1237
|
-
* preview's cover only its own first pages.
|
|
1238
|
-
*/
|
|
1239
|
-
unusedScriptFonts?: string[];
|
|
1240
|
-
/** A preview whose cut holds the whole body. */
|
|
1241
|
-
wholeBody?: true;
|
|
1242
|
-
embeddedFonts: Map<string, ArrayBuffer>;
|
|
1243
|
-
fontTableRelationshipsXml?: string;
|
|
1244
|
-
}
|
|
1245
|
-
/** Durable authorship metadata for one suggested (tracked-change) operation. */
|
|
1246
|
-
interface YrsAuthor {
|
|
1247
|
-
name: string;
|
|
1248
|
-
/** ISO timestamp supplied by the host so all peers share one clock policy. */
|
|
1249
|
-
date: string;
|
|
1250
|
-
}
|
|
1251
|
-
/** One position: `(story, paraId, offset)` — offsets are UTF-16 units within the paragraph. */
|
|
1252
|
-
interface YrsLoc {
|
|
1253
|
-
story: string;
|
|
1254
|
-
paraId: string;
|
|
1255
|
-
offset: number;
|
|
1256
|
-
}
|
|
1257
|
-
/** One binary Yrs position that transforms with collaborative edits. */
|
|
1258
|
-
interface YrsStickyPosition {
|
|
1259
|
-
story: string;
|
|
1260
|
-
encoded: Uint8Array;
|
|
1261
|
-
}
|
|
1262
|
-
/** A paragraph-addressed position without the story (used inside {@link YrsStoryRange}). */
|
|
1263
|
-
interface YrsParaOffset {
|
|
1264
|
-
paraId: string;
|
|
1265
|
-
offset: number;
|
|
1266
|
-
}
|
|
1267
|
-
/**
|
|
1268
|
-
* A half-open range `[start, end)` inside one story. Ends may sit in
|
|
1269
|
-
* different paragraphs; the boundary pilcrows are then part of the range
|
|
1270
|
-
* (deleting such a range merges paragraphs).
|
|
1271
|
-
*/
|
|
1272
|
-
interface YrsStoryRange {
|
|
1273
|
-
story: string;
|
|
1274
|
-
start: YrsParaOffset;
|
|
1275
|
-
end: YrsParaOffset;
|
|
1276
|
-
}
|
|
1277
|
-
/** One run-level mark for {@link YrsSession.toggleMark}. */
|
|
1278
|
-
type YrsRunMark = {
|
|
1279
|
-
type: 'bold';
|
|
1280
|
-
} | {
|
|
1281
|
-
type: 'italic';
|
|
1282
|
-
} | {
|
|
1283
|
-
type: 'underline';
|
|
1284
|
-
} | {
|
|
1285
|
-
type: 'superscript';
|
|
1286
|
-
} | {
|
|
1287
|
-
type: 'subscript';
|
|
1288
|
-
} | {
|
|
1289
|
-
type: 'fontFamily';
|
|
1290
|
-
value: string;
|
|
1291
|
-
} | {
|
|
1292
|
-
type: 'fontSize';
|
|
1293
|
-
value: number;
|
|
1294
|
-
} | {
|
|
1295
|
-
type: 'color';
|
|
1296
|
-
value: string;
|
|
1297
|
-
};
|
|
1298
|
-
/** A direct text color written by {@link YrsSession.formatRange}. */
|
|
1299
|
-
type YrsTextColor = {
|
|
1300
|
-
rgb: string;
|
|
1301
|
-
themeColor?: never;
|
|
1302
|
-
} | {
|
|
1303
|
-
rgb?: never;
|
|
1304
|
-
themeColor: string;
|
|
1305
|
-
};
|
|
1306
|
-
/**
|
|
1307
|
-
* Set-valued inline formatting for {@link YrsSession.formatRange}. Omitted
|
|
1308
|
-
* fields are left unchanged; `null` clears a field. Boolean `false` also
|
|
1309
|
-
* clears the corresponding mark.
|
|
1310
|
-
*/
|
|
1311
|
-
interface YrsInlineFormatDelta {
|
|
1312
|
-
bold?: boolean | null;
|
|
1313
|
-
italic?: boolean | null;
|
|
1314
|
-
underline?: boolean | {
|
|
1315
|
-
style?: string;
|
|
1316
|
-
color?: string;
|
|
1317
|
-
} | null;
|
|
1318
|
-
strike?: boolean | {
|
|
1319
|
-
double?: boolean;
|
|
1320
|
-
} | null;
|
|
1321
|
-
color?: YrsTextColor | null;
|
|
1322
|
-
highlight?: string | null;
|
|
1323
|
-
/** Font size in points; Rust writes both OOXML half-point size fields. */
|
|
1324
|
-
fontSize?: number | null;
|
|
1325
|
-
fontFamily?: {
|
|
1326
|
-
ascii: string;
|
|
1327
|
-
hAnsi?: string;
|
|
1328
|
-
} | null;
|
|
1329
|
-
/** Passive run properties not covered by the typed fields. `null` clears. */
|
|
1330
|
-
other?: Readonly<Record<string, unknown | null>>;
|
|
1331
|
-
}
|
|
1332
|
-
interface YrsHyperlinkAttrs {
|
|
1333
|
-
href: string;
|
|
1334
|
-
tooltip?: string | null;
|
|
1335
|
-
rId?: string | null;
|
|
1336
|
-
}
|
|
1337
|
-
/** Seed shape for {@link YrsSession.loadStories}. */
|
|
1338
|
-
interface YrsParagraphSeed {
|
|
1339
|
-
/** Paragraph text; must not contain paragraph breaks. */
|
|
1340
|
-
text: string;
|
|
1341
|
-
/** Defaults to `"Normal"`. */
|
|
1342
|
-
pStyle?: string;
|
|
1343
|
-
/** Defaults to `"left"`. */
|
|
1344
|
-
alignment?: string;
|
|
1345
|
-
}
|
|
1346
|
-
/** One story to seed via {@link YrsSession.loadStories}. */
|
|
1347
|
-
interface YrsStorySeed {
|
|
1348
|
-
storyId: string;
|
|
1349
|
-
/** At least one paragraph. */
|
|
1350
|
-
paragraphs: readonly YrsParagraphSeed[];
|
|
1351
|
-
}
|
|
1352
|
-
/** How a seeding entry point starts its opening; see {@link YrsSession.beginOpening}. */
|
|
1353
|
-
interface YrsOpeningOptions {
|
|
1354
|
-
/**
|
|
1355
|
-
* A fixed opening generation, for a deterministic seed every replica loads
|
|
1356
|
-
* as one session. Each opening mints a fresh one by default.
|
|
1357
|
-
*/
|
|
1358
|
-
generation?: string;
|
|
1359
|
-
/**
|
|
1360
|
-
* Seeds images as `media:{n}` tokens naming their part of the package,
|
|
1361
|
-
* instead of `data:` URLs, keeping them out of the document state. Only a
|
|
1362
|
-
* replica opened from the same package on a version that reads tokens
|
|
1363
|
-
* shows them, so every client of a shared room must be one. Off by default.
|
|
1364
|
-
*/
|
|
1365
|
-
mediaTokens?: boolean;
|
|
1366
|
-
}
|
|
1367
|
-
/**
|
|
1368
|
-
* A copy of `bytes` whose SHA-256 the platform takes off the calling thread,
|
|
1369
|
-
* where it has Web Crypto. Opening that copy unchanged skips hashing the
|
|
1370
|
-
* package on the calling thread; any other bytes open as before.
|
|
1371
|
-
* @internal
|
|
1372
|
-
*/
|
|
1373
|
-
declare function prepareDocxBytes(bytes: Uint8Array): Promise<Uint8Array>;
|
|
1374
|
-
/** The SHA-256 {@link prepareDocxBytes} took of `bytes`, if it took one. @internal */
|
|
1375
|
-
declare function preparedDocxDigest(bytes: Uint8Array): string | undefined;
|
|
1376
|
-
/** Snapshot of one paragraph from {@link YrsSession.paragraphs}. */
|
|
1377
|
-
interface YrsParagraph {
|
|
1378
|
-
/** Session key; not the paragraph's Word `w14:paraId`. */
|
|
1379
|
-
paraId: string;
|
|
1380
|
-
text: string;
|
|
1381
|
-
/** pStyle / alignment plus any op-set extras. */
|
|
1382
|
-
properties: Record<string, unknown>;
|
|
1383
|
-
}
|
|
1384
|
-
interface YrsTextSearchOptions {
|
|
1385
|
-
/** Defaults to false. */
|
|
1386
|
-
caseSensitive?: boolean;
|
|
1387
|
-
/** Maximum matches; unlimited by default. */
|
|
1388
|
-
limit?: number;
|
|
1389
|
-
}
|
|
1390
|
-
/** Paragraph-local UTF-16 offsets. */
|
|
1391
|
-
interface YrsTextMatch {
|
|
1392
|
-
story: string;
|
|
1393
|
-
paraId: string;
|
|
1394
|
-
start: number;
|
|
1395
|
-
end: number;
|
|
1396
|
-
text: string;
|
|
1397
|
-
}
|
|
1398
|
-
/** One direct numbering reference (`w:numPr`) on a paragraph. */
|
|
1399
|
-
interface YrsNumberingProperties {
|
|
1400
|
-
numId?: number;
|
|
1401
|
-
ilvl?: number;
|
|
1402
|
-
}
|
|
1403
|
-
/** One paragraph tab stop, measured in twips from the left margin. */
|
|
1404
|
-
interface YrsParagraphTabStop {
|
|
1405
|
-
position: number;
|
|
1406
|
-
alignment: 'left' | 'center' | 'right' | 'decimal' | 'bar' | 'clear' | 'num';
|
|
1407
|
-
leader?: 'none' | 'dot' | 'hyphen' | 'underscore' | 'heavy' | 'middleDot';
|
|
1408
|
-
}
|
|
1409
|
-
/**
|
|
1410
|
-
* Tri-state properties for {@link YrsSession.setParagraphAttrs}. Omitted
|
|
1411
|
-
* fields are kept and `null` clears. Numeric spacing and indents are OOXML
|
|
1412
|
-
* twips/line-spacing units, never CSS pixels.
|
|
1413
|
-
*/
|
|
1414
|
-
interface YrsParagraphAttrs {
|
|
1415
|
-
alignment?: 'left' | 'center' | 'right' | 'both' | 'distribute' | 'mediumKashida' | 'highKashida' | 'lowKashida' | 'thaiDistribute' | null;
|
|
1416
|
-
lineSpacing?: number | null;
|
|
1417
|
-
lineSpacingRule?: 'auto' | 'exact' | 'atLeast' | null;
|
|
1418
|
-
spaceBefore?: number | null;
|
|
1419
|
-
spaceAfter?: number | null;
|
|
1420
|
-
indentLeft?: number | null;
|
|
1421
|
-
indentRight?: number | null;
|
|
1422
|
-
indentFirstLine?: number | null;
|
|
1423
|
-
hangingIndent?: boolean | null;
|
|
1424
|
-
bidi?: boolean | null;
|
|
1425
|
-
tabs?: readonly YrsParagraphTabStop[] | null;
|
|
1426
|
-
defaultTextFormatting?: Readonly<Record<string, unknown>> | null;
|
|
1427
|
-
numPr?: YrsNumberingProperties | null;
|
|
1428
|
-
numPrFromStyle?: YrsNumberingProperties | null;
|
|
1429
|
-
listNumFmt?: string | null;
|
|
1430
|
-
listIsBullet?: boolean | null;
|
|
1431
|
-
listMarker?: string | null;
|
|
1432
|
-
listMarkerHidden?: boolean | null;
|
|
1433
|
-
listMarkerFontFamily?: string | null;
|
|
1434
|
-
listMarkerFontSize?: number | null;
|
|
1435
|
-
listMarkerBold?: boolean | null;
|
|
1436
|
-
listMarkerItalic?: boolean | null;
|
|
1437
|
-
listMarkerColor?: ColorValue | null;
|
|
1438
|
-
listMarkerSuffix?: 'tab' | 'space' | 'nothing' | null;
|
|
1439
|
-
listLevelNumFmts?: readonly string[] | null;
|
|
1440
|
-
listAbstractNumId?: number | null;
|
|
1441
|
-
listStartOverride?: number | null;
|
|
1442
|
-
/** Passive pPr/model properties not covered by the typed fields. */
|
|
1443
|
-
other?: Readonly<Record<string, unknown | null>>;
|
|
1444
|
-
}
|
|
1445
|
-
/**
|
|
1446
|
-
* Typed value for a content control. A string fills a plain- or rich-text control's content
|
|
1447
|
-
* (as a `setContentControlText` edit step would); the objects set checkbox, dropdown and date
|
|
1448
|
-
* controls.
|
|
1449
|
-
*/
|
|
1450
|
-
type YrsContentControlValue = {
|
|
1451
|
-
kind: 'dropdown';
|
|
1452
|
-
value: string;
|
|
1453
|
-
} | {
|
|
1454
|
-
kind: 'checkbox';
|
|
1455
|
-
checked: boolean;
|
|
1456
|
-
} | {
|
|
1457
|
-
kind: 'date';
|
|
1458
|
-
date: string;
|
|
1459
|
-
} | string;
|
|
1460
|
-
/** Image geometry authored in OOXML EMUs plus wrapping/position metadata. */
|
|
1461
|
-
interface YrsImageGeometry {
|
|
1462
|
-
widthEmu: number;
|
|
1463
|
-
heightEmu: number;
|
|
1464
|
-
wrap?: 'inline' | 'square' | 'tight' | 'through' | 'topAndBottom' | 'behind' | 'inFront';
|
|
1465
|
-
hOffsetEmu?: number | null;
|
|
1466
|
-
vOffsetEmu?: number | null;
|
|
1467
|
-
distTopEmu?: number | null;
|
|
1468
|
-
distBottomEmu?: number | null;
|
|
1469
|
-
distLeftEmu?: number | null;
|
|
1470
|
-
distRightEmu?: number | null;
|
|
1471
|
-
relativeFromHorizontal?: string | null;
|
|
1472
|
-
relativeFromVertical?: string | null;
|
|
1473
|
-
/** Additional image payload fields; `null` clears an existing field. */
|
|
1474
|
-
other?: Readonly<Record<string, unknown | null>>;
|
|
1475
|
-
}
|
|
1476
|
-
/** A text or picture watermark payload for {@link YrsSession.insertWatermark}. */
|
|
1477
|
-
type YrsWatermark = {
|
|
1478
|
-
kind: 'text';
|
|
1479
|
-
text: string;
|
|
1480
|
-
font: string;
|
|
1481
|
-
color: string;
|
|
1482
|
-
semitransparent: boolean;
|
|
1483
|
-
layout: 'diagonal' | 'horizontal';
|
|
1484
|
-
fontSize?: number;
|
|
1485
|
-
decorative?: boolean;
|
|
1486
|
-
} | {
|
|
1487
|
-
kind: 'picture';
|
|
1488
|
-
relId?: string;
|
|
1489
|
-
mediaPath?: string;
|
|
1490
|
-
dataUrl?: string;
|
|
1491
|
-
contentType?: string;
|
|
1492
|
-
scale: number;
|
|
1493
|
-
washout: boolean;
|
|
1494
|
-
widthEmu?: number;
|
|
1495
|
-
heightEmu?: number;
|
|
1496
|
-
decorative?: boolean;
|
|
1497
|
-
};
|
|
1498
|
-
/**
|
|
1499
|
-
* One formatted segment from {@link YrsSession.storySegments} — the render
|
|
1500
|
-
* bridge's input. `attributes` carries run marks plus `ins` / `del` revision
|
|
1501
|
-
* values (suggested deletions are retained text with a `del` attribute).
|
|
1502
|
-
*/
|
|
1503
|
-
type YrsStorySegment = {
|
|
1504
|
-
kind: 'text';
|
|
1505
|
-
text: string;
|
|
1506
|
-
attributes: Record<string, unknown>;
|
|
1507
|
-
} | {
|
|
1508
|
-
kind: 'pilcrow';
|
|
1509
|
-
paraId: string;
|
|
1510
|
-
properties: Record<string, unknown>;
|
|
1511
|
-
attributes: Record<string, unknown>;
|
|
1512
|
-
} | {
|
|
1513
|
-
kind: 'embed';
|
|
1514
|
-
/** Map-backed embed discriminator (`table`, `noteRef`, `image`, …). */
|
|
1515
|
-
embedKind: string;
|
|
1516
|
-
/** Authored map entries excluding the discriminator. */
|
|
1517
|
-
payload: Record<string, unknown>;
|
|
1518
|
-
attributes: Record<string, unknown>;
|
|
1519
|
-
};
|
|
1520
|
-
/** Current offsets of one sticky comment anchor. */
|
|
1521
|
-
interface YrsResolvedCommentAnchor {
|
|
1522
|
-
story: string;
|
|
1523
|
-
start: number;
|
|
1524
|
-
end: number;
|
|
1525
|
-
}
|
|
1526
|
-
/** A paragraph's story span; `end` is its pilcrow, so `end - start` is the paragraph length. */
|
|
1527
|
-
interface YrsParagraphSpan {
|
|
1528
|
-
start: number;
|
|
1529
|
-
end: number;
|
|
1530
|
-
}
|
|
1531
|
-
/** Compact paragraph entry used to build the live input-position projection. */
|
|
1532
|
-
interface YrsParagraphLength {
|
|
1533
|
-
paraId: string;
|
|
1534
|
-
/** UTF-16 text and inline embed units before the paragraph's pilcrow. */
|
|
1535
|
-
length: number;
|
|
1536
|
-
}
|
|
1537
|
-
/** Receipt of an op that minted a paragraph id. */
|
|
1538
|
-
interface YrsParagraphReceipt {
|
|
1539
|
-
paraId: string;
|
|
1540
|
-
}
|
|
1541
|
-
/** Receipt of an op that may have minted a tracked-change revision (suggesting mode). */
|
|
1542
|
-
interface YrsRevisionReceipt {
|
|
1543
|
-
revisionId: string | null;
|
|
1544
|
-
}
|
|
1545
|
-
/** Where the replacement text landed; after the struck-out text when suggesting. */
|
|
1546
|
-
interface YrsReplaceReceipt extends YrsRevisionReceipt {
|
|
1547
|
-
range?: YrsStoryRange;
|
|
1548
|
-
}
|
|
1549
|
-
/**
|
|
1550
|
-
* Receipt of {@link YrsSession.splitParagraph}. The first half keeps the
|
|
1551
|
-
* original paraId and the second half is re-minted; suggesting
|
|
1552
|
-
* mode stamps a `pPrIns` revision on the first half.
|
|
1553
|
-
*/
|
|
1554
|
-
interface YrsSplitReceipt {
|
|
1555
|
-
firstParaId: string;
|
|
1556
|
-
secondParaId: string;
|
|
1557
|
-
revisionId: string | null;
|
|
1558
|
-
}
|
|
1559
|
-
/** Low-level UTF-16 story operation for {@link YrsSession.applyRawOps}. */
|
|
1560
|
-
type YrsRawOp = {
|
|
1561
|
-
op: 'insert';
|
|
1562
|
-
index: number;
|
|
1563
|
-
text: string;
|
|
1564
|
-
attrs?: Record<string, unknown>;
|
|
1565
|
-
} | {
|
|
1566
|
-
op: 'delete';
|
|
1567
|
-
index: number;
|
|
1568
|
-
len: number;
|
|
1569
|
-
} | {
|
|
1570
|
-
op: 'format';
|
|
1571
|
-
index: number;
|
|
1572
|
-
len: number;
|
|
1573
|
-
attrs?: Record<string, unknown>;
|
|
1574
|
-
} | {
|
|
1575
|
-
/**
|
|
1576
|
-
* A pilcrow's `ooxmlParaId` binds its Word paragraph ID and is dropped
|
|
1577
|
-
* when it is not one; `sourceParaId` and `paraOrigin` are seeding's to set.
|
|
1578
|
-
*/
|
|
1579
|
-
op: 'insertEmbed';
|
|
1580
|
-
index: number;
|
|
1581
|
-
kind: string;
|
|
1582
|
-
payload?: Record<string, unknown>;
|
|
1583
|
-
attrs?: Record<string, unknown>;
|
|
1584
|
-
} | {
|
|
1585
|
-
op: 'setEmbedAttr';
|
|
1586
|
-
index: number;
|
|
1587
|
-
key: string;
|
|
1588
|
-
value: unknown;
|
|
1589
|
-
} | {
|
|
1590
|
-
/** Upserts a side-map comment with sticky story-unit ranges. */
|
|
1591
|
-
op: 'setComment';
|
|
1592
|
-
id: string;
|
|
1593
|
-
ranges: ReadonlyArray<readonly [number, number]>;
|
|
1594
|
-
author?: string;
|
|
1595
|
-
date?: string;
|
|
1596
|
-
body?: unknown;
|
|
1597
|
-
} | {
|
|
1598
|
-
/** Removes the side-map comment keyed by `id`; errors when missing. */
|
|
1599
|
-
op: 'removeComment';
|
|
1600
|
-
id: string;
|
|
1601
|
-
};
|
|
1602
|
-
/** Host context for {@link YrsSession.yrsBlocksForStory} (theme + list numbering). */
|
|
1603
|
-
interface YrsRenderEnv {
|
|
1604
|
-
compatibilityFlags?: Partial<CompatibilityFlags>;
|
|
1605
|
-
tocStyleIds?: string[];
|
|
1606
|
-
paragraphSpacingLinePx?: number;
|
|
1607
|
-
/** Section document-grid snap pitch in px (w:docGrid). The engine derives this from sections; hosts may omit it. */
|
|
1608
|
-
docGridPitchPx?: number;
|
|
1609
|
-
defaultParagraphStyleId?: string;
|
|
1610
|
-
/** Theme color name → hex (`accent1` → `4472C4`), for theme-color resolution. */
|
|
1611
|
-
themeColors?: Record<string, string>;
|
|
1612
|
-
/** The document default tab stop in twips. */
|
|
1613
|
-
defaultTabStopTwips?: number | null;
|
|
1614
|
-
/** Current page content height in CSS px, for proportional drawing constraints. */
|
|
1615
|
-
pageContentHeight?: number | null;
|
|
1616
|
-
/** yrs revision/paragraph id → dense numeric layout id (list markers, revisions). */
|
|
1617
|
-
numericIds?: Record<string, number>;
|
|
1618
|
-
/** Include hidden text in visible layout without changing the document. */
|
|
1619
|
-
showHiddenText?: boolean;
|
|
1620
|
-
/** Revision id → decision shown in layout; unlisted revisions render as tracked changes. */
|
|
1621
|
-
revisionPreview?: Readonly<Record<string, 'accepted' | 'rejected'>>;
|
|
1622
|
-
/**
|
|
1623
|
-
* Lay the opened package's images out as `media:{n}` tokens, which a
|
|
1624
|
-
* resolver given the session's `mediaSource` reads. @internal
|
|
1625
|
-
*/
|
|
1626
|
-
mediaTokens?: boolean;
|
|
1627
|
-
}
|
|
1628
|
-
/** Receipt of {@link YrsSession.addComment}. */
|
|
1629
|
-
interface YrsCommentReceipt {
|
|
1630
|
-
commentId: string;
|
|
1631
|
-
}
|
|
1632
|
-
/** A comment the session holds; see {@link YrsSession.listComments}. @internal */
|
|
1633
|
-
interface YrsCommentInfo {
|
|
1634
|
-
id: string;
|
|
1635
|
-
author: string;
|
|
1636
|
-
date: string;
|
|
1637
|
-
done: boolean;
|
|
1638
|
-
parentId: string | null;
|
|
1639
|
-
/** The body as it was given to {@link YrsSession.addComment} or `setComment`. */
|
|
1640
|
-
body: unknown;
|
|
1641
|
-
}
|
|
1642
|
-
/**
|
|
1643
|
-
* Target of {@link YrsSession.acceptChange} / {@link YrsSession.rejectChange}:
|
|
1644
|
-
* one coalesced revision id (resolved at every site, in any story — the
|
|
1645
|
-
* `acceptChangeById` twin) or an explicit story range (the range-command twin;
|
|
1646
|
-
* every tracked change overlapping the range resolves, no id filtering).
|
|
1647
|
-
*/
|
|
1648
|
-
type YrsChangeTarget = {
|
|
1649
|
-
revisionId: string;
|
|
1650
|
-
} | YrsStoryRange;
|
|
1651
|
-
/** Receipt of {@link YrsSession.acceptChange} / {@link YrsSession.rejectChange}. */
|
|
1652
|
-
interface YrsResolveReceipt {
|
|
1653
|
-
/** The revision ids resolved by the op (resolution order, deduplicated). */
|
|
1654
|
-
revisionIds: string[];
|
|
1655
|
-
}
|
|
1656
|
-
/** This peer's awareness selection, resolved from two yrs sticky positions. */
|
|
1657
|
-
interface YrsSelection {
|
|
1658
|
-
anchor: YrsLoc;
|
|
1659
|
-
head: YrsLoc;
|
|
1660
|
-
}
|
|
1661
|
-
interface YrsResidentCaretRect {
|
|
1662
|
-
pageIndex: number;
|
|
1663
|
-
pageId: string;
|
|
1664
|
-
x: number;
|
|
1665
|
-
y: number;
|
|
1666
|
-
height: number;
|
|
1667
|
-
}
|
|
1668
|
-
interface YrsResidentCaretSnapshot {
|
|
1669
|
-
frameEpoch: number;
|
|
1670
|
-
caretRect: YrsResidentCaretRect | null;
|
|
1671
|
-
/** Selection the rect was computed for. Absent on raw engine snapshots. */
|
|
1672
|
-
selection?: YrsSelection | null;
|
|
1673
|
-
}
|
|
1674
|
-
declare function sameYrsSelection(left: YrsSelection | null, right: YrsSelection | null): boolean;
|
|
1675
|
-
/** How far a region layout begun with {@link YrsSession.beginRegionLayout} has come. */
|
|
1676
|
-
interface YrsRegionLayoutProgress {
|
|
1677
|
-
measuredBlocks: number;
|
|
1678
|
-
bodyBlocks: number;
|
|
1679
|
-
/** The retained region layout reply, once the pass is complete. */
|
|
1680
|
-
layoutJson?: string;
|
|
1681
|
-
}
|
|
1682
|
-
/** Opt-in internal stage timings for one resident engine input. @internal */
|
|
1683
|
-
interface YrsEngineApplyProfile {
|
|
1684
|
-
selectionMs: number;
|
|
1685
|
-
editMs: number;
|
|
1686
|
-
lowerMs: number;
|
|
1687
|
-
measureMs: number;
|
|
1688
|
-
paginateMs: number;
|
|
1689
|
-
displayInputMs: number;
|
|
1690
|
-
displayBuildMs: number;
|
|
1691
|
-
displayFinalizeMs: number;
|
|
1692
|
-
displayMs: number;
|
|
1693
|
-
encodeMs: number;
|
|
1694
|
-
}
|
|
1695
|
-
/**
|
|
1696
|
-
* Serializable bootstrap state for the dedicated resident-layout worker.
|
|
1697
|
-
* The main-thread yrs replica records the inputs that established resident
|
|
1698
|
-
* render, measurement, and pagination state; the worker replays them once and
|
|
1699
|
-
* then owns every ordinary input-to-frame transaction.
|
|
1700
|
-
*
|
|
1701
|
-
* @internal
|
|
1702
|
-
*/
|
|
1703
|
-
/**
|
|
1704
|
-
* One resident font-store registration, in the order the main thread made it:
|
|
1705
|
-
* raw bytes, or a measurement view of an earlier id. The worker replays the
|
|
1706
|
-
* list to reproduce the same dense ids, so the order and the mix both matter.
|
|
1707
|
-
*
|
|
1708
|
-
* @internal
|
|
1709
|
-
*/
|
|
1710
|
-
type YrsResidentFontRegistration = Uint8Array | {
|
|
1711
|
-
substituteOf: number;
|
|
1712
|
-
family: string;
|
|
1713
|
-
};
|
|
1714
|
-
interface YrsResidentWorkerSnapshot {
|
|
1715
|
-
/** @internal */
|
|
1716
|
-
workerAuthoritative?: true;
|
|
1717
|
-
clientId: number;
|
|
1718
|
-
/** Full document state, or a state-vector diff when the caller supplied
|
|
1719
|
-
* the worker's known vector — both apply through the same merge path. */
|
|
1720
|
-
state: Uint8Array;
|
|
1721
|
-
selection: YrsSelection | null;
|
|
1722
|
-
/** Empty when the caller declared the worker's fonts current
|
|
1723
|
-
* (`knownFontsRevision` matches); the worker then keeps its registrations. */
|
|
1724
|
-
fonts: YrsResidentFontRegistration[];
|
|
1725
|
-
/** Monotonic revision of the resident font set (bumped by register/clear). */
|
|
1726
|
-
fontsRevision: number;
|
|
1727
|
-
renderInputs: Array<{
|
|
1728
|
-
story: string;
|
|
1729
|
-
env: YrsRenderEnv;
|
|
1730
|
-
}>;
|
|
1731
|
-
measureInputs: string[];
|
|
1732
|
-
layoutInput: string;
|
|
1733
|
-
layoutWithRegions: boolean;
|
|
1734
|
-
layoutRevision: number;
|
|
1735
|
-
/** The document is a preview's cut of a package: its layouts render NUMPAGES empty. */
|
|
1736
|
-
partialDocument?: boolean;
|
|
1737
|
-
/** Which seeded `data:` image sources lay out as `media:{n}` tokens. @internal */
|
|
1738
|
-
mediaSources?: string;
|
|
1739
|
-
}
|
|
1740
|
-
/**
|
|
1741
|
-
* What the sync target already holds, so a snapshot can ship deltas instead
|
|
1742
|
-
* of the whole world.
|
|
1743
|
-
*
|
|
1744
|
-
* @internal
|
|
1745
|
-
*/
|
|
1746
|
-
interface YrsResidentWorkerSyncOptions {
|
|
1747
|
-
/** The worker replica's last reported yrs state vector. */
|
|
1748
|
-
knownStateVector?: Uint8Array | null;
|
|
1749
|
-
/** The `fontsRevision` the worker last applied. */
|
|
1750
|
-
knownFontsRevision?: number | null;
|
|
1751
|
-
}
|
|
1752
|
-
/** A range-aggregated toggle mark. @public */
|
|
1753
|
-
type YrsTriState = boolean | 'mixed';
|
|
1754
|
-
/**
|
|
1755
|
-
* Read-only toolbar/a11y state aggregated from yrs over one story range.
|
|
1756
|
-
* Toggle marks are tri-state; value marks are `null` when absent or mixed.
|
|
1757
|
-
*
|
|
1758
|
-
* @public
|
|
1759
|
-
*/
|
|
1760
|
-
interface YrsSelectionContext {
|
|
1761
|
-
bold: YrsTriState;
|
|
1762
|
-
italic: YrsTriState;
|
|
1763
|
-
underline: YrsTriState;
|
|
1764
|
-
strike: YrsTriState;
|
|
1765
|
-
superscript: YrsTriState;
|
|
1766
|
-
subscript: YrsTriState;
|
|
1767
|
-
/** Uniform ASCII font family, or `null` when absent/mixed. */
|
|
1768
|
-
fontFamily: string | null;
|
|
1769
|
-
/** Uniform font size in half-points (the OOXML `w:sz` unit). */
|
|
1770
|
-
fontSize: number | null;
|
|
1771
|
-
/** Uniform RGB hex or theme-color name, or `null` when absent/mixed. */
|
|
1772
|
-
color: string | null;
|
|
1773
|
-
/** Uniform highlight name (`yellow`, …) or unmapped hex, or `null` when absent/mixed. */
|
|
1774
|
-
highlight: string | null;
|
|
1775
|
-
/** Paragraph containing the range start. */
|
|
1776
|
-
paraId: string;
|
|
1777
|
-
styleId: string | null;
|
|
1778
|
-
alignment: string | null;
|
|
1779
|
-
/**
|
|
1780
|
-
* Full authored pilcrow property bag. Known toolbar fields retain their
|
|
1781
|
-
* names (`indentLeft`, `spaceBefore`, `lineSpacing`, `numPr`, and so on);
|
|
1782
|
-
* paragraph style is stored as `pStyle`.
|
|
1783
|
-
*/
|
|
1784
|
-
paragraphProperties: {
|
|
1785
|
-
[key: string]: unknown;
|
|
1786
|
-
pStyle?: string;
|
|
1787
|
-
alignment?: string;
|
|
1788
|
-
indentLeft?: number;
|
|
1789
|
-
indentRight?: number;
|
|
1790
|
-
indentFirstLine?: number;
|
|
1791
|
-
hangingIndent?: boolean;
|
|
1792
|
-
spaceBefore?: number;
|
|
1793
|
-
spaceAfter?: number;
|
|
1794
|
-
lineSpacing?: number;
|
|
1795
|
-
lineSpacingRule?: string;
|
|
1796
|
-
numPr?: {
|
|
1797
|
-
numId?: number;
|
|
1798
|
-
ilvl?: number;
|
|
1799
|
-
};
|
|
1800
|
-
};
|
|
1801
|
-
hasSelection: boolean;
|
|
1802
|
-
isMultiParagraph: boolean;
|
|
1803
|
-
/** The range belongs to a table-cell story. */
|
|
1804
|
-
inTable: boolean;
|
|
1805
|
-
/** The range covers exactly one non-pilcrow embed unit. */
|
|
1806
|
-
isSingleEmbed: boolean;
|
|
1807
|
-
/** Embed discriminator (`image`, `drawing`, …), else `null`. */
|
|
1808
|
-
embedKind: string | null;
|
|
1809
|
-
/** Convenience flag for a single `image` embed selection. */
|
|
1810
|
-
isImage: boolean;
|
|
1811
|
-
inInsertion: boolean;
|
|
1812
|
-
inDeletion: boolean;
|
|
1813
|
-
}
|
|
1814
|
-
/**
|
|
1815
|
-
* One tracked insertion, deletion, or paragraph-mark revision read from yrs.
|
|
1816
|
-
*
|
|
1817
|
-
* @public
|
|
1818
|
-
*/
|
|
1819
|
-
interface YrsRevisionInfo {
|
|
1820
|
-
revisionId: string;
|
|
1821
|
-
author: string;
|
|
1822
|
-
date: string;
|
|
1823
|
-
kind: 'insertion' | 'deletion' | 'pPrIns' | 'pPrDel' | 'pPrChange' | 'trIns' | 'trDel' | 'tableIns' | 'tableDel';
|
|
1824
|
-
story: string;
|
|
1825
|
-
/** Raw affected text, capped at 80 Unicode code points. */
|
|
1826
|
-
preview: string;
|
|
1827
|
-
range: YrsStoryRange;
|
|
1828
|
-
}
|
|
1829
|
-
/**
|
|
1830
|
-
* Story-local locator for one native table embed.
|
|
1831
|
-
*
|
|
1832
|
-
* @public
|
|
1833
|
-
*/
|
|
1834
|
-
interface YrsTableLoc {
|
|
1835
|
-
story: string;
|
|
1836
|
-
/** Zero-based table ordinal in the parent story. */
|
|
1837
|
-
tableIndex: number;
|
|
1838
|
-
}
|
|
1839
|
-
/**
|
|
1840
|
-
* One table cell addressed in the resolved rectangular grid.
|
|
1841
|
-
*
|
|
1842
|
-
* @public
|
|
1843
|
-
*/
|
|
1844
|
-
interface YrsCellLoc extends YrsTableLoc {
|
|
1845
|
-
row: number;
|
|
1846
|
-
column: number;
|
|
1847
|
-
}
|
|
1848
|
-
/**
|
|
1849
|
-
* Anchor-cell to head-cell rectangular selection, addressed by grid
|
|
1850
|
-
* coordinates rather than document positions.
|
|
1851
|
-
*
|
|
1852
|
-
* @public
|
|
1853
|
-
*/
|
|
1854
|
-
interface YrsTableRange {
|
|
1855
|
-
anchor: YrsCellLoc;
|
|
1856
|
-
head: YrsCellLoc;
|
|
1857
|
-
}
|
|
1858
|
-
/**
|
|
1859
|
-
* Receipt shared by native table-structure and cell-format operations.
|
|
1860
|
-
*
|
|
1861
|
-
* @public
|
|
1862
|
-
*/
|
|
1863
|
-
interface YrsTableReceipt {
|
|
1864
|
-
table: YrsTableLoc;
|
|
1865
|
-
rows: number;
|
|
1866
|
-
columns: number;
|
|
1867
|
-
createdStoryIds: string[];
|
|
1868
|
-
deletedStoryIds: string[];
|
|
1869
|
-
/** Existing stories whose content changed: the table's story, plus a merge's surviving cell. */
|
|
1870
|
-
changedStoryIds: string[];
|
|
1871
|
-
newParaIds: string[];
|
|
1872
|
-
deletedTable: boolean;
|
|
1873
|
-
revisionIds: string[];
|
|
1874
|
-
}
|
|
1875
|
-
/**
|
|
1876
|
-
* OOXML-shaped cell border value passed through to `tcPr.borders`.
|
|
1877
|
-
*
|
|
1878
|
-
* @public
|
|
1879
|
-
*/
|
|
1880
|
-
interface YrsCellBorder {
|
|
1881
|
-
style: string;
|
|
1882
|
-
size?: number;
|
|
1883
|
-
color?: {
|
|
1884
|
-
rgb: string;
|
|
1885
|
-
};
|
|
1886
|
-
}
|
|
1887
|
-
/**
|
|
1888
|
-
* Per-side border patch for {@link YrsSession.setCellBorders}. An omitted side
|
|
1889
|
-
* is left alone, `style: 'none'` authors an explicit no-border, and `null`
|
|
1890
|
-
* drops the authored side.
|
|
1891
|
-
*
|
|
1892
|
-
* @public
|
|
1893
|
-
*/
|
|
1894
|
-
type YrsCellBorders = Partial<Record<'top' | 'bottom' | 'left' | 'right' | 'insideH' | 'insideV', YrsCellBorder | null>>;
|
|
1895
|
-
/** Undo grouping for tracked local transactions. */
|
|
1896
|
-
type YrsUndoCaptureMode = 'auto' | 'manual';
|
|
1897
|
-
/** Outcome of a target-resolving helper edit. @internal */
|
|
1898
|
-
type YrsTargetEditResult = {
|
|
1899
|
-
ok: true;
|
|
1900
|
-
version: string;
|
|
1901
|
-
} | DocxEditRefusal;
|
|
1902
|
-
/** Accepted-view texts around a selection; U+FFFC stands for each inline atom. @internal */
|
|
1903
|
-
interface YrsSelectionText {
|
|
1904
|
-
paraId: string;
|
|
1905
|
-
selectedText: string;
|
|
1906
|
-
paragraphText: string;
|
|
1907
|
-
before: string;
|
|
1908
|
-
after: string;
|
|
1909
|
-
}
|
|
1910
|
-
/**
|
|
1911
|
-
* One live replica of the yrs editing model. Thin typed wrapper over the
|
|
1912
|
-
* wasm `EditSession` — no editing logic on this side of the boundary.
|
|
1913
|
-
*/
|
|
1914
|
-
/** An embedded image's bytes, as its `media:{n}` source displays them. */
|
|
1915
|
-
interface YrsMediaSource {
|
|
1916
|
-
bytes: Uint8Array;
|
|
1917
|
-
mimeType: string;
|
|
1918
|
-
}
|
|
1919
|
-
/** @internal */
|
|
1920
|
-
interface YrsWorkerDocumentMirror {
|
|
1921
|
-
version: string;
|
|
1922
|
-
proposals: DocxProposalRegistryState;
|
|
1923
|
-
}
|
|
1924
|
-
interface YrsSession extends CollaborationReplica {
|
|
1925
|
-
/** The yrs client id this replica writes with. */
|
|
1926
|
-
readonly clientId: number;
|
|
1927
|
-
/** Register raw sfnt bytes in the session's measurement/display font store. */
|
|
1928
|
-
registerFont(bytes: Uint8Array): number;
|
|
1929
|
-
/**
|
|
1930
|
-
* Register a measurement view of `base` carrying the vertical metrics Word
|
|
1931
|
-
* measures `family` with, for a face the host substituted; `base` when the
|
|
1932
|
-
* engine knows no metrics for the family.
|
|
1933
|
-
*/
|
|
1934
|
-
registerSubstituteFont(base: number, family: string): number;
|
|
1935
|
-
/** Clear the session's registered measurement/display fonts. */
|
|
1936
|
-
clearFonts(): void;
|
|
1937
|
-
/** Measure one paragraph through the session's resident text engine. */
|
|
1938
|
-
measureParagraphJson(input: string): string;
|
|
1939
|
-
/** Paginate and retain the measured input and Layout in the session. */
|
|
1940
|
-
layoutDocumentJson(input: string): string;
|
|
1941
|
-
/** Return the compact font requirements for resident region layout. */
|
|
1942
|
-
layoutFontRequirementsJson(input: string): string;
|
|
1943
|
-
/** Paginate and compose section/page regions in the resident engine. */
|
|
1944
|
-
layoutDocumentWithRegionsJson(input: string): string;
|
|
1945
|
-
/** Same pass, but the reply omits the measured arena (fetch it on demand
|
|
1946
|
-
* through {@link YrsSession.retainedKernelInputsJson}). */
|
|
1947
|
-
layoutDocumentWithRegionsRetainedJson(input: string): string;
|
|
1948
|
-
/**
|
|
1949
|
-
* {@link YrsSession.layoutDocumentWithRegionsRetainedJson} a step at a time:
|
|
1950
|
-
* this lowers the body, and each {@link YrsSession.resumeRegionLayout}
|
|
1951
|
-
* measures up to `blocks` more body blocks. `layoutJson` arrives with the
|
|
1952
|
-
* step that completes the pass, equal to the one-call reply. A document
|
|
1953
|
-
* change, a font registration or another layout in between abandons the
|
|
1954
|
-
* pass, and resuming it then throws.
|
|
1955
|
-
*/
|
|
1956
|
-
beginRegionLayout(input: string): YrsRegionLayoutProgress;
|
|
1957
|
-
resumeRegionLayout(blocks: number): YrsRegionLayoutProgress;
|
|
1958
|
-
/** Retained `{ measured, options }` for the main-thread display fallback. */
|
|
1959
|
-
retainedKernelInputsJson(expectedLayoutRevision: number): string;
|
|
1960
|
-
/**
|
|
1961
|
-
* Record region layout `input` as the resident layout without running it
|
|
1962
|
-
* here: a resident worker replica runs it, and snapshots carry it there.
|
|
1963
|
-
* Returns the new layout revision. @internal
|
|
1964
|
-
*/
|
|
1965
|
-
adoptResidentWorkerLayout?(input: string): number;
|
|
1966
|
-
/** The current resident layout ran only in a worker replica. @internal */
|
|
1967
|
-
residentLayoutInWorker?(): boolean;
|
|
1968
|
-
/** Build display primitives against the session's resident font store. */
|
|
1969
|
-
buildDisplayListJson(input: string): string;
|
|
1970
|
-
/** Build a binary FrameDelta v1 against the last host-applied frame. */
|
|
1971
|
-
buildDisplayListFrame(input: string, expectedFrameEpoch: number): Uint8Array;
|
|
1972
|
-
/**
|
|
1973
|
-
* Limit full display builds to pages `start..end` plus the pages already
|
|
1974
|
-
* built; the rest stay unbuilt placeholders carrying their geometry. @internal
|
|
1975
|
-
*/
|
|
1976
|
-
setDisplayWindow(start: number, end: number): void;
|
|
1977
|
-
/** Keep every previously built page while windowed builds are on. @internal */
|
|
1978
|
-
setDisplayRetainBuiltPages(retain: boolean): void;
|
|
1979
|
-
/** @internal */
|
|
1980
|
-
setWindowedIncrementalBuilds(enabled: boolean): void;
|
|
1981
|
-
/** Build the listed unbuilt pages into a FrameDelta v1. @internal */
|
|
1982
|
-
buildDisplayPagesFrame(pages: readonly number[], expectedFrameEpoch: number): Uint8Array;
|
|
1983
|
-
/** Release built pages; null means the request was superseded. @internal */
|
|
1984
|
-
releaseDisplayPagesFrame(pages: number[], expectedFrameEpoch: number): Uint8Array | null;
|
|
1985
|
-
/** Make the next frame a full one, for a host taking over from another engine; no-op once destroyed. */
|
|
1986
|
-
resetFrameBase(): void;
|
|
1987
|
-
/** Caret geometry from the current resident display frame. */
|
|
1988
|
-
residentCaretSnapshot(): YrsResidentCaretSnapshot;
|
|
1989
|
-
/** Apply a collapsed plain-text insertion and return its resident FrameDelta. */
|
|
1990
|
-
applyInput(text: string, expectedFrameEpoch: number): Uint8Array;
|
|
1991
|
-
/**
|
|
1992
|
-
* Apply up to `count` (default 1) collapsed character deletions/paragraph
|
|
1993
|
-
* merges, lay out once, and return the resident FrameDelta.
|
|
1994
|
-
*/
|
|
1995
|
-
applyDelete(direction: 'backward' | 'forward', expectedFrameEpoch: number, count?: number): Uint8Array;
|
|
1996
|
-
/** Characters the last resident deletion removed; fewer than asked at a document boundary. */
|
|
1997
|
-
residentDeletedUnits(): number;
|
|
1998
|
-
/** Instrumented apply used only by opt-in browser performance traces. */
|
|
1999
|
-
applyInputProfiled(text: string, expectedFrameEpoch: number): {
|
|
2000
|
-
frame: Uint8Array;
|
|
2001
|
-
profile: YrsEngineApplyProfile;
|
|
2002
|
-
};
|
|
2003
|
-
/** Instrumented deletion used only by opt-in browser performance traces. */
|
|
2004
|
-
applyDeleteProfiled(direction: 'backward' | 'forward', expectedFrameEpoch: number, count?: number): {
|
|
2005
|
-
frame: Uint8Array;
|
|
2006
|
-
profile: YrsEngineApplyProfile;
|
|
2007
|
-
};
|
|
2008
|
-
/** Snapshot the inputs needed to move resident layout ownership to a worker. */
|
|
2009
|
-
residentWorkerSnapshot(options?: YrsResidentWorkerSyncOptions): YrsResidentWorkerSnapshot | null;
|
|
2010
|
-
/**
|
|
2011
|
-
* Cheap worker-sync probe: the resident layout revision when a worker
|
|
2012
|
-
* snapshot would be available, without encoding document state or copying
|
|
2013
|
-
* font bytes. Steady-state frame builds consult this instead of building a
|
|
2014
|
-
* full snapshot.
|
|
2015
|
-
*/
|
|
2016
|
-
residentWorkerProbe(): {
|
|
2017
|
-
layoutRevision: number;
|
|
2018
|
-
} | null;
|
|
2019
|
-
/** Resident display-list hit/range queries; results are small JSON records. */
|
|
2020
|
-
displayHitTestRegionsJson(pageIndex: number, x: number, y: number): string;
|
|
2021
|
-
displayVerticalMoveJson(position: number, direction: 'up' | 'down', goalX: number): string;
|
|
2022
|
-
displayRangeRectsJson(from: number, to: number): string;
|
|
2023
|
-
displayRangeRectsRegionJson(region: 'body' | 'header' | 'footer', rId: string, from: number, to: number): string;
|
|
2024
|
-
/** Read a glyph outline from the session's resident font store. */
|
|
2025
|
-
outlineGlyphJson(fontId: number, glyphId: number): string;
|
|
2026
|
-
/** Hydrates from an encoded yrs v1 update (typically a peer's {@link encodeState} output). */
|
|
2027
|
-
loadState(update: Uint8Array): void;
|
|
2028
|
-
/** Parses a DOCX, seeds its stories, and returns thin host metadata; see {@link openDocx}. */
|
|
2029
|
-
seedFromDocx(bytes: Uint8Array, options?: YrsOpeningOptions): YrsDocxHost;
|
|
2030
|
-
/**
|
|
2031
|
-
* Parses a DOCX and optionally seeds its stories. Seeding starts a new
|
|
2032
|
-
* opening, so its session anchors never resolve in another opening, even
|
|
2033
|
-
* one seeded alike by the same client; see {@link beginOpening}.
|
|
2034
|
-
*/
|
|
2035
|
-
openDocx(bytes: Uint8Array, seedStories: boolean, options?: YrsOpeningOptions): YrsDocxHost;
|
|
2036
|
-
/**
|
|
2037
|
-
* Opens a DOCX for display only, from the body's first `blocks` blocks:
|
|
2038
|
-
* enough to lay out its first pages with a prefix pass before the whole
|
|
2039
|
-
* document is opened. The session cannot save. `null`, opening nothing,
|
|
2040
|
-
* for a document with a float placed from outside the text or a section
|
|
2041
|
-
* with columns, which no cut of the body lays out like the whole: open it
|
|
2042
|
-
* with {@link openDocx}. @internal
|
|
2043
|
-
*/
|
|
2044
|
-
openDocxPreview(bytes: Uint8Array, blocks: number): YrsDocxHost | null;
|
|
2045
|
-
/** Opened by {@link openDocxPreview}: its document refuses every change. @internal */
|
|
2046
|
-
isDisplayOnly(): boolean;
|
|
2047
|
-
/**
|
|
2048
|
-
* Marks this empty session as showing a preview another engine opened: it refuses every
|
|
2049
|
-
* change, and {@link openDocxPreview} can still load the preview here. @internal
|
|
2050
|
-
*/
|
|
2051
|
-
markDisplayOnly(): void;
|
|
2052
|
-
/**
|
|
2053
|
-
* Marks whether the document is a preview's, as a replica of one is: its
|
|
2054
|
-
* layouts render NUMPAGES empty. @internal
|
|
2055
|
-
*/
|
|
2056
|
-
setPartialDocument(partial: boolean): void;
|
|
2057
|
-
/**
|
|
2058
|
-
* The region layout of only as much of the body as fills `pages` pages;
|
|
2059
|
-
* a reply marked `provisional` covers a prefix. @internal
|
|
2060
|
-
*/
|
|
2061
|
-
layoutDocumentWithRegionsPrefixRetainedJson(input: string, pages: number): string;
|
|
2062
|
-
/**
|
|
2063
|
-
* Starts a new opening of the document: its generation, replicated to
|
|
2064
|
-
* every replica, becomes part of every session anchor. Every seeding entry
|
|
2065
|
-
* point calls it; call it after building a document another way.
|
|
2066
|
-
*/
|
|
2067
|
-
beginOpening(generation?: string): void;
|
|
2068
|
-
/** Unions seeded opaque sequence names into document state. @internal */
|
|
2069
|
-
seedOpaqueSequences(names: readonly string[]): void;
|
|
2070
|
-
/** Materializes the retained canonical package for compatibility APIs. */
|
|
2071
|
-
materializeDocx(): Document | null;
|
|
2072
|
-
/**
|
|
2073
|
-
* The displayed bytes and media type of the package part a `media:{n}`
|
|
2074
|
-
* image source names, or `null` for any other source or a destroyed session.
|
|
2075
|
-
*/
|
|
2076
|
-
mediaSource(token: string): YrsMediaSource | null;
|
|
2077
|
-
/** Changes on package opening and session destruction. */
|
|
2078
|
-
mediaScope(): number;
|
|
2079
|
-
/** The `data:` URL a token stands for, or `null` when unavailable or destroyed. */
|
|
2080
|
-
mediaDataUrl(token: string): string | null;
|
|
2081
|
-
/**
|
|
2082
|
-
* Lays this replica's `data:` image sources out as the `media:{n}` tokens a
|
|
2083
|
-
* snapshot's `mediaSources` names. @internal
|
|
2084
|
-
*/
|
|
2085
|
-
loadMediaSources(json: string): void;
|
|
2086
|
-
/**
|
|
2087
|
-
* Seeds stories and returns paragraph IDs in document order. Seeding a
|
|
2088
|
-
* document that has no opening yet starts one; see {@link beginOpening}.
|
|
2089
|
-
*/
|
|
2090
|
-
loadStories(stories: readonly YrsStorySeed[]): Record<string, string[]>;
|
|
2091
|
-
/** Full document state as one yrs v1 update (Yjs wire format). */
|
|
2092
|
-
encodeState(): Uint8Array;
|
|
2093
|
-
/** Current Yrs state vector in the Yjs v1 wire format. */
|
|
2094
|
-
encodeStateVector(): Uint8Array;
|
|
2095
|
-
/** Full state, or only the state missing from a peer vector. */
|
|
2096
|
-
encodeStateAsUpdate(remoteStateVector?: Uint8Array): Uint8Array;
|
|
2097
|
-
/** Applies a remote/incremental yrs v1 update. */
|
|
2098
|
-
applyUpdate(update: Uint8Array): CollaborationTextInsertion | null;
|
|
2099
|
-
/** Apply a same-user worker update under the local undo origin. @internal */
|
|
2100
|
-
applyLocalUpdate(update: Uint8Array): void;
|
|
2101
|
-
/** Adopt another replica's host batch outside undo history. @internal */
|
|
2102
|
-
applyHostUpdate(update: Uint8Array, stories?: readonly string[]): void;
|
|
2103
|
-
/**
|
|
2104
|
-
* Subscribes to every committed transaction's v1 update (local AND
|
|
2105
|
-
* applied-remote). Returns an unsubscribe function.
|
|
2106
|
-
*/
|
|
2107
|
-
onUpdate(listener: (update: Uint8Array, origin: CollaborationUpdateOrigin) => void): () => void;
|
|
2108
|
-
/** Encode one location as a binary Yrs sticky position. */
|
|
2109
|
-
encodeStickyPosition(loc: YrsLoc): YrsStickyPosition;
|
|
2110
|
-
/** Resolve a binary Yrs sticky position against this replica. */
|
|
2111
|
-
resolveStickyPosition(position: YrsStickyPosition): YrsLoc | null;
|
|
2112
|
-
/** Store this peer's awareness selection as sticky positions. */
|
|
2113
|
-
setSelection(anchor: YrsLoc, head?: YrsLoc): void;
|
|
2114
|
-
/** Resolve this peer's current sticky selection, or null before initialization. */
|
|
2115
|
-
selection(): YrsSelection | null;
|
|
2116
|
-
/** Encode the current selection as binary Yrs sticky indices. */
|
|
2117
|
-
encodeSelection(): CollaborationCursor | null;
|
|
2118
|
-
/** Resolve a peer's binary Yrs sticky indices against this replica. */
|
|
2119
|
-
resolveSelection(cursor: CollaborationCursor): YrsSelection | null;
|
|
2120
|
-
/** Store this peer's rectangular table selection outside the document. */
|
|
2121
|
-
setCellSelection(range: YrsTableRange): void;
|
|
2122
|
-
/** Resolve the current sticky cell selection, or null before initialization. */
|
|
2123
|
-
cellSelection(): YrsTableRange | null;
|
|
2124
|
-
/** Begin local-origin undo capture once import/seeding has completed. */
|
|
2125
|
-
beginUndoCapture(): void;
|
|
2126
|
-
/** Separates subsequent local edits from the current undo step; safe before capture starts. */
|
|
2127
|
-
addUndoBoundary(): void;
|
|
2128
|
-
/** Changes grouping policy, closing the current group while retaining history. */
|
|
2129
|
-
setUndoCaptureMode(mode: YrsUndoCaptureMode): void;
|
|
2130
|
-
/** Current grouping policy; defaults to auto. */
|
|
2131
|
-
undoCaptureMode(): YrsUndoCaptureMode;
|
|
2132
|
-
/** Stories changed by the latest undo or redo, sorted. */
|
|
2133
|
-
historyStories(): string[];
|
|
2134
|
-
/** Undo/redo only local-origin direct operations (never remote/system transactions). */
|
|
2135
|
-
undo(): boolean;
|
|
2136
|
-
redo(): boolean;
|
|
2137
|
-
canUndo(): boolean;
|
|
2138
|
-
canRedo(): boolean;
|
|
2139
|
-
/** Adds a story with one paragraph; the receipt carries its paraId. */
|
|
2140
|
-
createStory(storyId: string, initialText: string, pStyle?: string, alignment?: string): YrsParagraphReceipt;
|
|
2141
|
-
/** Removes a complete story (including an unreachable table-cell story). */
|
|
2142
|
-
deleteStory(storyId: string): void;
|
|
2143
|
-
/** Inserts a row above or below the cell that `at` resolves into. */
|
|
2144
|
-
insertRow(at: YrsCellLoc, side: 'above' | 'below', suggesting?: YrsAuthor): YrsTableReceipt;
|
|
2145
|
-
/** Inserts a rectangular structural table at a paragraph-keyed location. */
|
|
2146
|
-
insertTable(at: YrsLoc, rows: number, columns: number, suggesting?: YrsAuthor): YrsTableReceipt;
|
|
2147
|
-
/** Inserts a column left or right of the cell that `at` resolves into. */
|
|
2148
|
-
insertColumn(at: YrsCellLoc, side: 'left' | 'right'): YrsTableReceipt;
|
|
2149
|
-
/** Deletes every row covered by an explicit rectangular cell range. */
|
|
2150
|
-
deleteRow(range: YrsTableRange, suggesting?: YrsAuthor): YrsTableReceipt;
|
|
2151
|
-
/** Deletes every column covered by an explicit rectangular cell range. */
|
|
2152
|
-
deleteColumn(range: YrsTableRange): YrsTableReceipt;
|
|
2153
|
-
/** Removes a complete table plus its reachable cell stories. */
|
|
2154
|
-
deleteTable(table: YrsTableLoc): YrsTableReceipt;
|
|
2155
|
-
/** Merges a rectangular range into its top-left cell. */
|
|
2156
|
-
mergeCells(range: YrsTableRange): YrsTableReceipt;
|
|
2157
|
-
/** Splits the merged cell covering `at` into one cell per grid slot. */
|
|
2158
|
-
splitCell(at: YrsCellLoc, rows?: number, columns?: number): YrsTableReceipt;
|
|
2159
|
-
/** Sets or clears the selected cells' background color. */
|
|
2160
|
-
setCellShading(range: YrsTableRange, color: string | null): YrsTableReceipt;
|
|
2161
|
-
/**
|
|
2162
|
-
* Merges an OOXML-shaped patch into selected cells' `tcPr`. JSON `null`
|
|
2163
|
-
* clears a property; merge/split-owned span keys are rejected.
|
|
2164
|
-
*/
|
|
2165
|
-
setCellTextFormat(range: YrsTableRange, patch: Readonly<Record<string, unknown>>): YrsTableReceipt;
|
|
2166
|
-
/**
|
|
2167
|
-
* Merges border sides into the selected cells. `insideH`/`insideV` resolve
|
|
2168
|
-
* per cell to the physical edges interior to the selection.
|
|
2169
|
-
*/
|
|
2170
|
-
setCellBorders(range: YrsTableRange, borders: YrsCellBorders): YrsTableReceipt;
|
|
2171
|
-
/** Sets one authored grid-column width in twips. */
|
|
2172
|
-
setColumnWidth(at: YrsCellLoc, widthTwips: number): YrsTableReceipt;
|
|
2173
|
-
/** Sets the table-wide preferred width in twips. */
|
|
2174
|
-
setTableWidth(table: YrsTableLoc, widthTwips: number): YrsTableReceipt;
|
|
2175
|
-
/** Inserts paragraph-break-free text. Suggesting mode mints a revision. */
|
|
2176
|
-
insertText(at: YrsLoc, text: string, suggesting?: YrsAuthor): YrsRevisionReceipt;
|
|
2177
|
-
/**
|
|
2178
|
-
* Deletes a range (plain) or marks it as a suggested deletion (suggesting).
|
|
2179
|
-
* A range spanning paragraphs also merges them (pilcrow-as-character).
|
|
2180
|
-
*/
|
|
2181
|
-
deleteRange(range: YrsStoryRange, suggesting?: YrsAuthor): YrsRevisionReceipt;
|
|
2182
|
-
/** Replaces a range with text in one transaction (one shared revision when suggesting). */
|
|
2183
|
-
replaceRange(range: YrsStoryRange, text: string, suggesting?: YrsAuthor): YrsReplaceReceipt;
|
|
2184
|
-
/**
|
|
2185
|
-
* Splits a paragraph by inserting one pilcrow. The FIRST half keeps the
|
|
2186
|
-
* original paraId; the SECOND half is re-minted (`secondParaId`).
|
|
2187
|
-
*/
|
|
2188
|
-
splitParagraph(at: YrsLoc, suggesting?: YrsAuthor): YrsSplitReceipt;
|
|
2189
|
-
/** Merges `paraId` with the FOLLOWING paragraph. Errors on the final paragraph. */
|
|
2190
|
-
mergeParagraphs(story: string, paraId: string, suggesting?: YrsAuthor): YrsRevisionReceipt;
|
|
2191
|
-
/**
|
|
2192
|
-
* Toggles one run mark across a range: removes it when every unit already
|
|
2193
|
-
* carries it, otherwise adds it. Adding superscript clears subscript and
|
|
2194
|
-
* vice versa.
|
|
2195
|
-
*/
|
|
2196
|
-
toggleMark(range: YrsStoryRange, mark: YrsRunMark): void;
|
|
2197
|
-
/** Applies set-valued direct formatting; omitted fields are kept and `null` fields clear. */
|
|
2198
|
-
formatRange(range: YrsStoryRange, delta: YrsInlineFormatDelta): void;
|
|
2199
|
-
/** Sets or clears the protected hyperlink attribute over a non-empty range. */
|
|
2200
|
-
setHyperlink(range: YrsStoryRange, hyperlink: YrsHyperlinkAttrs | null): void;
|
|
2201
|
-
/** Clears direct formatting while retaining hyperlinks and tracked-change stamps. */
|
|
2202
|
-
clearFormatting(range: YrsStoryRange): void;
|
|
2203
|
-
/** Applies a paragraph style id to every paragraph intersecting the range. */
|
|
2204
|
-
applyParagraphStyle(range: YrsStoryRange, styleId: string, suggesting?: YrsAuthor): void;
|
|
2205
|
-
/** Applies tri-state paragraph properties to every paragraph intersecting the range. */
|
|
2206
|
-
setParagraphAttrs(range: YrsStoryRange, attrs: YrsParagraphAttrs, suggesting?: YrsAuthor): void;
|
|
2207
|
-
/** Inserts one inline image embed, optionally as a tracked insertion. */
|
|
2208
|
-
insertImage(at: YrsLoc, image: Readonly<Record<string, unknown>>, suggesting?: YrsAuthor): YrsRevisionReceipt;
|
|
2209
|
-
/**
|
|
2210
|
-
* Sets the value of a content-control embed addressed by stable payload id. A string fills a
|
|
2211
|
-
* text control's content as one version-checked step and throws when the fill is refused.
|
|
2212
|
-
*/
|
|
2213
|
-
setContentControlValue(embedId: string, value: YrsContentControlValue): void;
|
|
2214
|
-
/** {@link setContentControlValue} for the embed at a paragraph-keyed position. */
|
|
2215
|
-
setContentControlValueAt(at: YrsLoc, value: YrsContentControlValue): void;
|
|
2216
|
-
/**
|
|
2217
|
-
* Removes an authored value from a content-control embed. It never erases a text control's
|
|
2218
|
-
* text: fill it with `''` for that.
|
|
2219
|
-
*/
|
|
2220
|
-
clearContentControlValue(embedId: string): void;
|
|
2221
|
-
/** Commits image size/wrapping/position fields in one transaction. */
|
|
2222
|
-
setImageGeometry(embedId: string, geometry: YrsImageGeometry): void;
|
|
2223
|
-
/** Commits image geometry at a paragraph-keyed position; reaches images that share an id. */
|
|
2224
|
-
setImageGeometryAt(at: YrsLoc, geometry: YrsImageGeometry): void;
|
|
2225
|
-
/** Inserts a native page-break embed at a paragraph-keyed location. */
|
|
2226
|
-
insertPageBreak(at: YrsLoc): void;
|
|
2227
|
-
/** Inserts a native section-break embed at a paragraph-keyed location. */
|
|
2228
|
-
insertSectionBreak(at: YrsLoc, type: 'nextPage' | 'continuous' | 'oddPage' | 'evenPage'): void;
|
|
2229
|
-
/** Inserts a typed watermark embed at a paragraph-keyed location. */
|
|
2230
|
-
insertWatermark(at: YrsLoc, watermark: YrsWatermark): void;
|
|
2231
|
-
/**
|
|
2232
|
-
* Applies raw story operations in one transaction, then repairs any
|
|
2233
|
-
* paragraph identity a pilcrow they insert or re-key duplicates and
|
|
2234
|
-
* promotes an editor-only paragraph they author into.
|
|
2235
|
-
*/
|
|
2236
|
-
applyRawOps(story: string, ops: readonly YrsRawOp[]): void;
|
|
2237
|
-
/**
|
|
2238
|
-
* Applies seed raw operations with deterministic item ordering. A
|
|
2239
|
-
* `setComment` for a comment already seeded adds its ranges to it.
|
|
2240
|
-
*/
|
|
2241
|
-
applySeedRawOps(story: string, ops: readonly YrsRawOp[]): void;
|
|
2242
|
-
/** Sets one paragraph property (any JSON value). `paraId` is reserved. */
|
|
2243
|
-
setParagraphAttr(paraId: string, key: string, value: unknown): void;
|
|
2244
|
-
/** Adds a sticky-anchored comment over one or more ranges. */
|
|
2245
|
-
addComment(ranges: readonly YrsStoryRange[], author: string, date: string, body: unknown): YrsCommentReceipt;
|
|
2246
|
-
/** Reanchors an existing comment with non-empty ranges; preserves metadata and joins local undo capture. */
|
|
2247
|
-
setCommentRanges(commentId: string, ranges: readonly YrsStoryRange[]): void;
|
|
2248
|
-
/**
|
|
2249
|
-
* Accepts tracked changes: pending insertions become plain content,
|
|
2250
|
-
* pending deletions are carried out; a `pPrIns` paragraph mark clears (the
|
|
2251
|
-
* split stays), a `pPrDel` mark joins with the following paragraph (whose
|
|
2252
|
-
* pPr survives — Word's surviving-`w:p` rule). Resolving never stamps a new
|
|
2253
|
-
* revision. Throws on an unknown revision id.
|
|
2254
|
-
*/
|
|
2255
|
-
acceptChange(target: YrsChangeTarget): YrsResolveReceipt;
|
|
2256
|
-
/**
|
|
2257
|
-
* Rejects tracked changes — the inverse of {@link acceptChange}: pending
|
|
2258
|
-
* insertions roll back, pending deletions restore their text; a `pPrIns`
|
|
2259
|
-
* mark joins back with the following paragraph, a `pPrDel` mark clears.
|
|
2260
|
-
*/
|
|
2261
|
-
rejectChange(target: YrsChangeTarget): YrsResolveReceipt;
|
|
2262
|
-
/** Aggregate toolbar/a11y state from yrs over one paragraph-addressed range. */
|
|
2263
|
-
selectionContext(range: YrsStoryRange): YrsSelectionContext;
|
|
2264
|
-
/** Enumerate tracked changes across every story in deterministic order. */
|
|
2265
|
-
listRevisions(): YrsRevisionInfo[];
|
|
2266
|
-
/** Current offsets of a comment's sticky anchors. Throws when an anchor no longer resolves. */
|
|
2267
|
-
resolveComment(commentId: string): YrsResolvedCommentAnchor[];
|
|
2268
|
-
/** Every comment the session holds, sorted by id. @internal */
|
|
2269
|
-
listComments(): YrsCommentInfo[];
|
|
2270
|
-
/** Story ids in the document, sorted. */
|
|
2271
|
-
storyIds(): string[];
|
|
2272
|
-
/** Whether the document has a story with this id, without listing them all. */
|
|
2273
|
-
hasStory(story: string): boolean;
|
|
2274
|
-
/** Story length in UTF-16 units (every embed, pilcrows included, counts 1). */
|
|
2275
|
-
storyLength(story: string): number;
|
|
2276
|
-
/** Returns the story's canonical-stream checksum. */
|
|
2277
|
-
storyChecksum(story: string): bigint;
|
|
2278
|
-
/** Lowers a story to layout blocks and rejects unsupported embeds. */
|
|
2279
|
-
yrsBlocksForStory(story: string, env?: YrsRenderEnv): unknown[];
|
|
2280
|
-
/** Paragraph snapshots in document order. */
|
|
2281
|
-
paragraphs(story: string): YrsParagraph[];
|
|
2282
|
-
/** Literal search in document order. */
|
|
2283
|
-
searchText(query: string, options?: YrsTextSearchOptions): YrsTextMatch[];
|
|
2284
|
-
/** Paragraph ids and inline-unit lengths, resolved in one Rust story traversal. */
|
|
2285
|
-
paragraphSpans(story: string): YrsParagraphLength[];
|
|
2286
|
-
/** The raw formatted-segment view (the render bridge's input). */
|
|
2287
|
-
storySegments(story: string): YrsStorySegment[];
|
|
2288
|
-
/**
|
|
2289
|
-
* The current story revision and the sorted ids of the stories created,
|
|
2290
|
-
* edited, or deleted after revision `since` (0 lists every story).
|
|
2291
|
-
*/
|
|
2292
|
-
storiesChangedSince(since: number): {
|
|
2293
|
-
revision: number;
|
|
2294
|
-
stories: string[];
|
|
2295
|
-
};
|
|
2296
|
-
/**
|
|
2297
|
-
* One digest per unit of {@link YrsSession.storySegments}, split after each
|
|
2298
|
-
* pilcrow. Equal digests mean equal segments.
|
|
2299
|
-
*/
|
|
2300
|
-
storySegmentUnitDigests(story: string): string[];
|
|
2301
|
-
/** The segments of the listed units, each as {@link YrsSession.storySegments} gives them. */
|
|
2302
|
-
storySegmentUnits(story: string, units: readonly number[]): YrsStorySegment[][];
|
|
2303
|
-
/**
|
|
2304
|
-
* The payload of the story's `tableIndex`-th table embed, as
|
|
2305
|
-
* {@link YrsSession.storySegments} gives it, or null when there is no such
|
|
2306
|
-
* table. Reads the one table rather than the whole story.
|
|
2307
|
-
*/
|
|
2308
|
-
tablePayload(story: string, tableIndex: number): Record<string, unknown> | null;
|
|
2309
|
-
/** A paragraph's story span (start unit, pilcrow index). */
|
|
2310
|
-
locateParagraph(story: string, paraId: string): YrsParagraphSpan;
|
|
2311
|
-
/** How many paragraphs of `story` carry `paraId`: 0, 1, or 2 for two or more. */
|
|
2312
|
-
paragraphIdCount(story: string, paraId: string): number;
|
|
2313
|
-
/**
|
|
2314
|
-
* Session, persisted and source anchors of every paragraph, including the
|
|
2315
|
-
* source package's paragraphs outside the stories, and the Word paragraph ID
|
|
2316
|
-
* each saves with. Reads only.
|
|
2317
|
-
*/
|
|
2318
|
-
paragraphIdentities(): DocxParagraphIdentitySnapshot;
|
|
2319
|
-
/**
|
|
2320
|
-
* Gives every paragraph that saves without a Word paragraph ID a fresh one,
|
|
2321
|
-
* editor-only paragraphs excepted, and repairs duplicates, so persisted
|
|
2322
|
-
* anchors survive save and reopen. Source IDs and saved claims keep their
|
|
2323
|
-
* IDs over unsaved claims and copies. A replicated change outside undo
|
|
2324
|
-
* history that later saves keep; a refusal changes nothing.
|
|
2325
|
-
*/
|
|
2326
|
-
persistParagraphIds(): DocxParagraphIdentityReceipt;
|
|
2327
|
-
/** Resolves an anchor to the paragraph that currently holds it. Reads only. */
|
|
2328
|
-
resolveParagraphAnchor(anchor: DocxParagraphAnchor): DocxParagraphAnchorResult;
|
|
2329
|
-
/** The Word paragraph ID each paragraph of a story saves with, in pilcrow order. @internal */
|
|
2330
|
-
storyParagraphIds(story: string): Array<string | null>;
|
|
2331
|
-
/** The paragraph IDs a save of the session applies. @internal */
|
|
2332
|
-
paragraphSavePlan(): DocxParagraphSavePlan;
|
|
2333
|
-
/**
|
|
2334
|
-
* Publishes the `[owner, paraId]` pairs a save captured and returns those
|
|
2335
|
-
* whose binding changed since. @internal
|
|
2336
|
-
*/
|
|
2337
|
-
recordSavedParagraphIds(saved: ReadonlyArray<readonly [string, string]>): Array<[string, string]>;
|
|
2338
|
-
/**
|
|
2339
|
-
* The Word paragraph IDs a DOCX package holds, by part URI, in document
|
|
2340
|
-
* order and upper case. Reads only. @internal
|
|
2341
|
-
*/
|
|
2342
|
-
writtenParagraphIds(bytes: Uint8Array): Record<string, string[]>;
|
|
2343
|
-
/**
|
|
2344
|
-
* The session-scoped version token. It changes on every committed change, local or remote,
|
|
2345
|
-
* and when the document is replaced; compare tokens only within this session.
|
|
2346
|
-
*/
|
|
2347
|
-
version(): string;
|
|
2348
|
-
/** Paragraph texts in one view, with the version they were read at. */
|
|
2349
|
-
readParagraphs(request: DocxReadParagraphsRequest): DocxReadParagraphsResult;
|
|
2350
|
-
/** Exact, case-sensitive, paragraph-local search; overlapping matches count separately. */
|
|
2351
|
-
findText(request: DocxFindTextRequest): DocxFindTextResult;
|
|
2352
|
-
/** Resolves and checks an edit batch without changing anything or reserving ids. */
|
|
2353
|
-
validateEdits(request: DocxEditRequest): DocxValidationResult;
|
|
2354
|
-
/**
|
|
2355
|
-
* Applies every step or none, resolving all targets against `expectVersion`. Policy
|
|
2356
|
-
* failures are returned; malformed requests throw.
|
|
2357
|
-
*/
|
|
2358
|
-
applyEdits(request: DocxEditRequest): DocxEditResult;
|
|
2359
|
-
/** Resolves a text target and formats it in one call. @internal */
|
|
2360
|
-
formatTextTarget(target: DocxTextTarget, delta: YrsInlineFormatDelta): YrsTargetEditResult;
|
|
2361
|
-
/** Resolves a text target and anchors side-map comment `id` over it in one call. @internal */
|
|
2362
|
-
commentTextTarget(target: DocxTextTarget, comment: {
|
|
2363
|
-
id: string;
|
|
2364
|
-
author: string;
|
|
2365
|
-
date: string;
|
|
2366
|
-
body: unknown;
|
|
2367
|
-
}): YrsTargetEditResult;
|
|
2368
|
-
/** Accepted-view texts around a paragraph-keyed selection. @internal */
|
|
2369
|
-
selectionText(range: YrsStoryRange): YrsSelectionText;
|
|
2370
|
-
/**
|
|
2371
|
-
* Proposes a round of tracked changes: every new proposal resolves against `expectVersion` and
|
|
2372
|
-
* the round applies as one batch outside undo history, or nothing changes. A retried id with
|
|
2373
|
-
* the same edit is a no-op; the same id with another edit refuses. Opening another document
|
|
2374
|
-
* forgets every proposal.
|
|
2375
|
-
*/
|
|
2376
|
-
proposeChanges(request: DocxProposalRequest): DocxProposalResult;
|
|
2377
|
-
/**
|
|
2378
|
-
* Sets how proposals render. Decisions change neither the document, its version nor undo
|
|
2379
|
-
* history; each call that changes one increments `previewVersion`.
|
|
2380
|
-
*/
|
|
2381
|
-
setProposalStates(request: DocxProposalStateRequest): DocxProposalResult;
|
|
2382
|
-
/**
|
|
2383
|
-
* Withdraws proposals, settling each as its decision previews it: accepted ones apply for good,
|
|
2384
|
-
* rejected and undecided ones are removed. The settlement is one change against `expectVersion`
|
|
2385
|
-
* outside undo history, so a later round resolves against the text the preview showed.
|
|
2386
|
-
*/
|
|
2387
|
-
withdrawProposals(request: DocxProposalWithdrawRequest): DocxProposalResult;
|
|
2388
|
-
/** The proposals in the order they were made. */
|
|
2389
|
-
getProposals(): DocxProposalSnapshot;
|
|
2390
|
-
/** @internal */
|
|
2391
|
-
mirrorWorkerDocument(mirror: YrsWorkerDocumentMirror | null): void;
|
|
2392
|
-
/** @internal */
|
|
2393
|
-
workerDocumentMirrored(): boolean;
|
|
2394
|
-
/** Listens for new proposals, decisions and a forgotten registry. Returns the unsubscribe. */
|
|
2395
|
-
onProposalChange(listener: (snapshot: DocxProposalSnapshot) => void): () => void;
|
|
2396
|
-
/**
|
|
2397
|
-
* Exports the committed document as read-only structured content with the version it was read
|
|
2398
|
-
* at; anchors resolve against that version. Nothing is committed, flushed or published.
|
|
2399
|
-
* Unusable options are refused; malformed ones throw.
|
|
2400
|
-
*/
|
|
2401
|
-
exportStructured(options: DocxExportOptions): DocxExportResult<DocxStructuredContent>;
|
|
2402
|
-
/** {@link exportStructured} rendered as Markdown from the same read. */
|
|
2403
|
-
exportMarkdown(options: DocxExportOptions): DocxExportResult<DocxMarkdownContent>;
|
|
2404
|
-
/**
|
|
2405
|
-
* {@link exportStructured} with the page map of the region layout this session retains. The
|
|
2406
|
-
* layout must have lowered the current version from this session's stories with section,
|
|
2407
|
-
* settings and note metadata that describe it, and measured every font the document uses
|
|
2408
|
-
* with the fonts registered now; this call lays nothing out, flushes nothing and loads no
|
|
2409
|
-
* font, and refuses a stale or incomplete layout.
|
|
2410
|
-
*/
|
|
2411
|
-
exportStructuredWithPages(options: DocxPageExportOptions): DocxExportResult<DocxPagedStructuredContent<DocxLayoutMap>>;
|
|
2412
|
-
/**
|
|
2413
|
-
* {@link exportStructuredWithPages} for an editor: `currentRequest` is the region layout
|
|
2414
|
-
* request it would lay the document out with now, and the retained layout must have used the
|
|
2415
|
-
* same fonts, measurement defaults, render environment and pagination options. @internal
|
|
2416
|
-
*/
|
|
2417
|
-
exportStructuredWithPagesFor(options: DocxPageExportOptions, currentRequest: string): DocxExportResult<DocxPagedStructuredContent<DocxLayoutMap>>;
|
|
2418
|
-
/**
|
|
2419
|
-
* Lays this private session out with `fonts` alone, in a measurement font store of its own,
|
|
2420
|
-
* and exports it with snapshot anchors and a snapshot map. `fonts` holds the font files back
|
|
2421
|
-
* to back and `fontLengths` their lengths; `request`'s font chains name them by index. Throws
|
|
2422
|
-
* for a font the engine rejects. @internal
|
|
2423
|
-
*/
|
|
2424
|
-
exportSnapshotWithPrivateFonts(fonts: Uint8Array, fontLengths: Uint32Array, request: string, options: DocxPageExportOptions): {
|
|
2425
|
-
ok: true;
|
|
2426
|
-
content: DocxPagedStructuredContent<DocxSnapshotLayoutMap>;
|
|
2427
|
-
} | {
|
|
2428
|
-
ok: false;
|
|
2429
|
-
failure: DocxExportFailure;
|
|
2430
|
-
};
|
|
2431
|
-
/**
|
|
2432
|
-
* The heading paragraphs of `story` in document order, classified as the structured export
|
|
2433
|
-
* classifies them. Throws for an unknown story.
|
|
2434
|
-
*/
|
|
2435
|
-
headings(story: string): DocxParagraphHeading[];
|
|
2436
|
-
/**
|
|
2437
|
-
* The content controls of the committed document with the version they were read at; control
|
|
2438
|
-
* ids and anchors resolve against that version. Nothing is committed, flushed or published.
|
|
2439
|
-
* Unusable options are refused; malformed ones throw.
|
|
2440
|
-
*/
|
|
2441
|
-
listContentControls(options?: DocxContentControlsOptions): DocxContentControlsResult;
|
|
2442
|
-
/** The controls {@link listContentControls} lists that match `query` exactly; none or several. */
|
|
2443
|
-
findContentControls(query: DocxContentControlQuery, options?: DocxContentControlsOptions): DocxContentControlsResult;
|
|
2444
|
-
/** Drops the observer and frees the wasm-side replica. Idempotent. */
|
|
2445
|
-
destroy(): void;
|
|
2446
|
-
}
|
|
2447
|
-
/** Options for {@link createYrsSession}. */
|
|
2448
|
-
interface CreateYrsSessionOptions {
|
|
2449
|
-
/**
|
|
2450
|
-
* The yrs client id (non-negative safe integer). Omit to allocate a random
|
|
2451
|
-
* 32-bit id, yjs-style.
|
|
2452
|
-
*/
|
|
2453
|
-
clientId?: number;
|
|
2454
|
-
}
|
|
2455
|
-
/**
|
|
2456
|
-
* Decodes the host metadata a resident worker's `open` replied with, for the
|
|
2457
|
-
* package `source` it opened. @internal
|
|
2458
|
-
*/
|
|
2459
|
-
declare function decodeDocxHostJson(json: string, source: Uint8Array): YrsDocxHost;
|
|
2460
|
-
/**
|
|
2461
|
-
* Creates a yrs editing replica. The first call dynamically imports and
|
|
2462
|
-
* initializes the embedded docx-edit wasm (~440KB base64) — callers must
|
|
2463
|
-
* load it lazily so non-editor consumers avoid the wasm startup cost.
|
|
2464
|
-
*/
|
|
2465
|
-
declare function createYrsSession(options?: CreateYrsSessionOptions): Promise<YrsSession>;
|
|
2466
|
-
|
|
2467
|
-
export { type DocxSavedDocument as $, type AnchorGeometryTarget as A, type DocxParagraphAnchor as B, type CollaborationReplica as C, type DocxOccurrence as D, type DocxParagraphAnchorResult as E, type DocxParagraphIdAssignment as F, type DocxParagraphIdDiagnostic as G, type DocxParagraphIdOrigin as H, type DocxParagraphIdRefusal as I, type DocxParagraphIdentity as J, type DocxParagraphIdentityReceipt as K, type DocxParagraphIdentitySnapshot as L, type DocxParagraphOrigin as M, type DocxParagraphRef as N, type DocxParagraphSavePlan as O, type DocxPersistedParagraphAnchor as P, type DocxProposalFailure as Q, type DocxProposalInput as R, type DocxProposalRecord as S, type DocxProposalRegistryState as T, type DocxProposalRequest as U, type DocxProposalResult as V, type DocxProposalSnapshot as W, type DocxProposalState as X, type YrsSession as Y, type DocxProposalStateRequest as Z, type DocxProposalWithdrawRequest as _, type YrsRenderEnv as a, type YrsResolvedCommentAnchor as a$, type DocxSavedParagraph as a0, type DocxSessionParagraphAnchor as a1, type DocxSessionSave as a2, type DocxSourceParagraphAnchor as a3, type DocxSourceStory as a4, type ProposalDisplayTarget as a5, type ProposalGeometryMirror as a6, type ProposalGeometryReader as a7, type ProposalGeometryRevision as a8, type ProposalGeometryTarget as a9, type YrsLocProjection as aA, type YrsMediaSource as aB, type YrsNumberingProperties as aC, type YrsOpeningOptions as aD, type YrsParaOffset as aE, type YrsParagraph as aF, type YrsParagraphAttrs as aG, type YrsParagraphLength as aH, type YrsParagraphReceipt as aI, type YrsParagraphSeed as aJ, type YrsParagraphSpan as aK, type YrsParagraphTabStop as aL, type YrsPointerProjectionTarget as aM, type YrsPositionOutline as aN, YrsPositionProjection as aO, type YrsProjectedCell as aP, type YrsProjectedNode as aQ, type YrsProjectedTable as aR, type YrsRawOp as aS, type YrsRegionLayoutProgress as aT, type YrsReplaceReceipt as aU, type YrsResidentCaretRect as aV, type YrsResidentCaretSnapshot as aW, type YrsResidentFontRegistration as aX, type YrsResidentWorkerSnapshot as aY, type YrsResidentWorkerSyncOptions as aZ, type YrsResolveReceipt as a_, type RawAnchorRange as aa, type ResidentCaretPaintStyle as ab, type ResidentEngineOffscreenPage as ac, type ResidentEngineWorkerApplyResult as ad, ResidentEngineWorkerClient as ae, type ResidentEngineWorkerFrame as af, type ResidentEngineWorkerOpened as ag, type ResidentProposalReply as ah, ResidentWorkerFailureError as ai, ResidentWorkerOutOfMemoryError as aj, type YrsAuthor as ak, type YrsCellBorder as al, type YrsCellBorders as am, type YrsCellLoc as an, type YrsChangeTarget as ao, type YrsCommentInfo as ap, type YrsCommentReceipt as aq, type YrsContentControlValue as ar, type YrsDocxHost as as, type YrsEngineApplyProfile as at, type YrsHyperlinkAttrs as au, type YrsImageGeometry as av, type YrsInlineFormatDelta as aw, type YrsInputParagraphSeed as ax, type YrsInputParagraphSpan as ay, type YrsInputPositionMap as az, type CollaborationTransport as b, type YrsRevisionReceipt as b0, type YrsRunMark as b1, type YrsSelectionContext as b2, type YrsSelectionText as b3, type YrsSplitReceipt as b4, type YrsStickyPosition as b5, type YrsStoryRange as b6, type YrsStorySeed as b7, type YrsStorySegmentSource as b8, type YrsTableLoc as b9, preloadDocxEngine as bA, preloadResidentEngineWorker as bB, prepareDocxBytes as bC, preparedDocxDigest as bD, projectYrsDisplayPosition as bE, proposalRevisionPreview as bF, proposalSetIdentity as bG, residentCaretDeviceRect as bH, residentCaretSnapshotForFrame as bI, resolveAnchorTarget as bJ, resolveMirroredNavigationTarget as bK, resolveNavigationTarget as bL, retainPreloadedResidentEngineWorker as bM, sameYrsSelection as bN, saveYrsDocx as bO, sessionSourcePackage as bP, takePreloadedResidentEngineWorker as bQ, textRangeToRaw as bR, writeSessionSave as bS, yrsLocToDisplayPosition as bT, yrsLocToProjectedDisplayPosition as bU, yrsToDocument as bV, type YrsTableRange as ba, type YrsTableReceipt as bb, type YrsTargetEditResult as bc, type YrsTextColor as bd, type YrsTextMatch as be, type YrsTextSearchOptions as bf, type YrsTriState as bg, type YrsUndoCaptureMode as bh, type YrsWatermark as bi, type YrsWorkerDocumentMirror as bj, anchorFailure as bk, canUseResidentEngineWorker as bl, captureSessionSave as bm, compareYrsLocs as bn, computeProposalGeometryMirror as bo, createYrsInputPositionMap as bp, createYrsLocProjectionFromOutline as bq, createYrsPositionProjection as br, createYrsSession as bs, decodeDocxHostJson as bt, displayPositionToYrsLoc as bu, documentToYrs as bv, editorSaveKeys as bw, hiddenRanges as bx, isBodyStory as by, ownProjectedParagraphs as bz, type CollaborationProviderOptions as c, type CollaborationStatus as d, type CollaborationPeer as e, type CollaborationCursor as f, type CollaborationPeerListener as g, type CollaborationStatusListener as h, type CollaborationErrorListener as i, type YrsSelection as j, type CollaborationAwarenessState as k, CollaborationError as l, type CollaborationErrorCode as m, type CollaborationPresence as n, type CollaborationResolvedUser as o, type CollaborationStatusChange as p, type CollaborationTextInsertion as q, type CollaborationTransportEvent as r, type CollaborationUpdateOrigin as s, type CollaborationUser as t, type YrsLoc as u, type YrsStorySegment as v, type YrsRevisionInfo as w, type AnchorReader as x, type AnchorResolutionFailure as y, type CreateYrsSessionOptions as z };
|