@betteroffice/docx 0.3.0 → 0.4.1

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 (82) hide show
  1. package/README.md +66 -1
  2. package/dist/chunk-2HLVVQIL.mjs +1 -0
  3. package/dist/chunk-2QHGQA3V.mjs +1 -0
  4. package/dist/{chunk-ACGKK7IB.mjs → chunk-3CYO46ML.mjs} +1 -1
  5. package/dist/chunk-3OWET2KZ.mjs +1 -0
  6. package/dist/chunk-4GEXNR7A.mjs +1 -0
  7. package/dist/chunk-4QHAMEAS.mjs +1 -0
  8. package/dist/chunk-6CHGYCFU.mjs +1 -0
  9. package/dist/chunk-7DDF4RHB.mjs +16 -0
  10. package/dist/chunk-AOWJ4WDE.mjs +1 -0
  11. package/dist/chunk-C5BX34CG.mjs +2 -0
  12. package/dist/chunk-DKWD4P4J.mjs +1 -0
  13. package/dist/chunk-DLXIZBB6.mjs +1 -0
  14. package/dist/chunk-EIPVFGIC.mjs +1 -0
  15. package/dist/{chunk-NT2OYIJ4.mjs → chunk-FMOSOX5V.mjs} +1 -1
  16. package/dist/chunk-HPZFJGGM.mjs +0 -0
  17. package/dist/chunk-LT2GCWZ3.mjs +0 -0
  18. package/dist/chunk-NVN26RHH.mjs +1 -0
  19. package/dist/{chunk-QE4ZDRKV.mjs → chunk-YLFKV2NT.mjs} +1 -1
  20. package/dist/collaboration/index.d.mts +6 -4
  21. package/dist/compareDocx-QX2YF3EF.mjs +1 -0
  22. package/dist/computeLayout-4MNWHE2T.mjs +1 -0
  23. package/dist/core.d.mts +4 -4
  24. package/dist/core.mjs +1 -1
  25. package/dist/{displayListQueries-BYFrBkw5.d.mts → displayListQueries-DnHmHUPY.d.mts} +23 -5
  26. package/dist/docx/index.d.mts +2 -2
  27. package/dist/docx/index.mjs +1 -1
  28. package/dist/editor/index.d.mts +16 -7
  29. package/dist/editor/index.mjs +1 -1
  30. package/dist/{fontLoader-CkXcPB1C.d.mts → fontLoader-BNSs0E8K.d.mts} +54 -1
  31. package/dist/{frameDelta-CVt5FAXT.d.mts → frameDelta-ByU7HBuB.d.mts} +21 -1
  32. package/dist/generated/edit/docx_edit_bg.wasm +0 -0
  33. package/dist/generated/layout/docx_layout_bg.wasm +0 -0
  34. package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
  35. package/dist/generated/parse/docx_parse_bg.wasm +0 -0
  36. package/dist/{index-BbZwdkPz.d.mts → index-yOtBET85.d.mts} +769 -16
  37. package/dist/layout/index.d.mts +2 -2
  38. package/dist/layout/index.mjs +1 -1
  39. package/dist/layout/pagination/index.d.mts +2 -2
  40. package/dist/layout/render/index.d.mts +140 -32
  41. package/dist/layout/render/index.mjs +1 -1
  42. package/dist/loadWasmAsset-Cr95TImt.d.mts +25 -0
  43. package/dist/{pagedExport-D3E4jZ-B.d.mts → pagedExport-BmSlEhoP.d.mts} +1 -1
  44. package/dist/parseWasm-NLAG22EU.mjs +1 -0
  45. package/dist/plugin-api/RenderedDomContext.d.mts +6 -4
  46. package/dist/plugin-api/RenderedDomContext.mjs +1 -1
  47. package/dist/{rustDisplayList-CwOoUn3t.d.mts → rustDisplayList-DcaA5iok.d.mts} +12 -4
  48. package/dist/{rustMeasureSource-CyBMcy1x.d.mts → rustMeasureSource-BkCx1FDx.d.mts} +2 -0
  49. package/dist/types/document.d.mts +3 -0
  50. package/dist/{types-B4jD0rrc.d.mts → types-Buyw6dFd.d.mts} +32 -3
  51. package/dist/utils/index.d.mts +14 -2
  52. package/dist/utils/index.mjs +1 -1
  53. package/dist/wasm-6WSIEYWC.mjs +1 -0
  54. package/dist/wasm-GSI2XMOH.mjs +1 -0
  55. package/dist/{wasm-G62X4WRW.mjs → wasm-IBCLSJQU.mjs} +1 -1
  56. package/dist/wasm-edit.d.mts +191 -18
  57. package/dist/wasm-edit.mjs +1 -1
  58. package/dist/wasm-layout.d.mts +1 -1
  59. package/dist/wasm-layout.mjs +1 -1
  60. package/dist/wasm-opc.d.mts +1 -1
  61. package/dist/wasm-opc.mjs +1 -1
  62. package/dist/wasm-parse.d.mts +1 -1
  63. package/dist/wasm-parse.mjs +1 -1
  64. package/dist/yrs/index.d.mts +5 -3
  65. package/dist/yrs/index.mjs +1 -1
  66. package/dist/yrs/residentEngineWorker.mjs +1 -1
  67. package/package.json +2 -2
  68. package/dist/chunk-5B4VMUXM.mjs +0 -16
  69. package/dist/chunk-5F6DLQZP.mjs +0 -1
  70. package/dist/chunk-5JEQC76K.mjs +0 -1
  71. package/dist/chunk-7GJG6LLU.mjs +0 -1
  72. package/dist/chunk-FE6FWGBJ.mjs +0 -1
  73. package/dist/chunk-H5YYCN42.mjs +0 -1
  74. package/dist/chunk-HLDJMU3R.mjs +0 -1
  75. package/dist/chunk-J7LNO6SM.mjs +0 -1
  76. package/dist/chunk-PGMXWI5X.mjs +0 -1
  77. package/dist/chunk-VQXNED2P.mjs +0 -2
  78. package/dist/chunk-Z4HZIPBS.mjs +0 -1
  79. package/dist/compareDocx-XXTZV4CG.mjs +0 -1
  80. package/dist/computeLayout-LWLAJWYA.mjs +0 -1
  81. package/dist/loadWasmAsset-CMvnVkfA.d.mts +0 -3
  82. package/dist/wasm-US6R7SWN.mjs +0 -1
@@ -222,6 +222,28 @@ declare function colorsEqual(color1: ColorValue | undefined | null, color2: Colo
222
222
  * - Callback notifications
223
223
  * - Font availability detection
224
224
  */
225
+ /**
226
+ * The loads and notifications of one editor instance; see
227
+ * {@link createFontLoadScope}.
228
+ *
229
+ * @public
230
+ */
231
+ interface FontLoadScope {
232
+ /** Hears the loads this scope asked for and module-level loads, not other scopes' loads. */
233
+ onFontsLoaded(callback: (fonts: string[]) => void): () => void;
234
+ /** Hears the failures of this scope's loads and of module-level loads. */
235
+ onFontError(callback: (error: Error) => void): () => void;
236
+ /** {@link loadDocumentFonts} on behalf of this scope. */
237
+ loadDocumentFonts(document: unknown): Promise<void>;
238
+ /** {@link loadFontsWithMapping} on behalf of this scope. */
239
+ loadFontsWithMapping(families: string[]): Promise<void>;
240
+ /** {@link loadFontDefinitions} on behalf of this scope. */
241
+ loadFontDefinitions(defs: ReadonlyArray<FontDefinition> | undefined): Promise<void>;
242
+ /** Drops the listeners and releases the embedded faces this scope holds; a later listener revives it. */
243
+ dispose(): void;
244
+ /** Whether it is disposed and not revived since. */
245
+ readonly disposed: boolean;
246
+ }
225
247
  /**
226
248
  * Load a font from Google Fonts
227
249
  *
@@ -341,6 +363,28 @@ declare function loadFontFromBuffer(fontFamily: string, buffer: ArrayBuffer, opt
341
363
  weight?: number | string;
342
364
  style?: 'normal' | 'italic';
343
365
  }): Promise<boolean>;
366
+ /** One face of a font file's bytes, as {@link registerDocumentFaces} takes it. */
367
+ interface BufferFaceInput {
368
+ family: string;
369
+ data: ArrayBuffer;
370
+ weight?: number | string;
371
+ style?: 'normal' | 'italic';
372
+ }
373
+ /**
374
+ * Registers one document's font faces from their bytes. Each family takes its
375
+ * own name, as {@link loadFontFromBuffer} registers it, unless a live
376
+ * registration holds different bytes under that name; then all its faces take
377
+ * an alias, so both documents keep their own glyphs. Faces with the same bytes
378
+ * are registered once. With a scope, the faces are held until the scope loads
379
+ * its next document or is disposed; without one, for the page's lifetime.
380
+ * `faces` may be a promise: the scope's next document is the one whose call
381
+ * came last, whichever faces arrive first. Resolves to the CSS family each
382
+ * family was registered under, for the families with at least one face that
383
+ * loaded, or to an empty map once a later document or disposal replaced it.
384
+ *
385
+ * @public
386
+ */
387
+ declare function registerDocumentFaces(faces: readonly BufferFaceInput[] | PromiseLike<readonly BufferFaceInput[]>, scope?: FontLoadScope): Promise<Map<string, string>>;
344
388
  /**
345
389
  * Load a font face from a URL (woff2, woff, ttf, otf).
346
390
  *
@@ -450,5 +494,14 @@ declare function extractFontsFromDocument(document: unknown): Set<string>;
450
494
  * @returns Promise resolving when fonts are loaded
451
495
  */
452
496
  declare function loadDocumentFonts(document: unknown): Promise<void>;
497
+ /**
498
+ * A scope for one editor instance's font loads. Loads made through it notify
499
+ * its own `onFontsLoaded` / `onFontError` listeners and the module-level ones,
500
+ * never another scope's; module-level loads still reach every scope, so a
501
+ * single editor hears what it heard before. Dedupe and caches stay shared.
502
+ *
503
+ * @public
504
+ */
505
+ declare function createFontLoadScope(): FontLoadScope;
453
506
 
454
- export { resolveShadingColor as A, setGoogleFontsEnabled as B, type FontDefinition as C, extractFontsFromDocument as D, getGoogleFontEquivalent as E, FONT_MAPPING as F, loadDocumentFonts as G, loadFontDefinitions as H, loadFontFromUrl as I, loadFontWithMapping as J, loadFontsWithMapping as K, onFontError as L, resolveColorToHex as M, type ThemeMatrixCell as T, colorsEqual as a, blendColors as b, canRenderFont as c, createRgbColor as d, createThemeColor as e, darkenColor as f, ensureHexPrefix as g, generateThemeTintShadeMatrix as h, getContrastingColor as i, getLoadedFonts as j, getThemeTintShadeHex as k, isBlack as l, isFontLoaded as m, isLoading as n, isGoogleFontsEnabled as o, isWhite as p, lightenColor as q, loadFont as r, loadFontFromBuffer as s, loadFonts as t, onFontsLoaded as u, parseColorString as v, preloadCommonFonts as w, resolveColor as x, resolveHighlightColor as y, resolveHighlightToCss as z };
507
+ export { resolveShadingColor as A, setGoogleFontsEnabled as B, type BufferFaceInput as C, FONT_MAPPING as D, type FontDefinition as E, type FontLoadScope as F, createFontLoadScope as G, extractFontsFromDocument as H, getGoogleFontEquivalent as I, loadDocumentFonts as J, loadFontDefinitions as K, loadFontFromUrl as L, loadFontWithMapping as M, loadFontsWithMapping as N, onFontError as O, registerDocumentFaces as P, resolveColorToHex as Q, type ThemeMatrixCell as T, colorsEqual as a, blendColors as b, canRenderFont as c, createRgbColor as d, createThemeColor as e, darkenColor as f, ensureHexPrefix as g, generateThemeTintShadeMatrix as h, getContrastingColor as i, getLoadedFonts as j, getThemeTintShadeHex as k, isBlack as l, isFontLoaded as m, isLoading as n, isGoogleFontsEnabled as o, isWhite as p, lightenColor as q, loadFont as r, loadFontFromBuffer as s, loadFonts as t, onFontsLoaded as u, parseColorString as v, preloadCommonFonts as w, resolveColor as x, resolveHighlightColor as y, resolveHighlightToCss as z };
@@ -31,6 +31,8 @@ interface DisplayPage {
31
31
  /** Formatted PAGE label (for example, "vii"). */
32
32
  pageLabel?: string;
33
33
  primitives: DisplayPrimitive[];
34
+ /** Leading primitives painted beneath the header and footer. */
35
+ watermarkPrimitiveCount?: number;
34
36
  /** Resolved page background. Undefined = transparent/host white. */
35
37
  background?: string;
36
38
  pageBorders?: PageBorderPrimitive[];
@@ -38,6 +40,10 @@ interface DisplayPage {
38
40
  footer?: HfRegion;
39
41
  /** Footnote/endnote regions in page coordinates. Undefined = none. */
40
42
  noteAreas?: NoteRegion[];
43
+ /** Geometry only: the page's content is built when the host asks for it. */
44
+ unbuilt?: boolean;
45
+ /** For an unbuilt page, the lowest and highest body position its layout places. */
46
+ positionSpan?: [number, number];
41
47
  }
42
48
  /** A page-local rectangle emitted as display-list metadata. */
43
49
  interface DisplayBounds {
@@ -716,12 +722,20 @@ interface FramePositionShiftRun {
716
722
  readonly changedMask: number;
717
723
  readonly delta: number;
718
724
  }
725
+ /** A note region note's new backlink anchor; null clears the field. */
726
+ interface FrameNoteAnchor {
727
+ readonly area: number;
728
+ readonly note: number;
729
+ readonly start: number | null;
730
+ readonly end: number | null;
731
+ }
719
732
  interface FramePagePositionShift {
720
733
  readonly kind: 'shift-positions';
721
734
  readonly pageIndex: number;
722
735
  readonly pageId: bigint;
723
736
  readonly fingerprint: bigint;
724
737
  readonly runs: readonly FramePositionShiftRun[];
738
+ readonly anchors: readonly FrameNoteAnchor[];
725
739
  }
726
740
  type FramePageOperation = FramePageUpsert | FramePageRemove | FramePageMove | FramePagePositionPatch | FramePagePositionShift;
727
741
  interface DecodedFrameDelta {
@@ -780,5 +794,11 @@ declare function applyFrameDeltaOwned(previous: RetainedFrame | null, delta: Dec
780
794
  * it.
781
795
  */
782
796
  declare function displayPageRevision(page: DisplayPage): number;
797
+ /**
798
+ * Counts the owned shifts that moved this page's note anchors in place, for
799
+ * consumers that render the anchors (the accessibility mirror) and otherwise
800
+ * key on page identity.
801
+ */
802
+ declare function displayPageNoteAnchorRevision(page: DisplayPage): number;
783
803
 
784
- export { type DisplayList as D, FRAME_DELTA_HEADER_BYTES as F, type GlyphRunPrimitive as G, type HfRegion as H, type ImagePrimitive as I, type LinePrimitive as L, type PositionedGlyph as P, type RetainedFrame as R, type TextRunPrimitive as T, type DisplayPage as a, type DisplayPrimitive as b, type DecodedFrameDelta as c, type DecorationPrimitive as d, type DisplayBounds as e, type DocAttrs as f, FRAME_DELTA_PAGE_OP_BYTES as g, FRAME_DELTA_VERSION as h, FrameDeltaError as i, type FrameDeltaErrorCode as j, type FramePageOperation as k, type RectPrimitive as l, type RetainedFramePage as m, type TableCellRef as n, applyFrameDelta as o, applyFrameDeltaOwned as p, decodeFrameDelta as q, displayPageRevision as r };
804
+ export { type DisplayList as D, FRAME_DELTA_HEADER_BYTES as F, type GlyphRunPrimitive as G, type HfRegion as H, type ImagePrimitive as I, type LinePrimitive as L, type PositionedGlyph as P, type RetainedFrame as R, type TextRunPrimitive as T, type DisplayPage as a, type DisplayPrimitive as b, type DecodedFrameDelta as c, type DecorationPrimitive as d, type DisplayBounds as e, type DocAttrs as f, FRAME_DELTA_PAGE_OP_BYTES as g, FRAME_DELTA_VERSION as h, FrameDeltaError as i, type FrameDeltaErrorCode as j, type FramePageOperation as k, type RectPrimitive as l, type RetainedFramePage as m, type TableCellRef as n, applyFrameDelta as o, applyFrameDeltaOwned as p, decodeFrameDelta as q, displayPageNoteAnchorRevision as r, displayPageRevision as s };