7z-iterator 1.4.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/dist/cjs/index.d.cts +3 -3
  2. package/dist/cjs/index.d.ts +3 -3
  3. package/dist/cjs/index.js +7 -38
  4. package/dist/cjs/index.js.map +1 -1
  5. package/dist/cjs/nextEntry.js +1 -2
  6. package/dist/cjs/nextEntry.js.map +1 -1
  7. package/dist/cjs/sevenz/ArchiveSource.d.cts +1 -0
  8. package/dist/cjs/sevenz/ArchiveSource.d.ts +1 -0
  9. package/dist/cjs/sevenz/ArchiveSource.js +23 -0
  10. package/dist/cjs/sevenz/ArchiveSource.js.map +1 -1
  11. package/dist/cjs/sevenz/SevenZipParser.js +22 -3
  12. package/dist/cjs/sevenz/SevenZipParser.js.map +1 -1
  13. package/dist/cjs/sevenz/codecs/index.js +52 -30
  14. package/dist/cjs/sevenz/codecs/index.js.map +1 -1
  15. package/dist/cjs/sevenz/constants.d.cts +1 -0
  16. package/dist/cjs/sevenz/constants.d.ts +1 -0
  17. package/dist/cjs/sevenz/constants.js +1 -0
  18. package/dist/cjs/sevenz/constants.js.map +1 -1
  19. package/dist/esm/index.d.ts +3 -3
  20. package/dist/esm/index.js +4 -3
  21. package/dist/esm/index.js.map +1 -1
  22. package/dist/esm/nextEntry.js +1 -2
  23. package/dist/esm/nextEntry.js.map +1 -1
  24. package/dist/esm/sevenz/ArchiveSource.d.ts +1 -0
  25. package/dist/esm/sevenz/ArchiveSource.js +23 -0
  26. package/dist/esm/sevenz/ArchiveSource.js.map +1 -1
  27. package/dist/esm/sevenz/SevenZipParser.js +22 -3
  28. package/dist/esm/sevenz/SevenZipParser.js.map +1 -1
  29. package/dist/esm/sevenz/codecs/index.js +32 -10
  30. package/dist/esm/sevenz/codecs/index.js.map +1 -1
  31. package/dist/esm/sevenz/constants.d.ts +1 -0
  32. package/dist/esm/sevenz/constants.js +1 -0
  33. package/dist/esm/sevenz/constants.js.map +1 -1
  34. package/package.json +3 -3
  35. package/dist/cjs/lzma/Lzma2ChunkParser.d.cts +0 -73
  36. package/dist/cjs/lzma/Lzma2ChunkParser.d.ts +0 -73
  37. package/dist/cjs/lzma/Lzma2ChunkParser.js +0 -148
  38. package/dist/cjs/lzma/Lzma2ChunkParser.js.map +0 -1
  39. package/dist/cjs/lzma/index.d.cts +0 -31
  40. package/dist/cjs/lzma/index.d.ts +0 -31
  41. package/dist/cjs/lzma/index.js +0 -83
  42. package/dist/cjs/lzma/index.js.map +0 -1
  43. package/dist/cjs/lzma/stream/transforms.d.cts +0 -46
  44. package/dist/cjs/lzma/stream/transforms.d.ts +0 -46
  45. package/dist/cjs/lzma/stream/transforms.js +0 -209
  46. package/dist/cjs/lzma/stream/transforms.js.map +0 -1
  47. package/dist/cjs/lzma/sync/Lzma2Decoder.d.cts +0 -63
  48. package/dist/cjs/lzma/sync/Lzma2Decoder.d.ts +0 -63
  49. package/dist/cjs/lzma/sync/Lzma2Decoder.js +0 -231
  50. package/dist/cjs/lzma/sync/Lzma2Decoder.js.map +0 -1
  51. package/dist/cjs/lzma/sync/LzmaDecoder.d.cts +0 -97
  52. package/dist/cjs/lzma/sync/LzmaDecoder.d.ts +0 -97
  53. package/dist/cjs/lzma/sync/LzmaDecoder.js +0 -580
  54. package/dist/cjs/lzma/sync/LzmaDecoder.js.map +0 -1
  55. package/dist/cjs/lzma/sync/RangeDecoder.d.cts +0 -69
  56. package/dist/cjs/lzma/sync/RangeDecoder.d.ts +0 -69
  57. package/dist/cjs/lzma/sync/RangeDecoder.js +0 -162
  58. package/dist/cjs/lzma/sync/RangeDecoder.js.map +0 -1
  59. package/dist/cjs/lzma/types.d.cts +0 -117
  60. package/dist/cjs/lzma/types.d.ts +0 -117
  61. package/dist/cjs/lzma/types.js +0 -264
  62. package/dist/cjs/lzma/types.js.map +0 -1
  63. package/dist/cjs/sevenz/codecs/Bcj.d.cts +0 -16
  64. package/dist/cjs/sevenz/codecs/Bcj.d.ts +0 -16
  65. package/dist/cjs/sevenz/codecs/Bcj.js +0 -183
  66. package/dist/cjs/sevenz/codecs/Bcj.js.map +0 -1
  67. package/dist/cjs/sevenz/codecs/BcjArm.d.cts +0 -21
  68. package/dist/cjs/sevenz/codecs/BcjArm.d.ts +0 -21
  69. package/dist/cjs/sevenz/codecs/BcjArm.js +0 -104
  70. package/dist/cjs/sevenz/codecs/BcjArm.js.map +0 -1
  71. package/dist/cjs/sevenz/codecs/BcjArm64.d.cts +0 -21
  72. package/dist/cjs/sevenz/codecs/BcjArm64.d.ts +0 -21
  73. package/dist/cjs/sevenz/codecs/BcjArm64.js +0 -65
  74. package/dist/cjs/sevenz/codecs/BcjArm64.js.map +0 -1
  75. package/dist/cjs/sevenz/codecs/BcjArmt.d.cts +0 -19
  76. package/dist/cjs/sevenz/codecs/BcjArmt.d.ts +0 -19
  77. package/dist/cjs/sevenz/codecs/BcjArmt.js +0 -76
  78. package/dist/cjs/sevenz/codecs/BcjArmt.js.map +0 -1
  79. package/dist/cjs/sevenz/codecs/BcjIa64.d.cts +0 -15
  80. package/dist/cjs/sevenz/codecs/BcjIa64.d.ts +0 -15
  81. package/dist/cjs/sevenz/codecs/BcjIa64.js +0 -141
  82. package/dist/cjs/sevenz/codecs/BcjIa64.js.map +0 -1
  83. package/dist/cjs/sevenz/codecs/BcjPpc.d.cts +0 -20
  84. package/dist/cjs/sevenz/codecs/BcjPpc.d.ts +0 -20
  85. package/dist/cjs/sevenz/codecs/BcjPpc.js +0 -64
  86. package/dist/cjs/sevenz/codecs/BcjPpc.js.map +0 -1
  87. package/dist/cjs/sevenz/codecs/BcjSparc.d.cts +0 -19
  88. package/dist/cjs/sevenz/codecs/BcjSparc.d.ts +0 -19
  89. package/dist/cjs/sevenz/codecs/BcjSparc.js +0 -69
  90. package/dist/cjs/sevenz/codecs/BcjSparc.js.map +0 -1
  91. package/dist/cjs/sevenz/codecs/Delta.d.cts +0 -16
  92. package/dist/cjs/sevenz/codecs/Delta.d.ts +0 -16
  93. package/dist/cjs/sevenz/codecs/Delta.js +0 -74
  94. package/dist/cjs/sevenz/codecs/Delta.js.map +0 -1
  95. package/dist/cjs/sevenz/codecs/Lzma.d.cts +0 -17
  96. package/dist/cjs/sevenz/codecs/Lzma.d.ts +0 -17
  97. package/dist/cjs/sevenz/codecs/Lzma.js +0 -40
  98. package/dist/cjs/sevenz/codecs/Lzma.js.map +0 -1
  99. package/dist/cjs/sevenz/codecs/Lzma2.d.cts +0 -20
  100. package/dist/cjs/sevenz/codecs/Lzma2.d.ts +0 -20
  101. package/dist/cjs/sevenz/codecs/Lzma2.js +0 -42
  102. package/dist/cjs/sevenz/codecs/Lzma2.js.map +0 -1
  103. package/dist/cjs/xz/Decoder.d.cts +0 -25
  104. package/dist/cjs/xz/Decoder.d.ts +0 -25
  105. package/dist/cjs/xz/Decoder.js +0 -194
  106. package/dist/cjs/xz/Decoder.js.map +0 -1
  107. package/dist/esm/lzma/Lzma2ChunkParser.d.ts +0 -73
  108. package/dist/esm/lzma/Lzma2ChunkParser.js +0 -137
  109. package/dist/esm/lzma/Lzma2ChunkParser.js.map +0 -1
  110. package/dist/esm/lzma/index.d.ts +0 -31
  111. package/dist/esm/lzma/index.js +0 -44
  112. package/dist/esm/lzma/index.js.map +0 -1
  113. package/dist/esm/lzma/stream/transforms.d.ts +0 -46
  114. package/dist/esm/lzma/stream/transforms.js +0 -189
  115. package/dist/esm/lzma/stream/transforms.js.map +0 -1
  116. package/dist/esm/lzma/sync/Lzma2Decoder.d.ts +0 -63
  117. package/dist/esm/lzma/sync/Lzma2Decoder.js +0 -211
  118. package/dist/esm/lzma/sync/Lzma2Decoder.js.map +0 -1
  119. package/dist/esm/lzma/sync/LzmaDecoder.d.ts +0 -97
  120. package/dist/esm/lzma/sync/LzmaDecoder.js +0 -543
  121. package/dist/esm/lzma/sync/LzmaDecoder.js.map +0 -1
  122. package/dist/esm/lzma/sync/RangeDecoder.d.ts +0 -69
  123. package/dist/esm/lzma/sync/RangeDecoder.js +0 -132
  124. package/dist/esm/lzma/sync/RangeDecoder.js.map +0 -1
  125. package/dist/esm/lzma/types.d.ts +0 -117
  126. package/dist/esm/lzma/types.js +0 -154
  127. package/dist/esm/lzma/types.js.map +0 -1
  128. package/dist/esm/sevenz/codecs/Bcj.d.ts +0 -16
  129. package/dist/esm/sevenz/codecs/Bcj.js +0 -175
  130. package/dist/esm/sevenz/codecs/Bcj.js.map +0 -1
  131. package/dist/esm/sevenz/codecs/BcjArm.d.ts +0 -21
  132. package/dist/esm/sevenz/codecs/BcjArm.js +0 -101
  133. package/dist/esm/sevenz/codecs/BcjArm.js.map +0 -1
  134. package/dist/esm/sevenz/codecs/BcjArm64.d.ts +0 -21
  135. package/dist/esm/sevenz/codecs/BcjArm64.js +0 -57
  136. package/dist/esm/sevenz/codecs/BcjArm64.js.map +0 -1
  137. package/dist/esm/sevenz/codecs/BcjArmt.d.ts +0 -19
  138. package/dist/esm/sevenz/codecs/BcjArmt.js +0 -66
  139. package/dist/esm/sevenz/codecs/BcjArmt.js.map +0 -1
  140. package/dist/esm/sevenz/codecs/BcjIa64.d.ts +0 -15
  141. package/dist/esm/sevenz/codecs/BcjIa64.js +0 -127
  142. package/dist/esm/sevenz/codecs/BcjIa64.js.map +0 -1
  143. package/dist/esm/sevenz/codecs/BcjPpc.d.ts +0 -20
  144. package/dist/esm/sevenz/codecs/BcjPpc.js +0 -55
  145. package/dist/esm/sevenz/codecs/BcjPpc.js.map +0 -1
  146. package/dist/esm/sevenz/codecs/BcjSparc.d.ts +0 -19
  147. package/dist/esm/sevenz/codecs/BcjSparc.js +0 -59
  148. package/dist/esm/sevenz/codecs/BcjSparc.js.map +0 -1
  149. package/dist/esm/sevenz/codecs/Delta.d.ts +0 -16
  150. package/dist/esm/sevenz/codecs/Delta.js +0 -66
  151. package/dist/esm/sevenz/codecs/Delta.js.map +0 -1
  152. package/dist/esm/sevenz/codecs/Lzma.d.ts +0 -17
  153. package/dist/esm/sevenz/codecs/Lzma.js +0 -33
  154. package/dist/esm/sevenz/codecs/Lzma.js.map +0 -1
  155. package/dist/esm/sevenz/codecs/Lzma2.d.ts +0 -20
  156. package/dist/esm/sevenz/codecs/Lzma2.js +0 -38
  157. package/dist/esm/sevenz/codecs/Lzma2.js.map +0 -1
  158. package/dist/esm/xz/Decoder.d.ts +0 -25
  159. package/dist/esm/xz/Decoder.js +0 -185
  160. package/dist/esm/xz/Decoder.js.map +0 -1
@@ -1,127 +0,0 @@
1
- // BCJ (IA64/Itanium) filter codec - converts IA64 branch instruction addresses
2
- // This filter makes IA64 executables more compressible by LZMA
3
- //
4
- // IA64 uses 128-bit instruction bundles with 3 instructions per bundle.
5
- // Branch instructions use 21-bit signed offsets (in bundles).
6
- //
7
- // Reference: https://github.com/kornelski/7z/blob/main/C/Bra.c
8
- import { bufferFrom } from 'extract-base-iterator';
9
- import createBufferingDecoder from './createBufferingDecoder.js';
10
- // IA64 branch instruction slot mask
11
- // Each bundle has a 5-bit template and 3 x 41-bit instruction slots
12
- const kBranchTable = [
13
- 0,
14
- 0,
15
- 0,
16
- 0,
17
- 0,
18
- 0,
19
- 0,
20
- 0,
21
- 0,
22
- 0,
23
- 0,
24
- 0,
25
- 0,
26
- 0,
27
- 0,
28
- 0,
29
- 4,
30
- 4,
31
- 6,
32
- 6,
33
- 0,
34
- 0,
35
- 7,
36
- 7,
37
- 4,
38
- 4,
39
- 0,
40
- 0,
41
- 4,
42
- 4,
43
- 0,
44
- 0
45
- ];
46
- /**
47
- * Decode IA64 BCJ filtered data
48
- * Reverses the BCJ transformation by converting absolute addresses back to relative
49
- *
50
- * @param input - IA64 BCJ filtered data
51
- * @param _properties - Unused for IA64 BCJ
52
- * @param _unpackSize - Unused for IA64 BCJ
53
- * @returns Unfiltered data
54
- */ export function decodeBcjIa64(input, _properties, _unpackSize) {
55
- const output = bufferFrom(input); // Copy since we modify in place
56
- let pos = 0;
57
- // Process 16-byte aligned bundles
58
- while(pos + 16 <= output.length){
59
- // Get template (low 5 bits of first byte)
60
- const template = output[pos] & 0x1f;
61
- const mask = kBranchTable[template];
62
- // Check each instruction slot (3 slots per bundle)
63
- for(let slot = 0; slot < 3; slot++){
64
- if ((mask & 1 << slot) === 0) {
65
- continue;
66
- }
67
- // Calculate bit position for this slot
68
- // Slot 0: bits 5-45, Slot 1: bits 46-86, Slot 2: bits 87-127
69
- const bitPos = 5 + slot * 41;
70
- const bytePos = bitPos >>> 3;
71
- const bitOffset = bitPos & 7;
72
- // Read 8 bytes to get the instruction (may span bytes)
73
- // We need at least 6 bytes for a 41-bit instruction
74
- if (pos + bytePos + 6 > output.length) {
75
- break;
76
- }
77
- // Extract instruction bytes
78
- const instr0 = output[pos + bytePos];
79
- const instr1 = output[pos + bytePos + 1];
80
- const instr2 = output[pos + bytePos + 2];
81
- const instr3 = output[pos + bytePos + 3];
82
- const instr4 = output[pos + bytePos + 4];
83
- const instr5 = output[pos + bytePos + 5];
84
- // Build instruction value (we only need the immediate field)
85
- // The immediate is in bits 13-32 of the instruction (20 bits)
86
- // Plus bit 36 as the sign bit
87
- // For decoding, we extract the address that was encoded and convert back
88
- let instrLo = instr0 >>> bitOffset | instr1 << 8 - bitOffset | instr2 << 16 - bitOffset | instr3 << 24 - bitOffset;
89
- let instrHi = instr4 >>> bitOffset | instr5 << 8 - bitOffset;
90
- // Check opcode for branch (opcode 4 or 5 in bits 37-40)
91
- const opcode = instrHi >>> 37 - 32 - bitOffset & 0xf;
92
- if (opcode !== 4 && opcode !== 5) {
93
- continue;
94
- }
95
- // Extract 21-bit immediate (bits 13-32 + sign bit 36)
96
- const imm20 = instrLo >>> 13 & 0xfffff;
97
- const sign = instrHi >>> 36 - 32 & 1;
98
- // Combine into 21-bit signed value
99
- let addr = imm20 | sign << 20;
100
- if (sign) {
101
- addr |= 0xffe00000; // Sign-extend
102
- }
103
- // Convert absolute to relative: subtract current position (in bundles)
104
- const relAddr = addr - (pos >>> 4);
105
- // Write back
106
- const newImm20 = relAddr & 0xfffff;
107
- const newSign = relAddr >>> 20 & 1;
108
- // Clear old immediate and write new one
109
- instrLo = instrLo & ~(0xfffff << 13) | newImm20 << 13;
110
- instrHi = instrHi & ~(1 << 36 - 32) | newSign << 36 - 32;
111
- // Write back bytes
112
- output[pos + bytePos] = output[pos + bytePos] & (1 << bitOffset) - 1 | (instrLo & 0xff) << bitOffset;
113
- output[pos + bytePos + 1] = instrLo >>> 8 - bitOffset & 0xff;
114
- output[pos + bytePos + 2] = instrLo >>> 16 - bitOffset & 0xff;
115
- output[pos + bytePos + 3] = instrLo >>> 24 - bitOffset & 0xff;
116
- output[pos + bytePos + 4] = instrLo >>> 32 - bitOffset & (1 << bitOffset) - 1 | (instrHi & 0xff) << bitOffset;
117
- output[pos + bytePos + 5] = output[pos + bytePos + 5] & ~((1 << bitOffset) - 1) | instrHi >>> 8 - bitOffset & (1 << bitOffset) - 1;
118
- }
119
- pos += 16;
120
- }
121
- return output;
122
- }
123
- /**
124
- * Create an IA64 BCJ decoder Transform stream
125
- */ export function createBcjIa64Decoder(properties, unpackSize) {
126
- return createBufferingDecoder(decodeBcjIa64, properties, unpackSize);
127
- }
@@ -1 +0,0 @@
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 '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":["bufferFrom","createBufferingDecoder","kBranchTable","decodeBcjIa64","input","_properties","_unpackSize","output","pos","length","template","mask","slot","bitPos","bytePos","bitOffset","instr0","instr1","instr2","instr3","instr4","instr5","instrLo","instrHi","opcode","imm20","sign","addr","relAddr","newImm20","newSign","createBcjIa64Decoder","properties","unpackSize"],"mappings":"AAAA,+EAA+E;AAC/E,+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AAa,KAAKP,YAAc;YAC7DR,MAAM,CAACC,MAAMM,UAAU,EAAE,GAAG,AAACQ,YAAa,KAAKP,YAAc;YAC7DR,MAAM,CAACC,MAAMM,UAAU,EAAE,GAAG,AAAEQ,YAAa,KAAKP,YAAe,AAAC,CAAA,KAAKA,SAAQ,IAAK,IAAO,AAACQ,CAAAA,UAAU,IAAG,KAAMR;YAC7GR,MAAM,CAACC,MAAMM,UAAU,EAAE,GAAG,AAACP,MAAM,CAACC,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,OAAOD;AACT;AAEA;;CAEC,GACD,OAAO,SAASwB,qBAAqBC,UAAmB,EAAEC,UAAmB;IAC3E,OAAOhC,uBAAuBE,eAAe6B,YAAYC;AAC3D"}
@@ -1,20 +0,0 @@
1
- import type { Transform } from 'stream';
2
- /**
3
- * Decode PowerPC BCJ filtered data
4
- * Reverses the BCJ transformation by converting absolute addresses back to relative
5
- *
6
- * PowerPC B/BL instruction format (big-endian):
7
- * - 4 bytes aligned
8
- * - Opcode 0x48 in high byte with AA=0, LK=1 (0x48000001 mask 0xFC000003)
9
- * - Bits 6-29 are 24-bit signed offset (in words)
10
- *
11
- * @param input - PowerPC BCJ filtered data
12
- * @param _properties - Unused for PowerPC BCJ
13
- * @param _unpackSize - Unused for PowerPC BCJ
14
- * @returns Unfiltered data
15
- */
16
- export declare function decodeBcjPpc(input: Buffer, _properties?: Buffer, _unpackSize?: number): Buffer;
17
- /**
18
- * Create a PowerPC BCJ decoder Transform stream
19
- */
20
- export declare function createBcjPpcDecoder(properties?: Buffer, unpackSize?: number): Transform;
@@ -1,55 +0,0 @@
1
- // BCJ (PowerPC) filter codec - converts PowerPC branch instruction addresses
2
- // This filter makes PowerPC executables more compressible by LZMA
3
- //
4
- // PowerPC is big-endian. Branch instructions use 26-bit signed offsets.
5
- //
6
- // Reference: https://github.com/kornelski/7z/blob/main/C/Bra.c
7
- import { bufferFrom } from 'extract-base-iterator';
8
- import createBufferingDecoder from './createBufferingDecoder.js';
9
- /**
10
- * Decode PowerPC BCJ filtered data
11
- * Reverses the BCJ transformation by converting absolute addresses back to relative
12
- *
13
- * PowerPC B/BL instruction format (big-endian):
14
- * - 4 bytes aligned
15
- * - Opcode 0x48 in high byte with AA=0, LK=1 (0x48000001 mask 0xFC000003)
16
- * - Bits 6-29 are 24-bit signed offset (in words)
17
- *
18
- * @param input - PowerPC BCJ filtered data
19
- * @param _properties - Unused for PowerPC BCJ
20
- * @param _unpackSize - Unused for PowerPC BCJ
21
- * @returns Unfiltered data
22
- */ export function decodeBcjPpc(input, _properties, _unpackSize) {
23
- const output = bufferFrom(input); // Copy since we modify in place
24
- let pos = 0;
25
- // Process 4-byte aligned positions
26
- while(pos + 4 <= output.length){
27
- // Read 32-bit value (big-endian)
28
- let instr = output[pos] << 24 | output[pos + 1] << 16 | output[pos + 2] << 8 | output[pos + 3];
29
- // Check for B/BL instruction: (instr & 0xFC000003) === 0x48000001
30
- if ((instr & 0xfc000003) === 0x48000001) {
31
- // Extract 26-bit offset (bits 2-27, the LI field)
32
- let addr = instr & 0x03fffffc;
33
- // Sign-extend 26-bit to 32-bit
34
- if (addr & 0x02000000) {
35
- addr |= 0xfc000000;
36
- }
37
- // Convert absolute to relative: subtract current position
38
- const relAddr = addr - pos;
39
- // Clear old offset and write new one
40
- instr = instr & 0xfc000003 | relAddr & 0x03fffffc;
41
- // Write back (big-endian)
42
- output[pos] = instr >>> 24 & 0xff;
43
- output[pos + 1] = instr >>> 16 & 0xff;
44
- output[pos + 2] = instr >>> 8 & 0xff;
45
- output[pos + 3] = instr & 0xff;
46
- }
47
- pos += 4;
48
- }
49
- return output;
50
- }
51
- /**
52
- * Create a PowerPC BCJ decoder Transform stream
53
- */ export function createBcjPpcDecoder(properties, unpackSize) {
54
- return createBufferingDecoder(decodeBcjPpc, properties, unpackSize);
55
- }
@@ -1 +0,0 @@
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 '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":["bufferFrom","createBufferingDecoder","decodeBcjPpc","input","_properties","_unpackSize","output","pos","length","instr","addr","relAddr","createBcjPpcDecoder","properties","unpackSize"],"mappings":"AAAA,6EAA6E;AAC7E,kEAAkE;AAClE,EAAE;AACF,wEAAwE;AACxE,EAAE;AACF,+DAA+D;AAE/D,SAASA,UAAU,QAAQ,wBAAwB;AAEnD,OAAOC,4BAA4B,8BAA8B;AAEjE;;;;;;;;;;;;;CAaC,GACD,OAAO,SAASC,aAAaC,KAAa,EAAEC,WAAoB,EAAEC,WAAoB;IACpF,MAAMC,SAASN,WAAWG,QAAQ,gCAAgC;IAClE,IAAII,MAAM;IAEV,mCAAmC;IACnC,MAAOA,MAAM,KAAKD,OAAOE,MAAM,CAAE;QAC/B,iCAAiC;QACjC,IAAIC,QAAQ,AAACH,MAAM,CAACC,IAAI,IAAI,KAAOD,MAAM,CAACC,MAAM,EAAE,IAAI,KAAOD,MAAM,CAACC,MAAM,EAAE,IAAI,IAAKD,MAAM,CAACC,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,MAAMC,UAAUD,OAAOH;YAEvB,qCAAqC;YACrCE,QAAQ,AAACA,QAAQ,aAAeE,UAAU;YAE1C,0BAA0B;YAC1BL,MAAM,CAACC,IAAI,GAAG,AAACE,UAAU,KAAM;YAC/BH,MAAM,CAACC,MAAM,EAAE,GAAG,AAACE,UAAU,KAAM;YACnCH,MAAM,CAACC,MAAM,EAAE,GAAG,AAACE,UAAU,IAAK;YAClCH,MAAM,CAACC,MAAM,EAAE,GAAGE,QAAQ;QAC5B;QACAF,OAAO;IACT;IAEA,OAAOD;AACT;AAEA;;CAEC,GACD,OAAO,SAASM,oBAAoBC,UAAmB,EAAEC,UAAmB;IAC1E,OAAOb,uBAAuBC,cAAcW,YAAYC;AAC1D"}
@@ -1,19 +0,0 @@
1
- import type { Transform } from 'stream';
2
- /**
3
- * Decode SPARC BCJ filtered data
4
- * Reverses the BCJ transformation by converting absolute addresses back to relative
5
- *
6
- * SPARC CALL instruction matching (big-endian):
7
- * - First byte 0x40 and (second byte & 0xC0) == 0x00, OR
8
- * - First byte 0x7F and (second byte & 0xC0) == 0xC0
9
- *
10
- * @param input - SPARC BCJ filtered data
11
- * @param _properties - Unused for SPARC BCJ
12
- * @param _unpackSize - Unused for SPARC BCJ
13
- * @returns Unfiltered data
14
- */
15
- export declare function decodeBcjSparc(input: Buffer, _properties?: Buffer, _unpackSize?: number): Buffer;
16
- /**
17
- * Create a SPARC BCJ decoder Transform stream
18
- */
19
- export declare function createBcjSparcDecoder(properties?: Buffer, unpackSize?: number): Transform;
@@ -1,59 +0,0 @@
1
- // BCJ (SPARC) filter codec - converts SPARC branch instruction addresses
2
- // This filter makes SPARC executables more compressible by LZMA
3
- //
4
- // SPARC is big-endian. CALL instructions use 30-bit signed offsets.
5
- // The filter only transforms CALL instructions with specific byte patterns.
6
- //
7
- // Reference: https://github.com/kornelski/7z/blob/main/C/Bra.c
8
- import { bufferFrom } from 'extract-base-iterator';
9
- import createBufferingDecoder from './createBufferingDecoder.js';
10
- /**
11
- * Decode SPARC BCJ filtered data
12
- * Reverses the BCJ transformation by converting absolute addresses back to relative
13
- *
14
- * SPARC CALL instruction matching (big-endian):
15
- * - First byte 0x40 and (second byte & 0xC0) == 0x00, OR
16
- * - First byte 0x7F and (second byte & 0xC0) == 0xC0
17
- *
18
- * @param input - SPARC BCJ filtered data
19
- * @param _properties - Unused for SPARC BCJ
20
- * @param _unpackSize - Unused for SPARC BCJ
21
- * @returns Unfiltered data
22
- */ export function decodeBcjSparc(input, _properties, _unpackSize) {
23
- const output = bufferFrom(input); // Copy since we modify in place
24
- let pos = 0;
25
- // Process 4-byte aligned positions
26
- while(pos + 4 <= output.length){
27
- const b0 = output[pos];
28
- const b1 = output[pos + 1];
29
- // Check for CALL instruction with specific byte patterns:
30
- // (b0 == 0x40 && (b1 & 0xC0) == 0x00) || (b0 == 0x7F && (b1 & 0xC0) == 0xC0)
31
- if (b0 === 0x40 && (b1 & 0xc0) === 0x00 || b0 === 0x7f && (b1 & 0xc0) === 0xc0) {
32
- // Read 32-bit value (big-endian)
33
- let src = b0 << 24 | b1 << 16 | output[pos + 2] << 8 | output[pos + 3];
34
- // Shift left by 2 (multiply by 4 for word addressing)
35
- src <<= 2;
36
- // Decoding: subtract position
37
- let dest = src - pos;
38
- // Shift right by 2
39
- dest >>>= 2;
40
- // Reconstruct with sign extension and opcode
41
- // (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) | (dest & 0x3FFFFF) | 0x40000000
42
- const signBit = dest >>> 22 & 1;
43
- const signExtend = signBit ? 0x3fc00000 : 0;
44
- dest = signExtend | dest & 0x3fffff | 0x40000000;
45
- // Write back (big-endian)
46
- output[pos] = dest >>> 24 & 0xff;
47
- output[pos + 1] = dest >>> 16 & 0xff;
48
- output[pos + 2] = dest >>> 8 & 0xff;
49
- output[pos + 3] = dest & 0xff;
50
- }
51
- pos += 4;
52
- }
53
- return output;
54
- }
55
- /**
56
- * Create a SPARC BCJ decoder Transform stream
57
- */ export function createBcjSparcDecoder(properties, unpackSize) {
58
- return createBufferingDecoder(decodeBcjSparc, properties, unpackSize);
59
- }
@@ -1 +0,0 @@
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 '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":["bufferFrom","createBufferingDecoder","decodeBcjSparc","input","_properties","_unpackSize","output","pos","length","b0","b1","src","dest","signBit","signExtend","createBcjSparcDecoder","properties","unpackSize"],"mappings":"AAAA,yEAAyE;AACzE,gEAAgE;AAChE,EAAE;AACF,oEAAoE;AACpE,4EAA4E;AAC5E,EAAE;AACF,+DAA+D;AAE/D,SAASA,UAAU,QAAQ,wBAAwB;AAEnD,OAAOC,4BAA4B,8BAA8B;AAEjE;;;;;;;;;;;;CAYC,GACD,OAAO,SAASC,eAAeC,KAAa,EAAEC,WAAoB,EAAEC,WAAoB;IACtF,MAAMC,SAASN,WAAWG,QAAQ,gCAAgC;IAClE,IAAII,MAAM;IAEV,mCAAmC;IACnC,MAAOA,MAAM,KAAKD,OAAOE,MAAM,CAAE;QAC/B,MAAMC,KAAKH,MAAM,CAACC,IAAI;QACtB,MAAMG,KAAKJ,MAAM,CAACC,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,KAAOJ,MAAM,CAACC,MAAM,EAAE,IAAI,IAAKD,MAAM,CAACC,MAAM,EAAE;YAE5E,sDAAsD;YACtDI,QAAQ;YAER,8BAA8B;YAC9B,IAAIC,OAAOD,MAAMJ;YAEjB,mBAAmB;YACnBK,UAAU;YAEV,6CAA6C;YAC7C,mFAAmF;YACnF,MAAMC,UAAU,AAACD,SAAS,KAAM;YAChC,MAAME,aAAaD,UAAU,aAAa;YAC1CD,OAAOE,aAAcF,OAAO,WAAY;YAExC,0BAA0B;YAC1BN,MAAM,CAACC,IAAI,GAAG,AAACK,SAAS,KAAM;YAC9BN,MAAM,CAACC,MAAM,EAAE,GAAG,AAACK,SAAS,KAAM;YAClCN,MAAM,CAACC,MAAM,EAAE,GAAG,AAACK,SAAS,IAAK;YACjCN,MAAM,CAACC,MAAM,EAAE,GAAGK,OAAO;QAC3B;QAEAL,OAAO;IACT;IAEA,OAAOD;AACT;AAEA;;CAEC,GACD,OAAO,SAASS,sBAAsBC,UAAmB,EAAEC,UAAmB;IAC5E,OAAOhB,uBAAuBC,gBAAgBc,YAAYC;AAC5D"}
@@ -1,16 +0,0 @@
1
- import { Transform } from 'extract-base-iterator';
2
- /**
3
- * Decode Delta filtered data (synchronous, for buffered use)
4
- * Reverses the delta transformation by adding previous values
5
- *
6
- * @param input - Delta filtered data
7
- * @param properties - Optional 1-byte properties (distance - 1)
8
- * @param _unpackSize - Unused for Delta
9
- * @returns Unfiltered data
10
- */
11
- export declare function decodeDelta(input: Buffer, properties?: Buffer, _unpackSize?: number): Buffer;
12
- /**
13
- * Create a streaming Delta decoder Transform.
14
- * Processes data chunk by chunk, maintaining state between chunks.
15
- */
16
- export declare function createDeltaDecoder(properties?: Buffer, _unpackSize?: number): InstanceType<typeof Transform>;
@@ -1,66 +0,0 @@
1
- // Delta filter codec - stores differences between consecutive bytes
2
- // Useful for data with gradual changes (images, audio, sensor data)
3
- //
4
- // The Delta filter stores the difference between each byte and the byte
5
- // N positions before it, where N is the "distance" parameter (default 1).
6
- // This makes data with regular patterns more compressible.
7
- //
8
- // This implementation uses true streaming - processes data chunk by chunk
9
- // while maintaining state between chunks.
10
- import { allocBuffer, bufferFrom, Transform } from 'extract-base-iterator';
11
- /**
12
- * Decode Delta filtered data (synchronous, for buffered use)
13
- * Reverses the delta transformation by adding previous values
14
- *
15
- * @param input - Delta filtered data
16
- * @param properties - Optional 1-byte properties (distance - 1)
17
- * @param _unpackSize - Unused for Delta
18
- * @returns Unfiltered data
19
- */ export function decodeDelta(input, properties, _unpackSize) {
20
- // Distance parameter: default is 1
21
- let distance = 1;
22
- if (properties && properties.length >= 1) {
23
- // Properties byte contains (distance - 1)
24
- distance = properties[0] + 1;
25
- }
26
- const output = bufferFrom(input); // Copy since we modify in place
27
- // State buffer for multi-byte distance
28
- const state = [];
29
- for(let i = 0; i < distance; i++){
30
- state.push(0);
31
- }
32
- for(let j = 0; j < output.length; j++){
33
- const idx = j % distance;
34
- state[idx] = state[idx] + output[j] & 0xff;
35
- output[j] = state[idx];
36
- }
37
- return output;
38
- }
39
- /**
40
- * Create a streaming Delta decoder Transform.
41
- * Processes data chunk by chunk, maintaining state between chunks.
42
- */ export function createDeltaDecoder(properties, _unpackSize) {
43
- // Distance parameter: default is 1
44
- let distance = 1;
45
- if (properties && properties.length >= 1) {
46
- distance = properties[0] + 1;
47
- }
48
- // State buffer for multi-byte distance
49
- const state = [];
50
- for(let i = 0; i < distance; i++){
51
- state.push(0);
52
- }
53
- let byteIndex = 0;
54
- return new Transform({
55
- transform: (chunk, _encoding, callback)=>{
56
- const output = allocBuffer(chunk.length);
57
- for(let j = 0; j < chunk.length; j++){
58
- const idx = byteIndex % distance;
59
- state[idx] = state[idx] + chunk[j] & 0xff;
60
- output[j] = state[idx];
61
- byteIndex++;
62
- }
63
- callback(null, output);
64
- }
65
- });
66
- }
@@ -1 +0,0 @@
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//\n// This implementation uses true streaming - processes data chunk by chunk\n// while maintaining state between chunks.\n\nimport { allocBuffer, bufferFrom, Transform } from 'extract-base-iterator';\n\n/**\n * Decode Delta filtered data (synchronous, for buffered use)\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: number[] = [];\n for (let i = 0; i < distance; i++) {\n state.push(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 streaming Delta decoder Transform.\n * Processes data chunk by chunk, maintaining state between chunks.\n */\nexport function createDeltaDecoder(properties?: Buffer, _unpackSize?: number): InstanceType<typeof Transform> {\n // Distance parameter: default is 1\n let distance = 1;\n if (properties && properties.length >= 1) {\n distance = properties[0] + 1;\n }\n\n // State buffer for multi-byte distance\n const state: number[] = [];\n for (let i = 0; i < distance; i++) {\n state.push(0);\n }\n\n let byteIndex = 0;\n\n return new Transform({\n transform: (chunk: Buffer, _encoding: string, callback: (err?: Error | null, data?: Buffer) => void) => {\n const output = allocBuffer(chunk.length);\n\n for (let j = 0; j < chunk.length; j++) {\n const idx = byteIndex % distance;\n state[idx] = (state[idx] + chunk[j]) & 0xff;\n output[j] = state[idx];\n byteIndex++;\n }\n\n callback(null, output);\n },\n });\n}\n"],"names":["allocBuffer","bufferFrom","Transform","decodeDelta","input","properties","_unpackSize","distance","length","output","state","i","push","j","idx","createDeltaDecoder","byteIndex","transform","chunk","_encoding","callback"],"mappings":"AAAA,oEAAoE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ST,YAAYkB,MAAMV,MAAM;YAEvC,IAAK,IAAIK,IAAI,GAAGA,IAAIK,MAAMV,MAAM,EAAEK,IAAK;gBACrC,MAAMC,MAAME,YAAYT;gBACxBG,KAAK,CAACI,IAAI,GAAG,AAACJ,KAAK,CAACI,IAAI,GAAGI,KAAK,CAACL,EAAE,GAAI;gBACvCJ,MAAM,CAACI,EAAE,GAAGH,KAAK,CAACI,IAAI;gBACtBE;YACF;YAEAI,SAAS,MAAMX;QACjB;IACF;AACF"}
@@ -1,17 +0,0 @@
1
- import type { Transform } from 'stream';
2
- /**
3
- * Decode LZMA compressed data to buffer
4
- *
5
- * @param input - LZMA compressed data
6
- * @param properties - Properties buffer (5 bytes: lc/lp/pb + dict size)
7
- * @param unpackSize - Expected output size
8
- * @returns Decompressed data
9
- */
10
- export declare function decodeLzma(input: Buffer, properties?: Buffer, unpackSize?: number): Buffer;
11
- /**
12
- * Create an LZMA decoder Transform stream
13
- *
14
- * Note: LZMA1 has no chunk boundaries, so this buffers all input
15
- * and decompresses when the stream ends.
16
- */
17
- export declare function createLzmaDecoder(properties?: Buffer, unpackSize?: number): Transform;
@@ -1,33 +0,0 @@
1
- // LZMA codec using TypeScript LZMA decoder
2
- // LZMA properties in 7z are 5 bytes: 1 byte lc/lp/pb + 4 bytes dictionary size (little-endian)
3
- import { createLzmaDecoder as createLzmaTransform, decodeLzma as lzmaDecode } from '../../lzma/index.js';
4
- /**
5
- * Decode LZMA compressed data to buffer
6
- *
7
- * @param input - LZMA compressed data
8
- * @param properties - Properties buffer (5 bytes: lc/lp/pb + dict size)
9
- * @param unpackSize - Expected output size
10
- * @returns Decompressed data
11
- */ export function decodeLzma(input, properties, unpackSize) {
12
- if (!properties || properties.length < 5) {
13
- throw new Error('LZMA requires 5-byte properties');
14
- }
15
- if (typeof unpackSize !== 'number' || unpackSize < 0) {
16
- throw new Error('LZMA requires known unpack size');
17
- }
18
- return lzmaDecode(input, properties, unpackSize);
19
- }
20
- /**
21
- * Create an LZMA decoder Transform stream
22
- *
23
- * Note: LZMA1 has no chunk boundaries, so this buffers all input
24
- * and decompresses when the stream ends.
25
- */ export function createLzmaDecoder(properties, unpackSize) {
26
- if (!properties || properties.length < 5) {
27
- throw new Error('LZMA requires 5-byte properties');
28
- }
29
- if (typeof unpackSize !== 'number' || unpackSize < 0) {
30
- throw new Error('LZMA requires known unpack size');
31
- }
32
- return createLzmaTransform(properties, unpackSize);
33
- }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/Lzma.ts"],"sourcesContent":["// LZMA codec using TypeScript LZMA decoder\n// LZMA properties in 7z are 5 bytes: 1 byte lc/lp/pb + 4 bytes dictionary size (little-endian)\n\nimport type { Transform } from 'stream';\nimport { createLzmaDecoder as createLzmaTransform, decodeLzma as lzmaDecode } from '../../lzma/index.ts';\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\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 if (typeof unpackSize !== 'number' || unpackSize < 0) {\n throw new Error('LZMA requires known unpack size');\n }\n\n return lzmaDecode(input, properties, unpackSize) as Buffer;\n}\n\n/**\n * Create an LZMA decoder Transform stream\n *\n * Note: LZMA1 has no chunk boundaries, so this buffers all input\n * and decompresses when the stream ends.\n */\nexport function createLzmaDecoder(properties?: Buffer, unpackSize?: number): Transform {\n if (!properties || properties.length < 5) {\n throw new Error('LZMA requires 5-byte properties');\n }\n\n if (typeof unpackSize !== 'number' || unpackSize < 0) {\n throw new Error('LZMA requires known unpack size');\n }\n\n return createLzmaTransform(properties, unpackSize) as Transform;\n}\n"],"names":["createLzmaDecoder","createLzmaTransform","decodeLzma","lzmaDecode","input","properties","unpackSize","length","Error"],"mappings":"AAAA,2CAA2C;AAC3C,+FAA+F;AAG/F,SAASA,qBAAqBC,mBAAmB,EAAEC,cAAcC,UAAU,QAAQ,sBAAsB;AAEzG;;;;;;;CAOC,GACD,OAAO,SAASD,WAAWE,KAAa,EAAEC,UAAmB,EAAEC,UAAmB;IAChF,IAAI,CAACD,cAAcA,WAAWE,MAAM,GAAG,GAAG;QACxC,MAAM,IAAIC,MAAM;IAClB;IAEA,IAAI,OAAOF,eAAe,YAAYA,aAAa,GAAG;QACpD,MAAM,IAAIE,MAAM;IAClB;IAEA,OAAOL,WAAWC,OAAOC,YAAYC;AACvC;AAEA;;;;;CAKC,GACD,OAAO,SAASN,kBAAkBK,UAAmB,EAAEC,UAAmB;IACxE,IAAI,CAACD,cAAcA,WAAWE,MAAM,GAAG,GAAG;QACxC,MAAM,IAAIC,MAAM;IAClB;IAEA,IAAI,OAAOF,eAAe,YAAYA,aAAa,GAAG;QACpD,MAAM,IAAIE,MAAM;IAClB;IAEA,OAAOP,oBAAoBI,YAAYC;AACzC"}
@@ -1,20 +0,0 @@
1
- import type { Transform } from 'stream';
2
- /**
3
- * Decode LZMA2 compressed data to buffer
4
- *
5
- * @param input - LZMA2 compressed data
6
- * @param properties - Properties buffer (1 byte: dictionary size)
7
- * @param unpackSize - Expected output size (optional, for pre-allocation)
8
- * @returns Decompressed data
9
- */
10
- export declare function decodeLzma2(input: Buffer, properties?: Buffer, unpackSize?: number): Buffer;
11
- /**
12
- * Create an LZMA2 decoder Transform stream
13
- *
14
- * This is a true streaming decoder that processes LZMA2 chunks incrementally.
15
- * Memory usage is O(dictionary_size + max_chunk_size) instead of O(folder_size).
16
- *
17
- * LZMA2 chunks are up to ~2MB uncompressed, so memory is bounded regardless of
18
- * total archive size.
19
- */
20
- export declare function createLzma2Decoder(properties?: Buffer, _unpackSize?: number): Transform;
@@ -1,38 +0,0 @@
1
- // LZMA2 codec using TypeScript LZMA decoder
2
- //
3
- // LZMA2 format specification:
4
- // https://github.com/ulikunitz/xz/blob/master/doc/LZMA2.md
5
- //
6
- // Control byte values:
7
- // 0x00 = End of stream
8
- // 0x01 = Uncompressed chunk, dictionary reset
9
- // 0x02 = Uncompressed chunk, no dictionary reset
10
- // 0x80-0xFF = LZMA compressed chunk (bits encode reset flags and size)
11
- import { createLzma2Decoder as createLzma2Transform, decodeLzma2 as lzma2Decode } from '../../lzma/index.js';
12
- /**
13
- * Decode LZMA2 compressed data to buffer
14
- *
15
- * @param input - LZMA2 compressed data
16
- * @param properties - Properties buffer (1 byte: dictionary size)
17
- * @param unpackSize - Expected output size (optional, for pre-allocation)
18
- * @returns Decompressed data
19
- */ export function decodeLzma2(input, properties, unpackSize) {
20
- if (!properties || properties.length < 1) {
21
- throw new Error('LZMA2 requires properties byte');
22
- }
23
- return lzma2Decode(input, properties, unpackSize);
24
- }
25
- /**
26
- * Create an LZMA2 decoder Transform stream
27
- *
28
- * This is a true streaming decoder that processes LZMA2 chunks incrementally.
29
- * Memory usage is O(dictionary_size + max_chunk_size) instead of O(folder_size).
30
- *
31
- * LZMA2 chunks are up to ~2MB uncompressed, so memory is bounded regardless of
32
- * total archive size.
33
- */ export function createLzma2Decoder(properties, _unpackSize) {
34
- if (!properties || properties.length < 1) {
35
- throw new Error('LZMA2 requires properties byte');
36
- }
37
- return createLzma2Transform(properties);
38
- }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/Lzma2.ts"],"sourcesContent":["// LZMA2 codec using TypeScript LZMA decoder\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\nimport type { Transform } from 'stream';\nimport { createLzma2Decoder as createLzma2Transform, decodeLzma2 as lzma2Decode } from '../../lzma/index.ts';\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 (optional, for pre-allocation)\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 return lzma2Decode(input, properties, unpackSize) as Buffer;\n}\n\n/**\n * Create an LZMA2 decoder Transform stream\n *\n * This is a true streaming decoder that processes LZMA2 chunks incrementally.\n * Memory usage is O(dictionary_size + max_chunk_size) instead of O(folder_size).\n *\n * LZMA2 chunks are up to ~2MB uncompressed, so memory is bounded regardless of\n * total archive size.\n */\nexport function createLzma2Decoder(properties?: Buffer, _unpackSize?: number): Transform {\n if (!properties || properties.length < 1) {\n throw new Error('LZMA2 requires properties byte');\n }\n\n return createLzma2Transform(properties) as Transform;\n}\n"],"names":["createLzma2Decoder","createLzma2Transform","decodeLzma2","lzma2Decode","input","properties","unpackSize","length","Error","_unpackSize"],"mappings":"AAAA,4CAA4C;AAC5C,EAAE;AACF,8BAA8B;AAC9B,2DAA2D;AAC3D,EAAE;AACF,uBAAuB;AACvB,+BAA+B;AAC/B,sDAAsD;AACtD,yDAAyD;AACzD,0EAA0E;AAG1E,SAASA,sBAAsBC,oBAAoB,EAAEC,eAAeC,WAAW,QAAQ,sBAAsB;AAE7G;;;;;;;CAOC,GACD,OAAO,SAASD,YAAYE,KAAa,EAAEC,UAAmB,EAAEC,UAAmB;IACjF,IAAI,CAACD,cAAcA,WAAWE,MAAM,GAAG,GAAG;QACxC,MAAM,IAAIC,MAAM;IAClB;IAEA,OAAOL,YAAYC,OAAOC,YAAYC;AACxC;AAEA;;;;;;;;CAQC,GACD,OAAO,SAASN,mBAAmBK,UAAmB,EAAEI,WAAoB;IAC1E,IAAI,CAACJ,cAAcA,WAAWE,MAAM,GAAG,GAAG;QACxC,MAAM,IAAIC,MAAM;IAClB;IAEA,OAAOP,qBAAqBI;AAC9B"}
@@ -1,25 +0,0 @@
1
- /**
2
- * XZ Decompression Module
3
- *
4
- * XZ is a container format that wraps LZMA2 compressed data.
5
- * This module provides both synchronous and streaming XZ decoders.
6
- *
7
- * Pure JavaScript implementation, works on Node.js 0.8+
8
- */
9
- import type { Transform as TransformType } from 'stream';
10
- /**
11
- * Decompress XZ data synchronously
12
- * @param input - XZ compressed data
13
- * @returns Decompressed data
14
- */
15
- export declare function decodeXZ(input: Buffer): Buffer;
16
- /**
17
- * Create an XZ decompression Transform stream
18
- *
19
- * Note: XZ buffers all input before decompressing, as it's a single-frame format.
20
- * For true streaming with better performance on large files, consider using XZ directly
21
- * with the sync decodeXZ() function.
22
- *
23
- * @returns Transform stream that decompresses XZ data
24
- */
25
- export declare function createXZDecoder(): TransformType;