@betteroffice/docx 0.0.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.
- package/LICENSE +201 -0
- package/README.md +41 -0
- package/dist/Subscribable-DOz6Ohoo.d.mts +33 -0
- package/dist/agent/index.d.mts +531 -0
- package/dist/agent/index.mjs +1 -0
- package/dist/chunk-34K66SY4.mjs +1 -0
- package/dist/chunk-3UBMCDME.mjs +1 -0
- package/dist/chunk-4RCISPPE.mjs +1 -0
- package/dist/chunk-4UD54UM5.mjs +1 -0
- package/dist/chunk-52GB3Y42.mjs +1 -0
- package/dist/chunk-6NEKRDXF.mjs +1 -0
- package/dist/chunk-6PW4CWUG.mjs +1 -0
- package/dist/chunk-7DEIW7FL.mjs +1 -0
- package/dist/chunk-7PCO5I2O.mjs +1 -0
- package/dist/chunk-BI3B33LI.mjs +1 -0
- package/dist/chunk-BIQWVK5P.mjs +2 -0
- package/dist/chunk-CIRN3LZA.mjs +1 -0
- package/dist/chunk-DXKG3HQ5.mjs +16 -0
- package/dist/chunk-EUUIJVM6.mjs +0 -0
- package/dist/chunk-FPZBTOD6.mjs +1 -0
- package/dist/chunk-FZIA7OFY.mjs +1 -0
- package/dist/chunk-GWKJ2Y4Y.mjs +1 -0
- package/dist/chunk-H3JCIGWK.mjs +1 -0
- package/dist/chunk-HJGAQIU7.mjs +2 -0
- package/dist/chunk-I6KKMUUC.mjs +1 -0
- package/dist/chunk-IL5JZJT7.mjs +1 -0
- package/dist/chunk-JY6ILTNS.mjs +1 -0
- package/dist/chunk-KEE52TT5.mjs +1 -0
- package/dist/chunk-KVKLLTDP.mjs +58 -0
- package/dist/chunk-KXNZFTTK.mjs +1 -0
- package/dist/chunk-L5ISVQ3W.mjs +1 -0
- package/dist/chunk-LDUWIM7M.mjs +1 -0
- package/dist/chunk-N5Q3YN64.mjs +1 -0
- package/dist/chunk-NEWOMDTX.mjs +1 -0
- package/dist/chunk-O2QSE2I7.mjs +1 -0
- package/dist/chunk-OBQGPMPQ.mjs +1 -0
- package/dist/chunk-OJOHXQNQ.mjs +1 -0
- package/dist/chunk-OMR3TWCD.mjs +2 -0
- package/dist/chunk-P3KDV4M2.mjs +1 -0
- package/dist/chunk-Q7PO7V73.mjs +1 -0
- package/dist/chunk-QOUFE3VX.mjs +1 -0
- package/dist/chunk-SINEY6ZF.mjs +1 -0
- package/dist/chunk-T4EZMUXM.mjs +1 -0
- package/dist/chunk-TTRUPDAB.mjs +1 -0
- package/dist/chunk-TYHI7RAD.mjs +1 -0
- package/dist/chunk-UIEJWORW.mjs +1 -0
- package/dist/chunk-VAOUFAUH.mjs +1 -0
- package/dist/chunk-VBOTMRXV.mjs +1 -0
- package/dist/chunk-VCER63GQ.mjs +1 -0
- package/dist/chunk-WAUF2UC7.mjs +2 -0
- package/dist/chunk-WRWRCBLK.mjs +1 -0
- package/dist/chunk-X4XDO3LZ.mjs +1 -0
- package/dist/chunk-XQBCCJBO.mjs +9 -0
- package/dist/chunk-XWUOLYRQ.mjs +2 -0
- package/dist/chunk-XYH6XWP3.mjs +10 -0
- package/dist/chunk-YBIM6UJV.mjs +8 -0
- package/dist/chunk-YCIH2Q3E.mjs +1 -0
- package/dist/chunk-YUOKI2HB.mjs +1 -0
- package/dist/chunk-ZOV5KL7C.mjs +1 -0
- package/dist/colorResolver-n0o7H7ep.d.mts +290 -0
- package/dist/content-sSHuWw49.d.mts +2202 -0
- package/dist/core-plugins.d.mts +37 -0
- package/dist/core-plugins.mjs +1 -0
- package/dist/core.d.mts +451 -0
- package/dist/core.mjs +1 -0
- package/dist/displayListQueries-p-ijSzdh.d.mts +222 -0
- package/dist/docx/index.d.mts +618 -0
- package/dist/docx/index.mjs +2 -0
- package/dist/docx/parser.d.mts +41 -0
- package/dist/docx/parser.mjs +1 -0
- package/dist/docx/rezip.d.mts +148 -0
- package/dist/docx/rezip.mjs +1 -0
- package/dist/docx/serializer/index.d.mts +42 -0
- package/dist/docx/serializer/index.mjs +1 -0
- package/dist/docx/wrapTypes.d.mts +19 -0
- package/dist/docx/wrapTypes.mjs +1 -0
- package/dist/docxInput-DTbCa48g.d.mts +21 -0
- package/dist/editor/index.d.mts +170 -0
- package/dist/editor/index.mjs +1 -0
- package/dist/editorTree-DO5PyDK8.d.mts +37 -0
- package/dist/executor-7O2RBJ2B.mjs +1 -0
- package/dist/fontLoader-Bx6DK6-2.d.mts +327 -0
- package/dist/formatting-DoL7KBSL.d.mts +823 -0
- package/dist/generated/edit/docx_edit_bg.wasm +0 -0
- package/dist/generated/layout/docx_layout_bg.wasm +0 -0
- package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
- package/dist/generated/parse/docx_parse_bg.wasm +0 -0
- package/dist/headerFooterLayout-0zPT64Qc.d.mts +316 -0
- package/dist/headless.d.mts +69 -0
- package/dist/headless.mjs +1 -0
- package/dist/layout/flow/index.d.mts +149 -0
- package/dist/layout/flow/index.mjs +1 -0
- package/dist/layout/index.d.mts +307 -0
- package/dist/layout/index.mjs +1 -0
- package/dist/layout/measure/index.d.mts +324 -0
- package/dist/layout/measure/index.mjs +1 -0
- package/dist/layout/pagination/index.d.mts +60 -0
- package/dist/layout/pagination/index.mjs +1 -0
- package/dist/layout/pagination/types.d.mts +4 -0
- package/dist/layout/pagination/types.mjs +1 -0
- package/dist/layout/render/index.d.mts +733 -0
- package/dist/layout/render/index.mjs +1 -0
- package/dist/loadWasmAsset-CMvnVkfA.d.mts +3 -0
- package/dist/managers/AutoSaveManager.d.mts +81 -0
- package/dist/managers/AutoSaveManager.mjs +1 -0
- package/dist/managers/TableSelectionManager.d.mts +74 -0
- package/dist/managers/TableSelectionManager.mjs +1 -0
- package/dist/managers/types.d.mts +113 -0
- package/dist/managers/types.mjs +0 -0
- package/dist/mcp-cli.mjs +142 -0
- package/dist/mcp.d.mts +162 -0
- package/dist/mcp.mjs +16 -0
- package/dist/measureBlocksPipeline-Df0Bbrwy.d.mts +109 -0
- package/dist/measuredBlock-DZwz8zhD.d.mts +26 -0
- package/dist/plugin-api/RenderedDomContext.d.mts +114 -0
- package/dist/plugin-api/RenderedDomContext.mjs +1 -0
- package/dist/plugin-api/index.d.mts +7 -0
- package/dist/plugin-api/index.mjs +0 -0
- package/dist/plugin-api/resolveItemPositions.d.mts +39 -0
- package/dist/plugin-api/resolveItemPositions.mjs +1 -0
- package/dist/plugin-api/types.d.mts +193 -0
- package/dist/plugin-api/types.mjs +0 -0
- package/dist/processTemplate-HDUIZFJ5.mjs +1 -0
- package/dist/registry-DMM5VTdT.d.mts +165 -0
- package/dist/rustDisplayList-dqunvwxH.d.mts +1036 -0
- package/dist/rustPagination-Bj2hq013.d.mts +106 -0
- package/dist/sectionConfigs-DW3J8q0X.d.mts +55 -0
- package/dist/selectionContext-Buc9BCU1.d.mts +570 -0
- package/dist/selectiveSave-oFBJ1n71.d.mts +16 -0
- package/dist/selectiveXmlPatch-ypkxlTD_.d.mts +23 -0
- package/dist/settingsParser-CcGvtmCK.d.mts +33 -0
- package/dist/styles/index.d.mts +162 -0
- package/dist/styles/index.mjs +1 -0
- package/dist/styles-VxNcXLdi.d.mts +189 -0
- package/dist/types/agentApi.d.mts +456 -0
- package/dist/types/agentApi.mjs +1 -0
- package/dist/types/content.d.mts +3 -0
- package/dist/types/content.mjs +1 -0
- package/dist/types/document.d.mts +117 -0
- package/dist/types/document.mjs +1 -0
- package/dist/types-DNrYr6yQ.d.mts +1754 -0
- package/dist/types-dYdjUZMo.d.mts +311 -0
- package/dist/units-O5Y02RKQ.d.mts +34 -0
- package/dist/utils/autoScroll.d.mts +24 -0
- package/dist/utils/autoScroll.mjs +1 -0
- package/dist/utils/cardStyles.d.mts +22 -0
- package/dist/utils/cardStyles.mjs +1 -0
- package/dist/utils/comments.d.mts +120 -0
- package/dist/utils/comments.mjs +4 -0
- package/dist/utils/findReplace.d.mts +114 -0
- package/dist/utils/findReplace.mjs +2 -0
- package/dist/utils/findVerticalScrollParent.d.mts +25 -0
- package/dist/utils/findVerticalScrollParent.mjs +1 -0
- package/dist/utils/fontOptions.d.mts +21 -0
- package/dist/utils/fontOptions.mjs +1 -0
- package/dist/utils/headingCollector.d.mts +28 -0
- package/dist/utils/headingCollector.mjs +1 -0
- package/dist/utils/highlightColors.d.mts +14 -0
- package/dist/utils/highlightColors.mjs +1 -0
- package/dist/utils/index.d.mts +956 -0
- package/dist/utils/index.mjs +84 -0
- package/dist/utils/listState.d.mts +27 -0
- package/dist/utils/listState.mjs +1 -0
- package/dist/utils/reportIssue.d.mts +23 -0
- package/dist/utils/reportIssue.mjs +2 -0
- package/dist/utils/sidebarConstants.d.mts +10 -0
- package/dist/utils/sidebarConstants.mjs +1 -0
- package/dist/utils/stylePreview.d.mts +70 -0
- package/dist/utils/stylePreview.mjs +1 -0
- package/dist/utils/textSelection.d.mts +92 -0
- package/dist/utils/textSelection.mjs +1 -0
- package/dist/utils/units.d.mts +78 -0
- package/dist/utils/units.mjs +1 -0
- package/dist/variableDetector-Borj29SF.d.mts +115 -0
- package/dist/wasm-FZQ5XB2Y.mjs +1 -0
- package/dist/wasm-SA237OSP.mjs +1 -0
- package/dist/wasm-edit.d.mts +473 -0
- package/dist/wasm-edit.mjs +1 -0
- package/dist/wasm-layout.d.mts +112 -0
- package/dist/wasm-layout.mjs +1 -0
- package/dist/wasm-opc.d.mts +16 -0
- package/dist/wasm-opc.mjs +1 -0
- package/dist/wasm-parse.d.mts +18 -0
- package/dist/wasm-parse.mjs +1 -0
- package/dist/watermarkApi-DCxjutkg.d.mts +38 -0
- package/dist/yrs/index.d.mts +882 -0
- package/dist/yrs/index.mjs +1 -0
- package/dist/yrs/residentEngineWorker.d.mts +2 -0
- package/dist/yrs/residentEngineWorker.mjs +1 -0
- package/package.json +365 -0
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
export { ToLayoutBlocksOptions, convertBorderSpecToLayout, demoteBlockLikeFloatingTables, isBlockLikeFloatingTable, resetBlockIdCounter, resolveListTemplate, toLayoutBlocks } from './flow/index.mjs';
|
|
2
|
+
import { ao as TableBlock, P as PageMargins, e as LayoutBlock, H as HeaderFooterContent, B as BlockExtent, ar as TableExtent, C as ColumnLayout } from '../types-DNrYr6yQ.mjs';
|
|
3
|
+
export { F as FloatPageGeometry, a as FloatingExclusionRect, b as FloatingImageZone, c as FloatingLineSegmentZone, M as MeasureBlockFn, d as clampFloatingWrapMargins, g as getFloatingMargins, m as measureBlocksWithFloats, r as rectsToFloatingZones } from '../measureBlocksPipeline-Df0Bbrwy.mjs';
|
|
4
|
+
export { BundledFontProvider, EmbeddedFaceInput, FontScript, FontStyle, RustMeasureSource, RustMeasureStats, RustTextEngine, createRustMeasureSource, getRustTextEngine, hashParagraphBlock } from './measure/index.mjs';
|
|
5
|
+
export { C as ConvertFootnoteOptions, a as ConvertHeaderFooterOptions, F as FOOTNOTE_COLUMN_GAP_PX, b as FOOTNOTE_SEPARATOR_HEIGHT, c as FootnoteRefLocation, H as HeaderFooterMetrics, M as MAX_FOOTNOTE_LAYOUT_PASSES, d as MeasureBlocksFn, S as StabilizeFootnoteLayoutArgs, e as StabilizeFootnoteLayoutResult, f as applyFootnotePresentation, g as buildFootnoteContentMap, h as buildFootnoteRenderItems, i as calculateFootnoteReservedHeights, j as calculateHeaderFooterVisualBounds, k as collectFootnoteRefs, l as computeHfCaretRectsFromDisplayList, m as computeHfSelectionRectsFromDisplayList, n as contributesToHeaderFooterFlowHeight, o as convertFootnoteToContent, p as convertHeaderFooterToContent, q as distributeFootnotesIntoColumns, r as footnoteReservedHeightsEqual, s as mapFootnotesToPages, t as normalizeHeaderFooterMeasureBlocks, u as resolveHeaderFooterVisualTop, v as stabilizeFootnoteLayout } from '../headerFooterLayout-0zPT64Qc.mjs';
|
|
6
|
+
import { S as SectionLayoutConfig } from '../sectionConfigs-DW3J8q0X.mjs';
|
|
7
|
+
import { Document } from '../types/document.mjs';
|
|
8
|
+
import { S as SectionProperties, m as HeaderFooter } from '../content-sSHuWw49.mjs';
|
|
9
|
+
import '../editorTree-DO5PyDK8.mjs';
|
|
10
|
+
import '../formatting-DoL7KBSL.mjs';
|
|
11
|
+
import '../settingsParser-CcGvtmCK.mjs';
|
|
12
|
+
import '../styles-VxNcXLdi.mjs';
|
|
13
|
+
import '../measuredBlock-DZwz8zhD.mjs';
|
|
14
|
+
import '../displayListQueries-p-ijSzdh.mjs';
|
|
15
|
+
import '../rustDisplayList-dqunvwxH.mjs';
|
|
16
|
+
import '../docx/wrapTypes.mjs';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @internal Helpers for resolving DOCX table-width metadata into pixel widths.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Resolve a DOCX width pair to pixels. `pct` values are 50ths of a percent
|
|
24
|
+
* (ECMA-376 §17.18.111 — 5000 means 100%). `dxa` / `auto` / unset are twips.
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
declare function resolveTableWidthPx(value: number | undefined, widthType: string | undefined, parentWidth: number): number | undefined;
|
|
29
|
+
/** A cell with its resolved grid position (column index honoring spans). */
|
|
30
|
+
interface ResolvedGridCell {
|
|
31
|
+
rowIndex: number;
|
|
32
|
+
cellIndex: number;
|
|
33
|
+
columnIndex: number;
|
|
34
|
+
colSpan: number;
|
|
35
|
+
rowSpan: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Resolve every cell's grid column index, accounting for `colSpan` and the
|
|
39
|
+
* columns occupied by vertically-merged (`rowSpan`) cells from earlier rows.
|
|
40
|
+
*
|
|
41
|
+
* Single source of truth for table grid geometry — the measurer, the painter,
|
|
42
|
+
* and the row-break paginator all consume this so they agree on which column a
|
|
43
|
+
* cell lives in. Width-free on purpose: callers multiply `columnIndex` by their
|
|
44
|
+
* own (possibly scaled) column widths to get an x offset.
|
|
45
|
+
*
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
declare function resolveCellGrid(tableBlock: TableBlock): ResolvedGridCell[];
|
|
49
|
+
/** Total grid columns, derived from the widest row's accumulated colSpans. */
|
|
50
|
+
declare function countTableColumns(tableBlock: TableBlock): number;
|
|
51
|
+
/**
|
|
52
|
+
* Make `columnWidths` exactly `colCount` long with every entry positive.
|
|
53
|
+
* Missing trailing columns inherit the average of existing positives; zero
|
|
54
|
+
* or negative entries split the leftover `targetWidth` evenly. Callers
|
|
55
|
+
* scale down totals that exceed the target — this helper only fills gaps.
|
|
56
|
+
*/
|
|
57
|
+
declare function normalizeTableColumnWidths(columnWidths: number[], colCount: number, targetWidth: number): number[];
|
|
58
|
+
/**
|
|
59
|
+
* Resolve a table's per-column pixel widths from its grid metadata and width
|
|
60
|
+
* budget — the width half of `measureTableBlock`, with NO cell-content
|
|
61
|
+
* measurement. Factored out so a caller that only needs widths (e.g. deciding
|
|
62
|
+
* whether a floating table is effectively full-width, before the main measure
|
|
63
|
+
* pass) doesn't have to measure every cell.
|
|
64
|
+
*
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
declare function resolveTableColumnWidths(tableBlock: TableBlock, contentWidth: number): number[];
|
|
68
|
+
/**
|
|
69
|
+
* Total pixel width of a table — sum of its resolved column widths, falling
|
|
70
|
+
* back to the explicit table width or the content-width budget. No cell-content
|
|
71
|
+
* measurement, so it is safe to call before the main measure pass. Mirrors the
|
|
72
|
+
* `totalWidth` that `measureTableBlock` produces.
|
|
73
|
+
*
|
|
74
|
+
* @internal
|
|
75
|
+
*/
|
|
76
|
+
declare function resolveTableTotalWidthPx(tableBlock: TableBlock, contentWidth: number): number;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Selection-overlay geometry value types, shared by the canvas overlays and
|
|
80
|
+
* the display-list queries (`selectionToRectsFromDisplayList` /
|
|
81
|
+
* `getCaretPositionFromDisplayList`).
|
|
82
|
+
*
|
|
83
|
+
* @packageDocumentation
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
/**
|
|
87
|
+
* A rectangle representing part of a selection.
|
|
88
|
+
*
|
|
89
|
+
* @public
|
|
90
|
+
*/
|
|
91
|
+
type SelectionRect = {
|
|
92
|
+
/** X coordinate in container space. */
|
|
93
|
+
x: number;
|
|
94
|
+
/** Y coordinate in container space. */
|
|
95
|
+
y: number;
|
|
96
|
+
/** Width of the rectangle. */
|
|
97
|
+
width: number;
|
|
98
|
+
/** Height of the rectangle (typically line height). */
|
|
99
|
+
height: number;
|
|
100
|
+
/** Page index (0-based). */
|
|
101
|
+
pageIndex: number;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Caret position for collapsed selection.
|
|
105
|
+
*
|
|
106
|
+
* @public
|
|
107
|
+
*/
|
|
108
|
+
type CaretPosition = {
|
|
109
|
+
/** X coordinate in container space. */
|
|
110
|
+
x: number;
|
|
111
|
+
/** Y coordinate in container space. */
|
|
112
|
+
y: number;
|
|
113
|
+
/** Height of the caret (line height). */
|
|
114
|
+
height: number;
|
|
115
|
+
/** Page index (0-based). */
|
|
116
|
+
pageIndex: number;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Header/footer body-margin extension.
|
|
121
|
+
*
|
|
122
|
+
* Word grows the header (or footer) band when its in-flow content is taller
|
|
123
|
+
* than the authored top (or bottom) margin minus the header/footer distance,
|
|
124
|
+
* pushing the body text down (or up). This module owns that computation so the
|
|
125
|
+
* React and Vue adapters share one implementation instead of byte-identical
|
|
126
|
+
* inline copies (the layout pipelines were drifting candidates — see
|
|
127
|
+
* `docx-editor` engine-unification work, issue #696).
|
|
128
|
+
*
|
|
129
|
+
* Two correctness rules live here:
|
|
130
|
+
*
|
|
131
|
+
* 1. The band height is driven by `HeaderFooterContent.flowHeight` (in-flow
|
|
132
|
+
* content only), NOT `height` / `visualBottom`. A page/margin-anchored
|
|
133
|
+
* float — e.g. a full-page letterhead anchored in a header — is positioned
|
|
134
|
+
* on the page and does not push the body in Word. Counting it inflated the
|
|
135
|
+
* effective top margin past the page on real-world templates, so the
|
|
136
|
+
* paginator hard-threw "page size and margins yield no content area" and
|
|
137
|
+
* the document rendered blank (issue #705).
|
|
138
|
+
*
|
|
139
|
+
* 2. A clamp guarantees `top + bottom` never consumes the whole page, so a
|
|
140
|
+
* pathological in-flow header degrades to a thin content band with a
|
|
141
|
+
* warning instead of aborting pagination.
|
|
142
|
+
*/
|
|
143
|
+
|
|
144
|
+
/** @public */
|
|
145
|
+
interface ExtendMarginsForHeaderFooterInput {
|
|
146
|
+
pageSize: {
|
|
147
|
+
w: number;
|
|
148
|
+
h: number;
|
|
149
|
+
};
|
|
150
|
+
/** Body fallback margins. */
|
|
151
|
+
margins: PageMargins;
|
|
152
|
+
/** Final-section margins (last `sectPr`). */
|
|
153
|
+
finalMargins: PageMargins;
|
|
154
|
+
/**
|
|
155
|
+
* Body flow blocks. Each `sectionBreak` block's `margins` is extended IN
|
|
156
|
+
* PLACE so multi-section documents paginate with the same band growth (the
|
|
157
|
+
* layout engine prefers `sectionBreak.margins` over the body fallback).
|
|
158
|
+
*/
|
|
159
|
+
bodyBlocks?: LayoutBlock[];
|
|
160
|
+
/** Header variants in play this layout (e.g. default + first-page). */
|
|
161
|
+
headers?: Array<HeaderFooterContent | undefined>;
|
|
162
|
+
/** Footer variants in play this layout. */
|
|
163
|
+
footers?: Array<HeaderFooterContent | undefined>;
|
|
164
|
+
/** Optional diagnostic sink for the clamp (adapters pass `console.warn`). */
|
|
165
|
+
warn?: (message: string) => void;
|
|
166
|
+
}
|
|
167
|
+
/** @public */
|
|
168
|
+
interface ExtendMarginsForHeaderFooterResult {
|
|
169
|
+
margins: PageMargins;
|
|
170
|
+
finalMargins: PageMargins;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Extend body margins so the body clears the header/footer bands, mirroring
|
|
174
|
+
* Word. Returns new `margins` / `finalMargins`; mutates `sectionBreak.margins`
|
|
175
|
+
* in place. When no extension is needed the original objects are returned
|
|
176
|
+
* unchanged.
|
|
177
|
+
*
|
|
178
|
+
* @public
|
|
179
|
+
*/
|
|
180
|
+
declare function extendMarginsForHeaderFooter(input: ExtendMarginsForHeaderFooterInput): ExtendMarginsForHeaderFooterResult;
|
|
181
|
+
|
|
182
|
+
/** Coordinates selection paint with the latest completed layout sequence. */
|
|
183
|
+
declare class LayoutSelectionGate {
|
|
184
|
+
#private;
|
|
185
|
+
setStateSeq(sequence: number): void;
|
|
186
|
+
incrementStateSeq(): number;
|
|
187
|
+
getStateSeq(): number;
|
|
188
|
+
getRenderSeq(): number;
|
|
189
|
+
onLayoutStart(): void;
|
|
190
|
+
onLayoutComplete(sequence: number): void;
|
|
191
|
+
isSafeToRender(): boolean;
|
|
192
|
+
requestRender(): void;
|
|
193
|
+
onRender(callback: () => void): () => void;
|
|
194
|
+
reset(): void;
|
|
195
|
+
getDebugInfo(): {
|
|
196
|
+
stateSeq: number;
|
|
197
|
+
renderSeq: number;
|
|
198
|
+
layoutUpdating: boolean;
|
|
199
|
+
hasPendingRender: boolean;
|
|
200
|
+
isSafe: boolean;
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Shared table measurement helper.
|
|
206
|
+
*
|
|
207
|
+
* Both React's PagedEditor and Vue's useDocxEditor measure tables the
|
|
208
|
+
* same way: resolve column widths through `tableWidthUtils`, track
|
|
209
|
+
* column occupancy across vertically merged cells, then call back into
|
|
210
|
+
* the adapter's `measureBlock` for each cell's contained blocks.
|
|
211
|
+
*
|
|
212
|
+
* This module lives in core (not in either adapter) so a fix on one
|
|
213
|
+
* side automatically applies to both. The recursive cell-content
|
|
214
|
+
* measurement is delegated to the caller via `measureBlock` because
|
|
215
|
+
* each adapter's block coverage differs (React supports floating
|
|
216
|
+
* zones, footnotes, textBoxes; Vue is a subset).
|
|
217
|
+
*/
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Visual height of a single block inside a table cell.
|
|
221
|
+
*
|
|
222
|
+
* A one-line paragraph that contains only image runs is laid out at the
|
|
223
|
+
* image's intrinsic height (plus the paragraph's explicit spacing), not
|
|
224
|
+
* a full text line — matching Word's per-cell layout. Everything else
|
|
225
|
+
* uses the measured `totalHeight` / `height`.
|
|
226
|
+
*/
|
|
227
|
+
declare function measureTableCellBlockVisualHeight(block: LayoutBlock, blockMeasure: BlockExtent): number;
|
|
228
|
+
/**
|
|
229
|
+
* measure a `TableBlock` against a content-width budget: resolve the column
|
|
230
|
+
* grid, measure every cell's blocks, then size rows — with vertically merged
|
|
231
|
+
* cells distributing their surplus height in a second pass.
|
|
232
|
+
*
|
|
233
|
+
* `measureBlock` is the per-cell-content callback; the adapter supplies its
|
|
234
|
+
* own so block coverage stays per-renderer.
|
|
235
|
+
*/
|
|
236
|
+
declare function measureTableBlock(tableBlock: TableBlock, contentWidth: number, measureBlock: (block: LayoutBlock, contentWidth: number) => BlockExtent): TableExtent;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Section-properties → page geometry helpers.
|
|
240
|
+
*
|
|
241
|
+
* Both adapters need the same translation from `SectionProperties` (twips
|
|
242
|
+
* + DOCX field names) into the layout engine's pixel-shaped `PageSize`
|
|
243
|
+
* and `PageMargins`. Living in core eliminates the subtle React/Vue
|
|
244
|
+
* drift that grows when each adapter ships its own twipsToPixels math.
|
|
245
|
+
*/
|
|
246
|
+
|
|
247
|
+
/** US Letter at 96 DPI — Word's default page size. */
|
|
248
|
+
declare const DEFAULT_PAGE_WIDTH_PX = 816;
|
|
249
|
+
/** US Letter at 96 DPI. */
|
|
250
|
+
declare const DEFAULT_PAGE_HEIGHT_PX = 1056;
|
|
251
|
+
/** 1 inch at 96 DPI — Word's default body margins. */
|
|
252
|
+
declare const DEFAULT_BODY_MARGIN_PX = 96;
|
|
253
|
+
/** Word's default `headerDistance` / `footerDistance` (0.5in = 48px). */
|
|
254
|
+
declare const DEFAULT_HF_DISTANCE_PX = 48;
|
|
255
|
+
/** Convert twips to pixels (1 twip = 1/20 point, 96 pixels per inch). */
|
|
256
|
+
declare function twipsToPixels(twips: number): number;
|
|
257
|
+
/**
|
|
258
|
+
* Convert SectionProperties page size (twips) → pixel `{ w, h }`.
|
|
259
|
+
*
|
|
260
|
+
* Page size is a SIZE: a literal `0` (malformed `w:pgSz`) defaults to Letter
|
|
261
|
+
* rather than rendering a zero-area page — so the truthy guard is intentional
|
|
262
|
+
* here (contrast `getMargins`, where `0` is honored). See `twipsToPxOr`.
|
|
263
|
+
*/
|
|
264
|
+
declare function getPageSize(sp: SectionProperties | null | undefined): {
|
|
265
|
+
w: number;
|
|
266
|
+
h: number;
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* Convert SectionProperties margins (twips) → pixel `PageMargins`.
|
|
270
|
+
*
|
|
271
|
+
* Every distance is an OFFSET, so an explicit `0` is honored (full-bleed body
|
|
272
|
+
* margins; a header/footer pinned to the page edge — issue #740). Only an
|
|
273
|
+
* ABSENT distance falls back to Word's default. `header`/`footer` default to
|
|
274
|
+
* 48px (Word's 0.5in) so the HF margin-extension math needn't special-case
|
|
275
|
+
* undefined.
|
|
276
|
+
*/
|
|
277
|
+
declare function getMargins(sp: SectionProperties | null | undefined): PageMargins;
|
|
278
|
+
/**
|
|
279
|
+
* Resolve the HeaderFooter pair (default + first-page) for a section.
|
|
280
|
+
*
|
|
281
|
+
* Mirrors React's lookup in DocxEditor.tsx: read `pkg.headers`/`footers`
|
|
282
|
+
* (Maps keyed by rId), resolve through `sp.headerReferences` /
|
|
283
|
+
* `footerReferences`. When `titlePg` is unset and only `first` HFs
|
|
284
|
+
* exist, they serve as the default — same Word fallback both adapters
|
|
285
|
+
* have shipped.
|
|
286
|
+
*/
|
|
287
|
+
declare function resolveHeaderFooter(doc: Document | null, sp: SectionProperties | null | undefined): {
|
|
288
|
+
header: HeaderFooter | null;
|
|
289
|
+
footer: HeaderFooter | null;
|
|
290
|
+
firstHeader: HeaderFooter | null;
|
|
291
|
+
firstFooter: HeaderFooter | null;
|
|
292
|
+
};
|
|
293
|
+
/**
|
|
294
|
+
* Extract column layout from section properties.
|
|
295
|
+
* Returns undefined for single-column (default) to avoid unnecessary paginator overhead.
|
|
296
|
+
*/
|
|
297
|
+
declare function getColumns(sectionProps: SectionProperties | null | undefined): ColumnLayout | undefined;
|
|
298
|
+
declare function columnWidthForSection(config: SectionLayoutConfig): number;
|
|
299
|
+
/**
|
|
300
|
+
* Compute per-block measurement widths by scanning for section breaks.
|
|
301
|
+
* Blocks must be measured with the page width/margins/columns of their own
|
|
302
|
+
* section so that the layout engine can paginate them against the right
|
|
303
|
+
* geometry without remeasuring.
|
|
304
|
+
*/
|
|
305
|
+
declare function computePerBlockWidths(blocks: LayoutBlock[], initialConfig: SectionLayoutConfig, finalConfig: SectionLayoutConfig): number[];
|
|
306
|
+
|
|
307
|
+
export { type CaretPosition, DEFAULT_BODY_MARGIN_PX, DEFAULT_HF_DISTANCE_PX, DEFAULT_PAGE_HEIGHT_PX, DEFAULT_PAGE_WIDTH_PX, type ExtendMarginsForHeaderFooterInput, type ExtendMarginsForHeaderFooterResult, LayoutSelectionGate, type ResolvedGridCell, type SelectionRect, columnWidthForSection, computePerBlockWidths, countTableColumns, extendMarginsForHeaderFooter, getColumns, getMargins, getPageSize, measureTableBlock, measureTableCellBlockVisualHeight, normalizeTableColumnWidths, resolveCellGrid, resolveHeaderFooter, resolveTableColumnWidths, resolveTableTotalWidthPx, resolveTableWidthPx, twipsToPixels };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{A as DEFAULT_BODY_MARGIN_PX,B as DEFAULT_HF_DISTANCE_PX,z as DEFAULT_PAGE_HEIGHT_PX,y as DEFAULT_PAGE_WIDTH_PX,b as FOOTNOTE_COLUMN_GAP_PX,a as FOOTNOTE_SEPARATOR_HEIGHT,x as LayoutSelectionGate,c as MAX_FOOTNOTE_LAYOUT_PASSES,h as applyFootnotePresentation,k as buildFootnoteContentMap,o as buildFootnoteRenderItems,m as calculateFootnoteReservedHeights,s as calculateHeaderFooterVisualBounds,f as collectFootnoteRefs,H as columnWidthForSection,u as computeHfCaretRectsFromDisplayList,v as computeHfSelectionRectsFromDisplayList,I as computePerBlockWidths,r as contributesToHeaderFooterFlowHeight,i as convertFootnoteToContent,t as convertHeaderFooterToContent,l as distributeFootnotesIntoColumns,w as extendMarginsForHeaderFooter,d as footnoteReservedHeightsEqual,G as getColumns,E as getMargins,D as getPageSize,g as mapFootnotesToPages,p as normalizeHeaderFooterMeasureBlocks,F as resolveHeaderFooter,q as resolveHeaderFooterVisualTop,n as stabilizeFootnoteLayout,C as twipsToPixels}from'../chunk-P3KDV4M2.mjs';export{h as createRustMeasureSource,e as getRustTextEngine,d as hashParagraphBlock,c as measureBlocksWithFloats,b as measureTableBlock,a as measureTableCellBlockVisualHeight}from'../chunk-7DEIW7FL.mjs';export{a as convertBorderSpecToLayout,e as demoteBlockLikeFloatingTables,d as isBlockLikeFloatingTable,b as resolveListTemplate,c as toLayoutBlocks}from'../chunk-IL5JZJT7.mjs';export{d as resetBlockIdCounter}from'../chunk-GWKJ2Y4Y.mjs';export{g as clampFloatingWrapMargins,c as countTableColumns,i as getFloatingMargins,d as normalizeTableColumnWidths,h as rectsToFloatingZones,b as resolveCellGrid,e as resolveTableColumnWidths,f as resolveTableTotalWidthPx,a as resolveTableWidthPx}from'../chunk-52GB3Y42.mjs';import'../chunk-7PCO5I2O.mjs';import'../chunk-X4XDO3LZ.mjs';import'../chunk-L5ISVQ3W.mjs';import'../chunk-OMR3TWCD.mjs';import'../chunk-XWUOLYRQ.mjs';import'../chunk-HJGAQIU7.mjs';import'../chunk-FZIA7OFY.mjs';import'../chunk-OBQGPMPQ.mjs';import'../chunk-3UBMCDME.mjs';import'../chunk-FPZBTOD6.mjs';import'../chunk-H3JCIGWK.mjs';import'../chunk-SINEY6ZF.mjs';import'../chunk-T4EZMUXM.mjs';import'../chunk-TTRUPDAB.mjs';
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { M as MeasureBlockFn } from '../../measureBlocksPipeline-Df0Bbrwy.mjs';
|
|
2
|
+
export { F as FloatPageGeometry, a as FloatingExclusionRect, b as FloatingImageZone, c as FloatingLineSegmentZone, d as clampFloatingWrapMargins, g as getFloatingMargins, m as measureBlocksWithFloats, r as rectsToFloatingZones } from '../../measureBlocksPipeline-Df0Bbrwy.mjs';
|
|
3
|
+
import { C as CompatibilityFlags } from '../../settingsParser-CcGvtmCK.mjs';
|
|
4
|
+
import { e as LayoutBlock, a1 as ParagraphBlock } from '../../types-DNrYr6yQ.mjs';
|
|
5
|
+
import '../../content-sSHuWw49.mjs';
|
|
6
|
+
import '../../formatting-DoL7KBSL.mjs';
|
|
7
|
+
import '../../docx/wrapTypes.mjs';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Script bucket a fallback face provides glyph coverage for. Han text is
|
|
11
|
+
* region-resolved by the caller (SC/TC/JP/KR — see `rustMeasureSource.ts`);
|
|
12
|
+
* kana, Hangul, Arabic and Hebrew detect directly.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
type FontScript = 'cjk-sc' | 'cjk-tc' | 'cjk-jp' | 'cjk-kr' | 'arabic' | 'hebrew';
|
|
17
|
+
/**
|
|
18
|
+
* Resolver for the bundled metric-compatible set (Carlito↔Calibri,
|
|
19
|
+
* Liberation↔Arial/Times/Courier, …). Returns a lazy byte loader so the
|
|
20
|
+
* (lazily fetched, same-origin) binary is only downloaded when a document
|
|
21
|
+
* actually needs the face, or `undefined` when the family has no bundled
|
|
22
|
+
* substitute.
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
interface BundledFontProvider {
|
|
27
|
+
/** Resolve a Word family to bundled metric-compatible face byte loaders, or undefined. */
|
|
28
|
+
resolve(family: string, bold: boolean, italic: boolean): (() => Promise<ArrayBuffer>) | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Optional per-script coverage fallback (Noto CJK/RTL faces). Same loader
|
|
31
|
+
* contract as {@link BundledFontProvider.resolve}; providers without
|
|
32
|
+
* script faces simply omit the method. These faces are coverage fallbacks
|
|
33
|
+
* first, metric approximations second — CJK metric compatibility is much
|
|
34
|
+
* weaker than the Carlito/Calibri class of substitutes.
|
|
35
|
+
*/
|
|
36
|
+
resolveScriptFallback?(script: FontScript, bold: boolean, italic: boolean): (() => Promise<ArrayBuffer>) | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* The always-available last-resort base face (broad-coverage Latin —
|
|
39
|
+
* Liberation Sans/Serif per serif-ness). Unlike {@link
|
|
40
|
+
* BundledFontProvider.resolve}, a conforming provider (e.g.
|
|
41
|
+
* `@betteroffice/docx-fonts`'s `resolveLastResortFace`) returns a loader for
|
|
42
|
+
* EVERY family, so the chain this registry builds is guaranteed non-empty
|
|
43
|
+
* and a run never routes to the browser measurer for want of font bytes. The
|
|
44
|
+
* face's metrics are the base font's, not the requested family's — the
|
|
45
|
+
* accepted divergence for a truly-unknown font, in exchange for staying on
|
|
46
|
+
* the native measurement path.
|
|
47
|
+
*
|
|
48
|
+
* Optional so mock/partial providers can omit it; when absent (or returning
|
|
49
|
+
* undefined) an unmapped family still yields an empty chain and the caller
|
|
50
|
+
* browser-falls-back that run — the pre-policy behavior. Same lazy loader
|
|
51
|
+
* contract as {@link BundledFontProvider.resolve}.
|
|
52
|
+
*/
|
|
53
|
+
resolveLastResort?(family: string, bold: boolean, italic: boolean): (() => Promise<ArrayBuffer>) | undefined;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* One embedded face extracted from the open document. Structurally identical
|
|
57
|
+
* to `EmbeddedFontFace` (`utils/embeddedFonts.ts`), so the output of
|
|
58
|
+
* `getEmbeddedFontFaces` feeds straight in; duplicated here so this module
|
|
59
|
+
* stays decoupled from the loader.
|
|
60
|
+
*
|
|
61
|
+
* @public
|
|
62
|
+
*/
|
|
63
|
+
interface EmbeddedFaceInput {
|
|
64
|
+
/** Word font name the face is registered under (attacker-controlled). */
|
|
65
|
+
family: string;
|
|
66
|
+
/** `'bold'` for the embedBold/embedBoldItalic slots, else `'normal'`. */
|
|
67
|
+
weight: 'normal' | 'bold';
|
|
68
|
+
/** `'italic'` for the embedItalic/embedBoldItalic slots, else `'normal'`. */
|
|
69
|
+
style: 'normal' | 'italic';
|
|
70
|
+
/** De-obfuscated OpenType/TrueType bytes. */
|
|
71
|
+
data: ArrayBuffer;
|
|
72
|
+
/** Whether the source face was subsetted (`w:subsetted`). */
|
|
73
|
+
subsetted: boolean;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The Rust measurement source — the SOLE text/layout measurement path. Every
|
|
78
|
+
* block kind is measured here: paragraphs through the wasm `docx-text` engine
|
|
79
|
+
* (Word metrics), tables/text boxes/shapes by pure recursion through the same
|
|
80
|
+
* measurer, and image/chart/break extents synthesized from declared
|
|
81
|
+
* dimensions. There is no browser `measureText` anywhere in layout.
|
|
82
|
+
*
|
|
83
|
+
* Division of labor:
|
|
84
|
+
* - {@link TextMeasureFontRegistry} (owned here) turns Word font requests
|
|
85
|
+
* into ordered engine font-id chains from embedded + bundled bytes, and
|
|
86
|
+
* resolves the shared per-script coverage fallbacks (CJK/RTL Noto faces).
|
|
87
|
+
* Resolution is deterministic: embedded faces → bundled metric-compatible
|
|
88
|
+
* face → always-available last-resort base face; never OS/local fonts.
|
|
89
|
+
* - {@link RustMeasureSource.prepareFonts} is the ONLY async step: it warms
|
|
90
|
+
* the registry for every (family, bold, italic) combo a block list uses,
|
|
91
|
+
* plus the script fallbacks for every script detected in the blocks'
|
|
92
|
+
* text — and for every request an earlier measure pass found unresolved
|
|
93
|
+
* (header/footer and footnote paragraphs reach measurement without
|
|
94
|
+
* passing through the adapters' block notifications; recording their
|
|
95
|
+
* misses here closes that gap). Call sites re-layout after it resolves.
|
|
96
|
+
* - {@link RustMeasureSource.createMeasureBlock} builds the sync
|
|
97
|
+
* `MeasureBlockFn` the float pipeline consumes. Paragraph blocks whose
|
|
98
|
+
* font chains are cached go to the engine — float-zoned blocks included,
|
|
99
|
+
* with the zones and cumulative Y passed through in the envelope.
|
|
100
|
+
*
|
|
101
|
+
* READINESS GATE (how measurement never races an unloaded face): a paragraph
|
|
102
|
+
* whose font chain (or script fallback) has not settled yet measures as a
|
|
103
|
+
* deterministic SYNTHETIC extent and records the miss;
|
|
104
|
+
* {@link RustMeasureSource.hasPendingFonts} then reports true, the adapter
|
|
105
|
+
* discards that provisional pass instead of committing it, and re-runs the
|
|
106
|
+
* pipeline when `prepareFonts` settles. Once settled, `font-unready` can
|
|
107
|
+
* never recur for those chains (the sync registry view is populated), so
|
|
108
|
+
* committed layouts are always measured against real, loaded font bytes.
|
|
109
|
+
*
|
|
110
|
+
* SELF-SUFFICIENT FONTS: every family chain the registry builds terminates in
|
|
111
|
+
* an always-available last-resort base face (broad-coverage Liberation
|
|
112
|
+
* Sans/Serif per serif-ness, supplied by the bundled provider's
|
|
113
|
+
* `resolveLastResort`), and the per-script Noto fallback is appended whenever
|
|
114
|
+
* a covered script is detected. A run whose family has no embedded/bundled
|
|
115
|
+
* match — or a character outside the family chain's coverage — still has real
|
|
116
|
+
* font bytes to measure with; the engine substitutes the terminal face's
|
|
117
|
+
* `.notdef` for genuinely uncovered characters. For a truly-unknown font the
|
|
118
|
+
* measured metrics are the base font's, not the requested family's — the
|
|
119
|
+
* accepted, deterministic substitution tradeoff.
|
|
120
|
+
*
|
|
121
|
+
* SYNTHETIC extents (deterministic pure arithmetic, no font tables, no
|
|
122
|
+
* platform state) stand in for exactly two residual cases: (a) an engine
|
|
123
|
+
* refusal — degenerate/attacker-crafted input tripping the security clamps,
|
|
124
|
+
* or a malformed payload; (b) a chain that SETTLED EMPTY, which can only
|
|
125
|
+
* happen when the host injects no bundled provider (`resolveLastResort`
|
|
126
|
+
* guarantees non-empty chains otherwise) and the document embeds nothing for
|
|
127
|
+
* the family. Both are counted in {@link RustMeasureStats}.
|
|
128
|
+
*
|
|
129
|
+
* Script fallbacks: runs are scanned for Unicode script ranges — kana → JP,
|
|
130
|
+
* Hangul → KR, Arabic → arabic, Hebrew → hebrew — and Han is region-resolved:
|
|
131
|
+
* kana in the same block wins (Japanese text), else the document's
|
|
132
|
+
* `w:themeFontLang` eastAsia hint ({@link RustMeasureSource.setScriptHints}),
|
|
133
|
+
* else Hangul in the block (hanja), else SC. The resolved script ids are
|
|
134
|
+
* appended AFTER the family faces of every chain the block uses, so the
|
|
135
|
+
* family face keeps supplying metrics/Latin glyphs and the script face only
|
|
136
|
+
* covers what the family face cannot. RTL text measures natively (the engine
|
|
137
|
+
* splits UBA level runs before shaping).
|
|
138
|
+
*
|
|
139
|
+
* @packageDocumentation
|
|
140
|
+
* @public
|
|
141
|
+
*/
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Font styling properties for a short-text measurement request (the
|
|
145
|
+
* `measureTextWidthWithActiveRustSource` latch and tab-leader glyph
|
|
146
|
+
* sizing).
|
|
147
|
+
*
|
|
148
|
+
* @public
|
|
149
|
+
*/
|
|
150
|
+
interface FontStyle {
|
|
151
|
+
fontFamily?: string;
|
|
152
|
+
/** In points. */
|
|
153
|
+
fontSize?: number;
|
|
154
|
+
bold?: boolean;
|
|
155
|
+
italic?: boolean;
|
|
156
|
+
/** In pixels. */
|
|
157
|
+
letterSpacing?: number;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Thin sync facade over the wasm measure exports (`register_measure_font`,
|
|
161
|
+
* `clear_measure_fonts`, `measure_paragraph_json`). Injectable so unit tests
|
|
162
|
+
* can script responses without loading wasm.
|
|
163
|
+
*
|
|
164
|
+
* @public
|
|
165
|
+
*/
|
|
166
|
+
interface RustTextEngine {
|
|
167
|
+
/** Register raw sfnt bytes; returns the engine font id. Throws on bad bytes. */
|
|
168
|
+
registerFont(bytes: Uint8Array): number;
|
|
169
|
+
/** Drop every registered font (ids restart at 0). */
|
|
170
|
+
clearFonts(): void;
|
|
171
|
+
/**
|
|
172
|
+
* Measurement input JSON in, `ParagraphExtent` JSON out. Throws with a
|
|
173
|
+
* message starting `UNSUPPORTED:` for blocks the engine cannot measure.
|
|
174
|
+
*/
|
|
175
|
+
measureParagraphJson(input: string): string;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Lazily load the embedded wasm module and expose its measure surface as a
|
|
179
|
+
* {@link RustTextEngine}. The dynamic `import()` keeps the ~800KB base64
|
|
180
|
+
* module out of the default bundle — only callers that actually enable Rust
|
|
181
|
+
* measurement pay for it (same pattern as the display-list builder's
|
|
182
|
+
* `loadEngine`).
|
|
183
|
+
*
|
|
184
|
+
* @public
|
|
185
|
+
*/
|
|
186
|
+
declare function getRustTextEngine(): Promise<RustTextEngine>;
|
|
187
|
+
/** Counters for the debug log line (rust vs synthetic per layout pass). */
|
|
188
|
+
interface RustMeasureStats {
|
|
189
|
+
/** Paragraph blocks measured by the Rust engine (including memo hits). */
|
|
190
|
+
rustMeasured: number;
|
|
191
|
+
/** Paragraphs that measured as a synthetic extent — sum of the reasons below. */
|
|
192
|
+
syntheticFallback: number;
|
|
193
|
+
/**
|
|
194
|
+
* Synthetic extents caused by a font chain (or script fallback) not having
|
|
195
|
+
* resolved yet. Transient by construction: the miss is recorded, the
|
|
196
|
+
* adapter discards the pass (`hasPendingFonts`), and the fonts-settled
|
|
197
|
+
* re-layout measures natively — so no COMMITTED layout ever contains one,
|
|
198
|
+
* and this MUST hold constant once `prepareFonts` settles.
|
|
199
|
+
*/
|
|
200
|
+
syntheticFontUnready: number;
|
|
201
|
+
/**
|
|
202
|
+
* Synthetic extents caused by an engine glyph-coverage refusal. Dormant —
|
|
203
|
+
* chains terminate in a last-resort face whose `.notdef` the shaper
|
|
204
|
+
* substitutes — but kept so a coverage regression is categorized rather
|
|
205
|
+
* than lumped in with `non-font` refusals.
|
|
206
|
+
*/
|
|
207
|
+
syntheticUncovered: number;
|
|
208
|
+
/**
|
|
209
|
+
* Synthetic-extent counts by `LayoutBlock.kind`. The audit counter proving
|
|
210
|
+
* text-bearing block kinds (`paragraph`, `table`, `textBox`) measure
|
|
211
|
+
* natively once fonts are ready.
|
|
212
|
+
*/
|
|
213
|
+
syntheticBlockKinds: Record<string, number>;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* The selectable measurement source. Create with
|
|
217
|
+
* {@link createRustMeasureSource}; see the module doc for the contract.
|
|
218
|
+
*
|
|
219
|
+
* @public
|
|
220
|
+
*/
|
|
221
|
+
interface RustMeasureSource {
|
|
222
|
+
/** Feed the open document's embedded faces (invalidates the measure memo). */
|
|
223
|
+
setEmbeddedFaces(faces: EmbeddedFaceInput[]): void;
|
|
224
|
+
/**
|
|
225
|
+
* Thread the document's compat flags (`w:compat`) into every subsequent
|
|
226
|
+
* engine call. Pass `undefined` to reset to all-off defaults. The memo key
|
|
227
|
+
* includes the flags, so switching documents cannot serve stale extents.
|
|
228
|
+
*/
|
|
229
|
+
setCompat(flags: CompatibilityFlags | undefined): void;
|
|
230
|
+
/**
|
|
231
|
+
* Thread document-level script hints into Han region resolution: pass the
|
|
232
|
+
* `w:themeFontLang` eastAsia tag (`settingsParser` → `themeFontLang`).
|
|
233
|
+
* Without a hint (or with a non-East-Asian tag) Han-only text defaults to
|
|
234
|
+
* Simplified Chinese. Invalidates the measure memo — region choice changes
|
|
235
|
+
* the fallback face and therefore the measured extents.
|
|
236
|
+
*/
|
|
237
|
+
setScriptHints(hints: {
|
|
238
|
+
eastAsia?: string;
|
|
239
|
+
} | undefined): void;
|
|
240
|
+
/**
|
|
241
|
+
* Warm the font registry for every (family, bold, italic) combo — plus the
|
|
242
|
+
* per-family regulars and the per-script coverage fallbacks — that
|
|
243
|
+
* `blocks`' paragraphs use, AND for every request an earlier measure pass
|
|
244
|
+
* recorded as unresolved (header/footer and footnote paragraphs reach the
|
|
245
|
+
* measurer without appearing in the adapters' block lists). The only async
|
|
246
|
+
* step; per-face failures are tolerated (the chain settles without that
|
|
247
|
+
* face). Resolves `true` when at least one previously-unsettled chain or
|
|
248
|
+
* script fallback settled — even settled-empty — i.e. a re-layout would
|
|
249
|
+
* measure differently (or the deferred pass can now proceed).
|
|
250
|
+
*/
|
|
251
|
+
prepareFonts(blocks: LayoutBlock[]): Promise<boolean>;
|
|
252
|
+
/**
|
|
253
|
+
* True while a font chain (or script fallback) some measured paragraph
|
|
254
|
+
* needed is still unresolved. The adapter's readiness gate: a pass measured
|
|
255
|
+
* with pending fonts is provisional (those paragraphs carry synthetic
|
|
256
|
+
* extents) and must be discarded, not committed; `prepareFonts` settles the
|
|
257
|
+
* pending set and the fonts-ready re-layout measures natively. Self-clears
|
|
258
|
+
* once every recorded request has settled.
|
|
259
|
+
*/
|
|
260
|
+
hasPendingFonts(): boolean;
|
|
261
|
+
/**
|
|
262
|
+
* The sync measure function for the float pipeline — the sole measurement
|
|
263
|
+
* path, exhaustive over every `LayoutBlock` kind. Paragraph blocks whose
|
|
264
|
+
* chains (and detected script fallbacks) are cached go to the engine —
|
|
265
|
+
* float-zoned blocks pass their zones and cumulative Y through in the
|
|
266
|
+
* envelope (measured fresh, never memoized). Tables, text boxes and shapes
|
|
267
|
+
* recurse through the same measurer; images/charts/breaks synthesize
|
|
268
|
+
* extents from declared dimensions. Unresolved chains and engine refusals
|
|
269
|
+
* produce deterministic synthetic extents (see the module doc).
|
|
270
|
+
*/
|
|
271
|
+
createMeasureBlock(): MeasureBlockFn;
|
|
272
|
+
/**
|
|
273
|
+
* The merged, doc-wide font-id chain map for `blocks` — every
|
|
274
|
+
* `"<family lowercase>|<bold 0|1>|<italic 0|1>"` combo the blocks' paragraphs
|
|
275
|
+
* use, mapped to its cached engine font-id chain (with the per-block script
|
|
276
|
+
* fallbacks appended after the family faces, exactly as
|
|
277
|
+
* {@link RustMeasureSource.createMeasureBlock} assembles them). Only chains that
|
|
278
|
+
* are already resolved (non-empty in the sync registry cache) are included; a
|
|
279
|
+
* combo whose chain has not settled yet is simply omitted (its runs stay on
|
|
280
|
+
* the char-distributed draw path until `prepareFonts` settles and a
|
|
281
|
+
* re-layout retries). Returns an empty object when nothing is resolved.
|
|
282
|
+
*
|
|
283
|
+
* This is the map the canvas display-list builder consumes to gate GlyphRun
|
|
284
|
+
* emission: the ids reference the same measurement `FontStore` the engine
|
|
285
|
+
* registered, so the outline provider can rasterize them.
|
|
286
|
+
*/
|
|
287
|
+
getDocumentFontChains(blocks: LayoutBlock[]): Record<string, number[]>;
|
|
288
|
+
/** Drop every cached chain, registration, and memoized measure. */
|
|
289
|
+
clear(): void;
|
|
290
|
+
/** Snapshot of the rust-vs-fallback counters (never reset implicitly). */
|
|
291
|
+
getStats(): RustMeasureStats;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Build a {@link RustMeasureSource} over a loaded engine. The source owns a
|
|
295
|
+
* {@link TextMeasureFontRegistry} whose sink is `engine.registerFont`;
|
|
296
|
+
* `bundled` is the optional metric-compatible font provider (injected — core
|
|
297
|
+
* never imports a fonts package).
|
|
298
|
+
*
|
|
299
|
+
* @public
|
|
300
|
+
*/
|
|
301
|
+
declare function createRustMeasureSource(opts: {
|
|
302
|
+
engine: RustTextEngine;
|
|
303
|
+
bundled?: BundledFontProvider;
|
|
304
|
+
}): RustMeasureSource;
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Stable identity hash for a paragraph block, used as the Rust measure
|
|
308
|
+
* memo's key so blocks that would lay out identically share one measurement.
|
|
309
|
+
* Every field that can change the rendered result contributes a labelled
|
|
310
|
+
* token; the assembled token list is serialized as JSON so no separator
|
|
311
|
+
* character can leak in from content.
|
|
312
|
+
*
|
|
313
|
+
* @packageDocumentation
|
|
314
|
+
* @public
|
|
315
|
+
*/
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Build the stable identity string for a paragraph block.
|
|
319
|
+
*
|
|
320
|
+
* @public
|
|
321
|
+
*/
|
|
322
|
+
declare function hashParagraphBlock(block: ParagraphBlock): string;
|
|
323
|
+
|
|
324
|
+
export { type BundledFontProvider, type EmbeddedFaceInput, type FontScript, type FontStyle, MeasureBlockFn, type RustMeasureSource, type RustMeasureStats, type RustTextEngine, createRustMeasureSource, getRustTextEngine, hashParagraphBlock };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{h as createRustMeasureSource,e as getRustTextEngine,d as hashParagraphBlock,c as measureBlocksWithFloats}from'../../chunk-7DEIW7FL.mjs';export{g as clampFloatingWrapMargins,i as getFloatingMargins,h as rectsToFloatingZones}from'../../chunk-52GB3Y42.mjs';import'../../chunk-7PCO5I2O.mjs';import'../../chunk-X4XDO3LZ.mjs';import'../../chunk-OBQGPMPQ.mjs';import'../../chunk-3UBMCDME.mjs';import'../../chunk-TTRUPDAB.mjs';
|