@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
|
@@ -62,34 +62,20 @@ 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;
|
|
66
65
|
// Create a pass-through wrapper that proxies to the underlying stream
|
|
67
66
|
super({
|
|
68
67
|
highWaterMark: options?.highWaterMark,
|
|
69
68
|
objectMode: options?.objectMode,
|
|
70
69
|
write(chunk, encoding, callback) {
|
|
71
|
-
|
|
70
|
+
options.stream.write(chunk, encoding, callback);
|
|
72
71
|
},
|
|
73
72
|
final(callback) {
|
|
74
|
-
|
|
73
|
+
options.stream.end(callback);
|
|
75
74
|
}
|
|
76
75
|
});
|
|
77
|
-
// Proxy events from underlying stream
|
|
78
|
-
|
|
79
|
-
|
|
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);
|
|
76
|
+
// Proxy events from underlying stream
|
|
77
|
+
options.stream.on("error", err => this.emit("error", err));
|
|
78
|
+
options.stream.on("close", () => this.emit("close"));
|
|
93
79
|
}
|
|
94
80
|
else {
|
|
95
81
|
super({
|
|
@@ -114,16 +100,17 @@ function normalizeWritable(stream) {
|
|
|
114
100
|
if (stream instanceof Writable) {
|
|
115
101
|
return stream;
|
|
116
102
|
}
|
|
117
|
-
// Node.js Writable:
|
|
103
|
+
// Node.js Writable: accept structurally even if typed as unknown.
|
|
118
104
|
if (stream instanceof stream_1.Writable) {
|
|
119
|
-
return stream;
|
|
105
|
+
return new Writable({ stream: stream });
|
|
120
106
|
}
|
|
121
107
|
// Web WritableStream: detect by getWriter() (avoid relying on global WritableStream).
|
|
122
108
|
if (stream?.getWriter) {
|
|
123
|
-
|
|
109
|
+
const nodeWritable = stream_1.Writable.fromWeb(stream);
|
|
110
|
+
return new Writable({ stream: nodeWritable });
|
|
124
111
|
}
|
|
125
|
-
// Assume it structurally matches Node's Writable.
|
|
126
|
-
return stream;
|
|
112
|
+
// Assume it structurally matches Node's Writable; wrap for consistent API.
|
|
113
|
+
return new Writable({ stream: stream });
|
|
127
114
|
}
|
|
128
115
|
// Import for internal use
|
|
129
116
|
const shared_1 = require("./shared.js");
|
|
@@ -236,13 +223,12 @@ function finished(stream, optionsOrCallback, callback) {
|
|
|
236
223
|
const promise = new Promise((resolve, reject) => {
|
|
237
224
|
const normalizedStream = toNodePipelineStream(stream);
|
|
238
225
|
stream_1.finished(normalizedStream, options, (err) => {
|
|
239
|
-
|
|
240
|
-
// If options.error === false, ignore errors and resolve.
|
|
241
|
-
if (err && options?.error !== false) {
|
|
226
|
+
if (err && !(options && options.error)) {
|
|
242
227
|
reject(err);
|
|
243
|
-
return;
|
|
244
228
|
}
|
|
245
|
-
|
|
229
|
+
else {
|
|
230
|
+
resolve();
|
|
231
|
+
}
|
|
246
232
|
});
|
|
247
233
|
});
|
|
248
234
|
if (cb) {
|
|
@@ -595,28 +581,13 @@ function addAbortSignal(signal, stream) {
|
|
|
595
581
|
stream.destroy(new Error("Aborted"));
|
|
596
582
|
return stream;
|
|
597
583
|
}
|
|
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
|
-
};
|
|
605
584
|
const onAbort = () => {
|
|
606
|
-
cleanup();
|
|
607
585
|
stream.destroy(new Error("Aborted"));
|
|
608
586
|
};
|
|
609
|
-
const onDone = () => {
|
|
610
|
-
cleanup();
|
|
611
|
-
};
|
|
612
|
-
const onError = () => {
|
|
613
|
-
cleanup();
|
|
614
|
-
};
|
|
615
587
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
616
|
-
stream.
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
stream.once?.("error", onError);
|
|
588
|
+
stream.on("close", () => {
|
|
589
|
+
signal.removeEventListener("abort", onAbort);
|
|
590
|
+
});
|
|
620
591
|
return stream;
|
|
621
592
|
}
|
|
622
593
|
/**
|
|
@@ -659,109 +630,56 @@ function compose(...transforms) {
|
|
|
659
630
|
if (len === 1 && isNativeTransform(transforms[0])) {
|
|
660
631
|
return transforms[0];
|
|
661
632
|
}
|
|
662
|
-
// Chain all transforms together
|
|
633
|
+
// Chain all transforms together
|
|
663
634
|
for (let i = 0; i < len - 1; i++) {
|
|
664
635
|
transforms[i].pipe(transforms[i + 1]);
|
|
665
636
|
}
|
|
637
|
+
// Create a Duplex that writes to first and reads from last
|
|
666
638
|
const first = transforms[0];
|
|
667
639
|
const last = transforms[len - 1];
|
|
668
|
-
//
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
while (true) {
|
|
678
|
-
const chunk = output.read();
|
|
679
|
-
if (chunk === null) {
|
|
680
|
-
break;
|
|
681
|
-
}
|
|
682
|
-
if (!target.push(chunk)) {
|
|
683
|
-
break;
|
|
684
|
-
}
|
|
640
|
+
// Create a PassThrough as the composed stream
|
|
641
|
+
const composed = new stream_1.PassThrough({ objectMode: first.readableObjectMode });
|
|
642
|
+
// Store original methods for forwarding
|
|
643
|
+
const passthroughWrite = composed.write.bind(composed);
|
|
644
|
+
const passthroughEnd = composed.end.bind(composed);
|
|
645
|
+
// Override write to write to first transform
|
|
646
|
+
composed.write = function (chunk, encodingOrCallback, callback) {
|
|
647
|
+
if (typeof encodingOrCallback === "function") {
|
|
648
|
+
return first.write(chunk, encodingOrCallback);
|
|
685
649
|
}
|
|
650
|
+
return first.write(chunk, encodingOrCallback, callback);
|
|
686
651
|
};
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
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
|
-
}
|
|
652
|
+
// Override end to end first transform
|
|
653
|
+
composed.end = function (chunkOrCallback, encodingOrCallback, callback) {
|
|
654
|
+
if (typeof chunkOrCallback === "function") {
|
|
655
|
+
first.end(chunkOrCallback);
|
|
730
656
|
}
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
cleanupListeners();
|
|
737
|
-
outputEnded = true;
|
|
738
|
-
composed.push(null);
|
|
739
|
-
};
|
|
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);
|
|
657
|
+
else if (typeof encodingOrCallback === "function") {
|
|
658
|
+
first.end(chunkOrCallback, encodingOrCallback);
|
|
659
|
+
}
|
|
660
|
+
else {
|
|
661
|
+
first.end(chunkOrCallback, encodingOrCallback, callback);
|
|
751
662
|
}
|
|
752
|
-
|
|
663
|
+
return composed;
|
|
753
664
|
};
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
|
|
665
|
+
// Override pipe to pipe from last transform
|
|
666
|
+
composed.pipe = function (dest) {
|
|
667
|
+
return last.pipe(dest);
|
|
668
|
+
};
|
|
669
|
+
// Forward data from last to composed
|
|
670
|
+
last.on("data", (chunk) => {
|
|
671
|
+
passthroughWrite(chunk);
|
|
672
|
+
});
|
|
673
|
+
// Forward end from last
|
|
674
|
+
last.on("end", () => {
|
|
675
|
+
passthroughEnd();
|
|
764
676
|
});
|
|
677
|
+
// Forward errors from any transform
|
|
678
|
+
for (const transform of transforms) {
|
|
679
|
+
transform.on("error", (err) => {
|
|
680
|
+
composed.emit("error", err);
|
|
681
|
+
});
|
|
682
|
+
}
|
|
765
683
|
return composed;
|
|
766
684
|
}
|
|
767
685
|
/**
|
|
@@ -842,7 +760,7 @@ function once(emitter, event, options) {
|
|
|
842
760
|
onAbort();
|
|
843
761
|
return;
|
|
844
762
|
}
|
|
845
|
-
options.signal.addEventListener("abort", onAbort
|
|
763
|
+
options.signal.addEventListener("abort", onAbort);
|
|
846
764
|
}
|
|
847
765
|
});
|
|
848
766
|
}
|
|
@@ -39,15 +39,3 @@ 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";
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
export class ByteQueue {
|
|
2
|
+
constructor(initial) {
|
|
3
|
+
this._start = 0;
|
|
4
|
+
this._end = 0;
|
|
5
|
+
this._cachedView = null;
|
|
6
|
+
this._cachedBuf = null;
|
|
7
|
+
this._cachedStart = 0;
|
|
8
|
+
this._cachedEnd = 0;
|
|
9
|
+
this._buf = new Uint8Array(0);
|
|
10
|
+
if (initial && initial.length > 0) {
|
|
11
|
+
this.reset(initial);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
get length() {
|
|
15
|
+
return this._end - this._start;
|
|
16
|
+
}
|
|
17
|
+
isEmpty() {
|
|
18
|
+
return this.length === 0;
|
|
19
|
+
}
|
|
20
|
+
view() {
|
|
21
|
+
if (this._start === this._end) {
|
|
22
|
+
return ByteQueue.EMPTY;
|
|
23
|
+
}
|
|
24
|
+
if (this._cachedView &&
|
|
25
|
+
this._cachedBuf === this._buf &&
|
|
26
|
+
this._cachedStart === this._start &&
|
|
27
|
+
this._cachedEnd === this._end) {
|
|
28
|
+
return this._cachedView;
|
|
29
|
+
}
|
|
30
|
+
const view = this._buf.subarray(this._start, this._end);
|
|
31
|
+
this._cachedView = view;
|
|
32
|
+
this._cachedBuf = this._buf;
|
|
33
|
+
this._cachedStart = this._start;
|
|
34
|
+
this._cachedEnd = this._end;
|
|
35
|
+
return view;
|
|
36
|
+
}
|
|
37
|
+
reset(data) {
|
|
38
|
+
this._cachedView = null;
|
|
39
|
+
this._cachedBuf = null;
|
|
40
|
+
if (!data || data.length === 0) {
|
|
41
|
+
this._buf = ByteQueue.EMPTY;
|
|
42
|
+
this._start = 0;
|
|
43
|
+
this._end = 0;
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
// Keep a private copy to ensure future writes cannot mutate the source.
|
|
47
|
+
const copy = new Uint8Array(data.length);
|
|
48
|
+
copy.set(data);
|
|
49
|
+
this._buf = copy;
|
|
50
|
+
this._start = 0;
|
|
51
|
+
this._end = copy.length;
|
|
52
|
+
}
|
|
53
|
+
append(chunk) {
|
|
54
|
+
if (chunk.length === 0) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
this._cachedView = null;
|
|
58
|
+
this._cachedBuf = null;
|
|
59
|
+
const unread = this.length;
|
|
60
|
+
// Fast path: enough tail room.
|
|
61
|
+
if (this._end + chunk.length <= this._buf.length) {
|
|
62
|
+
this._buf.set(chunk, this._end);
|
|
63
|
+
this._end += chunk.length;
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
// Allocate a new buffer and copy unread bytes (never compacts in-place).
|
|
67
|
+
const required = unread + chunk.length;
|
|
68
|
+
const nextSize = this._buf.length === 0 ? required : Math.max(this._buf.length * 2, required);
|
|
69
|
+
const next = new Uint8Array(nextSize);
|
|
70
|
+
if (unread > 0) {
|
|
71
|
+
next.set(this._buf.subarray(this._start, this._end), 0);
|
|
72
|
+
}
|
|
73
|
+
next.set(chunk, unread);
|
|
74
|
+
this._buf = next;
|
|
75
|
+
this._start = 0;
|
|
76
|
+
this._end = required;
|
|
77
|
+
}
|
|
78
|
+
read(length) {
|
|
79
|
+
if (length <= 0) {
|
|
80
|
+
return new Uint8Array(0);
|
|
81
|
+
}
|
|
82
|
+
if (length > this.length) {
|
|
83
|
+
throw new RangeError("ByteQueue: read beyond available data");
|
|
84
|
+
}
|
|
85
|
+
// Return a view for performance.
|
|
86
|
+
// To keep this safe for async consumers, we must ensure we never write into
|
|
87
|
+
// the same backing buffer again after it becomes fully consumed.
|
|
88
|
+
const out = this._buf.subarray(this._start, this._start + length);
|
|
89
|
+
this._start += length;
|
|
90
|
+
this._cachedView = null;
|
|
91
|
+
this._cachedBuf = null;
|
|
92
|
+
if (this._start === this._end) {
|
|
93
|
+
// Release backing storage to avoid reusing memory that might still be
|
|
94
|
+
// referenced by previously returned views.
|
|
95
|
+
this._buf = ByteQueue.EMPTY;
|
|
96
|
+
this._start = 0;
|
|
97
|
+
this._end = 0;
|
|
98
|
+
}
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
discard(length) {
|
|
102
|
+
if (length <= 0) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (length >= this.length) {
|
|
106
|
+
// Release backing storage for the same reason as read(): previously
|
|
107
|
+
// returned views may still be referenced by consumers.
|
|
108
|
+
this._buf = ByteQueue.EMPTY;
|
|
109
|
+
this._start = 0;
|
|
110
|
+
this._end = 0;
|
|
111
|
+
this._cachedView = null;
|
|
112
|
+
this._cachedBuf = null;
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
this._start += length;
|
|
116
|
+
this._cachedView = null;
|
|
117
|
+
this._cachedBuf = null;
|
|
118
|
+
if (this._start === this._end) {
|
|
119
|
+
this._buf = ByteQueue.EMPTY;
|
|
120
|
+
this._start = 0;
|
|
121
|
+
this._end = 0;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
ByteQueue.EMPTY = new Uint8Array(0);
|
|
@@ -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 "./byte-queue.js";
|
|
12
12
|
/**
|
|
13
13
|
* Default threshold (in bytes) to choose the lower-overhead path.
|
|
14
14
|
*
|
package/dist/{browser/modules/archive/compression → esm/modules/archive}/compress.browser.js
RENAMED
|
@@ -10,12 +10,20 @@
|
|
|
10
10
|
* - Safari >= 14.1
|
|
11
11
|
* - Edge >= 89
|
|
12
12
|
*/
|
|
13
|
-
import { compressWithStream, decompressWithStream,
|
|
13
|
+
import { compressWithStream, decompressWithStream, 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
|
-
|
|
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
|
+
}
|
|
19
27
|
/**
|
|
20
28
|
* Compress data using browser's native CompressionStream or JS fallback
|
|
21
29
|
*
|
|
@@ -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;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
export const
|
|
2
|
-
|
|
3
|
-
export const
|
|
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";
|
|
1
|
+
export const DEFAULT_COMPRESS_LEVEL = 6;
|
|
2
|
+
export const DEFAULT_ZIP_LEVEL = 6;
|
|
3
|
+
export const DEFAULT_ZIP_TIMESTAMPS = "dos+utc";
|
|
@@ -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
|
// ============================================================================
|
|
@@ -5,6 +5,9 @@
|
|
|
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
|
-
|
|
8
|
+
// ZIP builders
|
|
9
|
+
export { createZip, createZipSync, ZipBuilder } from "./zip-builder.js";
|
|
10
|
+
// Streaming ZIP (fflate-like API)
|
|
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";
|
|
@@ -6,8 +6,12 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export * from "./index.base.js";
|
|
8
8
|
// CRC32
|
|
9
|
-
export { crc32, crc32Update, crc32Finalize } from "./
|
|
9
|
+
export { crc32, crc32Update, crc32Finalize } from "./crc32.browser.js";
|
|
10
10
|
// Compression
|
|
11
|
-
export { compress, compressSync, decompress, decompressSync, hasCompressionStream } from "./
|
|
11
|
+
export { compress, compressSync, decompress, decompressSync, hasCompressionStream } from "./compress.browser.js";
|
|
12
12
|
// Streaming compression
|
|
13
|
-
export { createDeflateStream, createInflateStream, hasDeflateRaw } from "./
|
|
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)
|
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export * from "./index.base.js";
|
|
8
8
|
// CRC32
|
|
9
|
-
export { crc32, crc32Update, crc32Finalize } from "./
|
|
9
|
+
export { crc32, crc32Update, crc32Finalize } from "./crc32.js";
|
|
10
10
|
// Compression
|
|
11
|
-
export { compress, compressSync, decompress, decompressSync, hasCompressionStream } from "./
|
|
11
|
+
export { compress, compressSync, decompress, decompressSync, hasCompressionStream } from "./compress.js";
|
|
12
12
|
// Streaming compression
|
|
13
|
-
export { createDeflateStream, createInflateStream, hasDeflateRaw } from "./
|
|
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";
|