@stacksjs/stx 0.2.706 → 0.2.707
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/dist/app-shell.d.ts +2 -1
- package/dist/app-shell.js +5 -2
- package/dist/{chunk-e3yhx053.js → chunk-029qng4p.js} +5 -5
- package/dist/chunk-0dve54ne.js +3 -0
- package/dist/chunk-0f12mv0z.js +2 -0
- package/dist/{chunk-m4j9gedb.js → chunk-0myrwz84.js} +48 -8
- package/dist/{chunk-5bgkb4vm.js → chunk-0v5nfhwg.js} +3 -3
- package/dist/chunk-12vjp2gr.js +2 -0
- package/dist/chunk-18fr730w.js +2 -0
- package/dist/{chunk-p4czdmrr.js → chunk-1f4e06c2.js} +2 -2
- package/dist/{chunk-n2ema4wf.js → chunk-1xjv71dw.js} +2 -2
- package/dist/chunk-29sapda2.js +2 -0
- package/dist/{chunk-d597d0dp.js → chunk-2aarvd3a.js} +6 -6
- package/dist/chunk-2dgbme86.js +2 -0
- package/dist/{chunk-ah5ch04j.js → chunk-2gny5jdt.js} +2 -2
- package/dist/chunk-2qf6kd9r.js +2 -0
- package/dist/chunk-2snfd93r.js +2 -0
- package/dist/chunk-2tqekz3d.js +3 -0
- package/dist/{chunk-y91rz3rq.js → chunk-3457kk19.js} +7 -7
- package/dist/chunk-3hhcea1p.js +54 -0
- package/dist/chunk-3t3p2c1t.js +65 -0
- package/dist/{chunk-3850m7ab.js → chunk-3wkgd883.js} +1 -1
- package/dist/chunk-42t97n9v.js +2 -0
- package/dist/{chunk-t27fecet.js → chunk-42w6snem.js} +4 -4
- package/dist/chunk-46s9ma3t.js +2 -0
- package/dist/chunk-4c1fbthr.js +2 -0
- package/dist/{chunk-zggdhtmn.js → chunk-4ckxs446.js} +3 -3
- package/dist/chunk-4fxg20je.js +2 -0
- package/dist/chunk-4m9qn8ps.js +4 -0
- package/dist/chunk-4y73c35z.js +33 -0
- package/dist/{chunk-jkywbfb0.js → chunk-533g1b9b.js} +2 -2
- package/dist/chunk-58v34kba.js +2 -0
- package/dist/{chunk-9p452mq6.js → chunk-59g266vc.js} +114 -114
- package/dist/{chunk-2gzrx4ma.js → chunk-59k5ntkt.js} +56 -56
- package/dist/chunk-5n4qg8za.js +3 -0
- package/dist/{chunk-1kr1mpft.js → chunk-67abad76.js} +1 -1
- package/dist/{chunk-7smgebdq.js → chunk-6cz1sbb1.js} +3 -3
- package/dist/{chunk-eb3xg8an.js → chunk-6ms7rtqt.js} +1 -1
- package/dist/{chunk-4sesw88b.js → chunk-6n11z33h.js} +5 -5
- package/dist/chunk-6ndeycxk.js +2 -0
- package/dist/{chunk-tp4eqfxq.js → chunk-6ts3sthp.js} +2 -2
- package/dist/{chunk-8w4y3dx3.js → chunk-768evhvm.js} +2 -2
- package/dist/{chunk-0qtygx7m.js → chunk-79p5580k.js} +4 -4
- package/dist/chunk-79vj1txq.js +4 -0
- package/dist/chunk-7c7jnph2.js +20 -0
- package/dist/chunk-7dc3n69c.js +3 -0
- package/dist/chunk-7hpwcwwh.js +2 -0
- package/dist/chunk-7ppbv5bc.js +14 -0
- package/dist/{chunk-ccqe741j.js → chunk-83p5k4eb.js} +2 -2
- package/dist/{chunk-b1a79hgk.js → chunk-89s38bat.js} +2 -2
- package/dist/chunk-8s4rxgs8.js +2 -0
- package/dist/chunk-8ss2v7sw.js +2 -0
- package/dist/chunk-8t9em8md.js +2 -0
- package/dist/{chunk-vfjenjez.js → chunk-8v2vbc4y.js} +1 -1
- package/dist/chunk-921gb49g.js +2 -0
- package/dist/chunk-9736003n.js +2 -0
- package/dist/chunk-97r557ws.js +2 -0
- package/dist/{chunk-x7rtrdqq.js → chunk-998zvkzr.js} +3 -3
- package/dist/{chunk-5w1erc2m.js → chunk-9dg5ja4w.js} +1 -1
- package/dist/chunk-9frqh3bj.js +2 -0
- package/dist/{chunk-ygtfjnqj.js → chunk-9v1t47d2.js} +2 -2
- package/dist/chunk-a35m0g7z.js +2 -0
- package/dist/{chunk-3hxd5td3.js → chunk-am4wadh7.js} +2 -2
- package/dist/{chunk-wqe98032.js → chunk-an387127.js} +2 -2
- package/dist/{chunk-bsr9wnq4.js → chunk-ap30qs8p.js} +2 -2
- package/dist/chunk-avr65xra.js +2 -0
- package/dist/chunk-b2ajtmvk.js +2 -0
- package/dist/chunk-b6318vv3.js +2 -0
- package/dist/{chunk-7kn0d1f1.js → chunk-b7j48bq9.js} +2 -2
- package/dist/chunk-bcr8sq50.js +2 -0
- package/dist/chunk-bd9p1xmr.js +2 -0
- package/dist/chunk-c5tky2vf.js +32 -0
- package/dist/{chunk-qef5mz20.js → chunk-cam9je83.js} +105 -105
- package/dist/{chunk-njhd845r.js → chunk-ckrmrdjp.js} +5 -5
- package/dist/{chunk-epnpst9q.js → chunk-cm8m2ygc.js} +11 -11
- package/dist/{chunk-k296qq0p.js → chunk-cwhzk2n3.js} +2 -2
- package/dist/{chunk-rcdjse0z.js → chunk-czy6hs6g.js} +5 -5
- package/dist/{chunk-y7xsjr28.js → chunk-d21twmm2.js} +1 -1
- package/dist/chunk-d22sgyg2.js +3 -0
- package/dist/chunk-dhdt7e54.js +2 -0
- package/dist/chunk-dmcjap96.js +20 -0
- package/dist/chunk-dxqvv686.js +3 -0
- package/dist/chunk-dzkg6cy5.js +3 -0
- package/dist/{chunk-b3sw5ykg.js → chunk-edka95zp.js} +3 -3
- package/dist/chunk-enssxcpa.js +2 -0
- package/dist/chunk-eqz0g5c5.js +25 -0
- package/dist/chunk-f7a6nzx6.js +2 -0
- package/dist/{chunk-44c1mbye.js → chunk-fcbd7kwj.js} +3 -3
- package/dist/chunk-fen5nnc4.js +2 -0
- package/dist/chunk-fvk1xr5a.js +2 -0
- package/dist/chunk-g03tkxds.js +2 -0
- package/dist/{chunk-b2j7s1a2.js → chunk-g1tq4xdb.js} +2 -2
- package/dist/chunk-g6wd49b5.js +2 -0
- package/dist/chunk-gbkcc96c.js +2 -0
- package/dist/chunk-gk0nq2ky.js +2 -0
- package/dist/chunk-h8kbcz9t.js +2 -0
- package/dist/chunk-hs2sbkvk.js +2 -0
- package/dist/{chunk-yn9kvsk1.js → chunk-j2mpqa4p.js} +2 -2
- package/dist/chunk-j3emvkjb.js +2 -0
- package/dist/{chunk-a8erwxng.js → chunk-j9mpwt71.js} +3 -3
- package/dist/{chunk-gp9k0t3g.js → chunk-jb5sftzz.js} +2 -2
- package/dist/chunk-jef9mn1h.js +2 -0
- package/dist/chunk-jx7q5cnv.js +11 -0
- package/dist/chunk-jztsks2y.js +2 -0
- package/dist/{chunk-t8d33x9w.js → chunk-khrckvwn.js} +4 -4
- package/dist/{chunk-3ja845kw.js → chunk-km5dpg5v.js} +171 -171
- package/dist/chunk-kqdzjgm6.js +421 -0
- package/dist/chunk-ktf42hmd.js +2 -0
- package/dist/{chunk-4x2gnvz1.js → chunk-kxf8z7vp.js} +2 -2
- package/dist/chunk-mzwa2478.js +2 -0
- package/dist/chunk-n6carvxa.js +2 -0
- package/dist/chunk-ncs2j5kc.js +3 -0
- package/dist/chunk-nzyr320e.js +2 -0
- package/dist/{chunk-z9csfarm.js → chunk-p4s8hq38.js} +11 -11
- package/dist/chunk-pank9g6n.js +2 -0
- package/dist/chunk-pf427myt.js +2 -0
- package/dist/chunk-pfjsyvmj.js +21 -0
- package/dist/chunk-pgjqx3kg.js +42 -0
- package/dist/{chunk-3ys3sa08.js → chunk-qa9t9k6z.js} +1 -1
- package/dist/chunk-qf0bs4a5.js +2 -0
- package/dist/chunk-qprjkz11.js +18 -0
- package/dist/{chunk-j9h41w8b.js → chunk-qy1ss1en.js} +2 -2
- package/dist/chunk-r6bc2q44.js +2 -0
- package/dist/{chunk-2e2qnce5.js → chunk-r96wcqs6.js} +2 -2
- package/dist/{chunk-sxf17xfc.js → chunk-rb2a1qxb.js} +6 -6
- package/dist/chunk-rwjgpmrw.js +2 -0
- package/dist/{chunk-416jy1m5.js → chunk-s9b6abkb.js} +2 -2
- package/dist/chunk-sdpzaase.js +2 -0
- package/dist/{chunk-2p34qf9c.js → chunk-stvw8y3c.js} +2 -2
- package/dist/chunk-sy1btryy.js +2 -0
- package/dist/{chunk-66cfnzem.js → chunk-t21ae4rx.js} +5 -5
- package/dist/{chunk-9ra3ne11.js → chunk-t63f15yh.js} +3 -3
- package/dist/{chunk-2v7t87n8.js → chunk-t6ayy0t5.js} +2 -2
- package/dist/{chunk-11mjqfde.js → chunk-t7ezw8cj.js} +45 -45
- package/dist/chunk-t7mbaf69.js +2 -0
- package/dist/chunk-taste5sr.js +2 -0
- package/dist/chunk-txjx2xd6.js +2 -0
- package/dist/chunk-txr51pkd.js +2 -0
- package/dist/chunk-vjyrwvz0.js +24 -0
- package/dist/chunk-vstvadc2.js +12 -0
- package/dist/chunk-w2h6nn70.js +2 -0
- package/dist/chunk-w4vxhedk.js +2 -0
- package/dist/{chunk-ktkmv1j8.js → chunk-wbfg7p3k.js} +4 -4
- package/dist/{chunk-nv886zy6.js → chunk-wevcmbn6.js} +10 -10
- package/dist/{chunk-gxtmq5r2.js → chunk-wj235n59.js} +7 -7
- package/dist/{chunk-3392k9vm.js → chunk-wp6q0geg.js} +2 -2
- package/dist/chunk-x8zekavj.js +2 -0
- package/dist/{chunk-xc03cdet.js → chunk-xyyt8v1r.js} +28 -28
- package/dist/chunk-ykmcnk3x.js +2 -0
- package/dist/chunk-yw66yks2.js +43 -0
- package/dist/chunk-z05dbey1.js +2 -0
- package/dist/{chunk-w7e28p74.js → chunk-zav8yrtp.js} +9 -9
- package/dist/{chunk-2nqt1m3m.js → chunk-zdpd29xd.js} +2 -2
- package/dist/{chunk-ywzh979k.js → chunk-zecgd1wz.js} +4 -4
- package/dist/{chunk-c3hr5mm2.js → chunk-zjaw79zp.js} +2 -2
- package/dist/{chunk-fgr56q3w.js → chunk-zjw6j2x0.js} +4 -4
- package/dist/{chunk-k7pmzreg.js → chunk-zn3c0ew5.js} +3 -3
- package/dist/cli.js +46 -46
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/dev-server/serve-app.js +1 -1
- package/dist/expressions.js +6 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/island-chunking.js +5 -1
- package/dist/page-head.d.ts +2 -0
- package/dist/page-head.js +35 -0
- package/dist/production-builder.js +1 -1
- package/dist/production-server.js +2 -2
- package/dist/pwa.js +3 -3
- package/dist/site-builder/i18n.js +1 -1
- package/dist/ssg.js +36 -36
- package/dist/template-compiler.js +2 -1
- package/package.json +5 -5
- package/dist/chunk-09801kkv.js +0 -2
- package/dist/chunk-0s55c880.js +0 -2
- package/dist/chunk-0ys97vq8.js +0 -2
- package/dist/chunk-13jg9qpq.js +0 -2
- package/dist/chunk-1e79xcc8.js +0 -2
- package/dist/chunk-1yt4ynxh.js +0 -2
- package/dist/chunk-2whqx2c0.js +0 -2
- package/dist/chunk-2xtzzx00.js +0 -2
- package/dist/chunk-4t9cggwf.js +0 -2
- package/dist/chunk-5g7m27e1.js +0 -21
- package/dist/chunk-5h1ahj7m.js +0 -2
- package/dist/chunk-5zqxzyxk.js +0 -2
- package/dist/chunk-68wezwr7.js +0 -2
- package/dist/chunk-7gw96jpj.js +0 -2
- package/dist/chunk-7w2mrg3s.js +0 -2
- package/dist/chunk-8hhyp9p6.js +0 -2
- package/dist/chunk-926fs6g7.js +0 -2
- package/dist/chunk-93ft5jea.js +0 -3
- package/dist/chunk-94gp1g2f.js +0 -2
- package/dist/chunk-983zpa57.js +0 -3
- package/dist/chunk-98yf0aq9.js +0 -4
- package/dist/chunk-9wq145yr.js +0 -2
- package/dist/chunk-a4r93m1q.js +0 -2
- package/dist/chunk-aea12k73.js +0 -2
- package/dist/chunk-b378jpbp.js +0 -2
- package/dist/chunk-b7e07ybq.js +0 -3
- package/dist/chunk-bfhks7zf.js +0 -43
- package/dist/chunk-bhnq6xr5.js +0 -2
- package/dist/chunk-bksjh409.js +0 -2
- package/dist/chunk-c4sskkv6.js +0 -421
- package/dist/chunk-ca0vn95n.js +0 -18
- package/dist/chunk-cbdyns7r.js +0 -3
- package/dist/chunk-cknbhyw6.js +0 -2
- package/dist/chunk-csx3zne1.js +0 -3
- package/dist/chunk-d7vmzkjy.js +0 -2
- package/dist/chunk-djwat8vn.js +0 -2
- package/dist/chunk-dm7am3p3.js +0 -2
- package/dist/chunk-dpjs0ajs.js +0 -2
- package/dist/chunk-e41h5yrz.js +0 -11
- package/dist/chunk-f498cdg5.js +0 -2
- package/dist/chunk-fazw6sxz.js +0 -2
- package/dist/chunk-ffddd2t8.js +0 -14
- package/dist/chunk-fk71r3h6.js +0 -2
- package/dist/chunk-g1bed7se.js +0 -2
- package/dist/chunk-gbgbhpms.js +0 -2
- package/dist/chunk-h1fpjmr8.js +0 -2
- package/dist/chunk-ha4vb9a6.js +0 -2
- package/dist/chunk-hadbgke6.js +0 -2
- package/dist/chunk-hkmewh5h.js +0 -12
- package/dist/chunk-hmnj2hrh.js +0 -20
- package/dist/chunk-htyee0b7.js +0 -3
- package/dist/chunk-hz5vabap.js +0 -25
- package/dist/chunk-j10dhha2.js +0 -2
- package/dist/chunk-kjc1f6af.js +0 -2
- package/dist/chunk-m28d7w2s.js +0 -54
- package/dist/chunk-mv4wfsc5.js +0 -2
- package/dist/chunk-mwwd425n.js +0 -33
- package/dist/chunk-nbzy9m6a.js +0 -2
- package/dist/chunk-nmcgyxcg.js +0 -2
- package/dist/chunk-p4e7x4f6.js +0 -2
- package/dist/chunk-p6sdrq1y.js +0 -2
- package/dist/chunk-p78v88ng.js +0 -65
- package/dist/chunk-pbtr7w5e.js +0 -2
- package/dist/chunk-q13cp39b.js +0 -42
- package/dist/chunk-qfk2gh5y.js +0 -20
- package/dist/chunk-qqj8n8s9.js +0 -4
- package/dist/chunk-qtr1660m.js +0 -2
- package/dist/chunk-r0nm6sz0.js +0 -2
- package/dist/chunk-rb8g9nnc.js +0 -2
- package/dist/chunk-rhm7wg6p.js +0 -2
- package/dist/chunk-tjf1eajh.js +0 -2
- package/dist/chunk-ttn2hvze.js +0 -24
- package/dist/chunk-w42v5j1j.js +0 -2
- package/dist/chunk-w9kak6aj.js +0 -2
- package/dist/chunk-wr6z8z70.js +0 -2
- package/dist/chunk-xy3p6d2m.js +0 -2
- package/dist/chunk-yfppczrm.js +0 -2
- package/dist/chunk-yhf7pj12.js +0 -2
- package/dist/chunk-ympp4tja.js +0 -2
- package/dist/chunk-yyx89zxs.js +0 -2
- package/dist/chunk-z00ysspf.js +0 -31
- package/dist/chunk-z0x54ynx.js +0 -3
- package/dist/chunk-za6teyn1.js +0 -2
- package/dist/chunk-zgyw04pj.js +0 -2
- package/dist/chunk-zmnqha0x.js +0 -2
- package/dist/chunk-zw924mfr.js +0 -2
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{S}from"./chunk-kqdzjgm6.js";import{i}from"./chunk-cam9je83.js";import p from"fs";import g from"path";import*as y from"readline";var e={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},u={help:{description:"Show available commands",usage:"help [command]",handler:async(t,o)=>{if(t[0]&&u[t[0]]){let n=u[t[0]];console.log(`
|
|
3
|
+
${e.bold}${t[0]}${e.reset} - ${n.description}`),console.log(` Usage: ${e.cyan}${n.usage}${e.reset}
|
|
4
|
+
`)}else{console.log(`
|
|
5
|
+
${e.bold}Available Commands:${e.reset}
|
|
6
|
+
`);for(let[n,r]of Object.entries(u))console.log(` ${e.cyan}${n.padEnd(12)}${e.reset} ${r.description}`);console.log(`
|
|
7
|
+
${e.dim}Type 'help <command>' for more details${e.reset}
|
|
8
|
+
`)}}},render:{description:"Render a template file",usage:"render <file> [--raw]",handler:async(t,o)=>{if(!t[0]){console.log(`${e.red}Error: Please specify a file to render${e.reset}`);return}let n=g.resolve(o.cwd,t[0]);if(!await Bun.file(n).exists()){console.log(`${e.red}Error: File not found: ${n}${e.reset}`);return}try{let r=await Bun.file(n).text(),s=t.includes("--raw");console.log(`
|
|
9
|
+
${e.dim}Rendering ${n}...${e.reset}
|
|
10
|
+
`);let l=await i(r,o.context,n,{},new Set);if(o.lastResult=l,s)console.log(l);else l.split(`
|
|
11
|
+
`).forEach((d,c)=>{let f=String(c+1).padStart(3," ");console.log(`${e.dim}${f}${e.reset} ${d}`)});console.log()}catch(r){console.log(`${e.red}Error rendering template:${e.reset}`,r)}}},eval:{description:"Evaluate an expression",usage:"eval <expression>",handler:async(t,o)=>{if(!t.length){console.log(`${e.red}Error: Please provide an expression to evaluate${e.reset}`);return}let n=t.join(" ");try{let r=`{{ ${n} }}`,l=(await S(r,o.context,"eval")).trim();o.lastResult=l,console.log(`${e.green}\u2192${e.reset} ${l}`)}catch(r){console.log(`${e.red}Error:${e.reset}`,r)}}},set:{description:"Set a context variable",usage:"set <key> <value>",handler:async(t,o)=>{if(t.length<2){console.log(`${e.red}Error: Usage: set <key> <value>${e.reset}`);return}let n=t[0],r=t.slice(1).join(" "),s;try{s=JSON.parse(r)}catch{s=r}o.context[n]=s,console.log(`${e.green}\u2713${e.reset} ${n} = ${JSON.stringify(s)}`)}},unset:{description:"Remove a context variable",usage:"unset <key>",handler:async(t,o)=>{if(!t[0]){console.log(`${e.red}Error: Please specify a variable to remove${e.reset}`);return}if(t[0]in o.context)delete o.context[t[0]],console.log(`${e.green}\u2713${e.reset} Removed ${t[0]}`);else console.log(`${e.yellow}Variable not found: ${t[0]}${e.reset}`)}},context:{description:"Show current context variables",usage:"context",handler:async(t,o)=>{let n=Object.keys(o.context);if(n.length===0){console.log(`${e.dim}Context is empty${e.reset}`);return}console.log(`
|
|
12
|
+
${e.bold}Context Variables:${e.reset}
|
|
13
|
+
`);for(let r of n){let s=o.context[r],l=Array.isArray(s)?"array":typeof s,a=JSON.stringify(s).slice(0,50);console.log(` ${e.cyan}${r}${e.reset} ${e.dim}(${l})${e.reset}: ${a}${a.length>=50?"...":""}`)}console.log()}},clear:{description:"Clear context or screen",usage:"clear [context|screen]",handler:async(t,o)=>{if(t[0]==="context"||!t[0])o.context={},console.log(`${e.green}\u2713${e.reset} Context cleared`);if(t[0]==="screen"||!t[0])console.clear()}},cd:{description:"Change working directory",usage:"cd <directory>",handler:async(t,o)=>{if(!t[0]){console.log(`${e.cyan}${o.cwd}${e.reset}`);return}let n=g.resolve(o.cwd,t[0]);if(!p.existsSync(n)){console.log(`${e.red}Error: Directory not found: ${n}${e.reset}`);return}if(!p.statSync(n).isDirectory()){console.log(`${e.red}Error: Not a directory: ${n}${e.reset}`);return}o.cwd=n,console.log(`${e.green}\u2713${e.reset} ${n}`)}},ls:{description:"List files in current directory",usage:"ls [pattern]",handler:async(t,o)=>{let n=t[0]||"*",r=new Bun.Glob(n),s=[];for await(let c of r.scan({cwd:o.cwd,onlyFiles:!1}))s.push(c);if(s.length===0){console.log(`${e.dim}No files found${e.reset}`);return}s.sort();let l=s.filter((c)=>c.endsWith(".stx")),a=s.filter((c)=>c.endsWith(".md")),d=s.filter((c)=>!c.endsWith(".stx")&&!c.endsWith(".md"));if(l.length>0)console.log(`
|
|
14
|
+
${e.bold}Templates:${e.reset}`),l.forEach((c)=>console.log(` ${e.green}${c}${e.reset}`));if(a.length>0)console.log(`
|
|
15
|
+
${e.bold}Markdown:${e.reset}`),a.forEach((c)=>console.log(` ${e.blue}${c}${e.reset}`));if(d.length>0)console.log(`
|
|
16
|
+
${e.bold}Other:${e.reset}`),d.forEach((c)=>console.log(` ${e.dim}${c}${e.reset}`));console.log()}},cat:{description:"Show file contents",usage:"cat <file>",handler:async(t,o)=>{if(!t[0]){console.log(`${e.red}Error: Please specify a file${e.reset}`);return}let n=g.resolve(o.cwd,t[0]);if(!await Bun.file(n).exists()){console.log(`${e.red}Error: File not found: ${n}${e.reset}`);return}let s=(await Bun.file(n).text()).split(`
|
|
17
|
+
`);console.log(),s.forEach((l,a)=>{let d=String(a+1).padStart(3," ");console.log(`${e.dim}${d}${e.reset} ${l}`)}),console.log()}},load:{description:"Load context from JSON file",usage:"load <file.json>",handler:async(t,o)=>{if(!t[0]){console.log(`${e.red}Error: Please specify a JSON file${e.reset}`);return}let n=g.resolve(o.cwd,t[0]);if(!await Bun.file(n).exists()){console.log(`${e.red}Error: File not found: ${n}${e.reset}`);return}try{let r=await Bun.file(n).text(),s=JSON.parse(r);o.context={...o.context,...s},console.log(`${e.green}\u2713${e.reset} Loaded ${Object.keys(s).length} variables from ${t[0]}`)}catch(r){console.log(`${e.red}Error parsing JSON:${e.reset}`,r)}}},save:{description:"Save context to JSON file",usage:"save <file.json>",handler:async(t,o)=>{if(!t[0]){console.log(`${e.red}Error: Please specify a file name${e.reset}`);return}let n=g.resolve(o.cwd,t[0]);try{await Bun.write(n,JSON.stringify(o.context,null,2)),console.log(`${e.green}\u2713${e.reset} Context saved to ${t[0]}`)}catch(r){console.log(`${e.red}Error saving file:${e.reset}`,r)}}},history:{description:"Show command history",usage:"history [count]",handler:async(t,o)=>{let n=t[0]?Number.parseInt(t[0],10):20,r=o.history.slice(-n);if(r.length===0){console.log(`${e.dim}No history${e.reset}`);return}console.log(),r.forEach((s,l)=>{let a=String(o.history.length-r.length+l+1).padStart(3," ");console.log(`${e.dim}${a}${e.reset} ${s}`)}),console.log()}},exit:{description:"Exit interactive mode",usage:"exit",handler:async(t,o)=>{o.running=!1,console.log(`
|
|
18
|
+
${e.dim}Goodbye!${e.reset}
|
|
19
|
+
`)}},quit:{description:"Exit interactive mode (alias for exit)",usage:"quit",handler:async(t,o)=>u.exit.handler(t,o)}};function h(t,o){let n=t.split(" "),r=n[0];if(n.length===1)return Object.keys(u).filter((s)=>s.startsWith(r));if(["render","cat","load","cd"].includes(r)){let s=n.slice(1).join(" "),l=g.dirname(s)||".",a=g.basename(s),d=g.resolve(o.cwd,l);if(p.existsSync(d)&&p.statSync(d).isDirectory())try{return p.readdirSync(d).filter((f)=>f.startsWith(a)).map((f)=>`${r} ${l==="."?"":`${l}/`}${f}`)}catch{return[]}}if(["unset","eval","set"].includes(r)){let s=n[1]||"";return Object.keys(o.context).filter((l)=>l.startsWith(s)).map((l)=>`${r} ${l}`)}return[]}async function bg(t={}){let o={context:t.context||{},cwd:t.cwd||process.cwd(),history:[],running:!0,lastResult:null},n=y.createInterface({input:process.stdin,output:process.stdout,completer:(s)=>[h(s,o),s],historySize:t.maxHistory||100});console.log(`
|
|
20
|
+
${e.bold}${e.blue}stx Interactive Mode${e.reset}
|
|
21
|
+
${e.dim}Type 'help' for available commands, 'exit' to quit${e.reset}
|
|
22
|
+
`);let r=()=>{let s=o.cwd.replace(process.env.HOME||"","~");n.question(`${e.cyan}stx${e.reset} ${e.dim}${s}${e.reset} ${e.green}>${e.reset} `,async(l)=>{let a=l.trim();if(!a){if(o.running)r();return}o.history.push(a);let d=a.match(/(?:[^\s"]|"[^"]*")+/g)||[],c=d[0]?.toLowerCase(),f=d.slice(1).map((m)=>m.replace(/^"|"$/g,""));if(c&&u[c])try{await u[c].handler(f,o)}catch(m){console.log(`${e.red}Error:${e.reset}`,m)}else if(c)if(a.includes("{{")||a.includes("}}"))try{let m=await S(a,o.context,"eval");console.log(`${e.green}\u2192${e.reset} ${m}`)}catch{console.log(`${e.red}Unknown command: ${c}${e.reset}`),console.log(`${e.dim}Type 'help' for available commands${e.reset}`)}else console.log(`${e.red}Unknown command: ${c}${e.reset}`),console.log(`${e.dim}Type 'help' for available commands${e.reset}`);if(o.running)r();else n.close()})};n.on("SIGINT",()=>{console.log(`
|
|
23
|
+
${e.dim}(Use 'exit' to quit)${e.reset}`),r()}),r()}
|
|
24
|
+
export{bg};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
function o(t,i){let n=t[i],e=i+1;while(e<t.length){if(t[e]==="\\"){e+=2;continue}if(t[e]===n)return e+1;e++}return t.length}function b(t,i){let n=i+1;while(n<t.length){if(t[n]==="\\"){n+=2;continue}if(t[n]==="`")return n+1;if(t[n]==="$"&&t[n+1]==="{"){if(n=Lc(t,n+2),n<t.length)n++;continue}n++}return t.length}function Lc(t,i){let n=1,e=i,r="{",f="";while(e<t.length){let l=t[e];if(l==="\\"){e+=2;continue}if(l==='"'||l==="'"){e=o(t,e),r=h,f="";continue}if(l==="`"){e=b(t,e),r=h,f="";continue}if(l==="/"&&t[e+1]==="/"){while(e<t.length&&t[e]!==`
|
|
3
|
+
`)e++;continue}if(l==="/"&&t[e+1]==="*"){e+=2;while(e<t.length&&t.slice(e,e+2)!=="*/")e++;e+=2;continue}if(l==="/"&&a(r,f)){let u=w(t,e);if(u!==-1){e=u,r=h,f="";continue}}if(l==="{")n++;else if(l==="}"){if(n--,n===0)return e}if(/[\w$]/.test(l))f=/[\w$]/.test(r)?f+l:l,r=l;else if(!/\s/.test(l))r=l,f="";e++}return t.length}var m=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]);function a(t,i){if(i)return m.has(i);return!(t===")"||t==="]"||t===h)}var h="\x00";function w(t,i){let n=i+1,e=!1;while(n<t.length){let r=t[n];if(r===`
|
|
4
|
+
`)return-1;if(r==="\\"){n+=2;continue}if(r==="[")e=!0;else if(r==="]")e=!1;else if(r==="/"&&!e){n++;while(n<t.length&&/[a-z]/i.test(t[n]))n++;return n}n++}return-1}function s(t){let i="",n=0,e="",r="";while(n<t.length){let f=t.slice(n,n+2);if(f==="//"){while(n<t.length&&t[n]!==`
|
|
5
|
+
`)i+=" ",n++;continue}if(f==="/*"){while(n<t.length&&t.slice(n,n+2)!=="*/")i+=t[n]===`
|
|
6
|
+
`?`
|
|
7
|
+
`:" ",n++;i+=" ",n+=2;continue}let l=t[n];if(l==='"'||l==="'"){let u=l;i+=" ",n++;while(n<t.length&&t[n]!==u){if(t[n]==="\\"){i+=" ",n+=2;continue}i+=t[n]===`
|
|
8
|
+
`?`
|
|
9
|
+
`:" ",n++}i+=" ",n++,e=h,r="";continue}if(l==="/"&&a(e,r)){let u=w(t,n);if(u!==-1){i+=`/${" ".repeat(u-n-2)}/`,n=u,e=h,r="";continue}}if(l==="`"){i+=" ",n++;while(n<t.length&&t[n]!=="`"){if(t[n]==="\\"){i+=" ",n+=2;continue}if(t[n]==="$"&&t[n+1]==="{"){let u=n+2,g=Lc(t,u);if(i+=" ",i+=s(t.slice(u,g)),g<t.length)i+=" ";n=g+1;continue}i+=t[n]===`
|
|
10
|
+
`?`
|
|
11
|
+
`:" ",n++}i+=" ",n++,e=h,r="";continue}if(i+=l,n++,/[\w$]/.test(l))r=/[\w$]/.test(e)?r+l:l,e=l;else if(!/\s/.test(l))e=l,r=""}return i}function ge(t){let i=new Uint16Array(t.length),n=0,e=!0;for(let r=0;r<t.length;r++){let f=t[r];if(f===")"||f==="]"||f==="}")if(n===0)e=!1;else n--;if(i[r]=n,f==="("||f==="["||f==="{")n++}return{depths:i,balanced:e&&n===0}}
|
|
12
|
+
export{Lc,s,ge};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{bg}from"./chunk-vjyrwvz0.js";import"./chunk-cam9je83.js";import"./chunk-cm8m2ygc.js";import"./chunk-ap30qs8p.js";import"./chunk-eqz0g5c5.js";import"./chunk-3hhcea1p.js";import"./chunk-pgjqx3kg.js";import"./chunk-d22sgyg2.js";import"./chunk-7dc3n69c.js";import"./chunk-pfjsyvmj.js";import"./chunk-7ppbv5bc.js";import"./chunk-8v2vbc4y.js";import"./chunk-dzkg6cy5.js";import"./chunk-59g266vc.js";import"./chunk-j9mpwt71.js";import"./chunk-stvw8y3c.js";import"./chunk-zjw6j2x0.js";import"./chunk-3t3p2c1t.js";import"./chunk-0myrwz84.js";import"./chunk-kqdzjgm6.js";import"./chunk-1f4e06c2.js";import"./chunk-wp6q0geg.js";import"./chunk-xyyt8v1r.js";import"./chunk-zn3c0ew5.js";import"./chunk-zdpd29xd.js";export{bg as startInteractive};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{s}from"./chunk-vstvadc2.js";function y(e,n,i=240){return e.slice(n,n+i)}var v=[{rule:"route-params",pattern:/\blocation\s*\.\s*pathname\s*\.\s*(?:match|split)\s*\(/g,primitive:"useRoute() / useRouteParams() / useRouteParam(name)",why:"parsing the URL by hand re-implements the router and does not update on SPA navigation"},{rule:"alert",pattern:/(?<![.#\w$])(?:(?:window|globalThis)\s*\.\s*)?alert\s*\(/g,primitive:"stxAlert(message)",why:"themed, focus-trapped and non-blocking \u2014 but `await` it if the code after it "+"depended on the native dialog blocking until dismissal",reject:(e)=>/\b(?:async\s+)?function\s+alert\s*\(/.test(e)||/\b(?:const|let|var)\s+alert\s*=/.test(e)},{rule:"search-params",pattern:/new\s+URLSearchParams\s*\(/g,primitive:"useSearchParams()",why:"reactive, and writes back through the router instead of history.replaceState",reject:(e,n)=>{let i=e.indexOf("(",n);if(i===-1)return!0;let o=e.slice(i+1,e.indexOf(")",i)+1);return!/\b(?:location|search|href|url)\b/i.test(o)}},{rule:"navigate",pattern:/\blocation\s*\.\s*(?:assign|replace)\s*\(|\blocation\s*\.\s*href\s*=/g,primitive:"navigate(path) / goBack()",why:"a full document load throws away every store and the scroll position; navigate() is an SPA transition",reject:(e,n)=>/^[^\n]*?(?:['"`]\s*)?(?:mailto:|tel:|sms:|https?:\/\/|\/\/)/.test(y(e,n,160))},{rule:"fetch",pattern:/new\s+AbortController\s*\(/g,primitive:"useFetch(url) / useAsyncData(key, fn)",why:"cancellation, loading and error state are already wired; hand-rolling them is where the races live"},{rule:"polling",pattern:/setInterval\s*\(/g,primitive:"useEventSource() / useSSE() / useWebSocket() / useChannel()",why:"polling burns requests and lags; the push primitives are delivered",reject:(e,n)=>!/\bfetch\s*\(|\$fetch\b|useFetch\b|\.get\s*\(|axios\b/.test(y(e,n))},{rule:"debounce",pattern:/\bclearTimeout\s*\(/g,primitive:"useDebounce(fn, ms) / useThrottle(fn, ms)",why:"a hand-held timer handle per call site is the usual source of stale-result bugs",requires:(e)=>/setTimeout\s*\(/.test(e)},{rule:"click-outside",pattern:/document\s*\.\s*addEventListener\s*\(\s*['"](?:click|mousedown|pointerdown)['"]/g,primitive:"useClickOutside(ref, fn)",why:"the document-level listener plus the blur race is exactly what this composable exists to remove"},{rule:"focus",pattern:/\.\s*(?:getElementById|querySelector)\s*\([^)]*\)\s*(?:\?\.)?\s*\.?focus\s*\(/g,primitive:"useFocus(ref) with x-ref",why:"a query by id breaks under nested scopes and SPA navigation; a ref does not"},{rule:"clipboard",pattern:/navigator\s*\.\s*(?:clipboard|share)\b/g,primitive:"useClipboard() / useShare()",why:"permission state, the copied flag and the unsupported-browser fallback are already handled"},{rule:"watch",pattern:/\beffect\s*\(\s*\(\s*\)\s*=>\s*\{[^}]*\bvoid\s+\w+\s*\(\s*\)/g,primitive:"watch(source, cb) / watchMultiple([...], cb)",why:"the `void a(); void b()` dance is a manual dependency list; watch takes one directly"}],C=["confirm","tooltip",...v.map((e)=>e.rule)];function g(e,n){let i=1;for(let o=0;o<n;o++)if(e[o]===`
|
|
3
3
|
`)i++;return i}function b(e,n){let i=e.lastIndexOf(`
|
|
4
4
|
`,n)+1,o=e.indexOf(`
|
|
5
|
-
`,n);return e.slice(i,o===-1?e.length:o).trim().slice(0,120)}function S(e,n){let i=e.slice(0,n),o=i.lastIndexOf("function"),l=i.lastIndexOf("=>"),
|
|
6
|
-
${t.reason}`)}if(l.length>0){
|
|
7
|
-
use ${t.reason}`)}return
|
|
5
|
+
`,n);return e.slice(i,o===-1?e.length:o).trim().slice(0,120)}function S(e,n){let i=e.slice(0,n),o=i.lastIndexOf("function"),l=i.lastIndexOf("=>"),r=Math.max(o,l);if(r===-1)return!1;let t=e.slice(Math.max(0,r-120),r);return/\basync\b[^;{}]*$/.test(t)}function k(e){return/\b(?:async\s+)?function\s+confirm\s*\(/.test(e)||/\b(?:const|let|var)\s+confirm\s*=/.test(e)||/\bimport\s*\{[^}]*\bconfirm\b[^}]*\}/.test(e)}function A(e,n,i){if(k(e))return e;let o=/(^|[^\w$.])(?:(?:window|globalThis)\s*\.\s*)?confirm\s*\(/g,l=m(e),r="",t=0,a;while((a=o.exec(l))!==null){let c=a.index+a[1].length,u=g(e,c),d=b(e,c);if(/stxConfirm\s*\($/.test(e.slice(0,c+8)))continue;let p=S(e,c);if(i.push({file:n,line:u,rule:"confirm",applied:p,snippet:d,reason:p?void 0:"stxConfirm() returns a Promise and native confirm() is synchronous, so this needs `await` inside an async function. Rewriting it here would make the condition always true."}),p)r+=e.slice(t,c)+"await stxConfirm(",t=c+(a[0].length-a[1].length)}return r+e.slice(t)}function E(e,n,i){let o=/(<[a-z][\w-]*\b[^>]*?)\stitle=(["'])(.*?)\2/gis,l=R(e),r="",t=0,a;while((a=o.exec(l))!==null){let[c,u,d,p]=a,h=g(e,a.index),f=b(e,a.index),w=u.match(/^<([A-Za-z][\w-]*)/)?.[1]??"";if(/^[A-Z]/.test(w)){i.push({file:n,line:h,rule:"tooltip",applied:!1,snippet:f,reason:`\`title\` on <${w}> is a component prop, not an HTML attribute \u2014 `+"adding x-tooltip here would put a tooltip on a component and may duplicate text it already renders."});continue}if(/\bx-tooltip[=\s]/.test(u)||p.trim()===""){i.push({file:n,line:h,rule:"tooltip",applied:!1,snippet:f,reason:/\bx-tooltip[=\s]/.test(u)?"already has x-tooltip":"empty title"});continue}i.push({file:n,line:h,rule:"tooltip",applied:!0,snippet:f}),r+=e.slice(t,a.index)+`${u} x-tooltip=${d}${p}${d} title=${d}${p}${d}`,t=a.index+c.length}return r+e.slice(t)}function R(e){return e.replace(/<!--[\s\S]*?-->/g,(n)=>n.replace(/[^\n]/g," ")).replace(/\{\{--[\s\S]*?--\}\}/g,(n)=>n.replace(/[^\n]/g," "))}function F(e){let n=(i)=>i.replace(/[^\n]/g," ");return e.replace(/\/\*[\s\S]*?\*\//g,n).replace(/\/\/[^\n]*/g,n)}function m(e,n=!1){let i=R(e);return(n?F(i):s(i)).replace(/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi,(l,r)=>/\bclient\b/i.test(r)?l:l.replace(/[^\n]/g," "))}function O(e,n,i,o){let l=m(e),r=m(e,!0);for(let t of v){if(!i.includes(t.rule))continue;if(t.requires&&!t.requires(e))continue;t.pattern.lastIndex=0;let a,c=/['"]/.test(t.pattern.source)?r:l;t.pattern.lastIndex=0;while((a=t.pattern.exec(c))!==null){if(t.reject?.(e,a.index))continue;o.push({file:n,line:g(e,a.index),rule:t.rule,applied:!1,snippet:b(e,a.index),reason:`${t.primitive} \u2014 ${t.why}`})}}}function q(e,n={}){let i=n.rules??C,o=n.file??"<source>",l=[];O(e,o,i,l);let r=e;if(i.includes("confirm"))r=A(r,o,l);if(i.includes("tooltip"))r=E(r,o,l);l.sort((c,u)=>c.line-u.line);let t=new Set,a=l.filter((c)=>{let u=`${c.rule}:${c.line}`;if(t.has(u))return!1;return t.add(u),!0});return{code:r,findings:a}}var x=new Set(["confirm","tooltip"]);function I(e,n){if(e.length===0)return"No hand-rolled equivalents found.";let i=e.filter((t)=>t.applied),o=e.filter((t)=>!t.applied&&x.has(t.rule)),l=e.filter((t)=>!t.applied&&!x.has(t.rule)),r=[];if(i.length>0){r.push(n?`Rewrote ${i.length} site(s):`:`Would rewrite ${i.length} site(s) (pass --fix):`);for(let t of i)r.push(` ${t.file}:${t.line} [${t.rule}] ${t.snippet}`)}if(o.length>0){r.push("",`Needs a human \u2014 ${o.length} site(s):`);for(let t of o)r.push(` ${t.file}:${t.line} [${t.rule}] ${t.snippet}
|
|
6
|
+
${t.reason}`)}if(l.length>0){r.push("",`An stx primitive already covers this \u2014 ${l.length} site(s):`);for(let t of l)r.push(` ${t.file}:${t.line} [${t.rule}] ${t.snippet}
|
|
7
|
+
use ${t.reason}`)}return r.join(`
|
|
8
8
|
`)}export{q as codemodSource,I as formatCodemodFindings};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{m,h,p}from"./chunk-kqdzjgm6.js";import{L}from"./chunk-59g266vc.js";import{i}from"./chunk-cam9je83.js";import k from"path";var q={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var M=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function H(e){let t=[],o=0,n;M.lastIndex=0;while((n=M.exec(e))!==null){if(n.index>o){let a=e.slice(o,n.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let s=n[1],r=n[2];t.push({type:"suspense",name:s,content:r}),o=n.index+n[0].length}if(o<e.length){let s=e.slice(o);if(s.trim())t.push({type:t.length===0?"shell":"content",content:s})}if(t.length===0)t.push({type:"shell",content:e});return t}async function Kg(e,t={},o={}){let n={...L,...o,streaming:{...q,...o.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),g=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y={...t,__filename:e,__dirname:k.dirname(e)};if(g.trim())await m(g,y,e);let E=H(c),l=new Set;if(!E.some((w)=>w.type==="suspense")){let w=n.streaming?.strategy||"auto",x=new RegExp(T.source,"g");if(!(w!=="manual"&&x.test(c))){let u=await i(c,y,e,n,l);for(let b=0;b<u.length;b+=s)r.enqueue(u.slice(b,b+s)),await new Promise((f)=>setTimeout(f,0))}else{let u=[],b=new RegExp(T.source,"g"),f;while((f=b.exec(c))!==null)u.push({name:f[1],content:f[2],start:f.index,end:f.index+f[0].length});let v=0;for(let _ of u){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let O=await i(I,y,e,n,l);r.enqueue(O),await new Promise((D)=>setTimeout(D,0))}}let C=await i(_.content,y,e,n,l);r.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await i(_,y,e,n,l);r.enqueue(C)}}}}else{let w=new Map;for(let d of E)if(d.type==="shell"||d.type==="content"){let u=await i(d.content,y,e,n,l);r.enqueue(u)}else if(d.type==="suspense"&&d.name){let u=`stx-suspense-${d.name}`;r.enqueue(`<div id="${u}" data-suspense="${d.name}" style="display:contents;">
|
|
3
3
|
<template data-suspense-fallback>Loading...</template>
|
|
4
|
-
</div>`),w.set(
|
|
4
|
+
</div>`),w.set(d.name,i(d.content,y,e,n,l))}r.enqueue(`
|
|
5
5
|
<script>
|
|
6
6
|
(function() {
|
|
7
7
|
window.__stxSuspense = window.__stxSuspense || {
|
|
@@ -17,13 +17,13 @@ import{g,m,d}from"./chunk-c4sskkv6.js";import{N}from"./chunk-9p452mq6.js";import
|
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
})();
|
|
20
|
-
</script>`);let x=Array.from(w.entries()).map(async([
|
|
20
|
+
</script>`);let x=Array.from(w.entries()).map(async([d,u])=>{r.enqueue(await ra(d,u))});await Promise.all(x)}r.close()}catch(a){r.error(a)}}})}async function ra(e,t){try{let n=(await t).replace(/`/g,"\\`").replace(/<\/script>/gi,"<\\/script>");return`
|
|
21
21
|
<script>
|
|
22
22
|
window.__stxSuspense.resolve('${e}', \`${n}\`);
|
|
23
|
-
</script>`}catch(
|
|
23
|
+
</script>`}catch(o){let n=o instanceof Error?o.message:String(o);return`
|
|
24
24
|
<script>
|
|
25
|
-
window.__stxSuspense.resolve('${e}', '<div class="stx-error">Error loading content: ${
|
|
26
|
-
</script>`}}var
|
|
25
|
+
window.__stxSuspense.resolve('${e}', '<div class="stx-error">Error loading content: ${p(n)}</div>');
|
|
26
|
+
</script>`}}var ql=`
|
|
27
27
|
<script>
|
|
28
28
|
(function(){
|
|
29
29
|
window.__stxSuspense = window.__stxSuspense || {
|
|
@@ -43,12 +43,12 @@ window.__stxSuspense.resolve('${e}', '<div class="stx-error">Error loading conte
|
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
45
|
})();
|
|
46
|
-
</script>`;function z(e,t,
|
|
46
|
+
</script>`;function z(e,t,o){if(!t||t<=0)return e;let n,s=new Promise((r,a)=>{n=setTimeout(()=>a(Error(`streaming boundary "${o}" timed out after ${t}ms`)),t)});return Promise.race([e,s]).finally(()=>clearTimeout(n))}function Xg(e,t=[],o={}){let n=o.timeoutMs??0;return new ReadableStream({async start(s){try{if(s.enqueue(e),t.length>0)s.enqueue(ql),await Promise.all(t.map(async(r)=>{let a=z(r.render(),n,r.id);s.enqueue(await ra(r.id,a))}));s.close()}catch(r){s.error(r)}}})}var A=/@stream\s*\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)@endstream/gi;function Jg(e,t){return e.replace(A,(o,n,s)=>{let r=n.trim(),a=s.split(/@fallback/i),S=a[0].trim(),g=a.length>1?a.slice(1).join("@fallback").trim():"";if(!t.__streamTemplates)t.__streamTemplates={};return t.__streamTemplates[r]=S,`<div data-suspense="${r}">${g}</div>`})}function Yg(e){let t=e?.streamBoundaries;if(!t||typeof t!=="object")return;let o=Object.entries(t).filter(([,n])=>typeof n==="function");return o.length>0?o.map(([n,s])=>({id:n,render:s})):void 0}async function Zg(e,t={},o={}){let n={...L,...o,streaming:{...q,...o.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),g=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y={...t,__filename:e,__dirname:k.dirname(e)};if(g.trim())await m(g,y,e);let E=new Set,l=n.streaming?.strategy||"auto",R=new RegExp(T.source,"g");if(!(l!=="manual"&&R.test(c))){let x=await i(c,y,e,n,E);for(let d=0;d<x.length;d+=s)r.enqueue(x.slice(d,d+s))}else{let x=[],d=new RegExp(T.source,"g"),u;while((u=d.exec(c))!==null)x.push({name:u[1],content:u[2],start:u.index,end:u.index+u[0].length});let b=0;for(let f of x){if(f.start>b){let _=c.slice(b,f.start);if(_.trim()){let C=await i(_,y,e,n,E);r.enqueue(C)}}let v=await i(f.content,y,e,n,E);r.enqueue(v),b=f.end}if(b<c.length){let f=c.slice(b);if(f.trim()){let v=await i(f,y,e,n,E);r.enqueue(v)}}}r.close()}catch(a){r.error(a)}}})}async function Qg(e,t={}){let o={...L,...t,streaming:{...q,...t.streaming}},n=await Bun.file(e).text(),s=n.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),r=s?s[1]:"",a=n.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),S=a,g={},c;T.lastIndex=0;while((c=T.exec(a))!==null){let l=c[1],R=c[2];g[l]=R}let y=a.replace(T,"");return{renderShell:async(l={})=>{let R={...l,__filename:e,__dirname:k.dirname(e)};return await m(r,R,e),i(y,R,e,o,new Set)},renderSection:async(l,R={})=>{try{if(!g[l])return`<div class="error-message">Section "${p(l)}" not found in template "${p(e)}"</div>`;let w={...R,__filename:e,__dirname:k.dirname(e)};await m(r,w,e);let x=new Set;return await i(g[l],w,e,o,x)}catch(w){let x=w instanceof Error?w.message:String(w);return h("Expression",x,e,g[l]||"",0,g[l]||"")}},getSections:()=>Object.keys(g),getTemplate:()=>S}}var Gl={name:"suspense",hasEndTag:!0,handler:(e,t,o,n)=>{if(!t||t.length===0)throw Error("Suspense directive requires a name parameter");let s=t[0].replace(/['"`]/g,"");return`<!-- @suspense:${s} -->${e}<!-- @endsuspense:${s} -->`}},Kl={name:"island",hasEndTag:!0,handler:(e,t,o,n)=>{if(!t||t.length===0)throw Error("Island directive requires a name parameter");let s=t[0].replace(/['"`]/g,""),r=t[1]?t[1].replace(/['"`]/g,""):"lazy",a=`island-${s}-${Math.random().toString(36).substring(2,9)}`,S=e.match(/<script\s+props\s*>([\s\S]*?)<\/script>/i),g=S?S[1].trim():"",c=S?e.replace(S[0],""):e;return`<div data-island="${s}" data-island-id="${a}" data-priority="${r}">
|
|
47
47
|
${c}
|
|
48
48
|
<script type="application/json" data-island-props="${a}">
|
|
49
|
-
${
|
|
49
|
+
${g?`{${g}}`:"{}"}
|
|
50
50
|
</script>
|
|
51
|
-
</div>`}};function
|
|
51
|
+
</div>`}};function em(e={}){let t=[];if(e.streaming?.enabled)t.push(Gl);if(e.hydration?.enabled)t.push(Kl);return t}async function tm(e,t,o,n={}){return e}function nm(e,t={}){let o=new TextEncoder,n=e.pipeThrough(new TransformStream({transform(r,a){a.enqueue(o.encode(r))}})),s=new Headers(t.headers);if(!s.has("Content-Type"))s.set("Content-Type","text/html; charset=utf-8");if(!s.has("Transfer-Encoding"))s.set("Transfer-Encoding","chunked");if(!s.has("X-Content-Type-Options"))s.set("X-Content-Type-Options","nosniff");if(!s.has("X-Accel-Buffering"))s.set("X-Accel-Buffering","no");return new Response(n,{...t,headers:s})}function rm(e={mode:"full"}){let{mode:t,components:o={},dynamicImports:n=!0}=e,s=Object.entries(o).map(([r,a])=>`'${r}': ${n?`() => import('${a}')`:`require('${a}')`}`).join(`,
|
|
52
52
|
`);if(t==="loader")return`
|
|
53
53
|
(function() {
|
|
54
54
|
window.__stx = window.__stx || {};
|
|
@@ -191,4 +191,4 @@ else {
|
|
|
191
191
|
stx.hydrate();
|
|
192
192
|
}
|
|
193
193
|
})();`}
|
|
194
|
-
export{
|
|
194
|
+
export{Kg,ra,ql,Xg,Jg,Yg,Zg,Qg,Gl,Kl,em,tm,nm,rm};
|