@stacksjs/stx 0.2.448 → 0.2.450
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-g4hv6v3e.js → chunk-01qq35ea.js} +1 -1
- package/dist/chunk-20gh6qwe.js +2 -0
- package/dist/{chunk-fp6v2dq5.js → chunk-3ty4k2pr.js} +2 -2
- package/dist/{chunk-5vgdbqbz.js → chunk-4c84e4qb.js} +2 -2
- package/dist/{chunk-13raxes0.js → chunk-4gjjyhwt.js} +1 -1
- package/dist/chunk-5bdcx5a6.js +2 -0
- package/dist/{chunk-8bzc2v6z.js → chunk-7r0zs237.js} +1 -1
- package/dist/{chunk-frv8bhmz.js → chunk-7t55gjvd.js} +5 -5
- package/dist/{chunk-vbzeeeax.js → chunk-88vgxwmk.js} +1 -1
- package/dist/{chunk-y6zm894z.js → chunk-8f871c9w.js} +1 -1
- package/dist/chunk-987mr7v4.js +2 -0
- package/dist/{chunk-ytq686vx.js → chunk-9r081dw0.js} +1 -1
- package/dist/{chunk-sfvyfvbm.js → chunk-a19qyxgs.js} +1 -1
- package/dist/{chunk-gm7ewgf4.js → chunk-ame3pmf0.js} +1 -1
- package/dist/{chunk-7aspn183.js → chunk-cn0231jv.js} +1 -1
- package/dist/{chunk-t01a2dfe.js → chunk-cnmvkmvg.js} +1 -1
- package/dist/{chunk-hdat2brj.js → chunk-dqd53ks1.js} +1 -1
- package/dist/{chunk-vnq2c0tg.js → chunk-dsh48zkm.js} +1 -1
- package/dist/{chunk-fhpfe2s3.js → chunk-dye899tb.js} +1 -1
- package/dist/{chunk-j1h2z4wh.js → chunk-eg1tg9c8.js} +1 -1
- package/dist/{chunk-z72wwstp.js → chunk-f5cqvfw1.js} +1 -1
- package/dist/{chunk-9xf7yk65.js → chunk-f5mxhh2s.js} +1 -1
- package/dist/{chunk-21ypr4t0.js → chunk-fj8bejca.js} +1 -1
- package/dist/{chunk-cs3507d0.js → chunk-gvc45mkw.js} +1 -1
- package/dist/{chunk-h3gdfbmf.js → chunk-gxnx9tyz.js} +1 -1
- package/dist/{chunk-5ftzrjpd.js → chunk-h152z1d5.js} +1 -1
- package/dist/{chunk-bqc07550.js → chunk-jp874yvt.js} +1 -1
- package/dist/{chunk-2tpvt1c5.js → chunk-k94w32zh.js} +1 -1
- package/dist/{chunk-m5298269.js → chunk-kqtfgace.js} +1 -1
- package/dist/{chunk-brtvd5bs.js → chunk-me6yg009.js} +1 -1
- package/dist/{chunk-qmp7j5h4.js → chunk-nadsxyng.js} +1 -1
- package/dist/{chunk-rp69az5a.js → chunk-nkveg25t.js} +1 -1
- package/dist/{chunk-get6k573.js → chunk-p3qnehys.js} +1 -1
- package/dist/{chunk-237psdsd.js → chunk-pt6xds00.js} +1 -1
- package/dist/{chunk-7417f610.js → chunk-qzgqg0bw.js} +85 -25
- package/dist/{chunk-z4b0kr1z.js → chunk-r4xyes78.js} +2 -2
- package/dist/{chunk-bderms43.js → chunk-rqb8w08k.js} +1 -1
- package/dist/{chunk-dk3zazaw.js → chunk-rygb0w03.js} +1 -1
- package/dist/{chunk-yn3w9g2z.js → chunk-sk98kch4.js} +2 -2
- package/dist/{chunk-qmfwhvcr.js → chunk-tgyc1v2x.js} +6 -6
- package/dist/{chunk-n7n9zxmh.js → chunk-vavj9qkx.js} +30 -30
- package/dist/{chunk-mtctv02d.js → chunk-x6qt9hxd.js} +1 -1
- package/dist/{chunk-j3se49h7.js → chunk-xcag83az.js} +1 -1
- package/dist/chunk-xcrp8m3f.js +2 -0
- package/dist/{chunk-8y4wrp43.js → chunk-xgzvfwvn.js} +1 -1
- package/dist/{chunk-kwsw9tc4.js → chunk-y19enzen.js} +1 -1
- package/dist/{chunk-78wsn958.js → chunk-ycdcawf5.js} +1 -1
- package/dist/{chunk-pgnr089q.js → chunk-ygvyg62e.js} +1 -1
- package/dist/{chunk-j19s8n7w.js → chunk-ymvmhaqn.js} +1 -1
- package/dist/{chunk-bxhzs857.js → chunk-z8r0mbtk.js} +1 -1
- package/dist/cli.js +7 -7
- package/dist/component-renderer.js +6 -0
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/native/compiler/html-to-ir.js +42 -1
- package/dist/native/compiler/ir.d.ts +15 -1
- package/dist/native/primitives/ActivityIndicator.stx +1 -1
- package/dist/native/primitives/DatePicker.stx +1 -1
- package/dist/native/primitives/Modal.stx +1 -1
- package/dist/native/primitives/RefreshControl.stx +1 -1
- package/dist/native/primitives/Slider.stx +1 -1
- package/dist/native/primitives/StatusBar.stx +1 -1
- package/dist/native/primitives/Switch.stx +1 -1
- package/dist/native/runtime/native-host.js +26 -1
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/dist/utils.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-4gjc61wn.js +0 -2
- package/dist/chunk-d3yrvve4.js +0 -2
- package/dist/chunk-nkzn1hqq.js +0 -2
- package/dist/chunk-t6d5zq7d.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{In,Ha,bu,Va,wu,Ua,Dn,h,wt,he,Wa,Jr,qa,vu,W,Ka,xu,b,Su}from"./chunk-
|
|
2
|
+
import{In,Ha,bu,Va,wu,Ua,Dn,h,wt,he,Wa,Jr,qa,vu,W,Ka,xu,b,Su}from"./chunk-vavj9qkx.js";import"./chunk-0xztxj98.js";import"./chunk-73h7qjgq.js";import"./chunk-yx37nrgr.js";import"./chunk-ame3pmf0.js";import"./chunk-jwpcck1b.js";import"./chunk-g8k5rsqq.js";import"./chunk-zqzv5jy2.js";import"./chunk-5xj1df83.js";import"./chunk-axydabse.js";import"./chunk-afhkvj3k.js";import"./chunk-qzgqg0bw.js";import"./chunk-dqr5n49p.js";export{Ka as applyFilters,wu as clearCustomFilters,Wa as clientLoopScopes,In as defaultFilters,h as escapeHtml,wt as escapeHtmlValue,b as evaluateExpression,Ua as findMustacheEnd,Va as getAllFilters,qa as interpolateScriptAttributes,Jr as interpolateScriptExpressions,vu as interpolateScriptsInTemplate,W as processExpressions,Ha as registerFilter,bu as registerFilters,Dn as replaceInterpolations,xu as resetRejectedExpressionWarnings,Su as unescapeHtml,he as usesSignalsInScript};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{an,vs}from"./chunk-
|
|
2
|
+
import{an,vs}from"./chunk-ame3pmf0.js";import"./chunk-jwpcck1b.js";export{vs as generateRuntimeConfigTypes,an as prepareRuntimeConfig};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Vi,Qs,Vc,Ui,Wi,Uc,Wc}from"./chunk-
|
|
2
|
+
import{Vi,Qs,Vc,Ui,Wi,Uc,Wc}from"./chunk-cnmvkmvg.js";import"./chunk-f5mxhh2s.js";import"./chunk-dsh48zkm.js";import"./chunk-4c84e4qb.js";import{He,gc}from"./chunk-vavj9qkx.js";import"./chunk-0xztxj98.js";import"./chunk-73h7qjgq.js";import"./chunk-yx37nrgr.js";import"./chunk-ame3pmf0.js";import"./chunk-jwpcck1b.js";import"./chunk-g8k5rsqq.js";import"./chunk-zqzv5jy2.js";import"./chunk-5xj1df83.js";import"./chunk-axydabse.js";import"./chunk-afhkvj3k.js";import"./chunk-qzgqg0bw.js";import"./chunk-dqr5n49p.js";export{Vi as buildVirtualSource,He as extractScriptBlocks,gc as extractTemplateExpressions,Ui as findRuntimeTypeDeclarations,Wi as findStxModuleDeclarations,Wc as formatTypecheckDiagnostics,Vc as sourcePathFor,Uc as typecheckStxFiles,Qs as virtualPathFor};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{W,n}from"./chunk-
|
|
2
|
+
import{W,n}from"./chunk-vavj9qkx.js";import p from"fs";import g from"path";import*as y from"readline";var e={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},u={help:{description:"Show available commands",usage:"help [command]",handler:async(t,o)=>{if(t[0]&&u[t[0]]){let r=u[t[0]];console.log(`
|
|
3
3
|
${e.bold}${t[0]}${e.reset} - ${r.description}`),console.log(` Usage: ${e.cyan}${r.usage}${e.reset}
|
|
4
4
|
`)}else{console.log(`
|
|
5
5
|
${e.bold}Available Commands:${e.reset}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Yl,ho,Ea,Zl,Ql,eu,tu,nu,Ta,_a,ru,su,ou,iu}from"./chunk-
|
|
2
|
+
import{Yl,ho,Ea,Zl,Ql,eu,tu,nu,Ta,_a,ru,su,ou,iu}from"./chunk-8f871c9w.js";import"./chunk-vavj9qkx.js";import"./chunk-0xztxj98.js";import"./chunk-73h7qjgq.js";import"./chunk-yx37nrgr.js";import"./chunk-ame3pmf0.js";import"./chunk-jwpcck1b.js";import"./chunk-g8k5rsqq.js";import"./chunk-zqzv5jy2.js";import"./chunk-5xj1df83.js";import"./chunk-axydabse.js";import"./chunk-afhkvj3k.js";import"./chunk-qzgqg0bw.js";import"./chunk-dqr5n49p.js";export{Ea as SUSPENSE_RESOLVER_RUNTIME,ho as buildSuspenseResolveScript,nu as createStreamRenderer,eu as extractStreamBoundaries,iu as generateHydrationRuntime,_a as islandDirective,su as processSectionDirectives,Ql as processStreamDirectives,ru as registerStreamingDirectives,Zl as renderStreamingPage,Yl as streamTemplate,tu as streamTemplateSimple,ou as streamToResponse,Ta as streamingSuspenseDirective};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{o}from"./chunk-
|
|
2
|
+
import{o}from"./chunk-vavj9qkx.js";import{Sr}from"./chunk-rdq113p4.js";import p from"path";async function il(t={}){let d=performance.now(),s=t.root||process.cwd(),e=await o(s),u=t.ssr?.routeRules??e.routeRules??{};if(Sr(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-5bdcx5a6.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{il};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{xo,So,ko,fu}from"./chunk-
|
|
2
|
+
import{xo,So,ko,fu}from"./chunk-88vgxwmk.js";import"./chunk-sk98kch4.js";import"./chunk-vavj9qkx.js";import"./chunk-0xztxj98.js";import"./chunk-73h7qjgq.js";import"./chunk-yx37nrgr.js";import"./chunk-ame3pmf0.js";import"./chunk-jwpcck1b.js";import"./chunk-g8k5rsqq.js";import"./chunk-zqzv5jy2.js";import"./chunk-5xj1df83.js";import"./chunk-axydabse.js";import"./chunk-afhkvj3k.js";import"./chunk-qzgqg0bw.js";import"./chunk-dqr5n49p.js";export{xo as buildNative,fu as default,ko as getAvailableFormats,So as getAvailableTargets};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import g from"path";var y=/__stxModules\["((?:[^"\\]|\\.)*)"\]/g;function I(...r){let o=new Set;for(let s of r){if(!s||!s.includes("__stxModules["))continue;for(let e of s.matchAll(y))try{o.add(JSON.parse(`"${e[1]}"`))}catch{}}return[...o].sort()}async function M(r,o={}){if(r.length===0)return null;let s=process.cwd(),e=[],l=[];r.forEach((t,h)=>{let x=t.startsWith("npm:")?t.slice(4):g.resolve(s,t),a=`__stxRegistered${h}`,d=JSON.stringify(t);e.push(`import * as ${a} from ${JSON.stringify(x)};`),l.push(`if (!globalThis.__stxModules[${d}]) globalThis.__stxModules[${d}] = ${a};`)});let u=[...e,"globalThis.__stxModules = globalThis.__stxModules || {};",...l].join(`
|
|
3
|
-
`),n;try{let{bundleClientScript:t}=await import("./chunk-
|
|
3
|
+
`),n;try{let{bundleClientScript:t}=await import("./chunk-ycdcawf5.js");n=await t(u,g.join(s,".stx-module-registry.ts"),{projectRoot:s,minify:o.minify,externalizeUserModules:!1,collectInputs:o.collectInputs})}catch(t){return console.warn("[stx] could not build the page module registry (#1957):",t),null}let{transformAutoImports:p,generateAutoImportDestructuring:m}=await import("./chunk-fj8bejca.js"),i=p(n),f=m(i.stxImports,i.browserImports),{transformStoreImports:_}=await import("./chunk-wtqjfar3.js");n=_(i.code);let c=JSON.stringify(new Bun.CryptoHasher("md5").update(u).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${c}]) return;`,` __stxBundles[${c}] = true;`,f,n,"})();"].join(`
|
|
4
4
|
`)}export{M as buildModuleRegistryScript,I as registeredModuleIdsIn};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ds,Os,Ze,X,gn,or,mn,ir,ar,Tc,_c,Rc,hn,Ac,Pc,Ic,Dc,Ri,Ai,Pi,Ms,Ii,Oc,Qe,et,tt,nt,rt,st,Se,Mc}from"./chunk-
|
|
2
|
+
import{Ds,Os,Ze,X,gn,or,mn,ir,ar,Tc,_c,Rc,hn,Ac,Pc,Ic,Dc,Ri,Ai,Pi,Ms,Ii,Oc,Qe,et,tt,nt,rt,st,Se,Mc}from"./chunk-qzgqg0bw.js";export{mn as Router,Ic as abortNavigation,or as bracketPathToRegex,Qe as clearMiddleware,Ai as createClientCookieManager,rt as createMiddlewareContext,nt as createRouteLocation,Ri as createServerCookieManager,Pi as createStorageManager,Dc as defineMiddleware,_c as defineRoute,Rc as defineRoutes,ir as findErrorPage,ar as formatRoutes,Os as generateRouteManifest,Ds as generateRouteTypes,Ii as getMiddleware,et as getMiddlewareNames,Se as getRouterScript,Mc as getRouterScriptDev,Oc as hasMiddleware,Ze as isFileRequestPath,tt as loadMiddlewareFromDirectory,gn as matchRoute,Pc as navigateTo,X as patternToRegex,Ms as registerMiddleware,Ac as resetRoutes,hn as route,st as runMiddleware,Tc as setAppUrl};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{V,ae}from"./chunk-
|
|
2
|
+
import{V,ae}from"./chunk-vavj9qkx.js";import{le,S,Ke}from"./chunk-jwpcck1b.js";import{Ze,X,xe}from"./chunk-qzgqg0bw.js";import{_e,ne,C,re,ao,xr,co,Pt}from"./chunk-r4xyes78.js";import{Vr}from"./chunk-4c84e4qb.js";import{It}from"./chunk-rdq113p4.js";import H from"zlib";import{promisify as Y}from"util";var Q=Y(H.brotliCompress),Z=Y(H.gzip),K=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ee=["text/event-stream","multipart/x-mixed-replace"],te=1024;function se(t){if(!t)return!1;let e=t.toLowerCase();if(ee.some((i)=>e.startsWith(i)))return!1;return K.some((i)=>e.startsWith(i))}function oe(t){let e=new Map;for(let i of t.split(",")){let[s,...c]=i.trim().split(";"),l=s.trim().toLowerCase();if(!l)continue;let m=1;for(let f of c){let x=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(f);if(!x)continue;let g=Number.parseFloat(x[1]);if(Number.isFinite(g))m=g}e.set(l,m)}return e}function ie(t){if(!t)return null;let e=oe(t),i=e.get("*"),s=(c)=>e.get(c)??i??0;if(s("br")>0)return"br";if(s("gzip")>0)return"gzip";return null}async function At(t,e,i={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!se(e.headers.get("content-type")))return e;let s=ie(t.headers.get("accept-encoding"));if(!s)return e;let c;try{c=new Uint8Array(await e.arrayBuffer())}catch{return e}let l=()=>new Response(c,{status:e.status,statusText:e.statusText,headers:q(e.headers)});if(c.length<(i.threshold??te))return l();try{let m=s==="br"?await Q(c,{params:{[H.constants.BROTLI_PARAM_QUALITY]:i.quality??5,[H.constants.BROTLI_PARAM_SIZE_HINT]:c.length}}):await Z(c);if(m.length>=c.length)return l();let f=q(e.headers);return f.set("Content-Encoding",s),f.set("Content-Length",String(m.length)),new Response(m,{status:e.status,statusText:e.statusText,headers:f})}catch{return l()}}function q(t){let e=new Headers(t),i=e.get("Vary");if(!i)return e.set("Vary","Accept-Encoding"),e;if(!i.split(",").some((c)=>c.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${i}, Accept-Encoding`);return e}import J from"fs";import M from"path";var{serve:ce}=globalThis.Bun;class G{now;entries=new V(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,i){let s,c=async()=>{let r=s??await i();return r.headers.set("Cache-Control","private, no-store"),r.headers.set("Vary",C(r.headers.get("Vary")).Vary),r};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return c();let l=new URL(t.url),m=`${l.origin}${l.pathname}${l.search}|${ne(t)?"fragment":"document"}`,f=this.entries.get(m),x=(r)=>{let T=new Headers(r.headers);return T.set("Cache-Control","private, no-store"),T.set("Age",String(Math.max(0,Math.floor((this.now()-r.created)/1000)))),new Response(r.body.slice(0),{headers:T})},g=f?(this.now()-f.created)/1000:1/0;if(f&&g<e.maxAge)return x(f);let b=this.generation,O=async()=>{let r=await i();s=r;let T=(r.headers.get("Vary")??"").toLowerCase().split(",").map((R)=>R.trim()).filter(Boolean);if(r.status!==200||r.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(r.headers.get("Cache-Control")??"")||T.some((R)=>R!=="x-stx-router"&&R!=="accept-encoding"))return null;let L=await r.clone().arrayBuffer();if(L.byteLength>1048576)return null;r.headers.set("Vary",C(r.headers.get("Vary")).Vary);let n={body:L,headers:Array.from(r.headers.entries()),created:this.now(),path:l.pathname};if(this.generation===b)this.entries.set(m,n);return n},v=this.pending.get(m);if(!v){if(this.pending.size>=1000)return c();v=O().finally(()=>{if(this.pending.get(m)===v)this.pending.delete(m)}),this.pending.set(m,v)}if(f&&g<e.maxAge+(e.swr??0))return v.catch(()=>{}),x(f);let E=await v;return E?x(E):c()}}var pe={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function al(t={}){let e=M.resolve(t.outputDir||".output"),i=t.port??3000,s=ao(e);if(!s)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${s.routes.length} routes...`);let c=It(s.routeRules),l=new G,m=Vr(e,s.apiRoutes??[]),f=Bun.file(M.join(e,"server/runtime-config.json")),x=t.runtimeConfig??(await f.exists()?await f.json():void 0),g=x?S(x):void 0,b=new Map,O=new Map,v=new Map,E=new Map;for(let n of s.routes)try{let R=M.join(e,n.compiledPath),o=JSON.parse(await Bun.file(R).text());if(g)o.html=Ke(o.html,g);b.set(n.pattern,o),v.set(n.pattern,xe(o.html)),E.set(n.pattern,ae(o.html));let _=M.join(e,n.fragmentPath);if(await Bun.file(_).exists()){let A=await Bun.file(_).text();O.set(n.pattern,g?Ke(A,g):A)}}catch(R){console.warn(`[stx] Failed to load route ${n.pattern}:`,R)}let r=new Map,T=[];for(let n of s.routes)if(n.hasParams){let{regex:R,params:o}=X(n.pattern,{page:!0});T.push({regex:R,route:n,paramNames:o})}else r.set(n.pattern,n);let L=ce({port:i,async fetch(n){return At(n,await le(g??S(),async()=>{let o=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[o])return t.apiRoutes[o](n);let _=await m(n);if(_)return _;if((n.method==="GET"||n.method==="HEAD")&&o!=="/"){let p=M.resolve(e,"public"),d;try{d=decodeURIComponent(o)}catch{d=o}if(!d.includes("\x00")){let u=M.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${M.sep}`))try{if(J.existsSync(u)&&J.statSync(u).isFile()){let h=M.extname(u).toLowerCase(),j=pe[h]||"application/octet-stream",B=o.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(o);return new Response(Bun.file(u),{headers:{"Content-Type":j,"Cache-Control":B?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=ne(n),y=null,U={};if(y=r.get(o)||null,!y)for(let{regex:p,route:d,paramNames:u}of T){let a=o.match(p);if(a){y=d,u.forEach((h,j)=>{U[h]=a[j+1]});break}}if(!y){let p=Ze(o)?null:r.get("/404")||null;if(p){let d=b.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let k=c(o),W=Object.keys(k).length>0;return l.respond(n,k.cache,async()=>{let p=b.get(y.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let a=O.get(y.pattern);if(a){let h=v.get(y.pattern);return new Response(a,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...E.has(y.pattern)?{"X-STX-Runtime":E.get(y.pattern)?"true":"false"}:{},...h?{"X-STX-Layout":h.layout,"X-STX-Layout-Group":h.group}:{},...C(),...k.cache?{}:{"Cache-Control":_e}}})}}let d=xr(n.method),u=b.get(y.pattern);if(!u){let a=r.get("/500")||null;if(a){let h=b.get(a.pattern);if(h)return new Response(h.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(y.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",...C(),"Cache-Control":"public, max-age=60"}});try{let{html:a,boundaries:h,redirect:j,cookies:B,status:I,headers:z}=await Pt(u,{params:U,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:g});if(j)return co(j,B,z);if(h&&h.length>0){let{renderStreamingPage:P,streamToResponse:D}=await import("./chunk-k94w32zh.js"),N=new Headers({...C(),...z,"Cache-Control":"private, no-store"});for(let F of B??[])N.append("Set-Cookie",F);if(A&&!d){let F=xe(a);N.set("X-STX-Fragment","true"),N.set("X-STX-Runtime",ae(a)?"true":"false"),N.set("X-STX-Layout",F.layout),N.set("X-STX-Layout-Group",F.group)}return D(P(A&&!d?re(a,s.routerContainer||"main"):a,h,{timeoutMs:30000}),{status:I??u.status??200,headers:N})}let w=new Headers({"Content-Type":"text/html",...C(),...k.cache?{}:{"Cache-Control":"private, no-store"}});for(let P of B??[])w.append("Set-Cookie",P);for(let[P,D]of Object.entries(z??{}))w.set(P,D);if(w.set("Vary",C(w.get("Vary")).Vary),A&&!d){let P=xe(a);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",ae(a)?"true":"false"),w.set("X-STX-Layout",P.layout),w.set("X-STX-Layout-Group",P.group),new Response(re(a,s.routerContainer||"main"),{status:I??u.status??200,headers:w})}return new Response(a,{status:I??u.status??200,headers:w})}catch(a){if(console.error(`[stx] Hydration error for ${o}:`,a),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${L.port}`),console.log(`[stx] Serving ${s.routes.length} routes (${b.size} pre-loaded)`),{port:L.port,stop:()=>{l.invalidate(),L.stop()},invalidate:(n)=>l.invalidate(n)}}
|
|
3
3
|
export{At,al};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-afhkvj3k.js";import"./chunk-axydabse.js";import{y,I,O,N}from"./chunk-
|
|
2
|
+
import"./chunk-afhkvj3k.js";import"./chunk-axydabse.js";import{y,I,O,N}from"./chunk-vavj9qkx.js";import"./chunk-5xj1df83.js";import"./chunk-73h7qjgq.js";import"./chunk-qzgqg0bw.js";import"./chunk-zqzv5jy2.js";import"./chunk-g8k5rsqq.js";import"./chunk-yx37nrgr.js";import"./chunk-jwpcck1b.js";import"./chunk-ame3pmf0.js";import"./chunk-dqr5n49p.js";import"./chunk-0xztxj98.js";import f from"path";var b=["applyOfflineUpdate","broadcast","cacheMedia","calculateDistance","canNotify","clearCookies","clearFetchCache","clearOfflineData","clearStorage","copyToClipboard","createShareableFile","defineForm","getBatteryLevel","getCookie","getCurrentPosition","getStorageKeys","getStorageSize","getVoices","hasBattery","hasCameraPermission","hasGeolocationPermission","hasMicrophonePermission","hasNotificationPermission","hasResizeObserver","hexToHsl","hexToRgb","isBroadcastChannelSupported","isCharging","isDeviceMotionSupported","isDeviceOrientationSupported","isEventSourceSupported","isEyeDropperSupported","isInFullscreen","isMutationObserverSupported","isPermissionGranted","isSpeechRecognitionSupported","isSpeechSynthesisSupported","isWakeLockSupported","isWebSocketSupported","notify","onOfflineUpdateReady","parseCookies","pickColor","prefetch","removeCookie","requestMediaPermissions","requestMotionPermission","requestNotificationPermission","requestOrientationPermission","setCookie","share","shareCurrentPage","shareFiles","shareText","shareURL","shareWithFallback","speak","stopSpeaking","toggleFullscreen","useAsyncData","useAttributeObserver","useAutoLogout","useAutoWakeLock","useBattery","useBreakpoint","useBroadcastChannel","useBroadcastStream","useChannel","useChildListObserver","useClipboard","useColorHistory","useConditionalWakeLock","useCookies","useCopySelection","useDeviceMotion","useDeviceOrientation","useElementSize","useElementTextSelection","useElementVisibility","useEventSource","useEyeDropper","useFavicon","useForm","useFullscreen","useGeolocation","useGeolocationWatch","useHotkey","useIdle","useIdleState","useInfiniteScroll","useIntersectionObserver","useIntersectionObserverMultiple","useIsDesktop","useIsMobile","useIsTablet","useKeyPressed","useKeySequence","useKeyboard","useLastActive","useLazyLoad","useMeta","useMouse","useMouseInElement","useMutationObserver","useNetwork","useNotification","useOnline","useOutbox","useParallax","usePermission","usePermissions","usePointer","usePost","useResizeObserver","useResizeObserverMultiple","useSSE","useScroll","useSelectionPopup","useShare","useSpeechRecognition","useSpeechSynthesis","useStorage","useTextObserver","useTextSelection","useTitle","useVisibility","useWakeLock","useWindowSize"],L=new Set(b);var l=new Map,h=I(64),S=new Set,v=0,E=new Set(b);function W(){l.clear(),h.clear()}function R(o){let n=new Map;for(let r of o){let a=f.basename(r);if(a.endsWith(".d.ts"))continue;let t=a.replace(/\.[jt]s$/,"");if(t==="index")continue;if(t===a)continue;let i=n.get(t);if(i&&!i.endsWith(".js"))continue;n.set(t,r)}return[...n.values()].sort()}function P(o,n){let r=n.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(?:^|[^\\w$.])(?:const|let|var|function|class)\\s+${r}\\b`).test(o)}function M(o){if(!o)return[];let n=O(o,v),r=h.get(n);if(r)return r.slice();let a=o.replace(/<script\b[^>]*\bdata-stx-runtime\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-framework-composables\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-stores\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-composables\b[^>]*>[\s\S]*?<\/script>/gi,""),t=[];for(let i of E){if(S.has(i))continue;let u=i.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");if(new RegExp(`(^|[^\\w$.])${u}\\s*\\(`).test(a))t.push(i)}return t.sort(),h.set(n,t),t.slice()}async function U(o,n){let r=M(o);if(r.length===0)return null;let a=n??f.join(import.meta.dir,"composables"),t=`${a}\x00${r.join(",")}`,i=l.get(t);if(i!==void 0)return i||null;let u=N({loader:"ts",target:"browser",define:y()}),k=new Set(r),m=[],d=new Set,p=[];try{let s=new Bun.Glob("*.{ts,js}");for await(let e of s.scan({cwd:a,absolute:!0}))p.push(e)}catch{return l.set(t,""),null}p=R(p);for(let s of p){let e;try{e=await Bun.file(s).text()}catch{continue}let g=[];try{g=u.scan(e).exports.filter((c)=>c!=="default")}catch{continue}if(!g.some((c)=>k.has(c)))continue;try{e=e.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^import\s+type\s+.*$/gm,""),e=e.replace(/^export\s+\*\s+(?:as\s+\w+\s+)?from\s*['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^export\s+(?:type\s+)?\{[\s\S]*?\}\s*(?:from\s*['"][^'"]+['"]\s*)?;?\s*$/gm,""),e=e.replace(/^export\s+default\s+/gm,""),e=e.replace(/^export\s+(?=(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\b)/gm,""),m.push(`// ${f.basename(s).replace(/\.[jt]s$/,"")}
|
|
3
3
|
${u.transformSync(e).trim()}`);for(let c of g)d.add(c)}catch(c){console.warn(`[stx] framework composable ${f.basename(s)} could not be bundled:`,c)}}let w=r.filter((s)=>!d.has(s)&&!P(o,s));if(w.length>0)console.warn(`[stx] could not bundle ${w.join(", ")} from @stacksjs/stx/composables \u2014 `+"calls to them will throw ReferenceError in the browser. Import them explicitly so the bundler inlines them, or use a runtime equivalent from window.stx.");if(m.length===0)return l.set(t,""),null;let C=[...d].map((s)=>` try { if (!(${JSON.stringify(s)} in __s)) { __s[${JSON.stringify(s)}] = ${s}; if (!(${JSON.stringify(s)} in window)) window[${JSON.stringify(s)}] = ${s}; } } catch (e) {}`).join(`
|
|
4
4
|
`),x=`<script data-stx-framework-composables>
|
|
5
5
|
;(function(){
|
|
@@ -803,15 +803,28 @@ import x from"fs";import u from"path";import p from"fs";import v from"path";var
|
|
|
803
803
|
if(key)loadedExternalScripts[key]=1;
|
|
804
804
|
return key;
|
|
805
805
|
}
|
|
806
|
-
// Returns a promise, or null when there is
|
|
807
|
-
// loaded file, or an unparseable src.
|
|
808
|
-
// one 404 must not stop the rest of
|
|
809
|
-
//
|
|
806
|
+
// Returns a promise of whether the file loaded, or null when there is
|
|
807
|
+
// nothing to wait for \u2014 an already loaded file, or an unparseable src.
|
|
808
|
+
// Resolves rather than rejects on error: one 404 must not stop the rest of
|
|
809
|
+
// the page hydrating; the caller decides what a failure means.
|
|
810
|
+
//
|
|
811
|
+
// A file still on its way is not a loaded one. A prefetch starts loading
|
|
812
|
+
// the page's module registry (loadModuleRegistries), and this used to count
|
|
813
|
+
// it loaded the moment it was requested, so a tap that beat it swapped the
|
|
814
|
+
// page in and ran its setup ahead of the registry it imports from: "is not
|
|
815
|
+
// registered on this page", every binding dead. Locally a file loads in a
|
|
816
|
+
// millisecond and the tap never wins; on a phone far from the server it
|
|
817
|
+
// does. The tap now waits on the same request.
|
|
818
|
+
//
|
|
819
|
+
// And a file that failed is forgotten, so a fresh copy of the page that
|
|
820
|
+
// links it again (recoverUnbound) asks for it again rather than finding it
|
|
821
|
+
// "loaded" and running without it until the next reload.
|
|
822
|
+
var pendingExternalScripts={};
|
|
810
823
|
function loadExternalScript(src,base){
|
|
811
824
|
var key=externalScriptKey(src,base);
|
|
812
825
|
if(!key||loadedExternalScripts[key])return null;
|
|
813
|
-
|
|
814
|
-
return new Promise(function(resolve){
|
|
826
|
+
if(pendingExternalScripts[key])return pendingExternalScripts[key];
|
|
827
|
+
return pendingExternalScripts[key]=new Promise(function(resolve){
|
|
815
828
|
var el=ce('script');
|
|
816
829
|
el.src=key;
|
|
817
830
|
// Deliberately NOT data-stx-page: both swap paths clear those on every
|
|
@@ -822,11 +835,31 @@ import x from"fs";import u from"path";import p from"fs";import v from"path";var
|
|
|
822
835
|
// In document order: a fragment's composables bundle reads the module
|
|
823
836
|
// registry loaded beside it, and an inserted script is async by default.
|
|
824
837
|
el.async=false;
|
|
825
|
-
el.onload=function(){resolve()};
|
|
826
|
-
el.onerror=function(){
|
|
838
|
+
el.onload=function(){delete pendingExternalScripts[key];loadedExternalScripts[key]=1;resolve(true)};
|
|
839
|
+
el.onerror=function(){
|
|
840
|
+
log('[router] container script failed:',key);
|
|
841
|
+
delete pendingExternalScripts[key];
|
|
842
|
+
if(el.parentNode)el.parentNode.removeChild(el);
|
|
843
|
+
resolve(false);
|
|
844
|
+
};
|
|
827
845
|
dhead().appendChild(el);
|
|
828
846
|
});
|
|
829
847
|
}
|
|
848
|
+
// A page's module registry, stores or composables in serve mode: stx's own
|
|
849
|
+
// file, named by its content (registerServeModuleBundle). Without it the
|
|
850
|
+
// page's setup cannot run at all, unlike an app's own script, whose
|
|
851
|
+
// failure the rest of the page survives.
|
|
852
|
+
var MODULE_BUNDLE=/\\/_stx\\/modules\\.[0-9a-f]{16}\\.js(?:[?#]|$)/;
|
|
853
|
+
function isModuleBundle(src){return MODULE_BUNDLE.test(src||'')}
|
|
854
|
+
// Waits for the files a swap loads, then runs its scripts -- or, when one
|
|
855
|
+
// of them was a module bundle that did not load, recovers the page instead
|
|
856
|
+
// of running a setup that can only throw.
|
|
857
|
+
function afterExternalScripts(pending,run,url,ctx){
|
|
858
|
+
if(!pending.length){run();return}
|
|
859
|
+
var failed=false;
|
|
860
|
+
Promise.all(pending.map(function(p){return p.promise.then(function(ok){if(ok===false&&isModuleBundle(p.src))failed=true})}))
|
|
861
|
+
.then(function(){if(failed)recoverUnbound(url,ctx);else run()},run);
|
|
862
|
+
}
|
|
830
863
|
|
|
831
864
|
// Record scripts from the initial page load
|
|
832
865
|
qsa('script').forEach(function(s){
|
|
@@ -950,9 +983,13 @@ import x from"fs";import u from"path";import p from"fs";import v from"path";var
|
|
|
950
983
|
location.href=away;
|
|
951
984
|
return true;
|
|
952
985
|
}
|
|
953
|
-
|
|
986
|
+
// fresh: past every cache, the offline worker's included (it hands a
|
|
987
|
+
// no-store request straight to the network). For recoverUnbound, whose
|
|
988
|
+
// whole point is that the kept copy is the broken one.
|
|
989
|
+
function routerFetch(url,headers,fresh){
|
|
954
990
|
var init={headers:headers};
|
|
955
991
|
if(navAbort)init.signal=navAbort.signal;
|
|
992
|
+
if(fresh)init.cache='no-store';
|
|
956
993
|
return fetch(url,init);
|
|
957
994
|
}
|
|
958
995
|
function navigate(url,pushState,force){
|
|
@@ -1068,7 +1105,7 @@ else {
|
|
|
1068
1105
|
// the page content. Custom app-shell containers need full documents so
|
|
1069
1106
|
// the router does not inject a <main> fragment into the wrong element.
|
|
1070
1107
|
var wantsFragment=shouldUseFragmentResponse();
|
|
1071
|
-
return routerFetch(url,wantsFragment?{'X-STX-Router':'true','Accept':'text/html'}:{'Accept':'text/html'}).then(function(r){
|
|
1108
|
+
return routerFetch(url,wantsFragment?{'X-STX-Router':'true','Accept':'text/html'}:{'Accept':'text/html'},ctx.fresh).then(function(r){
|
|
1072
1109
|
if(stale())return null;
|
|
1073
1110
|
if(leaveOrigin(r))return null;
|
|
1074
1111
|
if(!r.ok)throw httpError(r.status);
|
|
@@ -1102,7 +1139,7 @@ else {
|
|
|
1102
1139
|
// Layout change? Fetch the FULL page (no X-STX-Router header) and do full document swap
|
|
1103
1140
|
if(isFragment&&checkLayoutChange(newLayout,url,newGroup)){
|
|
1104
1141
|
log('[router] layout change \u2014 fetching full page for document swap');
|
|
1105
|
-
return routerFetch(url,{'Accept':'text/html'}).then(function(fullRes){
|
|
1142
|
+
return routerFetch(url,{'Accept':'text/html'},ctx.fresh).then(function(fullRes){
|
|
1106
1143
|
log('[router] full page fetched:',fullRes.status,'ok:',fullRes.ok);
|
|
1107
1144
|
if(leaveOrigin(fullRes))return null;
|
|
1108
1145
|
if(!fullRes.ok)throw httpError(fullRes.status);
|
|
@@ -1151,6 +1188,33 @@ else {
|
|
|
1151
1188
|
pendingCtx=ctx;
|
|
1152
1189
|
return Promise.resolve(swap(html,cacheKey(url),pushState,hash)).then(function(){return false});
|
|
1153
1190
|
}
|
|
1191
|
+
// \u2500\u2500 A page whose module bundle did not load \u2500\u2500
|
|
1192
|
+
// Serve mode links a page's registry, stores and composables as
|
|
1193
|
+
// /_stx/modules.<hash>.js, answered from what the server process has
|
|
1194
|
+
// rendered. Its HTML can outlive that process: the router's cache, a
|
|
1195
|
+
// prefetch, the offline worker's kept copy. After a deploy (a new release
|
|
1196
|
+
// directory, a new process that has never rendered the page) the hash is
|
|
1197
|
+
// answered 404, and the page was swapped in with nothing bound -- its
|
|
1198
|
+
// {{ }} empty, its :for lists empty, its :if buttons gone -- until a
|
|
1199
|
+
// revalidation happened to replace the copy (hq.training, a coach's
|
|
1200
|
+
// /coaches/athletes).
|
|
1201
|
+
//
|
|
1202
|
+
// So that copy is dropped and the page fetched again past every cache:
|
|
1203
|
+
// the process answering renders it, which registers the bundle it links,
|
|
1204
|
+
// and a newer build is caught by the skew check and loaded whole (#1772).
|
|
1205
|
+
// Once only. A fresh copy whose bundle fails too is loaded as a document,
|
|
1206
|
+
// where the browser and the server settle it without the router.
|
|
1207
|
+
//
|
|
1208
|
+
// Not a page whose own setup throws: that throws again on a fresh copy, so
|
|
1209
|
+
// retrying would only add a round trip and a reload to every visit.
|
|
1210
|
+
function recoverUnbound(url,ctx){
|
|
1211
|
+
if(ctx&&ctx.id&&ctx.id!==navSeq)return;
|
|
1212
|
+
evictCache(cacheKey(url));
|
|
1213
|
+
if(ctx&&ctx.fresh){log('[router] module bundle failed again \u2014 full navigation to:',url);location.href=url;return}
|
|
1214
|
+
log('[router] module bundle failed \u2014 fetching',url,'again past the caches');
|
|
1215
|
+
navCtxNext={direction:'replace',fresh:true};
|
|
1216
|
+
navigate(url,'replace',true);
|
|
1217
|
+
}
|
|
1154
1218
|
function retryShown(){var root=activeRoot();var el=root&&root.querySelector?root.querySelector('[data-stx-retry]'):null;return el?el.getAttribute('data-stx-retry'):''}
|
|
1155
1219
|
document.addEventListener('click',function(e){
|
|
1156
1220
|
var b=e.target&&e.target.closest?e.target.closest('[data-stx-retry-button]'):null;
|
|
@@ -1585,10 +1649,9 @@ else {
|
|
|
1585
1649
|
var fragPending=[];
|
|
1586
1650
|
fragExternalScripts.forEach(function(src){
|
|
1587
1651
|
var pending=loadExternalScript(src,url);
|
|
1588
|
-
if(pending)fragPending.push(pending);
|
|
1652
|
+
if(pending)fragPending.push({src:src,promise:pending});
|
|
1589
1653
|
});
|
|
1590
|
-
|
|
1591
|
-
else runFragScripts();
|
|
1654
|
+
afterExternalScripts(fragPending,runFragScripts,url+(hash||''),ctx);
|
|
1592
1655
|
}
|
|
1593
1656
|
// With screens retained, the outgoing page is kept (or disposed once it
|
|
1594
1657
|
// has animated away) by screenBegin rather than cleaned up here.
|
|
@@ -1853,13 +1916,15 @@ else {
|
|
|
1853
1916
|
var src=new URL(s.getAttribute('src'),docBase).href;
|
|
1854
1917
|
if(loadedSrcs[src])return;
|
|
1855
1918
|
loadedSrcs[src]=1;
|
|
1856
|
-
extPromises.push(new Promise(function(resolve
|
|
1919
|
+
extPromises.push({src:src,promise:new Promise(function(resolve){
|
|
1857
1920
|
var ns=ce('script');
|
|
1858
1921
|
ns.src=src;
|
|
1859
|
-
ns.onload=resolve;
|
|
1860
|
-
|
|
1922
|
+
ns.onload=function(){resolve(true)};
|
|
1923
|
+
// Settled either way, as before (a rejection ran the scripts at
|
|
1924
|
+
// once); afterExternalScripts tells a failed module bundle apart.
|
|
1925
|
+
ns.onerror=function(){if(ns.parentNode)ns.parentNode.removeChild(ns);resolve(false)};
|
|
1861
1926
|
dhead().appendChild(ns);
|
|
1862
|
-
}));
|
|
1927
|
+
})});
|
|
1863
1928
|
});
|
|
1864
1929
|
|
|
1865
1930
|
// Before the inline scripts, and through the same barrier: an inline
|
|
@@ -1867,7 +1932,7 @@ else {
|
|
|
1867
1932
|
// so running it first would fail exactly the way this bug did.
|
|
1868
1933
|
routedExternalScripts.forEach(function(src){
|
|
1869
1934
|
var pending=loadExternalScript(src,docBase);
|
|
1870
|
-
if(pending)extPromises.push(pending);
|
|
1935
|
+
if(pending)extPromises.push({src:src,promise:pending});
|
|
1871
1936
|
});
|
|
1872
1937
|
|
|
1873
1938
|
// \u2500\u2500 Script re-execution \u2500\u2500
|
|
@@ -2042,12 +2107,7 @@ else {
|
|
|
2042
2107
|
window.dispatchEvent(new Event('stx:load'));
|
|
2043
2108
|
}
|
|
2044
2109
|
|
|
2045
|
-
|
|
2046
|
-
Promise.all(extPromises).then(execScripts).catch(execScripts);
|
|
2047
|
-
}
|
|
2048
|
-
else {
|
|
2049
|
-
execScripts();
|
|
2050
|
-
}
|
|
2110
|
+
afterExternalScripts(extPromises,execScripts,url+(hash||''),ctx);
|
|
2051
2111
|
}
|
|
2052
2112
|
|
|
2053
2113
|
function startSwap(){
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Fo,Gr,Y,Le,wt,b,Be,Fe,Bn,d,rn}from"./chunk-
|
|
2
|
+
import{Fo,Gr,Y,Le,wt,b,Be,Fe,Bn,d,rn}from"./chunk-vavj9qkx.js";import{D}from"./chunk-yqsza22w.js";import E from"path";var j=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function F(t,n,e){let r={fullTag:e,content:n,attrs:t};if(/\bserver\b/.test(t))return{...r,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...r,type:"client"};if(j.test(n))return{...r,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...r,type:"client"};return{...r,type:"server"}}var H=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function to(t){let n=[],e=[],r=[],o=0;while(o<t.length){let s=t.indexOf("<",o);if(s===-1)break;let a=Le(t,s);if(a>s){o=a;continue}let i=Y(t,s);if(i>s){let c=t.slice(s,i),u=H.exec(c);if(u){let l=F(u[1],u[2],c);switch(l.type){case"signals":n.push(l);break;case"client":e.push(l);break;case"server":r.push(l);break}}o=i;continue}o=s+(t.startsWith("<!--",s)?4:1)}return{signals:n,client:e,server:r}}var L=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function V(t){let n=[],e=/<!--[\s\S]*?(?:-->|$)|<(script|style|textarea|title|template)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,r;while((r=e.exec(t))!==null)n.push({start:r.index,end:r.index+r[0].length});return n}function P(t,n){return n.some((e)=>t>=e.start&&t<e.end)}function B(t){let n=(t||"").trim();if(!n)return null;if(/[\s>+~,:]/.test(n))return null;let e={},r=n,o=r.match(/^[a-z][\w-]*/i);if(o)e.tag=o[0].toLowerCase(),r=r.slice(o[0].length);while(r.length>0){let s=r.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(s){if(e.attr=s[1],s[3]!==void 0&&s[3]!=="")e.attrValue=s[3];r=r.slice(s[0].length);continue}let a=r.match(/^#([\w-]+)/);if(a){e.id=a[1],r=r.slice(a[0].length);continue}let i=r.match(/^\.([\w-]+)/);if(i){e.className=i[1],r=r.slice(i[0].length);continue}return null}if(!e.tag&&!e.attr&&!e.id&&!e.className)return null;return e}function q(t,n){if(n.attr){if(!(n.attrValue===void 0?new RegExp(`\\b${n.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${n.attr}\\s*=\\s*(["'])\\s*${n.attrValue}\\s*\\1`,"i")).test(t))return!1}if(n.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${n.id}\\s*\\1`,"i").test(t))return!1}if(n.className){let e=t.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!e)return!1;if(!e[2].split(/\s+/).includes(n.className))return!1}return!0}function T(t,n="main"){let e=B(n);if(!e)return null;let r=/<([a-z][\w-]*)\b([^>]*)>/gi,o=V(t),s;while((s=r.exec(t))!==null){if(P(s.index,o))continue;let a=s[1].toLowerCase(),i=s[2]||"";if(i.trimEnd().endsWith("/")||L.has(a))continue;if(e.tag&&e.tag!==a)continue;if(!q(i,e))continue;let c=s[0],u=s.index+c.length,l=new RegExp(`<(/?)${a}\\b([^>]*)>`,"gi");l.lastIndex=u;let f=1,p;while((p=l.exec(t))!==null){if(P(p.index,o))continue;let h=p[1]==="/";if(!h&&(p[2]||"").trimEnd().endsWith("/"))continue;if(f+=h?-1:1,f===0)return{openTag:c,openIndex:s.index,start:u,end:p.index,tagName:a}}return null}return null}var _e="private, no-store";function no(t){return t.replace(/&#(\d+);/g,(n,e)=>O(Number(e),n)).replace(/&#x([0-9a-f]+);/gi,(n,e)=>O(Number.parseInt(e,16),n)).replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&")}function O(t,n){if(!Number.isInteger(t)||t<0||t>1114111)return n;try{return String.fromCodePoint(t)}catch{return n}}function ne(t){return t.headers.get("X-STX-Router")==="true"}function z(t,n){if(!t)return n;return t.split(",").some((r)=>r.trim().toLowerCase()===n.toLowerCase())?t:`${t}, ${n}`}function C(t){return{Vary:z(t,"X-STX-Router")}}var G="stx-page-head:",U=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,v={dev:null,prod:null};function W(){let t=D()?"dev":"prod",n=v[t];if(n!==null)return n;try{let e=import.meta.require("./chunk-nkveg25t.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 ro(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 vr(t,n){try{let e=await Bun.file(t).text(),r=e,o=e.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(o)r=o[1].trim();let s=to(e),a=[...s.client.map((m)=>m.fullTag),...s.signals.map((m)=>m.fullTag)],i=[],c=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,u;while((u=c.exec(e))!==null)i.push(u[0]);let l=r;for(let m of s.server)l=l.replace(m.fullTag,"");for(let m of s.client)l=l.replace(m.fullTag,"");l=l.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let f="<!--__STX_PAGE_SLOT__-->";if(l=l.replace(/<slot\s*\/>/gi,f).replace(/<slot\s*>\s*<\/slot>/gi,f),!l.includes(f))return console.warn(`[stx] Shell ${t} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:p,extractVariables:h,defaultConfig:x,loadStxConfig:y}=await import("./chunk-987mr7v4.js"),R=await y(),g={__filename:t,__dirname:E.dirname(t)};for(let m of a){let A=m.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(A&&!m.includes("client")&&!m.includes('type="module"'))await h(A[1],g,t)}let S=await p(l,g,t,{...x,...R,...n},new Set),w=S.indexOf(f);if(w===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:S.substring(0,w),afterSlot:S.substring(w+f.length),filePath:t,shellScripts:a,shellStyles:i}}catch(e){return console.error(`[stx] Error processing shell ${t}:`,e),null}}function kn(t,n,e){let r,o="",s=n.match(U);if(s){n=n.replace(s[0],"");try{let l=Buffer.from(s[1],"base64").toString("utf8"),f=l.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(f)r=f[1].trim();o=l.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let a=e||r||"stx App",i=W(),c="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8">
|
|
@@ -26,5 +26,5 @@ ${i}
|
|
|
26
26
|
`));if(o.length>0)x.push(o.join(`
|
|
27
27
|
`));if(f.length>0)x.push(f.join(`
|
|
28
28
|
`));return x.push(l),x.join(`
|
|
29
|
-
`)}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 J(t){let n=t.headers.get("content-type")||"",e={},r=(o,s)=>{let a=e[o];if(a===void 0)e[o]=s;else if(Array.isArray(a))a.push(s);else e[o]=[a,s]};if(n.includes("multipart/form-data")){let o=await t.formData();for(let[s,a]of o.entries())if(typeof a==="string")r(s,a);return e}if(n.includes("application/x-www-form-urlencoded")){for(let[o,s]of new URLSearchParams(await t.text()).entries())r(o,s);return e}return e}function xr(t){if(!t)return!1;let n=t.toUpperCase();return n!=="GET"&&n!=="HEAD"}async function N(t,n={}){let e=n.request,r=n.method??e?.method;if(!e||!xr(r))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let o={};try{o=await J(e)}catch{}let s=await t.action({request:e,form:o,params:n.params??{},query:t.query??{},cookies:n.cookies??{}});if(s&&typeof s==="object"){let a=s,i=K(a.cookies),c=a.redirect;if(typeof c==="string"&&c)return{redirect:c,ran:!0,...i.length>0?{cookies:i}:{}};let{cookies:u,redirect:l,...f}=a;if(Object.assign(t,f),i.length>0)return{ran:!0,cookies:i}}return{ran:!0}}function K(t){if(!t||typeof t!=="object"||Array.isArray(t))return[];let n=[];for(let[e,r]of Object.entries(t)){if(!e)continue;if(typeof r==="string"){n.push(_(e,r));continue}if(r&&typeof r==="object"){let o=r;if(typeof o.value!=="string")continue;n.push(_(e,o.value,o))}}return n}function co(t,n=[],e){let r=new Headers({Location:t,"Cache-Control":"no-store"});for(let o of n)r.append("Set-Cookie",o);for(let[o,s]of Object.entries(e??{}))if(o.toLowerCase()!=="location")r.set(o,s);return new Response(null,{status:303,headers:r})}import k from"fs";import I from"path";function oo(t,n,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:e}}function io(t,n){let e=I.join(n,"manifest.json");k.writeFileSync(e,JSON.stringify(t,null,2))}function ao(t){let n=I.join(t,"manifest.json");if(!k.existsSync(n))return null;try{let e=k.readFileSync(n,"utf-8"),r=JSON.parse(e);if(r.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${r.version}`),null;return r}catch(e){return console.warn("[stx] Failed to load manifest:",e),null}}async function Pt(t,n={}){let{html:e,context:r,redirect:o,cookies:s}=await Z(t,n),a=Be(r),i=Fe(r);if(o)return{html:e,redirect:o,cookies:s,status:a,headers:i};let{extractStreamBoundaries:c}=await import("./chunk-
|
|
29
|
+
`)}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 J(t){let n=t.headers.get("content-type")||"",e={},r=(o,s)=>{let a=e[o];if(a===void 0)e[o]=s;else if(Array.isArray(a))a.push(s);else e[o]=[a,s]};if(n.includes("multipart/form-data")){let o=await t.formData();for(let[s,a]of o.entries())if(typeof a==="string")r(s,a);return e}if(n.includes("application/x-www-form-urlencoded")){for(let[o,s]of new URLSearchParams(await t.text()).entries())r(o,s);return e}return e}function xr(t){if(!t)return!1;let n=t.toUpperCase();return n!=="GET"&&n!=="HEAD"}async function N(t,n={}){let e=n.request,r=n.method??e?.method;if(!e||!xr(r))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let o={};try{o=await J(e)}catch{}let s=await t.action({request:e,form:o,params:n.params??{},query:t.query??{},cookies:n.cookies??{}});if(s&&typeof s==="object"){let a=s,i=K(a.cookies),c=a.redirect;if(typeof c==="string"&&c)return{redirect:c,ran:!0,...i.length>0?{cookies:i}:{}};let{cookies:u,redirect:l,...f}=a;if(Object.assign(t,f),i.length>0)return{ran:!0,cookies:i}}return{ran:!0}}function K(t){if(!t||typeof t!=="object"||Array.isArray(t))return[];let n=[];for(let[e,r]of Object.entries(t)){if(!e)continue;if(typeof r==="string"){n.push(_(e,r));continue}if(r&&typeof r==="object"){let o=r;if(typeof o.value!=="string")continue;n.push(_(e,o.value,o))}}return n}function co(t,n=[],e){let r=new Headers({Location:t,"Cache-Control":"no-store"});for(let o of n)r.append("Set-Cookie",o);for(let[o,s]of Object.entries(e??{}))if(o.toLowerCase()!=="location")r.set(o,s);return new Response(null,{status:303,headers:r})}import k from"fs";import I from"path";function oo(t,n,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:e}}function io(t,n){let e=I.join(n,"manifest.json");k.writeFileSync(e,JSON.stringify(t,null,2))}function ao(t){let n=I.join(t,"manifest.json");if(!k.existsSync(n))return null;try{let e=k.readFileSync(n,"utf-8"),r=JSON.parse(e);if(r.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${r.version}`),null;return r}catch(e){return console.warn("[stx] Failed to load manifest:",e),null}}async function Pt(t,n={}){let{html:e,context:r,redirect:o,cookies:s}=await Z(t,n),a=Be(r),i=Fe(r);if(o)return{html:e,redirect:o,cookies:s,status:a,headers:i};let{extractStreamBoundaries:c}=await import("./chunk-k94w32zh.js"),u=c(r),l=t.streamTemplates;if(l&&Object.keys(l).length>0){let{processDirectives:f}=await import("./chunk-ymvmhaqn.js"),{defaultConfig:p}=await import("./chunk-dqd53ks1.js"),h=r.streamBoundaries||{},x={...p,autoShell:!1},y=Object.keys(l).map((g)=>({id:g,render:async()=>{let S=typeof h[g]==="function"?await h[g]():void 0;return f(l[g],{...r,$boundary:S},t.sourceFile,x,new Set)}})),R=new Set(y.map((g)=>g.id));u=[...(u||[]).filter((g)=>!R.has(g.id)),...y]}return{html:e,boundaries:u&&u.length>0?u:void 0,cookies:s,status:a,headers:i}}async function Z(t,n){let e={__filename:t.sourceFile,__dirname:t.sourceFile.replace(/[/\\][^/\\]+$/,""),...n};if(!t.hasServerScripts&&!Gr(t.html))return{html:t.html,context:e};for(let a of t.serverScriptContent)try{await d(a,e,t.sourceFile)}catch(i){if(n.__stx_strict_hydration)throw i;console.warn(`[stx] Server script error in ${t.sourceFile}:`,i)}let r=await N(e,{request:n.request,method:n.method,params:n.params??{},cookies:n.cookies??{}}),o=(a)=>{let i=a.replace(/<script\b[^>]*\bdata-stx-server-data\b[^>]*>[\s\S]*?<\/script>/gi,""),c=Bn(e);if(!c)return i;let u=i.indexOf("</head>");return u<0?c+i:i.slice(0,u)+c+i.slice(u)};if(r.redirect)return{html:t.html,context:e,redirect:r.redirect,cookies:r.cookies};if(!Gr(t.html))return{html:o(t.html),context:e,cookies:r.cookies};let s=new Map;for(let[a,i]of Object.entries(t.placeholders))if(i.expression)try{let c=b(i.expression,e);if(i.type==="raw")s.set(a,c!==void 0&&c!==null?String(c):"");else s.set(a,c!==void 0&&c!==null?wt(String(c)):"")}catch(c){if(n.__stx_strict_hydration)throw c;s.set(a,"")}return{html:o(Fo(t.html,s)),context:e,cookies:r.cookies}}
|
|
30
30
|
export{to,_e,no,ne,C,ro,vr,kn,ge,so,re,oo,io,ao,xr,co,Pt};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Pe,Ut}from"./chunk-p7m673vn.js";import{Se}from"./chunk-
|
|
2
|
+
import{Pe,Ut}from"./chunk-p7m673vn.js";import{Se}from"./chunk-qzgqg0bw.js";import{jo,Bo,f,xt,M,Fn,zn,Hn,n,Q,A,o}from"./chunk-vavj9qkx.js";import{S}from"./chunk-jwpcck1b.js";import{vs}from"./chunk-ame3pmf0.js";import{ln,de}from"./chunk-zqzv5jy2.js";import{yi}from"./chunk-yx37nrgr.js";import{ge,re,oo,io,Pt}from"./chunk-r4xyes78.js";import{yt,Hr}from"./chunk-4c84e4qb.js";import{It}from"./chunk-rdq113p4.js";import{dt,Xt,Gt}from"./chunk-yd50awqp.js";import{createHash as ee}from"crypto";function J(i){return ee("sha256").update(i).digest("hex").slice(0,8)}function U(i=!1){let l=i?Ut():Pe(),a=J(l);return{content:l,filename:`runtime.${a}.js`,hash:a}}function V(){let i=Se(),l=J(i);return{content:i,filename:`router.${l}.js`,hash:l}}import m from"fs";import c from"path";import q from"path";import{createHash as te}from"crypto";function se(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(),_=te("sha256").update(e).digest("hex").slice(0,16);jo();let R={};try{R=await o(a.configDir)}catch{}let y=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,g;while((g=d.exec(e))!==null){let v=g[1];if(/\bserver\b/.test(v))y.push(g[2])}let u=new Set(y.flatMap((v)=>Q(v))),{context:w}=se({__filename:r,__dirname:q.dirname(r),__stx_serverDeclared:u}),C=new Set,P={...A,...R,...a,buildMode:"compile",strict:!1},b=await n(e,w,r,P,C),T=ge(b),B=Bo();return{route:l,sourceFile:i,html:b,fragment:T,placeholders:B,hasServerScripts:y.length>0,serverScriptContent:y,dependencies:Array.from(C),contentHash:_,status:xt(e),streamTemplates:w.__streamTemplates}}var ne=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(_,R){let y=m.readdirSync(_,{withFileTypes:!0});for(let d of y){if(ne.has(d.name))continue;let g=c.join(_,d.name),u=c.join(R,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 Xc(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),_=c.resolve(a,i.componentsDir??e.componentsDir??"components"),R=c.resolve(a,i.partialsDir??e.partialsDir??"partials"),y=c.resolve(a,i.layoutsDir??e.layoutsDir??"layouts"),d=i.publicDir??e.publicDir??"public",g=de(e.app?.head,{known:ln,source:"app.head"}),u=e.app?.colorMode,w=e.router?.container||"main",C=i.routeRules??e.routeRules??{},P=It(C),b=i.serverApi??e.serverApi,T=typeof b==="object"?b:{};if(b)yt(a,T);if(e.runtimeConfig)S(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 v=M(a,{pagesDirs:e._layerPageDirs}),Y=["components","layouts","partials"],O=v.filter((s)=>!Y.some((h)=>s.pattern.startsWith(`/${h}/`)||s.pattern===`/${h}`));console.log(`[stx build] Found ${O.length} page routes (${v.length-O.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let D=U(i.debug),x=V();await Bun.write(c.join(r,"public","__stx",D.filename),D.content),await Bun.write(c.join(r,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${D.filename} (${(D.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 k=[],H=[];for(let s of O){let h=P(s.pattern),E=h.rendering==="prerender";if(E&&(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:_,partialsDir:R,layoutsDir:y,debug:i.debug});if(k.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,D.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),t.html=Hn(t.html,g,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=Fn(t.html,u);if(g.htmlAttrs)t.html=zn(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),E){let p=await Pt(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=re(t.html,w);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),H.push({pattern:s.pattern,compiledPath:G,fragmentPath:I,isDynamic:t.hasServerScripts,hasParams:s.pattern.includes(":")||s.pattern.includes("["),prerendered:E}),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 F=c.resolve(a,d);if(m.existsSync(F)){let{copied:s,bytes:h}=Z(F,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 N=Gt(a);if(N){let{copied:s,bytes:h}=Z(N,c.join(r,"public",Xt));if(s>0)console.log(`[stx build] Copied ${s} asset${s===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${dt}/`)}let K={runtime:D.filename,router:x.filename},j=oo(H,K,r);if(j.routeRules=C,j.routerContainer=w,b)j.apiRoutes=await Hr(a,r,T);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await vs(a,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(yi(e._layerGraph),null,2));io(j,r);let L=Date.now()-l;return console.log(`
|
|
3
3
|
[stx build] Done in ${L}ms \u2014 ${k.length} pages compiled`),{pageCount:k.length,assets:K,outputDir:r,duration:L}}
|
|
4
4
|
export{Xc};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{d,os,Go,Jo,mc,hc,yc,bc,wc,vc,Ve,N,Ue,xc,Un,Sc,ai,kc,We,r,Wn,ci,g,ee,ju}from"./chunk-
|
|
2
|
+
import{d,os,Go,Jo,mc,hc,yc,bc,wc,vc,Ve,N,Ue,xc,Un,Sc,ai,kc,We,r,Wn,ci,g,ee,ju}from"./chunk-vavj9qkx.js";import"./chunk-0xztxj98.js";import"./chunk-73h7qjgq.js";import"./chunk-yx37nrgr.js";import"./chunk-ame3pmf0.js";import"./chunk-jwpcck1b.js";import"./chunk-g8k5rsqq.js";import"./chunk-zqzv5jy2.js";import"./chunk-5xj1df83.js";import"./chunk-axydabse.js";import"./chunk-afhkvj3k.js";import"./chunk-qzgqg0bw.js";import"./chunk-dqr5n49p.js";export{ee as clearComponentCache,kc as componentClientSignalNames,os as convertToCommonJS,g as createDetailedErrorMessage,wc as extractDirectiveNames,Go as extractScriptFromTemplate,d as extractVariables,r as fileExists,ju as getComponentCacheStats,hc as getPositionInfo,N as getSharedTranspiler,ci as getSourceLineInfo,bc as hasDirectives,Jo as hasVariables,Sc as isHydrateTrigger,vc as isJavaScriptScript,We as renderComponentWithSlot,Wn as resolveTemplatePath,xc as scopeOnRootElement,Ve as shouldTranspileTypeScript,ai as slotContentHasExpressions,Ue as transpileTypeScript,Un as userComponentFileExists,yc as validateDirective,mc as validateTemplate};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Pn,Oe,Ne,me,Uo,Nn,Z,q,nn,d,n,A}from"./chunk-
|
|
2
|
+
import{Pn,Oe,Ne,me,Uo,Nn,Z,q,nn,d,n,A}from"./chunk-vavj9qkx.js";import{dirname as C,resolve as R}from"path";function h(o){return o.endsWith(".md")||o.endsWith(".markdown")}function _(o){let e=[];m(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let r=[...e];m(/<code\b[^>]*>[\s\S]*?<\/code>/gi,r);function m(s,p){let u;while((u=s.exec(o))!==null){let t=u.index,i=t+u[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:m}=Pn(o),c=await(e.renderer??((s)=>Oe(s)))(m);return{html:_(c),frontmatter:r??{}}}function k(o){let e=o,r=Z(o);if(r)e=r.content.trim();let m=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,a=[],c=[],s=[],p=(i)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(i),u;while((u=m.exec(o))!==null){let i=u[1],l=u[2],f=u[0],g=i.includes("server");if(p(l))s.push(f);else if(g)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 g=l.index+l[0].length,x=t.indexOf("</script>",g);if(x===-1)continue;f.push({start:l.index,end:x+9}),i.lastIndex=x+9}for(let g=f.length-1;g>=0;g--)t=t.substring(0,f[g].start)+t.substring(f[g].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=Ne(p),g=(await Promise.all(c.map(async(w)=>{let y=w.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!y)return w;return await me(y[1],{eventBindings:i,templateContent:t,serverData:l,filePath:e})}))).join(`
|
|
15
15
|
`);if(t.match(/(<\/body>)/i))t=t.replace(/(<\/body>)/i,`${g}
|
|
16
16
|
$1`);else t+=`
|
|
17
|
-
${g}`}t=await q(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
|
+
${g}`}t=await q(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-ygvyg62e.js");t=await i(t)}catch{}return t}
|
|
18
18
|
export{Eo};
|