@betteroffice/docx 0.0.3 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/README.md +22 -8
  2. package/dist/chunk-24DL53QL.mjs +1 -0
  3. package/dist/chunk-5F6DLQZP.mjs +1 -0
  4. package/dist/chunk-BUZ2X5CT.mjs +16 -0
  5. package/dist/chunk-CTBUQRYQ.mjs +1 -0
  6. package/dist/{chunk-B4IR6YP4.mjs → chunk-GHEHBYQK.mjs} +1 -1
  7. package/dist/{chunk-NJHOPXZW.mjs → chunk-HLDJMU3R.mjs} +1 -1
  8. package/dist/chunk-HTDNSQ44.mjs +1 -0
  9. package/dist/{chunk-IFT6DUJX.mjs → chunk-LTVVQMHB.mjs} +1 -1
  10. package/dist/chunk-PI2I3TO5.mjs +57 -0
  11. package/dist/chunk-TMHG7OAZ.mjs +1 -0
  12. package/dist/chunk-VRGUAKOC.mjs +1 -0
  13. package/dist/collaboration/index.d.mts +32 -8
  14. package/dist/collaboration/index.mjs +1 -1
  15. package/dist/{content-MOZ6hKP4.d.mts → content-DrqzbIr7.d.mts} +582 -666
  16. package/dist/core.d.mts +7 -7
  17. package/dist/core.mjs +1 -1
  18. package/dist/{displayListQueries-BJlo7Jkz.d.mts → displayListQueries-DGDR-OWc.d.mts} +98 -50
  19. package/dist/docx/index.d.mts +5 -5
  20. package/dist/docx/index.mjs +1 -1
  21. package/dist/editor/index.d.mts +8 -8
  22. package/dist/{fontLoader-aSewHMKF.d.mts → fontLoader-DnixuYST.d.mts} +127 -2
  23. package/dist/{formatting-D1EPSaJP.d.mts → formatting-BqrFPeev.d.mts} +85 -203
  24. package/dist/{frameDelta-D965X8yK.d.mts → frameDelta-DMgR8n13.d.mts} +17 -10
  25. package/dist/generated/edit/docx_edit_bg.wasm +0 -0
  26. package/dist/generated/layout/docx_layout_bg.wasm +0 -0
  27. package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
  28. package/dist/generated/parse/docx_parse_bg.wasm +0 -0
  29. package/dist/{index-Dx4Z3lkz.d.mts → index-ImoMd0Ju.d.mts} +97 -67
  30. package/dist/layout/index.d.mts +40 -12
  31. package/dist/layout/index.mjs +1 -1
  32. package/dist/layout/pagination/index.d.mts +4 -4
  33. package/dist/layout/pagination/index.mjs +1 -1
  34. package/dist/layout/render/index.d.mts +33 -77
  35. package/dist/layout/render/index.mjs +1 -1
  36. package/dist/plugin-api/RenderedDomContext.d.mts +7 -7
  37. package/dist/plugin-api/index.d.mts +3 -3
  38. package/dist/plugin-api/resolveItemPositions.d.mts +3 -3
  39. package/dist/{rustDisplayList-BRuZBqdL.d.mts → rustDisplayList-B9dQoLHI.d.mts} +79 -50
  40. package/dist/{rustMeasureSource-D1KsQvVC.d.mts → rustMeasureSource-C0EZB055.d.mts} +5 -2
  41. package/dist/{selectiveSave-CVoajSKE.d.mts → selectiveSave-CRh-_Y_C.d.mts} +3 -3
  42. package/dist/styles/index.d.mts +3 -3
  43. package/dist/{styles-Dn_o3Vo5.d.mts → styles-CMybYYHS.d.mts} +1 -1
  44. package/dist/types/content.d.mts +2 -2
  45. package/dist/types/document.d.mts +7 -7
  46. package/dist/{types-BfqUl2h_.d.mts → types-CXLxVF1t.d.mts} +27 -23
  47. package/dist/utils/comments.d.mts +2 -2
  48. package/dist/utils/index.d.mts +11 -13
  49. package/dist/utils/index.mjs +1 -1
  50. package/dist/utils/stylePreview.d.mts +2 -2
  51. package/dist/utils/units.d.mts +4 -34
  52. package/dist/utils/units.mjs +1 -1
  53. package/dist/wasm-CJHQHBDE.mjs +1 -0
  54. package/dist/wasm-T2CRCO7S.mjs +1 -0
  55. package/dist/wasm-edit.d.mts +524 -168
  56. package/dist/wasm-edit.mjs +1 -1
  57. package/dist/wasm-layout.d.mts +35 -28
  58. package/dist/wasm-layout.mjs +1 -1
  59. package/dist/wasm-opc.mjs +1 -1
  60. package/dist/wasm-parse.mjs +1 -1
  61. package/dist/yrs/index.d.mts +6 -6
  62. package/dist/yrs/index.mjs +1 -1
  63. package/dist/yrs/residentEngineWorker.mjs +1 -1
  64. package/package.json +19 -3
  65. package/dist/chunk-3UBMCDME.mjs +0 -1
  66. package/dist/chunk-AEQOEQJ7.mjs +0 -57
  67. package/dist/chunk-AZ52IWB6.mjs +0 -16
  68. package/dist/chunk-GGEGIQRK.mjs +0 -1
  69. package/dist/chunk-T4EZMUXM.mjs +0 -1
  70. package/dist/chunk-WON6K4FY.mjs +0 -1
  71. package/dist/chunk-Y7RUNRU2.mjs +0 -1
  72. package/dist/wasm-DO3BUV7C.mjs +0 -1
  73. package/dist/wasm-NWXX4H5G.mjs +0 -1
@@ -1,5 +1,5 @@
1
- import { R as RetainedFrame } from './frameDelta-D965X8yK.mjs';
2
1
  import { Document } from './types/document.mjs';
2
+ import { R as RetainedFrame } from './frameDelta-DMgR8n13.mjs';
3
3
 
4
4
  type CollaborationUpdateOrigin = 'local' | 'remote';
5
5
  interface CollaborationReplica {
@@ -46,6 +46,43 @@ interface CollaborationProviderOptions {
46
46
  maxFrameBytes?: number;
47
47
  maxMessagesPerFrame?: number;
48
48
  maxPendingBytes?: number;
49
+ user?: CollaborationUser;
50
+ }
51
+ interface CollaborationUser {
52
+ name: string;
53
+ color?: string;
54
+ }
55
+ interface CollaborationResolvedUser {
56
+ name: string;
57
+ color: string;
58
+ }
59
+ interface CollaborationCursor {
60
+ story: string;
61
+ anchor: Uint8Array;
62
+ head: Uint8Array;
63
+ }
64
+ interface CollaborationTextInsertion {
65
+ clientId: number;
66
+ story: string;
67
+ paraId: string;
68
+ endOffset: number;
69
+ }
70
+ interface CollaborationAwarenessState {
71
+ clientId: number;
72
+ clock: number;
73
+ user: CollaborationResolvedUser;
74
+ cursor: CollaborationCursor | null;
75
+ }
76
+ interface CollaborationPeer extends CollaborationAwarenessState {
77
+ lastSeenAt: number;
78
+ cursorMovedAt: number;
79
+ inferredCursor: CollaborationTextInsertion | null;
80
+ }
81
+ type CollaborationPeerListener = (peers: readonly CollaborationPeer[]) => void;
82
+ interface CollaborationPresence {
83
+ readonly peers: readonly CollaborationPeer[];
84
+ setCursor(cursor: CollaborationCursor | null, broadcast?: boolean): void;
85
+ onPeers(listener: CollaborationPeerListener): () => void;
49
86
  }
50
87
  type CollaborationStatusListener = (change: CollaborationStatusChange) => void;
51
88
  type CollaborationErrorListener = (error: CollaborationError) => void;
@@ -158,15 +195,7 @@ declare class ResidentEngineWorkerClient {
158
195
  }
159
196
  declare function canUseResidentEngineWorker(): boolean;
160
197
 
161
- /**
162
- * Direct Document -> yrs load projection.
163
- *
164
- * This is the Document-model twin of the coexistence seed path. It emits the
165
- * same flat story vocabulary as `seedFromPm`, but never constructs a
166
- * ProseMirror node: text becomes attributed Y.Text, paragraphs become pilcrow
167
- * embeds, tables/block SDTs become structural embeds with child stories, and
168
- * comments become root-story side-map entries.
169
- */
198
+ /** Direct Document-to-yrs load projection. */
170
199
 
171
200
  /**
172
201
  * Seeds every yrs-owned editable story directly from a parsed Document.
@@ -179,14 +208,7 @@ declare function canUseResidentEngineWorker(): boolean;
179
208
  */
180
209
  declare function documentToYrs(session: YrsSession, document: Document): void;
181
210
 
182
- /**
183
- * yrs -> OOXML Document save projection.
184
- *
185
- * The yrs coexistence model stores each editable container as a flat story:
186
- * text carries inline formatting attributes, pilcrows carry paragraph
187
- * properties, and structural/inline atoms are map embeds. This module reads
188
- * that representation directly and rebuilds the serializer-facing Document.
189
- */
211
+ /** yrs-to-OOXML save projection. */
190
212
 
191
213
  /**
192
214
  * Rebuild all yrs-owned editable stories into the serializer-facing Document
@@ -217,6 +239,12 @@ declare function yrsToDocument(session: YrsSession, base: Document, options?: Yr
217
239
  * from its offset space). Story-global indices never cross this boundary.
218
240
  */
219
241
 
242
+ interface YrsDocxHost {
243
+ document: Document;
244
+ referencedFonts: string[];
245
+ embeddedFonts: Map<string, ArrayBuffer>;
246
+ fontTableRelationshipsXml?: string;
247
+ }
220
248
  /** Durable authorship metadata for one suggested (tracked-change) operation. */
221
249
  interface YrsAuthor {
222
250
  name: string;
@@ -229,6 +257,11 @@ interface YrsLoc {
229
257
  paraId: string;
230
258
  offset: number;
231
259
  }
260
+ /** One binary Yrs position that transforms with collaborative edits. */
261
+ interface YrsStickyPosition {
262
+ story: string;
263
+ encoded: Uint8Array;
264
+ }
232
265
  /** A paragraph-addressed position without the story (used inside {@link YrsStoryRange}). */
233
266
  interface YrsParaOffset {
234
267
  paraId: string;
@@ -463,8 +496,8 @@ interface YrsRevisionReceipt {
463
496
  revisionId: string | null;
464
497
  }
465
498
  /**
466
- * Receipt of {@link YrsSession.splitParagraph}. Under the S1 split the FIRST
467
- * half keeps the original paraId and the SECOND half is re-minted; suggesting
499
+ * Receipt of {@link YrsSession.splitParagraph}. The first half keeps the
500
+ * original paraId and the second half is re-minted; suggesting
468
501
  * mode stamps a `pPrIns` revision on the first half.
469
502
  */
470
503
  interface YrsSplitReceipt {
@@ -472,12 +505,7 @@ interface YrsSplitReceipt {
472
505
  secondParaId: string;
473
506
  revisionId: string | null;
474
507
  }
475
- /**
476
- * One low-level story mirror operation for {@link YrsSession.applyRawOps}. The
477
- * coexistence bridge lowers a ProseMirror transaction to a list of these and
478
- * applies them in one yrs transaction. Indices are UTF-16 story units, each read
479
- * against the story state after all prior ops in the batch.
480
- */
508
+ /** Low-level UTF-16 story operation for {@link YrsSession.applyRawOps}. */
481
509
  type YrsRawOp = {
482
510
  op: 'insert';
483
511
  index: number;
@@ -504,13 +532,7 @@ type YrsRawOp = {
504
532
  key: string;
505
533
  value: unknown;
506
534
  } | {
507
- /**
508
- * Upserts the side-map comment keyed by `id`, (re-)anchoring it to
509
- * `ranges` — non-empty `[start, end)` story-unit spans in the batch's
510
- * story (sticky `Assoc::After` starts / `Assoc::Before` ends). The
511
- * coexistence bridge keys by the PM comment id so identity survives the
512
- * mirror.
513
- */
535
+ /** Upserts a side-map comment with sticky story-unit ranges. */
514
536
  op: 'setComment';
515
537
  id: string;
516
538
  ranges: ReadonlyArray<readonly [number, number]>;
@@ -638,7 +660,7 @@ interface YrsSelectionContext {
638
660
  strike: YrsTriState;
639
661
  /** Uniform ASCII font family, or `null` when absent/mixed. */
640
662
  fontFamily: string | null;
641
- /** Uniform font size in half-points (the PM/OOXML `w:sz` unit). */
663
+ /** Uniform font size in half-points (the OOXML `w:sz` unit). */
642
664
  fontSize: number | null;
643
665
  /** Uniform RGB hex or theme-color name, or `null` when absent/mixed. */
644
666
  color: string | null;
@@ -647,7 +669,7 @@ interface YrsSelectionContext {
647
669
  styleId: string | null;
648
670
  alignment: string | null;
649
671
  /**
650
- * Full authored pilcrow property bag. Known toolbar fields retain their PM
672
+ * Full authored pilcrow property bag. Known toolbar fields retain their
651
673
  * names (`indentLeft`, `spaceBefore`, `lineSpacing`, `numPr`, and so on);
652
674
  * paragraph style is stored as `pStyle`.
653
675
  */
@@ -716,8 +738,8 @@ interface YrsCellLoc extends YrsTableLoc {
716
738
  column: number;
717
739
  }
718
740
  /**
719
- * Anchor-cell to head-cell rectangular selection, analogous to PM's
720
- * `CellSelection` but independent of ProseMirror positions.
741
+ * Anchor-cell to head-cell rectangular selection, addressed by grid
742
+ * coordinates rather than document positions.
721
743
  *
722
744
  * @public
723
745
  */
@@ -741,7 +763,7 @@ interface YrsTableReceipt {
741
763
  revisionIds: string[];
742
764
  }
743
765
  /**
744
- * OOXML/PM-shaped cell border value passed through to `tcPr.borders`.
766
+ * OOXML-shaped cell border value passed through to `tcPr.borders`.
745
767
  *
746
768
  * @public
747
769
  */
@@ -753,11 +775,13 @@ interface YrsCellBorder {
753
775
  };
754
776
  }
755
777
  /**
756
- * Complete per-side border object for {@link YrsSession.setCellBorders}.
778
+ * Per-side border patch for {@link YrsSession.setCellBorders}. An omitted side
779
+ * is left alone, `style: 'none'` authors an explicit no-border, and `null`
780
+ * drops the authored side.
757
781
  *
758
782
  * @public
759
783
  */
760
- type YrsCellBorders = Partial<Record<'top' | 'bottom' | 'left' | 'right' | 'insideH' | 'insideV', YrsCellBorder>>;
784
+ type YrsCellBorders = Partial<Record<'top' | 'bottom' | 'left' | 'right' | 'insideH' | 'insideV', YrsCellBorder | null>>;
761
785
  /**
762
786
  * One live replica of the yrs editing model. Thin typed wrapper over the
763
787
  * wasm `EditSession` — no editing logic on this side of the boundary.
@@ -810,17 +834,20 @@ interface YrsSession extends CollaborationReplica {
810
834
  } | null;
811
835
  /** Resident display-list hit/range queries; results are small JSON records. */
812
836
  displayHitTestRegionsJson(pageIndex: number, x: number, y: number): string;
837
+ displayVerticalMoveJson(position: number, direction: 'up' | 'down', goalX: number): string;
813
838
  displayRangeRectsJson(from: number, to: number): string;
814
839
  displayRangeRectsRegionJson(region: 'body' | 'header' | 'footer', rId: string, from: number, to: number): string;
815
840
  /** Read a glyph outline from the session's resident font store. */
816
841
  outlineGlyphJson(fontId: number, glyphId: number): string;
817
842
  /** Hydrates from an encoded yrs v1 update (typically a peer's {@link encodeState} output). */
818
843
  loadState(update: Uint8Array): void;
819
- /**
820
- * Seeds stories from parsed content (S1 scaffold; the real
821
- * `load(ParsedDocument)` lands with the ops track). Returns paraIds per
822
- * story in document order.
823
- */
844
+ /** Parses a DOCX, seeds its stories, and returns thin host metadata. */
845
+ seedFromDocx(bytes: Uint8Array): YrsDocxHost;
846
+ /** Parses a DOCX and optionally seeds its stories. */
847
+ openDocx(bytes: Uint8Array, seedStories: boolean): YrsDocxHost;
848
+ /** Materializes the retained canonical package for compatibility APIs. */
849
+ materializeDocx(): Document | null;
850
+ /** Seeds stories and returns paragraph IDs in document order. */
824
851
  loadStories(stories: readonly YrsStorySeed[]): Record<string, string[]>;
825
852
  /** Full document state as one yrs v1 update (Yjs wire format). */
826
853
  encodeState(): Uint8Array;
@@ -829,7 +856,7 @@ interface YrsSession extends CollaborationReplica {
829
856
  /** Full state, or only the state missing from a peer vector. */
830
857
  encodeStateAsUpdate(remoteStateVector?: Uint8Array): Uint8Array;
831
858
  /** Applies a remote/incremental yrs v1 update. */
832
- applyUpdate(update: Uint8Array): void;
859
+ applyUpdate(update: Uint8Array): CollaborationTextInsertion | null;
833
860
  /** Apply a same-user worker update under the local undo origin. @internal */
834
861
  applyLocalUpdate(update: Uint8Array, story: string): void;
835
862
  /**
@@ -837,16 +864,26 @@ interface YrsSession extends CollaborationReplica {
837
864
  * applied-remote). Returns an unsubscribe function.
838
865
  */
839
866
  onUpdate(listener: (update: Uint8Array, origin: CollaborationUpdateOrigin) => void): () => void;
867
+ /** Encode one location as a binary Yrs sticky position. */
868
+ encodeStickyPosition(loc: YrsLoc): YrsStickyPosition;
869
+ /** Resolve a binary Yrs sticky position against this replica. */
870
+ resolveStickyPosition(position: YrsStickyPosition): YrsLoc | null;
840
871
  /** Store this peer's awareness selection as sticky positions. */
841
872
  setSelection(anchor: YrsLoc, head?: YrsLoc): void;
842
873
  /** Resolve this peer's current sticky selection, or null before initialization. */
843
874
  selection(): YrsSelection | null;
875
+ /** Encode the current selection as binary Yrs sticky indices. */
876
+ encodeSelection(): CollaborationCursor | null;
877
+ /** Resolve a peer's binary Yrs sticky indices against this replica. */
878
+ resolveSelection(cursor: CollaborationCursor): YrsSelection | null;
844
879
  /** Store this peer's rectangular table selection outside the document. */
845
880
  setCellSelection(range: YrsTableRange): void;
846
881
  /** Resolve the current sticky cell selection, or null before initialization. */
847
882
  cellSelection(): YrsTableRange | null;
848
883
  /** Lazily begin local-origin undo capture after import/seeding has completed. */
849
884
  beginUndoCapture(story: string, includeTableStories?: boolean): void;
885
+ /** Story owned by the current undo/redo scope, or null before the first local edit. */
886
+ historyStory(): string | null;
850
887
  /** Coalesce the stack entries added since `startDepth` into one host undo intent. */
851
888
  markUndoGroup(startDepth: number): void;
852
889
  /** Undo/redo only local-origin direct operations (never remote/system transactions). */
@@ -880,11 +917,14 @@ interface YrsSession extends CollaborationReplica {
880
917
  /** Sets or clears the selected cells' background color. */
881
918
  setCellShading(range: YrsTableRange, color: string | null): YrsTableReceipt;
882
919
  /**
883
- * Merges an OOXML/PM-shaped patch into selected cells' `tcPr`. JSON `null`
920
+ * Merges an OOXML-shaped patch into selected cells' `tcPr`. JSON `null`
884
921
  * clears a property; merge/split-owned span keys are rejected.
885
922
  */
886
923
  setCellTextFormat(range: YrsTableRange, patch: Readonly<Record<string, unknown>>): YrsTableReceipt;
887
- /** Replaces the complete selected-cell border property object. */
924
+ /**
925
+ * Merges border sides into the selected cells. `insideH`/`insideV` resolve
926
+ * per cell to the physical edges interior to the selection.
927
+ */
888
928
  setCellBorders(range: YrsTableRange, borders: YrsCellBorders): YrsTableReceipt;
889
929
  /** Sets one authored grid-column width in twips. */
890
930
  setColumnWidth(at: YrsCellLoc, widthTwips: number): YrsTableReceipt;
@@ -906,7 +946,10 @@ interface YrsSession extends CollaborationReplica {
906
946
  splitParagraph(at: YrsLoc, suggesting?: YrsAuthor): YrsSplitReceipt;
907
947
  /** Merges `paraId` with the FOLLOWING paragraph. Errors on the final paragraph. */
908
948
  mergeParagraphs(story: string, paraId: string, suggesting?: YrsAuthor): YrsRevisionReceipt;
909
- /** Toggles one run mark across a range (PM toggleMark range semantics). */
949
+ /**
950
+ * Toggles one run mark across a range: removes it when every unit already
951
+ * carries it, otherwise adds it.
952
+ */
910
953
  toggleMark(range: YrsStoryRange, mark: YrsRunMark): void;
911
954
  /** Applies set-valued direct formatting; omitted fields are kept and `null` fields clear. */
912
955
  formatRange(range: YrsStoryRange, delta: YrsInlineFormatDelta): void;
@@ -934,18 +977,14 @@ interface YrsSession extends CollaborationReplica {
934
977
  insertSectionBreak(at: YrsLoc, type: 'nextPage' | 'continuous' | 'oddPage' | 'evenPage'): void;
935
978
  /** Inserts a typed watermark embed at a paragraph-keyed location. */
936
979
  insertWatermark(at: YrsLoc, watermark: YrsWatermark): void;
937
- /**
938
- * Applies a batch of raw story mirror ops in one transaction — the coexistence
939
- * bridge's mirror-into-yrs path (a faithful mirror of lowered PM state, not a
940
- * user-intent op). Not for direct app use.
941
- */
980
+ /** Applies raw story operations in one transaction. */
942
981
  applyRawOps(story: string, ops: readonly YrsRawOp[]): void;
943
982
  /** Sets one paragraph property (any JSON value). `paraId` is reserved. */
944
983
  setParagraphAttr(paraId: string, key: string, value: unknown): void;
945
984
  /** Adds a sticky-anchored comment over one or more ranges. */
946
985
  addComment(ranges: readonly YrsStoryRange[], author: string, date: string, body: unknown): YrsCommentReceipt;
947
986
  /**
948
- * Accepts tracked changes (S4b): pending insertions become plain content,
987
+ * Accepts tracked changes: pending insertions become plain content,
949
988
  * pending deletions are carried out; a `pPrIns` paragraph mark clears (the
950
989
  * split stays), a `pPrDel` mark joins with the following paragraph (whose
951
990
  * pPr survives — Word's surviving-`w:p` rule). Resolving never stamps a new
@@ -968,18 +1007,9 @@ interface YrsSession extends CollaborationReplica {
968
1007
  storyIds(): string[];
969
1008
  /** Story length in UTF-16 units (every embed, pilcrows included, counts 1). */
970
1009
  storyLength(story: string): number;
971
- /**
972
- * The story's `canonical-stream-v1` FNV-1a checksum. The coexistence watchdog
973
- * compares it against the PM projector's checksum after every mirrored edit.
974
- */
1010
+ /** Returns the story's canonical-stream checksum. */
975
1011
  storyChecksum(story: string): bigint;
976
- /**
977
- * Lowers a story through the resident Rust bridge. Throws with an
978
- * unsupported-embed message on any non-native content (opaque blobs) until
979
- * that class is promoted to native.
980
- * The return is the layout pipeline's `LayoutBlock[]` (kept as `unknown[]` to
981
- * keep this facade decoupled from the layout types).
982
- */
1012
+ /** Lowers a story to layout blocks and rejects unsupported embeds. */
983
1013
  yrsBlocksForStory(story: string, env?: YrsRenderEnv): unknown[];
984
1014
  /** Paragraph snapshots in document order. */
985
1015
  paragraphs(story: string): YrsParagraph[];
@@ -1007,4 +1037,4 @@ interface CreateYrsSessionOptions {
1007
1037
  */
1008
1038
  declare function createYrsSession(options?: CreateYrsSessionOptions): Promise<YrsSession>;
1009
1039
 
1010
- export { type YrsRunMark as $, type YrsEngineApplyProfile as A, type YrsHyperlinkAttrs as B, type CollaborationReplica as C, type YrsImageGeometry as D, type YrsInlineFormatDelta as E, type YrsInputParagraphSeed as F, type YrsInputParagraphSpan as G, type YrsInputPositionMap as H, type YrsNumberingProperties as I, type YrsParaOffset as J, type YrsParagraph as K, type YrsParagraphAttrs as L, type YrsParagraphLength as M, type YrsParagraphReceipt as N, type YrsParagraphSeed as O, type YrsParagraphSpan as P, type YrsParagraphTabStop as Q, type ResidentCaretPaintStyle as R, type YrsRawOp as S, type YrsResidentCaretRect as T, type YrsResidentCaretSnapshot as U, type YrsResidentWorkerSnapshot as V, type YrsResidentWorkerSyncOptions as W, type YrsResolveReceipt as X, type YrsSession as Y, type YrsResolvedCommentAnchor as Z, type YrsRevisionReceipt as _, type YrsRenderEnv as a, type YrsSelectionContext as a0, type YrsSplitReceipt as a1, type YrsStoryRange as a2, type YrsStorySeed as a3, type YrsStorySegment as a4, type YrsTableLoc as a5, type YrsTableRange as a6, type YrsTableReceipt as a7, type YrsTextColor as a8, type YrsTriState as a9, type YrsWatermark as aa, canUseResidentEngineWorker as ab, compareYrsLocs as ac, createYrsInputPositionMap as ad, createYrsSession as ae, displayPositionToYrsLoc as af, documentToYrs as ag, residentCaretDeviceRect as ah, residentCaretSnapshotForFrame as ai, sameYrsSelection as aj, yrsLocToDisplayPosition as ak, yrsToDocument as al, type CollaborationTransport as b, type CollaborationProviderOptions as c, type CollaborationStatus as d, type CollaborationStatusListener as e, type CollaborationErrorListener as f, type YrsSelection as g, CollaborationError as h, type CollaborationErrorCode as i, type CollaborationStatusChange as j, type CollaborationTransportEvent as k, type CollaborationUpdateOrigin as l, type YrsLoc as m, type YrsRevisionInfo as n, type CreateYrsSessionOptions as o, type ResidentEngineOffscreenPage as p, type ResidentEngineWorkerApplyResult as q, ResidentEngineWorkerClient as r, type ResidentEngineWorkerFrame as s, type YrsAuthor as t, type YrsCellBorder as u, type YrsCellBorders as v, type YrsCellLoc as w, type YrsChangeTarget as x, type YrsCommentReceipt as y, type YrsContentControlValue as z };
1040
+ export { type YrsParagraphTabStop as $, type ResidentEngineWorkerFrame as A, type YrsAuthor as B, type CollaborationReplica as C, type YrsCellBorder as D, type YrsCellBorders as E, type YrsCellLoc as F, type YrsChangeTarget as G, type YrsCommentReceipt as H, type YrsContentControlValue as I, type YrsDocxHost as J, type YrsEngineApplyProfile as K, type YrsHyperlinkAttrs as L, type YrsImageGeometry as M, type YrsInlineFormatDelta as N, type YrsInputParagraphSeed as O, type YrsInputParagraphSpan as P, type YrsInputPositionMap as Q, type ResidentCaretPaintStyle as R, type YrsNumberingProperties as S, type YrsParaOffset as T, type YrsParagraph as U, type YrsParagraphAttrs as V, type YrsParagraphLength as W, type YrsParagraphReceipt as X, type YrsSession as Y, type YrsParagraphSeed as Z, type YrsParagraphSpan as _, type YrsRenderEnv as a, type YrsRawOp as a0, type YrsResidentCaretRect as a1, type YrsResidentCaretSnapshot as a2, type YrsResidentWorkerSnapshot as a3, type YrsResidentWorkerSyncOptions as a4, type YrsResolveReceipt as a5, type YrsResolvedCommentAnchor as a6, type YrsRevisionReceipt as a7, type YrsRunMark as a8, type YrsSelectionContext as a9, type YrsSplitReceipt as aa, type YrsStickyPosition as ab, type YrsStoryRange as ac, type YrsStorySeed as ad, type YrsStorySegment as ae, type YrsTableLoc as af, type YrsTableRange as ag, type YrsTableReceipt as ah, type YrsTextColor as ai, type YrsTriState as aj, type YrsWatermark as ak, canUseResidentEngineWorker as al, compareYrsLocs as am, createYrsInputPositionMap as an, createYrsSession as ao, displayPositionToYrsLoc as ap, documentToYrs as aq, residentCaretDeviceRect as ar, residentCaretSnapshotForFrame as as, sameYrsSelection as at, yrsLocToDisplayPosition as au, yrsToDocument as av, 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 };
@@ -1,14 +1,44 @@
1
- export { B as BundledFontProvider, E as EmbeddedFaceInput, F as FontScript, a as ResidentFontRequirement, R as ResidentMeasurementConfig, b as RustMeasureSource, c as RustTextEngine, d as createRustMeasureSource, g as getRustTextEngine } from '../rustMeasureSource-D1KsQvVC.mjs';
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 { S as SectionProperties, H as HeaderFooter } from '../content-DrqzbIr7.mjs';
4
+ export { D as DrawingScene, V as DrawingSceneNode, c as ShapeEffect, aW as ShapeFillPaint, aX as ShapeStrokePaint, d as ShapeTextBodyProperties } from '../content-DrqzbIr7.mjs';
2
5
  import { Document } from '../types/document.mjs';
3
- import { S as SectionProperties, H as HeaderFooter } from '../content-MOZ6hKP4.mjs';
4
- import { a as DisplayListQueries, D as DisplayListRect } from '../displayListQueries-BJlo7Jkz.mjs';
5
- import '../formatting-D1EPSaJP.mjs';
6
- import '../styles-Dn_o3Vo5.mjs';
6
+ import '../formatting-BqrFPeev.mjs';
7
7
  import '../docx/wrapTypes.mjs';
8
- import '../frameDelta-D965X8yK.mjs';
9
- import '../rustDisplayList-BRuZBqdL.mjs';
10
- import '../types-BfqUl2h_.mjs';
11
- import './pagination/index.mjs';
8
+ import '../styles-CMybYYHS.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>;
12
42
 
13
43
  /**
14
44
  * Selection-overlay geometry value types, shared by the canvas overlays and
@@ -58,8 +88,6 @@ declare function resolveHeaderFooter(document: Document | null, section: Section
58
88
  firstHeader: HeaderFooter | null;
59
89
  firstFooter: HeaderFooter | null;
60
90
  };
61
- declare function computeHfCaretRectsFromDisplayList(queries: DisplayListQueries, section: 'header' | 'footer', rId: string, position: number, pageIndex?: number): DisplayListRect[];
62
- declare function computeHfSelectionRectsFromDisplayList(queries: DisplayListQueries, section: 'header' | 'footer', rId: string, from: number, to: number, pageIndex?: number): DisplayListRect[];
63
91
 
64
92
  /** Coordinates selection paint with the latest completed layout sequence. */
65
93
  declare class LayoutSelectionGate {
@@ -83,4 +111,4 @@ declare class LayoutSelectionGate {
83
111
  };
84
112
  }
85
113
 
86
- export { type CaretPosition, DEFAULT_PAGE_HEIGHT_PX, LayoutSelectionGate, type SelectionRect, computeHfCaretRectsFromDisplayList, computeHfSelectionRectsFromDisplayList, resolveHeaderFooter };
114
+ export { type BundledFontModule, BundledFontProvider, type CaretPosition, DEFAULT_PAGE_HEIGHT_PX, type DefaultFontOptions, LayoutSelectionGate, type SelectionRect, configureDefaultFonts, resolveDefaultFontProvider, resolveHeaderFooter };
@@ -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-DO3BUV7C.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,M=a?n?.get(a.rId)??null:null;return e?.titlePg||(f??(f=l),h??(h=M)),{header:f,footer:h,firstHeader:l,firstFooter:M}}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 L(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:L(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(n=>{r(n)&&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),n=this.facesByFamily.get(r);n?n.push(t):this.facesByFamily.set(r,[t]);}this.chains=new Map,this.chainResults=new Map;}getFontIdChain(e,t,r){let n=C(e,t,r),o=this.chains.get(n);if(!o){let i=this.chains,a=this.chainResults,f=this.generation,u=this.resolveChain(e,t,r);u.then(l=>{f===this.generation&&(a.set(n,l),l.retryable&&i.get(n)===u&&i.delete(n));},()=>{i.get(n)===u&&i.delete(n);}),i.set(n,u),o=u;}return o.then(i=>i.ids)}getCachedFontIdChain(e,t,r){let n=C(e,t,r),o=this.chainResults.get(n);if(o?.retryable){let i=this.chainResults;queueMicrotask(()=>{i.get(n)===o&&i.delete(n);});}return o?.ids}getScriptFallbackIds(e){let t=[...new Set(e)];return Promise.all(t.map(r=>this.resolveScript(r))).then(r=>{let n=[];for(let{id:o}of r)o!==null&&!n.includes(o)&&n.push(o);return n})}getCachedScriptFallbackIds(e){let t=this.scriptResults,r=[];for(let o of e){let i=t.get(o);if(!i)return;r.push([o,i]);}let n=[];for(let[o,i]of r){let{id:a}=i;a!==null&&!n.includes(a)&&n.push(a),i.retryable&&queueMicrotask(()=>{t.get(o)===i&&t.delete(o);});}return n}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 n=C(e,t,r),o=[],i=false,a=this.pickEmbeddedFace(e,t,r);if(a){let d=await this.registerFace(a);d!==null?o.push(d):i=true;}let f=await this.bundled();f===void 0&&typeof this.bundledSource=="function"&&(i=true);let u;try{u=f?.resolve(e,t,r);}catch(d){i=true,console.warn(`[fontRegistry] bundled face resolver for "${e}" failed; falling back: ${d instanceof Error?d.message:String(d)}`);}if(u){let d=await this.registerBundled(n,u,e);d!==null&&!o.includes(d)&&o.push(d),d===null&&(i=true);}let l;try{l=f?.resolveLastResort?.(e,t,r);}catch(d){i=true,console.warn(`[fontRegistry] last-resort resolver for "${e}" failed; falling back: ${d instanceof Error?d.message:String(d)}`);}if(l){let d=await this.registerLastResort(n,l,e);d!==null&&!o.includes(d)&&o.push(d),d===null&&(i=true);}return o.length===0&&this.warnFallback(e,f!==void 0,u!==void 0||l!==void 0),{ids:o,retryable:i}}warnFallback(e,t,r){if(this.warnedFallback)return;this.warnedFallback=true;let n="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. ${n} 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. ${n}`:`[fontRegistry] no font bytes for "${e}" \u2014 no font provider is configured. Install @betteroffice/fonts and pass it with configureDefaultFonts({ fonts }). `+n);}pickEmbeddedFace(e,t,r){let n=this.facesByFamily.get($(e));if(!n)return;let o=t?"bold":"normal",i=r?"italic":"normal";return n.find(a=>a.weight===o&&a.style===i)??n.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,n=>n===null),r.set(e,t);}return t}registerBundled(e,t,r){let n=this.bundledIds.get(e);if(!n){let o=this.bundledIds;n=(async()=>{try{let i=await t();return await this.registerBuffer(i)}catch(i){return console.warn(`[fontRegistry] bundled face for "${r}" failed to load or register; falling back: ${i instanceof Error?i.message:String(i)}`),null}})(),k(o,e,n,i=>i===null),o.set(e,n);}return n}registerLastResort(e,t,r){let n=this.lastResortIds.get(e);if(!n){let o=this.lastResortIds;n=(async()=>{try{let i=await t();return await this.registerBuffer(i)}catch{return console.warn(`[fontRegistry] last-resort base face for "${r}" failed to load or register; falling back`),null}})(),k(o,e,n,i=>i===null),o.set(e,n);}return n}resolveScript(e){let t=this.scriptIds.get(e);if(!t){let r=this.scriptIds,n=this.scriptResults;t=(async()=>{let o=null,i=false,a=await this.bundled();a===void 0&&typeof this.bundledSource=="function"&&(i=true);let f;try{f=a?.resolveScriptFallback?.(e,!1,!1);}catch(l){i=true,console.warn(`[fontRegistry] script-fallback resolver for "${e}" failed; falling back: ${l instanceof Error?l.message:String(l)}`);}if(f)try{let l=await f();o=await this.registerBuffer(l);}catch(l){i=true,console.warn(`[fontRegistry] script-fallback face for "${e}" failed to load or register; falling back: ${l instanceof Error?l.message:String(l)}`);}let u={id:o,retryable:i};return n.set(e,u),u})(),k(r,e,t,o=>o.retryable),r.set(e,t);}return t}};var q=null;function j(){return q??(q=import('../wasm-T2CRCO7S.mjs').then(async s=>(await s.preloadLayoutWasm(),{registerFont:s.registerMeasureFont,clearFonts:s.clearMeasureFonts}))),q}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(o=>[(async()=>{try{return e.getCachedFontIdChain(o.family,o.bold,o.italic)!==void 0?!1:(await e.getFontIdChain(o.family,o.bold,o.italic),!0)}catch{return false}})(),...Array.from(new Set(o.scripts??[]),async i=>{try{return e.getCachedScriptFallbackIds([i])!==void 0?!1:(await e.getScriptFallbackIds([i]),!0)}catch{return false}})]))).some(Boolean)},measurementConfigForRequirements(r){let n={};for(let o of r){let i=e.getCachedFontIdChain(o.family,o.bold,o.italic),a=e.getCachedScriptFallbackIds(o.scripts??[]);if(i===void 0||a===void 0)return;let f=Array.from(i);for(let u of a)f.includes(u)||f.push(u);f.length>0&&(n[o.key]=f);}return {fontChains:n,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,n=e?.headerReferences?.find(F=>F.type==="default"),o=e?.headerReferences?.find(F=>F.type==="first"),i=e?.footerReferences?.find(F=>F.type==="default"),a=e?.footerReferences?.find(F=>F.type==="first"),f=n?t?.get(n.rId)??null:null,u=i?r?.get(i.rId)??null:null,l=o?t?.get(o.rId)??null:null,d=a?r?.get(a.rId)??null:null;return e?.titlePg||(f??(f=l),u??(u=d)),{header:f,footer:u,firstHeader:l,firstFooter:d}}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 { L as LayoutBlock, B as BlockExtent } from '../../types-BfqUl2h_.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, a as Layout, b 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-BfqUl2h_.mjs';
3
- import '../../content-MOZ6hKP4.mjs';
4
- import '../../formatting-D1EPSaJP.mjs';
1
+ import { L as LayoutBlock, B as BlockExtent } from '../../types-CXLxVF1t.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, a as Layout, b 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-CXLxVF1t.mjs';
3
+ import '../../content-DrqzbIr7.mjs';
4
+ import '../../formatting-BqrFPeev.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-3UBMCDME.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 x(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 f(e,r,o){return l(e,r,o)}function l(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,x as pageGeometryFromPage,f as resolveAnchoredObjectVerticalTop};
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 x(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 f(e,r,o){return l(e,r,o)}function l(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,x as pageGeometryFromPage,f as resolveAnchoredObjectVerticalTop};