@evotecit/officeimo 0.1.0 → 0.1.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/README.md +13 -10
- package/bundles/officeimo-canopyx.js +842 -377
- package/bundles/officeimo-canopyx.mjs +729 -265
- package/bundles/officeimo-csv.js +29 -19
- package/bundles/officeimo-csv.mjs +17 -7
- package/bundles/officeimo-datatables.js +835 -379
- package/bundles/officeimo-datatables.mjs +723 -268
- package/bundles/officeimo-execution.js +35 -25
- package/bundles/officeimo-execution.mjs +17 -7
- package/bundles/officeimo-pdf.js +737 -291
- package/bundles/officeimo-pdf.mjs +688 -243
- package/bundles/officeimo-xlsx.js +114 -94
- package/bundles/officeimo-xlsx.mjs +48 -28
- package/bundles/officeimo.js +819 -363
- package/bundles/officeimo.mjs +709 -254
- package/dist/core/index.d.ts +2 -0
- package/dist/core/iteration.js +2 -2
- package/dist/core/sinks.js +2 -1
- package/dist/integrations/canopyx/source.js +13 -7
- package/dist/integrations/datatables/snapshot.js +3 -3
- package/dist/internal/rows.js +13 -4
- package/dist/opc/index.js +14 -9
- package/dist/pdf/document-grouped.js +72 -22
- package/dist/pdf/font-resources.js +2 -1
- package/dist/pdf/inline-text.js +50 -9
- package/dist/pdf/objects.js +188 -11
- package/dist/pdf/pages.js +28 -28
- package/dist/pdf/paragraph-layout.d.ts +2 -0
- package/dist/pdf/paragraph-layout.js +9 -4
- package/dist/pdf/session.js +1 -1
- package/dist/pdf/settings.d.ts +2 -0
- package/dist/pdf/settings.js +27 -2
- package/dist/pdf/structure.js +80 -28
- package/dist/pdf/table-band-flow.js +26 -11
- package/dist/pdf/table-band-plan.js +1 -3
- package/dist/pdf/table-layout.d.ts +4 -0
- package/dist/pdf/table-layout.js +22 -10
- package/dist/pdf/table-structure.js +28 -12
- package/dist/pdf/text.js +5 -0
- package/dist/pdf/types.d.ts +4 -2
- package/dist/pdf/xref.d.ts +1 -0
- package/dist/pdf/xref.js +30 -0
- package/dist/xlsx/values.js +3 -2
- package/dist/xlsx/workbook.js +7 -4
- package/dist/xlsx/worksheet.js +2 -1
- package/dist/xml/index.js +3 -3
- package/dist/zip/entry.js +1 -1
- package/dist/zip/index.js +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const _m2 = (() => {
|
|
3
3
|
function checkAbort(signal) {
|
|
4
4
|
if (signal?.aborted)
|
|
5
|
-
throw signal.reason
|
|
5
|
+
throw signal.reason;
|
|
6
6
|
}
|
|
7
7
|
/** Race a pending producer or sink operation without leaving abort listeners behind. */
|
|
8
8
|
function withAbort(promise, signal) {
|
|
@@ -10,7 +10,7 @@ function withAbort(promise, signal) {
|
|
|
10
10
|
return Promise.resolve(promise);
|
|
11
11
|
return new Promise((resolve, reject) => {
|
|
12
12
|
const cleanup = () => signal.removeEventListener("abort", abort);
|
|
13
|
-
const abort = () => { cleanup(); reject(signal.reason
|
|
13
|
+
const abort = () => { cleanup(); reject(signal.reason); };
|
|
14
14
|
signal.addEventListener("abort", abort, { once: true });
|
|
15
15
|
Promise.resolve(promise).then(value => { cleanup(); resolve(value); }, error => { cleanup(); reject(error); });
|
|
16
16
|
if (signal.aborted)
|
|
@@ -214,8 +214,9 @@ async function withDestination(destination, operation) {
|
|
|
214
214
|
// Native streams can belong to another browser realm; constructor identity is not portable.
|
|
215
215
|
if (destination && typeof destination.getWriter === "function") {
|
|
216
216
|
const writer = destination.getWriter();
|
|
217
|
+
// Native streams may retain accepted chunks after write resolves.
|
|
217
218
|
try {
|
|
218
|
-
return await operation({ write: bytes => writer.write(bytes) });
|
|
219
|
+
return await operation({ write: bytes => writer.write(new Uint8Array(bytes)) });
|
|
219
220
|
}
|
|
220
221
|
finally {
|
|
221
222
|
writer.releaseLock();
|
|
@@ -447,6 +448,8 @@ const { OfficeIMOError } = _m3;
|
|
|
447
448
|
const { ChunkedTextSink } = _m5;
|
|
448
449
|
|
|
449
450
|
const xmlDeclaration = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
|
|
451
|
+
const xmlEscapes = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'",
|
|
452
|
+
"\r": " ", "\n": " ", "\t": "	" };
|
|
450
453
|
/** XML 1.0 characters; Unicode mode retains valid surrogate pairs. */
|
|
451
454
|
function cleanXml(value, policy = "strip") {
|
|
452
455
|
if (policy !== "strip" && policy !== "reject")
|
|
@@ -458,9 +461,7 @@ function cleanXml(value, policy = "strip") {
|
|
|
458
461
|
}
|
|
459
462
|
/** Escape data, including whitespace that XML parsers otherwise normalize. */
|
|
460
463
|
function escapeXml(value, policy = "strip") {
|
|
461
|
-
|
|
462
|
-
"\r": " ", "\n": " ", "\t": "	" };
|
|
463
|
-
return cleanXml(value, policy).replace(/[&<>"'\r\n\t]/g, c => escapes[c]);
|
|
464
|
+
return cleanXml(value, policy).replace(/[&<>"'\r\n\t]/g, c => xmlEscapes[c]);
|
|
464
465
|
}
|
|
465
466
|
/** Encode an OOXML ST_Xstring attribute without interpreting literal escape tokens as characters. */
|
|
466
467
|
function escapeOoxmlAttribute(value, policy = "strip") {
|
|
@@ -621,7 +622,7 @@ class EntryWriter {
|
|
|
621
622
|
closed = false;
|
|
622
623
|
cleaned = false;
|
|
623
624
|
lifetime = new AbortController();
|
|
624
|
-
abort = () => { this.fail(this.signal?.reason
|
|
625
|
+
abort = () => { this.fail(this.signal?.reason); };
|
|
625
626
|
constructor(compression, sink, signal) {
|
|
626
627
|
this.sink = sink;
|
|
627
628
|
this.signal = signal;
|
|
@@ -785,7 +786,7 @@ class ZipWriter {
|
|
|
785
786
|
/** Pending header/directory writes and source reads must also stop on explicit discard. */
|
|
786
787
|
async acceptance(operation) {
|
|
787
788
|
const signal = this.options.signal;
|
|
788
|
-
const abort = () => this.lifetime.abort(signal?.reason
|
|
789
|
+
const abort = () => this.lifetime.abort(signal?.reason);
|
|
789
790
|
signal?.addEventListener("abort", abort, { once: true });
|
|
790
791
|
try {
|
|
791
792
|
checkAbort(signal);
|
|
@@ -1079,8 +1080,11 @@ class OpcPackage {
|
|
|
1079
1080
|
return uri;
|
|
1080
1081
|
}
|
|
1081
1082
|
addPart(part) {
|
|
1082
|
-
const uri
|
|
1083
|
-
|
|
1083
|
+
const { uri: requestedUri, contentType, data } = part;
|
|
1084
|
+
// Structural accessors and byte ownership are captured before reserving metadata.
|
|
1085
|
+
const capturedData = data instanceof Uint8Array ? new Uint8Array(data) : data;
|
|
1086
|
+
const uri = this.reserve(requestedUri, contentType);
|
|
1087
|
+
this.parts.set(uri.toLowerCase(), { uri, contentType, data: capturedData });
|
|
1084
1088
|
}
|
|
1085
1089
|
/** @internal */
|
|
1086
1090
|
addPrepared(uri, type, prepared) {
|
|
@@ -1105,17 +1109,19 @@ class OpcPackage {
|
|
|
1105
1109
|
checkAbort(this.options.signal);
|
|
1106
1110
|
this.open();
|
|
1107
1111
|
source = source === "/" ? source : partUri(source);
|
|
1108
|
-
|
|
1112
|
+
const { id, type, target: requestedTarget, external } = relationship;
|
|
1113
|
+
this.open();
|
|
1114
|
+
if (!/^[A-Za-z_][A-Za-z0-9_.-]*$/.test(id))
|
|
1109
1115
|
throw new TypeError("Relationship id must be an XML ID.");
|
|
1110
|
-
if (!/^[A-Za-z][A-Za-z0-9+.-]*:[^\s<>"']+$/.test(
|
|
1116
|
+
if (!/^[A-Za-z][A-Za-z0-9+.-]*:[^\s<>"']+$/.test(type))
|
|
1111
1117
|
throw new TypeError("Relationship type must be an absolute URI.");
|
|
1112
|
-
const target =
|
|
1113
|
-
if (
|
|
1118
|
+
const target = external ? requestedTarget : partUri(requestedTarget);
|
|
1119
|
+
if (external && (!target || /[\u0000-\u0020]/.test(target)))
|
|
1114
1120
|
throw new TypeError("Invalid external relationship target.");
|
|
1115
1121
|
const key = source.toLowerCase(), list = this.relationships.get(key) ?? new Map();
|
|
1116
|
-
if (list.has(
|
|
1117
|
-
throw new TypeError("Duplicate relationship id: " +
|
|
1118
|
-
list.set(
|
|
1122
|
+
if (list.has(id))
|
|
1123
|
+
throw new TypeError("Duplicate relationship id: " + id);
|
|
1124
|
+
list.set(id, { id, type, target, ...(external === undefined ? {} : { external }) });
|
|
1119
1125
|
this.relationships.set(key, list);
|
|
1120
1126
|
}
|
|
1121
1127
|
setProperties(core = {}, app = {}) {
|
|
@@ -1843,12 +1849,13 @@ function sheetName(requested, names, policy, register = true) {
|
|
|
1843
1849
|
throw new TypeError("Sheet name must be a string.");
|
|
1844
1850
|
// Validate and deduplicate the decoded literal value, before ST_Xstring attribute encoding.
|
|
1845
1851
|
// A requested _xHHHH_ token is literal text; the serializer protects its leading underscore.
|
|
1846
|
-
let base = cleanXml(requested, policy).replace(/[\[\]:*?/\\]/g, "_").
|
|
1852
|
+
let base = cleanXml(requested, policy).replace(/[\[\]:*?/\\]/g, "_").replace(/^[\s']+|[\s']+$/g, "");
|
|
1853
|
+
// Clipping can expose an internal apostrophe or the reserved History name.
|
|
1854
|
+
base = clipName(base, 31).replace(/[\s']+$/g, "");
|
|
1847
1855
|
if (!base)
|
|
1848
1856
|
base = "Sheet";
|
|
1849
1857
|
if (base.toLowerCase() === "history")
|
|
1850
1858
|
base += "_";
|
|
1851
|
-
base = clipName(base, 31);
|
|
1852
1859
|
let name = base, suffix = 2;
|
|
1853
1860
|
while (names.has(name.toLowerCase())) {
|
|
1854
1861
|
const tail = " (" + suffix++ + ")";
|
|
@@ -1887,11 +1894,18 @@ function createRowProjector(columns, worksheet, signal, validate = assertExportV
|
|
|
1887
1894
|
const getters = columns.some(column => column.value);
|
|
1888
1895
|
return (row, rowIndex = 0) => {
|
|
1889
1896
|
if (Array.isArray(row) && !getters) {
|
|
1890
|
-
|
|
1897
|
+
const length = row.length;
|
|
1898
|
+
if (length > columns.length)
|
|
1891
1899
|
throw new RangeError("Row has more values than declared columns.");
|
|
1892
|
-
|
|
1900
|
+
// Resolve each positional value once, just like key/value projections. Returning the
|
|
1901
|
+
// source array would let an accessor change a value after the portable-value check.
|
|
1902
|
+
const values = new Array(length);
|
|
1903
|
+
for (let index = 0; index < length; index++) {
|
|
1904
|
+
const value = row[index];
|
|
1893
1905
|
validate(value);
|
|
1894
|
-
|
|
1906
|
+
values[index] = value;
|
|
1907
|
+
}
|
|
1908
|
+
return values;
|
|
1895
1909
|
}
|
|
1896
1910
|
if (!row || typeof row !== "object" || isDate(row))
|
|
1897
1911
|
throw new TypeError("A row must be an array or object.");
|
|
@@ -1920,7 +1934,7 @@ function createRowProjector(columns, worksheet, signal, validate = assertExportV
|
|
|
1920
1934
|
};
|
|
1921
1935
|
}
|
|
1922
1936
|
/** @internal Shared metadata fields for full columns and adapter-owned partial overrides. */
|
|
1923
|
-
const columnOptionFields = ["header", "key", "value", "width", "type", "format", "wrapText", "alignment", "groups", "style", "valueFormatter"];
|
|
1937
|
+
const columnOptionFields = ["header", "key", "value", "width", "type", "format", "wrapText", "alignment", "rowHeader", "groups", "style", "valueFormatter"];
|
|
1924
1938
|
function copyColumns(columns, workbookStyles = false) {
|
|
1925
1939
|
if (!Array.isArray(columns))
|
|
1926
1940
|
throw new TypeError("Declare the columns in export order.");
|
|
@@ -1936,6 +1950,8 @@ function copyColumns(columns, workbookStyles = false) {
|
|
|
1936
1950
|
throw new TypeError("Each column needs a string header and an optional string key.");
|
|
1937
1951
|
if (captured.value !== undefined && typeof captured.value !== "function")
|
|
1938
1952
|
throw new TypeError("Column value getters must be functions.");
|
|
1953
|
+
if (captured.rowHeader !== undefined && typeof captured.rowHeader !== "boolean")
|
|
1954
|
+
throw new TypeError("Column rowHeader must be boolean.");
|
|
1939
1955
|
if (captured.groups !== undefined) {
|
|
1940
1956
|
if (!Array.isArray(captured.groups))
|
|
1941
1957
|
throw new TypeError("Column groups must be an array of strings.");
|
|
@@ -3220,7 +3236,8 @@ class Worksheet {
|
|
|
3220
3236
|
});
|
|
3221
3237
|
const originalCharacters = typeof value === "string" ? value.length : 0;
|
|
3222
3238
|
let reservedCharacters = this.preserved || header || footer ? originalCharacters : undefined;
|
|
3223
|
-
|
|
3239
|
+
// Cleaning removes characters; ordinary strings cannot cross Excel's limit.
|
|
3240
|
+
if (type === "string" && originalCharacters > 32767 && cleanXml(value, this.book.settings.invalidCharacterPolicy).length > 32767) {
|
|
3224
3241
|
const cell = col.letter + row;
|
|
3225
3242
|
if (link || this.linkedCells.has(cell))
|
|
3226
3243
|
throw new TypeError("A text-preservation cell cannot also have an external hyperlink.");
|
|
@@ -4440,12 +4457,15 @@ class Workbook {
|
|
|
4440
4457
|
});
|
|
4441
4458
|
}
|
|
4442
4459
|
addPart(part) {
|
|
4460
|
+
this.assertOpen();
|
|
4461
|
+
const { uri, contentType, data, relationship } = part;
|
|
4462
|
+
const capturedRelationship = relationship && { id: relationship.id, type: relationship.type, source: relationship.source };
|
|
4443
4463
|
this.assertOpen();
|
|
4444
4464
|
// Reserve now so collisions and invalid names fail at the call site.
|
|
4445
|
-
this.package.addPart(
|
|
4446
|
-
if (
|
|
4447
|
-
const { source,
|
|
4448
|
-
this.package.addRelationship(source ?? "/xl/workbook.xml", {
|
|
4465
|
+
this.package.addPart({ uri, contentType, data });
|
|
4466
|
+
if (capturedRelationship) {
|
|
4467
|
+
const { source, id, type } = capturedRelationship;
|
|
4468
|
+
this.package.addRelationship(source ?? "/xl/workbook.xml", { id, type, target: uri });
|
|
4449
4469
|
}
|
|
4450
4470
|
}
|
|
4451
4471
|
/** Complete the archive and return counts. Does not close or dispose a caller-owned sink. */
|