@cj-tech-master/excelts 4.2.0-canary.20260110111632.c88c61c → 4.2.1-canary.20260111102127.f808a37
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 +0 -31
- package/dist/browser/index.browser.d.ts +1 -0
- package/dist/browser/index.browser.js +12 -0
- package/dist/{esm/modules/archive → browser/modules/archive/compression}/compress.base.js +1 -1
- package/dist/{types/modules/archive → browser/modules/archive/compression}/compress.browser.d.ts +2 -8
- package/dist/browser/modules/archive/{compress.browser.js → compression/compress.browser.js} +3 -11
- package/dist/browser/modules/archive/{compress.d.ts → compression/compress.d.ts} +2 -2
- package/dist/{esm/modules/archive → browser/modules/archive/compression}/compress.js +1 -1
- package/dist/browser/modules/archive/{crc32.browser.d.ts → compression/crc32.browser.d.ts} +1 -1
- package/dist/browser/modules/archive/{crc32.d.ts → compression/crc32.d.ts} +1 -1
- package/dist/browser/modules/archive/{crc32.js → compression/crc32.js} +1 -1
- package/dist/browser/modules/archive/{deflate-fallback.js → compression/deflate-fallback.js} +1 -1
- package/dist/browser/modules/archive/{streaming-compress.browser.d.ts → compression/streaming-compress.browser.d.ts} +2 -2
- package/dist/browser/modules/archive/{streaming-compress.browser.js → compression/streaming-compress.browser.js} +3 -3
- package/dist/browser/modules/archive/{streaming-compress.d.ts → compression/streaming-compress.d.ts} +2 -2
- package/dist/browser/modules/archive/{streaming-compress.js → compression/streaming-compress.js} +2 -2
- package/dist/browser/modules/archive/defaults.d.ts +1 -0
- package/dist/browser/modules/archive/defaults.js +6 -3
- package/dist/browser/modules/archive/index.base.d.ts +4 -4
- package/dist/browser/modules/archive/index.base.js +3 -6
- package/dist/browser/modules/archive/index.browser.d.ts +3 -4
- package/dist/browser/modules/archive/index.browser.js +3 -7
- package/dist/browser/modules/archive/index.d.ts +3 -4
- package/dist/browser/modules/archive/index.js +3 -5
- package/dist/browser/modules/archive/internal/byte-queue.d.ts +33 -0
- package/dist/browser/modules/archive/internal/byte-queue.js +407 -0
- package/dist/browser/modules/archive/io/archive-sink.d.ts +9 -0
- package/dist/browser/modules/archive/io/archive-sink.js +77 -0
- package/dist/browser/modules/archive/io/archive-source.d.ts +8 -0
- package/dist/browser/modules/archive/io/archive-source.js +107 -0
- package/dist/browser/modules/archive/{extract.d.ts → unzip/extract.d.ts} +2 -2
- package/dist/browser/modules/archive/unzip/index.d.ts +40 -0
- package/dist/browser/modules/archive/unzip/index.js +164 -0
- package/dist/browser/modules/archive/{parse.base.d.ts → unzip/stream.base.d.ts} +36 -2
- package/dist/browser/modules/archive/unzip/stream.base.js +1022 -0
- package/dist/browser/modules/archive/{parse.browser.d.ts → unzip/stream.browser.d.ts} +1 -1
- package/dist/browser/modules/archive/{parse.browser.js → unzip/stream.browser.js} +371 -110
- package/dist/browser/modules/archive/{parse.d.ts → unzip/stream.d.ts} +2 -2
- package/dist/{esm/modules/archive/parse.js → browser/modules/archive/unzip/stream.js} +6 -5
- package/dist/browser/modules/archive/{zip-parser.d.ts → unzip/zip-parser.d.ts} +1 -1
- package/dist/{esm/modules/archive → browser/modules/archive/unzip}/zip-parser.js +38 -24
- package/dist/browser/modules/archive/utils/async-queue.d.ts +7 -0
- package/dist/browser/modules/archive/utils/async-queue.js +103 -0
- package/dist/browser/modules/archive/utils/bytes.js +16 -16
- package/dist/browser/modules/archive/utils/compressibility.d.ts +10 -0
- package/dist/browser/modules/archive/utils/compressibility.js +57 -0
- package/dist/browser/modules/archive/utils/parse-buffer.js +21 -23
- package/dist/browser/modules/archive/utils/pattern-scanner.d.ts +21 -0
- package/dist/browser/modules/archive/utils/pattern-scanner.js +27 -0
- package/dist/browser/modules/archive/utils/timestamps.js +62 -1
- package/dist/browser/modules/archive/utils/zip-extra-fields.d.ts +1 -1
- package/dist/browser/modules/archive/utils/zip-extra-fields.js +26 -14
- package/dist/browser/modules/archive/zip/index.d.ts +42 -0
- package/dist/browser/modules/archive/zip/index.js +157 -0
- package/dist/browser/modules/archive/{streaming-zip.d.ts → zip/stream.d.ts} +28 -5
- package/dist/browser/modules/archive/{streaming-zip.js → zip/stream.js} +192 -48
- package/dist/browser/modules/archive/zip/zip-bytes.d.ts +73 -0
- package/dist/browser/modules/archive/zip/zip-bytes.js +239 -0
- package/dist/{esm/modules/archive → browser/modules/archive/zip}/zip-entry-metadata.js +3 -3
- package/dist/browser/modules/archive/{zip-records.d.ts → zip-spec/zip-records.d.ts} +20 -0
- package/dist/browser/modules/archive/zip-spec/zip-records.js +126 -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 +3 -6
- package/dist/browser/modules/excel/xlsx/xlsx.js +1 -1
- package/dist/browser/modules/stream/streams.browser.d.ts +28 -30
- package/dist/browser/modules/stream/streams.browser.js +830 -710
- package/dist/browser/modules/stream/streams.js +140 -58
- package/dist/cjs/modules/archive/{compress.base.js → compression/compress.base.js} +1 -1
- package/dist/cjs/modules/archive/{compress.browser.js → compression/compress.browser.js} +3 -11
- package/dist/cjs/modules/archive/{compress.js → compression/compress.js} +1 -1
- package/dist/cjs/modules/archive/{crc32.js → compression/crc32.js} +1 -1
- package/dist/cjs/modules/archive/{deflate-fallback.js → compression/deflate-fallback.js} +1 -1
- package/dist/cjs/modules/archive/{streaming-compress.browser.js → compression/streaming-compress.browser.js} +3 -3
- package/dist/cjs/modules/archive/{streaming-compress.js → compression/streaming-compress.js} +2 -2
- package/dist/cjs/modules/archive/defaults.js +7 -4
- package/dist/cjs/modules/archive/index.base.js +9 -19
- package/dist/cjs/modules/archive/index.browser.js +4 -10
- package/dist/cjs/modules/archive/index.js +4 -8
- package/dist/cjs/modules/archive/internal/byte-queue.js +411 -0
- package/dist/cjs/modules/archive/io/archive-sink.js +82 -0
- package/dist/cjs/modules/archive/io/archive-source.js +114 -0
- package/dist/cjs/modules/archive/unzip/index.js +170 -0
- package/dist/cjs/modules/archive/unzip/stream.base.js +1044 -0
- package/dist/cjs/modules/archive/{parse.browser.js → unzip/stream.browser.js} +372 -111
- package/dist/cjs/modules/archive/{parse.js → unzip/stream.js} +9 -8
- package/dist/cjs/modules/archive/{zip-parser.js → unzip/zip-parser.js} +47 -33
- package/dist/cjs/modules/archive/utils/async-queue.js +106 -0
- package/dist/cjs/modules/archive/utils/bytes.js +16 -16
- package/dist/cjs/modules/archive/utils/compressibility.js +60 -0
- package/dist/cjs/modules/archive/utils/parse-buffer.js +21 -23
- package/dist/cjs/modules/archive/utils/pattern-scanner.js +31 -0
- package/dist/cjs/modules/archive/utils/timestamps.js +64 -3
- package/dist/cjs/modules/archive/utils/zip-extra-fields.js +26 -14
- package/dist/cjs/modules/archive/zip/index.js +162 -0
- package/dist/cjs/modules/archive/{streaming-zip.js → zip/stream.js} +194 -50
- package/dist/cjs/modules/archive/zip/zip-bytes.js +242 -0
- package/dist/cjs/modules/archive/{zip-entry-metadata.js → zip/zip-entry-metadata.js} +5 -5
- package/dist/cjs/modules/archive/zip-spec/zip-records.js +136 -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 +6 -9
- package/dist/cjs/modules/excel/xlsx/xlsx.js +2 -2
- package/dist/cjs/modules/stream/streams.browser.js +830 -710
- package/dist/cjs/modules/stream/streams.js +140 -58
- package/dist/esm/index.browser.js +12 -0
- package/dist/{browser/modules/archive → esm/modules/archive/compression}/compress.base.js +1 -1
- package/dist/esm/modules/archive/{compress.browser.js → compression/compress.browser.js} +3 -11
- package/dist/{browser/modules/archive → esm/modules/archive/compression}/compress.js +1 -1
- package/dist/esm/modules/archive/{crc32.js → compression/crc32.js} +1 -1
- package/dist/esm/modules/archive/{deflate-fallback.js → compression/deflate-fallback.js} +1 -1
- package/dist/esm/modules/archive/{streaming-compress.browser.js → compression/streaming-compress.browser.js} +3 -3
- package/dist/esm/modules/archive/{streaming-compress.js → compression/streaming-compress.js} +2 -2
- package/dist/esm/modules/archive/defaults.js +6 -3
- package/dist/esm/modules/archive/index.base.js +3 -6
- package/dist/esm/modules/archive/index.browser.js +3 -7
- package/dist/esm/modules/archive/index.js +3 -5
- package/dist/esm/modules/archive/internal/byte-queue.js +407 -0
- package/dist/esm/modules/archive/io/archive-sink.js +77 -0
- package/dist/esm/modules/archive/io/archive-source.js +107 -0
- package/dist/esm/modules/archive/unzip/index.js +164 -0
- package/dist/esm/modules/archive/unzip/stream.base.js +1022 -0
- package/dist/esm/modules/archive/{parse.browser.js → unzip/stream.browser.js} +371 -110
- package/dist/{browser/modules/archive/parse.js → esm/modules/archive/unzip/stream.js} +6 -5
- package/dist/{browser/modules/archive → esm/modules/archive/unzip}/zip-parser.js +38 -24
- package/dist/esm/modules/archive/utils/async-queue.js +103 -0
- package/dist/esm/modules/archive/utils/bytes.js +16 -16
- package/dist/esm/modules/archive/utils/compressibility.js +57 -0
- package/dist/esm/modules/archive/utils/parse-buffer.js +21 -23
- package/dist/esm/modules/archive/utils/pattern-scanner.js +27 -0
- package/dist/esm/modules/archive/utils/timestamps.js +62 -1
- package/dist/esm/modules/archive/utils/zip-extra-fields.js +26 -14
- package/dist/esm/modules/archive/zip/index.js +157 -0
- package/dist/esm/modules/archive/{streaming-zip.js → zip/stream.js} +192 -48
- package/dist/esm/modules/archive/zip/zip-bytes.js +239 -0
- package/dist/{browser/modules/archive → esm/modules/archive/zip}/zip-entry-metadata.js +3 -3
- package/dist/esm/modules/archive/zip-spec/zip-records.js +126 -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 +3 -6
- package/dist/esm/modules/excel/xlsx/xlsx.js +1 -1
- package/dist/esm/modules/stream/streams.browser.js +830 -710
- package/dist/esm/modules/stream/streams.js +140 -58
- package/dist/iife/THIRD_PARTY_NOTICES.md +0 -31
- package/dist/iife/excelts.iife.js +6190 -4400
- package/dist/iife/excelts.iife.js.map +1 -1
- package/dist/iife/excelts.iife.min.js +103 -31
- package/dist/types/index.browser.d.ts +1 -0
- package/dist/{browser/modules/archive → types/modules/archive/compression}/compress.browser.d.ts +2 -8
- package/dist/types/modules/archive/{streaming-compress.browser.d.ts → compression/streaming-compress.browser.d.ts} +1 -1
- package/dist/types/modules/archive/defaults.d.ts +1 -0
- package/dist/types/modules/archive/index.base.d.ts +4 -4
- package/dist/types/modules/archive/index.browser.d.ts +3 -4
- package/dist/types/modules/archive/index.d.ts +3 -4
- package/dist/types/modules/archive/internal/byte-queue.d.ts +33 -0
- package/dist/types/modules/archive/io/archive-sink.d.ts +9 -0
- package/dist/types/modules/archive/io/archive-source.d.ts +8 -0
- package/dist/types/modules/archive/unzip/index.d.ts +40 -0
- package/dist/types/modules/archive/{parse.base.d.ts → unzip/stream.base.d.ts} +38 -4
- package/dist/types/modules/archive/{parse.browser.d.ts → unzip/stream.browser.d.ts} +2 -2
- package/dist/types/modules/archive/{parse.d.ts → unzip/stream.d.ts} +3 -3
- package/dist/types/modules/archive/{zip-parser.d.ts → unzip/zip-parser.d.ts} +1 -1
- package/dist/types/modules/archive/utils/async-queue.d.ts +7 -0
- package/dist/types/modules/archive/utils/compressibility.d.ts +10 -0
- package/dist/types/modules/archive/utils/pattern-scanner.d.ts +21 -0
- package/dist/types/modules/archive/utils/zip-extra-fields.d.ts +1 -1
- package/dist/types/modules/archive/zip/index.d.ts +42 -0
- package/dist/types/modules/archive/{streaming-zip.d.ts → zip/stream.d.ts} +29 -6
- package/dist/types/modules/archive/zip/zip-bytes.d.ts +73 -0
- package/dist/types/modules/archive/{zip-entry-metadata.d.ts → zip/zip-entry-metadata.d.ts} +1 -1
- package/dist/types/modules/archive/{zip-records.d.ts → zip-spec/zip-records.d.ts} +20 -0
- package/dist/types/modules/excel/stream/workbook-writer.browser.d.ts +1 -1
- package/dist/types/modules/stream/streams.browser.d.ts +28 -30
- package/package.json +5 -1
- package/dist/browser/modules/archive/byte-queue.d.ts +0 -18
- package/dist/browser/modules/archive/byte-queue.js +0 -125
- package/dist/browser/modules/archive/parse.base.js +0 -644
- package/dist/browser/modules/archive/utils/zip-extra.d.ts +0 -18
- package/dist/browser/modules/archive/utils/zip-extra.js +0 -68
- package/dist/browser/modules/archive/zip-builder.d.ts +0 -117
- package/dist/browser/modules/archive/zip-builder.js +0 -292
- package/dist/browser/modules/archive/zip-constants.d.ts +0 -18
- package/dist/browser/modules/archive/zip-constants.js +0 -23
- package/dist/browser/modules/archive/zip-records.js +0 -84
- package/dist/cjs/modules/archive/byte-queue.js +0 -129
- package/dist/cjs/modules/archive/parse.base.js +0 -666
- package/dist/cjs/modules/archive/utils/zip-extra.js +0 -74
- package/dist/cjs/modules/archive/zip-builder.js +0 -297
- package/dist/cjs/modules/archive/zip-constants.js +0 -26
- package/dist/cjs/modules/archive/zip-records.js +0 -90
- package/dist/esm/modules/archive/byte-queue.js +0 -125
- package/dist/esm/modules/archive/parse.base.js +0 -644
- package/dist/esm/modules/archive/utils/zip-extra.js +0 -68
- package/dist/esm/modules/archive/zip-builder.js +0 -292
- package/dist/esm/modules/archive/zip-constants.js +0 -23
- package/dist/esm/modules/archive/zip-records.js +0 -84
- package/dist/types/modules/archive/byte-queue.d.ts +0 -18
- package/dist/types/modules/archive/utils/zip-extra.d.ts +0 -18
- package/dist/types/modules/archive/zip-builder.d.ts +0 -117
- package/dist/types/modules/archive/zip-constants.d.ts +0 -18
- /package/dist/browser/modules/archive/{compress.base.d.ts → compression/compress.base.d.ts} +0 -0
- /package/dist/browser/modules/archive/{crc32.base.d.ts → compression/crc32.base.d.ts} +0 -0
- /package/dist/browser/modules/archive/{crc32.base.js → compression/crc32.base.js} +0 -0
- /package/dist/browser/modules/archive/{crc32.browser.js → compression/crc32.browser.js} +0 -0
- /package/dist/browser/modules/archive/{deflate-fallback.d.ts → compression/deflate-fallback.d.ts} +0 -0
- /package/dist/browser/modules/archive/{streaming-compress.base.d.ts → compression/streaming-compress.base.d.ts} +0 -0
- /package/dist/browser/modules/archive/{streaming-compress.base.js → compression/streaming-compress.base.js} +0 -0
- /package/dist/browser/modules/archive/{extract.js → unzip/extract.js} +0 -0
- /package/dist/browser/modules/archive/{zip-entry-metadata.d.ts → zip/zip-entry-metadata.d.ts} +0 -0
- /package/dist/browser/modules/archive/{zip-entry-info.d.ts → zip-spec/zip-entry-info.d.ts} +0 -0
- /package/dist/browser/modules/archive/{zip-entry-info.js → zip-spec/zip-entry-info.js} +0 -0
- /package/dist/cjs/modules/archive/{crc32.base.js → compression/crc32.base.js} +0 -0
- /package/dist/cjs/modules/archive/{crc32.browser.js → compression/crc32.browser.js} +0 -0
- /package/dist/cjs/modules/archive/{streaming-compress.base.js → compression/streaming-compress.base.js} +0 -0
- /package/dist/cjs/modules/archive/{extract.js → unzip/extract.js} +0 -0
- /package/dist/cjs/modules/archive/{zip-entry-info.js → zip-spec/zip-entry-info.js} +0 -0
- /package/dist/esm/modules/archive/{crc32.base.js → compression/crc32.base.js} +0 -0
- /package/dist/esm/modules/archive/{crc32.browser.js → compression/crc32.browser.js} +0 -0
- /package/dist/esm/modules/archive/{streaming-compress.base.js → compression/streaming-compress.base.js} +0 -0
- /package/dist/esm/modules/archive/{extract.js → unzip/extract.js} +0 -0
- /package/dist/esm/modules/archive/{zip-entry-info.js → zip-spec/zip-entry-info.js} +0 -0
- /package/dist/types/modules/archive/{compress.base.d.ts → compression/compress.base.d.ts} +0 -0
- /package/dist/types/modules/archive/{compress.d.ts → compression/compress.d.ts} +0 -0
- /package/dist/types/modules/archive/{crc32.base.d.ts → compression/crc32.base.d.ts} +0 -0
- /package/dist/types/modules/archive/{crc32.browser.d.ts → compression/crc32.browser.d.ts} +0 -0
- /package/dist/types/modules/archive/{crc32.d.ts → compression/crc32.d.ts} +0 -0
- /package/dist/types/modules/archive/{deflate-fallback.d.ts → compression/deflate-fallback.d.ts} +0 -0
- /package/dist/types/modules/archive/{streaming-compress.base.d.ts → compression/streaming-compress.base.d.ts} +0 -0
- /package/dist/types/modules/archive/{streaming-compress.d.ts → compression/streaming-compress.d.ts} +0 -0
- /package/dist/types/modules/archive/{extract.d.ts → unzip/extract.d.ts} +0 -0
- /package/dist/types/modules/archive/{zip-entry-info.d.ts → zip-spec/zip-entry-info.d.ts} +0 -0
|
@@ -62,20 +62,34 @@ class Writable extends stream_1.Writable {
|
|
|
62
62
|
constructor(options) {
|
|
63
63
|
// If wrapping an existing stream, proxy to it
|
|
64
64
|
if (options?.stream) {
|
|
65
|
+
const underlying = options.stream;
|
|
65
66
|
// Create a pass-through wrapper that proxies to the underlying stream
|
|
66
67
|
super({
|
|
67
68
|
highWaterMark: options?.highWaterMark,
|
|
68
69
|
objectMode: options?.objectMode,
|
|
69
70
|
write(chunk, encoding, callback) {
|
|
70
|
-
|
|
71
|
+
underlying.write(chunk, encoding, callback);
|
|
71
72
|
},
|
|
72
73
|
final(callback) {
|
|
73
|
-
|
|
74
|
+
underlying.end(callback);
|
|
74
75
|
}
|
|
75
76
|
});
|
|
76
|
-
// Proxy events from underlying stream
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
// Proxy events from underlying stream, but ensure we clean up listeners so
|
|
78
|
+
// the underlying stream cannot retain this wrapper longer than necessary.
|
|
79
|
+
const onUnderlyingError = (err) => {
|
|
80
|
+
this.emit("error", err);
|
|
81
|
+
};
|
|
82
|
+
const onUnderlyingClose = () => {
|
|
83
|
+
this.emit("close");
|
|
84
|
+
};
|
|
85
|
+
const cleanup = () => {
|
|
86
|
+
underlying.off("error", onUnderlyingError);
|
|
87
|
+
underlying.off("close", onUnderlyingClose);
|
|
88
|
+
};
|
|
89
|
+
underlying.on("error", onUnderlyingError);
|
|
90
|
+
underlying.on("close", onUnderlyingClose);
|
|
91
|
+
this.once("close", cleanup);
|
|
92
|
+
this.once("finish", cleanup);
|
|
79
93
|
}
|
|
80
94
|
else {
|
|
81
95
|
super({
|
|
@@ -100,17 +114,16 @@ function normalizeWritable(stream) {
|
|
|
100
114
|
if (stream instanceof Writable) {
|
|
101
115
|
return stream;
|
|
102
116
|
}
|
|
103
|
-
// Node.js Writable:
|
|
117
|
+
// Node.js Writable: already compatible, avoid extra wrapper allocation.
|
|
104
118
|
if (stream instanceof stream_1.Writable) {
|
|
105
|
-
return
|
|
119
|
+
return stream;
|
|
106
120
|
}
|
|
107
121
|
// Web WritableStream: detect by getWriter() (avoid relying on global WritableStream).
|
|
108
122
|
if (stream?.getWriter) {
|
|
109
|
-
|
|
110
|
-
return new Writable({ stream: nodeWritable });
|
|
123
|
+
return stream_1.Writable.fromWeb(stream);
|
|
111
124
|
}
|
|
112
|
-
// Assume it structurally matches Node's Writable
|
|
113
|
-
return
|
|
125
|
+
// Assume it structurally matches Node's Writable.
|
|
126
|
+
return stream;
|
|
114
127
|
}
|
|
115
128
|
// Import for internal use
|
|
116
129
|
const shared_1 = require("./shared.js");
|
|
@@ -223,12 +236,13 @@ function finished(stream, optionsOrCallback, callback) {
|
|
|
223
236
|
const promise = new Promise((resolve, reject) => {
|
|
224
237
|
const normalizedStream = toNodePipelineStream(stream);
|
|
225
238
|
stream_1.finished(normalizedStream, options, (err) => {
|
|
226
|
-
|
|
239
|
+
// Node.js semantics: options.error defaults to true (report errors).
|
|
240
|
+
// If options.error === false, ignore errors and resolve.
|
|
241
|
+
if (err && options?.error !== false) {
|
|
227
242
|
reject(err);
|
|
243
|
+
return;
|
|
228
244
|
}
|
|
229
|
-
|
|
230
|
-
resolve();
|
|
231
|
-
}
|
|
245
|
+
resolve();
|
|
232
246
|
});
|
|
233
247
|
});
|
|
234
248
|
if (cb) {
|
|
@@ -581,13 +595,28 @@ function addAbortSignal(signal, stream) {
|
|
|
581
595
|
stream.destroy(new Error("Aborted"));
|
|
582
596
|
return stream;
|
|
583
597
|
}
|
|
598
|
+
const cleanup = () => {
|
|
599
|
+
signal.removeEventListener("abort", onAbort);
|
|
600
|
+
stream.off?.("close", onDone);
|
|
601
|
+
stream.off?.("end", onDone);
|
|
602
|
+
stream.off?.("finish", onDone);
|
|
603
|
+
stream.off?.("error", onError);
|
|
604
|
+
};
|
|
584
605
|
const onAbort = () => {
|
|
606
|
+
cleanup();
|
|
585
607
|
stream.destroy(new Error("Aborted"));
|
|
586
608
|
};
|
|
609
|
+
const onDone = () => {
|
|
610
|
+
cleanup();
|
|
611
|
+
};
|
|
612
|
+
const onError = () => {
|
|
613
|
+
cleanup();
|
|
614
|
+
};
|
|
587
615
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
588
|
-
stream.
|
|
589
|
-
|
|
590
|
-
|
|
616
|
+
stream.once?.("close", onDone);
|
|
617
|
+
stream.once?.("end", onDone);
|
|
618
|
+
stream.once?.("finish", onDone);
|
|
619
|
+
stream.once?.("error", onError);
|
|
591
620
|
return stream;
|
|
592
621
|
}
|
|
593
622
|
/**
|
|
@@ -630,56 +659,109 @@ function compose(...transforms) {
|
|
|
630
659
|
if (len === 1 && isNativeTransform(transforms[0])) {
|
|
631
660
|
return transforms[0];
|
|
632
661
|
}
|
|
633
|
-
// Chain all transforms together
|
|
662
|
+
// Chain all transforms together once.
|
|
634
663
|
for (let i = 0; i < len - 1; i++) {
|
|
635
664
|
transforms[i].pipe(transforms[i + 1]);
|
|
636
665
|
}
|
|
637
|
-
// Create a Duplex that writes to first and reads from last
|
|
638
666
|
const first = transforms[0];
|
|
639
667
|
const last = transforms[len - 1];
|
|
640
|
-
//
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
return first.write(chunk, encodingOrCallback);
|
|
649
|
-
}
|
|
650
|
-
return first.write(chunk, encodingOrCallback, callback);
|
|
651
|
-
};
|
|
652
|
-
// Override end to end first transform
|
|
653
|
-
composed.end = function (chunkOrCallback, encodingOrCallback, callback) {
|
|
654
|
-
if (typeof chunkOrCallback === "function") {
|
|
655
|
-
first.end(chunkOrCallback);
|
|
668
|
+
// Use a private output stream so we don't have to monkey-patch `write()` on the
|
|
669
|
+
// public composed stream (which would break piping into it).
|
|
670
|
+
const output = new stream_1.PassThrough({ objectMode: last.readableObjectMode ?? true });
|
|
671
|
+
last.pipe(output);
|
|
672
|
+
let outputEnded = false;
|
|
673
|
+
const pumpOutput = (target) => {
|
|
674
|
+
if (outputEnded) {
|
|
675
|
+
return;
|
|
656
676
|
}
|
|
657
|
-
|
|
658
|
-
|
|
677
|
+
while (true) {
|
|
678
|
+
const chunk = output.read();
|
|
679
|
+
if (chunk === null) {
|
|
680
|
+
break;
|
|
681
|
+
}
|
|
682
|
+
if (!target.push(chunk)) {
|
|
683
|
+
break;
|
|
684
|
+
}
|
|
659
685
|
}
|
|
660
|
-
|
|
661
|
-
|
|
686
|
+
};
|
|
687
|
+
const composed = new stream_1.Transform({
|
|
688
|
+
readableObjectMode: last.readableObjectMode,
|
|
689
|
+
writableObjectMode: first.writableObjectMode,
|
|
690
|
+
transform(chunk, encoding, callback) {
|
|
691
|
+
try {
|
|
692
|
+
// Forward writes into the head of the chain.
|
|
693
|
+
first.write(chunk, encoding, callback);
|
|
694
|
+
}
|
|
695
|
+
catch (err) {
|
|
696
|
+
callback(err);
|
|
697
|
+
}
|
|
698
|
+
},
|
|
699
|
+
flush(callback) {
|
|
700
|
+
// End the head of the chain; readable completion is driven by `output` ending.
|
|
701
|
+
const onFinish = () => {
|
|
702
|
+
cleanupFlush();
|
|
703
|
+
callback();
|
|
704
|
+
};
|
|
705
|
+
const onError = (err) => {
|
|
706
|
+
cleanupFlush();
|
|
707
|
+
callback(err);
|
|
708
|
+
};
|
|
709
|
+
const cleanupFlush = () => {
|
|
710
|
+
first.off?.("finish", onFinish);
|
|
711
|
+
first.off?.("error", onError);
|
|
712
|
+
};
|
|
713
|
+
first.once?.("finish", onFinish);
|
|
714
|
+
first.once?.("error", onError);
|
|
715
|
+
first.end();
|
|
716
|
+
},
|
|
717
|
+
read() {
|
|
718
|
+
pumpOutput(this);
|
|
719
|
+
},
|
|
720
|
+
destroy(err, callback) {
|
|
721
|
+
try {
|
|
722
|
+
output.destroy(err ?? undefined);
|
|
723
|
+
for (const t of transforms) {
|
|
724
|
+
t.destroy?.(err ?? undefined);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
finally {
|
|
728
|
+
callback(err);
|
|
729
|
+
}
|
|
662
730
|
}
|
|
663
|
-
|
|
731
|
+
});
|
|
732
|
+
const onOutputReadable = () => {
|
|
733
|
+
pumpOutput(composed);
|
|
664
734
|
};
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
735
|
+
const onOutputEnd = () => {
|
|
736
|
+
cleanupListeners();
|
|
737
|
+
outputEnded = true;
|
|
738
|
+
composed.push(null);
|
|
668
739
|
};
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
740
|
+
const onAnyError = (err) => {
|
|
741
|
+
cleanupListeners();
|
|
742
|
+
composed.destroy(err);
|
|
743
|
+
};
|
|
744
|
+
const transformErrorListeners = [];
|
|
745
|
+
const cleanupListeners = () => {
|
|
746
|
+
output.off("readable", onOutputReadable);
|
|
747
|
+
output.off("end", onOutputEnd);
|
|
748
|
+
output.off("error", onAnyError);
|
|
749
|
+
for (const { t, fn } of transformErrorListeners) {
|
|
750
|
+
t.off?.("error", fn);
|
|
751
|
+
}
|
|
752
|
+
transformErrorListeners.length = 0;
|
|
753
|
+
};
|
|
754
|
+
output.on("readable", onOutputReadable);
|
|
755
|
+
output.once("end", onOutputEnd);
|
|
756
|
+
output.once("error", onAnyError);
|
|
757
|
+
for (const t of transforms) {
|
|
758
|
+
const tt = t;
|
|
759
|
+
tt.once?.("error", onAnyError);
|
|
760
|
+
transformErrorListeners.push({ t: tt, fn: onAnyError });
|
|
682
761
|
}
|
|
762
|
+
composed.once("close", () => {
|
|
763
|
+
cleanupListeners();
|
|
764
|
+
});
|
|
683
765
|
return composed;
|
|
684
766
|
}
|
|
685
767
|
/**
|
|
@@ -760,7 +842,7 @@ function once(emitter, event, options) {
|
|
|
760
842
|
onAbort();
|
|
761
843
|
return;
|
|
762
844
|
}
|
|
763
|
-
options.signal.addEventListener("abort", onAbort);
|
|
845
|
+
options.signal.addEventListener("abort", onAbort, { once: true });
|
|
764
846
|
}
|
|
765
847
|
});
|
|
766
848
|
}
|
|
@@ -39,3 +39,15 @@ export { CsvParserStream, CsvFormatterStream } from "./modules/csv/csv.browser.j
|
|
|
39
39
|
// Utilities
|
|
40
40
|
// =============================================================================
|
|
41
41
|
export * from "./modules/excel/utils/sheet-utils.js";
|
|
42
|
+
// =============================================================================
|
|
43
|
+
// Archive (ZIP) support (Browser-compatible)
|
|
44
|
+
// =============================================================================
|
|
45
|
+
export {
|
|
46
|
+
// High-level archive API
|
|
47
|
+
zip, unzip, ZipArchive, ZipReader, UnzipEntry,
|
|
48
|
+
// CRC32
|
|
49
|
+
crc32, crc32Update, crc32Finalize,
|
|
50
|
+
// Compression utilities
|
|
51
|
+
compress, compressSync, decompress, decompressSync, hasCompressionStream,
|
|
52
|
+
// Streaming compression
|
|
53
|
+
createDeflateStream, createInflateStream, hasDeflateRaw } from "./modules/archive/index.browser.js";
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Browser fallback: For browsers without deflate-raw support (Firefox < 113, Safari < 16.4),
|
|
9
9
|
* see deflate-fallback.ts for pure JS implementation
|
|
10
10
|
*/
|
|
11
|
-
import { ByteQueue } from "
|
|
11
|
+
import { ByteQueue } from "../internal/byte-queue.js";
|
|
12
12
|
/**
|
|
13
13
|
* Default threshold (in bytes) to choose the lower-overhead path.
|
|
14
14
|
*
|
|
@@ -10,20 +10,12 @@
|
|
|
10
10
|
* - Safari >= 14.1
|
|
11
11
|
* - Edge >= 89
|
|
12
12
|
*/
|
|
13
|
-
import { compressWithStream, decompressWithStream, hasDeflateRawCompressionStream, hasDeflateRawDecompressionStream } from "./compress.base.js";
|
|
13
|
+
import { compressWithStream, decompressWithStream, hasCompressionStream, hasDeflateRawCompressionStream, hasDeflateRawDecompressionStream } from "./compress.base.js";
|
|
14
14
|
import { inflateRaw, deflateRawCompressed } from "./deflate-fallback.js";
|
|
15
|
-
import { DEFAULT_COMPRESS_LEVEL } from "
|
|
15
|
+
import { DEFAULT_COMPRESS_LEVEL } from "../defaults.js";
|
|
16
16
|
// Re-export shared types
|
|
17
17
|
export {};
|
|
18
|
-
|
|
19
|
-
* Check if CompressionStream is available in this environment.
|
|
20
|
-
*
|
|
21
|
-
* Note: Some environments may expose CompressionStream but not support
|
|
22
|
-
* the "deflate-raw" format that ZIP requires.
|
|
23
|
-
*/
|
|
24
|
-
export function hasCompressionStream() {
|
|
25
|
-
return typeof CompressionStream !== "undefined";
|
|
26
|
-
}
|
|
18
|
+
export { hasCompressionStream };
|
|
27
19
|
/**
|
|
28
20
|
* Compress data using browser's native CompressionStream or JS fallback
|
|
29
21
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { promisify } from "util";
|
|
8
8
|
import * as zlib from "zlib";
|
|
9
|
-
import { DEFAULT_COMPRESS_LEVEL } from "
|
|
9
|
+
import { DEFAULT_COMPRESS_LEVEL } from "../defaults.js";
|
|
10
10
|
// Re-export shared types and utilities
|
|
11
11
|
export { hasCompressionStream } from "./compress.base.js";
|
|
12
12
|
function uint8ArrayToBufferView(data) {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1
|
|
9
9
|
* Represented as 0xEDB88320 in reversed (LSB-first) form
|
|
10
10
|
*/
|
|
11
|
-
import { isNode } from "
|
|
11
|
+
import { isNode } from "../../../utils/env.js";
|
|
12
12
|
import { crc32JS, crc32UpdateJS, crc32Finalize } from "./crc32.base.js";
|
|
13
13
|
// Lazy-loaded zlib module for Node.js
|
|
14
14
|
let _zlib = null;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* - Safari < 16.4
|
|
11
11
|
* - Chrome < 103
|
|
12
12
|
*/
|
|
13
|
-
import { concatUint8Arrays } from "
|
|
13
|
+
import { concatUint8Arrays } from "../utils/bytes.js";
|
|
14
14
|
// ============================================================================
|
|
15
15
|
// DEFLATE Decompression (Full implementation)
|
|
16
16
|
// ============================================================================
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
*
|
|
7
7
|
* API compatible with Node.js version - supports .on("data"), .on("end"), .write(callback), .end()
|
|
8
8
|
*/
|
|
9
|
-
import { EventEmitter } from "
|
|
9
|
+
import { EventEmitter } from "../../stream/index.js";
|
|
10
10
|
import { deflateRawCompressed, inflateRaw } from "./deflate-fallback.js";
|
|
11
11
|
import { hasDeflateRawWebStreams } from "./compress.base.js";
|
|
12
|
-
import { concatUint8Arrays } from "
|
|
13
|
-
import { DEFAULT_COMPRESS_LEVEL } from "
|
|
12
|
+
import { concatUint8Arrays } from "../utils/bytes.js";
|
|
13
|
+
import { DEFAULT_COMPRESS_LEVEL } from "../defaults.js";
|
|
14
14
|
import { asError } from "./streaming-compress.base.js";
|
|
15
15
|
/**
|
|
16
16
|
* Check if deflate-raw streaming compression is supported by this library.
|
package/dist/esm/modules/archive/{streaming-compress.js → compression/streaming-compress.js}
RENAMED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* Each write() immediately produces compressed output without waiting for end().
|
|
6
6
|
*/
|
|
7
7
|
import { createDeflateRaw, createInflateRaw, constants } from "zlib";
|
|
8
|
-
import { Transform } from "
|
|
9
|
-
import { DEFAULT_COMPRESS_LEVEL } from "
|
|
8
|
+
import { Transform } from "../../stream/index.js";
|
|
9
|
+
import { DEFAULT_COMPRESS_LEVEL } from "../defaults.js";
|
|
10
10
|
/**
|
|
11
11
|
* Wrapper around zlib DeflateRaw that flushes after every write
|
|
12
12
|
* This ensures true streaming behavior - data is emitted immediately, not buffered
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
export const
|
|
2
|
-
|
|
3
|
-
export const
|
|
1
|
+
export const DEFAULT_DEFLATE_LEVEL = 6;
|
|
2
|
+
// Backward-compatible aliases (avoid default drift across modules).
|
|
3
|
+
export const DEFAULT_COMPRESS_LEVEL = DEFAULT_DEFLATE_LEVEL;
|
|
4
|
+
export const DEFAULT_ZIP_LEVEL = DEFAULT_DEFLATE_LEVEL;
|
|
5
|
+
// Prefer reproducible output by default: omit the Info-ZIP UTC mtime extra field.
|
|
6
|
+
export const DEFAULT_ZIP_TIMESTAMPS = "dos";
|
|
@@ -5,9 +5,6 @@
|
|
|
5
5
|
* Platform-specific entrypoints (index.ts / index.browser.ts) should re-export
|
|
6
6
|
* from this file and then layer their platform-specific bindings.
|
|
7
7
|
*/
|
|
8
|
-
//
|
|
9
|
-
export {
|
|
10
|
-
|
|
11
|
-
export { StreamingZip, ZipDeflateFile, Zip, ZipDeflate } from "./streaming-zip.js";
|
|
12
|
-
// Buffer-based unzip API (cross-platform)
|
|
13
|
-
export { extractAll, extractFile, listFiles, forEachEntry, ZipParser } from "./extract.js";
|
|
8
|
+
// High-level APIs
|
|
9
|
+
export { zip, ZipArchive } from "./zip/index.js";
|
|
10
|
+
export { unzip, ZipReader, UnzipEntry } from "./unzip/index.js";
|
|
@@ -6,12 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export * from "./index.base.js";
|
|
8
8
|
// CRC32
|
|
9
|
-
export { crc32, crc32Update, crc32Finalize } from "./crc32.browser.js";
|
|
9
|
+
export { crc32, crc32Update, crc32Finalize } from "./compression/crc32.browser.js";
|
|
10
10
|
// Compression
|
|
11
|
-
export { compress, compressSync, decompress, decompressSync, hasCompressionStream } from "./compress.browser.js";
|
|
11
|
+
export { compress, compressSync, decompress, decompressSync, hasCompressionStream } from "./compression/compress.browser.js";
|
|
12
12
|
// Streaming compression
|
|
13
|
-
export { createDeflateStream, createInflateStream, hasDeflateRaw } from "./streaming-compress.browser.js";
|
|
14
|
-
// Stream-based unzip API (browser implementation)
|
|
15
|
-
export { Parse, createParse } from "./parse.browser.js";
|
|
16
|
-
// Buffer-based unzip API (cross-platform)
|
|
17
|
-
// (re-exported from ./index.base)
|
|
13
|
+
export { createDeflateStream, createInflateStream, hasDeflateRaw } from "./compression/streaming-compress.browser.js";
|
|
@@ -6,10 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export * from "./index.base.js";
|
|
8
8
|
// CRC32
|
|
9
|
-
export { crc32, crc32Update, crc32Finalize } from "./crc32.js";
|
|
9
|
+
export { crc32, crc32Update, crc32Finalize } from "./compression/crc32.js";
|
|
10
10
|
// Compression
|
|
11
|
-
export { compress, compressSync, decompress, decompressSync, hasCompressionStream } from "./compress.js";
|
|
11
|
+
export { compress, compressSync, decompress, decompressSync, hasCompressionStream } from "./compression/compress.js";
|
|
12
12
|
// Streaming compression
|
|
13
|
-
export { createDeflateStream, createInflateStream, hasDeflateRaw } from "./streaming-compress.js";
|
|
14
|
-
// Stream-based unzip API (Node.js; browser build aliases to ./parse.browser.ts)
|
|
15
|
-
export { Parse, createParse } from "./parse.js";
|
|
13
|
+
export { createDeflateStream, createInflateStream, hasDeflateRaw } from "./compression/streaming-compress.js";
|