@stacksjs/stx 0.2.482 → 0.2.483
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-4ebwk9cw.js → chunk-01rz8h7x.js} +2 -2
- package/dist/{chunk-tr25zcf1.js → chunk-0egg3666.js} +9 -9
- package/dist/chunk-0fad6jf4.js +2 -0
- package/dist/chunk-0jfrzq0r.js +2 -0
- package/dist/{chunk-1m9v96z5.js → chunk-0ma6yhg9.js} +6 -6
- package/dist/{chunk-49h8ke5d.js → chunk-0ttq5enq.js} +1 -1
- package/dist/chunk-0vdxchfw.js +2 -0
- package/dist/{chunk-cgf2a166.js → chunk-1c407nky.js} +5 -5
- package/dist/{chunk-99kt56fn.js → chunk-1erc0vrb.js} +2 -2
- package/dist/chunk-1hpttjgq.js +2 -0
- package/dist/chunk-1mrn5s5z.js +2 -0
- package/dist/{chunk-v5rgebzz.js → chunk-1v86h5vn.js} +5 -5
- package/dist/chunk-1yckkva7.js +2 -0
- package/dist/{chunk-44dk5bb5.js → chunk-24jeywdh.js} +41 -41
- package/dist/chunk-258qj7pt.js +2 -0
- package/dist/{chunk-1z26g0cf.js → chunk-25m2wqsd.js} +6 -6
- package/dist/{chunk-28s5x7wv.js → chunk-298s08st.js} +2 -2
- package/dist/{chunk-eg5djbse.js → chunk-2cybh8dh.js} +2 -2
- package/dist/chunk-2fb4yx25.js +4 -0
- package/dist/chunk-2grygc4b.js +2 -0
- package/dist/{chunk-hq97tyb6.js → chunk-2hbygqzj.js} +2 -2
- package/dist/{chunk-8scw1bes.js → chunk-2hc5mbw8.js} +2 -2
- package/dist/{chunk-zpcxx4pp.js → chunk-2kyfaa0p.js} +2 -2
- package/dist/{chunk-ab7vh24b.js → chunk-2pph3dh0.js} +6 -6
- package/dist/{chunk-cd6hz56r.js → chunk-34154wz1.js} +5 -5
- package/dist/chunk-368zt1db.js +2 -0
- package/dist/{chunk-sarr8kz1.js → chunk-3mynjdqr.js} +6 -6
- package/dist/{chunk-5t5ahhjp.js → chunk-3s9s1mdt.js} +3 -3
- package/dist/chunk-3vqabd10.js +2 -0
- package/dist/chunk-490f2x2r.js +2 -0
- package/dist/chunk-4b5hg8y1.js +2 -0
- package/dist/{chunk-33h9ggbz.js → chunk-4c1afy15.js} +4 -4
- package/dist/{chunk-tfexmdkt.js → chunk-4drgbkga.js} +2 -2
- package/dist/chunk-4j2ej7er.js +2 -0
- package/dist/chunk-4k65naeg.js +2 -0
- package/dist/{chunk-cgszdc9m.js → chunk-4snv0gm8.js} +4 -4
- package/dist/chunk-5cd0jbt4.js +2 -0
- package/dist/{chunk-b1kdmkk8.js → chunk-5f7qy42x.js} +247 -266
- package/dist/{chunk-vvs75dse.js → chunk-67actssw.js} +2 -2
- package/dist/chunk-69dc3tyz.js +2 -0
- package/dist/chunk-6ejfx4qw.js +2 -0
- package/dist/{chunk-7ejq9n1v.js → chunk-71bbv43t.js} +4 -4
- package/dist/{chunk-7grtpdw5.js → chunk-7cbtcdqw.js} +2 -2
- package/dist/chunk-7wxmsv41.js +2 -0
- package/dist/{chunk-ah4qyrnn.js → chunk-802qf0vz.js} +1 -1
- package/dist/chunk-8b71njp8.js +30 -0
- package/dist/{chunk-2542vq5p.js → chunk-8fb1mqw1.js} +1 -1
- package/dist/{chunk-f4v80grv.js → chunk-8j8egh39.js} +3 -3
- package/dist/{chunk-6vn4pa76.js → chunk-93wkn776.js} +1 -1
- package/dist/chunk-9ds5dn6f.js +2 -0
- package/dist/chunk-9mywx2x0.js +2 -0
- package/dist/chunk-9s3tf3m3.js +2 -0
- package/dist/{chunk-jxrnagej.js → chunk-aabzyk88.js} +5 -5
- package/dist/chunk-ah4ww997.js +2 -0
- package/dist/chunk-avq5209p.js +2 -0
- package/dist/chunk-b0bgprzs.js +2 -0
- package/dist/chunk-b77v56fz.js +24 -0
- package/dist/{chunk-rycvcgkc.js → chunk-baprpeby.js} +3 -3
- package/dist/{chunk-bvhr055w.js → chunk-bv7bsdfe.js} +2 -2
- package/dist/{chunk-wkc34drs.js → chunk-c57j92td.js} +2 -2
- package/dist/chunk-c7cajwd2.js +2 -0
- package/dist/{chunk-8rx2v7zj.js → chunk-c8psbk2e.js} +1 -1
- package/dist/chunk-ckrpk6ak.js +2 -0
- package/dist/{chunk-3fjpg8kb.js → chunk-cp7hph6f.js} +3 -3
- package/dist/{chunk-80hpdc22.js → chunk-d19vgjjt.js} +2 -2
- package/dist/{chunk-pf0d8y9n.js → chunk-d4k4nyj0.js} +2 -2
- package/dist/{chunk-04qmr675.js → chunk-e62nw7zk.js} +2 -2
- package/dist/{chunk-pcq6vphz.js → chunk-e6y6s7q8.js} +2 -2
- package/dist/chunk-egax8990.js +2 -0
- package/dist/chunk-en0atzsp.js +2 -0
- package/dist/{chunk-2gmbxp60.js → chunk-er7y8hk9.js} +3 -3
- package/dist/chunk-ezvy497d.js +2 -0
- package/dist/chunk-f0prq6yw.js +2 -0
- package/dist/chunk-ftdabyt6.js +2 -0
- package/dist/chunk-g7ey7mtw.js +3 -0
- package/dist/chunk-g7jcpd5j.js +2 -0
- package/dist/chunk-gty89j8s.js +2 -0
- package/dist/{chunk-t7s0pdtw.js → chunk-gzt3ghgq.js} +3 -3
- package/dist/{chunk-3pv6f998.js → chunk-h6q8jafh.js} +2 -2
- package/dist/chunk-hem4ak5x.js +2 -0
- package/dist/{chunk-kp5tv8jx.js → chunk-hkjqqx92.js} +3 -3
- package/dist/{chunk-29pn79t5.js → chunk-hktvv0hd.js} +2 -2
- package/dist/chunk-hmyyq2hh.js +2 -0
- package/dist/{chunk-j2zgh5yk.js → chunk-hqvdm4h9.js} +2 -2
- package/dist/chunk-hsywkvng.js +2 -0
- package/dist/chunk-j2q2pp0x.js +2 -0
- package/dist/chunk-jbj6xh7f.js +3 -0
- package/dist/{chunk-33gkx5z1.js → chunk-jbvg29t0.js} +7 -7
- package/dist/chunk-jd9c46cc.js +2 -0
- package/dist/{chunk-kzzjk2mx.js → chunk-jva1bbpw.js} +10 -10
- package/dist/{chunk-27kb6nrb.js → chunk-jwjggr91.js} +2 -2
- package/dist/chunk-kkn0m1eg.js +2 -0
- package/dist/{chunk-j4afmryj.js → chunk-kp4mzspk.js} +4 -4
- package/dist/chunk-njpxfd44.js +2 -0
- package/dist/{chunk-7kjkmvrn.js → chunk-nr7qak48.js} +2 -2
- package/dist/{chunk-q9996m6n.js → chunk-nxxmhrd0.js} +2 -2
- package/dist/chunk-p5bwcppv.js +2 -0
- package/dist/chunk-p5pna1sn.js +2 -0
- package/dist/chunk-p6trwjap.js +2 -0
- package/dist/{chunk-8emc4aq5.js → chunk-qk5j55r0.js} +5 -5
- package/dist/chunk-qmcmjdy7.js +65 -0
- package/dist/{chunk-91jyax19.js → chunk-qv3rrz9a.js} +11 -11
- package/dist/chunk-rbsn2vf5.js +2 -0
- package/dist/chunk-rcn6m3cj.js +2 -0
- package/dist/chunk-rd2w20hg.js +2 -0
- package/dist/{chunk-5x9ftmve.js → chunk-rhrv2j36.js} +2 -2
- package/dist/{chunk-9ztdvnkk.js → chunk-rmavqxd8.js} +4 -4
- package/dist/chunk-rn2w32kh.js +2 -0
- package/dist/{chunk-q8pn42an.js → chunk-rn4cppcj.js} +4 -4
- package/dist/chunk-rt71qxdq.js +2 -0
- package/dist/chunk-s6v5p03w.js +2 -0
- package/dist/{chunk-k4shjm8n.js → chunk-s9mq9x2k.js} +5 -5
- package/dist/chunk-svywp38a.js +2 -0
- package/dist/chunk-sybzayv3.js +2 -0
- package/dist/{chunk-8adstrk5.js → chunk-szry3s17.js} +3 -3
- package/dist/chunk-tse7jzmz.js +2 -0
- package/dist/chunk-tvag2s5a.js +2 -0
- package/dist/{chunk-01nx6zcw.js → chunk-v7vkqg8f.js} +2 -2
- package/dist/chunk-vbhykx9z.js +2 -0
- package/dist/{chunk-se55qe2x.js → chunk-vg9dyc4y.js} +1 -1
- package/dist/{chunk-zkg0rbmp.js → chunk-vp827ah7.js} +6 -6
- package/dist/chunk-vr0fb0x1.js +2 -0
- package/dist/{chunk-bqx3dqv1.js → chunk-vs0ebfg5.js} +1 -1
- package/dist/chunk-vwybce48.js +2 -0
- package/dist/chunk-vzxkwr23.js +2 -0
- package/dist/{chunk-ak95401g.js → chunk-x8mp9yvn.js} +3 -3
- package/dist/{chunk-b8p9y1kv.js → chunk-xevnx24r.js} +2 -2
- package/dist/chunk-xfxrh6vx.js +2 -0
- package/dist/{chunk-960axmf7.js → chunk-yhv65tpd.js} +2 -2
- package/dist/chunk-yxgfw906.js +2 -0
- package/dist/chunk-z6nm6rf1.js +2 -0
- package/dist/{chunk-cxbp2m66.js → chunk-z9fz5dby.js} +5 -5
- package/dist/{chunk-gkj42zq7.js → chunk-z9tvn738.js} +2 -2
- package/dist/{chunk-abts223v.js → chunk-zkjp87ak.js} +3 -3
- package/dist/{chunk-w6n2j62h.js → chunk-zv0vgamy.js} +3 -3
- package/dist/cli.js +20 -20
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/document-shell.d.ts +11 -0
- package/dist/document-shell.js +11 -3
- package/dist/head.js +2 -1
- package/dist/pwa.js +3 -3
- package/dist/seo.d.ts +16 -0
- package/dist/seo.js +9 -6
- package/dist/ssg.js +13 -13
- package/package.json +5 -5
- package/dist/chunk-0e1rga0j.js +0 -2
- package/dist/chunk-0jp07cjs.js +0 -2
- package/dist/chunk-1kkyg54v.js +0 -2
- package/dist/chunk-2njt4vbe.js +0 -2
- package/dist/chunk-3aw80qrg.js +0 -2
- package/dist/chunk-3gbjppvg.js +0 -2
- package/dist/chunk-3nq94g1b.js +0 -2
- package/dist/chunk-4aw47rmg.js +0 -2
- package/dist/chunk-50vq8k55.js +0 -2
- package/dist/chunk-5fvzzqa3.js +0 -2
- package/dist/chunk-5pjsc9zv.js +0 -3
- package/dist/chunk-5sb7gw66.js +0 -2
- package/dist/chunk-5y4qxmaw.js +0 -2
- package/dist/chunk-7mh0fnrq.js +0 -2
- package/dist/chunk-8mxjd1ge.js +0 -2
- package/dist/chunk-8xvrcwtk.js +0 -2
- package/dist/chunk-969np51a.js +0 -2
- package/dist/chunk-9kzk7zyy.js +0 -2
- package/dist/chunk-9vqz2m13.js +0 -2
- package/dist/chunk-ap9nnv9z.js +0 -2
- package/dist/chunk-bw0gkfb3.js +0 -2
- package/dist/chunk-d20gxzk9.js +0 -2
- package/dist/chunk-db2sy0f3.js +0 -2
- package/dist/chunk-dbj4sn74.js +0 -2
- package/dist/chunk-dts9z53c.js +0 -2
- package/dist/chunk-ecr642nj.js +0 -2
- package/dist/chunk-eev60q15.js +0 -2
- package/dist/chunk-ep7hz9af.js +0 -2
- package/dist/chunk-fe5xht52.js +0 -2
- package/dist/chunk-fqhewm3t.js +0 -2
- package/dist/chunk-gzbzfndm.js +0 -2
- package/dist/chunk-hgcvtfnz.js +0 -2
- package/dist/chunk-j338fs8k.js +0 -2
- package/dist/chunk-jbmwm6k4.js +0 -2
- package/dist/chunk-jvdren00.js +0 -2
- package/dist/chunk-k7t0rmzy.js +0 -2
- package/dist/chunk-k84qkm21.js +0 -2
- package/dist/chunk-kd7m4d0g.js +0 -2
- package/dist/chunk-kk5cyjfs.js +0 -3
- package/dist/chunk-kmf7yh91.js +0 -2
- package/dist/chunk-m5dgc757.js +0 -2
- package/dist/chunk-m8w4hve0.js +0 -2
- package/dist/chunk-mhwptrvm.js +0 -2
- package/dist/chunk-mmh37ywa.js +0 -2
- package/dist/chunk-ms5aj58v.js +0 -2
- package/dist/chunk-n454sydr.js +0 -2
- package/dist/chunk-pd5r4j8r.js +0 -2
- package/dist/chunk-pe9bvwqn.js +0 -30
- package/dist/chunk-pt566gqb.js +0 -2
- package/dist/chunk-q4wpzj1f.js +0 -2
- package/dist/chunk-qtsymvxx.js +0 -2
- package/dist/chunk-r54tkwpc.js +0 -2
- package/dist/chunk-ra321t5d.js +0 -2
- package/dist/chunk-s10r6hxp.js +0 -64
- package/dist/chunk-sqjdb265.js +0 -2
- package/dist/chunk-st1s30tn.js +0 -2
- package/dist/chunk-tbef3yyk.js +0 -5
- package/dist/chunk-v7ahbhbd.js +0 -2
- package/dist/chunk-v9t3z8nm.js +0 -2
- package/dist/chunk-vcs1fx8e.js +0 -2
- package/dist/chunk-w0vrmvh7.js +0 -2
- package/dist/chunk-w28c9st3.js +0 -2
- package/dist/chunk-x73mzzm8.js +0 -2
- package/dist/chunk-xnjcmhs5.js +0 -4
- package/dist/chunk-yed9c66h.js +0 -2
- package/dist/chunk-zb5p05v4.js +0 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{M,ce}from"./chunk-
|
|
3
|
-
export{
|
|
2
|
+
import{M,ce}from"./chunk-5f7qy42x.js";import{ue,C,Xe}from"./chunk-1erc0vrb.js";import{Qe,G,ke}from"./chunk-rmavqxd8.js";import{Ae,ne,_,re,fo,$r,go,Ot}from"./chunk-8b71njp8.js";import{Kr}from"./chunk-34154wz1.js";import{Mt}from"./chunk-7cbtcdqw.js";import F from"zlib";import{promisify as Z}from"util";var ee=Z(F.brotliCompress),te=Z(F.gzip),se=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],oe=["text/event-stream","multipart/x-mixed-replace"],ae=1024;function ie(t){if(!t)return!1;let e=t.toLowerCase();if(oe.some((o)=>e.startsWith(o)))return!1;return se.some((o)=>e.startsWith(o))}function pe(t){let e=new Map;for(let o of t.split(",")){let[r,...a]=o.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of a){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function le(t){if(!t)return null;let e=pe(t),o=e.get("*"),r=(a)=>e.get(a)??o??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var J=33554432,H=new Map,U=0;function me(t,e){if(e.length>J/8)return;H.set(t,e),U+=e.length;for(let[o,r]of H){if(U<=J)break;H.delete(o),U-=r.length}}async function It(t,e,o={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!ie(e.headers.get("content-type")))return e;let r=le(t.headers.get("accept-encoding"));if(!r)return e;let a;try{a=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(a,{status:e.status,statusText:e.statusText,headers:Q(e.headers)});if(a.length<(o.threshold??ae))return f();try{let h=o.quality??5,g=`${r}:${h}:${a.length}:${Bun.hash(a)}`,l=H.get(g);if(!l)l=r==="br"?await ee(a,{params:{[F.constants.BROTLI_PARAM_QUALITY]:h,[F.constants.BROTLI_PARAM_SIZE_HINT]:a.length}}):await te(a),me(g,l);if(l.length>=a.length)return f();let m=Q(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function Q(t){let e=new Headers(t),o=e.get("Vary");if(!o)return e.set("Vary","Accept-Encoding"),e;if(!o.split(",").some((a)=>a.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${o}, Accept-Encoding`);return e}import K from"fs";import P from"path";var{serve:fe}=globalThis.Bun;class q{now;entries=new M(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,o){let r,a=async()=>{let s=r??await o();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",_(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return a();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${ne(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let S=new Headers(s.headers);return S.set("Cache-Control","private, no-store"),S.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:S})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let b=this.generation,k=async()=>{let s=await o();r=s;let S=(s.headers.get("Vary")??"").toLowerCase().split(",").map((y)=>y.trim()).filter(Boolean);if(s.status!==200||s.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(s.headers.get("Cache-Control")??"")||S.some((y)=>y!=="x-stx-router"&&y!=="accept-encoding"))return null;let B=await s.clone().arrayBuffer();if(B.byteLength>1048576)return null;s.headers.set("Vary",_(s.headers.get("Vary")).Vary);let n={body:B,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===b)this.entries.set(h,n);return n},v=this.pending.get(h);if(!v){if(this.pending.size>=1000)return a();v=k().finally(()=>{if(this.pending.get(h)===v)this.pending.delete(h)}),this.pending.set(h,v)}if(g&&m<e.maxAge+(e.swr??0))return v.catch(()=>{}),l(g);let E=await v;return E?l(E):a()}}var de={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function Qc(t={}){let e=P.resolve(t.outputDir||".output"),o=t.port??3000,r=fo(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let a=Mt(r.routeRules),f=new q,h=Kr(e,r.apiRoutes??[]),g=Bun.file(P.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?C(l):void 0,b=new Map,k=new Map,v=new Map,E=new Map;for(let n of r.routes)try{let y=P.join(e,n.compiledPath),i=JSON.parse(await Bun.file(y).text());if(m)i.html=Xe(i.html,m);b.set(n.pattern,i),v.set(n.pattern,ke(i.html)),E.set(n.pattern,ce(i.html));let X=P.join(e,n.fragmentPath);if(await Bun.file(X).exists()){let A=await Bun.file(X).text();k.set(n.pattern,m?Xe(A,m):A)}}catch(y){console.warn(`[stx] Failed to load route ${n.pattern}:`,y)}let s=new Map,S=[];for(let n of r.routes)if(n.hasParams){let{regex:y,params:i}=G(n.pattern,{page:!0});S.push({regex:y,route:n,paramNames:i})}else s.set(n.pattern,n);let B=fe({port:o,async fetch(n){return It(n,await ue(m??C(),async()=>{let i=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[i])return t.apiRoutes[i](n);let X=await h(n);if(X)return X;if((n.method==="GET"||n.method==="HEAD")&&i!=="/"){let p=P.resolve(e,"public"),d;try{d=decodeURIComponent(i)}catch{d=i}if(!d.includes("\x00")){let u=P.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${P.sep}`))try{if(K.existsSync(u)&&K.statSync(u).isFile()){let R=P.extname(u).toLowerCase(),L=de[R]||"application/octet-stream",N=i.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(i);return new Response(Bun.file(u),{headers:{"Content-Type":L,"Cache-Control":N?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=ne(n),w=null,W={};if(w=s.get(i)||null,!w)for(let{regex:p,route:d,paramNames:u}of S){let c=i.match(p);if(c){w=d,u.forEach((R,L)=>{W[R]=c[L+1]});break}}if(!w){let p=Qe(i)?null:s.get("/404")||null;if(p){let d=b.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let O=a(i),Y=Object.keys(O).length>0;return f.respond(n,O.cache,async()=>{let p=b.get(w.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let c=k.get(w.pattern);if(c){let R=v.get(w.pattern);return new Response(c,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...E.has(w.pattern)?{"X-STX-Runtime":E.get(w.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},..._(),...O.cache?{}:{"Cache-Control":Ae}}})}}let d=$r(n.method),u=b.get(w.pattern);if(!u){let c=s.get("/500")||null;if(c){let R=b.get(c.pattern);if(R)return new Response(R.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(w.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",..._(),"Cache-Control":"public, max-age=60"}});try{let{html:c,boundaries:R,redirect:L,cookies:N,status:I,headers:D}=await Ot(u,{params:W,request:n,method:n.method,__stx_strict_hydration:Y,__stx_runtime_config:m});if(L)return go(L,N,D);if(R&&R.length>0){let{renderStreamingPage:T,streamToResponse:z}=await import("./chunk-6ejfx4qw.js"),j=new Headers({..._(),...D,"Cache-Control":"private, no-store"});for(let V of N??[])j.append("Set-Cookie",V);if(A&&!d){let V=ke(c);j.set("X-STX-Fragment","true"),j.set("X-STX-Runtime",ce(c)?"true":"false"),j.set("X-STX-Layout",V.layout),j.set("X-STX-Layout-Group",V.group)}return z(T(A&&!d?re(c,r.routerContainer||"main"):c,R,{timeoutMs:30000}),{status:I??u.status??200,headers:j})}let x=new Headers({"Content-Type":"text/html",..._(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let T of N??[])x.append("Set-Cookie",T);for(let[T,z]of Object.entries(D??{}))x.set(T,z);if(x.set("Vary",_(x.get("Vary")).Vary),A&&!d){let T=ke(c);return x.set("X-STX-Fragment","true"),x.set("X-STX-Runtime",ce(c)?"true":"false"),x.set("X-STX-Layout",T.layout),x.set("X-STX-Layout-Group",T.group),new Response(re(c,r.routerContainer||"main"),{status:I??u.status??200,headers:x})}return new Response(c,{status:I??u.status??200,headers:x})}catch(c){if(console.error(`[stx] Hydration error for ${i}:`,c),Y)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${B.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${b.size} pre-loaded)`),{port:B.port,stop:()=>{f.invalidate(),B.stop()},invalidate:(n)=>f.invalidate(n)}}
|
|
3
|
+
export{It,Qc};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{_t,C}from"./chunk-1erc0vrb.js";import m from"fs";import e from"path";async function un(r,o,i){if(r.__stx_runtime_config)return;let n=_t();if(n||i){r.__stx_runtime_config=n??C(i);return}let t=e.dirname(e.resolve(o));while(!0){if(["stx.config.ts","stx.config.js",".config/stx.config.ts",".config/stx.config.js"].some((f)=>m.existsSync(e.join(t,f)))){let{loadStxConfig:f}=await import("./chunk-368zt1db.js"),c=await f(t);if(c.runtimeConfig)r.__stx_runtime_config=C(c.runtimeConfig);return}let s=e.dirname(t);if(s===t)return;t=s}}async function Cs(r,o){function i(n){if(n===null)return"null";if(Array.isArray(n))return`Array<${n.length?[...new Set(n.map(i))].join(" | "):"unknown"}>`;if(typeof n==="object")return`{ ${Object.entries(n).map(([t,s])=>`readonly ${JSON.stringify(t)}: ${i(s)}`).join("; ")} }`;return typeof n}await Bun.write(e.join(r,".stx/runtime-config.d.ts"),`import '@stacksjs/stx/runtime-config'
|
|
3
3
|
declare module '@stacksjs/stx/runtime-config' { interface PublicRuntimeConfig ${i(o.public??{})} }
|
|
4
4
|
`),await Bun.write(e.join(r,".stx/runtime-config-server.d.ts"),`import '@stacksjs/stx/runtime-config-server'
|
|
5
5
|
declare module '@stacksjs/stx/runtime-config-server' { interface PrivateRuntimeConfig ${i(o.private??{})} }
|
|
6
6
|
`)}
|
|
7
|
-
export{
|
|
7
|
+
export{un,Cs};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Zc}from"./chunk-baprpeby.js";import"./chunk-5f7qy42x.js";import"./chunk-szry3s17.js";import"./chunk-c57j92td.js";import"./chunk-kp4mzspk.js";import"./chunk-nxxmhrd0.js";import"./chunk-1erc0vrb.js";import"./chunk-qmcmjdy7.js";import"./chunk-b77v56fz.js";import"./chunk-2pph3dh0.js";import"./chunk-d4k4nyj0.js";import"./chunk-v7vkqg8f.js";import"./chunk-rmavqxd8.js";import"./chunk-e6y6s7q8.js";export{Zc as startInteractive};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{$t,bc,wc,vc,xc,Sc,d,kc,ps,Cc,ci,li}from"./chunk-5f7qy42x.js";import"./chunk-szry3s17.js";import"./chunk-c57j92td.js";import"./chunk-kp4mzspk.js";import"./chunk-nxxmhrd0.js";import"./chunk-1erc0vrb.js";import"./chunk-qmcmjdy7.js";import"./chunk-b77v56fz.js";import"./chunk-2pph3dh0.js";import"./chunk-d4k4nyj0.js";import"./chunk-v7vkqg8f.js";import"./chunk-rmavqxd8.js";import"./chunk-e6y6s7q8.js";export{$t as STX_ENGINE_BINDING_NAMES,ps as convertToCommonJS,ci as extractScriptFromTemplate,d as extractVariables,li as hasVariables,kc as isCompleteImport,Sc as isMissingBindingFailure,vc as isModuleResolutionFailure,xc as isSyntaxFailure,Cc as splitDeclaration,bc as stripTypeScript,wc as withoutStxReferrer};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Ee,_e,Te}from"./chunk-bv7bsdfe.js";import"./chunk-v7vkqg8f.js";import"./chunk-d4k4nyj0.js";import{d}from"./chunk-5f7qy42x.js";import"./chunk-2pph3dh0.js";import"./chunk-c57j92td.js";import"./chunk-rmavqxd8.js";import"./chunk-b77v56fz.js";import"./chunk-qmcmjdy7.js";import"./chunk-kp4mzspk.js";import"./chunk-1erc0vrb.js";import"./chunk-nxxmhrd0.js";import"./chunk-e6y6s7q8.js";import{it,gr,at,Vs,$e,Us,mr,ct,qs,lt}from"./chunk-2kyfaa0p.js";import"./chunk-szry3s17.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,(p)=>{if(p==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{Us("Config file changed, restarting...");try{await e.onChange()}catch(l){$e(`Failed to restart: ${l}`)}},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:dt(),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 p=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),l=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),g=l.length>0?l.reduce((i,m)=>i+m,0)/l.length:0,y=Object.entries(c).sort((i,m)=>m[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:p.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 dt(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var pt=".stx/story/bookmarks.json",mt=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,pt),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:mt,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:ut(),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 ut(){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:p}=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:p}=await import("./chunk-rt71qxdq.js"),l={},g=h(n);if(g)try{await d(g,l,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}if(r.props)Object.assign(l,r.props);let i=await p(n,l,e,{},new Set),m=Z(n),u=h(n);return i=Q(i),i=tt(i,l),{html:i,css:m,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 d(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-rt71qxdq.js"),c={...r},n=h(e);if(n)try{await d(n,c,"inline-template.stx")}catch{}let l=await a(e,c,"inline-template.stx",{},new Set);return l=Q(l),l=tt(l,c),{html:l,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
|
|
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 ct(t);_e(t,r);let s=lt(t.config,r);Te(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),p=N(),l=Bun.serve({port:e.port,hostname:o,fetch:async(i,m)=>{let f=new URL(i.url).pathname;if(f==="/__hmr"){if(m.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){p.open(i)},close(i){p.close(i)},message(i,m){p.message(i,m)}}}),g=`http://${o}:${e.port}`,y=qs(t,async(i,m)=>{console.log(` [${i}] ${m.relativePath}`);let u=await ct(t);_e(t,u);let f=lt(t.config,u);if(Te(t,f),i==="add")H(m.id,{fileName:m.fileName});else if(i==="unlink")O(m.id);else V(m.id,{fileName:m.fileName})});if(e.open){let i=g;try{let{exec:m}=await import("child_process"),u=process.platform;m(`${u==="darwin"?"open":u==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:l,url:g,close:async()=>{y(),l.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),p=t.storyFiles.find((l)=>l.id===n);if(!p)return new Response("Story not found",{status:404});try{let l=await Bun.file(p.path).text();return Response.json({id:p.id,fileName:p.fileName,relativePath:p.relativePath,content:l})}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),p=e.slice(12).split("/"),l=p[0],g=p[1]||"default",y,i=n.searchParams.get("props");if(i)try{y=JSON.parse(i)}catch{}let m=t.storyFiles.find((u)=>u.id===l);if(!m)return new Response("Story not found",{status:404});try{let u=await Y(t,m,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(),p=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(p)}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),p=o.getPreset(n);if(!p)return new Response("Preset not found",{status:404});return Response.json(p)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),p=o.usePreset(n);if(!p)return new Response("Preset not found",{status:404});return await o.save(),Response.json(p)}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(),p=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(p)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),p=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(p)}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),p=a.getBookmark(n);if(!p)return new Response("Bookmark not found",{status:404});return Response.json(p)}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),p=t.storyFiles.find((g)=>g.id===n),l=c.getComponentAnalytics(n,p?.fileName||n);return Response.json(l)}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
|
|
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 he(t={}){it();let e=await Ee({mode:"dev"});if(!e.config.enabled){$e("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}),at(e.storyFiles.length),gr(s.url),mr()};await o();let a=E(e,{onChange:async()=>{await s.close();let n=await Ee({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":mr();break;case"o":try{let{exec:l}=await import("child_process"),g=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";l(`${g} ${s.url}`)}catch{Vs("Failed to open browser")}break;case"r":await s.close(),await o();break;case"c":console.clear(),it(),at(e.storyFiles.length),gr(s.url);break;case"q":case"\x03":await c();break}});await new Promise(()=>{})}export{he as devCommand};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{t,i}from"./chunk-2pph3dh0.js";import{Ge,Je,Ye,de,ve,E,rr,mn,fe}from"./chunk-b77v56fz.js";var I=/(?<![\w$@])@meta\s*\(/g,C=/(?<![\w$@])@metaTag\s*\(/g,k=/(?<![\w$@])@structuredData\s*\(/g,N=/(?<![\w$@])@seo\s*\(/g;function _(e,r){return(n)=>E(e,n,"the call has no closing parenthesis",r,t.INVALID_DIRECTIVE_SYNTAX)}function j(e){return"property"in e?`<meta property="${l(e.property)}" content="${l(e.content)}">`:`<meta name="${l(e.name)}" content="${l(e.content)}">`}function Es(e,r,n,g){if(!e.includes("@meta"))return e;let a=Ge(e,I,(s,c)=>{let o=mn(Je(s),r);if(o.kind==="tag")return j(o.tag);if(o.kind==="empty")return"";return E("Meta",c,o.message,n,o.code)},_("Meta",n));return a=Ge(a,C,(s,c)=>{let o=Ye(s,r);if(!o.ok)return E("MetaTag",c,o.message,n,o.code);if(o.value===void 0||o.value===null)return"";if(!ve(o.value))return E("MetaTag",c,`expected an object such as { name, content }, got ${de(o.value)}`,n,t.TYPE_ERROR);let u=o.value;if(!u.name&&!u.property&&!u.httpEquiv)return E("MetaTag",c,"the tag needs a name, property or httpEquiv",n,t.INVALID_DIRECTIVE_SYNTAX);if(u.content===void 0||u.content===null||u.content===""||u.content===!1)return"";let p="<meta";if(u.name)p+=` name="${l(u.name)}"`;if(u.property)p+=` property="${l(u.property)}"`;if(u.httpEquiv)p+=` http-equiv="${l(u.httpEquiv)}"`;return p+=` content="${l(u.content)}">`,p},_("MetaTag",n)),a}function v(e){let r=(n)=>n["@context"]?{...n}:{...n,"@context":"https://schema.org"};if(ve(e))return r(e);if(Array.isArray(e)&&e.length>0&&e.every(ve))return e.map(r);return null}function A(e){return`<script type="application/ld+json">${JSON.stringify(e).replace(/<\//g,"<\\/")}</script>`}function _s(e,r,n){if(!e.includes("@structuredData"))return e;return Ge(e,k,(g,a)=>{let s=Ye(g,r);if(!s.ok)return E("StructuredData",a,s.message,n,s.code);if(s.value===void 0||s.value===null)return"";let c=v(s.value);if(!c)return E("StructuredData",a,`expected an object or an array of objects, got ${de(s.value)}`,n,t.TYPE_ERROR);try{return A(c)}catch(o){let u=o instanceof Error?o.message:String(o);return E("StructuredData",a,`the data cannot be written as JSON: ${u}`,n,t.EVALUATION_ERROR)}},_("StructuredData",n))}var L=new Set(["title","description","keywords","robots","canonical","openGraph","twitter","structuredData"]),R={image:"openGraph.image",url:"canonical or openGraph.url",type:"openGraph.type",siteName:"openGraph.siteName",locale:"openGraph.locale",og:"openGraph",author:"@meta('author', ...)"};function Ts(e,r,n,g){if(!e.includes("@seo"))return e;return Ge(e,N,(a,s)=>{if(!a.trim())return E("SEO",s,"expected an object: @seo({ title, description }) or @seo(seoVariable)",n,t.INVALID_DIRECTIVE_SYNTAX);let c=Ye(a,r);if(!c.ok)return E("SEO",s,c.message,n,c.code);if(c.value===void 0||c.value===null)return"";if(!ve(c.value))return E("SEO",s,`expected an object such as { title, description }, got ${de(c.value)}`,n,t.TYPE_ERROR);try{return q(c.value,s,n)}catch(o){let u=o instanceof Error?o.message:String(o);return E("SEO",s,`Error processing @seo directive: ${u}`,n,t.EVALUATION_ERROR)}},_("SEO",n))}function b(e,r,n,g){let a=e[r];if(a===void 0||a===null||a===!1)return;if(ve(a))return a;rr(n,`${r} must be an object, got ${de(a)}; its tags were left out`,g);return}function q(e,r,n){let g=Object.keys(e).filter((o)=>!L.has(o));if(g.length>0){let o=g.map((u)=>R[u]?`${u} (use ${R[u]})`:u).join(", ");rr(r,`@seo does not read ${o}; ${g.length===1?"it was":"they were"} ignored`,n)}let a="";if(e.title)a+=`<title>${l(e.title)}</title>
|
|
3
|
+
`,a+=`<meta name="title" content="${l(e.title)}">
|
|
4
|
+
`;if(e.description)a+=`<meta name="description" content="${l(e.description)}">
|
|
5
|
+
`;if(e.keywords){let o=Array.isArray(e.keywords)?e.keywords.join(", "):e.keywords;a+=`<meta name="keywords" content="${l(o)}">
|
|
6
|
+
`}if(e.robots)a+=`<meta name="robots" content="${l(e.robots)}">
|
|
7
|
+
`;if(e.canonical)a+=`<link rel="canonical" href="${l(e.canonical)}">
|
|
8
|
+
`;let s=b(e,"openGraph",r,n);if(s){if(a+=`<meta property="og:type" content="${l(s.type||"website")}">
|
|
9
|
+
`,s.title||e.title){let o=s.title||e.title||"";a+=`<meta property="og:title" content="${l(o)}">
|
|
10
|
+
`}if(s.description||e.description){let o=s.description||e.description||"";a+=`<meta property="og:description" content="${l(o)}">
|
|
11
|
+
`}if(s.url||e.canonical){let o=s.url||e.canonical||"";a+=`<meta property="og:url" content="${l(o)}">
|
|
12
|
+
`}if(s.image){if(a+=`<meta property="og:image" content="${l(s.image)}">
|
|
13
|
+
`,s.imageAlt)a+=`<meta property="og:image:alt" content="${l(s.imageAlt)}">
|
|
14
|
+
`;if(s.imageWidth)a+=`<meta property="og:image:width" content="${l(String(s.imageWidth))}">
|
|
15
|
+
`;if(s.imageHeight)a+=`<meta property="og:image:height" content="${l(String(s.imageHeight))}">
|
|
16
|
+
`;if(s.imageType)a+=`<meta property="og:image:type" content="${l(s.imageType)}">
|
|
17
|
+
`}if(s.siteName)a+=`<meta property="og:site_name" content="${l(s.siteName)}">
|
|
18
|
+
`;if(s.locale)a+=`<meta property="og:locale" content="${l(s.locale)}">
|
|
19
|
+
`;if(s.profile){let o=[["first_name",s.profile.firstName],["last_name",s.profile.lastName],["username",s.profile.username],["gender",s.profile.gender]];for(let[u,p]of o)if(p)a+=`<meta property="profile:${u}" content="${l(p)}">
|
|
20
|
+
`}}let c=b(e,"twitter",r,n);if(c){if(a+=`<meta name="twitter:card" content="${l(c.card||"summary_large_image")}">
|
|
21
|
+
`,c.title||e.title){let o=c.title||e.title||"";a+=`<meta name="twitter:title" content="${l(o)}">
|
|
22
|
+
`}if(c.description||e.description){let o=c.description||e.description||"";a+=`<meta name="twitter:description" content="${l(o)}">
|
|
23
|
+
`}if(c.image||s&&s.image){let o=c.image||(s?s.image:"")||"";a+=`<meta name="twitter:image" content="${l(o)}">
|
|
24
|
+
`;let u=c.imageAlt||(!c.image&&s?s.imageAlt:void 0);if(u)a+=`<meta name="twitter:image:alt" content="${l(u)}">
|
|
25
|
+
`}if(c.site)a+=`<meta name="twitter:site" content="${l(c.site)}">
|
|
26
|
+
`;if(c.creator)a+=`<meta name="twitter:creator" content="${l(c.creator)}">
|
|
27
|
+
`}if(e.structuredData!==void 0&&e.structuredData!==null){let o=v(e.structuredData);if(o)a+=`${A(o)}
|
|
28
|
+
`;else rr(r,`structuredData must be an object or an array of objects, got ${de(e.structuredData)}; it was left out`,n)}return a.trim()}function Rs(e,r,n){if(n.seo?.enabled===!1)return e;if(e.includes("<!-- stx SEO Tags -->")||r.__stx_seo_staged===!0||n.skipDefaultSeoTags===!0)return e;let g=r.__stx_runtime_head;if(!!(g?.title||g?.meta?.some((S)=>S.property==="og:title"||S.name==="og:title"||S.name==="twitter:title"||S.name==="description")))return e;if(/<meta\s+(?:[^>]*\s)?property=["']og:title["']/i.test(e)||/<meta\s+(?:[^>]*\s)?name=["']og:title["']/i.test(e)||/<meta\s+(?:[^>]*\s)?name=["']twitter:title["']/i.test(e))return e;if(!e.includes("<head>")&&!e.includes("<head "))return e;let s=e.includes("<title>")||e.includes("</title>"),c=M(e),o=V(c),u=U(c),p="";if(r.title)p=r.title;else if(r.meta&&r.meta.title)p=r.meta.title;else if(o)p=o;else if(n.seo?.defaultConfig?.title)p=n.seo.defaultConfig.title;else p=n.defaultTitle||"stx Project";let m="";if(r.description)m=r.description;else if(r.meta&&r.meta.description)m=r.meta.description;else if(u)m=u;else if(n.seo?.defaultConfig?.description)m=n.seo.defaultConfig.description;else m=n.defaultDescription||"A website built with stx templating engine";let d="";if(r.image)d=r.image;else if(r.meta&&r.meta.image)d=r.meta.image;else if(r.openGraph&&r.openGraph.image)d=r.openGraph.image;else if(n.seo?.defaultImage)d=n.seo.defaultImage;else if(n.defaultImage)d=n.defaultImage;let f=s?"":`
|
|
29
|
+
<meta name="title" content="${l(p)}">`,D=G(c)?"":`
|
|
30
|
+
<meta name="description" content="${l(m)}">`,y=`
|
|
31
|
+
<!-- stx SEO Tags -->${f}${D}
|
|
32
|
+
<meta property="og:title" content="${l(p)}">
|
|
33
|
+
<meta property="og:description" content="${l(m)}">
|
|
34
|
+
<meta property="og:type" content="website">
|
|
35
|
+
<meta name="twitter:card" content="summary_large_image">
|
|
36
|
+
<meta name="twitter:title" content="${l(p)}">
|
|
37
|
+
<meta name="twitter:description" content="${l(m)}">
|
|
38
|
+
`;if(d)y+=`
|
|
39
|
+
<meta property="og:image" content="${l(d)}">
|
|
40
|
+
<meta name="twitter:image" content="${l(d)}">
|
|
41
|
+
`;let h=e;if(!s)h=h.replace(/<head[^>]*>/,`$&
|
|
42
|
+
<title>${l(p)}</title>`);let w=r.__stx_head_injections;if(w)return r.__stx_seo_staged=!0,w.afterOpen.push(`
|
|
43
|
+
${y}
|
|
44
|
+
`),h;return h.replace(/<head[^>]*>/,`$&
|
|
45
|
+
${y}
|
|
46
|
+
`)}function M(e){let r=e.search(/<\/head\s*>/i);return r===-1?e:e.slice(0,r)}function x(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/�*39;|'/g,"'").replace(/&/g,"&")}function V(e){let r=e.match(/<title(?:\s[^>]*)?>([\s\S]*?)<\/title\s*>/i);return r?x(r[1].trim()):""}function O(e){return(e.match(/<meta\s[^>]*>/gi)||[]).filter((r)=>/\sname\s*=\s*["']description["']/i.test(r))}function G(e){return O(e).length>0}function U(e){for(let r of O(e)){let n=r.match(/\scontent\s*=\s*(?:"([^"]*)"|'([^']*)')/i),g=(n?.[1]??n?.[2]??"").trim();if(g)return x(g)}return""}function l(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var er={name:"meta",rawParams:!0,handler:(e,r,n,g)=>{let a=mn(r,n??{});if(a.kind==="error")return E("Meta",`@meta(${r.join(", ")})`,a.message,g,a.code);if(a.kind==="empty")return"";if(n)n.__stx_runtime_head=fe(n.__stx_runtime_head??{},{meta:[a.tag]});return""},hasEndTag:!1},tr={name:"structuredData",handler:(e,r,n,g)=>{if(e.trim()==="")return i("StructuredData","structuredData directive requires JSON-LD content",t.INVALID_DIRECTIVE_SYNTAX);try{let a=JSON.parse(e);if(!a["@context"])a["@context"]="https://schema.org";if(!a["@type"])return i("StructuredData","structuredData requires @type property",t.INVALID_DIRECTIVE_SYNTAX);return A(a)}catch(a){let s=a instanceof Error?a.message:String(a);return i("StructuredData",s,t.EVALUATION_ERROR)}},hasEndTag:!0};function Qu(){return[er,tr]}function ed(e,r){let{baseUrl:n,defaultChangefreq:g="weekly",defaultPriority:a=0.5,includeLastmod:s=!0}=r,c=n.replace(/\/$/,""),o=(m)=>m.startsWith("http")?m:`${c}${m.startsWith("/")?"":"/"}${m}`,u=e.map((m)=>{let d=o(m.loc),f=m.lastmod||(s?new Date().toISOString().split("T")[0]:void 0),D=m.changefreq||g,y=m.priority??a,h=` <url>
|
|
47
|
+
<loc>${T(d)}</loc>`;for(let w of m.alternates??[])h+=`
|
|
48
|
+
<xhtml:link rel="alternate" hreflang="${T(w.hreflang)}" href="${T(o(w.href))}"/>`;if(f)h+=`
|
|
49
|
+
<lastmod>${f}</lastmod>`;return h+=`
|
|
50
|
+
<changefreq>${D}</changefreq>`,h+=`
|
|
51
|
+
<priority>${y.toFixed(1)}</priority>`,h+=`
|
|
52
|
+
</url>`,h});return`<?xml version="1.0" encoding="UTF-8"?>
|
|
53
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"${e.some((m)=>m.alternates?.length)?' xmlns:xhtml="http://www.w3.org/1999/xhtml"':""}>
|
|
54
|
+
${u.join(`
|
|
55
|
+
`)}
|
|
56
|
+
</urlset>`}function td(e,r){let n=r.replace(/\/$/,""),g=new Date().toISOString().split("T")[0];return`<?xml version="1.0" encoding="UTF-8"?>
|
|
57
|
+
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
58
|
+
${e.map((s)=>{let c=s.startsWith("http")?s:`${n}${s.startsWith("/")?"":"/"}${s}`;return` <sitemap>
|
|
59
|
+
<loc>${T(c)}</loc>
|
|
60
|
+
<lastmod>${g}</lastmod>
|
|
61
|
+
</sitemap>`}).join(`
|
|
62
|
+
`)}
|
|
63
|
+
</sitemapindex>`}async function nd(e,r){let{extensions:n=[".stx",".html",".htm"],ignore:g=["_*",".*","node_modules","components","partials","layouts"]}=r,a=[],s=n.length===1?`*${n[0]}`:`*{${n.join(",")}}`,c=new Bun.Glob(`**/${s}`);for await(let o of c.scan(e)){if(g.some((f)=>{if(f.startsWith("*"))return o.includes(f.slice(1));return o.startsWith(f)||o.includes(`/${f}`)}))continue;let p=o.replace(/\\/g,"/").replace(/index\.(stx|html|htm)$/,"").replace(/\.(stx|html|htm)$/,"");if(!p.startsWith("/"))p=`/${p}`;if(p!=="/"&&p.endsWith("/"))p=p.slice(0,-1);let m=`${e}/${o}`,d;try{let f=await Bun.file(m).stat();if(f)d=new Date(f.mtime).toISOString().split("T")[0]}catch{}a.push({loc:p||"/",lastmod:d,priority:p==="/"?1:0.5})}return a.sort((o,u)=>o.loc.localeCompare(u.loc)),a}function nr(e){let r=[];for(let n of e.rules){if(r.push(`User-agent: ${n.userAgent}`),n.allow)for(let g of n.allow)r.push(`Allow: ${g}`);if(n.disallow)for(let g of n.disallow)r.push(`Disallow: ${g}`);if(n.crawlDelay!==void 0)r.push(`Crawl-delay: ${n.crawlDelay}`);r.push("")}if(e.sitemap){let n=Array.isArray(e.sitemap)?e.sitemap:[e.sitemap];for(let g of n)r.push(`Sitemap: ${g}`)}if(e.host)r.push(`Host: ${e.host}`);return r.join(`
|
|
64
|
+
`).trim()}function rd(e){return nr({rules:[{userAgent:"*",allow:["/"]}],sitemap:e})}function T(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}
|
|
65
|
+
export{Es,_s,Ts,Rs,er,tr,Qu,ed,td,nd,nr,rd};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Io}from"./chunk-aabzyk88.js";import{u}from"./chunk-cg8hg6cs.js";var wu=`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
'use strict';
|
|
@@ -465,7 +465,7 @@ else if (data.type === 'event' && data.method) {
|
|
|
465
465
|
}
|
|
466
466
|
})();
|
|
467
467
|
</script>
|
|
468
|
-
`;function
|
|
468
|
+
`;function ko(e={}){let{debug:r=!1,timeout:a=30000}=e;return`
|
|
469
469
|
<script>
|
|
470
470
|
(function() {
|
|
471
471
|
'use strict';
|
|
@@ -931,9 +931,9 @@ else if (data.type === 'event' && data.method) {
|
|
|
931
931
|
}
|
|
932
932
|
})();
|
|
933
933
|
</script>
|
|
934
|
-
`.replace("debug: false,",`debug: ${r},`).replace("timeout: 30000",`timeout: ${a}`)}function
|
|
934
|
+
`.replace("debug: false,",`debug: ${r},`).replace("timeout: 30000",`timeout: ${a}`)}function vu(){return!1}function xu(e,r={}){let a=/@craft(?:\(([\s\S]*?)\))?/g;return e.replace(a,(i,s)=>{let t={};if(s)try{t=JSON.parse(s.replace(/'/g,'"'))}catch{try{t=Function(`return ${s}`)()}catch{console.warn(`[stx] Invalid @craft config: ${s}`)}}return ko(t)})}function Co(e,r={}){if(e.includes("__craftBridgeInitialized"))return e;let a=ko(r);if(e.includes("</head>"))return e.replace("</head>",`${a}
|
|
935
935
|
</head>`);if(e.includes("<body"))return e.replace(/(<body[^>]*>)/,`$1
|
|
936
|
-
${a}`);return a+e}var
|
|
936
|
+
${a}`);return a+e}var zr={button:{nativeType:"craft-button",fallbackTag:"button",fallbackClasses:"craft-button",nativeProps:["variant","size","disabled","loading"]},"text-input":{nativeType:"craft-text-input",fallbackTag:"input",fallbackClasses:"craft-text-input",nativeProps:["placeholder","value","type","disabled","readonly"]},textarea:{nativeType:"craft-textarea",fallbackTag:"textarea",fallbackClasses:"craft-textarea",nativeProps:["placeholder","value","rows","disabled","readonly"]},checkbox:{nativeType:"craft-checkbox",fallbackTag:"input",fallbackClasses:"craft-checkbox",nativeProps:["checked","disabled","label"],render:(e,r)=>{let a=e.checked?"checked":"",i=e.disabled?"disabled":"";return`<label class="craft-checkbox-wrapper">
|
|
937
937
|
<input type="checkbox" class="craft-checkbox" ${a} ${i}>
|
|
938
938
|
<span class="craft-checkbox-label">${r||e.label||""}</span>
|
|
939
939
|
</label>`}},radio:{nativeType:"craft-radio",fallbackTag:"input",fallbackClasses:"craft-radio",nativeProps:["checked","disabled","name","value","label"]},select:{nativeType:"craft-select",fallbackTag:"select",fallbackClasses:"craft-select",nativeProps:["value","disabled","options","placeholder"]},slider:{nativeType:"craft-slider",fallbackTag:"input",fallbackClasses:"craft-slider",nativeProps:["value","min","max","step","disabled"],render:(e,r)=>{let a=e.min??0,i=e.max??100,s=e.step??1,t=e.value??50,n=e.disabled?"disabled":"";return`<input type="range" class="craft-slider" min="${a}" max="${i}" step="${s}" value="${t}" ${n}>`}},label:{nativeType:"craft-label",fallbackTag:"span",fallbackClasses:"craft-label",nativeProps:["text","for"]},badge:{nativeType:"craft-badge",fallbackTag:"span",fallbackClasses:"craft-badge",nativeProps:["variant","size"]},avatar:{nativeType:"craft-avatar",fallbackTag:"div",fallbackClasses:"craft-avatar",nativeProps:["src","alt","size","fallback"],render:(e,r)=>{let a=e.size||40,i=e.src,s=String(e.alt||""),t=e.fallback||(s?s.charAt(0).toUpperCase():"?");if(i)return`<img class="craft-avatar" src="${i}" alt="${s}" style="width:${a}px;height:${a}px;border-radius:50%">`;return`<div class="craft-avatar craft-avatar-fallback" style="width:${a}px;height:${a}px;border-radius:50%;display:flex;align-items:center;justify-content:center">${t}</div>`}},progress:{nativeType:"craft-progress",fallbackTag:"div",fallbackClasses:"craft-progress",nativeProps:["value","max","variant"],render:(e,r)=>{let a=Number(e.value)||0,i=Number(e.max)||100;return`<div class="craft-progress"><div class="craft-progress-bar" style="width:${Math.min(100,Math.max(0,a/i*100))}%"></div></div>`}},spinner:{nativeType:"craft-spinner",fallbackTag:"div",fallbackClasses:"craft-spinner",nativeProps:["size"],render:(e,r)=>{let a=e.size||24;return`<div class="craft-spinner" style="width:${a}px;height:${a}px"></div>`}},card:{nativeType:"craft-card",fallbackTag:"div",fallbackClasses:"craft-card",nativeProps:["title","subtitle","variant"]},modal:{nativeType:"craft-modal",fallbackTag:"dialog",fallbackClasses:"craft-modal",nativeProps:["open","title","closable","size"],render:(e,r)=>{let a=e.open?"open":"",i=e.title||"";return`<dialog class="craft-modal" ${a}>
|
|
@@ -947,7 +947,7 @@ ${a}`);return a+e}var Br={button:{nativeType:"craft-button",fallbackTag:"button"
|
|
|
947
947
|
</details>`}},divider:{nativeType:"craft-divider",fallbackTag:"hr",fallbackClasses:"craft-divider",nativeProps:["orientation","variant"]},table:{nativeType:"craft-table",fallbackTag:"table",fallbackClasses:"craft-table",nativeProps:["columns","rows","sortable","selectable"]},list:{nativeType:"craft-list",fallbackTag:"ul",fallbackClasses:"craft-list",nativeProps:["items","selectable"]},tree:{nativeType:"craft-tree",fallbackTag:"div",fallbackClasses:"craft-tree",nativeProps:["nodes","expandable","selectable"]},alert:{nativeType:"craft-alert",fallbackTag:"div",fallbackClasses:"craft-alert",nativeProps:["variant","title","dismissible"],render:(e,r)=>{let a=e.variant||"info",i=e.title||"";return`<div class="craft-alert craft-alert-${a}" role="alert">
|
|
948
948
|
${i?`<div class="craft-alert-title">${i}</div>`:""}
|
|
949
949
|
<div class="craft-alert-content">${r}</div>
|
|
950
|
-
</div>`}},toast:{nativeType:"craft-toast",fallbackTag:"div",fallbackClasses:"craft-toast",nativeProps:["variant","duration","position"]},tooltip:{nativeType:"craft-tooltip",fallbackTag:"span",fallbackClasses:"craft-tooltip",nativeProps:["content","position"],render:(e,r)=>{let a=e.content||"",i=e.position||"top";return`<span class="craft-tooltip" data-tooltip="${a}" data-position="${i}">${r}</span>`}},menu:{nativeType:"craft-menu",fallbackTag:"nav",fallbackClasses:"craft-menu",nativeProps:["items","orientation"]},breadcrumb:{nativeType:"craft-breadcrumb",fallbackTag:"nav",fallbackClasses:"craft-breadcrumb",nativeProps:["items","separator"]},sidebar:{nativeType:"craft-sidebar",fallbackTag:"aside",fallbackClasses:"craft-sidebar craft-sidebar-tahoe",nativeProps:["id","variant","material","backgroundEffect","allowsVibrancy","materialOpacity","materialDarkOpacity","minWidth","maxWidth","canCollapse","searchPlaceholder","selectedItem","sections","spaces","selectedSpace"],render:j},"sidebar-space":{nativeType:"craft-sidebar-space",fallbackTag:"section",fallbackClasses:"craft-sidebar-space",nativeProps:["id","label","icon","tint"],render:H},"sidebar-section":{nativeType:"craft-sidebar-section",fallbackTag:"section",fallbackClasses:"craft-sidebar-section",nativeProps:["id","title","header"],render:V},"sidebar-item":{nativeType:"craft-sidebar-item",fallbackTag:"button",fallbackClasses:"craft-sidebar-item",nativeProps:["id","label","icon","badge","tintColor"],render:W},pagination:{nativeType:"craft-pagination",fallbackTag:"nav",fallbackClasses:"craft-pagination",nativeProps:["total","page","pageSize"]},"code-editor":{nativeType:"craft-code-editor",fallbackTag:"textarea",fallbackClasses:"craft-code-editor",nativeProps:["value","language","theme","readonly","lineNumbers"]},"file-browser":{nativeType:"craft-file-browser",fallbackTag:"div",fallbackClasses:"craft-file-browser",nativeProps:["path","showHidden","selectable"]},"color-picker":{nativeType:"craft-color-picker",fallbackTag:"input",fallbackClasses:"craft-color-picker",nativeProps:["value","format"],render:(e,r)=>`<input type="color" class="craft-color-picker" value="${e.value||"#000000"}">`},"date-picker":{nativeType:"craft-date-picker",fallbackTag:"input",fallbackClasses:"craft-date-picker",nativeProps:["value","min","max","format"],render:(e,r)=>{let a=e.value||"",i=e.min||"",s=e.max||"";return`<input type="date" class="craft-date-picker" value="${a}" min="${i}" max="${s}">`}},"time-picker":{nativeType:"craft-time-picker",fallbackTag:"input",fallbackClasses:"craft-time-picker",nativeProps:["value","min","max","step"],render:(e,r)=>`<input type="time" class="craft-time-picker" value="${e.value||""}">`}}
|
|
950
|
+
</div>`}},toast:{nativeType:"craft-toast",fallbackTag:"div",fallbackClasses:"craft-toast",nativeProps:["variant","duration","position"]},tooltip:{nativeType:"craft-tooltip",fallbackTag:"span",fallbackClasses:"craft-tooltip",nativeProps:["content","position"],render:(e,r)=>{let a=e.content||"",i=e.position||"top";return`<span class="craft-tooltip" data-tooltip="${a}" data-position="${i}">${r}</span>`}},menu:{nativeType:"craft-menu",fallbackTag:"nav",fallbackClasses:"craft-menu",nativeProps:["items","orientation"]},breadcrumb:{nativeType:"craft-breadcrumb",fallbackTag:"nav",fallbackClasses:"craft-breadcrumb",nativeProps:["items","separator"]},sidebar:{nativeType:"craft-sidebar",fallbackTag:"aside",fallbackClasses:"craft-sidebar craft-sidebar-tahoe",nativeProps:["id","variant","material","backgroundEffect","allowsVibrancy","materialOpacity","materialDarkOpacity","minWidth","maxWidth","canCollapse","searchPlaceholder","selectedItem","sections","spaces","selectedSpace"],render:j},"sidebar-space":{nativeType:"craft-sidebar-space",fallbackTag:"section",fallbackClasses:"craft-sidebar-space",nativeProps:["id","label","icon","tint"],render:H},"sidebar-section":{nativeType:"craft-sidebar-section",fallbackTag:"section",fallbackClasses:"craft-sidebar-section",nativeProps:["id","title","header"],render:V},"sidebar-item":{nativeType:"craft-sidebar-item",fallbackTag:"button",fallbackClasses:"craft-sidebar-item",nativeProps:["id","label","icon","badge","tintColor"],render:W},pagination:{nativeType:"craft-pagination",fallbackTag:"nav",fallbackClasses:"craft-pagination",nativeProps:["total","page","pageSize"]},"code-editor":{nativeType:"craft-code-editor",fallbackTag:"textarea",fallbackClasses:"craft-code-editor",nativeProps:["value","language","theme","readonly","lineNumbers"]},"file-browser":{nativeType:"craft-file-browser",fallbackTag:"div",fallbackClasses:"craft-file-browser",nativeProps:["path","showHidden","selectable"]},"color-picker":{nativeType:"craft-color-picker",fallbackTag:"input",fallbackClasses:"craft-color-picker",nativeProps:["value","format"],render:(e,r)=>`<input type="color" class="craft-color-picker" value="${e.value||"#000000"}">`},"date-picker":{nativeType:"craft-date-picker",fallbackTag:"input",fallbackClasses:"craft-date-picker",nativeProps:["value","min","max","format"],render:(e,r)=>{let a=e.value||"",i=e.min||"",s=e.max||"";return`<input type="date" class="craft-date-picker" value="${a}" min="${i}" max="${s}">`}},"time-picker":{nativeType:"craft-time-picker",fallbackTag:"input",fallbackClasses:"craft-time-picker",nativeProps:["value","min","max","step"],render:(e,r)=>`<input type="time" class="craft-time-picker" value="${e.value||""}">`}},$o=`
|
|
951
951
|
<style id="craft-component-styles">
|
|
952
952
|
/* Craft Component Base Styles */
|
|
953
953
|
.craft-button {
|
|
@@ -1365,7 +1365,7 @@ ${a}`);return a+e}var Br={button:{nativeType:"craft-button",fallbackTag:"button"
|
|
|
1365
1365
|
}
|
|
1366
1366
|
}
|
|
1367
1367
|
</style>
|
|
1368
|
-
`,
|
|
1368
|
+
`,Su=`
|
|
1369
1369
|
<script id="craft-component-runtime">
|
|
1370
1370
|
(function() {
|
|
1371
1371
|
if (window.__stxCraftComponentRuntime) return;
|
|
@@ -1469,7 +1469,7 @@ ${a}`);return a+e}var Br={button:{nativeType:"craft-button",fallbackTag:"button"
|
|
|
1469
1469
|
document.addEventListener('craft:nativeui:ready', initializeCraftComponents);
|
|
1470
1470
|
})();
|
|
1471
1471
|
</script>
|
|
1472
|
-
`;function
|
|
1472
|
+
`;function Eo(e,r={}){let{classPrefix:a="craft"}=r;if(!e.includes("craft-component-styles"))if(e.includes("</head>"))e=e.replace("</head>",`${`
|
|
1473
1473
|
<style id="craft-component-styles">
|
|
1474
1474
|
/* Craft Component Base Styles */
|
|
1475
1475
|
.craft-button {
|
|
@@ -2934,7 +2934,7 @@ ${a}`);return a+e}var Br={button:{nativeType:"craft-button",fallbackTag:"button"
|
|
|
2934
2934
|
document.addEventListener('craft:nativeui:ready', initializeCraftComponents);
|
|
2935
2935
|
})();
|
|
2936
2936
|
</script>
|
|
2937
|
-
`;return e=e.replace(/<@craft-sidebar(?![-\w])\s*([^>]*)>([\s\S]*?)<\/@craft-sidebar>/g,(i,s,t)=>R("sidebar",s,t.trim(),r,a)),e=e.replace(/<@craft-sidebar(?![-\w])\s*([^>]*?)\/>/g,(i,s)=>R("sidebar",s,"",r,a)),e=e.replace(/<@craft-(\w+[-\w]*)\s*([^>]*?)\/>/g,(i,s,t)=>R(s,t,"",r,a)),e=e.replace(/<@craft-(\w+[-\w]*)\s*([^>]*)>([\s\S]*?)<\/@craft-\1>/g,(i,s,t,n)=>R(s,t,n.trim(),r,a)),e}function R(e,r,a,i,s){let t=i.components?.[e]||
|
|
2937
|
+
`;return e=e.replace(/<@craft-sidebar(?![-\w])\s*([^>]*)>([\s\S]*?)<\/@craft-sidebar>/g,(i,s,t)=>R("sidebar",s,t.trim(),r,a)),e=e.replace(/<@craft-sidebar(?![-\w])\s*([^>]*?)\/>/g,(i,s)=>R("sidebar",s,"",r,a)),e=e.replace(/<@craft-(\w+[-\w]*)\s*([^>]*?)\/>/g,(i,s,t)=>R(s,t,"",r,a)),e=e.replace(/<@craft-(\w+[-\w]*)\s*([^>]*)>([\s\S]*?)<\/@craft-\1>/g,(i,s,t,n)=>R(s,t,n.trim(),r,a)),e}function R(e,r,a,i,s){let t=i.components?.[e]||zr[e];if(!t)return console.warn(`[stx] Unknown Craft component: @craft-${e}`),`<div class="${s}-unknown" data-component="${e}">${a}</div>`;let n=A(r),c=[t.fallbackClasses||`${s}-${e}`];if(n.class)c.push(n.class),delete n.class;if(t.render)return n.__fallbackClasses=c.join(" "),t.render(n,a);let d=ee(n,t,c);if(["input","hr","br","img"].includes(t.fallbackTag))return`<${t.fallbackTag} ${d}>`;return`<${t.fallbackTag} ${d}>${a}</${t.fallbackTag}>`}function A(e){let r={},a=/(?::|@)?(\w+[-\w]*)(?:=(?:"([^"]*)"|'([^']*)'))?/g,i;while((i=a.exec(e))!==null){let[s,t,n,c]=i,d=n??c;if(s.startsWith(":"))r[t]=d;else if(s.startsWith("@"))r[`on${t.charAt(0).toUpperCase()}${t.slice(1)}`]=d;else if(d===void 0)r[t]=!0;else r[t]=d}return r}function j(e,r){let a=I(String(e.id||`craft-sidebar-${K(r||JSON.stringify(e))}`)),i=Q(e.spaces)||Y(r),s=i.length?[]:X(e.sections)||F(r),t=String(e.selectedSpace||i[0]?.id||""),n=i.find((g)=>g.id===t)||i[0],c=String(e.selectedItem||e.selected||(i.length?n?.sections[0]?.items[0]?.id:s[0]?.items[0]?.id)||""),d={id:a,variant:String(e.variant||"desktop"),material:String(e.material||"sidebar"),backgroundEffect:String(e.backgroundEffect||"shimmer"),allowsVibrancy:e.allowsVibrancy!==!1&&e.allowsVibrancy!=="false",materialOpacity:Number(e.materialOpacity??0.68),materialDarkOpacity:e.materialDarkOpacity===void 0?void 0:Number(e.materialDarkOpacity),minWidth:e.minWidth===void 0?240:Number(e.minWidth),maxWidth:e.maxWidth===void 0?340:Number(e.maxWidth),canCollapse:e.canCollapse!==!1&&e.canCollapse!=="false",searchPlaceholder:e.searchPlaceholder?String(e.searchPlaceholder):void 0,selectedItem:c,sections:s,spaces:i,selectedSpace:t||void 0},l=String(e.__fallbackClasses||"craft-sidebar craft-sidebar-tahoe"),p=Number(e.width||e.sidebarWidth||286),f=e.native===!1||e.native==="false"?"false":"true",x=d.searchPlaceholder?`<div class="craft-sidebar-search"><input type="search" placeholder="${C(d.searchPlaceholder)}"></div>`:"",b;if(i.length)b=G(i,t,c);else if(s.length)b=s.map((g)=>D(g,c)).join("");else b=r;return`<aside class="${h(l)}" data-craft="craft-sidebar" data-craft-native-sidebar data-craft-sidebar-id="${h(a)}" data-native="${f}" style="--craft-sidebar-width:${p}px">
|
|
2938
2938
|
${x}
|
|
2939
2939
|
${b}
|
|
2940
2940
|
</aside>
|
|
@@ -2955,7 +2955,7 @@ ${a}`);return a+e}var Br={button:{nativeType:"craft-button",fallbackTag:"button"
|
|
|
2955
2955
|
${e.icon?`<span class="craft-sidebar-item-icon" data-icon="${h(e.icon)}"${a}></span>`:""}
|
|
2956
2956
|
<span class="craft-sidebar-item-label">${C(e.label)}</span>
|
|
2957
2957
|
${e.badge?`<span class="craft-sidebar-item-badge">${C(e.badge)}</span>`:""}
|
|
2958
|
-
</button>`}function I(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"craft-sidebar"}function K(e){let r=5381;for(let a=0;a<e.length;a++)r=r*33^e.charCodeAt(a);return(r>>>0).toString(36)}function C(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function h(e){return C(e).replace(/`/g,"`")}function Z(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026")}function ee(e,r,a){let i=[];i.push(`class="${a.join(" ")}"`),i.push(`data-craft="${r.nativeType}"`);for(let[s,t]of Object.entries(e))if(t===!0)i.push(s);else if(t!==!1&&t!==void 0&&t!==null){let n=String(t).replace(/"/g,""");i.push(`${s}="${n}"`)}return i.join(" ")}function
|
|
2958
|
+
</button>`}function I(e){return e.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"craft-sidebar"}function K(e){let r=5381;for(let a=0;a<e.length;a++)r=r*33^e.charCodeAt(a);return(r>>>0).toString(36)}function C(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function h(e){return C(e).replace(/`/g,"`")}function Z(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026")}function ee(e,r,a){let i=[];i.push(`class="${a.join(" ")}"`),i.push(`data-craft="${r.nativeType}"`);for(let[s,t]of Object.entries(e))if(t===!0)i.push(s);else if(t!==!1&&t!==void 0&&t!==null){let n=String(t).replace(/"/g,""");i.push(`${s}="${n}"`)}return i.join(" ")}function ku(e,r){zr[e]=r}function Cu(){return{...zr}}import{existsSync as z,mkdirSync as v,copyFileSync as k,chmodSync as T}from"fs";import{join as o,basename as te}from"path";import{spawn as E,execSync as re}from"child_process";import{tmpdir as M,homedir as q,platform as ae}from"os";async function _o(e){let r=Date.now();try{if(!await Bun.file(e.input).exists())return{success:!1,target:e.target||P(),format:e.format||"app",error:`Input file not found: ${e.input}`};let a=e.target||P(),i=e.format||ue(a),s=e.output||o(process.cwd(),"dist","native");if(!z(s))v(s,{recursive:!0});let t=await Io(e.input,{context:e.context,options:{isDev:!1}});if(t=Co(t,{debug:e.verbose}),t=Eo(t),!t.includes("craft-component-styles")){if(t.includes("</head>"))t=t.replace("</head>",`${$o}
|
|
2959
2959
|
</head>`)}let n=e.name||te(e.input,".stx"),c=e.version||"1.0.0",d=e.craftPath||await fe();if(!d)return{success:!1,target:a,format:i,error:"Craft binary not found. Please install Craft or specify craftPath."};if(e.verbose)console.log(`\uD83D\uDCE6 Building native app for ${a}...`),console.log(` Input: ${e.input}`),console.log(` Output: ${s}`),console.log(` Craft: ${d}`);let l;switch(a){case"macos":l=await ie(t,n,c,s,i,e,d);break;case"windows":l=await oe(t,n,c,s,i,e,d);break;case"linux":l=await ce(t,n,c,s,i,e,d);break;case"ios":l=await de(t,n,c,s,e,d);break;case"android":l=await le(t,n,c,s,e,d);break;default:l={success:!1,target:a,format:i,error:`Unsupported target: ${a}`}}return l.duration=Date.now()-r,l}catch(a){return{success:!1,target:e.target||P(),format:e.format||"app",error:a.message,duration:Date.now()-r}}}async function ie(e,r,a,i,s,t,n){let c=t.bundleId||`com.stx.${r.toLowerCase().replace(/[^a-z0-9]/g,"")}`,d=o(i,`${r}.app`),l=o(d,"Contents"),p=o(l,"MacOS"),f=o(l,"Resources");v(p,{recursive:!0}),v(f,{recursive:!0});let x=o(f,"index.html");await Bun.write(x,e);let b="";if(t.sidebar?.enabled&&t.sidebar?.config)b=o(f,"sidebar-config.json"),await Bun.write(b,JSON.stringify(t.sidebar.config));let g=t.sidebar?.enabled?`--native-sidebar --sidebar-width ${t.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",m=t.menubarOnly??t.systemTray;if((t.bundleStyle||(await se(n)?"executable":"launcher"))==="executable"){let S=o(p,r);k(n,S),T(S,493);let w={html:"index.html",title:t.window?.title||r,width:t.window?.width||1200,height:t.window?.height||800,devTools:Boolean(t.devTools)};if(m)w.menubarOnly=!0;else if(t.systemTray)w.systemTray=!0;if(t.window?.frameless)w.frameless=!0;if(t.window?.transparent)w.transparent=!0;if(t.window?.alwaysOnTop)w.alwaysOnTop=!0;if(t.window?.resizable===!1)w.resizable=!1;await Bun.write(o(f,"craft.json"),`${JSON.stringify(w,null,2)}
|
|
2960
2960
|
`)}else{let S=o(p,"craft");k(n,S),T(S,493);let w=t.sidebar?.enabled?`--native-sidebar --sidebar-width ${t.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",U=`#!/bin/bash
|
|
2961
2961
|
set -euo pipefail
|
|
@@ -3018,5 +3018,5 @@ Exec=${a.toLowerCase()}
|
|
|
3018
3018
|
Terminal=false
|
|
3019
3019
|
Categories=Utility;
|
|
3020
3020
|
Icon=${a.toLowerCase()}
|
|
3021
|
-
`;u("fs").writeFileSync(o(n,`${a.toLowerCase()}.desktop`),b);let g=Buffer.from([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,2,0,0,0,144,119,83,222,0,0,0,12,73,68,65,84,8,215,99,248,255,255,63,0,5,254,2,254,220,204,89,231,0,0,0,0,73,69,78,68,174,66,96,130]);if(u("fs").writeFileSync(o(n,`${a.toLowerCase()}.png`),g),i.icon&&z(i.icon))k(i.icon,o(n,`${a.toLowerCase()}.png`));let m=E("appimagetool",[n,r],{env:{...process.env,ARCH:"x86_64"}});m.on("close",(y)=>{if(u("fs").rmSync(t,{recursive:!0,force:!0}),y===0)T(r,493),s({success:!0});else s({success:!1,error:`appimagetool exited with code ${y}. Install from https://appimage.github.io/appimagetool/`})}),m.on("error",(y)=>{u("fs").rmSync(t,{recursive:!0,force:!0}),s({success:!1,error:`appimagetool not found: ${y.message}`})})}catch(t){s({success:!1,error:t.message})}})}function
|
|
3022
|
-
export{
|
|
3021
|
+
`;u("fs").writeFileSync(o(n,`${a.toLowerCase()}.desktop`),b);let g=Buffer.from([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,2,0,0,0,144,119,83,222,0,0,0,12,73,68,65,84,8,215,99,248,255,255,63,0,5,254,2,254,220,204,89,231,0,0,0,0,73,69,78,68,174,66,96,130]);if(u("fs").writeFileSync(o(n,`${a.toLowerCase()}.png`),g),i.icon&&z(i.icon))k(i.icon,o(n,`${a.toLowerCase()}.png`));let m=E("appimagetool",[n,r],{env:{...process.env,ARCH:"x86_64"}});m.on("close",(y)=>{if(u("fs").rmSync(t,{recursive:!0,force:!0}),y===0)T(r,493),s({success:!0});else s({success:!1,error:`appimagetool exited with code ${y}. Install from https://appimage.github.io/appimagetool/`})}),m.on("error",(y)=>{u("fs").rmSync(t,{recursive:!0,force:!0}),s({success:!1,error:`appimagetool not found: ${y.message}`})})}catch(t){s({success:!1,error:t.message})}})}function To(){return[P()]}function Ro(e){switch(e){case"macos":return["app","dmg","pkg"];case"windows":return["app","zip","msi"];case"linux":return["app","deb","rpm","appimage"];case"ios":return["ipa"];case"android":return["apk"];default:return["app"]}}var he={buildNative:_o,getAvailableTargets:To,getAvailableFormats:Ro,detectPlatform:P},$u=he;
|
|
3022
|
+
export{wu,ko,vu,xu,Co,zr,$o,Su,Eo,ku,Cu,_o,To,Ro,$u};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{xt,gs,ui,$c}from"./chunk-5f7qy42x.js";import"./chunk-szry3s17.js";import"./chunk-c57j92td.js";import"./chunk-kp4mzspk.js";import"./chunk-nxxmhrd0.js";import"./chunk-1erc0vrb.js";import"./chunk-qmcmjdy7.js";import"./chunk-b77v56fz.js";import"./chunk-2pph3dh0.js";import"./chunk-d4k4nyj0.js";import"./chunk-v7vkqg8f.js";import"./chunk-rmavqxd8.js";import"./chunk-e6y6s7q8.js";export{$c as declareBareLoopHead,xt as parseLoopBinding,ui as processLoops,gs as reportDeferredLoopWarnings};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{wl}from"./chunk-2hbygqzj.js";import"./chunk-5f7qy42x.js";import"./chunk-szry3s17.js";import"./chunk-c57j92td.js";import"./chunk-kp4mzspk.js";import"./chunk-nxxmhrd0.js";import"./chunk-1erc0vrb.js";import"./chunk-qmcmjdy7.js";import"./chunk-b77v56fz.js";import"./chunk-2pph3dh0.js";import"./chunk-d4k4nyj0.js";import"./chunk-v7vkqg8f.js";import"./chunk-rmavqxd8.js";import"./chunk-e6y6s7q8.js";export{wl as buildApp};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{_o,To,Ro,$u}from"./chunk-qv3rrz9a.js";import"./chunk-aabzyk88.js";import"./chunk-5f7qy42x.js";import"./chunk-szry3s17.js";import"./chunk-c57j92td.js";import"./chunk-kp4mzspk.js";import"./chunk-nxxmhrd0.js";import"./chunk-1erc0vrb.js";import"./chunk-qmcmjdy7.js";import"./chunk-b77v56fz.js";import"./chunk-2pph3dh0.js";import"./chunk-d4k4nyj0.js";import"./chunk-v7vkqg8f.js";import"./chunk-rmavqxd8.js";import"./chunk-e6y6s7q8.js";export{_o as buildNative,$u as default,Ro as getAvailableFormats,To as getAvailableTargets};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Broadcast as s,BroadcastServer as h}from"ts-broadcasting";import{channel as
|
|
3
|
-
export{
|
|
2
|
+
import{Broadcast as s,BroadcastServer as h}from"ts-broadcasting";import{channel as hl}from"ts-broadcasting";import{Broadcast as yl,BroadcastServer as bl}from"ts-broadcasting";var e=null,u=[];function cl(){return e}async function ll(n){if(e)return e;let t=n.driver??"bun",r=n.host??"0.0.0.0",c=n.port??6001,l=n.scheme??"ws",a={verbose:n.verbose??!1,driver:t,default:t,connections:{[t]:{driver:t,host:r,port:c,scheme:l}}};return e=new h(a),s.setServer(e),await e.start(),e}async function ul(){for(let n of u)clearInterval(n);if(u.length=0,!e)return;await e.stop(),e=null}async function dl(n){let t=await import(n),r=t.default??t;if(typeof r!=="function")throw Error(`routes/channels.ts must export a default function, got ${typeof r}`);let c=0;return r({channel(a,o){if(c++,o.authorize&&e)e.channels.channel(a,o.authorize);if(o.interval&&o.data){let d=o.event??`${a}.updated`,p=o.data,v=setInterval(async()=>{try{let g=await p();sa(a,d,g)}catch{}},o.interval);u.push(v)}}}),c}var f=!1;function i(){if(e)return!0;if(!f)f=!0,console.warn("[stx] broadcast() called before server started \u2014 messages will be sent once broadcasting is ready");return!1}function sa(n,t,r){if(!i())return;s.send(n,t,r)}function pl(n,t,r){if(!i())return;s.toUser(n,t,r)}function fl(n,t,r){if(!i())return;s.toUsers(n,t,r)}function gl(n,t,r){if(!i())return;s.send(`private-${n}`,t,r)}function ml(n,t,r){if(!i())return;s.presence(n,t,r)}
|
|
3
|
+
export{cl,ll,ul,dl,sa,pl,fl,gl,ml,hl,yl,bl};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import x from"fs";import u from"path";import p from"fs";import w from"path";var y=["components","layouts","partials","emails"];function P(e){return e.split(/[\\/]/).filter(Boolean).slice(0,-1).some((a)=>y.includes(a))}function b(e){return P(e.replace(/^\//,""))}function
|
|
3
|
-
`),o=w.join(t,"route-types.d.ts");try{if(p.existsSync(o)&&p.readFileSync(o,"utf8")===n)return;p.mkdirSync(t,{recursive:!0}),p.writeFileSync(o,n)}catch{}}function
|
|
4
|
-
`))}import D from"path";var N=Object.freeze(["ico","png","jpg","jpeg","gif","webp","avif","svg","bmp","tif","tiff","heic","css","js","mjs","cjs","map","wasm","webmanifest","json","xml","txt","rss","atom","woff","woff2","ttf","otf","eot","mp3","mp4","m4a","m4v","mov","webm","ogg","ogv","oga","wav","flac","avi","mkv","pdf","csv","doc","docx","xls","xlsx","ppt","pptx","rtf","odt","zip","gz","tgz","tar","rar","7z","bz2","xz","php","phtml","asp","aspx","jsp","cgi","env","ini","yml","yaml","toml","sql","bak","old","swp","log","conf","cfg","exe","dmg","pkg","apk","ipa","msi","iso","bin","dll"]),I=N.flatMap((e)=>e===e.toUpperCase()?[e]:[e,e.toUpperCase()]).join("|"),j=new RegExp(`\\.(?:${I})$`),E=`(?![^/]*\\.(?:${I})$)`;function Ze(e){let t=e,a=t.search(/[?#]/);if(a!==-1)t=t.slice(0,a);let r=t.slice(t.lastIndexOf("/")+1);return r.length>0&&j.test(r)}function R(e,t){let r=D.relative(t,e).replace(/\.(stx|md)$/,"");if(r=r.split(D.sep).join("/"),r==="index")return"/";if(r.endsWith("/index"))r=r.slice(0,-6);return r=r.replace(/\[\[([^\]]+)\]\]/g,":$1?"),r=r.replace(/\[([^\]]+)\]/g,":$1"),r=r.replace(/:\.\.\.([^/]+)/g,":$1*"),`/${r}`}function G(e,t={}){let a=t.page?E:"",r=[],n="",o=0;while(o<e.length){let i=e.slice(o),c=/^\/:([^/?*]+)\?/.exec(i);if(c){r.push(c[1]);let d=o+c[0].length===e.length;n+=`(?:/${d?a:""}([^/]+))?`,o+=c[0].length;continue}let s=/^:([^/?*]+)\*/.exec(i);if(s){r.push(s[1]),n+="(.+)",o+=s[0].length;continue}let l=/^:([^/?*]+)/.exec(i);if(l){r.push(l[1]);let d=o+l[0].length===e.length;n+=`${d?a:""}([^/]+)`,o+=l[0].length;continue}n+=e[o].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),o+=1}return{regex:new RegExp(`^${n}$`),params:r}}function hn(e,t){let a=e===""?"/":e;for(let r of t){let n=a.match(r.regex);if(n){let o={};return r.params.forEach((i,c)=>{o[i]=n[c+1]}),{route:r,params:o}}}return null}function ar(e,t={}){let a=e.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return G(a,t)}import K from"fs";import L from"path";function _(e,t){let a=[],r=L.dirname(e);while(r.startsWith(t)||r===t){let n=L.join(r,"_layout.stx");if(K.existsSync(n))a.unshift(n);if(r===t)break;r=L.dirname(r)}return a}function F(e,t){let a=[];if(!x.existsSync(e))return a;let r=x.readdirSync(e,{withFileTypes:!0});for(let n of r){let o=u.join(e,n.name);if(n.isDirectory()){if(n.name.startsWith("."))continue;if(y.includes(n.name))continue;a.push(...F(o,t))}else if(n.isFile()){let i=u.extname(n.name);if(t.includes(i)){if(n.name.startsWith("_")&&n.name!=="_layout.stx")continue;if(n.name==="_layout.stx")continue;a.push(o)}}}return a}class yn{routes;pagesDir;pagesDirs;config;constructor(e,t={}){this.config=t;let a=t.pagesDirs&&t.pagesDirs.length>0?t.pagesDirs:[t.pagesDir||"pages"];this.pagesDirs=a.map((s)=>u.resolve(e,s)),this.pagesDir=this.pagesDirs[0];let r=t.extensions||[".stx"],n=(s)=>{let l=u.resolve(e,s);try{return x.realpathSync(l)}catch{return l}},o=(t.exclude??[]).filter((s)=>typeof s==="string"&&s.trim()!=="").map(n),i=(s)=>{if(o.length===0)return!1;let l=n(s);return o.some((d)=>l===d||l.startsWith(`${d}${u.sep}`))},c=new Set;this.routes=[];for(let s of this.pagesDirs){let l=F(s,r).filter((h)=>!i(h)),d=new Map;for(let h of l){let g=R(h,s),m=t.pagesDirs?g.replace(/:[\w]+/g,":param"):g;if(t.pagesDirs&&d.has(m))throw Error(`Conflicting layer pages for ${g}: ${d.get(m)} and ${h}`);if(d.set(m,h),c.has(m))continue;c.add(m);let{regex:H,params:M}=G(g,{page:!0}),C=t.layouts!==!1?_(h,s):[];this.routes.push({pattern:g,regex:H,params:M,filePath:h,isDynamic:M.length>0,layout:C.length>0?C[C.length-1]:void 0})}}if(this.routes.sort((s,l)=>{if(!s.isDynamic&&l.isDynamic)return-1;if(s.isDynamic&&!l.isDynamic)return 1;let d=s.pattern.split("/").length,h=l.pattern.split("/").length;if(d!==h)return h-d;return s.pattern.localeCompare(l.pattern)}),t.emit!==!1){let s=u.resolve(e,t.stateDir||process.env.STX_DIR?.trim()||".stx");Ms(this.routes,s),Ns(this.routes,s,this.pagesDir)}}match(e){let t=e===""?"/":e;for(let a of this.routes){let r=t.match(a.regex);if(r){let n={};return a.params.forEach((o,i)=>{n[o]=r[i+1]}),{route:a,params:n}}}return null}resolve(e,t){let a=this.routes.find((n)=>n.pattern===e||n.filePath.includes(e));if(!a)return"#not-found";let r=a.pattern;if(t)for(let[n,o]of Object.entries(t))r=r.replace(`:${n}`,encodeURIComponent(o));return r}addRoute(e){this.routes.push(e),this.routes.sort((t,a)=>{if(!t.isDynamic&&a.isDynamic)return-1;if(t.isDynamic&&!a.isDynamic)return 1;return t.pattern.localeCompare(a.pattern)})}getLayout(e){return e.layout??null}}function cr(e,t){let a=[`${t}.stx`,"error.stx"];for(let r of a){let n=u.join(e,r);if(x.existsSync(n))return n}return null}function lr(e,t){return e.map((a)=>{let r=u.relative(t,a.filePath),n=a.isDynamic?" (dynamic)":"";return`${a.pattern} \u2192 ${r}${n}`})}var f={},k="";function Ac(e){k=e.replace(/\/$/,"")}function Pc(e,t,a={}){f[e]={path:t,name:e,params:a}}function Ic(e){for(let[t,a]of Object.entries(e))if(typeof a==="string")f[t]={path:a,name:t};else f[t]={...a,name:t}}function bn(e,t={},a=!1){let r=f[e];if(!r)return console.warn(`Route [${e}] not defined.`),"#undefined-route";let n={...r.params,...t},o=r.path;o=o.replace(/:(\w+)/g,(c,s)=>{let l=n[s];if(l===void 0)return console.warn(`Missing parameter [${s}] for route [${e}].`),`:${s}`;return delete n[s],encodeURIComponent(String(l))});let i=Object.entries(n);if(i.length>0){let c=i.map(([s,l])=>`${encodeURIComponent(s)}=${encodeURIComponent(String(l))}`).join("&");o+=(o.includes("?")?"&":"?")+c}return a&&k?`${k}${o}`:o}function Dc(){for(let e of Object.keys(f))delete f[e];k=""}import B from"fs";import U from"path";function Oc(e,t={}){return{type:"redirect",path:e,options:{replace:t.replace??!1,external:t.external??!1,redirectCode:t.redirectCode??302}}}function Mc(e){return{type:"abort",error:typeof e==="string"?{statusCode:500,message:e}:e}}function Nc(e,t={}){return{handler:e,mode:t.mode??"universal"}}function O(e){let t={};if(!e)return t;let a=e.split(";");for(let r of a){let[n,...o]=r.split("=");if(n){let i=n.trim(),c=o.join("=").trim();if(i)t[i]=decodeURIComponent(c)}}return t}function S(e,t,a={}){let r=`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(a.expires){let n=typeof a.expires==="number"?new Date(Date.now()+a.expires*1000):a.expires;r+=`; Expires=${n.toUTCString()}`}if(a.path)r+=`; Path=${a.path}`;if(a.domain)r+=`; Domain=${a.domain}`;if(a.secure)r+="; Secure";if(a.httpOnly)r+="; HttpOnly";if(a.sameSite)r+=`; SameSite=${a.sameSite}`;return r}function Pi(e,t){let a=e.headers.get("cookie")||"",r=O(a);return{get(n){return r[n]},set(n,o,i={}){r[n]=o,t.append("Set-Cookie",S(n,o,i))},delete(n){delete r[n],t.append("Set-Cookie",S(n,"",{expires:new Date(0),path:"/"}))},getAll(){return{...r}}}}function Ii(){return{get(e){if(typeof document>"u")return;return O(document.cookie)[e]},set(e,t,a={}){if(typeof document>"u")return;document.cookie=S(e,t,a)},delete(e){if(typeof document>"u")return;document.cookie=S(e,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return O(document.cookie)}}}function Di(){let e=typeof window<"u"&&typeof window.localStorage<"u";return{get(t){if(!e)return null;try{return window.localStorage.getItem(t)}catch{return null}},set(t,a){if(!e)return;try{window.localStorage.setItem(t,a)}catch{}},remove(t){if(!e)return;try{window.localStorage.removeItem(t)}catch{}},isAvailable(){return e}}}var v=new Map;function Ls(e,t){v.set(e,t)}function Oi(e){return v.get(e)}function Lc(e){return v.has(e)}function Qe(){v.clear()}function et(){return Array.from(v.keys())}async function tt(e,t="middleware"){let a=U.resolve(e,t);if(!B.existsSync(a))return;let r=B.readdirSync(a);for(let n of r){if(!n.endsWith(".ts")&&!n.endsWith(".js"))continue;if(n.includes(".test.")||n.includes(".spec."))continue;let o=n.replace(/\.(ts|js)$/,""),i=U.join(a,n);try{let s=(await import(i)).default;if(s&&typeof s.handler==="function")Ls(o,s);else if(typeof s==="function")Ls(o,{handler:s,mode:"universal"})}catch(c){console.warn(`Failed to load middleware '${o}' from ${i}:`,c)}}}function W(e){let t={};if(!e)return t;let a=new URLSearchParams(e);for(let[r,n]of a)t[r]=n;return t}function nt(e,t,a,r=""){return{path:e,params:t,query:W(r),fullPath:r?`${e}?${r}`:e,meta:a}}function rt(e,t,a,r){let n=r?.isServer??typeof window>"u",o=!n,i=new Headers;return{to:e,from:t,isClient:o,isServer:n,cookies:n&&a?Pi(a,i):Ii(),storage:Di(),state:{},request:a,responseHeaders:i}}async function st(e,t){let a=Array.isArray(e)?e:[e],r=t.isServer;for(let n of a){let o=Oi(n);if(!o)return console.error(`Route middleware '${n}' is not registered \u2014 failing the guard closed.`),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:`Route middleware '${n}' is not registered`}},state:t.state,responseHeaders:t.responseHeaders};if(o.mode==="server"&&!r)continue;try{let i=await o.handler(t);if(i){if(i.type==="redirect")return{passed:!1,redirect:i,state:t.state,responseHeaders:t.responseHeaders};if(i.type==="abort")return{passed:!1,abort:i,state:t.state,responseHeaders:t.responseHeaders}}}catch(i){return console.error(`Error in middleware '${n}':`,i),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:i instanceof Error?i.message:"Middleware error"}},state:t.state,responseHeaders:t.responseHeaders}}}return{passed:!0,state:t.state,responseHeaders:t.responseHeaders}}function ur(e){let a=e.replace(/\\/g,"/").split("/").filter(Boolean),r=a.lastIndexOf("layouts"),n=r>=0?a[r+1]:a.at(-1);if(!n)return"app";return n.replace(/\.stx$/i,"")||"app"}function Se(e){let t=e.match(/<meta\b[^>]*name=["']stx-layout["'][^>]*content=["']([^"']+)["'][^>]*>/i),a=e.match(/<meta\b[^>]*name=["']stx-layout-group["'][^>]*content=["']([^"']+)["'][^>]*>/i),r=e.match(/<!--\s*stx-layout:\s*([^ ]+)\s*-->/i),n=t?.[1]||r?.[1]||"";return{layout:n,group:a?.[1]||ur(n)}}var A,T;function V(e){let t=[],a="log(",r=0;while(r<e.length){let n=e.indexOf("log(",r);if(n===-1){t.push(e.slice(r));break}let o=n>0?e[n-1]:" ",i=/\bfunction\s+$/.test(e.slice(Math.max(0,n-16),n));if(/[\w$.]/.test(o)||i){t.push(e.slice(r,n+4)),r=n+4;continue}t.push(e.slice(r,n));let c=1,s=n+4;while(s<e.length&&c>0){let l=e[s];if(l==='"'||l==="'"||l==="`"){let d=l;s++;while(s<e.length&&e[s]!==d){if(e[s]==="\\")s++;s++}s++;continue}if(l==="(")c++;else if(l===")")c--;s++}t.push("0"),r=s}return t.join("")}function q(e,t=!1){try{return new Bun.Transpiler(t?{loader:"js",minify:{whitespace:!0,identifiers:!0}}:{loader:"js",minifyWhitespace:!0}).transformSync(e).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return e}}function X(){return`
|
|
2
|
+
import x from"fs";import u from"path";import p from"fs";import w from"path";var y=["components","layouts","partials","emails"];function P(e){return e.split(/[\\/]/).filter(Boolean).slice(0,-1).some((a)=>y.includes(a))}function b(e){return P(e.replace(/^\//,""))}function Bs(e,t){let a=e.filter((i)=>!b(i.pattern)),r=["// Auto-generated by STX - do not edit"];if(a.length===0)r.push("// No page routes found \u2014 route paths stay typed as string.","export {}","");else{r.push("declare module '@stacksjs/stx' {"," interface KnownRoutes {");for(let i of a){let c=[];for(let l of i.params){let d=i.pattern.includes(`:${l}?`)?"?":"";c.push(`${l}${d}: string`)}let s=c.join("; ");r.push(` '${i.pattern}': { ${s} }`)}r.push(" }","}","","export {}","")}let n=r.join(`
|
|
3
|
+
`),o=w.join(t,"route-types.d.ts");try{if(p.existsSync(o)&&p.readFileSync(o,"utf8")===n)return;p.mkdirSync(t,{recursive:!0}),p.writeFileSync(o,n)}catch{}}function Fs(e,t,a){let r=process.cwd(),n=w.relative(r,a),o=e.filter((c)=>!b(c.pattern)),i=["// Auto-generated by stx \u2014 do not edit",`// Source: ${n||"pages"}/`,"","export const routes = ["];for(let c of o){let s=w.relative(r,c.filePath).replace(/\\/g,"/"),l=JSON.stringify(c.params),d=c.layout?`, layout: '${w.relative(r,c.layout).replace(/\\/g,"/")}'`:"";i.push(` { pattern: '${c.pattern}', filePath: '${s}', isDynamic: ${c.isDynamic}, params: ${l}${d} },`)}i.push("] as const",""),i.push("export type RouteName = typeof routes[number]['pattern']",""),p.mkdirSync(t,{recursive:!0}),p.writeFileSync(w.join(t,"routes.ts"),i.join(`
|
|
4
|
+
`))}import D from"path";var N=Object.freeze(["ico","png","jpg","jpeg","gif","webp","avif","svg","bmp","tif","tiff","heic","css","js","mjs","cjs","map","wasm","webmanifest","json","xml","txt","rss","atom","woff","woff2","ttf","otf","eot","mp3","mp4","m4a","m4v","mov","webm","ogg","ogv","oga","wav","flac","avi","mkv","pdf","csv","doc","docx","xls","xlsx","ppt","pptx","rtf","odt","zip","gz","tgz","tar","rar","7z","bz2","xz","php","phtml","asp","aspx","jsp","cgi","env","ini","yml","yaml","toml","sql","bak","old","swp","log","conf","cfg","exe","dmg","pkg","apk","ipa","msi","iso","bin","dll"]),I=N.flatMap((e)=>e===e.toUpperCase()?[e]:[e,e.toUpperCase()]).join("|"),j=new RegExp(`\\.(?:${I})$`),E=`(?![^/]*\\.(?:${I})$)`;function Qe(e){let t=e,a=t.search(/[?#]/);if(a!==-1)t=t.slice(0,a);let r=t.slice(t.lastIndexOf("/")+1);return r.length>0&&j.test(r)}function R(e,t){let r=D.relative(t,e).replace(/\.(stx|md)$/,"");if(r=r.split(D.sep).join("/"),r==="index")return"/";if(r.endsWith("/index"))r=r.slice(0,-6);return r=r.replace(/\[\[([^\]]+)\]\]/g,":$1?"),r=r.replace(/\[([^\]]+)\]/g,":$1"),r=r.replace(/:\.\.\.([^/]+)/g,":$1*"),`/${r}`}function G(e,t={}){let a=t.page?E:"",r=[],n="",o=0;while(o<e.length){let i=e.slice(o),c=/^\/:([^/?*]+)\?/.exec(i);if(c){r.push(c[1]);let d=o+c[0].length===e.length;n+=`(?:/${d?a:""}([^/]+))?`,o+=c[0].length;continue}let s=/^:([^/?*]+)\*/.exec(i);if(s){r.push(s[1]),n+="(.+)",o+=s[0].length;continue}let l=/^:([^/?*]+)/.exec(i);if(l){r.push(l[1]);let d=o+l[0].length===e.length;n+=`${d?a:""}([^/]+)`,o+=l[0].length;continue}n+=e[o].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),o+=1}return{regex:new RegExp(`^${n}$`),params:r}}function xn(e,t){let a=e===""?"/":e;for(let r of t){let n=a.match(r.regex);if(n){let o={};return r.params.forEach((i,c)=>{o[i]=n[c+1]}),{route:r,params:o}}}return null}function lr(e,t={}){let a=e.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return G(a,t)}import K from"fs";import L from"path";function _(e,t){let a=[],r=L.dirname(e);while(r.startsWith(t)||r===t){let n=L.join(r,"_layout.stx");if(K.existsSync(n))a.unshift(n);if(r===t)break;r=L.dirname(r)}return a}function F(e,t){let a=[];if(!x.existsSync(e))return a;let r=x.readdirSync(e,{withFileTypes:!0});for(let n of r){let o=u.join(e,n.name);if(n.isDirectory()){if(n.name.startsWith("."))continue;if(y.includes(n.name))continue;a.push(...F(o,t))}else if(n.isFile()){let i=u.extname(n.name);if(t.includes(i)){if(n.name.startsWith("_")&&n.name!=="_layout.stx")continue;if(n.name==="_layout.stx")continue;a.push(o)}}}return a}class Sn{routes;pagesDir;pagesDirs;config;constructor(e,t={}){this.config=t;let a=t.pagesDirs&&t.pagesDirs.length>0?t.pagesDirs:[t.pagesDir||"pages"];this.pagesDirs=a.map((s)=>u.resolve(e,s)),this.pagesDir=this.pagesDirs[0];let r=t.extensions||[".stx"],n=(s)=>{let l=u.resolve(e,s);try{return x.realpathSync(l)}catch{return l}},o=(t.exclude??[]).filter((s)=>typeof s==="string"&&s.trim()!=="").map(n),i=(s)=>{if(o.length===0)return!1;let l=n(s);return o.some((d)=>l===d||l.startsWith(`${d}${u.sep}`))},c=new Set;this.routes=[];for(let s of this.pagesDirs){let l=F(s,r).filter((h)=>!i(h)),d=new Map;for(let h of l){let g=R(h,s),m=t.pagesDirs?g.replace(/:[\w]+/g,":param"):g;if(t.pagesDirs&&d.has(m))throw Error(`Conflicting layer pages for ${g}: ${d.get(m)} and ${h}`);if(d.set(m,h),c.has(m))continue;c.add(m);let{regex:H,params:M}=G(g,{page:!0}),C=t.layouts!==!1?_(h,s):[];this.routes.push({pattern:g,regex:H,params:M,filePath:h,isDynamic:M.length>0,layout:C.length>0?C[C.length-1]:void 0})}}if(this.routes.sort((s,l)=>{if(!s.isDynamic&&l.isDynamic)return-1;if(s.isDynamic&&!l.isDynamic)return 1;let d=s.pattern.split("/").length,h=l.pattern.split("/").length;if(d!==h)return h-d;return s.pattern.localeCompare(l.pattern)}),t.emit!==!1){let s=u.resolve(e,t.stateDir||process.env.STX_DIR?.trim()||".stx");Bs(this.routes,s),Fs(this.routes,s,this.pagesDir)}}match(e){let t=e===""?"/":e;for(let a of this.routes){let r=t.match(a.regex);if(r){let n={};return a.params.forEach((o,i)=>{n[o]=r[i+1]}),{route:a,params:n}}}return null}resolve(e,t){let a=this.routes.find((n)=>n.pattern===e||n.filePath.includes(e));if(!a)return"#not-found";let r=a.pattern;if(t)for(let[n,o]of Object.entries(t))r=r.replace(`:${n}`,encodeURIComponent(o));return r}addRoute(e){this.routes.push(e),this.routes.sort((t,a)=>{if(!t.isDynamic&&a.isDynamic)return-1;if(t.isDynamic&&!a.isDynamic)return 1;return t.pattern.localeCompare(a.pattern)})}getLayout(e){return e.layout??null}}function ur(e,t){let a=[`${t}.stx`,"error.stx"];for(let r of a){let n=u.join(e,r);if(x.existsSync(n))return n}return null}function dr(e,t){return e.map((a)=>{let r=u.relative(t,a.filePath),n=a.isDynamic?" (dynamic)":"";return`${a.pattern} \u2192 ${r}${n}`})}var f={},k="";function Bc(e){k=e.replace(/\/$/,"")}function Fc(e,t,a={}){f[e]={path:t,name:e,params:a}}function zc(e){for(let[t,a]of Object.entries(e))if(typeof a==="string")f[t]={path:a,name:t};else f[t]={...a,name:t}}function kn(e,t={},a=!1){let r=f[e];if(!r)return console.warn(`Route [${e}] not defined.`),"#undefined-route";let n={...r.params,...t},o=r.path;o=o.replace(/:(\w+)/g,(c,s)=>{let l=n[s];if(l===void 0)return console.warn(`Missing parameter [${s}] for route [${e}].`),`:${s}`;return delete n[s],encodeURIComponent(String(l))});let i=Object.entries(n);if(i.length>0){let c=i.map(([s,l])=>`${encodeURIComponent(s)}=${encodeURIComponent(String(l))}`).join("&");o+=(o.includes("?")?"&":"?")+c}return a&&k?`${k}${o}`:o}function Hc(){for(let e of Object.keys(f))delete f[e];k=""}import B from"fs";import U from"path";function Vc(e,t={}){return{type:"redirect",path:e,options:{replace:t.replace??!1,external:t.external??!1,redirectCode:t.redirectCode??302}}}function Uc(e){return{type:"abort",error:typeof e==="string"?{statusCode:500,message:e}:e}}function Wc(e,t={}){return{handler:e,mode:t.mode??"universal"}}function O(e){let t={};if(!e)return t;let a=e.split(";");for(let r of a){let[n,...o]=r.split("=");if(n){let i=n.trim(),c=o.join("=").trim();if(i)t[i]=decodeURIComponent(c)}}return t}function S(e,t,a={}){let r=`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(a.expires){let n=typeof a.expires==="number"?new Date(Date.now()+a.expires*1000):a.expires;r+=`; Expires=${n.toUTCString()}`}if(a.path)r+=`; Path=${a.path}`;if(a.domain)r+=`; Domain=${a.domain}`;if(a.secure)r+="; Secure";if(a.httpOnly)r+="; HttpOnly";if(a.sameSite)r+=`; SameSite=${a.sameSite}`;return r}function Fi(e,t){let a=e.headers.get("cookie")||"",r=O(a);return{get(n){return r[n]},set(n,o,i={}){r[n]=o,t.append("Set-Cookie",S(n,o,i))},delete(n){delete r[n],t.append("Set-Cookie",S(n,"",{expires:new Date(0),path:"/"}))},getAll(){return{...r}}}}function zi(){return{get(e){if(typeof document>"u")return;return O(document.cookie)[e]},set(e,t,a={}){if(typeof document>"u")return;document.cookie=S(e,t,a)},delete(e){if(typeof document>"u")return;document.cookie=S(e,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return O(document.cookie)}}}function Hi(){let e=typeof window<"u"&&typeof window.localStorage<"u";return{get(t){if(!e)return null;try{return window.localStorage.getItem(t)}catch{return null}},set(t,a){if(!e)return;try{window.localStorage.setItem(t,a)}catch{}},remove(t){if(!e)return;try{window.localStorage.removeItem(t)}catch{}},isAvailable(){return e}}}var v=new Map;function zs(e,t){v.set(e,t)}function Vi(e){return v.get(e)}function qc(e){return v.has(e)}function et(){v.clear()}function tt(){return Array.from(v.keys())}async function nt(e,t="middleware"){let a=U.resolve(e,t);if(!B.existsSync(a))return;let r=B.readdirSync(a);for(let n of r){if(!n.endsWith(".ts")&&!n.endsWith(".js"))continue;if(n.includes(".test.")||n.includes(".spec."))continue;let o=n.replace(/\.(ts|js)$/,""),i=U.join(a,n);try{let s=(await import(i)).default;if(s&&typeof s.handler==="function")zs(o,s);else if(typeof s==="function")zs(o,{handler:s,mode:"universal"})}catch(c){console.warn(`Failed to load middleware '${o}' from ${i}:`,c)}}}function W(e){let t={};if(!e)return t;let a=new URLSearchParams(e);for(let[r,n]of a)t[r]=n;return t}function rt(e,t,a,r=""){return{path:e,params:t,query:W(r),fullPath:r?`${e}?${r}`:e,meta:a}}function st(e,t,a,r){let n=r?.isServer??typeof window>"u",o=!n,i=new Headers;return{to:e,from:t,isClient:o,isServer:n,cookies:n&&a?Fi(a,i):zi(),storage:Hi(),state:{},request:a,responseHeaders:i}}async function ot(e,t){let a=Array.isArray(e)?e:[e],r=t.isServer;for(let n of a){let o=Vi(n);if(!o)return console.error(`Route middleware '${n}' is not registered \u2014 failing the guard closed.`),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:`Route middleware '${n}' is not registered`}},state:t.state,responseHeaders:t.responseHeaders};if(o.mode==="server"&&!r)continue;try{let i=await o.handler(t);if(i){if(i.type==="redirect")return{passed:!1,redirect:i,state:t.state,responseHeaders:t.responseHeaders};if(i.type==="abort")return{passed:!1,abort:i,state:t.state,responseHeaders:t.responseHeaders}}}catch(i){return console.error(`Error in middleware '${n}':`,i),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:i instanceof Error?i.message:"Middleware error"}},state:t.state,responseHeaders:t.responseHeaders}}}return{passed:!0,state:t.state,responseHeaders:t.responseHeaders}}function pr(e){let a=e.replace(/\\/g,"/").split("/").filter(Boolean),r=a.lastIndexOf("layouts"),n=r>=0?a[r+1]:a.at(-1);if(!n)return"app";return n.replace(/\.stx$/i,"")||"app"}function ke(e){let t=e.match(/<meta\b[^>]*name=["']stx-layout["'][^>]*content=["']([^"']+)["'][^>]*>/i),a=e.match(/<meta\b[^>]*name=["']stx-layout-group["'][^>]*content=["']([^"']+)["'][^>]*>/i),r=e.match(/<!--\s*stx-layout:\s*([^ ]+)\s*-->/i),n=t?.[1]||r?.[1]||"";return{layout:n,group:a?.[1]||pr(n)}}var A,T;function V(e){let t=[],a="log(",r=0;while(r<e.length){let n=e.indexOf("log(",r);if(n===-1){t.push(e.slice(r));break}let o=n>0?e[n-1]:" ",i=/\bfunction\s+$/.test(e.slice(Math.max(0,n-16),n));if(/[\w$.]/.test(o)||i){t.push(e.slice(r,n+4)),r=n+4;continue}t.push(e.slice(r,n));let c=1,s=n+4;while(s<e.length&&c>0){let l=e[s];if(l==='"'||l==="'"||l==="`"){let d=l;s++;while(s<e.length&&e[s]!==d){if(e[s]==="\\")s++;s++}s++;continue}if(l==="(")c++;else if(l===")")c--;s++}t.push("0"),r=s}return t.join("")}function q(e,t=!1){try{return new Bun.Transpiler(t?{loader:"js",minify:{whitespace:!0,identifiers:!0}}:{loader:"js",minifyWhitespace:!0}).transformSync(e).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return e}}function X(){return`
|
|
5
5
|
;(function(){
|
|
6
6
|
'use strict';
|
|
7
7
|
var ROUTER_REV=7;
|
|
@@ -3690,4 +3690,4 @@ else {
|
|
|
3690
3690
|
|
|
3691
3691
|
if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',init);else init();
|
|
3692
3692
|
})();
|
|
3693
|
-
`}function
|
|
3693
|
+
`}function Ce(){if(A)return A;return A=q(V(X()),!0),A}function Kc(){if(T)return T;return T=q(X()),T}export{Bs,Fs,Qe,G,xn,lr,Sn,ur,dr,Bc,Fc,zc,kn,Hc,Vc,Uc,Wc,Fi,zi,Hi,zs,Vi,qc,et,tt,nt,rt,st,ot,pr,ke,Ce,Kc};
|