@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
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ZIP format constants (PKWARE APPNOTE)
|
|
3
|
+
* Shared by ZIP writer and parser implementations.
|
|
4
|
+
*/
|
|
5
|
+
export declare const LOCAL_FILE_HEADER_SIG = 67324752;
|
|
6
|
+
export declare const CENTRAL_DIR_HEADER_SIG = 33639248;
|
|
7
|
+
export declare const END_OF_CENTRAL_DIR_SIG = 101010256;
|
|
8
|
+
export declare const DATA_DESCRIPTOR_SIG = 134695760;
|
|
9
|
+
export declare const ZIP64_END_OF_CENTRAL_DIR_SIG = 101075792;
|
|
10
|
+
export declare const ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIG = 117853008;
|
|
11
|
+
export declare const VERSION_NEEDED = 20;
|
|
12
|
+
export declare const VERSION_MADE_BY = 20;
|
|
13
|
+
export declare const COMPRESSION_STORE = 0;
|
|
14
|
+
export declare const COMPRESSION_DEFLATE = 8;
|
|
15
|
+
export declare const FLAG_UTF8 = 2048;
|
|
16
|
+
export declare const FLAG_DATA_DESCRIPTOR = 8;
|
|
17
|
+
export declare const UINT16_MAX = 65535;
|
|
18
|
+
export declare const UINT32_MAX = 4294967295;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ZIP format constants (PKWARE APPNOTE)
|
|
3
|
+
* Shared by ZIP writer and parser implementations.
|
|
4
|
+
*/
|
|
5
|
+
// Signatures
|
|
6
|
+
export const LOCAL_FILE_HEADER_SIG = 0x04034b50;
|
|
7
|
+
export const CENTRAL_DIR_HEADER_SIG = 0x02014b50;
|
|
8
|
+
export const END_OF_CENTRAL_DIR_SIG = 0x06054b50;
|
|
9
|
+
export const DATA_DESCRIPTOR_SIG = 0x08074b50;
|
|
10
|
+
export const ZIP64_END_OF_CENTRAL_DIR_SIG = 0x06064b50;
|
|
11
|
+
export const ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIG = 0x07064b50;
|
|
12
|
+
// Versions
|
|
13
|
+
export const VERSION_NEEDED = 20; // 2.0 - supports DEFLATE
|
|
14
|
+
export const VERSION_MADE_BY = 20; // 2.0
|
|
15
|
+
// Compression methods
|
|
16
|
+
export const COMPRESSION_STORE = 0;
|
|
17
|
+
export const COMPRESSION_DEFLATE = 8;
|
|
18
|
+
// General purpose bit flags
|
|
19
|
+
export const FLAG_UTF8 = 0x0800;
|
|
20
|
+
export const FLAG_DATA_DESCRIPTOR = 0x0008;
|
|
21
|
+
// ZIP64 / sentinel sizes
|
|
22
|
+
export const UINT16_MAX = 0xffff;
|
|
23
|
+
export const UINT32_MAX = 0xffffffff;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { encodeUtf8 } from "
|
|
2
|
-
import { buildZipTimestampExtraField, dateToZipDos } from "
|
|
3
|
-
import { COMPRESSION_DEFLATE, COMPRESSION_STORE, FLAG_DATA_DESCRIPTOR, FLAG_UTF8 } from "
|
|
1
|
+
import { encodeUtf8 } from "./utils/text.js";
|
|
2
|
+
import { buildZipTimestampExtraField, dateToZipDos } from "./utils/timestamps.js";
|
|
3
|
+
import { COMPRESSION_DEFLATE, COMPRESSION_STORE, FLAG_DATA_DESCRIPTOR, FLAG_UTF8 } from "./zip-constants.js";
|
|
4
4
|
export function resolveZipCompressionMethod(deflate) {
|
|
5
5
|
return deflate ? COMPRESSION_DEFLATE : COMPRESSION_STORE;
|
|
6
6
|
}
|
|
@@ -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 "@archive/zip-entry-info";
|
|
7
7
|
export type { ZipEntryInfo };
|
|
8
8
|
/**
|
|
9
9
|
* ZIP parsing options
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* Works in both Node.js and browser environments
|
|
4
4
|
* No dependency on Node.js stream module
|
|
5
5
|
*/
|
|
6
|
-
import { decompress, decompressSync } from "
|
|
7
|
-
import { BinaryReader } from "
|
|
8
|
-
import { resolveZipLastModifiedDateFromUnixSeconds } from "
|
|
9
|
-
import { parseZipExtraFields } from "
|
|
10
|
-
import { CENTRAL_DIR_HEADER_SIG, COMPRESSION_DEFLATE, COMPRESSION_STORE, LOCAL_FILE_HEADER_SIG, UINT16_MAX, UINT32_MAX, ZIP64_END_OF_CENTRAL_DIR_SIG } from "
|
|
6
|
+
import { decompress, decompressSync } from "./compress.browser.js";
|
|
7
|
+
import { BinaryReader } from "./utils/binary.js";
|
|
8
|
+
import { resolveZipLastModifiedDateFromUnixSeconds } from "./utils/timestamps.js";
|
|
9
|
+
import { parseZipExtraFields } from "./utils/zip-extra-fields.js";
|
|
10
|
+
import { CENTRAL_DIR_HEADER_SIG, COMPRESSION_DEFLATE, COMPRESSION_STORE, END_OF_CENTRAL_DIR_SIG, LOCAL_FILE_HEADER_SIG, UINT16_MAX, UINT32_MAX, ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIG, ZIP64_END_OF_CENTRAL_DIR_SIG } from "./zip-constants.js";
|
|
11
11
|
/**
|
|
12
12
|
* Find the End of Central Directory record
|
|
13
13
|
* Searches backwards from the end of the file
|
|
@@ -16,13 +16,9 @@ function findEndOfCentralDir(data) {
|
|
|
16
16
|
// EOCD is at least 22 bytes, search backwards
|
|
17
17
|
// Comment can be up to 65535 bytes
|
|
18
18
|
const minOffset = Math.max(0, data.length - 65557);
|
|
19
|
-
|
|
20
|
-
const b0 = 0x50;
|
|
21
|
-
const b1 = 0x4b;
|
|
22
|
-
const b2 = 0x05;
|
|
23
|
-
const b3 = 0x06;
|
|
19
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
24
20
|
for (let i = data.length - 22; i >= minOffset; i--) {
|
|
25
|
-
if (
|
|
21
|
+
if (view.getUint32(i, true) === END_OF_CENTRAL_DIR_SIG) {
|
|
26
22
|
return i;
|
|
27
23
|
}
|
|
28
24
|
}
|
|
@@ -37,11 +33,8 @@ function findZip64EOCDLocator(data, eocdOffset) {
|
|
|
37
33
|
if (locatorOffset < 0) {
|
|
38
34
|
return -1;
|
|
39
35
|
}
|
|
40
|
-
|
|
41
|
-
if (
|
|
42
|
-
data[locatorOffset + 1] === 0x4b &&
|
|
43
|
-
data[locatorOffset + 2] === 0x06 &&
|
|
44
|
-
data[locatorOffset + 3] === 0x07) {
|
|
36
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
37
|
+
if (view.getUint32(locatorOffset, true) === ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIG) {
|
|
45
38
|
return locatorOffset;
|
|
46
39
|
}
|
|
47
40
|
return -1;
|
|
@@ -51,7 +44,7 @@ function findZip64EOCDLocator(data, eocdOffset) {
|
|
|
51
44
|
*/
|
|
52
45
|
function parseZipEntries(data, options = {}) {
|
|
53
46
|
const { decodeStrings = true } = options;
|
|
54
|
-
|
|
47
|
+
const entries = [];
|
|
55
48
|
// Find End of Central Directory
|
|
56
49
|
const eocdOffset = findEndOfCentralDir(data);
|
|
57
50
|
if (eocdOffset === -1) {
|
|
@@ -103,10 +96,6 @@ function parseZipEntries(data, options = {}) {
|
|
|
103
96
|
}
|
|
104
97
|
}
|
|
105
98
|
}
|
|
106
|
-
// Preallocate to avoid repeated array growth on large archives.
|
|
107
|
-
if (totalEntries > 0) {
|
|
108
|
-
entries = new Array(totalEntries);
|
|
109
|
-
}
|
|
110
99
|
// Read Central Directory entries
|
|
111
100
|
const centralReader = new BinaryReader(data, centralDirOffset);
|
|
112
101
|
for (let i = 0; i < totalEntries; i++) {
|
|
@@ -155,26 +144,23 @@ function parseZipEntries(data, options = {}) {
|
|
|
155
144
|
// Check for UTF-8 flag (bit 11)
|
|
156
145
|
const isUtf8 = (flags & 0x800) !== 0;
|
|
157
146
|
const useUtf8 = decodeStrings && isUtf8;
|
|
158
|
-
const fileName =
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
localHeaderOffset = vars.offsetToLocalFileHeader ?? localHeaderOffset;
|
|
171
|
-
}
|
|
172
|
-
const comment = commentLength > 0 ? centralReader.readString(commentLength, useUtf8) : "";
|
|
147
|
+
const fileName = centralReader.readString(fileNameLength, useUtf8);
|
|
148
|
+
const extraField = centralReader.readBytes(extraFieldLength);
|
|
149
|
+
const comment = centralReader.readString(commentLength, useUtf8);
|
|
150
|
+
const vars = {
|
|
151
|
+
compressedSize,
|
|
152
|
+
uncompressedSize,
|
|
153
|
+
offsetToLocalFileHeader: localHeaderOffset
|
|
154
|
+
};
|
|
155
|
+
const extraFields = extraFieldLength > 0 ? parseZipExtraFields(extraField, vars) : {};
|
|
156
|
+
compressedSize = vars.compressedSize;
|
|
157
|
+
uncompressedSize = vars.uncompressedSize;
|
|
158
|
+
localHeaderOffset = vars.offsetToLocalFileHeader ?? localHeaderOffset;
|
|
173
159
|
const isDirectory = fileName.endsWith("/") || (externalAttributes & 0x10) !== 0;
|
|
174
160
|
const isEncrypted = (flags & 0x01) !== 0;
|
|
175
161
|
const unixSecondsMtime = extraFields.mtimeUnixSeconds;
|
|
176
162
|
const lastModified = resolveZipLastModifiedDateFromUnixSeconds(lastModDate, lastModTime, unixSecondsMtime);
|
|
177
|
-
entries
|
|
163
|
+
entries.push({
|
|
178
164
|
path: fileName,
|
|
179
165
|
isDirectory,
|
|
180
166
|
compressedSize,
|
|
@@ -186,7 +172,7 @@ function parseZipEntries(data, options = {}) {
|
|
|
186
172
|
comment,
|
|
187
173
|
externalAttributes,
|
|
188
174
|
isEncrypted
|
|
189
|
-
};
|
|
175
|
+
});
|
|
190
176
|
}
|
|
191
177
|
return entries;
|
|
192
178
|
}
|
|
@@ -3,23 +3,6 @@
|
|
|
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;
|
|
23
6
|
export interface ZipLocalFileHeaderInput {
|
|
24
7
|
fileName: Uint8Array;
|
|
25
8
|
extraField: Uint8Array;
|
|
@@ -32,7 +15,6 @@ export interface ZipLocalFileHeaderInput {
|
|
|
32
15
|
uncompressedSize: number;
|
|
33
16
|
versionNeeded?: number;
|
|
34
17
|
}
|
|
35
|
-
export declare function writeLocalFileHeaderInto(out: Uint8Array, view: DataView, offset: number, input: ZipLocalFileHeaderInput): number;
|
|
36
18
|
export declare function buildLocalFileHeader(input: ZipLocalFileHeaderInput): Uint8Array;
|
|
37
19
|
export interface ZipCentralDirectoryHeaderInput {
|
|
38
20
|
fileName: Uint8Array;
|
|
@@ -50,7 +32,6 @@ export interface ZipCentralDirectoryHeaderInput {
|
|
|
50
32
|
versionNeeded?: number;
|
|
51
33
|
externalAttributes?: number;
|
|
52
34
|
}
|
|
53
|
-
export declare function writeCentralDirectoryHeaderInto(out: Uint8Array, view: DataView, offset: number, input: ZipCentralDirectoryHeaderInput): number;
|
|
54
35
|
export declare function buildCentralDirectoryHeader(input: ZipCentralDirectoryHeaderInput): Uint8Array;
|
|
55
36
|
export interface ZipEndOfCentralDirectoryInput {
|
|
56
37
|
entryCount: number;
|
|
@@ -58,6 +39,5 @@ export interface ZipEndOfCentralDirectoryInput {
|
|
|
58
39
|
centralDirOffset: number;
|
|
59
40
|
comment: Uint8Array;
|
|
60
41
|
}
|
|
61
|
-
export declare function writeEndOfCentralDirectoryInto(out: Uint8Array, view: DataView, offset: number, input: ZipEndOfCentralDirectoryInput): number;
|
|
62
42
|
export declare function buildEndOfCentralDirectory(input: ZipEndOfCentralDirectoryInput): Uint8Array;
|
|
63
43
|
export declare function buildDataDescriptor(crc32: number, compressedSize: number, uncompressedSize: number): Uint8Array<ArrayBuffer>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ZIP record builders (PKWARE APPNOTE)
|
|
3
|
+
*
|
|
4
|
+
* Shared by streaming zip writer and buffer zip builder.
|
|
5
|
+
*/
|
|
6
|
+
import { CENTRAL_DIR_HEADER_SIG, DATA_DESCRIPTOR_SIG, END_OF_CENTRAL_DIR_SIG, LOCAL_FILE_HEADER_SIG, VERSION_MADE_BY, VERSION_NEEDED } from "./zip-constants.js";
|
|
7
|
+
export function buildLocalFileHeader(input) {
|
|
8
|
+
const versionNeeded = input.versionNeeded ?? VERSION_NEEDED;
|
|
9
|
+
const header = new Uint8Array(30 + input.fileName.length + input.extraField.length);
|
|
10
|
+
const view = new DataView(header.buffer);
|
|
11
|
+
view.setUint32(0, LOCAL_FILE_HEADER_SIG, true);
|
|
12
|
+
view.setUint16(4, versionNeeded, true);
|
|
13
|
+
view.setUint16(6, input.flags, true);
|
|
14
|
+
view.setUint16(8, input.compressionMethod, true);
|
|
15
|
+
view.setUint16(10, input.dosTime, true);
|
|
16
|
+
view.setUint16(12, input.dosDate, true);
|
|
17
|
+
view.setUint32(14, input.crc32, true);
|
|
18
|
+
view.setUint32(18, input.compressedSize, true);
|
|
19
|
+
view.setUint32(22, input.uncompressedSize, true);
|
|
20
|
+
view.setUint16(26, input.fileName.length, true);
|
|
21
|
+
view.setUint16(28, input.extraField.length, true);
|
|
22
|
+
header.set(input.fileName, 30);
|
|
23
|
+
if (input.extraField.length > 0) {
|
|
24
|
+
header.set(input.extraField, 30 + input.fileName.length);
|
|
25
|
+
}
|
|
26
|
+
return header;
|
|
27
|
+
}
|
|
28
|
+
export function buildCentralDirectoryHeader(input) {
|
|
29
|
+
const versionMadeBy = input.versionMadeBy ?? VERSION_MADE_BY;
|
|
30
|
+
const versionNeeded = input.versionNeeded ?? VERSION_NEEDED;
|
|
31
|
+
const externalAttributes = input.externalAttributes ?? 0;
|
|
32
|
+
const header = new Uint8Array(46 + input.fileName.length + input.extraField.length + input.comment.length);
|
|
33
|
+
const view = new DataView(header.buffer);
|
|
34
|
+
view.setUint32(0, CENTRAL_DIR_HEADER_SIG, true);
|
|
35
|
+
view.setUint16(4, versionMadeBy, true);
|
|
36
|
+
view.setUint16(6, versionNeeded, true);
|
|
37
|
+
view.setUint16(8, input.flags, true);
|
|
38
|
+
view.setUint16(10, input.compressionMethod, true);
|
|
39
|
+
view.setUint16(12, input.dosTime, true);
|
|
40
|
+
view.setUint16(14, input.dosDate, true);
|
|
41
|
+
view.setUint32(16, input.crc32, true);
|
|
42
|
+
view.setUint32(20, input.compressedSize, true);
|
|
43
|
+
view.setUint32(24, input.uncompressedSize, true);
|
|
44
|
+
view.setUint16(28, input.fileName.length, true);
|
|
45
|
+
view.setUint16(30, input.extraField.length, true);
|
|
46
|
+
view.setUint16(32, input.comment.length, true);
|
|
47
|
+
view.setUint16(34, 0, true); // disk number start
|
|
48
|
+
view.setUint16(36, 0, true); // internal file attributes
|
|
49
|
+
view.setUint32(38, externalAttributes, true);
|
|
50
|
+
view.setUint32(42, input.localHeaderOffset, true);
|
|
51
|
+
header.set(input.fileName, 46);
|
|
52
|
+
if (input.extraField.length > 0) {
|
|
53
|
+
header.set(input.extraField, 46 + input.fileName.length);
|
|
54
|
+
}
|
|
55
|
+
if (input.comment.length > 0) {
|
|
56
|
+
header.set(input.comment, 46 + input.fileName.length + input.extraField.length);
|
|
57
|
+
}
|
|
58
|
+
return header;
|
|
59
|
+
}
|
|
60
|
+
export function buildEndOfCentralDirectory(input) {
|
|
61
|
+
const record = new Uint8Array(22 + input.comment.length);
|
|
62
|
+
const view = new DataView(record.buffer);
|
|
63
|
+
view.setUint32(0, END_OF_CENTRAL_DIR_SIG, true);
|
|
64
|
+
view.setUint16(4, 0, true);
|
|
65
|
+
view.setUint16(6, 0, true);
|
|
66
|
+
view.setUint16(8, input.entryCount, true);
|
|
67
|
+
view.setUint16(10, input.entryCount, true);
|
|
68
|
+
view.setUint32(12, input.centralDirSize, true);
|
|
69
|
+
view.setUint32(16, input.centralDirOffset, true);
|
|
70
|
+
view.setUint16(20, input.comment.length, true);
|
|
71
|
+
if (input.comment.length > 0) {
|
|
72
|
+
record.set(input.comment, 22);
|
|
73
|
+
}
|
|
74
|
+
return record;
|
|
75
|
+
}
|
|
76
|
+
export function buildDataDescriptor(crc32, compressedSize, uncompressedSize) {
|
|
77
|
+
const descriptor = new Uint8Array(16);
|
|
78
|
+
const view = new DataView(descriptor.buffer);
|
|
79
|
+
view.setUint32(0, DATA_DESCRIPTOR_SIG, true);
|
|
80
|
+
view.setUint32(4, crc32, true);
|
|
81
|
+
view.setUint32(8, compressedSize, true);
|
|
82
|
+
view.setUint32(12, uncompressedSize, true);
|
|
83
|
+
return descriptor;
|
|
84
|
+
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* with filesystem-specific features (filename input + temp-file buffering).
|
|
10
10
|
*/
|
|
11
11
|
import { EventEmitter, Readable } from "../../stream/index.browser.js";
|
|
12
|
-
import { createParse } from "../../archive/
|
|
12
|
+
import { createParse } from "../../archive/parse.browser.js";
|
|
13
13
|
import { iterateStream } from "../utils/iterate-stream.js";
|
|
14
14
|
import { getWorksheetNoFromWorksheetPath, getWorksheetNoFromWorksheetRelsPath, normalizeZipPath, OOXML_PATHS, worksheetRelTarget } from "../utils/ooxml-paths.js";
|
|
15
15
|
import { parseSax } from "../utils/parse-sax.js";
|
|
@@ -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/zip
|
|
10
|
+
import { Zip } from "@archive/streaming-zip";
|
|
11
11
|
import { StreamBuf } from "@excel/utils/stream-buf";
|
|
12
12
|
import { StylesXform } from "@excel/xlsx/xform/style/styles-xform";
|
|
13
13
|
import { SharedStrings } from "@excel/utils/shared-strings";
|
|
@@ -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, ZipDeflate } from "../../archive/zip
|
|
10
|
+
import { Zip, ZipDeflate } from "../../archive/streaming-zip.js";
|
|
11
11
|
import { StreamBuf } from "../utils/stream-buf.js";
|
|
12
12
|
import { base64ToUint8Array } from "../../../utils/utils.browser.js";
|
|
13
13
|
import { RelType } from "../xlsx/rel-type.js";
|
|
@@ -30,8 +30,8 @@ import { theme1Xml } from "./xml/theme1.js";
|
|
|
30
30
|
import { RelType } from "./rel-type.js";
|
|
31
31
|
import { StreamBuf } from "../utils/stream-buf.js";
|
|
32
32
|
import { bufferToString, base64ToUint8Array } from "../../../utils/utils.browser.js";
|
|
33
|
-
import { StreamingZip, ZipDeflateFile } from "../../archive/zip
|
|
34
|
-
import { ZipParser } from "../../archive/
|
|
33
|
+
import { StreamingZip, ZipDeflateFile } from "../../archive/streaming-zip.js";
|
|
34
|
+
import { ZipParser } from "../../archive/index.browser.js";
|
|
35
35
|
import { PassThrough, concatUint8Arrays } from "../../stream/index.browser.js";
|
|
36
36
|
import { commentsPath, commentsRelTargetFromWorksheetName, ctrlPropPath, drawingPath, drawingRelsPath, OOXML_REL_TARGETS, pivotTableRelTargetFromWorksheetName, pivotCacheDefinitionRelTargetFromWorkbook, getCommentsIndexFromPath, getDrawingNameFromPath, getDrawingNameFromRelsPath, getMediaFilenameFromPath, mediaPath, getPivotCacheDefinitionNameFromPath, getPivotCacheDefinitionNameFromRelsPath, getPivotCacheRecordsNameFromPath, getPivotTableNameFromPath, getPivotTableNameFromRelsPath, pivotCacheDefinitionPath, pivotCacheDefinitionRelsPath, pivotCacheDefinitionRelTargetFromPivotTable, pivotCacheRecordsPath, pivotCacheRecordsRelTarget, pivotTablePath, pivotTableRelsPath, getTableNameFromPath, tablePath, tableRelTargetFromWorksheetName, themePath, getThemeNameFromPath, getVmlDrawingNameFromPath, getWorksheetNoFromWorksheetPath, getWorksheetNoFromWorksheetRelsPath, isBinaryEntryPath, normalizeZipPath, OOXML_PATHS, vmlDrawingRelTargetFromWorksheetName, vmlDrawingPath, worksheetPath, worksheetRelsPath } from "../utils/ooxml-paths.js";
|
|
37
37
|
class StreamingZipWriterAdapter {
|
|
@@ -126,7 +126,10 @@ class StreamingZipWriterAdapter {
|
|
|
126
126
|
timestamps: this.timestamps
|
|
127
127
|
});
|
|
128
128
|
this.zip.add(file);
|
|
129
|
-
file.push(buffer, true);
|
|
129
|
+
const pushResult = file.push(buffer, true);
|
|
130
|
+
if (pushResult && typeof pushResult.catch === "function") {
|
|
131
|
+
pushResult.catch((err) => this._emit("error", err));
|
|
132
|
+
}
|
|
130
133
|
}
|
|
131
134
|
finalize() {
|
|
132
135
|
if (this.finalized) {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import fs from "fs";
|
|
17
17
|
import { fileExists } from "../../../utils/utils.browser.js";
|
|
18
18
|
import { XLSX as XLSXBase } from "./xlsx.browser.js";
|
|
19
|
-
import { Parse } from "../../archive/
|
|
19
|
+
import { Parse } from "../../archive/index.browser.js";
|
|
20
20
|
import { Writable, pipeline } from "../../stream/index.browser.js";
|
|
21
21
|
class XLSX extends XLSXBase {
|
|
22
22
|
constructor(workbook) {
|
|
@@ -27,7 +27,6 @@ export declare class Readable<T = Uint8Array> extends EventEmitter {
|
|
|
27
27
|
private _bufferSize;
|
|
28
28
|
private _reading;
|
|
29
29
|
private _ended;
|
|
30
|
-
private _endEmitted;
|
|
31
30
|
private _destroyed;
|
|
32
31
|
private _errored;
|
|
33
32
|
private _closed;
|
|
@@ -72,7 +71,6 @@ export declare class Readable<T = Uint8Array> extends EventEmitter {
|
|
|
72
71
|
* Push data to the stream (when using controllable stream)
|
|
73
72
|
*/
|
|
74
73
|
push(chunk: T | null): boolean;
|
|
75
|
-
private _emitEndOnce;
|
|
76
74
|
/**
|
|
77
75
|
* Put a chunk back at the front of the buffer
|
|
78
76
|
* Note: unshift is allowed even after end, as it's used to put back already read data
|
|
@@ -160,8 +158,7 @@ export declare class Readable<T = Uint8Array> extends EventEmitter {
|
|
|
160
158
|
private _startReading;
|
|
161
159
|
/**
|
|
162
160
|
* Async iterator support
|
|
163
|
-
* Uses
|
|
164
|
-
* This matches Node's behavior more closely (iterator drives flowing mode).
|
|
161
|
+
* Uses Web Stream reader for non-push mode, event-based for push mode
|
|
165
162
|
*/
|
|
166
163
|
[Symbol.asyncIterator](): AsyncIterableIterator<T>;
|
|
167
164
|
/**
|
|
@@ -288,12 +285,10 @@ export declare class Writable<T = Uint8Array> extends EventEmitter {
|
|
|
288
285
|
private _closed;
|
|
289
286
|
private _pendingWrites;
|
|
290
287
|
private _writableLength;
|
|
291
|
-
private _needDrain;
|
|
292
288
|
private _corked;
|
|
293
289
|
private _corkedChunks;
|
|
294
290
|
private _defaultEncoding;
|
|
295
291
|
private _aborted;
|
|
296
|
-
private _ownsStream;
|
|
297
292
|
private _writeFunc?;
|
|
298
293
|
private _finalFunc?;
|
|
299
294
|
readonly objectMode: boolean;
|
|
@@ -403,46 +398,53 @@ export declare function normalizeWritable<T = Uint8Array>(stream: WritableLike |
|
|
|
403
398
|
* A wrapper around Web TransformStream that provides Node.js-like API
|
|
404
399
|
*/
|
|
405
400
|
export declare class Transform<TInput = Uint8Array, TOutput = Uint8Array> extends EventEmitter {
|
|
401
|
+
private _stream;
|
|
406
402
|
/** @internal - for pipe() support */
|
|
407
403
|
readonly _readable: Readable<TOutput>;
|
|
408
404
|
/** @internal - for pipe() support */
|
|
409
405
|
readonly _writable: Writable<TInput>;
|
|
410
406
|
readonly objectMode: boolean;
|
|
411
|
-
private _destroyed;
|
|
412
407
|
private _ended;
|
|
408
|
+
private _destroyed;
|
|
413
409
|
private _errored;
|
|
414
|
-
private
|
|
415
|
-
private
|
|
416
|
-
private
|
|
417
|
-
private
|
|
418
|
-
private _transformImpl;
|
|
419
|
-
private _flushImpl;
|
|
410
|
+
private _pushBuffer;
|
|
411
|
+
private _transformController;
|
|
412
|
+
private _pendingEndWrites;
|
|
413
|
+
private _endPending;
|
|
420
414
|
/**
|
|
421
|
-
* Push data to the readable side (Node.js compatibility)
|
|
422
|
-
*
|
|
415
|
+
* Push data to the readable side (Node.js compatibility)
|
|
416
|
+
* Can be called from within transform callback
|
|
423
417
|
*/
|
|
424
418
|
push(chunk: TOutput | null): boolean;
|
|
425
419
|
constructor(options?: TransformStreamOptions & {
|
|
426
420
|
transform?: ((chunk: TInput) => TOutput | Promise<TOutput>) | ((this: Transform<TInput, TOutput>, chunk: TInput, encoding: string, callback: (error?: Error | null, data?: TOutput) => void) => void);
|
|
427
421
|
flush?: (() => TOutput | void | Promise<TOutput | void>) | ((this: Transform<TInput, TOutput>, callback: (error?: Error | null, data?: TOutput) => void) => void);
|
|
428
422
|
});
|
|
429
|
-
private
|
|
430
|
-
private _scheduleEnd;
|
|
431
|
-
private _emitErrorOnce;
|
|
432
|
-
private _hasSubclassTransform;
|
|
433
|
-
private _hasSubclassFlush;
|
|
434
|
-
private _runTransform;
|
|
435
|
-
private _runFlush;
|
|
423
|
+
private _dataForwardingSetup;
|
|
436
424
|
/**
|
|
437
|
-
* Override on
|
|
438
|
-
* Avoids starting flowing mode unless requested.
|
|
425
|
+
* Override on to start flowing when data listener is added
|
|
439
426
|
*/
|
|
440
427
|
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
428
|
+
/** @internal - whether we have a data event consumer */
|
|
429
|
+
private _hasDataConsumer;
|
|
441
430
|
/**
|
|
442
|
-
* Write to the
|
|
431
|
+
* Write data to the transform stream
|
|
432
|
+
* Note: Automatically starts consuming readable if no consumer to allow
|
|
433
|
+
* transform function to execute (Web Streams backpressure compatibility)
|
|
443
434
|
*/
|
|
444
435
|
write(chunk: TInput, callback?: (error?: Error | null) => void): boolean;
|
|
445
436
|
write(chunk: TInput, encoding?: string, callback?: (error?: Error | null) => void): boolean;
|
|
437
|
+
/** @internal - whether we're auto-consuming the readable */
|
|
438
|
+
private _readableConsuming;
|
|
439
|
+
/** @internal - buffer for auto-consumed data */
|
|
440
|
+
private _autoConsumedBuffer;
|
|
441
|
+
private _autoConsumedBufferIndex;
|
|
442
|
+
/** @internal - whether auto-consume has ended */
|
|
443
|
+
private _autoConsumeEnded;
|
|
444
|
+
/** @internal - promise that resolves when auto-consume finishes */
|
|
445
|
+
private _autoConsumePromise;
|
|
446
|
+
/** @internal - auto-consume readable to allow transform to execute */
|
|
447
|
+
private _startAutoConsume;
|
|
446
448
|
/**
|
|
447
449
|
* End the transform stream
|
|
448
450
|
* Delays closing to allow writes during data events to complete
|
|
@@ -454,8 +456,10 @@ export declare class Transform<TInput = Uint8Array, TOutput = Uint8Array> extend
|
|
|
454
456
|
* Read from the transform stream
|
|
455
457
|
*/
|
|
456
458
|
read(size?: number): TOutput | null;
|
|
459
|
+
/** @internal - list of piped destinations for forwarding auto-consumed data */
|
|
460
|
+
private _pipeDestinations;
|
|
457
461
|
/**
|
|
458
|
-
* Pipe
|
|
462
|
+
* Pipe to another stream (writable, transform, or duplex)
|
|
459
463
|
*/
|
|
460
464
|
pipe<W extends Writable<TOutput> | Transform<TOutput, any> | Duplex<any, TOutput>>(destination: W): W;
|
|
461
465
|
/**
|
|
@@ -550,7 +554,6 @@ export declare class Duplex<TRead = Uint8Array, TWrite = Uint8Array> extends Eve
|
|
|
550
554
|
writable: WritableStream<W>;
|
|
551
555
|
};
|
|
552
556
|
private _dataForwardingSetup;
|
|
553
|
-
private _sideForwardingCleanup;
|
|
554
557
|
constructor(options?: DuplexStreamOptions & {
|
|
555
558
|
allowHalfOpen?: boolean;
|
|
556
559
|
objectMode?: boolean;
|
|
@@ -558,7 +561,6 @@ export declare class Duplex<TRead = Uint8Array, TWrite = Uint8Array> extends Eve
|
|
|
558
561
|
write?: (this: Duplex<TRead, TWrite>, chunk: TWrite, encoding: string, callback: (error?: Error | null) => void) => void;
|
|
559
562
|
final?: (this: Duplex<TRead, TWrite>, callback: (error?: Error | null) => void) => void;
|
|
560
563
|
});
|
|
561
|
-
private _setupSideForwarding;
|
|
562
564
|
/**
|
|
563
565
|
* Override on() to set up data forwarding lazily
|
|
564
566
|
*/
|