@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 +0,0 @@
|
|
|
1
|
-
import'./chunk-LT2GCWZ3.mjs';export{h as decodeTiffImage,b as parseDocxS9Wire,c as parseRelationshipsXmlWire,a as preloadParseWasm,d as serializeDocxS10Wire,e as serializeDocxS11Wire,f as serializeDocxS12Wire,g as writeDocxS13Wire}from'./chunk-GKWXOZZH.mjs';import'./chunk-HGKSOBXK.mjs';import'./chunk-TTRUPDAB.mjs';
|
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
import { L as Layout } from './types-Cz7S77Ut.mjs';
|
|
2
|
-
import { MeasuredBlock } from './layout/pagination/index.mjs';
|
|
3
|
-
import { D as DisplayList, R as RetainedFrame } from './frameDelta-CLeO7K5z.mjs';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* JS seam to the Rust display-list builder.
|
|
7
|
-
*
|
|
8
|
-
* Marshals the `{ measured, options, layout }` envelope across the wasm
|
|
9
|
-
* boundary and hands back a DisplayList. Every paint and geometry decision
|
|
10
|
-
* happens in Rust; this module is serialization glue and nothing else, so a
|
|
11
|
-
* failure here is terminal — the types below carry no second engine to fall
|
|
12
|
-
* back to, only a typed {@link RustDisplayListSourceError} naming the stage
|
|
13
|
-
* that failed.
|
|
14
|
-
*
|
|
15
|
-
* Two transports exist. {@link buildRustDisplayList} sends the whole envelope
|
|
16
|
-
* and parses a DisplayList back. {@link buildRustDisplayFrame} prefers an
|
|
17
|
-
* engine that already retains pagination: it sends only the display-level
|
|
18
|
-
* extras and receives a binary FrameDelta, which is applied to the previous
|
|
19
|
-
* frame so unchanged pages keep object identity — the invariant the query
|
|
20
|
-
* facade's page-delta adoption depends on. An engine without
|
|
21
|
-
* `buildDisplayListFrame` takes the full-JSON path instead.
|
|
22
|
-
*
|
|
23
|
-
* The wasm module is loaded lazily on first build, so the inlined binary costs
|
|
24
|
-
* nothing until a display list is actually requested.
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* One header/footer part in the `headersFooters` envelope field: the measured
|
|
29
|
-
* blocks of the header/footer document identified by `rId`, plus the band
|
|
30
|
-
* metrics the caller already computed. The builder passes the metrics through
|
|
31
|
-
* verbatim and re-derives none of them.
|
|
32
|
-
*/
|
|
33
|
-
interface DisplayListHfVariant {
|
|
34
|
-
rId: string;
|
|
35
|
-
kind: 'header' | 'footer';
|
|
36
|
-
type: 'default' | 'first' | 'even';
|
|
37
|
-
/** `toMeasuredBlocks(content.blocks, content.measures)` — same schema as body `measured` */
|
|
38
|
-
measured: MeasuredBlock[];
|
|
39
|
-
/** HeaderFooterContent.height (in-flow stack incl. floating blocks) */
|
|
40
|
-
height: number;
|
|
41
|
-
/** HeaderFooterContent.flowHeight (in-flow band height; fallback: height) */
|
|
42
|
-
flowHeight?: number;
|
|
43
|
-
visualTop?: number;
|
|
44
|
-
visualBottom?: number;
|
|
45
|
-
/**
|
|
46
|
-
* Per-page resolved widths of PAGE/NUMPAGES field runs in this HF part, so a
|
|
47
|
-
* centered/right-aligned line carrying such a field re-centers per page. The
|
|
48
|
-
* line width is measured ONCE at the field's fallback text ("1"), so without
|
|
49
|
-
* this the builder holds the same centered position on every page even though
|
|
50
|
-
* "Page 2 of 3"/"Page 10 of 12" have different widths. Omitted ⇒ the fields
|
|
51
|
-
* ride the char-distributed fallback width on every page.
|
|
52
|
-
*/
|
|
53
|
-
fieldWidths?: DisplayListFieldWidths[];
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Per-page widths of one PAGE/NUMPAGES field run in an HF part. `pmStart` is the
|
|
57
|
-
* field run's position in the header/footer document, and is the key the Rust
|
|
58
|
-
* builder matches on. `fallbackWidth` is the width the measure baked into `line.width`
|
|
59
|
-
* (the field's fallback text); `perPage[i]` is the width of the field's resolved
|
|
60
|
-
* text on layout page index `i` (PAGE → that page's number, NUMPAGES → total).
|
|
61
|
-
*/
|
|
62
|
-
interface DisplayListFieldWidths {
|
|
63
|
-
pmStart: number;
|
|
64
|
-
fallbackWidth: number;
|
|
65
|
-
perPage: number[];
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Optional header/footer payload of the builder envelope. Absent ⇒ the Rust
|
|
69
|
-
* output is byte-identical to the body-only build. Flags come off the section
|
|
70
|
-
* properties / settings the DOM painter uses; distances are the same px the
|
|
71
|
-
* painter resolves (`headerDistance ?? page.margins.header ?? 48`).
|
|
72
|
-
*/
|
|
73
|
-
interface DisplayListHeadersFooters {
|
|
74
|
-
titlePg?: boolean;
|
|
75
|
-
evenAndOddHeaders?: boolean;
|
|
76
|
-
headerDistance?: number;
|
|
77
|
-
footerDistance?: number;
|
|
78
|
-
/** Page-level Word watermark, painted behind body/header/footer content. */
|
|
79
|
-
watermark?: DisplayListWatermark;
|
|
80
|
-
variants: DisplayListHfVariant[];
|
|
81
|
-
/** Stable section identity. Undefined ⇒ the envelope covers the whole document. */
|
|
82
|
-
sectionId?: string;
|
|
83
|
-
/** Zero-based section index. */
|
|
84
|
-
sectionIndex?: number;
|
|
85
|
-
}
|
|
86
|
-
type DisplayListWatermark = DisplayListTextWatermark | DisplayListPictureWatermark;
|
|
87
|
-
interface DisplayListTextWatermark {
|
|
88
|
-
kind: 'text';
|
|
89
|
-
text: string;
|
|
90
|
-
font: string;
|
|
91
|
-
color: string;
|
|
92
|
-
semitransparent: boolean;
|
|
93
|
-
layout: 'diagonal' | 'horizontal';
|
|
94
|
-
fontSize?: number;
|
|
95
|
-
/** Undefined defaults to true for watermarks. */
|
|
96
|
-
decorative?: boolean;
|
|
97
|
-
}
|
|
98
|
-
interface DisplayListPictureWatermark {
|
|
99
|
-
kind: 'picture';
|
|
100
|
-
relId?: string;
|
|
101
|
-
dataUrl?: string;
|
|
102
|
-
scale: number;
|
|
103
|
-
washout: boolean;
|
|
104
|
-
widthEmu?: number;
|
|
105
|
-
heightEmu?: number;
|
|
106
|
-
/** Undefined defaults to true for watermarks. */
|
|
107
|
-
decorative?: boolean;
|
|
108
|
-
}
|
|
109
|
-
/** One measured note in a page/section note area. */
|
|
110
|
-
interface DisplayListNoteItem {
|
|
111
|
-
kind?: 'footnote' | 'endnote';
|
|
112
|
-
id?: number;
|
|
113
|
-
displayLabel?: string;
|
|
114
|
-
measured?: MeasuredBlock[];
|
|
115
|
-
height?: number;
|
|
116
|
-
anchorDocStart?: number;
|
|
117
|
-
anchorDocEnd?: number;
|
|
118
|
-
customMarkFollows?: boolean;
|
|
119
|
-
}
|
|
120
|
-
/** Typed non-fragmented note-region input for the Rust display builder. */
|
|
121
|
-
interface DisplayListNoteArea {
|
|
122
|
-
pageIndex?: number;
|
|
123
|
-
sectionId?: string;
|
|
124
|
-
kind?: 'footnote' | 'endnote';
|
|
125
|
-
placement?: 'pageBottom' | 'beneathText' | 'sectEnd' | 'docEnd';
|
|
126
|
-
y?: number;
|
|
127
|
-
height?: number;
|
|
128
|
-
columns?: number;
|
|
129
|
-
separator?: DisplayListNoteItem;
|
|
130
|
-
notes?: DisplayListNoteItem[];
|
|
131
|
-
}
|
|
132
|
-
/** Stable reviewer palette entry for comments/revisions. */
|
|
133
|
-
interface DisplayListCommentAuthor {
|
|
134
|
-
id?: string;
|
|
135
|
-
name?: string;
|
|
136
|
-
paletteIndex?: number;
|
|
137
|
-
color?: string;
|
|
138
|
-
}
|
|
139
|
-
/** One reply of a comment thread (a11y announcement input). */
|
|
140
|
-
interface DisplayListCommentReply {
|
|
141
|
-
id?: number;
|
|
142
|
-
authorId?: string;
|
|
143
|
-
authorName?: string;
|
|
144
|
-
date?: string;
|
|
145
|
-
/** Plain-text body (the builder caps it before it reaches primitives). */
|
|
146
|
-
text?: string;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Per-comment thread metadata keyed by comment id, joined by the builder onto
|
|
150
|
-
* every primitive carrying that id in `commentIds` so the a11y mirror can
|
|
151
|
-
* announce the complete thread (author name, date, body, replies). All string
|
|
152
|
-
* values are file-derived/attacker-controlled; consumers must only ever
|
|
153
|
-
* assign them via textContent/setAttribute.
|
|
154
|
-
*/
|
|
155
|
-
interface DisplayListCommentThread {
|
|
156
|
-
/** Comment id — matches the numeric ids in `resolvedCommentIds`/`commentIds`. */
|
|
157
|
-
id?: number;
|
|
158
|
-
authorId?: string;
|
|
159
|
-
authorName?: string;
|
|
160
|
-
date?: string;
|
|
161
|
-
/** Plain-text body (builder-capped before emission). */
|
|
162
|
-
text?: string;
|
|
163
|
-
/** Replies in thread order (builder-capped count and text). */
|
|
164
|
-
replies?: DisplayListCommentReply[];
|
|
165
|
-
}
|
|
166
|
-
/** The `{ measured, options, layout }` envelope the Rust builder consumes. */
|
|
167
|
-
interface DisplayListBuildInputs {
|
|
168
|
-
/** Serialization contract version. Undefined reads as version 0. */
|
|
169
|
-
contractVersion?: number;
|
|
170
|
-
measured: MeasuredBlock[];
|
|
171
|
-
options: unknown;
|
|
172
|
-
layout: Layout;
|
|
173
|
-
/** header/footer parts + section flags; omitted ⇒ body-only display list */
|
|
174
|
-
headersFooters?: DisplayListHeadersFooters;
|
|
175
|
-
/**
|
|
176
|
-
* Doc-wide font-id chains keyed `"<family lowercase>|<bold 0|1>|<italic 0|1>"`
|
|
177
|
-
* → measurement `FontStore` ids — the SAME map the measurement input carries.
|
|
178
|
-
* Present only under Rust measurement (the ids must belong to a populated
|
|
179
|
-
* store); its presence against that store is what gates GlyphRun emission.
|
|
180
|
-
* Omitted ⇒ every text run is emitted as a browser-measured
|
|
181
|
-
* `TextRunPrimitive` rather than a shaped `GlyphRun`.
|
|
182
|
-
*/
|
|
183
|
-
fontChains?: Record<string, number[]>;
|
|
184
|
-
/** Page/section note regions. Undefined = no note emission. */
|
|
185
|
-
noteAreas?: DisplayListNoteArea[];
|
|
186
|
-
/** Resolved comments suppressed from active tint. Undefined = none known. */
|
|
187
|
-
resolvedCommentIds?: number[];
|
|
188
|
-
/** Stable reviewer palette. Undefined ⇒ the builder's built-in colors. */
|
|
189
|
-
commentAuthors?: DisplayListCommentAuthor[];
|
|
190
|
-
/** Per-comment thread metadata for a11y announcements. Undefined = none. */
|
|
191
|
-
commentThreads?: DisplayListCommentThread[];
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Minimal build surface, injectable so tests can fake the wasm module. Only
|
|
195
|
-
* `buildDisplayListJson` is required; the optional members are what an engine
|
|
196
|
-
* that retains its own pagination and display state additionally offers.
|
|
197
|
-
*/
|
|
198
|
-
interface RustDisplayListEngine {
|
|
199
|
-
buildDisplayListJson(input: string): string;
|
|
200
|
-
/** Binary FrameDelta build; the stateless layout wasm does not offer it. */
|
|
201
|
-
buildDisplayListFrame?(input: string, expectedFrameEpoch: number): Uint8Array;
|
|
202
|
-
/** Applies one keystroke and returns its frame, without a layout round trip. */
|
|
203
|
-
applyInput?(text: string, expectedFrameEpoch: number): Uint8Array;
|
|
204
|
-
displayHitTestRegionsJson?(pageIndex: number, x: number, y: number): string;
|
|
205
|
-
displayVerticalMoveJson?(position: number, direction: 'up' | 'down', goalX: number): string;
|
|
206
|
-
displayRangeRectsJson?(from: number, to: number): string;
|
|
207
|
-
displayRangeRectsRegionJson?(region: string, partId: string, from: number, to: number): string;
|
|
208
|
-
/** The bytes and media type of the part a `media:{n}` image source names. */
|
|
209
|
-
mediaSource?(token: string): {
|
|
210
|
-
bytes: Uint8Array;
|
|
211
|
-
mimeType: string;
|
|
212
|
-
} | null;
|
|
213
|
-
/** Changes whenever the package `mediaSource` reads changes. */
|
|
214
|
-
mediaScope?(): number;
|
|
215
|
-
}
|
|
216
|
-
type RustDisplayListSourceErrorStage = 'load' | 'build' | 'parse' | 'decode' | 'apply';
|
|
217
|
-
interface RustDisplayFrameResult {
|
|
218
|
-
displayList: DisplayList;
|
|
219
|
-
/**
|
|
220
|
-
* The retained frame to pass as `previous` on the next build. Null when the
|
|
221
|
-
* engine answered over full JSON, which retains nothing.
|
|
222
|
-
*/
|
|
223
|
-
frame: RetainedFrame | null;
|
|
224
|
-
transport: 'frame-delta-v1' | 'json';
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Typed terminal error from the mandatory Rust display-list source. Hosts may
|
|
228
|
-
* surface this through their editor error boundary; it is never permission to
|
|
229
|
-
* silently substitute painter geometry.
|
|
230
|
-
*/
|
|
231
|
-
declare class RustDisplayListSourceError extends Error {
|
|
232
|
-
readonly stage: RustDisplayListSourceErrorStage;
|
|
233
|
-
constructor(stage: RustDisplayListSourceErrorStage, cause: unknown);
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Query surface over an already-built display list, injectable so tests can
|
|
237
|
-
* fake the wasm module.
|
|
238
|
-
*
|
|
239
|
-
* The required `*Json` members take the display-list JSON as an argument and
|
|
240
|
-
* the Rust side re-parses it per query, so callers should cache the string.
|
|
241
|
-
* The OPTIONAL session-handle members parse the list once (`openDisplayList` →
|
|
242
|
-
* a handle) and answer many queries by handle with no re-serialization,
|
|
243
|
-
* reusing the same hit and range logic so results are byte-identical. They are
|
|
244
|
-
* optional because the embedded wasm may not carry them; `hasDisplayListSession`
|
|
245
|
-
* and `hasRangeRectsRegion` report what is present, and
|
|
246
|
-
* `createDisplayListQueries` falls back to the `*Json` path when it is not.
|
|
247
|
-
*/
|
|
248
|
-
interface RustDisplayListQueryEngine {
|
|
249
|
-
/**
|
|
250
|
-
* region-aware hit test → `{"region","rId"?,"noteId"?,"pos","target"}` or
|
|
251
|
-
* `"null"` JSON
|
|
252
|
-
*/
|
|
253
|
-
hitTestRegionsJson(displayList: string, pageIndex: number, x: number, y: number): string;
|
|
254
|
-
/** closest caret position on the adjacent visual line */
|
|
255
|
-
verticalMoveJson?(displayList: string, position: number, direction: 'up' | 'down', goalX: number): string;
|
|
256
|
-
/** body document range → JSON array of `{pageIndex,x,y,width,height}` rects */
|
|
257
|
-
rangeRectsJson(displayList: string, from: number, to: number): string;
|
|
258
|
-
/**
|
|
259
|
-
* Region-aware document range → JSON array of rects. `region` is a
|
|
260
|
-
* `DisplayListHitRegion` discriminant; `partId` names the instance — a
|
|
261
|
-
* header/footer part (empty for body, or to match any band of the kind) or a
|
|
262
|
-
* note id. Optional — the facade returns `[]` when it is absent.
|
|
263
|
-
*/
|
|
264
|
-
rangeRectsRegionJson?(displayList: string, region: string, partId: string, from: number, to: number): string;
|
|
265
|
-
/** true when the embedded wasm carries the region-aware range-rect exports */
|
|
266
|
-
hasRangeRectsRegion?(): boolean;
|
|
267
|
-
/** true when the embedded wasm carries the session-handle exports below */
|
|
268
|
-
hasDisplayListSession?(): boolean;
|
|
269
|
-
/** parse a display list once, return a handle for the by-handle queries */
|
|
270
|
-
openDisplayList?(displayList: string): number;
|
|
271
|
-
/** free a handle's parsed display list */
|
|
272
|
-
closeDisplayList?(handle: number): void;
|
|
273
|
-
/** patch a stored display list's changed pages in place (see layout wasm) */
|
|
274
|
-
updateDisplayList?(handle: number, update: string): void;
|
|
275
|
-
/** true when the embedded wasm carries the page-delta update export */
|
|
276
|
-
hasDisplayListUpdate?(): boolean;
|
|
277
|
-
/** region-aware hit test against a stored display list (by handle) */
|
|
278
|
-
hitTestRegionsByHandle?(handle: number, pageIndex: number, x: number, y: number): string;
|
|
279
|
-
/** adjacent visual-line move against a stored display list */
|
|
280
|
-
verticalMoveByHandle?(handle: number, position: number, direction: 'up' | 'down', goalX: number): string;
|
|
281
|
-
/** body document range against a stored display list (by handle) */
|
|
282
|
-
rangeRectsByHandle?(handle: number, from: number, to: number): string;
|
|
283
|
-
/** region-aware document range against a stored display list (by handle) */
|
|
284
|
-
rangeRectsRegionByHandle?(handle: number, region: string, partId: string, from: number, to: number): string;
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* Lazily load the wasm query surface (hit-test + range-rects). Shares the
|
|
288
|
-
* module promise with `buildRustDisplayList`, so on the canvas-renderer path
|
|
289
|
-
* the engine is already resolved by the time the first display list lands.
|
|
290
|
-
*/
|
|
291
|
-
declare function loadRustDisplayListQueryEngine(): Promise<RustDisplayListQueryEngine>;
|
|
292
|
-
/** Display-only fields sent to an engine that already retains pagination. */
|
|
293
|
-
declare function encodeDisplayListFrameExtras(inputs: DisplayListBuildInputs): string;
|
|
294
|
-
/**
|
|
295
|
-
* Build a DisplayList for a computed layout through the Rust engine. Throws
|
|
296
|
-
* {@link RustDisplayListSourceError} tagged with the failing stage — `load`,
|
|
297
|
-
* `build` or `parse` — when the wasm module cannot be loaded, the builder
|
|
298
|
-
* rejects the input, or its output does not parse.
|
|
299
|
-
*/
|
|
300
|
-
declare function buildRustDisplayList(inputs: DisplayListBuildInputs, engine?: RustDisplayListEngine): Promise<DisplayList>;
|
|
301
|
-
/**
|
|
302
|
-
* Build one display frame. An engine that retains pagination returns a binary
|
|
303
|
-
* FrameDelta, decoded and applied on top of `previous` so unchanged pages keep
|
|
304
|
-
* object identity; `previous` also supplies the frame epoch the engine checks
|
|
305
|
-
* before sending a delta rather than a full frame, unless `expectedFrameEpoch`
|
|
306
|
-
* overrides it (the engine numbers its frame after that epoch). An engine without
|
|
307
|
-
* `buildDisplayListFrame` takes the full-JSON path, and its result carries
|
|
308
|
-
* `frame: null` and `transport: 'json'`.
|
|
309
|
-
*
|
|
310
|
-
* Throws {@link RustDisplayListSourceError} tagged with the failing stage:
|
|
311
|
-
* `load`, `build`, `decode` or `apply`.
|
|
312
|
-
*/
|
|
313
|
-
declare function buildRustDisplayFrame(inputs: DisplayListBuildInputs, engine?: RustDisplayListEngine, previous?: RetainedFrame | null, expectedFrameEpoch?: number): Promise<RustDisplayFrameResult>;
|
|
314
|
-
|
|
315
|
-
export { type DisplayListHeadersFooters as D, type RustDisplayListQueryEngine as R, type DisplayListBuildInputs as a, type DisplayListHfVariant as b, type DisplayListPictureWatermark as c, type DisplayListTextWatermark as d, type DisplayListWatermark as e, type RustDisplayFrameResult as f, type RustDisplayListEngine as g, RustDisplayListSourceError as h, type RustDisplayListSourceErrorStage as i, buildRustDisplayFrame as j, buildRustDisplayList as k, encodeDisplayListFrameExtras as l, loadRustDisplayListQueryEngine as m };
|
package/dist/wasm-JPDPN2B2.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{p as buildDisplayListJson,t as clearMeasureFonts,g as closeDisplayList,d as hasDisplayListSession,i as hasDisplayListUpdate,e as hasRangeRectsRegion,j as hitTestRegionsByHandle,b as hitTestRegionsJson,q as layoutDocumentJson,u as measureParagraphJson,f as openDisplayList,v as outlineGlyphJson,a as preloadLayoutWasm,m as rangeRectsByHandle,c as rangeRectsJson,o as rangeRectsRegionByHandle,n as rangeRectsRegionJson,r as registerMeasureFont,s as registerSubstituteMeasureFont,h as updateDisplayList,l as verticalMoveByHandle,k as verticalMoveJson}from'./chunk-3RPZ44TT.mjs';import'./chunk-HGKSOBXK.mjs';import'./chunk-TTRUPDAB.mjs';
|
package/dist/wasm-QI7MWC5D.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import'./chunk-HPZFJGGM.mjs';export{a as preloadOpcWasm,c as rezipContainer,b as unzipContainer}from'./chunk-AXFMDV66.mjs';import'./chunk-HGKSOBXK.mjs';import'./chunk-TTRUPDAB.mjs';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {d,v,c as c$1,x as x$1,j as j$1,i,b as b$3,k as k$2,l as l$1,o as o$1,e as e$1}from'../chunk-5Z22FORG.mjs';import'../chunk-EUUIJVM6.mjs';import {c,a,d as d$1,e}from'../chunk-SHVHVJUB.mjs';import {k as k$1,D,a as a$1,h,l,j as j$2,x as x$2,u}from'../chunk-FK7X7557.mjs';import {b as b$1}from'../chunk-LIOWZSE7.mjs';import {b as b$2}from'../chunk-HGKSOBXK.mjs';import'../chunk-TTRUPDAB.mjs';async function he(e$1,i=Pn()){await a(),d$1(e$1);let n=e(i);n.set_local_lowering(true);let r=new Set,a$1=false,d=false,p=false,c=new Map,f=new Map,m=new Map,l=t=>{let s=c.get(t),u=JSON.parse(n.stories_changed_since(s?.revision??Number.MAX_SAFE_INTEGER));return !s||u.stories.includes(t)?(s={revision:u.revision,segments:JSON.parse(n.story_segments(t))},c.set(t,s)):s.revision=u.revision,s},g=()=>{p||(n.track_undo(),p=true);},h=()=>{a$1||(n.set_update_observer((t,s)=>{if(!(s!==0&&s!==1))for(let u of [...r])u(t,s===0?"local":"remote");}),a$1=true);},S={version:()=>n.version(),resolveParagraphAnchor:t=>JSON.parse(n.resolve_paragraph_anchor(JSON.stringify(t))),findText:t=>JSON.parse(n.find_text_json(JSON.stringify(t))),readParagraphs:t=>JSON.parse(n.read_paragraphs_json(JSON.stringify(t))),applyEdits:t=>JSON.parse(n.apply_edits_json(JSON.stringify(t))),listRevisions:()=>JSON.parse(n.list_revisions()),revisionStamps:t=>JSON.parse(n.revision_stamps_json(JSON.stringify(t))),settleRevisions:(t,s)=>{n.settle_revisions_json(JSON.stringify({accept:t,reject:s}));},...typeof n.begin_shared_reads=="function"&&typeof n.end_shared_reads=="function"?{sharedReads:t=>{n.begin_shared_reads();try{return t()}finally{n.end_shared_reads();}}}:{}},v={version:()=>n.version(),hasStory:t=>!tn.test(t)&&n.has_story(t),storyIds:()=>n.story_ids(),paragraphs:t=>JSON.parse(n.paragraphs(t)),paragraphIdCount:(t,s)=>n.paragraph_id_count(t,s),paragraphSpans:t=>{let s=f.get(t),u=JSON.parse(n.stories_changed_since(s?.revision??Number.MAX_SAFE_INTEGER));if(s&&!u.stories.includes(t))return s.revision=u.revision,s.spans;let y=JSON.parse(n.paragraph_spans(t));return f.set(t,{revision:u.revision,spans:y}),y},storySegments:t=>l(t).segments,positionOutline:t=>{if(tn.test(t))return null;let s=n.version(),u=m.get(t);if(u?.version===s)return u.outline;let y=JSON.parse(n.geometry_position_outline_json(t)),D=y==="legacy"?null:y;return m.set(t,{version:s,outline:D}),D},locateParagraph:(t,s)=>JSON.parse(n.locate_paragraph(t,s)),listRevisions:()=>JSON.parse(n.list_revisions()),resolveParagraphAnchor:S.resolveParagraphAnchor,findText:S.findText,proposalRevisions:t=>{let s=JSON.parse(n.proposal_revision_ranges_json(JSON.stringify(t)));if(Array.isArray(s))return s;if(s==="fallback"){let u=new Set(t);return v.listRevisions().filter(({revisionId:y})=>u.has(y))}return Rn(v,t)}};return {proposalEngine:S,geometryReader:v,paragraphSegments:(t,s)=>JSON.parse(n.story_segment_units(t,Uint32Array.from(s))),searchText:(t,s={})=>{if(!t)return [];let u=s.limit??Number.POSITIVE_INFINITY;if(!Number.isSafeInteger(u)&&u!==Number.POSITIVE_INFINITY||u<0)throw new RangeError("search limit must be a non-negative safe integer");return JSON.parse(n.search_text(t,s.caseSensitive??false,Number.isFinite(u)?Math.min(u,4294967295):void 0))},encodeStickyPosition:t=>({story:t.story,encoded:n.encode_sticky_position(t.story,t.paraId,t.offset)}),resolveStickyPosition:t=>{try{return JSON.parse(n.resolve_sticky_position(t.story,t.encoded))}catch{return null}},paragraphIdentities:()=>JSON.parse(n.paragraph_identities()),storiesChangedSince:t=>JSON.parse(n.stories_changed_since(t)),openDocx:(t,s,u)=>(c.clear(),b$3(n.open_docx(t,true,u,s),y=>y.startsWith("media:")?n.media_data_url(y)??null:null)),openDocxPreview:(t,s)=>{c.clear();let u=n.open_docx_preview(t,s);return u===void 0?null:b$3(u,y=>y.startsWith("media:")?n.media_data_url(y)??null:null)},encodeState:()=>n.encode_state(),revisionCount:t=>JSON.parse(n.list_revisions()).filter(s=>!t?.has(s.revisionId)).length,registerFont:t=>n.register_measure_font(t),registerSubstituteFont:(t,s)=>n.register_substitute_measure_font(t,s),clearFonts:()=>n.clear_measure_fonts(),encodeStateVector:()=>n.encode_state_vector(),measureParagraphJson:t=>n.measure_paragraph_json(t),layoutDocumentJson:t=>n.layout_document_json(t),layoutFontRequirementsJson:t=>n.layout_font_requirements_json(t),layoutDocumentWithRegionsRetainedJson:t=>n.layout_document_with_regions_retained_json(t),beginRegionLayout:t=>JSON.parse(n.begin_region_layout(t)),resumeRegionLayout:t=>JSON.parse(n.resume_region_layout(t)),setPartialDocument:t=>n.set_partial_document(t),layoutDocumentWithRegionsPrefixRetainedJson:(t,s)=>n.layout_document_with_regions_prefix_retained_json(t,s),layoutDocumentWithRegionsRetained:t=>n.layout_document_with_regions_retained(t),retainedHeadersFootersJson:()=>n.retained_headers_footers_json(),buildDisplayListFrame:(t,s)=>n.build_display_list_frame(t,s),setDisplayWindow:(t,s)=>n.set_display_window(t,s),setDisplayRetainBuiltPages:t=>n.set_display_retain_built_pages(t),setWindowedIncrementalBuilds:t=>n.set_windowed_incremental_builds(t),setDirectBatches:t=>n.set_direct_batches(t),directBatchesApplied:()=>n.direct_batches_applied(),buildDisplayPagesFrame:(t,s)=>n.build_display_pages_frame(Uint32Array.from(t),s),releaseDisplayPagesFrame:(t,s)=>{let u=n.release_display_pages_frame(Uint32Array.from(t),s);return u.length===0?null:u},residentCaretSnapshot:()=>JSON.parse(n.resident_caret_snapshot_json()),selection:()=>JSON.parse(n.selection()),applyInput:(t,s)=>(g(),n.apply_input(t,s)),applyDelete:(t,s,u=1)=>(g(),n.apply_delete(t,s,u)),residentDeletedUnits:()=>n.resident_deleted_units(),applyInputProfiled:(t,s)=>{g();let u=n.apply_input_profiled(t,s),y=JSON.parse(n.apply_input_profile_json());return {frame:u,profile:y}},applyDeleteProfiled:(t,s,u=1)=>{g();let y=n.apply_delete_profiled(t,s,u),D=JSON.parse(n.apply_input_profile_json());return {frame:y,profile:D}},outlineGlyphJson:(t,s)=>n.outline_glyph_json(t,s),loadMediaSources:t=>n.load_media_sources(t),loadState:t=>{c.clear(),n.load(t);},applyUpdate:t=>JSON.parse(n.apply_update_with_inference(t)),onUpdate:t=>(r.add(t),h(),()=>r.delete(t)),setSelection:(t,s=t)=>{if(t.story!==s.story)throw new Error("yrs selection must stay inside one story");n.set_selection(t.story,t.paraId,t.offset,s.paraId,s.offset);},yrsBlocksForStory:(t,s={})=>JSON.parse(n.yrs_blocks_for_story(t,JSON.stringify(s))),destroy:()=>{d||(d=true,r.clear(),c.clear(),a$1&&n.clear_update_observer(),n.free());}}}function Rn(e,i){let n=new Set(i),r=[],a=()=>e.listRevisions().filter(({revisionId:d})=>n.has(d));for(let d of e.storyIds().sort()){let p=0,c=new Set,f=[],m=new Map;for(let l of e.storySegments(d)){if(l.kind==="pilcrow"){if(ge(l.properties)||c.has(l.paraId))return a();c.add(l.paraId);for(let h of f.sort((S,v)=>S.start-v.start))r.push({revisionId:h.revisionId,kind:h.kind,story:d,range:{story:d,start:{paraId:l.paraId,offset:h.start},end:{paraId:l.paraId,offset:h.end}}});p=0,f=[],m.clear();continue}if(l.kind==="embed"&&ge(l.payload))return a();let g=l.kind==="text"?l.text.length:1;for(let[h,S]of [["ins","insertion"],["del","deletion"]]){let v=l.attributes[h];if(!v||typeof v!="object"||Array.isArray(v))continue;let t=v,s=t.info,u=s&&typeof s=="object"&&!Array.isArray(s)?s:t,y="id"in u?u.id:u.revisionId;if(typeof y!="string"&&!(typeof y=="number"&&Number.isFinite(y)))continue;let D=String(y);if(!n.has(D)){m.delete(S);continue}let U=m.get(S);if(U?.revisionId===D&&U.end===p)U.end+=g;else {let V={revisionId:D,kind:S,start:p,end:p+g};f.push(V),m.set(S,V);}}p+=g;}if(f.length>0)return a()}return r}var tn=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;function ge(e){return !e||typeof e!="object"?false:Object.entries(e).some(([i,n])=>i==="id"||i==="revisionId"||i==="pPrIns"||i==="pPrDel"||i==="pPrChange"||i==="trIns"||i==="trDel"||i==="tableIns"||i==="tableDel"||ge(n))}function Pn(){if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function"){let e=new Uint32Array(1);return crypto.getRandomValues(e),e[0]}return Math.floor(Math.random()*4294967295)}function rn(e,i,n,r){return e!==true?null:i?n??0:r===null?0:Math.max(0,r-2)}function ve(e,i){let[n,r]=e??[0,i];return [n,Math.min(r,Math.max(n,i))]}function on(e,i,n,r){if(!i)return {matches:[],carried:-1};let a=e.searchText(i,{caseSensitive:n}).filter(t=>t.story==="body"||t.story.startsWith("body:"));if(a.length===0)return {matches:[],carried:-1};let d=e.hasStory("body")?e.positionOutline?.("body"):null,p=d?k$2(d):l$1(e,"body"),c=new Map,f=t=>(c.has(t)||c.set(t,e.hasStory(t)?e$1(t,e.paragraphSpans(t)):null),c.get(t)),m=t=>t.story==="body"||t.story.startsWith("body:")?o$1(e,()=>p,t,"body",f):null,l=[];for(let t of a){let s={story:t.story,paraId:t.paraId,offset:t.start},u=m(s),y=m({...s,offset:t.end});u==null||y==null||u>=y||l.push({story:t.story,paraId:t.paraId,start:t.start,displayFrom:u,displayTo:y});}if(l.sort((t,s)=>t.displayFrom-s.displayFrom),l.length===0)return {matches:l,carried:-1};let g=null;try{g=r?e.resolveStickyPosition(r):null;}catch{}if(!g)return {matches:l,carried:0};let h=l.findIndex(t=>t.story===g.story&&t.paraId===g.paraId&&t.start===g.offset);if(h>=0)return {matches:l,carried:h};let S=m(g),v=S==null?-1:l.findIndex(t=>t.displayFrom>=S);return {matches:l,carried:v>=0?v:l.length-1}}var ke=self,de,sn=fn(),o=null,N=null,we=null,P=null,J=null,ee=null,_n=8,ne=null,be=false,E=null,A=null,X=null,W=null,b=[],De=0,Re=-1,an=Promise.resolve(),R=null,te=null,B=new Map,$=new Map,j=new Set,G=new Set,se=1,ae=1,re={color:"#000",width:2},H=null,C=null,z=null,oe=null,Q=new Set,x=null,_=null,T=null,k=null,In=24,En=3,xn=2**32-1,L=null,un=4,cn=0,ln=new Set;ke.onmessage=e=>{let i=e.data;if(i.type==="editModule"){de(i.module instanceof WebAssembly.Module?i.module:null);return}Fe(()=>kn(i),i.id);};ke.onmessageerror=()=>de(null);function fn(){return new Promise(e=>{de=e;})}function Fe(e,i,n=()=>true){an=an.then(()=>{if(n()){if(x)throw x;return cn=i,e()}}).catch(r=>gn(i,r));}function gn(e,i){let n=x??i;if(n instanceof WebAssembly.RuntimeError){yn(e,n);return}w({id:e,ok:false,error:i instanceof Error?i.message:String(i)});}function yn(e,i){if(ln.has(e))return;ln.add(e),x=i;let n=bn();w({id:e,ok:false,error:n>0?`Resident engine worker ran out of memory allocating ${n} bytes: ${i.message}`:`Resident engine worker trapped: ${i.message}`,terminal:true,...n>0?{outOfMemory:true}:{}});}async function kn(e){if(Oe(),e.type==="warm"){try{if(e.hostModule){let n=setTimeout(()=>de(null),1e4);await c(sn.then(r=>(clearTimeout(n),r)));}else await a();w({id:e.id,ok:!0});}catch(n){e.hostModule&&(sn=fn()),w({id:e.id,ok:false,error:n instanceof Error?n.message:String(n)});}return}if(e.type==="destroy"){Se();return}if(e.type==="open"){if(o&&(!be||e.previewBlocks!==void 0))throw new Error("Resident engine worker already holds a document");o&&Se(true);let n=await he(e.heapLimitBytes),r;try{e.previewBlocks===void 0&&n.setDirectBatches(!0),r=e.previewBlocks===void 0?n.openDocx(new Uint8Array(e.bytes),e.digest,e.generation):n.openDocxPreview(new Uint8Array(e.bytes),e.previewBlocks);}catch(d){throw d instanceof WebAssembly.RuntimeError||n.destroy(),d}if(r===null){n.destroy(),w({id:e.id,ok:true,previewRefused:true});return}N?.destroy(),N=null,o=n,ne={heapLimitBytes:e.heapLimitBytes},be=e.previewBlocks!==void 0;let a=Y(o.encodeStateVector());w({id:e.id,ok:true,hostJson:r,stateVector:a},[a]);return}if(e.type==="bootstrap"){if(!e.opened)Se(e.keepSurfaces===true),o=await he(e.heapLimitBytes);else {if(!o||!ne)throw new Error("Resident engine worker has no opened document");if(e.heapLimitBytes!==void 0&&e.heapLimitBytes!==ne.heapLimitBytes)throw new Error("Resident engine worker opened its document under another heap limit")}W?.(),W=null,E=null,K(),O(o,e.displayWindow,e.retainBuiltPages);let{layoutJson:n,provisional:r}=dn(e.snapshot,e.provisionalPages,e.layoutExtras!==void 0,e.opened!==true);(E!==null||A!==null)&&O(o,e.displayWindow,e.retainBuiltPages),r&&(_={layoutInput:e.snapshot.layoutInput,workerAuthoritative:e.snapshot.workerAuthoritative,extras:e.extras,layoutExtras:e.layoutExtras}),pn();let a=performance.now(),d=o.buildDisplayListFrame(Ie(e.extras,e.layoutExtras,n),e.expectedFrameEpoch);await M(e.id,d,performance.now()-a,b,void 0,a,false,false,e.layoutExtras===void 0?void 0:n??void 0,r);return}if(e.type==="fontRequirements"){if(!o)throw new Error("Resident engine worker is not initialized");let n=mn(o,e.layoutInput);ee={owner:o,layoutInput:e.layoutInput},P={version:o.proposalEngine.version(),layoutInput:e.layoutInput,requirementsJson:n},w({id:e.id,ok:true,requirementsJson:n});return}if(e.type==="encodeState"){if(!o)throw new Error("Resident engine worker is not initialized");let n=Y(o.encodeState());w({id:e.id,ok:true,state:n,version:o.proposalEngine.version(),proposals:N?.exportState()??{previewVersion:0,entries:[]}},[n]);return}if(e.type==="revisionCount"){if(!o)throw new Error("Resident engine worker is not initialized");let n=new Set(N?.snapshot().proposals.flatMap(r=>r.revisionIds));w({id:e.id,ok:true,revisionCount:o.revisionCount(n)});return}if(e.type==="eraseCaret"){H=null,C!==null&&await xe(false),w({id:e.id,ok:true});return}if(!o)throw new Error("Resident engine worker is not initialized");if(e.type==="proposal"){if(!W)throw new Error("Resident engine worker has not laid out its document");b=[];let n=false;try{let r=N??(N=d(o.proposalEngine)),a=o.proposalEngine.version(),d$1=o.storiesChangedSince(Number.MAX_SAFE_INTEGER).revision,p;switch(e.operation.kind){case "propose":p=r.propose(e.operation.request);break;case "setStates":p=r.setStates(e.operation.request);break;case "withdraw":p=r.withdraw(e.operation.request);break}n=e.operation.kind!=="snapshot";let c=o.storiesChangedSince(d$1).stories;c.length>0&&(T=null);let f=b.map(Y),m=Y(o.encodeStateVector()),l=r.snapshot(),g=l.version,h=v(o.geometryReader,l,g===a&&(g===we||b$1(o.geometryReader)));we=h.version;let S=P?.version===a&&e.operation.kind==="propose"&&p?.ok===!0&&c$1(l)===void 0&&On(o,e.operation.request,p);P=P&&(S||e.operation.kind==="snapshot"&&P.version===l.version)?{...P,version:l.version}:null;let v$1=c$1(l);e.operation.kind==="setStates"&&p?.ok===!0&&c.length===0&&ee?.owner===o&&(P=Dn(o,ee.layoutInput,v$1,l.version)),w({id:e.id,ok:!0,proposal:{...p===void 0?{}:{result:p},mirror:{version:g,proposals:r.exportState()},changedStories:c,updates:f,stateVector:m,geometry:h,...P?{fontRequirements:{layoutInput:P.layoutInput,requirementsJson:P.requirementsJson}}:{}}},[...f,m]);}catch(r){if(x)throw x;if(r instanceof WebAssembly.RuntimeError)throw r;w({id:e.id,ok:false,error:r instanceof Error?r.message:String(r),...n||b.length>0?{terminal:true}:{}});}finally{b=[];}return}if(e.type==="documentRead"){let n=o.proposalEngine,r;switch(e.read.kind){case "paragraphIdentities":r=o.paragraphIdentities();break;case "resolveParagraphAnchors":r={results:e.read.anchors.map(a=>n.resolveParagraphAnchor(a))};break;case "readParagraphs":r=n.readParagraphs(e.read.request);break;case "navigationTarget":r=x$1(o.geometryReader,e.read.story,e.read.paraId);break;case "searchText":r=on({...o.geometryReader,searchText:o.searchText,resolveStickyPosition:o.resolveStickyPosition},e.read.query,e.read.caseSensitive,e.read.carry);break;case "stickyAnchors":{let a=o;r=e.read.locs.map(d=>{try{return a.encodeStickyPosition(d)}catch{return null}});break}}w({id:e.id,ok:true,read:{version:n.version(),value:r}});return}if(e.type==="sync"){W?.(),W=null,E=null,K(),O(o,e.displayWindow,e.retainBuiltPages);let{layoutJson:n,provisional:r}=dn(e.snapshot,e.provisionalPages,e.layoutExtras!==void 0);(E!==null||A!==null)&&O(o,e.displayWindow,e.retainBuiltPages),r&&(_={layoutInput:e.snapshot.layoutInput,workerAuthoritative:e.snapshot.workerAuthoritative,extras:e.extras,layoutExtras:e.layoutExtras}),pn();let a=performance.now(),d=o.buildDisplayListFrame(Ie(e.extras,e.layoutExtras,n),e.expectedFrameEpoch);await M(e.id,d,performance.now()-a,b,void 0,a,false,e.paintCaret,e.layoutExtras===void 0?void 0:n??void 0,r);return}if(e.type==="buildPages"){let n=E===null?A:Math.min(E,A??E),r=n===null?e.pages:e.pages.filter(p=>p<n);if(e.background&&r.length>un){let p={request:r===e.pages?e:{...e,pages:r},owner:o,frameEpoch:e.expectedFrameEpoch,frames:[],offset:0,started:performance.now(),engineMs:0};L=p,Sn(p);return}O(o),b=[];let a=performance.now(),d=o.buildDisplayPagesFrame(r,e.expectedFrameEpoch);await M(e.id,d,performance.now()-a,b,void 0,a,false,e.paintCaret);return}if(e.type==="releasePages"){if(!R||R.frameEpoch!==e.expectedFrameEpoch||e.pages.some(({index:a,pageId:d})=>R.pages[a]?.pageId.toString()!==d)){w({id:e.id,ok:true,superseded:true});return}let n=performance.now(),r=o.releaseDisplayPagesFrame(e.pages.map(({index:a})=>a),e.expectedFrameEpoch);if(r===null){w({id:e.id,ok:true,superseded:true});return}await M(e.id,r,performance.now()-n,[],void 0,n,false,e.paintCaret);return}if(e.type==="completeLayout"){if(O(o),_&&e.sliceBlocks){Ce(),k={id:e.id,expectedFrameEpoch:e.expectedFrameEpoch,paintCaret:e.paintCaret,blocks:e.sliceBlocks,begun:false,restarts:0},_e(k);return}await ie(),await Je(e.id,e.expectedFrameEpoch,e.paintCaret);return}if(e.type==="buildFrame"){_?.workerAuthoritative||await ie(),O(o,e.displayWindow,e.retainBuiltPages),b=[];let n=performance.now(),r=o.buildDisplayListFrame(e.extras,e.expectedFrameEpoch);await M(e.id,r,performance.now()-n,b,void 0,n,false,e.paintCaret);return}if(e.type==="applyUpdate"){P=null,o.applyUpdate(e.update),e.selection&&o.setSelection(e.selection.anchor,e.selection.head);return}if(e.type==="attachCanvases"){let n=B.size>0&&(se!==e.devicePixelRatio||ae!==e.zoom),r=new Set(e.pages.map(a=>a.pageId));for(let a of e.activePageIds)G.has(a)||r.add(a);for(let{pageId:a,canvas:d}of e.pages)B.set(a,d);G=new Set(e.activePageIds),se=e.devicePixelRatio,ae=e.zoom,re=e.caretStyle;for(let[a,d]of B)G.has(a)||(k$1(d),$.delete(a),wn(a));await xe(n?true:r),w({id:e.id,ok:true});return}await ie(),P=null,T=null,O(o,e.displayWindow,e.retainBuiltPages),o.setSelection(e.selection.anchor,e.selection.head),b=[];let i=performance.now();try{let n=e.type==="applyDelete"?e.profile?o.applyDeleteProfiled(e.direction,e.expectedFrameEpoch,e.count):{frame:o.applyDelete(e.direction,e.expectedFrameEpoch,e.count),profile:void 0}:e.profile?o.applyInputProfiled(e.text,e.expectedFrameEpoch):{frame:o.applyInput(e.text,e.expectedFrameEpoch),profile:void 0};await M(e.id,n.frame,performance.now()-i,b,n.profile,i,e.selection.head.story==="body",e.paintCaret,void 0,!1,e.type==="applyDelete"?o.residentDeletedUnits():void 0);}catch(n){if(x)throw x;if(n instanceof WebAssembly.RuntimeError)throw n;let r=n instanceof Error?n.message:String(n);w({id:e.id,ok:false,error:r,residentUnavailable:r.includes("resident input state is not ready"),...b.length>0?{terminal:true}:{}});}finally{b=[];}}function dn(e,i,n=true,r=true){if(!o)throw new Error("Resident engine worker is not initialized");if(Ce(),_=null,K(),T=null,r&&!e.workerAuthoritative&&(P=null,o.loadState(e.state)),o.setPartialDocument(e.partialDocument===true),E=e.partialDocument===true?0:null,e.workerAuthoritative||o.loadMediaSources(e.mediaSources??""),e.fontsRevision!==Re){o.clearFonts();for(let c of e.fonts)c instanceof Uint8Array?o.registerFont(c):o.registerSubstituteFont(c.substituteOf,c.family);Re=e.fontsRevision;}for(let{story:c,env:f}of e.renderInputs)o.yrsBlocksForStory(c,f);for(let c of e.measureInputs)o.measureParagraphJson(c);let a=null,d=false,p=null;if(e.layoutWithRegions&&i!==void 0){a=o.layoutDocumentWithRegionsPrefixRetainedJson(e.layoutInput,i);let c=JSON.parse(a);d=c.provisional===true,p=c.layout.pages.length;}else e.layoutWithRegions&&!n?o.layoutDocumentWithRegionsRetained(e.layoutInput):e.layoutWithRegions?(a=o.layoutDocumentWithRegionsRetainedJson(e.layoutInput),e.partialDocument===true&&(p=JSON.parse(a).layout.pages.length)):o.layoutDocumentJson(e.layoutInput);return !e.workerAuthoritative&&e.selection&&o.setSelection(e.selection.anchor,e.selection.head),De=e.layoutRevision,b=[],E=rn(e.partialDocument,d,i,p),A=d&&e.partialDocument!==true?i??null:null,{layoutJson:a,provisional:d}}function Pe(){J?.release(),J=null;}function mn(e,i){let n=e.proposalEngine.version();(J?.owner!==e||J.version!==n)&&(Pe(),J={owner:e,version:n,byInput:new Map,release:e.onUpdate(Pe)});let r=J.byInput.get(i);if(r!==void 0)return r;let a=e.layoutFontRequirementsJson(i);return J.byInput.size>=_n&&J.byInput.delete(J.byInput.keys().next().value),J.byInput.set(i,a),a}function Dn(e,i,n,r){try{if(e.proposalEngine.version()!==r)return null;let a=JSON.parse(i);if(!a.renderEnv||typeof a.renderEnv!="object")return null;n===void 0?delete a.renderEnv.revisionPreview:a.renderEnv.revisionPreview=n;let d=JSON.stringify(a);return {version:r,layoutInput:d,requirementsJson:mn(e,d)}}catch(a){if(x)throw x;if(a instanceof WebAssembly.RuntimeError)throw a;return null}}function O(e,i,n){if(E!==null){e.setDisplayWindow(...ve(i,E)),e.setDisplayRetainBuiltPages(i!==void 0&&n===true),e.setWindowedIncrementalBuilds(true);return}i&&(A!==null?(X={window:i,retainBuiltPages:n===true},e.setDisplayWindow(...ve(i,A)),e.setDisplayRetainBuiltPages(false)):(e.setDisplayWindow(...i),e.setDisplayRetainBuiltPages(n===true))),e.setWindowedIncrementalBuilds(i!==void 0);}function K(){A=null,o&&X&&(o.setDisplayWindow(...X.window),o.setDisplayRetainBuiltPages(X.retainBuiltPages)),X=null;}async function ie(){if(!o||!_)return;let e=k;k=null;let{layoutInput:i,...n}=_;_=null;try{let r;if(e?.begun)try{r=o.resumeRegionLayout(xn).layoutJson;}catch(a){if(a instanceof WebAssembly.RuntimeError)throw a}T={...n,layoutJson:r??o.layoutDocumentWithRegionsRetainedJson(i),headersFootersJson:o.retainedHeadersFootersJson()},K(),e&&await Je(e.id,e.expectedFrameEpoch,e.paintCaret);}catch(r){throw e&&gn(e.id,r),r}}async function Je(e,i,n){let r=T;if(T=null,!o||!r){w({id:e,ok:true});return}O(o),b=[];let a=performance.now(),d=o.buildDisplayListFrame(Ie(r.extras,r.layoutExtras,null,r.headersFootersJson),i);await M(e,d,performance.now()-a,b,void 0,a,false,n,r.layoutJson);}var le=typeof MessageChannel=="function"?new MessageChannel:null,hn=[];le&&(le.port1.onmessage=()=>hn.shift()?.());function vn(e){if(!le){setTimeout(e,0);return}hn.push(e),le.port2.postMessage(null);}function Oe(){let e=L;e&&(L=null,w({id:e.request.id,ok:true,pageBuildSuperseded:true}));}function Sn(e){vn(()=>{L===e&&Fe(async()=>{try{await Fn(e);}catch(i){throw L===e&&(L=null),i}},e.request.id,()=>L===e);});}async function Fn(e){if(o!==e.owner||e.offset>0&&R?.frameEpoch!==e.frameEpoch){Oe();return}O(e.owner);let i=performance.now(),n=e.request.pages.slice(e.offset,e.offset+un),r=e.owner.buildDisplayPagesFrame(n,e.frameEpoch);if(e.engineMs+=performance.now()-i,e.offset+=n.length,e.offset===e.request.pages.length){L=null,await M(e.request.id,r,e.engineMs,[],void 0,e.started,false,e.request.paintCaret,void 0,false,void 0,e.frames);return}Ee(r),e.frameEpoch=R.frameEpoch,e.frames.push(r),Sn(e);}function _e(e){vn(()=>{k===e&&Fe(async()=>{try{await Jn(e);}catch(i){throw k===e&&(k=null),i}},e.id,()=>k===e);});}async function Jn(e){if(!o||k!==e||!_)return;let i;if(!e.begun)i=o.beginRegionLayout(_.layoutInput),e.begun=true;else {let a=performance.now();try{i=o.resumeRegionLayout(e.blocks);}catch(p){if(p instanceof WebAssembly.RuntimeError)throw p;let c=p instanceof Error?p.message:String(p);if(c!=="no region layout to resume"&&c!=="the document or its fonts changed since the region layout began")throw p;if(e.begun=false,e.restarts+=1,e.restarts>En&&!_.workerAuthoritative&&!N){try{await ie();}catch{}return}_e(e);return}let d=Math.max(1,performance.now()-a);e.blocks=Math.min(8192,Math.max(8,Math.round(e.blocks*In/d)));}if(i.layoutJson===void 0){_e(e);return}let{layoutInput:n,...r}=_;_=null,K(),k=null,T={...r,layoutJson:i.layoutJson,headersFootersJson:o.retainedHeadersFootersJson()},await Je(e.id,e.expectedFrameEpoch,e.paintCaret);}function Ce(){let e=k;k=null,e&&w({id:e.id,ok:true});}function Ie(e,i,n,r){if(i===void 0)return e;let a=r??(n===null?void 0:o?.retainedHeadersFootersJson()),d=a===void 0?void 0:JSON.parse(a);return D({...JSON.parse(i),...d?{headersFooters:d}:{}})}function pn(){o&&(W=o.onUpdate(e=>b.push(e.slice())));}function On(e,i,n){if(!n.ok||!P)return false;let r=JSON.parse(P.requirementsJson),a=JSON.parse(P.layoutInput);if(r.some(({scripts:p})=>p&&p.length>0)||Object.keys(a.renderEnv?.revisionPreview??{}).length>0)return false;let d=new Map;for(let p of i.proposals){let c=p.op==="replaceText"?p.replaceWith:p.text;if(!/^[\x20-\x7e]*$/.test(c))return false;let f=n.snapshot.proposals.find(({id:h})=>h===p.id);if(!f?.changed)continue;let{story:m,paraId:l}=f.paragraph,g=d.get(m)??new Set;g.add(l),d.set(m,g);}for(let[p,c]of d){let f=new Map,m=e.geometryReader.paragraphSpans(p);for(let g=0;g<m.length;g+=1){let{paraId:h}=m[g];if(c.has(h)){if(f.has(h))return false;f.set(h,g);}}if(f.size!==c.size)return false;let l=[...f.values()];for(let g of e.paragraphSegments(p,l)){let h=true,S=false;for(let v of g)v.kind==="text"?(h&&(h=/^[\x20-\x7e]*$/.test(v.text)),S||(S=v.text.length>0&&v.attributes.ins==null)):v.kind!=="pilcrow"&&(h=false);if(!h||!S)return false}}return true}function Se(e=false){Oe(),P=null,Pe(),ee=null,W?.(),W=null,N?.destroy(),N=null,o?.destroy(),we=null,o=null,ne=null,be=false,E=null,K(),b=[],De=0,Re=-1,Ce(),_=null,T=null,R=null,te=null,$.clear(),j.clear(),e||(B.clear(),G.clear()),H=null,C=null,z=null,oe=null,Q.clear();}function wn(e){Q.delete(e),C===e&&(C=null,z=null);}function Ee(e){R=x$2(R,u(e));for(let i of R.damagedPageIds)j.add(i.toString());}async function M(e,i,n,r=b,a,d=performance.now(),p=false,c=false,f,m=false,l,g=[]){Ee(i);let h=A;if(o&&h!==null&&R){let I=R.displayList.pages.filter(F=>F.pageIndex>=h&&!F.unbuilt).map(F=>F.pageIndex);if(I.length>0){if(o.releaseDisplayPagesFrame(I,R.frameEpoch)===null)throw new Error("Provisional display pages could not be released");i=o.buildDisplayPagesFrame([],0),Ee(i);}}let S=o?.residentCaretSnapshot();if(!S||!R||!j$1(S,R))throw new Error("Resident caret snapshot does not match the produced frame");if(p&&!S.caretRect)throw new Error("Resident input frame omitted collapsed caret geometry");let v=o?.selection()??null;H=c?S.caretRect??null:null;let t=new Map(R.pages.map(({pageId:I,page:F})=>[I.toString(),F.unbuilt===true]));for(let I of j)t.get(I)!==false&&j.delete(I);for(let I of new Set([...B.keys(),...$.keys()])){let F=t.get(I);if(F===false)continue;let Be=B.get(I);F===void 0?B.delete(I):Be&&k$1(Be),$.delete(I),wn(I);}let s=performance.now(),{replayedPages:u,caretPainted:y}=await xe(false),D=performance.now()-s,U=Y(i),V=g.map(Y),Ae=r.map(Y),Z=o?Y(o.encodeStateVector()):void 0;w({id:e,ok:true,frame:U,...V.length>0?{pageFrames:[...V,U]}:{},updates:Ae,engineMs:n,workerTotalMs:performance.now()-d,engineProfile:a,caret:S,selection:v,caretPainted:y,replayMs:D,replayedPages:u,layoutRevision:De,...l===void 0?{}:{deletedUnits:l},...Z?{stateVector:Z}:{},...f!==void 0?{layoutJson:f}:{},...m?{layoutProvisional:m}:{}},[U,...V,...Ae,...Z?[Z]:[]]);}async function xe(e){let i$1=e===true?G:e;if(i$1)for(let{pageId:f,page:m}of R?.pages??[]){let l=f.toString();!m.unbuilt&&i$1.has(l)&&j.add(l);}if(!R||B.size===0)return {replayedPages:0,caretPainted:false};!te&&o&&(te=new a$1({provider:(f,m)=>{try{return o.outlineGlyphJson(f,m)}catch(l){throw l instanceof WebAssembly.RuntimeError&&bn()>0&&yn(cn,l),l}}}));let n=H&&G.has(H.pageId)?H:null,r=n?i(n,re,se,ae):null,a=n&&r?`${n.pageId}|${r.x}|${r.y}|${r.width}|${r.height}|${re.color}`:null,d=[];for(let f=0;f<R.pages.length;f+=1){let l=R.pages[f].pageId.toString();if(!G.has(l))continue;let g=j.has(l),h$1=l===n?.pageId&&!(C===l&&z===a),S=l===C&&l!==n?.pageId;if(!g&&!h$1&&!S)continue;let v=B.get(l),t=R.displayList.pages[f];if(!v||!t||t.unbuilt)continue;let s=l,u=$.get(s);u||(u=new OffscreenCanvas(1,1),$.set(s,u));let y=u;if(!g&&Q.has(s)){d.push(Promise.resolve({canvas:v,buffer:y,pageId:s}));continue}d.push(h(y,t,{glyphCache:te??void 0},se,ae).then(()=>({canvas:v,buffer:y,pageId:s})));}let p=await Promise.all(d).catch(async f=>{throw await Promise.allSettled(d),f}),c=n!==null&&C===n.pageId&&z===a;for(let{canvas:f,buffer:m,pageId:l$1}of p)n&&r&&l$1===n.pageId?(oe||(oe=new OffscreenCanvas(1,1)),l(f,m,oe,{...r,color:re.color}),Q.add(l$1),C=l$1,z=a,c=true):(j$2(f,m),Q.delete(l$1),C===l$1&&(C=null,z=null)),j.delete(l$1);return {replayedPages:p.length,caretPainted:c}}function Y(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:e.slice().buffer}function bn(){return b$2().find(e=>e.label==="docx-edit")?.failedAllocationBytes??0}function w(e,i=[]){if(x&&e.ok)throw x;ke.postMessage({...e,memory:b$2()},i);}
|