@cj-tech-master/excelts 4.2.1-canary.20260111102127.f808a37 → 4.2.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/THIRD_PARTY_NOTICES.md +31 -0
- package/dist/browser/index.browser.d.ts +0 -1
- package/dist/browser/index.browser.js +0 -12
- package/dist/browser/modules/archive/byte-queue.d.ts +18 -0
- package/dist/browser/modules/archive/byte-queue.js +125 -0
- package/dist/browser/modules/archive/{compression/compress.base.js → compress.base.js} +1 -1
- package/dist/browser/modules/archive/{compression/compress.browser.d.ts → compress.browser.d.ts} +8 -2
- package/dist/{esm/modules/archive/compression → browser/modules/archive}/compress.browser.js +11 -3
- package/dist/browser/modules/archive/{compression/compress.d.ts → compress.d.ts} +2 -2
- package/dist/{esm/modules/archive/compression → browser/modules/archive}/compress.js +1 -1
- package/dist/browser/modules/archive/{compression/crc32.browser.d.ts → crc32.browser.d.ts} +1 -1
- package/dist/browser/modules/archive/{compression/crc32.d.ts → crc32.d.ts} +1 -1
- package/dist/browser/modules/archive/{compression/crc32.js → crc32.js} +1 -1
- package/dist/browser/modules/archive/defaults.d.ts +0 -1
- package/dist/browser/modules/archive/defaults.js +3 -6
- package/dist/browser/modules/archive/{compression/deflate-fallback.js → deflate-fallback.js} +1 -1
- package/dist/browser/modules/archive/{unzip/extract.d.ts → extract.d.ts} +2 -2
- package/dist/browser/modules/archive/index.base.d.ts +4 -4
- package/dist/browser/modules/archive/index.base.js +6 -3
- package/dist/browser/modules/archive/index.browser.d.ts +4 -3
- package/dist/browser/modules/archive/index.browser.js +7 -3
- package/dist/browser/modules/archive/index.d.ts +4 -3
- package/dist/browser/modules/archive/index.js +5 -3
- package/dist/browser/modules/archive/{unzip/stream.base.d.ts → parse.base.d.ts} +2 -36
- package/dist/browser/modules/archive/parse.base.js +644 -0
- package/dist/browser/modules/archive/{unzip/stream.browser.d.ts → parse.browser.d.ts} +1 -1
- package/dist/{esm/modules/archive/unzip/stream.browser.js → browser/modules/archive/parse.browser.js} +110 -371
- package/dist/browser/modules/archive/{unzip/stream.d.ts → parse.d.ts} +2 -2
- package/dist/{esm/modules/archive/unzip/stream.js → browser/modules/archive/parse.js} +5 -6
- package/dist/browser/modules/archive/{compression/streaming-compress.browser.d.ts → streaming-compress.browser.d.ts} +2 -2
- package/dist/browser/modules/archive/{compression/streaming-compress.browser.js → streaming-compress.browser.js} +3 -3
- package/dist/browser/modules/archive/{compression/streaming-compress.d.ts → streaming-compress.d.ts} +2 -2
- package/dist/browser/modules/archive/{compression/streaming-compress.js → streaming-compress.js} +2 -2
- package/dist/browser/modules/archive/{zip/stream.d.ts → streaming-zip.d.ts} +5 -28
- package/dist/{esm/modules/archive/zip/stream.js → browser/modules/archive/streaming-zip.js} +48 -192
- package/dist/browser/modules/archive/utils/bytes.js +16 -16
- package/dist/browser/modules/archive/utils/parse-buffer.js +23 -21
- package/dist/browser/modules/archive/utils/timestamps.js +1 -62
- package/dist/browser/modules/archive/utils/zip-extra-fields.d.ts +1 -1
- package/dist/browser/modules/archive/utils/zip-extra-fields.js +14 -26
- package/dist/browser/modules/archive/utils/zip-extra.d.ts +18 -0
- package/dist/browser/modules/archive/utils/zip-extra.js +68 -0
- package/dist/browser/modules/archive/zip-builder.d.ts +117 -0
- package/dist/browser/modules/archive/zip-builder.js +292 -0
- package/dist/browser/modules/archive/zip-constants.d.ts +18 -0
- package/dist/browser/modules/archive/zip-constants.js +23 -0
- package/dist/{esm/modules/archive/zip → browser/modules/archive}/zip-entry-metadata.js +3 -3
- package/dist/{types/modules/archive/unzip → browser/modules/archive}/zip-parser.d.ts +1 -1
- package/dist/{esm/modules/archive/unzip → browser/modules/archive}/zip-parser.js +24 -38
- package/dist/browser/modules/archive/{zip-spec/zip-records.d.ts → zip-records.d.ts} +0 -20
- package/dist/browser/modules/archive/zip-records.js +84 -0
- package/dist/browser/modules/excel/stream/workbook-reader.browser.js +1 -1
- package/dist/browser/modules/excel/stream/workbook-writer.browser.d.ts +1 -1
- package/dist/browser/modules/excel/stream/workbook-writer.browser.js +1 -1
- package/dist/browser/modules/excel/xlsx/xlsx.browser.js +6 -3
- package/dist/browser/modules/excel/xlsx/xlsx.js +1 -1
- package/dist/browser/modules/stream/streams.browser.d.ts +30 -28
- package/dist/browser/modules/stream/streams.browser.js +710 -830
- package/dist/browser/modules/stream/streams.js +58 -140
- package/dist/cjs/modules/archive/byte-queue.js +129 -0
- package/dist/cjs/modules/archive/{compression/compress.base.js → compress.base.js} +1 -1
- package/dist/cjs/modules/archive/{compression/compress.browser.js → compress.browser.js} +11 -3
- package/dist/cjs/modules/archive/{compression/compress.js → compress.js} +1 -1
- package/dist/cjs/modules/archive/{compression/crc32.js → crc32.js} +1 -1
- package/dist/cjs/modules/archive/defaults.js +4 -7
- package/dist/cjs/modules/archive/{compression/deflate-fallback.js → deflate-fallback.js} +1 -1
- package/dist/cjs/modules/archive/index.base.js +19 -9
- package/dist/cjs/modules/archive/index.browser.js +10 -4
- package/dist/cjs/modules/archive/index.js +8 -4
- package/dist/cjs/modules/archive/parse.base.js +666 -0
- package/dist/cjs/modules/archive/{unzip/stream.browser.js → parse.browser.js} +111 -372
- package/dist/cjs/modules/archive/{unzip/stream.js → parse.js} +8 -9
- package/dist/cjs/modules/archive/{compression/streaming-compress.browser.js → streaming-compress.browser.js} +3 -3
- package/dist/cjs/modules/archive/{compression/streaming-compress.js → streaming-compress.js} +2 -2
- package/dist/cjs/modules/archive/{zip/stream.js → streaming-zip.js} +50 -194
- package/dist/cjs/modules/archive/utils/bytes.js +16 -16
- package/dist/cjs/modules/archive/utils/parse-buffer.js +23 -21
- package/dist/cjs/modules/archive/utils/timestamps.js +3 -64
- package/dist/cjs/modules/archive/utils/zip-extra-fields.js +14 -26
- package/dist/cjs/modules/archive/utils/zip-extra.js +74 -0
- package/dist/cjs/modules/archive/zip-builder.js +297 -0
- package/dist/cjs/modules/archive/zip-constants.js +26 -0
- package/dist/cjs/modules/archive/{zip/zip-entry-metadata.js → zip-entry-metadata.js} +5 -5
- package/dist/cjs/modules/archive/{unzip/zip-parser.js → zip-parser.js} +33 -47
- package/dist/cjs/modules/archive/zip-records.js +90 -0
- package/dist/cjs/modules/excel/stream/workbook-reader.browser.js +2 -2
- package/dist/cjs/modules/excel/stream/workbook-writer.browser.js +4 -4
- package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +9 -6
- package/dist/cjs/modules/excel/xlsx/xlsx.js +2 -2
- package/dist/cjs/modules/stream/streams.browser.js +710 -830
- package/dist/cjs/modules/stream/streams.js +58 -140
- package/dist/esm/index.browser.js +0 -12
- package/dist/esm/modules/archive/byte-queue.js +125 -0
- package/dist/esm/modules/archive/{compression/compress.base.js → compress.base.js} +1 -1
- package/dist/{browser/modules/archive/compression → esm/modules/archive}/compress.browser.js +11 -3
- package/dist/{browser/modules/archive/compression → esm/modules/archive}/compress.js +1 -1
- package/dist/esm/modules/archive/{compression/crc32.js → crc32.js} +1 -1
- package/dist/esm/modules/archive/defaults.js +3 -6
- package/dist/esm/modules/archive/{compression/deflate-fallback.js → deflate-fallback.js} +1 -1
- package/dist/esm/modules/archive/index.base.js +6 -3
- package/dist/esm/modules/archive/index.browser.js +7 -3
- package/dist/esm/modules/archive/index.js +5 -3
- package/dist/esm/modules/archive/parse.base.js +644 -0
- package/dist/{browser/modules/archive/unzip/stream.browser.js → esm/modules/archive/parse.browser.js} +110 -371
- package/dist/{browser/modules/archive/unzip/stream.js → esm/modules/archive/parse.js} +5 -6
- package/dist/esm/modules/archive/{compression/streaming-compress.browser.js → streaming-compress.browser.js} +3 -3
- package/dist/esm/modules/archive/{compression/streaming-compress.js → streaming-compress.js} +2 -2
- package/dist/{browser/modules/archive/zip/stream.js → esm/modules/archive/streaming-zip.js} +48 -192
- package/dist/esm/modules/archive/utils/bytes.js +16 -16
- package/dist/esm/modules/archive/utils/parse-buffer.js +23 -21
- package/dist/esm/modules/archive/utils/timestamps.js +1 -62
- package/dist/esm/modules/archive/utils/zip-extra-fields.js +14 -26
- package/dist/esm/modules/archive/utils/zip-extra.js +68 -0
- package/dist/esm/modules/archive/zip-builder.js +292 -0
- package/dist/esm/modules/archive/zip-constants.js +23 -0
- package/dist/{browser/modules/archive/zip → esm/modules/archive}/zip-entry-metadata.js +3 -3
- package/dist/{browser/modules/archive/unzip → esm/modules/archive}/zip-parser.js +24 -38
- package/dist/esm/modules/archive/zip-records.js +84 -0
- package/dist/esm/modules/excel/stream/workbook-reader.browser.js +1 -1
- package/dist/esm/modules/excel/stream/workbook-writer.browser.js +1 -1
- package/dist/esm/modules/excel/xlsx/xlsx.browser.js +6 -3
- package/dist/esm/modules/excel/xlsx/xlsx.js +1 -1
- package/dist/esm/modules/stream/streams.browser.js +710 -830
- package/dist/esm/modules/stream/streams.js +58 -140
- package/dist/iife/THIRD_PARTY_NOTICES.md +31 -0
- package/dist/iife/excelts.iife.js +4425 -6215
- package/dist/iife/excelts.iife.js.map +1 -1
- package/dist/iife/excelts.iife.min.js +31 -103
- package/dist/types/index.browser.d.ts +0 -1
- package/dist/types/modules/archive/byte-queue.d.ts +18 -0
- package/dist/types/modules/archive/{compression/compress.browser.d.ts → compress.browser.d.ts} +8 -2
- package/dist/types/modules/archive/defaults.d.ts +0 -1
- package/dist/types/modules/archive/index.base.d.ts +4 -4
- package/dist/types/modules/archive/index.browser.d.ts +4 -3
- package/dist/types/modules/archive/index.d.ts +4 -3
- package/dist/types/modules/archive/{unzip/stream.base.d.ts → parse.base.d.ts} +4 -38
- package/dist/types/modules/archive/{unzip/stream.browser.d.ts → parse.browser.d.ts} +2 -2
- package/dist/types/modules/archive/{unzip/stream.d.ts → parse.d.ts} +3 -3
- package/dist/types/modules/archive/{compression/streaming-compress.browser.d.ts → streaming-compress.browser.d.ts} +1 -1
- package/dist/types/modules/archive/{zip/stream.d.ts → streaming-zip.d.ts} +6 -29
- package/dist/types/modules/archive/utils/zip-extra-fields.d.ts +1 -1
- package/dist/types/modules/archive/utils/zip-extra.d.ts +18 -0
- package/dist/types/modules/archive/zip-builder.d.ts +117 -0
- package/dist/types/modules/archive/zip-constants.d.ts +18 -0
- package/dist/types/modules/archive/{zip/zip-entry-metadata.d.ts → zip-entry-metadata.d.ts} +1 -1
- package/dist/{browser/modules/archive/unzip → types/modules/archive}/zip-parser.d.ts +1 -1
- package/dist/types/modules/archive/{zip-spec/zip-records.d.ts → zip-records.d.ts} +0 -20
- package/dist/types/modules/excel/stream/workbook-writer.browser.d.ts +1 -1
- package/dist/types/modules/stream/streams.browser.d.ts +30 -28
- package/package.json +1 -5
- package/dist/browser/modules/archive/internal/byte-queue.d.ts +0 -33
- package/dist/browser/modules/archive/internal/byte-queue.js +0 -407
- package/dist/browser/modules/archive/io/archive-sink.d.ts +0 -9
- package/dist/browser/modules/archive/io/archive-sink.js +0 -77
- package/dist/browser/modules/archive/io/archive-source.d.ts +0 -8
- package/dist/browser/modules/archive/io/archive-source.js +0 -107
- package/dist/browser/modules/archive/unzip/index.d.ts +0 -40
- package/dist/browser/modules/archive/unzip/index.js +0 -164
- package/dist/browser/modules/archive/unzip/stream.base.js +0 -1022
- package/dist/browser/modules/archive/utils/async-queue.d.ts +0 -7
- package/dist/browser/modules/archive/utils/async-queue.js +0 -103
- package/dist/browser/modules/archive/utils/compressibility.d.ts +0 -10
- package/dist/browser/modules/archive/utils/compressibility.js +0 -57
- package/dist/browser/modules/archive/utils/pattern-scanner.d.ts +0 -21
- package/dist/browser/modules/archive/utils/pattern-scanner.js +0 -27
- package/dist/browser/modules/archive/zip/index.d.ts +0 -42
- package/dist/browser/modules/archive/zip/index.js +0 -157
- package/dist/browser/modules/archive/zip/zip-bytes.d.ts +0 -73
- package/dist/browser/modules/archive/zip/zip-bytes.js +0 -239
- package/dist/browser/modules/archive/zip-spec/zip-records.js +0 -126
- package/dist/cjs/modules/archive/internal/byte-queue.js +0 -411
- package/dist/cjs/modules/archive/io/archive-sink.js +0 -82
- package/dist/cjs/modules/archive/io/archive-source.js +0 -114
- package/dist/cjs/modules/archive/unzip/index.js +0 -170
- package/dist/cjs/modules/archive/unzip/stream.base.js +0 -1044
- package/dist/cjs/modules/archive/utils/async-queue.js +0 -106
- package/dist/cjs/modules/archive/utils/compressibility.js +0 -60
- package/dist/cjs/modules/archive/utils/pattern-scanner.js +0 -31
- package/dist/cjs/modules/archive/zip/index.js +0 -162
- package/dist/cjs/modules/archive/zip/zip-bytes.js +0 -242
- package/dist/cjs/modules/archive/zip-spec/zip-records.js +0 -136
- package/dist/esm/modules/archive/internal/byte-queue.js +0 -407
- package/dist/esm/modules/archive/io/archive-sink.js +0 -77
- package/dist/esm/modules/archive/io/archive-source.js +0 -107
- package/dist/esm/modules/archive/unzip/index.js +0 -164
- package/dist/esm/modules/archive/unzip/stream.base.js +0 -1022
- package/dist/esm/modules/archive/utils/async-queue.js +0 -103
- package/dist/esm/modules/archive/utils/compressibility.js +0 -57
- package/dist/esm/modules/archive/utils/pattern-scanner.js +0 -27
- package/dist/esm/modules/archive/zip/index.js +0 -157
- package/dist/esm/modules/archive/zip/zip-bytes.js +0 -239
- package/dist/esm/modules/archive/zip-spec/zip-records.js +0 -126
- package/dist/types/modules/archive/internal/byte-queue.d.ts +0 -33
- package/dist/types/modules/archive/io/archive-sink.d.ts +0 -9
- package/dist/types/modules/archive/io/archive-source.d.ts +0 -8
- package/dist/types/modules/archive/unzip/index.d.ts +0 -40
- package/dist/types/modules/archive/utils/async-queue.d.ts +0 -7
- package/dist/types/modules/archive/utils/compressibility.d.ts +0 -10
- package/dist/types/modules/archive/utils/pattern-scanner.d.ts +0 -21
- package/dist/types/modules/archive/zip/index.d.ts +0 -42
- package/dist/types/modules/archive/zip/zip-bytes.d.ts +0 -73
- /package/dist/browser/modules/archive/{compression/compress.base.d.ts → compress.base.d.ts} +0 -0
- /package/dist/browser/modules/archive/{compression/crc32.base.d.ts → crc32.base.d.ts} +0 -0
- /package/dist/browser/modules/archive/{compression/crc32.base.js → crc32.base.js} +0 -0
- /package/dist/browser/modules/archive/{compression/crc32.browser.js → crc32.browser.js} +0 -0
- /package/dist/browser/modules/archive/{compression/deflate-fallback.d.ts → deflate-fallback.d.ts} +0 -0
- /package/dist/browser/modules/archive/{unzip/extract.js → extract.js} +0 -0
- /package/dist/browser/modules/archive/{compression/streaming-compress.base.d.ts → streaming-compress.base.d.ts} +0 -0
- /package/dist/browser/modules/archive/{compression/streaming-compress.base.js → streaming-compress.base.js} +0 -0
- /package/dist/browser/modules/archive/{zip-spec/zip-entry-info.d.ts → zip-entry-info.d.ts} +0 -0
- /package/dist/browser/modules/archive/{zip-spec/zip-entry-info.js → zip-entry-info.js} +0 -0
- /package/dist/browser/modules/archive/{zip/zip-entry-metadata.d.ts → zip-entry-metadata.d.ts} +0 -0
- /package/dist/cjs/modules/archive/{compression/crc32.base.js → crc32.base.js} +0 -0
- /package/dist/cjs/modules/archive/{compression/crc32.browser.js → crc32.browser.js} +0 -0
- /package/dist/cjs/modules/archive/{unzip/extract.js → extract.js} +0 -0
- /package/dist/cjs/modules/archive/{compression/streaming-compress.base.js → streaming-compress.base.js} +0 -0
- /package/dist/cjs/modules/archive/{zip-spec/zip-entry-info.js → zip-entry-info.js} +0 -0
- /package/dist/esm/modules/archive/{compression/crc32.base.js → crc32.base.js} +0 -0
- /package/dist/esm/modules/archive/{compression/crc32.browser.js → crc32.browser.js} +0 -0
- /package/dist/esm/modules/archive/{unzip/extract.js → extract.js} +0 -0
- /package/dist/esm/modules/archive/{compression/streaming-compress.base.js → streaming-compress.base.js} +0 -0
- /package/dist/esm/modules/archive/{zip-spec/zip-entry-info.js → zip-entry-info.js} +0 -0
- /package/dist/types/modules/archive/{compression/compress.base.d.ts → compress.base.d.ts} +0 -0
- /package/dist/types/modules/archive/{compression/compress.d.ts → compress.d.ts} +0 -0
- /package/dist/types/modules/archive/{compression/crc32.base.d.ts → crc32.base.d.ts} +0 -0
- /package/dist/types/modules/archive/{compression/crc32.browser.d.ts → crc32.browser.d.ts} +0 -0
- /package/dist/types/modules/archive/{compression/crc32.d.ts → crc32.d.ts} +0 -0
- /package/dist/types/modules/archive/{compression/deflate-fallback.d.ts → deflate-fallback.d.ts} +0 -0
- /package/dist/types/modules/archive/{unzip/extract.d.ts → extract.d.ts} +0 -0
- /package/dist/types/modules/archive/{compression/streaming-compress.base.d.ts → streaming-compress.base.d.ts} +0 -0
- /package/dist/types/modules/archive/{compression/streaming-compress.d.ts → streaming-compress.d.ts} +0 -0
- /package/dist/types/modules/archive/{zip-spec/zip-entry-info.d.ts → zip-entry-info.d.ts} +0 -0
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.ZipParser = void 0;
|
|
9
|
-
const compress_1 = require("
|
|
10
|
-
const binary_1 = require("
|
|
11
|
-
const timestamps_1 = require("
|
|
12
|
-
const zip_extra_fields_1 = require("
|
|
13
|
-
const
|
|
9
|
+
const compress_1 = require("./compress.js");
|
|
10
|
+
const binary_1 = require("./utils/binary.js");
|
|
11
|
+
const timestamps_1 = require("./utils/timestamps.js");
|
|
12
|
+
const zip_extra_fields_1 = require("./utils/zip-extra-fields.js");
|
|
13
|
+
const zip_constants_1 = require("./zip-constants.js");
|
|
14
14
|
/**
|
|
15
15
|
* Find the End of Central Directory record
|
|
16
16
|
* Searches backwards from the end of the file
|
|
@@ -19,13 +19,9 @@ function findEndOfCentralDir(data) {
|
|
|
19
19
|
// EOCD is at least 22 bytes, search backwards
|
|
20
20
|
// Comment can be up to 65535 bytes
|
|
21
21
|
const minOffset = Math.max(0, data.length - 65557);
|
|
22
|
-
|
|
23
|
-
const b0 = 0x50;
|
|
24
|
-
const b1 = 0x4b;
|
|
25
|
-
const b2 = 0x05;
|
|
26
|
-
const b3 = 0x06;
|
|
22
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
27
23
|
for (let i = data.length - 22; i >= minOffset; i--) {
|
|
28
|
-
if (
|
|
24
|
+
if (view.getUint32(i, true) === zip_constants_1.END_OF_CENTRAL_DIR_SIG) {
|
|
29
25
|
return i;
|
|
30
26
|
}
|
|
31
27
|
}
|
|
@@ -40,11 +36,8 @@ function findZip64EOCDLocator(data, eocdOffset) {
|
|
|
40
36
|
if (locatorOffset < 0) {
|
|
41
37
|
return -1;
|
|
42
38
|
}
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
-
data[locatorOffset + 1] === 0x4b &&
|
|
46
|
-
data[locatorOffset + 2] === 0x06 &&
|
|
47
|
-
data[locatorOffset + 3] === 0x07) {
|
|
39
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
40
|
+
if (view.getUint32(locatorOffset, true) === zip_constants_1.ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIG) {
|
|
48
41
|
return locatorOffset;
|
|
49
42
|
}
|
|
50
43
|
return -1;
|
|
@@ -54,7 +47,7 @@ function findZip64EOCDLocator(data, eocdOffset) {
|
|
|
54
47
|
*/
|
|
55
48
|
function parseZipEntries(data, options = {}) {
|
|
56
49
|
const { decodeStrings = true } = options;
|
|
57
|
-
|
|
50
|
+
const entries = [];
|
|
58
51
|
// Find End of Central Directory
|
|
59
52
|
const eocdOffset = findEndOfCentralDir(data);
|
|
60
53
|
if (eocdOffset === -1) {
|
|
@@ -88,7 +81,7 @@ function parseZipEntries(data, options = {}) {
|
|
|
88
81
|
// Read ZIP64 EOCD
|
|
89
82
|
const zip64Reader = new binary_1.BinaryReader(data, zip64EOCDOffset);
|
|
90
83
|
const zip64Sig = zip64Reader.readUint32();
|
|
91
|
-
if (zip64Sig ===
|
|
84
|
+
if (zip64Sig === zip_constants_1.ZIP64_END_OF_CENTRAL_DIR_SIG) {
|
|
92
85
|
zip64Reader.skip(8); // size of ZIP64 EOCD
|
|
93
86
|
zip64Reader.skip(2); // version made by
|
|
94
87
|
zip64Reader.skip(2); // version needed
|
|
@@ -98,23 +91,19 @@ function parseZipEntries(data, options = {}) {
|
|
|
98
91
|
zip64Reader.skip(8); // central directory size (unused)
|
|
99
92
|
const zip64CentralDirOffset = Number(zip64Reader.readBigUint64());
|
|
100
93
|
// Use ZIP64 values if standard values are maxed out
|
|
101
|
-
if (totalEntries ===
|
|
94
|
+
if (totalEntries === zip_constants_1.UINT16_MAX) {
|
|
102
95
|
totalEntries = zip64TotalEntries;
|
|
103
96
|
}
|
|
104
|
-
if (centralDirOffset ===
|
|
97
|
+
if (centralDirOffset === zip_constants_1.UINT32_MAX) {
|
|
105
98
|
centralDirOffset = zip64CentralDirOffset;
|
|
106
99
|
}
|
|
107
100
|
}
|
|
108
101
|
}
|
|
109
|
-
// Preallocate to avoid repeated array growth on large archives.
|
|
110
|
-
if (totalEntries > 0) {
|
|
111
|
-
entries = new Array(totalEntries);
|
|
112
|
-
}
|
|
113
102
|
// Read Central Directory entries
|
|
114
103
|
const centralReader = new binary_1.BinaryReader(data, centralDirOffset);
|
|
115
104
|
for (let i = 0; i < totalEntries; i++) {
|
|
116
105
|
const sig = centralReader.readUint32();
|
|
117
|
-
if (sig !==
|
|
106
|
+
if (sig !== zip_constants_1.CENTRAL_DIR_HEADER_SIG) {
|
|
118
107
|
throw new Error(`Invalid Central Directory header signature at entry ${i}`);
|
|
119
108
|
}
|
|
120
109
|
// Central Directory File Header format:
|
|
@@ -158,26 +147,23 @@ function parseZipEntries(data, options = {}) {
|
|
|
158
147
|
// Check for UTF-8 flag (bit 11)
|
|
159
148
|
const isUtf8 = (flags & 0x800) !== 0;
|
|
160
149
|
const useUtf8 = decodeStrings && isUtf8;
|
|
161
|
-
const fileName =
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
localHeaderOffset = vars.offsetToLocalFileHeader ?? localHeaderOffset;
|
|
174
|
-
}
|
|
175
|
-
const comment = commentLength > 0 ? centralReader.readString(commentLength, useUtf8) : "";
|
|
150
|
+
const fileName = centralReader.readString(fileNameLength, useUtf8);
|
|
151
|
+
const extraField = centralReader.readBytes(extraFieldLength);
|
|
152
|
+
const comment = centralReader.readString(commentLength, useUtf8);
|
|
153
|
+
const vars = {
|
|
154
|
+
compressedSize,
|
|
155
|
+
uncompressedSize,
|
|
156
|
+
offsetToLocalFileHeader: localHeaderOffset
|
|
157
|
+
};
|
|
158
|
+
const extraFields = extraFieldLength > 0 ? (0, zip_extra_fields_1.parseZipExtraFields)(extraField, vars) : {};
|
|
159
|
+
compressedSize = vars.compressedSize;
|
|
160
|
+
uncompressedSize = vars.uncompressedSize;
|
|
161
|
+
localHeaderOffset = vars.offsetToLocalFileHeader ?? localHeaderOffset;
|
|
176
162
|
const isDirectory = fileName.endsWith("/") || (externalAttributes & 0x10) !== 0;
|
|
177
163
|
const isEncrypted = (flags & 0x01) !== 0;
|
|
178
164
|
const unixSecondsMtime = extraFields.mtimeUnixSeconds;
|
|
179
165
|
const lastModified = (0, timestamps_1.resolveZipLastModifiedDateFromUnixSeconds)(lastModDate, lastModTime, unixSecondsMtime);
|
|
180
|
-
entries
|
|
166
|
+
entries.push({
|
|
181
167
|
path: fileName,
|
|
182
168
|
isDirectory,
|
|
183
169
|
compressedSize,
|
|
@@ -189,7 +175,7 @@ function parseZipEntries(data, options = {}) {
|
|
|
189
175
|
comment,
|
|
190
176
|
externalAttributes,
|
|
191
177
|
isEncrypted
|
|
192
|
-
};
|
|
178
|
+
});
|
|
193
179
|
}
|
|
194
180
|
return entries;
|
|
195
181
|
}
|
|
@@ -204,10 +190,10 @@ async function extractEntryData(data, entry) {
|
|
|
204
190
|
throw new Error(`File "${entry.path}" is encrypted and cannot be extracted`);
|
|
205
191
|
}
|
|
206
192
|
const compressedData = readEntryCompressedData(data, entry);
|
|
207
|
-
if (entry.compressionMethod ===
|
|
193
|
+
if (entry.compressionMethod === zip_constants_1.COMPRESSION_STORE) {
|
|
208
194
|
return compressedData;
|
|
209
195
|
}
|
|
210
|
-
if (entry.compressionMethod ===
|
|
196
|
+
if (entry.compressionMethod === zip_constants_1.COMPRESSION_DEFLATE) {
|
|
211
197
|
return (0, compress_1.decompress)(compressedData);
|
|
212
198
|
}
|
|
213
199
|
throw new Error(`Unsupported compression method: ${entry.compressionMethod}`);
|
|
@@ -223,10 +209,10 @@ function extractEntryDataSync(data, entry) {
|
|
|
223
209
|
throw new Error(`File "${entry.path}" is encrypted and cannot be extracted`);
|
|
224
210
|
}
|
|
225
211
|
const compressedData = readEntryCompressedData(data, entry);
|
|
226
|
-
if (entry.compressionMethod ===
|
|
212
|
+
if (entry.compressionMethod === zip_constants_1.COMPRESSION_STORE) {
|
|
227
213
|
return compressedData;
|
|
228
214
|
}
|
|
229
|
-
if (entry.compressionMethod ===
|
|
215
|
+
if (entry.compressionMethod === zip_constants_1.COMPRESSION_DEFLATE) {
|
|
230
216
|
return (0, compress_1.decompressSync)(compressedData);
|
|
231
217
|
}
|
|
232
218
|
throw new Error(`Unsupported compression method: ${entry.compressionMethod}`);
|
|
@@ -234,7 +220,7 @@ function extractEntryDataSync(data, entry) {
|
|
|
234
220
|
function readEntryCompressedData(data, entry) {
|
|
235
221
|
const reader = new binary_1.BinaryReader(data, entry.localHeaderOffset);
|
|
236
222
|
const sig = reader.readUint32();
|
|
237
|
-
if (sig !==
|
|
223
|
+
if (sig !== zip_constants_1.LOCAL_FILE_HEADER_SIG) {
|
|
238
224
|
throw new Error(`Invalid local file header signature for "${entry.path}"`);
|
|
239
225
|
}
|
|
240
226
|
reader.skip(2); // version needed
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ZIP record builders (PKWARE APPNOTE)
|
|
4
|
+
*
|
|
5
|
+
* Shared by streaming zip writer and buffer zip builder.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.buildLocalFileHeader = buildLocalFileHeader;
|
|
9
|
+
exports.buildCentralDirectoryHeader = buildCentralDirectoryHeader;
|
|
10
|
+
exports.buildEndOfCentralDirectory = buildEndOfCentralDirectory;
|
|
11
|
+
exports.buildDataDescriptor = buildDataDescriptor;
|
|
12
|
+
const zip_constants_1 = require("./zip-constants.js");
|
|
13
|
+
function buildLocalFileHeader(input) {
|
|
14
|
+
const versionNeeded = input.versionNeeded ?? zip_constants_1.VERSION_NEEDED;
|
|
15
|
+
const header = new Uint8Array(30 + input.fileName.length + input.extraField.length);
|
|
16
|
+
const view = new DataView(header.buffer);
|
|
17
|
+
view.setUint32(0, zip_constants_1.LOCAL_FILE_HEADER_SIG, true);
|
|
18
|
+
view.setUint16(4, versionNeeded, true);
|
|
19
|
+
view.setUint16(6, input.flags, true);
|
|
20
|
+
view.setUint16(8, input.compressionMethod, true);
|
|
21
|
+
view.setUint16(10, input.dosTime, true);
|
|
22
|
+
view.setUint16(12, input.dosDate, true);
|
|
23
|
+
view.setUint32(14, input.crc32, true);
|
|
24
|
+
view.setUint32(18, input.compressedSize, true);
|
|
25
|
+
view.setUint32(22, input.uncompressedSize, true);
|
|
26
|
+
view.setUint16(26, input.fileName.length, true);
|
|
27
|
+
view.setUint16(28, input.extraField.length, true);
|
|
28
|
+
header.set(input.fileName, 30);
|
|
29
|
+
if (input.extraField.length > 0) {
|
|
30
|
+
header.set(input.extraField, 30 + input.fileName.length);
|
|
31
|
+
}
|
|
32
|
+
return header;
|
|
33
|
+
}
|
|
34
|
+
function buildCentralDirectoryHeader(input) {
|
|
35
|
+
const versionMadeBy = input.versionMadeBy ?? zip_constants_1.VERSION_MADE_BY;
|
|
36
|
+
const versionNeeded = input.versionNeeded ?? zip_constants_1.VERSION_NEEDED;
|
|
37
|
+
const externalAttributes = input.externalAttributes ?? 0;
|
|
38
|
+
const header = new Uint8Array(46 + input.fileName.length + input.extraField.length + input.comment.length);
|
|
39
|
+
const view = new DataView(header.buffer);
|
|
40
|
+
view.setUint32(0, zip_constants_1.CENTRAL_DIR_HEADER_SIG, true);
|
|
41
|
+
view.setUint16(4, versionMadeBy, true);
|
|
42
|
+
view.setUint16(6, versionNeeded, true);
|
|
43
|
+
view.setUint16(8, input.flags, true);
|
|
44
|
+
view.setUint16(10, input.compressionMethod, true);
|
|
45
|
+
view.setUint16(12, input.dosTime, true);
|
|
46
|
+
view.setUint16(14, input.dosDate, true);
|
|
47
|
+
view.setUint32(16, input.crc32, true);
|
|
48
|
+
view.setUint32(20, input.compressedSize, true);
|
|
49
|
+
view.setUint32(24, input.uncompressedSize, true);
|
|
50
|
+
view.setUint16(28, input.fileName.length, true);
|
|
51
|
+
view.setUint16(30, input.extraField.length, true);
|
|
52
|
+
view.setUint16(32, input.comment.length, true);
|
|
53
|
+
view.setUint16(34, 0, true); // disk number start
|
|
54
|
+
view.setUint16(36, 0, true); // internal file attributes
|
|
55
|
+
view.setUint32(38, externalAttributes, true);
|
|
56
|
+
view.setUint32(42, input.localHeaderOffset, true);
|
|
57
|
+
header.set(input.fileName, 46);
|
|
58
|
+
if (input.extraField.length > 0) {
|
|
59
|
+
header.set(input.extraField, 46 + input.fileName.length);
|
|
60
|
+
}
|
|
61
|
+
if (input.comment.length > 0) {
|
|
62
|
+
header.set(input.comment, 46 + input.fileName.length + input.extraField.length);
|
|
63
|
+
}
|
|
64
|
+
return header;
|
|
65
|
+
}
|
|
66
|
+
function buildEndOfCentralDirectory(input) {
|
|
67
|
+
const record = new Uint8Array(22 + input.comment.length);
|
|
68
|
+
const view = new DataView(record.buffer);
|
|
69
|
+
view.setUint32(0, zip_constants_1.END_OF_CENTRAL_DIR_SIG, true);
|
|
70
|
+
view.setUint16(4, 0, true);
|
|
71
|
+
view.setUint16(6, 0, true);
|
|
72
|
+
view.setUint16(8, input.entryCount, true);
|
|
73
|
+
view.setUint16(10, input.entryCount, true);
|
|
74
|
+
view.setUint32(12, input.centralDirSize, true);
|
|
75
|
+
view.setUint32(16, input.centralDirOffset, true);
|
|
76
|
+
view.setUint16(20, input.comment.length, true);
|
|
77
|
+
if (input.comment.length > 0) {
|
|
78
|
+
record.set(input.comment, 22);
|
|
79
|
+
}
|
|
80
|
+
return record;
|
|
81
|
+
}
|
|
82
|
+
function buildDataDescriptor(crc32, compressedSize, uncompressedSize) {
|
|
83
|
+
const descriptor = new Uint8Array(16);
|
|
84
|
+
const view = new DataView(descriptor.buffer);
|
|
85
|
+
view.setUint32(0, zip_constants_1.DATA_DESCRIPTOR_SIG, true);
|
|
86
|
+
view.setUint32(4, crc32, true);
|
|
87
|
+
view.setUint32(8, compressedSize, true);
|
|
88
|
+
view.setUint32(12, uncompressedSize, true);
|
|
89
|
+
return descriptor;
|
|
90
|
+
}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.WorkbookReader = exports.WorkbookReaderOptionsSchema = exports.WorkbookReaderBase = void 0;
|
|
14
14
|
const _stream_1 = require("../../stream/index.js");
|
|
15
|
-
const
|
|
15
|
+
const parse_1 = require("../../archive/parse.js");
|
|
16
16
|
const iterate_stream_1 = require("../utils/iterate-stream.js");
|
|
17
17
|
const ooxml_paths_1 = require("../utils/ooxml-paths.js");
|
|
18
18
|
const parse_sax_1 = require("../utils/parse-sax.js");
|
|
@@ -359,7 +359,7 @@ class WorkbookReaderBase extends _stream_1.EventEmitter {
|
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
async *_parseEntries(stream) {
|
|
362
|
-
const zip = (0,
|
|
362
|
+
const zip = (0, parse_1.createParse)({ forceStream: true });
|
|
363
363
|
stream.on("error", (err) => zip.emit("error", err));
|
|
364
364
|
stream.pipe(zip);
|
|
365
365
|
for await (const entry of (0, iterate_stream_1.iterateStream)(zip)) {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.WorkbookWriter = exports.WorkbookWriterOptionsSchema = exports.WorkbookWriterBase = void 0;
|
|
13
|
-
const
|
|
13
|
+
const streaming_zip_1 = require("../../archive/streaming-zip.js");
|
|
14
14
|
const stream_buf_1 = require("../utils/stream-buf.js");
|
|
15
15
|
const utils_1 = require("../../../utils/utils.js");
|
|
16
16
|
const rel_type_1 = require("../xlsx/rel-type.js");
|
|
@@ -54,7 +54,7 @@ class WorkbookWriterBase {
|
|
|
54
54
|
this.commentRefs = [];
|
|
55
55
|
this._trueStreaming = options.trueStreaming ?? false;
|
|
56
56
|
// Create Zip instance
|
|
57
|
-
this.zip = new
|
|
57
|
+
this.zip = new streaming_zip_1.Zip((err, data, final) => {
|
|
58
58
|
if (err) {
|
|
59
59
|
this.stream.emit("error", err);
|
|
60
60
|
}
|
|
@@ -88,7 +88,7 @@ class WorkbookWriterBase {
|
|
|
88
88
|
bufSize: this._trueStreaming ? 4096 : 65536,
|
|
89
89
|
batch: !this._trueStreaming
|
|
90
90
|
});
|
|
91
|
-
const zipFile = new
|
|
91
|
+
const zipFile = new streaming_zip_1.ZipDeflate(path, { level: this.compressionLevel });
|
|
92
92
|
this.zip.add(zipFile);
|
|
93
93
|
const onData = (chunk) => zipFile.push(chunk);
|
|
94
94
|
stream.on("data", onData);
|
|
@@ -100,7 +100,7 @@ class WorkbookWriterBase {
|
|
|
100
100
|
return stream;
|
|
101
101
|
}
|
|
102
102
|
_addFile(data, name, base64) {
|
|
103
|
-
const zipFile = new
|
|
103
|
+
const zipFile = new streaming_zip_1.ZipDeflate(name, { level: this.compressionLevel });
|
|
104
104
|
this.zip.add(zipFile);
|
|
105
105
|
let buffer;
|
|
106
106
|
if (base64) {
|
|
@@ -33,8 +33,8 @@ const theme1_1 = require("./xml/theme1.js");
|
|
|
33
33
|
const rel_type_1 = require("./rel-type.js");
|
|
34
34
|
const stream_buf_1 = require("../utils/stream-buf.js");
|
|
35
35
|
const utils_1 = require("../../../utils/utils.js");
|
|
36
|
-
const
|
|
37
|
-
const
|
|
36
|
+
const streaming_zip_1 = require("../../archive/streaming-zip.js");
|
|
37
|
+
const _archive_1 = require("../../archive/index.js");
|
|
38
38
|
const _stream_1 = require("../../stream/index.js");
|
|
39
39
|
const ooxml_paths_1 = require("../utils/ooxml-paths.js");
|
|
40
40
|
class StreamingZipWriterAdapter {
|
|
@@ -45,7 +45,7 @@ class StreamingZipWriterAdapter {
|
|
|
45
45
|
this.level = options?.level ?? 6;
|
|
46
46
|
this.modTime = options?.modTime;
|
|
47
47
|
this.timestamps = options?.timestamps;
|
|
48
|
-
this.zip = new
|
|
48
|
+
this.zip = new streaming_zip_1.StreamingZip((err, data, final) => {
|
|
49
49
|
if (err) {
|
|
50
50
|
this._emit("error", err);
|
|
51
51
|
return;
|
|
@@ -123,13 +123,16 @@ class StreamingZipWriterAdapter {
|
|
|
123
123
|
else {
|
|
124
124
|
buffer = data;
|
|
125
125
|
}
|
|
126
|
-
const file = new
|
|
126
|
+
const file = new streaming_zip_1.ZipDeflateFile(options.name, {
|
|
127
127
|
level: this.level,
|
|
128
128
|
modTime: this.modTime,
|
|
129
129
|
timestamps: this.timestamps
|
|
130
130
|
});
|
|
131
131
|
this.zip.add(file);
|
|
132
|
-
file.push(buffer, true);
|
|
132
|
+
const pushResult = file.push(buffer, true);
|
|
133
|
+
if (pushResult && typeof pushResult.catch === "function") {
|
|
134
|
+
pushResult.catch((err) => this._emit("error", err));
|
|
135
|
+
}
|
|
133
136
|
}
|
|
134
137
|
finalize() {
|
|
135
138
|
if (this.finalized) {
|
|
@@ -288,7 +291,7 @@ class XLSX {
|
|
|
288
291
|
* Internal: Load from Uint8Array buffer
|
|
289
292
|
*/
|
|
290
293
|
async loadBuffer(buffer, options) {
|
|
291
|
-
const parser = new
|
|
294
|
+
const parser = new _archive_1.ZipParser(buffer);
|
|
292
295
|
const filesMap = await parser.extractAll();
|
|
293
296
|
// Convert Map to Record for loadFromFiles
|
|
294
297
|
const allFiles = {};
|
|
@@ -22,7 +22,7 @@ exports.XLSX = void 0;
|
|
|
22
22
|
const fs_1 = __importDefault(require("fs"));
|
|
23
23
|
const utils_1 = require("../../../utils/utils.js");
|
|
24
24
|
const xlsx_browser_1 = require("./xlsx.browser.js");
|
|
25
|
-
const
|
|
25
|
+
const _archive_1 = require("../../archive/index.js");
|
|
26
26
|
const _stream_1 = require("../../stream/index.js");
|
|
27
27
|
class XLSX extends xlsx_browser_1.XLSX {
|
|
28
28
|
constructor(workbook) {
|
|
@@ -78,7 +78,7 @@ class XLSX extends xlsx_browser_1.XLSX {
|
|
|
78
78
|
// Node.js specific: TRUE streaming read
|
|
79
79
|
// ==========================================================================
|
|
80
80
|
async read(stream, options) {
|
|
81
|
-
const parser = new
|
|
81
|
+
const parser = new _archive_1.Parse();
|
|
82
82
|
const swallowError = () => {
|
|
83
83
|
// Prevent unhandled 'error' events from crashing the process.
|
|
84
84
|
// Errors are surfaced via rejected promises.
|