@stacksjs/stx 0.2.795 → 0.2.798
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-y64f5t74.js → chunk-0beyn8ak.js} +5 -5
- package/dist/{chunk-jmbh26gv.js → chunk-0gsq8gps.js} +1 -1
- package/dist/chunk-0xnvjw7s.js +2 -0
- package/dist/chunk-1wyccmsr.js +2 -0
- package/dist/{chunk-4s0ye933.js → chunk-20yz8bjp.js} +2 -2
- package/dist/{chunk-bzhzp4f4.js → chunk-2ws2qe1k.js} +2 -2
- package/dist/{chunk-2bvaakcv.js → chunk-2z2bq2at.js} +3 -3
- package/dist/chunk-31qjy9xr.js +2 -0
- package/dist/chunk-33devn0s.js +2 -0
- package/dist/{chunk-baj6w8ja.js → chunk-33vr7x2t.js} +3 -3
- package/dist/chunk-33wpv2n1.js +2 -0
- package/dist/{chunk-aksrh8je.js → chunk-3mby4nes.js} +3 -3
- package/dist/chunk-3p5gxc6t.js +2 -0
- package/dist/{chunk-88acqv2r.js → chunk-3x598qjt.js} +4 -4
- package/dist/chunk-4hgz9dkv.js +2 -0
- package/dist/{chunk-7k6hd10j.js → chunk-4sesw88b.js} +5 -5
- package/dist/{chunk-624xpap6.js → chunk-4v50nafp.js} +13 -13
- package/dist/chunk-5kc9kjaa.js +2 -0
- package/dist/{chunk-2e5tvryz.js → chunk-5wwcgze3.js} +2 -2
- package/dist/chunk-5xd53dwe.js +2 -0
- package/dist/chunk-5y6518h8.js +2 -0
- package/dist/chunk-5y77pe7b.js +2 -0
- package/dist/chunk-6a97a9wk.js +2 -0
- package/dist/{chunk-xqjat573.js → chunk-6b5zhtb3.js} +2 -2
- package/dist/chunk-6hre8cg4.js +2 -0
- package/dist/{chunk-vpzdqbw7.js → chunk-6m4y5dh5.js} +6 -6
- package/dist/chunk-6pyweb05.js +2 -0
- package/dist/chunk-6tp7ys77.js +2 -0
- package/dist/chunk-6zxzr20d.js +2 -0
- package/dist/chunk-75ctpxr3.js +2 -0
- package/dist/{chunk-tmfrq4nq.js → chunk-7bxnjr3b.js} +7 -7
- package/dist/chunk-7gw96jpj.js +2 -0
- package/dist/chunk-7m4eesp0.js +2 -0
- package/dist/chunk-7na8bets.js +2 -0
- package/dist/{chunk-6s9bk98p.js → chunk-7yb82rm6.js} +2 -2
- package/dist/{chunk-dstzvtvk.js → chunk-810r5dk3.js} +3 -3
- package/dist/{chunk-njk5db1q.js → chunk-89jn2jmf.js} +4 -4
- package/dist/{chunk-nyer6v3y.js → chunk-8bzq2z0m.js} +5 -5
- package/dist/chunk-8k2n6abg.js +2 -0
- package/dist/chunk-8vqs94f3.js +2 -0
- package/dist/{chunk-3em44jbm.js → chunk-91htcq62.js} +2 -2
- package/dist/chunk-9736003n.js +2 -0
- package/dist/{chunk-p3ej3954.js → chunk-9b6896tb.js} +2 -2
- package/dist/{chunk-pnddmgjf.js → chunk-9k6tza24.js} +7 -7
- package/dist/chunk-9w33k6f7.js +2 -0
- package/dist/{chunk-g4n0bjfb.js → chunk-9x62j5f0.js} +10 -10
- package/dist/{chunk-1q16p7t2.js → chunk-a1ba9d2r.js} +5 -5
- package/dist/{chunk-8t8e75xm.js → chunk-a20wq8wf.js} +4 -4
- package/dist/{chunk-7y73txmp.js → chunk-a3xqfyb6.js} +2 -2
- package/dist/chunk-ag8j9ec2.js +2 -0
- package/dist/chunk-ak15dt1a.js +2 -0
- package/dist/{chunk-qnxctfdf.js → chunk-akcyaxwv.js} +2 -2
- package/dist/{chunk-f4j7nsj1.js → chunk-aw6369cx.js} +1 -1
- package/dist/{chunk-ennzzth4.js → chunk-b5ck6epd.js} +17 -17
- package/dist/chunk-b98743ja.js +2 -0
- package/dist/{chunk-3vpgr6nk.js → chunk-b9d70mgr.js} +3 -3
- package/dist/chunk-bskxswmn.js +2 -0
- package/dist/chunk-bv5h4etd.js +2 -0
- package/dist/chunk-c7x3bmvs.js +2 -0
- package/dist/{chunk-12jjf2me.js → chunk-c84pxd2k.js} +2 -2
- package/dist/chunk-camm2hcx.js +2 -0
- package/dist/chunk-cd2wda5c.js +2 -0
- package/dist/chunk-cv6pqg85.js +2 -0
- package/dist/chunk-cy0mab8y.js +2 -0
- package/dist/chunk-d554f2fj.js +2 -0
- package/dist/chunk-dd1vqndp.js +2 -0
- package/dist/{chunk-cfbpvm5e.js → chunk-ddhkhhc7.js} +2 -2
- package/dist/{chunk-thpwk6ya.js → chunk-dsnggn3g.js} +2 -2
- package/dist/chunk-e14v1q9c.js +2 -0
- package/dist/{chunk-hp10khyy.js → chunk-e37g6ezw.js} +20 -20
- package/dist/chunk-e3xw2bzh.js +2 -0
- package/dist/{chunk-pm8a4kdf.js → chunk-eegb7f3t.js} +5 -5
- package/dist/chunk-eeztqt6f.js +2 -0
- package/dist/{chunk-7s1kerhs.js → chunk-ef3w5thv.js} +2 -2
- package/dist/chunk-eh528njb.js +2 -0
- package/dist/{chunk-wzwfbehm.js → chunk-en0wry1c.js} +11 -11
- package/dist/chunk-eszpqrxy.js +2 -0
- package/dist/{chunk-dxe94pwy.js → chunk-fp0ew9n4.js} +4 -4
- package/dist/chunk-fyxkzs9c.js +2 -0
- package/dist/{chunk-hwcfgs3e.js → chunk-gjf8cjdt.js} +3 -3
- package/dist/{chunk-8zf87cc5.js → chunk-gvnfb6s2.js} +2 -2
- package/dist/{chunk-fcqxa38q.js → chunk-gzfvj15b.js} +1 -1
- package/dist/chunk-hb4jkdfr.js +2 -0
- package/dist/{chunk-r3a15pax.js → chunk-hg9mwgnr.js} +1 -1
- package/dist/{chunk-reb7rddz.js → chunk-hmt0vqhb.js} +1 -1
- package/dist/{chunk-r1vkk7qp.js → chunk-hp9e8nz6.js} +2 -2
- package/dist/chunk-hzps1xya.js +2 -0
- package/dist/{chunk-4p5g7v9g.js → chunk-j3st59hv.js} +2 -2
- package/dist/{chunk-zva4a7xq.js → chunk-jde0shn4.js} +2 -2
- package/dist/{chunk-2xprqx2v.js → chunk-jeprxn45.js} +6 -6
- package/dist/{chunk-d50vw81s.js → chunk-jt0yn7ab.js} +4 -4
- package/dist/chunk-k8gpvg0w.js +2 -0
- package/dist/chunk-kgn911k7.js +2 -0
- package/dist/{chunk-1hq3y7ss.js → chunk-kj8dvzpc.js} +2 -2
- package/dist/chunk-km8c0j9g.js +2 -0
- package/dist/{chunk-ayd635jf.js → chunk-mj3hzy1e.js} +5 -5
- package/dist/{chunk-9jcqbgq9.js → chunk-nw0v655w.js} +6 -6
- package/dist/{chunk-ata5wp2m.js → chunk-p1mghe1h.js} +6 -6
- package/dist/{chunk-rdymnn2t.js → chunk-p2a6dwj6.js} +6 -6
- package/dist/chunk-pw89m3re.js +2 -0
- package/dist/chunk-q38vjqv2.js +2 -0
- package/dist/{chunk-9b9tvhmh.js → chunk-q3ma4khe.js} +5 -5
- package/dist/{chunk-3f8w1x6w.js → chunk-q7q9e0gj.js} +7 -7
- package/dist/{chunk-7y29q1ng.js → chunk-qef2vv0m.js} +2 -2
- package/dist/{chunk-6wpwpk3c.js → chunk-qjbpa1n4.js} +4 -4
- package/dist/{chunk-y2jqx5k4.js → chunk-qm2wmqre.js} +1 -1
- package/dist/{chunk-53v4cby3.js → chunk-qpvwxppw.js} +4 -4
- package/dist/{chunk-427mhgje.js → chunk-qxt6hdat.js} +1 -1
- package/dist/{chunk-w6e30qkz.js → chunk-r6d6jphq.js} +20 -20
- package/dist/{chunk-538d185r.js → chunk-rbv6fxtx.js} +2 -2
- package/dist/chunk-rrketemm.js +2 -0
- package/dist/chunk-rwys552r.js +3 -0
- package/dist/chunk-s0bx4gjh.js +2 -0
- package/dist/{chunk-90zswh9v.js → chunk-s14jcqdf.js} +4 -4
- package/dist/{chunk-bwf8b4e4.js → chunk-s3fmmm98.js} +3 -3
- package/dist/chunk-s8s7b7rv.js +2 -0
- package/dist/{chunk-vkn133cs.js → chunk-s9b6abkb.js} +2 -2
- package/dist/{chunk-w76cve9j.js → chunk-sprgkk9j.js} +31 -31
- package/dist/chunk-sywqa4da.js +2 -0
- package/dist/{chunk-b58n1kfe.js → chunk-t65tn8ee.js} +2 -2
- package/dist/{chunk-ka8sk5qa.js → chunk-trjhz9d9.js} +1 -1
- package/dist/chunk-txrbz95y.js +2 -0
- package/dist/{chunk-yjnaqahd.js → chunk-v9hm1xv6.js} +5 -5
- package/dist/{chunk-c5vzr1va.js → chunk-w0zayhmg.js} +2 -2
- package/dist/{chunk-h656zg6k.js → chunk-w58bnt44.js} +3 -3
- package/dist/chunk-w7681v48.js +2 -0
- package/dist/chunk-w7wz670a.js +2 -0
- package/dist/{chunk-zmr0pvcd.js → chunk-wp6bdac7.js} +59 -59
- package/dist/{chunk-cepctq7e.js → chunk-x8ckxemg.js} +23 -23
- package/dist/{chunk-mcj5qtpp.js → chunk-xa36escd.js} +3 -3
- package/dist/{chunk-wa7fzgw7.js → chunk-xskswvef.js} +4 -4
- package/dist/chunk-xzgtdcbg.js +2 -0
- package/dist/{chunk-7xs45trj.js → chunk-y9bj3566.js} +2 -2
- package/dist/chunk-yfdb3x3p.js +2 -0
- package/dist/{chunk-azqf0ps0.js → chunk-yv4dwdhc.js} +2 -2
- package/dist/{chunk-m081078c.js → chunk-z1aq59qj.js} +3 -3
- package/dist/{chunk-axjfaere.js → chunk-z1fb5k3h.js} +127 -40
- package/dist/{chunk-tqvw1673.js → chunk-z8wfvqbk.js} +5 -5
- package/dist/chunk-z9a80qqg.js +2 -0
- package/dist/chunk-za5kx15m.js +2 -0
- package/dist/{chunk-hnbx1t3t.js → chunk-zbv8e4rq.js} +2 -2
- package/dist/{chunk-sphc7xzx.js → chunk-znx5m1jv.js} +1 -1
- package/dist/{chunk-zv3zpmv1.js → chunk-zqsacq3r.js} +1 -1
- package/dist/{chunk-ectx5ar9.js → chunk-zsy145ac.js} +3 -3
- package/dist/{chunk-x8ghjw9b.js → chunk-zx8tnhfr.js} +3 -3
- package/dist/cli.js +18 -18
- package/dist/client/signals-authoring-runtime.js +4 -1
- package/dist/client/signals-handler-runtime.js +25 -4
- package/dist/client/signals-helpers-runtime.js +12 -0
- package/dist/client/signals-native-row-runtime.js +58 -23
- package/dist/client/signals-pipe-runtime.js +16 -0
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/compiler/inline-style.js +91 -39
- package/dist/native/runtime/native-host.js +138 -17
- package/dist/native-build.js +2 -23
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +5 -5
- package/package.json +6 -6
- package/dist/chunk-027hdpgv.js +0 -2
- package/dist/chunk-054h7ktz.js +0 -2
- package/dist/chunk-09nyt9c5.js +0 -2
- package/dist/chunk-0d3ncyqh.js +0 -2
- package/dist/chunk-1yew6rw9.js +0 -2
- package/dist/chunk-211kxm18.js +0 -2
- package/dist/chunk-26y92p8r.js +0 -2
- package/dist/chunk-3ep9h16p.js +0 -2
- package/dist/chunk-49tn6yst.js +0 -2
- package/dist/chunk-4b7dwwn6.js +0 -2
- package/dist/chunk-4ncbq4bx.js +0 -2
- package/dist/chunk-4srnxp3b.js +0 -2
- package/dist/chunk-6z4bza9z.js +0 -2
- package/dist/chunk-75y9heas.js +0 -2
- package/dist/chunk-7ckdvsmj.js +0 -3
- package/dist/chunk-8w1wxr96.js +0 -2
- package/dist/chunk-98kjk52z.js +0 -2
- package/dist/chunk-9sea317f.js +0 -2
- package/dist/chunk-9tpv4cg7.js +0 -2
- package/dist/chunk-9wmjmas8.js +0 -2
- package/dist/chunk-ak10vygz.js +0 -2
- package/dist/chunk-axq3c7cb.js +0 -2
- package/dist/chunk-c5trhqpg.js +0 -2
- package/dist/chunk-c692kj5v.js +0 -2
- package/dist/chunk-cfr7cd88.js +0 -2
- package/dist/chunk-dsh5q9bg.js +0 -2
- package/dist/chunk-emnphnz7.js +0 -2
- package/dist/chunk-epcdgn78.js +0 -2
- package/dist/chunk-etegf4zj.js +0 -2
- package/dist/chunk-ewzdsksb.js +0 -2
- package/dist/chunk-ey8bgg6x.js +0 -2
- package/dist/chunk-f03sg8b0.js +0 -2
- package/dist/chunk-gf04pgaa.js +0 -2
- package/dist/chunk-ghn8vhet.js +0 -2
- package/dist/chunk-gywp6kd8.js +0 -2
- package/dist/chunk-k6sjqb7g.js +0 -2
- package/dist/chunk-me71d5w5.js +0 -2
- package/dist/chunk-nvytej81.js +0 -2
- package/dist/chunk-p1txw41y.js +0 -2
- package/dist/chunk-p8gekf4b.js +0 -2
- package/dist/chunk-px0qsd38.js +0 -2
- package/dist/chunk-qr23snrp.js +0 -2
- package/dist/chunk-s151a2dj.js +0 -2
- package/dist/chunk-sqettc34.js +0 -2
- package/dist/chunk-srgbv05n.js +0 -2
- package/dist/chunk-t0d4rsfx.js +0 -2
- package/dist/chunk-t0k0yk24.js +0 -2
- package/dist/chunk-tdcgskyy.js +0 -2
- package/dist/chunk-te3hr6d7.js +0 -2
- package/dist/chunk-tes8fdv6.js +0 -2
- package/dist/chunk-v6j5vkce.js +0 -2
- package/dist/chunk-vmp876q6.js +0 -2
- package/dist/chunk-vwp5fchy.js +0 -2
- package/dist/chunk-wes5fdpe.js +0 -2
- package/dist/chunk-wfnfb4fr.js +0 -2
- package/dist/chunk-wfrqwtar.js +0 -2
- package/dist/chunk-xbhb8102.js +0 -2
- package/dist/chunk-xv4paxmt.js +0 -2
- package/dist/chunk-yeaqebnd.js +0 -2
- package/dist/chunk-yj20tq3s.js +0 -2
- package/dist/chunk-yjm7c78z.js +0 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{kn}from"./chunk-
|
|
3
|
-
`}import P from"path";var Y="stx-page-head:",Z=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,k={dev:null,prod:null};function Q(){let t=
|
|
2
|
+
import{kn}from"./chunk-4v50nafp.js";import{W,S,Ot,Nt,Cr,m,el,wi,V,T}from"./chunk-wp6bdac7.js";import{Qt}from"./chunk-qm2wmqre.js";import{n}from"./chunk-rwys552r.js";import{X}from"./chunk-w0zayhmg.js";var z=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function U(t){let r=[],e=/<!--[\s\S]*?(?:-->|$)|<(script|style|textarea|title|template)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,s;while((s=e.exec(t))!==null)r.push({start:s.index,end:s.index+s[0].length});return r}function I(t,r){return r.some((e)=>t>=e.start&&t<e.end)}function G(t){let r=(t||"").trim();if(!r)return null;if(/[\s>+~,:]/.test(r))return null;let e={},s=r,a=s.match(/^[a-z][\w-]*/i);if(a)e.tag=a[0].toLowerCase(),s=s.slice(a[0].length);while(s.length>0){let i=s.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(i){if(e.attr=i[1],i[3]!==void 0&&i[3]!=="")e.attrValue=i[3];s=s.slice(i[0].length);continue}let o=s.match(/^#([\w-]+)/);if(o){e.id=o[1],s=s.slice(o[0].length);continue}let c=s.match(/^\.([\w-]+)/);if(c){e.className=c[1],s=s.slice(c[0].length);continue}return null}if(!e.tag&&!e.attr&&!e.id&&!e.className)return null;return e}function J(t,r){if(r.attr){if(!(r.attrValue===void 0?new RegExp(`\\b${r.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${r.attr}\\s*=\\s*(["'])\\s*${r.attrValue}\\s*\\1`,"i")).test(t))return!1}if(r.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${r.id}\\s*\\1`,"i").test(t))return!1}if(r.className){let e=t.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!e)return!1;if(!e[2].split(/\s+/).includes(r.className))return!1}return!0}function _(t,r="main"){let e=G(r);if(!e)return null;let s=/<([a-z][\w-]*)\b([^>]*)>/gi,a=U(t),i;while((i=s.exec(t))!==null){if(I(i.index,a))continue;let o=i[1].toLowerCase(),c=i[2]||"";if(c.trimEnd().endsWith("/")||z.has(o))continue;if(e.tag&&e.tag!==o)continue;if(!J(c,e))continue;let l=i[0],u=i.index+l.length,f=new RegExp(`<(/?)${o}\\b([^>]*)>`,"gi");f.lastIndex=u;let p=1,h;while((h=f.exec(t))!==null){if(I(h.index,a))continue;let y=h[1]==="/";if(!y&&(h[2]||"").trimEnd().endsWith("/"))continue;if(p+=y?-1:1,p===0)return{openTag:l,openIndex:i.index,start:u,end:h.index,tagName:o}}return null}return null}var ft="private, no-store";function An(t){return t.replace(/&#(\d+);/g,(r,e)=>N(Number(e),r)).replace(/&#x([0-9a-f]+);/gi,(r,e)=>N(Number.parseInt(e,16),r)).replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&")}function N(t,r){if(!Number.isInteger(t)||t<0||t>1114111)return r;try{return String.fromCodePoint(t)}catch{return r}}function Ce(t){return t.headers.get("X-STX-Router")==="true"}function K(t,r){if(!t)return r;return t.split(",").some((s)=>s.trim().toLowerCase()===r.toLowerCase())?t:`${t}, ${r}`}function D(t){return{Vary:K(t,"X-STX-Router")}}function E(t){return t.replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Pn(t){let r=/<head\b[^>]*>([\s\S]*?)<\/head\s*>/i.exec(t)?.[1]??"",e=/<(meta|link)\b(?:[^>"']|"[^"]*"|'[^']*')*>|<title\b[^>]*>[\s\S]*?<\/title\s*>/giy,s=S(r,(i,o)=>(e.lastIndex=o,e.exec(i)?e.lastIndex:-1)),a=[];for(let{token:i}of s){if(/^<title\b/i.test(i)){a.push(`<title>${E(i.replace(/^<title\b[^>]*>|<\/title\s*>$/gi,""))}</title>`);continue}let o=Object.create(null),c=i.replace(/^<\w+\b|>$/g,"");for(let l of c.matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g)){let u=l[1].toLowerCase();if(!(u in o))o[u]=l[2]??l[3]??l[4]??""}if(/^<meta\b/i.test(i)){let l=o.property?"property":"name",u=An(o[l]??"").toLowerCase();if(u==="description"||/^(?:og|twitter):[\w:]+$/.test(u))a.push(`<meta ${l}="${n(u)}" content="${E(o.content??"")}">`)}else{let l=An(o.rel??"").toLowerCase();if(l==="canonical"||l==="alternate"&&o.hreflang)a.push(`<link rel="${l}" href="${E(o.href??"")}"${l==="alternate"?` hreflang="${E(o.hreflang)}"`:""}>`)}}return`<template data-stx-page-head="1">${a.join("")}</template>
|
|
3
|
+
`}import P from"path";var Y="stx-page-head:",Z=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,k={dev:null,prod:null};function Q(){let t=X()?"dev":"prod",r=k[t];if(r!==null)return r;try{let e=import.meta.require("./chunk-b98743ja.js"),s=t==="dev"&&typeof e.getRouterScriptDev==="function"?e.getRouterScriptDev:e.getRouterScript;k[t]=`<script>${s()}</script>`}catch{k[t]=""}return k[t]}async function ca(t,r){if(r===!1)return null;if(r&&typeof r==="string"){let s=P.resolve(t,r);if(await Bun.file(s).exists())return s;return null}let e=P.join(t,"app.stx");if(await Bun.file(e).exists())return e;return null}async function mo(t,r){try{let e=await Bun.file(t).text(),s=e,a=e.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(a)s=a[1].trim();let i=Qt(e),o=[...i.client.map((g)=>g.fullTag),...i.signals.map((g)=>g.fullTag)],c=[],l=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,u;while((u=l.exec(e))!==null)c.push(u[0]);let f=s;for(let g of i.server)f=f.replace(g.fullTag,"");for(let g of i.client)f=f.replace(g.fullTag,"");f=f.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let p="<!--__STX_PAGE_SLOT__-->";if(f=f.replace(/<slot\s*\/>/gi,p).replace(/<slot\s*>\s*<\/slot>/gi,p),!f.includes(p))return console.warn(`[stx] Shell ${t} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:h,extractVariables:y,defaultConfig:R,loadStxConfig:b}=await import("./chunk-6hre8cg4.js"),A=await b(),d={__filename:t,__dirname:P.dirname(t)};for(let g of o){let C=g.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(C&&!g.includes("client")&&!g.includes('type="module"'))await y(C[1],d,t)}let x=await h(f,d,t,{...R,...A,...r},new Set),w=x.indexOf(p);if(w===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:x.substring(0,w),afterSlot:x.substring(w+p.length),filePath:t,shellScripts:o,shellStyles:c}}catch(e){return console.error(`[stx] Error processing shell ${t}:`,e),null}}function Xr(t,r,e){let s,a="",i=r.match(Z);if(i){r=r.replace(i[0],"");try{let f=Buffer.from(i[1],"base64").toString("utf8"),p=f.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(p)s=p[1].trim();a=f.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let o=e||s||"stx App",c=Q(),l="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
|
|
4
4
|
<html lang="en">
|
|
5
5
|
<head>
|
|
6
6
|
<meta charset="UTF-8">
|
|
@@ -23,10 +23,10 @@ ${c}
|
|
|
23
23
|
`),"utf8").toString("base64")}-->`)}let i=e.match(/<body\b[^>]*>/i),o=e.lastIndexOf("</body>");if(i&&o!==-1){let l=i.index+i[0].length,u=e.slice(l,o).trim();if(s.length>0)return s.join(`
|
|
24
24
|
`)+`
|
|
25
25
|
`+u;return u}let c=e;if(c=c.replace(/<!DOCTYPE\b[^>]*>/i,""),c=c.replace(/<html\b[^>]*>/i,""),c=c.replace(/<\/html\s*>/i,""),a)c=c.replace(/<head\b[^>]*>[\s\S]*?<\/head>/i,s.join(`
|
|
26
|
-
`));return c=c.replace(/<body\b[^>]*>/i,""),c=c.replace(/<\/body\s*>/i,""),c.trim()}var F=/^<script\b[^>]*\sdata-stx-(?:owner|instance)(?=[\s=/>])/i;function L(t,r,e,s){if(!F.test(r))return!1;let a=r.slice(0,r.indexOf(">")+1),i=/\sdata-stx-owner="([^"]+)"/i.exec(a)?.[1];if(!i)return!0;let o=`data-stx-scope="${i}"`;for(let c=t.indexOf(o);c!==-1;c=t.indexOf(o,c+o.length))if(c>=e&&c<s)return!1;return!0}function
|
|
26
|
+
`));return c=c.replace(/<body\b[^>]*>/i,""),c=c.replace(/<\/body\s*>/i,""),c.trim()}var F=/^<script\b[^>]*\sdata-stx-(?:owner|instance)(?=[\s=/>])/i;function L(t,r,e,s){if(!F.test(r))return!1;let a=r.slice(0,r.indexOf(">")+1),i=/\sdata-stx-owner="([^"]+)"/i.exec(a)?.[1];if(!i)return!0;let o=`data-stx-scope="${i}"`;for(let c=t.indexOf(o);c!==-1;c=t.indexOf(o,c+o.length))if(c>=e&&c<s)return!1;return!0}function la(t){return Ce(t)}function tt(t,r){let e=[],s=new Set;for(let a of S(t,W)){if(a.start>=r.start&&a.start<r.end)continue;let i=a.token.match(/^<script\b((?:"[^"]*"|'[^']*'|[^'">])*)>/i)?.[1]??"",o=new Map;for(let u of i.matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g))o.set(u[1].toLowerCase(),u[2]??u[3]??u[4]??"");let c=o.get("src")?.trim(),l=o.get("type")?.trim().toLowerCase();if(!c||o.has("server")||l&&!["module","text/javascript","application/javascript"].includes(l))continue;if(o.has("data-stx-runtime")||o.has("data-stx-router")||/^\/_stx\/(?:runtime|router)(?:\.[a-f0-9]{16})?\.js(?:[?#]|$)/i.test(c))continue;if(L(t,a.token,r.start,r.end)||s.has(a.token))continue;s.add(a.token),e.push(a.token)}return e}function qe(t,r="main"){return!!_(t.trim(),r)}function Ee(t,r="main",e=!1){let s=t.trim(),a=[],i=[],o=s.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(o){let x=o[1],w=/<style\b[^>]*>[\s\S]*?<\/style>/gi,g;while((g=w.exec(x))!==null)a.push(g[0]);let C=/<script\b[^>]*data-stx-(?:route-params|server-data|scoped|component-factories)[^>]*>[\s\S]*?<\/script>/gi;while((g=C.exec(x))!==null){if(F.test(g[0])||g[0].includes("__stx_early_mounts")||/^<script\b[^>]*\bdata-stx-runtime(?=[\s=>])/i.test(g[0]))continue;i.push(g[0])}}let c=_(s,r);if(!c)return(e?Pn(t):"")+We(t);let l=tt(s,c),u=new Set(l),{tagName:f,start:p,end:h}=c,y=s.slice(p,h).trim(),R=[],b=s.match(/<body\b[^>]*>/i),A=s.lastIndexOf("</body>");if(b&&b.index!==void 0&&A!==-1){let w=[[b.index+b[0].length,c.openIndex],[h+`</${f}>`.length,A]],g=/<script\b[^>]*>[\s\S]*?<\/script>/gi;for(let[C,j]of w){if(C>=j)continue;let q=s.slice(C,j),v;g.lastIndex=0;while((v=g.exec(q))!==null){if(L(s,v[0],p,h))continue;R.push(v[0])}}}let d=[];if(e)d.push(Pn(t));if(a.length>0)d.push(a.join(`
|
|
27
27
|
`));if(l.length>0)d.push(l.join(`
|
|
28
28
|
`));if(i.length>0)d.push(i.filter((x)=>!u.has(x)).join(`
|
|
29
29
|
`));if(R.length>0)d.push(R.filter((x)=>!u.has(x)).join(`
|
|
30
30
|
`));return d.push(y),d.join(`
|
|
31
|
-
`)}import O from"fs";import H from"path";function
|
|
32
|
-
export{ft,An,Ce,D,Pn,
|
|
31
|
+
`)}import O from"fs";import H from"path";function ua(t,r,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:r,outputDir:e}}function da(t,r){let e=H.join(r,"manifest.json");O.writeFileSync(e,JSON.stringify(t,null,2))}function pa(t){let r=H.join(t,"manifest.json");if(!O.existsSync(r))return null;try{let e=O.readFileSync(r,"utf-8"),s=JSON.parse(e);if(s.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${s.version}`),null;return s}catch(e){return console.warn("[stx] Failed to load manifest:",e),null}}function M(t,r,e={}){let s=`${encodeURIComponent(t)}=${encodeURIComponent(r)}`;if(e.maxAge!==void 0)s+=`; Max-Age=${e.maxAge}`;if(e.expires)s+=`; Expires=${e.expires.toUTCString()}`;if(e.path)s+=`; Path=${e.path}`;if(e.domain)s+=`; Domain=${e.domain}`;if(e.secure)s+="; Secure";if(e.httpOnly)s+="; HttpOnly";if(e.sameSite)s+=`; SameSite=${e.sameSite}`;return s}async function et(t){let r=t.headers.get("content-type")||"",e={},s=(a,i)=>{let o=e[a];if(o===void 0)e[a]=i;else if(Array.isArray(o))o.push(i);else e[a]=[o,i]};if(r.includes("multipart/form-data")){let a=await t.formData();for(let[i,o]of a.entries())if(typeof o==="string")s(i,o);return e}if(r.includes("application/x-www-form-urlencoded")){for(let[a,i]of new URLSearchParams(await t.text()).entries())s(a,i);return e}return e}function ho(t){if(!t)return!1;let r=t.toUpperCase();return r!=="GET"&&r!=="HEAD"}async function B(t,r={}){let e=r.request,s=r.method??e?.method;if(!e||!ho(s))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let a={};try{a=await et(e)}catch{}let i=await t.action({request:e,form:a,params:r.params??{},query:t.query??{},cookies:r.cookies??{}});if(i&&typeof i==="object"){let o=i,c=nt(o.cookies),l=o.redirect;if(typeof l==="string"&&l)return{redirect:l,ran:!0,...c.length>0?{cookies:c}:{}};let{cookies:u,redirect:f,...p}=o;if(Object.assign(t,p),c.length>0)return{ran:!0,cookies:c}}return{ran:!0}}function nt(t){if(!t||typeof t!=="object"||Array.isArray(t))return[];let r=[];for(let[e,s]of Object.entries(t)){if(!e)continue;if(typeof s==="string"){r.push(M(e,s));continue}if(s&&typeof s==="object"){let a=s;if(typeof a.value!=="string")continue;r.push(M(e,a.value,a))}}return r}function fa(t,r=[],e){let s=new Headers({Location:t,"Cache-Control":"no-store"});for(let a of r)s.append("Set-Cookie",a);for(let[a,i]of Object.entries(e??{}))if(a.toLowerCase()!=="location")s.set(a,i);return new Response(null,{status:303,headers:s})}async function In(t,r={}){let{html:e,context:s,redirect:a,cookies:i}=await rt(t,r),o=Ot(s),c=Nt(s);if(a)return{html:e,redirect:a,cookies:i,status:o,headers:c};let{extractStreamBoundaries:l}=await import("./chunk-c7x3bmvs.js"),u=l(s),f=t.streamTemplates;if(f&&Object.keys(f).length>0){let{processDirectives:p}=await import("./chunk-k8gpvg0w.js"),{defaultConfig:h}=await import("./chunk-cd2wda5c.js"),y=s.streamBoundaries||{},R={...h,autoShell:!1},b=Object.keys(f).map((d)=>({id:d,render:async()=>{let x=typeof y[d]==="function"?await y[d]():void 0;return p(f[d],{...s,$boundary:x},t.sourceFile,R,new Set)}})),A=new Set(b.map((d)=>d.id));u=[...(u||[]).filter((d)=>!A.has(d.id)),...b]}return{html:e,boundaries:u&&u.length>0?u:void 0,cookies:i,status:o,headers:c}}async function rt(t,r){let e={__filename:t.sourceFile,__dirname:t.sourceFile.replace(/[/\\][^/\\]+$/,""),...r};if(!t.hasServerScripts&&!wi(t.html))return{html:t.html,context:e};for(let o of t.serverScriptContent)try{await m(o,e,t.sourceFile)}catch(c){if(r.__stx_strict_hydration)throw c;console.warn(`[stx] Server script error in ${t.sourceFile}:`,c)}let s=await B(e,{request:r.request,method:r.method,params:r.params??{},cookies:r.cookies??{}}),a=(o)=>{let c=o.replace(/<script\b[^>]*\bdata-stx-server-data\b[^>]*>[\s\S]*?<\/script>/gi,""),l=Cr(e);if(!l)return c;let u=c.indexOf("</head>");return u<0?l+c:c.slice(0,u)+l+c.slice(u)};if(s.redirect)return{html:t.html,context:e,redirect:s.redirect,cookies:s.cookies};if(!wi(t.html))return{html:a(t.html),context:e,cookies:s.cookies};let i=new Map;for(let[o,c]of Object.entries(t.placeholders))if(c.expression)try{let l=T(c.expression,e);if(c.type==="raw")i.set(o,l!==void 0&&l!==null?String(l):"");else i.set(o,l!==void 0&&l!==null?V(String(l)):"")}catch(l){if(r.__stx_strict_hydration)throw l;i.set(o,"")}return{html:a(el(t.html,i)),context:e,cookies:s.cookies}}
|
|
32
|
+
export{ft,An,Ce,D,Pn,ca,mo,Xr,We,la,qe,Ee,ua,da,pa,ho,fa,In};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{b,x,
|
|
2
|
+
import{b,x,pi,fn}from"./chunk-wp6bdac7.js";import{Ko}from"./chunk-rbv6fxtx.js";import{l}from"./chunk-kj8dvzpc.js";import M from"fs";import d from"path";import{hasLocalConfig as le}from"bunfig";var bt={fg:{light:"neutral-900",dark:"neutral-100",description:"Primary text"},"fg-strong":{light:"neutral-700",dark:"neutral-300",description:"Labels, secondary headings"},"fg-muted":{light:"neutral-600",dark:"neutral-400",description:"Supporting text"},"fg-soft":{light:"neutral-500",dark:"neutral-400",description:"De-emphasised text"},"fg-subtle":{light:"neutral-400",dark:"neutral-500",description:"Recessive, non-essential text"},surface:{light:"neutral-50",dark:"neutral-800",description:"Page and panel background"},"surface-raised":{light:"neutral-100",dark:"neutral-700",description:"Cards, popovers"},"surface-sunken":{light:"neutral-200",dark:"neutral-700",description:"Wells, track backgrounds"},panel:{light:"white",dark:"neutral-800",description:"Card, menu, dialog surface"},field:{light:"white",dark:"neutral-700",description:"Form control surface"},page:{light:"neutral-50",dark:"neutral-900",description:"Page background, behind panels"},content:{light:"white",dark:"neutral-900",description:"Content area under a chrome header - a table or list body"},"surface-hover":{light:"neutral-100",dark:"neutral-700",description:"Row or item highlight on a page or panel"},"surface-raised-hover":{light:"neutral-200",dark:"neutral-600",description:"Raised surface, hovered"},"surface-sunken-hover":{light:"neutral-300",dark:"neutral-600",description:"Sunken surface, hovered"},"field-hover":{light:"neutral-50",dark:"neutral-600",description:"Form control surface, hovered"},link:{light:"blue-500",dark:"blue-400",description:"Hyperlink"},"link-hover":{light:"blue-600",dark:"blue-300",description:"Hyperlink, hovered"},inverse:{light:"neutral-900",dark:"neutral-700",description:"Tooltip bubble, inverted surface"},"inverse-ink":{light:"white",dark:"white",description:"Text on an inverted surface"},line:{light:"neutral-200",dark:"neutral-700",description:"Default border, divider"},"line-strong":{light:"neutral-300",dark:"neutral-600",description:"Input border, focus ring track"},"line-hover":{light:"neutral-400",dark:"neutral-500",description:"Border of a hovered control"},accent:{light:"blue-600",dark:"blue-400",description:"Primary action, selected state"},info:{light:"cyan-600",dark:"cyan-400",description:"Informational emphasis"},danger:{light:"red-600",dark:"red-400",description:"Errors, destructive actions"},success:{light:"green-600",dark:"green-400",description:"Confirmation"},warning:{light:"yellow-600",dark:"yellow-400",description:"Caution"},"accent-solid":{light:"blue-500",dark:"blue-600",description:"Primary button fill"},"info-solid":{light:"cyan-500",dark:"cyan-600",description:"Informational fill"},"danger-solid":{light:"red-500",dark:"red-600",description:"Destructive button fill"},"success-solid":{light:"green-500",dark:"green-600",description:"Confirmation fill"},"warning-solid":{light:"yellow-500",dark:"yellow-600",description:"Caution fill"},"accent-solid-hover":{light:"blue-600",dark:"blue-700",description:"Primary button fill, hovered"},"info-solid-hover":{light:"cyan-600",dark:"cyan-700",description:"Informational fill, hovered"},"danger-solid-hover":{light:"red-600",dark:"red-700",description:"Destructive fill, hovered"},"success-solid-hover":{light:"green-600",dark:"green-700",description:"Confirmation fill, hovered"},"warning-solid-hover":{light:"yellow-600",dark:"yellow-700",description:"Caution fill, hovered"},"accent-ink":{light:"white",dark:"white",description:"Text on a primary fill"},"info-ink":{light:"neutral-900",dark:"neutral-900",description:"Text on an informational fill"},"danger-ink":{light:"white",dark:"white",description:"Text on a destructive fill"},"success-ink":{light:"neutral-900",dark:"neutral-900",description:"Text on a confirmation fill"},"warning-ink":{light:"neutral-900",dark:"neutral-900",description:"Text on a caution fill"},"accent-soft":{light:"blue-100",dark:"blue-900",description:"Tinted primary fill"},"accent-soft-ink":{light:"blue-800",dark:"blue-200",description:"Text on a tinted primary fill"},"info-soft":{light:"cyan-100",dark:"cyan-900",description:"Tinted informational fill"},"info-soft-ink":{light:"cyan-800",dark:"cyan-200",description:"Text on a tinted informational fill"},"danger-soft":{light:"red-100",dark:"red-900",description:"Tinted destructive fill"},"danger-soft-ink":{light:"red-800",dark:"red-200",description:"Text on a tinted destructive fill"},"success-soft":{light:"green-100",dark:"green-900",description:"Tinted confirmation fill"},"success-soft-ink":{light:"green-800",dark:"green-200",description:"Text on a tinted confirmation fill"},"warning-soft":{light:"yellow-100",dark:"yellow-900",description:"Tinted caution fill"},"warning-soft-ink":{light:"yellow-800",dark:"yellow-200",description:"Text on a tinted caution fill"},secondary:{light:"purple-600",dark:"purple-400",description:"Secondary emphasis"},"secondary-solid":{light:"purple-500",dark:"purple-600",description:"Secondary fill"},"secondary-solid-hover":{light:"purple-600",dark:"purple-700",description:"Secondary fill, hovered"},"secondary-ink":{light:"white",dark:"white",description:"Text on a secondary fill"},"secondary-soft":{light:"purple-100",dark:"purple-900",description:"Tinted secondary fill"},"secondary-soft-ink":{light:"purple-800",dark:"purple-200",description:"Text on a tinted secondary fill"},"danger-fg":{light:"red-900",dark:"red-300",description:"Text in a field with an error"},"danger-fg-subtle":{light:"red-300",dark:"red-500",description:"Recessive text in a field with an error"},"danger-line":{light:"red-300",dark:"red-600",description:"Border of a field with an error"},"danger-focus":{light:"red-500",dark:"red-400",description:"Focus ring of a field with an error"}};function Ke(n){return`--stx-${n}`}function F(n,t){let s=t.lastIndexOf("-");if(s===-1)return typeof n[t]==="string"?n[t]:void 0;let r=n[t.slice(0,s)];if(!r||typeof r!=="object")return;let i=r[t.slice(s+1)];return typeof i==="string"?i:void 0}var xe=/^(?:#[\da-f]{3,8}|(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix|var)\(.*\)|white|black|transparent|currentcolor)$/i;function X(n,t){let s=t.trim();return F(n,s)??(xe.test(s)?s:void 0)}function Z(n={}){return[...Object.keys(n.roles??{}).filter((t)=>!bt[t]).map((t)=>`roles.${t}`),...Object.keys(n.shapes??{}).filter((t)=>!ye[t]).map((t)=>`shapes.${t}`),...Object.keys(n.density??{}).filter((t)=>!Ae[t]).map((t)=>`density.${t}`)]}function q(n){let t={};for(let[s,r]of Object.entries(bt)){let i=F(n,r.light);if(i===void 0)continue;t[s]=`var(${Ke(s)}, ${i})`}return t}function ee(n,t={}){let s=[],r=[];for(let[i,o]of Object.entries(bt)){let a=t[i],g=typeof a==="string"?a:a?.light,c=typeof a==="string"?a:a?.dark,u=g&&X(n,g)||F(n,o.light),m=c&&X(n,c)||F(n,o.dark);if(u===void 0)continue;if(s.push(` ${Ke(i)}: ${u};`),m!==void 0)r.push(` ${Ke(i)}: ${m};`)}if(s.length===0)return"";return["/* stx role tokens \u2014 override any of these to re-theme by meaning. */",":root {",...s,"}",".dark {",...r,"}",""].join(`
|
|
3
3
|
`)}var ye={control:{value:"0.375rem",description:"Buttons, inputs, selects \u2014 rounded-md"},panel:{value:"0.5rem",description:"Cards, dialogs, menus \u2014 rounded-lg"},pill:{value:"9999px",description:"Chips and badges, which are pill-shaped by intent"}};function an(n){return`--stx-radius-${n}`}function te(){let n={};for(let[t,s]of Object.entries(ye))n[t]=`var(${an(t)}, ${s.value})`;return n}function ne(n={}){return["/* stx shape tokens \u2014 a radius by what the thing is. */",":root {",...Object.entries(ye).map(([t,s])=>` ${an(t)}: ${n[t]??s.value};`),"}",""].join(`
|
|
4
4
|
`)}var Ae={"control-px":{value:"1rem",description:"Inline padding of a md text control \u2014 px-4"},"control-py":{value:"0.5rem",description:"Block padding of a md text control \u2014 py-2"},"control-text":{value:"1rem",description:"Font size of a md text control \u2014 text-base"},"control-leading":{value:"1.5rem",description:"Line height of a md text control \u2014 text-base"},"cell-px":{value:"1.5rem",description:"Inline padding of every table cell, header or body \u2014 px-6"},"cell-py":{value:"1rem",description:"Block padding of a body cell \u2014 py-4"},"cell-text":{value:"0.875rem",description:"Font size of a body cell \u2014 text-sm"},"cell-leading":{value:"1.25rem",description:"Line height of a body cell \u2014 text-sm"},"cell-head-py":{value:"0.75rem",description:"Block padding of a header cell \u2014 py-3"},"cell-head-text":{value:"0.75rem",description:"Font size of a header cell \u2014 text-xs"},"cell-head-leading":{value:"1rem",description:"Line height of a header cell \u2014 text-xs"}},nr={"control-x":"control-px","control-y":"control-py","cell-x":"cell-px","cell-y":"cell-py","cell-head-y":"cell-head-py"},rr={control:{size:"control-text",leading:"control-leading"},cell:{size:"cell-text",leading:"cell-leading"},"cell-head":{size:"cell-head-text",leading:"cell-head-leading"}};function Ge(n){return`--stx-${n}`}function V(n){let t=Ae[n];if(!t)throw Error(`[stx] unknown density token "${n}"`);return`var(${Ge(n)}, ${t.value})`}function se(){let n={};for(let[t,s]of Object.entries(nr))n[t]=V(s);return n}function re(){let n={};for(let[t,{size:s,leading:r}]of Object.entries(rr))n[t]=[V(s),{lineHeight:V(r)}];return n}function ie(n={}){return["/* stx density tokens \u2014 how much room a control or a table cell takes. */",":root {",...Object.entries(Ae).map(([t,s])=>` ${Ge(t)}: ${n[t]??s.value};`),"}",""].join(`
|
|
5
5
|
`)}function oe(n){return typeof n==="object"&&n!==null&&!Array.isArray(n)}function U(n,t){let s={...n};for(let[r,i]of Object.entries(t))s[r]=oe(i)&&oe(s[r])?U(s[r],i):i;return s}function ce(n,t){if(!t.fonts)return"";let s=new n({...t.config,fonts:t.fonts,cssVariables:!1}).toCSS(!1,t.minify);return s&&!t.minify?`${s}
|
|
6
|
-
`:s}function ae(n={},t={}){let s=n.theme||{},r=t.theme||{},{extend:i,...o}=r,{extend:a,...g}=s,c=g.colors||{};g.colors={...c,...q(c)};let u=g.borderRadius||{};g.borderRadius={...u,...te()};let m=g.spacing||{};g.spacing={...m,...se()};let H=g.fontSize||{};g.fontSize={...H,...re()};let R=U(g,o),k=U(a||{},i||{});if(Object.keys(k).length>0)R.extend=k;let E=[...n.safelist||[],...t.safelist||[]],_={...n.shortcuts||{},...t.shortcuts||{}},P=[...n.preflights||[],...t.preflights||[]],{fonts:K,...D}=n,{fonts:O,roles:T,shapes:N,density:C,...w}=t,f={roles:T,shapes:N,density:C},j=O??K;return{config:{...D,...w,theme:R,safelist:E,shortcuts:_,...P.length>0?{preflights:P}:{},content:[],output:""},safelist:E,shortcuts:_,includePreflight:t.preflight!==!1,minify:t.minify===!0,tokenCSS:ee({...c,...R.colors},T)+ne(N)+ie(C),unknownRoles:Z(f),...j?{fonts:j}:{}}}var e={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgGray:"\x1B[100m"};var p=null,A="";function de(n){try{let t=n.startsWith("file:")?new URL(n).pathname:n;A=`${t}@${Math.trunc(M.statSync(t).mtimeMs)}`}catch{A=n}}var Q=!1,v=null,I="",B=!1,pe=256,S=new Map,h=new Map,z=null,he=null,G=new Map,ge=new Set;function L(n){return Bun.hash(n).toString(16).padStart(16,"0").slice(0,16)}function W(n,t){if(S.has(n))S.delete(n);else if(S.size>=pe)S.delete(S.keys().next().value);S.set(n,t)}function ke(n){let t=L(n);if(h.has(t))h.delete(t);else if(h.size>=pe)h.delete(h.keys().next().value);return h.set(t,n),t}function
|
|
7
|
-
`)}async function $e(n,t){try{let s=await
|
|
6
|
+
`:s}function ae(n={},t={}){let s=n.theme||{},r=t.theme||{},{extend:i,...o}=r,{extend:a,...g}=s,c=g.colors||{};g.colors={...c,...q(c)};let u=g.borderRadius||{};g.borderRadius={...u,...te()};let m=g.spacing||{};g.spacing={...m,...se()};let H=g.fontSize||{};g.fontSize={...H,...re()};let R=U(g,o),k=U(a||{},i||{});if(Object.keys(k).length>0)R.extend=k;let E=[...n.safelist||[],...t.safelist||[]],_={...n.shortcuts||{},...t.shortcuts||{}},P=[...n.preflights||[],...t.preflights||[]],{fonts:K,...D}=n,{fonts:O,roles:T,shapes:N,density:C,...w}=t,f={roles:T,shapes:N,density:C},j=O??K;return{config:{...D,...w,theme:R,safelist:E,shortcuts:_,...P.length>0?{preflights:P}:{},content:[],output:""},safelist:E,shortcuts:_,includePreflight:t.preflight!==!1,minify:t.minify===!0,tokenCSS:ee({...c,...R.colors},T)+ne(N)+ie(C),unknownRoles:Z(f),...j?{fonts:j}:{}}}var e={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgGray:"\x1B[100m"};var p=null,A="";function de(n){try{let t=n.startsWith("file:")?new URL(n).pathname:n;A=`${t}@${Math.trunc(M.statSync(t).mtimeMs)}`}catch{A=n}}var Q=!1,v=null,I="",B=!1,pe=256,S=new Map,h=new Map,z=null,he=null,G=new Map,ge=new Set;function L(n){return Bun.hash(n).toString(16).padStart(16,"0").slice(0,16)}function W(n,t){if(S.has(n))S.delete(n);else if(S.size>=pe)S.delete(S.keys().next().value);S.set(n,t)}function ke(n){let t=L(n);if(h.has(t))h.delete(t);else if(h.size>=pe)h.delete(h.keys().next().value);return h.set(t,n),t}function _h(n){let t=h.get(n);if(t===void 0)return;return h.delete(n),h.set(n,t),t}async function Ce(n,t=z){if(!t)return null;try{let s=Bun.file(d.join(t,`cw-${L(n)}.css`));if(!await s.exists())return null;return await s.text()}catch{return null}}async function Se(n,t,s=z){if(!s)return;try{if(!M.existsSync(s))M.mkdirSync(s,{recursive:!0});await Bun.write(d.join(s,`cw-${L(n)}.css`),t)}catch{}}async function ue(n){try{let t=await import(n);if(t&&t.CSSGenerator)return{CSSGenerator:t.CSSGenerator,config:t.config,build:t.build,defaultConfig:t.defaultConfig,extractClasses:t.extractClasses}}catch{}return null}var we=[["@stacksjs","ts-css","dist","engine","index.js"],["@stacksjs","ts-css","src","engine","index.ts"]],be=["@stacksjs/ts-css/engine","@stacksjs/ts-css/dist/engine/index.js"];function ve(){let n=[],t=process.cwd();while(t!==d.dirname(t)){for(let s of["node_modules","pantry"])for(let r of we)n.push(d.join(t,s,...r));t=d.dirname(t)}return n}function Re(){let n=[],t=process.env.HOME||process.env.USERPROFILE||"",s=[t&&d.join(t,"Code","Tools","ts-css"),t&&d.join(t,"Code","Tools","crosswind"),t&&d.join(t,"repos","stacks-org","ts-css"),t&&d.join(t,"repos","stacks-org","crosswind"),d.join(process.cwd(),"..","ts-css"),d.join(process.cwd(),"..","crosswind")].filter(Boolean);for(let r of s)n.push(d.join(r,"packages","toolkit","dist","engine","index.js")),n.push(d.join(r,"packages","toolkit","src","engine","index.ts"));if(t)n.push(d.join(t,"Code","Tools","stx","node_modules","@stacksjs","ts-css","dist","engine","index.js"));return n}async function oc(){if(Q)return p;Q=!0;try{let n=async(i)=>{for(let o of i){if(!await Bun.file(o).exists())continue;let a=await ue(o);if(a){if(de(o),!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} CSS engine loaded from ${d.dirname(d.dirname(o))}`);return a}}return null};if(process.env.CROSSWIND_SRC){let i=d.resolve(process.env.CROSSWIND_SRC),o=await n([i]);if(!o)throw Error(`CROSSWIND_SRC did not resolve to a Css module: ${i}`);return p=o,p}let t=await n(ve());if(t)return p=t,p;let s=be;for(let i of s){let o=await ue(i);if(o){p=o;try{de(import.meta.resolve(i))}catch{A=i}if(!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} CSS engine loaded`);return p}}let r=await n(Re());if(r)return p=r,p;throw Error("Css CSSGenerator not found in any location")}catch{return console.warn(`${e.yellow}[ts-css] CSS engine not available, Tailwind styles will not be generated${e.reset}`),console.warn(`${e.yellow}Run 'bun add @stacksjs/ts-css' to enable CSS generation${e.reset}`),null}}function Ch(){Y.clear(),p=null,Q=!1,v=null,I="",S.clear(),h.clear(),he=null,G.clear()}var fe=!1;async function ic(n){try{let t=le({name:"css",cwd:n})?"css":le({name:"crosswind",cwd:n})?"crosswind":null;if(!t)return null;if(t==="crosswind"&&!process.env.STACKS_DEV_QUIET&&!fe)fe=!0,console.warn(`${e.yellow}[ts-css]${e.reset} Reading the CSS config from a \`crosswind\` file. Rename it to \`css\` (e.g. config/css.ts) \u2014 the old name is deprecated.`);let{loadConfigWithResult:s}=await import("bunfig"),r=await s({name:t,cwd:n,defaultConfig:{},checkEnv:!1,verbose:!1});if(!r?.path||!r.config||Object.keys(r.config).length===0)return null;let i=d.relative(n,r.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} Loaded config from ${i||r.path}`);return r.config}catch(t){if(t instanceof Error&&t.name==="ConfigNotFoundError")return null;return console.warn(`${e.yellow}[ts-css]${e.reset} Failed to load css config:`,t instanceof Error?t.message:t),null}}async function Tf(n){let t=null;try{let{loadStxConfig:s}=await import("./chunk-cd2wda5c.js"),r=await s(n);if(r.css)if(typeof r.css==="string"){let i=d.isAbsolute(r.css)?r.css:d.resolve(n,r.css);if(await Bun.file(i).exists()){let o=await import(i);t=o.default||o,console.log(`${e.green}[ts-css]${e.reset} Loaded config from stx.config.ts \u2192 ${r.css}`)}}else{if(t={...r.css,content:r.css.content||[],preflight:r.css.preflight??!0,minify:r.css.minify??!1},r.css.config){let i=d.isAbsolute(r.css.config)?r.css.config:d.resolve(n,r.css.config);if(await Bun.file(i).exists()){let o=await import(i);t={...o.default||o,...t}}}console.log(`${e.green}[ts-css]${e.reset} Using inline CSS config from stx.config.ts`)}}catch{}return t||await ic(n)}function $f(n){try{let t=new WeakSet;return L(JSON.stringify(n??{},(s,r)=>{if(typeof r==="function")return`[fn]${String(r)}`;if(typeof r==="object"&&r!==null){if(t.has(r))return"[circular]";t.add(r)}return r})??"")}catch{return"unhashable"}}async function cn(n){if(B)return I;B=!0;try{let t=await oc();if(!t||!t.build)return B=!1,"";if(!v)v=await ic(n);if(!v)return B=!1,"";let s=t.defaultConfig?.theme||{},r=v.theme||{},i={...t.defaultConfig,...v,theme:{...s,...r,extend:{...s.extend||{},...r.extend||{}}}},o=performance.now(),a=await t.build(i),g=performance.now()-o;if(I=a.css,console.log(`${e.cyan}[ts-css]${e.reset} Built ${a.classes.size} classes in ${g.toFixed(1)}ms`),i.output){let c=d.isAbsolute(i.output)?i.output:d.join(n,i.output),u=d.dirname(c);if(!M.existsSync(u))M.mkdirSync(u,{recursive:!0});await Bun.write(c,a.css)}return B=!1,a.css}catch(t){return console.error(`${e.red}[ts-css]${e.reset} Build error:`,t),B=!1,I}}async function sr(n){v=null,await cn(n)}function Eh(){return I}function Rf(n){let t=new Set,s=/class\s*=\s*["']([^"']+)["']/gi,r=s.exec(n);while(r!==null){for(let a of r[1].split(/\s+/))if(a.trim())t.add(a.trim());r=s.exec(n)}let i=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,o=i.exec(n);while(o!==null){let a=o[1].match(/'([^']+)'/g);if(a){for(let g of a)for(let c of g.slice(1,-1).split(/\s+/))if(c.trim())t.add(c.trim())}o=i.exec(n)}return t}var Y=b(64);async function Af(n,t){let s=()=>G.get(t?d.resolve(t):process.cwd())?.fingerprint??null,r=Y.get(x(n,t,s()));if(r!==void 0)return r;let i=await $e(n,t);if(i)Y.set(x(n,t,s()),i);return i}function*me(n){yield n;let t=new Set;for(let s of n.matchAll(/\/_stx\/modules\.([0-9a-f]{16})\.js/g)){let r=s[1];if(t.has(r))continue;t.add(r);let i=Ko(r);if(i)yield i}}function Th(n){return[...me(n)].join(`
|
|
7
|
+
`)}async function $e(n,t){try{let s=await oc();if(!s)return"";let r=new Set;for(let f of me(n)){let j=typeof s.extractClasses==="function"?s.extractClasses(f):Rf(f);for(let J of j)r.add(J)}if(r.size===0)return"";let i=t?d.resolve(t):process.cwd(),o=l(i,"cache");if(!z)z=o;let a=G.get(i);if(!a){let f=await Tf(i);a={config:f,fingerprint:$f(f)},G.set(i,a),he=a.fingerprint}let g=[...r].sort().join(" "),c=`${A}::${a.fingerprint||"default"}::${g}`,u=S.get(c);if(u!==void 0)return W(c,u),u;let m=await Ce(c,o);if(m!==null)return W(c,m),m;let H=s.defaultConfig||s.config,R=a.config||{},k=ae(H,R),{safelist:E,includePreflight:_,minify:P,tokenCSS:K}=k;if(k.unknownRoles.length>0&&!ge.has(i))ge.add(i),console.warn(`${e.yellow}[ts-css]${e.reset} No stx role for ${k.unknownRoles.join(", ")} - these keep the stock value. Role names: semanticTokenNames() in @stacksjs/stx/theme-tokens.`);let D=k.config,O=new s.CSSGenerator(D),T=D.shortcuts||R.shortcuts||{},N=Object.keys(T).filter((f)=>r.has(f)||E.includes(f));for(let f of E)if(!T[f])O.generate(f);for(let f of r)if(!T[f])O.generate(f);let C="";if(N.length>0){let f=new s.CSSGenerator(D);for(let j of N)f.generate(j);if(C=f.toCSS(!1,P),C&&!C.endsWith(`
|
|
8
8
|
`))C+=`
|
|
9
|
-
`}let w=C+O.toCSS(_,P);return w=ce(s.CSSGenerator,k)+K+w,W(c,w),Se(c,w,o),w}catch(s){return console.warn("Failed to generate Css CSS:",s),""}}async function y(n,t,s=!1,r=!1){let i=await
|
|
9
|
+
`}let w=C+O.toCSS(_,P);return w=ce(s.CSSGenerator,k)+K+w,W(c,w),Se(c,w,o),w}catch(s){return console.warn("Failed to generate Css CSS:",s),""}}async function y(n,t,s=!1,r=!1){let i=await Af(n,t);if(!i)return r?fn(n):n;let o=s?`<link data-css="generated" rel="stylesheet" href="/_stx/css.${ke(i)}.css">`:`<style data-css="generated">
|
|
10
10
|
${i}
|
|
11
11
|
</style>`;if(r)return Te(n,o);let a=/(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g;if(a.test(n)){let g=!1;return n.replace(a,()=>{if(g)return"";return g=!0,o})}if(n.includes("</head>"))return n.replace("</head>",`${o}
|
|
12
12
|
</head>`);if(n.includes("<body"))return n.replace(/<body([^>]*)>/,`<body$1>
|
|
13
|
-
${o}`);return o+n}function Te(n,t){let s=
|
|
13
|
+
${o}`);return o+n}function Te(n,t){let s=pi(n).map((c)=>({...c,replacement:""})),r=/(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g,i=r.exec(n);if(i!==null){let c=!0;while(i!==null)s.push({start:i.index,end:i.index+i[0].length,replacement:c?t:""}),c=!1,i=r.exec(n)}else{let c=n.indexOf("</head>");if(c!==-1)s.push({start:c,end:c,replacement:`${t}
|
|
14
14
|
`});else{let u=n.match(/<body([^>]*)>/);if(u?.index!==void 0)s.push({start:u.index,end:u.index+u[0].length,replacement:`${u[0]}
|
|
15
15
|
${t}`});else s.push({start:0,end:0,replacement:t})}}s.sort((c,u)=>c.start-u.start||c.end-u.end);for(let c=1;c<s.length;c++)if(s[c].start<s[c-1].end)return je(fn(n),t);let o=Array(s.length*2+1),a=0,g=0;for(let c of s)o[g++]=n.slice(a,c.start),o[g++]=c.replacement,a=c.end;return o[g]=n.slice(a),o.join("")}function je(n,t){let s=/(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g;if(s.test(n)){let r=!1;return n.replace(s,()=>{if(r)return"";return r=!0,t})}if(n.includes("</head>"))return n.replace("</head>",`${t}
|
|
16
16
|
</head>`);if(n.includes("<body"))return n.replace(/<body([^>]*)>/,`<body$1>
|
|
17
17
|
${t}`);return t+n}
|
|
18
|
-
export{bt,
|
|
18
|
+
export{bt,Ke,ye,an,Ae,nr,rr,Ge,e,_h,oc,Ch,ic,Tf,$f,cn,sr,Eh,Rf,Af,Th,y};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
function
|
|
2
|
+
function ha(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="id",dynamicHeight:d=!1,estimatedItemHeight:g=l,direction:x="vertical"}=c,e=[...v],t=0,n=new Map;function f(){if(d)return h();let i=Math.max(0,Math.floor(t/l)-s),r=Math.ceil(u/l),m=Math.min(e.length-1,i+r+s*2);return{startIndex:i,endIndex:m}}function h(){let i=0,r=0,m=e.length-1;for(let p=0;p<e.length;p++){let M=n.get(p)||g;if(i+M>t){r=Math.max(0,p-s);break}i+=M}i=0;for(let p=0;p<e.length;p++){let M=n.get(p)||g;if(i+=M,i>t+u){m=Math.min(e.length-1,p+s);break}}return{startIndex:r,endIndex:m}}function w(){if(d){let i=0;for(let r=0;r<e.length;r++)i+=n.get(r)||g;return i}return e.length*l}function y(i){if(d){let r=0;for(let m=0;m<i;m++)r+=n.get(m)||g;return r}return i*l}function S(){let{startIndex:i,endIndex:r}=f();return{startIndex:i,endIndex:r,scrollTop:t,totalHeight:w(),visibleItems:e.slice(i,r+1),itemHeights:new Map(n)}}function L(i,r="auto"){let m=y(i);a(m,r)}function a(i,r="auto"){t=Math.max(0,Math.min(i,w()-u))}function o(){f()}function H(i){e=[...i],n.clear(),o()}function I(){e=[],n.clear()}return{scrollToIndex:L,scrollToOffset:a,getState:S,refresh:o,setItems:H,destroy:I}}function ya(v,c={},l){let u=/@virtualList\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@endvirtualList/gi;return v.replace(u,(s,b,d,g)=>{let x=b.trim(),e=c[x];if(!e||!Array.isArray(e))return`<!-- virtualList: items "${x}" not found or not an array -->`;let t={itemHeight:50,containerHeight:400,overscan:3};if(d)try{let a=d.trim(),o=Function(`return ${a}`)();t={...t,...o}}catch{}let n=`vlist-${Math.random().toString(36).substring(2,9)}`,f=Math.ceil(t.containerHeight/t.itemHeight),h=t.overscan||3,w=0,y=Math.min(e.length-1,f+h),S="";for(let a=w;a<=y&&a<e.length;a++){let o=e[a],H=g.replace(/\{\{\s*item\s*\}\}/g,typeof o==="object"?JSON.stringify(o):String(o)).replace(/\{\{\s*item\.(\w+)\s*\}\}/g,(I,i)=>{if(typeof o==="object"&&o!==null)return String(o[i]??"");return""}).replace(/\{\{\s*index\s*\}\}/g,String(a));S+=`
|
|
3
3
|
<div class="virtual-item ${t.itemClass||""}"
|
|
4
4
|
style="position: absolute; top: ${a*t.itemHeight}px; height: ${t.itemHeight}px; width: 100%;"
|
|
5
5
|
data-index="${a}">
|
|
@@ -76,7 +76,7 @@ function ma(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="
|
|
|
76
76
|
};
|
|
77
77
|
})();
|
|
78
78
|
</script>
|
|
79
|
-
`})}function
|
|
79
|
+
`})}function ql(){return`
|
|
80
80
|
.virtual-list-container {
|
|
81
81
|
position: relative;
|
|
82
82
|
overflow-y: auto;
|
|
@@ -124,7 +124,7 @@ function ma(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="
|
|
|
124
124
|
0% { background-position: 200% 0; }
|
|
125
125
|
100% { background-position: -200% 0; }
|
|
126
126
|
}
|
|
127
|
-
`}function
|
|
127
|
+
`}function Xl(v,c){let l=null,u=()=>{if(!l)l=ha(v(),c);return l};return{visibleItems:()=>u().getState().visibleItems,totalHeight:()=>u().getState().totalHeight,containerProps:()=>({style:{height:`${c.containerHeight}px`,overflow:"auto",position:"relative"},onScroll:(s)=>{let b=s.target;if(l)l.scrollToOffset(b.scrollTop)}}),itemProps:(s)=>({style:{position:"absolute",top:`${s*c.itemHeight}px`,height:`${c.itemHeight}px`,width:"100%"},"data-index":s}),scrollToIndex:(s)=>{u().scrollToIndex(s)}}}function Kl(v,c={},l){let u=/@infiniteList\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@loading\s*([\s\S]*?)@endinfiniteList/gi;return v.replace(u,(s,b,d,g,x)=>{let e=b.trim(),t=c[e];if(!t||!Array.isArray(t))return`<!-- infiniteList: items "${e}" not found or not an array -->`;let n={itemHeight:50,containerHeight:400,overscan:3,threshold:100,hasMore:!0};if(d)try{let w=Function(`return ${d.trim()}`)();n={...n,...w}}catch{}let f=`ilist-${Math.random().toString(36).substring(2,9)}`,h=ya(`@virtualList(${e}, ${JSON.stringify({itemHeight:n.itemHeight,containerHeight:n.containerHeight,overscan:n.overscan,containerClass:n.containerClass})})${g}@endvirtualList`,c);return h=h.replace("</script>",`
|
|
128
128
|
// Infinite scroll detection
|
|
129
129
|
container.addEventListener('scroll', function() {
|
|
130
130
|
const scrollBottom = container.scrollTop + container.clientHeight;
|
|
@@ -142,7 +142,7 @@ function ma(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="
|
|
|
142
142
|
${x}
|
|
143
143
|
</div>
|
|
144
144
|
</div>
|
|
145
|
-
`})}function
|
|
145
|
+
`})}function Gl(v,c={},l){let u=/@virtualGrid\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@endvirtualGrid/gi;return v.replace(u,(s,b,d,g)=>{let x=b.trim(),e=c[x];if(!e||!Array.isArray(e))return`<!-- virtualGrid: items "${x}" not found or not an array -->`;let t={columns:3,rowHeight:100,containerHeight:400,gap:10,overscan:2};if(d)try{let o=Function(`return ${d.trim()}`)();t={...t,...o}}catch{}let n=`vgrid-${Math.random().toString(36).substring(2,9)}`,f=Math.ceil(e.length/t.columns),h=f*(t.rowHeight+(t.gap||0)),w=Math.ceil(t.containerHeight/(t.rowHeight+(t.gap||0))),y=t.overscan||2,S=0,L=Math.min(f-1,w+y),a="";for(let o=S;o<=L;o++)for(let H=0;H<t.columns;H++){let I=o*t.columns+H;if(I>=e.length)break;let i=e[I],r=H*(100/t.columns),m=o*(t.rowHeight+(t.gap||0)),p=g.replace(/\{\{\s*item\s*\}\}/g,typeof i==="object"?JSON.stringify(i):String(i)).replace(/\{\{\s*item\.(\w+)\s*\}\}/g,(M,T)=>{if(typeof i==="object"&&i!==null)return String(i[T]??"");return""}).replace(/\{\{\s*index\s*\}\}/g,String(I));a+=`
|
|
146
146
|
<div class="virtual-grid-item"
|
|
147
147
|
style="position: absolute; top: ${m}px; left: ${r}%; width: calc(${100/t.columns}% - ${t.gap||0}px); height: ${t.rowHeight}px;"
|
|
148
148
|
data-index="${I}">
|
|
@@ -212,5 +212,5 @@ function ma(v,c){let{itemHeight:l,containerHeight:u,overscan:s=3,keyProperty:b="
|
|
|
212
212
|
});
|
|
213
213
|
})();
|
|
214
214
|
</script>
|
|
215
|
-
`})}var
|
|
216
|
-
export{
|
|
215
|
+
`})}var $m={createVirtualList:ha,processVirtualListDirectives:ya,processInfiniteListDirectives:Kl,processVirtualGridDirectives:Gl,generateVirtualListCSS:ql,useVirtualList:Xl};
|
|
216
|
+
export{ha,ya,ql,Xl,Kl,Gl,$m};
|
|
@@ -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 Jl(){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 Yl(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 Zl(){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 Ql(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 eu(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 tu(){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 nu(e){if(typeof window>"u")return!1;return document.querySelector(`[data-island="${e}"]`)?.classList.contains("hydrated")??!1}function ru(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 su(e){return e.replace(/@static\s*([\s\S]*?)@endstatic/gi,(t,n)=>`<div class="stx-static">${n.trim()}</div>`)}function ou(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 Rm={processPartialHydrationDirectives:Yl,processStaticDirectives:su,generatePartialHydrationCSS:Zl,generateIslandManifest:ou,createIslandRegistry:Jl,hydrateIsland:Ql,hydrateByStrategy:eu,hydrateAll:tu,isHydrated:nu,onHydrated:ru};
|
|
391
|
+
export{Jl,Yl,Zl,Ql,eu,tu,nu,ru,su,ou,Rm};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Wg}from"./chunk-a3xqfyb6.js";import"./chunk-9x62j5f0.js";import"./chunk-3mby4nes.js";import"./chunk-2ws2qe1k.js";import"./chunk-qpvwxppw.js";import"./chunk-7bxnjr3b.js";import"./chunk-qjbpa1n4.js";import"./chunk-wp6bdac7.js";import"./chunk-zbv8e4rq.js";import"./chunk-akcyaxwv.js";import"./chunk-4v50nafp.js";import"./chunk-2yxva96k.js";import"./chunk-t65tn8ee.js";export{Wg as buildApp};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{lt,ut,dt}from"./chunk-7qk4exw1.js";import"./chunk-
|
|
2
|
+
import{lt,ut,dt}from"./chunk-7qk4exw1.js";import"./chunk-t65tn8ee.js";import"./chunk-2yxva96k.js";import{m}from"./chunk-wp6bdac7.js";import"./chunk-4v50nafp.js";import"./chunk-akcyaxwv.js";import"./chunk-zbv8e4rq.js";import{Vt,no,Ut,Ui,ct,Wi,ro,Wt,Xi,qt}from"./chunk-gvnfb6s2.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(d)=>{if(d==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{Wi("Config file changed, restarting...");try{await e.onChange()}catch(p){ct(`Failed to restart: ${p}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var nt=".stx/story/analytics.json",st=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,nt),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:st,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:at(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let d=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),p=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),g=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,y=Object.entries(c).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:d.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:g}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function at(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var it=".stx/story/bookmarks.json",pt=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,it),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:pt,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:mt(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function mt(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
const ws = new WebSocket('${t}');
|
|
@@ -556,9 +556,9 @@ window.__stxPerformance = {
|
|
|
556
556
|
|
|
557
557
|
window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
|
|
558
558
|
</script>
|
|
559
|
-
`}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-
|
|
559
|
+
`}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-k8gpvg0w.js"),p={},g=h(n);if(g)try{await m(g,p,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),u=h(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:u,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await m(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-k8gpvg0w.js"),c={...r},n=h(e);if(n)try{await m(n,c,"inline-template.stx")}catch{}let p=await a(e,c,"inline-template.stx",{},new Set);return p=Q(p),p=tt(p,c),{html:p,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
|
|
560
560
|
`)}function Q(t){return t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function h(t){let e=[],r=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
|
|
561
|
-
`)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function rt(t,e){let r=await Wt(t);ut(t,r);let s=qt(t.config,r);dt(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),d=N(),p=Bun.serve({port:e.port,hostname:o,fetch:async(i,l)=>{let f=new URL(i.url).pathname;if(f==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(f.startsWith("/api/"))return xt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,f,e.port)},websocket:{open(i){d.open(i)},close(i){d.close(i)},message(i,l){d.message(i,l)}}}),g=`http://${o}:${e.port}`,y=
|
|
561
|
+
`)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function rt(t,e){let r=await Wt(t);ut(t,r);let s=qt(t.config,r);dt(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),d=N(),p=Bun.serve({port:e.port,hostname:o,fetch:async(i,l)=>{let f=new URL(i.url).pathname;if(f==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(f.startsWith("/api/"))return xt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,f,e.port)},websocket:{open(i){d.open(i)},close(i){d.close(i)},message(i,l){d.message(i,l)}}}),g=`http://${o}:${e.port}`,y=Xi(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let u=await Wt(t);ut(t,u);let f=qt(t.config,u);if(dt(t,f),i==="add")H(l.id,{fileName:l.fileName});else if(i==="unlink")O(l.id);else V(l.id,{fileName:l.fileName})});if(e.open){let i=g;try{let{exec:l}=await import("child_process"),u=process.platform;l(`${u==="darwin"?"open":u==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:p,url:g,close:async()=>{y(),p.stop()}}}async function xt(t,e,r,s){let{presetsManager:o,bookmarksManager:a,analyticsTracker:c}=s;if(e==="/api/stories")return Response.json({files:t.storyFiles.map((n)=>({id:n.id,fileName:n.fileName,relativePath:n.relativePath,treePath:n.treePath})),tree:t.tree});if(e.startsWith("/api/story/")){let n=e.slice(11),d=t.storyFiles.find((p)=>p.id===n);if(!d)return new Response("Story not found",{status:404});try{let p=await Bun.file(d.path).text();return Response.json({id:d.id,fileName:d.fileName,relativePath:d.relativePath,content:p})}catch{return new Response("Error reading story",{status:500})}}if(e==="/api/config")return Response.json({theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets});if(e.startsWith("/api/render/")){let n=new URL(r.url),d=e.slice(12).split("/"),p=d[0],g=d[1]||"default",y,i=n.searchParams.get("props");if(i)try{y=JSON.parse(i)}catch{}let l=t.storyFiles.find((u)=>u.id===p);if(!l)return new Response("Story not found",{status:404});try{let u=await Y(t,l,g,y);return Response.json({html:u.html,css:u.css,js:u.js,errors:u.errors,duration:u.duration})}catch(u){return Response.json({html:"",css:"",js:"",errors:[u instanceof Error?u.message:String(u)],duration:0},{status:500})}}if(e==="/api/presets"&&r.method==="GET")return Response.json({presets:o.getAllPresets()});if(e==="/api/presets"&&r.method==="POST")try{let n=await r.json(),d=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/presets/")&&!e.includes("/use")&&r.method==="GET"){let n=e.slice(13),d=o.getPreset(n);if(!d)return new Response("Preset not found",{status:404});return Response.json(d)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),d=o.usePreset(n);if(!d)return new Response("Preset not found",{status:404});return await o.save(),Response.json(d)}if(e.startsWith("/api/presets/")&&r.method==="DELETE"){let n=e.slice(13);if(!o.deletePreset(n))return new Response("Preset not found",{status:404});return await o.save(),Response.json({success:!0})}if(e==="/api/bookmarks"&&r.method==="GET")return Response.json({bookmarks:a.getAllBookmarks()});if(e==="/api/bookmarks"&&r.method==="POST")try{let n=await r.json(),d=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),d=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/bookmarks/")&&e!=="/api/bookmarks/toggle"&&r.method==="GET"){let n=e.slice(15),d=a.getBookmark(n);if(!d)return new Response("Bookmark not found",{status:404});return Response.json(d)}if(e.startsWith("/api/bookmarks/")&&r.method==="DELETE"){let n=e.slice(15);if(!a.deleteBookmark(n))return new Response("Bookmark not found",{status:404});return await a.save(),Response.json({success:!0})}if(e==="/api/analytics/track"&&r.method==="POST")try{let n=await r.json();if(n.type==="view"&&n.componentId)c.trackView(n.componentId,n.variantId);else if(n.type==="prop_change"&&n.componentId&&n.propName)c.trackPropChange(n.componentId,n.propName,null);else if(n.type==="variant_switch"&&n.componentId&&n.variantId)c.trackVariantSwitch(n.componentId,n.variantId);else if(n.type==="search"&&n.query)c.trackSearch(n.query,0);return await c.save(),Response.json({success:!0})}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/analytics/summary"&&r.method==="GET")return Response.json({mostViewed:c.getMostViewedComponents(10),mostChangedProps:c.getMostChangedProps(10),searchAnalytics:c.getSearchAnalytics()});if(e.startsWith("/api/analytics/component/")&&r.method==="GET"){let n=e.slice(25),d=t.storyFiles.find((g)=>g.id===n),p=c.getComponentAnalytics(n,d?.fileName||n);return Response.json(p)}return new Response("Not found",{status:404})}function wt(t,e,r){let s=kt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function kt(t,e){let{theme:r}=t.config,s=r.title||"STX Story",o=`ws://localhost:${e}/__hmr`,a=F(o);return`<!DOCTYPE html>
|
|
562
562
|
<html lang="en" class="${r.darkClass||"dark"}">
|
|
563
563
|
<head>
|
|
564
564
|
<meta charset="UTF-8">
|
|
@@ -1276,5 +1276,5 @@ else {
|
|
|
1276
1276
|
<style>${W()}</style>
|
|
1277
1277
|
${D()}
|
|
1278
1278
|
</body>
|
|
1279
|
-
</html>`}import St from"fs";import Pt from"path";var Ct=new Map,Tt=[],Rt=[],It=new Map;async function ot(t){let e=t.config.setupFile;if(!e)return;let r=Pt.resolve(t.root,e);try{await St.promises.access(r)}catch{return}let s={storyContext:t,registerComponent:(o,a)=>{Ct.set(o,a)},addCSS:(o)=>{Tt.push(o)},addScript:(o)=>{Rt.push(o)},setState:(o,a)=>{It.set(o,a)}};try{let o=await import(r);if(typeof o.default==="function")await o.default(s);else if(typeof o.setupStory==="function")await o.setupStory(s)}catch(o){console.warn(`Warning: Failed to load setup file: ${o}`)}}async function we(t={}){Vt();let e=await lt({mode:"dev"});if(!e.config.enabled){ct("Story feature is disabled in config.");return}await ot(e);let r=t.port??e.config.port,s,o=async()=>{s=await rt(e,{port:r,open:t.open,host:t.host}),Ut(e.storyFiles.length),
|
|
1280
|
-
`),a.stop(),await s.close(),process.exit(0)};if(process.on("SIGINT",c),process.on("SIGTERM",c),process.stdin.isTTY)process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",async(n)=>{switch(n.toString()){case"h":
|
|
1279
|
+
</html>`}import St from"fs";import Pt from"path";var Ct=new Map,Tt=[],Rt=[],It=new Map;async function ot(t){let e=t.config.setupFile;if(!e)return;let r=Pt.resolve(t.root,e);try{await St.promises.access(r)}catch{return}let s={storyContext:t,registerComponent:(o,a)=>{Ct.set(o,a)},addCSS:(o)=>{Tt.push(o)},addScript:(o)=>{Rt.push(o)},setState:(o,a)=>{It.set(o,a)}};try{let o=await import(r);if(typeof o.default==="function")await o.default(s);else if(typeof o.setupStory==="function")await o.setupStory(s)}catch(o){console.warn(`Warning: Failed to load setup file: ${o}`)}}async function we(t={}){Vt();let e=await lt({mode:"dev"});if(!e.config.enabled){ct("Story feature is disabled in config.");return}await ot(e);let r=t.port??e.config.port,s,o=async()=>{s=await rt(e,{port:r,open:t.open,host:t.host}),Ut(e.storyFiles.length),no(s.url),ro()};await o();let a=E(e,{onChange:async()=>{await s.close();let n=await lt({mode:"dev"});Object.assign(e,n),await o()}}),c=async()=>{console.log(`
|
|
1280
|
+
`),a.stop(),await s.close(),process.exit(0)};if(process.on("SIGINT",c),process.on("SIGTERM",c),process.stdin.isTTY)process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",async(n)=>{switch(n.toString()){case"h":ro();break;case"o":try{let{exec:p}=await import("child_process"),g=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";p(`${g} ${s.url}`)}catch{Ui("Failed to open browser")}break;case"r":await s.close(),await o();break;case"c":console.clear(),Vt(),Ut(e.storyFiles.length),no(s.url);break;case"q":case"\x03":await c();break}});await new Promise(()=>{})}export{we as devCommand};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{u,f,R,d,q}from"./chunk-
|
|
2
|
+
import{u,f,R,d,q}from"./chunk-4v50nafp.js";import{z,Is,U,Oe,de,kr,je,Be,s,h,Se,_}from"./chunk-wp6bdac7.js";import{at}from"./chunk-t65tn8ee.js";import{A}from"./chunk-2yxva96k.js";import{se}from"./chunk-yv4dwdhc.js";import{L,Ye}from"./chunk-k3rcpnzm.js";import{E,_n}from"./chunk-w0zayhmg.js";import C from"path";import{existsSync as St}from"fs";function ct(a,t){let c=0;for(let i=t;i<a.length;i++){let S=a[i];if(S==="("||S==="["||S==="{")c++;else if(S===")"||S==="]"||S==="}")c--;else if(S===","&&c===0)return i}return-1}function yt(a,t,c){let i=a,S=new RegExp(`${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),n=S.exec(i);while(n){let g=n.index,e=g+n[0].length-1,D=1,Z=e+1;while(Z<i.length&&D>0){if(i[Z]==="(")D++;else if(i[Z]===")")D--;Z++}if(D!==0)break;let rt=i.substring(e+1,Z-1),N=`${c}(${rt})`;i=i.substring(0,g)+N+i.substring(Z),S.lastIndex=g+N.length,n=S.exec(i)}return i}function $t(a){return/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(a)}function mt(a){let t=a,c=[],i=new Set,S=0,n=0,g=t.length,e=(N)=>{n++;while(n<g){if(t[n]==="\\"){n+=2;continue}if(t[n]===N){n++;return}n++}},D=()=>{n++;while(n<g){if(t[n]==="\\"){n+=2;continue}if(t[n]==="`"){n++;return}if(t[n]==="$"&&t[n+1]==="{"){n+=2;let N=1;while(n<g&&N>0)if(t[n]==="{")N++,n++;else if(t[n]==="}")N--,n++;else if(t[n]==="'"||t[n]==='"')e(t[n]);else if(t[n]==="`")D();else n++;continue}n++}},Z=()=>{if(t[n]==="/"&&t[n+1]==="/"){while(n<g&&t[n]!==`
|
|
3
3
|
`)n++;return!0}if(t[n]==="/"&&t[n+1]==="*"){n+=2;while(n<g-1&&!(t[n]==="*"&&t[n+1]==="/"))n++;return n+=2,!0}return!1},rt=()=>{if(S!==0)return;let N=t.slice(n).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(N){let H=N[2];if(!i.has(H))c.push(H),i.add(H);return}let et=t.slice(n).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(et){let H=et[1];if(!i.has(H))c.push(H),i.add(H);return}let Y=t.slice(n).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(Y){let H=Y[1];if(!i.has(H))c.push(H),i.add(H)}};while(n<g){if(Z())continue;if(t[n]==="'"||t[n]==='"'){e(t[n]);continue}if(t[n]==="`"){D();continue}if(t[n]==="{"){S++,n++;continue}if(t[n]==="}"){S--,n++;continue}if(S===0&&/[a-z]/i.test(t[n])&&(n===0||/\s|[;{}()]/.test(t[n-1])))rt();n++}return c.join(", ")}function Et(a,t=""){let c=mt(a).split(",").map((i)=>i.trim()).filter(Boolean);return`
|
|
4
4
|
(function() {
|
|
5
5
|
${at("var",c)}
|
|
@@ -9,7 +9,7 @@ import{u,f,R,d,q}from"./chunk-624xpap6.js";import{z,Ps,U,Oe,de,kr,je,Be,s,h,Se,_
|
|
|
9
9
|
|
|
10
10
|
${a}
|
|
11
11
|
${t}})();
|
|
12
|
-
`}function vt(a,t){let i=mt(a).split(",").map((g)=>g.trim()).filter(Boolean),S=new Set(z(a,!0).split(",").map((g)=>g.trim())),n=i.map((g)=>S.has(g)?` try { ${g}; Object.defineProperty(__scopeRegistration, ${JSON.stringify(g)}, ${
|
|
12
|
+
`}function vt(a,t){let i=mt(a).split(",").map((g)=>g.trim()).filter(Boolean),S=new Set(z(a,!0).split(",").map((g)=>g.trim())),n=i.map((g)=>S.has(g)?` try { ${g}; Object.defineProperty(__scopeRegistration, ${JSON.stringify(g)}, ${Is(g)}); } catch (e) { /* not actually top-level */ }`:` try { __scopeRegistration[${JSON.stringify(g)}] = ${g}; } catch (e) { /* not actually top-level */ }`).join(`
|
|
13
13
|
`);return`
|
|
14
14
|
// Register scope variables for STX runtime
|
|
15
15
|
if (!window.stx._scopes) window.stx._scopes = {};
|
|
@@ -44,11 +44,11 @@ ${n}
|
|
|
44
44
|
}
|
|
45
45
|
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
46
46
|
}
|
|
47
|
-
})();`;return c+a+i}function It(a,t){if(L(a)){let S=L(a).tag.match(/data-stx-scope="([^"]*)"/);if(S)return{html:a,mergedIntoExisting:S[1],stamped:!0,root:"body"};return{html:Ye(a,(n,g)=>`<body${g} data-stx-scope="${t}">`),mergedIntoExisting:null,stamped:!0,root:"body"}}let c=a.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(c){let i=c[2]+c[3],S=c[2].slice(1),n=i.match(/data-stx-scope="([^"]*)"/);if(n)return{html:a,mergedIntoExisting:n[1],stamped:!0,root:S};let g=c[1],e=c[2],D=c[3];return{html:`${g}${e} data-stx-scope="${t}"${D}${a.slice(c[0].length)}`,mergedIntoExisting:null,stamped:!0,root:S}}return{html:a,mergedIntoExisting:null,stamped:!1,root:null}}var Mt=0;function ut(a,t){let c=C.basename(a,".stx").replace(/[^a-zA-Z0-9]/g,"_"),i=t.__stx_scope_seq;return i?`stx_scope_${c}_${++i.n}_${i.key}`:`stx_scope_${c}_${++Mt}`}var lt=new Set,pt=new Set;function
|
|
47
|
+
})();`;return c+a+i}function It(a,t){if(L(a)){let S=L(a).tag.match(/data-stx-scope="([^"]*)"/);if(S)return{html:a,mergedIntoExisting:S[1],stamped:!0,root:"body"};return{html:Ye(a,(n,g)=>`<body${g} data-stx-scope="${t}">`),mergedIntoExisting:null,stamped:!0,root:"body"}}let c=a.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(c){let i=c[2]+c[3],S=c[2].slice(1),n=i.match(/data-stx-scope="([^"]*)"/);if(n)return{html:a,mergedIntoExisting:n[1],stamped:!0,root:S};let g=c[1],e=c[2],D=c[3];return{html:`${g}${e} data-stx-scope="${t}"${D}${a.slice(c[0].length)}`,mergedIntoExisting:null,stamped:!0,root:S}}return{html:a,mergedIntoExisting:null,stamped:!1,root:null}}var Mt=0;function ut(a,t){let c=C.basename(a,".stx").replace(/[^a-zA-Z0-9]/g,"_"),i=t.__stx_scope_seq;return i?`stx_scope_${c}_${++i.n}_${i.key}`:`stx_scope_${c}_${++Mt}`}var lt=new Set,pt=new Set;function $h(){lt.clear(),pt.clear()}var Tt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Pf(a){let t=(e)=>e.replace(/[^\n]/g," "),c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,t).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,t).replace(/<!--[\s\S]*?-->/g,t).replace(/\x00STX_HTML_COMMENT_\d+\x00/g,t).replace(/\{\{[\s\S]*?\}\}/g,t).replace(/\{!![\s\S]*?!!\}/g,t),i=[],S=0,n=/<(\/?)([A-Za-z][\w-]*)\b(?:[^<>"']|"[^"]*"|'[^']*')*?(\/?)>/g,g;while((g=n.exec(c))!==null){let e=g[1]==="/",D=g[2],Z=g[3]==="/"||Tt.has(D.toLowerCase());if(e){S=Math.max(0,S-1);continue}if(S===0)i.push(D);if(!Z)S++}return i}function ft(a){return/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(a)}var Je=new U(500),ac=new Set;function Rh(){ac.clear()}function Ct(a){if(a.__onceStore instanceof Set)return a.__onceStore;return ac}async function as(a,t,c,i,S,n=new Set){let g=i.partialsDir||C.join(C.dirname(c),"partials");if(g&&!C.isAbsolute(g))g=C.resolve(process.cwd(),g);let e=yt(a,"@partial","@include"),D=Ct(t);e=e.replace(/@once([\s\S]*?)@endonce/g,(m,I,x)=>{let p=I.trim(),r=`${c}:${p}`;if(D.has(r))return"";return D.add(r),I});{let m=/@includeIf\s*\(/g,I;while((I=m.exec(e))!==null){let x=I.index,p=x+I[0].length-1,r=1,w=p+1;while(w<e.length&&r>0){if(e[w]==="(")r++;else if(e[w]===")")r--;w++}if(r!==0)break;let l=e.substring(p+1,w-1),o=l.match(/^\s*['"]([^'"]+)['"]/);if(!o){m.lastIndex=w;continue}let O=o[1],P=Z(O,g,c),k="";if(P&&await Bun.file(P).exists())S.add(P),k=`@include(${l})`;e=e.substring(0,x)+k+e.substring(w),m.lastIndex=0}}for(let[m,I]of[["@includeWhen",!1],["@includeUnless",!0]]){let x=new RegExp(`${m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),p;while((p=x.exec(e))!==null){let r=p.index,w=r+p[0].length-1,l=1,o=w+1;while(o<e.length&&l>0){if(e[o]==="(")l++;else if(e[o]===")")l--;o++}if(l!==0)break;let O=e.substring(w+1,o-1),P=ct(O,0);if(P===-1){x.lastIndex=o;continue}let k=O.substring(0,P).trim(),V=O.substring(P+1).trim(),W=V.match(/^\s*['"]([^'"]+)['"]/);if(!W){x.lastIndex=o;continue}let b=W[1],J=V.substring(W[0].length),B,M=ct(J,0);if(M!==-1)B=J.substring(M+1).trim();try{let T=`Boolean(${k})`,j;if(f(T)){let it=d(T,Object.keys(t));j=Boolean(it(...Object.values(t)))}else j=Boolean(u(T,t));let tt=I?!j:j,nt="";if(tt){let it=Z(b,g,c);if(it&&await Bun.file(it).exists())S.add(it);nt=`@include('${b}'${B?`, ${B}`:""})`}e=e.substring(0,r)+nt+e.substring(o),x.lastIndex=0}catch(T){let j=T instanceof Error?T.message:String(T),tt=h("Include",`Error evaluating ${m} condition: ${j}`,c,a,r);e=e.substring(0,r)+tt+e.substring(o),x.lastIndex=0}}}{let m=/@each\s*\(/g,I;while((I=m.exec(e))!==null){let x=I.index,p=x+I[0].length-1,r=1,w=p+1;while(w<e.length&&r>0){if(e[w]==="(")r++;else if(e[w]===")"){if(r--,r===0)break}w++}if(r!==0)break;let l=e.substring(p+1,w),o=e.substring(x,w+1),O=l.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!O){m.lastIndex=0,e=e.replace(o,"");continue}let[,P,k,V,W]=O;try{let b,J=k.trim();if(f(J))b=d(J,Object.keys(t))(...Object.values(t));else b=u(J,t);let B="";if(Array.isArray(b)&&b.length>0)for(let M of b){let T={...t,[V]:M},j=await et(P,T,a,x);B+=j}else if(W)B=await et(W,{},a,x);e=e.substring(0,x)+B+e.substring(w+1),m.lastIndex=0}catch(b){let J=b instanceof Error?b.message:String(b);e=e.substring(0,x)+h("Each",`Error in @each: ${J}`,c,a,x)+e.substring(w+1),m.lastIndex=0}}}{let m=/@includeFirst\s*\(/g,I;while((I=m.exec(e))!==null){let x=I.index,p=x+I[0].length-1,r=1,w=p+1;while(w<e.length&&r>0){if(e[w]==="(")r++;else if(e[w]===")"){if(r--,r===0)break}w++}if(r!==0)break;let l=e.substring(p+1,w),o=e.substring(x,w+1),O=l.match(/^\s*(\[[^\]]+\])/);if(!O){m.lastIndex=0,e=e.replace(o,"");continue}let P=O[1],k=l.slice(O[0].length),V,W=k.match(/^\s*,\s*\{/);if(W){k=k.slice(W[0].length-1);let B=1,M=1;while(M<k.length&&B>0){if(k[M]==="{")B++;else if(k[M]==="}"){if(B--,B===0)break}M++}V=k.substring(0,M+1),k=k.slice(M+1)}let b,J=k.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(J)b=J[1];try{let B=JSON.parse(P.replace(/'/g,'"')),M={};if(V)try{M=R(V,t)}catch(j){let tt=j instanceof Error?j.message:String(j);if(i.debug){let nt=h("Include",`Error parsing includeFirst variables: ${tt}`,c,a,x,o);e=e.replace(o,()=>nt)}else e=e.replace(o,()=>b||"");continue}let T=!1;for(let j of B){let tt=Z(j,g,c);if(!tt)continue;if(await s(tt)){let nt=await et(j,M,a,x);e=e.replace(o,()=>nt),T=!0;break}}if(!T)if(b!==void 0)e=e.replace(o,()=>b);else if(i.debug){let j=h("Include",`None of the includeFirst paths exist: ${P}`,c,a,x,o);e=e.replace(o,()=>j)}else e=e.replace(o,"")}catch(B){let M=B instanceof Error?B.message:String(B),T=h("Include",`Error processing @includeFirst: ${M}`,c,a,x,o);e=e.replace(o,()=>T)}m.lastIndex=0}}function Z(m,I,x){try{let p=m;if(!m.endsWith(".stx"))p=`${m}.stx`;let r=C.resolve(I),w=C.resolve(C.dirname(x)),l;if(!p.startsWith("./")&&!p.startsWith("../")){for(let W of i._layerPartialDirs??[]){let b=C.resolve(W,p);if(b.startsWith(`${C.resolve(W)}${C.sep}`)&&St(b))return b}l=C.resolve(I,p)}else l=C.resolve(w,p);let o=C.normalize(l),O=o.startsWith(r+C.sep)||o===r,P=o.startsWith(w+C.sep)||o===w,k=!1,V=C.dirname(w);if(o.startsWith(V+C.sep)){if(!C.relative(V,o).split(C.sep).some((B)=>B.startsWith(".")&&B!=="."&&B!==".."))k=!0}if(!O&&!P&&!k)return console.error(`Security: Path traversal attempt blocked for include path: ${m}`),console.error(` Resolved to: ${o}`),console.error(` Allowed dirs: ${r}, ${w}`),null;return o}catch(p){return console.error(`Error resolving path ${m}: ${p}`),null}}let rt=C.resolve(c);n.add(rt);function N(m,I,x,p){return i.onIncludeError?.({includePath:m,templatePath:c,message:I,partialsDir:g}),h("Include",I,c,x,p)}async function et(m,I={},x,p){let r=Z(m,g,c);if(!r)return N(m,`Could not resolve path for include: ${m}`,x,p);let w=C.resolve(r);if(n.has(w)){let l=[...n,w].map((o)=>C.basename(o)).join(" -> ");return N(m,`Circular include detected: ${l}`,x,p)}try{S.add(r);let l;if(!l)try{l=await Bun.file(r).text()}catch(v){let K=v instanceof Error?v.message:String(v);return N(m,`Error loading include file ${m}: ${K}`,x,p)}if(l)l=l.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(l&&l.includes("@stream")){let{processStreamDirectives:v}=await import("./chunk-c7x3bmvs.js");l=v(l,t)}if(l&&(i.debug||!E()&&!_n()))try{let{warnUnbalancedTags:v}=await import("./chunk-kgn911k7.js");v(l,r)}catch{}try{let{processESImports:v}=await import("./chunk-e14v1q9c.js");l=await v(l,t,r,i,S)}catch(v){if(i.debug)console.warn(`[stx] partial ES import extraction skipped for ${r}:`,v instanceof Error?v.message:v)}let o=l,O=de(o);if(O)o=O.content.trim();let k=l.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),V="";if(k)V=`<style${k[1]}>${k[2]}</style>`;let W=[];o=o.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(v,K,y)=>{if(!ft(K))return"";return W.push({attrs:K,body:y}),`__STX_DATA_BLOCK_${W.length-1}__`}),o=o.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let b={...t};b.__stx_signals_gate=Se(l,r);for(let[v,K]of Object.entries(I))b[v]=K;let J=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,B=[...l.matchAll(J)].sort((v,K)=>{let y=(v[1]||"").includes("server"),X=(K[1]||"").includes("server");return Number(X)-Number(y)}),M="",T=null,j=!1,tt=!1;for(let v of B){let K=v[1]||"",y=v[2]||"";if(ft(K))continue;let X=K.includes("server"),wt=je(K);if(!X&&!/\bsrc\s*=/i.test(K))Oe(y,r,i.strict);if(!X&&y.trim()){let{interpolateScriptExpressions:F}=await import("./chunk-eh528njb.js");y=F(y,b,m)}let ot="";try{let{extractAndStripCssImports:F,renderVendorStyleTags:Q}=await import("./chunk-7na8bets.js"),st=F(y,{filePath:r,projectRoot:process.cwd()});y=st.code,ot=Q(st.styles)}catch(F){if(i.debug)console.warn(`[stx] vendor-css extractor skipped for ${r}:`,F instanceof Error?F.message:F)}if(wt&&y.trim())y=Be(y);if(!X){try{let{injectBrowserCoreAutoImports:Q}=await import("./chunk-7na8bets.js");y=Q(y).code;let{hasUserImports:st,bundleClientScript:bt}=await import("./chunk-eeztqt6f.js");if(st(y))y=await bt(y,r,{projectRoot:process.cwd()})}catch(Q){if(i.debug)console.warn(`[stx] bundler skipped for ${r}:`,Q instanceof Error?Q.message:Q)}let{stripStxRuntimeImports:F}=await import("./chunk-6tp7ys77.js");y=F(y)}let dt=$t(y);if(!X){let{extractBridgeData:F,generateServerDataBridge:Q}=await import("./chunk-7na8bets.js"),st=Q(y,F(b));if(st)y=`${st}
|
|
48
48
|
${y}`}if(dt&&!X){j=!0,T=ut(r,t);let F=A(y),Q=gt(F,T);M+=`${ot}<script data-stx-scoped data-stx-run="always" data-stx-owner="${T}">${Q}</script>
|
|
49
|
-
`;continue}if(X)try{let{extractVariables:F}=await import("./chunk-
|
|
50
|
-
`}}if(W.length>0){let{interpolateScriptExpressions:v}=await import("./chunk-
|
|
49
|
+
`;continue}if(X)try{let{extractVariables:F}=await import("./chunk-e3xw2bzh.js");await F(y,b,r)}catch(F){if(i.debug)console.warn(`Warning: Could not extract variables from server script in ${r}:`,F)}if(!X&&!dt){let F=K.replace(/\bclient\b/i,"").trim();T=ut(r,t);let Q=A(y),st=gt(Q,T);if(/__scopeRegistration\["(?!__stx)[^"]+"\]\s*=|Object\.defineProperty\(__scopeRegistration, "(?!__stx)/.test(st))tt=!0;M+=`${ot}<script data-stx-scoped data-stx-run="always" data-stx-owner="${T}"${F?` ${F}`:""}>${st}</script>
|
|
50
|
+
`}}if(W.length>0){let{interpolateScriptExpressions:v}=await import("./chunk-eh528njb.js");o=o.replace(/__STX_DATA_BLOCK_(\d+)__/g,(K,y)=>{let X=W[Number(y)];return`<script${X.attrs}>${v(X.body,b,m)}</script>`})}if(T){let v=It(o,T);if(o=v.html,v.mergedIntoExisting){let y=T,X=v.mergedIntoExisting;M=M.split(`'${y}'`).join(`'${X}'`).split(`"${y}"`).join(`"${X}"`),T=X}else if(!v.stamped&&j&&!lt.has(r))lt.add(r),console.warn(`[stx] ${C.relative(process.cwd(),r)} declares signals but has no element to scope them to, so nothing in it will hydrate. Wrap the partial's markup in a single root element.`);if(v.stamped&&v.root!=="body"&&(j||tt)&&!pt.has(r)){let y=Pf(o);if(y.length>1)pt.add(r),console.warn(`[stx] ${C.relative(process.cwd(),r)} declares ${j?"signals":"bindings"} and has ${y.length} top-level elements (${y.map((X)=>`<${X}>`).join(", ")}). Only the first is scoped, so bindings in the others cannot see what this partial's script declares. Wrap the partial's markup in a single root element.`)}let K=v.stamped&&v.root!==null&&kr(v.root);M=Rt(M,K?T:null)}if(o.includes("@include")||o.includes("@partial"))o=await as(o,b,r,i,S,n);let{processLoops:nt,reportDeferredLoopWarnings:it}=await import("./chunk-hb4jkdfr.js"),G=nt(o,b,r,void 0,!0);G=se(G,b,r),G=it(G);let{processMetaDirectives:ht,processSeoDirective:xt,processStructuredData:_t}=await import("./chunk-w7681v48.js");if(G=ht(G,b,r,i),G=_t(G,b,r),G=xt(G,b,r,i),G=_(G,b,r),V)G+=`
|
|
51
51
|
`+V;if(M)G+=`
|
|
52
|
-
`+M;return G}catch(l){if(l instanceof q)throw l;let o=l instanceof Error?l.message:String(l);return N(m,`Error processing include ${m}: ${o}`,x,p)}}let Y=/@include\s*\(/g,H;while((H=Y.exec(e))!==null){let m=H.index,I=m+H[0].length-1,x=1,p=I+1;while(p<e.length&&x>0){if(e[p]==="(")x++;else if(e[p]===")")x--;p++}if(x!==0)break;let r=e.substring(m,p),w=e.substring(I+1,p-1),l=w.match(/^\s*['"]([^'"]+)['"]/);if(!l){Y.lastIndex=p;continue}let o=l[1],O,P=w.substring(l[0].length),k=ct(P,0);if(k!==-1)O=P.substring(k+1).trim();let V={};if(O)try{V=R(O,t)}catch(b){let J=b instanceof Error?b.message:String(b);e=e.replace(r,h("Include",`Error parsing include variables for ${o}: ${J}`,c,a,m)),Y.lastIndex=0;continue}let W=await et(o,V,a,m);e=e.substring(0,m)+W+e.substring(p),Y.lastIndex=0}return e}function
|
|
52
|
+
`+M;return G}catch(l){if(l instanceof q)throw l;let o=l instanceof Error?l.message:String(l);return N(m,`Error processing include ${m}: ${o}`,x,p)}}let Y=/@include\s*\(/g,H;while((H=Y.exec(e))!==null){let m=H.index,I=m+H[0].length-1,x=1,p=I+1;while(p<e.length&&x>0){if(e[p]==="(")x++;else if(e[p]===")")x--;p++}if(x!==0)break;let r=e.substring(m,p),w=e.substring(I+1,p-1),l=w.match(/^\s*['"]([^'"]+)['"]/);if(!l){Y.lastIndex=p;continue}let o=l[1],O,P=w.substring(l[0].length),k=ct(P,0);if(k!==-1)O=P.substring(k+1).trim();let V={};if(O)try{V=R(O,t)}catch(b){let J=b instanceof Error?b.message:String(b);e=e.replace(r,h("Include",`Error parsing include variables for ${o}: ${J}`,c,a,m)),Y.lastIndex=0;continue}let W=await et(o,V,a,m);e=e.substring(0,m)+W+e.substring(p),Y.lastIndex=0}return e}function cs(a,t){let c=a;function i(S,n,g,e){let D=S,Z=!0;while(Z){Z=!1;let rt=new RegExp(`@${n}\\(['"]([^'"]+)['"]\\)`),N=D.match(rt);if(!N||N.index===void 0)break;let et=N.index,Y=N[1],H=et+N[0].length,m=new RegExp(`@${n}\\(`),I=new RegExp(`@${g}(?![a-z])`),x=1,p=H,r=-1;while(x>0&&p<D.length){let l=D.slice(p),o=l.match(m),O=l.match(I),P=o?p+o.index:1/0,k=O?p+O.index:1/0;if(P<k)x++,p=P+(o[0].length||1);else if(k<1/0){if(x--,x===0){r=k;break}p=k+g.length+1}else break}if(r===-1)break;let w=D.slice(H,r);if(!t[Y])t[Y]=[];if(e)t[Y].unshift(w);else t[Y].push(w);D=D.substring(0,et)+D.substring(r+`@${g}`.length),Z=!0}return D}return c=i(c,"push","endpush",!1),c=i(c,"prepend","endprepend",!0),c}function ls(a,t){return a.replace(/@stack\(['"]([^'"]+)['"]\)/g,(c,i)=>{if(!t[i]||t[i].length===0)return"";return t[i].join(`
|
|
53
53
|
`)})}
|
|
54
|
-
export{
|
|
54
|
+
export{$h,Pf,Je,ac,Rh,as,cs,ls};
|