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.
Files changed (103) hide show
  1. package/README.md +16 -0
  2. package/dist/{PptxHandler-AUK27AQD.mjs → PptxHandler-64BZOBWX.mjs} +3 -3
  3. package/dist/{PptxHandler-QBGEZDCO.cjs → PptxHandler-AILFLRH7.cjs} +3 -3
  4. package/dist/PptxHandler-PMLQGMFQ.mjs +4 -0
  5. package/dist/{PresentationBuilder-RX7D75GZ.mjs → PresentationBuilder-EJY2TYWL.mjs} +2 -2
  6. package/dist/{PresentationBuilder-MEETJGEA.mjs → PresentationBuilder-HBCCO2CF.mjs} +3 -3
  7. package/dist/{PresentationBuilder-CI45KEHL.cjs → PresentationBuilder-RBQP6A37.cjs} +5 -5
  8. package/dist/automation/index.cjs +273 -156
  9. package/dist/automation/index.mjs +273 -156
  10. package/dist/automation/xlsx-read.d.ts +2 -8
  11. package/dist/automation/xlsx-read.d.ts.map +1 -1
  12. package/dist/automation/xlsx.d.ts +2 -2
  13. package/dist/chart/index.cjs +89 -47
  14. package/dist/chart/index.mjs +89 -47
  15. package/dist/{chunk-6DHZZD5R.mjs → chunk-2XMK5SXU.mjs} +106 -48
  16. package/dist/{chunk-VGDHSED6.mjs → chunk-DHAZSMC7.mjs} +1 -1
  17. package/dist/{chunk-TX2QFS3J.mjs → chunk-FZBAMWCJ.mjs} +788 -542
  18. package/dist/{chunk-E2PYQQQV.mjs → chunk-JJ37PCNR.mjs} +89 -47
  19. package/dist/{chunk-S5TGOEQX.cjs → chunk-MU3XSASV.cjs} +106 -47
  20. package/dist/{chunk-GMETZZ3V.cjs → chunk-NXTHB2M3.cjs} +1857 -1611
  21. package/dist/{chunk-HVRFRYYS.mjs → chunk-OQPT5IC3.mjs} +5 -5
  22. package/dist/{chunk-5F7OB7PA.mjs → chunk-OTXJVFMY.mjs} +785 -539
  23. package/dist/{chunk-635WPRNJ.mjs → chunk-R7RL7W43.mjs} +19 -3
  24. package/dist/{chunk-E3PRAHL6.mjs → chunk-WRFMS5CL.mjs} +1 -1
  25. package/dist/docx/embedded.cjs +89 -47
  26. package/dist/docx/embedded.mjs +89 -47
  27. package/dist/docx/index.cjs +89 -47
  28. package/dist/docx/index.mjs +89 -47
  29. package/dist/docx/load/index.cjs +89 -47
  30. package/dist/docx/load/index.mjs +89 -47
  31. package/dist/index.cjs +128 -53
  32. package/dist/index.mjs +128 -53
  33. package/dist/opc/index.cjs +90 -47
  34. package/dist/opc/index.mjs +90 -48
  35. package/dist/opc/zip-limits.d.ts +6 -0
  36. package/dist/opc/zip-limits.d.ts.map +1 -1
  37. package/dist/pptx/automation/index.cjs +954 -622
  38. package/dist/pptx/automation/index.d.ts +4 -4
  39. package/dist/pptx/automation/index.mjs +6 -6
  40. package/dist/pptx/chunks/{index-DCbp5fOs.d.ts → index-CbFowkp4.d.ts} +12 -5
  41. package/dist/pptx/chunks/{index-DCbp5fOs.d.ts.map → index-CbFowkp4.d.ts.map} +1 -1
  42. package/dist/pptx/chunks/{index-CX0RM1fF.d.ts → index-D4FnOx6x.d.ts} +3 -3
  43. package/dist/pptx/chunks/{index-CX0RM1fF.d.ts.map → index-D4FnOx6x.d.ts.map} +1 -1
  44. package/dist/pptx/chunks/{index-CgjEEpfK.d.ts → index-D8DNpc1X.d.ts} +289 -118
  45. package/dist/pptx/chunks/index-D8DNpc1X.d.ts.map +1 -0
  46. package/dist/pptx/chunks/{text-operations-CjalmJIi.d.ts → text-operations-CNfUj45U.d.ts} +16 -2
  47. package/dist/pptx/chunks/{text-operations-CjalmJIi.d.ts.map → text-operations-CNfUj45U.d.ts.map} +1 -1
  48. package/dist/pptx/cli/index.cjs +954 -622
  49. package/dist/pptx/cli/index.d.ts +1 -1
  50. package/dist/pptx/cli/index.mjs +5 -5
  51. package/dist/pptx/converter/index.d.ts +1 -1
  52. package/dist/pptx/converter/index.mjs +3 -3
  53. package/dist/pptx/editor/render/editor-history.cjs +21 -0
  54. package/dist/pptx/editor/render/editor-history.d.ts +9 -0
  55. package/dist/pptx/editor/render/editor-history.d.ts.map +1 -1
  56. package/dist/pptx/editor/render/editor-history.mjs +21 -0
  57. package/dist/pptx/editor/render/find-replace.cjs +14 -14
  58. package/dist/pptx/editor/render/find-replace.d.ts +2 -2
  59. package/dist/pptx/editor/render/find-replace.mjs +1 -1
  60. package/dist/pptx/editor/render/slide-operations.cjs +8 -8
  61. package/dist/pptx/editor/render/slide-operations.mjs +2 -2
  62. package/dist/pptx/index.cjs +953 -620
  63. package/dist/pptx/index.d.ts +5 -5
  64. package/dist/pptx/index.mjs +6 -6
  65. package/dist/pptx/node/index.d.ts +1 -1
  66. package/dist/pptx/signature-node/index.cjs +89 -47
  67. package/dist/pptx/signature-node/index.mjs +2 -2
  68. package/dist/visio/index.cjs +266 -150
  69. package/dist/visio/index.mjs +266 -150
  70. package/dist/visio/ui/index.cjs +266 -150
  71. package/dist/visio/ui/index.mjs +266 -150
  72. package/dist/xlsx/index.cjs +518 -153
  73. package/dist/xlsx/index.mjs +518 -154
  74. package/dist/xlsx/load/index.cjs +266 -150
  75. package/dist/xlsx/load/index.mjs +266 -150
  76. package/dist/xlsx/numfmt/view.d.ts +13 -0
  77. package/dist/xlsx/numfmt/view.d.ts.map +1 -0
  78. package/dist/xlsx/read/index.d.ts +1 -0
  79. package/dist/xlsx/read/index.d.ts.map +1 -1
  80. package/dist/xlsx/read/limits.d.ts +5 -0
  81. package/dist/xlsx/read/limits.d.ts.map +1 -1
  82. package/dist/xlsx/read/package.d.ts +6 -0
  83. package/dist/xlsx/read/package.d.ts.map +1 -1
  84. package/dist/xlsx/read/rows-stream.d.ts +12 -0
  85. package/dist/xlsx/read/rows-stream.d.ts.map +1 -0
  86. package/dist/xlsx/read/rows.d.ts +37 -0
  87. package/dist/xlsx/read/rows.d.ts.map +1 -0
  88. package/dist/xlsx/read/shared-strings.d.ts +6 -1
  89. package/dist/xlsx/read/shared-strings.d.ts.map +1 -1
  90. package/dist/xlsx/read/sheet-data-source.d.ts +30 -3
  91. package/dist/xlsx/read/sheet-data-source.d.ts.map +1 -1
  92. package/dist/xlsx/read/sheet-data.d.ts +13 -2
  93. package/dist/xlsx/read/sheet-data.d.ts.map +1 -1
  94. package/dist/xlsx/read/worksheet.d.ts.map +1 -1
  95. package/dist/xlsx/ui/index.cjs +266 -150
  96. package/dist/xlsx/ui/index.mjs +266 -150
  97. package/dist/xml/index.cjs +38 -6
  98. package/dist/xml/index.mjs +37 -7
  99. package/dist/xml/lite.d.ts +15 -0
  100. package/dist/xml/lite.d.ts.map +1 -1
  101. package/package.json +1 -1
  102. package/dist/PptxHandler-5UO5DD5K.mjs +0 -4
  103. package/dist/pptx/chunks/index-CgjEEpfK.d.ts.map +0 -1
@@ -250,57 +250,99 @@ function resolveLimits(limits) {
250
250
  fail: (message, limit, kind) => create ? create(message, { limit, kind }) : new ZipLimitError(message, { limit, kind })
251
251
  };
252
252
  }
253
- function inflateEntryGuarded(entry, alreadyRead, limits) {
253
+ async function inflateEntryGuarded(entry, alreadyRead, limits) {
254
+ const chunks = [];
255
+ let size = 0;
256
+ for await (const chunk of streamEntryGuarded(entry, alreadyRead, limits)) {
257
+ chunks.push(chunk);
258
+ size += chunk.byteLength;
259
+ }
260
+ if (chunks.length === 1 && chunks[0]) return chunks[0];
261
+ const out = new Uint8Array(size);
262
+ let offset = 0;
263
+ for (const chunk of chunks) {
264
+ out.set(chunk, offset);
265
+ offset += chunk.byteLength;
266
+ }
267
+ return out;
268
+ }
269
+ var AHEAD = 8;
270
+ async function* streamEntryGuarded(entry, alreadyRead, limits) {
254
271
  const r = resolveLimits(limits);
255
272
  const declared = declaredEntrySize(entry);
256
- return new Promise((resolvePromise, reject) => {
257
- const chunks = [];
258
- let size = 0;
259
- let done = false;
260
- const stream = entry.internalStream("uint8array");
261
- const abort = (error) => {
262
- if (done) return;
263
- done = true;
264
- stream.pause();
265
- chunks.length = 0;
266
- reject(error);
267
- };
268
- stream.on("data", (chunk) => {
269
- if (done) return;
270
- size += chunk.byteLength;
271
- if (size > declared || size > r.maxEntryBytes)
272
- return abort(
273
- r.fail(
274
- `${r.label} part ${entry.name} inflates past its declared size`,
275
- r.maxEntryBytes,
276
- size > declared ? "declaredSize" : "maxEntryBytes"
277
- )
278
- );
279
- if (alreadyRead + size > r.maxTotalBytes)
280
- return abort(
281
- r.fail(
282
- `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
283
- r.maxTotalBytes,
284
- "maxTotalBytes"
285
- )
286
- );
287
- chunks.push(chunk);
288
- });
289
- stream.on("error", (error) => abort(error));
290
- stream.on("end", () => {
291
- if (done) return;
292
- done = true;
293
- if (chunks.length === 1 && chunks[0]) return resolvePromise(chunks[0]);
294
- const out = new Uint8Array(size);
295
- let offset = 0;
296
- for (const chunk of chunks) {
297
- out.set(chunk, offset);
298
- offset += chunk.byteLength;
299
- }
300
- resolvePromise(out);
301
- });
273
+ const stream = entry.internalStream("uint8array");
274
+ const queue = [];
275
+ let size = 0;
276
+ let ended = false;
277
+ let stopped = false;
278
+ let failure;
279
+ let paused = false;
280
+ let wake;
281
+ const pause = () => {
282
+ paused = true;
283
+ stream.pause();
284
+ };
285
+ const resume = () => {
286
+ if (!paused || stopped) return;
287
+ paused = false;
302
288
  stream.resume();
289
+ };
290
+ const fail = (error) => {
291
+ failure ??= error;
292
+ stopped = true;
293
+ queue.length = 0;
294
+ pause();
295
+ wake?.();
296
+ };
297
+ stream.on("data", (chunk) => {
298
+ if (stopped) return pause();
299
+ size += chunk.byteLength;
300
+ if (size > declared || size > r.maxEntryBytes)
301
+ return fail(
302
+ r.fail(
303
+ `${r.label} part ${entry.name} inflates past its declared size`,
304
+ r.maxEntryBytes,
305
+ size > declared ? "declaredSize" : "maxEntryBytes"
306
+ )
307
+ );
308
+ if (alreadyRead + size > r.maxTotalBytes)
309
+ return fail(
310
+ r.fail(
311
+ `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
312
+ r.maxTotalBytes,
313
+ "maxTotalBytes"
314
+ )
315
+ );
316
+ queue.push(chunk);
317
+ if (queue.length >= AHEAD) pause();
318
+ wake?.();
319
+ });
320
+ stream.on("error", (error) => fail(error));
321
+ stream.on("end", () => {
322
+ ended = true;
323
+ wake?.();
303
324
  });
325
+ stream.resume();
326
+ try {
327
+ for (; ; ) {
328
+ if (failure) throw failure;
329
+ const chunk = queue.shift();
330
+ if (chunk) {
331
+ if (queue.length < AHEAD / 2) resume();
332
+ yield chunk;
333
+ continue;
334
+ }
335
+ if (ended) return;
336
+ await new Promise((resolve) => {
337
+ wake = resolve;
338
+ resume();
339
+ });
340
+ wake = void 0;
341
+ }
342
+ } finally {
343
+ stopped = true;
344
+ if (!ended) pause();
345
+ }
304
346
  }
305
347
  function toBase64(bytes) {
306
348
  let binary = "";
@@ -2880,57 +2880,99 @@ function resolveLimits(limits) {
2880
2880
  fail: (message, limit, kind) => create ? create(message, { limit, kind }) : new ZipLimitError(message, { limit, kind })
2881
2881
  };
2882
2882
  }
2883
- function inflateEntryGuarded(entry, alreadyRead, limits) {
2883
+ async function inflateEntryGuarded(entry, alreadyRead, limits) {
2884
+ const chunks = [];
2885
+ let size = 0;
2886
+ for await (const chunk2 of streamEntryGuarded(entry, alreadyRead, limits)) {
2887
+ chunks.push(chunk2);
2888
+ size += chunk2.byteLength;
2889
+ }
2890
+ if (chunks.length === 1 && chunks[0]) return chunks[0];
2891
+ const out = new Uint8Array(size);
2892
+ let offset = 0;
2893
+ for (const chunk2 of chunks) {
2894
+ out.set(chunk2, offset);
2895
+ offset += chunk2.byteLength;
2896
+ }
2897
+ return out;
2898
+ }
2899
+ var AHEAD = 8;
2900
+ async function* streamEntryGuarded(entry, alreadyRead, limits) {
2884
2901
  const r = resolveLimits(limits);
2885
2902
  const declared = declaredEntrySize(entry);
2886
- return new Promise((resolvePromise, reject) => {
2887
- const chunks = [];
2888
- let size = 0;
2889
- let done = false;
2890
- const stream = entry.internalStream("uint8array");
2891
- const abort = (error) => {
2892
- if (done) return;
2893
- done = true;
2894
- stream.pause();
2895
- chunks.length = 0;
2896
- reject(error);
2897
- };
2898
- stream.on("data", (chunk2) => {
2899
- if (done) return;
2900
- size += chunk2.byteLength;
2901
- if (size > declared || size > r.maxEntryBytes)
2902
- return abort(
2903
- r.fail(
2904
- `${r.label} part ${entry.name} inflates past its declared size`,
2905
- r.maxEntryBytes,
2906
- size > declared ? "declaredSize" : "maxEntryBytes"
2907
- )
2908
- );
2909
- if (alreadyRead + size > r.maxTotalBytes)
2910
- return abort(
2911
- r.fail(
2912
- `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
2913
- r.maxTotalBytes,
2914
- "maxTotalBytes"
2915
- )
2916
- );
2917
- chunks.push(chunk2);
2918
- });
2919
- stream.on("error", (error) => abort(error));
2920
- stream.on("end", () => {
2921
- if (done) return;
2922
- done = true;
2923
- if (chunks.length === 1 && chunks[0]) return resolvePromise(chunks[0]);
2924
- const out = new Uint8Array(size);
2925
- let offset = 0;
2926
- for (const chunk2 of chunks) {
2927
- out.set(chunk2, offset);
2928
- offset += chunk2.byteLength;
2929
- }
2930
- resolvePromise(out);
2931
- });
2903
+ const stream = entry.internalStream("uint8array");
2904
+ const queue = [];
2905
+ let size = 0;
2906
+ let ended = false;
2907
+ let stopped = false;
2908
+ let failure;
2909
+ let paused = false;
2910
+ let wake;
2911
+ const pause = () => {
2912
+ paused = true;
2913
+ stream.pause();
2914
+ };
2915
+ const resume = () => {
2916
+ if (!paused || stopped) return;
2917
+ paused = false;
2932
2918
  stream.resume();
2919
+ };
2920
+ const fail = (error) => {
2921
+ failure ??= error;
2922
+ stopped = true;
2923
+ queue.length = 0;
2924
+ pause();
2925
+ wake?.();
2926
+ };
2927
+ stream.on("data", (chunk2) => {
2928
+ if (stopped) return pause();
2929
+ size += chunk2.byteLength;
2930
+ if (size > declared || size > r.maxEntryBytes)
2931
+ return fail(
2932
+ r.fail(
2933
+ `${r.label} part ${entry.name} inflates past its declared size`,
2934
+ r.maxEntryBytes,
2935
+ size > declared ? "declaredSize" : "maxEntryBytes"
2936
+ )
2937
+ );
2938
+ if (alreadyRead + size > r.maxTotalBytes)
2939
+ return fail(
2940
+ r.fail(
2941
+ `${r.label} package exceeds the ${mib(r.maxTotalBytes)} MiB uncompressed content limit`,
2942
+ r.maxTotalBytes,
2943
+ "maxTotalBytes"
2944
+ )
2945
+ );
2946
+ queue.push(chunk2);
2947
+ if (queue.length >= AHEAD) pause();
2948
+ wake?.();
2949
+ });
2950
+ stream.on("error", (error) => fail(error));
2951
+ stream.on("end", () => {
2952
+ ended = true;
2953
+ wake?.();
2933
2954
  });
2955
+ stream.resume();
2956
+ try {
2957
+ for (; ; ) {
2958
+ if (failure) throw failure;
2959
+ const chunk2 = queue.shift();
2960
+ if (chunk2) {
2961
+ if (queue.length < AHEAD / 2) resume();
2962
+ yield chunk2;
2963
+ continue;
2964
+ }
2965
+ if (ended) return;
2966
+ await new Promise((resolve) => {
2967
+ wake = resolve;
2968
+ resume();
2969
+ });
2970
+ wake = void 0;
2971
+ }
2972
+ } finally {
2973
+ stopped = true;
2974
+ if (!ended) pause();
2975
+ }
2934
2976
  }
2935
2977
  function toBase64(bytes) {
2936
2978
  let binary = "";
@@ -39134,6 +39176,22 @@ var THEME_EFFECT_SCHEMES = THEME_EFFECT_SCHEME_SOURCES.map(([id, name, fmtScheme
39134
39176
  function findThemeEffectScheme(id) {
39135
39177
  return THEME_EFFECT_SCHEMES.find((scheme) => scheme.id === id);
39136
39178
  }
39179
+ function formatSchemeKey(scheme) {
39180
+ const raw = (styles) => (styles ?? []).map((style) => style.rawNode ?? null);
39181
+ const lists = [scheme.fillStyles, scheme.lineStyles, scheme.effectStyles];
39182
+ return JSON.stringify(
39183
+ [scheme.name ?? null, ...lists.map(raw), raw(scheme.backgroundFillStyles)],
39184
+ (_key, value) => {
39185
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
39186
+ return value;
39187
+ }
39188
+ const entries = Object.entries(value);
39189
+ const isAttribute = ([key]) => key.startsWith("@_");
39190
+ const attributes2 = entries.filter(isAttribute).sort(([x], [y]) => x < y ? -1 : 1);
39191
+ return Object.fromEntries([...attributes2, ...entries.filter((entry) => !isAttribute(entry))]);
39192
+ }
39193
+ );
39194
+ }
39137
39195
  function wrapFormatSchemeXml(fmtSchemeXml) {
39138
39196
  return fmtSchemeXml.replace(
39139
39197
  /^<a:fmtScheme/u,
@@ -44863,6 +44921,7 @@ exports.first = first;
44863
44921
  exports.firstParagraphRuns = firstParagraphRuns;
44864
44922
  exports.flattenCellTxBodyText = flattenCellTxBodyText;
44865
44923
  exports.formatAutoNumberMarker = formatAutoNumberMarker;
44924
+ exports.formatSchemeKey = formatSchemeKey;
44866
44925
  exports.generateFontGuid = generateFontGuid;
44867
44926
  exports.getSignaturePathsToStrip = getSignaturePathsToStrip;
44868
44927
  exports.getTblFromRawXml = getTblFromRawXml;