@stacksjs/stx 0.2.915 → 0.2.917
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-dgt9kfkp.js → chunk-0asdv3hk.js} +1 -1
- package/dist/{chunk-z5nx021e.js → chunk-0atz8fjx.js} +1 -1
- package/dist/chunk-0fm6avxt.js +3 -0
- package/dist/{chunk-dp6r6gtb.js → chunk-0sj79ha5.js} +2 -2
- package/dist/{chunk-pmn9kynz.js → chunk-0v7555tr.js} +1 -1
- package/dist/{chunk-49980am3.js → chunk-11rnqey0.js} +1 -1
- package/dist/chunk-31yx4sjh.js +2 -0
- package/dist/{chunk-vnk582z7.js → chunk-388xpdw5.js} +31 -5
- package/dist/chunk-38kerh2r.js +2 -0
- package/dist/{chunk-4a9bqc8f.js → chunk-3h4db9yb.js} +3 -3
- package/dist/{chunk-man5ap64.js → chunk-43sgpy4e.js} +4 -4
- package/dist/{chunk-g44932zc.js → chunk-4pve3r5a.js} +1 -1
- package/dist/chunk-5d5dxts6.js +2 -0
- package/dist/{chunk-4w9pvpfd.js → chunk-5fdsyyfe.js} +1 -1
- package/dist/{chunk-5pb1x7x6.js → chunk-67yr4m5h.js} +1 -1
- package/dist/chunk-6aqr0e6s.js +2 -0
- package/dist/{chunk-xtf3sab5.js → chunk-6bw02d1t.js} +1 -1
- package/dist/{chunk-7gwysmrs.js → chunk-789yp1tg.js} +1 -1
- package/dist/{chunk-r1fhahnn.js → chunk-7ar11ccn.js} +1 -1
- package/dist/{chunk-cv6d4zr5.js → chunk-7fc0vrs5.js} +1 -1
- package/dist/{chunk-x1kzqxj5.js → chunk-82fg5gp6.js} +1 -1
- package/dist/chunk-89r7bbsk.js +2 -0
- package/dist/{chunk-7anbc757.js → chunk-8b8az19t.js} +4 -4
- package/dist/{chunk-n1y82svg.js → chunk-8x3yaahc.js} +1 -1
- package/dist/{chunk-n0nf8n0h.js → chunk-91p8p2cc.js} +2 -2
- package/dist/{chunk-bdkst2wp.js → chunk-9kn81bmp.js} +1 -1
- package/dist/{chunk-wz44vmgn.js → chunk-9w9y84t5.js} +2 -2
- package/dist/{chunk-4r0028av.js → chunk-b5qzed8y.js} +7 -7
- package/dist/chunk-bh2khcet.js +2 -0
- package/dist/{chunk-p9fyn5k4.js → chunk-bm6y085n.js} +1 -1
- package/dist/{chunk-etmq1qny.js → chunk-c13dv3wm.js} +1 -1
- package/dist/{chunk-1rfzs48h.js → chunk-c6096ssb.js} +1 -1
- package/dist/{chunk-t85zac4y.js → chunk-da05660m.js} +5 -5
- package/dist/{chunk-9xmx8hc7.js → chunk-dwt2drzf.js} +1 -1
- package/dist/{chunk-xj95sk0y.js → chunk-e0tvd7jj.js} +1 -1
- package/dist/{chunk-1jakr6f2.js → chunk-ezqfrea9.js} +1 -1
- package/dist/{chunk-5xbx0r3k.js → chunk-f0sxbgbm.js} +1 -1
- package/dist/{chunk-vq7m7xcz.js → chunk-fn1reean.js} +19 -19
- package/dist/{chunk-d1ka4dvr.js → chunk-h0aw9hmc.js} +2 -2
- package/dist/{chunk-eqdg72re.js → chunk-js1wayhb.js} +1 -1
- package/dist/chunk-k2t0w8z1.js +2 -0
- package/dist/{chunk-am7xmh9p.js → chunk-kcpxqsdj.js} +1 -1
- package/dist/{chunk-pcwq66w3.js → chunk-ma5ptt4m.js} +1 -1
- package/dist/{chunk-4w8t0a9e.js → chunk-mf5cqv1k.js} +2 -2
- package/dist/{chunk-47nzpbvm.js → chunk-mt5ewkbg.js} +2 -2
- package/dist/{chunk-zbpvmgjn.js → chunk-n4m50dpk.js} +5 -5
- package/dist/{chunk-9b2wdkbq.js → chunk-ngqb22wj.js} +8 -8
- package/dist/{chunk-whc4jptx.js → chunk-nwef47nx.js} +1 -1
- package/dist/{chunk-q9gbdzw0.js → chunk-p3x84jj0.js} +1 -1
- package/dist/chunk-p9bghe13.js +2 -0
- package/dist/chunk-q2cwzgd0.js +2 -0
- package/dist/{chunk-g0hkknzm.js → chunk-q60afqr7.js} +1 -1
- package/dist/chunk-s2c0ynn9.js +2 -0
- package/dist/{chunk-7x3tt27s.js → chunk-t65f98qv.js} +1 -1
- package/dist/{chunk-47z0m17p.js → chunk-v78hjbz0.js} +1 -1
- package/dist/{chunk-smnt37jq.js → chunk-w6ydg43d.js} +1 -1
- package/dist/{chunk-mdgcjzcn.js → chunk-wc10m4tp.js} +1 -1
- package/dist/{chunk-q85wy43m.js → chunk-wcxa8xy2.js} +1 -1
- package/dist/{chunk-wsfqb5jk.js → chunk-wgrj0cvs.js} +1 -1
- package/dist/{chunk-7qzanp9y.js → chunk-wj9bqkc0.js} +1 -1
- package/dist/{chunk-6t8ce21j.js → chunk-wm24jx3t.js} +1 -1
- package/dist/chunk-wpkwx3wq.js +2 -0
- package/dist/{chunk-1gj46s0g.js → chunk-wq17dce6.js} +1 -1
- package/dist/{chunk-yga49yw3.js → chunk-xjt5129x.js} +1 -1
- package/dist/{chunk-1p6gaaf3.js → chunk-yc3frw0z.js} +1 -1
- package/dist/{chunk-barb4gka.js → chunk-yq2krsc9.js} +1 -1
- package/dist/{chunk-zk5g49p5.js → chunk-ywrpmyzj.js} +1 -1
- package/dist/cli.js +7 -7
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/dev-server/ts-css.d.ts +1 -1
- package/dist/dev-server/ts-css.js +2 -2
- package/dist/native/compiler/html-to-ir.d.ts +3 -1
- package/dist/native/compiler/html-to-ir.js +30 -0
- package/dist/process.js +1 -1
- package/dist/pwa.js +1 -1
- package/dist/ssg.js +2 -2
- package/dist/types/config-types.d.ts +1 -0
- package/package.json +5 -5
- package/dist/chunk-490rrkrp.js +0 -2
- package/dist/chunk-6n50b07t.js +0 -2
- package/dist/chunk-g4w3wms2.js +0 -2
- package/dist/chunk-j3d3q3g7.js +0 -2
- package/dist/chunk-jmggm1ep.js +0 -3
- package/dist/chunk-m8mmasgc.js +0 -2
- package/dist/chunk-mjny8x91.js +0 -2
- package/dist/chunk-r4e17p2x.js +0 -2
- package/dist/chunk-rnsa5zz5.js +0 -2
- package/dist/chunk-sw5g5mbd.js +0 -2
- package/dist/chunk-t63y6qd5.js +0 -2
- package/dist/chunk-z9wwa50p.js +0 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-0jdz31q1.js";import"./chunk-4vz17ytv.js";import"./chunk-16sfjkc4.js";import"./chunk-phzhmnnm.js";import"./chunk-9928zdej.js";import"./chunk-
|
|
2
|
+
import"./chunk-0jdz31q1.js";import"./chunk-4vz17ytv.js";import"./chunk-16sfjkc4.js";import"./chunk-phzhmnnm.js";import"./chunk-9928zdej.js";import"./chunk-b5qzed8y.js";import"./chunk-w98yt4d4.js";import"./chunk-p3x84jj0.js";import"./chunk-2vx2ben8.js";import"./chunk-w6ydg43d.js";import{l}from"./chunk-4e18r89n.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{Ln,z}from"./chunk-w98yt4d4.js";import m from"fs";import e from"path";async function Dn(r,o,i){if(r.__stx_runtime_config)return;let n=Ln();if(n||i){r.__stx_runtime_config=n??z(i);return}let t=e.dirname(e.resolve(o));while(!0){if(["stx.config.ts","stx.config.js",".config/stx.config.ts",".config/stx.config.js"].some((f)=>m.existsSync(e.join(t,f)))){let{loadStxConfig:f}=await import("./chunk-
|
|
2
|
+
import{Ln,z}from"./chunk-w98yt4d4.js";import m from"fs";import e from"path";async function Dn(r,o,i){if(r.__stx_runtime_config)return;let n=Ln();if(n||i){r.__stx_runtime_config=n??z(i);return}let t=e.dirname(e.resolve(o));while(!0){if(["stx.config.ts","stx.config.js",".config/stx.config.ts",".config/stx.config.js"].some((f)=>m.existsSync(e.join(t,f)))){let{loadStxConfig:f}=await import("./chunk-82fg5gp6.js"),c=await f(t);if(c.runtimeConfig)r.__stx_runtime_config=z(c.runtimeConfig);return}let s=e.dirname(t);if(s===t)return;t=s}}async function Ji(r,o){function i(n){if(n===null)return"null";if(Array.isArray(n))return`Array<${n.length?[...new Set(n.map(i))].join(" | "):"unknown"}>`;if(typeof n==="object")return`{ ${Object.entries(n).map(([t,s])=>`readonly ${JSON.stringify(t)}: ${i(s)}`).join("; ")} }`;return typeof n}await Bun.write(e.join(r,".stx/runtime-config.d.ts"),`import '@stacksjs/stx/runtime-config'
|
|
3
3
|
declare module '@stacksjs/stx/runtime-config' { interface PublicRuntimeConfig ${i(o.public??{})} }
|
|
4
4
|
`),await Bun.write(e.join(r,".stx/runtime-config-server.d.ts"),`import '@stacksjs/stx/runtime-config-server'
|
|
5
5
|
declare module '@stacksjs/stx/runtime-config-server' { interface PrivateRuntimeConfig ${i(o.private??{})} }
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Pm}from"./chunk-yc3frw0z.js";import"./chunk-3h4db9yb.js";import"./chunk-f0sxbgbm.js";import"./chunk-0sj79ha5.js";import"./chunk-0fm6avxt.js";import"./chunk-8b8az19t.js";import"./chunk-mf5cqv1k.js";import"./chunk-w6ydg43d.js";import"./chunk-2vx2ben8.js";import"./chunk-jr2r2nh5.js";import"./chunk-xnp031ba.js";import"./chunk-388xpdw5.js";import"./chunk-b5qzed8y.js";import"./chunk-p3x84jj0.js";import"./chunk-w98yt4d4.js";import"./chunk-4vz17ytv.js";import"./chunk-phzhmnnm.js";import"./chunk-9928zdej.js";import"./chunk-0jdz31q1.js";import"./chunk-16sfjkc4.js";export{Pm as startProductionServer};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ma,Mm,jo,Dm,bu,wu,Lm,jm}from"./chunk-c13dv3wm.js";import"./chunk-wc10m4tp.js";import"./chunk-0atz8fjx.js";import"./chunk-0sj79ha5.js";import"./chunk-cwcmmgvz.js";import"./chunk-9w9y84t5.js";import"./chunk-8b8az19t.js";import"./chunk-nhyv3w4r.js";import"./chunk-0adc8x2h.js";import"./chunk-mf5cqv1k.js";import"./chunk-w6ydg43d.js";import"./chunk-2vx2ben8.js";import"./chunk-jr2r2nh5.js";import"./chunk-xnp031ba.js";import"./chunk-388xpdw5.js";import{_e,so}from"./chunk-b5qzed8y.js";import"./chunk-p3x84jj0.js";import"./chunk-w98yt4d4.js";import"./chunk-4vz17ytv.js";import"./chunk-phzhmnnm.js";import"./chunk-9928zdej.js";import"./chunk-0jdz31q1.js";import"./chunk-16sfjkc4.js";export{Ma as buildScriptVirtualFile,Mm as buildVirtualSource,_e as extractScriptBlocks,so as extractTemplateExpressions,bu as findRuntimeTypeDeclarations,wu as findStxModuleDeclarations,jm as formatTypecheckDiagnostics,Dm as sourcePathFor,Lm as typecheckStxFiles,jo as virtualPathFor};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ug,Dc,ly,Lc,dg,pg,Sn,xr,uy,fg,gg,dy,S}from"./chunk-
|
|
2
|
+
import{ug,Dc,ly,Lc,dg,pg,Sn,xr,uy,fg,gg,dy,S}from"./chunk-ngqb22wj.js";import"./chunk-t65f98qv.js";import"./chunk-b5qzed8y.js";import"./chunk-p3x84jj0.js";import"./chunk-w98yt4d4.js";import"./chunk-4vz17ytv.js";import"./chunk-phzhmnnm.js";import"./chunk-9928zdej.js";import"./chunk-0jdz31q1.js";import"./chunk-16sfjkc4.js";export{Sn as buildCss,fg as extractClassNames,pg as fingerprintConfig,gg as generateCss,uy as getCachedCSS,ug as getCssServeAsset,S as injectCss,Dc as loadCssEngine,Lc as loadCssEngineConfig,xr as rebuildCss,ly as resetCssCache,dg as resolveUserCssConfig,dy as withLinkedModuleBundles};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Is,yg,ui,bg}from"./chunk-bm6y085n.js";import"./chunk-9tv0tw7f.js";import"./chunk-9w9y84t5.js";import"./chunk-8b8az19t.js";import"./chunk-nhyv3w4r.js";import"./chunk-mf5cqv1k.js";import"./chunk-w6ydg43d.js";import"./chunk-2vx2ben8.js";import"./chunk-jr2r2nh5.js";import"./chunk-xnp031ba.js";import"./chunk-388xpdw5.js";import{Wt}from"./chunk-b5qzed8y.js";import"./chunk-p3x84jj0.js";import"./chunk-w98yt4d4.js";import"./chunk-4vz17ytv.js";import"./chunk-phzhmnnm.js";import"./chunk-9928zdej.js";import"./chunk-0jdz31q1.js";import"./chunk-16sfjkc4.js";export{bg as declareBareLoopHead,Wt as parseLoopBinding,yg as processLoops,ui as processLoopsAsync,Is as reportDeferredLoopWarnings};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{cl,s,Ce}from"./chunk-
|
|
2
|
+
import{cl,s,Ce}from"./chunk-b5qzed8y.js";import{gt}from"./chunk-zkwkhesc.js";import{l}from"./chunk-4e18r89n.js";import o from"fs";import u from"path";var xg=new Map,m=new Map;async function wy(e){let n;for(let i=0;i<3;i++)try{let g=(await o.promises.stat(e)).mtime.getTime(),a=m.get(e);if(a&&a.mtime===g)return a.content;let h=await Bun.file(e).text(),w=(await o.promises.stat(e)).mtime.getTime();if(w!==g)continue;return m.set(e,{content:h,mtime:w}),h}catch(r){n=r;break}throw m.delete(e),Error(`File not found: ${e}${n?` (${n.message})`:""}`)}function vy(e){m.delete(e)}function xy(e){for(let t of m.keys())if(t.startsWith(e))m.delete(t)}var f=null,B=null,x=null;function Sy(e){x=e}async function Sg(e=!1){let t=x??await import("./chunk-94qc4zwb.js");if(e)return t.generateSignalsRuntimeDev();if(f===null)f=t.generateSignalsRuntime();return f}var S=null;async function kg(){if(S===null){let{getRouterScript:e}=await import("./chunk-11rnqey0.js");S=e()}return S}var y={};async function ky(e,t=!1){let n=e==="runtime"?await Sg(t):await kg(),i=e==="runtime"&&t?"runtime-debug":e,r=y[i];if(!r||r.content!==n)r={content:n,hash:Bun.hash(n).toString(16).padStart(16,"0").slice(0,16)},y[i]=r;return{content:n,hash:r.hash,url:`/_stx/${e}.${r.hash}.js`}}var E=500,T=33554432,c=new Map,p=0;function C(e){return l(process.cwd(),"module-bundles",`${e}.js`)}function _y(e){let t=Bun.hash(e).toString(16).padStart(16,"0").slice(0,16),n=c.get(t),i=n!==void 0;if(i)c.delete(t),p-=n.length*2;c.set(t,e),p+=e.length*2;while(c.size>1&&(c.size>E||p>T)){let r=c.keys().next().value;p-=c.get(r).length*2,c.delete(r)}if(!i)try{let r=C(t);if(!o.existsSync(r))o.mkdirSync(u.dirname(r),{recursive:!0}),o.writeFileSync(r,e)}catch{}return`/_stx/modules.${t}.js`}function wi(e){if(!/^[0-9a-f]{16}$/.test(e))return;let t=c.get(e);if(t!==void 0)return t;try{return o.readFileSync(C(e),"utf8")}catch{return}}function Cy(){m.clear(),Ce(),cl(),f=null,B=null,S=null}function v(e){let t={debug:e.debug===!0,middleware:(e.middleware??[]).map((n)=>({name:n.name,timing:n.timing,handler:String(n.handler)})),customDirectives:(e.customDirectives??[]).map((n)=>({name:n.name,hasEndTag:n.hasEndTag===!0,rawParams:n.rawParams===!0,handler:String(n.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(t)).digest("hex")}async function Er(e,t){try{if(!t.cachePath)return null;let n=u.resolve(t.cachePath),i=u.join(n,`${Bs(e)}.html`),r=u.join(n,`${Bs(e)}.meta.json`);if(!await s(i)||!await s(r))return null;let g=await Bun.file(r).text(),a=JSON.parse(g);if(a.cacheVersion!==t.cacheVersion)return null;if(a.engine!==gt())return null;if(a.optionsSignature!==v(t))return null;if((await o.promises.stat(e)).mtime.getTime()>a.mtime)return null;for(let d of a.dependencies)if(await s(d)){if((await o.promises.stat(d)).mtime.getTime()>a.mtime)return null}else return null;return await Bun.file(i).text()}catch(n){return console.warn(`Cache error for ${e}:`,n),null}}async function Tr(e,t,n,i){try{if(!i.cachePath)return;let r=u.resolve(i.cachePath);await o.promises.mkdir(r,{recursive:!0});let g=u.join(r,`${Bs(e)}.html`),a=u.join(r,`${Bs(e)}.meta.json`),h=await o.promises.stat(e);await Bun.write(g,t);let d={sourcePath:e,mtime:h.mtime.getTime(),dependencies:Array.from(n),cacheVersion:i.cacheVersion,engine:gt(),optionsSignature:v(i),generatedAt:Date.now()};await Bun.write(a,JSON.stringify(d,null,2)),xg.set(e,{output:t,mtime:h.mtime.getTime(),dependencies:n})}catch(r){console.warn(`Failed to cache template ${e}:`,r)}}var _=16;function Bs(e){return new Bun.CryptoHasher("sha1").update(e).digest("hex").substring(0,_)}
|
|
3
3
|
export{xg,wy,vy,xy,Sy,Sg,kg,ky,_y,wi,Cy,Er,Tr,Bs};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{P}from"./chunk-
|
|
2
|
+
import{P}from"./chunk-b5qzed8y.js";import{i}from"./chunk-n4m50dpk.js";import p from"fs";import g from"path";import*as y from"readline";var e={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},u={help:{description:"Show available commands",usage:"help [command]",handler:async(t,o)=>{if(t[0]&&u[t[0]]){let n=u[t[0]];console.log(`
|
|
3
3
|
${e.bold}${t[0]}${e.reset} - ${n.description}`),console.log(` Usage: ${e.cyan}${n.usage}${e.reset}
|
|
4
4
|
`)}else{console.log(`
|
|
5
5
|
${e.bold}Available Commands:${e.reset}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{M,n,u}from"./chunk-4vz17ytv.js";import{ae}from"./chunk-
|
|
2
|
+
import{M,n,u}from"./chunk-4vz17ytv.js";import{ae}from"./chunk-b5qzed8y.js";import{xi}from"./chunk-2vx2ben8.js";import E from"path";var S;async function W(){if(S!==void 0)return S;try{let e=await import("@stacksjs/ts-i18n");S=e.loadLocale??null}catch{S=null}return S}var T={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},v={},L={},k={};function J(e,s=0){if(s<=0)return!1;return Date.now()-e.loadedAt>s}async function G(e,s){if({...T,...s.i18n}.cache&&v[e]){let t=v[e],o=s.i18n?.cacheMaxAge??0;if(!J(t,o))return t.translations}if(L[e]?.state==="loading")return L[e].promise;k[e]="loading";let r=C(e,s).then((t)=>(k[e]="loaded",delete L[e],t)).catch((t)=>{throw k[e]="error",L[e]={promise:r,state:"error",error:t instanceof Error?t:Error(String(t))},t});return L[e]={promise:r,state:"loading"},r}async function C(e,s){let i={...T,...s.i18n},r=E.isAbsolute(i.translationsDir)?i.translationsDir:E.resolve(s.root||process.cwd(),i.translationsDir);try{let t=await W(),o=t?await t(e,{translationsDir:r,defaultLocale:i.defaultLocale,sources:ee(i.format)}):await Y(e,i,r);if(o===void 0){let c=e!==i.defaultLocale?await C(i.defaultLocale,s):{};if(i.cache)v[e]={translations:c,loadedAt:Date.now(),locale:e};return c}let l=o;if(i.cache)v[e]={translations:l,loadedAt:Date.now(),locale:e};return l}catch(t){if(s.debug)console.error(`Error loading translation file for locale "${e}":`,t);if(e!==i.defaultLocale)return C(i.defaultLocale,s);return{}}}async function Y(e,s,i){let r=E.join(i,`${e}${Z(s.format)}`);try{let t=await import(r);return t.default||t}catch(t){try{let o=await Bun.file(r).text();if(s.format==="yaml"||s.format==="yml")return Q(o);if(s.format==="json")return JSON.parse(o);throw t}catch{return}}}function Z(e){switch(e){case"yaml":return".yaml";case"yml":return".yml";case"js":return".js";case"ts":return".ts";case"json":default:return".json"}}function Q(e){let s={},i=e.split(`
|
|
3
3
|
`),r=[{obj:s,indent:-1}];for(let t of i){let o=t.replace(/#.*$/,"").trimEnd();if(!o.trim())continue;let l=o.search(/\S/);if(l===-1)continue;while(r.length>1&&r[r.length-1].indent>=l)r.pop();let c=r[r.length-1].obj,a=o.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(a){let[,,g,p]=a,f=g.trim(),m=p.trim();if(m==="")c[f]={},r.push({obj:c[f],indent:l});else c[f]=X(m)}}return s}function X(e){if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1);let s=e.toLowerCase();if(s==="true"||s==="yes")return!0;if(s==="false"||s==="no")return!1;if(s==="null"||s==="~")return null;let i=Number(e);if(!Number.isNaN(i)&&e!=="")return i;return e}function ee(e){switch(e){case"yaml":case"yml":return["yaml"];case"js":case"ts":return["ts"];case"json":default:return["json"]}}async function te(e,s){return G(e,s)}function re(e,s){for(let i of e){let r=i.trim(),t=r.match(/^\{(\d+)\}\s*(.*)$/);if(t){let l=Number.parseInt(t[1],10);if(s===l)return t[2];continue}let o=r.match(/^\[(\d+),(\d+|\*)\]\s*(.*)$/);if(o){let l=Number.parseInt(o[1],10),c=o[2]==="*"?Number.POSITIVE_INFINITY:Number.parseInt(o[2],10);if(s>=l&&s<=c)return o[3];continue}}if(e.length===2)return s===1?e[0].trim():e[1].trim();if(s<e.length)return e[s].trim();return e[e.length-1].trim()}function ne(e,s={}){return j(e,s)}function j(e,s){let i="",r=0;while(r<e.length)if(e[r]==="{"){let t=ie(e,r);if(t===-1){i+=e[r],r++;continue}let o=e.slice(r+1,t);i+=se(o,s),r=t+1}else if(e[r]==="'"&&r+1<e.length)if(e[r+1]==="'")i+="'",r+=2;else if(e[r+1]==="{"||e[r+1]==="}")i+=e[r+1],r+=2;else i+=e[r],r++;else i+=e[r],r++;return i}function ie(e,s){let i=0;for(let r=s;r<e.length;r++)if(e[r]==="{")i++;else if(e[r]==="}"){if(i--,i===0)return r}return-1}function se(e,s){let i=oe(e);if(i.length===0)return`{${e}}`;let r=i[0].trim(),t=s[r];if(i.length===1)return t!==void 0?String(t):`{${r}}`;switch(i[1].trim().toLowerCase()){case"plural":return le(t,i.slice(2).join(","),s);case"select":return ue(t,i.slice(2).join(","));case"selectordinal":return de(t,i.slice(2).join(","));case"number":return pe(t,i[2]?.trim());case"date":return fe(t,i[2]?.trim());case"time":return me(t,i[2]?.trim());default:return t!==void 0?String(t):`{${e}}`}}function oe(e){let s=[],i="",r=0;for(let t=0;t<e.length;t++){let o=e[t];if(o==="{")r++,i+=o;else if(o==="}")r--,i+=o;else if(o===","&&r===0)s.push(i),i="";else i+=o}if(i)s.push(i);return s}function le(e,s,i){let r=Number(e)||0,t=P(s),o=`=${r}`;if(t[o])return R(t[o],r,i);let l=ce(r);if(t[l])return R(t[l],r,i);if(t.other)return R(t.other,r,i);return String(r)}function R(e,s,i){let r=e.replace(/#/g,String(s));return j(r,i)}function ce(e){let s=Math.abs(e),i=Math.floor(s),r=String(e).includes(".")?String(e).split(".")[1].length:0;if(i===1&&r===0)return"one";return"other"}function ue(e,s){let i=String(e||""),r=P(s);if(r[i])return r[i];return r.other||String(e)}function de(e,s){let i=Number(e)||0,r=P(s),t=ge(i);if(r[t])return r[t].replace(/#/g,String(i));if(r.other)return r.other.replace(/#/g,String(i));return String(i)}function ge(e){let s=Math.abs(e),i=s%10,r=s%100;if(i===1&&r!==11)return"one";if(i===2&&r!==12)return"two";if(i===3&&r!==13)return"few";return"other"}function P(e){let s={},i=/(\w+|=\d+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,r=i.exec(e);while(r!==null)s[r[1]]=r[2],r=i.exec(e);return s}function pe(e,s){let i=Number(e);if(Number.isNaN(i))return String(e);switch(s){case"integer":return Math.floor(i).toLocaleString();case"percent":return`${(i*100).toFixed(0)}%`;case"currency":return i.toLocaleString(void 0,{style:"currency",currency:"USD"});default:return i.toLocaleString()}}function fe(e,s){let i=e instanceof Date?e:new Date(String(e));if(Number.isNaN(i.getTime()))return String(e);let r={};switch(s){case"short":r.dateStyle="short";break;case"medium":r.dateStyle="medium";break;case"long":r.dateStyle="long";break;case"full":r.dateStyle="full";break;default:r.dateStyle="medium"}return i.toLocaleDateString(void 0,r)}function me(e,s){let i=e instanceof Date?e:new Date(String(e));if(Number.isNaN(i.getTime()))return String(e);let r={};switch(s){case"short":r.timeStyle="short";break;case"medium":r.timeStyle="medium";break;case"long":r.timeStyle="long";break;case"full":r.timeStyle="full";break;default:r.timeStyle="short"}return i.toLocaleTimeString(void 0,r)}function be(e){return/\{[^}]+,\s*(?:plural|select|selectordinal|number|date|time)\s*,/.test(e)}function O(e,s,i=!0,r={}){let t=e.split("."),o=s;for(let c of t){if(o===void 0||o===null)break;o=o[c]}if(o===void 0||o===null)return i?e:"";let l=String(o);if(be(l))return ne(l,r);if(l.includes("|")&&"count"in r){let c=Number(r.count),a=l.split("|");l=re(a,c)}for(let[c,a]of Object.entries(r)){let g=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");l=l.replace(new RegExp(`:${g}`,"g"),()=>String(a))}return l}var D=new Set(["ar","arc","ckb","dv","fa","he","khw","ks","nqo","prs","ps","sd","syr","ug","ur","uz-af","yi"]),he=new Set(["adlm","arab","aran","hebr","nkoo","rohg","syrc","thaa","yezi"]);function q(e){if(!e)return"ltr";let s=e.trim().toLowerCase().replace(/_/g,"-").split("-"),i=s[0];if(!i)return"ltr";let r=s[1]?.length===4?s[1]:void 0;if(r)return he.has(r)?"rtl":"ltr";if(s.length>1&&D.has(`${i}-${s[1]}`))return"rtl";return D.has(i)?"rtl":"ltr"}async function Xc(e,s,i,r){let t=e,o=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)([\s\S]*?)@endtranslate/g,l={...T,...r.i18n},c=await te(l.locale,r);s.__translations=c,s.__locale=l.locale,s.__i18nConfig=l,t=await F(t,o,async(p,f,m,w,h)=>{try{let b={};if(m)try{let d=[()=>JSON.parse(m),()=>{let x=`{"data":${m}}`,A=JSON.parse(x);return typeof A.data==="object"?A.data:{}},()=>M(m,s)];for(let x of d)try{if(b=x(),Object.keys(b).length>0)break}catch{}}catch(d){if(r.debug)console.error("Error parsing parameters for @translate directive:",d)}let y=O(f,c,l.fallbackToKey,b);return y?ae(t,h,y,!1,p.length):w.trim()}catch(b){if(r.debug)console.error("Error processing @translate directive:",b);return u("Translate",`Error in @translate('${f}'): ${b instanceof Error?b.message:String(b)}`,n.EVALUATION_ERROR)}});let a=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]+\})\s*)?\)/g;if(r.debug){console.warn(`Processing translations in template. Sections: ${t.includes("<h2>Translation with Parameters</h2>")?"Parameters section found":"Parameters section missing"}`);let p=[...t.matchAll(a)];console.warn(`Found ${p.length} @translate matches`),p.forEach((f,m)=>console.warn(`Match ${m}: ${f[0]}, Key: ${f[1]}, Params: ${f[2]||"none"}`))}return t=await F(t,/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)/g,async(p,f,m,w)=>{try{let h={};if(m)try{let b=[()=>JSON.parse(m),()=>{let y=`{"data":${m}}`,d=JSON.parse(y);return typeof d.data==="object"?d.data:{}},()=>M(m,s)];for(let y of b)try{if(h=y(),Object.keys(h).length>0)break}catch{}}catch(b){if(r.debug)console.error("Error parsing parameters for @translate directive:",b)}return ae(t,w,O(f,c,l.fallbackToKey,h),!1,p.length)}catch(h){if(r.debug)console.error("Error processing @translate directive:",h);return u("Translate",`Error in @translate('${f}'): ${h instanceof Error?h.message:String(h)}`,n.EVALUATION_ERROR)}}),t}async function F(e,s,i){let r=[];return e.replace(s,(o,...l)=>{let c=i(o,...l).then((a)=>({match:o,replacement:a}));return r.push(c),o}),(await Promise.all(r)).reduce((o,{match:l,replacement:c})=>o.replace(l,()=>c),e)}function _(e,s){if(!e||q(e)!=="rtl")return!1;return!s||s.trim().toLowerCase()!=="rtl"}function V(e){if(!e)return!1;return e.trim().split(/\s+/)[0]?.toLowerCase()==="presentation"||e.trim().split(/\s+/)[0]?.toLowerCase()==="none"}function I(e,s){let i=new RegExp(`\\b${s}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i").exec(e);if(!i)return null;return i[2]??i[3]??i[4]??null}function Gc(e,s,i,r){let t=e;t=t.replace(/@a11y\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(l,c,a)=>{let p={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[c]||"Make this element accessible";return`<!-- a11y-hint: ${a||p} -->`});let o=/@screenReader\(([^@]*)\)@endScreenReader/g;return t=t.replace(o,(l,c)=>`<span class="sr-only">${c.trim()}</span>`),t=t.replace(/@ariaDescribe\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(l,c,a)=>`<span id="${`desc-${c}`}" class="sr-only">${a}</span>`),t}function ye(){return typeof globalThis.document<"u"&&typeof globalThis.document.createElement==="function"}function xe(e){let s=new Map,i=e.replace(/<(\/?)([A-Z][\w:.-]*)(?=[\s/>])/g,(t,o,l)=>{let c=s.get(l);if(!c)c=`stx-a11y-component-${s.size}`,s.set(l,c);return`<${o}${c}`}),r=new Map([...s.entries()].map(([t,o])=>[o,t]));return{protectedSource:i,restore:(t)=>t.replace(/<(\/?)(stx-a11y-component-\d+)(?=[\s/>])/g,(o,l,c)=>{let a=r.get(c);return a?`<${l}${a}`:o})}}function we(e,s){let i=[],r=/<img\s+([^>]*)>/gi,t;t=r.exec(e);while(t!==null){let d=t[1];if(!/\balt\s*=/i.test(d))i.push({type:"missing-alt",element:t[0].substring(0,100),message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"});t=r.exec(e)}let o=/<button([^>]*)>\s*<\/button>/gi;t=o.exec(e);while(t!==null){let d=t[1];if(!/\baria-label\s*=/i.test(d)&&!/\btitle\s*=/i.test(d))i.push({type:"missing-accessible-name",element:t[0].substring(0,100),message:"Empty button missing accessible name",impact:"critical",help:"Add text content, aria-label, or title",helpUrl:"https://web.dev/learn/accessibility/aria-html/"});t=o.exec(e)}let l=/<a\s+([^>]*)>\s*<\/a>/gi;t=l.exec(e);while(t!==null){let d=t[1];if(!/\baria-label\s*=/i.test(d)&&!/\btitle\s*=/i.test(d))i.push({type:"link-missing-text",element:t[0].substring(0,100),message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"});t=l.exec(e)}let c=/<(input|select|textarea)\s+([^>]*)>/gi;t=c.exec(e);while(t!==null){let d=t[2];if(/\btype\s*=\s*["']hidden["']/i.test(d)){t=c.exec(e);continue}let x=/\baria-label\s*=/i.test(d)||/\baria-labelledby\s*=/i.test(d),A=d.match(/\bid\s*=\s*["']([^"']+)["']/i);if(!x){let B=A&&new RegExp(`<label[^>]*\\bfor\\s*=\\s*["']${A[1]}["']`,"i").test(e),U=t.index,N=e.substring(0,U),Se=e.substring(U),H=(N.match(/<label\b/gi)||[]).length,z=(N.match(/<\/label>/gi)||[]).length,K=H>z;if(!B&&!K)i.push({type:"input-missing-label",element:t[0].substring(0,100),message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})}t=c.exec(e)}let a=/<h([1-6])[^>]*>/gi,g=[];t=a.exec(e);while(t!==null)g.push(Number.parseInt(t[1],10)),t=a.exec(e);let p=0;for(let d of g){if(p>0&&d>p+1)i.push({type:"heading-skip",element:`<h${d}>`,message:`Heading level skipped from h${p} to h${d}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});p=d}if(/<html\b/i.test(e)&&!/<html[^>]*\slang\s*=/i.test(e))i.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});let f=e.match(/<html\b([^>]*)>/i);if(f&&_(I(f[1],"lang"),I(f[1],"dir")))i.push({type:"missing-dir",element:f[0].substring(0,100),message:'Document language is right-to-left but dir="rtl" is not set',impact:"serious",help:'Add dir="rtl" to the html element so the layout mirrors the text',helpUrl:"https://www.w3.org/International/questions/qa-html-dir"});let m=/<table([^>]*)>([\s\S]*?)<\/table>/gi;t=m.exec(e);while(t!==null){let d=t[2];if(!V(I(t[1],"role"))&&!/<th\b/i.test(d))i.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});t=m.exec(e)}let w=/<(video|audio)[^>]*\sautoplay\s[^>]*>/gi;t=w.exec(e);while(t!==null){if(!/\bmuted\b/i.test(t[0]))i.push({type:"autoplay-audio",element:`<${t[1]}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"});t=w.exec(e)}let h=/\btabindex\s*=\s*["']([1-9]\d*)["']/gi;t=h.exec(e);while(t!==null)i.push({type:"positive-tabindex",element:`tabindex="${t[1]}"`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"}),t=h.exec(e);let b=/<iframe\s+([^>]*)>/gi;t=b.exec(e);while(t!==null){let d=t[1];if(!/\btitle\s*=/i.test(d)&&!/\baria-label\s*=/i.test(d))i.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"});t=b.exec(e)}let y=/<([a-z]+)\s+([^>]*role\s*=\s*["']button["'][^>]*)>/gi;t=y.exec(e);while(t!==null){let d=t[1].toLowerCase(),x=t[2];if(d!=="button"&&!/\btabindex\s*=/i.test(x))i.push({type:"button-not-focusable",element:t[0].substring(0,100),message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"});t=y.exec(e)}return i}async function Ae(e,s){let{protectedSource:i}=xe(e);if(!ye())return we(i,s);let r=[];try{let t=globalThis.document.createElement("div");t.innerHTML=i,t.querySelectorAll("img").forEach((a)=>{if(!a.hasAttribute("alt"))r.push({type:"missing-alt",element:`<${a.outerHTML}>`,message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"})}),t.querySelectorAll('button, a, [role="button"]').forEach((a)=>{if(!(a.hasAttribute("aria-label")||a.hasAttribute("aria-labelledby")||a.textContent&&a.textContent.trim().length>0))r.push({type:"missing-accessible-name",element:`<${a.outerHTML}>`,message:"Interactive element missing accessible name",impact:"critical",help:"Add text content, aria-label, or aria-labelledby",helpUrl:"https://web.dev/learn/accessibility/aria-html/"})}),t.querySelectorAll("input, select, textarea").forEach((a)=>{let g=a.getAttribute("id"),p=g&&t.querySelector(`label[for="${g}"]`),f=a.hasAttribute("aria-label")||a.hasAttribute("aria-labelledby"),m=a.closest("label")!==null;if(!p&&!f&&!m)r.push({type:"input-missing-label",element:`<${a.outerHTML}>`,message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})});let o=Array.from(t.querySelectorAll("h1, h2, h3, h4, h5, h6")),l=0;for(let a of o){let g=Number.parseInt(a.tagName.charAt(1));if(l>0&&g>l+1)r.push({type:"heading-skip",element:`<${a.outerHTML}>`,message:`Heading level skipped from h${l} to h${g}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});l=g}let c=t.querySelector("html");if(i.includes("<html")&&c&&!c.hasAttribute("lang"))r.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});if(c&&_(c.getAttribute("lang"),c.getAttribute("dir")))r.push({type:"missing-dir",element:"<html>",message:'Document language is right-to-left but dir="rtl" is not set',impact:"serious",help:'Add dir="rtl" to the html element so the layout mirrors the text',helpUrl:"https://www.w3.org/International/questions/qa-html-dir"});if(t.querySelectorAll("a").forEach((a)=>{let g=a.textContent&&a.textContent.trim().length>0,p=a.hasAttribute("aria-label")||a.hasAttribute("aria-labelledby"),f=a.hasAttribute("title"),m=a.querySelector("img[alt]");if(!g&&!p&&!f&&!m)r.push({type:"link-missing-text",element:`<${a.outerHTML}>`,message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"})}),i.includes("<nav")||i.includes("<header")){if(!t.querySelector('a[href="#main"], a[href="#content"], .skip-link, [class*="skip"]')&&t.querySelectorAll("a").length>5)r.push({type:"missing-skip-link",element:"<nav>",message:"Consider adding a skip navigation link",impact:"minor",help:"Add a skip link to allow keyboard users to bypass navigation",helpUrl:"https://web.dev/learn/accessibility/focus/#skip-links"})}if(t.querySelectorAll("table").forEach((a)=>{if(V(a.getAttribute("role")))return;let g=a.querySelector("caption");if(!a.querySelector("th"))r.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});if(!g&&!a.hasAttribute("aria-label")&&!a.hasAttribute("aria-labelledby"))r.push({type:"table-missing-caption",element:"<table>",message:"Table missing caption or accessible name",impact:"minor",help:"Add a caption element or aria-label to describe the table",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"})}),t.querySelectorAll('[style*="color"]').forEach((a)=>{let g=a.getAttribute("style")||"";if(g.includes("color:")&&!g.includes("background"))r.push({type:"potential-contrast-issue",element:`<${a.tagName.toLowerCase()}>`,message:"Element has inline color style - verify contrast ratio",impact:"minor",help:"Ensure text has sufficient contrast ratio (4.5:1 for normal text)",helpUrl:"https://web.dev/learn/accessibility/color-contrast/"})}),t.querySelectorAll("video[autoplay], audio[autoplay]").forEach((a)=>{if(!a.hasAttribute("muted"))r.push({type:"autoplay-audio",element:`<${a.tagName.toLowerCase()}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"})}),t.querySelectorAll("[tabindex]").forEach((a)=>{if(Number.parseInt(a.getAttribute("tabindex")||"0")>0)r.push({type:"positive-tabindex",element:`<${a.tagName.toLowerCase()}>`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"})}),t.querySelectorAll('[role="button"]').forEach((a)=>{if(!a.hasAttribute("tabindex"))r.push({type:"button-not-focusable",element:`<${a.outerHTML}>`,message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"})}),i.includes("<body")&&!t.querySelector('main, [role="main"]'))r.push({type:"missing-main-landmark",element:"<body>",message:"Document missing main landmark region",impact:"moderate",help:"Add a main element to identify the primary content",helpUrl:"https://web.dev/learn/accessibility/structure/#landmarks"});t.querySelectorAll("iframe").forEach((a)=>{if(!a.hasAttribute("title")&&!a.hasAttribute("aria-label"))r.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"})})}catch(t){console.error(`Error checking accessibility in ${s}:`,t)}return r}async function Jc(e,s={}){let i={},{recursive:r=!0,ignorePaths:t=[]}=s,o=Array.isArray(e)?e:[e],l=await xi(o,{recursive:r,ignorePaths:t}),c=[];for(let a of l)try{let g=await Bun.file(a).text();if(a.endsWith("good-a11y.stx"))continue;let p=await Ae(g,a);if(c.push(a),p.length>0)i[a]=p}catch(g){console.error(`Error scanning ${a}:`,g)}return{results:i,scannedFiles:c}}var Yc={name:"a11y",handler:(e,s,i,r)=>{if(!s.length)return e;let t=s[0].replace(/['"]/g,""),o=s.length>1?s[1].replace(/['"]/g,""):"",c={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[t]||"Make this element accessible";return`<!-- a11y-hint: ${o||c} -->${e}`},hasEndTag:!1},Zc={name:"screenReader",handler:(e)=>`<span class="sr-only">${e}</span>`,hasEndTag:!0};
|
|
4
4
|
export{Xc,Gc,Jc,Yc,Zc};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{k,E,A,ee,O,so,ie}from"./chunk-
|
|
2
|
+
import{k,E,A,ee,O,so,ie}from"./chunk-b5qzed8y.js";import{je}from"./chunk-9928zdej.js";import{Z}from"./chunk-0adc8x2h.js";import{C}from"./chunk-16sfjkc4.js";import{D,zn}from"./chunk-phzhmnnm.js";import{a}from"./chunk-mf5cqv1k.js";import{$e,yn,bn,wn}from"./chunk-0atz8fjx.js";import{Ot}from"./chunk-9w9y84t5.js";import{Rt,sr,un,ve}from"./chunk-jz37h2z0.js";import{I,rt}from"./chunk-e5rag6rh.js";import w from"path";var x=new Map,P=new Map,R=k(64),T=new Map,ne=["composables","functions"];function W(e){let s=w.basename(e,".ts");return s==="index"||s==="types"||e.endsWith(".d.ts")}async function se(e){if(e)return w.resolve(e);let s=`<default>:${process.cwd()}`,i=T.get(s);if(i!==void 0)return i;let t=await oe();if(t!==null)T.set(s,t);return t}async function oe(){let e=await a(),s=e.root||process.cwd(),i=e.composablesDir;if(i)return w.resolve(s,i);for(let t of ne){let n=w.resolve(s,t);try{let c=new Bun.Glob("**/*.ts");for await(let r of c.scan({cwd:n,absolute:!0}))if(!W(r))return n}catch{}}return null}async function X(e){let s=Array.isArray(e)?e:e?[w.resolve(e)]:(await a())._layerComposableDirs??[await se()].filter((t)=>!!t),i=new Map;for(let t of s){let n=new Bun.Glob("**/*.ts");try{for await(let c of n.scan({cwd:t,absolute:!0})){let r=w.relative(t,c);if(!W(c)&&!i.has(r))i.set(r,c)}}catch{}}return{key:s.join("\x00"),files:[...i.values()].sort()}}async function Uo(e){let{files:s}=await X(e),i=ie({loader:"ts",target:"browser",define:A()}),t=[];for(let n of s)try{let c=await Bun.file(n).text(),r=i.scan(c).exports.filter((d)=>d!=="default");if(r.length>0)t.push({file:n,names:r})}catch{}return t}function re(e,s){return new RegExp(`\\b${s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(e)}function Q(e,s){let i=new Set(e.match(/\w+/g)),t=new Set;for(let n of s)if(/^\w+$/.test(n)?i.has(n):re(e,n))t.add(n);return t}var H=k(64);function U(e,s){let i=E(e,s.size),t=H.get(i);if(t)return t;let n;try{n=je(e,s)}catch{n=Q(e,s)}let c=[...e.matchAll(/(?:const|let|var)\s*\{([^}]*)\}\s*=\s*window\.__composables\u0008/g),...e.matchAll(/import\s*\{([^}]*)\}\s*from\s*['"]@composables['"]/g)];for(let r of c)for(let d of r[1].split(",")){let f=d.trim().split(/\s*(?::|\u0008as\u0008)\s*/)[0];if(f&&s.has(f))n.add(f)}return H.set(i,n),n}function ae(e){return!e||/^(?:module|(?:text|application)\/(?:java|ecma)script|application\/stx-[\w-]+)$/i.test(e)}var q=k(256);function ce(e,s){let i=new Set(s),t="",n=0,c=new Set;for(let r of ee(e)){t+=e.slice(n,r.start),n=r.end;let d=O(r.attrs),f=e.slice(r.bodyStart,r.bodyEnd),u=d.get("type"),m=typeof u==="string"?u.trim():void 0;if(!ae(m)){if(!/json/i.test(m??""))t+=` ${f} `;continue}let h=Q(f,i);if(h.size===0)continue;let _=E(f,[...h].sort().join(",")),b=q.get(_);if(!b)b=U(f,h),q.set(_,b);for(let v of b)c.add(v)}t+=e.slice(n);for(let r of so(t))for(let d of U(r.code,i))c.add(d);return c}function le(e,s,i){let t=new Map;for(let{file:f,names:u}of e)for(let m of u)if(!t.has(m))t.set(m,f);let n=new Set(t.keys()),c=(f)=>{let u=[];for(let m of U(f,n))u.push(t.get(m));return u},r=new Set,d=i.flatMap((f,u)=>u===0?[...ce(f,t.keys())].map((m)=>t.get(m)):c(f));while(d.length>0){let f=[];for(let u of d){if(r.has(u))continue;r.add(u);for(let m of c(s.get(u)??""))if(!r.has(m))f.push(m)}d=f}return r}async function qh(e,s,i,t){let{key:n,files:c}=await X(e);if(!n)return null;let r=()=>[...new Set([...c,...c.flatMap((o)=>$e(o))])],d=Rt(r());if(c.length===0)return ve(x,n,d,""),null;c.sort();let f=ie({loader:"ts",target:"browser",define:A()}),u=un(P,n,d);if(!u){let o=new Map,l=[];for(let p of c)try{let S=await Bun.file(p).text();o.set(p,S);let g=f.scan(S).exports.filter((te)=>te!=="default");if(g.length>0)l.push({file:p,names:g})}catch{o.set(p,"")}u=ve(P,n,d,{codeByFile:o,modules:l})}let{codeByFile:m,modules:h}=u,_;if(s===void 0)_=new Set(c);else{let o=i?[s,...i]:[s],l=E(o.join("\x00"),n,o.length,d),p=R.get(l);if(_=p??le(h,m,o),!p)R.set(l,_)}if(_.size===0)return null;let b=c.filter((o)=>_.has(o)),v=()=>{if(!t)return;for(let o of b)t.push(o,...$e(o))},N=`${n}\x00${b.join("\x00")}\x00${bn()}`,z=un(x,N,d);if(z!==void 0)return v(),z||null;let F=[],B=new Set,K=new Set;for(let o of b)try{let l=m.get(o)??await Bun.file(o).text(),p=w.basename(o,".ts");for(let g of l.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(g[1])K.add(g[1]);let S=[];try{for(let g of f.scan(l).exports)if(g!=="default")B.add(g),S.push(g)}catch{}if(l=D(l),yn(l))l=await wn(l,o,{projectRoot:process.cwd(),externalizeUserModules:!1,expose:S}),l=Ot(l);l=zn(l),l=l.replace(/^export\s+(default\s+)?/gm,""),l=f.transformSync(l),F.push(`// Composable: ${p}
|
|
3
3
|
${l.trim()}`)}catch(l){console.warn(`[stx] Failed to load composable ${o}:`,l)}if(F.length===0||B.size===0)return ve(x,N,d,""),null;let V=[...B].map((o)=>` try { if (!(${JSON.stringify(o)} in __c)) __c[${JSON.stringify(o)}] = ${o}; } catch (e) {}`).join(`
|
|
4
4
|
`),G=JSON.stringify([...B]),M=F.join(`
|
|
5
5
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{y,Ui,_l,Cl,Vg,Wg,qg,Kg,Xg,po,Gg,Ye,ie,Ze,Jg,Hr,Yg,$l,Rl,qi,Qe,s,On,Al,b,Ce,Ny}from"./chunk-
|
|
2
|
+
import{y,Ui,_l,Cl,Vg,Wg,qg,Kg,Xg,po,Gg,Ye,ie,Ze,Jg,Hr,Yg,$l,Rl,qi,Qe,s,On,Al,b,Ce,Ny}from"./chunk-b5qzed8y.js";import"./chunk-p3x84jj0.js";import"./chunk-w98yt4d4.js";import"./chunk-4vz17ytv.js";import"./chunk-phzhmnnm.js";import"./chunk-9928zdej.js";import"./chunk-0jdz31q1.js";import"./chunk-16sfjkc4.js";export{Rl as SIGNAL_COMPOSABLE_CALL,Ce as clearComponentCache,qi as componentClientSignalNames,Ui as convertToCommonJS,b as createDetailedErrorMessage,Xg as extractDirectiveNames,_l as extractScriptFromTemplate,y as extractVariables,s as fileExists,Ny as getComponentCacheStats,Wg as getPositionInfo,ie as getSharedTranspiler,Al as getSourceLineInfo,Kg as hasDirectives,Cl as hasVariables,Yg as isHydrateTrigger,Gg as isJavaScriptScript,Qe as renderComponentWithSlot,On as resolveTemplatePath,Jg as scopeOnRootElement,po as scopeSequenceKey,Ye as shouldTranspileTypeScript,$l as slotContentHasExpressions,Ze as transpileTypeScript,Hr as userComponentFileExists,qg as validateDirective,Vg as validateTemplate};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Su,Zm,ku,_u,Qm,eh}from"./chunk-
|
|
2
|
+
import{Su,Zm,ku,_u,Qm,eh}from"./chunk-wm24jx3t.js";import"./chunk-b5qzed8y.js";import"./chunk-p3x84jj0.js";import"./chunk-w98yt4d4.js";import"./chunk-4vz17ytv.js";import"./chunk-phzhmnnm.js";import"./chunk-9928zdej.js";import"./chunk-0jdz31q1.js";import"./chunk-16sfjkc4.js";export{eh as applySlots,Qm as extractSlotContent,Zm as parseSlotElement,Su as parseSlots,_u as processSlots,ku as renderSlot};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-16sfjkc4.js";import"./chunk-phzhmnnm.js";import"./chunk-0jdz31q1.js";import"./chunk-9928zdej.js";import{k,E,A,ie}from"./chunk-
|
|
2
|
+
import"./chunk-16sfjkc4.js";import"./chunk-phzhmnnm.js";import"./chunk-0jdz31q1.js";import"./chunk-9928zdej.js";import{k,E,A,ie}from"./chunk-b5qzed8y.js";import"./chunk-4vz17ytv.js";import"./chunk-w98yt4d4.js";import"./chunk-p3x84jj0.js";import{Sr}from"./chunk-1hx6dyy9.js";import{existsSync as C}from"fs";import l from"path";var b=["applyOfflineUpdate","broadcast","cacheMedia","calculateDistance","canNotify","clearCookies","clearFetchCache","clearOfflineData","clearStorage","copyToClipboard","createShareableFile","defineForm","getBatteryLevel","getCookie","getCurrentPosition","getStorageKeys","getStorageSize","getVoices","hasBattery","hasCameraPermission","hasGeolocationPermission","hasMicrophonePermission","hasNotificationPermission","hasResizeObserver","hexToHsl","hexToRgb","isBroadcastChannelSupported","isCharging","isDeviceMotionSupported","isDeviceOrientationSupported","isEventSourceSupported","isEyeDropperSupported","isInFullscreen","isMutationObserverSupported","isPermissionGranted","isSpeechRecognitionSupported","isSpeechSynthesisSupported","isWakeLockSupported","isWebSocketSupported","notify","onOfflineUpdateReady","parseCookies","pickColor","prefetch","removeCookie","requestMediaPermissions","requestMotionPermission","requestNotificationPermission","requestOrientationPermission","setCookie","share","shareCurrentPage","shareFiles","shareText","shareURL","shareWithFallback","speak","stopSpeaking","toggleFullscreen","useAmbientSound","useAnimationFrame","useAsyncData","useAttributeObserver","useAutoLogout","useAutoWakeLock","useBattery","useBreakpoint","useBreathPacer","useBroadcastChannel","useChannel","useChildListObserver","useClipboard","useColorHistory","useCompletion","useConditionalWakeLock","useCookies","useCopySelection","useDeviceMotion","useDeviceOrientation","useElementSize","useElementTextSelection","useElementVisibility","useEventSource","useEyeDropper","useFavicon","useForm","useFullscreen","useGeolocation","useGeolocationWatch","useHotkey","useIdle","useIdleState","useInfiniteScroll","useIntersectionObserver","useIntersectionObserverMultiple","useIsDesktop","useIsMobile","useIsTablet","useKeyPressed","useKeySequence","useKeyboard","useLastActive","useLazyLoad","useMeta","useMouse","useMouseInElement","useMutationObserver","useNetwork","useNotification","useOnline","useOutbox","useParallax","usePermission","usePermissions","usePointer","usePost","useResizeObserver","useResizeObserverMultiple","useSSE","useScroll","useSelectionPopup","useShare","useSpeechRecognition","useSpeechSynthesis","useStorage","useTextObserver","useTextSelection","useTitle","useVirtualList","useVisibility","useWakeLock","useWindowSize"],_=new Set(b);var u=new Map,h=k(64),S=new Set,y=0,R=new Set(b);function z(){u.clear(),h.clear()}function P(s){let o=new Map;for(let t of s){let i=l.basename(t);if(i.endsWith(".d.ts"))continue;let r=i.replace(/\.[jt]s$/,"");if(r==="index")continue;if(r===i)continue;let a=o.get(r);if(a&&!a.endsWith(".js"))continue;o.set(r,t)}return[...o.values()].sort()}function I(s,o){let t=o.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(?:^|[^\\w$.])(?:const|let|var|function|class)\\s+${t}\\b`).test(s)}function M(s){if(!s)return[];let o=E(s,y),t=h.get(o);if(t)return t.slice();let i=s.replace(/<script\b[^>]*\bdata-stx-runtime\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-framework-composables\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-stores\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-composables\b[^>]*>[\s\S]*?<\/script>/gi,""),r=[];for(let a of R){if(S.has(a))continue;let p=a.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");if(new RegExp(`(^|[^\\w$.])${p}\\s*\\(`).test(i))r.push(a)}return r.sort(),h.set(o,r),r.slice()}function L(){let s=l.join(import.meta.dir,"composables"),o=import.meta.url.endsWith(".ts")?"ts":"js";if(C(l.join(s,`index.${o}`)))return s;let t=Sr("@stacksjs/stx/composables");return t?l.dirname(t):void 0}async function V(s,o){let t=M(s);if(t.length===0)return null;let i=o??L();if(!i)return null;let r=`${i}\x00${t.join(",")}`,a=u.get(r);if(a!==void 0)return a||null;let p=ie({loader:"ts",target:"browser",define:A()}),v=new Set(t),m=[],d=new Set,f=[];try{let n=new Bun.Glob("*.{ts,js}");for await(let e of n.scan({cwd:i,absolute:!0}))f.push(e)}catch{return u.set(r,""),null}f=P(f);for(let n of f){let e;try{e=await Bun.file(n).text()}catch{continue}let g=[];try{g=p.scan(e).exports.filter((c)=>c!=="default")}catch{continue}if(!g.some((c)=>v.has(c)))continue;try{e=e.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^import\s+type\s+.*$/gm,""),e=e.replace(/^export\s+\*\s+(?:as\s+\w+\s+)?from\s*['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^export\s+(?:type\s+)?\{[\s\S]*?\}\s*(?:from\s*['"][^'"]+['"]\s*)?;?\s*$/gm,""),e=e.replace(/^export\s+default\s+/gm,""),e=e.replace(/^export\s+(?=(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\b)/gm,""),m.push(`// ${l.basename(n).replace(/\.[jt]s$/,"")}
|
|
3
3
|
${p.transformSync(e).trim()}`);for(let c of g)d.add(c)}catch(c){console.warn(`[stx] framework composable ${l.basename(n)} could not be bundled:`,c)}}let w=t.filter((n)=>!d.has(n)&&!I(s,n));if(w.length>0)console.warn(`[stx] could not bundle ${w.join(", ")} from @stacksjs/stx/composables \u2014 `+"calls to them will throw ReferenceError in the browser. Import them explicitly so the bundler inlines them, or use a runtime equivalent from window.stx.");if(m.length===0)return u.set(r,""),null;let O=[...d].map((n)=>` try { if (!(${JSON.stringify(n)} in __s)) { __s[${JSON.stringify(n)}] = ${n}; if (!(${JSON.stringify(n)} in window)) window[${JSON.stringify(n)}] = ${n}; } } catch (e) {}`).join(`
|
|
4
4
|
`),x=`<script data-stx-scoped data-stx-run="always" data-stx-framework-composables>
|
|
5
5
|
;(function(){
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{m,p}from"./chunk-4vz17ytv.js";import{oe,F,g}from"./chunk-
|
|
2
|
+
import{m,p}from"./chunk-4vz17ytv.js";import{oe,F,g}from"./chunk-b5qzed8y.js";function z(t,o){let i=1,r=o,e="<template",n="</template";while(r<t.length&&i>0){let s=t.indexOf("<",r);if(s===-1)break;if(r=s,t.startsWith(e,r)&&(r+e.length>=t.length||/[\s>\/]/.test(t[r+e.length]))){i++,r+=e.length;continue}if(t.startsWith(n,r)){let a=t.indexOf(">",r+n.length);if(a!==-1){if(i--,i===0)return a+1;r=a+1;continue}}r++}return i===0?r:-1}var N=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function k(t,o){let i=null;for(let r=o;r<t.length;r++){let e=t[r];if(i){if(e==="\\"){r++;continue}if(e===i)i=null;continue}if(e==='"'||e==="'"){i=e;continue}if(e===">")return r+1}return-1}function B(t,o,i){let r=o.toLowerCase(),e=1,n=i;while(n<t.length){let s=t.indexOf("<",n);if(s===-1)return-1;if(t.startsWith("<!--",s)){let f=t.indexOf("-->",s+4);n=f===-1?t.length:f+3;continue}let a=k(t,s+1);if(a===-1)return-1;let u=t.slice(s,a),c=u.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(c&&c[2].toLowerCase()===r){if(c[1]==="/"){if(e--,e===0)return a}else if(!/\/\s*>$/.test(u))e++}n=a}return-1}function Z(t){let o=[],i=[],r=/\bslot\s*=\s*(?:"([^"]+)"|'([^']+)')/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let l=t.indexOf("-->",n+4);e=l===-1?t.length:l+3;continue}let s=k(t,n+1);if(s===-1)break;let a=t.slice(n,s),u=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!u){e=s;continue}let c=u[2].toLowerCase();if(u[1]==="/"){let l=i.lastIndexOf(c);if(l!==-1)i.splice(l);e=s;continue}let f=/\/\s*>$/.test(a),d=i.length===0?a.match(r):null;if(d){let l=d[1]||d[2],h=a.replace(r,"").replace(/\s+(?=\/?>$)/,"").replace(/\s{2,}/g," "),S=f||N.has(c)?-1:B(t,c,s);if(S===-1)o.push({start:n,end:s,slotName:l,element:h}),e=s;else o.push({start:n,end:S,slotName:l,element:h+t.slice(s,S)}),e=S;continue}if(!f&&!N.has(c)){if(i.push(c),c==="script"||c==="style"){let l=t.toLowerCase().indexOf(`</${c}>`,s);if(l!==-1){e=l;continue}}}e=s}return o}function L(t){let o=[],i=[],r=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let l=t.indexOf("-->",n+4);e=l===-1?t.length:l+3;continue}let s=k(t,n+1);if(s===-1)break;let a=t.slice(n,s),u=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!u){e=s;continue}let c=u[1]==="/",f=u[2].toLowerCase();if(c){let l=i.lastIndexOf(f);if(l!==-1)i.splice(l);e=s;continue}if(f==="template"&&i.length===0){let l=a.match(r);if(l){let h=z(t,s);if(h!==-1){let S=l[1]||l[2]||l[3];o.push({start:n,end:h,slotName:S,content:t.slice(s,h-11).trim(),propsBinding:l[4]||void 0}),e=h;continue}}}if(!/\/\s*>$/.test(a)&&!N.has(f)){if(i.push(f),f==="script"||f==="style"){let l=t.toLowerCase().indexOf(`</${f}>`,s);if(l!==-1){e=l;continue}}}e=s}return o}function Su(t){let o={default:"",named:new Map},i=t,r=L(t);for(let n of r)o.named.set(n.slotName,{name:n.slotName,content:n.content,propsBinding:n.propsBinding});r.sort((n,s)=>s.start-n.start);for(let n of r)i=i.slice(0,n.start)+i.slice(n.end);let e=Z(i);for(let n of e){let s=o.named.get(n.slotName);if(s)s.content+=n.element;else o.named.set(n.slotName,{name:n.slotName,content:n.element})}for(let n=e.length-1;n>=0;n--){let s=e[n];i=i.slice(0,s.start)+i.slice(s.end)}return o.default=i.trim(),o}function Zm(t){let o=t.match(/name\s*=\s*["']([^"']+)["']/),i=o?o[1]:"",r={},e=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,n;while((n=e.exec(t))!==null)r[n[1]]=n[2];let s=t.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),a=s?s[1].trim():"";return{name:i,props:r,defaultContent:a}}async function ku(t,o,i,r){if(!t)return i;let e=t.content;if(t.propsBinding&&Object.keys(o).length>0){let n=t.propsBinding.trim(),s={...r},a=new Set,u=new Set;if(n.startsWith("{")&&n.endsWith("}")){let c=n.slice(1,-1).split(",").map((f)=>f.trim()).filter(Boolean);for(let f of c){let[d,l]=f.split(":").map((S)=>S.trim()),h=l||d;if(s[h]=o[d],o[d]!==void 0)u.add(h);else a.add(h)}}else if(s[n]=o,Object.values(o).some((c)=>c===void 0))a.add(n);else u.add(n);e=j(e,s,a,u)}return e}function j(t,o,i,r){return t.replace(/\{\{\s*([^}]+)\s*\}\}/g,(e,n)=>{try{let s=n.trim();if(F(s,i))return e;if(Array.isArray(o.__stx_preserved_client_expressions)&&o.__stx_preserved_client_expressions.includes(s)&&!F(s,r))return e;let a=_(s,o);if(a===void 0)return e;return g(String(a??""))}catch{return`{{ ${n} }}`}})}function _(t,o){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test(t)){let r=t.split("."),e=o;for(let n of r)if(e&&typeof e==="object"&&n in e)e=e[n];else return;return e}let i=t.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(i){let[,r,e,n]=i,s=o[r],a=parseInt(n,10);if(typeof s==="number")switch(e){case"+":return s+a;case"-":return s-a;case"*":return s*a;case"/":return s/a}}try{if(!m(t))return;return p(t,Object.keys(o))(...Object.values(o))}catch{return}}async function _u(t,o,i,r){let e=t;e=await I(e,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(a,u,c,f)=>{let d=o.named.get(u),l=f?.trim()||"",h=c||"",S={},E=[],C=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,b;while((b=C.exec(h))!==null){let w=b[1],x=b[2];S[w]=_(x,i),E.push([w,x])}if(r!==void 0&&d?.propsBinding&&Object.values(S).some((w)=>w===void 0)){let w=d.propsBinding.trim(),x=oe(`${w} in []`),y="__stx_slot_props";while(x.includes(y))y+="_";let M=E.map(([A,P])=>{let O=S[A],R;try{R=O===void 0?void 0:JSON.stringify(O)}catch{}return`${JSON.stringify(A)}:(${R??P})`}).join(","),v=g(JSON.stringify({binding:w,names:x,owner:r}));return`<template :for="${g(`${y} in [{${M}}]`)}" data-stx-slot-binding="${encodeURIComponent(w)}" data-stx-slot-scope="${v}">${d.content}</template>`}return await ku(d,S,l,i)});let s=/<slot\b((?:"[^"]*"|'[^']*'|[^>"'])*?)\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return e=e.replace(s,(a,u,c)=>{if(/\bname\s*=/.test(u||""))return a;let f=c?.trim()||"";return o.default||f}),e}async function I(t,o,i){let r=[],e=[];t.replace(o,(a,...u)=>{let c=u[u.length-2];return e.push({match:a,index:c}),r.push(i(a,...u.slice(0,-2))),a});let n=await Promise.all(r),s=t;for(let a=e.length-1;a>=0;a--){let{match:u,index:c}=e[a];s=s.slice(0,c)+n[a]+s.slice(c+u.length)}return s}function Qm(t){let o=Su(t);return{defaultSlot:o.default,namedSlots:o.named}}async function eh(t,o,i,r,e){return await _u(t,{default:o,named:i},r,e)}
|
|
3
3
|
export{Su,Zm,ku,_u,Qm,eh};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Rm}from"./chunk-v78hjbz0.js";import"./chunk-n4m50dpk.js";import"./chunk-ngqb22wj.js";import"./chunk-43sgpy4e.js";import"./chunk-fs43342z.js";import"./chunk-0v7555tr.js";import"./chunk-0fm6avxt.js";import"./chunk-bm6y085n.js";import"./chunk-9tv0tw7f.js";import"./chunk-9w9y84t5.js";import"./chunk-8b8az19t.js";import"./chunk-nhyv3w4r.js";import"./chunk-t65f98qv.js";import"./chunk-0adc8x2h.js";import"./chunk-mf5cqv1k.js";import"./chunk-w6ydg43d.js";import"./chunk-2vx2ben8.js";import"./chunk-jr2r2nh5.js";import"./chunk-xnp031ba.js";import"./chunk-388xpdw5.js";import"./chunk-b5qzed8y.js";import"./chunk-p3x84jj0.js";import"./chunk-w98yt4d4.js";import"./chunk-4vz17ytv.js";import"./chunk-phzhmnnm.js";import"./chunk-9928zdej.js";import"./chunk-0jdz31q1.js";import"./chunk-16sfjkc4.js";export{Rm as startInteractive};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{tg,ng,$e,rg,Pc,mn,hn,iy,Ic,yn,hr,sg,og,ig,Cs,ag,cg,Oc,bn,lg,wn,Nc,ay}from"./chunk-
|
|
2
|
+
import{tg,ng,$e,rg,Pc,mn,hn,iy,Ic,yn,hr,sg,og,ig,Cs,ag,cg,Oc,bn,lg,wn,Nc,ay}from"./chunk-0atz8fjx.js";import"./chunk-0sj79ha5.js";import"./chunk-cwcmmgvz.js";import"./chunk-0adc8x2h.js";import"./chunk-mf5cqv1k.js";import"./chunk-w6ydg43d.js";import"./chunk-2vx2ben8.js";import"./chunk-jr2r2nh5.js";import"./chunk-xnp031ba.js";import"./chunk-388xpdw5.js";import"./chunk-b5qzed8y.js";import"./chunk-p3x84jj0.js";import"./chunk-w98yt4d4.js";import"./chunk-4vz17ytv.js";import"./chunk-phzhmnnm.js";import"./chunk-9928zdej.js";import"./chunk-0jdz31q1.js";import"./chunk-16sfjkc4.js";export{hr as MODULE_SPECIFIER_PREFIX,Oc as assertBundleBuildCanSettle,tg as bundleCacheDir,ng as bundleCacheEntryLimit,ay as bundleClientEntriesSplit,wn as bundleClientScript,hn as clearBundleFailures,$e as clientBundleDependencies,mn as getBundleFailures,yn as hasUserImports,cg as isWithinBundlerCallback,bn as moduleSubstitutionKey,og as normalizeRegistrySpecifiers,lg as queueClientBundleBuild,Pc as recordBundleFailure,sg as registryIdForPath,Ic as resolveBundlerFallback,ig as rewriteRegistryImports,iy as setBundlerFallbackMode,rg as shouldLogBundlerDiagnostics,Nc as tempBuildName,Cs as withModuleSubstitutes,ag as withinBundlerCallback};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{qa,zu,rr,mh,Hu,Uu,Vu,hh}from"./chunk-
|
|
2
|
+
import{qa,zu,rr,mh,Hu,Uu,Vu,hh}from"./chunk-789yp1tg.js";import"./chunk-b5qzed8y.js";import"./chunk-p3x84jj0.js";import"./chunk-w98yt4d4.js";import"./chunk-4vz17ytv.js";import"./chunk-phzhmnnm.js";import"./chunk-9928zdej.js";import"./chunk-0jdz31q1.js";import"./chunk-16sfjkc4.js";export{rr as Validator,zu as defineForm,Hu as processErrorDirective,Uu as processErrorsDirective,hh as processFormValidationDirectives,Vu as processHasErrorsDirective,qa as useForm,mh as v};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{et,z,Jt}from"./chunk-w98yt4d4.js";import{T}from"./chunk-0jdz31q1.js";import{Et,Be,V,ds,Tt,Fe,Fa,Fo,za,Gn}from"./chunk-4a9bqc8f.js";import{Dt,Se,We,Ai,Pi}from"./chunk-vnk582z7.js";import{ni}from"./chunk-dp6r6gtb.js";import{Jn}from"./chunk-fznjm7qt.js";import{Ae}from"./chunk-7anbc757.js";import ae from"fs";import P from"path";var{serve:ge}=globalThis.Bun;import k from"zlib";import{promisify as re}from"util";var ce=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ue=["text/event-stream","multipart/x-mixed-replace"],pe=1024;function le(t){if(!t)return!1;let e=t.toLowerCase();if(ue.some((o)=>e.startsWith(o)))return!1;return ce.some((o)=>e.startsWith(o))}function me(t){let e=new Map;for(let o of t.split(",")){let[r,...c]=o.trim().split(";"),m=r.trim().toLowerCase();if(!m)continue;let v=1;for(let d of c){let u=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(d);if(!u)continue;let l=Number.parseFloat(u[1]);if(Number.isFinite(l))v=l}e.set(m,v)}return e}function fe(t){if(!t)return null;let e=me(t),o=e.get("*"),r=(c)=>e.get(c)??o??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var se=33554432,F=new Map,W=0;function de(t,e){if(e.length>se/8)return;F.set(t,e),W+=e.length;for(let[o,r]of F){if(W<=se)break;F.delete(o),W-=r.length}}async function Wn(t,e,o={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!le(e.headers.get("content-type")))return e;let r=fe(t.headers.get("accept-encoding"));if(!r)return e;let c;try{c=new Uint8Array(await e.arrayBuffer())}catch{return e}let m=()=>new Response(c,{status:e.status,statusText:e.statusText,headers:oe(e.headers)});if(c.length<(o.threshold??pe))return m();try{let v=o.quality??5,d=`${r}:${v}:${c.length}:${Bun.hash(c)}`,u=F.get(d);if(!u)u=r==="br"?await re(k.brotliCompress)(c,{params:{[k.constants.BROTLI_PARAM_QUALITY]:v,[k.constants.BROTLI_PARAM_SIZE_HINT]:c.length}}):await re(k.gzip)(c),de(d,u);if(u.length>=c.length)return m();let l=oe(e.headers);return l.set("Content-Encoding",r),l.set("Content-Length",String(u.length)),new Response(u,{status:e.status,statusText:e.statusText,headers:l})}catch{return m()}}function oe(t){let e=new Headers(t),o=e.get("Vary");if(!o)return e.set("Vary","Accept-Encoding"),e;if(!o.split(",").some((c)=>c.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${o}, Accept-Encoding`);return e}var he=new Set(["x-stx-router","accept-encoding",...ds.map((t)=>t.toLowerCase())]);class J{now;entries=new T(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,o){let r,c=async()=>{let a=r??await o();return a.headers.set("Cache-Control","private, no-store"),a.headers.set("Vary",V(a.headers.get("Vary")).Vary),a};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return c();let m=new URL(t.url),v=Be(t)?`fragment|${ds.map((a)=>t.headers.get(a)??"").join("|")}`:"document",d=`${m.origin}${m.pathname}${m.search}|${v}`,u=this.entries.get(d),l=(a)=>{let S=new Headers(a.headers);return S.set("Cache-Control","private, no-store"),S.set("Age",String(Math.max(0,Math.floor((this.now()-a.created)/1000)))),new Response(a.body.slice(0),{headers:S})},b=u?(this.now()-u.created)/1000:1/0;if(u&&b<e.maxAge)return l(u);let N=this.generation,X=async()=>{let a=await o();r=a;let S=(a.headers.get("Vary")??"").toLowerCase().split(",").map((s)=>s.trim()).filter(Boolean);if(a.status!==200||a.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(a.headers.get("Cache-Control")??"")||S.some((s)=>!he.has(s)))return null;let n=await a.clone().arrayBuffer();if(n.byteLength>1048576)return null;a.headers.set("Vary",V(a.headers.get("Vary")).Vary);let A={body:n,headers:Array.from(a.headers.entries()),created:this.now(),path:m.pathname};if(this.generation===N)this.entries.set(d,A);return A},w=this.pending.get(d);if(!w){if(this.pending.size>=1000)return c();w=X().finally(()=>{if(this.pending.get(d)===w)this.pending.delete(d)}),this.pending.set(d,w)}if(u&&b<e.maxAge+(e.swr??0))return w.catch(()=>{}),l(u);let E=await w;return E?l(E):c()}}var Re={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};function q(t,e){if(!e)return null;let o=Pi(t.headers);return o&&Ai(o,e)?e:null}function K(t){return t?{"X-STX-Layout":t.layout,"X-STX-Layout-Group":t.group}:{}}async function Pm(t={}){let e=P.resolve(t.outputDir||".output"),o=t.port??3000,r=Fa(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let c=Jn(r.routeRules),m=new J,v=ni(e,r.apiRoutes??[]),d=Bun.file(P.join(e,"server/runtime-config.json")),u=t.runtimeConfig??(await d.exists()?await d.json():void 0),l=u?z(u):void 0,b=new Map,N=new Map,X=new Map,w=new Map;for(let n of r.routes)try{let A=P.join(e,n.compiledPath),s=JSON.parse(await Bun.file(A).text());if(l)s.html=Jt(s.html,l);b.set(n.pattern,s),X.set(n.pattern,We(s.html)),w.set(n.pattern,Ae(s.html));let j=P.join(e,n.fragmentPath);if(Tt(s.html,r.routerContainer||"main")&&await Bun.file(j).exists()){let M=await Bun.file(j).text();N.set(n.pattern,l?Jt(M,l):M)}}catch(A){console.warn(`[stx] Failed to load route ${n.pattern}:`,A)}let E=new Map,a=[];for(let n of r.routes)if(n.hasParams){let{regex:A,params:s}=Se(n.pattern,{page:!0});a.push({regex:A,route:n,paramNames:s})}else E.set(n.pattern,n);let S=ge({port:o,async fetch(n){return Wn(n,await et(l??z(),async()=>{let s=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[s])return t.apiRoutes[s](n);let j=await v(n);if(j)return j;if((n.method==="GET"||n.method==="HEAD")&&s!=="/"){let p=P.resolve(e,"public"),y;try{y=decodeURIComponent(s)}catch{y=s}if(!y.includes("\x00")){let f=P.resolve(p,`.${y}`);if(f===p||f.startsWith(`${p}${P.sep}`))try{if(ae.existsSync(f)&&ae.statSync(f).isFile()){let i=P.extname(f).toLowerCase(),g=Re[i]||"application/octet-stream",H=s.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(s);return new Response(Bun.file(f),{headers:{"Content-Type":g,"Cache-Control":H?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let M=Be(n),R=null,Q={};if(R=E.get(s)||null,!R)for(let{regex:p,route:y,paramNames:f}of a){let h=s.match(p);if(h){R=y,f.forEach((i,g)=>{Q[i]=h[g+1]});break}}if(!R){let p=Dt(s)?null:E.get("/404")||null;if(p){let y=b.get(p.pattern);if(y)return new Response(y.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let O=c(s),Z=Object.keys(O).length>0;return m.respond(n,O.cache,async()=>{let p=b.get(R.pattern),y=M?q(n,X.get(R.pattern)):null;if(M&&!y&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let i=N.get(R.pattern);if(i){let g=X.get(R.pattern);return new Response(i,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...w.has(R.pattern)?{"X-STX-Runtime":w.get(R.pattern)?"true":"false"}:{},...g?{"X-STX-Layout":g.layout,"X-STX-Layout-Group":g.group}:{},...V(),...O.cache?{}:{"Cache-Control":Et}}})}}let f=Fo(n.method),h=b.get(R.pattern);if(!h){let i=E.get("/500")||null;if(i){let g=b.get(i.pattern);if(g)return new Response(g.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(R.prerendered&&f)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!f&&!h.hasServerScripts&&Object.keys(h.placeholders).length===0)return new Response(h.html,{status:h.status??200,headers:{"Content-Type":"text/html",...V(),"Cache-Control":"public, max-age=60",...K(y)}});try{let{html:i,boundaries:g,redirect:H,cookies:I,status:D,headers:U}=await Gn(h,{params:Q,request:n,method:n.method,__stx_strict_hydration:Z,__stx_runtime_config:l});if(H)return za(H,I,U);if(g&&g.length>0){let{renderStreamingPage:x,streamToResponse:B}=await import("./chunk-6n50b07t.js"),L=new Headers({...V(),...U,"Cache-Control":"private, no-store"});for(let Y of I??[])L.append("Set-Cookie",Y);let _=M&&!f?We(i):null,te=_?q(n,_):null,ne=M&&!f&&!te&&Tt(i,r.routerContainer||"main");if(ne&&_)L.set("X-STX-Fragment","true"),L.set("X-STX-Runtime",Ae(i)?"true":"false"),L.set("X-STX-Layout",_.layout),L.set("X-STX-Layout-Group",_.group);for(let[Y,ie]of Object.entries(K(te)))L.set(Y,ie);return B(x(ne?Fe(i,r.routerContainer||"main",!0):i,g,{timeoutMs:30000}),{status:D??h.status??200,headers:L})}let C=new Headers({"Content-Type":"text/html",...V(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let x of I??[])C.append("Set-Cookie",x);for(let[x,B]of Object.entries(U??{}))C.set(x,B);C.set("Vary",V(C.get("Vary")).Vary);let G=M&&!f?We(i):null,ee=G?q(n,G):null;for(let[x,B]of Object.entries(K(ee)))C.set(x,B);if(M&&!f&&!ee&&Tt(i,r.routerContainer||"main")){let x=G??We(i);return C.set("X-STX-Fragment","true"),C.set("X-STX-Runtime",Ae(i)?"true":"false"),C.set("X-STX-Layout",x.layout),C.set("X-STX-Layout-Group",x.group),new Response(Fe(i,r.routerContainer||"main",!0),{status:D??h.status??200,headers:C})}return new Response(i,{status:D??h.status??200,headers:C})}catch(i){if(console.error(`[stx] Hydration error for ${s}:`,i),Z)return new Response("Internal Server Error",{status:500});return new Response(h.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${S.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${b.size} pre-loaded)`),{port:S.port,stop:()=>{m.invalidate(),S.stop()},invalidate:(n)=>m.invalidate(n)}}
|
|
2
|
+
import{et,z,Jt}from"./chunk-w98yt4d4.js";import{T}from"./chunk-0jdz31q1.js";import{Et,Be,V,ds,Tt,Fe,Fa,Fo,za,Gn}from"./chunk-3h4db9yb.js";import{Dt,Se,We,Ai,Pi}from"./chunk-388xpdw5.js";import{ni}from"./chunk-0sj79ha5.js";import{Jn}from"./chunk-fznjm7qt.js";import{Ae}from"./chunk-8b8az19t.js";import ae from"fs";import P from"path";var{serve:ge}=globalThis.Bun;import k from"zlib";import{promisify as re}from"util";var ce=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ue=["text/event-stream","multipart/x-mixed-replace"],pe=1024;function le(t){if(!t)return!1;let e=t.toLowerCase();if(ue.some((o)=>e.startsWith(o)))return!1;return ce.some((o)=>e.startsWith(o))}function me(t){let e=new Map;for(let o of t.split(",")){let[r,...c]=o.trim().split(";"),m=r.trim().toLowerCase();if(!m)continue;let v=1;for(let d of c){let u=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(d);if(!u)continue;let l=Number.parseFloat(u[1]);if(Number.isFinite(l))v=l}e.set(m,v)}return e}function fe(t){if(!t)return null;let e=me(t),o=e.get("*"),r=(c)=>e.get(c)??o??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var se=33554432,F=new Map,W=0;function de(t,e){if(e.length>se/8)return;F.set(t,e),W+=e.length;for(let[o,r]of F){if(W<=se)break;F.delete(o),W-=r.length}}async function Wn(t,e,o={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!le(e.headers.get("content-type")))return e;let r=fe(t.headers.get("accept-encoding"));if(!r)return e;let c;try{c=new Uint8Array(await e.arrayBuffer())}catch{return e}let m=()=>new Response(c,{status:e.status,statusText:e.statusText,headers:oe(e.headers)});if(c.length<(o.threshold??pe))return m();try{let v=o.quality??5,d=`${r}:${v}:${c.length}:${Bun.hash(c)}`,u=F.get(d);if(!u)u=r==="br"?await re(k.brotliCompress)(c,{params:{[k.constants.BROTLI_PARAM_QUALITY]:v,[k.constants.BROTLI_PARAM_SIZE_HINT]:c.length}}):await re(k.gzip)(c),de(d,u);if(u.length>=c.length)return m();let l=oe(e.headers);return l.set("Content-Encoding",r),l.set("Content-Length",String(u.length)),new Response(u,{status:e.status,statusText:e.statusText,headers:l})}catch{return m()}}function oe(t){let e=new Headers(t),o=e.get("Vary");if(!o)return e.set("Vary","Accept-Encoding"),e;if(!o.split(",").some((c)=>c.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${o}, Accept-Encoding`);return e}var he=new Set(["x-stx-router","accept-encoding",...ds.map((t)=>t.toLowerCase())]);class J{now;entries=new T(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,o){let r,c=async()=>{let a=r??await o();return a.headers.set("Cache-Control","private, no-store"),a.headers.set("Vary",V(a.headers.get("Vary")).Vary),a};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return c();let m=new URL(t.url),v=Be(t)?`fragment|${ds.map((a)=>t.headers.get(a)??"").join("|")}`:"document",d=`${m.origin}${m.pathname}${m.search}|${v}`,u=this.entries.get(d),l=(a)=>{let S=new Headers(a.headers);return S.set("Cache-Control","private, no-store"),S.set("Age",String(Math.max(0,Math.floor((this.now()-a.created)/1000)))),new Response(a.body.slice(0),{headers:S})},b=u?(this.now()-u.created)/1000:1/0;if(u&&b<e.maxAge)return l(u);let N=this.generation,X=async()=>{let a=await o();r=a;let S=(a.headers.get("Vary")??"").toLowerCase().split(",").map((s)=>s.trim()).filter(Boolean);if(a.status!==200||a.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(a.headers.get("Cache-Control")??"")||S.some((s)=>!he.has(s)))return null;let n=await a.clone().arrayBuffer();if(n.byteLength>1048576)return null;a.headers.set("Vary",V(a.headers.get("Vary")).Vary);let A={body:n,headers:Array.from(a.headers.entries()),created:this.now(),path:m.pathname};if(this.generation===N)this.entries.set(d,A);return A},w=this.pending.get(d);if(!w){if(this.pending.size>=1000)return c();w=X().finally(()=>{if(this.pending.get(d)===w)this.pending.delete(d)}),this.pending.set(d,w)}if(u&&b<e.maxAge+(e.swr??0))return w.catch(()=>{}),l(u);let E=await w;return E?l(E):c()}}var Re={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};function q(t,e){if(!e)return null;let o=Pi(t.headers);return o&&Ai(o,e)?e:null}function K(t){return t?{"X-STX-Layout":t.layout,"X-STX-Layout-Group":t.group}:{}}async function Pm(t={}){let e=P.resolve(t.outputDir||".output"),o=t.port??3000,r=Fa(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let c=Jn(r.routeRules),m=new J,v=ni(e,r.apiRoutes??[]),d=Bun.file(P.join(e,"server/runtime-config.json")),u=t.runtimeConfig??(await d.exists()?await d.json():void 0),l=u?z(u):void 0,b=new Map,N=new Map,X=new Map,w=new Map;for(let n of r.routes)try{let A=P.join(e,n.compiledPath),s=JSON.parse(await Bun.file(A).text());if(l)s.html=Jt(s.html,l);b.set(n.pattern,s),X.set(n.pattern,We(s.html)),w.set(n.pattern,Ae(s.html));let j=P.join(e,n.fragmentPath);if(Tt(s.html,r.routerContainer||"main")&&await Bun.file(j).exists()){let M=await Bun.file(j).text();N.set(n.pattern,l?Jt(M,l):M)}}catch(A){console.warn(`[stx] Failed to load route ${n.pattern}:`,A)}let E=new Map,a=[];for(let n of r.routes)if(n.hasParams){let{regex:A,params:s}=Se(n.pattern,{page:!0});a.push({regex:A,route:n,paramNames:s})}else E.set(n.pattern,n);let S=ge({port:o,async fetch(n){return Wn(n,await et(l??z(),async()=>{let s=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[s])return t.apiRoutes[s](n);let j=await v(n);if(j)return j;if((n.method==="GET"||n.method==="HEAD")&&s!=="/"){let p=P.resolve(e,"public"),y;try{y=decodeURIComponent(s)}catch{y=s}if(!y.includes("\x00")){let f=P.resolve(p,`.${y}`);if(f===p||f.startsWith(`${p}${P.sep}`))try{if(ae.existsSync(f)&&ae.statSync(f).isFile()){let i=P.extname(f).toLowerCase(),g=Re[i]||"application/octet-stream",H=s.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(s);return new Response(Bun.file(f),{headers:{"Content-Type":g,"Cache-Control":H?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let M=Be(n),R=null,Q={};if(R=E.get(s)||null,!R)for(let{regex:p,route:y,paramNames:f}of a){let h=s.match(p);if(h){R=y,f.forEach((i,g)=>{Q[i]=h[g+1]});break}}if(!R){let p=Dt(s)?null:E.get("/404")||null;if(p){let y=b.get(p.pattern);if(y)return new Response(y.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let O=c(s),Z=Object.keys(O).length>0;return m.respond(n,O.cache,async()=>{let p=b.get(R.pattern),y=M?q(n,X.get(R.pattern)):null;if(M&&!y&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let i=N.get(R.pattern);if(i){let g=X.get(R.pattern);return new Response(i,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...w.has(R.pattern)?{"X-STX-Runtime":w.get(R.pattern)?"true":"false"}:{},...g?{"X-STX-Layout":g.layout,"X-STX-Layout-Group":g.group}:{},...V(),...O.cache?{}:{"Cache-Control":Et}}})}}let f=Fo(n.method),h=b.get(R.pattern);if(!h){let i=E.get("/500")||null;if(i){let g=b.get(i.pattern);if(g)return new Response(g.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(R.prerendered&&f)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!f&&!h.hasServerScripts&&Object.keys(h.placeholders).length===0)return new Response(h.html,{status:h.status??200,headers:{"Content-Type":"text/html",...V(),"Cache-Control":"public, max-age=60",...K(y)}});try{let{html:i,boundaries:g,redirect:H,cookies:I,status:D,headers:U}=await Gn(h,{params:Q,request:n,method:n.method,__stx_strict_hydration:Z,__stx_runtime_config:l});if(H)return za(H,I,U);if(g&&g.length>0){let{renderStreamingPage:x,streamToResponse:B}=await import("./chunk-6aqr0e6s.js"),L=new Headers({...V(),...U,"Cache-Control":"private, no-store"});for(let Y of I??[])L.append("Set-Cookie",Y);let _=M&&!f?We(i):null,te=_?q(n,_):null,ne=M&&!f&&!te&&Tt(i,r.routerContainer||"main");if(ne&&_)L.set("X-STX-Fragment","true"),L.set("X-STX-Runtime",Ae(i)?"true":"false"),L.set("X-STX-Layout",_.layout),L.set("X-STX-Layout-Group",_.group);for(let[Y,ie]of Object.entries(K(te)))L.set(Y,ie);return B(x(ne?Fe(i,r.routerContainer||"main",!0):i,g,{timeoutMs:30000}),{status:D??h.status??200,headers:L})}let C=new Headers({"Content-Type":"text/html",...V(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let x of I??[])C.append("Set-Cookie",x);for(let[x,B]of Object.entries(U??{}))C.set(x,B);C.set("Vary",V(C.get("Vary")).Vary);let G=M&&!f?We(i):null,ee=G?q(n,G):null;for(let[x,B]of Object.entries(K(ee)))C.set(x,B);if(M&&!f&&!ee&&Tt(i,r.routerContainer||"main")){let x=G??We(i);return C.set("X-STX-Fragment","true"),C.set("X-STX-Runtime",Ae(i)?"true":"false"),C.set("X-STX-Layout",x.layout),C.set("X-STX-Layout-Group",x.group),new Response(Fe(i,r.routerContainer||"main",!0),{status:D??h.status??200,headers:C})}return new Response(i,{status:D??h.status??200,headers:C})}catch(i){if(console.error(`[stx] Hydration error for ${s}:`,i),Z)return new Response("Internal Server Error",{status:500});return new Response(h.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${S.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${b.size} pre-loaded)`),{port:S.port,stop:()=>{m.invalidate(),S.stop()},invalidate:(n)=>m.invalidate(n)}}
|
|
3
3
|
export{Wn,Pm};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{je}from"./chunk-9928zdej.js";import{C}from"./chunk-16sfjkc4.js";import{D,zn}from"./chunk-phzhmnnm.js";import{A,ie}from"./chunk-
|
|
2
|
+
import{je}from"./chunk-9928zdej.js";import{C}from"./chunk-16sfjkc4.js";import{D,zn}from"./chunk-phzhmnnm.js";import{A,ie}from"./chunk-b5qzed8y.js";import{a}from"./chunk-mf5cqv1k.js";import{$e,yn,bn,wn}from"./chunk-0atz8fjx.js";import{Ot}from"./chunk-9w9y84t5.js";import{Rt,sr,un,ve}from"./chunk-jz37h2z0.js";import{I,rt}from"./chunk-e5rag6rh.js";import v from"fs";import b from"path";import x from"process";function U(s,o){for(let e of s.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(e[1])o.add(e[1]);for(let e of s.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let t of(e[1]??"").split(",")){let r=((t.includes(":")?t.split(":").pop():t)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(r))o.add(r)}for(let e of s.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let t of(e[1]??"").split(",")){let n=t.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(n))o.add(n)}}var h=new Map;async function O(s,o=I()){let e;if(s)e=b.resolve(s);else{let l=await a();e=b.resolve(l.root||x.cwd(),l.storesDir||"stores")}let t=`${e}\x00${bn()}\x00${o?"shared":"inline"}`,n=new Bun.Glob("*.ts"),r=[];try{for await(let l of n.scan({cwd:e,absolute:!0})){let c=b.basename(l,".ts");if(["index","types"].includes(c))continue;if(l.includes(".d.ts"))continue;r.push(l)}}catch{return ve(h,t,"",{chunks:[]}),null}let i=()=>[...new Set([...r,...r.flatMap((l)=>$e(l))])],f=Rt(i()),u=un(h,t,f);if(u!==void 0)return u.chunks.length>0?u:null;if(r.length===0)return ve(h,t,f,{chunks:[]}),null;let m=[];for(let l of r){let c=await Bun.file(l).text();m.push({file:l,hasUseStore:/useStore\s*\(/.test(c)})}m.sort((l,c)=>{if(l.hasUseStore===c.hasUseStore)return 0;return l.hasUseStore?1:-1});let p=m.map((l)=>l.file),g=[],d=ie({loader:"ts",target:"browser",define:A()});for(let l of p)try{let c=await Bun.file(l).text(),k=b.basename(l,".ts"),_=new Set;U(c,_);let y=[...c.matchAll(/\bdefineStore\s*(?:<[^>()]*>)?\(\s*(['"`])([^'"`$\\]+)\1/g)].map((N)=>N[2]),E=c.match(/\bdefineStore\s*(?:<[^>()]*>)?\(/g)?.length??0;if(yn(c))c=await wn(c,l,{projectRoot:x.cwd(),externalizeUserModules:o});c=Ot(c),c=D(c),c=zn(c),c=c.replace(/^export\s+(default\s+)?/gm,""),c=d.transformSync(c),g.push({name:k,ids:y.length===E?y:[],declared:_,code:`// Store: ${k}
|
|
3
3
|
${c.trim()}`})}catch(c){console.warn(`[stx] Failed to load store ${l}:`,c)}if(g.length===0)return ve(h,t,f,{chunks:[]}),null;f=Rt(i());let S={chunks:g};return ve(h,t,f,S),S}function R(s){let o=new Set;for(let r of s)for(let i of r.declared)o.add(i);let e=s.map((r)=>r.code).join(`
|
|
4
4
|
|
|
5
5
|
`),n=`;(function(){
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{x}from"./chunk-
|
|
2
|
+
import{x}from"./chunk-b5qzed8y.js";import{createHash as j}from"crypto";function C(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var F=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function z(t){return Bun.hash(t).toString(16)}function Ec(t,e={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let n=new Map,o=t.replace(F,(r,a,u,l)=>{let c=l.trim();if(!c)return r;if(/\bdata-stx-src=/.test(u))return r;if(e.minify)c=C(c);let i=z(c);if(!n.has(i))n.set(i,c);let f=e.integrity?` data-stx-integrity="sha384-${j("sha384").update(c).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${a}" data-stx-src="/_stx/islands/${i}.js"${f}${u}></script>`}),s=Array.from(n,([r,a])=>({hash:r,code:a}));return{html:o,chunks:s}}var L=new Set(["visible","idle"]);function Tc(t){if(!t.includes("data-stx-src="))return t;let e=new Map,n=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,o;while((o=n.exec(t))!==null)e.set(o[1],o[2]);let s=new Set,r=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,a;while((a=r.exec(t))!==null)if(L.has(e.get(a[1])||""))s.add(a[2]);let u=/<\/head\s*>/iy,l=x(t,(i,f)=>(u.lastIndex=f,u.exec(i)?u.lastIndex:-1))[0]?.start??-1;if(s.size===0||l===-1)return t;let c=Array.from(s).filter((i)=>!t.includes(`rel="prefetch" href="${i}"`)).map((i)=>`<link rel="prefetch" href="${i}" as="script">`).join("");if(!c)return t;return t.slice(0,l)+c+t.slice(l)}import y from"fs";import M from"path";var E="_stx";function _(t){return Bun.hash(t).toString(16).slice(0,8)}function N(t){let e=[],n=(o)=>{for(let s of y.readdirSync(o,{withFileTypes:!0})){let r=M.join(o,s.name);if(s.isDirectory())n(r);else if(s.isFile()&&r.endsWith(".html"))e.push(r)}};if(y.existsSync(t))n(t);return e}var B=[{pattern:/<script\b([^>]*\bdata-stx-runtime\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"runtime",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(t)=>`<script data-stx-runtime src="${t}"></script>`},{pattern:/<script\b([^>]*\bdata-stx-router\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"router",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(t)=>`<script data-stx-router src="${t}"></script>`},{pattern:/<style\b([^>]*\bdata-css=(?:"generated"|'generated')[^>]*)>([\s\S]*?)<\/style>/gi,prefix:"css",extension:"css",contentType:"text/css; charset=utf-8",replace:(t)=>`<link data-css="generated" rel="stylesheet" href="${t}">`}];function H(t,e=`/${E}`){let n=[],o=new Set,s=0,r=t;for(let a of B)r=r.replace(a.pattern,(u,l,c)=>{if(/(?:^|\s)stx-inline(?:\s|=|$)/i.test(l)||/\b(?:src|href)\s*=/.test(l)||!c.trim())return u;let i=`${a.prefix}.${_(c)}.${a.extension}`;if(!o.has(i))o.add(i),n.push({filename:i,contents:c,contentType:a.contentType});return s+=c.length,a.replace(`${e}/${i}`)});return{html:r,assets:n,bytesInlined:s}}function $c(t){let e={pages:0,assets:0,bytesInlined:0},n=M.join(t,E),o=new Set;for(let s of N(t)){let r=y.readFileSync(s,"utf8"),{html:a,assets:u,bytesInlined:l}=H(r);if(a===r)continue;for(let c of u){if(o.has(c.filename))continue;o.add(c.filename),y.mkdirSync(n,{recursive:!0}),y.writeFileSync(M.join(n,c.filename),c.contents),e.assets++}y.writeFileSync(s,a),e.bytesInlined+=l,e.pages++}return e}import m from"fs";import T from"path";var O=1024,D=/<(script|style)\b([^>]*)>([\s\S]*?)<\/\1>/gi,P=new Set(["","module","text/javascript","application/javascript","module/javascript"]);function W(t){return Bun.hash(t).toString(16).slice(0,8)}function K(t){let e=[],n=(o)=>{for(let s of m.readdirSync(o,{withFileTypes:!0})){let r=T.join(o,s.name);if(s.isDirectory())n(r);else if(s.isFile()&&r.endsWith(".html"))e.push(r)}};if(m.existsSync(t))n(t);return e}function Y(t,e){let n=t.match(new RegExp(`\\b${e}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i"));if(!n)return;return n[2]??n[3]??n[4]??""}function G(t,e,n){if(/(?:^|\s)stx-inline(?:\s|=|$)|\bdata-stx-(?:color-mode-boot|appearance-bootstrap)\b/i.test(e))return!1;if(n.length<O)return!1;if(/\b(?:src|href)\s*=/i.test(e))return!1;if(t.toLowerCase()==="script"){if(!P.has((Y(e,"type")??"").trim().toLowerCase()))return!1;return!0}return!0}function X(t){let e=[];for(let n of t.matchAll(/<template\b[^>]*>[\s\S]*?<\/template>/gi))e.push([n.index,n.index+n[0].length]);return e}function Rc(t){let e={pages:0,assets:0,bytesInlined:0},n=K(t);if(n.length<2)return e;let o=new Map,s=new Map;for(let i of n){let f=m.readFileSync(i,"utf8");o.set(i,f);let R=X(f);for(let g of f.matchAll(D)){let[w,p,d,h]=g;if(!G(p,d,h))continue;if(R.some(([v,A])=>g.index>=v&&g.index<A))continue;let b=`${p.toLowerCase()}\x00${h}`,S=s.get(b);if(S)S.push({file:i,whole:w,tag:p,attrs:d,body:h});else s.set(b,[{file:i,whole:w,tag:p,attrs:d,body:h}])}}let r=[...s.values()].filter((i)=>new Set(i.map((f)=>f.file)).size>1);if(r.length===0)return e;let a=T.join(t,E),u=new Map(o),l=new Map,c=[];for(let i of r){let{tag:f,body:R}=i[0],g=f.toLowerCase()==="script",w=`${g?"chunk":"style"}.${W(R)}.${g?"js":"css"}`;c.push({filename:w,contents:R,contentType:g?"text/javascript; charset=utf-8":"text/css; charset=utf-8"});let p=`/${E}/${w}`;for(let d of i){let h=g?`<script${d.attrs} src="${p}"></script>`:`<link${d.attrs} rel="stylesheet" href="${p}">`,b=u.get(d.file),S=b.replace(d.whole,()=>h);if(S===b)continue;u.set(d.file,S),l.set(d.file,(l.get(d.file)??0)+d.body.length)}}m.mkdirSync(a,{recursive:!0});for(let i of c)m.writeFileSync(T.join(a,i.filename),i.contents),e.assets++;for(let[i,f]of u){if(f===o.get(i))continue;m.writeFileSync(i,f),e.pages++,e.bytesInlined+=l.get(i)??0}return e}import k from"fs";import I from"path";var Z="layout-types.d.ts";function J(t){let e=[],n=(o,s)=>{let r;try{r=k.readdirSync(o,{withFileTypes:!0})}catch{return}for(let a of r){if(a.name.startsWith("."))continue;let u=I.join(o,a.name);if(a.isDirectory())n(u,s?`${s}/${a.name}`:a.name);else if(a.isFile()&&a.name.endsWith(".stx")&&a.name!=="_layout.stx"){let l=a.name.slice(0,-4);e.push(s?`${s}/${l}`:l)}}};return n(t,""),e.sort()}function U(t){let e=["// Auto-generated by stx \u2014 do not edit.","//","// Makes `definePageMeta({ layout })` reject a name with no layout behind it.","// Include this file in your tsconfig (it lives in the stx state directory,","// `.stx/` by default) for the check to apply.",""];if(t.length===0)return e.push("// No layouts found \u2014 `layout` stays typed as `string`.","export {}",""),e.join(`
|
|
3
3
|
`);return e.push("declare module '@stacksjs/stx' {"," interface KnownLayouts {",...t.map((n)=>` '${n}': true`)," }","}","","export {}",""),e.join(`
|
|
4
4
|
`)}function Ac(t,e){if(!t)return[];let n=I.isAbsolute(t)?t:I.resolve(process.cwd(),t),o=J(n),s=U(o),r=I.join(e,Z);try{if(k.existsSync(r)&&k.readFileSync(r,"utf8")===s)return o;k.mkdirSync(e,{recursive:!0}),k.writeFileSync(r,s)}catch{}return o}
|
|
5
5
|
export{Ec,Tc,$c,Rc,Ac};
|