@cj-tech-master/excelts 4.2.1 → 4.2.2-canary.20260115044841.88820eb

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (331) hide show
  1. package/THIRD_PARTY_NOTICES.md +0 -31
  2. package/dist/browser/index.browser.d.ts +1 -0
  3. package/dist/browser/index.browser.js +12 -0
  4. package/dist/{esm/modules/archive → browser/modules/archive/compression}/compress.base.js +1 -1
  5. package/dist/{types/modules/archive → browser/modules/archive/compression}/compress.browser.d.ts +2 -8
  6. package/dist/browser/modules/archive/{compress.browser.js → compression/compress.browser.js} +3 -11
  7. package/dist/browser/modules/archive/{compress.d.ts → compression/compress.d.ts} +2 -2
  8. package/dist/{esm/modules/archive → browser/modules/archive/compression}/compress.js +1 -1
  9. package/dist/browser/modules/archive/{crc32.browser.d.ts → compression/crc32.browser.d.ts} +1 -1
  10. package/dist/browser/modules/archive/{crc32.d.ts → compression/crc32.d.ts} +1 -1
  11. package/dist/browser/modules/archive/{crc32.js → compression/crc32.js} +1 -1
  12. package/dist/browser/modules/archive/{deflate-fallback.js → compression/deflate-fallback.js} +1 -1
  13. package/dist/browser/modules/archive/{streaming-compress.browser.d.ts → compression/streaming-compress.browser.d.ts} +2 -2
  14. package/dist/browser/modules/archive/{streaming-compress.browser.js → compression/streaming-compress.browser.js} +3 -3
  15. package/dist/browser/modules/archive/{streaming-compress.d.ts → compression/streaming-compress.d.ts} +2 -2
  16. package/dist/browser/modules/archive/{streaming-compress.js → compression/streaming-compress.js} +2 -2
  17. package/dist/browser/modules/archive/defaults.d.ts +1 -0
  18. package/dist/browser/modules/archive/defaults.js +6 -3
  19. package/dist/browser/modules/archive/index.base.d.ts +4 -4
  20. package/dist/browser/modules/archive/index.base.js +3 -6
  21. package/dist/browser/modules/archive/index.browser.d.ts +3 -4
  22. package/dist/browser/modules/archive/index.browser.js +3 -7
  23. package/dist/browser/modules/archive/index.d.ts +3 -4
  24. package/dist/browser/modules/archive/index.js +3 -5
  25. package/dist/browser/modules/archive/internal/byte-queue.d.ts +33 -0
  26. package/dist/browser/modules/archive/internal/byte-queue.js +407 -0
  27. package/dist/browser/modules/archive/io/archive-sink.d.ts +8 -0
  28. package/dist/browser/modules/archive/io/archive-sink.js +45 -0
  29. package/dist/browser/modules/archive/io/archive-source.d.ts +6 -0
  30. package/dist/browser/modules/archive/io/archive-source.js +100 -0
  31. package/dist/browser/modules/archive/{extract.d.ts → unzip/extract.d.ts} +2 -2
  32. package/dist/browser/modules/archive/unzip/index.d.ts +40 -0
  33. package/dist/browser/modules/archive/unzip/index.js +164 -0
  34. package/dist/browser/modules/archive/{parse.base.d.ts → unzip/stream.base.d.ts} +36 -2
  35. package/dist/browser/modules/archive/unzip/stream.base.js +1022 -0
  36. package/dist/browser/modules/archive/{parse.browser.d.ts → unzip/stream.browser.d.ts} +1 -1
  37. package/dist/browser/modules/archive/{parse.browser.js → unzip/stream.browser.js} +371 -110
  38. package/dist/browser/modules/archive/{parse.d.ts → unzip/stream.d.ts} +2 -2
  39. package/dist/{esm/modules/archive/parse.js → browser/modules/archive/unzip/stream.js} +6 -5
  40. package/dist/browser/modules/archive/{zip-parser.d.ts → unzip/zip-parser.d.ts} +1 -1
  41. package/dist/{esm/modules/archive → browser/modules/archive/unzip}/zip-parser.js +38 -24
  42. package/dist/browser/modules/archive/utils/async-queue.d.ts +7 -0
  43. package/dist/browser/modules/archive/utils/async-queue.js +103 -0
  44. package/dist/browser/modules/archive/utils/bytes.js +16 -16
  45. package/dist/browser/modules/archive/utils/compressibility.d.ts +10 -0
  46. package/dist/browser/modules/archive/utils/compressibility.js +57 -0
  47. package/dist/browser/modules/archive/utils/parse-buffer.js +21 -23
  48. package/dist/browser/modules/archive/utils/pattern-scanner.d.ts +21 -0
  49. package/dist/browser/modules/archive/utils/pattern-scanner.js +27 -0
  50. package/dist/browser/modules/archive/utils/timestamps.js +62 -1
  51. package/dist/browser/modules/archive/utils/zip-extra-fields.d.ts +1 -1
  52. package/dist/browser/modules/archive/utils/zip-extra-fields.js +26 -14
  53. package/dist/browser/modules/archive/zip/index.d.ts +42 -0
  54. package/dist/browser/modules/archive/zip/index.js +157 -0
  55. package/dist/browser/modules/archive/{streaming-zip.d.ts → zip/stream.d.ts} +28 -5
  56. package/dist/browser/modules/archive/{streaming-zip.js → zip/stream.js} +192 -48
  57. package/dist/browser/modules/archive/zip/zip-bytes.d.ts +73 -0
  58. package/dist/browser/modules/archive/zip/zip-bytes.js +239 -0
  59. package/dist/{esm/modules/archive → browser/modules/archive/zip}/zip-entry-metadata.js +3 -3
  60. package/dist/browser/modules/archive/{zip-records.d.ts → zip-spec/zip-records.d.ts} +20 -0
  61. package/dist/browser/modules/archive/zip-spec/zip-records.js +126 -0
  62. package/dist/browser/modules/excel/stream/workbook-reader.browser.js +1 -1
  63. package/dist/browser/modules/excel/stream/workbook-writer.browser.d.ts +1 -1
  64. package/dist/browser/modules/excel/stream/workbook-writer.browser.js +1 -1
  65. package/dist/browser/modules/excel/utils/ooxml-validator.d.ts +48 -0
  66. package/dist/browser/modules/excel/utils/ooxml-validator.js +469 -0
  67. package/dist/browser/modules/excel/utils/parse-sax.d.ts +3 -0
  68. package/dist/browser/modules/excel/utils/parse-sax.js +32 -13
  69. package/dist/browser/modules/excel/worksheet.js +5 -2
  70. package/dist/browser/modules/excel/xlsx/xform/core/app-xform.js +3 -3
  71. package/dist/browser/modules/excel/xlsx/xform/core/core-xform.js +56 -68
  72. package/dist/browser/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.d.ts +1 -0
  73. package/dist/browser/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.js +13 -1
  74. package/dist/browser/modules/excel/xlsx/xform/drawing/sp-xform.d.ts +18 -0
  75. package/dist/browser/modules/excel/xlsx/xform/drawing/sp-xform.js +112 -0
  76. package/dist/browser/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.d.ts +6 -1
  77. package/dist/browser/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +30 -2
  78. package/dist/browser/modules/excel/xlsx/xform/drawing/vml-drawing-xform.js +11 -0
  79. package/dist/browser/modules/excel/xlsx/xform/list-xform.js +8 -10
  80. package/dist/browser/modules/excel/xlsx/xform/sheet/page-setup-xform.d.ts +1 -0
  81. package/dist/browser/modules/excel/xlsx/xform/sheet/page-setup-xform.js +16 -2
  82. package/dist/browser/modules/excel/xlsx/xform/sheet/worksheet-xform.js +110 -12
  83. package/dist/browser/modules/excel/xlsx/xform/strings/shared-string-xform.js +2 -3
  84. package/dist/browser/modules/excel/xlsx/xform/strings/text-xform.js +5 -7
  85. package/dist/browser/modules/excel/xlsx/xlsx.browser.js +11 -10
  86. package/dist/browser/modules/excel/xlsx/xlsx.js +1 -1
  87. package/dist/browser/modules/stream/base-transform.d.ts +3 -0
  88. package/dist/browser/modules/stream/base-transform.js +34 -20
  89. package/dist/browser/modules/stream/buffered-stream.d.ts +2 -12
  90. package/dist/browser/modules/stream/chunked-builder.js +4 -4
  91. package/dist/browser/modules/stream/index.browser.d.ts +13 -19
  92. package/dist/browser/modules/stream/index.browser.js +10 -22
  93. package/dist/browser/modules/stream/index.d.ts +18 -41
  94. package/dist/browser/modules/stream/index.js +15 -44
  95. package/dist/browser/modules/stream/internal/event-utils.d.ts +17 -0
  96. package/dist/browser/modules/stream/internal/event-utils.js +40 -0
  97. package/dist/browser/modules/stream/internal/type-guards.d.ts +9 -0
  98. package/dist/browser/modules/stream/internal/type-guards.js +24 -0
  99. package/dist/browser/modules/stream/pull-stream.d.ts +5 -6
  100. package/dist/browser/modules/stream/pull-stream.js +107 -43
  101. package/dist/browser/modules/stream/shared.d.ts +1 -1
  102. package/dist/browser/modules/stream/shared.js +7 -4
  103. package/dist/browser/modules/stream/streams.browser.d.ts +32 -44
  104. package/dist/browser/modules/stream/streams.browser.js +921 -836
  105. package/dist/browser/modules/stream/streams.d.ts +4 -20
  106. package/dist/browser/modules/stream/streams.js +146 -95
  107. package/dist/browser/modules/stream/utils.js +5 -38
  108. package/dist/cjs/modules/archive/{compress.base.js → compression/compress.base.js} +1 -1
  109. package/dist/cjs/modules/archive/{compress.browser.js → compression/compress.browser.js} +3 -11
  110. package/dist/cjs/modules/archive/{compress.js → compression/compress.js} +1 -1
  111. package/dist/cjs/modules/archive/{crc32.js → compression/crc32.js} +1 -1
  112. package/dist/cjs/modules/archive/{deflate-fallback.js → compression/deflate-fallback.js} +1 -1
  113. package/dist/cjs/modules/archive/{streaming-compress.browser.js → compression/streaming-compress.browser.js} +3 -3
  114. package/dist/cjs/modules/archive/{streaming-compress.js → compression/streaming-compress.js} +2 -2
  115. package/dist/cjs/modules/archive/defaults.js +7 -4
  116. package/dist/cjs/modules/archive/index.base.js +9 -19
  117. package/dist/cjs/modules/archive/index.browser.js +4 -10
  118. package/dist/cjs/modules/archive/index.js +4 -8
  119. package/dist/cjs/modules/archive/internal/byte-queue.js +411 -0
  120. package/dist/cjs/modules/archive/io/archive-sink.js +49 -0
  121. package/dist/cjs/modules/archive/io/archive-source.js +105 -0
  122. package/dist/cjs/modules/archive/unzip/index.js +170 -0
  123. package/dist/cjs/modules/archive/unzip/stream.base.js +1044 -0
  124. package/dist/cjs/modules/archive/{parse.browser.js → unzip/stream.browser.js} +372 -111
  125. package/dist/cjs/modules/archive/{parse.js → unzip/stream.js} +9 -8
  126. package/dist/cjs/modules/archive/{zip-parser.js → unzip/zip-parser.js} +47 -33
  127. package/dist/cjs/modules/archive/utils/async-queue.js +106 -0
  128. package/dist/cjs/modules/archive/utils/bytes.js +16 -16
  129. package/dist/cjs/modules/archive/utils/compressibility.js +60 -0
  130. package/dist/cjs/modules/archive/utils/parse-buffer.js +21 -23
  131. package/dist/cjs/modules/archive/utils/pattern-scanner.js +31 -0
  132. package/dist/cjs/modules/archive/utils/timestamps.js +64 -3
  133. package/dist/cjs/modules/archive/utils/zip-extra-fields.js +26 -14
  134. package/dist/cjs/modules/archive/zip/index.js +162 -0
  135. package/dist/cjs/modules/archive/{streaming-zip.js → zip/stream.js} +194 -50
  136. package/dist/cjs/modules/archive/zip/zip-bytes.js +242 -0
  137. package/dist/cjs/modules/archive/{zip-entry-metadata.js → zip/zip-entry-metadata.js} +5 -5
  138. package/dist/cjs/modules/archive/zip-spec/zip-records.js +136 -0
  139. package/dist/cjs/modules/excel/stream/workbook-reader.browser.js +2 -2
  140. package/dist/cjs/modules/excel/stream/workbook-writer.browser.js +4 -4
  141. package/dist/cjs/modules/excel/utils/ooxml-validator.js +475 -0
  142. package/dist/cjs/modules/excel/utils/parse-sax.js +32 -13
  143. package/dist/cjs/modules/excel/worksheet.js +5 -2
  144. package/dist/cjs/modules/excel/xlsx/xform/core/app-xform.js +3 -3
  145. package/dist/cjs/modules/excel/xlsx/xform/core/core-xform.js +56 -68
  146. package/dist/cjs/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.js +13 -1
  147. package/dist/cjs/modules/excel/xlsx/xform/drawing/sp-xform.js +115 -0
  148. package/dist/cjs/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +30 -2
  149. package/dist/cjs/modules/excel/xlsx/xform/drawing/vml-drawing-xform.js +11 -0
  150. package/dist/cjs/modules/excel/xlsx/xform/list-xform.js +8 -10
  151. package/dist/cjs/modules/excel/xlsx/xform/sheet/page-setup-xform.js +16 -2
  152. package/dist/cjs/modules/excel/xlsx/xform/sheet/worksheet-xform.js +110 -12
  153. package/dist/cjs/modules/excel/xlsx/xform/strings/shared-string-xform.js +2 -3
  154. package/dist/cjs/modules/excel/xlsx/xform/strings/text-xform.js +5 -7
  155. package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +14 -13
  156. package/dist/cjs/modules/excel/xlsx/xlsx.js +2 -2
  157. package/dist/cjs/modules/stream/base-transform.js +34 -20
  158. package/dist/cjs/modules/stream/chunked-builder.js +4 -4
  159. package/dist/cjs/modules/stream/index.browser.js +10 -17
  160. package/dist/cjs/modules/stream/index.js +15 -39
  161. package/dist/cjs/modules/stream/internal/event-utils.js +43 -0
  162. package/dist/cjs/modules/stream/internal/type-guards.js +30 -0
  163. package/dist/cjs/modules/stream/pull-stream.js +107 -43
  164. package/dist/cjs/modules/stream/shared.js +7 -4
  165. package/dist/cjs/modules/stream/streams.browser.js +927 -847
  166. package/dist/cjs/modules/stream/streams.js +156 -107
  167. package/dist/cjs/modules/stream/utils.js +3 -36
  168. package/dist/esm/index.browser.js +12 -0
  169. package/dist/{browser/modules/archive → esm/modules/archive/compression}/compress.base.js +1 -1
  170. package/dist/esm/modules/archive/{compress.browser.js → compression/compress.browser.js} +3 -11
  171. package/dist/{browser/modules/archive → esm/modules/archive/compression}/compress.js +1 -1
  172. package/dist/esm/modules/archive/{crc32.js → compression/crc32.js} +1 -1
  173. package/dist/esm/modules/archive/{deflate-fallback.js → compression/deflate-fallback.js} +1 -1
  174. package/dist/esm/modules/archive/{streaming-compress.browser.js → compression/streaming-compress.browser.js} +3 -3
  175. package/dist/esm/modules/archive/{streaming-compress.js → compression/streaming-compress.js} +2 -2
  176. package/dist/esm/modules/archive/defaults.js +6 -3
  177. package/dist/esm/modules/archive/index.base.js +3 -6
  178. package/dist/esm/modules/archive/index.browser.js +3 -7
  179. package/dist/esm/modules/archive/index.js +3 -5
  180. package/dist/esm/modules/archive/internal/byte-queue.js +407 -0
  181. package/dist/esm/modules/archive/io/archive-sink.js +45 -0
  182. package/dist/esm/modules/archive/io/archive-source.js +100 -0
  183. package/dist/esm/modules/archive/unzip/index.js +164 -0
  184. package/dist/esm/modules/archive/unzip/stream.base.js +1022 -0
  185. package/dist/esm/modules/archive/{parse.browser.js → unzip/stream.browser.js} +371 -110
  186. package/dist/{browser/modules/archive/parse.js → esm/modules/archive/unzip/stream.js} +6 -5
  187. package/dist/{browser/modules/archive → esm/modules/archive/unzip}/zip-parser.js +38 -24
  188. package/dist/esm/modules/archive/utils/async-queue.js +103 -0
  189. package/dist/esm/modules/archive/utils/bytes.js +16 -16
  190. package/dist/esm/modules/archive/utils/compressibility.js +57 -0
  191. package/dist/esm/modules/archive/utils/parse-buffer.js +21 -23
  192. package/dist/esm/modules/archive/utils/pattern-scanner.js +27 -0
  193. package/dist/esm/modules/archive/utils/timestamps.js +62 -1
  194. package/dist/esm/modules/archive/utils/zip-extra-fields.js +26 -14
  195. package/dist/esm/modules/archive/zip/index.js +157 -0
  196. package/dist/esm/modules/archive/{streaming-zip.js → zip/stream.js} +192 -48
  197. package/dist/esm/modules/archive/zip/zip-bytes.js +239 -0
  198. package/dist/{browser/modules/archive → esm/modules/archive/zip}/zip-entry-metadata.js +3 -3
  199. package/dist/esm/modules/archive/zip-spec/zip-records.js +126 -0
  200. package/dist/esm/modules/excel/stream/workbook-reader.browser.js +1 -1
  201. package/dist/esm/modules/excel/stream/workbook-writer.browser.js +1 -1
  202. package/dist/esm/modules/excel/utils/ooxml-validator.js +469 -0
  203. package/dist/esm/modules/excel/utils/parse-sax.js +32 -13
  204. package/dist/esm/modules/excel/worksheet.js +5 -2
  205. package/dist/esm/modules/excel/xlsx/xform/core/app-xform.js +3 -3
  206. package/dist/esm/modules/excel/xlsx/xform/core/core-xform.js +56 -68
  207. package/dist/esm/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.js +13 -1
  208. package/dist/esm/modules/excel/xlsx/xform/drawing/sp-xform.js +112 -0
  209. package/dist/esm/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +30 -2
  210. package/dist/esm/modules/excel/xlsx/xform/drawing/vml-drawing-xform.js +11 -0
  211. package/dist/esm/modules/excel/xlsx/xform/list-xform.js +8 -10
  212. package/dist/esm/modules/excel/xlsx/xform/sheet/page-setup-xform.js +16 -2
  213. package/dist/esm/modules/excel/xlsx/xform/sheet/worksheet-xform.js +110 -12
  214. package/dist/esm/modules/excel/xlsx/xform/strings/shared-string-xform.js +2 -3
  215. package/dist/esm/modules/excel/xlsx/xform/strings/text-xform.js +5 -7
  216. package/dist/esm/modules/excel/xlsx/xlsx.browser.js +11 -10
  217. package/dist/esm/modules/excel/xlsx/xlsx.js +1 -1
  218. package/dist/esm/modules/stream/base-transform.js +34 -20
  219. package/dist/esm/modules/stream/chunked-builder.js +4 -4
  220. package/dist/esm/modules/stream/index.browser.js +10 -22
  221. package/dist/esm/modules/stream/index.js +15 -44
  222. package/dist/esm/modules/stream/internal/event-utils.js +40 -0
  223. package/dist/esm/modules/stream/internal/type-guards.js +24 -0
  224. package/dist/esm/modules/stream/pull-stream.js +107 -43
  225. package/dist/esm/modules/stream/shared.js +7 -4
  226. package/dist/esm/modules/stream/streams.browser.js +921 -836
  227. package/dist/esm/modules/stream/streams.js +146 -95
  228. package/dist/esm/modules/stream/utils.js +5 -38
  229. package/dist/iife/THIRD_PARTY_NOTICES.md +0 -31
  230. package/dist/iife/excelts.iife.js +6592 -4537
  231. package/dist/iife/excelts.iife.js.map +1 -1
  232. package/dist/iife/excelts.iife.min.js +103 -31
  233. package/dist/types/index.browser.d.ts +1 -0
  234. package/dist/{browser/modules/archive → types/modules/archive/compression}/compress.browser.d.ts +2 -8
  235. package/dist/types/modules/archive/{streaming-compress.browser.d.ts → compression/streaming-compress.browser.d.ts} +1 -1
  236. package/dist/types/modules/archive/defaults.d.ts +1 -0
  237. package/dist/types/modules/archive/index.base.d.ts +4 -4
  238. package/dist/types/modules/archive/index.browser.d.ts +3 -4
  239. package/dist/types/modules/archive/index.d.ts +3 -4
  240. package/dist/types/modules/archive/internal/byte-queue.d.ts +33 -0
  241. package/dist/types/modules/archive/io/archive-sink.d.ts +8 -0
  242. package/dist/types/modules/archive/io/archive-source.d.ts +6 -0
  243. package/dist/types/modules/archive/unzip/index.d.ts +40 -0
  244. package/dist/types/modules/archive/{parse.base.d.ts → unzip/stream.base.d.ts} +38 -4
  245. package/dist/types/modules/archive/{parse.browser.d.ts → unzip/stream.browser.d.ts} +2 -2
  246. package/dist/types/modules/archive/{parse.d.ts → unzip/stream.d.ts} +3 -3
  247. package/dist/types/modules/archive/{zip-parser.d.ts → unzip/zip-parser.d.ts} +1 -1
  248. package/dist/types/modules/archive/utils/async-queue.d.ts +7 -0
  249. package/dist/types/modules/archive/utils/compressibility.d.ts +10 -0
  250. package/dist/types/modules/archive/utils/pattern-scanner.d.ts +21 -0
  251. package/dist/types/modules/archive/utils/zip-extra-fields.d.ts +1 -1
  252. package/dist/types/modules/archive/zip/index.d.ts +42 -0
  253. package/dist/types/modules/archive/{streaming-zip.d.ts → zip/stream.d.ts} +29 -6
  254. package/dist/types/modules/archive/zip/zip-bytes.d.ts +73 -0
  255. package/dist/types/modules/archive/{zip-entry-metadata.d.ts → zip/zip-entry-metadata.d.ts} +1 -1
  256. package/dist/types/modules/archive/{zip-records.d.ts → zip-spec/zip-records.d.ts} +20 -0
  257. package/dist/types/modules/excel/stream/workbook-writer.browser.d.ts +1 -1
  258. package/dist/types/modules/excel/utils/ooxml-validator.d.ts +48 -0
  259. package/dist/types/modules/excel/utils/parse-sax.d.ts +3 -0
  260. package/dist/types/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.d.ts +1 -0
  261. package/dist/types/modules/excel/xlsx/xform/drawing/sp-xform.d.ts +18 -0
  262. package/dist/types/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.d.ts +6 -1
  263. package/dist/types/modules/excel/xlsx/xform/sheet/page-setup-xform.d.ts +1 -0
  264. package/dist/types/modules/stream/base-transform.d.ts +3 -0
  265. package/dist/types/modules/stream/buffered-stream.d.ts +2 -12
  266. package/dist/types/modules/stream/index.browser.d.ts +13 -19
  267. package/dist/types/modules/stream/index.d.ts +18 -41
  268. package/dist/types/modules/stream/internal/event-utils.d.ts +17 -0
  269. package/dist/types/modules/stream/internal/type-guards.d.ts +9 -0
  270. package/dist/types/modules/stream/pull-stream.d.ts +5 -6
  271. package/dist/types/modules/stream/shared.d.ts +1 -1
  272. package/dist/types/modules/stream/streams.browser.d.ts +32 -44
  273. package/dist/types/modules/stream/streams.d.ts +4 -20
  274. package/package.json +14 -10
  275. package/dist/browser/modules/archive/byte-queue.d.ts +0 -18
  276. package/dist/browser/modules/archive/byte-queue.js +0 -125
  277. package/dist/browser/modules/archive/parse.base.js +0 -644
  278. package/dist/browser/modules/archive/utils/zip-extra.d.ts +0 -18
  279. package/dist/browser/modules/archive/utils/zip-extra.js +0 -68
  280. package/dist/browser/modules/archive/zip-builder.d.ts +0 -117
  281. package/dist/browser/modules/archive/zip-builder.js +0 -292
  282. package/dist/browser/modules/archive/zip-constants.d.ts +0 -18
  283. package/dist/browser/modules/archive/zip-constants.js +0 -23
  284. package/dist/browser/modules/archive/zip-records.js +0 -84
  285. package/dist/cjs/modules/archive/byte-queue.js +0 -129
  286. package/dist/cjs/modules/archive/parse.base.js +0 -666
  287. package/dist/cjs/modules/archive/utils/zip-extra.js +0 -74
  288. package/dist/cjs/modules/archive/zip-builder.js +0 -297
  289. package/dist/cjs/modules/archive/zip-constants.js +0 -26
  290. package/dist/cjs/modules/archive/zip-records.js +0 -90
  291. package/dist/esm/modules/archive/byte-queue.js +0 -125
  292. package/dist/esm/modules/archive/parse.base.js +0 -644
  293. package/dist/esm/modules/archive/utils/zip-extra.js +0 -68
  294. package/dist/esm/modules/archive/zip-builder.js +0 -292
  295. package/dist/esm/modules/archive/zip-constants.js +0 -23
  296. package/dist/esm/modules/archive/zip-records.js +0 -84
  297. package/dist/types/modules/archive/byte-queue.d.ts +0 -18
  298. package/dist/types/modules/archive/utils/zip-extra.d.ts +0 -18
  299. package/dist/types/modules/archive/zip-builder.d.ts +0 -117
  300. package/dist/types/modules/archive/zip-constants.d.ts +0 -18
  301. /package/dist/browser/modules/archive/{compress.base.d.ts → compression/compress.base.d.ts} +0 -0
  302. /package/dist/browser/modules/archive/{crc32.base.d.ts → compression/crc32.base.d.ts} +0 -0
  303. /package/dist/browser/modules/archive/{crc32.base.js → compression/crc32.base.js} +0 -0
  304. /package/dist/browser/modules/archive/{crc32.browser.js → compression/crc32.browser.js} +0 -0
  305. /package/dist/browser/modules/archive/{deflate-fallback.d.ts → compression/deflate-fallback.d.ts} +0 -0
  306. /package/dist/browser/modules/archive/{streaming-compress.base.d.ts → compression/streaming-compress.base.d.ts} +0 -0
  307. /package/dist/browser/modules/archive/{streaming-compress.base.js → compression/streaming-compress.base.js} +0 -0
  308. /package/dist/browser/modules/archive/{extract.js → unzip/extract.js} +0 -0
  309. /package/dist/browser/modules/archive/{zip-entry-metadata.d.ts → zip/zip-entry-metadata.d.ts} +0 -0
  310. /package/dist/browser/modules/archive/{zip-entry-info.d.ts → zip-spec/zip-entry-info.d.ts} +0 -0
  311. /package/dist/browser/modules/archive/{zip-entry-info.js → zip-spec/zip-entry-info.js} +0 -0
  312. /package/dist/cjs/modules/archive/{crc32.base.js → compression/crc32.base.js} +0 -0
  313. /package/dist/cjs/modules/archive/{crc32.browser.js → compression/crc32.browser.js} +0 -0
  314. /package/dist/cjs/modules/archive/{streaming-compress.base.js → compression/streaming-compress.base.js} +0 -0
  315. /package/dist/cjs/modules/archive/{extract.js → unzip/extract.js} +0 -0
  316. /package/dist/cjs/modules/archive/{zip-entry-info.js → zip-spec/zip-entry-info.js} +0 -0
  317. /package/dist/esm/modules/archive/{crc32.base.js → compression/crc32.base.js} +0 -0
  318. /package/dist/esm/modules/archive/{crc32.browser.js → compression/crc32.browser.js} +0 -0
  319. /package/dist/esm/modules/archive/{streaming-compress.base.js → compression/streaming-compress.base.js} +0 -0
  320. /package/dist/esm/modules/archive/{extract.js → unzip/extract.js} +0 -0
  321. /package/dist/esm/modules/archive/{zip-entry-info.js → zip-spec/zip-entry-info.js} +0 -0
  322. /package/dist/types/modules/archive/{compress.base.d.ts → compression/compress.base.d.ts} +0 -0
  323. /package/dist/types/modules/archive/{compress.d.ts → compression/compress.d.ts} +0 -0
  324. /package/dist/types/modules/archive/{crc32.base.d.ts → compression/crc32.base.d.ts} +0 -0
  325. /package/dist/types/modules/archive/{crc32.browser.d.ts → compression/crc32.browser.d.ts} +0 -0
  326. /package/dist/types/modules/archive/{crc32.d.ts → compression/crc32.d.ts} +0 -0
  327. /package/dist/types/modules/archive/{deflate-fallback.d.ts → compression/deflate-fallback.d.ts} +0 -0
  328. /package/dist/types/modules/archive/{streaming-compress.base.d.ts → compression/streaming-compress.base.d.ts} +0 -0
  329. /package/dist/types/modules/archive/{streaming-compress.d.ts → compression/streaming-compress.d.ts} +0 -0
  330. /package/dist/types/modules/archive/{extract.d.ts → unzip/extract.d.ts} +0 -0
  331. /package/dist/types/modules/archive/{zip-entry-info.d.ts → zip-spec/zip-entry-info.d.ts} +0 -0
@@ -0,0 +1,73 @@
1
+ /**
2
+ * ZIP file format encoder (single-buffer output)
3
+ *
4
+ * Implements ZIP file structure according to PKWARE's APPNOTE.TXT specification
5
+ * https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
6
+ *
7
+ * This module focuses on producing a complete ZIP as a single Uint8Array.
8
+ * For true streaming (push chunks while reading sources), use `zip()` / `ZipArchive.stream()`.
9
+ */
10
+ import { type CompressOptions } from "@archive/compression/compress";
11
+ import { type ZipTimestampMode } from "@archive/utils/timestamps";
12
+ /**
13
+ * ZIP file entry
14
+ */
15
+ export interface ZipEntry {
16
+ /** File name (can include directory path, use forward slashes) */
17
+ name: string;
18
+ /** File data (will be compressed unless level=0) */
19
+ data: Uint8Array;
20
+ /** Optional per-entry compression level override */
21
+ level?: number;
22
+ /** File modification time (optional, defaults to current time) */
23
+ modTime?: Date;
24
+ /** File comment (optional) */
25
+ comment?: string;
26
+ }
27
+ /**
28
+ * ZIP encoder options
29
+ */
30
+ export interface ZipOptions extends CompressOptions {
31
+ /** ZIP file comment (optional) */
32
+ comment?: string;
33
+ /**
34
+ * Default modification time for entries that don't specify `modTime`.
35
+ *
36
+ * If you need stable output across runs, either pass this explicitly or use `reproducible: true`.
37
+ */
38
+ modTime?: Date;
39
+ /**
40
+ * If true, bias defaults toward reproducible output:
41
+ * - default `modTime` becomes 1980-01-01 00:00:00 (local time)
42
+ * - default `timestamps` becomes "dos" (no UTC extra field)
43
+ */
44
+ reproducible?: boolean;
45
+ /**
46
+ * Max number of entries to compress concurrently in `createZip()`.
47
+ * This helps avoid zlib threadpool saturation / memory spikes with many files.
48
+ *
49
+ * Defaults to 4.
50
+ */
51
+ concurrency?: number;
52
+ /**
53
+ * If true (default), automatically STORE incompressible data.
54
+ * If false, always follow `level` (DEFLATE when level > 0).
55
+ */
56
+ smartStore?: boolean;
57
+ /**
58
+ * Timestamp writing strategy.
59
+ * - "dos": only write DOS date/time fields (smallest output)
60
+ * - "dos+utc": also write UTC mtime in 0x5455 extra field
61
+ */
62
+ timestamps?: ZipTimestampMode;
63
+ }
64
+ /**
65
+ * Create a ZIP file from entries (async)
66
+ */
67
+ export declare function createZip(entries: ZipEntry[], options?: ZipOptions): Promise<Uint8Array>;
68
+ /**
69
+ * Create a ZIP file from entries (sync)
70
+ *
71
+ * This is supported in both Node.js and browser builds.
72
+ */
73
+ export declare function createZipSync(entries: ZipEntry[], options?: ZipOptions): Uint8Array;
@@ -0,0 +1,239 @@
1
+ /**
2
+ * ZIP file format encoder (single-buffer output)
3
+ *
4
+ * Implements ZIP file structure according to PKWARE's APPNOTE.TXT specification
5
+ * https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
6
+ *
7
+ * This module focuses on producing a complete ZIP as a single Uint8Array.
8
+ * For true streaming (push chunks while reading sources), use `zip()` / `ZipArchive.stream()`.
9
+ */
10
+ import { compress, compressSync } from "../compression/compress.browser.js";
11
+ import { crc32 } from "../compression/crc32.browser.js";
12
+ import { DEFAULT_ZIP_LEVEL, DEFAULT_ZIP_TIMESTAMPS } from "../defaults.js";
13
+ import { isProbablyIncompressible } from "../utils/compressibility.js";
14
+ import { encodeUtf8 } from "../utils/text.js";
15
+ import {} from "../utils/timestamps.js";
16
+ import { buildZipEntryMetadata, resolveZipCompressionMethod } from "./zip-entry-metadata.js";
17
+ import { FLAG_UTF8, ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE, ZIP_END_OF_CENTRAL_DIR_FIXED_SIZE, ZIP_LOCAL_FILE_HEADER_FIXED_SIZE, writeCentralDirectoryHeaderInto, writeEndOfCentralDirectoryInto, writeLocalFileHeaderInto } from "../zip-spec/zip-records.js";
18
+ const REPRODUCIBLE_ZIP_MOD_TIME = new Date(1980, 0, 1, 0, 0, 0);
19
+ function encodeZipComment(comment) {
20
+ // Keep empty comment as empty bytes (no encoding surprises).
21
+ return comment ? encodeUtf8(comment) : new Uint8Array(0);
22
+ }
23
+ function shouldDeflate(level, data) {
24
+ return level > 0 && data.length > 0;
25
+ }
26
+ async function compressEntryMaybe(entry, level, compressOptions, smartStore) {
27
+ if (!shouldDeflate(level, entry.data)) {
28
+ return { compressedData: entry.data, deflate: false };
29
+ }
30
+ if (!smartStore) {
31
+ const compressed = await compress(entry.data, compressOptions);
32
+ return { compressedData: compressed, deflate: true };
33
+ }
34
+ // Heuristic: skip deflate for high-entropy inputs.
35
+ if (isProbablyIncompressible(entry.data)) {
36
+ return { compressedData: entry.data, deflate: false };
37
+ }
38
+ const compressed = await compress(entry.data, compressOptions);
39
+ if (compressed.length >= entry.data.length) {
40
+ return { compressedData: entry.data, deflate: false };
41
+ }
42
+ return { compressedData: compressed, deflate: true };
43
+ }
44
+ function compressEntryMaybeSync(entry, level, compressOptions, smartStore) {
45
+ if (!shouldDeflate(level, entry.data)) {
46
+ return { compressedData: entry.data, deflate: false };
47
+ }
48
+ if (!smartStore) {
49
+ const compressed = compressSync(entry.data, compressOptions);
50
+ return { compressedData: compressed, deflate: true };
51
+ }
52
+ if (isProbablyIncompressible(entry.data)) {
53
+ return { compressedData: entry.data, deflate: false };
54
+ }
55
+ const compressed = compressSync(entry.data, compressOptions);
56
+ if (compressed.length >= entry.data.length) {
57
+ return { compressedData: entry.data, deflate: false };
58
+ }
59
+ return { compressedData: compressed, deflate: true };
60
+ }
61
+ function computeLocalRecordSize(entry) {
62
+ return (ZIP_LOCAL_FILE_HEADER_FIXED_SIZE +
63
+ entry.name.length +
64
+ entry.extraField.length +
65
+ entry.compressedData.length);
66
+ }
67
+ function computeCentralDirHeaderSize(entry) {
68
+ return (ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE +
69
+ entry.name.length +
70
+ entry.extraField.length +
71
+ entry.comment.length);
72
+ }
73
+ function buildProcessedEntry(entry, offset, settings, compressedData, deflate) {
74
+ const modDate = entry.modTime ?? settings.defaultModTime;
75
+ const metadata = buildZipEntryMetadata({
76
+ name: entry.name,
77
+ comment: entry.comment,
78
+ modTime: modDate,
79
+ timestamps: settings.timestamps,
80
+ useDataDescriptor: false,
81
+ deflate
82
+ });
83
+ return {
84
+ name: metadata.nameBytes,
85
+ uncompressedSize: entry.data.length,
86
+ compressedData,
87
+ crc: crc32(entry.data),
88
+ compressionMethod: resolveZipCompressionMethod(deflate),
89
+ modTime: metadata.dosTime,
90
+ modDate: metadata.dosDate,
91
+ extraField: metadata.extraField,
92
+ comment: metadata.commentBytes,
93
+ offset
94
+ };
95
+ }
96
+ function appendProcessedEntry(processedEntries, entry, compressedData, deflate, currentOffset, settings) {
97
+ const processedEntry = buildProcessedEntry(entry, currentOffset, settings, compressedData, deflate);
98
+ processedEntries.push(processedEntry);
99
+ return {
100
+ processedEntry,
101
+ nextOffset: currentOffset + computeLocalRecordSize(processedEntry)
102
+ };
103
+ }
104
+ function finalizeZip(processedEntries, zipComment) {
105
+ // Assemble ZIP into a single buffer to reduce allocations and copying.
106
+ let localSectionSize = 0;
107
+ let centralDirSize = 0;
108
+ for (const entry of processedEntries) {
109
+ localSectionSize += computeLocalRecordSize(entry);
110
+ centralDirSize += computeCentralDirHeaderSize(entry);
111
+ }
112
+ // The central directory should start immediately after local section.
113
+ const centralDirOffset = localSectionSize;
114
+ const totalSize = localSectionSize + centralDirSize + ZIP_END_OF_CENTRAL_DIR_FIXED_SIZE + zipComment.length;
115
+ const out = new Uint8Array(totalSize);
116
+ const view = new DataView(out.buffer, out.byteOffset, out.byteLength);
117
+ let offset = 0;
118
+ // Local file headers and data
119
+ for (const entry of processedEntries) {
120
+ offset += writeLocalFileHeaderInto(out, view, offset, {
121
+ fileName: entry.name,
122
+ extraField: entry.extraField,
123
+ flags: FLAG_UTF8,
124
+ compressionMethod: entry.compressionMethod,
125
+ dosTime: entry.modTime,
126
+ dosDate: entry.modDate,
127
+ crc32: entry.crc,
128
+ compressedSize: entry.compressedData.length,
129
+ uncompressedSize: entry.uncompressedSize
130
+ });
131
+ out.set(entry.compressedData, offset);
132
+ offset += entry.compressedData.length;
133
+ }
134
+ // Central directory headers
135
+ for (const entry of processedEntries) {
136
+ offset += writeCentralDirectoryHeaderInto(out, view, offset, {
137
+ fileName: entry.name,
138
+ extraField: entry.extraField,
139
+ comment: entry.comment,
140
+ flags: FLAG_UTF8,
141
+ compressionMethod: entry.compressionMethod,
142
+ dosTime: entry.modTime,
143
+ dosDate: entry.modDate,
144
+ crc32: entry.crc,
145
+ compressedSize: entry.compressedData.length,
146
+ uncompressedSize: entry.uncompressedSize,
147
+ localHeaderOffset: entry.offset
148
+ });
149
+ }
150
+ // End of central directory
151
+ writeEndOfCentralDirectoryInto(out, view, offset, {
152
+ entryCount: processedEntries.length,
153
+ centralDirSize,
154
+ centralDirOffset,
155
+ comment: zipComment
156
+ });
157
+ return out;
158
+ }
159
+ /**
160
+ * Create a ZIP file from entries (async)
161
+ */
162
+ export async function createZip(entries, options = {}) {
163
+ const reproducible = options.reproducible ?? false;
164
+ const level = options.level ?? DEFAULT_ZIP_LEVEL;
165
+ const smartStore = options.smartStore ?? true;
166
+ const concurrency = options.concurrency ?? 4;
167
+ const timestamps = options.timestamps ?? (reproducible ? "dos" : DEFAULT_ZIP_TIMESTAMPS);
168
+ const zipComment = encodeZipComment(options.comment);
169
+ const defaultModTime = options.modTime ?? (reproducible ? REPRODUCIBLE_ZIP_MOD_TIME : new Date());
170
+ const settings = {
171
+ level,
172
+ timestamps,
173
+ defaultModTime
174
+ };
175
+ const thresholdBytes = options.thresholdBytes;
176
+ const limit = Math.max(1, Math.floor(concurrency));
177
+ const processedEntries = new Array(entries.length);
178
+ if (entries.length > 0) {
179
+ let nextIndex = 0;
180
+ const workerCount = Math.min(limit, entries.length);
181
+ const workers = Array.from({ length: workerCount }, async () => {
182
+ while (true) {
183
+ const idx = nextIndex++;
184
+ if (idx >= entries.length) {
185
+ return;
186
+ }
187
+ const entry = entries[idx];
188
+ const entryLevel = entry.level ?? level;
189
+ const compressOptions = {
190
+ level: entryLevel,
191
+ thresholdBytes
192
+ };
193
+ const { compressedData, deflate } = await compressEntryMaybe(entry, entryLevel, compressOptions, smartStore);
194
+ processedEntries[idx] = buildProcessedEntry(entry, 0, settings, compressedData, deflate);
195
+ }
196
+ });
197
+ await Promise.all(workers);
198
+ }
199
+ // Compute offsets in original order.
200
+ let currentOffset = 0;
201
+ for (let i = 0; i < processedEntries.length; i++) {
202
+ const processedEntry = processedEntries[i];
203
+ processedEntry.offset = currentOffset;
204
+ currentOffset += computeLocalRecordSize(processedEntry);
205
+ }
206
+ return finalizeZip(processedEntries, zipComment);
207
+ }
208
+ /**
209
+ * Create a ZIP file from entries (sync)
210
+ *
211
+ * This is supported in both Node.js and browser builds.
212
+ */
213
+ export function createZipSync(entries, options = {}) {
214
+ const reproducible = options.reproducible ?? false;
215
+ const level = options.level ?? DEFAULT_ZIP_LEVEL;
216
+ const smartStore = options.smartStore ?? true;
217
+ const timestamps = options.timestamps ?? (reproducible ? "dos" : DEFAULT_ZIP_TIMESTAMPS);
218
+ const zipComment = encodeZipComment(options.comment);
219
+ const defaultModTime = options.modTime ?? (reproducible ? REPRODUCIBLE_ZIP_MOD_TIME : new Date());
220
+ const settings = {
221
+ level,
222
+ timestamps,
223
+ defaultModTime
224
+ };
225
+ const thresholdBytes = options.thresholdBytes;
226
+ const processedEntries = [];
227
+ let currentOffset = 0;
228
+ for (const entry of entries) {
229
+ const entryLevel = entry.level ?? level;
230
+ const compressOptions = {
231
+ level: entryLevel,
232
+ thresholdBytes
233
+ };
234
+ const { compressedData, deflate } = compressEntryMaybeSync(entry, entryLevel, compressOptions, smartStore);
235
+ const result = appendProcessedEntry(processedEntries, entry, compressedData, deflate, currentOffset, settings);
236
+ currentOffset = result.nextOffset;
237
+ }
238
+ return finalizeZip(processedEntries, zipComment);
239
+ }
@@ -1,6 +1,6 @@
1
- import { encodeUtf8 } from "./utils/text.js";
2
- import { buildZipTimestampExtraField, dateToZipDos } from "./utils/timestamps.js";
3
- import { COMPRESSION_DEFLATE, COMPRESSION_STORE, FLAG_DATA_DESCRIPTOR, FLAG_UTF8 } from "./zip-constants.js";
1
+ import { encodeUtf8 } from "../utils/text.js";
2
+ import { buildZipTimestampExtraField, dateToZipDos } from "../utils/timestamps.js";
3
+ import { COMPRESSION_DEFLATE, COMPRESSION_STORE, FLAG_DATA_DESCRIPTOR, FLAG_UTF8 } from "../zip-spec/zip-records.js";
4
4
  export function resolveZipCompressionMethod(deflate) {
5
5
  return deflate ? COMPRESSION_DEFLATE : COMPRESSION_STORE;
6
6
  }
@@ -3,6 +3,23 @@
3
3
  *
4
4
  * Shared by streaming zip writer and buffer zip builder.
5
5
  */
6
+ export declare const LOCAL_FILE_HEADER_SIG = 67324752;
7
+ export declare const CENTRAL_DIR_HEADER_SIG = 33639248;
8
+ export declare const END_OF_CENTRAL_DIR_SIG = 101010256;
9
+ export declare const DATA_DESCRIPTOR_SIG = 134695760;
10
+ export declare const ZIP64_END_OF_CENTRAL_DIR_SIG = 101075792;
11
+ export declare const ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIG = 117853008;
12
+ export declare const VERSION_NEEDED = 20;
13
+ export declare const VERSION_MADE_BY = 20;
14
+ export declare const COMPRESSION_STORE = 0;
15
+ export declare const COMPRESSION_DEFLATE = 8;
16
+ export declare const FLAG_UTF8 = 2048;
17
+ export declare const FLAG_DATA_DESCRIPTOR = 8;
18
+ export declare const UINT16_MAX = 65535;
19
+ export declare const UINT32_MAX = 4294967295;
20
+ export declare const ZIP_LOCAL_FILE_HEADER_FIXED_SIZE = 30;
21
+ export declare const ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE = 46;
22
+ export declare const ZIP_END_OF_CENTRAL_DIR_FIXED_SIZE = 22;
6
23
  export interface ZipLocalFileHeaderInput {
7
24
  fileName: Uint8Array;
8
25
  extraField: Uint8Array;
@@ -15,6 +32,7 @@ export interface ZipLocalFileHeaderInput {
15
32
  uncompressedSize: number;
16
33
  versionNeeded?: number;
17
34
  }
35
+ export declare function writeLocalFileHeaderInto(out: Uint8Array, view: DataView, offset: number, input: ZipLocalFileHeaderInput): number;
18
36
  export declare function buildLocalFileHeader(input: ZipLocalFileHeaderInput): Uint8Array;
19
37
  export interface ZipCentralDirectoryHeaderInput {
20
38
  fileName: Uint8Array;
@@ -32,6 +50,7 @@ export interface ZipCentralDirectoryHeaderInput {
32
50
  versionNeeded?: number;
33
51
  externalAttributes?: number;
34
52
  }
53
+ export declare function writeCentralDirectoryHeaderInto(out: Uint8Array, view: DataView, offset: number, input: ZipCentralDirectoryHeaderInput): number;
35
54
  export declare function buildCentralDirectoryHeader(input: ZipCentralDirectoryHeaderInput): Uint8Array;
36
55
  export interface ZipEndOfCentralDirectoryInput {
37
56
  entryCount: number;
@@ -39,5 +58,6 @@ export interface ZipEndOfCentralDirectoryInput {
39
58
  centralDirOffset: number;
40
59
  comment: Uint8Array;
41
60
  }
61
+ export declare function writeEndOfCentralDirectoryInto(out: Uint8Array, view: DataView, offset: number, input: ZipEndOfCentralDirectoryInput): number;
42
62
  export declare function buildEndOfCentralDirectory(input: ZipEndOfCentralDirectoryInput): Uint8Array;
43
63
  export declare function buildDataDescriptor(crc32: number, compressedSize: number, uncompressedSize: number): Uint8Array<ArrayBuffer>;
@@ -0,0 +1,126 @@
1
+ /**
2
+ * ZIP record builders (PKWARE APPNOTE)
3
+ *
4
+ * Shared by streaming zip writer and buffer zip builder.
5
+ */
6
+ // =============================================================================
7
+ // ZIP format constants (PKWARE APPNOTE)
8
+ // =============================================================================
9
+ // Signatures
10
+ export const LOCAL_FILE_HEADER_SIG = 0x04034b50;
11
+ export const CENTRAL_DIR_HEADER_SIG = 0x02014b50;
12
+ export const END_OF_CENTRAL_DIR_SIG = 0x06054b50;
13
+ export const DATA_DESCRIPTOR_SIG = 0x08074b50;
14
+ export const ZIP64_END_OF_CENTRAL_DIR_SIG = 0x06064b50;
15
+ export const ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIG = 0x07064b50;
16
+ // Versions
17
+ export const VERSION_NEEDED = 20; // 2.0 - supports DEFLATE
18
+ export const VERSION_MADE_BY = 20; // 2.0
19
+ // Compression methods
20
+ export const COMPRESSION_STORE = 0;
21
+ export const COMPRESSION_DEFLATE = 8;
22
+ // General purpose bit flags
23
+ export const FLAG_UTF8 = 0x0800;
24
+ export const FLAG_DATA_DESCRIPTOR = 0x0008;
25
+ // ZIP64 / sentinel sizes
26
+ export const UINT16_MAX = 0xffff;
27
+ export const UINT32_MAX = 0xffffffff;
28
+ export const ZIP_LOCAL_FILE_HEADER_FIXED_SIZE = 30;
29
+ export const ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE = 46;
30
+ export const ZIP_END_OF_CENTRAL_DIR_FIXED_SIZE = 22;
31
+ export function writeLocalFileHeaderInto(out, view, offset, input) {
32
+ const versionNeeded = input.versionNeeded ?? VERSION_NEEDED;
33
+ view.setUint32(offset + 0, LOCAL_FILE_HEADER_SIG, true);
34
+ view.setUint16(offset + 4, versionNeeded, true);
35
+ view.setUint16(offset + 6, input.flags, true);
36
+ view.setUint16(offset + 8, input.compressionMethod, true);
37
+ view.setUint16(offset + 10, input.dosTime, true);
38
+ view.setUint16(offset + 12, input.dosDate, true);
39
+ view.setUint32(offset + 14, input.crc32, true);
40
+ view.setUint32(offset + 18, input.compressedSize, true);
41
+ view.setUint32(offset + 22, input.uncompressedSize, true);
42
+ view.setUint16(offset + 26, input.fileName.length, true);
43
+ view.setUint16(offset + 28, input.extraField.length, true);
44
+ out.set(input.fileName, offset + ZIP_LOCAL_FILE_HEADER_FIXED_SIZE);
45
+ if (input.extraField.length > 0) {
46
+ out.set(input.extraField, offset + ZIP_LOCAL_FILE_HEADER_FIXED_SIZE + input.fileName.length);
47
+ }
48
+ return ZIP_LOCAL_FILE_HEADER_FIXED_SIZE + input.fileName.length + input.extraField.length;
49
+ }
50
+ export function buildLocalFileHeader(input) {
51
+ const header = new Uint8Array(ZIP_LOCAL_FILE_HEADER_FIXED_SIZE + input.fileName.length + input.extraField.length);
52
+ const view = new DataView(header.buffer, header.byteOffset, header.byteLength);
53
+ writeLocalFileHeaderInto(header, view, 0, input);
54
+ return header;
55
+ }
56
+ export function writeCentralDirectoryHeaderInto(out, view, offset, input) {
57
+ const versionMadeBy = input.versionMadeBy ?? VERSION_MADE_BY;
58
+ const versionNeeded = input.versionNeeded ?? VERSION_NEEDED;
59
+ const externalAttributes = input.externalAttributes ?? 0;
60
+ view.setUint32(offset + 0, CENTRAL_DIR_HEADER_SIG, true);
61
+ view.setUint16(offset + 4, versionMadeBy, true);
62
+ view.setUint16(offset + 6, versionNeeded, true);
63
+ view.setUint16(offset + 8, input.flags, true);
64
+ view.setUint16(offset + 10, input.compressionMethod, true);
65
+ view.setUint16(offset + 12, input.dosTime, true);
66
+ view.setUint16(offset + 14, input.dosDate, true);
67
+ view.setUint32(offset + 16, input.crc32, true);
68
+ view.setUint32(offset + 20, input.compressedSize, true);
69
+ view.setUint32(offset + 24, input.uncompressedSize, true);
70
+ view.setUint16(offset + 28, input.fileName.length, true);
71
+ view.setUint16(offset + 30, input.extraField.length, true);
72
+ view.setUint16(offset + 32, input.comment.length, true);
73
+ view.setUint16(offset + 34, 0, true); // disk number start
74
+ view.setUint16(offset + 36, 0, true); // internal file attributes
75
+ view.setUint32(offset + 38, externalAttributes, true);
76
+ view.setUint32(offset + 42, input.localHeaderOffset, true);
77
+ out.set(input.fileName, offset + ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE);
78
+ if (input.extraField.length > 0) {
79
+ out.set(input.extraField, offset + ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE + input.fileName.length);
80
+ }
81
+ if (input.comment.length > 0) {
82
+ out.set(input.comment, offset + ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE + input.fileName.length + input.extraField.length);
83
+ }
84
+ return (ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE +
85
+ input.fileName.length +
86
+ input.extraField.length +
87
+ input.comment.length);
88
+ }
89
+ export function buildCentralDirectoryHeader(input) {
90
+ const header = new Uint8Array(ZIP_CENTRAL_DIR_HEADER_FIXED_SIZE +
91
+ input.fileName.length +
92
+ input.extraField.length +
93
+ input.comment.length);
94
+ const view = new DataView(header.buffer, header.byteOffset, header.byteLength);
95
+ writeCentralDirectoryHeaderInto(header, view, 0, input);
96
+ return header;
97
+ }
98
+ export function writeEndOfCentralDirectoryInto(out, view, offset, input) {
99
+ view.setUint32(offset + 0, END_OF_CENTRAL_DIR_SIG, true);
100
+ view.setUint16(offset + 4, 0, true);
101
+ view.setUint16(offset + 6, 0, true);
102
+ view.setUint16(offset + 8, input.entryCount, true);
103
+ view.setUint16(offset + 10, input.entryCount, true);
104
+ view.setUint32(offset + 12, input.centralDirSize, true);
105
+ view.setUint32(offset + 16, input.centralDirOffset, true);
106
+ view.setUint16(offset + 20, input.comment.length, true);
107
+ if (input.comment.length > 0) {
108
+ out.set(input.comment, offset + ZIP_END_OF_CENTRAL_DIR_FIXED_SIZE);
109
+ }
110
+ return ZIP_END_OF_CENTRAL_DIR_FIXED_SIZE + input.comment.length;
111
+ }
112
+ export function buildEndOfCentralDirectory(input) {
113
+ const record = new Uint8Array(ZIP_END_OF_CENTRAL_DIR_FIXED_SIZE + input.comment.length);
114
+ const view = new DataView(record.buffer, record.byteOffset, record.byteLength);
115
+ writeEndOfCentralDirectoryInto(record, view, 0, input);
116
+ return record;
117
+ }
118
+ export function buildDataDescriptor(crc32, compressedSize, uncompressedSize) {
119
+ const descriptor = new Uint8Array(16);
120
+ const view = new DataView(descriptor.buffer);
121
+ view.setUint32(0, DATA_DESCRIPTOR_SIG, true);
122
+ view.setUint32(4, crc32, true);
123
+ view.setUint32(8, compressedSize, true);
124
+ view.setUint32(12, uncompressedSize, true);
125
+ return descriptor;
126
+ }
@@ -9,7 +9,7 @@
9
9
  * with filesystem-specific features (filename input + temp-file buffering).
10
10
  */
11
11
  import { EventEmitter, Readable } from "../../stream/index.browser.js";
12
- import { createParse } from "../../archive/parse.browser.js";
12
+ import { createParse } from "../../archive/unzip/stream.browser.js";
13
13
  import { iterateStream } from "../utils/iterate-stream.js";
14
14
  import { getWorksheetNoFromWorksheetPath, getWorksheetNoFromWorksheetRelsPath, normalizeZipPath, OOXML_PATHS, worksheetRelTarget } from "../utils/ooxml-paths.js";
15
15
  import { parseSax } from "../utils/parse-sax.js";
@@ -7,7 +7,7 @@
7
7
  * Node.js uses `workbook-writer.ts`, which extends the same base implementation
8
8
  * with filesystem-specific features (filename output + image loading).
9
9
  */
10
- import { Zip } from "@archive/streaming-zip";
10
+ import { Zip } from "@archive/zip/stream";
11
11
  import { StreamBuf } from "@excel/utils/stream-buf";
12
12
  import { StylesXform } from "@excel/xlsx/xform/style/styles-xform";
13
13
  import { SharedStrings } from "@excel/utils/shared-strings";
@@ -7,7 +7,7 @@
7
7
  * Node.js uses `workbook-writer.ts`, which extends the same base implementation
8
8
  * with filesystem-specific features (filename output + image loading).
9
9
  */
10
- import { Zip, ZipDeflate } from "../../archive/streaming-zip.js";
10
+ import { Zip, ZipDeflate } from "../../archive/zip/stream.js";
11
11
  import { StreamBuf } from "../utils/stream-buf.js";
12
12
  import { base64ToUint8Array } from "../../../utils/utils.browser.js";
13
13
  import { RelType } from "../xlsx/rel-type.js";
@@ -0,0 +1,48 @@
1
+ export type OoxmlProblemKind = "missing-part" | "xml-malformed" | "content-types-missing" | "content-types-malformed" | "content-types-missing-default" | "content-types-missing-for-part" | "content-types-duplicate-override" | "root-rels-missing-officeDocument" | "rels-malformed" | "rels-missing-target" | "rels-duplicate-id" | "rels-empty-target" | "rels-invalid-target-path" | "rels-source-missing" | "workbook-sheet-missing-rel" | "workbook-sheet-wrong-rel-type" | "workbook-duplicate-sheetId" | "workbook-duplicate-sheet-rid" | "sheet-missing-rels" | "sheet-controls-missing-drawing" | "sheet-control-missing-rel" | "sheet-control-wrong-rel-type" | "sheet-legacyDrawing-missing-rel" | "sheet-legacyDrawing-wrong-rel-type" | "sheet-drawing-missing-rel" | "sheet-drawing-wrong-rel-type" | "sheet-comments-missing-rel" | "sheet-comments-wrong-rel-type" | "sheet-hyperlink-missing-rel" | "sheet-hyperlink-wrong-rel-type" | "sheet-tablePart-missing-rel" | "sheet-tablePart-wrong-rel-type";
2
+ export type OoxmlOrderingProblemKind = "sheet-legacyDrawing-after-controls";
3
+ export interface OoxmlValidationProblem {
4
+ kind: OoxmlProblemKind;
5
+ file?: string;
6
+ message: string;
7
+ }
8
+ export interface OoxmlOrderingValidationProblem {
9
+ kind: OoxmlOrderingProblemKind;
10
+ file?: string;
11
+ message: string;
12
+ }
13
+ export interface OoxmlValidationReport {
14
+ ok: boolean;
15
+ problems: Array<OoxmlValidationProblem | OoxmlOrderingValidationProblem>;
16
+ stats: {
17
+ entryCount: number;
18
+ xmlLikeCount: number;
19
+ relsCount: number;
20
+ };
21
+ }
22
+ export interface OoxmlValidateOptions {
23
+ /**
24
+ * Whether to check every XML-like entry (.xml, .rels, .vml) for well-formedness.
25
+ * Default: true.
26
+ */
27
+ checkXmlWellFormed?: boolean;
28
+ /**
29
+ * Whether to validate relationship targets exist (TargetMode=External ignored).
30
+ * Default: true.
31
+ */
32
+ checkRelationshipTargets?: boolean;
33
+ /**
34
+ * Whether to validate that every ContentTypes Override PartName exists.
35
+ * Default: true.
36
+ */
37
+ checkContentTypesOverrides?: boolean;
38
+ /**
39
+ * Whether to validate worksheet <controls>/<legacyDrawing> r:id wiring.
40
+ * Default: true.
41
+ */
42
+ checkWorksheetControlWiring?: boolean;
43
+ /**
44
+ * If provided, stops after this many problems.
45
+ */
46
+ maxProblems?: number;
47
+ }
48
+ export declare function validateXlsxBuffer(xlsxBuffer: Uint8Array, options?: OoxmlValidateOptions): Promise<OoxmlValidationReport>;