@cj-tech-master/excelts 4.2.1 → 4.2.2
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 +8 -0
- package/dist/browser/modules/archive/io/archive-sink.js +45 -0
- package/dist/browser/modules/archive/io/archive-source.d.ts +6 -0
- package/dist/browser/modules/archive/io/archive-source.js +100 -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/utils/ooxml-validator.d.ts +48 -0
- package/dist/browser/modules/excel/utils/ooxml-validator.js +469 -0
- package/dist/browser/modules/excel/worksheet.js +5 -2
- package/dist/browser/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.d.ts +1 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.js +13 -1
- package/dist/browser/modules/excel/xlsx/xform/drawing/sp-xform.d.ts +18 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/sp-xform.js +112 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.d.ts +6 -1
- package/dist/browser/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +30 -2
- package/dist/browser/modules/excel/xlsx/xform/drawing/vml-drawing-xform.js +11 -0
- package/dist/browser/modules/excel/xlsx/xform/sheet/page-setup-xform.d.ts +1 -0
- package/dist/browser/modules/excel/xlsx/xform/sheet/page-setup-xform.js +16 -2
- package/dist/browser/modules/excel/xlsx/xform/sheet/worksheet-xform.js +110 -12
- 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/base-transform.d.ts +3 -0
- package/dist/browser/modules/stream/base-transform.js +34 -20
- package/dist/browser/modules/stream/buffered-stream.d.ts +2 -12
- package/dist/browser/modules/stream/chunked-builder.js +4 -4
- package/dist/browser/modules/stream/index.browser.d.ts +13 -19
- package/dist/browser/modules/stream/index.browser.js +10 -22
- package/dist/browser/modules/stream/index.d.ts +18 -41
- package/dist/browser/modules/stream/index.js +15 -44
- package/dist/browser/modules/stream/internal/event-utils.d.ts +17 -0
- package/dist/browser/modules/stream/internal/event-utils.js +40 -0
- package/dist/browser/modules/stream/internal/type-guards.d.ts +9 -0
- package/dist/browser/modules/stream/internal/type-guards.js +24 -0
- package/dist/browser/modules/stream/pull-stream.d.ts +5 -6
- package/dist/browser/modules/stream/pull-stream.js +107 -43
- package/dist/browser/modules/stream/shared.d.ts +1 -1
- package/dist/browser/modules/stream/shared.js +7 -4
- package/dist/browser/modules/stream/streams.browser.d.ts +32 -44
- package/dist/browser/modules/stream/streams.browser.js +921 -836
- package/dist/browser/modules/stream/streams.d.ts +4 -20
- package/dist/browser/modules/stream/streams.js +146 -95
- package/dist/browser/modules/stream/utils.js +5 -38
- 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 +49 -0
- package/dist/cjs/modules/archive/io/archive-source.js +105 -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/utils/ooxml-validator.js +475 -0
- package/dist/cjs/modules/excel/worksheet.js +5 -2
- package/dist/cjs/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.js +13 -1
- package/dist/cjs/modules/excel/xlsx/xform/drawing/sp-xform.js +115 -0
- package/dist/cjs/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +30 -2
- package/dist/cjs/modules/excel/xlsx/xform/drawing/vml-drawing-xform.js +11 -0
- package/dist/cjs/modules/excel/xlsx/xform/sheet/page-setup-xform.js +16 -2
- package/dist/cjs/modules/excel/xlsx/xform/sheet/worksheet-xform.js +110 -12
- 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/base-transform.js +34 -20
- package/dist/cjs/modules/stream/chunked-builder.js +4 -4
- package/dist/cjs/modules/stream/index.browser.js +10 -17
- package/dist/cjs/modules/stream/index.js +15 -39
- package/dist/cjs/modules/stream/internal/event-utils.js +43 -0
- package/dist/cjs/modules/stream/internal/type-guards.js +30 -0
- package/dist/cjs/modules/stream/pull-stream.js +107 -43
- package/dist/cjs/modules/stream/shared.js +7 -4
- package/dist/cjs/modules/stream/streams.browser.js +927 -847
- package/dist/cjs/modules/stream/streams.js +156 -107
- package/dist/cjs/modules/stream/utils.js +3 -36
- 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 +45 -0
- package/dist/esm/modules/archive/io/archive-source.js +100 -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/utils/ooxml-validator.js +469 -0
- package/dist/esm/modules/excel/worksheet.js +5 -2
- package/dist/esm/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.js +13 -1
- package/dist/esm/modules/excel/xlsx/xform/drawing/sp-xform.js +112 -0
- package/dist/esm/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +30 -2
- package/dist/esm/modules/excel/xlsx/xform/drawing/vml-drawing-xform.js +11 -0
- package/dist/esm/modules/excel/xlsx/xform/sheet/page-setup-xform.js +16 -2
- package/dist/esm/modules/excel/xlsx/xform/sheet/worksheet-xform.js +110 -12
- 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/base-transform.js +34 -20
- package/dist/esm/modules/stream/chunked-builder.js +4 -4
- package/dist/esm/modules/stream/index.browser.js +10 -22
- package/dist/esm/modules/stream/index.js +15 -44
- package/dist/esm/modules/stream/internal/event-utils.js +40 -0
- package/dist/esm/modules/stream/internal/type-guards.js +24 -0
- package/dist/esm/modules/stream/pull-stream.js +107 -43
- package/dist/esm/modules/stream/shared.js +7 -4
- package/dist/esm/modules/stream/streams.browser.js +921 -836
- package/dist/esm/modules/stream/streams.js +146 -95
- package/dist/esm/modules/stream/utils.js +5 -38
- package/dist/iife/THIRD_PARTY_NOTICES.md +0 -31
- package/dist/iife/excelts.iife.js +6495 -4440
- 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 +8 -0
- package/dist/types/modules/archive/io/archive-source.d.ts +6 -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/excel/utils/ooxml-validator.d.ts +48 -0
- package/dist/types/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.d.ts +1 -0
- package/dist/types/modules/excel/xlsx/xform/drawing/sp-xform.d.ts +18 -0
- package/dist/types/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.d.ts +6 -1
- package/dist/types/modules/excel/xlsx/xform/sheet/page-setup-xform.d.ts +1 -0
- package/dist/types/modules/stream/base-transform.d.ts +3 -0
- package/dist/types/modules/stream/buffered-stream.d.ts +2 -12
- package/dist/types/modules/stream/index.browser.d.ts +13 -19
- package/dist/types/modules/stream/index.d.ts +18 -41
- package/dist/types/modules/stream/internal/event-utils.d.ts +17 -0
- package/dist/types/modules/stream/internal/type-guards.d.ts +9 -0
- package/dist/types/modules/stream/pull-stream.d.ts +5 -6
- package/dist/types/modules/stream/shared.d.ts +1 -1
- package/dist/types/modules/stream/streams.browser.d.ts +32 -44
- package/dist/types/modules/stream/streams.d.ts +4 -20
- package/package.json +14 -10
- 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
|
@@ -2,12 +2,33 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* ZIP extra field parsing helpers.
|
|
4
4
|
*
|
|
5
|
-
* Kept standalone so both streaming parser (`
|
|
5
|
+
* Kept standalone so both streaming parser (`stream.base.ts`) and buffer parser
|
|
6
6
|
* (`zip-parser.ts`) can share ZIP64 + Info-ZIP timestamp handling.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.parseZipExtraFields = parseZipExtraFields;
|
|
10
|
-
const
|
|
10
|
+
const EXTENDED_TIMESTAMP_ID = 0x5455;
|
|
11
|
+
function parseExtendedTimestampMtimeUnixSeconds(extraField) {
|
|
12
|
+
const view = new DataView(extraField.buffer, extraField.byteOffset, extraField.byteLength);
|
|
13
|
+
let offset = 0;
|
|
14
|
+
while (offset + 4 <= extraField.length) {
|
|
15
|
+
const headerId = view.getUint16(offset, true);
|
|
16
|
+
const dataSize = view.getUint16(offset + 2, true);
|
|
17
|
+
const dataStart = offset + 4;
|
|
18
|
+
const dataEnd = dataStart + dataSize;
|
|
19
|
+
if (dataEnd > extraField.length) {
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
if (headerId === EXTENDED_TIMESTAMP_ID && dataSize >= 1) {
|
|
23
|
+
const flags = extraField[dataStart];
|
|
24
|
+
if ((flags & 0x01) !== 0 && dataSize >= 5) {
|
|
25
|
+
return view.getUint32(dataStart + 1, true) >>> 0;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
offset = dataEnd;
|
|
29
|
+
}
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
11
32
|
function readUint64LE(view, offset) {
|
|
12
33
|
// Convert to Number via 2x Uint32 to avoid BigInt requirements.
|
|
13
34
|
const low = view.getUint32(offset, true);
|
|
@@ -46,18 +67,9 @@ function parseZipExtraFields(extraField, vars) {
|
|
|
46
67
|
}
|
|
47
68
|
}
|
|
48
69
|
else if (signature === 0x5455) {
|
|
49
|
-
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
if ((flags & 0x01) !== 0 && partSize >= 5) {
|
|
53
|
-
extra.mtimeUnixSeconds = view.getUint32(dataStart + 1, true) >>> 0;
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
const unixSeconds = (0, zip_extra_1.parseExtendedTimestampMtimeUnixSeconds)(extraField.subarray(offset, dataEnd));
|
|
57
|
-
if (unixSeconds !== undefined) {
|
|
58
|
-
extra.mtimeUnixSeconds = unixSeconds;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
70
|
+
const unixSeconds = parseExtendedTimestampMtimeUnixSeconds(extraField.subarray(offset, dataEnd));
|
|
71
|
+
if (unixSeconds !== undefined) {
|
|
72
|
+
extra.mtimeUnixSeconds = unixSeconds;
|
|
61
73
|
}
|
|
62
74
|
}
|
|
63
75
|
offset = dataEnd;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ZipArchive = void 0;
|
|
4
|
+
exports.zip = zip;
|
|
5
|
+
const defaults_1 = require("../defaults.js");
|
|
6
|
+
const stream_1 = require("./stream.js");
|
|
7
|
+
const zip_bytes_1 = require("./zip-bytes.js");
|
|
8
|
+
const archive_sink_1 = require("../io/archive-sink.js");
|
|
9
|
+
const archive_source_1 = require("../io/archive-source.js");
|
|
10
|
+
const async_queue_1 = require("../utils/async-queue.js");
|
|
11
|
+
const REPRODUCIBLE_ZIP_MOD_TIME = new Date(1980, 0, 1, 0, 0, 0);
|
|
12
|
+
class ZipArchive {
|
|
13
|
+
constructor(options = {}) {
|
|
14
|
+
this._entries = [];
|
|
15
|
+
this._sealed = false;
|
|
16
|
+
const reproducible = options.reproducible ?? false;
|
|
17
|
+
this._options = {
|
|
18
|
+
level: options.level ?? defaults_1.DEFAULT_ZIP_LEVEL,
|
|
19
|
+
timestamps: options.timestamps ?? (reproducible ? "dos" : defaults_1.DEFAULT_ZIP_TIMESTAMPS),
|
|
20
|
+
comment: options.comment,
|
|
21
|
+
modTime: options.modTime ?? (reproducible ? REPRODUCIBLE_ZIP_MOD_TIME : new Date()),
|
|
22
|
+
smartStore: options.smartStore ?? true
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
add(name, source, options) {
|
|
26
|
+
if (this._sealed) {
|
|
27
|
+
throw new Error("Cannot add entries after output has started");
|
|
28
|
+
}
|
|
29
|
+
if (!name) {
|
|
30
|
+
throw new Error("Entry name is required");
|
|
31
|
+
}
|
|
32
|
+
this._entries.push({ name, source, options });
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
stream() {
|
|
36
|
+
this._sealed = true;
|
|
37
|
+
const queue = (0, async_queue_1.createAsyncQueue)();
|
|
38
|
+
const zip = new stream_1.StreamingZip((err, data, final) => {
|
|
39
|
+
if (err) {
|
|
40
|
+
queue.fail(err);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (data.length) {
|
|
44
|
+
queue.push(data);
|
|
45
|
+
}
|
|
46
|
+
if (final) {
|
|
47
|
+
queue.close();
|
|
48
|
+
}
|
|
49
|
+
}, { comment: this._options.comment });
|
|
50
|
+
(async () => {
|
|
51
|
+
try {
|
|
52
|
+
for (const entry of this._entries) {
|
|
53
|
+
const level = entry.options?.level ?? this._options.level;
|
|
54
|
+
const file = new stream_1.ZipDeflateFile(entry.name, {
|
|
55
|
+
level,
|
|
56
|
+
modTime: entry.options?.modTime ?? this._options.modTime,
|
|
57
|
+
timestamps: this._options.timestamps,
|
|
58
|
+
comment: entry.options?.comment,
|
|
59
|
+
smartStore: this._options.smartStore
|
|
60
|
+
});
|
|
61
|
+
zip.add(file);
|
|
62
|
+
// Feed data
|
|
63
|
+
if (entry.source instanceof Uint8Array ||
|
|
64
|
+
entry.source instanceof ArrayBuffer ||
|
|
65
|
+
typeof entry.source === "string" ||
|
|
66
|
+
(typeof Blob !== "undefined" && entry.source instanceof Blob)) {
|
|
67
|
+
const bytes = await (0, archive_source_1.toUint8Array)(entry.source);
|
|
68
|
+
await file.push(bytes, true);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
for await (const chunk of (0, archive_source_1.toAsyncIterable)(entry.source)) {
|
|
72
|
+
await file.push(chunk, false);
|
|
73
|
+
}
|
|
74
|
+
await file.push(new Uint8Array(0), true);
|
|
75
|
+
}
|
|
76
|
+
await file.complete();
|
|
77
|
+
}
|
|
78
|
+
zip.end();
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
queue.fail(e instanceof Error ? e : new Error(String(e)));
|
|
82
|
+
}
|
|
83
|
+
})();
|
|
84
|
+
return queue.iterable;
|
|
85
|
+
}
|
|
86
|
+
async bytes() {
|
|
87
|
+
this._sealed = true;
|
|
88
|
+
const allSourcesInMemory = this._entries.every(e => e.source instanceof Uint8Array ||
|
|
89
|
+
e.source instanceof ArrayBuffer ||
|
|
90
|
+
typeof e.source === "string" ||
|
|
91
|
+
(typeof Blob !== "undefined" && e.source instanceof Blob));
|
|
92
|
+
const hasBlobSource = this._entries.some(e => typeof Blob !== "undefined" && e.source instanceof Blob);
|
|
93
|
+
// Fast-path: when all sources are already in memory and there are no
|
|
94
|
+
// per-entry compression overrides, use the single-buffer ZIP builder.
|
|
95
|
+
// This avoids the overhead of chunking + collecting from the streaming writer.
|
|
96
|
+
if (allSourcesInMemory) {
|
|
97
|
+
// Prefer the sync builder when possible (Node.js hot path): it avoids
|
|
98
|
+
// async/Promise overhead and uses zlib sync fast paths.
|
|
99
|
+
if (!hasBlobSource) {
|
|
100
|
+
const entries = this._entries.map(e => ({
|
|
101
|
+
name: e.name,
|
|
102
|
+
data: (0, archive_source_1.toUint8ArraySync)(e.source),
|
|
103
|
+
level: e.options?.level,
|
|
104
|
+
modTime: e.options?.modTime,
|
|
105
|
+
comment: e.options?.comment
|
|
106
|
+
}));
|
|
107
|
+
return (0, zip_bytes_1.createZipSync)(entries, {
|
|
108
|
+
level: this._options.level,
|
|
109
|
+
timestamps: this._options.timestamps,
|
|
110
|
+
modTime: this._options.modTime,
|
|
111
|
+
comment: this._options.comment,
|
|
112
|
+
smartStore: this._options.smartStore
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
const entries = await Promise.all(this._entries.map(async (e) => ({
|
|
116
|
+
name: e.name,
|
|
117
|
+
data: await (0, archive_source_1.toUint8Array)(e.source),
|
|
118
|
+
level: e.options?.level,
|
|
119
|
+
modTime: e.options?.modTime,
|
|
120
|
+
comment: e.options?.comment
|
|
121
|
+
})));
|
|
122
|
+
return (0, zip_bytes_1.createZip)(entries, {
|
|
123
|
+
level: this._options.level,
|
|
124
|
+
timestamps: this._options.timestamps,
|
|
125
|
+
modTime: this._options.modTime,
|
|
126
|
+
comment: this._options.comment,
|
|
127
|
+
smartStore: this._options.smartStore
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return (0, archive_sink_1.collect)(this.stream());
|
|
131
|
+
}
|
|
132
|
+
bytesSync() {
|
|
133
|
+
this._sealed = true;
|
|
134
|
+
const entries = this._entries.map(e => {
|
|
135
|
+
if (!(e.source instanceof Uint8Array) &&
|
|
136
|
+
!(e.source instanceof ArrayBuffer) &&
|
|
137
|
+
typeof e.source !== "string") {
|
|
138
|
+
throw new Error("bytesSync() only supports Uint8Array/ArrayBuffer/string sources");
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
name: e.name,
|
|
142
|
+
data: (0, archive_source_1.toUint8ArraySync)(e.source),
|
|
143
|
+
modTime: e.options?.modTime,
|
|
144
|
+
comment: e.options?.comment
|
|
145
|
+
};
|
|
146
|
+
});
|
|
147
|
+
return (0, zip_bytes_1.createZipSync)(entries, {
|
|
148
|
+
level: this._options.level,
|
|
149
|
+
timestamps: this._options.timestamps,
|
|
150
|
+
modTime: this._options.modTime,
|
|
151
|
+
comment: this._options.comment,
|
|
152
|
+
smartStore: this._options.smartStore
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
async pipeTo(sink) {
|
|
156
|
+
await (0, archive_sink_1.pipeIterableToSink)(this.stream(), sink);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
exports.ZipArchive = ZipArchive;
|
|
160
|
+
function zip(options) {
|
|
161
|
+
return new ZipArchive(options);
|
|
162
|
+
}
|
|
@@ -3,17 +3,18 @@
|
|
|
3
3
|
* True Streaming ZIP creator - shared implementation.
|
|
4
4
|
*
|
|
5
5
|
* This module is intentionally platform-agnostic.
|
|
6
|
-
* - In Node builds it uses `./crc32` + `./streaming-compress` (zlib-backed).
|
|
6
|
+
* - In Node builds it uses `./compression/crc32` + `./compression/streaming-compress` (zlib-backed).
|
|
7
7
|
* - In browser builds the bundler aliases those imports to their browser variants.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.ZipDeflate = exports.Zip = exports.StreamingZip = exports.ZipDeflateFile = void 0;
|
|
11
|
-
const crc32_1 = require("
|
|
12
|
-
const streaming_compress_1 = require("
|
|
13
|
-
const defaults_1 = require("
|
|
11
|
+
const crc32_1 = require("../compression/crc32.js");
|
|
12
|
+
const streaming_compress_1 = require("../compression/streaming-compress.js");
|
|
13
|
+
const defaults_1 = require("../defaults.js");
|
|
14
14
|
const zip_entry_metadata_1 = require("./zip-entry-metadata.js");
|
|
15
|
-
const
|
|
16
|
-
const
|
|
15
|
+
const text_1 = require("../utils/text.js");
|
|
16
|
+
const compressibility_1 = require("../utils/compressibility.js");
|
|
17
|
+
const zip_records_1 = require("../zip-spec/zip-records.js");
|
|
17
18
|
/**
|
|
18
19
|
* True Streaming ZIP File - compresses chunk by chunk
|
|
19
20
|
*/
|
|
@@ -26,9 +27,15 @@ class ZipDeflateFile {
|
|
|
26
27
|
this._finalized = false;
|
|
27
28
|
this._headerEmitted = false;
|
|
28
29
|
this._ondata = null;
|
|
30
|
+
this._onerror = null;
|
|
29
31
|
this._centralDirEntryInfo = null;
|
|
30
32
|
this._pendingEnd = false;
|
|
31
33
|
this._emittedDataDescriptor = false;
|
|
34
|
+
this._localHeader = null;
|
|
35
|
+
// Smart STORE: delay method selection until we sample data.
|
|
36
|
+
this._deflateWanted = null;
|
|
37
|
+
this._pendingChunks = [];
|
|
38
|
+
this._sampleLen = 0;
|
|
32
39
|
// Promise resolution for completion (including data descriptor)
|
|
33
40
|
this._completeResolve = null;
|
|
34
41
|
this._completeReject = null;
|
|
@@ -37,46 +44,70 @@ class ZipDeflateFile {
|
|
|
37
44
|
// Queue for incoming data before ondata is set
|
|
38
45
|
this._dataQueue = [];
|
|
39
46
|
this._finalQueued = false;
|
|
47
|
+
// Serialize push() calls so callers don't need to await to preserve ordering.
|
|
48
|
+
this._pushChain = Promise.resolve();
|
|
40
49
|
this.name = name;
|
|
41
50
|
const modTime = options?.modTime ?? new Date();
|
|
42
51
|
this._modTime = modTime;
|
|
43
52
|
this.level = options?.level ?? defaults_1.DEFAULT_ZIP_LEVEL;
|
|
53
|
+
this._smartStore = options?.smartStore ?? true;
|
|
54
|
+
this._sampleBuffer = this._smartStore ? new Uint8Array(64 * 1024) : new Uint8Array(0);
|
|
44
55
|
const metadata = (0, zip_entry_metadata_1.buildZipEntryMetadata)({
|
|
45
56
|
name,
|
|
46
|
-
comment: "",
|
|
57
|
+
comment: options?.comment ?? "",
|
|
47
58
|
modTime,
|
|
48
59
|
timestamps: options?.timestamps ?? defaults_1.DEFAULT_ZIP_TIMESTAMPS,
|
|
49
60
|
useDataDescriptor: true,
|
|
50
|
-
deflate:
|
|
61
|
+
deflate: false
|
|
51
62
|
});
|
|
52
63
|
this.nameBytes = metadata.nameBytes;
|
|
64
|
+
this.commentBytes = metadata.commentBytes;
|
|
53
65
|
this.dosTime = metadata.dosTime;
|
|
54
66
|
this.dosDate = metadata.dosDate;
|
|
55
67
|
this.extraField = metadata.extraField;
|
|
56
68
|
this._flags = metadata.flags;
|
|
57
69
|
this._compressionMethod = metadata.compressionMethod;
|
|
58
|
-
//
|
|
59
|
-
if (this.
|
|
60
|
-
|
|
61
|
-
this.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
this._enqueueData(chunk, false);
|
|
68
|
-
});
|
|
69
|
-
// Handle end - emit data descriptor
|
|
70
|
-
// IMPORTANT: Only use 'end' event, NOT 'finish'!
|
|
71
|
-
// Node.js zlib emits events in order: finish -> data -> end
|
|
72
|
-
this._deflate.on("end", () => {
|
|
73
|
-
if (this._pendingEnd && !this._emittedDataDescriptor) {
|
|
74
|
-
this._emittedDataDescriptor = true;
|
|
75
|
-
this._emitDataDescriptor();
|
|
76
|
-
}
|
|
77
|
-
});
|
|
70
|
+
// If smart store is disabled, decide method upfront and keep true streaming semantics.
|
|
71
|
+
if (!this._smartStore) {
|
|
72
|
+
const deflate = this.level > 0;
|
|
73
|
+
this._deflateWanted = deflate;
|
|
74
|
+
this._compressionMethod = this._buildCompressionMethod(deflate);
|
|
75
|
+
if (deflate) {
|
|
76
|
+
this._initDeflateStream();
|
|
77
|
+
}
|
|
78
|
+
return;
|
|
78
79
|
}
|
|
79
|
-
|
|
80
|
+
// Level 0: always STORE.
|
|
81
|
+
if (this.level === 0) {
|
|
82
|
+
this._deflateWanted = false;
|
|
83
|
+
this._compressionMethod = this._buildCompressionMethod(false);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
_buildCompressionMethod(deflate) {
|
|
87
|
+
return (0, zip_entry_metadata_1.resolveZipCompressionMethod)(deflate);
|
|
88
|
+
}
|
|
89
|
+
_initDeflateStream() {
|
|
90
|
+
if (this._deflate) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
this._deflate = (0, streaming_compress_1.createDeflateStream)({ level: this.level });
|
|
94
|
+
this._deflate.on("error", (err) => {
|
|
95
|
+
this._rejectComplete(err);
|
|
96
|
+
});
|
|
97
|
+
// Handle compressed output - this is true streaming!
|
|
98
|
+
this._deflate.on("data", (chunk) => {
|
|
99
|
+
this._compressedSize += chunk.length;
|
|
100
|
+
this._enqueueData(chunk, false);
|
|
101
|
+
});
|
|
102
|
+
// Handle end - emit data descriptor
|
|
103
|
+
// IMPORTANT: Only use 'end' event, NOT 'finish'!
|
|
104
|
+
// Node.js zlib emits events in order: finish -> data -> end
|
|
105
|
+
this._deflate.on("end", () => {
|
|
106
|
+
if (this._pendingEnd && !this._emittedDataDescriptor) {
|
|
107
|
+
this._emittedDataDescriptor = true;
|
|
108
|
+
this._emitDataDescriptor();
|
|
109
|
+
}
|
|
110
|
+
});
|
|
80
111
|
}
|
|
81
112
|
_buildLocalHeader() {
|
|
82
113
|
// CRC + sizes are written via data descriptor for true streaming.
|
|
@@ -90,9 +121,66 @@ class ZipDeflateFile {
|
|
|
90
121
|
crc32: 0,
|
|
91
122
|
compressedSize: 0,
|
|
92
123
|
uncompressedSize: 0,
|
|
93
|
-
versionNeeded:
|
|
124
|
+
versionNeeded: zip_records_1.VERSION_NEEDED
|
|
94
125
|
});
|
|
95
126
|
}
|
|
127
|
+
_accumulateSample(data) {
|
|
128
|
+
if (this._deflateWanted !== null) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (this._sampleLen >= this._sampleBuffer.length) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const take = Math.min(this._sampleBuffer.length - this._sampleLen, data.length);
|
|
135
|
+
if (take <= 0) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
this._sampleBuffer.set(data.subarray(0, take), this._sampleLen);
|
|
139
|
+
this._sampleLen += take;
|
|
140
|
+
}
|
|
141
|
+
_shouldDecide(final) {
|
|
142
|
+
if (this._deflateWanted !== null) {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
return final || this._sampleLen >= 16 * 1024;
|
|
146
|
+
}
|
|
147
|
+
_decideCompressionIfNeeded(final) {
|
|
148
|
+
if (this._deflateWanted !== null) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
// Match non-streaming builder semantics: empty files never need DEFLATE.
|
|
152
|
+
if (final && this._sampleLen === 0) {
|
|
153
|
+
this._deflateWanted = false;
|
|
154
|
+
this._compressionMethod = this._buildCompressionMethod(false);
|
|
155
|
+
this._localHeader = null;
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
// Default to DEFLATE unless heuristic says STORE.
|
|
159
|
+
const sample = this._sampleBuffer.subarray(0, this._sampleLen);
|
|
160
|
+
const store = (0, compressibility_1.isProbablyIncompressible)(sample);
|
|
161
|
+
this._deflateWanted = !store;
|
|
162
|
+
this._compressionMethod = this._buildCompressionMethod(this._deflateWanted);
|
|
163
|
+
this._localHeader = null;
|
|
164
|
+
if (this._deflateWanted) {
|
|
165
|
+
this._initDeflateStream();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
_emitHeaderIfNeeded() {
|
|
169
|
+
if (this._headerEmitted) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
this._emitHeader();
|
|
173
|
+
this._headerEmitted = true;
|
|
174
|
+
}
|
|
175
|
+
async _flushPendingChunks() {
|
|
176
|
+
if (this._pendingChunks.length === 0) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
for (const chunk of this._pendingChunks) {
|
|
180
|
+
await this._writeData(chunk);
|
|
181
|
+
}
|
|
182
|
+
this._pendingChunks = [];
|
|
183
|
+
}
|
|
96
184
|
_enqueueData(data, final) {
|
|
97
185
|
if (this._ondata) {
|
|
98
186
|
this._ondata(data, final);
|
|
@@ -124,13 +212,29 @@ class ZipDeflateFile {
|
|
|
124
212
|
// Flush any queued data
|
|
125
213
|
this._flushQueue();
|
|
126
214
|
}
|
|
215
|
+
get onerror() {
|
|
216
|
+
return this._onerror ?? undefined;
|
|
217
|
+
}
|
|
218
|
+
set onerror(cb) {
|
|
219
|
+
this._onerror = cb;
|
|
220
|
+
// If an error already occurred, surface it immediately.
|
|
221
|
+
if (this._completeError) {
|
|
222
|
+
cb(this._completeError);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
127
225
|
_resolveComplete() {
|
|
128
226
|
if (this._completeResolve) {
|
|
129
227
|
this._completeResolve();
|
|
130
228
|
}
|
|
131
229
|
}
|
|
132
230
|
_rejectComplete(err) {
|
|
231
|
+
if (this._completeError) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
133
234
|
this._completeError = err;
|
|
235
|
+
if (this._onerror) {
|
|
236
|
+
this._onerror(err);
|
|
237
|
+
}
|
|
134
238
|
if (this._completeReject) {
|
|
135
239
|
this._completeReject(err);
|
|
136
240
|
}
|
|
@@ -156,13 +260,6 @@ class ZipDeflateFile {
|
|
|
156
260
|
}
|
|
157
261
|
promise.then(() => callback()).catch(err => callback(err));
|
|
158
262
|
}
|
|
159
|
-
_emitHeaderIfNeeded() {
|
|
160
|
-
if (this._headerEmitted) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
this._emitHeader();
|
|
164
|
-
this._headerEmitted = true;
|
|
165
|
-
}
|
|
166
263
|
_writeData(data) {
|
|
167
264
|
if (data.length === 0) {
|
|
168
265
|
return Promise.resolve();
|
|
@@ -220,27 +317,60 @@ class ZipDeflateFile {
|
|
|
220
317
|
this._emitDataDescriptor();
|
|
221
318
|
return completePromise;
|
|
222
319
|
}
|
|
223
|
-
|
|
224
|
-
* Push data - immediately compresses and outputs
|
|
225
|
-
* Returns a Promise that resolves when the write is complete.
|
|
226
|
-
* If final=true, it resolves after the data descriptor is emitted.
|
|
227
|
-
*/
|
|
228
|
-
push(data, final = false, callback) {
|
|
320
|
+
_pushUnchained(data, final, callback) {
|
|
229
321
|
if (this._finalized) {
|
|
230
322
|
const promise = Promise.reject(new Error("Cannot push to finalized ZipDeflateFile"));
|
|
231
323
|
this._tapCallback(promise, callback);
|
|
232
324
|
return promise;
|
|
233
325
|
}
|
|
326
|
+
if (this._deflateWanted === null) {
|
|
327
|
+
this._accumulateSample(data);
|
|
328
|
+
if (!this._shouldDecide(final)) {
|
|
329
|
+
if (data.length > 0) {
|
|
330
|
+
this._pendingChunks.push(data);
|
|
331
|
+
}
|
|
332
|
+
const promise = Promise.resolve();
|
|
333
|
+
this._tapCallback(promise, callback);
|
|
334
|
+
return promise;
|
|
335
|
+
}
|
|
336
|
+
this._decideCompressionIfNeeded(final);
|
|
337
|
+
this._emitHeaderIfNeeded();
|
|
338
|
+
const hadPendingChunks = this._pendingChunks.length > 0;
|
|
339
|
+
const flushPromise = this._flushPendingChunks();
|
|
340
|
+
let writePromise = flushPromise;
|
|
341
|
+
if (data.length > 0) {
|
|
342
|
+
writePromise = hadPendingChunks
|
|
343
|
+
? flushPromise.then(() => this._writeData(data))
|
|
344
|
+
: this._writeData(data);
|
|
345
|
+
}
|
|
346
|
+
const promise = final ? this._finalizeAfterWrite(writePromise) : writePromise;
|
|
347
|
+
this._tapCallback(promise, callback);
|
|
348
|
+
return promise;
|
|
349
|
+
}
|
|
234
350
|
this._emitHeaderIfNeeded();
|
|
235
351
|
const writePromise = this._writeData(data);
|
|
236
352
|
const promise = final ? this._finalizeAfterWrite(writePromise) : writePromise;
|
|
237
353
|
this._tapCallback(promise, callback);
|
|
238
354
|
return promise;
|
|
239
355
|
}
|
|
356
|
+
/**
|
|
357
|
+
* Push data - immediately compresses and outputs
|
|
358
|
+
* Returns a Promise that resolves when the write is complete.
|
|
359
|
+
* If final=true, it resolves after the data descriptor is emitted.
|
|
360
|
+
*/
|
|
361
|
+
push(data, final = false, callback) {
|
|
362
|
+
const promise = (this._pushChain = this._pushChain.then(() => this._pushUnchained(data, final, callback)));
|
|
363
|
+
// Prevent unhandled rejection when callers intentionally ignore the Promise.
|
|
364
|
+
promise.catch(() => { });
|
|
365
|
+
return promise;
|
|
366
|
+
}
|
|
240
367
|
/**
|
|
241
368
|
* Emit local file header with Data Descriptor flag
|
|
242
369
|
*/
|
|
243
370
|
_emitHeader() {
|
|
371
|
+
if (!this._localHeader) {
|
|
372
|
+
this._localHeader = this._buildLocalHeader();
|
|
373
|
+
}
|
|
244
374
|
this._enqueueData(this._localHeader, false);
|
|
245
375
|
}
|
|
246
376
|
/**
|
|
@@ -253,6 +383,7 @@ class ZipDeflateFile {
|
|
|
253
383
|
this._centralDirEntryInfo = {
|
|
254
384
|
name: this.nameBytes,
|
|
255
385
|
extraField: this.extraField,
|
|
386
|
+
comment: this.commentBytes,
|
|
256
387
|
flags: this._flags,
|
|
257
388
|
crc: crcValue,
|
|
258
389
|
compressedSize: this._compressedSize,
|
|
@@ -291,7 +422,7 @@ class ZipDeflateFile {
|
|
|
291
422
|
crc32: this._centralDirEntryInfo.crc,
|
|
292
423
|
lastModified: this._modTime,
|
|
293
424
|
localHeaderOffset: this._centralDirEntryInfo.offset,
|
|
294
|
-
comment:
|
|
425
|
+
comment: (0, text_1.decodeUtf8)(this._centralDirEntryInfo.comment),
|
|
295
426
|
externalAttributes: 0,
|
|
296
427
|
isEncrypted: false
|
|
297
428
|
};
|
|
@@ -310,7 +441,7 @@ exports.ZipDeflate = ZipDeflateFile;
|
|
|
310
441
|
* Streaming ZIP Creator - processes files sequentially
|
|
311
442
|
*/
|
|
312
443
|
class StreamingZip {
|
|
313
|
-
constructor(callback) {
|
|
444
|
+
constructor(callback, options) {
|
|
314
445
|
this.entries = [];
|
|
315
446
|
this.currentOffset = 0;
|
|
316
447
|
this.ended = false;
|
|
@@ -320,10 +451,12 @@ class StreamingZip {
|
|
|
320
451
|
this.fileQueueIndex = 0;
|
|
321
452
|
this.activeFile = null;
|
|
322
453
|
this.callback = callback;
|
|
454
|
+
// Avoid per-instance TextEncoder allocations.
|
|
455
|
+
this.zipComment = options?.comment ? (0, text_1.encodeUtf8)(options.comment) : new Uint8Array(0);
|
|
323
456
|
}
|
|
324
457
|
add(file) {
|
|
325
458
|
if (this.ended) {
|
|
326
|
-
throw new Error("Cannot add files after calling end()");
|
|
459
|
+
throw new Error("Cannot add files after calling end() ");
|
|
327
460
|
}
|
|
328
461
|
this.fileQueue.push(file);
|
|
329
462
|
// If no active file, process this one
|
|
@@ -346,7 +479,18 @@ class StreamingZip {
|
|
|
346
479
|
const file = this.fileQueue[this.fileQueueIndex++];
|
|
347
480
|
this.activeFile = file;
|
|
348
481
|
const startOffset = this.currentOffset;
|
|
482
|
+
const empty = new Uint8Array(0);
|
|
483
|
+
file.onerror = (err) => {
|
|
484
|
+
if (this.ended) {
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
this.ended = true;
|
|
488
|
+
this.callback(err, empty, true);
|
|
489
|
+
};
|
|
349
490
|
file.ondata = (data, final) => {
|
|
491
|
+
if (this.ended) {
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
350
494
|
this.currentOffset += data.length;
|
|
351
495
|
this.callback(null, data, false);
|
|
352
496
|
if (final) {
|
|
@@ -372,7 +516,7 @@ class StreamingZip {
|
|
|
372
516
|
const header = (0, zip_records_1.buildCentralDirectoryHeader)({
|
|
373
517
|
fileName: entry.name,
|
|
374
518
|
extraField: entry.extraField,
|
|
375
|
-
comment: empty,
|
|
519
|
+
comment: entry.comment ?? empty,
|
|
376
520
|
flags: entry.flags,
|
|
377
521
|
compressionMethod: entry.compressionMethod,
|
|
378
522
|
dosTime: entry.dosTime,
|
|
@@ -381,8 +525,8 @@ class StreamingZip {
|
|
|
381
525
|
compressedSize: entry.compressedSize,
|
|
382
526
|
uncompressedSize: entry.uncompressedSize,
|
|
383
527
|
localHeaderOffset: entry.offset,
|
|
384
|
-
versionMadeBy:
|
|
385
|
-
versionNeeded:
|
|
528
|
+
versionMadeBy: zip_records_1.VERSION_MADE_BY,
|
|
529
|
+
versionNeeded: zip_records_1.VERSION_NEEDED
|
|
386
530
|
});
|
|
387
531
|
centralDirSize += header.length;
|
|
388
532
|
this.callback(null, header, false);
|
|
@@ -391,7 +535,7 @@ class StreamingZip {
|
|
|
391
535
|
entryCount: this.entries.length,
|
|
392
536
|
centralDirSize,
|
|
393
537
|
centralDirOffset,
|
|
394
|
-
comment:
|
|
538
|
+
comment: this.zipComment
|
|
395
539
|
});
|
|
396
540
|
this.callback(null, eocd, true);
|
|
397
541
|
}
|