reamkit 1.15.4 → 1.17.0
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/bidi/segments.js +1 -2
- package/dist/esm/core/converter/facade.d.ts +5 -0
- package/dist/esm/core/converter/project.js +5 -1
- package/dist/esm/core/converter/ream.d.ts +6 -0
- package/dist/esm/core/converter/ream.js +34 -8
- package/dist/esm/core/document-model/index.d.ts +1 -1
- package/dist/esm/core/document-model/types.d.ts +659 -7
- package/dist/esm/core/drawingml/chart-geometry.d.ts +34 -10
- package/dist/esm/core/drawingml/chart-geometry.js +424 -92
- package/dist/esm/core/drawingml/chart-parser.js +301 -11
- package/dist/esm/core/drawingml/colors.d.ts +7 -7
- package/dist/esm/core/drawingml/colors.js +84 -18
- package/dist/esm/core/drawingml/preset-geometry.js +240 -6
- package/dist/esm/core/drawingml/shape-render.d.ts +12 -0
- package/dist/esm/core/drawingml/shape-render.js +116 -3
- package/dist/esm/core/drawingml/sparkline-geometry.js +6 -4
- package/dist/esm/core/drawingml/theme-parser.d.ts +51 -0
- package/dist/esm/core/drawingml/theme-parser.js +92 -1
- package/dist/esm/core/font/measure.d.ts +5 -0
- package/dist/esm/core/font/measure.js +21 -1
- package/dist/esm/core/font/ttf-subset.js +26 -1
- package/dist/esm/core/images.d.ts +2 -2
- package/dist/esm/core/images.js +353 -43
- package/dist/esm/core/indexed-colors.d.ts +11 -0
- package/dist/esm/core/indexed-colors.js +81 -0
- package/dist/esm/core/ir/flow.d.ts +23 -1
- package/dist/esm/core/ir/sheet.d.ts +61 -0
- package/dist/esm/{excel → core}/number-format.d.ts +37 -0
- package/dist/esm/core/number-format.js +800 -0
- package/dist/esm/core/numbering/apply.d.ts +5 -3
- package/dist/esm/core/numbering/apply.js +42 -11
- package/dist/esm/core/numbering/index.js +2 -0
- package/dist/esm/core/numbering/state.d.ts +13 -1
- package/dist/esm/core/numbering/state.js +256 -15
- package/dist/esm/core/opc/alternate-content.d.ts +13 -0
- package/dist/esm/core/opc/alternate-content.js +72 -0
- package/dist/esm/core/opc/core-properties.js +1 -0
- package/dist/esm/core/opc/package.d.ts +14 -1
- package/dist/esm/core/opc/package.js +43 -4
- package/dist/esm/core/opc/relationships.js +1 -0
- package/dist/esm/core/opc/xml-entities.d.ts +12 -0
- package/dist/esm/core/opc/xml-entities.js +91 -0
- package/dist/esm/core/po-helpers.js +16 -1
- package/dist/esm/core/spreadsheet-model/index.d.ts +1 -1
- package/dist/esm/core/spreadsheet-model/types.d.ts +137 -0
- package/dist/esm/core/style-cascade/resolver.js +66 -11
- package/dist/esm/core/style-cascade/table.js +35 -11
- package/dist/esm/core/style-cascade/types.d.ts +42 -1
- package/dist/esm/core/style-cascade/types.js +4 -0
- package/dist/esm/core/vector.d.ts +30 -0
- package/dist/esm/excel/activex-parser.js +1 -0
- package/dist/esm/excel/column-bands.d.ts +26 -1
- package/dist/esm/excel/column-bands.js +156 -20
- package/dist/esm/excel/comments-parser.js +5 -3
- package/dist/esm/excel/conditional-format.d.ts +25 -2
- package/dist/esm/excel/conditional-format.js +63 -19
- package/dist/esm/excel/escaped-text.d.ts +9 -0
- package/dist/esm/excel/escaped-text.js +20 -0
- package/dist/esm/excel/form-control-parser.js +1 -0
- package/dist/esm/excel/formula/dates.js +1 -1
- package/dist/esm/excel/header-footer.d.ts +9 -1
- package/dist/esm/excel/header-footer.js +162 -14
- package/dist/esm/excel/index.d.ts +1 -1
- package/dist/esm/excel/index.js +2 -2
- package/dist/esm/excel/pivot-table-parser.js +1 -0
- package/dist/esm/excel/print-model.d.ts +75 -0
- package/dist/esm/excel/print-model.js +899 -77
- package/dist/esm/excel/printer-settings.d.ts +16 -0
- package/dist/esm/excel/printer-settings.js +36 -0
- package/dist/esm/excel/rich-value.d.ts +13 -0
- package/dist/esm/excel/rich-value.js +120 -0
- package/dist/esm/excel/shared-strings-parser.js +11 -7
- package/dist/esm/excel/sheet-drawing.d.ts +11 -0
- package/dist/esm/excel/sheet-drawing.js +26 -3
- package/dist/esm/excel/sheet-shape-parser.d.ts +53 -1
- package/dist/esm/excel/sheet-shape-parser.js +461 -32
- package/dist/esm/excel/sheet-to-flow.d.ts +23 -2
- package/dist/esm/excel/sheet-to-flow.js +553 -36
- package/dist/esm/excel/slicer-parser.js +1 -0
- package/dist/esm/excel/styles-parser.d.ts +30 -2
- package/dist/esm/excel/styles-parser.js +177 -40
- package/dist/esm/excel/table-parser.js +1 -0
- package/dist/esm/excel/vml-drawing.d.ts +68 -0
- package/dist/esm/excel/vml-drawing.js +158 -0
- package/dist/esm/excel/workbook-parser.d.ts +5 -0
- package/dist/esm/excel/workbook-parser.js +5 -1
- package/dist/esm/excel/worksheet-parser.d.ts +2 -1
- package/dist/esm/excel/worksheet-parser.js +150 -61
- package/dist/esm/excel/xlsx-reader.js +242 -11
- package/dist/esm/excel/xlsx-to-pdf.js +12 -1
- package/dist/esm/html/html-writer.js +29 -6
- package/dist/esm/layout/page-doc.d.ts +87 -1
- package/dist/esm/layout/styled-layout.d.ts +46 -2
- package/dist/esm/layout/styled-layout.js +2345 -274
- package/dist/esm/pdf/cid-font.js +20 -9
- package/dist/esm/pdf/objects.d.ts +13 -0
- package/dist/esm/pdf/objects.js +18 -1
- package/dist/esm/pdf/shading.js +76 -6
- package/dist/esm/pdf/styled-page-emitter.js +355 -49
- package/dist/esm/pdf/text-page-renderer.js +1 -0
- package/dist/esm/pdf/vector-graphics.d.ts +31 -2
- package/dist/esm/pdf/vector-graphics.js +103 -3
- package/dist/esm/pptx/pptx-reader.js +2 -0
- package/dist/esm/pptx/slide-parser.d.ts +21 -4
- package/dist/esm/pptx/slide-parser.js +98 -24
- package/dist/esm/svg/svg-writer.js +23 -4
- package/dist/esm/word/document-parser.d.ts +96 -7
- package/dist/esm/word/document-parser.js +538 -116
- package/dist/esm/word/docx-reader.js +135 -43
- package/dist/esm/word/docx-writer.js +6 -1
- package/dist/esm/word/drawing-parser.d.ts +86 -5
- package/dist/esm/word/drawing-parser.js +1590 -54
- package/dist/esm/word/index.d.ts +4 -4
- package/dist/esm/word/numbering-parser.d.ts +2 -1
- package/dist/esm/word/numbering-parser.js +108 -21
- package/dist/esm/word/paragraph-properties.d.ts +11 -1
- package/dist/esm/word/paragraph-properties.js +219 -10
- package/dist/esm/word/run-properties.js +45 -1
- package/dist/esm/word/settings-parser.d.ts +24 -0
- package/dist/esm/word/settings-parser.js +32 -5
- package/dist/esm/word/shading.d.ts +11 -0
- package/dist/esm/word/shading.js +64 -0
- package/dist/esm/word/styles-parser.js +9 -2
- package/dist/esm/word/table-parser.d.ts +9 -1
- package/dist/esm/word/table-parser.js +182 -30
- package/package.json +7 -3
- package/dist/esm/excel/number-format.js +0 -476
|
@@ -3,7 +3,6 @@ import { computeBidi } from "./algorithm.js";
|
|
|
3
3
|
var OBJECT_REPLACEMENT = 65532;
|
|
4
4
|
var RLE = 8235;
|
|
5
5
|
var PDF_FMT = 8236;
|
|
6
|
-
var LRE = 8234;
|
|
7
6
|
/**
|
|
8
7
|
* Resolve UAX #9 embedding levels for a paragraph described as a flat list of
|
|
9
8
|
* {@link BidiSegment}s, returning one level per "real" position: one per text
|
|
@@ -24,7 +23,7 @@ function segmentLevels(segments, baseDir) {
|
|
|
24
23
|
let realCount = 0;
|
|
25
24
|
for (const seg of segments) {
|
|
26
25
|
const isObject = seg.object === true;
|
|
27
|
-
const wrap = seg.rtl
|
|
26
|
+
const wrap = seg.rtl === true ? RLE : 0;
|
|
28
27
|
if (wrap) {
|
|
29
28
|
bidiCps.push(wrap);
|
|
30
29
|
realIndexOfBidi.push(-1);
|
|
@@ -24,6 +24,11 @@ export interface ConvertOptions extends ConvertDocxOptions {
|
|
|
24
24
|
* never the wall clock; omitted ⇒ those clock-relative rules no-op.
|
|
25
25
|
*/
|
|
26
26
|
readonly now?: Date;
|
|
27
|
+
/**
|
|
28
|
+
* §18.3.1.34 `&F` — the workbook's file name, for a spreadsheet whose header
|
|
29
|
+
* or footer prints it. Absent, the code is dropped.
|
|
30
|
+
*/
|
|
31
|
+
readonly fileName?: string;
|
|
27
32
|
/**
|
|
28
33
|
* Font resolution chain (ir-design §8). When set (and no caller `fonts`),
|
|
29
34
|
* the facade resolves the default font set through these providers — e.g.
|
|
@@ -24,7 +24,11 @@ function flowRenderOptions(flow) {
|
|
|
24
24
|
resources: flow.resources,
|
|
25
25
|
...flow.charts ? { charts: flow.charts } : {},
|
|
26
26
|
...flow.embeddedFonts ? { embeddedFonts: flow.embeddedFonts } : {},
|
|
27
|
-
...flow.language ? { language: flow.language } : {}
|
|
27
|
+
...flow.language ? { language: flow.language } : {},
|
|
28
|
+
...flow.doNotExpandShiftReturn ? { doNotExpandShiftReturn: true } : {},
|
|
29
|
+
...flow.pageBackgroundColorHex ? { pageBackgroundColorHex: flow.pageBackgroundColorHex } : {},
|
|
30
|
+
...flow.pageBackgroundFill ? { pageBackgroundFill: flow.pageBackgroundFill } : {},
|
|
31
|
+
...flow.gutterAtTop ? { gutterAtTop: true } : {}
|
|
28
32
|
};
|
|
29
33
|
}
|
|
30
34
|
//#endregion
|
|
@@ -54,6 +54,12 @@ export interface ReamConvertOptions extends Omit<StyledRenderOptions, 'registry'
|
|
|
54
54
|
* unchanged.
|
|
55
55
|
*/
|
|
56
56
|
readonly now?: Date;
|
|
57
|
+
/**
|
|
58
|
+
* §18.3.1.34 `&F` — the workbook's file name, for a spreadsheet whose header
|
|
59
|
+
* or footer prints it. A byte-oriented reader cannot know it; supplied here,
|
|
60
|
+
* the code resolves, and omitted it is dropped exactly as before.
|
|
61
|
+
*/
|
|
62
|
+
readonly fileName?: string;
|
|
57
63
|
}
|
|
58
64
|
/**
|
|
59
65
|
* The object face of the library: parse a document once into the format-neutral
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { fetchFontSet } from "../fonts/remote-fonts.js";
|
|
2
2
|
import { FontRegistry } from "../font/font-registry.js";
|
|
3
|
+
import { createFontMeasure } from "../font/measure.js";
|
|
3
4
|
import { ConversionLossError } from "../ir/loss.js";
|
|
4
5
|
import { layoutStyledDocument } from "../../layout/styled-layout.js";
|
|
5
6
|
import { signPdf } from "../../pdf/signature.js";
|
|
@@ -12,8 +13,14 @@ import { writeXlsx } from "../../excel/xlsx-writer.js";
|
|
|
12
13
|
import { writeHtml } from "../../html/html-writer.js";
|
|
13
14
|
import { writeSvg } from "../../svg/svg-writer.js";
|
|
14
15
|
import { resolveDocxAutoFonts } from "../../word/docx-to-pdf.js";
|
|
16
|
+
import { isCfb, openCfb } from "../ole/cfb.js";
|
|
15
17
|
import { DEFAULT_READERS, resolveFontsViaChain, toFlowDoc } from "./facade.js";
|
|
16
18
|
//#region src/core/converter/ream.ts
|
|
19
|
+
/**
|
|
20
|
+
* The point size Excel's column-width unit is quoted at — its default theme
|
|
21
|
+
* font is 11 pt, and 8.43 of its digits are the documented 64 px column.
|
|
22
|
+
*/
|
|
23
|
+
var DEFAULT_WORKBOOK_FONT_PT = 11;
|
|
17
24
|
/** OOXML / legacy MIME types by reader id, for the PDF/A-3 embedded source file. */
|
|
18
25
|
var SOURCE_MIME = {
|
|
19
26
|
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
@@ -71,7 +78,10 @@ var Ream = class Ream {
|
|
|
71
78
|
static parse(bytes, options = {}) {
|
|
72
79
|
const readers = options.readers ?? DEFAULT_READERS;
|
|
73
80
|
const reader = readers.find((r) => r.sniff(bytes));
|
|
74
|
-
if (!reader)
|
|
81
|
+
if (!reader) {
|
|
82
|
+
if (isEncryptedOoxml(bytes)) throw new Error("Password-protected OOXML document (ECMA-376 §2.3 EncryptedPackage) — re-save it without a password");
|
|
83
|
+
throw new Error(`Unrecognized document format (readers: ${readers.map((r) => r.id).join(", ")})`);
|
|
84
|
+
}
|
|
75
85
|
const { doc, losses } = reader.read(bytes, { password: options.password });
|
|
76
86
|
const sheet = doc.kind === "sheet" ? doc : void 0;
|
|
77
87
|
return new Ream(toFlowDoc(doc), sheet, losses, bytes, reader.id);
|
|
@@ -106,7 +116,10 @@ var Ream = class Ream {
|
|
|
106
116
|
*/
|
|
107
117
|
async convertWithReport(to, options = {}) {
|
|
108
118
|
const losses = [...this.losses];
|
|
109
|
-
const flow = this.sheet && options.now ? projectSheetDoc(this.sheet, {
|
|
119
|
+
const flow = this.sheet && (options.now || options.fileName) ? projectSheetDoc(this.sheet, {
|
|
120
|
+
...options.now ? { now: options.now } : {},
|
|
121
|
+
...options.fileName ? { fileName: options.fileName } : {}
|
|
122
|
+
}) : this.flow;
|
|
110
123
|
if (to === "html") {
|
|
111
124
|
const html = writeHtml(flow);
|
|
112
125
|
losses.push(...html.losses);
|
|
@@ -137,10 +150,15 @@ var Ream = class Ream {
|
|
|
137
150
|
}
|
|
138
151
|
const { fonts, registriesByFamily } = await this.resolveFonts(options, losses);
|
|
139
152
|
const registry = FontRegistry.fromBytes(fonts);
|
|
153
|
+
const paginated = this.sheet ? projectSheetDoc(this.sheet, {
|
|
154
|
+
...options.now ? { now: options.now } : {},
|
|
155
|
+
...options.fileName ? { fileName: options.fileName } : {},
|
|
156
|
+
digitWidthPt: createFontMeasure(registry.resolveByStyle(false, false).parsed).textWidthPt("0", DEFAULT_WORKBOOK_FONT_PT)
|
|
157
|
+
}) : flow;
|
|
140
158
|
if (to === "svg") {
|
|
141
|
-
const svg = writeSvg(layoutStyledDocument(
|
|
159
|
+
const svg = writeSvg(layoutStyledDocument(paginated.body, {
|
|
142
160
|
registry,
|
|
143
|
-
...flowRenderOptions(
|
|
161
|
+
...flowRenderOptions(paginated)
|
|
144
162
|
}));
|
|
145
163
|
losses.push(...svg.losses);
|
|
146
164
|
this.enforceStrict(options, losses);
|
|
@@ -150,8 +168,8 @@ var Ream = class Ream {
|
|
|
150
168
|
};
|
|
151
169
|
}
|
|
152
170
|
const { fonts: _a, fontBytes: _b, fontFamily: _c, fontFetch: _d, fontProviders: _e, strict: _f, embedSource, signature, info: callerInfo, attachments: callerAttachments, ...renderOptions } = options;
|
|
153
|
-
const info =
|
|
154
|
-
...
|
|
171
|
+
const info = paginated.info || callerInfo ? {
|
|
172
|
+
...paginated.info,
|
|
155
173
|
...callerInfo
|
|
156
174
|
} : void 0;
|
|
157
175
|
const attachments = [...callerAttachments ?? []];
|
|
@@ -165,13 +183,13 @@ var Ream = class Ream {
|
|
|
165
183
|
const styled = {
|
|
166
184
|
registry,
|
|
167
185
|
...registriesByFamily ? { registriesByFamily } : {},
|
|
168
|
-
...flowRenderOptions(
|
|
186
|
+
...flowRenderOptions(paginated),
|
|
169
187
|
...info ? { info } : {},
|
|
170
188
|
...attachments.length > 0 ? { attachments } : {},
|
|
171
189
|
...signature ? { signaturePlaceholder: signature } : {},
|
|
172
190
|
...renderOptions
|
|
173
191
|
};
|
|
174
|
-
let pdf = styled.encrypt ? await renderStyledPdfEncrypted(
|
|
192
|
+
let pdf = styled.encrypt ? await renderStyledPdfEncrypted(paginated.body, styled) : renderStyledPdf(paginated.body, styled);
|
|
175
193
|
if (signature) pdf = await signPdf(pdf, signature);
|
|
176
194
|
this.enforceStrict(options, losses);
|
|
177
195
|
return {
|
|
@@ -214,5 +232,13 @@ var Ream = class Ream {
|
|
|
214
232
|
if (options.strict && losses.length > 0) throw new ConversionLossError(losses[0]);
|
|
215
233
|
}
|
|
216
234
|
};
|
|
235
|
+
function isEncryptedOoxml(bytes) {
|
|
236
|
+
if (!isCfb(bytes)) return false;
|
|
237
|
+
try {
|
|
238
|
+
return openCfb(bytes).hasStream("EncryptedPackage");
|
|
239
|
+
} catch {
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
217
243
|
//#endregion
|
|
218
244
|
export { Ream };
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @packageDocumentation
|
|
7
7
|
*/
|
|
8
|
-
export type { AbstractNumbering, Alignment, Border, BorderStyle, BodyElement, Comment, CellBorders, CellMerge, DocumentInfo, CellMargins, CellProperties, CellShading, CellDataBar, CellIcon, CellIconShape, CellSparkline, Chart, ChartBlock, ChartDataPoint, ChartSeries, ChartType, CustomGeometry, CustomPathCmd, DocumentModel, FontFamilyMap, HeaderFooterReference, HeaderFooterType, ImageBlock, InlineImage, MathAccent, MathBar, MathDelimiter, MathEqArray, MathFraction, MathFunc, MathGroupChr, MathLimit, MathMatrix, MathNary, MathNode, MathRadical, MathRow, MathRun, MathScript, Numbering, NumberingFormat, NumberingInstance, NumberingLevel, NumberingReference, PageMargins, PageSize, Paragraph, ParagraphProperties, Run, RunProperties, RowProperties, Section, FloatAnchor, SectionColumns, SectionProperties, ShapeBlock, ShapeDash, ShapeFill, ShapeFillKind, ShapeGeometry, ShapeLine, ShapeTextBody, ShapeTransform, Style, StyleSheet, StyleType, Table, TableCell, TableLook, TableProperties, TableStyleCondition, TableStyleConditionType, TableStyleLayer, TableRow, UnderlineStyle, VerticalAlign, } from './types.js';
|
|
8
|
+
export type { AbstractNumbering, Alignment, Border, BorderStyle, BodyElement, Comment, CellBorders, CellMerge, DocumentInfo, CellMargins, CellProperties, CellShading, CellDataBar, CellIcon, CellIconShape, CellSparkline, Chart, ChartBlock, ChartDataPoint, ChartLineStyle, ChartMarker, ChartMarkerSymbol, ChartSeries, ChartType, CustomGeometry, CustomPathCmd, DocumentModel, FontFamilyMap, HeaderFooterReference, HeaderFooterType, ImageBlock, ImageCrop, InlineImage, MathAccent, MathBar, MathDelimiter, MathEqArray, MathFraction, MathFunc, MathGroupChr, MathLimit, MathMatrix, MathNary, MathNode, MathRadical, MathRow, MathRun, MathScript, Numbering, NumberingFormat, NumberingInstance, NumberingLevel, PictureBullet, PictureOutline, NumberingReference, PageMargins, PageSize, Paragraph, ParagraphProperties, FrameProperties, RelativeSize, TabStop, Run, RunProperties, RowConditionalFormat, RowProperties, Section, FloatAnchor, SectionColumns, SectionProperties, ShapeBlock, ShapeShadow, ShapeDash, ShapeFill, ShapeFillKind, ShapeGeometry, ShapeGroupChild, ShapeLine, LineEnd, ShapeTextBody, ShapeTransform, Style, StyleSheet, StyleType, Table, TableCell, TableLook, TableProperties, TableStyleCondition, TableStyleConditionType, TableStyleLayer, TableRow, UnderlineStyle, VerticalAlign, } from './types.js';
|