@stacksjs/bun-router 0.1.7 → 0.1.8

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.
Files changed (100) hide show
  1. package/dist/chunk-4wd1d6ay.js +416 -0
  2. package/dist/{chunk-nf3kv7kv.js → chunk-8rrs7556.js} +1 -1
  3. package/dist/{chunk-3y4gaz7v.js → chunk-m4aaj9ay.js} +1 -1
  4. package/dist/cli.js +30 -59
  5. package/dist/container/index.js +1 -1
  6. package/dist/index.js +2 -2
  7. package/package.json +9 -1
  8. package/dist/chunk-03m2j6h7.js +0 -2
  9. package/dist/chunk-08cw7ejr.js +0 -3
  10. package/dist/chunk-0e4g0fyv.js +0 -62
  11. package/dist/chunk-0mmn02yw.js +0 -2
  12. package/dist/chunk-126c9qm3.js +0 -2
  13. package/dist/chunk-12p13817.js +0 -2
  14. package/dist/chunk-14v65c37.js +0 -4
  15. package/dist/chunk-1b6a7t3v.js +0 -231
  16. package/dist/chunk-1wenkmk0.js +0 -2
  17. package/dist/chunk-2152npfd.js +0 -2
  18. package/dist/chunk-26w23krx.js +0 -2
  19. package/dist/chunk-2g8m379z.js +0 -10
  20. package/dist/chunk-2rr178et.js +0 -1654
  21. package/dist/chunk-2w8f3swz.js +0 -29
  22. package/dist/chunk-4r1x4afz.js +0 -12
  23. package/dist/chunk-4wyw66zk.js +0 -2
  24. package/dist/chunk-4z5sf8ag.js +0 -2
  25. package/dist/chunk-58tfvayh.js +0 -4
  26. package/dist/chunk-5be9x5cq.js +0 -3
  27. package/dist/chunk-5dp83qcx.js +0 -397
  28. package/dist/chunk-5f0d9j9a.js +0 -2
  29. package/dist/chunk-5z52b0fc.js +0 -28
  30. package/dist/chunk-5zrnk2kq.js +0 -4
  31. package/dist/chunk-6bbmkwng.js +0 -3
  32. package/dist/chunk-6dmqtdnq.js +0 -2
  33. package/dist/chunk-6e91956t.js +0 -3
  34. package/dist/chunk-6rv8w5jk.js +0 -2
  35. package/dist/chunk-6x1feysm.js +0 -3
  36. package/dist/chunk-7qnxdedn.js +0 -321
  37. package/dist/chunk-7y72hm1x.js +0 -2
  38. package/dist/chunk-8hbhfh6b.js +0 -194
  39. package/dist/chunk-8kfzygg5.js +0 -3
  40. package/dist/chunk-8wpj3fqe.js +0 -351
  41. package/dist/chunk-8wydx2we.js +0 -2
  42. package/dist/chunk-8zjnjvv7.js +0 -2
  43. package/dist/chunk-9805tt8n.js +0 -341
  44. package/dist/chunk-988h4bzr.js +0 -2
  45. package/dist/chunk-9b6a58ac.js +0 -2
  46. package/dist/chunk-a8fcaywb.js +0 -2
  47. package/dist/chunk-bfjwn7yg.js +0 -2
  48. package/dist/chunk-bp2522mm.js +0 -2
  49. package/dist/chunk-brpgjyqg.js +0 -3
  50. package/dist/chunk-bswe62q4.js +0 -48
  51. package/dist/chunk-c3v796c8.js +0 -943
  52. package/dist/chunk-ccqmwdry.js +0 -2
  53. package/dist/chunk-ck0crwnx.js +0 -2
  54. package/dist/chunk-cqgkxcb4.js +0 -2
  55. package/dist/chunk-dntnakjy.js +0 -2
  56. package/dist/chunk-dxg045wj.js +0 -5
  57. package/dist/chunk-e3qej0jr.js +0 -4
  58. package/dist/chunk-ettdpnrw.js +0 -60
  59. package/dist/chunk-ezqwq17j.js +0 -185
  60. package/dist/chunk-ezx3qsez.js +0 -2
  61. package/dist/chunk-f72nnjy4.js +0 -15413
  62. package/dist/chunk-fna5n0ey.js +0 -246
  63. package/dist/chunk-fqhckdt8.js +0 -2
  64. package/dist/chunk-fr6hbx25.js +0 -2
  65. package/dist/chunk-g9cwng6w.js +0 -3
  66. package/dist/chunk-gd3za5x0.js +0 -2
  67. package/dist/chunk-gf28608k.js +0 -2
  68. package/dist/chunk-h1dj6v8q.js +0 -3
  69. package/dist/chunk-hjxe7k2g.js +0 -2
  70. package/dist/chunk-hrkgznbn.js +0 -2
  71. package/dist/chunk-j6h5v0br.js +0 -2
  72. package/dist/chunk-kjtjbcq4.js +0 -71
  73. package/dist/chunk-mgb01qdv.js +0 -14
  74. package/dist/chunk-n24c9whp.js +0 -2
  75. package/dist/chunk-n2j24b0h.js +0 -4540
  76. package/dist/chunk-nhmtg01n.js +0 -84
  77. package/dist/chunk-p0qhpnqh.js +0 -70
  78. package/dist/chunk-p0w1x8y2.js +0 -3
  79. package/dist/chunk-p3dk1w2w.js +0 -216
  80. package/dist/chunk-q4e9pxs7.js +0 -3
  81. package/dist/chunk-q5dv1kyy.js +0 -2
  82. package/dist/chunk-qnqgf9tq.js +0 -2
  83. package/dist/chunk-qvwy1808.js +0 -898
  84. package/dist/chunk-r18f77vc.js +0 -12
  85. package/dist/chunk-r63za1mr.js +0 -2
  86. package/dist/chunk-rft8gw92.js +0 -7851
  87. package/dist/chunk-ryvmyskt.js +0 -4211
  88. package/dist/chunk-sa6mx308.js +0 -2
  89. package/dist/chunk-sw0chtw4.js +0 -4
  90. package/dist/chunk-va0pc7hx.js +0 -2
  91. package/dist/chunk-vcp8dnjq.js +0 -412
  92. package/dist/chunk-vg1erq1q.js +0 -2
  93. package/dist/chunk-vsh4390q.js +0 -358
  94. package/dist/chunk-w0jv49ch.js +0 -11
  95. package/dist/chunk-wm805tte.js +0 -35
  96. package/dist/chunk-xg9xscqz.js +0 -1
  97. package/dist/chunk-xj9h6mc9.js +0 -2
  98. package/dist/chunk-ytvzwrq3.js +0 -51
  99. package/dist/chunk-zde7ebc4.js +0 -288
  100. package/dist/chunk-zmqsv2xy.js +0 -2
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{$s as H,$t as Ia,As as g,At as ha,Bs as h,Bt as ia,Cs as i,Ct as ja,Ds as j,Dt as ka,Es as k,Et as la,Fs as l,Ft as ma,Gs as m,Gt as na,Hs as n,Ht as oa,Is as o,It as pa,Js as p,Jt as qa,Ks as q,Kt as ra,Ls as r,Lt as sa,Ms as s,Mt as ta,Ns as t,Nt as ua,Os as u,Ot as va,Ps as v,Pt as wa,Qs as w,Qt as xa,Rs as x,Rt as ya,Ss as y,St as za,Ts as z,Tt as Aa,Us as A,Ut as Ba,Vs as B,Vt as Ca,Ws as C,Wt as Da,Xs as D,Xt as Ea,Ys as E,Yt as Fa,Zs as F,Zt as Ga,_s as G,_t as Ha,at as I,au as Ja,bt as J,bu as Ka,ct as K,cu as La,dt as L,du as Ma,et as M,eu as Na,ft as N,fu as Oa,gt as O,gu as Pa,ht as P,hu as Qa,it as Q,iu as Ra,jt as R,ju as Sa,kt as S,ku as Ta,lt as T,mt as U,nt as V,ot as W,pt as X,qt as Y,rt as Z,st as _,tt as aa,us as a,ut as ba,vs as b,vt as ca,ws as c,wt as da,xs as d,xt as ea,ys as e,yt as fa,zs as f,zt as ga}from"./chunk-fna5n0ey.js";import"./chunk-nf3kv7kv.js";export{aa as KERNELS,Ma as SPLATHASH_TARGET_SIZE,Ia as _internals,w as analyzeImage,s as applyExifOrientation,P as applyWatermark,N as batchProcessImages,U as blur,V as boxBlur,b as cloneImageData,qa as composite,ra as compositeMultiple,y as config,ga as contrast,M as convertImageFormat,Y as convolve,a as createImageData,ta as createLinearGradient,sa as createSolidColor,n as crop,D as debugLog,t as decode,_ as emboss,u as encode,p as extend,o as extract,C as filterPaths,l as flip,m as flop,F as formatBytes,f as fromCodecData,ha as gamma,Fa as generateAppIcons,Ha as generateFavicons,Ea as generateIOSAppIcons,La as generateImageSet,Da as generateMacOSAppIcons,Ta as generatePictureSet,L as generatePlaceholder,x as generateReport,Ka as generateResponsiveImages,Ja as generateSocialImages,Ga as generateSprite,Ca as generateThumbHash,ka as getDominantColor,z as getFiles,v as getMetadata,c as getPixel,e as getPixelBilinear,ba as grayscale,ma as hslToRgb,Oa as imageToSplatHash,K as imageToSvg,ea as invert,B as isPathMatching,r as jpegExifOrientation,oa as linearToSrgb,da as modulate,ia as normalize,O as optimizeImage,J as optimizeSvg,E as parseFileSize,G as printSummary,ua as process,H as processImage,va as processMultiple,I as processSvg,T as resize,Q as resizeBicubic,R as resizeBilinear,S as resizeLanczos,la as rgbToHsl,Aa as rgbaToDataURL,Na as rgbaToSplatHash,wa as rgbaToThumbHash,h as rotate,j as rotate180,k as rotate270,i as rotate90,fa as sepia,d as setPixel,W as sharpen,X as sharpenConvolution,Z as sobelEdgeDetection,Ra as splatHashFromBase64,Qa as splatHashToBase64,Sa as splatHashToDataURL,Pa as splatHashToRgba,na as srgbToLinear,ca as threshold,za as thumbHashToApproximateAspectRatio,ya as thumbHashToAverageRGBA,Ba as thumbHashToDataURL,xa as thumbHashToRGBA,ja as tint,g as toCodecData,pa as toColorSpace,q as trim,A as watchFiles};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{We as o,Xe as p,Ye as q}from"./chunk-rft8gw92.js";import{cf as a,df as b,ef as c,ff as d,gf as e,hf as f,if as g,jf as h,kf as i,lf as j,mf as k,nf as l,of as m,pf as n}from"./chunk-p0w1x8y2.js";import"./chunk-brpgjyqg.js";import"./chunk-nf3kv7kv.js";export{d as batch,q as default,b as derived,c as effect,o as generateSignalsRuntime,p as generateSignalsRuntimeDev,k as isDerived,j as isSignal,f as onDestroy,e as onMount,m as peek,i as pendingLifecycleCounts,h as runDestroyCallbacks,g as runMountCallbacks,a as state,l as untrack,n as useOptimistic};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{dj as a,ej as b,fj as c,gj as d,hj as e,ij as f}from"./chunk-ryvmyskt.js";import"./chunk-2g8m379z.js";import"./chunk-ezqwq17j.js";import"./chunk-wm805tte.js";import"./chunk-58tfvayh.js";import"./chunk-brpgjyqg.js";import"./chunk-2rr178et.js";import"./chunk-5be9x5cq.js";import"./chunk-5zrnk2kq.js";import"./chunk-p0qhpnqh.js";import"./chunk-nf3kv7kv.js";export{d as config,a as defaultConfig,e as defineStxConfig,c as loadStxConfig,b as resolveStxDirectories,f as validateConfig};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{jj as c,kj as d,lj as e,mj as f,nj as g,oj as h,pj as i,qg as a,qj as j,rg as b,rj as k}from"./chunk-ryvmyskt.js";import"./chunk-2g8m379z.js";import"./chunk-ezqwq17j.js";import"./chunk-wm805tte.js";import"./chunk-58tfvayh.js";import"./chunk-brpgjyqg.js";import"./chunk-2rr178et.js";import"./chunk-5be9x5cq.js";import"./chunk-5zrnk2kq.js";import"./chunk-p0qhpnqh.js";import"./chunk-nf3kv7kv.js";export{e as STX_AUTO_IMPORTS,c as extractAndStripCssImports,i as extractBridgeData,a as findInterpolationEnd,g as generateAutoImportDestructuring,h as generateBrowserAutoImportDestructuring,j as generateServerDataBridge,f as injectBrowserCoreAutoImports,k as processClientScript,d as renderVendorStyleTags,b as stripCommentsAndLiterals};
@@ -1,3 +0,0 @@
1
- // @bun
2
- var n=["batch","computed","configureFetch","defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","defineStore","derived","effect","goBack","goForward","inject","invalidateRoute","isDerived","isSignal","navigate","nextTick","onBeforeMount","onBeforeUnmount","onDestroy","onMount","onMounted","onUnmounted","peek","provide","reactive","ref","refresh","registerStoresClient","setRouteParams","state","untrack","useAsync","useClickOutside","useColorMode","useCookie","useCounter","useDark","useDebounce","useDebouncedValue","useEventListener","useFetch","useFocus","useHead","useId","useInterval","useLocalStorage","useMediaQuery","useMutation","useOptimistic","usePreferredContrast","usePreferredDark","usePreferredLight","usePreferredReducedMotion","useQuery","useReactiveProp","useRef","useRoute","useRouteParam","useRouteParams","useScrollLock","useSearchParams","useSeoMeta","useSessionStorage","useSlots","useStore","useThrottle","useTimeout","useToggle","useWebSocket","watch","watchEffect","watchMultiple","withDefaults"],g=["onMount","onDestroy"];function T(e="const",t=[],s){let r=t.length?n.filter((o)=>!t.includes(o)):n;if(s!==void 0)r=r.filter((o)=>{let i=o.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(^|[^\\w$])${i}(?![\\w$])`).test(s)});return`${e} { ${r.join(", ")} } = window.stx;`}var c=["defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","withDefaults"];var l=n.filter((e)=>!c.includes(e));function d(e){if(!e)return!1;return l.some((t)=>new RegExp(`\\b${t}\\s*(?:<[^>]*>)?\\s*\\(`).test(e))}var p=[/@if\s*=/,/@for\s*=/,/@show\s*=/,/@model\s*=/,/@bind:/,/@class\s*=/,/@style\s*=/,/\bx-data\s*=/,/\bstate\s*(?:<[^>]*>)?\s*\(/,/\bderived\s*(?:<[^>]*>)?\s*\(/,/\beffect\s*(?:<[^>]*>)?\s*\(/,/\bref\s*(?:<[^>]*>)?\s*\(/,/\bcomputed\s*(?:<[^>]*>)?\s*\(/,/\breactive\s*(?:<[^>]*>)?\s*\(/,/\bwatch\s*(?:<[^>]*>)?\s*\(/,/\bwatchEffect\s*(?:<[^>]*>)?\s*\(/,/\s:[a-z][\w-]*\s*=\s*["']/i,/\s:(?:if|else-if|else|for|show|text|html|model)\s*=/,/data-stx(?:-auto)?(?![-\w])/,/data-stx-scoped/],f=/\s@[a-z][\w.:-]*\s*=/i;function m(e){if(!e)return!1;let t=u(e);if(p.some((s)=>s.test(t)))return!0;return d(t)}function h(e){if(!e)return!1;return f.test(u(e))||m(e)}var x=["if","else-if","elseif","else","for","show","key","text","html","model","ref"];function S(e){return x.includes(e.toLowerCase())}var a=["x-text","x-html","x-model","x-show","x-if","x-for","x-cloak","x-ref","x-data","x-bind","x-class","x-style","x-tooltip","x-tooltip-position"],b=["x-init","x-transition","x-effect","x-on"],v=[...a,...b];function E(){return`{${a.map((e)=>`'${e}':1`).join(",")}}`}function u(e){if(!e)return e;let t=(s)=>s.replace(/(<[^>]*>)|([^<]+)/g,(r,o,i)=>o??" ".repeat(i.length));return e.replace(/(<pre\b[^>]*>)([\s\S]*?)(<\/pre>)/gi,(s,r,o,i)=>r+t(o)+i).replace(/(<code\b[^>]*>)([\s\S]*?)(<\/code>)/gi,(s,r,o,i)=>r+t(o)+i).replace(/<!--[\s\S]*?-->/g,(s)=>" ".repeat(s.length))}
3
- export{n as Un,g as Vn,T as Wn,d as Xn,m as Yn,h as Zn,S as _n,v as $n,E as ao};
@@ -1,48 +0,0 @@
1
- // @bun
2
- import{We as J,Xe as Q}from"./chunk-rft8gw92.js";import{Ll as Ct,Zl as Dt,bm as st,dj as bt,em as Pt,fj as I,fm as Mt,rg as j,sj as yt,uj as $t,xm as _t,yj as it,zj as rt}from"./chunk-ryvmyskt.js";import{in as Rt}from"./chunk-2g8m379z.js";import{Un as V}from"./chunk-brpgjyqg.js";import{Lo as q}from"./chunk-2rr178et.js";import{Zu as kt}from"./chunk-nf3kv7kv.js";import v from"fs";import g from"path";import Z from"fs";import Ot from"path";var k="resources/assets",K="assets";function z(t=process.cwd()){let n=Ot.resolve(t,k);return Z.existsSync(n)&&Z.statSync(n).isDirectory()?n:null}import{createHash as jt}from"crypto";function tt(t){return jt("sha256").update(t).digest("hex").slice(0,8)}function et(t=!1){let n=t?Q():J(),i=tt(n);return{content:n,filename:`runtime.${i}.js`,hash:i}}function nt(){let t=q(),n=tt(t);return{content:t,filename:`router.${n}.js`,hash:n}}function ge(t){return{runtimeTag:t.runtime?`<script src="/__stx/${t.runtime.filename}"></script>`:"",routerTag:t.router?`<script src="/__stx/${t.router.filename}"></script>`:"",cssTag:t.css?`<link rel="stylesheet" href="/__stx/${t.css.filename}">`:""}}import St from"path";import B from"path";var It=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function Lt(t,n,i){let e={fullTag:i,content:n,attrs:t};if(/\bserver\b/.test(t))return{...e,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...e,type:"client"};if(It.test(n))return{...e,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...e,type:"client"};return{...e,type:"server"}}var Nt=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function ot(t){let n=[],i=[],e=[],r=0;while(r<t.length){let a=t.indexOf("<",r);if(a===-1)break;let c=rt(t,a);if(c>a){r=c;continue}let s=it(t,a);if(s>a){let o=t.slice(a,s),p=Nt.exec(o);if(p){let l=Lt(p[1],p[2],o);switch(l.type){case"signals":n.push(l);break;case"client":i.push(l);break;case"server":e.push(l);break}}r=s;continue}r=a+(t.startsWith("<!--",a)?4:1)}return{signals:n,client:i,server:e}}var{require:Bt}=import.meta,Ft="stx-page-head:",Ht=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,D=null;function Vt(){if(D!==null)return D;try{let{getRouterScript:t}=Bt("stx-router");D=`<script>${t()}</script>`}catch{D=""}return D}async function ve(t,n){if(n===!1)return null;if(n&&typeof n==="string"){let e=B.resolve(t,n);if(await Bun.file(e).exists())return e;return null}let i=B.join(t,"app.stx");if(await Bun.file(i).exists())return i;return null}async function Ee(t,n){try{let i=await Bun.file(t).text(),e=i,r=i.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(r)e=r[1].trim();let a=ot(i),c=[...a.client.map((d)=>d.fullTag),...a.signals.map((d)=>d.fullTag)],s=[],o=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,p;while((p=o.exec(i))!==null)s.push(p[0]);let l=e;for(let d of a.server)l=l.replace(d.fullTag,"");for(let d of a.client)l=l.replace(d.fullTag,"");l=l.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let f="<!--__STX_PAGE_SLOT__-->";if(l=l.replace(/<slot\s*\/>/gi,f).replace(/<slot\s*>\s*<\/slot>/gi,f),!l.includes(f))return console.warn(`[stx] Shell ${t} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:m,extractVariables:b,defaultConfig:E,loadStxConfig:T}=await import("./chunk-n2j24b0h.js"),y=await T(),x={__filename:t,__dirname:B.dirname(t)};for(let d of c){let w=d.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(w&&!d.includes("client")&&!d.includes('type="module"'))await b(w[1],x,t)}let _=await m(l,x,t,{...E,...y,...n},new Set),S=_.indexOf(f);if(S===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:_.substring(0,S),afterSlot:_.substring(S+f.length),filePath:t,shellScripts:c,shellStyles:s}}catch(i){return console.error(`[stx] Error processing shell ${t}:`,i),null}}function Ae(t,n,i){let e,r="",a=n.match(Ht);if(a){n=n.replace(a[0],"");try{let p=Buffer.from(a[1],"base64").toString("utf8"),l=p.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(l)e=l[1].trim();r=p.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let c=i||e||"stx App",s=Vt(),o="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
3
- <html lang="en">
4
- <head>
5
- <meta charset="UTF-8">
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <title>${c}</title>
8
- ${r?` ${r}
9
- `:""} ${t.shellStyles.join(`
10
- `)}
11
- </head>
12
- <body>
13
- ${t.beforeSlot}
14
- <div data-stx-content>${n}</div>
15
- ${t.afterSlot}
16
- ${t.shellScripts.filter((p)=>!p.includes("server")).join(`
17
- `)}
18
- ${o}
19
- ${s}
20
- </body>
21
- </html>`}function P(t,n={}){let i=t.trim();if(!st(i))return t;let e=[],r=i.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(r){let o=r[1],p=/<style\b[^>]*>[\s\S]*?<\/style>/gi,l;while((l=p.exec(o))!==null)e.push(l[0])}if(n.preserveHead&&r){let o=[],p=/<title\b[^>]*>[\s\S]*?<\/title>|<meta\b[^>]*>|<link\b[^>]*>/gi,l;while((l=p.exec(r[1]))!==null){if(/<meta\b[^>]*(?:\bcharset|name="viewport")/i.test(l[0]))continue;o.push(l[0])}if(o.length>0)e.unshift(`<!--${Ft}${Buffer.from(o.join(`
22
- `),"utf8").toString("base64")}-->`)}let a=i.match(/<body\b[^>]*>/i),c=i.lastIndexOf("</body>");if(a&&c!==-1){let o=a.index+a[0].length,p=i.slice(o,c).trim();if(e.length>0)return e.join(`
23
- `)+`
24
- `+p;return p}let s=i;if(s=s.replace(/<!DOCTYPE\b[^>]*>/i,""),s=s.replace(/<html\b[^>]*>/i,""),s=s.replace(/<\/html\s*>/i,""),r)s=s.replace(/<head\b[^>]*>[\s\S]*?<\/head>/i,e.join(`
25
- `));return s=s.replace(/<body\b[^>]*>/i,""),s=s.replace(/<\/body\s*>/i,""),s.trim()}function Re(t){return t.headers.get("X-STX-Router")==="true"}function lt(t,n="main"){let i=t.trim(),e=[],r=[],a=i.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(a){let S=a[1],d=/<style\b[^>]*>[\s\S]*?<\/style>/gi,w;while((w=d.exec(S))!==null)e.push(w[0]);let A=/<script\b[^>]*data-stx-route-params[^>]*>[\s\S]*?<\/script>/gi;while((w=A.exec(S))!==null)r.push(w[0])}let c=n.replace(/^[.#]/,"").toLowerCase(),s=new RegExp(`<${c}\\b[^>]*>`,"i"),o=i.match(s);if(!o||o.index===void 0)return P(t);let p=o.index+o[0].length,l=new RegExp(`<${c}\\b[^>]*>`,"gi"),f=new RegExp(`</${c}\\s*>`,"gi");l.lastIndex=p,f.lastIndex=p;let m=1,b=-1;while(m>0){let S=l.exec(i),d=f.exec(i);if(!d)break;if(S&&S.index<d.index)m++,f.lastIndex=S.index+S[0].length;else if(m--,b=d.index,m>0)l.lastIndex=d.index+d[0].length}if(b===-1)return P(t);let E=i.slice(p,b).trim(),T=[],y=i.match(/<body\b[^>]*>/i),x=i.lastIndexOf("</body>");if(y&&y.index!==void 0&&x!==-1){let S=[[y.index+y[0].length,o.index],[b+`</${c}>`.length,x]],d=/<script\b[^>]*>[\s\S]*?<\/script>/gi;for(let[w,A]of S){if(w>=A)continue;let L=i.slice(w,A),C;d.lastIndex=0;while((C=d.exec(L))!==null)T.push(C[0])}}let _=[];if(e.length>0)_.push(e.join(`
26
- `));if(r.length>0)_.push(r.join(`
27
- `));if(T.length>0)_.push(T.join(`
28
- `));return _.push(E),_.join(`
29
- `)}import{createHash as ce}from"crypto";var ct=/<script(\s[^>]*)?>([\s\S]*?)<\/script>/gi;function Gt(t){let n=(i)=>i.replace(/[^\n]/g," ");return t.replace(/<!--[\s\S]*?-->/g,n).replace(/\{\{--[\s\S]*?--\}\}/g,n)}function Xt(t){let n=[],i=Gt(t);ct.lastIndex=0;let e;while((e=ct.exec(i))!==null){let r=(e[1]||"").trim(),a=(e[0].match(/^<script(?:\s[^>]*)?>/i)?.[0]??"<script>").length,c=(e[0].match(/<\/script\s*>$/i)?.[0]??"</script>").length,s=e.index+a,o=e.index+e[0].length-c,p=t.slice(s,o);if(/\bsrc\s*=/.test(r))continue;let l=r.match(/\btype\s*=\s*["']([^"']+)["']/i);if(l&&!/^(?:module|text\/(?:javascript|typescript))$/i.test(l[1]))continue;let f=/\bserver\b/.test(r)?"server":/\bclient\b/.test(r)?"client":"plain",m=M(t,s);n.push({kind:f,code:p,startLine:m,attrs:r})}return n}function M(t,n){let i=1;for(let e=0;e<n&&e<t.length;e++)if(t.charCodeAt(e)===10)i++;return i}function F(t,n){let i=t.lastIndexOf(`
30
- `,n-1)+1;return n-i+1}function mt(t){let n=t.split(""),i=(r,a)=>{for(let c=r;c<a&&c<n.length;c++)if(n[c]!==`
31
- `)n[c]=" "},e=[/<script(?:\s[^>]*)?>[\s\S]*?<\/script>/gi,/<style(?:\s[^>]*)?>[\s\S]*?<\/style>/gi,/<!--[\s\S]*?-->/g,/\{\{--[\s\S]*?--\}\}/g,/@verbatim\b[\s\S]*?@endverbatim\b/g];for(let r of e){r.lastIndex=0;let a;while((a=r.exec(t))!==null)i(a.index,a.index+a[0].length)}return n.join("")}function Wt(t){let n=0,i="";for(let e=0;e<t.length;e++){let r=t[e];if(i){if(r==="\\"){e++;continue}if(r===i)i="";continue}if(r==='"'||r==="'"||r==="`"){i=r;continue}if(r==="("||r==="["||r==="{"){n++;continue}if(r===")"||r==="]"||r==="}"){n--;continue}if(r==="|"&&n===0){if(t[e+1]==="|"){e++;continue}if(t[e-1]==="|")continue;return t.slice(0,e)}}return t}var ht=new Set([":for","x-for","v-for"]),O=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,H="__stx_interpolated",at="__StxElement",xt="__StxTemplateValue",Ut=`type ${xt}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function pt(t){return t.replace(/\{\{[\s\S]*?\}\}/g,H).replace(/\{!![\s\S]*?!!\}/g,H)}function Oe(t){return t.replace(/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/g,(n)=>{let i=n.split(`
32
- `).length-1,e=n.length-i;return`0${" ".repeat(Math.max(0,e-1))}${`
33
- `.repeat(i)}`})}var Yt=["foreach","endforeach","forelse","endforelse","for","endfor","while","endwhile","empty","if","elseif","else","endif","unless","endunless","isset","endisset","switch","case","default","endswitch","auth","endauth","guest","endguest","env","endenv","once","endonce","break","continue"],Zt=new RegExp(String.raw`^[ \t]*@(?:${Yt.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");function je(t){return t.replace(Zt,(n)=>n.replace(/[^\n]/g," "))}var ut=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);function Kt(t){let n=mt(t),i=[],e=/(@?)\{\{([\s\S]*?)\}\}|(@?)\{!!([\s\S]*?)!!\}/g,r;while((r=e.exec(n))!==null){if(r[1]||r[3])continue;let a=r[2]??r[4]??"",c=r[2]!==void 0?2:3,s=Wt(a);if(!s.trim())continue;let o=r.index+c+(s.length-s.trimStart().length);i.push({code:s.trim(),line:M(n,o),column:F(n,o),kind:"interpolation"})}O.lastIndex=0;while((r=O.exec(n))!==null){let a=r[1],c=r[3]??"",s=a.replace(/\..*$/,"").replace(/^([^:].*?):.*$/,"$1");if(ut.has(s)||ut.has(a))continue;if(!c.trim())continue;let o=r.index+r[0].indexOf(r[2],r[0].indexOf(a)+a.length)+1;if(ht.has(s)){let l=c.match(/\s+(?:in|of)\s+/);if(!l||l.index===void 0)continue;let f=c.slice(l.index+l[0].length),m=l.index+l[0].length+(f.length-f.trimStart().length);i.push({code:pt(f.trim()),line:M(n,o+m),column:F(n,o+m),kind:"directive",attribute:s});continue}let p=c.length-c.trimStart().length;i.push({code:pt(c.trim()),line:M(n,o+p),column:F(n,o+p),kind:"directive",attribute:s})}return i.sort((a,c)=>a.line-c.line||a.column-c.column),i}function zt(t){let n=new Map,i=(s,o)=>{let p=s.split(/[,[\]{}()\s]+/).filter(Boolean);for(let l of p){let f=l.replace(/^\.\.\./,"").trim();if(!/^\$?[A-Z_$][\w$]*$/i.test(f))continue;let m=p.length===1?o:void 0,b=n.get(f);if(!b)n.set(f,{name:f,iterable:m});else if(b.iterable!==m)b.iterable=void 0}},e=/^\$?[A-Z_$][\w$]*$/i,r=(s)=>{let o=s.trim();return e.test(o)?o:void 0};for(let s of t.matchAll(/@for(?:each|else)\s*\(([\s\S]*?)\)/g)){let o=s[1].match(/^([\s\S]*?)\bas\b([\s\S]*)$/);if(!o)continue;i(o[2].replace(/=>/g," "),r(o[1]))}for(let s of t.matchAll(/@for\s*\(\s*(?:let|const|var)\s+([\w$]+)/g))i(s[1]);let a=mt(t);O.lastIndex=0;let c;while((c=O.exec(a))!==null){let s=c[1].replace(/\..*$/,"");if(!ht.has(s))continue;let o=c[3].match(/\s+(?:in|of)\s+/);if(!o||o.index===void 0)continue;i(c[3].slice(0,o.index),r(c[3].slice(o.index+o[0].length)))}for(let s of t.matchAll(/@(?:php|js|ts)\b([\s\S]*?)@end(?:php|js|ts)\b/g))for(let o of s[1].matchAll(/\b(?:const|let|var|function|class)\s+([\w$]+)/g))i(o[1]);return[...n.values()].sort((s,o)=>s.name.localeCompare(o.name))}function R(t){let n=new Set;for(let i of t.matchAll(/^\s*(?:export\s+)?(?:const|let|var)\s+([\w$]+)/gm))n.add(i[1]);for(let i of t.matchAll(/^\s*(?:export\s+)?(?:async\s+)?function\s*\*?\s*([\w$]+)/gm))n.add(i[1]);for(let i of t.matchAll(/^\s*(?:export\s+)?class\s+([\w$]+)/gm))n.add(i[1]);for(let i of t.matchAll(/^\s*(?:export\s+)?(?:const|let|var)\s*[[{]([^\]}]*)[\]}]/gm))for(let e of i[1].split(",")){let r=e.split(":").pop().split("=")[0].replace(/^\.\.\./,"").trim();if(/^[A-Z_$][\w$]*$/i.test(r))n.add(r)}return[...n].sort()}function qt(){return["declare var window: any",...V.map((t)=>`declare var ${t}: any`)].join(`
34
- `)}var Jt=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore"];function Qt(){return Jt.map((t)=>`declare var ${t}: any`).join(`
35
- `)}function gt(t){let n=/\bdefineClientPayload\s*\(\s*\{([\s\S]*?)\}\s*\)/g,i,e=!1,r=new Set,a=j(t);while((i=n.exec(a))!==null){e=!0;for(let c of te(i[1])){let s=c.split(":")[0].trim();if(/^[A-Za-z_$][\w$]*$/.test(s))r.add(s)}}return e?[...r]:null}function te(t){let n=[],i=0,e="";for(let r of t){if(r===","&&i===0){n.push(e),e="";continue}if(r==="("||r==="["||r==="{")i++;else if(r===")"||r==="]"||r==="}")i--;e+=r}return n.push(e),n.filter((r)=>r.trim().length>0)}function ee(t){let n=/^[ \t]*import\b[\s\S]*?(?:from\s*['"][^'"]*['"]|['"][^'"]*['"])[ \t]*;?[ \t]*$/gm,i=[],e=t.replace(n,(r)=>(i.push(r.trim()),r.split(`
36
- `).map(()=>"").join(`
37
- `)));return{imports:i.join(`
38
- `),body:e}}function Ie(t){let n=gt(t);if(!n){let c=R(t);if(c.length===0)return"";return["",`// ${re}`,...c.map((s)=>`declare var ${s}: any`)].join(`
39
- `)}if(n.length===0)return"";let{imports:i,body:e}=ee(t),r=e.replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class)\b)/gm,""),a=["",`// ${ie}`];if(i)a.push(i);return a.push(`async function ${ft}() {`,r,` return { ${n.join(", ")} }`,"}",`type ${dt} = Awaited<ReturnType<typeof ${ft}>>`,...n.map((c)=>`declare var ${c}: ${dt}[${JSON.stringify(c)}]`)),a.join(`
40
- `)}function ne(t){let n=j(t).split(""),i=0;for(let e=0;e<n.length;e++){let r=n[e];if(r==="{"||r==="("||r==="["){i++;continue}if(r==="}"||r===")"||r==="]"){i=Math.max(0,i-1);continue}if(i>0&&r!==`
41
- `)n[e]=" "}return R(n.join(""))}function Le(t,n){if(gt(t)!==null)return[];let i=j(n),e=new Set(V);return ne(t).filter((r)=>{if(e.has(r))return!1;if(R(n).includes(r))return!1;return new RegExp(`(?<![.#\\w$])${r}(?![\\w$])`).test(i)})}var ie="stx: types for the declared client payload (#1868)",re="stx: untyped bridge names \u2014 declare a defineClientPayload to check these (#1868)",ft="__stxServerScope",dt="__StxClientPayload";var oe=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","$errors","$csrf","props","slot"];var se=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;function le(t){let n=t.code.trim();if(!n)return null;if(t.attribute?.startsWith("@")){if(se.test(n))return null;let e=";(($event: any): void => { ";return{text:`${e}${n} });`,prefixLength:e.length}}let i=";void ((";return{text:`${i}${n}));`,prefixLength:i.length}}function Ne(t,n={}){let i=Xt(t),e=t.split(`
42
- `),r=Array.from({length:e.length},()=>""),a=new Map;for(let s of i)s.code.split(`
43
- `).forEach((o,p)=>{let l=s.startLine-1+p;if(l<r.length)r[l]=o});let c=(s,o)=>{if(r.push(s),o)a.set(r.length,o)};if(n.globals!==!1){if(c(""),n.runtimeGlobals!==!1)for(let o of qt().split(`
44
- `))c(o);for(let o of Qt().split(`
45
- `))c(o);for(let o of oe)c(`declare var ${o}: any`);c(`declare var ${H}: any`);let s=new Set(i.flatMap((o)=>R(o.code)));c(`type ${at}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);for(let o of zt(t)){if(s.has(o.name))continue;let p=o.iterable&&s.has(o.iterable)?`${at}<typeof ${o.iterable}>`:"any";c(`declare var ${o.name}: ${p}`)}}if(n.templateExpressions!==!1){let s=Kt(t).map((o)=>({expression:o,statement:le(o)})).filter((o)=>o.statement!==null);if(s.length>0){let o=[...new Set(i.flatMap((l)=>R(l.code)))].filter((l)=>/^[A-Z_$][\w$]*$/i.test(l)),p=0;if(o.length>0){c(Ut);for(let l of o)c(`type __StxT_${l} = ${xt}<typeof ${l}>`);c(`;((${o.map((l)=>`${l}: __StxT_${l}`).join(", ")}) => {`),p=1}for(let{expression:l,statement:f}of s){let m=" ".repeat(p);c(m+f.text,{line:l.line,column:l.column,expression:l,prefixLength:f.prefixLength+m.length})}if(p>0)c("});")}}return c("export {}"),{text:r.join(`
46
- `),lineMap:a,sourceLineCount:e.length}}function ke(t,n,i){let e=t.lineMap.get(n);if(!e)return n<=t.sourceLineCount?{line:n,column:i}:null;let r=Math.max(0,i-1-(e.prefixLength??0));return{line:e.line,column:e.column+r,expression:e.expression}}function ae(t={}){let n=new Set;return{context:new Proxy(t,{get(i,e){if(e in i)return i[e];if(typeof e==="string"&&!e.startsWith("__"))n.add(e);return},has(i,e){if(e in i)return!0;if(typeof e==="string"&&!e.startsWith("__"))n.add(e);return!1}}),accessedKeys:n}}async function wt(t,n,i={}){let e=St.resolve(t),r=await Bun.file(e).text(),a=ce("sha256").update(r).digest("hex").slice(0,16);yt();let c={};try{c=await I()}catch{}let s=[],o=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,p;while((p=o.exec(r))!==null){let x=p[1];if(/\bserver\b/.test(x))s.push(p[2])}let l=new Set(s.flatMap((x)=>R(x))),{context:f}=ae({__filename:e,__dirname:St.dirname(e),__stx_serverDeclared:l}),m=new Set,b={...bt,...c,...i,buildMode:"compile",strict:!1},E=await _t(r,f,e,b,m),T=P(E),y=$t();return{route:n,sourceFile:t,html:E,fragment:T,placeholders:y,hasServerScripts:s.length>0,serverScriptContent:s,dependencies:Array.from(m),contentHash:a,streamTemplates:f.__streamTemplates}}import G from"fs";import Tt from"path";function vt(t,n,i){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:i}}function Et(t,n){let i=Tt.join(n,"manifest.json");G.writeFileSync(i,JSON.stringify(t,null,2))}function Qe(t){let n=Tt.join(t,"manifest.json");if(!G.existsSync(n))return null;try{let i=G.readFileSync(n,"utf-8"),e=JSON.parse(i);if(e.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${e.version}`),null;return e}catch(i){return console.warn("[stx] Failed to load manifest:",i),null}}var pe=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function At(t,n){let i=0,e=0;if(!v.existsSync(t))return{copied:i,bytes:e};v.mkdirSync(n,{recursive:!0});function r(a,c){let s=v.readdirSync(a,{withFileTypes:!0});for(let o of s){if(pe.has(o.name))continue;let p=g.join(a,o.name),l=g.join(c,o.name);if(o.isDirectory())v.mkdirSync(l,{recursive:!0}),r(p,l);else if(o.isFile()){if(v.existsSync(l))continue;v.copyFileSync(p,l),i++,e+=v.statSync(l).size}}}return r(t,n),{copied:i,bytes:e}}async function mn(t={}){let n=Date.now(),i=g.resolve(t.root||process.cwd()),e=g.resolve(i,t.outputDir||".output");console.log("[stx build] Starting production build...");let r={};try{r=await I()}catch{}let a=t.componentsDir??r.componentsDir??"components",c=t.partialsDir??r.partialsDir??"partials",s=t.layoutsDir??r.layoutsDir??"layouts",o=t.publicDir??r.publicDir??"public",p=r.app?.head||{},l=r.app?.colorMode,f=r.router?.container||"main";if(v.existsSync(e))v.rmSync(e,{recursive:!0});let m=[g.join(e,"public","__stx"),g.join(e,"public","assets"),g.join(e,"server","pages"),g.join(e,"server","fragments")];for(let h of m)v.mkdirSync(h,{recursive:!0});console.log("[stx build] Discovering routes...");let b=Mt(i),E=["components","layouts","partials"],T=b.filter((h)=>!E.some((u)=>h.pattern.startsWith(`/${u}/`)||h.pattern===`/${u}`));console.log(`[stx build] Found ${T.length} page routes (${b.length-T.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let y=et(t.debug),x=nt();await Bun.write(g.join(e,"public","__stx",y.filename),y.content),await Bun.write(g.join(e,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${y.filename} (${(y.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${x.filename} (${(x.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let _=[],S=[];for(let h of T)try{let u=await wt(h.filePath,h.pattern,{componentsDir:a,partialsDir:c,layoutsDir:s,debug:t.debug});if(_.push(u),u.html=u.html.replace(/runtime\.__STX_HASH__\.js/g,y.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),u.html=Pt(u.html,p,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...l&&{colorMode:l}}),l)u.html=Ct(u.html,l);if(p.htmlAttrs)u.html=Dt(u.html,p.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(u.html)){let N=u.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(N&&N[1]){let Y=N[1];u.html=u.html.replace(" "+Y,""),u.html=u.html.replace(/<body([^>]*)>/,`<body$1 ${Y}>`)}}u.html=u.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),u.html=await Rt(u.html),u.fragment=lt(u.html,f);let X=h.pattern==="/"?"index":h.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),W=g.join("server","pages",`${X}.compiled.json`),U=g.join("server","fragments",`${X}.html`);await Bun.write(g.join(e,W),JSON.stringify(u,null,2)),await Bun.write(g.join(e,U),u.fragment),S.push({pattern:h.pattern,compiledPath:W,fragmentPath:U,isDynamic:u.hasServerScripts,hasParams:h.pattern.includes(":")||h.pattern.includes("[")}),console.log(`[stx build] \u2713 ${h.pattern}`)}catch(u){console.error(`[stx build] \u2717 ${h.pattern}:`,u instanceof Error?u.message:u)}let d=g.resolve(i,o);if(v.existsSync(d)){let{copied:h,bytes:u}=At(d,g.join(e,"public"));if(h>0)console.log(`[stx build] Copied ${h} public asset${h===1?"":"s"} (${(u/1024).toFixed(1)}KB) from ${o}/`)}let w=z(i);if(w){let{copied:h,bytes:u}=At(w,g.join(e,"public",K));if(h>0)console.log(`[stx build] Copied ${h} asset${h===1?"":"s"} (${(u/1024).toFixed(1)}KB) from ${k}/`)}let A={runtime:y.filename,router:x.filename},L=vt(S,A,e);Et(L,e);let C=Date.now()-n;return console.log(`
47
- [stx build] Done in ${C}ms \u2014 ${_.length} pages compiled`),{pageCount:_.length,assets:A,outputDir:e,duration:C}}
48
- export{Lt as u,ot as v,ve as w,Ee as x,Ae as y,P as z,Re as A,lt as B,K as C,z as D,tt as E,et as F,nt as G,ge as H,Xt as I,Oe as J,je as K,Kt as L,Qt as M,Ie as N,Le as O,Ne as P,ke as Q,wt as R,vt as S,Et as T,Qe as U,mn as V};