@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
|
@@ -25,3 +25,4 @@ export { WorkbookWriter, WorkbookReader, WorksheetWriter, WorksheetReader };
|
|
|
25
25
|
export type { CsvReadOptions, CsvWriteOptions, CsvStreamReadOptions, CsvStreamWriteOptions } from "./modules/csv/csv.browser.js";
|
|
26
26
|
export { CsvParserStream, CsvFormatterStream } from "./modules/csv/csv.browser.js";
|
|
27
27
|
export * from "./modules/excel/utils/sheet-utils.js";
|
|
28
|
+
export { zip, unzip, ZipArchive, ZipReader, UnzipEntry, type ZipOptions, type ZipEntryOptions, type UnzipOptions, type ArchiveSource, type ArchiveSink, crc32, crc32Update, crc32Finalize, compress, compressSync, decompress, decompressSync, hasCompressionStream, type CompressOptions, createDeflateStream, createInflateStream, hasDeflateRaw, type StreamCompressOptions } from "./modules/archive/index.browser.js";
|
package/dist/{browser/modules/archive → types/modules/archive/compression}/compress.browser.d.ts
RENAMED
|
@@ -10,15 +10,9 @@
|
|
|
10
10
|
* - Safari >= 14.1
|
|
11
11
|
* - Edge >= 89
|
|
12
12
|
*/
|
|
13
|
-
import { type CompressOptions } from "
|
|
13
|
+
import { type CompressOptions, hasCompressionStream } from "./compress.base.js";
|
|
14
14
|
export { type CompressOptions };
|
|
15
|
-
|
|
16
|
-
* Check if CompressionStream is available in this environment.
|
|
17
|
-
*
|
|
18
|
-
* Note: Some environments may expose CompressionStream but not support
|
|
19
|
-
* the "deflate-raw" format that ZIP requires.
|
|
20
|
-
*/
|
|
21
|
-
export declare function hasCompressionStream(): boolean;
|
|
15
|
+
export { hasCompressionStream };
|
|
22
16
|
/**
|
|
23
17
|
* Compress data using browser's native CompressionStream or JS fallback
|
|
24
18
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* API compatible with Node.js version - supports .on("data"), .on("end"), .write(callback), .end()
|
|
8
8
|
*/
|
|
9
|
-
export type { StreamCompressOptions } from "./streaming-compress.base.js";
|
|
9
|
+
export type { DeflateStream, InflateStream, StreamCompressOptions, StreamingCodec } from "./streaming-compress.base.js";
|
|
10
10
|
import { type DeflateStream, type InflateStream, type StreamCompressOptions } from "./streaming-compress.base.js";
|
|
11
11
|
/**
|
|
12
12
|
* Check if deflate-raw streaming compression is supported by this library.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ZipTimestampMode } from "./utils/timestamps.js";
|
|
2
|
+
export declare const DEFAULT_DEFLATE_LEVEL = 6;
|
|
2
3
|
export declare const DEFAULT_COMPRESS_LEVEL = 6;
|
|
3
4
|
export declare const DEFAULT_ZIP_LEVEL = 6;
|
|
4
5
|
export declare const DEFAULT_ZIP_TIMESTAMPS: ZipTimestampMode;
|
|
@@ -5,7 +5,7 @@
|
|
|
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
|
-
export
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export type
|
|
8
|
+
export type { ArchiveSource } from "./io/archive-source.js";
|
|
9
|
+
export type { ArchiveSink } from "./io/archive-sink.js";
|
|
10
|
+
export { zip, ZipArchive, type ZipOptions, type ZipEntryOptions } from "./zip/index.js";
|
|
11
|
+
export { unzip, ZipReader, UnzipEntry, type UnzipOptions } from "./unzip/index.js";
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* browser-specific implementations so we can enforce export-surface parity.
|
|
6
6
|
*/
|
|
7
7
|
export * from "./index.base.js";
|
|
8
|
-
export { crc32, crc32Update, crc32Finalize } from "./crc32.browser.js";
|
|
9
|
-
export { compress, compressSync, decompress, decompressSync, hasCompressionStream, type CompressOptions } from "./compress.browser.js";
|
|
10
|
-
export { createDeflateStream, createInflateStream, hasDeflateRaw, type StreamCompressOptions } from "./streaming-compress.browser.js";
|
|
11
|
-
export { Parse, createParse, type ParseOptions, type ZipEntry as StreamZipEntry } from "./parse.browser.js";
|
|
8
|
+
export { crc32, crc32Update, crc32Finalize } from "./compression/crc32.browser.js";
|
|
9
|
+
export { compress, compressSync, decompress, decompressSync, hasCompressionStream, type CompressOptions } from "./compression/compress.browser.js";
|
|
10
|
+
export { createDeflateStream, createInflateStream, hasDeflateRaw, type StreamCompressOptions } from "./compression/streaming-compress.browser.js";
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* It groups all ZIP creation and extraction utilities in one place.
|
|
6
6
|
*/
|
|
7
7
|
export * from "./index.base.js";
|
|
8
|
-
export { crc32, crc32Update, crc32Finalize } from "./crc32.js";
|
|
9
|
-
export { compress, compressSync, decompress, decompressSync, hasCompressionStream, type CompressOptions } from "./compress.js";
|
|
10
|
-
export { createDeflateStream, createInflateStream, hasDeflateRaw, type StreamCompressOptions } from "./streaming-compress.js";
|
|
11
|
-
export { Parse, createParse, type ParseOptions, type ZipEntry as StreamZipEntry } from "./parse.js";
|
|
8
|
+
export { crc32, crc32Update, crc32Finalize } from "./compression/crc32.js";
|
|
9
|
+
export { compress, compressSync, decompress, decompressSync, hasCompressionStream, type CompressOptions } from "./compression/compress.js";
|
|
10
|
+
export { createDeflateStream, createInflateStream, hasDeflateRaw, type StreamCompressOptions } from "./compression/streaming-compress.js";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare class ByteQueue {
|
|
2
|
+
private static readonly EMPTY;
|
|
3
|
+
private _chunks;
|
|
4
|
+
private _headOffset;
|
|
5
|
+
private _length;
|
|
6
|
+
private _cachedView;
|
|
7
|
+
private _cachedLength;
|
|
8
|
+
constructor(initial?: Uint8Array);
|
|
9
|
+
get length(): number;
|
|
10
|
+
isEmpty(): boolean;
|
|
11
|
+
view(): Uint8Array;
|
|
12
|
+
reset(data?: Uint8Array): void;
|
|
13
|
+
append(chunk: Uint8Array): void;
|
|
14
|
+
read(length: number): Uint8Array;
|
|
15
|
+
/**
|
|
16
|
+
* Return a list of chunk views totaling `length` bytes without consuming.
|
|
17
|
+
*
|
|
18
|
+
* This avoids materializing a contiguous buffer for streaming write paths.
|
|
19
|
+
*/
|
|
20
|
+
peekChunks(length: number): Uint8Array[];
|
|
21
|
+
discard(length: number): void;
|
|
22
|
+
/**
|
|
23
|
+
* Find the first index of `pattern` within the queue.
|
|
24
|
+
*
|
|
25
|
+
* This avoids materializing a contiguous `view()` for common small patterns
|
|
26
|
+
* (ZIP signatures are typically 2-4 bytes).
|
|
27
|
+
*/
|
|
28
|
+
indexOfPattern(pattern: Uint8Array, startIndex?: number): number;
|
|
29
|
+
/** Peek a little-endian uint32 at `offset` without consuming bytes. Returns null if not enough bytes. */
|
|
30
|
+
peekUint32LE(offset: number): number | null;
|
|
31
|
+
/** Peek a single byte at `offset` without consuming bytes. */
|
|
32
|
+
peekByte(offset: number): number;
|
|
33
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type ArchiveSink = WritableStream<Uint8Array> | {
|
|
2
|
+
write(chunk: Uint8Array): any;
|
|
3
|
+
end?(cb?: any): any;
|
|
4
|
+
on?(event: string, listener: (...args: any[]) => void): any;
|
|
5
|
+
once?(event: string, listener: (...args: any[]) => void): any;
|
|
6
|
+
};
|
|
7
|
+
export declare function isWritableStream(value: unknown): value is WritableStream<Uint8Array>;
|
|
8
|
+
export declare function pipeIterableToSink(iterable: AsyncIterable<Uint8Array>, sink: ArchiveSink): Promise<void>;
|
|
9
|
+
export declare function collect(iterable: AsyncIterable<Uint8Array>): Promise<Uint8Array>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type ArchiveSource = Uint8Array | ArrayBuffer | string | Blob | AsyncIterable<unknown> | ReadableStream<unknown> | {
|
|
2
|
+
[Symbol.asyncIterator](): AsyncIterator<unknown>;
|
|
3
|
+
};
|
|
4
|
+
export declare function isReadableStream(value: unknown): value is ReadableStream<unknown>;
|
|
5
|
+
export declare function isAsyncIterable(value: unknown): value is AsyncIterable<unknown>;
|
|
6
|
+
export declare function toUint8ArraySync(source: Uint8Array | ArrayBuffer | string): Uint8Array;
|
|
7
|
+
export declare function toUint8Array(source: Uint8Array | ArrayBuffer | string | Blob): Promise<Uint8Array>;
|
|
8
|
+
export declare function toAsyncIterable(source: ArchiveSource): AsyncIterable<Uint8Array>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ZipParser, type ZipEntryInfo } from "./zip-parser.js";
|
|
2
|
+
import { type ParseOptions, type ZipEntry as ParseZipEntry } from "./stream.js";
|
|
3
|
+
import { type ArchiveSink } from "../io/archive-sink.js";
|
|
4
|
+
import { type ArchiveSource } from "../io/archive-source.js";
|
|
5
|
+
export interface UnzipOptions {
|
|
6
|
+
decodeStrings?: boolean;
|
|
7
|
+
parse?: ParseOptions;
|
|
8
|
+
}
|
|
9
|
+
export declare class UnzipEntry {
|
|
10
|
+
readonly path: string;
|
|
11
|
+
readonly isDirectory: boolean;
|
|
12
|
+
private readonly _info?;
|
|
13
|
+
private readonly _parser?;
|
|
14
|
+
private readonly _parseEntry?;
|
|
15
|
+
constructor(args: {
|
|
16
|
+
kind: "buffer";
|
|
17
|
+
parser: ZipParser;
|
|
18
|
+
info: ZipEntryInfo;
|
|
19
|
+
} | {
|
|
20
|
+
kind: "stream";
|
|
21
|
+
entry: ParseZipEntry;
|
|
22
|
+
});
|
|
23
|
+
bytes(): Promise<Uint8Array>;
|
|
24
|
+
stream(): AsyncIterable<Uint8Array>;
|
|
25
|
+
pipeTo(sink: ArchiveSink): Promise<void>;
|
|
26
|
+
text(encoding?: string): Promise<string>;
|
|
27
|
+
discard(): void;
|
|
28
|
+
}
|
|
29
|
+
export declare class ZipReader {
|
|
30
|
+
private readonly _source;
|
|
31
|
+
private readonly _options;
|
|
32
|
+
private _bufferParser;
|
|
33
|
+
constructor(source: ArchiveSource, options?: UnzipOptions);
|
|
34
|
+
private _ensureBufferParser;
|
|
35
|
+
get(path: string): Promise<UnzipEntry | null>;
|
|
36
|
+
entries(): AsyncIterable<UnzipEntry>;
|
|
37
|
+
bytes(path: string): Promise<Uint8Array | null>;
|
|
38
|
+
close(): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
export declare function unzip(source: ArchiveSource, options?: UnzipOptions): ZipReader;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Duplex, PassThrough, Transform, type Readable } from "
|
|
2
|
-
import { ByteQueue } from "
|
|
3
|
-
import { parseZipExtraFields, type ZipExtraFields, type ZipVars } from "
|
|
1
|
+
import { Duplex, PassThrough, Transform, type Readable } from "../../stream/index.js";
|
|
2
|
+
import { ByteQueue } from "../internal/byte-queue.js";
|
|
3
|
+
import { parseZipExtraFields, type ZipExtraFields, type ZipVars } from "../utils/zip-extra-fields.js";
|
|
4
|
+
export declare const DATA_DESCRIPTOR_SIGNATURE_BYTES: Uint8Array<ArrayBufferLike>;
|
|
4
5
|
export declare const CRX_HEADER_FORMAT: [string, number][];
|
|
5
6
|
export declare const LOCAL_FILE_HEADER_FORMAT: [string, number][];
|
|
6
7
|
export declare const DATA_DESCRIPTOR_FORMAT: [string, number][];
|
|
@@ -119,9 +120,14 @@ export interface ValidatedDataDescriptorScanResult {
|
|
|
119
120
|
*/
|
|
120
121
|
export declare function scanValidatedDataDescriptor(view: Uint8Array, dataDescriptorSignature: Uint8Array, bytesEmitted: number, startIndex?: number, out?: ValidatedDataDescriptorScanResult): ValidatedDataDescriptorScanResult;
|
|
121
122
|
export interface StreamUntilValidatedDataDescriptorSource {
|
|
122
|
-
getView(): Uint8Array;
|
|
123
123
|
getLength(): number;
|
|
124
124
|
read(length: number): Uint8Array;
|
|
125
|
+
/** Optional: zero-copy chunk views for streaming writes. */
|
|
126
|
+
peekChunks?(length: number): Uint8Array[];
|
|
127
|
+
/** Optional: consume bytes previously written from peekChunks(). */
|
|
128
|
+
discard?(length: number): void;
|
|
129
|
+
indexOfPattern(pattern: Uint8Array, startIndex: number): number;
|
|
130
|
+
peekUint32LE(offset: number): number | null;
|
|
125
131
|
isFinished(): boolean;
|
|
126
132
|
onDataAvailable(cb: () => void): () => void;
|
|
127
133
|
maybeReleaseWriteCallback?: () => void;
|
|
@@ -142,6 +148,34 @@ export declare function streamUntilValidatedDataDescriptor(options: StreamUntilV
|
|
|
142
148
|
export interface ParseOptions {
|
|
143
149
|
verbose?: boolean;
|
|
144
150
|
forceStream?: boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Browser-only: use a Web Worker to run inflate off the main thread.
|
|
153
|
+
* Defaults to false.
|
|
154
|
+
*/
|
|
155
|
+
useWorkerInflate?: boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Browser-only: provide an explicit Worker script URL.
|
|
158
|
+
*
|
|
159
|
+
* Useful under strict CSP that blocks `blob:` workers. When set, the browser
|
|
160
|
+
* parser will try to construct `new Worker(workerInflateUrl)`.
|
|
161
|
+
*/
|
|
162
|
+
workerInflateUrl?: string;
|
|
163
|
+
/**
|
|
164
|
+
* Input backpressure high-water mark (bytes).
|
|
165
|
+
*
|
|
166
|
+
* When provided, implementations may delay the writable callback until the
|
|
167
|
+
* internal input buffer drops below `inputLowWaterMarkBytes`.
|
|
168
|
+
*
|
|
169
|
+
* This is primarily used by the browser parser, because its writable side
|
|
170
|
+
* otherwise tends to accept unlimited data and can cause large memory spikes.
|
|
171
|
+
*/
|
|
172
|
+
inputHighWaterMarkBytes?: number;
|
|
173
|
+
/**
|
|
174
|
+
* Input backpressure low-water mark (bytes).
|
|
175
|
+
* When the internal buffer drops to (or below) this value, a delayed writable
|
|
176
|
+
* callback may be released.
|
|
177
|
+
*/
|
|
178
|
+
inputLowWaterMarkBytes?: number;
|
|
145
179
|
/**
|
|
146
180
|
* Threshold (in bytes) for small file optimization.
|
|
147
181
|
* Files smaller than this will use sync decompression (no stream overhead).
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* Falls back to pure JavaScript implementation for older browsers.
|
|
6
6
|
* Uses the browser Duplex stream implementation for compatibility.
|
|
7
7
|
*/
|
|
8
|
-
import { Duplex } from "
|
|
9
|
-
import { type CrxHeader, type PullStreamPublicApi, type EntryProps, type EntryVars, type InflateFactory, type ParseOptions, type ZipEntry } from "./
|
|
8
|
+
import { Duplex } from "../../stream/index.js";
|
|
9
|
+
import { type CrxHeader, type PullStreamPublicApi, type EntryProps, type EntryVars, type InflateFactory, type ParseOptions, type ZipEntry } from "./stream.base.js";
|
|
10
10
|
export type { CrxHeader, EntryProps, EntryVars, ParseOptions, ZipEntry };
|
|
11
11
|
export type ParseStream = Duplex & {
|
|
12
12
|
promise(): Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Duplex } from "
|
|
2
|
-
import { type PullStreamPublicApi, type CrxHeader, type EntryProps, type EntryVars, type InflateFactory, type ParseOptions, type ZipEntry } from "./
|
|
3
|
-
export type { CrxHeader } from "./
|
|
1
|
+
import type { Duplex } from "../../stream/index.js";
|
|
2
|
+
import { type PullStreamPublicApi, type CrxHeader, type EntryProps, type EntryVars, type InflateFactory, type ParseOptions, type ZipEntry } from "./stream.base.js";
|
|
3
|
+
export type { CrxHeader } from "./stream.base.js";
|
|
4
4
|
export type { EntryProps, EntryVars, ParseOptions, ZipEntry };
|
|
5
5
|
export type ParseStream = Duplex & {
|
|
6
6
|
promise(): Promise<void>;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Works in both Node.js and browser environments
|
|
4
4
|
* No dependency on Node.js stream module
|
|
5
5
|
*/
|
|
6
|
-
import type { ZipEntryInfo } from "
|
|
6
|
+
import type { ZipEntryInfo } from "../zip-spec/zip-entry-info.js";
|
|
7
7
|
export type { ZipEntryInfo };
|
|
8
8
|
/**
|
|
9
9
|
* ZIP parsing options
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Heuristic: detect incompressible (high-entropy) data.
|
|
3
|
+
*
|
|
4
|
+
* This is a performance optimization: if data looks random, DEFLATE usually
|
|
5
|
+
* wastes CPU and may even produce slightly larger output.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isProbablyIncompressible(data: Uint8Array, options?: {
|
|
8
|
+
sampleBytes?: number;
|
|
9
|
+
minDecisionBytes?: number;
|
|
10
|
+
}): boolean;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface PatternSearchTarget {
|
|
2
|
+
indexOfPattern(pattern: Uint8Array, startIndex: number): number;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Stateful helper for incremental pattern scanning in growing buffers.
|
|
6
|
+
*
|
|
7
|
+
* The scanner tracks a `searchFrom` cursor and an `overlap` region so callers
|
|
8
|
+
* can avoid rescanning bytes that cannot start a match.
|
|
9
|
+
*/
|
|
10
|
+
export declare class PatternScanner {
|
|
11
|
+
readonly pattern: Uint8Array;
|
|
12
|
+
readonly overlap: number;
|
|
13
|
+
searchFrom: number;
|
|
14
|
+
constructor(pattern: Uint8Array);
|
|
15
|
+
/** Find the next match index starting at the current `searchFrom`. */
|
|
16
|
+
find(target: PatternSearchTarget): number;
|
|
17
|
+
/** Update `searchFrom` after consuming `consumed` bytes from the front. */
|
|
18
|
+
onConsume(consumed: number): void;
|
|
19
|
+
/** Update `searchFrom` after a no-match scan on a buffer of length `bufferLength`. */
|
|
20
|
+
onNoMatch(bufferLength: number): void;
|
|
21
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ZIP extra field parsing helpers.
|
|
3
3
|
*
|
|
4
|
-
* Kept standalone so both streaming parser (`
|
|
4
|
+
* Kept standalone so both streaming parser (`stream.base.ts`) and buffer parser
|
|
5
5
|
* (`zip-parser.ts`) can share ZIP64 + Info-ZIP timestamp handling.
|
|
6
6
|
*/
|
|
7
7
|
export interface ZipVars {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ZipTimestampMode } from "../utils/timestamps.js";
|
|
2
|
+
import { type ArchiveSink } from "../io/archive-sink.js";
|
|
3
|
+
import { type ArchiveSource } from "../io/archive-source.js";
|
|
4
|
+
export interface ZipOptions {
|
|
5
|
+
level?: number;
|
|
6
|
+
timestamps?: ZipTimestampMode;
|
|
7
|
+
comment?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Default modification time for entries that don't specify `modTime`.
|
|
10
|
+
*
|
|
11
|
+
* If you need stable output across runs, either pass this explicitly or use `reproducible: true`.
|
|
12
|
+
*/
|
|
13
|
+
modTime?: Date;
|
|
14
|
+
/**
|
|
15
|
+
* If true, bias defaults toward reproducible output:
|
|
16
|
+
* - default `modTime` becomes 1980-01-01 00:00:00 (local time)
|
|
17
|
+
* - default `timestamps` becomes "dos" (no UTC extra field)
|
|
18
|
+
*/
|
|
19
|
+
reproducible?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* If true (default), automatically STORE incompressible data.
|
|
22
|
+
* If false, always follow `level` (DEFLATE when level > 0).
|
|
23
|
+
*/
|
|
24
|
+
smartStore?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface ZipEntryOptions {
|
|
27
|
+
level?: number;
|
|
28
|
+
modTime?: Date;
|
|
29
|
+
comment?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare class ZipArchive {
|
|
32
|
+
private readonly _options;
|
|
33
|
+
private readonly _entries;
|
|
34
|
+
private _sealed;
|
|
35
|
+
constructor(options?: ZipOptions);
|
|
36
|
+
add(name: string, source: ArchiveSource, options?: ZipEntryOptions): this;
|
|
37
|
+
stream(): AsyncIterable<Uint8Array>;
|
|
38
|
+
bytes(): Promise<Uint8Array>;
|
|
39
|
+
bytesSync(): Uint8Array;
|
|
40
|
+
pipeTo(sink: ArchiveSink): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
export declare function zip(options?: ZipOptions): ZipArchive;
|
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
* True Streaming ZIP creator - shared implementation.
|
|
3
3
|
*
|
|
4
4
|
* This module is intentionally platform-agnostic.
|
|
5
|
-
* - In Node builds it uses `./crc32` + `./streaming-compress` (zlib-backed).
|
|
5
|
+
* - In Node builds it uses `./compression/crc32` + `./compression/streaming-compress` (zlib-backed).
|
|
6
6
|
* - In browser builds the bundler aliases those imports to their browser variants.
|
|
7
7
|
*/
|
|
8
|
-
import type { ZipTimestampMode } from "
|
|
9
|
-
import type { ZipEntryInfo as UnzipZipEntryInfo } from "
|
|
8
|
+
import type { ZipTimestampMode } from "../utils/timestamps.js";
|
|
9
|
+
import type { ZipEntryInfo as UnzipZipEntryInfo } from "../zip-spec/zip-entry-info.js";
|
|
10
10
|
/**
|
|
11
11
|
* Internal entry info for central directory
|
|
12
12
|
*/
|
|
13
13
|
interface ZipEntryInfo {
|
|
14
14
|
name: Uint8Array;
|
|
15
15
|
extraField: Uint8Array;
|
|
16
|
+
comment: Uint8Array;
|
|
16
17
|
flags: number;
|
|
17
18
|
crc: number;
|
|
18
19
|
compressedSize: number;
|
|
@@ -34,43 +35,62 @@ export declare class ZipDeflateFile {
|
|
|
34
35
|
private _finalized;
|
|
35
36
|
private _headerEmitted;
|
|
36
37
|
private _ondata;
|
|
38
|
+
private _onerror;
|
|
37
39
|
private _centralDirEntryInfo;
|
|
38
40
|
private _pendingEnd;
|
|
39
41
|
private _emittedDataDescriptor;
|
|
40
42
|
private _localHeader;
|
|
43
|
+
private _deflateWanted;
|
|
44
|
+
private _pendingChunks;
|
|
45
|
+
private _sampleBuffer;
|
|
46
|
+
private _sampleLen;
|
|
47
|
+
private _smartStore;
|
|
41
48
|
private _completeResolve;
|
|
42
49
|
private _completeReject;
|
|
43
50
|
private _completePromise;
|
|
44
51
|
private _completeError;
|
|
45
52
|
private _dataQueue;
|
|
46
53
|
private _finalQueued;
|
|
54
|
+
private _pushChain;
|
|
47
55
|
readonly name: string;
|
|
48
56
|
readonly level: number;
|
|
49
57
|
readonly nameBytes: Uint8Array;
|
|
58
|
+
readonly commentBytes: Uint8Array;
|
|
50
59
|
readonly dosTime: number;
|
|
51
60
|
readonly dosDate: number;
|
|
52
61
|
readonly extraField: Uint8Array;
|
|
53
62
|
private readonly _flags;
|
|
54
|
-
private
|
|
63
|
+
private _compressionMethod;
|
|
55
64
|
private readonly _modTime;
|
|
56
65
|
constructor(name: string, options?: {
|
|
57
66
|
level?: number;
|
|
58
67
|
modTime?: Date;
|
|
59
68
|
timestamps?: ZipTimestampMode;
|
|
69
|
+
comment?: string;
|
|
70
|
+
smartStore?: boolean;
|
|
60
71
|
});
|
|
72
|
+
private _buildCompressionMethod;
|
|
73
|
+
private _initDeflateStream;
|
|
61
74
|
private _buildLocalHeader;
|
|
75
|
+
private _accumulateSample;
|
|
76
|
+
private _shouldDecide;
|
|
77
|
+
private _decideCompressionIfNeeded;
|
|
78
|
+
private _emitHeaderIfNeeded;
|
|
79
|
+
private _flushPendingChunks;
|
|
62
80
|
private _enqueueData;
|
|
63
81
|
private _flushQueue;
|
|
64
82
|
get ondata(): ((data: Uint8Array, final: boolean) => void) | undefined;
|
|
65
83
|
set ondata(cb: (data: Uint8Array, final: boolean) => void);
|
|
84
|
+
get onerror(): ((err: Error) => void) | undefined;
|
|
85
|
+
set onerror(cb: (err: Error) => void);
|
|
66
86
|
private _resolveComplete;
|
|
67
87
|
private _rejectComplete;
|
|
68
88
|
private _ensureCompletePromise;
|
|
69
89
|
private _tapCallback;
|
|
70
|
-
private _emitHeaderIfNeeded;
|
|
71
90
|
private _writeData;
|
|
72
91
|
private _endDeflateAndWait;
|
|
73
92
|
private _finalizeAfterWrite;
|
|
93
|
+
private _pushUnchained;
|
|
74
94
|
/**
|
|
75
95
|
* Push data - immediately compresses and outputs
|
|
76
96
|
* Returns a Promise that resolves when the write is complete.
|
|
@@ -108,10 +128,13 @@ export declare class StreamingZip {
|
|
|
108
128
|
private currentOffset;
|
|
109
129
|
private ended;
|
|
110
130
|
private endPending;
|
|
131
|
+
private zipComment;
|
|
111
132
|
private fileQueue;
|
|
112
133
|
private fileQueueIndex;
|
|
113
134
|
private activeFile;
|
|
114
|
-
constructor(callback: (err: Error | null, data: Uint8Array, final: boolean) => void
|
|
135
|
+
constructor(callback: (err: Error | null, data: Uint8Array, final: boolean) => void, options?: {
|
|
136
|
+
comment?: string;
|
|
137
|
+
});
|
|
115
138
|
add(file: ZipDeflateFile): void;
|
|
116
139
|
private _processNextFile;
|
|
117
140
|
private _finalize;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ZIP file format encoder (single-buffer output)
|
|
3
|
+
*
|
|
4
|
+
* Implements ZIP file structure according to PKWARE's APPNOTE.TXT specification
|
|
5
|
+
* https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
|
|
6
|
+
*
|
|
7
|
+
* This module focuses on producing a complete ZIP as a single Uint8Array.
|
|
8
|
+
* For true streaming (push chunks while reading sources), use `zip()` / `ZipArchive.stream()`.
|
|
9
|
+
*/
|
|
10
|
+
import { type CompressOptions } from "../compression/compress.js";
|
|
11
|
+
import { type ZipTimestampMode } from "../utils/timestamps.js";
|
|
12
|
+
/**
|
|
13
|
+
* ZIP file entry
|
|
14
|
+
*/
|
|
15
|
+
export interface ZipEntry {
|
|
16
|
+
/** File name (can include directory path, use forward slashes) */
|
|
17
|
+
name: string;
|
|
18
|
+
/** File data (will be compressed unless level=0) */
|
|
19
|
+
data: Uint8Array;
|
|
20
|
+
/** Optional per-entry compression level override */
|
|
21
|
+
level?: number;
|
|
22
|
+
/** File modification time (optional, defaults to current time) */
|
|
23
|
+
modTime?: Date;
|
|
24
|
+
/** File comment (optional) */
|
|
25
|
+
comment?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* ZIP encoder options
|
|
29
|
+
*/
|
|
30
|
+
export interface ZipOptions extends CompressOptions {
|
|
31
|
+
/** ZIP file comment (optional) */
|
|
32
|
+
comment?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Default modification time for entries that don't specify `modTime`.
|
|
35
|
+
*
|
|
36
|
+
* If you need stable output across runs, either pass this explicitly or use `reproducible: true`.
|
|
37
|
+
*/
|
|
38
|
+
modTime?: Date;
|
|
39
|
+
/**
|
|
40
|
+
* If true, bias defaults toward reproducible output:
|
|
41
|
+
* - default `modTime` becomes 1980-01-01 00:00:00 (local time)
|
|
42
|
+
* - default `timestamps` becomes "dos" (no UTC extra field)
|
|
43
|
+
*/
|
|
44
|
+
reproducible?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Max number of entries to compress concurrently in `createZip()`.
|
|
47
|
+
* This helps avoid zlib threadpool saturation / memory spikes with many files.
|
|
48
|
+
*
|
|
49
|
+
* Defaults to 4.
|
|
50
|
+
*/
|
|
51
|
+
concurrency?: number;
|
|
52
|
+
/**
|
|
53
|
+
* If true (default), automatically STORE incompressible data.
|
|
54
|
+
* If false, always follow `level` (DEFLATE when level > 0).
|
|
55
|
+
*/
|
|
56
|
+
smartStore?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Timestamp writing strategy.
|
|
59
|
+
* - "dos": only write DOS date/time fields (smallest output)
|
|
60
|
+
* - "dos+utc": also write UTC mtime in 0x5455 extra field
|
|
61
|
+
*/
|
|
62
|
+
timestamps?: ZipTimestampMode;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Create a ZIP file from entries (async)
|
|
66
|
+
*/
|
|
67
|
+
export declare function createZip(entries: ZipEntry[], options?: ZipOptions): Promise<Uint8Array>;
|
|
68
|
+
/**
|
|
69
|
+
* Create a ZIP file from entries (sync)
|
|
70
|
+
*
|
|
71
|
+
* This is supported in both Node.js and browser builds.
|
|
72
|
+
*/
|
|
73
|
+
export declare function createZipSync(entries: ZipEntry[], options?: ZipOptions): Uint8Array;
|
|
@@ -3,6 +3,23 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Shared by streaming zip writer and buffer zip builder.
|
|
5
5
|
*/
|
|
6
|
+
export declare const LOCAL_FILE_HEADER_SIG = 67324752;
|
|
7
|
+
export declare const CENTRAL_DIR_HEADER_SIG = 33639248;
|
|
8
|
+
export declare const END_OF_CENTRAL_DIR_SIG = 101010256;
|
|
9
|
+
export declare const DATA_DESCRIPTOR_SIG = 134695760;
|
|
10
|
+
export declare const ZIP64_END_OF_CENTRAL_DIR_SIG = 101075792;
|
|
11
|
+
export declare const ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIG = 117853008;
|
|
12
|
+
export declare const VERSION_NEEDED = 20;
|
|
13
|
+
export declare const VERSION_MADE_BY = 20;
|
|
14
|
+
export declare const COMPRESSION_STORE = 0;
|
|
15
|
+
export declare const COMPRESSION_DEFLATE = 8;
|
|
16
|
+
export declare const FLAG_UTF8 = 2048;
|
|
17
|
+
export declare const FLAG_DATA_DESCRIPTOR = 8;
|
|
18
|
+
export declare const UINT16_MAX = 65535;
|
|
19
|
+
export declare const UINT32_MAX = 4294967295;
|
|
20
|
+
export declare const ZIP_LOCAL_FILE_HEADER_FIXED_SIZE = 30;
|
|
21
|
+
export declare const ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE = 46;
|
|
22
|
+
export declare const ZIP_END_OF_CENTRAL_DIR_FIXED_SIZE = 22;
|
|
6
23
|
export interface ZipLocalFileHeaderInput {
|
|
7
24
|
fileName: Uint8Array;
|
|
8
25
|
extraField: Uint8Array;
|
|
@@ -15,6 +32,7 @@ export interface ZipLocalFileHeaderInput {
|
|
|
15
32
|
uncompressedSize: number;
|
|
16
33
|
versionNeeded?: number;
|
|
17
34
|
}
|
|
35
|
+
export declare function writeLocalFileHeaderInto(out: Uint8Array, view: DataView, offset: number, input: ZipLocalFileHeaderInput): number;
|
|
18
36
|
export declare function buildLocalFileHeader(input: ZipLocalFileHeaderInput): Uint8Array;
|
|
19
37
|
export interface ZipCentralDirectoryHeaderInput {
|
|
20
38
|
fileName: Uint8Array;
|
|
@@ -32,6 +50,7 @@ export interface ZipCentralDirectoryHeaderInput {
|
|
|
32
50
|
versionNeeded?: number;
|
|
33
51
|
externalAttributes?: number;
|
|
34
52
|
}
|
|
53
|
+
export declare function writeCentralDirectoryHeaderInto(out: Uint8Array, view: DataView, offset: number, input: ZipCentralDirectoryHeaderInput): number;
|
|
35
54
|
export declare function buildCentralDirectoryHeader(input: ZipCentralDirectoryHeaderInput): Uint8Array;
|
|
36
55
|
export interface ZipEndOfCentralDirectoryInput {
|
|
37
56
|
entryCount: number;
|
|
@@ -39,5 +58,6 @@ export interface ZipEndOfCentralDirectoryInput {
|
|
|
39
58
|
centralDirOffset: number;
|
|
40
59
|
comment: Uint8Array;
|
|
41
60
|
}
|
|
61
|
+
export declare function writeEndOfCentralDirectoryInto(out: Uint8Array, view: DataView, offset: number, input: ZipEndOfCentralDirectoryInput): number;
|
|
42
62
|
export declare function buildEndOfCentralDirectory(input: ZipEndOfCentralDirectoryInput): Uint8Array;
|
|
43
63
|
export declare function buildDataDescriptor(crc32: number, compressedSize: number, uncompressedSize: number): Uint8Array<ArrayBuffer>;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Node.js uses `workbook-writer.ts`, which extends the same base implementation
|
|
8
8
|
* with filesystem-specific features (filename output + image loading).
|
|
9
9
|
*/
|
|
10
|
-
import { Zip } from "../../archive/
|
|
10
|
+
import { Zip } from "../../archive/zip/stream.js";
|
|
11
11
|
import { StreamBuf } from "../utils/stream-buf.js";
|
|
12
12
|
import { StylesXform } from "../xlsx/xform/style/styles-xform.js";
|
|
13
13
|
import { SharedStrings } from "../utils/shared-strings.js";
|