@stacksjs/stx 0.2.604 → 0.2.605
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-a1szmtn1.js → chunk-0jsg0z9j.js} +2 -2
- package/dist/{chunk-8txwa114.js → chunk-1548a62z.js} +1 -1
- package/dist/{chunk-8mffwm1f.js → chunk-214w9gst.js} +1 -1
- package/dist/{chunk-5c153w4j.js → chunk-279b1228.js} +1 -1
- package/dist/chunk-2h99p36p.js +2 -0
- package/dist/{chunk-jjs6nqh1.js → chunk-2rzcy4yg.js} +1 -1
- package/dist/{chunk-et8wjgxw.js → chunk-5ajbkx0a.js} +1 -1
- package/dist/{chunk-zg0pnh4w.js → chunk-6kmqb08x.js} +1 -1
- package/dist/{chunk-jczknjbw.js → chunk-813wwkap.js} +1 -1
- package/dist/{chunk-38mt99p3.js → chunk-9nct3gsy.js} +1 -1
- package/dist/{chunk-bk3yktq8.js → chunk-a2pd13yw.js} +1 -1
- package/dist/{chunk-xcyreehd.js → chunk-afnj003j.js} +1 -1
- package/dist/{chunk-j0z7010x.js → chunk-atqnvmea.js} +18 -18
- package/dist/{chunk-g3qbe5y2.js → chunk-ax5t83f4.js} +1 -1
- package/dist/{chunk-eactb0nz.js → chunk-bc8rzjnh.js} +1 -1
- package/dist/{chunk-3xdfqn0d.js → chunk-btbdp4fg.js} +2 -2
- package/dist/{chunk-r4adpej7.js → chunk-bvczk7xr.js} +1 -1
- package/dist/{chunk-6vncjspv.js → chunk-c88e6w5r.js} +1 -1
- package/dist/chunk-cg3vfr6b.js +2 -0
- package/dist/{chunk-xwatzxk5.js → chunk-dnnc0m92.js} +1 -1
- package/dist/chunk-ej1erz2c.js +2 -0
- package/dist/{chunk-t9914jjh.js → chunk-erb1bc49.js} +1 -1
- package/dist/{chunk-79zfhk62.js → chunk-f49nnf8v.js} +1 -1
- package/dist/{chunk-ftr0fvw7.js → chunk-fkh9zshs.js} +2 -2
- package/dist/{chunk-bn7fzfc2.js → chunk-gbe53zv3.js} +1 -1
- package/dist/{chunk-bx3qewwk.js → chunk-gqm3w433.js} +1 -1
- package/dist/{chunk-ydt4sd6m.js → chunk-h5cgm4hy.js} +1 -1
- package/dist/{chunk-vmsw9sdw.js → chunk-h8a8y1wh.js} +1 -1
- package/dist/{chunk-djqmzzn6.js → chunk-hjh1a3ga.js} +1 -1
- package/dist/{chunk-er5wxv0f.js → chunk-hrv206vt.js} +1 -1
- package/dist/{chunk-rd7w0cx4.js → chunk-jg8w43n0.js} +5 -5
- package/dist/chunk-k229zdjh.js +2 -0
- package/dist/chunk-knngjd2r.js +2 -0
- package/dist/{chunk-de3gknmn.js → chunk-kty4k2jq.js} +1 -1
- package/dist/{chunk-bpz3yv92.js → chunk-makn68zy.js} +1 -1
- package/dist/chunk-mnwf9yde.js +2 -0
- package/dist/{chunk-rd9yv1n3.js → chunk-n633zv27.js} +1 -1
- package/dist/{chunk-jb6zejnt.js → chunk-navkh35g.js} +1 -1
- package/dist/{chunk-00vp75pj.js → chunk-nzpthbe1.js} +1 -1
- package/dist/{chunk-08p1kxsj.js → chunk-pyj4ashw.js} +1 -1
- package/dist/{chunk-wf2wnmjg.js → chunk-qhxf7pxh.js} +1 -1
- package/dist/{chunk-7ejmya3v.js → chunk-qjmqp5z7.js} +1 -1
- package/dist/{chunk-hvqjs9ps.js → chunk-rc7wmbnz.js} +1 -1
- package/dist/{chunk-788d9msn.js → chunk-sqq6kpve.js} +1 -1
- package/dist/{chunk-xarb7knj.js → chunk-tcddr6dx.js} +1 -1
- package/dist/{chunk-nfht2ryp.js → chunk-tt1p6zt8.js} +4 -1
- package/dist/{chunk-kn2exbq7.js → chunk-v3dnfv5g.js} +2 -2
- package/dist/{chunk-xmz2h8cb.js → chunk-v4gepwh9.js} +1 -1
- package/dist/{chunk-jmczvhpy.js → chunk-x7epxhsz.js} +2 -2
- package/dist/{chunk-afmzxwj1.js → chunk-zfrpjaxw.js} +1 -1
- package/dist/cli.js +7 -7
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-0rekvsy4.js +0 -2
- package/dist/chunk-1sbj8yqe.js +0 -2
- package/dist/chunk-esac5ych.js +0 -2
- package/dist/chunk-h5g8k974.js +0 -2
- package/dist/chunk-hvd9qc98.js +0 -2
- package/dist/chunk-xe7jw7nn.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ml}from"./chunk-
|
|
2
|
+
import{Ml}from"./chunk-h5cgm4hy.js";import"./chunk-atqnvmea.js";import"./chunk-t19th11m.js";import"./chunk-v8ze2q95.js";import"./chunk-k71e38fk.js";import"./chunk-813wwkap.js";import"./chunk-48s1nprc.js";import"./chunk-qf39z0hg.js";import"./chunk-gh181dnr.js";import"./chunk-38mt83wa.js";import"./chunk-jtq8e3b0.js";import"./chunk-b3c1gggs.js";import"./chunk-tt1p6zt8.js";import"./chunk-82bttwqm.js";export{Ml as buildApp};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{K,ds,ps,hc,At,oi,gs,ii,Gu,we,mn,xe}from"./chunk-
|
|
2
|
+
import{K,ds,ps,hc,At,oi,gs,ii,Gu,we,mn,xe}from"./chunk-atqnvmea.js";import"./chunk-t19th11m.js";import"./chunk-v8ze2q95.js";import{Li,s}from"./chunk-6eg9a3mt.js";import"./chunk-k71e38fk.js";import"./chunk-813wwkap.js";import"./chunk-48s1nprc.js";import"./chunk-qf39z0hg.js";import"./chunk-gh181dnr.js";import"./chunk-38mt83wa.js";import"./chunk-jtq8e3b0.js";import"./chunk-b3c1gggs.js";import"./chunk-tt1p6zt8.js";import"./chunk-82bttwqm.js";export{K as BROWSER_CORE_IMPORTS,hc as STX_AUTO_IMPORTS,ds as extractAndStripCssImports,we as extractBridgeData,Li as findInterpolationEnd,ii as generateAutoImportDestructuring,Gu as generateBrowserAutoImportDestructuring,mn as generateServerDataBridge,At as injectBrowserCoreAutoImports,xe as processClientScript,gs as referencesName,ps as renderVendorStyleTags,s as stripCommentsAndLiterals,oi as transformAutoImports};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Bt}from"./chunk-gh181dnr.js";import{li,ms,V,We,ee,It,x,Ke,Xe,cr,u}from"./chunk-
|
|
2
|
+
import{Bt}from"./chunk-gh181dnr.js";import{li,ms,V,We,ee,It,x,Ke,Xe,cr,u}from"./chunk-atqnvmea.js";import{N}from"./chunk-zvs13kgh.js";var H=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function B(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(H.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 q=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function ko(t){let n=[],e=[],r=[],i=0;while(i<t.length){let s=t.indexOf("<",i);if(s===-1)break;let a=We(t,s);if(a>s){i=a;continue}let o=V(t,s);if(o>s){let c=t.slice(s,o),f=q.exec(c);if(f){let l=B(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}}i=o;continue}i=s+(t.startsWith("<!--",s)?4:1)}return{signals:n,client:e,server:r}}var z=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function G(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 U(t){let n=(t||"").trim();if(!n)return null;if(/[\s>+~,:]/.test(n))return null;let e={},r=n,i=r.match(/^[a-z][\w-]*/i);if(i)e.tag=i[0].toLowerCase(),r=r.slice(i[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 o=r.match(/^\.([\w-]+)/);if(o){e.className=o[1],r=r.slice(o[0].length);continue}return null}if(!e.tag&&!e.attr&&!e.id&&!e.className)return null;return e}function W(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 O(t,n="main"){let e=U(n);if(!e)return null;let r=/<([a-z][\w-]*)\b([^>]*)>/gi,i=G(t),s;while((s=r.exec(t))!==null){if(P(s.index,i))continue;let a=s[1].toLowerCase(),o=s[2]||"";if(o.trimEnd().endsWith("/")||z.has(a))continue;if(e.tag&&e.tag!==a)continue;if(!W(o,e))continue;let c=s[0],f=s.index+c.length,l=new RegExp(`<(/?)${a}\\b([^>]*)>`,"gi");l.lastIndex=f;let g=1,m;while((m=l.exec(t))!==null){if(P(m.index,i))continue;let S=m[1]==="/";if(!S&&(m[2]||"").trimEnd().endsWith("/"))continue;if(g+=S?-1:1,g===0)return{openTag:c,openIndex:s.index,start:f,end:m.index,tagName:a}}return null}return null}var Le="private, no-store";function Co(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 oe(t){return t.headers.get("X-STX-Router")==="true"}function X(t,n){if(!t)return n;return t.split(",").some((r)=>r.trim().toLowerCase()===n.toLowerCase())?t:`${t}, ${n}`}function T(t){return{Vary:X(t,"X-STX-Router")}}import E from"path";var J="stx-page-head:",K=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,v={dev:null,prod:null};function Y(){let t=N()?"dev":"prod",n=v[t];if(n!==null)return n;try{let e=import.meta.require("./chunk-v4gepwh9.js"),r=t==="dev"&&typeof e.getRouterScriptDev==="function"?e.getRouterScriptDev:e.getRouterScript;v[t]=`<script>${r()}</script>`}catch{v[t]=""}return v[t]}async function _o(t,n){if(n===!1)return null;if(n&&typeof n==="string"){let r=E.resolve(t,n);if(await Bun.file(r).exists())return r;return null}let e=E.join(t,"app.stx");if(await Bun.file(e).exists())return e;return null}async function Fr(t,n){try{let e=await Bun.file(t).text(),r=e,i=e.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(i)r=i[1].trim();let s=ko(e),a=[...s.client.map((d)=>d.fullTag),...s.signals.map((d)=>d.fullTag)],o=[],c=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,f;while((f=c.exec(e))!==null)o.push(f[0]);let l=r;for(let d of s.server)l=l.replace(d.fullTag,"");for(let d of s.client)l=l.replace(d.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:m,extractVariables:S,defaultConfig:b,loadStxConfig:w}=await import("./chunk-knngjd2r.js"),y=await w(),p={__filename:t,__dirname:E.dirname(t)};for(let d of a){let C=d.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(C&&!d.includes("client")&&!d.includes('type="module"'))await S(C[1],p,t)}let R=await m(l,p,t,{...b,...y,...n},new Set),h=R.indexOf(g);if(h===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:R.substring(0,h),afterSlot:R.substring(h+g.length),filePath:t,shellScripts:a,shellStyles:o}}catch(e){return console.error(`[stx] Error processing shell ${t}:`,e),null}}function qn(t,n,e){let r,i="",s=n.match(K);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();i=l.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let a=e||r||"stx App",o=Y(),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">
|
|
@@ -27,5 +27,5 @@ ${o}
|
|
|
27
27
|
`));if(i.length>0)y.push(i.filter((p)=>!c.has(p)).join(`
|
|
28
28
|
`));if(S.length>0)y.push(S.filter((p)=>!c.has(p)).join(`
|
|
29
29
|
`));return y.push(m),y.join(`
|
|
30
|
-
`)}import k from"fs";import D from"path";function To(t,n,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:e}}function $o(t,n){let e=D.join(n,"manifest.json");k.writeFileSync(e,JSON.stringify(t,null,2))}function Ro(t){let n=D.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}}function _(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 Q(t){let n=t.headers.get("content-type")||"",e={},r=(i,s)=>{let a=e[i];if(a===void 0)e[i]=s;else if(Array.isArray(a))a.push(s);else e[i]=[a,s]};if(n.includes("multipart/form-data")){let i=await t.formData();for(let[s,a]of i.entries())if(typeof a==="string")r(s,a);return e}if(n.includes("application/x-www-form-urlencoded")){for(let[i,s]of new URLSearchParams(await t.text()).entries())r(i,s);return e}return e}function zr(t){if(!t)return!1;let n=t.toUpperCase();return n!=="GET"&&n!=="HEAD"}async function F(t,n={}){let e=n.request,r=n.method??e?.method;if(!e||!zr(r))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let i={};try{i=await Q(e)}catch{}let s=await t.action({request:e,form:i,params:n.params??{},query:t.query??{},cookies:n.cookies??{}});if(s&&typeof s==="object"){let a=s,o=tt(a.cookies),c=a.redirect;if(typeof c==="string"&&c)return{redirect:c,ran:!0,...o.length>0?{cookies:o}:{}};let{cookies:f,redirect:l,...g}=a;if(Object.assign(t,g),o.length>0)return{ran:!0,cookies:o}}return{ran:!0}}function tt(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,r));continue}if(r&&typeof r==="object"){let i=r;if(typeof i.value!=="string")continue;n.push(_(e,i.value,i))}}return n}function Ao(t,n=[],e){let r=new Headers({Location:t,"Cache-Control":"no-store"});for(let i of n)r.append("Set-Cookie",i);for(let[i,s]of Object.entries(e??{}))if(i.toLowerCase()!=="location")r.set(i,s);return new Response(null,{status:303,headers:r})}async function Wt(t,n={}){let{html:e,context:r,redirect:i,cookies:s}=await et(t,n),a=Ke(r),o=Xe(r);if(i)return{html:e,redirect:i,cookies:s,status:a,headers:o};let{extractStreamBoundaries:c}=await import("./chunk-
|
|
30
|
+
`)}import k from"fs";import D from"path";function To(t,n,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:e}}function $o(t,n){let e=D.join(n,"manifest.json");k.writeFileSync(e,JSON.stringify(t,null,2))}function Ro(t){let n=D.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}}function _(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 Q(t){let n=t.headers.get("content-type")||"",e={},r=(i,s)=>{let a=e[i];if(a===void 0)e[i]=s;else if(Array.isArray(a))a.push(s);else e[i]=[a,s]};if(n.includes("multipart/form-data")){let i=await t.formData();for(let[s,a]of i.entries())if(typeof a==="string")r(s,a);return e}if(n.includes("application/x-www-form-urlencoded")){for(let[i,s]of new URLSearchParams(await t.text()).entries())r(i,s);return e}return e}function zr(t){if(!t)return!1;let n=t.toUpperCase();return n!=="GET"&&n!=="HEAD"}async function F(t,n={}){let e=n.request,r=n.method??e?.method;if(!e||!zr(r))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let i={};try{i=await Q(e)}catch{}let s=await t.action({request:e,form:i,params:n.params??{},query:t.query??{},cookies:n.cookies??{}});if(s&&typeof s==="object"){let a=s,o=tt(a.cookies),c=a.redirect;if(typeof c==="string"&&c)return{redirect:c,ran:!0,...o.length>0?{cookies:o}:{}};let{cookies:f,redirect:l,...g}=a;if(Object.assign(t,g),o.length>0)return{ran:!0,cookies:o}}return{ran:!0}}function tt(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,r));continue}if(r&&typeof r==="object"){let i=r;if(typeof i.value!=="string")continue;n.push(_(e,i.value,i))}}return n}function Ao(t,n=[],e){let r=new Headers({Location:t,"Cache-Control":"no-store"});for(let i of n)r.append("Set-Cookie",i);for(let[i,s]of Object.entries(e??{}))if(i.toLowerCase()!=="location")r.set(i,s);return new Response(null,{status:303,headers:r})}async function Wt(t,n={}){let{html:e,context:r,redirect:i,cookies:s}=await et(t,n),a=Ke(r),o=Xe(r);if(i)return{html:e,redirect:i,cookies:s,status:a,headers:o};let{extractStreamBoundaries:c}=await import("./chunk-hjh1a3ga.js"),f=c(r),l=t.streamTemplates;if(l&&Object.keys(l).length>0){let{processDirectives:g}=await import("./chunk-9nct3gsy.js"),{defaultConfig:m}=await import("./chunk-6kmqb08x.js"),S=r.streamBoundaries||{},b={...m,autoShell:!1},w=Object.keys(l).map((p)=>({id:p,render:async()=>{let R=typeof S[p]==="function"?await S[p]():void 0;return g(l[p],{...r,$boundary:R},t.sourceFile,b,new Set)}})),y=new Set(w.map((p)=>p.id));f=[...(f||[]).filter((p)=>!y.has(p.id)),...w]}return{html:e,boundaries:f&&f.length>0?f:void 0,cookies:s,status:a,headers:o}}async function et(t,n){let e={__filename:t.sourceFile,__dirname:t.sourceFile.replace(/[/\\][^/\\]+$/,""),...n};if(!t.hasServerScripts&&!ms(t.html))return{html:t.html,context:e};for(let a of t.serverScriptContent)try{await u(a,e,t.sourceFile)}catch(o){if(n.__stx_strict_hydration)throw o;console.warn(`[stx] Server script error in ${t.sourceFile}:`,o)}let r=await F(e,{request:n.request,method:n.method,params:n.params??{},cookies:n.cookies??{}}),i=(a)=>{let o=a.replace(/<script\b[^>]*\bdata-stx-server-data\b[^>]*>[\s\S]*?<\/script>/gi,""),c=cr(e);if(!c)return o;let f=o.indexOf("</head>");return f<0?c+o:o.slice(0,f)+c+o.slice(f)};if(r.redirect)return{html:t.html,context:e,redirect:r.redirect,cookies:r.cookies};if(!ms(t.html))return{html:i(t.html),context:e,cookies:r.cookies};let s=new Map;for(let[a,o]of Object.entries(t.placeholders))if(o.expression)try{let c=x(o.expression,e);if(o.type==="raw")s.set(a,c!==void 0&&c!==null?String(c):"");else s.set(a,c!==void 0&&c!==null?It(String(c)):"")}catch(c){if(n.__stx_strict_hydration)throw c;s.set(a,"")}return{html:i(li(t.html,s)),context:e,cookies:r.cookies}}
|
|
31
31
|
export{ko,Le,Co,oe,T,_o,Fr,qn,ve,Eo,ie,To,$o,Ro,zr,Ao,Wt};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Pt,Rs,Ti,Hc}from"./chunk-
|
|
2
|
+
import{Pt,Rs,Ti,Hc}from"./chunk-atqnvmea.js";import"./chunk-t19th11m.js";import"./chunk-v8ze2q95.js";import"./chunk-k71e38fk.js";import"./chunk-813wwkap.js";import"./chunk-48s1nprc.js";import"./chunk-qf39z0hg.js";import"./chunk-gh181dnr.js";import"./chunk-38mt83wa.js";import"./chunk-jtq8e3b0.js";import"./chunk-b3c1gggs.js";import"./chunk-tt1p6zt8.js";import"./chunk-82bttwqm.js";export{Hc as declareBareLoopHead,Pt as parseLoopBinding,Ti as processLoops,Rs as reportDeferredLoopWarnings};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{id,di,ad,pi,Ec,Tc,Dt,wn,cd,$c,Rc,ld,f}from"./chunk-
|
|
2
|
+
import{id,di,ad,pi,Ec,Tc,Dt,wn,cd,$c,Rc,ld,f}from"./chunk-atqnvmea.js";import"./chunk-t19th11m.js";import"./chunk-v8ze2q95.js";import"./chunk-k71e38fk.js";import"./chunk-813wwkap.js";import"./chunk-48s1nprc.js";import"./chunk-qf39z0hg.js";import"./chunk-gh181dnr.js";import"./chunk-38mt83wa.js";import"./chunk-jtq8e3b0.js";import"./chunk-b3c1gggs.js";import"./chunk-tt1p6zt8.js";import"./chunk-82bttwqm.js";export{Dt as buildCss,$c as extractClassNames,Tc as fingerprintConfig,Rc as generateCss,cd as getCachedCSS,id as getCssServeAsset,f as injectCss,di as loadCssEngine,pi as loadCssEngineConfig,wn as rebuildCss,ad as resetCssCache,Ec as resolveUserCssConfig,ld as withLinkedModuleBundles};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Cl}from"./chunk-h8a8y1wh.js";import"./chunk-btbdp4fg.js";import"./chunk-vn6h03nq.js";import"./chunk-x7epxhsz.js";import"./chunk-atqnvmea.js";import"./chunk-t19th11m.js";import"./chunk-v8ze2q95.js";import"./chunk-k71e38fk.js";import"./chunk-813wwkap.js";import"./chunk-48s1nprc.js";import"./chunk-qf39z0hg.js";import"./chunk-gh181dnr.js";import"./chunk-38mt83wa.js";import"./chunk-jtq8e3b0.js";import"./chunk-b3c1gggs.js";import"./chunk-tt1p6zt8.js";import"./chunk-82bttwqm.js";export{Cl as buildForProduction};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ze,q}from"./chunk-y0qjpcc8.js";import{Ko}from"./chunk-
|
|
2
|
+
import{ze,q}from"./chunk-y0qjpcc8.js";import{Ko}from"./chunk-fkh9zshs.js";import{d}from"./chunk-yn2d8x8m.js";import{existsSync as M,mkdirSync as v,copyFileSync as k,chmodSync as T}from"fs";import{join as o,basename as te}from"path";import{spawn as E,execSync as ae}from"child_process";import{homedir as B,platform as re}from"os";var Lu=`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
'use strict';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{$t,as,cs,ls,qu,us}from"./chunk-x7epxhsz.js";import"./chunk-k71e38fk.js";import"./chunk-48s1nprc.js";import"./chunk-tt1p6zt8.js";export{cs as buildServerApi,qu as createServerApi,$t as discoverServerApi,as as generateApiTypes,us as isServerApiSource,ls as productionApiDispatcher};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{le,uc,ri,kt,Ct,Wu,si,_t,pn,dc,pc,fc,is,Et,gc,Tt,mc}from"./chunk-
|
|
2
|
+
import{le,uc,ri,kt,Ct,Wu,si,_t,pn,dc,pc,fc,is,Et,gc,Tt,mc}from"./chunk-sqq6kpve.js";import"./chunk-x7epxhsz.js";import"./chunk-tds3d65g.js";import"./chunk-atqnvmea.js";import"./chunk-t19th11m.js";import"./chunk-v8ze2q95.js";import"./chunk-k71e38fk.js";import"./chunk-813wwkap.js";import"./chunk-48s1nprc.js";import"./chunk-qf39z0hg.js";import"./chunk-gh181dnr.js";import"./chunk-38mt83wa.js";import"./chunk-jtq8e3b0.js";import"./chunk-b3c1gggs.js";import"./chunk-tt1p6zt8.js";import"./chunk-82bttwqm.js";export{pn as MODULE_SPECIFIER_PREFIX,Tt as bundleClientScript,Ct as clearBundleFailures,le as clientBundleDependencies,kt as getBundleFailures,_t as hasUserImports,Et as moduleSubstitutionKey,pc as normalizeRegistrySpecifiers,gc as queueClientBundleBuild,ri as recordBundleFailure,dc as registryIdForPath,si as resolveBundlerFallback,fc as rewriteRegistryImports,Wu as setBundlerFallbackMode,uc as shouldLogBundlerDiagnostics,mc as tempBuildName,is as withModuleSubstitutes};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{b,u,n,g,A}from"./chunk-
|
|
2
|
+
import{b,u,n,g,A}from"./chunk-atqnvmea.js";import k from"path";var q={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var M=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function H(e){let t=[],o=0,s;M.lastIndex=0;while((s=M.exec(e))!==null){if(s.index>o){let a=e.slice(o,s.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let r=s[1],i=s[2];t.push({type:"suspense",name:r,content:i}),o=s.index+s[0].length}if(o<e.length){let r=e.slice(o);if(r.trim())t.push({type:t.length===0?"shell":"content",content:r})}if(t.length===0)t.push({type:"shell",content:e});return t}async function Tu(e,t={},o={}){let s={...A,...o,streaming:{...q,...o.streaming}},r=s.streaming?.bufferSize||16384;return new ReadableStream({async start(i){try{let a=await Bun.file(e).text(),w=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),m=w?w[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y={...t,__filename:e,__dirname:k.dirname(e)};if(m.trim())await u(m,y,e);let E=H(c),l=new Set;if(!E.some((h)=>h.type==="suspense")){let h=s.streaming?.strategy||"auto",S=new RegExp(T.source,"g");if(!(h!=="manual"&&S.test(c))){let p=await n(c,y,e,s,l);for(let x=0;x<p.length;x+=r)i.enqueue(p.slice(x,x+r)),await new Promise((f)=>setTimeout(f,0))}else{let p=[],x=new RegExp(T.source,"g"),f;while((f=x.exec(c))!==null)p.push({name:f[1],content:f[2],start:f.index,end:f.index+f[0].length});let v=0;for(let _ of p){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let O=await n(I,y,e,s,l);i.enqueue(O),await new Promise((D)=>setTimeout(D,0))}}let C=await n(_.content,y,e,s,l);i.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await n(_,y,e,s,l);i.enqueue(C)}}}}else{let h=new Map;for(let d of E)if(d.type==="shell"||d.type==="content"){let p=await n(d.content,y,e,s,l);i.enqueue(p)}else if(d.type==="suspense"&&d.name){let p=`stx-suspense-${d.name}`;i.enqueue(`<div id="${p}" data-suspense="${d.name}" style="display:contents;">
|
|
3
3
|
<template data-suspense-fallback>Loading...</template>
|
|
4
4
|
</div>`),h.set(d.name,n(d.content,y,e,s,l))}i.enqueue(`
|
|
5
5
|
<script>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{er,Ve,we,xe,fi,sr,ne,J,Sn,u,n,A}from"./chunk-
|
|
2
|
+
import{er,Ve,we,xe,fi,sr,ne,J,Sn,u,n,A}from"./chunk-atqnvmea.js";function h(o){return o.endsWith(".md")||o.endsWith(".markdown")}function _(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}=er(o),c=await(e.renderer??((s)=>Ve(s)))(g);return{html:_(c),frontmatter:r??{}}}import{dirname as C,resolve as R}from"path";function k(o){let e=o,r=ne(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 v(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=we(p),d=(await Promise.all(c.map(async(w)=>{let y=w.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!y)return w;return await xe(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 J(t)}if(r.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=v(t,r.title)}if(r.injectCSS)try{let{injectCss:i}=await import("./chunk-
|
|
17
|
+
${d}`}t=await J(t)}if(r.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=v(t,r.title)}if(r.injectCSS)try{let{injectCss:i}=await import("./chunk-c88e6w5r.js");t=await i(t)}catch{}return t}
|
|
18
18
|
export{Ko};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import m from"path";var y=/__stxModules\["((?:[^"\\]|\\.)*)"\]/g;function I(...o){let r=new Set;for(let s of o){if(!s||!s.includes("__stxModules["))continue;for(let e of s.matchAll(y))try{r.add(JSON.parse(`"${e[1]}"`))}catch{}}return[...r].sort()}async function w(o,r={}){if(o.length===0)return null;let s=process.cwd(),e=[],a=[];o.forEach((t,c)=>{let i=t.startsWith("npm:")?t.slice(4):m.resolve(s,t),l=`__stxRegistered${c}`,p=JSON.stringify(t);e.push(`import * as ${l} from ${JSON.stringify(i)};`),a.push(`if (!globalThis.__stxModules[${p}]) globalThis.__stxModules[${p}] = ${l};`)});let d=[...e,"globalThis.__stxModules = globalThis.__stxModules || {};",...a].join(`
|
|
3
|
-
`),n;try{let{bundleClientScript:t}=await import("./chunk-
|
|
3
|
+
`),n;try{let{bundleClientScript:t}=await import("./chunk-erb1bc49.js");n=await t(d,m.join(s,".stx-module-registry.ts"),{projectRoot:s,minify:r.minify,externalizeUserModules:!1,collectInputs:r.collectInputs,throwOnFailure:!0})}catch(t){let{formatBuildFailure:c}=await import("./chunk-y6909jm7.js"),i=c(t);console.warn(`[stx] could not build the page module registry (#1957): ${i}`);let l=`[stx] the page module registry did not build, so ${o.join(", ")} cannot load (#1957): ${i}`;return`;console.error(${JSON.stringify(l)});`}let{transformAutoImports:f,generateAutoImportDestructuring:_}=await import("./chunk-bc8rzjnh.js"),u=f(n),h=_(u.stxImports,u.browserImports),{transformStoreImports:x}=await import("./chunk-hq4mtcp0.js");n=x(u.code);let g=JSON.stringify(new Bun.CryptoHasher("md5").update(d).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${g}]) return;`,` __stxBundles[${g}] = true;`,h,n,"})();"].join(`
|
|
4
4
|
`)}export{w as buildModuleRegistryScript,I as registeredModuleIdsIn};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{u,$s,_i,Ei,Uc,Wc,qc,Gc,Kc,Xc,Ze,j,Qe,Jc,lr,Yc,Ai,Zc,et,r,ur,Pi,g,re,md}from"./chunk-
|
|
2
|
+
import{u,$s,_i,Ei,Uc,Wc,qc,Gc,Kc,Xc,Ze,j,Qe,Jc,lr,Yc,Ai,Zc,et,r,ur,Pi,g,re,md}from"./chunk-atqnvmea.js";import"./chunk-t19th11m.js";import"./chunk-v8ze2q95.js";import"./chunk-k71e38fk.js";import"./chunk-813wwkap.js";import"./chunk-48s1nprc.js";import"./chunk-qf39z0hg.js";import"./chunk-gh181dnr.js";import"./chunk-38mt83wa.js";import"./chunk-jtq8e3b0.js";import"./chunk-b3c1gggs.js";import"./chunk-tt1p6zt8.js";import"./chunk-82bttwqm.js";export{re as clearComponentCache,Zc as componentClientSignalNames,$s as convertToCommonJS,g as createDetailedErrorMessage,Kc as extractDirectiveNames,_i as extractScriptFromTemplate,u as extractVariables,r as fileExists,md as getComponentCacheStats,Wc as getPositionInfo,j as getSharedTranspiler,Pi as getSourceLineInfo,Gc as hasDirectives,Ei as hasVariables,Yc as isHydrateTrigger,Xc as isJavaScriptScript,et as renderComponentWithSlot,ur as resolveTemplatePath,Jc as scopeOnRootElement,Ze as shouldTranspileTypeScript,Ai as slotContentHasExpressions,Qe as transpileTypeScript,lr as userComponentFileExists,qc as validateDirective,Uc as validateTemplate};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{o}from"./chunk-
|
|
2
|
+
import{o}from"./chunk-atqnvmea.js";import{Hr}from"./chunk-9cgga2aw.js";import p from"path";async function Ml(t={}){let d=performance.now(),s=t.root||process.cwd(),e=await o(s),u=t.ssr?.routeRules??e.routeRules??{};if(Hr(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-cg3vfr6b.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{Ml};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Pe}from"./chunk-
|
|
2
|
+
import{Pe}from"./chunk-tt1p6zt8.js";import{Fe,sn}from"./chunk-vn6h03nq.js";import{ai,ci,f,Nt,pe,L,n,A,o}from"./chunk-atqnvmea.js";import{C}from"./chunk-48s1nprc.js";import{Fs}from"./chunk-813wwkap.js";import{Tn,$n,Rn,Pn,ye}from"./chunk-gh181dnr.js";import{Fi}from"./chunk-k71e38fk.js";import{ve,ie,To,$o,Wt}from"./chunk-btbdp4fg.js";import{$t,cs}from"./chunk-x7epxhsz.js";import{qt}from"./chunk-9cgga2aw.js";import{xt,un,dn}from"./chunk-122y2fkw.js";import m from"fs";import c from"path";import{createHash as Q}from"crypto";function J(i){return Q("sha256").update(i).digest("hex").slice(0,8)}function U(i=!1){let l=i?sn():Fe(),a=J(l);return{content:l,filename:`runtime.${a}.js`,hash:a}}function V(){let i=Pe(),l=J(i);return{content:i,filename:`router.${l}.js`,hash:l}}import q from"path";import{createHash as ee}from"crypto";function te(i={}){let l=new Set;return{context:new Proxy(i,{get(r,e){if(e in r)return r[e];if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return},has(r,e){if(e in r)return!0;if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return!1}}),accessedKeys:l}}async function X(i,l,a={}){let r=q.resolve(i),e=await Bun.file(r).text(),S=ee("sha256").update(e).digest("hex").slice(0,16);ai();let _={};try{_=await o(a.configDir)}catch{}let y=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,g;while((g=d.exec(e))!==null){let R=g[1];if(/\bserver\b/.test(R))y.push(g[2])}let u=new Set(y.flatMap((R)=>pe(R))),{context:D}=te({__filename:r,__dirname:q.dirname(r),__stx_serverDeclared:u}),w=new Set,P={...A,..._,...a,buildMode:"compile",strict:!1},b=await n(e,D,r,P,w),T=ve(b),B=ci();return{route:l,sourceFile:i,html:b,fragment:T,placeholders:B,hasServerScripts:y.length>0,serverScriptContent:y,dependencies:Array.from(w),contentHash:S,status:Nt(e),streamTemplates:D.__streamTemplates}}var re=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function Z(i,l){let a=0,r=0;if(!m.existsSync(i))return{copied:a,bytes:r};m.mkdirSync(l,{recursive:!0});function e(S,_){let y=m.readdirSync(S,{withFileTypes:!0});for(let d of y){if(re.has(d.name))continue;let g=c.join(S,d.name),u=c.join(_,d.name);if(d.isDirectory())m.mkdirSync(u,{recursive:!0}),e(g,u);else if(d.isFile()){if(m.existsSync(u))continue;m.copyFileSync(g,u),a++,r+=m.statSync(u).size}}}return e(i,l),{copied:a,bytes:r}}async function Cl(i={}){let l=Date.now(),a=c.resolve(i.root||process.cwd()),r=c.resolve(a,i.outputDir||".output");console.log("[stx build] Starting production build...");let e=await o(a),S=c.resolve(a,i.componentsDir??e.componentsDir??"components"),_=c.resolve(a,i.partialsDir??e.partialsDir??"partials"),y=c.resolve(a,i.layoutsDir??e.layoutsDir??"layouts"),d=i.publicDir??e.publicDir??"public",g=ye(e.app?.head,{known:Pn,source:"app.head"}),u=e.app?.colorMode,D=e.router?.container||"main",w=i.routeRules??e.routeRules??{},P=qt(w),b=i.serverApi??e.serverApi,T=typeof b==="object"?b:{};if(b)$t(a,T);if(e.runtimeConfig)C(e.runtimeConfig,{});if(m.existsSync(r))m.rmSync(r,{recursive:!0});let B=[c.join(r,"public","__stx"),c.join(r,"public","assets"),c.join(r,"server","pages"),c.join(r,"server","fragments")];for(let s of B)m.mkdirSync(s,{recursive:!0});console.log("[stx build] Discovering routes...");let R=L(a,{pagesDirs:e._layerPageDirs}),Y=["components","layouts","partials"],M=R.filter((s)=>!Y.some((h)=>s.pattern.startsWith(`/${h}/`)||s.pattern===`/${h}`));console.log(`[stx build] Found ${M.length} page routes (${R.length-M.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let v=U(i.debug),x=V();await Bun.write(c.join(r,"public","__stx",v.filename),v.content),await Bun.write(c.join(r,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${v.filename} (${(v.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${x.filename} (${(x.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let O=[],E=[];for(let s of M){let h=P(s.pattern),k=h.rendering==="prerender";if(k&&(s.pattern.includes(":")||s.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${s.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let t=await X(s.filePath,s.pattern,{configDir:a,componentsDir:S,partialsDir:_,layoutsDir:y,debug:i.debug});if(O.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,v.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),t.html=Rn(t.html,g,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=Tn(t.html,u);if(g.htmlAttrs)t.html=$n(t.html,g.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(t.html)){let p=t.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(p&&p[1]){let W=p[1];t.html=t.html.replace(" "+W,""),t.html=t.html.replace(/<body([^>]*)>/,`<body$1 ${W}>`)}}if(t.html=t.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),t.html=await f(t.html),k){let p=await Wt(t,{params:{},request:new Request(`http://stx.build${s.pattern}`),method:"GET",__stx_strict_hydration:!0});if(p.redirect||p.cookies?.length||p.boundaries?.length||p.headers&&Object.keys(p.headers).length)throw Error(`Prerendered route ${s.pattern} cannot set response headers/cookies, redirect or stream`);t.html=p.html,t.status=p.status??t.status,t.hasServerScripts=!1,t.serverScriptContent=[],t.placeholders={}}t.fragment=ie(t.html,D);let z=s.pattern==="/"?"index":s.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),G=c.join("server","pages",`${z}.compiled.json`),I=c.join("server","fragments",`${z}.html`);await Bun.write(c.join(r,G),JSON.stringify(t,null,2)),await Bun.write(c.join(r,I),t.fragment),E.push({pattern:s.pattern,compiledPath:G,fragmentPath:I,isDynamic:t.hasServerScripts,hasParams:s.pattern.includes(":")||s.pattern.includes("["),prerendered:k}),console.log(`[stx build] \u2713 ${s.pattern}`)}catch(t){if(Object.keys(h).length)throw t;console.error(`[stx build] \u2717 ${s.pattern}:`,t instanceof Error?t.message:t)}}let H=c.resolve(a,d);if(m.existsSync(H)){let{copied:s,bytes:h}=Z(H,c.join(r,"public"));if(s>0)console.log(`[stx build] Copied ${s} public asset${s===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${d}/`)}let F=dn(a);if(F){let{copied:s,bytes:h}=Z(F,c.join(r,"public",un));if(s>0)console.log(`[stx build] Copied ${s} asset${s===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${xt}/`)}let N={runtime:v.filename,router:x.filename},j=To(E,N,r);if(j.routeRules=w,j.routerContainer=D,b)j.apiRoutes=await cs(a,r,T);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await Fs(a,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(Fi(e._layerGraph),null,2));$o(j,r);let K=Date.now()-l;return console.log(`
|
|
3
3
|
[stx build] Done in ${K}ms \u2014 ${O.length} pages compiled`),{pageCount:O.length,assets:N,outputDir:r,duration:K}}
|
|
4
4
|
export{Cl};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Tu,jo,tc,$u,Ru,Au,Pu,Iu,nc,rc,Ou,Du,Nu,Mu}from"./chunk-
|
|
2
|
+
import{Tu,jo,tc,$u,Ru,Au,Pu,Iu,nc,rc,Ou,Du,Nu,Mu}from"./chunk-f49nnf8v.js";import"./chunk-atqnvmea.js";import"./chunk-t19th11m.js";import"./chunk-v8ze2q95.js";import"./chunk-k71e38fk.js";import"./chunk-813wwkap.js";import"./chunk-48s1nprc.js";import"./chunk-qf39z0hg.js";import"./chunk-gh181dnr.js";import"./chunk-38mt83wa.js";import"./chunk-jtq8e3b0.js";import"./chunk-b3c1gggs.js";import"./chunk-tt1p6zt8.js";import"./chunk-82bttwqm.js";export{tc as SUSPENSE_RESOLVER_RUNTIME,jo as buildSuspenseResolveScript,Iu as createStreamRenderer,Au as extractStreamBoundaries,Mu as generateHydrationRuntime,rc as islandDirective,Du as processSectionDirectives,Ru as processStreamDirectives,Ou as registerStreamingDirectives,$u as renderStreamingPage,Tu as streamTemplate,Pu as streamTemplateSimple,Nu as streamToResponse,nc as streamingSuspenseDirective};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{y}from"./chunk-b3c1gggs.js";import{K,Je,ws,xs,gi,mi,hi,yi,ir,Ss,bi,vi,wi,Mt,o}from"./chunk-
|
|
2
|
+
import{y}from"./chunk-b3c1gggs.js";import{K,Je,ws,xs,gi,mi,hi,yi,ir,Ss,bi,vi,wi,Mt,o}from"./chunk-atqnvmea.js";import{Qr}from"./chunk-navkh35g.js";import{a}from"./chunk-dgtxj56t.js";import{existsSync as M,readFileSync as G}from"fs";import h from"path";var me=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),te=Mt.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 ba(e,t="",s=""){let u=e.startLine>1?`
|
|
5
5
|
`.repeat(e.startLine-1):"",i=Ss(e)+xs(ws(e.code)),l=e.kind==="client"||e.kind==="plain"?hi(t,e.code):"";return ir(`${u+i}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{G,b,hn,yn,e,Dt,wn,f,Ge,Nt,Ke,Xe,ne,L,fe,J,u,_e,Ri,Os,n,r,re,dr,o,P,ge}from"./chunk-
|
|
2
|
+
import{G,b,hn,yn,e,Dt,wn,f,Ge,Nt,Ke,Xe,ne,L,fe,J,u,_e,Ri,Os,n,r,re,dr,o,P,ge}from"./chunk-atqnvmea.js";import{Y,In,se,I,Ft}from"./chunk-38mt83wa.js";import{at,Ln,_r,Er,Tr,ct,lt,ut,dt,pt,ft,Ae}from"./chunk-tt1p6zt8.js";import{Le,Co,oe,T,_o,Fr,qn,ve,Eo,ie}from"./chunk-btbdp4fg.js";import{Vt}from"./chunk-afnj003j.js";import{ue}from"./chunk-tds3d65g.js";import{a}from"./chunk-dgtxj56t.js";import{N}from"./chunk-zvs13kgh.js";async function Gn(t){try{let s=await Bun.file(t).text(),i=Jn(s),d=Yn(s,t),c=Qn(s,i),l=Zn(s,i);return{file:t,metrics:i,issues:d,suggestions:c,performance:l}}catch(s){throw Error(`Failed to analyze template ${t}: ${s instanceof Error?s.message:String(s)}`)}}function Jn(t){let s=t.split(`
|
|
3
3
|
`),i=t.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),c=(i?i[1]:"").split(`
|
|
4
4
|
`).length,l={conditionals:(t.match(/@(if|unless|elseif|else|endif|endunless)\b/g)||[]).length,loops:(t.match(/@(foreach|for|endforeach|endfor|while|endwhile)\b/g)||[]).length,includes:(t.match(/@(include|component|extends|section|yield)\b/g)||[]).length,custom:0,total:0};l.total=l.conditionals+l.loops+l.includes+l.custom;let m=(t.match(/\{\{[\s\S]*?\}\}/g)||[]).length,p=(t.match(/\{!![\s\S]*?!!\}/g)||[]).length,h=(t.match(/@(?:if|unless|elseif|foreach|for|while)\s*\([^)]+\)/g)||[]).length,g=m+p+h,y=(t.match(/<[A-Z][^>]*>/g)||[]).length,w=(t.match(/@(?:layout|extends)\(/g)||[]).length,S=0,R=0;for(let C of s)if(/@(?:if|unless|foreach|for|while|section)\b/.test(C)&&!/@end/.test(C)&&!/@else/.test(C))R++,S=Math.max(S,R);else if(/@end(?:if|unless|foreach|for|while|section)\b/.test(C))R--;let v=S>=4?3:0,x=Math.min(10,Math.ceil(l.total*0.5+g*0.1+y*0.3+(c>10?c*0.05:0)+v));return{lines:s.length,characters:t.length,directives:l,expressions:g,components:y,layouts:w,scriptLines:c,complexity:x}}function Yn(t,s){let i=[],d=Jt(t,"if","endif");if(d>0)i.push({type:"error",category:"syntax",message:`Found ${d} unmatched @if directive(s)`,suggestion:"Ensure every @if has a corresponding @endif"});let c=Jt(t,"foreach","endforeach");if(c>0)i.push({type:"error",category:"syntax",message:`Found ${c} unmatched @foreach directive(s)`,suggestion:"Ensure every @foreach has a corresponding @endforeach"});let l=t.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(l&&l.length>0)i.push({type:"warning",category:"performance",message:"Nested loops detected which may impact performance",suggestion:"Consider preprocessing data or using more efficient data structures"});let m=(t.match(/\{!![\s\S]*?!!\}/g)||[]).length;if(m>0)i.push({type:"warning",category:"security",message:`Found ${m} raw output expression(s) {!! !!}`,suggestion:"Ensure raw outputs are properly sanitized to prevent XSS"});let p=t.match(/<img[^>]*>/g);if(p){let y=p.filter((w)=>!w.includes("alt="));if(y.length>0)i.push({type:"warning",category:"accessibility",message:`Found ${y.length} image(s) without alt attributes`,suggestion:"Add alt attributes to all images for screen reader accessibility"})}let h=t.split(`
|
|
5
5
|
`).filter((y)=>y.length>120);if(h.length>0)i.push({type:"info",category:"maintainability",message:`Found ${h.length} line(s) longer than 120 characters`,suggestion:"Consider breaking long lines for better readability"});let g=(t.match(/style\s*=\s*["'][^"']*["']/g)||[]).length;if(g>3)i.push({type:"info",category:"maintainability",message:`Found ${g} inline style attributes`,suggestion:"Consider moving styles to CSS classes for better maintainability"});return i}function Qn(t,s){let i=[];if(s.complexity>7)i.push({type:"refactor",message:"Template complexity is high. Consider breaking into smaller components.",impact:"high",effort:"medium"});else if(s.complexity>5&&s.directives.total>8)i.push({type:"optimization",message:"Template has moderate complexity. Consider component extraction for reusability.",impact:"medium",effort:"low"});if(s.lines>100&&s.components===0)i.push({type:"refactor",message:"Large template with no components. Consider extracting reusable parts into components.",impact:"medium",effort:"medium"});if(s.expressions>20)i.push({type:"optimization",message:"Many template expressions detected. Consider preprocessing some data in the script section.",impact:"medium",effort:"low"});let d=t.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(d&&d.length>0)i.push({type:"optimization",message:"Nested loops detected. Consider preprocessing data or optimizing data structures.",impact:"high",effort:"medium"});if(s.directives.total===0&&s.expressions<5)i.push({type:"optimization",message:"Template appears static. Consider enabling aggressive caching.",impact:"high",effort:"low"});if(s.scriptLines>50)i.push({type:"refactor",message:"Large script section. Consider moving complex logic to external modules.",impact:"medium",effort:"medium"});return i}function Zn(t,s){let i=1;if(i+=s.directives.conditionals*0.1,i+=s.directives.loops*0.5,i+=s.directives.includes*2,i+=s.expressions*0.05,i+=s.components*1,s.scriptLines>10)i+=s.scriptLines*0.1;let d;if(s.expressions===0&&s.directives.total===0)d="high";else if(s.expressions<5&&s.directives.total<3)d="medium";else d="low";let c=[];if(i>10)c.push("Consider optimizing template complexity");if(d==="low"&&s.directives.total>5)c.push("Reduce dynamic content for better caching");if(s.components===0&&s.lines>40)c.push("Extract components to improve reusability and performance");return{estimatedRenderTime:Math.round(i*100)/100,complexityScore:s.complexity,cacheability:d,recommendations:c}}function Jt(t,s,i){let d=t.replace(/<!--[\s\S]*?-->/g,""),c=(d.match(new RegExp(`@${s}\\b`,"g"))||[]).length,l=(d.match(new RegExp(`@${i}\\b`,"g"))||[]).length;return Math.abs(c-l)}async function uo(t=["**/*.stx"],s){let i=[],d=[];for(let l of t){let m=await Array.fromAsync(new Bun.Glob(l).scan({cwd:s||process.cwd(),onlyFiles:!0,absolute:!0}));d.push(...m.filter((p)=>p.endsWith(".stx")))}for(let l of d)try{let m=await Gn(l);i.push(m)}catch(m){console.warn(`Failed to analyze ${l}:`,m)}let c=er(i);return{results:i,summary:c}}function er(t){let s=t.length,i=t.reduce((g,y)=>g+y.metrics.lines,0),d=s>0?t.reduce((g,y)=>g+y.metrics.complexity,0)/s:0,c=t.reduce((g,y)=>g+y.issues.length,0),l={};t.forEach((g)=>{g.issues.forEach((y)=>{l[y.category]=(l[y.category]||0)+1})});let m=s>0?t.reduce((g,y)=>g+y.performance.estimatedRenderTime,0)/s:0,p=Math.max(1,Math.min(10,Math.round(10-m/2-d/2))),h=[];if(d>6)h.push("Project has high average complexity. Consider refactoring complex templates.");if(c>s*2)h.push("High number of issues detected. Run detailed analysis on individual files.");if(l.security>0)h.push("Security issues found. Review raw output usage and input sanitization.");return{totalFiles:s,totalLines:i,avgComplexity:Math.round(d*100)/100,totalIssues:c,issuesByCategory:l,performanceScore:p,recommendations:h}}import{mkdir as tr,readFile as nr,readdir as rr,stat as Yt,writeFile as or}from"fs/promises";import Re from"path";function rn(t){if(t==="connectedCallback")return`method "${t}" is reserved; define "onConnect" instead, which the element calls once it is connected, rendered and bound`;if(t==="disconnectedCallback")return`method "${t}" is reserved; define "onDisconnect" instead, which the element calls as it leaves the DOM, before it releases its own listeners`;return`method "${t}" is reserved`}var on=new Set(["constructor","connectedCallback","disconnectedCallback","attributeChangedCallback","adoptedCallback"]);function sr(t){return t.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((s)=>s.charAt(0).toUpperCase()+s.slice(1)).join("")}function jt(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()}function ir(t){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test(t)&&!t.startsWith("xml")&&!/[A-Z]/.test(t)}function ar(t){if(t===!0)return"open";if(t==="open"||t==="closed")return t;return!1}async function cr(t){let s=[];async function i(d){let c=await rr(d,{withFileTypes:!0});c.sort((l,m)=>l.name.localeCompare(m.name));for(let l of c){let m=Re.join(d,l.name);if(l.isDirectory()){if(!l.name.startsWith(".")&&l.name!=="node_modules")await i(m)}else if(l.isFile()&&l.name.endsWith(".stx")&&!/\.(?:test|spec)\.stx$/i.test(l.name))s.push(m)}}return await i(t),s}function lr(t,s){let i=t.match(/<script\b(?=[^>]*(?:\bcomponent\b|\bstx:component\b))[^>]*>([\s\S]*?)<\/script>/i);if(!i)return{};let d=i[1].trim();if(!d)return{};try{return JSON.parse(d)}catch(c){throw Error(`${s}: <script component> must contain JSON metadata (${c.message})`)}}function pr(t,s){let i={},d=[...t.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)];for(let c of d){if(!/\bclient\b/i.test(c[1])||/\bcomponent\b|\bstx:component\b/i.test(c[1]))continue;let l;try{l=new Bun.Transpiler({loader:"ts"}).transformSync(c[2])}catch(h){throw Error(`${s}: failed to transpile <script client> (${h.message})`)}let m=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)\s*\(([^)]*)\)\s*\{/g,p;while(p=m.exec(l)){let h=p[1];if(on.has(h))throw Error(`${s}: client ${rn(h)}`);let g=m.lastIndex,y=1,w="",S=!1,R=g;for(;R<l.length&&y>0;R++){let x=l[R];if(S){S=!1;continue}if(w){if(x==="\\")S=!0;else if(x===w)w="";continue}if(x==='"'||x==="'"||x==="`")w=x;else if(x==="{")y++;else if(x==="}")y--}if(y!==0)throw Error(`${s}: unterminated client function "${h}"`);let v=p[0].includes("async")?"async ":"";i[h]=`${v}${h}(${p[2]}) {${l.slice(g,R-1)}}`,m.lastIndex=R}}return i}function ur(t){let s=t.match(/<template\b(?![^>]*\bshadowrootmode\b)[^>]*>([\s\S]*?)<\/template>/i);return(s?s[1]:t).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").trim()}function Qt(t){return[...t.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((s)=>s[1].trim()).filter(Boolean).join(`
|
|
@@ -876,7 +876,7 @@ else {
|
|
|
876
876
|
};
|
|
877
877
|
})();
|
|
878
878
|
</script>
|
|
879
|
-
`}function Ve(t,s,i={}){let d=Xr(s,i),c=t.lastIndexOf("</body>");if(c!==-1)return t.slice(0,c)+d+t.slice(c);if(t.includes("</html>"))return t.replace("</html>",`${d}</html>`);return t+d}function $t(t){let s=t.toLowerCase();return s.endsWith(".css")||s.endsWith(".scss")||s.endsWith(".sass")||s.endsWith(".less")}function Ct(t){let s=t.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>s.endsWith(d))}function Rt(t){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((i)=>i.test(t))}var st=null;function Et(t){if(!st)st=new an(t);return st}function ht(){if(st)st.stop(),st=null}import Pt from"path";var it={name:"bun-plugin-stx",async setup(t){let i={...await o(),...t.config?.stx},d=new Set,c=i.webComponents?.enabled?`./${Pt.relative(Pt.dirname(t.config?.outdir||"dist"),i.webComponents.outputDir||"dist/web-components")}`:"/web-components",l=[];if(i.webComponents?.enabled)try{let m=await dr(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 hn(m,i);if(x){if(i.debug)console.log(`Using cached version of ${m}`);return{contents:x,loader:"html"}}}let h=await se(()=>Bun.file(m).text(),"",(x)=>{throw new In(`Failed to read stx file: ${m}`,m,void 0,void 0,`File read error: ${x.message}`)});if(!h)throw new In(`stx file is empty: ${m}`,m);let{scriptContent:g,templateContent:y,allScripts:w}=G.time("script-extraction",()=>{let x=h,C=ne(h);if(C)x=C.content.trim();let k=h.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],H="",D=[];for(let E of k){let M=E.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",B=E.match(/<script\b([^>]*)>/i),q=B?B[1]:"";if(/\bserver\b/i.test(q))H=M;else D.push(E)}let _=x.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:H,templateContent:_,allScripts:D}}),S={__filename:m,__dirname:Pt.dirname(m),__stx:{webComponentsPath:c,builtComponents:l}};await se(()=>u(g,S,m),void 0,(x)=>{let C=new Y(`Script execution failed in ${m}: ${x.message}`,m,void 0,void 0,g.substring(0,100));if(I.log(C,{filePath:m,scriptContent:g}),i.debug)throw C});let v=await G.timeAsync("directive-processing",async()=>await n(y,S,m,i,p));if(w.length>0){let{interpolateScriptsInTemplate:x}=await import("./chunk-
|
|
879
|
+
`}function Ve(t,s,i={}){let d=Xr(s,i),c=t.lastIndexOf("</body>");if(c!==-1)return t.slice(0,c)+d+t.slice(c);if(t.includes("</html>"))return t.replace("</html>",`${d}</html>`);return t+d}function $t(t){let s=t.toLowerCase();return s.endsWith(".css")||s.endsWith(".scss")||s.endsWith(".sass")||s.endsWith(".less")}function Ct(t){let s=t.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>s.endsWith(d))}function Rt(t){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((i)=>i.test(t))}var st=null;function Et(t){if(!st)st=new an(t);return st}function ht(){if(st)st.stop(),st=null}import Pt from"path";var it={name:"bun-plugin-stx",async setup(t){let i={...await o(),...t.config?.stx},d=new Set,c=i.webComponents?.enabled?`./${Pt.relative(Pt.dirname(t.config?.outdir||"dist"),i.webComponents.outputDir||"dist/web-components")}`:"/web-components",l=[];if(i.webComponents?.enabled)try{let m=await dr(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 hn(m,i);if(x){if(i.debug)console.log(`Using cached version of ${m}`);return{contents:x,loader:"html"}}}let h=await se(()=>Bun.file(m).text(),"",(x)=>{throw new In(`Failed to read stx file: ${m}`,m,void 0,void 0,`File read error: ${x.message}`)});if(!h)throw new In(`stx file is empty: ${m}`,m);let{scriptContent:g,templateContent:y,allScripts:w}=G.time("script-extraction",()=>{let x=h,C=ne(h);if(C)x=C.content.trim();let k=h.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],H="",D=[];for(let E of k){let M=E.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",B=E.match(/<script\b([^>]*)>/i),q=B?B[1]:"";if(/\bserver\b/i.test(q))H=M;else D.push(E)}let _=x.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:H,templateContent:_,allScripts:D}}),S={__filename:m,__dirname:Pt.dirname(m),__stx:{webComponentsPath:c,builtComponents:l}};await se(()=>u(g,S,m),void 0,(x)=>{let C=new Y(`Script execution failed in ${m}: ${x.message}`,m,void 0,void 0,g.substring(0,100));if(I.log(C,{filePath:m,scriptContent:g}),i.debug)throw C});let v=await G.timeAsync("directive-processing",async()=>await n(y,S,m,i,p));if(w.length>0){let{interpolateScriptsInTemplate:x}=await import("./chunk-makn68zy.js"),C=x(w.join(`
|
|
880
880
|
`),S),k=v.search(/<\/body>/i);if(k!==-1)v=v.slice(0,k)+C+`
|
|
881
881
|
`+v.slice(k);else v+=`
|
|
882
882
|
${C}`}if(v=await J(v),p.forEach((x)=>d.add(x)),i.cache&&i.cachePath){if(await yn(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 Y(`Plugin processing failed: ${String(p)}`,m);if(I.log(h,{filePath:m,buildConfig:t.config}),Ft.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||N()?`<!DOCTYPE html>
|
|
@@ -939,7 +939,7 @@ ${C}`}if(v=await J(v),p.forEach((x)=>d.add(x)),i.cache&&i.cachePath){if(await yn
|
|
|
939
939
|
<h1>Something went wrong</h1>
|
|
940
940
|
<p>An internal error occurred. Please try again later.</p>
|
|
941
941
|
</body>
|
|
942
|
-
</html>`,loader:"html"}}})}};async function Fn(t,s={}){let i=s.port||3000,d=s.watch!==!1,c=s.hotReload!==!1&&d,l=null,m=s.hmrPort||i+1,p=we.resolve(t);if(!Be.existsSync(p))return console.error(`${e.red}Error: File not found: ${e.bright}${p}${e.reset}`),!1;if(p.endsWith(".md"))return zt(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");Be.mkdirSync(h,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let g=null,y=async()=>{try{let M={name:"public-assets",setup(Te){Te.onResolve({filter:/^\/(images|fonts|assets|public)\//},(he)=>({path:he.path,external:!0}))}},B=await Bun.build({entrypoints:[p],outdir:h,plugins:[M,it],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 q=B.outputs.find((Te)=>Te.path.endsWith(".html"));if(!q)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return g=await Bun.file(q.path).text(),!0}catch(M){return console.error(`${e.red}Error building stx file:${e.reset}`,M),!1}};if(!await y())return!1;let S=we.dirname(p);await Dt(S);let R=i;try{if(R=await Ye(i),R!==i)console.log(`${e.yellow}Port ${i} is busy, using port ${R} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let M=s.hmrPort||R+1;l=Et({wsPort:M,verbose:!1}),m=l.start(M)}let v={},x=null,C;try{let{loadStxConfig:M}=await import("./chunk-
|
|
942
|
+
</html>`,loader:"html"}}})}};async function Fn(t,s={}){let i=s.port||3000,d=s.watch!==!1,c=s.hotReload!==!1&&d,l=null,m=s.hmrPort||i+1,p=we.resolve(t);if(!Be.existsSync(p))return console.error(`${e.red}Error: File not found: ${e.bright}${p}${e.reset}`),!1;if(p.endsWith(".md"))return zt(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");Be.mkdirSync(h,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let g=null,y=async()=>{try{let M={name:"public-assets",setup(Te){Te.onResolve({filter:/^\/(images|fonts|assets|public)\//},(he)=>({path:he.path,external:!0}))}},B=await Bun.build({entrypoints:[p],outdir:h,plugins:[M,it],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 q=B.outputs.find((Te)=>Te.path.endsWith(".html"));if(!q)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return g=await Bun.file(q.path).text(),!0}catch(M){return console.error(`${e.red}Error building stx file:${e.reset}`,M),!1}};if(!await y())return!1;let S=we.dirname(p);await Dt(S);let R=i;try{if(R=await Ye(i),R!==i)console.log(`${e.yellow}Port ${i} is busy, using port ${R} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let M=s.hmrPort||R+1;l=Et({wsPort:M,verbose:!1}),m=l.start(M)}let v={},x=null,C;try{let{loadStxConfig:M}=await import("./chunk-knngjd2r.js"),B=await M();if(C=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 q=Object.keys(v).length;if(q>0)console.log(`${e.blue}Loaded ${e.bright}${q} API route${q>1?"s":""}${e.reset}`)}if(B?.broadcasting?.enabled)try{let{startBroadcasting:q,loadChannels:Z}=await import("./chunk-wn2gzwmv.js"),Te=B.broadcasting;await q(Te);let he=Te.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${he}/ws${e.reset}`);let Pe=we.join(process.cwd(),"channels.ts");if(Be.existsSync(Pe))try{let ae=await Z(Pe);console.log(`${e.blue}Loaded ${e.bright}${ae} broadcast channel${ae!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(ae){console.warn(`${e.yellow}Failed to load channels.ts: ${ae.message}${e.reset}`)}}catch(q){console.warn(`${e.yellow}Broadcasting failed to start: ${q.message}${e.reset}`)}}catch{}let{createServerApi:k,isServerApiSource:H}=await import("./chunk-ej1erz2c.js"),D=await k(process.cwd(),C);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${R}/${e.reset}...`),c)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${m}${e.reset}`);let _=Gr({port:R,async fetch(M){return Vt(M,await(async()=>{let B=new URL(M.url);if([h,we.dirname(p),we.join(process.cwd(),"public")].some((ae)=>H(we.join(ae,B.pathname),process.cwd(),C)))return new Response("Not Found",{status:404});if(x)try{let ae=await x.handleRequest(M);if(ae.status!==404)return ae}catch{}if(v[B.pathname])try{return await v[B.pathname](M)}catch(ae){return new Response(JSON.stringify({error:ae.message}),{status:500,headers:{"Content-Type":"application/json"}})}let q=await D(M);if(q)return q;if(B.pathname==="/")return(async()=>{let U=await f(g||"");if(c)U=Ve(U,m);if(s.native)if(U.includes("<head>"))U=U.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(U.includes("<html"))U=U.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 U="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+U;if(s.titlebarHidden)if(U.includes("<head>"))U=U.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(U.includes("<html"))U=U.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 U=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${U}`;return U})().then((U)=>new Response(U,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let Z=we.join(h,B.pathname);if(Be.existsSync(Z)&&Be.statSync(Z).isFile()){let ae=Bun.file(Z),U=we.extname(Z).toLowerCase(),j="text/plain";if(U===".ts"||U===".tsx"){let Fe=new Bun.Transpiler({loader:U===".tsx"?"tsx":"ts"}),Ue=await ae.text(),tt=Fe.transformSync(Ue);return new Response(tt,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(U){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(ae,{headers:{"Content-Type":j}})}let Te=we.dirname(p),he=we.join(Te,B.pathname);if(Be.existsSync(he)&&Be.statSync(he).isFile()){let ae=Bun.file(he),U=we.extname(he).toLowerCase(),j="text/plain";if(U===".ts"||U===".tsx"){let Fe=new Bun.Transpiler({loader:U===".tsx"?"tsx":"ts"}),Ue=await ae.text(),tt=Fe.transformSync(Ue);return new Response(tt,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(U){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(ae,{headers:{"Content-Type":j}})}let Pe=we.join(process.cwd(),"public",B.pathname);if(Be.existsSync(Pe)&&Be.statSync(Pe).isFile()){let ae=Bun.file(Pe),U=we.extname(Pe).toLowerCase(),j="application/octet-stream";if(U===".ts"||U===".tsx"){let Fe=new Bun.Transpiler({loader:U===".tsx"?"tsx":"ts"}),Ue=await ae.text(),tt=Fe.transformSync(Ue);return new Response(tt,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(U){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(ae,{headers:{"Content-Type":j}})}return new Response("Not Found",{status:404})})())},error(M){return new Response(`<pre>${M}
|
|
943
943
|
${M.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
|
|
944
944
|
${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(`
|
|
945
945
|
${e.bright}\u2192 ${e.cyan}http://localhost:${R}/${e.reset}`),console.log(`
|
|
@@ -1426,12 +1426,12 @@ ${v.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),con
|
|
|
1426
1426
|
${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(`
|
|
1427
1427
|
${e.bright}\u2192 ${e.cyan}http://localhost:${y}/${e.reset}`),console.log(`
|
|
1428
1428
|
${e.yellow}Routes:${e.reset}`);let S=new Set(p.map((v)=>v.routeTemplate)),R=Object.entries(m).filter(([v])=>!S.has(v)).sort(([v],[x])=>v.localeCompare(x)).map(([v,x])=>({route:v==="/"?"/":v,filePath:Ee.relative(process.cwd(),x.filePath),fileType:x.fileType}));for(let v of p){let x=v.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");R.push({route:x,filePath:Ee.relative(process.cwd(),v.filePath),fileType:"stx"})}if(R.sort((v,x)=>v.route.localeCompare(x.route)),R.forEach((v,x)=>{let k=x===R.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(`
|
|
1429
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Qe(w.url.toString(),()=>{if(d)Ze.watch(l,{recursive:!0}).close();w.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=Ze.watch(l,{recursive:!0},async(x,C)=>{if(!C)return;if(C.endsWith(".stx")||C.endsWith(".js")||C.endsWith(".ts")||C.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${C}${e.yellow} changed, rebuilding...${e.reset}`),_e.clear(),re(),await h()});process.on("SIGINT",()=>{v.close(),w.stop(),process.exit(0)})}return!0}function ln(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var{serve:Yr}=globalThis.Bun;import be from"fs";import te from"path";async function pn(t){try{return Nt(await Bun.file(t).text())}catch{return}}function Ut(t){let s=Bun.file(t),i=te.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 Hn(t=".",s={}){let i=s.port||3000,d=s.watch!==!1,c=s.hotReload!==!1&&d,l=null,m=s.hmrPort||i+1,p=te.resolve(t),{loadStxConfig:h}=await import("./chunk-1sbj8yqe.js"),g=await h(p),{createServerApi:y,isServerApiSource:w}=await import("./chunk-h5g8k974.js"),S=s.stxOptions?.serverApi??g.serverApi,R=await y(p,S),v=g.root&&g.root!=="."?te.join(p,g.root):p,x=s.pagesDir||g.pagesDir||"pages",C=te.join(v,x);if(!be.existsSync(C)&&!g._layerPageDirs?.some((O)=>be.existsSync(O)))return console.error(`${e.red}Error: No '${x}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${C}${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=L(v,{pagesDir:x,pagesDirs:g._layerPageDirs?[C,...g._layerPageDirs.slice(1)]:void 0});if(k.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${C}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${k.length}${e.blue} routes${e.reset}`);let H=g?._pluginPageDirs||[],D=[];for(let{dir:O,prefix:F}of H)if(be.existsSync(O)){let z=L(te.dirname(O),{pagesDir:te.basename(O)});for(let W of z){let xe=F==="/"?W.pattern:`${F}${W.pattern==="/"?"":W.pattern}`;D.push({route:{...W,pattern:xe},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 _=new Map,E=null,M=null;if(s.stxOptions?.shell!==!1){if(M=await _o(p,s.stxOptions?.shell),M){if(E=await Fr(M,s.stxOptions||{}),E)console.log(`${e.blue}Using app shell: ${e.bright}${te.relative(p,M)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}ct(),await ut(p);let B=lt();if(B.length>0)console.log(`${e.blue}Loaded ${e.bright}${B.length}${e.blue} middleware: ${e.dim}${B.join(", ")}${e.reset}`);let q={},Z=null;try{let{loadStxConfig:O}=await import("./chunk-1sbj8yqe.js"),F=await O(p);if(F?.apiRouter)Z=F?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(F?.apiRoutes){q=F.apiRoutes;let z=Object.keys(q).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:W}=await import("./chunk-wn2gzwmv.js"),xe=F.broadcasting;await z(xe);let ze=xe.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${ze}/ws${e.reset}`);let qe=te.join(process.cwd(),"channels.ts");if(be.existsSync(qe))try{let ee=await W(qe);console.log(`${e.blue}Loaded ${e.bright}${ee} broadcast channel${ee!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(ee){console.warn(`${e.yellow}Failed to load channels.ts: ${ee.message}${e.reset}`)}}catch(z){console.warn(`${e.yellow}Broadcasting failed to start: ${z.message}${e.reset}`)}}catch{}let Te=a(p,"output");be.mkdirSync(Te,{recursive:!0});let he=new Map,Pe=new Set,ae=async(O)=>{let F=Er(C,O);if(!F)return null;try{let z=await Bun.build({entrypoints:[F],outdir:Te,plugins:[it],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...s.stxOptions});if(!z.success)return null;let W=z.outputs.find((xe)=>xe.path.endsWith(".html"));if(!W)return null;return await Bun.file(W.path).text()}catch{return null}},U=new Map,j=async(O,F)=>{try{let{processDirectives:z,extractVariables:W,defaultConfig:xe,loadStxConfig:ze,injectRouterScript:qe}=await import("./chunk-1sbj8yqe.js"),{checkCache:ee,cacheTemplate:Q,readFileCached:V,templateCache:K}=await import("./chunk-wf2wnmjg.js"),Se=await ze(p),Je=(ce)=>{if(!ce)return ce;if(te.isAbsolute(ce))return ce;return te.resolve(p,ce)},A={...xe,...Se,...s.stxOptions,autoShell:!0};if(s.debugDirectives)A.debug=!0;A.partialsDir=Je(A.partialsDir),A.componentsDir=Je(A.componentsDir),A.layoutsDir=Je(A.layoutsDir),A.storesDir=Je(A.storesDir||"stores"),A.cachePath=Je(A.cachePath)??a(p,"cache");let ye=!F&&!s.profile,le=A.cache!==!1;if(le&&ye){let ce=K.get(O.filePath);if(ce)try{if((await be.promises.stat(O.filePath)).mtime.getTime()<=ce.mtime){let He=!0;for(let Ce of ce.dependencies){if(!be.existsSync(Ce)){He=!1;break}if((await be.promises.stat(Ce)).mtime.getTime()>ce.mtime){He=!1;break}}if(He){let Ce=ce.output;if(E)Ce=ve(Ce,{preserveHead:!0});let gt=U.get(O.filePath);return{route:O,content:Ce,status:gt?.status??await pn(O.filePath),headers:gt?.headers}}}}catch{}let Ie=await ee(O.filePath,A);if(Ie){let je=Ie;if(E)je=ve(je,{preserveHead:!0});let He=U.get(O.filePath);return{route:O,content:je,status:He?.status??await pn(O.filePath),headers:He?.headers}}}let me=le?await V(O.filePath):await Bun.file(O.filePath).text(),$e=Nt(me),{classifyAllScripts:X}=await import("./chunk-1sbj8yqe.js"),Me=X(me),Ne=Me.server.map((ce)=>ce.content),de=me;for(let ce of Me.server)de=de.replace(ce.fullTag,"");let pe={__filename:O.filePath,__dirname:te.dirname(O.filePath),__stx_options:A,params:F??{},__stx_runtime_head:{}};for(let ce of Ne)try{await W(ce,pe,O.filePath)}catch(Ie){if(s.stxOptions?.debug)console.error("[stx] variable extraction error",O.filePath,Ie?.message||Ie)}let We=new Set,Oe;if(s.profile){let ce=performance.now();Oe=await z(de,pe,O.filePath,A,We);let Ie=performance.now()-ce,je=te.relative(p,O.filePath)||O.filePath;console.log(`[stx:profile] ${je} \u2192 ${Ie.toFixed(2)}ms`)}else Oe=await z(de,pe,O.filePath,A,We);if(!E)Oe=await qe(Oe,{router:A.router});{let{interpolateScriptExpressions:ce}=await import("./chunk-bpz3yv92.js");Oe=Oe.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ie,je,He)=>{if(!/function\s+__stx_setup_/.test(He))return Ie;return`<script${je}>${ce(He,pe)}</script>`})}if(E)Oe=ve(Oe,{preserveHead:!0});if(le&&ye)await Q(O.filePath,Oe,We,A);let{extractStreamBoundaries:Kn}=await import("./chunk-djqmzzn6.js"),nt=Kn(pe),mt=pe.__streamTemplates;if(mt&&typeof mt==="object"&&Object.keys(mt).length>0){let ce=pe.streamBoundaries||{},Ie={...A,autoShell:!1},je=Object.keys(mt).map((Ce)=>({id:Ce,render:async()=>{let gt=typeof ce[Ce]==="function"?await ce[Ce]():void 0;return z(mt[Ce],{...pe,$boundary:gt},O.filePath,Ie,new Set)}})),He=new Set(je.map((Ce)=>Ce.id));nt=[...(nt||[]).filter((Ce)=>!He.has(Ce.id)),...je]}if(nt&&nt.length>0)Pe.add(O.pattern);else nt=void 0;let Kt=Ke(pe),Xt=Xe(pe);if(ye)U.set(O.filePath,{status:Kt,headers:Xt});return{route:O,content:Oe,status:Kt??$e,headers:Xt,boundaries:nt}}catch(z){return console.error(`${e.red}Error building ${e.bright}${O.pattern}${e.reset}:`,z),null}},Fe=8,Ue=async()=>{he.clear(),_.clear();for(let O=0;O<k.length;O+=Fe){let F=k.slice(O,O+Fe),z=await Promise.all(F.map((W)=>j(W)));for(let W of z)if(W)he.set(W.route.pattern,W)}for(let O=0;O<D.length;O+=Fe){let F=D.slice(O,O+Fe),z=await Promise.all(F.map(({route:W})=>j(W)));for(let W of z)if(W)_.set(W.route.pattern,W)}return he.size>0};if(console.log(`${e.blue}Building pages...${e.reset}`),!await Ue())return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await Dt(p);let et=i;try{if(et=await Ye(i),et!==i)console.log(`${e.yellow}Port ${i} is busy, using port ${et} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let O=s.hmrPort||et+1;l=Et({wsPort:O,verbose:!1}),m=l.start(O)}let At=(O,F)=>{let W=`<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(O.includes("</head>"))return O.replace("</head>",`${W}</head>`);if(O.includes("<body"))return O.replace(/<body([^>]*)>/,`<body$1>${W}`);return W+O};console.log(`${e.blue}Starting server...${e.reset}`);let Mt=Yr({port:et,async fetch(O){let F=new URL(O.url),z=g?.publicDir||"public",W=te.join(p,z,F.pathname),xe=te.join(p,F.pathname),ze=te.join(Te,F.pathname);if([W,xe,ze].some((A)=>w(A,p,S)))return new Response("Not Found",{status:404});let[qe,ee,Q]=await Promise.all([be.promises.stat(W).catch(()=>null),be.promises.stat(xe).catch(()=>null),be.promises.stat(ze).catch(()=>null)]);if(qe?.isFile()&&!w(W,p,S))return Ut(W);if(ee?.isFile()&&!w(xe,p,S))return Ut(xe);if(Q?.isFile()&&!w(ze,p,S))return Ut(ze);if(F.pathname.startsWith("/_stx/component/")){let A=decodeURIComponent(F.pathname.slice(16));if(A)try{let ye=`<${A} />`,le={...buildConfig,autoShell:!1},me=await processDirectives(ye,{},te.join(p,"components",`${A}.stx`),le,new Set);return new Response(me,{headers:{"Content-Type":"text/html"}})}catch(ye){return new Response(`<div class="stx-async-error">${ye.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(F.pathname==="/_stx/img"){let{handleImageRequest:A}=await import("./chunk-jyqanvwp.js"),ye=await A(O,{publicDir:te.join(p,z),cacheDir:a(p,"cache","img")});if(ye)return ye}if(Z)try{let A=await Z.handleRequest(O);if(A.status!==404)return A}catch{}if(q[F.pathname])try{return await q[F.pathname](O)}catch(A){return new Response(JSON.stringify({error:A.message}),{status:500,headers:{"Content-Type":"application/json"}})}let V=await R(O);if(V)return V;let K=Ln(F.pathname,k);if(K){let A=he.get(K.route.pattern),ye=Pe.has(K.route.pattern);if(K.route.isDynamic&&Object.keys(K.params).length>0||ye){let le=await j(K.route,K.params);if(le)A=le}if(A){let le=A.status??200,me=A.headers??{},$e=(K.route.filePath?Ge(await Bun.file(K.route.filePath).text().catch(()=>"")):null)??{};if($e.validate){if(!await $e.validate({params:K.params})){let Ne=await ae(404);if(Ne){let de=Ne;if(de=await f(de,p),c)de=Ve(de,m);return new Response(de,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if($e.middleware){let Me=dt(F.pathname,K.params,$e,F.search),Ne=pt(Me,null,O,{isServer:!0}),de=await ft($e.middleware,Ne);if(de.redirect){let pe=de.redirect.path,We=de.redirect.options.redirectCode||302,Oe=new Headers(de.responseHeaders);return Oe.set("Location",pe),new Response(null,{status:We,headers:Oe})}if(de.abort){let{statusCode:pe,message:We}=de.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${pe}</title></head><body><h1>Error ${pe}</h1><p>${We}</p></body></html>`,{status:pe,headers:{"Content-Type":"text/html"}})}if(Object.keys(de.state).length>0){let pe=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(de.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;A.content=A.content.replace("</head>",`${pe}</head>`)}}let X=A.content;if(E&&Eo(O)){let Me=Ae(X),Ne=fe(X),de=X.match(/<title[^>]*>([\s\S]*?)<\/title>/i),pe=de?Co(de[1].trim()):"";if(Object.keys(K.params).length>0)X=At(X,K.params);X=await f(X,p);let We=g?.router?.container||"main";return X=ie(X,We),new Response(X,{status:le,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Me.layout,"X-STX-Layout-Group":Me.group,"X-STX-Runtime":Ne?"true":"false",...pe&&{"X-STX-Title":encodeURIComponent(pe)},[Ri]:Os(),...T(),"Cache-Control":Le}})}if(E)X=qn(E,X);if(Object.keys(K.params).length>0)X=At(X,K.params);if(X=await f(X,p),c)X=Ve(X,m);if(s.native)if(X.includes("<head>"))X=X.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 X="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+X;if(s.titlebarHidden)if(X.includes("<head>"))X=X.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 X=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${X}`;if(A.boundaries&&A.boundaries.length>0){let{renderStreamingPage:Me,streamToResponse:Ne}=await import("./chunk-djqmzzn6.js");return Ne(Me(X,A.boundaries,{timeoutMs:30000}),{status:le,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(X,{status:le,headers:{"Content-Type":"text/html",...T(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...me}})}}if(D.length>0){let A=D.map((le)=>le.route),ye=Ln(F.pathname,A);if(ye){let le=_.get(ye.route.pattern);if(le){let me=le.content;if(E)me=qn(E,me);if(Object.keys(ye.params).length>0)me=At(me,ye.params);if(me=await f(me,p),c)me=Ve(me,m);return new Response(me,{status:le.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:le}of H)if(le!=="/"&&F.pathname.startsWith(le)){let me=_.get(le)||_.get(le+"/");if(me){let $e=me.content;if(E)$e=qn(E,$e);if($e=await f($e,p),c)$e=Ve($e,m);return new Response($e,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(at(F.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let Se=he.get("/");if(Se){let A=Se.content;if(A=await f(A,p),c)A=Ve(A,m);if(s.native)if(A.includes("<head>"))A=A.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 A="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+A;return new Response(A,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let Je=await ae(404);if(Je){let A=Je;if(A=await f(A,p),c)A=Ve(A,m);return new Response(A,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(O){let F=await ae(500);if(F)return new Response(F,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${O}
|
|
1429
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Qe(w.url.toString(),()=>{if(d)Ze.watch(l,{recursive:!0}).close();w.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let v=Ze.watch(l,{recursive:!0},async(x,C)=>{if(!C)return;if(C.endsWith(".stx")||C.endsWith(".js")||C.endsWith(".ts")||C.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${C}${e.yellow} changed, rebuilding...${e.reset}`),_e.clear(),re(),await h()});process.on("SIGINT",()=>{v.close(),w.stop(),process.exit(0)})}return!0}function ln(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var{serve:Yr}=globalThis.Bun;import be from"fs";import te from"path";async function pn(t){try{return Nt(await Bun.file(t).text())}catch{return}}function Ut(t){let s=Bun.file(t),i=te.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 Hn(t=".",s={}){let i=s.port||3000,d=s.watch!==!1,c=s.hotReload!==!1&&d,l=null,m=s.hmrPort||i+1,p=te.resolve(t),{loadStxConfig:h}=await import("./chunk-knngjd2r.js"),g=await h(p),{createServerApi:y,isServerApiSource:w}=await import("./chunk-ej1erz2c.js"),S=s.stxOptions?.serverApi??g.serverApi,R=await y(p,S),v=g.root&&g.root!=="."?te.join(p,g.root):p,x=s.pagesDir||g.pagesDir||"pages",C=te.join(v,x);if(!be.existsSync(C)&&!g._layerPageDirs?.some((O)=>be.existsSync(O)))return console.error(`${e.red}Error: No '${x}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${C}${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=L(v,{pagesDir:x,pagesDirs:g._layerPageDirs?[C,...g._layerPageDirs.slice(1)]:void 0});if(k.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${C}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${k.length}${e.blue} routes${e.reset}`);let H=g?._pluginPageDirs||[],D=[];for(let{dir:O,prefix:F}of H)if(be.existsSync(O)){let z=L(te.dirname(O),{pagesDir:te.basename(O)});for(let W of z){let xe=F==="/"?W.pattern:`${F}${W.pattern==="/"?"":W.pattern}`;D.push({route:{...W,pattern:xe},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 _=new Map,E=null,M=null;if(s.stxOptions?.shell!==!1){if(M=await _o(p,s.stxOptions?.shell),M){if(E=await Fr(M,s.stxOptions||{}),E)console.log(`${e.blue}Using app shell: ${e.bright}${te.relative(p,M)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}ct(),await ut(p);let B=lt();if(B.length>0)console.log(`${e.blue}Loaded ${e.bright}${B.length}${e.blue} middleware: ${e.dim}${B.join(", ")}${e.reset}`);let q={},Z=null;try{let{loadStxConfig:O}=await import("./chunk-knngjd2r.js"),F=await O(p);if(F?.apiRouter)Z=F?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(F?.apiRoutes){q=F.apiRoutes;let z=Object.keys(q).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:W}=await import("./chunk-wn2gzwmv.js"),xe=F.broadcasting;await z(xe);let ze=xe.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${ze}/ws${e.reset}`);let qe=te.join(process.cwd(),"channels.ts");if(be.existsSync(qe))try{let ee=await W(qe);console.log(`${e.blue}Loaded ${e.bright}${ee} broadcast channel${ee!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(ee){console.warn(`${e.yellow}Failed to load channels.ts: ${ee.message}${e.reset}`)}}catch(z){console.warn(`${e.yellow}Broadcasting failed to start: ${z.message}${e.reset}`)}}catch{}let Te=a(p,"output");be.mkdirSync(Te,{recursive:!0});let he=new Map,Pe=new Set,ae=async(O)=>{let F=Er(C,O);if(!F)return null;try{let z=await Bun.build({entrypoints:[F],outdir:Te,plugins:[it],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...s.stxOptions});if(!z.success)return null;let W=z.outputs.find((xe)=>xe.path.endsWith(".html"));if(!W)return null;return await Bun.file(W.path).text()}catch{return null}},U=new Map,j=async(O,F)=>{try{let{processDirectives:z,extractVariables:W,defaultConfig:xe,loadStxConfig:ze,injectRouterScript:qe}=await import("./chunk-knngjd2r.js"),{checkCache:ee,cacheTemplate:Q,readFileCached:V,templateCache:K}=await import("./chunk-qhxf7pxh.js"),Se=await ze(p),Je=(ce)=>{if(!ce)return ce;if(te.isAbsolute(ce))return ce;return te.resolve(p,ce)},A={...xe,...Se,...s.stxOptions,autoShell:!0};if(s.debugDirectives)A.debug=!0;A.partialsDir=Je(A.partialsDir),A.componentsDir=Je(A.componentsDir),A.layoutsDir=Je(A.layoutsDir),A.storesDir=Je(A.storesDir||"stores"),A.cachePath=Je(A.cachePath)??a(p,"cache");let ye=!F&&!s.profile,le=A.cache!==!1;if(le&&ye){let ce=K.get(O.filePath);if(ce)try{if((await be.promises.stat(O.filePath)).mtime.getTime()<=ce.mtime){let He=!0;for(let Ce of ce.dependencies){if(!be.existsSync(Ce)){He=!1;break}if((await be.promises.stat(Ce)).mtime.getTime()>ce.mtime){He=!1;break}}if(He){let Ce=ce.output;if(E)Ce=ve(Ce,{preserveHead:!0});let gt=U.get(O.filePath);return{route:O,content:Ce,status:gt?.status??await pn(O.filePath),headers:gt?.headers}}}}catch{}let Ie=await ee(O.filePath,A);if(Ie){let je=Ie;if(E)je=ve(je,{preserveHead:!0});let He=U.get(O.filePath);return{route:O,content:je,status:He?.status??await pn(O.filePath),headers:He?.headers}}}let me=le?await V(O.filePath):await Bun.file(O.filePath).text(),$e=Nt(me),{classifyAllScripts:X}=await import("./chunk-knngjd2r.js"),Me=X(me),Ne=Me.server.map((ce)=>ce.content),de=me;for(let ce of Me.server)de=de.replace(ce.fullTag,"");let pe={__filename:O.filePath,__dirname:te.dirname(O.filePath),__stx_options:A,params:F??{},__stx_runtime_head:{}};for(let ce of Ne)try{await W(ce,pe,O.filePath)}catch(Ie){if(s.stxOptions?.debug)console.error("[stx] variable extraction error",O.filePath,Ie?.message||Ie)}let We=new Set,Oe;if(s.profile){let ce=performance.now();Oe=await z(de,pe,O.filePath,A,We);let Ie=performance.now()-ce,je=te.relative(p,O.filePath)||O.filePath;console.log(`[stx:profile] ${je} \u2192 ${Ie.toFixed(2)}ms`)}else Oe=await z(de,pe,O.filePath,A,We);if(!E)Oe=await qe(Oe,{router:A.router});{let{interpolateScriptExpressions:ce}=await import("./chunk-makn68zy.js");Oe=Oe.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ie,je,He)=>{if(!/function\s+__stx_setup_/.test(He))return Ie;return`<script${je}>${ce(He,pe)}</script>`})}if(E)Oe=ve(Oe,{preserveHead:!0});if(le&&ye)await Q(O.filePath,Oe,We,A);let{extractStreamBoundaries:Kn}=await import("./chunk-hjh1a3ga.js"),nt=Kn(pe),mt=pe.__streamTemplates;if(mt&&typeof mt==="object"&&Object.keys(mt).length>0){let ce=pe.streamBoundaries||{},Ie={...A,autoShell:!1},je=Object.keys(mt).map((Ce)=>({id:Ce,render:async()=>{let gt=typeof ce[Ce]==="function"?await ce[Ce]():void 0;return z(mt[Ce],{...pe,$boundary:gt},O.filePath,Ie,new Set)}})),He=new Set(je.map((Ce)=>Ce.id));nt=[...(nt||[]).filter((Ce)=>!He.has(Ce.id)),...je]}if(nt&&nt.length>0)Pe.add(O.pattern);else nt=void 0;let Kt=Ke(pe),Xt=Xe(pe);if(ye)U.set(O.filePath,{status:Kt,headers:Xt});return{route:O,content:Oe,status:Kt??$e,headers:Xt,boundaries:nt}}catch(z){return console.error(`${e.red}Error building ${e.bright}${O.pattern}${e.reset}:`,z),null}},Fe=8,Ue=async()=>{he.clear(),_.clear();for(let O=0;O<k.length;O+=Fe){let F=k.slice(O,O+Fe),z=await Promise.all(F.map((W)=>j(W)));for(let W of z)if(W)he.set(W.route.pattern,W)}for(let O=0;O<D.length;O+=Fe){let F=D.slice(O,O+Fe),z=await Promise.all(F.map(({route:W})=>j(W)));for(let W of z)if(W)_.set(W.route.pattern,W)}return he.size>0};if(console.log(`${e.blue}Building pages...${e.reset}`),!await Ue())return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await Dt(p);let et=i;try{if(et=await Ye(i),et!==i)console.log(`${e.yellow}Port ${i} is busy, using port ${et} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(c){let O=s.hmrPort||et+1;l=Et({wsPort:O,verbose:!1}),m=l.start(O)}let At=(O,F)=>{let W=`<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(O.includes("</head>"))return O.replace("</head>",`${W}</head>`);if(O.includes("<body"))return O.replace(/<body([^>]*)>/,`<body$1>${W}`);return W+O};console.log(`${e.blue}Starting server...${e.reset}`);let Mt=Yr({port:et,async fetch(O){let F=new URL(O.url),z=g?.publicDir||"public",W=te.join(p,z,F.pathname),xe=te.join(p,F.pathname),ze=te.join(Te,F.pathname);if([W,xe,ze].some((A)=>w(A,p,S)))return new Response("Not Found",{status:404});let[qe,ee,Q]=await Promise.all([be.promises.stat(W).catch(()=>null),be.promises.stat(xe).catch(()=>null),be.promises.stat(ze).catch(()=>null)]);if(qe?.isFile()&&!w(W,p,S))return Ut(W);if(ee?.isFile()&&!w(xe,p,S))return Ut(xe);if(Q?.isFile()&&!w(ze,p,S))return Ut(ze);if(F.pathname.startsWith("/_stx/component/")){let A=decodeURIComponent(F.pathname.slice(16));if(A)try{let ye=`<${A} />`,le={...buildConfig,autoShell:!1},me=await processDirectives(ye,{},te.join(p,"components",`${A}.stx`),le,new Set);return new Response(me,{headers:{"Content-Type":"text/html"}})}catch(ye){return new Response(`<div class="stx-async-error">${ye.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(F.pathname==="/_stx/img"){let{handleImageRequest:A}=await import("./chunk-jyqanvwp.js"),ye=await A(O,{publicDir:te.join(p,z),cacheDir:a(p,"cache","img")});if(ye)return ye}if(Z)try{let A=await Z.handleRequest(O);if(A.status!==404)return A}catch{}if(q[F.pathname])try{return await q[F.pathname](O)}catch(A){return new Response(JSON.stringify({error:A.message}),{status:500,headers:{"Content-Type":"application/json"}})}let V=await R(O);if(V)return V;let K=Ln(F.pathname,k);if(K){let A=he.get(K.route.pattern),ye=Pe.has(K.route.pattern);if(K.route.isDynamic&&Object.keys(K.params).length>0||ye){let le=await j(K.route,K.params);if(le)A=le}if(A){let le=A.status??200,me=A.headers??{},$e=(K.route.filePath?Ge(await Bun.file(K.route.filePath).text().catch(()=>"")):null)??{};if($e.validate){if(!await $e.validate({params:K.params})){let Ne=await ae(404);if(Ne){let de=Ne;if(de=await f(de,p),c)de=Ve(de,m);return new Response(de,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if($e.middleware){let Me=dt(F.pathname,K.params,$e,F.search),Ne=pt(Me,null,O,{isServer:!0}),de=await ft($e.middleware,Ne);if(de.redirect){let pe=de.redirect.path,We=de.redirect.options.redirectCode||302,Oe=new Headers(de.responseHeaders);return Oe.set("Location",pe),new Response(null,{status:We,headers:Oe})}if(de.abort){let{statusCode:pe,message:We}=de.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${pe}</title></head><body><h1>Error ${pe}</h1><p>${We}</p></body></html>`,{status:pe,headers:{"Content-Type":"text/html"}})}if(Object.keys(de.state).length>0){let pe=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(de.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;A.content=A.content.replace("</head>",`${pe}</head>`)}}let X=A.content;if(E&&Eo(O)){let Me=Ae(X),Ne=fe(X),de=X.match(/<title[^>]*>([\s\S]*?)<\/title>/i),pe=de?Co(de[1].trim()):"";if(Object.keys(K.params).length>0)X=At(X,K.params);X=await f(X,p);let We=g?.router?.container||"main";return X=ie(X,We),new Response(X,{status:le,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Me.layout,"X-STX-Layout-Group":Me.group,"X-STX-Runtime":Ne?"true":"false",...pe&&{"X-STX-Title":encodeURIComponent(pe)},[Ri]:Os(),...T(),"Cache-Control":Le}})}if(E)X=qn(E,X);if(Object.keys(K.params).length>0)X=At(X,K.params);if(X=await f(X,p),c)X=Ve(X,m);if(s.native)if(X.includes("<head>"))X=X.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 X="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+X;if(s.titlebarHidden)if(X.includes("<head>"))X=X.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 X=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${X}`;if(A.boundaries&&A.boundaries.length>0){let{renderStreamingPage:Me,streamToResponse:Ne}=await import("./chunk-hjh1a3ga.js");return Ne(Me(X,A.boundaries,{timeoutMs:30000}),{status:le,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(X,{status:le,headers:{"Content-Type":"text/html",...T(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...me}})}}if(D.length>0){let A=D.map((le)=>le.route),ye=Ln(F.pathname,A);if(ye){let le=_.get(ye.route.pattern);if(le){let me=le.content;if(E)me=qn(E,me);if(Object.keys(ye.params).length>0)me=At(me,ye.params);if(me=await f(me,p),c)me=Ve(me,m);return new Response(me,{status:le.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:le}of H)if(le!=="/"&&F.pathname.startsWith(le)){let me=_.get(le)||_.get(le+"/");if(me){let $e=me.content;if(E)$e=qn(E,$e);if($e=await f($e,p),c)$e=Ve($e,m);return new Response($e,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(at(F.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let Se=he.get("/");if(Se){let A=Se.content;if(A=await f(A,p),c)A=Ve(A,m);if(s.native)if(A.includes("<head>"))A=A.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 A="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+A;return new Response(A,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let Je=await ae(404);if(Je){let A=Je;if(A=await f(A,p),c)A=Ve(A,m);return new Response(A,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(O){let F=await ae(500);if(F)return new Response(F,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${O}
|
|
1430
1430
|
${O.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
|
|
1431
1431
|
${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(`
|
|
1432
1432
|
${e.bright}\u2192 ${e.cyan}http://localhost:${et}/${e.reset}`),c)console.log(`${e.dim} HMR: ws://localhost:${m}${e.reset}`);console.log(`
|
|
1433
1433
|
${e.yellow}Routes:${e.reset}`);let _t=[...Tr(k,p)];for(let{route:O}of D)_t.push(`${O.pattern}`);if(_t.forEach((O,F)=>{let W=F===_t.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${e.green}${W}${e.reset}${O}`)}),console.log(`
|
|
1434
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Qe(Mt.url.toString(),()=>{if(l)ht();Mt.stop()}),s.native){let O,F=te.join(C,"index.stx");if(be.existsSync(F)){let W=await Bun.file(F).text();O=Tt(W)}let z=g?.app?.window??{};await rt(et,{title:g?.app?.head?.title||te.basename(p)||"stx App",width:z.width,height:z.height,darkMode:z.darkMode,hotReload:z.hotReload,titlebarHidden:z.titlebarHidden??s.titlebarHidden===!0,nativeSidebar:!!O,sidebarConfig:O})}if(d){console.log(`${e.blue}Watching for changes...${e.reset}`);let O=(ee)=>ee.startsWith("public/")||ee.startsWith("public\\"),F=(ee)=>{let Q=ee.toLowerCase();return Q.endsWith(".stx")||Q.endsWith(".html")||Q.endsWith(".md")},z=new Map,W=()=>{let ee=new Set([p,...g._layerGraph?.layers.map((Q)=>Q.root)??[],...g._layerGraph?.configDependencies.map((Q)=>te.dirname(Q))??[]].filter((Q)=>be.existsSync(Q)).map((Q)=>be.realpathSync(Q)));for(let Q of g._layerGraph?.layers??[])for(let V of Object.values(Q.resources)){if(!be.existsSync(V))continue;let K=be.realpathSync(V);if(![...ee].some((Se)=>K===Se||K.startsWith(`${Se}${te.sep}`)))ee.add(K)}for(let[Q,V]of z)if(!ee.has(Q))V.close(),z.delete(Q);for(let Q of ee)if(!z.has(Q)&&be.existsSync(Q))z.set(Q,be.watch(Q,{recursive:!0},(V,K)=>{ze(Q,V,K).catch((Se)=>console.error("[stx] Layer rebuild failed:",Se))}))},xe=Promise.resolve(),ze=(ee,Q,V)=>(xe=xe.catch(()=>{}).then(()=>qe(ee,Q,V)),xe),qe=async(ee,Q,V)=>{if(!V||Rt(V))return;if(Ct(V)){if(g._layerGraph){let K=await h(p);Object.assign(g,K),k.splice(0,k.length,...L(v,{pagesDir:x,pagesDirs:K._layerPageDirs?[C,...K._layerPageDirs.slice(1)]:void 0})),W()}if(O(V)){if(console.log(`${e.cyan}${V} changed${e.reset}`),c&&l)l.reload(V)}else if(F(V)){console.log(`${e.yellow}${V} changed, rebuilding...${e.reset}`),_e.clear(),re();try{let{invalidateFileCache:K,templateCache:Se}=await import("./chunk-
|
|
1434
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Qe(Mt.url.toString(),()=>{if(l)ht();Mt.stop()}),s.native){let O,F=te.join(C,"index.stx");if(be.existsSync(F)){let W=await Bun.file(F).text();O=Tt(W)}let z=g?.app?.window??{};await rt(et,{title:g?.app?.head?.title||te.basename(p)||"stx App",width:z.width,height:z.height,darkMode:z.darkMode,hotReload:z.hotReload,titlebarHidden:z.titlebarHidden??s.titlebarHidden===!0,nativeSidebar:!!O,sidebarConfig:O})}if(d){console.log(`${e.blue}Watching for changes...${e.reset}`);let O=(ee)=>ee.startsWith("public/")||ee.startsWith("public\\"),F=(ee)=>{let Q=ee.toLowerCase();return Q.endsWith(".stx")||Q.endsWith(".html")||Q.endsWith(".md")},z=new Map,W=()=>{let ee=new Set([p,...g._layerGraph?.layers.map((Q)=>Q.root)??[],...g._layerGraph?.configDependencies.map((Q)=>te.dirname(Q))??[]].filter((Q)=>be.existsSync(Q)).map((Q)=>be.realpathSync(Q)));for(let Q of g._layerGraph?.layers??[])for(let V of Object.values(Q.resources)){if(!be.existsSync(V))continue;let K=be.realpathSync(V);if(![...ee].some((Se)=>K===Se||K.startsWith(`${Se}${te.sep}`)))ee.add(K)}for(let[Q,V]of z)if(!ee.has(Q))V.close(),z.delete(Q);for(let Q of ee)if(!z.has(Q)&&be.existsSync(Q))z.set(Q,be.watch(Q,{recursive:!0},(V,K)=>{ze(Q,V,K).catch((Se)=>console.error("[stx] Layer rebuild failed:",Se))}))},xe=Promise.resolve(),ze=(ee,Q,V)=>(xe=xe.catch(()=>{}).then(()=>qe(ee,Q,V)),xe),qe=async(ee,Q,V)=>{if(!V||Rt(V))return;if(Ct(V)){if(g._layerGraph){let K=await h(p);Object.assign(g,K),k.splice(0,k.length,...L(v,{pagesDir:x,pagesDirs:K._layerPageDirs?[C,...K._layerPageDirs.slice(1)]:void 0})),W()}if(O(V)){if(console.log(`${e.cyan}${V} changed${e.reset}`),c&&l)l.reload(V)}else if(F(V)){console.log(`${e.yellow}${V} changed, rebuilding...${e.reset}`),_e.clear(),re();try{let{invalidateFileCache:K,templateCache:Se}=await import("./chunk-qhxf7pxh.js");K(te.resolve(ee,V)),Se.delete(te.resolve(ee,V))}catch{}if(M&&V){if(te.resolve(ee,V)===M||te.basename(M)===V){let Se=await Fr(M,s.stxOptions||{});if(Se)E=Se}}if(await Ue(),await wn(p),c&&l)l.reload(V)}else{console.log(`${e.yellow}${V} changed, rebuilding...${e.reset}`),_e.clear(),re();try{let{invalidateFileCache:K,templateCache:Se}=await import("./chunk-qhxf7pxh.js");K(te.resolve(ee,V)),Se.delete(te.resolve(ee,V))}catch{}if(await Ue(),c&&l)l.reload(V)}}else if($t(V)){if(console.log(`${e.cyan}CSS ${V} changed${e.reset}`),c&&l)l.updateCss(V)}};W(),process.on("SIGINT",()=>{for(let ee of z.values())ee.close();if(l)ht();Mt.stop(),process.exit(0)})}return!0}import Wt from"fs";import yt from"path";async function Qr(t){try{let i=(await Bun.file(t).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!i)return[];let d=i[1],c=[],l=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,m;while((m=l.exec(d))!==null){let p=m[1],h=m[2]||m[3]||m[4];if(!h)continue;let g={name:h},y=p.match(/@type\s+\{([^}]+)\}/i);if(y)g.type=y[1].trim();if(p.match(/@required/i))g.required=!0;let S=p.match(/@default\s+(.+?)(?:\s+|$)/i);if(S)g.default=S[1].trim();let R=p.split(`
|
|
1435
1435
|
`).map((v)=>v.trim().replace(/^\*\s*/,"")).filter((v)=>!v.startsWith("@")&&v.length>0);g.description=R.join(" ").trim(),c.push(g)}if(c.length===0){let p=d.match(/module\.exports\s*=\s*\{([^}]+)\}/i);if(p){let g=p[1].split(",").map((y)=>y.trim()).filter(Boolean);for(let y of g){let[w]=y.split(":").map((S)=>S.trim());if(w)c.push({name:w})}}}return c}catch(s){return console.error(`Error extracting props from ${t}:`,s),[]}}async function Zr(t){try{let s=await Bun.file(t).text(),i=s.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||s.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//);if(i)return i[1].split(`
|
|
1436
1436
|
`).map((d)=>d.trim().replace(/^\*\s*/,"")).join(" ").trim();return""}catch{return""}}async function eo(t,s=!1,i){let d=yt.basename(t,".stx"),c=await Qr(t),l=await Zr(t),m="";if(s&&i)m=`<${i}></${i}>`;else{let p=c.map((h)=>{if(h.type==="boolean")return`:${h.name}="true"`;return`${h.name}="value"`}).join(`
|
|
1437
1437
|
`);m=`<${d}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Qr,Zl,Ql}from"./chunk-navkh35g.js";import"./chunk-sqq6kpve.js";import"./chunk-x7epxhsz.js";import"./chunk-tds3d65g.js";import"./chunk-atqnvmea.js";import"./chunk-t19th11m.js";import"./chunk-v8ze2q95.js";import"./chunk-k71e38fk.js";import"./chunk-813wwkap.js";import"./chunk-48s1nprc.js";import"./chunk-qf39z0hg.js";import"./chunk-gh181dnr.js";import"./chunk-38mt83wa.js";import"./chunk-jtq8e3b0.js";import"./chunk-b3c1gggs.js";import"./chunk-tt1p6zt8.js";import"./chunk-82bttwqm.js";export{Ql as clearComposableCache,Zl as getComposableScript,Qr as listComposableModules};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ca,la}from"./chunk-jg8w43n0.js";import"./chunk-279b1228.js";import"./chunk-afnj003j.js";import"./chunk-tc3ne706.js";import"./chunk-g6ew2drc.js";import"./chunk-hrv206vt.js";import"./chunk-4h58as2c.js";import"./chunk-h8a8y1wh.js";import{ko}from"./chunk-btbdp4fg.js";import"./chunk-hsy9rhct.js";import"./chunk-f17rcvdb.js";import"./chunk-h5cgm4hy.js";import"./chunk-tnafnb23.js";import"./chunk-nb0ytx70.js";import"./chunk-n633zv27.js";import"./chunk-1944jgb2.js";import"./chunk-gzpxvca7.js";import"./chunk-y09g63k0.js";import"./chunk-bsy10tz6.js";import"./chunk-htcptqtn.js";import"./chunk-wkxzzdzs.js";import"./chunk-bfbmdjh4.js";import"./chunk-navkh35g.js";import"./chunk-hz11wmx9.js";import"./chunk-q1cvef6b.js";import"./chunk-axz1x4r9.js";import"./chunk-h7atbtds.js";import"./chunk-8s7zbhdd.js";import"./chunk-kty4k2jq.js";import"./chunk-vn6h03nq.js";import"./chunk-f49nnf8v.js";import"./chunk-fkh9zshs.js";import"./chunk-y0qjpcc8.js";import"./chunk-zrw1zf54.js";import"./chunk-sqq6kpve.js";import"./chunk-x7epxhsz.js";import"./chunk-tds3d65g.js";import{xe,hn,yn,J,u,n,dr,A,o,ge}from"./chunk-atqnvmea.js";import"./chunk-t19th11m.js";import"./chunk-v8ze2q95.js";import"./chunk-k71e38fk.js";import"./chunk-813wwkap.js";import"./chunk-48s1nprc.js";import"./chunk-qf39z0hg.js";import"./chunk-gh181dnr.js";import"./chunk-38mt83wa.js";import"./chunk-jtq8e3b0.js";import"./chunk-b3c1gggs.js";import"./chunk-tt1p6zt8.js";import"./chunk-82bttwqm.js";export{dr as buildWebComponents,yn as cacheTemplate,hn as checkCache,ko as classifyAllScripts,ca as createMiddleware,la as createRoute,A as defaultConfig,u as extractVariables,J as injectRouterScript,o as loadStxConfig,xe as processClientScript,n as processDirectives,ge as readMarkdownFile};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{y}from"./chunk-b3c1gggs.js";import{O,zt}from"./chunk-jtq8e3b0.js";import{w,Ye,j,o}from"./chunk-
|
|
2
|
+
import{y}from"./chunk-b3c1gggs.js";import{O,zt}from"./chunk-jtq8e3b0.js";import{w,Ye,j,o}from"./chunk-atqnvmea.js";import{le,_t,Et,Tt}from"./chunk-sqq6kpve.js";import{Be,rn,wt,U}from"./chunk-eqa0wdv9.js";import{E,Nn}from"./chunk-zvs13kgh.js";import p from"path";var a=new Map;function A(c,n){for(let s of c.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(s[1])n.add(s[1]);for(let s of c.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let i of(s[1]??"").split(",")){let l=((i.includes(":")?i.split(":").pop():i)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(l))n.add(l)}for(let s of c.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let i of(s[1]??"").split(",")){let r=i.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(r))n.add(r)}}async function vu(c){let n;if(c)n=p.resolve(c);else{let t=await o();n=p.resolve(t.root||process.cwd(),t.storesDir||"stores")}let s=`${n}\x00${Et()}`,i=new Bun.Glob("*.ts"),r=[];try{for await(let t of i.scan({cwd:n,absolute:!0})){let e=p.basename(t,".ts");if(["index","types"].includes(e))continue;if(t.includes(".d.ts"))continue;r.push(t)}}catch{return U(a,s,"",""),null}let l=()=>[...new Set([...r,...r.flatMap((t)=>le(t))])],f=Be(l()),d=wt(a,s,f);if(d!==void 0)return d||null;if(r.length===0)return U(a,s,f,""),null;let u=[];for(let t of r){let e=await Bun.file(t).text();u.push({file:t,hasUseStore:/useStore\s*\(/.test(e)})}u.sort((t,e)=>{if(t.hasUseStore===e.hasUseStore)return 0;return t.hasUseStore?1:-1});let x=u.map((t)=>t.file),m=[],g=new Set,v=j({loader:"ts",target:"browser",define:w()});for(let t of x)try{let e=await Bun.file(t).text(),_=p.basename(t,".ts");if(A(e,g),_t(e))e=await Tt(e,t,{projectRoot:process.cwd(),externalizeUserModules:E()});e=Ye(e),e=O(e),e=zt(e),e=e.replace(/^export\s+(default\s+)?/gm,""),e=v.transformSync(e),m.push(`// Store: ${_}
|
|
3
3
|
${e.trim()}`)}catch(e){console.warn(`[stx] Failed to load store ${t}:`,e)}if(m.length===0)return U(a,s,f,""),null;let S=m.join(`
|
|
4
4
|
|
|
5
5
|
`),h=`;(function(){
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{tr,yc,Ku,bc,Xu,vc,nr,b,It,Se,wc,hs,xc,Ju,X,Sc,Yu,x,Zu}from"./chunk-
|
|
2
|
+
import{tr,yc,Ku,bc,Xu,vc,nr,b,It,Se,wc,hs,xc,Ju,X,Sc,Yu,x,Zu}from"./chunk-atqnvmea.js";import"./chunk-t19th11m.js";import"./chunk-v8ze2q95.js";import"./chunk-k71e38fk.js";import"./chunk-813wwkap.js";import"./chunk-48s1nprc.js";import"./chunk-qf39z0hg.js";import"./chunk-gh181dnr.js";import"./chunk-38mt83wa.js";import"./chunk-jtq8e3b0.js";import"./chunk-b3c1gggs.js";import"./chunk-tt1p6zt8.js";import"./chunk-82bttwqm.js";export{Sc as applyFilters,Xu as clearCustomFilters,wc as clientLoopScopes,tr as defaultFilters,b as escapeHtml,It as escapeHtmlValue,x as evaluateExpression,vc as findMustacheEnd,bc as getAllFilters,xc as interpolateScriptAttributes,hs as interpolateScriptExpressions,Ju as interpolateScriptsInTemplate,X as processExpressions,yc as registerFilter,Ku as registerFilters,nr as replaceInterpolations,Yu as resetRejectedExpressionWarnings,Zu as unescapeHtml,Se as usesSignalsInScript};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{hl}from"./chunk-afnj003j.js";import"./chunk-btbdp4fg.js";import"./chunk-x7epxhsz.js";import"./chunk-atqnvmea.js";import"./chunk-t19th11m.js";import"./chunk-v8ze2q95.js";import"./chunk-k71e38fk.js";import"./chunk-813wwkap.js";import"./chunk-48s1nprc.js";import"./chunk-qf39z0hg.js";import"./chunk-gh181dnr.js";import"./chunk-38mt83wa.js";import"./chunk-jtq8e3b0.js";import"./chunk-b3c1gggs.js";import"./chunk-tt1p6zt8.js";import"./chunk-82bttwqm.js";export{hl as startProductionServer};
|