@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
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ZIP file format encoder (single-buffer output)
|
|
3
|
+
*
|
|
4
|
+
* Implements ZIP file structure according to PKWARE's APPNOTE.TXT specification
|
|
5
|
+
* https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
|
|
6
|
+
*
|
|
7
|
+
* This module focuses on producing a complete ZIP as a single Uint8Array.
|
|
8
|
+
* For true streaming (push chunks while reading sources), use `zip()` / `ZipArchive.stream()`.
|
|
9
|
+
*/
|
|
10
|
+
import { compress, compressSync } from "../compression/compress.js";
|
|
11
|
+
import { crc32 } from "../compression/crc32.js";
|
|
12
|
+
import { DEFAULT_ZIP_LEVEL, DEFAULT_ZIP_TIMESTAMPS } from "../defaults.js";
|
|
13
|
+
import { isProbablyIncompressible } from "../utils/compressibility.js";
|
|
14
|
+
import { encodeUtf8 } from "../utils/text.js";
|
|
15
|
+
import {} from "../utils/timestamps.js";
|
|
16
|
+
import { buildZipEntryMetadata, resolveZipCompressionMethod } from "./zip-entry-metadata.js";
|
|
17
|
+
import { FLAG_UTF8, ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE, ZIP_END_OF_CENTRAL_DIR_FIXED_SIZE, ZIP_LOCAL_FILE_HEADER_FIXED_SIZE, writeCentralDirectoryHeaderInto, writeEndOfCentralDirectoryInto, writeLocalFileHeaderInto } from "../zip-spec/zip-records.js";
|
|
18
|
+
const REPRODUCIBLE_ZIP_MOD_TIME = new Date(1980, 0, 1, 0, 0, 0);
|
|
19
|
+
function encodeZipComment(comment) {
|
|
20
|
+
// Keep empty comment as empty bytes (no encoding surprises).
|
|
21
|
+
return comment ? encodeUtf8(comment) : new Uint8Array(0);
|
|
22
|
+
}
|
|
23
|
+
function shouldDeflate(level, data) {
|
|
24
|
+
return level > 0 && data.length > 0;
|
|
25
|
+
}
|
|
26
|
+
async function compressEntryMaybe(entry, level, compressOptions, smartStore) {
|
|
27
|
+
if (!shouldDeflate(level, entry.data)) {
|
|
28
|
+
return { compressedData: entry.data, deflate: false };
|
|
29
|
+
}
|
|
30
|
+
if (!smartStore) {
|
|
31
|
+
const compressed = await compress(entry.data, compressOptions);
|
|
32
|
+
return { compressedData: compressed, deflate: true };
|
|
33
|
+
}
|
|
34
|
+
// Heuristic: skip deflate for high-entropy inputs.
|
|
35
|
+
if (isProbablyIncompressible(entry.data)) {
|
|
36
|
+
return { compressedData: entry.data, deflate: false };
|
|
37
|
+
}
|
|
38
|
+
const compressed = await compress(entry.data, compressOptions);
|
|
39
|
+
if (compressed.length >= entry.data.length) {
|
|
40
|
+
return { compressedData: entry.data, deflate: false };
|
|
41
|
+
}
|
|
42
|
+
return { compressedData: compressed, deflate: true };
|
|
43
|
+
}
|
|
44
|
+
function compressEntryMaybeSync(entry, level, compressOptions, smartStore) {
|
|
45
|
+
if (!shouldDeflate(level, entry.data)) {
|
|
46
|
+
return { compressedData: entry.data, deflate: false };
|
|
47
|
+
}
|
|
48
|
+
if (!smartStore) {
|
|
49
|
+
const compressed = compressSync(entry.data, compressOptions);
|
|
50
|
+
return { compressedData: compressed, deflate: true };
|
|
51
|
+
}
|
|
52
|
+
if (isProbablyIncompressible(entry.data)) {
|
|
53
|
+
return { compressedData: entry.data, deflate: false };
|
|
54
|
+
}
|
|
55
|
+
const compressed = compressSync(entry.data, compressOptions);
|
|
56
|
+
if (compressed.length >= entry.data.length) {
|
|
57
|
+
return { compressedData: entry.data, deflate: false };
|
|
58
|
+
}
|
|
59
|
+
return { compressedData: compressed, deflate: true };
|
|
60
|
+
}
|
|
61
|
+
function computeLocalRecordSize(entry) {
|
|
62
|
+
return (ZIP_LOCAL_FILE_HEADER_FIXED_SIZE +
|
|
63
|
+
entry.name.length +
|
|
64
|
+
entry.extraField.length +
|
|
65
|
+
entry.compressedData.length);
|
|
66
|
+
}
|
|
67
|
+
function computeCentralDirHeaderSize(entry) {
|
|
68
|
+
return (ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE +
|
|
69
|
+
entry.name.length +
|
|
70
|
+
entry.extraField.length +
|
|
71
|
+
entry.comment.length);
|
|
72
|
+
}
|
|
73
|
+
function buildProcessedEntry(entry, offset, settings, compressedData, deflate) {
|
|
74
|
+
const modDate = entry.modTime ?? settings.defaultModTime;
|
|
75
|
+
const metadata = buildZipEntryMetadata({
|
|
76
|
+
name: entry.name,
|
|
77
|
+
comment: entry.comment,
|
|
78
|
+
modTime: modDate,
|
|
79
|
+
timestamps: settings.timestamps,
|
|
80
|
+
useDataDescriptor: false,
|
|
81
|
+
deflate
|
|
82
|
+
});
|
|
83
|
+
return {
|
|
84
|
+
name: metadata.nameBytes,
|
|
85
|
+
uncompressedSize: entry.data.length,
|
|
86
|
+
compressedData,
|
|
87
|
+
crc: crc32(entry.data),
|
|
88
|
+
compressionMethod: resolveZipCompressionMethod(deflate),
|
|
89
|
+
modTime: metadata.dosTime,
|
|
90
|
+
modDate: metadata.dosDate,
|
|
91
|
+
extraField: metadata.extraField,
|
|
92
|
+
comment: metadata.commentBytes,
|
|
93
|
+
offset
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function appendProcessedEntry(processedEntries, entry, compressedData, deflate, currentOffset, settings) {
|
|
97
|
+
const processedEntry = buildProcessedEntry(entry, currentOffset, settings, compressedData, deflate);
|
|
98
|
+
processedEntries.push(processedEntry);
|
|
99
|
+
return {
|
|
100
|
+
processedEntry,
|
|
101
|
+
nextOffset: currentOffset + computeLocalRecordSize(processedEntry)
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function finalizeZip(processedEntries, zipComment) {
|
|
105
|
+
// Assemble ZIP into a single buffer to reduce allocations and copying.
|
|
106
|
+
let localSectionSize = 0;
|
|
107
|
+
let centralDirSize = 0;
|
|
108
|
+
for (const entry of processedEntries) {
|
|
109
|
+
localSectionSize += computeLocalRecordSize(entry);
|
|
110
|
+
centralDirSize += computeCentralDirHeaderSize(entry);
|
|
111
|
+
}
|
|
112
|
+
// The central directory should start immediately after local section.
|
|
113
|
+
const centralDirOffset = localSectionSize;
|
|
114
|
+
const totalSize = localSectionSize + centralDirSize + ZIP_END_OF_CENTRAL_DIR_FIXED_SIZE + zipComment.length;
|
|
115
|
+
const out = new Uint8Array(totalSize);
|
|
116
|
+
const view = new DataView(out.buffer, out.byteOffset, out.byteLength);
|
|
117
|
+
let offset = 0;
|
|
118
|
+
// Local file headers and data
|
|
119
|
+
for (const entry of processedEntries) {
|
|
120
|
+
offset += writeLocalFileHeaderInto(out, view, offset, {
|
|
121
|
+
fileName: entry.name,
|
|
122
|
+
extraField: entry.extraField,
|
|
123
|
+
flags: FLAG_UTF8,
|
|
124
|
+
compressionMethod: entry.compressionMethod,
|
|
125
|
+
dosTime: entry.modTime,
|
|
126
|
+
dosDate: entry.modDate,
|
|
127
|
+
crc32: entry.crc,
|
|
128
|
+
compressedSize: entry.compressedData.length,
|
|
129
|
+
uncompressedSize: entry.uncompressedSize
|
|
130
|
+
});
|
|
131
|
+
out.set(entry.compressedData, offset);
|
|
132
|
+
offset += entry.compressedData.length;
|
|
133
|
+
}
|
|
134
|
+
// Central directory headers
|
|
135
|
+
for (const entry of processedEntries) {
|
|
136
|
+
offset += writeCentralDirectoryHeaderInto(out, view, offset, {
|
|
137
|
+
fileName: entry.name,
|
|
138
|
+
extraField: entry.extraField,
|
|
139
|
+
comment: entry.comment,
|
|
140
|
+
flags: FLAG_UTF8,
|
|
141
|
+
compressionMethod: entry.compressionMethod,
|
|
142
|
+
dosTime: entry.modTime,
|
|
143
|
+
dosDate: entry.modDate,
|
|
144
|
+
crc32: entry.crc,
|
|
145
|
+
compressedSize: entry.compressedData.length,
|
|
146
|
+
uncompressedSize: entry.uncompressedSize,
|
|
147
|
+
localHeaderOffset: entry.offset
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
// End of central directory
|
|
151
|
+
writeEndOfCentralDirectoryInto(out, view, offset, {
|
|
152
|
+
entryCount: processedEntries.length,
|
|
153
|
+
centralDirSize,
|
|
154
|
+
centralDirOffset,
|
|
155
|
+
comment: zipComment
|
|
156
|
+
});
|
|
157
|
+
return out;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Create a ZIP file from entries (async)
|
|
161
|
+
*/
|
|
162
|
+
export async function createZip(entries, options = {}) {
|
|
163
|
+
const reproducible = options.reproducible ?? false;
|
|
164
|
+
const level = options.level ?? DEFAULT_ZIP_LEVEL;
|
|
165
|
+
const smartStore = options.smartStore ?? true;
|
|
166
|
+
const concurrency = options.concurrency ?? 4;
|
|
167
|
+
const timestamps = options.timestamps ?? (reproducible ? "dos" : DEFAULT_ZIP_TIMESTAMPS);
|
|
168
|
+
const zipComment = encodeZipComment(options.comment);
|
|
169
|
+
const defaultModTime = options.modTime ?? (reproducible ? REPRODUCIBLE_ZIP_MOD_TIME : new Date());
|
|
170
|
+
const settings = {
|
|
171
|
+
level,
|
|
172
|
+
timestamps,
|
|
173
|
+
defaultModTime
|
|
174
|
+
};
|
|
175
|
+
const thresholdBytes = options.thresholdBytes;
|
|
176
|
+
const limit = Math.max(1, Math.floor(concurrency));
|
|
177
|
+
const processedEntries = new Array(entries.length);
|
|
178
|
+
if (entries.length > 0) {
|
|
179
|
+
let nextIndex = 0;
|
|
180
|
+
const workerCount = Math.min(limit, entries.length);
|
|
181
|
+
const workers = Array.from({ length: workerCount }, async () => {
|
|
182
|
+
while (true) {
|
|
183
|
+
const idx = nextIndex++;
|
|
184
|
+
if (idx >= entries.length) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const entry = entries[idx];
|
|
188
|
+
const entryLevel = entry.level ?? level;
|
|
189
|
+
const compressOptions = {
|
|
190
|
+
level: entryLevel,
|
|
191
|
+
thresholdBytes
|
|
192
|
+
};
|
|
193
|
+
const { compressedData, deflate } = await compressEntryMaybe(entry, entryLevel, compressOptions, smartStore);
|
|
194
|
+
processedEntries[idx] = buildProcessedEntry(entry, 0, settings, compressedData, deflate);
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
await Promise.all(workers);
|
|
198
|
+
}
|
|
199
|
+
// Compute offsets in original order.
|
|
200
|
+
let currentOffset = 0;
|
|
201
|
+
for (let i = 0; i < processedEntries.length; i++) {
|
|
202
|
+
const processedEntry = processedEntries[i];
|
|
203
|
+
processedEntry.offset = currentOffset;
|
|
204
|
+
currentOffset += computeLocalRecordSize(processedEntry);
|
|
205
|
+
}
|
|
206
|
+
return finalizeZip(processedEntries, zipComment);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Create a ZIP file from entries (sync)
|
|
210
|
+
*
|
|
211
|
+
* This is supported in both Node.js and browser builds.
|
|
212
|
+
*/
|
|
213
|
+
export function createZipSync(entries, options = {}) {
|
|
214
|
+
const reproducible = options.reproducible ?? false;
|
|
215
|
+
const level = options.level ?? DEFAULT_ZIP_LEVEL;
|
|
216
|
+
const smartStore = options.smartStore ?? true;
|
|
217
|
+
const timestamps = options.timestamps ?? (reproducible ? "dos" : DEFAULT_ZIP_TIMESTAMPS);
|
|
218
|
+
const zipComment = encodeZipComment(options.comment);
|
|
219
|
+
const defaultModTime = options.modTime ?? (reproducible ? REPRODUCIBLE_ZIP_MOD_TIME : new Date());
|
|
220
|
+
const settings = {
|
|
221
|
+
level,
|
|
222
|
+
timestamps,
|
|
223
|
+
defaultModTime
|
|
224
|
+
};
|
|
225
|
+
const thresholdBytes = options.thresholdBytes;
|
|
226
|
+
const processedEntries = [];
|
|
227
|
+
let currentOffset = 0;
|
|
228
|
+
for (const entry of entries) {
|
|
229
|
+
const entryLevel = entry.level ?? level;
|
|
230
|
+
const compressOptions = {
|
|
231
|
+
level: entryLevel,
|
|
232
|
+
thresholdBytes
|
|
233
|
+
};
|
|
234
|
+
const { compressedData, deflate } = compressEntryMaybeSync(entry, entryLevel, compressOptions, smartStore);
|
|
235
|
+
const result = appendProcessedEntry(processedEntries, entry, compressedData, deflate, currentOffset, settings);
|
|
236
|
+
currentOffset = result.nextOffset;
|
|
237
|
+
}
|
|
238
|
+
return finalizeZip(processedEntries, zipComment);
|
|
239
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { encodeUtf8 } from "
|
|
2
|
-
import { buildZipTimestampExtraField, dateToZipDos } from "
|
|
3
|
-
import { COMPRESSION_DEFLATE, COMPRESSION_STORE, FLAG_DATA_DESCRIPTOR, FLAG_UTF8 } from "
|
|
1
|
+
import { encodeUtf8 } from "../utils/text.js";
|
|
2
|
+
import { buildZipTimestampExtraField, dateToZipDos } from "../utils/timestamps.js";
|
|
3
|
+
import { COMPRESSION_DEFLATE, COMPRESSION_STORE, FLAG_DATA_DESCRIPTOR, FLAG_UTF8 } from "../zip-spec/zip-records.js";
|
|
4
4
|
export function resolveZipCompressionMethod(deflate) {
|
|
5
5
|
return deflate ? COMPRESSION_DEFLATE : COMPRESSION_STORE;
|
|
6
6
|
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ZIP record builders (PKWARE APPNOTE)
|
|
3
|
+
*
|
|
4
|
+
* Shared by streaming zip writer and buffer zip builder.
|
|
5
|
+
*/
|
|
6
|
+
// =============================================================================
|
|
7
|
+
// ZIP format constants (PKWARE APPNOTE)
|
|
8
|
+
// =============================================================================
|
|
9
|
+
// Signatures
|
|
10
|
+
export const LOCAL_FILE_HEADER_SIG = 0x04034b50;
|
|
11
|
+
export const CENTRAL_DIR_HEADER_SIG = 0x02014b50;
|
|
12
|
+
export const END_OF_CENTRAL_DIR_SIG = 0x06054b50;
|
|
13
|
+
export const DATA_DESCRIPTOR_SIG = 0x08074b50;
|
|
14
|
+
export const ZIP64_END_OF_CENTRAL_DIR_SIG = 0x06064b50;
|
|
15
|
+
export const ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIG = 0x07064b50;
|
|
16
|
+
// Versions
|
|
17
|
+
export const VERSION_NEEDED = 20; // 2.0 - supports DEFLATE
|
|
18
|
+
export const VERSION_MADE_BY = 20; // 2.0
|
|
19
|
+
// Compression methods
|
|
20
|
+
export const COMPRESSION_STORE = 0;
|
|
21
|
+
export const COMPRESSION_DEFLATE = 8;
|
|
22
|
+
// General purpose bit flags
|
|
23
|
+
export const FLAG_UTF8 = 0x0800;
|
|
24
|
+
export const FLAG_DATA_DESCRIPTOR = 0x0008;
|
|
25
|
+
// ZIP64 / sentinel sizes
|
|
26
|
+
export const UINT16_MAX = 0xffff;
|
|
27
|
+
export const UINT32_MAX = 0xffffffff;
|
|
28
|
+
export const ZIP_LOCAL_FILE_HEADER_FIXED_SIZE = 30;
|
|
29
|
+
export const ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE = 46;
|
|
30
|
+
export const ZIP_END_OF_CENTRAL_DIR_FIXED_SIZE = 22;
|
|
31
|
+
export function writeLocalFileHeaderInto(out, view, offset, input) {
|
|
32
|
+
const versionNeeded = input.versionNeeded ?? VERSION_NEEDED;
|
|
33
|
+
view.setUint32(offset + 0, LOCAL_FILE_HEADER_SIG, true);
|
|
34
|
+
view.setUint16(offset + 4, versionNeeded, true);
|
|
35
|
+
view.setUint16(offset + 6, input.flags, true);
|
|
36
|
+
view.setUint16(offset + 8, input.compressionMethod, true);
|
|
37
|
+
view.setUint16(offset + 10, input.dosTime, true);
|
|
38
|
+
view.setUint16(offset + 12, input.dosDate, true);
|
|
39
|
+
view.setUint32(offset + 14, input.crc32, true);
|
|
40
|
+
view.setUint32(offset + 18, input.compressedSize, true);
|
|
41
|
+
view.setUint32(offset + 22, input.uncompressedSize, true);
|
|
42
|
+
view.setUint16(offset + 26, input.fileName.length, true);
|
|
43
|
+
view.setUint16(offset + 28, input.extraField.length, true);
|
|
44
|
+
out.set(input.fileName, offset + ZIP_LOCAL_FILE_HEADER_FIXED_SIZE);
|
|
45
|
+
if (input.extraField.length > 0) {
|
|
46
|
+
out.set(input.extraField, offset + ZIP_LOCAL_FILE_HEADER_FIXED_SIZE + input.fileName.length);
|
|
47
|
+
}
|
|
48
|
+
return ZIP_LOCAL_FILE_HEADER_FIXED_SIZE + input.fileName.length + input.extraField.length;
|
|
49
|
+
}
|
|
50
|
+
export function buildLocalFileHeader(input) {
|
|
51
|
+
const header = new Uint8Array(ZIP_LOCAL_FILE_HEADER_FIXED_SIZE + input.fileName.length + input.extraField.length);
|
|
52
|
+
const view = new DataView(header.buffer, header.byteOffset, header.byteLength);
|
|
53
|
+
writeLocalFileHeaderInto(header, view, 0, input);
|
|
54
|
+
return header;
|
|
55
|
+
}
|
|
56
|
+
export function writeCentralDirectoryHeaderInto(out, view, offset, input) {
|
|
57
|
+
const versionMadeBy = input.versionMadeBy ?? VERSION_MADE_BY;
|
|
58
|
+
const versionNeeded = input.versionNeeded ?? VERSION_NEEDED;
|
|
59
|
+
const externalAttributes = input.externalAttributes ?? 0;
|
|
60
|
+
view.setUint32(offset + 0, CENTRAL_DIR_HEADER_SIG, true);
|
|
61
|
+
view.setUint16(offset + 4, versionMadeBy, true);
|
|
62
|
+
view.setUint16(offset + 6, versionNeeded, true);
|
|
63
|
+
view.setUint16(offset + 8, input.flags, true);
|
|
64
|
+
view.setUint16(offset + 10, input.compressionMethod, true);
|
|
65
|
+
view.setUint16(offset + 12, input.dosTime, true);
|
|
66
|
+
view.setUint16(offset + 14, input.dosDate, true);
|
|
67
|
+
view.setUint32(offset + 16, input.crc32, true);
|
|
68
|
+
view.setUint32(offset + 20, input.compressedSize, true);
|
|
69
|
+
view.setUint32(offset + 24, input.uncompressedSize, true);
|
|
70
|
+
view.setUint16(offset + 28, input.fileName.length, true);
|
|
71
|
+
view.setUint16(offset + 30, input.extraField.length, true);
|
|
72
|
+
view.setUint16(offset + 32, input.comment.length, true);
|
|
73
|
+
view.setUint16(offset + 34, 0, true); // disk number start
|
|
74
|
+
view.setUint16(offset + 36, 0, true); // internal file attributes
|
|
75
|
+
view.setUint32(offset + 38, externalAttributes, true);
|
|
76
|
+
view.setUint32(offset + 42, input.localHeaderOffset, true);
|
|
77
|
+
out.set(input.fileName, offset + ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE);
|
|
78
|
+
if (input.extraField.length > 0) {
|
|
79
|
+
out.set(input.extraField, offset + ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE + input.fileName.length);
|
|
80
|
+
}
|
|
81
|
+
if (input.comment.length > 0) {
|
|
82
|
+
out.set(input.comment, offset + ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE + input.fileName.length + input.extraField.length);
|
|
83
|
+
}
|
|
84
|
+
return (ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE +
|
|
85
|
+
input.fileName.length +
|
|
86
|
+
input.extraField.length +
|
|
87
|
+
input.comment.length);
|
|
88
|
+
}
|
|
89
|
+
export function buildCentralDirectoryHeader(input) {
|
|
90
|
+
const header = new Uint8Array(ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE +
|
|
91
|
+
input.fileName.length +
|
|
92
|
+
input.extraField.length +
|
|
93
|
+
input.comment.length);
|
|
94
|
+
const view = new DataView(header.buffer, header.byteOffset, header.byteLength);
|
|
95
|
+
writeCentralDirectoryHeaderInto(header, view, 0, input);
|
|
96
|
+
return header;
|
|
97
|
+
}
|
|
98
|
+
export function writeEndOfCentralDirectoryInto(out, view, offset, input) {
|
|
99
|
+
view.setUint32(offset + 0, END_OF_CENTRAL_DIR_SIG, true);
|
|
100
|
+
view.setUint16(offset + 4, 0, true);
|
|
101
|
+
view.setUint16(offset + 6, 0, true);
|
|
102
|
+
view.setUint16(offset + 8, input.entryCount, true);
|
|
103
|
+
view.setUint16(offset + 10, input.entryCount, true);
|
|
104
|
+
view.setUint32(offset + 12, input.centralDirSize, true);
|
|
105
|
+
view.setUint32(offset + 16, input.centralDirOffset, true);
|
|
106
|
+
view.setUint16(offset + 20, input.comment.length, true);
|
|
107
|
+
if (input.comment.length > 0) {
|
|
108
|
+
out.set(input.comment, offset + ZIP_END_OF_CENTRAL_DIR_FIXED_SIZE);
|
|
109
|
+
}
|
|
110
|
+
return ZIP_END_OF_CENTRAL_DIR_FIXED_SIZE + input.comment.length;
|
|
111
|
+
}
|
|
112
|
+
export function buildEndOfCentralDirectory(input) {
|
|
113
|
+
const record = new Uint8Array(ZIP_END_OF_CENTRAL_DIR_FIXED_SIZE + input.comment.length);
|
|
114
|
+
const view = new DataView(record.buffer, record.byteOffset, record.byteLength);
|
|
115
|
+
writeEndOfCentralDirectoryInto(record, view, 0, input);
|
|
116
|
+
return record;
|
|
117
|
+
}
|
|
118
|
+
export function buildDataDescriptor(crc32, compressedSize, uncompressedSize) {
|
|
119
|
+
const descriptor = new Uint8Array(16);
|
|
120
|
+
const view = new DataView(descriptor.buffer);
|
|
121
|
+
view.setUint32(0, DATA_DESCRIPTOR_SIG, true);
|
|
122
|
+
view.setUint32(4, crc32, true);
|
|
123
|
+
view.setUint32(8, compressedSize, true);
|
|
124
|
+
view.setUint32(12, uncompressedSize, true);
|
|
125
|
+
return descriptor;
|
|
126
|
+
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* with filesystem-specific features (filename input + temp-file buffering).
|
|
10
10
|
*/
|
|
11
11
|
import { EventEmitter, Readable } from "../../stream/index.js";
|
|
12
|
-
import { createParse } from "../../archive/
|
|
12
|
+
import { createParse } from "../../archive/unzip/stream.js";
|
|
13
13
|
import { iterateStream } from "../utils/iterate-stream.js";
|
|
14
14
|
import { getWorksheetNoFromWorksheetPath, getWorksheetNoFromWorksheetRelsPath, normalizeZipPath, OOXML_PATHS, worksheetRelTarget } from "../utils/ooxml-paths.js";
|
|
15
15
|
import { parseSax } from "../utils/parse-sax.js";
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Node.js uses `workbook-writer.ts`, which extends the same base implementation
|
|
8
8
|
* with filesystem-specific features (filename output + image loading).
|
|
9
9
|
*/
|
|
10
|
-
import { Zip, ZipDeflate } from "../../archive/
|
|
10
|
+
import { Zip, ZipDeflate } from "../../archive/zip/stream.js";
|
|
11
11
|
import { StreamBuf } from "../utils/stream-buf.js";
|
|
12
12
|
import { base64ToUint8Array } from "../../../utils/utils.js";
|
|
13
13
|
import { RelType } from "../xlsx/rel-type.js";
|