@stacksjs/stx 0.2.672 → 0.2.674
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/chunk-0jwdcqj8.js +2 -0
- package/dist/chunk-0mwdq478.js +2 -0
- package/dist/{chunk-npa7gze7.js → chunk-0nfqgv4n.js} +2 -2
- package/dist/chunk-1y6egkty.js +2 -0
- package/dist/{chunk-1sr6c0nk.js → chunk-25zmy8q6.js} +2 -2
- package/dist/chunk-2881tcqt.js +2 -0
- package/dist/chunk-2a775q7x.js +2 -0
- package/dist/chunk-2asdbd5e.js +2 -0
- package/dist/chunk-34yj93hh.js +2 -0
- package/dist/{chunk-30nes8ne.js → chunk-35ezh7de.js} +2 -2
- package/dist/{chunk-sjcqxfq1.js → chunk-40tswfe7.js} +8 -8
- package/dist/chunk-41de209e.js +2 -0
- package/dist/{chunk-6xe8rnfv.js → chunk-4b9s7wgy.js} +2 -2
- package/dist/{chunk-ttbn287w.js → chunk-4bgjrrvz.js} +1 -1
- package/dist/{chunk-365vg0eg.js → chunk-4s8zacxg.js} +4 -4
- package/dist/chunk-4w6baw62.js +3 -0
- package/dist/{chunk-fbtv2k1p.js → chunk-506mv7hb.js} +2 -2
- package/dist/{chunk-fzqj1mjz.js → chunk-5qtthtg3.js} +7 -7
- package/dist/chunk-5s1ay9mv.js +2 -0
- package/dist/{chunk-kenbxxbn.js → chunk-5vt48yce.js} +6 -6
- package/dist/{chunk-qv6axke4.js → chunk-5zhp87wv.js} +2 -2
- package/dist/{chunk-hvf2e7pr.js → chunk-6s7tvmqp.js} +1 -1
- package/dist/{chunk-ecqrkyg8.js → chunk-6sjtyd0k.js} +4 -4
- package/dist/{chunk-a3d0g4mr.js → chunk-7adznted.js} +2 -2
- package/dist/chunk-7j1zgrnf.js +42 -0
- package/dist/chunk-7kznee1g.js +2 -0
- package/dist/{chunk-qjtpxsyx.js → chunk-7mvz972c.js} +3 -3
- package/dist/chunk-80zgyaqe.js +2 -0
- package/dist/chunk-84tqb1rn.js +2 -0
- package/dist/chunk-8azm7nha.js +2 -0
- package/dist/chunk-902qnyg0.js +2 -0
- package/dist/{chunk-3y41efsf.js → chunk-9dtbvjpp.js} +8 -8
- package/dist/chunk-9n6jwcpb.js +2 -0
- package/dist/{chunk-yfvm7q6t.js → chunk-a4p18ybc.js} +3 -3
- package/dist/chunk-a6y8td0d.js +2 -0
- package/dist/chunk-a7kt1ts4.js +2 -0
- package/dist/chunk-a81y8g40.js +2 -0
- package/dist/{chunk-mjm3tyfj.js → chunk-aet1pgw7.js} +36 -36
- package/dist/chunk-aft1zc84.js +2 -0
- package/dist/{chunk-04kg16qs.js → chunk-am2w363p.js} +4 -4
- package/dist/{chunk-ym41ybz2.js → chunk-asezs2n3.js} +6 -6
- package/dist/{chunk-7kk2m44a.js → chunk-bawq4fqy.js} +4 -4
- package/dist/chunk-bdp2r0v4.js +2 -0
- package/dist/{chunk-1mj9crcg.js → chunk-bkkpq8dx.js} +9 -9
- package/dist/chunk-brtvm8mb.js +2 -0
- package/dist/{chunk-2dp7hyv7.js → chunk-bsajk82t.js} +14 -14
- package/dist/chunk-bvzr9zqt.js +2 -0
- package/dist/{chunk-t9yqq483.js → chunk-cbjabv1w.js} +4 -4
- package/dist/chunk-cbvgtf3m.js +2 -0
- package/dist/chunk-cfydbaeq.js +2 -0
- package/dist/{chunk-t2pzy3x1.js → chunk-ck2e3e47.js} +3 -3
- package/dist/{chunk-wpmrz872.js → chunk-d09q93yf.js} +2 -2
- package/dist/{chunk-a91atghh.js → chunk-d1a86qx8.js} +1 -1
- package/dist/{chunk-xqp4hstk.js → chunk-dgc1a3yt.js} +6 -6
- package/dist/chunk-dq8c3h4n.js +2 -0
- package/dist/chunk-e36pne7n.js +2 -0
- package/dist/chunk-e62qfexp.js +2 -0
- package/dist/chunk-eq5jzaj5.js +2 -0
- package/dist/{chunk-kwek8xdt.js → chunk-f9zyf9n6.js} +65 -65
- package/dist/{chunk-dgb4z4kw.js → chunk-faakv1p6.js} +2 -2
- package/dist/{chunk-yqz01qvy.js → chunk-fb7t1nn9.js} +3 -3
- package/dist/{chunk-06b8btkv.js → chunk-fbmth6xv.js} +10 -10
- package/dist/{chunk-7met6yva.js → chunk-fd49fahd.js} +5 -5
- package/dist/chunk-fr39emcz.js +2 -0
- package/dist/chunk-fsq13amm.js +2 -0
- package/dist/chunk-fw413k9q.js +3 -0
- package/dist/chunk-fxh12vqd.js +2 -0
- package/dist/chunk-gcc9fa33.js +2 -0
- package/dist/chunk-h6t2ney6.js +2 -0
- package/dist/{chunk-kgfgb971.js → chunk-ham5x7ts.js} +4 -4
- package/dist/{chunk-n38yb274.js → chunk-hb3edeq9.js} +6 -6
- package/dist/{chunk-fvtwec1r.js → chunk-hegfgw27.js} +1 -1
- package/dist/{chunk-p472crv1.js → chunk-hgry3mjd.js} +1 -1
- package/dist/{chunk-t961jbzc.js → chunk-hsmcbh0p.js} +7 -7
- package/dist/{chunk-wz2zb53w.js → chunk-hz4x7h0n.js} +5 -5
- package/dist/{chunk-jxda11cg.js → chunk-j6m8xqh3.js} +2 -2
- package/dist/chunk-j8g5cvvm.js +2 -0
- package/dist/chunk-jzjpyyw2.js +2 -0
- package/dist/chunk-k1b8x73j.js +2 -0
- package/dist/{chunk-8k3rwv8r.js → chunk-kdebh22m.js} +7 -7
- package/dist/{chunk-pvb48ehs.js → chunk-mwnhdsbp.js} +2 -2
- package/dist/{chunk-s20h5gmr.js → chunk-nj343mw2.js} +5 -5
- package/dist/chunk-nw9bdk2n.js +2 -0
- package/dist/chunk-p4jkswz8.js +2 -0
- package/dist/chunk-p4r90vqf.js +2 -0
- package/dist/{chunk-bnn7pd62.js → chunk-p6qd7ad0.js} +2 -2
- package/dist/chunk-p8bgy5tt.js +2 -0
- package/dist/{chunk-aprhqxky.js → chunk-pb6erpj3.js} +5 -5
- package/dist/{chunk-r3e6x87d.js → chunk-pg2v1pb5.js} +3 -3
- package/dist/{chunk-dw81nc5v.js → chunk-pqqe2b6m.js} +4 -4
- package/dist/chunk-q6nwcav4.js +2 -0
- package/dist/chunk-qmqavdz2.js +2 -0
- package/dist/chunk-qpw72bty.js +2 -0
- package/dist/chunk-qwnh1kj6.js +2 -0
- package/dist/chunk-qy9m6qdn.js +2 -0
- package/dist/chunk-qychcdsm.js +2 -0
- package/dist/{chunk-7d4z944r.js → chunk-qz5b8ed4.js} +7 -7
- package/dist/{chunk-6ajahb2x.js → chunk-r7fdw2v5.js} +3 -3
- package/dist/{chunk-mmwedr93.js → chunk-rdr09efy.js} +5 -5
- package/dist/chunk-rj3w1ama.js +2 -0
- package/dist/{chunk-prf164ct.js → chunk-rr527jt6.js} +2 -2
- package/dist/{chunk-x68etmdg.js → chunk-rv39s5az.js} +4 -4
- package/dist/{chunk-a5zqqgx2.js → chunk-rym0309c.js} +3 -3
- package/dist/{chunk-sqayfat9.js → chunk-s0vtjyyj.js} +1 -1
- package/dist/{chunk-vqc4h16r.js → chunk-s2wptfm1.js} +2 -2
- package/dist/chunk-sf0r963g.js +2 -0
- package/dist/{chunk-a3yte051.js → chunk-sqn3y9qt.js} +2 -2
- package/dist/{chunk-9gfffs28.js → chunk-srq9fqq8.js} +10 -10
- package/dist/chunk-ss820yys.js +2 -0
- package/dist/{chunk-pn1ehs6a.js → chunk-szevd7d5.js} +2 -2
- package/dist/{chunk-wbzmr6a4.js → chunk-t0k16vqv.js} +2 -2
- package/dist/chunk-t4j9g2vh.js +2 -0
- package/dist/chunk-t79jfpv6.js +3 -0
- package/dist/{chunk-rcadtv3x.js → chunk-t9kxhe46.js} +1 -1
- package/dist/{chunk-zqtbtqbq.js → chunk-tddnb5bv.js} +2 -2
- package/dist/{chunk-hvzzhkhr.js → chunk-thceyzj6.js} +2 -2
- package/dist/{chunk-n3m7fkv1.js → chunk-trh7s6k3.js} +5 -5
- package/dist/{chunk-3349573p.js → chunk-trz8z4j4.js} +18 -18
- package/dist/chunk-ttemwrbx.js +2 -0
- package/dist/{chunk-wankp78x.js → chunk-twqzn21x.js} +7 -7
- package/dist/chunk-v14rq8b4.js +3 -0
- package/dist/{chunk-b4pcw34n.js → chunk-v21bhhjb.js} +1 -1
- package/dist/{chunk-ka8befem.js → chunk-v6peecfp.js} +2 -2
- package/dist/{chunk-g8r0km7g.js → chunk-vayhx642.js} +2 -2
- package/dist/{chunk-5pgk3w2c.js → chunk-vdxg7e1y.js} +2 -2
- package/dist/chunk-vq513cxx.js +2 -0
- package/dist/chunk-vvq8xe3n.js +2 -0
- package/dist/{chunk-tre98h62.js → chunk-w3d98907.js} +2 -2
- package/dist/{chunk-p3x21vp7.js → chunk-w7t2cfgy.js} +42 -42
- package/dist/chunk-w8t31bn9.js +2 -0
- package/dist/chunk-x1kz4d7j.js +2 -0
- package/dist/chunk-xcsyqwxf.js +25 -0
- package/dist/{chunk-9p6efb17.js → chunk-xghcsg3f.js} +1 -1
- package/dist/chunk-xn9jrjzh.js +2 -0
- package/dist/{chunk-nrvwejdw.js → chunk-y1pcdeg9.js} +5 -5
- package/dist/{chunk-qffbkvfn.js → chunk-yx3dpdwc.js} +3 -3
- package/dist/{chunk-f9hrpwsw.js → chunk-z22zy22p.js} +2 -2
- package/dist/chunk-z97bwx8m.js +2 -0
- package/dist/{chunk-120ze5ms.js → chunk-zmg1peyg.js} +3 -3
- package/dist/{chunk-pxdww4rb.js → chunk-zp79zkkd.js} +2 -2
- package/dist/cli.js +20 -20
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/loops.js +19 -3
- package/dist/pwa.js +3 -3
- package/dist/signal-processing.d.ts +12 -0
- package/dist/signal-processing.js +1 -1
- package/dist/ssg.js +6 -6
- package/package.json +5 -5
- package/dist/chunk-028ee6q5.js +0 -2
- package/dist/chunk-02ymqwmj.js +0 -2
- package/dist/chunk-0dcrd58z.js +0 -2
- package/dist/chunk-0f33ssaq.js +0 -2
- package/dist/chunk-17yfcd5s.js +0 -2
- package/dist/chunk-1pnp91wx.js +0 -2
- package/dist/chunk-23b0khvh.js +0 -3
- package/dist/chunk-2f17h17f.js +0 -2
- package/dist/chunk-4c183zem.js +0 -2
- package/dist/chunk-4ve8vsw5.js +0 -2
- package/dist/chunk-4yt8tg4j.js +0 -2
- package/dist/chunk-52gp2xxk.js +0 -2
- package/dist/chunk-5w1c7x22.js +0 -2
- package/dist/chunk-5zgrvj4b.js +0 -2
- package/dist/chunk-67kj14at.js +0 -2
- package/dist/chunk-6vzktvyw.js +0 -2
- package/dist/chunk-7a3g26kk.js +0 -2
- package/dist/chunk-7d2fab0z.js +0 -2
- package/dist/chunk-7dtpszqq.js +0 -2
- package/dist/chunk-7spxdz5k.js +0 -2
- package/dist/chunk-864qtx7y.js +0 -2
- package/dist/chunk-89jbdtgw.js +0 -3
- package/dist/chunk-96mm4q2g.js +0 -2
- package/dist/chunk-9szxxgv5.js +0 -2
- package/dist/chunk-9yxgdy4z.js +0 -42
- package/dist/chunk-a95r5nmq.js +0 -25
- package/dist/chunk-am246nf3.js +0 -2
- package/dist/chunk-avnhsjq0.js +0 -2
- package/dist/chunk-aw3meb8t.js +0 -2
- package/dist/chunk-b4fd2dtk.js +0 -2
- package/dist/chunk-b823zxq6.js +0 -3
- package/dist/chunk-bdg0fydw.js +0 -2
- package/dist/chunk-d6en3vz7.js +0 -2
- package/dist/chunk-dnw3knxq.js +0 -2
- package/dist/chunk-dpvxe52r.js +0 -2
- package/dist/chunk-e1fetwbr.js +0 -2
- package/dist/chunk-e44z03s5.js +0 -2
- package/dist/chunk-e4vpr36s.js +0 -2
- package/dist/chunk-f8dkq3ta.js +0 -2
- package/dist/chunk-fcn71bq1.js +0 -2
- package/dist/chunk-g2jmwh7p.js +0 -2
- package/dist/chunk-j0v970k3.js +0 -2
- package/dist/chunk-jk41jwsc.js +0 -2
- package/dist/chunk-k2pa44rf.js +0 -2
- package/dist/chunk-qq1k3364.js +0 -2
- package/dist/chunk-qxmyaajq.js +0 -2
- package/dist/chunk-sc7hszsx.js +0 -2
- package/dist/chunk-sf0wsq74.js +0 -2
- package/dist/chunk-shpc1ttk.js +0 -2
- package/dist/chunk-sj6mhjdq.js +0 -2
- package/dist/chunk-sqhmkvwd.js +0 -2
- package/dist/chunk-sw6p5176.js +0 -2
- package/dist/chunk-tb6vacgp.js +0 -2
- package/dist/chunk-we8ptx6w.js +0 -2
- package/dist/chunk-weqc0ssb.js +0 -2
- package/dist/chunk-wq712sw1.js +0 -2
- package/dist/chunk-wyq0c4wy.js +0 -2
- package/dist/chunk-wz6368p4.js +0 -2
- package/dist/chunk-yscr04dv.js +0 -2
- package/dist/chunk-z8j2sbnb.js +0 -2
- package/dist/chunk-z8p6tk5z.js +0 -2
- package/dist/chunk-zhf01af3.js +0 -3
- package/dist/chunk-zp9k5pha.js +0 -2
|
@@ -72,7 +72,7 @@ else {
|
|
|
72
72
|
${t}
|
|
73
73
|
})();
|
|
74
74
|
</script>
|
|
75
|
-
`}function
|
|
75
|
+
`}function gd(i,n,o){f=0;let l=/@defer\s*\(([^)]*)\)\s*([\s\S]*?)@enddefer/g;return i.replace(l,(t,e,s)=>{let a=v(),r=p(t,e,s),d=r.placeholder?`<div data-defer-placeholder>${r.placeholder}</div>`:"",c=r.loading?`<div data-defer-loading style="display: none;">${r.loading}</div>`:'<div data-defer-loading style="display: none;"></div>',g=r.error?`<div data-defer-error style="display: none;">${r.error}</div>`:"",u=`<div data-defer-content style="display: none;">${r.content}</div>`,h=E(a,r);return`
|
|
76
76
|
<div id="${a}" class="stx-defer" data-defer-trigger="${r.trigger}">
|
|
77
77
|
${d}
|
|
78
78
|
${c}
|
|
@@ -81,4 +81,4 @@ else {
|
|
|
81
81
|
</div>
|
|
82
82
|
${h}
|
|
83
83
|
`})}
|
|
84
|
-
export{
|
|
84
|
+
export{gd};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{k}from"./chunk-
|
|
2
|
+
import{k}from"./chunk-f9zyf9n6.js";import{s}from"./chunk-aet1pgw7.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
3
|
${e.bold}${t[0]}${e.reset} - ${n.description}`),console.log(` Usage: ${e.cyan}${n.usage}${e.reset}
|
|
4
4
|
`)}else{console.log(`
|
|
5
5
|
${e.bold}Available Commands:${e.reset}
|
|
@@ -16,9 +16,9 @@ ${e.bold}Markdown:${e.reset}`),a.forEach((i)=>console.log(` ${e.blue}${i}${e.re
|
|
|
16
16
|
${e.bold}Other:${e.reset}`),d.forEach((i)=>console.log(` ${e.dim}${i}${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 l=(await Bun.file(n).text()).split(`
|
|
17
17
|
`);console.log(),l.forEach((c,a)=>{let d=String(a+1).padStart(3," ");console.log(`${e.dim}${d}${e.reset} ${c}`)}),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(),l=JSON.parse(r);o.context={...o.context,...l},console.log(`${e.green}\u2713${e.reset} Loaded ${Object.keys(l).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((l,c)=>{let a=String(o.history.length-r.length+c+1).padStart(3," ");console.log(`${e.dim}${a}${e.reset} ${l}`)}),console.log()}},exit:{description:"Exit interactive mode",usage:"exit",handler:async(t,o)=>{o.running=!1,console.log(`
|
|
18
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((l)=>l.startsWith(r));if(["render","cat","load","cd"].includes(r)){let l=n.slice(1).join(" "),c=g.dirname(l)||".",a=g.basename(l),d=g.resolve(o.cwd,c);if(p.existsSync(d)&&p.statSync(d).isDirectory())try{return p.readdirSync(d).filter((f)=>f.startsWith(a)).map((f)=>`${r} ${c==="."?"":`${c}/`}${f}`)}catch{return[]}}if(["unset","eval","set"].includes(r)){let l=n[1]||"";return Object.keys(o.context).filter((c)=>c.startsWith(l)).map((c)=>`${r} ${c}`)}return[]}async function
|
|
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((l)=>l.startsWith(r));if(["render","cat","load","cd"].includes(r)){let l=n.slice(1).join(" "),c=g.dirname(l)||".",a=g.basename(l),d=g.resolve(o.cwd,c);if(p.existsSync(d)&&p.statSync(d).isDirectory())try{return p.readdirSync(d).filter((f)=>f.startsWith(a)).map((f)=>`${r} ${c==="."?"":`${c}/`}${f}`)}catch{return[]}}if(["unset","eval","set"].includes(r)){let l=n[1]||"";return Object.keys(o.context).filter((c)=>c.startsWith(l)).map((c)=>`${r} ${c}`)}return[]}async function $u(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:(l)=>[h(l,o),l],historySize:t.maxHistory||100});console.log(`
|
|
20
20
|
${e.bold}${e.blue}stx Interactive Mode${e.reset}
|
|
21
21
|
${e.dim}Type 'help' for available commands, 'exit' to quit${e.reset}
|
|
22
22
|
`);let r=()=>{let l=o.cwd.replace(process.env.HOME||"","~");n.question(`${e.cyan}stx${e.reset} ${e.dim}${l}${e.reset} ${e.green}>${e.reset} `,async(c)=>{let a=c.trim();if(!a){if(o.running)r();return}o.history.push(a);let d=a.match(/(?:[^\s"]|"[^"]*")+/g)||[],i=d[0]?.toLowerCase(),f=d.slice(1).map((m)=>m.replace(/^"|"$/g,""));if(i&&u[i])try{await u[i].handler(f,o)}catch(m){console.log(`${e.red}Error:${e.reset}`,m)}else if(i)if(a.includes("{{")||a.includes("}}"))try{let m=await k(a,o.context,"eval");console.log(`${e.green}\u2192${e.reset} ${m}`)}catch{console.log(`${e.red}Unknown command: ${i}${e.reset}`),console.log(`${e.dim}Type 'help' for available commands${e.reset}`)}else console.log(`${e.red}Unknown command: ${i}${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
23
|
${e.dim}(Use 'exit' to quit)${e.reset}`),r()}),r()}
|
|
24
|
-
export{
|
|
24
|
+
export{$u};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{x}from"./chunk-
|
|
2
|
+
import{x}from"./chunk-zp79zkkd.js";import{be,$t,Eo,To,Aa,Pa,Ia,Oa,us,Ro,Na,Da,Ma,un}from"./chunk-f9zyf9n6.js";import{o}from"./chunk-srq9fqq8.js";import{Hs}from"./chunk-hsmcbh0p.js";import{c}from"./chunk-v14rq8b4.js";import{existsSync as M,readFileSync as K}from"fs";import h from"path";var ge=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),ee=un.filter((e)=>!ge.has(e)).sort(),te=[...x].sort(),me=[...new Set([...ee,...te])].sort(),he=new Set(ee),ye=new Set(te),xe=new Set(me),Y=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Se(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ne(e,t){let s=[];for(let u of t){if(u.offset===void 0)continue;let i=u.kind==="server"?he:ye;Y.lastIndex=0;for(let l of u.code.matchAll(Y)){let g=l.index+l[0].indexOf("{")+1;for(let m of l[1].matchAll(/[^,]+/g)){let S=m[0];if(/^\s*type\s/.test(S))continue;let y=/^\s*([A-Za-z_$][\w$]*)/.exec(S);if(!y)continue;let r=y[1];if(!xe.has(r)||i.has(r))continue;let f=u.offset+g+m.index+y[0].length-r.length,p=e.slice(0,f),w=p.split(`
|
|
3
3
|
`).length;s.push({line:w,column:f-(p.lastIndexOf(`
|
|
4
|
-
`)+1)+1,offset:f,length:r.length,name:r,kind:u.kind,message:Se(r,u.kind)})}}}return s}import T from"path";var ke="@stacksjs/stx-typescript-plugin";function we(e,t){let s=T.resolve(e);for(;;){let u=T.join(s,"tsconfig.json");if(t(u))return u;let i=T.dirname(s);if(i===s)return;s=i}}function ie(e,t,s){let u=we(e,s);if(!u)return;let i=new Set,l=(g)=>{if(i.has(g))return;i.add(g);let m=t(g);if(!m)return;let S=m.compilerOptions?.plugins;if(Array.isArray(S)){let r=S.find((p)=>p?.name===ke),f=Array.isArray(r?.libs)?r.libs.filter((p)=>typeof p==="string"):[];return r?{configPath:g,libs:f.map((p)=>T.resolve(T.dirname(g),p))}:null}let y=typeof m.extends==="string"?[m.extends]:Array.isArray(m.extends)?m.extends:[];for(let r of[...y].reverse()){if(typeof r!=="string"||!r.startsWith("."))continue;let f=T.resolve(T.dirname(g),r.endsWith(".json")?r:`${r}.json`),p=l(f);if(p!==void 0)return p}return};return l(u)??void 0}function
|
|
5
|
-
`.repeat(e.startLine-1):"",i
|
|
4
|
+
`)+1)+1,offset:f,length:r.length,name:r,kind:u.kind,message:Se(r,u.kind)})}}}return s}import T from"path";var ke="@stacksjs/stx-typescript-plugin";function we(e,t){let s=T.resolve(e);for(;;){let u=T.join(s,"tsconfig.json");if(t(u))return u;let i=T.dirname(s);if(i===s)return;s=i}}function ie(e,t,s){let u=we(e,s);if(!u)return;let i=new Set,l=(g)=>{if(i.has(g))return;i.add(g);let m=t(g);if(!m)return;let S=m.compilerOptions?.plugins;if(Array.isArray(S)){let r=S.find((p)=>p?.name===ke),f=Array.isArray(r?.libs)?r.libs.filter((p)=>typeof p==="string"):[];return r?{configPath:g,libs:f.map((p)=>T.resolve(T.dirname(g),p))}:null}let y=typeof m.extends==="string"?[m.extends]:Array.isArray(m.extends)?m.extends:[];for(let r of[...y].reverse()){if(typeof r!=="string"||!r.startsWith("."))continue;let f=T.resolve(T.dirname(g),r.endsWith(".json")?r:`${r}.json`),p=l(f);if(p!==void 0)return p}return};return l(u)??void 0}function Ic(e,t="",s=""){let u=e.startLine>1?`
|
|
5
|
+
`.repeat(e.startLine-1):"",i=Ro(e)+To(Eo(e.code)),l=e.kind==="client"||e.kind==="plain"?Ia(t,e.code):"";return us(`${u+i}
|
|
6
6
|
${l}
|
|
7
7
|
export {}
|
|
8
8
|
`,s)}var $e=new Set(["name","status","length","location","history","origin","closed","close","open","focus","blur","print","scroll","scrollTo","scrollBy","stop","top","parent","self","frames","event","external","menubar","toolbar"]);function ve(e){if(e.length===0)return"";let t=["// Generated \u2014 the composables the runtime publishes as bare globals."],s=new Set(x),u=[];for(let{file:i,names:l}of e){let g=JSON.stringify(i.replace(/\\/g,"/").replace(/\.ts$/,""));u.push(` export * from ${g}`);for(let m of l){if(s.has(m)||$e.has(m))continue;s.add(m),t.push(`declare const ${m}: typeof import(${g})[${JSON.stringify(m)}]`)}}return t.push("declare module '@composables' {",...u,"}"),t.join(`
|
|
9
|
-
`)}function
|
|
9
|
+
`)}function _i(e,t,s){return`${e}.__stx_${t}${s}.ts`}function Ou(e){return e.replace(/\.__stx_(?:server|client|plain|template)\d+\.ts$/,"")}function Oc(){return se("stx.d.ts")}function Nc(){return se("stx-module.d.ts")}function se(e){for(let t of[h.resolve(import.meta.dir,"..",e),h.resolve(import.meta.dir,"..","..",e)])if(M(t))return t;return null}var Te=/^(.*?)\((\d+),(\d+)\):\s+(error|warning)\s+TS(\d+):\s+(.*)$/;function De(e){return e>=1000&&e<2000}function re(e){let t="",s=!1,u=!1;for(let i=0;i<e.length;i++){let l=e[i];if(s){if(t+=l,u)u=!1;else if(l==="\\")u=!0;else if(l==='"')s=!1;continue}if(l==='"'){s=!0,t+=l;continue}if(l==="/"&&e[i+1]==="/"){while(i<e.length&&e[i]!==`
|
|
10
10
|
`)i++;t+=`
|
|
11
|
-
`;continue}if(l==="/"&&e[i+1]==="*"){i+=2;while(i<e.length&&!(e[i]==="*"&&e[i+1]==="/"))i++;i++;continue}t+=l}return t.replace(/,(\s*[}\]])/g,"$1")}function Ee(e){try{return JSON.parse(re(K(e,"utf8")))}catch{return}}function Oe(e){let t=h.resolve(e),s;for(;;){let r=h.join(t,"tsconfig.json");if(M(r)){s=r;break}let f=h.dirname(t);if(f===t)break;t=f}if(!s)return{};let u=new Set,i=s,l,g,m=s;while(i&&!u.has(i)){u.add(i);let r;try{r=JSON.parse(re(K(i,"utf8")))}catch{break}let f=r?.compilerOptions??{};if(!l&&f.paths&&typeof f.paths==="object")l=f.paths,m=i;if(!g&&typeof f.baseUrl==="string")g=h.resolve(h.dirname(i),f.baseUrl);if(l&&g)break;i=typeof r?.extends==="string"?h.resolve(h.dirname(i),r.extends.endsWith(".json")?r.extends:`${r.extends}.json`):void 0}if(!l)return{};let S=g??h.dirname(m),y={};for(let[r,f]of Object.entries(l)){if(!Array.isArray(f))continue;y[r]=f.map((p)=>typeof p==="string"&&!h.isAbsolute(p)?h.resolve(S,p):p)}return{paths:y}}async function
|
|
12
|
-
`);for(let d of ne(a,b))S.push({file:n,line:d.line,column:d.column,code:0,message:d.message,category:"error",blockKind:d.kind});if(s&&k){let d=b.filter((O)=>O.kind!=="server"),E=[...new Set(d.flatMap((O)=>
|
|
13
|
-
`),ve(await
|
|
11
|
+
`;continue}if(l==="/"&&e[i+1]==="*"){i+=2;while(i<e.length&&!(e[i]==="*"&&e[i+1]==="/"))i++;i++;continue}t+=l}return t.replace(/,(\s*[}\]])/g,"$1")}function Ee(e){try{return JSON.parse(re(K(e,"utf8")))}catch{return}}function Oe(e){let t=h.resolve(e),s;for(;;){let r=h.join(t,"tsconfig.json");if(M(r)){s=r;break}let f=h.dirname(t);if(f===t)break;t=f}if(!s)return{};let u=new Set,i=s,l,g,m=s;while(i&&!u.has(i)){u.add(i);let r;try{r=JSON.parse(re(K(i,"utf8")))}catch{break}let f=r?.compilerOptions??{};if(!l&&f.paths&&typeof f.paths==="object")l=f.paths,m=i;if(!g&&typeof f.baseUrl==="string")g=h.resolve(h.dirname(i),f.baseUrl);if(l&&g)break;i=typeof r?.extends==="string"?h.resolve(h.dirname(i),r.extends.endsWith(".json")?r.extends:`${r.extends}.json`):void 0}if(!l)return{};let S=g??h.dirname(m),y={};for(let[r,f]of Object.entries(l)){if(!Array.isArray(f))continue;y[r]=f.map((p)=>typeof p==="string"&&!h.isAbsolute(p)?h.resolve(S,p):p)}return{paths:y}}async function Nu(e,t={}){let s=t.client!==!1,u=t.server!==!1,i=t.templates!==!1,l=t.componentsDir??(i?(await o()).componentsDir:void 0),g=new Map,m=new Map,S=[],y=[],r=0,f=0,p=Oc();for(let n of e){let a=await Bun.file(n).text(),b=$t(a).filter((d)=>{if(d.kind==="server")return u;return s}),k=$t(a).filter((d)=>d.kind==="server").map((d)=>d.code).join(`
|
|
12
|
+
`);for(let d of ne(a,b))S.push({file:n,line:d.line,column:d.column,code:0,message:d.message,category:"error",blockKind:d.kind});if(s&&k){let d=b.filter((O)=>O.kind!=="server"),E=[...new Set(d.flatMap((O)=>Oa(k,O.code)))];if(E.length>0)m.set(n,{names:E,line:d[0].startLine,kind:d[0].kind})}let D=h.dirname(h.resolve(n)),v=i?Na(a,{runtimeGlobals:!p,originDir:D,filePath:h.resolve(n),componentsDir:l}):null,R=v?[...v.lineMap.values()].filter((d)=>d.expression).length:0;if(b.length===0&&R===0)continue;if(y.push(n),r+=b.length,f+=R,b.forEach((d,E)=>{g.set(_i(n,d.kind,E),{source:Ic(d,k,D),origin:n,kind:d.kind})}),v&&R>0)g.set(_i(n,"template",0),{source:v.text,origin:n,kind:"template",virtual:v})}if(g.size===0)return{diagnostics:S,checkedFiles:y,blockCount:0,expressionCount:0};let w=(t.extraLibs??[]).map((n)=>h.resolve(n)),oe=ie(e.length>0?h.dirname(h.resolve(e[0])):process.cwd(),Ee,M);for(let n of oe?.libs??[])if(!w.includes(n)&&M(n))w.push(n);if(p)w.push(p);let G=p?Nc():null;if(G)w.push(G);let X=`${c()}/typecheck/__stx_globals.d.ts`,ce=["// Generated \u2014 the context serve.ts injects into <script server> blocks.",Aa(p?Pa(K(p,"utf8")):void 0),...p?[]:["declare const window: any",...x.map((n)=>`declare const ${n}: any`)],["// Generated \u2014 the names stx auto-imports from @stacksjs/browser.",...be.map((n)=>`declare const ${n}: any`)].join(`
|
|
13
|
+
`),ve(await Hs())].filter(Boolean).join(`
|
|
14
14
|
`),_=`${c()}/typecheck`;await Bun.$`rm -rf ${_}`.quiet().nothrow(),await Bun.$`mkdir -p ${_}`.quiet().nothrow(),await Bun.write(X,ce);let N=new Map,ae=0;for(let[n,a]of g){let b=`${ae++}_${n.replace(/[^\w.-]+/g,"_")}`;await Bun.write(`${_}/${b}`,a.source),N.set(b,a)}let le={target:"ESNext",module:"ESNext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,allowJs:!0,esModuleInterop:!0,resolveJsonModule:!0,lib:["ESNext","DOM","DOM.Iterable"],types:[],...Oe(e.length>0?h.dirname(h.resolve(e[0])):process.cwd()),...t.compilerOptions??{}},F=async(n,a)=>{let b=`${_}/tsconfig${a===1?"":`.${a}`}.json`;await Bun.write(b,JSON.stringify({compilerOptions:le,files:n.map((D)=>`${_}/${D}`).concat(X,...w)},null,2));let k=Bun.spawnSync(["bun","x","tsc","-p",b,"--pretty","false"],{stdout:"pipe",stderr:"pipe"});return{output:new TextDecoder().decode(k.stdout)+new TextDecoder().decode(k.stderr),exitCode:k.exitCode??0}},V=await F([...N.keys()],1),J=V.output,I=[],U=V.exitCode,W=0,ue=new Set(w.map((n)=>n.split("/").pop())),z=0,B=new Set,q=(n)=>{for(let a of n.replace(/\n[\t ]+([^\n]*)/g," $1").split(`
|
|
15
|
-
`)){let b=a.match(Te);if(!b)continue;if(W++,ue.has(b[1].split("/").pop()))z++;let[,k,D,v,R,d,E]=b,O=k.split("/").pop(),C=N.get(O);if(!C)continue;if(De(Number(d)))B.add(O);let A=Number(D),L=Number(v),Q;if(C.virtual){let P=
|
|
15
|
+
`)){let b=a.match(Te);if(!b)continue;if(W++,ue.has(b[1].split("/").pop()))z++;let[,k,D,v,R,d,E]=b,O=k.split("/").pop(),C=N.get(O);if(!C)continue;if(De(Number(d)))B.add(O);let A=Number(D),L=Number(v),Q;if(C.virtual){let P=Ma(C.virtual,A,L);if(!P?.expression)continue;if(Da(P,Number(d)))continue;A=P.line,L=P.column,Q=P.expression.code.trim()}I.push({file:C.origin,line:A,column:L,code:Number(d),message:E,category:R==="error"?"error":"warning",blockKind:C.kind,expression:Q})}};q(J);let pe=W,de=z;if(B.size>0&&B.size<N.size){let n=[...N.keys()].filter((a)=>!B.has(a));q((await F(n,2)).output)}if(s)for(let[n,a]of m){if(a.names.length===0)continue;I.push({file:n,line:a.line,column:1,code:0,message:`${a.names.length===1?"1 value reaches":`${a.names.length} values reach`} this block on the implicit bridge and ${a.names.length===1?"is":"are"} untyped: ${a.names.join(", ")}. Declare them with defineClientPayload({ ${a.names.join(", ")} }) in the server block to have them checked.`,category:"warning",blockKind:a.kind})}I.push(...S);let H=new Set,j=I.filter((n)=>{let a=`${n.file}:${n.line}:${n.column}:${n.code}:${n.message}`;if(H.has(a))return!1;return H.add(a),!0});j.sort((n,a)=>n.file.localeCompare(a.file)||n.line-a.line||n.column-a.column);let Z=de>0&&j.length===0,fe=Z||U!==0&&pe===0?`${Z?"a file passed with --lib has errors of its own, so nothing in your code was checked":`tsc exited ${U} without reporting any diagnostic, so nothing was checked`}. `+"A syntax error in an ambient declaration file does this \u2014 skipLibCheck suppresses "+`SEMANTIC diagnostics only. tsc said:
|
|
16
16
|
${J.trim().split(`
|
|
17
17
|
`).slice(0,12).join(`
|
|
18
|
-
`)||"(no output)"}`:void 0;return{diagnostics:j,checkedFiles:y,blockCount:r,expressionCount:f,failure:fe}}function
|
|
18
|
+
`)||"(no output)"}`:void 0;return{diagnostics:j,checkedFiles:y,blockCount:r,expressionCount:f,failure:fe}}function Du(e){return e.map((t)=>{let s=t.blockKind==="template"?`[template: ${t.expression??""}]`:`[${t.blockKind==="plain"?"<script>":`<script ${t.blockKind}>`}]`;return`${t.file}:${t.line}:${t.column} ${t.category} TS${t.code} ${t.message} ${s}`}).join(`
|
|
19
19
|
`)}
|
|
20
|
-
export{
|
|
20
|
+
export{Ic,_i,Ou,Oc,Nc,Nu,Du};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import S from"fs";import _ from"path";function
|
|
2
|
+
import S from"fs";import _ from"path";function Ns(e){let{token:t,baseUrl:i="https://api.netlify.com/api/v1"}=e;async function s(n,r,l={}){let p=`${i}${r}`,f={Authorization:`Bearer ${t}`,"User-Agent":"stx-deploy/1.0"},u;if(l.rawBody)f["Content-Type"]=l.contentType||"application/octet-stream",u=l.rawBody;else if(l.body)f["Content-Type"]="application/json",u=JSON.stringify(l.body);let o=await fetch(p,{method:n,headers:f,body:u});if(!o.ok){let g=Error(`Netlify API error: ${o.status} ${o.statusText}`);g.status=o.status;try{let b=await o.json();g.message=b.message||g.message,g.code=b.code,g.details=b}catch{}throw g}let a=await o.text();if(!a)return{};return JSON.parse(a)}return{async getSite(n){return s("GET",`/sites/${n}`)},async listSites(){return s("GET","/sites")},async createSite(n){let r={};if(n)r.name=n;return s("POST","/sites",{body:r})},async createDeploy(n,r){let l={files:r.files,draft:r.draft??!0,async:r.async??!0};if(r.title)l.title=r.title;if(r.branch)l.branch=r.branch;if(r.functions)l.functions=r.functions;return s("POST",`/sites/${n}/deploys`,{body:l})},async uploadFile(n,r,l){let p=r.startsWith("/")?r.slice(1):r;await s("PUT",`/deploys/${n}/files/${p}`,{rawBody:l,contentType:"application/octet-stream"})},async uploadFiles(n,r){let p=[...r],f=async()=>{while(p.length>0){let o=p.shift();if(o)await this.uploadFile(n,o.path,o.content)}},u=Array.from({length:Math.min(5,r.length)},()=>f());await Promise.all(u)},async getDeploy(n){return s("GET",`/deploys/${n}`)},async waitForDeploy(n,r={}){let{timeout:l=300000,pollInterval:p=2000,onProgress:f}=r,u=Date.now();while(!0){let o=await this.getDeploy(n);if(f)f(o);if(o.state==="ready")return o;if(o.state==="error"){let a=Error(`Deploy failed: ${o.error_message||"Unknown error"}`);throw a.status=500,a.details=o,a}if(Date.now()-u>l){let a=Error(`Deploy timed out after ${l}ms`);throw a.status=408,a.details=o,a}await new Promise((a)=>setTimeout(a,p))}},async lockDeploy(n){return s("POST",`/deploys/${n}/lock`)},async unlockDeploy(n){return s("POST",`/deploys/${n}/unlock`)}}}async function vi(e){let t=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(t)).map((s)=>s.toString(16).padStart(2,"0")).join("")}async function Er(e,t={}){let{ignore:i=["node_modules",".git",".env*","*.map"]}=t,s=[],n=new Bun.Glob("**/*");for await(let r of n.scan({cwd:e,onlyFiles:!0,dot:!1})){if(i.some((a)=>{if(a.includes("*"))return new RegExp(`^${a.replace(/\*/g,".*")}$`).test(r);return r.includes(a)}))continue;let p=`${e}/${r}`,u=await Bun.file(p).arrayBuffer(),o=await vi(u);s.push({path:r,content:new Uint8Array(u),sha1:o})}return s}function Ds(e){let t={};for(let i of e)t[`/${i.path}`]=i.sha1;return t}function Ms(e,t){let i=new Set(t.map((s)=>s.startsWith("/")?s.slice(1):s));return e.filter((s)=>i.has(s.path))}function Sn(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;if(e<1073741824)return`${(e/1048576).toFixed(1)} MB`;return`${(e/1073741824).toFixed(1)} GB`}function Vt(e){return e.reduce((t,i)=>t+i.content.byteLength,0)}import m from"fs";import y from"path";function wi(e){let t=[];if(t.push("[build]"),t.push(` command = "${d(e.build.command)}"`),t.push(` publish = "${d(e.build.publish)}"`),e.build.functions)t.push(` functions = "${d(e.build.functions)}"`);if(e.build.edge_functions)t.push(` edge_functions = "${d(e.build.edge_functions)}"`);if(e.build.environment&&Object.keys(e.build.environment).length>0){t.push(""),t.push("[build.environment]");for(let[i,s]of Object.entries(e.build.environment))t.push(` ${i} = "${d(s)}"`)}if(e.functions){if(t.push(""),t.push("[functions]"),e.functions.directory)t.push(` directory = "${d(e.functions.directory)}"`);if(e.functions.node_bundler)t.push(` node_bundler = "${e.functions.node_bundler}"`);if(e.functions.external_node_modules&&e.functions.external_node_modules.length>0)t.push(` external_node_modules = [${e.functions.external_node_modules.map((i)=>`"${i}"`).join(", ")}]`)}if(e.edge_functions&&e.edge_functions.length>0){t.push("");for(let i of e.edge_functions)t.push("[[edge_functions]]"),t.push(` function = "${d(i.function)}"`),t.push(` path = "${d(i.path)}"`)}if(e.redirects&&e.redirects.length>0){t.push("");for(let i of e.redirects){if(t.push("[[redirects]]"),t.push(` from = "${d(i.from)}"`),t.push(` to = "${d(i.to)}"`),i.status!==void 0)t.push(` status = ${i.status}`);if(i.force!==void 0)t.push(` force = ${i.force}`);if(i.conditions&&Object.keys(i.conditions).length>0){t.push(" [redirects.conditions]");for(let[s,n]of Object.entries(i.conditions))t.push(` ${s} = "${d(n)}"`)}}}if(e.headers&&e.headers.length>0){t.push("");for(let i of e.headers){t.push("[[headers]]"),t.push(` for = "${d(i.for)}"`),t.push(" [headers.values]");for(let[s,n]of Object.entries(i.values))t.push(` ${s} = "${d(n)}"`)}}if(e.plugins&&e.plugins.length>0){t.push("");for(let i of e.plugins)if(t.push("[[plugins]]"),t.push(` package = "${d(i.package)}"`),i.inputs&&Object.keys(i.inputs).length>0){t.push(" [plugins.inputs]");for(let[s,n]of Object.entries(i.inputs))if(typeof n==="string")t.push(` ${s} = "${d(n)}"`);else if(typeof n==="boolean"||typeof n==="number")t.push(` ${s} = ${n}`)}}if(e.context&&Object.keys(e.context).length>0)for(let[i,s]of Object.entries(e.context)){if(t.push(""),t.push(`[context.${i}]`),s.command)t.push(` command = "${d(s.command)}"`);if(s.publish)t.push(` publish = "${d(s.publish)}"`);if(s.environment&&Object.keys(s.environment).length>0){t.push(` [context.${i}.environment]`);for(let[n,r]of Object.entries(s.environment))t.push(` ${n} = "${d(r)}"`)}}return t.join(`
|
|
3
3
|
`)+`
|
|
4
|
-
`}function d(e){return e.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}async function
|
|
4
|
+
`}function d(e){return e.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}async function Tr(e){let t={framework:"stx",buildCommand:"bun run build",outputDir:"dist"},i=y.join(e,"package.json");if(await Bun.file(i).exists())try{let u=JSON.parse(await Bun.file(i).text());if(u.scripts?.build)t.buildCommand="bun run build";let o={...u.dependencies,...u.devDependencies};if(o["@stacksjs/stx"]||o.stx)t.framework="stx"}catch{}let s=y.join(e,"stx.config.ts"),n=y.join(e,".config","stx.config.ts");if(await Bun.file(s).exists()||await Bun.file(n).exists())t.framework="stx";let r=["dist","build","out","public",".output"];for(let u of r){let o=y.join(e,u);if(m.existsSync(o)&&m.statSync(o).isDirectory()){t.outputDir=u;break}}let l=["functions","netlify/functions","api"];for(let u of l){let o=y.join(e,u);if(m.existsSync(o)&&m.statSync(o).isDirectory()){t.functionsDir=u;break}}let p=y.join(e,"netlify","edge-functions");if(m.existsSync(p))t.edgeFunctionsDir="netlify/edge-functions";let f=y.join(e,t.outputDir||"dist");if(m.existsSync(f)){let u=m.existsSync(y.join(f,"index.html")),o=m.readdirSync(f).filter((a)=>a.endsWith(".html"));t.isSPA=u&&o.length===1}return t}function $r(e={}){let t={build:{command:e.buildCommand||"bun run build",publish:e.outputDir||"dist"}};if(e.functionsDir)t.build.functions=e.functionsDir,t.functions={directory:e.functionsDir,node_bundler:"esbuild"};if(e.edgeFunctionsDir)t.build.edge_functions=e.edgeFunctionsDir;if(t.headers=[{for:"/*",values:{"X-Frame-Options":"DENY","X-Content-Type-Options":"nosniff","X-XSS-Protection":"1; mode=block","Referrer-Policy":"strict-origin-when-cross-origin"}},{for:"/assets/*",values:{"Cache-Control":"public, max-age=31536000, immutable"}}],e.isSPA!==!1)t.redirects=[{from:"/*",to:"/index.html",status:200}];return t.context={production:{environment:{NODE_ENV:"production"}},"deploy-preview":{environment:{NODE_ENV:"development"}}},t}async function Ls(e,t){let i=await Tr(e),s=t||$r(i),n=wi(s),r=y.join(e,"netlify.toml");return await Bun.write(r,n),r}function js(e){return m.existsSync(y.join(e,"netlify.toml"))}async function Au(e={}){let t=Date.now(),i=[],s=e.cwd||process.cwd(),n=(c)=>{i.push(c)},r=(c)=>{if(e.onProgress)e.onProgress(c)},l=_.resolve(s,e.directory||"dist"),p=e.token||process.env.NETLIFY_AUTH_TOKEN,f=e.siteId||process.env.NETLIFY_SITE_ID;if(!p)throw new lt(`No Netlify auth token found.
|
|
5
5
|
|
|
6
6
|
To deploy to Netlify:
|
|
7
7
|
1. Create account at https://app.netlify.com
|
|
@@ -19,12 +19,12 @@ Find your site ID at: https://app.netlify.com/sites/YOUR_SITE/settings/general`,
|
|
|
19
19
|
|
|
20
20
|
Run \`stx build\` first or specify a different directory with --directory`,"NO_BUILD_DIR");if(!(S.readdirSync(l).length>0))throw new lt(`Build directory is empty: ${l}
|
|
21
21
|
|
|
22
|
-
Run \`stx build\` to generate files`,"EMPTY_BUILD_DIR");if(e.dryRun){r({stage:"collect",message:"Collecting files..."});let c=await
|
|
22
|
+
Run \`stx build\` to generate files`,"EMPTY_BUILD_DIR");if(e.dryRun){r({stage:"collect",message:"Collecting files..."});let c=await Er(l),w=Vt(c);return n(`Would deploy ${c.length} files (${Sn(w)})`),n(`From: ${l}`),n(`To: Site ${f}`),n(`Mode: ${e.production?"production":"draft"}`),{success:!0,url:`https://${f}.netlify.app (dry-run)`,deployId:"dry-run",logs:i,duration:Date.now()-t,filesUploaded:c.length,totalSize:w}}let o=Ns({token:p});r({stage:"collect",message:"Verifying site..."});try{let c=await o.getSite(f);n(`Deploying to: ${c.name} (${c.url})`)}catch(c){if(c.status===404)throw new lt(`Site not found: ${f}
|
|
23
23
|
|
|
24
|
-
Check your site ID or create a new site at https://app.netlify.com`,"SITE_NOT_FOUND");throw c}r({stage:"collect",message:"Collecting files..."});let a=await
|
|
24
|
+
Check your site ID or create a new site at https://app.netlify.com`,"SITE_NOT_FOUND");throw c}r({stage:"collect",message:"Collecting files..."});let a=await Er(l),g=Vt(a);if(n(`Found ${a.length} files (${Sn(g)})`),a.length===0)throw new lt(`No files found in ${l}`,"NO_FILES");let b=Ds(a);r({stage:"upload",message:"Creating deploy...",percent:0});let D=await o.createDeploy(f,{title:e.message||"Deploy from stx CLI",draft:!e.production,files:b});n(`Created deploy: ${D.id}`);let h=Ms(a,D.required||[]);if(n(`Uploading ${h.length} files...`),h.length>0){let c=0,w=Vt(h);for(let x of h){await o.uploadFile(D.id,x.path,x.content),c++;let C=Math.round(c/h.length*100);r({stage:"upload",message:`Uploading: ${x.path}`,percent:C,details:{uploaded:c,total:h.length}})}n(`Uploaded ${Sn(w)}`)}else n("All files already on CDN (no upload needed)");r({stage:"process",message:"Processing deploy..."});let N=await o.waitForDeploy(D.id,{onProgress:(c)=>{r({stage:"process",message:`Status: ${c.state}`,details:c})}}),P=Date.now()-t;if(r({stage:"done",message:"Deploy complete!"}),n(`Deploy complete in ${(P/1000).toFixed(1)}s`),n(`URL: ${N.deploy_ssl_url}`),e.production)n(`Site: ${N.ssl_url}`);if(e.open){let c=e.production?N.ssl_url:N.deploy_ssl_url;I(c)}return{success:!0,url:N.deploy_ssl_url,siteUrl:e.production?N.ssl_url:void 0,deployId:N.id,logs:i,duration:P,filesUploaded:h.length,totalSize:Vt(h)}}async function Pu(e={}){let t=e.directory||process.cwd(),i;if(js(t))i=_.join(t,"netlify.toml");else{let s=await Tr(t);i=await Ls(t,$r(s))}if(e.siteId){let s=_.join(t,".env.local"),n="";if(await Bun.file(s).exists()){if(n=await Bun.file(s).text(),n=n.split(`
|
|
25
25
|
`).filter((r)=>!r.startsWith("NETLIFY_SITE_ID=")).join(`
|
|
26
26
|
`),n&&!n.endsWith(`
|
|
27
27
|
`))n+=`
|
|
28
28
|
`}n+=`NETLIFY_SITE_ID=${e.siteId}
|
|
29
29
|
`,await Bun.write(s,n)}return{configPath:i,siteId:e.siteId}}class lt extends Error{code;constructor(e,t){super(e);this.name="DeployError",this.code=t}}function I(e){let t=process.platform,i=t==="darwin"?"open":t==="win32"?"start":"xdg-open";Bun.spawn([i,e],{stdio:["ignore","ignore","ignore"]})}
|
|
30
|
-
export{
|
|
30
|
+
export{Ns,vi,Er,Ds,Ms,Sn,Vt,wi,Tr,$r,Ls,js,Au,Pu,lt};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{gp,Cl,io,zr,Gn,ao,co,Hr,Vr,Ur,lo,aa,El,ht}from"./chunk-40tswfe7.js";import"./chunk-twqzn21x.js";import"./chunk-hgry3mjd.js";import"./chunk-srq9fqq8.js";import"./chunk-rym0309c.js";import"./chunk-7adznted.js";import"./chunk-am2w363p.js";import"./chunk-5qtthtg3.js";import"./chunk-4s8zacxg.js";import{L}from"./chunk-f9zyf9n6.js";import"./chunk-mwnhdsbp.js";import"./chunk-25zmy8q6.js";import"./chunk-bsajk82t.js";import"./chunk-ce6zddpf.js";import"./chunk-zp79zkkd.js";export{gp as clearScriptScanCache,Hr as convertServerLoopAttributesToDirectives,ao as convertSignalDirectivesToAttributes,Vr as convertSignalLoopsToAttributes,Gn as extractClientSignalNames,L as extractExports,aa as findMarkupIndexOutsideScripts,zr as hasSignalsSyntax,io as parseLoopExpression,co as preEvalLiteralReactiveIfs,Ur as processScriptSetup,lo as processSignals,El as rewriteStxImportSpecifiers,Cl as scanScriptTags,ht as stripStxRuntimeImports};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ho,yo,bo,vo,Jr,Yr,_p,Cp,Ep,Tp,Zr,$p}from"./chunk-5qtthtg3.js";import"./chunk-bsajk82t.js";export{$p as generateDefaultRobotsTxt,Zr as generateRobotsTxt,Cp as generateSitemap,Ep as generateSitemapIndex,vo as injectSeoTags,Jr as metaDirective,ho as processMetaDirectives,bo as processSeoDirective,yo as processStructuredData,_p as registerSeoDirectives,Tp as scanForSitemapEntries,Yr as structuredDataDirective};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ee}from"./chunk-t79jfpv6.js";import R from"fs";import g from"path";import C from"crypto";var S=new Set(["webp","avif","jpeg","png"]),T=new Set(["cover","contain","fill","inside","outside"]),q=new Set([".jpg",".jpeg",".png",".webp",".avif",".gif"]),k=4096,D=80,U="cover";async function Oi(e,t){let r=t.routePath??"/_stx/img",h=new URL(e.url);if(h.pathname!==r)return null;let a=A(h,t);if(!a.ok)return new Response(a.error,{status:a.status,headers:{"Content-Type":"text/plain"}});let{srcFsPath:n,srcUrl:d,width:l,height:i,format:s,quality:u,fit:c}=a,m;try{m=R.statSync(n)}catch{return new Response(`Source image not found: ${d}`,{status:404,headers:{"Content-Type":"text/plain"}})}if(!m.isFile())return new Response("Not a file",{status:404,headers:{"Content-Type":"text/plain"}});let w=t.cacheDir??".stx/cache/img";await R.promises.mkdir(w,{recursive:!0});let b=`${n}:${m.mtimeMs}:${m.size}`,I=`${l}x${i}:${s}:${u}:${c}`,f=C.createHash("sha256").update(`${b}|${I}`).digest("hex").slice(0,16),o=g.join(w,`${f}.${s}`),p={"Content-Type":ee(s),"Cache-Control":"public, max-age=31536000, immutable",ETag:`"${f}"`,"X-Stx-Image-Cache":"HIT"};if(e.headers.get("if-none-match")===`"${f}"`)return new Response(null,{status:304,headers:p});let v=Bun.file(o);if(await v.exists())return new Response(v,{headers:p});try{let x=Buffer.from(await Bun.file(n).arrayBuffer()),{resizeAndConvert:P}=await L(),F=await P(x,{width:l,height:i,format:s,quality:u,fit:c});return await Bun.write(o,F),p["X-Stx-Image-Cache"]="MISS",new Response(new Uint8Array(F),{headers:p})}catch(x){let P=x.message;return new Response(`Image processing failed: ${P}`,{status:500,headers:{"Content-Type":"text/plain"}})}}function Lc(e){return async(t)=>await Oi(t,e)??new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain"}})}function A(e,t){let r=e.searchParams.get("src");if(!r)return{ok:!1,error:"Missing required param: src",status:400};if(!r.startsWith("/"))return{ok:!1,error:"src must be an absolute URL path (start with /)",status:400};if(r.startsWith("//"))return{ok:!1,error:"src must be a local path",status:400};let h=g.extname(r).toLowerCase();if(!q.has(h))return{ok:!1,error:`Unsupported source extension: ${h}`,status:400};let a=g.resolve(t.publicDir),n=g.resolve(a,r.slice(1));if(!n.startsWith(`${a}${g.sep}`)&&n!==a)return{ok:!1,error:"src is outside publicDir",status:400};let d=t.maxWidth??k,l=t.maxHeight??k,i=e.searchParams.get("w"),s=e.searchParams.get("h"),u=i?Number.parseInt(i,10):0,c=s?Number.parseInt(s,10):0;if(i&&(!Number.isFinite(u)||u<=0))return{ok:!1,error:"Invalid w (must be positive integer)",status:400};if(s&&(!Number.isFinite(c)||c<=0))return{ok:!1,error:"Invalid h (must be positive integer)",status:400};if(!i&&!s)return{ok:!1,error:"At least one of w or h is required",status:400};let m=Math.min(u||d,d),w=Math.min(c||l,l),b=e.searchParams.get("f")||"webp";if(!S.has(b))return{ok:!1,error:`Invalid f (must be one of: ${[...S].join(", ")})`,status:400};let I=b,f=e.searchParams.get("q"),o=f?Number.parseInt(f,10):t.defaultQuality??D;if(!Number.isFinite(o)||o<1||o>100)return{ok:!1,error:"Invalid q (must be 1-100)",status:400};let y=e.searchParams.get("fit")||t.defaultFit||U;if(!T.has(y))return{ok:!1,error:`Invalid fit (must be one of: ${[...T].join(", ")})`,status:400};return{ok:!0,srcFsPath:n,srcUrl:r,width:m,height:w,format:I,quality:o,fit:y}}async function L(){return await import("./chunk-2asdbd5e.js")}
|
|
3
|
+
export{Oi,Lc};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{qc,Gc,Kc,Xc,Jc,Yc,Zc,Qc,el,tl,td}from"./chunk-hb3edeq9.js";export{qc as createIslandRegistry,td as default,tl as generateIslandManifest,Kc as generatePartialHydrationCSS,Yc as hydrateAll,Jc as hydrateByStrategy,Xc as hydrateIsland,Zc as isHydrated,Qc as onHydrated,Gc as processPartialHydrationDirectives,el as processStaticDirectives};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var g=0;function p(){return`async-${++g}-${Date.now().toString(36)}`}function
|
|
2
|
+
var g=0;function p(){return`async-${++g}-${Date.now().toString(36)}`}function $d(e,t={},c){let o=/@async\s*\(([^)]*)\)\s*([\s\S]*?)@error\s*([\s\S]*?)@endasync/gi,i=/@async\s*\(([^)]*)\)\s*([\s\S]*?)@endasync/gi,n=e;return n=n.replace(o,(r,s,a,d)=>{let l=p(),y=u(s);return m(l,y,a.trim(),d.trim())}),n=n.replace(i,(r,s,a)=>{let d=p(),l=u(s);return m(d,l,a.trim(),'<div class="stx-async-error">Failed to load component</div>')}),n}function u(e){let t={component:"",timeout:30000,delay:200,suspensible:!0,retries:0},c=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,o;while((o=c.exec(e))!==null){let i=o[1],n=o[2]||o[3],r=o[4],s=o[5];switch(i){case"component":t.component=n||s||"";break;case"timeout":t.timeout=r?parseInt(r,10):30000;break;case"delay":t.delay=r?parseInt(r,10):200;break;case"suspensible":t.suspensible=s==="true";break;case"retries":t.retries=r?parseInt(r,10):0;break;case"loadingComponent":t.loadingComponent=n||s;break;case"errorComponent":t.errorComponent=n||s;break}}return t}function m(e,t,c,o){let{component:i,timeout:n,delay:r,suspensible:s,retries:a}=t;return`
|
|
3
3
|
<div class="stx-async-component" data-async-id="${e}" data-component="${i}" data-status="pending">
|
|
4
4
|
<div class="stx-async-loading" data-async-loading="${e}">
|
|
5
5
|
${c}
|
|
@@ -226,7 +226,7 @@ catch (error) {
|
|
|
226
226
|
loadComponent();
|
|
227
227
|
})();
|
|
228
228
|
</script>
|
|
229
|
-
`}function
|
|
229
|
+
`}function Rd(e){return{__asyncComponent:!0,...typeof e==="function"?{loader:e}:e}}function Ad(e){return typeof e==="object"&&e!==null&&"__asyncComponent"in e&&e.__asyncComponent===!0}function Pd(){return`
|
|
230
230
|
/* STX Async Component Styles */
|
|
231
231
|
.stx-async-component {
|
|
232
232
|
position: relative;
|
|
@@ -300,7 +300,7 @@ catch (error) {
|
|
|
300
300
|
background-size: 200% 100%;
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
|
-
`}function
|
|
303
|
+
`}function Id(){return`
|
|
304
304
|
// STX Async Component Runtime
|
|
305
305
|
(function() {
|
|
306
306
|
if (typeof window === 'undefined') return;
|
|
@@ -355,4 +355,4 @@ catch (error) {
|
|
|
355
355
|
console.log('[stx] Async component runtime initialized');
|
|
356
356
|
})();
|
|
357
357
|
`}
|
|
358
|
-
export{
|
|
358
|
+
export{$d,Rd,Ad,Pd,Id};
|
|
@@ -159,7 +159,7 @@ else {
|
|
|
159
159
|
stxIslands.initIslands();
|
|
160
160
|
}
|
|
161
161
|
})();
|
|
162
|
-
</script>`}function b(e){let t=e.match(/<([A-Z][a-zA-Z0-9]+)[\s/>]/);if(t)return t[1];let n=e.match(/<([a-z][a-z0-9]*-[a-z0-9-]+)[\s/>]/);if(n)return n[1];return null}function w(e,t){let n={},r=/:([a-zA-Z_][\w-]*)\s*=\s*"([^"]+)"/g,i;while((i=r.exec(e))!==null){let d=i[1],o=i[2];if(o in t)n[d]=t[o];else n[d]=o}return n}function
|
|
162
|
+
</script>`}function b(e){let t=e.match(/<([A-Z][a-zA-Z0-9]+)[\s/>]/);if(t)return t[1];let n=e.match(/<([a-z][a-z0-9]*-[a-z0-9-]+)[\s/>]/);if(n)return n[1];return null}function w(e,t){let n={},r=/:([a-zA-Z_][\w-]*)\s*=\s*"([^"]+)"/g,i;while((i=r.exec(e))!==null){let d=i[1],o=i[2];if(o in t)n[d]=t[o];else n[d]=o}return n}function qc(){let e=new Map;return{islands:e,register(t){e.set(t.id,t)},get(t){return e.get(t)},async hydrate(t){let n=e.get(t);if(!n||n.hydrated)return;if(n.hydrated=!0,typeof window<"u"&&typeof window.dispatchEvent==="function")window.dispatchEvent(new CustomEvent("stx:hydrate",{detail:{id:t,component:n.component}}))},async hydrateAll(){let t=Array.from(e.values()).filter((n)=>!n.hydrated).map((n)=>this.hydrate(n.id));await Promise.all(t)}}}function I(e){return`
|
|
163
163
|
<script data-hydrate="${e}">
|
|
164
164
|
(function() {
|
|
165
165
|
const island = document.querySelector('[data-island="${e}"]');
|
|
@@ -311,7 +311,7 @@ else {
|
|
|
311
311
|
});
|
|
312
312
|
})();
|
|
313
313
|
</script>
|
|
314
|
-
`}function
|
|
314
|
+
`}function Gc(e,t={},n){let r=e,i=!1,d=/@client:(load|idle|visible|media|only|hover|event)/i.test(e);if(r=u(r,"load",t),r=u(r,"idle",t),r=u(r,"visible",t),r=u(r,"media",t),r=M(r),r=u(r,"hover",t),r=u(r,"event",t),i=d&&r!==e,i)r+=`
|
|
315
315
|
`+v();return r}function u(e,t,n){let r=new RegExp(`@client:${t}(?:\\s*\\(([^)]*)\\))?\\s*([\\s\\S]*?)@endclient`,"gi");return e.replace(r,(i,d,o)=>{let a={strategy:t};if(d)try{let E=d.split(",").map((h)=>h.trim());for(let h of E){let[m,g]=h.split(":").map((p)=>p.trim());if(m&&g){let p=g.replace(/^['"]|['"]$/g,"");a[m]=p}}}catch{}let s=`island-${Math.random().toString(36).substring(2,9)}`,y=b(o.trim()),f=w(o.trim(),n),c=[];if(a.rootMargin)c.push(`data-root-margin="${a.rootMargin}"`);if(a.threshold!==void 0)c.push(`data-threshold="${a.threshold}"`);if(a.media)c.push(`data-media="${a.media}"`);if(a.event)c.push(`data-event="${a.event}"`);if(y)c.push(`data-component="${y}"`);let x=Object.keys(f).length>0?`
|
|
316
316
|
<script type="application/json" data-island-props="${s}">${JSON.stringify(f)}</script>`:"",l="";switch(t){case"load":l=I(s);break;case"idle":l=L(s,a);break;case"visible":l=C(s,a);break;case"media":l=S(s,a);break;case"hover":l=k(s);break;case"event":l=H(s,a);break}return`
|
|
317
317
|
<div data-island="${s}"
|
|
@@ -342,7 +342,7 @@ else {
|
|
|
342
342
|
}
|
|
343
343
|
})();
|
|
344
344
|
</script>
|
|
345
|
-
`})}function
|
|
345
|
+
`})}function Kc(){return`
|
|
346
346
|
/* Island base styles */
|
|
347
347
|
.stx-island {
|
|
348
348
|
display: contents;
|
|
@@ -383,9 +383,9 @@ else {
|
|
|
383
383
|
.stx-island.hydrated {
|
|
384
384
|
opacity: 1;
|
|
385
385
|
}
|
|
386
|
-
`}function
|
|
386
|
+
`}function Xc(e){if(typeof window>"u")return;let t=document.querySelector(`[data-island="${e}"]`);if(!t||t.classList.contains("hydrated"))return;t.classList.add("hydrated"),t.dispatchEvent(new CustomEvent("stx:hydrated",{bubbles:!0}))}function Jc(e){if(typeof window>"u")return;document.querySelectorAll(`[data-strategy="${e}"]:not(.hydrated)`).forEach((n)=>{n.classList.add("hydrated"),n.dispatchEvent(new CustomEvent("stx:hydrated",{bubbles:!0}))})}function Yc(){if(typeof window>"u")return;document.querySelectorAll(".stx-island:not(.hydrated)").forEach((t)=>{t.classList.add("hydrated"),t.dispatchEvent(new CustomEvent("stx:hydrated",{bubbles:!0}))})}function Zc(e){if(typeof window>"u")return!1;return document.querySelector(`[data-island="${e}"]`)?.classList.contains("hydrated")??!1}function Qc(e){return new Promise((t)=>{if(typeof window>"u"){t();return}let n=document.querySelector(`[data-island="${e}"]`);if(!n){t();return}if(n.classList.contains("hydrated")){t();return}n.addEventListener("stx:hydrated",()=>t(),{once:!0})})}function el(e){return e.replace(/@static\s*([\s\S]*?)@endstatic/gi,(t,n)=>`<div class="stx-static">${n.trim()}</div>`)}function tl(e){let t=e.map((n)=>({id:n.id,component:n.component,strategy:n.options.strategy,props:n.props}));return`
|
|
387
387
|
<script type="application/json" id="stx-island-manifest">
|
|
388
388
|
${JSON.stringify(t)}
|
|
389
389
|
</script>
|
|
390
|
-
`}var
|
|
391
|
-
export{
|
|
390
|
+
`}var td={processPartialHydrationDirectives:Gc,processStaticDirectives:el,generatePartialHydrationCSS:Kc,generateIslandManifest:tl,createIslandRegistry:qc,hydrateIsland:Xc,hydrateByStrategy:Jc,hydrateAll:Yc,isHydrated:Zc,onHydrated:Qc};
|
|
391
|
+
export{qc,Gc,Kc,Xc,Jc,Yc,Zc,Qc,el,tl,td};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{i}from"./chunk-
|
|
2
|
+
import{i}from"./chunk-7mvz972c.js";function y(e,n,s=240){return e.slice(n,n+s)}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 s=e.indexOf("(",n);if(s===-1)return!0;let o=e.slice(s+1,e.indexOf(")",s)+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 s=1;for(let o=0;o<n;o++)if(e[o]===`
|
|
3
3
|
`)s++;return s}function b(e,n){let s=e.lastIndexOf(`
|
|
4
4
|
`,n)+1,o=e.indexOf(`
|
|
5
5
|
`,n);return e.slice(s,o===-1?e.length:o).trim().slice(0,120)}function S(e,n){let s=e.slice(0,n),o=s.lastIndexOf("function"),l=s.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,s){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(s.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,s){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)){s.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()===""){s.push({file:n,line:h,rule:"tooltip",applied:!1,snippet:f,reason:/\bx-tooltip[=\s]/.test(u)?"already has x-tooltip":"empty title"});continue}s.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=(s)=>s.replace(/[^\n]/g," ");return e.replace(/\/\*[\s\S]*?\*\//g,n).replace(/\/\/[^\n]*/g,n)}function m(e,n=!1){let s=R(e);return(n?F(s):i(s)).replace(/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi,(l,r)=>/\bclient\b/i.test(r)?l:l.replace(/[^\n]/g," "))}function O(e,n,s,o){let l=m(e),r=m(e,!0);for(let t of v){if(!s.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 s=n.rules??C,o=n.file??"<source>",l=[];O(e,o,s,l);let r=e;if(s.includes("confirm"))r=A(r,o,l);if(s.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 s=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(s.length>0){r.push(n?`Rewrote ${s.length} site(s):`:`Would rewrite ${s.length} site(s) (pass --fix):`);for(let t of s)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}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{w}from"./chunk-
|
|
2
|
+
import{w}from"./chunk-bsajk82t.js";function Ke(e,r){let n=v(e,r);return n.ok?{expression:n.expression,endPos:n.endPos}:null}function v(e,r){let n=r;while(n<e.length&&/\s/.test(e[n]))n++;if(e[n]!=="(")return{ok:!1,reason:"missing-open-paren",pos:n};let c=w(e,"(",")",n);if(c===-1)return{ok:!1,reason:"unclosed-paren",pos:n};return{ok:!0,expression:e.slice(n+1,c),endPos:c+1}}function y(e,r){let n=e.lastIndexOf("<",r);if(n===-1)return!1;return n>e.lastIndexOf(">",r)}function yt(e,r,n,c){let o=1,i=c,u=new RegExp(`@${r}\\s*\\(`,"g"),a=new RegExp(`@${n}(?![a-z])`,"g");while(i<e.length&&o>0){u.lastIndex=i,a.lastIndex=i;let p=u.exec(e),t=a.exec(e),s=p?p.index:1/0,f=t?t.index:1/0;if(s<f)o++,i=s+p[0].length;else if(f<1/0){if(o--,o===0)return f;i=f+t[0].length}else break}return-1}function P(e,r){let n=e.slice(r).match(/^@if\s*/);if(!n)return null;let c=r+n[0].length,o=Ke(e,c);if(!o)return null;let i=o.endPos,u=yt(e,"if","endif",i);if(u===-1)return null;let a=e.slice(i,u),p=[],t=0,s="if",f=o.expression,l=0,x=0;while(t<a.length){let h=a.indexOf("@",t);if(h===-1)break;t=h;let d=a.substring(h);if(y(a,h)){t++;continue}if(/^@if\s*\(/.test(d)){x++,t++;continue}if(/^@endif(?![a-z])/.test(d)){x--,t+=6;continue}if(x===0){let g=d.match(/^@elseif\s*/);if(g){p.push({type:s,condition:f,content:a.substring(l,t),start:i+l,end:i+t});let m=t+g[0].length,b=Ke(a,m);if(!b){t++;continue}s="elseif",f=b.expression,t=b.endPos,l=t;continue}else if(/^@else(?![a-z])/.test(d)){p.push({type:s,condition:f,content:a.substring(l,t),start:i+l,end:i+t}),s="else",f=void 0,t+=5,l=t;continue}}t++}return p.push({type:s,condition:f,content:a.slice(l),start:i+l,end:i+a.length}),{fullMatch:e.slice(r,u+6),branches:p,start:r,end:u+6}}function tn(e){let r=[],n=/@if\s*\(/g,c=n.exec(e);while(c!==null){if(r.some((u)=>c.index>u.start&&c.index<u.end)){c=n.exec(e);continue}let i=P(e,c.index);if(i)r.push(i),n.lastIndex=i.end;c=n.exec(e)}return r}function Wr(e,r,n){let c=[],o=new RegExp(`@${r}\\s*\\(`,"g"),i=o.exec(e);while(i!==null){if(c.some((d)=>i.index>d.start&&i.index<d.end)){i=o.exec(e);continue}let a=i.index,p=a+i[0].length-1,t=w(e,"(",")",p);if(t===-1){i=o.exec(e);continue}let s=e.slice(p+1,t),f=t+1,l=yt(e,r,n,f);if(l===-1){i=o.exec(e);continue}let x=e.slice(f,l),h=l+`@${n}`.length;c.push({fullMatch:e.slice(a,h),name:r,params:s,content:x,start:a,end:h}),o.lastIndex=h,i=o.exec(e)}return c}function uo(e,r){let n=e.slice(r).match(/^@switch\s*/);if(!n)return null;let c=r+n[0].length,o=Ke(e,c);if(!o)return null;let i=o.endPos,u=yt(e,"switch","endswitch",i);if(u===-1)return null;let a=e.slice(i,u),p=[],t=0,s=null,f=0;while(t<a.length){let l=a.slice(t),x=l.match(/^@switch\s*\(/),h=l.match(/^@endswitch(?![a-z])/);if(x){if(f++,s)s.content+=x[0];t+=x[0].length;continue}if(h){if(f--,s)s.content+=h[0];t+=h[0].length;continue}if(f>0){if(s)s.content+=a[t];t++;continue}let d=l.match(/^@case\s*/),g=l.match(/^@default(?![a-z])/),m=l.match(/^@break(?![a-z])/);if(d&&l.startsWith("@case")){if(s)p.push(s);let b=t+d[0].length,E=Ke(a,b);if(!E){t++;continue}s={type:"case",value:E.expression,content:""},t=E.endPos}else if(g&&l.startsWith("@default")){if(s)p.push(s);s={type:"default",content:""},t+=g[0].length}else if(m&&l.startsWith("@break"))t+=m[0].length;else{if(s)s.content+=a[t];t++}}if(s)p.push(s);return{fullMatch:e.slice(r,u+10),expression:o.expression,cases:p,start:r,end:u+10}}export{Ke,yt,tn,Wr,uo};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{x}from"./chunk-
|
|
3
|
-
${i.trim()}`)}catch(i){console.warn(`[stx] Failed to load composable ${r}:`,i)}if(N.length===0||B.size===0)return
|
|
2
|
+
import{x}from"./chunk-zp79zkkd.js";import{T,vn}from"./chunk-ce6zddpf.js";import{rn,y,b,S,X}from"./chunk-f9zyf9n6.js";import{o}from"./chunk-srq9fqq8.js";import{Ce,Xt,Jt,Yt}from"./chunk-rv39s5az.js";import{ht}from"./chunk-40tswfe7.js";import{pt,In,Wt,ie}from"./chunk-0nfqgv4n.js";import{C,br}from"./chunk-506mv7hb.js";import w from"path";var v=new Map,k=new Map,A=y(64),E=new Map,Z=["composables","functions"];function z(t){let n=w.basename(t,".ts");return n==="index"||n==="types"||t.endsWith(".d.ts")}async function q(t){if(t)return w.resolve(t);let n=`<default>:${process.cwd()}`,a=E.get(n);if(a!==void 0)return a;let e=await Q();if(e!==null)E.set(n,e);return e}async function Q(){let t=await o(),n=t.root||process.cwd(),a=t.composablesDir;if(a)return w.resolve(n,a);for(let e of Z){let s=w.resolve(n,e);try{let d=new Bun.Glob("**/*.ts");for await(let c of d.scan({cwd:s,absolute:!0}))if(!z(c))return s}catch{}}return null}async function G(t){let n=Array.isArray(t)?t:t?[w.resolve(t)]:(await o())._layerComposableDirs??[await q()].filter((e)=>!!e),a=new Map;for(let e of n){let s=new Bun.Glob("**/*.ts");try{for await(let d of s.scan({cwd:e,absolute:!0})){let c=w.relative(e,d);if(!z(d)&&!a.has(c))a.set(c,d)}}catch{}}return{key:n.join("\x00"),files:[...a.values()].sort()}}async function Hs(t){let{files:n}=await G(t),a=X({loader:"ts",target:"browser",define:S()}),e=[];for(let s of n)try{let d=await Bun.file(s).text(),c=a.scan(d).exports.filter((m)=>m!=="default");if(c.length>0)e.push({file:s,names:c})}catch{}return e}function V(t,n){return new RegExp(`\\b${n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(t)}function J(t,n){let a=new Set(t.match(/\w+/g)),e=new Set;for(let s of n)if(/^\w+$/.test(s)?a.has(s):V(t,s))e.add(s);return e}var U=y(64);function Y(t,n){let a=b(t,n.size),e=U.get(a);if(e)return e;let s;try{s=rn(t,n)}catch{s=J(t,n)}let d=[...t.matchAll(/(?:const|let|var)\s*\{([^}]*)\}\s*=\s*window\.__composables\u0008/g),...t.matchAll(/import\s*\{([^}]*)\}\s*from\s*['"]@composables['"]/g)];for(let c of d)for(let m of c[1].split(",")){let p=m.trim().split(/\s*(?::|\u0008as\u0008)\s*/)[0];if(p&&n.has(p))s.add(p)}return U.set(a,s),s}function ee(t,n,a){let e=new Map;for(let{file:u,names:l}of t)for(let f of l)if(!e.has(f))e.set(f,u);let s=(u)=>{let l=[];for(let f of J(u,e.keys()))l.push(e.get(f));return l},d=new Set(e.keys()),c=(u)=>{let l=[];for(let f of Y(u,d))l.push(e.get(f));return l},m=new Set,p=a.flatMap((u,l)=>l===0?s(u):c(u));while(p.length>0){let u=[];for(let l of p){if(m.has(l))continue;m.add(l);for(let f of c(n.get(l)??""))if(!m.has(f))u.push(f)}p=u}return m}async function Hd(t,n,a){let{key:e,files:s}=await G(t);if(!e)return null;let d=()=>[...new Set([...s,...s.flatMap((r)=>Ce(r))])],c=pt(d());if(s.length===0)return ie(v,e,c,""),null;s.sort();let m=X({loader:"ts",target:"browser",define:S()}),p=Wt(k,e,c);if(!p){let r=new Map,i=[];for(let g of s)try{let h=await Bun.file(g).text();r.set(g,h);let _=m.scan(h).exports.filter((W)=>W!=="default");if(_.length>0)i.push({file:g,names:_})}catch{r.set(g,"")}p=ie(k,e,c,{codeByFile:r,modules:i})}let{codeByFile:u,modules:l}=p,f;if(n===void 0)f=new Set(s);else{let r=a?[n,...a]:[n],i=b(r.join("\x00"),e,r.length,c),g=A.get(i);if(f=g??ee(l,u,r),!g)A.set(i,f)}if(f.size===0)return null;let I=s.filter((r)=>f.has(r)),M=`${e}\x00${I.join("\x00")}\x00${Jt()}`,F=Wt(v,M,c);if(F!==void 0)return F||null;let N=[],B=new Set,R=new Set;for(let r of I)try{let i=u.get(r)??await Bun.file(r).text(),g=w.basename(r,".ts");for(let _ of i.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(_[1])R.add(_[1]);let h=[];try{for(let _ of m.scan(i).exports)if(_!=="default")B.add(_),h.push(_)}catch{}if(i=T(i),Xt(i))i=await Yt(i,r,{projectRoot:process.cwd(),externalizeUserModules:!1,expose:h}),i=ht(i);i=vn(i),i=i.replace(/^export\s+(default\s+)?/gm,""),i=m.transformSync(i),N.push(`// Composable: ${g}
|
|
3
|
+
${i.trim()}`)}catch(i){console.warn(`[stx] Failed to load composable ${r}:`,i)}if(N.length===0||B.size===0)return ie(v,M,c,""),null;let L=[...B].map((r)=>` try { if (!(${JSON.stringify(r)} in __c)) __c[${JSON.stringify(r)}] = ${r}; } catch (e) {}`).join(`
|
|
4
4
|
`),j=JSON.stringify([...B]),D=N.join(`
|
|
5
5
|
|
|
6
|
-
`),
|
|
6
|
+
`),H=x.filter((r)=>!R.has(r)&&new RegExp(`\\b${r}\\b`).test(D)).map((r)=>`var ${r} = __stx[${JSON.stringify(r)}];`).join(`
|
|
7
7
|
`),P=JSON.stringify(new Bun.CryptoHasher("md5").update(`${j}\x00${D}`).digest("hex").slice(0,12)),K=`;(function(){
|
|
8
8
|
var __bundles = window.__stxComposableBundles || (window.__stxComposableBundles = {});
|
|
9
9
|
if (__bundles[${P}]) return;
|
|
@@ -12,9 +12,9 @@ var __published = window.__stxComposableGlobals || (window.__stxComposableGlobal
|
|
|
12
12
|
window.__composables = window.__composables || {};
|
|
13
13
|
var __c = window.__composables;
|
|
14
14
|
var __stx = window.stx || {};
|
|
15
|
-
${W}
|
|
16
|
-
${D}
|
|
17
15
|
${H}
|
|
16
|
+
${D}
|
|
17
|
+
${L}
|
|
18
18
|
var __names = ${j};
|
|
19
19
|
for (var __i = 0; __i < __names.length; __i++) {
|
|
20
20
|
var __n = __names[__i];
|
|
@@ -29,5 +29,5 @@ ${H}
|
|
|
29
29
|
window[__n] = __c[__n];
|
|
30
30
|
__published[__n] = true;
|
|
31
31
|
}
|
|
32
|
-
})();`,O=C()?
|
|
33
|
-
export{
|
|
32
|
+
})();`,O=C()?br(K):K;return c=pt(d()),ie(v,M,c,O),O}function Vd(){v.clear(),In(),k.clear(),A.clear(),E.clear()}
|
|
33
|
+
export{Hs,Hd,Vd};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
`);if(!await Bun.file(o).exists()||await Bun.file(o).text()!==f)await Bun.write(o,f);return o}async function
|
|
4
|
-
`)}`);let a=e.outputs.find((u)=>u.kind==="entry-point");if(!a)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await a.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),a),f.push({...t,filePath:n})}return f}function j(s,l){let o=s.map((i)=>({route:i,...
|
|
5
|
-
`));let u=n.outputs.find((d)=>d.kind==="entry-point");if(!u||n.outputs.length!==1)throw Error(`Unsupported API bundle output: ${p.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await u.text()).toString("base64")}`)).default})(f))}catch(t){return console.error("[stx] API discovery failed:",t),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function
|
|
6
|
-
export{Zt,
|
|
2
|
+
import{ce}from"./chunk-4s8zacxg.js";import{je,A}from"./chunk-25zmy8q6.js";import{va}from"./chunk-am2w363p.js";import{c}from"./chunk-v14rq8b4.js";import S from"fs";import m from"path";import{pathToFileURL as O}from"url";var E=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],P=new Set;function Zt(s,l={}){let o=m.resolve(s,l.dir??"server/api"),i=[],f=new Map;if(!S.existsSync(o))return i;let t=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:o})).sort();for(let e of t){if(e.endsWith(".d.ts"))continue;let p=e.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),n=p.pop(),u=n.lastIndexOf("."),d=u>=0?n.slice(u+1):"get",g=d.toUpperCase();if(!E.includes(g)||d!==d.toLowerCase())throw Error(`Unsupported API method suffix in ${e}; use ${E.map((y)=>y.toLowerCase()).join(", ")}`);if(u>=0)n=n.slice(0,u);if(n!=="index")p.push(n);let r=new Set,h=p.map((y,I)=>{let v=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(y);if(v){if(r.has(v[2])||v[1]&&I!==p.length-1)throw Error(`Invalid API parameter in ${e}`);return r.add(v[2]),`:${v[2]}${v[1]?"*":""}`}if(!/^[\w-]+$/.test(y))throw Error(`Unsupported API path segment ${y} in ${e}`);return y}),w=`/api${h.length?`/${h.join("/")}`:""}`,x=`${g} ${w.replace(/:\w+/g,":param")}`;if(f.has(x))throw Error(`Ambiguous API route ${g} ${w}: ${f.get(x)} and ${e}`);f.set(x,e);let R=m.join(o,e);P.add(m.resolve(R)),P.add(S.realpathSync(R)),i.push({pattern:w,method:g,filePath:R})}return i.sort((e,a)=>{let p=e.pattern.split("/"),n=a.pattern.split("/"),u=(d)=>d?.endsWith("*")?0:d?.startsWith(":")?1:2;for(let d=0;d<Math.max(p.length,n.length);d++){let g=u(n[d])-u(p[d]);if(g)return g}return e.pattern.localeCompare(a.pattern)||e.method.localeCompare(a.method)})}async function Ks(s,l){let o=c(s,"api-types.d.ts"),i=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let t of l){let e=`./${m.relative(m.dirname(o),t.filePath).replace(/\\/g,"/")}`,{params:a}=ce(t.pattern);i.push(` ${JSON.stringify(`${t.method} ${t.pattern}`)}: { params: { ${a.map((p)=>`${JSON.stringify(p)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(e)}).default>> }`)}i.push(" }","}","export {}","");let f=i.join(`
|
|
3
|
+
`);if(!await Bun.file(o).exists()||await Bun.file(o).text()!==f)await Bun.write(o,f);return o}async function Xs(s,l,o={}){let i=Zt(s,o);await Ks(s,i);let f=[];for(let t of i){let e=await Bun.build({entrypoints:[t.filePath],target:"bun",format:"esm",minify:!1,splitting:!1});if(!e.success)throw Error(`API build failed for ${t.filePath}: ${e.logs.join(`
|
|
4
|
+
`)}`);let a=e.outputs.find((u)=>u.kind==="entry-point");if(!a)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await a.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),a),f.push({...t,filePath:n})}return f}function j(s,l){let o=s.map((i)=>({route:i,...ce(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,a=(r)=>r.replace(/:\w+/g,":param"),p=t.filter((r)=>a(r.route.pattern)===a(e)),n=i.method,u=p.find((r)=>r.route.method===n)??(n==="HEAD"?p.find((r)=>r.route.method==="GET"):void 0);if(!u){let r=new Set(p.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=u.regex.exec(f),g=Object.create(null);try{u.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(u.route);if(typeof r!=="function")throw Error(`API endpoint ${u.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Js(s,l){return j(l,async(o)=>(await import(O(m.resolve(s,o.filePath)).href)).default)}async function op(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=Zt(s,o);return await Ks(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=Zt(s,o);await Ks(s,t);let{loadStxConfig:e}=await import("./chunk-2881tcqt.js"),a=A((await e(s)).runtimeConfig);return await je(a,()=>j(t,async(p)=>{let n=await Bun.build({entrypoints:[p.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
|
|
5
|
+
`));let u=n.outputs.find((d)=>d.kind==="entry-point");if(!u||n.outputs.length!==1)throw Error(`Unsupported API bundle output: ${p.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await u.text()).toString("base64")}`)).default})(f))}catch(t){return console.error("[stx] API discovery failed:",t),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function Ys(s,l,o){if(va(s))return!0;let i=/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/;if(i.test(m.basename(s)))return!0;try{if(i.test(m.basename(S.realpathSync(s))))return!0}catch{}if(P.has(m.resolve(s)))return!0;if(!o)return!1;let f=m.resolve(l,typeof o==="object"?o.dir??"server/api":"server/api"),t=(a)=>{try{return S.realpathSync(a)}catch{return m.resolve(a)}},e=t(s);return[f,m.resolve(l,"server"),m.resolve(l,".output/server")].some((a)=>{let p=t(a);return e===p||e.startsWith(`${p}${m.sep}`)})}
|
|
6
|
+
export{Zt,Ks,Xs,Js,op,Ys};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Broadcast as s,BroadcastServer as h}from"ts-broadcasting";import{channel as
|
|
3
|
-
export{
|
|
2
|
+
import{Broadcast as s,BroadcastServer as h}from"ts-broadcasting";import{channel as qu}from"ts-broadcasting";import{Broadcast as Gu,BroadcastServer as Ku}from"ts-broadcasting";var e=null,u=[];function ju(){return e}async function Bu(n){if(e)return e;let t=n.driver??"bun",r=n.host??"0.0.0.0",c=n.port??6001,l=n.scheme??"ws",a={verbose:n.verbose??!1,driver:t,default:t,connections:{[t]:{driver:t,host:r,port:c,scheme:l}}};return e=new h(a),s.setServer(e),await e.start(),e}async function Fu(){for(let n of u)clearInterval(n);if(u.length=0,!e)return;await e.stop(),e=null}async function zu(n){let t=await import(n),r=t.default??t;if(typeof r!=="function")throw Error(`routes/channels.ts must export a default function, got ${typeof r}`);let c=0;return r({channel(a,o){if(c++,o.authorize&&e)e.channels.channel(a,o.authorize);if(o.interval&&o.data){let d=o.event??`${a}.updated`,p=o.data,v=setInterval(async()=>{try{let g=await p();Mc(a,d,g)}catch{}},o.interval);u.push(v)}}}),c}var f=!1;function i(){if(e)return!0;if(!f)f=!0,console.warn("[stx] broadcast() called before server started \u2014 messages will be sent once broadcasting is ready");return!1}function Mc(n,t,r){if(!i())return;s.send(n,t,r)}function Hu(n,t,r){if(!i())return;s.toUser(n,t,r)}function Vu(n,t,r){if(!i())return;s.toUsers(n,t,r)}function Uu(n,t,r){if(!i())return;s.send(`private-${n}`,t,r)}function Wu(n,t,r){if(!i())return;s.presence(n,t,r)}
|
|
3
|
+
export{ju,Bu,Fu,zu,Mc,Hu,Vu,Uu,Wu,qu,Gu,Ku};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Hn,s}from"./chunk-aet1pgw7.js";import"./chunk-kdebh22m.js";import"./chunk-rr527jt6.js";import"./chunk-xcsyqwxf.js";import"./chunk-bkkpq8dx.js";import"./chunk-7j1zgrnf.js";import"./chunk-v6peecfp.js";import"./chunk-40tswfe7.js";import{he}from"./chunk-twqzn21x.js";import"./chunk-hgry3mjd.js";import"./chunk-4b9s7wgy.js";import"./chunk-srq9fqq8.js";import"./chunk-rym0309c.js";import"./chunk-7adznted.js";import"./chunk-am2w363p.js";import"./chunk-5qtthtg3.js";import"./chunk-4s8zacxg.js";import{Ae,gs,ms}from"./chunk-f9zyf9n6.js";import"./chunk-mwnhdsbp.js";import"./chunk-25zmy8q6.js";import"./chunk-bsajk82t.js";import"./chunk-ce6zddpf.js";import"./chunk-zp79zkkd.js";export{Hn as buildModulesTag,he as injectRouterScript,s as processDirectives,gs as processJsonDirective,ms as processOnceDirective,Ae as validateClientScript};
|