ooxml.js 2.6.2 → 2.6.4
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/package-io/read.cjs +7 -5
- package/dist/package-io/read.js +7 -5
- package/dist/typed/docx/read.cjs +2 -1
- package/dist/typed/docx/read.js +2 -1
- package/dist/typed/pptx/inherit.cjs +4 -2
- package/dist/typed/pptx/inherit.js +4 -2
- package/dist/typed/pptx/read.cjs +9 -4
- package/dist/typed/pptx/read.js +9 -4
- package/dist/typed/xlsx/build.cjs +9 -6
- package/dist/typed/xlsx/build.js +9 -6
- package/dist/typed/xlsx/print-settings.cjs +4 -4
- package/dist/typed/xlsx/print-settings.js +4 -4
- package/package.json +1 -1
package/dist/package-io/read.cjs
CHANGED
|
@@ -6,11 +6,13 @@ const require_zip = require("../zip.cjs");
|
|
|
6
6
|
function parsePackage(bytes) {
|
|
7
7
|
const entries = require_zip.unzipPackage(bytes);
|
|
8
8
|
const parts = {};
|
|
9
|
-
for (const [path, partBytes] of Object.entries(entries)) if (looksLikeXml(partBytes))
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
for (const [path, partBytes] of Object.entries(entries)) if (looksLikeXml(partBytes)) {
|
|
10
|
+
const xml = new TextDecoder("utf-8").decode(partBytes);
|
|
11
|
+
parts[path] = {
|
|
12
|
+
kind: "xml",
|
|
13
|
+
nodes: require_xml_parse.parseXml(xml)
|
|
14
|
+
};
|
|
15
|
+
} else parts[path] = {
|
|
14
16
|
kind: "binary",
|
|
15
17
|
base64: require_util_base64.bytesToBase64(partBytes)
|
|
16
18
|
};
|
package/dist/package-io/read.js
CHANGED
|
@@ -5,11 +5,13 @@ import { unzipPackage } from "../zip.js";
|
|
|
5
5
|
function parsePackage(bytes) {
|
|
6
6
|
const entries = unzipPackage(bytes);
|
|
7
7
|
const parts = {};
|
|
8
|
-
for (const [path, partBytes] of Object.entries(entries)) if (looksLikeXml(partBytes))
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
for (const [path, partBytes] of Object.entries(entries)) if (looksLikeXml(partBytes)) {
|
|
9
|
+
const xml = new TextDecoder("utf-8").decode(partBytes);
|
|
10
|
+
parts[path] = {
|
|
11
|
+
kind: "xml",
|
|
12
|
+
nodes: parseXml(xml)
|
|
13
|
+
};
|
|
14
|
+
} else parts[path] = {
|
|
13
15
|
kind: "binary",
|
|
14
16
|
base64: bytesToBase64(partBytes)
|
|
15
17
|
};
|
package/dist/typed/docx/read.cjs
CHANGED
|
@@ -107,7 +107,8 @@ function readDrawingImage(drawing, rels, pkg) {
|
|
|
107
107
|
const rel = rId === void 0 ? void 0 : rels.get(rId);
|
|
108
108
|
const mediaPart = rel === void 0 ? void 0 : pkg.parts[rel.target];
|
|
109
109
|
if (mediaPart?.kind !== "binary") return;
|
|
110
|
-
const
|
|
110
|
+
const bytes = require_util_base64.base64ToBytes(mediaPart.base64);
|
|
111
|
+
const format = require_image_sniff.sniffImageFormat(bytes);
|
|
111
112
|
if (format === void 0) return;
|
|
112
113
|
const image = {
|
|
113
114
|
kind: "image",
|
package/dist/typed/docx/read.js
CHANGED
|
@@ -106,7 +106,8 @@ function readDrawingImage(drawing, rels, pkg) {
|
|
|
106
106
|
const rel = rId === void 0 ? void 0 : rels.get(rId);
|
|
107
107
|
const mediaPart = rel === void 0 ? void 0 : pkg.parts[rel.target];
|
|
108
108
|
if (mediaPart?.kind !== "binary") return;
|
|
109
|
-
const
|
|
109
|
+
const bytes = base64ToBytes(mediaPart.base64);
|
|
110
|
+
const format = sniffImageFormat(bytes);
|
|
110
111
|
if (format === void 0) return;
|
|
111
112
|
const image = {
|
|
112
113
|
kind: "image",
|
|
@@ -16,11 +16,13 @@ function resolveSlideInheritance(pkg, slidePath) {
|
|
|
16
16
|
const masterRoot = masterPath === void 0 ? void 0 : require_typed_util.rootElement(pkg.parts[masterPath]);
|
|
17
17
|
const themePath = masterPath === void 0 ? void 0 : findRelTarget(pkg, masterPath, THEME_REL_SUFFIX);
|
|
18
18
|
const themeRoot = themePath === void 0 ? void 0 : require_typed_util.rootElement(pkg.parts[themePath]);
|
|
19
|
+
const theme = themeRoot === void 0 ? require_typed_shared_drawingml.EMPTY_THEME : require_typed_shared_drawingml.readTheme(themeRoot);
|
|
20
|
+
const clrMapEl = masterRoot === void 0 ? void 0 : require_typed_util.childrenWithTag(masterRoot, "p:clrMap")[0];
|
|
19
21
|
return {
|
|
20
22
|
layoutRoot,
|
|
21
23
|
masterRoot,
|
|
22
|
-
theme
|
|
23
|
-
colorMap: require_typed_shared_drawingml.readColorMap(
|
|
24
|
+
theme,
|
|
25
|
+
colorMap: require_typed_shared_drawingml.readColorMap(clrMapEl)
|
|
24
26
|
};
|
|
25
27
|
}
|
|
26
28
|
const TYPE_NORMALIZATION = /* @__PURE__ */ new Map([["ctrTitle", "title"], ["subTitle", "body"]]);
|
|
@@ -15,11 +15,13 @@ function resolveSlideInheritance(pkg, slidePath) {
|
|
|
15
15
|
const masterRoot = masterPath === void 0 ? void 0 : rootElement(pkg.parts[masterPath]);
|
|
16
16
|
const themePath = masterPath === void 0 ? void 0 : findRelTarget(pkg, masterPath, THEME_REL_SUFFIX);
|
|
17
17
|
const themeRoot = themePath === void 0 ? void 0 : rootElement(pkg.parts[themePath]);
|
|
18
|
+
const theme = themeRoot === void 0 ? EMPTY_THEME : readTheme(themeRoot);
|
|
19
|
+
const clrMapEl = masterRoot === void 0 ? void 0 : childrenWithTag(masterRoot, "p:clrMap")[0];
|
|
18
20
|
return {
|
|
19
21
|
layoutRoot,
|
|
20
22
|
masterRoot,
|
|
21
|
-
theme
|
|
22
|
-
colorMap: readColorMap(
|
|
23
|
+
theme,
|
|
24
|
+
colorMap: readColorMap(clrMapEl)
|
|
23
25
|
};
|
|
24
26
|
}
|
|
25
27
|
const TYPE_NORMALIZATION = /* @__PURE__ */ new Map([["ctrTitle", "title"], ["subTitle", "body"]]);
|
package/dist/typed/pptx/read.cjs
CHANGED
|
@@ -104,7 +104,8 @@ function readLineSpacingMultiplier(pPr) {
|
|
|
104
104
|
}
|
|
105
105
|
function readParagraph(pEl, placeholderType, context, slideRels) {
|
|
106
106
|
const pPr = require_typed_util.childrenWithTag(pEl, "a:pPr")[0];
|
|
107
|
-
const
|
|
107
|
+
const level = pPr === void 0 ? 0 : Number(require_typed_util.attr(pPr, "lvl") ?? "0");
|
|
108
|
+
const masterDefaults = require_typed_pptx_inherit.resolveDefaultRunProperties(placeholderType, level, context);
|
|
108
109
|
const pPrDefRPr = pPr === void 0 ? void 0 : require_typed_util.childrenWithTag(pPr, "a:defRPr")[0];
|
|
109
110
|
const paragraphDefaults = pPrDefRPr === void 0 ? masterDefaults : mergeRunProperties(masterDefaults, require_typed_pptx_inherit.readRunPropertiesFromElement(pPrDefRPr, context));
|
|
110
111
|
const runs = [];
|
|
@@ -200,7 +201,8 @@ function readPicShape(pic, context, slideRels, pkg, parentTransform) {
|
|
|
200
201
|
const mediaPart = rel === void 0 ? void 0 : pkg.parts[rel.target];
|
|
201
202
|
const blocks = [];
|
|
202
203
|
if (mediaPart?.kind === "binary") {
|
|
203
|
-
const
|
|
204
|
+
const bytes = require_util_base64.base64ToBytes(mediaPart.base64);
|
|
205
|
+
const format = require_image_sniff.sniffImageFormat(bytes);
|
|
204
206
|
if (format !== void 0) {
|
|
205
207
|
const image = {
|
|
206
208
|
kind: "image",
|
|
@@ -225,7 +227,8 @@ function readTableCell(tc, context, slideRels) {
|
|
|
225
227
|
const vMerge = require_typed_util.attr(tc, "vMerge");
|
|
226
228
|
if (hMerge === "1" || vMerge === "1") return { blocks: [] };
|
|
227
229
|
const tcPr = require_typed_util.childrenWithTag(tc, "a:tcPr")[0];
|
|
228
|
-
const
|
|
230
|
+
const solidFill = tcPr === void 0 ? void 0 : require_typed_util.childrenWithTag(tcPr, "a:solidFill")[0];
|
|
231
|
+
const background = require_typed_shared_drawingml.readSolidFillColor(solidFill, context.colorMap, context.theme);
|
|
229
232
|
const txBody = require_typed_util.childrenWithTag(tc, "a:txBody")[0];
|
|
230
233
|
const gridSpan = require_typed_util.attr(tc, "gridSpan");
|
|
231
234
|
const rowSpan = require_typed_util.attr(tc, "rowSpan");
|
|
@@ -289,7 +292,9 @@ function walkShapeTreeChildren(children, parentTransform, context, slideRels, pk
|
|
|
289
292
|
if (shape !== void 0) out.push(shape);
|
|
290
293
|
} else if (node.tag === "p:grpSp") {
|
|
291
294
|
const grpSpPr = require_typed_util.childrenWithTag(node, "p:grpSpPr")[0];
|
|
292
|
-
const
|
|
295
|
+
const xfrmEl = grpSpPr === void 0 ? void 0 : require_typed_util.childrenWithTag(grpSpPr, "a:xfrm")[0];
|
|
296
|
+
const ownGroupTransform = require_typed_shared_drawingml.readGroupXfrm(xfrmEl);
|
|
297
|
+
const composed = require_typed_shared_drawingml.composeGroupTransform(ownGroupTransform, parentTransform);
|
|
293
298
|
walkShapeTreeChildren(node.children, composed, context, slideRels, pkg, out);
|
|
294
299
|
}
|
|
295
300
|
}
|
package/dist/typed/pptx/read.js
CHANGED
|
@@ -103,7 +103,8 @@ function readLineSpacingMultiplier(pPr) {
|
|
|
103
103
|
}
|
|
104
104
|
function readParagraph(pEl, placeholderType, context, slideRels) {
|
|
105
105
|
const pPr = childrenWithTag(pEl, "a:pPr")[0];
|
|
106
|
-
const
|
|
106
|
+
const level = pPr === void 0 ? 0 : Number(attr(pPr, "lvl") ?? "0");
|
|
107
|
+
const masterDefaults = resolveDefaultRunProperties(placeholderType, level, context);
|
|
107
108
|
const pPrDefRPr = pPr === void 0 ? void 0 : childrenWithTag(pPr, "a:defRPr")[0];
|
|
108
109
|
const paragraphDefaults = pPrDefRPr === void 0 ? masterDefaults : mergeRunProperties(masterDefaults, readRunPropertiesFromElement(pPrDefRPr, context));
|
|
109
110
|
const runs = [];
|
|
@@ -199,7 +200,8 @@ function readPicShape(pic, context, slideRels, pkg, parentTransform) {
|
|
|
199
200
|
const mediaPart = rel === void 0 ? void 0 : pkg.parts[rel.target];
|
|
200
201
|
const blocks = [];
|
|
201
202
|
if (mediaPart?.kind === "binary") {
|
|
202
|
-
const
|
|
203
|
+
const bytes = base64ToBytes(mediaPart.base64);
|
|
204
|
+
const format = sniffImageFormat(bytes);
|
|
203
205
|
if (format !== void 0) {
|
|
204
206
|
const image = {
|
|
205
207
|
kind: "image",
|
|
@@ -224,7 +226,8 @@ function readTableCell(tc, context, slideRels) {
|
|
|
224
226
|
const vMerge = attr(tc, "vMerge");
|
|
225
227
|
if (hMerge === "1" || vMerge === "1") return { blocks: [] };
|
|
226
228
|
const tcPr = childrenWithTag(tc, "a:tcPr")[0];
|
|
227
|
-
const
|
|
229
|
+
const solidFill = tcPr === void 0 ? void 0 : childrenWithTag(tcPr, "a:solidFill")[0];
|
|
230
|
+
const background = readSolidFillColor(solidFill, context.colorMap, context.theme);
|
|
228
231
|
const txBody = childrenWithTag(tc, "a:txBody")[0];
|
|
229
232
|
const gridSpan = attr(tc, "gridSpan");
|
|
230
233
|
const rowSpan = attr(tc, "rowSpan");
|
|
@@ -288,7 +291,9 @@ function walkShapeTreeChildren(children, parentTransform, context, slideRels, pk
|
|
|
288
291
|
if (shape !== void 0) out.push(shape);
|
|
289
292
|
} else if (node.tag === "p:grpSp") {
|
|
290
293
|
const grpSpPr = childrenWithTag(node, "p:grpSpPr")[0];
|
|
291
|
-
const
|
|
294
|
+
const xfrmEl = grpSpPr === void 0 ? void 0 : childrenWithTag(grpSpPr, "a:xfrm")[0];
|
|
295
|
+
const ownGroupTransform = readGroupXfrm(xfrmEl);
|
|
296
|
+
const composed = composeGroupTransform(ownGroupTransform, parentTransform);
|
|
292
297
|
walkShapeTreeChildren(node.children, composed, context, slideRels, pkg, out);
|
|
293
298
|
}
|
|
294
299
|
}
|
|
@@ -162,11 +162,12 @@ function buildDefinedNameElements(sheets) {
|
|
|
162
162
|
return elements;
|
|
163
163
|
}
|
|
164
164
|
function buildWorkbookPart(sheets) {
|
|
165
|
-
const
|
|
165
|
+
const sheetElements = sheets.map((sheet, index) => require_xml_fragment.el("sheet", {
|
|
166
166
|
name: require_xml_entities.encodeXmlText(sheet.name),
|
|
167
167
|
sheetId: String(index + 1),
|
|
168
168
|
"r:id": worksheetRelId(index)
|
|
169
|
-
}))
|
|
169
|
+
}));
|
|
170
|
+
const children = [require_xml_fragment.el("sheets", {}, sheetElements)];
|
|
170
171
|
const definedNameElements = buildDefinedNameElements(sheets);
|
|
171
172
|
if (definedNameElements.length > 0) children.push(require_xml_fragment.el("definedNames", {}, definedNameElements));
|
|
172
173
|
return xmlPart(require_xml_fragment.el("workbook", {
|
|
@@ -270,7 +271,7 @@ function computeDimension(sheet) {
|
|
|
270
271
|
}
|
|
271
272
|
function buildColsElement(columns) {
|
|
272
273
|
if (columns.length === 0) return;
|
|
273
|
-
|
|
274
|
+
const colElements = columns.map((column) => {
|
|
274
275
|
const attrs = {
|
|
275
276
|
min: String(column.index + 1),
|
|
276
277
|
max: String(column.index + 1)
|
|
@@ -281,7 +282,8 @@ function buildColsElement(columns) {
|
|
|
281
282
|
}
|
|
282
283
|
if (column.hidden === true) attrs.hidden = "true";
|
|
283
284
|
return require_xml_fragment.el("col", attrs);
|
|
284
|
-
})
|
|
285
|
+
});
|
|
286
|
+
return require_xml_fragment.el("cols", {}, colElements);
|
|
285
287
|
}
|
|
286
288
|
function renderCellValue(value, isFormulaResult, sharedStrings) {
|
|
287
289
|
switch (value.kind) {
|
|
@@ -351,7 +353,7 @@ function buildSheetDataElement(sheet, sharedStrings, cellFormats) {
|
|
|
351
353
|
}
|
|
352
354
|
const rowInfoByIndex = /* @__PURE__ */ new Map();
|
|
353
355
|
for (const row of sheet.rows) rowInfoByIndex.set(row.index, row);
|
|
354
|
-
|
|
356
|
+
const rowElements = Array.from(/* @__PURE__ */ new Set([...cellsByRow.keys(), ...rowInfoByIndex.keys()])).sort((a, b) => a - b).map((rowIndex) => {
|
|
355
357
|
const cells = (cellsByRow.get(rowIndex) ?? []).slice().sort((a, b) => a.column - b.column);
|
|
356
358
|
const rowInfo = rowInfoByIndex.get(rowIndex);
|
|
357
359
|
const attrs = { r: String(rowIndex + 1) };
|
|
@@ -363,7 +365,8 @@ function buildSheetDataElement(sheet, sharedStrings, cellFormats) {
|
|
|
363
365
|
if (rowInfo.hidden === true) attrs.hidden = "true";
|
|
364
366
|
}
|
|
365
367
|
return require_xml_fragment.el("row", attrs, cells.map((cell) => buildCellElement(cell, sharedStrings, cellFormats)));
|
|
366
|
-
})
|
|
368
|
+
});
|
|
369
|
+
return require_xml_fragment.el("sheetData", {}, rowElements);
|
|
367
370
|
}
|
|
368
371
|
function buildMergeCellsElement(cells) {
|
|
369
372
|
const merges = cells.filter((cell) => (cell.colSpan ?? 1) > 1 || (cell.rowSpan ?? 1) > 1);
|
package/dist/typed/xlsx/build.js
CHANGED
|
@@ -161,11 +161,12 @@ function buildDefinedNameElements(sheets) {
|
|
|
161
161
|
return elements;
|
|
162
162
|
}
|
|
163
163
|
function buildWorkbookPart(sheets) {
|
|
164
|
-
const
|
|
164
|
+
const sheetElements = sheets.map((sheet, index) => el("sheet", {
|
|
165
165
|
name: encodeXmlText(sheet.name),
|
|
166
166
|
sheetId: String(index + 1),
|
|
167
167
|
"r:id": worksheetRelId(index)
|
|
168
|
-
}))
|
|
168
|
+
}));
|
|
169
|
+
const children = [el("sheets", {}, sheetElements)];
|
|
169
170
|
const definedNameElements = buildDefinedNameElements(sheets);
|
|
170
171
|
if (definedNameElements.length > 0) children.push(el("definedNames", {}, definedNameElements));
|
|
171
172
|
return xmlPart(el("workbook", {
|
|
@@ -269,7 +270,7 @@ function computeDimension(sheet) {
|
|
|
269
270
|
}
|
|
270
271
|
function buildColsElement(columns) {
|
|
271
272
|
if (columns.length === 0) return;
|
|
272
|
-
|
|
273
|
+
const colElements = columns.map((column) => {
|
|
273
274
|
const attrs = {
|
|
274
275
|
min: String(column.index + 1),
|
|
275
276
|
max: String(column.index + 1)
|
|
@@ -280,7 +281,8 @@ function buildColsElement(columns) {
|
|
|
280
281
|
}
|
|
281
282
|
if (column.hidden === true) attrs.hidden = "true";
|
|
282
283
|
return el("col", attrs);
|
|
283
|
-
})
|
|
284
|
+
});
|
|
285
|
+
return el("cols", {}, colElements);
|
|
284
286
|
}
|
|
285
287
|
function renderCellValue(value, isFormulaResult, sharedStrings) {
|
|
286
288
|
switch (value.kind) {
|
|
@@ -350,7 +352,7 @@ function buildSheetDataElement(sheet, sharedStrings, cellFormats) {
|
|
|
350
352
|
}
|
|
351
353
|
const rowInfoByIndex = /* @__PURE__ */ new Map();
|
|
352
354
|
for (const row of sheet.rows) rowInfoByIndex.set(row.index, row);
|
|
353
|
-
|
|
355
|
+
const rowElements = Array.from(/* @__PURE__ */ new Set([...cellsByRow.keys(), ...rowInfoByIndex.keys()])).sort((a, b) => a - b).map((rowIndex) => {
|
|
354
356
|
const cells = (cellsByRow.get(rowIndex) ?? []).slice().sort((a, b) => a.column - b.column);
|
|
355
357
|
const rowInfo = rowInfoByIndex.get(rowIndex);
|
|
356
358
|
const attrs = { r: String(rowIndex + 1) };
|
|
@@ -362,7 +364,8 @@ function buildSheetDataElement(sheet, sharedStrings, cellFormats) {
|
|
|
362
364
|
if (rowInfo.hidden === true) attrs.hidden = "true";
|
|
363
365
|
}
|
|
364
366
|
return el("row", attrs, cells.map((cell) => buildCellElement(cell, sharedStrings, cellFormats)));
|
|
365
|
-
})
|
|
367
|
+
});
|
|
368
|
+
return el("sheetData", {}, rowElements);
|
|
366
369
|
}
|
|
367
370
|
function buildMergeCellsElement(cells) {
|
|
368
371
|
const merges = cells.filter((cell) => (cell.colSpan ?? 1) > 1 || (cell.rowSpan ?? 1) > 1);
|
|
@@ -6,10 +6,10 @@ const require_typed_xlsx_util = require("./util.cjs");
|
|
|
6
6
|
let document_schema_js = require("document-schema.js");
|
|
7
7
|
//#region src/typed/xlsx/print-settings.ts
|
|
8
8
|
const DEFAULT_MARGINS = {
|
|
9
|
-
topPt:
|
|
10
|
-
rightPt: .
|
|
11
|
-
bottomPt:
|
|
12
|
-
leftPt: .
|
|
9
|
+
topPt: 54,
|
|
10
|
+
rightPt: 50.4,
|
|
11
|
+
bottomPt: 54,
|
|
12
|
+
leftPt: 50.4
|
|
13
13
|
};
|
|
14
14
|
const DEFAULT_HEADER_FOOTER_MARGIN_PT = .3 * 72;
|
|
15
15
|
const DEFAULT_FIT_TO_PAGES = 1;
|
|
@@ -5,10 +5,10 @@ import { paperSizeCodeToPageSize, parseUniversalMeasureToPt, readXmlBool } from
|
|
|
5
5
|
import { PAGE_SIZE_LETTER } from "document-schema.js";
|
|
6
6
|
//#region src/typed/xlsx/print-settings.ts
|
|
7
7
|
const DEFAULT_MARGINS = {
|
|
8
|
-
topPt:
|
|
9
|
-
rightPt: .
|
|
10
|
-
bottomPt:
|
|
11
|
-
leftPt: .
|
|
8
|
+
topPt: 54,
|
|
9
|
+
rightPt: 50.4,
|
|
10
|
+
bottomPt: 54,
|
|
11
|
+
leftPt: 50.4
|
|
12
12
|
};
|
|
13
13
|
const DEFAULT_HEADER_FOOTER_MARGIN_PT = .3 * 72;
|
|
14
14
|
const DEFAULT_FIT_TO_PAGES = 1;
|
package/package.json
CHANGED