@cj-tech-master/excelts 4.2.1 → 4.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (311) 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/worksheet.js +5 -2
  68. package/dist/browser/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.d.ts +1 -0
  69. package/dist/browser/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.js +13 -1
  70. package/dist/browser/modules/excel/xlsx/xform/drawing/sp-xform.d.ts +18 -0
  71. package/dist/browser/modules/excel/xlsx/xform/drawing/sp-xform.js +112 -0
  72. package/dist/browser/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.d.ts +6 -1
  73. package/dist/browser/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +30 -2
  74. package/dist/browser/modules/excel/xlsx/xform/drawing/vml-drawing-xform.js +11 -0
  75. package/dist/browser/modules/excel/xlsx/xform/sheet/page-setup-xform.d.ts +1 -0
  76. package/dist/browser/modules/excel/xlsx/xform/sheet/page-setup-xform.js +16 -2
  77. package/dist/browser/modules/excel/xlsx/xform/sheet/worksheet-xform.js +110 -12
  78. package/dist/browser/modules/excel/xlsx/xlsx.browser.js +3 -6
  79. package/dist/browser/modules/excel/xlsx/xlsx.js +1 -1
  80. package/dist/browser/modules/stream/base-transform.d.ts +3 -0
  81. package/dist/browser/modules/stream/base-transform.js +34 -20
  82. package/dist/browser/modules/stream/buffered-stream.d.ts +2 -12
  83. package/dist/browser/modules/stream/chunked-builder.js +4 -4
  84. package/dist/browser/modules/stream/index.browser.d.ts +13 -19
  85. package/dist/browser/modules/stream/index.browser.js +10 -22
  86. package/dist/browser/modules/stream/index.d.ts +18 -41
  87. package/dist/browser/modules/stream/index.js +15 -44
  88. package/dist/browser/modules/stream/internal/event-utils.d.ts +17 -0
  89. package/dist/browser/modules/stream/internal/event-utils.js +40 -0
  90. package/dist/browser/modules/stream/internal/type-guards.d.ts +9 -0
  91. package/dist/browser/modules/stream/internal/type-guards.js +24 -0
  92. package/dist/browser/modules/stream/pull-stream.d.ts +5 -6
  93. package/dist/browser/modules/stream/pull-stream.js +107 -43
  94. package/dist/browser/modules/stream/shared.d.ts +1 -1
  95. package/dist/browser/modules/stream/shared.js +7 -4
  96. package/dist/browser/modules/stream/streams.browser.d.ts +32 -44
  97. package/dist/browser/modules/stream/streams.browser.js +921 -836
  98. package/dist/browser/modules/stream/streams.d.ts +4 -20
  99. package/dist/browser/modules/stream/streams.js +146 -95
  100. package/dist/browser/modules/stream/utils.js +5 -38
  101. package/dist/cjs/modules/archive/{compress.base.js → compression/compress.base.js} +1 -1
  102. package/dist/cjs/modules/archive/{compress.browser.js → compression/compress.browser.js} +3 -11
  103. package/dist/cjs/modules/archive/{compress.js → compression/compress.js} +1 -1
  104. package/dist/cjs/modules/archive/{crc32.js → compression/crc32.js} +1 -1
  105. package/dist/cjs/modules/archive/{deflate-fallback.js → compression/deflate-fallback.js} +1 -1
  106. package/dist/cjs/modules/archive/{streaming-compress.browser.js → compression/streaming-compress.browser.js} +3 -3
  107. package/dist/cjs/modules/archive/{streaming-compress.js → compression/streaming-compress.js} +2 -2
  108. package/dist/cjs/modules/archive/defaults.js +7 -4
  109. package/dist/cjs/modules/archive/index.base.js +9 -19
  110. package/dist/cjs/modules/archive/index.browser.js +4 -10
  111. package/dist/cjs/modules/archive/index.js +4 -8
  112. package/dist/cjs/modules/archive/internal/byte-queue.js +411 -0
  113. package/dist/cjs/modules/archive/io/archive-sink.js +49 -0
  114. package/dist/cjs/modules/archive/io/archive-source.js +105 -0
  115. package/dist/cjs/modules/archive/unzip/index.js +170 -0
  116. package/dist/cjs/modules/archive/unzip/stream.base.js +1044 -0
  117. package/dist/cjs/modules/archive/{parse.browser.js → unzip/stream.browser.js} +372 -111
  118. package/dist/cjs/modules/archive/{parse.js → unzip/stream.js} +9 -8
  119. package/dist/cjs/modules/archive/{zip-parser.js → unzip/zip-parser.js} +47 -33
  120. package/dist/cjs/modules/archive/utils/async-queue.js +106 -0
  121. package/dist/cjs/modules/archive/utils/bytes.js +16 -16
  122. package/dist/cjs/modules/archive/utils/compressibility.js +60 -0
  123. package/dist/cjs/modules/archive/utils/parse-buffer.js +21 -23
  124. package/dist/cjs/modules/archive/utils/pattern-scanner.js +31 -0
  125. package/dist/cjs/modules/archive/utils/timestamps.js +64 -3
  126. package/dist/cjs/modules/archive/utils/zip-extra-fields.js +26 -14
  127. package/dist/cjs/modules/archive/zip/index.js +162 -0
  128. package/dist/cjs/modules/archive/{streaming-zip.js → zip/stream.js} +194 -50
  129. package/dist/cjs/modules/archive/zip/zip-bytes.js +242 -0
  130. package/dist/cjs/modules/archive/{zip-entry-metadata.js → zip/zip-entry-metadata.js} +5 -5
  131. package/dist/cjs/modules/archive/zip-spec/zip-records.js +136 -0
  132. package/dist/cjs/modules/excel/stream/workbook-reader.browser.js +2 -2
  133. package/dist/cjs/modules/excel/stream/workbook-writer.browser.js +4 -4
  134. package/dist/cjs/modules/excel/utils/ooxml-validator.js +475 -0
  135. package/dist/cjs/modules/excel/worksheet.js +5 -2
  136. package/dist/cjs/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.js +13 -1
  137. package/dist/cjs/modules/excel/xlsx/xform/drawing/sp-xform.js +115 -0
  138. package/dist/cjs/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +30 -2
  139. package/dist/cjs/modules/excel/xlsx/xform/drawing/vml-drawing-xform.js +11 -0
  140. package/dist/cjs/modules/excel/xlsx/xform/sheet/page-setup-xform.js +16 -2
  141. package/dist/cjs/modules/excel/xlsx/xform/sheet/worksheet-xform.js +110 -12
  142. package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +6 -9
  143. package/dist/cjs/modules/excel/xlsx/xlsx.js +2 -2
  144. package/dist/cjs/modules/stream/base-transform.js +34 -20
  145. package/dist/cjs/modules/stream/chunked-builder.js +4 -4
  146. package/dist/cjs/modules/stream/index.browser.js +10 -17
  147. package/dist/cjs/modules/stream/index.js +15 -39
  148. package/dist/cjs/modules/stream/internal/event-utils.js +43 -0
  149. package/dist/cjs/modules/stream/internal/type-guards.js +30 -0
  150. package/dist/cjs/modules/stream/pull-stream.js +107 -43
  151. package/dist/cjs/modules/stream/shared.js +7 -4
  152. package/dist/cjs/modules/stream/streams.browser.js +927 -847
  153. package/dist/cjs/modules/stream/streams.js +156 -107
  154. package/dist/cjs/modules/stream/utils.js +3 -36
  155. package/dist/esm/index.browser.js +12 -0
  156. package/dist/{browser/modules/archive → esm/modules/archive/compression}/compress.base.js +1 -1
  157. package/dist/esm/modules/archive/{compress.browser.js → compression/compress.browser.js} +3 -11
  158. package/dist/{browser/modules/archive → esm/modules/archive/compression}/compress.js +1 -1
  159. package/dist/esm/modules/archive/{crc32.js → compression/crc32.js} +1 -1
  160. package/dist/esm/modules/archive/{deflate-fallback.js → compression/deflate-fallback.js} +1 -1
  161. package/dist/esm/modules/archive/{streaming-compress.browser.js → compression/streaming-compress.browser.js} +3 -3
  162. package/dist/esm/modules/archive/{streaming-compress.js → compression/streaming-compress.js} +2 -2
  163. package/dist/esm/modules/archive/defaults.js +6 -3
  164. package/dist/esm/modules/archive/index.base.js +3 -6
  165. package/dist/esm/modules/archive/index.browser.js +3 -7
  166. package/dist/esm/modules/archive/index.js +3 -5
  167. package/dist/esm/modules/archive/internal/byte-queue.js +407 -0
  168. package/dist/esm/modules/archive/io/archive-sink.js +45 -0
  169. package/dist/esm/modules/archive/io/archive-source.js +100 -0
  170. package/dist/esm/modules/archive/unzip/index.js +164 -0
  171. package/dist/esm/modules/archive/unzip/stream.base.js +1022 -0
  172. package/dist/esm/modules/archive/{parse.browser.js → unzip/stream.browser.js} +371 -110
  173. package/dist/{browser/modules/archive/parse.js → esm/modules/archive/unzip/stream.js} +6 -5
  174. package/dist/{browser/modules/archive → esm/modules/archive/unzip}/zip-parser.js +38 -24
  175. package/dist/esm/modules/archive/utils/async-queue.js +103 -0
  176. package/dist/esm/modules/archive/utils/bytes.js +16 -16
  177. package/dist/esm/modules/archive/utils/compressibility.js +57 -0
  178. package/dist/esm/modules/archive/utils/parse-buffer.js +21 -23
  179. package/dist/esm/modules/archive/utils/pattern-scanner.js +27 -0
  180. package/dist/esm/modules/archive/utils/timestamps.js +62 -1
  181. package/dist/esm/modules/archive/utils/zip-extra-fields.js +26 -14
  182. package/dist/esm/modules/archive/zip/index.js +157 -0
  183. package/dist/esm/modules/archive/{streaming-zip.js → zip/stream.js} +192 -48
  184. package/dist/esm/modules/archive/zip/zip-bytes.js +239 -0
  185. package/dist/{browser/modules/archive → esm/modules/archive/zip}/zip-entry-metadata.js +3 -3
  186. package/dist/esm/modules/archive/zip-spec/zip-records.js +126 -0
  187. package/dist/esm/modules/excel/stream/workbook-reader.browser.js +1 -1
  188. package/dist/esm/modules/excel/stream/workbook-writer.browser.js +1 -1
  189. package/dist/esm/modules/excel/utils/ooxml-validator.js +469 -0
  190. package/dist/esm/modules/excel/worksheet.js +5 -2
  191. package/dist/esm/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.js +13 -1
  192. package/dist/esm/modules/excel/xlsx/xform/drawing/sp-xform.js +112 -0
  193. package/dist/esm/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +30 -2
  194. package/dist/esm/modules/excel/xlsx/xform/drawing/vml-drawing-xform.js +11 -0
  195. package/dist/esm/modules/excel/xlsx/xform/sheet/page-setup-xform.js +16 -2
  196. package/dist/esm/modules/excel/xlsx/xform/sheet/worksheet-xform.js +110 -12
  197. package/dist/esm/modules/excel/xlsx/xlsx.browser.js +3 -6
  198. package/dist/esm/modules/excel/xlsx/xlsx.js +1 -1
  199. package/dist/esm/modules/stream/base-transform.js +34 -20
  200. package/dist/esm/modules/stream/chunked-builder.js +4 -4
  201. package/dist/esm/modules/stream/index.browser.js +10 -22
  202. package/dist/esm/modules/stream/index.js +15 -44
  203. package/dist/esm/modules/stream/internal/event-utils.js +40 -0
  204. package/dist/esm/modules/stream/internal/type-guards.js +24 -0
  205. package/dist/esm/modules/stream/pull-stream.js +107 -43
  206. package/dist/esm/modules/stream/shared.js +7 -4
  207. package/dist/esm/modules/stream/streams.browser.js +921 -836
  208. package/dist/esm/modules/stream/streams.js +146 -95
  209. package/dist/esm/modules/stream/utils.js +5 -38
  210. package/dist/iife/THIRD_PARTY_NOTICES.md +0 -31
  211. package/dist/iife/excelts.iife.js +6495 -4440
  212. package/dist/iife/excelts.iife.js.map +1 -1
  213. package/dist/iife/excelts.iife.min.js +103 -31
  214. package/dist/types/index.browser.d.ts +1 -0
  215. package/dist/{browser/modules/archive → types/modules/archive/compression}/compress.browser.d.ts +2 -8
  216. package/dist/types/modules/archive/{streaming-compress.browser.d.ts → compression/streaming-compress.browser.d.ts} +1 -1
  217. package/dist/types/modules/archive/defaults.d.ts +1 -0
  218. package/dist/types/modules/archive/index.base.d.ts +4 -4
  219. package/dist/types/modules/archive/index.browser.d.ts +3 -4
  220. package/dist/types/modules/archive/index.d.ts +3 -4
  221. package/dist/types/modules/archive/internal/byte-queue.d.ts +33 -0
  222. package/dist/types/modules/archive/io/archive-sink.d.ts +8 -0
  223. package/dist/types/modules/archive/io/archive-source.d.ts +6 -0
  224. package/dist/types/modules/archive/unzip/index.d.ts +40 -0
  225. package/dist/types/modules/archive/{parse.base.d.ts → unzip/stream.base.d.ts} +38 -4
  226. package/dist/types/modules/archive/{parse.browser.d.ts → unzip/stream.browser.d.ts} +2 -2
  227. package/dist/types/modules/archive/{parse.d.ts → unzip/stream.d.ts} +3 -3
  228. package/dist/types/modules/archive/{zip-parser.d.ts → unzip/zip-parser.d.ts} +1 -1
  229. package/dist/types/modules/archive/utils/async-queue.d.ts +7 -0
  230. package/dist/types/modules/archive/utils/compressibility.d.ts +10 -0
  231. package/dist/types/modules/archive/utils/pattern-scanner.d.ts +21 -0
  232. package/dist/types/modules/archive/utils/zip-extra-fields.d.ts +1 -1
  233. package/dist/types/modules/archive/zip/index.d.ts +42 -0
  234. package/dist/types/modules/archive/{streaming-zip.d.ts → zip/stream.d.ts} +29 -6
  235. package/dist/types/modules/archive/zip/zip-bytes.d.ts +73 -0
  236. package/dist/types/modules/archive/{zip-entry-metadata.d.ts → zip/zip-entry-metadata.d.ts} +1 -1
  237. package/dist/types/modules/archive/{zip-records.d.ts → zip-spec/zip-records.d.ts} +20 -0
  238. package/dist/types/modules/excel/stream/workbook-writer.browser.d.ts +1 -1
  239. package/dist/types/modules/excel/utils/ooxml-validator.d.ts +48 -0
  240. package/dist/types/modules/excel/xlsx/xform/drawing/ctrl-prop-xform.d.ts +1 -0
  241. package/dist/types/modules/excel/xlsx/xform/drawing/sp-xform.d.ts +18 -0
  242. package/dist/types/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.d.ts +6 -1
  243. package/dist/types/modules/excel/xlsx/xform/sheet/page-setup-xform.d.ts +1 -0
  244. package/dist/types/modules/stream/base-transform.d.ts +3 -0
  245. package/dist/types/modules/stream/buffered-stream.d.ts +2 -12
  246. package/dist/types/modules/stream/index.browser.d.ts +13 -19
  247. package/dist/types/modules/stream/index.d.ts +18 -41
  248. package/dist/types/modules/stream/internal/event-utils.d.ts +17 -0
  249. package/dist/types/modules/stream/internal/type-guards.d.ts +9 -0
  250. package/dist/types/modules/stream/pull-stream.d.ts +5 -6
  251. package/dist/types/modules/stream/shared.d.ts +1 -1
  252. package/dist/types/modules/stream/streams.browser.d.ts +32 -44
  253. package/dist/types/modules/stream/streams.d.ts +4 -20
  254. package/package.json +14 -10
  255. package/dist/browser/modules/archive/byte-queue.d.ts +0 -18
  256. package/dist/browser/modules/archive/byte-queue.js +0 -125
  257. package/dist/browser/modules/archive/parse.base.js +0 -644
  258. package/dist/browser/modules/archive/utils/zip-extra.d.ts +0 -18
  259. package/dist/browser/modules/archive/utils/zip-extra.js +0 -68
  260. package/dist/browser/modules/archive/zip-builder.d.ts +0 -117
  261. package/dist/browser/modules/archive/zip-builder.js +0 -292
  262. package/dist/browser/modules/archive/zip-constants.d.ts +0 -18
  263. package/dist/browser/modules/archive/zip-constants.js +0 -23
  264. package/dist/browser/modules/archive/zip-records.js +0 -84
  265. package/dist/cjs/modules/archive/byte-queue.js +0 -129
  266. package/dist/cjs/modules/archive/parse.base.js +0 -666
  267. package/dist/cjs/modules/archive/utils/zip-extra.js +0 -74
  268. package/dist/cjs/modules/archive/zip-builder.js +0 -297
  269. package/dist/cjs/modules/archive/zip-constants.js +0 -26
  270. package/dist/cjs/modules/archive/zip-records.js +0 -90
  271. package/dist/esm/modules/archive/byte-queue.js +0 -125
  272. package/dist/esm/modules/archive/parse.base.js +0 -644
  273. package/dist/esm/modules/archive/utils/zip-extra.js +0 -68
  274. package/dist/esm/modules/archive/zip-builder.js +0 -292
  275. package/dist/esm/modules/archive/zip-constants.js +0 -23
  276. package/dist/esm/modules/archive/zip-records.js +0 -84
  277. package/dist/types/modules/archive/byte-queue.d.ts +0 -18
  278. package/dist/types/modules/archive/utils/zip-extra.d.ts +0 -18
  279. package/dist/types/modules/archive/zip-builder.d.ts +0 -117
  280. package/dist/types/modules/archive/zip-constants.d.ts +0 -18
  281. /package/dist/browser/modules/archive/{compress.base.d.ts → compression/compress.base.d.ts} +0 -0
  282. /package/dist/browser/modules/archive/{crc32.base.d.ts → compression/crc32.base.d.ts} +0 -0
  283. /package/dist/browser/modules/archive/{crc32.base.js → compression/crc32.base.js} +0 -0
  284. /package/dist/browser/modules/archive/{crc32.browser.js → compression/crc32.browser.js} +0 -0
  285. /package/dist/browser/modules/archive/{deflate-fallback.d.ts → compression/deflate-fallback.d.ts} +0 -0
  286. /package/dist/browser/modules/archive/{streaming-compress.base.d.ts → compression/streaming-compress.base.d.ts} +0 -0
  287. /package/dist/browser/modules/archive/{streaming-compress.base.js → compression/streaming-compress.base.js} +0 -0
  288. /package/dist/browser/modules/archive/{extract.js → unzip/extract.js} +0 -0
  289. /package/dist/browser/modules/archive/{zip-entry-metadata.d.ts → zip/zip-entry-metadata.d.ts} +0 -0
  290. /package/dist/browser/modules/archive/{zip-entry-info.d.ts → zip-spec/zip-entry-info.d.ts} +0 -0
  291. /package/dist/browser/modules/archive/{zip-entry-info.js → zip-spec/zip-entry-info.js} +0 -0
  292. /package/dist/cjs/modules/archive/{crc32.base.js → compression/crc32.base.js} +0 -0
  293. /package/dist/cjs/modules/archive/{crc32.browser.js → compression/crc32.browser.js} +0 -0
  294. /package/dist/cjs/modules/archive/{streaming-compress.base.js → compression/streaming-compress.base.js} +0 -0
  295. /package/dist/cjs/modules/archive/{extract.js → unzip/extract.js} +0 -0
  296. /package/dist/cjs/modules/archive/{zip-entry-info.js → zip-spec/zip-entry-info.js} +0 -0
  297. /package/dist/esm/modules/archive/{crc32.base.js → compression/crc32.base.js} +0 -0
  298. /package/dist/esm/modules/archive/{crc32.browser.js → compression/crc32.browser.js} +0 -0
  299. /package/dist/esm/modules/archive/{streaming-compress.base.js → compression/streaming-compress.base.js} +0 -0
  300. /package/dist/esm/modules/archive/{extract.js → unzip/extract.js} +0 -0
  301. /package/dist/esm/modules/archive/{zip-entry-info.js → zip-spec/zip-entry-info.js} +0 -0
  302. /package/dist/types/modules/archive/{compress.base.d.ts → compression/compress.base.d.ts} +0 -0
  303. /package/dist/types/modules/archive/{compress.d.ts → compression/compress.d.ts} +0 -0
  304. /package/dist/types/modules/archive/{crc32.base.d.ts → compression/crc32.base.d.ts} +0 -0
  305. /package/dist/types/modules/archive/{crc32.browser.d.ts → compression/crc32.browser.d.ts} +0 -0
  306. /package/dist/types/modules/archive/{crc32.d.ts → compression/crc32.d.ts} +0 -0
  307. /package/dist/types/modules/archive/{deflate-fallback.d.ts → compression/deflate-fallback.d.ts} +0 -0
  308. /package/dist/types/modules/archive/{streaming-compress.base.d.ts → compression/streaming-compress.base.d.ts} +0 -0
  309. /package/dist/types/modules/archive/{streaming-compress.d.ts → compression/streaming-compress.d.ts} +0 -0
  310. /package/dist/types/modules/archive/{extract.d.ts → unzip/extract.d.ts} +0 -0
  311. /package/dist/types/modules/archive/{zip-entry-info.d.ts → zip-spec/zip-entry-info.d.ts} +0 -0
@@ -2,6 +2,7 @@ import { BaseCellAnchorXform } from "./base-cell-anchor-xform.js";
2
2
  import { StaticXform } from "../static-xform.js";
3
3
  import { CellPositionXform } from "./cell-position-xform.js";
4
4
  import { PicXform } from "./pic-xform.js";
5
+ import { SpXform } from "./sp-xform.js";
5
6
  class TwoCellAnchorXform extends BaseCellAnchorXform {
6
7
  constructor() {
7
8
  super();
@@ -9,6 +10,7 @@ class TwoCellAnchorXform extends BaseCellAnchorXform {
9
10
  "xdr:from": new CellPositionXform({ tag: "xdr:from" }),
10
11
  "xdr:to": new CellPositionXform({ tag: "xdr:to" }),
11
12
  "xdr:pic": new PicXform(),
13
+ "xdr:sp": new SpXform(),
12
14
  "xdr:clientData": new StaticXform({ tag: "xdr:clientData" })
13
15
  };
14
16
  }
@@ -16,15 +18,41 @@ class TwoCellAnchorXform extends BaseCellAnchorXform {
16
18
  return "xdr:twoCellAnchor";
17
19
  }
18
20
  prepare(model, options) {
19
- this.map["xdr:pic"].prepare(model.picture, options);
21
+ if (model.picture) {
22
+ this.map["xdr:pic"].prepare(model.picture, options);
23
+ }
20
24
  }
21
25
  render(xmlStream, model) {
26
+ const wrapAlternateContent = !!model.alternateContent;
27
+ if (wrapAlternateContent) {
28
+ xmlStream.openNode("mc:AlternateContent", {
29
+ "xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006"
30
+ });
31
+ xmlStream.openNode("mc:Choice", {
32
+ Requires: model.alternateContent?.requires,
33
+ ...(model.alternateContent?.requires === "a14"
34
+ ? {
35
+ "xmlns:a14": "http://schemas.microsoft.com/office/drawing/2010/main"
36
+ }
37
+ : {})
38
+ });
39
+ }
22
40
  xmlStream.openNode(this.tag, { editAs: model.range.editAs || "oneCell" });
23
41
  this.map["xdr:from"].render(xmlStream, model.range.tl);
24
42
  this.map["xdr:to"].render(xmlStream, model.range.br);
25
- this.map["xdr:pic"].render(xmlStream, model.picture);
43
+ if (model.picture) {
44
+ this.map["xdr:pic"].render(xmlStream, model.picture);
45
+ }
46
+ else if (model.shape) {
47
+ this.map["xdr:sp"].render(xmlStream, model.shape);
48
+ }
26
49
  this.map["xdr:clientData"].render(xmlStream, {});
27
50
  xmlStream.closeNode();
51
+ if (wrapAlternateContent) {
52
+ xmlStream.closeNode(); // mc:Choice
53
+ xmlStream.leafNode("mc:Fallback");
54
+ xmlStream.closeNode(); // mc:AlternateContent
55
+ }
28
56
  }
29
57
  parseClose(name) {
30
58
  if (this.parser) {
@@ -107,14 +107,22 @@ class VmlDrawingXform extends BaseXform {
107
107
  }
108
108
  // ClientData - the core of the checkbox control
109
109
  xmlStream.openNode("x:ClientData", { ObjectType: "Checkbox" });
110
+ // Match Excel's VML patterns (similar to Note ClientData): include positioning and cell address.
111
+ // Omitting these can cause Excel to repair the sheet by dropping all legacy controls.
112
+ xmlStream.leafNode("x:MoveWithCells");
113
+ xmlStream.leafNode("x:SizeWithCells");
110
114
  // Anchor position
111
115
  xmlStream.openNode("x:Anchor");
112
116
  xmlStream.writeText(FormCheckbox.getVmlAnchor(control));
113
117
  xmlStream.closeNode();
118
+ // Protection / text locking
119
+ xmlStream.leafNode("x:Locked", undefined, "False");
120
+ xmlStream.leafNode("x:LockText", undefined, "True");
114
121
  // Print settings
115
122
  xmlStream.leafNode("x:PrintObject", undefined, control.print ? "True" : "False");
116
123
  xmlStream.leafNode("x:AutoFill", undefined, "False");
117
124
  xmlStream.leafNode("x:AutoLine", undefined, "False");
125
+ xmlStream.leafNode("x:TextHAlign", undefined, "Left");
118
126
  xmlStream.leafNode("x:TextVAlign", undefined, "Center");
119
127
  // Linked cell
120
128
  if (control.link) {
@@ -126,6 +134,9 @@ class VmlDrawingXform extends BaseXform {
126
134
  }
127
135
  // Checked state (0 = unchecked, 1 = checked, 2 = mixed)
128
136
  xmlStream.leafNode("x:Checked", undefined, String(FormCheckbox.getVmlCheckedValue(control)));
137
+ // Cell address (0-based row/column)
138
+ xmlStream.leafNode("x:Row", undefined, String(control.tl.row));
139
+ xmlStream.leafNode("x:Column", undefined, String(control.tl.col));
129
140
  xmlStream.closeNode(); // x:ClientData
130
141
  xmlStream.closeNode(); // v:shape
131
142
  }
@@ -19,6 +19,7 @@ interface PageSetupModel {
19
19
  }
20
20
  declare class PageSetupXform extends BaseXform {
21
21
  get tag(): string;
22
+ private _dpiToXml;
22
23
  render(xmlStream: any, model: PageSetupModel): void;
23
24
  parseOpen(node: any): boolean;
24
25
  parseText(): void;
@@ -36,13 +36,27 @@ class PageSetupXform extends BaseXform {
36
36
  get tag() {
37
37
  return "pageSetup";
38
38
  }
39
+ _dpiToXml(value) {
40
+ // Excel commonly omits these attributes. 4294967295 is used as a sentinel default
41
+ // when parsing missing values; it should never be serialized back out.
42
+ if (value === undefined) {
43
+ return undefined;
44
+ }
45
+ if (!Number.isFinite(value)) {
46
+ return undefined;
47
+ }
48
+ if (value === 4294967295) {
49
+ return undefined;
50
+ }
51
+ return value;
52
+ }
39
53
  render(xmlStream, model) {
40
54
  if (model) {
41
55
  const attributes = {
42
56
  paperSize: model.paperSize,
43
57
  orientation: model.orientation,
44
- horizontalDpi: model.horizontalDpi,
45
- verticalDpi: model.verticalDpi,
58
+ horizontalDpi: this._dpiToXml(model.horizontalDpi),
59
+ verticalDpi: this._dpiToXml(model.verticalDpi),
46
60
  pageOrder: pageOrderToXml(model.pageOrder),
47
61
  blackAndWhite: booleanToXml(model.blackAndWhite),
48
62
  draft: booleanToXml(model.draft),
@@ -137,6 +137,14 @@ class WorkSheetXform extends BaseXform {
137
137
  options.merges = new Merges();
138
138
  model.hyperlinks = options.hyperlinks = [];
139
139
  model.comments = options.comments = [];
140
+ // Some Excel builds are surprisingly strict when legacy form controls exist.
141
+ // Emitting a default sheetView (workbookViewId=0) matches typical Excel output
142
+ // and avoids relying on optional element handling.
143
+ if (model.formControls && model.formControls.length > 0) {
144
+ if (!model.views || model.views.length === 0) {
145
+ model.views = [{ workbookViewId: 0 }];
146
+ }
147
+ }
140
148
  options.formulae = {};
141
149
  options.siFormulae = 0;
142
150
  this.map.cols.prepare(model.cols, options);
@@ -278,6 +286,23 @@ class WorkSheetXform extends BaseXform {
278
286
  // prepare form controls (legacy checkboxes)
279
287
  // Form controls share the VML file with comments, but need separate ctrlProp relationships
280
288
  if (model.formControls && model.formControls.length > 0) {
289
+ // Ensure a DrawingML drawing part exists for form controls.
290
+ // Excel often repairs sheets that have legacy controls but no <drawing> part.
291
+ let { drawing } = model;
292
+ if (!drawing) {
293
+ drawing = model.drawing = {
294
+ rId: nextRid(rels),
295
+ name: `drawing${++options.drawingsCount}`,
296
+ anchors: [],
297
+ rels: []
298
+ };
299
+ options.drawings.push(drawing);
300
+ rels.push({
301
+ Id: drawing.rId,
302
+ Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",
303
+ Target: drawingRelTargetFromWorksheet(drawing.name)
304
+ });
305
+ }
281
306
  // If no comments, we need to add the VML drawing relationship for form controls
282
307
  if (model.comments.length === 0) {
283
308
  rels.push({
@@ -286,6 +311,14 @@ class WorkSheetXform extends BaseXform {
286
311
  Target: vmlDrawingRelTargetFromWorksheet(model.id)
287
312
  });
288
313
  }
314
+ // Add hidden DrawingML shapes that bridge to the VML shape ids.
315
+ // This mirrors what Excel writes when it "repairs" legacy form controls.
316
+ const toNativePos = (p) => ({
317
+ nativeCol: p.col,
318
+ nativeColOff: p.colOff,
319
+ nativeRow: p.row,
320
+ nativeRowOff: p.rowOff
321
+ });
289
322
  // Add ctrlProp relationships for each form control
290
323
  for (const control of model.formControls) {
291
324
  const globalCtrlPropId = options.formControlRefs.length + 1;
@@ -298,6 +331,22 @@ class WorkSheetXform extends BaseXform {
298
331
  Target: ctrlPropRelTargetFromWorksheet(globalCtrlPropId)
299
332
  });
300
333
  options.formControlRefs.push(globalCtrlPropId);
334
+ const defaultName = `Check Box ${Math.max(1, control.shapeId - 1024)}`;
335
+ drawing.anchors.push({
336
+ range: {
337
+ editAs: "absolute",
338
+ tl: toNativePos(control.tl),
339
+ br: toNativePos(control.br)
340
+ },
341
+ alternateContent: { requires: "a14" },
342
+ shape: {
343
+ cNvPrId: control.shapeId,
344
+ name: control.name || defaultName,
345
+ hidden: true,
346
+ spid: `_x0000_s${control.shapeId}`,
347
+ text: control.text
348
+ }
349
+ });
301
350
  }
302
351
  }
303
352
  // prepare ext items
@@ -305,7 +354,14 @@ class WorkSheetXform extends BaseXform {
305
354
  }
306
355
  render(xmlStream, model) {
307
356
  xmlStream.openXml(XmlStream.StdDocAttributes);
308
- xmlStream.openNode("worksheet", WorkSheetXform.WORKSHEET_ATTRIBUTES);
357
+ const worksheetAttrs = { ...WorkSheetXform.WORKSHEET_ATTRIBUTES };
358
+ if (model.formControls && model.formControls.length > 0) {
359
+ worksheetAttrs["xmlns:x14"] = "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main";
360
+ worksheetAttrs["xmlns:xdr"] =
361
+ "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing";
362
+ worksheetAttrs["mc:Ignorable"] = `${worksheetAttrs["mc:Ignorable"]} x14`;
363
+ }
364
+ xmlStream.openNode("worksheet", worksheetAttrs);
309
365
  const sheetFormatPropertiesModel = model.properties
310
366
  ? {
311
367
  defaultRowHeight: model.properties.defaultRowHeight,
@@ -355,26 +411,68 @@ class WorkSheetXform extends BaseXform {
355
411
  this.map.colBreaks.render(xmlStream, model.colBreaks);
356
412
  this.map.drawing.render(xmlStream, model.drawing); // Note: must be after rowBreaks/colBreaks
357
413
  this.map.picture.render(xmlStream, model.background); // Note: must be after drawing
358
- this.map.tableParts.render(xmlStream, model.tables);
414
+ if (model.rels) {
415
+ // Add a <legacyDrawing /> node for each VML drawing relationship (comments and/or form controls).
416
+ // NOTE: Excel is picky about worksheet child element order; legacyDrawing must come before controls.
417
+ model.rels.forEach(rel => {
418
+ if (rel.Type === RelType.VmlDrawing) {
419
+ xmlStream.leafNode("legacyDrawing", { "r:id": rel.Id });
420
+ }
421
+ });
422
+ }
359
423
  // Controls section for legacy form controls (checkboxes, etc.)
360
424
  // Excel expects <controls> entries that reference ctrlProp relationships.
361
425
  if (model.formControls && model.formControls.length > 0) {
426
+ xmlStream.openNode("mc:AlternateContent");
427
+ xmlStream.openNode("mc:Choice", { Requires: "x14" });
362
428
  xmlStream.openNode("controls");
363
429
  for (const control of model.formControls) {
364
- if (control.ctrlPropRelId) {
365
- xmlStream.leafNode("control", { shapeId: control.shapeId, "r:id": control.ctrlPropRelId });
430
+ if (!control.ctrlPropRelId) {
431
+ continue;
366
432
  }
433
+ const defaultName = `Check Box ${Math.max(1, control.shapeId - 1024)}`;
434
+ xmlStream.openNode("mc:AlternateContent");
435
+ xmlStream.openNode("mc:Choice", { Requires: "x14" });
436
+ xmlStream.openNode("control", {
437
+ shapeId: control.shapeId,
438
+ "r:id": control.ctrlPropRelId,
439
+ name: control.name || defaultName
440
+ });
441
+ xmlStream.openNode("controlPr", {
442
+ locked: 0,
443
+ defaultSize: 0,
444
+ print: control.print ? 1 : 0,
445
+ autoFill: 0,
446
+ autoLine: 0,
447
+ autoPict: 0
448
+ });
449
+ xmlStream.openNode("anchor");
450
+ xmlStream.openNode("from");
451
+ xmlStream.leafNode("xdr:col", undefined, control.tl.col);
452
+ xmlStream.leafNode("xdr:colOff", undefined, control.tl.colOff);
453
+ xmlStream.leafNode("xdr:row", undefined, control.tl.row);
454
+ xmlStream.leafNode("xdr:rowOff", undefined, control.tl.rowOff);
455
+ xmlStream.closeNode();
456
+ xmlStream.openNode("to");
457
+ xmlStream.leafNode("xdr:col", undefined, control.br.col);
458
+ xmlStream.leafNode("xdr:colOff", undefined, control.br.colOff);
459
+ xmlStream.leafNode("xdr:row", undefined, control.br.row);
460
+ xmlStream.leafNode("xdr:rowOff", undefined, control.br.rowOff);
461
+ xmlStream.closeNode(); // to
462
+ xmlStream.closeNode(); // anchor
463
+ xmlStream.closeNode(); // controlPr
464
+ xmlStream.closeNode(); // control
465
+ xmlStream.closeNode(); // mc:Choice
466
+ xmlStream.leafNode("mc:Fallback");
467
+ xmlStream.closeNode(); // mc:AlternateContent
367
468
  }
368
469
  xmlStream.closeNode();
470
+ xmlStream.closeNode();
471
+ xmlStream.leafNode("mc:Fallback");
472
+ xmlStream.closeNode();
369
473
  }
370
- if (model.rels) {
371
- // Add a <legacyDrawing /> node for each VML drawing relationship (comments and/or form controls).
372
- model.rels.forEach(rel => {
373
- if (rel.Type === RelType.VmlDrawing) {
374
- xmlStream.leafNode("legacyDrawing", { "r:id": rel.Id });
375
- }
376
- });
377
- }
474
+ // Table parts must come after <controls> in worksheet element order.
475
+ this.map.tableParts.render(xmlStream, model.tables);
378
476
  // extLst should be the last element in the worksheet.
379
477
  this.map.extLst.render(xmlStream, model);
380
478
  xmlStream.closeNode();
@@ -30,8 +30,8 @@ import { theme1Xml } from "./xml/theme1.js";
30
30
  import { RelType } from "./rel-type.js";
31
31
  import { StreamBuf } from "../utils/stream-buf.js";
32
32
  import { bufferToString, base64ToUint8Array } from "../../../utils/utils.browser.js";
33
- import { StreamingZip, ZipDeflateFile } from "../../archive/streaming-zip.js";
34
- import { ZipParser } from "../../archive/index.browser.js";
33
+ import { StreamingZip, ZipDeflateFile } from "../../archive/zip/stream.js";
34
+ import { ZipParser } from "../../archive/unzip/zip-parser.js";
35
35
  import { PassThrough, concatUint8Arrays } from "../../stream/index.browser.js";
36
36
  import { commentsPath, commentsRelTargetFromWorksheetName, ctrlPropPath, drawingPath, drawingRelsPath, OOXML_REL_TARGETS, pivotTableRelTargetFromWorksheetName, pivotCacheDefinitionRelTargetFromWorkbook, getCommentsIndexFromPath, getDrawingNameFromPath, getDrawingNameFromRelsPath, getMediaFilenameFromPath, mediaPath, getPivotCacheDefinitionNameFromPath, getPivotCacheDefinitionNameFromRelsPath, getPivotCacheRecordsNameFromPath, getPivotTableNameFromPath, getPivotTableNameFromRelsPath, pivotCacheDefinitionPath, pivotCacheDefinitionRelsPath, pivotCacheDefinitionRelTargetFromPivotTable, pivotCacheRecordsPath, pivotCacheRecordsRelTarget, pivotTablePath, pivotTableRelsPath, getTableNameFromPath, tablePath, tableRelTargetFromWorksheetName, themePath, getThemeNameFromPath, getVmlDrawingNameFromPath, getWorksheetNoFromWorksheetPath, getWorksheetNoFromWorksheetRelsPath, isBinaryEntryPath, normalizeZipPath, OOXML_PATHS, vmlDrawingRelTargetFromWorksheetName, vmlDrawingPath, worksheetPath, worksheetRelsPath } from "../utils/ooxml-paths.js";
37
37
  class StreamingZipWriterAdapter {
@@ -126,10 +126,7 @@ class StreamingZipWriterAdapter {
126
126
  timestamps: this.timestamps
127
127
  });
128
128
  this.zip.add(file);
129
- const pushResult = file.push(buffer, true);
130
- if (pushResult && typeof pushResult.catch === "function") {
131
- pushResult.catch((err) => this._emit("error", err));
132
- }
129
+ file.push(buffer, true);
133
130
  }
134
131
  finalize() {
135
132
  if (this.finalized) {
@@ -16,7 +16,7 @@
16
16
  import fs from "fs";
17
17
  import { fileExists } from "../../../utils/utils.browser.js";
18
18
  import { XLSX as XLSXBase } from "./xlsx.browser.js";
19
- import { Parse } from "../../archive/index.browser.js";
19
+ import { Parse } from "../../archive/unzip/stream.browser.js";
20
20
  import { Writable, pipeline } from "../../stream/index.browser.js";
21
21
  class XLSX extends XLSXBase {
22
22
  constructor(workbook) {
@@ -24,6 +24,8 @@ export declare abstract class BaseTransform<TInput = Uint8Array, TOutput = Uint8
24
24
  protected _errorEmitted: boolean;
25
25
  protected _objectMode: boolean;
26
26
  protected _highWaterMark: number;
27
+ private _ending;
28
+ private _flushInProgress;
27
29
  constructor(options?: BaseTransformOptions);
28
30
  /**
29
31
  * Main transform implementation - must be overridden by subclasses
@@ -49,6 +51,7 @@ export declare abstract class BaseTransform<TInput = Uint8Array, TOutput = Uint8
49
51
  * Process next chunk in buffer
50
52
  */
51
53
  private _processNext;
54
+ private _maybeFlush;
52
55
  /**
53
56
  * Emit error only once
54
57
  */
@@ -17,6 +17,8 @@ export class BaseTransform extends EventEmitter {
17
17
  this._isDestroyed = false;
18
18
  this._isFinished = false;
19
19
  this._errorEmitted = false;
20
+ this._ending = false;
21
+ this._flushInProgress = false;
20
22
  this._objectMode = options.objectMode ?? false;
21
23
  this._highWaterMark = options.highWaterMark ?? 16384;
22
24
  }
@@ -45,26 +47,8 @@ export class BaseTransform extends EventEmitter {
45
47
  if (chunk !== undefined) {
46
48
  this.write(chunk);
47
49
  }
48
- // Wait for buffer to drain, then flush
49
- const checkAndFlush = () => {
50
- if (this._buffer.length === this._bufferIndex && !this._isProcessing) {
51
- this.processFlush((err, data) => {
52
- if (err) {
53
- this._emitError(err);
54
- }
55
- else if (data !== undefined) {
56
- this.emit("data", data);
57
- }
58
- this._isFinished = true;
59
- this.emit("finish");
60
- this.emit("end");
61
- });
62
- }
63
- else {
64
- setTimeout(checkAndFlush, 0);
65
- }
66
- };
67
- checkAndFlush();
50
+ this._ending = true;
51
+ this._maybeFlush();
68
52
  }
69
53
  /**
70
54
  * Destroy the stream
@@ -113,13 +97,43 @@ export class BaseTransform extends EventEmitter {
113
97
  }
114
98
  // Process next chunk
115
99
  this._processNext();
100
+ this._maybeFlush();
116
101
  }
117
102
  });
118
103
  }
119
104
  catch (err) {
120
105
  this._isProcessing = false;
121
106
  this._emitError(err);
107
+ this._maybeFlush();
108
+ }
109
+ }
110
+ _maybeFlush() {
111
+ if (!this._ending || this._isDestroyed || this._isFinished || this._flushInProgress) {
112
+ return;
122
113
  }
114
+ // If an error was emitted, stop flushing to avoid hanging end().
115
+ if (this._errorEmitted) {
116
+ this._isFinished = true;
117
+ this.emit("finish");
118
+ this.emit("end");
119
+ return;
120
+ }
121
+ if (this._isProcessing || this._bufferIndex < this._buffer.length) {
122
+ return;
123
+ }
124
+ this._flushInProgress = true;
125
+ this.processFlush((err, data) => {
126
+ this._flushInProgress = false;
127
+ if (err) {
128
+ this._emitError(err);
129
+ }
130
+ else if (data !== undefined) {
131
+ this.emit("data", data);
132
+ }
133
+ this._isFinished = true;
134
+ this.emit("finish");
135
+ this.emit("end");
136
+ });
123
137
  }
124
138
  /**
125
139
  * Emit error only once
@@ -5,14 +5,8 @@
5
5
  * Works identically in both browser and Node.js environments.
6
6
  */
7
7
  import { EventEmitter } from "@stream/event-emitter";
8
- /**
9
- * Represents a chunk of data with copy capabilities
10
- */
11
- export interface DataChunk {
12
- readonly length: number;
13
- copy(target: Uint8Array, targetOffset: number, offset: number, length: number): number;
14
- toUint8Array(): Uint8Array;
15
- }
8
+ import type { BufferedStreamOptions, DataChunk } from "@stream/types";
9
+ export type { BufferedStreamOptions, DataChunk } from "@stream/types";
16
10
  /**
17
11
  * String chunk implementation
18
12
  */
@@ -34,10 +28,6 @@ export declare class BufferChunk implements DataChunk {
34
28
  copy(target: Uint8Array, targetOffset: number, offset: number, length: number): number;
35
29
  toUint8Array(): Uint8Array;
36
30
  }
37
- export interface BufferedStreamOptions {
38
- /** Batch size for internal read-write buffers */
39
- batchSize?: number;
40
- }
41
31
  /**
42
32
  * Browser-compatible Buffered Stream with efficient chunk management
43
33
  */
@@ -45,7 +45,7 @@ export class ChunkedBuilder {
45
45
  _consolidate() {
46
46
  if (this._pieces.length > 0) {
47
47
  this._chunks.push(this._pieces.join(""));
48
- this._pieces = [];
48
+ this._pieces.length = 0;
49
49
  }
50
50
  }
51
51
  /**
@@ -76,8 +76,8 @@ export class ChunkedBuilder {
76
76
  * Clear all content
77
77
  */
78
78
  clear() {
79
- this._pieces = [];
80
- this._chunks = [];
79
+ this._pieces.length = 0;
80
+ this._chunks.length = 0;
81
81
  this._totalLength = 0;
82
82
  }
83
83
  /**
@@ -99,7 +99,7 @@ export class ChunkedBuilder {
99
99
  // Has chunks - consolidate and join
100
100
  if (piecesLen > 0) {
101
101
  this._chunks.push(this._pieces.join(""));
102
- this._pieces = [];
102
+ this._pieces.length = 0;
103
103
  }
104
104
  if (this._chunks.length === 1) {
105
105
  return this._chunks[0];
@@ -1,22 +1,16 @@
1
1
  /**
2
- * Stream Module (browser type surface)
2
+ * Stream Module (browser entry)
3
3
  *
4
- * Mirrors [src/modules/stream/index.ts] but explicitly re-exports from
5
- * ./streams.browser so we can enforce index export-surface parity.
4
+ * Mirrors the public surface of `./index.ts`, but exports the browser
5
+ * implementation from `./streams.browser`.
6
+ *
7
+ * This file is intentionally export-only (tree-shaking friendly).
6
8
  */
7
- import type { ReadableStreamOptions, WritableStreamOptions, TransformStreamOptions, DuplexStreamOptions, PullStreamOptions, BufferedStreamOptions, TransformCallback, FlushCallback, WriteCallback, DestroyCallback, IEventEmitter, IReadable, IWritable, ITransform, IDuplex, IPullStream, IBufferedStream, IPassThrough, ICollector, DataChunk, EventListener, PipelineSource, PipelineTransform, PipelineDestination, ReadWriteBufferOptions } from "@stream/types";
8
- export type { ReadableStreamOptions, WritableStreamOptions, TransformStreamOptions, DuplexStreamOptions, PullStreamOptions, BufferedStreamOptions, TransformCallback, FlushCallback, WriteCallback, DestroyCallback, IEventEmitter, IReadable, IWritable, ITransform, IDuplex, IPullStream, IBufferedStream, IPassThrough, ICollector, DataChunk, EventListener, PipelineSource, PipelineTransform, PipelineDestination, ReadWriteBufferOptions };
9
- import { Readable, Writable, Transform, Duplex, PassThrough, Collector, PullStream, BufferedStream, StringChunk, BufferChunk, createReadable, createWritable, createTransform, createCollector, createPassThrough, createPullStream, createBufferedStream, createReadableFromArray, createReadableFromAsyncIterable, createReadableFromGenerator, createReadableFromPromise, createDuplex, createEmptyReadable, createNullWritable, pipeline, finished, streamToPromise, streamToUint8Array, streamToBuffer, streamToString, drainStream, copyStream, addAbortSignal, compose, finishedAll, once, promisify, isReadable, isWritable, isTransform, isDuplex, isStream, isDestroyed, isDisturbed, isErrored, getDefaultHighWaterMark, setDefaultHighWaterMark, duplexPair, normalizeWritable as Writeable, consumers, promises } from "@stream/streams.browser";
10
- import type { PipelineOptions, FinishedOptions } from "@stream/streams.browser";
11
- export { Readable, Writable, Transform, Duplex, PassThrough, Collector, PullStream, BufferedStream, StringChunk, BufferChunk, createReadable, createWritable, createTransform, createCollector, createPassThrough, createPullStream, createBufferedStream, createReadableFromArray, createReadableFromAsyncIterable, createReadableFromGenerator, createReadableFromPromise, createDuplex, createEmptyReadable, createNullWritable, pipeline, finished, streamToPromise, streamToUint8Array, streamToBuffer, streamToString, drainStream, copyStream, addAbortSignal, compose, finishedAll, once, promisify, isReadable, isWritable, isTransform, isDuplex, isStream, isDestroyed, isDisturbed, isErrored, getDefaultHighWaterMark, setDefaultHighWaterMark, duplexPair, Writeable, consumers, promises };
12
- export type { PipelineOptions, FinishedOptions };
13
- import { EventEmitter } from "@stream/event-emitter";
14
- export { EventEmitter };
15
- import { ChunkedBuilder, TransactionalChunkedBuilder } from "@stream/chunked-builder";
16
- import type { ChunkedBuilderOptions, BuilderSnapshot } from "@stream/chunked-builder";
17
- export { ChunkedBuilder, TransactionalChunkedBuilder };
18
- export type { ChunkedBuilderOptions, BuilderSnapshot };
19
- import { textEncoder, textDecoder, stringToUint8Array, uint8ArrayToString, uint8ArrayEquals, uint8ArrayIndexOf, uint8ArraySlice, toUint8Array, bufferToString, concatUint8Arrays } from "@stream/shared";
20
- export { textEncoder, textDecoder, stringToUint8Array, uint8ArrayToString, uint8ArrayEquals, uint8ArrayIndexOf, uint8ArraySlice, toUint8Array, bufferToString, concatUint8Arrays };
21
- import { collect, text, json, bytes, fromString, fromJSON, fromBytes, transform, filter } from "@stream/utils";
22
- export { collect, text, json, bytes, fromString, fromJSON, fromBytes, transform, filter };
9
+ export type { ReadableStreamOptions, WritableStreamOptions, TransformStreamOptions, DuplexStreamOptions, PullStreamOptions, BufferedStreamOptions, TransformCallback, FlushCallback, WriteCallback, DestroyCallback, IEventEmitter, IReadable, IWritable, ITransform, IDuplex, IPullStream, IBufferedStream, IPassThrough, ICollector, DataChunk, EventListener, PipelineSource, PipelineTransform, PipelineDestination, ReadWriteBufferOptions } from "@stream/types";
10
+ export { Readable, Writable, Transform, Duplex, PassThrough, Collector, PullStream, BufferedStream, StringChunk, BufferChunk, createReadable, createWritable, createTransform, createCollector, createPassThrough, createPullStream, createBufferedStream, createReadableFromArray, createReadableFromAsyncIterable, createReadableFromGenerator, createReadableFromPromise, createDuplex, createEmptyReadable, createNullWritable, pipeline, finished, streamToPromise, streamToUint8Array, streamToBuffer, streamToString, drainStream, copyStream, addAbortSignal, compose, finishedAll, once, promisify, isReadable, isWritable, isTransform, isDuplex, isStream, isDestroyed, isDisturbed, isErrored, getDefaultHighWaterMark, setDefaultHighWaterMark, duplexPair, normalizeWritable as Writeable, consumers, promises } from "@stream/streams.browser";
11
+ export type { PipelineOptions, FinishedOptions } from "@stream/streams.browser";
12
+ export { EventEmitter } from "@stream/event-emitter";
13
+ export { ChunkedBuilder, TransactionalChunkedBuilder } from "@stream/chunked-builder";
14
+ export type { ChunkedBuilderOptions, BuilderSnapshot } from "@stream/chunked-builder";
15
+ export { textEncoder, textDecoder, stringToUint8Array, uint8ArrayToString, uint8ArrayEquals, uint8ArrayIndexOf, uint8ArraySlice, toUint8Array, bufferToString, concatUint8Arrays } from "@stream/shared";
16
+ export { collect, text, json, bytes, fromString, fromJSON, fromBytes, transform, filter } from "@stream/utils";
@@ -1,25 +1,13 @@
1
1
  /**
2
- * Stream Module (browser type surface)
2
+ * Stream Module (browser entry)
3
3
  *
4
- * Mirrors [src/modules/stream/index.ts] but explicitly re-exports from
5
- * ./streams.browser so we can enforce index export-surface parity.
4
+ * Mirrors the public surface of `./index.ts`, but exports the browser
5
+ * implementation from `./streams.browser`.
6
+ *
7
+ * This file is intentionally export-only (tree-shaking friendly).
6
8
  */
7
- // =============================================================================
8
- // Native Stream Classes and Functions (browser)
9
- // =============================================================================
10
- import { Readable, Writable, Transform, Duplex, PassThrough, Collector, PullStream, BufferedStream, StringChunk, BufferChunk, createReadable, createWritable, createTransform, createCollector, createPassThrough, createPullStream, createBufferedStream, createReadableFromArray, createReadableFromAsyncIterable, createReadableFromGenerator, createReadableFromPromise, createDuplex, createEmptyReadable, createNullWritable, pipeline, finished, streamToPromise, streamToUint8Array, streamToBuffer, streamToString, drainStream, copyStream, addAbortSignal, compose, finishedAll, once, promisify, isReadable, isWritable, isTransform, isDuplex, isStream, isDestroyed, isDisturbed, isErrored, getDefaultHighWaterMark, setDefaultHighWaterMark, duplexPair, normalizeWritable as Writeable, consumers, promises } from "./streams.browser.js";
11
- export { Readable, Writable, Transform, Duplex, PassThrough, Collector, PullStream, BufferedStream, StringChunk, BufferChunk, createReadable, createWritable, createTransform, createCollector, createPassThrough, createPullStream, createBufferedStream, createReadableFromArray, createReadableFromAsyncIterable, createReadableFromGenerator, createReadableFromPromise, createDuplex, createEmptyReadable, createNullWritable, pipeline, finished, streamToPromise, streamToUint8Array, streamToBuffer, streamToString, drainStream, copyStream, addAbortSignal, compose, finishedAll, once, promisify, isReadable, isWritable, isTransform, isDuplex, isStream, isDestroyed, isDisturbed, isErrored, getDefaultHighWaterMark, setDefaultHighWaterMark, duplexPair, Writeable, consumers, promises };
12
- import { EventEmitter } from "./event-emitter.js";
13
- export { EventEmitter };
14
- // =============================================================================
15
- // ChunkedBuilder (platform-independent)
16
- // =============================================================================
17
- import { ChunkedBuilder, TransactionalChunkedBuilder } from "./chunked-builder.js";
18
- export { ChunkedBuilder, TransactionalChunkedBuilder };
19
- // =============================================================================
20
- // Utility Functions (platform-independent)
21
- // =============================================================================
22
- import { textEncoder, textDecoder, stringToUint8Array, uint8ArrayToString, uint8ArrayEquals, uint8ArrayIndexOf, uint8ArraySlice, toUint8Array, bufferToString, concatUint8Arrays } from "./shared.js";
23
- export { textEncoder, textDecoder, stringToUint8Array, uint8ArrayToString, uint8ArrayEquals, uint8ArrayIndexOf, uint8ArraySlice, toUint8Array, bufferToString, concatUint8Arrays };
24
- import { collect, text, json, bytes, fromString, fromJSON, fromBytes, transform, filter } from "./utils.js";
25
- export { collect, text, json, bytes, fromString, fromJSON, fromBytes, transform, filter };
9
+ export { Readable, Writable, Transform, Duplex, PassThrough, Collector, PullStream, BufferedStream, StringChunk, BufferChunk, createReadable, createWritable, createTransform, createCollector, createPassThrough, createPullStream, createBufferedStream, createReadableFromArray, createReadableFromAsyncIterable, createReadableFromGenerator, createReadableFromPromise, createDuplex, createEmptyReadable, createNullWritable, pipeline, finished, streamToPromise, streamToUint8Array, streamToBuffer, streamToString, drainStream, copyStream, addAbortSignal, compose, finishedAll, once, promisify, isReadable, isWritable, isTransform, isDuplex, isStream, isDestroyed, isDisturbed, isErrored, getDefaultHighWaterMark, setDefaultHighWaterMark, duplexPair, normalizeWritable as Writeable, consumers, promises } from "./streams.browser.js";
10
+ export { EventEmitter } from "./event-emitter.js";
11
+ export { ChunkedBuilder, TransactionalChunkedBuilder } from "./chunked-builder.js";
12
+ export { textEncoder, textDecoder, stringToUint8Array, uint8ArrayToString, uint8ArrayEquals, uint8ArrayIndexOf, uint8ArraySlice, toUint8Array, bufferToString, concatUint8Arrays } from "./shared.js";
13
+ export { collect, text, json, bytes, fromString, fromJSON, fromBytes, transform, filter } from "./utils.js";