@cj-tech-master/excelts 4.2.1 → 4.2.2-canary.20260115044841.88820eb
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/utils/parse-sax.d.ts +3 -0
- package/dist/browser/modules/excel/utils/parse-sax.js +32 -13
- package/dist/browser/modules/excel/worksheet.js +5 -2
- package/dist/browser/modules/excel/xlsx/xform/core/app-xform.js +3 -3
- package/dist/browser/modules/excel/xlsx/xform/core/core-xform.js +56 -68
- 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/list-xform.js +8 -10
- 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/xform/strings/shared-string-xform.js +2 -3
- package/dist/browser/modules/excel/xlsx/xform/strings/text-xform.js +5 -7
- package/dist/browser/modules/excel/xlsx/xlsx.browser.js +11 -10
- 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/utils/parse-sax.js +32 -13
- package/dist/cjs/modules/excel/worksheet.js +5 -2
- package/dist/cjs/modules/excel/xlsx/xform/core/app-xform.js +3 -3
- package/dist/cjs/modules/excel/xlsx/xform/core/core-xform.js +56 -68
- 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/list-xform.js +8 -10
- 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/xform/strings/shared-string-xform.js +2 -3
- package/dist/cjs/modules/excel/xlsx/xform/strings/text-xform.js +5 -7
- package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +14 -13
- 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/utils/parse-sax.js +32 -13
- package/dist/esm/modules/excel/worksheet.js +5 -2
- package/dist/esm/modules/excel/xlsx/xform/core/app-xform.js +3 -3
- package/dist/esm/modules/excel/xlsx/xform/core/core-xform.js +56 -68
- 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/list-xform.js +8 -10
- 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/xform/strings/shared-string-xform.js +2 -3
- package/dist/esm/modules/excel/xlsx/xform/strings/text-xform.js +5 -7
- package/dist/esm/modules/excel/xlsx/xlsx.browser.js +11 -10
- 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 +6592 -4537
- 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/utils/parse-sax.d.ts +3 -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
|
@@ -13,14 +13,12 @@ class TextXform extends BaseXform {
|
|
|
13
13
|
xmlStream.closeNode();
|
|
14
14
|
}
|
|
15
15
|
parseOpen(node) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return true;
|
|
21
|
-
default:
|
|
22
|
-
return false;
|
|
16
|
+
if (node.name === "t") {
|
|
17
|
+
this._text = [];
|
|
18
|
+
this.model = "";
|
|
19
|
+
return true;
|
|
23
20
|
}
|
|
21
|
+
return false;
|
|
24
22
|
}
|
|
25
23
|
parseText(text) {
|
|
26
24
|
this._text.push(text);
|
|
@@ -30,8 +30,8 @@ import { theme1Xml } from "./xml/theme1.js";
|
|
|
30
30
|
import { RelType } from "./rel-type.js";
|
|
31
31
|
import { StreamBuf } from "../utils/stream-buf.js";
|
|
32
32
|
import { bufferToString, base64ToUint8Array } from "../../../utils/utils.js";
|
|
33
|
-
import { StreamingZip, ZipDeflateFile } from "../../archive/
|
|
34
|
-
import { ZipParser } from "../../archive/
|
|
33
|
+
import { StreamingZip, ZipDeflateFile } from "../../archive/zip/stream.js";
|
|
34
|
+
import { ZipParser } from "../../archive/unzip/zip-parser.js";
|
|
35
35
|
import { PassThrough, concatUint8Arrays } from "../../stream/index.js";
|
|
36
36
|
import { commentsPath, commentsRelTargetFromWorksheetName, ctrlPropPath, drawingPath, drawingRelsPath, OOXML_REL_TARGETS, pivotTableRelTargetFromWorksheetName, pivotCacheDefinitionRelTargetFromWorkbook, getCommentsIndexFromPath, getDrawingNameFromPath, getDrawingNameFromRelsPath, getMediaFilenameFromPath, mediaPath, getPivotCacheDefinitionNameFromPath, getPivotCacheDefinitionNameFromRelsPath, getPivotCacheRecordsNameFromPath, getPivotTableNameFromPath, getPivotTableNameFromRelsPath, pivotCacheDefinitionPath, pivotCacheDefinitionRelsPath, pivotCacheDefinitionRelTargetFromPivotTable, pivotCacheRecordsPath, pivotCacheRecordsRelTarget, pivotTablePath, pivotTableRelsPath, getTableNameFromPath, tablePath, tableRelTargetFromWorksheetName, themePath, getThemeNameFromPath, getVmlDrawingNameFromPath, getWorksheetNoFromWorksheetPath, getWorksheetNoFromWorksheetRelsPath, isBinaryEntryPath, normalizeZipPath, OOXML_PATHS, vmlDrawingRelTargetFromWorksheetName, vmlDrawingPath, worksheetPath, worksheetRelsPath } from "../utils/ooxml-paths.js";
|
|
37
37
|
class StreamingZipWriterAdapter {
|
|
@@ -126,10 +126,7 @@ class StreamingZipWriterAdapter {
|
|
|
126
126
|
timestamps: this.timestamps
|
|
127
127
|
});
|
|
128
128
|
this.zip.add(file);
|
|
129
|
-
|
|
130
|
-
if (pushResult && typeof pushResult.catch === "function") {
|
|
131
|
-
pushResult.catch((err) => this._emit("error", err));
|
|
132
|
-
}
|
|
129
|
+
file.push(buffer, true);
|
|
133
130
|
}
|
|
134
131
|
finalize() {
|
|
135
132
|
if (this.finalized) {
|
|
@@ -367,8 +364,10 @@ class XLSX {
|
|
|
367
364
|
case OOXML_PATHS.docPropsApp: {
|
|
368
365
|
const appXform = new AppXform();
|
|
369
366
|
const appProperties = await appXform.parseStream(stream);
|
|
370
|
-
|
|
371
|
-
|
|
367
|
+
if (appProperties) {
|
|
368
|
+
model.company = appProperties.company;
|
|
369
|
+
model.manager = appProperties.manager;
|
|
370
|
+
}
|
|
372
371
|
break;
|
|
373
372
|
}
|
|
374
373
|
case OOXML_PATHS.docPropsCore: {
|
|
@@ -830,8 +829,10 @@ class XLSX {
|
|
|
830
829
|
case OOXML_PATHS.docPropsApp: {
|
|
831
830
|
const appXform = new AppXform();
|
|
832
831
|
const appProperties = await appXform.parseStream(stream);
|
|
833
|
-
|
|
834
|
-
|
|
832
|
+
if (appProperties) {
|
|
833
|
+
model.company = appProperties.company;
|
|
834
|
+
model.manager = appProperties.manager;
|
|
835
|
+
}
|
|
835
836
|
break;
|
|
836
837
|
}
|
|
837
838
|
case OOXML_PATHS.docPropsCore: {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import fs from "fs";
|
|
17
17
|
import { fileExists } from "../../../utils/utils.js";
|
|
18
18
|
import { XLSX as XLSXBase } from "./xlsx.browser.js";
|
|
19
|
-
import { Parse } from "../../archive/
|
|
19
|
+
import { Parse } from "../../archive/unzip/stream.js";
|
|
20
20
|
import { Writable, pipeline } from "../../stream/index.js";
|
|
21
21
|
class XLSX extends XLSXBase {
|
|
22
22
|
constructor(workbook) {
|
|
@@ -17,6 +17,8 @@ export class BaseTransform extends EventEmitter {
|
|
|
17
17
|
this._isDestroyed = false;
|
|
18
18
|
this._isFinished = false;
|
|
19
19
|
this._errorEmitted = false;
|
|
20
|
+
this._ending = false;
|
|
21
|
+
this._flushInProgress = false;
|
|
20
22
|
this._objectMode = options.objectMode ?? false;
|
|
21
23
|
this._highWaterMark = options.highWaterMark ?? 16384;
|
|
22
24
|
}
|
|
@@ -45,26 +47,8 @@ export class BaseTransform extends EventEmitter {
|
|
|
45
47
|
if (chunk !== undefined) {
|
|
46
48
|
this.write(chunk);
|
|
47
49
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (this._buffer.length === this._bufferIndex && !this._isProcessing) {
|
|
51
|
-
this.processFlush((err, data) => {
|
|
52
|
-
if (err) {
|
|
53
|
-
this._emitError(err);
|
|
54
|
-
}
|
|
55
|
-
else if (data !== undefined) {
|
|
56
|
-
this.emit("data", data);
|
|
57
|
-
}
|
|
58
|
-
this._isFinished = true;
|
|
59
|
-
this.emit("finish");
|
|
60
|
-
this.emit("end");
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
setTimeout(checkAndFlush, 0);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
checkAndFlush();
|
|
50
|
+
this._ending = true;
|
|
51
|
+
this._maybeFlush();
|
|
68
52
|
}
|
|
69
53
|
/**
|
|
70
54
|
* Destroy the stream
|
|
@@ -113,13 +97,43 @@ export class BaseTransform extends EventEmitter {
|
|
|
113
97
|
}
|
|
114
98
|
// Process next chunk
|
|
115
99
|
this._processNext();
|
|
100
|
+
this._maybeFlush();
|
|
116
101
|
}
|
|
117
102
|
});
|
|
118
103
|
}
|
|
119
104
|
catch (err) {
|
|
120
105
|
this._isProcessing = false;
|
|
121
106
|
this._emitError(err);
|
|
107
|
+
this._maybeFlush();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
_maybeFlush() {
|
|
111
|
+
if (!this._ending || this._isDestroyed || this._isFinished || this._flushInProgress) {
|
|
112
|
+
return;
|
|
122
113
|
}
|
|
114
|
+
// If an error was emitted, stop flushing to avoid hanging end().
|
|
115
|
+
if (this._errorEmitted) {
|
|
116
|
+
this._isFinished = true;
|
|
117
|
+
this.emit("finish");
|
|
118
|
+
this.emit("end");
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (this._isProcessing || this._bufferIndex < this._buffer.length) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
this._flushInProgress = true;
|
|
125
|
+
this.processFlush((err, data) => {
|
|
126
|
+
this._flushInProgress = false;
|
|
127
|
+
if (err) {
|
|
128
|
+
this._emitError(err);
|
|
129
|
+
}
|
|
130
|
+
else if (data !== undefined) {
|
|
131
|
+
this.emit("data", data);
|
|
132
|
+
}
|
|
133
|
+
this._isFinished = true;
|
|
134
|
+
this.emit("finish");
|
|
135
|
+
this.emit("end");
|
|
136
|
+
});
|
|
123
137
|
}
|
|
124
138
|
/**
|
|
125
139
|
* Emit error only once
|
|
@@ -45,7 +45,7 @@ export class ChunkedBuilder {
|
|
|
45
45
|
_consolidate() {
|
|
46
46
|
if (this._pieces.length > 0) {
|
|
47
47
|
this._chunks.push(this._pieces.join(""));
|
|
48
|
-
this._pieces =
|
|
48
|
+
this._pieces.length = 0;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
@@ -76,8 +76,8 @@ export class ChunkedBuilder {
|
|
|
76
76
|
* Clear all content
|
|
77
77
|
*/
|
|
78
78
|
clear() {
|
|
79
|
-
this._pieces =
|
|
80
|
-
this._chunks =
|
|
79
|
+
this._pieces.length = 0;
|
|
80
|
+
this._chunks.length = 0;
|
|
81
81
|
this._totalLength = 0;
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
@@ -99,7 +99,7 @@ export class ChunkedBuilder {
|
|
|
99
99
|
// Has chunks - consolidate and join
|
|
100
100
|
if (piecesLen > 0) {
|
|
101
101
|
this._chunks.push(this._pieces.join(""));
|
|
102
|
-
this._pieces =
|
|
102
|
+
this._pieces.length = 0;
|
|
103
103
|
}
|
|
104
104
|
if (this._chunks.length === 1) {
|
|
105
105
|
return this._chunks[0];
|
|
@@ -1,25 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Stream Module (browser
|
|
2
|
+
* Stream Module (browser entry)
|
|
3
3
|
*
|
|
4
|
-
* Mirrors
|
|
5
|
-
*
|
|
4
|
+
* Mirrors the public surface of `./index.ts`, but exports the browser
|
|
5
|
+
* implementation from `./streams.browser`.
|
|
6
|
+
*
|
|
7
|
+
* This file is intentionally export-only (tree-shaking friendly).
|
|
6
8
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
import { EventEmitter } from "./event-emitter.js";
|
|
13
|
-
export { EventEmitter };
|
|
14
|
-
// =============================================================================
|
|
15
|
-
// ChunkedBuilder (platform-independent)
|
|
16
|
-
// =============================================================================
|
|
17
|
-
import { ChunkedBuilder, TransactionalChunkedBuilder } from "./chunked-builder.js";
|
|
18
|
-
export { ChunkedBuilder, TransactionalChunkedBuilder };
|
|
19
|
-
// =============================================================================
|
|
20
|
-
// Utility Functions (platform-independent)
|
|
21
|
-
// =============================================================================
|
|
22
|
-
import { textEncoder, textDecoder, stringToUint8Array, uint8ArrayToString, uint8ArrayEquals, uint8ArrayIndexOf, uint8ArraySlice, toUint8Array, bufferToString, concatUint8Arrays } from "./shared.js";
|
|
23
|
-
export { textEncoder, textDecoder, stringToUint8Array, uint8ArrayToString, uint8ArrayEquals, uint8ArrayIndexOf, uint8ArraySlice, toUint8Array, bufferToString, concatUint8Arrays };
|
|
24
|
-
import { collect, text, json, bytes, fromString, fromJSON, fromBytes, transform, filter } from "./utils.js";
|
|
25
|
-
export { collect, text, json, bytes, fromString, fromJSON, fromBytes, transform, filter };
|
|
9
|
+
export { Readable, Writable, Transform, Duplex, PassThrough, Collector, PullStream, BufferedStream, StringChunk, BufferChunk, createReadable, createWritable, createTransform, createCollector, createPassThrough, createPullStream, createBufferedStream, createReadableFromArray, createReadableFromAsyncIterable, createReadableFromGenerator, createReadableFromPromise, createDuplex, createEmptyReadable, createNullWritable, pipeline, finished, streamToPromise, streamToUint8Array, streamToBuffer, streamToString, drainStream, copyStream, addAbortSignal, compose, finishedAll, once, promisify, isReadable, isWritable, isTransform, isDuplex, isStream, isDestroyed, isDisturbed, isErrored, getDefaultHighWaterMark, setDefaultHighWaterMark, duplexPair, normalizeWritable as Writeable, consumers, promises } from "./streams.browser.js";
|
|
10
|
+
export { EventEmitter } from "./event-emitter.js";
|
|
11
|
+
export { ChunkedBuilder, TransactionalChunkedBuilder } from "./chunked-builder.js";
|
|
12
|
+
export { textEncoder, textDecoder, stringToUint8Array, uint8ArrayToString, uint8ArrayEquals, uint8ArrayIndexOf, uint8ArraySlice, toUint8Array, bufferToString, concatUint8Arrays } from "./shared.js";
|
|
13
|
+
export { collect, text, json, bytes, fromString, fromJSON, fromBytes, transform, filter } from "./utils.js";
|
|
@@ -1,52 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Stream Module
|
|
2
|
+
* Stream Module (Node.js entry)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Public entrypoint for stream utilities and classes.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* -
|
|
8
|
-
*
|
|
9
|
-
* Both implementations provide the same API for cross-platform compatibility.
|
|
6
|
+
* Notes:
|
|
7
|
+
* - This file is intentionally export-only (tree-shaking friendly).
|
|
8
|
+
* - Browser builds should import from `@stream/index.browser`.
|
|
10
9
|
*
|
|
11
10
|
* @example
|
|
12
|
-
* ```
|
|
13
|
-
* import {
|
|
14
|
-
* Readable,
|
|
15
|
-
* Writable,
|
|
16
|
-
* Transform,
|
|
17
|
-
* Duplex,
|
|
18
|
-
* PassThrough,
|
|
19
|
-
* pipeline,
|
|
20
|
-
* createTransform,
|
|
21
|
-
* streamToUint8Array
|
|
22
|
-
* } from './modules/stream.js';
|
|
23
|
-
*
|
|
24
|
-
* // Create a transform stream
|
|
25
|
-
* const uppercase = createTransform<Uint8Array, Uint8Array>(chunk => {
|
|
26
|
-
* const text = new TextDecoder().decode(chunk);
|
|
27
|
-
* return new TextEncoder().encode(text.toUpperCase());
|
|
28
|
-
* });
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { pipeline, createTransform, createCollector } from "./index.js";
|
|
29
13
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
14
|
+
* const upper = createTransform<Uint8Array, Uint8Array>(chunk => chunk);
|
|
15
|
+
* const out = createCollector<Uint8Array>();
|
|
16
|
+
* await pipeline(source, upper, out);
|
|
32
17
|
* ```
|
|
33
18
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export {
|
|
39
|
-
import { EventEmitter } from "./event-emitter.js";
|
|
40
|
-
export { EventEmitter };
|
|
41
|
-
// =============================================================================
|
|
42
|
-
// ChunkedBuilder (platform-independent)
|
|
43
|
-
// =============================================================================
|
|
44
|
-
import { ChunkedBuilder, TransactionalChunkedBuilder } from "./chunked-builder.js";
|
|
45
|
-
export { ChunkedBuilder, TransactionalChunkedBuilder };
|
|
46
|
-
// =============================================================================
|
|
47
|
-
// Utility Functions (platform-independent)
|
|
48
|
-
// =============================================================================
|
|
49
|
-
import { textEncoder, textDecoder, stringToUint8Array, uint8ArrayToString, uint8ArrayEquals, uint8ArrayIndexOf, uint8ArraySlice, toUint8Array, bufferToString, concatUint8Arrays } from "./shared.js";
|
|
50
|
-
export { textEncoder, textDecoder, stringToUint8Array, uint8ArrayToString, uint8ArrayEquals, uint8ArrayIndexOf, uint8ArraySlice, toUint8Array, bufferToString, concatUint8Arrays };
|
|
51
|
-
import { collect, text, json, bytes, fromString, fromJSON, fromBytes, transform, filter } from "./utils.js";
|
|
52
|
-
export { collect, text, json, bytes, fromString, fromJSON, fromBytes, transform, filter };
|
|
19
|
+
export { Readable, Writable, Transform, Duplex, PassThrough, Collector, PullStream, BufferedStream, StringChunk, BufferChunk, createReadable, createWritable, createTransform, createCollector, createPassThrough, createPullStream, createBufferedStream, createReadableFromArray, createReadableFromAsyncIterable, createReadableFromGenerator, createReadableFromPromise, createDuplex, createEmptyReadable, createNullWritable, pipeline, finished, streamToPromise, streamToUint8Array, streamToBuffer, streamToString, drainStream, copyStream, addAbortSignal, compose, finishedAll, once, promisify, isReadable, isWritable, isTransform, isDuplex, isStream, isDestroyed, isDisturbed, isErrored, getDefaultHighWaterMark, setDefaultHighWaterMark, duplexPair, normalizeWritable as Writeable, consumers, promises } from "./streams.js";
|
|
20
|
+
export { EventEmitter } from "./event-emitter.js";
|
|
21
|
+
export { ChunkedBuilder, TransactionalChunkedBuilder } from "./chunked-builder.js";
|
|
22
|
+
export { textEncoder, textDecoder, stringToUint8Array, uint8ArrayToString, uint8ArrayEquals, uint8ArrayIndexOf, uint8ArraySlice, toUint8Array, bufferToString, concatUint8Arrays } from "./shared.js";
|
|
23
|
+
export { collect, text, json, bytes, fromString, fromJSON, fromBytes, transform, filter } from "./utils.js";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Small event utilities for Node-style emitters.
|
|
3
|
+
*
|
|
4
|
+
* Prefer keeping this separate from the main stream implementation so other
|
|
5
|
+
* modules (e.g. archive) can reuse it without pulling in the whole stream API.
|
|
6
|
+
*/
|
|
7
|
+
function off(emitter, event, listener) {
|
|
8
|
+
if (typeof emitter.off === "function") {
|
|
9
|
+
emitter.off(event, listener);
|
|
10
|
+
}
|
|
11
|
+
else if (typeof emitter.removeListener === "function") {
|
|
12
|
+
emitter.removeListener(event, listener);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Resolve when an emitter fires `event`, reject on `error`.
|
|
17
|
+
*/
|
|
18
|
+
export function onceEvent(emitter, event) {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
const onError = (err) => {
|
|
21
|
+
cleanup();
|
|
22
|
+
reject(err instanceof Error ? err : new Error(String(err)));
|
|
23
|
+
};
|
|
24
|
+
const onDone = () => {
|
|
25
|
+
cleanup();
|
|
26
|
+
resolve();
|
|
27
|
+
};
|
|
28
|
+
const cleanup = () => {
|
|
29
|
+
off(emitter, "error", onError);
|
|
30
|
+
off(emitter, event, onDone);
|
|
31
|
+
};
|
|
32
|
+
if (typeof emitter.once === "function") {
|
|
33
|
+
emitter.once("error", onError);
|
|
34
|
+
emitter.once(event, onDone);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
emitter.on?.("error", onError);
|
|
38
|
+
emitter.on?.(event, onDone);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight runtime type guards shared across modules.
|
|
3
|
+
*
|
|
4
|
+
* Keep this file dependency-free to maximize deduping in bundled builds.
|
|
5
|
+
*/
|
|
6
|
+
export function isReadableStream(value) {
|
|
7
|
+
return !!value && typeof value === "object" && typeof value.getReader === "function";
|
|
8
|
+
}
|
|
9
|
+
export function isWritableStream(value) {
|
|
10
|
+
return !!value && typeof value === "object" && typeof value.getWriter === "function";
|
|
11
|
+
}
|
|
12
|
+
export function isAsyncIterable(value) {
|
|
13
|
+
return (!!value &&
|
|
14
|
+
(typeof value === "object" || typeof value === "function") &&
|
|
15
|
+
typeof value[Symbol.asyncIterator] === "function");
|
|
16
|
+
}
|
|
17
|
+
export function isTransformStream(value) {
|
|
18
|
+
return (!!value &&
|
|
19
|
+
typeof value === "object" &&
|
|
20
|
+
!!value.readable &&
|
|
21
|
+
!!value.writable &&
|
|
22
|
+
isReadableStream(value.readable) &&
|
|
23
|
+
isWritableStream(value.writable));
|
|
24
|
+
}
|
|
@@ -5,36 +5,41 @@
|
|
|
5
5
|
* Works identically in both browser and Node.js environments.
|
|
6
6
|
*/
|
|
7
7
|
import { EventEmitter } from "./event-emitter.js";
|
|
8
|
-
|
|
8
|
+
const EMPTY_U8 = new Uint8Array(0);
|
|
9
9
|
/**
|
|
10
10
|
* Browser-compatible Pull Stream - Read data from buffer on demand with pattern matching
|
|
11
11
|
*/
|
|
12
12
|
export class PullStream extends EventEmitter {
|
|
13
13
|
constructor(_options = {}) {
|
|
14
14
|
super();
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
// Single growable buffer with read/write cursors.
|
|
16
|
+
// IMPORTANT: never mutate bytes that have already been returned via subarray
|
|
17
|
+
// (to keep views stable). When we need to reclaim prefix space, we allocate
|
|
18
|
+
// a new buffer and copy the remaining bytes.
|
|
19
|
+
this._buffer = new Uint8Array(0);
|
|
20
|
+
this._bufferReadIndex = 0;
|
|
21
|
+
this._bufferWriteIndex = 0;
|
|
18
22
|
this.finished = false;
|
|
19
23
|
this._destroyed = false;
|
|
20
24
|
}
|
|
21
|
-
//
|
|
25
|
+
// Maintain legacy protected accessor for subclasses.
|
|
26
|
+
// Returned value is a view of the readable region.
|
|
22
27
|
get buffer() {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return new Uint8Array(0);
|
|
28
|
+
if (this._bufferReadIndex === this._bufferWriteIndex) {
|
|
29
|
+
return EMPTY_U8;
|
|
26
30
|
}
|
|
27
|
-
|
|
28
|
-
return this._bufferChunks[0];
|
|
29
|
-
}
|
|
30
|
-
// Consolidate multiple chunks
|
|
31
|
-
const buf = concatUint8Arrays(this._bufferChunks);
|
|
32
|
-
this._bufferChunks = [buf];
|
|
33
|
-
return buf;
|
|
31
|
+
return this._buffer.subarray(this._bufferReadIndex, this._bufferWriteIndex);
|
|
34
32
|
}
|
|
35
33
|
set buffer(buf) {
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
if (buf.length === 0) {
|
|
35
|
+
this._buffer = EMPTY_U8;
|
|
36
|
+
this._bufferReadIndex = 0;
|
|
37
|
+
this._bufferWriteIndex = 0;
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
this._buffer = buf;
|
|
41
|
+
this._bufferReadIndex = 0;
|
|
42
|
+
this._bufferWriteIndex = buf.length;
|
|
38
43
|
}
|
|
39
44
|
/**
|
|
40
45
|
* Write data to the stream
|
|
@@ -44,8 +49,38 @@ export class PullStream extends EventEmitter {
|
|
|
44
49
|
this.emit("error", new Error("Cannot write to destroyed stream"));
|
|
45
50
|
return false;
|
|
46
51
|
}
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
const chunkLen = chunk.length;
|
|
53
|
+
if (chunkLen === 0) {
|
|
54
|
+
this.emit("chunk");
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
// Fast path: first write can reuse caller buffer without copy.
|
|
58
|
+
if (this._buffer.length === 0) {
|
|
59
|
+
this._buffer = chunk;
|
|
60
|
+
this._bufferReadIndex = 0;
|
|
61
|
+
this._bufferWriteIndex = chunkLen;
|
|
62
|
+
this.emit("chunk");
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
const required = this._bufferWriteIndex + chunkLen;
|
|
66
|
+
if (required <= this._buffer.length) {
|
|
67
|
+
this._buffer.set(chunk, this._bufferWriteIndex);
|
|
68
|
+
this._bufferWriteIndex += chunkLen;
|
|
69
|
+
this.emit("chunk");
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
// Need a new buffer. We keep previously returned views stable by allocating.
|
|
73
|
+
const remaining = this._bufferWriteIndex - this._bufferReadIndex;
|
|
74
|
+
const nextLength = remaining + chunkLen;
|
|
75
|
+
const prevCap = this._buffer.length;
|
|
76
|
+
// Grow exponentially to avoid O(n^2) copying on many small writes.
|
|
77
|
+
const nextCap = Math.max(nextLength, prevCap > 0 ? prevCap * 2 : 1024);
|
|
78
|
+
const next = new Uint8Array(nextCap);
|
|
79
|
+
next.set(this._buffer.subarray(this._bufferReadIndex, this._bufferWriteIndex), 0);
|
|
80
|
+
next.set(chunk, remaining);
|
|
81
|
+
this._buffer = next;
|
|
82
|
+
this._bufferReadIndex = 0;
|
|
83
|
+
this._bufferWriteIndex = nextLength;
|
|
49
84
|
this.emit("chunk");
|
|
50
85
|
return true;
|
|
51
86
|
}
|
|
@@ -69,8 +104,9 @@ export class PullStream extends EventEmitter {
|
|
|
69
104
|
return;
|
|
70
105
|
}
|
|
71
106
|
this._destroyed = true;
|
|
72
|
-
this.
|
|
73
|
-
this.
|
|
107
|
+
this._buffer = EMPTY_U8;
|
|
108
|
+
this._bufferReadIndex = 0;
|
|
109
|
+
this._bufferWriteIndex = 0;
|
|
74
110
|
if (error) {
|
|
75
111
|
this.emit("error", error);
|
|
76
112
|
}
|
|
@@ -95,19 +131,32 @@ export class PullStream extends EventEmitter {
|
|
|
95
131
|
reject(new Error("Stream destroyed"));
|
|
96
132
|
return;
|
|
97
133
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
134
|
+
if (size === 0) {
|
|
135
|
+
resolve(this._buffer.subarray(this._bufferReadIndex, this._bufferReadIndex));
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const available = this._bufferWriteIndex - this._bufferReadIndex;
|
|
139
|
+
if (available >= size) {
|
|
140
|
+
const start = this._bufferReadIndex;
|
|
141
|
+
const end = start + size;
|
|
142
|
+
const result = this._buffer.subarray(start, end);
|
|
143
|
+
this._bufferReadIndex = end;
|
|
144
|
+
if (this._bufferReadIndex === this._bufferWriteIndex) {
|
|
145
|
+
this._buffer = EMPTY_U8;
|
|
146
|
+
this._bufferReadIndex = 0;
|
|
147
|
+
this._bufferWriteIndex = 0;
|
|
148
|
+
}
|
|
103
149
|
resolve(result);
|
|
104
150
|
return;
|
|
105
151
|
}
|
|
106
152
|
if (this.finished) {
|
|
107
153
|
// Return whatever we have
|
|
108
|
-
const result = this.
|
|
109
|
-
|
|
110
|
-
|
|
154
|
+
const result = this._bufferReadIndex === this._bufferWriteIndex
|
|
155
|
+
? EMPTY_U8
|
|
156
|
+
: this._buffer.subarray(this._bufferReadIndex, this._bufferWriteIndex);
|
|
157
|
+
this._buffer = EMPTY_U8;
|
|
158
|
+
this._bufferReadIndex = 0;
|
|
159
|
+
this._bufferWriteIndex = 0;
|
|
111
160
|
resolve(result);
|
|
112
161
|
return;
|
|
113
162
|
}
|
|
@@ -124,21 +173,36 @@ export class PullStream extends EventEmitter {
|
|
|
124
173
|
reject(new Error("Stream destroyed"));
|
|
125
174
|
return;
|
|
126
175
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
this.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
176
|
+
// Match empty pattern without consuming anything.
|
|
177
|
+
if (pattern.length === 0) {
|
|
178
|
+
this._match = 0;
|
|
179
|
+
resolve(this._buffer.subarray(this._bufferReadIndex, this._bufferReadIndex));
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const matchIndexAbs = this._indexOf(this._buffer, this._bufferReadIndex, this._bufferWriteIndex, pattern);
|
|
183
|
+
if (matchIndexAbs !== -1) {
|
|
184
|
+
this._match = matchIndexAbs - this._bufferReadIndex;
|
|
185
|
+
const patternLen = pattern.length;
|
|
186
|
+
const resultEndAbs = includePattern ? matchIndexAbs + patternLen : matchIndexAbs;
|
|
187
|
+
const consumeTo = matchIndexAbs + patternLen;
|
|
188
|
+
const result = this._buffer.subarray(this._bufferReadIndex, resultEndAbs);
|
|
189
|
+
this._bufferReadIndex = consumeTo;
|
|
190
|
+
if (this._bufferReadIndex === this._bufferWriteIndex) {
|
|
191
|
+
this._buffer = EMPTY_U8;
|
|
192
|
+
this._bufferReadIndex = 0;
|
|
193
|
+
this._bufferWriteIndex = 0;
|
|
194
|
+
}
|
|
134
195
|
resolve(result);
|
|
135
196
|
return;
|
|
136
197
|
}
|
|
137
198
|
if (this.finished) {
|
|
138
199
|
// Pattern not found, return everything
|
|
139
|
-
const result =
|
|
140
|
-
|
|
141
|
-
|
|
200
|
+
const result = this._bufferReadIndex === this._bufferWriteIndex
|
|
201
|
+
? EMPTY_U8
|
|
202
|
+
: this._buffer.subarray(this._bufferReadIndex, this._bufferWriteIndex);
|
|
203
|
+
this._buffer = EMPTY_U8;
|
|
204
|
+
this._bufferReadIndex = 0;
|
|
205
|
+
this._bufferWriteIndex = 0;
|
|
142
206
|
resolve(result);
|
|
143
207
|
return;
|
|
144
208
|
}
|
|
@@ -158,7 +222,7 @@ export class PullStream extends EventEmitter {
|
|
|
158
222
|
* Get remaining buffer length
|
|
159
223
|
*/
|
|
160
224
|
get length() {
|
|
161
|
-
return this.
|
|
225
|
+
return this._bufferWriteIndex - this._bufferReadIndex;
|
|
162
226
|
}
|
|
163
227
|
/**
|
|
164
228
|
* Check if stream is finished
|
|
@@ -175,13 +239,13 @@ export class PullStream extends EventEmitter {
|
|
|
175
239
|
/**
|
|
176
240
|
* Find pattern in Uint8Array (like Buffer.indexOf)
|
|
177
241
|
*/
|
|
178
|
-
_indexOf(haystack,
|
|
242
|
+
_indexOf(haystack, start, end, needle) {
|
|
179
243
|
const needleLen = needle.length;
|
|
180
244
|
if (needleLen === 0) {
|
|
181
245
|
return start;
|
|
182
246
|
}
|
|
183
|
-
const haystackLen =
|
|
184
|
-
if (needleLen > haystackLen) {
|
|
247
|
+
const haystackLen = end;
|
|
248
|
+
if (needleLen > haystackLen - start) {
|
|
185
249
|
return -1;
|
|
186
250
|
}
|
|
187
251
|
const first = needle[0];
|
|
@@ -54,7 +54,7 @@ export function uint8ArrayToString(arr, encoding) {
|
|
|
54
54
|
/**
|
|
55
55
|
* Concatenate multiple Uint8Arrays efficiently
|
|
56
56
|
*/
|
|
57
|
-
export function concatUint8Arrays(arrays) {
|
|
57
|
+
export function concatUint8Arrays(arrays, totalLength) {
|
|
58
58
|
const len = arrays.length;
|
|
59
59
|
if (len === 0) {
|
|
60
60
|
return new Uint8Array(0);
|
|
@@ -63,9 +63,12 @@ export function concatUint8Arrays(arrays) {
|
|
|
63
63
|
return arrays[0];
|
|
64
64
|
}
|
|
65
65
|
// Calculate total length with for loop for better performance
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
if (totalLength === undefined) {
|
|
67
|
+
let sum = 0;
|
|
68
|
+
for (let i = 0; i < len; i++) {
|
|
69
|
+
sum += arrays[i].length;
|
|
70
|
+
}
|
|
71
|
+
totalLength = sum;
|
|
69
72
|
}
|
|
70
73
|
const result = new Uint8Array(totalLength);
|
|
71
74
|
let offset = 0;
|