@betteroffice/docx 0.0.4 → 0.2.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/README.md +4 -7
- package/dist/chunk-47Q2FMFF.mjs +1 -0
- package/dist/chunk-5F6DLQZP.mjs +1 -0
- package/dist/chunk-6LQJAKOC.mjs +1 -0
- package/dist/chunk-ACGKK7IB.mjs +1 -0
- package/dist/{chunk-NTSSE5QK.mjs → chunk-AFMVSI4Z.mjs} +2 -2
- package/dist/chunk-GD4VNJ64.mjs +1 -0
- package/dist/{chunk-NJHOPXZW.mjs → chunk-HLDJMU3R.mjs} +1 -1
- package/dist/{chunk-YTILOUAA.mjs → chunk-JHJLG4I6.mjs} +1 -1
- package/dist/chunk-PGMXWI5X.mjs +1 -0
- package/dist/{chunk-NBSLB77E.mjs → chunk-WTFRNX5K.mjs} +1 -1
- package/dist/collaboration/index.d.mts +6 -6
- package/dist/{content-C3sTRz-u.d.mts → content-CvEtPl0c.d.mts} +124 -22
- package/dist/core.d.mts +8 -8
- package/dist/core.mjs +1 -1
- package/dist/{displayListQueries-DLzpvJV6.d.mts → displayListQueries-DF8F6fMl.d.mts} +87 -50
- package/dist/docx/index.d.mts +5 -5
- package/dist/docx/index.mjs +1 -1
- package/dist/editor/index.d.mts +21 -12
- package/dist/editor/index.mjs +1 -1
- package/dist/{fontLoader-CMH3bZ2Z.d.mts → fontLoader-b8eicJKV.d.mts} +1 -1
- package/dist/{formatting-BEkIBePP.d.mts → formatting-7zKCTu5a.d.mts} +11 -2
- package/dist/{frameDelta-B2kC6XiP.d.mts → frameDelta-pA4jrQ1G.d.mts} +16 -10
- 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-2piKi4gO.d.mts → index-CHl2zLJ7.d.mts} +146 -77
- package/dist/layout/index.d.mts +40 -13
- package/dist/layout/index.mjs +1 -1
- package/dist/layout/pagination/index.d.mts +4 -4
- package/dist/layout/pagination/index.mjs +1 -1
- package/dist/layout/render/index.d.mts +33 -77
- package/dist/layout/render/index.mjs +1 -1
- package/dist/plugin-api/RenderedDomContext.d.mts +7 -7
- package/dist/plugin-api/index.d.mts +3 -3
- package/dist/plugin-api/resolveItemPositions.d.mts +3 -3
- package/dist/{rustDisplayList-B0M2eBkU.d.mts → rustDisplayList-BJqaN9tt.d.mts} +74 -50
- package/dist/{rustMeasureSource-D1KsQvVC.d.mts → rustMeasureSource-C0EZB055.d.mts} +5 -2
- package/dist/{selectiveSave-CVoajSKE.d.mts → selectiveSave-CRh-_Y_C.d.mts} +3 -3
- package/dist/styles/index.d.mts +6 -10
- package/dist/styles/index.mjs +1 -1
- package/dist/{styles-BK3Jecxs.d.mts → styles-7e-mq3c-.d.mts} +1 -1
- package/dist/types/content.d.mts +2 -2
- package/dist/types/document.d.mts +8 -7
- package/dist/{types-C1rv3KM-.d.mts → types-C4A8mWjU.d.mts} +44 -24
- package/dist/utils/comments.d.mts +2 -2
- package/dist/utils/index.d.mts +11 -13
- package/dist/utils/index.mjs +1 -1
- package/dist/utils/stylePreview.d.mts +2 -2
- package/dist/wasm-7SOSHNGP.mjs +1 -0
- package/dist/{wasm-JE7B3ROD.mjs → wasm-ZQAVP7P2.mjs} +1 -1
- package/dist/wasm-edit.d.mts +525 -185
- package/dist/wasm-edit.mjs +1 -1
- package/dist/wasm-layout.d.mts +31 -28
- package/dist/wasm-layout.mjs +1 -1
- package/dist/wasm-opc.mjs +1 -1
- package/dist/wasm-parse.d.mts +2 -1
- package/dist/wasm-parse.mjs +1 -1
- package/dist/yrs/index.d.mts +5 -5
- package/dist/yrs/index.mjs +1 -1
- package/dist/yrs/residentEngineWorker.mjs +1 -1
- package/package.json +19 -2
- package/dist/chunk-4V6MDZIK.mjs +0 -1
- package/dist/chunk-6KDV6AIL.mjs +0 -1
- package/dist/chunk-B4IR6YP4.mjs +0 -1
- package/dist/chunk-GGEGIQRK.mjs +0 -1
- package/dist/chunk-T4EZMUXM.mjs +0 -1
- package/dist/chunk-WBH3SXI6.mjs +0 -1
- package/dist/wasm-F2ETFAYL.mjs +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Document } from './types/document.mjs';
|
|
2
|
-
import { R as RetainedFrame } from './frameDelta-
|
|
2
|
+
import { R as RetainedFrame } from './frameDelta-pA4jrQ1G.mjs';
|
|
3
3
|
|
|
4
4
|
type CollaborationUpdateOrigin = 'local' | 'remote';
|
|
5
5
|
interface CollaborationReplica {
|
|
@@ -134,6 +134,91 @@ declare function residentCaretDeviceRect(rect: Pick<YrsResidentCaretRect, 'x' |
|
|
|
134
134
|
};
|
|
135
135
|
declare function residentCaretSnapshotForFrame(snapshot: YrsResidentCaretSnapshot, frame: RetainedFrame): YrsResidentCaretSnapshot | null;
|
|
136
136
|
|
|
137
|
+
type ResidentEngineWorkerRequest = {
|
|
138
|
+
id: number;
|
|
139
|
+
type: 'bootstrap';
|
|
140
|
+
snapshot: YrsResidentWorkerSnapshot;
|
|
141
|
+
extras: string;
|
|
142
|
+
expectedFrameEpoch: number;
|
|
143
|
+
} | {
|
|
144
|
+
id: number;
|
|
145
|
+
type: 'sync';
|
|
146
|
+
snapshot: YrsResidentWorkerSnapshot;
|
|
147
|
+
extras: string;
|
|
148
|
+
expectedFrameEpoch: number;
|
|
149
|
+
paintCaret: boolean;
|
|
150
|
+
} | {
|
|
151
|
+
id: number;
|
|
152
|
+
type: 'buildFrame';
|
|
153
|
+
extras: string;
|
|
154
|
+
expectedFrameEpoch: number;
|
|
155
|
+
paintCaret: boolean;
|
|
156
|
+
} | {
|
|
157
|
+
id: number;
|
|
158
|
+
type: 'applyInput';
|
|
159
|
+
text: string;
|
|
160
|
+
selection: YrsSelection;
|
|
161
|
+
expectedFrameEpoch: number;
|
|
162
|
+
profile: boolean;
|
|
163
|
+
paintCaret: boolean;
|
|
164
|
+
} | {
|
|
165
|
+
id: number;
|
|
166
|
+
type: 'applyDelete';
|
|
167
|
+
direction: 'backward' | 'forward';
|
|
168
|
+
selection: YrsSelection;
|
|
169
|
+
expectedFrameEpoch: number;
|
|
170
|
+
profile: boolean;
|
|
171
|
+
paintCaret: boolean;
|
|
172
|
+
} | {
|
|
173
|
+
id: number;
|
|
174
|
+
type: 'applyUpdate';
|
|
175
|
+
update: Uint8Array;
|
|
176
|
+
selection: YrsSelection | null;
|
|
177
|
+
} | {
|
|
178
|
+
id: number;
|
|
179
|
+
type: 'attachCanvases';
|
|
180
|
+
pages: Array<{
|
|
181
|
+
pageId: string;
|
|
182
|
+
canvas: OffscreenCanvas;
|
|
183
|
+
}>;
|
|
184
|
+
activePageIds: string[];
|
|
185
|
+
devicePixelRatio: number;
|
|
186
|
+
zoom: number;
|
|
187
|
+
caretStyle: ResidentCaretPaintStyle;
|
|
188
|
+
} | {
|
|
189
|
+
id: number;
|
|
190
|
+
type: 'eraseCaret';
|
|
191
|
+
} | {
|
|
192
|
+
id: number;
|
|
193
|
+
type: 'destroy';
|
|
194
|
+
};
|
|
195
|
+
type ResidentEngineWorkerResponse = {
|
|
196
|
+
id: number;
|
|
197
|
+
ok: true;
|
|
198
|
+
frame?: ArrayBuffer;
|
|
199
|
+
updates?: ArrayBuffer[];
|
|
200
|
+
engineMs?: number;
|
|
201
|
+
workerTotalMs?: number;
|
|
202
|
+
engineProfile?: YrsEngineApplyProfile;
|
|
203
|
+
caret?: YrsResidentCaretSnapshot;
|
|
204
|
+
selection?: YrsSelection | null;
|
|
205
|
+
/** The presented frame carries the worker-painted caret line. */
|
|
206
|
+
caretPainted?: boolean;
|
|
207
|
+
replayMs?: number;
|
|
208
|
+
replayedPages?: number;
|
|
209
|
+
layoutRevision?: number;
|
|
210
|
+
/** The worker replica's yrs state vector after this operation, so the
|
|
211
|
+
* next sync can ship a diff instead of the whole document state. */
|
|
212
|
+
stateVector?: ArrayBuffer;
|
|
213
|
+
} | {
|
|
214
|
+
id: number;
|
|
215
|
+
ok: false;
|
|
216
|
+
error: string;
|
|
217
|
+
residentUnavailable?: boolean;
|
|
218
|
+
/** A wasm trap poisoned the worker; it refuses every later request. */
|
|
219
|
+
terminal?: boolean;
|
|
220
|
+
};
|
|
221
|
+
|
|
137
222
|
interface ResidentEngineWorkerFrame {
|
|
138
223
|
frame: Uint8Array;
|
|
139
224
|
updates: Uint8Array[];
|
|
@@ -155,17 +240,24 @@ interface ResidentEngineOffscreenPage {
|
|
|
155
240
|
interface ResidentEngineWorkerApplyResult extends ResidentEngineWorkerFrame {
|
|
156
241
|
applied: true;
|
|
157
242
|
}
|
|
243
|
+
interface ResidentEngineWorkerPort {
|
|
244
|
+
onmessage: ((event: MessageEvent<ResidentEngineWorkerResponse>) => void) | null;
|
|
245
|
+
onerror: ((event: ErrorEvent) => void) | null;
|
|
246
|
+
onmessageerror: ((event: MessageEvent) => void) | null;
|
|
247
|
+
postMessage(message: ResidentEngineWorkerRequest, transfer?: Transferable[]): void;
|
|
248
|
+
terminate(): void;
|
|
249
|
+
}
|
|
158
250
|
/** Dedicated-worker owner for resident input, pagination, and FrameDelta output. */
|
|
159
251
|
declare class ResidentEngineWorkerClient {
|
|
160
252
|
private readonly worker;
|
|
161
253
|
private readonly pending;
|
|
162
254
|
private nextId;
|
|
163
|
-
private
|
|
255
|
+
private terminalError;
|
|
164
256
|
private ready;
|
|
165
257
|
private revision;
|
|
166
258
|
private remoteVector;
|
|
167
259
|
private appliedFontsRevision;
|
|
168
|
-
constructor();
|
|
260
|
+
constructor(worker?: ResidentEngineWorkerPort);
|
|
169
261
|
isReady(): boolean;
|
|
170
262
|
layoutRevision(): number;
|
|
171
263
|
/** The worker replica's last reported yrs state vector (null before any). */
|
|
@@ -191,19 +283,14 @@ declare class ResidentEngineWorkerClient {
|
|
|
191
283
|
/** Record a successfully applied bootstrap/sync payload's fonts revision.
|
|
192
284
|
* The state vector is tracked centrally in `onmessage`. */
|
|
193
285
|
private recordSync;
|
|
194
|
-
private
|
|
286
|
+
private fail;
|
|
287
|
+
}
|
|
288
|
+
/** The worker itself failed (crash, timeout, torn-down, corrupt reply). */
|
|
289
|
+
declare class ResidentWorkerFailureError extends Error {
|
|
195
290
|
}
|
|
196
291
|
declare function canUseResidentEngineWorker(): boolean;
|
|
197
292
|
|
|
198
|
-
/**
|
|
199
|
-
* Direct Document -> yrs load projection.
|
|
200
|
-
*
|
|
201
|
-
* This is the Document-model twin of the coexistence seed path. It emits the
|
|
202
|
-
* same flat story vocabulary as `seedFromPm`, but never constructs a
|
|
203
|
-
* ProseMirror node: text becomes attributed Y.Text, paragraphs become pilcrow
|
|
204
|
-
* embeds, tables/block SDTs become structural embeds with child stories, and
|
|
205
|
-
* comments become root-story side-map entries.
|
|
206
|
-
*/
|
|
293
|
+
/** Direct Document-to-yrs load projection. */
|
|
207
294
|
|
|
208
295
|
/**
|
|
209
296
|
* Seeds every yrs-owned editable story directly from a parsed Document.
|
|
@@ -216,14 +303,7 @@ declare function canUseResidentEngineWorker(): boolean;
|
|
|
216
303
|
*/
|
|
217
304
|
declare function documentToYrs(session: YrsSession, document: Document): void;
|
|
218
305
|
|
|
219
|
-
/**
|
|
220
|
-
* yrs -> OOXML Document save projection.
|
|
221
|
-
*
|
|
222
|
-
* The yrs coexistence model stores each editable container as a flat story:
|
|
223
|
-
* text carries inline formatting attributes, pilcrows carry paragraph
|
|
224
|
-
* properties, and structural/inline atoms are map embeds. This module reads
|
|
225
|
-
* that representation directly and rebuilds the serializer-facing Document.
|
|
226
|
-
*/
|
|
306
|
+
/** yrs-to-OOXML save projection. */
|
|
227
307
|
|
|
228
308
|
/**
|
|
229
309
|
* Rebuild all yrs-owned editable stories into the serializer-facing Document
|
|
@@ -511,8 +591,8 @@ interface YrsRevisionReceipt {
|
|
|
511
591
|
revisionId: string | null;
|
|
512
592
|
}
|
|
513
593
|
/**
|
|
514
|
-
* Receipt of {@link YrsSession.splitParagraph}.
|
|
515
|
-
*
|
|
594
|
+
* Receipt of {@link YrsSession.splitParagraph}. The first half keeps the
|
|
595
|
+
* original paraId and the second half is re-minted; suggesting
|
|
516
596
|
* mode stamps a `pPrIns` revision on the first half.
|
|
517
597
|
*/
|
|
518
598
|
interface YrsSplitReceipt {
|
|
@@ -520,12 +600,7 @@ interface YrsSplitReceipt {
|
|
|
520
600
|
secondParaId: string;
|
|
521
601
|
revisionId: string | null;
|
|
522
602
|
}
|
|
523
|
-
/**
|
|
524
|
-
* One low-level story mirror operation for {@link YrsSession.applyRawOps}. The
|
|
525
|
-
* coexistence bridge lowers a ProseMirror transaction to a list of these and
|
|
526
|
-
* applies them in one yrs transaction. Indices are UTF-16 story units, each read
|
|
527
|
-
* against the story state after all prior ops in the batch.
|
|
528
|
-
*/
|
|
603
|
+
/** Low-level UTF-16 story operation for {@link YrsSession.applyRawOps}. */
|
|
529
604
|
type YrsRawOp = {
|
|
530
605
|
op: 'insert';
|
|
531
606
|
index: number;
|
|
@@ -552,13 +627,7 @@ type YrsRawOp = {
|
|
|
552
627
|
key: string;
|
|
553
628
|
value: unknown;
|
|
554
629
|
} | {
|
|
555
|
-
/**
|
|
556
|
-
* Upserts the side-map comment keyed by `id`, (re-)anchoring it to
|
|
557
|
-
* `ranges` — non-empty `[start, end)` story-unit spans in the batch's
|
|
558
|
-
* story (sticky `Assoc::After` starts / `Assoc::Before` ends). The
|
|
559
|
-
* coexistence bridge keys by the PM comment id so identity survives the
|
|
560
|
-
* mirror.
|
|
561
|
-
*/
|
|
630
|
+
/** Upserts a side-map comment with sticky story-unit ranges. */
|
|
562
631
|
op: 'setComment';
|
|
563
632
|
id: string;
|
|
564
633
|
ranges: ReadonlyArray<readonly [number, number]>;
|
|
@@ -572,6 +641,9 @@ type YrsRawOp = {
|
|
|
572
641
|
};
|
|
573
642
|
/** Host context for {@link YrsSession.yrsBlocksForStory} (theme + list numbering). */
|
|
574
643
|
interface YrsRenderEnv {
|
|
644
|
+
tocStyleIds?: string[];
|
|
645
|
+
paragraphSpacingLinePx?: number;
|
|
646
|
+
defaultParagraphStyleId?: string;
|
|
575
647
|
/** Theme color name → hex (`accent1` → `4472C4`), for theme-color resolution. */
|
|
576
648
|
themeColors?: Record<string, string>;
|
|
577
649
|
/** The document default tab stop in twips. */
|
|
@@ -580,6 +652,8 @@ interface YrsRenderEnv {
|
|
|
580
652
|
pageContentHeight?: number | null;
|
|
581
653
|
/** yrs revision/paragraph id → dense numeric layout id (list markers, revisions). */
|
|
582
654
|
numericIds?: Record<string, number>;
|
|
655
|
+
/** Include hidden text in visible layout without changing the document. */
|
|
656
|
+
showHiddenText?: boolean;
|
|
583
657
|
}
|
|
584
658
|
/** Receipt of {@link YrsSession.addComment}. */
|
|
585
659
|
interface YrsCommentReceipt {
|
|
@@ -686,7 +760,7 @@ interface YrsSelectionContext {
|
|
|
686
760
|
strike: YrsTriState;
|
|
687
761
|
/** Uniform ASCII font family, or `null` when absent/mixed. */
|
|
688
762
|
fontFamily: string | null;
|
|
689
|
-
/** Uniform font size in half-points (the
|
|
763
|
+
/** Uniform font size in half-points (the OOXML `w:sz` unit). */
|
|
690
764
|
fontSize: number | null;
|
|
691
765
|
/** Uniform RGB hex or theme-color name, or `null` when absent/mixed. */
|
|
692
766
|
color: string | null;
|
|
@@ -695,7 +769,7 @@ interface YrsSelectionContext {
|
|
|
695
769
|
styleId: string | null;
|
|
696
770
|
alignment: string | null;
|
|
697
771
|
/**
|
|
698
|
-
* Full authored pilcrow property bag. Known toolbar fields retain their
|
|
772
|
+
* Full authored pilcrow property bag. Known toolbar fields retain their
|
|
699
773
|
* names (`indentLeft`, `spaceBefore`, `lineSpacing`, `numPr`, and so on);
|
|
700
774
|
* paragraph style is stored as `pStyle`.
|
|
701
775
|
*/
|
|
@@ -764,8 +838,8 @@ interface YrsCellLoc extends YrsTableLoc {
|
|
|
764
838
|
column: number;
|
|
765
839
|
}
|
|
766
840
|
/**
|
|
767
|
-
* Anchor-cell to head-cell rectangular selection,
|
|
768
|
-
*
|
|
841
|
+
* Anchor-cell to head-cell rectangular selection, addressed by grid
|
|
842
|
+
* coordinates rather than document positions.
|
|
769
843
|
*
|
|
770
844
|
* @public
|
|
771
845
|
*/
|
|
@@ -789,7 +863,7 @@ interface YrsTableReceipt {
|
|
|
789
863
|
revisionIds: string[];
|
|
790
864
|
}
|
|
791
865
|
/**
|
|
792
|
-
* OOXML
|
|
866
|
+
* OOXML-shaped cell border value passed through to `tcPr.borders`.
|
|
793
867
|
*
|
|
794
868
|
* @public
|
|
795
869
|
*/
|
|
@@ -801,11 +875,13 @@ interface YrsCellBorder {
|
|
|
801
875
|
};
|
|
802
876
|
}
|
|
803
877
|
/**
|
|
804
|
-
*
|
|
878
|
+
* Per-side border patch for {@link YrsSession.setCellBorders}. An omitted side
|
|
879
|
+
* is left alone, `style: 'none'` authors an explicit no-border, and `null`
|
|
880
|
+
* drops the authored side.
|
|
805
881
|
*
|
|
806
882
|
* @public
|
|
807
883
|
*/
|
|
808
|
-
type YrsCellBorders = Partial<Record<'top' | 'bottom' | 'left' | 'right' | 'insideH' | 'insideV', YrsCellBorder>>;
|
|
884
|
+
type YrsCellBorders = Partial<Record<'top' | 'bottom' | 'left' | 'right' | 'insideH' | 'insideV', YrsCellBorder | null>>;
|
|
809
885
|
/**
|
|
810
886
|
* One live replica of the yrs editing model. Thin typed wrapper over the
|
|
811
887
|
* wasm `EditSession` — no editing logic on this side of the boundary.
|
|
@@ -825,6 +901,11 @@ interface YrsSession extends CollaborationReplica {
|
|
|
825
901
|
layoutFontRequirementsJson(input: string): string;
|
|
826
902
|
/** Paginate and compose section/page regions in the resident engine. */
|
|
827
903
|
layoutDocumentWithRegionsJson(input: string): string;
|
|
904
|
+
/** Same pass, but the reply omits the measured arena (fetch it on demand
|
|
905
|
+
* through {@link YrsSession.retainedKernelInputsJson}). */
|
|
906
|
+
layoutDocumentWithRegionsRetainedJson(input: string): string;
|
|
907
|
+
/** Retained `{ measured, options }` for the main-thread display fallback. */
|
|
908
|
+
retainedKernelInputsJson(expectedLayoutRevision: number): string;
|
|
828
909
|
/** Build display primitives against the session's resident font store. */
|
|
829
910
|
buildDisplayListJson(input: string): string;
|
|
830
911
|
/** Build a binary FrameDelta v1 against the last host-applied frame. */
|
|
@@ -871,11 +952,7 @@ interface YrsSession extends CollaborationReplica {
|
|
|
871
952
|
openDocx(bytes: Uint8Array, seedStories: boolean): YrsDocxHost;
|
|
872
953
|
/** Materializes the retained canonical package for compatibility APIs. */
|
|
873
954
|
materializeDocx(): Document | null;
|
|
874
|
-
/**
|
|
875
|
-
* Seeds stories from parsed content (S1 scaffold; the real
|
|
876
|
-
* `load(ParsedDocument)` lands with the ops track). Returns paraIds per
|
|
877
|
-
* story in document order.
|
|
878
|
-
*/
|
|
955
|
+
/** Seeds stories and returns paragraph IDs in document order. */
|
|
879
956
|
loadStories(stories: readonly YrsStorySeed[]): Record<string, string[]>;
|
|
880
957
|
/** Full document state as one yrs v1 update (Yjs wire format). */
|
|
881
958
|
encodeState(): Uint8Array;
|
|
@@ -886,7 +963,7 @@ interface YrsSession extends CollaborationReplica {
|
|
|
886
963
|
/** Applies a remote/incremental yrs v1 update. */
|
|
887
964
|
applyUpdate(update: Uint8Array): CollaborationTextInsertion | null;
|
|
888
965
|
/** Apply a same-user worker update under the local undo origin. @internal */
|
|
889
|
-
applyLocalUpdate(update: Uint8Array
|
|
966
|
+
applyLocalUpdate(update: Uint8Array): void;
|
|
890
967
|
/**
|
|
891
968
|
* Subscribes to every committed transaction's v1 update (local AND
|
|
892
969
|
* applied-remote). Returns an unsubscribe function.
|
|
@@ -908,18 +985,15 @@ interface YrsSession extends CollaborationReplica {
|
|
|
908
985
|
setCellSelection(range: YrsTableRange): void;
|
|
909
986
|
/** Resolve the current sticky cell selection, or null before initialization. */
|
|
910
987
|
cellSelection(): YrsTableRange | null;
|
|
911
|
-
/**
|
|
912
|
-
beginUndoCapture(
|
|
913
|
-
/**
|
|
914
|
-
|
|
988
|
+
/** Begin local-origin undo capture once import/seeding has completed. */
|
|
989
|
+
beginUndoCapture(): void;
|
|
990
|
+
/** Stories changed by the latest undo or redo, sorted. */
|
|
991
|
+
historyStories(): string[];
|
|
915
992
|
/** Undo/redo only local-origin direct operations (never remote/system transactions). */
|
|
916
993
|
undo(): boolean;
|
|
917
994
|
redo(): boolean;
|
|
918
995
|
canUndo(): boolean;
|
|
919
996
|
canRedo(): boolean;
|
|
920
|
-
/** Current local undo/redo stack sizes (zero before tracking starts). */
|
|
921
|
-
undoDepth(): number;
|
|
922
|
-
redoDepth(): number;
|
|
923
997
|
/** Adds a story with one paragraph; the receipt carries its paraId. */
|
|
924
998
|
createStory(storyId: string, initialText: string, pStyle?: string, alignment?: string): YrsParagraphReceipt;
|
|
925
999
|
/** Removes a complete story (including an unreachable table-cell story). */
|
|
@@ -943,11 +1017,14 @@ interface YrsSession extends CollaborationReplica {
|
|
|
943
1017
|
/** Sets or clears the selected cells' background color. */
|
|
944
1018
|
setCellShading(range: YrsTableRange, color: string | null): YrsTableReceipt;
|
|
945
1019
|
/**
|
|
946
|
-
* Merges an OOXML
|
|
1020
|
+
* Merges an OOXML-shaped patch into selected cells' `tcPr`. JSON `null`
|
|
947
1021
|
* clears a property; merge/split-owned span keys are rejected.
|
|
948
1022
|
*/
|
|
949
1023
|
setCellTextFormat(range: YrsTableRange, patch: Readonly<Record<string, unknown>>): YrsTableReceipt;
|
|
950
|
-
/**
|
|
1024
|
+
/**
|
|
1025
|
+
* Merges border sides into the selected cells. `insideH`/`insideV` resolve
|
|
1026
|
+
* per cell to the physical edges interior to the selection.
|
|
1027
|
+
*/
|
|
951
1028
|
setCellBorders(range: YrsTableRange, borders: YrsCellBorders): YrsTableReceipt;
|
|
952
1029
|
/** Sets one authored grid-column width in twips. */
|
|
953
1030
|
setColumnWidth(at: YrsCellLoc, widthTwips: number): YrsTableReceipt;
|
|
@@ -969,7 +1046,10 @@ interface YrsSession extends CollaborationReplica {
|
|
|
969
1046
|
splitParagraph(at: YrsLoc, suggesting?: YrsAuthor): YrsSplitReceipt;
|
|
970
1047
|
/** Merges `paraId` with the FOLLOWING paragraph. Errors on the final paragraph. */
|
|
971
1048
|
mergeParagraphs(story: string, paraId: string, suggesting?: YrsAuthor): YrsRevisionReceipt;
|
|
972
|
-
/**
|
|
1049
|
+
/**
|
|
1050
|
+
* Toggles one run mark across a range: removes it when every unit already
|
|
1051
|
+
* carries it, otherwise adds it.
|
|
1052
|
+
*/
|
|
973
1053
|
toggleMark(range: YrsStoryRange, mark: YrsRunMark): void;
|
|
974
1054
|
/** Applies set-valued direct formatting; omitted fields are kept and `null` fields clear. */
|
|
975
1055
|
formatRange(range: YrsStoryRange, delta: YrsInlineFormatDelta): void;
|
|
@@ -997,18 +1077,16 @@ interface YrsSession extends CollaborationReplica {
|
|
|
997
1077
|
insertSectionBreak(at: YrsLoc, type: 'nextPage' | 'continuous' | 'oddPage' | 'evenPage'): void;
|
|
998
1078
|
/** Inserts a typed watermark embed at a paragraph-keyed location. */
|
|
999
1079
|
insertWatermark(at: YrsLoc, watermark: YrsWatermark): void;
|
|
1000
|
-
/**
|
|
1001
|
-
* Applies a batch of raw story mirror ops in one transaction — the coexistence
|
|
1002
|
-
* bridge's mirror-into-yrs path (a faithful mirror of lowered PM state, not a
|
|
1003
|
-
* user-intent op). Not for direct app use.
|
|
1004
|
-
*/
|
|
1080
|
+
/** Applies raw story operations in one transaction. */
|
|
1005
1081
|
applyRawOps(story: string, ops: readonly YrsRawOp[]): void;
|
|
1082
|
+
/** Applies seed raw operations with deterministic item ordering. */
|
|
1083
|
+
applySeedRawOps(story: string, ops: readonly YrsRawOp[]): void;
|
|
1006
1084
|
/** Sets one paragraph property (any JSON value). `paraId` is reserved. */
|
|
1007
1085
|
setParagraphAttr(paraId: string, key: string, value: unknown): void;
|
|
1008
1086
|
/** Adds a sticky-anchored comment over one or more ranges. */
|
|
1009
1087
|
addComment(ranges: readonly YrsStoryRange[], author: string, date: string, body: unknown): YrsCommentReceipt;
|
|
1010
1088
|
/**
|
|
1011
|
-
* Accepts tracked changes
|
|
1089
|
+
* Accepts tracked changes: pending insertions become plain content,
|
|
1012
1090
|
* pending deletions are carried out; a `pPrIns` paragraph mark clears (the
|
|
1013
1091
|
* split stays), a `pPrDel` mark joins with the following paragraph (whose
|
|
1014
1092
|
* pPr survives — Word's surviving-`w:p` rule). Resolving never stamps a new
|
|
@@ -1031,18 +1109,9 @@ interface YrsSession extends CollaborationReplica {
|
|
|
1031
1109
|
storyIds(): string[];
|
|
1032
1110
|
/** Story length in UTF-16 units (every embed, pilcrows included, counts 1). */
|
|
1033
1111
|
storyLength(story: string): number;
|
|
1034
|
-
/**
|
|
1035
|
-
* The story's `canonical-stream-v1` FNV-1a checksum. The coexistence watchdog
|
|
1036
|
-
* compares it against the PM projector's checksum after every mirrored edit.
|
|
1037
|
-
*/
|
|
1112
|
+
/** Returns the story's canonical-stream checksum. */
|
|
1038
1113
|
storyChecksum(story: string): bigint;
|
|
1039
|
-
/**
|
|
1040
|
-
* Lowers a story through the resident Rust bridge. Throws with an
|
|
1041
|
-
* unsupported-embed message on any non-native content (opaque blobs) until
|
|
1042
|
-
* that class is promoted to native.
|
|
1043
|
-
* The return is the layout pipeline's `LayoutBlock[]` (kept as `unknown[]` to
|
|
1044
|
-
* keep this facade decoupled from the layout types).
|
|
1045
|
-
*/
|
|
1114
|
+
/** Lowers a story to layout blocks and rejects unsupported embeds. */
|
|
1046
1115
|
yrsBlocksForStory(story: string, env?: YrsRenderEnv): unknown[];
|
|
1047
1116
|
/** Paragraph snapshots in document order. */
|
|
1048
1117
|
paragraphs(story: string): YrsParagraph[];
|
|
@@ -1070,4 +1139,4 @@ interface CreateYrsSessionOptions {
|
|
|
1070
1139
|
*/
|
|
1071
1140
|
declare function createYrsSession(options?: CreateYrsSessionOptions): Promise<YrsSession>;
|
|
1072
1141
|
|
|
1073
|
-
export { type
|
|
1142
|
+
export { type YrsParagraphSpan as $, type ResidentEngineWorkerFrame as A, ResidentWorkerFailureError as B, type CollaborationReplica as C, type YrsAuthor as D, type YrsCellBorder as E, type YrsCellBorders as F, type YrsCellLoc as G, type YrsChangeTarget as H, type YrsCommentReceipt as I, type YrsContentControlValue as J, type YrsDocxHost as K, type YrsEngineApplyProfile as L, type YrsHyperlinkAttrs as M, type YrsImageGeometry as N, type YrsInlineFormatDelta as O, type YrsInputParagraphSeed as P, type YrsInputParagraphSpan as Q, type ResidentCaretPaintStyle as R, type YrsInputPositionMap as S, type YrsNumberingProperties as T, type YrsParaOffset as U, type YrsParagraph as V, type YrsParagraphAttrs as W, type YrsParagraphLength as X, type YrsSession as Y, type YrsParagraphReceipt as Z, type YrsParagraphSeed as _, type YrsRenderEnv as a, type YrsParagraphTabStop as a0, type YrsRawOp as a1, type YrsResidentCaretRect as a2, type YrsResidentCaretSnapshot as a3, type YrsResidentWorkerSnapshot as a4, type YrsResidentWorkerSyncOptions as a5, type YrsResolveReceipt as a6, type YrsResolvedCommentAnchor as a7, type YrsRevisionReceipt as a8, type YrsRunMark as a9, type YrsSelectionContext as aa, type YrsSplitReceipt as ab, type YrsStickyPosition as ac, type YrsStoryRange as ad, type YrsStorySeed as ae, type YrsStorySegment as af, type YrsTableLoc as ag, type YrsTableRange as ah, type YrsTableReceipt as ai, type YrsTextColor as aj, type YrsTriState as ak, type YrsWatermark as al, canUseResidentEngineWorker as am, compareYrsLocs as an, createYrsInputPositionMap as ao, createYrsSession as ap, displayPositionToYrsLoc as aq, documentToYrs as ar, residentCaretDeviceRect as as, residentCaretSnapshotForFrame as at, sameYrsSelection as au, yrsLocToDisplayPosition as av, yrsToDocument as aw, type CollaborationTransport as b, 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 YrsRevisionInfo as v, type CreateYrsSessionOptions as w, type ResidentEngineOffscreenPage as x, type ResidentEngineWorkerApplyResult as y, ResidentEngineWorkerClient as z };
|
package/dist/layout/index.d.mts
CHANGED
|
@@ -1,15 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { B as BundledFontProvider } from '../rustMeasureSource-C0EZB055.mjs';
|
|
2
|
+
export { a as BundledFontProviderSource, E as EmbeddedFaceInput, F as FontScript, b as ResidentFontRequirement, R as ResidentMeasurementConfig, c as RustMeasureSource, d as RustTextEngine, e as createRustMeasureSource, g as getRustTextEngine } from '../rustMeasureSource-C0EZB055.mjs';
|
|
3
|
+
import { f as SectionProperties, H as HeaderFooter } from '../content-CvEtPl0c.mjs';
|
|
4
|
+
export { D as DrawingScene, V as DrawingSceneNode, b as ShapeEffect, aX as ShapeFillPaint, aY as ShapeStrokePaint, c as ShapeTextBodyProperties } from '../content-CvEtPl0c.mjs';
|
|
4
5
|
import { Document } from '../types/document.mjs';
|
|
5
|
-
import
|
|
6
|
-
import '../formatting-BEkIBePP.mjs';
|
|
6
|
+
import '../formatting-7zKCTu5a.mjs';
|
|
7
7
|
import '../docx/wrapTypes.mjs';
|
|
8
|
-
import '../styles-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
import '../styles-7e-mq3c-.mjs';
|
|
9
|
+
|
|
10
|
+
/** Opt-in bundled-font provider resolution. @packageDocumentation */
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The slice of `@betteroffice/fonts` this module consumes. Structural on
|
|
14
|
+
* purpose: the engine never names that package, so no bundler ever has to
|
|
15
|
+
* resolve it.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
interface BundledFontModule {
|
|
20
|
+
createFontProvider(options?: {
|
|
21
|
+
baseUrl?: string | URL;
|
|
22
|
+
}): BundledFontProvider;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* How to obtain bundled fonts. Nothing is loaded until one of `fonts` or
|
|
26
|
+
* `load` is given — the engine never reaches for a font package on its own.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
interface DefaultFontOptions {
|
|
31
|
+
/** The imported `@betteroffice/fonts` module. */
|
|
32
|
+
fonts?: BundledFontModule;
|
|
33
|
+
/** Lazy alternative to {@link DefaultFontOptions.fonts}, resolving to the same module. */
|
|
34
|
+
load?: () => Promise<unknown>;
|
|
35
|
+
/** Fetch the faces from this base URL instead of the module's own assets. */
|
|
36
|
+
baseUrl?: string | URL;
|
|
37
|
+
}
|
|
38
|
+
/** Configure the default provider and reset its memoized resolution. @public */
|
|
39
|
+
declare function configureDefaultFonts(next: DefaultFontOptions): void;
|
|
40
|
+
/** Resolve the configured provider, or `undefined` when no font source is set. @public */
|
|
41
|
+
declare function resolveDefaultFontProvider(): Promise<BundledFontProvider | undefined>;
|
|
13
42
|
|
|
14
43
|
/**
|
|
15
44
|
* Selection-overlay geometry value types, shared by the canvas overlays and
|
|
@@ -59,8 +88,6 @@ declare function resolveHeaderFooter(document: Document | null, section: Section
|
|
|
59
88
|
firstHeader: HeaderFooter | null;
|
|
60
89
|
firstFooter: HeaderFooter | null;
|
|
61
90
|
};
|
|
62
|
-
declare function computeHfCaretRectsFromDisplayList(queries: DisplayListQueries, section: 'header' | 'footer', rId: string, position: number, pageIndex?: number): DisplayListRect[];
|
|
63
|
-
declare function computeHfSelectionRectsFromDisplayList(queries: DisplayListQueries, section: 'header' | 'footer', rId: string, from: number, to: number, pageIndex?: number): DisplayListRect[];
|
|
64
91
|
|
|
65
92
|
/** Coordinates selection paint with the latest completed layout sequence. */
|
|
66
93
|
declare class LayoutSelectionGate {
|
|
@@ -84,4 +111,4 @@ declare class LayoutSelectionGate {
|
|
|
84
111
|
};
|
|
85
112
|
}
|
|
86
113
|
|
|
87
|
-
export { type CaretPosition, DEFAULT_PAGE_HEIGHT_PX, LayoutSelectionGate, type SelectionRect,
|
|
114
|
+
export { type BundledFontModule, BundledFontProvider, type CaretPosition, DEFAULT_PAGE_HEIGHT_PX, type DefaultFontOptions, LayoutSelectionGate, type SelectionRect, configureDefaultFonts, resolveDefaultFontProvider, resolveHeaderFooter };
|
package/dist/layout/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {d,e,g as g$1,c,f,b as b$1}from'../chunk-TTRUPDAB.mjs';function x(o){return o.trim().toLowerCase()}function B(o,e,t){return `${x(o)}|${e?1:0}|${t?1:0}`}var I=class{constructor(e,t){b$1(this,"sink");b$1(this,"bundled");b$1(this,"facesByFamily",new Map);b$1(this,"faceIds",new WeakMap);b$1(this,"bundledIds",new Map);b$1(this,"lastResortIds",new Map);b$1(this,"bufferIds",new WeakMap);b$1(this,"scriptIds",new Map);b$1(this,"scriptResults",new Map);b$1(this,"chains",new Map);b$1(this,"chainResults",new Map);b$1(this,"generation",0);this.sink=e,this.bundled=t?.bundled;}setEmbeddedFaces(e){this.generation++,this.facesByFamily=new Map;for(let t of e){let n=x(t.family),r=this.facesByFamily.get(n);r?r.push(t):this.facesByFamily.set(n,[t]);}this.chains=new Map,this.chainResults=new Map;}getFontIdChain(e,t,n){let r=B(e,t,n),i=this.chains.get(r);return i||(i=this.resolveChain(r,e,t,n),this.chains.set(r,i)),i}getCachedFontIdChain(e,t,n){return this.chainResults.get(B(e,t,n))}getScriptFallbackIds(e){let t=[...new Set(e)];return Promise.all(t.map(n=>this.resolveScript(n))).then(n=>{let r=[];for(let i of n)i!==null&&!r.includes(i)&&r.push(i);return r})}getCachedScriptFallbackIds(e){let t=[];for(let n of e){if(!this.scriptResults.has(n))return;let r=this.scriptResults.get(n);r!==null&&!t.includes(r)&&t.push(r);}return t}clear(){this.generation++,this.faceIds=new WeakMap,this.bundledIds=new Map,this.lastResortIds=new Map,this.bufferIds=new WeakMap,this.scriptIds=new Map,this.scriptResults=new Map,this.chains=new Map,this.chainResults=new Map;}async resolveChain(e,t,n,r){let i=this.generation,s=[],a=this.pickEmbeddedFace(t,n,r);if(a){let l=await this.registerFace(a);l!==null&&s.push(l);}let f=this.bundled?.resolve(t,n,r);if(f){let l=await this.registerBundled(e,f,t);l!==null&&!s.includes(l)&&s.push(l);}let h=this.bundled?.resolveLastResort?.(t,n,r);if(h){let l=await this.registerLastResort(e,h,t);l!==null&&!s.includes(l)&&s.push(l);}return i===this.generation&&this.chainResults.set(e,s),s}pickEmbeddedFace(e,t,n){let r=this.facesByFamily.get(x(e));if(!r)return;let i=t?"bold":"normal",s=n?"italic":"normal";return r.find(a=>a.weight===i&&a.style===s)??r.find(a=>a.weight==="normal"&&a.style==="normal")}registerBuffer(e){let t=this.bufferIds.get(e);return t||(t=Promise.resolve().then(()=>this.sink.registerFont(new Uint8Array(e))),t.catch(()=>{}),this.bufferIds.set(e,t)),t}registerFace(e){let t=this.faceIds.get(e);return t||(t=(async()=>{try{return await this.registerBuffer(e.data)}catch{return console.warn(`[fontRegistry] embedded face "${e.family}" (${e.weight} ${e.style}) was rejected by the text engine; falling back`),null}})(),this.faceIds.set(e,t)),t}registerBundled(e,t,n){let r=this.bundledIds.get(e);return r||(r=(async()=>{try{let i=await t();return await this.registerBuffer(i)}catch{return console.warn(`[fontRegistry] bundled face for "${n}" failed to load or register; falling back`),null}})(),this.bundledIds.set(e,r)),r}registerLastResort(e,t,n){let r=this.lastResortIds.get(e);return r||(r=(async()=>{try{let i=await t();return await this.registerBuffer(i)}catch{return console.warn(`[fontRegistry] last-resort base face for "${n}" failed to load or register; falling back`),null}})(),this.lastResortIds.set(e,r)),r}resolveScript(e){let t=this.scriptIds.get(e);if(!t){let n=this.scriptResults;t=(async()=>{let r=null,i=this.bundled?.resolveScriptFallback?.(e,false,false);if(i)try{let s=await i();r=await this.registerBuffer(s);}catch{console.warn(`[fontRegistry] script-fallback face for "${e}" failed to load or register; falling back`);}return n.set(e,r),r})(),this.scriptIds.set(e,t);}return t}};var L=null;function T(){return L??(L=import('../wasm-JE7B3ROD.mjs').then(async o=>(await o.preloadLayoutWasm(),{registerFont:o.registerMeasureFont,clearFonts:o.clearMeasureFonts}))),L}function H(o){let e=new I({registerFont:n=>o.engine.registerFont(n)},{bundled:o.bundled}),t;return {setEmbeddedFaces(n){e.setEmbeddedFaces(n);},setCompat(n){t=n;},async prepareFontRequirements(n){return (await Promise.all(n.flatMap(i=>[(async()=>{try{return e.getCachedFontIdChain(i.family,i.bold,i.italic)!==void 0?!1:(await e.getFontIdChain(i.family,i.bold,i.italic),!0)}catch{return false}})(),...Array.from(new Set(i.scripts??[]),async s=>{try{return e.getCachedScriptFallbackIds([s])!==void 0?!1:(await e.getScriptFallbackIds([s]),!0)}catch{return false}})]))).some(Boolean)},measurementConfigForRequirements(n){let r={};for(let i of n){let s=e.getCachedFontIdChain(i.family,i.bold,i.italic),a=e.getCachedScriptFallbackIds(i.scripts??[]);if(s===void 0||a===void 0)return;let f=Array.from(s);for(let h of a)f.includes(h)||f.push(h);f.length>0&&(r[i.key]=f);}return {fontChains:r,defaults:{fontSize:11,fontFamily:"Calibri"},compat:{noLeading:t?.noLeading??false,doNotExpandShiftReturn:t?.doNotExpandShiftReturn??false},authoritativeShaping:true}},clear(){e.clear();}}}var q=1056;function A(o,e){let t=o?.package.headers,n=o?.package.footers,r=e?.headerReferences?.find(y=>y.type==="default"),i=e?.headerReferences?.find(y=>y.type==="first"),s=e?.footerReferences?.find(y=>y.type==="default"),a=e?.footerReferences?.find(y=>y.type==="first"),f=r?t?.get(r.rId)??null:null,h=s?n?.get(s.rId)??null:null,l=i?t?.get(i.rId)??null:null,k=a?n?.get(a.rId)??null:null;return e?.titlePg||(f??(f=l),h??(h=k)),{header:f,footer:h,firstHeader:l,firstFooter:k}}function D(o,e,t,n,r){let i=o.hfCaretRects(e,t,n);return r===void 0?i:i.filter(s=>s.pageIndex===r)}function $(o,e,t,n,r,i){let s=o.hfRangeRects(e,t,Math.min(n,r),Math.max(n,r));return i===void 0?s:s.filter(a=>a.pageIndex===i)}var p,m,g,b,R,w,E,C=class{constructor(){d(this,w);d(this,p,0);d(this,m,0);d(this,g,false);d(this,b,false);d(this,R,new Set);}setStateSeq(e$1){e(this,p,e$1);}incrementStateSeq(){return ++g$1(this,p)._}getStateSeq(){return c(this,p)}getRenderSeq(){return c(this,m)}onLayoutStart(){e(this,g,true);}onLayoutComplete(e$1){e(this,m,e$1),e(this,g,false),c(this,b)&&this.isSafeToRender()&&(e(this,b,false),f(this,w,E).call(this));}isSafeToRender(){return !c(this,g)&&c(this,m)>=c(this,p)}requestRender(){this.isSafeToRender()?f(this,w,E).call(this):e(this,b,true);}onRender(e){return c(this,R).add(e),()=>c(this,R).delete(e)}reset(){e(this,p,0),e(this,m,0),e(this,g,false),e(this,b,false);}getDebugInfo(){return {stateSeq:c(this,p),renderSeq:c(this,m),layoutUpdating:c(this,g),hasPendingRender:c(this,b),isSafe:this.isSafeToRender()}}};p=new WeakMap,m=new WeakMap,g=new WeakMap,b=new WeakMap,R=new WeakMap,w=new WeakSet,E=function(){for(let e of c(this,R))try{e();}catch(t){console.error("LayoutSelectionGate: render callback error",t);}};export{q as DEFAULT_PAGE_HEIGHT_PX,C as LayoutSelectionGate,D as computeHfCaretRectsFromDisplayList,$ as computeHfSelectionRectsFromDisplayList,H as createRustMeasureSource,T as getRustTextEngine,A as resolveHeaderFooter};
|
|
1
|
+
import {d,e,g as g$1,c,f,b as b$1}from'../chunk-TTRUPDAB.mjs';var I={},R;function q(s){if(s===void 0)return;let e=typeof s=="string"?s:s.href,t=typeof location>"u"?void 0:location.href;try{return new URL(e,t)}catch{throw new TypeError(`configureDefaultFonts baseUrl must be absolute when no browser location exists: ${e}`)}}function U(){return I.fonts!==void 0||I.load!==void 0}function H(s){I={...s,baseUrl:q(s.baseUrl)},R=void 0,I.baseUrl!==void 0&&!U()&&console.warn("[configureDefaultFonts] a baseUrl on its own loads nothing \u2014 the face manifest lives in @betteroffice/fonts. Pass the module too: configureDefaultFonts({ fonts, baseUrl }).");}async function K(){let{baseUrl:s,fonts:e,load:t}=I;try{return (e??await t()).createFontProvider(s===void 0?void 0:{baseUrl:s})}catch(r){console.warn("[configureDefaultFonts] the configured font source failed to load",r);return}}function M(){if(!U())return Promise.resolve(void 0);if(R===void 0){let s=K();s.then(e=>{e===void 0&&R===s&&(R=void 0);}),R=s;}return R}function $(s){return s.trim().toLowerCase()}function C(s,e,t){return `${$(s)}|${e?1:0}|${t?1:0}`}function k(s,e,t,r){t.then(o=>{r(o)&&s.get(e)===t&&s.delete(e);},()=>{s.get(e)===t&&s.delete(e);});}var x=class{constructor(e,t){b$1(this,"sink");b$1(this,"bundledSource");b$1(this,"bundledPromise");b$1(this,"warnedFallback",false);b$1(this,"facesByFamily",new Map);b$1(this,"faceIds",new WeakMap);b$1(this,"bundledIds",new Map);b$1(this,"lastResortIds",new Map);b$1(this,"bufferIds",new WeakMap);b$1(this,"scriptIds",new Map);b$1(this,"scriptResults",new Map);b$1(this,"chains",new Map);b$1(this,"chainResults",new Map);b$1(this,"generation",0);this.sink=e,this.bundledSource=t?.bundled;}bundled(){if(this.bundledPromise===void 0){let e=this.bundledSource,t=Promise.resolve().then(()=>typeof e=="function"?e():e).catch(()=>{});t.then(r=>{r===void 0&&this.bundledPromise===t&&(this.bundledPromise=void 0);}),this.bundledPromise=t;}return this.bundledPromise}setEmbeddedFaces(e){this.generation++,this.facesByFamily=new Map;for(let t of e){let r=$(t.family),o=this.facesByFamily.get(r);o?o.push(t):this.facesByFamily.set(r,[t]);}this.chains=new Map,this.chainResults=new Map;}getFontIdChain(e,t,r){let o=C(e,t,r),i=this.chains.get(o);if(!i){let n=this.chains,a=this.chainResults,f=this.generation,u=this.resolveChain(e,t,r);u.then(d=>{f===this.generation&&(a.set(o,d),d.retryable&&n.get(o)===u&&n.delete(o));},()=>{n.get(o)===u&&n.delete(o);}),n.set(o,u),i=u;}return i.then(n=>n.ids)}getCachedFontIdChain(e,t,r,o=true){let i=C(e,t,r),n=this.chainResults.get(i);if(o&&n?.retryable){let a=this.chainResults;queueMicrotask(()=>{a.get(i)===n&&a.delete(i);});}return n?.ids}getScriptFallbackIds(e){let t=[...new Set(e)];return Promise.all(t.map(r=>this.resolveScript(r))).then(r=>{let o=[];for(let{id:i}of r)i!==null&&!o.includes(i)&&o.push(i);return o})}getCachedScriptFallbackIds(e,t=true){let r=this.scriptResults,o=[];for(let n of e){let a=r.get(n);if(!a)return;o.push([n,a]);}let i=[];for(let[n,a]of o){let{id:f}=a;f!==null&&!i.includes(f)&&i.push(f),t&&a.retryable&&queueMicrotask(()=>{r.get(n)===a&&r.delete(n);});}return i}clear(){this.generation++,this.bundledPromise=void 0,this.faceIds=new WeakMap,this.bundledIds=new Map,this.lastResortIds=new Map,this.bufferIds=new WeakMap,this.scriptIds=new Map,this.scriptResults=new Map,this.chains=new Map,this.chainResults=new Map;}async resolveChain(e,t,r){let o=C(e,t,r),i=[],n=false,a=this.pickEmbeddedFace(e,t,r);if(a){let l=await this.registerFace(a);l!==null?i.push(l):n=true;}let f=await this.bundled();f===void 0&&typeof this.bundledSource=="function"&&(n=true);let u;try{u=f?.resolve(e,t,r);}catch(l){n=true,console.warn(`[fontRegistry] bundled face resolver for "${e}" failed; falling back: ${l instanceof Error?l.message:String(l)}`);}if(u){let l=await this.registerBundled(o,u,e);l!==null&&!i.includes(l)&&i.push(l),l===null&&(n=true);}let d;try{d=f?.resolveLastResort?.(e,t,r);}catch(l){n=true,console.warn(`[fontRegistry] last-resort resolver for "${e}" failed; falling back: ${l instanceof Error?l.message:String(l)}`);}if(d){let l=await this.registerLastResort(o,d,e);l!==null&&!i.includes(l)&&i.push(l),l===null&&(n=true);}return i.length===0&&this.warnFallback(e,f!==void 0,u!==void 0||d!==void 0),{ids:i,retryable:n}}warnFallback(e,t,r){if(this.warnedFallback)return;this.warnedFallback=true;let o="Native measurement is unsupported; browser hosts fall back to measureText and may use different OS fonts, so pagination can vary. Reported once per registry.";console.warn(r?`[fontRegistry] no font bytes for "${e}" \u2014 the font provider resolved but every matching face failed to load. ${o} If a bundler inlined @betteroffice/fonts, mark it external so its asset URLs resolve.`:t?`[fontRegistry] no font bytes for "${e}" \u2014 the configured font provider has no matching face. Add coverage for this family. ${o}`:`[fontRegistry] no font bytes for "${e}" \u2014 no font provider is configured. Install @betteroffice/fonts and pass it with configureDefaultFonts({ fonts }). `+o);}pickEmbeddedFace(e,t,r){let o=this.facesByFamily.get($(e));if(!o)return;let i=t?"bold":"normal",n=r?"italic":"normal";return o.find(a=>a.weight===i&&a.style===n)??o.find(a=>a.weight==="normal"&&a.style==="normal")}registerBuffer(e){let t=this.bufferIds.get(e);if(!t){let r=this.bufferIds;t=Promise.resolve().then(()=>this.sink.registerFont(new Uint8Array(e))),k(r,e,t,()=>false),r.set(e,t);}return t}registerFace(e){let t=this.faceIds.get(e);if(!t){let r=this.faceIds;t=(async()=>{try{return await this.registerBuffer(e.data)}catch{return console.warn(`[fontRegistry] embedded face "${e.family}" (${e.weight} ${e.style}) was rejected by the text engine; falling back`),null}})(),k(r,e,t,o=>o===null),r.set(e,t);}return t}registerBundled(e,t,r){let o=this.bundledIds.get(e);if(!o){let i=this.bundledIds;o=(async()=>{try{let n=await t();return await this.registerBuffer(n)}catch(n){return console.warn(`[fontRegistry] bundled face for "${r}" failed to load or register; falling back: ${n instanceof Error?n.message:String(n)}`),null}})(),k(i,e,o,n=>n===null),i.set(e,o);}return o}registerLastResort(e,t,r){let o=this.lastResortIds.get(e);if(!o){let i=this.lastResortIds;o=(async()=>{try{let n=await t();return await this.registerBuffer(n)}catch{return console.warn(`[fontRegistry] last-resort base face for "${r}" failed to load or register; falling back`),null}})(),k(i,e,o,n=>n===null),i.set(e,o);}return o}resolveScript(e){let t=this.scriptIds.get(e);if(!t){let r=this.scriptIds,o=this.scriptResults;t=(async()=>{let i=null,n=false,a=await this.bundled();a===void 0&&typeof this.bundledSource=="function"&&(n=true);let f;try{f=a?.resolveScriptFallback?.(e,!1,!1);}catch(d){n=true,console.warn(`[fontRegistry] script-fallback resolver for "${e}" failed; falling back: ${d instanceof Error?d.message:String(d)}`);}if(f)try{let d=await f();i=await this.registerBuffer(d);}catch(d){n=true,console.warn(`[fontRegistry] script-fallback face for "${e}" failed to load or register; falling back: ${d instanceof Error?d.message:String(d)}`);}let u={id:i,retryable:n};return o.set(e,u),u})(),k(r,e,t,i=>i.retryable),r.set(e,t);}return t}};var L=null;function j(){return L??(L=import('../wasm-ZQAVP7P2.mjs').then(async s=>(await s.preloadLayoutWasm(),{registerFont:s.registerMeasureFont,clearFonts:s.clearMeasureFonts}))),L}function V(s){let e=new x({registerFont:r=>s.engine.registerFont(r)},{bundled:s.bundled??M}),t;return {setEmbeddedFaces(r){e.setEmbeddedFaces(r);},setCompat(r){t=r;},async prepareFontRequirements(r){return (await Promise.all(r.flatMap(i=>[(async()=>{try{return e.getCachedFontIdChain(i.family,i.bold,i.italic,!1)!==void 0?!1:(await e.getFontIdChain(i.family,i.bold,i.italic),!0)}catch{return false}})(),...Array.from(new Set(i.scripts??[]),async n=>{try{return e.getCachedScriptFallbackIds([n],!1)!==void 0?!1:(await e.getScriptFallbackIds([n]),!0)}catch{return false}})]))).some(Boolean)},measurementConfigForRequirements(r){let o=r.map(n=>({requirement:n,familyIds:e.getCachedFontIdChain(n.family,n.bold,n.italic,false),scriptIds:e.getCachedScriptFallbackIds(n.scripts??[],false)}));if(o.some(({familyIds:n,scriptIds:a})=>n===void 0||a===void 0))return;let i={};for(let{requirement:n}of o){let a=e.getCachedFontIdChain(n.family,n.bold,n.italic),f=e.getCachedScriptFallbackIds(n.scripts??[]);if(a===void 0||f===void 0)return;let u=Array.from(a);for(let d of f)u.includes(d)||u.push(d);u.length>0&&(i[n.key]=u);}return {fontChains:i,defaults:{fontSize:11,fontFamily:"Calibri"},compat:{noLeading:t?.noLeading??false,doNotExpandShiftReturn:t?.doNotExpandShiftReturn??false},authoritativeShaping:true}},clear(){e.clear();}}}var _=1056;function G(s,e){let t=s?.package.headers,r=s?.package.footers,o=e?.headerReferences?.find(F=>F.type==="default"),i=e?.headerReferences?.find(F=>F.type==="first"),n=e?.footerReferences?.find(F=>F.type==="default"),a=e?.footerReferences?.find(F=>F.type==="first"),f=o?t?.get(o.rId)??null:null,u=n?r?.get(n.rId)??null:null,d=i?t?.get(i.rId)??null:null,l=a?r?.get(a.rId)??null:null;return e?.titlePg||(f??(f=d),u??(u=l)),{header:f,footer:u,firstHeader:d,firstFooter:l}}var g,b,m,y,w,B,T,A=class{constructor(){d(this,B);d(this,g,0);d(this,b,0);d(this,m,false);d(this,y,false);d(this,w,new Set);}setStateSeq(e$1){e(this,g,e$1);}incrementStateSeq(){return ++g$1(this,g)._}getStateSeq(){return c(this,g)}getRenderSeq(){return c(this,b)}onLayoutStart(){e(this,m,true);}onLayoutComplete(e$1){e(this,b,e$1),e(this,m,false),c(this,y)&&this.isSafeToRender()&&(e(this,y,false),f(this,B,T).call(this));}isSafeToRender(){return !c(this,m)&&c(this,b)>=c(this,g)}requestRender(){this.isSafeToRender()?f(this,B,T).call(this):e(this,y,true);}onRender(e){return c(this,w).add(e),()=>c(this,w).delete(e)}reset(){e(this,g,0),e(this,b,0),e(this,m,false),e(this,y,false);}getDebugInfo(){return {stateSeq:c(this,g),renderSeq:c(this,b),layoutUpdating:c(this,m),hasPendingRender:c(this,y),isSafe:this.isSafeToRender()}}};g=new WeakMap,b=new WeakMap,m=new WeakMap,y=new WeakMap,w=new WeakMap,B=new WeakSet,T=function(){for(let e of c(this,w))try{e();}catch(t){console.error("LayoutSelectionGate: render callback error",t);}};export{_ as DEFAULT_PAGE_HEIGHT_PX,A as LayoutSelectionGate,H as configureDefaultFonts,V as createRustMeasureSource,j as getRustTextEngine,M as resolveDefaultFontProvider,G as resolveHeaderFooter};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as AnchoredObjectPositionInput, d as BlockId, e as BorderStyle, C as CellBorderSpec, f as CellBorders, g as ChartBlock, h as ChartExtent, i as ChartFragment, j as ColumnBreakBlock, k as ColumnBreakExtent, l as ColumnLayout, D as DEFAULT_TEXTBOX_MARGINS, m as DEFAULT_TEXTBOX_WIDTH, n as DocumentPosition, o as FieldRun, p as FloatingTablePosition, F as FootnoteContent, q as FootnoteRenderItem, r as Fragment, s as FragmentBase, H as HeaderFooterContent, t as HeaderFooterContentHeights, u as HeaderFooterLayout, v as HitTestResult, w as HyperlinkInfo, I as ImageBlock, x as ImageExtent, y as ImageFragment, z as ImageRun, E as ImageRunPosition, G as InlineSdtWidget,
|
|
3
|
-
import '../../content-
|
|
4
|
-
import '../../formatting-
|
|
1
|
+
import { b as LayoutBlock, B as BlockExtent } from '../../types-C4A8mWjU.mjs';
|
|
2
|
+
export { A as AnchoredObjectPositionInput, d as BlockId, e as BorderStyle, C as CellBorderSpec, f as CellBorders, g as ChartBlock, h as ChartExtent, i as ChartFragment, j as ColumnBreakBlock, k as ColumnBreakExtent, l as ColumnLayout, D as DEFAULT_TEXTBOX_MARGINS, m as DEFAULT_TEXTBOX_WIDTH, n as DocumentPosition, o as FieldRun, p as FloatingTablePosition, F as FootnoteContent, q as FootnoteRenderItem, r as Fragment, s as FragmentBase, H as HeaderFooterContent, t as HeaderFooterContentHeights, u as HeaderFooterLayout, v as HitTestResult, w as HyperlinkInfo, I as ImageBlock, x as ImageExtent, y as ImageFragment, z as ImageRun, E as ImageRunPosition, G as InlineSdtWidget, L as Layout, a as LayoutOptions, J as LineBreakRun, K as ListNumPr, N as NoteAreaContract, M as NoteLayoutItem, O as NoteSettingsContract, P as Page, Q as PageBorderContract, S as PageBreakBlock, T as PageBreakExtent, U as PageGeometry, V as PageHeaderFooterRefs, W as PageMargins, X as PageNumberingContract, Y as ParagraphAttrs, Z as ParagraphBlock, _ as ParagraphBorders, $ as ParagraphExtent, a0 as ParagraphFragment, a1 as ParagraphIndent, a2 as ParagraphSpacing, R as ResolvedLine, c as ResolvedSegment, a3 as Run, a4 as RunFontSlots, a5 as RunFormatting, a6 as RunLanguageSlots, a7 as SdtGroup, a8 as SectionBreakBlock, a9 as SectionBreakExtent, aa as ShapeBlock, ab as ShapeBlockFill, ac as ShapeBlockStroke, ad as ShapeBlockTransform, ae as ShapeExtent, af as ShapeFragment, ag as TabAlignment, ah as TabRun, ai as TabStop, aj as TableBlock, ak as TableCell, al as TableCellExtent, am as TableExtent, an as TableFragment, ao as TableRow, ap as TableRowExtent, aq as TextBoxBlock, ar as TextBoxExtent, as as TextBoxFragment, at as TextRun, au as TypesetBidiSlice, av as TypesetClusterAdvance, aw as TypesetRow, ax as TypesetRowSegment, ay as TypesetRunAdvance, az as WrapTextDirection, aA as assertExhaustiveLayoutBlock, aB as isTextWrappingFloatingImageRun, aC as pageGeometryFromPage, aD as resolveAnchoredObjectVerticalTop } from '../../types-C4A8mWjU.mjs';
|
|
3
|
+
import '../../content-CvEtPl0c.mjs';
|
|
4
|
+
import '../../formatting-7zKCTu5a.mjs';
|
|
5
5
|
import '../../docx/wrapTypes.mjs';
|
|
6
6
|
|
|
7
7
|
interface MeasuredBlock {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {b as b$2,c as c$1}from'../../chunk-OBQGPMPQ.mjs';import {b as b$1}from'../../chunk-CTBUQRYQ.mjs';import'../../chunk-TTRUPDAB.mjs';var c={top:4,bottom:4,left:7,right:7},h=200;function y(e,r){let o=e.kind??"<unknown>";throw new Error(`${r}: unhandled LayoutBlock kind "${o}". Add the case alongside the other LayoutBlock switches (see types.ts).`)}function
|
|
1
|
+
import {b as b$2,c as c$1}from'../../chunk-OBQGPMPQ.mjs';import {b as b$1}from'../../chunk-CTBUQRYQ.mjs';import'../../chunk-TTRUPDAB.mjs';var c={top:4,bottom:4,left:7,right:7},h=200;function y(e,r){let o=e.kind??"<unknown>";throw new Error(`${r}: unhandled LayoutBlock kind "${o}". Add the case alongside the other LayoutBlock switches (see types.ts).`)}function f(e){return {pageWidth:e.size.w,pageHeight:e.size.h,marginLeft:e.margins.left,marginTop:e.margins.top,contentWidth:e.size.w-e.margins.left-e.margins.right,contentHeight:e.size.h-e.margins.top-e.margins.bottom}}function x(e,r,o){return p(e,r,o)}function p(e,r,o){let n=e.position?.vertical;if(!n)return r;let t=b(n.relativeTo,r,o);return n.align==="top"?t.base:n.align==="center"?t.size?t.base+(t.size-e.height)/2:r:n.align==="bottom"?t.size?t.base+t.size-e.height:r:n.posOffset!==void 0?t.base+b$1(n.posOffset):n.relativeTo==="paragraph"||n.relativeTo==="line"?r:t.base}function b(e,r,o){let n=o?.pageHeight??0,t=o?.marginTop??0,a=o?.contentHeight??0;switch(e){case "paragraph":case "line":return {base:r,size:0};case "page":return {base:-t,size:n};case "topMargin":return {base:-t,size:t};case "bottomMargin":return {base:a,size:t};default:return {base:0,size:a}}}function k(e){return b$2(e.wrapType)||e.wrapType==="topAndBottom"?false:c$1(e.wrapType)?true:e.displayMode==="float"&&e.cssFloat!=="none"}export{c as DEFAULT_TEXTBOX_MARGINS,h as DEFAULT_TEXTBOX_WIDTH,y as assertExhaustiveLayoutBlock,k as isTextWrappingFloatingImageRun,f as pageGeometryFromPage,x as resolveAnchoredObjectVerticalTop};
|