reamkit 0.1.0-alpha.0 → 1.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/README.md +107 -30
- package/dist/esm/{bidi → core/bidi}/algorithm.js +1 -1
- package/dist/esm/{bidi → core/bidi}/char-types.js +1 -1
- package/dist/esm/{bidi → core/bidi}/index.d.ts +2 -0
- package/dist/esm/{bidi → core/bidi}/index.js +2 -1
- package/dist/esm/core/bidi/segments.d.ts +6 -0
- package/dist/esm/core/bidi/segments.js +41 -0
- package/dist/esm/core/bytes.d.ts +1 -0
- package/dist/esm/core/bytes.js +11 -0
- package/dist/esm/core/converter/facade.d.ts +45 -0
- package/dist/esm/core/converter/facade.js +89 -0
- package/dist/esm/core/converter/index.d.ts +4 -0
- package/dist/esm/core/converter/project.d.ts +4 -0
- package/dist/esm/core/converter/project.js +17 -0
- package/dist/esm/core/converter/ream.d.ts +35 -0
- package/dist/esm/core/converter/ream.js +101 -0
- package/dist/esm/{crypto → core/crypto}/asn1.js +1 -1
- package/dist/esm/{crypto → core/crypto}/cms.js +1 -1
- package/dist/esm/core/document-model/index.d.ts +1 -0
- package/dist/esm/{document-model → core/document-model}/types.d.ts +57 -41
- package/dist/esm/{ooxml → core}/drawingml/chart-parser.d.ts +1 -1
- package/dist/esm/{ooxml → core}/drawingml/chart-parser.js +6 -29
- package/dist/esm/{ooxml → core}/drawingml/colors.d.ts +3 -0
- package/dist/esm/{ooxml → core}/drawingml/colors.js +32 -2
- package/dist/esm/{ooxml → core}/drawingml/theme-parser.js +2 -2
- package/dist/esm/{font → core/font}/arabic-joining.js +1 -1
- package/dist/esm/{font → core/font}/binary-reader.js +1 -1
- package/dist/esm/{font → core/font}/font-registry.d.ts +1 -0
- package/dist/esm/{font → core/font}/font-registry.js +17 -16
- package/dist/esm/{font → core/font}/index.d.ts +3 -0
- package/dist/esm/core/font/measure.d.ts +7 -0
- package/dist/esm/core/font/measure.js +30 -0
- package/dist/esm/{font → core/font}/opentype-layout.js +1 -1
- package/dist/esm/{font → core/font}/ttf-parser.js +1 -1
- package/dist/esm/{font → core/font}/ttf-subset.js +1 -1
- package/dist/esm/core/fonts/provider.d.ts +60 -0
- package/dist/esm/core/fonts/provider.js +163 -0
- package/dist/esm/{fonts → core/fonts}/remote-fonts.js +1 -1
- package/dist/esm/{hyphenation → core/hyphenation}/index.js +1 -1
- package/dist/esm/{hyphenation → core/hyphenation}/liang.js +1 -1
- package/dist/esm/{hyphenation → core/hyphenation}/patterns-en-us.js +1 -1
- package/dist/esm/{hyphenation → core/hyphenation}/patterns-ru.js +1 -1
- package/dist/esm/core/images.d.ts +17 -0
- package/dist/esm/core/images.js +308 -0
- package/dist/esm/core/ir/adapters.d.ts +37 -0
- package/dist/esm/core/ir/features.d.ts +25 -0
- package/dist/esm/core/ir/features.js +24 -0
- package/dist/esm/core/ir/flow.d.ts +24 -0
- package/dist/esm/core/ir/index.d.ts +11 -0
- package/dist/esm/core/ir/loss.d.ts +22 -0
- package/dist/esm/core/ir/loss.js +15 -0
- package/dist/esm/core/ir/resources.d.ts +16 -0
- package/dist/esm/core/ir/resources.js +50 -0
- package/dist/esm/core/ir/units.d.ts +16 -0
- package/dist/esm/core/ir/units.js +41 -0
- package/dist/esm/core/line-breaker/index.d.ts +2 -0
- package/dist/esm/{line-breaker → core/line-breaker}/knuth-plass.d.ts +1 -0
- package/dist/esm/{line-breaker → core/line-breaker}/knuth-plass.js +3 -3
- package/dist/esm/core/numbering/apply.d.ts +3 -0
- package/dist/esm/core/numbering/apply.js +62 -0
- package/dist/esm/core/numbering/index.d.ts +2 -0
- package/dist/esm/{numbering → core/numbering}/state.js +1 -1
- package/dist/esm/{opc → core/opc}/core-properties.js +1 -1
- package/dist/esm/{opc → core/opc}/package.d.ts +2 -1
- package/dist/esm/{opc → core/opc}/package.js +7 -3
- package/dist/esm/{opc → core/opc}/relationship-types.js +1 -1
- package/dist/esm/{opc → core/opc}/relationships.js +1 -1
- package/dist/esm/{ooxml/wordproc → core}/po-helpers.js +1 -1
- package/dist/esm/core/style-cascade/index.d.ts +3 -0
- package/dist/esm/core/style-cascade/index.js +2 -0
- package/dist/esm/core/style-cascade/resolver.d.ts +7 -0
- package/dist/esm/{style-cascade → core/style-cascade}/resolver.js +82 -10
- package/dist/esm/{style-cascade → core/style-cascade}/types.d.ts +10 -8
- package/dist/esm/{style-cascade → core/style-cascade}/types.js +9 -8
- package/dist/esm/core/vector.d.ts +45 -0
- package/dist/esm/core/vector.js +48 -0
- package/dist/esm/{ooxml/spreadsheet → excel}/cell-reference.js +1 -1
- package/dist/esm/{ooxml/spreadsheet → excel}/defined-name-ref.js +1 -1
- package/dist/esm/{ooxml/spreadsheet → excel}/index.d.ts +1 -1
- package/dist/esm/{ooxml/spreadsheet → excel}/number-format.js +1 -1
- package/dist/esm/excel/print-model.d.ts +18 -0
- package/dist/esm/{converter/xlsx-to-pdf.js → excel/print-model.js} +39 -148
- package/dist/esm/{ooxml/spreadsheet → excel}/shared-strings-parser.js +1 -1
- package/dist/esm/{ooxml/spreadsheet → excel}/styles-parser.js +1 -1
- package/dist/esm/{ooxml/spreadsheet → excel}/workbook-parser.js +1 -1
- package/dist/esm/{ooxml/spreadsheet → excel}/worksheet-parser.js +1 -1
- package/dist/esm/excel/xlsx-reader.d.ts +4 -0
- package/dist/esm/excel/xlsx-reader.js +91 -0
- package/dist/esm/{converter → excel}/xlsx-to-pdf.d.ts +13 -2
- package/dist/esm/excel/xlsx-to-pdf.js +69 -0
- package/dist/esm/index.d.ts +23 -8
- package/dist/esm/index.js +18 -10
- package/dist/esm/{pdf → layout}/arc-to-bezier.d.ts +1 -1
- package/dist/esm/{pdf → layout}/arc-to-bezier.js +2 -2
- package/dist/esm/{pdf → layout}/chart-geometry.d.ts +1 -1
- package/dist/esm/{pdf → layout}/math-layout.d.ts +2 -2
- package/dist/esm/{pdf → layout}/math-layout.js +1 -1
- package/dist/esm/layout/page-doc.d.ts +133 -0
- package/dist/esm/layout/page-doc.js +38 -0
- package/dist/esm/{pdf → layout}/preset-geometry.d.ts +2 -2
- package/dist/esm/{pdf → layout}/preset-geometry.js +2 -2
- package/dist/esm/layout/styled-layout.d.ts +84 -0
- package/dist/esm/layout/styled-layout.js +1729 -0
- package/dist/esm/pdf/cid-font.d.ts +1 -1
- package/dist/esm/pdf/cid-font.js +6 -21
- package/dist/esm/pdf/image-xobject.d.ts +4 -5
- package/dist/esm/pdf/image-xobject.js +21 -324
- package/dist/esm/pdf/index.d.ts +2 -2
- package/dist/esm/pdf/index.js +1 -0
- package/dist/esm/pdf/signature.js +4 -4
- package/dist/esm/pdf/styled-page-emitter.d.ts +11 -0
- package/dist/esm/pdf/styled-page-emitter.js +557 -0
- package/dist/esm/pdf/styled-page-renderer.d.ts +4 -42
- package/dist/esm/pdf/styled-page-renderer.js +4 -2311
- package/dist/esm/pdf/text-page-renderer.d.ts +1 -1
- package/dist/esm/pdf/vector-graphics.d.ts +3 -45
- package/dist/esm/pdf/vector-graphics.js +2 -46
- package/dist/esm/svg/svg-writer.d.ts +8 -0
- package/dist/esm/svg/svg-writer.js +137 -0
- package/dist/esm/word/document-parser.d.ts +16 -0
- package/dist/esm/{ooxml/wordproc → word}/document-parser.js +55 -47
- package/dist/esm/word/docx-reader.d.ts +4 -0
- package/dist/esm/word/docx-reader.js +191 -0
- package/dist/esm/word/docx-to-pdf.d.ts +34 -0
- package/dist/esm/word/docx-to-pdf.js +112 -0
- package/dist/esm/{ooxml/wordproc → word}/drawing-parser.d.ts +10 -9
- package/dist/esm/{ooxml/wordproc → word}/drawing-parser.js +15 -42
- package/dist/esm/{ooxml/wordproc → word}/font-table.d.ts +2 -2
- package/dist/esm/{ooxml/wordproc → word}/font-table.js +2 -2
- package/dist/esm/{ooxml/wordproc → word}/index.d.ts +3 -2
- package/dist/esm/{ooxml/wordproc → word}/numbering-parser.d.ts +1 -1
- package/dist/esm/{ooxml/wordproc → word}/numbering-parser.js +1 -1
- package/dist/esm/{ooxml/math → word}/omml-parser.d.ts +2 -2
- package/dist/esm/{ooxml/math → word}/omml-parser.js +2 -2
- package/dist/esm/{ooxml/wordproc → word}/paragraph-properties.d.ts +1 -1
- package/dist/esm/{ooxml/wordproc → word}/paragraph-properties.js +9 -8
- package/dist/esm/{ooxml/wordproc → word}/po-to-flat.d.ts +1 -1
- package/dist/esm/{ooxml/wordproc → word}/po-to-flat.js +2 -2
- package/dist/esm/{ooxml/wordproc → word}/run-properties.d.ts +1 -1
- package/dist/esm/{ooxml/wordproc → word}/run-properties.js +3 -2
- package/dist/esm/{ooxml/wordproc → word}/settings-parser.js +2 -2
- package/dist/esm/word/styles-parser.d.ts +2 -0
- package/dist/esm/{ooxml/wordproc → word}/styles-parser.js +4 -7
- package/dist/esm/word/table-parser.d.ts +4 -0
- package/dist/esm/{ooxml/wordproc → word}/table-parser.js +80 -26
- package/dist/esm/{ooxml/wordproc → word}/xml-helpers.js +1 -1
- package/package.json +5 -6
- package/dist/esm/converter/docx-to-pdf.d.ts +0 -15
- package/dist/esm/converter/docx-to-pdf.js +0 -227
- package/dist/esm/converter/index.d.ts +0 -4
- package/dist/esm/converter/index.js +0 -2
- package/dist/esm/document-model/index.d.ts +0 -1
- package/dist/esm/line-breaker/index.d.ts +0 -2
- package/dist/esm/numbering/index.d.ts +0 -1
- package/dist/esm/ooxml/index.d.ts +0 -1
- package/dist/esm/ooxml/wordproc/document-parser.d.ts +0 -9
- package/dist/esm/ooxml/wordproc/styles-parser.d.ts +0 -3
- package/dist/esm/ooxml/wordproc/table-parser.d.ts +0 -3
- package/dist/esm/style-cascade/index.d.ts +0 -3
- package/dist/esm/style-cascade/resolver.d.ts +0 -4
- /package/dist/esm/{bidi → core/bidi}/algorithm.d.ts +0 -0
- /package/dist/esm/{bidi → core/bidi}/char-types.d.ts +0 -0
- /package/dist/esm/{crypto → core/crypto}/asn1.d.ts +0 -0
- /package/dist/esm/{crypto → core/crypto}/cms.d.ts +0 -0
- /package/dist/esm/{crypto → core/crypto}/index.d.ts +0 -0
- /package/dist/esm/{crypto → core/crypto}/index.js +0 -0
- /package/dist/esm/{document-model → core/document-model}/index.js +0 -0
- /package/dist/esm/{ooxml → core}/drawingml/theme-parser.d.ts +0 -0
- /package/dist/esm/{font → core/font}/arabic-joining.d.ts +0 -0
- /package/dist/esm/{font → core/font}/binary-reader.d.ts +0 -0
- /package/dist/esm/{font → core/font}/opentype-layout.d.ts +0 -0
- /package/dist/esm/{font → core/font}/ttf-parser.d.ts +0 -0
- /package/dist/esm/{font → core/font}/ttf-subset.d.ts +0 -0
- /package/dist/esm/{fonts → core/fonts}/index.d.ts +0 -0
- /package/dist/esm/{fonts → core/fonts}/remote-fonts.d.ts +0 -0
- /package/dist/esm/{hyphenation → core/hyphenation}/index.d.ts +0 -0
- /package/dist/esm/{hyphenation → core/hyphenation}/liang.d.ts +0 -0
- /package/dist/esm/{hyphenation → core/hyphenation}/patterns-en-us.d.ts +0 -0
- /package/dist/esm/{hyphenation → core/hyphenation}/patterns-ru.d.ts +0 -0
- /package/dist/esm/{numbering → core/numbering}/state.d.ts +0 -0
- /package/dist/esm/{opc → core/opc}/core-properties.d.ts +0 -0
- /package/dist/esm/{opc → core/opc}/index.d.ts +0 -0
- /package/dist/esm/{opc → core/opc}/index.js +0 -0
- /package/dist/esm/{opc → core/opc}/relationship-types.d.ts +0 -0
- /package/dist/esm/{opc → core/opc}/relationships.d.ts +0 -0
- /package/dist/esm/{ooxml/wordproc → core}/po-helpers.d.ts +0 -0
- /package/dist/esm/{ooxml/spreadsheet → excel}/cell-reference.d.ts +0 -0
- /package/dist/esm/{ooxml/spreadsheet → excel}/defined-name-ref.d.ts +0 -0
- /package/dist/esm/{ooxml/spreadsheet → excel}/index.js +0 -0
- /package/dist/esm/{ooxml/spreadsheet → excel}/number-format.d.ts +0 -0
- /package/dist/esm/{ooxml/spreadsheet → excel}/shared-strings-parser.d.ts +0 -0
- /package/dist/esm/{ooxml/spreadsheet → excel}/styles-parser.d.ts +0 -0
- /package/dist/esm/{ooxml/spreadsheet → excel}/workbook-parser.d.ts +0 -0
- /package/dist/esm/{ooxml/spreadsheet → excel}/worksheet-parser.d.ts +0 -0
- /package/dist/esm/{pdf → layout}/chart-geometry.js +0 -0
- /package/dist/esm/{ooxml/wordproc → word}/index.js +0 -0
- /package/dist/esm/{ooxml/wordproc → word}/settings-parser.d.ts +0 -0
- /package/dist/esm/{ooxml/wordproc → word}/text-extractor.d.ts +0 -0
- /package/dist/esm/{ooxml/wordproc → word}/text-extractor.js +0 -0
- /package/dist/esm/{ooxml/wordproc → word}/xml-helpers.d.ts +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { NumberingState } from "./state.js";
|
|
2
|
+
//#region src/core/numbering/apply.ts
|
|
3
|
+
function applyNumbering(body, numbering) {
|
|
4
|
+
if (!numbering || numbering.abstractNums.size === 0) return body.map((b) => b);
|
|
5
|
+
const state = new NumberingState();
|
|
6
|
+
const transformParagraph = (p) => {
|
|
7
|
+
const ref = p.properties.numbering;
|
|
8
|
+
if (!ref) return p;
|
|
9
|
+
const marker = state.resolveMarker(numbering, ref);
|
|
10
|
+
if (marker === null) return p;
|
|
11
|
+
const instance = numbering.numInstances.get(ref.numId);
|
|
12
|
+
const level = (instance ? numbering.abstractNums.get(instance.abstractNumId) : void 0)?.levels.get(ref.ilvl);
|
|
13
|
+
const markerRun = {
|
|
14
|
+
text: `${marker}\t`,
|
|
15
|
+
properties: level?.runProperties ?? {}
|
|
16
|
+
};
|
|
17
|
+
return {
|
|
18
|
+
properties: mergeIndentFromLevel(p.properties, level?.paragraphProperties),
|
|
19
|
+
runs: [markerRun, ...p.runs]
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
const visit = (el) => {
|
|
23
|
+
if (el.kind === "paragraph") return {
|
|
24
|
+
kind: "paragraph",
|
|
25
|
+
paragraph: transformParagraph(el.paragraph)
|
|
26
|
+
};
|
|
27
|
+
if (el.kind === "image") return el;
|
|
28
|
+
if (el.kind === "shape") return el;
|
|
29
|
+
if (el.kind === "chart") return el;
|
|
30
|
+
return {
|
|
31
|
+
kind: "table",
|
|
32
|
+
table: {
|
|
33
|
+
...el.table,
|
|
34
|
+
rows: el.table.rows.map((row) => ({
|
|
35
|
+
...row,
|
|
36
|
+
cells: row.cells.map((cell) => ({
|
|
37
|
+
...cell,
|
|
38
|
+
content: cell.content.map(visit)
|
|
39
|
+
}))
|
|
40
|
+
}))
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
return body.map(visit);
|
|
45
|
+
}
|
|
46
|
+
function mergeIndentFromLevel(paragraphProps, levelProps) {
|
|
47
|
+
if (!levelProps) return paragraphProps;
|
|
48
|
+
const out = { ...paragraphProps };
|
|
49
|
+
if (out.indentLeft === void 0 && levelProps.indentLeft !== void 0) out.indentLeft = levelProps.indentLeft;
|
|
50
|
+
if (out.indentRight === void 0 && levelProps.indentRight !== void 0) out.indentRight = levelProps.indentRight;
|
|
51
|
+
if (out.indentFirstLine === void 0 && levelProps.indentFirstLine !== void 0) out.indentFirstLine = levelProps.indentFirstLine;
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
function applyNumberingToHeadersFooters(hf, numbering) {
|
|
55
|
+
if (!hf || hf.size === 0) return /* @__PURE__ */ new Map();
|
|
56
|
+
if (!numbering || numbering.abstractNums.size === 0) return hf;
|
|
57
|
+
const out = /* @__PURE__ */ new Map();
|
|
58
|
+
for (const [key, value] of hf) out.set(key, applyNumbering(value, numbering));
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { applyNumbering, applyNumberingToHeadersFooters };
|
|
@@ -9,11 +9,12 @@ export declare class OpcPackage {
|
|
|
9
9
|
private readonly parts;
|
|
10
10
|
private readonly rootRelationships;
|
|
11
11
|
private constructor();
|
|
12
|
+
private readonly relsCache;
|
|
12
13
|
static open(buffer: Uint8Array, options?: OpcOpenOptions): OpcPackage;
|
|
13
14
|
getPart(path: string): Uint8Array | undefined;
|
|
14
15
|
requirePart(path: string): Uint8Array;
|
|
15
16
|
listParts(): Array<string>;
|
|
16
|
-
getPartRelationships(partPath: string):
|
|
17
|
+
getPartRelationships(partPath: string): ReadonlyArray<Relationship>;
|
|
17
18
|
resolveRelatedPart(sourcePartPath: string, relationship: Relationship): {
|
|
18
19
|
readonly path: string;
|
|
19
20
|
readonly data: Uint8Array;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parseRelationships } from "./relationships.js";
|
|
2
2
|
import "./relationship-types.js";
|
|
3
3
|
import { unzipSync } from "fflate";
|
|
4
|
-
//#region src/opc/package.ts
|
|
4
|
+
//#region src/core/opc/package.ts
|
|
5
5
|
var ROOT_RELS_PATH = "_rels/.rels";
|
|
6
6
|
var MIB = 1024 * 1024;
|
|
7
7
|
var OpcPackage = class OpcPackage {
|
|
@@ -9,6 +9,7 @@ var OpcPackage = class OpcPackage {
|
|
|
9
9
|
this.parts = parts;
|
|
10
10
|
this.rootRelationships = rootRelationships;
|
|
11
11
|
}
|
|
12
|
+
relsCache = /* @__PURE__ */ new Map();
|
|
12
13
|
static open(buffer, options = {}) {
|
|
13
14
|
const maxArchive = options.maxArchiveBytes ?? 128 * MIB;
|
|
14
15
|
const maxEntry = options.maxEntryBytes ?? 256 * MIB;
|
|
@@ -54,13 +55,16 @@ var OpcPackage = class OpcPackage {
|
|
|
54
55
|
}
|
|
55
56
|
getPartRelationships(partPath) {
|
|
56
57
|
const normalized = normalizePath(partPath);
|
|
58
|
+
const cached = this.relsCache.get(normalized);
|
|
59
|
+
if (cached) return cached;
|
|
57
60
|
const slash = normalized.lastIndexOf("/");
|
|
58
61
|
const dir = slash >= 0 ? normalized.substring(0, slash) : "";
|
|
59
62
|
const base = slash >= 0 ? normalized.substring(slash + 1) : normalized;
|
|
60
63
|
const relsPath = dir.length > 0 ? `${dir}/_rels/${base}.rels` : `_rels/${base}.rels`;
|
|
61
64
|
const data = this.parts.get(relsPath);
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
const rels = data ? parseRelationships(data) : [];
|
|
66
|
+
this.relsCache.set(normalized, rels);
|
|
67
|
+
return rels;
|
|
64
68
|
}
|
|
65
69
|
resolveRelatedPart(sourcePartPath, relationship) {
|
|
66
70
|
if (relationship.targetMode !== "Internal") return void 0;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { EMPTY_STYLE_SHEET, resolveBodyStyles, resolveHeadersFootersStyles, resolveParagraphProperties, resolveRunProperties, } from './resolver.js';
|
|
2
|
+
export type { ResolvedRunProperties, ResolvedParagraphProperties, } from './types.js';
|
|
3
|
+
export { DEFAULT_RESOLVED_RUN, DEFAULT_RESOLVED_PARAGRAPH } from './types.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BodyElement, ParagraphProperties, RunProperties, StyleSheet } from '../document-model/index.js';
|
|
2
|
+
import { ResolvedParagraphProperties, ResolvedRunProperties } from './types.js';
|
|
3
|
+
export declare const EMPTY_STYLE_SHEET: StyleSheet;
|
|
4
|
+
export declare function resolveRunProperties(runDirect: RunProperties, paragraphDirect: ParagraphProperties, sheet: StyleSheet): ResolvedRunProperties;
|
|
5
|
+
export declare function resolveParagraphProperties(paragraphDirect: ParagraphProperties, sheet: StyleSheet): ResolvedParagraphProperties;
|
|
6
|
+
export declare function resolveBodyStyles(body: ReadonlyArray<BodyElement>, sheet: StyleSheet): Array<BodyElement>;
|
|
7
|
+
export declare function resolveHeadersFootersStyles(hf: ReadonlyMap<string, ReadonlyArray<BodyElement>>, sheet: StyleSheet): ReadonlyMap<string, ReadonlyArray<BodyElement>>;
|
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
import { DEFAULT_RESOLVED_PARAGRAPH, DEFAULT_RESOLVED_RUN } from "./types.js";
|
|
2
|
-
//#region src/style-cascade/resolver.ts
|
|
2
|
+
//#region src/core/style-cascade/resolver.ts
|
|
3
|
+
var EMPTY_STYLE_SHEET = {
|
|
4
|
+
defaultRunProperties: {},
|
|
5
|
+
defaultParagraphProperties: {},
|
|
6
|
+
styles: /* @__PURE__ */ new Map()
|
|
7
|
+
};
|
|
8
|
+
var runCascadeCache = /* @__PURE__ */ new WeakMap();
|
|
3
9
|
function resolveRunProperties(runDirect, paragraphDirect, sheet) {
|
|
10
|
+
let bySheet = runCascadeCache.get(sheet);
|
|
11
|
+
if (!bySheet) {
|
|
12
|
+
bySheet = /* @__PURE__ */ new WeakMap();
|
|
13
|
+
runCascadeCache.set(sheet, bySheet);
|
|
14
|
+
}
|
|
15
|
+
let byRun = bySheet.get(runDirect);
|
|
16
|
+
if (!byRun) {
|
|
17
|
+
byRun = /* @__PURE__ */ new WeakMap();
|
|
18
|
+
bySheet.set(runDirect, byRun);
|
|
19
|
+
}
|
|
20
|
+
const hit = byRun.get(paragraphDirect);
|
|
21
|
+
if (hit) return hit;
|
|
22
|
+
const resolved = computeRunProperties(runDirect, paragraphDirect, sheet);
|
|
23
|
+
byRun.set(paragraphDirect, resolved);
|
|
24
|
+
return resolved;
|
|
25
|
+
}
|
|
26
|
+
function computeRunProperties(runDirect, paragraphDirect, sheet) {
|
|
4
27
|
let acc = mergeRun(DEFAULT_RESOLVED_RUN, sheet.defaultRunProperties);
|
|
5
28
|
if (paragraphDirect.styleId) {
|
|
6
29
|
const chain = resolveStyleChain(paragraphDirect.styleId, sheet);
|
|
@@ -52,7 +75,7 @@ function mergeRun(base, override) {
|
|
|
52
75
|
italic: override.italic ?? base.italic,
|
|
53
76
|
underline: override.underline ?? base.underline,
|
|
54
77
|
strike: override.strike ?? base.strike,
|
|
55
|
-
|
|
78
|
+
fontSizePt: override.fontSizePt ?? base.fontSizePt,
|
|
56
79
|
colorHex: override.colorHex ?? base.colorHex,
|
|
57
80
|
fontFamily: override.fontFamily ?? base.fontFamily,
|
|
58
81
|
verticalAlign: override.verticalAlign ?? base.verticalAlign,
|
|
@@ -63,19 +86,21 @@ function mergeRun(base, override) {
|
|
|
63
86
|
function mergePar(base, override) {
|
|
64
87
|
const outlineLevel = override.outlineLevel ?? base.outlineLevel;
|
|
65
88
|
const styleId = override.styleId ?? base.styleId;
|
|
89
|
+
const numbering = override.numbering ?? base.numbering;
|
|
66
90
|
return {
|
|
67
91
|
alignment: override.alignment ?? base.alignment,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
92
|
+
spacingBefore: override.spacingBefore ?? base.spacingBefore,
|
|
93
|
+
spacingAfter: override.spacingAfter ?? base.spacingAfter,
|
|
94
|
+
spacingLine: override.spacingLine ?? base.spacingLine,
|
|
71
95
|
spacingLineRule: override.spacingLineRule ?? base.spacingLineRule,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
96
|
+
indentLeft: override.indentLeft ?? base.indentLeft,
|
|
97
|
+
indentRight: override.indentRight ?? base.indentRight,
|
|
98
|
+
indentFirstLine: override.indentFirstLine ?? base.indentFirstLine,
|
|
75
99
|
pageBreakBefore: override.pageBreakBefore ?? base.pageBreakBefore,
|
|
76
100
|
bidi: override.bidi ?? base.bidi,
|
|
77
101
|
...outlineLevel !== void 0 ? { outlineLevel } : {},
|
|
78
|
-
...styleId !== void 0 ? { styleId } : {}
|
|
102
|
+
...styleId !== void 0 ? { styleId } : {},
|
|
103
|
+
...numbering !== void 0 ? { numbering } : {}
|
|
79
104
|
};
|
|
80
105
|
}
|
|
81
106
|
function mergeRunPartial(base, override) {
|
|
@@ -92,5 +117,52 @@ function copyDefined(base, override) {
|
|
|
92
117
|
}
|
|
93
118
|
return out;
|
|
94
119
|
}
|
|
120
|
+
function resolveBodyStyles(body, sheet) {
|
|
121
|
+
const visitParagraph = (p) => ({
|
|
122
|
+
...p,
|
|
123
|
+
properties: resolveParagraphProperties(p.properties, sheet),
|
|
124
|
+
runs: p.runs.map((r) => ({
|
|
125
|
+
...r,
|
|
126
|
+
properties: resolveRunProperties(r.properties, p.properties, sheet)
|
|
127
|
+
}))
|
|
128
|
+
});
|
|
129
|
+
const visit = (el) => {
|
|
130
|
+
if (el.kind === "paragraph") return {
|
|
131
|
+
kind: "paragraph",
|
|
132
|
+
paragraph: visitParagraph(el.paragraph)
|
|
133
|
+
};
|
|
134
|
+
if (el.kind === "table") return {
|
|
135
|
+
kind: "table",
|
|
136
|
+
table: {
|
|
137
|
+
...el.table,
|
|
138
|
+
rows: el.table.rows.map((row) => ({
|
|
139
|
+
...row,
|
|
140
|
+
cells: row.cells.map((cell) => ({
|
|
141
|
+
...cell,
|
|
142
|
+
content: cell.content.map(visit)
|
|
143
|
+
}))
|
|
144
|
+
}))
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
if (el.kind === "shape" && el.shape.text) return {
|
|
148
|
+
kind: "shape",
|
|
149
|
+
shape: {
|
|
150
|
+
...el.shape,
|
|
151
|
+
text: {
|
|
152
|
+
...el.shape.text,
|
|
153
|
+
content: el.shape.text.content.map(visit)
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
return el;
|
|
158
|
+
};
|
|
159
|
+
return body.map(visit);
|
|
160
|
+
}
|
|
161
|
+
function resolveHeadersFootersStyles(hf, sheet) {
|
|
162
|
+
if (hf.size === 0) return hf;
|
|
163
|
+
const out = /* @__PURE__ */ new Map();
|
|
164
|
+
for (const [key, value] of hf) out.set(key, resolveBodyStyles(value, sheet));
|
|
165
|
+
return out;
|
|
166
|
+
}
|
|
95
167
|
//#endregion
|
|
96
|
-
export { resolveParagraphProperties, resolveRunProperties };
|
|
168
|
+
export { EMPTY_STYLE_SHEET, resolveBodyStyles, resolveHeadersFootersStyles, resolveParagraphProperties, resolveRunProperties };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Alignment, FontFamilyMap, UnderlineStyle, VerticalAlign } from '../document-model/index.js';
|
|
1
|
+
import { Alignment, FontFamilyMap, NumberingReference, UnderlineStyle, VerticalAlign } from '../document-model/index.js';
|
|
2
|
+
import { Pt } from '../ir/index.js';
|
|
2
3
|
export interface ResolvedRunProperties {
|
|
3
4
|
readonly bold: boolean;
|
|
4
5
|
readonly italic: boolean;
|
|
5
6
|
readonly underline: UnderlineStyle;
|
|
6
7
|
readonly strike: boolean;
|
|
7
|
-
readonly
|
|
8
|
+
readonly fontSizePt: Pt;
|
|
8
9
|
readonly colorHex: string;
|
|
9
10
|
readonly fontFamily: FontFamilyMap;
|
|
10
11
|
readonly verticalAlign: VerticalAlign;
|
|
@@ -13,17 +14,18 @@ export interface ResolvedRunProperties {
|
|
|
13
14
|
}
|
|
14
15
|
export interface ResolvedParagraphProperties {
|
|
15
16
|
readonly alignment: Alignment;
|
|
16
|
-
readonly
|
|
17
|
-
readonly
|
|
18
|
-
readonly
|
|
17
|
+
readonly spacingBefore: Pt;
|
|
18
|
+
readonly spacingAfter: Pt;
|
|
19
|
+
readonly spacingLine: Pt;
|
|
19
20
|
readonly spacingLineRule: 'auto' | 'exact' | 'atLeast';
|
|
20
|
-
readonly
|
|
21
|
-
readonly
|
|
22
|
-
readonly
|
|
21
|
+
readonly indentLeft: Pt;
|
|
22
|
+
readonly indentRight: Pt;
|
|
23
|
+
readonly indentFirstLine: Pt;
|
|
23
24
|
readonly pageBreakBefore: boolean;
|
|
24
25
|
readonly bidi: boolean;
|
|
25
26
|
readonly outlineLevel?: number;
|
|
26
27
|
readonly styleId?: string;
|
|
28
|
+
readonly numbering?: NumberingReference;
|
|
27
29
|
}
|
|
28
30
|
export declare const DEFAULT_RESOLVED_RUN: ResolvedRunProperties;
|
|
29
31
|
export declare const DEFAULT_RESOLVED_PARAGRAPH: ResolvedParagraphProperties;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { halfPtToPt, twipsToPt } from "../ir/units.js";
|
|
2
|
+
//#region src/core/style-cascade/types.ts
|
|
2
3
|
var DEFAULT_RESOLVED_RUN = {
|
|
3
4
|
bold: false,
|
|
4
5
|
italic: false,
|
|
5
6
|
underline: "none",
|
|
6
7
|
strike: false,
|
|
7
|
-
|
|
8
|
+
fontSizePt: halfPtToPt(22),
|
|
8
9
|
colorHex: "000000",
|
|
9
10
|
fontFamily: {},
|
|
10
11
|
verticalAlign: "baseline",
|
|
@@ -12,13 +13,13 @@ var DEFAULT_RESOLVED_RUN = {
|
|
|
12
13
|
};
|
|
13
14
|
var DEFAULT_RESOLVED_PARAGRAPH = {
|
|
14
15
|
alignment: "left",
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
spacingBefore: twipsToPt(0),
|
|
17
|
+
spacingAfter: twipsToPt(0),
|
|
18
|
+
spacingLine: twipsToPt(240),
|
|
18
19
|
spacingLineRule: "auto",
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
indentLeft: twipsToPt(0),
|
|
21
|
+
indentRight: twipsToPt(0),
|
|
22
|
+
indentFirstLine: twipsToPt(0),
|
|
22
23
|
pageBreakBefore: false,
|
|
23
24
|
bidi: false
|
|
24
25
|
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type PathSegment = {
|
|
2
|
+
readonly op: 'move';
|
|
3
|
+
readonly x: number;
|
|
4
|
+
readonly y: number;
|
|
5
|
+
} | {
|
|
6
|
+
readonly op: 'line';
|
|
7
|
+
readonly x: number;
|
|
8
|
+
readonly y: number;
|
|
9
|
+
} | {
|
|
10
|
+
readonly op: 'cubic';
|
|
11
|
+
readonly x1: number;
|
|
12
|
+
readonly y1: number;
|
|
13
|
+
readonly x2: number;
|
|
14
|
+
readonly y2: number;
|
|
15
|
+
readonly x: number;
|
|
16
|
+
readonly y: number;
|
|
17
|
+
} | {
|
|
18
|
+
readonly op: 'close';
|
|
19
|
+
};
|
|
20
|
+
export interface VectorPath {
|
|
21
|
+
readonly segments: ReadonlyArray<PathSegment>;
|
|
22
|
+
readonly fillRule?: 'nonzero' | 'evenodd';
|
|
23
|
+
}
|
|
24
|
+
export interface StrokeStyle {
|
|
25
|
+
readonly colorHex: string;
|
|
26
|
+
readonly widthPt: number;
|
|
27
|
+
readonly cap?: 'butt' | 'round' | 'square';
|
|
28
|
+
readonly join?: 'miter' | 'round' | 'bevel';
|
|
29
|
+
readonly dash?: ReadonlyArray<number>;
|
|
30
|
+
}
|
|
31
|
+
export interface VectorShape {
|
|
32
|
+
readonly paths: ReadonlyArray<VectorPath>;
|
|
33
|
+
readonly fillColorHex?: string;
|
|
34
|
+
readonly stroke?: StrokeStyle;
|
|
35
|
+
readonly transform: readonly [number, number, number, number, number, number];
|
|
36
|
+
}
|
|
37
|
+
export declare class PathBuilder {
|
|
38
|
+
private readonly segments;
|
|
39
|
+
moveTo(x: number, y: number): this;
|
|
40
|
+
lineTo(x: number, y: number): this;
|
|
41
|
+
cubicTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): this;
|
|
42
|
+
append(segments: ReadonlyArray<PathSegment>): this;
|
|
43
|
+
close(): this;
|
|
44
|
+
build(fillRule?: 'nonzero' | 'evenodd'): VectorPath;
|
|
45
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//#region src/core/vector.ts
|
|
2
|
+
var PathBuilder = class {
|
|
3
|
+
segments = [];
|
|
4
|
+
moveTo(x, y) {
|
|
5
|
+
this.segments.push({
|
|
6
|
+
op: "move",
|
|
7
|
+
x,
|
|
8
|
+
y
|
|
9
|
+
});
|
|
10
|
+
return this;
|
|
11
|
+
}
|
|
12
|
+
lineTo(x, y) {
|
|
13
|
+
this.segments.push({
|
|
14
|
+
op: "line",
|
|
15
|
+
x,
|
|
16
|
+
y
|
|
17
|
+
});
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
cubicTo(x1, y1, x2, y2, x, y) {
|
|
21
|
+
this.segments.push({
|
|
22
|
+
op: "cubic",
|
|
23
|
+
x1,
|
|
24
|
+
y1,
|
|
25
|
+
x2,
|
|
26
|
+
y2,
|
|
27
|
+
x,
|
|
28
|
+
y
|
|
29
|
+
});
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
append(segments) {
|
|
33
|
+
for (const s of segments) this.segments.push(s);
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
close() {
|
|
37
|
+
this.segments.push({ op: "close" });
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
build(fillRule) {
|
|
41
|
+
return {
|
|
42
|
+
segments: this.segments.slice(),
|
|
43
|
+
...fillRule ? { fillRule } : {}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
export { PathBuilder };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseCellRef } from "./cell-reference.js";
|
|
2
|
-
//#region src/
|
|
2
|
+
//#region src/excel/defined-name-ref.ts
|
|
3
3
|
function stripQualifier(token) {
|
|
4
4
|
const bang = token.lastIndexOf("!");
|
|
5
5
|
return (bang >= 0 ? token.substring(bang + 1) : token).replace(/\$/g, "").trim();
|
|
@@ -4,7 +4,7 @@ export { parseAreaRef, parseTitleRowRange } from './defined-name-ref.js';
|
|
|
4
4
|
export type { CellRange } from './defined-name-ref.js';
|
|
5
5
|
export { parseSharedStrings } from './shared-strings-parser.js';
|
|
6
6
|
export { parseWorkbook } from './workbook-parser.js';
|
|
7
|
-
export type { DefinedName, ParsedWorkbook, SheetReference
|
|
7
|
+
export type { DefinedName, ParsedWorkbook, SheetReference } from './workbook-parser.js';
|
|
8
8
|
export { parseWorksheet } from './worksheet-parser.js';
|
|
9
9
|
export type { CellType, ColumnWidth, MergedRange, ParsedWorksheet, RowHeight, WorksheetCell, XlsxPageMargins, XlsxPageSetup, XlsxPrintOptions, } from './worksheet-parser.js';
|
|
10
10
|
export { parseXlsxStyles, EMPTY_XLSX_STYLES } from './styles-parser.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BodyElement, SectionProperties } from '../core/document-model/index.js';
|
|
2
|
+
import { CellRange, DefinedName, ParsedWorksheet, XlsxStyles } from './index.js';
|
|
3
|
+
export declare function sectionFromWorksheet(worksheet: ParsedWorksheet): SectionProperties | undefined;
|
|
4
|
+
export declare function resolvePrintArea(definedNames: ReadonlyArray<DefinedName>, sheetIdx: number): CellRange | undefined;
|
|
5
|
+
export declare function resolvePrintTitleRows(definedNames: ReadonlyArray<DefinedName>, sheetIdx: number): {
|
|
6
|
+
readonly startRow: number;
|
|
7
|
+
readonly endRow: number;
|
|
8
|
+
} | undefined;
|
|
9
|
+
interface PrintModelOptions {
|
|
10
|
+
readonly printArea?: CellRange;
|
|
11
|
+
readonly gridLines: boolean;
|
|
12
|
+
readonly titleRows?: {
|
|
13
|
+
readonly startRow: number;
|
|
14
|
+
readonly endRow: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export declare function worksheetToBody(worksheet: ParsedWorksheet, sharedStrings: Array<string>, styles: XlsxStyles, date1904: boolean, print: PrintModelOptions): Array<BodyElement>;
|
|
18
|
+
export {};
|