@cj-tech-master/excelts 4.2.0 → 4.2.1-canary.20260112134913.a3cecdd
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/{types/modules/archive → browser/modules/archive/compression}/compress.base.d.ts +1 -0
- package/dist/browser/modules/archive/{compress.base.js → compression/compress.base.js} +2 -1
- package/dist/{types/modules/archive → browser/modules/archive/compression}/compress.browser.d.ts +10 -8
- package/dist/{esm/modules/archive → browser/modules/archive/compression}/compress.browser.js +18 -19
- package/dist/browser/modules/archive/{compress.d.ts → compression/compress.d.ts} +2 -2
- package/dist/browser/modules/archive/{compress.js → 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} +58 -3
- 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} +376 -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} +7 -6
- package/dist/{types/modules/archive → browser/modules/archive/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/form-control.d.ts +2 -0
- package/dist/browser/modules/excel/form-control.js +54 -16
- 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 +117 -5
- 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 -42
- package/dist/browser/modules/stream/streams.browser.js +941 -823
- 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} +2 -1
- package/dist/cjs/modules/archive/{compress.browser.js → compression/compress.browser.js} +18 -19
- 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} +377 -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/form-control.js +54 -16
- 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 +117 -5
- 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 +947 -834
- 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/esm/modules/archive/{compress.base.js → compression/compress.base.js} +2 -1
- package/dist/{browser/modules/archive → esm/modules/archive/compression}/compress.browser.js +18 -19
- package/dist/esm/modules/archive/{compress.js → 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} +376 -110
- package/dist/{browser/modules/archive/parse.js → esm/modules/archive/unzip/stream.js} +7 -6
- 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/form-control.js +54 -16
- 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 +117 -5
- 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 +941 -823
- 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 +81 -0
- package/dist/iife/excelts.iife.js +4979 -2800
- 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.base.d.ts +1 -0
- package/dist/{browser/modules/archive → types/modules/archive/compression}/compress.browser.d.ts +10 -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} +60 -5
- 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/{browser/modules/archive → types/modules/archive/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/form-control.d.ts +2 -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 -42
- package/dist/types/modules/stream/streams.d.ts +4 -20
- package/package.json +19 -15
- 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 -610
- 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 -632
- 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 -610
- 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/{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/{LICENSE → iife/LICENSE} +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
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ZIP file format builder
|
|
3
|
-
*
|
|
4
|
-
* Implements ZIP file structure according to PKWARE's APPNOTE.TXT specification
|
|
5
|
-
* https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
|
|
6
|
-
*
|
|
7
|
-
* ZIP file structure:
|
|
8
|
-
* ┌──────────────────────────┐
|
|
9
|
-
* │ Local File Header 1 │
|
|
10
|
-
* │ File Data 1 │
|
|
11
|
-
* ├──────────────────────────┤
|
|
12
|
-
* │ Local File Header 2 │
|
|
13
|
-
* │ File Data 2 │
|
|
14
|
-
* ├──────────────────────────┤
|
|
15
|
-
* │ ... │
|
|
16
|
-
* ├──────────────────────────┤
|
|
17
|
-
* │ Central Directory 1 │
|
|
18
|
-
* │ Central Directory 2 │
|
|
19
|
-
* │ ... │
|
|
20
|
-
* ├──────────────────────────┤
|
|
21
|
-
* │ End of Central Directory │
|
|
22
|
-
* └──────────────────────────┘
|
|
23
|
-
*/
|
|
24
|
-
import { compress, compressSync } from "./compress.js";
|
|
25
|
-
import { crc32 } from "./crc32.js";
|
|
26
|
-
import { concatUint8Arrays, sumUint8ArrayLengths } from "./utils/bytes.js";
|
|
27
|
-
import {} from "./utils/timestamps.js";
|
|
28
|
-
import { buildZipEntryMetadata, resolveZipCompressionMethod } from "./zip-entry-metadata.js";
|
|
29
|
-
import { DEFAULT_ZIP_LEVEL, DEFAULT_ZIP_TIMESTAMPS } from "./defaults.js";
|
|
30
|
-
import { buildCentralDirectoryHeader, buildEndOfCentralDirectory, buildLocalFileHeader } from "./zip-records.js";
|
|
31
|
-
import { FLAG_UTF8, VERSION_MADE_BY, VERSION_NEEDED } from "./zip-constants.js";
|
|
32
|
-
const LOCAL_FILE_HEADER_FIXED_SIZE = 30;
|
|
33
|
-
function encodeZipComment(comment) {
|
|
34
|
-
// Keep empty comment as empty bytes (no encoding surprises).
|
|
35
|
-
return comment ? new TextEncoder().encode(comment) : new Uint8Array(0);
|
|
36
|
-
}
|
|
37
|
-
function shouldDeflate(level, data) {
|
|
38
|
-
return level > 0 && data.length > 0;
|
|
39
|
-
}
|
|
40
|
-
function computeLocalRecordSize(entry) {
|
|
41
|
-
return (LOCAL_FILE_HEADER_FIXED_SIZE +
|
|
42
|
-
entry.name.length +
|
|
43
|
-
entry.extraField.length +
|
|
44
|
-
entry.compressedData.length);
|
|
45
|
-
}
|
|
46
|
-
function buildProcessedEntry(entry, offset, settings, compressedData) {
|
|
47
|
-
const modDate = entry.modTime ?? settings.defaultModTime;
|
|
48
|
-
const isCompressed = shouldDeflate(settings.level, entry.data);
|
|
49
|
-
const metadata = buildZipEntryMetadata({
|
|
50
|
-
name: entry.name,
|
|
51
|
-
comment: entry.comment,
|
|
52
|
-
modTime: modDate,
|
|
53
|
-
timestamps: settings.timestamps,
|
|
54
|
-
useDataDescriptor: false,
|
|
55
|
-
deflate: isCompressed
|
|
56
|
-
});
|
|
57
|
-
return {
|
|
58
|
-
name: metadata.nameBytes,
|
|
59
|
-
data: entry.data,
|
|
60
|
-
compressedData,
|
|
61
|
-
crc: crc32(entry.data),
|
|
62
|
-
compressionMethod: resolveZipCompressionMethod(isCompressed),
|
|
63
|
-
modTime: metadata.dosTime,
|
|
64
|
-
modDate: metadata.dosDate,
|
|
65
|
-
extraField: metadata.extraField,
|
|
66
|
-
comment: metadata.commentBytes,
|
|
67
|
-
offset
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
function appendProcessedEntry(processedEntries, entry, compressedData, currentOffset, settings) {
|
|
71
|
-
const processedEntry = buildProcessedEntry(entry, currentOffset, settings, compressedData);
|
|
72
|
-
processedEntries.push(processedEntry);
|
|
73
|
-
return {
|
|
74
|
-
processedEntry,
|
|
75
|
-
nextOffset: currentOffset + computeLocalRecordSize(processedEntry)
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
function finalizeZip(processedEntries, zipComment, centralDirOffset) {
|
|
79
|
-
// Build ZIP structure
|
|
80
|
-
const chunks = [];
|
|
81
|
-
// Local file headers and data
|
|
82
|
-
for (const entry of processedEntries) {
|
|
83
|
-
chunks.push(buildLocalFileHeaderChunk(entry));
|
|
84
|
-
chunks.push(entry.compressedData);
|
|
85
|
-
}
|
|
86
|
-
chunks.push(...buildCentralDirectorySection(processedEntries, centralDirOffset, zipComment));
|
|
87
|
-
return concatUint8Arrays(chunks);
|
|
88
|
-
}
|
|
89
|
-
function buildLocalFileHeaderChunk(entry) {
|
|
90
|
-
return buildLocalFileHeader({
|
|
91
|
-
fileName: entry.name,
|
|
92
|
-
extraField: entry.extraField,
|
|
93
|
-
flags: FLAG_UTF8,
|
|
94
|
-
compressionMethod: entry.compressionMethod,
|
|
95
|
-
dosTime: entry.modTime,
|
|
96
|
-
dosDate: entry.modDate,
|
|
97
|
-
crc32: entry.crc,
|
|
98
|
-
compressedSize: entry.compressedData.length,
|
|
99
|
-
uncompressedSize: entry.data.length,
|
|
100
|
-
versionNeeded: VERSION_NEEDED
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
function buildCentralDirHeaderChunk(entry) {
|
|
104
|
-
return buildCentralDirectoryHeader({
|
|
105
|
-
fileName: entry.name,
|
|
106
|
-
extraField: entry.extraField,
|
|
107
|
-
comment: entry.comment,
|
|
108
|
-
flags: FLAG_UTF8,
|
|
109
|
-
compressionMethod: entry.compressionMethod,
|
|
110
|
-
dosTime: entry.modTime,
|
|
111
|
-
dosDate: entry.modDate,
|
|
112
|
-
crc32: entry.crc,
|
|
113
|
-
compressedSize: entry.compressedData.length,
|
|
114
|
-
uncompressedSize: entry.data.length,
|
|
115
|
-
localHeaderOffset: entry.offset,
|
|
116
|
-
versionMadeBy: VERSION_MADE_BY,
|
|
117
|
-
versionNeeded: VERSION_NEEDED
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
function buildCentralDirectorySection(processedEntries, centralDirOffset, zipComment) {
|
|
121
|
-
const chunks = [];
|
|
122
|
-
for (const entry of processedEntries) {
|
|
123
|
-
chunks.push(buildCentralDirHeaderChunk(entry));
|
|
124
|
-
}
|
|
125
|
-
const centralDirSize = sumUint8ArrayLengths(chunks);
|
|
126
|
-
chunks.push(buildEndOfCentralDirectory({
|
|
127
|
-
entryCount: processedEntries.length,
|
|
128
|
-
centralDirSize,
|
|
129
|
-
centralDirOffset,
|
|
130
|
-
comment: zipComment
|
|
131
|
-
}));
|
|
132
|
-
return chunks;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Create a ZIP file from entries (async)
|
|
136
|
-
*
|
|
137
|
-
* @param entries - Files to include in ZIP
|
|
138
|
-
* @param options - ZIP options
|
|
139
|
-
* @returns ZIP file as Uint8Array
|
|
140
|
-
*
|
|
141
|
-
* @example
|
|
142
|
-
* ```ts
|
|
143
|
-
* const zip = await createZip([
|
|
144
|
-
* { name: "hello.txt", data: new TextEncoder().encode("Hello!") },
|
|
145
|
-
* { name: "folder/file.txt", data: new TextEncoder().encode("Nested!") }
|
|
146
|
-
* ], { level: 6 });
|
|
147
|
-
* ```
|
|
148
|
-
*/
|
|
149
|
-
export async function createZip(entries, options = {}) {
|
|
150
|
-
const level = options.level ?? DEFAULT_ZIP_LEVEL;
|
|
151
|
-
const timestamps = options.timestamps ?? DEFAULT_ZIP_TIMESTAMPS;
|
|
152
|
-
const zipComment = encodeZipComment(options.comment);
|
|
153
|
-
const defaultModTime = new Date();
|
|
154
|
-
const settings = {
|
|
155
|
-
level,
|
|
156
|
-
timestamps,
|
|
157
|
-
defaultModTime
|
|
158
|
-
};
|
|
159
|
-
const compressOptions = {
|
|
160
|
-
level,
|
|
161
|
-
thresholdBytes: options.thresholdBytes
|
|
162
|
-
};
|
|
163
|
-
const compressedDatas = await Promise.all(entries.map(async (entry) => {
|
|
164
|
-
return shouldDeflate(level, entry.data) ? compress(entry.data, compressOptions) : entry.data;
|
|
165
|
-
}));
|
|
166
|
-
// Process entries
|
|
167
|
-
const processedEntries = [];
|
|
168
|
-
let currentOffset = 0;
|
|
169
|
-
for (let i = 0; i < entries.length; i++) {
|
|
170
|
-
const entry = entries[i];
|
|
171
|
-
const compressedData = compressedDatas[i];
|
|
172
|
-
const result = appendProcessedEntry(processedEntries, entry, compressedData, currentOffset, settings);
|
|
173
|
-
currentOffset = result.nextOffset;
|
|
174
|
-
}
|
|
175
|
-
return finalizeZip(processedEntries, zipComment, currentOffset);
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Create a ZIP file from entries (sync)
|
|
179
|
-
*
|
|
180
|
-
* This is supported in both Node.js and browser builds.
|
|
181
|
-
*/
|
|
182
|
-
export function createZipSync(entries, options = {}) {
|
|
183
|
-
const level = options.level ?? DEFAULT_ZIP_LEVEL;
|
|
184
|
-
const timestamps = options.timestamps ?? DEFAULT_ZIP_TIMESTAMPS;
|
|
185
|
-
const zipComment = encodeZipComment(options.comment);
|
|
186
|
-
const defaultModTime = new Date();
|
|
187
|
-
const settings = {
|
|
188
|
-
level,
|
|
189
|
-
timestamps,
|
|
190
|
-
defaultModTime
|
|
191
|
-
};
|
|
192
|
-
const compressOptions = {
|
|
193
|
-
level,
|
|
194
|
-
thresholdBytes: options.thresholdBytes
|
|
195
|
-
};
|
|
196
|
-
// Process entries
|
|
197
|
-
const processedEntries = [];
|
|
198
|
-
let currentOffset = 0;
|
|
199
|
-
for (const entry of entries) {
|
|
200
|
-
// Compress data
|
|
201
|
-
const compressedData = shouldDeflate(level, entry.data)
|
|
202
|
-
? compressSync(entry.data, compressOptions)
|
|
203
|
-
: entry.data;
|
|
204
|
-
const result = appendProcessedEntry(processedEntries, entry, compressedData, currentOffset, settings);
|
|
205
|
-
currentOffset = result.nextOffset;
|
|
206
|
-
}
|
|
207
|
-
return finalizeZip(processedEntries, zipComment, currentOffset);
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Streaming ZIP builder for large files
|
|
211
|
-
* Writes chunks to a callback as they are generated
|
|
212
|
-
*/
|
|
213
|
-
export class ZipBuilder {
|
|
214
|
-
/**
|
|
215
|
-
* Create a new ZIP builder
|
|
216
|
-
* @param options - ZIP options
|
|
217
|
-
*/
|
|
218
|
-
constructor(options = {}) {
|
|
219
|
-
this.entries = [];
|
|
220
|
-
this.currentOffset = 0;
|
|
221
|
-
this.finalized = false;
|
|
222
|
-
this.level = options.level ?? DEFAULT_ZIP_LEVEL;
|
|
223
|
-
this.zipComment = encodeZipComment(options.comment);
|
|
224
|
-
this.timestamps = options.timestamps ?? DEFAULT_ZIP_TIMESTAMPS;
|
|
225
|
-
this.compressOptions = {
|
|
226
|
-
level: this.level,
|
|
227
|
-
thresholdBytes: options.thresholdBytes
|
|
228
|
-
};
|
|
229
|
-
this.settings = {
|
|
230
|
-
level: this.level,
|
|
231
|
-
timestamps: this.timestamps,
|
|
232
|
-
defaultModTime: new Date()
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Add a file to the ZIP (async)
|
|
237
|
-
* @param entry - File entry
|
|
238
|
-
* @returns Local file header and compressed data chunks
|
|
239
|
-
*/
|
|
240
|
-
async addFile(entry) {
|
|
241
|
-
if (this.finalized) {
|
|
242
|
-
throw new Error("Cannot add files after finalizing");
|
|
243
|
-
}
|
|
244
|
-
// Compress data
|
|
245
|
-
const compressedData = shouldDeflate(this.level, entry.data)
|
|
246
|
-
? await compress(entry.data, this.compressOptions)
|
|
247
|
-
: entry.data;
|
|
248
|
-
const result = appendProcessedEntry(this.entries, entry, compressedData, this.currentOffset, this.settings);
|
|
249
|
-
this.currentOffset = result.nextOffset;
|
|
250
|
-
return [buildLocalFileHeaderChunk(result.processedEntry), compressedData];
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Add a file to the ZIP (sync)
|
|
254
|
-
* @param entry - File entry
|
|
255
|
-
* @returns Local file header and compressed data chunks
|
|
256
|
-
*/
|
|
257
|
-
addFileSync(entry) {
|
|
258
|
-
if (this.finalized) {
|
|
259
|
-
throw new Error("Cannot add files after finalizing");
|
|
260
|
-
}
|
|
261
|
-
// Compress data
|
|
262
|
-
const compressedData = shouldDeflate(this.level, entry.data)
|
|
263
|
-
? compressSync(entry.data, this.compressOptions)
|
|
264
|
-
: entry.data;
|
|
265
|
-
const result = appendProcessedEntry(this.entries, entry, compressedData, this.currentOffset, this.settings);
|
|
266
|
-
this.currentOffset = result.nextOffset;
|
|
267
|
-
return [buildLocalFileHeaderChunk(result.processedEntry), compressedData];
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Finalize the ZIP and return central directory + end record
|
|
271
|
-
* @returns Central directory and end of central directory chunks
|
|
272
|
-
*/
|
|
273
|
-
finalize() {
|
|
274
|
-
if (this.finalized) {
|
|
275
|
-
throw new Error("ZIP already finalized");
|
|
276
|
-
}
|
|
277
|
-
this.finalized = true;
|
|
278
|
-
return buildCentralDirectorySection(this.entries, this.currentOffset, this.zipComment);
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Get current number of entries
|
|
282
|
-
*/
|
|
283
|
-
get entryCount() {
|
|
284
|
-
return this.entries.length;
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* Get current ZIP data size (without central directory)
|
|
288
|
-
*/
|
|
289
|
-
get dataSize() {
|
|
290
|
-
return this.currentOffset;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
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,84 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export declare class ByteQueue {
|
|
2
|
-
private static readonly EMPTY;
|
|
3
|
-
private _buf;
|
|
4
|
-
private _start;
|
|
5
|
-
private _end;
|
|
6
|
-
private _cachedView;
|
|
7
|
-
private _cachedBuf;
|
|
8
|
-
private _cachedStart;
|
|
9
|
-
private _cachedEnd;
|
|
10
|
-
constructor(initial?: Uint8Array);
|
|
11
|
-
get length(): number;
|
|
12
|
-
isEmpty(): boolean;
|
|
13
|
-
view(): Uint8Array;
|
|
14
|
-
reset(data?: Uint8Array): void;
|
|
15
|
-
append(chunk: Uint8Array): void;
|
|
16
|
-
read(length: number): Uint8Array;
|
|
17
|
-
discard(length: number): void;
|
|
18
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export declare function unixSecondsFromDate(date: Date): number;
|
|
2
|
-
/**
|
|
3
|
-
* Build Info-ZIP "Extended Timestamp" extra field (0x5455).
|
|
4
|
-
* We write only mtime (UTC, Unix seconds) to minimize size.
|
|
5
|
-
*
|
|
6
|
-
* Layout:
|
|
7
|
-
* - Header ID: 2 bytes (0x5455)
|
|
8
|
-
* - Data size: 2 bytes
|
|
9
|
-
* - Flags: 1 byte (bit0 = mtime)
|
|
10
|
-
* - mtime: 4 bytes (Unix seconds)
|
|
11
|
-
*/
|
|
12
|
-
export declare function buildExtendedTimestampExtraFieldFromUnixSeconds(unixSeconds: number): Uint8Array;
|
|
13
|
-
export declare function buildExtendedTimestampExtraFieldFromDate(date: Date): Uint8Array;
|
|
14
|
-
/**
|
|
15
|
-
* Parse Info-ZIP "Extended Timestamp" extra field (0x5455) and return mtime.
|
|
16
|
-
* Returns Unix seconds (UTC) if present.
|
|
17
|
-
*/
|
|
18
|
-
export declare function parseExtendedTimestampMtimeUnixSeconds(extraField: Uint8Array): number | undefined;
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ZIP file format builder
|
|
3
|
-
*
|
|
4
|
-
* Implements ZIP file structure according to PKWARE's APPNOTE.TXT specification
|
|
5
|
-
* https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
|
|
6
|
-
*
|
|
7
|
-
* ZIP file structure:
|
|
8
|
-
* ┌──────────────────────────┐
|
|
9
|
-
* │ Local File Header 1 │
|
|
10
|
-
* │ File Data 1 │
|
|
11
|
-
* ├──────────────────────────┤
|
|
12
|
-
* │ Local File Header 2 │
|
|
13
|
-
* │ File Data 2 │
|
|
14
|
-
* ├──────────────────────────┤
|
|
15
|
-
* │ ... │
|
|
16
|
-
* ├──────────────────────────┤
|
|
17
|
-
* │ Central Directory 1 │
|
|
18
|
-
* │ Central Directory 2 │
|
|
19
|
-
* │ ... │
|
|
20
|
-
* ├──────────────────────────┤
|
|
21
|
-
* │ End of Central Directory │
|
|
22
|
-
* └──────────────────────────┘
|
|
23
|
-
*/
|
|
24
|
-
import { type CompressOptions } from "./compress.js";
|
|
25
|
-
import { type ZipTimestampMode } from "./utils/timestamps.js";
|
|
26
|
-
/**
|
|
27
|
-
* ZIP file entry
|
|
28
|
-
*/
|
|
29
|
-
export interface ZipEntry {
|
|
30
|
-
/** File name (can include directory path, use forward slashes) */
|
|
31
|
-
name: string;
|
|
32
|
-
/** File data (will be compressed unless level=0) */
|
|
33
|
-
data: Uint8Array;
|
|
34
|
-
/** File modification time (optional, defaults to current time) */
|
|
35
|
-
modTime?: Date;
|
|
36
|
-
/** File comment (optional) */
|
|
37
|
-
comment?: string;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* ZIP builder options
|
|
41
|
-
*/
|
|
42
|
-
export interface ZipOptions extends CompressOptions {
|
|
43
|
-
/** ZIP file comment (optional) */
|
|
44
|
-
comment?: string;
|
|
45
|
-
/**
|
|
46
|
-
* Timestamp writing strategy.
|
|
47
|
-
* - "dos": only write DOS date/time fields (smallest output)
|
|
48
|
-
* - "dos+utc": also write UTC mtime in 0x5455 extra field (default, best practice)
|
|
49
|
-
*/
|
|
50
|
-
timestamps?: ZipTimestampMode;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Create a ZIP file from entries (async)
|
|
54
|
-
*
|
|
55
|
-
* @param entries - Files to include in ZIP
|
|
56
|
-
* @param options - ZIP options
|
|
57
|
-
* @returns ZIP file as Uint8Array
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```ts
|
|
61
|
-
* const zip = await createZip([
|
|
62
|
-
* { name: "hello.txt", data: new TextEncoder().encode("Hello!") },
|
|
63
|
-
* { name: "folder/file.txt", data: new TextEncoder().encode("Nested!") }
|
|
64
|
-
* ], { level: 6 });
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
|
-
export declare function createZip(entries: ZipEntry[], options?: ZipOptions): Promise<Uint8Array>;
|
|
68
|
-
/**
|
|
69
|
-
* Create a ZIP file from entries (sync)
|
|
70
|
-
*
|
|
71
|
-
* This is supported in both Node.js and browser builds.
|
|
72
|
-
*/
|
|
73
|
-
export declare function createZipSync(entries: ZipEntry[], options?: ZipOptions): Uint8Array;
|
|
74
|
-
/**
|
|
75
|
-
* Streaming ZIP builder for large files
|
|
76
|
-
* Writes chunks to a callback as they are generated
|
|
77
|
-
*/
|
|
78
|
-
export declare class ZipBuilder {
|
|
79
|
-
private entries;
|
|
80
|
-
private currentOffset;
|
|
81
|
-
private level;
|
|
82
|
-
private zipComment;
|
|
83
|
-
private timestamps;
|
|
84
|
-
private compressOptions;
|
|
85
|
-
private settings;
|
|
86
|
-
private finalized;
|
|
87
|
-
/**
|
|
88
|
-
* Create a new ZIP builder
|
|
89
|
-
* @param options - ZIP options
|
|
90
|
-
*/
|
|
91
|
-
constructor(options?: ZipOptions);
|
|
92
|
-
/**
|
|
93
|
-
* Add a file to the ZIP (async)
|
|
94
|
-
* @param entry - File entry
|
|
95
|
-
* @returns Local file header and compressed data chunks
|
|
96
|
-
*/
|
|
97
|
-
addFile(entry: ZipEntry): Promise<Uint8Array[]>;
|
|
98
|
-
/**
|
|
99
|
-
* Add a file to the ZIP (sync)
|
|
100
|
-
* @param entry - File entry
|
|
101
|
-
* @returns Local file header and compressed data chunks
|
|
102
|
-
*/
|
|
103
|
-
addFileSync(entry: ZipEntry): Uint8Array[];
|
|
104
|
-
/**
|
|
105
|
-
* Finalize the ZIP and return central directory + end record
|
|
106
|
-
* @returns Central directory and end of central directory chunks
|
|
107
|
-
*/
|
|
108
|
-
finalize(): Uint8Array[];
|
|
109
|
-
/**
|
|
110
|
-
* Get current number of entries
|
|
111
|
-
*/
|
|
112
|
-
get entryCount(): number;
|
|
113
|
-
/**
|
|
114
|
-
* Get current ZIP data size (without central directory)
|
|
115
|
-
*/
|
|
116
|
-
get dataSize(): number;
|
|
117
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
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;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/browser/modules/archive/{deflate-fallback.d.ts → compression/deflate-fallback.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/browser/modules/archive/{zip-entry-metadata.d.ts → zip/zip-entry-metadata.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/types/modules/archive/{deflate-fallback.d.ts → compression/deflate-fallback.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
/package/dist/types/modules/archive/{streaming-compress.d.ts → compression/streaming-compress.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|