@stacksjs/stx 0.2.671 → 0.2.673
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-jcrk8xn6.js → chunk-0f4csefs.js} +2 -2
- package/dist/{chunk-mehp1sma.js → chunk-0qqvmfrw.js} +5 -5
- package/dist/{chunk-7fk5ygvh.js → chunk-1fd7x7b8.js} +1 -1
- package/dist/{chunk-c836tm9c.js → chunk-1ptwdkvn.js} +1 -1
- package/dist/chunk-1v60t3sb.js +2 -0
- package/dist/{chunk-v0v2xnk7.js → chunk-5xvan09w.js} +1 -1
- package/dist/{chunk-bjrx38kf.js → chunk-6rzshbey.js} +1 -1
- package/dist/{chunk-2jqthnya.js → chunk-7b3kr56x.js} +1 -1
- package/dist/{chunk-gfa140m0.js → chunk-81q3sc0w.js} +1 -1
- package/dist/{chunk-wj9njs0n.js → chunk-8d33aqs5.js} +1 -1
- package/dist/chunk-8tdz8svp.js +2 -0
- package/dist/{chunk-av3qvakg.js → chunk-8yqfpkp4.js} +3 -3
- package/dist/{chunk-ttszb0qr.js → chunk-99bhc1h1.js} +1 -1
- package/dist/chunk-9rrnyd5m.js +2 -0
- package/dist/{chunk-kezhxaye.js → chunk-9tdnfztv.js} +2 -2
- package/dist/{chunk-k35fd0mn.js → chunk-agqcqf3q.js} +4 -4
- package/dist/{chunk-wytkp0ss.js → chunk-amkwmxs8.js} +1 -1
- package/dist/chunk-b1hxtn08.js +2 -0
- package/dist/{chunk-pe470p36.js → chunk-b4vk2m82.js} +1 -1
- package/dist/chunk-b58tv8jc.js +25 -0
- package/dist/{chunk-ey3wv3qq.js → chunk-b6nzy1rg.js} +1 -1
- package/dist/{chunk-wmkmj8d3.js → chunk-chzgfna2.js} +1 -1
- package/dist/{chunk-erpjegf6.js → chunk-dq56166k.js} +1 -1
- package/dist/{chunk-r3e1avhs.js → chunk-e6p0k6br.js} +1 -1
- package/dist/{chunk-pjgnvpks.js → chunk-f8agvh5v.js} +1 -1
- package/dist/{chunk-1s6j0k3c.js → chunk-g64z2e92.js} +1 -1
- package/dist/{chunk-3gcpv242.js → chunk-gw7h5k3b.js} +1 -1
- package/dist/{chunk-s45a5axx.js → chunk-h4dkvnhd.js} +2 -2
- package/dist/{chunk-11c5q4h7.js → chunk-hmyb701s.js} +2 -2
- package/dist/chunk-hzv2qj0t.js +18 -0
- package/dist/{chunk-48cx52vd.js → chunk-jefe0rgt.js} +2 -2
- package/dist/{chunk-w63hh78w.js → chunk-jg5zt20a.js} +5 -5
- package/dist/{chunk-zg08y45x.js → chunk-jr9wfthg.js} +1 -1
- package/dist/{chunk-j2318qfk.js → chunk-jst1fbdm.js} +1 -1
- package/dist/chunk-kq9y6gfy.js +2 -0
- package/dist/{chunk-1zeerj7e.js → chunk-m6q3f5rf.js} +4 -4
- package/dist/chunk-md2qhahg.js +2 -0
- package/dist/{chunk-x3s7wxm6.js → chunk-mxbc2ahy.js} +1 -1
- package/dist/{chunk-zcv5vjq3.js → chunk-p38m3947.js} +1 -1
- package/dist/{chunk-d21ag28g.js → chunk-ptcj11b4.js} +1 -1
- package/dist/chunk-qcjh3pp8.js +2 -0
- package/dist/{chunk-x5tgasp8.js → chunk-qmfycza5.js} +1 -1
- package/dist/{chunk-kjfnym5y.js → chunk-qw441qys.js} +1 -1
- package/dist/chunk-qyjsne99.js +2 -0
- package/dist/{chunk-6z3d3t00.js → chunk-rcsgt4wy.js} +1 -1
- package/dist/{chunk-nhh8b7xj.js → chunk-rermy54w.js} +1 -1
- package/dist/{chunk-9ah1zsch.js → chunk-rwjf25ht.js} +1 -1
- package/dist/{chunk-1yf17fzh.js → chunk-rx0ep3v1.js} +1 -1
- package/dist/{chunk-7k3v1qv8.js → chunk-sfc2v7rt.js} +1 -1
- package/dist/chunk-sy0z64yz.js +2 -0
- package/dist/{chunk-2j996te9.js → chunk-t0zh1dn9.js} +6 -6
- package/dist/{chunk-nm7h30yt.js → chunk-ta7bmfvg.js} +1 -1
- package/dist/{chunk-435ww2a2.js → chunk-vhs13kbf.js} +1 -1
- package/dist/{chunk-kjrrxwj0.js → chunk-wns8g6k9.js} +1 -1
- package/dist/{chunk-z7t0ds1f.js → chunk-xr69d4tk.js} +1 -1
- package/dist/{chunk-10np2c03.js → chunk-xwhmh0w0.js} +1 -1
- package/dist/chunk-xz6dw6yw.js +2 -0
- package/dist/{chunk-eky3cdcg.js → chunk-y8kdy3d2.js} +1 -1
- package/dist/{chunk-m6zpcyhm.js → chunk-yg267y85.js} +1 -1
- package/dist/{chunk-mnyf1jq8.js → chunk-ynz7bzc6.js} +1 -1
- package/dist/{chunk-k5wpdg44.js → chunk-zvygkwyf.js} +1 -1
- package/dist/cli.js +7 -7
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/loops.js +7 -1
- package/dist/menubar-build.d.ts +10 -0
- package/dist/menubar-build.js +38 -0
- package/dist/pwa.js +1 -1
- package/dist/render.js +3 -0
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-1pw1nvta.js +0 -25
- package/dist/chunk-7s44ew85.js +0 -2
- package/dist/chunk-a92b91a7.js +0 -2
- package/dist/chunk-dnszn1xb.js +0 -2
- package/dist/chunk-e5dvqb47.js +0 -2
- package/dist/chunk-ggxkpxfm.js +0 -2
- package/dist/chunk-m0e0n317.js +0 -2
- package/dist/chunk-qzfcy37r.js +0 -2
- package/dist/chunk-t8w6h94x.js +0 -2
- package/dist/chunk-vy35p3qj.js +0 -2
- package/dist/chunk-wqgz7vqp.js +0 -2
- package/dist/chunk-ym09kjfr.js +0 -18
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t,a}from"./chunk-2dp7hyv7.js";import{n,pn,m}from"./chunk-
|
|
2
|
+
import{t,a}from"./chunk-2dp7hyv7.js";import{n,pn,m}from"./chunk-t0zh1dn9.js";import{Ye}from"./chunk-365vg0eg.js";import{Xr,Jr}from"./chunk-fzqj1mjz.js";import{va,go,Gr,Kr}from"./chunk-04kg16qs.js";import{ha,ya}from"./chunk-yg267y85.js";import{bt}from"./chunk-3hxd5td3.js";import{nn,Ca,tr,nr}from"./chunk-zhf01af3.js";import{f}from"./chunk-b7e07ybq.js";import{Ts}from"./chunk-qv6axke4.js";import Q from"fs";import j from"path";import{loadConfigWithResult as Ht}from"bunfig";var B={duration:300,delay:0,ease:"ease",direction:"both"};function nt(e,r={}){let{duration:i,delay:l,ease:s,direction:c,custom:d}={...B,...r};if(e==="custom"&&d)return d;switch(e){case"fade":return`${c==="in"?"opacity: 0; animation: fadeIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":c==="out"?"opacity: 1; animation: fadeOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"opacity: 1; transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
|
|
3
3
|
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
|
|
4
4
|
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }`;case"slide":return`${c==="in"?"transform: translateY(20px); opacity: 0; animation: slideIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":c==="out"?"transform: translateY(0); opacity: 1; animation: slideOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"transform: translateY(0); opacity: 1; transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms), opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
|
|
5
5
|
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
|
|
@@ -1307,6 +1307,6 @@ ${y}
|
|
|
1307
1307
|
customElements.define('${r}', ${d});
|
|
1308
1308
|
`}async function Qe(e,r,i,l){if(r.length<1)return a("WebComponent","@webcomponent directive requires at least the tag name parameter",t.INVALID_DIRECTIVE_SYNTAX);let s=r[0].replace(/['"]/g,""),d=(i.__stx_options||{}).componentsDir||"components",p=q.isAbsolute(d)?[q.join(d,`${s}.stx`),q.join(q.dirname(l),`${s}.stx`)]:[q.join(q.dirname(l),d,`${s}.stx`),q.join(process.cwd(),d,`${s}.stx`),q.join(q.dirname(l),`${s}.stx`)],u=null;for(let h of p)if(await n(h)){u=await Bun.file(h).text();break}if(!u)return a("WebComponent",`Component file not found: ${s}.stx`,t.FILE_NOT_FOUND);let g=Ft(u,s);return`<script type="module">
|
|
1309
1309
|
${qt(g)}
|
|
1310
|
-
</script>`}var N={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,stateDir:nn,cachePath:".stx/cache",cacheVersion:"1.0.0",componentRenderCacheBytes:33554432,build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:Ie,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:Qe,hasEndTag:!1,description:"Include a web component in the template"},ha,ya,Xr,Jr,De,ke,Ae,Pe,_e,Oe,Fe,$e,...Ts],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"main",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,scrollRestoration:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};function Ut(e,r,i){let l=r||"pages";if(e)return{root:e,pagesDir:l};let s=i||process.cwd(),c=j.join(s,"resources","views"),d=j.join(s,"resources","layouts");if(Q.existsSync(c)&&Q.existsSync(d))return{root:"resources",pagesDir:"views"};let p=j.join(s,"resources","views","pages");if(Q.existsSync(p))return{root:"resources/views",pagesDir:l};return{root:".",pagesDir:l}}var et=new Set,ue=["partialsDir","componentsDir","layoutsDir"],Se=new WeakMap;function Bt(e,r){let i=r.replace(/[\\/]+$/,"");if(!i||i===".")return!0;let l=e.replace(/\\/g,"/"),s=i.replace(/\\/g,"/");return l===s||l.startsWith(`${s}/`)}function Rl(e,r){let i=!e.root,l=Ut(e.root,e.pagesDir,r);if(e.root=l.root,e.pagesDir=l.pagesDir,i&&l.root!=="."){let s=`${r}::${l.root}`;if(!et.has(s))et.add(s),console.warn(`[stx] No "root" in config \u2014 inferred "${l.root}" from the project layout. Template directories are resolved under it; set root explicitly to pin this.`)}if(!Se.has(e)){let s={};for(let c of ue){let d=e[c];if(typeof d==="string"&&d)s[c]=d}Se.set(e,s)}if(e.root&&e.root!=="."){let s=e.root;for(let c of ue){let d=e[c];if(typeof d!=="string"||!d)continue;if(j.isAbsolute(d)||Bt(d,s))continue;e[c]=j.join(s,d)}}for(let s of ue){let c=e[s];if(typeof c!=="string"||!c||j.isAbsolute(c))continue;e[s]=j.resolve(r,c)}return e}function Jt(e,r){let i=Se.get(e);for(let l of ue){let s=e[l];if(typeof s!=="string"||!s)continue;let c=j.isAbsolute(s)?s:j.join(r,s);if(Q.existsSync(c))continue;let d=i?.[l]??s,p=e.root,u=!!p&&p!==".";console.warn(`[stx] ${String(l)} resolves to "${c}", which does not exist. Configured as "${d}"`+(u?`, resolved under root "${p}".`:"."))}}function Kt(e){if(e.customDirectives)e.customDirectives=[...e.customDirectives];if(e.middleware)e.middleware=[...e.middleware];if(e.apiRoutes)e.apiRoutes={...e.apiRoutes}}function Gt(e){if(Ca(e.stateDir),e.stateDir=tr(),e.cachePath=nr(e.cachePath),e.build)e.build.cacheDir=nr(e.build.cacheDir);if(e.media?.cache)e.media.cache.directory=nr(e.media.cache.directory);if(e.story)e.story.outDir=nr(e.story.outDir)}var K=null,Y=new Map,de=new Map,se=null;async function po(e,r=Ht){try{return await r(e)}catch(i){if(i instanceof Error&&i.name==="ConfigNotFoundError")return{config:e.defaultConfig};throw i}}async function o(e){let r=e?j.resolve(e):process.cwd(),i=de.get(r);if(i&&i.signature!==Gr(i.graph)){let c=Y.get(r);if(Y.delete(r),de.delete(r),!e)K=null,se=null;let{clearComponentCache:d}=await import("./chunk-z7t0ds1f.js"),{partialsCache:p}=await import("./chunk-zcv5vjq3.js");if(d(),p.clear(),c&&i.configSignature===Kr(i.graph)){let u=c.then(async(g)=>{let y={...i.graph};await go(y,r),de.set(r,{graph:y,signature:Gr(y),configSignature:Kr(y)});let h={...g,_layerGraph:y};if(!e)K=h;return h});return Y.set(r,u),u}}if(!e){if(K)return K;if(se)return se}let l=Y.get(r);if(l)return l;let s=(async()=>{let c=[".ts",".js",".mjs",".cjs",".json"],d=c.some((v)=>Q.existsSync(j.join(r,`stx.config${v}`))),p=c.some((v)=>Q.existsSync(j.join(r,"config",`ui${v}`))),u;if(d&&p){let v=await po({name:"ui",cwd:j.join(r,"config"),defaultConfig:N,errorPolicy:"throw",verbose:!1});u=(await po({name:"stx",alias:"ui",cwd:r,defaultConfig:v.config,errorPolicy:"throw",verbose:!1})).config}else u=(await po({name:"stx",alias:"ui",cwd:r,defaultConfig:N,errorPolicy:"throw",verbose:!1})).config;if(u.extends!==void 0||i){let v=await va(r,N);u=v.config,de.set(r,{graph:v.graph,signature:Gr(v.graph),configSignature:Kr(v.graph)})}if(u.runtimeConfig){let{resolveRuntimeConfig:v}=await import("./chunk-02ymqwmj.js");v(u.runtimeConfig,{});let{generateRuntimeConfigTypes:b}=await import("./chunk-kjfnym5y.js");await b(r,u.runtimeConfig)}Kt(u),Gt(u),Rl(u,r),Jt(u,r);let g=[],y=new Set((u.plugins??[]).map((v)=>typeof v==="string"?v:v[0]));for(let v of u.componentPackages??["@stacksjs/components"]){let b=`${v}/stx-plugin`;if(y.has(b)||y.has(v))continue;try{f.resolve(b,{paths:[r]}),g.push(b)}catch{}}let h=[...u.plugins??[],...g];if(h.length>0){let{pluginManager:v}=await import("./chunk-fcn71bq1.js"),b=[],x=[];for(let P of h){let S=typeof P==="string"?P:P[0],A=typeof P==="string"?{}:P[1]||{};try{let k,E;try{let w=f.resolve(S,{paths:[r]});k=await import(w),E=j.dirname(w)}catch{let w=j.resolve(r,S);k=await import(w),E=j.dirname(w)}let I=k.default||k;if(!v.has(I.name))await v.register(I,u);if(I.components){let w=Array.isArray(I.components)?I.components:[I.components];for(let C of w)b.push(j.resolve(E,C))}if(I.pages){let w=j.resolve(E,I.pages),C=A.path||"/";x.push({dir:w,prefix:C})}if(I.setup){let w={addDirective:(C)=>{u.customDirectives=u.customDirectives||[],u.customDirectives.push(C)},addRoute:(C,D)=>{u.apiRoutes=u.apiRoutes||{},u.apiRoutes[C]=D},addMiddleware:(C)=>{u.middleware=u.middleware||[],u.middleware.push(C)},pluginDir:E,config:u};await I.setup(A,w)}process.stderr.write(`[stx] Plugin loaded: ${I.name||S}
|
|
1310
|
+
</script>`}var N={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,stateDir:nn,cachePath:".stx/cache",cacheVersion:"1.0.0",componentRenderCacheBytes:33554432,build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:Ie,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:Qe,hasEndTag:!1,description:"Include a web component in the template"},ha,ya,Xr,Jr,De,ke,Ae,Pe,_e,Oe,Fe,$e,...Ts],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"main",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,scrollRestoration:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};function Ut(e,r,i){let l=r||"pages";if(e)return{root:e,pagesDir:l};let s=i||process.cwd(),c=j.join(s,"resources","views"),d=j.join(s,"resources","layouts");if(Q.existsSync(c)&&Q.existsSync(d))return{root:"resources",pagesDir:"views"};let p=j.join(s,"resources","views","pages");if(Q.existsSync(p))return{root:"resources/views",pagesDir:l};return{root:".",pagesDir:l}}var et=new Set,ue=["partialsDir","componentsDir","layoutsDir"],Se=new WeakMap;function Bt(e,r){let i=r.replace(/[\\/]+$/,"");if(!i||i===".")return!0;let l=e.replace(/\\/g,"/"),s=i.replace(/\\/g,"/");return l===s||l.startsWith(`${s}/`)}function Rl(e,r){let i=!e.root,l=Ut(e.root,e.pagesDir,r);if(e.root=l.root,e.pagesDir=l.pagesDir,i&&l.root!=="."){let s=`${r}::${l.root}`;if(!et.has(s))et.add(s),console.warn(`[stx] No "root" in config \u2014 inferred "${l.root}" from the project layout. Template directories are resolved under it; set root explicitly to pin this.`)}if(!Se.has(e)){let s={};for(let c of ue){let d=e[c];if(typeof d==="string"&&d)s[c]=d}Se.set(e,s)}if(e.root&&e.root!=="."){let s=e.root;for(let c of ue){let d=e[c];if(typeof d!=="string"||!d)continue;if(j.isAbsolute(d)||Bt(d,s))continue;e[c]=j.join(s,d)}}for(let s of ue){let c=e[s];if(typeof c!=="string"||!c||j.isAbsolute(c))continue;e[s]=j.resolve(r,c)}return e}function Jt(e,r){let i=Se.get(e);for(let l of ue){let s=e[l];if(typeof s!=="string"||!s)continue;let c=j.isAbsolute(s)?s:j.join(r,s);if(Q.existsSync(c))continue;let d=i?.[l]??s,p=e.root,u=!!p&&p!==".";console.warn(`[stx] ${String(l)} resolves to "${c}", which does not exist. Configured as "${d}"`+(u?`, resolved under root "${p}".`:"."))}}function Kt(e){if(e.customDirectives)e.customDirectives=[...e.customDirectives];if(e.middleware)e.middleware=[...e.middleware];if(e.apiRoutes)e.apiRoutes={...e.apiRoutes}}function Gt(e){if(Ca(e.stateDir),e.stateDir=tr(),e.cachePath=nr(e.cachePath),e.build)e.build.cacheDir=nr(e.build.cacheDir);if(e.media?.cache)e.media.cache.directory=nr(e.media.cache.directory);if(e.story)e.story.outDir=nr(e.story.outDir)}var K=null,Y=new Map,de=new Map,se=null;async function po(e,r=Ht){try{return await r(e)}catch(i){if(i instanceof Error&&i.name==="ConfigNotFoundError")return{config:e.defaultConfig};throw i}}async function o(e){let r=e?j.resolve(e):process.cwd(),i=de.get(r);if(i&&i.signature!==Gr(i.graph)){let c=Y.get(r);if(Y.delete(r),de.delete(r),!e)K=null,se=null;let{clearComponentCache:d}=await import("./chunk-xr69d4tk.js"),{partialsCache:p}=await import("./chunk-p38m3947.js");if(d(),p.clear(),c&&i.configSignature===Kr(i.graph)){let u=c.then(async(g)=>{let y={...i.graph};await go(y,r),de.set(r,{graph:y,signature:Gr(y),configSignature:Kr(y)});let h={...g,_layerGraph:y};if(!e)K=h;return h});return Y.set(r,u),u}}if(!e){if(K)return K;if(se)return se}let l=Y.get(r);if(l)return l;let s=(async()=>{let c=[".ts",".js",".mjs",".cjs",".json"],d=c.some((v)=>Q.existsSync(j.join(r,`stx.config${v}`))),p=c.some((v)=>Q.existsSync(j.join(r,"config",`ui${v}`))),u;if(d&&p){let v=await po({name:"ui",cwd:j.join(r,"config"),defaultConfig:N,errorPolicy:"throw",verbose:!1});u=(await po({name:"stx",alias:"ui",cwd:r,defaultConfig:v.config,errorPolicy:"throw",verbose:!1})).config}else u=(await po({name:"stx",alias:"ui",cwd:r,defaultConfig:N,errorPolicy:"throw",verbose:!1})).config;if(u.extends!==void 0||i){let v=await va(r,N);u=v.config,de.set(r,{graph:v.graph,signature:Gr(v.graph),configSignature:Kr(v.graph)})}if(u.runtimeConfig){let{resolveRuntimeConfig:v}=await import("./chunk-02ymqwmj.js");v(u.runtimeConfig,{});let{generateRuntimeConfigTypes:b}=await import("./chunk-qw441qys.js");await b(r,u.runtimeConfig)}Kt(u),Gt(u),Rl(u,r),Jt(u,r);let g=[],y=new Set((u.plugins??[]).map((v)=>typeof v==="string"?v:v[0]));for(let v of u.componentPackages??["@stacksjs/components"]){let b=`${v}/stx-plugin`;if(y.has(b)||y.has(v))continue;try{f.resolve(b,{paths:[r]}),g.push(b)}catch{}}let h=[...u.plugins??[],...g];if(h.length>0){let{pluginManager:v}=await import("./chunk-fcn71bq1.js"),b=[],x=[];for(let P of h){let S=typeof P==="string"?P:P[0],A=typeof P==="string"?{}:P[1]||{};try{let k,E;try{let w=f.resolve(S,{paths:[r]});k=await import(w),E=j.dirname(w)}catch{let w=j.resolve(r,S);k=await import(w),E=j.dirname(w)}let I=k.default||k;if(!v.has(I.name))await v.register(I,u);if(I.components){let w=Array.isArray(I.components)?I.components:[I.components];for(let C of w)b.push(j.resolve(E,C))}if(I.pages){let w=j.resolve(E,I.pages),C=A.path||"/";x.push({dir:w,prefix:C})}if(I.setup){let w={addDirective:(C)=>{u.customDirectives=u.customDirectives||[],u.customDirectives.push(C)},addRoute:(C,D)=>{u.apiRoutes=u.apiRoutes||{},u.apiRoutes[C]=D},addMiddleware:(C)=>{u.middleware=u.middleware||[],u.middleware.push(C)},pluginDir:E,config:u};await I.setup(A,w)}process.stderr.write(`[stx] Plugin loaded: ${I.name||S}
|
|
1311
1311
|
`)}catch(k){console.warn(`[stx] Failed to load plugin ${S}:`,k.message)}}u._pluginComponentDirs=b,u._pluginPageDirs=x}return u})();if(Y.set(r,s),s.catch(()=>{if(Y.get(r)===s)Y.delete(r)}),!e)se=s,s.then((c)=>{K=c}).catch(()=>{});return s}var R=new Proxy(N,{get(e,r){if(K&&r in K)return K[r];if(!se)o().catch((i)=>{console.warn("[stx] Failed to load config file:",i?.message||i)});return e[r]}});function xp(e){return e}function Sp(e){let r=[],i=[];if(e.partialsDir!==void 0&&typeof e.partialsDir!=="string")r.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if(e.componentsDir!==void 0&&typeof e.componentsDir!=="string")r.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if(e.cache!==void 0&&typeof e.cache!=="boolean")r.push({path:"cache",message:"cache must be a boolean",severity:"error"});if(e.debug!==void 0&&typeof e.debug!=="boolean")r.push({path:"debug",message:"debug must be a boolean",severity:"error"});if(e.streaming){if(e.streaming.bufferSize!==void 0){if(typeof e.streaming.bufferSize!=="number"||e.streaming.bufferSize<=0)r.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if(e.streaming.timeout!==void 0){if(typeof e.streaming.timeout!=="number"||e.streaming.timeout<=0)r.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if(e.streaming.strategy!==void 0){let l=["auto","manual","sections"];if(!l.includes(e.streaming.strategy))r.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${l.join(", ")}`,severity:"error"})}}if(e.i18n){if(e.i18n.format!==void 0){let l=["json","yaml","yml","js"];if(!l.includes(e.i18n.format))r.push({path:"i18n.format",message:`i18n.format must be one of: ${l.join(", ")}`,severity:"error"})}}if(e.animation){if(e.animation.defaultDuration!==void 0){if(typeof e.animation.defaultDuration!=="number"||e.animation.defaultDuration<0)r.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if(e.animation.staggerDelay!==void 0){if(typeof e.animation.staggerDelay!=="number"||e.animation.staggerDelay<0)r.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if(e.a11y){if(e.a11y.level!==void 0){let l=["AA","AAA"];if(!l.includes(e.a11y.level))r.push({path:"a11y.level",message:`a11y.level must be one of: ${l.join(", ")}`,severity:"error"})}}if(e.hydration){if(e.hydration.mode!==void 0){let l=["progressive","islands"];if(!l.includes(e.hydration.mode))r.push({path:"hydration.mode",message:`hydration.mode must be one of: ${l.join(", ")}`,severity:"error"})}if(e.hydration.preload!==void 0){let l=["none","eager","lazy"];if(!l.includes(e.hydration.preload))r.push({path:"hydration.preload",message:`hydration.preload must be one of: ${l.join(", ")}`,severity:"error"})}}if(e.customDirectives)if(!Array.isArray(e.customDirectives))r.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else e.customDirectives.forEach((l,s)=>{if(!l.name||typeof l.name!=="string")r.push({path:`customDirectives[${s}].name`,message:"Custom directive must have a name string",severity:"error"});if(!l.handler||typeof l.handler!=="function")r.push({path:`customDirectives[${s}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if(e.middleware)if(!Array.isArray(e.middleware))r.push({path:"middleware",message:"middleware must be an array",severity:"error"});else e.middleware.forEach((l,s)=>{if(!l.name||typeof l.name!=="string")r.push({path:`middleware[${s}].name`,message:"Middleware must have a name string",severity:"error"});if(!l.handler||typeof l.handler!=="function")r.push({path:`middleware[${s}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!l.timing||!["before","after"].includes(l.timing))r.push({path:`middleware[${s}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if(e.debug===!0&&e.cache===!0)i.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if(e.seo?.enabled===!0&&!e.seo?.defaultConfig?.title)i.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if(e.pwa){if(e.pwa.enabled===!0&&!e.pwa.manifest?.name)r.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if(e.pwa.manifest?.display!==void 0){let l=["fullscreen","standalone","minimal-ui","browser"];if(!l.includes(e.pwa.manifest.display))r.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${l.join(", ")}`,severity:"error"})}if(e.pwa.manifest?.orientation!==void 0){let l=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!l.includes(e.pwa.manifest.orientation))r.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${l.join(", ")}`,severity:"error"})}if(e.pwa.routes){let l=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];e.pwa.routes.forEach((s,c)=>{if(!s.pattern||typeof s.pattern!=="string")r.push({path:`pwa.routes[${c}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!l.includes(s.strategy))r.push({path:`pwa.routes[${c}].strategy`,message:`PWA route strategy must be one of: ${l.join(", ")}`,severity:"error"});if(s.maxAgeSeconds!==void 0&&(typeof s.maxAgeSeconds!=="number"||s.maxAgeSeconds<0))r.push({path:`pwa.routes[${c}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(s.maxEntries!==void 0&&(typeof s.maxEntries!=="number"||s.maxEntries<1))r.push({path:`pwa.routes[${c}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if(e.pwa.icons?.sizes){if(!Array.isArray(e.pwa.icons.sizes))r.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if(e.pwa.icons.sizes.filter((s)=>typeof s!=="number"||s<16||s>1024).length>0)r.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if(e.pwa.icons?.purpose){let l=["any","maskable","monochrome"];if(e.pwa.icons.purpose.filter((c)=>!l.includes(c)).length>0)r.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${l.join(", ")}`,severity:"error"})}if(e.pwa.enabled===!0&&!e.pwa.icons?.src)i.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if(e.pwa.enabled===!0&&!e.pwa.manifest?.themeColor)i.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:r.length===0,errors:r,warnings:i}}
|
|
1312
1312
|
export{ua,da,Yn,Xe,pa,qr,N,Rl,po,o,R,xp,Sp};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ae,Ma,ds,ln,g,Oe,Ne}from"./chunk-t0zh1dn9.js";import{Yn,Xe,N}from"./chunk-hmyb701s.js";import{Hn,s}from"./chunk-jg5zt20a.js";import{me}from"./chunk-agqcqf3q.js";function b(o){return o.endsWith(".md")||o.endsWith(".markdown")}function k(o){let e=[];m(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let r=[...e];m(/<code\b[^>]*>[\s\S]*?<\/code>/gi,r);function m(n,p){let u;while((u=n.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((n,p)=>n.start-p.start);let c="",a=0;for(let n of e){if(n.start<a)continue;c+=o.slice(a,n.start),c+=`@raw${o.slice(n.start,n.end)}@endraw`,a=n.end}return c+=o.slice(a),c}async function R(o,e={}){let{data:r,content:m}=Yn(o),a=await(e.renderer??((n)=>Xe(n)))(m);return{html:k(a),frontmatter:r??{}}}import{dirname as v,resolve as _}from"path";function M(o){let e=o,r=ae(o);if(r)e=r.content.trim();let m=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,c=[],a=[],n=[],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],d=u[0],f=i.includes("server");if(p(l))n.push(d);else if(f)a.push(l);else c.push(d)}let t=e;{let i=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,l,d=[];while((l=i.exec(t))!==null){let f=l.index+l[0].length,x=t.indexOf("</script>",f);if(x===-1)continue;d.push({start:l.index,end:x+9}),i.lastIndex=x+9}for(let f=d.length-1;f>=0;f--)t=t.substring(0,d[f].start)+t.substring(d[f].end)}for(let i of c)t=t.replace(i,"");return{templateContent:t,serverScripts:a,clientScripts:c,signalsScripts:n}}function E(o,e){return`<!DOCTYPE html>
|
|
3
|
+
<html lang="en">
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
+
<title>${(e||"stx").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
${o}
|
|
11
|
+
</body>
|
|
12
|
+
</html>`}async function Ki(o,e={}){let r=_(o),m=Bun.file(r);if(!await m.exists())throw Error(`Template file not found: ${r}`);let c=await m.text(),a=null;if(b(r)){let n=await R(c,{renderer:e.markdownRenderer});c=n.html,a=n.frontmatter}if(a)e={...e,context:{...a,...e.context||{}}};if(e.layout){let n=_(e.layout),p=Bun.file(n);if(!await p.exists())throw Error(`Layout template not found: ${n}`);let{layout:u,injectCSS:t,...i}=e,l={...e.context||{}};ln(l);let d=await S(c,r,{...i,context:{...l,__stx_defer_server_data:!0},injectCSS:!1}),f=await p.text(),x={...l,content:d},y={...i,context:x,injectCSS:t};return S(f,n,y)}return S(c,r,e)}async function S(o,e,r={}){let{templateContent:m,serverScripts:c,clientScripts:a}=M(o),n={...N,...r.options},p={__filename:e,__dirname:v(e),__stx:{},__stx_options:n,__stx_sfc_mode:!0,__stx_inject_css:r.injectCSS===!0,__stxServeContext:void 0,...ds(r.context??{}),definePageMeta:()=>{},...r.context||{}};for(let i of c)await g(i,p,e);let u=new Set,t=m;if(t=await s(t,p,e,n,u),Ma(p,r.context),r.templateOnly){if(t=t.replace(/<script data-stx-scoped>[\s\S]*?<\/script>\s*/gi,""),t=t.replace(/<!-- stx SEO Tags -->[\s\S]*?(?=<)/i,""),a.length>0)t+=`
|
|
13
|
+
${a.join(`
|
|
14
|
+
`)}`}else{if(r.processClientScripts!==!1&&a.length>0){let i=p.__stx_event_bindings||[],l=Oe(p),d=await Promise.all(a.map(async(w)=>{let C=w.match(/<script\b([^>]*)>/i)?.[1]||"";if(/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(C))return w;let h=w.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!h)return w;return await Ne(h[1],{eventBindings:i,templateContent:t,serverData:l,filePath:e})})),x=[await Hn(d,{...n,buildMode:"compile"}),...d].filter(Boolean).join(`
|
|
15
|
+
`);if(t.match(/(<\/body>)/i))t=t.replace(/(<\/body>)/i,`${x}
|
|
16
|
+
$1`);else t+=`
|
|
17
|
+
${x}`}t=await me(t)}if(r.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=E(t,r.title)}if(r.injectCSS)try{let{injectCss:i}=await import("./chunk-rermy54w.js");t=await i(t)}catch{}return t}
|
|
18
|
+
export{Ki};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{yn}from"./chunk-2dp7hyv7.js";import{W,Pe,ce,Rt,At,cr,g,Ya,Mo,F,_}from"./chunk-
|
|
2
|
+
import{yn}from"./chunk-2dp7hyv7.js";import{W,Pe,ce,Rt,At,cr,g,Ya,Mo,F,_}from"./chunk-t0zh1dn9.js";import{H}from"./chunk-fbtv2k1p.js";var V=/\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(V.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 _i(t){let n=[],e=[],r=[],i=0;while(i<t.length){let s=t.indexOf("<",i);if(s===-1)break;let a=Pe(t,s);if(a>s){i=a;continue}let o=W(t,s);if(o>s){let c=t.slice(s,o),u=q.exec(c);if(u){let l=B(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}}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 X(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=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(!X(o,e))continue;let c=s[0],u=s.index+c.length,l=new RegExp(`<(/?)${a}\\b([^>]*)>`,"gi");l.lastIndex=u;let f=1,m;while((m=l.exec(t))!==null){if(P(m.index,i))continue;let x=m[1]==="/";if(!x&&(m[2]||"").trimEnd().endsWith("/"))continue;if(f+=x?-1:1,f===0)return{openTag:c,openIndex:s.index,start:u,end:m.index,tagName:a}}return null}return null}var ut="private, no-store";function Ci(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 Se(t){return t.headers.get("X-STX-Router")==="true"}function J(t,n){if(!t)return n;return t.split(",").some((r)=>r.trim().toLowerCase()===n.toLowerCase())?t:`${t}, ${n}`}function O(t){return{Vary:J(t,"X-STX-Router")}}import A from"path";var K="stx-page-head:",Y=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,C={dev:null,prod:null};function Z(){let t=H()?"dev":"prod",n=C[t];if(n!==null)return n;try{let e=import.meta.require("./chunk-028ee6q5.js"),r=t==="dev"&&typeof e.getRouterScriptDev==="function"?e.getRouterScriptDev:e.getRouterScript;C[t]=`<script>${r()}</script>`}catch{C[t]=""}return C[t]}async function Ei(t,n){if(n===!1)return null;if(n&&typeof n==="string"){let r=A.resolve(t,n);if(await Bun.file(r).exists())return r;return null}let e=A.join(t,"app.stx");if(await Bun.file(e).exists())return e;return null}async function js(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=_i(e),a=[...s.client.map((d)=>d.fullTag),...s.signals.map((d)=>d.fullTag)],o=[],c=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,u;while((u=c.exec(e))!==null)o.push(u[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 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:m,extractVariables:x,defaultConfig:y,loadStxConfig:R}=await import("./chunk-qyjsne99.js"),S=await R(),p={__filename:t,__dirname:A.dirname(t)};for(let d of a){let w=d.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(w&&!d.includes("client")&&!d.includes('type="module"'))await x(w[1],p,t)}let b=await m(l,p,t,{...y,...S,...n},new Set),h=b.indexOf(f);if(h===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:b.substring(0,h),afterSlot:b.substring(h+f.length),filePath:t,shellScripts:a,shellStyles:o}}catch(e){return console.error(`[stx] Error processing shell ${t}:`,e),null}}function $r(t,n,e){let r,i="",s=n.match(Y);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();i=l.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let a=e||r||"stx App",o=Z(),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)S.push(i.filter((p)=>!c.has(p)).join(`
|
|
28
28
|
`));if(x.length>0)S.push(x.filter((p)=>!c.has(p)).join(`
|
|
29
29
|
`));return S.push(m),S.join(`
|
|
30
|
-
`)}import E from"fs";import I from"path";function $i(t,n,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:e}}function Ri(t,n){let e=I.join(n,"manifest.json");E.writeFileSync(e,JSON.stringify(t,null,2))}function Ai(t){let n=I.join(t,"manifest.json");if(!E.existsSync(n))return null;try{let e=E.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 k(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 tt(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 Bs(t){if(!t)return!1;let n=t.toUpperCase();return n!=="GET"&&n!=="HEAD"}async function D(t,n={}){let e=n.request,r=n.method??e?.method;if(!e||!Bs(r))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let i={};try{i=await tt(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=et(a.cookies),c=a.redirect;if(typeof c==="string"&&c)return{redirect:c,ran:!0,...o.length>0?{cookies:o}:{}};let{cookies:u,redirect:l,...f}=a;if(Object.assign(t,f),o.length>0)return{ran:!0,cookies:o}}return{ran:!0}}function et(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(k(e,r));continue}if(r&&typeof r==="object"){let i=r;if(typeof i.value!=="string")continue;n.push(k(e,i.value,i))}}return n}function Pi(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 kn(t,n={}){let{html:e,context:r,redirect:i,cookies:s}=await nt(t,n),a=Rt(r),o=At(r);if(i)return{html:e,redirect:i,cookies:s,status:a,headers:o};let{extractStreamBoundaries:c}=await import("./chunk-
|
|
30
|
+
`)}import E from"fs";import I from"path";function $i(t,n,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:e}}function Ri(t,n){let e=I.join(n,"manifest.json");E.writeFileSync(e,JSON.stringify(t,null,2))}function Ai(t){let n=I.join(t,"manifest.json");if(!E.existsSync(n))return null;try{let e=E.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 k(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 tt(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 Bs(t){if(!t)return!1;let n=t.toUpperCase();return n!=="GET"&&n!=="HEAD"}async function D(t,n={}){let e=n.request,r=n.method??e?.method;if(!e||!Bs(r))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let i={};try{i=await tt(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=et(a.cookies),c=a.redirect;if(typeof c==="string"&&c)return{redirect:c,ran:!0,...o.length>0?{cookies:o}:{}};let{cookies:u,redirect:l,...f}=a;if(Object.assign(t,f),o.length>0)return{ran:!0,cookies:o}}return{ran:!0}}function et(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(k(e,r));continue}if(r&&typeof r==="object"){let i=r;if(typeof i.value!=="string")continue;n.push(k(e,i.value,i))}}return n}function Pi(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 kn(t,n={}){let{html:e,context:r,redirect:i,cookies:s}=await nt(t,n),a=Rt(r),o=At(r);if(i)return{html:e,redirect:i,cookies:s,status:a,headers:o};let{extractStreamBoundaries:c}=await import("./chunk-9rrnyd5m.js"),u=c(r),l=t.streamTemplates;if(l&&Object.keys(l).length>0){let{processDirectives:f}=await import("./chunk-8tdz8svp.js"),{defaultConfig:m}=await import("./chunk-8d33aqs5.js"),x=r.streamBoundaries||{},y={...m,autoShell:!1},R=Object.keys(l).map((p)=>({id:p,render:async()=>{let b=typeof x[p]==="function"?await x[p]():void 0;return f(l[p],{...r,$boundary:b},t.sourceFile,y,new Set)}})),S=new Set(R.map((p)=>p.id));u=[...(u||[]).filter((p)=>!S.has(p.id)),...R]}return{html:e,boundaries:u&&u.length>0?u:void 0,cookies:s,status:a,headers:o}}async function nt(t,n){let e={__filename:t.sourceFile,__dirname:t.sourceFile.replace(/[/\\][^/\\]+$/,""),...n};if(!t.hasServerScripts&&!Mo(t.html))return{html:t.html,context:e};for(let a of t.serverScriptContent)try{await g(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 D(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 u=o.indexOf("</head>");return u<0?c+o:o.slice(0,u)+c+o.slice(u)};if(r.redirect)return{html:t.html,context:e,redirect:r.redirect,cookies:r.cookies};if(!Mo(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=_(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?F(String(c)):"")}catch(c){if(n.__stx_strict_hydration)throw c;s.set(a,"")}return{html:i(Ya(t.html,s)),context:e,cookies:r.cookies}}
|
|
31
31
|
export{_i,ut,Ci,Se,O,Ei,js,$r,He,Ti,ke,$i,Ri,Ai,Bs,Pi,kn};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{_o,Ea,r,Et,te,S,Ae,on,Pe,le,q,or,an,us,La,ln,cr,ps,gs,ja,Ao,Ba,Fa,za,Ha,Oe,Ne,ms,Le,n,pn,m,d,F,K,ve,k,_}from"./chunk-
|
|
2
|
+
import{_o,Ea,r,Et,te,S,Ae,on,Pe,le,q,or,an,us,La,ln,cr,ps,gs,ja,Ao,Ba,Fa,za,Ha,Oe,Ne,ms,Le,n,pn,m,d,F,K,ve,k,_}from"./chunk-t0zh1dn9.js";import{l,p,E,t,re,z,a,we,zo,D,hn,Ho,Mt,Vo,ec,pr,tc,rt,nc,fr,rc,yn,Uo,sc,gr,hr,xe,Wo}from"./chunk-2dp7hyv7.js";import{Ot}from"./chunk-1sr6c0nk.js";import{gn}from"./chunk-xwhmh0w0.js";import{h}from"./chunk-h4dkvnhd.js";import{er,ts}from"./chunk-365vg0eg.js";import{ua,da,Yn,Xe,pa,R}from"./chunk-hmyb701s.js";import{mo,ho,yo,bo}from"./chunk-fzqj1mjz.js";import{oa,Br}from"./chunk-99bhc1h1.js";import{Dr,Mr,Lr}from"./chunk-m6q3f5rf.js";import{Nr,qn}from"./chunk-b58tv8jc.js";import{Fr,io,ao,zr,Hr,co}from"./chunk-9tdnfztv.js";import{Zs}from"./chunk-prf164ct.js";import{ee,no,ro,so}from"./chunk-ka8befem.js";import{Gn,ge,aa,Kn,ca}from"./chunk-agqcqf3q.js";import{U,Ge}from"./chunk-bnn7pd62.js";import{fa,ga}from"./chunk-yg267y85.js";import{C,bn,qo}from"./chunk-fbtv2k1p.js";import fs from"fs";import ce from"path";function lt(){return`
|
|
3
3
|
// STX Lifecycle Runtime
|
|
4
4
|
(function() {
|
|
5
5
|
if (typeof window === 'undefined') return;
|
|
@@ -854,13 +854,13 @@ ${I}
|
|
|
854
854
|
</style>`;o=o.replace(x,P),v.lastIndex=0}catch(I){}}}return o}import it from"path";var cs=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.\.?\/[^'"]*)\2/g,ls=/(<script\b[^>]*>)([\s\S]*?)(<\/script>)/gi;function ds(c,e){if(!e||!c.includes("/"))return c;let u=it.dirname(e);return c.replace(cs,(o,g,i,f)=>{let v=it.resolve(u,f);return`${g}${i}${v.split(it.sep).join("/")}${i}`})}function dn(c,e){if(!e||!c.includes("<script"))return c;return c.replace(ls,(u,o,g,i)=>`${o}${ds(g,e)}${i}`)}var _e="<!--PARENT_CONTENT_PLACEHOLDER-->";function fn(c){return c.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Sn(c,e){let u=c.length,o=e,g=!0,i=[],f=(v)=>v+9<=u&&c[v]==="<"&&c[v+1]==="/"&&(c[v+2]==="s"||c[v+2]==="S")&&(c[v+3]==="c"||c[v+3]==="C")&&(c[v+4]==="r"||c[v+4]==="R")&&(c[v+5]==="i"||c[v+5]==="I")&&(c[v+6]==="p"||c[v+6]==="P")&&(c[v+7]==="t"||c[v+7]==="T")&&(c[v+8]===">"||/\s/.test(c[v+8]));while(o<u){let v=c[o];if(f(o))return o;if(v==="/"&&c[o+1]==="/"){if(o=c.indexOf(`
|
|
855
855
|
`,o+2),o===-1)return-1;o+=1,g=!0;continue}if(v==="/"&&c[o+1]==="*"){let y=c.indexOf("*/",o+2);if(y===-1)return-1;o=y+2,g=!0;continue}if(v==="/"&&g){let y=o+1,x=!1;while(y<u){let b=c[y];if(b==="\\"){y+=2;continue}if(b==="[")x=!0;else if(b==="]")x=!1;else if(b==="/"&&!x){y++;break}else if(b===`
|
|
856
856
|
`){y=-1;break}y++}if(y===-1){o++,g=!1;continue}while(y<u&&/[a-z]/.test(c[y]))y++;o=y,g=!1;continue}if(v==="'"||v==='"'){let y=v;o++;while(o<u){if(c[o]==="\\"){o+=2;continue}if(c[o]===y){o++;break}if(c[o]===`
|
|
857
|
-
`)break;o++}g=!1;continue}if(v==="`"){o++;while(o<u){if(c[o]==="\\"){o+=2;continue}if(c[o]==="`"){o++;break}if(c[o]==="$"&&c[o+1]==="{"){i.push(!0),o+=2,g=!0;break}o++}if(i.length===0)g=!1;continue}if(v==="}"&&i.length>0){i.pop(),o++;while(o<u){if(c[o]==="\\"){o+=2;continue}if(c[o]==="`"){o++,g=!1;break}if(c[o]==="$"&&c[o+1]==="{"){i.push(!0),o+=2,g=!0;break}o++}continue}if(/\s/.test(v));else if(/[)\].\w$]/.test(v))g=!1;else g=!0;o++}return-1}function $n(c,e){let u=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(`<script\\b(?=[^>]*\\b${u}(?:\\s|=|/?>))[^>]*>`,"i").exec(c);if(!o)return null;let g=o.index+o[0].length,i=c.indexOf("</script>",g);if(i===-1)return null;let f=c.indexOf(">",i);if(f===-1)return null;return{start:o.index,end:f+1}}var hs=4096;async function mn(c,e,u){if(u.buildMode!=="serve"||e.length<hs)return null;let{registerServeModuleBundle:o}=await import("./chunk-
|
|
857
|
+
`)break;o++}g=!1;continue}if(v==="`"){o++;while(o<u){if(c[o]==="\\"){o+=2;continue}if(c[o]==="`"){o++;break}if(c[o]==="$"&&c[o+1]==="{"){i.push(!0),o+=2,g=!0;break}o++}if(i.length===0)g=!1;continue}if(v==="}"&&i.length>0){i.pop(),o++;while(o<u){if(c[o]==="\\"){o+=2;continue}if(c[o]==="`"){o++,g=!1;break}if(c[o]==="$"&&c[o+1]==="{"){i.push(!0),o+=2,g=!0;break}o++}continue}if(/\s/.test(v));else if(/[)\].\w$]/.test(v))g=!1;else g=!0;o++}return-1}function $n(c,e){let u=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(`<script\\b(?=[^>]*\\b${u}(?:\\s|=|/?>))[^>]*>`,"i").exec(c);if(!o)return null;let g=o.index+o[0].length,i=c.indexOf("</script>",g);if(i===-1)return null;let f=c.indexOf(">",i);if(f===-1)return null;return{start:o.index,end:f+1}}var hs=4096;async function mn(c,e,u){if(u.buildMode!=="serve"||e.length<hs)return null;let{registerServeModuleBundle:o}=await import("./chunk-gw7h5k3b.js");return`<script ${c} src="${o(e)}"></script>`}async function Hn(c,e,u){try{let{registeredModuleIdsIn:o,buildModuleRegistryScript:g}=await r("stx/client-module-registry",()=>import("./chunk-rcsgt4wy.js")),i=[],f=await g(o(...c),{minify:qo(e.buildMode),collectInputs:i});for(let v of i)u?.add(v);if(!f)return null;if(e.buildMode==="serve"){let{registerServeModuleBundle:v}=await import("./chunk-gw7h5k3b.js");return`<script data-stx-scoped data-stx-run="always" data-stx-modules src="${v(f)}"></script>`}return`<script data-stx-scoped data-stx-run="always" data-stx-modules>${f.replace(/<\/script/gi,"<\\/script")}</script>`}catch{return null}}function ys(c,e=""){let u=$n(c,"data-stx-runtime");if(!u)return c;let o=Gn(c);if(o===-1||o===u.start){if(!e)return c;return c.slice(0,u.end)+e+c.slice(u.end)}if(o<u.start)return c.slice(0,o)+c.slice(u.start,u.end)+e+`
|
|
858
858
|
`+c.slice(o,u.start)+c.slice(u.end);let g=c.slice(u.start,u.end),i=c.slice(0,u.start)+c.slice(u.end),f=Gn(i);if(f===-1)return g+e+`
|
|
859
859
|
`+i;return i.slice(0,f)+g+e+`
|
|
860
860
|
`+i.slice(f)}function vs(c){let e=/\x00STX_ESC_MUSTACHE_OPEN\x00([\s\S]*?)\x00STX_ESC_MUSTACHE_CLOSE\x00/g;return c.replace(e,(u,o,g)=>{let i=c.slice(0,g);return i.lastIndexOf("<")>i.lastIndexOf(">")?`{{${o}}}`:`{<!--stx-literal-->{${o}}}`})}async function s(c,e,u,o,g){if(o.ssr===!1&&!o.autoShell&&o.buildMode==="spa")return c;if(e.__stx_signals_gate===void 0)e.__stx_signals_gate=ve(c,u);let i=!e.__stxProcessingDepth;ln(e);for(let f of o._layerGraph?.configDependencies??[])g.add(f);if(i&&o.runtimeConfig)await gn(e,u,o.runtimeConfig);if(i)za(e),e.__stx_scope_seq??={n:0,key:ms(String(e.__filename??u))},e.__stx_head_injections=Vo(),e.__stx_seo_staged=!1;if(!e.__stxProcessingDepth)e.__stxProcessingDepth=0;if(e.__stxProcessingDepth++,!e.__onceStore)e.__onceStore=new Set;if((o.debug||!C()&&!bn())&&u&&u.endsWith(".stx"))Zs(c,u);try{return await te.timeAsync("template-processing",async()=>{let f=await bs(c,e,u,o,g);if(i)f=Ao(f);if(i&&o.autoShell&&o.buildMode!=="compile"){let v=xe(o.app?.head,{known:hr,source:"app.head"}),x=(e.__stx_runtime_head||null)??Wo(),b=(e.__stx_head_raw||"").trim(),w,T=b.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(T)w=T[1].trim(),b=b.replace(T[0],"").trim();let A=e.__sections?.title,O=A?k(A,e,u):void 0,M=x.title||w||O,I=!x.title&&(!!w||!!O),P=x.meta||[],N=new Set(P.map((G)=>rt(G)).filter(Boolean)),V={...v,...M&&{title:M},meta:[...(v.meta||[]).filter((G)=>!N.has(rt(G))),...P],link:[...v.link||[],...x.link||[]],script:[...v.script||[],...x.script||[]],headRaw:[v.headRaw,b].filter(Boolean).join(`
|
|
861
861
|
`),...x.htmlAttrs&&{htmlAttrs:nc(v.htmlAttrs,x.htmlAttrs)},...x.bodyAttrs&&{bodyAttrs:{...v.bodyAttrs||{},...x.bodyAttrs}}},X=Uo(f);if(f=gr(f,V,{...I&&{titleIsHtml:!0},...o.app?.colorMode&&{colorMode:o.app.colorMode}},X),X)f=sc(f,v),f=fr(f,V.htmlAttrs);let L=f.match(/<!-- stx-layout: ([^ ]+) -->/);if(L&&f.includes("<head")){let G=L[1],J=ts(G);f=f.replace(/<head\b[^>]*>/i,(Y)=>`${Y}
|
|
862
862
|
<meta name="stx-layout" content="${fn(G)}">
|
|
863
|
-
<meta name="stx-layout-group" content="${fn(J)}">`)}let j=f.match(/function (__stx_setup_\w+)\(/),H=j?U(f):null;if(j&&H&&!/\bdata-stx=/.test(H.tag)){f=Ge(f,(J,Y)=>`<body${Y} data-stx="${j[1]}">`);let G=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${j[1]}"`,"i");f=f.replace(G,"$1")}}if(i){let v=e.__stx_head_injections??Vo(),y=rc(f);if(y!==null)v.beforeClose.push(y);let x=tn(f);if(x!==null)v.afterOpen.push(x);if(o.offline?.enabled&&!f.includes("data-stx-offline"))v.beforeClose.push(nn);f=ec(f,v);let b=o.app?.colorMode;if(b)f=pr(f,b)}if(i)if($n(f,"data-stx-runtime")){let y=null,x=null,b=null,w=null,T=null;try{let{getStoreScript:O}=await r("stx/store-loader",()=>import("./chunk-
|
|
863
|
+
<meta name="stx-layout-group" content="${fn(J)}">`)}let j=f.match(/function (__stx_setup_\w+)\(/),H=j?U(f):null;if(j&&H&&!/\bdata-stx=/.test(H.tag)){f=Ge(f,(J,Y)=>`<body${Y} data-stx="${j[1]}">`);let G=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${j[1]}"`,"i");f=f.replace(G,"$1")}}if(i){let v=e.__stx_head_injections??Vo(),y=rc(f);if(y!==null)v.beforeClose.push(y);let x=tn(f);if(x!==null)v.afterOpen.push(x);if(o.offline?.enabled&&!f.includes("data-stx-offline"))v.beforeClose.push(nn);f=ec(f,v);let b=o.app?.colorMode;if(b)f=pr(f,b)}if(i)if($n(f,"data-stx-runtime")){let y=null,x=null,b=null,w=null,T=null;try{let{getStoreScript:O}=await r("stx/store-loader",()=>import("./chunk-b1hxtn08.js")),M=o.storesDir,I=await O(M);if(I)b=`<script data-stx-stores>${I}</script>`,x=await mn("data-stx-stores",I,o)??b}catch{}y=await Hn([f,b],o,g);try{let{getFrameworkComposableScript:O}=await r("stx/framework-composables",()=>import("./chunk-chzgfna2.js"));T=await O(f)}catch{}try{let{getComposableScript:O}=await r("stx/composable-loader",()=>import("./chunk-sy0z64yz.js")),M=o.composablesDir,I=[y,b,T].filter((N)=>N!==null),P=await O(o._layerComposableDirs??M,f,I);if(P)w=await mn('data-stx-scoped data-stx-run="always" data-stx-composables',P,o)??`<script data-stx-scoped data-stx-run="always" data-stx-composables>${P}</script>`}catch{}let A=[y,x,w,T].filter((O)=>O!==null).map((O)=>`
|
|
864
864
|
${O}`).join("");f=ys(f,A)}else{let y=await Hn([f],o,g);if(y){let x=f.search(/<script\b[^>]*>(?:(?!<\/script>)[\s\S])*?__stxModules\[/i);if(x!==-1)f=f.slice(0,x)+y+`
|
|
865
865
|
`+f.slice(x)}}if(i)f=tc(f);if(i&&e.__stx_inject_css!==!1)f=await h(f,void 0,o.buildMode==="serve",!0);else if(i)f=an(f);if(f=f.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),f=vs(f),i&&e.__stx_runtime_config)f=Ot(f,e.__stx_runtime_config);if(i&&!e.__stx_defer_server_data){let v=cr(e);if(v){let y=/<head\b[^>]*>/i.exec(f),x=y?y.index+y[0].length:0;f=f.slice(0,x)+v+f.slice(x)}}return f})}catch(f){if(f instanceof z)throw f;let v=f instanceof Error?f.message:String(f),y=new re(`Template processing failed: ${v}`,u,void 0,void 0,c.substring(0,200)+(c.length>200?"...":""));if(D.log(y,{filePath:u,context:e}),hn.logDetailedError(y,{filePath:u,template:c.substring(0,500)}),C()&&!o.debug)console.error(`[stx] ${ce.relative(process.cwd(),u)||u}: ${y.message}`);if(o.debug)throw y;return zo.createFallbackContent("Template Processing",y)}}async function bs(c,e,u,o,g){let i=process.cwd(),f={...o,partialsDir:o.partialsDir&&!ce.isAbsolute(o.partialsDir)?ce.resolve(i,o.partialsDir):o.partialsDir,componentsDir:o.componentsDir&&!ce.isAbsolute(o.componentsDir)?ce.resolve(i,o.componentsDir):o.componentsDir,layoutsDir:o.layoutsDir&&!ce.isAbsolute(o.layoutsDir)?ce.resolve(i,o.layoutsDir):o.layoutsDir},v=f,y=c;await ks(u,e),xs(e,v),y=await we(()=>zt(y,e,u,v),y,(L)=>{D.log(L,{filePath:u,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${u}: ${L.message}`)}),y=y.replace(/\{\{--[\s\S]*?--\}\}/g,"");let x=le(y,Pe,(L,j)=>`\x00STX_HTML_COMMENT_${j}\x00`);y=x.output;let b=x.tokens,w=(L)=>b.length===0?L:L.replace(/\x00STX_HTML_COMMENT_(\d+)\x00/g,(j,H)=>b[Number(H)]??""),T="\x00STX_ESCAPED_AT\x00",A="\x00STX_ESC_MUSTACHE_OPEN\x00",O="\x00STX_ESC_MUSTACHE_CLOSE\x00";y=y.replace(/@@/g,T),y=y.replace(/@\{\{([\s\S]*?)\}\}/g,(L,j)=>`${A}${j}${O}`),y=Jt(y),y=await un(y,u,g);let M={};y=Mr(y,M);let I={...e.__sections||{}},P="",N=mt(gt(c)),V=/@nolayout\b/.test(y)||N===!1;if(/@nolayout\b/.test(y))y=y.replace(/@nolayout\b\s*/g,"");let X=y.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(X)P=X[1],y=y.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");else if(typeof N==="string"){if(P=N,!/@section\s*\(/.test(y))y=`@section('content')
|
|
866
866
|
${y.trim()}
|
|
@@ -869,7 +869,7 @@ ${y.trim()}
|
|
|
869
869
|
@endsection`}}if(P&&y.includes("<script")){let L=q(y),j=L.scripts.map((H)=>vn(H,u)??H);y=or(L.output,j)}if(y=y.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(L,j,H)=>(I[j]=H,"")),y=y.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(L,j,H)=>{if(/^(['"]).*\1$/.test(H.trim()))return L;try{let G=l(H.trim(),e);if(G===void 0)return L;let Y=(e.__stx_inline_section_values??=[]).push(G)-1;return I[j]=`{{ __stx_inline_section_values[${Y}] }}`,""}catch{return L}}),y=y.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(L,j,H)=>{if(H.includes("@parent"))I[j]=H.replace("@parent",_e);else I[j]=H.trim();return""}),e.__sections=I,y=y.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(L,j,H)=>I[j]||H||""),!("slot"in e)||e.slot===void 0)y=y.replace(/\{\{\s*slot\s*\}\}/g,()=>I.content||"");if(y=Lr(y,M),P){let L=[],j=q(y),H=le(j.output,on,(G,J)=>`\x00STX_ORPHAN_STYLE_${J}\x00`);if(y=H.output.replace(/\x00STX_(SCRIPT|ORPHAN_STYLE)_(\d+)\x00/g,(G,J,Y)=>{let ne=J==="SCRIPT"?vn(j.scripts[Number(Y)],u):H.tokens[Number(Y)];if(ne)L.push(ne);return""}),L.length>0){let G=L.join(`
|
|
870
870
|
`);I.content=I.content?`${I.content}
|
|
871
871
|
${G}`:G,e.__sections=I}}if(P)try{let L;if(ce.isAbsolute(P))L=P,g.add(P);else L=await we(()=>pn(P,u,f,g),null,()=>{throw new re(`Failed to resolve layout path: ${P}`,u,void 0,void 0,`Layout referenced from ${u}`)});if(!L){let ne=(oe)=>{if(!oe)return[];try{let ae=ce.isAbsolute(oe)?oe:ce.resolve(process.cwd(),oe);return fs.readdirSync(ae).filter((ue)=>ue.endsWith(".stx")).map((ue)=>ue.replace(/\.stx$/,""))}catch{return[]}},se=[...ne(f.layoutsDir),...ne(f.fallbackLayoutsDir)].filter((oe,ae,ue)=>ue.indexOf(oe)===ae).sort(),de=`Layout not found: ${P} (referenced from ${u})`+(se.length>0?`. Available layouts: ${se.join(", ")}`:f.layoutsDir?`. No .stx layouts found in ${f.layoutsDir}`:"");if(D.log(Error(de),{layoutPath:P,filePath:u,available:se},"error"),console.error(`[stx] ${de}`),f.debug)throw new re(de,u);return y}let j=await we(()=>Bun.file(L).text(),"",()=>{throw new re(`Failed to read layout file: ${L}`,u,void 0,void 0,"Layout content could not be loaded")});j=dn(j,L);let H=j.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(H){if(f.debug)console.log(`Found nested layout: ${H[1]} in ${L}`);let ne={},se=j.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(ae,ue,ke)=>(ne[ue]=ke.trim(),""));for(let[ae,ue]of Object.entries(ne))if(I[ae]&&I[ae].includes(_e)){let ke=I[ae].indexOf(_e);I[ae]=I[ae].slice(0,ke)+ue+I[ae].slice(ke+_e.length)}else if(!I[ae])I[ae]=ue;let de={...e,__sections:I},oe=`@layout('${H[1]}')${se}`;return await s(oe,de,L,f,g)}let G=j.replace(/\{\{--[\s\S]*?--\}\}/g,""),J=Mr(G,M),Y={};return J=J.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(ne,se,de)=>(Y[se]=de.trim(),`@slot('${se}')`)),J=J.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(ne,se,de)=>{if(I[se]){let oe=I[se];if(oe.includes(_e)){let ae=Y[se]||"",ue=oe.indexOf(_e);oe=oe.slice(0,ue)+ae+oe.slice(ue+_e.length)}return oe}return de||""}),J=ws(J,I),J=J.replace(/\{\{\s*slot\s*\}\}/g,()=>I.content||""),J=Lr(J,M),e.__originalFilePath=u,y=await kn(J,e,L,f,g),y=`<!-- stx-layout: ${P} -->
|
|
872
|
-
${y}`,w(y)}catch(L){if(L instanceof z)throw L;throw new re(`Error processing layout ${P}: ${L instanceof Error?L.message:String(L)}`,u)}return w(await kn(y,e,u,f,g))}function ws(c,e){return c.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(u,o,g)=>{let i=e[o];if(i!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(i))return i}return g||""})}function xs(c,e){if(c.__stx_sfc_mode=!0,c.__stx_options=e,e.buildMode)c.__stx_buildMode=e.buildMode;let u=e.envPrefix||"STX_PUBLIC_",o={};for(let[g,i]of Object.entries(process.env))if(g.startsWith(u)&&i!==void 0)o[g]=i;c.$env=o}async function ks(c,e){await we(()=>Kt(c,e),void 0,(u)=>{D.log(u,{filePath:c,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${c}: ${u.message}`)})}var ot="data-stx-source";function vn(c,e){if(!c)return c;let u=/^<script\b([^>]*)>/i.exec(c);if(!u||!/\bserver\b/.test(u[1])||u[1].includes(ot))return c;return`<script ${ot}="${encodeURIComponent(e)}"${c.slice(7)}`}function Ss(c){let e=new RegExp(`${ot}="([^"]*)"`).exec(c);return e?decodeURIComponent(e[1]):void 0}function wn(c){return c.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function xn(c,e,u){return`<div data-stx-server-script-error role="alert" style="padding:12px 14px;border:1px solid #f0b4b4;border-left-width:4px;background:#fff5f5;color:#7a1f1f;font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace"><strong style="display:block;margin-bottom:4px">stx: a <script server> ${e==="module-resolution"?"imports a module that does not resolve":e==="syntax"?"does not parse":"names something that does not exist"}, so this component rendered nothing.</strong><span style="display:block;opacity:.85">${wn(c)}</span><span style="display:block;margin-top:4px">${wn(u)}</span></div>`}async function $s(c,e,u,o){let{scanScriptTags:g}=await r("stx/signal-processing",()=>import("./chunk-
|
|
872
|
+
${y}`,w(y)}catch(L){if(L instanceof z)throw L;throw new re(`Error processing layout ${P}: ${L instanceof Error?L.message:String(L)}`,u)}return w(await kn(y,e,u,f,g))}function ws(c,e){return c.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(u,o,g)=>{let i=e[o];if(i!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(i))return i}return g||""})}function xs(c,e){if(c.__stx_sfc_mode=!0,c.__stx_options=e,e.buildMode)c.__stx_buildMode=e.buildMode;let u=e.envPrefix||"STX_PUBLIC_",o={};for(let[g,i]of Object.entries(process.env))if(g.startsWith(u)&&i!==void 0)o[g]=i;c.$env=o}async function ks(c,e){await we(()=>Kt(c,e),void 0,(u)=>{D.log(u,{filePath:c,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${c}: ${u.message}`)})}var ot="data-stx-source";function vn(c,e){if(!c)return c;let u=/^<script\b([^>]*)>/i.exec(c);if(!u||!/\bserver\b/.test(u[1])||u[1].includes(ot))return c;return`<script ${ot}="${encodeURIComponent(e)}"${c.slice(7)}`}function Ss(c){let e=new RegExp(`${ot}="([^"]*)"`).exec(c);return e?decodeURIComponent(e[1]):void 0}function wn(c){return c.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function xn(c,e,u){return`<div data-stx-server-script-error role="alert" style="padding:12px 14px;border:1px solid #f0b4b4;border-left-width:4px;background:#fff5f5;color:#7a1f1f;font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace"><strong style="display:block;margin-bottom:4px">stx: a <script server> ${e==="module-resolution"?"imports a module that does not resolve":e==="syntax"?"does not parse":"names something that does not exist"}, so this component rendered nothing.</strong><span style="display:block;opacity:.85">${wn(c)}</span><span style="display:block;margin-top:4px">${wn(u)}</span></div>`}async function $s(c,e,u,o){let{scanScriptTags:g}=await r("stx/signal-processing",()=>import("./chunk-f8agvh5v.js")),i=[],f=!C()&&!bn();for(let y of g(c)){let x=y.attrs;if(!/\bserver\b/.test(x))continue;let b=y.start+y.fullMatch.indexOf(">")+1,w=Sn(c,b);if(w===-1)continue;let T=c.slice(b,w);if(!T.trim())continue;let A=Ss(x)??u,O={index:y.start,length:w+9-y.start};try{let{extractVariables:M}=await r("stx/variable-extractor",()=>import("./chunk-g64z2e92.js"));await M(T,e,A,{preserveExisting:!0,onFailure:(I)=>{if(I.kind==="unknown")return;if(o?.onServerScriptError?.({sourcePath:A,kind:I.kind,message:I.message}),!f)return;i.push({...O,markup:xn(A,I.kind,I.message)})}})}catch(M){let I=M instanceof Error?M:Error(String(M));if(D.log(I,{filePath:A,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${A}: ${I.message}`),f)i.push({...O,markup:xn(A,"unknown",I.message)})}}if(i.length===0)return c;let v=c;for(let y of i.sort((x,b)=>b.index-x.index))v=v.slice(0,y.index)+y.markup+v.slice(y.index+y.length);return v}async function Es(c,e,u){try{let{interpolateScriptsInTemplate:o}=await r("stx/expressions",()=>import("./chunk-jr9wfthg.js"));return o(c,e,{skipServer:!0})}catch(o){let g=o instanceof Error?o:Error(String(o));return D.log(g,{filePath:u,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${u}: ${g.message}`),c}}async function kn(c,e,u,o,g){let i=c,f=o;if(i=await $s(i,e,u,o),i=await Bt(i,e,u),i=await Ft(i,e,u),i=await Es(i,e,u),i=await At(i,e,u,f),ve(i))i=io(i,e),i=Hr(i,e),i=zr(i,e);i=ao(i);let{processStreamDirectives:v}=await r("stx/streaming",()=>import("./chunk-9rrnyd5m.js"));i=v(i,e),i=qn(i,e,u,f,!0),i=await en(i,e,u,f,g),i=await Br(i,e,u,f,g),i=ua(i,e,u,f);let{processDeferDirectives:y}=await r("stx/defer",()=>import("./chunk-2f17h17f.js"));i=y(i,e,u);let{processTeleportDirectives:x}=await r("stx/teleport",()=>import("./chunk-wq712sw1.js"));i=x(i,e,u);let{processTransitionDirectives:b,processTransitionAttributes:w}=await r("stx/transitions",()=>import("./chunk-k2pa44rf.js"));i=b(i,e,u),i=w(i);let{processErrorBoundaryDirectives:T,stripRenderFailedMarkers:A}=await r("stx/error-boundaries",()=>import("./chunk-h85hrwkq.js"));i=T(i,e,u),i=A(i);let{processSuspenseDirectives:O}=await r("stx/suspense",()=>import("./chunk-weqc0ssb.js"));i=O(i,e,u);let{processAsyncDirectives:M}=await r("stx/async-components",()=>import("./chunk-67kj14at.js"));i=M(i,e,u);let{processKeepAliveDirectives:I}=await r("stx/keep-alive",()=>import("./chunk-6vzktvyw.js"));i=I(i,e,u);let{processVirtualListDirectives:P,processVirtualGridDirectives:N,processInfiniteListDirectives:V}=await r("stx/virtual-scrolling",()=>import("./chunk-sf0wsq74.js"));i=P(i,e,u),i=N(i,e,u),i=V(i,e,u);let{processPartialHydrationDirectives:X,processStaticDirectives:L}=await r("stx/partial-hydration",()=>import("./chunk-9szxxgv5.js"));i=X(i,e,u),i=L(i);let{processComputedDirectives:j,processWatchDirectives:H}=await r("stx/computed",()=>import("./chunk-1xdzcy9d.js"));i=j(i,e,u),i=H(i,e,u);let{processFormValidationDirectives:G}=await r("stx/forms-validation",()=>import("./chunk-b6nzy1rg.js"));i=G(i,e,u);let{processHeadDirective:J,processTitleDirective:Y,processMetaDirective:ne,resetHead:se}=await r("stx/head",()=>import("./chunk-e1fetwbr.js"));if(!e.__stx_head_preset&&!e.__stx_runtime_head)se();let de=J(i);if(i=de.content,de.headContent)e.__stx_head_raw=`${e.__stx_head_raw||""}${de.headContent}
|
|
873
873
|
`;if(i=Y(i,e),i=ne(i,e,u),i=Xt(i),i=no(i,e),i=Ct(i),i=Ut(i),i=await Dr(i,e,u,f,g),i=await Br(i,e,u,f,g),e.__stxProcessingDepth===1)i=Ha(i,e);if(i=i.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),i=Ao(i),i=ee(i,e,u),i=Nr(i),i=La(i,e,{filePath:u,buildMode:f.buildMode}),i=ro(i,e),i=so(i,e),i=ze(i,e),i=Nt(i,e),i=Ht(i,e),i=await bt(i,e,u,f),i=await pa(i,e,u),i=await fa(i,e,u,f),i=ga(i,e,u,f),i=mo(i,e,u,f),i=ho(i,e,u),i=yo(i,e,u,f),i=_t(i,e,u,f),i=ps(i,e),i=gs(i),i=ja(i),!f.skipEventDirectives)i=Ea(i,e,u);if(i=vt(i,e,u),f.debug){let B=/\bx-data\s*=/.test(i),W=Fr(c);if(B&&W)console.warn(`[stx] ${u}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
|
|
874
874
|
Both work on the same page, but they manage separate scopes.
|
|
875
875
|
Prefer signals (state/derived/effect) for new components.`)}i=oa(i,e),i=await k(i,e,u),i=Ba(i),i=Fa(i),i=pt(i);let{processXElementDirectives:oe}=await r("stx/x-element",()=>import("./chunk-zhxdpzga.js"));i=oe(i);let ae=e.__originalFilePath||u,ue=Oe(e);if(i=await co(i,f,ae,ue),i=Pt(i,e),i=await Wt(i,e,u,f),f.media?.image?.autoSiblings){let B=f.publicDir||"public",{rewriteImagesWithSiblings:W}=await r("stx/image-optimization/auto-sibling",()=>import("./chunk-shpc1ttk.js"));i=await W(i,{publicDir:B})}if(f.seo?.enabled)i=bo(i,e,f);let ke=(B,W,Z=!0)=>{if(!W)return B;let he=W.match(/<title\b[^>]*>[\s\S]*?<\/title>/i),ie=/<head\b[^>]*>[\s\S]*?(?:<\/head\s*>|<body\b|$)/i.exec(B),fe=ie?/<title\b[^>]*>[\s\S]*?<\/title>/i.exec(ie[0]):null;if(he&&ie&&fe){if(Z){let Ce=ie.index+fe.index;B=B.slice(0,Ce)+he[0]+B.slice(Ce+fe[0].length)}if(W=W.replace(he[0],"").trim(),!W)return B}if(/<\/head>/i.test(B))return B.replace(/<\/head>/i,`${W}
|
|
@@ -883,6 +883,6 @@ ${lt()}
|
|
|
883
883
|
`+Ce}else i=i.replace("</head>",`${W}
|
|
884
884
|
</head>`)}else if(i.includes("<body"))i=i.replace(/<body([^>]*)>/,`<body$1>
|
|
885
885
|
${W}`);else i=W+`
|
|
886
|
-
`+i}{let{scanScriptTags:B}=await r("stx/signal-processing",()=>import("./chunk-
|
|
886
|
+
`+i}{let{scanScriptTags:B}=await r("stx/signal-processing",()=>import("./chunk-f8agvh5v.js")),W=[];for(let Z of B(i)){if(!/\bserver\b/i.test(Z.attrs))continue;let he=Z.start+Z.fullMatch.indexOf(">")+1,ie=Sn(i,he);if(ie===-1)continue;let fe=ie+9;while(fe<i.length&&/\s/.test(i[fe]))fe++;W.push({start:Z.start,end:fe})}if(W.length>0){let Z=Array(W.length+1),he=0;for(let ie=0;ie<W.length;ie++){let{start:fe,end:Ce}=W[ie];Z[ie]=i.slice(he,fe),he=Ce}Z[W.length]=i.slice(he),i=Z.join("")}}let at=us(i,u);if(at.hasScoped)i=at.html;let Rn=e.__stx_event_bindings||[],Ke=!1,ct=[],Mn=/\s:[a-z][\w.-]*\s*=/.test(i),{scanScriptTags:Dn}=await r("stx/signal-processing",()=>import("./chunk-f8agvh5v.js"));for(let B of Dn(i,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))ct.push({match:B.fullMatch,attrs:B.attrs,content:B.body});for(let{match:B,attrs:W,content:Z}of ct){Ke=!0;let he=Z;Ae(Z,u,o.strict,e.__originalFilePath);let ie=await Ne(Z,{eventBindings:Rn,attrs:W,hasColonDirectives:Mn,templateContent:c,filePath:u,projectRoot:process.cwd(),production:qo(o.buildMode),serverData:ue});i=i.replace(B,()=>ie)}if(Ke)e.__stx_event_bindings=[];if(!Ke&&e.__stxProcessingDepth===1){let B=e.__stx_event_bindings||[];if(B.length>0){let W=_o(B);if(W){let Z=i.lastIndexOf("</body>");i=Z===-1?i+W:i.slice(0,Z)+W+`
|
|
887
887
|
`+i.slice(Z)}e.__stx_event_bindings=[]}}if(!ge(i)&&aa(i))i=await Kn(i,f);if(i=ca(i),f.csp?.enabled&&f.csp.useNonce&&typeof e.cspNonce==="string")i=$t(i,e.cspNonce);return i}
|
|
888
888
|
export{gt,Te,ta,Ys,Hn,s};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{he,hs,ru,Ap,su,Pp,It,d,F,K,fn,ve,ou,Lo,iu,Ip,k,au,Op,_,Np}from"./chunk-
|
|
2
|
+
import{he,hs,ru,Ap,su,Pp,It,d,F,K,fn,ve,ou,Lo,iu,Ip,k,au,Op,_,Np}from"./chunk-t0zh1dn9.js";import"./chunk-xwhmh0w0.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{au as applyFilters,Pp as clearCustomFilters,ou as clientLoopScopes,hs as defaultFilters,fn as escapeAttributeValue,d as escapeHtml,F as escapeHtmlValue,K as escapeInterpolatedHtmlValue,_ as evaluateExpression,he as findMustacheEnd,su as getAllFilters,iu as interpolateScriptAttributes,Lo as interpolateScriptExpressions,Ip as interpolateScriptsInTemplate,k as processExpressions,ru as registerFilter,Ap as registerFilters,It as replaceInterpolations,Op as resetRejectedExpressionWarnings,Np as unescapeHtml,ve as usesSignalsInScript};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ta,n,de}from"./chunk-
|
|
2
|
+
import{Ta,n,de}from"./chunk-t0zh1dn9.js";import{Ze}from"./chunk-2zzc7006.js";import{c}from"./chunk-zhf01af3.js";import o from"fs";import l from"path";var El=new Map,m=new Map;async function gp(e){let r;for(let i=0;i<3;i++)try{let g=(await o.promises.stat(e)).mtime.getTime(),a=m.get(e);if(a&&a.mtime===g)return a.content;let h=await Bun.file(e).text(),w=(await o.promises.stat(e)).mtime.getTime();if(w!==g)continue;return m.set(e,{content:h,mtime:w}),h}catch(s){r=s;break}throw m.delete(e),Error(`File not found: ${e}${r?` (${r.message})`:""}`)}function mp(e){m.delete(e)}function hp(e){for(let t of m.keys())if(t.startsWith(e))m.delete(t)}var f=null,B=null,x=null;function yp(e){x=e}async function Tl(e=!1){let t=x??await import("./chunk-yscr04dv.js");if(e)return t.generateSignalsRuntimeDev();if(f===null)f=t.generateSignalsRuntime();return f}var S=null;async function $l(){if(S===null){let{getRouterScript:e}=await import("./chunk-028ee6q5.js");S=e()}return S}var y={};async function bp(e,t=!1){let r=e==="runtime"?await Tl(t):await $l(),i=e==="runtime"&&t?"runtime-debug":e,s=y[i];if(!s||s.content!==r)s={content:r,hash:Bun.hash(r).toString(16).padStart(16,"0").slice(0,16)},y[i]=s;return{content:r,hash:s.hash,url:`/_stx/${e}.${s.hash}.js`}}var E=500,T=33554432,u=new Map,p=0;function C(e){return c(process.cwd(),"module-bundles",`${e}.js`)}function vp(e){let t=Bun.hash(e).toString(16).padStart(16,"0").slice(0,16),r=u.get(t),i=r!==void 0;if(i)u.delete(t),p-=r.length*2;u.set(t,e),p+=e.length*2;while(u.size>1&&(u.size>E||p>T)){let s=u.keys().next().value;p-=u.get(s).length*2,u.delete(s)}if(!i)try{let s=C(t);if(!o.existsSync(s))o.mkdirSync(l.dirname(s),{recursive:!0}),o.writeFileSync(s,e)}catch{}return`/_stx/modules.${t}.js`}function uo(e){if(!/^[0-9a-f]{16}$/.test(e))return;let t=u.get(e);if(t!==void 0)return t;try{return o.readFileSync(C(e),"utf8")}catch{return}}function wp(){m.clear(),de(),Ta(),f=null,B=null,S=null}function v(e){let t={debug:e.debug===!0,middleware:(e.middleware??[]).map((r)=>({name:r.name,timing:r.timing,handler:String(r.handler)})),customDirectives:(e.customDirectives??[]).map((r)=>({name:r.name,hasEndTag:r.hasEndTag===!0,rawParams:r.rawParams===!0,handler:String(r.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(t)).digest("hex")}async function Xn(e,t){try{if(!t.cachePath)return null;let r=l.resolve(t.cachePath),i=l.join(r,`${Wr(e)}.html`),s=l.join(r,`${Wr(e)}.meta.json`);if(!await n(i)||!await n(s))return null;let g=await Bun.file(s).text(),a=JSON.parse(g);if(a.cacheVersion!==t.cacheVersion)return null;if(a.engine!==Ze())return null;if(a.optionsSignature!==v(t))return null;if((await o.promises.stat(e)).mtime.getTime()>a.mtime)return null;for(let d of a.dependencies)if(await n(d)){if((await o.promises.stat(d)).mtime.getTime()>a.mtime)return null}else return null;return await Bun.file(i).text()}catch(r){return console.warn(`Cache error for ${e}:`,r),null}}async function Jn(e,t,r,i){try{if(!i.cachePath)return;let s=l.resolve(i.cachePath);await o.promises.mkdir(s,{recursive:!0});let g=l.join(s,`${Wr(e)}.html`),a=l.join(s,`${Wr(e)}.meta.json`),h=await o.promises.stat(e);await Bun.write(g,t);let d={sourcePath:e,mtime:h.mtime.getTime(),dependencies:Array.from(r),cacheVersion:i.cacheVersion,engine:Ze(),optionsSignature:v(i),generatedAt:Date.now()};await Bun.write(a,JSON.stringify(d,null,2)),El.set(e,{output:t,mtime:h.mtime.getTime(),dependencies:r})}catch(s){console.warn(`Failed to cache template ${e}:`,s)}}var _=16;function Wr(e){return new Bun.CryptoHasher("sha1").update(e).digest("hex").substring(0,_)}
|
|
3
3
|
export{El,gp,mp,hp,yp,Tl,$l,bp,vp,uo,wp,Xn,Jn,Wr};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Hi,Vi,Ui,Wi,tp}from"./chunk-dq56166k.js";import"./chunk-hzv2qj0t.js";import"./chunk-yfvm7q6t.js";import"./chunk-jg5zt20a.js";import"./chunk-h4dkvnhd.js";import"./chunk-prf164ct.js";import"./chunk-b58tv8jc.js";import"./chunk-m6q3f5rf.js";import"./chunk-99bhc1h1.js";import"./chunk-ka8befem.js";import"./chunk-9tdnfztv.js";import"./chunk-agqcqf3q.js";import"./chunk-p472crv1.js";import"./chunk-jst1fbdm.js";import"./chunk-hmyb701s.js";import"./chunk-yg267y85.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import"./chunk-t0zh1dn9.js";import"./chunk-xwhmh0w0.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{Hi as buildNative,tp as default,Vi as findCraftBinary,Wi as getAvailableFormats,Ui as getAvailableTargets};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{l,p,E,u,z}from"./chunk-2dp7hyv7.js";import{L,ns,B,Ae,ae,ar,De,Me,n,m,ve,k}from"./chunk-
|
|
2
|
+
import{l,p,E,u,z}from"./chunk-2dp7hyv7.js";import{L,ns,B,Ae,ae,ar,De,Me,n,m,ve,k}from"./chunk-t0zh1dn9.js";import{st}from"./chunk-pxdww4rb.js";import{T}from"./chunk-ce6zddpf.js";import{ee}from"./chunk-ka8befem.js";import{U,Ge}from"./chunk-bnn7pd62.js";import{C,bn}from"./chunk-fbtv2k1p.js";import A from"path";import{existsSync as St}from"fs";function at(a,t){let c=0;for(let i=t;i<a.length;i++){let b=a[i];if(b==="("||b==="["||b==="{")c++;else if(b===")"||b==="]"||b==="}")c--;else if(b===","&&c===0)return i}return-1}function yt(a,t,c){let i=a,b=new RegExp(`${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),s=b.exec(i);while(s){let f=s.index,e=f+s[0].length-1,D=1,H=e+1;while(H<i.length&&D>0){if(i[H]==="(")D++;else if(i[H]===")")D--;H++}if(D!==0)break;let it=i.substring(e+1,H-1),j=`${c}(${it})`;i=i.substring(0,f)+j+i.substring(H),b.lastIndex=f+j.length,s=b.exec(i)}return i}function $t(a){return/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(a)}function mt(a){let t=a,c=[],i=new Set,b=0,s=0,f=t.length,e=(j)=>{s++;while(s<f){if(t[s]==="\\"){s+=2;continue}if(t[s]===j){s++;return}s++}},D=()=>{s++;while(s<f){if(t[s]==="\\"){s+=2;continue}if(t[s]==="`"){s++;return}if(t[s]==="$"&&t[s+1]==="{"){s+=2;let j=1;while(s<f&&j>0)if(t[s]==="{")j++,s++;else if(t[s]==="}")j--,s++;else if(t[s]==="'"||t[s]==='"')e(t[s]);else if(t[s]==="`")D();else s++;continue}s++}},H=()=>{if(t[s]==="/"&&t[s+1]==="/"){while(s<f&&t[s]!==`
|
|
3
3
|
`)s++;return!0}if(t[s]==="/"&&t[s+1]==="*"){s+=2;while(s<f-1&&!(t[s]==="*"&&t[s+1]==="/"))s++;return s+=2,!0}return!1},it=()=>{if(b!==0)return;let j=t.slice(s).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(j){let V=j[2];if(!i.has(V))c.push(V),i.add(V);return}let et=t.slice(s).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(et){let V=et[1];if(!i.has(V))c.push(V),i.add(V);return}let Y=t.slice(s).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(Y){let V=Y[1];if(!i.has(V))c.push(V),i.add(V)}};while(s<f){if(H())continue;if(t[s]==="'"||t[s]==='"'){e(t[s]);continue}if(t[s]==="`"){D();continue}if(t[s]==="{"){b++,s++;continue}if(t[s]==="}"){b--,s++;continue}if(b===0&&/[a-z]/i.test(t[s])&&(s===0||/\s|[;{}()]/.test(t[s-1])))it();s++}return c.join(", ")}function Et(a,t=""){let c=mt(a).split(",").map((i)=>i.trim()).filter(Boolean);return`
|
|
4
4
|
(function() {
|
|
5
5
|
${st("var",c)}
|
|
@@ -44,10 +44,10 @@ ${s}
|
|
|
44
44
|
}
|
|
45
45
|
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
46
46
|
}
|
|
47
|
-
})();`;return c+a+i}function It(a,t){if(U(a)){let b=U(a).tag.match(/data-stx-scope="([^"]*)"/);if(b)return{html:a,mergedIntoExisting:b[1],stamped:!0,root:"body"};return{html:Ge(a,(s,f)=>`<body${f} data-stx-scope="${t}">`),mergedIntoExisting:null,stamped:!0,root:"body"}}let c=a.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(c){let i=c[2]+c[3],b=c[2].slice(1),s=i.match(/data-stx-scope="([^"]*)"/);if(s)return{html:a,mergedIntoExisting:s[1],stamped:!0,root:b};let f=c[1],e=c[2],D=c[3];return{html:`${f}${e} data-stx-scope="${t}"${D}${a.slice(c[0].length)}`,mergedIntoExisting:null,stamped:!0,root:b}}return{html:a,mergedIntoExisting:null,stamped:!1,root:null}}var Mt=0;function ut(a,t){let c=A.basename(a,".stx").replace(/[^a-zA-Z0-9]/g,"_"),i=t.__stx_scope_seq;return i?`stx_scope_${c}_${++i.n}_${i.key}`:`stx_scope_${c}_${++Mt}`}var lt=new Set,pt=new Set;function lp(){lt.clear(),pt.clear()}var Tt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Sl(a){let t=(e)=>e.replace(/[^\n]/g," "),c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,t).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,t).replace(/<!--[\s\S]*?-->/g,t).replace(/\x00STX_HTML_COMMENT_\d+\x00/g,t).replace(/\{\{[\s\S]*?\}\}/g,t).replace(/\{!![\s\S]*?!!\}/g,t),i=[],b=0,s=/<(\/?)([A-Za-z][\w-]*)\b(?:[^<>"']|"[^"]*"|'[^']*')*?(\/?)>/g,f;while((f=s.exec(c))!==null){let e=f[1]==="/",D=f[2],H=f[3]==="/"||Tt.has(D.toLowerCase());if(e){b=Math.max(0,b-1);continue}if(b===0)i.push(D);if(!H)b++}return i}function ft(a){return/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(a)}var qe=new B(500),sa=new Set;function up(){sa.clear()}function Ct(a){if(a.__onceStore instanceof Set)return a.__onceStore;return sa}async function Dr(a,t,c,i,b,s=new Set){let f=i.partialsDir||A.join(A.dirname(c),"partials");if(f&&!A.isAbsolute(f))f=A.resolve(process.cwd(),f);let e=yt(a,"@partial","@include"),D=Ct(t);e=e.replace(/@once([\s\S]*?)@endonce/g,(h,R,x)=>{let g=R.trim(),r=`${c}:${g}`;if(D.has(r))return"";return D.add(r),R});{let h=/@includeIf\s*\(/g,R;while((R=h.exec(e))!==null){let x=R.index,g=x+R[0].length-1,r=1,_=g+1;while(_<e.length&&r>0){if(e[_]==="(")r++;else if(e[_]===")")r--;_++}if(r!==0)break;let d=e.substring(g+1,_-1),o=d.match(/^\s*['"]([^'"]+)['"]/);if(!o){h.lastIndex=_;continue}let O=o[1],W=H(O,f,c),v="";if(W&&await Bun.file(W).exists())b.add(W),v=`@include(${d})`;e=e.substring(0,x)+v+e.substring(_),h.lastIndex=0}}for(let[h,R]of[["@includeWhen",!1],["@includeUnless",!0]]){let x=new RegExp(`${h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),g;while((g=x.exec(e))!==null){let r=g.index,_=r+g[0].length-1,d=1,o=_+1;while(o<e.length&&d>0){if(e[o]==="(")d++;else if(e[o]===")")d--;o++}if(d!==0)break;let O=e.substring(_+1,o-1),W=at(O,0);if(W===-1){x.lastIndex=o;continue}let v=O.substring(0,W).trim(),X=O.substring(W+1).trim(),F=X.match(/^\s*['"]([^'"]+)['"]/);if(!F){x.lastIndex=o;continue}let w=F[1],J=X.substring(F[0].length),N,I=at(J,0);if(I!==-1)N=J.substring(I+1).trim();try{let M=`Boolean(${v})`,P;if(p(M)){let ot=u(M,Object.keys(t));P=Boolean(ot(...Object.values(t)))}else P=Boolean(l(M,t));let tt=R?!P:P,rt="";if(tt){let ot=H(w,f,c);if(ot&&await Bun.file(ot).exists())b.add(ot);rt=`@include('${w}'${N?`, ${N}`:""})`}e=e.substring(0,r)+rt+e.substring(o),x.lastIndex=0}catch(M){let P=M instanceof Error?M.message:String(M),tt=m("Include",`Error evaluating ${h} condition: ${P}`,c,a,r);e=e.substring(0,r)+tt+e.substring(o),x.lastIndex=0}}}{let h=/@each\s*\(/g,R;while((R=h.exec(e))!==null){let x=R.index,g=x+R[0].length-1,r=1,_=g+1;while(_<e.length&&r>0){if(e[_]==="(")r++;else if(e[_]===")"){if(r--,r===0)break}_++}if(r!==0)break;let d=e.substring(g+1,_),o=e.substring(x,_+1),O=d.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!O){h.lastIndex=0,e=e.replace(o,"");continue}let[,W,v,X,F]=O;try{let w,J=v.trim();if(p(J))w=u(J,Object.keys(t))(...Object.values(t));else w=l(J,t);let N="";if(Array.isArray(w)&&w.length>0)for(let I of w){let M={...t,[X]:I},P=await et(W,M,a,x);N+=P}else if(F)N=await et(F,{},a,x);e=e.substring(0,x)+N+e.substring(_+1),h.lastIndex=0}catch(w){let J=w instanceof Error?w.message:String(w);e=e.substring(0,x)+m("Each",`Error in @each: ${J}`,c,a,x)+e.substring(_+1),h.lastIndex=0}}}{let h=/@includeFirst\s*\(/g,R;while((R=h.exec(e))!==null){let x=R.index,g=x+R[0].length-1,r=1,_=g+1;while(_<e.length&&r>0){if(e[_]==="(")r++;else if(e[_]===")"){if(r--,r===0)break}_++}if(r!==0)break;let d=e.substring(g+1,_),o=e.substring(x,_+1),O=d.match(/^\s*(\[[^\]]+\])/);if(!O){h.lastIndex=0,e=e.replace(o,"");continue}let W=O[1],v=d.slice(O[0].length),X,F=v.match(/^\s*,\s*\{/);if(F){v=v.slice(F[0].length-1);let N=1,I=1;while(I<v.length&&N>0){if(v[I]==="{")N++;else if(v[I]==="}"){if(N--,N===0)break}I++}X=v.substring(0,I+1),v=v.slice(I+1)}let w,J=v.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(J)w=J[1];try{let N=JSON.parse(W.replace(/'/g,'"')),I={};if(X)try{I=E(X,t)}catch(P){let tt=P instanceof Error?P.message:String(P);if(i.debug){let rt=m("Include",`Error parsing includeFirst variables: ${tt}`,c,a,x,o);e=e.replace(o,()=>rt)}else e=e.replace(o,()=>w||"");continue}let M=!1;for(let P of N){let tt=H(P,f,c);if(!tt)continue;if(await n(tt)){let rt=await et(P,I,a,x);e=e.replace(o,()=>rt),M=!0;break}}if(!M)if(w!==void 0)e=e.replace(o,()=>w);else if(i.debug){let P=m("Include",`None of the includeFirst paths exist: ${W}`,c,a,x,o);e=e.replace(o,()=>P)}else e=e.replace(o,"")}catch(N){let I=N instanceof Error?N.message:String(N),M=m("Include",`Error processing @includeFirst: ${I}`,c,a,x,o);e=e.replace(o,()=>M)}h.lastIndex=0}}function H(h,R,x){try{let g=h;if(!h.endsWith(".stx"))g=`${h}.stx`;let r=A.resolve(R),_=A.resolve(A.dirname(x)),d;if(!g.startsWith("./")&&!g.startsWith("../")){for(let F of i._layerPartialDirs??[]){let w=A.resolve(F,g);if(w.startsWith(`${A.resolve(F)}${A.sep}`)&&St(w))return w}d=A.resolve(R,g)}else d=A.resolve(_,g);let o=A.normalize(d),O=o.startsWith(r+A.sep)||o===r,W=o.startsWith(_+A.sep)||o===_,v=!1,X=A.dirname(_);if(o.startsWith(X+A.sep)){if(!A.relative(X,o).split(A.sep).some((N)=>N.startsWith(".")&&N!=="."&&N!==".."))v=!0}if(!O&&!W&&!v)return console.error(`Security: Path traversal attempt blocked for include path: ${h}`),console.error(` Resolved to: ${o}`),console.error(` Allowed dirs: ${r}, ${_}`),null;return o}catch(g){return console.error(`Error resolving path ${h}: ${g}`),null}}let it=A.resolve(c);s.add(it);function j(h,R,x,g){return i.onIncludeError?.({includePath:h,templatePath:c,message:R,partialsDir:f}),m("Include",R,c,x,g)}async function et(h,R={},x,g){let r=H(h,f,c);if(!r)return j(h,`Could not resolve path for include: ${h}`,x,g);let _=A.resolve(r);if(s.has(_)){let d=[...s,_].map((o)=>A.basename(o)).join(" -> ");return j(h,`Circular include detected: ${d}`,x,g)}try{b.add(r);let d;if(!d)try{d=await Bun.file(r).text()}catch(y){let q=y instanceof Error?y.message:String(y);return j(h,`Error loading include file ${h}: ${q}`,x,g)}if(d)d=d.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(d&&d.includes("@stream")){let{processStreamDirectives:y}=await import("./chunk-
|
|
47
|
+
})();`;return c+a+i}function It(a,t){if(U(a)){let b=U(a).tag.match(/data-stx-scope="([^"]*)"/);if(b)return{html:a,mergedIntoExisting:b[1],stamped:!0,root:"body"};return{html:Ge(a,(s,f)=>`<body${f} data-stx-scope="${t}">`),mergedIntoExisting:null,stamped:!0,root:"body"}}let c=a.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(c){let i=c[2]+c[3],b=c[2].slice(1),s=i.match(/data-stx-scope="([^"]*)"/);if(s)return{html:a,mergedIntoExisting:s[1],stamped:!0,root:b};let f=c[1],e=c[2],D=c[3];return{html:`${f}${e} data-stx-scope="${t}"${D}${a.slice(c[0].length)}`,mergedIntoExisting:null,stamped:!0,root:b}}return{html:a,mergedIntoExisting:null,stamped:!1,root:null}}var Mt=0;function ut(a,t){let c=A.basename(a,".stx").replace(/[^a-zA-Z0-9]/g,"_"),i=t.__stx_scope_seq;return i?`stx_scope_${c}_${++i.n}_${i.key}`:`stx_scope_${c}_${++Mt}`}var lt=new Set,pt=new Set;function lp(){lt.clear(),pt.clear()}var Tt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Sl(a){let t=(e)=>e.replace(/[^\n]/g," "),c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,t).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,t).replace(/<!--[\s\S]*?-->/g,t).replace(/\x00STX_HTML_COMMENT_\d+\x00/g,t).replace(/\{\{[\s\S]*?\}\}/g,t).replace(/\{!![\s\S]*?!!\}/g,t),i=[],b=0,s=/<(\/?)([A-Za-z][\w-]*)\b(?:[^<>"']|"[^"]*"|'[^']*')*?(\/?)>/g,f;while((f=s.exec(c))!==null){let e=f[1]==="/",D=f[2],H=f[3]==="/"||Tt.has(D.toLowerCase());if(e){b=Math.max(0,b-1);continue}if(b===0)i.push(D);if(!H)b++}return i}function ft(a){return/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(a)}var qe=new B(500),sa=new Set;function up(){sa.clear()}function Ct(a){if(a.__onceStore instanceof Set)return a.__onceStore;return sa}async function Dr(a,t,c,i,b,s=new Set){let f=i.partialsDir||A.join(A.dirname(c),"partials");if(f&&!A.isAbsolute(f))f=A.resolve(process.cwd(),f);let e=yt(a,"@partial","@include"),D=Ct(t);e=e.replace(/@once([\s\S]*?)@endonce/g,(h,R,x)=>{let g=R.trim(),r=`${c}:${g}`;if(D.has(r))return"";return D.add(r),R});{let h=/@includeIf\s*\(/g,R;while((R=h.exec(e))!==null){let x=R.index,g=x+R[0].length-1,r=1,_=g+1;while(_<e.length&&r>0){if(e[_]==="(")r++;else if(e[_]===")")r--;_++}if(r!==0)break;let d=e.substring(g+1,_-1),o=d.match(/^\s*['"]([^'"]+)['"]/);if(!o){h.lastIndex=_;continue}let O=o[1],W=H(O,f,c),v="";if(W&&await Bun.file(W).exists())b.add(W),v=`@include(${d})`;e=e.substring(0,x)+v+e.substring(_),h.lastIndex=0}}for(let[h,R]of[["@includeWhen",!1],["@includeUnless",!0]]){let x=new RegExp(`${h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),g;while((g=x.exec(e))!==null){let r=g.index,_=r+g[0].length-1,d=1,o=_+1;while(o<e.length&&d>0){if(e[o]==="(")d++;else if(e[o]===")")d--;o++}if(d!==0)break;let O=e.substring(_+1,o-1),W=at(O,0);if(W===-1){x.lastIndex=o;continue}let v=O.substring(0,W).trim(),X=O.substring(W+1).trim(),F=X.match(/^\s*['"]([^'"]+)['"]/);if(!F){x.lastIndex=o;continue}let w=F[1],J=X.substring(F[0].length),N,I=at(J,0);if(I!==-1)N=J.substring(I+1).trim();try{let M=`Boolean(${v})`,P;if(p(M)){let ot=u(M,Object.keys(t));P=Boolean(ot(...Object.values(t)))}else P=Boolean(l(M,t));let tt=R?!P:P,rt="";if(tt){let ot=H(w,f,c);if(ot&&await Bun.file(ot).exists())b.add(ot);rt=`@include('${w}'${N?`, ${N}`:""})`}e=e.substring(0,r)+rt+e.substring(o),x.lastIndex=0}catch(M){let P=M instanceof Error?M.message:String(M),tt=m("Include",`Error evaluating ${h} condition: ${P}`,c,a,r);e=e.substring(0,r)+tt+e.substring(o),x.lastIndex=0}}}{let h=/@each\s*\(/g,R;while((R=h.exec(e))!==null){let x=R.index,g=x+R[0].length-1,r=1,_=g+1;while(_<e.length&&r>0){if(e[_]==="(")r++;else if(e[_]===")"){if(r--,r===0)break}_++}if(r!==0)break;let d=e.substring(g+1,_),o=e.substring(x,_+1),O=d.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!O){h.lastIndex=0,e=e.replace(o,"");continue}let[,W,v,X,F]=O;try{let w,J=v.trim();if(p(J))w=u(J,Object.keys(t))(...Object.values(t));else w=l(J,t);let N="";if(Array.isArray(w)&&w.length>0)for(let I of w){let M={...t,[X]:I},P=await et(W,M,a,x);N+=P}else if(F)N=await et(F,{},a,x);e=e.substring(0,x)+N+e.substring(_+1),h.lastIndex=0}catch(w){let J=w instanceof Error?w.message:String(w);e=e.substring(0,x)+m("Each",`Error in @each: ${J}`,c,a,x)+e.substring(_+1),h.lastIndex=0}}}{let h=/@includeFirst\s*\(/g,R;while((R=h.exec(e))!==null){let x=R.index,g=x+R[0].length-1,r=1,_=g+1;while(_<e.length&&r>0){if(e[_]==="(")r++;else if(e[_]===")"){if(r--,r===0)break}_++}if(r!==0)break;let d=e.substring(g+1,_),o=e.substring(x,_+1),O=d.match(/^\s*(\[[^\]]+\])/);if(!O){h.lastIndex=0,e=e.replace(o,"");continue}let W=O[1],v=d.slice(O[0].length),X,F=v.match(/^\s*,\s*\{/);if(F){v=v.slice(F[0].length-1);let N=1,I=1;while(I<v.length&&N>0){if(v[I]==="{")N++;else if(v[I]==="}"){if(N--,N===0)break}I++}X=v.substring(0,I+1),v=v.slice(I+1)}let w,J=v.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(J)w=J[1];try{let N=JSON.parse(W.replace(/'/g,'"')),I={};if(X)try{I=E(X,t)}catch(P){let tt=P instanceof Error?P.message:String(P);if(i.debug){let rt=m("Include",`Error parsing includeFirst variables: ${tt}`,c,a,x,o);e=e.replace(o,()=>rt)}else e=e.replace(o,()=>w||"");continue}let M=!1;for(let P of N){let tt=H(P,f,c);if(!tt)continue;if(await n(tt)){let rt=await et(P,I,a,x);e=e.replace(o,()=>rt),M=!0;break}}if(!M)if(w!==void 0)e=e.replace(o,()=>w);else if(i.debug){let P=m("Include",`None of the includeFirst paths exist: ${W}`,c,a,x,o);e=e.replace(o,()=>P)}else e=e.replace(o,"")}catch(N){let I=N instanceof Error?N.message:String(N),M=m("Include",`Error processing @includeFirst: ${I}`,c,a,x,o);e=e.replace(o,()=>M)}h.lastIndex=0}}function H(h,R,x){try{let g=h;if(!h.endsWith(".stx"))g=`${h}.stx`;let r=A.resolve(R),_=A.resolve(A.dirname(x)),d;if(!g.startsWith("./")&&!g.startsWith("../")){for(let F of i._layerPartialDirs??[]){let w=A.resolve(F,g);if(w.startsWith(`${A.resolve(F)}${A.sep}`)&&St(w))return w}d=A.resolve(R,g)}else d=A.resolve(_,g);let o=A.normalize(d),O=o.startsWith(r+A.sep)||o===r,W=o.startsWith(_+A.sep)||o===_,v=!1,X=A.dirname(_);if(o.startsWith(X+A.sep)){if(!A.relative(X,o).split(A.sep).some((N)=>N.startsWith(".")&&N!=="."&&N!==".."))v=!0}if(!O&&!W&&!v)return console.error(`Security: Path traversal attempt blocked for include path: ${h}`),console.error(` Resolved to: ${o}`),console.error(` Allowed dirs: ${r}, ${_}`),null;return o}catch(g){return console.error(`Error resolving path ${h}: ${g}`),null}}let it=A.resolve(c);s.add(it);function j(h,R,x,g){return i.onIncludeError?.({includePath:h,templatePath:c,message:R,partialsDir:f}),m("Include",R,c,x,g)}async function et(h,R={},x,g){let r=H(h,f,c);if(!r)return j(h,`Could not resolve path for include: ${h}`,x,g);let _=A.resolve(r);if(s.has(_)){let d=[...s,_].map((o)=>A.basename(o)).join(" -> ");return j(h,`Circular include detected: ${d}`,x,g)}try{b.add(r);let d;if(!d)try{d=await Bun.file(r).text()}catch(y){let q=y instanceof Error?y.message:String(y);return j(h,`Error loading include file ${h}: ${q}`,x,g)}if(d)d=d.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(d&&d.includes("@stream")){let{processStreamDirectives:y}=await import("./chunk-9rrnyd5m.js");d=y(d,t)}if(d&&(i.debug||!C()&&!bn()))try{let{warnUnbalancedTags:y}=await import("./chunk-z8p6tk5z.js");y(d,r)}catch{}try{let{processESImports:y}=await import("./chunk-6rzshbey.js");d=await y(d,t,r,i,b)}catch(y){if(i.debug)console.warn(`[stx] partial ES import extraction skipped for ${r}:`,y instanceof Error?y.message:y)}let o=d,O=ae(o);if(O)o=O.content.trim();let v=d.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),X="";if(v)X=`<style${v[1]}>${v[2]}</style>`;let F=[];o=o.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(y,q,S)=>{if(!ft(q))return"";return F.push({attrs:q,body:S}),`__STX_DATA_BLOCK_${F.length-1}__`}),o=o.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let w={...t};w.__stx_signals_gate=ve(d,r);for(let[y,q]of Object.entries(R))w[y]=q;let J=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,N=[...d.matchAll(J)].sort((y,q)=>{let S=(y[1]||"").includes("server"),K=(q[1]||"").includes("server");return Number(K)-Number(S)}),I="",M=null,P=!1,tt=!1;for(let y of N){let q=y[1]||"",S=y[2]||"";if(ft(q))continue;let K=q.includes("server"),wt=De(q);if(!K&&!/\bsrc\s*=/i.test(q))Ae(S,r,i.strict);if(!K&&S.trim()){let{interpolateScriptExpressions:Z}=await import("./chunk-jr9wfthg.js");S=Z(S,w,h)}let ct="";try{let{extractAndStripCssImports:Z,renderVendorStyleTags:Q}=await import("./chunk-rwjf25ht.js"),nt=Z(S,{filePath:r,projectRoot:process.cwd()});S=nt.code,ct=Q(nt.styles)}catch(Z){if(i.debug)console.warn(`[stx] vendor-css extractor skipped for ${r}:`,Z instanceof Error?Z.message:Z)}if(wt&&S.trim())S=Me(S);if(!K){try{let{injectBrowserCoreAutoImports:Q}=await import("./chunk-rwjf25ht.js");S=Q(S).code;let{hasUserImports:nt,bundleClientScript:bt}=await import("./chunk-e6p0k6br.js");if(nt(S))S=await bt(S,r,{projectRoot:process.cwd()})}catch(Q){if(i.debug)console.warn(`[stx] bundler skipped for ${r}:`,Q instanceof Error?Q.message:Q)}let{stripStxRuntimeImports:Z}=await import("./chunk-f8agvh5v.js");S=Z(S)}let dt=$t(S);if(!K){let{extractBridgeData:Z,generateServerDataBridge:Q}=await import("./chunk-rwjf25ht.js"),nt=Q(S,Z(w));if(nt)S=`${nt}
|
|
48
48
|
${S}`}if(dt&&!K){P=!0,M=ut(r,t);let Z=T(S),Q=gt(Z,M);I+=`${ct}<script data-stx-scoped data-stx-run="always" data-stx-owner="${M}">${Q}</script>
|
|
49
|
-
`;continue}if(K)try{let{extractVariables:Z}=await import("./chunk-
|
|
50
|
-
`}}if(F.length>0){let{interpolateScriptExpressions:y}=await import("./chunk-
|
|
49
|
+
`;continue}if(K)try{let{extractVariables:Z}=await import("./chunk-g64z2e92.js");await Z(S,w,r)}catch(Z){if(i.debug)console.warn(`Warning: Could not extract variables from server script in ${r}:`,Z)}if(!K&&!dt){let Z=q.replace(/\bclient\b/i,"").trim();M=ut(r,t);let Q=T(S),nt=gt(Q,M);if(/__scopeRegistration\["(?!__stx)[^"]+"\]\s*=|Object\.defineProperty\(__scopeRegistration, "(?!__stx)/.test(nt))tt=!0;I+=`${ct}<script data-stx-scoped data-stx-run="always" data-stx-owner="${M}"${Z?` ${Z}`:""}>${nt}</script>
|
|
50
|
+
`}}if(F.length>0){let{interpolateScriptExpressions:y}=await import("./chunk-jr9wfthg.js");o=o.replace(/__STX_DATA_BLOCK_(\d+)__/g,(q,S)=>{let K=F[Number(S)];return`<script${K.attrs}>${y(K.body,w,h)}</script>`})}if(M){let y=It(o,M);if(o=y.html,y.mergedIntoExisting){let S=M,K=y.mergedIntoExisting;I=I.split(`'${S}'`).join(`'${K}'`).split(`"${S}"`).join(`"${K}"`),M=K}else if(!y.stamped&&P&&!lt.has(r))lt.add(r),console.warn(`[stx] ${A.relative(process.cwd(),r)} declares signals but has no element to scope them to, so nothing in it will hydrate. Wrap the partial's markup in a single root element.`);if(y.stamped&&y.root!=="body"&&(P||tt)&&!pt.has(r)){let S=Sl(o);if(S.length>1)pt.add(r),console.warn(`[stx] ${A.relative(process.cwd(),r)} declares ${P?"signals":"bindings"} and has ${S.length} top-level elements (${S.map((K)=>`<${K}>`).join(", ")}). Only the first is scoped, so bindings in the others cannot see what this partial's script declares. Wrap the partial's markup in a single root element.`)}let q=y.stamped&&y.root!==null&&ar(y.root);I=Rt(I,q?M:null)}if(o.includes("@include")||o.includes("@partial"))o=await Dr(o,w,r,i,b,s);let{processLoops:rt,reportDeferredLoopWarnings:ot}=await import("./chunk-amkwmxs8.js"),G=rt(o,w,r,void 0,!0);G=ee(G,w,r),G=ot(G);let{processMetaDirectives:ht,processSeoDirective:xt,processStructuredData:_t}=await import("./chunk-qxmyaajq.js");if(G=ht(G,w,r,i),G=_t(G,w,r),G=xt(G,w,r,i),G=k(G,w,r),X)G+=`
|
|
51
51
|
`+X;if(I)G+=`
|
|
52
52
|
`+I;return G}catch(d){if(d instanceof z)throw d;let o=d instanceof Error?d.message:String(d);return j(h,`Error processing include ${h}: ${o}`,x,g)}}let Y=/@include\s*\(/g,V;while((V=Y.exec(e))!==null){let h=V.index,R=h+V[0].length-1,x=1,g=R+1;while(g<e.length&&x>0){if(e[g]==="(")x++;else if(e[g]===")")x--;g++}if(x!==0)break;let r=e.substring(h,g),_=e.substring(R+1,g-1),d=_.match(/^\s*['"]([^'"]+)['"]/);if(!d){Y.lastIndex=g;continue}let o=d[1],O,W=_.substring(d[0].length),v=at(W,0);if(v!==-1)O=W.substring(v+1).trim();let X={};if(O)try{X=E(O,t)}catch(w){let J=w instanceof Error?w.message:String(w);e=e.replace(r,m("Include",`Error parsing include variables for ${o}: ${J}`,c,a,h)),Y.lastIndex=0;continue}let F=await et(o,X,a,h);e=e.substring(0,h)+F+e.substring(g),Y.lastIndex=0}return e}function Mr(a,t){let c=a;function i(b,s,f,e){let D=b,H=!0;while(H){H=!1;let it=new RegExp(`@${s}\\(['"]([^'"]+)['"]\\)`),j=D.match(it);if(!j||j.index===void 0)break;let et=j.index,Y=j[1],V=et+j[0].length,h=new RegExp(`@${s}\\(`),R=new RegExp(`@${f}(?![a-z])`),x=1,g=V,r=-1;while(x>0&&g<D.length){let d=D.slice(g),o=d.match(h),O=d.match(R),W=o?g+o.index:1/0,v=O?g+O.index:1/0;if(W<v)x++,g=W+(o[0].length||1);else if(v<1/0){if(x--,x===0){r=v;break}g=v+f.length+1}else break}if(r===-1)break;let _=D.slice(V,r);if(!t[Y])t[Y]=[];if(e)t[Y].unshift(_);else t[Y].push(_);D=D.substring(0,et)+D.substring(r+`@${f}`.length),H=!0}return D}return c=i(c,"push","endpush",!1),c=i(c,"prepend","endprepend",!0),c}function Lr(a,t){return a.replace(/@stack\(['"]([^'"]+)['"]\)/g,(c,i)=>{if(!t[i]||t[i].length===0)return"";return t[i].join(`
|
|
53
53
|
`)})}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Tu}from"./chunk-ynz7bzc6.js";import"./chunk-jg5zt20a.js";import"./chunk-h4dkvnhd.js";import"./chunk-prf164ct.js";import"./chunk-b58tv8jc.js";import"./chunk-m6q3f5rf.js";import"./chunk-99bhc1h1.js";import"./chunk-ka8befem.js";import"./chunk-9tdnfztv.js";import"./chunk-agqcqf3q.js";import"./chunk-p472crv1.js";import"./chunk-jst1fbdm.js";import"./chunk-hmyb701s.js";import"./chunk-yg267y85.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import"./chunk-t0zh1dn9.js";import"./chunk-xwhmh0w0.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{Tu as startInteractive};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{ie}from"./chunk-365vg0eg.js";import{je,A}from"./chunk-1sr6c0nk.js";import{ba}from"./chunk-04kg16qs.js";import{c}from"./chunk-zhf01af3.js";import S from"fs";import m from"path";import{pathToFileURL as O}from"url";var E=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],P=new Set;function Zt(s,l={}){let o=m.resolve(s,l.dir??"server/api"),i=[],f=new Map;if(!S.existsSync(o))return i;let t=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:o})).sort();for(let e of t){if(e.endsWith(".d.ts"))continue;let p=e.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),n=p.pop(),u=n.lastIndexOf("."),d=u>=0?n.slice(u+1):"get",g=d.toUpperCase();if(!E.includes(g)||d!==d.toLowerCase())throw Error(`Unsupported API method suffix in ${e}; use ${E.map((y)=>y.toLowerCase()).join(", ")}`);if(u>=0)n=n.slice(0,u);if(n!=="index")p.push(n);let r=new Set,h=p.map((y,I)=>{let v=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(y);if(v){if(r.has(v[2])||v[1]&&I!==p.length-1)throw Error(`Invalid API parameter in ${e}`);return r.add(v[2]),`:${v[2]}${v[1]?"*":""}`}if(!/^[\w-]+$/.test(y))throw Error(`Unsupported API path segment ${y} in ${e}`);return y}),w=`/api${h.length?`/${h.join("/")}`:""}`,x=`${g} ${w.replace(/:\w+/g,":param")}`;if(f.has(x))throw Error(`Ambiguous API route ${g} ${w}: ${f.get(x)} and ${e}`);f.set(x,e);let R=m.join(o,e);P.add(m.resolve(R)),P.add(S.realpathSync(R)),i.push({pattern:w,method:g,filePath:R})}return i.sort((e,a)=>{let p=e.pattern.split("/"),n=a.pattern.split("/"),u=(d)=>d?.endsWith("*")?0:d?.startsWith(":")?1:2;for(let d=0;d<Math.max(p.length,n.length);d++){let g=u(n[d])-u(p[d]);if(g)return g}return e.pattern.localeCompare(a.pattern)||e.method.localeCompare(a.method)})}async function Gs(s,l){let o=c(s,"api-types.d.ts"),i=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let t of l){let e=`./${m.relative(m.dirname(o),t.filePath).replace(/\\/g,"/")}`,{params:a}=ie(t.pattern);i.push(` ${JSON.stringify(`${t.method} ${t.pattern}`)}: { params: { ${a.map((p)=>`${JSON.stringify(p)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(e)}).default>> }`)}i.push(" }","}","export {}","");let f=i.join(`
|
|
3
3
|
`);if(!await Bun.file(o).exists()||await Bun.file(o).text()!==f)await Bun.write(o,f);return o}async function Ks(s,l,o={}){let i=Zt(s,o);await Gs(s,i);let f=[];for(let t of i){let e=await Bun.build({entrypoints:[t.filePath],target:"bun",format:"esm",minify:!1,splitting:!1});if(!e.success)throw Error(`API build failed for ${t.filePath}: ${e.logs.join(`
|
|
4
|
-
`)}`);let a=e.outputs.find((u)=>u.kind==="entry-point");if(!a)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await a.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),a),f.push({...t,filePath:n})}return f}function j(s,l){let o=s.map((i)=>({route:i,...ie(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,a=(r)=>r.replace(/:\w+/g,":param"),p=t.filter((r)=>a(r.route.pattern)===a(e)),n=i.method,u=p.find((r)=>r.route.method===n)??(n==="HEAD"?p.find((r)=>r.route.method==="GET"):void 0);if(!u){let r=new Set(p.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=u.regex.exec(f),g=Object.create(null);try{u.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(u.route);if(typeof r!=="function")throw Error(`API endpoint ${u.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Xs(s,l){return j(l,async(o)=>(await import(O(m.resolve(s,o.filePath)).href)).default)}async function sp(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=Zt(s,o);return await Gs(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=Zt(s,o);await Gs(s,t);let{loadStxConfig:e}=await import("./chunk-
|
|
4
|
+
`)}`);let a=e.outputs.find((u)=>u.kind==="entry-point");if(!a)throw Error(`No API bundle for ${t.filePath}`);if(e.outputs.length!==1)throw Error(`API endpoint ${t.filePath} emits assets; package those explicitly instead`);let n=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await a.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write(m.join(l,n),a),f.push({...t,filePath:n})}return f}function j(s,l){let o=s.map((i)=>({route:i,...ie(i.pattern)}));return async(i)=>{let f=new URL(i.url).pathname,t=o.filter((r)=>r.regex.test(f));if(!t.length)return null;let e=t[0].route.pattern,a=(r)=>r.replace(/:\w+/g,":param"),p=t.filter((r)=>a(r.route.pattern)===a(e)),n=i.method,u=p.find((r)=>r.route.method===n)??(n==="HEAD"?p.find((r)=>r.route.method==="GET"):void 0);if(!u){let r=new Set(p.map((h)=>h.route.method));if(r.has("GET"))r.add("HEAD");return r.add("OPTIONS"),new Response(null,{status:n==="OPTIONS"?204:405,headers:{Allow:Array.from(r).sort().join(", ")}})}let d=u.regex.exec(f),g=Object.create(null);try{u.params.forEach((r,h)=>{g[r]=decodeURIComponent(d[h+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let r=await l(u.route);if(typeof r!=="function")throw Error(`API endpoint ${u.route.filePath} must default-export a handler`);let h=await r(i,{params:g}),w=h instanceof Response?h:h===void 0?new Response(null,{status:204}):Response.json(h);if(n==="HEAD")return new Response(null,{status:w.status,headers:w.headers});return w}catch(r){return console.error(`[stx] API error for ${n} ${e}:`,r),Response.json({error:"Internal Server Error"},{status:500})}}}function Xs(s,l){return j(l,async(o)=>(await import(O(m.resolve(s,o.filePath)).href)).default)}async function sp(s,l){if(!l)return async()=>null;let o=l===!0?{}:l,i=Zt(s,o);return await Gs(s,i),async(f)=>{if(!new URL(f.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let t=Zt(s,o);await Gs(s,t);let{loadStxConfig:e}=await import("./chunk-8d33aqs5.js"),a=A((await e(s)).runtimeConfig);return await je(a,()=>j(t,async(p)=>{let n=await Bun.build({entrypoints:[p.filePath],target:"bun",format:"esm",splitting:!1});if(!n.success)throw Error(n.logs.join(`
|
|
5
5
|
`));let u=n.outputs.find((d)=>d.kind==="entry-point");if(!u||n.outputs.length!==1)throw Error(`Unsupported API bundle output: ${p.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await u.text()).toString("base64")}`)).default})(f))}catch(t){return console.error("[stx] API discovery failed:",t),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function Js(s,l,o){if(ba(s))return!0;let i=/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/;if(i.test(m.basename(s)))return!0;try{if(i.test(m.basename(S.realpathSync(s))))return!0}catch{}if(P.has(m.resolve(s)))return!0;if(!o)return!1;let f=m.resolve(l,typeof o==="object"?o.dir??"server/api":"server/api"),t=(a)=>{try{return S.realpathSync(a)}catch{return m.resolve(a)}},e=t(s);return[f,m.resolve(l,"server"),m.resolve(l,".output/server")].some((a)=>{let p=t(a);return e===p||e.startsWith(`${p}${m.sep}`)})}
|
|
6
6
|
export{Zt,Gs,Ks,Xs,sp,Js};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{lp,Sl,qe,sa,up,Dr,Mr,Lr}from"./chunk-
|
|
2
|
+
import{lp,Sl,qe,sa,up,Dr,Mr,Lr}from"./chunk-m6q3f5rf.js";import"./chunk-99bhc1h1.js";import"./chunk-ka8befem.js";import"./chunk-p472crv1.js";import"./chunk-t0zh1dn9.js";import"./chunk-xwhmh0w0.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{up as clearOnceStore,sa as onceStore,qe as partialsCache,Dr as processIncludes,Mr as processStackPushDirectives,Lr as processStackReplacements,lp as resetUnscopedSignalWarnings,Sl as topLevelElements};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{x}from"./chunk-pxdww4rb.js";import{ye,$t,Co,Eo,Ra,Aa,Pa,Ia,ls,$o,Oa,Na,Da,un}from"./chunk-
|
|
2
|
+
import{x}from"./chunk-pxdww4rb.js";import{ye,$t,Co,Eo,Ra,Aa,Pa,Ia,ls,$o,Oa,Na,Da,un}from"./chunk-t0zh1dn9.js";import{o}from"./chunk-hmyb701s.js";import{zs}from"./chunk-sfc2v7rt.js";import{c}from"./chunk-zhf01af3.js";import{existsSync as M,readFileSync as K}from"fs";import h from"path";var ge=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),ee=un.filter((e)=>!ge.has(e)).sort(),te=[...x].sort(),me=[...new Set([...ee,...te])].sort(),he=new Set(ee),be=new Set(te),xe=new Set(me),Y=/\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 ne(e,t){let s=[];for(let u of t){if(u.offset===void 0)continue;let i=u.kind==="server"?he:be;Y.lastIndex=0;for(let l of u.code.matchAll(Y)){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 y=/^\s*([A-Za-z_$][\w$]*)/.exec(S);if(!y)continue;let r=y[1];if(!xe.has(r)||i.has(r))continue;let f=u.offset+g+m.index+y[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 ie(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 y=typeof m.extends==="string"?[m.extends]:Array.isArray(m.extends)?m.extends:[];for(let r of[...y].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 Pc(e,t="",s=""){let u=e.startLine>1?`
|
|
5
5
|
`.repeat(e.startLine-1):"",i=$o(e)+Eo(Co(e.code)),l=e.kind==="client"||e.kind==="plain"?Pa(t,e.code):"";return ls(`${u+i}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Pc,ki,Iu,Ic,Oc,Ou,Nu}from"./chunk-ptcj11b4.js";import"./chunk-sfc2v7rt.js";import"./chunk-1fd7x7b8.js";import"./chunk-mxbc2ahy.js";import"./chunk-md2jn67b.js";import"./chunk-9tdnfztv.js";import"./chunk-agqcqf3q.js";import"./chunk-p472crv1.js";import"./chunk-hmyb701s.js";import"./chunk-yg267y85.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-fzqj1mjz.js";import"./chunk-365vg0eg.js";import{$t,Fl}from"./chunk-t0zh1dn9.js";import"./chunk-xwhmh0w0.js";import"./chunk-1sr6c0nk.js";import"./chunk-2dp7hyv7.js";import"./chunk-ce6zddpf.js";import"./chunk-pxdww4rb.js";export{Pc as buildVirtualSource,$t as extractScriptBlocks,Fl as extractTemplateExpressions,Ic as findRuntimeTypeDeclarations,Oc as findStxModuleDeclarations,Nu as formatTypecheckDiagnostics,Iu as sourcePathFor,Ou as typecheckStxFiles,ki as virtualPathFor};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{B}from"./chunk-
|
|
2
|
+
import{B}from"./chunk-t0zh1dn9.js";import{je,A,Ot}from"./chunk-1sr6c0nk.js";import{ut,Se,O,ke,Ai,Bs,Pi,kn}from"./chunk-jefe0rgt.js";import{vt,ie,Je}from"./chunk-365vg0eg.js";import{Xs}from"./chunk-mxbc2ahy.js";import{_n}from"./chunk-vqc4h16r.js";import{ge}from"./chunk-agqcqf3q.js";import Z from"fs";import T from"path";var{serve:pe}=globalThis.Bun;import F from"zlib";import{promisify as Q}from"util";var K=Q(F.brotliCompress),ee=Q(F.gzip),te=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ne=["text/event-stream","multipart/x-mixed-replace"],re=1024;function se(t){if(!t)return!1;let e=t.toLowerCase();if(ne.some((o)=>e.startsWith(o)))return!1;return te.some((o)=>e.startsWith(o))}function oe(t){let e=new Map;for(let o of t.split(",")){let[r,...a]=o.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of a){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function ae(t){if(!t)return null;let e=oe(t),o=e.get("*"),r=(a)=>e.get(a)??o??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var Y=33554432,H=new Map,U=0;function ce(t,e){if(e.length>Y/8)return;H.set(t,e),U+=e.length;for(let[o,r]of H){if(U<=Y)break;H.delete(o),U-=r.length}}async function xn(t,e,o={}){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 r=ae(t.headers.get("accept-encoding"));if(!r)return e;let a;try{a=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(a,{status:e.status,statusText:e.statusText,headers:J(e.headers)});if(a.length<(o.threshold??re))return f();try{let h=o.quality??5,g=`${r}:${h}:${a.length}:${Bun.hash(a)}`,l=H.get(g);if(!l)l=r==="br"?await K(a,{params:{[F.constants.BROTLI_PARAM_QUALITY]:h,[F.constants.BROTLI_PARAM_SIZE_HINT]:a.length}}):await ee(a),ce(g,l);if(l.length>=a.length)return f();let m=J(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function J(t){let e=new Headers(t),o=e.get("Vary");if(!o)return e.set("Vary","Accept-Encoding"),e;if(!o.split(",").some((a)=>a.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${o}, Accept-Encoding`);return e}class G{now;entries=new B(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,o){let r,a=async()=>{let s=r??await o();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",O(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return a();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${Se(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let b=new Headers(s.headers);return b.set("Cache-Control","private, no-store"),b.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:b})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let v=this.generation,N=async()=>{let s=await o();r=s;let b=(s.headers.get("Vary")??"").toLowerCase().split(",").map((y)=>y.trim()).filter(Boolean);if(s.status!==200||s.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(s.headers.get("Cache-Control")??"")||b.some((y)=>y!=="x-stx-router"&&y!=="accept-encoding"))return null;let E=await s.clone().arrayBuffer();if(E.byteLength>1048576)return null;s.headers.set("Vary",O(s.headers.get("Vary")).Vary);let n={body:E,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===v)this.entries.set(h,n);return n},x=this.pending.get(h);if(!x){if(this.pending.size>=1000)return a();x=N().finally(()=>{if(this.pending.get(h)===x)this.pending.delete(h)}),this.pending.set(h,x)}if(g&&m<e.maxAge+(e.swr??0))return x.catch(()=>{}),l(g);let M=await x;return M?l(M):a()}}var ue={".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 $u(t={}){let e=T.resolve(t.outputDir||".output"),o=t.port??3000,r=Ai(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let a=_n(r.routeRules),f=new G,h=Xs(e,r.apiRoutes??[]),g=Bun.file(T.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?A(l):void 0,v=new Map,N=new Map,x=new Map,M=new Map;for(let n of r.routes)try{let y=T.join(e,n.compiledPath),i=JSON.parse(await Bun.file(y).text());if(m)i.html=Ot(i.html,m);v.set(n.pattern,i),x.set(n.pattern,Je(i.html)),M.set(n.pattern,ge(i.html));let X=T.join(e,n.fragmentPath);if(await Bun.file(X).exists()){let P=await Bun.file(X).text();N.set(n.pattern,m?Ot(P,m):P)}}catch(y){console.warn(`[stx] Failed to load route ${n.pattern}:`,y)}let s=new Map,b=[];for(let n of r.routes)if(n.hasParams){let{regex:y,params:i}=ie(n.pattern,{page:!0});b.push({regex:y,route:n,paramNames:i})}else s.set(n.pattern,n);let E=pe({port:o,async fetch(n){return xn(n,await je(m??A(),async()=>{let i=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[i])return t.apiRoutes[i](n);let X=await h(n);if(X)return X;if((n.method==="GET"||n.method==="HEAD")&&i!=="/"){let p=T.resolve(e,"public"),d;try{d=decodeURIComponent(i)}catch{d=i}if(!d.includes("\x00")){let u=T.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${T.sep}`))try{if(Z.existsSync(u)&&Z.statSync(u).isFile()){let R=T.extname(u).toLowerCase(),L=ue[R]||"application/octet-stream",_=i.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(i);return new Response(Bun.file(u),{headers:{"Content-Type":L,"Cache-Control":_?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let P=Se(n),C=null,q={};if(C=s.get(i)||null,!C)for(let{regex:p,route:d,paramNames:u}of b){let c=i.match(p);if(c){C=d,u.forEach((R,L)=>{q[R]=c[L+1]});break}}if(!C){let p=vt(i)?null:s.get("/404")||null;if(p){let d=v.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=a(i),W=Object.keys(k).length>0;return f.respond(n,k.cache,async()=>{let p=v.get(C.pattern);if(P&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let c=N.get(C.pattern);if(c){let R=x.get(C.pattern);return new Response(c,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...M.has(C.pattern)?{"X-STX-Runtime":M.get(C.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},...O(),...k.cache?{}:{"Cache-Control":ut}}})}}let d=Bs(n.method),u=v.get(C.pattern);if(!u){let c=s.get("/500")||null;if(c){let R=v.get(c.pattern);if(R)return new Response(R.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(C.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",...O(),"Cache-Control":"public, max-age=60"}});try{let{html:c,boundaries:R,redirect:L,cookies:_,status:I,headers:D}=await kn(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(L)return Pi(L,_,D);if(R&&R.length>0){let{renderStreamingPage:S,streamToResponse:z}=await import("./chunk-9rrnyd5m.js"),j=new Headers({...O(),...D,"Cache-Control":"private, no-store"});for(let V of _??[])j.append("Set-Cookie",V);if(P&&!d){let V=Je(c);j.set("X-STX-Fragment","true"),j.set("X-STX-Runtime",ge(c)?"true":"false"),j.set("X-STX-Layout",V.layout),j.set("X-STX-Layout-Group",V.group)}return z(S(P&&!d?ke(c,r.routerContainer||"main"):c,R,{timeoutMs:30000}),{status:I??u.status??200,headers:j})}let w=new Headers({"Content-Type":"text/html",...O(),...k.cache?{}:{"Cache-Control":"private, no-store"}});for(let S of _??[])w.append("Set-Cookie",S);for(let[S,z]of Object.entries(D??{}))w.set(S,z);if(w.set("Vary",O(w.get("Vary")).Vary),P&&!d){let S=Je(c);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",ge(c)?"true":"false"),w.set("X-STX-Layout",S.layout),w.set("X-STX-Layout-Group",S.group),new Response(ke(c,r.routerContainer||"main"),{status:I??u.status??200,headers:w})}return new Response(c,{status:I??u.status??200,headers:w})}catch(c){if(console.error(`[stx] Hydration error for ${i}:`,c),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:${E.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${v.size} pre-loaded)`),{port:E.port,stop:()=>{f.invalidate(),E.stop()},invalidate:(n)=>f.invalidate(n)}}
|
|
3
3
|
export{xn,$u};
|