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,7 +1,10 @@
|
|
|
1
|
+
/** A picture shape: the BLIP store index it references plus its cell anchor. */
|
|
1
2
|
export interface EscherPicture {
|
|
3
|
+
/** 1-based index into the BLIP store (the OPT `pib` property). */
|
|
2
4
|
readonly blipIndex: number;
|
|
3
5
|
readonly anchor?: EscherAnchor;
|
|
4
6
|
}
|
|
7
|
+
/** A from/to two-cell anchor (each cell index a u16, each offset 1/1024 of the cell). */
|
|
5
8
|
export interface EscherAnchor {
|
|
6
9
|
readonly col1: number;
|
|
7
10
|
readonly row1: number;
|
|
@@ -12,13 +15,37 @@ export interface EscherAnchor {
|
|
|
12
15
|
readonly dx2: number;
|
|
13
16
|
readonly dy2: number;
|
|
14
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Read the workbook-globals MSODrawingGroup's BLIP store: one entry per BSE (so a
|
|
20
|
+
* `pib` index lines up), holding the extracted image bytes — or `undefined` for
|
|
21
|
+
* an entry we cannot read (a metafile blip, an empty slot), which keeps the
|
|
22
|
+
* indices aligned.
|
|
23
|
+
*
|
|
24
|
+
* @param msoDrawingGroup The concatenated MSODrawingGroup record bytes.
|
|
25
|
+
* @returns The image pool, indexed so `pib − 1` selects an entry.
|
|
26
|
+
*/
|
|
15
27
|
export declare function parseBlipStore(msoDrawingGroup: Uint8Array): Array<Uint8Array | undefined>;
|
|
28
|
+
/**
|
|
29
|
+
* The picture shapes in a sheet's MSODrawing: every SpContainer that carries a
|
|
30
|
+
* `pib` (a picture-fill reference into the BLIP store) with its cell anchor.
|
|
31
|
+
*/
|
|
16
32
|
export declare function parseSheetPictures(msoDrawing: Uint8Array): Array<EscherPicture>;
|
|
33
|
+
/**
|
|
34
|
+
* A non-picture drawing shape: its preset type (MSOSPT), cell anchor, fill/line
|
|
35
|
+
* colours (when literal RGB) and whether it carries a text box.
|
|
36
|
+
*/
|
|
17
37
|
export interface EscherShape {
|
|
38
|
+
/** The MSOSPT preset shape type (the Sp record's instance). */
|
|
18
39
|
readonly shapeType: number;
|
|
40
|
+
/** Whether the shape carries a client text box. */
|
|
19
41
|
readonly hasText: boolean;
|
|
20
42
|
readonly anchor?: EscherAnchor;
|
|
21
43
|
readonly fillColorHex?: string;
|
|
22
44
|
readonly lineColorHex?: string;
|
|
23
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* The non-picture shapes (autoshapes, text boxes) in a sheet's MSODrawing — every
|
|
48
|
+
* SpContainer that is NOT a picture (no `pib`). Pictures are handled separately
|
|
49
|
+
* by {@link parseSheetPictures}.
|
|
50
|
+
*/
|
|
24
51
|
export declare function parseSheetShapes(msoDrawing: Uint8Array): Array<EscherShape>;
|
|
@@ -24,6 +24,15 @@ function* records(d) {
|
|
|
24
24
|
off = end;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Read the workbook-globals MSODrawingGroup's BLIP store: one entry per BSE (so a
|
|
29
|
+
* `pib` index lines up), holding the extracted image bytes — or `undefined` for
|
|
30
|
+
* an entry we cannot read (a metafile blip, an empty slot), which keeps the
|
|
31
|
+
* indices aligned.
|
|
32
|
+
*
|
|
33
|
+
* @param msoDrawingGroup The concatenated MSODrawingGroup record bytes.
|
|
34
|
+
* @returns The image pool, indexed so `pib − 1` selects an entry.
|
|
35
|
+
*/
|
|
27
36
|
function parseBlipStore(msoDrawingGroup) {
|
|
28
37
|
const store = findContainer(msoDrawingGroup, FBT_BSTORE_CONTAINER, 0);
|
|
29
38
|
if (!store) return [];
|
|
@@ -41,6 +50,10 @@ function findContainer(d, type, depth) {
|
|
|
41
50
|
}
|
|
42
51
|
}
|
|
43
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* The picture shapes in a sheet's MSODrawing: every SpContainer that carries a
|
|
55
|
+
* `pib` (a picture-fill reference into the BLIP store) with its cell anchor.
|
|
56
|
+
*/
|
|
44
57
|
function parseSheetPictures(msoDrawing) {
|
|
45
58
|
const out = [];
|
|
46
59
|
collectPictures(msoDrawing, out, 0);
|
|
@@ -63,6 +76,11 @@ var FBT_SP = 61450;
|
|
|
63
76
|
var FBT_CLIENT_TEXTBOX = 61453;
|
|
64
77
|
var PROP_FILL_COLOR = 385;
|
|
65
78
|
var PROP_LINE_COLOR = 448;
|
|
79
|
+
/**
|
|
80
|
+
* The non-picture shapes (autoshapes, text boxes) in a sheet's MSODrawing — every
|
|
81
|
+
* SpContainer that is NOT a picture (no `pib`). Pictures are handled separately
|
|
82
|
+
* by {@link parseSheetPictures}.
|
|
83
|
+
*/
|
|
66
84
|
function parseSheetShapes(msoDrawing) {
|
|
67
85
|
const out = [];
|
|
68
86
|
collectShapes(msoDrawing, out, 0);
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { DocumentReader } from '../../core/ir/adapters.js';
|
|
2
2
|
import { SheetDoc } from '../../core/ir/sheet.js';
|
|
3
|
+
/**
|
|
4
|
+
* The legacy `.xls` {@link DocumentReader} (XLS-3): sniffs a BIFF8 OLE2/CFB
|
|
5
|
+
* workbook and reads it into the same {@link SheetDoc} the OOXML xlsx reader
|
|
6
|
+
* produces, so the whole render pipeline works on a 1997–2003 `.xls`. Reports a
|
|
7
|
+
* single degraded {@link Loss} for the unread Excel-tables / autofilter feature.
|
|
8
|
+
*/
|
|
3
9
|
export declare const xlsReader: DocumentReader<SheetDoc>;
|
|
@@ -16,6 +16,12 @@ var XLS_LOSSES = [{
|
|
|
16
16
|
feature: FEATURES.cellFormatting,
|
|
17
17
|
detail: "legacy .xls Excel tables / autofilter are not read; the sheet’s cell data, styling, images, charts, drawing shapes, conditional formatting, comments, hyperlinks, data validation, defined names, the page-setup print model, frozen panes and custom row heights are"
|
|
18
18
|
}];
|
|
19
|
+
/**
|
|
20
|
+
* The legacy `.xls` {@link DocumentReader} (XLS-3): sniffs a BIFF8 OLE2/CFB
|
|
21
|
+
* workbook and reads it into the same {@link SheetDoc} the OOXML xlsx reader
|
|
22
|
+
* produces, so the whole render pipeline works on a 1997–2003 `.xls`. Reports a
|
|
23
|
+
* single degraded {@link Loss} for the unread Excel-tables / autofilter feature.
|
|
24
|
+
*/
|
|
19
25
|
var xlsReader = {
|
|
20
26
|
id: "xls",
|
|
21
27
|
produces: "sheet",
|
|
@@ -2,6 +2,32 @@ import { DocumentReader, ReadResult } from '../core/ir/adapters.js';
|
|
|
2
2
|
import { FlowDoc } from '../core/ir/flow.js';
|
|
3
3
|
import { SheetDoc } from '../core/ir/sheet.js';
|
|
4
4
|
import { ProjectSheetOptions } from './sheet-to-flow.js';
|
|
5
|
+
/**
|
|
6
|
+
* Read a `.xlsx` and project it to a {@link FlowDoc} in one step:
|
|
7
|
+
* {@link readXlsxToSheetDoc} then {@link projectSheetDoc}. The xlsx reader
|
|
8
|
+
* records no read-time losses.
|
|
9
|
+
*
|
|
10
|
+
* @param xlsx The `.xlsx` (OPC ZIP) bytes.
|
|
11
|
+
* @param options Projection knobs (the W9 reference date).
|
|
12
|
+
* @returns The flow document plus an (empty) loss list.
|
|
13
|
+
*/
|
|
5
14
|
export declare function readXlsx(xlsx: Uint8Array, options?: ProjectSheetOptions): ReadResult<FlowDoc>;
|
|
15
|
+
/**
|
|
16
|
+
* Read a `.xlsx` into the {@link SheetDoc} SpreadsheetML IR node. Everything that
|
|
17
|
+
* needs the OPC package — workbook/worksheet/styles/shared-string parsing, chart
|
|
18
|
+
* and drawing resolution, tables, pivots, slicers, hyperlinks, comments and
|
|
19
|
+
* controls — happens here; the SheetDoc → FlowDoc projection (sheet-to-flow) is
|
|
20
|
+
* then a pure transform.
|
|
21
|
+
*
|
|
22
|
+
* @param xlsx The `.xlsx` (OPC ZIP) bytes.
|
|
23
|
+
* @returns The parsed spreadsheet IR tree.
|
|
24
|
+
* @throws Error when `xl/workbook.xml` is missing or the workbook has no sheets.
|
|
25
|
+
*/
|
|
6
26
|
export declare function readXlsxToSheetDoc(xlsx: Uint8Array): SheetDoc;
|
|
27
|
+
/**
|
|
28
|
+
* The OOXML `.xlsx` {@link DocumentReader}: sniffs the OPC ZIP for
|
|
29
|
+
* `xl/workbook.xml` and reads it into a {@link SheetDoc}. The reader's native
|
|
30
|
+
* tree is the SheetDoc; the facade/Ream project it to a {@link FlowDoc} for
|
|
31
|
+
* rendering (E-SHEET SB1).
|
|
32
|
+
*/
|
|
7
33
|
export declare const xlsxReader: DocumentReader<SheetDoc>;
|
|
@@ -34,12 +34,32 @@ var SLICER_CACHE_REL_TAIL = "/slicerCache";
|
|
|
34
34
|
var THREADED_COMMENTS_REL_TAIL = "/threadedComment";
|
|
35
35
|
var PERSON_REL_TAIL = "/person";
|
|
36
36
|
var MAX_SLICER_ITEMS = 256;
|
|
37
|
+
/**
|
|
38
|
+
* Read a `.xlsx` and project it to a {@link FlowDoc} in one step:
|
|
39
|
+
* {@link readXlsxToSheetDoc} then {@link projectSheetDoc}. The xlsx reader
|
|
40
|
+
* records no read-time losses.
|
|
41
|
+
*
|
|
42
|
+
* @param xlsx The `.xlsx` (OPC ZIP) bytes.
|
|
43
|
+
* @param options Projection knobs (the W9 reference date).
|
|
44
|
+
* @returns The flow document plus an (empty) loss list.
|
|
45
|
+
*/
|
|
37
46
|
function readXlsx(xlsx, options = {}) {
|
|
38
47
|
return {
|
|
39
48
|
doc: projectSheetDoc(readXlsxToSheetDoc(xlsx), options),
|
|
40
49
|
losses: []
|
|
41
50
|
};
|
|
42
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Read a `.xlsx` into the {@link SheetDoc} SpreadsheetML IR node. Everything that
|
|
54
|
+
* needs the OPC package — workbook/worksheet/styles/shared-string parsing, chart
|
|
55
|
+
* and drawing resolution, tables, pivots, slicers, hyperlinks, comments and
|
|
56
|
+
* controls — happens here; the SheetDoc → FlowDoc projection (sheet-to-flow) is
|
|
57
|
+
* then a pure transform.
|
|
58
|
+
*
|
|
59
|
+
* @param xlsx The `.xlsx` (OPC ZIP) bytes.
|
|
60
|
+
* @returns The parsed spreadsheet IR tree.
|
|
61
|
+
* @throws Error when `xl/workbook.xml` is missing or the workbook has no sheets.
|
|
62
|
+
*/
|
|
43
63
|
function readXlsxToSheetDoc(xlsx) {
|
|
44
64
|
const pkg = OpcPackage.open(xlsx);
|
|
45
65
|
const workbookData = pkg.getPart(WORKBOOK_PART);
|
|
@@ -384,6 +404,12 @@ function lighten(hex, amount) {
|
|
|
384
404
|
const hx = (c) => c.toString(16).padStart(2, "0").toUpperCase();
|
|
385
405
|
return `${hx(ch(16))}${hx(ch(8))}${hx(ch(0))}`;
|
|
386
406
|
}
|
|
407
|
+
/**
|
|
408
|
+
* The OOXML `.xlsx` {@link DocumentReader}: sniffs the OPC ZIP for
|
|
409
|
+
* `xl/workbook.xml` and reads it into a {@link SheetDoc}. The reader's native
|
|
410
|
+
* tree is the SheetDoc; the facade/Ream project it to a {@link FlowDoc} for
|
|
411
|
+
* rendering (E-SHEET SB1).
|
|
412
|
+
*/
|
|
387
413
|
var xlsxReader = {
|
|
388
414
|
id: "xlsx",
|
|
389
415
|
produces: "sheet",
|
|
@@ -1,13 +1,40 @@
|
|
|
1
1
|
import { FontBytesByVariant } from '../core/font/index.js';
|
|
2
2
|
import { FetchLike } from '../core/fonts/index.js';
|
|
3
3
|
import { SignatureOptions, StyledRenderOptions } from '../pdf/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Options for the xlsx → PDF convenience converters. Extends the low-level
|
|
6
|
+
* {@link StyledRenderOptions} (minus the font `registry` and `styles`, which the
|
|
7
|
+
* converter builds itself) with font acquisition and source-touching conveniences.
|
|
8
|
+
*/
|
|
4
9
|
export interface ConvertXlsxOptions extends Omit<StyledRenderOptions, 'registry' | 'styles'> {
|
|
10
|
+
/** Shorthand for supplying a single regular-variant font as raw bytes. */
|
|
5
11
|
readonly fontBytes?: Uint8Array;
|
|
12
|
+
/** Explicit font bytes per variant (regular/bold/italic/bold-italic). */
|
|
6
13
|
readonly fonts?: FontBytesByVariant;
|
|
14
|
+
/**
|
|
15
|
+
* Force a substitute font family for the auto-download path. Ignored when
|
|
16
|
+
* `fonts`/`fontBytes` are supplied.
|
|
17
|
+
*/
|
|
7
18
|
readonly fontFamily?: string;
|
|
19
|
+
/** Injectable `fetch` for the auto-download path (defaults to the global `fetch`). */
|
|
8
20
|
readonly fontFetch?: FetchLike;
|
|
21
|
+
/**
|
|
22
|
+
* For PDF/A-3 only: embed the input `.xlsx` as an associated source file
|
|
23
|
+
* (`/AFRelationship /Source`). Ignored for other profiles.
|
|
24
|
+
*/
|
|
9
25
|
readonly embedSource?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* E-SHEET W9 — the reference date for conditional-format `timePeriod` rules and
|
|
28
|
+
* `TODAY()`/`NOW()` in `expression` rules. An explicit input (never the wall
|
|
29
|
+
* clock), so output stays deterministic; omitted ⇒ those clock-relative rules
|
|
30
|
+
* no-op.
|
|
31
|
+
*/
|
|
10
32
|
readonly now?: Date;
|
|
33
|
+
/**
|
|
34
|
+
* Digitally sign the output (ISO 32000 §12.8). Requires the async
|
|
35
|
+
* {@link convertXlsxToPdf} (signing uses WebCrypto). Ignored by the sync
|
|
36
|
+
* converter.
|
|
37
|
+
*/
|
|
11
38
|
readonly signature?: SignatureOptions;
|
|
12
39
|
}
|
|
13
40
|
/**
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import { DocumentWriter, WriteResult } from '../core/ir/adapters.js';
|
|
2
2
|
import { SheetDoc } from '../core/ir/sheet.js';
|
|
3
|
+
/**
|
|
4
|
+
* Serialize a {@link SheetDoc} back to a `.xlsx` (E-SHEET SD1). The first writer
|
|
5
|
+
* that consumes the SpreadsheetML IR node directly (not the FlowDoc projection),
|
|
6
|
+
* so the cells keep their RAW value + style index and the SheetDoc is a stable
|
|
7
|
+
* round-trip fixpoint (SD2). Re-emits the full grid surface — values, shared
|
|
8
|
+
* strings, styles, merges, column/row geometry, the page model, conditional
|
|
9
|
+
* formatting, sparklines, table parts and embedded charts — through the core OPC
|
|
10
|
+
* writer.
|
|
11
|
+
*
|
|
12
|
+
* @param sheet The spreadsheet IR tree to write.
|
|
13
|
+
* @returns The encoded `.xlsx` bytes and any write-time losses (e.g. a chart
|
|
14
|
+
* frame whose data could not be resolved).
|
|
15
|
+
*/
|
|
3
16
|
export declare function writeXlsx(sheet: SheetDoc): WriteResult;
|
|
17
|
+
/** The `.xlsx` {@link DocumentWriter}: a thin wrapper over {@link writeXlsx}. */
|
|
4
18
|
export declare const xlsxWriter: DocumentWriter<SheetDoc>;
|
|
@@ -24,6 +24,19 @@ var CT_STYLES = "application/vnd.openxmlformats-officedocument.spreadsheetml.sty
|
|
|
24
24
|
var CT_TABLE = "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml";
|
|
25
25
|
var MAIN_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
|
|
26
26
|
var R_NS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
27
|
+
/**
|
|
28
|
+
* Serialize a {@link SheetDoc} back to a `.xlsx` (E-SHEET SD1). The first writer
|
|
29
|
+
* that consumes the SpreadsheetML IR node directly (not the FlowDoc projection),
|
|
30
|
+
* so the cells keep their RAW value + style index and the SheetDoc is a stable
|
|
31
|
+
* round-trip fixpoint (SD2). Re-emits the full grid surface — values, shared
|
|
32
|
+
* strings, styles, merges, column/row geometry, the page model, conditional
|
|
33
|
+
* formatting, sparklines, table parts and embedded charts — through the core OPC
|
|
34
|
+
* writer.
|
|
35
|
+
*
|
|
36
|
+
* @param sheet The spreadsheet IR tree to write.
|
|
37
|
+
* @returns The encoded `.xlsx` bytes and any write-time losses (e.g. a chart
|
|
38
|
+
* frame whose data could not be resolved).
|
|
39
|
+
*/
|
|
27
40
|
function writeXlsx(sheet) {
|
|
28
41
|
const losses = [];
|
|
29
42
|
const worksheetParts = [];
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import { DocumentWriter, WriteResult } from '../core/ir/adapters.js';
|
|
2
2
|
import { FlowDoc } from '../core/ir/flow.js';
|
|
3
|
+
/**
|
|
4
|
+
* Render a {@link FlowDoc} to a self-contained HTML document (ir-design §7).
|
|
5
|
+
*
|
|
6
|
+
* A flow medium: no pagination, no layout engine and no fonts to embed, so this
|
|
7
|
+
* is a pure, zero-I/O transform. `flow.body` already carries FINAL effective
|
|
8
|
+
* properties (the Stage-6 contract), so values map straight to CSS; every read
|
|
9
|
+
* still routes through the cascade resolver over the empty sheet, a memoized
|
|
10
|
+
* identity on reader output. Charts and shapes emit as inline SVG; deliberately
|
|
11
|
+
* out of scope (reported as losses): inline math and headers/footers (no fixed
|
|
12
|
+
* pages to band them onto). Page-break hints map to CSS `break-before`.
|
|
13
|
+
*
|
|
14
|
+
* @param flow The format-neutral interlayer document tree.
|
|
15
|
+
* @returns The encoded HTML bytes plus the recorded {@link Loss} list.
|
|
16
|
+
*/
|
|
3
17
|
export declare function writeHtml(flow: FlowDoc): WriteResult;
|
|
18
|
+
/**
|
|
19
|
+
* The flow-medium {@link DocumentWriter} adapter (id `'html'`), wrapping
|
|
20
|
+
* {@link writeHtml}, with the set of {@link FEATURES} it renders.
|
|
21
|
+
*/
|
|
4
22
|
export declare const htmlWriter: DocumentWriter<FlowDoc>;
|
|
@@ -10,6 +10,20 @@ import { buildShapePaths, buildShapeTransform, buildStroke, gradientSvgDef } fro
|
|
|
10
10
|
import { sanitizeHref } from "../core/links.js";
|
|
11
11
|
import { toBase64 } from "../core/bytes.js";
|
|
12
12
|
//#region src/html/html-writer.ts
|
|
13
|
+
/**
|
|
14
|
+
* Render a {@link FlowDoc} to a self-contained HTML document (ir-design §7).
|
|
15
|
+
*
|
|
16
|
+
* A flow medium: no pagination, no layout engine and no fonts to embed, so this
|
|
17
|
+
* is a pure, zero-I/O transform. `flow.body` already carries FINAL effective
|
|
18
|
+
* properties (the Stage-6 contract), so values map straight to CSS; every read
|
|
19
|
+
* still routes through the cascade resolver over the empty sheet, a memoized
|
|
20
|
+
* identity on reader output. Charts and shapes emit as inline SVG; deliberately
|
|
21
|
+
* out of scope (reported as losses): inline math and headers/footers (no fixed
|
|
22
|
+
* pages to band them onto). Page-break hints map to CSS `break-before`.
|
|
23
|
+
*
|
|
24
|
+
* @param flow The format-neutral interlayer document tree.
|
|
25
|
+
* @returns The encoded HTML bytes plus the recorded {@link Loss} list.
|
|
26
|
+
*/
|
|
13
27
|
function writeHtml(flow) {
|
|
14
28
|
const losses = [];
|
|
15
29
|
const out = [];
|
|
@@ -50,6 +64,10 @@ function writeHtml(flow) {
|
|
|
50
64
|
losses
|
|
51
65
|
};
|
|
52
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* The flow-medium {@link DocumentWriter} adapter (id `'html'`), wrapping
|
|
69
|
+
* {@link writeHtml}, with the set of {@link FEATURES} it renders.
|
|
70
|
+
*/
|
|
53
71
|
var htmlWriter = {
|
|
54
72
|
id: "html",
|
|
55
73
|
consumes: "flow",
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The public API for Ream.
|
|
3
|
+
*
|
|
4
|
+
* The package reads Word, Excel, PowerPoint and PDF — including the legacy
|
|
5
|
+
* `.doc` / `.xls` / `.ppt` — and converts any of them to PDF, SVG, HTML, DOCX or
|
|
6
|
+
* XLSX, implemented from the ECMA-376 and ISO 32000 specifications without
|
|
7
|
+
* wrapping LibreOffice, headless Office, or any commercial SDK.
|
|
8
|
+
*
|
|
9
|
+
* Typical use:
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Ream } from 'reamkit';
|
|
13
|
+
* const doc = Ream.parse(bytes); // format sniffed
|
|
14
|
+
* const pdf = await doc.convert('pdf'); // one parse, any target
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* Advanced consumers can build custom pipelines from the reader/writer
|
|
18
|
+
* interfaces, drive the layout engine directly via {@link renderStyledPdf},
|
|
19
|
+
* supply a hyphenator, or import the typed document model from the
|
|
20
|
+
* `reamkit/document-model` subpath.
|
|
21
|
+
*
|
|
22
|
+
* @packageDocumentation
|
|
23
|
+
*/
|
|
1
24
|
export { fetchFontSet, resolveFamilyKey } from './core/fonts/index.js';
|
|
2
25
|
export type { FamilyKey, FetchFontSetOptions, FetchLike } from './core/fonts/index.js';
|
|
3
26
|
export { renderStyledPdf } from './pdf/index.js';
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import { MathNode } from '../core/document-model/index.js';
|
|
2
2
|
import { PathSegment } from '../core/vector.js';
|
|
3
|
+
/** Font variant a math glyph renders in (drives the auto-italic of letters). */
|
|
3
4
|
export type MathVariant = 'regular' | 'italic' | 'bold' | 'boldItalic';
|
|
5
|
+
/**
|
|
6
|
+
* An ordinary symbol drawn from the font: a string positioned in the box's local
|
|
7
|
+
* frame (origin = box left, baseline at `y = 0`, y up).
|
|
8
|
+
*/
|
|
4
9
|
export interface MathGlyphItem {
|
|
5
10
|
readonly kind: 'glyph';
|
|
6
11
|
readonly x: number;
|
|
12
|
+
/** Baseline offset, up positive. */
|
|
7
13
|
readonly y: number;
|
|
8
14
|
readonly text: string;
|
|
9
15
|
readonly variant: MathVariant;
|
|
10
16
|
readonly sizePt: number;
|
|
11
17
|
}
|
|
18
|
+
/** A filled rectangle (fraction bars, accent rules); `(x, y)` is its bottom-left edge. */
|
|
12
19
|
export interface MathRuleItem {
|
|
13
20
|
readonly kind: 'rule';
|
|
14
21
|
readonly x: number;
|
|
@@ -16,29 +23,61 @@ export interface MathRuleItem {
|
|
|
16
23
|
readonly w: number;
|
|
17
24
|
readonly h: number;
|
|
18
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* A vector path drawn instead of a math-font glyph (radicals, stretchy
|
|
28
|
+
* delimiters, big operators) — so no math font is needed.
|
|
29
|
+
*/
|
|
19
30
|
export interface MathPathItem {
|
|
20
31
|
readonly kind: 'path';
|
|
21
32
|
readonly segments: ReadonlyArray<PathSegment>;
|
|
33
|
+
/** Present ⇒ stroked at this width. */
|
|
22
34
|
readonly strokeWidthPt?: number;
|
|
35
|
+
/** `true` ⇒ filled. */
|
|
23
36
|
readonly fill?: boolean;
|
|
24
37
|
}
|
|
38
|
+
/** A positioned draw item in a {@link MathBox}'s local frame. */
|
|
25
39
|
export type MathDrawItem = MathGlyphItem | MathRuleItem | MathPathItem;
|
|
40
|
+
/**
|
|
41
|
+
* A laid-out math box: a width plus ascent (above the baseline) and descent
|
|
42
|
+
* (below), and a flat list of positioned {@link MathDrawItem}s in a LOCAL frame
|
|
43
|
+
* (origin = box left, baseline at `y = 0`, y up).
|
|
44
|
+
*/
|
|
26
45
|
export interface MathBox {
|
|
27
46
|
readonly width: number;
|
|
28
47
|
readonly ascent: number;
|
|
29
48
|
readonly descent: number;
|
|
30
49
|
readonly items: ReadonlyArray<MathDrawItem>;
|
|
31
50
|
}
|
|
51
|
+
/** Injected text-measure: the advance width of `text` at `sizePt` in `variant`. */
|
|
32
52
|
export type MeasureMath = (text: string, sizePt: number, variant: MathVariant) => number;
|
|
53
|
+
/** Layout context threaded through {@link layoutMath} — currently just the em size. */
|
|
33
54
|
export interface MathCtx {
|
|
34
55
|
readonly sizePt: number;
|
|
35
56
|
}
|
|
57
|
+
/** Decompose a {@link MathVariant} into its independent bold / italic flags. */
|
|
36
58
|
export declare function variantStyle(v: MathVariant): {
|
|
37
59
|
bold: boolean;
|
|
38
60
|
italic: boolean;
|
|
39
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* Recursively lay out an ECMA-376 §22 OfficeMath node into a {@link MathBox}.
|
|
64
|
+
* Ordinary symbols become {@link MathGlyphItem}s (rendered from the font);
|
|
65
|
+
* structural elements (fraction rules, radicals, big operators, stretchy
|
|
66
|
+
* delimiters) become rule/path items drawn as vector graphics. Pure: text widths
|
|
67
|
+
* arrive through the injected `measure` fn.
|
|
68
|
+
*
|
|
69
|
+
* @param node The math tree node to lay out.
|
|
70
|
+
* @param ctx The layout context (em size).
|
|
71
|
+
* @param measure The injected advance-width measurer.
|
|
72
|
+
* @returns The positioned box; constructs added in later milestones render empty.
|
|
73
|
+
*/
|
|
40
74
|
export declare function layoutMath(node: MathNode, ctx: MathCtx, measure: MeasureMath): MathBox;
|
|
75
|
+
/** Translate every item in a box by `(dx, dy)`, returning shifted copies. */
|
|
41
76
|
export declare function shiftItems(items: ReadonlyArray<MathDrawItem>, dx: number, dy: number): Array<MathDrawItem>;
|
|
77
|
+
/**
|
|
78
|
+
* Flatten a math tree into `(variant, text)` glyph segments — used to subset the
|
|
79
|
+
* right glyphs into the right font variant. Grows alongside {@link layoutMath}.
|
|
80
|
+
*/
|
|
42
81
|
export declare function mathGlyphSegments(node: MathNode): Array<{
|
|
43
82
|
variant: MathVariant;
|
|
44
83
|
text: string;
|
|
@@ -6,6 +6,7 @@ var BAR_THICK = .045;
|
|
|
6
6
|
var FRAC_GAP = .15;
|
|
7
7
|
var FRAC_PAD = .12;
|
|
8
8
|
var SCRIPT_SIZE = .7;
|
|
9
|
+
/** Decompose a {@link MathVariant} into its independent bold / italic flags. */
|
|
9
10
|
function variantStyle(v) {
|
|
10
11
|
return {
|
|
11
12
|
bold: v === "bold" || v === "boldItalic",
|
|
@@ -20,6 +21,18 @@ function runCharVariant(ch, run) {
|
|
|
20
21
|
const bold = run.bold ?? false;
|
|
21
22
|
return variantOf(run.nor ? false : run.italic ?? isAutoItalic(ch), bold);
|
|
22
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Recursively lay out an ECMA-376 §22 OfficeMath node into a {@link MathBox}.
|
|
26
|
+
* Ordinary symbols become {@link MathGlyphItem}s (rendered from the font);
|
|
27
|
+
* structural elements (fraction rules, radicals, big operators, stretchy
|
|
28
|
+
* delimiters) become rule/path items drawn as vector graphics. Pure: text widths
|
|
29
|
+
* arrive through the injected `measure` fn.
|
|
30
|
+
*
|
|
31
|
+
* @param node The math tree node to lay out.
|
|
32
|
+
* @param ctx The layout context (em size).
|
|
33
|
+
* @param measure The injected advance-width measurer.
|
|
34
|
+
* @returns The positioned box; constructs added in later milestones render empty.
|
|
35
|
+
*/
|
|
23
36
|
function layoutMath(node, ctx, measure) {
|
|
24
37
|
switch (node.type) {
|
|
25
38
|
case "run": return layoutRun(node, ctx, measure);
|
|
@@ -1016,6 +1029,7 @@ function layoutGroupChr(node, ctx, measure) {
|
|
|
1016
1029
|
items
|
|
1017
1030
|
};
|
|
1018
1031
|
}
|
|
1032
|
+
/** Translate every item in a box by `(dx, dy)`, returning shifted copies. */
|
|
1019
1033
|
function shiftItems(items, dx, dy) {
|
|
1020
1034
|
return items.map((it) => {
|
|
1021
1035
|
if (it.kind === "glyph") return {
|
|
@@ -1054,6 +1068,10 @@ function shiftSegment(s, dx, dy) {
|
|
|
1054
1068
|
case "close": return s;
|
|
1055
1069
|
}
|
|
1056
1070
|
}
|
|
1071
|
+
/**
|
|
1072
|
+
* Flatten a math tree into `(variant, text)` glyph segments — used to subset the
|
|
1073
|
+
* right glyphs into the right font variant. Grows alongside {@link layoutMath}.
|
|
1074
|
+
*/
|
|
1057
1075
|
function mathGlyphSegments(node) {
|
|
1058
1076
|
const out = [];
|
|
1059
1077
|
const visit = (n) => {
|