@cj-tech-master/excelts 4.2.1-canary.20260111102127.f808a37 → 4.2.1

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 (232) hide show
  1. package/THIRD_PARTY_NOTICES.md +31 -0
  2. package/dist/browser/index.browser.d.ts +0 -1
  3. package/dist/browser/index.browser.js +0 -12
  4. package/dist/browser/modules/archive/byte-queue.d.ts +18 -0
  5. package/dist/browser/modules/archive/byte-queue.js +125 -0
  6. package/dist/browser/modules/archive/{compression/compress.base.js → compress.base.js} +1 -1
  7. package/dist/browser/modules/archive/{compression/compress.browser.d.ts → compress.browser.d.ts} +8 -2
  8. package/dist/{esm/modules/archive/compression → browser/modules/archive}/compress.browser.js +11 -3
  9. package/dist/browser/modules/archive/{compression/compress.d.ts → compress.d.ts} +2 -2
  10. package/dist/{esm/modules/archive/compression → browser/modules/archive}/compress.js +1 -1
  11. package/dist/browser/modules/archive/{compression/crc32.browser.d.ts → crc32.browser.d.ts} +1 -1
  12. package/dist/browser/modules/archive/{compression/crc32.d.ts → crc32.d.ts} +1 -1
  13. package/dist/browser/modules/archive/{compression/crc32.js → crc32.js} +1 -1
  14. package/dist/browser/modules/archive/defaults.d.ts +0 -1
  15. package/dist/browser/modules/archive/defaults.js +3 -6
  16. package/dist/browser/modules/archive/{compression/deflate-fallback.js → deflate-fallback.js} +1 -1
  17. package/dist/browser/modules/archive/{unzip/extract.d.ts → extract.d.ts} +2 -2
  18. package/dist/browser/modules/archive/index.base.d.ts +4 -4
  19. package/dist/browser/modules/archive/index.base.js +6 -3
  20. package/dist/browser/modules/archive/index.browser.d.ts +4 -3
  21. package/dist/browser/modules/archive/index.browser.js +7 -3
  22. package/dist/browser/modules/archive/index.d.ts +4 -3
  23. package/dist/browser/modules/archive/index.js +5 -3
  24. package/dist/browser/modules/archive/{unzip/stream.base.d.ts → parse.base.d.ts} +2 -36
  25. package/dist/browser/modules/archive/parse.base.js +644 -0
  26. package/dist/browser/modules/archive/{unzip/stream.browser.d.ts → parse.browser.d.ts} +1 -1
  27. package/dist/{esm/modules/archive/unzip/stream.browser.js → browser/modules/archive/parse.browser.js} +110 -371
  28. package/dist/browser/modules/archive/{unzip/stream.d.ts → parse.d.ts} +2 -2
  29. package/dist/{esm/modules/archive/unzip/stream.js → browser/modules/archive/parse.js} +5 -6
  30. package/dist/browser/modules/archive/{compression/streaming-compress.browser.d.ts → streaming-compress.browser.d.ts} +2 -2
  31. package/dist/browser/modules/archive/{compression/streaming-compress.browser.js → streaming-compress.browser.js} +3 -3
  32. package/dist/browser/modules/archive/{compression/streaming-compress.d.ts → streaming-compress.d.ts} +2 -2
  33. package/dist/browser/modules/archive/{compression/streaming-compress.js → streaming-compress.js} +2 -2
  34. package/dist/browser/modules/archive/{zip/stream.d.ts → streaming-zip.d.ts} +5 -28
  35. package/dist/{esm/modules/archive/zip/stream.js → browser/modules/archive/streaming-zip.js} +48 -192
  36. package/dist/browser/modules/archive/utils/bytes.js +16 -16
  37. package/dist/browser/modules/archive/utils/parse-buffer.js +23 -21
  38. package/dist/browser/modules/archive/utils/timestamps.js +1 -62
  39. package/dist/browser/modules/archive/utils/zip-extra-fields.d.ts +1 -1
  40. package/dist/browser/modules/archive/utils/zip-extra-fields.js +14 -26
  41. package/dist/browser/modules/archive/utils/zip-extra.d.ts +18 -0
  42. package/dist/browser/modules/archive/utils/zip-extra.js +68 -0
  43. package/dist/browser/modules/archive/zip-builder.d.ts +117 -0
  44. package/dist/browser/modules/archive/zip-builder.js +292 -0
  45. package/dist/browser/modules/archive/zip-constants.d.ts +18 -0
  46. package/dist/browser/modules/archive/zip-constants.js +23 -0
  47. package/dist/{esm/modules/archive/zip → browser/modules/archive}/zip-entry-metadata.js +3 -3
  48. package/dist/{types/modules/archive/unzip → browser/modules/archive}/zip-parser.d.ts +1 -1
  49. package/dist/{esm/modules/archive/unzip → browser/modules/archive}/zip-parser.js +24 -38
  50. package/dist/browser/modules/archive/{zip-spec/zip-records.d.ts → zip-records.d.ts} +0 -20
  51. package/dist/browser/modules/archive/zip-records.js +84 -0
  52. package/dist/browser/modules/excel/stream/workbook-reader.browser.js +1 -1
  53. package/dist/browser/modules/excel/stream/workbook-writer.browser.d.ts +1 -1
  54. package/dist/browser/modules/excel/stream/workbook-writer.browser.js +1 -1
  55. package/dist/browser/modules/excel/xlsx/xlsx.browser.js +6 -3
  56. package/dist/browser/modules/excel/xlsx/xlsx.js +1 -1
  57. package/dist/browser/modules/stream/streams.browser.d.ts +30 -28
  58. package/dist/browser/modules/stream/streams.browser.js +710 -830
  59. package/dist/browser/modules/stream/streams.js +58 -140
  60. package/dist/cjs/modules/archive/byte-queue.js +129 -0
  61. package/dist/cjs/modules/archive/{compression/compress.base.js → compress.base.js} +1 -1
  62. package/dist/cjs/modules/archive/{compression/compress.browser.js → compress.browser.js} +11 -3
  63. package/dist/cjs/modules/archive/{compression/compress.js → compress.js} +1 -1
  64. package/dist/cjs/modules/archive/{compression/crc32.js → crc32.js} +1 -1
  65. package/dist/cjs/modules/archive/defaults.js +4 -7
  66. package/dist/cjs/modules/archive/{compression/deflate-fallback.js → deflate-fallback.js} +1 -1
  67. package/dist/cjs/modules/archive/index.base.js +19 -9
  68. package/dist/cjs/modules/archive/index.browser.js +10 -4
  69. package/dist/cjs/modules/archive/index.js +8 -4
  70. package/dist/cjs/modules/archive/parse.base.js +666 -0
  71. package/dist/cjs/modules/archive/{unzip/stream.browser.js → parse.browser.js} +111 -372
  72. package/dist/cjs/modules/archive/{unzip/stream.js → parse.js} +8 -9
  73. package/dist/cjs/modules/archive/{compression/streaming-compress.browser.js → streaming-compress.browser.js} +3 -3
  74. package/dist/cjs/modules/archive/{compression/streaming-compress.js → streaming-compress.js} +2 -2
  75. package/dist/cjs/modules/archive/{zip/stream.js → streaming-zip.js} +50 -194
  76. package/dist/cjs/modules/archive/utils/bytes.js +16 -16
  77. package/dist/cjs/modules/archive/utils/parse-buffer.js +23 -21
  78. package/dist/cjs/modules/archive/utils/timestamps.js +3 -64
  79. package/dist/cjs/modules/archive/utils/zip-extra-fields.js +14 -26
  80. package/dist/cjs/modules/archive/utils/zip-extra.js +74 -0
  81. package/dist/cjs/modules/archive/zip-builder.js +297 -0
  82. package/dist/cjs/modules/archive/zip-constants.js +26 -0
  83. package/dist/cjs/modules/archive/{zip/zip-entry-metadata.js → zip-entry-metadata.js} +5 -5
  84. package/dist/cjs/modules/archive/{unzip/zip-parser.js → zip-parser.js} +33 -47
  85. package/dist/cjs/modules/archive/zip-records.js +90 -0
  86. package/dist/cjs/modules/excel/stream/workbook-reader.browser.js +2 -2
  87. package/dist/cjs/modules/excel/stream/workbook-writer.browser.js +4 -4
  88. package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +9 -6
  89. package/dist/cjs/modules/excel/xlsx/xlsx.js +2 -2
  90. package/dist/cjs/modules/stream/streams.browser.js +710 -830
  91. package/dist/cjs/modules/stream/streams.js +58 -140
  92. package/dist/esm/index.browser.js +0 -12
  93. package/dist/esm/modules/archive/byte-queue.js +125 -0
  94. package/dist/esm/modules/archive/{compression/compress.base.js → compress.base.js} +1 -1
  95. package/dist/{browser/modules/archive/compression → esm/modules/archive}/compress.browser.js +11 -3
  96. package/dist/{browser/modules/archive/compression → esm/modules/archive}/compress.js +1 -1
  97. package/dist/esm/modules/archive/{compression/crc32.js → crc32.js} +1 -1
  98. package/dist/esm/modules/archive/defaults.js +3 -6
  99. package/dist/esm/modules/archive/{compression/deflate-fallback.js → deflate-fallback.js} +1 -1
  100. package/dist/esm/modules/archive/index.base.js +6 -3
  101. package/dist/esm/modules/archive/index.browser.js +7 -3
  102. package/dist/esm/modules/archive/index.js +5 -3
  103. package/dist/esm/modules/archive/parse.base.js +644 -0
  104. package/dist/{browser/modules/archive/unzip/stream.browser.js → esm/modules/archive/parse.browser.js} +110 -371
  105. package/dist/{browser/modules/archive/unzip/stream.js → esm/modules/archive/parse.js} +5 -6
  106. package/dist/esm/modules/archive/{compression/streaming-compress.browser.js → streaming-compress.browser.js} +3 -3
  107. package/dist/esm/modules/archive/{compression/streaming-compress.js → streaming-compress.js} +2 -2
  108. package/dist/{browser/modules/archive/zip/stream.js → esm/modules/archive/streaming-zip.js} +48 -192
  109. package/dist/esm/modules/archive/utils/bytes.js +16 -16
  110. package/dist/esm/modules/archive/utils/parse-buffer.js +23 -21
  111. package/dist/esm/modules/archive/utils/timestamps.js +1 -62
  112. package/dist/esm/modules/archive/utils/zip-extra-fields.js +14 -26
  113. package/dist/esm/modules/archive/utils/zip-extra.js +68 -0
  114. package/dist/esm/modules/archive/zip-builder.js +292 -0
  115. package/dist/esm/modules/archive/zip-constants.js +23 -0
  116. package/dist/{browser/modules/archive/zip → esm/modules/archive}/zip-entry-metadata.js +3 -3
  117. package/dist/{browser/modules/archive/unzip → esm/modules/archive}/zip-parser.js +24 -38
  118. package/dist/esm/modules/archive/zip-records.js +84 -0
  119. package/dist/esm/modules/excel/stream/workbook-reader.browser.js +1 -1
  120. package/dist/esm/modules/excel/stream/workbook-writer.browser.js +1 -1
  121. package/dist/esm/modules/excel/xlsx/xlsx.browser.js +6 -3
  122. package/dist/esm/modules/excel/xlsx/xlsx.js +1 -1
  123. package/dist/esm/modules/stream/streams.browser.js +710 -830
  124. package/dist/esm/modules/stream/streams.js +58 -140
  125. package/dist/iife/THIRD_PARTY_NOTICES.md +31 -0
  126. package/dist/iife/excelts.iife.js +4425 -6215
  127. package/dist/iife/excelts.iife.js.map +1 -1
  128. package/dist/iife/excelts.iife.min.js +31 -103
  129. package/dist/types/index.browser.d.ts +0 -1
  130. package/dist/types/modules/archive/byte-queue.d.ts +18 -0
  131. package/dist/types/modules/archive/{compression/compress.browser.d.ts → compress.browser.d.ts} +8 -2
  132. package/dist/types/modules/archive/defaults.d.ts +0 -1
  133. package/dist/types/modules/archive/index.base.d.ts +4 -4
  134. package/dist/types/modules/archive/index.browser.d.ts +4 -3
  135. package/dist/types/modules/archive/index.d.ts +4 -3
  136. package/dist/types/modules/archive/{unzip/stream.base.d.ts → parse.base.d.ts} +4 -38
  137. package/dist/types/modules/archive/{unzip/stream.browser.d.ts → parse.browser.d.ts} +2 -2
  138. package/dist/types/modules/archive/{unzip/stream.d.ts → parse.d.ts} +3 -3
  139. package/dist/types/modules/archive/{compression/streaming-compress.browser.d.ts → streaming-compress.browser.d.ts} +1 -1
  140. package/dist/types/modules/archive/{zip/stream.d.ts → streaming-zip.d.ts} +6 -29
  141. package/dist/types/modules/archive/utils/zip-extra-fields.d.ts +1 -1
  142. package/dist/types/modules/archive/utils/zip-extra.d.ts +18 -0
  143. package/dist/types/modules/archive/zip-builder.d.ts +117 -0
  144. package/dist/types/modules/archive/zip-constants.d.ts +18 -0
  145. package/dist/types/modules/archive/{zip/zip-entry-metadata.d.ts → zip-entry-metadata.d.ts} +1 -1
  146. package/dist/{browser/modules/archive/unzip → types/modules/archive}/zip-parser.d.ts +1 -1
  147. package/dist/types/modules/archive/{zip-spec/zip-records.d.ts → zip-records.d.ts} +0 -20
  148. package/dist/types/modules/excel/stream/workbook-writer.browser.d.ts +1 -1
  149. package/dist/types/modules/stream/streams.browser.d.ts +30 -28
  150. package/package.json +1 -5
  151. package/dist/browser/modules/archive/internal/byte-queue.d.ts +0 -33
  152. package/dist/browser/modules/archive/internal/byte-queue.js +0 -407
  153. package/dist/browser/modules/archive/io/archive-sink.d.ts +0 -9
  154. package/dist/browser/modules/archive/io/archive-sink.js +0 -77
  155. package/dist/browser/modules/archive/io/archive-source.d.ts +0 -8
  156. package/dist/browser/modules/archive/io/archive-source.js +0 -107
  157. package/dist/browser/modules/archive/unzip/index.d.ts +0 -40
  158. package/dist/browser/modules/archive/unzip/index.js +0 -164
  159. package/dist/browser/modules/archive/unzip/stream.base.js +0 -1022
  160. package/dist/browser/modules/archive/utils/async-queue.d.ts +0 -7
  161. package/dist/browser/modules/archive/utils/async-queue.js +0 -103
  162. package/dist/browser/modules/archive/utils/compressibility.d.ts +0 -10
  163. package/dist/browser/modules/archive/utils/compressibility.js +0 -57
  164. package/dist/browser/modules/archive/utils/pattern-scanner.d.ts +0 -21
  165. package/dist/browser/modules/archive/utils/pattern-scanner.js +0 -27
  166. package/dist/browser/modules/archive/zip/index.d.ts +0 -42
  167. package/dist/browser/modules/archive/zip/index.js +0 -157
  168. package/dist/browser/modules/archive/zip/zip-bytes.d.ts +0 -73
  169. package/dist/browser/modules/archive/zip/zip-bytes.js +0 -239
  170. package/dist/browser/modules/archive/zip-spec/zip-records.js +0 -126
  171. package/dist/cjs/modules/archive/internal/byte-queue.js +0 -411
  172. package/dist/cjs/modules/archive/io/archive-sink.js +0 -82
  173. package/dist/cjs/modules/archive/io/archive-source.js +0 -114
  174. package/dist/cjs/modules/archive/unzip/index.js +0 -170
  175. package/dist/cjs/modules/archive/unzip/stream.base.js +0 -1044
  176. package/dist/cjs/modules/archive/utils/async-queue.js +0 -106
  177. package/dist/cjs/modules/archive/utils/compressibility.js +0 -60
  178. package/dist/cjs/modules/archive/utils/pattern-scanner.js +0 -31
  179. package/dist/cjs/modules/archive/zip/index.js +0 -162
  180. package/dist/cjs/modules/archive/zip/zip-bytes.js +0 -242
  181. package/dist/cjs/modules/archive/zip-spec/zip-records.js +0 -136
  182. package/dist/esm/modules/archive/internal/byte-queue.js +0 -407
  183. package/dist/esm/modules/archive/io/archive-sink.js +0 -77
  184. package/dist/esm/modules/archive/io/archive-source.js +0 -107
  185. package/dist/esm/modules/archive/unzip/index.js +0 -164
  186. package/dist/esm/modules/archive/unzip/stream.base.js +0 -1022
  187. package/dist/esm/modules/archive/utils/async-queue.js +0 -103
  188. package/dist/esm/modules/archive/utils/compressibility.js +0 -57
  189. package/dist/esm/modules/archive/utils/pattern-scanner.js +0 -27
  190. package/dist/esm/modules/archive/zip/index.js +0 -157
  191. package/dist/esm/modules/archive/zip/zip-bytes.js +0 -239
  192. package/dist/esm/modules/archive/zip-spec/zip-records.js +0 -126
  193. package/dist/types/modules/archive/internal/byte-queue.d.ts +0 -33
  194. package/dist/types/modules/archive/io/archive-sink.d.ts +0 -9
  195. package/dist/types/modules/archive/io/archive-source.d.ts +0 -8
  196. package/dist/types/modules/archive/unzip/index.d.ts +0 -40
  197. package/dist/types/modules/archive/utils/async-queue.d.ts +0 -7
  198. package/dist/types/modules/archive/utils/compressibility.d.ts +0 -10
  199. package/dist/types/modules/archive/utils/pattern-scanner.d.ts +0 -21
  200. package/dist/types/modules/archive/zip/index.d.ts +0 -42
  201. package/dist/types/modules/archive/zip/zip-bytes.d.ts +0 -73
  202. /package/dist/browser/modules/archive/{compression/compress.base.d.ts → compress.base.d.ts} +0 -0
  203. /package/dist/browser/modules/archive/{compression/crc32.base.d.ts → crc32.base.d.ts} +0 -0
  204. /package/dist/browser/modules/archive/{compression/crc32.base.js → crc32.base.js} +0 -0
  205. /package/dist/browser/modules/archive/{compression/crc32.browser.js → crc32.browser.js} +0 -0
  206. /package/dist/browser/modules/archive/{compression/deflate-fallback.d.ts → deflate-fallback.d.ts} +0 -0
  207. /package/dist/browser/modules/archive/{unzip/extract.js → extract.js} +0 -0
  208. /package/dist/browser/modules/archive/{compression/streaming-compress.base.d.ts → streaming-compress.base.d.ts} +0 -0
  209. /package/dist/browser/modules/archive/{compression/streaming-compress.base.js → streaming-compress.base.js} +0 -0
  210. /package/dist/browser/modules/archive/{zip-spec/zip-entry-info.d.ts → zip-entry-info.d.ts} +0 -0
  211. /package/dist/browser/modules/archive/{zip-spec/zip-entry-info.js → zip-entry-info.js} +0 -0
  212. /package/dist/browser/modules/archive/{zip/zip-entry-metadata.d.ts → zip-entry-metadata.d.ts} +0 -0
  213. /package/dist/cjs/modules/archive/{compression/crc32.base.js → crc32.base.js} +0 -0
  214. /package/dist/cjs/modules/archive/{compression/crc32.browser.js → crc32.browser.js} +0 -0
  215. /package/dist/cjs/modules/archive/{unzip/extract.js → extract.js} +0 -0
  216. /package/dist/cjs/modules/archive/{compression/streaming-compress.base.js → streaming-compress.base.js} +0 -0
  217. /package/dist/cjs/modules/archive/{zip-spec/zip-entry-info.js → zip-entry-info.js} +0 -0
  218. /package/dist/esm/modules/archive/{compression/crc32.base.js → crc32.base.js} +0 -0
  219. /package/dist/esm/modules/archive/{compression/crc32.browser.js → crc32.browser.js} +0 -0
  220. /package/dist/esm/modules/archive/{unzip/extract.js → extract.js} +0 -0
  221. /package/dist/esm/modules/archive/{compression/streaming-compress.base.js → streaming-compress.base.js} +0 -0
  222. /package/dist/esm/modules/archive/{zip-spec/zip-entry-info.js → zip-entry-info.js} +0 -0
  223. /package/dist/types/modules/archive/{compression/compress.base.d.ts → compress.base.d.ts} +0 -0
  224. /package/dist/types/modules/archive/{compression/compress.d.ts → compress.d.ts} +0 -0
  225. /package/dist/types/modules/archive/{compression/crc32.base.d.ts → crc32.base.d.ts} +0 -0
  226. /package/dist/types/modules/archive/{compression/crc32.browser.d.ts → crc32.browser.d.ts} +0 -0
  227. /package/dist/types/modules/archive/{compression/crc32.d.ts → crc32.d.ts} +0 -0
  228. /package/dist/types/modules/archive/{compression/deflate-fallback.d.ts → deflate-fallback.d.ts} +0 -0
  229. /package/dist/types/modules/archive/{unzip/extract.d.ts → extract.d.ts} +0 -0
  230. /package/dist/types/modules/archive/{compression/streaming-compress.base.d.ts → streaming-compress.base.d.ts} +0 -0
  231. /package/dist/types/modules/archive/{compression/streaming-compress.d.ts → streaming-compress.d.ts} +0 -0
  232. /package/dist/types/modules/archive/{zip-spec/zip-entry-info.d.ts → zip-entry-info.d.ts} +0 -0
@@ -1,136 +0,0 @@
1
- "use strict";
2
- /**
3
- * ZIP record builders (PKWARE APPNOTE)
4
- *
5
- * Shared by streaming zip writer and buffer zip builder.
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.ZIP_END_OF_CENTRAL_DIR_FIXED_SIZE = exports.ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE = exports.ZIP_LOCAL_FILE_HEADER_FIXED_SIZE = exports.UINT32_MAX = exports.UINT16_MAX = exports.FLAG_DATA_DESCRIPTOR = exports.FLAG_UTF8 = exports.COMPRESSION_DEFLATE = exports.COMPRESSION_STORE = exports.VERSION_MADE_BY = exports.VERSION_NEEDED = exports.ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIG = exports.ZIP64_END_OF_CENTRAL_DIR_SIG = exports.DATA_DESCRIPTOR_SIG = exports.END_OF_CENTRAL_DIR_SIG = exports.CENTRAL_DIR_HEADER_SIG = exports.LOCAL_FILE_HEADER_SIG = void 0;
9
- exports.writeLocalFileHeaderInto = writeLocalFileHeaderInto;
10
- exports.buildLocalFileHeader = buildLocalFileHeader;
11
- exports.writeCentralDirectoryHeaderInto = writeCentralDirectoryHeaderInto;
12
- exports.buildCentralDirectoryHeader = buildCentralDirectoryHeader;
13
- exports.writeEndOfCentralDirectoryInto = writeEndOfCentralDirectoryInto;
14
- exports.buildEndOfCentralDirectory = buildEndOfCentralDirectory;
15
- exports.buildDataDescriptor = buildDataDescriptor;
16
- // =============================================================================
17
- // ZIP format constants (PKWARE APPNOTE)
18
- // =============================================================================
19
- // Signatures
20
- exports.LOCAL_FILE_HEADER_SIG = 0x04034b50;
21
- exports.CENTRAL_DIR_HEADER_SIG = 0x02014b50;
22
- exports.END_OF_CENTRAL_DIR_SIG = 0x06054b50;
23
- exports.DATA_DESCRIPTOR_SIG = 0x08074b50;
24
- exports.ZIP64_END_OF_CENTRAL_DIR_SIG = 0x06064b50;
25
- exports.ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIG = 0x07064b50;
26
- // Versions
27
- exports.VERSION_NEEDED = 20; // 2.0 - supports DEFLATE
28
- exports.VERSION_MADE_BY = 20; // 2.0
29
- // Compression methods
30
- exports.COMPRESSION_STORE = 0;
31
- exports.COMPRESSION_DEFLATE = 8;
32
- // General purpose bit flags
33
- exports.FLAG_UTF8 = 0x0800;
34
- exports.FLAG_DATA_DESCRIPTOR = 0x0008;
35
- // ZIP64 / sentinel sizes
36
- exports.UINT16_MAX = 0xffff;
37
- exports.UINT32_MAX = 0xffffffff;
38
- exports.ZIP_LOCAL_FILE_HEADER_FIXED_SIZE = 30;
39
- exports.ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE = 46;
40
- exports.ZIP_END_OF_CENTRAL_DIR_FIXED_SIZE = 22;
41
- function writeLocalFileHeaderInto(out, view, offset, input) {
42
- const versionNeeded = input.versionNeeded ?? exports.VERSION_NEEDED;
43
- view.setUint32(offset + 0, exports.LOCAL_FILE_HEADER_SIG, true);
44
- view.setUint16(offset + 4, versionNeeded, true);
45
- view.setUint16(offset + 6, input.flags, true);
46
- view.setUint16(offset + 8, input.compressionMethod, true);
47
- view.setUint16(offset + 10, input.dosTime, true);
48
- view.setUint16(offset + 12, input.dosDate, true);
49
- view.setUint32(offset + 14, input.crc32, true);
50
- view.setUint32(offset + 18, input.compressedSize, true);
51
- view.setUint32(offset + 22, input.uncompressedSize, true);
52
- view.setUint16(offset + 26, input.fileName.length, true);
53
- view.setUint16(offset + 28, input.extraField.length, true);
54
- out.set(input.fileName, offset + exports.ZIP_LOCAL_FILE_HEADER_FIXED_SIZE);
55
- if (input.extraField.length > 0) {
56
- out.set(input.extraField, offset + exports.ZIP_LOCAL_FILE_HEADER_FIXED_SIZE + input.fileName.length);
57
- }
58
- return exports.ZIP_LOCAL_FILE_HEADER_FIXED_SIZE + input.fileName.length + input.extraField.length;
59
- }
60
- function buildLocalFileHeader(input) {
61
- const header = new Uint8Array(exports.ZIP_LOCAL_FILE_HEADER_FIXED_SIZE + input.fileName.length + input.extraField.length);
62
- const view = new DataView(header.buffer, header.byteOffset, header.byteLength);
63
- writeLocalFileHeaderInto(header, view, 0, input);
64
- return header;
65
- }
66
- function writeCentralDirectoryHeaderInto(out, view, offset, input) {
67
- const versionMadeBy = input.versionMadeBy ?? exports.VERSION_MADE_BY;
68
- const versionNeeded = input.versionNeeded ?? exports.VERSION_NEEDED;
69
- const externalAttributes = input.externalAttributes ?? 0;
70
- view.setUint32(offset + 0, exports.CENTRAL_DIR_HEADER_SIG, true);
71
- view.setUint16(offset + 4, versionMadeBy, true);
72
- view.setUint16(offset + 6, versionNeeded, true);
73
- view.setUint16(offset + 8, input.flags, true);
74
- view.setUint16(offset + 10, input.compressionMethod, true);
75
- view.setUint16(offset + 12, input.dosTime, true);
76
- view.setUint16(offset + 14, input.dosDate, true);
77
- view.setUint32(offset + 16, input.crc32, true);
78
- view.setUint32(offset + 20, input.compressedSize, true);
79
- view.setUint32(offset + 24, input.uncompressedSize, true);
80
- view.setUint16(offset + 28, input.fileName.length, true);
81
- view.setUint16(offset + 30, input.extraField.length, true);
82
- view.setUint16(offset + 32, input.comment.length, true);
83
- view.setUint16(offset + 34, 0, true); // disk number start
84
- view.setUint16(offset + 36, 0, true); // internal file attributes
85
- view.setUint32(offset + 38, externalAttributes, true);
86
- view.setUint32(offset + 42, input.localHeaderOffset, true);
87
- out.set(input.fileName, offset + exports.ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE);
88
- if (input.extraField.length > 0) {
89
- out.set(input.extraField, offset + exports.ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE + input.fileName.length);
90
- }
91
- if (input.comment.length > 0) {
92
- out.set(input.comment, offset + exports.ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE + input.fileName.length + input.extraField.length);
93
- }
94
- return (exports.ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE +
95
- input.fileName.length +
96
- input.extraField.length +
97
- input.comment.length);
98
- }
99
- function buildCentralDirectoryHeader(input) {
100
- const header = new Uint8Array(exports.ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE +
101
- input.fileName.length +
102
- input.extraField.length +
103
- input.comment.length);
104
- const view = new DataView(header.buffer, header.byteOffset, header.byteLength);
105
- writeCentralDirectoryHeaderInto(header, view, 0, input);
106
- return header;
107
- }
108
- function writeEndOfCentralDirectoryInto(out, view, offset, input) {
109
- view.setUint32(offset + 0, exports.END_OF_CENTRAL_DIR_SIG, true);
110
- view.setUint16(offset + 4, 0, true);
111
- view.setUint16(offset + 6, 0, true);
112
- view.setUint16(offset + 8, input.entryCount, true);
113
- view.setUint16(offset + 10, input.entryCount, true);
114
- view.setUint32(offset + 12, input.centralDirSize, true);
115
- view.setUint32(offset + 16, input.centralDirOffset, true);
116
- view.setUint16(offset + 20, input.comment.length, true);
117
- if (input.comment.length > 0) {
118
- out.set(input.comment, offset + exports.ZIP_END_OF_CENTRAL_DIR_FIXED_SIZE);
119
- }
120
- return exports.ZIP_END_OF_CENTRAL_DIR_FIXED_SIZE + input.comment.length;
121
- }
122
- function buildEndOfCentralDirectory(input) {
123
- const record = new Uint8Array(exports.ZIP_END_OF_CENTRAL_DIR_FIXED_SIZE + input.comment.length);
124
- const view = new DataView(record.buffer, record.byteOffset, record.byteLength);
125
- writeEndOfCentralDirectoryInto(record, view, 0, input);
126
- return record;
127
- }
128
- function buildDataDescriptor(crc32, compressedSize, uncompressedSize) {
129
- const descriptor = new Uint8Array(16);
130
- const view = new DataView(descriptor.buffer);
131
- view.setUint32(0, exports.DATA_DESCRIPTOR_SIG, true);
132
- view.setUint32(4, crc32, true);
133
- view.setUint32(8, compressedSize, true);
134
- view.setUint32(12, uncompressedSize, true);
135
- return descriptor;
136
- }
@@ -1,407 +0,0 @@
1
- import { indexOfUint8ArrayPattern } from "../utils/bytes.js";
2
- export class ByteQueue {
3
- constructor(initial) {
4
- // Store data as immutable chunks to avoid copying on append.
5
- this._chunks = [];
6
- this._headOffset = 0;
7
- this._length = 0;
8
- // Lazily materialized contiguous view (used only by callers that require a single buffer).
9
- this._cachedView = null;
10
- this._cachedLength = 0;
11
- if (initial && initial.length > 0) {
12
- this.reset(initial);
13
- }
14
- }
15
- get length() {
16
- return this._length;
17
- }
18
- isEmpty() {
19
- return this.length === 0;
20
- }
21
- view() {
22
- if (this._length === 0) {
23
- return ByteQueue.EMPTY;
24
- }
25
- // Fast path: single chunk.
26
- if (this._chunks.length === 1) {
27
- const c = this._chunks[0];
28
- return c.subarray(this._headOffset, this._headOffset + this._length);
29
- }
30
- if (this._cachedView && this._cachedLength === this._length) {
31
- return this._cachedView;
32
- }
33
- const out = new Uint8Array(this._length);
34
- let offset = 0;
35
- for (let i = 0; i < this._chunks.length; i++) {
36
- const c = this._chunks[i];
37
- const start = i === 0 ? this._headOffset : 0;
38
- const end = i === this._chunks.length - 1 ? start + (this._length - offset) : c.length;
39
- out.set(c.subarray(start, end), offset);
40
- offset += end - start;
41
- if (offset >= out.length) {
42
- break;
43
- }
44
- }
45
- this._cachedView = out;
46
- this._cachedLength = this._length;
47
- return out;
48
- }
49
- reset(data) {
50
- this._cachedView = null;
51
- this._cachedLength = 0;
52
- this._chunks = [];
53
- this._headOffset = 0;
54
- this._length = 0;
55
- if (!data || data.length === 0) {
56
- return;
57
- }
58
- // Keep a private copy to ensure future writes cannot mutate the source.
59
- const copy = new Uint8Array(data.length);
60
- copy.set(data);
61
- this._chunks = [copy];
62
- this._headOffset = 0;
63
- this._length = copy.length;
64
- }
65
- append(chunk) {
66
- if (chunk.length === 0) {
67
- return;
68
- }
69
- this._cachedView = null;
70
- this._cachedLength = 0;
71
- this._chunks.push(chunk);
72
- this._length += chunk.length;
73
- }
74
- read(length) {
75
- if (length <= 0) {
76
- return new Uint8Array(0);
77
- }
78
- if (length > this._length) {
79
- throw new RangeError("ByteQueue: read beyond available data");
80
- }
81
- this._cachedView = null;
82
- this._cachedLength = 0;
83
- if (this._chunks.length === 1) {
84
- const c = this._chunks[0];
85
- const start = this._headOffset;
86
- const end = start + length;
87
- const out = c.subarray(start, end);
88
- this._headOffset = end;
89
- this._length -= length;
90
- if (this._length === 0) {
91
- this._chunks = [];
92
- this._headOffset = 0;
93
- }
94
- else if (this._headOffset >= c.length) {
95
- this._chunks.shift();
96
- this._headOffset = 0;
97
- }
98
- return out;
99
- }
100
- // Slow path: spans multiple chunks, copy into a single output buffer.
101
- const out = new Uint8Array(length);
102
- let outOffset = 0;
103
- let remaining = length;
104
- while (remaining > 0) {
105
- const c = this._chunks[0];
106
- const start = this._headOffset;
107
- const available = c.length - start;
108
- const toCopy = Math.min(available, remaining);
109
- out.set(c.subarray(start, start + toCopy), outOffset);
110
- outOffset += toCopy;
111
- remaining -= toCopy;
112
- this._headOffset += toCopy;
113
- this._length -= toCopy;
114
- if (this._headOffset >= c.length) {
115
- this._chunks.shift();
116
- this._headOffset = 0;
117
- }
118
- }
119
- if (this._length === 0) {
120
- this._chunks = [];
121
- this._headOffset = 0;
122
- }
123
- return out;
124
- }
125
- /**
126
- * Return a list of chunk views totaling `length` bytes without consuming.
127
- *
128
- * This avoids materializing a contiguous buffer for streaming write paths.
129
- */
130
- peekChunks(length) {
131
- if (length <= 0) {
132
- return [];
133
- }
134
- if (length > this._length) {
135
- throw new RangeError("ByteQueue: peek beyond available data");
136
- }
137
- // Fast path: single chunk.
138
- if (this._chunks.length === 1) {
139
- const c = this._chunks[0];
140
- const start = this._headOffset;
141
- return [c.subarray(start, start + length)];
142
- }
143
- const parts = [];
144
- let remaining = length;
145
- for (let i = 0; i < this._chunks.length && remaining > 0; i++) {
146
- const c = this._chunks[i];
147
- const start = i === 0 ? this._headOffset : 0;
148
- const avail = c.length - start;
149
- if (avail <= 0) {
150
- continue;
151
- }
152
- const toTake = Math.min(avail, remaining);
153
- parts.push(c.subarray(start, start + toTake));
154
- remaining -= toTake;
155
- }
156
- return parts;
157
- }
158
- discard(length) {
159
- if (length <= 0) {
160
- return;
161
- }
162
- if (length >= this._length) {
163
- this._chunks = [];
164
- this._headOffset = 0;
165
- this._length = 0;
166
- this._cachedView = null;
167
- this._cachedLength = 0;
168
- return;
169
- }
170
- this._cachedView = null;
171
- this._cachedLength = 0;
172
- let remaining = length;
173
- while (remaining > 0) {
174
- const c = this._chunks[0];
175
- const start = this._headOffset;
176
- const available = c.length - start;
177
- const toDrop = Math.min(available, remaining);
178
- this._headOffset += toDrop;
179
- this._length -= toDrop;
180
- remaining -= toDrop;
181
- if (this._headOffset >= c.length) {
182
- this._chunks.shift();
183
- this._headOffset = 0;
184
- }
185
- }
186
- if (this._length === 0) {
187
- this._chunks = [];
188
- this._headOffset = 0;
189
- }
190
- }
191
- /**
192
- * Find the first index of `pattern` within the queue.
193
- *
194
- * This avoids materializing a contiguous `view()` for common small patterns
195
- * (ZIP signatures are typically 2-4 bytes).
196
- */
197
- indexOfPattern(pattern, startIndex = 0) {
198
- const patLen = pattern.length;
199
- if (patLen === 0) {
200
- return 0;
201
- }
202
- const len = this._length;
203
- if (patLen > len) {
204
- return -1;
205
- }
206
- let start = startIndex | 0;
207
- if (start < 0) {
208
- start = 0;
209
- }
210
- if (start > len - patLen) {
211
- return -1;
212
- }
213
- // Fast path: single chunk.
214
- if (this._chunks.length === 1) {
215
- const c = this._chunks[0];
216
- const base = this._headOffset;
217
- const view = c.subarray(base, base + len);
218
- // Delegate to native indexOf checks for 1..4 bytes.
219
- if (patLen === 1) {
220
- return view.indexOf(pattern[0], start);
221
- }
222
- return indexOfUint8ArrayPattern(view, pattern, start);
223
- }
224
- // Multi-chunk: optimize only for very common small patterns.
225
- if (patLen > 4) {
226
- // Rare: materialize view.
227
- const v = this.view();
228
- return indexOfUint8ArrayPattern(v, pattern, start);
229
- }
230
- const b0 = pattern[0];
231
- const b1 = patLen >= 2 ? pattern[1] : 0;
232
- const b2 = patLen >= 3 ? pattern[2] : 0;
233
- const b3 = patLen >= 4 ? pattern[3] : 0;
234
- const chunks = this._chunks;
235
- const peekByteAcrossChunks = (chunkIndex, absoluteIndex) => {
236
- let ci = chunkIndex;
237
- let idx = absoluteIndex;
238
- while (ci < chunks.length) {
239
- const c = chunks[ci];
240
- if (idx < c.length) {
241
- return c[idx] | 0;
242
- }
243
- idx -= c.length;
244
- ci++;
245
- }
246
- return null;
247
- };
248
- let globalBase = 0;
249
- for (let ci = 0; ci < chunks.length; ci++) {
250
- const c = chunks[ci];
251
- const chunkOffset = ci === 0 ? this._headOffset : 0;
252
- const chunkLen = c.length - chunkOffset;
253
- if (chunkLen <= 0) {
254
- continue;
255
- }
256
- const chunkStartGlobal = globalBase;
257
- const chunkEndGlobal = chunkStartGlobal + chunkLen;
258
- // Compute local start for this chunk.
259
- const localStart = start <= chunkStartGlobal
260
- ? chunkOffset
261
- : start >= chunkEndGlobal
262
- ? c.length
263
- : chunkOffset + (start - chunkStartGlobal);
264
- if (localStart > c.length - 1) {
265
- globalBase += chunkLen;
266
- continue;
267
- }
268
- const lastLocal = c.length - 1;
269
- let i = c.indexOf(b0, localStart);
270
- while (i !== -1 && i <= lastLocal) {
271
- const globalPos = chunkStartGlobal + (i - chunkOffset);
272
- if (globalPos > len - patLen) {
273
- return -1;
274
- }
275
- if (patLen === 1) {
276
- return globalPos;
277
- }
278
- // Fast path: match stays fully inside the current chunk.
279
- // Avoid calling peekByte() which walks the chunk list per byte.
280
- const staysInChunk = i + patLen <= c.length;
281
- if (staysInChunk) {
282
- if (c[i + 1] !== b1) {
283
- i = c.indexOf(b0, i + 1);
284
- continue;
285
- }
286
- if (patLen === 2) {
287
- return globalPos;
288
- }
289
- if (c[i + 2] !== b2) {
290
- i = c.indexOf(b0, i + 1);
291
- continue;
292
- }
293
- if (patLen === 3) {
294
- return globalPos;
295
- }
296
- if (c[i + 3] !== b3) {
297
- i = c.indexOf(b0, i + 1);
298
- continue;
299
- }
300
- return globalPos;
301
- }
302
- // Slow path: pattern spans chunks.
303
- const b1v = peekByteAcrossChunks(ci, i + 1);
304
- if (b1v === null || b1v !== b1) {
305
- i = c.indexOf(b0, i + 1);
306
- continue;
307
- }
308
- if (patLen === 2) {
309
- return globalPos;
310
- }
311
- const b2v = peekByteAcrossChunks(ci, i + 2);
312
- if (b2v === null || b2v !== b2) {
313
- i = c.indexOf(b0, i + 1);
314
- continue;
315
- }
316
- if (patLen === 3) {
317
- return globalPos;
318
- }
319
- const b3v = peekByteAcrossChunks(ci, i + 3);
320
- if (b3v === null || b3v !== b3) {
321
- i = c.indexOf(b0, i + 1);
322
- continue;
323
- }
324
- return globalPos;
325
- }
326
- globalBase += chunkLen;
327
- }
328
- return -1;
329
- }
330
- /** Peek a little-endian uint32 at `offset` without consuming bytes. Returns null if not enough bytes. */
331
- peekUint32LE(offset) {
332
- const off = offset | 0;
333
- if (off < 0 || off + 4 > this._length) {
334
- return null;
335
- }
336
- // Try to read contiguously from a single chunk to avoid 4x chunk-walk.
337
- const chunks = this._chunks;
338
- let remaining = off;
339
- for (let i = 0; i < chunks.length; i++) {
340
- const c = chunks[i];
341
- const start = i === 0 ? this._headOffset : 0;
342
- const avail = c.length - start;
343
- if (remaining < avail) {
344
- const idx = start + remaining;
345
- if (idx + 4 <= c.length) {
346
- const b0 = c[idx] | 0;
347
- const b1 = c[idx + 1] | 0;
348
- const b2 = c[idx + 2] | 0;
349
- const b3 = c[idx + 3] | 0;
350
- return (b0 | (b1 << 8) | (b2 << 16) | (b3 << 24)) >>> 0;
351
- }
352
- // Cross-chunk read (rare): walk forward across chunks once.
353
- const b0 = c[idx] | 0;
354
- let b1 = 0;
355
- let b2 = 0;
356
- let b3 = 0;
357
- let ci = i;
358
- let pos = idx + 1;
359
- for (let k = 1; k < 4; k++) {
360
- while (ci < chunks.length) {
361
- const cc = chunks[ci];
362
- if (pos < cc.length) {
363
- const v = cc[pos] | 0;
364
- if (k === 1) {
365
- b1 = v;
366
- }
367
- else if (k === 2) {
368
- b2 = v;
369
- }
370
- else {
371
- b3 = v;
372
- }
373
- pos++;
374
- break;
375
- }
376
- ci++;
377
- pos = 0;
378
- }
379
- }
380
- return (b0 | (b1 << 8) | (b2 << 16) | (b3 << 24)) >>> 0;
381
- }
382
- remaining -= avail;
383
- }
384
- // Should be unreachable due to bounds check above.
385
- return null;
386
- }
387
- /** Peek a single byte at `offset` without consuming bytes. */
388
- peekByte(offset) {
389
- const off = offset | 0;
390
- if (off < 0 || off >= this._length) {
391
- throw new RangeError("ByteQueue: peek beyond available data");
392
- }
393
- let remaining = off;
394
- for (let i = 0; i < this._chunks.length; i++) {
395
- const c = this._chunks[i];
396
- const start = i === 0 ? this._headOffset : 0;
397
- const avail = c.length - start;
398
- if (remaining < avail) {
399
- return c[start + remaining] | 0;
400
- }
401
- remaining -= avail;
402
- }
403
- // Should be unreachable.
404
- throw new RangeError("ByteQueue: peek beyond available data");
405
- }
406
- }
407
- ByteQueue.EMPTY = new Uint8Array(0);
@@ -1,77 +0,0 @@
1
- export function isWritableStream(value) {
2
- return !!value && typeof value === "object" && typeof value.getWriter === "function";
3
- }
4
- function once(emitter, event) {
5
- return new Promise((resolve, reject) => {
6
- const onError = (err) => {
7
- cleanup();
8
- reject(err instanceof Error ? err : new Error(String(err)));
9
- };
10
- const onDone = () => {
11
- cleanup();
12
- resolve();
13
- };
14
- const cleanup = () => {
15
- emitter.off?.("error", onError);
16
- emitter.off?.(event, onDone);
17
- emitter.removeListener?.("error", onError);
18
- emitter.removeListener?.(event, onDone);
19
- };
20
- emitter.on?.("error", onError);
21
- emitter.on?.(event, onDone);
22
- });
23
- }
24
- export async function pipeIterableToSink(iterable, sink) {
25
- if (isWritableStream(sink)) {
26
- const writer = sink.getWriter();
27
- try {
28
- for await (const chunk of iterable) {
29
- await writer.write(chunk);
30
- }
31
- await writer.close();
32
- }
33
- finally {
34
- try {
35
- writer.releaseLock();
36
- }
37
- catch {
38
- // Ignore
39
- }
40
- }
41
- return;
42
- }
43
- // Node-style Writable
44
- for await (const chunk of iterable) {
45
- const ok = sink.write(chunk);
46
- if (ok === false && typeof sink.once === "function") {
47
- await once(sink, "drain");
48
- }
49
- }
50
- if (typeof sink.end === "function") {
51
- sink.end();
52
- }
53
- if (typeof sink.once === "function") {
54
- await Promise.race([once(sink, "finish"), once(sink, "close")]);
55
- }
56
- }
57
- export async function collect(iterable) {
58
- const chunks = [];
59
- let total = 0;
60
- for await (const chunk of iterable) {
61
- chunks.push(chunk);
62
- total += chunk.length;
63
- }
64
- if (chunks.length === 0) {
65
- return new Uint8Array(0);
66
- }
67
- if (chunks.length === 1) {
68
- return chunks[0];
69
- }
70
- const out = new Uint8Array(total);
71
- let offset = 0;
72
- for (const chunk of chunks) {
73
- out.set(chunk, offset);
74
- offset += chunk.length;
75
- }
76
- return out;
77
- }