reamkit 1.15.0 → 1.15.2
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/dist/esm/core/arc-to-bezier.d.ts +23 -0
- package/dist/esm/core/arc-to-bezier.js +23 -0
- package/dist/esm/core/bidi/algorithm.d.ts +26 -0
- package/dist/esm/core/bidi/algorithm.js +21 -0
- package/dist/esm/core/bidi/char-types.d.ts +17 -0
- package/dist/esm/core/bidi/char-types.js +10 -0
- package/dist/esm/core/bidi/index.d.ts +42 -0
- package/dist/esm/core/bidi/index.js +27 -0
- package/dist/esm/core/bidi/segments.d.ts +22 -0
- package/dist/esm/core/bidi/segments.js +14 -0
- package/dist/esm/core/bytes.d.ts +9 -0
- package/dist/esm/core/bytes.js +9 -0
- package/dist/esm/core/converter/facade.d.ts +38 -1
- package/dist/esm/core/converter/facade.js +25 -0
- package/dist/esm/core/converter/project.d.ts +12 -0
- package/dist/esm/core/converter/project.js +11 -0
- package/dist/esm/core/converter/ream.d.ts +107 -0
- package/dist/esm/core/converter/ream.js +76 -0
- package/dist/esm/core/crypto/asn1.d.ts +77 -0
- package/dist/esm/core/crypto/asn1.js +65 -0
- package/dist/esm/core/crypto/cms.d.ts +25 -0
- package/dist/esm/core/crypto/cms.js +8 -0
- package/dist/esm/core/document-model/index.d.ts +7 -0
- package/dist/esm/core/document-model/types.d.ts +328 -0
- package/dist/esm/core/drawingml/chart-geometry.d.ts +125 -0
- package/dist/esm/core/drawingml/chart-geometry.js +96 -0
- package/dist/esm/core/drawingml/chart-parser.d.ts +34 -0
- package/dist/esm/core/drawingml/chart-parser.js +34 -0
- package/dist/esm/core/drawingml/chart-serializer.d.ts +12 -0
- package/dist/esm/core/drawingml/chart-serializer.js +12 -0
- package/dist/esm/core/drawingml/colors.d.ts +53 -0
- package/dist/esm/core/drawingml/colors.js +41 -0
- package/dist/esm/core/drawingml/preset-geometry.d.ts +30 -0
- package/dist/esm/core/drawingml/preset-geometry.js +30 -0
- package/dist/esm/core/drawingml/shape-render.d.ts +54 -0
- package/dist/esm/core/drawingml/shape-render.js +54 -0
- package/dist/esm/core/drawingml/sparkline-geometry.d.ts +15 -0
- package/dist/esm/core/drawingml/sparkline-geometry.js +13 -0
- package/dist/esm/core/drawingml/theme-parser.d.ts +11 -0
- package/dist/esm/core/drawingml/theme-parser.js +11 -0
- package/dist/esm/core/font/arabic-joining.d.ts +21 -0
- package/dist/esm/core/font/arabic-joining.js +16 -0
- package/dist/esm/core/font/binary-reader.d.ts +17 -0
- package/dist/esm/core/font/binary-reader.js +17 -0
- package/dist/esm/core/font/font-registry.d.ts +37 -0
- package/dist/esm/core/font/font-registry.js +31 -0
- package/dist/esm/core/font/measure.d.ts +20 -0
- package/dist/esm/core/font/measure.js +11 -0
- package/dist/esm/core/font/opentype-layout.d.ts +49 -0
- package/dist/esm/core/font/opentype-layout.js +37 -0
- package/dist/esm/core/font/ttf-parser.d.ts +32 -0
- package/dist/esm/core/font/ttf-parser.js +7 -0
- package/dist/esm/core/font/ttf-subset.d.ts +21 -0
- package/dist/esm/core/font/ttf-subset.js +21 -0
- package/dist/esm/core/fonts/provider.d.ts +8 -1
- package/dist/esm/core/fonts/provider.js +1 -0
- package/dist/esm/core/fonts/remote-fonts.d.ts +22 -0
- package/dist/esm/core/fonts/remote-fonts.js +16 -0
- package/dist/esm/core/hyphenation/index.d.ts +25 -0
- package/dist/esm/core/hyphenation/index.js +17 -0
- package/dist/esm/core/hyphenation/liang.d.ts +27 -0
- package/dist/esm/core/hyphenation/liang.js +14 -0
- package/dist/esm/core/images.d.ts +32 -0
- package/dist/esm/core/images.js +12 -0
- package/dist/esm/core/ir/adapters.d.ts +23 -0
- package/dist/esm/core/ir/features.d.ts +8 -0
- package/dist/esm/core/ir/features.js +1 -0
- package/dist/esm/core/ir/flow.d.ts +20 -0
- package/dist/esm/core/ir/index.d.ts +7 -0
- package/dist/esm/core/ir/loss.d.ts +12 -0
- package/dist/esm/core/ir/loss.js +8 -0
- package/dist/esm/core/ir/resources.d.ts +12 -0
- package/dist/esm/core/ir/resources.js +11 -0
- package/dist/esm/core/ir/sheet.d.ts +81 -0
- package/dist/esm/core/ir/units.d.ts +9 -0
- package/dist/esm/core/ir/units.js +2 -0
- package/dist/esm/core/line-breaker/cjk.d.ts +26 -0
- package/dist/esm/core/line-breaker/cjk.js +60 -0
- package/dist/esm/core/line-breaker/greedy.d.ts +14 -0
- package/dist/esm/core/line-breaker/greedy.js +14 -0
- package/dist/esm/core/line-breaker/index.d.ts +1 -0
- package/dist/esm/core/line-breaker/index.js +3 -0
- package/dist/esm/core/line-breaker/knuth-plass.d.ts +29 -5
- package/dist/esm/core/line-breaker/knuth-plass.js +10 -5
- package/dist/esm/core/numbering/apply.d.ts +19 -0
- package/dist/esm/core/numbering/apply.js +19 -0
- package/dist/esm/core/numbering/state.d.ts +15 -0
- package/dist/esm/core/numbering/state.js +15 -0
- package/dist/esm/core/ole/cfb.d.ts +19 -0
- package/dist/esm/core/ole/cfb.js +50 -4
- package/dist/esm/core/opc/core-properties.d.ts +12 -0
- package/dist/esm/core/opc/core-properties.js +5 -0
- package/dist/esm/core/opc/opc-writer.d.ts +24 -4
- package/dist/esm/core/opc/opc-writer.js +12 -0
- package/dist/esm/core/opc/package.d.ts +55 -0
- package/dist/esm/core/opc/package.js +46 -0
- package/dist/esm/core/opc/relationship-types.d.ts +8 -0
- package/dist/esm/core/opc/relationship-types.js +5 -0
- package/dist/esm/core/opc/relationships.d.ts +12 -0
- package/dist/esm/core/opc/relationships.js +7 -0
- package/dist/esm/core/po-helpers.d.ts +38 -0
- package/dist/esm/core/po-helpers.js +33 -0
- package/dist/esm/core/spreadsheet-model/types.d.ts +281 -0
- package/dist/esm/core/style-cascade/resolver.d.ts +31 -0
- package/dist/esm/core/style-cascade/resolver.js +31 -0
- package/dist/esm/core/style-cascade/table.d.ts +7 -0
- package/dist/esm/core/style-cascade/table.js +7 -0
- package/dist/esm/core/style-cascade/types.d.ts +27 -0
- package/dist/esm/core/style-cascade/types.js +2 -0
- package/dist/esm/core/vector.d.ts +67 -0
- package/dist/esm/core/vector.js +23 -0
- package/dist/esm/excel/activex-parser.d.ts +31 -0
- package/dist/esm/excel/activex-parser.js +24 -0
- package/dist/esm/excel/cell-reference.d.ts +14 -0
- package/dist/esm/excel/cell-reference.js +9 -0
- package/dist/esm/excel/column-bands.d.ts +29 -0
- package/dist/esm/excel/column-bands.js +26 -0
- package/dist/esm/excel/comments-parser.d.ts +19 -0
- package/dist/esm/excel/comments-parser.js +19 -0
- package/dist/esm/excel/conditional-format.d.ts +38 -0
- package/dist/esm/excel/conditional-format.js +25 -0
- package/dist/esm/excel/defined-name-ref.d.ts +21 -0
- package/dist/esm/excel/defined-name-ref.js +20 -0
- package/dist/esm/excel/form-control-parser.d.ts +13 -0
- package/dist/esm/excel/form-control-parser.js +5 -0
- package/dist/esm/excel/formula/context.d.ts +37 -0
- package/dist/esm/excel/formula/dates.d.ts +23 -0
- package/dist/esm/excel/formula/dates.js +20 -0
- package/dist/esm/excel/formula/eval.d.ts +21 -0
- package/dist/esm/excel/formula/eval.js +11 -0
- package/dist/esm/excel/formula/functions.d.ts +12 -0
- package/dist/esm/excel/formula/functions.js +12 -0
- package/dist/esm/excel/formula/index.d.ts +21 -0
- package/dist/esm/excel/formula/index.js +16 -0
- package/dist/esm/excel/formula/lexer.d.ts +12 -0
- package/dist/esm/excel/formula/lexer.js +10 -0
- package/dist/esm/excel/formula/parser.d.ts +20 -0
- package/dist/esm/excel/formula/parser.js +53 -0
- package/dist/esm/excel/formula/value.d.ts +53 -0
- package/dist/esm/excel/formula/value.js +30 -0
- package/dist/esm/excel/header-footer.d.ts +9 -0
- package/dist/esm/excel/header-footer.js +9 -0
- package/dist/esm/excel/number-format.d.ts +34 -0
- package/dist/esm/excel/number-format.js +34 -0
- package/dist/esm/excel/pivot-table-parser.d.ts +8 -0
- package/dist/esm/excel/pivot-table-parser.js +8 -0
- package/dist/esm/excel/print-model.d.ts +56 -0
- package/dist/esm/excel/print-model.js +43 -0
- package/dist/esm/excel/shared-strings-parser.d.ts +13 -0
- package/dist/esm/excel/shared-strings-parser.js +5 -0
- package/dist/esm/excel/sheet-drawing.d.ts +34 -0
- package/dist/esm/excel/sheet-drawing.js +21 -0
- package/dist/esm/excel/sheet-shape-parser.d.ts +12 -0
- package/dist/esm/excel/sheet-shape-parser.js +12 -0
- package/dist/esm/excel/sheet-to-flow.d.ts +19 -0
- package/dist/esm/excel/sheet-to-flow.js +10 -0
- package/dist/esm/excel/slicer-parser.d.ts +23 -0
- package/dist/esm/excel/slicer-parser.js +10 -0
- package/dist/esm/excel/styles-parser.d.ts +8 -0
- package/dist/esm/excel/styles-parser.js +8 -0
- package/dist/esm/excel/table-parser.d.ts +24 -0
- package/dist/esm/excel/table-parser.js +5 -0
- package/dist/esm/excel/workbook-parser.d.ts +17 -0
- package/dist/esm/excel/workbook-parser.js +5 -0
- package/dist/esm/excel/worksheet-parser.d.ts +9 -0
- package/dist/esm/excel/worksheet-parser.js +9 -0
- package/dist/esm/excel/xls/biff-chart.d.ts +10 -0
- package/dist/esm/excel/xls/biff-chart.js +10 -0
- package/dist/esm/excel/xls/biff-reader.d.ts +27 -0
- package/dist/esm/excel/xls/biff-reader.js +44 -0
- package/dist/esm/excel/xls/biff-styles.d.ts +20 -0
- package/dist/esm/excel/xls/biff-styles.js +20 -0
- package/dist/esm/excel/xls/escher.d.ts +27 -0
- package/dist/esm/excel/xls/escher.js +18 -0
- package/dist/esm/excel/xls/xls-reader.d.ts +6 -0
- package/dist/esm/excel/xls/xls-reader.js +6 -0
- package/dist/esm/excel/xlsx-reader.d.ts +26 -0
- package/dist/esm/excel/xlsx-reader.js +26 -0
- package/dist/esm/excel/xlsx-to-pdf.d.ts +27 -0
- package/dist/esm/excel/xlsx-writer.d.ts +14 -0
- package/dist/esm/excel/xlsx-writer.js +13 -0
- package/dist/esm/html/html-writer.d.ts +18 -0
- package/dist/esm/html/html-writer.js +18 -0
- package/dist/esm/index.d.ts +23 -0
- package/dist/esm/layout/math-layout.d.ts +39 -0
- package/dist/esm/layout/math-layout.js +18 -0
- package/dist/esm/layout/page-doc.d.ts +91 -0
- package/dist/esm/layout/styled-layout.d.ts +175 -0
- package/dist/esm/layout/styled-layout.js +117 -2
- package/dist/esm/pdf/builtin-fonts.d.ts +5 -0
- package/dist/esm/pdf/cid-font.d.ts +22 -0
- package/dist/esm/pdf/cid-font.js +10 -0
- package/dist/esm/pdf/embedded-file.d.ts +16 -0
- package/dist/esm/pdf/embedded-file.js +9 -0
- package/dist/esm/pdf/encryption.d.ts +59 -0
- package/dist/esm/pdf/encryption.js +37 -0
- package/dist/esm/pdf/icc-profile.d.ts +8 -0
- package/dist/esm/pdf/icc-profile.js +8 -0
- package/dist/esm/pdf/image-xobject.d.ts +19 -0
- package/dist/esm/pdf/image-xobject.js +9 -0
- package/dist/esm/pdf/objects.d.ts +40 -0
- package/dist/esm/pdf/objects.js +36 -0
- package/dist/esm/pdf/serialize.d.ts +18 -0
- package/dist/esm/pdf/serialize.js +18 -0
- package/dist/esm/pdf/shading.d.ts +16 -0
- package/dist/esm/pdf/shading.js +16 -0
- package/dist/esm/pdf/signature.d.ts +36 -0
- package/dist/esm/pdf/signature.js +22 -0
- package/dist/esm/pdf/struct-tree.d.ts +64 -0
- package/dist/esm/pdf/struct-tree.js +60 -0
- package/dist/esm/pdf/styled-page-emitter.d.ts +33 -0
- package/dist/esm/pdf/styled-page-emitter.js +21 -0
- package/dist/esm/pdf/styled-page-renderer.d.ts +18 -0
- package/dist/esm/pdf/styled-page-renderer.js +18 -0
- package/dist/esm/pdf/text-encoding.d.ts +16 -0
- package/dist/esm/pdf/text-page-renderer.d.ts +11 -0
- package/dist/esm/pdf/vector-graphics.d.ts +12 -0
- package/dist/esm/pdf/vector-graphics.js +12 -0
- package/dist/esm/pdf/writer.d.ts +39 -0
- package/dist/esm/pdf/writer.js +27 -0
- package/dist/esm/pdf/xmp.d.ts +16 -0
- package/dist/esm/pdf/xmp.js +9 -0
- package/dist/esm/pdf-reader/ccitt.d.ts +25 -0
- package/dist/esm/pdf-reader/ccitt.js +15 -0
- package/dist/esm/pdf-reader/cmap.d.ts +12 -0
- package/dist/esm/pdf-reader/cmap.js +9 -0
- package/dist/esm/pdf-reader/content.d.ts +69 -0
- package/dist/esm/pdf-reader/content.js +16 -0
- package/dist/esm/pdf-reader/crypto.d.ts +5 -0
- package/dist/esm/pdf-reader/crypto.js +5 -0
- package/dist/esm/pdf-reader/decrypt.d.ts +17 -0
- package/dist/esm/pdf-reader/decrypt.js +12 -0
- package/dist/esm/pdf-reader/document.d.ts +53 -0
- package/dist/esm/pdf-reader/document.js +50 -0
- package/dist/esm/pdf-reader/flow-build.d.ts +51 -2
- package/dist/esm/pdf-reader/flow-build.js +67 -2
- package/dist/esm/pdf-reader/font.d.ts +12 -0
- package/dist/esm/pdf-reader/font.js +12 -0
- package/dist/esm/pdf-reader/image-decode.d.ts +21 -0
- package/dist/esm/pdf-reader/image-decode.js +14 -0
- package/dist/esm/pdf-reader/images.d.ts +19 -0
- package/dist/esm/pdf-reader/images.js +9 -0
- package/dist/esm/pdf-reader/layout.d.ts +15 -0
- package/dist/esm/pdf-reader/layout.js +17 -2
- package/dist/esm/pdf-reader/lexer.d.ts +43 -0
- package/dist/esm/pdf-reader/lexer.js +38 -0
- package/dist/esm/pdf-reader/parser.d.ts +15 -0
- package/dist/esm/pdf-reader/parser.js +8 -0
- package/dist/esm/pdf-reader/png-encode.d.ts +9 -0
- package/dist/esm/pdf-reader/png-encode.js +8 -0
- package/dist/esm/pdf-reader/predictor.d.ts +9 -0
- package/dist/esm/pdf-reader/predictor.js +8 -0
- package/dist/esm/pdf-reader/reader.d.ts +16 -0
- package/dist/esm/pdf-reader/reader.js +16 -0
- package/dist/esm/pdf-reader/shading.d.ts +10 -0
- package/dist/esm/pdf-reader/shading.js +10 -0
- package/dist/esm/pdf-reader/struct-tree.d.ts +24 -0
- package/dist/esm/pdf-reader/struct-tree.js +12 -0
- package/dist/esm/pdf-reader/tagged.d.ts +13 -0
- package/dist/esm/pdf-reader/tagged.js +15 -2
- package/dist/esm/pdf-reader/text.d.ts +11 -0
- package/dist/esm/pdf-reader/text.js +11 -0
- package/dist/esm/pdf-reader/vector.d.ts +19 -0
- package/dist/esm/pdf-reader/vector.js +9 -0
- package/dist/esm/pptx/placeholder-cascade.d.ts +21 -0
- package/dist/esm/pptx/placeholder-cascade.js +10 -0
- package/dist/esm/pptx/ppt/ppt-reader.d.ts +16 -0
- package/dist/esm/pptx/ppt/ppt-reader.js +16 -0
- package/dist/esm/pptx/ppt/ppt-text.d.ts +55 -0
- package/dist/esm/pptx/ppt/ppt-text.js +14 -0
- package/dist/esm/pptx/pptx-reader.d.ts +21 -0
- package/dist/esm/pptx/pptx-reader.js +37 -1
- package/dist/esm/pptx/slide-parser.d.ts +102 -0
- package/dist/esm/pptx/slide-parser.js +78 -0
- package/dist/esm/pptx/sp-helpers.d.ts +28 -0
- package/dist/esm/pptx/sp-helpers.js +22 -0
- package/dist/esm/svg/svg-writer.d.ts +17 -0
- package/dist/esm/svg/svg-writer.js +16 -0
- package/dist/esm/word/doc/doc-reader.d.ts +16 -0
- package/dist/esm/word/doc/doc-reader.js +26 -4
- package/dist/esm/word/doc/doc-text.d.ts +81 -0
- package/dist/esm/word/doc/doc-text.js +38 -0
- package/dist/esm/word/document-parser.d.ts +134 -0
- package/dist/esm/word/document-parser.js +86 -0
- package/dist/esm/word/docx-reader.d.ts +16 -0
- package/dist/esm/word/docx-reader.js +16 -0
- package/dist/esm/word/docx-to-pdf.d.ts +52 -0
- package/dist/esm/word/docx-to-pdf.js +21 -0
- package/dist/esm/word/docx-writer.d.ts +17 -0
- package/dist/esm/word/docx-writer.js +17 -0
- package/dist/esm/word/drawing-parser.d.ts +88 -0
- package/dist/esm/word/drawing-parser.js +68 -0
- package/dist/esm/word/font-table.d.ts +24 -0
- package/dist/esm/word/font-table.js +24 -0
- package/dist/esm/word/numbering-parser.d.ts +11 -0
- package/dist/esm/word/numbering-parser.js +11 -0
- package/dist/esm/word/omml-parser.d.ts +15 -0
- package/dist/esm/word/omml-parser.js +15 -0
- package/dist/esm/word/omml-serializer.d.ts +9 -0
- package/dist/esm/word/omml-serializer.js +9 -0
- package/dist/esm/word/paragraph-properties.d.ts +10 -0
- package/dist/esm/word/paragraph-properties.js +10 -0
- package/dist/esm/word/po-to-flat.d.ts +11 -0
- package/dist/esm/word/po-to-flat.js +11 -0
- package/dist/esm/word/run-properties.d.ts +10 -0
- package/dist/esm/word/run-properties.js +10 -0
- package/dist/esm/word/settings-parser.d.ts +13 -0
- package/dist/esm/word/settings-parser.js +8 -0
- package/dist/esm/word/styles-parser.d.ts +10 -0
- package/dist/esm/word/styles-parser.js +10 -0
- package/dist/esm/word/table-parser.d.ts +11 -0
- package/dist/esm/word/table-parser.js +11 -0
- package/dist/esm/word/text-extractor.d.ts +9 -0
- package/dist/esm/word/xml-helpers.d.ts +44 -0
- package/dist/esm/word/xml-helpers.js +38 -0
- package/package.json +1 -1
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A capability/loss feature name. A plain string, hierarchical via dot-segments
|
|
3
|
+
* (`'tables.nested'` ⊂ `'tables'`); the vocabulary is OPEN so third-party
|
|
4
|
+
* adapters can introduce their own. {@link FEATURES} canonicalizes the names the
|
|
5
|
+
* core uses.
|
|
6
|
+
*/
|
|
1
7
|
export type Feature = string;
|
|
8
|
+
/** The feature names the core declares, so the docs' capability matrix is code-generated. */
|
|
2
9
|
export declare const FEATURES: {
|
|
3
10
|
readonly text: "text";
|
|
4
11
|
readonly tables: "tables";
|
|
@@ -23,6 +30,7 @@ export declare const FEATURES: {
|
|
|
23
30
|
readonly pdfTagged: "pdf.tagged";
|
|
24
31
|
readonly pdfSignatures: "pdf.signatures";
|
|
25
32
|
};
|
|
33
|
+
/** Union of the canonical {@link FEATURES} values. */
|
|
26
34
|
export type KnownFeature = (typeof FEATURES)[keyof typeof FEATURES];
|
|
27
35
|
/** True when `feature` equals `prefix` or sits under it ('tables.nested' ⊂ 'tables'). */
|
|
28
36
|
export declare function featureWithin(feature: Feature, prefix: Feature): boolean;
|
|
@@ -1,14 +1,34 @@
|
|
|
1
1
|
import { BodyElement, Chart, Comment, DocumentInfo, Numbering, Section, SectionProperties, StyleSheet } from '../document-model/index.js';
|
|
2
2
|
import { FontRegistry } from '../font/index.js';
|
|
3
3
|
import { ResourceStore } from './resources.js';
|
|
4
|
+
/**
|
|
5
|
+
* The semantic IR tree (ir-design §5): everything a reader extracts from the
|
|
6
|
+
* document bytes, format-neutrally — the flow `body` plus its document-scoped
|
|
7
|
+
* companions (styles, numbering, header/footer bands, notes, charts, binary
|
|
8
|
+
* resources, metadata). Caller-supplied conversion options (fonts, PDF/A
|
|
9
|
+
* profile, signature, …) are deliberately NOT part of the tree; they
|
|
10
|
+
* parameterize transforms, not the document.
|
|
11
|
+
*
|
|
12
|
+
* `body` carries FINAL effective properties — readers materialize list markers
|
|
13
|
+
* and resolve the style cascade while building it — so render projections must
|
|
14
|
+
* not re-apply `styles`/`numbering`, which remain only as round-trip material.
|
|
15
|
+
*/
|
|
4
16
|
export interface FlowDoc {
|
|
17
|
+
/** Discriminant for {@link SourceDoc} (a FlowDoc passes through projection). */
|
|
5
18
|
readonly kind: 'flow';
|
|
19
|
+
/** The document flow content, carrying resolved, effective properties. */
|
|
6
20
|
readonly body: ReadonlyArray<BodyElement>;
|
|
7
21
|
/** Multi-section page geometry (docx). Empty for single-geometry sources. */
|
|
8
22
|
readonly sections: ReadonlyArray<Section>;
|
|
9
23
|
/** Single-section page geometry (xlsx print setup). */
|
|
10
24
|
readonly section?: SectionProperties;
|
|
25
|
+
/** Resolved style sheet, kept as round-trip material (already folded into `body`). */
|
|
11
26
|
readonly styles: StyleSheet;
|
|
27
|
+
/**
|
|
28
|
+
* Raw numbering definitions (round-trip material). `body` already carries the
|
|
29
|
+
* materialized list markers — readers apply numbering as a FlowDoc transform,
|
|
30
|
+
* so render projections must not re-apply it.
|
|
31
|
+
*/
|
|
12
32
|
readonly numbering?: Numbering;
|
|
13
33
|
readonly headersFooters?: ReadonlyMap<string, ReadonlyArray<BodyElement>>;
|
|
14
34
|
/** §17.11 footnotes/endnotes content by id (separator stubs excluded). */
|
|
@@ -6,6 +6,13 @@ export type { Feature, KnownFeature } from './features.js';
|
|
|
6
6
|
export { FEATURES, featureWithin } from './features.js';
|
|
7
7
|
export type { Loss, LossReport, LossSeverity } from './loss.js';
|
|
8
8
|
export { ConversionLossError, formatLoss } from './loss.js';
|
|
9
|
+
/**
|
|
10
|
+
* Passthrough bag for the round-trip door (ir-design §4): a node MAY carry the
|
|
11
|
+
* source format's raw fragment keyed by format id (e.g. `{ ooxml: <fragment> }`).
|
|
12
|
+
* Writers for other formats ignore it; a same-format writer may use it to
|
|
13
|
+
* reproduce constructs the neutral core does not model. v1 promises only
|
|
14
|
+
* cross-format fidelity — this keeps the door open without promising more.
|
|
15
|
+
*/
|
|
9
16
|
export interface NativeBag {
|
|
10
17
|
readonly [formatId: string]: unknown;
|
|
11
18
|
}
|
|
@@ -5,18 +5,30 @@ import { Feature } from './features.js';
|
|
|
5
5
|
* - `substituted` — content was replaced by an equivalent (e.g. font substitution).
|
|
6
6
|
*/
|
|
7
7
|
export type LossSeverity = 'dropped' | 'degraded' | 'substituted';
|
|
8
|
+
/** A single conversion loss: something the pipeline dropped, degraded or substituted. */
|
|
8
9
|
export interface Loss {
|
|
10
|
+
/** How badly the content was affected. */
|
|
9
11
|
readonly severity: LossSeverity;
|
|
12
|
+
/** The affected {@link Feature} (drives the capability/loss matrix). */
|
|
10
13
|
readonly feature: Feature;
|
|
11
14
|
/** Human-readable specifics: what exactly happened to what. */
|
|
12
15
|
readonly detail: string;
|
|
13
16
|
/** Optional location hint (page/paragraph/sheet reference). */
|
|
14
17
|
readonly where?: string;
|
|
15
18
|
}
|
|
19
|
+
/** An ordered, read-only list of {@link Loss} entries, returned alongside the output. */
|
|
16
20
|
export type LossReport = ReadonlyArray<Loss>;
|
|
21
|
+
/**
|
|
22
|
+
* Format a {@link Loss} as one human-readable line, e.g.
|
|
23
|
+
* `[degraded] charts at sheet "Q3": gradient flattened`.
|
|
24
|
+
*
|
|
25
|
+
* @param loss The loss to format.
|
|
26
|
+
* @returns The one-line description.
|
|
27
|
+
*/
|
|
17
28
|
export declare function formatLoss(loss: Loss): string;
|
|
18
29
|
/** Thrown by strict-mode conversions on the first recorded loss. */
|
|
19
30
|
export declare class ConversionLossError extends Error {
|
|
20
31
|
readonly loss: Loss;
|
|
32
|
+
/** @param loss The first loss that tripped strict mode (retained on the error). */
|
|
21
33
|
constructor(loss: Loss);
|
|
22
34
|
}
|
package/dist/esm/core/ir/loss.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
//#region src/core/ir/loss.ts
|
|
2
|
+
/**
|
|
3
|
+
* Format a {@link Loss} as one human-readable line, e.g.
|
|
4
|
+
* `[degraded] charts at sheet "Q3": gradient flattened`.
|
|
5
|
+
*
|
|
6
|
+
* @param loss The loss to format.
|
|
7
|
+
* @returns The one-line description.
|
|
8
|
+
*/
|
|
2
9
|
function formatLoss(loss) {
|
|
3
10
|
const where = loss.where ? ` at ${loss.where}` : "";
|
|
4
11
|
return `[${loss.severity}] ${loss.feature}${where}: ${loss.detail}`;
|
|
5
12
|
}
|
|
6
13
|
/** Thrown by strict-mode conversions on the first recorded loss. */
|
|
7
14
|
var ConversionLossError = class extends Error {
|
|
15
|
+
/** @param loss The first loss that tripped strict mode (retained on the error). */
|
|
8
16
|
constructor(loss) {
|
|
9
17
|
super(`strict conversion failed — ${formatLoss(loss)}`);
|
|
10
18
|
this.loss = loss;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
/** A content-addressed id for a binary resource held in a {@link ResourceStore}. */
|
|
1
2
|
export type ResourceId = string & {
|
|
2
3
|
readonly __brand: 'resource-id';
|
|
3
4
|
};
|
|
5
|
+
/**
|
|
6
|
+
* A content-addressed store for the IR's binary payloads (images, fonts). IR
|
|
7
|
+
* trees stay pure JSON and reference bytes by {@link ResourceId}; ids derive
|
|
8
|
+
* from the bytes (a synchronous 64-bit FNV-1a), so identical payloads
|
|
9
|
+
* deduplicate for free and equal documents get equal ids — which keeps IR-level
|
|
10
|
+
* diffs and the byte-identical gates meaningful.
|
|
11
|
+
*/
|
|
4
12
|
export declare class ResourceStore {
|
|
5
13
|
private readonly byId;
|
|
6
14
|
/**
|
|
@@ -9,8 +17,12 @@ export declare class ResourceStore {
|
|
|
9
17
|
* different bytes probes deterministic `~n` suffixes.
|
|
10
18
|
*/
|
|
11
19
|
put(bytes: Uint8Array): ResourceId;
|
|
20
|
+
/** Look up the bytes for an id, or `undefined` when absent. */
|
|
12
21
|
get(id: ResourceId): Uint8Array | undefined;
|
|
22
|
+
/** Whether an id is present in the store. */
|
|
13
23
|
has(id: ResourceId): boolean;
|
|
24
|
+
/** All stored ids, in insertion order. */
|
|
14
25
|
ids(): ReadonlyArray<ResourceId>;
|
|
26
|
+
/** The number of distinct resources stored. */
|
|
15
27
|
get size(): number;
|
|
16
28
|
}
|
|
@@ -14,6 +14,13 @@ function equalBytes(x, y) {
|
|
|
14
14
|
for (let i = 0; i < x.length; i++) if (x[i] !== y[i]) return false;
|
|
15
15
|
return true;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* A content-addressed store for the IR's binary payloads (images, fonts). IR
|
|
19
|
+
* trees stay pure JSON and reference bytes by {@link ResourceId}; ids derive
|
|
20
|
+
* from the bytes (a synchronous 64-bit FNV-1a), so identical payloads
|
|
21
|
+
* deduplicate for free and equal documents get equal ids — which keeps IR-level
|
|
22
|
+
* diffs and the byte-identical gates meaningful.
|
|
23
|
+
*/
|
|
17
24
|
var ResourceStore = class {
|
|
18
25
|
byId = /* @__PURE__ */ new Map();
|
|
19
26
|
/**
|
|
@@ -33,15 +40,19 @@ var ResourceStore = class {
|
|
|
33
40
|
if (equalBytes(existing, bytes)) return id;
|
|
34
41
|
}
|
|
35
42
|
}
|
|
43
|
+
/** Look up the bytes for an id, or `undefined` when absent. */
|
|
36
44
|
get(id) {
|
|
37
45
|
return this.byId.get(id);
|
|
38
46
|
}
|
|
47
|
+
/** Whether an id is present in the store. */
|
|
39
48
|
has(id) {
|
|
40
49
|
return this.byId.has(id);
|
|
41
50
|
}
|
|
51
|
+
/** All stored ids, in insertion order. */
|
|
42
52
|
ids() {
|
|
43
53
|
return [...this.byId.keys()];
|
|
44
54
|
}
|
|
55
|
+
/** The number of distinct resources stored. */
|
|
45
56
|
get size() {
|
|
46
57
|
return this.byId.size;
|
|
47
58
|
}
|
|
@@ -1,65 +1,146 @@
|
|
|
1
1
|
import { Chart, DocumentInfo, ShapeBlock } from '../document-model/index.js';
|
|
2
2
|
import { DefinedName, MergedRange, ParsedWorksheet, SheetRichRun, XlsxStyles } from '../spreadsheet-model/index.js';
|
|
3
3
|
import { ResourceId, ResourceStore } from './resources.js';
|
|
4
|
+
/**
|
|
5
|
+
* §20.5 SpreadsheetDrawingML — a chart frame anchored over a sheet's grid,
|
|
6
|
+
* already sized from its two-cell anchor. `chartPartPath` keys into
|
|
7
|
+
* {@link SheetDoc.chartData} for the resolved chart.
|
|
8
|
+
*/
|
|
4
9
|
export interface SheetChartRef {
|
|
5
10
|
readonly chartPartPath: string;
|
|
6
11
|
readonly widthPt: number;
|
|
7
12
|
readonly heightPt: number;
|
|
8
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* §20.5.2.1 xdr:pic — a picture anchored over a sheet's grid, sized from its
|
|
16
|
+
* anchor. The bytes live in {@link SheetDoc.resources}; `resourceId` keys into
|
|
17
|
+
* it. The projection emits an ImageBlock per picture after the grid.
|
|
18
|
+
*/
|
|
9
19
|
export interface SheetImageRef {
|
|
10
20
|
readonly resourceId: ResourceId;
|
|
11
21
|
readonly widthPt: number;
|
|
12
22
|
readonly heightPt: number;
|
|
13
23
|
}
|
|
24
|
+
/** One item (label + selection state) in a {@link SheetSlicer}. */
|
|
14
25
|
export interface SheetSlicerItem {
|
|
26
|
+
/** The item's display label. */
|
|
15
27
|
readonly label: string;
|
|
28
|
+
/** Whether the item is currently selected (filtered in). */
|
|
16
29
|
readonly selected: boolean;
|
|
17
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* A slicer panel (xl/slicers + xl/slicerCaches, E-SHEET SV2) resolved against
|
|
33
|
+
* its source so the projection can render it as a captioned button box after the
|
|
34
|
+
* grid. Items + selection resolve for native-table slicers; an OLAP/pivot slicer
|
|
35
|
+
* the cache cannot resolve inline degrades to a caption-only box.
|
|
36
|
+
*/
|
|
18
37
|
export interface SheetSlicer {
|
|
19
38
|
readonly caption: string;
|
|
20
39
|
readonly columnCount: number;
|
|
21
40
|
readonly items: ReadonlyArray<SheetSlicerItem>;
|
|
41
|
+
/**
|
|
42
|
+
* Resolved fills + header text colour from the slicer style name + workbook
|
|
43
|
+
* theme (the same accent heuristic as tables/pivots). Absent ⇒ a plain box.
|
|
44
|
+
*/
|
|
22
45
|
readonly headerHex?: string;
|
|
23
46
|
readonly selectedHex?: string;
|
|
24
47
|
readonly headerTextHex?: string;
|
|
25
48
|
readonly selectedTextHex?: string;
|
|
26
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* §18.3.1.47 — a cell (or range) hyperlink resolved to an external URL (E-SHEET
|
|
52
|
+
* W3). The projection stamps `run.href` on every cell the range covers.
|
|
53
|
+
*/
|
|
27
54
|
export interface SheetHyperlink {
|
|
28
55
|
readonly ref: MergedRange;
|
|
29
56
|
readonly url: string;
|
|
30
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* A cell comment / note (E-SHEET W7): an A1 anchor, the resolved author display
|
|
60
|
+
* name, the text body, and whether it came from the modern threaded comments
|
|
61
|
+
* part (a conversation) or the legacy note part.
|
|
62
|
+
*/
|
|
31
63
|
export interface SheetComment {
|
|
32
64
|
readonly ref: string;
|
|
33
65
|
readonly author?: string;
|
|
34
66
|
readonly text: string;
|
|
35
67
|
readonly threaded: boolean;
|
|
36
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* A form control resolved against its ctrlProp part (E-SHEET W8): the display
|
|
71
|
+
* name, the `objectType` (CheckBox / Radio / Spin / …) and the bit of state the
|
|
72
|
+
* listing shows — `checked` for check/option buttons, `value` for
|
|
73
|
+
* spin/scroll/list controls. Render-only.
|
|
74
|
+
*/
|
|
37
75
|
export interface SheetFormControl {
|
|
38
76
|
readonly name?: string;
|
|
39
77
|
readonly objectType?: string;
|
|
40
78
|
readonly checked?: boolean;
|
|
41
79
|
readonly value?: number;
|
|
42
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* An ActiveX control resolved against its activeX part (E-SHEET W10): the control
|
|
83
|
+
* class (`type`, from the `<oleObject progId>`) plus the visible state persisted
|
|
84
|
+
* in the property bag — `caption`, `value` (checked/text/number, as a string)
|
|
85
|
+
* and OptionButton `groupName`. Render-only.
|
|
86
|
+
*/
|
|
43
87
|
export interface SheetActiveXControl {
|
|
44
88
|
readonly type: string;
|
|
45
89
|
readonly caption?: string;
|
|
46
90
|
readonly value?: string;
|
|
47
91
|
readonly groupName?: string;
|
|
48
92
|
}
|
|
93
|
+
/** One worksheet: the parsed grid plus its resolved, anchor-ordered overlays. */
|
|
49
94
|
export interface Sheet {
|
|
95
|
+
/** The sheet (tab) name. */
|
|
50
96
|
readonly name: string;
|
|
97
|
+
/**
|
|
98
|
+
* The grid + per-sheet geometry exactly as parsed: cells, columns, rows,
|
|
99
|
+
* merges, dimensions, pageSetup/printOptions, manual breaks, drawingRelId.
|
|
100
|
+
*/
|
|
51
101
|
readonly grid: ParsedWorksheet;
|
|
102
|
+
/** Chart frames on this sheet, anchor-ordered (resolved data in {@link SheetDoc.chartData}). */
|
|
52
103
|
readonly charts?: ReadonlyArray<SheetChartRef>;
|
|
104
|
+
/** Picture frames on this sheet, anchor-ordered (bytes in {@link SheetDoc.resources}). */
|
|
53
105
|
readonly images?: ReadonlyArray<SheetImageRef>;
|
|
106
|
+
/** Drawing shapes on this sheet (E-SHEET W2), fully resolved + anchor-ordered. */
|
|
54
107
|
readonly shapes?: ReadonlyArray<ShapeBlock>;
|
|
108
|
+
/**
|
|
109
|
+
* Cell hyperlinks resolved to external URLs (E-SHEET W3); the projection sets
|
|
110
|
+
* `run.href` on covered cells. In-workbook (location-only) links are not carried.
|
|
111
|
+
*/
|
|
55
112
|
readonly hyperlinks?: ReadonlyArray<SheetHyperlink>;
|
|
113
|
+
/** Slicer panels on this sheet (E-SHEET SV2), rendered after the grid + charts. */
|
|
56
114
|
readonly slicers?: ReadonlyArray<SheetSlicer>;
|
|
115
|
+
/**
|
|
116
|
+
* Cell comments / notes (E-SHEET W7), legacy and threaded. The projection
|
|
117
|
+
* lists them in a "Comments" section after the grid (mirroring Excel's "print
|
|
118
|
+
* comments at end of sheet"); render-only.
|
|
119
|
+
*/
|
|
57
120
|
readonly comments?: ReadonlyArray<SheetComment>;
|
|
121
|
+
/**
|
|
122
|
+
* Form controls on this sheet (E-SHEET W8), resolved to type + state. Listed
|
|
123
|
+
* in a "Form controls" section after the grid; render-only.
|
|
124
|
+
*/
|
|
58
125
|
readonly formControls?: ReadonlyArray<SheetFormControl>;
|
|
126
|
+
/**
|
|
127
|
+
* ActiveX controls on this sheet (E-SHEET W10), resolved to type + visible
|
|
128
|
+
* state. Listed in an "ActiveX controls" section after the grid; render-only.
|
|
129
|
+
*/
|
|
59
130
|
readonly activeXControls?: ReadonlyArray<SheetActiveXControl>;
|
|
60
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* The SpreadsheetML IR tree (E-SHEET): a workbook of grid {@link Sheet}s plus
|
|
134
|
+
* its workbook-scoped companions — the style table, shared-string table, defined
|
|
135
|
+
* names, date system, parsed charts, binary resources and metadata. Cells keep
|
|
136
|
+
* their RAW stored value + a style index; resolution (shared strings, number
|
|
137
|
+
* formats, the style cascade, the print model) happens at the projection
|
|
138
|
+
* boundary, never in the tree.
|
|
139
|
+
*/
|
|
61
140
|
export interface SheetDoc {
|
|
141
|
+
/** Discriminant for {@link SourceDoc} (projected to a FlowDoc for rendering). */
|
|
62
142
|
readonly kind: 'sheet';
|
|
143
|
+
/** The workbook's worksheets, in tab order. */
|
|
63
144
|
readonly sheets: ReadonlyArray<Sheet>;
|
|
64
145
|
/** §18.8 workbook style table (cellXfs + fonts/fills/borders/numFmts). */
|
|
65
146
|
readonly styles: XlsxStyles;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The IR's one length unit: PostScript points (1/72 inch), as a branded number.
|
|
3
|
+
* Readers convert their format-native units (twips, half-points, EMU, …) to `Pt`
|
|
4
|
+
* at the boundary, and writers convert out the same way. The brand is shallow —
|
|
5
|
+
* a `Pt` is assignable to `number` so layout arithmetic reads it freely; only
|
|
6
|
+
* *constructing* one requires {@link pt} or a `*ToPt` converter.
|
|
7
|
+
*/
|
|
1
8
|
export type Pt = number & {
|
|
2
9
|
readonly __brand: 'pt';
|
|
3
10
|
};
|
|
@@ -12,5 +19,7 @@ export declare function eighthPtToPt(eighthPt: number): Pt;
|
|
|
12
19
|
export declare function emuToPt(emu: number): Pt;
|
|
13
20
|
/** CSS reference pixels: 96 px = 1 inch = 72 pt. */
|
|
14
21
|
export declare function pxToPt(px: number): Pt;
|
|
22
|
+
/** Inches: 1 inch = 72 pt. */
|
|
15
23
|
export declare function inchToPt(inches: number): Pt;
|
|
24
|
+
/** Millimetres: 25.4 mm = 1 inch = 72 pt. */
|
|
16
25
|
export declare function mmToPt(mm: number): Pt;
|
|
@@ -31,9 +31,11 @@ function emuToPt(emu) {
|
|
|
31
31
|
function pxToPt(px) {
|
|
32
32
|
return px * .75;
|
|
33
33
|
}
|
|
34
|
+
/** Inches: 1 inch = 72 pt. */
|
|
34
35
|
function inchToPt(inches) {
|
|
35
36
|
return inches * 72;
|
|
36
37
|
}
|
|
38
|
+
/** Millimetres: 25.4 mm = 1 inch = 72 pt. */
|
|
37
39
|
function mmToPt(mm) {
|
|
38
40
|
return mm / 25.4 * 72;
|
|
39
41
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** True for a "wide" CJK code point that carries inter-character break opportunities. */
|
|
2
|
+
export declare function isCjkWide(cp: number): boolean;
|
|
3
|
+
/** True for a wide closing punctuation / non-starter that must not start a line. */
|
|
4
|
+
export declare function isCjkNoBreakBefore(cp: number): boolean;
|
|
5
|
+
/** True for a wide opening punctuation that must not end a line (break after it). */
|
|
6
|
+
export declare function isCjkNoBreakAfter(cp: number): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Split a whitespace-free segment so each wide CJK character becomes its own
|
|
9
|
+
* piece, while non-CJK runs stay grouped. Returns the input as a single-element
|
|
10
|
+
* array when it holds no CJK — so Latin / non-CJK tokenization stays byte-identical.
|
|
11
|
+
*
|
|
12
|
+
* @param seg A run of non-whitespace text.
|
|
13
|
+
* @returns The pieces, in order.
|
|
14
|
+
*/
|
|
15
|
+
export declare function splitCjkSegment(seg: string): Array<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Whether a line may break between code point `left` (end of the piece before the
|
|
18
|
+
* boundary) and `right` (start of the piece after it). A break needs at least one
|
|
19
|
+
* wide character on the boundary, and is suppressed before a non-starter or after
|
|
20
|
+
* a non-ender.
|
|
21
|
+
*
|
|
22
|
+
* @param left The last code point of the left piece.
|
|
23
|
+
* @param right The first code point of the right piece.
|
|
24
|
+
* @returns `true` when a break is allowed here.
|
|
25
|
+
*/
|
|
26
|
+
export declare function cjkBreakBetween(left: number, right: number): boolean;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
//#region src/core/line-breaker/cjk.ts
|
|
2
|
+
/** True for a "wide" CJK code point that carries inter-character break opportunities. */
|
|
3
|
+
function isCjkWide(cp) {
|
|
4
|
+
return cp >= 11904 && cp <= 12031 || cp >= 12288 && cp <= 12351 || cp >= 12352 && cp <= 12543 || cp >= 13312 && cp <= 19903 || cp >= 19968 && cp <= 40959 || cp >= 63744 && cp <= 64255 || cp >= 65280 && cp <= 65519 || cp >= 131072 && cp <= 262143;
|
|
5
|
+
}
|
|
6
|
+
var NO_BREAK_BEFORE = new Set([..."、。,.!?:;」』】)〕〉》}〞〟」‐・…‥ー〜々ゝゞ", ..."ぁぃぅぇぉっゃゅょゎァィゥェォッャュョヮ"].map((c) => c.codePointAt(0)));
|
|
7
|
+
var NO_BREAK_AFTER = new Set([..."({「『【〔〈《〝⦅"].map((c) => c.codePointAt(0)));
|
|
8
|
+
/** True for a wide closing punctuation / non-starter that must not start a line. */
|
|
9
|
+
function isCjkNoBreakBefore(cp) {
|
|
10
|
+
return NO_BREAK_BEFORE.has(cp);
|
|
11
|
+
}
|
|
12
|
+
/** True for a wide opening punctuation that must not end a line (break after it). */
|
|
13
|
+
function isCjkNoBreakAfter(cp) {
|
|
14
|
+
return NO_BREAK_AFTER.has(cp);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Split a whitespace-free segment so each wide CJK character becomes its own
|
|
18
|
+
* piece, while non-CJK runs stay grouped. Returns the input as a single-element
|
|
19
|
+
* array when it holds no CJK — so Latin / non-CJK tokenization stays byte-identical.
|
|
20
|
+
*
|
|
21
|
+
* @param seg A run of non-whitespace text.
|
|
22
|
+
* @returns The pieces, in order.
|
|
23
|
+
*/
|
|
24
|
+
function splitCjkSegment(seg) {
|
|
25
|
+
let hasWide = false;
|
|
26
|
+
for (const ch of seg) if (isCjkWide(ch.codePointAt(0))) {
|
|
27
|
+
hasWide = true;
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
if (!hasWide) return [seg];
|
|
31
|
+
const out = [];
|
|
32
|
+
let buf = "";
|
|
33
|
+
for (const ch of seg) if (isCjkWide(ch.codePointAt(0))) {
|
|
34
|
+
if (buf) {
|
|
35
|
+
out.push(buf);
|
|
36
|
+
buf = "";
|
|
37
|
+
}
|
|
38
|
+
out.push(ch);
|
|
39
|
+
} else buf += ch;
|
|
40
|
+
if (buf) out.push(buf);
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Whether a line may break between code point `left` (end of the piece before the
|
|
45
|
+
* boundary) and `right` (start of the piece after it). A break needs at least one
|
|
46
|
+
* wide character on the boundary, and is suppressed before a non-starter or after
|
|
47
|
+
* a non-ender.
|
|
48
|
+
*
|
|
49
|
+
* @param left The last code point of the left piece.
|
|
50
|
+
* @param right The first code point of the right piece.
|
|
51
|
+
* @returns `true` when a break is allowed here.
|
|
52
|
+
*/
|
|
53
|
+
function cjkBreakBetween(left, right) {
|
|
54
|
+
if (!isCjkWide(left) && !isCjkWide(right)) return false;
|
|
55
|
+
if (isCjkNoBreakAfter(left)) return false;
|
|
56
|
+
if (isCjkNoBreakBefore(right)) return false;
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { cjkBreakBetween, isCjkWide, splitCjkSegment };
|
|
@@ -1,2 +1,16 @@
|
|
|
1
1
|
import { Item } from './knuth-plass.js';
|
|
2
|
+
/**
|
|
3
|
+
* Break a paragraph into lines greedily (first-fit, E-PARITY FP3): each line
|
|
4
|
+
* ends at the last feasible breakpoint that still fits the target width, never
|
|
5
|
+
* looking ahead to balance the paragraph — matching Word/LibreOffice line (and
|
|
6
|
+
* page) counts under a renderer-compatibility `layoutProfile`. An over-long run
|
|
7
|
+
* with no earlier break gets an emergency break so it cannot merge forward.
|
|
8
|
+
*
|
|
9
|
+
* @param items The box/glue/penalty stream, sharing the {@link Item} shape
|
|
10
|
+
* and feasibility convention of {@link breakLines}.
|
|
11
|
+
* @param lineWidths Target width: a single number (uniform) or a per-line array
|
|
12
|
+
* (0-based), reusing the last entry for trailing lines.
|
|
13
|
+
* @returns Indices into `items` where each line ends — the same shape
|
|
14
|
+
* {@link breakLines} returns, so the layout consumer is identical.
|
|
15
|
+
*/
|
|
2
16
|
export declare function greedyBreakLines(items: ReadonlyArray<Item>, lineWidths: number | ReadonlyArray<number>): ReadonlyArray<number>;
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import { FORBIDDEN_BREAK } from "./knuth-plass.js";
|
|
2
2
|
//#region src/core/line-breaker/greedy.ts
|
|
3
|
+
/**
|
|
4
|
+
* Break a paragraph into lines greedily (first-fit, E-PARITY FP3): each line
|
|
5
|
+
* ends at the last feasible breakpoint that still fits the target width, never
|
|
6
|
+
* looking ahead to balance the paragraph — matching Word/LibreOffice line (and
|
|
7
|
+
* page) counts under a renderer-compatibility `layoutProfile`. An over-long run
|
|
8
|
+
* with no earlier break gets an emergency break so it cannot merge forward.
|
|
9
|
+
*
|
|
10
|
+
* @param items The box/glue/penalty stream, sharing the {@link Item} shape
|
|
11
|
+
* and feasibility convention of {@link breakLines}.
|
|
12
|
+
* @param lineWidths Target width: a single number (uniform) or a per-line array
|
|
13
|
+
* (0-based), reusing the last entry for trailing lines.
|
|
14
|
+
* @returns Indices into `items` where each line ends — the same shape
|
|
15
|
+
* {@link breakLines} returns, so the layout consumer is identical.
|
|
16
|
+
*/
|
|
3
17
|
function greedyBreakLines(items, lineWidths) {
|
|
4
18
|
if (items.length === 0) return [];
|
|
5
19
|
const widthFor = (line) => typeof lineWidths === "number" ? lineWidths : lineWidths[Math.min(line, lineWidths.length - 1)];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { FORCED_BREAK, breakLines } from './knuth-plass.js';
|
|
2
2
|
export { greedyBreakLines } from './greedy.js';
|
|
3
|
+
export { splitCjkSegment, cjkBreakBetween, isCjkWide } from './cjk.js';
|
|
3
4
|
export type { Item, BoxItem, GlueItem, PenaltyItem, BreakResult, } from './knuth-plass.js';
|
|
@@ -1,32 +1,56 @@
|
|
|
1
|
+
/** A box: unbreakable content (a word or glyph cluster) of fixed `width`. */
|
|
1
2
|
export interface BoxItem {
|
|
2
3
|
readonly type: 'box';
|
|
3
4
|
readonly width: number;
|
|
4
5
|
}
|
|
6
|
+
/** Glue: flexible inter-word space, a candidate breakpoint after a {@link BoxItem}. */
|
|
5
7
|
export interface GlueItem {
|
|
6
8
|
readonly type: 'glue';
|
|
9
|
+
/** Natural width. */
|
|
7
10
|
readonly width: number;
|
|
11
|
+
/** How far it can expand (positive). */
|
|
8
12
|
readonly stretch: number;
|
|
13
|
+
/** How far it can contract (positive). */
|
|
9
14
|
readonly shrink: number;
|
|
10
15
|
}
|
|
16
|
+
/** A penalty: an optional breakpoint with a cost (e.g. a hyphenation point). */
|
|
11
17
|
export interface PenaltyItem {
|
|
12
18
|
readonly type: 'penalty';
|
|
19
|
+
/** Width added if the break is taken here (e.g. the hyphen char). */
|
|
13
20
|
readonly width: number;
|
|
21
|
+
/** Break cost: negative = forced, `+Infinity` = forbidden. */
|
|
14
22
|
readonly penalty: number;
|
|
23
|
+
/** True for hyphenation points — two flagged breaks in a row are penalized. */
|
|
15
24
|
readonly flagged: boolean;
|
|
16
25
|
}
|
|
26
|
+
/** One item in the box/glue/penalty stream {@link breakLines} consumes. */
|
|
17
27
|
export type Item = BoxItem | GlueItem | PenaltyItem;
|
|
28
|
+
/** The output of {@link breakLines}: where each line breaks and how it stretches. */
|
|
18
29
|
export interface BreakResult {
|
|
30
|
+
/**
|
|
31
|
+
* Indices into `items[]` where the line breaks happen (the last index is also
|
|
32
|
+
* the final forced break / sentinel penalty).
|
|
33
|
+
*/
|
|
19
34
|
readonly breaks: ReadonlyArray<number>;
|
|
35
|
+
/**
|
|
36
|
+
* Per-line adjustment ratio in `[-1, ∞)`. Used by the layout consumer to
|
|
37
|
+
* distribute extra space across the glues on each line.
|
|
38
|
+
*/
|
|
20
39
|
readonly ratios: ReadonlyArray<number>;
|
|
21
40
|
}
|
|
41
|
+
/** A penalty `≤` this forces a break here; writers push the paragraph-final break with it. */
|
|
22
42
|
export declare const FORCED_BREAK = -10000;
|
|
43
|
+
/** A penalty `≥` this forbids a break here (shared with the greedy breaker). */
|
|
23
44
|
export declare const FORBIDDEN_BREAK = 10000;
|
|
24
45
|
/**
|
|
25
|
-
* Break a paragraph into lines using the Knuth-Plass total-fit algorithm
|
|
46
|
+
* Break a paragraph into lines using the Knuth-Plass total-fit algorithm:
|
|
47
|
+
* dynamic programming over the box/glue/penalty stream that minimizes total
|
|
48
|
+
* demerits across the whole paragraph.
|
|
26
49
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* different, rest the same".
|
|
50
|
+
* @param items The box/glue/penalty stream.
|
|
51
|
+
* @param lineWidths Target width: a number (uniform) or an array indexed by line
|
|
52
|
+
* (0-based); a shorter array reuses its last entry for trailing
|
|
53
|
+
* lines (the common "first line different, rest the same" case).
|
|
54
|
+
* @returns The break indices and per-line adjustment ratios ({@link BreakResult}).
|
|
31
55
|
*/
|
|
32
56
|
export declare function breakLines(items: ReadonlyArray<Item>, lineWidths: number | ReadonlyArray<number>): BreakResult;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
//#region src/core/line-breaker/knuth-plass.ts
|
|
2
|
+
/** A penalty `≤` this forces a break here; writers push the paragraph-final break with it. */
|
|
2
3
|
var FORCED_BREAK = -1e4;
|
|
4
|
+
/** A penalty `≥` this forbids a break here (shared with the greedy breaker). */
|
|
3
5
|
var FORBIDDEN_BREAK = 1e4;
|
|
4
6
|
var LINE_PENALTY = 10;
|
|
5
7
|
var FITNESS_PENALTY = 100;
|
|
@@ -17,12 +19,15 @@ function fitnessClass(r) {
|
|
|
17
19
|
return FIT_VERY_LOOSE;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
|
-
* Break a paragraph into lines using the Knuth-Plass total-fit algorithm
|
|
22
|
+
* Break a paragraph into lines using the Knuth-Plass total-fit algorithm:
|
|
23
|
+
* dynamic programming over the box/glue/penalty stream that minimizes total
|
|
24
|
+
* demerits across the whole paragraph.
|
|
21
25
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* different, rest the same".
|
|
26
|
+
* @param items The box/glue/penalty stream.
|
|
27
|
+
* @param lineWidths Target width: a number (uniform) or an array indexed by line
|
|
28
|
+
* (0-based); a shorter array reuses its last entry for trailing
|
|
29
|
+
* lines (the common "first line different, rest the same" case).
|
|
30
|
+
* @returns The break indices and per-line adjustment ratios ({@link BreakResult}).
|
|
26
31
|
*/
|
|
27
32
|
function breakLines(items, lineWidths) {
|
|
28
33
|
if (items.length === 0) return {
|
|
@@ -1,3 +1,22 @@
|
|
|
1
1
|
import { BodyElement, Numbering } from '../document-model/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Apply list numbering to a body as a FlowDoc transform (§17.9): walk the
|
|
4
|
+
* elements (recursing into table cells), advancing list counters and prepending
|
|
5
|
+
* each numbered paragraph's resolved marker as a leading `listMarker` run, with
|
|
6
|
+
* level-inherited indents. Shapes and charts do not advance counters. Returns the
|
|
7
|
+
* body unchanged when there is no numbering.
|
|
8
|
+
*
|
|
9
|
+
* @param body The body elements to transform.
|
|
10
|
+
* @param numbering The parsed numbering definitions, or `undefined`.
|
|
11
|
+
* @returns A new body with markers materialized.
|
|
12
|
+
*/
|
|
2
13
|
export declare function applyNumbering(body: ReadonlyArray<BodyElement>, numbering: Numbering | undefined): Array<BodyElement>;
|
|
14
|
+
/**
|
|
15
|
+
* Apply {@link applyNumbering} to each header/footer band independently (each
|
|
16
|
+
* gets its own counter state), keyed as in the input map.
|
|
17
|
+
*
|
|
18
|
+
* @param hf The header/footer bodies by key, or `undefined`.
|
|
19
|
+
* @param numbering The parsed numbering definitions, or `undefined`.
|
|
20
|
+
* @returns A new map with numbering applied (empty when `hf` is empty/absent).
|
|
21
|
+
*/
|
|
3
22
|
export declare function applyNumberingToHeadersFooters(hf: ReadonlyMap<string, ReadonlyArray<BodyElement>> | undefined, numbering: Numbering | undefined): ReadonlyMap<string, ReadonlyArray<BodyElement>>;
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import { NumberingState } from "./state.js";
|
|
2
2
|
//#region src/core/numbering/apply.ts
|
|
3
|
+
/**
|
|
4
|
+
* Apply list numbering to a body as a FlowDoc transform (§17.9): walk the
|
|
5
|
+
* elements (recursing into table cells), advancing list counters and prepending
|
|
6
|
+
* each numbered paragraph's resolved marker as a leading `listMarker` run, with
|
|
7
|
+
* level-inherited indents. Shapes and charts do not advance counters. Returns the
|
|
8
|
+
* body unchanged when there is no numbering.
|
|
9
|
+
*
|
|
10
|
+
* @param body The body elements to transform.
|
|
11
|
+
* @param numbering The parsed numbering definitions, or `undefined`.
|
|
12
|
+
* @returns A new body with markers materialized.
|
|
13
|
+
*/
|
|
3
14
|
function applyNumbering(body, numbering) {
|
|
4
15
|
if (!numbering || numbering.abstractNums.size === 0) return body.map((b) => b);
|
|
5
16
|
const state = new NumberingState();
|
|
@@ -54,6 +65,14 @@ function mergeIndentFromLevel(paragraphProps, levelProps) {
|
|
|
54
65
|
if (out.indentFirstLine === void 0 && levelProps.indentFirstLine !== void 0) out.indentFirstLine = levelProps.indentFirstLine;
|
|
55
66
|
return out;
|
|
56
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Apply {@link applyNumbering} to each header/footer band independently (each
|
|
70
|
+
* gets its own counter state), keyed as in the input map.
|
|
71
|
+
*
|
|
72
|
+
* @param hf The header/footer bodies by key, or `undefined`.
|
|
73
|
+
* @param numbering The parsed numbering definitions, or `undefined`.
|
|
74
|
+
* @returns A new map with numbering applied (empty when `hf` is empty/absent).
|
|
75
|
+
*/
|
|
57
76
|
function applyNumberingToHeadersFooters(hf, numbering) {
|
|
58
77
|
if (!hf || hf.size === 0) return /* @__PURE__ */ new Map();
|
|
59
78
|
if (!numbering || numbering.abstractNums.size === 0) return hf;
|