@poe-platform/safe-bash 0.1.811 → 0.1.813

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 (351) hide show
  1. package/dist/audio-ast/id3-source.d.ts +27 -0
  2. package/dist/audio-ast/index.d.ts +5 -0
  3. package/dist/audio-ast/index.js +1001 -596
  4. package/dist/audio-ast/mp3-source.d.ts +18 -0
  5. package/dist/audio-ast/ogg-source.d.ts +25 -0
  6. package/dist/audio-ast/ogg-stream-source.d.ts +22 -0
  7. package/dist/audio-ast/vorbis.d.ts +14 -0
  8. package/dist/image-ast/index.js +139 -9
  9. package/dist/mp4-ast/containers/adapters.d.ts +7 -0
  10. package/dist/office-xml/retained-xml-document.d.ts +8 -0
  11. package/dist/pdf-ast/ast.d.ts +2 -0
  12. package/dist/pdf-ast/content/dictionary-cursor.d.ts +15 -0
  13. package/dist/pdf-ast/content/range-operator-parser.d.ts +4 -0
  14. package/dist/pdf-ast/content/stored-dictionary.d.ts +10 -0
  15. package/dist/pdf-ast/cos/lexer.d.ts +8 -5
  16. package/dist/pdf-ast/cos/object-reader.d.ts +4 -3
  17. package/dist/pdf-ast/cos/range-parser.d.ts +4 -0
  18. package/dist/pdf-ast/cos/retained-objects.d.ts +1 -0
  19. package/dist/pdf-ast/cos/retained-writer.d.ts +1 -0
  20. package/dist/pdf-ast/cos/value-parser.d.ts +32 -2
  21. package/dist/pdf-ast/edit/retained-append-attachments.d.ts +13 -0
  22. package/dist/pdf-ast/edit/retained-bookmarks.d.ts +13 -0
  23. package/dist/pdf-ast/edit/retained-graph.d.ts +6 -0
  24. package/dist/pdf-ast/edit/retained-save.d.ts +2 -0
  25. package/dist/pdf-ast/edit/retained-stamps.d.ts +9 -0
  26. package/dist/pdf-ast/extract/retained-form-field-details.d.ts +20 -0
  27. package/dist/pdf-ast/extract/retained-form-fields.d.ts +17 -4
  28. package/dist/pdf-ast/fonts/resolve.d.ts +3 -1
  29. package/dist/pdf-ast/index.d.ts +4 -1
  30. package/dist/pdf-ast/index.js +2127 -975
  31. package/dist/pdf-ast/retained-document.d.ts +4 -0
  32. package/dist/safe-bash/audio-ast.browser.js +7 -1
  33. package/dist/safe-bash/chunks/{chunk-HHSOUC3Z.js → chunk-HPQE675Q.js} +1 -1
  34. package/dist/safe-bash/chunks/{chunk-BUYRKFW2.js → chunk-I6ECNJMR.js} +1 -1
  35. package/dist/safe-bash/chunks/{pdftk-WRYEP3CA.js → pdftk-Y2TX74LY.js} +2 -1
  36. package/dist/safe-bash/command-chunks/biff-4ALVARRF-7SRX6R6N.js +5192 -0
  37. package/dist/safe-bash/command-chunks/{chunk-EHSM5ZQS.js → chunk-2DGJOOXM.js} +8 -8
  38. package/dist/safe-bash/command-chunks/{chunk-Q6S57NOQ.js → chunk-2E2H7MBH.js} +7 -7
  39. package/dist/safe-bash/command-chunks/{chunk-MMBZTYXO.js → chunk-2PQRZDNR.js} +221 -0
  40. package/dist/safe-bash/command-chunks/{chunk-5OO2P27R.js → chunk-2V6FOLXV.js} +78 -25
  41. package/dist/safe-bash/command-chunks/{chunk-56NYSX65.js → chunk-2Z3WRRFT.js} +9 -9
  42. package/dist/safe-bash/command-chunks/chunk-3D24WDND.js +63 -0
  43. package/dist/safe-bash/command-chunks/{chunk-47NEG4UO.js → chunk-3JST2Q7G.js} +219 -43
  44. package/dist/safe-bash/command-chunks/{chunk-WGG6G2KG.js → chunk-3LJAXFH5.js} +7 -7
  45. package/dist/safe-bash/command-chunks/{chunk-AHA6IWAJ.js → chunk-3TYDSGAH.js} +6 -6
  46. package/dist/safe-bash/command-chunks/{chunk-YSMNXMAO.js → chunk-3Y4XZB24.js} +4 -4
  47. package/dist/safe-bash/command-chunks/{chunk-ZIIO6GRY.js → chunk-4PBNMKAT.js} +7 -7
  48. package/dist/safe-bash/command-chunks/{chunk-JFYWVQ4V.js → chunk-4Z6W5EOC.js} +8 -8
  49. package/dist/safe-bash/command-chunks/{chunk-GEM47B2P.js → chunk-57DDYKE5.js} +7 -7
  50. package/dist/safe-bash/command-chunks/{chunk-HARUYHH7.js → chunk-5HUICAWD.js} +1 -1
  51. package/dist/safe-bash/command-chunks/{chunk-4CKFNXRN.js → chunk-5IFRAI7Y.js} +1 -1
  52. package/dist/safe-bash/command-chunks/{chunk-RHYJVTJO.js → chunk-5KGEZ3RW.js} +2 -2
  53. package/dist/safe-bash/command-chunks/{chunk-A5FZBR7X.js → chunk-5MFDRSGG.js} +4 -4
  54. package/dist/safe-bash/command-chunks/{chunk-7GKKMNL6.js → chunk-5P6I2T63.js} +8 -8
  55. package/dist/safe-bash/command-chunks/{chunk-6M6TM5Z5.js → chunk-5VQVZPP3.js} +3 -3
  56. package/dist/safe-bash/command-chunks/{chunk-MIRL7HTF.js → chunk-6244HYJY.js} +1 -1
  57. package/dist/safe-bash/command-chunks/chunk-63EMPQ7Z.js +115 -0
  58. package/dist/safe-bash/command-chunks/{chunk-XRVKWGVQ.js → chunk-6CY5BHBS.js} +6 -6
  59. package/dist/safe-bash/command-chunks/{chunk-XVP6V5K3.js → chunk-6IWE7PTK.js} +6 -6
  60. package/dist/safe-bash/command-chunks/{chunk-6QBMND4A.js → chunk-6SRHWVEB.js} +1 -1
  61. package/dist/safe-bash/command-chunks/chunk-6ZHQB453.js +35 -0
  62. package/dist/safe-bash/command-chunks/chunk-73NYFNAS.js +173 -0
  63. package/dist/safe-bash/command-chunks/{chunk-VU3EQF7F.js → chunk-7NXTEWPR.js} +229 -75
  64. package/dist/safe-bash/command-chunks/{chunk-554Z6IKP.js → chunk-7PRL6RJ6.js} +2 -2
  65. package/dist/safe-bash/command-chunks/{chunk-SDTPO2VV.js → chunk-7PZHWMK6.js} +7 -7
  66. package/dist/safe-bash/command-chunks/{chunk-XZ2FWFNV.js → chunk-7QZ2HP2F.js} +6 -6
  67. package/dist/safe-bash/command-chunks/{chunk-OEJM666F.js → chunk-7UC2Q6Z6.js} +5 -5
  68. package/dist/safe-bash/command-chunks/{chunk-COKYZUBW.js → chunk-AJI55RS7.js} +1 -1
  69. package/dist/safe-bash/command-chunks/{chunk-2VCKUNDZ.js → chunk-B2C3UPJS.js} +27 -17
  70. package/dist/safe-bash/command-chunks/{chunk-WXRYDALR.js → chunk-BBAB7LC4.js} +4 -4
  71. package/dist/safe-bash/command-chunks/{chunk-QYMEASQ6.js → chunk-BEHUSUOY.js} +4 -4
  72. package/dist/safe-bash/command-chunks/{chunk-Z2JW6M2D.js → chunk-BK7ISUJL.js} +3 -3
  73. package/dist/safe-bash/command-chunks/{chunk-33YCKZZX.js → chunk-C5KLFZGT.js} +6 -6
  74. package/dist/safe-bash/command-chunks/{chunk-TVH4JORU.js → chunk-C5QDEB3I.js} +3 -3
  75. package/dist/safe-bash/command-chunks/{chunk-N4R2SHSS.js → chunk-CCZZVCHX.js} +2 -2
  76. package/dist/safe-bash/command-chunks/{chunk-2VLAXKTS.js → chunk-CTDC4LJT.js} +121 -85
  77. package/dist/safe-bash/command-chunks/{chunk-S6R3IB36.js → chunk-D55REQA3.js} +1 -1
  78. package/dist/safe-bash/command-chunks/{chunk-Y4EYCZFT.js → chunk-D6WJY6QO.js} +10 -10
  79. package/dist/safe-bash/command-chunks/{chunk-2CORNDGF.js → chunk-DBLHCJJU.js} +2 -2
  80. package/dist/safe-bash/command-chunks/{chunk-SPW4GW4Z.js → chunk-DFI7QF3M.js} +2 -2
  81. package/dist/safe-bash/command-chunks/{chunk-456PHA3L.js → chunk-DMCI6T6N.js} +1 -1
  82. package/dist/safe-bash/command-chunks/{chunk-TW73OXPR.js → chunk-EJTNVXWF.js} +6 -6
  83. package/dist/safe-bash/command-chunks/{chunk-QD7ZRDUN.js → chunk-ET2VPDUA.js} +1 -1
  84. package/dist/safe-bash/command-chunks/{chunk-5LI2DLNZ.js → chunk-EXOQGXEU.js} +26 -26
  85. package/dist/safe-bash/command-chunks/{chunk-CRV2Q3PB.js → chunk-EZ4NQIPL.js} +1 -1
  86. package/dist/safe-bash/command-chunks/chunk-FWKLBDMK.js +0 -0
  87. package/dist/safe-bash/command-chunks/{chunk-22MOB45U.js → chunk-FWPVQGYK.js} +6 -6
  88. package/dist/safe-bash/command-chunks/{chunk-QC5RMGSA.js → chunk-G3RUXKVY.js} +3 -3
  89. package/dist/safe-bash/command-chunks/{chunk-JYUJAF4L.js → chunk-G7NENPYV.js} +4 -0
  90. package/dist/safe-bash/command-chunks/{chunk-KCOJA7EM.js → chunk-GKILM4HZ.js} +7 -7
  91. package/dist/safe-bash/command-chunks/{chunk-HTVIYLVB.js → chunk-GNXTMSYN.js} +4 -4
  92. package/dist/safe-bash/command-chunks/{chunk-D2ASPM7R.js → chunk-GOBUDKZ3.js} +3 -3
  93. package/dist/safe-bash/command-chunks/{chunk-RNSKXOG3.js → chunk-GVWVRPG6.js} +6 -6
  94. package/dist/safe-bash/command-chunks/{chunk-ZHRGYR7B.js → chunk-HCKYUQ3L.js} +7 -7
  95. package/dist/safe-bash/command-chunks/{chunk-AGLK7OJR.js → chunk-HDSIIQBS.js} +1 -1
  96. package/dist/safe-bash/command-chunks/{chunk-DM2CPMB4.js → chunk-HKOMXGJS.js} +2 -2
  97. package/dist/safe-bash/command-chunks/{chunk-IT7TAC3F.js → chunk-HVW53ARH.js} +16 -16
  98. package/dist/safe-bash/command-chunks/{chunk-M7QE2MN7.js → chunk-I4GMCWAT.js} +6 -6
  99. package/dist/safe-bash/command-chunks/{chunk-5MB64DWR.js → chunk-IHSOOSNC.js} +9 -9
  100. package/dist/safe-bash/command-chunks/{chunk-LCZDBW55.js → chunk-JAHJWVGF.js} +5 -5
  101. package/dist/safe-bash/command-chunks/{chunk-MOZD7RUY.js → chunk-JORIVUPM.js} +27 -11
  102. package/dist/safe-bash/command-chunks/{chunk-PMAM4N33.js → chunk-JUJHYPYL.js} +9 -9
  103. package/dist/safe-bash/command-chunks/{chunk-ENT3IV2G.js → chunk-KBUBSMCQ.js} +12 -12
  104. package/dist/safe-bash/command-chunks/{chunk-ZXR6LXV5.js → chunk-KCE5D4Z4.js} +48 -4
  105. package/dist/safe-bash/command-chunks/{chunk-FIIAYCWS.js → chunk-KZ5ODST6.js} +2 -2
  106. package/dist/safe-bash/command-chunks/{chunk-PNGDJA6M.js → chunk-LD7BONZY.js} +2 -2
  107. package/dist/safe-bash/command-chunks/{chunk-KJ4XXZIL.js → chunk-M3Z5PU2M.js} +582 -59
  108. package/dist/safe-bash/command-chunks/{chunk-LXLLA4PM.js → chunk-MKX4JAZ6.js} +17 -17
  109. package/dist/safe-bash/command-chunks/{chunk-RQIQ75W5.js → chunk-MNHBQBF6.js} +5 -5
  110. package/dist/safe-bash/command-chunks/{chunk-A2CLZMQZ.js → chunk-MPKY37QR.js} +1 -1
  111. package/dist/safe-bash/command-chunks/{chunk-K5GB2YMN.js → chunk-MUUWBZIC.js} +10 -10
  112. package/dist/safe-bash/command-chunks/{chunk-JOCFI7TG.js → chunk-N32GSM3J.js} +1 -1
  113. package/dist/safe-bash/command-chunks/{chunk-EUT24Y5Z.js → chunk-NKTULXVD.js} +8 -8
  114. package/dist/safe-bash/command-chunks/{chunk-5HPU7D36.js → chunk-NMPED6L5.js} +4 -4
  115. package/dist/safe-bash/command-chunks/{chunk-QZZ73J2O.js → chunk-NPFHUS4X.js} +6 -6
  116. package/dist/safe-bash/command-chunks/{chunk-X7FA7ZD5.js → chunk-O675URF4.js} +8 -8
  117. package/dist/safe-bash/command-chunks/{chunk-R6EGGK5M.js → chunk-P7EL2FWW.js} +7 -7
  118. package/dist/safe-bash/command-chunks/{chunk-YS25EI54.js → chunk-PCCFLPUQ.js} +2 -2
  119. package/dist/safe-bash/command-chunks/{chunk-RRL3Y562.js → chunk-PI6MOMHA.js} +11 -11
  120. package/dist/safe-bash/command-chunks/{chunk-26VCZHLJ.js → chunk-PIOQBOEK.js} +1 -1
  121. package/dist/safe-bash/command-chunks/chunk-PK36TVXB.js +175 -0
  122. package/dist/safe-bash/command-chunks/{chunk-72C3TZ2U.js → chunk-PKLJRB7W.js} +264 -129
  123. package/dist/safe-bash/command-chunks/{chunk-6CCQI6XZ.js → chunk-PSCOXGCA.js} +12 -12
  124. package/dist/safe-bash/command-chunks/{chunk-XPD636C4.js → chunk-PVGZMLC6.js} +3 -3
  125. package/dist/safe-bash/command-chunks/{chunk-JQVHUSDD.js → chunk-PXWS3Q7L.js} +5 -5
  126. package/dist/safe-bash/command-chunks/{chunk-HDJVJTCK.js → chunk-QFF5KBOM.js} +9 -9
  127. package/dist/safe-bash/command-chunks/{chunk-MPUHH2KR.js → chunk-QM2HZJSJ.js} +3 -3
  128. package/dist/safe-bash/command-chunks/{chunk-UAXSE3XE.js → chunk-R2BMZAHG.js} +5 -5
  129. package/dist/safe-bash/command-chunks/{chunk-KB7DUBVL.js → chunk-RGOQKIG6.js} +5 -5
  130. package/dist/safe-bash/command-chunks/{chunk-D2KZ66W4.js → chunk-RLCQ7BN3.js} +187 -39
  131. package/dist/safe-bash/command-chunks/{chunk-B5LDP7AA.js → chunk-S2N2V5U4.js} +2 -2
  132. package/dist/safe-bash/command-chunks/{chunk-OA75SGN2.js → chunk-SGPCXAG7.js} +7 -7
  133. package/dist/safe-bash/command-chunks/{chunk-Z5QOVRVH.js → chunk-SU26FZLJ.js} +1 -1
  134. package/dist/safe-bash/command-chunks/{chunk-QUM3SYAJ.js → chunk-SYSX46IV.js} +3 -3
  135. package/dist/safe-bash/command-chunks/chunk-T3E5RV3U.js +737 -0
  136. package/dist/safe-bash/command-chunks/{chunk-YORJDX4V.js → chunk-T5ERNELL.js} +4 -4
  137. package/dist/safe-bash/command-chunks/{chunk-KL3OIBKB.js → chunk-T6C5QP7T.js} +6495 -6343
  138. package/dist/safe-bash/command-chunks/{chunk-ATTWQVR2.js → chunk-TKRLZIFI.js} +17 -17
  139. package/dist/safe-bash/command-chunks/{chunk-ZMHEGDU2.js → chunk-TODWFDYB.js} +2 -2
  140. package/dist/safe-bash/command-chunks/{chunk-YSY6R6AS.js → chunk-TQEB4DH4.js} +703 -102
  141. package/dist/safe-bash/command-chunks/{chunk-36XGIPOG.js → chunk-U5TWQFZY.js} +1 -1
  142. package/dist/safe-bash/command-chunks/{chunk-APEWTWCC.js → chunk-UAF4IX5H.js} +6 -6
  143. package/dist/safe-bash/command-chunks/{chunk-6VPQ3CDZ.js → chunk-V37D6AHO.js} +5 -5
  144. package/dist/safe-bash/command-chunks/{chunk-RID6VYS3.js → chunk-V6XBEYPC.js} +8 -8
  145. package/dist/safe-bash/command-chunks/{chunk-WJCN2IXI.js → chunk-VQOINPVF.js} +2 -2
  146. package/dist/safe-bash/command-chunks/{chunk-W5YSINXC.js → chunk-VVWXY6IA.js} +6 -6
  147. package/dist/safe-bash/command-chunks/{chunk-HKATEVAP.js → chunk-WPVBUVFK.js} +6 -6
  148. package/dist/safe-bash/command-chunks/{chunk-UYWSIIUX.js → chunk-X53AEG36.js} +7 -7
  149. package/dist/safe-bash/command-chunks/{chunk-L5MCW6CM.js → chunk-X64XGIXZ.js} +9 -155
  150. package/dist/safe-bash/command-chunks/{chunk-Q73EMLLZ.js → chunk-X6RHJ6YN.js} +84 -5
  151. package/dist/safe-bash/command-chunks/{chunk-7PVHO47B.js → chunk-XG6UWQV5.js} +6 -6
  152. package/dist/safe-bash/command-chunks/{chunk-NQDIT667.js → chunk-XIDGHIGB.js} +5 -5
  153. package/dist/safe-bash/command-chunks/{chunk-DPR5CYQV.js → chunk-XITDDJFT.js} +2 -0
  154. package/dist/safe-bash/command-chunks/{chunk-CV7M2QJU.js → chunk-XLYIVBAR.js} +7 -7
  155. package/dist/safe-bash/command-chunks/{chunk-WVMHRNXZ.js → chunk-YUXTK3XA.js} +3 -3
  156. package/dist/safe-bash/command-chunks/{chunk-SPLOIABU.js → chunk-YXD6VGVG.js} +3 -3
  157. package/dist/safe-bash/command-chunks/{chunk-2ZFLMWOX.js → chunk-Z5BIM5B7.js} +1 -1
  158. package/dist/safe-bash/command-chunks/chunk-ZYLGNIGA.js +156 -0
  159. package/dist/safe-bash/command-chunks/{command-engine-BEWABZ75.js → command-engine-X3OLN7N6.js} +206 -86
  160. package/dist/safe-bash/command-chunks/{engine-AXXFTGCL-QBQNBI6K.js → engine-XUCIFZ7V-LJFGZM6O.js} +1 -1
  161. package/dist/safe-bash/command-chunks/paradox-4FCZE53D-LQPGVMEL.js +365 -0
  162. package/dist/safe-bash/commands/pandoc/index.browser.js +1 -1
  163. package/dist/safe-bash/full-core.browser.js +2 -2
  164. package/dist/safe-bash/plugins/index.browser.js +2 -2
  165. package/dist/safe-bash-command-apply-patch/apply.js +4 -4
  166. package/dist/safe-bash-command-apply-patch/index.js +4 -4
  167. package/dist/safe-bash-command-apply-patch/matcher.js +2 -2
  168. package/dist/safe-bash-command-apply-patch/parser.js +2 -2
  169. package/dist/safe-bash-command-apply-patch/shared.d.ts +2 -0
  170. package/dist/safe-bash-command-apply-patch/shared.js +1 -1
  171. package/dist/safe-bash-command-diff/diff.js +1 -1
  172. package/dist/safe-bash-command-diff/index.js +1 -1
  173. package/dist/safe-bash-command-ffmpeg/index.js +1 -1
  174. package/dist/safe-bash-command-ffprobe/index.js +2 -2
  175. package/dist/safe-bash-command-ffprobe/media.d.ts +3 -1
  176. package/dist/safe-bash-command-ffprobe/media.js +2 -2
  177. package/dist/safe-bash-command-html-to-markdown/budget.js +2 -1
  178. package/dist/safe-bash-command-html-to-markdown/entities.js +4 -3
  179. package/dist/safe-bash-command-html-to-markdown/index.js +564 -110
  180. package/dist/safe-bash-command-html-to-markdown/input.js +6 -5
  181. package/dist/safe-bash-command-html-to-markdown/options.js +2 -1
  182. package/dist/safe-bash-command-html-to-markdown/parser.js +5 -4
  183. package/dist/safe-bash-command-html-to-markdown/render.js +6 -5
  184. package/dist/safe-bash-command-html-to-markdown/text.js +3 -2
  185. package/dist/safe-bash-command-htmlq/index.js +361 -37
  186. package/dist/safe-bash-command-htmlq/tree.d.ts +3 -2
  187. package/dist/safe-bash-command-pandoc/command.js +7 -7
  188. package/dist/safe-bash-command-pandoc/index.js +55 -55
  189. package/dist/safe-bash-command-patch/index.js +6 -6
  190. package/dist/safe-bash-command-patch/patch-envelope.js +53 -3
  191. package/dist/safe-bash-command-patch/patch-formats.d.ts +2 -2
  192. package/dist/safe-bash-command-patch/patch-formats.js +2 -2
  193. package/dist/safe-bash-command-patch/patch-gnu-reject.d.ts +2 -1
  194. package/dist/safe-bash-command-patch/patch-gnu-reject.js +4 -3
  195. package/dist/safe-bash-command-patch/patch-publication.js +2 -1
  196. package/dist/safe-bash-command-patch/patch.js +6 -6
  197. package/dist/safe-bash-command-patch/unified.d.ts +10 -2
  198. package/dist/safe-bash-command-patch/unified.js +1 -1
  199. package/dist/safe-bash-command-pdftk/index.d.ts +6 -2
  200. package/dist/safe-bash-command-pdftk/index.js +835 -243
  201. package/dist/safe-bash-command-pptx/command-engine.d.ts +15 -3
  202. package/dist/safe-bash-command-pptx/engine.d.ts +2 -2
  203. package/dist/safe-bash-command-pptx/engine.js +1 -1
  204. package/dist/safe-bash-command-pptx/index.js +9 -2
  205. package/dist/safe-bash-command-soffice/index.js +1 -1
  206. package/dist/safe-bash-command-ssconvert/index.js +2 -2
  207. package/dist/safe-bash-command-xmllint/index.js +22 -31
  208. package/dist/safe-bash-diff-engine/document.d.ts +2 -1
  209. package/dist/safe-bash-diff-engine/document.js +7 -4
  210. package/dist/safe-bash-presentation-engine/accessibility.js +31 -30
  211. package/dist/safe-bash-presentation-engine/animation-editing.js +16 -15
  212. package/dist/safe-bash-presentation-engine/animations.js +16 -15
  213. package/dist/safe-bash-presentation-engine/backgrounds.js +17 -16
  214. package/dist/safe-bash-presentation-engine/bytes.js +3 -3
  215. package/dist/safe-bash-presentation-engine/chart-editing.js +34 -33
  216. package/dist/safe-bash-presentation-engine/chart-object-operations.js +25 -24
  217. package/dist/safe-bash-presentation-engine/charts.js +31 -30
  218. package/dist/safe-bash-presentation-engine/command-placeholder.js +59 -55
  219. package/dist/safe-bash-presentation-engine/comments.js +17 -16
  220. package/dist/safe-bash-presentation-engine/connector-operations.js +32 -31
  221. package/dist/safe-bash-presentation-engine/connectors.js +29 -28
  222. package/dist/safe-bash-presentation-engine/content-types.js +4 -4
  223. package/dist/safe-bash-presentation-engine/creation.js +6 -6
  224. package/dist/safe-bash-presentation-engine/diff.js +32 -31
  225. package/dist/safe-bash-presentation-engine/drawing-enums.d.ts +10 -10
  226. package/dist/safe-bash-presentation-engine/drawing-format.js +20 -19
  227. package/dist/safe-bash-presentation-engine/drawing-operations.js +31 -30
  228. package/dist/safe-bash-presentation-engine/drawing-schema.js +21 -20
  229. package/dist/safe-bash-presentation-engine/equations.js +17 -16
  230. package/dist/safe-bash-presentation-engine/errors.js +2 -2
  231. package/dist/safe-bash-presentation-engine/fields.js +17 -16
  232. package/dist/safe-bash-presentation-engine/font-metrics.js +3 -3
  233. package/dist/safe-bash-presentation-engine/image-extraction.js +20 -19
  234. package/dist/safe-bash-presentation-engine/image-formatting.js +32 -31
  235. package/dist/safe-bash-presentation-engine/image-insertion.js +18 -17
  236. package/dist/safe-bash-presentation-engine/image-replacement.js +21 -20
  237. package/dist/safe-bash-presentation-engine/image-value.js +4 -4
  238. package/dist/safe-bash-presentation-engine/images.js +19 -18
  239. package/dist/safe-bash-presentation-engine/index.d.ts +6 -2
  240. package/dist/safe-bash-presentation-engine/index.js +112 -97
  241. package/dist/safe-bash-presentation-engine/layouts.js +16 -15
  242. package/dist/safe-bash-presentation-engine/length.js +3 -3
  243. package/dist/safe-bash-presentation-engine/links.js +16 -15
  244. package/dist/safe-bash-presentation-engine/masters.js +15 -14
  245. package/dist/safe-bash-presentation-engine/media-editing.js +24 -23
  246. package/dist/safe-bash-presentation-engine/media-extraction.js +17 -16
  247. package/dist/safe-bash-presentation-engine/media.js +16 -15
  248. package/dist/safe-bash-presentation-engine/memberships.js +15 -14
  249. package/dist/safe-bash-presentation-engine/notes.js +16 -15
  250. package/dist/safe-bash-presentation-engine/ole-enum.js +4 -4
  251. package/dist/safe-bash-presentation-engine/ole-insertion.js +20 -19
  252. package/dist/safe-bash-presentation-engine/opaque-objects.js +9 -9
  253. package/dist/safe-bash-presentation-engine/package-reader.js +5 -5
  254. package/dist/safe-bash-presentation-engine/package-tools.d.ts +3 -0
  255. package/dist/safe-bash-presentation-engine/package-tools.js +27 -17
  256. package/dist/safe-bash-presentation-engine/package-uri.js +3 -3
  257. package/dist/safe-bash-presentation-engine/package-writer.js +4 -4
  258. package/dist/safe-bash-presentation-engine/presentation-model.js +58 -54
  259. package/dist/safe-bash-presentation-engine/presentation-settings.js +14 -13
  260. package/dist/safe-bash-presentation-engine/properties.js +16 -15
  261. package/dist/safe-bash-presentation-engine/relationships.js +4 -4
  262. package/dist/safe-bash-presentation-engine/resource-limits.js +1 -1
  263. package/dist/safe-bash-presentation-engine/retained-archive-staging.d.ts +19 -0
  264. package/dist/safe-bash-presentation-engine/retained-extraction-output.d.ts +18 -0
  265. package/dist/safe-bash-presentation-engine/retained-inspection.js +14 -12
  266. package/dist/safe-bash-presentation-engine/retained-package-extraction.d.ts +22 -0
  267. package/dist/safe-bash-presentation-engine/retained-package-packing.d.ts +19 -0
  268. package/dist/safe-bash-presentation-engine/retained-package.d.ts +2 -0
  269. package/dist/safe-bash-presentation-engine/retained-package.js +6 -4
  270. package/dist/safe-bash-presentation-engine/retained-slide-publication.d.ts +24 -0
  271. package/dist/safe-bash-presentation-engine/retained-text.js +19 -17
  272. package/dist/safe-bash-presentation-engine/retained-xml-parts.d.ts +5 -1
  273. package/dist/safe-bash-presentation-engine/retained-xml-publication.d.ts +18 -0
  274. package/dist/safe-bash-presentation-engine/retained-xml-replacement.d.ts +13 -0
  275. package/dist/safe-bash-presentation-engine/sanitize.js +17 -16
  276. package/dist/safe-bash-presentation-engine/selectors.js +10 -10
  277. package/dist/safe-bash-presentation-engine/shape-groups.js +31 -30
  278. package/dist/safe-bash-presentation-engine/shape-operations.js +30 -29
  279. package/dist/safe-bash-presentation-engine/shape-path-operations.js +32 -31
  280. package/dist/safe-bash-presentation-engine/shape-paths.js +16 -15
  281. package/dist/safe-bash-presentation-engine/shape-presets.js +3 -3
  282. package/dist/safe-bash-presentation-engine/shape-selection.js +31 -30
  283. package/dist/safe-bash-presentation-engine/shape-transforms.js +18 -17
  284. package/dist/safe-bash-presentation-engine/shapes.d.ts +1 -1
  285. package/dist/safe-bash-presentation-engine/shapes.js +27 -26
  286. package/dist/safe-bash-presentation-engine/slide-copy.js +17 -16
  287. package/dist/safe-bash-presentation-engine/slide-import.js +18 -17
  288. package/dist/safe-bash-presentation-engine/slide-merge-split.js +20 -19
  289. package/dist/safe-bash-presentation-engine/slide-model.js +43 -42
  290. package/dist/safe-bash-presentation-engine/slide-removal.js +18 -17
  291. package/dist/safe-bash-presentation-engine/slide-transfer-budget.js +9 -9
  292. package/dist/safe-bash-presentation-engine/slides.d.ts +1 -0
  293. package/dist/safe-bash-presentation-engine/slides.js +23 -17
  294. package/dist/safe-bash-presentation-engine/table-operations.js +33 -32
  295. package/dist/safe-bash-presentation-engine/table-spans.js +32 -31
  296. package/dist/safe-bash-presentation-engine/tables.js +31 -30
  297. package/dist/safe-bash-presentation-engine/tags.js +16 -15
  298. package/dist/safe-bash-presentation-engine/template-bindings.js +33 -32
  299. package/dist/safe-bash-presentation-engine/template-repeat.js +40 -39
  300. package/dist/safe-bash-presentation-engine/text-fitting.js +27 -26
  301. package/dist/safe-bash-presentation-engine/text-frames.js +27 -26
  302. package/dist/safe-bash-presentation-engine/text-paragraphs.js +27 -26
  303. package/dist/safe-bash-presentation-engine/text-reading.js +11 -11
  304. package/dist/safe-bash-presentation-engine/text-replacement.js +17 -16
  305. package/dist/safe-bash-presentation-engine/text-runs.js +20 -19
  306. package/dist/safe-bash-presentation-engine/themes.js +16 -15
  307. package/dist/safe-bash-presentation-engine/transitions.js +16 -15
  308. package/dist/safe-bash-presentation-engine/validation.js +10 -9
  309. package/dist/safe-bash-presentation-engine/xml-parts.d.ts +2 -0
  310. package/dist/safe-bash-presentation-engine/xml-parts.js +23 -15
  311. package/dist/safe-bash-presentation-engine/xml-view.js +3 -3
  312. package/dist/safe-bash-presentation-engine/xml.js +3 -3
  313. package/dist/safe-bash-regex-engine/index.js +1 -1
  314. package/dist/safe-bash-regex-engine/python-glob.js +1 -1
  315. package/dist/safe-bash-regex-engine/text/regex.d.ts +19 -0
  316. package/dist/safe-bash-regex-engine/text/regex.js +1 -1
  317. package/dist/safe-bash-xml-engine/document.js +3 -3
  318. package/dist/safe-bash-xml-engine/evaluate.js +1 -1
  319. package/dist/safe-bash-xml-engine/index.d.ts +1 -0
  320. package/dist/safe-bash-xml-engine/index.js +8 -4
  321. package/dist/safe-bash-xml-engine/query.js +2 -2
  322. package/dist/safe-bash-xml-engine/recovery.d.ts +10 -0
  323. package/dist/safe-bash-xml-engine/stored-document.d.ts +1 -1
  324. package/dist/safe-bash-xml-engine/stored-document.js +1 -1
  325. package/dist/safe-bash-xml-engine/stored-evaluate.js +1 -1
  326. package/dist/spreadsheet-engine/formulas/functions/python-printf.js +56 -33
  327. package/dist/spreadsheet-format-xls/biff-encrypted-properties.d.ts +2 -2
  328. package/dist/spreadsheet-format-xls/biff-encrypted-properties.js +86 -24
  329. package/dist/spreadsheet-format-xls/biff-metadata.d.ts +1 -0
  330. package/dist/spreadsheet-format-xls/biff-metadata.js +2 -2
  331. package/dist/spreadsheet-format-xls/biff-properties-merge.d.ts +6 -2
  332. package/dist/spreadsheet-format-xls/biff-properties-merge.js +413 -296
  333. package/dist/spreadsheet-format-xls/biff-properties-write.js +40 -23
  334. package/dist/spreadsheet-format-xls/biff-properties.js +3 -68
  335. package/dist/spreadsheet-format-xls/biff-property-index.d.ts +23 -0
  336. package/dist/spreadsheet-format-xls/biff-property-index.js +93 -0
  337. package/dist/spreadsheet-format-xls/biff-property-name.d.ts +4 -0
  338. package/dist/spreadsheet-format-xls/biff-property-name.js +114 -0
  339. package/dist/spreadsheet-format-xls/biff-property-text.d.ts +6 -0
  340. package/dist/spreadsheet-format-xls/biff-property-text.js +68 -0
  341. package/dist/spreadsheet-format-xls/biff-property-transcode.d.ts +5 -0
  342. package/dist/spreadsheet-format-xls/biff-property-transcode.js +45 -0
  343. package/dist/spreadsheet-format-xls/biff-write-metadata.js +10 -1
  344. package/package.json +6 -3
  345. package/dist/safe-bash/command-chunks/biff-3EFLKBAH-NYWZOYQS.js +0 -4942
  346. package/dist/safe-bash/command-chunks/chunk-5Q22ZLNC.js +0 -127
  347. package/dist/safe-bash/command-chunks/chunk-JKLOBSMP.js +0 -56
  348. package/dist/safe-bash/command-chunks/chunk-JYTESTBS.js +0 -99
  349. package/dist/safe-bash/command-chunks/chunk-WH3TIOTS.js +0 -326
  350. package/dist/safe-bash/command-chunks/paradox-ZWWXYY4J-JYOSWSBL.js +0 -362
  351. package/dist/spreadsheet-format-xls/biff-properties-layout.js +0 -56
@@ -1,12 +1,13 @@
1
+ import { createBiffPropertyNameEncoder } from "./biff-property-name.js";
2
+ import { readBiffPropertyText } from "./biff-property-text.js";
3
+ import { stageWideBiffProperty } from './biff-property-transcode.js';
4
+ import { stagePropertyBytes, propertyChunks } from './biff-property-bytes.js';
1
5
  import { SsconvertError } from "../spreadsheet-engine/contracts.js";
2
- import { singleByteTables } from "../spreadsheet-engine/encoding/tables.js";
3
- import { biffDbcsTables } from "../spreadsheet-engine/encoding/biff-dbcs-tables.js";
4
6
  import { Binary, invalidBiff } from "./biff-binary.js";
5
- import { biffDecode } from "./biff-strings.js";
6
7
  import { biffPropertyFields, biffPropertyFormats, readBiffProperties } from "./biff-properties.js";
7
- import { readBiffPropertySections, readBiffPropertyValues } from "./biff-properties-layout.js";
8
+ import { propertyRange, readPropertySectionRanges, readPropertyValueRanges } from "./biff-property-range.js";
8
9
  /** Rebuild offsets around original opaque spans. Never transcode their codepage. */
9
- export async function mergeBiffProperties(book, streams, handled, context, charge, allocate) {
10
+ export async function mergeBiffProperties(book, streams, handled, context, charge, allocate, staged) {
10
11
  const canonical = (name) => ["\u0005SummaryInformation", "\u0005DocumentSummaryInformation"].find(target => target.toUpperCase() === name.toUpperCase());
11
12
  const snapshots = new Map(), duplicates = new Set();
12
13
  const preserved = new Set();
@@ -27,316 +28,432 @@ export async function mergeBiffProperties(book, streams, handled, context, charg
27
28
  throw new SsconvertError("resource-limit", "ssconvert BIFF property text limit exceeded");
28
29
  return text;
29
30
  };
30
- for (const record of book.unsupportedRecords ?? []) {
31
- admit(1);
32
- if (record.source !== "biff" || record.kind !== "ole-properties" || record.disposition !== "retained")
33
- continue;
34
- const data = record.data;
35
- if (!data || typeof data !== "object" || Array.isArray(data))
36
- continue;
37
- const object = data;
38
- charge(Object.keys(object).length);
39
- if (Object.keys(object).some(key => !["stream", "bytes", "modeled"].includes(key)) || typeof object.stream !== "string" ||
40
- typeof object.bytes !== "string" || object.modeled !== undefined && !Array.isArray(object.modeled))
41
- continue;
42
- charge(object.stream.length + object.bytes.length);
43
- const name = canonical(object.stream);
44
- if (!name)
45
- continue;
46
- if (snapshots.has(name)) {
47
- duplicates.add(name);
48
- continue;
49
- }
50
- if (object.bytes.length % 2)
51
- invalidBiff("invalid retained property bytes");
52
- const bytes = allocate(object.bytes.length / 2);
53
- for (let i = 0; i < bytes.length; i++) {
54
- const high = "0123456789abcdef".indexOf(object.bytes[i * 2].toLowerCase()), low = "0123456789abcdef".indexOf(object.bytes[i * 2 + 1].toLowerCase());
55
- if (high < 0 || low < 0)
56
- invalidBiff("invalid retained property bytes");
57
- bytes[i] = high * 16 + low;
58
- }
59
- snapshots.set(name, { record, bytes, modeled: object.modeled });
60
- }
61
- for (const name of duplicates)
62
- snapshots.delete(name);
63
- if (!snapshots.size)
64
- return preserved;
65
- const parse = (bytes) => readBiffPropertySections(bytes, admit, charge).map(section => {
66
- const data = bytes.subarray(section.offset, section.end);
67
- return { ...section, bytes: data, ...(biffPropertyFields.has(section.guid) || section.guid === biffPropertyFormats.custom ?
68
- { values: readBiffPropertyValues(new Binary(data), admit, charge) } : {}) };
69
- });
70
- const old = new Map([...snapshots].map(([name, snapshot]) => [name, parse(snapshot.bytes)]));
71
- const fresh = new Map([...streams].map(([name, bytes]) => [name, parse(bytes)]));
72
- const original = new Map(), pending = new Map();
73
- const identity = (property) => `${property.stream}:${property.section}:${property.id}`;
74
- const readContext = { ...context, limits: { ...context.limits, inputBytes: context.limits.outputBytes } };
75
- // Reuse scalar decoding, but do not create another retained hexadecimal copy.
76
- await readBiffProperties(new Map([...snapshots].map(([name, value]) => [name, value.bytes])), readContext, accountText, charge, undefined, property => { admit(1); original.set(identity(property), property); });
77
- await readBiffProperties(streams, readContext, accountText, charge, undefined, property => { admit(1); pending.set(property.key, property); });
78
- const dictionary = (section) => {
79
- const data = section.values?.get(0);
80
- if (!data)
81
- return [];
82
- const cp = section.values?.get(1)?.u16(4) ?? 1252, width = cp === 1200 ? 2 : 1, count = data.u32(0);
83
- data.check(4, count * 9);
84
- admit(count);
85
- let at = 4;
86
- const entries = [];
87
- for (let i = 0; i < count; i++) {
88
- const start = at, id = data.u32(at), length = data.u32(at + 4);
89
- at += 8;
90
- if (!length)
91
- invalidBiff("empty property dictionary name");
92
- const bytes = data.slice(at, (length - 1) * width);
93
- const name = cp === 1200 || cp === 65001 ? new TextDecoder(cp === 1200 ? "utf-16le" : "utf-8", { fatal: true, ignoreBOM: true }).decode(bytes) : biffDecode(bytes, cp);
94
- accountText(name);
95
- at += length * width;
96
- if (width === 2)
97
- at = Math.ceil(at / 4) * 4;
98
- entries.push({ id, name, bytes: data.slice(start, at - start) });
99
- }
100
- return entries;
31
+ const temporarySources = [];
32
+ const closeTemporary = async () => {
33
+ const outcomes = await Promise.allSettled(temporarySources.map(source => source.close()));
34
+ const errors = outcomes.filter((value) => value.status === "rejected").map(value => value.reason);
35
+ if (errors.length)
36
+ throw new AggregateError(errors, "BIFF property merge storage cleanup failed");
101
37
  };
102
- const writeDictionary = (section, entries) => {
103
- const bytes = allocate(4 + entries.reduce((sum, entry) => sum + entry.bytes.length, 0));
104
- new DataView(bytes.buffer).setUint32(0, entries.length, true);
105
- let at = 4;
106
- for (const entry of entries) {
107
- charge(entry.bytes.length);
108
- bytes.set(entry.bytes, at);
109
- at += entry.bytes.length;
38
+ try {
39
+ for (const record of book.unsupportedRecords ?? []) {
40
+ admit(1);
41
+ if (record.source !== "biff" || record.kind !== "ole-properties" || record.disposition !== "retained")
42
+ continue;
43
+ const data = record.data;
44
+ if (!data || typeof data !== "object" || Array.isArray(data))
45
+ continue;
46
+ const object = data;
47
+ charge(Object.keys(object).length);
48
+ if (Object.keys(object).some(key => !["stream", "bytes", "modeled"].includes(key)) || typeof object.stream !== "string" ||
49
+ typeof object.bytes !== "string" || object.modeled !== undefined && !Array.isArray(object.modeled))
50
+ continue;
51
+ charge(object.stream.length + object.bytes.length);
52
+ const name = canonical(object.stream);
53
+ if (!name)
54
+ continue;
55
+ if (snapshots.has(name)) {
56
+ duplicates.add(name);
57
+ continue;
58
+ }
59
+ if (object.bytes.length % 2)
60
+ invalidBiff("invalid retained property bytes");
61
+ const hex = object.bytes, size = hex.length / 2;
62
+ if (size > context.limits.outputBytes || size > 0xffffffff)
63
+ throw new SsconvertError("resource-limit", "ssconvert BIFF property output bytes limit exceeded");
64
+ charge(size);
65
+ const byte = (at) => {
66
+ const high = "0123456789abcdef".indexOf(hex[at * 2].toLowerCase()), low = "0123456789abcdef".indexOf(hex[at * 2 + 1].toLowerCase());
67
+ if (high < 0 || low < 0)
68
+ invalidBiff("invalid retained property bytes");
69
+ return high * 16 + low;
70
+ };
71
+ for (let at = 0; at < size; at++) {
72
+ if (at % 16384 === 0)
73
+ context.signal.throwIfAborted();
74
+ byte(at);
75
+ }
76
+ const bytes = propertyRange({ size, async read(at, count) {
77
+ const bytes = new Uint8Array(Math.min(16384, count, size - at));
78
+ for (let i = 0; i < bytes.length; i++)
79
+ bytes[i] = byte(at + i);
80
+ return bytes;
81
+ } }, context);
82
+ snapshots.set(name, { record, bytes, modeled: object.modeled });
110
83
  }
111
- section.values.set(0, new Binary(bytes));
112
- };
113
- const remove = (section, id) => {
114
- section.values.delete(id);
115
- if (section.guid === biffPropertyFormats.custom)
116
- writeDictionary(section, dictionary(section).filter(entry => entry.id !== id));
117
- };
118
- const take = (property) => {
119
- charge(fresh.get(property.stream).length);
120
- const section = fresh.get(property.stream).find(section => section.offset === property.section);
121
- const value = section.values.get(property.id);
122
- remove(section, property.id);
123
- pending.delete(property.key);
124
- return value;
125
- };
126
- const wide = (data, section) => {
127
- if (data.u32(0) !== 30 || (section.values.get(1)?.u16(4) ?? 1252) === 65001)
128
- return data;
129
- const value = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(data.slice(8, data.u32(4) - 1));
130
- charge(value.length);
131
- const bytes = allocate(8 + (value.length + 1) * 2), view = new DataView(bytes.buffer);
132
- view.setUint32(0, 31, true);
133
- view.setUint32(4, value.length + 1, true);
134
- for (let i = 0; i < value.length; i++)
135
- view.setUint16(8 + i * 2, value.charCodeAt(i), true);
136
- return new Binary(bytes);
137
- };
138
- const same = (a, b) => {
139
- if (!Array.isArray(a) || !Array.isArray(b))
140
- return Object.is(a, b);
141
- charge(a.length + b.length);
142
- return a.length === b.length && a.every((value, i) => Object.is(value, b[i]));
143
- };
144
- for (const [name, snapshot] of snapshots) {
145
- const seen = new Set();
146
- let modeled = snapshot.modeled;
147
- if (!modeled) {
148
- modeled = [];
149
- // SummaryInformation is read first. A legacy document-only snapshot lacks
150
- // that earlier stream's ownership decisions: infer only unchanged values.
151
- for (const property of original.values()) {
152
- charge(1);
153
- if (property.stream !== name)
154
- continue;
155
- if (name === "\u0005SummaryInformation" || snapshots.has("\u0005SummaryInformation") ||
156
- Object.hasOwn(book.properties ?? {}, property.key) && same(property.value, book.properties?.[property.key])) {
157
- admit(1);
158
- modeled.push([property.section, property.id, property.key]);
84
+ for (const name of duplicates)
85
+ snapshots.delete(name);
86
+ if (!snapshots.size)
87
+ return preserved;
88
+ const parse = async (input) => {
89
+ const file = propertyRange(input, context), sections = [];
90
+ for (const section of await readPropertySectionRanges(file, admit, charge)) {
91
+ const bytes = file.slice(section.offset, section.end - section.offset);
92
+ sections.push({ ...section, bytes, ...(biffPropertyFields.has(section.guid) || section.guid === biffPropertyFormats.custom ?
93
+ { values: await readPropertyValueRanges(bytes, admit, charge) } : {}) });
94
+ }
95
+ return sections;
96
+ };
97
+ const old = new Map(), fresh = new Map();
98
+ for (const [name, snapshot] of snapshots)
99
+ old.set(name, await parse(snapshot.bytes));
100
+ for (const [name, bytes] of streams)
101
+ fresh.set(name, await parse(bytes));
102
+ const materialize = async (source) => {
103
+ const bytes = allocate(source.size);
104
+ for (let at = 0; at < bytes.length;) {
105
+ const part = await source.read(at, bytes.length - at);
106
+ bytes.set(part, at);
107
+ at += part.length;
108
+ }
109
+ return new Binary(bytes);
110
+ };
111
+ const original = new Map(), pending = new Map();
112
+ const identity = (property) => `${property.stream}:${property.section}:${property.id}`;
113
+ const readContext = { ...context, limits: { ...context.limits, inputBytes: context.limits.outputBytes } };
114
+ // Reuse scalar decoding, but do not create another retained hexadecimal copy.
115
+ await readBiffProperties(new Map([...snapshots].map(([name, value]) => [name, value.bytes])), readContext, accountText, charge, undefined, property => { admit(1); original.set(identity(property), property); });
116
+ await readBiffProperties(streams, readContext, accountText, charge, undefined, property => { admit(1); pending.set(property.key, property); });
117
+ const chunks = async function* (source) {
118
+ for (let at = 0; at < source.size;) {
119
+ const bytes = await source.read(at, source.size - at);
120
+ at += bytes.length;
121
+ yield bytes;
122
+ }
123
+ };
124
+ const dictionary = async function* (section, names = true) {
125
+ const data = section.values?.get(0);
126
+ if (!data)
127
+ return;
128
+ const cp = await section.values?.get(1)?.u16(4) ?? 1252, count = await data.u32(0);
129
+ data.check(4, count * 9);
130
+ if (names) {
131
+ charge(data.size);
132
+ admit(count);
133
+ }
134
+ let at = 4;
135
+ for (let i = 0; i < count; i++) {
136
+ const start = at, id = await data.u32(at);
137
+ let name = '';
138
+ if (names) {
139
+ const entry = await readBiffPropertyText(data, at + 4, cp, readContext, accountText, charge);
140
+ at = entry.end;
141
+ name = entry.value;
142
+ }
143
+ else {
144
+ // Replay already validated spans without retaining or decoding their names again.
145
+ const length = await data.u32(at + 4), width = cp === 1200 ? 2 : 1;
146
+ if (!length)
147
+ invalidBiff("empty property dictionary name");
148
+ at += 8 + length * width;
149
+ if (width === 2)
150
+ at = Math.ceil(at / 4) * 4;
159
151
  }
152
+ yield { id, name, bytes: data.slice(start, at - start) };
160
153
  }
161
- }
162
- for (const entry of modeled) {
163
- admit(1);
164
- if (!Array.isArray(entry) || entry.length !== 3 || typeof entry[0] !== "number" || typeof entry[1] !== "number" || typeof entry[2] !== "string")
165
- invalidBiff("invalid retained property identity");
166
- const [offset, id, key] = entry;
167
- const property = original.get(identity({ stream: name, section: offset, id }));
168
- if (!property || property.key !== key || seen.has(key))
169
- invalidBiff("invalid retained property identity");
170
- seen.add(key);
171
- charge(old.get(name).length);
172
- const section = old.get(name).find(section => section.offset === offset);
173
- const value = book.properties?.[key], replacement = pending.get(key);
174
- if (!Object.hasOwn(book.properties ?? {}, key))
175
- remove(section, id);
176
- else if (same(property.value, value)) {
177
- preserved.add(key);
178
- if (replacement)
179
- take(replacement);
154
+ };
155
+ const writeDictionary = async (section, plan) => {
156
+ const output = { length: plan.length, async *chunks() {
157
+ const header = new Uint8Array(4);
158
+ new DataView(header.buffer).setUint32(0, plan.count, true);
159
+ yield header;
160
+ for await (const entry of dictionary(section, false))
161
+ if (entry.id !== plan.remove) {
162
+ charge(entry.bytes.size);
163
+ yield* chunks(entry.bytes);
164
+ }
165
+ if (plan.append) {
166
+ charge(plan.append.size);
167
+ yield* chunks(plan.append);
168
+ }
169
+ } };
170
+ if (staged) {
171
+ staged.reserve(plan.length);
172
+ const source = await stagePropertyBytes(output, context);
173
+ temporarySources.push(source);
174
+ section.values.set(0, propertyRange(source, context));
180
175
  }
181
- else if (replacement)
182
- section.values.set(id, wide(take(replacement), section));
183
- }
184
- }
185
- // Reverse the same tables as the importer; no transliteration or escape fallback.
186
- const encodings = new Map();
187
- const encodeName = (name, cp) => {
188
- accountText(name);
189
- if (cp === 65001)
190
- return new TextEncoder().encode(name + "\0");
191
- if (cp === 1200) {
192
- const bytes = allocate((name.length + 1) * 2), view = new DataView(bytes.buffer);
193
- for (let i = 0; i < name.length; i++)
194
- view.setUint16(i * 2, name.charCodeAt(i), true);
195
- return bytes;
196
- }
197
- let reverse = encodings.get(cp);
198
- if (!reverse) {
199
- reverse = new Map();
200
- encodings.set(cp, reverse);
201
- const dbcs = biffDbcsTables[cp], table = dbcs?.single ?? singleByteTables[cp === 1201 ? "iso-8859-1" : cp === 10000 ? "macintosh" : cp >= 1250 && cp <= 1258 ? `windows-${cp}` : `cp${cp}`];
202
- if (!table)
203
- return undefined;
204
- for (let i = 0; i < table.length; i++) {
205
- charge(1);
206
- if (table[i] !== "\uffff" && !reverse.has(table[i]))
207
- reverse.set(table[i], [i]);
176
+ else {
177
+ const bytes = allocate(plan.length);
178
+ let at = 0;
179
+ for await (const part of output.chunks()) {
180
+ bytes.set(part, at);
181
+ at += part.length;
182
+ }
183
+ section.values.set(0, propertyRange(bytes, context));
208
184
  }
209
- if (dbcs)
210
- for (const [lead, row] of Object.entries(dbcs.double))
211
- for (let trail = 0; trail < row.length; trail++) {
212
- charge(1);
213
- if (row[trail] !== "\uffff" && !reverse.has(row[trail]))
214
- reverse.set(row[trail], [Number(lead), trail]);
185
+ };
186
+ const remove = async (section, id) => {
187
+ section.values.delete(id);
188
+ if (section.guid === biffPropertyFormats.custom) {
189
+ let length = 4, count = 0;
190
+ for await (const entry of dictionary(section))
191
+ if (entry.id !== id) {
192
+ length += entry.bytes.size;
193
+ count++;
215
194
  }
216
- }
217
- const result = [];
218
- for (const character of name + "\0") {
219
- charge(1);
220
- const value = reverse.get(character);
221
- if (!value)
222
- return undefined;
223
- result.push(...value);
224
- if (result.length > context.limits.outputBytes)
225
- throw new SsconvertError("resource-limit", "ssconvert BIFF property output bytes limit exceeded");
226
- }
227
- const bytes = Uint8Array.from(result);
228
- return biffDecode(bytes, cp) === name + "\0" ? bytes : undefined;
229
- };
230
- const warn = async (key, reason) => context.diagnostic?.({ code: "biff-loss-warning", severity: "warning",
231
- message: `Unsupported Excel BIFF document property: ${key} (${reason}; original property bytes retained)` });
232
- for (const property of [...pending.values()]) {
233
- charge(fresh.get(property.stream).length + (old.get(property.stream)?.length ?? 0));
234
- const source = fresh.get(property.stream).find(section => section.offset === property.section);
235
- const target = old.get(property.stream)?.find(section => section.guid === source.guid);
236
- if (!target)
237
- continue;
238
- const value = take(property), values = target.values;
239
- let id = property.id;
240
- if (target.guid === biffPropertyFormats.custom) {
241
- let entries;
242
- try {
243
- entries = dictionary(target);
195
+ await writeDictionary(section, { length, count, remove: id });
244
196
  }
245
- catch (error) {
246
- if (!(error instanceof SsconvertError) || error.code !== "unsupported-feature")
247
- throw error;
248
- await warn(property.key, "unknown dictionary encoding");
249
- continue;
197
+ };
198
+ const take = async (property) => {
199
+ charge(fresh.get(property.stream).length);
200
+ const section = fresh.get(property.stream).find(section => section.offset === property.section);
201
+ const value = section.values.get(property.id);
202
+ await remove(section, property.id);
203
+ pending.delete(property.key);
204
+ return value;
205
+ };
206
+ const wide = async (source, section) => {
207
+ if (await source.u32(0) !== 30 || (await section.values.get(1)?.u16(4) ?? 1252) === 65001)
208
+ return source;
209
+ if (staged) {
210
+ const output = await stageWideBiffProperty(source, context, charge, staged.reserve);
211
+ temporarySources.push(output);
212
+ return propertyRange(output, context);
250
213
  }
251
- charge(entries.length + values.size);
252
- if (entries.some(entry => entry.name === property.key)) {
253
- await warn(property.key, "opaque name collision");
254
- continue;
214
+ const data = await materialize(source);
215
+ const value = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(data.slice(8, data.u32(4) - 1));
216
+ charge(value.length);
217
+ const bytes = allocate(8 + (value.length + 1) * 2), view = new DataView(bytes.buffer);
218
+ view.setUint32(0, 31, true);
219
+ view.setUint32(4, value.length + 1, true);
220
+ for (let i = 0; i < value.length; i++)
221
+ view.setUint16(8 + i * 2, value.charCodeAt(i), true);
222
+ return propertyRange(bytes, context);
223
+ };
224
+ const same = (a, b) => {
225
+ if (!Array.isArray(a) || !Array.isArray(b))
226
+ return Object.is(a, b);
227
+ charge(a.length + b.length);
228
+ return a.length === b.length && a.every((value, i) => Object.is(value, b[i]));
229
+ };
230
+ for (const [name, snapshot] of snapshots) {
231
+ const seen = new Set();
232
+ let modeled = snapshot.modeled;
233
+ if (!modeled) {
234
+ modeled = [];
235
+ // SummaryInformation is read first. A legacy document-only snapshot lacks
236
+ // that earlier stream's ownership decisions: infer only unchanged values.
237
+ for (const property of original.values()) {
238
+ charge(1);
239
+ if (property.stream !== name)
240
+ continue;
241
+ if (name === "\u0005SummaryInformation" || snapshots.has("\u0005SummaryInformation") ||
242
+ Object.hasOwn(book.properties ?? {}, property.key) && same(property.value, book.properties?.[property.key])) {
243
+ admit(1);
244
+ modeled.push([property.section, property.id, property.key]);
245
+ }
246
+ }
247
+ }
248
+ for (const entry of modeled) {
249
+ admit(1);
250
+ if (!Array.isArray(entry) || entry.length !== 3 || typeof entry[0] !== "number" || typeof entry[1] !== "number" || typeof entry[2] !== "string")
251
+ invalidBiff("invalid retained property identity");
252
+ const [offset, id, key] = entry;
253
+ const property = original.get(identity({ stream: name, section: offset, id }));
254
+ if (!property || property.key !== key || seen.has(key))
255
+ invalidBiff("invalid retained property identity");
256
+ seen.add(key);
257
+ charge(old.get(name).length);
258
+ const section = old.get(name).find(section => section.offset === offset);
259
+ const value = book.properties?.[key], replacement = pending.get(key);
260
+ if (!Object.hasOwn(book.properties ?? {}, key))
261
+ await remove(section, id);
262
+ else if (same(property.value, value)) {
263
+ preserved.add(key);
264
+ if (replacement)
265
+ await take(replacement);
266
+ }
267
+ else if (replacement)
268
+ section.values.set(id, await wide(await take(replacement), section));
255
269
  }
256
- const cp = values.get(1)?.u16(4) ?? 1252, text = encodeName(property.key, cp);
257
- if (!text) {
258
- await warn(property.key, "name cannot be encoded in the original codepage");
270
+ }
271
+ const encodeName = createBiffPropertyNameEncoder(context, charge, accountText);
272
+ const warn = async (key, reason) => context.diagnostic?.({ code: "biff-loss-warning", severity: "warning",
273
+ message: `Unsupported Excel BIFF document property: ${key} (${reason}; original property bytes retained)` });
274
+ for (const property of [...pending.values()]) {
275
+ charge(fresh.get(property.stream).length + (old.get(property.stream)?.length ?? 0));
276
+ const source = fresh.get(property.stream).find(section => section.offset === property.section);
277
+ const target = old.get(property.stream)?.find(section => section.guid === source.guid);
278
+ if (!target)
259
279
  continue;
280
+ const value = await take(property), values = target.values;
281
+ let id = property.id;
282
+ if (target.guid === biffPropertyFormats.custom) {
283
+ let count = 0, dictionaryLength = 4, maximumId = 1, collision = false;
284
+ try {
285
+ for await (const entry of dictionary(target)) {
286
+ count++;
287
+ dictionaryLength += entry.bytes.size;
288
+ maximumId = Math.max(maximumId, entry.id);
289
+ if (entry.name === property.key)
290
+ collision = true;
291
+ }
292
+ }
293
+ catch (error) {
294
+ if (!(error instanceof SsconvertError) || error.code !== "unsupported-feature")
295
+ throw error;
296
+ await warn(property.key, "unknown dictionary encoding");
297
+ continue;
298
+ }
299
+ charge(count + values.size);
300
+ if (collision) {
301
+ await warn(property.key, "opaque name collision");
302
+ continue;
303
+ }
304
+ const cp = await values.get(1)?.u16(4) ?? 1252, text = encodeName(property.key, cp);
305
+ if (!text) {
306
+ await warn(property.key, "name cannot be encoded in the original codepage");
307
+ continue;
308
+ }
309
+ id = maximumId;
310
+ for (const key of values.keys())
311
+ id = Math.max(id, key);
312
+ id++;
313
+ if (id > 0xffffffff) {
314
+ await warn(property.key, "no free property ID");
315
+ continue;
316
+ }
317
+ const size = 8 + text.length, length = cp === 1200 ? Math.ceil(size / 4) * 4 : size;
318
+ const entry = { length, *chunks() {
319
+ const header = new Uint8Array(8), view = new DataView(header.buffer);
320
+ view.setUint32(0, id, true);
321
+ view.setUint32(4, text.length / (cp === 1200 ? 2 : 1), true);
322
+ yield header;
323
+ yield* propertyChunks(text);
324
+ if (length > size)
325
+ yield new Uint8Array(length - size);
326
+ } };
327
+ let bytes;
328
+ if (staged) {
329
+ staged.reserve(length);
330
+ const source = await stagePropertyBytes(entry, context);
331
+ temporarySources.push(source);
332
+ bytes = propertyRange(source, context);
333
+ }
334
+ else {
335
+ const data = allocate(length);
336
+ let at = 0;
337
+ for (const part of entry.chunks()) {
338
+ data.set(part, at);
339
+ at += part.length;
340
+ }
341
+ bytes = propertyRange(data, context);
342
+ }
343
+ await writeDictionary(target, { length: dictionaryLength + bytes.size, count: count + 1, append: bytes });
260
344
  }
261
- id = 1;
262
- for (const key of values.keys())
263
- id = Math.max(id, key);
264
- for (const entry of entries)
265
- id = Math.max(id, entry.id);
266
- id++;
267
- if (id > 0xffffffff) {
268
- await warn(property.key, "no free property ID");
345
+ else if (values.has(id)) {
346
+ await warn(property.key, "opaque property ID collision");
269
347
  continue;
270
348
  }
271
- const length = 8 + text.length, bytes = allocate(cp === 1200 ? Math.ceil(length / 4) * 4 : length), view = new DataView(bytes.buffer);
272
- view.setUint32(0, id, true);
273
- view.setUint32(4, text.length / (cp === 1200 ? 2 : 1), true);
274
- bytes.set(text, 8);
275
- writeDictionary(target, [...entries, { id, name: property.key, bytes }]);
349
+ values.set(id, await wide(value, target));
276
350
  }
277
- else if (values.has(id)) {
278
- await warn(property.key, "opaque property ID collision");
279
- continue;
351
+ const reserve = staged?.reserve ?? ((length) => {
352
+ charge(length);
353
+ if (length > 0xffffffff || length > context.limits.outputBytes)
354
+ throw new SsconvertError("resource-limit", "ssconvert BIFF property output bytes limit exceeded");
355
+ return length;
356
+ });
357
+ const encodeSection = (section) => {
358
+ if (!section.values)
359
+ return { length: section.bytes.size, chunks: () => chunks(section.bytes) };
360
+ const values = section.values;
361
+ let length = 8 + values.size * 8;
362
+ for (const value of values.values())
363
+ length += Math.ceil(value.size / 4) * 4;
364
+ // Buffered output charges the section size here, as the old allocation did.
365
+ reserve(length);
366
+ return { length, async *chunks() {
367
+ const header = new Uint8Array(8), view = new DataView(header.buffer);
368
+ view.setUint32(0, length, true);
369
+ view.setUint32(4, values.size, true);
370
+ yield header;
371
+ let at = 8 + values.size * 8;
372
+ for (const [id, value] of values) {
373
+ charge(value.size);
374
+ const entry = new Uint8Array(8), view = new DataView(entry.buffer);
375
+ view.setUint32(0, id, true);
376
+ view.setUint32(4, at, true);
377
+ yield entry;
378
+ at += Math.ceil(value.size / 4) * 4;
379
+ }
380
+ for (const value of values.values()) {
381
+ yield* chunks(value);
382
+ const padding = (4 - value.size % 4) % 4;
383
+ if (padding)
384
+ yield new Uint8Array(padding);
385
+ }
386
+ } };
387
+ };
388
+ for (const name of new Set([...streams.keys(), ...snapshots.keys()])) {
389
+ for (const section of fresh.get(name) ?? [])
390
+ charge(1 + section.values.size);
391
+ const remaining = fresh.get(name)?.filter(section => [...section.values.keys()].some(id => id >= 2)) ?? [];
392
+ if (!old.has(name) && remaining.some(section => section.guid === biffPropertyFormats.custom) &&
393
+ !remaining.some(section => section.guid === biffPropertyFormats.document)) {
394
+ const builtin = fresh.get(name)?.find(section => section.guid === biffPropertyFormats.document);
395
+ if (builtin)
396
+ remaining.unshift(builtin);
397
+ }
398
+ const sections = [...old.get(name) ?? [], ...remaining];
399
+ if (!sections.length) {
400
+ streams.delete(name);
401
+ continue;
402
+ }
403
+ const bodies = sections.map(encodeSection), length = 28 + sections.length * 20 + bodies.reduce((sum, body) => sum + body.length, 0);
404
+ const originalHeader = await (snapshots.get(name)?.bytes ?? propertyRange(streams.get(name), context)).read(0, 28);
405
+ const output = { length, async *chunks() {
406
+ const header = new Uint8Array(originalHeader);
407
+ new DataView(header.buffer).setUint32(24, sections.length, true);
408
+ yield header;
409
+ let at = 28 + sections.length * 20;
410
+ for (let i = 0; i < sections.length; i++) {
411
+ charge(1);
412
+ const entry = new Uint8Array(20), view = new DataView(entry.buffer);
413
+ for (let j = 0; j < 16; j++)
414
+ entry[j] = parseInt(sections[i].guid.slice(j * 2, j * 2 + 2), 16);
415
+ view.setUint32(16, at, true);
416
+ yield entry;
417
+ at += bodies[i].length;
418
+ }
419
+ for (const body of bodies)
420
+ yield* body.chunks();
421
+ } };
422
+ if (staged) {
423
+ reserve(length);
424
+ staged.sources.set(name, await stagePropertyBytes(output, context));
425
+ }
426
+ else {
427
+ const bytes = allocate(length);
428
+ let at = 0;
429
+ for await (const part of output.chunks()) {
430
+ bytes.set(part, at);
431
+ at += part.length;
432
+ }
433
+ streams.set(name, bytes);
434
+ }
435
+ const snapshot = snapshots.get(name);
436
+ if (snapshot)
437
+ handled.add(snapshot.record);
280
438
  }
281
- values.set(id, wide(value, target));
282
- }
283
- const encodeSection = (section) => {
284
- if (!section.values)
285
- return section.bytes;
286
- const entries = [...section.values], bytes = allocate(8 + entries.length * 8 + entries.reduce((sum, [, value]) => sum + Math.ceil(value.bytes.length / 4) * 4, 0));
287
- const view = new DataView(bytes.buffer);
288
- view.setUint32(0, bytes.length, true);
289
- view.setUint32(4, entries.length, true);
290
- let at = 8 + entries.length * 8;
291
- entries.forEach(([id, value], i) => {
292
- charge(value.bytes.length);
293
- view.setUint32(8 + i * 8, id, true);
294
- view.setUint32(12 + i * 8, at, true);
295
- bytes.set(value.bytes, at);
296
- at += Math.ceil(value.bytes.length / 4) * 4;
439
+ const exposed = new Set();
440
+ await readBiffProperties(staged?.sources ?? streams, readContext, accountText, charge, undefined, property => {
441
+ admit(1);
442
+ if (!Object.hasOwn(book.properties ?? {}, property.key))
443
+ exposed.add(property.key);
297
444
  });
298
- return bytes;
299
- };
300
- for (const name of new Set([...streams.keys(), ...snapshots.keys()])) {
301
- for (const section of fresh.get(name) ?? [])
302
- charge(1 + section.values.size);
303
- const remaining = fresh.get(name)?.filter(section => [...section.values.keys()].some(id => id >= 2)) ?? [];
304
- if (!old.has(name) && remaining.some(section => section.guid === biffPropertyFormats.custom) &&
305
- !remaining.some(section => section.guid === biffPropertyFormats.document)) {
306
- const builtin = fresh.get(name)?.find(section => section.guid === biffPropertyFormats.document);
307
- if (builtin)
308
- remaining.unshift(builtin);
445
+ for (const key of exposed)
446
+ await warn(key, "opaque property exposes a field absent from the model");
447
+ }
448
+ catch (error) {
449
+ try {
450
+ await closeTemporary();
309
451
  }
310
- const sections = [...old.get(name) ?? [], ...remaining];
311
- if (!sections.length) {
312
- streams.delete(name);
313
- continue;
452
+ catch (cleanup) {
453
+ throw new AggregateError([error, cleanup], "BIFF property merge and cleanup failed");
314
454
  }
315
- const bodies = sections.map(encodeSection), bytes = allocate(28 + sections.length * 20 + bodies.reduce((sum, body) => sum + body.length, 0));
316
- bytes.set((snapshots.get(name)?.bytes ?? streams.get(name)).subarray(0, 28));
317
- const view = new DataView(bytes.buffer);
318
- view.setUint32(24, sections.length, true);
319
- let at = 28 + sections.length * 20;
320
- sections.forEach((section, i) => {
321
- charge(1);
322
- for (let j = 0; j < 16; j++)
323
- bytes[28 + i * 20 + j] = parseInt(section.guid.slice(j * 2, j * 2 + 2), 16);
324
- view.setUint32(44 + i * 20, at, true);
325
- bytes.set(bodies[i], at);
326
- at += bodies[i].length;
327
- });
328
- streams.set(name, bytes);
329
- const snapshot = snapshots.get(name);
330
- if (snapshot)
331
- handled.add(snapshot.record);
455
+ throw error;
332
456
  }
333
- const exposed = new Set();
334
- await readBiffProperties(streams, readContext, accountText, charge, undefined, property => {
335
- admit(1);
336
- if (!Object.hasOwn(book.properties ?? {}, property.key))
337
- exposed.add(property.key);
338
- });
339
- for (const key of exposed)
340
- await warn(key, "opaque property exposes a field absent from the model");
457
+ await closeTemporary();
341
458
  return preserved;
342
459
  }