@stacksjs/stx 0.2.520 → 0.2.522
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-wjnt2rxg.js → chunk-1qr6ht4t.js} +1 -1
- package/dist/{chunk-eyq96y73.js → chunk-22k95k4s.js} +1 -1
- package/dist/{chunk-f8sp9dpx.js → chunk-2zcamy5t.js} +1 -1
- package/dist/{chunk-7wp5r7er.js → chunk-387mj2t0.js} +1 -1
- package/dist/{chunk-2xjf207h.js → chunk-38dn8xcx.js} +1 -1
- package/dist/{chunk-0d9znrk3.js → chunk-3cd3q0se.js} +1 -1
- package/dist/{chunk-5pwdgk0p.js → chunk-3djvdg4t.js} +1 -1
- package/dist/chunk-43s5qsjg.js +2 -0
- package/dist/{chunk-emhqzh0r.js → chunk-5fmc9xyx.js} +1 -1
- package/dist/{chunk-5snae0x9.js → chunk-6b94c1jb.js} +6 -0
- package/dist/{chunk-0rc0zanq.js → chunk-6w10wb1b.js} +2 -2
- package/dist/{chunk-wkrpxnfa.js → chunk-78yge30f.js} +1 -1
- package/dist/chunk-7y4844mr.js +2 -0
- package/dist/{chunk-m49ar4nx.js → chunk-8c0fmchj.js} +1 -1
- package/dist/{chunk-383fpjag.js → chunk-8ga1dn8v.js} +1 -1
- package/dist/{chunk-v5hx02q8.js → chunk-a9n36502.js} +1 -1
- package/dist/{chunk-vgjeneva.js → chunk-ab73xcp2.js} +1 -1
- package/dist/{chunk-krmfkjmr.js → chunk-b1fw8mwk.js} +1 -1
- package/dist/{chunk-mqhc108n.js → chunk-beecfd50.js} +1 -1
- package/dist/{chunk-2r852nze.js → chunk-bppenzpa.js} +1 -1
- package/dist/{chunk-jvygw613.js → chunk-c5h16dew.js} +1 -1
- package/dist/{chunk-10n5sjnc.js → chunk-cncktp6c.js} +1 -1
- package/dist/{chunk-wvgr7d7p.js → chunk-cvvpffkp.js} +1 -1
- package/dist/{chunk-bv9bf961.js → chunk-eadyddmz.js} +1 -1
- package/dist/{chunk-4ka1vqzc.js → chunk-eegbfbm4.js} +18 -18
- package/dist/{chunk-ebx5vyzv.js → chunk-g7xxfcem.js} +1 -1
- package/dist/{chunk-nne0200a.js → chunk-gst25gwa.js} +1 -1
- package/dist/{chunk-dgd0pedw.js → chunk-jgz64wmw.js} +2 -2
- package/dist/{chunk-02fry4k9.js → chunk-k7xhky05.js} +5 -5
- package/dist/{chunk-bhah6ngn.js → chunk-kdkt2z3v.js} +1 -1
- package/dist/chunk-ktxvmgpz.js +2 -0
- package/dist/{chunk-0sc4hfpz.js → chunk-m6pfe21s.js} +1 -1
- package/dist/{chunk-jv96mqj5.js → chunk-mgm471hk.js} +1 -1
- package/dist/{chunk-49mkn02f.js → chunk-mjmea6wr.js} +1 -1
- package/dist/{chunk-v0pm4sb7.js → chunk-nbtd4jk0.js} +1 -1
- package/dist/{chunk-kwkhhb3p.js → chunk-nzpp1gcf.js} +1 -1
- package/dist/{chunk-mdfggh1k.js → chunk-p3znkt4w.js} +2 -2
- package/dist/{chunk-hrxj9rvt.js → chunk-p5tz0r3g.js} +1 -1
- package/dist/{chunk-8yzj60vj.js → chunk-rhwkwny1.js} +1 -1
- package/dist/{chunk-8e062ckg.js → chunk-shjcstfw.js} +1 -1
- package/dist/{chunk-c311fczy.js → chunk-srqhbjcm.js} +1 -1
- package/dist/chunk-syrntd1t.js +45 -0
- package/dist/{chunk-tqyv643n.js → chunk-takvfs50.js} +1 -1
- package/dist/{chunk-xa3sy06t.js → chunk-v6wk57np.js} +1 -1
- package/dist/{chunk-w6chh1c7.js → chunk-vy7927pg.js} +1 -1
- package/dist/{chunk-xyqw5y8g.js → chunk-w2dn0zfs.js} +1 -1
- package/dist/{chunk-3rt07ec9.js → chunk-wfv7v7tf.js} +1 -1
- package/dist/{chunk-28jnw45c.js → chunk-xb1gnzcs.js} +1 -1
- package/dist/{chunk-fgvhepsg.js → chunk-y4vw1727.js} +1 -1
- package/dist/{chunk-8b1g1dyc.js → chunk-zzgqg00a.js} +1 -1
- package/dist/cli.js +8 -8
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/native/compiler/headwind-to-style.js +14 -5
- package/dist/native/runtime/craft-bridge.js +10 -1
- package/dist/pwa.js +1 -1
- package/dist/signals.js +6 -0
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-5r2t5mj7.js +0 -45
- package/dist/chunk-bj98tbj4.js +0 -2
- package/dist/chunk-j39n1p72.js +0 -2
- package/dist/chunk-ssq3veat.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{y}from"./chunk-yxdyh23k.js";import{I,At}from"./chunk-ba88n1j7.js";import{m,h,w,Ve,L,o}from"./chunk-
|
|
2
|
+
import{y}from"./chunk-yxdyh23k.js";import{I,At}from"./chunk-ba88n1j7.js";import{m,h,w,Ve,L,o}from"./chunk-eegbfbm4.js";import{ie,yt,bt}from"./chunk-b1fw8mwk.js";import{Ie,qt,pt,H}from"./chunk-2fb4yx25.js";import _ from"path";var x=new Map,D=new Map,N=m(64),k=new Map,U=["composables","functions"];function O(t){let r=_.basename(t,".ts");return r==="index"||r==="types"||t.endsWith(".d.ts")}async function W(t){if(t)return _.resolve(t);let r=`<default>:${process.cwd()}`,c=k.get(r);if(c!==void 0)return c;let e=await X();if(e!==null)k.set(r,e);return e}async function X(){let t=await o(),r=t.root||process.cwd(),c=t.composablesDir;if(c)return _.resolve(r,c);for(let e of U){let i=_.resolve(r,e);try{let l=new Bun.Glob("**/*.ts");for await(let a of l.scan({cwd:i,absolute:!0}))if(!O(a))return i}catch{}}return null}async function G(t){let r=Array.isArray(t)?t:t?[_.resolve(t)]:(await o())._layerComposableDirs??[await W()].filter((e)=>!!e),c=new Map;for(let e of r){let i=new Bun.Glob("**/*.ts");try{for await(let l of i.scan({cwd:e,absolute:!0})){let a=_.relative(e,l);if(!O(l)&&!c.has(a))c.set(a,l)}}catch{}}return{key:r.join("\x00"),files:[...c.values()].sort()}}async function Lr(t){let{files:r}=await G(t),c=L({loader:"ts",target:"browser",define:w()}),e=[];for(let i of r)try{let l=await Bun.file(i).text(),a=c.scan(l).exports.filter((f)=>f!=="default");if(a.length>0)e.push({file:i,names:a})}catch{}return e}function Z(t,r){return new RegExp(`\\b${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(t)}function q(t,r){let c=new Set(t.match(/\w+/g)),e=new Set;for(let i of r)if(/^\w+$/.test(i)?c.has(i):Z(t,i))e.add(i);return e}function Q(t,r,c){let e=new Map;for(let{file:f,names:d}of t)for(let u of d)if(!e.has(u))e.set(u,f);let i=(f)=>{let d=[];for(let u of q(f,e.keys()))d.push(e.get(u));return d},l=new Set,a=c.flatMap(i);while(a.length>0){let f=[];for(let d of a){if(l.has(d))continue;l.add(d);for(let u of i(r.get(d)??""))if(!l.has(u))f.push(u)}a=f}return l}async function Ml(t,r,c){let{key:e,files:i}=await G(t);if(!e)return null;let l=()=>[...new Set([...i,...i.flatMap((n)=>ie(n))])],a=Ie(l());if(i.length===0)return H(x,e,a,""),null;i.sort();let f=L({loader:"ts",target:"browser",define:w()}),d=pt(D,e,a);if(!d){let n=new Map,s=[];for(let p of i)try{let S=await Bun.file(p).text();n.set(p,S);let g=f.scan(S).exports.filter((z)=>z!=="default");if(g.length>0)s.push({file:p,names:g})}catch{n.set(p,"")}d=H(D,e,a,{codeByFile:n,modules:s})}let{codeByFile:u,modules:J}=d,b;if(r===void 0)b=new Set(i);else{let n=c?[r,...c]:[r],s=h(n.join("\x00"),e,n.length,a),p=N.get(s);if(b=p??Q(J,u,n),!p)N.set(s,b)}if(b.size===0)return null;let E=i.filter((n)=>b.has(n)),v=`${e}\x00${E.join("\x00")}`,F=pt(x,v,a);if(F!==void 0)return F||null;let M=[],C=new Set,j=new Set;for(let n of E)try{let s=u.get(n)??await Bun.file(n).text(),p=_.basename(n,".ts");for(let g of s.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(g[1])j.add(g[1]);let S=[];try{for(let g of f.scan(s).exports)if(g!=="default")C.add(g),S.push(g)}catch{}if(s=I(s),yt(s))s=await bt(s,n,{projectRoot:process.cwd(),externalizeUserModules:!1,expose:S}),s=Ve(s);s=At(s),s=s.replace(/^export\s+(default\s+)?/gm,""),s=f.transformSync(s),M.push(`// Composable: ${p}
|
|
3
3
|
${s.trim()}`)}catch(s){console.warn(`[stx] Failed to load composable ${n}:`,s)}if(M.length===0||C.size===0)return H(x,v,a,""),null;let K=[...C].map((n)=>` try { if (!(${JSON.stringify(n)} in __c)) __c[${JSON.stringify(n)}] = ${n}; } catch (e) {}`).join(`
|
|
4
4
|
`),A=JSON.stringify([...C]),B=M.join(`
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Tt}from"./chunk-gynes6rm.js";import{qo,Qr,Y,je,St,x,Fe,ze,Kn,u}from"./chunk-
|
|
2
|
+
import{Tt}from"./chunk-gynes6rm.js";import{qo,Qr,Y,je,St,x,Fe,ze,Kn,u}from"./chunk-eegbfbm4.js";import{O}from"./chunk-hktvv0hd.js";import v from"path";var D=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function F(t,n,e){let r={fullTag:e,content:n,attrs:t};if(/\bserver\b/.test(t))return{...r,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...r,type:"client"};if(D.test(n))return{...r,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...r,type:"client"};return{...r,type:"server"}}var H=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function io(t){let n=[],e=[],r=[],o=0;while(o<t.length){let s=t.indexOf("<",o);if(s===-1)break;let a=je(t,s);if(a>s){o=a;continue}let i=Y(t,s);if(i>s){let c=t.slice(s,i),f=H.exec(c);if(f){let l=F(f[1],f[2],c);switch(l.type){case"signals":n.push(l);break;case"client":e.push(l);break;case"server":r.push(l);break}}o=i;continue}o=s+(t.startsWith("<!--",s)?4:1)}return{signals:n,client:e,server:r}}var L=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function V(t){let n=[],e=/<!--[\s\S]*?(?:-->|$)|<(script|style|textarea|title|template)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,r;while((r=e.exec(t))!==null)n.push({start:r.index,end:r.index+r[0].length});return n}function P(t,n){return n.some((e)=>t>=e.start&&t<e.end)}function B(t){let n=(t||"").trim();if(!n)return null;if(/[\s>+~,:]/.test(n))return null;let e={},r=n,o=r.match(/^[a-z][\w-]*/i);if(o)e.tag=o[0].toLowerCase(),r=r.slice(o[0].length);while(r.length>0){let s=r.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(s){if(e.attr=s[1],s[3]!==void 0&&s[3]!=="")e.attrValue=s[3];r=r.slice(s[0].length);continue}let a=r.match(/^#([\w-]+)/);if(a){e.id=a[1],r=r.slice(a[0].length);continue}let i=r.match(/^\.([\w-]+)/);if(i){e.className=i[1],r=r.slice(i[0].length);continue}return null}if(!e.tag&&!e.attr&&!e.id&&!e.className)return null;return e}function q(t,n){if(n.attr){if(!(n.attrValue===void 0?new RegExp(`\\b${n.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${n.attr}\\s*=\\s*(["'])\\s*${n.attrValue}\\s*\\1`,"i")).test(t))return!1}if(n.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${n.id}\\s*\\1`,"i").test(t))return!1}if(n.className){let e=t.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!e)return!1;if(!e[2].split(/\s+/).includes(n.className))return!1}return!0}function T(t,n="main"){let e=B(n);if(!e)return null;let r=/<([a-z][\w-]*)\b([^>]*)>/gi,o=V(t),s;while((s=r.exec(t))!==null){if(P(s.index,o))continue;let a=s[1].toLowerCase(),i=s[2]||"";if(i.trimEnd().endsWith("/")||L.has(a))continue;if(e.tag&&e.tag!==a)continue;if(!q(i,e))continue;let c=s[0],f=s.index+c.length,l=new RegExp(`<(/?)${a}\\b([^>]*)>`,"gi");l.lastIndex=f;let g=1,d;while((d=l.exec(t))!==null){if(P(d.index,o))continue;let h=d[1]==="/";if(!h&&(d[2]||"").trimEnd().endsWith("/"))continue;if(g+=h?-1:1,g===0)return{openTag:c,openIndex:s.index,start:f,end:d.index,tagName:a}}return null}return null}var Ae="private, no-store";function ao(t){return t.replace(/&#(\d+);/g,(n,e)=>M(Number(e),n)).replace(/&#x([0-9a-f]+);/gi,(n,e)=>M(Number.parseInt(e,16),n)).replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&")}function M(t,n){if(!Number.isInteger(t)||t<0||t>1114111)return n;try{return String.fromCodePoint(t)}catch{return n}}function ne(t){return t.headers.get("X-STX-Router")==="true"}function z(t,n){if(!t)return n;return t.split(",").some((r)=>r.trim().toLowerCase()===n.toLowerCase())?t:`${t}, ${n}`}function _(t){return{Vary:z(t,"X-STX-Router")}}var G="stx-page-head:",U=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,A={dev:null,prod:null};function W(){let t=O()?"dev":"prod",n=A[t];if(n!==null)return n;try{let e=import.meta.require("./chunk-9c86wgnk.js"),r=t==="dev"&&typeof e.getRouterScriptDev==="function"?e.getRouterScriptDev:e.getRouterScript;A[t]=`<script>${r()}</script>`}catch{A[t]=""}return A[t]}async function co(t,n){if(n===!1)return null;if(n&&typeof n==="string"){let r=v.resolve(t,n);if(await Bun.file(r).exists())return r;return null}let e=v.join(t,"app.stx");if(await Bun.file(e).exists())return e;return null}async function Cr(t,n){try{let e=await Bun.file(t).text(),r=e,o=e.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(o)r=o[1].trim();let s=io(e),a=[...s.client.map((m)=>m.fullTag),...s.signals.map((m)=>m.fullTag)],i=[],c=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,f;while((f=c.exec(e))!==null)i.push(f[0]);let l=r;for(let m of s.server)l=l.replace(m.fullTag,"");for(let m of s.client)l=l.replace(m.fullTag,"");l=l.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let g="<!--__STX_PAGE_SLOT__-->";if(l=l.replace(/<slot\s*\/>/gi,g).replace(/<slot\s*>\s*<\/slot>/gi,g),!l.includes(g))return console.warn(`[stx] Shell ${t} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:d,extractVariables:h,defaultConfig:S,loadStxConfig:b}=await import("./chunk-7y4844mr.js"),R=await b(),p={__filename:t,__dirname:v.dirname(t)};for(let m of a){let C=m.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(C&&!m.includes("client")&&!m.includes('type="module"'))await h(C[1],p,t)}let y=await d(l,p,t,{...S,...R,...n},new Set),w=y.indexOf(g);if(w===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:y.substring(0,w),afterSlot:y.substring(w+g.length),filePath:t,shellScripts:a,shellStyles:i}}catch(e){return console.error(`[stx] Error processing shell ${t}:`,e),null}}function An(t,n,e){let r,o="",s=n.match(U);if(s){n=n.replace(s[0],"");try{let l=Buffer.from(s[1],"base64").toString("utf8"),g=l.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(g)r=g[1].trim();o=l.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let a=e||r||"stx App",i=W(),c="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8">
|
|
@@ -26,5 +26,5 @@ ${i}
|
|
|
26
26
|
`));if(o.length>0)S.push(o.join(`
|
|
27
27
|
`));if(g.length>0)S.push(g.join(`
|
|
28
28
|
`));return S.push(l),S.join(`
|
|
29
|
-
`)}function E(t,n,e={}){let r=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(e.maxAge!==void 0)r+=`; Max-Age=${e.maxAge}`;if(e.expires)r+=`; Expires=${e.expires.toUTCString()}`;if(e.path)r+=`; Path=${e.path}`;if(e.domain)r+=`; Domain=${e.domain}`;if(e.secure)r+="; Secure";if(e.httpOnly)r+="; HttpOnly";if(e.sameSite)r+=`; SameSite=${e.sameSite}`;return r}async function J(t){let n=t.headers.get("content-type")||"",e={},r=(o,s)=>{let a=e[o];if(a===void 0)e[o]=s;else if(Array.isArray(a))a.push(s);else e[o]=[a,s]};if(n.includes("multipart/form-data")){let o=await t.formData();for(let[s,a]of o.entries())if(typeof a==="string")r(s,a);return e}if(n.includes("application/x-www-form-urlencoded")){for(let[o,s]of new URLSearchParams(await t.text()).entries())r(o,s);return e}return e}function Er(t){if(!t)return!1;let n=t.toUpperCase();return n!=="GET"&&n!=="HEAD"}async function I(t,n={}){let e=n.request,r=n.method??e?.method;if(!e||!Er(r))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let o={};try{o=await J(e)}catch{}let s=await t.action({request:e,form:o,params:n.params??{},query:t.query??{},cookies:n.cookies??{}});if(s&&typeof s==="object"){let a=s,i=K(a.cookies),c=a.redirect;if(typeof c==="string"&&c)return{redirect:c,ran:!0,...i.length>0?{cookies:i}:{}};let{cookies:f,redirect:l,...g}=a;if(Object.assign(t,g),i.length>0)return{ran:!0,cookies:i}}return{ran:!0}}function K(t){if(!t||typeof t!=="object"||Array.isArray(t))return[];let n=[];for(let[e,r]of Object.entries(t)){if(!e)continue;if(typeof r==="string"){n.push(E(e,r));continue}if(r&&typeof r==="object"){let o=r;if(typeof o.value!=="string")continue;n.push(E(e,o.value,o))}}return n}function go(t,n=[],e){let r=new Headers({Location:t,"Cache-Control":"no-store"});for(let o of n)r.append("Set-Cookie",o);for(let[o,s]of Object.entries(e??{}))if(o.toLowerCase()!=="location")r.set(o,s);return new Response(null,{status:303,headers:r})}import k from"fs";import j from"path";function uo(t,n,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:e}}function po(t,n){let e=j.join(n,"manifest.json");k.writeFileSync(e,JSON.stringify(t,null,2))}function fo(t){let n=j.join(t,"manifest.json");if(!k.existsSync(n))return null;try{let e=k.readFileSync(n,"utf-8"),r=JSON.parse(e);if(r.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${r.version}`),null;return r}catch(e){return console.warn("[stx] Failed to load manifest:",e),null}}async function Ot(t,n={}){let{html:e,context:r,redirect:o,cookies:s}=await Z(t,n),a=Fe(r),i=ze(r);if(o)return{html:e,redirect:o,cookies:s,status:a,headers:i};let{extractStreamBoundaries:c}=await import("./chunk-
|
|
29
|
+
`)}function E(t,n,e={}){let r=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(e.maxAge!==void 0)r+=`; Max-Age=${e.maxAge}`;if(e.expires)r+=`; Expires=${e.expires.toUTCString()}`;if(e.path)r+=`; Path=${e.path}`;if(e.domain)r+=`; Domain=${e.domain}`;if(e.secure)r+="; Secure";if(e.httpOnly)r+="; HttpOnly";if(e.sameSite)r+=`; SameSite=${e.sameSite}`;return r}async function J(t){let n=t.headers.get("content-type")||"",e={},r=(o,s)=>{let a=e[o];if(a===void 0)e[o]=s;else if(Array.isArray(a))a.push(s);else e[o]=[a,s]};if(n.includes("multipart/form-data")){let o=await t.formData();for(let[s,a]of o.entries())if(typeof a==="string")r(s,a);return e}if(n.includes("application/x-www-form-urlencoded")){for(let[o,s]of new URLSearchParams(await t.text()).entries())r(o,s);return e}return e}function Er(t){if(!t)return!1;let n=t.toUpperCase();return n!=="GET"&&n!=="HEAD"}async function I(t,n={}){let e=n.request,r=n.method??e?.method;if(!e||!Er(r))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let o={};try{o=await J(e)}catch{}let s=await t.action({request:e,form:o,params:n.params??{},query:t.query??{},cookies:n.cookies??{}});if(s&&typeof s==="object"){let a=s,i=K(a.cookies),c=a.redirect;if(typeof c==="string"&&c)return{redirect:c,ran:!0,...i.length>0?{cookies:i}:{}};let{cookies:f,redirect:l,...g}=a;if(Object.assign(t,g),i.length>0)return{ran:!0,cookies:i}}return{ran:!0}}function K(t){if(!t||typeof t!=="object"||Array.isArray(t))return[];let n=[];for(let[e,r]of Object.entries(t)){if(!e)continue;if(typeof r==="string"){n.push(E(e,r));continue}if(r&&typeof r==="object"){let o=r;if(typeof o.value!=="string")continue;n.push(E(e,o.value,o))}}return n}function go(t,n=[],e){let r=new Headers({Location:t,"Cache-Control":"no-store"});for(let o of n)r.append("Set-Cookie",o);for(let[o,s]of Object.entries(e??{}))if(o.toLowerCase()!=="location")r.set(o,s);return new Response(null,{status:303,headers:r})}import k from"fs";import j from"path";function uo(t,n,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:e}}function po(t,n){let e=j.join(n,"manifest.json");k.writeFileSync(e,JSON.stringify(t,null,2))}function fo(t){let n=j.join(t,"manifest.json");if(!k.existsSync(n))return null;try{let e=k.readFileSync(n,"utf-8"),r=JSON.parse(e);if(r.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${r.version}`),null;return r}catch(e){return console.warn("[stx] Failed to load manifest:",e),null}}async function Ot(t,n={}){let{html:e,context:r,redirect:o,cookies:s}=await Z(t,n),a=Fe(r),i=ze(r);if(o)return{html:e,redirect:o,cookies:s,status:a,headers:i};let{extractStreamBoundaries:c}=await import("./chunk-c5h16dew.js"),f=c(r),l=t.streamTemplates;if(l&&Object.keys(l).length>0){let{processDirectives:g}=await import("./chunk-mjmea6wr.js"),{defaultConfig:d}=await import("./chunk-bppenzpa.js"),h=r.streamBoundaries||{},S={...d,autoShell:!1},b=Object.keys(l).map((p)=>({id:p,render:async()=>{let y=typeof h[p]==="function"?await h[p]():void 0;return g(l[p],{...r,$boundary:y},t.sourceFile,S,new Set)}})),R=new Set(b.map((p)=>p.id));f=[...(f||[]).filter((p)=>!R.has(p.id)),...b]}return{html:e,boundaries:f&&f.length>0?f:void 0,cookies:s,status:a,headers:i}}async function Z(t,n){let e={__filename:t.sourceFile,__dirname:t.sourceFile.replace(/[/\\][^/\\]+$/,""),...n};if(!t.hasServerScripts&&!Qr(t.html))return{html:t.html,context:e};for(let a of t.serverScriptContent)try{await u(a,e,t.sourceFile)}catch(i){if(n.__stx_strict_hydration)throw i;console.warn(`[stx] Server script error in ${t.sourceFile}:`,i)}let r=await I(e,{request:n.request,method:n.method,params:n.params??{},cookies:n.cookies??{}}),o=(a)=>{let i=a.replace(/<script\b[^>]*\bdata-stx-server-data\b[^>]*>[\s\S]*?<\/script>/gi,""),c=Kn(e);if(!c)return i;let f=i.indexOf("</head>");return f<0?c+i:i.slice(0,f)+c+i.slice(f)};if(r.redirect)return{html:t.html,context:e,redirect:r.redirect,cookies:r.cookies};if(!Qr(t.html))return{html:o(t.html),context:e,cookies:r.cookies};let s=new Map;for(let[a,i]of Object.entries(t.placeholders))if(i.expression)try{let c=x(i.expression,e);if(i.type==="raw")s.set(a,c!==void 0&&c!==null?String(c):"");else s.set(a,c!==void 0&&c!==null?St(String(c)):"")}catch(c){if(n.__stx_strict_hydration)throw c;s.set(a,"")}return{html:o(qo(t.html,s)),context:e,cookies:r.cookies}}
|
|
30
30
|
export{io,Ae,ao,ne,_,co,Cr,An,me,lo,re,uo,po,fo,Er,go,Ot};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{X,yn,te,P,Rt}from"./chunk-365ktg70.js";import{Qe,xn,lr,dr,ur,et,tt,nt,rt,st,ot,ke}from"./chunk-1aw9qbdf.js";import{U,b,nn,rn,e,kt,sn,f,Be,Ct,Fe,ze,Z,N,ce,K,u,be,pi,bs,n,r,ee,Jn,o,A,le}from"./chunk-
|
|
2
|
+
import{X,yn,te,P,Rt}from"./chunk-365ktg70.js";import{Qe,xn,lr,dr,ur,et,tt,nt,rt,st,ot,ke}from"./chunk-1aw9qbdf.js";import{U,b,nn,rn,e,kt,sn,f,Be,Ct,Fe,ze,Z,N,ce,K,u,be,pi,bs,n,r,ee,Jn,o,A,le}from"./chunk-eegbfbm4.js";import{Ae,ao,ne,_,co,Cr,An,me,lo,re}from"./chunk-jgz64wmw.js";import{It}from"./chunk-v6wk57np.js";import{ae}from"./chunk-2hc5mbw8.js";import{a}from"./chunk-dne8n6h3.js";import{O}from"./chunk-hktvv0hd.js";function Ks(t,s){let i=[],d=`${s}=`;for(let c=0;c<t.length;c++){let l=t[c];if(l.startsWith(d)){let m=l.slice(d.length);if(m)i.push(m);continue}if(l===s){let m=t[c+1];if(m!==void 0&&!m.startsWith("-"))i.push(m),c++}}return i}var{serve:rr}=globalThis.Bun;import Bt from"fs";import pt from"path";function bt(){return`
|
|
3
3
|
/* Theme selector for code blocks */
|
|
4
4
|
.theme-selector {
|
|
5
5
|
margin: 1rem 0;
|
|
@@ -1786,7 +1786,7 @@ else {
|
|
|
1786
1786
|
})()
|
|
1787
1787
|
</script>
|
|
1788
1788
|
`;import _e from"fs";import $e from"path";function On(t){try{return _e.statSync(t).mtimeMs}catch{return null}}function Dt(t,s){let i=Math.max(0,Math.round((s-t)/1000));if(i<60)return`${i}s ago`;if(i<3600)return`${Math.round(i/60)}m ago`;return`${Math.round(i/3600)}h ago`}function Ei(t,s){try{return globalThis.Bun?.resolveSync(t,s)??null}catch{return null}}function Dn(t,s="stx"){let i=$e.resolve(t);for(let d=0;d<10;d++){let c=$e.join(i,"pantry","@stacksjs",s);if(_e.existsSync(c))return c;let l=$e.dirname(i);if(l===i)break;i=l}return null}var Mn=["@stacksjs/stx","bun-plugin-stx"];function Pi(t){try{let s=_e.readFileSync($e.join(t,"package.json"),"utf8"),i=JSON.parse(s)?.version;return typeof i==="string"?i:null}catch{return null}}function Oi(t,s=6){let i=$e.resolve(t),d=[],c=new Set;function l(p,h){if(h>s)return;let g;try{g=_e.realpathSync(p)}catch{return}if(c.has(g))return;c.add(g);for(let w of Mn){let S=$e.join(p,w),C=Pi(S);if(C!==null)d.push({name:w,version:C,dir:$e.relative(i,S)||S,nested:h>0})}let y;try{y=_e.readdirSync(p,{withFileTypes:!0})}catch{return}for(let w of y){if(!w.isDirectory()&&!w.isSymbolicLink())continue;if(w.name===".bin"||w.name===".cache")continue;let S=$e.join(p,w.name);if(w.name.startsWith("@")){let v;try{v=_e.readdirSync(S,{withFileTypes:!0})}catch{continue}for(let x of v){let T=$e.join(S,x.name,"node_modules");if(_e.existsSync(T))l(T,h+1)}continue}let C=$e.join(S,"node_modules");if(_e.existsSync(C))l(C,h+1)}}let m=$e.join(i,"node_modules");if(_e.existsSync(m))l(m,0);return d}function Ai(t){let s=[];for(let i of Mn){let d=t.filter((m)=>m.name===i);if(d.length<=1)continue;let c=[...new Set(d.map((m)=>m.version))],l=d.map((m)=>`${m.version} at ${m.dir}`).join("; ");if(c.length===1){s.push({name:`${i} copies`,status:"info",detail:`${d.length} copies, all ${c[0]} \u2014 duplicated but in agreement`});continue}s.push({name:`${i} copies disagree`,status:"error",detail:`${c.length} versions installed, so which one runs depends on who imports it: ${l}`,fix:`remove the nested copies, or add an overrides entry pinning ${i}, then reinstall \u2014 and verify with: find -L node_modules -path '*/${i}/package.json' -exec grep -H '"version"' {} +`})}return s}async function yr(t={}){let s=t.cwd?$e.resolve(t.cwd):process.cwd(),i=t.resolve??Ei,d=Date.now(),c=[],l=i("@stacksjs/stx",s);c.push(l?{name:"@stacksjs/stx resolves to",status:"ok",detail:l}:{name:"@stacksjs/stx resolves to",status:"info",detail:"not resolvable from here (running inside the stx repo, or not installed)"});let m=i("bun-plugin-stx",s);if(m)c.push({name:"bun-plugin-stx resolves to",status:"ok",detail:m});for(let h of Ai(Oi(s)))c.push(h);let p=Dn(s,"stx");if(!p)c.push({name:"pantry",status:"info",detail:"no pantry/@stacksjs/stx found \u2014 standard install (nothing to rebuild)"});else{let h=$e.join(p,"src/signals.ts"),g=[$e.join(p,"dist/index.js"),$e.join(p,"dist/signals.js")].find((v)=>_e.existsSync(v))||null,y=On(h),w=g?On(g):null;if(y==null)c.push({name:"pantry dist freshness",status:"info",detail:`found pantry at ${p} but no src/signals.ts to compare`});else if(w==null)c.push({name:"pantry dist freshness",status:"error",detail:"pantry has src but no built dist \u2014 the dev server will resolve nothing (or a stale copy elsewhere)",fix:`cd ${p} && bun build.ts`});else if(w<y){let v=Math.round((y-w)/1000);c.push({name:"pantry dist freshness",status:"error",detail:`dist (${Dt(w,d)}) is OLDER than src/signals.ts (${Dt(y,d)}) by ${v}s \u2014 your edit isn't built`,fix:`cd ${p} && bun build.ts`})}else c.push({name:"pantry dist freshness",status:"ok",detail:`dist rebuilt after src (src ${Dt(y,d)}, dist ${Dt(w,d)})`});let S=$e.join(s,"node_modules/@stacksjs/stx"),C=null;try{C=_e.lstatSync(S)}catch{C=null}if(!C)c.push({name:"node_modules \u2192 pantry",status:"info",detail:"node_modules/@stacksjs/stx not present (not installed here)"});else if(C.isSymbolicLink()){let v=null;try{v=_e.realpathSync(S)}catch{}let x=(()=>{try{return _e.realpathSync(p)}catch{return p}})();c.push(v===x?{name:"node_modules \u2192 pantry",status:"ok",detail:"symlinked to pantry"}:{name:"node_modules \u2192 pantry",status:"warn",detail:`symlinked to ${v||"(dangling)"}, not pantry`})}else c.push({name:"node_modules \u2192 pantry",status:"warn",detail:"is a real directory, NOT symlinked to pantry \u2014 edits to pantry src/dist won't be resolved",fix:"rm -rf node_modules/@stacksjs/stx && ln -s ../../pantry/@stacksjs/stx node_modules/@stacksjs/stx"})}if(c.push({name:"dev runtime cache",status:"info",detail:"cleared automatically on source edits by the dev watcher (clearDevCaches, #1745 item C)"}),t.generateRuntime)try{let g=t.generateRuntime().length;c.push(g>1000?{name:"signals runtime",status:"ok",detail:`generated ${g.toLocaleString()} chars`}:{name:"signals runtime",status:"warn",detail:`generated only ${g} chars \u2014 suspiciously short`})}catch(h){c.push({name:"signals runtime",status:"error",detail:`failed to generate: ${h.message}`})}return{checks:c,ok:!c.some((h)=>h.status==="error")}}function br(t){let s={ok:"\u2713",warn:"\u26A0",error:"\u2717",info:"\xB7"},i=["stx runtime resolution:"];for(let d of t.checks)if(i.push(` ${s[d.status]} ${d.name}: ${d.detail}`),d.fix)i.push(` \u2192 ${d.fix}`);return i.push(""),i.push(t.ok?"\u2713 All framework-runtime layers are aligned.":"\u2717 A runtime layer is stale \u2014 see the fixes above."),i.join(`
|
|
1789
|
-
`)}var ft={name:"bun-plugin-stx",async setup(t){let i={...await o(),...t.config?.stx},d=new Set,c=i.webComponents?.enabled?`./${Mt.relative(Mt.dirname(t.config?.outdir||"dist"),i.webComponents.outputDir||"dist/web-components")}`:"/web-components",l=[];if(i.webComponents?.enabled)try{let m=await Jn(i,d);if(l.push(...m),i.debug&&m.length>0)console.log(`Successfully built ${m.length} web components`)}catch(m){console.error("Failed to build web components:",m)}t.onLoad({filter:/\.stx$/},async({path:m})=>{try{let p=new Set;if(i.cache&&i.cachePath){let x=await nn(m,i);if(x){if(i.debug)console.log(`Using cached version of ${m}`);return{contents:x,loader:"html"}}}let h=await te(()=>Bun.file(m).text(),"",(x)=>{throw new yn(`Failed to read stx file: ${m}`,m,void 0,void 0,`File read error: ${x.message}`)});if(!h)throw new yn(`stx file is empty: ${m}`,m);let{scriptContent:g,templateContent:y,allScripts:w}=U.time("script-extraction",()=>{let x=h,T=Z(h);if(T)x=T.content.trim();let k=h.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],H="",M=[];for(let R of k){let L=R.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",B=R.match(/<script\b([^>]*)>/i),G=B?B[1]:"";if(/\bserver\b/i.test(G))H=L;else M.push(R)}let I=x.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:H,templateContent:I,allScripts:M}}),S={__filename:m,__dirname:Mt.dirname(m),__stx:{webComponentsPath:c,builtComponents:l}};await te(()=>u(g,S,m),void 0,(x)=>{let T=new X(`Script execution failed in ${m}: ${x.message}`,m,void 0,void 0,g.substring(0,100));if(P.log(T,{filePath:m,scriptContent:g}),i.debug)throw T});let v=await U.timeAsync("directive-processing",async()=>await n(y,S,m,i,p));if(w.length>0){let{interpolateScriptsInTemplate:x}=await import("./chunk-
|
|
1789
|
+
`)}var ft={name:"bun-plugin-stx",async setup(t){let i={...await o(),...t.config?.stx},d=new Set,c=i.webComponents?.enabled?`./${Mt.relative(Mt.dirname(t.config?.outdir||"dist"),i.webComponents.outputDir||"dist/web-components")}`:"/web-components",l=[];if(i.webComponents?.enabled)try{let m=await Jn(i,d);if(l.push(...m),i.debug&&m.length>0)console.log(`Successfully built ${m.length} web components`)}catch(m){console.error("Failed to build web components:",m)}t.onLoad({filter:/\.stx$/},async({path:m})=>{try{let p=new Set;if(i.cache&&i.cachePath){let x=await nn(m,i);if(x){if(i.debug)console.log(`Using cached version of ${m}`);return{contents:x,loader:"html"}}}let h=await te(()=>Bun.file(m).text(),"",(x)=>{throw new yn(`Failed to read stx file: ${m}`,m,void 0,void 0,`File read error: ${x.message}`)});if(!h)throw new yn(`stx file is empty: ${m}`,m);let{scriptContent:g,templateContent:y,allScripts:w}=U.time("script-extraction",()=>{let x=h,T=Z(h);if(T)x=T.content.trim();let k=h.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],H="",M=[];for(let R of k){let L=R.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",B=R.match(/<script\b([^>]*)>/i),G=B?B[1]:"";if(/\bserver\b/i.test(G))H=L;else M.push(R)}let I=x.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:H,templateContent:I,allScripts:M}}),S={__filename:m,__dirname:Mt.dirname(m),__stx:{webComponentsPath:c,builtComponents:l}};await te(()=>u(g,S,m),void 0,(x)=>{let T=new X(`Script execution failed in ${m}: ${x.message}`,m,void 0,void 0,g.substring(0,100));if(P.log(T,{filePath:m,scriptContent:g}),i.debug)throw T});let v=await U.timeAsync("directive-processing",async()=>await n(y,S,m,i,p));if(w.length>0){let{interpolateScriptsInTemplate:x}=await import("./chunk-ab73xcp2.js"),T=x(w.join(`
|
|
1790
1790
|
`),S),k=v.search(/<\/body>/i);if(k!==-1)v=v.slice(0,k)+T+`
|
|
1791
1791
|
`+v.slice(k);else v+=`
|
|
1792
1792
|
${T}`}if(v=await K(v),p.forEach((x)=>d.add(x)),i.cache&&i.cachePath){if(await rn(m,v,p,i),i.debug)console.log(`Cached template ${m} with ${p.size} dependencies`)}return{contents:v,loader:"html"}}catch(p){let h=p instanceof Error?p:new X(`Plugin processing failed: ${String(p)}`,m);if(P.log(h,{filePath:m,buildConfig:t.config}),Rt.logDetailedError(h,{filePath:m,plugin:"bun-plugin-stx"}),i.debug)console.error("stx Plugin Error:",h);let g=h,y=g.line||null,w=g.context||null;return{contents:i.debug||O()?`<!DOCTYPE html>
|
|
@@ -1849,7 +1849,7 @@ ${T}`}if(v=await K(v),p.forEach((x)=>d.add(x)),i.cache&&i.cachePath){if(await rn
|
|
|
1849
1849
|
<h1>Something went wrong</h1>
|
|
1850
1850
|
<p>An internal error occurred. Please try again later.</p>
|
|
1851
1851
|
</body>
|
|
1852
|
-
</html>`,loader:"html"}}})}};async function Cn(t,s={}){let i=s.port||3000,d=s.watch!==!1,c=s.hotReload!==!1&&d,l=null,m=s.hmrPort||i+1,p=Se.resolve(t);if(!Ne.existsSync(p))return console.error(`${e.red}Error: File not found: ${e.bright}${p}${e.reset}`),!1;if(p.endsWith(".md"))return Ft(p,s);else if(!p.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${p}${e.reset}. Only .stx and .md files are supported.`),!1;let h=a(process.cwd(),"output");Ne.mkdirSync(h,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let g=null,y=async()=>{try{let L={name:"public-assets",setup(Ce){Ce.onResolve({filter:/^\/(images|fonts|assets|public)\//},(ye)=>({path:ye.path,external:!0}))}},B=await Bun.build({entrypoints:[p],outdir:h,plugins:[L,ft],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...s.stxOptions});if(!B.success)return console.error(`${e.red}Build failed:${e.reset}`,B.logs),!1;let G=B.outputs.find((Ce)=>Ce.path.endsWith(".html"));if(!G)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return g=await Bun.file(G.path).text(),!0}catch(L){return console.error(`${e.red}Error building stx file:${e.reset}`,L),!1}};if(!await y())return!1;let S=Se.dirname(p);await kt(S);let C=i;try{if(C=await Ye(i),C!==i)console.log(`${e.yellow}Port ${i} is busy, using port ${C} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let L=s.hmrPort||C+1;l=Pt({wsPort:L,verbose:!1}),m=l.start(L)}let v={},x=null,T;try{let{loadStxConfig:L}=await import("./chunk-
|
|
1852
|
+
</html>`,loader:"html"}}})}};async function Cn(t,s={}){let i=s.port||3000,d=s.watch!==!1,c=s.hotReload!==!1&&d,l=null,m=s.hmrPort||i+1,p=Se.resolve(t);if(!Ne.existsSync(p))return console.error(`${e.red}Error: File not found: ${e.bright}${p}${e.reset}`),!1;if(p.endsWith(".md"))return Ft(p,s);else if(!p.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${p}${e.reset}. Only .stx and .md files are supported.`),!1;let h=a(process.cwd(),"output");Ne.mkdirSync(h,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let g=null,y=async()=>{try{let L={name:"public-assets",setup(Ce){Ce.onResolve({filter:/^\/(images|fonts|assets|public)\//},(ye)=>({path:ye.path,external:!0}))}},B=await Bun.build({entrypoints:[p],outdir:h,plugins:[L,ft],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...s.stxOptions});if(!B.success)return console.error(`${e.red}Build failed:${e.reset}`,B.logs),!1;let G=B.outputs.find((Ce)=>Ce.path.endsWith(".html"));if(!G)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return g=await Bun.file(G.path).text(),!0}catch(L){return console.error(`${e.red}Error building stx file:${e.reset}`,L),!1}};if(!await y())return!1;let S=Se.dirname(p);await kt(S);let C=i;try{if(C=await Ye(i),C!==i)console.log(`${e.yellow}Port ${i} is busy, using port ${C} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let L=s.hmrPort||C+1;l=Pt({wsPort:L,verbose:!1}),m=l.start(L)}let v={},x=null,T;try{let{loadStxConfig:L}=await import("./chunk-7y4844mr.js"),B=await L();if(T=s.stxOptions?.serverApi??B.serverApi,B?.apiRouter)x=B?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(B?.apiRoutes){v=B.apiRoutes;let G=Object.keys(v).length;if(G>0)console.log(`${e.blue}Loaded ${e.bright}${G} API route${G>1?"s":""}${e.reset}`)}if(B?.broadcasting?.enabled)try{let{startBroadcasting:G,loadChannels:oe}=await import("./chunk-3c9t71pc.js"),Ce=B.broadcasting;await G(Ce);let ye=Ce.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${ye}/ws${e.reset}`);let De=Se.join(process.cwd(),"channels.ts");if(Ne.existsSync(De))try{let de=await oe(De);console.log(`${e.blue}Loaded ${e.bright}${de} broadcast channel${de!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(de){console.warn(`${e.yellow}Failed to load channels.ts: ${de.message}${e.reset}`)}}catch(G){console.warn(`${e.yellow}Broadcasting failed to start: ${G.message}${e.reset}`)}}catch{}let{createServerApi:k,isServerApiSource:H}=await import("./chunk-22k95k4s.js"),M=await k(process.cwd(),T);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${C}/${e.reset}...`),c)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${m}${e.reset}`);let I=Fi({port:C,async fetch(L){return It(L,await(async()=>{let B=new URL(L.url);if([h,Se.dirname(p),Se.join(process.cwd(),"public")].some((de)=>H(Se.join(de,B.pathname),process.cwd(),T)))return new Response("Not Found",{status:404});if(x)try{let de=await x.handleRequest(L);if(de.status!==404)return de}catch{}if(v[B.pathname])try{return await v[B.pathname](L)}catch(de){return new Response(JSON.stringify({error:de.message}),{status:500,headers:{"Content-Type":"application/json"}})}let G=await M(L);if(G)return G;if(B.pathname==="/")return(async()=>{let W=await f(g||"");if(c)W=Xe(W,m);if(s.native)if(W.includes("<head>"))W=W.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(W.includes("<html"))W=W.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else W="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+W;if(s.titlebarHidden)if(W.includes("<head>"))W=W.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(W.includes("<html"))W=W.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else W=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${W}`;return W})().then((W)=>new Response(W,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let oe=Se.join(h,B.pathname);if(Ne.existsSync(oe)&&Ne.statSync(oe).isFile()){let de=Bun.file(oe),W=Se.extname(oe).toLowerCase(),j="text/plain";if(W===".ts"||W===".tsx"){let Ue=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),qe=await de.text(),ct=Ue.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":j="text/html";break;case".css":j="text/css";break;case".js":j="text/javascript";break;case".json":j="application/json";break;case".png":j="image/png";break;case".jpg":case".jpeg":j="image/jpeg";break;case".gif":j="image/gif";break;case".woff":j="font/woff";break;case".woff2":j="font/woff2";break;case".ttf":j="font/ttf";break;case".otf":j="font/otf";break;case".eot":j="application/vnd.ms-fontobject";break}return new Response(de,{headers:{"Content-Type":j}})}let Ce=Se.dirname(p),ye=Se.join(Ce,B.pathname);if(Ne.existsSync(ye)&&Ne.statSync(ye).isFile()){let de=Bun.file(ye),W=Se.extname(ye).toLowerCase(),j="text/plain";if(W===".ts"||W===".tsx"){let Ue=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),qe=await de.text(),ct=Ue.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":j="text/html";break;case".css":j="text/css";break;case".js":j="text/javascript";break;case".json":j="application/json";break;case".png":j="image/png";break;case".jpg":case".jpeg":j="image/jpeg";break;case".gif":j="image/gif";break;case".svg":j="image/svg+xml";break;case".ico":j="image/x-icon";break;case".woff":j="font/woff";break;case".woff2":j="font/woff2";break;case".ttf":j="font/ttf";break;case".otf":j="font/otf";break;case".eot":j="application/vnd.ms-fontobject";break}return new Response(de,{headers:{"Content-Type":j}})}let De=Se.join(process.cwd(),"public",B.pathname);if(Ne.existsSync(De)&&Ne.statSync(De).isFile()){let de=Bun.file(De),W=Se.extname(De).toLowerCase(),j="application/octet-stream";if(W===".ts"||W===".tsx"){let Ue=new Bun.Transpiler({loader:W===".tsx"?"tsx":"ts"}),qe=await de.text(),ct=Ue.transformSync(qe);return new Response(ct,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(W){case".html":j="text/html";break;case".css":j="text/css";break;case".js":j="text/javascript";break;case".json":j="application/json";break;case".png":j="image/png";break;case".jpg":case".jpeg":j="image/jpeg";break;case".gif":j="image/gif";break;case".svg":j="image/svg+xml";break;case".ico":j="image/x-icon";break;case".woff":j="font/woff";break;case".woff2":j="font/woff2";break;case".ttf":j="font/ttf";break;case".otf":j="font/otf";break;case".eot":j="application/vnd.ms-fontobject";break}return new Response(de,{headers:{"Content-Type":j}})}return new Response("Not Found",{status:404})})())},error(L){return new Response(`<pre>${L}
|
|
1853
1853
|
${L.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
|
|
1854
1854
|
${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
|
|
1855
1855
|
${e.bright}\u2192 ${e.cyan}http://localhost:${C}/${e.reset}`),console.log(`
|
|
@@ -2025,9 +2025,9 @@ ${v.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),con
|
|
|
2025
2025
|
${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
|
|
2026
2026
|
${e.bright}\u2192 ${e.cyan}http://localhost:${y}/${e.reset}`),console.log(`
|
|
2027
2027
|
${e.yellow}Routes:${e.reset}`);let S=new Set(p.map((v)=>v.routeTemplate)),C=Object.entries(m).filter(([v])=>!S.has(v)).sort(([v],[x])=>v.localeCompare(x)).map(([v,x])=>({route:v==="/"?"/":v,filePath:Oe.relative(process.cwd(),x.filePath),fileType:x.fileType}));for(let v of p){let x=v.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");C.push({route:x,filePath:Oe.relative(process.cwd(),v.filePath),fileType:"stx"})}if(C.sort((v,x)=>v.route.localeCompare(x.route)),C.forEach((v,x)=>{let k=x===C.length-1?"\u2514\u2500 ":"\u251C\u2500 ",H=v.fileType==="md"?`${e.magenta}(markdown)${e.reset}`:"";console.log(` ${e.green}${k}${v.route}${e.reset} \u2192 ${e.bright}${v.filePath}${e.reset} ${H}`)}),console.log(`
|
|
2028
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ze(w.url.toString(),()=>{if(d)it.watch(l,{recursive:!0}).close();w.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=it.watch(l,{recursive:!0},async(x,T)=>{if(!T)return;if(T.endsWith(".stx")||T.endsWith(".js")||T.endsWith(".ts")||T.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${T}${e.yellow} changed, rebuilding...${e.reset}`),be.clear(),ee(),await h()});process.on("SIGINT",()=>{v.close(),w.stop(),process.exit(0)})}return!0}function Wn(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var{serve:Ni}=globalThis.Bun;import ve from"fs";import ie from"path";async function qn(t){try{return Ct(await Bun.file(t).text())}catch{return}}function qt(t){let s=Bun.file(t),i=ie.extname(t).toLowerCase(),d={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},l=[".js",".css",".json"].includes(i)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(s,{headers:{"Content-Type":d[i]||"application/octet-stream",...l}})}async function $n(t=".",s={}){let i=s.port||3000,d=s.watch!==!1,c=s.hotReload!==!1&&d,l=null,m=s.hmrPort||i+1,p=ie.resolve(t),{loadStxConfig:h}=await import("./chunk-bj98tbj4.js"),g=await h(p),{createServerApi:y,isServerApiSource:w}=await import("./chunk-eyq96y73.js"),S=s.stxOptions?.serverApi??g.serverApi,C=await y(p,S),v=g.root&&g.root!=="."?ie.join(p,g.root):p,x=s.pagesDir||g.pagesDir||"pages",T=ie.join(v,x);if(!ve.existsSync(T)&&!g._layerPageDirs?.some((E)=>ve.existsSync(E)))return console.error(`${e.red}Error: No '${x}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${T}${e.reset}`),console.log(`${e.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${e.reset}`),console.log(`${e.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${e.reset}`),console.log(`${e.dim}Starting fresh? Create ${x}/index.stx for the homepage.${e.reset}`),!1;let k=N(v,{pagesDir:x,pagesDirs:g._layerPageDirs?[T,...g._layerPageDirs.slice(1)]:void 0});if(k.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${T}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${k.length}${e.blue} routes${e.reset}`);let H=g?._pluginPageDirs||[],M=[];for(let{dir:E,prefix:F}of H)if(ve.existsSync(E)){let z=N(ie.dirname(E),{pagesDir:ie.basename(E)});for(let V of z){let we=F==="/"?V.pattern:`${F}${V.pattern==="/"?"":V.pattern}`;M.push({route:{...V,pattern:we},prefix:F})}if(z.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${z.length}${e.blue} routes at ${e.cyan}${F}${e.reset}`)}let I=new Map,R=null,L=null;if(s.stxOptions?.shell!==!1){if(L=await co(p,s.stxOptions?.shell),L){if(R=await Cr(L,s.stxOptions||{}),R)console.log(`${e.blue}Using app shell: ${e.bright}${ie.relative(p,L)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}et(),await nt(p);let B=tt();if(B.length>0)console.log(`${e.blue}Loaded ${e.bright}${B.length}${e.blue} middleware: ${e.dim}${B.join(", ")}${e.reset}`);let G={},oe=null;try{let{loadStxConfig:E}=await import("./chunk-bj98tbj4.js"),F=await E(p);if(F?.apiRouter)oe=F?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(F?.apiRoutes){G=F.apiRoutes;let z=Object.keys(G).length;if(z>0)console.log(`${e.blue}Loaded ${e.bright}${z} API route${z>1?"s":""}${e.reset}`)}if(F?.broadcasting?.enabled)try{let{startBroadcasting:z,loadChannels:V}=await import("./chunk-3c9t71pc.js"),we=F.broadcasting;await z(we);let We=we.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${We}/ws${e.reset}`);let Ge=ie.join(process.cwd(),"channels.ts");if(ve.existsSync(Ge))try{let se=await V(Ge);console.log(`${e.blue}Loaded ${e.bright}${se} broadcast channel${se!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(se){console.warn(`${e.yellow}Failed to load channels.ts: ${se.message}${e.reset}`)}}catch(z){console.warn(`${e.yellow}Broadcasting failed to start: ${z.message}${e.reset}`)}}catch{}let Ce=a(p,"output");ve.mkdirSync(Ce,{recursive:!0});let ye=new Map,De=new Set,de=async(E)=>{let F=dr(T,E);if(!F)return null;try{let z=await Bun.build({entrypoints:[F],outdir:Ce,plugins:[ft],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...s.stxOptions});if(!z.success)return null;let V=z.outputs.find((we)=>we.path.endsWith(".html"));if(!V)return null;return await Bun.file(V.path).text()}catch{return null}},W=new Map,j=async(E,F)=>{try{let{processDirectives:z,extractVariables:V,defaultConfig:we,loadStxConfig:We,injectRouterScript:Ge}=await import("./chunk-bj98tbj4.js"),{checkCache:se,cacheTemplate:Q,readFileCached:q,templateCache:J}=await import("./chunk-bhah6ngn.js"),Te=await We(p),Je=(pe)=>{if(!pe)return pe;if(ie.isAbsolute(pe))return pe;return ie.resolve(p,pe)},D={...we,...Te,...s.stxOptions,autoShell:!0};if(s.debugDirectives)D.debug=!0;D.partialsDir=Je(D.partialsDir),D.componentsDir=Je(D.componentsDir),D.layoutsDir=Je(D.layoutsDir),D.storesDir=Je(D.storesDir||"stores"),D.cachePath=Je(D.cachePath)??a(p,"cache");let xe=!F&&!s.profile,ue=D.cache!==!1;if(ue&&xe){let pe=J.get(E.filePath);if(pe)try{if((await ve.promises.stat(E.filePath)).mtime.getTime()<=pe.mtime){let He=!0;for(let Ee of pe.dependencies){if(!ve.existsSync(Ee)){He=!1;break}if((await ve.promises.stat(Ee)).mtime.getTime()>pe.mtime){He=!1;break}}if(He){let Ee=pe.output;if(R)Ee=me(Ee,{preserveHead:!0});let gt=W.get(E.filePath);return{route:E,content:Ee,status:gt?.status??await qn(E.filePath),headers:gt?.headers}}}}catch{}let Ie=await se(E.filePath,D);if(Ie){let je=Ie;if(R)je=me(je,{preserveHead:!0});let He=W.get(E.filePath);return{route:E,content:je,status:He?.status??await qn(E.filePath),headers:He?.headers}}}let he=ue?await q(E.filePath):await Bun.file(E.filePath).text(),Re=Ct(he),{classifyAllScripts:Y}=await import("./chunk-bj98tbj4.js"),Le=Y(he),Ve=Le.server.map((pe)=>pe.content),fe=he;for(let pe of Le.server)fe=fe.replace(pe.fullTag,"");let ge={__filename:E.filePath,__dirname:ie.dirname(E.filePath),__stx_options:D,params:F??{},__stx_runtime_head:{}};for(let pe of Ve)try{await V(pe,ge,E.filePath)}catch(Ie){if(s.stxOptions?.debug)console.error("[stx] variable extraction error",E.filePath,Ie?.message||Ie)}let Ke=new Set,Me;if(s.profile){let pe=performance.now();Me=await z(fe,ge,E.filePath,D,Ke);let Ie=performance.now()-pe,je=ie.relative(p,E.filePath)||E.filePath;console.log(`[stx:profile] ${je} \u2192 ${Ie.toFixed(2)}ms`)}else Me=await z(fe,ge,E.filePath,D,Ke);if(!R)Me=await Ge(Me,{router:D.router});{let{interpolateScriptExpressions:pe}=await import("./chunk-vgjeneva.js");Me=Me.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ie,je,He)=>{if(!/function\s+__stx_setup_/.test(He))return Ie;return`<script${je}>${pe(He,ge)}</script>`})}if(R)Me=me(Me,{preserveHead:!0});if(ue&&xe)await Q(E.filePath,Me,Ke,D);let{extractStreamBoundaries:Kn}=await import("./chunk-jvygw613.js"),lt=Kn(ge),mt=ge.__streamTemplates;if(mt&&typeof mt==="object"&&Object.keys(mt).length>0){let pe=ge.streamBoundaries||{},Ie={...D,autoShell:!1},je=Object.keys(mt).map((Ee)=>({id:Ee,render:async()=>{let gt=typeof pe[Ee]==="function"?await pe[Ee]():void 0;return z(mt[Ee],{...ge,$boundary:gt},E.filePath,Ie,new Set)}})),He=new Set(je.map((Ee)=>Ee.id));lt=[...(lt||[]).filter((Ee)=>!He.has(Ee.id)),...je]}if(lt&<.length>0)De.add(E.pattern);else lt=void 0;let Kt=Fe(ge),Xt=ze(ge);if(xe)W.set(E.filePath,{status:Kt,headers:Xt});return{route:E,content:Me,status:Kt??Re,headers:Xt,boundaries:lt}}catch(z){return console.error(`${e.red}Error building ${e.bright}${E.pattern}${e.reset}:`,z),null}},Ue=8,qe=async()=>{ye.clear(),I.clear();for(let E=0;E<k.length;E+=Ue){let F=k.slice(E,E+Ue),z=await Promise.all(F.map((V)=>j(V)));for(let V of z)if(V)ye.set(V.route.pattern,V)}for(let E=0;E<M.length;E+=Ue){let F=M.slice(E,E+Ue),z=await Promise.all(F.map(({route:V})=>j(V)));for(let V of z)if(V)I.set(V.route.pattern,V)}return ye.size>0};if(console.log(`${e.blue}Building pages...${e.reset}`),!await qe())return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await kt(p);let at=i;try{if(at=await Ye(i),at!==i)console.log(`${e.yellow}Port ${i} is busy, using port ${at} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let E=s.hmrPort||at+1;l=Pt({wsPort:E,verbose:!1}),m=l.start(E)}let _t=(E,F)=>{let V=`<script data-stx-route-params>(function(){var p=${JSON.stringify(F).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(E.includes("</head>"))return E.replace("</head>",`${V}</head>`);if(E.includes("<body"))return E.replace(/<body([^>]*)>/,`<body$1>${V}`);return V+E};console.log(`${e.blue}Starting server...${e.reset}`);let Lt=Ni({port:at,async fetch(E){let F=new URL(E.url),z=g?.publicDir||"public",V=ie.join(p,z,F.pathname),we=ie.join(p,F.pathname),We=ie.join(Ce,F.pathname);if([V,we,We].some((D)=>w(D,p,S)))return new Response("Not Found",{status:404});let[Ge,se,Q]=await Promise.all([ve.promises.stat(V).catch(()=>null),ve.promises.stat(we).catch(()=>null),ve.promises.stat(We).catch(()=>null)]);if(Ge?.isFile()&&!w(V,p,S))return qt(V);if(se?.isFile()&&!w(we,p,S))return qt(we);if(Q?.isFile()&&!w(We,p,S))return qt(We);if(F.pathname.startsWith("/_stx/component/")){let D=decodeURIComponent(F.pathname.slice(16));if(D)try{let xe=`<${D} />`,ue={...buildConfig,autoShell:!1},he=await processDirectives(xe,{},ie.join(p,"components",`${D}.stx`),ue,new Set);return new Response(he,{headers:{"Content-Type":"text/html"}})}catch(xe){return new Response(`<div class="stx-async-error">${xe.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(F.pathname==="/_stx/img"){let{handleImageRequest:D}=await import("./chunk-vc1m5fr9.js"),xe=await D(E,{publicDir:ie.join(p,z),cacheDir:a(p,"cache","img")});if(xe)return xe}if(oe)try{let D=await oe.handleRequest(E);if(D.status!==404)return D}catch{}if(G[F.pathname])try{return await G[F.pathname](E)}catch(D){return new Response(JSON.stringify({error:D.message}),{status:500,headers:{"Content-Type":"application/json"}})}let q=await C(E);if(q)return q;let J=xn(F.pathname,k);if(J){let D=ye.get(J.route.pattern),xe=De.has(J.route.pattern);if(J.route.isDynamic&&Object.keys(J.params).length>0||xe){let ue=await j(J.route,J.params);if(ue)D=ue}if(D){let ue=D.status??200,he=D.headers??{},Re=(J.route.filePath?Be(await Bun.file(J.route.filePath).text().catch(()=>"")):null)??{};if(Re.validate){if(!await Re.validate({params:J.params})){let Ve=await de(404);if(Ve){let fe=Ve;if(fe=await f(fe,p),c)fe=Xe(fe,m);return new Response(fe,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(Re.middleware){let Le=rt(F.pathname,J.params,Re,F.search),Ve=st(Le,null,E,{isServer:!0}),fe=await ot(Re.middleware,Ve);if(fe.redirect){let ge=fe.redirect.path,Ke=fe.redirect.options.redirectCode||302,Me=new Headers(fe.responseHeaders);return Me.set("Location",ge),new Response(null,{status:Ke,headers:Me})}if(fe.abort){let{statusCode:ge,message:Ke}=fe.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${ge}</title></head><body><h1>Error ${ge}</h1><p>${Ke}</p></body></html>`,{status:ge,headers:{"Content-Type":"text/html"}})}if(Object.keys(fe.state).length>0){let ge=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(fe.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;D.content=D.content.replace("</head>",`${ge}</head>`)}}let Y=D.content;if(R&&lo(E)){let Le=ke(Y),Ve=ce(Y),fe=Y.match(/<title[^>]*>([\s\S]*?)<\/title>/i),ge=fe?ao(fe[1].trim()):"";if(Object.keys(J.params).length>0)Y=_t(Y,J.params);Y=await f(Y,p);let Ke=g?.router?.container||"main";return Y=re(Y,Ke),new Response(Y,{status:ue,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Le.layout,"X-STX-Layout-Group":Le.group,"X-STX-Runtime":Ve?"true":"false",...ge&&{"X-STX-Title":encodeURIComponent(ge)},[pi]:bs(),..._(),"Cache-Control":Ae}})}if(R)Y=An(R,Y);if(Object.keys(J.params).length>0)Y=_t(Y,J.params);if(Y=await f(Y,p),c)Y=Xe(Y,m);if(s.native)if(Y.includes("<head>"))Y=Y.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else Y="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+Y;if(s.titlebarHidden)if(Y.includes("<head>"))Y=Y.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else Y=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${Y}`;if(D.boundaries&&D.boundaries.length>0){let{renderStreamingPage:Le,streamToResponse:Ve}=await import("./chunk-jvygw613.js");return Ve(Le(Y,D.boundaries,{timeoutMs:30000}),{status:ue,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(Y,{status:ue,headers:{"Content-Type":"text/html",..._(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...he}})}}if(M.length>0){let D=M.map((ue)=>ue.route),xe=xn(F.pathname,D);if(xe){let ue=I.get(xe.route.pattern);if(ue){let he=ue.content;if(R)he=An(R,he);if(Object.keys(xe.params).length>0)he=_t(he,xe.params);if(he=await f(he,p),c)he=Xe(he,m);return new Response(he,{status:ue.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:ue}of H)if(ue!=="/"&&F.pathname.startsWith(ue)){let he=I.get(ue)||I.get(ue+"/");if(he){let Re=he.content;if(R)Re=An(R,Re);if(Re=await f(Re,p),c)Re=Xe(Re,m);return new Response(Re,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(Qe(F.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let Te=ye.get("/");if(Te){let D=Te.content;if(D=await f(D,p),c)D=Xe(D,m);if(s.native)if(D.includes("<head>"))D=D.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else D="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+D;return new Response(D,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let Je=await de(404);if(Je){let D=Je;if(D=await f(D,p),c)D=Xe(D,m);return new Response(D,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(E){let F=await de(500);if(F)return new Response(F,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${E}
|
|
2028
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ze(w.url.toString(),()=>{if(d)it.watch(l,{recursive:!0}).close();w.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=it.watch(l,{recursive:!0},async(x,T)=>{if(!T)return;if(T.endsWith(".stx")||T.endsWith(".js")||T.endsWith(".ts")||T.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${T}${e.yellow} changed, rebuilding...${e.reset}`),be.clear(),ee(),await h()});process.on("SIGINT",()=>{v.close(),w.stop(),process.exit(0)})}return!0}function Wn(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var{serve:Ni}=globalThis.Bun;import ve from"fs";import ie from"path";async function qn(t){try{return Ct(await Bun.file(t).text())}catch{return}}function qt(t){let s=Bun.file(t),i=ie.extname(t).toLowerCase(),d={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},l=[".js",".css",".json"].includes(i)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(s,{headers:{"Content-Type":d[i]||"application/octet-stream",...l}})}async function $n(t=".",s={}){let i=s.port||3000,d=s.watch!==!1,c=s.hotReload!==!1&&d,l=null,m=s.hmrPort||i+1,p=ie.resolve(t),{loadStxConfig:h}=await import("./chunk-7y4844mr.js"),g=await h(p),{createServerApi:y,isServerApiSource:w}=await import("./chunk-22k95k4s.js"),S=s.stxOptions?.serverApi??g.serverApi,C=await y(p,S),v=g.root&&g.root!=="."?ie.join(p,g.root):p,x=s.pagesDir||g.pagesDir||"pages",T=ie.join(v,x);if(!ve.existsSync(T)&&!g._layerPageDirs?.some((E)=>ve.existsSync(E)))return console.error(`${e.red}Error: No '${x}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${T}${e.reset}`),console.log(`${e.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${e.reset}`),console.log(`${e.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${e.reset}`),console.log(`${e.dim}Starting fresh? Create ${x}/index.stx for the homepage.${e.reset}`),!1;let k=N(v,{pagesDir:x,pagesDirs:g._layerPageDirs?[T,...g._layerPageDirs.slice(1)]:void 0});if(k.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${T}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${k.length}${e.blue} routes${e.reset}`);let H=g?._pluginPageDirs||[],M=[];for(let{dir:E,prefix:F}of H)if(ve.existsSync(E)){let z=N(ie.dirname(E),{pagesDir:ie.basename(E)});for(let V of z){let we=F==="/"?V.pattern:`${F}${V.pattern==="/"?"":V.pattern}`;M.push({route:{...V,pattern:we},prefix:F})}if(z.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${z.length}${e.blue} routes at ${e.cyan}${F}${e.reset}`)}let I=new Map,R=null,L=null;if(s.stxOptions?.shell!==!1){if(L=await co(p,s.stxOptions?.shell),L){if(R=await Cr(L,s.stxOptions||{}),R)console.log(`${e.blue}Using app shell: ${e.bright}${ie.relative(p,L)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}et(),await nt(p);let B=tt();if(B.length>0)console.log(`${e.blue}Loaded ${e.bright}${B.length}${e.blue} middleware: ${e.dim}${B.join(", ")}${e.reset}`);let G={},oe=null;try{let{loadStxConfig:E}=await import("./chunk-7y4844mr.js"),F=await E(p);if(F?.apiRouter)oe=F?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(F?.apiRoutes){G=F.apiRoutes;let z=Object.keys(G).length;if(z>0)console.log(`${e.blue}Loaded ${e.bright}${z} API route${z>1?"s":""}${e.reset}`)}if(F?.broadcasting?.enabled)try{let{startBroadcasting:z,loadChannels:V}=await import("./chunk-3c9t71pc.js"),we=F.broadcasting;await z(we);let We=we.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${We}/ws${e.reset}`);let Ge=ie.join(process.cwd(),"channels.ts");if(ve.existsSync(Ge))try{let se=await V(Ge);console.log(`${e.blue}Loaded ${e.bright}${se} broadcast channel${se!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(se){console.warn(`${e.yellow}Failed to load channels.ts: ${se.message}${e.reset}`)}}catch(z){console.warn(`${e.yellow}Broadcasting failed to start: ${z.message}${e.reset}`)}}catch{}let Ce=a(p,"output");ve.mkdirSync(Ce,{recursive:!0});let ye=new Map,De=new Set,de=async(E)=>{let F=dr(T,E);if(!F)return null;try{let z=await Bun.build({entrypoints:[F],outdir:Ce,plugins:[ft],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...s.stxOptions});if(!z.success)return null;let V=z.outputs.find((we)=>we.path.endsWith(".html"));if(!V)return null;return await Bun.file(V.path).text()}catch{return null}},W=new Map,j=async(E,F)=>{try{let{processDirectives:z,extractVariables:V,defaultConfig:we,loadStxConfig:We,injectRouterScript:Ge}=await import("./chunk-7y4844mr.js"),{checkCache:se,cacheTemplate:Q,readFileCached:q,templateCache:J}=await import("./chunk-kdkt2z3v.js"),Te=await We(p),Je=(pe)=>{if(!pe)return pe;if(ie.isAbsolute(pe))return pe;return ie.resolve(p,pe)},D={...we,...Te,...s.stxOptions,autoShell:!0};if(s.debugDirectives)D.debug=!0;D.partialsDir=Je(D.partialsDir),D.componentsDir=Je(D.componentsDir),D.layoutsDir=Je(D.layoutsDir),D.storesDir=Je(D.storesDir||"stores"),D.cachePath=Je(D.cachePath)??a(p,"cache");let xe=!F&&!s.profile,ue=D.cache!==!1;if(ue&&xe){let pe=J.get(E.filePath);if(pe)try{if((await ve.promises.stat(E.filePath)).mtime.getTime()<=pe.mtime){let He=!0;for(let Ee of pe.dependencies){if(!ve.existsSync(Ee)){He=!1;break}if((await ve.promises.stat(Ee)).mtime.getTime()>pe.mtime){He=!1;break}}if(He){let Ee=pe.output;if(R)Ee=me(Ee,{preserveHead:!0});let gt=W.get(E.filePath);return{route:E,content:Ee,status:gt?.status??await qn(E.filePath),headers:gt?.headers}}}}catch{}let Ie=await se(E.filePath,D);if(Ie){let je=Ie;if(R)je=me(je,{preserveHead:!0});let He=W.get(E.filePath);return{route:E,content:je,status:He?.status??await qn(E.filePath),headers:He?.headers}}}let he=ue?await q(E.filePath):await Bun.file(E.filePath).text(),Re=Ct(he),{classifyAllScripts:Y}=await import("./chunk-7y4844mr.js"),Le=Y(he),Ve=Le.server.map((pe)=>pe.content),fe=he;for(let pe of Le.server)fe=fe.replace(pe.fullTag,"");let ge={__filename:E.filePath,__dirname:ie.dirname(E.filePath),__stx_options:D,params:F??{},__stx_runtime_head:{}};for(let pe of Ve)try{await V(pe,ge,E.filePath)}catch(Ie){if(s.stxOptions?.debug)console.error("[stx] variable extraction error",E.filePath,Ie?.message||Ie)}let Ke=new Set,Me;if(s.profile){let pe=performance.now();Me=await z(fe,ge,E.filePath,D,Ke);let Ie=performance.now()-pe,je=ie.relative(p,E.filePath)||E.filePath;console.log(`[stx:profile] ${je} \u2192 ${Ie.toFixed(2)}ms`)}else Me=await z(fe,ge,E.filePath,D,Ke);if(!R)Me=await Ge(Me,{router:D.router});{let{interpolateScriptExpressions:pe}=await import("./chunk-ab73xcp2.js");Me=Me.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ie,je,He)=>{if(!/function\s+__stx_setup_/.test(He))return Ie;return`<script${je}>${pe(He,ge)}</script>`})}if(R)Me=me(Me,{preserveHead:!0});if(ue&&xe)await Q(E.filePath,Me,Ke,D);let{extractStreamBoundaries:Kn}=await import("./chunk-c5h16dew.js"),lt=Kn(ge),mt=ge.__streamTemplates;if(mt&&typeof mt==="object"&&Object.keys(mt).length>0){let pe=ge.streamBoundaries||{},Ie={...D,autoShell:!1},je=Object.keys(mt).map((Ee)=>({id:Ee,render:async()=>{let gt=typeof pe[Ee]==="function"?await pe[Ee]():void 0;return z(mt[Ee],{...ge,$boundary:gt},E.filePath,Ie,new Set)}})),He=new Set(je.map((Ee)=>Ee.id));lt=[...(lt||[]).filter((Ee)=>!He.has(Ee.id)),...je]}if(lt&<.length>0)De.add(E.pattern);else lt=void 0;let Kt=Fe(ge),Xt=ze(ge);if(xe)W.set(E.filePath,{status:Kt,headers:Xt});return{route:E,content:Me,status:Kt??Re,headers:Xt,boundaries:lt}}catch(z){return console.error(`${e.red}Error building ${e.bright}${E.pattern}${e.reset}:`,z),null}},Ue=8,qe=async()=>{ye.clear(),I.clear();for(let E=0;E<k.length;E+=Ue){let F=k.slice(E,E+Ue),z=await Promise.all(F.map((V)=>j(V)));for(let V of z)if(V)ye.set(V.route.pattern,V)}for(let E=0;E<M.length;E+=Ue){let F=M.slice(E,E+Ue),z=await Promise.all(F.map(({route:V})=>j(V)));for(let V of z)if(V)I.set(V.route.pattern,V)}return ye.size>0};if(console.log(`${e.blue}Building pages...${e.reset}`),!await qe())return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await kt(p);let at=i;try{if(at=await Ye(i),at!==i)console.log(`${e.yellow}Port ${i} is busy, using port ${at} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let E=s.hmrPort||at+1;l=Pt({wsPort:E,verbose:!1}),m=l.start(E)}let _t=(E,F)=>{let V=`<script data-stx-route-params>(function(){var p=${JSON.stringify(F).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(E.includes("</head>"))return E.replace("</head>",`${V}</head>`);if(E.includes("<body"))return E.replace(/<body([^>]*)>/,`<body$1>${V}`);return V+E};console.log(`${e.blue}Starting server...${e.reset}`);let Lt=Ni({port:at,async fetch(E){let F=new URL(E.url),z=g?.publicDir||"public",V=ie.join(p,z,F.pathname),we=ie.join(p,F.pathname),We=ie.join(Ce,F.pathname);if([V,we,We].some((D)=>w(D,p,S)))return new Response("Not Found",{status:404});let[Ge,se,Q]=await Promise.all([ve.promises.stat(V).catch(()=>null),ve.promises.stat(we).catch(()=>null),ve.promises.stat(We).catch(()=>null)]);if(Ge?.isFile()&&!w(V,p,S))return qt(V);if(se?.isFile()&&!w(we,p,S))return qt(we);if(Q?.isFile()&&!w(We,p,S))return qt(We);if(F.pathname.startsWith("/_stx/component/")){let D=decodeURIComponent(F.pathname.slice(16));if(D)try{let xe=`<${D} />`,ue={...buildConfig,autoShell:!1},he=await processDirectives(xe,{},ie.join(p,"components",`${D}.stx`),ue,new Set);return new Response(he,{headers:{"Content-Type":"text/html"}})}catch(xe){return new Response(`<div class="stx-async-error">${xe.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(F.pathname==="/_stx/img"){let{handleImageRequest:D}=await import("./chunk-vc1m5fr9.js"),xe=await D(E,{publicDir:ie.join(p,z),cacheDir:a(p,"cache","img")});if(xe)return xe}if(oe)try{let D=await oe.handleRequest(E);if(D.status!==404)return D}catch{}if(G[F.pathname])try{return await G[F.pathname](E)}catch(D){return new Response(JSON.stringify({error:D.message}),{status:500,headers:{"Content-Type":"application/json"}})}let q=await C(E);if(q)return q;let J=xn(F.pathname,k);if(J){let D=ye.get(J.route.pattern),xe=De.has(J.route.pattern);if(J.route.isDynamic&&Object.keys(J.params).length>0||xe){let ue=await j(J.route,J.params);if(ue)D=ue}if(D){let ue=D.status??200,he=D.headers??{},Re=(J.route.filePath?Be(await Bun.file(J.route.filePath).text().catch(()=>"")):null)??{};if(Re.validate){if(!await Re.validate({params:J.params})){let Ve=await de(404);if(Ve){let fe=Ve;if(fe=await f(fe,p),c)fe=Xe(fe,m);return new Response(fe,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(Re.middleware){let Le=rt(F.pathname,J.params,Re,F.search),Ve=st(Le,null,E,{isServer:!0}),fe=await ot(Re.middleware,Ve);if(fe.redirect){let ge=fe.redirect.path,Ke=fe.redirect.options.redirectCode||302,Me=new Headers(fe.responseHeaders);return Me.set("Location",ge),new Response(null,{status:Ke,headers:Me})}if(fe.abort){let{statusCode:ge,message:Ke}=fe.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${ge}</title></head><body><h1>Error ${ge}</h1><p>${Ke}</p></body></html>`,{status:ge,headers:{"Content-Type":"text/html"}})}if(Object.keys(fe.state).length>0){let ge=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(fe.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;D.content=D.content.replace("</head>",`${ge}</head>`)}}let Y=D.content;if(R&&lo(E)){let Le=ke(Y),Ve=ce(Y),fe=Y.match(/<title[^>]*>([\s\S]*?)<\/title>/i),ge=fe?ao(fe[1].trim()):"";if(Object.keys(J.params).length>0)Y=_t(Y,J.params);Y=await f(Y,p);let Ke=g?.router?.container||"main";return Y=re(Y,Ke),new Response(Y,{status:ue,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Le.layout,"X-STX-Layout-Group":Le.group,"X-STX-Runtime":Ve?"true":"false",...ge&&{"X-STX-Title":encodeURIComponent(ge)},[pi]:bs(),..._(),"Cache-Control":Ae}})}if(R)Y=An(R,Y);if(Object.keys(J.params).length>0)Y=_t(Y,J.params);if(Y=await f(Y,p),c)Y=Xe(Y,m);if(s.native)if(Y.includes("<head>"))Y=Y.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else Y="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+Y;if(s.titlebarHidden)if(Y.includes("<head>"))Y=Y.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else Y=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${Y}`;if(D.boundaries&&D.boundaries.length>0){let{renderStreamingPage:Le,streamToResponse:Ve}=await import("./chunk-c5h16dew.js");return Ve(Le(Y,D.boundaries,{timeoutMs:30000}),{status:ue,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(Y,{status:ue,headers:{"Content-Type":"text/html",..._(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...he}})}}if(M.length>0){let D=M.map((ue)=>ue.route),xe=xn(F.pathname,D);if(xe){let ue=I.get(xe.route.pattern);if(ue){let he=ue.content;if(R)he=An(R,he);if(Object.keys(xe.params).length>0)he=_t(he,xe.params);if(he=await f(he,p),c)he=Xe(he,m);return new Response(he,{status:ue.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:ue}of H)if(ue!=="/"&&F.pathname.startsWith(ue)){let he=I.get(ue)||I.get(ue+"/");if(he){let Re=he.content;if(R)Re=An(R,Re);if(Re=await f(Re,p),c)Re=Xe(Re,m);return new Response(Re,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(Qe(F.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let Te=ye.get("/");if(Te){let D=Te.content;if(D=await f(D,p),c)D=Xe(D,m);if(s.native)if(D.includes("<head>"))D=D.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else D="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+D;return new Response(D,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let Je=await de(404);if(Je){let D=Je;if(D=await f(D,p),c)D=Xe(D,m);return new Response(D,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(E){let F=await de(500);if(F)return new Response(F,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${E}
|
|
2029
2029
|
${E.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
|
|
2030
2030
|
${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
|
|
2031
2031
|
${e.bright}\u2192 ${e.cyan}http://localhost:${at}/${e.reset}`),c)console.log(`${e.dim} HMR: ws://localhost:${m}${e.reset}`);console.log(`
|
|
2032
2032
|
${e.yellow}Routes:${e.reset}`);let jt=[...ur(k,p)];for(let{route:E}of M)jt.push(`${E.pattern}`);if(jt.forEach((E,F)=>{let V=F===jt.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${e.green}${V}${e.reset}${E}`)}),console.log(`
|
|
2033
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ze(Lt.url.toString(),()=>{if(l)ht();Lt.stop()}),s.native){let E,F=ie.join(T,"index.stx");if(ve.existsSync(F)){let V=await Bun.file(F).text();E=St(V)}let z=g?.app?.window??{};await dt(at,{title:g?.app?.head?.title||ie.basename(p)||"stx App",width:z.width,height:z.height,darkMode:z.darkMode,hotReload:z.hotReload,titlebarHidden:z.titlebarHidden??s.titlebarHidden===!0,nativeSidebar:!!E,sidebarConfig:E})}if(d){console.log(`${e.blue}Watching for changes...${e.reset}`);let E=(se)=>se.startsWith("public/")||se.startsWith("public\\"),F=(se)=>{let Q=se.toLowerCase();return Q.endsWith(".stx")||Q.endsWith(".html")||Q.endsWith(".md")},z=new Map,V=()=>{let se=new Set([p,...g._layerGraph?.layers.map((Q)=>Q.root)??[],...g._layerGraph?.configDependencies.map((Q)=>ie.dirname(Q))??[]].filter((Q)=>ve.existsSync(Q)).map((Q)=>ve.realpathSync(Q)));for(let Q of g._layerGraph?.layers??[])for(let q of Object.values(Q.resources)){if(!ve.existsSync(q))continue;let J=ve.realpathSync(q);if(![...se].some((Te)=>J===Te||J.startsWith(`${Te}${ie.sep}`)))se.add(J)}for(let[Q,q]of z)if(!se.has(Q))q.close(),z.delete(Q);for(let Q of se)if(!z.has(Q)&&ve.existsSync(Q))z.set(Q,ve.watch(Q,{recursive:!0},(q,J)=>{We(Q,q,J).catch((Te)=>console.error("[stx] Layer rebuild failed:",Te))}))},we=Promise.resolve(),We=(se,Q,q)=>(we=we.catch(()=>{}).then(()=>Ge(se,Q,q)),we),Ge=async(se,Q,q)=>{if(!q||Et(q))return;if($t(q)){if(g._layerGraph){let J=await h(p);Object.assign(g,J),k.splice(0,k.length,...N(v,{pagesDir:x,pagesDirs:J._layerPageDirs?[T,...J._layerPageDirs.slice(1)]:void 0})),V()}if(E(q)){if(console.log(`${e.cyan}${q} changed${e.reset}`),c&&l)l.reload(q)}else if(F(q)){console.log(`${e.yellow}${q} changed, rebuilding...${e.reset}`),be.clear(),ee();try{let{invalidateFileCache:J,templateCache:Te}=await import("./chunk-
|
|
2033
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ze(Lt.url.toString(),()=>{if(l)ht();Lt.stop()}),s.native){let E,F=ie.join(T,"index.stx");if(ve.existsSync(F)){let V=await Bun.file(F).text();E=St(V)}let z=g?.app?.window??{};await dt(at,{title:g?.app?.head?.title||ie.basename(p)||"stx App",width:z.width,height:z.height,darkMode:z.darkMode,hotReload:z.hotReload,titlebarHidden:z.titlebarHidden??s.titlebarHidden===!0,nativeSidebar:!!E,sidebarConfig:E})}if(d){console.log(`${e.blue}Watching for changes...${e.reset}`);let E=(se)=>se.startsWith("public/")||se.startsWith("public\\"),F=(se)=>{let Q=se.toLowerCase();return Q.endsWith(".stx")||Q.endsWith(".html")||Q.endsWith(".md")},z=new Map,V=()=>{let se=new Set([p,...g._layerGraph?.layers.map((Q)=>Q.root)??[],...g._layerGraph?.configDependencies.map((Q)=>ie.dirname(Q))??[]].filter((Q)=>ve.existsSync(Q)).map((Q)=>ve.realpathSync(Q)));for(let Q of g._layerGraph?.layers??[])for(let q of Object.values(Q.resources)){if(!ve.existsSync(q))continue;let J=ve.realpathSync(q);if(![...se].some((Te)=>J===Te||J.startsWith(`${Te}${ie.sep}`)))se.add(J)}for(let[Q,q]of z)if(!se.has(Q))q.close(),z.delete(Q);for(let Q of se)if(!z.has(Q)&&ve.existsSync(Q))z.set(Q,ve.watch(Q,{recursive:!0},(q,J)=>{We(Q,q,J).catch((Te)=>console.error("[stx] Layer rebuild failed:",Te))}))},we=Promise.resolve(),We=(se,Q,q)=>(we=we.catch(()=>{}).then(()=>Ge(se,Q,q)),we),Ge=async(se,Q,q)=>{if(!q||Et(q))return;if($t(q)){if(g._layerGraph){let J=await h(p);Object.assign(g,J),k.splice(0,k.length,...N(v,{pagesDir:x,pagesDirs:J._layerPageDirs?[T,...J._layerPageDirs.slice(1)]:void 0})),V()}if(E(q)){if(console.log(`${e.cyan}${q} changed${e.reset}`),c&&l)l.reload(q)}else if(F(q)){console.log(`${e.yellow}${q} changed, rebuilding...${e.reset}`),be.clear(),ee();try{let{invalidateFileCache:J,templateCache:Te}=await import("./chunk-kdkt2z3v.js");J(ie.resolve(se,q)),Te.delete(ie.resolve(se,q))}catch{}if(L&&q){if(ie.resolve(se,q)===L||ie.basename(L)===q){let Te=await Cr(L,s.stxOptions||{});if(Te)R=Te}}if(await qe(),await sn(p),c&&l)l.reload(q)}else{console.log(`${e.yellow}${q} changed, rebuilding...${e.reset}`),be.clear(),ee();try{let{invalidateFileCache:J,templateCache:Te}=await import("./chunk-kdkt2z3v.js");J(ie.resolve(se,q)),Te.delete(ie.resolve(se,q))}catch{}if(await qe(),c&&l)l.reload(q)}}else if(Tt(q)){if(console.log(`${e.cyan}CSS ${q} changed${e.reset}`),c&&l)l.updateCss(q)}};V(),process.on("SIGINT",()=>{for(let se of z.values())se.close();if(l)ht();Lt.stop(),process.exit(0)})}return!0}export{Ks,Xs,Gs,Js,hr,Ys,Zs,Qs,Ui,Wi,yr,br,Cn,En,$n};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ne,oc,Md,Nd,Ld,jd,ic,ac,Bd,Fd,Ko,zd,nn,rn,zn}from"./chunk-
|
|
2
|
+
import{Ne,oc,Md,Nd,Ld,jd,ic,ac,Bd,Fd,Ko,zd,nn,rn,zn}from"./chunk-eegbfbm4.js";import"./chunk-fxxrrq9n.js";import"./chunk-c57j92td.js";import"./chunk-kp4mzspk.js";import"./chunk-srqhbjcm.js";import"./chunk-6k4f583z.js";import"./chunk-gbfap7rv.js";import"./chunk-gynes6rm.js";import"./chunk-365ktg70.js";import"./chunk-ba88n1j7.js";import"./chunk-yxdyh23k.js";import"./chunk-1aw9qbdf.js";import"./chunk-e6y6s7q8.js";export{jd as __setSignalsGeneratorsForTest,Ne as cacheEngineFingerprint,rn as cacheTemplate,nn as checkCache,zd as clearDevCaches,ac as getCachedRouterScript,ic as getCachedSignalsRuntime,Bd as getServeClientAsset,Ko as getServeModuleBundle,zn as hashFilePath,Nd as invalidateFileCache,Ld as invalidateFileCacheByDir,Md as readFileCached,Fd as registerServeModuleBundle,oc as templateCache};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Lr,Ml,Nl}from"./chunk-gst25gwa.js";import"./chunk-b1fw8mwk.js";import"./chunk-shjcstfw.js";import"./chunk-2hc5mbw8.js";import"./chunk-eegbfbm4.js";import"./chunk-fxxrrq9n.js";import"./chunk-c57j92td.js";import"./chunk-kp4mzspk.js";import"./chunk-srqhbjcm.js";import"./chunk-6k4f583z.js";import"./chunk-gbfap7rv.js";import"./chunk-gynes6rm.js";import"./chunk-365ktg70.js";import"./chunk-ba88n1j7.js";import"./chunk-yxdyh23k.js";import"./chunk-1aw9qbdf.js";import"./chunk-e6y6s7q8.js";export{Nl as clearComposableCache,Ml as getComposableScript,Lr as listComposableModules};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ts,ns,rs,Wd,Un,qd}from"./chunk-
|
|
2
|
+
import{ts,ns,rs,Wd,Un,qd}from"./chunk-eegbfbm4.js";export{Un as clearImageDeliveryCatalog,Wd as deliveredImage,rs as efficientDeliverySources,ts as getImageDelivery,ns as isTransparentImage,qd as prepareImageDelivery};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-yxdyh23k.js";import"./chunk-ba88n1j7.js";import{m,h,w,L}from"./chunk-
|
|
2
|
+
import"./chunk-yxdyh23k.js";import"./chunk-ba88n1j7.js";import{m,h,w,L}from"./chunk-eegbfbm4.js";import"./chunk-365ktg70.js";import"./chunk-c57j92td.js";import"./chunk-1aw9qbdf.js";import"./chunk-gynes6rm.js";import"./chunk-gbfap7rv.js";import"./chunk-kp4mzspk.js";import"./chunk-6k4f583z.js";import"./chunk-srqhbjcm.js";import"./chunk-e6y6s7q8.js";import"./chunk-fxxrrq9n.js";import f from"path";var S=["applyOfflineUpdate","broadcast","cacheMedia","calculateDistance","canNotify","clearCookies","clearFetchCache","clearOfflineData","clearStorage","copyToClipboard","createShareableFile","defineForm","getBatteryLevel","getCookie","getCurrentPosition","getStorageKeys","getStorageSize","getVoices","hasBattery","hasCameraPermission","hasGeolocationPermission","hasMicrophonePermission","hasNotificationPermission","hasResizeObserver","hexToHsl","hexToRgb","isBroadcastChannelSupported","isCharging","isDeviceMotionSupported","isDeviceOrientationSupported","isEventSourceSupported","isEyeDropperSupported","isInFullscreen","isMutationObserverSupported","isPermissionGranted","isSpeechRecognitionSupported","isSpeechSynthesisSupported","isWakeLockSupported","isWebSocketSupported","notify","onOfflineUpdateReady","parseCookies","pickColor","prefetch","removeCookie","requestMediaPermissions","requestMotionPermission","requestNotificationPermission","requestOrientationPermission","setCookie","share","shareCurrentPage","shareFiles","shareText","shareURL","shareWithFallback","speak","stopSpeaking","toggleFullscreen","useAmbientSound","useAsyncData","useAttributeObserver","useAutoLogout","useAutoWakeLock","useBattery","useBreakpoint","useBreathPacer","useBroadcastChannel","useBroadcastStream","useChannel","useChildListObserver","useClipboard","useColorHistory","useConditionalWakeLock","useCookies","useCopySelection","useDeviceMotion","useDeviceOrientation","useElementSize","useElementTextSelection","useElementVisibility","useEventSource","useEyeDropper","useFavicon","useForm","useFullscreen","useGeolocation","useGeolocationWatch","useHotkey","useIdle","useIdleState","useInfiniteScroll","useIntersectionObserver","useIntersectionObserverMultiple","useIsDesktop","useIsMobile","useIsTablet","useKeyPressed","useKeySequence","useKeyboard","useLastActive","useLazyLoad","useMeta","useMouse","useMouseInElement","useMutationObserver","useNetwork","useNotification","useOnline","useOutbox","useParallax","usePermission","usePermissions","usePointer","usePost","useResizeObserver","useResizeObserverMultiple","useSSE","useScroll","useSelectionPopup","useShare","useSpeechRecognition","useSpeechSynthesis","useStorage","useTextObserver","useTextSelection","useTitle","useVisibility","useWakeLock","useWindowSize"],_=new Set(S);var l=new Map,x=m(64),y=new Set,O=0,R=new Set(S);function W(){l.clear(),x.clear()}function P(o){let n=new Map;for(let r of o){let a=f.basename(r);if(a.endsWith(".d.ts"))continue;let t=a.replace(/\.[jt]s$/,"");if(t==="index")continue;if(t===a)continue;let i=n.get(t);if(i&&!i.endsWith(".js"))continue;n.set(t,r)}return[...n.values()].sort()}function I(o,n){let r=n.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(?:^|[^\\w$.])(?:const|let|var|function|class)\\s+${r}\\b`).test(o)}function M(o){if(!o)return[];let n=h(o,O),r=x.get(n);if(r)return r.slice();let a=o.replace(/<script\b[^>]*\bdata-stx-runtime\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-framework-composables\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-stores\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-composables\b[^>]*>[\s\S]*?<\/script>/gi,""),t=[];for(let i of R){if(y.has(i))continue;let u=i.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");if(new RegExp(`(^|[^\\w$.])${u}\\s*\\(`).test(a))t.push(i)}return t.sort(),x.set(n,t),t.slice()}async function A(o,n){let r=M(o);if(r.length===0)return null;let a=n??f.join(import.meta.dir,"composables"),t=`${a}\x00${r.join(",")}`,i=l.get(t);if(i!==void 0)return i||null;let u=L({loader:"ts",target:"browser",define:w()}),C=new Set(r),d=[],g=new Set,p=[];try{let s=new Bun.Glob("*.{ts,js}");for await(let e of s.scan({cwd:a,absolute:!0}))p.push(e)}catch{return l.set(t,""),null}p=P(p);for(let s of p){let e;try{e=await Bun.file(s).text()}catch{continue}let b=[];try{b=u.scan(e).exports.filter((c)=>c!=="default")}catch{continue}if(!b.some((c)=>C.has(c)))continue;try{e=e.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^import\s+type\s+.*$/gm,""),e=e.replace(/^export\s+\*\s+(?:as\s+\w+\s+)?from\s*['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^export\s+(?:type\s+)?\{[\s\S]*?\}\s*(?:from\s*['"][^'"]+['"]\s*)?;?\s*$/gm,""),e=e.replace(/^export\s+default\s+/gm,""),e=e.replace(/^export\s+(?=(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\b)/gm,""),d.push(`// ${f.basename(s).replace(/\.[jt]s$/,"")}
|
|
3
3
|
${u.transformSync(e).trim()}`);for(let c of b)g.add(c)}catch(c){console.warn(`[stx] framework composable ${f.basename(s)} could not be bundled:`,c)}}let v=r.filter((s)=>!g.has(s)&&!I(o,s));if(v.length>0)console.warn(`[stx] could not bundle ${v.join(", ")} from @stacksjs/stx/composables \u2014 `+"calls to them will throw ReferenceError in the browser. Import them explicitly so the bundler inlines them, or use a runtime equivalent from window.stx.");if(d.length===0)return l.set(t,""),null;let E=[...g].map((s)=>` try { if (!(${JSON.stringify(s)} in __s)) { __s[${JSON.stringify(s)}] = ${s}; if (!(${JSON.stringify(s)} in window)) window[${JSON.stringify(s)}] = ${s}; } } catch (e) {}`).join(`
|
|
4
4
|
`),k=`<script data-stx-framework-composables>
|
|
5
5
|
;(function(){
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{K,ws,vs,xs,n}from"./chunk-
|
|
2
|
+
import{K,ws,vs,xs,n}from"./chunk-eegbfbm4.js";import"./chunk-fxxrrq9n.js";import"./chunk-c57j92td.js";import"./chunk-kp4mzspk.js";import"./chunk-srqhbjcm.js";import"./chunk-6k4f583z.js";import"./chunk-gbfap7rv.js";import"./chunk-gynes6rm.js";import"./chunk-365ktg70.js";import"./chunk-ba88n1j7.js";import"./chunk-yxdyh23k.js";import"./chunk-1aw9qbdf.js";import"./chunk-e6y6s7q8.js";export{K as injectRouterScript,n as processDirectives,ws as processJsonDirective,vs as processOnceDirective,xs as validateClientScript};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Et,bc,wc,vc,xc,Sc,u,kc,ps,Cc,ci,li}from"./chunk-
|
|
2
|
+
import{Et,bc,wc,vc,xc,Sc,u,kc,ps,Cc,ci,li}from"./chunk-eegbfbm4.js";import"./chunk-fxxrrq9n.js";import"./chunk-c57j92td.js";import"./chunk-kp4mzspk.js";import"./chunk-srqhbjcm.js";import"./chunk-6k4f583z.js";import"./chunk-gbfap7rv.js";import"./chunk-gynes6rm.js";import"./chunk-365ktg70.js";import"./chunk-ba88n1j7.js";import"./chunk-yxdyh23k.js";import"./chunk-1aw9qbdf.js";import"./chunk-e6y6s7q8.js";export{Et as STX_ENGINE_BINDING_NAMES,ps as convertToCommonJS,ci as extractScriptFromTemplate,u 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{y}from"./chunk-yxdyh23k.js";import{W,He,ss,os,Yo,Zo,Qo,ei,Wn,is,ti,ni,ri,Et,o}from"./chunk-
|
|
2
|
+
import{y}from"./chunk-yxdyh23k.js";import{W,He,ss,os,Yo,Zo,Qo,ei,Wn,is,ti,ni,ri,Et,o}from"./chunk-eegbfbm4.js";import{Lr}from"./chunk-gst25gwa.js";import{a}from"./chunk-dne8n6h3.js";import{existsSync as M,readFileSync as K}from"fs";import h from"path";var me=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),te=Et.filter((e)=>!me.has(e)).sort(),ne=[...y].sort(),he=[...new Set([...te,...ne])].sort(),be=new Set(te),ye=new Set(ne),xe=new Set(he),ee=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Se(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ie(e,t){let s=[];for(let u of t){if(u.offset===void 0)continue;let i=u.kind==="server"?be:ye;ee.lastIndex=0;for(let l of u.code.matchAll(ee)){let g=l.index+l[0].indexOf("{")+1;for(let m of l[1].matchAll(/[^,]+/g)){let S=m[0];if(/^\s*type\s/.test(S))continue;let x=/^\s*([A-Za-z_$][\w$]*)/.exec(S);if(!x)continue;let r=x[1];if(!xe.has(r)||i.has(r))continue;let f=u.offset+g+m.index+x[0].length-r.length,p=e.slice(0,f),w=p.split(`
|
|
3
3
|
`).length;s.push({line:w,column:f-(p.lastIndexOf(`
|
|
4
4
|
`)+1)+1,offset:f,length:r.length,name:r,kind:u.kind,message:Se(r,u.kind)})}}}return s}import T from"path";var ke="@stacksjs/stx-typescript-plugin";function we(e,t){let s=T.resolve(e);for(;;){let u=T.join(s,"tsconfig.json");if(t(u))return u;let i=T.dirname(s);if(i===s)return;s=i}}function se(e,t,s){let u=we(e,s);if(!u)return;let i=new Set,l=(g)=>{if(i.has(g))return;i.add(g);let m=t(g);if(!m)return;let S=m.compilerOptions?.plugins;if(Array.isArray(S)){let r=S.find((p)=>p?.name===ke),f=Array.isArray(r?.libs)?r.libs.filter((p)=>typeof p==="string"):[];return r?{configPath:g,libs:f.map((p)=>T.resolve(T.dirname(g),p))}:null}let x=typeof m.extends==="string"?[m.extends]:Array.isArray(m.extends)?m.extends:[];for(let r of[...x].reverse()){if(typeof r!=="string"||!r.startsWith("."))continue;let f=T.resolve(T.dirname(g),r.endsWith(".json")?r:`${r}.json`),p=l(f);if(p!==void 0)return p}return};return l(u)??void 0}function ea(e,t="",s=""){let u=e.startLine>1?`
|
|
5
5
|
`.repeat(e.startLine-1):"",i=is(e)+os(ss(e.code)),l=e.kind==="client"||e.kind==="plain"?Qo(t,e.code):"";return Wn(`${u+i}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{jn,Me,Le,he,Jo,Vn,Z,K,an,u,n,R}from"./chunk-
|
|
2
|
+
import{jn,Me,Le,he,Jo,Vn,Z,K,an,u,n,R}from"./chunk-eegbfbm4.js";import{dirname as k,resolve as _}from"path";function h(o){return o.endsWith(".md")||o.endsWith(".markdown")}function C(o){let e=[];g(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let r=[...e];g(/<code\b[^>]*>[\s\S]*?<\/code>/gi,r);function g(s,p){let m;while((m=s.exec(o))!==null){let t=m.index,i=t+m[0].length;if(p?.some((l)=>t>=l.start&&i<=l.end))continue;e.push({start:t,end:i})}}if(e.length===0)return o;e.sort((s,p)=>s.start-p.start);let a="",c=0;for(let s of e){if(s.start<c)continue;a+=o.slice(c,s.start),a+=`@raw${o.slice(s.start,s.end)}@endraw`,c=s.end}return a+=o.slice(c),a}async function b(o,e={}){let{data:r,content:g}=jn(o),c=await(e.renderer??((s)=>Me(s)))(g);return{html:C(c),frontmatter:r??{}}}function v(o){let e=o,r=Z(o);if(r)e=r.content.trim();let g=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,a=[],c=[],s=[],p=(i)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(i),m;while((m=g.exec(o))!==null){let i=m[1],l=m[2],f=m[0],d=i.includes("server");if(p(l))s.push(f);else if(d)c.push(l);else a.push(f)}let t=e;{let i=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,l,f=[];while((l=i.exec(t))!==null){let d=l.index+l[0].length,x=t.indexOf("</script>",d);if(x===-1)continue;f.push({start:l.index,end:x+9}),i.lastIndex=x+9}for(let d=f.length-1;d>=0;d--)t=t.substring(0,f[d].start)+t.substring(f[d].end)}for(let i of a)t=t.replace(i,"");return{templateContent:t,serverScripts:c,clientScripts:a,signalsScripts:s}}function M(o,e){return`<!DOCTYPE html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8">
|
|
@@ -14,5 +14,5 @@ ${c.join(`
|
|
|
14
14
|
`)}`}else{if(r.processClientScripts!==!1&&c.length>0){let i=p.__stx_event_bindings||[],l=Le(p),d=(await Promise.all(c.map(async(w)=>{let y=w.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!y)return w;return await he(y[1],{eventBindings:i,templateContent:t,serverData:l,filePath:e})}))).join(`
|
|
15
15
|
`);if(t.match(/(<\/body>)/i))t=t.replace(/(<\/body>)/i,`${d}
|
|
16
16
|
$1`);else t+=`
|
|
17
|
-
${d}`}t=await K(t)}if(r.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=M(t,r.title)}if(r.injectCSS)try{let{injectCss:i}=await import("./chunk-
|
|
17
|
+
${d}`}t=await K(t)}if(r.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=M(t,r.title)}if(r.injectCSS)try{let{injectCss:i}=await import("./chunk-3djvdg4t.js");t=await i(t)}catch{}return t}
|
|
18
18
|
export{Io};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{xt,gs,di,Ec}from"./chunk-
|
|
2
|
+
import{xt,gs,di,Ec}from"./chunk-eegbfbm4.js";import"./chunk-fxxrrq9n.js";import"./chunk-c57j92td.js";import"./chunk-kp4mzspk.js";import"./chunk-srqhbjcm.js";import"./chunk-6k4f583z.js";import"./chunk-gbfap7rv.js";import"./chunk-gynes6rm.js";import"./chunk-365ktg70.js";import"./chunk-ba88n1j7.js";import"./chunk-yxdyh23k.js";import"./chunk-1aw9qbdf.js";import"./chunk-e6y6s7q8.js";export{Ec as declareBareLoopHead,xt as parseLoopBinding,di as processLoops,gs as reportDeferredLoopWarnings};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{o}from"./chunk-
|
|
2
|
+
import{o}from"./chunk-eegbfbm4.js";import{$r}from"./chunk-2etevws0.js";import p from"path";async function wl(t={}){let d=performance.now(),s=t.root||process.cwd(),e=await o(s),u=t.ssr?.routeRules??e.routeRules??{};if($r(u),!e.ssr&&Object.keys(u).length)throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");if(!e.ssr&&(t.ssr?.serverApi??e.serverApi))throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");let r=e.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${r.toUpperCase()}${e.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let n,l;if(r==="ssg"){let{generateStaticSite:i}=await import("./ssg.js");n=await i({pagesDir:p.join(e.root||".",e.pagesDir||e.build?.pagesDir||"pages"),publicDir:e.publicDir||e.build?.publicDir||"public",outputDir:e.build?.outputDir||"dist",generate404:e.build?.generate404??!0,minify:e.build?.minify??!0,cleanOutput:e.build?.cleanOutput??!0,router:e.router,...t.ssg})}else{let{buildForProduction:i}=await import("./chunk-cvvpffkp.js");l=await i({root:s,outputDir:".output",debug:t.debug,...t.ssr})}let a=Math.round(performance.now()-d);return{mode:r,ssg:n,ssr:l,duration:a}}
|
|
3
3
|
export{wl};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{G}from"./chunk-1aw9qbdf.js";import{de,C}from"./chunk-6k4f583z.js";import{xi}from"./chunk-kp4mzspk.js";import{a}from"./chunk-dne8n6h3.js";import v from"fs";import m from"path";import{pathToFileURL as I}from"url";var P=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],R=new Set;function wt(s,l={}){let o=m.resolve(s,l.dir??"server/api"),i=[],f=new Map;if(!v.existsSync(o))return i;let t=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:o})).sort();for(let e of t){if(e.endsWith(".d.ts"))continue;let u=e.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),n=u.pop(),c=n.lastIndexOf("."),d=c>=0?n.slice(c+1):"get",g=d.toUpperCase();if(!P.includes(g)||d!==d.toLowerCase())throw Error(`Unsupported API method suffix in ${e}; use ${P.map((A)=>A.toLowerCase()).join(", ")}`);if(c>=0)n=n.slice(0,c);if(n!=="index")u.push(n);let r=new Set,h=u.map((A,j)=>{let y=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(A);if(y){if(r.has(y[2])||y[1]&&j!==u.length-1)throw Error(`Invalid API parameter in ${e}`);return r.add(y[2]),`:${y[2]}${y[1]?"*":""}`}if(!/^[\w-]+$/.test(A))throw Error(`Unsupported API path segment ${A} in ${e}`);return A}),w=`/api${h.length?`/${h.join("/")}`:""}`,S=`${g} ${w.replace(/:\w+/g,":param")}`;if(f.has(S))throw Error(`Ambiguous API route ${g} ${w}: ${f.get(S)} and ${e}`);f.set(S,e);let x=m.join(o,e);R.add(m.resolve(x)),R.add(v.realpathSync(x)),i.push({pattern:w,method:g,filePath:x})}return i.sort((e,p)=>{let u=e.pattern.split("/"),n=p.pattern.split("/"),c=(d)=>d?.endsWith("*")?0:d?.startsWith(":")?1:2;for(let d=0;d<Math.max(u.length,n.length);d++){let g=c(n[d])-c(u[d]);if(g)return g}return e.pattern.localeCompare(p.pattern)||e.method.localeCompare(p.method)})}async function Wr(s,l){let o=a(s,"api-types.d.ts"),i=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let t of l){let e=`./${m.relative(m.dirname(o),t.filePath).replace(/\\/g,"/")}`,{params:p}=G(t.pattern);i.push(` ${JSON.stringify(`${t.method} ${t.pattern}`)}: { params: { ${p.map((u)=>`${JSON.stringify(u)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(e)}).default>> }`)}i.push(" }","}","export {}","");let f=i.join(`
|
|
3
3
|
`);if(!await Bun.file(o).exists()||await Bun.file(o).text()!==f)await Bun.write(o,f);return o}async function qr(s,l,o={}){let i=wt(s,o);await Wr(s,i);let f=[];for(let t of i){let e=await Bun.build({entrypoints:[t.filePath],target:"bun",format:"esm",minify:!1,splitting:!1});if(!e.success)throw Error(`API build failed for ${t.filePath}: ${e.logs.join(`
|
|
4
|
-
`)}`);let p=e.outputs.find((c)=>c.kind==="entry-point");if(!p)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await p.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),p),f.push({...t,filePath:n})}return f}function E(s,l){let o=s.map((i)=>({route:i,...G(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,p=(r)=>r.replace(/:\w+/g,":param"),u=t.filter((r)=>p(r.route.pattern)===p(e)),n=i.method,c=u.find((r)=>r.route.method===n)??(n==="HEAD"?u.find((r)=>r.route.method==="GET"):void 0);if(!c){let r=new Set(u.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=c.regex.exec(f),g=Object.create(null);try{c.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(c.route);if(typeof r!=="function")throw Error(`API endpoint ${c.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Kr(s,l){return E(l,async(o)=>(await import(I(m.resolve(s,o.filePath)).href)).default)}async function Td(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=wt(s,o);return await Wr(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=wt(s,o);await Wr(s,t);let{loadStxConfig:e}=await import("./chunk-
|
|
4
|
+
`)}`);let p=e.outputs.find((c)=>c.kind==="entry-point");if(!p)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await p.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),p),f.push({...t,filePath:n})}return f}function E(s,l){let o=s.map((i)=>({route:i,...G(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,p=(r)=>r.replace(/:\w+/g,":param"),u=t.filter((r)=>p(r.route.pattern)===p(e)),n=i.method,c=u.find((r)=>r.route.method===n)??(n==="HEAD"?u.find((r)=>r.route.method==="GET"):void 0);if(!c){let r=new Set(u.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=c.regex.exec(f),g=Object.create(null);try{c.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(c.route);if(typeof r!=="function")throw Error(`API endpoint ${c.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Kr(s,l){return E(l,async(o)=>(await import(I(m.resolve(s,o.filePath)).href)).default)}async function Td(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=wt(s,o);return await Wr(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=wt(s,o);await Wr(s,t);let{loadStxConfig:e}=await import("./chunk-bppenzpa.js"),p=C((await e(s)).runtimeConfig);return await de(p,()=>E(t,async(u)=>{let n=await Bun.build({entrypoints:[u.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
|
|
5
5
|
`));let c=n.outputs.find((d)=>d.kind==="entry-point");if(!c||n.outputs.length!==1)throw Error(`Unsupported API bundle output: ${u.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await c.text()).toString("base64")}`)).default})(f))}catch(t){return console.error("[stx] API discovery failed:",t),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function Xr(s,l,o){if(xi(s))return!0;let i=/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/;if(i.test(m.basename(s)))return!0;try{if(i.test(m.basename(v.realpathSync(s))))return!0}catch{}if(R.has(m.resolve(s)))return!0;if(!o)return!1;let f=m.resolve(l,typeof o==="object"?o.dir??"server/api":"server/api"),t=(p)=>{try{return v.realpathSync(p)}catch{return m.resolve(p)}},e=t(s);return[f,m.resolve(l,"server"),m.resolve(l,".output/server")].some((p)=>{let u=t(p);return e===u||e.startsWith(`${u}${m.sep}`)})}
|
|
6
6
|
export{wt,Wr,qr,Kr,Td,Xr};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{_t,C}from"./chunk-6k4f583z.js";import m from"fs";import e from"path";async function dn(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-
|
|
2
|
+
import{_t,C}from"./chunk-6k4f583z.js";import m from"fs";import e from"path";async function dn(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-bppenzpa.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??{})} }
|