@stacksjs/stx 0.2.778 → 0.2.779
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-01tdpc0k.js +2 -0
- package/dist/{chunk-rb9y8vce.js → chunk-05q29wa1.js} +1 -1
- package/dist/{chunk-wb29g63f.js → chunk-0prn4ekp.js} +1 -1
- package/dist/{chunk-8x0sjz6z.js → chunk-0xkf0h88.js} +1 -1
- package/dist/{chunk-y3q8gmd6.js → chunk-212cvnpd.js} +5 -5
- package/dist/chunk-24pd2s3m.js +2 -0
- package/dist/{chunk-k4hvaaza.js → chunk-2f7sh2he.js} +1 -1
- package/dist/{chunk-y9aba77v.js → chunk-2y01g6t4.js} +1 -1
- package/dist/{chunk-zr4mpbes.js → chunk-356203x0.js} +1 -1
- package/dist/{chunk-0wzmp0ba.js → chunk-3t3k8wv1.js} +1 -1
- package/dist/{chunk-jqjk78r3.js → chunk-5gsycj60.js} +4 -4
- package/dist/{chunk-8pd98vpn.js → chunk-5vez56hj.js} +1 -1
- package/dist/chunk-64d14ka0.js +2 -0
- package/dist/{chunk-ym12sccz.js → chunk-7wwyv1yz.js} +1 -1
- package/dist/{chunk-3vjfm93a.js → chunk-8d67yz72.js} +1 -1
- package/dist/{chunk-3hkrzrmg.js → chunk-8fymf3g0.js} +1 -1
- package/dist/{chunk-91rw19p3.js → chunk-8t1hw0gz.js} +1 -1
- package/dist/{chunk-bxj3x49y.js → chunk-97nxfxe1.js} +1 -1
- package/dist/{chunk-cwmt7kb9.js → chunk-abxv5a8p.js} +1 -1
- package/dist/{chunk-qmdftp4f.js → chunk-avdvhg13.js} +1 -1
- package/dist/{chunk-1ckm5pms.js → chunk-azvjwte2.js} +1 -1
- package/dist/{chunk-m6arzt5b.js → chunk-bmc9cdn7.js} +2 -2
- package/dist/{chunk-b59vdzqk.js → chunk-bwtj5rmk.js} +1 -1
- package/dist/{chunk-fqhkvh0j.js → chunk-c0d9ee0h.js} +1 -1
- package/dist/{chunk-argcf6y0.js → chunk-c2t0412w.js} +1 -1
- package/dist/{chunk-t7erayrc.js → chunk-cvde33bc.js} +1 -1
- package/dist/chunk-e0svetvm.js +2 -0
- package/dist/{chunk-8t1a622w.js → chunk-esvybdrr.js} +1 -1
- package/dist/{chunk-yeyk85cf.js → chunk-f1bgnjkt.js} +1 -1
- package/dist/chunk-g1e9p7m9.js +2 -0
- package/dist/{chunk-jhb7rj27.js → chunk-g4rd9yc8.js} +1 -1
- package/dist/{chunk-6mhvk4ky.js → chunk-h2hkcvac.js} +4 -4
- package/dist/{chunk-kd7xak9y.js → chunk-h2qj88z7.js} +1 -1
- package/dist/{chunk-4ydk5v34.js → chunk-h3t43mt8.js} +1 -1
- package/dist/{chunk-5t59jega.js → chunk-hdzxtnbj.js} +6 -6
- package/dist/{chunk-9h65q2tj.js → chunk-hfp73ff2.js} +1 -1
- package/dist/chunk-hnb9ar0j.js +2 -0
- package/dist/{chunk-1kaqdd92.js → chunk-j0hz9tst.js} +2 -2
- package/dist/{chunk-wge8v05a.js → chunk-j5stpj5s.js} +1 -1
- package/dist/{chunk-mcma5jam.js → chunk-mb2awj9c.js} +1 -1
- package/dist/{chunk-3sbsgbbg.js → chunk-ndy6wmn4.js} +1 -1
- package/dist/chunk-p4f3hz9e.js +3 -0
- package/dist/{chunk-3btafd2j.js → chunk-pfv3hena.js} +3 -3
- package/dist/{chunk-k76tp0dd.js → chunk-pzm3mvh4.js} +1 -1
- package/dist/{chunk-7qa329rc.js → chunk-r9fa4mge.js} +1 -1
- package/dist/{chunk-s71pzh2j.js → chunk-rb2f4z2x.js} +1 -1
- package/dist/{chunk-2ce796hv.js → chunk-rkrxqyj1.js} +4 -4
- package/dist/{chunk-pe0zy95x.js → chunk-s548myyc.js} +2 -2
- package/dist/{chunk-4wgb7gn7.js → chunk-s6gwfp55.js} +1 -1
- package/dist/{chunk-35405srm.js → chunk-sh5vmqdz.js} +1 -1
- package/dist/{chunk-09ew1tg3.js → chunk-sv15wh4x.js} +2 -2
- package/dist/{chunk-fwjrba26.js → chunk-te1w7dpt.js} +1 -1
- package/dist/chunk-v89qwb1k.js +2 -0
- package/dist/chunk-v8t78d1e.js +2 -0
- package/dist/{chunk-4w7bgqfk.js → chunk-vbj8mtqm.js} +2 -2
- package/dist/{chunk-j8vza88s.js → chunk-w07n62g2.js} +1 -1
- package/dist/chunk-we29y7ek.js +2 -0
- package/dist/{chunk-gy9s3008.js → chunk-x3jwremr.js} +1 -1
- package/dist/{chunk-fmqhe1dh.js → chunk-xcskfc2n.js} +1 -1
- package/dist/{chunk-e014bgs8.js → chunk-y5a4spyy.js} +2 -2
- package/dist/chunk-yvr24wxe.js +2 -0
- package/dist/{chunk-eqcjmsj0.js → chunk-zey7wj7y.js} +4 -4
- package/dist/{chunk-3ytfa6hf.js → chunk-zkbnsqr3.js} +1 -1
- package/dist/{chunk-zg28r8kx.js → chunk-zs9cn1xm.js} +1 -1
- package/dist/cli.js +7 -7
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/native/runtime/craft-bridge.js +5 -0
- package/dist/native/runtime/craft.d.ts +2 -0
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-0g22v4rd.js +0 -2
- package/dist/chunk-1gn2nm1p.js +0 -2
- package/dist/chunk-5n854rfw.js +0 -2
- package/dist/chunk-9ceer598.js +0 -2
- package/dist/chunk-gdzhdncm.js +0 -2
- package/dist/chunk-kengxq4d.js +0 -2
- package/dist/chunk-kt01nheq.js +0 -2
- package/dist/chunk-nhxg2npz.js +0 -2
- package/dist/chunk-v7d15mj8.js +0 -3
- package/dist/chunk-xdb52fnp.js +0 -2
- package/dist/chunk-z2zz7yj0.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ka,_a,Ca,Ea,yh}from"./chunk-2y01g6t4.js";import"./chunk-qby3e5nm.js";import"./chunk-y5a4spyy.js";import"./chunk-c0ejyxfj.js";import"./chunk-5gsycj60.js";import"./chunk-j0hz9tst.js";import"./chunk-zey7wj7y.js";import"./chunk-2gqhfge6.js";import"./chunk-cvde33bc.js";import"./chunk-p4f3hz9e.js";import"./chunk-7wwyv1yz.js";import"./chunk-he85ksa7.js";import"./chunk-sv15wh4x.js";import"./chunk-rkrxqyj1.js";import"./chunk-wj78td69.js";import"./chunk-avdvhg13.js";import"./chunk-bmc9cdn7.js";import"./chunk-h2qj88z7.js";import"./chunk-zxfptbac.js";import"./chunk-605b93pe.js";import"./chunk-x8js27hd.js";import"./chunk-yewd8836.js";import"./chunk-hdzxtnbj.js";import"./chunk-s6gwfp55.js";import"./chunk-27rzdq3n.js";import"./chunk-bq9xf8nq.js";import"./chunk-2yxva96k.js";import"./chunk-9f6qx8b9.js";export{ka as buildNative,yh as default,_a as findCraftBinary,Ea as getAvailableFormats,Ca as getAvailableTargets};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{bf,wf,he,vf,Za,en,tn,bh,Qa,nn,Qn,xf,Sf,kf,rs,rn,_f,sn,ec,wh}from"./chunk-
|
|
2
|
+
import{bf,wf,he,vf,Za,en,tn,bh,Qa,nn,Qn,xf,Sf,kf,rs,rn,_f,sn,ec,wh}from"./chunk-97nxfxe1.js";import"./chunk-te1w7dpt.js";import"./chunk-7sh9fa3q.js";import"./chunk-bmc9cdn7.js";import"./chunk-h2qj88z7.js";import"./chunk-zxfptbac.js";import"./chunk-605b93pe.js";import"./chunk-x8js27hd.js";import"./chunk-yewd8836.js";import"./chunk-hdzxtnbj.js";import"./chunk-s6gwfp55.js";import"./chunk-27rzdq3n.js";import"./chunk-bq9xf8nq.js";import"./chunk-2yxva96k.js";import"./chunk-9f6qx8b9.js";export{Qn as MODULE_SPECIFIER_PREFIX,bf as bundleCacheDir,wf as bundleCacheEntryLimit,wh as bundleClientEntriesSplit,sn as bundleClientScript,tn as clearBundleFailures,he as clientBundleDependencies,en as getBundleFailures,nn as hasUserImports,rn as moduleSubstitutionKey,Sf as normalizeRegistrySpecifiers,_f as queueClientBundleBuild,Za as recordBundleFailure,xf as registryIdForPath,Qa as resolveBundlerFallback,kf as rewriteRegistryImports,bh as setBundlerFallbackMode,vf as shouldLogBundlerDiagnostics,ec as tempBuildName,rs as withModuleSubstitutes};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{m,pi,Vc,Uc,rg,sg,og,ig,ag,zs,cg,je,Y,Be,lg,Cr,ug,Kc,hi,Fe,r,bn,Xc,h,fe,Wh}from"./chunk-
|
|
2
|
+
import{m,pi,Vc,Uc,rg,sg,og,ig,ag,zs,cg,je,Y,Be,lg,Cr,ug,Kc,hi,Fe,r,bn,Xc,h,fe,Wh}from"./chunk-hdzxtnbj.js";import"./chunk-s6gwfp55.js";import"./chunk-27rzdq3n.js";import"./chunk-bq9xf8nq.js";import"./chunk-2yxva96k.js";import"./chunk-9f6qx8b9.js";export{fe as clearComponentCache,hi as componentClientSignalNames,pi as convertToCommonJS,h as createDetailedErrorMessage,ag as extractDirectiveNames,Vc as extractScriptFromTemplate,m as extractVariables,r as fileExists,Wh as getComponentCacheStats,sg as getPositionInfo,Y as getSharedTranspiler,Xc as getSourceLineInfo,ig as hasDirectives,Uc as hasVariables,ug as isHydrateTrigger,cg as isJavaScriptScript,Fe as renderComponentWithSlot,bn as resolveTemplatePath,lg as scopeOnRootElement,zs as scopeSequenceKey,je as shouldTranspileTypeScript,Kc as slotContentHasExpressions,Be as transpileTypeScript,Cr as userComponentFileExists,og as validateDirective,rg as validateTemplate};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Bl,um,Fl,zl,dm,pm}from"./chunk-
|
|
2
|
+
import{Bl,um,Fl,zl,dm,pm}from"./chunk-8d67yz72.js";import"./chunk-hdzxtnbj.js";import"./chunk-s6gwfp55.js";import"./chunk-27rzdq3n.js";import"./chunk-bq9xf8nq.js";import"./chunk-2yxva96k.js";import"./chunk-9f6qx8b9.js";export{pm as applySlots,dm as extractSlotContent,um as parseSlotElement,Bl as parseSlots,zl as processSlots,Fl as renderSlot};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{oe,de,gn,Ot,Nt,m,r,fe,p}from"./chunk-
|
|
2
|
+
import{oe,de,gn,Ot,Nt,m,r,fe,p}from"./chunk-hdzxtnbj.js";import{yt,Re,tc,ss,Io,Oo,i}from"./chunk-5gsycj60.js";import{ae,Er,ke,B,Sn}from"./chunk-bq9xf8nq.js";import{St,pr,Es,Ts,$s,kt,_t,Ct,Et,Tt,$t,et}from"./chunk-yewd8836.js";import{vs,a,P}from"./chunk-bmc9cdn7.js";import{ft,An,Ce,M,oa,fo,qr,We,ia,qe,Ee}from"./chunk-pfv3hena.js";import{lr,ur}from"./chunk-avdvhg13.js";import{$n}from"./chunk-g4rd9yc8.js";import{e,cn,sr,y}from"./chunk-j0hz9tst.js";import{Je}from"./chunk-zey7wj7y.js";import{$e}from"./chunk-7sh9fa3q.js";import{X,be,we}from"./chunk-rkrxqyj1.js";import{l}from"./chunk-jdj1358b.js";import{K}from"./chunk-bmfk3b29.js";async function Nn(t){try{let n=await Bun.file(t).text(),o=Un(n),d=Wn(n,t),s=Vn(n,o),c=qn(n,o);return{file:t,metrics:o,issues:d,suggestions:s,performance:c}}catch(n){throw Error(`Failed to analyze template ${t}: ${n instanceof Error?n.message:String(n)}`)}}function Un(t){let n=t.split(`
|
|
3
3
|
`),o=t.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),s=(o?o[1]:"").split(`
|
|
4
4
|
`).length,c={conditionals:(t.match(/@(if|unless|elseif|else|endif|endunless)\b/g)||[]).length,loops:(t.match(/@(foreach|for|endforeach|endfor|while|endwhile)\b/g)||[]).length,includes:(t.match(/@(include|component|extends|section|yield)\b/g)||[]).length,custom:0,total:0};c.total=c.conditionals+c.loops+c.includes+c.custom;let u=(t.match(/\{\{[\s\S]*?\}\}/g)||[]).length,f=(t.match(/\{!![\s\S]*?!!\}/g)||[]).length,g=(t.match(/@(?:if|unless|elseif|foreach|for|while)\s*\([^)]+\)/g)||[]).length,h=u+f+g,x=(t.match(/<[A-Z][^>]*>/g)||[]).length,v=(t.match(/@(?:layout|extends)\(/g)||[]).length,S=0,T=0;for(let k of n)if(/@(?:if|unless|foreach|for|while|section)\b/.test(k)&&!/@end/.test(k)&&!/@else/.test(k))T++,S=Math.max(S,T);else if(/@end(?:if|unless|foreach|for|while|section)\b/.test(k))T--;let w=S>=4?3:0,b=Math.min(10,Math.ceil(c.total*0.5+h*0.1+x*0.3+(s>10?s*0.05:0)+w));return{lines:n.length,characters:t.length,directives:c,expressions:h,components:x,layouts:v,scriptLines:s,complexity:b}}function Wn(t,n){let o=[],d=Xt(t,"if","endif");if(d>0)o.push({type:"error",category:"syntax",message:`Found ${d} unmatched @if directive(s)`,suggestion:"Ensure every @if has a corresponding @endif"});let s=Xt(t,"foreach","endforeach");if(s>0)o.push({type:"error",category:"syntax",message:`Found ${s} unmatched @foreach directive(s)`,suggestion:"Ensure every @foreach has a corresponding @endforeach"});let c=t.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(c&&c.length>0)o.push({type:"warning",category:"performance",message:"Nested loops detected which may impact performance",suggestion:"Consider preprocessing data or using more efficient data structures"});let u=(t.match(/\{!![\s\S]*?!!\}/g)||[]).length;if(u>0)o.push({type:"warning",category:"security",message:`Found ${u} raw output expression(s) {!! !!}`,suggestion:"Ensure raw outputs are properly sanitized to prevent XSS"});let f=t.match(/<img[^>]*>/g);if(f){let x=f.filter((v)=>!v.includes("alt="));if(x.length>0)o.push({type:"warning",category:"accessibility",message:`Found ${x.length} image(s) without alt attributes`,suggestion:"Add alt attributes to all images for screen reader accessibility"})}let g=t.split(`
|
|
5
5
|
`).filter((x)=>x.length>120);if(g.length>0)o.push({type:"info",category:"maintainability",message:`Found ${g.length} line(s) longer than 120 characters`,suggestion:"Consider breaking long lines for better readability"});let h=(t.match(/style\s*=\s*["'][^"']*["']/g)||[]).length;if(h>3)o.push({type:"info",category:"maintainability",message:`Found ${h} inline style attributes`,suggestion:"Consider moving styles to CSS classes for better maintainability"});return o}function Vn(t,n){let o=[];if(n.complexity>7)o.push({type:"refactor",message:"Template complexity is high. Consider breaking into smaller components.",impact:"high",effort:"medium"});else if(n.complexity>5&&n.directives.total>8)o.push({type:"optimization",message:"Template has moderate complexity. Consider component extraction for reusability.",impact:"medium",effort:"low"});if(n.lines>100&&n.components===0)o.push({type:"refactor",message:"Large template with no components. Consider extracting reusable parts into components.",impact:"medium",effort:"medium"});if(n.expressions>20)o.push({type:"optimization",message:"Many template expressions detected. Consider preprocessing some data in the script section.",impact:"medium",effort:"low"});let d=t.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(d&&d.length>0)o.push({type:"optimization",message:"Nested loops detected. Consider preprocessing data or optimizing data structures.",impact:"high",effort:"medium"});if(n.directives.total===0&&n.expressions<5)o.push({type:"optimization",message:"Template appears static. Consider enabling aggressive caching.",impact:"high",effort:"low"});if(n.scriptLines>50)o.push({type:"refactor",message:"Large script section. Consider moving complex logic to external modules.",impact:"medium",effort:"medium"});return o}function qn(t,n){let o=1;if(o+=n.directives.conditionals*0.1,o+=n.directives.loops*0.5,o+=n.directives.includes*2,o+=n.expressions*0.05,o+=n.components*1,n.scriptLines>10)o+=n.scriptLines*0.1;let d;if(n.expressions===0&&n.directives.total===0)d="high";else if(n.expressions<5&&n.directives.total<3)d="medium";else d="low";let s=[];if(o>10)s.push("Consider optimizing template complexity");if(d==="low"&&n.directives.total>5)s.push("Reduce dynamic content for better caching");if(n.components===0&&n.lines>40)s.push("Extract components to improve reusability and performance");return{estimatedRenderTime:Math.round(o*100)/100,complexityScore:n.complexity,cacheability:d,recommendations:s}}function Xt(t,n,o){let d=t.replace(/<!--[\s\S]*?-->/g,""),s=(d.match(new RegExp(`@${n}\\b`,"g"))||[]).length,c=(d.match(new RegExp(`@${o}\\b`,"g"))||[]).length;return Math.abs(s-c)}async function Ki(t=["**/*.stx"],n){let o=[],d=[];for(let c of t){let u=await Array.fromAsync(new Bun.Glob(c).scan({cwd:n||process.cwd(),onlyFiles:!0,absolute:!0}));d.push(...u.filter((f)=>f.endsWith(".stx")))}for(let c of d)try{let u=await Nn(c);o.push(u)}catch(u){console.warn(`Failed to analyze ${c}:`,u)}let s=Kn(o);return{results:o,summary:s}}function Kn(t){let n=t.length,o=t.reduce((h,x)=>h+x.metrics.lines,0),d=n>0?t.reduce((h,x)=>h+x.metrics.complexity,0)/n:0,s=t.reduce((h,x)=>h+x.issues.length,0),c={};t.forEach((h)=>{h.issues.forEach((x)=>{c[x.category]=(c[x.category]||0)+1})});let u=n>0?t.reduce((h,x)=>h+x.performance.estimatedRenderTime,0)/n:0,f=Math.max(1,Math.min(10,Math.round(10-u/2-d/2))),g=[];if(d>6)g.push("Project has high average complexity. Consider refactoring complex templates.");if(s>n*2)g.push("High number of issues detected. Run detailed analysis on individual files.");if(c.security>0)g.push("Security issues found. Review raw output usage and input sanitization.");return{totalFiles:n,totalLines:o,avgComplexity:Math.round(d*100)/100,totalIssues:s,issuesByCategory:c,performanceScore:f,recommendations:g}}import{mkdir as Xn,readFile as Gn,readdir as Jn,stat as Gt,writeFile as Yn}from"fs/promises";import Te from"path";function tn(t){if(t==="connectedCallback")return`method "${t}" is reserved; define "onConnect" instead, which the element calls once it is connected, rendered and bound`;if(t==="disconnectedCallback")return`method "${t}" is reserved; define "onDisconnect" instead, which the element calls as it leaves the DOM, before it releases its own listeners`;return`method "${t}" is reserved`}var nn=new Set(["constructor","connectedCallback","disconnectedCallback","attributeChangedCallback","adoptedCallback"]);function Qn(t){return t.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((n)=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}function It(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Zn(t){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test(t)&&!t.startsWith("xml")&&!/[A-Z]/.test(t)}function er(t){if(t===!0)return"open";if(t==="open"||t==="closed")return t;return!1}async function tr(t){let n=[];async function o(d){let s=await Jn(d,{withFileTypes:!0});s.sort((c,u)=>c.name.localeCompare(u.name));for(let c of s){let u=Te.join(d,c.name);if(c.isDirectory()){if(!c.name.startsWith(".")&&c.name!=="node_modules")await o(u)}else if(c.isFile()&&c.name.endsWith(".stx")&&!/\.(?:test|spec)\.stx$/i.test(c.name))n.push(u)}}return await o(t),n}function nr(t,n){let o=t.match(/<script\b(?=[^>]*(?:\bcomponent\b|\bstx:component\b))[^>]*>([\s\S]*?)<\/script>/i);if(!o)return{};let d=o[1].trim();if(!d)return{};try{return JSON.parse(d)}catch(s){throw Error(`${n}: <script component> must contain JSON metadata (${s.message})`)}}function rr(t,n){let o={},d=[...t.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)];for(let s of d){if(!/\bclient\b/i.test(s[1])||/\bcomponent\b|\bstx:component\b/i.test(s[1]))continue;let c;try{c=new Bun.Transpiler({loader:"ts"}).transformSync(s[2])}catch(g){throw Error(`${n}: failed to transpile <script client> (${g.message})`)}let u=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)\s*\(([^)]*)\)\s*\{/g,f;while(f=u.exec(c)){let g=f[1];if(nn.has(g))throw Error(`${n}: client ${tn(g)}`);let h=u.lastIndex,x=1,v="",S=!1,T=h;for(;T<c.length&&x>0;T++){let b=c[T];if(S){S=!1;continue}if(v){if(b==="\\")S=!0;else if(b===v)v="";continue}if(b==='"'||b==="'"||b==="`")v=b;else if(b==="{")x++;else if(b==="}")x--}if(x!==0)throw Error(`${n}: unterminated client function "${g}"`);let w=f[0].includes("async")?"async ":"";o[g]=`${w}${g}(${f[2]}) {${c.slice(h,T-1)}}`,u.lastIndex=T}}return o}function or(t){let n=t.match(/<template\b(?![^>]*\bshadowrootmode\b)[^>]*>([\s\S]*?)<\/template>/i);return(n?n[1]:t).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").trim()}function Jt(t){return[...t.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((n)=>n[1].trim()).filter(Boolean).join(`
|
|
@@ -887,7 +887,7 @@ else {
|
|
|
887
887
|
};
|
|
888
888
|
})();
|
|
889
889
|
</script>
|
|
890
|
-
`}function Ne(t,n,o={}){let d=Br(n,o),s=t.lastIndexOf("</body>");if(s!==-1)return t.slice(0,s)+d+t.slice(s);if(t.includes("</html>"))return t.replace("</html>",`${d}</html>`);return t+d}function ht(t){let n=t.toLowerCase();return n.endsWith(".css")||n.endsWith(".scss")||n.endsWith(".sass")||n.endsWith(".less")}function bt(t){let n=t.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>n.endsWith(d))}function xt(t){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((o)=>o.test(t))}var nt=null;function vt(t){if(!nt)nt=new on(t);return nt}function it(){if(nt)nt.stop(),nt=null}import wt from"path";var rt={name:"bun-plugin-stx",async setup(t){let o={...await a(),...t.config?.stx},d=new Set,s=o.webComponents?.enabled?`./${wt.relative(wt.dirname(t.config?.outdir||"dist"),o.webComponents.outputDir||"dist/web-components")}`:"/web-components",c=[];if(o.webComponents?.enabled)try{let u=await vs(o,d);if(c.push(...u),o.debug&&u.length>0)console.log(`Successfully built ${u.length} web components`)}catch(u){console.error("Failed to build web components:",u)}t.onLoad({filter:/\.stx$/},async({path:u})=>{try{let f=new Set;if(o.cache&&o.cachePath){let b=await lr(u,o);if(b){if(o.debug)console.log(`Using cached version of ${u}`);return{contents:b,loader:"html"}}}let g=await ke(()=>Bun.file(u).text(),"",(b)=>{throw new Er(`Failed to read stx file: ${u}`,u,void 0,void 0,`File read error: ${b.message}`)});if(!g)throw new Er(`stx file is empty: ${u}`,u);let{scriptContent:h,templateContent:x,allScripts:v}=oe.time("script-extraction",()=>{let b=g,k=de(g);if(k)b=k.content.trim();let _=g.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],E="",R=[];for(let C of _){let D=C.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",I=C.match(/<script\b([^>]*)>/i),V=I?I[1]:"";if(/\bserver\b/i.test(V))E=D;else R.push(C)}let A=b.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:E,templateContent:A,allScripts:R}}),S={__filename:u,__dirname:wt.dirname(u),__stx:{webComponentsPath:s,builtComponents:c}};await ke(()=>m(h,S,u),void 0,(b)=>{let k=new ae(`Script execution failed in ${u}: ${b.message}`,u,void 0,void 0,h.substring(0,100));if(B.log(k,{filePath:u,scriptContent:h}),o.debug)throw k});let w=await oe.timeAsync("directive-processing",async()=>await i(x,S,u,o,f));if(v.length>0){let{interpolateScriptsInTemplate:b}=await import("./chunk-
|
|
890
|
+
`}function Ne(t,n,o={}){let d=Br(n,o),s=t.lastIndexOf("</body>");if(s!==-1)return t.slice(0,s)+d+t.slice(s);if(t.includes("</html>"))return t.replace("</html>",`${d}</html>`);return t+d}function ht(t){let n=t.toLowerCase();return n.endsWith(".css")||n.endsWith(".scss")||n.endsWith(".sass")||n.endsWith(".less")}function bt(t){let n=t.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((d)=>n.endsWith(d))}function xt(t){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((o)=>o.test(t))}var nt=null;function vt(t){if(!nt)nt=new on(t);return nt}function it(){if(nt)nt.stop(),nt=null}import wt from"path";var rt={name:"bun-plugin-stx",async setup(t){let o={...await a(),...t.config?.stx},d=new Set,s=o.webComponents?.enabled?`./${wt.relative(wt.dirname(t.config?.outdir||"dist"),o.webComponents.outputDir||"dist/web-components")}`:"/web-components",c=[];if(o.webComponents?.enabled)try{let u=await vs(o,d);if(c.push(...u),o.debug&&u.length>0)console.log(`Successfully built ${u.length} web components`)}catch(u){console.error("Failed to build web components:",u)}t.onLoad({filter:/\.stx$/},async({path:u})=>{try{let f=new Set;if(o.cache&&o.cachePath){let b=await lr(u,o);if(b){if(o.debug)console.log(`Using cached version of ${u}`);return{contents:b,loader:"html"}}}let g=await ke(()=>Bun.file(u).text(),"",(b)=>{throw new Er(`Failed to read stx file: ${u}`,u,void 0,void 0,`File read error: ${b.message}`)});if(!g)throw new Er(`stx file is empty: ${u}`,u);let{scriptContent:h,templateContent:x,allScripts:v}=oe.time("script-extraction",()=>{let b=g,k=de(g);if(k)b=k.content.trim();let _=g.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],E="",R=[];for(let C of _){let D=C.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",I=C.match(/<script\b([^>]*)>/i),V=I?I[1]:"";if(/\bserver\b/i.test(V))E=D;else R.push(C)}let A=b.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:E,templateContent:A,allScripts:R}}),S={__filename:u,__dirname:wt.dirname(u),__stx:{webComponentsPath:s,builtComponents:c}};await ke(()=>m(h,S,u),void 0,(b)=>{let k=new ae(`Script execution failed in ${u}: ${b.message}`,u,void 0,void 0,h.substring(0,100));if(B.log(k,{filePath:u,scriptContent:h}),o.debug)throw k});let w=await oe.timeAsync("directive-processing",async()=>await i(x,S,u,o,f));if(v.length>0){let{interpolateScriptsInTemplate:b}=await import("./chunk-azvjwte2.js"),k=b(v.join(`
|
|
891
891
|
`),S),_=w.search(/<\/body>/i);if(_!==-1)w=w.slice(0,_)+k+`
|
|
892
892
|
`+w.slice(_);else w+=`
|
|
893
893
|
${k}`}if(w=await we(w),f.forEach((b)=>d.add(b)),o.cache&&o.cachePath){if(await ur(u,w,f,o),o.debug)console.log(`Cached template ${u} with ${f.size} dependencies`)}return{contents:w,loader:"html"}}catch(f){let g=f instanceof Error?f:new ae(`Plugin processing failed: ${String(f)}`,u);if(B.log(g,{filePath:u,buildConfig:t.config}),Sn.logDetailedError(g,{filePath:u,plugin:"bun-plugin-stx"}),o.debug)console.error("stx Plugin Error:",g);let h=g,x=h.line||null,v=h.context||null;return{contents:o.debug||K()?`<!DOCTYPE html>
|
|
@@ -950,7 +950,7 @@ ${k}`}if(w=await we(w),f.forEach((b)=>d.add(b)),o.cache&&o.cachePath){if(await u
|
|
|
950
950
|
<h1>Something went wrong</h1>
|
|
951
951
|
<p>An internal error occurred. Please try again later.</p>
|
|
952
952
|
</body>
|
|
953
|
-
</html>`,loader:"html"}}})}};async function Fr(t,n={}){let o=n.port||3000,d=n.watch!==!1,s=n.hotReload!==!1&&d,c=null,u=n.hmrPort||o+1,f=ge.resolve(t);if(!Be.existsSync(f))return console.error(`${e.red}Error: File not found: ${e.bright}${f}${e.reset}`),!1;if(f.endsWith(".md"))return Ft(f,n);else if(!f.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${f}${e.reset}. Only .stx and .md files are supported.`),!1;let g=l(process.cwd(),"output");Be.mkdirSync(g,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let h=null,x=async()=>{try{let D={name:"public-assets",setup(xe){xe.onResolve({filter:/^\/(images|fonts|assets|public)\//},(le)=>({path:le.path,external:!0}))}},I=await Bun.build({entrypoints:[f],outdir:g,plugins:[D,rt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!I.success)return console.error(`${e.red}Build failed:${e.reset}`,I.logs),!1;let V=I.outputs.find((xe)=>xe.path.endsWith(".html"));if(!V)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return h=await Bun.file(V.path).text(),!0}catch(D){return console.error(`${e.red}Error building stx file:${e.reset}`,D),!1}};if(!await x())return!1;let S=ge.dirname(f);await cn(S);let T=o;try{if(T=await Ve(o),T!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${T} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(s){let D=n.hmrPort||T+1;c=vt({wsPort:D,verbose:!1}),u=c.start(D)}let w={},b=null,k;try{let{loadStxConfig:D}=await import("./chunk-
|
|
953
|
+
</html>`,loader:"html"}}})}};async function Fr(t,n={}){let o=n.port||3000,d=n.watch!==!1,s=n.hotReload!==!1&&d,c=null,u=n.hmrPort||o+1,f=ge.resolve(t);if(!Be.existsSync(f))return console.error(`${e.red}Error: File not found: ${e.bright}${f}${e.reset}`),!1;if(f.endsWith(".md"))return Ft(f,n);else if(!f.endsWith(".stx"))return console.error(`${e.red}Error: Unsupported file type: ${e.bright}${f}${e.reset}. Only .stx and .md files are supported.`),!1;let g=l(process.cwd(),"output");Be.mkdirSync(g,{recursive:!0}),console.log(`${e.blue}Building ${e.bright}${t}${e.reset}...`);let h=null,x=async()=>{try{let D={name:"public-assets",setup(xe){xe.onResolve({filter:/^\/(images|fonts|assets|public)\//},(le)=>({path:le.path,external:!0}))}},I=await Bun.build({entrypoints:[f],outdir:g,plugins:[D,rt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!I.success)return console.error(`${e.red}Build failed:${e.reset}`,I.logs),!1;let V=I.outputs.find((xe)=>xe.path.endsWith(".html"));if(!V)return console.error(`${e.red}No HTML output found${e.reset}`),!1;return h=await Bun.file(V.path).text(),!0}catch(D){return console.error(`${e.red}Error building stx file:${e.reset}`,D),!1}};if(!await x())return!1;let S=ge.dirname(f);await cn(S);let T=o;try{if(T=await Ve(o),T!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${T} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(s){let D=n.hmrPort||T+1;c=vt({wsPort:D,verbose:!1}),u=c.start(D)}let w={},b=null,k;try{let{loadStxConfig:D}=await import("./chunk-e0svetvm.js"),I=await D();if(k=n.stxOptions?.serverApi??I.serverApi,I?.apiRouter)b=I?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(I?.apiRoutes){w=I.apiRoutes;let V=Object.keys(w).length;if(V>0)console.log(`${e.blue}Loaded ${e.bright}${V} API route${V>1?"s":""}${e.reset}`)}if(I?.broadcasting?.enabled)try{let{startBroadcasting:V,loadChannels:Y}=await import("./chunk-x0e0pcn0.js"),xe=I.broadcasting;await V(xe);let le=xe.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${le}/ws${e.reset}`);let Oe=ge.join(process.cwd(),"channels.ts");if(Be.existsSync(Oe))try{let ne=await Y(Oe);console.log(`${e.blue}Loaded ${e.bright}${ne} broadcast channel${ne!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(ne){console.warn(`${e.yellow}Failed to load channels.ts: ${ne.message}${e.reset}`)}}catch(V){console.warn(`${e.yellow}Broadcasting failed to start: ${V.message}${e.reset}`)}}catch{}let{createServerApi:_,isServerApiSource:E}=await import("./chunk-xcskfc2n.js"),R=await _(process.cwd(),k);if(console.log(`${e.blue}Starting server on ${e.cyan}http://localhost:${T}/${e.reset}...`),s)console.log(`${e.magenta}Hot reload enabled on ws://localhost:${u}${e.reset}`);let A=Nr({port:T,async fetch(D){return $n(D,await(async()=>{let I=new URL(D.url);if([g,ge.dirname(f),ge.join(process.cwd(),"public")].some((ne)=>E(ge.join(ne,I.pathname),process.cwd(),k)))return new Response("Not Found",{status:404});if(b)try{let ne=await b.handleRequest(D);if(ne.status!==404)return ne}catch{}if(w[I.pathname])try{return await w[I.pathname](D)}catch(ne){return new Response(JSON.stringify({error:ne.message}),{status:500,headers:{"Content-Type":"application/json"}})}let V=await R(D);if(V)return V;if(I.pathname==="/")return(async()=>{let z=await y(h||"");if(s)z=Ne(z,u);if(n.native)if(z.includes("<head>"))z=z.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(z.includes("<html"))z=z.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else z="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+z;if(n.titlebarHidden)if(z.includes("<head>"))z=z.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(z.includes("<html"))z=z.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else z=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${z}`;return z})().then((z)=>new Response(z,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let Y=ge.join(g,I.pathname);if(Be.existsSync(Y)&&Be.statSync(Y).isFile()){let ne=Bun.file(Y),z=ge.extname(Y).toLowerCase(),L="text/plain";if(z===".ts"||z===".tsx"){let Fe=new Bun.Transpiler({loader:z===".tsx"?"tsx":"ts"}),ze=await ne.text(),Ye=Fe.transformSync(ze);return new Response(Ye,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(z){case".html":L="text/html";break;case".css":L="text/css";break;case".js":L="text/javascript";break;case".json":L="application/json";break;case".png":L="image/png";break;case".jpg":case".jpeg":L="image/jpeg";break;case".gif":L="image/gif";break;case".woff":L="font/woff";break;case".woff2":L="font/woff2";break;case".ttf":L="font/ttf";break;case".otf":L="font/otf";break;case".eot":L="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":L}})}let xe=ge.dirname(f),le=ge.join(xe,I.pathname);if(Be.existsSync(le)&&Be.statSync(le).isFile()){let ne=Bun.file(le),z=ge.extname(le).toLowerCase(),L="text/plain";if(z===".ts"||z===".tsx"){let Fe=new Bun.Transpiler({loader:z===".tsx"?"tsx":"ts"}),ze=await ne.text(),Ye=Fe.transformSync(ze);return new Response(Ye,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(z){case".html":L="text/html";break;case".css":L="text/css";break;case".js":L="text/javascript";break;case".json":L="application/json";break;case".png":L="image/png";break;case".jpg":case".jpeg":L="image/jpeg";break;case".gif":L="image/gif";break;case".svg":L="image/svg+xml";break;case".ico":L="image/x-icon";break;case".woff":L="font/woff";break;case".woff2":L="font/woff2";break;case".ttf":L="font/ttf";break;case".otf":L="font/otf";break;case".eot":L="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":L}})}let Oe=ge.join(process.cwd(),"public",I.pathname);if(Be.existsSync(Oe)&&Be.statSync(Oe).isFile()){let ne=Bun.file(Oe),z=ge.extname(Oe).toLowerCase(),L="application/octet-stream";if(z===".ts"||z===".tsx"){let Fe=new Bun.Transpiler({loader:z===".tsx"?"tsx":"ts"}),ze=await ne.text(),Ye=Fe.transformSync(ze);return new Response(Ye,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(z){case".html":L="text/html";break;case".css":L="text/css";break;case".js":L="text/javascript";break;case".json":L="application/json";break;case".png":L="image/png";break;case".jpg":case".jpeg":L="image/jpeg";break;case".gif":L="image/gif";break;case".svg":L="image/svg+xml";break;case".ico":L="image/x-icon";break;case".woff":L="font/woff";break;case".woff2":L="font/woff2";break;case".ttf":L="font/ttf";break;case".otf":L="font/otf";break;case".eot":L="application/vnd.ms-fontobject";break}return new Response(ne,{headers:{"Content-Type":L}})}return new Response("Not Found",{status:404})})())},error(D){return new Response(`<pre>${D}
|
|
954
954
|
${D.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
|
|
955
955
|
${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
|
|
956
956
|
${e.bright}\u2192 ${e.cyan}http://localhost:${T}/${e.reset}`),console.log(`
|
|
@@ -1437,12 +1437,12 @@ ${w.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),con
|
|
|
1437
1437
|
${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
|
|
1438
1438
|
${e.bright}\u2192 ${e.cyan}http://localhost:${x}/${e.reset}`),console.log(`
|
|
1439
1439
|
${e.yellow}Routes:${e.reset}`);let S=new Set(f.map((w)=>w.routeTemplate)),T=Object.entries(u).filter(([w])=>!S.has(w)).sort(([w],[b])=>w.localeCompare(b)).map(([w,b])=>({route:w==="/"?"/":w,filePath:Pe.relative(process.cwd(),b.filePath),fileType:b.fileType}));for(let w of f){let b=w.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");T.push({route:b,filePath:Pe.relative(process.cwd(),w.filePath),fileType:"stx"})}if(T.sort((w,b)=>w.route.localeCompare(b.route)),T.forEach((w,b)=>{let _=b===T.length-1?"\u2514\u2500 ":"\u251C\u2500 ",E=w.fileType==="md"?`${e.magenta}(markdown)${e.reset}`:"";console.log(` ${e.green}${_}${w.route}${e.reset} \u2192 ${e.bright}${w.filePath}${e.reset} ${E}`)}),console.log(`
|
|
1440
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(v.url.toString(),()=>{if(d)Xe.watch(c,{recursive:!0}).close();v.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let w=Xe.watch(c,{recursive:!0},async(b,k)=>{if(!k)return;if(k.endsWith(".stx")||k.endsWith(".js")||k.endsWith(".ts")||k.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${k}${e.yellow} changed, rebuilding...${e.reset}`),Je.clear(),fe(),await g()});process.on("SIGINT",()=>{w.close(),v.stop(),process.exit(0)})}return!0}function an(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var{serve:Wr}=globalThis.Bun;import me from"fs";import te from"path";async function dn(t){try{return gn(await Bun.file(t).text())}catch{return}}function zt(t){let n=Bun.file(t),o=te.extname(t).toLowerCase(),d={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},c=[".js",".css",".json"].includes(o)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(n,{headers:{"Content-Type":d[o]||"application/octet-stream",...c}})}async function Hr(t=".",n={}){let o=n.port||3000,d=n.watch!==!1,s=n.hotReload!==!1&&d,c=null,u=n.hmrPort||o+1,f=te.resolve(t),{loadStxConfig:g}=await import("./chunk-5n854rfw.js"),h=await g(f),{createServerApi:x,isServerApiSource:v}=await import("./chunk-fmqhe1dh.js"),S=n.stxOptions?.serverApi??h.serverApi,T=await x(f,S),w=h.root&&h.root!=="."?te.join(f,h.root):f,b=n.pagesDir||h.pagesDir||"pages",k=te.join(w,b);if(!me.existsSync(k)&&!h._layerPageDirs?.some((O)=>me.existsSync(O)))return console.error(`${e.red}Error: No '${b}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${k}${e.reset}`),console.log(`${e.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${e.reset}`),console.log(`${e.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${e.reset}`),console.log(`${e.dim}Starting fresh? Create ${b}/index.stx for the homepage.${e.reset}`),!1;let _=X(w,{pagesDir:b,pagesDirs:h._layerPageDirs?[k,...h._layerPageDirs.slice(1)]:void 0});if(_.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${k}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${_.length}${e.blue} routes${e.reset}`);let E=h?._pluginPageDirs||[],R=[];for(let{dir:O,prefix:j}of E)if(me.existsSync(O)){let N=X(te.dirname(O),{pagesDir:te.basename(O)});for(let Q of N){let q=j==="/"?Q.pattern:`${j}${Q.pattern==="/"?"":Q.pattern}`;R.push({route:{...Q,pattern:q},prefix:j})}if(N.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${N.length}${e.blue} routes at ${e.cyan}${j}${e.reset}`)}let A=new Map,C=null,D=null;if(n.stxOptions?.shell!==!1){if(D=await oa(f,n.stxOptions?.shell),D){if(C=await fo(D,n.stxOptions||{}),C)console.log(`${e.blue}Using app shell: ${e.bright}${te.relative(f,D)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}kt(),await Ct(f);let I=_t();if(I.length>0)console.log(`${e.blue}Loaded ${e.bright}${I.length}${e.blue} middleware: ${e.dim}${I.join(", ")}${e.reset}`);let V={},Y=null;try{let{loadStxConfig:O}=await import("./chunk-5n854rfw.js"),j=await O(f);if(j?.apiRouter)Y=j?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(j?.apiRoutes){V=j.apiRoutes;let N=Object.keys(V).length;if(N>0)console.log(`${e.blue}Loaded ${e.bright}${N} API route${N>1?"s":""}${e.reset}`)}if(j?.broadcasting?.enabled)try{let{startBroadcasting:N,loadChannels:Q}=await import("./chunk-x0e0pcn0.js"),q=j.broadcasting;await N(q);let Ae=q.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${Ae}/ws${e.reset}`);let ve=te.join(process.cwd(),"channels.ts");if(me.existsSync(ve))try{let U=await Q(ve);console.log(`${e.blue}Loaded ${e.bright}${U} broadcast channel${U!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(U){console.warn(`${e.yellow}Failed to load channels.ts: ${U.message}${e.reset}`)}}catch(N){console.warn(`${e.yellow}Broadcasting failed to start: ${N.message}${e.reset}`)}}catch{}let xe=l(f,"output");me.mkdirSync(xe,{recursive:!0});let le=new Map,Oe=new Set,ne=async(O)=>{let j=Ts(k,O);if(!j)return null;try{let N=await Bun.build({entrypoints:[j],outdir:xe,plugins:[rt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!N.success)return null;let Q=N.outputs.find((q)=>q.path.endsWith(".html"));if(!Q)return null;return await Bun.file(Q.path).text()}catch{return null}},z=new Map,L=async(O,j)=>{try{let{processDirectives:N,extractVariables:Q,defaultConfig:q,loadStxConfig:Ae,injectRouterScript:ve}=await import("./chunk-5n854rfw.js"),{checkCache:U,cacheTemplate:J,readFileCached:W,templateCache:pe}=await import("./chunk-k76tp0dd.js"),G=await Ae(f),Ue=(ie)=>{if(!ie)return ie;if(te.isAbsolute(ie))return ie;return te.resolve(f,ie)},ce={...q,...G,...n.stxOptions,autoShell:!0};if(n.debugDirectives)ce.debug=!0;ce.partialsDir=Ue(ce.partialsDir),ce.componentsDir=Ue(ce.componentsDir),ce.layoutsDir=Ue(ce.layoutsDir),ce.storesDir=Ue(ce.storesDir||"stores"),ce.cachePath=Ue(ce.cachePath)??l(f,"cache");let H=!j&&!n.profile,re=ce.cache!==!1;if(re&&H){let ie=pe.get(O.filePath);if(ie)try{if((await me.promises.stat(O.filePath)).mtime.getTime()<=ie.mtime){let He=!0;for(let Se of ie.dependencies){if(!me.existsSync(Se)){He=!1;break}if((await me.promises.stat(Se)).mtime.getTime()>ie.mtime){He=!1;break}}if(He){let Se=ie.output;if(C)Se=We(Se,{preserveHead:!0});let st=z.get(O.filePath);return{route:O,content:Se,status:st?.status??await dn(O.filePath),headers:st?.headers}}}}catch{}let Ie=await U(O.filePath,ce);if(Ie){let je=Ie;if(C)je=We(je,{preserveHead:!0});let He=z.get(O.filePath);return{route:O,content:je,status:He?.status??await dn(O.filePath),headers:He?.headers}}}let Z=re?await W(O.filePath):await Bun.file(O.filePath).text(),se=gn(Z),{classifyAllScripts:ue}=await import("./chunk-5n854rfw.js"),F=ue(Z),Le=F.server.map((ie)=>ie.content),Me=Z;for(let ie of F.server)Me=Me.replace(ie.fullTag,"");let ee={__filename:O.filePath,__dirname:te.dirname(O.filePath),__stx_options:ce,params:j??{},__stx_runtime_head:{}};for(let ie of Le)try{await Q(ie,ee,O.filePath)}catch(Ie){if(n.stxOptions?.debug)console.error("[stx] variable extraction error",O.filePath,Ie?.message||Ie)}let De=new Set,he;if(n.profile){let ie=performance.now();he=await N(Me,ee,O.filePath,ce,De);let Ie=performance.now()-ie,je=te.relative(f,O.filePath)||O.filePath;console.log(`[stx:profile] ${je} \u2192 ${Ie.toFixed(2)}ms`)}else he=await N(Me,ee,O.filePath,ce,De);if(!C)he=await ve(he,{router:ce.router});{let{interpolateScriptExpressions:ie}=await import("./chunk-1ckm5pms.js");he=he.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ie,je,He)=>{if(!/function\s+__stx_setup_/.test(He))return Ie;return`<script${je}>${ie(He,ee)}</script>`})}if(C)he=We(he,{preserveHead:!0});if(re&&H)await J(O.filePath,he,De,ce);let{extractStreamBoundaries:ct}=await import("./chunk-gy9s3008.js"),Qe=ct(ee),ot=ee.__streamTemplates;if(ot&&typeof ot==="object"&&Object.keys(ot).length>0){let ie=ee.streamBoundaries||{},Ie={...ce,autoShell:!1},je=Object.keys(ot).map((Se)=>({id:Se,render:async()=>{let st=typeof ie[Se]==="function"?await ie[Se]():void 0;return N(ot[Se],{...ee,$boundary:st},O.filePath,Ie,new Set)}})),He=new Set(je.map((Se)=>Se.id));Qe=[...(Qe||[]).filter((Se)=>!He.has(Se.id)),...je]}if(Qe&&Qe.length>0)Oe.add(O.pattern);else Qe=void 0;let Vt=Ot(ee),qt=Nt(ee);if(H)z.set(O.filePath,{status:Vt,headers:qt});return{route:O,content:he,status:Vt??se,headers:qt,boundaries:Qe}}catch(N){return console.error(`${e.red}Error building ${e.bright}${O.pattern}${e.reset}:`,N),null}},Fe=8,ze=async()=>{let O=new Set(le.keys()),j=new Set(A.keys());le.clear(),A.clear();let N=n.prebuild===!1?_.filter((q)=>O.has(q.pattern)):_,Q=n.prebuild===!1?R.filter(({route:q})=>j.has(q.pattern)):R;for(let q=0;q<N.length;q+=Fe){let Ae=N.slice(q,q+Fe),ve=await Promise.all(Ae.map((U)=>L(U)));for(let U of ve)if(U)le.set(U.route.pattern,U)}for(let q=0;q<Q.length;q+=Fe){let Ae=Q.slice(q,q+Fe),ve=await Promise.all(Ae.map(({route:U})=>L(U)));for(let U of ve)if(U)A.set(U.route.pattern,U)}return le.size>0};if(console.log(`${e.blue}${n.prebuild===!1?"Rendering pages on request...":"Building pages..."}${e.reset}`),!(n.prebuild===!1?_.length+R.length>0:await ze()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await cn(f);let Ge=o;try{if(Ge=await Ve(o),Ge!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${Ge} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(s){let O=n.hmrPort||Ge+1;c=vt({wsPort:O,verbose:!1}),u=c.start(O)}let Pt=(O,j)=>{let Q=`<script data-stx-route-params>(function(){var p=${JSON.stringify(j).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(O.includes("</head>"))return O.replace("</head>",`${Q}</head>`);if(O.includes("<body"))return O.replace(/<body([^>]*)>/,`<body$1>${Q}`);return Q+O};console.log(`${e.blue}Starting server...${e.reset}`);let At=Wr({port:Ge,hostname:n.hostname,async fetch(O){let j=new URL(O.url),N=n.stxOptions?.offline??h.offline;if(j.pathname===Io&&N?.enabled){if(!["GET","HEAD"].includes(O.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});return new Response(O.method==="HEAD"?null:Oo(N,ss()),{headers:{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-store","Service-Worker-Allowed":"/"}})}let Q=h?.publicDir||"public",q=te.join(f,Q,j.pathname),Ae=te.join(f,j.pathname),ve=te.join(xe,j.pathname);if([q,Ae,ve].some((H)=>v(H,f,S)))return new Response("Not Found",{status:404});let[U,J,W]=await Promise.all([me.promises.stat(q).catch(()=>null),me.promises.stat(Ae).catch(()=>null),me.promises.stat(ve).catch(()=>null)]);if(U?.isFile()&&!v(q,f,S))return zt(q);if(J?.isFile()&&!v(Ae,f,S))return zt(Ae);if(W?.isFile()&&!v(ve,f,S))return zt(ve);if(j.pathname.startsWith("/_stx/component/")){let H=decodeURIComponent(j.pathname.slice(16));if(H)try{let re=`<${H} />`,Z={...buildConfig,autoShell:!1},se=await processDirectives(re,{},te.join(f,"components",`${H}.stx`),Z,new Set);return new Response(se,{headers:{"Content-Type":"text/html"}})}catch(re){return new Response(`<div class="stx-async-error">${re.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(j.pathname==="/_stx/img"){let{handleImageRequest:H}=await import("./chunk-mcevnfnx.js"),re=await H(O,{publicDir:te.join(f,Q),cacheDir:l(f,"cache","img")});if(re)return re}if(Y)try{let H=await Y.handleRequest(O);if(H.status!==404)return H}catch{}if(V[j.pathname])try{return await V[j.pathname](O)}catch(H){return new Response(JSON.stringify({error:H.message}),{status:500,headers:{"Content-Type":"application/json"}})}let pe=await T(O);if(pe)return pe;let G=pr(j.pathname,_);if(G){let H=le.get(G.route.pattern),re=Oe.has(G.route.pattern);if(!H||G.route.isDynamic&&Object.keys(G.params).length>0||re){let Z=await L(G.route,G.params);if(Z){if(H=Z,!G.route.isDynamic&&!re)le.set(G.route.pattern,Z)}}if(H){let Z=H.status??200,se=H.headers??{},ue=(G.route.filePath?yt(await Bun.file(G.route.filePath).text().catch(()=>"")):null)??{};if(ue.validate){if(!await ue.validate({params:G.params})){let Me=await ne(404);if(Me){let ee=Me;if(ee=await y(ee,f),s)ee=Ne(ee,u);return new Response(ee,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(ue.middleware){let Le=Et(j.pathname,G.params,ue,j.search),Me=Tt(Le,null,O,{isServer:!0}),ee=await $t(ue.middleware,Me);if(ee.redirect){let De=ee.redirect.path,he=ee.redirect.options.redirectCode||302,ct=new Headers(ee.responseHeaders);return ct.set("Location",De),new Response(null,{status:he,headers:ct})}if(ee.abort){let{statusCode:De,message:he}=ee.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${De}</title></head><body><h1>Error ${De}</h1><p>${he}</p></body></html>`,{status:De,headers:{"Content-Type":"text/html"}})}if(Object.keys(ee.state).length>0){let De=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(ee.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;H.content=H.content.replace("</head>",`${De}</head>`)}}let F=H.content;if(C&&ia(O)&&qe(F,h?.router?.container||"main")){let Le=et(F),Me=be(F),ee=F.match(/<title[^>]*>([\s\S]*?)<\/title>/i),De=ee?An(ee[1].trim()):"";if(Object.keys(G.params).length>0)F=Pt(F,G.params);F=await y(F,f);let he=h?.router?.container||"main";return F=Ee(F,he,!0),new Response(F,{status:Z,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Le.layout,"X-STX-Layout-Group":Le.group,"X-STX-Runtime":Me?"true":"false",...De&&{"X-STX-Title":encodeURIComponent(De)},[tc]:ss(),...M(),"Cache-Control":ft}})}if(C)F=qr(C,F);if(Object.keys(G.params).length>0)F=Pt(F,G.params);if(F=await y(F,f),s)F=Ne(F,u);if(n.native)if(F.includes("<head>"))F=F.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else F="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+F;if(n.titlebarHidden)if(F.includes("<head>"))F=F.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else F=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${F}`;if(H.boundaries&&H.boundaries.length>0){let{renderStreamingPage:Le,streamToResponse:Me}=await import("./chunk-gy9s3008.js");return Me(Le(F,H.boundaries,{timeoutMs:30000}),{status:Z,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(F,{status:Z,headers:{"Content-Type":"text/html",...M(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...se}})}}if(R.length>0){let H=R.map((Z)=>Z.route),re=pr(j.pathname,H);if(re){let Z=A.get(re.route.pattern);if(!Z||re.route.isDynamic){let se=await L(re.route,re.params);if(se){if(Z=se,!re.route.isDynamic)A.set(re.route.pattern,se)}}if(Z){let se=Z.content;if(C)se=qr(C,se);if(Object.keys(re.params).length>0)se=Pt(se,re.params);if(se=await y(se,f),s)se=Ne(se,u);return new Response(se,{status:Z.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:Z}of E)if(Z!=="/"&&j.pathname.startsWith(Z)){let se=A.get(Z)||A.get(Z+"/");if(!se){let ue=R.find(({route:F})=>F.pattern===Z||F.pattern===`${Z}/`);if(ue){let F=await L(ue.route);if(F)se=F,A.set(ue.route.pattern,F)}}if(se){let ue=se.content;if(C)ue=qr(C,ue);if(ue=await y(ue,f),s)ue=Ne(ue,u);return new Response(ue,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(St(j.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let Ue=le.get("/");if(Ue){let H=Ue.content;if(H=await y(H,f),s)H=Ne(H,u);if(n.native)if(H.includes("<head>"))H=H.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else H="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+H;return new Response(H,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let ce=await ne(404);if(ce){let H=ce;if(H=await y(H,f),s)H=Ne(H,u);return new Response(H,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(O){let j=await ne(500);if(j)return new Response(j,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${O}
|
|
1440
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(v.url.toString(),()=>{if(d)Xe.watch(c,{recursive:!0}).close();v.stop()}),d){console.log(`${e.blue}Watching for changes...${e.reset}`);let w=Xe.watch(c,{recursive:!0},async(b,k)=>{if(!k)return;if(k.endsWith(".stx")||k.endsWith(".js")||k.endsWith(".ts")||k.endsWith(".md"))console.log(`${e.yellow}File ${e.bright}${k}${e.yellow} changed, rebuilding...${e.reset}`),Je.clear(),fe(),await g()});process.on("SIGINT",()=>{w.close(),v.stop(),process.exit(0)})}return!0}function an(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var{serve:Wr}=globalThis.Bun;import me from"fs";import te from"path";async function dn(t){try{return gn(await Bun.file(t).text())}catch{return}}function zt(t){let n=Bun.file(t),o=te.extname(t).toLowerCase(),d={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},c=[".js",".css",".json"].includes(o)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(n,{headers:{"Content-Type":d[o]||"application/octet-stream",...c}})}async function Hr(t=".",n={}){let o=n.port||3000,d=n.watch!==!1,s=n.hotReload!==!1&&d,c=null,u=n.hmrPort||o+1,f=te.resolve(t),{loadStxConfig:g}=await import("./chunk-e0svetvm.js"),h=await g(f),{createServerApi:x,isServerApiSource:v}=await import("./chunk-xcskfc2n.js"),S=n.stxOptions?.serverApi??h.serverApi,T=await x(f,S),w=h.root&&h.root!=="."?te.join(f,h.root):f,b=n.pagesDir||h.pagesDir||"pages",k=te.join(w,b);if(!me.existsSync(k)&&!h._layerPageDirs?.some((O)=>me.existsSync(O)))return console.error(`${e.red}Error: No '${b}' directory found${e.reset}`),console.log(`${e.dim}Looked in: ${e.bright}${k}${e.reset}`),console.log(`${e.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${e.reset}`),console.log(`${e.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${e.reset}`),console.log(`${e.dim}Starting fresh? Create ${b}/index.stx for the homepage.${e.reset}`),!1;let _=X(w,{pagesDir:b,pagesDirs:h._layerPageDirs?[k,...h._layerPageDirs.slice(1)]:void 0});if(_.length===0)return console.error(`${e.red}Error: No page files found in ${e.bright}${k}${e.reset}`),!1;console.log(`${e.blue}Found ${e.bright}${_.length}${e.blue} routes${e.reset}`);let E=h?._pluginPageDirs||[],R=[];for(let{dir:O,prefix:j}of E)if(me.existsSync(O)){let N=X(te.dirname(O),{pagesDir:te.basename(O)});for(let Q of N){let q=j==="/"?Q.pattern:`${j}${Q.pattern==="/"?"":Q.pattern}`;R.push({route:{...Q,pattern:q},prefix:j})}if(N.length>0)console.log(`${e.blue}Plugin pages: ${e.bright}${N.length}${e.blue} routes at ${e.cyan}${j}${e.reset}`)}let A=new Map,C=null,D=null;if(n.stxOptions?.shell!==!1){if(D=await oa(f,n.stxOptions?.shell),D){if(C=await fo(D,n.stxOptions||{}),C)console.log(`${e.blue}Using app shell: ${e.bright}${te.relative(f,D)}${e.reset} ${e.dim}(deprecated: use layouts/default.stx instead)${e.reset}`)}}kt(),await Ct(f);let I=_t();if(I.length>0)console.log(`${e.blue}Loaded ${e.bright}${I.length}${e.blue} middleware: ${e.dim}${I.join(", ")}${e.reset}`);let V={},Y=null;try{let{loadStxConfig:O}=await import("./chunk-e0svetvm.js"),j=await O(f);if(j?.apiRouter)Y=j?.apiRouter,console.log(`${e.blue}Using custom router for API handling${e.reset}`);if(j?.apiRoutes){V=j.apiRoutes;let N=Object.keys(V).length;if(N>0)console.log(`${e.blue}Loaded ${e.bright}${N} API route${N>1?"s":""}${e.reset}`)}if(j?.broadcasting?.enabled)try{let{startBroadcasting:N,loadChannels:Q}=await import("./chunk-x0e0pcn0.js"),q=j.broadcasting;await N(q);let Ae=q.port??6001;console.log(`${e.magenta}Broadcasting on ${e.cyan}ws://localhost:${Ae}/ws${e.reset}`);let ve=te.join(process.cwd(),"channels.ts");if(me.existsSync(ve))try{let U=await Q(ve);console.log(`${e.blue}Loaded ${e.bright}${U} broadcast channel${U!==1?"s":""}${e.blue} from channels.ts${e.reset}`)}catch(U){console.warn(`${e.yellow}Failed to load channels.ts: ${U.message}${e.reset}`)}}catch(N){console.warn(`${e.yellow}Broadcasting failed to start: ${N.message}${e.reset}`)}}catch{}let xe=l(f,"output");me.mkdirSync(xe,{recursive:!0});let le=new Map,Oe=new Set,ne=async(O)=>{let j=Ts(k,O);if(!j)return null;try{let N=await Bun.build({entrypoints:[j],outdir:xe,plugins:[rt],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...n.stxOptions});if(!N.success)return null;let Q=N.outputs.find((q)=>q.path.endsWith(".html"));if(!Q)return null;return await Bun.file(Q.path).text()}catch{return null}},z=new Map,L=async(O,j)=>{try{let{processDirectives:N,extractVariables:Q,defaultConfig:q,loadStxConfig:Ae,injectRouterScript:ve}=await import("./chunk-e0svetvm.js"),{checkCache:U,cacheTemplate:J,readFileCached:W,templateCache:pe}=await import("./chunk-pzm3mvh4.js"),G=await Ae(f),Ue=(ie)=>{if(!ie)return ie;if(te.isAbsolute(ie))return ie;return te.resolve(f,ie)},ce={...q,...G,...n.stxOptions,autoShell:!0};if(n.debugDirectives)ce.debug=!0;ce.partialsDir=Ue(ce.partialsDir),ce.componentsDir=Ue(ce.componentsDir),ce.layoutsDir=Ue(ce.layoutsDir),ce.storesDir=Ue(ce.storesDir||"stores"),ce.cachePath=Ue(ce.cachePath)??l(f,"cache");let H=!j&&!n.profile,re=ce.cache!==!1;if(re&&H){let ie=pe.get(O.filePath);if(ie)try{if((await me.promises.stat(O.filePath)).mtime.getTime()<=ie.mtime){let He=!0;for(let Se of ie.dependencies){if(!me.existsSync(Se)){He=!1;break}if((await me.promises.stat(Se)).mtime.getTime()>ie.mtime){He=!1;break}}if(He){let Se=ie.output;if(C)Se=We(Se,{preserveHead:!0});let st=z.get(O.filePath);return{route:O,content:Se,status:st?.status??await dn(O.filePath),headers:st?.headers}}}}catch{}let Ie=await U(O.filePath,ce);if(Ie){let je=Ie;if(C)je=We(je,{preserveHead:!0});let He=z.get(O.filePath);return{route:O,content:je,status:He?.status??await dn(O.filePath),headers:He?.headers}}}let Z=re?await W(O.filePath):await Bun.file(O.filePath).text(),se=gn(Z),{classifyAllScripts:ue}=await import("./chunk-e0svetvm.js"),F=ue(Z),Le=F.server.map((ie)=>ie.content),Me=Z;for(let ie of F.server)Me=Me.replace(ie.fullTag,"");let ee={__filename:O.filePath,__dirname:te.dirname(O.filePath),__stx_options:ce,params:j??{},__stx_runtime_head:{}};for(let ie of Le)try{await Q(ie,ee,O.filePath)}catch(Ie){if(n.stxOptions?.debug)console.error("[stx] variable extraction error",O.filePath,Ie?.message||Ie)}let De=new Set,he;if(n.profile){let ie=performance.now();he=await N(Me,ee,O.filePath,ce,De);let Ie=performance.now()-ie,je=te.relative(f,O.filePath)||O.filePath;console.log(`[stx:profile] ${je} \u2192 ${Ie.toFixed(2)}ms`)}else he=await N(Me,ee,O.filePath,ce,De);if(!C)he=await ve(he,{router:ce.router});{let{interpolateScriptExpressions:ie}=await import("./chunk-azvjwte2.js");he=he.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(Ie,je,He)=>{if(!/function\s+__stx_setup_/.test(He))return Ie;return`<script${je}>${ie(He,ee)}</script>`})}if(C)he=We(he,{preserveHead:!0});if(re&&H)await J(O.filePath,he,De,ce);let{extractStreamBoundaries:ct}=await import("./chunk-x3jwremr.js"),Qe=ct(ee),ot=ee.__streamTemplates;if(ot&&typeof ot==="object"&&Object.keys(ot).length>0){let ie=ee.streamBoundaries||{},Ie={...ce,autoShell:!1},je=Object.keys(ot).map((Se)=>({id:Se,render:async()=>{let st=typeof ie[Se]==="function"?await ie[Se]():void 0;return N(ot[Se],{...ee,$boundary:st},O.filePath,Ie,new Set)}})),He=new Set(je.map((Se)=>Se.id));Qe=[...(Qe||[]).filter((Se)=>!He.has(Se.id)),...je]}if(Qe&&Qe.length>0)Oe.add(O.pattern);else Qe=void 0;let Vt=Ot(ee),qt=Nt(ee);if(H)z.set(O.filePath,{status:Vt,headers:qt});return{route:O,content:he,status:Vt??se,headers:qt,boundaries:Qe}}catch(N){return console.error(`${e.red}Error building ${e.bright}${O.pattern}${e.reset}:`,N),null}},Fe=8,ze=async()=>{let O=new Set(le.keys()),j=new Set(A.keys());le.clear(),A.clear();let N=n.prebuild===!1?_.filter((q)=>O.has(q.pattern)):_,Q=n.prebuild===!1?R.filter(({route:q})=>j.has(q.pattern)):R;for(let q=0;q<N.length;q+=Fe){let Ae=N.slice(q,q+Fe),ve=await Promise.all(Ae.map((U)=>L(U)));for(let U of ve)if(U)le.set(U.route.pattern,U)}for(let q=0;q<Q.length;q+=Fe){let Ae=Q.slice(q,q+Fe),ve=await Promise.all(Ae.map(({route:U})=>L(U)));for(let U of ve)if(U)A.set(U.route.pattern,U)}return le.size>0};if(console.log(`${e.blue}${n.prebuild===!1?"Rendering pages on request...":"Building pages..."}${e.reset}`),!(n.prebuild===!1?_.length+R.length>0:await ze()))return console.error(`${e.red}No pages were successfully built${e.reset}`),!1;await cn(f);let Ge=o;try{if(Ge=await Ve(o),Ge!==o)console.log(`${e.yellow}Port ${o} is busy, using port ${Ge} instead${e.reset}`)}catch{return console.error(`${e.red}Could not find an available port${e.reset}`),!1}if(s){let O=n.hmrPort||Ge+1;c=vt({wsPort:O,verbose:!1}),u=c.start(O)}let Pt=(O,j)=>{let Q=`<script data-stx-route-params>(function(){var p=${JSON.stringify(j).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(O.includes("</head>"))return O.replace("</head>",`${Q}</head>`);if(O.includes("<body"))return O.replace(/<body([^>]*)>/,`<body$1>${Q}`);return Q+O};console.log(`${e.blue}Starting server...${e.reset}`);let At=Wr({port:Ge,hostname:n.hostname,async fetch(O){let j=new URL(O.url),N=n.stxOptions?.offline??h.offline;if(j.pathname===Io&&N?.enabled){if(!["GET","HEAD"].includes(O.method))return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, HEAD"}});return new Response(O.method==="HEAD"?null:Oo(N,ss()),{headers:{"Content-Type":"application/javascript; charset=utf-8","Cache-Control":"no-store","Service-Worker-Allowed":"/"}})}let Q=h?.publicDir||"public",q=te.join(f,Q,j.pathname),Ae=te.join(f,j.pathname),ve=te.join(xe,j.pathname);if([q,Ae,ve].some((H)=>v(H,f,S)))return new Response("Not Found",{status:404});let[U,J,W]=await Promise.all([me.promises.stat(q).catch(()=>null),me.promises.stat(Ae).catch(()=>null),me.promises.stat(ve).catch(()=>null)]);if(U?.isFile()&&!v(q,f,S))return zt(q);if(J?.isFile()&&!v(Ae,f,S))return zt(Ae);if(W?.isFile()&&!v(ve,f,S))return zt(ve);if(j.pathname.startsWith("/_stx/component/")){let H=decodeURIComponent(j.pathname.slice(16));if(H)try{let re=`<${H} />`,Z={...buildConfig,autoShell:!1},se=await processDirectives(re,{},te.join(f,"components",`${H}.stx`),Z,new Set);return new Response(se,{headers:{"Content-Type":"text/html"}})}catch(re){return new Response(`<div class="stx-async-error">${re.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(j.pathname==="/_stx/img"){let{handleImageRequest:H}=await import("./chunk-mcevnfnx.js"),re=await H(O,{publicDir:te.join(f,Q),cacheDir:l(f,"cache","img")});if(re)return re}if(Y)try{let H=await Y.handleRequest(O);if(H.status!==404)return H}catch{}if(V[j.pathname])try{return await V[j.pathname](O)}catch(H){return new Response(JSON.stringify({error:H.message}),{status:500,headers:{"Content-Type":"application/json"}})}let pe=await T(O);if(pe)return pe;let G=pr(j.pathname,_);if(G){let H=le.get(G.route.pattern),re=Oe.has(G.route.pattern);if(!H||G.route.isDynamic&&Object.keys(G.params).length>0||re){let Z=await L(G.route,G.params);if(Z){if(H=Z,!G.route.isDynamic&&!re)le.set(G.route.pattern,Z)}}if(H){let Z=H.status??200,se=H.headers??{},ue=(G.route.filePath?yt(await Bun.file(G.route.filePath).text().catch(()=>"")):null)??{};if(ue.validate){if(!await ue.validate({params:G.params})){let Me=await ne(404);if(Me){let ee=Me;if(ee=await y(ee,f),s)ee=Ne(ee,u);return new Response(ee,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(ue.middleware){let Le=Et(j.pathname,G.params,ue,j.search),Me=Tt(Le,null,O,{isServer:!0}),ee=await $t(ue.middleware,Me);if(ee.redirect){let De=ee.redirect.path,he=ee.redirect.options.redirectCode||302,ct=new Headers(ee.responseHeaders);return ct.set("Location",De),new Response(null,{status:he,headers:ct})}if(ee.abort){let{statusCode:De,message:he}=ee.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${De}</title></head><body><h1>Error ${De}</h1><p>${he}</p></body></html>`,{status:De,headers:{"Content-Type":"text/html"}})}if(Object.keys(ee.state).length>0){let De=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(ee.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;H.content=H.content.replace("</head>",`${De}</head>`)}}let F=H.content;if(C&&ia(O)&&qe(F,h?.router?.container||"main")){let Le=et(F),Me=be(F),ee=F.match(/<title[^>]*>([\s\S]*?)<\/title>/i),De=ee?An(ee[1].trim()):"";if(Object.keys(G.params).length>0)F=Pt(F,G.params);F=await y(F,f);let he=h?.router?.container||"main";return F=Ee(F,he,!0),new Response(F,{status:Z,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Le.layout,"X-STX-Layout-Group":Le.group,"X-STX-Runtime":Me?"true":"false",...De&&{"X-STX-Title":encodeURIComponent(De)},[tc]:ss(),...M(),"Cache-Control":ft}})}if(C)F=qr(C,F);if(Object.keys(G.params).length>0)F=Pt(F,G.params);if(F=await y(F,f),s)F=Ne(F,u);if(n.native)if(F.includes("<head>"))F=F.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else F="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+F;if(n.titlebarHidden)if(F.includes("<head>"))F=F.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else F=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${F}`;if(H.boundaries&&H.boundaries.length>0){let{renderStreamingPage:Le,streamToResponse:Me}=await import("./chunk-x3jwremr.js");return Me(Le(F,H.boundaries,{timeoutMs:30000}),{status:Z,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(F,{status:Z,headers:{"Content-Type":"text/html",...M(),"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0",...se}})}}if(R.length>0){let H=R.map((Z)=>Z.route),re=pr(j.pathname,H);if(re){let Z=A.get(re.route.pattern);if(!Z||re.route.isDynamic){let se=await L(re.route,re.params);if(se){if(Z=se,!re.route.isDynamic)A.set(re.route.pattern,se)}}if(Z){let se=Z.content;if(C)se=qr(C,se);if(Object.keys(re.params).length>0)se=Pt(se,re.params);if(se=await y(se,f),s)se=Ne(se,u);return new Response(se,{status:Z.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:Z}of E)if(Z!=="/"&&j.pathname.startsWith(Z)){let se=A.get(Z)||A.get(Z+"/");if(!se){let ue=R.find(({route:F})=>F.pattern===Z||F.pattern===`${Z}/`);if(ue){let F=await L(ue.route);if(F)se=F,A.set(ue.route.pattern,F)}}if(se){let ue=se.content;if(C)ue=qr(C,ue);if(ue=await y(ue,f),s)ue=Ne(ue,u);return new Response(ue,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}if(St(j.pathname))return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}});let Ue=le.get("/");if(Ue){let H=Ue.content;if(H=await y(H,f),s)H=Ne(H,u);if(n.native)if(H.includes("<head>"))H=H.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else H="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+H;return new Response(H,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let ce=await ne(404);if(ce){let H=ce;if(H=await y(H,f),s)H=Ne(H,u);return new Response(H,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(O){let j=await ne(500);if(j)return new Response(j,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${O}
|
|
1441
1441
|
${O.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
|
|
1442
1442
|
${e.blue}stx${e.reset} ${e.green}${process.env.stx_VERSION||"v0.0.10"}${e.reset} ${e.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${e.reset}`),console.log(`
|
|
1443
1443
|
${e.bright}\u2192 ${e.cyan}http://localhost:${Ge}/${e.reset}`),s)console.log(`${e.dim} HMR: ws://localhost:${u}${e.reset}`);console.log(`
|
|
1444
1444
|
${e.yellow}Routes:${e.reset}`);let Dt=[...$s(_,f)];for(let{route:O}of R)Dt.push(`${O.pattern}`);if(Dt.forEach((O,j)=>{let Q=j===Dt.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${e.green}${Q}${e.reset}${O}`)}),console.log(`
|
|
1445
|
-
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(At.url.toString(),()=>{if(c)it();At.stop()}),n.native){let O,j=te.join(k,"index.stx");if(me.existsSync(j)){let Q=await Bun.file(j).text();O=gt(Q)}let N=h?.app?.window??{};await Ze(Ge,{title:h?.app?.head?.title||te.basename(f)||"stx App",width:N.width,height:N.height,darkMode:N.darkMode,hotReload:N.hotReload,titlebarHidden:N.titlebarHidden??n.titlebarHidden===!0,nativeSidebar:!!O,sidebarConfig:O})}if(d){console.log(`${e.blue}Watching for changes...${e.reset}`);let O=(U)=>U.startsWith("public/")||U.startsWith("public\\"),j=(U)=>{let J=U.toLowerCase();return J.endsWith(".stx")||J.endsWith(".html")||J.endsWith(".md")},N=new Map,Q=()=>{let U=new Set([f,...h._layerGraph?.layers.map((J)=>J.root)??[],...h._layerGraph?.configDependencies.map((J)=>te.dirname(J))??[]].filter((J)=>me.existsSync(J)).map((J)=>me.realpathSync(J)));for(let J of h._layerGraph?.layers??[])for(let W of Object.values(J.resources)){if(!me.existsSync(W))continue;let pe=me.realpathSync(W);if(![...U].some((G)=>pe===G||pe.startsWith(`${G}${te.sep}`)))U.add(pe)}for(let[J,W]of N)if(!U.has(J))W.close(),N.delete(J);for(let J of U)if(!N.has(J)&&me.existsSync(J))N.set(J,me.watch(J,{recursive:!0},(W,pe)=>{Ae(J,W,pe).catch((G)=>console.error("[stx] Layer rebuild failed:",G))}))},q=Promise.resolve(),Ae=(U,J,W)=>(q=q.catch(()=>{}).then(()=>ve(U,J,W)),q),ve=async(U,J,W)=>{if(!W||xt(W))return;if(bt(W)){if(h._layerGraph){let pe=await g(f);Object.assign(h,pe),_.splice(0,_.length,...X(w,{pagesDir:b,pagesDirs:pe._layerPageDirs?[k,...pe._layerPageDirs.slice(1)]:void 0})),Q()}if(O(W)){if(console.log(`${e.cyan}${W} changed${e.reset}`),s&&c)c.reload(W)}else if(j(W)){console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),Je.clear(),fe();try{let{invalidateFileCache:pe,templateCache:G}=await import("./chunk-
|
|
1445
|
+
Press ${e.cyan}h${e.reset} + ${e.cyan}Enter${e.reset} to show shortcuts`),Ke(At.url.toString(),()=>{if(c)it();At.stop()}),n.native){let O,j=te.join(k,"index.stx");if(me.existsSync(j)){let Q=await Bun.file(j).text();O=gt(Q)}let N=h?.app?.window??{};await Ze(Ge,{title:h?.app?.head?.title||te.basename(f)||"stx App",width:N.width,height:N.height,darkMode:N.darkMode,hotReload:N.hotReload,titlebarHidden:N.titlebarHidden??n.titlebarHidden===!0,nativeSidebar:!!O,sidebarConfig:O})}if(d){console.log(`${e.blue}Watching for changes...${e.reset}`);let O=(U)=>U.startsWith("public/")||U.startsWith("public\\"),j=(U)=>{let J=U.toLowerCase();return J.endsWith(".stx")||J.endsWith(".html")||J.endsWith(".md")},N=new Map,Q=()=>{let U=new Set([f,...h._layerGraph?.layers.map((J)=>J.root)??[],...h._layerGraph?.configDependencies.map((J)=>te.dirname(J))??[]].filter((J)=>me.existsSync(J)).map((J)=>me.realpathSync(J)));for(let J of h._layerGraph?.layers??[])for(let W of Object.values(J.resources)){if(!me.existsSync(W))continue;let pe=me.realpathSync(W);if(![...U].some((G)=>pe===G||pe.startsWith(`${G}${te.sep}`)))U.add(pe)}for(let[J,W]of N)if(!U.has(J))W.close(),N.delete(J);for(let J of U)if(!N.has(J)&&me.existsSync(J))N.set(J,me.watch(J,{recursive:!0},(W,pe)=>{Ae(J,W,pe).catch((G)=>console.error("[stx] Layer rebuild failed:",G))}))},q=Promise.resolve(),Ae=(U,J,W)=>(q=q.catch(()=>{}).then(()=>ve(U,J,W)),q),ve=async(U,J,W)=>{if(!W||xt(W))return;if(bt(W)){if(h._layerGraph){let pe=await g(f);Object.assign(h,pe),_.splice(0,_.length,...X(w,{pagesDir:b,pagesDirs:pe._layerPageDirs?[k,...pe._layerPageDirs.slice(1)]:void 0})),Q()}if(O(W)){if(console.log(`${e.cyan}${W} changed${e.reset}`),s&&c)c.reload(W)}else if(j(W)){console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),Je.clear(),fe();try{let{invalidateFileCache:pe,templateCache:G}=await import("./chunk-pzm3mvh4.js");pe(te.resolve(U,W)),G.delete(te.resolve(U,W))}catch{}if(D&&W){if(te.resolve(U,W)===D||te.basename(D)===W){let G=await fo(D,n.stxOptions||{});if(G)C=G}}if(await ze(),await sr(f),s&&c)c.reload(W)}else{console.log(`${e.yellow}${W} changed, rebuilding...${e.reset}`),Je.clear(),fe();try{let{invalidateFileCache:pe,templateCache:G}=await import("./chunk-pzm3mvh4.js");pe(te.resolve(U,W)),G.delete(te.resolve(U,W))}catch{}if(await ze(),s&&c)c.reload(W)}}else if(ht(W)){if(console.log(`${e.cyan}CSS ${W} changed${e.reset}`),s&&c)c.updateCss(W)}};Q(),process.on("SIGINT",()=>{for(let U of N.values())U.close();if(c)it();At.stop(),process.exit(0)})}return!0}import Ut from"fs";import at from"path";async function Vr(t){try{let o=(await Bun.file(t).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return[];let d=o[1],s=[],c=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,u;while((u=c.exec(d))!==null){let f=u[1],g=u[2]||u[3]||u[4];if(!g)continue;let h={name:g},x=f.match(/@type\s+\{([^}]+)\}/i);if(x)h.type=x[1].trim();if(f.match(/@required/i))h.required=!0;let S=f.match(/@default\s+(.+?)(?:\s+|$)/i);if(S)h.default=S[1].trim();let T=f.split(`
|
|
1446
1446
|
`).map((w)=>w.trim().replace(/^\*\s*/,"")).filter((w)=>!w.startsWith("@")&&w.length>0);h.description=T.join(" ").trim(),s.push(h)}if(s.length===0){let f=d.match(/module\.exports\s*=\s*\{([^}]+)\}/i);if(f){let h=f[1].split(",").map((x)=>x.trim()).filter(Boolean);for(let x of h){let[v]=x.split(":").map((S)=>S.trim());if(v)s.push({name:v})}}}return s}catch(n){return console.error(`Error extracting props from ${t}:`,n),[]}}async function Kr(t){try{let n=await Bun.file(t).text(),o=n.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||n.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//);if(o)return o[1].split(`
|
|
1447
1447
|
`).map((d)=>d.trim().replace(/^\*\s*/,"")).join(" ").trim();return""}catch{return""}}async function Xr(t,n=!1,o){let d=at.basename(t,".stx"),s=await Vr(t),c=await Kr(t),u="";if(n&&o)u=`<${o}></${o}>`;else{let f=s.map((g)=>{if(g.type==="boolean")return`:${g.name}="true"`;return`${g.name}="value"`}).join(`
|
|
1448
1448
|
`);u=`<${d}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{us,or,Pf}from"./chunk-7wwyv1yz.js";import"./chunk-he85ksa7.js";import"./chunk-sv15wh4x.js";import"./chunk-rkrxqyj1.js";import"./chunk-wj78td69.js";import"./chunk-bmc9cdn7.js";import"./chunk-h2qj88z7.js";import"./chunk-zxfptbac.js";import"./chunk-605b93pe.js";import"./chunk-x8js27hd.js";import"./chunk-yewd8836.js";import{Pt}from"./chunk-hdzxtnbj.js";import"./chunk-s6gwfp55.js";import"./chunk-27rzdq3n.js";import"./chunk-bq9xf8nq.js";import"./chunk-2yxva96k.js";import"./chunk-9f6qx8b9.js";export{Pf as declareBareLoopHead,Pt as parseLoopBinding,or as processLoops,us as reportDeferredLoopWarnings};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{m,h,p}from"./chunk-
|
|
2
|
+
import{m,h,p}from"./chunk-hdzxtnbj.js";import{j}from"./chunk-bmc9cdn7.js";import{i}from"./chunk-5gsycj60.js";import k from"path";var q={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var M=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function H(e){let t=[],o=0,n;M.lastIndex=0;while((n=M.exec(e))!==null){if(n.index>o){let a=e.slice(o,n.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let s=n[1],r=n[2];t.push({type:"suspense",name:s,content:r}),o=n.index+n[0].length}if(o<e.length){let s=e.slice(o);if(s.trim())t.push({type:t.length===0?"shell":"content",content:s})}if(t.length===0)t.push({type:"shell",content:e});return t}async function Rm(e,t={},o={}){let n={...j,...o,streaming:{...q,...o.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),g=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y={...t,__filename:e,__dirname:k.dirname(e)};if(g.trim())await m(g,y,e);let E=H(c),l=new Set;if(!E.some((w)=>w.type==="suspense")){let w=n.streaming?.strategy||"auto",x=new RegExp(T.source,"g");if(!(w!=="manual"&&x.test(c))){let u=await i(c,y,e,n,l);for(let b=0;b<u.length;b+=s)r.enqueue(u.slice(b,b+s)),await new Promise((f)=>setTimeout(f,0))}else{let u=[],b=new RegExp(T.source,"g"),f;while((f=b.exec(c))!==null)u.push({name:f[1],content:f[2],start:f.index,end:f.index+f[0].length});let v=0;for(let _ of u){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let O=await i(I,y,e,n,l);r.enqueue(O),await new Promise((D)=>setTimeout(D,0))}}let C=await i(_.content,y,e,n,l);r.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await i(_,y,e,n,l);r.enqueue(C)}}}}else{let w=new Map;for(let d of E)if(d.type==="shell"||d.type==="content"){let u=await i(d.content,y,e,n,l);r.enqueue(u)}else if(d.type==="suspense"&&d.name){let u=`stx-suspense-${d.name}`;r.enqueue(`<div id="${u}" data-suspense="${d.name}" style="display:contents;">
|
|
3
3
|
<template data-suspense-fallback>Loading...</template>
|
|
4
4
|
</div>`),w.set(d.name,i(d.content,y,e,n,l))}r.enqueue(`
|
|
5
5
|
<script>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Qr}from"./chunk-qby3e5nm.js";import{S}from"./chunk-
|
|
2
|
+
import{Qr}from"./chunk-qby3e5nm.js";import{S}from"./chunk-hdzxtnbj.js";import{a}from"./chunk-bmc9cdn7.js";import{Ke,re}from"./chunk-c0ejyxfj.js";import{Ka}from"./chunk-y5a4spyy.js";import{L}from"./chunk-k3rcpnzm.js";import{g}from"./chunk-0dve54ne.js";import{existsSync as F,mkdirSync as y,copyFileSync as P,chmodSync as I,rmSync as he}from"fs";import{join as c,basename as ve,resolve as G}from"path";import{spawn as z}from"child_process";import{platform as xe}from"os";function E(e,r,i){let n=new RegExp(`</${r}\\s*>`,"iy"),s=S(e,(t,o)=>(n.lastIndex=o,n.exec(t)?n.lastIndex:-1))[0];return s?e.slice(0,s.start)+i+e.slice(s.start):null}var du=`
|
|
3
3
|
<script>
|
|
4
4
|
(function() {
|
|
5
5
|
'use strict';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-bq9xf8nq.js";import"./chunk-9f6qx8b9.js";import"./chunk-2yxva96k.js";import"./chunk-
|
|
2
|
+
import"./chunk-bq9xf8nq.js";import"./chunk-9f6qx8b9.js";import"./chunk-2yxva96k.js";import"./chunk-hdzxtnbj.js";import"./chunk-27rzdq3n.js";import"./chunk-s6gwfp55.js";import"./chunk-zxfptbac.js";import"./chunk-h2qj88z7.js";import{l}from"./chunk-jdj1358b.js";import u from"fs";import m from"path";async function d(e,t={}){let s=Date.now(),n={total:0,passed:0,failed:0,new:0,failures:[],duration:0},i=t.snapshotDir||l(e.root,"story","snapshots");await u.promises.mkdir(i,{recursive:!0});let r=e.storyFiles;if(t.filter&&t.filter.length>0)r=r.filter((a)=>t.filter.some((o)=>a.fileName.toLowerCase().includes(o.toLowerCase())));for(let a of r)await h(a,i,t,n);return n.duration=Date.now()-s,n}async function h(e,t,s,n){let i=e.story;if(!i)return;for(let r of i.variants){n.total++;let a=m.join(t,`${e.id}-${r.id}.snap`),o=g(r.source||""),f=await w(a);if(s.update||!f){let p={storyId:e.id,variantId:r.id,component:e.fileName,timestamp:Date.now(),hash:o};if(await u.promises.writeFile(a,JSON.stringify(p,null,2)),!f)n.new++;n.passed++}else try{let p=await u.promises.readFile(a,"utf-8"),c=JSON.parse(p);if(c.hash===o)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(c.hash,o)})}catch(p){n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:`Error reading snapshot: ${p}`})}}}async function x(e,t={}){return(await d(e,{...t,update:!0})).total}function g(e){let t=0;for(let s=0;s<e.length;s++){let n=e.charCodeAt(s);t=(t<<5)-t+n,t=t&t}return t.toString(16)}function y(e,t){if(e===t)return 0;let s=Math.abs(Number.parseInt(e,16)-Number.parseInt(t,16));return Math.min(s/1e6,1)}async function w(e){try{return await u.promises.access(e),!0}catch{return!1}}function F(e){let t=[];if(t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(" STX Story Visual Regression Tests"),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),e.failures.length>0){t.push(" \u274C Failures:"),t.push("");for(let s of e.failures){if(t.push(` \u2022 ${s.component} / ${s.variantId}`),t.push(` ${s.message}`),s.difference!==void 0)t.push(` Difference: ${(s.difference*100).toFixed(2)}%`);t.push("")}}if(t.push(" Summary:"),t.push(` Total: ${e.total}`),t.push(` Passed: ${e.passed} \u2713`),t.push(` Failed: ${e.failed} \u2717`),e.new>0)t.push(` New: ${e.new} \u26A1`);return t.push(` Time: ${e.duration}ms`),t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),t.join(`
|
|
3
3
|
`)}export{F as formatTestResults,d as runVisualTests,x as updateSnapshots};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{k}from"./chunk-9f6qx8b9.js";import{xe,It,ii,ai,Rc,Ac,Pc,Ic,Ms,li,Oc,Nc,Dc,hn}from"./chunk-
|
|
2
|
+
import{k}from"./chunk-9f6qx8b9.js";import{xe,It,ii,ai,Rc,Ac,Pc,Ic,Ms,li,Oc,Nc,Dc,hn}from"./chunk-hdzxtnbj.js";import{a}from"./chunk-bmc9cdn7.js";import{yo}from"./chunk-zkbnsqr3.js";import{l}from"./chunk-jdj1358b.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=hn.filter((e)=>!ge.has(e)).sort(),te=[...k].sort(),me=[...new Set([...ee,...te])].sort(),he=new Set(ee),be=new Set(te),ye=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 c of u.code.matchAll(Y)){let g=c.index+c[0].indexOf("{")+1;for(let m of c[1].matchAll(/[^,]+/g)){let x=m[0];if(/^\s*type\s/.test(x))continue;let y=/^\s*([A-Za-z_$][\w$]*)/.exec(x);if(!y)continue;let r=y[1];if(!ye.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,c=(g)=>{if(i.has(g))return;i.add(g);let m=t(g);if(!m)return;let x=m.compilerOptions?.plugins;if(Array.isArray(x)){let r=x.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=c(f);if(p!==void 0)return p}return};return c(u)??void 0}function Nl(e,t="",s=""){let u=e.startLine>1?`
|
|
5
5
|
`.repeat(e.startLine-1):"",i=li(e)+ai(ii(e.code)),c=e.kind==="client"||e.kind==="plain"?Pc(t,e.code):"";return Ms(`${u+i}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{oi,Ec,o,At,oe,C,Oe,pn,Ne,pe,G,vr,fn,Ls,Lc,mn,_r,Bs,Fs,jc,di,Bc,Fc,zc,Hc,Me,Le,zs,Fe,r,bn,h,p,V,Z,Se,_,T}from"./chunk-
|
|
2
|
+
import{oi,Ec,o,At,oe,C,Oe,pn,Ne,pe,G,vr,fn,Ls,Lc,mn,_r,Bs,Fs,jc,di,Bc,Fc,zc,Hc,Me,Le,zs,Fe,r,bn,h,p,V,Z,Se,_,T}from"./chunk-hdzxtnbj.js";import{u,f,R,t,ae,q,c,ke,Si,B,Sn,ki,Ft,_i,tl,$r,nl,it,rl,Rr,sl,kn,Ci,ol,Ar,Ir,_e,Ei}from"./chunk-bq9xf8nq.js";import{Lt}from"./chunk-27rzdq3n.js";import{vn}from"./chunk-s6gwfp55.js";import{y}from"./chunk-j0hz9tst.js";import{gr,Rs}from"./chunk-yewd8836.js";import{uc,dc,dr,Qe,pc,P}from"./chunk-bmc9cdn7.js";import{Jo,Yo,Zo,Qo}from"./chunk-x8js27hd.js";import{oc,ls}from"./chunk-cvde33bc.js";import{os,is,as}from"./chunk-zey7wj7y.js";import{ps,Ho,Vo,gs,ms,Uo}from"./chunk-sv15wh4x.js";import{us,or}from"./chunk-7wwyv1yz.js";import{No}from"./chunk-2gqhfge6.js";import{se,jo,Bo,Fo}from"./chunk-he85ksa7.js";import{ar,be,ac,cr,cc}from"./chunk-rkrxqyj1.js";import{L,Ye}from"./chunk-k3rcpnzm.js";import{fc,gc}from"./chunk-h2qj88z7.js";import{E,_n,Ti}from"./chunk-bmfk3b29.js";import fs from"fs";import ce from"path";function dt(){return`
|
|
3
3
|
// STX Lifecycle Runtime
|
|
4
4
|
(function() {
|
|
5
5
|
if (typeof window === 'undefined') return;
|
|
@@ -1558,7 +1558,7 @@ ${M}
|
|
|
1558
1558
|
</style>`;a=a.replace(x,I),v.lastIndex=0}catch(M){}}}return a}import ot from"path";var rs=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.\.?\/[^'"]*)\2/g,cs=/(<script\b[^>]*>)([\s\S]*?)(<\/script>)/gi;function ds(s,e){if(!e||!s.includes("/"))return s;let l=ot.dirname(e);return s.replace(rs,(a,d,n,g)=>{let v=ot.resolve(l,g);return`${d}${n}${v.split(ot.sep).join("/")}${n}`})}function un(s,e){if(!e||!s.includes("<script"))return s;return s.replace(cs,(l,a,d,n)=>`${a}${ds(d,e)}${n}`)}var Te="<!--PARENT_CONTENT_PLACEHOLDER-->";function dn(s){return s.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function En(s,e){let l=s.length,a=e,d=!0,n=[],g=(v)=>v+9<=l&&s[v]==="<"&&s[v+1]==="/"&&(s[v+2]==="s"||s[v+2]==="S")&&(s[v+3]==="c"||s[v+3]==="C")&&(s[v+4]==="r"||s[v+4]==="R")&&(s[v+5]==="i"||s[v+5]==="I")&&(s[v+6]==="p"||s[v+6]==="P")&&(s[v+7]==="t"||s[v+7]==="T")&&(s[v+8]===">"||/\s/.test(s[v+8]));while(a<l){let v=s[a];if(g(a))return a;if(v==="/"&&s[a+1]==="/"){if(a=s.indexOf(`
|
|
1559
1559
|
`,a+2),a===-1)return-1;a+=1,d=!0;continue}if(v==="/"&&s[a+1]==="*"){let m=s.indexOf("*/",a+2);if(m===-1)return-1;a=m+2,d=!0;continue}if(v==="/"&&d){let m=a+1,x=!1;while(m<l){let b=s[m];if(b==="\\"){m+=2;continue}if(b==="[")x=!0;else if(b==="]")x=!1;else if(b==="/"&&!x){m++;break}else if(b===`
|
|
1560
1560
|
`){m=-1;break}m++}if(m===-1){a++,d=!1;continue}while(m<l&&/[a-z]/.test(s[m]))m++;a=m,d=!1;continue}if(v==="'"||v==='"'){let m=v;a++;while(a<l){if(s[a]==="\\"){a+=2;continue}if(s[a]===m){a++;break}if(s[a]===`
|
|
1561
|
-
`)break;a++}d=!1;continue}if(v==="`"){a++;while(a<l){if(s[a]==="\\"){a+=2;continue}if(s[a]==="`"){a++;break}if(s[a]==="$"&&s[a+1]==="{"){n.push(!0),a+=2,d=!0;break}a++}if(n.length===0)d=!1;continue}if(v==="}"&&n.length>0){n.pop(),a++;while(a<l){if(s[a]==="\\"){a+=2;continue}if(s[a]==="`"){a++,d=!1;break}if(s[a]==="$"&&s[a+1]==="{"){n.push(!0),a+=2,d=!0;break}a++}continue}if(/\s/.test(v));else if(/[)\].\w$]/.test(v))d=!1;else d=!0;a++}return-1}function Tn(s,e){let l=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`<script\\b(?=[^>]*\\b${l}(?:\\s|=|/?>))[^>]*>`,"i").exec(s);if(!a)return null;let d=a.index+a[0].length,n=s.indexOf("</script>",d);if(n===-1)return null;let g=s.indexOf(">",n);if(g===-1)return null;return{start:a.index,end:g+1}}var hs=4096;async function at(s,e,l){if(l.buildMode!=="serve"||e.length<hs)return null;let{registerServeModuleBundle:a}=await import("./chunk-
|
|
1561
|
+
`)break;a++}d=!1;continue}if(v==="`"){a++;while(a<l){if(s[a]==="\\"){a+=2;continue}if(s[a]==="`"){a++;break}if(s[a]==="$"&&s[a+1]==="{"){n.push(!0),a+=2,d=!0;break}a++}if(n.length===0)d=!1;continue}if(v==="}"&&n.length>0){n.pop(),a++;while(a<l){if(s[a]==="\\"){a+=2;continue}if(s[a]==="`"){a++,d=!1;break}if(s[a]==="$"&&s[a+1]==="{"){n.push(!0),a+=2,d=!0;break}a++}continue}if(/\s/.test(v));else if(/[)\].\w$]/.test(v))d=!1;else d=!0;a++}return-1}function Tn(s,e){let l=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`<script\\b(?=[^>]*\\b${l}(?:\\s|=|/?>))[^>]*>`,"i").exec(s);if(!a)return null;let d=a.index+a[0].length,n=s.indexOf("</script>",d);if(n===-1)return null;let g=s.indexOf(">",n);if(g===-1)return null;return{start:a.index,end:g+1}}var hs=4096;async function at(s,e,l){if(l.buildMode!=="serve"||e.length<hs)return null;let{registerServeModuleBundle:a}=await import("./chunk-pzm3mvh4.js");return`<script ${s} src="${a(e)}"></script>`}async function tr(s,e,l,a){try{let{registeredModuleIdsIn:d,buildModuleRegistryScript:n}=await o("stx/client-module-registry",()=>import("./chunk-bwtj5rmk.js")),g=[],v=await n(d(...s),{minify:Ti(e.buildMode,e.minifyClient),collectInputs:g});for(let m of g)l?.add(m);if(a)a.inputs=g,a.code=v??void 0;if(!v)return null;if(e.buildMode==="serve"){let{registerServeModuleBundle:m}=await import("./chunk-pzm3mvh4.js");return`<script data-stx-scoped data-stx-run="always" data-stx-modules src="${m(v)}"></script>`}return`<script data-stx-scoped data-stx-run="always" data-stx-modules>${v.replace(/<\/script/gi,"<\\/script")}</script>`}catch{return null}}async function ys(s,e,l,a){let d={modulesTag:null,modulesCode:null,storeTag:null,storeCode:null,composableTag:null,composableCode:null,frameworkScript:null};try{let{getFrameworkComposableScript:S}=await o("stx/framework-composables",()=>import("./chunk-esvybdrr.js"));d.frameworkScript=await S(s)}catch{}let n=null;try{n=await o("stx/store-loader",()=>import("./chunk-hnb9ar0j.js"))}catch{}let g=e.storesDir,v=!!a.__stx_native_screen||(n?.pageStoresAll()??!0),m=v?"":s.replace(/<script\b[^>]*\bdata-stx-(?:runtime|router|hmr)\b[^>]*>[\s\S]*?<\/script>/gi,""),x=[],b=[],w=null;for(let S=0;S<8;S++){let k=null,D="",A=!1;try{if(n){let H=v?await n.getStoreScript(g).then((U)=>U?{code:U,stores:["*"],functions:null}:null):await n.getStoreScriptFor(g,[m],{reads:n.storesReadInFiles([...x,...b]),runOnce:!0});if(H)k=H.code,D=H.stores.join(","),A=!!H.functions&&!v}}catch{}if(w!==null&&D===w)break;w=D;let M=A?'data-stx-scoped data-stx-run="always" data-stx-stores':"data-stx-stores",I=k?`<script ${M}>${k}</script>`:null;d.storeCode=k,d.storeTag=k?await at(M,k,e)??I:null;let N={};d.modulesTag=await tr([s,I],e,l,N),d.modulesCode=N.code??null,x=N.inputs??[],d.composableTag=null,d.composableCode=null,b=[];try{let{getComposableScript:H}=await o("stx/composable-loader",()=>import("./chunk-v8t78d1e.js")),U=e.composablesDir,O=[d.modulesCode??d.modulesTag,I,d.frameworkScript].filter((F)=>F!==null),j=await H(e._layerComposableDirs??U,s,O,b);if(j)d.composableCode=j,d.composableTag=await at('data-stx-scoped data-stx-run="always" data-stx-composables',j,e)??`<script data-stx-scoped data-stx-run="always" data-stx-composables>${j}</script>`}catch{}if(v||!n)break}return d}async function vs(s,e,l,a={}){let{withModuleSubstitutes:d,moduleSubstitutionKey:n}=await import("./chunk-05q29wa1.js"),g=await import("./chunk-q71qqjy7.js"),{messages:v,webModules:m}=e,x=null,b=null,w=n()===""&&!a.__stx_native_screen;if(v&&g.pageMessagesEnabled(e)&&w)try{x=await g.loadPageMessages(process.cwd(),v)}catch(M){bs(M)}if(m&&Object.keys(m).length&&w)try{b=await(await import("./chunk-tyjzye2d.js")).loadWebModules(process.cwd(),m)}catch(M){ws(M)}let S=new Map([...b??[],...x?.stubs??[]]),k=()=>ys(s,e,l,a),D=S.size?await d(S,k):await k(),A=null;if(x){let M=g.messageAreasIn(D.modulesCode,D.storeCode,D.composableCode),I=g.pageMessagesScript(x,g.pageLanguages(s,x),M);if(I)A=await at('data-stx-scoped data-stx-run="always" data-stx-messages',I,e)??`<script data-stx-scoped data-stx-run="always" data-stx-messages>${I.replace(/<\/script/gi,"<\\/script")}</script>`}return[A,D.modulesTag,D.storeTag,D.composableTag,D.frameworkScript].filter((M)=>M!==null)}var gn=!1;function bs(s){if(gn)return;gn=!0,console.warn(`[stx] messages: ${s instanceof Error?s.message:String(s)}; pages ship every language`)}var hn=!1;function ws(s){if(hn)return;hn=!0,console.warn(`[stx] ${s instanceof Error?s.message:String(s)}; pages bundle the real modules`)}function xs(s,e=""){let l=Tn(s,"data-stx-runtime");if(!l)return s;let a=ar(s);if(a===-1||a===l.start){if(!e)return s;return s.slice(0,l.end)+e+s.slice(l.end)}if(a<l.start)return s.slice(0,a)+s.slice(l.start,l.end)+e+`
|
|
1562
1562
|
`+s.slice(a,l.start)+s.slice(l.end);let d=s.slice(l.start,l.end),n=s.slice(0,l.start)+s.slice(l.end),g=ar(n);if(g===-1)return d+e+`
|
|
1563
1563
|
`+n;return n.slice(0,g)+d+e+`
|
|
1564
1564
|
`+n.slice(g)}function Ss(s){let e=/\x00STX_ESC_MUSTACHE_OPEN\x00([\s\S]*?)\x00STX_ESC_MUSTACHE_CLOSE\x00/g;return s.replace(e,(l,a,d)=>{let n=s.slice(0,d);return n.lastIndexOf("<")>n.lastIndexOf(">")?`{{${a}}}`:`{<!--stx-literal-->{${a}}}`})}async function i(s,e,l,a,d){if(a.ssr===!1&&!a.autoShell&&a.buildMode==="spa")return s;if(e.__stx_signals_gate===void 0)e.__stx_signals_gate=Se(s,l);let n=!e.__stxProcessingDepth;mn(e);for(let g of a._layerGraph?.configDependencies??[])d.add(g);if(n&&a.runtimeConfig)await vn(e,l,a.runtimeConfig);if(n)zc(e),e.__stx_scope_seq??={n:0,key:zs(String(e.__filename??l))},e.__stx_head_injections=_i(),e.__stx_seo_staged=!1;if(!e.__stxProcessingDepth)e.__stxProcessingDepth=0;if(e.__stxProcessingDepth++,!e.__onceStore)e.__onceStore=new Set;if((a.debug||!E()&&!_n())&&l&&l.endsWith(".stx"))No(s,l);try{return await oe.timeAsync("template-processing",async()=>{let g=await ks(s,e,l,a,d);if(n)g=di(g);if(n&&a.autoShell&&a.buildMode!=="compile"){let v=_e(a.app?.head,{known:Ir,source:"app.head"}),x=(e.__stx_runtime_head||null)??Ei(),b=(e.__stx_head_raw||"").trim(),w,S=b.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(S)w=S[1].trim(),b=b.replace(S[0],"").trim();let k=e.__sections?.title,D=k?_(k,e,l):void 0,A=x.title||w||D,M=!x.title&&(!!w||!!D),I=x.meta||[],N=new Set(I.map((X)=>it(X)).filter(Boolean)),H={...v,...A&&{title:A},meta:[...(v.meta||[]).filter((X)=>!N.has(it(X))),...I],link:[...v.link||[],...x.link||[]],script:[...v.script||[],...x.script||[]],headRaw:[v.headRaw,b].filter(Boolean).join(`
|
|
@@ -1573,7 +1573,7 @@ ${m.trim()}
|
|
|
1573
1573
|
@endsection`}}if(I&&m.includes("<script")){let O=G(m),j=O.scripts.map((F)=>yn(F,l)??F);m=vr(O.output,j)}if(m=m.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(O,j,F)=>(M[j]=F,"")),m=m.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(O,j,F)=>{if(/^(['"]).*\1$/.test(F.trim()))return O;try{let X=u(F.trim(),e);if(X===void 0)return O;let ee=(e.__stx_inline_section_values??=[]).push(X)-1;return M[j]=`{{ __stx_inline_section_values[${ee}] }}`,""}catch{return O}}),m=m.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(O,j,F)=>{if(F.includes("@parent"))M[j]=F.replace("@parent",Te);else M[j]=F.trim();return""}),e.__sections=M,m=m.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(O,j,F)=>M[j]||F||""),!("slot"in e)||e.slot===void 0)m=m.replace(/\{\{\s*slot\s*\}\}/g,()=>M.content||"");if(m=as(m,A),I){let O=[],j=G(m),F=pe(j.output,pn,(X,K)=>`\x00STX_ORPHAN_STYLE_${K}\x00`);if(m=F.output.replace(/\x00STX_(SCRIPT|ORPHAN_STYLE)_(\d+)\x00/g,(X,K,ee)=>{let te=K==="SCRIPT"?yn(j.scripts[Number(ee)],l):F.tokens[Number(ee)];if(te)O.push(te);return""}),O.length>0){let X=O.join(`
|
|
1574
1574
|
`);M.content=M.content?`${M.content}
|
|
1575
1575
|
${X}`:X,e.__sections=M}}if(I)try{let O;if(ce.isAbsolute(I))O=I,d.add(I);else O=await ke(()=>bn(I,l,g,d),null,()=>{throw new ae(`Failed to resolve layout path: ${I}`,l,void 0,void 0,`Layout referenced from ${l}`)});if(!O){let te=(J)=>{if(!J)return[];try{let me=ce.isAbsolute(J)?J:ce.resolve(process.cwd(),J);return fs.readdirSync(me).filter((we)=>we.endsWith(".stx")).map((we)=>we.replace(/\.stx$/,""))}catch{return[]}},ne=[...te(g.layoutsDir),...te(g.fallbackLayoutsDir)].filter((J,me,we)=>we.indexOf(J)===me).sort(),le=[g.layoutsDir,g.fallbackLayoutsDir].filter((J)=>typeof J==="string"&&J.length>0),de=le.length>0?` Searched: ${le.join(", ")} (set \`layoutsDir\` to look elsewhere).`:"",ie=`Layout not found: ${I} (referenced from ${l})`+(ne.length>0?`. Available layouts: ${ne.join(", ")}`:g.layoutsDir?`. No .stx layouts found in ${g.layoutsDir}`:"")+de;if(B.log(Error(ie),{layoutPath:I,filePath:l,available:ne},"error"),console.error(`[stx] ${ie}`),g.debug)throw new ae(ie,l);return m}let j=await ke(()=>Bun.file(O).text(),"",()=>{throw new ae(`Failed to read layout file: ${O}`,l,void 0,void 0,"Layout content could not be loaded")});j=un(j,O);let F=j.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(F){if(g.debug)console.log(`Found nested layout: ${F[1]} in ${O}`);let te={},ne=j.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(ie,J,me)=>(te[J]=me.trim(),""));for(let[ie,J]of Object.entries(te))if(M[ie]&&M[ie].includes(Te)){let me=M[ie].indexOf(Te);M[ie]=M[ie].slice(0,me)+J+M[ie].slice(me+Te.length)}else if(!M[ie])M[ie]=J;let le={...e,__sections:M},de=`@layout('${F[1]}')${ne}`;return await i(de,le,O,g,d)}let X=j.replace(/\{\{--[\s\S]*?--\}\}/g,""),K=is(X,A),ee={};return K=K.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(te,ne,le)=>(ee[ne]=le.trim(),`@slot('${ne}')`)),K=K.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(te,ne,le)=>{if(M[ne]){let de=M[ne];if(de.includes(Te)){let ie=ee[ne]||"",J=de.indexOf(Te);de=de.slice(0,J)+ie+de.slice(J+Te.length)}return de}return le||""}),K=$s(K,M),K=K.replace(/\{\{\s*slot\s*\}\}/g,()=>M.content||""),K=as(K,A),e.__originalFilePath=l,m=await $n(K,e,O,g,d),m=`<!-- stx-layout: ${I} -->
|
|
1576
|
-
${m}`,w(m)}catch(O){if(O instanceof q)throw O;throw new ae(`Error processing layout ${I}: ${O instanceof Error?O.message:String(O)}`,l)}return w(await $n(m,e,l,g,d))}function $s(s,e){return s.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(l,a,d)=>{let n=e[a];if(n!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(n))return n}return d||""})}function Es(s,e){if(s.__stx_sfc_mode=!0,s.__stx_options=e,e.buildMode)s.__stx_buildMode=e.buildMode;let l=e.envPrefix||"STX_PUBLIC_",a={};for(let[d,n]of Object.entries(process.env))if(d.startsWith(l)&&n!==void 0)a[d]=n;s.$env=a}async function _s(s,e){await ke(()=>Jt(s,e),void 0,(l)=>{B.log(l,{filePath:s,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${s}: ${l.message}`)})}var ct="data-stx-source";function yn(s,e){if(!s)return s;let l=/^<script\b([^>]*)>/i.exec(s);if(!l||!/\bserver\b/.test(l[1])||l[1].includes(ct))return s;return`<script ${ct}="${encodeURIComponent(e)}"${s.slice(7)}`}function Ts(s){let e=new RegExp(`${ct}="([^"]*)"`).exec(s);return e?decodeURIComponent(e[1]):void 0}function wn(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function xn(s,e,l){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(s)}</span><span style="display:block;margin-top:4px">${wn(l)}</span></div>`}async function Cs(s,e,l,a){let{scanScriptTags:d}=await o("stx/signal-processing",()=>import("./chunk-
|
|
1576
|
+
${m}`,w(m)}catch(O){if(O instanceof q)throw O;throw new ae(`Error processing layout ${I}: ${O instanceof Error?O.message:String(O)}`,l)}return w(await $n(m,e,l,g,d))}function $s(s,e){return s.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(l,a,d)=>{let n=e[a];if(n!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(n))return n}return d||""})}function Es(s,e){if(s.__stx_sfc_mode=!0,s.__stx_options=e,e.buildMode)s.__stx_buildMode=e.buildMode;let l=e.envPrefix||"STX_PUBLIC_",a={};for(let[d,n]of Object.entries(process.env))if(d.startsWith(l)&&n!==void 0)a[d]=n;s.$env=a}async function _s(s,e){await ke(()=>Jt(s,e),void 0,(l)=>{B.log(l,{filePath:s,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${s}: ${l.message}`)})}var ct="data-stx-source";function yn(s,e){if(!s)return s;let l=/^<script\b([^>]*)>/i.exec(s);if(!l||!/\bserver\b/.test(l[1])||l[1].includes(ct))return s;return`<script ${ct}="${encodeURIComponent(e)}"${s.slice(7)}`}function Ts(s){let e=new RegExp(`${ct}="([^"]*)"`).exec(s);return e?decodeURIComponent(e[1]):void 0}function wn(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function xn(s,e,l){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(s)}</span><span style="display:block;margin-top:4px">${wn(l)}</span></div>`}async function Cs(s,e,l,a){let{scanScriptTags:d}=await o("stx/signal-processing",()=>import("./chunk-w07n62g2.js")),n=[],g=!E()&&!_n();for(let m of d(s)){let x=m.attrs;if(!/\bserver\b/.test(x))continue;let b=m.start+m.fullMatch.indexOf(">")+1,w=En(s,b);if(w===-1)continue;let S=s.slice(b,w);if(!S.trim())continue;let k=Ts(x)??l,D={index:m.start,length:w+9-m.start};try{let{extractVariables:A}=await o("stx/variable-extractor",()=>import("./chunk-j5stpj5s.js"));await A(S,e,k,{preserveExisting:!0,onFailure:(M)=>{if(M.kind==="unknown")return;if(a?.onServerScriptError?.({sourcePath:k,kind:M.kind,message:M.message}),!g)return;n.push({...D,markup:xn(k,M.kind,M.message)})}})}catch(A){let M=A instanceof Error?A:Error(String(A));if(B.log(M,{filePath:k,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${k}: ${M.message}`),g)n.push({...D,markup:xn(k,"unknown",M.message)})}}if(n.length===0)return s;let v=s;for(let m of n.sort((x,b)=>b.index-x.index))v=v.slice(0,m.index)+m.markup+v.slice(m.index+m.length);return v}async function As(s,e,l){try{let{interpolateScriptsInTemplate:a}=await o("stx/expressions",()=>import("./chunk-azvjwte2.js"));return a(s,e,{skipServer:!0})}catch(a){let d=a instanceof Error?a:Error(String(a));return B.log(d,{filePath:l,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${l}: ${d.message}`),s}}async function $n(s,e,l,a,d){let n=s,g=a;if(n=await Cs(n,e,l,a),n=await qt(n,e,l),n=await Ut(n,e,l),n=await As(n,e,l),n=await Mt(n,e,l,g),Se(n))n=Ho(n,e),n=ms(n,e),n=gs(n,e);n=Vo(n);let{processStreamDirectives:v}=await o("stx/streaming",()=>import("./chunk-x3jwremr.js"));n=v(n,e),n=or(n,e,l,g,!0),n=await nn(n,e,l,g,d),n=await ls(n,e,l,g,d),n=uc(n,e,l,g);let{processDeferDirectives:m}=await o("stx/defer",()=>import("./chunk-p43hw6ef.js"));n=m(n,e,l);let{processTeleportDirectives:x}=await o("stx/teleport",()=>import("./chunk-nx20kccb.js"));n=x(n,e,l);let{processTransitionDirectives:b,processTransitionAttributes:w}=await o("stx/transitions",()=>import("./chunk-cpq9b0fx.js"));n=b(n,e,l),n=w(n);let{processErrorBoundaryDirectives:S,stripRenderFailedMarkers:k}=await o("stx/error-boundaries",()=>import("./chunk-h85hrwkq.js"));n=S(n,e,l),n=k(n);let{processSuspenseDirectives:D}=await o("stx/suspense",()=>import("./chunk-yrdxvphr.js"));n=D(n,e,l);let{processAsyncDirectives:A}=await o("stx/async-components",()=>import("./chunk-7y2h7nfd.js"));n=A(n,e,l);let{processKeepAliveDirectives:M}=await o("stx/keep-alive",()=>import("./chunk-m90wyzhd.js"));n=M(n,e,l);let{processVirtualListDirectives:I,processVirtualGridDirectives:N,processInfiniteListDirectives:H}=await o("stx/virtual-scrolling",()=>import("./chunk-713az4kg.js"));n=I(n,e,l),n=N(n,e,l),n=H(n,e,l);let{processPartialHydrationDirectives:U,processStaticDirectives:O}=await o("stx/partial-hydration",()=>import("./chunk-x756yzrc.js"));n=U(n,e,l),n=O(n);let{processComputedDirectives:j,processWatchDirectives:F}=await o("stx/computed",()=>import("./chunk-1xdzcy9d.js"));n=j(n,e,l),n=F(n,e,l);let{processFormValidationDirectives:X}=await o("stx/forms-validation",()=>import("./chunk-8fymf3g0.js"));n=X(n,e,l);let{processHeadDirective:K,processTitleDirective:ee,processMetaDirective:te,resetHead:ne}=await o("stx/head",()=>import("./chunk-t482tgm6.js"));if(!e.__stx_head_preset&&!e.__stx_runtime_head)ne();let le=K(n);if(n=le.content,le.headContent)e.__stx_head_raw=`${e.__stx_head_raw||""}${le.headContent}
|
|
1577
1577
|
`;if(n=ee(n,e),n=te(n,e,l),n=Gt(n),n=jo(n,e),n=Rt(n),n=zt(n),n=await os(n,e,l,g,d),n=await ls(n,e,l,g,d),n=n.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),n=di(n),n=se(n,e,l),n=us(n),e.__stxProcessingDepth===1)n=Hc(n,e);if(n=Lc(n,e,{filePath:l,buildMode:g.buildMode}),n=Bo(n,e),n=Fo(n,e),n=We(n,e),n=Ht(n,e),n=Bt(n,e),n=await xt(n,e,l,g),n=await pc(n,e,l),n=await fc(n,e,l,g),n=gc(n,e,l,g),n=Jo(n,e,l,g),n=Yo(n,e,l),n=Zo(n,e,l,g),n=Tt(n,e,l,g),n=Bs(n,e),n=Fs(n),n=jc(n),!g.skipEventDirectives)n=Ec(n,e,l);if(n=wt(n,e,l),g.debug){let z=/\bx-data\s*=/.test(n),W=ps(s);if(z&&W)console.warn(`[stx] ${l}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
|
|
1578
1578
|
Both work on the same page, but they manage separate scopes.
|
|
1579
1579
|
Prefer signals (state/derived/effect) for new components.`)}n=oc(n,e),n=await _(n,e,l),n=Bc(n),n=Fc(n),n=gt(n);let{processXElementDirectives:de}=await o("stx/x-element",()=>import("./chunk-zhxdpzga.js"));n=de(n);let ie=e.__originalFilePath||l,J=Me(e);if(n=await Uo(n,g,ie,J),n=Pt(n,e),n=await Kt(n,e,l,g),g.media?.image?.autoSiblings){let z=g.publicDir||"public",{rewriteImagesWithSiblings:W}=await o("stx/image-optimization/auto-sibling",()=>import("./chunk-gbgbhpms.js"));n=await W(n,{publicDir:z})}if(g.seo?.enabled)n=Qo(n,e,g);let me=(z,W,Q=!0)=>{if(!W)return z;let he=W.match(/<title\b[^>]*>[\s\S]*?<\/title>/i),re=/<head\b[^>]*>[\s\S]*?(?:<\/head\s*>|<body\b|$)/i.exec(z),fe=re?/<title\b[^>]*>[\s\S]*?<\/title>/i.exec(re[0]):null;if(he&&re&&fe){if(Q){let Ce=re.index+fe.index;z=z.slice(0,Ce)+he[0]+z.slice(Ce+fe[0].length)}if(W=W.replace(he[0],"").trim(),!W)return z}if(/<\/head>/i.test(z))return z.replace(/<\/head>/i,`${W}
|
|
@@ -1587,6 +1587,6 @@ ${dt()}
|
|
|
1587
1587
|
`+Ce}else n=n.replace("</head>",`${W}
|
|
1588
1588
|
</head>`)}else if(n.includes("<body"))n=n.replace(/<body([^>]*)>/,`<body$1>
|
|
1589
1589
|
${W}`);else n=W+`
|
|
1590
|
-
`+n}{let{scanScriptTags:z}=await o("stx/signal-processing",()=>import("./chunk-
|
|
1590
|
+
`+n}{let{scanScriptTags:z}=await o("stx/signal-processing",()=>import("./chunk-w07n62g2.js")),W=[];for(let Q of z(n)){if(!/\bserver\b/i.test(Q.attrs))continue;let he=Q.start+Q.fullMatch.indexOf(">")+1,re=En(n,he);if(re===-1)continue;let fe=re+9;while(fe<n.length&&/\s/.test(n[fe]))fe++;W.push({start:Q.start,end:fe})}if(W.length>0){let Q=Array(W.length+1),he=0;for(let re=0;re<W.length;re++){let{start:fe,end:Ce}=W[re];Q[re]=n.slice(he,fe),he=Ce}Q[W.length]=n.slice(he),n=Q.join("")}}let lt=Ls(n,l);if(lt.hasScoped)n=lt.html;let Dn=e.__stx_event_bindings||[],Ke=!1,ut=[],In=/\s:[a-z][\w.-]*\s*=/.test(n),{scanScriptTags:On}=await o("stx/signal-processing",()=>import("./chunk-w07n62g2.js"));for(let z of On(n,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))ut.push({match:z.fullMatch,attrs:z.attrs,content:z.body});for(let{match:z,attrs:W,content:Q}of ut){Ke=!0;let he=Q;Oe(Q,l,a.strict,e.__originalFilePath);let re=await Le(Q,{eventBindings:Dn,attrs:W,hasColonDirectives:In,templateContent:s,filePath:l,projectRoot:process.cwd(),production:Ti(a.buildMode,a.minifyClient),serverData:J});n=n.replace(z,()=>re)}if(Ke)e.__stx_event_bindings=[];if(!Ke&&e.__stxProcessingDepth===1){let z=e.__stx_event_bindings||[];if(z.length>0){let W=oi(z);if(W){let Q=n.lastIndexOf("</body>");n=Q===-1?n+W:n.slice(0,Q)+W+`
|
|
1591
1591
|
`+n.slice(Q)}e.__stx_event_bindings=[]}}if(!be(n)&&ac(n))n=await cr(n,g);if(n=cc(n),g.csp?.enabled&&g.csp.useNonce&&typeof e.cspNonce==="string")n=_t(n,e.cspNonce);return n}
|
|
1592
1592
|
export{yt,Re,tc,ss,Io,Oo,tr,i};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{tt}from"./chunk-yewd8836.js";import{ht,Hn}from"./chunk-ra8f8sm2.js";import{De,gn,Gc,Jc}from"./chunk-
|
|
2
|
+
import{tt}from"./chunk-yewd8836.js";import{ht,Hn}from"./chunk-ra8f8sm2.js";import{De,gn,Gc,Jc}from"./chunk-hdzxtnbj.js";import{$r,Rr,Ar,Ir,_e}from"./chunk-bq9xf8nq.js";import{O}from"./chunk-27rzdq3n.js";import{wi}from"./chunk-s6gwfp55.js";import{y}from"./chunk-j0hz9tst.js";import{i}from"./chunk-5gsycj60.js";import{j,a}from"./chunk-bmc9cdn7.js";import{vc}from"./chunk-605b93pe.js";import{Pn,We,Ee,aa,ca,In}from"./chunk-pfv3hena.js";import{on,Ro}from"./chunk-te1w7dpt.js";import{On}from"./chunk-985afhhy.js";import{Zt,Yn,Zn}from"./chunk-ndjmt3vg.js";import{X}from"./chunk-rkrxqyj1.js";import m from"fs";import c from"path";import{createHash as Q}from"crypto";function W(n){return Q("sha256").update(n).digest("hex").slice(0,8)}function J(n=!1){let l=n?Hn():ht(),o=W(l);return{content:l,filename:`runtime.${o}.js`,hash:o}}function U(){let n=tt(),l=W(n);return{content:n,filename:`router.${l}.js`,hash:l}}import V from"path";import{createHash as ee}from"crypto";function te(n={}){let l=new Set;return{context:new Proxy(n,{get(r,e){if(e in r)return r[e];if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return},has(r,e){if(e in r)return!0;if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return!1}}),accessedKeys:l}}async function q(n,l,o={}){let r=V.resolve(n),e=await Bun.file(r).text(),S=ee("sha256").update(e).digest("hex").slice(0,16);Gc();let _={};try{_=await a(o.configDir)}catch{}let h=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,g;while((g=d.exec(e))!==null){let R=g[1];if(/\bserver\b/.test(R))h.push(g[2])}let u=new Set(h.flatMap((R)=>De(R))),{context:D}=te({__filename:r,__dirname:V.dirname(r),__stx_serverDeclared:u}),A=new Set,T={...j,..._,...o,buildMode:"compile",strict:!1},b=await i(e,D,r,T,A),w=Pn(b)+We(b),P=Jc();return{route:l,sourceFile:n,html:b,fragment:w,placeholders:P,hasServerScripts:h.length>0,serverScriptContent:h,dependencies:Array.from(A),contentHash:S,status:gn(e),streamTemplates:D.__streamTemplates}}var re=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function Z(n,l){let o=0,r=0;if(!m.existsSync(n))return{copied:o,bytes:r};m.mkdirSync(l,{recursive:!0});function e(S,_){let h=m.readdirSync(S,{withFileTypes:!0});for(let d of h){if(re.has(d.name))continue;let g=c.join(S,d.name),u=c.join(_,d.name);if(d.isDirectory())m.mkdirSync(u,{recursive:!0}),e(g,u);else if(d.isFile()){if(m.existsSync(u))continue;m.copyFileSync(g,u),o++,r+=m.statSync(u).size}}}return e(n,l),{copied:o,bytes:r}}async function Yg(n={}){let l=Date.now(),o=c.resolve(n.root||process.cwd()),r=c.resolve(o,n.outputDir||".output");console.log("[stx build] Starting production build...");let e=await a(o),S=c.resolve(o,n.componentsDir??e.componentsDir??"components"),_=c.resolve(o,n.partialsDir??e.partialsDir??"partials"),h=c.resolve(o,n.layoutsDir??e.layoutsDir??"layouts"),d=n.publicDir??e.publicDir??"public",g=_e(e.app?.head,{known:Ir,source:"app.head"}),u=e.app?.colorMode,D=e.router?.container||"main",A=n.routeRules??e.routeRules??{},T=On(A),b=n.serverApi??e.serverApi,w=typeof b==="object"?b:{};if(b)on(o,w);if(e.runtimeConfig)O(e.runtimeConfig,{});if(m.existsSync(r))m.rmSync(r,{recursive:!0});let P=[c.join(r,"public","__stx"),c.join(r,"public","assets"),c.join(r,"server","pages"),c.join(r,"server","fragments")];for(let s of P)m.mkdirSync(s,{recursive:!0});console.log("[stx build] Discovering routes...");let R=X(o,{pagesDirs:e._layerPageDirs}),Y=["components","layouts","partials"],B=R.filter((s)=>!Y.some((f)=>s.pattern.startsWith(`/${f}/`)||s.pattern===`/${f}`));console.log(`[stx build] Found ${B.length} page routes (${R.length-B.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let v=J(n.debug),x=U();await Bun.write(c.join(r,"public","__stx",v.filename),v.content),await Bun.write(c.join(r,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${v.filename} (${(v.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${x.filename} (${(x.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let M=[],k=[];for(let s of B){let f=T(s.pattern),H=f.rendering==="prerender";if(H&&(s.pattern.includes(":")||s.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${s.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let t=await q(s.filePath,s.pattern,{configDir:o,componentsDir:S,partialsDir:_,layoutsDir:h,debug:n.debug});if(M.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,v.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),t.html=Ar(t.html,g,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=$r(t.html,u);if(g.htmlAttrs)t.html=Rr(t.html,g.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(t.html)){let p=t.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(p&&p[1]){let I=p[1];t.html=t.html.replace(" "+I,""),t.html=t.html.replace(/<body([^>]*)>/,`<body$1 ${I}>`)}}if(t.html=t.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),t.html=await y(t.html),H){let p=await In(t,{params:{},request:new Request(`http://stx.build${s.pattern}`),method:"GET",__stx_strict_hydration:!0});if(p.redirect||p.cookies?.length||p.boundaries?.length||p.headers&&Object.keys(p.headers).length)throw Error(`Prerendered route ${s.pattern} cannot set response headers/cookies, redirect or stream`);t.html=p.html,t.status=p.status??t.status,t.hasServerScripts=!1,t.serverScriptContent=[],t.placeholders={}}t.fragment=Ee(t.html,D,!0);let L=s.pattern==="/"?"index":s.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),z=c.join("server","pages",`${L}.compiled.json`),G=c.join("server","fragments",`${L}.html`);await Bun.write(c.join(r,z),JSON.stringify(t,null,2)),await Bun.write(c.join(r,G),t.fragment),k.push({pattern:s.pattern,compiledPath:z,fragmentPath:G,isDynamic:t.hasServerScripts,hasParams:s.pattern.includes(":")||s.pattern.includes("["),prerendered:H}),console.log(`[stx build] \u2713 ${s.pattern}`)}catch(t){if(Object.keys(f).length)throw t;console.error(`[stx build] \u2717 ${s.pattern}:`,t instanceof Error?t.message:t)}}let E=c.resolve(o,d);if(m.existsSync(E)){let{copied:s,bytes:f}=Z(E,c.join(r,"public"));if(s>0)console.log(`[stx build] Copied ${s} public asset${s===1?"":"s"} (${(f/1024).toFixed(1)}KB) from ${d}/`)}let F=Zn(o);if(F){let{copied:s,bytes:f}=Z(F,c.join(r,"public",Yn));if(s>0)console.log(`[stx build] Copied ${s} asset${s===1?"":"s"} (${(f/1024).toFixed(1)}KB) from ${Zt}/`)}let N={runtime:v.filename,router:x.filename},C=aa(k,N,r);if(C.routeRules=A,C.routerContainer=D,b)C.apiRoutes=await Ro(o,r,w);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await wi(o,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(vc(e._layerGraph),null,2));ca(C,r);let K=Date.now()-l;return console.log(`
|
|
3
3
|
[stx build] Done in ${K}ms \u2014 ${M.length} pages compiled`),{pageCount:M.length,assets:N,outputDir:r,duration:K}}
|
|
4
4
|
export{Yg};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ug}from"./chunk-g4rd9yc8.js";import"./chunk-pfv3hena.js";import"./chunk-ndy6wmn4.js";import"./chunk-te1w7dpt.js";import"./chunk-p4f3hz9e.js";import"./chunk-rkrxqyj1.js";import"./chunk-bmc9cdn7.js";import"./chunk-h2qj88z7.js";import"./chunk-zxfptbac.js";import"./chunk-605b93pe.js";import"./chunk-x8js27hd.js";import"./chunk-yewd8836.js";import"./chunk-hdzxtnbj.js";import"./chunk-s6gwfp55.js";import"./chunk-27rzdq3n.js";import"./chunk-bq9xf8nq.js";import"./chunk-2yxva96k.js";import"./chunk-9f6qx8b9.js";export{Ug as startProductionServer};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{xi,Ws,u,f,R,st,d,qs,t,c,w}from"./chunk-bq9xf8nq.js";import{ve,Pt,J,I,Mt,Z,_}from"./chunk-5t59jega.js";import{ir}from"./chunk-09ew1tg3.js";import{se}from"./chunk-he85ksa7.js";import{ys}from"./chunk-wj78td69.js";var de=1000,pe=!1;function he(n,r){let l=/@(include|partial)\s*\(\s*(['"])([^'"]+)\2\s*,\s*/g,e="",o=0,i;while((i=l.exec(n))!==null){let g=i.index+i[0].length,x=i.index+i[0].indexOf("("),b=w(n,"(",")",x);if(b===-1)continue;let p=n.slice(g,b).trim();if(!p)continue;if(!Object.keys(r).some((a)=>new RegExp(`(?:^|[^\\w$.])${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w$])`).test(p)))continue;let m;try{let a=R(p,r);if(!a||typeof a!=="object")continue;m=JSON.stringify(a)}catch{continue}e+=n.slice(o,g)+m,o=b,l.lastIndex=b}return o===0?n:e+n.slice(o)}function me(n,r){let l=/@component\s*\(/g,e=n,o,i=[];while((o=l.exec(e))!==null){let g=o.index,x=g+o[0].length-1,b=1,p=x+1;while(p<e.length&&b>0){if(e[p]==="(")b++;else if(e[p]===")"){if(b--,b===0)break}p++}if(b!==0)continue;let s=e.substring(x+1,p),m=p+1,a=s.match(/^\s*['"]([^'"]+)['"]/);if(!a)continue;let y=a[1],h=s.slice(a[0].length),O=h.match(/^\s*,\s*/);if(!O)continue;let S=h.slice(O[0].length).trim();if(!S)continue;try{let v=R(S,r),W=JSON.stringify(v),F=`@component('${y}', ${W})`;i.push({start:g,end:m,replacement:F})}catch{continue}}for(let g=i.length-1;g>=0;g--){let{start:x,end:b,replacement:p}=i[g];e=e.substring(0,x)+p+e.substring(b)}return e}function oe(n,r,l){let e=n,o=new RegExp(`${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),i;while((i=o.exec(e))!==null){let g=i.index,x=g+i[0].length-1,b=1,p=x+1,s=null,m=!1;while(p<e.length&&b>0){let h=e[p];if(m){m=!1,p++;continue}if(h==="\\"&&s){m=!0,p++;continue}if(s){if(h===s)s=null;p++;continue}if(h==='"'||h==="'"||h==="`"){s=h,p++;continue}if(h==="(")b++;else if(h===")"){if(b--,b===0)break}p++}if(b!==0)break;let a=e.substring(x+1,p),y=l(a);e=e.substring(0,g)+y+e.substring(p+1)}return e}function be(n,r){let l=n;return l=l.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(e,o)=>{if(o in r)return`:${o}="${o}"`;return e}),l=l.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(e,o,i)=>{try{if(I(i,r.__stx_client_signal_names||[]))return e;let g=Object.keys(r),x=Object.values(r);xi(i);let b=!1,s=d(i,g,()=>{b=!0})(...x);if(b)return e;let m=JSON.stringify(s);if(m===void 0){if(!st(i).some((h)=>!(h in r)))return"";return e}let a=Buffer.from(m,"utf8").toString("base64");return`__stx_${o}="${a}"`}catch(g){return e}}),l}var ee="<!--__STX_BREAK__-->",ne="<!--__STX_CONTINUE__-->";function le(n,r){let l=/\{\{\{?|\{!!|@(break|continue)(?![\w$])/g,e="",o=0;for(let i=l.exec(n);i;i=l.exec(n)){if(!i[1]){let p=i[0].length===3&&i[0]==="{{{"?3:2,s=i[0]==="{!!"?n.indexOf("!!}",l.lastIndex):ve(n,i.index,p);if(s<0)break;l.lastIndex=s+(i[0]==="{!!"?3:p);continue}let g=l.lastIndex,x=!0,b=/^\s*\(/.exec(n.slice(g));if(b){let p=g+b[0].length-1,s=w(n,"(",")",p);if(s<0)break;g=s+1;try{let m=`!!(${n.slice(p+1,s).trim()})`;x=f(m)?Boolean(d(m,Object.keys(r))(...Object.values(r))):Boolean(u(m,r))}catch{x=!1}}if(e+=n.slice(o,i.index),x)return e+(i[1]==="break"?ee:ne);o=g,l.lastIndex=g}return e+n.slice(o)}function ae(n){let r=(o)=>o.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),l="",e=0;return Mt(n,(o,i,g)=>(l+=ie(r(n.slice(e,g))),l+=`\${__stxRenderLoopValue(${g}, (${i}), ${o.length})}`,e=g+o.length,o)),l+ie(r(n.slice(e)))}function ue(n,r,l,e){return Z(n,r,l==null?"":String(l),!1,e)}function ie(n){let r=n;return r=oe(r,"@break",(l)=>{let e=l.trim();if(!qs(e))return"";return`\`; if (${e}) { break; } result += \``}),r=oe(r,"@continue",(l)=>{let e=l.trim();if(!qs(e))return"";return`\`; if (${e}) { continue; } result += \``}),r=r.replace(/@break(?!\()/g,"`; break; result += `"),r=r.replace(/@continue(?!\()/g,"`; continue; result += `"),r}function xe(n){let r=/@forelse\s*\(/g,l,e=[],o=/@foreach\s*\(/g,i=/@endforeach/g,g;while((g=o.exec(n))!==null)e.push({pos:g.index,delta:1});while((g=i.exec(n))!==null)e.push({pos:g.index,delta:-1});e.sort((s,m)=>s.pos-m.pos);let x=[],b=0;for(let s of e)b+=s.delta,x.push({pos:s.pos,depth:b});function p(s){let m=0,a=x.length-1,y=0;while(m<=a){let h=m+a>>1;if(x[h].pos<=s)y=x[h].depth,m=h+1;else a=h-1}return y}while((l=r.exec(n))!==null){if(p(l.index)>0)continue;let s=l.index,m=l.index+l[0].length-1,a=1,y=m+1,h=-1;while(y<n.length&&a>0){if(n[y]==="(")a++;else if(n[y]===")"){if(a--,a===0){h=y;break}}y++}if(h===-1)continue;let O=n.substring(m+1,h),S=Pt(O);if(!S)continue;let{arrayExpr:v,itemVar:W}=S,F=h+1,A=1,B=F,D=/@forelse\s*\(/g,L=/@endforelse/g,V=-1;while(A>0&&B<n.length){D.lastIndex=B,L.lastIndex=B;let P=D.exec(n),E=L.exec(n);if(!E)break;if(P&&P.index<E.index)A++,B=P.index+P[0].length;else{if(A--,A===0){V=E.index;break}B=E.index+11}}if(V===-1)continue;let k=n.substring(F,V),K=V+11,U=-1,z=0,N=0;while(N<k.length){let P=k.indexOf("@",N);if(P===-1)break;let E=k.substring(P);if(/^@forelse\s*\(/.test(E))z++,N=P+1;else if(E.startsWith("@endforelse"))z--,N=P+11;else if(z===0&&E.startsWith("@empty")){if(k.length<=P+6||!/[a-z]/i.test(k[P+6])){U=P;break}N=P+1}else N=P+1}if(U===-1)continue;return{start:s,end:K,arrayExpr:v,itemVar:W,foreachContent:k.substring(0,U),emptyContent:k.substring(U+6)}}return null}function ce(n,r){let l=n;while(!0){let e=xe(l);if(!e)break;let{start:o,end:i,arrayExpr:g,itemVar:x,foreachContent:b,emptyContent:p}=e;try{let s;if(f(g))s=d(g,Object.keys(r))(...Object.values(r));else s=u(g,r);let m;if(!Array.isArray(s)||s.length===0)m=p;else m=`@foreach (${g} as ${x})${b}@endforeach`;l=l.substring(0,o)+m+l.substring(i)}catch(s){let m=s instanceof Error?s.message:String(s),a=c("Forelse",`Error in @forelse(${g} as ${x}): ${m}`,t.EVALUATION_ERROR);l=l.substring(0,o)+a+l.substring(i)}}return l}var fe="<!--stx:foreach-not-iterable:",ye=/<!--stx:foreach-not-iterable:([^|>]*)\|([^>]*?)-->/g;function Ee(n,r){return`${fe}${encodeURIComponent(n)}|${encodeURIComponent(r)}-->`}function _e(n,r){console.warn(`[stx] @foreach(${n}) in ${r}: ${n} is not iterable server-side, so the loop rendered nothing. `+"Values a server loop reads must come from <script server> or the page context \u2014 "+"a plain <script> runs in the browser.")}function us(n){if(!n.includes(fe))return n;return n.replace(ye,(r,l,e)=>(_e(decodeURIComponent(l),decodeURIComponent(e)),""))}function or(n,r,l,e,o=!1){let i=n,g=new Set(r.__stx_client_signal_names||[]);for(let s of ir(n))g.add(s);if(g.size)r={...r,__stx_client_signal_names:[...g]};i=ce(i,r);function x(s){let m=/@foreach\s*\(/g,a;while((a=m.exec(s))!==null){let y=a.index,h=a.index+a[0].length-1,O=1,S=h+1,v=-1;while(S<s.length&&O>0){if(s[S]==="(")O++;else if(s[S]===")"){if(O--,O===0){v=S;break}}S++}if(v===-1)continue;let W=s.substring(h+1,v),F=Pt(W);if(!F)continue;let A=y,{arrayExpr:B,itemVar:D}=F,L=v+1,V=1,k=L,K=/@foreach\s*\(/g,U=/@endforeach/g;while(V>0&&k<s.length){K.lastIndex=k,U.lastIndex=k;let z=K.exec(s),N=U.exec(s);if(!N)break;if(z&&z.index<N.index)V++,k=z.index+z[0].length;else{if(V--,V===0){let P=s.substring(L,N.index),E=N.index+11;return{start:A,end:E,arrayExpr:B,itemVar:D,content:P}}k=N.index+11}}}return null}function b(s,m){let a=s;while(!0){let y=x(a);if(!y)break;let{start:h,end:O,arrayExpr:S,itemVar:v,content:W}=y;try{let F=S.trim(),A;if(f(F))A=d(F,Object.keys(m))(...Object.values(m));else A=u(F,m);let B=!1;if(!Array.isArray(A))if(A instanceof Map)A=Array.from(A),B=!0;else if(A instanceof Set)A=Array.from(A);else if(typeof A==="string")A=Array.from(A);else if(A&&typeof A==="object"&&!(A instanceof Date)&&!(A instanceof RegExp))A=Object.entries(A),B=!0;else{let E=Ee(F,l)+c("Foreach",`Error in @foreach: ${F} is not iterable`,t.TYPE_ERROR);a=a.substring(0,h)+E+a.substring(O);continue}let D=e?.loops?.useAltLoopVariable??pe,L=v.trim(),V=null,k,K=!1;if(L.includes("=>")){let E=L.split("=>").map((j)=>j.trim());if(E.length===2&&E[0]&&E[1])V=E[0],k=E[1];else k=L}else if(!L.startsWith("[")&&!L.startsWith("{")&&L.includes(",")){let E=L.split(",").map((j)=>j.trim());if(E.length===2&&E[0]&&E[1])k=E[0],V=E[1],K=!0;else k=L}else k=L;let U="",z=new Set(J(`${S} as ${v}`)),N=A,P=m[Ws]??new WeakMap;for(let E=0;E<N.length;E++){let j=N[E],te={index:E,iteration:E+1,first:E===0,last:E===N.length-1,count:N.length},M={...m,loop:te,$loop:te,[Ws]:P};if(Array.isArray(m.__stx_client_signal_names))M.__stx_client_signal_names=m.__stx_client_signal_names.filter((H)=>!z.has(H));if(k.startsWith("[")&&k.endsWith("]")){let H=k.slice(1,-1).split(",").map((T)=>T.trim());if(Array.isArray(j))H.forEach((T,X)=>{if(T)M[T]=j[X]});else M[k]=j}else if(k.startsWith("{")&&k.endsWith("}")){let H=k.slice(1,-1).split(",").map((T)=>T.trim()).filter(Boolean);if(j!==null&&typeof j==="object")H.forEach((T)=>{let X=T.indexOf(":"),Q=(X===-1?T:T.slice(0,X)).trim(),re=X===-1?Q:T.slice(X+1).trim();if(Q&&re)M[re]=j[Q]});else M[k]=j}else M[k]=j;if(V)if(!K&&B&&Array.isArray(j)&&j.length===2)M[V]=j[0],M[k]=j[1];else M[V]=E;let C=ce(W,M);C=or(C,M,l,e,!0),C=se(C,M,l),C=le(C,M);let q=C.indexOf(ee),G=C.indexOf(ne),Y=q<0?G:G<0?q:Math.min(q,G);if(Y>=0)C=C.slice(0,Y);if(C=_(C,M,l),C=be(C,M),C=me(C,M),C=he(C,M),U+=C,Y>=0&&Y===q)break}a=a.substring(0,h)+U+a.substring(O)}catch(F){let A=c("Foreach",`Error in @foreach(${S.trim()} as ${v.trim()}): ${F instanceof Error?F.message:String(F)}`,t.EVALUATION_ERROR);a=a.substring(0,h)+A+a.substring(O)}}return a}i=b(i,r),i=$e(i,r,l,e);let p=e?.loops?.maxWhileIterations??de;return i=we(i,r,p),o?i:us(i)}function Pf(n){let r=/^(\s*)([A-Za-z_$][\w$]*|\[[^\]]*\]|\{[^}]*\})(\s+(?:of|in)\s)/.exec(n);if(!r||/^(?:const|let|var)$/.test(r[2]))return n;return`${r[1]}let ${n.slice(r[1].length)}`}function ge(n){return qs(n)}function $e(n,r,l,e){let o=n,i=!0;while(i){i=!1;let g=o.match(/@for\s*\(/);if(!g||g.index===void 0)break;let x=g.index,b=x+g[0].length-1,p=w(o,"(",")",b);if(p===-1)break;let s=Pf(o.slice(b+1,p)),m=p+1,a=ys(o.slice(x),"for","endfor");if(a.length===0)break;let y=a[0].content,h=x+a[0].end;if(!ge(s)){let O=c("For",`Unsafe expression in @for: ${s}`,t.UNSAFE_EXPRESSION);o=o.substring(0,x)+O+o.substring(h),i=!0;continue}try{let O=Ae(s),S=/@(?:for|foreach|if|unless)\s*\(/.test(y);if(O.length>0&&S){let D=Re({forExpr:s,content:y,iterVarNames:O,context:r,filePath:l,options:e});o=o.substring(0,x)+D+o.substring(h),i=!0;continue}let v=Object.keys(r),W=Object.values(r),F=ae(y),B=Function(...v,"__stxRenderLoopValue",`
|
|
2
|
+
import{xi,Ws,u,f,R,st,d,qs,t,c,w}from"./chunk-bq9xf8nq.js";import{ve,Pt,J,I,Mt,Z,_}from"./chunk-hdzxtnbj.js";import{ir}from"./chunk-sv15wh4x.js";import{se}from"./chunk-he85ksa7.js";import{ys}from"./chunk-wj78td69.js";var de=1000,pe=!1;function he(n,r){let l=/@(include|partial)\s*\(\s*(['"])([^'"]+)\2\s*,\s*/g,e="",o=0,i;while((i=l.exec(n))!==null){let g=i.index+i[0].length,x=i.index+i[0].indexOf("("),b=w(n,"(",")",x);if(b===-1)continue;let p=n.slice(g,b).trim();if(!p)continue;if(!Object.keys(r).some((a)=>new RegExp(`(?:^|[^\\w$.])${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w$])`).test(p)))continue;let m;try{let a=R(p,r);if(!a||typeof a!=="object")continue;m=JSON.stringify(a)}catch{continue}e+=n.slice(o,g)+m,o=b,l.lastIndex=b}return o===0?n:e+n.slice(o)}function me(n,r){let l=/@component\s*\(/g,e=n,o,i=[];while((o=l.exec(e))!==null){let g=o.index,x=g+o[0].length-1,b=1,p=x+1;while(p<e.length&&b>0){if(e[p]==="(")b++;else if(e[p]===")"){if(b--,b===0)break}p++}if(b!==0)continue;let s=e.substring(x+1,p),m=p+1,a=s.match(/^\s*['"]([^'"]+)['"]/);if(!a)continue;let y=a[1],h=s.slice(a[0].length),O=h.match(/^\s*,\s*/);if(!O)continue;let S=h.slice(O[0].length).trim();if(!S)continue;try{let v=R(S,r),W=JSON.stringify(v),F=`@component('${y}', ${W})`;i.push({start:g,end:m,replacement:F})}catch{continue}}for(let g=i.length-1;g>=0;g--){let{start:x,end:b,replacement:p}=i[g];e=e.substring(0,x)+p+e.substring(b)}return e}function oe(n,r,l){let e=n,o=new RegExp(`${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),i;while((i=o.exec(e))!==null){let g=i.index,x=g+i[0].length-1,b=1,p=x+1,s=null,m=!1;while(p<e.length&&b>0){let h=e[p];if(m){m=!1,p++;continue}if(h==="\\"&&s){m=!0,p++;continue}if(s){if(h===s)s=null;p++;continue}if(h==='"'||h==="'"||h==="`"){s=h,p++;continue}if(h==="(")b++;else if(h===")"){if(b--,b===0)break}p++}if(b!==0)break;let a=e.substring(x+1,p),y=l(a);e=e.substring(0,g)+y+e.substring(p+1)}return e}function be(n,r){let l=n;return l=l.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(e,o)=>{if(o in r)return`:${o}="${o}"`;return e}),l=l.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(e,o,i)=>{try{if(I(i,r.__stx_client_signal_names||[]))return e;let g=Object.keys(r),x=Object.values(r);xi(i);let b=!1,s=d(i,g,()=>{b=!0})(...x);if(b)return e;let m=JSON.stringify(s);if(m===void 0){if(!st(i).some((h)=>!(h in r)))return"";return e}let a=Buffer.from(m,"utf8").toString("base64");return`__stx_${o}="${a}"`}catch(g){return e}}),l}var ee="<!--__STX_BREAK__-->",ne="<!--__STX_CONTINUE__-->";function le(n,r){let l=/\{\{\{?|\{!!|@(break|continue)(?![\w$])/g,e="",o=0;for(let i=l.exec(n);i;i=l.exec(n)){if(!i[1]){let p=i[0].length===3&&i[0]==="{{{"?3:2,s=i[0]==="{!!"?n.indexOf("!!}",l.lastIndex):ve(n,i.index,p);if(s<0)break;l.lastIndex=s+(i[0]==="{!!"?3:p);continue}let g=l.lastIndex,x=!0,b=/^\s*\(/.exec(n.slice(g));if(b){let p=g+b[0].length-1,s=w(n,"(",")",p);if(s<0)break;g=s+1;try{let m=`!!(${n.slice(p+1,s).trim()})`;x=f(m)?Boolean(d(m,Object.keys(r))(...Object.values(r))):Boolean(u(m,r))}catch{x=!1}}if(e+=n.slice(o,i.index),x)return e+(i[1]==="break"?ee:ne);o=g,l.lastIndex=g}return e+n.slice(o)}function ae(n){let r=(o)=>o.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),l="",e=0;return Mt(n,(o,i,g)=>(l+=ie(r(n.slice(e,g))),l+=`\${__stxRenderLoopValue(${g}, (${i}), ${o.length})}`,e=g+o.length,o)),l+ie(r(n.slice(e)))}function ue(n,r,l,e){return Z(n,r,l==null?"":String(l),!1,e)}function ie(n){let r=n;return r=oe(r,"@break",(l)=>{let e=l.trim();if(!qs(e))return"";return`\`; if (${e}) { break; } result += \``}),r=oe(r,"@continue",(l)=>{let e=l.trim();if(!qs(e))return"";return`\`; if (${e}) { continue; } result += \``}),r=r.replace(/@break(?!\()/g,"`; break; result += `"),r=r.replace(/@continue(?!\()/g,"`; continue; result += `"),r}function xe(n){let r=/@forelse\s*\(/g,l,e=[],o=/@foreach\s*\(/g,i=/@endforeach/g,g;while((g=o.exec(n))!==null)e.push({pos:g.index,delta:1});while((g=i.exec(n))!==null)e.push({pos:g.index,delta:-1});e.sort((s,m)=>s.pos-m.pos);let x=[],b=0;for(let s of e)b+=s.delta,x.push({pos:s.pos,depth:b});function p(s){let m=0,a=x.length-1,y=0;while(m<=a){let h=m+a>>1;if(x[h].pos<=s)y=x[h].depth,m=h+1;else a=h-1}return y}while((l=r.exec(n))!==null){if(p(l.index)>0)continue;let s=l.index,m=l.index+l[0].length-1,a=1,y=m+1,h=-1;while(y<n.length&&a>0){if(n[y]==="(")a++;else if(n[y]===")"){if(a--,a===0){h=y;break}}y++}if(h===-1)continue;let O=n.substring(m+1,h),S=Pt(O);if(!S)continue;let{arrayExpr:v,itemVar:W}=S,F=h+1,A=1,B=F,D=/@forelse\s*\(/g,L=/@endforelse/g,V=-1;while(A>0&&B<n.length){D.lastIndex=B,L.lastIndex=B;let P=D.exec(n),E=L.exec(n);if(!E)break;if(P&&P.index<E.index)A++,B=P.index+P[0].length;else{if(A--,A===0){V=E.index;break}B=E.index+11}}if(V===-1)continue;let k=n.substring(F,V),K=V+11,U=-1,z=0,N=0;while(N<k.length){let P=k.indexOf("@",N);if(P===-1)break;let E=k.substring(P);if(/^@forelse\s*\(/.test(E))z++,N=P+1;else if(E.startsWith("@endforelse"))z--,N=P+11;else if(z===0&&E.startsWith("@empty")){if(k.length<=P+6||!/[a-z]/i.test(k[P+6])){U=P;break}N=P+1}else N=P+1}if(U===-1)continue;return{start:s,end:K,arrayExpr:v,itemVar:W,foreachContent:k.substring(0,U),emptyContent:k.substring(U+6)}}return null}function ce(n,r){let l=n;while(!0){let e=xe(l);if(!e)break;let{start:o,end:i,arrayExpr:g,itemVar:x,foreachContent:b,emptyContent:p}=e;try{let s;if(f(g))s=d(g,Object.keys(r))(...Object.values(r));else s=u(g,r);let m;if(!Array.isArray(s)||s.length===0)m=p;else m=`@foreach (${g} as ${x})${b}@endforeach`;l=l.substring(0,o)+m+l.substring(i)}catch(s){let m=s instanceof Error?s.message:String(s),a=c("Forelse",`Error in @forelse(${g} as ${x}): ${m}`,t.EVALUATION_ERROR);l=l.substring(0,o)+a+l.substring(i)}}return l}var fe="<!--stx:foreach-not-iterable:",ye=/<!--stx:foreach-not-iterable:([^|>]*)\|([^>]*?)-->/g;function Ee(n,r){return`${fe}${encodeURIComponent(n)}|${encodeURIComponent(r)}-->`}function _e(n,r){console.warn(`[stx] @foreach(${n}) in ${r}: ${n} is not iterable server-side, so the loop rendered nothing. `+"Values a server loop reads must come from <script server> or the page context \u2014 "+"a plain <script> runs in the browser.")}function us(n){if(!n.includes(fe))return n;return n.replace(ye,(r,l,e)=>(_e(decodeURIComponent(l),decodeURIComponent(e)),""))}function or(n,r,l,e,o=!1){let i=n,g=new Set(r.__stx_client_signal_names||[]);for(let s of ir(n))g.add(s);if(g.size)r={...r,__stx_client_signal_names:[...g]};i=ce(i,r);function x(s){let m=/@foreach\s*\(/g,a;while((a=m.exec(s))!==null){let y=a.index,h=a.index+a[0].length-1,O=1,S=h+1,v=-1;while(S<s.length&&O>0){if(s[S]==="(")O++;else if(s[S]===")"){if(O--,O===0){v=S;break}}S++}if(v===-1)continue;let W=s.substring(h+1,v),F=Pt(W);if(!F)continue;let A=y,{arrayExpr:B,itemVar:D}=F,L=v+1,V=1,k=L,K=/@foreach\s*\(/g,U=/@endforeach/g;while(V>0&&k<s.length){K.lastIndex=k,U.lastIndex=k;let z=K.exec(s),N=U.exec(s);if(!N)break;if(z&&z.index<N.index)V++,k=z.index+z[0].length;else{if(V--,V===0){let P=s.substring(L,N.index),E=N.index+11;return{start:A,end:E,arrayExpr:B,itemVar:D,content:P}}k=N.index+11}}}return null}function b(s,m){let a=s;while(!0){let y=x(a);if(!y)break;let{start:h,end:O,arrayExpr:S,itemVar:v,content:W}=y;try{let F=S.trim(),A;if(f(F))A=d(F,Object.keys(m))(...Object.values(m));else A=u(F,m);let B=!1;if(!Array.isArray(A))if(A instanceof Map)A=Array.from(A),B=!0;else if(A instanceof Set)A=Array.from(A);else if(typeof A==="string")A=Array.from(A);else if(A&&typeof A==="object"&&!(A instanceof Date)&&!(A instanceof RegExp))A=Object.entries(A),B=!0;else{let E=Ee(F,l)+c("Foreach",`Error in @foreach: ${F} is not iterable`,t.TYPE_ERROR);a=a.substring(0,h)+E+a.substring(O);continue}let D=e?.loops?.useAltLoopVariable??pe,L=v.trim(),V=null,k,K=!1;if(L.includes("=>")){let E=L.split("=>").map((j)=>j.trim());if(E.length===2&&E[0]&&E[1])V=E[0],k=E[1];else k=L}else if(!L.startsWith("[")&&!L.startsWith("{")&&L.includes(",")){let E=L.split(",").map((j)=>j.trim());if(E.length===2&&E[0]&&E[1])k=E[0],V=E[1],K=!0;else k=L}else k=L;let U="",z=new Set(J(`${S} as ${v}`)),N=A,P=m[Ws]??new WeakMap;for(let E=0;E<N.length;E++){let j=N[E],te={index:E,iteration:E+1,first:E===0,last:E===N.length-1,count:N.length},M={...m,loop:te,$loop:te,[Ws]:P};if(Array.isArray(m.__stx_client_signal_names))M.__stx_client_signal_names=m.__stx_client_signal_names.filter((H)=>!z.has(H));if(k.startsWith("[")&&k.endsWith("]")){let H=k.slice(1,-1).split(",").map((T)=>T.trim());if(Array.isArray(j))H.forEach((T,X)=>{if(T)M[T]=j[X]});else M[k]=j}else if(k.startsWith("{")&&k.endsWith("}")){let H=k.slice(1,-1).split(",").map((T)=>T.trim()).filter(Boolean);if(j!==null&&typeof j==="object")H.forEach((T)=>{let X=T.indexOf(":"),Q=(X===-1?T:T.slice(0,X)).trim(),re=X===-1?Q:T.slice(X+1).trim();if(Q&&re)M[re]=j[Q]});else M[k]=j}else M[k]=j;if(V)if(!K&&B&&Array.isArray(j)&&j.length===2)M[V]=j[0],M[k]=j[1];else M[V]=E;let C=ce(W,M);C=or(C,M,l,e,!0),C=se(C,M,l),C=le(C,M);let q=C.indexOf(ee),G=C.indexOf(ne),Y=q<0?G:G<0?q:Math.min(q,G);if(Y>=0)C=C.slice(0,Y);if(C=_(C,M,l),C=be(C,M),C=me(C,M),C=he(C,M),U+=C,Y>=0&&Y===q)break}a=a.substring(0,h)+U+a.substring(O)}catch(F){let A=c("Foreach",`Error in @foreach(${S.trim()} as ${v.trim()}): ${F instanceof Error?F.message:String(F)}`,t.EVALUATION_ERROR);a=a.substring(0,h)+A+a.substring(O)}}return a}i=b(i,r),i=$e(i,r,l,e);let p=e?.loops?.maxWhileIterations??de;return i=we(i,r,p),o?i:us(i)}function Pf(n){let r=/^(\s*)([A-Za-z_$][\w$]*|\[[^\]]*\]|\{[^}]*\})(\s+(?:of|in)\s)/.exec(n);if(!r||/^(?:const|let|var)$/.test(r[2]))return n;return`${r[1]}let ${n.slice(r[1].length)}`}function ge(n){return qs(n)}function $e(n,r,l,e){let o=n,i=!0;while(i){i=!1;let g=o.match(/@for\s*\(/);if(!g||g.index===void 0)break;let x=g.index,b=x+g[0].length-1,p=w(o,"(",")",b);if(p===-1)break;let s=Pf(o.slice(b+1,p)),m=p+1,a=ys(o.slice(x),"for","endfor");if(a.length===0)break;let y=a[0].content,h=x+a[0].end;if(!ge(s)){let O=c("For",`Unsafe expression in @for: ${s}`,t.UNSAFE_EXPRESSION);o=o.substring(0,x)+O+o.substring(h),i=!0;continue}try{let O=Ae(s),S=/@(?:for|foreach|if|unless)\s*\(/.test(y);if(O.length>0&&S){let D=Re({forExpr:s,content:y,iterVarNames:O,context:r,filePath:l,options:e});o=o.substring(0,x)+D+o.substring(h),i=!0;continue}let v=Object.keys(r),W=Object.values(r),F=ae(y),B=Function(...v,"__stxRenderLoopValue",`
|
|
3
3
|
let result = '';
|
|
4
4
|
for (${s}) {
|
|
5
5
|
result += \`${F}\`;
|