7z-iterator 0.2.9 → 0.2.11
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/dist/cjs/FileEntry.js +1 -1
- package/dist/cjs/FileEntry.js.map +1 -1
- package/dist/cjs/SevenZipIterator.js +1 -1
- package/dist/cjs/SevenZipIterator.js.map +1 -1
- package/dist/cjs/compat.js +1 -1
- package/dist/cjs/compat.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/lib/Lock.js +1 -1
- package/dist/cjs/lib/streamToSource.js +1 -1
- package/dist/cjs/lib/streamToSource.js.map +1 -1
- package/dist/cjs/nextEntry.js +1 -1
- package/dist/cjs/nextEntry.js.map +1 -1
- package/dist/cjs/sevenz/NumberCodec.js +1 -1
- package/dist/cjs/sevenz/NumberCodec.js.map +1 -1
- package/dist/cjs/sevenz/SevenZipParser.js +1 -1
- package/dist/cjs/sevenz/SevenZipParser.js.map +1 -1
- package/dist/cjs/sevenz/codecs/Aes.js +1 -1
- package/dist/cjs/sevenz/codecs/Aes.js.map +1 -1
- package/dist/cjs/sevenz/codecs/BZip2.js +1 -1
- package/dist/cjs/sevenz/codecs/Bcj.js +2 -2
- package/dist/cjs/sevenz/codecs/Bcj.js.map +1 -1
- package/dist/cjs/sevenz/codecs/Bcj2.js +1 -1
- package/dist/cjs/sevenz/codecs/Bcj2.js.map +1 -1
- package/dist/cjs/sevenz/codecs/BcjArm.js +1 -1
- package/dist/cjs/sevenz/codecs/BcjArm.js.map +1 -1
- package/dist/cjs/sevenz/codecs/BcjArm64.js +1 -1
- package/dist/cjs/sevenz/codecs/BcjArm64.js.map +1 -1
- package/dist/cjs/sevenz/codecs/BcjArmt.js +1 -1
- package/dist/cjs/sevenz/codecs/BcjArmt.js.map +1 -1
- package/dist/cjs/sevenz/codecs/BcjIa64.js +1 -1
- package/dist/cjs/sevenz/codecs/BcjIa64.js.map +1 -1
- package/dist/cjs/sevenz/codecs/BcjPpc.js +1 -1
- package/dist/cjs/sevenz/codecs/BcjPpc.js.map +1 -1
- package/dist/cjs/sevenz/codecs/BcjSparc.js +1 -1
- package/dist/cjs/sevenz/codecs/BcjSparc.js.map +1 -1
- package/dist/cjs/sevenz/codecs/Copy.js +1 -1
- package/dist/cjs/sevenz/codecs/Deflate.js +1 -1
- package/dist/cjs/sevenz/codecs/Delta.js +1 -1
- package/dist/cjs/sevenz/codecs/Delta.js.map +1 -1
- package/dist/cjs/sevenz/codecs/Lzma.js +1 -1
- package/dist/cjs/sevenz/codecs/Lzma.js.map +1 -1
- package/dist/cjs/sevenz/codecs/Lzma2.js +1 -1
- package/dist/cjs/sevenz/codecs/Lzma2.js.map +1 -1
- package/dist/cjs/sevenz/codecs/createBufferingDecoder.js +1 -1
- package/dist/cjs/sevenz/codecs/createBufferingDecoder.js.map +1 -1
- package/dist/cjs/sevenz/codecs/index.js +1 -1
- package/dist/cjs/sevenz/codecs/index.js.map +1 -1
- package/dist/cjs/sevenz/codecs/lzmaCompat.d.cts +1 -1
- package/dist/cjs/sevenz/codecs/lzmaCompat.d.ts +1 -1
- package/dist/cjs/sevenz/codecs/lzmaCompat.js +1 -1
- package/dist/cjs/sevenz/codecs/lzmaCompat.js.map +1 -1
- package/dist/cjs/sevenz/codecs/streams.js +1 -1
- package/dist/cjs/sevenz/codecs/streams.js.map +1 -1
- package/dist/cjs/sevenz/constants.d.cts +8 -8
- package/dist/cjs/sevenz/constants.d.ts +8 -8
- package/dist/cjs/sevenz/constants.js +1 -1
- package/dist/cjs/sevenz/constants.js.map +1 -1
- package/dist/cjs/sevenz/headers.js +2 -2
- package/dist/cjs/sevenz/headers.js.map +1 -1
- package/dist/cjs/sevenz/index.js +1 -1
- package/dist/cjs/types.js +1 -1
- package/dist/esm/FileEntry.js +1 -1
- package/dist/esm/FileEntry.js.map +1 -1
- package/dist/esm/SevenZipIterator.js +6 -6
- package/dist/esm/SevenZipIterator.js.map +1 -1
- package/dist/esm/compat.js +2 -2
- package/dist/esm/compat.js.map +1 -1
- package/dist/esm/lib/streamToSource.js +12 -12
- package/dist/esm/lib/streamToSource.js.map +1 -1
- package/dist/esm/nextEntry.js +11 -11
- package/dist/esm/nextEntry.js.map +1 -1
- package/dist/esm/sevenz/NumberCodec.js +19 -19
- package/dist/esm/sevenz/NumberCodec.js.map +1 -1
- package/dist/esm/sevenz/SevenZipParser.js +191 -191
- package/dist/esm/sevenz/SevenZipParser.js.map +1 -1
- package/dist/esm/sevenz/codecs/Aes.js +29 -29
- package/dist/esm/sevenz/codecs/Aes.js.map +1 -1
- package/dist/esm/sevenz/codecs/Bcj.js +8 -8
- package/dist/esm/sevenz/codecs/Bcj.js.map +1 -1
- package/dist/esm/sevenz/codecs/Bcj2.js +35 -35
- package/dist/esm/sevenz/codecs/Bcj2.js.map +1 -1
- package/dist/esm/sevenz/codecs/BcjArm.js +4 -4
- package/dist/esm/sevenz/codecs/BcjArm.js.map +1 -1
- package/dist/esm/sevenz/codecs/BcjArm64.js +5 -5
- package/dist/esm/sevenz/codecs/BcjArm64.js.map +1 -1
- package/dist/esm/sevenz/codecs/BcjArmt.js +10 -10
- package/dist/esm/sevenz/codecs/BcjArmt.js.map +1 -1
- package/dist/esm/sevenz/codecs/BcjIa64.js +24 -24
- package/dist/esm/sevenz/codecs/BcjIa64.js.map +1 -1
- package/dist/esm/sevenz/codecs/BcjPpc.js +5 -5
- package/dist/esm/sevenz/codecs/BcjPpc.js.map +1 -1
- package/dist/esm/sevenz/codecs/BcjSparc.js +8 -8
- package/dist/esm/sevenz/codecs/BcjSparc.js.map +1 -1
- package/dist/esm/sevenz/codecs/Delta.js +6 -6
- package/dist/esm/sevenz/codecs/Delta.js.map +1 -1
- package/dist/esm/sevenz/codecs/Lzma.js +16 -16
- package/dist/esm/sevenz/codecs/Lzma.js.map +1 -1
- package/dist/esm/sevenz/codecs/Lzma2.js +35 -35
- package/dist/esm/sevenz/codecs/Lzma2.js.map +1 -1
- package/dist/esm/sevenz/codecs/createBufferingDecoder.js +3 -3
- package/dist/esm/sevenz/codecs/createBufferingDecoder.js.map +1 -1
- package/dist/esm/sevenz/codecs/index.js +6 -6
- package/dist/esm/sevenz/codecs/index.js.map +1 -1
- package/dist/esm/sevenz/codecs/lzmaCompat.d.ts +1 -1
- package/dist/esm/sevenz/codecs/lzmaCompat.js +5 -5
- package/dist/esm/sevenz/codecs/lzmaCompat.js.map +1 -1
- package/dist/esm/sevenz/codecs/streams.js +13 -13
- package/dist/esm/sevenz/codecs/streams.js.map +1 -1
- package/dist/esm/sevenz/constants.d.ts +8 -8
- package/dist/esm/sevenz/constants.js +9 -9
- package/dist/esm/sevenz/constants.js.map +1 -1
- package/dist/esm/sevenz/headers.js +134 -134
- package/dist/esm/sevenz/headers.js.map +1 -1
- package/package.json +20 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/BcjArmt.ts"],"sourcesContent":["// BCJ (ARM Thumb) filter codec - converts ARM Thumb branch instruction addresses\n// This filter makes ARM Thumb executables more compressible by LZMA\n//\n// ARM Thumb uses 16-bit instructions, but BL (branch with link) spans two 16-bit words.\n// The filter converts relative addresses to absolute during compression.\n//\n// Reference: https://github.com/kornelski/7z/blob/main/C/Bra.c\n\nimport { bufferFrom } from 'extract-base-iterator';\nimport type { Transform } from 'readable-stream';\nimport createBufferingDecoder from './createBufferingDecoder.ts';\n\n/**\n * Decode ARM Thumb BCJ filtered data\n * Reverses the BCJ transformation by converting absolute addresses back to relative\n *\n * ARM Thumb BL instruction format (2 x 16-bit):\n * - First half-word: 1111 0xxx xxxx xxxx (high bits of offset)\n * - Second half-word: 1111 1xxx xxxx xxxx (low bits of offset)\n *\n * @param input - ARM Thumb BCJ filtered data\n * @param _properties - Unused for ARM Thumb BCJ\n * @param _unpackSize - Unused for ARM Thumb BCJ\n * @returns Unfiltered data\n */\nexport function decodeBcjArmt(input: Buffer, _properties?: Buffer, _unpackSize?: number): Buffer {\n
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/BcjArmt.ts"],"sourcesContent":["// BCJ (ARM Thumb) filter codec - converts ARM Thumb branch instruction addresses\n// This filter makes ARM Thumb executables more compressible by LZMA\n//\n// ARM Thumb uses 16-bit instructions, but BL (branch with link) spans two 16-bit words.\n// The filter converts relative addresses to absolute during compression.\n//\n// Reference: https://github.com/kornelski/7z/blob/main/C/Bra.c\n\nimport { bufferFrom } from 'extract-base-iterator';\nimport type { Transform } from 'readable-stream';\nimport createBufferingDecoder from './createBufferingDecoder.ts';\n\n/**\n * Decode ARM Thumb BCJ filtered data\n * Reverses the BCJ transformation by converting absolute addresses back to relative\n *\n * ARM Thumb BL instruction format (2 x 16-bit):\n * - First half-word: 1111 0xxx xxxx xxxx (high bits of offset)\n * - Second half-word: 1111 1xxx xxxx xxxx (low bits of offset)\n *\n * @param input - ARM Thumb BCJ filtered data\n * @param _properties - Unused for ARM Thumb BCJ\n * @param _unpackSize - Unused for ARM Thumb BCJ\n * @returns Unfiltered data\n */\nexport function decodeBcjArmt(input: Buffer, _properties?: Buffer, _unpackSize?: number): Buffer {\n const output = bufferFrom(input); // Copy since we modify in place\n let pos = 0;\n\n // Process 2-byte aligned positions\n while (pos + 4 <= output.length) {\n // Read two 16-bit values (little-endian)\n const w0 = output[pos] | (output[pos + 1] << 8);\n const w1 = output[pos + 2] | (output[pos + 3] << 8);\n\n // Check for BL instruction pair:\n // First word: 0xF000-0xF7FF (1111 0xxx xxxx xxxx)\n // Second word: 0xF800-0xFFFF (1111 1xxx xxxx xxxx)\n if ((w0 & 0xf800) === 0xf000 && (w1 & 0xf800) === 0xf800) {\n // Extract and combine the offset parts\n // High 11 bits from w0, low 11 bits from w1\n const hi = w0 & 0x7ff;\n const lo = w1 & 0x7ff;\n\n // Combine into 22-bit offset (in half-words)\n let addr = (hi << 11) | lo;\n\n // Sign-extend 22-bit to 32-bit\n if (addr & 0x200000) {\n addr |= 0xffc00000;\n }\n\n // Convert absolute to relative:\n // Subtract current position (in half-words, so divide by 2)\n // Thumb PC is 2 half-words (4 bytes) ahead\n const relAddr = addr - (pos >>> 1);\n\n // Write back\n const newHi = (relAddr >>> 11) & 0x7ff;\n const newLo = relAddr & 0x7ff;\n\n output[pos] = newHi & 0xff;\n output[pos + 1] = 0xf0 | ((newHi >>> 8) & 0x07);\n output[pos + 2] = newLo & 0xff;\n output[pos + 3] = 0xf8 | ((newLo >>> 8) & 0x07);\n\n pos += 4;\n } else {\n pos += 2;\n }\n }\n\n return output;\n}\n\n/**\n * Create an ARM Thumb BCJ decoder Transform stream\n */\nexport function createBcjArmtDecoder(properties?: Buffer, unpackSize?: number): Transform {\n return createBufferingDecoder(decodeBcjArmt, properties, unpackSize);\n}\n"],"names":["createBcjArmtDecoder","decodeBcjArmt","input","_properties","_unpackSize","output","bufferFrom","pos","length","w0","w1","hi","lo","addr","relAddr","newHi","newLo","properties","unpackSize","createBufferingDecoder"],"mappings":"AAAA,iFAAiF;AACjF,oEAAoE;AACpE,EAAE;AACF,wFAAwF;AACxF,yEAAyE;AACzE,EAAE;AACF,+DAA+D;;;;;;;;;;;;QAwE/CA;eAAAA;;QArDAC;eAAAA;;;mCAjBW;+EAEQ;;;;;;AAe5B,SAASA,cAAcC,KAAa,EAAEC,WAAoB,EAAEC,WAAoB;IACrF,IAAMC,SAASC,IAAAA,+BAAU,EAACJ,QAAQ,gCAAgC;IAClE,IAAIK,MAAM;IAEV,mCAAmC;IACnC,MAAOA,MAAM,KAAKF,OAAOG,MAAM,CAAE;QAC/B,yCAAyC;QACzC,IAAMC,KAAKJ,MAAM,CAACE,IAAI,GAAIF,MAAM,CAACE,MAAM,EAAE,IAAI;QAC7C,IAAMG,KAAKL,MAAM,CAACE,MAAM,EAAE,GAAIF,MAAM,CAACE,MAAM,EAAE,IAAI;QAEjD,iCAAiC;QACjC,kDAAkD;QAClD,mDAAmD;QACnD,IAAI,AAACE,CAAAA,KAAK,MAAK,MAAO,UAAU,AAACC,CAAAA,KAAK,MAAK,MAAO,QAAQ;YACxD,uCAAuC;YACvC,4CAA4C;YAC5C,IAAMC,KAAKF,KAAK;YAChB,IAAMG,KAAKF,KAAK;YAEhB,6CAA6C;YAC7C,IAAIG,OAAO,AAACF,MAAM,KAAMC;YAExB,+BAA+B;YAC/B,IAAIC,OAAO,UAAU;gBACnBA,QAAQ;YACV;YAEA,gCAAgC;YAChC,4DAA4D;YAC5D,2CAA2C;YAC3C,IAAMC,UAAUD,OAAQN,CAAAA,QAAQ,CAAA;YAEhC,aAAa;YACb,IAAMQ,QAAQ,AAACD,YAAY,KAAM;YACjC,IAAME,QAAQF,UAAU;YAExBT,MAAM,CAACE,IAAI,GAAGQ,QAAQ;YACtBV,MAAM,CAACE,MAAM,EAAE,GAAG,OAAQ,AAACQ,UAAU,IAAK;YAC1CV,MAAM,CAACE,MAAM,EAAE,GAAGS,QAAQ;YAC1BX,MAAM,CAACE,MAAM,EAAE,GAAG,OAAQ,AAACS,UAAU,IAAK;YAE1CT,OAAO;QACT,OAAO;YACLA,OAAO;QACT;IACF;IAEA,OAAOF;AACT;AAKO,SAASL,qBAAqBiB,UAAmB,EAAEC,UAAmB;IAC3E,OAAOC,IAAAA,iCAAsB,EAAClB,eAAegB,YAAYC;AAC3D"}
|
|
@@ -138,4 +138,4 @@ function decodeBcjIa64(input, _properties, _unpackSize) {
|
|
|
138
138
|
function createBcjIa64Decoder(properties, unpackSize) {
|
|
139
139
|
return (0, _createBufferingDecoderts.default)(decodeBcjIa64, properties, unpackSize);
|
|
140
140
|
}
|
|
141
|
-
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (
|
|
141
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (let key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/BcjIa64.ts"],"sourcesContent":["// BCJ (IA64/Itanium) filter codec - converts IA64 branch instruction addresses\n// This filter makes IA64 executables more compressible by LZMA\n//\n// IA64 uses 128-bit instruction bundles with 3 instructions per bundle.\n// Branch instructions use 21-bit signed offsets (in bundles).\n//\n// Reference: https://github.com/kornelski/7z/blob/main/C/Bra.c\n\nimport { bufferFrom } from 'extract-base-iterator';\nimport type { Transform } from 'readable-stream';\nimport createBufferingDecoder from './createBufferingDecoder.ts';\n\n// IA64 branch instruction slot mask\n// Each bundle has a 5-bit template and 3 x 41-bit instruction slots\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/BcjIa64.ts"],"sourcesContent":["// BCJ (IA64/Itanium) filter codec - converts IA64 branch instruction addresses\n// This filter makes IA64 executables more compressible by LZMA\n//\n// IA64 uses 128-bit instruction bundles with 3 instructions per bundle.\n// Branch instructions use 21-bit signed offsets (in bundles).\n//\n// Reference: https://github.com/kornelski/7z/blob/main/C/Bra.c\n\nimport { bufferFrom } from 'extract-base-iterator';\nimport type { Transform } from 'readable-stream';\nimport createBufferingDecoder from './createBufferingDecoder.ts';\n\n// IA64 branch instruction slot mask\n// Each bundle has a 5-bit template and 3 x 41-bit instruction slots\nconst kBranchTable = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 6, 6, 0, 0, 7, 7, 4, 4, 0, 0, 4, 4, 0, 0];\n\n/**\n * Decode IA64 BCJ filtered data\n * Reverses the BCJ transformation by converting absolute addresses back to relative\n *\n * @param input - IA64 BCJ filtered data\n * @param _properties - Unused for IA64 BCJ\n * @param _unpackSize - Unused for IA64 BCJ\n * @returns Unfiltered data\n */\nexport function decodeBcjIa64(input: Buffer, _properties?: Buffer, _unpackSize?: number): Buffer {\n const output = bufferFrom(input); // Copy since we modify in place\n let pos = 0;\n\n // Process 16-byte aligned bundles\n while (pos + 16 <= output.length) {\n // Get template (low 5 bits of first byte)\n const template = output[pos] & 0x1f;\n const mask = kBranchTable[template];\n\n // Check each instruction slot (3 slots per bundle)\n for (let slot = 0; slot < 3; slot++) {\n if ((mask & (1 << slot)) === 0) {\n continue;\n }\n\n // Calculate bit position for this slot\n // Slot 0: bits 5-45, Slot 1: bits 46-86, Slot 2: bits 87-127\n const bitPos = 5 + slot * 41;\n const bytePos = bitPos >>> 3;\n const bitOffset = bitPos & 7;\n\n // Read 8 bytes to get the instruction (may span bytes)\n // We need at least 6 bytes for a 41-bit instruction\n if (pos + bytePos + 6 > output.length) {\n break;\n }\n\n // Extract instruction bytes\n const instr0 = output[pos + bytePos];\n const instr1 = output[pos + bytePos + 1];\n const instr2 = output[pos + bytePos + 2];\n const instr3 = output[pos + bytePos + 3];\n const instr4 = output[pos + bytePos + 4];\n const instr5 = output[pos + bytePos + 5];\n\n // Build instruction value (we only need the immediate field)\n // The immediate is in bits 13-32 of the instruction (20 bits)\n // Plus bit 36 as the sign bit\n\n // For decoding, we extract the address that was encoded and convert back\n let instrLo = (instr0 >>> bitOffset) | (instr1 << (8 - bitOffset)) | (instr2 << (16 - bitOffset)) | (instr3 << (24 - bitOffset));\n\n let instrHi = (instr4 >>> bitOffset) | (instr5 << (8 - bitOffset));\n\n // Check opcode for branch (opcode 4 or 5 in bits 37-40)\n const opcode = (instrHi >>> (37 - 32 - bitOffset)) & 0xf;\n if (opcode !== 4 && opcode !== 5) {\n continue;\n }\n\n // Extract 21-bit immediate (bits 13-32 + sign bit 36)\n const imm20 = (instrLo >>> 13) & 0xfffff;\n const sign = (instrHi >>> (36 - 32)) & 1;\n\n // Combine into 21-bit signed value\n let addr = imm20 | (sign << 20);\n if (sign) {\n addr |= 0xffe00000; // Sign-extend\n }\n\n // Convert absolute to relative: subtract current position (in bundles)\n const relAddr = addr - (pos >>> 4);\n\n // Write back\n const newImm20 = relAddr & 0xfffff;\n const newSign = (relAddr >>> 20) & 1;\n\n // Clear old immediate and write new one\n instrLo = (instrLo & ~(0xfffff << 13)) | (newImm20 << 13);\n instrHi = (instrHi & ~(1 << (36 - 32))) | (newSign << (36 - 32));\n\n // Write back bytes\n output[pos + bytePos] = (output[pos + bytePos] & ((1 << bitOffset) - 1)) | ((instrLo & 0xff) << bitOffset);\n output[pos + bytePos + 1] = (instrLo >>> (8 - bitOffset)) & 0xff;\n output[pos + bytePos + 2] = (instrLo >>> (16 - bitOffset)) & 0xff;\n output[pos + bytePos + 3] = (instrLo >>> (24 - bitOffset)) & 0xff;\n output[pos + bytePos + 4] = ((instrLo >>> (32 - bitOffset)) & ((1 << bitOffset) - 1)) | ((instrHi & 0xff) << bitOffset);\n output[pos + bytePos + 5] = (output[pos + bytePos + 5] & ~((1 << bitOffset) - 1)) | ((instrHi >>> (8 - bitOffset)) & ((1 << bitOffset) - 1));\n }\n\n pos += 16;\n }\n\n return output;\n}\n\n/**\n * Create an IA64 BCJ decoder Transform stream\n */\nexport function createBcjIa64Decoder(properties?: Buffer, unpackSize?: number): Transform {\n return createBufferingDecoder(decodeBcjIa64, properties, unpackSize);\n}\n"],"names":["createBcjIa64Decoder","decodeBcjIa64","kBranchTable","input","_properties","_unpackSize","output","bufferFrom","pos","length","template","mask","slot","bitPos","bytePos","bitOffset","instr0","instr1","instr2","instr3","instr4","instr5","instrLo","instrHi","opcode","imm20","sign","addr","relAddr","newImm20","newSign","properties","unpackSize","createBufferingDecoder"],"mappings":"AAAA,+EAA+E;AAC/E,+DAA+D;AAC/D,EAAE;AACF,wEAAwE;AACxE,8DAA8D;AAC9D,EAAE;AACF,+DAA+D;;;;;;;;;;;;QA6G/CA;eAAAA;;QA1FAC;eAAAA;;;mCAjBW;+EAEQ;;;;;;AAEnC,oCAAoC;AACpC,oEAAoE;AACpE,IAAMC,eAAe;IAAC;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG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,MAAM,CAACE,MAAMM,UAAU,EAAE,GAAG,CAAE,CAAA,AAAC,CAAA,KAAKC,SAAQ,IAAK,CAAA,IAAO,AAACQ,YAAa,IAAIR,YAAe,AAAC,CAAA,KAAKA,SAAQ,IAAK;QAC3I;QAEAP,OAAO;IACT;IAEA,OAAOF;AACT;AAKO,SAASN,qBAAqB+B,UAAmB,EAAEC,UAAmB;IAC3E,OAAOC,IAAAA,iCAAsB,EAAChC,eAAe8B,YAAYC;AAC3D"}
|
|
@@ -61,4 +61,4 @@ function decodeBcjPpc(input, _properties, _unpackSize) {
|
|
|
61
61
|
function createBcjPpcDecoder(properties, unpackSize) {
|
|
62
62
|
return (0, _createBufferingDecoderts.default)(decodeBcjPpc, properties, unpackSize);
|
|
63
63
|
}
|
|
64
|
-
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (
|
|
64
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (let key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/BcjPpc.ts"],"sourcesContent":["// BCJ (PowerPC) filter codec - converts PowerPC branch instruction addresses\n// This filter makes PowerPC executables more compressible by LZMA\n//\n// PowerPC is big-endian. Branch instructions use 26-bit signed offsets.\n//\n// Reference: https://github.com/kornelski/7z/blob/main/C/Bra.c\n\nimport { bufferFrom } from 'extract-base-iterator';\nimport type { Transform } from 'readable-stream';\nimport createBufferingDecoder from './createBufferingDecoder.ts';\n\n/**\n * Decode PowerPC BCJ filtered data\n * Reverses the BCJ transformation by converting absolute addresses back to relative\n *\n * PowerPC B/BL instruction format (big-endian):\n * - 4 bytes aligned\n * - Opcode 0x48 in high byte with AA=0, LK=1 (0x48000001 mask 0xFC000003)\n * - Bits 6-29 are 24-bit signed offset (in words)\n *\n * @param input - PowerPC BCJ filtered data\n * @param _properties - Unused for PowerPC BCJ\n * @param _unpackSize - Unused for PowerPC BCJ\n * @returns Unfiltered data\n */\nexport function decodeBcjPpc(input: Buffer, _properties?: Buffer, _unpackSize?: number): Buffer {\n
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/BcjPpc.ts"],"sourcesContent":["// BCJ (PowerPC) filter codec - converts PowerPC branch instruction addresses\n// This filter makes PowerPC executables more compressible by LZMA\n//\n// PowerPC is big-endian. Branch instructions use 26-bit signed offsets.\n//\n// Reference: https://github.com/kornelski/7z/blob/main/C/Bra.c\n\nimport { bufferFrom } from 'extract-base-iterator';\nimport type { Transform } from 'readable-stream';\nimport createBufferingDecoder from './createBufferingDecoder.ts';\n\n/**\n * Decode PowerPC BCJ filtered data\n * Reverses the BCJ transformation by converting absolute addresses back to relative\n *\n * PowerPC B/BL instruction format (big-endian):\n * - 4 bytes aligned\n * - Opcode 0x48 in high byte with AA=0, LK=1 (0x48000001 mask 0xFC000003)\n * - Bits 6-29 are 24-bit signed offset (in words)\n *\n * @param input - PowerPC BCJ filtered data\n * @param _properties - Unused for PowerPC BCJ\n * @param _unpackSize - Unused for PowerPC BCJ\n * @returns Unfiltered data\n */\nexport function decodeBcjPpc(input: Buffer, _properties?: Buffer, _unpackSize?: number): Buffer {\n const output = bufferFrom(input); // Copy since we modify in place\n let pos = 0;\n\n // Process 4-byte aligned positions\n while (pos + 4 <= output.length) {\n // Read 32-bit value (big-endian)\n let instr = (output[pos] << 24) | (output[pos + 1] << 16) | (output[pos + 2] << 8) | output[pos + 3];\n\n // Check for B/BL instruction: (instr & 0xFC000003) === 0x48000001\n if ((instr & 0xfc000003) === 0x48000001) {\n // Extract 26-bit offset (bits 2-27, the LI field)\n let addr = instr & 0x03fffffc;\n\n // Sign-extend 26-bit to 32-bit\n if (addr & 0x02000000) {\n addr |= 0xfc000000;\n }\n\n // Convert absolute to relative: subtract current position\n const relAddr = addr - pos;\n\n // Clear old offset and write new one\n instr = (instr & 0xfc000003) | (relAddr & 0x03fffffc);\n\n // Write back (big-endian)\n output[pos] = (instr >>> 24) & 0xff;\n output[pos + 1] = (instr >>> 16) & 0xff;\n output[pos + 2] = (instr >>> 8) & 0xff;\n output[pos + 3] = instr & 0xff;\n }\n pos += 4;\n }\n\n return output;\n}\n\n/**\n * Create a PowerPC BCJ decoder Transform stream\n */\nexport function createBcjPpcDecoder(properties?: Buffer, unpackSize?: number): Transform {\n return createBufferingDecoder(decodeBcjPpc, properties, unpackSize);\n}\n"],"names":["createBcjPpcDecoder","decodeBcjPpc","input","_properties","_unpackSize","output","bufferFrom","pos","length","instr","addr","relAddr","properties","unpackSize","createBufferingDecoder"],"mappings":"AAAA,6EAA6E;AAC7E,kEAAkE;AAClE,EAAE;AACF,wEAAwE;AACxE,EAAE;AACF,+DAA+D;;;;;;;;;;;;QA4D/CA;eAAAA;;QAxCAC;eAAAA;;;mCAlBW;+EAEQ;;;;;;AAgB5B,SAASA,aAAaC,KAAa,EAAEC,WAAoB,EAAEC,WAAoB;IACpF,IAAMC,SAASC,IAAAA,+BAAU,EAACJ,QAAQ,gCAAgC;IAClE,IAAIK,MAAM;IAEV,mCAAmC;IACnC,MAAOA,MAAM,KAAKF,OAAOG,MAAM,CAAE;QAC/B,iCAAiC;QACjC,IAAIC,QAAQ,AAACJ,MAAM,CAACE,IAAI,IAAI,KAAOF,MAAM,CAACE,MAAM,EAAE,IAAI,KAAOF,MAAM,CAACE,MAAM,EAAE,IAAI,IAAKF,MAAM,CAACE,MAAM,EAAE;QAEpG,kEAAkE;QAClE,IAAI,AAACE,CAAAA,QAAQ,UAAS,MAAO,YAAY;YACvC,kDAAkD;YAClD,IAAIC,OAAOD,QAAQ;YAEnB,+BAA+B;YAC/B,IAAIC,OAAO,YAAY;gBACrBA,QAAQ;YACV;YAEA,0DAA0D;YAC1D,IAAMC,UAAUD,OAAOH;YAEvB,qCAAqC;YACrCE,QAAQ,AAACA,QAAQ,aAAeE,UAAU;YAE1C,0BAA0B;YAC1BN,MAAM,CAACE,IAAI,GAAG,AAACE,UAAU,KAAM;YAC/BJ,MAAM,CAACE,MAAM,EAAE,GAAG,AAACE,UAAU,KAAM;YACnCJ,MAAM,CAACE,MAAM,EAAE,GAAG,AAACE,UAAU,IAAK;YAClCJ,MAAM,CAACE,MAAM,EAAE,GAAGE,QAAQ;QAC5B;QACAF,OAAO;IACT;IAEA,OAAOF;AACT;AAKO,SAASL,oBAAoBY,UAAmB,EAAEC,UAAmB;IAC1E,OAAOC,IAAAA,iCAAsB,EAACb,cAAcW,YAAYC;AAC1D"}
|
|
@@ -66,4 +66,4 @@ function decodeBcjSparc(input, _properties, _unpackSize) {
|
|
|
66
66
|
function createBcjSparcDecoder(properties, unpackSize) {
|
|
67
67
|
return (0, _createBufferingDecoderts.default)(decodeBcjSparc, properties, unpackSize);
|
|
68
68
|
}
|
|
69
|
-
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (
|
|
69
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (let key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/BcjSparc.ts"],"sourcesContent":["// BCJ (SPARC) filter codec - converts SPARC branch instruction addresses\n// This filter makes SPARC executables more compressible by LZMA\n//\n// SPARC is big-endian. CALL instructions use 30-bit signed offsets.\n// The filter only transforms CALL instructions with specific byte patterns.\n//\n// Reference: https://github.com/kornelski/7z/blob/main/C/Bra.c\n\nimport { bufferFrom } from 'extract-base-iterator';\nimport type { Transform } from 'readable-stream';\nimport createBufferingDecoder from './createBufferingDecoder.ts';\n\n/**\n * Decode SPARC BCJ filtered data\n * Reverses the BCJ transformation by converting absolute addresses back to relative\n *\n * SPARC CALL instruction matching (big-endian):\n * - First byte 0x40 and (second byte & 0xC0) == 0x00, OR\n * - First byte 0x7F and (second byte & 0xC0) == 0xC0\n *\n * @param input - SPARC BCJ filtered data\n * @param _properties - Unused for SPARC BCJ\n * @param _unpackSize - Unused for SPARC BCJ\n * @returns Unfiltered data\n */\nexport function decodeBcjSparc(input: Buffer, _properties?: Buffer, _unpackSize?: number): Buffer {\n
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/BcjSparc.ts"],"sourcesContent":["// BCJ (SPARC) filter codec - converts SPARC branch instruction addresses\n// This filter makes SPARC executables more compressible by LZMA\n//\n// SPARC is big-endian. CALL instructions use 30-bit signed offsets.\n// The filter only transforms CALL instructions with specific byte patterns.\n//\n// Reference: https://github.com/kornelski/7z/blob/main/C/Bra.c\n\nimport { bufferFrom } from 'extract-base-iterator';\nimport type { Transform } from 'readable-stream';\nimport createBufferingDecoder from './createBufferingDecoder.ts';\n\n/**\n * Decode SPARC BCJ filtered data\n * Reverses the BCJ transformation by converting absolute addresses back to relative\n *\n * SPARC CALL instruction matching (big-endian):\n * - First byte 0x40 and (second byte & 0xC0) == 0x00, OR\n * - First byte 0x7F and (second byte & 0xC0) == 0xC0\n *\n * @param input - SPARC BCJ filtered data\n * @param _properties - Unused for SPARC BCJ\n * @param _unpackSize - Unused for SPARC BCJ\n * @returns Unfiltered data\n */\nexport function decodeBcjSparc(input: Buffer, _properties?: Buffer, _unpackSize?: number): Buffer {\n const output = bufferFrom(input); // Copy since we modify in place\n let pos = 0;\n\n // Process 4-byte aligned positions\n while (pos + 4 <= output.length) {\n const b0 = output[pos];\n const b1 = output[pos + 1];\n\n // Check for CALL instruction with specific byte patterns:\n // (b0 == 0x40 && (b1 & 0xC0) == 0x00) || (b0 == 0x7F && (b1 & 0xC0) == 0xC0)\n if ((b0 === 0x40 && (b1 & 0xc0) === 0x00) || (b0 === 0x7f && (b1 & 0xc0) === 0xc0)) {\n // Read 32-bit value (big-endian)\n let src = (b0 << 24) | (b1 << 16) | (output[pos + 2] << 8) | output[pos + 3];\n\n // Shift left by 2 (multiply by 4 for word addressing)\n src <<= 2;\n\n // Decoding: subtract position\n let dest = src - pos;\n\n // Shift right by 2\n dest >>>= 2;\n\n // Reconstruct with sign extension and opcode\n // (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) | (dest & 0x3FFFFF) | 0x40000000\n const signBit = (dest >>> 22) & 1;\n const signExtend = signBit ? 0x3fc00000 : 0;\n dest = signExtend | (dest & 0x3fffff) | 0x40000000;\n\n // Write back (big-endian)\n output[pos] = (dest >>> 24) & 0xff;\n output[pos + 1] = (dest >>> 16) & 0xff;\n output[pos + 2] = (dest >>> 8) & 0xff;\n output[pos + 3] = dest & 0xff;\n }\n\n pos += 4;\n }\n\n return output;\n}\n\n/**\n * Create a SPARC BCJ decoder Transform stream\n */\nexport function createBcjSparcDecoder(properties?: Buffer, unpackSize?: number): Transform {\n return createBufferingDecoder(decodeBcjSparc, properties, unpackSize);\n}\n"],"names":["createBcjSparcDecoder","decodeBcjSparc","input","_properties","_unpackSize","output","bufferFrom","pos","length","b0","b1","src","dest","signBit","signExtend","properties","unpackSize","createBufferingDecoder"],"mappings":"AAAA,yEAAyE;AACzE,gEAAgE;AAChE,EAAE;AACF,oEAAoE;AACpE,4EAA4E;AAC5E,EAAE;AACF,+DAA+D;;;;;;;;;;;;QAiE/CA;eAAAA;;QA9CAC;eAAAA;;;mCAjBW;+EAEQ;;;;;;AAe5B,SAASA,eAAeC,KAAa,EAAEC,WAAoB,EAAEC,WAAoB;IACtF,IAAMC,SAASC,IAAAA,+BAAU,EAACJ,QAAQ,gCAAgC;IAClE,IAAIK,MAAM;IAEV,mCAAmC;IACnC,MAAOA,MAAM,KAAKF,OAAOG,MAAM,CAAE;QAC/B,IAAMC,KAAKJ,MAAM,CAACE,IAAI;QACtB,IAAMG,KAAKL,MAAM,CAACE,MAAM,EAAE;QAE1B,0DAA0D;QAC1D,6EAA6E;QAC7E,IAAI,AAACE,OAAO,QAAQ,AAACC,CAAAA,KAAK,IAAG,MAAO,QAAUD,OAAO,QAAQ,AAACC,CAAAA,KAAK,IAAG,MAAO,MAAO;YAClF,iCAAiC;YACjC,IAAIC,MAAM,AAACF,MAAM,KAAOC,MAAM,KAAOL,MAAM,CAACE,MAAM,EAAE,IAAI,IAAKF,MAAM,CAACE,MAAM,EAAE;YAE5E,sDAAsD;YACtDI,QAAQ;YAER,8BAA8B;YAC9B,IAAIC,OAAOD,MAAMJ;YAEjB,mBAAmB;YACnBK,UAAU;YAEV,6CAA6C;YAC7C,mFAAmF;YACnF,IAAMC,UAAU,AAACD,SAAS,KAAM;YAChC,IAAME,aAAaD,UAAU,aAAa;YAC1CD,OAAOE,aAAcF,OAAO,WAAY;YAExC,0BAA0B;YAC1BP,MAAM,CAACE,IAAI,GAAG,AAACK,SAAS,KAAM;YAC9BP,MAAM,CAACE,MAAM,EAAE,GAAG,AAACK,SAAS,KAAM;YAClCP,MAAM,CAACE,MAAM,EAAE,GAAG,AAACK,SAAS,IAAK;YACjCP,MAAM,CAACE,MAAM,EAAE,GAAGK,OAAO;QAC3B;QAEAL,OAAO;IACT;IAEA,OAAOF;AACT;AAKO,SAASL,sBAAsBe,UAAmB,EAAEC,UAAmB;IAC5E,OAAOC,IAAAA,iCAAsB,EAAChB,gBAAgBc,YAAYC;AAC5D"}
|
|
@@ -38,4 +38,4 @@ function createCopyDecoder() {
|
|
|
38
38
|
function decodeCopy(input, _properties, _unpackSize) {
|
|
39
39
|
return input;
|
|
40
40
|
}
|
|
41
|
-
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (
|
|
41
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (let key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -33,4 +33,4 @@ function decodeDeflate(input, _properties, _unpackSize) {
|
|
|
33
33
|
function createDeflateDecoder(properties, unpackSize) {
|
|
34
34
|
return (0, _createBufferingDecoderts.default)(decodeDeflate, properties, unpackSize);
|
|
35
35
|
}
|
|
36
|
-
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (
|
|
36
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (let key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -52,4 +52,4 @@ function decodeDelta(input, properties, _unpackSize) {
|
|
|
52
52
|
function createDeltaDecoder(properties, unpackSize) {
|
|
53
53
|
return (0, _createBufferingDecoderts.default)(decodeDelta, properties, unpackSize);
|
|
54
54
|
}
|
|
55
|
-
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (
|
|
55
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (let key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/Delta.ts"],"sourcesContent":["// Delta filter codec - stores differences between consecutive bytes\n// Useful for data with gradual changes (images, audio, sensor data)\n//\n// The Delta filter stores the difference between each byte and the byte\n// N positions before it, where N is the \"distance\" parameter (default 1).\n// This makes data with regular patterns more compressible.\n\nimport { bufferFrom } from 'extract-base-iterator';\nimport type { Transform } from 'readable-stream';\nimport createBufferingDecoder from './createBufferingDecoder.ts';\n\n/**\n * Decode Delta filtered data\n * Reverses the delta transformation by adding previous values\n *\n * @param input - Delta filtered data\n * @param properties - Optional 1-byte properties (distance - 1)\n * @param _unpackSize - Unused for Delta\n * @returns Unfiltered data\n */\nexport function decodeDelta(input: Buffer, properties?: Buffer, _unpackSize?: number): Buffer {\n // Distance parameter: default is 1\n
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/Delta.ts"],"sourcesContent":["// Delta filter codec - stores differences between consecutive bytes\n// Useful for data with gradual changes (images, audio, sensor data)\n//\n// The Delta filter stores the difference between each byte and the byte\n// N positions before it, where N is the \"distance\" parameter (default 1).\n// This makes data with regular patterns more compressible.\n\nimport { bufferFrom } from 'extract-base-iterator';\nimport type { Transform } from 'readable-stream';\nimport createBufferingDecoder from './createBufferingDecoder.ts';\n\n/**\n * Decode Delta filtered data\n * Reverses the delta transformation by adding previous values\n *\n * @param input - Delta filtered data\n * @param properties - Optional 1-byte properties (distance - 1)\n * @param _unpackSize - Unused for Delta\n * @returns Unfiltered data\n */\nexport function decodeDelta(input: Buffer, properties?: Buffer, _unpackSize?: number): Buffer {\n // Distance parameter: default is 1\n let distance = 1;\n if (properties && properties.length >= 1) {\n // Properties byte contains (distance - 1)\n distance = properties[0] + 1;\n }\n\n const output = bufferFrom(input); // Copy since we modify in place\n\n // State buffer for multi-byte distance\n const state = new Array(distance);\n for (let i = 0; i < distance; i++) {\n state[i] = 0;\n }\n\n for (let j = 0; j < output.length; j++) {\n const idx = j % distance;\n state[idx] = (state[idx] + output[j]) & 0xff;\n output[j] = state[idx];\n }\n\n return output;\n}\n\n/**\n * Create a Delta decoder Transform stream\n */\nexport function createDeltaDecoder(properties?: Buffer, unpackSize?: number): Transform {\n return createBufferingDecoder(decodeDelta, properties, unpackSize);\n}\n"],"names":["createDeltaDecoder","decodeDelta","input","properties","_unpackSize","distance","length","output","bufferFrom","state","Array","i","j","idx","unpackSize","createBufferingDecoder"],"mappings":"AAAA,oEAAoE;AACpE,oEAAoE;AACpE,EAAE;AACF,wEAAwE;AACxE,0EAA0E;AAC1E,2DAA2D;;;;;;;;;;;;QA2C3CA;eAAAA;;QA5BAC;eAAAA;;;mCAbW;+EAEQ;;;;;;AAW5B,SAASA,YAAYC,KAAa,EAAEC,UAAmB,EAAEC,WAAoB;IAClF,mCAAmC;IACnC,IAAIC,WAAW;IACf,IAAIF,cAAcA,WAAWG,MAAM,IAAI,GAAG;QACxC,0CAA0C;QAC1CD,WAAWF,UAAU,CAAC,EAAE,GAAG;IAC7B;IAEA,IAAMI,SAASC,IAAAA,+BAAU,EAACN,QAAQ,gCAAgC;IAElE,uCAAuC;IACvC,IAAMO,QAAQ,IAAIC,MAAML;IACxB,IAAK,IAAIM,IAAI,GAAGA,IAAIN,UAAUM,IAAK;QACjCF,KAAK,CAACE,EAAE,GAAG;IACb;IAEA,IAAK,IAAIC,IAAI,GAAGA,IAAIL,OAAOD,MAAM,EAAEM,IAAK;QACtC,IAAMC,MAAMD,IAAIP;QAChBI,KAAK,CAACI,IAAI,GAAG,AAACJ,KAAK,CAACI,IAAI,GAAGN,MAAM,CAACK,EAAE,GAAI;QACxCL,MAAM,CAACK,EAAE,GAAGH,KAAK,CAACI,IAAI;IACxB;IAEA,OAAON;AACT;AAKO,SAASP,mBAAmBG,UAAmB,EAAEW,UAAmB;IACzE,OAAOC,IAAAA,iCAAsB,EAACd,aAAaE,YAAYW;AACzD"}
|
|
@@ -80,4 +80,4 @@ function createLzmaDecoder(properties, _unpackSize) {
|
|
|
80
80
|
// Fall back to buffering decoder with pure JS implementation
|
|
81
81
|
return (0, _createBufferingDecoderts.default)(decodeLzma, properties, _unpackSize);
|
|
82
82
|
}
|
|
83
|
-
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (
|
|
83
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (let key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/Lzma.ts"],"sourcesContent":["import Module from 'module';\n\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/Lzma.ts"],"sourcesContent":["import Module from 'module';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\n// LZMA codec - uses native lzma-native when available, falls back to lzma-purejs\n// LZMA properties in 7z are 5 bytes: 1 byte lc/lp/pb + 4 bytes dictionary size (little-endian)\n//\n// Native optimization: On Node.js 8+, lzma-native provides liblzma bindings\n// that decode LZMA1 streams natively for better performance.\n// Falls back to lzma-purejs for Node.js 0.8-7.x compatibility.\n\nimport type { Transform } from 'readable-stream';\nimport createBufferingDecoder from './createBufferingDecoder.ts';\nimport { createNativeLzma1Decoder, hasNativeLzma } from './lzmaCompat.ts';\nimport { createInputStream, createOutputStream } from './streams.ts';\n\n// Import vendored lzma-purejs - provides raw LZMA decoder (patched for LZMA2 support)\n// Path accounts for build output in dist/esm/sevenz/codecs/\nconst { LZMA } = _require('../../../../assets/lzma-purejs');\nconst LzmaDecoder = LZMA.Decoder;\n\n/**\n * Parse LZMA properties from 5-byte buffer\n * First byte: lc + lp*9 + pb*45\n * Next 4 bytes: dictionary size (little-endian)\n */\nfunction parseLzmaProperties(properties: Buffer): { lc: number; lp: number; pb: number; dictSize: number } {\n const propByte = properties[0];\n const lc = propByte % 9;\n const remainder = Math.floor(propByte / 9);\n const lp = remainder % 5;\n const pb = Math.floor(remainder / 5);\n const dictSize = properties.readUInt32LE(1);\n return { lc: lc, lp: lp, pb: pb, dictSize: dictSize };\n}\n\n/**\n * Decode LZMA compressed data to buffer\n *\n * @param input - LZMA compressed data\n * @param properties - Properties buffer (5 bytes: lc/lp/pb + dict size)\n * @param unpackSize - Expected output size (optional, -1 for unknown)\n * @returns Decompressed data\n */\nexport function decodeLzma(input: Buffer, properties?: Buffer, unpackSize?: number): Buffer {\n if (!properties || properties.length < 5) {\n throw new Error('LZMA requires 5-byte properties');\n }\n\n const decoder = new LzmaDecoder();\n\n // setDecoderProperties expects array-like with 5 bytes\n if (!decoder.setDecoderProperties(properties)) {\n throw new Error('Invalid LZMA properties');\n }\n\n const inStream = createInputStream(input, 0, input.length);\n\n // Use -1 for unknown size (decoder will use end marker)\n const size = typeof unpackSize === 'number' ? unpackSize : -1;\n\n // Pre-allocate output stream if size is known (memory optimization)\n const outStream = createOutputStream(size > 0 ? size : undefined);\n\n const success = decoder.code(inStream, outStream, size);\n if (!success) {\n throw new Error('LZMA decompression failed');\n }\n\n return outStream.toBuffer();\n}\n\n/**\n * Create an LZMA decoder Transform stream\n *\n * Uses native lzma-native when available for better performance,\n * falls back to lzma-purejs buffering decoder for Node.js 0.8+ compatibility.\n */\nexport function createLzmaDecoder(properties?: Buffer, _unpackSize?: number): Transform {\n // Try native decoder first (available on Node.js 8+ with lzma-native installed)\n if (hasNativeLzma && properties && properties.length >= 5) {\n const props = parseLzmaProperties(properties);\n const nativeDecoder = createNativeLzma1Decoder(props.lc, props.lp, props.pb, props.dictSize);\n if (nativeDecoder) {\n return nativeDecoder;\n }\n }\n\n // Fall back to buffering decoder with pure JS implementation\n return createBufferingDecoder(decodeLzma, properties, _unpackSize);\n}\n"],"names":["createLzmaDecoder","decodeLzma","_require","require","Module","createRequire","LZMA","LzmaDecoder","Decoder","parseLzmaProperties","properties","propByte","lc","remainder","Math","floor","lp","pb","dictSize","readUInt32LE","input","unpackSize","length","Error","decoder","setDecoderProperties","inStream","createInputStream","size","outStream","createOutputStream","undefined","success","code","toBuffer","_unpackSize","hasNativeLzma","props","nativeDecoder","createNativeLzma1Decoder","createBufferingDecoder"],"mappings":";;;;;;;;;;;QA8EgBA;eAAAA;;QAlCAC;eAAAA;;;6DA5CG;+EAYgB;4BACqB;yBACF;;;;;;AAZtD,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAc1F,sFAAsF;AACtF,4DAA4D;AAC5D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,EAACF,MAAMzB,EAAE,EAAEyB,MAAMrB,EAAE,EAAEqB,MAAMpB,EAAE,EAAEoB,MAAMnB,QAAQ;QAC3F,IAAIoB,eAAe;YACjB,OAAOA;QACT;IACF;IAEA,6DAA6D;IAC7D,OAAOE,IAAAA,iCAAsB,EAACvC,YAAYS,YAAYyB;AACxD"}
|
|
@@ -223,4 +223,4 @@ function createLzma2Decoder(properties, unpackSize) {
|
|
|
223
223
|
// Fall back to buffering decoder with pure JS implementation
|
|
224
224
|
return (0, _createBufferingDecoderts.default)(decodeLzma2, properties, unpackSize);
|
|
225
225
|
}
|
|
226
|
-
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (
|
|
226
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (let key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/Lzma2.ts"],"sourcesContent":["import Module from 'module';\n\nvar _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\n// LZMA2 codec - uses native lzma-native when available, falls back to lzma-purejs\n// LZMA2 is a container format that wraps LZMA chunks with framing\n//\n// LZMA2 format specification:\n// https://github.com/ulikunitz/xz/blob/master/doc/LZMA2.md\n//\n// Control byte values:\n// 0x00 = End of stream\n// 0x01 = Uncompressed chunk, dictionary reset\n// 0x02 = Uncompressed chunk, no dictionary reset\n// 0x80-0xFF = LZMA compressed chunk (bits encode reset flags and size)\n//\n// Native optimization: On Node.js 8+, lzma-native provides liblzma bindings\n// that decode LZMA2 streams natively for better performance.\n// Falls back to lzma-purejs for Node.js 0.8-7.x compatibility.\n\nimport { allocBufferUnsafe } from 'extract-base-iterator';\nimport type { Transform } from 'readable-stream';\nimport createBufferingDecoder from './createBufferingDecoder.ts';\nimport { createNativeLzma2Decoder, hasNativeLzma } from './lzmaCompat.ts';\nimport { createInputStream, createOutputStream } from './streams.ts';\n\n// Import vendored lzma-purejs - provides raw LZMA decoder (patched for LZMA2 support)\n// Path accounts for build output in dist/esm/sevenz/codecs/\nvar { LZMA } = _require('../../../../assets/lzma-purejs');\nvar LzmaDecoder = LZMA.Decoder;\n\n/**\n * Decode LZMA2 dictionary size from properties byte\n * Properties byte encodes dictionary size as: 2^(dictByte/2 + 12) or similar\n *\n * Per XZ spec, dictionary sizes are:\n * 0x00 = 4 KiB (2^12)\n * 0x01 = 6 KiB\n * 0x02 = 8 KiB (2^13)\n * ...\n * 0x28 = 1.5 GiB\n */\nfunction decodeDictionarySize(propByte: number): number {\n if (propByte > 40) {\n throw new Error(`Invalid LZMA2 dictionary size property: ${propByte}`);\n }\n if (propByte === 40) {\n // Max dictionary size: 4 GiB - 1\n return 0xffffffff;\n }\n // Dictionary size = 2 | (propByte & 1) << (propByte / 2 + 11)\n var base = 2 | (propByte & 1);\n var shift = Math.floor(propByte / 2) + 11;\n return base << shift;\n}\n\n/**\n * Decode LZMA2 compressed data to buffer\n *\n * @param input - LZMA2 compressed data\n * @param properties - Properties buffer (1 byte: dictionary size)\n * @param unpackSize - Expected output size (used for pre-allocation to reduce memory)\n * @returns Decompressed data\n */\nexport function decodeLzma2(input: Buffer, properties?: Buffer, unpackSize?: number): Buffer {\n if (!properties || properties.length < 1) {\n throw new Error('LZMA2 requires properties byte');\n }\n\n var dictSize = decodeDictionarySize(properties[0]);\n\n // Memory optimization: pre-allocate output buffer if size is known\n // This avoids double-memory during Buffer.concat\n var outputBuffer: Buffer | null = null;\n var outputPos = 0;\n var outputChunks: Buffer[] = [];\n\n if (unpackSize && unpackSize > 0) {\n outputBuffer = allocBufferUnsafe(unpackSize);\n }\n\n var offset = 0;\n\n // LZMA decoder instance - reused across chunks\n // The vendored decoder supports setSolid() for LZMA2 state preservation\n // The decoder also has _nowPos64 which tracks cumulative position for rep0 validation\n // and _prevByte which is used for literal decoder context selection\n var decoder = new LzmaDecoder() as InstanceType<typeof LzmaDecoder> & {\n setSolid: (solid: boolean) => void;\n _nowPos64: number;\n _prevByte: number;\n };\n decoder.setDictionarySize(dictSize);\n\n // Access internal _outWindow for dictionary management\n // We need to preserve dictionary state across LZMA2 chunks\n type OutWindowType = {\n _buffer: Buffer;\n _pos: number;\n _streamPos: number;\n _windowSize: number;\n init: (solid: boolean) => void;\n };\n var outWindow = (decoder as unknown as { _outWindow: OutWindowType })._outWindow;\n\n // Track current LZMA properties (lc, lp, pb)\n var propsSet = false;\n\n while (offset < input.length) {\n var control = input[offset++];\n\n if (control === 0x00) {\n // End of LZMA2 stream\n break;\n }\n\n if (control === 0x01 || control === 0x02) {\n // Uncompressed chunk\n // 0x01 = dictionary reset + uncompressed\n // 0x02 = uncompressed (no reset)\n\n // Handle dictionary reset for 0x01\n if (control === 0x01) {\n outWindow._pos = 0;\n outWindow._streamPos = 0;\n decoder._nowPos64 = 0;\n }\n\n if (offset + 2 > input.length) {\n throw new Error('Truncated LZMA2 uncompressed chunk header');\n }\n\n // Size is big-endian, 16-bit, value + 1\n var uncompSize = ((input[offset] << 8) | input[offset + 1]) + 1;\n offset += 2;\n\n if (offset + uncompSize > input.length) {\n throw new Error('Truncated LZMA2 uncompressed data');\n }\n\n // Get the uncompressed data\n var uncompData = input.slice(offset, offset + uncompSize);\n\n // Copy uncompressed data to output\n if (outputBuffer) {\n uncompData.copy(outputBuffer, outputPos);\n outputPos += uncompData.length;\n } else {\n outputChunks?.push(uncompData);\n }\n\n // Also update the decoder's internal dictionary so subsequent LZMA chunks can reference it\n // The decoder needs to track this data for LZ77 back-references\n // We write directly to _buffer to avoid flush() which requires _stream to be set\n // We must also update _streamPos to match _pos so that flush() doesn't try to write\n for (var i = 0; i < uncompData.length; i++) {\n outWindow._buffer[outWindow._pos++] = uncompData[i];\n // Handle circular buffer wrap-around\n if (outWindow._pos >= outWindow._windowSize) {\n outWindow._pos = 0;\n }\n }\n // Keep _streamPos in sync so flush() doesn't try to write these bytes\n // (they're already in our output buffer)\n outWindow._streamPos = outWindow._pos;\n\n // Update decoder's cumulative position so subsequent LZMA chunks have correct rep0 validation\n decoder._nowPos64 += uncompSize;\n\n // Update prevByte for literal decoder context in subsequent LZMA chunks\n decoder._prevByte = uncompData[uncompData.length - 1];\n\n offset += uncompSize;\n } else if (control >= 0x80) {\n // LZMA compressed chunk\n // Control byte format (bits 7-0):\n // Bit 7: always 1 for LZMA chunk\n // Bits 6-5: reset mode (00=nothing, 01=state, 10=state+props, 11=all)\n // Bits 4-0: high 5 bits of uncompressed size - 1\n\n // Control byte ranges (based on bits 6-5):\n // 0x80-0x9F (00): no reset - continue existing state (solid mode)\n // 0xA0-0xBF (01): reset state only\n // 0xC0-0xDF (10): reset state + new properties\n // 0xE0-0xFF (11): reset dictionary + state + new properties\n var resetState = control >= 0xa0;\n var newProps = control >= 0xc0;\n var dictReset = control >= 0xe0;\n var useSolidMode = !resetState;\n\n // Handle dictionary reset for control bytes 0xE0-0xFF\n if (dictReset) {\n outWindow._pos = 0;\n outWindow._streamPos = 0;\n }\n\n if (offset + 4 > input.length) {\n throw new Error('Truncated LZMA2 LZMA chunk header');\n }\n\n // Uncompressed size: 5 bits from control + 16 bits from next 2 bytes + 1\n var uncompHigh = control & 0x1f;\n var uncompSize2 = ((uncompHigh << 16) | (input[offset] << 8) | input[offset + 1]) + 1;\n offset += 2;\n\n // Compressed size: 16 bits + 1\n var compSize = ((input[offset] << 8) | input[offset + 1]) + 1;\n offset += 2;\n\n // If new properties, read 1-byte LZMA properties\n if (newProps) {\n if (offset >= input.length) {\n throw new Error('Truncated LZMA2 properties byte');\n }\n var propsByte = input[offset++];\n\n // Properties byte: pb * 45 + lp * 9 + lc\n // where pb, lp, lc are LZMA parameters\n var lc = propsByte % 9;\n var remainder = Math.floor(propsByte / 9);\n var lp = remainder % 5;\n var pb = Math.floor(remainder / 5);\n\n if (!decoder.setLcLpPb(lc, lp, pb)) {\n throw new Error(`Invalid LZMA properties: lc=${lc} lp=${lp} pb=${pb}`);\n }\n propsSet = true;\n }\n\n if (!propsSet) {\n throw new Error('LZMA chunk without properties');\n }\n\n if (offset + compSize > input.length) {\n throw new Error('Truncated LZMA2 compressed data');\n }\n\n // Decode LZMA chunk\n var inStream = createInputStream(input, offset, compSize);\n var outStream = createOutputStream(uncompSize2); // Pre-allocate for memory efficiency\n\n // Set solid mode based on control byte - this preserves state across code() calls\n decoder.setSolid(useSolidMode);\n\n // Decode the chunk\n var success = decoder.code(inStream, outStream, uncompSize2);\n if (!success) {\n throw new Error('LZMA decompression failed');\n }\n\n var chunkOutput = outStream.toBuffer();\n if (outputBuffer) {\n chunkOutput.copy(outputBuffer, outputPos);\n outputPos += chunkOutput.length;\n } else {\n outputChunks?.push(chunkOutput);\n }\n\n offset += compSize;\n } else {\n throw new Error(`Invalid LZMA2 control byte: 0x${control.toString(16)}`);\n }\n }\n\n // Return pre-allocated buffer or concatenated chunks\n if (outputBuffer) {\n // Return only the used portion if we didn't fill the buffer\n return outputPos < outputBuffer.length ? outputBuffer.slice(0, outputPos) : outputBuffer;\n }\n return Buffer.concat(outputChunks);\n}\n\n/**\n * Create an LZMA2 decoder Transform stream\n *\n * Uses native lzma-native when available for better performance,\n * falls back to lzma-purejs buffering decoder for Node.js 0.8+ compatibility.\n */\nexport function createLzma2Decoder(properties?: Buffer, unpackSize?: number): Transform {\n // Try native decoder first (available on Node.js 8+ with lzma-native installed)\n if (hasNativeLzma && properties && properties.length >= 1) {\n var dictSize = decodeDictionarySize(properties[0]);\n var nativeDecoder = createNativeLzma2Decoder(dictSize);\n if (nativeDecoder) {\n return nativeDecoder;\n }\n }\n\n // Fall back to buffering decoder with pure JS implementation\n return createBufferingDecoder(decodeLzma2, properties, unpackSize);\n}\n"],"names":["createLzma2Decoder","decodeLzma2","_require","require","Module","createRequire","LZMA","LzmaDecoder","Decoder","decodeDictionarySize","propByte","Error","base","shift","Math","floor","input","properties","unpackSize","length","dictSize","outputBuffer","outputPos","outputChunks","allocBufferUnsafe","offset","decoder","setDictionarySize","outWindow","_outWindow","propsSet","control","_pos","_streamPos","_nowPos64","uncompSize","uncompData","slice","copy","push","i","_buffer","_windowSize","_prevByte","resetState","newProps","dictReset","useSolidMode","uncompHigh","uncompSize2","compSize","propsByte","lc","remainder","lp","pb","setLcLpPb","inStream","createInputStream","outStream","createOutputStream","setSolid","success","code","chunkOutput","toBuffer","toString","Buffer","concat","hasNativeLzma","nativeDecoder","createNativeLzma2Decoder","createBufferingDecoder"],"mappings":";;;;;;;;;;;QAsRgBA;eAAAA;;QAtNAC;eAAAA;;;6DAhEG;mCAoBe;+EAEC;4BACqB;yBACF;;;;;;AAtBtD,IAAIC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAwBxF,sFAAsF;AACtF,4DAA4D;AAC5D,IAAI,AAAEG,OAASJ,SAAS,kCAAlBI;AACN,IAAIC,cAAcD,KAAKE,OAAO;AAE9B;;;;;;;;;;CAUC,GACD,SAASC,qBAAqBC,QAAgB;IAC5C,IAAIA,WAAW,IAAI;QACjB,MAAM,IAAIC,MAAM,AAAC,2CAAmD,OAATD;IAC7D;IACA,IAAIA,aAAa,IAAI;QACnB,iCAAiC;QACjC,OAAO;IACT;IACA,8DAA8D;IAC9D,IAAIE,OAAO,IAAKF,WAAW;IAC3B,IAAIG,QAAQC,KAAKC,KAAK,CAACL,WAAW,KAAK;IACvC,OAAOE,QAAQC;AACjB;AAUO,SAASZ,YAAYe,KAAa,EAAEC,UAAmB,EAAEC,UAAmB;IACjF,IAAI,CAACD,cAAcA,WAAWE,MAAM,GAAG,GAAG;QACxC,MAAM,IAAIR,MAAM;IAClB;IAEA,IAAIS,WAAWX,qBAAqBQ,UAAU,CAAC,EAAE;IAEjD,mEAAmE;IACnE,iDAAiD;IACjD,IAAII,eAA8B;IAClC,IAAIC,YAAY;IAChB,IAAIC,eAAyB,EAAE;IAE/B,IAAIL,cA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pE;IACF;IAEA,qDAAqD;IACrD,IAAI7C,cAAc;QAChB,4DAA4D;QAC5D,OAAOC,YAAYD,aAAaF,MAAM,GAAGE,aAAagB,KAAK,CAAC,GAAGf,aAAaD;IAC9E;IACA,OAAO8C,OAAOC,MAAM,CAAC7C;AACvB;AAQO,SAASvB,mBAAmBiB,UAAmB,EAAEC,UAAmB;IACzE,gFAAgF;IAChF,IAAImD,2BAAa,IAAIpD,cAAcA,WAAWE,MAAM,IAAI,GAAG;QACzD,IAAIC,WAAWX,qBAAqBQ,UAAU,CAAC,EAAE;QACjD,IAAIqD,gBAAgBC,IAAAA,sCAAwB,EAACnD;QAC7C,IAAIkD,eAAe;YACjB,OAAOA;QACT;IACF;IAEA,6DAA6D;IAC7D,OAAOE,IAAAA,iCAAsB,EAACvE,aAAagB,YAAYC;AACzD"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/Lzma2.ts"],"sourcesContent":["import Module from 'module';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\n// LZMA2 codec - uses native lzma-native when available, falls back to lzma-purejs\n// LZMA2 is a container format that wraps LZMA chunks with framing\n//\n// LZMA2 format specification:\n// https://github.com/ulikunitz/xz/blob/master/doc/LZMA2.md\n//\n// Control byte values:\n// 0x00 = End of stream\n// 0x01 = Uncompressed chunk, dictionary reset\n// 0x02 = Uncompressed chunk, no dictionary reset\n// 0x80-0xFF = LZMA compressed chunk (bits encode reset flags and size)\n//\n// Native optimization: On Node.js 8+, lzma-native provides liblzma bindings\n// that decode LZMA2 streams natively for better performance.\n// Falls back to lzma-purejs for Node.js 0.8-7.x compatibility.\n\nimport { allocBufferUnsafe } from 'extract-base-iterator';\nimport type { Transform } from 'readable-stream';\nimport createBufferingDecoder from './createBufferingDecoder.ts';\nimport { createNativeLzma2Decoder, hasNativeLzma } from './lzmaCompat.ts';\nimport { createInputStream, createOutputStream } from './streams.ts';\n\n// Import vendored lzma-purejs - provides raw LZMA decoder (patched for LZMA2 support)\n// Path accounts for build output in dist/esm/sevenz/codecs/\nconst { LZMA } = _require('../../../../assets/lzma-purejs');\nconst LzmaDecoder = LZMA.Decoder;\n\n/**\n * Decode LZMA2 dictionary size from properties byte\n * Properties byte encodes dictionary size as: 2^(dictByte/2 + 12) or similar\n *\n * Per XZ spec, dictionary sizes are:\n * 0x00 = 4 KiB (2^12)\n * 0x01 = 6 KiB\n * 0x02 = 8 KiB (2^13)\n * ...\n * 0x28 = 1.5 GiB\n */\nfunction decodeDictionarySize(propByte: number): number {\n if (propByte > 40) {\n throw new Error(`Invalid LZMA2 dictionary size property: ${propByte}`);\n }\n if (propByte === 40) {\n // Max dictionary size: 4 GiB - 1\n return 0xffffffff;\n }\n // Dictionary size = 2 | (propByte & 1) << (propByte / 2 + 11)\n const base = 2 | (propByte & 1);\n const shift = Math.floor(propByte / 2) + 11;\n return base << shift;\n}\n\n/**\n * Decode LZMA2 compressed data to buffer\n *\n * @param input - LZMA2 compressed data\n * @param properties - Properties buffer (1 byte: dictionary size)\n * @param unpackSize - Expected output size (used for pre-allocation to reduce memory)\n * @returns Decompressed data\n */\nexport function decodeLzma2(input: Buffer, properties?: Buffer, unpackSize?: number): Buffer {\n if (!properties || properties.length < 1) {\n throw new Error('LZMA2 requires properties byte');\n }\n\n const dictSize = decodeDictionarySize(properties[0]);\n\n // Memory optimization: pre-allocate output buffer if size is known\n // This avoids double-memory during Buffer.concat\n let outputBuffer: Buffer | null = null;\n let outputPos = 0;\n const outputChunks: Buffer[] = [];\n\n if (unpackSize && unpackSize > 0) {\n outputBuffer = allocBufferUnsafe(unpackSize);\n }\n\n let offset = 0;\n\n // LZMA decoder instance - reused across chunks\n // The vendored decoder supports setSolid() for LZMA2 state preservation\n // The decoder also has _nowPos64 which tracks cumulative position for rep0 validation\n // and _prevByte which is used for literal decoder context selection\n const decoder = new LzmaDecoder() as InstanceType<typeof LzmaDecoder> & {\n setSolid: (solid: boolean) => void;\n _nowPos64: number;\n _prevByte: number;\n };\n decoder.setDictionarySize(dictSize);\n\n // Access internal _outWindow for dictionary management\n // We need to preserve dictionary state across LZMA2 chunks\n type OutWindowType = {\n _buffer: Buffer;\n _pos: number;\n _streamPos: number;\n _windowSize: number;\n init: (solid: boolean) => void;\n };\n const outWindow = (decoder as unknown as { _outWindow: OutWindowType })._outWindow;\n\n // Track current LZMA properties (lc, lp, pb)\n let propsSet = false;\n\n while (offset < input.length) {\n const control = input[offset++];\n\n if (control === 0x00) {\n // End of LZMA2 stream\n break;\n }\n\n if (control === 0x01 || control === 0x02) {\n // Uncompressed chunk\n // 0x01 = dictionary reset + uncompressed\n // 0x02 = uncompressed (no reset)\n\n // Handle dictionary reset for 0x01\n if (control === 0x01) {\n outWindow._pos = 0;\n outWindow._streamPos = 0;\n decoder._nowPos64 = 0;\n }\n\n if (offset + 2 > input.length) {\n throw new Error('Truncated LZMA2 uncompressed chunk header');\n }\n\n // Size is big-endian, 16-bit, value + 1\n const uncompSize = ((input[offset] << 8) | input[offset + 1]) + 1;\n offset += 2;\n\n if (offset + uncompSize > input.length) {\n throw new Error('Truncated LZMA2 uncompressed data');\n }\n\n // Get the uncompressed data\n const uncompData = input.slice(offset, offset + uncompSize);\n\n // Copy uncompressed data to output\n if (outputBuffer) {\n uncompData.copy(outputBuffer, outputPos);\n outputPos += uncompData.length;\n } else {\n outputChunks?.push(uncompData);\n }\n\n // Also update the decoder's internal dictionary so subsequent LZMA chunks can reference it\n // The decoder needs to track this data for LZ77 back-references\n // We write directly to _buffer to avoid flush() which requires _stream to be set\n // We must also update _streamPos to match _pos so that flush() doesn't try to write\n for (let i = 0; i < uncompData.length; i++) {\n outWindow._buffer[outWindow._pos++] = uncompData[i];\n // Handle circular buffer wrap-around\n if (outWindow._pos >= outWindow._windowSize) {\n outWindow._pos = 0;\n }\n }\n // Keep _streamPos in sync so flush() doesn't try to write these bytes\n // (they're already in our output buffer)\n outWindow._streamPos = outWindow._pos;\n\n // Update decoder's cumulative position so subsequent LZMA chunks have correct rep0 validation\n decoder._nowPos64 += uncompSize;\n\n // Update prevByte for literal decoder context in subsequent LZMA chunks\n decoder._prevByte = uncompData[uncompData.length - 1];\n\n offset += uncompSize;\n } else if (control >= 0x80) {\n // LZMA compressed chunk\n // Control byte format (bits 7-0):\n // Bit 7: always 1 for LZMA chunk\n // Bits 6-5: reset mode (00=nothing, 01=state, 10=state+props, 11=all)\n // Bits 4-0: high 5 bits of uncompressed size - 1\n\n // Control byte ranges (based on bits 6-5):\n // 0x80-0x9F (00): no reset - continue existing state (solid mode)\n // 0xA0-0xBF (01): reset state only\n // 0xC0-0xDF (10): reset state + new properties\n // 0xE0-0xFF (11): reset dictionary + state + new properties\n const resetState = control >= 0xa0;\n const newProps = control >= 0xc0;\n const dictReset = control >= 0xe0;\n const useSolidMode = !resetState;\n\n // Handle dictionary reset for control bytes 0xE0-0xFF\n if (dictReset) {\n outWindow._pos = 0;\n outWindow._streamPos = 0;\n }\n\n if (offset + 4 > input.length) {\n throw new Error('Truncated LZMA2 LZMA chunk header');\n }\n\n // Uncompressed size: 5 bits from control + 16 bits from next 2 bytes + 1\n const uncompHigh = control & 0x1f;\n const uncompSize2 = ((uncompHigh << 16) | (input[offset] << 8) | input[offset + 1]) + 1;\n offset += 2;\n\n // Compressed size: 16 bits + 1\n const compSize = ((input[offset] << 8) | input[offset + 1]) + 1;\n offset += 2;\n\n // If new properties, read 1-byte LZMA properties\n if (newProps) {\n if (offset >= input.length) {\n throw new Error('Truncated LZMA2 properties byte');\n }\n const propsByte = input[offset++];\n\n // Properties byte: pb * 45 + lp * 9 + lc\n // where pb, lp, lc are LZMA parameters\n const lc = propsByte % 9;\n const remainder = Math.floor(propsByte / 9);\n const lp = remainder % 5;\n const pb = Math.floor(remainder / 5);\n\n if (!decoder.setLcLpPb(lc, lp, pb)) {\n throw new Error(`Invalid LZMA properties: lc=${lc} lp=${lp} pb=${pb}`);\n }\n propsSet = true;\n }\n\n if (!propsSet) {\n throw new Error('LZMA chunk without properties');\n }\n\n if (offset + compSize > input.length) {\n throw new Error('Truncated LZMA2 compressed data');\n }\n\n // Decode LZMA chunk\n const inStream = createInputStream(input, offset, compSize);\n const outStream = createOutputStream(uncompSize2); // Pre-allocate for memory efficiency\n\n // Set solid mode based on control byte - this preserves state across code() calls\n decoder.setSolid(useSolidMode);\n\n // Decode the chunk\n const success = decoder.code(inStream, outStream, uncompSize2);\n if (!success) {\n throw new Error('LZMA decompression failed');\n }\n\n const chunkOutput = outStream.toBuffer();\n if (outputBuffer) {\n chunkOutput.copy(outputBuffer, outputPos);\n outputPos += chunkOutput.length;\n } else {\n outputChunks?.push(chunkOutput);\n }\n\n offset += compSize;\n } else {\n throw new Error(`Invalid LZMA2 control byte: 0x${control.toString(16)}`);\n }\n }\n\n // Return pre-allocated buffer or concatenated chunks\n if (outputBuffer) {\n // Return only the used portion if we didn't fill the buffer\n return outputPos < outputBuffer.length ? outputBuffer.slice(0, outputPos) : outputBuffer;\n }\n return Buffer.concat(outputChunks);\n}\n\n/**\n * Create an LZMA2 decoder Transform stream\n *\n * Uses native lzma-native when available for better performance,\n * falls back to lzma-purejs buffering decoder for Node.js 0.8+ compatibility.\n */\nexport function createLzma2Decoder(properties?: Buffer, unpackSize?: number): Transform {\n // Try native decoder first (available on Node.js 8+ with lzma-native installed)\n if (hasNativeLzma && properties && properties.length >= 1) {\n const dictSize = decodeDictionarySize(properties[0]);\n const nativeDecoder = createNativeLzma2Decoder(dictSize);\n if (nativeDecoder) {\n return nativeDecoder;\n }\n }\n\n // Fall back to buffering decoder with pure JS implementation\n return createBufferingDecoder(decodeLzma2, properties, unpackSize);\n}\n"],"names":["createLzma2Decoder","decodeLzma2","_require","require","Module","createRequire","LZMA","LzmaDecoder","Decoder","decodeDictionarySize","propByte","Error","base","shift","Math","floor","input","properties","unpackSize","length","dictSize","outputBuffer","outputPos","outputChunks","allocBufferUnsafe","offset","decoder","setDictionarySize","outWindow","_outWindow","propsSet","control","_pos","_streamPos","_nowPos64","uncompSize","uncompData","slice","copy","push","i","_buffer","_windowSize","_prevByte","resetState","newProps","dictReset","useSolidMode","uncompHigh","uncompSize2","compSize","propsByte","lc","remainder","lp","pb","setLcLpPb","inStream","createInputStream","outStream","createOutputStream","setSolid","success","code","chunkOutput","toBuffer","toString","Buffer","concat","hasNativeLzma","nativeDecoder","createNativeLzma2Decoder","createBufferingDecoder"],"mappings":";;;;;;;;;;;QAsRgBA;eAAAA;;QAtNAC;eAAAA;;;6DAhEG;mCAoBe;+EAEC;4BACqB;yBACF;;;;;;AAtBtD,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAwB1F,sFAAsF;AACtF,4DAA4D;AAC5D,IAAM,AAAEG,OAASJ,SAAS,kCAAlBI;AACR,IAAMC,cAAcD,KAAKE,OAAO;AAEhC;;;;;;;;;;CAUC,GACD,SAASC,qBAAqBC,QAAgB;IAC5C,IAAIA,WAAW,IAAI;QACjB,MAAM,IAAIC,MAAM,AAAC,2CAAmD,OAATD;IAC7D;IACA,IAAIA,aAAa,IAAI;QACnB,iCAAiC;QACjC,OAAO;IACT;IACA,8DAA8D;IAC9D,IAAME,OAAO,IAAKF,WAAW;IAC7B,IAAMG,QAAQC,KAAKC,KAAK,CAACL,WAAW,KAAK;IACzC,OAAOE,QAAQC;AACjB;AAUO,SAASZ,YAAYe,KAAa,EAAEC,UAAmB,EAAEC,UAAmB;IACjF,IAAI,CAACD,cAAcA,WAAWE,MAAM,GAAG,GAAG;QACxC,MAAM,IAAIR,MAAM;IAClB;IAEA,IAAMS,WAAWX,qBAAqBQ,UAAU,CAAC,EAAE;IAEnD,mEAAmE;IACnE,iDAAiD;IACjD,IAAII,eAA8B;IAClC,IAAIC,YAAY;IAChB,IAAMC,eAAyB,EAAE;IAEjC,IAAIL,cAAcA,aAAa,GAAG;QAChCG,eAAeG,IAAAA,sCAAiB,EAACN;IACnC;IAEA,IAAIO,SAAS;IAEb,+CAA+C;I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AAagB,KAAK,CAAC,GAAGf,aAAaD;IAC9E;IACA,OAAO8C,OAAOC,MAAM,CAAC7C;AACvB;AAQO,SAASvB,mBAAmBiB,UAAmB,EAAEC,UAAmB;IACzE,gFAAgF;IAChF,IAAImD,2BAAa,IAAIpD,cAAcA,WAAWE,MAAM,IAAI,GAAG;QACzD,IAAMC,WAAWX,qBAAqBQ,UAAU,CAAC,EAAE;QACnD,IAAMqD,gBAAgBC,IAAAA,sCAAwB,EAACnD;QAC/C,IAAIkD,eAAe;YACjB,OAAOA;QACT;IACF;IAEA,6DAA6D;IAC7D,OAAOE,IAAAA,iCAAsB,EAACvE,aAAagB,YAAYC;AACzD"}
|
|
@@ -46,4 +46,4 @@ function createBufferingDecoder(decodeFn, properties, unpackSize) {
|
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (
|
|
49
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (let key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/createBufferingDecoder.ts"],"sourcesContent":["// Helper to create a Transform stream that buffers all input before decoding\n// Used by codecs that need the full input before decompression (LZMA, LZMA2, BZip2, etc.)\n\nimport Stream from 'stream';\n\n// Use native streams when available, readable-stream only for Node 0.x\nconst major = +process.versions.node.split('.')[0];\nlet Transform: typeof Stream.Transform;\nif (major > 0) {\n Transform = Stream.Transform;\n} else {\n Transform = require('readable-stream').Transform;\n}\ntype TransformCallback = (error?: Error | null, data?: Buffer) => void;\n\nexport type DecodeFn = (input: Buffer, properties?: Buffer, unpackSize?: number) => Buffer;\n\n/**\n * Create a Transform stream that buffers all input, then decodes in flush\n * This is the common pattern for codecs that can't stream (need full input)\n */\nexport default function createBufferingDecoder(decodeFn: DecodeFn, properties?: Buffer, unpackSize?: number): Stream.Transform {\n
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/createBufferingDecoder.ts"],"sourcesContent":["// Helper to create a Transform stream that buffers all input before decoding\n// Used by codecs that need the full input before decompression (LZMA, LZMA2, BZip2, etc.)\n\nimport Stream from 'stream';\n\n// Use native streams when available, readable-stream only for Node 0.x\nconst major = +process.versions.node.split('.')[0];\nlet Transform: typeof Stream.Transform;\nif (major > 0) {\n Transform = Stream.Transform;\n} else {\n Transform = require('readable-stream').Transform;\n}\ntype TransformCallback = (error?: Error | null, data?: Buffer) => void;\n\nexport type DecodeFn = (input: Buffer, properties?: Buffer, unpackSize?: number) => Buffer;\n\n/**\n * Create a Transform stream that buffers all input, then decodes in flush\n * This is the common pattern for codecs that can't stream (need full input)\n */\nexport default function createBufferingDecoder(decodeFn: DecodeFn, properties?: Buffer, unpackSize?: number): Stream.Transform {\n const chunks: Buffer[] = [];\n\n return new Transform({\n transform: (chunk: Buffer, _encoding: string, callback: TransformCallback) => {\n chunks.push(chunk);\n callback();\n },\n flush: function (callback: TransformCallback) {\n try {\n const input = Buffer.concat(chunks);\n const output = decodeFn(input, properties, unpackSize);\n this.push(output);\n callback();\n } catch (err) {\n callback(err as Error);\n }\n },\n });\n}\n"],"names":["createBufferingDecoder","major","process","versions","node","split","Transform","Stream","require","decodeFn","properties","unpackSize","chunks","transform","chunk","_encoding","callback","push","flush","input","Buffer","concat","output","err"],"mappings":"AAAA,6EAA6E;AAC7E,0FAA0F;;;;;+BAgB1F;;;CAGC,GACD;;;eAAwBA;;;6DAlBL;;;;;;AAEnB,uEAAuE;AACvE,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAIC;AACJ,IAAIL,QAAQ,GAAG;IACbK,YAAYC,eAAM,CAACD,SAAS;AAC9B,OAAO;IACLA,YAAYE,QAAQ,mBAAmBF,SAAS;AAClD;AASe,SAASN,uBAAuBS,QAAkB,EAAEC,UAAmB,EAAEC,UAAmB;IACzG,IAAMC,SAAmB,EAAE;IAE3B,OAAO,IAAIN,UAAU;QACnBO,WAAW,SAACC,OAAeC,WAAmBC;YAC5CJ,OAAOK,IAAI,CAACH;YACZE;QACF;QACAE,OAAO,SAAPA,MAAiBF,QAA2B;YAC1C,IAAI;gBACF,IAAMG,QAAQC,OAAOC,MAAM,CAACT;gBAC5B,IAAMU,SAASb,SAASU,OAAOT,YAAYC;gBAC3C,IAAI,CAACM,IAAI,CAACK;gBACVN;YACF,EAAE,OAAOO,KAAK;gBACZP,SAASO;YACX;QACF;IACF;AACF"}
|
|
@@ -185,4 +185,4 @@ registerCodec(_constantsts.CodecId.BCJ2, {
|
|
|
185
185
|
decode: _Bcj2ts.decodeBcj2,
|
|
186
186
|
createDecoder: _Bcj2ts.createBcj2Decoder
|
|
187
187
|
}); // Note: PPMd codec is not implemented. See FUTURE_ENHANCEMENTS.md
|
|
188
|
-
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (
|
|
188
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (let key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/index.ts"],"sourcesContent":["// Codec registry for 7z decompression\n// Each codec provides a decode function and optionally a streaming decoder\n\nimport type { Transform } from 'readable-stream';\nimport { CodecId, createCodedError, ErrorCode } from '../constants.ts';\nimport { createAesDecoder, decodeAes, getPassword, setPassword } from './Aes.ts';\nimport { createBcjDecoder, decodeBcj } from './Bcj.ts';\nimport { createBcj2Decoder, decodeBcj2, decodeBcj2Multi } from './Bcj2.ts';\nimport { createBcjArmDecoder, decodeBcjArm } from './BcjArm.ts';\nimport { createBcjArm64Decoder, decodeBcjArm64 } from './BcjArm64.ts';\nimport { createBcjArmtDecoder, decodeBcjArmt } from './BcjArmt.ts';\nimport { createBcjIa64Decoder, decodeBcjIa64 } from './BcjIa64.ts';\nimport { createBcjPpcDecoder, decodeBcjPpc } from './BcjPpc.ts';\nimport { createBcjSparcDecoder, decodeBcjSparc } from './BcjSparc.ts';\nimport { createBzip2Decoder, decodeBzip2 } from './BZip2.ts';\nimport { createCopyDecoder, decodeCopy } from './Copy.ts';\nimport { createDeflateDecoder, decodeDeflate } from './Deflate.ts';\nimport { createDeltaDecoder, decodeDelta } from './Delta.ts';\nimport { createLzmaDecoder, decodeLzma } from './Lzma.ts';\nimport { createLzma2Decoder, decodeLzma2 } from './Lzma2.ts';\n\n// Re-export password functions for API access\nexport { getPassword, setPassword };\n\nexport interface Codec {\n decode: (input: Buffer, properties?: Buffer, unpackSize?: number) => Buffer;\n createDecoder: (properties?: Buffer, unpackSize?: number) => Transform;\n}\n\n// Registry of supported codecs\nvar codecs: { [key: string]: Codec } = {};\n\n/**\n * Convert codec ID bytes to a string key\n */\nfunction codecIdToKey(id: number[]): string {\n var parts: string[] = [];\n for (var i = 0; i < id.length; i++) {\n parts.push(id[i].toString(16).toUpperCase());\n }\n return parts.join('-');\n}\n\n/**\n * Check if two codec IDs match\n */\nfunction codecIdEquals(a: number[], b: number[]): boolean {\n if (a.length !== b.length) return false;\n for (var i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n}\n\n/**\n * Register a codec\n */\nexport function registerCodec(id: number[], codec: Codec): void {\n codecs[codecIdToKey(id)] = codec;\n}\n\n/**\n * Get a codec by ID\n * @throws Error if codec is not supported\n */\nexport function getCodec(id: number[]): Codec {\n var key = codecIdToKey(id);\n var codec = codecs[key];\n if (!codec) {\n throw createCodedError(`Unsupported codec: ${key}`, ErrorCode.UNSUPPORTED_CODEC);\n }\n return codec;\n}\n\n/**\n * Check if a codec is supported\n */\nexport function isCodecSupported(id: number[]): boolean {\n return codecs[codecIdToKey(id)] !== undefined;\n}\n\n/**\n * Get human-readable codec name\n */\nexport function getCodecName(id: number[]): string {\n if (codecIdEquals(id, CodecId.COPY)) return 'Copy';\n if (codecIdEquals(id, CodecId.LZMA)) return 'LZMA';\n if (codecIdEquals(id, CodecId.LZMA2)) return 'LZMA2';\n if (codecIdEquals(id, CodecId.BCJ_X86)) return 'BCJ (x86)';\n if (codecIdEquals(id, CodecId.BCJ_ARM)) return 'BCJ (ARM)';\n if (codecIdEquals(id, CodecId.BCJ_ARMT)) return 'BCJ (ARM Thumb)';\n if (codecIdEquals(id, CodecId.BCJ_ARM64)) return 'BCJ (ARM64)';\n if (codecIdEquals(id, CodecId.BCJ_PPC)) return 'BCJ (PowerPC)';\n if (codecIdEquals(id, CodecId.BCJ_IA64)) return 'BCJ (IA64)';\n if (codecIdEquals(id, CodecId.BCJ_SPARC)) return 'BCJ (SPARC)';\n if (codecIdEquals(id, CodecId.BCJ2)) return 'BCJ2';\n if (codecIdEquals(id, CodecId.PPMD)) return 'PPMd';\n if (codecIdEquals(id, CodecId.DELTA)) return 'Delta';\n if (codecIdEquals(id, CodecId.DEFLATE)) return 'Deflate';\n if (codecIdEquals(id, CodecId.BZIP2)) return 'BZip2';\n if (codecIdEquals(id, CodecId.AES)) return 'AES-256';\n return `Unknown (${codecIdToKey(id)})`;\n}\n\n/**\n * Check if a codec ID matches BCJ2\n */\nexport function isBcj2Codec(id: number[]): boolean {\n return codecIdEquals(id, CodecId.BCJ2);\n}\n\n// Re-export BCJ2 multi-stream decoder for special handling\nexport { decodeBcj2Multi };\n\n// Register built-in codecs\n\n// Copy codec (no compression)\nregisterCodec(CodecId.COPY, {\n decode: decodeCopy,\n createDecoder: createCopyDecoder,\n});\n\n// LZMA codec\nregisterCodec(CodecId.LZMA, {\n decode: decodeLzma,\n createDecoder: createLzmaDecoder,\n});\n\n// LZMA2 codec\nregisterCodec(CodecId.LZMA2, {\n decode: decodeLzma2,\n createDecoder: createLzma2Decoder,\n});\n\n// BCJ (x86) filter\nregisterCodec(CodecId.BCJ_X86, {\n decode: decodeBcj,\n createDecoder: createBcjDecoder,\n});\n\n// BCJ (ARM) filter\nregisterCodec(CodecId.BCJ_ARM, {\n decode: decodeBcjArm,\n createDecoder: createBcjArmDecoder,\n});\n\n// BCJ (ARM Thumb) filter\nregisterCodec(CodecId.BCJ_ARMT, {\n decode: decodeBcjArmt,\n createDecoder: createBcjArmtDecoder,\n});\n\n// BCJ (ARM64) filter\nregisterCodec(CodecId.BCJ_ARM64, {\n decode: decodeBcjArm64,\n createDecoder: createBcjArm64Decoder,\n});\n\n// BCJ (PowerPC) filter\nregisterCodec(CodecId.BCJ_PPC, {\n decode: decodeBcjPpc,\n createDecoder: createBcjPpcDecoder,\n});\n\n// BCJ (IA64) filter\nregisterCodec(CodecId.BCJ_IA64, {\n decode: decodeBcjIa64,\n createDecoder: createBcjIa64Decoder,\n});\n\n// BCJ (SPARC) filter\nregisterCodec(CodecId.BCJ_SPARC, {\n decode: decodeBcjSparc,\n createDecoder: createBcjSparcDecoder,\n});\n\n// Delta filter\nregisterCodec(CodecId.DELTA, {\n decode: decodeDelta,\n createDecoder: createDeltaDecoder,\n});\n\n// Deflate codec\nregisterCodec(CodecId.DEFLATE, {\n decode: decodeDeflate,\n createDecoder: createDeflateDecoder,\n});\n\n// BZip2 codec\nregisterCodec(CodecId.BZIP2, {\n decode: decodeBzip2,\n createDecoder: createBzip2Decoder,\n});\n\n// AES-256-CBC codec (encryption)\nregisterCodec(CodecId.AES, {\n decode: decodeAes,\n createDecoder: createAesDecoder,\n});\n\n// BCJ2 (x86-64) filter - multi-stream\n// Note: BCJ2 requires special handling in SevenZipParser due to 4-stream architecture\nregisterCodec(CodecId.BCJ2, {\n decode: decodeBcj2,\n createDecoder: createBcj2Decoder,\n});\n\n// Note: PPMd codec is not implemented. See FUTURE_ENHANCEMENTS.md\n"],"names":["decodeBcj2Multi","getCodec","getCodecName","getPassword","isBcj2Codec","isCodecSupported","registerCodec","setPassword","codecs","codecIdToKey","id","parts","i","length","push","toString","toUpperCase","join","codecIdEquals","a","b","codec","key","createCodedError","ErrorCode","UNSUPPORTED_CODEC","undefined","CodecId","COPY","LZMA","LZMA2","BCJ_X86","BCJ_ARM","BCJ_ARMT","BCJ_ARM64","BCJ_PPC","BCJ_IA64","BCJ_SPARC","BCJ2","PPMD","DELTA","DEFLATE","BZIP2","AES","decode","decodeCopy","createDecoder","createCopyDecoder","decodeLzma","createLzmaDecoder","decodeLzma2","createLzma2Decoder","decodeBcj","createBcjDecoder","decodeBcjArm","createBcjArmDecoder","decodeBcjArmt","createBcjArmtDecoder","decodeBcjArm64","createBcjArm64Decoder","decodeBcjPpc","createBcjPpcDecoder","decodeBcjIa64","createBcjIa64Decoder","decodeBcjSparc","createBcjSparcDecoder","decodeDelta","createDeltaDecoder","decodeDeflate","createDeflateDecoder","decodeBzip2","createBzip2Decoder","decodeAes","createAesDecoder","decodeBcj2","createBcj2Decoder"],"mappings":"AAAA,sCAAsC;AACtC,2EAA2E;;;;;;;;;;;;QA+GlEA;eAAAA,uBAAe;;QA/CRC;eAAAA;;QAmBAC;eAAAA;;QA9DPC;eAAAA,kBAAW;;QAqFJC;eAAAA;;QA9BAC;eAAAA;;QApBAC;eAAAA;;QAnCMC;eAAAA,kBAAW;;;2BAlBoB;qBACiB;qBAC1B;sBACmB;wBACb;0BACI;yBACF;yBACA;wBACF;0BACI;uBACN;sBACF;yBACM;uBACJ;sBACF;uBACE;AAUhD,+BAA+B;AAC/B,IAAIC,SAAmC,CAAC;AAExC;;CAEC,GACD,SAASC,aAAaC,EAAY;IAChC,IAAIC,QAAkB,EAAE;IACxB,IAAK,IAAIC,IAAI,GAAGA,IAAIF,GAAGG,MAAM,EAAED,IAAK;QAClCD,MAAMG,IAAI,CAACJ,EAAE,CAACE,EAAE,CAACG,QAAQ,C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AAO,CAACM,QAAQ,EAAE;IAC9BW,QAAQY,wBAAa;IACrBV,eAAeW,+BAAoB;AACrC;AAEA,qBAAqB;AACrBnD,cAAcqB,oBAAO,CAACO,SAAS,EAAE;IAC/BU,QAAQc,0BAAc;IACtBZ,eAAea,iCAAqB;AACtC;AAEA,uBAAuB;AACvBrD,cAAcqB,oBAAO,CAACQ,OAAO,EAAE;IAC7BS,QAAQgB,sBAAY;IACpBd,eAAee,6BAAmB;AACpC;AAEA,oBAAoB;AACpBvD,cAAcqB,oBAAO,CAACS,QAAQ,EAAE;IAC9BQ,QAAQkB,wBAAa;IACrBhB,eAAeiB,+BAAoB;AACrC;AAEA,qBAAqB;AACrBzD,cAAcqB,oBAAO,CAACU,SAAS,EAAE;IAC/BO,QAAQoB,0BAAc;IACtBlB,eAAemB,iCAAqB;AACtC;AAEA,eAAe;AACf3D,cAAcqB,oBAAO,CAACa,KAAK,EAAE;IAC3BI,QAAQsB,oBAAW;IACnBpB,eAAeqB,2BAAkB;AACnC;AAEA,gBAAgB;AAChB7D,cAAcqB,oBAAO,CAACc,OAAO,EAAE;IAC7BG,QAAQwB,wBAAa;IACrBtB,eAAeuB,+BAAoB;AACrC;AAEA,cAAc;AACd/D,cAAcqB,oBAAO,CAACe,KAAK,EAAE;IAC3BE,QAAQ0B,oBAAW;IACnBxB,eAAeyB,2BAAkB;AACnC;AAEA,iCAAiC;AACjCjE,cAAcqB,oBAAO,CAACgB,GAAG,EAAE;IACzBC,QAAQ4B,gBAAS;IACjB1B,eAAe2B,uBAAgB;AACjC;AAEA,sCAAsC;AACtC,sFAAsF;AACtFnE,cAAcqB,oBAAO,CAACW,IAAI,EAAE;IAC1BM,QAAQ8B,kBAAU;IAClB5B,eAAe6B,yBAAiB;AAClC,IAEA,kEAAkE"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/index.ts"],"sourcesContent":["// Codec registry for 7z decompression\n// Each codec provides a decode function and optionally a streaming decoder\n\nimport type { Transform } from 'readable-stream';\nimport { CodecId, createCodedError, ErrorCode } from '../constants.ts';\nimport { createAesDecoder, decodeAes, getPassword, setPassword } from './Aes.ts';\nimport { createBcjDecoder, decodeBcj } from './Bcj.ts';\nimport { createBcj2Decoder, decodeBcj2, decodeBcj2Multi } from './Bcj2.ts';\nimport { createBcjArmDecoder, decodeBcjArm } from './BcjArm.ts';\nimport { createBcjArm64Decoder, decodeBcjArm64 } from './BcjArm64.ts';\nimport { createBcjArmtDecoder, decodeBcjArmt } from './BcjArmt.ts';\nimport { createBcjIa64Decoder, decodeBcjIa64 } from './BcjIa64.ts';\nimport { createBcjPpcDecoder, decodeBcjPpc } from './BcjPpc.ts';\nimport { createBcjSparcDecoder, decodeBcjSparc } from './BcjSparc.ts';\nimport { createBzip2Decoder, decodeBzip2 } from './BZip2.ts';\nimport { createCopyDecoder, decodeCopy } from './Copy.ts';\nimport { createDeflateDecoder, decodeDeflate } from './Deflate.ts';\nimport { createDeltaDecoder, decodeDelta } from './Delta.ts';\nimport { createLzmaDecoder, decodeLzma } from './Lzma.ts';\nimport { createLzma2Decoder, decodeLzma2 } from './Lzma2.ts';\n\n// Re-export password functions for API access\nexport { getPassword, setPassword };\n\nexport interface Codec {\n decode: (input: Buffer, properties?: Buffer, unpackSize?: number) => Buffer;\n createDecoder: (properties?: Buffer, unpackSize?: number) => Transform;\n}\n\n// Registry of supported codecs\nconst codecs: { [key: string]: Codec } = {};\n\n/**\n * Convert codec ID bytes to a string key\n */\nfunction codecIdToKey(id: number[]): string {\n const parts: string[] = [];\n for (let i = 0; i < id.length; i++) {\n parts.push(id[i].toString(16).toUpperCase());\n }\n return parts.join('-');\n}\n\n/**\n * Check if two codec IDs match\n */\nfunction codecIdEquals(a: number[], b: number[]): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n}\n\n/**\n * Register a codec\n */\nexport function registerCodec(id: number[], codec: Codec): void {\n codecs[codecIdToKey(id)] = codec;\n}\n\n/**\n * Get a codec by ID\n * @throws Error if codec is not supported\n */\nexport function getCodec(id: number[]): Codec {\n const key = codecIdToKey(id);\n const codec = codecs[key];\n if (!codec) {\n throw createCodedError(`Unsupported codec: ${key}`, ErrorCode.UNSUPPORTED_CODEC);\n }\n return codec;\n}\n\n/**\n * Check if a codec is supported\n */\nexport function isCodecSupported(id: number[]): boolean {\n return codecs[codecIdToKey(id)] !== undefined;\n}\n\n/**\n * Get human-readable codec name\n */\nexport function getCodecName(id: number[]): string {\n if (codecIdEquals(id, CodecId.COPY)) return 'Copy';\n if (codecIdEquals(id, CodecId.LZMA)) return 'LZMA';\n if (codecIdEquals(id, CodecId.LZMA2)) return 'LZMA2';\n if (codecIdEquals(id, CodecId.BCJ_X86)) return 'BCJ (x86)';\n if (codecIdEquals(id, CodecId.BCJ_ARM)) return 'BCJ (ARM)';\n if (codecIdEquals(id, CodecId.BCJ_ARMT)) return 'BCJ (ARM Thumb)';\n if (codecIdEquals(id, CodecId.BCJ_ARM64)) return 'BCJ (ARM64)';\n if (codecIdEquals(id, CodecId.BCJ_PPC)) return 'BCJ (PowerPC)';\n if (codecIdEquals(id, CodecId.BCJ_IA64)) return 'BCJ (IA64)';\n if (codecIdEquals(id, CodecId.BCJ_SPARC)) return 'BCJ (SPARC)';\n if (codecIdEquals(id, CodecId.BCJ2)) return 'BCJ2';\n if (codecIdEquals(id, CodecId.PPMD)) return 'PPMd';\n if (codecIdEquals(id, CodecId.DELTA)) return 'Delta';\n if (codecIdEquals(id, CodecId.DEFLATE)) return 'Deflate';\n if (codecIdEquals(id, CodecId.BZIP2)) return 'BZip2';\n if (codecIdEquals(id, CodecId.AES)) return 'AES-256';\n return `Unknown (${codecIdToKey(id)})`;\n}\n\n/**\n * Check if a codec ID matches BCJ2\n */\nexport function isBcj2Codec(id: number[]): boolean {\n return codecIdEquals(id, CodecId.BCJ2);\n}\n\n// Re-export BCJ2 multi-stream decoder for special handling\nexport { decodeBcj2Multi };\n\n// Register built-in codecs\n\n// Copy codec (no compression)\nregisterCodec(CodecId.COPY, {\n decode: decodeCopy,\n createDecoder: createCopyDecoder,\n});\n\n// LZMA codec\nregisterCodec(CodecId.LZMA, {\n decode: decodeLzma,\n createDecoder: createLzmaDecoder,\n});\n\n// LZMA2 codec\nregisterCodec(CodecId.LZMA2, {\n decode: decodeLzma2,\n createDecoder: createLzma2Decoder,\n});\n\n// BCJ (x86) filter\nregisterCodec(CodecId.BCJ_X86, {\n decode: decodeBcj,\n createDecoder: createBcjDecoder,\n});\n\n// BCJ (ARM) filter\nregisterCodec(CodecId.BCJ_ARM, {\n decode: decodeBcjArm,\n createDecoder: createBcjArmDecoder,\n});\n\n// BCJ (ARM Thumb) filter\nregisterCodec(CodecId.BCJ_ARMT, {\n decode: decodeBcjArmt,\n createDecoder: createBcjArmtDecoder,\n});\n\n// BCJ (ARM64) filter\nregisterCodec(CodecId.BCJ_ARM64, {\n decode: decodeBcjArm64,\n createDecoder: createBcjArm64Decoder,\n});\n\n// BCJ (PowerPC) filter\nregisterCodec(CodecId.BCJ_PPC, {\n decode: decodeBcjPpc,\n createDecoder: createBcjPpcDecoder,\n});\n\n// BCJ (IA64) filter\nregisterCodec(CodecId.BCJ_IA64, {\n decode: decodeBcjIa64,\n createDecoder: createBcjIa64Decoder,\n});\n\n// BCJ (SPARC) filter\nregisterCodec(CodecId.BCJ_SPARC, {\n decode: decodeBcjSparc,\n createDecoder: createBcjSparcDecoder,\n});\n\n// Delta filter\nregisterCodec(CodecId.DELTA, {\n decode: decodeDelta,\n createDecoder: createDeltaDecoder,\n});\n\n// Deflate codec\nregisterCodec(CodecId.DEFLATE, {\n decode: decodeDeflate,\n createDecoder: createDeflateDecoder,\n});\n\n// BZip2 codec\nregisterCodec(CodecId.BZIP2, {\n decode: decodeBzip2,\n createDecoder: createBzip2Decoder,\n});\n\n// AES-256-CBC codec (encryption)\nregisterCodec(CodecId.AES, {\n decode: decodeAes,\n createDecoder: createAesDecoder,\n});\n\n// BCJ2 (x86-64) filter - multi-stream\n// Note: BCJ2 requires special handling in SevenZipParser due to 4-stream architecture\nregisterCodec(CodecId.BCJ2, {\n decode: decodeBcj2,\n createDecoder: createBcj2Decoder,\n});\n\n// Note: PPMd codec is not implemented. See FUTURE_ENHANCEMENTS.md\n"],"names":["decodeBcj2Multi","getCodec","getCodecName","getPassword","isBcj2Codec","isCodecSupported","registerCodec","setPassword","codecs","codecIdToKey","id","parts","i","length","push","toString","toUpperCase","join","codecIdEquals","a","b","codec","key","createCodedError","ErrorCode","UNSUPPORTED_CODEC","undefined","CodecId","COPY","LZMA","LZMA2","BCJ_X86","BCJ_ARM","BCJ_ARMT","BCJ_ARM64","BCJ_PPC","BCJ_IA64","BCJ_SPARC","BCJ2","PPMD","DELTA","DEFLATE","BZIP2","AES","decode","decodeCopy","createDecoder","createCopyDecoder","decodeLzma","createLzmaDecoder","decodeLzma2","createLzma2Decoder","decodeBcj","createBcjDecoder","decodeBcjArm","createBcjArmDecoder","decodeBcjArmt","createBcjArmtDecoder","decodeBcjArm64","createBcjArm64Decoder","decodeBcjPpc","createBcjPpcDecoder","decodeBcjIa64","createBcjIa64Decoder","decodeBcjSparc","createBcjSparcDecoder","decodeDelta","createDeltaDecoder","decodeDeflate","createDeflateDecoder","decodeBzip2","createBzip2Decoder","decodeAes","createAesDecoder","decodeBcj2","createBcj2Decoder"],"mappings":"AAAA,sCAAsC;AACtC,2EAA2E;;;;;;;;;;;;QA+GlEA;eAAAA,uBAAe;;QA/CRC;eAAAA;;QAmBAC;eAAAA;;QA9DPC;eAAAA,kBAAW;;QAqFJC;eAAAA;;QA9BAC;eAAAA;;QApBAC;eAAAA;;QAnCMC;eAAAA,kBAAW;;;2BAlBoB;qBACiB;qBAC1B;sBACmB;wBACb;0BACI;yBACF;yBACA;wBACF;0BACI;uBACN;sBACF;yBACM;uBACJ;sBACF;uBACE;AAUhD,+BAA+B;AAC/B,IAAMC,SAAmC,CAAC;AAE1C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8B,kBAAU;IAClB5B,eAAe6B,yBAAiB;AAClC,IAEA,kEAAkE"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* the callback-based async pattern used throughout the iterator libraries.
|
|
10
10
|
*/
|
|
11
11
|
import type { Transform } from 'readable-stream';
|
|
12
|
-
export declare
|
|
12
|
+
export declare const hasNativeLzma: boolean;
|
|
13
13
|
/**
|
|
14
14
|
* Create a native LZMA2 decoder stream
|
|
15
15
|
* Returns a Transform stream that decodes LZMA2 data
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* the callback-based async pattern used throughout the iterator libraries.
|
|
10
10
|
*/
|
|
11
11
|
import type { Transform } from 'readable-stream';
|
|
12
|
-
export declare
|
|
12
|
+
export declare const hasNativeLzma: boolean;
|
|
13
13
|
/**
|
|
14
14
|
* Create a native LZMA2 decoder stream
|
|
15
15
|
* Returns a Transform stream that decodes LZMA2 data
|
|
@@ -63,4 +63,4 @@ function createNativeLzma1Decoder(_lc, _lp, _pb, _dictSize) {
|
|
|
63
63
|
// LZMA2 native works correctly and is more common in modern 7z files
|
|
64
64
|
return null;
|
|
65
65
|
}
|
|
66
|
-
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (
|
|
66
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (let key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/lzmaCompat.ts"],"sourcesContent":["/**\n * LZMA compatibility layer - uses native lzma when available, falls back to lzma-purejs\n *\n * lzma-native provides native liblzma bindings with rawDecoder support.\n * This gives significant performance improvements on Node.js 8+ while\n * maintaining compatibility with Node.js 0.8+ via lzma-purejs fallback.\n *\n * The native decoder uses Node.js streams which integrate naturally with\n * the callback-based async pattern used throughout the iterator libraries.\n */\n\nimport Module from 'module';\nimport type { Transform } from 'readable-stream';\n\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/lzmaCompat.ts"],"sourcesContent":["/**\n * LZMA compatibility layer - uses native lzma when available, falls back to lzma-purejs\n *\n * lzma-native provides native liblzma bindings with rawDecoder support.\n * This gives significant performance improvements on Node.js 8+ while\n * maintaining compatibility with Node.js 0.8+ via lzma-purejs fallback.\n *\n * The native decoder uses Node.js streams which integrate naturally with\n * the callback-based async pattern used throughout the iterator libraries.\n */\n\nimport Module from 'module';\nimport type { Transform } from 'readable-stream';\n\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\n// Try to load lzma-native (only on Node 10+ where ES6 class syntax is supported)\n// Note: We must check the version BEFORE requiring because syntax errors during\n// module parsing cannot be caught by try/catch\nlet lzmaNative: typeof import('lzma-native') | null = null;\nlet _hasNativeLzmaLib = false;\nconst major = +process.versions.node.split('.')[0];\n\nif (major >= 10) {\n try {\n lzmaNative = _require('lzma-native');\n // Verify rawDecoder support\n _hasNativeLzmaLib = lzmaNative !== null && typeof lzmaNative.createStream === 'function';\n } catch (_e) {\n // lzma-native not available - will use lzma-purejs\n }\n}\n\n// Export whether native lzma is available for streaming\nexport const hasNativeLzma = _hasNativeLzmaLib;\n\n/**\n * Create a native LZMA2 decoder stream\n * Returns a Transform stream that decodes LZMA2 data\n *\n * Note: Native LZMA2 decoder disabled due to LZMA_DATA_ERROR issues with\n * lzma-native's rawDecoder for LZMA2. The native decoder fails partway through\n * decompression on certain archives (e.g., Node.js Windows releases), reporting\n * \"Data is corrupt\" even when the data is valid. Falls back to lzma-purejs\n * which handles all LZMA2 streams correctly.\n *\n * @param _dictSize - Dictionary size (unused, native disabled)\n * @returns null - always falls back to pure JS decoder\n */\nexport function createNativeLzma2Decoder(_dictSize?: number): Transform | null {\n // Native LZMA2 disabled - lzma-native's rawDecoder has issues with certain\n // LZMA2 streams (LZMA_DATA_ERROR: Data is corrupt), even when data is valid.\n // The pure JS lzma-purejs implementation handles all streams correctly.\n return null;\n}\n\n/**\n * Create a native LZMA1 decoder stream\n * Returns a Transform stream that decodes LZMA1 data\n *\n * Note: Native LZMA1 decoder disabled due to LZMA_BUF_ERROR issues with\n * lzma-native's rawDecoder for LZMA1. Falls back to lzma-purejs which\n * handles 7z's LZMA1 format correctly. LZMA2 native works fine.\n *\n * @param _lc - Literal context bits (0-8)\n * @param _lp - Literal position bits (0-4)\n * @param _pb - Position bits (0-4)\n * @param _dictSize - Dictionary size\n * @returns null - always falls back to pure JS decoder\n */\nexport function createNativeLzma1Decoder(_lc: number, _lp: number, _pb: number, _dictSize: number): Transform | null {\n // Native LZMA1 disabled - lzma-native's rawDecoder has issues with 7z's LZMA1 format\n // (LZMA_BUF_ERROR: No progress is possible)\n // LZMA2 native works correctly and is more common in modern 7z files\n return null;\n}\n"],"names":["createNativeLzma1Decoder","createNativeLzma2Decoder","hasNativeLzma","_require","require","Module","createRequire","lzmaNative","_hasNativeLzmaLib","major","process","versions","node","split","createStream","_e","_dictSize","_lc","_lp","_pb"],"mappings":"AAAA;;;;;;;;;CASC;;;;;;;;;;;QA6DeA;eAAAA;;QArBAC;eAAAA;;QAfHC;eAAAA;;;6DAvBM;;;;;;AAGnB,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAE1F,iFAAiF;AACjF,gFAAgF;AAChF,+CAA+C;AAC/C,IAAIG,aAAkD;AACtD,IAAIC,oBAAoB;AACxB,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAElD,IAAIJ,SAAS,IAAI;IACf,IAAI;QACFF,aAAaJ,SAAS;QACtB,4BAA4B;QAC5BK,oBAAoBD,eAAe,QAAQ,OAAOA,WAAWO,YAAY,KAAK;IAChF,EAAE,OAAOC,IAAI;IACX,mDAAmD;IACrD;AACF;AAGO,IAAMb,gBAAgBM;AAetB,SAASP,yBAAyBe,SAAkB;IACzD,2EAA2E;IAC3E,6EAA6E;IAC7E,wEAAwE;IACxE,OAAO;AACT;AAgBO,SAAShB,yBAAyBiB,GAAW,EAAEC,GAAW,EAAEC,GAAW,EAAEH,SAAiB;IAC/F,qFAAqF;IACrF,4CAA4C;IAC5C,qEAAqE;IACrE,OAAO;AACT"}
|
|
@@ -106,4 +106,4 @@ function createOutputStream(expectedSize) {
|
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
-
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (
|
|
109
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (let key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/streams.ts"],"sourcesContent":["// Shared stream wrappers for lzma-purejs codec interface\n// These adapters convert between Buffer/lzma-purejs stream interfaces\n\nimport { allocBufferUnsafe } from 'extract-base-iterator';\n\n/**\n * Input stream wrapper for lzma-purejs\n * Wraps a Buffer region as a readable stream interface\n */\nexport function createInputStream(buffer: Buffer, offset: number, length: number) {\n
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/streams.ts"],"sourcesContent":["// Shared stream wrappers for lzma-purejs codec interface\n// These adapters convert between Buffer/lzma-purejs stream interfaces\n\nimport { allocBufferUnsafe } from 'extract-base-iterator';\n\n/**\n * Input stream wrapper for lzma-purejs\n * Wraps a Buffer region as a readable stream interface\n */\nexport function createInputStream(buffer: Buffer, offset: number, length: number) {\n let pos = 0;\n const end = Math.min(offset + length, buffer.length);\n const start = offset;\n\n return {\n readByte: (): number => {\n if (start + pos >= end) return -1;\n return buffer[start + pos++];\n },\n read: (buf: number[], bufOffset: number, len: number): number => {\n let bytesRead = 0;\n while (bytesRead < len && start + pos < end) {\n buf[bufOffset + bytesRead] = buffer[start + pos];\n pos++;\n bytesRead++;\n }\n return bytesRead === 0 ? -1 : bytesRead;\n },\n };\n}\n\n/**\n * Output stream wrapper for lzma-purejs\n * Collects output bytes into Buffer chunks\n * Uses typed arrays for memory efficiency (1 byte per element instead of 8)\n *\n * Memory optimization: If expectedSize is provided, pre-allocates a single buffer\n * to avoid double-memory during Buffer.concat.\n *\n * @param expectedSize - Optional expected output size for pre-allocation\n */\nexport function createOutputStream(expectedSize?: number) {\n // Pre-allocation mode: single buffer, no concat needed\n // Includes bounds checking for safety on older Node.js versions\n if (expectedSize && expectedSize > 0) {\n const buffer = allocBufferUnsafe(expectedSize);\n let bufPos = 0;\n const bufLen = buffer.length;\n\n return {\n writeByte: (b: number): void => {\n if (bufPos < bufLen) {\n buffer[bufPos++] = b;\n }\n // Silently ignore overflow (should not happen with correct size)\n },\n write: (buf: number[], bufOffset: number, len: number): number => {\n for (let i = 0; i < len && bufPos < bufLen; i++) {\n buffer[bufPos++] = buf[bufOffset + i];\n }\n return len;\n },\n flush: (): void => {\n // No-op for pre-allocated buffer\n },\n toBuffer: (): Buffer => {\n // Return only the used portion\n return bufPos < buffer.length ? buffer.slice(0, bufPos) : buffer;\n },\n };\n }\n\n // Chunked mode: accumulate in 64KB chunks (fallback for unknown size)\n const chunks: Buffer[] = [];\n const CHUNK_SIZE = 65536; // 64KB chunks for better memory efficiency\n let currentChunk: Buffer = allocBufferUnsafe(CHUNK_SIZE);\n let pos = 0;\n\n return {\n writeByte: (b: number): void => {\n currentChunk[pos++] = b;\n if (pos >= CHUNK_SIZE) {\n chunks.push(currentChunk);\n currentChunk = allocBufferUnsafe(CHUNK_SIZE);\n pos = 0;\n }\n },\n write: function (buf: number[], bufOffset: number, len: number): number {\n for (let i = 0; i < len; i++) {\n this.writeByte(buf[bufOffset + i]);\n }\n return len;\n },\n flush: (): void => {\n if (pos > 0) {\n // Only keep the used portion of the current chunk\n chunks.push(currentChunk.slice(0, pos));\n currentChunk = allocBufferUnsafe(CHUNK_SIZE);\n pos = 0;\n }\n },\n toBuffer: function (): Buffer {\n this.flush();\n // Optimization: if single chunk, return it directly\n if (chunks.length === 1) {\n return chunks[0];\n }\n return Buffer.concat(chunks);\n },\n };\n}\n"],"names":["createInputStream","createOutputStream","buffer","offset","length","pos","end","Math","min","start","readByte","read","buf","bufOffset","len","bytesRead","expectedSize","allocBufferUnsafe","bufPos","bufLen","writeByte","b","write","i","flush","toBuffer","slice","chunks","CHUNK_SIZE","currentChunk","push","Buffer","concat"],"mappings":"AAAA,yDAAyD;AACzD,sEAAsE;;;;;;;;;;;;QAQtDA;eAAAA;;QAgCAC;eAAAA;;;mCAtCkB;AAM3B,SAASD,kBAAkBE,MAAc,EAAEC,MAAc,EAAEC,MAAc;IAC9E,IAAIC,MAAM;IACV,IAAMC,MAAMC,KAAKC,GAAG,CAACL,SAASC,QAAQF,OAAOE,MAAM;IACnD,IAAMK,QAAQN;IAEd,OAAO;QACLO,UAAU;YACR,IAAID,QAAQJ,OAAOC,KAAK,OAAO,CAAC;YAChC,OAAOJ,MAAM,CAACO,QAAQJ,MAAM;QAC9B;QACAM,MAAM,SAACC,KAAeC,WAAmBC;YACvC,IAAIC,YAAY;YAChB,MAAOA,YAAYD,OAAOL,QAAQJ,MAAMC,IAAK;gBAC3CM,GAAG,CAACC,YAAYE,UAAU,GAAGb,MAAM,CAACO,QAAQJ,IAAI;gBAChDA;gBACAU;YACF;YACA,OAAOA,cAAc,IAAI,CAAC,IAAIA;QAChC;IACF;AACF;AAYO,SAASd,mBAAmBe,YAAqB;IACtD,uDAAuD;IACvD,gEAAgE;IAChE,IAAIA,gBAAgBA,eAAe,GAAG;QACpC,IAAMd,SAASe,IAAAA,sCAAiB,EAACD;QACjC,IAAIE,SAAS;QACb,IAAMC,SAASjB,OAA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,IAAIG,OAAOvB,MAAM,KAAK,GAAG;gBACvB,OAAOuB,MAAM,CAAC,EAAE;YAClB;YACA,OAAOI,OAAOC,MAAM,CAACL;QACvB;IACF;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
export declare
|
|
3
|
-
export declare
|
|
4
|
-
export declare
|
|
1
|
+
export declare const SEVENZ_MAGIC: number[];
|
|
2
|
+
export declare const SIGNATURE_HEADER_SIZE = 32;
|
|
3
|
+
export declare const START_HEADER_SIZE = 20;
|
|
4
|
+
export declare const PropertyId: {
|
|
5
5
|
kEnd: number;
|
|
6
6
|
kHeader: number;
|
|
7
7
|
kArchiveProperties: number;
|
|
@@ -29,7 +29,7 @@ export declare var PropertyId: {
|
|
|
29
29
|
kStartPos: number;
|
|
30
30
|
kDummy: number;
|
|
31
31
|
};
|
|
32
|
-
export declare
|
|
32
|
+
export declare const CodecId: {
|
|
33
33
|
COPY: number[];
|
|
34
34
|
DELTA: number[];
|
|
35
35
|
LZMA: number[];
|
|
@@ -47,7 +47,7 @@ export declare var CodecId: {
|
|
|
47
47
|
BZIP2: number[];
|
|
48
48
|
AES: number[];
|
|
49
49
|
};
|
|
50
|
-
export declare
|
|
50
|
+
export declare const FileAttribute: {
|
|
51
51
|
READONLY: number;
|
|
52
52
|
HIDDEN: number;
|
|
53
53
|
SYSTEM: number;
|
|
@@ -64,7 +64,7 @@ export declare var FileAttribute: {
|
|
|
64
64
|
ENCRYPTED: number;
|
|
65
65
|
UNIX_EXTENSION: number;
|
|
66
66
|
};
|
|
67
|
-
export declare
|
|
67
|
+
export declare const UnixMode: {
|
|
68
68
|
DIR: number;
|
|
69
69
|
FILE: number;
|
|
70
70
|
SYMLINK: number;
|
|
@@ -74,7 +74,7 @@ export declare var UnixMode: {
|
|
|
74
74
|
DEFAULT_DIR: number;
|
|
75
75
|
DEFAULT_FILE: number;
|
|
76
76
|
};
|
|
77
|
-
export declare
|
|
77
|
+
export declare const ErrorCode: {
|
|
78
78
|
INVALID_SIGNATURE: string;
|
|
79
79
|
CRC_MISMATCH: string;
|
|
80
80
|
UNSUPPORTED_CODEC: string;
|