@poe-platform/safe-bash 0.1.803 → 0.1.804

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 (696) hide show
  1. package/README.md +56 -31
  2. package/dist/image-ast/ast.d.ts +1 -0
  3. package/dist/image-ast/browser/ast.d.ts +1 -0
  4. package/dist/image-ast/browser/codecs/jpeg.d.ts +2 -2
  5. package/dist/image-ast/codecs/jpeg.d.ts +2 -2
  6. package/dist/image-ast/index.browser.js +692 -8364
  7. package/dist/image-ast/index.js +692 -8364
  8. package/dist/mp4-ast/codecs.d.ts +7 -2
  9. package/dist/safe-bash/chunks/{chunk-CHYGPFVM.js → chunk-22SX3F2R.js} +1 -1
  10. package/dist/safe-bash/chunks/{chunk-FBUCWVTE.js → chunk-2IVBJTBD.js} +1 -1
  11. package/dist/safe-bash/chunks/chunk-2POETUMB.js +190 -0
  12. package/dist/safe-bash/chunks/{chunk-XVOSKJE2.js → chunk-47D7WBJK.js} +1 -1
  13. package/dist/safe-bash/chunks/{chunk-VKNVHEX3.js → chunk-4ESI236Y.js} +1 -1
  14. package/dist/safe-bash/chunks/{chunk-74GHTNJA.js → chunk-4KTMKD5W.js} +1 -1
  15. package/dist/safe-bash/chunks/{chunk-55YJASTN.js → chunk-4T53AERN.js} +1 -1
  16. package/dist/safe-bash/chunks/{chunk-DQP3VHSB.js → chunk-5XIFJVOO.js} +1 -1
  17. package/dist/safe-bash/chunks/{chunk-5OHX7C2V.js → chunk-62BOHHJT.js} +1 -1
  18. package/dist/safe-bash/chunks/{chunk-HZAMGT5I.js → chunk-67WIFM3N.js} +17 -6
  19. package/dist/safe-bash/chunks/{chunk-4D4N7IU2.js → chunk-6LNFRPW5.js} +2 -2
  20. package/dist/safe-bash/chunks/{chunk-6O77NL2S.js → chunk-6SMICPI3.js} +1 -1
  21. package/dist/safe-bash/chunks/{chunk-4BSJLKNM.js → chunk-7O76UFQD.js} +1 -1
  22. package/dist/safe-bash/chunks/{chunk-PNBBUWSM.js → chunk-AW5KIT6V.js} +3488 -39
  23. package/dist/safe-bash/chunks/{chunk-JMMEIDPF.js → chunk-B2Z73HTZ.js} +52 -28
  24. package/dist/safe-bash/chunks/chunk-B3ZMOJVM.js +319 -0
  25. package/dist/safe-bash/chunks/{chunk-7ZBU7KYV.js → chunk-CFAWS3O4.js} +1 -1
  26. package/dist/safe-bash/chunks/{chunk-I5HZ4FGE.js → chunk-CL2FCTTO.js} +1 -1
  27. package/dist/safe-bash/chunks/{chunk-2LSAMQER.js → chunk-CTXNARJH.js} +1 -1
  28. package/dist/safe-bash/chunks/{chunk-TFIBK2GI.js → chunk-D5Q7NFWI.js} +1 -1
  29. package/dist/safe-bash/chunks/{chunk-OQRVVGR6.js → chunk-DSOOVZ6Q.js} +1 -1
  30. package/dist/safe-bash/chunks/{chunk-VTH3MLDU.js → chunk-DUTAG6ZD.js} +1 -1
  31. package/dist/safe-bash/chunks/{chunk-XAQMU6OY.js → chunk-EE5YGFIZ.js} +1 -1
  32. package/dist/safe-bash/chunks/{chunk-FZE4HW6G.js → chunk-EJOYT2ME.js} +1 -1
  33. package/dist/safe-bash/chunks/chunk-FAAIR6EJ.js +887 -0
  34. package/dist/safe-bash/chunks/{chunk-OV6IHKO6.js → chunk-FOB2FZR4.js} +2 -2
  35. package/dist/safe-bash/chunks/chunk-G6V4RRSQ.js +14 -0
  36. package/dist/safe-bash/chunks/{chunk-UTBUUFDM.js → chunk-GGQAGQXQ.js} +1 -1
  37. package/dist/safe-bash/chunks/{chunk-K6VCD7IY.js → chunk-HIIYIJ5G.js} +2 -4
  38. package/dist/safe-bash/chunks/{chunk-VBTDHOWC.js → chunk-IOHH2GTI.js} +4 -3
  39. package/dist/safe-bash/chunks/{chunk-CTVWDACF.js → chunk-IQW34XQT.js} +1 -1
  40. package/dist/safe-bash/chunks/{chunk-HZ7BWKQ3.js → chunk-IS572AAT.js} +1 -1
  41. package/dist/safe-bash/chunks/{chunk-AUSNDQTJ.js → chunk-JPSUHHOA.js} +1 -1
  42. package/dist/safe-bash/chunks/{chunk-ZVD5IS4V.js → chunk-KBZ4UB2O.js} +2 -2
  43. package/dist/safe-bash/chunks/{chunk-AM5ESLPH.js → chunk-KU5CVWKA.js} +1 -1
  44. package/dist/safe-bash/chunks/{chunk-RYFQ3LZG.js → chunk-LPOVNKNB.js} +173 -153
  45. package/dist/safe-bash/chunks/{chunk-46Z5E5EV.js → chunk-MBOC3LZ4.js} +1 -1
  46. package/dist/safe-bash/chunks/{chunk-6PAVEFT3.js → chunk-N4BQFD3P.js} +1 -1
  47. package/dist/safe-bash/chunks/{chunk-CS4MNM6I.js → chunk-NGKCVNWS.js} +1 -1
  48. package/dist/safe-bash/chunks/{chunk-7R5BDCG7.js → chunk-OHML2BEU.js} +1 -1
  49. package/dist/safe-bash/chunks/{chunk-C5OWC2TL.js → chunk-OQ3AGYCZ.js} +1 -1
  50. package/dist/safe-bash/chunks/{chunk-B7TAL7S5.js → chunk-PTAEWLSE.js} +0 -2
  51. package/dist/safe-bash/chunks/{chunk-LVOBFF4D.js → chunk-Q4FNLOTI.js} +1 -1
  52. package/dist/safe-bash/chunks/chunk-Q5XO3NAS.js +1036 -0
  53. package/dist/safe-bash/chunks/{chunk-GEG3BWGE.js → chunk-RHFRJIWQ.js} +1 -1
  54. package/dist/safe-bash/chunks/chunk-RUR6J33T.js +11 -0
  55. package/dist/safe-bash/chunks/{chunk-EEEWOYEG.js → chunk-S4RFUUXO.js} +839 -24
  56. package/dist/safe-bash/chunks/{chunk-RRR7AQ24.js → chunk-SD2ISU5L.js} +1 -1
  57. package/dist/safe-bash/chunks/{chunk-3NDIFSNM.js → chunk-SUJ3NTMH.js} +3 -3
  58. package/dist/safe-bash/chunks/{chunk-R3NAKOED.js → chunk-SZRUU5HS.js} +2 -2
  59. package/dist/safe-bash/chunks/{chunk-PH63PLPZ.js → chunk-TC3F4UFF.js} +1 -1
  60. package/dist/safe-bash/chunks/{chunk-3R3AANOR.js → chunk-TCKYOLUE.js} +1 -1
  61. package/dist/safe-bash/chunks/{chunk-D3ANYGMC.js → chunk-UV4X32QU.js} +1 -1
  62. package/dist/safe-bash/chunks/{chunk-E7OYNDGL.js → chunk-V7QT2RWC.js} +1 -1
  63. package/dist/safe-bash/chunks/{chunk-B7PIL77G.js → chunk-W2IYOVHK.js} +804 -1195
  64. package/dist/safe-bash/chunks/{chunk-3HQU4OJO.js → chunk-XNGVOSGI.js} +1 -1
  65. package/dist/safe-bash/chunks/{chunk-J42RIHHJ.js → chunk-XQWCQSRN.js} +1 -1
  66. package/dist/safe-bash/chunks/{chunk-A7XEHALN.js → chunk-Y7FW6GLT.js} +6 -6
  67. package/dist/safe-bash/chunks/{chunk-QGUV42T5.js → chunk-YL3GBUG4.js} +1 -1
  68. package/dist/safe-bash/chunks/chunk-YOXUCJER.js +389 -0
  69. package/dist/safe-bash/chunks/{chunk-HBCN24ZA.js → chunk-Z2AAYYJN.js} +2 -2
  70. package/dist/safe-bash/chunks/chunk-ZKYKJCZZ.js +30 -0
  71. package/dist/safe-bash/chunks/core-IE3AFIDX.js +85806 -0
  72. package/dist/safe-bash/chunks/{ffmpeg-WTC3TEFI.js → ffmpeg-YANDK6HU.js} +2 -2
  73. package/dist/safe-bash/chunks/{gh-6WU6PXL4.js → gh-4MBJ2S5V.js} +2 -2
  74. package/dist/safe-bash/chunks/{git-EFZIGJW4.js → git-2QONJNRQ.js} +2 -2
  75. package/dist/safe-bash/chunks/{imagemagick-EIEYGWPF.js → imagemagick-JLEHGYSN.js} +2 -2
  76. package/dist/safe-bash/chunks/{mmdc-ROQJT5HQ.js → mmdc-6LD7A6ND.js} +2 -2
  77. package/dist/safe-bash/chunks/{pdfimages-DW7LWXFI.js → pdfimages-RSHL7LOP.js} +2 -2
  78. package/dist/safe-bash/chunks/{pdfinfo-TIP6XLUQ.js → pdfinfo-L3SGWPNG.js} +2 -2
  79. package/dist/safe-bash/chunks/{pdftk-DMG22ITZ.js → pdftk-LFBJNU5A.js} +2 -2
  80. package/dist/safe-bash/chunks/{pdftoppm-WNDYR72T.js → pdftoppm-NXXFUIHG.js} +2 -2
  81. package/dist/safe-bash/chunks/{pdftotext-5IPZ4NI7.js → pdftotext-4IHNWT6F.js} +2 -2
  82. package/dist/safe-bash/chunks/{qpdf-TTX2DIUA.js → qpdf-ZEIREV63.js} +2 -2
  83. package/dist/safe-bash/chunks/read-builtin-A4QKAT45.js +9 -0
  84. package/dist/safe-bash/chunks/{sips-XYS46JPJ.js → sips-D5YBG2V3.js} +2 -2
  85. package/dist/safe-bash/chunks/{soffice-TU73E5KL.js → soffice-RAJU3JUT.js} +2 -2
  86. package/dist/safe-bash/chunks/source-files-3XWRRHFA.js +7 -0
  87. package/dist/safe-bash/chunks/{wkhtmltopdf-FSZ2CHGE.js → wkhtmltopdf-7UE4FORZ.js} +2 -2
  88. package/dist/safe-bash/command-chunks/{chunk-7KWZXKY6.js → chunk-26RTBV2I.js} +1 -0
  89. package/dist/safe-bash/command-chunks/{chunk-AQJ2ROJO.js → chunk-2WYNMZR2.js} +10 -8
  90. package/dist/safe-bash/command-chunks/{chunk-BDSMROQZ.js → chunk-36GFRF2N.js} +2 -1
  91. package/dist/safe-bash/command-chunks/{chunk-GC5TJZOF.js → chunk-3VIA2IA7.js} +114 -31
  92. package/dist/safe-bash/command-chunks/{chunk-NKFYQSES.js → chunk-4CTI3ZTX.js} +1 -0
  93. package/dist/safe-bash/command-chunks/{chunk-WH627NJL.js → chunk-4MYP2FX4.js} +2 -1
  94. package/dist/safe-bash/command-chunks/{chunk-ZDN7MJE6.js → chunk-4R5ADJM5.js} +11 -1
  95. package/dist/safe-bash/command-chunks/{chunk-P2N33UMN.js → chunk-5MIKM54M.js} +4 -4
  96. package/dist/safe-bash/command-chunks/{chunk-DB453IE6.js → chunk-6FZQUOSJ.js} +1 -1
  97. package/dist/safe-bash/command-chunks/{chunk-PICVQ6B5.js → chunk-6GKYHPJG.js} +1 -1
  98. package/dist/safe-bash/command-chunks/{chunk-7K6JYKPJ.js → chunk-6M2ELGEN.js} +17 -15
  99. package/dist/safe-bash/command-chunks/{chunk-PXEIT2O4.js → chunk-6UR7V3ET.js} +8 -1
  100. package/dist/safe-bash/command-chunks/{chunk-6KJ3LPI2.js → chunk-6XBS5B46.js} +26 -3
  101. package/dist/safe-bash/command-chunks/{chunk-5PWJG2UK.js → chunk-6YXLZX7L.js} +2 -2
  102. package/dist/safe-bash/command-chunks/{chunk-EK6YNAXT.js → chunk-753YOR54.js} +31 -5
  103. package/dist/safe-bash/command-chunks/{chunk-RMWQAAO5.js → chunk-7IR4NRNE.js} +2 -2
  104. package/dist/safe-bash/command-chunks/{chunk-FZTK4MFI.js → chunk-7NM73SVK.js} +8 -8
  105. package/dist/safe-bash/command-chunks/{chunk-NXEQ3ESQ.js → chunk-7QD5YY4F.js} +6 -11
  106. package/dist/safe-bash/command-chunks/{chunk-EMPU65ZK.js → chunk-A5LBSJGH.js} +1 -0
  107. package/dist/safe-bash/command-chunks/{chunk-4FEVBOL5.js → chunk-ARZMP2L2.js} +2 -2
  108. package/dist/safe-bash/command-chunks/{chunk-NKIELG7Y.js → chunk-BAKFZ477.js} +40 -19
  109. package/dist/safe-bash/command-chunks/{chunk-QRRYN2KO.js → chunk-BC7BK6R6.js} +0 -2424
  110. package/dist/safe-bash/command-chunks/{chunk-CQHP3I66.js → chunk-BOEOJS2Q.js} +1 -1
  111. package/dist/safe-bash/command-chunks/{chunk-XS72HTMA.js → chunk-BWGGLYEB.js} +5 -22
  112. package/dist/safe-bash/command-chunks/{chunk-PMBFZXTK.js → chunk-C5ZZKP7V.js} +1 -1
  113. package/dist/safe-bash/command-chunks/{chunk-LHIOAFWW.js → chunk-C7SEB6WU.js} +1 -1
  114. package/dist/safe-bash/command-chunks/{chunk-XPT2UGBF.js → chunk-CHJKFRT7.js} +1 -1
  115. package/dist/safe-bash/command-chunks/{chunk-TIOCQVUQ.js → chunk-CON26Q2O.js} +1 -1
  116. package/dist/safe-bash/command-chunks/{chunk-E55UKBIE.js → chunk-DBAT3IK2.js} +1 -1
  117. package/dist/safe-bash/command-chunks/{chunk-Z45N42QC.js → chunk-DPAYAVMS.js} +15 -1
  118. package/dist/safe-bash/command-chunks/chunk-DS3NXVUM.js +368 -0
  119. package/dist/safe-bash/command-chunks/{chunk-5ZMZ573Q.js → chunk-DSJ3VRL3.js} +16 -4
  120. package/dist/safe-bash/command-chunks/{chunk-K2GDEMEU.js → chunk-EFRCFWVR.js} +4 -4
  121. package/dist/safe-bash/command-chunks/{chunk-DZCY63VJ.js → chunk-EV6HIJ5H.js} +6 -5
  122. package/dist/safe-bash/command-chunks/{chunk-JDYXY44P.js → chunk-FJURV46Y.js} +3 -3
  123. package/dist/safe-bash/command-chunks/{chunk-TZZ4WUKH.js → chunk-FZAWGKSE.js} +6 -4
  124. package/dist/safe-bash/command-chunks/{chunk-YHFXOX6U.js → chunk-GOCFQ6XV.js} +4 -4
  125. package/dist/safe-bash/command-chunks/{chunk-QVOS4YXL.js → chunk-HH5O7DJI.js} +1 -1
  126. package/dist/safe-bash/command-chunks/{chunk-3HHCU5YU.js → chunk-HK7F5SDC.js} +13 -0
  127. package/dist/safe-bash/command-chunks/{chunk-JNZ3CVAE.js → chunk-HQBXIZC7.js} +8 -3
  128. package/dist/safe-bash/command-chunks/{chunk-V4K2JDYU.js → chunk-I63DBZXZ.js} +2 -2
  129. package/dist/safe-bash/command-chunks/{chunk-WNE7FPVR.js → chunk-I64TLTIW.js} +24 -16
  130. package/dist/safe-bash/command-chunks/{chunk-GFC2NTDG.js → chunk-ICANWOXH.js} +5 -29
  131. package/dist/safe-bash/command-chunks/{chunk-SQRQW3CT.js → chunk-IJ6LGLXM.js} +1 -1
  132. package/dist/safe-bash/command-chunks/{chunk-TGSNCQSR.js → chunk-JT4RYCA6.js} +1771 -1663
  133. package/dist/safe-bash/command-chunks/{chunk-II77KPZN.js → chunk-JWW6FYBN.js} +2 -2
  134. package/dist/safe-bash/command-chunks/{chunk-ZYXH3B66.js → chunk-LCJWKTCJ.js} +250 -203
  135. package/dist/safe-bash/command-chunks/chunk-LU4HBPP2.js +97 -0
  136. package/dist/safe-bash/command-chunks/{chunk-XJXU3VVH.js → chunk-LWOE65OE.js} +20 -5
  137. package/dist/safe-bash/command-chunks/{chunk-GMIHJYDG.js → chunk-M32HFSX7.js} +22 -6
  138. package/dist/safe-bash/command-chunks/{chunk-YG4EPFWC.js → chunk-M3NINRDU.js} +2880 -172
  139. package/dist/safe-bash/command-chunks/chunk-MQREDAL6.js +164 -0
  140. package/dist/safe-bash/command-chunks/{chunk-LWS62ISU.js → chunk-N6DIASO2.js} +1 -1
  141. package/dist/safe-bash/command-chunks/chunk-NGL7YK7O.js +188 -0
  142. package/dist/safe-bash/command-chunks/{chunk-EARHPPPJ.js → chunk-NJYHWKIL.js} +39 -9
  143. package/dist/safe-bash/command-chunks/{chunk-6JSIFWYT.js → chunk-OJQRSCBP.js} +1 -1
  144. package/dist/safe-bash/command-chunks/{chunk-OQU6UT6X.js → chunk-OV3XREFN.js} +11 -0
  145. package/dist/safe-bash/command-chunks/{chunk-MIXBO6U7.js → chunk-PTZLF456.js} +2 -2
  146. package/dist/safe-bash/command-chunks/{chunk-ALDC4XP4.js → chunk-QILLRNES.js} +34 -10
  147. package/dist/safe-bash/command-chunks/{chunk-L22T3H7L.js → chunk-QR25JLKO.js} +1 -1
  148. package/dist/safe-bash/command-chunks/{chunk-NASVPT6F.js → chunk-R7C4MGZ5.js} +17 -224
  149. package/dist/safe-bash/command-chunks/{chunk-LCF3OB7P.js → chunk-RBME3JEH.js} +1 -1
  150. package/dist/safe-bash/command-chunks/{chunk-2KG2QLJE.js → chunk-RFWGYT7G.js} +3 -0
  151. package/dist/safe-bash/command-chunks/{chunk-5TBUOBDE.js → chunk-RZMVRT26.js} +27 -13
  152. package/dist/safe-bash/command-chunks/chunk-TFR6B3WB.js +44 -0
  153. package/dist/safe-bash/command-chunks/chunk-TOH3OF3O.js +179 -0
  154. package/dist/safe-bash/command-chunks/chunk-TT4DAFBT.js +13621 -0
  155. package/dist/safe-bash/command-chunks/{chunk-LWSBAWLT.js → chunk-TXI64OAG.js} +1 -1
  156. package/dist/safe-bash/command-chunks/{chunk-GIRNFXP3.js → chunk-TZRI7BJZ.js} +45 -15
  157. package/dist/safe-bash/command-chunks/{chunk-QOKBZFFD.js → chunk-U3MMODA5.js} +2 -7
  158. package/dist/safe-bash/command-chunks/{chunk-ZYHTWNAE.js → chunk-UAW423ZL.js} +11 -11
  159. package/dist/safe-bash/command-chunks/{chunk-C5YYCQHW.js → chunk-UXEEUGOV.js} +222 -12
  160. package/dist/safe-bash/command-chunks/{chunk-GY3BWK7K.js → chunk-VOZPMJRX.js} +87 -80
  161. package/dist/safe-bash/command-chunks/{chunk-ILX2NOLF.js → chunk-WPANOB4A.js} +20 -20
  162. package/dist/safe-bash/command-chunks/{chunk-Y2WBSJG6.js → chunk-X4QZQI5Q.js} +65 -64
  163. package/dist/safe-bash/command-chunks/{chunk-HDCNKOIX.js → chunk-XGI57GCN.js} +1 -1
  164. package/dist/safe-bash/command-chunks/{chunk-5UBXNSFZ.js → chunk-XUCU7QQT.js} +1281 -1278
  165. package/dist/safe-bash/command-chunks/chunk-Y22VXJBD.js +296 -0
  166. package/dist/safe-bash/command-chunks/{chunk-WVHONVZ4.js → chunk-YMFUUPDX.js} +5 -3
  167. package/dist/safe-bash/command-chunks/{chunk-IR2BY7EL.js → chunk-YYGIBXFZ.js} +2 -2
  168. package/dist/safe-bash/command-chunks/{chunk-MSFXC3OC.js → chunk-Z4FO6OHE.js} +2 -2
  169. package/dist/safe-bash/command-chunks/{chunk-WWIBP2ET.js → chunk-Z5ZZVDUD.js} +143 -22
  170. package/dist/safe-bash/command-chunks/{chunk-LOICUCHG.js → chunk-ZHN3QDCI.js} +1 -1
  171. package/dist/safe-bash/commands/alias/index.d.ts +2 -0
  172. package/dist/safe-bash/commands/alias/index.js +2 -0
  173. package/dist/safe-bash/commands/apply-patch/index.browser.js +2 -3
  174. package/dist/safe-bash/commands/apply-patch/index.d.ts +0 -1
  175. package/dist/safe-bash/commands/apply-patch/index.js +0 -1
  176. package/dist/safe-bash/commands/archive/index.browser.js +2 -3
  177. package/dist/safe-bash/commands/archive/index.d.ts +0 -1
  178. package/dist/safe-bash/commands/archive/index.js +0 -1
  179. package/dist/safe-bash/commands/bytes/index.js +2 -1
  180. package/dist/safe-bash/commands/chmod/index.browser.js +1 -1
  181. package/dist/safe-bash/commands/column/index.browser.js +2 -3
  182. package/dist/safe-bash/commands/column/index.d.ts +0 -1
  183. package/dist/safe-bash/commands/column/index.js +0 -1
  184. package/dist/safe-bash/commands/copy-source.js +1 -0
  185. package/dist/safe-bash/commands/csplit/index.browser.js +2 -2
  186. package/dist/safe-bash/commands/csvkit/index.browser.js +72 -0
  187. package/dist/safe-bash/commands/csvkit/index.d.ts +0 -5
  188. package/dist/safe-bash/commands/csvkit/index.js +0 -50
  189. package/dist/safe-bash/commands/docx/index.browser.js +5 -7
  190. package/dist/safe-bash/commands/du/index.browser.js +2 -3
  191. package/dist/safe-bash/commands/du/index.d.ts +0 -1
  192. package/dist/safe-bash/commands/du/index.js +0 -1
  193. package/dist/safe-bash/commands/expr/index.browser.js +2 -3
  194. package/dist/safe-bash/commands/expr/index.d.ts +0 -1
  195. package/dist/safe-bash/commands/expr/index.js +0 -1
  196. package/dist/safe-bash/commands/factor/index.browser.js +2 -2
  197. package/dist/safe-bash/commands/file/index.browser.js +2 -3
  198. package/dist/safe-bash/commands/file/index.d.ts +0 -1
  199. package/dist/safe-bash/commands/file/index.js +0 -1
  200. package/dist/safe-bash/commands/filesystem.js +1 -1
  201. package/dist/safe-bash/commands/getopt/index.browser.js +2 -2
  202. package/dist/safe-bash/commands/grep-aliases/index.browser.js +3 -3
  203. package/dist/safe-bash/commands/hexdump/index.browser.js +2 -2
  204. package/dist/safe-bash/commands/html-to-markdown/index.browser.js +2 -3
  205. package/dist/safe-bash/commands/html-to-markdown/index.d.ts +0 -1
  206. package/dist/safe-bash/commands/html-to-markdown/index.js +0 -1
  207. package/dist/safe-bash/commands/htmlq/index.d.ts +1 -5
  208. package/dist/safe-bash/commands/htmlq/index.js +1 -143
  209. package/dist/safe-bash/commands/iconv/index.browser.js +2 -2
  210. package/dist/safe-bash/commands/line-endings/index.browser.js +2 -2
  211. package/dist/safe-bash/commands/llm/index.browser.js +2 -2
  212. package/dist/safe-bash/commands/llm/providers/index.browser.js +1 -1
  213. package/dist/safe-bash/commands/mdq/index.browser.js +3 -3
  214. package/dist/safe-bash/commands/media/index.browser.js +4 -16314
  215. package/dist/safe-bash/commands/media/index.d.ts +1 -5
  216. package/dist/safe-bash/commands/media/index.js +1 -3
  217. package/dist/safe-bash/commands/media/plugin.d.ts +1 -18
  218. package/dist/safe-bash/commands/media/plugin.js +1 -90
  219. package/dist/safe-bash/commands/media/remote.d.ts +1 -63
  220. package/dist/safe-bash/commands/media/remote.js +1 -405
  221. package/dist/safe-bash/commands/media/settings.d.ts +1 -4
  222. package/dist/safe-bash/commands/media/settings.js +1 -26
  223. package/dist/safe-bash/commands/metadata/index.browser.js +3 -4
  224. package/dist/safe-bash/commands/metadata/index.d.ts +0 -1
  225. package/dist/safe-bash/commands/metadata/index.js +2 -2
  226. package/dist/safe-bash/commands/mktemp/index.browser.js +1 -1
  227. package/dist/safe-bash/commands/network/curl.js +1 -3
  228. package/dist/safe-bash/commands/network/index.browser.js +3 -4
  229. package/dist/safe-bash/commands/network/public.d.ts +0 -1
  230. package/dist/safe-bash/commands/network/public.js +0 -1
  231. package/dist/safe-bash/commands/network/transport.js +2 -1
  232. package/dist/safe-bash/commands/network/wget.js +1 -3
  233. package/dist/safe-bash/commands/node/browser.d.ts +0 -1
  234. package/dist/safe-bash/commands/node/browser.js +0 -1
  235. package/dist/safe-bash/commands/node/default-runtime.d.ts +3 -0
  236. package/dist/safe-bash/commands/node/default-runtime.js +15 -0
  237. package/dist/safe-bash/commands/node/index.browser.js +7 -8
  238. package/dist/safe-bash/commands/node/index.js +3 -3
  239. package/dist/safe-bash/commands/node/path.js +1 -1
  240. package/dist/safe-bash/commands/node/preload.d.ts +1 -1
  241. package/dist/safe-bash/commands/node/preload.js +4 -1
  242. package/dist/safe-bash/commands/node/quickjs.d.ts +2 -0
  243. package/dist/safe-bash/commands/node/quickjs.js +2 -0
  244. package/dist/safe-bash/commands/node/safejs.js +26 -12
  245. package/dist/safe-bash/commands/op/index.browser.js +2 -3
  246. package/dist/safe-bash/commands/op/index.d.ts +0 -11
  247. package/dist/safe-bash/commands/op/index.js +0 -84
  248. package/dist/safe-bash/commands/pandoc/index.browser.js +44 -0
  249. package/dist/safe-bash/commands/pandoc/index.d.ts +0 -1
  250. package/dist/safe-bash/commands/pandoc/index.js +0 -1
  251. package/dist/safe-bash/commands/pr/index.browser.js +2 -2
  252. package/dist/safe-bash/commands/python/docker-runner.js +4 -3
  253. package/dist/safe-bash/commands/python/docker.d.ts +1 -0
  254. package/dist/safe-bash/commands/python/docker.js +5 -2
  255. package/dist/safe-bash/commands/python/index.browser.js +17 -13
  256. package/dist/safe-bash/commands/python/index.d.ts +2 -1
  257. package/dist/safe-bash/commands/python/index.js +10 -8
  258. package/dist/safe-bash/commands/python/llm-capability.js +65 -2
  259. package/dist/safe-bash/commands/python/llm-dependencies.d.ts +27 -0
  260. package/dist/safe-bash/commands/python/llm-dependencies.js +66 -0
  261. package/dist/safe-bash/commands/python/llm-module.js +6 -4
  262. package/dist/safe-bash/commands/python/llm-reference-module.d.ts +3 -0
  263. package/dist/safe-bash/commands/python/llm-reference-module.js +690 -0
  264. package/dist/safe-bash/commands/python/worker.browser.js +2 -3
  265. package/dist/safe-bash/commands/python/worker.d.ts +0 -1
  266. package/dist/safe-bash/commands/python/worker.js +0 -1
  267. package/dist/safe-bash/commands/regex-execution/ere/transport/wire-engine.d.ts +1 -1
  268. package/dist/safe-bash/commands/regex-execution/ere/transport/wire-engine.js +3 -3
  269. package/dist/safe-bash/commands/regex-execution/public.browser.js +7 -7
  270. package/dist/safe-bash/commands/safejs/options.js +5 -1
  271. package/dist/safe-bash/commands/safejs/runtime.d.ts +1 -0
  272. package/dist/safe-bash/commands/safejs/runtime.js +1 -1
  273. package/dist/safe-bash/commands/split/index.browser.js +2 -3
  274. package/dist/safe-bash/commands/split/index.d.ts +0 -1
  275. package/dist/safe-bash/commands/split/index.js +0 -1
  276. package/dist/safe-bash/commands/ssconvert/index.browser.js +98 -0
  277. package/dist/safe-bash/commands/stat/index.browser.js +1 -1
  278. package/dist/safe-bash/commands/stream-format/index.browser.js +3 -4
  279. package/dist/safe-bash/commands/stream-format/index.d.ts +0 -1
  280. package/dist/safe-bash/commands/stream-format/index.js +0 -1
  281. package/dist/safe-bash/commands/stream-inspection/index.browser.js +3 -4
  282. package/dist/safe-bash/commands/stream-inspection/index.d.ts +0 -1
  283. package/dist/safe-bash/commands/stream-inspection/index.js +0 -1
  284. package/dist/safe-bash/commands/streams.js +2 -1
  285. package/dist/safe-bash/commands/table-text/index.browser.js +3 -4
  286. package/dist/safe-bash/commands/table-text/index.d.ts +0 -1
  287. package/dist/safe-bash/commands/table-text/index.js +0 -1
  288. package/dist/safe-bash/commands/text.js +28 -24
  289. package/dist/safe-bash/commands/time-env/index.browser.js +3 -4
  290. package/dist/safe-bash/commands/time-env/index.d.ts +0 -1
  291. package/dist/safe-bash/commands/time-env/index.js +0 -1
  292. package/dist/safe-bash/commands/tree/index.browser.js +2 -3
  293. package/dist/safe-bash/commands/tree/index.d.ts +0 -1
  294. package/dist/safe-bash/commands/tree/index.js +0 -1
  295. package/dist/safe-bash/commands/tsort/index.browser.js +2 -2
  296. package/dist/safe-bash/commands/unalias/index.d.ts +2 -0
  297. package/dist/safe-bash/commands/unalias/index.js +2 -0
  298. package/dist/safe-bash/commands/xml/index.browser.js +2 -2
  299. package/dist/safe-bash/commands/yq/index.browser.js +2 -2
  300. package/dist/safe-bash/core.browser.js +2 -2
  301. package/dist/safe-bash/core.d.ts +7 -1
  302. package/dist/safe-bash/core.js +7 -1
  303. package/dist/safe-bash/execution-runtime.js +2 -1
  304. package/dist/safe-bash/fs/s3/http/index.d.ts +2 -2
  305. package/dist/safe-bash/fs/s3/http/index.js +1 -1
  306. package/dist/safe-bash/full-core.browser.js +283 -945
  307. package/dist/safe-bash/internal/op/types.d.ts +1 -0
  308. package/dist/safe-bash/jobs.browser.js +5 -5
  309. package/dist/safe-bash/lazy-optional.d.ts +3 -3
  310. package/dist/safe-bash/lazy-optional.js +1 -1
  311. package/dist/safe-bash/opt-in/commands/cmp/index.js +7 -6
  312. package/dist/safe-bash/opt-in/commands/dd/index.js +1 -1
  313. package/dist/safe-bash/opt-in/commands/dd/io.js +51 -5
  314. package/dist/safe-bash/opt-in/commands/truncate/index.js +2 -2
  315. package/dist/safe-bash/opt-in/commands/yq/native-work.js +2 -0
  316. package/dist/safe-bash/opt-in/optional/commands/shuf/input.js +2 -1
  317. package/dist/safe-bash/opt-in/optional/commands/shuf/shuf.js +4 -2
  318. package/dist/safe-bash/opt-in/optional.d.ts +1 -1
  319. package/dist/safe-bash/opt-in/optional.js +1 -1
  320. package/dist/safe-bash/opt-in/shell/extensions/read/index.js +2 -344
  321. package/dist/safe-bash/optional-host.browser.js +23 -18
  322. package/dist/safe-bash/optional-host.d.ts +1 -0
  323. package/dist/safe-bash/optional-host.js +1 -0
  324. package/dist/safe-bash/playwright/controller.js +41 -3
  325. package/dist/safe-bash/playwright/native-storage-targets.js +4 -2
  326. package/dist/safe-bash/plugins/base.d.ts +1 -1
  327. package/dist/safe-bash/plugins/base.js +3 -3
  328. package/dist/safe-bash/plugins/composition.d.ts +5 -2
  329. package/dist/safe-bash/plugins/composition.js +10 -7
  330. package/dist/safe-bash/plugins/index.browser.js +44 -41
  331. package/dist/safe-bash/plugins/index.js +3 -2
  332. package/dist/safe-bash/plugins/portable-commands.d.ts +3 -0
  333. package/dist/safe-bash/plugins/portable-commands.js +31 -0
  334. package/dist/safe-bash/registry-entry.browser.js +41 -42
  335. package/dist/safe-bash/search.browser.js +32 -33
  336. package/dist/safe-bash/shell/arithmetic.js +19 -6
  337. package/dist/safe-bash/shell/arrays/state.js +1 -1
  338. package/dist/safe-bash/shell/arrays/syntax.js +4 -3
  339. package/dist/safe-bash/shell/index.d.ts +0 -1
  340. package/dist/safe-bash/shell/index.js +0 -1
  341. package/dist/safe-bash/shell/parser.d.ts +2 -2
  342. package/dist/safe-bash/shell/parser.js +268 -64
  343. package/dist/safe-bash/shell/read-builtin.d.ts +3 -0
  344. package/dist/safe-bash/shell/read-builtin.js +344 -0
  345. package/dist/safe-bash/shell/runtime.d.ts +21 -4
  346. package/dist/safe-bash/shell/runtime.js +373 -412
  347. package/dist/safe-bash/shell/session-state.js +25 -0
  348. package/dist/safe-bash/shell/shell.js +76 -154
  349. package/dist/safe-bash/shell/tilde-expansion.d.ts +1 -1
  350. package/dist/safe-bash/shell/tilde-expansion.js +2 -2
  351. package/dist/safe-bash/shell/types.d.ts +5 -0
  352. package/dist/safe-bash/shell/value-state.js +1 -1
  353. package/dist/safe-bash/shell-entry.browser.js +32 -33
  354. package/dist/safe-bash/trap.browser.js +4 -4
  355. package/dist/safe-bash/yq-browser/index.js +1 -1
  356. package/dist/safe-bash-calendar-engine/time-env/calendar.d.ts +1 -1
  357. package/dist/safe-bash-calendar-engine/time-env/calendar.js +1 -1
  358. package/dist/safe-bash-calendar-engine/time-env/format.js +1 -1
  359. package/dist/safe-bash-command-alias/index.d.ts +13 -0
  360. package/dist/safe-bash-command-alias/index.js +88 -0
  361. package/dist/safe-bash-command-apply-patch/apply.js +3 -3
  362. package/dist/safe-bash-command-apply-patch/index.js +3 -3
  363. package/dist/safe-bash-command-apply-patch/matcher.js +1 -1
  364. package/dist/safe-bash-command-apply-patch/parser.js +1 -1
  365. package/dist/safe-bash-command-awk/awk-pipes.js +2 -2
  366. package/dist/safe-bash-command-awk/awk-reader.js +1 -1
  367. package/dist/safe-bash-command-awk/awk-runtime.js +3 -3
  368. package/dist/safe-bash-command-awk/awk.js +5 -5
  369. package/dist/safe-bash-command-awk/index.js +5 -5
  370. package/dist/safe-bash-command-bc/index.js +206 -60
  371. package/dist/safe-bash-command-cmp/index.js +7 -6
  372. package/dist/safe-bash-command-column/column.js +3 -3
  373. package/dist/safe-bash-command-column/index.js +3 -3
  374. package/dist/safe-bash-command-column/layout.js +2 -2
  375. package/dist/safe-bash-command-csvkit/index.d.ts +1 -0
  376. package/dist/safe-bash-command-csvkit/index.js +1505 -7
  377. package/dist/safe-bash-command-csvkit/sync-support.js +2 -7
  378. package/dist/safe-bash-command-curl/curl.js +1 -1
  379. package/dist/safe-bash-command-curl/index.js +1 -1
  380. package/dist/safe-bash-command-date/date.js +1 -1
  381. package/dist/safe-bash-command-date/index.js +1 -1
  382. package/dist/safe-bash-command-dd/index.js +1 -1
  383. package/dist/safe-bash-command-dd/io.js +51 -5
  384. package/dist/safe-bash-command-diff/diff.js +1 -1
  385. package/dist/safe-bash-command-diff/index.js +1 -1
  386. package/dist/safe-bash-command-diff3/index.js +10 -13
  387. package/dist/safe-bash-command-exiftool/index.js +278 -50
  388. package/dist/safe-bash-command-exiftool/registry.d.ts +4 -2
  389. package/dist/safe-bash-command-factor/command.js +2 -2
  390. package/dist/safe-bash-command-factor/index.js +2 -2
  391. package/dist/safe-bash-command-fd/arguments.d.ts +2 -0
  392. package/dist/safe-bash-command-fd/index.js +42 -12
  393. package/dist/safe-bash-command-ffmpeg/index.js +356 -66
  394. package/dist/safe-bash-command-find/find-format.d.ts +3 -0
  395. package/dist/safe-bash-command-find/find-format.js +1 -1
  396. package/dist/safe-bash-command-find/find.js +2 -2
  397. package/dist/safe-bash-command-find/index.js +2 -2
  398. package/dist/safe-bash-command-fmt/index.js +1 -4
  399. package/dist/safe-bash-command-fold/engine.d.ts +1 -1
  400. package/dist/safe-bash-command-fold/family.js +2 -2
  401. package/dist/safe-bash-command-fold/index.js +1 -1
  402. package/dist/safe-bash-command-hexdump/command.js +2 -2
  403. package/dist/safe-bash-command-hexdump/index.js +2 -2
  404. package/dist/safe-bash-command-html-to-markdown/entities.js +1 -1
  405. package/dist/safe-bash-command-html-to-markdown/index.js +4 -4
  406. package/dist/safe-bash-command-html-to-markdown/input.js +3 -3
  407. package/dist/safe-bash-command-html-to-markdown/parser.js +2 -2
  408. package/dist/safe-bash-command-html-to-markdown/render.js +3 -3
  409. package/dist/safe-bash-command-htmlq/contracts.d.ts +5 -2
  410. package/dist/safe-bash-command-htmlq/index.d.ts +2 -1
  411. package/dist/safe-bash-command-htmlq/index.js +175 -49
  412. package/dist/safe-bash-command-htmlq/sync.d.ts +1 -0
  413. package/dist/safe-bash-command-imagemagick/index.js +56 -6
  414. package/dist/safe-bash-command-install/arguments.d.ts +27 -0
  415. package/dist/safe-bash-command-install/arguments.js +224 -0
  416. package/dist/safe-bash-command-install/index.d.ts +7 -0
  417. package/dist/safe-bash-command-install/index.js +942 -0
  418. package/dist/safe-bash-command-install/mode.d.ts +6 -0
  419. package/dist/safe-bash-command-install/mode.js +71 -0
  420. package/dist/safe-bash-command-install/options.d.ts +40 -0
  421. package/dist/safe-bash-command-install/options.js +27 -0
  422. package/dist/safe-bash-command-jq/index.js +1 -1
  423. package/dist/safe-bash-command-jq/jq.js +1 -1
  424. package/dist/safe-bash-command-less/index.js +37 -61
  425. package/dist/safe-bash-command-llm/command.js +1 -1
  426. package/dist/safe-bash-command-llm/elevenlabs.js +2 -2
  427. package/dist/safe-bash-command-llm/index.js +4 -4
  428. package/dist/safe-bash-command-llm/openai.js +2 -2
  429. package/dist/safe-bash-command-llm/providers/elevenlabs.js +2 -2
  430. package/dist/safe-bash-command-llm/providers/index.js +3 -3
  431. package/dist/safe-bash-command-llm/providers/openai.js +2 -2
  432. package/dist/safe-bash-command-llm/providers/shared.js +1 -1
  433. package/dist/{safe-bash-mcp → safe-bash-command-mcp}/index.browser.d.ts +463 -46
  434. package/dist/safe-bash-command-mcp/index.browser.js +19308 -0
  435. package/dist/{safe-bash-mcp → safe-bash-command-mcp}/index.d.ts +15 -6
  436. package/dist/{safe-bash-mcp → safe-bash-command-mcp}/index.js +2804 -2771
  437. package/dist/safe-bash-command-media/LICENSE +21 -0
  438. package/dist/safe-bash-command-media/index.d.ts +6 -0
  439. package/dist/safe-bash-command-media/index.js +30 -0
  440. package/dist/safe-bash-command-media/plugin.d.ts +18 -0
  441. package/dist/safe-bash-command-media/plugin.js +11 -0
  442. package/dist/safe-bash-command-media/remote.d.ts +63 -0
  443. package/dist/safe-bash-command-media/remote.js +11 -0
  444. package/dist/safe-bash-command-media/settings.d.ts +4 -0
  445. package/dist/safe-bash-command-media/settings.js +41 -0
  446. package/dist/safe-bash-command-mktemp/command.js +1 -1
  447. package/dist/safe-bash-command-mktemp/index.js +1 -1
  448. package/dist/safe-bash-command-mmdc/arguments.d.ts +1 -0
  449. package/dist/safe-bash-command-mmdc/command.d.ts +2 -0
  450. package/dist/safe-bash-command-mmdc/contracts.d.ts +8 -1
  451. package/dist/safe-bash-command-mmdc/index.js +359 -7
  452. package/dist/safe-bash-command-nl/index.js +1 -1
  453. package/dist/safe-bash-command-nl/nl.js +1 -1
  454. package/dist/safe-bash-command-node/LICENSE +21 -0
  455. package/dist/safe-bash-command-node/index.d.ts +17 -0
  456. package/dist/safe-bash-command-node/index.js +328 -0
  457. package/dist/safe-bash-command-numfmt/index.js +1 -0
  458. package/dist/safe-bash-command-od/index.js +10 -6
  459. package/dist/safe-bash-command-op/index.js +39 -32
  460. package/dist/safe-bash-command-op/types.d.ts +1 -0
  461. package/dist/safe-bash-command-pandoc/command.js +3 -3
  462. package/dist/safe-bash-command-pandoc/index.d.ts +1 -0
  463. package/dist/safe-bash-command-pandoc/index.js +5 -3
  464. package/dist/safe-bash-command-pandoc/sync.d.ts +1 -0
  465. package/dist/safe-bash-command-patch/index.js +4 -4
  466. package/dist/safe-bash-command-patch/patch.js +4 -4
  467. package/dist/safe-bash-command-pdfimages/index.js +1 -1
  468. package/dist/safe-bash-command-pdfinfo/index.js +30 -5
  469. package/dist/safe-bash-command-pdftk/index.js +21 -23
  470. package/dist/safe-bash-command-pdftoppm/index.js +17 -4
  471. package/dist/safe-bash-command-pdftotext/index.js +11 -14
  472. package/dist/safe-bash-command-qpdf/index.d.ts +1 -0
  473. package/dist/safe-bash-command-qpdf/index.js +9 -6
  474. package/dist/safe-bash-command-rg/index.js +1 -1
  475. package/dist/safe-bash-command-rg/rg-command.js +1 -1
  476. package/dist/safe-bash-command-sed/index.js +1 -1
  477. package/dist/safe-bash-command-sed/sed.js +1 -1
  478. package/dist/safe-bash-command-shuf/input.d.ts +2 -2
  479. package/dist/safe-bash-command-shuf/input.js +2 -1
  480. package/dist/safe-bash-command-shuf/shuf.js +4 -2
  481. package/dist/safe-bash-command-sips/index.js +2 -2
  482. package/dist/safe-bash-command-soffice/index.js +97 -12
  483. package/dist/safe-bash-command-sponge/index.js +4 -1
  484. package/dist/safe-bash-command-sqlite3/engine.d.ts +1 -0
  485. package/dist/safe-bash-command-sqlite3/index.js +510 -70
  486. package/dist/safe-bash-command-ssconvert/formats/xlsx.js +2 -2
  487. package/dist/safe-bash-command-ssconvert/index.js +44 -22
  488. package/dist/safe-bash-command-stat/command.js +1 -1
  489. package/dist/safe-bash-command-stat/index.js +1 -1
  490. package/dist/safe-bash-command-tar/create.d.ts +1 -0
  491. package/dist/safe-bash-command-tar/create.js +2 -2
  492. package/dist/safe-bash-command-tar/extract.js +2 -2
  493. package/dist/safe-bash-command-tar/index.js +4 -4
  494. package/dist/safe-bash-command-tar/modes.js +4 -4
  495. package/dist/safe-bash-command-tar/options.js +1 -1
  496. package/dist/safe-bash-command-truncate/index.js +2 -2
  497. package/dist/safe-bash-command-tsort/command.js +2 -2
  498. package/dist/safe-bash-command-tsort/index.js +2 -2
  499. package/dist/safe-bash-command-unalias/index.d.ts +12 -0
  500. package/dist/safe-bash-command-unalias/index.js +67 -0
  501. package/dist/safe-bash-command-unrtf/index.js +26 -4
  502. package/dist/safe-bash-command-xan/argv.d.ts +1 -1
  503. package/dist/safe-bash-command-xan/argv.js +2 -2
  504. package/dist/safe-bash-command-xan/budget.d.ts +0 -1
  505. package/dist/safe-bash-command-xan/budget.js +1 -1
  506. package/dist/safe-bash-command-xan/commands.js +6 -6
  507. package/dist/safe-bash-command-xan/csv.js +2 -2
  508. package/dist/safe-bash-command-xan/index.js +8 -9
  509. package/dist/safe-bash-command-xan/io.js +4 -4
  510. package/dist/safe-bash-command-xan/options.js +1 -1
  511. package/dist/safe-bash-command-xan/selector.js +2 -2
  512. package/dist/safe-bash-command-xmllint/index.js +45 -23
  513. package/dist/safe-bash-command-xxd/index.js +41 -10
  514. package/dist/safe-bash-command-yq/accounting.js +1 -1
  515. package/dist/safe-bash-command-yq/index.js +3 -2
  516. package/dist/safe-bash-command-yq/native-work.js +2 -0
  517. package/dist/safe-bash-command-yq/parser.js +2 -2
  518. package/dist/safe-bash-command-yq/query.js +5 -5
  519. package/dist/safe-bash-command-yq/toml.js +2 -2
  520. package/dist/safe-bash-command-zip/index.js +3 -3
  521. package/dist/safe-bash-compression-engine/bounded-codec.js +2 -2
  522. package/dist/safe-bash-compression-engine/codec-loader.js +1 -1
  523. package/dist/safe-bash-compression-engine/files.js +5 -5
  524. package/dist/safe-bash-compression-engine/index.js +4 -4
  525. package/dist/safe-bash-compression-engine/operand.js +5 -5
  526. package/dist/safe-bash-compression-engine/stream.js +4 -4
  527. package/dist/safe-bash-compression-engine/zstd-decode.js +3 -3
  528. package/dist/safe-bash-contracts/command.js +3 -3
  529. package/dist/safe-bash-contracts/default-executor.js +2 -2
  530. package/dist/safe-bash-contracts/diagnostics.js +3 -3
  531. package/dist/safe-bash-contracts/escaping.js +6 -6
  532. package/dist/safe-bash-contracts/filesystem-descriptor.js +3 -3
  533. package/dist/safe-bash-contracts/filesystem-output.js +5 -5
  534. package/dist/safe-bash-contracts/http.d.ts +7 -0
  535. package/dist/safe-bash-contracts/index.js +8 -8
  536. package/dist/safe-bash-contracts/io.js +2 -2
  537. package/dist/safe-bash-contracts/output.js +3 -3
  538. package/dist/safe-bash-contracts/runtime-control.d.ts +2 -2
  539. package/dist/safe-bash-contracts/runtime-control.js +4 -2
  540. package/dist/safe-bash-contracts/signals.d.ts +2 -0
  541. package/dist/safe-bash-contracts/signals.js +3 -1
  542. package/dist/safe-bash-contracts/yield.js +1 -1
  543. package/dist/safe-bash-csv-engine/index.d.ts +2 -1
  544. package/dist/safe-bash-csv-engine/index.js +21 -15
  545. package/dist/safe-bash-io-engine/commands/search/requirements.js +2 -2
  546. package/dist/safe-bash-io-engine/commands/text-programs/shared.js +6 -6
  547. package/dist/safe-bash-io-engine/internal.js +1 -1
  548. package/dist/safe-bash-io-engine/shell/pattern.js +38 -18
  549. package/dist/safe-bash-line-ending-engine/convert.js +9 -204
  550. package/dist/safe-bash-line-ending-engine/encoding.js +9 -42
  551. package/dist/safe-bash-line-ending-engine/index.js +48 -0
  552. package/dist/safe-bash-line-ending-engine/info.js +9 -90
  553. package/dist/safe-bash-line-ending-engine/internal.js +15 -160
  554. package/dist/safe-bash-line-ending-engine/io.js +12 -289
  555. package/dist/safe-bash-line-ending-engine/stage.js +10 -160
  556. package/dist/safe-bash-markdown-engine/index.js +3 -3
  557. package/dist/safe-bash-network-engine/args.d.ts +6 -0
  558. package/dist/safe-bash-network-engine/args.js +4 -2
  559. package/dist/safe-bash-network-engine/body.js +1 -1
  560. package/dist/safe-bash-network-engine/fetch-transport.js +3 -1
  561. package/dist/safe-bash-network-engine/index.js +3 -1
  562. package/dist/safe-bash-network-engine/input.js +2 -2
  563. package/dist/safe-bash-network-engine/platform-portable.js +3 -1
  564. package/dist/safe-bash-query-engine/dates.d.ts +1 -1
  565. package/dist/safe-bash-query-engine/dates.js +1 -1
  566. package/dist/safe-bash-query-engine/index.js +6 -6
  567. package/dist/safe-bash-query-engine/interpreter.js +4 -4
  568. package/dist/safe-bash-query-engine/parser.js +1 -1
  569. package/dist/safe-bash-query-engine/query-core.js +6 -6
  570. package/dist/safe-bash-regex-engine/execution/bounded-provider.js +10 -0
  571. package/dist/safe-bash-regex-engine/index.js +1 -1
  572. package/dist/safe-bash-regex-engine/text/regex.d.ts +1 -1
  573. package/dist/safe-bash-regex-engine/text/regex.js +1 -1
  574. package/dist/safe-bash-search-engine/ergonomic-regex.d.ts +1 -0
  575. package/dist/safe-bash-search-engine/ergonomic-regex.js +1 -1
  576. package/dist/safe-bash-search-engine/grep.js +16 -9
  577. package/dist/safe-bash-search-engine/matcher.d.ts +2 -2
  578. package/dist/safe-bash-search-engine/matcher.js +12 -8
  579. package/dist/safe-bash-search-engine/shared.js +1 -1
  580. package/dist/safe-bash-search-engine/walk.js +13 -1
  581. package/dist/safe-bash-text-stream-engine/stream-format/shared.d.ts +1 -1
  582. package/dist/safe-bash-text-stream-engine/stream-format/shared.js +2 -1
  583. package/dist/safe-bash-xml-engine/document.js +3 -3
  584. package/dist/safe-bash-xml-engine/evaluate.js +2 -2
  585. package/dist/safe-bash-xml-engine/index.js +4 -4
  586. package/dist/safe-bash-xml-engine/io.js +7 -2
  587. package/dist/safe-bash-xml-engine/limits.d.ts +0 -2
  588. package/dist/safe-bash-xml-engine/limits.js +1 -1
  589. package/dist/safe-bash-xml-engine/query.js +3 -3
  590. package/dist/safe-bash-zip-engine/index.js +3 -3
  591. package/dist/safe-bash-zip-engine/zip/repair.js +3 -3
  592. package/dist/safe-bash-zip-engine/zip/safety.js +1 -1
  593. package/dist/safe-bash-zip-engine/zip/sfx.js +3 -3
  594. package/dist/safe-bash-zip-engine/zip/volumes.js +1 -1
  595. package/dist/safe-bash-zip-engine/zip-format.js +3 -3
  596. package/dist/safe-playwright-cloudflare/browser-socket-closure.js +18 -3
  597. package/dist/safe-playwright-cloudflare/shell-browser-resource.js +1 -1
  598. package/dist/xlsx-ast/xlsx.js +6 -5
  599. package/package.json +86 -98
  600. package/dist/media-cli/bytes.d.ts +0 -8
  601. package/dist/media-cli/bytes.js +0 -40
  602. package/dist/media-cli/concat.d.ts +0 -30
  603. package/dist/media-cli/concat.js +0 -197
  604. package/dist/media-cli/content.js +0 -66
  605. package/dist/media-cli/dependency-grammars.d.ts +0 -12
  606. package/dist/media-cli/dependency-grammars.js +0 -557
  607. package/dist/media-cli/discover.js +0 -286
  608. package/dist/media-cli/engine.js +0 -190
  609. package/dist/media-cli/filename-expression.js +0 -147
  610. package/dist/media-cli/filesystem.js +0 -35
  611. package/dist/media-cli/frontend-contract.js +0 -8
  612. package/dist/media-cli/frontend-issues.d.ts +0 -6
  613. package/dist/media-cli/frontend-issues.js +0 -9
  614. package/dist/media-cli/imagemagick-operand.d.ts +0 -42
  615. package/dist/media-cli/imagemagick-operand.js +0 -229
  616. package/dist/media-cli/imagemagick-references.d.ts +0 -7
  617. package/dist/media-cli/imagemagick-references.js +0 -42
  618. package/dist/media-cli/imagemagick.generated.js +0 -3254
  619. package/dist/media-cli/imagemagick.js +0 -615
  620. package/dist/media-cli/index.js +0 -12
  621. package/dist/media-cli/mvg.d.ts +0 -10
  622. package/dist/media-cli/mvg.js +0 -102
  623. package/dist/media-cli/network.js +0 -78
  624. package/dist/media-cli/options.generated.js +0 -3312
  625. package/dist/media-cli/preset.d.ts +0 -11
  626. package/dist/media-cli/preset.js +0 -57
  627. package/dist/media-cli/resolution-path.d.ts +0 -23
  628. package/dist/media-cli/resolution-path.js +0 -217
  629. package/dist/media-cli/resolver.js +0 -494
  630. package/dist/media-cli/resources.d.ts +0 -16
  631. package/dist/media-cli/resources.js +0 -187
  632. package/dist/media-cli/shim.js +0 -52
  633. package/dist/media-cli/tee.d.ts +0 -6
  634. package/dist/media-cli/tee.js +0 -38
  635. package/dist/office-package/zip-sync.js +0 -111
  636. package/dist/remote-execution/binary.js +0 -178
  637. package/dist/remote-execution/callback-result.js +0 -26
  638. package/dist/remote-execution/canonical-capabilities.d.ts +0 -5
  639. package/dist/remote-execution/canonical-capabilities.js +0 -45
  640. package/dist/remote-execution/canonical-metadata.d.ts +0 -4
  641. package/dist/remote-execution/canonical-metadata.js +0 -32
  642. package/dist/remote-execution/client.js +0 -824
  643. package/dist/remote-execution/deployment.js +0 -131
  644. package/dist/remote-execution/descriptors.js +0 -267
  645. package/dist/remote-execution/effects.js +0 -357
  646. package/dist/remote-execution/endpoint.js +0 -224
  647. package/dist/remote-execution/files.js +0 -291
  648. package/dist/remote-execution/hosting-operation.js +0 -26
  649. package/dist/remote-execution/hosting-request.d.ts +0 -4
  650. package/dist/remote-execution/hosting-request.js +0 -12
  651. package/dist/remote-execution/hosting-stream.d.ts +0 -8
  652. package/dist/remote-execution/hosting-stream.js +0 -64
  653. package/dist/remote-execution/index.js +0 -18
  654. package/dist/remote-execution/invocation-admission.d.ts +0 -3
  655. package/dist/remote-execution/invocation-admission.js +0 -17
  656. package/dist/remote-execution/job-binding.js +0 -1269
  657. package/dist/remote-execution/materializations.js +0 -284
  658. package/dist/remote-execution/modal-driver.js +0 -90
  659. package/dist/remote-execution/native-result.d.ts +0 -3
  660. package/dist/remote-execution/native-result.js +0 -16
  661. package/dist/remote-execution/output-freshness.d.ts +0 -4
  662. package/dist/remote-execution/output-freshness.js +0 -19
  663. package/dist/remote-execution/output-retrieval.js +0 -474
  664. package/dist/remote-execution/process-http.js +0 -607
  665. package/dist/remote-execution/process.js +0 -577
  666. package/dist/remote-execution/protocol.js +0 -208
  667. package/dist/remote-execution/relay.js +0 -91
  668. package/dist/remote-execution/rest-driver.js +0 -93
  669. package/dist/remote-execution/upload-descriptor.js +0 -201
  670. package/dist/remote-execution/upload-protocol.js +0 -62
  671. package/dist/remote-execution/uploads.js +0 -324
  672. package/dist/remote-execution/wire-json.d.ts +0 -4
  673. package/dist/remote-execution/wire-json.js +0 -44
  674. package/dist/remote-execution/wire-validation.js +0 -131
  675. package/dist/remote-execution/wire.generated.js +0 -4224
  676. package/dist/safe-bash/chunks/chunk-GDYNCWRV.js +0 -161
  677. package/dist/safe-bash/chunks/chunk-IWDICZVK.js +0 -20
  678. package/dist/safe-bash/chunks/chunk-MHMMRCYC.js +0 -3464
  679. package/dist/safe-bash/chunks/chunk-UE5KZDEK.js +0 -77
  680. package/dist/safe-bash/chunks/csvkit-TACDU7FC.js +0 -1618
  681. package/dist/safe-bash/chunks/implementation-MLFHUQ5M.js +0 -133
  682. package/dist/safe-bash/commands/csvkit/sync.js +0 -1639
  683. package/dist/safe-bash/commands/node/unconfigured.d.ts +0 -3
  684. package/dist/safe-bash/commands/node/unconfigured.js +0 -10
  685. package/dist/safe-bash/commands/pandoc/implementation.d.ts +0 -8
  686. package/dist/safe-bash/commands/pandoc/implementation.js +0 -94
  687. package/dist/safe-bash-mcp/index.browser.js +0 -9167
  688. package/dist/safe-bash/command-chunks/{chunk-ZRRBXU3M.js → chunk-GIN5GUDP.js} +4 -4
  689. package/dist/safe-bash/command-chunks/{chunk-LAOM65EE.js → chunk-IEO4XVN6.js} +3 -3
  690. package/dist/safe-bash/command-chunks/{chunk-BXCXRYVU.js → chunk-JNANXVJV.js} +0 -0
  691. package/dist/safe-bash/command-chunks/{chunk-364TMWBT.js → chunk-MWREVL44.js} +6 -6
  692. package/dist/safe-bash/command-chunks/{chunk-464RVBGB.js → chunk-Q5TDKFHK.js} +3 -3
  693. package/dist/safe-bash/command-chunks/{chunk-AJR3AQYA.js → chunk-UKX3LZHR.js} +0 -0
  694. package/dist/safe-bash/command-chunks/{chunk-XIIBTGC5.js → chunk-XPXEQKRW.js} +9 -9
  695. package/dist/safe-bash/command-chunks/{chunk-FDBUV4HJ.js → chunk-Y4HGTG3E.js} +3 -3
  696. /package/dist/{safe-bash/commands/csvkit → safe-bash-command-csvkit}/sync.d.ts +0 -0
@@ -1,1618 +0,0 @@
1
- import {
2
- inflateRaw
3
- } from "./chunk-MHMMRCYC.js";
4
- import {
5
- builtInDirectContextExecutors,
6
- syncCommandEvaluators
7
- } from "./chunk-E7OYNDGL.js";
8
- import {
9
- init_platform
10
- } from "./chunk-B7TAL7S5.js";
11
-
12
- // packages/safe-bash/src/commands/csvkit/index.ts
13
- init_platform();
14
-
15
- // packages/safe-bash/src/commands/csvkit/sync.ts
16
- init_platform();
17
-
18
- // packages/office-package/dist/zip-sync.js
19
- init_platform();
20
- function readZipArchiveEntries(zipBytes) {
21
- const map = /* @__PURE__ */ new Map();
22
- const view = new DataView(zipBytes.buffer, zipBytes.byteOffset, zipBytes.byteLength);
23
- let eocdPos = -1;
24
- for (let i = zipBytes.length - 22; i >= Math.max(0, zipBytes.length - 65557); i--) {
25
- if (view.getUint32(i, true) === 101010256) {
26
- eocdPos = i;
27
- break;
28
- }
29
- }
30
- if (eocdPos < 0)
31
- throw new Error("Invalid ZIP: missing end of central directory");
32
- const count = view.getUint16(eocdPos + 10, true);
33
- let cdPos = view.getUint32(eocdPos + 16, true);
34
- for (let i = 0; i < count; i++) {
35
- if (cdPos + 46 > zipBytes.length || view.getUint32(cdPos, true) !== 33639248) {
36
- throw new Error("Invalid ZIP: truncated central directory");
37
- }
38
- const method = view.getUint16(cdPos + 10, true);
39
- const compSize = view.getUint32(cdPos + 20, true);
40
- const nameLen = view.getUint16(cdPos + 28, true);
41
- const extraLen = view.getUint16(cdPos + 30, true);
42
- const commentLen = view.getUint16(cdPos + 32, true);
43
- const localOffset = view.getUint32(cdPos + 42, true);
44
- if (cdPos + 46 + nameLen + extraLen + commentLen > zipBytes.length || localOffset + 30 > zipBytes.length || view.getUint32(localOffset, true) !== 67324752) {
45
- throw new Error("Invalid ZIP: truncated or invalid entry header");
46
- }
47
- const name = new TextDecoder().decode(zipBytes.subarray(cdPos + 46, cdPos + 46 + nameLen));
48
- const localNameLen = view.getUint16(localOffset + 26, true);
49
- const localExtraLen = view.getUint16(localOffset + 28, true);
50
- const dataStart = localOffset + 30 + localNameLen + localExtraLen;
51
- if (dataStart + compSize > zipBytes.length) {
52
- throw new Error("Invalid ZIP: truncated entry data");
53
- }
54
- const rawData = zipBytes.subarray(dataStart, dataStart + compSize);
55
- if (method === 0) {
56
- map.set(name, new Uint8Array(rawData));
57
- } else if (method === 8) {
58
- map.set(name, inflateRaw(rawData));
59
- }
60
- cdPos += 46 + nameLen + extraLen + commentLen;
61
- }
62
- return map;
63
- }
64
-
65
- // packages/safe-bash/src/commands/csvkit/sync.ts
66
- import {
67
- defaultHeaders,
68
- inferTable,
69
- readCsv,
70
- sniff,
71
- Decimal,
72
- pythonValueText,
73
- writeCsvRow,
74
- parseColumnIdentifiers,
75
- matchColumnIdentifier
76
- } from "../../safe-bash-command-csvkit/sync-support.js";
77
- var syncUtf8Decoder = new TextDecoder("utf-8", { fatal: true });
78
- function parseSyncCsvkitCommon(opArgs, mode) {
79
- const res = {
80
- tabs: false,
81
- noDoublequote: false,
82
- skipInitialSpace: false,
83
- noHeaderRow: false,
84
- skipLines: 0,
85
- lineNumbers: false,
86
- addBom: false,
87
- noInference: false,
88
- blanks: false,
89
- noLeadingZeroes: false,
90
- sniffLimit: 1024,
91
- noNumberEllipsis: false,
92
- indent: null,
93
- key: null,
94
- streamOutput: false
95
- };
96
- let positionalDone = false;
97
- for (let i = 0; i < opArgs.length; i++) {
98
- const a = opArgs[i];
99
- if (!positionalDone && a === "--") {
100
- positionalDone = true;
101
- continue;
102
- }
103
- if (!positionalDone && a.startsWith("-") && a !== "-") {
104
- if (a === "-t" || a === "--tabs") {
105
- res.tabs = true;
106
- continue;
107
- }
108
- if (a === "-b" || a === "--no-doublequote") {
109
- res.noDoublequote = true;
110
- continue;
111
- }
112
- if (a === "-S" || a === "--skipinitialspace") {
113
- res.skipInitialSpace = true;
114
- continue;
115
- }
116
- if (a === "-H" || a === "--no-header-row") {
117
- res.noHeaderRow = true;
118
- continue;
119
- }
120
- if (a === "-l" || a === "--linenumbers") {
121
- res.lineNumbers = true;
122
- continue;
123
- }
124
- if (a === "--add-bom") {
125
- res.addBom = true;
126
- continue;
127
- }
128
- if (a === "-I" || a === "--no-inference") {
129
- res.noInference = true;
130
- continue;
131
- }
132
- if (a === "--blanks") {
133
- res.blanks = true;
134
- continue;
135
- }
136
- if (a === "--no-leading-zeroes") {
137
- res.noLeadingZeroes = true;
138
- continue;
139
- }
140
- if (a === "-d" || a.startsWith("-d") || a === "--delimiter" || a.startsWith("--delimiter=")) {
141
- const v = a.startsWith("--delimiter=") ? a.slice(12) : a.startsWith("-d=") ? a.slice(3) : a.length > 2 && a.startsWith("-d") ? a.slice(2) : opArgs[++i];
142
- if (!v || Array.from(v).length !== 1) return void 0;
143
- res.delimiter = v;
144
- continue;
145
- }
146
- if (a === "-q" || a.startsWith("-q") || a === "--quotechar" || a.startsWith("--quotechar=")) {
147
- const v = a.startsWith("--quotechar=") ? a.slice(12) : a.startsWith("-q=") ? a.slice(3) : a.length > 2 && a.startsWith("-q") ? a.slice(2) : opArgs[++i];
148
- if (!v || Array.from(v).length !== 1) return void 0;
149
- res.quotechar = v;
150
- continue;
151
- }
152
- if (a === "-p" || a === "--escapechar") {
153
- const v = opArgs[++i];
154
- if (!v || Array.from(v).length !== 1) return void 0;
155
- res.escapechar = v;
156
- continue;
157
- }
158
- if (a === "-K" || a.startsWith("-K") || a === "--skip-lines" || a.startsWith("--skip-lines=")) {
159
- const v = a.startsWith("--skip-lines=") ? a.slice(13) : a.startsWith("-K=") ? a.slice(3) : a.length > 2 && a.startsWith("-K") ? a.slice(2) : opArgs[++i];
160
- if (v === void 0 || !/^[0-9]+$/.test(v)) return void 0;
161
- res.skipLines = Number(v);
162
- continue;
163
- }
164
- if (a === "-y" || a === "--snifflimit") {
165
- const v = opArgs[++i];
166
- if (v === void 0 || !/^-?[0-9]+$/.test(v)) return void 0;
167
- res.sniffLimit = Number(v);
168
- continue;
169
- }
170
- if (mode === "csvlook") {
171
- if (a === "--no-number-ellipsis") {
172
- res.noNumberEllipsis = true;
173
- continue;
174
- }
175
- if (a === "--max-rows" || a === "--max-columns" || a === "--max-column-width" || a === "--max-precision") {
176
- const v = opArgs[++i];
177
- if (v === void 0 || !/^[0-9]+$/.test(v)) return void 0;
178
- const n = Number(v);
179
- if (a === "--max-rows") res.maxRows = n;
180
- else if (a === "--max-columns") res.maxColumns = n;
181
- else if (a === "--max-column-width") res.maxColumnWidth = n;
182
- else res.maxPrecision = n;
183
- continue;
184
- }
185
- } else {
186
- if (a === "--stream") {
187
- res.streamOutput = true;
188
- continue;
189
- }
190
- if (a === "-i" || a.startsWith("-i") || a === "--indent" || a.startsWith("--indent=")) {
191
- const v = a.startsWith("--indent=") ? a.slice(9) : a.startsWith("-i=") ? a.slice(3) : a.length > 2 && a.startsWith("-i") ? a.slice(2) : opArgs[++i];
192
- if (v === void 0 || !/^[0-9]+$/.test(v)) return void 0;
193
- res.indent = Number(v);
194
- continue;
195
- }
196
- if (a === "-k" || a.startsWith("-k") || a === "--key" || a.startsWith("--key=")) {
197
- const v = a.startsWith("--key=") ? a.slice(6) : a.startsWith("-k=") ? a.slice(3) : a.length > 2 && a.startsWith("-k") ? a.slice(2) : opArgs[++i];
198
- if (v === void 0) return void 0;
199
- res.key = v;
200
- continue;
201
- }
202
- }
203
- if (!a.startsWith("--") && a.length > 2) {
204
- let ok = true;
205
- for (let j = 1; j < a.length; j++) {
206
- const ch = a[j];
207
- if (ch === "t") res.tabs = true;
208
- else if (ch === "b") res.noDoublequote = true;
209
- else if (ch === "S") res.skipInitialSpace = true;
210
- else if (ch === "H") res.noHeaderRow = true;
211
- else if (ch === "l") res.lineNumbers = true;
212
- else if (ch === "I") res.noInference = true;
213
- else {
214
- ok = false;
215
- break;
216
- }
217
- }
218
- if (ok) continue;
219
- }
220
- return void 0;
221
- }
222
- if (res.filePath !== void 0) return void 0;
223
- res.filePath = a;
224
- }
225
- return res;
226
- }
227
- function loadSyncTypedTable(inBytes, opts, readFileSync) {
228
- let sourceBytes = inBytes;
229
- if (opts.filePath !== void 0 && opts.filePath !== "-") {
230
- if (!readFileSync) return void 0;
231
- sourceBytes = readFileSync(opts.filePath);
232
- }
233
- if (!sourceBytes || sourceBytes.byteLength > 16384) return void 0;
234
- let text;
235
- try {
236
- text = syncUtf8Decoder.decode(sourceBytes);
237
- } catch {
238
- return void 0;
239
- }
240
- if (text.charCodeAt(0) === 65279) text = text.slice(1);
241
- if (opts.skipLines > 0) {
242
- let linesLeft = opts.skipLines;
243
- let pos = 0;
244
- while (pos < text.length && linesLeft > 0) {
245
- const ch = text[pos++];
246
- if (ch === "\r") {
247
- if (text[pos] === "\n") pos++;
248
- linesLeft--;
249
- } else if (ch === "\n") {
250
- linesLeft--;
251
- }
252
- }
253
- text = text.slice(pos);
254
- }
255
- const explicitDelimiter = opts.tabs ? " " : opts.delimiter;
256
- let dialect = {
257
- ...explicitDelimiter !== void 0 ? { delimiter: explicitDelimiter } : {},
258
- ...opts.quotechar !== void 0 ? { quotechar: opts.quotechar } : {},
259
- ...opts.escapechar !== void 0 ? { escapechar: opts.escapechar } : {},
260
- doublequote: !opts.noDoublequote,
261
- skipinitialspace: opts.skipInitialSpace
262
- };
263
- if (!opts.tabs && opts.delimiter === void 0 && opts.quotechar === void 0 && opts.escapechar === void 0 && !opts.noDoublequote && !opts.skipInitialSpace && opts.sniffLimit !== 0 && text.length > 0) {
264
- const sample = opts.sniffLimit > 0 ? text.slice(0, opts.sniffLimit) : text;
265
- if (sample.includes(",") && !/[\t;|:\x27]/.test(sample)) {
266
- dialect = { delimiter: ",", quotechar: '"', doublequote: true, skipinitialspace: false };
267
- } else {
268
- const sniffed = sniff(sample);
269
- if (sniffed) dialect = sniffed;
270
- }
271
- }
272
- let headers;
273
- const rows = [];
274
- const rowLimit = opts.maxRows;
275
- for (const record of readCsv(text, dialect)) {
276
- const values = record.cells.map((c) => pythonValueText(c));
277
- const cells = opts.lineNumbers ? [!opts.noHeaderRow && record.line === 1 ? "line_numbers" : String(record.line - (opts.noHeaderRow ? 0 : 1)), ...values] : values;
278
- if (headers === void 0) {
279
- headers = opts.noHeaderRow ? defaultHeaders(cells.length) : cells;
280
- if (headers.some((name) => !name) || new Set(headers).size !== headers.length) return void 0;
281
- if (!opts.noHeaderRow) {
282
- if (rowLimit === 0) break;
283
- continue;
284
- }
285
- }
286
- rows.push(cells);
287
- if (rowLimit !== void 0 && rows.length >= rowLimit) break;
288
- }
289
- const inferenceOpts = {
290
- now: Date.now(),
291
- timezone: "UTC",
292
- noInference: opts.noInference,
293
- numberTextOnly: false,
294
- blanks: opts.blanks,
295
- nullValues: [],
296
- noLeadingZeroes: opts.noLeadingZeroes,
297
- maxDecimalDigits: Infinity,
298
- maxDecimalExponent: Infinity
299
- };
300
- return inferTable(headers ?? [], rows, inferenceOpts);
301
- }
302
- function syncPrecision(values) {
303
- let whole = 1;
304
- let places = 0;
305
- for (const value of values) {
306
- if (value === null || typeof value !== "object" || value.kind !== "decimal") continue;
307
- const d = Decimal.parse(value.value).normalized();
308
- if (d.special || Math.abs(Number(d.toString())) === Infinity) continue;
309
- places = Math.max(places, -d.exponent);
310
- whole = Math.max(whole, d.coefficient.toString().length + d.exponent);
311
- }
312
- return Math.min(places, 28 - whole);
313
- }
314
- function syncNumberText(value, places, ellipsis) {
315
- const d = Decimal.parse(value);
316
- if (d.special === "Infinity" || Math.abs(Number(d.toString())) === Infinity) return value;
317
- places = Math.max(0, places);
318
- if (d.special) {
319
- const digits2 = "NaN" + d.payload;
320
- let grouped2 = "";
321
- for (let i = 0; i < digits2.length; i++) {
322
- if (i && (digits2.length - i) % 3 === 0) grouped2 += ",";
323
- grouped2 += digits2[i];
324
- }
325
- return grouped2 + (places ? "." + "0".repeat(places) : "") + ellipsis;
326
- }
327
- let coefficient = d.coefficient;
328
- const shift = d.exponent + places;
329
- if (shift >= 0) coefficient *= 10n ** BigInt(shift);
330
- else {
331
- const divisor = 10n ** BigInt(-shift);
332
- const rest = coefficient % divisor;
333
- coefficient /= divisor;
334
- if (rest * 2n > divisor || rest * 2n === divisor && coefficient % 2n !== 0n) coefficient++;
335
- }
336
- if (coefficient.toString().length > 28) throw new Error("InvalidOperation");
337
- const digits = coefficient.toString().padStart(places + 1, "0");
338
- const whole = digits.slice(0, digits.length - places);
339
- let grouped = "";
340
- for (let i = 0; i < whole.length; i++) {
341
- if (i && (whole.length - i) % 3 === 0) grouped += ",";
342
- grouped += whole[i];
343
- }
344
- return (d.negative ? "-" : "") + grouped + (places ? "." + digits.slice(-places) : "") + ellipsis;
345
- }
346
- function evalSyncCsvlook(inBytes, opArgs, readFileSync) {
347
- try {
348
- const opts = parseSyncCsvkitCommon(opArgs, "csvlook");
349
- if (!opts) return void 0;
350
- const table = loadSyncTypedTable(inBytes, opts, readFileSync);
351
- if (!table) return void 0;
352
- const maxColumns = opts.maxColumns ?? table.headers.length;
353
- const width = opts.maxColumnWidth;
354
- const maxPrecision = opts.maxPrecision ?? 3;
355
- const cpLen = (v) => Array.from(v).length;
356
- const truncate = (v) => {
357
- const chars = Array.from(v);
358
- return width !== void 0 && chars.length > width ? chars.slice(0, width - 3).join("") + "..." : v;
359
- };
360
- const names = table.headers.slice(0, maxColumns).map(truncate);
361
- if (maxColumns < table.headers.length) names.push("...");
362
- const widths = names.map(cpLen);
363
- const formats = table.columns.map((column, index) => {
364
- if (index >= maxColumns || column.type !== "Number") return void 0;
365
- const places = syncPrecision(table.rows.map((row) => row[index]));
366
- return { places: Math.min(places, maxPrecision), ellipsis: places > maxPrecision && !opts.noNumberEllipsis ? "\u2026" : "" };
367
- });
368
- const renderedRows = table.rows.map((row) => {
369
- const cells = [];
370
- for (const [j, value] of row.entries()) {
371
- const format = formats[j];
372
- let text = j >= maxColumns ? "..." : value === null ? "" : format && typeof value === "object" && value.kind === "decimal" ? syncNumberText(value.value, format.places, format.ellipsis) : pythonValueText(value).replaceAll("\n", "\u21B5");
373
- text = truncate(text);
374
- widths[j] = Math.max(widths[j], cpLen(text));
375
- cells.push(text);
376
- if (j >= maxColumns) break;
377
- }
378
- return cells;
379
- });
380
- const formatRow = (cells) => {
381
- const fields = cells.map((cell, j) => {
382
- const col = table.columns[j];
383
- if (!col) throw new Error("IndexError");
384
- const spaces = widths[j] - cpLen(cell);
385
- const padding = " ".repeat(Math.max(0, spaces));
386
- return col.type === "Text" ? " " + cell + padding + " " : " " + padding + cell + " ";
387
- });
388
- return "|" + fields.join("|") + "|\n";
389
- };
390
- let out = opts.addBom ? "\uFEFF" : "";
391
- out += formatRow(names);
392
- out += "| " + widths.map((size) => "-".repeat(size)).join(" | ") + " |\n";
393
- for (const row of renderedRows) out += formatRow(row);
394
- return out;
395
- } catch {
396
- return void 0;
397
- }
398
- }
399
- function syncFloatText(value) {
400
- if (Number.isNaN(value)) return "NaN";
401
- if (!Number.isFinite(value)) return value < 0 ? "-Infinity" : "Infinity";
402
- if (Object.is(value, -0)) return "-0.0";
403
- const exponent = Number(value.toExponential().split("e")[1]);
404
- if (value !== 0 && (exponent < -4 || exponent >= 16)) {
405
- const [digits, power] = value.toExponential().split("e");
406
- const exp = Number(power);
407
- return digits + "e" + (exp < 0 ? "-" : "+") + String(Math.abs(exp)).padStart(2, "0");
408
- }
409
- return String(value) + (Number.isInteger(value) ? ".0" : "");
410
- }
411
- function emitSyncJson(cur, indent, d = 0) {
412
- if (typeof cur === "number") return syncFloatText(cur);
413
- if (cur === null || typeof cur === "string" || typeof cur === "boolean") return JSON.stringify(cur);
414
- if (cur instanceof Map) {
415
- let buf2 = "{";
416
- let index = 0;
417
- const childPad2 = indent !== null ? "\n" + " ".repeat(indent * (d + 1)) : "";
418
- for (const [key, child] of cur.entries()) {
419
- if (index++) buf2 += indent === null ? ", " : ",";
420
- if (indent !== null) buf2 += childPad2;
421
- buf2 += JSON.stringify(key) + ": " + emitSyncJson(child, indent, d + 1);
422
- }
423
- if (cur.size && indent !== null) buf2 += "\n" + " ".repeat(indent * d);
424
- buf2 += "}";
425
- return buf2;
426
- }
427
- const arr = cur;
428
- let buf = "[";
429
- const childPad = indent !== null ? "\n" + " ".repeat(indent * (d + 1)) : "";
430
- for (let index = 0; index < arr.length; index++) {
431
- if (index) buf += indent === null ? ", " : ",";
432
- if (indent !== null) buf += childPad;
433
- buf += emitSyncJson(arr[index], indent, d + 1);
434
- }
435
- if (arr.length && indent !== null) buf += "\n" + " ".repeat(indent * d);
436
- buf += "]";
437
- return buf;
438
- }
439
- function evalSyncCsvjson(inBytes, opArgs, readFileSync) {
440
- try {
441
- const opts = parseSyncCsvkitCommon(opArgs, "csvjson");
442
- if (!opts) return void 0;
443
- if (opts.streamOutput && opts.key !== null) return void 0;
444
- if (opts.streamOutput && opts.indent !== null) return void 0;
445
- const table = loadSyncTypedTable(inBytes, opts, readFileSync);
446
- if (!table) return void 0;
447
- const jsonify = (value) => {
448
- if (typeof value !== "object" || value === null) return value;
449
- if (value.kind === "decimal") return value.value.includes("NaN") ? NaN : Number(value.value);
450
- if (value.kind === "datetime") return value.value.replace(" ", "T");
451
- return pythonValueText(value);
452
- };
453
- const rows = table.rows.map(
454
- (row) => new Map(table.headers.map((name, index) => [name, jsonify(row[index])]))
455
- );
456
- let output = rows;
457
- if (opts.key !== null) {
458
- const column = table.headers.indexOf(opts.key);
459
- if (column < 0 && rows.length) return void 0;
460
- const keyed = /* @__PURE__ */ new Map();
461
- for (const [index, row] of table.rows.entries()) {
462
- const cell = row[column];
463
- const value = cell === null ? "None" : typeof cell === "object" && cell.kind === "decimal" ? Decimal.parse(cell.value).normalized().toString() : pythonValueText(cell);
464
- if (keyed.has(value)) return void 0;
465
- keyed.set(value, rows[index]);
466
- }
467
- output = keyed;
468
- }
469
- let out = opts.addBom ? "\uFEFF" : "";
470
- if (opts.streamOutput) {
471
- for (const row of rows) {
472
- out += emitSyncJson(row, opts.indent) + "\n";
473
- }
474
- return out;
475
- }
476
- out += emitSyncJson(output, opts.indent);
477
- return out;
478
- } catch {
479
- return void 0;
480
- }
481
- }
482
- function evalSyncCsvsort(inBytes, opArgs, readFileSync) {
483
- try {
484
- let columnsSpec = null;
485
- let reverse = false;
486
- let ignoreCase = false;
487
- let namesOnly = false;
488
- let zeroBased = false;
489
- const filteredArgs = [];
490
- let posDone = false;
491
- for (let i = 0; i < opArgs.length; i++) {
492
- const a = opArgs[i];
493
- if (!posDone && a === "--") {
494
- posDone = true;
495
- filteredArgs.push(a);
496
- continue;
497
- }
498
- if (!posDone && a.startsWith("-") && a !== "-") {
499
- if (a === "-r" || a === "--reverse") {
500
- reverse = true;
501
- continue;
502
- }
503
- if (a === "-i" || a === "--ignore-case") {
504
- ignoreCase = true;
505
- continue;
506
- }
507
- if (a === "-n" || a === "--names") {
508
- namesOnly = true;
509
- continue;
510
- }
511
- if (a === "--zero") {
512
- zeroBased = true;
513
- continue;
514
- }
515
- if (a === "-ri" || a === "-ir") {
516
- reverse = true;
517
- ignoreCase = true;
518
- continue;
519
- }
520
- if (a === "-c" || a.startsWith("-c") || a === "--columns" || a.startsWith("--columns=")) {
521
- const v = a.startsWith("--columns=") ? a.slice(10) : a.startsWith("-c=") ? a.slice(3) : a.length > 2 && a.startsWith("-c") ? a.slice(2) : opArgs[++i];
522
- if (v === void 0) return void 0;
523
- columnsSpec = v;
524
- continue;
525
- }
526
- }
527
- filteredArgs.push(a);
528
- }
529
- const opts = parseSyncCsvkitCommon(filteredArgs, "csvlook");
530
- if (!opts) return void 0;
531
- const table = loadSyncTypedTable(inBytes, opts, readFileSync);
532
- if (!table) return void 0;
533
- let out = opts.addBom ? "\uFEFF" : "";
534
- if (namesOnly) {
535
- if (opts.noHeaderRow) return void 0;
536
- for (let i = 0; i < table.headers.length; i++) {
537
- out += `${String(i + (zeroBased ? 0 : 1)).padStart(3, " ")}: ${table.headers[i]}
538
- `;
539
- }
540
- return out;
541
- }
542
- const columns = parseColumnIdentifiers(columnsSpec, table.headers, zeroBased ? 0 : 1, null, () => {
543
- }, true);
544
- const rows = [...table.rows];
545
- const keyed = rows.map(
546
- (row) => columns.map((idx) => {
547
- const val = row[idx];
548
- return ignoreCase && typeof val === "string" ? val.toUpperCase() : val;
549
- })
550
- );
551
- const indices = rows.map((_, i) => i);
552
- indices.sort((a, b) => {
553
- for (let c = 0; c < columns.length; c++) {
554
- const x = keyed[a][c];
555
- const y = keyed[b][c];
556
- let order = 0;
557
- if (x === null || y === null) order = x === null ? y === null ? 0 : 1 : -1;
558
- else if (typeof x === "string" && typeof y === "string") {
559
- order = x < y ? -1 : x > y ? 1 : 0;
560
- } else if (typeof x === "boolean" && typeof y === "boolean") {
561
- order = Number(x) - Number(y);
562
- } else if (typeof x === "object" && typeof y === "object" && x.kind === "decimal" && y.kind === "decimal") {
563
- if (x.value.includes("NaN") || y.value.includes("NaN")) throw new Error("NaN");
564
- order = Decimal.parse(x.value).compare(Decimal.parse(y.value));
565
- } else if (typeof x === "object" && typeof y === "object" && (x.kind === "date" || x.kind === "datetime") && (y.kind === "date" || y.kind === "datetime") && x.kind === y.kind) {
566
- order = x.value < y.value ? -1 : x.value > y.value ? 1 : 0;
567
- } else if (typeof x === "object" && typeof y === "object" && x.kind === "timedelta" && y.kind === "timedelta") {
568
- order = x.microseconds < y.microseconds ? -1 : x.microseconds > y.microseconds ? 1 : 0;
569
- } else {
570
- throw new Error("unsupported type");
571
- }
572
- if (order !== 0) return reverse ? -order : order;
573
- }
574
- return 0;
575
- });
576
- const outDialect = { delimiter: ",", quotechar: '"', doublequote: true, lineterminator: "\n" };
577
- out += writeCsvRow(table.headers, outDialect);
578
- for (const idx of indices) {
579
- const formattedCells = rows[idx].map((v) => {
580
- if (v === null) return "";
581
- if (typeof v === "object" && v.kind === "datetime") return v.value.replace(" ", "T");
582
- return pythonValueText(v);
583
- });
584
- out += writeCsvRow(formattedCells, outDialect);
585
- }
586
- return out;
587
- } catch {
588
- return void 0;
589
- }
590
- }
591
- function evalSyncCsvformat(inBytes, opArgs, readFileSync) {
592
- try {
593
- let outDelimiter = ",";
594
- let outTabs = false;
595
- let outAsv = false;
596
- let outQuotechar = '"';
597
- let outQuoting = 0;
598
- let outNoDoublequote = false;
599
- let outEscapechar;
600
- let outLineterminator = "\n";
601
- let skipHeader = false;
602
- const filteredArgs = [];
603
- let posDone = false;
604
- for (let i = 0; i < opArgs.length; i++) {
605
- const a = opArgs[i];
606
- if (!posDone && a === "--") {
607
- posDone = true;
608
- filteredArgs.push(a);
609
- continue;
610
- }
611
- if (!posDone && a.startsWith("-") && a !== "-") {
612
- if (a === "-E" || a === "--skip-header") {
613
- skipHeader = true;
614
- continue;
615
- }
616
- if (a === "-T" || a === "--out-tabs") {
617
- outTabs = true;
618
- continue;
619
- }
620
- if (a === "-A" || a === "--out-asv") {
621
- outAsv = true;
622
- continue;
623
- }
624
- if (a === "-B" || a === "--out-no-doublequote") {
625
- outNoDoublequote = true;
626
- continue;
627
- }
628
- if (a === "-D" || a.startsWith("-D") || a === "--out-delimiter" || a.startsWith("--out-delimiter=")) {
629
- const v = a.startsWith("--out-delimiter=") ? a.slice(16) : a.startsWith("-D=") ? a.slice(3) : a.length > 2 && a.startsWith("-D") ? a.slice(2) : opArgs[++i];
630
- if (!v || Array.from(v).length !== 1) return void 0;
631
- outDelimiter = v;
632
- continue;
633
- }
634
- if (a === "-Q" || a.startsWith("-Q") || a === "--out-quotechar" || a.startsWith("--out-quotechar=")) {
635
- const v = a.startsWith("--out-quotechar=") ? a.slice(16) : a.startsWith("-Q=") ? a.slice(3) : a.length > 2 && a.startsWith("-Q") ? a.slice(2) : opArgs[++i];
636
- if (!v || Array.from(v).length !== 1) return void 0;
637
- outQuotechar = v;
638
- continue;
639
- }
640
- if (a === "-P" || a === "--out-escapechar") {
641
- const v = opArgs[++i];
642
- if (!v || Array.from(v).length !== 1) return void 0;
643
- outEscapechar = v;
644
- continue;
645
- }
646
- if (a === "-M" || a.startsWith("-M") || a === "--out-lineterminator" || a.startsWith("--out-lineterminator=")) {
647
- const v = a.startsWith("--out-lineterminator=") ? a.slice(21) : a.startsWith("-M=") ? a.slice(3) : a.length > 2 && a.startsWith("-M") ? a.slice(2) : opArgs[++i];
648
- if (v === void 0) return void 0;
649
- outLineterminator = v;
650
- continue;
651
- }
652
- if (a === "-U" || a.startsWith("-U") || a === "--out-quoting" || a.startsWith("--out-quoting=")) {
653
- const v = a.startsWith("--out-quoting=") ? a.slice(14) : a.startsWith("-U=") ? a.slice(3) : a.length > 2 && a.startsWith("-U") ? a.slice(2) : opArgs[++i];
654
- if (v === void 0 || !/^[0123]$/.test(v)) return void 0;
655
- outQuoting = Number(v);
656
- continue;
657
- }
658
- }
659
- filteredArgs.push(a);
660
- }
661
- const opts = parseSyncCsvkitCommon(filteredArgs, "csvlook");
662
- if (!opts) return void 0;
663
- let sourceBytes = inBytes;
664
- if (opts.filePath !== void 0 && opts.filePath !== "-") {
665
- if (!readFileSync) return void 0;
666
- sourceBytes = readFileSync(opts.filePath);
667
- }
668
- if (!sourceBytes || sourceBytes.byteLength > 16384) return void 0;
669
- let text = syncUtf8Decoder.decode(sourceBytes);
670
- if (text.charCodeAt(0) === 65279) text = text.slice(1);
671
- if (opts.skipLines > 0) {
672
- let linesLeft = opts.skipLines;
673
- let pos = 0;
674
- while (pos < text.length && linesLeft > 0) {
675
- const ch = text[pos++];
676
- if (ch === "\r") {
677
- if (text[pos] === "\n") pos++;
678
- linesLeft--;
679
- } else if (ch === "\n") linesLeft--;
680
- }
681
- text = text.slice(pos);
682
- }
683
- const explicitInDelimiter = opts.tabs ? " " : opts.delimiter;
684
- let inDialect = {
685
- ...explicitInDelimiter !== void 0 ? { delimiter: explicitInDelimiter } : {},
686
- ...opts.quotechar !== void 0 ? { quotechar: opts.quotechar } : {},
687
- ...opts.escapechar !== void 0 ? { escapechar: opts.escapechar } : {},
688
- doublequote: !opts.noDoublequote,
689
- skipinitialspace: opts.skipInitialSpace
690
- };
691
- if (!opts.tabs && opts.delimiter === void 0 && opts.quotechar === void 0 && opts.escapechar === void 0 && !opts.noDoublequote && !opts.skipInitialSpace && opts.sniffLimit !== 0 && text.length > 0) {
692
- const sample = opts.sniffLimit > 0 ? text.slice(0, opts.sniffLimit) : text;
693
- if (sample.includes(",") && !/[\t;|:\x27]/.test(sample)) {
694
- inDialect = { delimiter: ",", quotechar: '"', doublequote: true, skipinitialspace: false };
695
- } else {
696
- const sniffed = sniff(sample);
697
- if (sniffed) inDialect = sniffed;
698
- }
699
- }
700
- const outDialect = {
701
- delimiter: outAsv ? "" : outTabs ? " " : outDelimiter,
702
- lineterminator: outAsv ? "" : outLineterminator,
703
- quotechar: outQuotechar,
704
- quoting: outQuoting,
705
- doublequote: !outNoDoublequote,
706
- ...outEscapechar !== void 0 ? { escapechar: outEscapechar } : {}
707
- };
708
- writeCsvRow([], outDialect);
709
- let out = opts.addBom ? "\uFEFF" : "";
710
- let first = true;
711
- for (const record of readCsv(text, inDialect)) {
712
- const values = record.cells.map((c) => pythonValueText(c));
713
- if (first) {
714
- first = false;
715
- if (opts.noHeaderRow) {
716
- if (!skipHeader) {
717
- const hdr = defaultHeaders(values.length);
718
- out += writeCsvRow(opts.lineNumbers ? ["line_number", ...hdr] : hdr, outDialect);
719
- }
720
- } else {
721
- if (!skipHeader) {
722
- out += writeCsvRow(opts.lineNumbers ? ["line_number", ...values] : values, outDialect);
723
- }
724
- continue;
725
- }
726
- }
727
- const rowCells = opts.lineNumbers ? [String(record.line - (opts.noHeaderRow ? 0 : 1)), ...values] : values;
728
- out += writeCsvRow(rowCells, outDialect);
729
- }
730
- return out;
731
- } catch {
732
- return void 0;
733
- }
734
- }
735
- function evalSyncCsvstat(inBytes, opArgs, readFileSync) {
736
- try {
737
- let countOnly = false;
738
- let namesOnly = false;
739
- let zeroBased = false;
740
- let noGrouping = false;
741
- let columnsSpec = null;
742
- let metricOp;
743
- const filteredArgs = [];
744
- let posDone = false;
745
- for (let i = 0; i < opArgs.length; i++) {
746
- const a = opArgs[i];
747
- if (!posDone && a === "--") {
748
- posDone = true;
749
- filteredArgs.push(a);
750
- continue;
751
- }
752
- if (!posDone && a.startsWith("-") && a !== "-") {
753
- if (a === "--count") {
754
- countOnly = true;
755
- continue;
756
- }
757
- if (a === "-n" || a === "--names") {
758
- namesOnly = true;
759
- continue;
760
- }
761
- if (a === "--zero") {
762
- zeroBased = true;
763
- continue;
764
- }
765
- if (a === "-G" || a === "--no-grouping-separator") {
766
- noGrouping = true;
767
- continue;
768
- }
769
- if (a === "-c" || a.startsWith("-c") || a === "--columns" || a.startsWith("--columns=")) {
770
- const v = a.startsWith("--columns=") ? a.slice(10) : a.startsWith("-c=") ? a.slice(3) : a.length > 2 && a.startsWith("-c") ? a.slice(2) : opArgs[++i];
771
- if (!v) return void 0;
772
- columnsSpec = v;
773
- continue;
774
- }
775
- const mMap = {
776
- "--type": "type",
777
- "--nulls": "nulls",
778
- "--non-nulls": "nonnulls",
779
- "--unique": "unique",
780
- "--min": "min",
781
- "--max": "max",
782
- "--sum": "sum",
783
- "--mean": "mean",
784
- "--median": "median",
785
- "--stdev": "stdev",
786
- "--max-precision": "max_precision",
787
- "--len": "len"
788
- };
789
- if (mMap[a]) {
790
- if (metricOp !== void 0) return void 0;
791
- metricOp = mMap[a];
792
- continue;
793
- }
794
- }
795
- filteredArgs.push(a);
796
- }
797
- const modeCount = (countOnly ? 1 : 0) + (namesOnly ? 1 : 0) + (metricOp ? 1 : 0);
798
- if (modeCount !== 1) return void 0;
799
- const opts = parseSyncCsvkitCommon(filteredArgs, "csvlook");
800
- if (!opts) return void 0;
801
- const table = loadSyncTypedTable(inBytes, opts, readFileSync);
802
- if (!table) return void 0;
803
- let out = opts.addBom ? "\uFEFF" : "";
804
- if (namesOnly) {
805
- if (opts.noHeaderRow) return void 0;
806
- for (let i = 0; i < table.headers.length; i++) {
807
- out += `${String(i + (zeroBased ? 0 : 1)).padStart(3, " ")}: ${table.headers[i]}
808
- `;
809
- }
810
- return out;
811
- }
812
- if (countOnly) {
813
- return out + `${table.rows.length}
814
- `;
815
- }
816
- const ids = parseColumnIdentifiers(columnsSpec, table.headers, zeroBased ? 0 : 1, void 0, () => {
817
- }, true);
818
- const fmtDec = (d) => {
819
- const num = Number(d.toString());
820
- if (!Number.isFinite(num)) return d.toString();
821
- let s = num.toFixed(3);
822
- while (s.endsWith("0")) s = s.slice(0, -1);
823
- if (s.endsWith(".")) s = s.slice(0, -1);
824
- if (!noGrouping) {
825
- const [intPart = "", fracPart] = s.split(".");
826
- const sign = intPart.startsWith("-") ? "-" : "";
827
- const digits = sign ? intPart.slice(1) : intPart;
828
- const grouped = digits.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
829
- s = sign + grouped + (fracPart !== void 0 ? "." + fracPart : "");
830
- }
831
- return s;
832
- };
833
- for (const id of ids) {
834
- const colType = table.columns[id].type;
835
- const values = table.rows.map((r) => r[id]);
836
- const nonNull = values.filter((v) => v !== null);
837
- let valStr = "None";
838
- if (metricOp === "type") valStr = colType;
839
- else if (metricOp === "nulls") valStr = nonNull.length !== values.length ? "True" : "False";
840
- else if (metricOp === "nonnulls") valStr = String(nonNull.length);
841
- else if (metricOp === "unique") {
842
- const seen = new Set(values.map((v) => v === null ? "null" : typeof v === "object" && v.kind === "decimal" ? "d:" + Decimal.parse(v.value).normalized().toString() : typeof v + ":" + pythonValueText(v)));
843
- valStr = String(seen.size);
844
- } else if (metricOp === "len" && colType === "Text") {
845
- let maxLen = 0;
846
- for (const v of nonNull) maxLen = Math.max(maxLen, Array.from(String(v)).length);
847
- valStr = fmtDec(Decimal.parse(String(maxLen)));
848
- } else if ((metricOp === "min" || metricOp === "max") && colType !== "Number") {
849
- if (nonNull.length > 0) {
850
- const strs = nonNull.map((v) => typeof v === "object" && v !== null && "value" in v ? String(v.value) : pythonValueText(v));
851
- let best = strs[0];
852
- for (let k = 1; k < strs.length; k++) {
853
- if (metricOp === "min" ? strs[k] < best : strs[k] > best) best = strs[k];
854
- }
855
- valStr = best;
856
- }
857
- } else if ((metricOp === "min" || metricOp === "max" || metricOp === "sum" || metricOp === "mean" || metricOp === "median" || metricOp === "stdev" || metricOp === "max_precision") && colType === "Number") {
858
- if (nonNull.length > 0) {
859
- const decs = nonNull.map((v) => Decimal.parse(v.value));
860
- if (metricOp === "min" || metricOp === "max") {
861
- let best = decs[0];
862
- for (let k = 1; k < decs.length; k++) {
863
- if (metricOp === "min" ? decs[k].compare(best) < 0 : decs[k].compare(best) > 0) best = decs[k];
864
- }
865
- valStr = fmtDec(best);
866
- } else if (metricOp === "max_precision") {
867
- let maxP = 0;
868
- for (const d of decs) {
869
- const norm = d.normalized();
870
- if (!norm.special && -norm.exponent > maxP) maxP = -norm.exponent;
871
- }
872
- valStr = fmtDec(Decimal.parse(String(maxP)));
873
- } else if (metricOp === "median") {
874
- const sorted = [...decs].sort((a, b) => a.compare(b));
875
- const mid = Math.floor(sorted.length / 2);
876
- const med = sorted.length % 2 === 1 ? sorted[mid] : sorted[mid - 1].add(sorted[mid]).divide(Decimal.parse("2"));
877
- valStr = fmtDec(med);
878
- } else if (metricOp === "stdev") {
879
- if (decs.length >= 2) {
880
- const nums = decs.map((d) => Number(d.toString()));
881
- if (nums.some((n) => !Number.isFinite(n))) return void 0;
882
- const mean = nums.reduce((a, b) => a + b, 0) / nums.length;
883
- const variance = nums.reduce((acc, n) => acc + (n - mean) * (n - mean), 0) / (nums.length - 1);
884
- valStr = fmtDec(Decimal.parse(String(Math.sqrt(variance))));
885
- }
886
- } else {
887
- let sum = Decimal.parse("0");
888
- for (const d of decs) sum = sum.add(d);
889
- valStr = fmtDec(metricOp === "sum" ? sum : sum.divide(Decimal.parse(String(decs.length))));
890
- }
891
- }
892
- } else {
893
- return void 0;
894
- }
895
- out += (ids.length === 1 ? "" : `${String(id + 1).padStart(3)}. ${table.headers[id]}: `) + valStr + "\n";
896
- }
897
- return out;
898
- } catch {
899
- return void 0;
900
- }
901
- }
902
- function evalSyncIn2csv(inBytes, opArgs, readFileSync) {
903
- try {
904
- let formatSpec;
905
- let keySpec;
906
- let schemaSpec;
907
- let sheetSpec;
908
- let namesOnly = false;
909
- const filteredArgs = [];
910
- let posDone = false;
911
- for (let i = 0; i < opArgs.length; i++) {
912
- const a = opArgs[i];
913
- if (!posDone && a === "--") {
914
- posDone = true;
915
- filteredArgs.push(a);
916
- continue;
917
- }
918
- if (!posDone && a.startsWith("-") && a !== "-") {
919
- if (a === "-n" || a === "--names") {
920
- namesOnly = true;
921
- continue;
922
- }
923
- if (a === "-f" || a.startsWith("-f") || a === "--format" || a.startsWith("--format=")) {
924
- const v = a.startsWith("--format=") ? a.slice(9) : a.startsWith("-f=") ? a.slice(3) : a.length > 2 && a.startsWith("-f") ? a.slice(2) : opArgs[++i];
925
- if (!v) return void 0;
926
- formatSpec = v.toLowerCase();
927
- continue;
928
- }
929
- if (a === "-k" || a.startsWith("-k") || a === "--key" || a.startsWith("--key=")) {
930
- const v = a.startsWith("--key=") ? a.slice(6) : a.startsWith("-k=") ? a.slice(3) : a.length > 2 && a.startsWith("-k") ? a.slice(2) : opArgs[++i];
931
- if (!v) return void 0;
932
- keySpec = v;
933
- continue;
934
- }
935
- if (a === "--sheet" || a.startsWith("--sheet=")) {
936
- const v = a.startsWith("--sheet=") ? a.slice(8) : opArgs[++i];
937
- if (!v) return void 0;
938
- sheetSpec = v;
939
- continue;
940
- }
941
- if (a === "-s" || a.startsWith("-s") || a === "--schema" || a.startsWith("--schema=")) {
942
- const v = a.startsWith("--schema=") ? a.slice(9) : a.startsWith("-s=") ? a.slice(3) : a.length > 2 && a.startsWith("-s") ? a.slice(2) : opArgs[++i];
943
- if (!v) return void 0;
944
- schemaSpec = v;
945
- continue;
946
- }
947
- }
948
- filteredArgs.push(a);
949
- }
950
- const opts = parseSyncCsvkitCommon(filteredArgs, "csvlook");
951
- if (!opts) return void 0;
952
- let sourceBytes = inBytes;
953
- if (opts.filePath !== void 0 && opts.filePath !== "-") {
954
- if (!readFileSync) return void 0;
955
- sourceBytes = readFileSync(opts.filePath);
956
- }
957
- if (!sourceBytes || sourceBytes.byteLength > 16384) return void 0;
958
- let fmt = formatSpec;
959
- if (!fmt && opts.filePath && opts.filePath !== "-") {
960
- const lower = opts.filePath.toLowerCase();
961
- if (lower.endsWith(".geojson")) fmt = "geojson";
962
- else if (lower.endsWith(".xlsx")) fmt = "xlsx";
963
- else if (lower.endsWith(".json") || lower.endsWith(".js")) fmt = "json";
964
- else if (lower.endsWith(".ndjson") || lower.endsWith(".jsonl")) fmt = "ndjson";
965
- else if (lower.endsWith(".csv") || lower.endsWith(".tsv")) fmt = "csv";
966
- }
967
- if (!fmt && schemaSpec !== void 0) fmt = "fixed";
968
- if (!fmt && keySpec !== void 0) fmt = "json";
969
- if (fmt === "geojson") {
970
- if (namesOnly) return void 0;
971
- let text2 = syncUtf8Decoder.decode(sourceBytes);
972
- if (text2.charCodeAt(0) === 65279) text2 = text2.slice(1);
973
- const doc = JSON.parse(text2);
974
- if (!doc || typeof doc !== "object" || Array.isArray(doc) || doc.type !== "FeatureCollection" || !Array.isArray(doc.features)) {
975
- return void 0;
976
- }
977
- const propKeys = [];
978
- const seenProps = /* @__PURE__ */ new Set();
979
- for (const feat of doc.features) {
980
- if (!feat || typeof feat !== "object" || Array.isArray(feat)) return void 0;
981
- const props = feat.properties && typeof feat.properties === "object" && !Array.isArray(feat.properties) ? feat.properties : {};
982
- for (const k of Object.keys(props)) {
983
- if (!seenProps.has(k)) {
984
- seenProps.add(k);
985
- propKeys.push(k);
986
- }
987
- }
988
- }
989
- const outDialect2 = { delimiter: ",", quotechar: '"', doublequote: true, lineterminator: "\n" };
990
- let out2 = writeCsvRow(["id", ...propKeys, "geojson", "type", "longitude", "latitude"], outDialect2);
991
- for (const feat of doc.features) {
992
- const props = feat.properties && typeof feat.properties === "object" && !Array.isArray(feat.properties) ? feat.properties : {};
993
- const geom = feat.geometry && typeof feat.geometry === "object" && !Array.isArray(feat.geometry) ? feat.geometry : null;
994
- const gType = geom ? String(geom.type ?? "") : "";
995
- const coords = gType === "Point" && Array.isArray(geom?.coordinates) && geom.coordinates.length >= 2 ? geom.coordinates : void 0;
996
- const fmtVal = (v, isProp = false) => {
997
- if (v === void 0 || v === null) return "";
998
- if (typeof v === "boolean") return v ? "True" : "False";
999
- if (typeof v === "object") return isProp ? JSON.stringify(v) : "";
1000
- return String(v);
1001
- };
1002
- const geomJson = JSON.stringify(geom).replace(/":/g, '": ').replace(/,"/g, ', "');
1003
- const rowCells = [
1004
- fmtVal(feat.id),
1005
- ...propKeys.map((k) => fmtVal(props[k], true)),
1006
- geomJson,
1007
- gType,
1008
- coords ? fmtVal(coords[0]) : "",
1009
- coords ? fmtVal(coords[1]) : ""
1010
- ];
1011
- out2 += writeCsvRow(rowCells, outDialect2);
1012
- }
1013
- return out2;
1014
- }
1015
- if (fmt === "xlsx") {
1016
- if (sourceBytes[0] !== 80 || sourceBytes[1] !== 75) return void 0;
1017
- const entries = readZipArchiveEntries(sourceBytes);
1018
- if (entries.has("EncryptionInfo") || entries.has("EncryptedPackage")) return void 0;
1019
- const wbXmlBytes = entries.get("xl/workbook.xml");
1020
- if (!wbXmlBytes) return void 0;
1021
- const wbXml = syncUtf8Decoder.decode(wbXmlBytes);
1022
- const sheetNames = [];
1023
- for (const m of wbXml.matchAll(/<sheet\b[^>]*\bname="([^"]+)"/g)) {
1024
- sheetNames.push(m[1]);
1025
- }
1026
- if (sheetNames.length === 0) return void 0;
1027
- if (namesOnly) {
1028
- return sheetNames.map((n) => n + "\n").join("");
1029
- }
1030
- const targetIdx = sheetSpec ? sheetNames.indexOf(sheetSpec) : 0;
1031
- if (targetIdx < 0) return void 0;
1032
- const sheetBytes = entries.get(`xl/worksheets/sheet${targetIdx + 1}.xml`);
1033
- if (!sheetBytes) return void 0;
1034
- const sheetXml = syncUtf8Decoder.decode(sheetBytes);
1035
- if (/<f(?:\s|>)/u.test(sheetXml)) return void 0;
1036
- const sharedStrings = [];
1037
- const sstBytes = entries.get("xl/sharedStrings.xml");
1038
- if (sstBytes) {
1039
- const sstXml = syncUtf8Decoder.decode(sstBytes);
1040
- for (const si of sstXml.matchAll(/<si\b[\s\S]*?<\/si>/g)) {
1041
- const parts = [...si[0].matchAll(/<t(?:\s[^>]*)?>([\s\S]*?)<\/t>/g)].map(
1042
- (t) => (t[1] ?? "").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&")
1043
- );
1044
- sharedStrings.push(parts.join(""));
1045
- }
1046
- }
1047
- const csvRows = [];
1048
- for (const rm of sheetXml.matchAll(/<row\b[\s\S]*?<\/row>/g)) {
1049
- const cells = [];
1050
- for (const cm of rm[0].matchAll(/<c\b([^>]*?)(?:\/>|>([\s\S]*?)<\/c>)/g)) {
1051
- const attrs = cm[1] ?? "";
1052
- const body = cm[2] ?? "";
1053
- const refM = /\br="([A-Z]+)\d+"/i.exec(attrs);
1054
- if (refM?.[1]) {
1055
- let col = 0;
1056
- for (const ch of refM[1].toUpperCase()) col = col * 26 + (ch.charCodeAt(0) - 64);
1057
- col -= 1;
1058
- while (cells.length < col) cells.push("");
1059
- }
1060
- if (cm[2] === void 0) {
1061
- cells.push("");
1062
- continue;
1063
- }
1064
- const tM = /\bt="([^"]+)"/.exec(attrs);
1065
- const cType = tM?.[1] ?? "n";
1066
- if (cType === "inlineStr") {
1067
- const tv = /<t(?:\s[^>]*)?>([\s\S]*?)<\/t>/.exec(body);
1068
- cells.push((tv?.[1] ?? "").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&"));
1069
- } else {
1070
- const vv = /<v>([\s\S]*?)<\/v>/.exec(body);
1071
- const raw = (vv?.[1] ?? "").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
1072
- cells.push(cType === "s" ? sharedStrings[Number.parseInt(raw, 10)] ?? "" : raw);
1073
- }
1074
- }
1075
- csvRows.push(cells);
1076
- }
1077
- const synthDialect = { delimiter: ",", quotechar: '"', doublequote: true, lineterminator: "\n" };
1078
- const synthCsv = csvRows.map((r) => writeCsvRow(r, synthDialect)).join("");
1079
- const synthBytes = new TextEncoder().encode(synthCsv);
1080
- const table2 = loadSyncTypedTable(synthBytes, { ...opts, filePath: "-" }, void 0);
1081
- if (!table2) return void 0;
1082
- let out2 = opts.addBom ? "\uFEFF" : "";
1083
- out2 += writeCsvRow(table2.headers, synthDialect);
1084
- for (const row of table2.rows) {
1085
- out2 += writeCsvRow(
1086
- row.map((v) => v === null ? "" : typeof v === "object" && v.kind === "datetime" ? v.value.replace(" ", "T") : pythonValueText(v)),
1087
- synthDialect
1088
- );
1089
- }
1090
- return out2;
1091
- }
1092
- if (fmt === "fixed") {
1093
- if (!schemaSpec || !readFileSync) return void 0;
1094
- const schemaBytes = readFileSync(schemaSpec);
1095
- if (!schemaBytes || schemaBytes.byteLength > 16384) return void 0;
1096
- let schemaText = syncUtf8Decoder.decode(schemaBytes);
1097
- if (schemaText.charCodeAt(0) === 65279) schemaText = schemaText.slice(1);
1098
- const schemaRows = Array.from(readCsv(schemaText, { delimiter: ",", quotechar: '"', doublequote: true }), (record) => record.cells);
1099
- if (schemaRows.length < 2) return void 0;
1100
- const sHead = schemaRows[0];
1101
- const colIdx = sHead.indexOf("column");
1102
- const startIdx = sHead.indexOf("start");
1103
- const lenIdx = sHead.indexOf("length");
1104
- if (colIdx < 0 || startIdx < 0 || lenIdx < 0) return void 0;
1105
- let oneBased;
1106
- const fields = [];
1107
- for (let r = 1; r < schemaRows.length; r++) {
1108
- const row = schemaRows[r];
1109
- if (row.length === 0 || row.length === 1 && row[0] === "") continue;
1110
- const stNum = Number(row[startIdx]);
1111
- const lnNum = Number(row[lenIdx]);
1112
- if (!Number.isSafeInteger(stNum) || !Number.isSafeInteger(lnNum) || stNum < 0 || lnNum < 0) return void 0;
1113
- oneBased ??= stNum === 1;
1114
- fields.push({ name: row[colIdx], start: stNum - (oneBased ? 1 : 0), length: lnNum });
1115
- }
1116
- let inText = syncUtf8Decoder.decode(sourceBytes);
1117
- if (inText.charCodeAt(0) === 65279) inText = inText.slice(1);
1118
- const rawLines = inText.split(/\r?\n/);
1119
- if (rawLines.length > 0 && rawLines[rawLines.length - 1] === "") rawLines.pop();
1120
- const outDialect2 = { delimiter: ",", quotechar: '"', doublequote: true, lineterminator: "\n" };
1121
- let out2 = opts.addBom ? "\uFEFF" : "";
1122
- out2 += writeCsvRow(fields.map((f) => f.name), outDialect2);
1123
- for (let idx = opts.skipLines; idx < rawLines.length; idx++) {
1124
- const chars = Array.from(rawLines[idx]);
1125
- const cells = fields.map((f) => chars.slice(f.start, f.start + f.length).join("").trim());
1126
- out2 += writeCsvRow(cells, outDialect2);
1127
- }
1128
- return out2;
1129
- }
1130
- if (namesOnly) {
1131
- if (fmt !== "json") return void 0;
1132
- let text2 = syncUtf8Decoder.decode(sourceBytes);
1133
- if (text2.charCodeAt(0) === 65279) text2 = text2.slice(1);
1134
- const root = JSON.parse(text2);
1135
- if (!root || typeof root !== "object" || Array.isArray(root)) return void 0;
1136
- return Object.keys(root).map((k) => k + "\n").join("");
1137
- }
1138
- if (fmt === "csv") {
1139
- const table2 = loadSyncTypedTable(inBytes, opts, readFileSync);
1140
- if (!table2) return void 0;
1141
- const outDialect2 = { delimiter: ",", quotechar: '"', doublequote: true, lineterminator: "\n" };
1142
- let out2 = opts.addBom ? "\uFEFF" : "";
1143
- out2 += writeCsvRow(table2.headers, outDialect2);
1144
- for (const row of table2.rows) {
1145
- out2 += writeCsvRow(
1146
- row.map((v) => v === null ? "" : typeof v === "object" && v.kind === "datetime" ? v.value.replace(" ", "T") : pythonValueText(v)),
1147
- outDialect2
1148
- );
1149
- }
1150
- return out2;
1151
- }
1152
- if (fmt !== "json" && fmt !== "ndjson") return void 0;
1153
- if (fmt === "ndjson" && keySpec !== void 0) return void 0;
1154
- let text = syncUtf8Decoder.decode(sourceBytes);
1155
- if (text.charCodeAt(0) === 65279) text = text.slice(1);
1156
- let parsedItems;
1157
- if (fmt === "ndjson") {
1158
- parsedItems = [];
1159
- for (const line of text.split(/\r?\n/)) {
1160
- const trimmed = line.trim();
1161
- if (!trimmed) continue;
1162
- parsedItems.push(JSON.parse(trimmed));
1163
- }
1164
- } else {
1165
- let root = JSON.parse(text);
1166
- if (root && typeof root === "object" && !Array.isArray(root)) {
1167
- if (!keySpec || !(keySpec in root)) return void 0;
1168
- root = root[keySpec];
1169
- }
1170
- if (!Array.isArray(root)) return void 0;
1171
- parsedItems = root;
1172
- }
1173
- const headers = [];
1174
- const known = /* @__PURE__ */ new Set();
1175
- const rawMaps = [];
1176
- const flatten = (val, path, row) => {
1177
- if (val !== null && typeof val === "object") {
1178
- if (Array.isArray(val)) {
1179
- for (let idx = 0; idx < val.length; idx++) flatten(val[idx], path + String(idx) + "/", row);
1180
- } else {
1181
- for (const [k, child] of Object.entries(val)) flatten(child, path + k + "/", row);
1182
- }
1183
- return;
1184
- }
1185
- let start = 0;
1186
- let end = path.length;
1187
- while (path[start] === "/") start++;
1188
- while (end > start && path[end - 1] === "/") end--;
1189
- const name = path.slice(start, end);
1190
- if (!name) throw new Error("empty header");
1191
- const cell = val === null || val === void 0 ? null : typeof val === "boolean" ? val ? "True" : "False" : String(val);
1192
- row.set(name, cell);
1193
- };
1194
- for (const item of parsedItems) {
1195
- if (item === null || typeof item !== "object" || Array.isArray(item)) return void 0;
1196
- const row = /* @__PURE__ */ new Map();
1197
- flatten(item, "", row);
1198
- for (const name of row.keys()) {
1199
- if (!known.has(name)) {
1200
- known.add(name);
1201
- headers.push(name);
1202
- }
1203
- }
1204
- rawMaps.push(row);
1205
- }
1206
- if (headers.length === 0) return void 0;
1207
- const stringRows = rawMaps.map((m, rIdx) => {
1208
- const cells = headers.map((h) => m.get(h) ?? "");
1209
- return opts.lineNumbers ? [String(rIdx + 1), ...cells] : cells;
1210
- });
1211
- const finalHeaders = opts.lineNumbers ? ["line_number", ...headers] : headers;
1212
- const inferenceOpts = {
1213
- now: Date.now(),
1214
- timezone: "UTC",
1215
- noInference: opts.noInference,
1216
- numberTextOnly: false,
1217
- blanks: opts.blanks,
1218
- nullValues: [],
1219
- noLeadingZeroes: opts.noLeadingZeroes,
1220
- maxDecimalDigits: Infinity,
1221
- maxDecimalExponent: Infinity
1222
- };
1223
- const table = inferTable(finalHeaders, stringRows, inferenceOpts);
1224
- const outDialect = { delimiter: ",", quotechar: '"', doublequote: true, lineterminator: "\n" };
1225
- let out = opts.addBom ? "\uFEFF" : "";
1226
- out += writeCsvRow(table.headers, outDialect);
1227
- for (const row of table.rows) {
1228
- out += writeCsvRow(
1229
- row.map((v) => v === null ? "" : typeof v === "object" && v.kind === "datetime" ? v.value.replace(" ", "T") : pythonValueText(v)),
1230
- outDialect
1231
- );
1232
- }
1233
- return out;
1234
- } catch {
1235
- return void 0;
1236
- }
1237
- }
1238
- function evalSyncCsvstack(inBytes, opArgs, readFileSync) {
1239
- try {
1240
- let groupsSpec;
1241
- let groupName = "group";
1242
- let groupByFilenames = false;
1243
- let noHeaderRow = false;
1244
- let lineNumbers = false;
1245
- let addBom = false;
1246
- let delimiter = ",";
1247
- let tabs = false;
1248
- const files = [];
1249
- let posDone = false;
1250
- for (let i = 0; i < opArgs.length; i++) {
1251
- const a = opArgs[i];
1252
- if (!posDone && a === "--") {
1253
- posDone = true;
1254
- continue;
1255
- }
1256
- if (!posDone && a.startsWith("-") && a !== "-") {
1257
- if (a === "-H" || a === "--no-header-row") {
1258
- noHeaderRow = true;
1259
- continue;
1260
- }
1261
- if (a === "-l" || a === "--linenumbers") {
1262
- lineNumbers = true;
1263
- continue;
1264
- }
1265
- if (a === "--add-bom") {
1266
- addBom = true;
1267
- continue;
1268
- }
1269
- if (a === "-t" || a === "--tabs") {
1270
- tabs = true;
1271
- continue;
1272
- }
1273
- if (a === "-d" || a === "--delimiter" || a.startsWith("--delimiter=")) {
1274
- const v = a.startsWith("--delimiter=") ? a.slice(12) : opArgs[++i];
1275
- if (!v || Array.from(v).length !== 1) return void 0;
1276
- delimiter = v;
1277
- continue;
1278
- }
1279
- if (a === "--filenames") {
1280
- groupByFilenames = true;
1281
- continue;
1282
- }
1283
- if (a === "-g" || a === "--groups") {
1284
- const v = opArgs[++i];
1285
- if (v === void 0) return void 0;
1286
- groupsSpec = v;
1287
- continue;
1288
- }
1289
- if (a === "-n" || a === "--group-name") {
1290
- const v = opArgs[++i];
1291
- if (v === void 0) return void 0;
1292
- groupName = v;
1293
- continue;
1294
- }
1295
- return void 0;
1296
- }
1297
- files.push(a);
1298
- }
1299
- if (files.length === 0) files.push("-");
1300
- if (noHeaderRow) return void 0;
1301
- const groups = groupsSpec !== void 0 && !groupByFilenames ? groupsSpec.split(",") : void 0;
1302
- if (groups && groups.length !== files.length) return void 0;
1303
- const grouped = groupsSpec !== void 0 || groupByFilenames;
1304
- const parsedFiles = [];
1305
- const unionHeaders = [];
1306
- const seen = /* @__PURE__ */ new Set();
1307
- for (let idx = 0; idx < files.length; idx++) {
1308
- const f = files[idx];
1309
- const bytes = f === "-" ? inBytes : readFileSync ? readFileSync(f) : void 0;
1310
- if (!bytes || bytes.byteLength > 16384) return void 0;
1311
- let text = syncUtf8Decoder.decode(bytes);
1312
- if (text.charCodeAt(0) === 65279) text = text.slice(1);
1313
- const recs = [...readCsv(text, { delimiter: tabs ? " " : delimiter, quotechar: '"', doublequote: true, skipinitialspace: false })];
1314
- const hdr = recs[0] ? recs[0].cells.map((c) => pythonValueText(c)) : [];
1315
- for (const h of hdr) {
1316
- if (!seen.has(h)) {
1317
- seen.add(h);
1318
- unionHeaders.push(h);
1319
- }
1320
- }
1321
- const groupVal = groups ? groups[idx] : f.split("/").at(-1);
1322
- parsedFiles.push({
1323
- group: groupVal,
1324
- headers: hdr,
1325
- rows: recs.slice(1).map((r) => r.cells.map((c) => pythonValueText(c)))
1326
- });
1327
- }
1328
- const outHeaders = grouped ? [groupName, ...unionHeaders] : [...unionHeaders];
1329
- const outDialect = { delimiter: ",", quotechar: '"', doublequote: true, lineterminator: "\n" };
1330
- let out = addBom ? "\uFEFF" : "";
1331
- out += writeCsvRow(lineNumbers ? ["line_number", ...outHeaders] : outHeaders, outDialect);
1332
- let lineNum = 1;
1333
- for (const pf of parsedFiles) {
1334
- for (const r of pf.rows) {
1335
- const rowMap = /* @__PURE__ */ new Map();
1336
- for (let c = 0; c < pf.headers.length; c++) rowMap.set(pf.headers[c], r[c] ?? "");
1337
- const cells = unionHeaders.map((h) => rowMap.get(h) ?? "");
1338
- if (grouped) cells.unshift(pf.group);
1339
- if (lineNumbers) cells.unshift(String(lineNum++));
1340
- out += writeCsvRow(cells, outDialect);
1341
- }
1342
- }
1343
- return out;
1344
- } catch {
1345
- return void 0;
1346
- }
1347
- }
1348
- function evalSyncCsvjoin(inBytes, opArgs, readFileSync) {
1349
- try {
1350
- let columnsSpec;
1351
- let joinMode = "inner";
1352
- let noInference = false;
1353
- let addBom = false;
1354
- let delimiter;
1355
- let tabs = false;
1356
- const files = [];
1357
- let posDone = false;
1358
- for (let i = 0; i < opArgs.length; i++) {
1359
- const a = opArgs[i];
1360
- if (!posDone && a === "--") {
1361
- posDone = true;
1362
- continue;
1363
- }
1364
- if (!posDone && a.startsWith("-") && a !== "-") {
1365
- if (a === "--left") {
1366
- joinMode = "left";
1367
- continue;
1368
- }
1369
- if (a === "--right") {
1370
- joinMode = "right";
1371
- continue;
1372
- }
1373
- if (a === "--outer") {
1374
- joinMode = "outer";
1375
- continue;
1376
- }
1377
- if (a === "-I" || a === "--no-inference") {
1378
- noInference = true;
1379
- continue;
1380
- }
1381
- if (a === "--add-bom") {
1382
- addBom = true;
1383
- continue;
1384
- }
1385
- if (a === "-t" || a === "--tabs") {
1386
- tabs = true;
1387
- continue;
1388
- }
1389
- if (a === "-d" || a === "--delimiter" || a.startsWith("--delimiter=")) {
1390
- const v = a.startsWith("--delimiter=") ? a.slice(12) : opArgs[++i];
1391
- if (!v || Array.from(v).length !== 1) return void 0;
1392
- delimiter = v;
1393
- continue;
1394
- }
1395
- if (a === "-c" || a === "--columns") {
1396
- const v = opArgs[++i];
1397
- if (v === void 0) return void 0;
1398
- columnsSpec = v;
1399
- continue;
1400
- }
1401
- return void 0;
1402
- }
1403
- files.push(a);
1404
- }
1405
- if (files.length !== 2) return void 0;
1406
- const leftOpts = {
1407
- ...delimiter === void 0 ? {} : { delimiter },
1408
- tabs,
1409
- noDoublequote: false,
1410
- skipInitialSpace: false,
1411
- noHeaderRow: false,
1412
- skipLines: 0,
1413
- lineNumbers: false,
1414
- addBom: false,
1415
- noInference,
1416
- blanks: false,
1417
- noLeadingZeroes: false,
1418
- sniffLimit: 1024,
1419
- noNumberEllipsis: false,
1420
- indent: null,
1421
- key: null,
1422
- streamOutput: false,
1423
- filePath: files[0]
1424
- };
1425
- const rightOpts = { ...leftOpts, filePath: files[1] };
1426
- const leftTable = loadSyncTypedTable(inBytes, leftOpts, readFileSync);
1427
- const rightTable = loadSyncTypedTable(inBytes, rightOpts, readFileSync);
1428
- if (!leftTable || !rightTable) return void 0;
1429
- if (!columnsSpec) {
1430
- if (joinMode !== "inner") return void 0;
1431
- const outHeaders2 = [
1432
- ...leftTable.headers,
1433
- ...rightTable.headers.map((h) => leftTable.headers.includes(h) ? h + "2" : h)
1434
- ];
1435
- if (new Set(outHeaders2).size !== outHeaders2.length) return void 0;
1436
- const maxRows = Math.max(leftTable.rows.length, rightTable.rows.length);
1437
- const outDialect2 = { delimiter: ",", quotechar: '"', doublequote: true, lineterminator: "\n" };
1438
- let out2 = addBom ? "\uFEFF" : "";
1439
- out2 += writeCsvRow(outHeaders2, outDialect2);
1440
- for (let r = 0; r < maxRows; r++) {
1441
- const lRow = leftTable.rows[r] ?? leftTable.headers.map(() => null);
1442
- const rRow = rightTable.rows[r] ?? rightTable.headers.map(() => null);
1443
- out2 += writeCsvRow(
1444
- [...lRow, ...rRow].map((v) => v === null ? "" : typeof v === "object" && v.kind === "datetime" ? v.value.replace(" ", "T") : pythonValueText(v)),
1445
- outDialect2
1446
- );
1447
- }
1448
- return out2;
1449
- }
1450
- const colParts = columnsSpec.split(",");
1451
- if (colParts.length !== 1 && colParts.length !== 2) return void 0;
1452
- const leftKey = matchColumnIdentifier(leftTable.headers, colParts[0], 1);
1453
- const rightKey = matchColumnIdentifier(rightTable.headers, colParts[1] ?? colParts[0], 1);
1454
- const full = joinMode === "outer" || joinMode === "right";
1455
- const inner = joinMode === "inner";
1456
- const keyVal = (v) => {
1457
- if (v === null) return "null";
1458
- if (typeof v === "string") return "text:" + v;
1459
- if (typeof v === "boolean") return v ? "number:1:0" : "number:0";
1460
- if (v.kind === "decimal") {
1461
- const d = Decimal.parse(v.value).normalized();
1462
- return "number:" + d.toString();
1463
- }
1464
- return "other:" + pythonValueText(v);
1465
- };
1466
- const includedRight = rightTable.headers.map((_, idx) => idx).filter((idx) => full || idx !== rightKey);
1467
- const outHeaders = [
1468
- ...leftTable.headers,
1469
- ...includedRight.map((idx) => leftTable.headers.includes(rightTable.headers[idx]) ? rightTable.headers[idx] + "2" : rightTable.headers[idx])
1470
- ];
1471
- if (new Set(outHeaders).size !== outHeaders.length) return void 0;
1472
- const rightHash = /* @__PURE__ */ new Map();
1473
- const rightKeys = [];
1474
- for (const row of rightTable.rows) {
1475
- const k = keyVal(row[rightKey]);
1476
- rightKeys.push(k);
1477
- const list = rightHash.get(k);
1478
- if (list) list.push(row);
1479
- else rightHash.set(k, [row]);
1480
- }
1481
- const joinedRows = [];
1482
- const seenKeys = /* @__PURE__ */ new Set();
1483
- for (const lRow of leftTable.rows) {
1484
- const k = keyVal(lRow[leftKey]);
1485
- const matches = k === "null" ? void 0 : rightHash.get(k);
1486
- if (matches) {
1487
- seenKeys.add(k);
1488
- for (const rRow of matches) {
1489
- joinedRows.push([...lRow, ...includedRight.map((idx) => rRow[idx])]);
1490
- }
1491
- } else if (!inner && joinMode !== "right") {
1492
- joinedRows.push([...lRow, ...includedRight.map(() => null)]);
1493
- }
1494
- }
1495
- if (full) {
1496
- for (let i = 0; i < rightTable.rows.length; i++) {
1497
- const k = rightKeys[i];
1498
- if (k === "null" || !seenKeys.has(k)) {
1499
- const rRow = rightTable.rows[i];
1500
- joinedRows.push([...leftTable.headers.map(() => null), ...includedRight.map((idx) => rRow[idx])]);
1501
- }
1502
- }
1503
- }
1504
- const outDialect = { delimiter: ",", quotechar: '"', doublequote: true, lineterminator: "\n" };
1505
- let out = addBom ? "\uFEFF" : "";
1506
- out += writeCsvRow(outHeaders, outDialect);
1507
- for (const row of joinedRows) {
1508
- out += writeCsvRow(
1509
- row.map((v) => v === null ? "" : typeof v === "object" && v.kind === "datetime" ? v.value.replace(" ", "T") : pythonValueText(v)),
1510
- outDialect
1511
- );
1512
- }
1513
- return out;
1514
- } catch {
1515
- return void 0;
1516
- }
1517
- }
1518
-
1519
- // packages/safe-bash/src/commands/csvkit/index.ts
1520
- import { createCsvkitCommands as createRawCsvkitCommands } from "../../safe-bash-command-csvkit/index.js";
1521
- import { CsvkitBlocked, CsvkitCleanupError, CsvkitDiagnostic, Decimal as Decimal2, DecimalTrap, DictionaryWriter, LazyInput, OwnedArguments, POSSIBLE_DELIMITERS as POSSIBLE_DELIMITERS2, PythonException, Runtime, SqlTuple, WorkbookInput, Writer, castValue, columnTypeOrder, commands, compileCreateTable, createCsvkitCommand, createCsvpyInterpreter, createDatabaseProvider, createGzipCompressionProvider, createMemorySqliteFileSystem, createSqlTransportProvider, createSqliteDatabaseProvider, databaseDialects, defaultHeaders as defaultHeaders2, defaultLimits, defaultSniffStreamProfile, deriveSchema, diagnosticReport, execute, inferTable as inferTable2, matchColumnIdentifier as matchColumnIdentifier2, normalizeEncoding, parseArguments, parseColumnIdentifiers as parseColumnIdentifiers2, parseDatabaseUrl, pythonCodecs, pythonValueText as pythonValueText2, readCsv as readCsv2, readCsvStream, resolveDatabaseProvider, run, sniff as sniff2, sqlIdentifier, sqlOptions, sqlSchemaIdentifier, sqlTransportProfiles, utf8Codec, virtualPath, warningText, writeCsvRow as writeCsvRow2 } from "../../safe-bash-command-csvkit/index.js";
1522
- function isDefaultCsvkitOptions(options) {
1523
- if (!options) return true;
1524
- return options.limits === void 0 && options.codecs === void 0 && options.locale === void 0 && options.clock === void 0 && options.terminal === void 0 && options.compression === void 0 && options.databases === void 0 && options.sqlDialects === void 0 && options.interpreter === void 0 && options.openMatchFile === void 0 && options.sniffing === void 0 && options.columnWarnings === void 0 && options.probeInputOpen === void 0;
1525
- }
1526
- function createCsvkitCommands(options = {}) {
1527
- const defs = createRawCsvkitCommands(options);
1528
- Object.assign(syncCommandEvaluators, { evalSyncCsvlook, evalSyncCsvjson, evalSyncCsvsort, evalSyncCsvformat, evalSyncCsvstat, evalSyncIn2csv, evalSyncCsvstack, evalSyncCsvjoin });
1529
- if (isDefaultCsvkitOptions(options)) {
1530
- for (let i = 0; i < defs.length; i++) builtInDirectContextExecutors.add(defs[i].execute);
1531
- }
1532
- return defs;
1533
- }
1534
- function csvkitCommands(options = {}) {
1535
- const commands2 = createCsvkitCommands(options);
1536
- const replace = options.replace ?? false;
1537
- return {
1538
- name: "csvkit-commands",
1539
- setup(host) {
1540
- if (!replace) {
1541
- for (const command of commands2) {
1542
- const existing = host.commands.get(command.name);
1543
- if (existing && !(command.fallback && !existing.fallback)) {
1544
- throw new Error(`Command already registered: ${command.name}`);
1545
- }
1546
- }
1547
- }
1548
- for (const command of commands2) {
1549
- host.commands.register(command, { replace });
1550
- }
1551
- }
1552
- };
1553
- }
1554
- export {
1555
- CsvkitBlocked,
1556
- CsvkitCleanupError,
1557
- CsvkitDiagnostic,
1558
- Decimal2 as Decimal,
1559
- DecimalTrap,
1560
- DictionaryWriter,
1561
- LazyInput,
1562
- OwnedArguments,
1563
- POSSIBLE_DELIMITERS2 as POSSIBLE_DELIMITERS,
1564
- PythonException,
1565
- Runtime,
1566
- SqlTuple,
1567
- WorkbookInput,
1568
- Writer,
1569
- castValue,
1570
- columnTypeOrder,
1571
- commands,
1572
- compileCreateTable,
1573
- createCsvkitCommand,
1574
- createCsvkitCommands,
1575
- createCsvpyInterpreter,
1576
- createDatabaseProvider,
1577
- createGzipCompressionProvider,
1578
- createMemorySqliteFileSystem,
1579
- createSqlTransportProvider,
1580
- createSqliteDatabaseProvider,
1581
- csvkitCommands,
1582
- databaseDialects,
1583
- defaultHeaders2 as defaultHeaders,
1584
- defaultLimits,
1585
- defaultSniffStreamProfile,
1586
- deriveSchema,
1587
- diagnosticReport,
1588
- evalSyncCsvformat,
1589
- evalSyncCsvjoin,
1590
- evalSyncCsvjson,
1591
- evalSyncCsvlook,
1592
- evalSyncCsvsort,
1593
- evalSyncCsvstack,
1594
- evalSyncCsvstat,
1595
- evalSyncIn2csv,
1596
- execute,
1597
- inferTable2 as inferTable,
1598
- matchColumnIdentifier2 as matchColumnIdentifier,
1599
- normalizeEncoding,
1600
- parseArguments,
1601
- parseColumnIdentifiers2 as parseColumnIdentifiers,
1602
- parseDatabaseUrl,
1603
- pythonCodecs,
1604
- pythonValueText2 as pythonValueText,
1605
- readCsv2 as readCsv,
1606
- readCsvStream,
1607
- resolveDatabaseProvider,
1608
- run,
1609
- sniff2 as sniff,
1610
- sqlIdentifier,
1611
- sqlOptions,
1612
- sqlSchemaIdentifier,
1613
- sqlTransportProfiles,
1614
- utf8Codec,
1615
- virtualPath,
1616
- warningText,
1617
- writeCsvRow2 as writeCsvRow
1618
- };