@xlsxflow/core 1.1.6 → 1.1.7
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/CHANGELOG.md +10 -0
- package/README.md +12 -4
- package/dist/index.cjs +11 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +11 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/dist/index.mjs
CHANGED
|
@@ -11,6 +11,15 @@ const CRC_TABLE = (() => {
|
|
|
11
11
|
function crc32(bytes) {
|
|
12
12
|
return (crc32Update(0xffffffff, bytes) ^ 0xffffffff) >>> 0;
|
|
13
13
|
}
|
|
14
|
+
// Older runtimes lack CompressionStream or its 'deflate-raw' format; say what is needed instead of a bare ReferenceError
|
|
15
|
+
function deflateRaw(kind) {
|
|
16
|
+
try {
|
|
17
|
+
return (kind === 'compress' ? new CompressionStream('deflate-raw') : new DecompressionStream('deflate-raw'));
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
throw new Error(`XlsxFlow needs ${kind === 'compress' ? 'CompressionStream' : 'DecompressionStream'} with 'deflate-raw': Chrome 103+, Firefox 113+, Safari 16.4+, Node 20.12+, Deno, Bun or Cloudflare Workers`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
14
23
|
// Running CRC-32 over chunks: start at 0xffffffff, finish with (crc ^ 0xffffffff) >>> 0
|
|
15
24
|
function crc32Update(crc, bytes) {
|
|
16
25
|
for (let i = 0; i < bytes.length; i++)
|
|
@@ -56,7 +65,7 @@ class ZipStreamWriter {
|
|
|
56
65
|
// Stream data, tracking sizes and CRC32
|
|
57
66
|
let uncompressedSize = 0;
|
|
58
67
|
let crc = 0xffffffff;
|
|
59
|
-
const compressor =
|
|
68
|
+
const compressor = deflateRaw('compress');
|
|
60
69
|
const writer = compressor.writable.getWriter();
|
|
61
70
|
const reader = compressor.readable.getReader();
|
|
62
71
|
const input = inputStream.getReader();
|
|
@@ -503,7 +512,7 @@ class ZipRandomAccessParser {
|
|
|
503
512
|
}
|
|
504
513
|
const stream = await this.extractRawStream(filename);
|
|
505
514
|
const data = record.compressionMethod === 0 ? stream
|
|
506
|
-
: stream.pipeThrough(
|
|
515
|
+
: stream.pipeThrough(deflateRaw('decompress'));
|
|
507
516
|
// Node reports bad deflate data as a bare TypeError; name the entry instead
|
|
508
517
|
const inflated = data.getReader();
|
|
509
518
|
let total = 0;
|