@betteroffice/docx 0.0.2 → 0.0.4
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 +20 -7
- package/dist/chunk-4V6MDZIK.mjs +1 -0
- package/dist/chunk-6KDV6AIL.mjs +1 -0
- package/dist/chunk-CTBUQRYQ.mjs +1 -0
- package/dist/chunk-GGEGIQRK.mjs +1 -0
- package/dist/chunk-J7LNO6SM.mjs +1 -0
- package/dist/{chunk-IFT6DUJX.mjs → chunk-LTVVQMHB.mjs} +1 -1
- package/dist/chunk-NBSLB77E.mjs +1 -0
- package/dist/chunk-NTSSE5QK.mjs +57 -0
- package/dist/chunk-YTILOUAA.mjs +16 -0
- package/dist/collaboration/index.d.mts +31 -6
- package/dist/collaboration/index.mjs +1 -1
- package/dist/{content-DLFHRQav.d.mts → content-C3sTRz-u.d.mts} +115 -248
- package/dist/core.d.mts +6 -6
- package/dist/core.mjs +1 -1
- package/dist/{displayListQueries-UGc_XBUv.d.mts → displayListQueries-DLzpvJV6.d.mts} +36 -7
- package/dist/docx/index.d.mts +3 -3
- package/dist/docx/index.mjs +1 -1
- package/dist/editor/index.d.mts +7 -6
- package/dist/{fontLoader-aSewHMKF.d.mts → fontLoader-CMH3bZ2Z.d.mts} +127 -2
- package/dist/{formatting-D1EPSaJP.d.mts → formatting-BEkIBePP.d.mts} +77 -203
- package/dist/{rustDisplayList-CX78djsZ.d.mts → frameDelta-B2kC6XiP.d.mts} +5 -274
- package/dist/generated/edit/docx_edit_bg.wasm +0 -0
- package/dist/generated/layout/docx_layout_bg.wasm +0 -0
- package/dist/generated/parse/docx_parse_bg.wasm +0 -0
- package/dist/{index-Bwxm3oiC.d.mts → index-2piKi4gO.d.mts} +147 -8
- package/dist/layout/index.d.mts +8 -6
- 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 +10 -9
- package/dist/layout/render/index.mjs +1 -1
- package/dist/plugin-api/RenderedDomContext.d.mts +7 -6
- package/dist/plugin-api/index.d.mts +3 -3
- package/dist/plugin-api/resolveItemPositions.d.mts +3 -3
- package/dist/rustDisplayList-B0M2eBkU.d.mts +283 -0
- package/dist/styles/index.d.mts +2 -2
- package/dist/{styles-Dn_o3Vo5.d.mts → styles-BK3Jecxs.d.mts} +1 -1
- package/dist/types/content.d.mts +2 -2
- package/dist/types/document.d.mts +6 -6
- package/dist/{types-DMkDbvEu.d.mts → types-C1rv3KM-.d.mts} +2 -2
- package/dist/utils/comments.d.mts +2 -2
- package/dist/utils/index.d.mts +4 -4
- package/dist/utils/index.mjs +1 -1
- package/dist/utils/stylePreview.d.mts +2 -2
- package/dist/utils/units.d.mts +4 -34
- package/dist/utils/units.mjs +1 -1
- package/dist/wasm-F2ETFAYL.mjs +1 -0
- package/dist/wasm-JE7B3ROD.mjs +1 -0
- package/dist/wasm-edit.d.mts +25 -0
- package/dist/wasm-edit.mjs +1 -1
- package/dist/wasm-layout.d.mts +14 -1
- package/dist/wasm-layout.mjs +1 -1
- package/dist/yrs/index.d.mts +5 -4
- package/dist/yrs/index.mjs +1 -1
- package/dist/yrs/residentEngineWorker.mjs +1 -1
- package/package.json +1 -2
- package/dist/chunk-3UBMCDME.mjs +0 -1
- package/dist/chunk-6NEKRDXF.mjs +0 -1
- package/dist/chunk-AEQOEQJ7.mjs +0 -57
- package/dist/chunk-AZ52IWB6.mjs +0 -16
- package/dist/chunk-CIRN3LZA.mjs +0 -1
- package/dist/chunk-NTQM4EYN.mjs +0 -1
- package/dist/wasm-BGQBTR2J.mjs +0 -1
- package/dist/wasm-SA237OSP.mjs +0 -1
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { D as DrawingScene, d as ShapeTextBodyProperties } from './content-DLFHRQav.mjs';
|
|
4
|
-
import { T as TextModernEffects } from './formatting-D1EPSaJP.mjs';
|
|
1
|
+
import { T as TextModernEffects } from './formatting-BEkIBePP.mjs';
|
|
2
|
+
import { D as DrawingScene, d as ShapeTextBodyProperties } from './content-C3sTRz-u.mjs';
|
|
5
3
|
|
|
6
4
|
interface DisplayList {
|
|
7
5
|
/** Contract version. Undefined reads as legacy version 0. */
|
|
@@ -223,6 +221,8 @@ interface DocAttrs {
|
|
|
223
221
|
paraId?: string;
|
|
224
222
|
fromLine?: number;
|
|
225
223
|
toLine?: number;
|
|
224
|
+
/** Resolved line index within the owning paragraph. */
|
|
225
|
+
lineIndex?: number;
|
|
226
226
|
/**
|
|
227
227
|
* Table cell the primitive paints inside, when any. The a11y mirror builds
|
|
228
228
|
* real ARIA table semantics (role table/row/cell, aria-row/colindex) from
|
|
@@ -764,273 +764,4 @@ declare function applyFrameDelta(previous: RetainedFrame | null, delta: DecodedF
|
|
|
764
764
|
*/
|
|
765
765
|
declare function applyFrameDeltaOwned(previous: RetainedFrame | null, delta: DecodedFrameDelta): RetainedFrame;
|
|
766
766
|
|
|
767
|
-
|
|
768
|
-
* JS seam to the Rust display-list builder (crates/docx-layout).
|
|
769
|
-
*
|
|
770
|
-
* Marshals the same `{ measured, options, layout }` triple the golden
|
|
771
|
-
* fixtures pin (see scripts/export-displaylist-fixtures.ts) across the wasm
|
|
772
|
-
* boundary and parses the resulting DisplayList. All paint/geometry decisions
|
|
773
|
-
* happen in Rust — this module is serialization glue only.
|
|
774
|
-
*
|
|
775
|
-
* The wasm module is loaded lazily via dynamic import on first build, so the
|
|
776
|
-
* ~800KB inlined binary costs nothing until the experimental canvas renderer
|
|
777
|
-
* is actually enabled.
|
|
778
|
-
*
|
|
779
|
-
* @experimental part of the rust-canvas-engine change; shape may evolve.
|
|
780
|
-
*/
|
|
781
|
-
|
|
782
|
-
/**
|
|
783
|
-
* One header/footer part in the `headersFooters` envelope field: the measured
|
|
784
|
-
* blocks of the HF ProseMirror doc identified by `rId`, plus the band metrics
|
|
785
|
-
* `convertHeaderFooterPmDocToContent` computed (passed through verbatim — the
|
|
786
|
-
* Rust builder re-derives nothing).
|
|
787
|
-
*/
|
|
788
|
-
interface DisplayListHfVariant {
|
|
789
|
-
rId: string;
|
|
790
|
-
kind: 'header' | 'footer';
|
|
791
|
-
type: 'default' | 'first' | 'even';
|
|
792
|
-
/** `toMeasuredBlocks(content.blocks, content.measures)` — same schema as body `measured` */
|
|
793
|
-
measured: MeasuredBlock[];
|
|
794
|
-
/** HeaderFooterContent.height (in-flow stack incl. floating blocks) */
|
|
795
|
-
height: number;
|
|
796
|
-
/** HeaderFooterContent.flowHeight (in-flow band height; fallback: height) */
|
|
797
|
-
flowHeight?: number;
|
|
798
|
-
visualTop?: number;
|
|
799
|
-
visualBottom?: number;
|
|
800
|
-
/**
|
|
801
|
-
* Per-page resolved widths of PAGE/NUMPAGES field runs in this HF part, so a
|
|
802
|
-
* centered/right-aligned line carrying such a field re-centers per page. The
|
|
803
|
-
* line width is measured ONCE at the field's fallback text ("1"), so without
|
|
804
|
-
* this the builder holds the same centered position on every page even though
|
|
805
|
-
* "Page 2 of 3"/"Page 10 of 12" have different widths. Omitted ⇒ the fields
|
|
806
|
-
* ride the char-distributed fallback width (byte-identical to before).
|
|
807
|
-
*/
|
|
808
|
-
fieldWidths?: DisplayListFieldWidths[];
|
|
809
|
-
}
|
|
810
|
-
/**
|
|
811
|
-
* Per-page widths of one PAGE/NUMPAGES field run in an HF part. `pmStart` is the
|
|
812
|
-
* field run's position in the HF ProseMirror doc (the key the Rust builder
|
|
813
|
-
* matches). `fallbackWidth` is the width the measure baked into `line.width`
|
|
814
|
-
* (the field's fallback text); `perPage[i]` is the width of the field's resolved
|
|
815
|
-
* text on layout page index `i` (PAGE → that page's number, NUMPAGES → total).
|
|
816
|
-
*/
|
|
817
|
-
interface DisplayListFieldWidths {
|
|
818
|
-
pmStart: number;
|
|
819
|
-
fallbackWidth: number;
|
|
820
|
-
perPage: number[];
|
|
821
|
-
}
|
|
822
|
-
/**
|
|
823
|
-
* Optional header/footer payload of the builder envelope. Absent ⇒ the Rust
|
|
824
|
-
* output is byte-identical to the body-only build. Flags come off the section
|
|
825
|
-
* properties / settings the DOM painter uses; distances are the same px the
|
|
826
|
-
* painter resolves (`headerDistance ?? page.margins.header ?? 48`).
|
|
827
|
-
*/
|
|
828
|
-
interface DisplayListHeadersFooters {
|
|
829
|
-
titlePg?: boolean;
|
|
830
|
-
evenAndOddHeaders?: boolean;
|
|
831
|
-
headerDistance?: number;
|
|
832
|
-
footerDistance?: number;
|
|
833
|
-
/** Page-level Word watermark, painted behind body/header/footer content. */
|
|
834
|
-
watermark?: DisplayListWatermark;
|
|
835
|
-
variants: DisplayListHfVariant[];
|
|
836
|
-
/** Stable section identity. Undefined = document-global legacy envelope. */
|
|
837
|
-
sectionId?: string;
|
|
838
|
-
/** Zero-based section index. */
|
|
839
|
-
sectionIndex?: number;
|
|
840
|
-
}
|
|
841
|
-
type DisplayListWatermark = DisplayListTextWatermark | DisplayListPictureWatermark;
|
|
842
|
-
interface DisplayListTextWatermark {
|
|
843
|
-
kind: 'text';
|
|
844
|
-
text: string;
|
|
845
|
-
font: string;
|
|
846
|
-
color: string;
|
|
847
|
-
semitransparent: boolean;
|
|
848
|
-
layout: 'diagonal' | 'horizontal';
|
|
849
|
-
fontSize?: number;
|
|
850
|
-
/** Undefined defaults to true for watermarks. */
|
|
851
|
-
decorative?: boolean;
|
|
852
|
-
}
|
|
853
|
-
interface DisplayListPictureWatermark {
|
|
854
|
-
kind: 'picture';
|
|
855
|
-
relId?: string;
|
|
856
|
-
dataUrl?: string;
|
|
857
|
-
scale: number;
|
|
858
|
-
washout: boolean;
|
|
859
|
-
widthEmu?: number;
|
|
860
|
-
heightEmu?: number;
|
|
861
|
-
/** Undefined defaults to true for watermarks. */
|
|
862
|
-
decorative?: boolean;
|
|
863
|
-
}
|
|
864
|
-
/** One measured note in a page/section note area. */
|
|
865
|
-
interface DisplayListNoteItem {
|
|
866
|
-
kind?: 'footnote' | 'endnote';
|
|
867
|
-
id?: number;
|
|
868
|
-
displayLabel?: string;
|
|
869
|
-
measured?: MeasuredBlock[];
|
|
870
|
-
height?: number;
|
|
871
|
-
anchorDocStart?: number;
|
|
872
|
-
anchorDocEnd?: number;
|
|
873
|
-
customMarkFollows?: boolean;
|
|
874
|
-
}
|
|
875
|
-
/** Typed non-fragmented note-region input for the Rust display builder. */
|
|
876
|
-
interface DisplayListNoteArea {
|
|
877
|
-
pageIndex?: number;
|
|
878
|
-
sectionId?: string;
|
|
879
|
-
kind?: 'footnote' | 'endnote';
|
|
880
|
-
placement?: 'pageBottom' | 'beneathText' | 'sectEnd' | 'docEnd';
|
|
881
|
-
y?: number;
|
|
882
|
-
height?: number;
|
|
883
|
-
columns?: number;
|
|
884
|
-
separator?: DisplayListNoteItem;
|
|
885
|
-
notes?: DisplayListNoteItem[];
|
|
886
|
-
}
|
|
887
|
-
/** Stable reviewer palette entry for comments/revisions. */
|
|
888
|
-
interface DisplayListCommentAuthor {
|
|
889
|
-
id?: string;
|
|
890
|
-
name?: string;
|
|
891
|
-
paletteIndex?: number;
|
|
892
|
-
color?: string;
|
|
893
|
-
}
|
|
894
|
-
/** One reply of a comment thread (a11y announcement input). */
|
|
895
|
-
interface DisplayListCommentReply {
|
|
896
|
-
id?: number;
|
|
897
|
-
authorId?: string;
|
|
898
|
-
authorName?: string;
|
|
899
|
-
date?: string;
|
|
900
|
-
/** Plain-text body (the builder caps it before it reaches primitives). */
|
|
901
|
-
text?: string;
|
|
902
|
-
}
|
|
903
|
-
/**
|
|
904
|
-
* Per-comment thread metadata keyed by comment id, joined by the builder onto
|
|
905
|
-
* every primitive carrying that id in `commentIds` so the a11y mirror can
|
|
906
|
-
* announce the complete thread (author name, date, body, replies). All string
|
|
907
|
-
* values are file-derived/attacker-controlled; consumers must only ever
|
|
908
|
-
* assign them via textContent/setAttribute.
|
|
909
|
-
*/
|
|
910
|
-
interface DisplayListCommentThread {
|
|
911
|
-
/** Comment id — matches the numeric ids in `resolvedCommentIds`/`commentIds`. */
|
|
912
|
-
id?: number;
|
|
913
|
-
authorId?: string;
|
|
914
|
-
authorName?: string;
|
|
915
|
-
date?: string;
|
|
916
|
-
/** Plain-text body (builder-capped before emission). */
|
|
917
|
-
text?: string;
|
|
918
|
-
/** Replies in thread order (builder-capped count and text). */
|
|
919
|
-
replies?: DisplayListCommentReply[];
|
|
920
|
-
}
|
|
921
|
-
/** The `{ measured, options, layout }` envelope the Rust builder consumes. */
|
|
922
|
-
interface DisplayListBuildInputs {
|
|
923
|
-
/** Serialization contract version. Undefined reads as legacy version 0. */
|
|
924
|
-
contractVersion?: number;
|
|
925
|
-
measured: MeasuredBlock[];
|
|
926
|
-
options: unknown;
|
|
927
|
-
layout: Layout;
|
|
928
|
-
/** header/footer parts + section flags; omitted ⇒ body-only display list */
|
|
929
|
-
headersFooters?: DisplayListHeadersFooters;
|
|
930
|
-
/**
|
|
931
|
-
* Doc-wide font-id chains keyed `"<family lowercase>|<bold 0|1>|<italic 0|1>"`
|
|
932
|
-
* → measurement `FontStore` ids — the SAME map the measurement input carries.
|
|
933
|
-
* Present only under Rust measurement (the ids must belong to a populated
|
|
934
|
-
* store); its presence against that store is what gates GlyphRun emission.
|
|
935
|
-
* Omitted ⇒ every text run takes the browser-measured `TextRunPrimitive` path
|
|
936
|
-
* (byte-identical to the pre-glyph build).
|
|
937
|
-
*/
|
|
938
|
-
fontChains?: Record<string, number[]>;
|
|
939
|
-
/** Page/section note regions. Undefined = no note emission. */
|
|
940
|
-
noteAreas?: DisplayListNoteArea[];
|
|
941
|
-
/** Resolved comments suppressed from active tint. Undefined = none known. */
|
|
942
|
-
resolvedCommentIds?: number[];
|
|
943
|
-
/** Stable reviewer palette. Undefined = legacy hard-coded colors. */
|
|
944
|
-
commentAuthors?: DisplayListCommentAuthor[];
|
|
945
|
-
/** Per-comment thread metadata for a11y announcements. Undefined = none. */
|
|
946
|
-
commentThreads?: DisplayListCommentThread[];
|
|
947
|
-
}
|
|
948
|
-
/** Minimal engine surface, injectable so tests can fake the wasm module. */
|
|
949
|
-
interface RustDisplayListEngine {
|
|
950
|
-
buildDisplayListJson(input: string): string;
|
|
951
|
-
/** Resident editing engines expose binary deltas; the stateless layout wasm does not. */
|
|
952
|
-
buildDisplayListFrame?(input: string, expectedFrameEpoch: number): Uint8Array;
|
|
953
|
-
/** One-owner ordinary input path; available on the resident editing engine. */
|
|
954
|
-
applyInput?(text: string, expectedFrameEpoch: number): Uint8Array;
|
|
955
|
-
displayHitTestRegionsJson?(pageIndex: number, x: number, y: number): string;
|
|
956
|
-
displayRangeRectsJson?(from: number, to: number): string;
|
|
957
|
-
displayRangeRectsRegionJson?(region: 'body' | 'header' | 'footer', rId: string, from: number, to: number): string;
|
|
958
|
-
}
|
|
959
|
-
type RustDisplayListSourceErrorStage = 'load' | 'build' | 'parse' | 'decode' | 'apply';
|
|
960
|
-
interface RustDisplayFrameResult {
|
|
961
|
-
displayList: DisplayList;
|
|
962
|
-
/** Null only on the compatibility JSON engine path. */
|
|
963
|
-
frame: RetainedFrame | null;
|
|
964
|
-
transport: 'frame-delta-v1' | 'json';
|
|
965
|
-
}
|
|
966
|
-
/**
|
|
967
|
-
* Typed terminal error from the mandatory Rust display-list source. Hosts may
|
|
968
|
-
* surface this through their editor error boundary; it is never permission to
|
|
969
|
-
* silently substitute painter geometry.
|
|
970
|
-
*/
|
|
971
|
-
declare class RustDisplayListSourceError extends Error {
|
|
972
|
-
readonly stage: RustDisplayListSourceErrorStage;
|
|
973
|
-
constructor(stage: RustDisplayListSourceErrorStage, cause: unknown);
|
|
974
|
-
}
|
|
975
|
-
/**
|
|
976
|
-
* Query surface over an already-built display list, injectable so tests can
|
|
977
|
-
* fake the wasm module.
|
|
978
|
-
*
|
|
979
|
-
* The `*Json` calls take the display-list JSON string as an argument (the Rust
|
|
980
|
-
* side re-parses it per query — callers should cache the string). The
|
|
981
|
-
* session-handle members parse the list ONCE (`openDisplayList` → handle) and
|
|
982
|
-
* answer many queries by handle with no re-serialization, reusing the same
|
|
983
|
-
* hit/range logic so results are byte-identical. The handle members are
|
|
984
|
-
* OPTIONAL: the embedded wasm carries them only after the integrator re-embeds,
|
|
985
|
-
* so `createDisplayListQueries` feature-detects `hasDisplayListSession` and
|
|
986
|
-
* falls back to the `*Json` path when they are absent.
|
|
987
|
-
*/
|
|
988
|
-
interface RustDisplayListQueryEngine {
|
|
989
|
-
/** region-aware hit test → `{"region","rId"?,"pos"}` or `"null"` JSON */
|
|
990
|
-
hitTestRegionsJson(displayList: string, pageIndex: number, x: number, y: number): string;
|
|
991
|
-
/** body PM range → JSON array of `{pageIndex,x,y,width,height}` rects */
|
|
992
|
-
rangeRectsJson(displayList: string, from: number, to: number): string;
|
|
993
|
-
/**
|
|
994
|
-
* Region-aware PM range → JSON array of rects. `region` is
|
|
995
|
-
* `'body' | 'header' | 'footer'`; `rId` scopes header/footer to one HF part
|
|
996
|
-
* (empty for body / match-any). OPTIONAL: the embedded wasm carries it only
|
|
997
|
-
* after the integrator re-embeds, so `createDisplayListQueries` falls back to
|
|
998
|
-
* `[]` when absent (HF selection geometry stays a documented gap until then).
|
|
999
|
-
*/
|
|
1000
|
-
rangeRectsRegionJson?(displayList: string, region: string, rId: string, from: number, to: number): string;
|
|
1001
|
-
/** true when the embedded wasm carries the region-aware range-rect exports */
|
|
1002
|
-
hasRangeRectsRegion?(): boolean;
|
|
1003
|
-
/** true when the embedded wasm carries the session-handle exports below */
|
|
1004
|
-
hasDisplayListSession?(): boolean;
|
|
1005
|
-
/** parse a display list once, return a handle for the by-handle queries */
|
|
1006
|
-
openDisplayList?(displayList: string): number;
|
|
1007
|
-
/** free a handle's parsed display list */
|
|
1008
|
-
closeDisplayList?(handle: number): void;
|
|
1009
|
-
/** region-aware hit test against a stored display list (by handle) */
|
|
1010
|
-
hitTestRegionsByHandle?(handle: number, pageIndex: number, x: number, y: number): string;
|
|
1011
|
-
/** body PM range against a stored display list (by handle) */
|
|
1012
|
-
rangeRectsByHandle?(handle: number, from: number, to: number): string;
|
|
1013
|
-
/** region-aware PM range against a stored display list (by handle) */
|
|
1014
|
-
rangeRectsRegionByHandle?(handle: number, region: string, rId: string, from: number, to: number): string;
|
|
1015
|
-
}
|
|
1016
|
-
/**
|
|
1017
|
-
* Lazily load the wasm query surface (hit-test + range-rects). Shares the
|
|
1018
|
-
* module promise with `buildRustDisplayList`, so on the canvas-renderer path
|
|
1019
|
-
* the engine is already resolved by the time the first display list lands.
|
|
1020
|
-
*/
|
|
1021
|
-
declare function loadRustDisplayListQueryEngine(): Promise<RustDisplayListQueryEngine>;
|
|
1022
|
-
/** Display-only fields sent to an engine that already retains pagination. */
|
|
1023
|
-
declare function encodeDisplayListFrameExtras(inputs: DisplayListBuildInputs): string;
|
|
1024
|
-
/**
|
|
1025
|
-
* Build a DisplayList for a computed layout through the Rust engine. Throws
|
|
1026
|
-
* when the wasm module fails to load or the builder rejects the input — the
|
|
1027
|
-
* caller is expected to fall back to the DOM painter.
|
|
1028
|
-
*/
|
|
1029
|
-
declare function buildRustDisplayList(inputs: DisplayListBuildInputs, engine?: RustDisplayListEngine): Promise<DisplayList>;
|
|
1030
|
-
/**
|
|
1031
|
-
* Production display build. Resident editing engines return FrameDelta v1;
|
|
1032
|
-
* older/stateless engines retain the full-JSON parity path.
|
|
1033
|
-
*/
|
|
1034
|
-
declare function buildRustDisplayFrame(inputs: DisplayListBuildInputs, engine?: RustDisplayListEngine, previous?: RetainedFrame | null): Promise<RustDisplayFrameResult>;
|
|
1035
|
-
|
|
1036
|
-
export { applyFrameDeltaOwned as A, buildRustDisplayFrame as B, buildRustDisplayList as C, type DisplayListHeadersFooters as D, decodeFrameDelta as E, FRAME_DELTA_HEADER_BYTES as F, type GlyphRunPrimitive as G, type HfRegion as H, type ImagePrimitive as I, encodeDisplayListFrameExtras as J, loadRustDisplayListQueryEngine as K, type LinePrimitive as L, type PositionedGlyph as P, type RustDisplayListQueryEngine as R, type TextRunPrimitive as T, type DisplayList as a, type DisplayPage as b, type DisplayPrimitive as c, type DecodedFrameDelta as d, type DecorationPrimitive as e, type DisplayBounds as f, type DisplayListBuildInputs as g, type DisplayListHfVariant as h, type DisplayListPictureWatermark as i, type DisplayListTextWatermark as j, type DisplayListWatermark as k, type DocAttrs as l, FRAME_DELTA_PAGE_OP_BYTES as m, FRAME_DELTA_VERSION as n, FrameDeltaError as o, type FrameDeltaErrorCode as p, type FramePageOperation as q, type RectPrimitive as r, type RetainedFrame as s, type RetainedFramePage as t, type RustDisplayFrameResult as u, type RustDisplayListEngine as v, RustDisplayListSourceError as w, type RustDisplayListSourceErrorStage as x, type TableCellRef as y, applyFrameDelta as z };
|
|
767
|
+
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 };
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Document } from './types/document.mjs';
|
|
2
|
+
import { R as RetainedFrame } from './frameDelta-B2kC6XiP.mjs';
|
|
2
3
|
|
|
3
4
|
type CollaborationUpdateOrigin = 'local' | 'remote';
|
|
4
5
|
interface CollaborationReplica {
|
|
@@ -45,6 +46,43 @@ interface CollaborationProviderOptions {
|
|
|
45
46
|
maxFrameBytes?: number;
|
|
46
47
|
maxMessagesPerFrame?: number;
|
|
47
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;
|
|
48
86
|
}
|
|
49
87
|
type CollaborationStatusListener = (change: CollaborationStatusChange) => void;
|
|
50
88
|
type CollaborationErrorListener = (error: CollaborationError) => void;
|
|
@@ -80,12 +118,32 @@ declare function displayPositionToYrsLoc(map: YrsInputPositionMap, position: num
|
|
|
80
118
|
/** Compare two Locs in document order using one live map. */
|
|
81
119
|
declare function compareYrsLocs(map: YrsInputPositionMap, a: YrsLoc, b: YrsLoc): number;
|
|
82
120
|
|
|
121
|
+
/** Resolved styling for the worker-painted caret (the worker cannot read CSS vars). */
|
|
122
|
+
interface ResidentCaretPaintStyle {
|
|
123
|
+
color: string;
|
|
124
|
+
/** CSS-px stroke width, matching the DOM caret's un-zoomed width. */
|
|
125
|
+
width: number;
|
|
126
|
+
}
|
|
127
|
+
/** Device-px caret rect: geometry scales by dpr*zoom, stroke width by dpr only
|
|
128
|
+
* (the DOM caret keeps its CSS-px width across zoom levels). */
|
|
129
|
+
declare function residentCaretDeviceRect(rect: Pick<YrsResidentCaretRect, 'x' | 'y' | 'height'>, style: ResidentCaretPaintStyle, devicePixelRatio: number, zoom: number): {
|
|
130
|
+
x: number;
|
|
131
|
+
y: number;
|
|
132
|
+
width: number;
|
|
133
|
+
height: number;
|
|
134
|
+
};
|
|
135
|
+
declare function residentCaretSnapshotForFrame(snapshot: YrsResidentCaretSnapshot, frame: RetainedFrame): YrsResidentCaretSnapshot | null;
|
|
136
|
+
|
|
83
137
|
interface ResidentEngineWorkerFrame {
|
|
84
138
|
frame: Uint8Array;
|
|
85
139
|
updates: Uint8Array[];
|
|
86
140
|
engineMs: number;
|
|
87
141
|
workerTotalMs: number;
|
|
88
142
|
engineProfile?: YrsEngineApplyProfile;
|
|
143
|
+
caret: YrsResidentCaretSnapshot;
|
|
144
|
+
selection: YrsSelection | null;
|
|
145
|
+
/** The presented frame carries the worker-painted caret line. */
|
|
146
|
+
caretPainted: boolean;
|
|
89
147
|
replayMs: number;
|
|
90
148
|
replayedPages: number;
|
|
91
149
|
layoutRevision: number;
|
|
@@ -105,22 +163,34 @@ declare class ResidentEngineWorkerClient {
|
|
|
105
163
|
private destroyed;
|
|
106
164
|
private ready;
|
|
107
165
|
private revision;
|
|
166
|
+
private remoteVector;
|
|
167
|
+
private appliedFontsRevision;
|
|
108
168
|
constructor();
|
|
109
169
|
isReady(): boolean;
|
|
110
170
|
layoutRevision(): number;
|
|
171
|
+
/** The worker replica's last reported yrs state vector (null before any). */
|
|
172
|
+
remoteStateVector(): Uint8Array | null;
|
|
173
|
+
/** The fonts revision this worker last applied (null before bootstrap). */
|
|
174
|
+
syncedFontsRevision(): number | null;
|
|
111
175
|
bootstrap(snapshot: YrsResidentWorkerSnapshot, extras: string): Promise<ResidentEngineWorkerFrame>;
|
|
112
|
-
sync(snapshot: YrsResidentWorkerSnapshot, extras: string, expectedFrameEpoch: number): Promise<ResidentEngineWorkerFrame>;
|
|
113
|
-
buildFrame(extras: string, expectedFrameEpoch: number): Promise<ResidentEngineWorkerFrame>;
|
|
114
|
-
applyInput(text: string, selection: YrsSelection, expectedFrameEpoch: number, profile?: boolean): Promise<ResidentEngineWorkerApplyResult | {
|
|
176
|
+
sync(snapshot: YrsResidentWorkerSnapshot, extras: string, expectedFrameEpoch: number, paintCaret?: boolean): Promise<ResidentEngineWorkerFrame>;
|
|
177
|
+
buildFrame(extras: string, expectedFrameEpoch: number, paintCaret?: boolean): Promise<ResidentEngineWorkerFrame>;
|
|
178
|
+
applyInput(text: string, selection: YrsSelection, expectedFrameEpoch: number, profile?: boolean, paintCaret?: boolean): Promise<ResidentEngineWorkerApplyResult | {
|
|
115
179
|
applied: false;
|
|
116
180
|
}>;
|
|
117
|
-
applyDelete(direction: 'backward' | 'forward', selection: YrsSelection, expectedFrameEpoch: number, profile?: boolean): Promise<ResidentEngineWorkerApplyResult | {
|
|
181
|
+
applyDelete(direction: 'backward' | 'forward', selection: YrsSelection, expectedFrameEpoch: number, profile?: boolean, paintCaret?: boolean): Promise<ResidentEngineWorkerApplyResult | {
|
|
118
182
|
applied: false;
|
|
119
183
|
}>;
|
|
184
|
+
/** Drop the worker-painted caret line by re-presenting the caret page's
|
|
185
|
+
* retained raster. Fire-and-forget and idempotent. */
|
|
186
|
+
eraseCaret(): void;
|
|
120
187
|
invalidate(update: Uint8Array, selection: YrsSelection | null): void;
|
|
121
|
-
attachCanvases(pages: ResidentEngineOffscreenPage[], activePageIds: string[], devicePixelRatio: number, zoom: number): Promise<void>;
|
|
188
|
+
attachCanvases(pages: ResidentEngineOffscreenPage[], activePageIds: string[], devicePixelRatio: number, zoom: number, caretStyle: ResidentCaretPaintStyle): Promise<void>;
|
|
122
189
|
destroy(): void;
|
|
123
190
|
private request;
|
|
191
|
+
/** Record a successfully applied bootstrap/sync payload's fonts revision.
|
|
192
|
+
* The state vector is tracked centrally in `onmessage`. */
|
|
193
|
+
private recordSync;
|
|
124
194
|
private failAll;
|
|
125
195
|
}
|
|
126
196
|
declare function canUseResidentEngineWorker(): boolean;
|
|
@@ -184,6 +254,12 @@ declare function yrsToDocument(session: YrsSession, base: Document, options?: Yr
|
|
|
184
254
|
* from its offset space). Story-global indices never cross this boundary.
|
|
185
255
|
*/
|
|
186
256
|
|
|
257
|
+
interface YrsDocxHost {
|
|
258
|
+
document: Document;
|
|
259
|
+
referencedFonts: string[];
|
|
260
|
+
embeddedFonts: Map<string, ArrayBuffer>;
|
|
261
|
+
fontTableRelationshipsXml?: string;
|
|
262
|
+
}
|
|
187
263
|
/** Durable authorship metadata for one suggested (tracked-change) operation. */
|
|
188
264
|
interface YrsAuthor {
|
|
189
265
|
name: string;
|
|
@@ -196,6 +272,11 @@ interface YrsLoc {
|
|
|
196
272
|
paraId: string;
|
|
197
273
|
offset: number;
|
|
198
274
|
}
|
|
275
|
+
/** One binary Yrs position that transforms with collaborative edits. */
|
|
276
|
+
interface YrsStickyPosition {
|
|
277
|
+
story: string;
|
|
278
|
+
encoded: Uint8Array;
|
|
279
|
+
}
|
|
199
280
|
/** A paragraph-addressed position without the story (used inside {@link YrsStoryRange}). */
|
|
200
281
|
interface YrsParaOffset {
|
|
201
282
|
paraId: string;
|
|
@@ -523,6 +604,20 @@ interface YrsSelection {
|
|
|
523
604
|
anchor: YrsLoc;
|
|
524
605
|
head: YrsLoc;
|
|
525
606
|
}
|
|
607
|
+
interface YrsResidentCaretRect {
|
|
608
|
+
pageIndex: number;
|
|
609
|
+
pageId: string;
|
|
610
|
+
x: number;
|
|
611
|
+
y: number;
|
|
612
|
+
height: number;
|
|
613
|
+
}
|
|
614
|
+
interface YrsResidentCaretSnapshot {
|
|
615
|
+
frameEpoch: number;
|
|
616
|
+
caretRect: YrsResidentCaretRect | null;
|
|
617
|
+
/** Selection the rect was computed for. Absent on raw engine snapshots. */
|
|
618
|
+
selection?: YrsSelection | null;
|
|
619
|
+
}
|
|
620
|
+
declare function sameYrsSelection(left: YrsSelection | null, right: YrsSelection | null): boolean;
|
|
526
621
|
/** Opt-in internal stage timings for one resident engine input. @internal */
|
|
527
622
|
interface YrsEngineApplyProfile {
|
|
528
623
|
selectionMs: number;
|
|
@@ -546,9 +641,15 @@ interface YrsEngineApplyProfile {
|
|
|
546
641
|
*/
|
|
547
642
|
interface YrsResidentWorkerSnapshot {
|
|
548
643
|
clientId: number;
|
|
644
|
+
/** Full document state, or a state-vector diff when the caller supplied
|
|
645
|
+
* the worker's known vector — both apply through the same merge path. */
|
|
549
646
|
state: Uint8Array;
|
|
550
647
|
selection: YrsSelection | null;
|
|
648
|
+
/** Empty when the caller declared the worker's fonts current
|
|
649
|
+
* (`knownFontsRevision` matches); the worker then keeps its registrations. */
|
|
551
650
|
fonts: Uint8Array[];
|
|
651
|
+
/** Monotonic revision of the resident font set (bumped by register/clear). */
|
|
652
|
+
fontsRevision: number;
|
|
552
653
|
renderInputs: Array<{
|
|
553
654
|
story: string;
|
|
554
655
|
env: YrsRenderEnv;
|
|
@@ -558,6 +659,18 @@ interface YrsResidentWorkerSnapshot {
|
|
|
558
659
|
layoutWithRegions: boolean;
|
|
559
660
|
layoutRevision: number;
|
|
560
661
|
}
|
|
662
|
+
/**
|
|
663
|
+
* What the sync target already holds, so a snapshot can ship deltas instead
|
|
664
|
+
* of the whole world.
|
|
665
|
+
*
|
|
666
|
+
* @internal
|
|
667
|
+
*/
|
|
668
|
+
interface YrsResidentWorkerSyncOptions {
|
|
669
|
+
/** The worker replica's last reported yrs state vector. */
|
|
670
|
+
knownStateVector?: Uint8Array | null;
|
|
671
|
+
/** The `fontsRevision` the worker last applied. */
|
|
672
|
+
knownFontsRevision?: number | null;
|
|
673
|
+
}
|
|
561
674
|
/** A range-aggregated toggle mark. @public */
|
|
562
675
|
type YrsTriState = boolean | 'mixed';
|
|
563
676
|
/**
|
|
@@ -716,6 +829,8 @@ interface YrsSession extends CollaborationReplica {
|
|
|
716
829
|
buildDisplayListJson(input: string): string;
|
|
717
830
|
/** Build a binary FrameDelta v1 against the last host-applied frame. */
|
|
718
831
|
buildDisplayListFrame(input: string, expectedFrameEpoch: number): Uint8Array;
|
|
832
|
+
/** Caret geometry from the current resident display frame. */
|
|
833
|
+
residentCaretSnapshot(): YrsResidentCaretSnapshot;
|
|
719
834
|
/** Apply a collapsed plain-text insertion and return its resident FrameDelta. */
|
|
720
835
|
applyInput(text: string, expectedFrameEpoch: number): Uint8Array;
|
|
721
836
|
/** Apply a collapsed character deletion/paragraph merge and return its resident FrameDelta. */
|
|
@@ -731,15 +846,31 @@ interface YrsSession extends CollaborationReplica {
|
|
|
731
846
|
profile: YrsEngineApplyProfile;
|
|
732
847
|
};
|
|
733
848
|
/** Snapshot the inputs needed to move resident layout ownership to a worker. */
|
|
734
|
-
residentWorkerSnapshot(): YrsResidentWorkerSnapshot | null;
|
|
849
|
+
residentWorkerSnapshot(options?: YrsResidentWorkerSyncOptions): YrsResidentWorkerSnapshot | null;
|
|
850
|
+
/**
|
|
851
|
+
* Cheap worker-sync probe: the resident layout revision when a worker
|
|
852
|
+
* snapshot would be available, without encoding document state or copying
|
|
853
|
+
* font bytes. Steady-state frame builds consult this instead of building a
|
|
854
|
+
* full snapshot.
|
|
855
|
+
*/
|
|
856
|
+
residentWorkerProbe(): {
|
|
857
|
+
layoutRevision: number;
|
|
858
|
+
} | null;
|
|
735
859
|
/** Resident display-list hit/range queries; results are small JSON records. */
|
|
736
860
|
displayHitTestRegionsJson(pageIndex: number, x: number, y: number): string;
|
|
861
|
+
displayVerticalMoveJson(position: number, direction: 'up' | 'down', goalX: number): string;
|
|
737
862
|
displayRangeRectsJson(from: number, to: number): string;
|
|
738
863
|
displayRangeRectsRegionJson(region: 'body' | 'header' | 'footer', rId: string, from: number, to: number): string;
|
|
739
864
|
/** Read a glyph outline from the session's resident font store. */
|
|
740
865
|
outlineGlyphJson(fontId: number, glyphId: number): string;
|
|
741
866
|
/** Hydrates from an encoded yrs v1 update (typically a peer's {@link encodeState} output). */
|
|
742
867
|
loadState(update: Uint8Array): void;
|
|
868
|
+
/** Parses a DOCX, seeds its stories, and returns thin host metadata. */
|
|
869
|
+
seedFromDocx(bytes: Uint8Array): YrsDocxHost;
|
|
870
|
+
/** Parses a DOCX and optionally seeds its stories. */
|
|
871
|
+
openDocx(bytes: Uint8Array, seedStories: boolean): YrsDocxHost;
|
|
872
|
+
/** Materializes the retained canonical package for compatibility APIs. */
|
|
873
|
+
materializeDocx(): Document | null;
|
|
743
874
|
/**
|
|
744
875
|
* Seeds stories from parsed content (S1 scaffold; the real
|
|
745
876
|
* `load(ParsedDocument)` lands with the ops track). Returns paraIds per
|
|
@@ -753,7 +884,7 @@ interface YrsSession extends CollaborationReplica {
|
|
|
753
884
|
/** Full state, or only the state missing from a peer vector. */
|
|
754
885
|
encodeStateAsUpdate(remoteStateVector?: Uint8Array): Uint8Array;
|
|
755
886
|
/** Applies a remote/incremental yrs v1 update. */
|
|
756
|
-
applyUpdate(update: Uint8Array):
|
|
887
|
+
applyUpdate(update: Uint8Array): CollaborationTextInsertion | null;
|
|
757
888
|
/** Apply a same-user worker update under the local undo origin. @internal */
|
|
758
889
|
applyLocalUpdate(update: Uint8Array, story: string): void;
|
|
759
890
|
/**
|
|
@@ -761,10 +892,18 @@ interface YrsSession extends CollaborationReplica {
|
|
|
761
892
|
* applied-remote). Returns an unsubscribe function.
|
|
762
893
|
*/
|
|
763
894
|
onUpdate(listener: (update: Uint8Array, origin: CollaborationUpdateOrigin) => void): () => void;
|
|
895
|
+
/** Encode one location as a binary Yrs sticky position. */
|
|
896
|
+
encodeStickyPosition(loc: YrsLoc): YrsStickyPosition;
|
|
897
|
+
/** Resolve a binary Yrs sticky position against this replica. */
|
|
898
|
+
resolveStickyPosition(position: YrsStickyPosition): YrsLoc | null;
|
|
764
899
|
/** Store this peer's awareness selection as sticky positions. */
|
|
765
900
|
setSelection(anchor: YrsLoc, head?: YrsLoc): void;
|
|
766
901
|
/** Resolve this peer's current sticky selection, or null before initialization. */
|
|
767
902
|
selection(): YrsSelection | null;
|
|
903
|
+
/** Encode the current selection as binary Yrs sticky indices. */
|
|
904
|
+
encodeSelection(): CollaborationCursor | null;
|
|
905
|
+
/** Resolve a peer's binary Yrs sticky indices against this replica. */
|
|
906
|
+
resolveSelection(cursor: CollaborationCursor): YrsSelection | null;
|
|
768
907
|
/** Store this peer's rectangular table selection outside the document. */
|
|
769
908
|
setCellSelection(range: YrsTableRange): void;
|
|
770
909
|
/** Resolve the current sticky cell selection, or null before initialization. */
|
|
@@ -931,4 +1070,4 @@ interface CreateYrsSessionOptions {
|
|
|
931
1070
|
*/
|
|
932
1071
|
declare function createYrsSession(options?: CreateYrsSessionOptions): Promise<YrsSession>;
|
|
933
1072
|
|
|
934
|
-
export { type
|
|
1073
|
+
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 };
|
package/dist/layout/index.d.mts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
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';
|
|
2
|
+
import { S as SectionProperties, H as HeaderFooter } from '../content-C3sTRz-u.mjs';
|
|
3
|
+
export { D as DrawingScene, T as DrawingSceneNode, c as ShapeEffect, aU as ShapeFillPaint, aV as ShapeStrokePaint, d as ShapeTextBodyProperties } from '../content-C3sTRz-u.mjs';
|
|
2
4
|
import { Document } from '../types/document.mjs';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import '../formatting-D1EPSaJP.mjs';
|
|
6
|
-
import '../styles-Dn_o3Vo5.mjs';
|
|
5
|
+
import { a as DisplayListQueries, D as DisplayListRect } from '../displayListQueries-DLzpvJV6.mjs';
|
|
6
|
+
import '../formatting-BEkIBePP.mjs';
|
|
7
7
|
import '../docx/wrapTypes.mjs';
|
|
8
|
-
import '../
|
|
9
|
-
import '../
|
|
8
|
+
import '../styles-BK3Jecxs.mjs';
|
|
9
|
+
import '../frameDelta-B2kC6XiP.mjs';
|
|
10
|
+
import '../rustDisplayList-B0M2eBkU.mjs';
|
|
11
|
+
import '../types-C1rv3KM-.mjs';
|
|
10
12
|
import './pagination/index.mjs';
|
|
11
13
|
|
|
12
14
|
/**
|
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-
|
|
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};
|