@poe-platform/safe-bash 0.1.799 → 0.1.801

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 (1076) hide show
  1. package/README.md +48 -22
  2. package/dist/image-ast/index.browser.js +1503 -98
  3. package/dist/image-ast/index.js +1503 -98
  4. package/dist/mp4-ast/types.d.ts +1 -0
  5. package/dist/office-package/zip.d.ts +2 -0
  6. package/dist/office-package/zip.js +1 -1
  7. package/dist/pdf-ast/index.js +5 -4
  8. package/dist/safe-bash/chunks/{chunk-LUOFIVNI.js → chunk-3NDIFSNM.js} +3 -3
  9. package/dist/safe-bash/chunks/chunk-3R3AANOR.js +26 -0
  10. package/dist/safe-bash/chunks/{chunk-TRVGCN3U.js → chunk-45PK3NWI.js} +4 -4
  11. package/dist/safe-bash/chunks/{chunk-KHMGTPD6.js → chunk-46Z5E5EV.js} +2 -2
  12. package/dist/safe-bash/chunks/{chunk-XB3B7KMM.js → chunk-6O77NL2S.js} +1 -1
  13. package/dist/safe-bash/chunks/{chunk-T3JTVIEP.js → chunk-6PAVEFT3.js} +1 -1
  14. package/dist/safe-bash/chunks/{chunk-PYVEAFJM.js → chunk-74GHTNJA.js} +3 -2
  15. package/dist/safe-bash/chunks/{chunk-LQHGH25W.js → chunk-7R5BDCG7.js} +1 -1
  16. package/dist/safe-bash/chunks/{chunk-WUNK5NXJ.js → chunk-7VNF5BFF.js} +1140 -1660
  17. package/dist/safe-bash/chunks/{chunk-NHOXKQNE.js → chunk-A7XEHALN.js} +6 -6
  18. package/dist/safe-bash/chunks/{chunk-MHZ24KEI.js → chunk-AM5ESLPH.js} +1 -1
  19. package/dist/safe-bash/chunks/{chunk-3L3T6LYV.js → chunk-AUSNDQTJ.js} +1 -1
  20. package/dist/safe-bash/chunks/{chunk-YG5WAHK7.js → chunk-B7TAL7S5.js} +1 -3
  21. package/dist/safe-bash/chunks/{chunk-K7IQZE7D.js → chunk-C5OWC2TL.js} +1 -1
  22. package/dist/safe-bash/chunks/{chunk-F3RV2F72.js → chunk-CHYGPFVM.js} +1 -1
  23. package/dist/safe-bash/chunks/{chunk-M4CFCXHN.js → chunk-CS4MNM6I.js} +1 -1
  24. package/dist/safe-bash/chunks/{chunk-H6JW3E4F.js → chunk-CTVWDACF.js} +1 -1
  25. package/dist/safe-bash/chunks/{chunk-KTGR4U57.js → chunk-D3ANYGMC.js} +2 -3
  26. package/dist/safe-bash/chunks/{chunk-ENR3HB2B.js → chunk-E7OYNDGL.js} +1 -2
  27. package/dist/safe-bash/chunks/{chunk-SOZK5JVX.js → chunk-FBUCWVTE.js} +1 -1
  28. package/dist/safe-bash/chunks/{chunk-NX2SQVON.js → chunk-FNDNHAGE.js} +46 -27
  29. package/dist/safe-bash/chunks/{chunk-KCVSVD65.js → chunk-I5HZ4FGE.js} +1 -1
  30. package/dist/safe-bash/chunks/{chunk-KMH2DF3I.js → chunk-ICFDYV64.js} +7 -2
  31. package/dist/safe-bash/chunks/{chunk-T5KKDMYB.js → chunk-IVRQ4BXL.js} +7 -1
  32. package/dist/safe-bash/chunks/{chunk-KV7PKOHV.js → chunk-IWDICZVK.js} +1 -1
  33. package/dist/safe-bash/chunks/{chunk-I4OAEOP6.js → chunk-J42RIHHJ.js} +1 -1
  34. package/dist/safe-bash/chunks/chunk-K6VCD7IY.js +106 -0
  35. package/dist/safe-bash/chunks/{chunk-63FXVDGF.js → chunk-LVOBFF4D.js} +1 -1
  36. package/dist/safe-bash/chunks/{chunk-U5NUZPCC.js → chunk-MHMMRCYC.js} +1 -1
  37. package/dist/safe-bash/chunks/{chunk-6HZYFL3H.js → chunk-NR3EM4LS.js} +1 -1
  38. package/dist/safe-bash/chunks/{chunk-VYZTG3GV.js → chunk-NZQXYWA3.js} +1 -1
  39. package/dist/safe-bash/chunks/{chunk-JSVX4VIA.js → chunk-OQRVVGR6.js} +3 -2
  40. package/dist/safe-bash/chunks/{chunk-B3DDEDH2.js → chunk-OV6IHKO6.js} +2 -2
  41. package/dist/safe-bash/chunks/{chunk-SPYL72GN.js → chunk-PQRAK7HU.js} +1196 -5781
  42. package/dist/safe-bash/chunks/chunk-SZH7EJLD.js +9221 -0
  43. package/dist/safe-bash/chunks/{chunk-AKC46AF6.js → chunk-TFIBK2GI.js} +8 -41
  44. package/dist/safe-bash/chunks/{chunk-ZNAFMYIA.js → chunk-UE5KZDEK.js} +2 -2
  45. package/dist/safe-bash/chunks/{chunk-QU3BVQ53.js → chunk-UTBUUFDM.js} +1 -1
  46. package/dist/safe-bash/chunks/{chunk-6IBTC4YL.js → chunk-VQDD3G76.js} +93 -39
  47. package/dist/safe-bash/chunks/{chunk-IUTD5FH5.js → chunk-VTH3MLDU.js} +2 -7
  48. package/dist/safe-bash/chunks/{chunk-LLZCZ24K.js → chunk-XVOSKJE2.js} +1 -1
  49. package/dist/safe-bash/chunks/{csvkit-W2UEKH6P.js → csvkit-TACDU7FC.js} +3 -3
  50. package/dist/safe-bash/chunks/{ffmpeg-42CGASMV.js → ffmpeg-WTC3TEFI.js} +2 -2
  51. package/dist/safe-bash/chunks/{gh-26GYLH6D.js → gh-6WU6PXL4.js} +2 -2
  52. package/dist/safe-bash/chunks/{git-YREKMUVD.js → git-EFZIGJW4.js} +2 -2
  53. package/dist/safe-bash/chunks/{imagemagick-3YIX4XO2.js → imagemagick-EIEYGWPF.js} +2 -2
  54. package/dist/safe-bash/chunks/{implementation-E3YMKU3Z.js → implementation-MLFHUQ5M.js} +2 -2
  55. package/dist/safe-bash/chunks/mmdc-ROQJT5HQ.js +118 -0
  56. package/dist/safe-bash/chunks/{pdfimages-UE2UISP2.js → pdfimages-DW7LWXFI.js} +2 -2
  57. package/dist/safe-bash/chunks/{pdfinfo-RGARKLI5.js → pdfinfo-TIP6XLUQ.js} +4 -12
  58. package/dist/safe-bash/chunks/{pdftk-JY3WVCCC.js → pdftk-DMG22ITZ.js} +2 -2
  59. package/dist/safe-bash/chunks/{pdftoppm-GPD3BMPY.js → pdftoppm-WNDYR72T.js} +2 -2
  60. package/dist/safe-bash/chunks/{pdftotext-K7GQ2QJZ.js → pdftotext-5IPZ4NI7.js} +2 -2
  61. package/dist/safe-bash/chunks/{qpdf-F4U7WUSU.js → qpdf-TTX2DIUA.js} +2 -2
  62. package/dist/safe-bash/chunks/{sips-RWENS7X5.js → sips-XYS46JPJ.js} +2 -2
  63. package/dist/safe-bash/chunks/{soffice-IT6W2C5F.js → soffice-TU73E5KL.js} +2 -2
  64. package/dist/safe-bash/chunks/{wkhtmltopdf-JYNDAHIZ.js → wkhtmltopdf-FSZ2CHGE.js} +2 -2
  65. package/dist/safe-bash/command-chunks/{chunk-QBGA56UH.js → chunk-2ELYGJDD.js} +7 -7
  66. package/dist/safe-bash/command-chunks/chunk-2FGJYFWZ.js +44 -0
  67. package/dist/safe-bash/command-chunks/chunk-2H4JTFIL.js +53 -0
  68. package/dist/safe-bash/command-chunks/{chunk-52PCQXD2.js → chunk-2NHI5F5S.js} +2 -1
  69. package/dist/safe-bash/command-chunks/{chunk-HDKVO47G.js → chunk-2SQEIUGJ.js} +3 -3
  70. package/dist/safe-bash/command-chunks/chunk-364TMWBT.js +946 -0
  71. package/dist/safe-bash/command-chunks/chunk-3E2OIS2J.js +7037 -0
  72. package/dist/safe-bash/command-chunks/chunk-3HHCU5YU.js +380 -0
  73. package/dist/safe-bash/command-chunks/{chunk-TF6OA2GK.js → chunk-3NV3HYT2.js} +1 -1
  74. package/dist/safe-bash/command-chunks/chunk-4B7Y7S6E.js +61 -0
  75. package/dist/safe-bash/command-chunks/{chunk-LLCXZKZ6.js → chunk-4BB2SWJ5.js} +2 -2
  76. package/dist/safe-bash/command-chunks/{chunk-IEXHHNOF.js → chunk-4J5CZ2DP.js} +2 -7
  77. package/dist/safe-bash/command-chunks/{chunk-WDHI3S6Y.js → chunk-4OOUQTQO.js} +1 -1
  78. package/dist/safe-bash/command-chunks/chunk-4ZHMW6F5.js +104 -0
  79. package/dist/safe-bash/command-chunks/{chunk-YMONDXET.js → chunk-4ZQWGOZB.js} +2 -2
  80. package/dist/safe-bash/command-chunks/chunk-5BSTFCXG.js +553 -0
  81. package/dist/safe-bash/command-chunks/{chunk-MKQVQMXO.js → chunk-5LU4UCBR.js} +1 -1
  82. package/dist/safe-bash/command-chunks/chunk-5PWJG2UK.js +174 -0
  83. package/dist/safe-bash/command-chunks/chunk-5TBUOBDE.js +346 -0
  84. package/dist/safe-bash/command-chunks/{chunk-JMPP4TCW.js → chunk-5UBXNSFZ.js} +3 -2
  85. package/dist/safe-bash/command-chunks/chunk-5XY4DTNG.js +34 -0
  86. package/dist/safe-bash/command-chunks/chunk-5ZMZ573Q.js +140 -0
  87. package/dist/safe-bash/command-chunks/{chunk-3NG75MOB.js → chunk-67GQA75T.js} +1 -1
  88. package/dist/safe-bash/command-chunks/chunk-67QKREJK.js +347 -0
  89. package/dist/safe-bash/command-chunks/{chunk-L6SU4S26.js → chunk-6B7WQIKB.js} +0 -7
  90. package/dist/safe-bash/command-chunks/chunk-6BNTBWIK.js +327 -0
  91. package/dist/safe-bash/command-chunks/chunk-6EPHJGGF.js +23 -0
  92. package/dist/safe-bash/command-chunks/chunk-6F4XCVON.js +266 -0
  93. package/dist/safe-bash/command-chunks/chunk-6KJ3LPI2.js +94 -0
  94. package/dist/safe-bash/command-chunks/{chunk-HLDTOR7M.js → chunk-6ZVI7LUY.js} +1 -1
  95. package/dist/safe-bash/command-chunks/{chunk-X6NJC3IC.js → chunk-75OFBY5R.js} +1 -1
  96. package/dist/safe-bash/command-chunks/chunk-7K6JYKPJ.js +422 -0
  97. package/dist/safe-bash/command-chunks/chunk-7N2LI2KO.js +206 -0
  98. package/dist/safe-bash/command-chunks/{chunk-MRW5HD2D.js → chunk-7O3E4LPT.js} +4 -22
  99. package/dist/safe-bash/command-chunks/chunk-7U7EXOXX.js +1392 -0
  100. package/dist/safe-bash/command-chunks/{chunk-6CYTRQ24.js → chunk-7VTKQUA5.js} +20 -17
  101. package/dist/safe-bash/command-chunks/{chunk-BZPAWTUL.js → chunk-AEF5BA3D.js} +1 -1
  102. package/dist/safe-bash/command-chunks/{pptx-GBPNWNEP-7EQEVXV5.js → chunk-AI5JAXQF.js} +34820 -18029
  103. package/dist/safe-bash/command-chunks/{chunk-63R3FEZJ.js → chunk-AIV5BF5W.js} +1 -1
  104. package/dist/safe-bash/command-chunks/{chunk-AYUTO323.js → chunk-AKJG2XD3.js} +2 -18
  105. package/dist/safe-bash/command-chunks/{chunk-J34TZVMW.js → chunk-ALDC4XP4.js} +0 -5
  106. package/dist/safe-bash/command-chunks/chunk-AMO3THU4.js +105 -0
  107. package/dist/safe-bash/command-chunks/chunk-ARBYOQUZ.js +65 -0
  108. package/dist/safe-bash/command-chunks/chunk-BAGCY35S.js +231 -0
  109. package/dist/safe-bash/command-chunks/chunk-BAXU7B5Z.js +101 -0
  110. package/dist/safe-bash/command-chunks/{chunk-44AHAB5O.js → chunk-BDSMROQZ.js} +1 -4
  111. package/dist/safe-bash/command-chunks/chunk-BNOU5YQS.js +182 -0
  112. package/dist/safe-bash/command-chunks/{chunk-4ZALPDBV.js → chunk-BPE5INLI.js} +2 -2
  113. package/dist/safe-bash/command-chunks/{chunk-OT4LZMLB.js → chunk-BR73BIOW.js} +1 -1
  114. package/dist/safe-bash/command-chunks/chunk-C5YYCQHW.js +1444 -0
  115. package/dist/safe-bash/command-chunks/chunk-C7I25AAL.js +25 -0
  116. package/dist/safe-bash/command-chunks/{chunk-4ONEXMD3.js → chunk-CAP7ZJSY.js} +8 -8
  117. package/dist/safe-bash/command-chunks/{chunk-DWFLVJC6.js → chunk-CCRHMAU5.js} +2 -1
  118. package/dist/safe-bash/command-chunks/chunk-CQ5YGOGB.js +150 -0
  119. package/dist/safe-bash/command-chunks/{chunk-JCNNOMBV.js → chunk-CQTRW45K.js} +3 -2
  120. package/dist/safe-bash/command-chunks/{chunk-N2F74VRO.js → chunk-CZ7EN3JG.js} +1 -1
  121. package/dist/safe-bash/command-chunks/chunk-DB453IE6.js +122 -0
  122. package/dist/safe-bash/command-chunks/{chunk-KKG4BAFZ.js → chunk-DIEPXUM4.js} +6 -0
  123. package/dist/safe-bash/command-chunks/chunk-DOKKNRRM.js +87 -0
  124. package/dist/safe-bash/command-chunks/{chunk-2PX5B7T5.js → chunk-DQAVUDDX.js} +2 -2
  125. package/dist/safe-bash/command-chunks/chunk-DT7BCTWY.js +249 -0
  126. package/dist/safe-bash/command-chunks/{chunk-6BETHLXZ.js → chunk-DZCY63VJ.js} +13 -11
  127. package/dist/safe-bash/command-chunks/{chunk-QUENU6GM.js → chunk-E55UKBIE.js} +3 -3
  128. package/dist/safe-bash/command-chunks/chunk-EK6YNAXT.js +343 -0
  129. package/dist/safe-bash/command-chunks/chunk-EQ4HV54N.js +22 -0
  130. package/dist/safe-bash/command-chunks/{chunk-HLGKIZ25.js → chunk-F6OYH562.js} +2 -0
  131. package/dist/safe-bash/command-chunks/{chunk-MC3VWLIZ.js → chunk-FDBUV4HJ.js} +28 -19
  132. package/dist/safe-bash/command-chunks/{chunk-7FKUC34S.js → chunk-FPVUD6TH.js} +6 -3
  133. package/dist/safe-bash/command-chunks/chunk-FXELCPFX.js +195 -0
  134. package/dist/safe-bash/command-chunks/chunk-FXOA7RBK.js +42 -0
  135. package/dist/safe-bash/command-chunks/{chunk-LPORMIZS.js → chunk-FZTK4MFI.js} +9 -9
  136. package/dist/safe-bash/command-chunks/{chunk-K543PB3I.js → chunk-G66QUHIZ.js} +6 -35
  137. package/dist/safe-bash/command-chunks/chunk-GFQZCKO6.js +272 -0
  138. package/dist/safe-bash/command-chunks/{chunk-CU5RLO62.js → chunk-GLOZX57Y.js} +92 -18
  139. package/dist/safe-bash/command-chunks/chunk-GMIHJYDG.js +331 -0
  140. package/dist/safe-bash/command-chunks/chunk-GOB777HR.js +97 -0
  141. package/dist/safe-bash/command-chunks/chunk-GRBWW4SG.js +48 -0
  142. package/dist/safe-bash/command-chunks/{chunk-PPNBNFAU.js → chunk-GYQ2HAKQ.js} +8 -8
  143. package/dist/safe-bash/command-chunks/chunk-H622NS6Z.js +11 -0
  144. package/dist/safe-bash/command-chunks/{chunk-UI32HWGS.js → chunk-HMOZ6XVJ.js} +1 -1
  145. package/dist/safe-bash/command-chunks/{chunk-AVSPNLWV.js → chunk-I237SNW5.js} +1 -1
  146. package/dist/safe-bash/command-chunks/{chunk-43GSSUAY.js → chunk-II77KPZN.js} +5 -5
  147. package/dist/safe-bash/command-chunks/{chunk-ZS3QPNUL.js → chunk-IR2BY7EL.js} +21 -6
  148. package/dist/safe-bash/command-chunks/{chunk-SG424QWS.js → chunk-JDYXY44P.js} +2 -2
  149. package/dist/safe-bash/command-chunks/chunk-JNZ3CVAE.js +147 -0
  150. package/dist/safe-bash/command-chunks/{chunk-4QJOYXVB.js → chunk-JV7LBUTP.js} +1 -1
  151. package/dist/safe-bash/command-chunks/{chunk-IKS2YXZQ.js → chunk-K67MWWWH.js} +3 -3
  152. package/dist/safe-bash/command-chunks/chunk-KFVV7ZJO.js +216 -0
  153. package/dist/safe-bash/command-chunks/{chunk-G4PNVO6Z.js → chunk-KP7AO66M.js} +1 -1
  154. package/dist/safe-bash/command-chunks/{chunk-KMCZ6P4O.js → chunk-KQLD3AED.js} +68 -7
  155. package/dist/safe-bash/command-chunks/chunk-KWESKQHR.js +25 -0
  156. package/dist/safe-bash/command-chunks/{chunk-YZ5SVZFD.js → chunk-KXU3IRUO.js} +3 -3
  157. package/dist/safe-bash/command-chunks/{chunk-C7IHMJEW.js → chunk-KZC5UWFF.js} +2 -2
  158. package/dist/safe-bash/command-chunks/{chunk-2WRTLCGK.js → chunk-LAOM65EE.js} +5 -5
  159. package/dist/safe-bash/command-chunks/chunk-LE5LZNHE.js +204 -0
  160. package/dist/safe-bash/command-chunks/{chunk-HFII3QYO.js → chunk-LWS62ISU.js} +46 -32
  161. package/dist/safe-bash/command-chunks/{chunk-BZDDAPSV.js → chunk-LWSBAWLT.js} +1 -1
  162. package/dist/safe-bash/command-chunks/chunk-MDH5T4OS.js +41 -0
  163. package/dist/safe-bash/command-chunks/{chunk-X7TM3AKW.js → chunk-MIXBO6U7.js} +20 -7
  164. package/dist/safe-bash/command-chunks/chunk-MM6HU6CX.js +20 -0
  165. package/dist/safe-bash/command-chunks/{chunk-MYJAZ3U2.js → chunk-MPL2466A.js} +2 -2
  166. package/dist/safe-bash/command-chunks/{chunk-HLBX5IRS.js → chunk-MQFIPHIQ.js} +46 -81
  167. package/dist/safe-bash/command-chunks/{chunk-ZJBR5Q5I.js → chunk-MSFXC3OC.js} +4 -4
  168. package/dist/safe-bash/command-chunks/{chunk-NI7MKJPN.js → chunk-MTQH74CF.js} +3 -55
  169. package/dist/safe-bash/command-chunks/chunk-MWUZZWXK.js +354 -0
  170. package/dist/safe-bash/command-chunks/chunk-N4PFUSRM.js +35 -0
  171. package/dist/safe-bash/command-chunks/chunk-NCD7PEWH.js +298 -0
  172. package/dist/safe-bash/command-chunks/chunk-NFGI5IGF.js +266 -0
  173. package/dist/safe-bash/command-chunks/{chunk-I3K5RYU4.js → chunk-NKFYQSES.js} +73 -26
  174. package/dist/safe-bash/command-chunks/{chunk-KVFCSLKK.js → chunk-NXEQ3ESQ.js} +6 -0
  175. package/dist/safe-bash/command-chunks/{chunk-NGWB2YBL.js → chunk-O4JQSB7O.js} +1 -1
  176. package/dist/safe-bash/command-chunks/{chunk-7L24L4UO.js → chunk-OQU6UT6X.js} +2 -20
  177. package/dist/safe-bash/command-chunks/{chunk-3VGGYEDH.js → chunk-ORYGZYKW.js} +4 -3
  178. package/dist/safe-bash/command-chunks/{chunk-ZXKW7SJ2.js → chunk-OYYV7ZAF.js} +2 -2
  179. package/dist/safe-bash/command-chunks/chunk-P2N33UMN.js +270 -0
  180. package/dist/safe-bash/command-chunks/{chunk-Q7Q5GM5S.js → chunk-P5APDEFB.js} +2 -2
  181. package/dist/safe-bash/command-chunks/{chunk-X2YQLGKS.js → chunk-PCEFOYA3.js} +240 -148
  182. package/dist/safe-bash/command-chunks/{chunk-OLQG7ZCN.js → chunk-PEF7K3UQ.js} +136 -75
  183. package/dist/safe-bash/command-chunks/chunk-PII4YEZW.js +123 -0
  184. package/dist/safe-bash/command-chunks/{chunk-AIRGA2SU.js → chunk-PMBFZXTK.js} +1 -1
  185. package/dist/safe-bash/command-chunks/{chunk-ZT4KSS2V.js → chunk-PTT3I223.js} +1 -1
  186. package/dist/safe-bash/command-chunks/{chunk-4Y3WVMK4.js → chunk-PV66YWHB.js} +1 -0
  187. package/dist/safe-bash/command-chunks/chunk-Q3EWDEUQ.js +185 -0
  188. package/dist/safe-bash/command-chunks/{chunk-AXK3H4PX.js → chunk-QJ33BHI4.js} +1 -1
  189. package/dist/safe-bash/command-chunks/chunk-QKFSRZGQ.js +1091 -0
  190. package/dist/safe-bash/command-chunks/{chunk-JZSNU2MY.js → chunk-QKJLP53H.js} +2 -2
  191. package/dist/safe-bash/command-chunks/{chunk-VVI4Z73I.js → chunk-QP4R6GLA.js} +5 -1
  192. package/dist/safe-bash/command-chunks/chunk-RMWQAAO5.js +2488 -0
  193. package/dist/safe-bash/command-chunks/{chunk-QDTBMSBE.js → chunk-RO62EWX6.js} +2 -2
  194. package/dist/safe-bash/command-chunks/{chunk-HRLIAMXC.js → chunk-RZZI24ZE.js} +7 -6
  195. package/dist/safe-bash/command-chunks/{chunk-PFAADCB5.js → chunk-SDNBCQ3X.js} +10 -24
  196. package/dist/safe-bash/command-chunks/chunk-SEM36PG5.js +11 -0
  197. package/dist/safe-bash/command-chunks/{chunk-36O5OT7E.js → chunk-T35Y7YQD.js} +1 -1
  198. package/dist/safe-bash/command-chunks/{chunk-ESMCX3YV.js → chunk-TGSNCQSR.js} +710 -143
  199. package/dist/safe-bash/command-chunks/chunk-TIOCQVUQ.js +557 -0
  200. package/dist/safe-bash/command-chunks/{chunk-T5H5UJQ3.js → chunk-TNOA7FCQ.js} +1 -1
  201. package/dist/safe-bash/command-chunks/{chunk-GN2TKLE7.js → chunk-TS65BJHG.js} +5 -5
  202. package/dist/safe-bash/command-chunks/chunk-TSCGT46G.js +363 -0
  203. package/dist/safe-bash/command-chunks/chunk-UG7SMZFF.js +178 -0
  204. package/dist/safe-bash/command-chunks/{chunk-KBEURXFF.js → chunk-UN6WS55J.js} +3 -3
  205. package/dist/safe-bash/command-chunks/chunk-UXSR5BZH.js +136 -0
  206. package/dist/safe-bash/command-chunks/{chunk-SX2X3IH4.js → chunk-V2V5OCL3.js} +1 -1
  207. package/dist/safe-bash/command-chunks/chunk-V6BEDRMQ.js +112 -0
  208. package/dist/safe-bash/command-chunks/chunk-V7A7DRTU.js +293 -0
  209. package/dist/safe-bash/command-chunks/{chunk-5SHGJ7NO.js → chunk-VA5ZHYYA.js} +73 -33
  210. package/dist/safe-bash/command-chunks/{chunk-J4PEQWSF.js → chunk-VGG2DL5Q.js} +0 -1
  211. package/dist/safe-bash/command-chunks/chunk-VPR5LQYX.js +1228 -0
  212. package/dist/safe-bash/command-chunks/{chunk-EIVW3X3N.js → chunk-VSRGNQCP.js} +11 -6
  213. package/dist/safe-bash/command-chunks/{chunk-TYVCKQDH.js → chunk-VXSLJH7G.js} +56 -6
  214. package/dist/safe-bash/command-chunks/{chunk-PXYOWWMV.js → chunk-W7RAD4EW.js} +4 -3
  215. package/dist/safe-bash/command-chunks/{src-UJOWAS2S.js → chunk-WD3ERGRY.js} +77 -277
  216. package/dist/safe-bash/command-chunks/{chunk-5ZSM4UFN.js → chunk-WECIOOQB.js} +8 -64
  217. package/dist/safe-bash/command-chunks/{chunk-YFSDDFGV.js → chunk-WH627NJL.js} +446 -53
  218. package/dist/safe-bash/command-chunks/chunk-WNE7FPVR.js +236 -0
  219. package/dist/safe-bash/command-chunks/{chunk-UKS2XJZI.js → chunk-WPYIOKE3.js} +4 -4
  220. package/dist/safe-bash/command-chunks/{chunk-HHP343KT.js → chunk-WTECBRU4.js} +1 -1
  221. package/dist/safe-bash/command-chunks/{chunk-AO6Z5EQ7.js → chunk-WVE64WM2.js} +6 -5
  222. package/dist/safe-bash/command-chunks/chunk-WVHONVZ4.js +594 -0
  223. package/dist/safe-bash/command-chunks/chunk-XIIBTGC5.js +580 -0
  224. package/dist/safe-bash/command-chunks/chunk-XJXU3VVH.js +737 -0
  225. package/dist/safe-bash/command-chunks/chunk-XNLFHHOC.js +63 -0
  226. package/dist/safe-bash/command-chunks/{chunk-XAFSZDY2.js → chunk-XS72HTMA.js} +11 -0
  227. package/dist/safe-bash/command-chunks/chunk-Y5INTD6S.js +220 -0
  228. package/dist/safe-bash/command-chunks/chunk-YIQACGEW.js +43 -0
  229. package/dist/safe-bash/command-chunks/chunk-YOF7R4OY.js +80 -0
  230. package/dist/safe-bash/command-chunks/{chunk-VZHRZMS7.js → chunk-YOFC45RK.js} +1 -1
  231. package/dist/safe-bash/command-chunks/{chunk-2FUAW6GO.js → chunk-Z45N42QC.js} +75 -11
  232. package/dist/safe-bash/command-chunks/chunk-ZHUWOUWB.js +618 -0
  233. package/dist/safe-bash/command-chunks/{chunk-OPUJSTHS.js → chunk-ZYHTWNAE.js} +215 -67
  234. package/dist/safe-bash/command-chunks/chunk-ZYXH3B66.js +636 -0
  235. package/dist/safe-bash/command-chunks/{model-store-L35QTZMJ.js → model-store-WPKMRPV4.js} +2 -2
  236. package/dist/safe-bash/command-chunks/pptx-7G52EJ6L-4JACH5FB.js +625 -0
  237. package/dist/safe-bash/command-chunks/python-worker-source-TYOFJMCW.js +4 -0
  238. package/dist/safe-bash/command-chunks/src-ICMQISAA.js +501 -0
  239. package/dist/safe-bash/commands/archive/create.d.ts +1 -17
  240. package/dist/safe-bash/commands/archive/create.js +1 -252
  241. package/dist/safe-bash/commands/archive/extract.d.ts +1 -11
  242. package/dist/safe-bash/commands/archive/extract.js +1 -640
  243. package/dist/safe-bash/commands/archive/format.d.ts +1 -32
  244. package/dist/safe-bash/commands/archive/format.js +1 -225
  245. package/dist/safe-bash/commands/archive/index.d.ts +5 -10
  246. package/dist/safe-bash/commands/archive/index.js +6 -931
  247. package/dist/safe-bash/commands/archive/listing.d.ts +1 -2
  248. package/dist/safe-bash/commands/archive/listing.js +1 -21
  249. package/dist/safe-bash/commands/archive/modes.d.ts +1 -5
  250. package/dist/safe-bash/commands/archive/modes.js +1 -182
  251. package/dist/safe-bash/commands/archive/options.d.ts +1 -53
  252. package/dist/safe-bash/commands/archive/options.js +1 -462
  253. package/dist/safe-bash/commands/archive/stream.d.ts +1 -22
  254. package/dist/safe-bash/commands/archive/stream.js +1 -188
  255. package/dist/safe-bash/commands/archive/transform.d.ts +1 -16
  256. package/dist/safe-bash/commands/archive/transform.js +1 -85
  257. package/dist/safe-bash/commands/archive/unzip/arguments.d.ts +1 -53
  258. package/dist/safe-bash/commands/archive/unzip/arguments.js +1 -322
  259. package/dist/safe-bash/commands/archive/unzip/safety.d.ts +1 -32
  260. package/dist/safe-bash/commands/archive/unzip/safety.js +1 -295
  261. package/dist/safe-bash/commands/archive/unzip.d.ts +1 -3
  262. package/dist/safe-bash/commands/archive/unzip.js +1 -398
  263. package/dist/safe-bash/commands/archive/zip/aes.d.ts +1 -17
  264. package/dist/safe-bash/commands/archive/zip/aes.js +1 -156
  265. package/dist/safe-bash/commands/archive/zip/comments.d.ts +1 -17
  266. package/dist/safe-bash/commands/archive/zip/comments.js +1 -83
  267. package/dist/safe-bash/commands/archive/zip/crc.d.ts +1 -1
  268. package/dist/safe-bash/commands/archive/zip/crc.js +1 -1
  269. package/dist/safe-bash/commands/archive/zip/crypto.d.ts +1 -19
  270. package/dist/safe-bash/commands/archive/zip/crypto.js +1 -118
  271. package/dist/safe-bash/commands/archive/zip/dates.d.ts +1 -4
  272. package/dist/safe-bash/commands/archive/zip/dates.js +1 -66
  273. package/dist/safe-bash/commands/archive/zip/environment.d.ts +1 -2
  274. package/dist/safe-bash/commands/archive/zip/environment.js +1 -62
  275. package/dist/safe-bash/commands/archive/zip/grow.d.ts +1 -3
  276. package/dist/safe-bash/commands/archive/zip/grow.js +1 -2
  277. package/dist/safe-bash/commands/archive/zip/help.d.ts +1 -4
  278. package/dist/safe-bash/commands/archive/zip/help.js +1 -182
  279. package/dist/safe-bash/commands/archive/zip/line-endings.d.ts +1 -2
  280. package/dist/safe-bash/commands/archive/zip/line-endings.js +1 -194
  281. package/dist/safe-bash/commands/archive/zip/log.d.ts +1 -22
  282. package/dist/safe-bash/commands/archive/zip/log.js +1 -159
  283. package/dist/safe-bash/commands/archive/zip/lzma.d.ts +1 -9
  284. package/dist/safe-bash/commands/archive/zip/lzma.js +1 -40
  285. package/dist/safe-bash/commands/archive/zip/move.d.ts +1 -11
  286. package/dist/safe-bash/commands/archive/zip/move.js +1 -59
  287. package/dist/safe-bash/commands/archive/zip/names.d.ts +1 -2
  288. package/dist/safe-bash/commands/archive/zip/names.js +1 -33
  289. package/dist/safe-bash/commands/archive/zip/options.d.ts +1 -13
  290. package/dist/safe-bash/commands/archive/zip/options.js +1 -124
  291. package/dist/safe-bash/commands/archive/zip/repair.d.ts +1 -10
  292. package/dist/safe-bash/commands/archive/zip/repair.js +1 -392
  293. package/dist/safe-bash/commands/archive/zip/safety.d.ts +1 -54
  294. package/dist/safe-bash/commands/archive/zip/safety.js +1 -360
  295. package/dist/safe-bash/commands/archive/zip/sfx.d.ts +1 -4
  296. package/dist/safe-bash/commands/archive/zip/sfx.js +1 -52
  297. package/dist/safe-bash/commands/archive/zip/test-command.d.ts +1 -5
  298. package/dist/safe-bash/commands/archive/zip/test-command.js +1 -101
  299. package/dist/safe-bash/commands/archive/zip/volumes.d.ts +1 -21
  300. package/dist/safe-bash/commands/archive/zip/volumes.js +1 -281
  301. package/dist/safe-bash/commands/archive/zip/zip64.d.ts +1 -30
  302. package/dist/safe-bash/commands/archive/zip/zip64.js +1 -227
  303. package/dist/safe-bash/commands/archive/zip-format.d.ts +1 -68
  304. package/dist/safe-bash/commands/archive/zip-format.js +1 -1075
  305. package/dist/safe-bash/commands/archive/zip.d.ts +1 -3
  306. package/dist/safe-bash/commands/archive/zip.js +1 -1523
  307. package/dist/safe-bash/commands/awk/index.d.ts +2 -0
  308. package/dist/safe-bash/commands/awk/index.js +2 -0
  309. package/dist/safe-bash/commands/bytes/compression/index.js +4 -2
  310. package/dist/safe-bash/commands/copy-preserve.d.ts +1 -0
  311. package/dist/safe-bash/commands/csplit/index.browser.js +2 -2
  312. package/dist/safe-bash/commands/curl/index.d.ts +2 -0
  313. package/dist/safe-bash/commands/curl/index.js +2 -0
  314. package/dist/safe-bash/commands/diff/index.d.ts +2 -0
  315. package/dist/safe-bash/commands/diff/index.js +2 -0
  316. package/dist/safe-bash/commands/diff-patch/diff-format.d.ts +1 -10
  317. package/dist/safe-bash/commands/diff-patch/diff-format.js +1 -237
  318. package/dist/safe-bash/commands/diff-patch/diff-options.d.ts +1 -38
  319. package/dist/safe-bash/commands/diff-patch/diff-options.js +1 -261
  320. package/dist/safe-bash/commands/diff-patch/diff-output.d.ts +1 -20
  321. package/dist/safe-bash/commands/diff-patch/diff-output.js +1 -290
  322. package/dist/safe-bash/commands/diff-patch/diff.d.ts +1 -2
  323. package/dist/safe-bash/commands/diff-patch/diff.js +1 -656
  324. package/dist/safe-bash/commands/diff-patch/index.d.ts +4 -5
  325. package/dist/safe-bash/commands/diff-patch/index.js +8 -333
  326. package/dist/safe-bash/commands/diff-patch/patch-envelope.d.ts +1 -2
  327. package/dist/safe-bash/commands/diff-patch/patch-envelope.js +1 -63
  328. package/dist/safe-bash/commands/diff-patch/patch-formats.d.ts +1 -7
  329. package/dist/safe-bash/commands/diff-patch/patch-formats.js +1 -264
  330. package/dist/safe-bash/commands/diff-patch/patch-gnu-paths.d.ts +1 -41
  331. package/dist/safe-bash/commands/diff-patch/patch-gnu-paths.js +1 -263
  332. package/dist/safe-bash/commands/diff-patch/patch-gnu-reject.d.ts +1 -3
  333. package/dist/safe-bash/commands/diff-patch/patch-gnu-reject.js +1 -100
  334. package/dist/safe-bash/commands/diff-patch/patch-path.d.ts +1 -3
  335. package/dist/safe-bash/commands/diff-patch/patch-path.js +1 -91
  336. package/dist/safe-bash/commands/diff-patch/patch-publication.d.ts +1 -13
  337. package/dist/safe-bash/commands/diff-patch/patch-publication.js +1 -107
  338. package/dist/safe-bash/commands/diff-patch/patch.d.ts +1 -2
  339. package/dist/safe-bash/commands/diff-patch/patch.js +1 -653
  340. package/dist/safe-bash/commands/diff-patch/shared.d.ts +1 -53
  341. package/dist/safe-bash/commands/diff-patch/shared.js +1 -267
  342. package/dist/safe-bash/commands/diff-patch/unified.d.ts +1 -52
  343. package/dist/safe-bash/commands/diff-patch/unified.js +1 -385
  344. package/dist/safe-bash/commands/directory-admission.d.ts +1 -3
  345. package/dist/safe-bash/commands/directory-admission.js +1 -26
  346. package/dist/safe-bash/commands/docx/index.browser.js +1 -1
  347. package/dist/safe-bash/commands/execution.js +19 -13
  348. package/dist/safe-bash/commands/factor/index.browser.js +2 -2
  349. package/dist/safe-bash/commands/filesystem.d.ts +1 -1
  350. package/dist/safe-bash/commands/filesystem.js +17 -13
  351. package/dist/safe-bash/commands/find/index.d.ts +2 -0
  352. package/dist/safe-bash/commands/find/index.js +2 -0
  353. package/dist/safe-bash/commands/find-format.d.ts +1 -20
  354. package/dist/safe-bash/commands/find-format.js +1 -161
  355. package/dist/safe-bash/commands/find.d.ts +2 -18
  356. package/dist/safe-bash/commands/find.js +2 -1236
  357. package/dist/safe-bash/commands/getopt/index.browser.js +2 -2
  358. package/dist/safe-bash/commands/gzip/index.d.ts +2 -0
  359. package/dist/safe-bash/commands/gzip/index.js +2 -0
  360. package/dist/safe-bash/commands/hexdump/index.browser.js +2 -2
  361. package/dist/safe-bash/commands/htmlq/index.d.ts +1 -1
  362. package/dist/safe-bash/commands/iconv/index.browser.js +2 -2
  363. package/dist/safe-bash/commands/line-endings/index.browser.js +2 -2
  364. package/dist/safe-bash/commands/line-endings/index.d.ts +1 -1
  365. package/dist/safe-bash/commands/line-endings/index.js +1 -262
  366. package/dist/safe-bash/commands/llm/index.browser.js +4 -2
  367. package/dist/safe-bash/commands/llm/providers/index.browser.js +1 -1
  368. package/dist/safe-bash/commands/mdq/index.browser.js +3 -3
  369. package/dist/safe-bash/commands/media/index.browser.js +1 -1
  370. package/dist/safe-bash/commands/metadata/chmod.d.ts +1 -4
  371. package/dist/safe-bash/commands/metadata/chmod.js +2 -63
  372. package/dist/safe-bash/commands/network/aggregate.d.ts +1 -4
  373. package/dist/safe-bash/commands/network/aggregate.js +1 -23
  374. package/dist/safe-bash/commands/network/args.d.ts +1 -68
  375. package/dist/safe-bash/commands/network/args.js +1 -321
  376. package/dist/safe-bash/commands/network/authorizer.d.ts +1 -6
  377. package/dist/safe-bash/commands/network/authorizer.js +1 -33
  378. package/dist/safe-bash/commands/network/body.d.ts +1 -9
  379. package/dist/safe-bash/commands/network/body.js +1 -393
  380. package/dist/safe-bash/commands/network/curl.d.ts +3 -13
  381. package/dist/safe-bash/commands/network/curl.js +6 -695
  382. package/dist/safe-bash/commands/network/deadline.d.ts +1 -2
  383. package/dist/safe-bash/commands/network/deadline.js +1 -14
  384. package/dist/safe-bash/commands/network/decode.d.ts +1 -2
  385. package/dist/safe-bash/commands/network/decode.js +1 -79
  386. package/dist/safe-bash/commands/network/fetch-transport.d.ts +1 -7
  387. package/dist/safe-bash/commands/network/fetch-transport.js +1 -94
  388. package/dist/safe-bash/commands/network/form-content-type.d.ts +1 -5
  389. package/dist/safe-bash/commands/network/form-content-type.js +1 -63
  390. package/dist/safe-bash/commands/network/form-headers.d.ts +1 -2
  391. package/dist/safe-bash/commands/network/form-headers.js +1 -35
  392. package/dist/safe-bash/commands/network/glob.d.ts +1 -7
  393. package/dist/safe-bash/commands/network/glob.js +1 -134
  394. package/dist/safe-bash/commands/network/index.browser.js +4 -12
  395. package/dist/safe-bash/commands/network/input.d.ts +1 -5
  396. package/dist/safe-bash/commands/network/input.js +1 -276
  397. package/dist/safe-bash/commands/network/output.d.ts +1 -6
  398. package/dist/safe-bash/commands/network/output.js +1 -131
  399. package/dist/safe-bash/commands/network/platform-portable.d.ts +1 -5
  400. package/dist/safe-bash/commands/network/platform-portable.js +1 -26
  401. package/dist/safe-bash/commands/network/private-address.d.ts +1 -1
  402. package/dist/safe-bash/commands/network/private-address.js +1 -44
  403. package/dist/safe-bash/commands/network/public.d.ts +2 -2
  404. package/dist/safe-bash/commands/network/public.js +2 -2
  405. package/dist/safe-bash/commands/network/shared.d.ts +1 -14
  406. package/dist/safe-bash/commands/network/shared.js +1 -71
  407. package/dist/safe-bash/commands/network/transport.js +2 -2
  408. package/dist/safe-bash/commands/network/types.d.ts +1 -37
  409. package/dist/safe-bash/commands/network/types.js +1 -31
  410. package/dist/safe-bash/commands/network/url.d.ts +1 -2
  411. package/dist/safe-bash/commands/network/url.js +1 -30
  412. package/dist/safe-bash/commands/network/wget.d.ts +3 -3
  413. package/dist/safe-bash/commands/network/wget.js +9 -332
  414. package/dist/safe-bash/commands/node/filesystem.js +3 -2
  415. package/dist/safe-bash/commands/node/index.browser.js +8 -9
  416. package/dist/safe-bash/commands/node/index.d.ts +3 -3
  417. package/dist/safe-bash/commands/node/index.js +5 -0
  418. package/dist/safe-bash/commands/node/safejs.d.ts +3 -3
  419. package/dist/safe-bash/commands/node/safejs.js +6 -1
  420. package/dist/safe-bash/commands/node/types.d.ts +1 -1
  421. package/dist/safe-bash/commands/node/types.js +1 -1
  422. package/dist/safe-bash/commands/node/unconfigured.d.ts +3 -0
  423. package/dist/safe-bash/commands/node/unconfigured.js +10 -0
  424. package/dist/safe-bash/commands/op/index.browser.js +3 -3
  425. package/dist/safe-bash/commands/patch/index.d.ts +2 -0
  426. package/dist/safe-bash/commands/patch/index.js +2 -0
  427. package/dist/safe-bash/commands/pdfinfo/index.js +2 -1
  428. package/dist/safe-bash/commands/pr/index.browser.js +2 -2
  429. package/dist/safe-bash/commands/predicates.js +3 -4
  430. package/dist/safe-bash/commands/python/host-capabilities.js +31 -14
  431. package/dist/safe-bash/commands/python/index.browser.js +11 -11
  432. package/dist/safe-bash/commands/python/llm-capability.d.ts +1 -0
  433. package/dist/safe-bash/commands/python/llm-capability.js +27 -7
  434. package/dist/safe-bash/commands/python/llm-module.js +11 -0
  435. package/dist/safe-bash/commands/python/manifest.d.ts +2 -0
  436. package/dist/safe-bash/commands/python/manifest.js +13 -6
  437. package/dist/safe-bash/commands/python/provisioning.js +1 -1
  438. package/dist/safe-bash/commands/python/shell-capability.d.ts +1 -0
  439. package/dist/safe-bash/commands/python/shell-capability.js +3 -2
  440. package/dist/safe-bash/commands/python/worker.browser.js +3 -3
  441. package/dist/safe-bash/commands/regex-execution/matching.js +1 -2
  442. package/dist/safe-bash/commands/regex-execution/public.browser.js +8 -8
  443. package/dist/safe-bash/commands/safejs/runtime.js +16 -7
  444. package/dist/safe-bash/commands/search/index.d.ts +1 -1
  445. package/dist/safe-bash/commands/search/index.js +1 -347
  446. package/dist/safe-bash/commands/search/portable.d.ts +2 -2
  447. package/dist/safe-bash/commands/search/portable.js +3 -2
  448. package/dist/safe-bash/commands/sed/index.d.ts +2 -0
  449. package/dist/safe-bash/commands/sed/index.js +2 -0
  450. package/dist/safe-bash/commands/standard.d.ts +1 -0
  451. package/dist/safe-bash/commands/standard.js +2 -1
  452. package/dist/safe-bash/commands/streams.js +6 -24
  453. package/dist/safe-bash/commands/tar/index.d.ts +2 -0
  454. package/dist/safe-bash/commands/tar/index.js +2 -0
  455. package/dist/safe-bash/commands/text-programs/awk-inspection.d.ts +1 -19
  456. package/dist/safe-bash/commands/text-programs/awk-inspection.js +1 -50
  457. package/dist/safe-bash/commands/text-programs/awk-pipes.d.ts +2 -0
  458. package/dist/safe-bash/commands/text-programs/awk-pipes.js +2 -0
  459. package/dist/safe-bash/commands/text-programs/awk-pretty.d.ts +1 -3
  460. package/dist/safe-bash/commands/text-programs/awk-pretty.js +1 -197
  461. package/dist/safe-bash/commands/text-programs/awk-quote.d.ts +1 -2
  462. package/dist/safe-bash/commands/text-programs/awk-quote.js +1 -15
  463. package/dist/safe-bash/commands/text-programs/awk-reader.d.ts +1 -42
  464. package/dist/safe-bash/commands/text-programs/awk-reader.js +1 -449
  465. package/dist/safe-bash/commands/text-programs/awk-retention.d.ts +1 -13
  466. package/dist/safe-bash/commands/text-programs/awk-retention.js +1 -51
  467. package/dist/safe-bash/commands/text-programs/awk-runtime.d.ts +1 -150
  468. package/dist/safe-bash/commands/text-programs/awk-runtime.js +1 -2627
  469. package/dist/safe-bash/commands/text-programs/awk-syntax.d.ts +1 -142
  470. package/dist/safe-bash/commands/text-programs/awk-syntax.js +1 -509
  471. package/dist/safe-bash/commands/text-programs/awk-values.d.ts +1 -32
  472. package/dist/safe-bash/commands/text-programs/awk-values.js +1 -386
  473. package/dist/safe-bash/commands/text-programs/awk.d.ts +1 -3
  474. package/dist/safe-bash/commands/text-programs/awk.js +1 -361
  475. package/dist/safe-bash/commands/text-programs/inplace.d.ts +1 -16
  476. package/dist/safe-bash/commands/text-programs/inplace.js +1 -155
  477. package/dist/safe-bash/commands/text-programs/sed.d.ts +1 -3
  478. package/dist/safe-bash/commands/text-programs/sed.js +1 -1647
  479. package/dist/safe-bash/commands/text.js +268 -364
  480. package/dist/safe-bash/commands/tsort/index.browser.js +2 -2
  481. package/dist/safe-bash/commands/unzip/index.d.ts +2 -0
  482. package/dist/safe-bash/commands/unzip/index.js +2 -0
  483. package/dist/safe-bash/commands/wget/index.d.ts +2 -0
  484. package/dist/safe-bash/commands/wget/index.js +2 -0
  485. package/dist/safe-bash/commands/xml/index.browser.js +2 -2
  486. package/dist/safe-bash/commands/yq/index.browser.js +8 -3
  487. package/dist/safe-bash/commands/yq/index.d.ts +1 -6
  488. package/dist/safe-bash/commands/yq/index.js +1 -36
  489. package/dist/safe-bash/commands/zip/index.d.ts +2 -0
  490. package/dist/safe-bash/commands/zip/index.js +2 -0
  491. package/dist/safe-bash/core.browser.js +2 -2
  492. package/dist/safe-bash/core.d.ts +14 -2
  493. package/dist/safe-bash/core.js +8 -2
  494. package/dist/safe-bash/fs/s3/index.d.ts +2 -2
  495. package/dist/safe-bash/fs/s3/index.js +1 -1
  496. package/dist/safe-bash/full-core.browser.js +321 -286
  497. package/dist/safe-bash/jobs.browser.js +5 -5
  498. package/dist/safe-bash/lazy-mmdc.d.ts +6 -0
  499. package/dist/safe-bash/lazy-mmdc.js +23 -0
  500. package/dist/safe-bash/opt-in/commands/dd/index.js +2 -0
  501. package/dist/safe-bash/opt-in/commands/yq/mike.js +6 -13
  502. package/dist/safe-bash/opt-in/commands/yq/native-work.d.ts +1 -0
  503. package/dist/safe-bash/opt-in/commands/yq/native-work.js +17 -0
  504. package/dist/safe-bash/opt-in/optional/commands/shuf/options.d.ts +1 -0
  505. package/dist/safe-bash/opt-in/optional/commands/shuf/options.js +2 -4
  506. package/dist/safe-bash/opt-in/optional/commands/shuf/shuf.js +2 -1
  507. package/dist/safe-bash/optional-host.browser.js +15 -11
  508. package/dist/safe-bash/optional-host.d.ts +1 -1
  509. package/dist/safe-bash/optional-host.js +1 -1
  510. package/dist/safe-bash/playwright/ability-execution.js +3 -2
  511. package/dist/safe-bash/playwright/adapter.js +1 -1
  512. package/dist/safe-bash/playwright/controller.js +9 -8
  513. package/dist/safe-bash/playwright/modal-capabilities.js +2 -1
  514. package/dist/safe-bash/playwright/native-json-snapshot.js +4 -3
  515. package/dist/safe-bash/playwright/native-snapshot.js +5 -4
  516. package/dist/safe-bash/playwright/open-options.js +3 -3
  517. package/dist/safe-bash/playwright/resource-limit.d.ts +2 -0
  518. package/dist/safe-bash/playwright/resource-limit.js +4 -0
  519. package/dist/safe-bash/playwright/session-configuration.js +8 -3
  520. package/dist/safe-bash/playwright/snapshot.js +8 -7
  521. package/dist/safe-bash/playwright/standard-capabilities.js +5 -4
  522. package/dist/safe-bash/plugins/composition.d.ts +1 -0
  523. package/dist/safe-bash/plugins/composition.js +3 -8
  524. package/dist/safe-bash/plugins/index.browser.js +27 -29
  525. package/dist/safe-bash/registry-entry.browser.js +28 -30
  526. package/dist/safe-bash/shell/arrays/bindings.d.ts +3 -5
  527. package/dist/safe-bash/shell/arrays/bindings.js +7 -3
  528. package/dist/safe-bash/shell/arrays/state.js +4 -0
  529. package/dist/safe-bash/shell/brace-expansion.js +1 -1
  530. package/dist/safe-bash/shell/dynamic-variables.d.ts +10 -0
  531. package/dist/safe-bash/shell/dynamic-variables.js +25 -0
  532. package/dist/safe-bash/shell/input.js +16 -14
  533. package/dist/safe-bash/shell/parser.js +8 -1
  534. package/dist/safe-bash/shell/runtime.d.ts +7 -4
  535. package/dist/safe-bash/shell/runtime.js +604 -802
  536. package/dist/safe-bash/shell/shell.js +2 -31
  537. package/dist/safe-bash/shell/types.d.ts +2 -0
  538. package/dist/safe-bash/shell/value-state.js +17 -2
  539. package/dist/safe-bash/shell/worker-limits.js +1 -0
  540. package/dist/safe-bash/shell-entry.browser.js +25 -27
  541. package/dist/safe-bash/trap.browser.d.ts +3 -0
  542. package/dist/safe-bash/trap.browser.js +14 -0
  543. package/dist/safe-bash/worker/host.js +1 -1
  544. package/dist/safe-bash/yq-browser/index.js +1 -1
  545. package/dist/safe-bash-base-encoding-engine/base.js +2 -2
  546. package/dist/safe-bash-base-encoding-engine/shared.js +1 -1
  547. package/dist/safe-bash-byte-input-engine/index.d.ts +3 -2
  548. package/dist/safe-bash-byte-input-engine/index.js +4 -1
  549. package/dist/safe-bash-checksum-engine/index.js +13 -6
  550. package/dist/safe-bash-command-apply-patch/apply.d.ts +1 -1
  551. package/dist/safe-bash-command-apply-patch/apply.js +4 -3
  552. package/dist/safe-bash-command-apply-patch/index.js +4 -4
  553. package/dist/safe-bash-command-apply-patch/matcher.js +1 -1
  554. package/dist/safe-bash-command-apply-patch/parser.js +1 -1
  555. package/dist/safe-bash-command-awk/LICENSE +21 -0
  556. package/dist/safe-bash-command-awk/awk-inspection.d.ts +19 -0
  557. package/dist/safe-bash-command-awk/awk-inspection.js +9 -0
  558. package/dist/safe-bash-command-awk/awk-pipes.d.ts +19 -0
  559. package/dist/safe-bash-command-awk/awk-pipes.js +8 -0
  560. package/dist/safe-bash-command-awk/awk-pretty.d.ts +3 -0
  561. package/dist/safe-bash-command-awk/awk-pretty.js +8 -0
  562. package/dist/safe-bash-command-awk/awk-quote.d.ts +2 -0
  563. package/dist/safe-bash-command-awk/awk-quote.js +7 -0
  564. package/dist/safe-bash-command-awk/awk-reader.d.ts +42 -0
  565. package/dist/safe-bash-command-awk/awk-reader.js +9 -0
  566. package/dist/safe-bash-command-awk/awk-retention.d.ts +13 -0
  567. package/dist/safe-bash-command-awk/awk-retention.js +7 -0
  568. package/dist/safe-bash-command-awk/awk-runtime.d.ts +151 -0
  569. package/dist/safe-bash-command-awk/awk-runtime.js +11 -0
  570. package/dist/safe-bash-command-awk/awk-syntax.d.ts +144 -0
  571. package/dist/safe-bash-command-awk/awk-syntax.js +14 -0
  572. package/dist/safe-bash-command-awk/awk-values.d.ts +32 -0
  573. package/dist/safe-bash-command-awk/awk-values.js +35 -0
  574. package/dist/safe-bash-command-awk/awk.d.ts +3 -0
  575. package/dist/safe-bash-command-awk/awk.js +16 -0
  576. package/dist/safe-bash-command-awk/index.d.ts +7 -0
  577. package/dist/safe-bash-command-awk/index.js +36 -0
  578. package/dist/safe-bash-command-bc/index.d.ts +6 -0
  579. package/dist/safe-bash-command-bc/index.js +136 -266
  580. package/dist/safe-bash-command-column/column.js +5 -5
  581. package/dist/safe-bash-command-column/display.d.ts +1 -1
  582. package/dist/safe-bash-command-column/display.js +1 -1
  583. package/dist/safe-bash-command-column/index.js +5 -5
  584. package/dist/safe-bash-command-column/internal.d.ts +0 -2
  585. package/dist/safe-bash-command-column/internal.js +1 -1
  586. package/dist/safe-bash-command-column/layout.js +4 -4
  587. package/dist/safe-bash-command-column/table.js +2 -2
  588. package/dist/safe-bash-command-comm/comm.js +1 -1
  589. package/dist/safe-bash-command-comm/index.js +1 -1
  590. package/dist/safe-bash-command-csplit/command.js +2 -2
  591. package/dist/safe-bash-command-csplit/index.js +2 -2
  592. package/dist/safe-bash-command-csvcut/index.d.ts +1 -0
  593. package/dist/safe-bash-command-csvcut/index.js +1 -0
  594. package/dist/safe-bash-command-csvgrep/index.d.ts +1 -0
  595. package/dist/safe-bash-command-csvgrep/index.js +2 -2
  596. package/dist/safe-bash-command-csvkit/contracts.d.ts +1 -0
  597. package/dist/safe-bash-command-csvkit/csvpy-interpreter.d.ts +2 -1
  598. package/dist/safe-bash-command-csvkit/default-csvpy.d.ts +11 -0
  599. package/dist/safe-bash-command-csvkit/errors.js +22 -0
  600. package/dist/safe-bash-command-csvkit/index.d.ts +1 -0
  601. package/dist/safe-bash-command-csvkit/index.js +180 -12
  602. package/dist/safe-bash-command-csvkit/python-worker-browser.d.ts +3 -0
  603. package/dist/safe-bash-command-csvkit/python-worker-browser.js +16 -0
  604. package/dist/safe-bash-command-csvkit/python-worker-contract.d.ts +20 -0
  605. package/dist/safe-bash-command-csvkit/python-worker-node.d.ts +3 -0
  606. package/dist/safe-bash-command-csvkit/python-worker-node.js +9 -0
  607. package/dist/safe-bash-command-csvkit/runtime.d.ts +1 -0
  608. package/dist/safe-bash-command-csvkit/sync-support.js +1 -1
  609. package/dist/safe-bash-command-curl/LICENSE +21 -0
  610. package/dist/safe-bash-command-curl/curl.d.ts +13 -0
  611. package/dist/safe-bash-command-curl/curl.js +9 -0
  612. package/dist/safe-bash-command-curl/index.d.ts +6 -0
  613. package/dist/safe-bash-command-curl/index.js +26 -0
  614. package/dist/safe-bash-command-dd/index.js +2 -0
  615. package/dist/safe-bash-command-diff/LICENSE +21 -0
  616. package/dist/safe-bash-command-diff/diff-format.d.ts +10 -0
  617. package/dist/safe-bash-command-diff/diff-format.js +10 -0
  618. package/dist/safe-bash-command-diff/diff-options.d.ts +38 -0
  619. package/dist/safe-bash-command-diff/diff-options.js +7 -0
  620. package/dist/safe-bash-command-diff/diff-output.d.ts +20 -0
  621. package/dist/safe-bash-command-diff/diff-output.js +19 -0
  622. package/dist/safe-bash-command-diff/diff.d.ts +2 -0
  623. package/dist/safe-bash-command-diff/diff.js +10 -0
  624. package/dist/safe-bash-command-diff/index.d.ts +8 -0
  625. package/dist/safe-bash-command-diff/index.js +34 -0
  626. package/dist/safe-bash-command-diff/sync.d.ts +2 -0
  627. package/dist/safe-bash-command-diff/sync.js +9 -0
  628. package/dist/safe-bash-command-diff3/index.js +5 -5
  629. package/dist/safe-bash-command-docx/index.d.ts +4 -4
  630. package/dist/safe-bash-command-docx/index.js +12 -5
  631. package/dist/safe-bash-command-dos2unix/index.d.ts +1 -0
  632. package/dist/safe-bash-command-dos2unix/index.js +225 -1
  633. package/dist/safe-bash-command-dos2unix/sync.d.ts +1 -0
  634. package/dist/safe-bash-command-exiftool/index.d.ts +1 -0
  635. package/dist/safe-bash-command-exiftool/index.js +2 -2
  636. package/dist/safe-bash-command-factor/command.js +2 -2
  637. package/dist/safe-bash-command-factor/index.js +2 -2
  638. package/dist/safe-bash-command-fd/index.js +9 -9
  639. package/dist/safe-bash-command-ffmpeg/index.js +117 -102
  640. package/dist/safe-bash-command-file/index.js +4 -4
  641. package/dist/safe-bash-command-file/shared.js +1 -1
  642. package/dist/safe-bash-command-find/LICENSE +21 -0
  643. package/dist/safe-bash-command-find/find-format.d.ts +20 -0
  644. package/dist/safe-bash-command-find/find-format.js +9 -0
  645. package/dist/safe-bash-command-find/find.d.ts +18 -0
  646. package/dist/safe-bash-command-find/find.js +10 -0
  647. package/dist/safe-bash-command-find/index.d.ts +13 -0
  648. package/dist/safe-bash-command-find/index.js +45 -0
  649. package/dist/safe-bash-command-fmt/index.js +7 -4
  650. package/dist/safe-bash-command-git/git_rust.wasm +0 -0
  651. package/dist/safe-bash-command-git/index.js +5 -7
  652. package/dist/safe-bash-command-git/wasm.generated.js +1 -1
  653. package/dist/safe-bash-command-gzip/LICENSE +21 -0
  654. package/dist/safe-bash-command-gzip/index.d.ts +11 -0
  655. package/dist/safe-bash-command-gzip/index.js +95 -0
  656. package/dist/safe-bash-command-hexdump/command.js +4 -4
  657. package/dist/safe-bash-command-hexdump/custom.d.ts +24 -0
  658. package/dist/safe-bash-command-hexdump/index.js +4 -4
  659. package/dist/safe-bash-command-hexdump/internal.d.ts +2 -0
  660. package/dist/safe-bash-command-hexdump/internal.js +1 -1
  661. package/dist/safe-bash-command-hexdump/io.js +2 -2
  662. package/dist/safe-bash-command-hexdump/options.d.ts +3 -0
  663. package/dist/safe-bash-command-hexdump/options.js +2 -2
  664. package/dist/safe-bash-command-hostname/index.js +1 -1
  665. package/dist/safe-bash-command-html-to-markdown/budget.js +1 -1
  666. package/dist/safe-bash-command-html-to-markdown/entities.js +3 -3
  667. package/dist/safe-bash-command-html-to-markdown/index.js +11 -11
  668. package/dist/safe-bash-command-html-to-markdown/input.js +5 -5
  669. package/dist/safe-bash-command-html-to-markdown/parser.d.ts +1 -0
  670. package/dist/safe-bash-command-html-to-markdown/parser.js +4 -4
  671. package/dist/safe-bash-command-html-to-markdown/render.js +5 -5
  672. package/dist/safe-bash-command-html-to-markdown/text.js +2 -2
  673. package/dist/safe-bash-command-htmlq/index.d.ts +1 -0
  674. package/dist/safe-bash-command-htmlq/index.js +39 -17
  675. package/dist/safe-bash-command-iconv/codec.js +1 -1
  676. package/dist/safe-bash-command-iconv/command.js +2 -2
  677. package/dist/safe-bash-command-iconv/index.js +2 -2
  678. package/dist/safe-bash-command-imagemagick/index.js +45 -35
  679. package/dist/safe-bash-command-join/index.js +1 -1
  680. package/dist/safe-bash-command-join/join.js +1 -1
  681. package/dist/safe-bash-command-jq/index.js +1 -1
  682. package/dist/safe-bash-command-jq/jq.js +1 -1
  683. package/dist/safe-bash-command-less/index.js +43 -28
  684. package/dist/safe-bash-command-llm/command.js +1 -1
  685. package/dist/safe-bash-command-llm/index.d.ts +1 -0
  686. package/dist/safe-bash-command-llm/index.js +16 -14
  687. package/dist/safe-bash-command-llm/openai.js +3 -3
  688. package/dist/safe-bash-command-llm/providers/index.js +3 -3
  689. package/dist/safe-bash-command-llm/providers/openai.js +3 -3
  690. package/dist/safe-bash-command-llm/stored-schema.d.ts +10 -0
  691. package/dist/safe-bash-command-mmdc/index.d.ts +1 -0
  692. package/dist/safe-bash-command-mmdc/index.js +13 -604
  693. package/dist/safe-bash-command-mmdc/settings.d.ts +2 -0
  694. package/dist/safe-bash-command-mmdc/settings.js +7 -0
  695. package/dist/safe-bash-command-numfmt/index.js +0 -11
  696. package/dist/safe-bash-command-od/index.js +101 -68
  697. package/dist/safe-bash-command-pandoc/command.js +4 -3
  698. package/dist/safe-bash-command-pandoc/defaults.d.ts +1 -0
  699. package/dist/safe-bash-command-pandoc/index.js +4 -3
  700. package/dist/safe-bash-command-pandoc/lua-filters.js +1 -1
  701. package/dist/safe-bash-command-pandoc/types.d.ts +3 -1
  702. package/dist/safe-bash-command-paste/index.js +1 -1
  703. package/dist/safe-bash-command-paste/paste.js +1 -1
  704. package/dist/safe-bash-command-patch/LICENSE +21 -0
  705. package/dist/safe-bash-command-patch/index.d.ts +8 -0
  706. package/dist/safe-bash-command-patch/index.js +38 -0
  707. package/dist/safe-bash-command-patch/patch-envelope.d.ts +2 -0
  708. package/dist/safe-bash-command-patch/patch-envelope.js +7 -0
  709. package/dist/safe-bash-command-patch/patch-formats.d.ts +7 -0
  710. package/dist/safe-bash-command-patch/patch-formats.js +9 -0
  711. package/dist/safe-bash-command-patch/patch-gnu-paths.d.ts +41 -0
  712. package/dist/safe-bash-command-patch/patch-gnu-paths.js +26 -0
  713. package/dist/safe-bash-command-patch/patch-gnu-reject.d.ts +3 -0
  714. package/dist/safe-bash-command-patch/patch-gnu-reject.js +7 -0
  715. package/dist/safe-bash-command-patch/patch-path.d.ts +3 -0
  716. package/dist/safe-bash-command-patch/patch-path.js +11 -0
  717. package/dist/safe-bash-command-patch/patch-publication.d.ts +13 -0
  718. package/dist/safe-bash-command-patch/patch-publication.js +7 -0
  719. package/dist/safe-bash-command-patch/patch.d.ts +2 -0
  720. package/dist/safe-bash-command-patch/patch.js +14 -0
  721. package/dist/safe-bash-command-patch/sync.d.ts +2 -0
  722. package/dist/safe-bash-command-patch/sync.js +7 -0
  723. package/dist/safe-bash-command-patch/unified.d.ts +52 -0
  724. package/dist/safe-bash-command-patch/unified.js +16 -0
  725. package/dist/safe-bash-command-pathchk/index.js +3 -13
  726. package/dist/safe-bash-command-pdfimages/index.js +62 -25
  727. package/dist/safe-bash-command-pdfinfo/index.d.ts +0 -23
  728. package/dist/safe-bash-command-pdfinfo/index.js +39 -782
  729. package/dist/safe-bash-command-pdftk/index.js +40 -12
  730. package/dist/safe-bash-command-pdftoppm/index.js +76 -30
  731. package/dist/safe-bash-command-pdftotext/index.js +37 -15
  732. package/dist/safe-bash-command-pptx/index.d.ts +4 -4
  733. package/dist/safe-bash-command-pptx/index.js +11 -5
  734. package/dist/safe-bash-command-pr/command.js +2 -2
  735. package/dist/safe-bash-command-pr/index.js +4 -4
  736. package/dist/safe-bash-command-qpdf/index.js +31 -18
  737. package/dist/safe-bash-command-rg/index.d.ts +1 -0
  738. package/dist/safe-bash-command-rg/index.js +222 -1
  739. package/dist/safe-bash-command-rg/rg-command.js +1 -1
  740. package/dist/safe-bash-command-rg/sync.d.ts +1 -0
  741. package/dist/safe-bash-command-sed/LICENSE +21 -0
  742. package/dist/safe-bash-command-sed/index.d.ts +7 -0
  743. package/dist/safe-bash-command-sed/index.js +28 -0
  744. package/dist/safe-bash-command-sed/inplace.d.ts +16 -0
  745. package/dist/safe-bash-command-sed/inplace.js +9 -0
  746. package/dist/safe-bash-command-sed/sed.d.ts +3 -0
  747. package/dist/safe-bash-command-sed/sed.js +8 -0
  748. package/dist/safe-bash-command-shuf/options.d.ts +1 -0
  749. package/dist/safe-bash-command-shuf/options.js +2 -4
  750. package/dist/safe-bash-command-shuf/shuf.js +2 -1
  751. package/dist/safe-bash-command-sips/index.js +111 -35
  752. package/dist/safe-bash-command-soffice/index.js +21 -17
  753. package/dist/safe-bash-command-split/index.js +3 -3
  754. package/dist/safe-bash-command-split/io.js +1 -1
  755. package/dist/safe-bash-command-split/outputs.js +2 -2
  756. package/dist/safe-bash-command-split/split.js +3 -3
  757. package/dist/safe-bash-command-sqlite3/btree.d.ts +1 -0
  758. package/dist/safe-bash-command-sqlite3/engine.d.ts +7 -2
  759. package/dist/safe-bash-command-sqlite3/index.js +436 -537
  760. package/dist/safe-bash-command-ssconvert/commands.js +9 -9
  761. package/dist/safe-bash-command-ssconvert/core.js +8 -8
  762. package/dist/safe-bash-command-ssconvert/formats/csv.js +9 -9
  763. package/dist/safe-bash-command-ssconvert/formats/ods.js +9 -9
  764. package/dist/safe-bash-command-ssconvert/formats/spreadsheetml.js +2 -2
  765. package/dist/safe-bash-command-ssconvert/formats/xls.js +9 -9
  766. package/dist/safe-bash-command-ssconvert/formats/xlsx.js +9 -9
  767. package/dist/safe-bash-command-ssconvert/index.js +21 -21
  768. package/dist/safe-bash-command-tar/LICENSE +21 -0
  769. package/dist/safe-bash-command-tar/create.d.ts +17 -0
  770. package/dist/safe-bash-command-tar/create.js +14 -0
  771. package/dist/safe-bash-command-tar/extract.d.ts +11 -0
  772. package/dist/safe-bash-command-tar/extract.js +14 -0
  773. package/dist/safe-bash-command-tar/format.d.ts +32 -0
  774. package/dist/safe-bash-command-tar/format.js +19 -0
  775. package/dist/safe-bash-command-tar/index.d.ts +8 -0
  776. package/dist/safe-bash-command-tar/index.js +551 -0
  777. package/dist/safe-bash-command-tar/listing.d.ts +2 -0
  778. package/dist/safe-bash-command-tar/listing.js +7 -0
  779. package/dist/safe-bash-command-tar/modes.d.ts +5 -0
  780. package/dist/safe-bash-command-tar/modes.js +16 -0
  781. package/dist/safe-bash-command-tar/options.d.ts +53 -0
  782. package/dist/safe-bash-command-tar/options.js +10 -0
  783. package/dist/safe-bash-command-tar/stream.d.ts +22 -0
  784. package/dist/safe-bash-command-tar/stream.js +15 -0
  785. package/dist/safe-bash-command-tar/transform.d.ts +16 -0
  786. package/dist/safe-bash-command-tar/transform.js +9 -0
  787. package/dist/safe-bash-command-tree/arguments.js +3 -3
  788. package/dist/safe-bash-command-tree/charset.js +1 -1
  789. package/dist/safe-bash-command-tree/index.js +4 -4
  790. package/dist/safe-bash-command-tree/io.js +1 -1
  791. package/dist/safe-bash-command-tree/pattern.js +2 -2
  792. package/dist/safe-bash-command-tree/tree.js +4 -4
  793. package/dist/safe-bash-command-unrtf/index.js +14 -7
  794. package/dist/safe-bash-command-unzip/LICENSE +21 -0
  795. package/dist/safe-bash-command-unzip/index.d.ts +7 -0
  796. package/dist/safe-bash-command-unzip/index.js +39 -0
  797. package/dist/safe-bash-command-unzip/sync.d.ts +3 -0
  798. package/dist/safe-bash-command-unzip/sync.js +9 -0
  799. package/dist/safe-bash-command-unzip/unzip/safety.d.ts +32 -0
  800. package/dist/safe-bash-command-unzip/unzip/safety.js +7 -0
  801. package/dist/safe-bash-command-unzip/unzip.d.ts +3 -0
  802. package/dist/safe-bash-command-unzip/unzip.js +8 -0
  803. package/dist/safe-bash-command-wget/LICENSE +21 -0
  804. package/dist/safe-bash-command-wget/index.d.ts +6 -0
  805. package/dist/safe-bash-command-wget/index.js +26 -0
  806. package/dist/safe-bash-command-wget/wget.d.ts +3 -0
  807. package/dist/safe-bash-command-wget/wget.js +7 -0
  808. package/dist/safe-bash-command-xan/argv.d.ts +4 -1
  809. package/dist/safe-bash-command-xan/argv.js +1 -1
  810. package/dist/safe-bash-command-xan/commands.js +6 -3
  811. package/dist/safe-bash-command-xan/csv.d.ts +1 -1
  812. package/dist/safe-bash-command-xan/csv.js +1 -1
  813. package/dist/safe-bash-command-xan/index.js +18 -17
  814. package/dist/safe-bash-command-xan/io.js +3 -3
  815. package/dist/safe-bash-command-xmllint/index.js +190 -50
  816. package/dist/safe-bash-command-xxd/index.js +105 -91
  817. package/dist/safe-bash-command-xz/command.d.ts +2 -0
  818. package/dist/safe-bash-command-xz/index.d.ts +1 -1
  819. package/dist/safe-bash-command-xz/index.js +11 -2
  820. package/dist/safe-bash-command-xz/options.d.ts +9 -1
  821. package/dist/safe-bash-command-xz/options.js +3 -1
  822. package/dist/safe-bash-command-yq/index.d.ts +4 -11
  823. package/dist/safe-bash-command-yq/index.js +3367 -670
  824. package/dist/safe-bash-command-yq/mike.js +6 -13
  825. package/dist/safe-bash-command-yq/native-work.d.ts +1 -0
  826. package/dist/safe-bash-command-yq/native-work.js +17 -0
  827. package/dist/safe-bash-command-yq/query.d.ts +11 -0
  828. package/dist/safe-bash-command-yq/query.js +735 -0
  829. package/dist/safe-bash-command-zip/LICENSE +21 -0
  830. package/dist/safe-bash-command-zip/index.d.ts +7 -0
  831. package/dist/safe-bash-command-zip/index.js +38 -0
  832. package/dist/safe-bash-command-zip/sync.d.ts +3 -0
  833. package/dist/safe-bash-command-zip/sync.js +9 -0
  834. package/dist/safe-bash-command-zip/zip.d.ts +3 -0
  835. package/dist/safe-bash-command-zip/zip.js +7 -0
  836. package/dist/safe-bash-compression-engine/files.js +4 -4
  837. package/dist/safe-bash-compression-engine/index.js +2 -2
  838. package/dist/safe-bash-compression-engine/operand.js +6 -6
  839. package/dist/safe-bash-compression-engine/stream.js +2 -2
  840. package/dist/safe-bash-compression-engine/zstd-decode.js +1 -1
  841. package/dist/safe-bash-contracts/command.js +1 -1
  842. package/dist/safe-bash-contracts/diagnostics.js +4 -4
  843. package/dist/safe-bash-contracts/escaping.js +12 -12
  844. package/dist/safe-bash-contracts/filesystem-descriptor.js +1 -1
  845. package/dist/safe-bash-contracts/filesystem-output.js +8 -8
  846. package/dist/safe-bash-contracts/index.d.ts +1 -0
  847. package/dist/safe-bash-contracts/index.js +39 -35
  848. package/dist/safe-bash-contracts/io.d.ts +4 -1
  849. package/dist/safe-bash-contracts/io.js +4 -2
  850. package/dist/safe-bash-contracts/managed-abort.d.ts +10 -0
  851. package/dist/safe-bash-contracts/output.js +3 -3
  852. package/dist/safe-bash-diff-engine/LICENSE +21 -0
  853. package/dist/safe-bash-diff-engine/index.d.ts +1 -0
  854. package/dist/safe-bash-diff-engine/index.js +24 -0
  855. package/dist/safe-bash-diff-engine/shared.d.ts +54 -0
  856. package/dist/safe-bash-diff-engine/shared.js +19 -0
  857. package/dist/safe-bash-io-engine/commands/archive/internal.js +5 -23
  858. package/dist/safe-bash-io-engine/commands/directory-admission.d.ts +3 -0
  859. package/dist/safe-bash-io-engine/commands/directory-admission.js +34 -0
  860. package/dist/safe-bash-io-engine/commands/mode-change.d.ts +4 -0
  861. package/dist/safe-bash-io-engine/commands/mode-change.js +60 -0
  862. package/dist/safe-bash-io-engine/commands/search/requirements.js +2 -2
  863. package/dist/safe-bash-io-engine/commands/text-programs/shared.js +44 -66
  864. package/dist/safe-bash-io-engine/internal.js +1 -1
  865. package/dist/safe-bash-io-engine/shell/pattern.js +8 -13
  866. package/dist/safe-bash-io-engine/shell/string-operations.js +1 -1
  867. package/dist/safe-bash-markdown-engine/commonmark-blocks.js +4 -4
  868. package/dist/safe-bash-markdown-engine/commonmark-inlines.js +4 -4
  869. package/dist/safe-bash-markdown-engine/commonmark-syntax.js +2 -2
  870. package/dist/safe-bash-markdown-engine/gfm-syntax.js +3 -3
  871. package/dist/safe-bash-markdown-engine/index.js +7 -7
  872. package/dist/safe-bash-mcp/index.browser.d.ts +161 -35
  873. package/dist/safe-bash-mcp/index.browser.js +417 -0
  874. package/dist/safe-bash-mcp/index.d.ts +66 -2
  875. package/dist/safe-bash-mcp/index.js +1838 -122
  876. package/dist/safe-bash-network-engine/LICENSE +21 -0
  877. package/dist/safe-bash-network-engine/aggregate.d.ts +4 -0
  878. package/dist/safe-bash-network-engine/aggregate.js +37 -0
  879. package/dist/safe-bash-network-engine/args.d.ts +68 -0
  880. package/dist/safe-bash-network-engine/args.js +19 -0
  881. package/dist/safe-bash-network-engine/authorizer.d.ts +6 -0
  882. package/dist/safe-bash-network-engine/authorizer.js +8 -0
  883. package/dist/safe-bash-network-engine/body.d.ts +9 -0
  884. package/dist/safe-bash-network-engine/body.js +374 -0
  885. package/dist/safe-bash-network-engine/deadline.d.ts +2 -0
  886. package/dist/safe-bash-network-engine/deadline.js +7 -0
  887. package/dist/safe-bash-network-engine/decode.d.ts +2 -0
  888. package/dist/safe-bash-network-engine/decode.js +80 -0
  889. package/dist/safe-bash-network-engine/fetch-transport.d.ts +7 -0
  890. package/dist/safe-bash-network-engine/fetch-transport.js +9 -0
  891. package/dist/safe-bash-network-engine/form-content-type.d.ts +5 -0
  892. package/dist/safe-bash-network-engine/form-content-type.js +8 -0
  893. package/dist/safe-bash-network-engine/form-headers.d.ts +2 -0
  894. package/dist/safe-bash-network-engine/form-headers.js +10 -0
  895. package/dist/safe-bash-network-engine/glob.d.ts +7 -0
  896. package/dist/safe-bash-network-engine/glob.js +124 -0
  897. package/dist/safe-bash-network-engine/index.d.ts +3 -0
  898. package/dist/safe-bash-network-engine/index.js +26 -0
  899. package/dist/safe-bash-network-engine/input.d.ts +5 -0
  900. package/dist/safe-bash-network-engine/input.js +255 -0
  901. package/dist/safe-bash-network-engine/output.d.ts +6 -0
  902. package/dist/safe-bash-network-engine/output.js +132 -0
  903. package/dist/safe-bash-network-engine/platform-portable.d.ts +5 -0
  904. package/dist/safe-bash-network-engine/platform-portable.js +19 -0
  905. package/dist/safe-bash-network-engine/private-address.d.ts +1 -0
  906. package/dist/safe-bash-network-engine/private-address.js +7 -0
  907. package/dist/safe-bash-network-engine/shared.d.ts +14 -0
  908. package/dist/safe-bash-network-engine/shared.js +23 -0
  909. package/dist/safe-bash-network-engine/types.d.ts +42 -0
  910. package/dist/safe-bash-network-engine/types.js +11 -0
  911. package/dist/safe-bash-network-engine/url.d.ts +2 -0
  912. package/dist/safe-bash-network-engine/url.js +8 -0
  913. package/dist/safe-bash-query-engine/capture.d.ts +1 -0
  914. package/dist/safe-bash-query-engine/capture.js +9 -7
  915. package/dist/safe-bash-query-engine/dates.d.ts +5 -1
  916. package/dist/safe-bash-query-engine/dates.js +10 -2
  917. package/dist/safe-bash-query-engine/delpaths.js +5 -5
  918. package/dist/safe-bash-query-engine/formats.js +3 -3
  919. package/dist/safe-bash-query-engine/index.js +15 -15
  920. package/dist/safe-bash-query-engine/indices.js +5 -5
  921. package/dist/safe-bash-query-engine/input.d.ts +1 -2
  922. package/dist/safe-bash-query-engine/input.js +2 -4
  923. package/dist/safe-bash-query-engine/interpreter.d.ts +5 -0
  924. package/dist/safe-bash-query-engine/interpreter.js +13 -13
  925. package/dist/safe-bash-query-engine/limits.js +1 -1
  926. package/dist/safe-bash-query-engine/parser.d.ts +8 -1
  927. package/dist/safe-bash-query-engine/parser.js +2 -2
  928. package/dist/safe-bash-query-engine/query-core.js +15 -15
  929. package/dist/safe-bash-query-engine/recurse.js +2 -2
  930. package/dist/safe-bash-query-engine/regex.d.ts +4 -2
  931. package/dist/safe-bash-query-engine/regex.js +10 -5
  932. package/dist/safe-bash-query-engine/split.js +2 -2
  933. package/dist/safe-bash-query-engine/splits.d.ts +1 -1
  934. package/dist/safe-bash-query-engine/splits.js +7 -6
  935. package/dist/safe-bash-query-engine/values.js +4 -4
  936. package/dist/safe-bash-regex-engine/ere/matcher.js +106 -34
  937. package/dist/safe-bash-regex-engine/execution/bounded-provider.js +55 -67
  938. package/dist/safe-bash-regex-engine/execution/portable.d.ts +0 -1
  939. package/dist/safe-bash-regex-engine/execution/portable.js +6 -10
  940. package/dist/safe-bash-regex-engine/execution/protocol.d.ts +0 -5
  941. package/dist/safe-bash-regex-engine/execution/protocol.js +1 -3
  942. package/dist/safe-bash-regex-engine/index.js +6 -4
  943. package/dist/safe-bash-regex-engine/text/budget.d.ts +1 -0
  944. package/dist/safe-bash-regex-engine/text/budget.js +1 -1
  945. package/dist/safe-bash-regex-engine/text/regex.d.ts +15 -0
  946. package/dist/safe-bash-regex-engine/text/regex.js +6 -4
  947. package/dist/safe-bash-regex-engine/text/replacement-buffer.js +2 -2
  948. package/dist/safe-bash-regex-engine/text/rust-syntax.js +2 -2
  949. package/dist/safe-bash-search-engine/ergonomic-regex.d.ts +12 -2
  950. package/dist/safe-bash-search-engine/ergonomic-regex.js +2 -2
  951. package/dist/safe-bash-search-engine/glob.js +2 -2
  952. package/dist/safe-bash-search-engine/grep.js +191 -229
  953. package/dist/safe-bash-search-engine/matcher.d.ts +6 -2
  954. package/dist/safe-bash-search-engine/matcher.js +30 -8
  955. package/dist/safe-bash-search-engine/options.js +1 -1
  956. package/dist/safe-bash-search-engine/output.d.ts +3 -2
  957. package/dist/safe-bash-search-engine/output.js +111 -30
  958. package/dist/safe-bash-search-engine/shared.d.ts +2 -0
  959. package/dist/safe-bash-search-engine/shared.js +2 -2
  960. package/dist/safe-bash-search-engine/walk.js +11 -10
  961. package/dist/safe-bash-table-text-engine/table-text/internal.d.ts +7 -5
  962. package/dist/safe-bash-table-text-engine/table-text/internal.js +39 -21
  963. package/dist/safe-bash-xml-engine/document.d.ts +1 -1
  964. package/dist/safe-bash-xml-engine/document.js +3 -3
  965. package/dist/safe-bash-xml-engine/evaluate.d.ts +1 -0
  966. package/dist/safe-bash-xml-engine/evaluate.js +4 -1
  967. package/dist/safe-bash-xml-engine/index.js +8 -6
  968. package/dist/safe-bash-xml-engine/io.js +1 -1
  969. package/dist/safe-bash-xml-engine/limits.d.ts +2 -0
  970. package/dist/safe-bash-xml-engine/limits.js +1 -1
  971. package/dist/safe-bash-xml-engine/predicate.d.ts +57 -0
  972. package/dist/safe-bash-xml-engine/query.d.ts +3 -15
  973. package/dist/safe-bash-xml-engine/query.js +3 -2
  974. package/dist/safe-bash-zip-engine/LICENSE +21 -0
  975. package/dist/safe-bash-zip-engine/index.d.ts +1 -0
  976. package/dist/safe-bash-zip-engine/index.js +32 -0
  977. package/dist/safe-bash-zip-engine/unzip/arguments.d.ts +53 -0
  978. package/dist/safe-bash-zip-engine/unzip/arguments.js +270 -0
  979. package/dist/safe-bash-zip-engine/zip/aes.d.ts +17 -0
  980. package/dist/safe-bash-zip-engine/zip/aes.js +15 -0
  981. package/dist/safe-bash-zip-engine/zip/comments.d.ts +17 -0
  982. package/dist/safe-bash-zip-engine/zip/comments.js +77 -0
  983. package/dist/safe-bash-zip-engine/zip/crc.d.ts +1 -0
  984. package/dist/safe-bash-zip-engine/zip/crc.js +7 -0
  985. package/dist/safe-bash-zip-engine/zip/crypto.d.ts +19 -0
  986. package/dist/safe-bash-zip-engine/zip/crypto.js +16 -0
  987. package/dist/safe-bash-zip-engine/zip/dates.d.ts +4 -0
  988. package/dist/safe-bash-zip-engine/zip/dates.js +68 -0
  989. package/dist/safe-bash-zip-engine/zip/environment.d.ts +2 -0
  990. package/dist/safe-bash-zip-engine/zip/environment.js +60 -0
  991. package/dist/safe-bash-zip-engine/zip/grow.d.ts +3 -0
  992. package/dist/safe-bash-zip-engine/zip/grow.js +7 -0
  993. package/dist/safe-bash-zip-engine/zip/help.d.ts +4 -0
  994. package/dist/safe-bash-zip-engine/zip/help.js +194 -0
  995. package/dist/safe-bash-zip-engine/zip/line-endings.d.ts +2 -0
  996. package/dist/safe-bash-zip-engine/zip/line-endings.js +165 -0
  997. package/dist/safe-bash-zip-engine/zip/log.d.ts +22 -0
  998. package/dist/safe-bash-zip-engine/zip/log.js +153 -0
  999. package/dist/safe-bash-zip-engine/zip/lzma.d.ts +9 -0
  1000. package/dist/safe-bash-zip-engine/zip/lzma.js +7 -0
  1001. package/dist/safe-bash-zip-engine/zip/move.d.ts +11 -0
  1002. package/dist/safe-bash-zip-engine/zip/move.js +57 -0
  1003. package/dist/safe-bash-zip-engine/zip/names.d.ts +2 -0
  1004. package/dist/safe-bash-zip-engine/zip/names.js +37 -0
  1005. package/dist/safe-bash-zip-engine/zip/options.d.ts +13 -0
  1006. package/dist/safe-bash-zip-engine/zip/options.js +23 -0
  1007. package/dist/safe-bash-zip-engine/zip/repair.d.ts +10 -0
  1008. package/dist/safe-bash-zip-engine/zip/repair.js +348 -0
  1009. package/dist/safe-bash-zip-engine/zip/safety.d.ts +54 -0
  1010. package/dist/safe-bash-zip-engine/zip/safety.js +19 -0
  1011. package/dist/safe-bash-zip-engine/zip/sfx.d.ts +4 -0
  1012. package/dist/safe-bash-zip-engine/zip/sfx.js +58 -0
  1013. package/dist/safe-bash-zip-engine/zip/test-command.d.ts +5 -0
  1014. package/dist/safe-bash-zip-engine/zip/test-command.js +98 -0
  1015. package/dist/safe-bash-zip-engine/zip/volumes.d.ts +21 -0
  1016. package/dist/safe-bash-zip-engine/zip/volumes.js +255 -0
  1017. package/dist/safe-bash-zip-engine/zip/zip64.d.ts +30 -0
  1018. package/dist/safe-bash-zip-engine/zip/zip64.js +25 -0
  1019. package/dist/safe-bash-zip-engine/zip-format.d.ts +68 -0
  1020. package/dist/safe-bash-zip-engine/zip-format.js +27 -0
  1021. package/dist/safe-playwright-cloudflare/browser-codegen.generated.d.ts +7 -7
  1022. package/dist/safe-playwright-cloudflare/browser-codegen.generated.js +866 -8069
  1023. package/dist/safe-playwright-cloudflare/browser-run-code-budget.d.ts +0 -1
  1024. package/dist/safe-playwright-cloudflare/browser-run-code-budget.js +0 -2
  1025. package/dist/safe-playwright-cloudflare/browser-trace-archive.d.ts +5 -1
  1026. package/dist/safe-playwright-cloudflare/browser-trace-archive.js +2 -1
  1027. package/dist/safe-playwright-cloudflare/browser-trace-budget.js +8 -4
  1028. package/dist/safe-playwright-cloudflare/shell-browser-resource.d.ts +2 -0
  1029. package/dist/safe-playwright-cloudflare/shell-browser-resource.js +3 -11
  1030. package/dist/safe-playwright-cloudflare/shell-playwright.d.ts +2 -0
  1031. package/dist/safe-playwright-cloudflare/shell-playwright.js +1 -1
  1032. package/dist/spreadsheet-engine/codecs/odf-hyperlinks.js +8 -2
  1033. package/dist/spreadsheet-engine/formulas/functions/captured-bessel-phase.js +2 -2
  1034. package/dist/spreadsheet-engine/formulas/label-references.js +54 -33
  1035. package/dist/spreadsheet-engine/formulas/parser.js +3 -1
  1036. package/dist/spreadsheet-engine/formulas/rewriting.js +13 -3
  1037. package/dist/spreadsheet-engine/io/publication.d.ts +1 -0
  1038. package/dist/spreadsheet-format-xls/biff-data-tables.js +4 -6
  1039. package/dist/spreadsheet-format-xls/biff-formulas.js +3 -0
  1040. package/dist/spreadsheet-format-xls/biff-label-ranges.js +9 -6
  1041. package/dist/spreadsheet-format-xls/biff.js +1 -1
  1042. package/dist/xlsx-ast/xlsx.js +8 -5
  1043. package/package.json +165 -15
  1044. package/dist/safe-bash/chunks/chunk-AZAJJVFX.js +0 -23017
  1045. package/dist/safe-bash/chunks/chunk-O4ZUCRGN.js +0 -13
  1046. package/dist/safe-bash/chunks/chunk-S264DZO2.js +0 -243
  1047. package/dist/safe-bash/chunks/chunk-WVG5SHHQ.js +0 -12
  1048. package/dist/safe-bash/chunks/chunk-ZW6K2J7P.js +0 -2652
  1049. package/dist/safe-bash/command-chunks/chunk-5MPOQ6V3.js +0 -181
  1050. package/dist/safe-bash/command-chunks/chunk-BIXLZ3OG.js +0 -14342
  1051. package/dist/safe-bash/command-chunks/chunk-DUYJE2HY.js +0 -14
  1052. package/dist/safe-bash/command-chunks/chunk-KAGBORIC.js +0 -88
  1053. package/dist/safe-bash/command-chunks/chunk-NETECMOF.js +0 -40
  1054. package/dist/safe-bash/command-chunks/chunk-XS3PGJU2.js +0 -343
  1055. package/dist/safe-bash/command-chunks/chunk-XTZALMLR.js +0 -488
  1056. package/dist/safe-bash/commands/archive/zip/aes-primitives-unavailable.d.ts +0 -2
  1057. package/dist/safe-bash/commands/archive/zip/aes-primitives-unavailable.js +0 -3
  1058. package/dist/safe-bash/commands/archive/zip/aes-primitives.d.ts +0 -2
  1059. package/dist/safe-bash/commands/archive/zip/aes-primitives.js +0 -3
  1060. package/dist/safe-bash/commands/xml/document.d.ts +0 -2
  1061. package/dist/safe-bash/commands/xml/document.js +0 -2
  1062. package/dist/safe-bash/commands/xml/evaluate.d.ts +0 -2
  1063. package/dist/safe-bash/commands/xml/evaluate.js +0 -2
  1064. package/dist/safe-bash/commands/xml/json.d.ts +0 -2
  1065. package/dist/safe-bash/commands/xml/json.js +0 -2
  1066. package/dist/safe-bash/commands/xml/limits.d.ts +0 -2
  1067. package/dist/safe-bash/commands/xml/limits.js +0 -2
  1068. package/dist/safe-bash/commands/xml/query.d.ts +0 -2
  1069. package/dist/safe-bash/commands/xml/query.js +0 -2
  1070. package/dist/safe-bash/command-chunks/{chunk-FIUFIDAO.js → chunk-2JRBIDAD.js} +3 -3
  1071. package/dist/safe-bash/command-chunks/{chunk-BWNXWI33.js → chunk-2LMZVE3I.js} +0 -0
  1072. package/dist/safe-bash/command-chunks/{chunk-B5BKA5WH.js → chunk-B5TAOCKD.js} +3 -3
  1073. package/dist/safe-bash/command-chunks/{chunk-2ENZ6JGA.js → chunk-KEV7C3KH.js} +3 -3
  1074. package/dist/safe-bash/command-chunks/{chunk-S62HELHU.js → chunk-PL6O4K6W.js} +3 -3
  1075. package/dist/safe-bash/command-chunks/{chunk-DDLQ5YDB.js → chunk-YHFXOX6U.js} +9 -9
  1076. package/dist/safe-bash/command-chunks/{chunk-DQMOM72Z.js → chunk-ZRRBXU3M.js} +4 -4
@@ -1,1648 +1,2 @@
1
- import { decodeBytes, encodeBytes, writeEncodedBytes } from "../../byte-encoding.js";
2
- import { tryReadMemoryFileViewSync } from "@poe-platform/safe-fs/core";
3
- import { FsError, writeBytes } from "../../contracts/index.js";
4
- import { writeFileOutput } from "../../contracts/filesystem-output.js";
5
- import { Pattern, substitute, trySubstituteSync, trySubstitutePairSync, trySubstitutePairToBufferSync, trySubstitutePairBatchToBufferSync } from "./regex.js";
6
- import { Budget, ProgramError, byteString, bytes, command, getCachedLatin1Batch, input, lineRecordBatches, readProgram, virtualPath, write } from "./shared.js";
7
- import { assertPathRequirements, requiredFileInput, sedRequirements } from "../search/requirements.js";
8
- import { pathOf } from "../internal.js";
9
- import { editInPlace, prepareInPlace } from "./inplace.js";
10
- const sedProgramCache = new Map();
11
- const sedFastRawCache = new Map();
12
- const EMPTY_STRINGS = Object.freeze([]);
13
- const EMPTY_SET = new Set();
14
- function tryParseFastPairProgramSync(rawProg, budget) {
15
- if (rawProg.length > 256 || rawProg.startsWith("#n"))
16
- return undefined;
17
- const parts = rawProg.split(/[;\n]/);
18
- const instructions = [];
19
- const stepsBefore = budget.stepsUsed;
20
- for (let i = 0; i < parts.length; i++) {
21
- const part = parts[i].trim();
22
- if (part.length === 0)
23
- continue;
24
- if (part.charCodeAt(0) !== 115 || part.length < 4)
25
- return undefined;
26
- const delim = part[1];
27
- if (delim === "\\" || delim === "\n")
28
- return undefined;
29
- let p = 2;
30
- let patStr = "";
31
- while (p < part.length && part[p] !== delim) {
32
- const ch = part[p++];
33
- if (ch === "\\") {
34
- if (p >= part.length)
35
- return undefined;
36
- const next = part[p++];
37
- if (next === "[" || next === "]" || next === delim)
38
- return undefined;
39
- patStr += `\\${next}`;
40
- }
41
- else {
42
- if (ch === "[")
43
- return undefined;
44
- patStr += ch;
45
- }
46
- }
47
- if (p >= part.length || part[p] !== delim || patStr.length === 0)
48
- return undefined;
49
- p++;
50
- let repStr = "";
51
- let repGroupCount = 0;
52
- while (p < part.length && part[p] !== delim) {
53
- const ch = part[p++];
54
- if (ch === "\\") {
55
- if (p >= part.length)
56
- return undefined;
57
- const next = part[p++];
58
- if (next === delim)
59
- return undefined;
60
- if (next >= "1" && next <= "9")
61
- repGroupCount = Math.max(repGroupCount, Number(next));
62
- repStr += `\\${next}`;
63
- }
64
- else {
65
- repStr += ch;
66
- }
67
- }
68
- if (p >= part.length || part[p] !== delim)
69
- return undefined;
70
- p++;
71
- let global = false;
72
- for (; p < part.length; p++) {
73
- if (part[p] === "g" && !global)
74
- global = true;
75
- else
76
- return undefined;
77
- }
78
- let compiled;
79
- try {
80
- compiled = new Pattern(patStr, false, false);
81
- }
82
- catch {
83
- return undefined;
84
- }
85
- const compiledInternal = compiled;
86
- if (compiledInternal.parsed || repGroupCount > compiled.groupCount)
87
- return undefined;
88
- if (!compiledInternal.budgetPrepared && (compiledInternal.compiledSteps ?? 0) > 0) {
89
- compiledInternal.budgetPrepared = true;
90
- budget.step(compiledInternal.compiledSteps);
91
- }
92
- instructions.push({
93
- kind: "s",
94
- negate: false,
95
- pattern: compiled,
96
- replacement: repStr,
97
- replacementGroupCount: repGroupCount,
98
- global,
99
- });
100
- if (instructions.length > 2)
101
- return undefined;
102
- }
103
- if (instructions.length !== 2)
104
- return undefined;
105
- const steps = budget.stepsUsed - stepsBefore;
106
- const cached = {
107
- program: instructions,
108
- steps,
109
- outputFiles: EMPTY_STRINGS,
110
- readFiles: EMPTY_STRINGS,
111
- };
112
- const cacheKey = `0:\n:${Infinity}:${rawProg}`;
113
- if (sedProgramCache.size >= 64)
114
- sedProgramCache.delete(sedProgramCache.keys().next().value);
115
- sedProgramCache.set(cacheKey, cached);
116
- sedFastRawCache.set(rawProg, cached);
117
- return cached;
118
- }
119
- async function parse(source, extended, separator, maxProgramInstructions, budget) {
120
- const result = [];
121
- const groups = [];
122
- const labels = new Map();
123
- let offset = 0;
124
- const horizontal = () => { while (source[offset] === " " || source[offset] === "\t" || source[offset] === "\r")
125
- offset++; };
126
- const delimited = (delimiter, regex = false) => {
127
- let text = "";
128
- let bracket = false;
129
- let first = 0;
130
- let special = "";
131
- while (offset < source.length) {
132
- const character = source[offset++];
133
- if (character === delimiter && !bracket)
134
- return text;
135
- if (character === "\\") {
136
- if (bracket && source[offset] !== delimiter && source[offset] !== "\n") {
137
- text += "\\";
138
- first = 0;
139
- continue;
140
- }
141
- const next = source[offset++];
142
- if (next === undefined)
143
- break;
144
- text += next === "\n"
145
- || (!bracket && next === delimiter && (regex ? (!extended && "()|+?{}".includes(next)) || "ntrfva".includes(next) : (next === "n" || next === "t" || (next >= "0" && next <= "9"))))
146
- ? next : `\\${next}`;
147
- if (bracket)
148
- first = 0;
149
- }
150
- else {
151
- if (character === "\n")
152
- throw new ProgramError("unterminated delimited expression");
153
- if (regex) {
154
- if (!bracket && character === "[") {
155
- bracket = true;
156
- first = 2;
157
- }
158
- else if (bracket) {
159
- if (special) {
160
- if (character === special && source[offset] === "]") {
161
- text += character + source[offset++];
162
- special = "";
163
- continue;
164
- }
165
- }
166
- else if (character === "[" && [":", ".", "="].includes(source[offset] ?? "")) {
167
- special = source[offset++];
168
- text += character + special;
169
- first = 0;
170
- continue;
171
- }
172
- else if (character === "]" && !first)
173
- bracket = false;
174
- first = first === 2 && character === "^" ? 1 : 0;
175
- }
176
- }
177
- text += character;
178
- }
179
- }
180
- throw new ProgramError(bracket ? "unterminated bracket expression" : "unterminated delimited expression");
181
- };
182
- const address = async () => {
183
- horizontal();
184
- const number = /^[0-9]+/u.exec(source.slice(offset));
185
- if (number) {
186
- offset += number[0].length;
187
- const value = Number(number[0]);
188
- if (!Number.isSafeInteger(value))
189
- throw new ProgramError("sed line address exceeds safe integer range");
190
- if (source[offset] === "~") {
191
- offset++;
192
- const stepMatch = /^[0-9]+/u.exec(source.slice(offset));
193
- if (!stepMatch)
194
- throw new ProgramError("invalid step address");
195
- offset += stepMatch[0].length;
196
- const step = Number(stepMatch[0]);
197
- if (!Number.isSafeInteger(step))
198
- throw new ProgramError("sed line address exceeds safe integer range");
199
- return { kind: "step", first: value, step };
200
- }
201
- return { kind: "number", number: value };
202
- }
203
- if (source[offset] === "$") {
204
- offset++;
205
- return { kind: "last" };
206
- }
207
- let delimiter;
208
- if (source[offset] === "/")
209
- delimiter = source[offset++];
210
- else if (source[offset] === "\\" && source[offset + 1] && source[offset + 1] !== "\n") {
211
- offset++;
212
- delimiter = source[offset++];
213
- }
214
- if (delimiter !== undefined) {
215
- const pattern = delimited(delimiter, true);
216
- const ignoreCase = source[offset] === "I";
217
- if (ignoreCase)
218
- offset++;
219
- if (!pattern && ignoreCase)
220
- throw new ProgramError("flags on an empty regex are not supported");
221
- const compiled = pattern ? new Pattern(pattern, extended, ignoreCase) : undefined;
222
- if (compiled)
223
- await compiled.prepare(budget);
224
- return { kind: "regex", pattern: compiled };
225
- }
226
- return undefined;
227
- };
228
- const label = () => {
229
- horizontal();
230
- const start = offset;
231
- while (offset < source.length && ![";", "\n", "}"].includes(source[offset]))
232
- offset++;
233
- const text = source.slice(start, offset).trim();
234
- return text;
235
- };
236
- const textArgument = (terminator) => {
237
- horizontal();
238
- if (source[offset] === "\\") {
239
- offset++;
240
- if (source[offset] === "\n")
241
- offset++;
242
- }
243
- let text = "";
244
- while (offset < source.length && source[offset] !== "\n") {
245
- const character = source[offset++];
246
- if (character === "\\" && offset < source.length) {
247
- const next = source[offset++];
248
- text += next === "n" ? "\n" : next === "t" ? "\t" : next;
249
- }
250
- else
251
- text += character;
252
- }
253
- return text + terminator;
254
- };
255
- const fileArgument = () => {
256
- horizontal();
257
- const start = offset;
258
- while (offset < source.length && source[offset] !== "\n")
259
- offset++;
260
- const file = decodeBytes(encodeBytes(source.slice(start, offset), "latin1"), "utf8");
261
- if (!file || file.includes("\0"))
262
- throw new ProgramError("file command requires a nonempty filename without NUL");
263
- return file;
264
- };
265
- while (offset < source.length) {
266
- horizontal();
267
- if (source[offset] === ";" || source[offset] === "\n") {
268
- offset++;
269
- continue;
270
- }
271
- if (source[offset] === "#") {
272
- while (offset < source.length && source[offset] !== "\n")
273
- offset++;
274
- continue;
275
- }
276
- if (offset === source.length)
277
- break;
278
- if (result.length >= maxProgramInstructions)
279
- throw new ProgramError("program instruction limit exceeded");
280
- const first = await address();
281
- horizontal();
282
- let second;
283
- if (source[offset] === ",") {
284
- offset++;
285
- horizontal();
286
- if (source[offset] === "+" || source[offset] === "~") {
287
- const relKind = source[offset];
288
- const relMatch = /^[0-9]+/u.exec(source.slice(offset + 1));
289
- if (relMatch) {
290
- offset += 1 + relMatch[0].length;
291
- const count = Number(relMatch[0]);
292
- if (!Number.isSafeInteger(count))
293
- throw new ProgramError("sed line address exceeds safe integer range");
294
- second = { kind: relKind === "+" ? "plus" : "tilde", count };
295
- }
296
- }
297
- if (!second)
298
- second = await address();
299
- if (!first || !second)
300
- throw new ProgramError("invalid address range");
301
- }
302
- if (first?.kind === "number" && first.number === 0 && second?.kind !== "regex" || second?.kind === "number" && second.number === 0)
303
- throw new ProgramError("zero address requires a 0,/regex/ range");
304
- horizontal();
305
- const negate = source[offset] === "!";
306
- if (negate) {
307
- offset++;
308
- horizontal();
309
- }
310
- const kind = source[offset++];
311
- if (kind === undefined)
312
- throw new ProgramError("missing sed command");
313
- const instruction = { kind, negate, ...(first ? { first } : {}), ...(second ? { second } : {}) };
314
- if (kind === "{") {
315
- groups.push(result.length);
316
- result.push(instruction);
317
- continue;
318
- }
319
- if (kind === "}") {
320
- if (first || negate)
321
- throw new ProgramError("closing group cannot have an address");
322
- const start = groups.pop();
323
- if (start === undefined)
324
- throw new ProgramError("unmatched '}'");
325
- result[start].jump = result.length + 1;
326
- }
327
- else if (kind === "s") {
328
- const delimiter = source[offset++];
329
- if (!delimiter || delimiter === "\\" || delimiter === "\n")
330
- throw new ProgramError("invalid substitution delimiter");
331
- const pattern = delimited(delimiter, true);
332
- instruction.replacement = delimited(delimiter);
333
- instruction.replacementGroupCount = 0;
334
- for (let index = 0; index < instruction.replacement.length; index++) {
335
- if (instruction.replacement[index] !== "\\")
336
- continue;
337
- const escaped = instruction.replacement[++index];
338
- if (escaped !== undefined && escaped >= "1" && escaped <= "9") {
339
- instruction.replacementGroupCount = Math.max(instruction.replacementGroupCount, Number(escaped));
340
- }
341
- }
342
- let ignoreCase = false;
343
- while (offset < source.length && ![";", "\n", "}", " ", "\t", "#"].includes(source[offset])) {
344
- const flag = source[offset++];
345
- if (flag === "g" && !instruction.global)
346
- instruction.global = true;
347
- else if (flag === "p" && !instruction.print)
348
- instruction.print = true;
349
- else if ((flag === "i" || flag === "I") && !ignoreCase)
350
- ignoreCase = true;
351
- else if (flag === "w" && instruction.file === undefined) {
352
- instruction.file = fileArgument();
353
- break;
354
- }
355
- else if (/^[1-9]$/u.test(flag) && instruction.occurrence === undefined) {
356
- const rest = /^[0-9]*/u.exec(source.slice(offset))[0];
357
- offset += rest.length;
358
- instruction.occurrence = Number(flag + rest);
359
- if (!Number.isSafeInteger(instruction.occurrence))
360
- throw new ProgramError("invalid substitution occurrence");
361
- }
362
- else
363
- throw new ProgramError(`unsupported substitution flag '${flag}'`);
364
- }
365
- if (!pattern && ignoreCase)
366
- throw new ProgramError("flags on an empty regex are not supported");
367
- if (pattern) {
368
- instruction.pattern = new Pattern(pattern, extended, ignoreCase);
369
- if (instruction.replacementGroupCount > instruction.pattern.groupCount)
370
- throw new ProgramError("replacement references an undefined capture group");
371
- await instruction.pattern.prepare(budget);
372
- }
373
- }
374
- else if (kind === "r" || kind === "w") {
375
- if (kind === "r" && second)
376
- throw new ProgramError("read accepts at most one address");
377
- instruction.file = fileArgument();
378
- }
379
- else if (kind === "a" || kind === "i" || kind === "c")
380
- instruction.text = textArgument(kind === "a" ? "\n" : separator);
381
- else if (kind === "b" || kind === "t" || kind === "T" || kind === ":") {
382
- instruction.text = label();
383
- if (first && kind === ":")
384
- throw new ProgramError("labels cannot have addresses");
385
- if (kind === ":") {
386
- if (!instruction.text || labels.has(instruction.text))
387
- throw new ProgramError("empty or duplicate branch label");
388
- labels.set(instruction.text, result.length);
389
- }
390
- }
391
- else if (kind === "q" || kind === "Q") {
392
- if (second)
393
- throw new ProgramError("quit accepts at most one address");
394
- horizontal();
395
- const status = /^[0-9]+/u.exec(source.slice(offset));
396
- if (status) {
397
- offset += status[0].length;
398
- instruction.status = Number(status[0]);
399
- if (instruction.status > 255)
400
- throw new ProgramError("quit status exceeds 255");
401
- }
402
- }
403
- else if (kind === "y") {
404
- const delimiter = source[offset++];
405
- if (!delimiter || delimiter === "\\" || delimiter === "\n")
406
- throw new ProgramError("invalid translation delimiter");
407
- const decode = (text) => text.replace(/\\(.)/gsu, (_whole, escaped) => escaped === "n" ? "\n" : escaped === "t" ? "\t" : escaped);
408
- const from = decode(delimited(delimiter));
409
- const to = decode(delimited(delimiter));
410
- if (from.length !== to.length)
411
- throw new ProgramError("translation sets have different lengths");
412
- instruction.translation = new Map([...from].map((character, index) => [character, to[index]]));
413
- }
414
- else if (!"pdDPhHgGxnN=lzF".includes(kind))
415
- throw new ProgramError(`unsupported sed command '${kind}'`);
416
- result.push(instruction);
417
- horizontal();
418
- if (offset < source.length && ![";", "\n", "}", "#"].includes(source[offset]))
419
- throw new ProgramError(`unexpected text after '${kind}' command`);
420
- }
421
- if (groups.length)
422
- throw new ProgramError("unclosed sed group");
423
- for (const instruction of result)
424
- if (["b", "t", "T"].includes(instruction.kind)) {
425
- const target = instruction.text ? labels.get(instruction.text) : result.length;
426
- if (target === undefined)
427
- throw new ProgramError(`undefined branch label '${instruction.text}'`);
428
- instruction.jump = target;
429
- }
430
- return result;
431
- }
432
- async function* nullRecords(context, files, budget) {
433
- const names = files.length ? files : ["-"];
434
- for (let fileIndex = 0; fileIndex < names.length; fileIndex++) {
435
- const file = names[fileIndex];
436
- let pending = "";
437
- for await (const chunk of input(context, file)) {
438
- budget.step();
439
- let start = 0;
440
- while (start < chunk.byteLength) {
441
- const end = chunk.indexOf(0, start);
442
- const stop = end < 0 ? chunk.byteLength : end;
443
- if (pending.length + stop - start > budget.maxBufferBytes)
444
- throw new ProgramError("text buffer limit exceeded");
445
- pending += decodeBytes(encodeBytes(chunk.subarray(start, stop)), "latin1");
446
- if (end < 0)
447
- break;
448
- yield { text: pending, terminated: true, file, fileIndex };
449
- pending = "";
450
- start = end + 1;
451
- }
452
- }
453
- if (pending)
454
- yield { text: pending, terminated: false, file, fileIndex };
455
- }
456
- }
457
- const STDOUT_CAP = 65536;
458
- const STDOUT_FLUSH = 60000;
459
- let sharedSedStdoutBuf;
460
- let sharedSedStdoutBufInUse = false;
461
- let lastSedPairProgram;
462
- let lastSedPairBatch;
463
- let lastSedPairStdoutLen = 0;
464
- let lastSedPairSavedOutBuf;
465
- let lastSedPairSteps = 0;
466
- let lastSedPairStdoutIntact = false;
467
- let sedPairBimodalWarm = 0;
468
- async function execute(program, context, files, quiet, budget, separator, outputState, lineLength) {
469
- const useBatches = separator !== "\0";
470
- const batchSource = useBatches ? lineRecordBatches(context, files, budget) : undefined;
471
- const singleSource = useBatches ? undefined : nullRecords(context, files, budget);
472
- let currentBatch;
473
- let currentBatchLen = 0;
474
- let batchIndex = 0;
475
- const sharedBatchRecord = {
476
- text: "",
477
- terminated: true,
478
- file: "",
479
- fileIndex: 0,
480
- };
481
- const fillFromBatch = (batch, idx, target) => {
482
- if (idx < batch.ends.length) {
483
- const start = idx === 0 ? 0 : batch.ends[idx - 1] + 1;
484
- const end = batch.ends[idx];
485
- const slice = batch.text.slice(start, end);
486
- target.text = idx === 0 && batch.firstLinePrefix ? batch.firstLinePrefix + slice : slice;
487
- target.terminated = true;
488
- }
489
- else {
490
- target.text = batch.trailingText;
491
- target.terminated = false;
492
- }
493
- target.file = batch.file;
494
- target.fileIndex = batch.fileIndex;
495
- return target;
496
- };
497
- let currentRecord;
498
- let followingRecord;
499
- if (batchSource) {
500
- const firstBatch = await batchSource.next();
501
- if (!firstBatch.done) {
502
- currentBatch = firstBatch.value;
503
- currentBatchLen = currentBatch.ends.length + (currentBatch.trailingText !== undefined ? 1 : 0);
504
- if (currentBatchLen > 0) {
505
- currentRecord = fillFromBatch(currentBatch, 0, sharedBatchRecord);
506
- batchIndex = 1;
507
- }
508
- }
509
- }
510
- else {
511
- const first = await singleSource.next();
512
- if (!first.done)
513
- currentRecord = first.value;
514
- }
515
- const peekNextRecord = async () => {
516
- if (followingRecord !== undefined)
517
- return followingRecord ?? undefined;
518
- if (batchSource) {
519
- if (currentBatch && batchIndex < currentBatchLen) {
520
- followingRecord = fillFromBatch(currentBatch, batchIndex, { text: "", terminated: true, file: "", fileIndex: 0 });
521
- return followingRecord;
522
- }
523
- const nextBatch = await batchSource.next();
524
- if (nextBatch.done) {
525
- followingRecord = null;
526
- return undefined;
527
- }
528
- currentBatch = nextBatch.value;
529
- currentBatchLen = currentBatch.ends.length + (currentBatch.trailingText !== undefined ? 1 : 0);
530
- if (currentBatchLen === 0) {
531
- followingRecord = null;
532
- return undefined;
533
- }
534
- batchIndex = 0;
535
- followingRecord = fillFromBatch(currentBatch, 0, { text: "", terminated: true, file: "", fileIndex: 0 });
536
- return followingRecord;
537
- }
538
- const next = await singleSource.next();
539
- followingRecord = next.done ? null : next.value;
540
- return followingRecord ?? undefined;
541
- };
542
- const readNextRecord = async () => {
543
- if (followingRecord !== undefined) {
544
- const next = followingRecord ?? undefined;
545
- followingRecord = undefined;
546
- if (batchSource && next !== undefined && currentBatch && batchIndex < currentBatchLen) {
547
- batchIndex++;
548
- }
549
- return next;
550
- }
551
- if (batchSource) {
552
- if (currentBatch && batchIndex < currentBatchLen) {
553
- return fillFromBatch(currentBatch, batchIndex++, sharedBatchRecord);
554
- }
555
- const nextBatch = await batchSource.next();
556
- if (nextBatch.done)
557
- return undefined;
558
- currentBatch = nextBatch.value;
559
- currentBatchLen = currentBatch.ends.length + (currentBatch.trailingText !== undefined ? 1 : 0);
560
- if (currentBatchLen === 0)
561
- return undefined;
562
- batchIndex = 1;
563
- return fillFromBatch(currentBatch, 0, sharedBatchRecord);
564
- }
565
- const next = await singleSource.next();
566
- return next.done ? undefined : next.value;
567
- };
568
- const prepareRecord = async (record) => {
569
- if (record.terminated || files.length < 2)
570
- return record;
571
- const next = await peekNextRecord();
572
- return next !== undefined && next.fileIndex !== record.fileIndex ? { ...record, terminated: true } : record;
573
- };
574
- let number = 0;
575
- let hold = "";
576
- let holdTerminated = true;
577
- const STDOUT_CAP = 65536;
578
- const STDOUT_FLUSH = 60000;
579
- const stdoutSync = typeof context.stdout.writeSync === "function"
580
- ? context.stdout
581
- : undefined;
582
- const canReuseStdoutBuf = !context.stdout.isPipeStage;
583
- let usingSharedStdoutBuf = false;
584
- let stdoutBuf;
585
- if (canReuseStdoutBuf && !sharedSedStdoutBufInUse) {
586
- sharedSedStdoutBufInUse = true;
587
- usingSharedStdoutBuf = true;
588
- if (!sharedSedStdoutBuf) {
589
- sharedSedStdoutBuf = new Uint8Array(STDOUT_CAP);
590
- }
591
- stdoutBuf = sharedSedStdoutBuf;
592
- }
593
- let stdoutLen = 0;
594
- const sepCode = separator.charCodeAt(0) & 0xff;
595
- const appendStdout = (text) => {
596
- const tLen = text.length;
597
- if (tLen === 0)
598
- return;
599
- if (!stdoutBuf) {
600
- stdoutBuf = new Uint8Array(Math.max(STDOUT_CAP, tLen + 1));
601
- }
602
- else if (stdoutLen + tLen > stdoutBuf.length) {
603
- const grown = new Uint8Array(Math.max(stdoutBuf.length * 2, stdoutLen + tLen + 1));
604
- grown.set(stdoutBuf.subarray(0, stdoutLen), 0);
605
- stdoutBuf = grown;
606
- }
607
- writeEncodedBytes(stdoutBuf, text, stdoutLen, tLen, "latin1");
608
- stdoutLen += tLen;
609
- };
610
- const appendStdoutSep = () => {
611
- if (!stdoutBuf) {
612
- stdoutBuf = new Uint8Array(STDOUT_CAP);
613
- }
614
- else if (stdoutLen + 1 > stdoutBuf.length) {
615
- const grown = new Uint8Array(stdoutBuf.length * 2);
616
- grown.set(stdoutBuf.subarray(0, stdoutLen), 0);
617
- stdoutBuf = grown;
618
- }
619
- stdoutBuf[stdoutLen++] = sepCode;
620
- };
621
- const flushStdout = () => {
622
- if (stdoutLen > 0 && stdoutBuf) {
623
- const flushedLen = stdoutLen;
624
- const chunk = new Uint8Array(stdoutBuf.buffer, stdoutBuf.byteOffset, flushedLen);
625
- stdoutLen = 0;
626
- context.signal.throwIfAborted();
627
- if (stdoutSync) {
628
- stdoutSync.writeSync(chunk);
629
- return undefined;
630
- }
631
- return writeBytes(context.stdout, encodeBytes(chunk), context.signal);
632
- }
633
- return undefined;
634
- };
635
- const joinSpace = (left, right) => {
636
- if (left.length + separator.length + right.length > budget.maxBufferBytes)
637
- throw new ProgramError("text buffer limit exceeded");
638
- return left + separator + right;
639
- };
640
- const emit = (text, terminated = true) => {
641
- if (outputState.stdoutUnterminated)
642
- appendStdoutSep();
643
- appendStdout(text);
644
- outputState.stdoutUnterminated = !terminated;
645
- if (!useBatches || stdoutLen >= STDOUT_FLUSH)
646
- return flushStdout();
647
- return undefined;
648
- };
649
- let lastPattern;
650
- const active = new Map();
651
- for (let pc = 0; pc < program.length; pc++) {
652
- const first = program[pc].first;
653
- if (first?.kind === "number" && first.number === 0)
654
- active.set(pc, 0);
655
- }
656
- const getPattern = (pattern) => {
657
- if (pattern)
658
- lastPattern = pattern;
659
- if (!lastPattern)
660
- throw new ProgramError("no previous regular expression");
661
- return lastPattern;
662
- };
663
- const appended = [];
664
- let appendedSize = 0;
665
- const append = (item) => {
666
- appendedSize += (item.text ?? item.file ?? "").length + 32;
667
- if (appendedSize > budget.maxBufferBytes)
668
- throw new ProgramError("append queue buffer limit exceeded");
669
- appended.push(item);
670
- };
671
- let record;
672
- let pattern = "";
673
- let substituted = false;
674
- let deleted = false;
675
- let quit = false;
676
- let status = 0;
677
- const print = () => {
678
- if (outputState.stdoutUnterminated)
679
- appendStdoutSep();
680
- appendStdout(pattern);
681
- if (record.terminated)
682
- appendStdoutSep();
683
- outputState.stdoutUnterminated = !record.terminated;
684
- if (!useBatches || stdoutLen >= STDOUT_FLUSH)
685
- return flushStdout();
686
- return undefined;
687
- };
688
- const flushSlow = async (printPattern) => {
689
- if (appended.length > 0) {
690
- await assertPathRequirements(context, sedRequirements, ["script-read"], appended.flatMap(item => item.file === undefined ? [] : [item.file]));
691
- }
692
- if (printPattern && !quiet && !deleted) {
693
- const p = print();
694
- if (p)
695
- await p;
696
- }
697
- if (outputState.stdoutUnterminated && (appended.length || quit)) {
698
- appendStdoutSep();
699
- if (stdoutLen >= STDOUT_FLUSH)
700
- await flushStdout();
701
- outputState.stdoutUnterminated = false;
702
- }
703
- for (const item of appended) {
704
- if (item.text !== undefined) {
705
- appendStdout(item.text);
706
- if (stdoutLen >= STDOUT_FLUSH)
707
- await flushStdout();
708
- continue;
709
- }
710
- await flushStdout();
711
- const path = virtualPath(context, item.file);
712
- try {
713
- for await (const chunk of requiredFileInput(context, sedRequirements, "script-read", path, budget.maxBufferBytes)) {
714
- budget.step();
715
- const pendingCheck = budget.checkpointSync();
716
- if (pendingCheck)
717
- await pendingCheck;
718
- if (chunk.byteLength > budget.maxBufferBytes)
719
- throw new ProgramError("read buffer limit exceeded");
720
- await writeBytes(context.stdout, chunk, context.signal);
721
- }
722
- }
723
- catch (error) {
724
- context.signal.throwIfAborted();
725
- if (!(error instanceof FsError) || !["ENOENT", "EACCES", "EPERM", "EISDIR", "ENOTDIR"].includes(error.code))
726
- throw error;
727
- }
728
- }
729
- appended.length = 0;
730
- appendedSize = 0;
731
- };
732
- const flush = (printPattern = true) => {
733
- if (appended.length === 0 && !quit) {
734
- if (printPattern && !quiet && !deleted)
735
- return print();
736
- return undefined;
737
- }
738
- return flushSlow(printPattern);
739
- };
740
- const writeFile = async (file) => {
741
- if (stdoutLen > 0)
742
- await flushStdout();
743
- const path = virtualPath(context, file);
744
- const terminated = record.terminated || separator === "\n";
745
- const text = (outputState.unterminatedFiles.has(path) ? separator : "") + pattern + (terminated ? separator : "");
746
- await writeFileOutput(context, bytes(text), chunk => context.fs.appendFile(path, chunk, { signal: context.signal }));
747
- if (terminated)
748
- outputState.unterminatedFiles.delete(path);
749
- else
750
- outputState.unterminatedFiles.add(path);
751
- };
752
- const matches = (address) => {
753
- if (address.kind === "number")
754
- return number === address.number;
755
- if (address.kind === "step")
756
- return address.step === 0 ? number === address.first : number >= address.first && (number - address.first) % address.step === 0;
757
- if (address.kind === "plus" || address.kind === "tilde")
758
- return false;
759
- if (address.kind === "last") {
760
- if (batchSource && batchIndex < currentBatchLen)
761
- return false;
762
- return peekNextRecord().then(next => next === undefined);
763
- }
764
- return getPattern(address.pattern).tryTestSync(pattern, budget);
765
- };
766
- try {
767
- while (currentRecord !== undefined) {
768
- budget.step();
769
- number++;
770
- record = currentRecord.terminated || files.length < 2 ? currentRecord : await prepareRecord(currentRecord);
771
- pattern = record.text;
772
- substituted = false;
773
- deleted = false;
774
- quit = false;
775
- status = 0;
776
- for (let pc = 0; pc < program.length;) {
777
- budget.step();
778
- const instruction = program[pc];
779
- if (number === 1 || (number & 31) === 0 || instruction.kind === "b" || instruction.kind === "t" || instruction.kind === "T" || instruction.kind === "D") {
780
- const pendingCheck = budget.checkpointSync();
781
- if (pendingCheck)
782
- await pendingCheck;
783
- }
784
- let selected = true;
785
- let ending = false;
786
- if (instruction.first) {
787
- if (instruction.second) {
788
- if (active.has(pc)) {
789
- const startLine = active.get(pc);
790
- if (instruction.second.kind === "number" && number > instruction.second.number)
791
- selected = false;
792
- const endMatch = instruction.second.kind === "number" ? number >= instruction.second.number
793
- : instruction.second.kind === "plus" ? number >= startLine + instruction.second.count
794
- : instruction.second.kind === "tilde" ? (instruction.second.count === 0 || (number > startLine && number % instruction.second.count === 0))
795
- : matches(instruction.second);
796
- ending = endMatch instanceof Promise ? await endMatch : endMatch;
797
- if (ending)
798
- active.delete(pc);
799
- }
800
- else {
801
- const firstMatch = matches(instruction.first);
802
- selected = firstMatch instanceof Promise ? await firstMatch : firstMatch;
803
- if (selected) {
804
- ending = instruction.second.kind === "number" && number >= instruction.second.number
805
- || (instruction.second.kind === "plus" || instruction.second.kind === "tilde") && instruction.second.count === 0
806
- || instruction.second.kind === "last" && (await peekNextRecord()) === undefined;
807
- if (!ending)
808
- active.set(pc, number);
809
- }
810
- }
811
- }
812
- else {
813
- const firstMatch = matches(instruction.first);
814
- selected = firstMatch instanceof Promise ? await firstMatch : firstMatch;
815
- }
816
- }
817
- if (instruction.negate)
818
- selected = !selected;
819
- if (!selected) {
820
- pc = instruction.kind === "{" ? instruction.jump : pc + 1;
821
- continue;
822
- }
823
- switch (instruction.kind) {
824
- case "p": {
825
- const p = print();
826
- if (p)
827
- await p;
828
- break;
829
- }
830
- case "P": {
831
- const end = pattern.indexOf(separator);
832
- const p = emit(end < 0 ? pattern + (record.terminated ? separator : "") : pattern.slice(0, end + 1), end >= 0 || record.terminated);
833
- if (p)
834
- await p;
835
- break;
836
- }
837
- case "=": {
838
- const p = emit(`${number}${separator}`);
839
- if (p)
840
- await p;
841
- break;
842
- }
843
- case "l": {
844
- const escapes = { "\x07": "\\a", "\b": "\\b", "\f": "\\f", "\n": "\\n", "\r": "\\r", "\t": "\\t", "\v": "\\v", "\\": "\\\\" };
845
- let line = "";
846
- for (let offset = 0; offset <= pattern.length; offset++) {
847
- budget.step();
848
- await budget.checkpointSync();
849
- const character = pattern[offset];
850
- const lineEnd = character === "\n" && separator === "\n";
851
- const token = character === undefined || lineEnd ? "$" : escapes[character] ?? (character.charCodeAt(0) < 32 || character.charCodeAt(0) >= 127 ? `\\${character.charCodeAt(0).toString(8).padStart(3, "0")}` : character);
852
- // GNU sed reserves a column for continuation but appends the end marker without wrapping.
853
- if (lineLength > 0 && character !== undefined && !lineEnd && line.length + token.length >= lineLength) {
854
- await emit(line + "\\" + separator);
855
- line = "";
856
- }
857
- line = budget.check(line + token);
858
- if (lineEnd) {
859
- await emit(line + separator);
860
- line = "";
861
- }
862
- }
863
- await emit(line + separator);
864
- break;
865
- }
866
- case "d":
867
- deleted = true;
868
- pc = program.length;
869
- continue;
870
- case "D": {
871
- const end = pattern.indexOf(separator);
872
- if (end < 0) {
873
- deleted = true;
874
- pc = program.length;
875
- }
876
- else {
877
- pattern = pattern.slice(end + 1);
878
- pc = 0;
879
- }
880
- continue;
881
- }
882
- case "q":
883
- quit = true;
884
- status = instruction.status ?? 0;
885
- pc = program.length;
886
- continue;
887
- case "Q":
888
- deleted = true;
889
- quit = true;
890
- status = instruction.status ?? 0;
891
- pc = program.length;
892
- continue;
893
- case "z":
894
- pattern = "";
895
- break;
896
- case "F": {
897
- const p = emit(`${record.file}${separator}`);
898
- if (p)
899
- await p;
900
- break;
901
- }
902
- case "a":
903
- append({ text: instruction.text });
904
- break;
905
- case "r":
906
- append({ file: instruction.file });
907
- break;
908
- case "w":
909
- await writeFile(instruction.file);
910
- break;
911
- case "i":
912
- await emit(instruction.text);
913
- break;
914
- case "c":
915
- if (!instruction.second || ending || instruction.negate || (await peekNextRecord()) === undefined)
916
- await emit(instruction.text);
917
- deleted = true;
918
- pc = program.length;
919
- continue;
920
- case "h":
921
- hold = pattern;
922
- holdTerminated = record.terminated;
923
- break;
924
- case "H":
925
- hold = joinSpace(hold, pattern);
926
- holdTerminated = record.terminated;
927
- break;
928
- case "g":
929
- pattern = hold;
930
- record = { ...record, terminated: holdTerminated };
931
- break;
932
- case "G":
933
- pattern = joinSpace(pattern, hold);
934
- record = { ...record, terminated: holdTerminated };
935
- break;
936
- case "x": {
937
- [pattern, hold] = [hold, pattern];
938
- const terminated = record.terminated;
939
- record = { ...record, terminated: holdTerminated };
940
- holdTerminated = terminated;
941
- break;
942
- }
943
- case "s": {
944
- const expression = getPattern(instruction.pattern);
945
- if (instruction.replacementGroupCount > expression.groupCount)
946
- throw new ProgramError("replacement references an undefined capture group");
947
- if (!instruction.print && !instruction.file && pc + 1 < program.length) {
948
- const nextInst = program[pc + 1];
949
- if (nextInst.kind === "s" && !nextInst.first && !nextInst.second && !nextInst.negate && !nextInst.print && !nextInst.file && nextInst.pattern) {
950
- const nextExpr = nextInst.pattern;
951
- if (nextInst.replacementGroupCount <= nextExpr.groupCount) {
952
- const canPairAnchored = expression.getFastPrefixInfo()?.anchoredStart === true;
953
- if (canPairAnchored &&
954
- pc === 0 &&
955
- program.length === 2 &&
956
- !quiet &&
957
- !deleted &&
958
- appended.length === 0 &&
959
- record.terminated &&
960
- !outputState.stdoutUnterminated) {
961
- if (!stdoutBuf)
962
- stdoutBuf = new Uint8Array(STDOUT_CAP);
963
- const newPosOrPromise = trySubstitutePairToBufferSync(pattern, expression, instruction.replacement, instruction.global ?? false, instruction.occurrence ?? 1, nextExpr, nextInst.replacement, nextInst.global ?? false, nextInst.occurrence ?? 1, budget, stdoutBuf, stdoutLen, sepCode);
964
- const newPos = typeof newPosOrPromise === "number" ? newPosOrPromise : await newPosOrPromise;
965
- if (newPos >= 0) {
966
- lastPattern = nextExpr;
967
- stdoutLen = newPos;
968
- budget.step();
969
- if (!useBatches || stdoutLen >= STDOUT_FLUSH) {
970
- const p = flushStdout();
971
- if (p)
972
- await p;
973
- }
974
- if (batchSource && currentBatch && followingRecord === undefined) {
975
- const batchText = currentBatch.text;
976
- const batchEnds = currentBatch.ends;
977
- const endsLen = batchEnds.length;
978
- const g1 = instruction.global ?? false;
979
- const o1 = instruction.occurrence ?? 1;
980
- const r1 = instruction.replacement;
981
- const g2 = nextInst.global ?? false;
982
- const o2 = nextInst.occurrence ?? 1;
983
- const r2 = nextInst.replacement;
984
- while (batchIndex < endsLen) {
985
- if (batchIndex === 0 && currentBatch.firstLinePrefix)
986
- break;
987
- const lStart = batchIndex === 0 ? 0 : batchEnds[batchIndex - 1] + 1;
988
- const lEnd = batchEnds[batchIndex];
989
- if (!stdoutBuf)
990
- stdoutBuf = new Uint8Array(STDOUT_CAP);
991
- const nextPosOrPromise = trySubstitutePairToBufferSync(batchText, expression, r1, g1, o1, nextExpr, r2, g2, o2, budget, stdoutBuf, stdoutLen, sepCode, lStart, lEnd);
992
- const nextPos = typeof nextPosOrPromise === "number" ? nextPosOrPromise : await nextPosOrPromise;
993
- if (nextPos < 0)
994
- break;
995
- batchIndex++;
996
- number++;
997
- budget.step(3);
998
- if ((number & 31) === 0) {
999
- const pendingCheck = budget.checkpointSync();
1000
- if (pendingCheck)
1001
- await pendingCheck;
1002
- }
1003
- stdoutLen = nextPos;
1004
- if (stdoutLen >= STDOUT_FLUSH) {
1005
- const p = flushStdout();
1006
- if (p)
1007
- await p;
1008
- }
1009
- }
1010
- }
1011
- deleted = true;
1012
- pc += 2;
1013
- continue;
1014
- }
1015
- }
1016
- if (!canPairAnchored &&
1017
- pc === 0 &&
1018
- program.length === 2 &&
1019
- !quiet &&
1020
- !deleted &&
1021
- appended.length === 0 &&
1022
- record.terminated &&
1023
- !outputState.stdoutUnterminated &&
1024
- expression.canFindSync() &&
1025
- nextExpr.canFindSync()) {
1026
- const g1 = instruction.global ?? false;
1027
- const o1 = instruction.occurrence ?? 1;
1028
- const r1 = instruction.replacement;
1029
- const g2 = nextInst.global ?? false;
1030
- const o2 = nextInst.occurrence ?? 1;
1031
- const r2 = nextInst.replacement;
1032
- const c1OrP = trySubstituteSync(pattern, expression, r1, budget, g1, o1);
1033
- const c1 = c1OrP instanceof Promise ? await c1OrP : c1OrP;
1034
- const c2OrP = trySubstituteSync(c1.text, nextExpr, r2, budget, g2, o2);
1035
- const c2 = c2OrP instanceof Promise ? await c2OrP : c2OrP;
1036
- lastPattern = nextExpr;
1037
- appendStdout(c2.text);
1038
- appendStdoutSep();
1039
- if (!useBatches || stdoutLen >= STDOUT_FLUSH) {
1040
- const p = flushStdout();
1041
- if (p)
1042
- await p;
1043
- }
1044
- if (batchSource && currentBatch && followingRecord === undefined) {
1045
- const batchText = currentBatch.text;
1046
- const batchEnds = currentBatch.ends;
1047
- const endsLen = batchEnds.length;
1048
- while (batchIndex < endsLen) {
1049
- if (batchIndex === 0 && currentBatch.firstLinePrefix)
1050
- break;
1051
- const lStart = batchIndex === 0 ? 0 : batchEnds[batchIndex - 1] + 1;
1052
- const lEnd = batchEnds[batchIndex];
1053
- const lineStr = batchText.slice(lStart, lEnd);
1054
- const s1OrP = trySubstituteSync(lineStr, expression, r1, budget, g1, o1);
1055
- const s1 = s1OrP instanceof Promise ? await s1OrP : s1OrP;
1056
- const s2OrP = trySubstituteSync(s1.text, nextExpr, r2, budget, g2, o2);
1057
- const s2 = s2OrP instanceof Promise ? await s2OrP : s2OrP;
1058
- batchIndex++;
1059
- number++;
1060
- budget.step(3);
1061
- if ((number & 31) === 0) {
1062
- const pendingCheck = budget.checkpointSync();
1063
- if (pendingCheck)
1064
- await pendingCheck;
1065
- }
1066
- appendStdout(s2.text);
1067
- appendStdoutSep();
1068
- if (stdoutLen >= STDOUT_FLUSH) {
1069
- const p = flushStdout();
1070
- if (p)
1071
- await p;
1072
- }
1073
- }
1074
- }
1075
- deleted = true;
1076
- pc += 2;
1077
- continue;
1078
- }
1079
- const pairedOrPromise = !canPairAnchored ? undefined : trySubstitutePairSync(pattern, expression, instruction.replacement, instruction.global ?? false, instruction.occurrence ?? 1, nextExpr, nextInst.replacement, nextInst.global ?? false, nextInst.occurrence ?? 1, budget);
1080
- const paired = pairedOrPromise instanceof Promise ? await pairedOrPromise : pairedOrPromise;
1081
- if (paired !== undefined) {
1082
- lastPattern = nextExpr;
1083
- pattern = paired.text;
1084
- if (paired.substituted)
1085
- substituted = true;
1086
- budget.step();
1087
- pc += 2;
1088
- continue;
1089
- }
1090
- }
1091
- }
1092
- }
1093
- const changedOrPromise = trySubstituteSync(pattern, expression, instruction.replacement, budget, instruction.global ?? false, instruction.occurrence ?? 1);
1094
- const changed = changedOrPromise instanceof Promise ? await changedOrPromise : changedOrPromise;
1095
- pattern = changed.text;
1096
- if (changed.count) {
1097
- substituted = true;
1098
- if (instruction.print) {
1099
- const p = print();
1100
- if (p)
1101
- await p;
1102
- }
1103
- if (instruction.file)
1104
- await writeFile(instruction.file);
1105
- }
1106
- break;
1107
- }
1108
- case "y": {
1109
- // Interpreter strings contain one Latin-1 code unit per input byte.
1110
- budget.step(pattern.length);
1111
- const translated = new Uint8Array(pattern.length);
1112
- for (let index = 0; index < pattern.length; index++) {
1113
- if (index % 256 === 0)
1114
- await budget.checkpointSync();
1115
- translated[index] = (instruction.translation.get(pattern[index]) ?? pattern[index]).charCodeAt(0);
1116
- }
1117
- pattern = decodeBytes(translated, "latin1");
1118
- break;
1119
- }
1120
- case "b":
1121
- pc = instruction.jump;
1122
- continue;
1123
- case "t":
1124
- case "T": {
1125
- const branch = instruction.kind === "t" ? substituted : !substituted;
1126
- substituted = false;
1127
- if (branch) {
1128
- pc = instruction.jump;
1129
- continue;
1130
- }
1131
- break;
1132
- }
1133
- case "n":
1134
- case "N": {
1135
- if (instruction.kind === "n") {
1136
- const p = flush();
1137
- if (p)
1138
- await p;
1139
- }
1140
- else if ((await peekNextRecord()) !== undefined) {
1141
- const p = flush(false);
1142
- if (p)
1143
- await p;
1144
- }
1145
- const next = await readNextRecord();
1146
- if (next === undefined) {
1147
- if (instruction.kind === "N") {
1148
- const p = flush();
1149
- if (p)
1150
- await p;
1151
- }
1152
- return { status: 0, quit: false };
1153
- }
1154
- record = next.terminated || files.length < 2 ? next : await prepareRecord(next);
1155
- number++;
1156
- pattern = instruction.kind === "N" ? joinSpace(pattern, record.text) : record.text;
1157
- substituted = false;
1158
- break;
1159
- }
1160
- }
1161
- pc++;
1162
- }
1163
- const flushPending = flush();
1164
- if (flushPending)
1165
- await flushPending;
1166
- if (quit)
1167
- return { status, quit: true };
1168
- currentRecord = followingRecord === undefined && batchSource && currentBatch && batchIndex < currentBatchLen
1169
- ? fillFromBatch(currentBatch, batchIndex++, sharedBatchRecord)
1170
- : await readNextRecord();
1171
- }
1172
- return { status: 0, quit: false };
1173
- }
1174
- finally {
1175
- try {
1176
- if (stdoutLen > 0)
1177
- await flushStdout();
1178
- if (batchSource)
1179
- await batchSource.return(undefined);
1180
- else if (singleSource)
1181
- await singleSource.return(undefined);
1182
- }
1183
- finally {
1184
- if (usingSharedStdoutBuf)
1185
- sharedSedStdoutBufInUse = false;
1186
- }
1187
- }
1188
- }
1189
- function runSedPairBatchLoopSync(batchText, batchEnds, endsLen, expr0, r1, g1, o1, expr1, r2, g2, o2, budget, stdoutBuf) {
1190
- return trySubstitutePairBatchToBufferSync(batchText, batchEnds, endsLen, expr0, r1, g1, o1, expr1, r2, g2, o2, budget, stdoutBuf, 10, STDOUT_FLUSH);
1191
- }
1192
- function tryExecutePairFastSync(program, context, file, quiet, budget, separator) {
1193
- if (program.length !== 2 || quiet || separator !== "\n" || file === "-")
1194
- return undefined;
1195
- const inst0 = program[0];
1196
- const inst1 = program[1];
1197
- if (inst0.kind !== "s" || inst0.first || inst0.second || inst0.negate || inst0.print || inst0.file || !inst0.pattern ||
1198
- inst1.kind !== "s" || inst1.first || inst1.second || inst1.negate || inst1.print || inst1.file || !inst1.pattern) {
1199
- return undefined;
1200
- }
1201
- const expr0 = inst0.pattern;
1202
- const expr1 = inst1.pattern;
1203
- if (inst0.replacementGroupCount > expr0.groupCount || inst1.replacementGroupCount > expr1.groupCount)
1204
- return undefined;
1205
- const stdoutSync = typeof context.stdout.writeSync === "function"
1206
- ? context.stdout
1207
- : undefined;
1208
- if (!stdoutSync)
1209
- return undefined;
1210
- const fastMem = context._fastMemoryBackingFs;
1211
- if (!fastMem ||
1212
- fastMem.capabilitiesFor !== undefined ||
1213
- context._cachedInputBudget !== undefined ||
1214
- Object.prototype.hasOwnProperty.call(fastMem, "readStream") ||
1215
- Object.prototype.hasOwnProperty.call(fastMem, "readFile")) {
1216
- return undefined;
1217
- }
1218
- const path = pathOf(context, file);
1219
- if (path === "/dev" || path.startsWith("/dev/"))
1220
- return undefined;
1221
- let rawBytes;
1222
- try {
1223
- rawBytes = tryReadMemoryFileViewSync(fastMem, path, undefined, context.signal, true);
1224
- }
1225
- catch (e) {
1226
- console.error('SED_SYNC_ERR:', e);
1227
- return undefined;
1228
- }
1229
- if (!rawBytes || rawBytes.byteLength < 256)
1230
- return undefined;
1231
- const cachedBatch = getCachedLatin1Batch(rawBytes);
1232
- if (!cachedBatch || cachedBatch.lastLineStart !== cachedBatch.text.length || cachedBatch.maxLineLen > budget.maxBufferBytes) {
1233
- return undefined;
1234
- }
1235
- const pending = budget.checkpointSync();
1236
- if (pending) {
1237
- pending.catch(() => { });
1238
- return undefined;
1239
- }
1240
- budget.step();
1241
- let usingSharedStdoutBuf = false;
1242
- let stdoutBuf;
1243
- if (!sharedSedStdoutBufInUse) {
1244
- sharedSedStdoutBufInUse = true;
1245
- usingSharedStdoutBuf = true;
1246
- if (!sharedSedStdoutBuf)
1247
- sharedSedStdoutBuf = new Uint8Array(STDOUT_CAP);
1248
- stdoutBuf = sharedSedStdoutBuf;
1249
- }
1250
- else {
1251
- stdoutBuf = new Uint8Array(STDOUT_CAP);
1252
- }
1253
- const batchText = cachedBatch.text;
1254
- const batchEnds = cachedBatch.ends;
1255
- const endsLen = batchEnds.length;
1256
- const g1 = inst0.global ?? false;
1257
- const o1 = inst0.occurrence ?? 1;
1258
- const r1 = inst0.replacement;
1259
- const g2 = inst1.global ?? false;
1260
- const o2 = inst1.occurrence ?? 1;
1261
- const r2 = inst1.replacement;
1262
- try {
1263
- if (usingSharedStdoutBuf &&
1264
- lastSedPairStdoutIntact &&
1265
- program === lastSedPairProgram &&
1266
- cachedBatch === lastSedPairBatch &&
1267
- (++sedPairBimodalWarm > 4 || (sedPairBimodalWarm & 1) === 1)) {
1268
- budget.step(lastSedPairSteps);
1269
- const pCheck = budget.checkpointSync();
1270
- if (pCheck) {
1271
- pCheck.catch(() => { });
1272
- return undefined;
1273
- }
1274
- context._chargeFastFsOp?.();
1275
- if (lastSedPairStdoutLen > 0) {
1276
- context.signal.throwIfAborted();
1277
- if (lastSedPairSavedOutBuf !== undefined && typeof stdoutSync.writeImmutableSync === "function") {
1278
- stdoutSync.writeImmutableSync(lastSedPairSavedOutBuf);
1279
- }
1280
- else if (typeof stdoutSync.writeRangeSync === "function") {
1281
- stdoutSync.writeRangeSync(stdoutBuf, lastSedPairStdoutLen);
1282
- }
1283
- else {
1284
- stdoutSync.writeSync(new Uint8Array(stdoutBuf.buffer, stdoutBuf.byteOffset, lastSedPairStdoutLen));
1285
- }
1286
- }
1287
- return 0;
1288
- }
1289
- if (usingSharedStdoutBuf)
1290
- lastSedPairStdoutIntact = false;
1291
- const stepsBefore = budget.stepsUsed;
1292
- // Keep the attempt private until every line succeeds. Larger results use
1293
- // the streaming executor without publishing a prefix that it would replay.
1294
- const stdoutLen = runSedPairBatchLoopSync(batchText, batchEnds, endsLen, expr0, r1, g1, o1, expr1, r2, g2, o2, budget, stdoutBuf);
1295
- if (stdoutLen >= 0 && usingSharedStdoutBuf && rawBytes.byteLength >= 1024) {
1296
- lastSedPairProgram = program;
1297
- lastSedPairBatch = cachedBatch;
1298
- lastSedPairStdoutLen = stdoutLen;
1299
- lastSedPairSavedOutBuf = stdoutLen > 0 ? Uint8Array.prototype.slice.call(stdoutBuf, 0, stdoutLen) : undefined;
1300
- lastSedPairSteps = budget.stepsUsed - stepsBefore;
1301
- lastSedPairStdoutIntact = true;
1302
- }
1303
- if (stdoutLen < 0)
1304
- return undefined;
1305
- context._chargeFastFsOp?.();
1306
- if (stdoutLen > 0) {
1307
- context.signal.throwIfAborted();
1308
- if (typeof stdoutSync.writeRangeSync === "function") {
1309
- stdoutSync.writeRangeSync(stdoutBuf, stdoutLen);
1310
- }
1311
- else {
1312
- stdoutSync.writeSync(new Uint8Array(stdoutBuf.buffer, stdoutBuf.byteOffset, stdoutLen));
1313
- }
1314
- }
1315
- return 0;
1316
- }
1317
- finally {
1318
- if (usingSharedStdoutBuf)
1319
- sharedSedStdoutBufInUse = false;
1320
- }
1321
- }
1322
- const SED_META_RE = /[\\^$.*+?()[\]{}|\n]/;
1323
- function tryExecuteSimpleSedStdinSync(rawProg, context, options) {
1324
- if (rawProg.length < 4 || rawProg.length > 256 || rawProg.charCodeAt(0) !== 115)
1325
- return undefined;
1326
- const delim = rawProg[1];
1327
- if (delim === "\\" || delim === "\n")
1328
- return undefined;
1329
- const parts = rawProg.split(delim);
1330
- if (parts.length !== 4)
1331
- return undefined;
1332
- const pat = parts[1];
1333
- const rep = parts[2];
1334
- const flags = parts[3];
1335
- if (pat.length === 0 || (flags !== "" && flags !== "g"))
1336
- return undefined;
1337
- if (SED_META_RE.test(pat) || rep.includes("&") || rep.includes("\\") || rep.includes("\n"))
1338
- return undefined;
1339
- for (let i = 0; i < rawProg.length; i++) {
1340
- if (rawProg.charCodeAt(i) >= 128)
1341
- return undefined;
1342
- }
1343
- const stdinSync = context.stdin;
1344
- const stdoutSync = context.stdout;
1345
- if (typeof stdinSync.tryReadAllSync !== "function" || typeof stdoutSync.writeSync !== "function")
1346
- return undefined;
1347
- const rawBytes = stdinSync.tryReadAllSync();
1348
- if (!rawBytes || rawBytes.byteLength > 16384)
1349
- return undefined;
1350
- for (let i = 0; i < rawBytes.byteLength; i++) {
1351
- const b = rawBytes[i];
1352
- if (b >= 128 || b === 0)
1353
- return undefined;
1354
- }
1355
- const budget = Budget.acquire(context, options);
1356
- try {
1357
- const pCheck = budget.checkpointSync();
1358
- if (pCheck) {
1359
- pCheck.catch(() => { });
1360
- return undefined;
1361
- }
1362
- const text = decodeBytes(encodeBytes(rawBytes.buffer, rawBytes.byteOffset, rawBytes.byteLength), "latin1");
1363
- if (text.length === 0) {
1364
- budget.step(1);
1365
- return 0;
1366
- }
1367
- const hasTrailingNewline = text.charCodeAt(text.length - 1) === 10;
1368
- const body = hasTrailingNewline ? text.slice(0, -1) : text;
1369
- const lines = body.split("\n");
1370
- const isGlobal = flags === "g";
1371
- budget.step(1 + lines.length);
1372
- for (let i = 0; i < lines.length; i++) {
1373
- const line = lines[i];
1374
- if (line.length > budget.maxBufferBytes)
1375
- return undefined;
1376
- const idx = line.indexOf(pat);
1377
- if (idx !== -1) {
1378
- const nextLine = isGlobal ? line.split(pat).join(rep) : line.slice(0, idx) + rep + line.slice(idx + pat.length);
1379
- if (nextLine.length > budget.maxBufferBytes)
1380
- return undefined;
1381
- lines[i] = nextLine;
1382
- }
1383
- }
1384
- const outText = lines.join("\n") + (hasTrailingNewline ? "\n" : "");
1385
- budget.check(outText);
1386
- const outBytes = encodeBytes(outText, "latin1");
1387
- if (!stdoutSync.writeSync(outBytes))
1388
- return undefined;
1389
- return 0;
1390
- }
1391
- catch {
1392
- return undefined;
1393
- }
1394
- finally {
1395
- Budget.release(budget);
1396
- }
1397
- }
1398
- export function sedCommand(options = {}) {
1399
- const maxProgramInstructions = options.maxProgramInstructions === undefined ? Infinity : options.maxProgramInstructions;
1400
- const definition = command("sed", context => {
1401
- if (maxProgramInstructions === Infinity &&
1402
- (context.args.length === 1 || (context.args.length === 2 && context.args[0] === "-e"))) {
1403
- const rawProg = context.args[context.args.length - 1];
1404
- const stdinRes = tryExecuteSimpleSedStdinSync(rawProg, context, options);
1405
- if (stdinRes !== undefined)
1406
- return stdinRes;
1407
- }
1408
- if (maxProgramInstructions === Infinity &&
1409
- context.args.length === 2 &&
1410
- !context.args[0].startsWith("-") &&
1411
- context.args[0] !== "-" &&
1412
- !context.args[1].startsWith("-") &&
1413
- context.args[1] !== "-") {
1414
- const rawProg = context.args[0];
1415
- let cached = sedFastRawCache.get(rawProg);
1416
- if (!cached) {
1417
- const parseBudget = Budget.acquire(context, options);
1418
- try {
1419
- cached = tryParseFastPairProgramSync(rawProg, parseBudget);
1420
- }
1421
- finally {
1422
- Budget.release(parseBudget);
1423
- }
1424
- }
1425
- if (cached && cached.outputFiles.length === 0 && cached.readFiles.length === 0) {
1426
- const quiet = rawProg.charCodeAt(0) === 35 && rawProg.charCodeAt(1) === 110;
1427
- const budget = Budget.acquire(context, options);
1428
- try {
1429
- if (cached.steps > 0)
1430
- budget.step(cached.steps);
1431
- const syncStatus = tryExecutePairFastSync(cached.program, context, context.args[1], quiet, budget, "\n");
1432
- if (syncStatus !== undefined)
1433
- return syncStatus;
1434
- }
1435
- finally {
1436
- Budget.release(budget);
1437
- }
1438
- }
1439
- }
1440
- return executeSedGeneral(context, options, maxProgramInstructions);
1441
- });
1442
- return { ...definition, filesystemRequirements: sedRequirements };
1443
- }
1444
- async function executeSedGeneral(context, options, maxProgramInstructions) {
1445
- if ((maxProgramInstructions !== Infinity && !Number.isSafeInteger(maxProgramInstructions)) || maxProgramInstructions < 1)
1446
- throw new ProgramError("maxProgramInstructions must be a positive safe integer");
1447
- const budget = new Budget(context, options);
1448
- const sources = [];
1449
- const files = [];
1450
- let quiet = false;
1451
- let extended = false;
1452
- let separate = false;
1453
- let lineLength = 70;
1454
- const setLineLength = (value) => {
1455
- if (value === undefined || !value.length || [...value].some(character => character < "0" || character > "9") || !Number.isSafeInteger(Number(value))) {
1456
- throw new ProgramError("line length must be a nonnegative safe integer");
1457
- }
1458
- lineLength = Number(value);
1459
- };
1460
- let separator = "\n";
1461
- let inPlace;
1462
- let ended = false;
1463
- for (let index = 0; index < context.args.length; index++) {
1464
- const argument = context.args[index];
1465
- if (ended || argument === "-" || !argument.startsWith("-")) {
1466
- files.push(argument);
1467
- continue;
1468
- }
1469
- if (argument === "--") {
1470
- ended = true;
1471
- continue;
1472
- }
1473
- if (argument === "--null-data") {
1474
- separator = "\0";
1475
- continue;
1476
- }
1477
- if (argument === "--quiet" || argument === "--silent") {
1478
- quiet = true;
1479
- continue;
1480
- }
1481
- if (argument === "--unbuffered" || argument === "--posix")
1482
- continue;
1483
- if (argument === "--regexp-extended") {
1484
- extended = true;
1485
- continue;
1486
- }
1487
- if (argument === "--in-place" || argument.startsWith("--in-place=")) {
1488
- inPlace = argument === "--in-place" ? "" : argument.slice("--in-place=".length);
1489
- continue;
1490
- }
1491
- if (argument === "--separate") {
1492
- separate = true;
1493
- continue;
1494
- }
1495
- if (argument === "--line-length" || argument.startsWith("--line-length=")) {
1496
- setLineLength(argument === "--line-length" ? context.args[++index] : argument.slice("--line-length=".length));
1497
- continue;
1498
- }
1499
- if (argument === "--expression" || argument.startsWith("--expression=")) {
1500
- const source = argument === "--expression" ? context.args[++index] : argument.slice("--expression=".length);
1501
- if (source === undefined)
1502
- throw new ProgramError("--expression requires an argument");
1503
- sources.push(byteString(source));
1504
- continue;
1505
- }
1506
- if (argument === "--file" || argument.startsWith("--file=")) {
1507
- const source = argument === "--file" ? context.args[++index] : argument.slice("--file=".length);
1508
- if (source === undefined)
1509
- throw new ProgramError("--file requires an argument");
1510
- await assertPathRequirements(context, sedRequirements, ["script-file"], [source]);
1511
- sources.push(await readProgram(context, source));
1512
- continue;
1513
- }
1514
- if (argument.startsWith("--"))
1515
- throw new ProgramError(`unsupported option '${argument}'`);
1516
- for (let position = 1; position < argument.length; position++) {
1517
- const flag = argument[position];
1518
- if (flag === "n")
1519
- quiet = true;
1520
- else if (flag === "u") { /* unbuffered */ }
1521
- else if (flag === "z")
1522
- separator = "\0";
1523
- else if (flag === "E" || flag === "r")
1524
- extended = true;
1525
- else if (flag === "s")
1526
- separate = true;
1527
- else if (flag === "l") {
1528
- setLineLength(argument.slice(position + 1) || context.args[++index]);
1529
- position = argument.length;
1530
- }
1531
- else if (flag === "i") {
1532
- inPlace = argument.slice(position + 1);
1533
- if (!inPlace && context.args[index + 1] === "")
1534
- index++;
1535
- position = argument.length;
1536
- }
1537
- else if (flag === "e" || flag === "f") {
1538
- const source = argument.slice(position + 1) || context.args[++index];
1539
- if (source === undefined)
1540
- throw new ProgramError(`-${flag} requires an argument`);
1541
- if (flag === "f")
1542
- await assertPathRequirements(context, sedRequirements, ["script-file"], [source]);
1543
- sources.push(flag === "f" ? await readProgram(context, source) : byteString(source));
1544
- position = argument.length;
1545
- }
1546
- else
1547
- throw new ProgramError(`unsupported option '-${flag}'`);
1548
- }
1549
- }
1550
- if (!sources.length) {
1551
- if (!files.length)
1552
- throw new ProgramError("missing program");
1553
- sources.push(byteString(files.shift()));
1554
- }
1555
- if (sources[0]?.startsWith("#n"))
1556
- quiet = true;
1557
- const sourceText = sources.length === 1 ? sources[0] : sources.join("\n");
1558
- const canCache = sourceText.length <= 8192;
1559
- const cacheKey = canCache ? `${extended ? 1 : 0}:${separator}:${maxProgramInstructions}:${sourceText}` : "";
1560
- let cached = canCache ? sedProgramCache.get(cacheKey) : undefined;
1561
- if (cached) {
1562
- if (cached.steps > 0)
1563
- budget.step(cached.steps);
1564
- }
1565
- else {
1566
- const stepsBefore = budget.stepsUsed;
1567
- const parsedProgram = await parse(sourceText, extended, separator, maxProgramInstructions, budget);
1568
- const steps = budget.stepsUsed - stepsBefore;
1569
- let outFiles;
1570
- let rdFiles;
1571
- for (let i = 0; i < parsedProgram.length; i++) {
1572
- const inst = parsedProgram[i];
1573
- if (inst.file !== undefined) {
1574
- if (inst.kind === "r")
1575
- (rdFiles ??= []).push(inst.file);
1576
- else
1577
- (outFiles ??= []).push(inst.file);
1578
- }
1579
- }
1580
- cached = {
1581
- program: parsedProgram,
1582
- steps,
1583
- outputFiles: outFiles ?? EMPTY_STRINGS,
1584
- readFiles: rdFiles ?? EMPTY_STRINGS,
1585
- };
1586
- if (canCache) {
1587
- if (sedProgramCache.size >= 64)
1588
- sedProgramCache.delete(sedProgramCache.keys().next().value);
1589
- sedProgramCache.set(cacheKey, cached);
1590
- if (!extended && separator === "\n" && maxProgramInstructions === Infinity && sources.length === 1)
1591
- sedFastRawCache.set(sources[0], cached);
1592
- }
1593
- }
1594
- const { program, outputFiles, readFiles } = cached;
1595
- if (outputFiles.length > 0) {
1596
- await assertPathRequirements(context, sedRequirements, ["script-output"], outputFiles);
1597
- }
1598
- if (inPlace !== undefined || outputFiles.length > 0) {
1599
- await assertPathRequirements(context, sedRequirements, ["file"], files.filter(file => file !== "-"));
1600
- if (readFiles.length > 0) {
1601
- await assertPathRequirements(context, sedRequirements, ["script-read"], readFiles);
1602
- }
1603
- }
1604
- const prepareOutputs = async () => {
1605
- if (outputFiles.length === 0)
1606
- return;
1607
- const paths = new Set(outputFiles.map(file => virtualPath(context, file)));
1608
- for (const path of paths)
1609
- await writeFileOutput(context, new Uint8Array(), chunk => context.fs.writeFile(path, chunk, { signal: context.signal }));
1610
- };
1611
- const outputState = { stdoutUnterminated: false, unterminatedFiles: outputFiles.length > 0 ? new Set() : EMPTY_SET };
1612
- if (inPlace !== undefined) {
1613
- if (!files.length || files.includes("-"))
1614
- throw new ProgramError("in-place editing requires named files");
1615
- if (inPlace.includes("/") || inPlace.includes("\0"))
1616
- throw new ProgramError("backup suffix cannot contain '/' or NUL");
1617
- await assertPathRequirements(context, sedRequirements, ["in-place"], files);
1618
- if (inPlace)
1619
- await assertPathRequirements(context, sedRequirements, ["backup"], files.flatMap(file => [file, file + inPlace]));
1620
- const targets = await prepareInPlace(context, files, inPlace);
1621
- if (outputFiles.length > 0)
1622
- await prepareOutputs();
1623
- for (const target of targets) {
1624
- const result = await editInPlace(context, target, inPlace, budget, async (stdin) => {
1625
- let rewritten = "";
1626
- const child = Object.assign(Object.create(Object.getPrototypeOf(context)), context, { stdin, stdout: { async write(chunk) { rewritten = budget.check(rewritten + decodeBytes(encodeBytes(chunk), "latin1")); } } });
1627
- outputState.stdoutUnterminated = false;
1628
- const result = await execute(program, child, ["-"], quiet, budget, separator, outputState, lineLength);
1629
- return { result, data: bytes(rewritten) };
1630
- });
1631
- if (result.quit || result.status)
1632
- return result.status;
1633
- }
1634
- return 0;
1635
- }
1636
- if (outputFiles.length > 0)
1637
- await prepareOutputs();
1638
- if (separate) {
1639
- for (const file of files.length ? files : ["-"]) {
1640
- const result = await execute(program, context, [file], quiet, budget, separator, outputState, lineLength);
1641
- if (result.quit || result.status)
1642
- return result.status;
1643
- }
1644
- return 0;
1645
- }
1646
- return (await execute(program, context, files, quiet, budget, separator, outputState, lineLength)).status;
1647
- }
1
+ export * from "../../../safe-bash-command-sed/sed.js";
1648
2
  //# sourceMappingURL=sed.js.map