ooxml-core 1.25.2 → 1.26.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 +16 -0
- package/dist/{PptxHandler-AUK27AQD.mjs → PptxHandler-64BZOBWX.mjs} +3 -3
- package/dist/{PptxHandler-QBGEZDCO.cjs → PptxHandler-AILFLRH7.cjs} +3 -3
- package/dist/PptxHandler-PMLQGMFQ.mjs +4 -0
- package/dist/{PresentationBuilder-RX7D75GZ.mjs → PresentationBuilder-EJY2TYWL.mjs} +2 -2
- package/dist/{PresentationBuilder-MEETJGEA.mjs → PresentationBuilder-HBCCO2CF.mjs} +3 -3
- package/dist/{PresentationBuilder-CI45KEHL.cjs → PresentationBuilder-RBQP6A37.cjs} +5 -5
- package/dist/automation/index.cjs +273 -156
- package/dist/automation/index.mjs +273 -156
- package/dist/automation/xlsx-read.d.ts +2 -8
- package/dist/automation/xlsx-read.d.ts.map +1 -1
- package/dist/automation/xlsx.d.ts +2 -2
- package/dist/chart/index.cjs +89 -47
- package/dist/chart/index.mjs +89 -47
- package/dist/{chunk-6DHZZD5R.mjs → chunk-2XMK5SXU.mjs} +106 -48
- package/dist/{chunk-VGDHSED6.mjs → chunk-DHAZSMC7.mjs} +1 -1
- package/dist/{chunk-TX2QFS3J.mjs → chunk-FZBAMWCJ.mjs} +788 -542
- package/dist/{chunk-E2PYQQQV.mjs → chunk-JJ37PCNR.mjs} +89 -47
- package/dist/{chunk-S5TGOEQX.cjs → chunk-MU3XSASV.cjs} +106 -47
- package/dist/{chunk-GMETZZ3V.cjs → chunk-NXTHB2M3.cjs} +1857 -1611
- package/dist/{chunk-HVRFRYYS.mjs → chunk-OQPT5IC3.mjs} +5 -5
- package/dist/{chunk-5F7OB7PA.mjs → chunk-OTXJVFMY.mjs} +785 -539
- package/dist/{chunk-635WPRNJ.mjs → chunk-R7RL7W43.mjs} +19 -3
- package/dist/{chunk-E3PRAHL6.mjs → chunk-WRFMS5CL.mjs} +1 -1
- package/dist/docx/embedded.cjs +89 -47
- package/dist/docx/embedded.mjs +89 -47
- package/dist/docx/index.cjs +89 -47
- package/dist/docx/index.mjs +89 -47
- package/dist/docx/load/index.cjs +89 -47
- package/dist/docx/load/index.mjs +89 -47
- package/dist/index.cjs +128 -53
- package/dist/index.mjs +128 -53
- package/dist/opc/index.cjs +90 -47
- package/dist/opc/index.mjs +90 -48
- package/dist/opc/zip-limits.d.ts +6 -0
- package/dist/opc/zip-limits.d.ts.map +1 -1
- package/dist/pptx/automation/index.cjs +954 -622
- package/dist/pptx/automation/index.d.ts +4 -4
- package/dist/pptx/automation/index.mjs +6 -6
- package/dist/pptx/chunks/{index-DCbp5fOs.d.ts → index-CbFowkp4.d.ts} +12 -5
- package/dist/pptx/chunks/{index-DCbp5fOs.d.ts.map → index-CbFowkp4.d.ts.map} +1 -1
- package/dist/pptx/chunks/{index-CX0RM1fF.d.ts → index-D4FnOx6x.d.ts} +3 -3
- package/dist/pptx/chunks/{index-CX0RM1fF.d.ts.map → index-D4FnOx6x.d.ts.map} +1 -1
- package/dist/pptx/chunks/{index-CgjEEpfK.d.ts → index-D8DNpc1X.d.ts} +289 -118
- package/dist/pptx/chunks/index-D8DNpc1X.d.ts.map +1 -0
- package/dist/pptx/chunks/{text-operations-CjalmJIi.d.ts → text-operations-CNfUj45U.d.ts} +16 -2
- package/dist/pptx/chunks/{text-operations-CjalmJIi.d.ts.map → text-operations-CNfUj45U.d.ts.map} +1 -1
- package/dist/pptx/cli/index.cjs +954 -622
- package/dist/pptx/cli/index.d.ts +1 -1
- package/dist/pptx/cli/index.mjs +5 -5
- package/dist/pptx/converter/index.d.ts +1 -1
- package/dist/pptx/converter/index.mjs +3 -3
- package/dist/pptx/editor/render/editor-history.cjs +21 -0
- package/dist/pptx/editor/render/editor-history.d.ts +9 -0
- package/dist/pptx/editor/render/editor-history.d.ts.map +1 -1
- package/dist/pptx/editor/render/editor-history.mjs +21 -0
- package/dist/pptx/editor/render/find-replace.cjs +14 -14
- package/dist/pptx/editor/render/find-replace.d.ts +2 -2
- package/dist/pptx/editor/render/find-replace.mjs +1 -1
- package/dist/pptx/editor/render/slide-operations.cjs +8 -8
- package/dist/pptx/editor/render/slide-operations.mjs +2 -2
- package/dist/pptx/index.cjs +953 -620
- package/dist/pptx/index.d.ts +5 -5
- package/dist/pptx/index.mjs +6 -6
- package/dist/pptx/node/index.d.ts +1 -1
- package/dist/pptx/signature-node/index.cjs +89 -47
- package/dist/pptx/signature-node/index.mjs +2 -2
- package/dist/visio/index.cjs +266 -150
- package/dist/visio/index.mjs +266 -150
- package/dist/visio/ui/index.cjs +266 -150
- package/dist/visio/ui/index.mjs +266 -150
- package/dist/xlsx/index.cjs +518 -153
- package/dist/xlsx/index.mjs +518 -154
- package/dist/xlsx/load/index.cjs +266 -150
- package/dist/xlsx/load/index.mjs +266 -150
- package/dist/xlsx/numfmt/view.d.ts +13 -0
- package/dist/xlsx/numfmt/view.d.ts.map +1 -0
- package/dist/xlsx/read/index.d.ts +1 -0
- package/dist/xlsx/read/index.d.ts.map +1 -1
- package/dist/xlsx/read/limits.d.ts +5 -0
- package/dist/xlsx/read/limits.d.ts.map +1 -1
- package/dist/xlsx/read/package.d.ts +6 -0
- package/dist/xlsx/read/package.d.ts.map +1 -1
- package/dist/xlsx/read/rows-stream.d.ts +12 -0
- package/dist/xlsx/read/rows-stream.d.ts.map +1 -0
- package/dist/xlsx/read/rows.d.ts +37 -0
- package/dist/xlsx/read/rows.d.ts.map +1 -0
- package/dist/xlsx/read/shared-strings.d.ts +6 -1
- package/dist/xlsx/read/shared-strings.d.ts.map +1 -1
- package/dist/xlsx/read/sheet-data-source.d.ts +30 -3
- package/dist/xlsx/read/sheet-data-source.d.ts.map +1 -1
- package/dist/xlsx/read/sheet-data.d.ts +13 -2
- package/dist/xlsx/read/sheet-data.d.ts.map +1 -1
- package/dist/xlsx/read/worksheet.d.ts.map +1 -1
- package/dist/xlsx/ui/index.cjs +266 -150
- package/dist/xlsx/ui/index.mjs +266 -150
- package/dist/xml/index.cjs +38 -6
- package/dist/xml/index.mjs +37 -7
- package/dist/xml/lite.d.ts +15 -0
- package/dist/xml/lite.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/PptxHandler-5UO5DD5K.mjs +0 -4
- package/dist/pptx/chunks/index-CgjEEpfK.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -2446,6 +2446,7 @@ function nudgeOutsideLabels(boxes, disc, minY, maxY) {
|
|
|
2446
2446
|
var xml_exports = {};
|
|
2447
2447
|
__export(xml_exports, {
|
|
2448
2448
|
DEFAULT_XML_LIMITS: () => DEFAULT_XML_LIMITS,
|
|
2449
|
+
LiteDeclinedError: () => LiteDeclinedError,
|
|
2449
2450
|
LiteElement: () => LiteElement,
|
|
2450
2451
|
NS: () => NS,
|
|
2451
2452
|
XmlLimitError: () => XmlLimitError,
|
|
@@ -2456,6 +2457,7 @@ __export(xml_exports, {
|
|
|
2456
2457
|
elements: () => elements,
|
|
2457
2458
|
first: () => first,
|
|
2458
2459
|
isElement: () => isElement,
|
|
2460
|
+
liteChildElements: () => liteChildElements,
|
|
2459
2461
|
makeNS: () => makeNS,
|
|
2460
2462
|
named: () => named,
|
|
2461
2463
|
parseLiteFragment: () => parseLiteFragment,
|
|
@@ -2710,40 +2712,68 @@ function decode(text3) {
|
|
|
2710
2712
|
}
|
|
2711
2713
|
var isSpace = (code) => code === 32 || code === 9 || code === 10 || code === 13;
|
|
2712
2714
|
var hasLineEnds = (xml) => xml.includes("\r") || xml.includes("\x85") || xml.includes("\u2028") || xml.includes("\u2029");
|
|
2715
|
+
var LiteDeclinedError = class extends Error {
|
|
2716
|
+
constructor() {
|
|
2717
|
+
super("The XML fragment needs the full parser");
|
|
2718
|
+
this.name = "LiteDeclinedError";
|
|
2719
|
+
}
|
|
2720
|
+
};
|
|
2713
2721
|
function parseLiteFragment(xml, container, namespaces) {
|
|
2722
|
+
const nodes = topLevelNodes(xml, namespaces);
|
|
2723
|
+
for (let next = nodes.next(); ; next = nodes.next()) {
|
|
2724
|
+
if (next.done) return next.value ? container : void 0;
|
|
2725
|
+
container.childNodes.push(next.value);
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2728
|
+
function* liteChildElements(xml, namespaces) {
|
|
2729
|
+
const nodes = topLevelNodes(xml, namespaces);
|
|
2730
|
+
for (let next = nodes.next(); ; next = nodes.next()) {
|
|
2731
|
+
if (next.done) {
|
|
2732
|
+
if (next.value) return;
|
|
2733
|
+
throw new LiteDeclinedError();
|
|
2734
|
+
}
|
|
2735
|
+
if (typeof next.value !== "string") yield next.value.asElement();
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
function* topLevelNodes(xml, namespaces) {
|
|
2714
2739
|
const source = hasLineEnds(xml) ? xml.replace(/\r[\n\u0085]/g, "\n").replace(/[\r\u0085\u2028\u2029]/g, "\n") : xml;
|
|
2715
|
-
const root =
|
|
2740
|
+
const root = new LiteElement("", "", null);
|
|
2741
|
+
const level3 = root.childNodes;
|
|
2716
2742
|
const stack = [root];
|
|
2717
2743
|
let top = root;
|
|
2718
2744
|
const n2 = source.length;
|
|
2719
2745
|
let pos = 0;
|
|
2720
2746
|
while (pos < n2) {
|
|
2747
|
+
if (level3.length && stack.length === 1) {
|
|
2748
|
+
yield* level3;
|
|
2749
|
+
level3.length = 0;
|
|
2750
|
+
}
|
|
2721
2751
|
const lt = source.indexOf("<", pos);
|
|
2722
2752
|
const end = lt < 0 ? n2 : lt;
|
|
2723
2753
|
if (end > pos) {
|
|
2724
2754
|
const text3 = decode(source.slice(pos, end));
|
|
2725
|
-
if (text3 === void 0) return
|
|
2755
|
+
if (text3 === void 0) return false;
|
|
2726
2756
|
top.childNodes.push(text3);
|
|
2727
2757
|
}
|
|
2728
2758
|
if (lt < 0) break;
|
|
2729
2759
|
const next = source.charCodeAt(lt + 1);
|
|
2730
2760
|
if (next === 33) {
|
|
2731
2761
|
const after = skipCommentOrCdata(source, lt, top);
|
|
2732
|
-
if (after < 0) return
|
|
2762
|
+
if (after < 0) return false;
|
|
2733
2763
|
pos = after;
|
|
2734
2764
|
continue;
|
|
2735
2765
|
}
|
|
2736
2766
|
if (next === 47) {
|
|
2737
2767
|
const gt = source.indexOf(">", lt);
|
|
2738
2768
|
if (gt < 0 || stack.length < 2 || source.slice(lt + 2, gt).trimEnd() !== top.tagName)
|
|
2739
|
-
return
|
|
2769
|
+
return false;
|
|
2740
2770
|
stack.pop();
|
|
2741
2771
|
top = stack[stack.length - 1];
|
|
2742
2772
|
pos = gt + 1;
|
|
2743
2773
|
continue;
|
|
2744
2774
|
}
|
|
2745
2775
|
const parsed = startTag(source, lt + 1, namespaces);
|
|
2746
|
-
if (!parsed) return
|
|
2776
|
+
if (!parsed) return false;
|
|
2747
2777
|
top.childNodes.push(parsed.element);
|
|
2748
2778
|
if (!parsed.selfClosing) {
|
|
2749
2779
|
stack.push(parsed.element);
|
|
@@ -2751,7 +2781,9 @@ function parseLiteFragment(xml, container, namespaces) {
|
|
|
2751
2781
|
}
|
|
2752
2782
|
pos = parsed.end;
|
|
2753
2783
|
}
|
|
2754
|
-
|
|
2784
|
+
if (stack.length !== 1) return false;
|
|
2785
|
+
yield* level3;
|
|
2786
|
+
return true;
|
|
2755
2787
|
}
|
|
2756
2788
|
var DECLARATIONS = /<!DOCTYPE|<!ENTITY/i;
|
|
2757
2789
|
function skipCommentOrCdata(source, lt, parent) {
|
|
@@ -12387,57 +12419,99 @@ function resolveLimits(limits) {
|
|
|
12387
12419
|
fail: (message, limit, kind) => create2 ? create2(message, { limit, kind }) : new ZipLimitError(message, { limit, kind })
|
|
12388
12420
|
};
|
|
12389
12421
|
}
|
|
12390
|
-
function inflateEntryGuarded(entry3, alreadyRead, limits) {
|
|
12422
|
+
async function inflateEntryGuarded(entry3, alreadyRead, limits) {
|
|
12423
|
+
const chunks = [];
|
|
12424
|
+
let size = 0;
|
|
12425
|
+
for await (const chunk of streamEntryGuarded(entry3, alreadyRead, limits)) {
|
|
12426
|
+
chunks.push(chunk);
|
|
12427
|
+
size += chunk.byteLength;
|
|
12428
|
+
}
|
|
12429
|
+
if (chunks.length === 1 && chunks[0]) return chunks[0];
|
|
12430
|
+
const out = new Uint8Array(size);
|
|
12431
|
+
let offset = 0;
|
|
12432
|
+
for (const chunk of chunks) {
|
|
12433
|
+
out.set(chunk, offset);
|
|
12434
|
+
offset += chunk.byteLength;
|
|
12435
|
+
}
|
|
12436
|
+
return out;
|
|
12437
|
+
}
|
|
12438
|
+
var AHEAD = 8;
|
|
12439
|
+
async function* streamEntryGuarded(entry3, alreadyRead, limits) {
|
|
12391
12440
|
const r = resolveLimits(limits);
|
|
12392
12441
|
const declared = declaredEntrySize(entry3);
|
|
12393
|
-
|
|
12394
|
-
|
|
12395
|
-
|
|
12396
|
-
|
|
12397
|
-
|
|
12398
|
-
|
|
12399
|
-
|
|
12400
|
-
|
|
12401
|
-
|
|
12402
|
-
|
|
12403
|
-
|
|
12404
|
-
|
|
12405
|
-
|
|
12406
|
-
|
|
12407
|
-
|
|
12408
|
-
if (size > declared || size > r.maxEntryBytes)
|
|
12409
|
-
return abort(
|
|
12410
|
-
r.fail(
|
|
12411
|
-
`${r.label} part ${entry3.name} inflates past its declared size`,
|
|
12412
|
-
r.maxEntryBytes,
|
|
12413
|
-
size > declared ? "declaredSize" : "maxEntryBytes"
|
|
12414
|
-
)
|
|
12415
|
-
);
|
|
12416
|
-
if (alreadyRead + size > r.maxTotalBytes)
|
|
12417
|
-
return abort(
|
|
12418
|
-
r.fail(
|
|
12419
|
-
`${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
|
|
12420
|
-
r.maxTotalBytes,
|
|
12421
|
-
"maxTotalBytes"
|
|
12422
|
-
)
|
|
12423
|
-
);
|
|
12424
|
-
chunks.push(chunk);
|
|
12425
|
-
});
|
|
12426
|
-
stream.on("error", (error) => abort(error));
|
|
12427
|
-
stream.on("end", () => {
|
|
12428
|
-
if (done) return;
|
|
12429
|
-
done = true;
|
|
12430
|
-
if (chunks.length === 1 && chunks[0]) return resolvePromise(chunks[0]);
|
|
12431
|
-
const out = new Uint8Array(size);
|
|
12432
|
-
let offset = 0;
|
|
12433
|
-
for (const chunk of chunks) {
|
|
12434
|
-
out.set(chunk, offset);
|
|
12435
|
-
offset += chunk.byteLength;
|
|
12436
|
-
}
|
|
12437
|
-
resolvePromise(out);
|
|
12438
|
-
});
|
|
12442
|
+
const stream = entry3.internalStream("uint8array");
|
|
12443
|
+
const queue = [];
|
|
12444
|
+
let size = 0;
|
|
12445
|
+
let ended = false;
|
|
12446
|
+
let stopped = false;
|
|
12447
|
+
let failure;
|
|
12448
|
+
let paused = false;
|
|
12449
|
+
let wake;
|
|
12450
|
+
const pause = () => {
|
|
12451
|
+
paused = true;
|
|
12452
|
+
stream.pause();
|
|
12453
|
+
};
|
|
12454
|
+
const resume = () => {
|
|
12455
|
+
if (!paused || stopped) return;
|
|
12456
|
+
paused = false;
|
|
12439
12457
|
stream.resume();
|
|
12458
|
+
};
|
|
12459
|
+
const fail = (error) => {
|
|
12460
|
+
failure ??= error;
|
|
12461
|
+
stopped = true;
|
|
12462
|
+
queue.length = 0;
|
|
12463
|
+
pause();
|
|
12464
|
+
wake?.();
|
|
12465
|
+
};
|
|
12466
|
+
stream.on("data", (chunk) => {
|
|
12467
|
+
if (stopped) return pause();
|
|
12468
|
+
size += chunk.byteLength;
|
|
12469
|
+
if (size > declared || size > r.maxEntryBytes)
|
|
12470
|
+
return fail(
|
|
12471
|
+
r.fail(
|
|
12472
|
+
`${r.label} part ${entry3.name} inflates past its declared size`,
|
|
12473
|
+
r.maxEntryBytes,
|
|
12474
|
+
size > declared ? "declaredSize" : "maxEntryBytes"
|
|
12475
|
+
)
|
|
12476
|
+
);
|
|
12477
|
+
if (alreadyRead + size > r.maxTotalBytes)
|
|
12478
|
+
return fail(
|
|
12479
|
+
r.fail(
|
|
12480
|
+
`${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
|
|
12481
|
+
r.maxTotalBytes,
|
|
12482
|
+
"maxTotalBytes"
|
|
12483
|
+
)
|
|
12484
|
+
);
|
|
12485
|
+
queue.push(chunk);
|
|
12486
|
+
if (queue.length >= AHEAD) pause();
|
|
12487
|
+
wake?.();
|
|
12488
|
+
});
|
|
12489
|
+
stream.on("error", (error) => fail(error));
|
|
12490
|
+
stream.on("end", () => {
|
|
12491
|
+
ended = true;
|
|
12492
|
+
wake?.();
|
|
12440
12493
|
});
|
|
12494
|
+
stream.resume();
|
|
12495
|
+
try {
|
|
12496
|
+
for (; ; ) {
|
|
12497
|
+
if (failure) throw failure;
|
|
12498
|
+
const chunk = queue.shift();
|
|
12499
|
+
if (chunk) {
|
|
12500
|
+
if (queue.length < AHEAD / 2) resume();
|
|
12501
|
+
yield chunk;
|
|
12502
|
+
continue;
|
|
12503
|
+
}
|
|
12504
|
+
if (ended) return;
|
|
12505
|
+
await new Promise((resolve) => {
|
|
12506
|
+
wake = resolve;
|
|
12507
|
+
resume();
|
|
12508
|
+
});
|
|
12509
|
+
wake = void 0;
|
|
12510
|
+
}
|
|
12511
|
+
} finally {
|
|
12512
|
+
stopped = true;
|
|
12513
|
+
if (!ended) pause();
|
|
12514
|
+
}
|
|
12441
12515
|
}
|
|
12442
12516
|
function toBase64(bytes) {
|
|
12443
12517
|
let binary = "";
|
|
@@ -40317,6 +40391,7 @@ __export(opc_exports, {
|
|
|
40317
40391
|
replaceTitleGroup: () => replaceTitleGroup,
|
|
40318
40392
|
resolvePartPath: () => resolvePartPath,
|
|
40319
40393
|
signature: () => signature_exports,
|
|
40394
|
+
streamEntryGuarded: () => streamEntryGuarded,
|
|
40320
40395
|
titleGroups: () => titleGroups,
|
|
40321
40396
|
writeAppProperties: () => writeAppProperties,
|
|
40322
40397
|
writeCoreProperties: () => writeCoreProperties,
|
package/dist/opc/index.cjs
CHANGED
|
@@ -534,57 +534,99 @@ function resolveLimits(limits) {
|
|
|
534
534
|
fail: (message, limit, kind) => create ? create(message, { limit, kind }) : new ZipLimitError(message, { limit, kind })
|
|
535
535
|
};
|
|
536
536
|
}
|
|
537
|
-
function inflateEntryGuarded(entry, alreadyRead, limits) {
|
|
537
|
+
async function inflateEntryGuarded(entry, alreadyRead, limits) {
|
|
538
|
+
const chunks = [];
|
|
539
|
+
let size = 0;
|
|
540
|
+
for await (const chunk of streamEntryGuarded(entry, alreadyRead, limits)) {
|
|
541
|
+
chunks.push(chunk);
|
|
542
|
+
size += chunk.byteLength;
|
|
543
|
+
}
|
|
544
|
+
if (chunks.length === 1 && chunks[0]) return chunks[0];
|
|
545
|
+
const out = new Uint8Array(size);
|
|
546
|
+
let offset = 0;
|
|
547
|
+
for (const chunk of chunks) {
|
|
548
|
+
out.set(chunk, offset);
|
|
549
|
+
offset += chunk.byteLength;
|
|
550
|
+
}
|
|
551
|
+
return out;
|
|
552
|
+
}
|
|
553
|
+
var AHEAD = 8;
|
|
554
|
+
async function* streamEntryGuarded(entry, alreadyRead, limits) {
|
|
538
555
|
const r = resolveLimits(limits);
|
|
539
556
|
const declared = declaredEntrySize(entry);
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
if (size > declared || size > r.maxEntryBytes)
|
|
556
|
-
return abort(
|
|
557
|
-
r.fail(
|
|
558
|
-
`${r.label} part ${entry.name} inflates past its declared size`,
|
|
559
|
-
r.maxEntryBytes,
|
|
560
|
-
size > declared ? "declaredSize" : "maxEntryBytes"
|
|
561
|
-
)
|
|
562
|
-
);
|
|
563
|
-
if (alreadyRead + size > r.maxTotalBytes)
|
|
564
|
-
return abort(
|
|
565
|
-
r.fail(
|
|
566
|
-
`${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
|
|
567
|
-
r.maxTotalBytes,
|
|
568
|
-
"maxTotalBytes"
|
|
569
|
-
)
|
|
570
|
-
);
|
|
571
|
-
chunks.push(chunk);
|
|
572
|
-
});
|
|
573
|
-
stream.on("error", (error) => abort(error));
|
|
574
|
-
stream.on("end", () => {
|
|
575
|
-
if (done) return;
|
|
576
|
-
done = true;
|
|
577
|
-
if (chunks.length === 1 && chunks[0]) return resolvePromise(chunks[0]);
|
|
578
|
-
const out = new Uint8Array(size);
|
|
579
|
-
let offset = 0;
|
|
580
|
-
for (const chunk of chunks) {
|
|
581
|
-
out.set(chunk, offset);
|
|
582
|
-
offset += chunk.byteLength;
|
|
583
|
-
}
|
|
584
|
-
resolvePromise(out);
|
|
585
|
-
});
|
|
557
|
+
const stream = entry.internalStream("uint8array");
|
|
558
|
+
const queue = [];
|
|
559
|
+
let size = 0;
|
|
560
|
+
let ended = false;
|
|
561
|
+
let stopped = false;
|
|
562
|
+
let failure;
|
|
563
|
+
let paused = false;
|
|
564
|
+
let wake;
|
|
565
|
+
const pause = () => {
|
|
566
|
+
paused = true;
|
|
567
|
+
stream.pause();
|
|
568
|
+
};
|
|
569
|
+
const resume = () => {
|
|
570
|
+
if (!paused || stopped) return;
|
|
571
|
+
paused = false;
|
|
586
572
|
stream.resume();
|
|
573
|
+
};
|
|
574
|
+
const fail = (error) => {
|
|
575
|
+
failure ??= error;
|
|
576
|
+
stopped = true;
|
|
577
|
+
queue.length = 0;
|
|
578
|
+
pause();
|
|
579
|
+
wake?.();
|
|
580
|
+
};
|
|
581
|
+
stream.on("data", (chunk) => {
|
|
582
|
+
if (stopped) return pause();
|
|
583
|
+
size += chunk.byteLength;
|
|
584
|
+
if (size > declared || size > r.maxEntryBytes)
|
|
585
|
+
return fail(
|
|
586
|
+
r.fail(
|
|
587
|
+
`${r.label} part ${entry.name} inflates past its declared size`,
|
|
588
|
+
r.maxEntryBytes,
|
|
589
|
+
size > declared ? "declaredSize" : "maxEntryBytes"
|
|
590
|
+
)
|
|
591
|
+
);
|
|
592
|
+
if (alreadyRead + size > r.maxTotalBytes)
|
|
593
|
+
return fail(
|
|
594
|
+
r.fail(
|
|
595
|
+
`${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
|
|
596
|
+
r.maxTotalBytes,
|
|
597
|
+
"maxTotalBytes"
|
|
598
|
+
)
|
|
599
|
+
);
|
|
600
|
+
queue.push(chunk);
|
|
601
|
+
if (queue.length >= AHEAD) pause();
|
|
602
|
+
wake?.();
|
|
603
|
+
});
|
|
604
|
+
stream.on("error", (error) => fail(error));
|
|
605
|
+
stream.on("end", () => {
|
|
606
|
+
ended = true;
|
|
607
|
+
wake?.();
|
|
587
608
|
});
|
|
609
|
+
stream.resume();
|
|
610
|
+
try {
|
|
611
|
+
for (; ; ) {
|
|
612
|
+
if (failure) throw failure;
|
|
613
|
+
const chunk = queue.shift();
|
|
614
|
+
if (chunk) {
|
|
615
|
+
if (queue.length < AHEAD / 2) resume();
|
|
616
|
+
yield chunk;
|
|
617
|
+
continue;
|
|
618
|
+
}
|
|
619
|
+
if (ended) return;
|
|
620
|
+
await new Promise((resolve) => {
|
|
621
|
+
wake = resolve;
|
|
622
|
+
resume();
|
|
623
|
+
});
|
|
624
|
+
wake = void 0;
|
|
625
|
+
}
|
|
626
|
+
} finally {
|
|
627
|
+
stopped = true;
|
|
628
|
+
if (!ended) pause();
|
|
629
|
+
}
|
|
588
630
|
}
|
|
589
631
|
function toBase64(bytes) {
|
|
590
632
|
let binary = "";
|
|
@@ -1694,6 +1736,7 @@ exports.replaceEmbeddedPackage = replaceEmbeddedPackage;
|
|
|
1694
1736
|
exports.replaceTitleGroup = replaceTitleGroup;
|
|
1695
1737
|
exports.resolvePartPath = resolvePartPath;
|
|
1696
1738
|
exports.signature = signature_exports;
|
|
1739
|
+
exports.streamEntryGuarded = streamEntryGuarded;
|
|
1697
1740
|
exports.titleGroups = titleGroups;
|
|
1698
1741
|
exports.writeAppProperties = writeAppProperties;
|
|
1699
1742
|
exports.writeCoreProperties = writeCoreProperties;
|
package/dist/opc/index.mjs
CHANGED
|
@@ -528,57 +528,99 @@ function resolveLimits(limits) {
|
|
|
528
528
|
fail: (message, limit, kind) => create ? create(message, { limit, kind }) : new ZipLimitError(message, { limit, kind })
|
|
529
529
|
};
|
|
530
530
|
}
|
|
531
|
-
function inflateEntryGuarded(entry, alreadyRead, limits) {
|
|
531
|
+
async function inflateEntryGuarded(entry, alreadyRead, limits) {
|
|
532
|
+
const chunks = [];
|
|
533
|
+
let size = 0;
|
|
534
|
+
for await (const chunk of streamEntryGuarded(entry, alreadyRead, limits)) {
|
|
535
|
+
chunks.push(chunk);
|
|
536
|
+
size += chunk.byteLength;
|
|
537
|
+
}
|
|
538
|
+
if (chunks.length === 1 && chunks[0]) return chunks[0];
|
|
539
|
+
const out = new Uint8Array(size);
|
|
540
|
+
let offset = 0;
|
|
541
|
+
for (const chunk of chunks) {
|
|
542
|
+
out.set(chunk, offset);
|
|
543
|
+
offset += chunk.byteLength;
|
|
544
|
+
}
|
|
545
|
+
return out;
|
|
546
|
+
}
|
|
547
|
+
var AHEAD = 8;
|
|
548
|
+
async function* streamEntryGuarded(entry, alreadyRead, limits) {
|
|
532
549
|
const r = resolveLimits(limits);
|
|
533
550
|
const declared = declaredEntrySize(entry);
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
if (size > declared || size > r.maxEntryBytes)
|
|
550
|
-
return abort(
|
|
551
|
-
r.fail(
|
|
552
|
-
`${r.label} part ${entry.name} inflates past its declared size`,
|
|
553
|
-
r.maxEntryBytes,
|
|
554
|
-
size > declared ? "declaredSize" : "maxEntryBytes"
|
|
555
|
-
)
|
|
556
|
-
);
|
|
557
|
-
if (alreadyRead + size > r.maxTotalBytes)
|
|
558
|
-
return abort(
|
|
559
|
-
r.fail(
|
|
560
|
-
`${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
|
|
561
|
-
r.maxTotalBytes,
|
|
562
|
-
"maxTotalBytes"
|
|
563
|
-
)
|
|
564
|
-
);
|
|
565
|
-
chunks.push(chunk);
|
|
566
|
-
});
|
|
567
|
-
stream.on("error", (error) => abort(error));
|
|
568
|
-
stream.on("end", () => {
|
|
569
|
-
if (done) return;
|
|
570
|
-
done = true;
|
|
571
|
-
if (chunks.length === 1 && chunks[0]) return resolvePromise(chunks[0]);
|
|
572
|
-
const out = new Uint8Array(size);
|
|
573
|
-
let offset = 0;
|
|
574
|
-
for (const chunk of chunks) {
|
|
575
|
-
out.set(chunk, offset);
|
|
576
|
-
offset += chunk.byteLength;
|
|
577
|
-
}
|
|
578
|
-
resolvePromise(out);
|
|
579
|
-
});
|
|
551
|
+
const stream = entry.internalStream("uint8array");
|
|
552
|
+
const queue = [];
|
|
553
|
+
let size = 0;
|
|
554
|
+
let ended = false;
|
|
555
|
+
let stopped = false;
|
|
556
|
+
let failure;
|
|
557
|
+
let paused = false;
|
|
558
|
+
let wake;
|
|
559
|
+
const pause = () => {
|
|
560
|
+
paused = true;
|
|
561
|
+
stream.pause();
|
|
562
|
+
};
|
|
563
|
+
const resume = () => {
|
|
564
|
+
if (!paused || stopped) return;
|
|
565
|
+
paused = false;
|
|
580
566
|
stream.resume();
|
|
567
|
+
};
|
|
568
|
+
const fail = (error) => {
|
|
569
|
+
failure ??= error;
|
|
570
|
+
stopped = true;
|
|
571
|
+
queue.length = 0;
|
|
572
|
+
pause();
|
|
573
|
+
wake?.();
|
|
574
|
+
};
|
|
575
|
+
stream.on("data", (chunk) => {
|
|
576
|
+
if (stopped) return pause();
|
|
577
|
+
size += chunk.byteLength;
|
|
578
|
+
if (size > declared || size > r.maxEntryBytes)
|
|
579
|
+
return fail(
|
|
580
|
+
r.fail(
|
|
581
|
+
`${r.label} part ${entry.name} inflates past its declared size`,
|
|
582
|
+
r.maxEntryBytes,
|
|
583
|
+
size > declared ? "declaredSize" : "maxEntryBytes"
|
|
584
|
+
)
|
|
585
|
+
);
|
|
586
|
+
if (alreadyRead + size > r.maxTotalBytes)
|
|
587
|
+
return fail(
|
|
588
|
+
r.fail(
|
|
589
|
+
`${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
|
|
590
|
+
r.maxTotalBytes,
|
|
591
|
+
"maxTotalBytes"
|
|
592
|
+
)
|
|
593
|
+
);
|
|
594
|
+
queue.push(chunk);
|
|
595
|
+
if (queue.length >= AHEAD) pause();
|
|
596
|
+
wake?.();
|
|
597
|
+
});
|
|
598
|
+
stream.on("error", (error) => fail(error));
|
|
599
|
+
stream.on("end", () => {
|
|
600
|
+
ended = true;
|
|
601
|
+
wake?.();
|
|
581
602
|
});
|
|
603
|
+
stream.resume();
|
|
604
|
+
try {
|
|
605
|
+
for (; ; ) {
|
|
606
|
+
if (failure) throw failure;
|
|
607
|
+
const chunk = queue.shift();
|
|
608
|
+
if (chunk) {
|
|
609
|
+
if (queue.length < AHEAD / 2) resume();
|
|
610
|
+
yield chunk;
|
|
611
|
+
continue;
|
|
612
|
+
}
|
|
613
|
+
if (ended) return;
|
|
614
|
+
await new Promise((resolve) => {
|
|
615
|
+
wake = resolve;
|
|
616
|
+
resume();
|
|
617
|
+
});
|
|
618
|
+
wake = void 0;
|
|
619
|
+
}
|
|
620
|
+
} finally {
|
|
621
|
+
stopped = true;
|
|
622
|
+
if (!ended) pause();
|
|
623
|
+
}
|
|
582
624
|
}
|
|
583
625
|
function toBase64(bytes) {
|
|
584
626
|
let binary = "";
|
|
@@ -1643,4 +1685,4 @@ function computeVerificationStatus(details) {
|
|
|
1643
1685
|
return hasInvalidSignature ? "signature-invalid" : hasRevoked ? "certificate-revoked" : hasTimestampInvalid ? "timestamp-invalid" : hasTimestampUntrusted ? "timestamp-untrusted" : hasMissing ? "reference-missing" : hasMismatch ? "digest-mismatch" : allVerified ? "verified-trusted" : hasUntrusted ? "verified-untrusted" : "present-not-verified";
|
|
1644
1686
|
}
|
|
1645
1687
|
|
|
1646
|
-
export { CORE_PROPERTY_FIELDS, CUSTOM_PROPERTIES_FMTID, DEFAULT_ZIP_LIMITS, PROPERTY_CONTENT_TYPES, PROPERTY_PART_NAMES, RELATIONSHIP_TYPES, STRICT_APP_NAMESPACES, ZipLimitError, allocateCustomPropertyIds, buildContentTypesXml, buildRelationshipsXml, clonePartGraph, contentTypeForPart, customPropertyFromText, declaredEntrySize, ensureContentTypeDefault, ensureContentTypeOverride, ensureRelationship, findOfficeDocumentPart, formatW3cdtf, fromTitleGroups, getRelationshipId, guardZip, hyperlinkPolicy, inflateEntryGuarded, isOpenableHyperlinkHref, isSafeHyperlinkHref, isSafePartName, isStorableHyperlinkHref, listEmbeddedPackages, nextRelationshipId, openZip, parseAppProperties, parseContentTypes, parseCoreProperties, parseCustomProperties, parseCustomPropertyTexts, parseRelationships, relationshipsPartFor, relativePartTarget, removeContentTypeOverride, replaceEmbeddedPackage, replaceTitleGroup, resolvePartPath, signature_exports as signature, titleGroups, writeAppProperties, writeCoreProperties, writeCustomProperties };
|
|
1688
|
+
export { CORE_PROPERTY_FIELDS, CUSTOM_PROPERTIES_FMTID, DEFAULT_ZIP_LIMITS, PROPERTY_CONTENT_TYPES, PROPERTY_PART_NAMES, RELATIONSHIP_TYPES, STRICT_APP_NAMESPACES, ZipLimitError, allocateCustomPropertyIds, buildContentTypesXml, buildRelationshipsXml, clonePartGraph, contentTypeForPart, customPropertyFromText, declaredEntrySize, ensureContentTypeDefault, ensureContentTypeOverride, ensureRelationship, findOfficeDocumentPart, formatW3cdtf, fromTitleGroups, getRelationshipId, guardZip, hyperlinkPolicy, inflateEntryGuarded, isOpenableHyperlinkHref, isSafeHyperlinkHref, isSafePartName, isStorableHyperlinkHref, listEmbeddedPackages, nextRelationshipId, openZip, parseAppProperties, parseContentTypes, parseCoreProperties, parseCustomProperties, parseCustomPropertyTexts, parseRelationships, relationshipsPartFor, relativePartTarget, removeContentTypeOverride, replaceEmbeddedPackage, replaceTitleGroup, resolvePartPath, signature_exports as signature, streamEntryGuarded, titleGroups, writeAppProperties, writeCoreProperties, writeCustomProperties };
|
package/dist/opc/zip-limits.d.ts
CHANGED
|
@@ -50,6 +50,12 @@ export declare function declaredEntrySize(entry: JSZip.JSZipObject): number;
|
|
|
50
50
|
* size or the running total passes the limit, before the rest of the entry is inflated.
|
|
51
51
|
*/
|
|
52
52
|
export declare function inflateEntryGuarded(entry: JSZip.JSZipObject, alreadyRead: number, limits: ZipLimits): Promise<Uint8Array>;
|
|
53
|
+
/**
|
|
54
|
+
* The inflated chunks of one entry as they are produced, with the checks of
|
|
55
|
+
* {@link inflateEntryGuarded}: a violation throws from the iteration before more is inflated.
|
|
56
|
+
* Inflating pauses while the reader is behind, and stops when the reader stops early.
|
|
57
|
+
*/
|
|
58
|
+
export declare function streamEntryGuarded(entry: JSZip.JSZipObject, alreadyRead: number, limits: ZipLimits): AsyncGenerator<Uint8Array, void, undefined>;
|
|
53
59
|
/**
|
|
54
60
|
* Validates a loaded zip (entry count, part names, declared sizes) and replaces every entry's
|
|
55
61
|
* `async` so each read inflates through the streaming guard with per-entry and running-total
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zip-limits.d.ts","sourceRoot":"","sources":["../../opc/zip-limits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,0DAA0D;AAC1D,eAAO,MAAM,kBAAkB;aAC9B,aAAa;aACb,UAAU,EAAE,KAAM;aAClB,aAAa;aACb,aAAa;CACJ,CAAC;AAEX;;;GAGG;AACH,MAAM,MAAM,YAAY,GACrB,eAAe,GACf,YAAY,GACZ,eAAe,GACf,eAAe,GACf,cAAc,GACd,UAAU,CAAC;AAEd,+EAA+E;AAC/E,MAAM,WAAW,SAAS;IACzB,mDAAmD;IACnD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qCAAqC;IACrC,U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