@cj-tech-master/excelts 4.2.0 → 4.2.1-canary.20260112134913.a3cecdd

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 (317) 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/{types/modules/archive → browser/modules/archive/compression}/compress.base.d.ts +1 -0
  5. package/dist/browser/modules/archive/{compress.base.js → compression/compress.base.js} +2 -1
  6. package/dist/{types/modules/archive → browser/modules/archive/compression}/compress.browser.d.ts +10 -8
  7. package/dist/{esm/modules/archive → browser/modules/archive/compression}/compress.browser.js +18 -19
  8. package/dist/browser/modules/archive/{compress.d.ts → compression/compress.d.ts} +2 -2
  9. package/dist/browser/modules/archive/{compress.js → compression/compress.js} +1 -1
  10. package/dist/browser/modules/archive/{crc32.browser.d.ts → compression/crc32.browser.d.ts} +1 -1
  11. package/dist/browser/modules/archive/{crc32.d.ts → compression/crc32.d.ts} +1 -1
  12. package/dist/browser/modules/archive/{crc32.js → compression/crc32.js} +1 -1
  13. package/dist/browser/modules/archive/{deflate-fallback.js → compression/deflate-fallback.js} +1 -1
  14. package/dist/browser/modules/archive/{streaming-compress.browser.d.ts → compression/streaming-compress.browser.d.ts} +2 -2
  15. package/dist/browser/modules/archive/{streaming-compress.browser.js → compression/streaming-compress.browser.js} +3 -3
  16. package/dist/browser/modules/archive/{streaming-compress.d.ts → compression/streaming-compress.d.ts} +2 -2
  17. package/dist/browser/modules/archive/{streaming-compress.js → compression/streaming-compress.js} +2 -2
  18. package/dist/browser/modules/archive/defaults.d.ts +1 -0
  19. package/dist/browser/modules/archive/defaults.js +6 -3
  20. package/dist/browser/modules/archive/index.base.d.ts +4 -4
  21. package/dist/browser/modules/archive/index.base.js +3 -6
  22. package/dist/browser/modules/archive/index.browser.d.ts +3 -4
  23. package/dist/browser/modules/archive/index.browser.js +3 -7
  24. package/dist/browser/modules/archive/index.d.ts +3 -4
  25. package/dist/browser/modules/archive/index.js +3 -5
  26. package/dist/browser/modules/archive/internal/byte-queue.d.ts +33 -0
  27. package/dist/browser/modules/archive/internal/byte-queue.js +407 -0
  28. package/dist/browser/modules/archive/io/archive-sink.d.ts +8 -0
  29. package/dist/browser/modules/archive/io/archive-sink.js +45 -0
  30. package/dist/browser/modules/archive/io/archive-source.d.ts +6 -0
  31. package/dist/browser/modules/archive/io/archive-source.js +100 -0
  32. package/dist/browser/modules/archive/{extract.d.ts → unzip/extract.d.ts} +2 -2
  33. package/dist/browser/modules/archive/unzip/index.d.ts +40 -0
  34. package/dist/browser/modules/archive/unzip/index.js +164 -0
  35. package/dist/browser/modules/archive/{parse.base.d.ts → unzip/stream.base.d.ts} +58 -3
  36. package/dist/browser/modules/archive/unzip/stream.base.js +1022 -0
  37. package/dist/browser/modules/archive/{parse.browser.d.ts → unzip/stream.browser.d.ts} +1 -1
  38. package/dist/browser/modules/archive/{parse.browser.js → unzip/stream.browser.js} +376 -110
  39. package/dist/browser/modules/archive/{parse.d.ts → unzip/stream.d.ts} +2 -2
  40. package/dist/{esm/modules/archive/parse.js → browser/modules/archive/unzip/stream.js} +7 -6
  41. package/dist/{types/modules/archive → browser/modules/archive/unzip}/zip-parser.d.ts +1 -1
  42. package/dist/{esm/modules/archive → browser/modules/archive/unzip}/zip-parser.js +38 -24
  43. package/dist/browser/modules/archive/utils/async-queue.d.ts +7 -0
  44. package/dist/browser/modules/archive/utils/async-queue.js +103 -0
  45. package/dist/browser/modules/archive/utils/bytes.js +16 -16
  46. package/dist/browser/modules/archive/utils/compressibility.d.ts +10 -0
  47. package/dist/browser/modules/archive/utils/compressibility.js +57 -0
  48. package/dist/browser/modules/archive/utils/parse-buffer.js +21 -23
  49. package/dist/browser/modules/archive/utils/pattern-scanner.d.ts +21 -0
  50. package/dist/browser/modules/archive/utils/pattern-scanner.js +27 -0
  51. package/dist/browser/modules/archive/utils/timestamps.js +62 -1
  52. package/dist/browser/modules/archive/utils/zip-extra-fields.d.ts +1 -1
  53. package/dist/browser/modules/archive/utils/zip-extra-fields.js +26 -14
  54. package/dist/browser/modules/archive/zip/index.d.ts +42 -0
  55. package/dist/browser/modules/archive/zip/index.js +157 -0
  56. package/dist/browser/modules/archive/{streaming-zip.d.ts → zip/stream.d.ts} +28 -5
  57. package/dist/browser/modules/archive/{streaming-zip.js → zip/stream.js} +192 -48
  58. package/dist/browser/modules/archive/zip/zip-bytes.d.ts +73 -0
  59. package/dist/browser/modules/archive/zip/zip-bytes.js +239 -0
  60. package/dist/{esm/modules/archive → browser/modules/archive/zip}/zip-entry-metadata.js +3 -3
  61. package/dist/browser/modules/archive/{zip-records.d.ts → zip-spec/zip-records.d.ts} +20 -0
  62. package/dist/browser/modules/archive/zip-spec/zip-records.js +126 -0
  63. package/dist/browser/modules/excel/form-control.d.ts +2 -0
  64. package/dist/browser/modules/excel/form-control.js +54 -16
  65. package/dist/browser/modules/excel/stream/workbook-reader.browser.js +1 -1
  66. package/dist/browser/modules/excel/stream/workbook-writer.browser.d.ts +1 -1
  67. package/dist/browser/modules/excel/stream/workbook-writer.browser.js +1 -1
  68. package/dist/browser/modules/excel/utils/ooxml-validator.d.ts +48 -0
  69. package/dist/browser/modules/excel/utils/ooxml-validator.js +469 -0
  70. package/dist/browser/modules/excel/worksheet.js +5 -2
  71. package/dist/browser/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.d.ts +1 -0
  72. package/dist/browser/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.js +13 -1
  73. package/dist/browser/modules/excel/xlsx/xform/drawing/sp-xform.d.ts +18 -0
  74. package/dist/browser/modules/excel/xlsx/xform/drawing/sp-xform.js +112 -0
  75. package/dist/browser/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.d.ts +6 -1
  76. package/dist/browser/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +30 -2
  77. package/dist/browser/modules/excel/xlsx/xform/drawing/vml-drawing-xform.js +11 -0
  78. package/dist/browser/modules/excel/xlsx/xform/sheet/page-setup-xform.d.ts +1 -0
  79. package/dist/browser/modules/excel/xlsx/xform/sheet/page-setup-xform.js +16 -2
  80. package/dist/browser/modules/excel/xlsx/xform/sheet/worksheet-xform.js +117 -5
  81. package/dist/browser/modules/excel/xlsx/xlsx.browser.js +3 -6
  82. package/dist/browser/modules/excel/xlsx/xlsx.js +1 -1
  83. package/dist/browser/modules/stream/base-transform.d.ts +3 -0
  84. package/dist/browser/modules/stream/base-transform.js +34 -20
  85. package/dist/browser/modules/stream/buffered-stream.d.ts +2 -12
  86. package/dist/browser/modules/stream/chunked-builder.js +4 -4
  87. package/dist/browser/modules/stream/index.browser.d.ts +13 -19
  88. package/dist/browser/modules/stream/index.browser.js +10 -22
  89. package/dist/browser/modules/stream/index.d.ts +18 -41
  90. package/dist/browser/modules/stream/index.js +15 -44
  91. package/dist/browser/modules/stream/internal/event-utils.d.ts +17 -0
  92. package/dist/browser/modules/stream/internal/event-utils.js +40 -0
  93. package/dist/browser/modules/stream/internal/type-guards.d.ts +9 -0
  94. package/dist/browser/modules/stream/internal/type-guards.js +24 -0
  95. package/dist/browser/modules/stream/pull-stream.d.ts +5 -6
  96. package/dist/browser/modules/stream/pull-stream.js +107 -43
  97. package/dist/browser/modules/stream/shared.d.ts +1 -1
  98. package/dist/browser/modules/stream/shared.js +7 -4
  99. package/dist/browser/modules/stream/streams.browser.d.ts +32 -42
  100. package/dist/browser/modules/stream/streams.browser.js +941 -823
  101. package/dist/browser/modules/stream/streams.d.ts +4 -20
  102. package/dist/browser/modules/stream/streams.js +146 -95
  103. package/dist/browser/modules/stream/utils.js +5 -38
  104. package/dist/cjs/modules/archive/{compress.base.js → compression/compress.base.js} +2 -1
  105. package/dist/cjs/modules/archive/{compress.browser.js → compression/compress.browser.js} +18 -19
  106. package/dist/cjs/modules/archive/{compress.js → compression/compress.js} +1 -1
  107. package/dist/cjs/modules/archive/{crc32.js → compression/crc32.js} +1 -1
  108. package/dist/cjs/modules/archive/{deflate-fallback.js → compression/deflate-fallback.js} +1 -1
  109. package/dist/cjs/modules/archive/{streaming-compress.browser.js → compression/streaming-compress.browser.js} +3 -3
  110. package/dist/cjs/modules/archive/{streaming-compress.js → compression/streaming-compress.js} +2 -2
  111. package/dist/cjs/modules/archive/defaults.js +7 -4
  112. package/dist/cjs/modules/archive/index.base.js +9 -19
  113. package/dist/cjs/modules/archive/index.browser.js +4 -10
  114. package/dist/cjs/modules/archive/index.js +4 -8
  115. package/dist/cjs/modules/archive/internal/byte-queue.js +411 -0
  116. package/dist/cjs/modules/archive/io/archive-sink.js +49 -0
  117. package/dist/cjs/modules/archive/io/archive-source.js +105 -0
  118. package/dist/cjs/modules/archive/unzip/index.js +170 -0
  119. package/dist/cjs/modules/archive/unzip/stream.base.js +1044 -0
  120. package/dist/cjs/modules/archive/{parse.browser.js → unzip/stream.browser.js} +377 -111
  121. package/dist/cjs/modules/archive/{parse.js → unzip/stream.js} +9 -8
  122. package/dist/cjs/modules/archive/{zip-parser.js → unzip/zip-parser.js} +47 -33
  123. package/dist/cjs/modules/archive/utils/async-queue.js +106 -0
  124. package/dist/cjs/modules/archive/utils/bytes.js +16 -16
  125. package/dist/cjs/modules/archive/utils/compressibility.js +60 -0
  126. package/dist/cjs/modules/archive/utils/parse-buffer.js +21 -23
  127. package/dist/cjs/modules/archive/utils/pattern-scanner.js +31 -0
  128. package/dist/cjs/modules/archive/utils/timestamps.js +64 -3
  129. package/dist/cjs/modules/archive/utils/zip-extra-fields.js +26 -14
  130. package/dist/cjs/modules/archive/zip/index.js +162 -0
  131. package/dist/cjs/modules/archive/{streaming-zip.js → zip/stream.js} +194 -50
  132. package/dist/cjs/modules/archive/zip/zip-bytes.js +242 -0
  133. package/dist/cjs/modules/archive/{zip-entry-metadata.js → zip/zip-entry-metadata.js} +5 -5
  134. package/dist/cjs/modules/archive/zip-spec/zip-records.js +136 -0
  135. package/dist/cjs/modules/excel/form-control.js +54 -16
  136. package/dist/cjs/modules/excel/stream/workbook-reader.browser.js +2 -2
  137. package/dist/cjs/modules/excel/stream/workbook-writer.browser.js +4 -4
  138. package/dist/cjs/modules/excel/utils/ooxml-validator.js +475 -0
  139. package/dist/cjs/modules/excel/worksheet.js +5 -2
  140. package/dist/cjs/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.js +13 -1
  141. package/dist/cjs/modules/excel/xlsx/xform/drawing/sp-xform.js +115 -0
  142. package/dist/cjs/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +30 -2
  143. package/dist/cjs/modules/excel/xlsx/xform/drawing/vml-drawing-xform.js +11 -0
  144. package/dist/cjs/modules/excel/xlsx/xform/sheet/page-setup-xform.js +16 -2
  145. package/dist/cjs/modules/excel/xlsx/xform/sheet/worksheet-xform.js +117 -5
  146. package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +6 -9
  147. package/dist/cjs/modules/excel/xlsx/xlsx.js +2 -2
  148. package/dist/cjs/modules/stream/base-transform.js +34 -20
  149. package/dist/cjs/modules/stream/chunked-builder.js +4 -4
  150. package/dist/cjs/modules/stream/index.browser.js +10 -17
  151. package/dist/cjs/modules/stream/index.js +15 -39
  152. package/dist/cjs/modules/stream/internal/event-utils.js +43 -0
  153. package/dist/cjs/modules/stream/internal/type-guards.js +30 -0
  154. package/dist/cjs/modules/stream/pull-stream.js +107 -43
  155. package/dist/cjs/modules/stream/shared.js +7 -4
  156. package/dist/cjs/modules/stream/streams.browser.js +947 -834
  157. package/dist/cjs/modules/stream/streams.js +156 -107
  158. package/dist/cjs/modules/stream/utils.js +3 -36
  159. package/dist/esm/index.browser.js +12 -0
  160. package/dist/esm/modules/archive/{compress.base.js → compression/compress.base.js} +2 -1
  161. package/dist/{browser/modules/archive → esm/modules/archive/compression}/compress.browser.js +18 -19
  162. package/dist/esm/modules/archive/{compress.js → compression/compress.js} +1 -1
  163. package/dist/esm/modules/archive/{crc32.js → compression/crc32.js} +1 -1
  164. package/dist/esm/modules/archive/{deflate-fallback.js → compression/deflate-fallback.js} +1 -1
  165. package/dist/esm/modules/archive/{streaming-compress.browser.js → compression/streaming-compress.browser.js} +3 -3
  166. package/dist/esm/modules/archive/{streaming-compress.js → compression/streaming-compress.js} +2 -2
  167. package/dist/esm/modules/archive/defaults.js +6 -3
  168. package/dist/esm/modules/archive/index.base.js +3 -6
  169. package/dist/esm/modules/archive/index.browser.js +3 -7
  170. package/dist/esm/modules/archive/index.js +3 -5
  171. package/dist/esm/modules/archive/internal/byte-queue.js +407 -0
  172. package/dist/esm/modules/archive/io/archive-sink.js +45 -0
  173. package/dist/esm/modules/archive/io/archive-source.js +100 -0
  174. package/dist/esm/modules/archive/unzip/index.js +164 -0
  175. package/dist/esm/modules/archive/unzip/stream.base.js +1022 -0
  176. package/dist/esm/modules/archive/{parse.browser.js → unzip/stream.browser.js} +376 -110
  177. package/dist/{browser/modules/archive/parse.js → esm/modules/archive/unzip/stream.js} +7 -6
  178. package/dist/{browser/modules/archive → esm/modules/archive/unzip}/zip-parser.js +38 -24
  179. package/dist/esm/modules/archive/utils/async-queue.js +103 -0
  180. package/dist/esm/modules/archive/utils/bytes.js +16 -16
  181. package/dist/esm/modules/archive/utils/compressibility.js +57 -0
  182. package/dist/esm/modules/archive/utils/parse-buffer.js +21 -23
  183. package/dist/esm/modules/archive/utils/pattern-scanner.js +27 -0
  184. package/dist/esm/modules/archive/utils/timestamps.js +62 -1
  185. package/dist/esm/modules/archive/utils/zip-extra-fields.js +26 -14
  186. package/dist/esm/modules/archive/zip/index.js +157 -0
  187. package/dist/esm/modules/archive/{streaming-zip.js → zip/stream.js} +192 -48
  188. package/dist/esm/modules/archive/zip/zip-bytes.js +239 -0
  189. package/dist/{browser/modules/archive → esm/modules/archive/zip}/zip-entry-metadata.js +3 -3
  190. package/dist/esm/modules/archive/zip-spec/zip-records.js +126 -0
  191. package/dist/esm/modules/excel/form-control.js +54 -16
  192. package/dist/esm/modules/excel/stream/workbook-reader.browser.js +1 -1
  193. package/dist/esm/modules/excel/stream/workbook-writer.browser.js +1 -1
  194. package/dist/esm/modules/excel/utils/ooxml-validator.js +469 -0
  195. package/dist/esm/modules/excel/worksheet.js +5 -2
  196. package/dist/esm/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.js +13 -1
  197. package/dist/esm/modules/excel/xlsx/xform/drawing/sp-xform.js +112 -0
  198. package/dist/esm/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +30 -2
  199. package/dist/esm/modules/excel/xlsx/xform/drawing/vml-drawing-xform.js +11 -0
  200. package/dist/esm/modules/excel/xlsx/xform/sheet/page-setup-xform.js +16 -2
  201. package/dist/esm/modules/excel/xlsx/xform/sheet/worksheet-xform.js +117 -5
  202. package/dist/esm/modules/excel/xlsx/xlsx.browser.js +3 -6
  203. package/dist/esm/modules/excel/xlsx/xlsx.js +1 -1
  204. package/dist/esm/modules/stream/base-transform.js +34 -20
  205. package/dist/esm/modules/stream/chunked-builder.js +4 -4
  206. package/dist/esm/modules/stream/index.browser.js +10 -22
  207. package/dist/esm/modules/stream/index.js +15 -44
  208. package/dist/esm/modules/stream/internal/event-utils.js +40 -0
  209. package/dist/esm/modules/stream/internal/type-guards.js +24 -0
  210. package/dist/esm/modules/stream/pull-stream.js +107 -43
  211. package/dist/esm/modules/stream/shared.js +7 -4
  212. package/dist/esm/modules/stream/streams.browser.js +941 -823
  213. package/dist/esm/modules/stream/streams.js +146 -95
  214. package/dist/esm/modules/stream/utils.js +5 -38
  215. package/dist/iife/THIRD_PARTY_NOTICES.md +81 -0
  216. package/dist/iife/excelts.iife.js +4979 -2800
  217. package/dist/iife/excelts.iife.js.map +1 -1
  218. package/dist/iife/excelts.iife.min.js +103 -31
  219. package/dist/types/index.browser.d.ts +1 -0
  220. package/dist/{browser/modules/archive → types/modules/archive/compression}/compress.base.d.ts +1 -0
  221. package/dist/{browser/modules/archive → types/modules/archive/compression}/compress.browser.d.ts +10 -8
  222. package/dist/types/modules/archive/{streaming-compress.browser.d.ts → compression/streaming-compress.browser.d.ts} +1 -1
  223. package/dist/types/modules/archive/defaults.d.ts +1 -0
  224. package/dist/types/modules/archive/index.base.d.ts +4 -4
  225. package/dist/types/modules/archive/index.browser.d.ts +3 -4
  226. package/dist/types/modules/archive/index.d.ts +3 -4
  227. package/dist/types/modules/archive/internal/byte-queue.d.ts +33 -0
  228. package/dist/types/modules/archive/io/archive-sink.d.ts +8 -0
  229. package/dist/types/modules/archive/io/archive-source.d.ts +6 -0
  230. package/dist/types/modules/archive/unzip/index.d.ts +40 -0
  231. package/dist/types/modules/archive/{parse.base.d.ts → unzip/stream.base.d.ts} +60 -5
  232. package/dist/types/modules/archive/{parse.browser.d.ts → unzip/stream.browser.d.ts} +2 -2
  233. package/dist/types/modules/archive/{parse.d.ts → unzip/stream.d.ts} +3 -3
  234. package/dist/{browser/modules/archive → types/modules/archive/unzip}/zip-parser.d.ts +1 -1
  235. package/dist/types/modules/archive/utils/async-queue.d.ts +7 -0
  236. package/dist/types/modules/archive/utils/compressibility.d.ts +10 -0
  237. package/dist/types/modules/archive/utils/pattern-scanner.d.ts +21 -0
  238. package/dist/types/modules/archive/utils/zip-extra-fields.d.ts +1 -1
  239. package/dist/types/modules/archive/zip/index.d.ts +42 -0
  240. package/dist/types/modules/archive/{streaming-zip.d.ts → zip/stream.d.ts} +29 -6
  241. package/dist/types/modules/archive/zip/zip-bytes.d.ts +73 -0
  242. package/dist/types/modules/archive/{zip-entry-metadata.d.ts → zip/zip-entry-metadata.d.ts} +1 -1
  243. package/dist/types/modules/archive/{zip-records.d.ts → zip-spec/zip-records.d.ts} +20 -0
  244. package/dist/types/modules/excel/form-control.d.ts +2 -0
  245. package/dist/types/modules/excel/stream/workbook-writer.browser.d.ts +1 -1
  246. package/dist/types/modules/excel/utils/ooxml-validator.d.ts +48 -0
  247. package/dist/types/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.d.ts +1 -0
  248. package/dist/types/modules/excel/xlsx/xform/drawing/sp-xform.d.ts +18 -0
  249. package/dist/types/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.d.ts +6 -1
  250. package/dist/types/modules/excel/xlsx/xform/sheet/page-setup-xform.d.ts +1 -0
  251. package/dist/types/modules/stream/base-transform.d.ts +3 -0
  252. package/dist/types/modules/stream/buffered-stream.d.ts +2 -12
  253. package/dist/types/modules/stream/index.browser.d.ts +13 -19
  254. package/dist/types/modules/stream/index.d.ts +18 -41
  255. package/dist/types/modules/stream/internal/event-utils.d.ts +17 -0
  256. package/dist/types/modules/stream/internal/type-guards.d.ts +9 -0
  257. package/dist/types/modules/stream/pull-stream.d.ts +5 -6
  258. package/dist/types/modules/stream/shared.d.ts +1 -1
  259. package/dist/types/modules/stream/streams.browser.d.ts +32 -42
  260. package/dist/types/modules/stream/streams.d.ts +4 -20
  261. package/package.json +19 -15
  262. package/dist/browser/modules/archive/byte-queue.d.ts +0 -18
  263. package/dist/browser/modules/archive/byte-queue.js +0 -125
  264. package/dist/browser/modules/archive/parse.base.js +0 -610
  265. package/dist/browser/modules/archive/utils/zip-extra.d.ts +0 -18
  266. package/dist/browser/modules/archive/utils/zip-extra.js +0 -68
  267. package/dist/browser/modules/archive/zip-builder.d.ts +0 -117
  268. package/dist/browser/modules/archive/zip-builder.js +0 -292
  269. package/dist/browser/modules/archive/zip-constants.d.ts +0 -18
  270. package/dist/browser/modules/archive/zip-constants.js +0 -23
  271. package/dist/browser/modules/archive/zip-records.js +0 -84
  272. package/dist/cjs/modules/archive/byte-queue.js +0 -129
  273. package/dist/cjs/modules/archive/parse.base.js +0 -632
  274. package/dist/cjs/modules/archive/utils/zip-extra.js +0 -74
  275. package/dist/cjs/modules/archive/zip-builder.js +0 -297
  276. package/dist/cjs/modules/archive/zip-constants.js +0 -26
  277. package/dist/cjs/modules/archive/zip-records.js +0 -90
  278. package/dist/esm/modules/archive/byte-queue.js +0 -125
  279. package/dist/esm/modules/archive/parse.base.js +0 -610
  280. package/dist/esm/modules/archive/utils/zip-extra.js +0 -68
  281. package/dist/esm/modules/archive/zip-builder.js +0 -292
  282. package/dist/esm/modules/archive/zip-constants.js +0 -23
  283. package/dist/esm/modules/archive/zip-records.js +0 -84
  284. package/dist/types/modules/archive/byte-queue.d.ts +0 -18
  285. package/dist/types/modules/archive/utils/zip-extra.d.ts +0 -18
  286. package/dist/types/modules/archive/zip-builder.d.ts +0 -117
  287. package/dist/types/modules/archive/zip-constants.d.ts +0 -18
  288. /package/dist/browser/modules/archive/{crc32.base.d.ts → compression/crc32.base.d.ts} +0 -0
  289. /package/dist/browser/modules/archive/{crc32.base.js → compression/crc32.base.js} +0 -0
  290. /package/dist/browser/modules/archive/{crc32.browser.js → compression/crc32.browser.js} +0 -0
  291. /package/dist/browser/modules/archive/{deflate-fallback.d.ts → compression/deflate-fallback.d.ts} +0 -0
  292. /package/dist/browser/modules/archive/{streaming-compress.base.d.ts → compression/streaming-compress.base.d.ts} +0 -0
  293. /package/dist/browser/modules/archive/{streaming-compress.base.js → compression/streaming-compress.base.js} +0 -0
  294. /package/dist/browser/modules/archive/{extract.js → unzip/extract.js} +0 -0
  295. /package/dist/browser/modules/archive/{zip-entry-metadata.d.ts → zip/zip-entry-metadata.d.ts} +0 -0
  296. /package/dist/browser/modules/archive/{zip-entry-info.d.ts → zip-spec/zip-entry-info.d.ts} +0 -0
  297. /package/dist/browser/modules/archive/{zip-entry-info.js → zip-spec/zip-entry-info.js} +0 -0
  298. /package/dist/cjs/modules/archive/{crc32.base.js → compression/crc32.base.js} +0 -0
  299. /package/dist/cjs/modules/archive/{crc32.browser.js → compression/crc32.browser.js} +0 -0
  300. /package/dist/cjs/modules/archive/{streaming-compress.base.js → compression/streaming-compress.base.js} +0 -0
  301. /package/dist/cjs/modules/archive/{extract.js → unzip/extract.js} +0 -0
  302. /package/dist/cjs/modules/archive/{zip-entry-info.js → zip-spec/zip-entry-info.js} +0 -0
  303. /package/dist/esm/modules/archive/{crc32.base.js → compression/crc32.base.js} +0 -0
  304. /package/dist/esm/modules/archive/{crc32.browser.js → compression/crc32.browser.js} +0 -0
  305. /package/dist/esm/modules/archive/{streaming-compress.base.js → compression/streaming-compress.base.js} +0 -0
  306. /package/dist/esm/modules/archive/{extract.js → unzip/extract.js} +0 -0
  307. /package/dist/esm/modules/archive/{zip-entry-info.js → zip-spec/zip-entry-info.js} +0 -0
  308. /package/dist/{LICENSE → iife/LICENSE} +0 -0
  309. /package/dist/types/modules/archive/{compress.d.ts → compression/compress.d.ts} +0 -0
  310. /package/dist/types/modules/archive/{crc32.base.d.ts → compression/crc32.base.d.ts} +0 -0
  311. /package/dist/types/modules/archive/{crc32.browser.d.ts → compression/crc32.browser.d.ts} +0 -0
  312. /package/dist/types/modules/archive/{crc32.d.ts → compression/crc32.d.ts} +0 -0
  313. /package/dist/types/modules/archive/{deflate-fallback.d.ts → compression/deflate-fallback.d.ts} +0 -0
  314. /package/dist/types/modules/archive/{streaming-compress.base.d.ts → compression/streaming-compress.base.d.ts} +0 -0
  315. /package/dist/types/modules/archive/{streaming-compress.d.ts → compression/streaming-compress.d.ts} +0 -0
  316. /package/dist/types/modules/archive/{extract.d.ts → unzip/extract.d.ts} +0 -0
  317. /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
+ }
@@ -42,6 +42,8 @@ export interface FormCheckboxModel {
42
42
  shapeId: number;
43
43
  /** Control property ID (rId in relationships) */
44
44
  ctrlPropId: number;
45
+ /** Relationship id (e.g., rId5) in sheet rels for ctrlProp (set during XLSX prepare) */
46
+ ctrlPropRelId?: string;
45
47
  /** Top-left anchor */
46
48
  tl: FormControlAnchor;
47
49
  /** Bottom-right anchor */
@@ -106,25 +106,63 @@ class FormCheckbox {
106
106
  let tl;
107
107
  let br;
108
108
  if (typeof range === "string") {
109
- // Parse cell reference like "B2" or "B2:D3"
110
- const decoded = colCache.decode(range);
111
- if ("top" in decoded) {
112
- // It's a range like "B2:D3"
113
- tl = {
114
- col: decoded.left - 1, // Convert to 0-based
115
- colOff: DEFAULT_COL_OFF,
116
- row: decoded.top - 1,
117
- rowOff: DEFAULT_ROW_OFF
118
- };
119
- br = {
120
- col: decoded.right - 1,
121
- colOff: DEFAULT_END_COL_OFF,
122
- row: decoded.bottom - 1,
123
- rowOff: DEFAULT_END_ROW_OFF
124
- };
109
+ // Parse cell reference like "B2" or range like "B2:D3"
110
+ const isRange = range.includes(":");
111
+ if (isRange) {
112
+ const decoded = colCache.decode(range);
113
+ if ("top" in decoded) {
114
+ // Treat 1-cell ranges (e.g., "J4:J4") as a single cell with default checkbox size.
115
+ if (decoded.left === decoded.right && decoded.top === decoded.bottom) {
116
+ const col = decoded.left - 1;
117
+ const row = decoded.top - 1;
118
+ tl = {
119
+ col,
120
+ colOff: DEFAULT_COL_OFF,
121
+ row,
122
+ rowOff: DEFAULT_ROW_OFF
123
+ };
124
+ br = {
125
+ col: col + 2,
126
+ colOff: DEFAULT_END_COL_OFF,
127
+ row: row + 1,
128
+ rowOff: DEFAULT_END_ROW_OFF
129
+ };
130
+ }
131
+ else {
132
+ // Regular range
133
+ tl = {
134
+ col: decoded.left - 1, // Convert to 0-based
135
+ colOff: DEFAULT_COL_OFF,
136
+ row: decoded.top - 1,
137
+ rowOff: DEFAULT_ROW_OFF
138
+ };
139
+ br = {
140
+ col: decoded.right - 1,
141
+ colOff: DEFAULT_END_COL_OFF,
142
+ row: decoded.bottom - 1,
143
+ rowOff: DEFAULT_END_ROW_OFF
144
+ };
145
+ }
146
+ }
147
+ else {
148
+ // Defensive fallback: if the cache returns an address, treat it like a single-cell ref.
149
+ tl = {
150
+ col: decoded.col - 1,
151
+ colOff: DEFAULT_COL_OFF,
152
+ row: decoded.row - 1,
153
+ rowOff: DEFAULT_ROW_OFF
154
+ };
155
+ br = {
156
+ col: decoded.col + 1,
157
+ colOff: DEFAULT_END_COL_OFF,
158
+ row: decoded.row,
159
+ rowOff: DEFAULT_END_ROW_OFF
160
+ };
161
+ }
125
162
  }
126
163
  else {
127
164
  // Single cell reference - create default size checkbox
165
+ const decoded = colCache.decodeAddress(range);
128
166
  tl = {
129
167
  col: decoded.col - 1,
130
168
  colOff: DEFAULT_COL_OFF,
@@ -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>;