@poe-platform/safe-bash 0.1.800 → 0.1.802
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.
- package/README.md +16 -5
- package/dist/image-ast/index.browser.js +122 -76
- package/dist/image-ast/index.js +122 -76
- package/dist/pdf-ast/index.js +4 -3
- package/dist/safe-bash/chunks/chunk-3HQU4OJO.js +13 -0
- package/dist/safe-bash/chunks/{chunk-LUOFIVNI.js → chunk-3NDIFSNM.js} +3 -3
- package/dist/safe-bash/chunks/{chunk-4SEW2Q6H.js → chunk-3R3AANOR.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-K4YMYFRJ.js → chunk-44ALJ4QG.js} +5809 -7424
- package/dist/safe-bash/chunks/{chunk-KHMGTPD6.js → chunk-46Z5E5EV.js} +2 -2
- package/dist/safe-bash/chunks/chunk-4BSJLKNM.js +14 -0
- package/dist/safe-bash/chunks/chunk-4D4N7IU2.js +47 -0
- package/dist/safe-bash/chunks/chunk-55YJASTN.js +14 -0
- package/dist/safe-bash/chunks/{chunk-XB3B7KMM.js → chunk-6O77NL2S.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-T3JTVIEP.js → chunk-6PAVEFT3.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-PYVEAFJM.js → chunk-74GHTNJA.js} +3 -2
- package/dist/safe-bash/chunks/{chunk-LQHGH25W.js → chunk-7R5BDCG7.js} +1 -1
- package/dist/safe-bash/chunks/chunk-7ZBU7KYV.js +14 -0
- package/dist/safe-bash/chunks/{chunk-MHZ24KEI.js → chunk-AM5ESLPH.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-3L3T6LYV.js → chunk-AUSNDQTJ.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-YG5WAHK7.js → chunk-B7TAL7S5.js} +1 -3
- package/dist/safe-bash/chunks/{chunk-QVSRRNZT.js → chunk-BJA5XNP6.js} +6 -6
- package/dist/safe-bash/chunks/{chunk-K7IQZE7D.js → chunk-C5OWC2TL.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-F3RV2F72.js → chunk-CHYGPFVM.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-M4CFCXHN.js → chunk-CS4MNM6I.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-H6JW3E4F.js → chunk-CTVWDACF.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-BHJE5LPZ.js → chunk-D3ANYGMC.js} +1 -1
- package/dist/safe-bash/chunks/chunk-DQP3VHSB.js +15 -0
- package/dist/safe-bash/chunks/{chunk-NLAW7KDI.js → chunk-E7OYNDGL.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-SOZK5JVX.js → chunk-FBUCWVTE.js} +1 -1
- package/dist/safe-bash/chunks/chunk-FZE4HW6G.js +11 -0
- package/dist/safe-bash/chunks/chunk-GEG3BWGE.js +14 -0
- package/dist/safe-bash/chunks/{chunk-HHW7MGS2.js → chunk-GETUOD5D.js} +4 -4
- package/dist/safe-bash/chunks/chunk-HBCN24ZA.js +50 -0
- package/dist/safe-bash/chunks/chunk-HZ7BWKQ3.js +13 -0
- package/dist/safe-bash/chunks/{chunk-JJSTTIEZ.js → chunk-HZAMGT5I.js} +3 -3
- package/dist/safe-bash/chunks/{chunk-KCVSVD65.js → chunk-I5HZ4FGE.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-KV7PKOHV.js → chunk-IWDICZVK.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-I4OAEOP6.js → chunk-J42RIHHJ.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-K2VCOJ2B.js → chunk-K6VCD7IY.js} +7 -12
- package/dist/safe-bash/chunks/chunk-KDNSPLII.js +83 -0
- package/dist/safe-bash/chunks/{chunk-63FXVDGF.js → chunk-LVOBFF4D.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-U5NUZPCC.js → chunk-MHMMRCYC.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-KW24TAIU.js → chunk-NQCM3TYR.js} +922 -658
- package/dist/safe-bash/chunks/{chunk-VYZTG3GV.js → chunk-NZQXYWA3.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-TFGRKY43.js → chunk-OQRVVGR6.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-PPYM75Z3.js → chunk-OV6IHKO6.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-TYD7EVUJ.js → chunk-PH63PLPZ.js} +8 -8
- package/dist/safe-bash/chunks/chunk-QGUV42T5.js +44 -0
- package/dist/safe-bash/chunks/chunk-R3NAKOED.js +51 -0
- package/dist/safe-bash/chunks/chunk-RRR7AQ24.js +38 -0
- package/dist/safe-bash/chunks/{chunk-RKKRJ54E.js → chunk-RSTHLAF3.js} +30 -23
- package/dist/safe-bash/chunks/{chunk-RMWLWH7Q.js → chunk-SHEMU2Z7.js} +378 -1148
- package/dist/safe-bash/chunks/{chunk-7YSRXFEG.js → chunk-TFIBK2GI.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-I7L3G3NX.js → chunk-UE5KZDEK.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-QU3BVQ53.js → chunk-UTBUUFDM.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-6HZYFL3H.js → chunk-VKNVHEX3.js} +2 -7
- package/dist/safe-bash/chunks/chunk-VSAJ4OTM.js +962 -0
- package/dist/safe-bash/chunks/{chunk-46UISJCK.js → chunk-VTH3MLDU.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-JTLSUJ7V.js → chunk-WDLGKIHD.js} +56 -39
- package/dist/safe-bash/chunks/chunk-XAQMU6OY.js +14 -0
- package/dist/safe-bash/chunks/{chunk-LLZCZ24K.js → chunk-XVOSKJE2.js} +1 -1
- package/dist/safe-bash/chunks/chunk-ZVD5IS4V.js +49 -0
- package/dist/safe-bash/chunks/{csvkit-QGP3GAOB.js → csvkit-TACDU7FC.js} +3 -3
- package/dist/safe-bash/chunks/{ffmpeg-JTVH26MK.js → ffmpeg-WTC3TEFI.js} +2 -2
- package/dist/safe-bash/chunks/{gh-I7QX7N5C.js → gh-6WU6PXL4.js} +2 -2
- package/dist/safe-bash/chunks/{git-MA7NKYVP.js → git-EFZIGJW4.js} +2 -2
- package/dist/safe-bash/chunks/{imagemagick-Y4NPWX2Q.js → imagemagick-EIEYGWPF.js} +2 -2
- package/dist/safe-bash/chunks/{implementation-BWDKOVQJ.js → implementation-MLFHUQ5M.js} +2 -2
- package/dist/safe-bash/chunks/{mmdc-44PELHDG.js → mmdc-ROQJT5HQ.js} +2 -2
- package/dist/safe-bash/chunks/{pdfimages-635TRW4Q.js → pdfimages-DW7LWXFI.js} +2 -2
- package/dist/safe-bash/chunks/{pdfinfo-FSDAA2KY.js → pdfinfo-TIP6XLUQ.js} +2 -2
- package/dist/safe-bash/chunks/{pdftk-GQ5UH3VG.js → pdftk-DMG22ITZ.js} +2 -2
- package/dist/safe-bash/chunks/{pdftoppm-YTXQCAYT.js → pdftoppm-WNDYR72T.js} +2 -2
- package/dist/safe-bash/chunks/{pdftotext-CVA2G7FY.js → pdftotext-5IPZ4NI7.js} +2 -2
- package/dist/safe-bash/chunks/{qpdf-HZMIFG4A.js → qpdf-TTX2DIUA.js} +2 -2
- package/dist/safe-bash/chunks/{sips-E7UBDP33.js → sips-XYS46JPJ.js} +2 -2
- package/dist/safe-bash/chunks/{soffice-ELASUWUK.js → soffice-TU73E5KL.js} +2 -2
- package/dist/safe-bash/chunks/{wkhtmltopdf-EPO6YCMG.js → wkhtmltopdf-FSZ2CHGE.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-QBGA56UH.js → chunk-2ELYGJDD.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-52PCQXD2.js → chunk-2NHI5F5S.js} +2 -1
- package/dist/safe-bash/command-chunks/{chunk-HDKVO47G.js → chunk-2SQEIUGJ.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-5LSGEIZY.js → chunk-3HHCU5YU.js} +4 -3
- package/dist/safe-bash/command-chunks/{chunk-TF6OA2GK.js → chunk-3NV3HYT2.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-2QHG43WJ.js → chunk-4BB2SWJ5.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-IEXHHNOF.js → chunk-4J5CZ2DP.js} +2 -7
- package/dist/safe-bash/command-chunks/{chunk-WDHI3S6Y.js → chunk-4OOUQTQO.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-YMONDXET.js → chunk-4ZQWGOZB.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-L6DVEBW3.js → chunk-5BSTFCXG.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-Q3DII3Q7.js → chunk-5PWJG2UK.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-JMPP4TCW.js → chunk-5UBXNSFZ.js} +3 -2
- package/dist/safe-bash/command-chunks/{chunk-3NG75MOB.js → chunk-67GQA75T.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-L6SU4S26.js → chunk-6B7WQIKB.js} +0 -7
- package/dist/safe-bash/command-chunks/{chunk-V6MSPQLA.js → chunk-6BNTBWIK.js} +4 -39
- package/dist/safe-bash/command-chunks/{chunk-SAMH7SQE.js → chunk-6GWJUQAV.js} +237 -145
- package/dist/safe-bash/command-chunks/{chunk-JN7WIP6S.js → chunk-6KJ3LPI2.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-HLDTOR7M.js → chunk-6ZVI7LUY.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-X6NJC3IC.js → chunk-75OFBY5R.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-MRW5HD2D.js → chunk-7O3E4LPT.js} +4 -22
- package/dist/safe-bash/command-chunks/{chunk-TEVJJPTC.js → chunk-7U7EXOXX.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-6CYTRQ24.js → chunk-7VTKQUA5.js} +20 -17
- package/dist/safe-bash/command-chunks/{chunk-BZPAWTUL.js → chunk-AEF5BA3D.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-63R3FEZJ.js → chunk-AIV5BF5W.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-AYUTO323.js → chunk-AKJG2XD3.js} +2 -18
- package/dist/safe-bash/command-chunks/{chunk-J34TZVMW.js → chunk-ALDC4XP4.js} +0 -5
- package/dist/safe-bash/command-chunks/{chunk-CKXV2CLD.js → chunk-ARBYOQUZ.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-44AHAB5O.js → chunk-BDSMROQZ.js} +1 -4
- package/dist/safe-bash/command-chunks/{chunk-53P53XFM.js → chunk-BPE5INLI.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-OT4LZMLB.js → chunk-BR73BIOW.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-WB5SVIG7.js → chunk-C5YYCQHW.js} +498 -88
- package/dist/safe-bash/command-chunks/{chunk-EUSPTFAX.js → chunk-CAP7ZJSY.js} +7 -7
- package/dist/safe-bash/command-chunks/{chunk-DWFLVJC6.js → chunk-CCRHMAU5.js} +2 -1
- package/dist/safe-bash/command-chunks/{chunk-GI4CJED2.js → chunk-CQTRW45K.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-KKG4BAFZ.js → chunk-DIEPXUM4.js} +6 -0
- package/dist/safe-bash/command-chunks/{chunk-QJAFJP2G.js → chunk-DZCY63VJ.js} +12 -10
- package/dist/safe-bash/command-chunks/{chunk-QUENU6GM.js → chunk-E55UKBIE.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-MC3VWLIZ.js → chunk-FDBUV4HJ.js} +28 -19
- package/dist/safe-bash/command-chunks/{chunk-7FKUC34S.js → chunk-FPVUD6TH.js} +6 -3
- package/dist/safe-bash/command-chunks/{chunk-E2LB7FRT.js → chunk-FXOA7RBK.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-QWIDNAAK.js → chunk-FZTK4MFI.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-K543PB3I.js → chunk-G66QUHIZ.js} +6 -35
- package/dist/safe-bash/command-chunks/{chunk-YJDV76GL.js → chunk-GFQZCKO6.js} +29 -19
- package/dist/safe-bash/command-chunks/{chunk-FKKB5X5V.js → chunk-GOB777HR.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-IYPAQ7PH.js → chunk-GRBWW4SG.js} +6 -0
- package/dist/safe-bash/command-chunks/{chunk-EFANWIHL.js → chunk-GY3BWK7K.js} +1 -0
- package/dist/safe-bash/command-chunks/{chunk-PPNBNFAU.js → chunk-GYQ2HAKQ.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-PJJUYO3R.js → chunk-II77KPZN.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-VL67NWNS.js → chunk-JDYXY44P.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-4QJOYXVB.js → chunk-JV7LBUTP.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-IKS2YXZQ.js → chunk-K67MWWWH.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-BKCNF5U3.js → chunk-KQLD3AED.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-UMDIOL3O.js → chunk-KXU3IRUO.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-QZF3SINC.js → chunk-LAOM65EE.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-HFII3QYO.js → chunk-LWS62ISU.js} +46 -32
- package/dist/safe-bash/command-chunks/{chunk-BZDDAPSV.js → chunk-LWSBAWLT.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-U6G67N23.js → chunk-MIXBO6U7.js} +18 -5
- package/dist/safe-bash/command-chunks/{chunk-JQ74HC37.js → chunk-MQFIPHIQ.js} +23 -50
- package/dist/safe-bash/command-chunks/{chunk-ZJBR5Q5I.js → chunk-MSFXC3OC.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-NI7MKJPN.js → chunk-MTQH74CF.js} +3 -55
- package/dist/safe-bash/command-chunks/chunk-MWUZZWXK.js +354 -0
- package/dist/safe-bash/command-chunks/{chunk-RVLO4DYT.js → chunk-N4PFUSRM.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-WBNZ4PRE.js → chunk-NGG2XL56.js} +7 -4
- package/dist/safe-bash/command-chunks/{chunk-D4OP2BR3.js → chunk-NKFYQSES.js} +1 -2
- package/dist/safe-bash/command-chunks/{chunk-NGWB2YBL.js → chunk-O4JQSB7O.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-GLOZX57Y.js → chunk-OQKC5ZU2.js} +23 -114
- package/dist/safe-bash/command-chunks/{chunk-7L24L4UO.js → chunk-OQU6UT6X.js} +2 -20
- package/dist/safe-bash/command-chunks/{chunk-TYCGMRLM.js → chunk-OYYV7ZAF.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-SVULUDOP.js → chunk-P2N33UMN.js} +20 -81
- package/dist/safe-bash/command-chunks/{chunk-Q7Q5GM5S.js → chunk-P5APDEFB.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-3HXDA5PT.js → chunk-PMBFZXTK.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-4Y3WVMK4.js → chunk-PV66YWHB.js} +1 -0
- package/dist/safe-bash/command-chunks/{chunk-AXK3H4PX.js → chunk-QJ33BHI4.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-3LSOYLNV.js → chunk-QKFSRZGQ.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-JZSNU2MY.js → chunk-QKJLP53H.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-LC2MFKT4.js → chunk-RMWQAAO5.js} +24 -25
- package/dist/safe-bash/command-chunks/{chunk-QDTBMSBE.js → chunk-RO62EWX6.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-4C6QI5BQ.js → chunk-RZZI24ZE.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-PFAADCB5.js → chunk-SDNBCQ3X.js} +10 -24
- package/dist/safe-bash/command-chunks/{chunk-36O5OT7E.js → chunk-T35Y7YQD.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-6HMX4CQS.js → chunk-TGSNCQSR.js} +44 -16
- package/dist/safe-bash/command-chunks/{chunk-5T7CRJHW.js → chunk-TIOCQVUQ.js} +4 -7
- package/dist/safe-bash/command-chunks/{chunk-GN2TKLE7.js → chunk-TS65BJHG.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-7RGB363W.js → chunk-TSCGT46G.js} +3 -2
- package/dist/safe-bash/command-chunks/{chunk-KBEURXFF.js → chunk-UN6WS55J.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-SX2X3IH4.js → chunk-V2V5OCL3.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-ERYJLO6G.js → chunk-V7A7DRTU.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-5SHGJ7NO.js → chunk-VA5ZHYYA.js} +73 -33
- package/dist/safe-bash/command-chunks/{chunk-XETLEHZP.js → chunk-VPR5LQYX.js} +3 -2
- package/dist/safe-bash/command-chunks/{chunk-3DT2YOGW.js → chunk-VSRGNQCP.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-N2F74VRO.js → chunk-VT6MJBEI.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-J5SN3PZ3.js → chunk-VXSLJH7G.js} +53 -3
- package/dist/safe-bash/command-chunks/{chunk-PXYOWWMV.js → chunk-W7RAD4EW.js} +4 -3
- package/dist/safe-bash/command-chunks/{chunk-YGC6OS5O.js → chunk-WECIOOQB.js} +5 -8
- package/dist/safe-bash/command-chunks/{chunk-HHP343KT.js → chunk-WTECBRU4.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-AO6Z5EQ7.js → chunk-WVE64WM2.js} +6 -5
- package/dist/safe-bash/command-chunks/{chunk-Z7RVSD5K.js → chunk-WVHONVZ4.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-HLGKIZ25.js → chunk-X54L3DBL.js} +6 -9
- package/dist/safe-bash/command-chunks/{chunk-QNIMV57G.js → chunk-XNLFHHOC.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-XAFSZDY2.js → chunk-XS72HTMA.js} +11 -0
- package/dist/safe-bash/command-chunks/{chunk-KYSPGS33.js → chunk-YIQACGEW.js} +2 -0
- package/dist/safe-bash/command-chunks/{chunk-NAY27PXB.js → chunk-YOFC45RK.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-T5H5UJQ3.js → chunk-YVNGTIJO.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-QI7LGHJJ.js → chunk-Z45N42QC.js} +21 -6
- package/dist/safe-bash/command-chunks/{chunk-67IQF5GC.js → chunk-ZYHTWNAE.js} +23 -9
- package/dist/safe-bash/command-chunks/{chunk-STC3LEWJ.js → chunk-ZYXH3B66.js} +5 -3
- package/dist/safe-bash/commands/apply-patch/index.browser.js +14 -0
- package/dist/safe-bash/commands/archive/index.browser.js +36 -0
- package/dist/safe-bash/commands/bytes/compression/index.js +3 -2
- package/dist/safe-bash/commands/column/index.browser.js +12 -0
- package/dist/safe-bash/commands/copy-preserve.d.ts +1 -0
- package/dist/safe-bash/commands/csplit/index.browser.js +2 -2
- package/dist/safe-bash/commands/docx/index.browser.js +1 -1
- package/dist/safe-bash/commands/du/index.browser.js +14 -0
- package/dist/safe-bash/commands/execution.js +19 -13
- package/dist/safe-bash/commands/expr/index.browser.js +12 -0
- package/dist/safe-bash/commands/factor/index.browser.js +2 -2
- package/dist/safe-bash/commands/file/index.browser.js +14 -0
- package/dist/safe-bash/commands/filesystem.d.ts +1 -1
- package/dist/safe-bash/commands/filesystem.js +26 -15
- package/dist/safe-bash/commands/getopt/index.browser.js +2 -2
- package/dist/safe-bash/commands/grep-aliases/index.browser.js +14 -0
- package/dist/safe-bash/commands/hexdump/index.browser.js +2 -2
- package/dist/safe-bash/commands/html-to-markdown/index.browser.js +16 -0
- package/dist/safe-bash/commands/htmlq/index.d.ts +1 -1
- package/dist/safe-bash/commands/iconv/index.browser.js +2 -2
- package/dist/safe-bash/commands/line-endings/index.browser.js +2 -2
- package/dist/safe-bash/commands/llm/index.browser.js +2 -2
- package/dist/safe-bash/commands/llm/providers/index.browser.js +1 -1
- package/dist/safe-bash/commands/mdq/index.browser.js +3 -3
- package/dist/safe-bash/commands/media/index.browser.js +1 -1
- package/dist/safe-bash/commands/metadata/index.browser.js +21 -0
- package/dist/safe-bash/commands/network/curl.d.ts +1 -1
- package/dist/safe-bash/commands/network/curl.js +1 -3
- package/dist/safe-bash/commands/network/index.browser.js +4 -4
- package/dist/safe-bash/commands/network/platform-portable.d.ts +1 -5
- package/dist/safe-bash/commands/network/platform-portable.js +1 -26
- package/dist/safe-bash/commands/network/public.d.ts +2 -2
- package/dist/safe-bash/commands/network/public.js +2 -2
- package/dist/safe-bash/commands/network/transport.js +2 -2
- package/dist/safe-bash/commands/network/wget.d.ts +1 -1
- package/dist/safe-bash/commands/network/wget.js +1 -3
- package/dist/safe-bash/commands/node/filesystem.js +3 -2
- package/dist/safe-bash/commands/node/index.browser.js +8 -8
- package/dist/safe-bash/commands/node/types.js +1 -1
- package/dist/safe-bash/commands/op/index.browser.js +3 -3
- package/dist/safe-bash/commands/pr/index.browser.js +2 -2
- package/dist/safe-bash/commands/python/host-capabilities.js +31 -14
- package/dist/safe-bash/commands/python/index.browser.js +11 -11
- package/dist/safe-bash/commands/python/manifest.d.ts +1 -0
- package/dist/safe-bash/commands/python/manifest.js +6 -3
- package/dist/safe-bash/commands/python/shell-capability.d.ts +1 -0
- package/dist/safe-bash/commands/python/shell-capability.js +3 -2
- package/dist/safe-bash/commands/python/worker.browser.js +3 -3
- package/dist/safe-bash/commands/regex-execution/public.browser.js +8 -6
- package/dist/safe-bash/commands/safejs/runtime.js +16 -7
- package/dist/safe-bash/commands/split/index.browser.js +14 -0
- package/dist/safe-bash/commands/standard.d.ts +1 -0
- package/dist/safe-bash/commands/standard.js +2 -1
- package/dist/safe-bash/commands/stream-format/index.browser.js +11 -0
- package/dist/safe-bash/commands/stream-inspection/index.browser.js +11 -0
- package/dist/safe-bash/commands/streams.js +11 -29
- package/dist/safe-bash/commands/table-text/index.browser.js +11 -0
- package/dist/safe-bash/commands/text.js +269 -496
- package/dist/safe-bash/commands/time-env/index.browser.js +15 -0
- package/dist/safe-bash/commands/tree/index.browser.js +14 -0
- package/dist/safe-bash/commands/tsort/index.browser.js +2 -2
- package/dist/safe-bash/commands/xml/index.browser.js +2 -2
- package/dist/safe-bash/commands/yq/index.browser.js +2 -2
- package/dist/safe-bash/core.browser.js +1 -1
- package/dist/safe-bash/core.d.ts +6 -1
- package/dist/safe-bash/core.js +1 -1
- package/dist/safe-bash/full-core.browser.js +308 -295
- package/dist/safe-bash/jobs.browser.js +5 -5
- package/dist/safe-bash/opt-in/commands/dd/index.js +2 -0
- package/dist/safe-bash/opt-in/optional/commands/shuf/options.d.ts +1 -0
- package/dist/safe-bash/opt-in/optional/commands/shuf/options.js +2 -4
- package/dist/safe-bash/opt-in/optional/commands/shuf/shuf.js +2 -1
- package/dist/safe-bash/optional-host.browser.js +15 -15
- package/dist/safe-bash/plugins/composition.d.ts +1 -0
- package/dist/safe-bash/plugins/composition.js +3 -8
- package/dist/safe-bash/plugins/index.browser.js +41 -27
- package/dist/safe-bash/registry-entry.browser.js +42 -28
- package/dist/safe-bash/search.browser.js +48 -0
- package/dist/safe-bash/shell/arrays/bindings.js +1 -1
- package/dist/safe-bash/shell/arrays/state.js +4 -0
- package/dist/safe-bash/shell/brace-expansion.js +1 -1
- package/dist/safe-bash/shell/dynamic-variables.d.ts +10 -0
- package/dist/safe-bash/shell/dynamic-variables.js +25 -0
- package/dist/safe-bash/shell/parser.js +8 -1
- package/dist/safe-bash/shell/runtime.d.ts +4 -13
- package/dist/safe-bash/shell/runtime.js +334 -1049
- package/dist/safe-bash/shell/shell.js +2 -54
- package/dist/safe-bash/shell-entry.browser.js +35 -26
- package/dist/safe-bash/trap.browser.js +4 -4
- package/dist/safe-bash/yq-browser/index.js +1 -1
- package/dist/safe-bash-base-encoding-engine/base.js +2 -2
- package/dist/safe-bash-base-encoding-engine/shared.js +1 -1
- package/dist/safe-bash-byte-input-engine/index.d.ts +3 -2
- package/dist/safe-bash-byte-input-engine/index.js +4 -1
- package/dist/safe-bash-checksum-engine/index.js +13 -6
- package/dist/safe-bash-command-apply-patch/apply.d.ts +1 -1
- package/dist/safe-bash-command-apply-patch/apply.js +4 -3
- package/dist/safe-bash-command-apply-patch/index.js +3 -3
- package/dist/safe-bash-command-apply-patch/matcher.js +1 -1
- package/dist/safe-bash-command-apply-patch/parser.js +1 -1
- package/dist/safe-bash-command-awk/awk-inspection.js +2 -2
- package/dist/safe-bash-command-awk/awk-runtime.js +3 -3
- package/dist/safe-bash-command-awk/awk-syntax.d.ts +1 -1
- package/dist/safe-bash-command-awk/awk-syntax.js +2 -2
- package/dist/safe-bash-command-awk/awk-values.js +1 -1
- package/dist/safe-bash-command-awk/awk.js +5 -5
- package/dist/safe-bash-command-awk/index.js +5 -5
- package/dist/safe-bash-command-bc/index.d.ts +2 -0
- package/dist/safe-bash-command-bc/index.js +123 -92
- package/dist/safe-bash-command-column/column.js +5 -5
- package/dist/safe-bash-command-column/display.d.ts +1 -1
- package/dist/safe-bash-command-column/display.js +1 -1
- package/dist/safe-bash-command-column/index.js +5 -5
- package/dist/safe-bash-command-column/internal.d.ts +0 -2
- package/dist/safe-bash-command-column/internal.js +1 -1
- package/dist/safe-bash-command-column/layout.js +4 -4
- package/dist/safe-bash-command-column/table.js +2 -2
- package/dist/safe-bash-command-comm/comm.js +1 -1
- package/dist/safe-bash-command-comm/index.js +1 -1
- package/dist/safe-bash-command-csvcut/index.d.ts +1 -0
- package/dist/safe-bash-command-csvcut/index.js +1 -0
- package/dist/safe-bash-command-csvgrep/index.d.ts +1 -0
- package/dist/safe-bash-command-csvgrep/index.js +2 -2
- package/dist/safe-bash-command-csvkit/index.js +9 -9
- package/dist/safe-bash-command-csvkit/sync-support.js +1 -1
- package/dist/safe-bash-command-curl/curl.js +1 -1
- package/dist/safe-bash-command-curl/index.js +1 -1
- package/dist/safe-bash-command-dd/index.js +2 -0
- package/dist/safe-bash-command-diff/diff.js +1 -1
- package/dist/safe-bash-command-diff/index.js +1 -1
- package/dist/safe-bash-command-exiftool/index.d.ts +1 -0
- package/dist/safe-bash-command-fd/index.js +9 -9
- package/dist/safe-bash-command-ffmpeg/index.js +31 -8
- package/dist/safe-bash-command-file/index.js +1 -1
- package/dist/safe-bash-command-file/shared.js +1 -1
- package/dist/safe-bash-command-find/find.js +1 -1
- package/dist/safe-bash-command-find/index.js +1 -1
- package/dist/safe-bash-command-gzip/index.js +3 -2
- package/dist/safe-bash-command-hexdump/command.js +4 -4
- package/dist/safe-bash-command-hexdump/custom.d.ts +24 -0
- package/dist/safe-bash-command-hexdump/index.js +4 -4
- package/dist/safe-bash-command-hexdump/internal.d.ts +2 -0
- package/dist/safe-bash-command-hexdump/internal.js +1 -1
- package/dist/safe-bash-command-hexdump/io.js +2 -2
- package/dist/safe-bash-command-hexdump/options.d.ts +3 -0
- package/dist/safe-bash-command-hexdump/options.js +2 -2
- package/dist/safe-bash-command-hostname/index.js +1 -1
- package/dist/safe-bash-command-html-to-markdown/budget.js +1 -1
- package/dist/safe-bash-command-html-to-markdown/entities.js +3 -3
- package/dist/safe-bash-command-html-to-markdown/index.js +6 -6
- package/dist/safe-bash-command-html-to-markdown/input.js +5 -5
- package/dist/safe-bash-command-html-to-markdown/parser.d.ts +1 -0
- package/dist/safe-bash-command-html-to-markdown/parser.js +4 -4
- package/dist/safe-bash-command-html-to-markdown/render.js +5 -5
- package/dist/safe-bash-command-html-to-markdown/text.js +2 -2
- package/dist/safe-bash-command-htmlq/index.d.ts +1 -0
- package/dist/safe-bash-command-htmlq/index.js +27 -9
- package/dist/safe-bash-command-iconv/codec.js +1 -1
- package/dist/safe-bash-command-iconv/command.js +2 -2
- package/dist/safe-bash-command-iconv/index.js +2 -2
- package/dist/safe-bash-command-imagemagick/index.js +24 -6
- package/dist/safe-bash-command-join/index.js +1 -1
- package/dist/safe-bash-command-join/join.js +1 -1
- package/dist/safe-bash-command-jq/index.js +1 -1
- package/dist/safe-bash-command-jq/jq.js +1 -1
- package/dist/safe-bash-command-less/index.js +43 -28
- package/dist/safe-bash-command-mmdc/index.d.ts +1 -0
- package/dist/safe-bash-command-nl/index.js +1 -1
- package/dist/safe-bash-command-nl/nl.js +1 -1
- package/dist/safe-bash-command-numfmt/index.js +0 -11
- package/dist/safe-bash-command-od/index.js +101 -68
- package/dist/safe-bash-command-pandoc/command.js +1 -1
- package/dist/safe-bash-command-pandoc/index.js +1 -1
- package/dist/safe-bash-command-paste/index.js +1 -1
- package/dist/safe-bash-command-paste/paste.js +1 -1
- package/dist/safe-bash-command-pathchk/index.js +3 -13
- package/dist/safe-bash-command-pdfimages/index.js +27 -11
- package/dist/safe-bash-command-pdfinfo/index.js +19 -10
- package/dist/safe-bash-command-pdftk/index.js +3 -3
- package/dist/safe-bash-command-pdftoppm/index.js +26 -10
- package/dist/safe-bash-command-pdftotext/index.js +27 -13
- package/dist/safe-bash-command-qpdf/index.js +5 -5
- package/dist/safe-bash-command-rg/index.js +1 -1
- package/dist/safe-bash-command-rg/rg-command.d.ts +0 -1
- package/dist/safe-bash-command-rg/rg-command.js +3 -5
- package/dist/safe-bash-command-sed/index.js +1 -1
- package/dist/safe-bash-command-sed/sed.js +1 -1
- package/dist/safe-bash-command-shuf/options.d.ts +1 -0
- package/dist/safe-bash-command-shuf/options.js +2 -4
- package/dist/safe-bash-command-shuf/shuf.js +2 -1
- package/dist/safe-bash-command-soffice/index.js +20 -16
- package/dist/safe-bash-command-split/index.js +3 -3
- package/dist/safe-bash-command-split/io.js +1 -1
- package/dist/safe-bash-command-split/outputs.js +2 -2
- package/dist/safe-bash-command-split/split.js +3 -3
- package/dist/safe-bash-command-sqlite3/btree.d.ts +1 -0
- package/dist/safe-bash-command-sqlite3/engine.d.ts +6 -0
- package/dist/safe-bash-command-sqlite3/index.js +284 -85
- package/dist/safe-bash-command-ssconvert/commands.js +9 -9
- package/dist/safe-bash-command-ssconvert/core.js +8 -8
- package/dist/safe-bash-command-ssconvert/formats/csv.js +9 -9
- package/dist/safe-bash-command-ssconvert/formats/ods.js +8 -8
- package/dist/safe-bash-command-ssconvert/formats/spreadsheetml.js +2 -2
- package/dist/safe-bash-command-ssconvert/formats/xls.js +9 -9
- package/dist/safe-bash-command-ssconvert/formats/xlsx.js +8 -8
- package/dist/safe-bash-command-ssconvert/index.js +20 -20
- package/dist/safe-bash-command-tar/extract.js +1 -1
- package/dist/safe-bash-command-tar/index.js +5 -4
- package/dist/safe-bash-command-tar/modes.js +2 -2
- package/dist/safe-bash-command-tree/arguments.js +3 -3
- package/dist/safe-bash-command-tree/charset.js +1 -1
- package/dist/safe-bash-command-tree/index.js +4 -4
- package/dist/safe-bash-command-tree/io.js +1 -1
- package/dist/safe-bash-command-tree/pattern.js +2 -2
- package/dist/safe-bash-command-tree/tree.js +4 -4
- package/dist/safe-bash-command-unexpand/index.js +1 -1
- package/dist/safe-bash-command-unexpand/unexpand.js +1 -1
- package/dist/safe-bash-command-unrtf/index.js +14 -7
- package/dist/safe-bash-command-unzip/index.js +1 -1
- package/dist/safe-bash-command-unzip/unzip.js +1 -1
- package/dist/safe-bash-command-wget/index.js +1 -1
- package/dist/safe-bash-command-wget/wget.js +1 -1
- package/dist/safe-bash-command-xan/argv.d.ts +1 -1
- package/dist/safe-bash-command-xan/argv.js +1 -1
- package/dist/safe-bash-command-xan/commands.js +5 -3
- package/dist/safe-bash-command-xan/csv.d.ts +1 -1
- package/dist/safe-bash-command-xan/csv.js +1 -1
- package/dist/safe-bash-command-xan/index.js +7 -7
- package/dist/safe-bash-command-xan/io.js +3 -3
- package/dist/safe-bash-command-xmllint/index.js +1 -1
- package/dist/safe-bash-command-xxd/index.js +105 -91
- package/dist/safe-bash-command-xz/command.d.ts +2 -0
- package/dist/safe-bash-command-xz/index.d.ts +1 -1
- package/dist/safe-bash-command-xz/index.js +8 -0
- package/dist/safe-bash-command-yq/query.js +1 -1
- package/dist/safe-bash-command-zip/index.js +1 -1
- package/dist/safe-bash-command-zip/zip.js +1 -1
- package/dist/safe-bash-contracts/escaping.js +3 -3
- package/dist/safe-bash-contracts/filesystem-output.js +2 -2
- package/dist/safe-bash-contracts/index.d.ts +1 -0
- package/dist/safe-bash-contracts/index.js +7 -3
- package/dist/safe-bash-contracts/io.d.ts +4 -1
- package/dist/safe-bash-contracts/io.js +3 -1
- package/dist/safe-bash-contracts/managed-abort.d.ts +10 -0
- package/dist/safe-bash-contracts/output.js +2 -2
- package/dist/safe-bash-diff-engine/index.js +1 -1
- package/dist/safe-bash-diff-engine/shared.d.ts +3 -2
- package/dist/safe-bash-diff-engine/shared.js +1 -1
- package/dist/safe-bash-io-engine/commands/archive/internal.js +5 -23
- package/dist/safe-bash-io-engine/commands/search/requirements.js +2 -2
- package/dist/safe-bash-io-engine/commands/text-programs/shared.js +33 -44
- package/dist/safe-bash-io-engine/internal.js +1 -1
- package/dist/safe-bash-io-engine/shell/pattern.js +1 -1
- package/dist/safe-bash-io-engine/shell/string-operations.js +1 -1
- package/dist/safe-bash-mcp/index.browser.d.ts +155 -35
- package/dist/safe-bash-mcp/index.browser.js +416 -0
- package/dist/safe-bash-mcp/index.d.ts +54 -2
- package/dist/safe-bash-mcp/index.js +286 -90
- package/dist/safe-bash-network-engine/aggregate.js +2 -2
- package/dist/safe-bash-network-engine/args.js +4 -4
- package/dist/safe-bash-network-engine/authorizer.js +1 -1
- package/dist/safe-bash-network-engine/body.js +6 -6
- package/dist/safe-bash-network-engine/decode.d.ts +1 -1
- package/dist/safe-bash-network-engine/decode.js +3 -4
- package/dist/safe-bash-network-engine/fetch-transport.js +3 -3
- package/dist/safe-bash-network-engine/form-content-type.js +2 -2
- package/dist/safe-bash-network-engine/form-headers.js +2 -2
- package/dist/safe-bash-network-engine/glob.js +1 -1
- package/dist/safe-bash-network-engine/index.js +4 -4
- package/dist/safe-bash-network-engine/input.js +6 -6
- package/dist/safe-bash-network-engine/output.js +2 -2
- package/dist/safe-bash-network-engine/platform-portable.js +3 -3
- package/dist/safe-bash-network-engine/shared.js +2 -2
- package/dist/safe-bash-network-engine/types.d.ts +7 -2
- package/dist/safe-bash-network-engine/types.js +1 -1
- package/dist/safe-bash-network-engine/url.js +2 -2
- package/dist/safe-bash-query-engine/capture.js +3 -3
- package/dist/safe-bash-query-engine/delpaths.js +3 -3
- package/dist/safe-bash-query-engine/formats.js +2 -2
- package/dist/safe-bash-query-engine/index.js +11 -11
- package/dist/safe-bash-query-engine/indices.js +3 -3
- package/dist/safe-bash-query-engine/input.js +1 -1
- package/dist/safe-bash-query-engine/interpreter.js +9 -9
- package/dist/safe-bash-query-engine/parser.js +1 -1
- package/dist/safe-bash-query-engine/query-core.js +11 -11
- package/dist/safe-bash-query-engine/regex.js +4 -4
- package/dist/safe-bash-query-engine/splits.js +5 -5
- package/dist/safe-bash-query-engine/values.js +2 -2
- package/dist/safe-bash-regex-engine/ere/matcher.js +102 -30
- package/dist/safe-bash-regex-engine/execution/bounded-provider.js +55 -67
- package/dist/safe-bash-regex-engine/execution/portable.d.ts +0 -1
- package/dist/safe-bash-regex-engine/execution/portable.js +6 -10
- package/dist/safe-bash-regex-engine/execution/protocol.d.ts +0 -5
- package/dist/safe-bash-regex-engine/execution/protocol.js +1 -3
- package/dist/safe-bash-regex-engine/index.js +6 -4
- package/dist/safe-bash-regex-engine/text/budget.d.ts +1 -1
- package/dist/safe-bash-regex-engine/text/budget.js +1 -1
- package/dist/safe-bash-regex-engine/text/regex.d.ts +14 -0
- package/dist/safe-bash-regex-engine/text/regex.js +6 -4
- package/dist/safe-bash-regex-engine/text/replacement-buffer.js +2 -2
- package/dist/safe-bash-regex-engine/text/rust-syntax.js +2 -2
- package/dist/safe-bash-search-engine/grep.js +189 -227
- package/dist/safe-bash-table-text-engine/table-text/internal.d.ts +7 -5
- package/dist/safe-bash-table-text-engine/table-text/internal.js +39 -21
- package/dist/safe-playwright-cloudflare/browser-trace-budget.js +6 -2
- package/dist/spreadsheet-engine/codecs/odf-hyperlinks.js +8 -2
- package/dist/spreadsheet-engine/formulas/functions/captured-bessel-phase.js +2 -2
- package/dist/spreadsheet-engine/formulas/label-references.js +54 -33
- package/dist/spreadsheet-engine/formulas/parser.js +3 -1
- package/dist/spreadsheet-engine/formulas/rewriting.js +13 -3
- package/dist/spreadsheet-format-xls/biff-data-tables.js +4 -6
- package/dist/spreadsheet-format-xls/biff-formulas.js +3 -0
- package/dist/spreadsheet-format-xls/biff-label-ranges.js +9 -6
- package/dist/spreadsheet-format-xls/biff.js +1 -1
- package/dist/xlsx-ast/xlsx.js +8 -5
- package/package.json +68 -12
- package/dist/safe-bash/command-chunks/chunk-KAGBORIC.js +0 -88
- /package/dist/safe-bash/command-chunks/{chunk-BWNXWI33.js → chunk-2LMZVE3I.js} +0 -0
|
@@ -2,17 +2,26 @@ import {
|
|
|
2
2
|
parseSelection,
|
|
3
3
|
resolveSelection
|
|
4
4
|
} from "./chunk-LCF3OB7P.js";
|
|
5
|
+
import {
|
|
6
|
+
Writer
|
|
7
|
+
} from "./chunk-VM2ZMWHQ.js";
|
|
8
|
+
import {
|
|
9
|
+
observe,
|
|
10
|
+
outputOperation,
|
|
11
|
+
preflight,
|
|
12
|
+
publish
|
|
13
|
+
} from "./chunk-JDYXY44P.js";
|
|
5
14
|
import {
|
|
6
15
|
checkedAdd,
|
|
7
16
|
inferDelimiter,
|
|
8
17
|
unsigned
|
|
9
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-Z45N42QC.js";
|
|
10
19
|
import {
|
|
11
20
|
boundedSort
|
|
12
21
|
} from "./chunk-HEYKESED.js";
|
|
13
22
|
import {
|
|
14
23
|
Scanner
|
|
15
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-E55UKBIE.js";
|
|
16
25
|
import {
|
|
17
26
|
XanError
|
|
18
27
|
} from "./chunk-QOKBZFFD.js";
|
|
@@ -23,6 +32,484 @@ import {
|
|
|
23
32
|
// packages/safe-bash-command-xan/src/commands.ts
|
|
24
33
|
init_buffer();
|
|
25
34
|
|
|
35
|
+
// packages/safe-bash-command-xan/src/extended.ts
|
|
36
|
+
init_buffer();
|
|
37
|
+
import { resolvePath } from "../../safe-bash-contracts/path.js";
|
|
38
|
+
|
|
39
|
+
// packages/safe-bash-command-xan/src/cells.ts
|
|
40
|
+
init_buffer();
|
|
41
|
+
async function* emitted(bytes, budget) {
|
|
42
|
+
try {
|
|
43
|
+
yield bytes;
|
|
44
|
+
} finally {
|
|
45
|
+
budget.release(bytes.length);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function* textRow(values, writer, budget) {
|
|
49
|
+
const owned = [];
|
|
50
|
+
budget.hold(values.length * 32);
|
|
51
|
+
try {
|
|
52
|
+
const cells = [];
|
|
53
|
+
for (const value of values) {
|
|
54
|
+
if (typeof value === "string") {
|
|
55
|
+
const bytes = await budget.encode(value);
|
|
56
|
+
owned.push(bytes);
|
|
57
|
+
cells.push(bytes);
|
|
58
|
+
} else cells.push(value);
|
|
59
|
+
}
|
|
60
|
+
yield* emitted(await writer.values(cells), budget);
|
|
61
|
+
} finally {
|
|
62
|
+
for (const bytes of owned) budget.release(bytes.length);
|
|
63
|
+
budget.release(values.length * 32);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async function compareBytes(left, right, budget) {
|
|
67
|
+
for (let i = 0; i < Math.min(left.length, right.length); i++) {
|
|
68
|
+
budget.work();
|
|
69
|
+
if (left[i] !== right[i]) return left[i] < right[i] ? -1 : 1;
|
|
70
|
+
if ((i & 1023) === 0) {
|
|
71
|
+
const c = budget.checkpoint();
|
|
72
|
+
if (c) await c;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return Math.sign(left.length - right.length);
|
|
76
|
+
}
|
|
77
|
+
function cellText(bytes, budget) {
|
|
78
|
+
budget.work(bytes.length);
|
|
79
|
+
try {
|
|
80
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
81
|
+
} catch {
|
|
82
|
+
throw new XanError("cell is not valid UTF-8");
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function decimalNumber(text, budget) {
|
|
86
|
+
let offset = text[0] === "+" || text[0] === "-" ? 1 : 0;
|
|
87
|
+
let digits = 0;
|
|
88
|
+
while (offset < text.length && text[offset] >= "0" && text[offset] <= "9") {
|
|
89
|
+
offset++;
|
|
90
|
+
digits++;
|
|
91
|
+
budget.work();
|
|
92
|
+
}
|
|
93
|
+
if (text[offset] === ".") {
|
|
94
|
+
offset++;
|
|
95
|
+
while (offset < text.length && text[offset] >= "0" && text[offset] <= "9") {
|
|
96
|
+
offset++;
|
|
97
|
+
digits++;
|
|
98
|
+
budget.work();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (!digits) return void 0;
|
|
102
|
+
if (text[offset] === "e" || text[offset] === "E") {
|
|
103
|
+
offset++;
|
|
104
|
+
if (text[offset] === "+" || text[offset] === "-") offset++;
|
|
105
|
+
const start = offset;
|
|
106
|
+
while (offset < text.length && text[offset] >= "0" && text[offset] <= "9") {
|
|
107
|
+
offset++;
|
|
108
|
+
budget.work();
|
|
109
|
+
}
|
|
110
|
+
if (offset === start) return void 0;
|
|
111
|
+
}
|
|
112
|
+
if (offset !== text.length) return void 0;
|
|
113
|
+
const value = Number(text);
|
|
114
|
+
return Number.isFinite(value) ? value : void 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// packages/safe-bash-command-xan/src/extended.ts
|
|
118
|
+
async function select(text, header, args, budget) {
|
|
119
|
+
budget.hold((header?.width ?? 0) * 32);
|
|
120
|
+
try {
|
|
121
|
+
return await resolveSelection(await parseSelection(text, budget), header?.cells.map((cell) => cell.decoded.view()) ?? [], args.noHeaders, budget);
|
|
122
|
+
} finally {
|
|
123
|
+
budget.release((header?.width ?? 0) * 32);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async function key(row, selected, budget) {
|
|
127
|
+
const size = selected.reduce((n, i) => n + row.cells[i].decoded.length * 2 + 32, 0);
|
|
128
|
+
budget.hold(size);
|
|
129
|
+
let result = "";
|
|
130
|
+
for (const index of selected) {
|
|
131
|
+
const bytes = row.cells[index].decoded.view();
|
|
132
|
+
result += `${bytes.length}:`;
|
|
133
|
+
for (const byte of bytes) {
|
|
134
|
+
budget.work();
|
|
135
|
+
result += String.fromCharCode(byte);
|
|
136
|
+
const cp = budget.checkpoint();
|
|
137
|
+
if (cp) await cp;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return { identity: result, size };
|
|
141
|
+
}
|
|
142
|
+
async function aggregates(text, header, args, budget) {
|
|
143
|
+
const result = [];
|
|
144
|
+
let at = 0;
|
|
145
|
+
const whitespace2 = () => {
|
|
146
|
+
while (at < text.length && " \n\r ".includes(text[at])) at++;
|
|
147
|
+
};
|
|
148
|
+
while (at < text.length) {
|
|
149
|
+
whitespace2();
|
|
150
|
+
const begin = at;
|
|
151
|
+
while (at < text.length && text[at] !== "(") at++;
|
|
152
|
+
const name = text.slice(begin, at).trim().toLowerCase();
|
|
153
|
+
if (!["count", "sum", "mean", "avg", "min", "max", "first", "last"].includes(name) || at === text.length) throw new XanError("expected an aggregate call");
|
|
154
|
+
const start = ++at;
|
|
155
|
+
let quote = "";
|
|
156
|
+
while (at < text.length) {
|
|
157
|
+
const ch = text[at];
|
|
158
|
+
if (quote) {
|
|
159
|
+
if (ch === quote) quote = "";
|
|
160
|
+
} else if (ch === '"' || ch === "'") quote = ch;
|
|
161
|
+
else if (ch === ")") break;
|
|
162
|
+
at++;
|
|
163
|
+
}
|
|
164
|
+
if (at === text.length) throw new XanError("unterminated aggregate call");
|
|
165
|
+
const column = text.slice(start, at).trim();
|
|
166
|
+
at++;
|
|
167
|
+
let label = text.slice(begin, at).trim();
|
|
168
|
+
whitespace2();
|
|
169
|
+
if (text.slice(at, at + 2).toLowerCase() === "as" && " \n".includes(text[at + 2] ?? "")) {
|
|
170
|
+
at += 2;
|
|
171
|
+
whitespace2();
|
|
172
|
+
const quote2 = text[at] === '"' || text[at] === "'" ? text[at++] : void 0;
|
|
173
|
+
const start2 = at;
|
|
174
|
+
while (at < text.length && (quote2 ? text[at] !== quote2 : text[at] !== ",")) at++;
|
|
175
|
+
label = text.slice(start2, at).trim();
|
|
176
|
+
if (quote2) {
|
|
177
|
+
if (text[at++] !== quote2) throw new XanError("unterminated aggregate alias");
|
|
178
|
+
whitespace2();
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (at < text.length && text[at++] !== ",") throw new XanError("expected comma between aggregate calls");
|
|
182
|
+
let field;
|
|
183
|
+
if (column && column !== "*") {
|
|
184
|
+
const fields = await select(column, header, args, budget);
|
|
185
|
+
try {
|
|
186
|
+
if (fields.length !== 1) throw new XanError("aggregate requires one column");
|
|
187
|
+
field = fields[0];
|
|
188
|
+
} finally {
|
|
189
|
+
budget.release(fields.length * 8);
|
|
190
|
+
}
|
|
191
|
+
} else if (name !== "count") throw new XanError(`${name} requires a column`);
|
|
192
|
+
budget.hold(128 + label.length * 2);
|
|
193
|
+
result.push({ name, label, ...field === void 0 ? {} : { field } });
|
|
194
|
+
}
|
|
195
|
+
if (!result.length) throw new XanError("expected an aggregate call");
|
|
196
|
+
return result;
|
|
197
|
+
}
|
|
198
|
+
async function* extendedRows(args, scope, budget, writer) {
|
|
199
|
+
if (args.command === "from") {
|
|
200
|
+
yield* from(args, scope, budget, writer);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (args.command === "cat") {
|
|
204
|
+
yield* concatenate(args, scope, budget, writer);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const scanner = scope.open(args.inputs[0], args);
|
|
208
|
+
const header = await scanner.next();
|
|
209
|
+
if (header) scope.own(header.free);
|
|
210
|
+
const retained = [];
|
|
211
|
+
scope.own(() => {
|
|
212
|
+
for (const row of retained) row.free();
|
|
213
|
+
budget.release(retained.length * 32);
|
|
214
|
+
});
|
|
215
|
+
async function* rows2() {
|
|
216
|
+
let row = args.noHeaders ? header : await scanner.next();
|
|
217
|
+
try {
|
|
218
|
+
while (row) {
|
|
219
|
+
if (row.width !== header?.width) throw new XanError("CSV error: inconsistent field count");
|
|
220
|
+
yield row;
|
|
221
|
+
row = await scanner.next();
|
|
222
|
+
}
|
|
223
|
+
} finally {
|
|
224
|
+
row?.free();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (args.command === "enum") {
|
|
228
|
+
if (!args.noHeaders && header) yield* textRow([args.options.get("column-name") ?? "index", ...header.cells.map((cell) => cell.decoded.view())], writer, budget);
|
|
229
|
+
let index = args.start;
|
|
230
|
+
for await (const row of rows2()) {
|
|
231
|
+
try {
|
|
232
|
+
yield* textRow([String(index++), ...row.cells.map((cell) => cell.decoded.view())], writer, budget);
|
|
233
|
+
} finally {
|
|
234
|
+
row.free();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if (args.command === "dedup") {
|
|
240
|
+
const selected = await select(args.selection, header, args, budget);
|
|
241
|
+
const seen = /* @__PURE__ */ new Map();
|
|
242
|
+
scope.own(() => {
|
|
243
|
+
for (const entry of seen.values()) entry.row.free();
|
|
244
|
+
});
|
|
245
|
+
if (!args.noHeaders && header) yield* emitted(await writer.row(header.cells), budget);
|
|
246
|
+
for await (const row of rows2()) {
|
|
247
|
+
const { identity, size } = await key(row, selected, budget), existing = seen.get(identity);
|
|
248
|
+
if (existing) {
|
|
249
|
+
budget.release(size);
|
|
250
|
+
existing.count++;
|
|
251
|
+
if (args.options.has("keep-last")) {
|
|
252
|
+
existing.row.free();
|
|
253
|
+
existing.row = row;
|
|
254
|
+
} else row.free();
|
|
255
|
+
} else {
|
|
256
|
+
budget.hold(96);
|
|
257
|
+
seen.set(identity, { row, count: 1 });
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
for (const entry of seen.values()) if (!args.options.has("keep-duplicates") || entry.count > 1) yield* emitted(await writer.row(entry.row.cells), budget);
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
if (args.command === "agg" || args.command === "groupby") {
|
|
264
|
+
const selected = args.command === "groupby" ? await select(args.rightSelection ?? "", header, args, budget) : [];
|
|
265
|
+
const specs = await aggregates(args.operand, header, args, budget);
|
|
266
|
+
const groups = /* @__PURE__ */ new Map();
|
|
267
|
+
const make = (row) => {
|
|
268
|
+
budget.hold(specs.length * 128 + selected.length * 32 + 64);
|
|
269
|
+
return { keys: selected.map((index) => {
|
|
270
|
+
const bytes = row.cells[index].decoded.view();
|
|
271
|
+
budget.hold(bytes.length);
|
|
272
|
+
return bytes.slice();
|
|
273
|
+
}), states: specs.map(() => ({ count: 0, sum: 0, min: Infinity, max: -Infinity })) };
|
|
274
|
+
};
|
|
275
|
+
if (args.command === "agg") groups.set("", make());
|
|
276
|
+
yield* textRow([...selected.map((index) => args.noHeaders ? String(index) : header.cells[index].decoded.view()), ...specs.map((spec) => spec.label)], writer, budget);
|
|
277
|
+
for await (const row of rows2()) {
|
|
278
|
+
try {
|
|
279
|
+
const { identity, size } = selected.length ? await key(row, selected, budget) : { identity: "", size: 0 };
|
|
280
|
+
let group = groups.get(identity);
|
|
281
|
+
if (!group) {
|
|
282
|
+
group = make(row);
|
|
283
|
+
groups.set(identity, group);
|
|
284
|
+
} else budget.release(size);
|
|
285
|
+
for (let i = 0; i < specs.length; i++) {
|
|
286
|
+
budget.work();
|
|
287
|
+
const spec = specs[i], state = group.states[i];
|
|
288
|
+
const bytes = spec.field === void 0 ? void 0 : row.cells[spec.field].decoded.view();
|
|
289
|
+
if (spec.name === "count") {
|
|
290
|
+
if (!bytes || bytes.length) state.count++;
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
if (!bytes?.length) continue;
|
|
294
|
+
state.count++;
|
|
295
|
+
if (spec.name === "first" || spec.name === "last") {
|
|
296
|
+
if (spec.name === "first" && state.first) continue;
|
|
297
|
+
const previous = spec.name === "first" ? state.first : state.last;
|
|
298
|
+
if (previous) budget.release(previous.length);
|
|
299
|
+
budget.hold(bytes.length);
|
|
300
|
+
if (spec.name === "first") state.first = bytes.slice();
|
|
301
|
+
else state.last = bytes.slice();
|
|
302
|
+
} else {
|
|
303
|
+
budget.hold(bytes.length * 4);
|
|
304
|
+
let value;
|
|
305
|
+
try {
|
|
306
|
+
value = decimalNumber(cellText(bytes, budget), budget);
|
|
307
|
+
} finally {
|
|
308
|
+
budget.release(bytes.length * 4);
|
|
309
|
+
}
|
|
310
|
+
if (value === void 0) throw new XanError(`${spec.name} requires numeric values`);
|
|
311
|
+
state.sum += value;
|
|
312
|
+
state.min = Math.min(state.min, value);
|
|
313
|
+
state.max = Math.max(state.max, value);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
} finally {
|
|
317
|
+
row.free();
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
for (const group of groups.values()) yield* textRow([...group.keys, ...specs.map((spec, i) => {
|
|
321
|
+
const state = group.states[i];
|
|
322
|
+
if (spec.name === "first") return state.first ?? "";
|
|
323
|
+
if (spec.name === "last") return state.last ?? "";
|
|
324
|
+
if (spec.name === "count") return String(state.count);
|
|
325
|
+
if (spec.name === "sum") return String(state.sum);
|
|
326
|
+
if (!state.count) return "";
|
|
327
|
+
return String(spec.name === "min" ? state.min : spec.name === "max" ? state.max : state.sum / state.count);
|
|
328
|
+
})], writer, budget);
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
if (args.command === "transpose" && !args.noHeaders && header) {
|
|
332
|
+
budget.hold(32);
|
|
333
|
+
retained.push(header);
|
|
334
|
+
}
|
|
335
|
+
for await (const row of rows2()) {
|
|
336
|
+
budget.hold(32);
|
|
337
|
+
retained.push(row);
|
|
338
|
+
}
|
|
339
|
+
if (args.command === "transpose") {
|
|
340
|
+
for (let i = 0; i < (header?.width ?? 0); i++) yield* textRow(retained.map((row) => row.cells[i].decoded.view()), writer, budget);
|
|
341
|
+
} else if (args.command === "split") {
|
|
342
|
+
const options = args.options;
|
|
343
|
+
let size = Number(await unsigned(options.get("size") ?? "4096", "--size", budget));
|
|
344
|
+
if (options.has("chunks")) {
|
|
345
|
+
const chunks = Number(await unsigned(options.get("chunks"), "--chunks", budget));
|
|
346
|
+
if (!chunks) throw new XanError("chunks must be positive");
|
|
347
|
+
size = Math.max(1, Math.ceil(retained.length / chunks));
|
|
348
|
+
}
|
|
349
|
+
if (!Number.isSafeInteger(size) || size <= 0) throw new XanError("size must be positive");
|
|
350
|
+
const directory = resolvePath(scope.context.cwd, options.get("out-dir") ?? ".");
|
|
351
|
+
const template = options.get("filename") ?? "{}.csv";
|
|
352
|
+
if (template.split("{}").length !== 2 || template.includes("/") || template.includes("\\") || template.includes("\0")) throw new XanError("filename must contain one {} and no path separators");
|
|
353
|
+
await observe(() => scope.context.fs.mkdir(directory, { recursive: true, signal: budget.signal }), budget.signal);
|
|
354
|
+
for (let start = 0; start < Math.max(1, retained.length); start += size) {
|
|
355
|
+
budget.work();
|
|
356
|
+
const output = resolvePath(directory, template.replace("{}", String(options.has("chunks") ? start / size : start)));
|
|
357
|
+
const destination = await preflight(scope.context, { ...args, output }, budget);
|
|
358
|
+
const operation = outputOperation(scope.context, true);
|
|
359
|
+
const chunks = async function* () {
|
|
360
|
+
const chunkWriter = new Writer(writer.delimiter, budget);
|
|
361
|
+
if (!args.noHeaders && header) yield* emitted(await chunkWriter.row(header.cells), budget);
|
|
362
|
+
for (let i = start; i < Math.min(start + size, retained.length); i++) yield* emitted(await chunkWriter.row(retained[i].cells), budget);
|
|
363
|
+
};
|
|
364
|
+
try {
|
|
365
|
+
await publish(scope.context, destination, chunks(), operation, budget);
|
|
366
|
+
} finally {
|
|
367
|
+
await operation.close();
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
} else if (args.command === "to") {
|
|
371
|
+
const format = args.operand;
|
|
372
|
+
if (!["json", "jsonl", "ndjson", "txt"].includes(format)) throw new XanError(`unsupported output format: ${format}`);
|
|
373
|
+
const names = header?.cells.map((cell, index) => args.noHeaders ? String(index) : cellText(cell.decoded.view(), budget)) ?? [];
|
|
374
|
+
const numeric = names.map((_, column) => retained.every((row) => {
|
|
375
|
+
const text = cellText(row.cells[column].decoded.view(), budget);
|
|
376
|
+
return !text || decimalNumber(text, budget) !== void 0;
|
|
377
|
+
}));
|
|
378
|
+
if (format === "json") yield* emitted(await writer.text("["), budget);
|
|
379
|
+
for (let i = 0; i < retained.length; i++) {
|
|
380
|
+
const row = retained[i];
|
|
381
|
+
const temporary = row.cells.reduce((n, cell) => n + cell.decoded.length * 12 + 64, 0);
|
|
382
|
+
budget.hold(temporary);
|
|
383
|
+
try {
|
|
384
|
+
const values = row.cells.map((cell) => cellText(cell.decoded.view(), budget));
|
|
385
|
+
if (format === "txt") {
|
|
386
|
+
yield* emitted(await writer.text(values.join("\n") + "\n"), budget);
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
const record = Object.fromEntries(values.flatMap((value, column) => !value && args.options.has("omit") ? [] : [[names[column], !value ? args.options.has("nulls") ? null : "" : numeric[column] ? Number(value) : value]]));
|
|
390
|
+
yield* emitted(await writer.text((format === "json" && i ? "," : "") + JSON.stringify(record) + (format === "json" ? "" : "\n")), budget);
|
|
391
|
+
} finally {
|
|
392
|
+
budget.release(temporary);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
if (format === "json") yield* emitted(await writer.text("]\n"), budget);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
async function* from(args, scope, budget, writer) {
|
|
399
|
+
const path = args.inputs[0], format = args.options.get("format") ?? path.slice(path.lastIndexOf(".") + 1);
|
|
400
|
+
if (!["json", "jsonl", "ndjson", "txt", "text", "lines", "raw"].includes(format)) throw new XanError(`unsupported input format: ${format}`);
|
|
401
|
+
const scanner = scope.open(path, args), chunks = [];
|
|
402
|
+
let size = 0;
|
|
403
|
+
for await (const chunk of scanner.raw(false)) {
|
|
404
|
+
budget.hold(chunk.length + 32);
|
|
405
|
+
chunks.push(chunk.slice());
|
|
406
|
+
size += chunk.length;
|
|
407
|
+
}
|
|
408
|
+
budget.hold(size * 64);
|
|
409
|
+
const bytes = new Uint8Array(size);
|
|
410
|
+
let offset = 0;
|
|
411
|
+
for (const chunk of chunks) {
|
|
412
|
+
bytes.set(chunk, offset);
|
|
413
|
+
offset += chunk.length;
|
|
414
|
+
budget.work(chunk.length);
|
|
415
|
+
const cp = budget.checkpoint();
|
|
416
|
+
if (cp) await cp;
|
|
417
|
+
}
|
|
418
|
+
const text = cellText(bytes, budget);
|
|
419
|
+
if (["raw", "txt", "text", "lines"].includes(format)) {
|
|
420
|
+
yield* textRow([args.options.get("column-name") ?? "text"], writer, budget);
|
|
421
|
+
const lines = format === "raw" ? [text] : text.split("\n");
|
|
422
|
+
if (format !== "raw" && lines.at(-1) === "") lines.pop();
|
|
423
|
+
for (const line of lines) {
|
|
424
|
+
budget.add("maxRecords", 1);
|
|
425
|
+
const value = line.endsWith("\r") && format !== "raw" ? line.slice(0, -1) : line;
|
|
426
|
+
const bytes2 = await budget.textSize(value);
|
|
427
|
+
budget.bound("maxCellBytes", bytes2);
|
|
428
|
+
budget.bound("maxRecordBytes", bytes2);
|
|
429
|
+
yield* textRow([value], writer, budget);
|
|
430
|
+
}
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
let data2;
|
|
434
|
+
try {
|
|
435
|
+
data2 = format === "json" ? JSON.parse(text) : text.split("\n").filter((line) => line.trim()).map((line) => JSON.parse(line));
|
|
436
|
+
} catch {
|
|
437
|
+
throw new XanError("invalid JSON input");
|
|
438
|
+
}
|
|
439
|
+
const rows2 = Array.isArray(data2) ? data2 : args.options.has("single-object") ? [data2] : typeof data2 === "object" && data2 !== null ? Object.entries(data2).map(([key2, value]) => ({ key: key2, value })) : [];
|
|
440
|
+
const names = /* @__PURE__ */ new Set();
|
|
441
|
+
for (const row of rows2) {
|
|
442
|
+
budget.add("maxRecords", 1);
|
|
443
|
+
if (!row || typeof row !== "object" || Array.isArray(row)) throw new XanError("JSON records must be objects");
|
|
444
|
+
for (const name of Object.keys(row)) {
|
|
445
|
+
budget.work();
|
|
446
|
+
names.add(name);
|
|
447
|
+
budget.bound("maxColumns", names.size);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
const columns = [...names];
|
|
451
|
+
if (args.options.has("sort-keys")) columns.sort();
|
|
452
|
+
if (columns.length) yield* textRow(columns, writer, budget);
|
|
453
|
+
for (const row of rows2) {
|
|
454
|
+
const values = [];
|
|
455
|
+
let recordBytes = 0;
|
|
456
|
+
for (const name of columns) {
|
|
457
|
+
const value = row[name];
|
|
458
|
+
const text2 = value === null || value === void 0 ? "" : typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
459
|
+
const bytes2 = await budget.textSize(text2);
|
|
460
|
+
budget.bound("maxCellBytes", bytes2);
|
|
461
|
+
recordBytes += bytes2;
|
|
462
|
+
budget.bound("maxRecordBytes", recordBytes);
|
|
463
|
+
values.push(text2);
|
|
464
|
+
}
|
|
465
|
+
yield* textRow(values, writer, budget);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
async function* concatenate(args, scope, budget, writer) {
|
|
469
|
+
if (!["rows", "cols", "columns"].includes(args.operand)) throw new XanError("cat requires rows or columns");
|
|
470
|
+
if (args.operand === "rows") {
|
|
471
|
+
let width2;
|
|
472
|
+
let headerEmitted = false;
|
|
473
|
+
for (let input = 0; input < args.inputs.length; input++) {
|
|
474
|
+
const scanner = scope.open(args.inputs[input], args);
|
|
475
|
+
let first = true;
|
|
476
|
+
for (; ; ) {
|
|
477
|
+
const row = await scanner.next();
|
|
478
|
+
if (!row) break;
|
|
479
|
+
try {
|
|
480
|
+
width2 ??= row.width;
|
|
481
|
+
if (row.width !== width2) throw new XanError("CSV error: inconsistent field count");
|
|
482
|
+
if (!(first && headerEmitted && !args.noHeaders)) yield* emitted(await writer.row(row.cells), budget);
|
|
483
|
+
headerEmitted = true;
|
|
484
|
+
} finally {
|
|
485
|
+
row.free();
|
|
486
|
+
}
|
|
487
|
+
first = false;
|
|
488
|
+
}
|
|
489
|
+
await scanner.close();
|
|
490
|
+
}
|
|
491
|
+
} else {
|
|
492
|
+
const scanners = args.inputs.map((path) => scope.open(path, args)), widths = [];
|
|
493
|
+
for (; ; ) {
|
|
494
|
+
const rows2 = [];
|
|
495
|
+
try {
|
|
496
|
+
for (const scanner of scanners) rows2.push(await scanner.next());
|
|
497
|
+
if (rows2.every((row) => !row) || !args.options.has("pad") && rows2.some((row) => !row)) break;
|
|
498
|
+
const values = [];
|
|
499
|
+
for (let i = 0; i < rows2.length; i++) {
|
|
500
|
+
const row = rows2[i];
|
|
501
|
+
widths[i] ??= row?.width ?? 0;
|
|
502
|
+
if (row && row.width !== widths[i]) throw new XanError("CSV error: inconsistent field count");
|
|
503
|
+
values.push(...row ? row.cells.map((cell) => cell.decoded.view()) : Array(widths[i]).fill(""));
|
|
504
|
+
}
|
|
505
|
+
yield* textRow(values, writer, budget);
|
|
506
|
+
} finally {
|
|
507
|
+
for (const row of rows2) row?.free();
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
26
513
|
// packages/safe-bash-command-xan/src/condition.ts
|
|
27
514
|
init_buffer();
|
|
28
515
|
async function condition(expression, headers, noHeaders, budget, scope) {
|
|
@@ -123,84 +610,6 @@ async function condition(expression, headers, noHeaders, budget, scope) {
|
|
|
123
610
|
// packages/safe-bash-command-xan/src/transform.ts
|
|
124
611
|
init_buffer();
|
|
125
612
|
|
|
126
|
-
// packages/safe-bash-command-xan/src/cells.ts
|
|
127
|
-
init_buffer();
|
|
128
|
-
async function* emitted(bytes, budget) {
|
|
129
|
-
try {
|
|
130
|
-
yield bytes;
|
|
131
|
-
} finally {
|
|
132
|
-
budget.release(bytes.length);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
async function* textRow(values, writer, budget) {
|
|
136
|
-
const owned = [];
|
|
137
|
-
budget.hold(values.length * 32);
|
|
138
|
-
try {
|
|
139
|
-
const cells = [];
|
|
140
|
-
for (const value of values) {
|
|
141
|
-
if (typeof value === "string") {
|
|
142
|
-
const bytes = await budget.encode(value);
|
|
143
|
-
owned.push(bytes);
|
|
144
|
-
cells.push(bytes);
|
|
145
|
-
} else cells.push(value);
|
|
146
|
-
}
|
|
147
|
-
yield* emitted(await writer.values(cells), budget);
|
|
148
|
-
} finally {
|
|
149
|
-
for (const bytes of owned) budget.release(bytes.length);
|
|
150
|
-
budget.release(values.length * 32);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
async function compareBytes(left, right, budget) {
|
|
154
|
-
for (let i = 0; i < Math.min(left.length, right.length); i++) {
|
|
155
|
-
budget.work();
|
|
156
|
-
if (left[i] !== right[i]) return left[i] < right[i] ? -1 : 1;
|
|
157
|
-
if ((i & 1023) === 0) {
|
|
158
|
-
const c = budget.checkpoint();
|
|
159
|
-
if (c) await c;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return Math.sign(left.length - right.length);
|
|
163
|
-
}
|
|
164
|
-
function cellText(bytes, budget) {
|
|
165
|
-
budget.work(bytes.length);
|
|
166
|
-
try {
|
|
167
|
-
return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
168
|
-
} catch {
|
|
169
|
-
throw new XanError("cell is not valid UTF-8");
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
function decimalNumber(text, budget) {
|
|
173
|
-
let offset = text[0] === "+" || text[0] === "-" ? 1 : 0;
|
|
174
|
-
let digits = 0;
|
|
175
|
-
while (offset < text.length && text[offset] >= "0" && text[offset] <= "9") {
|
|
176
|
-
offset++;
|
|
177
|
-
digits++;
|
|
178
|
-
budget.work();
|
|
179
|
-
}
|
|
180
|
-
if (text[offset] === ".") {
|
|
181
|
-
offset++;
|
|
182
|
-
while (offset < text.length && text[offset] >= "0" && text[offset] <= "9") {
|
|
183
|
-
offset++;
|
|
184
|
-
digits++;
|
|
185
|
-
budget.work();
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
if (!digits) return void 0;
|
|
189
|
-
if (text[offset] === "e" || text[offset] === "E") {
|
|
190
|
-
offset++;
|
|
191
|
-
if (text[offset] === "+" || text[offset] === "-") offset++;
|
|
192
|
-
const start = offset;
|
|
193
|
-
while (offset < text.length && text[offset] >= "0" && text[offset] <= "9") {
|
|
194
|
-
offset++;
|
|
195
|
-
budget.work();
|
|
196
|
-
}
|
|
197
|
-
if (offset === start) return void 0;
|
|
198
|
-
}
|
|
199
|
-
if (offset !== text.length) return void 0;
|
|
200
|
-
const value = Number(text);
|
|
201
|
-
return Number.isFinite(value) ? value : void 0;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
613
|
// packages/safe-bash-command-xan/src/summary.ts
|
|
205
614
|
init_buffer();
|
|
206
615
|
async function* summarize(args, rows2, first, selected, budget, writer) {
|
|
@@ -238,21 +647,21 @@ async function* summarize(args, rows2, first, selected, budget, writer) {
|
|
|
238
647
|
if (args.command === "freq") {
|
|
239
648
|
if (!bytes.length && options.has("no-extra")) continue;
|
|
240
649
|
hold(bytes.length * 4 + 64);
|
|
241
|
-
let
|
|
650
|
+
let key2 = "";
|
|
242
651
|
for (let i = 0; i < bytes.length; i++) {
|
|
243
652
|
budget.work();
|
|
244
|
-
|
|
653
|
+
key2 += String.fromCharCode(bytes[i]);
|
|
245
654
|
if ((i & 1023) === 0) {
|
|
246
655
|
const c = budget.checkpoint();
|
|
247
656
|
if (c) await c;
|
|
248
657
|
}
|
|
249
658
|
}
|
|
250
|
-
const existing = state.frequencies.get(
|
|
659
|
+
const existing = state.frequencies.get(key2);
|
|
251
660
|
if (existing) {
|
|
252
661
|
existing.count++;
|
|
253
662
|
budget.release(bytes.length * 4 + 64);
|
|
254
663
|
held -= bytes.length * 4 + 64;
|
|
255
|
-
} else state.frequencies.set(
|
|
664
|
+
} else state.frequencies.set(key2, { bytes: bytes.slice(), count: 1 });
|
|
256
665
|
continue;
|
|
257
666
|
}
|
|
258
667
|
if (!bytes.length) {
|
|
@@ -577,7 +986,7 @@ async function* join(args, left, first, leftKeys, scope, budget, writer) {
|
|
|
577
986
|
budget.hold(bytes);
|
|
578
987
|
held += bytes;
|
|
579
988
|
};
|
|
580
|
-
const
|
|
989
|
+
const key2 = async (row, columns) => {
|
|
581
990
|
let result = "", nonempty = false;
|
|
582
991
|
for (const i of columns) {
|
|
583
992
|
const bytes = row.cells[i].decoded.view();
|
|
@@ -612,7 +1021,7 @@ async function* join(args, left, first, leftKeys, scope, budget, writer) {
|
|
|
612
1021
|
hold(row.cells.reduce((n, cell) => n + cell.decoded.length * 8 + 64, 128));
|
|
613
1022
|
rows2.push(row);
|
|
614
1023
|
retained = true;
|
|
615
|
-
const value = await
|
|
1024
|
+
const value = await key2(row, rightKeys);
|
|
616
1025
|
if (value !== void 0) {
|
|
617
1026
|
const group = index.get(value);
|
|
618
1027
|
if (group) group.push(row);
|
|
@@ -627,7 +1036,7 @@ async function* join(args, left, first, leftKeys, scope, budget, writer) {
|
|
|
627
1036
|
budget.hold(row.cells.reduce((n, cell) => n + cell.decoded.length * 8 + 64, 0));
|
|
628
1037
|
let value;
|
|
629
1038
|
try {
|
|
630
|
-
value = await
|
|
1039
|
+
value = await key2(row, leftKeys);
|
|
631
1040
|
const matches = options.has("cross") ? rows2 : value === void 0 ? [] : index.get(value) ?? [];
|
|
632
1041
|
if (semi) {
|
|
633
1042
|
if (options.has("anti") ? !matches.length : matches.length) yield* output(row, void 0);
|
|
@@ -667,7 +1076,8 @@ function width(row, expected) {
|
|
|
667
1076
|
if (row.width !== expected) throw new XanError(`CSV error: record ${row.number} (byte: ${row.offset}): found record with ${row.width} fields, but the previous record has ${expected} fields`);
|
|
668
1077
|
}
|
|
669
1078
|
async function prepareRows(args, selection, scope, budget, writer) {
|
|
670
|
-
if (args.help) return emitted2(await writer.text("xan: CSV tools for virtual files and byte streams\nCommands: headers (h), count, select, slice, head, tail, sort, search,\n filter, reverse, rename, drop, stats, freq (frequency), join\nCommon: -h --help, -d --delimiter BYTE, -o --output PATH\nheaders: -j --just-names, --csv, -s --start N, --color auto|never\ncount/select/slice: -n --no-headers\ncount: -H/--human-readable, -c/--check-alignment, -a/--approx, -p/--parallel, -t/--threads N\nselect: literal selection or -e/--evaluate COLUMN, -f/--evaluate-file PATH;\nslice: -s/--start, --skip, -e/--end, -l/--len, -i/--index, -I/--indices, -L/--last\nslice bytes: -B/--byte-offset N, --end-byte N, --raw\nslice conditions: -S/--start-condition EXPR, -E/--end-condition EXPR\nConditions: named column comparisons with string/number literals.\nhead/tail: -l/--limit N (default 10)\nsort: -s/--select COLUMNS, -N/--numeric, -R/--reverse, -u/--uniq\nsearch: PATTERN; -s/--select, -e/--exact, -i/--ignore-case, -v/--invert-match\nfilter: COLUMN comparison LITERAL; -v/--invert-match\nrename: NAMES; -s/--select COLUMNS; drop: SELECTION\nstats/freq: -s/--select COLUMNS; freq: -l/--limit N, -A/--all, -N/--no-extra\njoin: COLUMNS LEFT [RIGHT_COLUMNS] RIGHT; --left/--right/--full/--semi/--anti/--cross\n --drop-key none|left|right|both, --nulls, -i/--ignore-case\nSearch uses literal substrings; filter supports the comparisons above.\
|
|
1079
|
+
if (args.help) return emitted2(await writer.text("xan: CSV tools for virtual files and byte streams\nCommands: headers (h), count, select, slice, head, tail, sort, search,\n filter, reverse, rename, drop, stats, freq (frequency), join,\n dedup, enum, transpose, agg, groupby, to, from, cat, split\nCommon: -h --help, -d --delimiter BYTE, -o --output PATH\nheaders: -j --just-names, --csv, -s --start N, --color auto|never\ncount/select/slice: -n --no-headers\ncount: -H/--human-readable, -c/--check-alignment, -a/--approx, -p/--parallel, -t/--threads N\nselect: literal selection or -e/--evaluate COLUMN, -f/--evaluate-file PATH;\nslice: -s/--start, --skip, -e/--end, -l/--len, -i/--index, -I/--indices, -L/--last\nslice bytes: -B/--byte-offset N, --end-byte N, --raw\nslice conditions: -S/--start-condition EXPR, -E/--end-condition EXPR\nConditions: named column comparisons with string/number literals.\nhead/tail: -l/--limit N (default 10)\nsort: -s/--select COLUMNS, -N/--numeric, -R/--reverse, -u/--uniq\nsearch: PATTERN; -s/--select, -e/--exact, -i/--ignore-case, -v/--invert-match\nfilter: COLUMN comparison LITERAL; -v/--invert-match\nrename: NAMES; -s/--select COLUMNS; drop: SELECTION\nstats/freq: -s/--select COLUMNS; freq: -l/--limit N, -A/--all, -N/--no-extra\njoin: COLUMNS LEFT [RIGHT_COLUMNS] RIGHT; --left/--right/--full/--semi/--anti/--cross\n --drop-key none|left|right|both, --nulls, -i/--ignore-case\nSearch uses literal substrings; filter supports the comparisons above.\nagg/groupby: aggregate calls (count, sum, mean, min, max, first, last) with optional AS names.\nto: json, jsonl, ndjson, txt; from: -f json, jsonl, ndjson, txt, raw.\ncat: rows or cols [--pad]; split: -S SIZE, -O DIRECTORY, -f TEMPLATE.\nOther expressions, formats and forced color are unsupported.\nCount execution options use exact sequential counting.\n"), budget);
|
|
1080
|
+
if (["dedup", "enum", "transpose", "agg", "groupby", "to", "from", "cat", "split"].includes(args.command)) return extendedRows(args, scope, budget, writer);
|
|
671
1081
|
if (!["headers", "count", "select", "drop", "slice"].includes(args.command)) return transformRows(args, scope, budget, writer);
|
|
672
1082
|
if (args.command === "headers") return prepareHeaders(args, scope, budget, writer);
|
|
673
1083
|
if (args.command === "slice" && !args.raw && args.noHeaders && args.last === 0) return emitted2(new Uint8Array(0), budget);
|