@stacksjs/bun-router 0.1.0 → 0.1.1

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 (150) hide show
  1. package/dist/chunk-03m2j6h7.js +2 -0
  2. package/dist/chunk-08cw7ejr.js +3 -0
  3. package/dist/chunk-0e4g0fyv.js +62 -0
  4. package/dist/chunk-0mmn02yw.js +2 -0
  5. package/dist/chunk-126c9qm3.js +2 -0
  6. package/dist/chunk-12p13817.js +2 -0
  7. package/dist/chunk-14v65c37.js +4 -0
  8. package/dist/{chunk-s3dn1kwx.js → chunk-1b6a7t3v.js} +2 -2
  9. package/dist/chunk-1wenkmk0.js +2 -0
  10. package/dist/chunk-2152npfd.js +2 -0
  11. package/dist/chunk-26w23krx.js +2 -0
  12. package/dist/chunk-2g8m379z.js +10 -0
  13. package/dist/{chunk-5mxby3fd.js → chunk-2rr178et.js} +2 -2
  14. package/dist/chunk-2w8f3swz.js +29 -0
  15. package/dist/chunk-3y4gaz7v.js +82 -0
  16. package/dist/chunk-4r1x4afz.js +12 -0
  17. package/dist/chunk-4wyw66zk.js +2 -0
  18. package/dist/chunk-4z5sf8ag.js +2 -0
  19. package/dist/{chunk-krkchy8v.js → chunk-58tfvayh.js} +3 -3
  20. package/dist/{chunk-ex5fkjah.js → chunk-5dp83qcx.js} +43 -43
  21. package/dist/chunk-5f0d9j9a.js +2 -0
  22. package/dist/{chunk-zhx0hxdd.js → chunk-5z52b0fc.js} +7 -7
  23. package/dist/{chunk-kc659vhx.js → chunk-5zrnk2kq.js} +3 -3
  24. package/dist/chunk-6dmqtdnq.js +2 -0
  25. package/dist/{chunk-5s1pr62n.js → chunk-6e91956t.js} +2 -2
  26. package/dist/{chunk-jrf5a2ap.js → chunk-6rv8w5jk.js} +1 -1
  27. package/dist/{chunk-5n0ckcmc.js → chunk-6x1feysm.js} +2 -2
  28. package/dist/chunk-7y72hm1x.js +2 -0
  29. package/dist/{chunk-zetqzgf3.js → chunk-8hbhfh6b.js} +6 -6
  30. package/dist/{chunk-5ncn73tp.js → chunk-8kfzygg5.js} +2 -2
  31. package/dist/chunk-8wydx2we.js +2 -0
  32. package/dist/chunk-8zjnjvv7.js +2 -0
  33. package/dist/chunk-988h4bzr.js +2 -0
  34. package/dist/chunk-9b6a58ac.js +2 -0
  35. package/dist/chunk-a8fcaywb.js +2 -0
  36. package/dist/chunk-bfjwn7yg.js +2 -0
  37. package/dist/chunk-bp2522mm.js +2 -0
  38. package/dist/chunk-bswe62q4.js +48 -0
  39. package/dist/chunk-c3v796c8.js +943 -0
  40. package/dist/chunk-ccqmwdry.js +2 -0
  41. package/dist/chunk-ck0crwnx.js +2 -0
  42. package/dist/chunk-cqgkxcb4.js +2 -0
  43. package/dist/chunk-dntnakjy.js +2 -0
  44. package/dist/{chunk-67wgad4f.js → chunk-ettdpnrw.js} +2 -2
  45. package/dist/{chunk-csfrpsp7.js → chunk-ezqwq17j.js} +10 -10
  46. package/dist/chunk-ezx3qsez.js +2 -0
  47. package/dist/{chunk-73k79n7q.js → chunk-f72nnjy4.js} +360 -360
  48. package/dist/chunk-fna5n0ey.js +246 -0
  49. package/dist/chunk-fqhckdt8.js +2 -0
  50. package/dist/chunk-fr6hbx25.js +2 -0
  51. package/dist/{chunk-vr10sbbh.js → chunk-g9cwng6w.js} +1 -1
  52. package/dist/chunk-gd3za5x0.js +2 -0
  53. package/dist/chunk-gf28608k.js +2 -0
  54. package/dist/chunk-h1dj6v8q.js +3 -0
  55. package/dist/chunk-hjxe7k2g.js +2 -0
  56. package/dist/chunk-hrkgznbn.js +2 -0
  57. package/dist/chunk-j6h5v0br.js +2 -0
  58. package/dist/{chunk-0gjq8ttx.js → chunk-mgb01qdv.js} +2 -2
  59. package/dist/chunk-n24c9whp.js +2 -0
  60. package/dist/{chunk-kxp888dn.js → chunk-n2j24b0h.js} +244 -244
  61. package/dist/{chunk-vv3gb1m5.js → chunk-nhmtg01n.js} +2 -2
  62. package/dist/chunk-p0qhpnqh.js +70 -0
  63. package/dist/chunk-p0w1x8y2.js +3 -0
  64. package/dist/{chunk-9ght4n4r.js → chunk-p3dk1w2w.js} +11 -11
  65. package/dist/{chunk-6sjvhy5f.js → chunk-q4e9pxs7.js} +2 -2
  66. package/dist/chunk-q5dv1kyy.js +2 -0
  67. package/dist/chunk-qnqgf9tq.js +2 -0
  68. package/dist/chunk-qvwy1808.js +898 -0
  69. package/dist/{chunk-5s0pnsd6.js → chunk-r18f77vc.js} +4 -4
  70. package/dist/chunk-r63za1mr.js +2 -0
  71. package/dist/{chunk-6s1kbajm.js → chunk-rft8gw92.js} +1 -1
  72. package/dist/chunk-ryvmyskt.js +4211 -0
  73. package/dist/chunk-sa6mx308.js +2 -0
  74. package/dist/chunk-va0pc7hx.js +2 -0
  75. package/dist/chunk-vcp8dnjq.js +412 -0
  76. package/dist/chunk-vg1erq1q.js +2 -0
  77. package/dist/{chunk-hmgedrmr.js → chunk-w0jv49ch.js} +3 -3
  78. package/dist/{chunk-0t5vz87j.js → chunk-wm805tte.js} +19 -19
  79. package/dist/chunk-xj9h6mc9.js +2 -0
  80. package/dist/chunk-ytvzwrq3.js +51 -0
  81. package/dist/{chunk-w4r464v5.js → chunk-zde7ebc4.js} +2 -2
  82. package/dist/chunk-zmqsv2xy.js +2 -0
  83. package/dist/cli.js +57 -66
  84. package/dist/container/index.js +1 -1
  85. package/dist/index.d.ts +1 -0
  86. package/dist/index.js +29 -29
  87. package/dist/typed/client.d.ts +89 -0
  88. package/dist/typed/contract.d.ts +34 -0
  89. package/dist/typed/endpoint.d.ts +90 -0
  90. package/dist/typed/index.d.ts +14 -0
  91. package/dist/typed/router.d.ts +141 -0
  92. package/package.json +1 -1
  93. package/dist/chunk-30rkn2ym.js +0 -2
  94. package/dist/chunk-38cmrard.js +0 -2
  95. package/dist/chunk-3qna6dwd.js +0 -2
  96. package/dist/chunk-4d5fmta0.js +0 -2
  97. package/dist/chunk-4x3b4b4q.js +0 -2
  98. package/dist/chunk-6xed4va1.js +0 -2
  99. package/dist/chunk-748n6ydj.js +0 -2
  100. package/dist/chunk-7rsf8tes.js +0 -898
  101. package/dist/chunk-8aspmtf1.js +0 -2
  102. package/dist/chunk-8yfdg595.js +0 -2
  103. package/dist/chunk-90eze7av.js +0 -3
  104. package/dist/chunk-9dvwyej7.js +0 -2
  105. package/dist/chunk-a2w45krb.js +0 -2
  106. package/dist/chunk-a547f2ab.js +0 -48
  107. package/dist/chunk-bqdycvtc.js +0 -2
  108. package/dist/chunk-cd03rk3x.js +0 -2
  109. package/dist/chunk-ct0m17q5.js +0 -2
  110. package/dist/chunk-dhbvvr5h.js +0 -2
  111. package/dist/chunk-dhptcsya.js +0 -943
  112. package/dist/chunk-dq93zag9.js +0 -2
  113. package/dist/chunk-edrtesh7.js +0 -2
  114. package/dist/chunk-ejcws37w.js +0 -2
  115. package/dist/chunk-ex890p45.js +0 -51
  116. package/dist/chunk-f69cpnhw.js +0 -2
  117. package/dist/chunk-fjf53b44.js +0 -2
  118. package/dist/chunk-fjzye4qj.js +0 -2
  119. package/dist/chunk-gfd23b6t.js +0 -2
  120. package/dist/chunk-habv0vef.js +0 -12
  121. package/dist/chunk-hz6fc788.js +0 -2
  122. package/dist/chunk-jff6j9y3.js +0 -10
  123. package/dist/chunk-jmeb7n8k.js +0 -70
  124. package/dist/chunk-jy2jhcpy.js +0 -246
  125. package/dist/chunk-m249t3je.js +0 -3
  126. package/dist/chunk-m9yabnjx.js +0 -2
  127. package/dist/chunk-mekrq9wd.js +0 -2
  128. package/dist/chunk-mmxv535f.js +0 -82
  129. package/dist/chunk-mypn7jss.js +0 -2
  130. package/dist/chunk-n18x1k3c.js +0 -2
  131. package/dist/chunk-nkddjzsa.js +0 -2
  132. package/dist/chunk-pjmhqmr9.js +0 -2
  133. package/dist/chunk-qyrnsaq1.js +0 -2
  134. package/dist/chunk-r19ff2qm.js +0 -62
  135. package/dist/chunk-r338fssq.js +0 -2
  136. package/dist/chunk-s36z58x2.js +0 -29
  137. package/dist/chunk-s79dd325.js +0 -471
  138. package/dist/chunk-ta38j9em.js +0 -2
  139. package/dist/chunk-tpfgntwj.js +0 -4211
  140. package/dist/chunk-vw8rwv6e.js +0 -2
  141. package/dist/chunk-wcrqs5z9.js +0 -2
  142. package/dist/chunk-x6d1rmwa.js +0 -2
  143. package/dist/chunk-x7ft15zz.js +0 -2
  144. package/dist/chunk-x8trwn7j.js +0 -3
  145. package/dist/chunk-xhepdj1f.js +0 -2
  146. package/dist/chunk-xv2em0q4.js +0 -4
  147. package/dist/chunk-ypw6g0te.js +0 -2
  148. package/dist/chunk-z8szsm21.js +0 -2
  149. package/dist/chunk-zfbh14qe.js +0 -2
  150. /package/dist/{chunk-a3wahyg7.js → chunk-nf3kv7kv.js} +0 -0
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ke as a,Le as b,Me as c,Ne as d,Oe as e}from"./chunk-vsh4390q.js";import"./chunk-nf3kv7kv.js";export{b as defineAsyncComponent,d as generateAsyncComponentCSS,e as generateAsyncComponentRuntime,c as isAsyncComponent,a as processAsyncDirectives};
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{cf as g}from"./chunk-p0w1x8y2.js";function m(e,t){let r={};for(let n of e)r[n]=g(t(n));return new Proxy({},{get:(n,a)=>r[a]?.(),set:(n,a,u)=>{if(r[a])r[a].set(u);else r[a]=g(u);return!0},has:(n,a)=>(a in r),deleteProperty:(n,a)=>(delete r[a],!0),ownKeys:()=>Reflect.ownKeys(r),getOwnPropertyDescriptor:(n,a)=>(a in r)?{enumerable:!0,configurable:!0,writable:!0,value:r[a]()}:void 0})}function D(e,t){let r={};for(let n of t)r[n]=e[n];return r}function p(e,t){let r=Object.keys(e),n=m(r,(s)=>t?.[s]??e[s].getDefaultValue()),a=m(r,()=>[]),u=m(r,()=>!1),d=m(r,()=>!1),f=m(r,()=>!1),i=g(!1);async function o(s){f[s]=!0;let c=await e[s].validate(n[s],n);return a[s]=c,f[s]=!1,c.length===0}async function l(){i.set(!0);let s=await Promise.all(r.map(o));return i.set(!1),s.every(Boolean)}function b(){for(let s of r)n[s]=t?.[s]??e[s].getDefaultValue(),a[s]=[],u[s]=!1,d[s]=!1}function y(s){for(let c of r)if(c in s)n[c]=s[c],d[c]=!0}function R(s,c){n[s]=c,d[s]=!0}function w(s,c=!0){if(u[s]=c,c)o(s)}function v(s){return{value:n[s],errors:a[s],touched:u[s],dirty:d[s],valid:a[s].length===0,validating:f[s]}}function S(s){return async(c)=>{c?.preventDefault?.();for(let M of r)u[M]=!0;if(await l())await s(D(n,r))}}return{values:n,errors:a,touched:u,dirty:d,get isValid(){return r.every((s)=>a[s].length===0)},get isValidating(){return i()||r.some((s)=>f[s])},get isDirty(){return r.some((s)=>d[s])},validate:l,validateField:o,reset:b,setValues:y,setFieldValue:R,setFieldTouched:w,getFieldState:v,handleSubmit:S}}var x=p;class h{rules=[];defaultValue="";addRule(e){let t=new h;return t.rules=[...this.rules,e],t.defaultValue=this.defaultValue,t}required(e="This field is required"){return this.addRule({name:"required",message:e,validate:(t)=>{if(t===null||t===void 0)return e;if(typeof t==="string"&&t.trim()==="")return e;if(Array.isArray(t)&&t.length===0)return e;return!0}})}email(e="Please enter a valid email"){return this.addRule({name:"email",message:e,validate:(t)=>{if(!t)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(t))||e}})}url(e="Please enter a valid URL"){return this.addRule({name:"url",message:e,validate:(t)=>{if(!t)return!0;try{return new URL(String(t)),!0}catch{return e}}})}min(e,t){let r=t||`Must be at least ${e} characters`;return this.addRule({name:"min",message:r,validate:(n)=>{if(!n)return!0;return String(n).length>=e||r}})}max(e,t){let r=t||`Must be no more than ${e} characters`;return this.addRule({name:"max",message:r,validate:(n)=>{if(!n)return!0;return String(n).length<=e||r}})}length(e,t,r){let n=r||`Must be between ${e} and ${t} characters`;return this.addRule({name:"length",message:n,validate:(a)=>{if(!a)return!0;let u=String(a).length;return u>=e&&u<=t||n}})}pattern(e,t="Invalid format"){return this.addRule({name:"pattern",message:t,validate:(r)=>{if(!r)return!0;return e.test(String(r))||t}})}hasUppercase(e="Must contain an uppercase letter"){return this.pattern(/[A-Z]/,e)}hasLowercase(e="Must contain a lowercase letter"){return this.pattern(/[a-z]/,e)}hasNumber(e="Must contain a number"){return this.pattern(/\d/,e)}hasSpecial(e="Must contain a special character"){return this.pattern(/[!@#$%^&*(),.?":{}|<>]/,e)}alphanumeric(e="Only letters and numbers allowed"){return this.pattern(/^[a-zA-Z0-9]+$/,e)}startsWithLetter(e="Must start with a letter"){return this.pattern(/^[a-zA-Z]/,e)}noSpaces(e="Spaces are not allowed"){return this.addRule({name:"noSpaces",message:e,validate:(t)=>{if(!t)return!0;return!String(t).includes(" ")||e}})}number(e="Must be a number"){let t=this.addRule({name:"number",message:e,validate:(r)=>{if(!r&&r!==0)return!0;return!Number.isNaN(Number(r))||e}});return t.defaultValue=0,t}integer(e="Must be a whole number"){return this.addRule({name:"integer",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number.isInteger(Number(t))||e}})}positive(e="Must be a positive number"){return this.addRule({name:"positive",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number(t)>0||e}})}negative(e="Must be a negative number"){return this.addRule({name:"negative",message:e,validate:(t)=>{if(!t&&t!==0)return!0;return Number(t)<0||e}})}minValue(e,t){let r=t||`Must be at least ${e}`;return this.addRule({name:"minValue",message:r,validate:(n)=>{if(!n&&n!==0)return!0;return Number(n)>=e||r}})}maxValue(e,t){let r=t||`Must be no more than ${e}`;return this.addRule({name:"maxValue",message:r,validate:(n)=>{if(!n&&n!==0)return!0;return Number(n)<=e||r}})}between(e,t,r){let n=r||`Must be between ${e} and ${t}`;return this.addRule({name:"between",message:n,validate:(a)=>{if(!a&&a!==0)return!0;let u=Number(a);return u>=e&&u<=t||n}})}matches(e,t){let r=t||`Must match ${e}`;return this.addRule({name:"matches",message:r,validate:(n,a)=>{if(!a)return!0;return n===a[e]||r}})}oneOf(e,t){let r=t||`Must be one of: ${e.join(", ")}`;return this.addRule({name:"oneOf",message:r,validate:(n)=>{if(!n)return!0;return e.includes(n)||r}})}notOneOf(e,t){let r=t||`Cannot be one of: ${e.join(", ")}`;return this.addRule({name:"notOneOf",message:r,validate:(n)=>{if(!n)return!0;return!e.includes(n)||r}})}date(e="Must be a valid date"){return this.addRule({name:"date",message:e,validate:(t)=>{if(!t)return!0;let r=new Date(String(t));return!Number.isNaN(r.getTime())||e}})}before(e,t){let r=new Date(e),n=t||`Must be before ${r.toLocaleDateString()}`;return this.addRule({name:"before",message:n,validate:(a)=>{if(!a)return!0;return new Date(String(a))<r||n}})}after(e,t){let r=new Date(e),n=t||`Must be after ${r.toLocaleDateString()}`;return this.addRule({name:"after",message:n,validate:(a)=>{if(!a)return!0;return new Date(String(a))>r||n}})}custom(e,t="Invalid value"){return this.addRule({name:"custom",message:t,validate:e})}async(e,t="Invalid value"){return this.addRule({name:"async",message:t,async:!0,validate:e})}when(e,t){let r=new h;r.rules=[...this.rules],r.defaultValue=this.defaultValue;for(let n of t.getRules())r.rules.push({...n,validate:(a,u)=>{if(!e(a,u||{}))return!0;return n.validate(a,u)}});return r}getRules(){return this.rules}getDefaultValue(){return this.defaultValue}default(e){let t=new h;return t.rules=[...this.rules],t.defaultValue=e,t}async validate(e,t){let r=[];for(let n of this.rules){let a=await n.validate(e,t);if(a!==!0)r.push(a)}return r}validateSync(e,t){let r=[];for(let n of this.rules){if(n.async)continue;let a=n.validate(e,t);if(a!==!0)r.push(a)}return r}}var O=new h;function N(e,t,r){let n=/@error\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderror/g;return e.replace(n,(a,u,d)=>{try{let f=u.trim().split("."),i=t;for(let l of f)if(i&&typeof i==="object"&&l in i)i=i[l];else return"";let o=i;if(!o||!Array.isArray(o)||o.length===0)return"";return o.map((l)=>d.replace(/\{\{\s*message\s*\}\}/g,l)).join(`
3
+ `)}catch{return""}})}function V(e,t,r){let n=/@errors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderrors/g;return e.replace(n,(a,u,d)=>{try{let f=u.trim().split("."),i=t;for(let l of f)if(i&&typeof i==="object"&&l in i)i=i[l];else return"";let o=i;if(!o||!Array.isArray(o)||o.length===0)return"";return o.map((l)=>d.replace(/\{\{\s*message\s*\}\}/g,l)).join(`
4
+ `)}catch{return""}})}function A(e,t,r){let n=/@hasErrors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@endhasErrors/g;return e.replace(n,(a,u,d)=>{try{let f=u.trim().split("."),i=t;for(let l of f)if(i&&typeof i==="object"&&l in i)i=i[l];else return"";let o=i;if(!o||!Array.isArray(o)||o.length===0)return"";return d}catch{return""}})}function j(e,t,r){let n=e;return n=N(n,t,r),n=V(n,t,r),n=A(n,t,r),n}export{p as ne,x as oe,h as pe,O as qe,N as re,V as se,A as te,j as ue};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./chunk-a3wahyg7.js";var d=0;function u(){return`eb-${++d}-${Date.now().toString(36)}`}function p(e,o={},n){let r=/@errorBoundary(?:\s*\(([^)]*)\))?\s*([\s\S]*?)@fallback\s*([\s\S]*?)@enderrorBoundary/gi;return e.replace(r,(t,a,l,s)=>{let i=u(),c=y(a||"");return b(i,l.trim(),s.trim(),c)})}function y(e){let o={},n=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\w+))/g,r;while((r=n.exec(e))!==null){let t=r[1],a=r[2]||r[3]||r[4];switch(t){case"id":o.id=a;break;case"logErrors":o.logErrors=a==="true";break}}return o}function b(e,o,n,r){let t=r.logErrors!==!1;return`
2
+ import"./chunk-nf3kv7kv.js";var d=0;function u(){return`eb-${++d}-${Date.now().toString(36)}`}function p(e,o={},n){let r=/@errorBoundary(?:\s*\(([^)]*)\))?\s*([\s\S]*?)@fallback\s*([\s\S]*?)@enderrorBoundary/gi;return e.replace(r,(t,a,l,s)=>{let i=u(),c=y(a||"");return b(i,l.trim(),s.trim(),c)})}function y(e){let o={},n=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\w+))/g,r;while((r=n.exec(e))!==null){let t=r[1],a=r[2]||r[3]||r[4];switch(t){case"id":o.id=a;break;case"logErrors":o.logErrors=a==="true";break}}return o}function b(e,o,n,r){let t=r.logErrors!==!1;return`
3
3
  <div class="stx-error-boundary" data-boundary-id="${e}" data-has-error="false">
4
4
  <div class="stx-error-boundary-content" data-boundary-content="${e}">
5
5
  ${o}
@@ -228,4 +228,4 @@ import"./chunk-a3wahyg7.js";var d=0;function u(){return`eb-${++d}-${Date.now().t
228
228
 
229
229
  console.log('[stx] Error boundary runtime initialized');
230
230
  })();
231
- `}export{f as withErrorBoundary,p as processErrorBoundaryDirectives,h as generateErrorBoundaryRuntime,k as generateErrorBoundaryCSS,E as createErrorBoundary};
231
+ `}export{E as createErrorBoundary,k as generateErrorBoundaryCSS,h as generateErrorBoundaryRuntime,p as processErrorBoundaryDirectives,f as withErrorBoundary};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{m as a,n as b}from"./chunk-08cw7ejr.js";import"./chunk-h1dj6v8q.js";import"./chunk-fna5n0ey.js";import"./chunk-nf3kv7kv.js";export{b as createImageHandler,a as handleImageRequest};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Aj as a,Bj as b,Cj as c,Dj as d,Ej as e,Fj as f,Gj as g,Hj as h,Ij as i,Jj as j,Kj as k,Lj as l,Mj as m,Nj as n}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{l as applyFilters,e as clearCustomFilters,a as defaultFilters,f as escapeHtml,m as evaluateExpression,d as getAllFilters,i as interpolateScriptAttributes,h as interpolateScriptExpressions,j as interpolateScriptsInTemplate,k as processExpressions,b as registerFilter,c as registerFilters,n as unescapeHtml,g as usesSignalsInScript};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{rl as a,sl as b}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{a as parseLoopBinding,b as processLoops};
@@ -0,0 +1,10 @@
1
+ // @bun
2
+ import{jq as ne}from"./chunk-p0qhpnqh.js";import{Zu as te}from"./chunk-nf3kv7kv.js";import r from"path";function Y(s){return typeof s==="object"&&s!==null&&!Array.isArray(s)}function N(s,e){let t={...s};for(let[o,n]of Object.entries(e))t[o]=Y(n)&&Y(t[o])?N(t[o],n):n;return t}function q(s={},e={}){let t=s.theme||{},o=e.theme||{},{extend:n,...c}=o,{extend:i,...x}=t,f=N(x,c),S=N(i||{},n||{});if(Object.keys(S).length>0)f.extend=S;let B=[...s.safelist||[],...e.safelist||[]],k={...s.shortcuts||{},...e.shortcuts||{}},j=[...s.preflights||[],...e.preflights||[]];return{config:{...s,...e,theme:f,safelist:B,shortcuts:k,...j.length>0?{preflights:j}:{},content:[],output:""},safelist:B,shortcuts:k,includePreflight:e.preflight!==!1,minify:e.minify===!0}}import E from"path";var P=".stx",ce="STX_DIR",Z=null;function me(s){Z=s?.trim()||null}function F(){return process.env[ce]?.trim()||Z||P}function ee(s=process.cwd(),...e){let t=F();return E.isAbsolute(t)?E.join(t,...e):E.join(s,t,...e)}function Ce(s){if(!s||E.isAbsolute(s))return s;let e=s.replace(/\\/g,"/");if(e!==P&&!e.startsWith(`${P}/`))return s;let t=e.slice(P.length+1);return t?E.join(F(),t):F()}var a={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgGray:"\x1B[100m"};var p=null,G=!1,w=null,_="",b=!1,re=256,m=new Map,g=new Map,C=null,O=null;function M(s){return Bun.hash(s).toString(16).padStart(16,"0").slice(0,16)}function W(s,e){if(m.has(s))m.delete(s);else if(m.size>=re)m.delete(m.keys().next().value);m.set(s,e)}function ae(s){let e=M(s);if(g.has(e))g.delete(e);else if(g.size>=re)g.delete(g.keys().next().value);return g.set(e,s),e}function ve(s){let e=g.get(s);if(e===void 0)return;return g.delete(s),g.set(s,e),e}async function le(s){if(!C)return null;try{let e=Bun.file(r.join(C,`cw-${M(s)}.css`));if(!await e.exists())return null;return await e.text()}catch{return null}}async function de(s,e){if(!C)return;try{if(!fs.existsSync(C))fs.mkdirSync(C,{recursive:!0});await Bun.write(r.join(C,`cw-${M(s)}.css`),e)}catch{}}async function se(s){try{let e=await import(s);if(e&&e.CSSGenerator)return{CSSGenerator:e.CSSGenerator,config:e.config,build:e.build,defaultConfig:e.defaultConfig,extractClasses:e.extractClasses}}catch{}return null}function fe(){let s=[],e=process.cwd();while(e!==r.dirname(e))s.push(r.join(e,"node_modules","@cwcss","crosswind","dist","index.js")),s.push(r.join(e,"node_modules","@cwcss","crosswind","src","index.ts")),s.push(r.join(e,"pantry","@cwcss","crosswind","dist","index.js")),s.push(r.join(e,"pantry","@cwcss","crosswind","src","index.ts")),s.push(r.join(e,"node_modules","@stacksjs","crosswind","dist","index.js")),s.push(r.join(e,"pantry","@stacksjs","crosswind","dist","index.js")),e=r.dirname(e);return s}function ue(){let s=[],e=process.env.HOME||process.env.USERPROFILE||"";if(e){let t=[r.join(e,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),r.join(e,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),r.join(e,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),r.join(e,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),r.join(e,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),r.join(e,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];s.push(...t)}return s.push(r.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),s.push(r.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),s}async function oe(){if(G)return p;G=!0;try{let s=async(n)=>{for(let c of n){if(!await Bun.file(c).exists())continue;let i=await se(c);if(i){if(!process.env.STACKS_DEV_QUIET)console.log(`${a.green}[Crosswind]${a.reset} CSS engine loaded from ${r.dirname(r.dirname(c))}`);return i}}return null};if(process.env.CROSSWIND_SRC){let n=r.resolve(process.env.CROSSWIND_SRC),c=await s([n]);if(!c)throw Error(`CROSSWIND_SRC did not resolve to a Crosswind module: ${n}`);return p=c,p}let e=await s(fe());if(e)return p=e,p;let t=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let n of t){let c=await se(n);if(c){if(p=c,!process.env.STACKS_DEV_QUIET)console.log(`${a.green}[Crosswind]${a.reset} CSS engine loaded`);return p}}let o=await s(ue());if(o)return p=o,p;throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${a.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${a.reset}`),console.warn(`${a.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${a.reset}`),null}}function Te(){m.clear(),g.clear()}function De(){p=null,G=!1,w=null,_="",m.clear(),g.clear(),O=null}async function ie(s){try{if(!ne({name:"crosswind",cwd:s}))return null;let{loadConfigWithResult:e}=await import("./chunk-ccqmwdry.js"),t=await e({name:"crosswind",cwd:s,defaultConfig:{},checkEnv:!1,verbose:!1});if(!t?.path||!t.config||Object.keys(t.config).length===0)return null;let o=r.relative(s,t.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${a.green}[Crosswind]${a.reset} Loaded config from ${o||t.path}`);return t.config}catch(e){if(e instanceof Error&&e.name==="ConfigNotFoundError")return null;return console.warn(`${a.yellow}[Crosswind]${a.reset} Failed to load crosswind config:`,e instanceof Error?e.message:e),null}}async function ge(s){if(b)return _;b=!0;try{let e=await oe();if(!e||!e.build)return b=!1,"";if(!w)w=await ie(s);if(!w)return b=!1,"";let t=e.defaultConfig?.theme||{},o=w.theme||{},n={...e.defaultConfig,...w,theme:{...t,...o,extend:{...t.extend||{},...o.extend||{}}}},c=performance.now(),i=await e.build(n),x=performance.now()-c;if(_=i.css,console.log(`${a.cyan}[Crosswind]${a.reset} Built ${i.classes.size} classes in ${x.toFixed(1)}ms`),n.output){let f=r.isAbsolute(n.output)?n.output:r.join(s,n.output),S=r.dirname(f);if(!fs.existsSync(S))fs.mkdirSync(S,{recursive:!0});await Bun.write(f,i.css)}return b=!1,i.css}catch(e){return console.error(`${a.red}[Crosswind]${a.reset} Build error:`,e),b=!1,_}}async function Ee(s){w=null,await ge(s)}function _e(){return _}function we(s){let e=new Set,t=/class\s*=\s*["']([^"']+)["']/gi,o=t.exec(s);while(o!==null){for(let i of o[1].split(/\s+/))if(i.trim())e.add(i.trim());o=t.exec(s)}let n=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,c=n.exec(s);while(c!==null){let i=c[1].match(/'([^']+)'/g);if(i){for(let x of i)for(let f of x.slice(1,-1).split(/\s+/))if(f.trim())e.add(f.trim())}c=n.exec(s)}return e}async function pe(s,e){try{let t=await oe();if(!t)return"";let o=typeof t.extractClasses==="function"?t.extractClasses(s):we(s);if(o.size===0)return"";let n=e?r.resolve(e):process.cwd();if(!C)C=ee(n,"cache");let c=[...o].sort().join(" "),i=`${O||"default"}::${c}`,x=m.get(i);if(x!==void 0)return W(i,x),x;let f=await le(i);if(f!==null)return W(i,f),f;if(!w){let d=null;try{let{loadStxConfig:D}=await import("./chunk-bfjwn7yg.js"),l=await D(n);if(l.css)if(typeof l.css==="string"){let u=r.isAbsolute(l.css)?l.css:r.resolve(n,l.css);if(await Bun.file(u).exists()){let h=await import(u);d=h.default||h,console.log(`${a.green}[Crosswind]${a.reset} Loaded config from stx.config.ts \u2192 ${l.css}`)}}else{if(d={...l.css,content:l.css.content||[],preflight:l.css.preflight??!0,minify:l.css.minify??!1},l.css.config){let u=r.isAbsolute(l.css.config)?l.css.config:r.resolve(n,l.css.config);if(await Bun.file(u).exists()){let h=await import(u);d={...h.default||h,...d}}}console.log(`${a.green}[Crosswind]${a.reset} Using inline CSS config from stx.config.ts`)}}catch{}w=d||await ie(n);try{O=M(JSON.stringify(w??{}))}catch{O="unhashable"}}let S=t.defaultConfig||t.config,B=w||{},k=q(S,B),{safelist:j,includePreflight:K,minify:z}=k,U=k.config,v=new t.CSSGenerator(U);for(let d of j)v.generate(d);for(let d of o)v.generate(d);let y=v.toCSS(K,z),V=U.shortcuts||B.shortcuts||{};for(let[d,D]of Object.entries(V)){if(!o.has(d)&&!j.includes(d))continue;let l=D.split(/\s+/).filter(Boolean);for(let u of l)v.generate(u)}y=v.toCSS(K,z);let T=y.split(`
3
+ `);for(let[d,D]of Object.entries(V)){if(!o.has(d)&&!j.includes(d))continue;let l=D.split(/\s+/).filter(Boolean),u=[],h=[];for(let I of l){let H=I.startsWith("dark:"),Q=`.${(H?I.slice(5):I).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let R=0;R<T.length;R++){let X=T[R].trim();if(X===`${Q} {`||X.startsWith(`${Q} {`)){let A=R,J="";while(A<T.length){if(J+=T[A],T[A].includes("}"))break;A++}let L=J.match(/\{([^}]+)\}/);if(L)if(H)h.push(L[1].trim());else u.push(L[1].trim());break}}}if(u.length)y+=`
4
+ .${d} { ${u.join(" ")} }`;if(h.length)y+=`
5
+ @media (prefers-color-scheme: dark) { .dark .${d} { ${h.join(" ")} } }`}return W(i,y),de(i,y),y}catch(t){return console.warn("Failed to generate Crosswind CSS:",t),""}}async function Re(s,e,t=!1){let o=await pe(s,e);if(!o)return s;let n=t?`<link data-crosswind="generated" rel="stylesheet" href="/_stx/crosswind.${ae(o)}.css">`:`<style data-crosswind="generated">
6
+ ${o}
7
+ </style>`,c=/(?:<style\b[^>]*\bdata-crosswind=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-crosswind=(?:"generated"|'generated')[^>]*>)/g;if(c.test(s)){let i=!1;return s.replace(c,()=>{if(i)return"";return i=!0,n})}if(s.includes("</head>"))return s.replace("</head>",`${n}
8
+ </head>`);if(s.includes("<body"))return s.replace(/<body([^>]*)>/,`<body$1>
9
+ ${n}`);return n+s}
10
+ export{P as Rm,ce as Sm,me as Tm,F as Um,ee as Vm,Ce as Wm,N as Xm,q as Ym,a as Zm,ve as _m,oe as $m,Te as an,De as bn,ie as cn,ge as dn,Ee as en,_e as fn,we as gn,pe as hn,Re as in};
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import E from"fs";import d from"path";import c from"fs";import f from"path";var g=["components","layouts","partials","emails"];function _(e){return e.split(/[\\/]/).filter(Boolean).slice(0,-1).some((t)=>g.includes(t))}function y(e){return _(e.replace(/^\//,""))}function k(e,t){let r=e.filter((o)=>!y(o.pattern)),a=["// Auto-generated by STX - do not edit"];if(r.length===0)a.push("// No page routes found \u2014 route paths stay typed as string.","export {}","");else{a.push("declare module '@stacksjs/stx' {"," interface KnownRoutes {");for(let o of r){let i=[];for(let u of o.params){let p=o.pattern.includes(`:${u}?`)?"?":"";i.push(`${u}${p}: string`)}let l=i.join("; ");a.push(` '${o.pattern}': { ${l} }`)}a.push(" }","}","","export {}","")}let n=a.join(`
3
3
  `),s=f.join(t,"route-types.d.ts");try{if(c.existsSync(s)&&c.readFileSync(s,"utf8")===n)return;c.mkdirSync(t,{recursive:!0}),c.writeFileSync(s,n)}catch{}}function C(e,t,r){let a=process.cwd(),n=f.relative(a,r),s=e.filter((i)=>!y(i.pattern)),o=["// Auto-generated by stx \u2014 do not edit",`// Source: ${n||"pages"}/`,"","export const routes = ["];for(let i of s){let l=f.relative(a,i.filePath).replace(/\\/g,"/"),u=JSON.stringify(i.params),p=i.layout?`, layout: '${f.relative(a,i.layout).replace(/\\/g,"/")}'`:"";o.push(` { pattern: '${i.pattern}', filePath: '${l}', isDynamic: ${i.isDynamic}, params: ${u}${p} },`)}o.push("] as const",""),o.push("export type RouteName = typeof routes[number]['pattern']",""),c.mkdirSync(t,{recursive:!0}),c.writeFileSync(f.join(t,"routes.ts"),o.join(`
4
- `))}import N from"path";function A(e,t){let r=N.relative(t,e).replace(/\.(stx|md)$/,"");if(r=r.split(N.sep).join("/"),r==="index")return"/";if(r.endsWith("/index"))r=r.slice(0,-6);return r=r.replace(/\[\[([^\]]+)\]\]/g,":$1?"),r=r.replace(/\[([^\]]+)\]/g,":$1"),r=r.replace(/:\.\.\.([^/]+)/g,":$1*"),`/${r}`}function v(e){let t=[],r="",a=0;while(a<e.length){let n=e.slice(a),s=/^\/:([^/?*]+)\?/.exec(n);if(s){t.push(s[1]),r+="(?:/([^/]+))?",a+=s[0].length;continue}let o=/^:([^/?*]+)\*/.exec(n);if(o){t.push(o[1]),r+="(.+)",a+=o[0].length;continue}let i=/^:([^/?*]+)/.exec(n);if(i){t.push(i[1]),r+="([^/]+)",a+=i[0].length;continue}r+=e[a].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),a+=1}return{regex:new RegExp(`^${r}$`),params:t}}function q(e,t){let r=e===""?"/":e;for(let a of t){let n=r.match(a.regex);if(n){let s={};return a.params.forEach((o,i)=>{s[o]=n[i+1]}),{route:a,params:s}}}return null}function H(e){let t=e.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return v(t)}import $ from"fs";import R from"path";function T(e,t){let r=[],a=R.dirname(e);while(a.startsWith(t)||a===t){let n=R.join(a,"_layout.stx");if($.existsSync(n))r.unshift(n);if(a===t)break;a=R.dirname(a)}return r}function F(e,t){let r=[];if(!E.existsSync(e))return r;let a=E.readdirSync(e,{withFileTypes:!0});for(let n of a){let s=d.join(e,n.name);if(n.isDirectory()){if(n.name.startsWith("."))continue;if(g.includes(n.name))continue;r.push(...F(s,t))}else if(n.isFile()){let o=d.extname(n.name);if(t.includes(o)){if(n.name.startsWith("_")&&n.name!=="_layout.stx")continue;if(n.name==="_layout.stx")continue;r.push(s)}}}return r}class L{routes;pagesDir;pagesDirs;config;constructor(e,t={}){this.config=t;let r=t.pagesDirs&&t.pagesDirs.length>0?t.pagesDirs:[t.pagesDir||"pages"];this.pagesDirs=r.map((o)=>d.resolve(e,o)),this.pagesDir=this.pagesDirs[0];let a=t.extensions||[".stx"],n=new Set;this.routes=[];for(let o of this.pagesDirs){let i=F(o,a);for(let l of i){let u=A(l,o);if(n.has(u))continue;n.add(u);let{regex:p,params:O}=v(u),S=t.layouts!==!1?T(l,o):[];this.routes.push({pattern:u,regex:p,params:O,filePath:l,isDynamic:O.length>0,layout:S.length>0?S[S.length-1]:void 0})}}this.routes.sort((o,i)=>{if(!o.isDynamic&&i.isDynamic)return-1;if(o.isDynamic&&!i.isDynamic)return 1;let l=o.pattern.split("/").length,u=i.pattern.split("/").length;if(l!==u)return u-l;return o.pattern.localeCompare(i.pattern)});let s=d.resolve(e,t.stateDir||process.env.STX_DIR?.trim()||".stx");k(this.routes,s),C(this.routes,s,this.pagesDir)}match(e){let t=e===""?"/":e;for(let r of this.routes){let a=t.match(r.regex);if(a){let n={};return r.params.forEach((s,o)=>{n[s]=a[o+1]}),{route:r,params:n}}}return null}resolve(e,t){let r=this.routes.find((n)=>n.pattern===e||n.filePath.includes(e));if(!r)return"#not-found";let a=r.pattern;if(t)for(let[n,s]of Object.entries(t))a=a.replace(`:${n}`,encodeURIComponent(s));return a}addRoute(e){this.routes.push(e),this.routes.sort((t,r)=>{if(!t.isDynamic&&r.isDynamic)return-1;if(t.isDynamic&&!r.isDynamic)return 1;return t.pattern.localeCompare(r.pattern)})}getLayout(e){return e.layout??null}}function W(e,t){return new L(e,t)}function V(e,t){let r=[`${t}.stx`,"error.stx"];for(let a of r){let n=d.join(e,a);if(E.existsSync(n))return n}return null}function z(e,t){return e.map((r)=>{let a=d.relative(t,r.filePath),n=r.isDynamic?" (dynamic)":"";return`${r.pattern} \u2192 ${a}${n}`})}var h={},w="";function K(e){w=e.replace(/\/$/,"")}function Y(e,t,r={}){h[e]={path:t,name:e,params:r}}function J(e){for(let[t,r]of Object.entries(e))if(typeof r==="string")h[t]={path:r,name:t};else h[t]={...r,name:t}}function Q(e,t={},r=!1){let a=h[e];if(!a)return console.warn(`Route [${e}] not defined.`),"#undefined-route";let n={...a.params,...t},s=a.path;s=s.replace(/:(\w+)/g,(i,l)=>{let u=n[l];if(u===void 0)return console.warn(`Missing parameter [${l}] for route [${e}].`),`:${l}`;return delete n[l],encodeURIComponent(String(u))});let o=Object.entries(n);if(o.length>0){let i=o.map(([l,u])=>`${encodeURIComponent(l)}=${encodeURIComponent(String(u))}`).join("&");s+=(s.includes("?")?"&":"?")+i}return r&&w?`${w}${s}`:s}function Z(){for(let e of Object.keys(h))delete h[e];w=""}import I from"fs";import D from"path";function ee(e,t={}){return{type:"redirect",path:e,options:{replace:t.replace??!1,external:t.external??!1,redirectCode:t.redirectCode??302}}}function te(e){return{type:"abort",error:typeof e==="string"?{statusCode:500,message:e}:e}}function re(e,t={}){return{handler:e,mode:t.mode??"universal"}}function P(e){let t={};if(!e)return t;let r=e.split(";");for(let a of r){let[n,...s]=a.split("=");if(n){let o=n.trim(),i=s.join("=").trim();if(o)t[o]=decodeURIComponent(i)}}return t}function x(e,t,r={}){let a=`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(r.expires){let n=typeof r.expires==="number"?new Date(Date.now()+r.expires*1000):r.expires;a+=`; Expires=${n.toUTCString()}`}if(r.path)a+=`; Path=${r.path}`;if(r.domain)a+=`; Domain=${r.domain}`;if(r.secure)a+="; Secure";if(r.httpOnly)a+="; HttpOnly";if(r.sameSite)a+=`; SameSite=${r.sameSite}`;return a}function G(e,t){let r=e.headers.get("cookie")||"",a=P(r);return{get(n){return a[n]},set(n,s,o={}){a[n]=s,t.append("Set-Cookie",x(n,s,o))},delete(n){delete a[n],t.append("Set-Cookie",x(n,"",{expires:new Date(0),path:"/"}))},getAll(){return{...a}}}}function B(){return{get(e){if(typeof document>"u")return;return P(document.cookie)[e]},set(e,t,r={}){if(typeof document>"u")return;document.cookie=x(e,t,r)},delete(e){if(typeof document>"u")return;document.cookie=x(e,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return P(document.cookie)}}}function U(){let e=typeof window<"u"&&typeof window.localStorage<"u";return{get(t){if(!e)return null;try{return window.localStorage.getItem(t)}catch{return null}},set(t,r){if(!e)return;try{window.localStorage.setItem(t,r)}catch{}},remove(t){if(!e)return;try{window.localStorage.removeItem(t)}catch{}},isAvailable(){return e}}}var m=new Map;function M(e,t){m.set(e,t)}function X(e){return m.get(e)}function ae(e){return m.has(e)}function ne(){m.clear()}function oe(){return Array.from(m.keys())}async function se(e,t="middleware"){let r=D.resolve(e,t);if(!I.existsSync(r))return;let a=I.readdirSync(r);for(let n of a){if(!n.endsWith(".ts")&&!n.endsWith(".js"))continue;if(n.includes(".test.")||n.includes(".spec."))continue;let s=n.replace(/\.(ts|js)$/,""),o=D.join(r,n);try{let i=(await import(o)).default;if(i&&typeof i.handler==="function")M(s,i);else if(typeof i==="function")M(s,{handler:i,mode:"universal"})}catch(i){console.warn(`Failed to load middleware '${s}' from ${o}:`,i)}}}function ie(e){let t={};if(!e)return t;let r=new URLSearchParams(e);for(let[a,n]of r)t[a]=n;return t}function le(e,t,r,a=""){return{path:e,params:t,query:ie(a),fullPath:a?`${e}?${a}`:e,meta:r}}function ue(e,t,r,a){let n=a?.isServer??typeof window>"u",s=!n,o=new Headers;return{to:e,from:t,isClient:s,isServer:n,cookies:n&&r?G(r,o):B(),storage:U(),state:{},request:r,responseHeaders:o}}async function ce(e,t){let r=Array.isArray(e)?e:[e],a=t.isServer;for(let n of r){let s=X(n);if(!s)return console.error(`Route middleware '${n}' is not registered \u2014 failing the guard closed.`),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:`Route middleware '${n}' is not registered`}},state:t.state,responseHeaders:t.responseHeaders};if(s.mode==="server"&&!a)continue;try{let o=await s.handler(t);if(o){if(o.type==="redirect")return{passed:!1,redirect:o,state:t.state,responseHeaders:t.responseHeaders};if(o.type==="abort")return{passed:!1,abort:o,state:t.state,responseHeaders:t.responseHeaders}}}catch(o){return console.error(`Error in middleware '${n}':`,o),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:o instanceof Error?o.message:"Middleware error"}},state:t.state,responseHeaders:t.responseHeaders}}}return{passed:!0,state:t.state,responseHeaders:t.responseHeaders}}function j(e){let t=e.replace(/\\/g,"/").split("/").filter(Boolean),r=t.lastIndexOf("layouts"),a=r>=0?t[r+1]:t.at(-1);if(!a)return"app";return a.replace(/\.stx$/i,"")||"app"}function de(e){let t=e.match(/<meta\b[^>]*name=["']stx-layout["'][^>]*content=["']([^"']+)["'][^>]*>/i),r=e.match(/<meta\b[^>]*name=["']stx-layout-group["'][^>]*content=["']([^"']+)["'][^>]*>/i),a=e.match(/<!--\s*stx-layout:\s*([^ ]+)\s*-->/i),n=t?.[1]||a?.[1]||"";return{layout:n,group:r?.[1]||j(n)}}var b;function he(e){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(e).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return e}}function pe(){if(b)return b;return b=he(`
4
+ `))}import N from"path";function A(e,t){let r=N.relative(t,e).replace(/\.(stx|md)$/,"");if(r=r.split(N.sep).join("/"),r==="index")return"/";if(r.endsWith("/index"))r=r.slice(0,-6);return r=r.replace(/\[\[([^\]]+)\]\]/g,":$1?"),r=r.replace(/\[([^\]]+)\]/g,":$1"),r=r.replace(/:\.\.\.([^/]+)/g,":$1*"),`/${r}`}function v(e){let t=[],r="",a=0;while(a<e.length){let n=e.slice(a),s=/^\/:([^/?*]+)\?/.exec(n);if(s){t.push(s[1]),r+="(?:/([^/]+))?",a+=s[0].length;continue}let o=/^:([^/?*]+)\*/.exec(n);if(o){t.push(o[1]),r+="(.+)",a+=o[0].length;continue}let i=/^:([^/?*]+)/.exec(n);if(i){t.push(i[1]),r+="([^/]+)",a+=i[0].length;continue}r+=e[a].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),a+=1}return{regex:new RegExp(`^${r}$`),params:t}}function q(e,t){let r=e===""?"/":e;for(let a of t){let n=r.match(a.regex);if(n){let s={};return a.params.forEach((o,i)=>{s[o]=n[i+1]}),{route:a,params:s}}}return null}function H(e){let t=e.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return v(t)}import W from"fs";import R from"path";function T(e,t){let r=[],a=R.dirname(e);while(a.startsWith(t)||a===t){let n=R.join(a,"_layout.stx");if(W.existsSync(n))r.unshift(n);if(a===t)break;a=R.dirname(a)}return r}function F(e,t){let r=[];if(!E.existsSync(e))return r;let a=E.readdirSync(e,{withFileTypes:!0});for(let n of a){let s=d.join(e,n.name);if(n.isDirectory()){if(n.name.startsWith("."))continue;if(g.includes(n.name))continue;r.push(...F(s,t))}else if(n.isFile()){let o=d.extname(n.name);if(t.includes(o)){if(n.name.startsWith("_")&&n.name!=="_layout.stx")continue;if(n.name==="_layout.stx")continue;r.push(s)}}}return r}class L{routes;pagesDir;pagesDirs;config;constructor(e,t={}){this.config=t;let r=t.pagesDirs&&t.pagesDirs.length>0?t.pagesDirs:[t.pagesDir||"pages"];this.pagesDirs=r.map((o)=>d.resolve(e,o)),this.pagesDir=this.pagesDirs[0];let a=t.extensions||[".stx"],n=new Set;this.routes=[];for(let o of this.pagesDirs){let i=F(o,a);for(let l of i){let u=A(l,o);if(n.has(u))continue;n.add(u);let{regex:p,params:O}=v(u),S=t.layouts!==!1?T(l,o):[];this.routes.push({pattern:u,regex:p,params:O,filePath:l,isDynamic:O.length>0,layout:S.length>0?S[S.length-1]:void 0})}}this.routes.sort((o,i)=>{if(!o.isDynamic&&i.isDynamic)return-1;if(o.isDynamic&&!i.isDynamic)return 1;let l=o.pattern.split("/").length,u=i.pattern.split("/").length;if(l!==u)return u-l;return o.pattern.localeCompare(i.pattern)});let s=d.resolve(e,t.stateDir||process.env.STX_DIR?.trim()||".stx");k(this.routes,s),C(this.routes,s,this.pagesDir)}match(e){let t=e===""?"/":e;for(let r of this.routes){let a=t.match(r.regex);if(a){let n={};return r.params.forEach((s,o)=>{n[s]=a[o+1]}),{route:r,params:n}}}return null}resolve(e,t){let r=this.routes.find((n)=>n.pattern===e||n.filePath.includes(e));if(!r)return"#not-found";let a=r.pattern;if(t)for(let[n,s]of Object.entries(t))a=a.replace(`:${n}`,encodeURIComponent(s));return a}addRoute(e){this.routes.push(e),this.routes.sort((t,r)=>{if(!t.isDynamic&&r.isDynamic)return-1;if(t.isDynamic&&!r.isDynamic)return 1;return t.pattern.localeCompare(r.pattern)})}getLayout(e){return e.layout??null}}function V(e,t){return new L(e,t)}function z(e,t){let r=[`${t}.stx`,"error.stx"];for(let a of r){let n=d.join(e,a);if(E.existsSync(n))return n}return null}function K(e,t){return e.map((r)=>{let a=d.relative(t,r.filePath),n=r.isDynamic?" (dynamic)":"";return`${r.pattern} \u2192 ${a}${n}`})}var h={},w="";function Y(e){w=e.replace(/\/$/,"")}function J(e,t,r={}){h[e]={path:t,name:e,params:r}}function Q(e){for(let[t,r]of Object.entries(e))if(typeof r==="string")h[t]={path:r,name:t};else h[t]={...r,name:t}}function Z(e,t={},r=!1){let a=h[e];if(!a)return console.warn(`Route [${e}] not defined.`),"#undefined-route";let n={...a.params,...t},s=a.path;s=s.replace(/:(\w+)/g,(i,l)=>{let u=n[l];if(u===void 0)return console.warn(`Missing parameter [${l}] for route [${e}].`),`:${l}`;return delete n[l],encodeURIComponent(String(u))});let o=Object.entries(n);if(o.length>0){let i=o.map(([l,u])=>`${encodeURIComponent(l)}=${encodeURIComponent(String(u))}`).join("&");s+=(s.includes("?")?"&":"?")+i}return r&&w?`${w}${s}`:s}function ee(){for(let e of Object.keys(h))delete h[e];w=""}import I from"fs";import D from"path";function te(e,t={}){return{type:"redirect",path:e,options:{replace:t.replace??!1,external:t.external??!1,redirectCode:t.redirectCode??302}}}function re(e){return{type:"abort",error:typeof e==="string"?{statusCode:500,message:e}:e}}function ae(e,t={}){return{handler:e,mode:t.mode??"universal"}}function P(e){let t={};if(!e)return t;let r=e.split(";");for(let a of r){let[n,...s]=a.split("=");if(n){let o=n.trim(),i=s.join("=").trim();if(o)t[o]=decodeURIComponent(i)}}return t}function x(e,t,r={}){let a=`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(r.expires){let n=typeof r.expires==="number"?new Date(Date.now()+r.expires*1000):r.expires;a+=`; Expires=${n.toUTCString()}`}if(r.path)a+=`; Path=${r.path}`;if(r.domain)a+=`; Domain=${r.domain}`;if(r.secure)a+="; Secure";if(r.httpOnly)a+="; HttpOnly";if(r.sameSite)a+=`; SameSite=${r.sameSite}`;return a}function G(e,t){let r=e.headers.get("cookie")||"",a=P(r);return{get(n){return a[n]},set(n,s,o={}){a[n]=s,t.append("Set-Cookie",x(n,s,o))},delete(n){delete a[n],t.append("Set-Cookie",x(n,"",{expires:new Date(0),path:"/"}))},getAll(){return{...a}}}}function B(){return{get(e){if(typeof document>"u")return;return P(document.cookie)[e]},set(e,t,r={}){if(typeof document>"u")return;document.cookie=x(e,t,r)},delete(e){if(typeof document>"u")return;document.cookie=x(e,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return P(document.cookie)}}}function U(){let e=typeof window<"u"&&typeof window.localStorage<"u";return{get(t){if(!e)return null;try{return window.localStorage.getItem(t)}catch{return null}},set(t,r){if(!e)return;try{window.localStorage.setItem(t,r)}catch{}},remove(t){if(!e)return;try{window.localStorage.removeItem(t)}catch{}},isAvailable(){return e}}}var m=new Map;function M(e,t){m.set(e,t)}function X(e){return m.get(e)}function ne(e){return m.has(e)}function oe(){m.clear()}function se(){return Array.from(m.keys())}async function ie(e,t="middleware"){let r=D.resolve(e,t);if(!I.existsSync(r))return;let a=I.readdirSync(r);for(let n of a){if(!n.endsWith(".ts")&&!n.endsWith(".js"))continue;if(n.includes(".test.")||n.includes(".spec."))continue;let s=n.replace(/\.(ts|js)$/,""),o=D.join(r,n);try{let i=(await import(o)).default;if(i&&typeof i.handler==="function")M(s,i);else if(typeof i==="function")M(s,{handler:i,mode:"universal"})}catch(i){console.warn(`Failed to load middleware '${s}' from ${o}:`,i)}}}function le(e){let t={};if(!e)return t;let r=new URLSearchParams(e);for(let[a,n]of r)t[a]=n;return t}function ue(e,t,r,a=""){return{path:e,params:t,query:le(a),fullPath:a?`${e}?${a}`:e,meta:r}}function ce(e,t,r,a){let n=a?.isServer??typeof window>"u",s=!n,o=new Headers;return{to:e,from:t,isClient:s,isServer:n,cookies:n&&r?G(r,o):B(),storage:U(),state:{},request:r,responseHeaders:o}}async function de(e,t){let r=Array.isArray(e)?e:[e],a=t.isServer;for(let n of r){let s=X(n);if(!s)return console.error(`Route middleware '${n}' is not registered \u2014 failing the guard closed.`),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:`Route middleware '${n}' is not registered`}},state:t.state,responseHeaders:t.responseHeaders};if(s.mode==="server"&&!a)continue;try{let o=await s.handler(t);if(o){if(o.type==="redirect")return{passed:!1,redirect:o,state:t.state,responseHeaders:t.responseHeaders};if(o.type==="abort")return{passed:!1,abort:o,state:t.state,responseHeaders:t.responseHeaders}}}catch(o){return console.error(`Error in middleware '${n}':`,o),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:o instanceof Error?o.message:"Middleware error"}},state:t.state,responseHeaders:t.responseHeaders}}}return{passed:!0,state:t.state,responseHeaders:t.responseHeaders}}function j(e){let t=e.replace(/\\/g,"/").split("/").filter(Boolean),r=t.lastIndexOf("layouts"),a=r>=0?t[r+1]:t.at(-1);if(!a)return"app";return a.replace(/\.stx$/i,"")||"app"}function he(e){let t=e.match(/<meta\b[^>]*name=["']stx-layout["'][^>]*content=["']([^"']+)["'][^>]*>/i),r=e.match(/<meta\b[^>]*name=["']stx-layout-group["'][^>]*content=["']([^"']+)["'][^>]*>/i),a=e.match(/<!--\s*stx-layout:\s*([^ ]+)\s*-->/i),n=t?.[1]||a?.[1]||"";return{layout:n,group:r?.[1]||j(n)}}var b;function pe(e){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(e).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return e}}function fe(){if(b)return b;return b=pe(`
5
5
  ;(function(){
6
6
  'use strict';
7
7
  var ROUTER_REV=7;
@@ -1651,4 +1651,4 @@ else {
1651
1651
 
1652
1652
  if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',init);else init();
1653
1653
  })();
1654
- `),b}export{g as bo,_ as co,y as do,k as eo,C as fo,A as go,v as ho,q as io,H as jo,T as ko,L as lo,W as mo,V as no,z as oo,K as po,Y as qo,J as ro,Q as so,Z as to,ee as uo,te as vo,re as wo,G as xo,B as yo,U as zo,M as Ao,X as Bo,ae as Co,ne as Do,oe as Eo,se as Fo,le as Go,ue as Ho,ce as Io,j as Jo,de as Ko,pe as Lo};
1654
+ `),b}export{g as bo,_ as co,y as do,k as eo,C as fo,A as go,v as ho,q as io,H as jo,T as ko,L as lo,V as mo,z as no,K as oo,Y as po,J as qo,Q as ro,Z as so,ee as to,te as uo,re as vo,ae as wo,G as xo,B as yo,U as zo,M as Ao,X as Bo,ne as Co,oe as Do,se as Eo,ie as Fo,ue as Go,ce as Ho,de as Io,j as Jo,he as Ko,fe as Lo};
@@ -0,0 +1,29 @@
1
+ // @bun
2
+ import{Fu as B,Ku as v,Lu as O,Mu as U,Nu as N}from"./chunk-6x1feysm.js";import{Zu as P}from"./chunk-nf3kv7kv.js";import{resolve as Z,basename as ce,extname as de,join as ue}from"path";import{mkdir as he}from"fs/promises";var ie={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0};class V{config;constructor(t={}){this.config={...ie,...t}}async get(t,e){return O(t,e,"video",this.config)}async set(t,e,a){return U(t,e,a,"video",this.config)}async clear(){return N("video",this.config)}updateConfig(t){this.config={...this.config,...t}}}var R=null;function D(t){if(!R)R=new V(t);else if(t)R.updateConfig(t);return R}async function M(t,e,a){let n=a?{directory:`${a.outputDir}/../.cache`}:{};return D(n).get(t,e)}async function A(t,e,a,n){let u=n?{directory:`${n.outputDir}/../.cache`}:{};return D(u).set(t,e,a)}async function re(){return D().clear()}import{resolve as I,basename as F,extname as W,join as H}from"path";import{mkdir as q}from"fs/promises";async function L(){try{return await import("ts-videos")}catch{return null}}async function z(t,e,a,n){let u=await L();if(!u)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let r=I(t);if(!await v(r))return null;await q(a,{recursive:!0});let i=await B(r),o=F(t,W(t)),s=e.format||"webp",h=e.timestamp||0,p=`${o}-poster-${i}.${s}`,l=H(a,p),m=await u.extractThumbnails(r,{timestamps:[h],width:e.width||1280,height:e.height,format:s,quality:e.quality||85,outputDir:a,outputPattern:p.replace(`.${s}`,"")});if(m&&m.length>0){let c=m[0];return{path:l,url:`${n}/${p}`,width:c.width||e.width||1280,height:c.height||720,timestamp:h,size:c.size||0}}return null}catch(r){return console.warn(`[stx-media] Failed to generate poster: ${r}`),null}}async function E(t,e,a,n){let u=await L();if(!u)return[];try{let r=I(t);if(!await v(r))return[];await q(a,{recursive:!0});let i=await B(r),o=F(t,W(t)),s=e.format||"webp",h=(await new u.Input(r).getInfo()).duration||60,p=e.count||10,l=e.interval||h/p,m=[];for(let d=0;d<p&&d*l<h;d++)m.push(d*l);let c=await u.extractThumbnails(r,{timestamps:m,width:e.width||320,format:s,quality:e.quality||80,outputDir:a,outputPattern:`${o}-thumb-${i}`});if(c&&c.length>0)return c.map((d,f)=>({path:d.path||H(a,`${o}-thumb-${i}-${f}.${s}`),url:`${n}/${o}-thumb-${i}-${f}.${s}`,width:d.width||e.width||320,height:d.height||180,timestamp:m[f],size:d.size||0}));return[]}catch(r){return console.warn(`[stx-media] Failed to generate thumbnails: ${r}`),[]}}async function ne(t,e,a,n){let u=await L();if(!u)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let r=I(t);if(!await v(r))return null;await q(a,{recursive:!0});let i=await B(r),o=F(t,W(t)),s=(await new u.Input(r).getInfo()).duration||60,h=e.columns||10,p=e.interval||5,l=e.thumbnailWidth||160,m=e.thumbnailHeight||90,c=e.format||"jpeg",d=Math.ceil(s/p),f=Math.ceil(d/h),y=`${o}-sprite-${i}.${c}`,w=H(a,y),x=[];for(let b=0;b<d;b++)x.push(b*p);let g=await u.extractThumbnails(r,{timestamps:x,width:l,height:m,format:c,quality:e.quality||70,outputDir:H(a,".temp")});if(!g||g.length===0)return null;try{let b=await import("./chunk-9b6a58ac.js"),S=h*l,pe=f*m,we=await b.createSprite({images:g.map((ae)=>ae.path),columns:h,padding:0,outputPath:w,format:c,quality:e.quality||70});return{url:`${n}/${y}`,path:w,columns:h,rows:f,thumbnailWidth:l,thumbnailHeight:m,interval:p,totalFrames:d}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(r){return console.warn(`[stx-media] Failed to generate sprite sheet: ${r}`),null}}import{resolve as X,basename as _,extname as G,join as C}from"path";import{mkdir as T,writeFile as J}from"fs/promises";async function K(){try{return await import("ts-videos")}catch{return null}}var Y=[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000},{label:"360p",width:640,height:360,bitrate:600000,audioBitrate:64000}];async function j(t,e,a,n,u){let r=await K();if(!r)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let i=X(t);if(!await v(i))return null;let o=await B(i),s=_(t,G(t)),h=C(a,`${s}-${o}-hls`);await T(h,{recursive:!0});let p=e.length>0?e:Y,l=u?.segmentDuration||6,m=(await new r.Input(i).getInfo()).duration||0,c=[],d=0;for(let w of p){let x=C(h,w.label);await T(x,{recursive:!0});let g=`${w.label}.m3u8`,b=C(x,g);try{let S=await r.generateHLS(i,{outputDir:x,segmentDuration:l,width:w.width,height:w.height,videoBitrate:w.bitrate,audioBitrate:w.audioBitrate,playlistName:w.label});if(S)c.push({quality:w,url:`${n}/${s}-${o}-hls/${w.label}/${g}`,path:b}),d+=S.segmentCount||Math.ceil(m/l)}catch(S){console.warn(`[stx-media] Failed to generate HLS for ${w.label}: ${S}`)}}if(c.length===0)return null;let f=C(h,"master.m3u8"),y=se(c,n,s,o);return await J(f,y),{manifestUrl:`${n}/${s}-${o}-hls/master.m3u8`,manifestPath:f,playlists:c,segmentCount:d,duration:m}}catch(i){return console.warn(`[stx-media] Failed to generate HLS manifest: ${i}`),null}}function se(t,e,a,n){let u=["#EXTM3U","#EXT-X-VERSION:3"];for(let r of t){let{quality:i}=r,o=i.bitrate+(i.audioBitrate||128000),s=`${i.width}x${i.height||Math.round(i.width*9/16)}`;u.push(`#EXT-X-STREAM-INF:BANDWIDTH=${o},RESOLUTION=${s},NAME="${i.label}"`,`${i.label}/${i.label}.m3u8`)}return u.join(`
3
+ `)}async function k(t,e,a,n,u){let r=await K();if(!r)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let i=X(t);if(!await v(i))return null;let o=await B(i),s=_(t,G(t)),h=C(a,`${s}-${o}-dash`);await T(h,{recursive:!0});let p=e.length>0?e:Y,l=u?.segmentDuration||4,m=u?.minBufferTime||2,c=(await new r.Input(i).getInfo()).duration||0,d=[],f=[];for(let g of p){let b=C(h,g.label);await T(b,{recursive:!0});try{if(await r.generateDASH(i,{outputDir:b,segmentDuration:l,width:g.width,height:g.height,videoBitrate:g.bitrate,audioBitrate:g.audioBitrate})){if(d.push({bandwidth:g.bitrate,width:g.width,height:g.height||Math.round(g.width*9/16),url:`${n}/${s}-${o}-dash/${g.label}/video`}),g.audioBitrate)f.push({bandwidth:g.audioBitrate,url:`${n}/${s}-${o}-dash/${g.label}/audio`})}}catch(S){console.warn(`[stx-media] Failed to generate DASH for ${g.label}: ${S}`)}}if(d.length===0)return null;let y=C(h,"manifest.mpd"),w=oe(d,f,c,l,m);await J(y,w);let x=[{type:"video",representations:d}];if(f.length>0)x.push({type:"audio",representations:f});return{manifestUrl:`${n}/${s}-${o}-dash/manifest.mpd`,manifestPath:y,adaptationSets:x,duration:c}}catch(i){return console.warn(`[stx-media] Failed to generate DASH manifest: ${i}`),null}}function oe(t,e,a,n,u){let r=Q(a),i=Q(u),o=`<?xml version="1.0" encoding="UTF-8"?>
4
+ <MPD xmlns="urn:mpeg:dash:schema:mpd:2011"
5
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6
+ xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd"
7
+ type="static"
8
+ mediaPresentationDuration="${r}"
9
+ minBufferTime="${i}"
10
+ profiles="urn:mpeg:dash:profile:isoff-on-demand:2011">
11
+ <Period>
12
+ <AdaptationSet mimeType="video/mp4" codecs="avc1.64001f" segmentAlignment="true" startWithSAP="1">
13
+ `;for(let s=0;s<t.length;s++){let h=t[s];o+=` <Representation id="video${s}" bandwidth="${h.bandwidth}" width="${h.width}" height="${h.height}">
14
+ <BaseURL>${h.url}/</BaseURL>
15
+ <SegmentBase indexRange="0-999">
16
+ <Initialization range="0-999"/>
17
+ </SegmentBase>
18
+ </Representation>
19
+ `}if(o+=` </AdaptationSet>
20
+ `,e.length>0){o+=` <AdaptationSet mimeType="audio/mp4" codecs="mp4a.40.2" segmentAlignment="true" startWithSAP="1">
21
+ `;for(let s=0;s<e.length;s++){let h=e[s];o+=` <Representation id="audio${s}" bandwidth="${h.bandwidth}">
22
+ <BaseURL>${h.url}/</BaseURL>
23
+ <SegmentBase indexRange="0-999">
24
+ <Initialization range="0-999"/>
25
+ </SegmentBase>
26
+ </Representation>
27
+ `}o+=` </AdaptationSet>
28
+ `}return o+=` </Period>
29
+ </MPD>`,o}function Q(t){let e=Math.floor(t/3600),a=Math.floor(t%3600/60),n=Math.floor(t%60),u="PT";if(e>0)u+=`${e}H`;if(a>0)u+=`${a}M`;return u+=`${n}S`,u}async function ee(){try{return await import("ts-videos")}catch{return null}}function le(t){switch(t){case"very-low":return 500000;case"low":return 1e6;case"medium":return 2500000;case"high":return 5000000;case"very-high":return 1e7;case"lossless":return 0;default:return 2500000}}function me(t){switch(t){case"youtube":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};case"twitter":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"instagram-feed":return{codec:"h264",maxWidth:1080,maxHeight:1080,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"instagram-story":case"instagram-reels":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"tiktok":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"discord":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:60,bitrate:8000000,audioCodec:"aac",audioBitrate:192000};case"linkedin":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"facebook":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"web-progressive":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000,twoPass:!0};case"web-streaming":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};default:return{}}}async function te(t){let e=await ee();if(!e)return null;try{let a=Z(t),n=await new e.Input(a).getInfo();return{duration:n.duration||0,width:n.width||0,height:n.height||0,frameRate:n.frameRate||0,bitrate:n.bitrate||0,codec:n.videoCodec||"",audioCodec:n.audioCodec}}catch(a){return console.warn(`[stx-media] Failed to analyze video: ${a}`),null}}async function fe(t,e,a,n){let u=await ee();if(!u)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:t,processed:!1};let r=await M(t,e,a);if(r)return r;try{let i=Z(t);if(!await v(i))return{src:t,processed:!1,errors:[`Source file not found: ${t}`]};let o=a.outputDir||"dist/videos",s=a.baseUrl||"/videos";await he(o,{recursive:!0});let h=await B(i),p=ce(t,de(t)),l={src:t,processed:!0,hash:h};n?.({percentage:5,stage:"analyzing"}),l.metadata=await te(i)||void 0;let m={};if(e.quality)m.bitrate=le(e.quality);if(e.platform)Object.assign(m,me(e.platform));if(e.transcode)Object.assign(m,e.transcode);if(Object.keys(m).length>0||e.process){n?.({percentage:10,stage:"transcoding"});let c=`${p}-${h}.mp4`,d=ue(o,c);try{let f=await ge(i,d,m,u,(y)=>n?.({percentage:10+y*0.5,stage:"transcoding"}));if(f)l.transcoded={path:d,url:`${s}/${c}`,duration:f.duration,size:f.size,video:{codec:m.codec||"h264",width:f.width,height:f.height,bitrate:f.bitrate,frameRate:f.frameRate},audio:f.audioCodec?{codec:m.audioCodec||"aac",bitrate:m.audioBitrate||128000,sampleRate:m.sampleRate||48000,channels:m.channels||2}:void 0}}catch(f){l.errors=l.errors||[],l.errors.push(`Transcoding failed: ${f}`)}}if(e.generatePoster){n?.({percentage:65,stage:"generating-poster"});let c=typeof e.generatePoster==="object"?e.generatePoster:{timestamp:0},d=await z(i,c,o,s);if(d)l.poster=d}if(a.thumbnails?.enabled){n?.({percentage:70,stage:"generating-thumbnails"});let c=await E(i,a.thumbnails,o,s);if(c.length>0)l.thumbnails=c}if(e.streaming){n?.({percentage:80,stage:"generating-manifests"});let c=typeof e.streaming==="object"?e.streaming:a.streaming||{format:"hls"};if(c.format==="hls"||c.format===void 0){let d=await j(i,c.qualities||a.streaming?.defaultQualities||[],o,s);if(d)l.streaming={...l.streaming,hls:d}}if(c.format==="dash"){let d=await k(i,c.qualities||a.streaming?.defaultQualities||[],o,s);if(d)l.streaming={...l.streaming,dash:d}}}if(e.spriteSheet)n?.({percentage:90,stage:"generating-sprite-sheet"});return n?.({percentage:100,stage:"complete"}),await A(t,e,l,a),l}catch(i){return{src:t,processed:!1,errors:[`Processing failed: ${i}`]}}}async function ge(t,e,a,n,u){try{let r=await new n.Conversion(t,e,{videoCodec:a.codec,videoBitrate:a.bitrate,width:a.maxWidth,height:a.maxHeight,frameRate:a.frameRate,audioCodec:a.audioCodec,audioBitrate:a.audioBitrate,sampleRate:a.sampleRate,channels:a.channels}).run((i)=>{u?.(i.percentage/100)});return{duration:r.duration||0,size:r.size||0,width:r.width||a.maxWidth||0,height:r.height||a.maxHeight||0,bitrate:r.bitrate||a.bitrate||0,frameRate:r.frameRate||a.frameRate||30,audioCodec:r.audioCodec}}catch(r){return console.error(`[stx-media] Transcoding failed: ${r}`),null}}export{V as uu,M as vu,A as wu,re as xu,z as yu,E as zu,ne as Au,j as Bu,k as Cu,te as Du,fe as Eu};
@@ -0,0 +1,82 @@
1
+ // @bun
2
+ class a extends Error{code;statusCode;context;retryable;severity;category;timestamp;cause;constructor(e){super(e.message);if(this.name=this.constructor.name,this.code=e.code,this.statusCode=e.statusCode||500,this.context=e.context||{},this.retryable=e.retryable||!1,this.severity=e.severity||"medium",this.category=e.category||"system",this.timestamp=new Date,this.cause=e.cause,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,statusCode:this.statusCode,context:this.context,retryable:this.retryable,severity:this.severity,category:this.category,timestamp:this.timestamp.toISOString(),stack:this.stack,cause:this.cause?{name:this.cause.name,message:this.cause.message,stack:this.cause.stack}:void 0}}toResponse(){let e={error:{code:this.code,message:this.message,statusCode:this.statusCode,timestamp:this.timestamp.toISOString(),requestId:this.context.requestId}};return new Response(JSON.stringify(e),{status:this.statusCode,headers:{"Content-Type":"application/json","X-Error-Code":this.code,"X-Request-ID":this.context.requestId||""}})}}class x extends a{fields;constructor(e,t={},n){super({code:"VALIDATION_ERROR",message:e,statusCode:400,context:n,retryable:!1,severity:"low",category:"validation"});this.fields=t}toResponse(){let e={error:{code:this.code,message:this.message,statusCode:this.statusCode,timestamp:this.timestamp.toISOString(),requestId:this.context.requestId,fields:this.fields}};return new Response(JSON.stringify(e),{status:this.statusCode,headers:{"Content-Type":"application/json","X-Error-Code":this.code,"X-Request-ID":this.context.requestId||""}})}}class T extends a{constructor(e="Authentication required",t){super({code:"AUTHENTICATION_ERROR",message:e,statusCode:401,context:t,retryable:!1,severity:"medium",category:"authentication"})}}class E extends a{requiredPermissions;constructor(e="Access denied",t,n){super({code:"AUTHORIZATION_ERROR",message:e,statusCode:403,context:n,retryable:!1,severity:"medium",category:"authorization"});this.requiredPermissions=t}}class w extends a{resource;resourceId;constructor(e="Resource not found",t,n,r){super({code:"NOT_FOUND",message:e,statusCode:404,context:r,retryable:!1,severity:"low",category:"business"});this.resource=t,this.resourceId=n}}class R extends a{allowedMethods;constructor(e,t,n){super({code:"METHOD_NOT_ALLOWED",message:`Method ${e} not allowed. Allowed methods: ${t.join(", ")}`,statusCode:405,context:n,retryable:!1,severity:"low",category:"business"});this.allowedMethods=t}toResponse(){let e=super.toResponse();return e.headers.set("Allow",this.allowedMethods.join(", ")),e}}class S extends a{timeoutMs;constructor(e="Request timeout",t,n){super({code:"REQUEST_TIMEOUT",message:e,statusCode:408,context:n,retryable:!0,severity:"medium",category:"network"});this.timeoutMs=t}}class B extends a{retryAfter;limit;remaining;constructor(e="Rate limit exceeded",t,n,r=0,i){super({code:"RATE_LIMIT_EXCEEDED",message:e,statusCode:429,context:i,retryable:!0,severity:"medium",category:"network"});this.retryAfter=t,this.limit=n,this.remaining=r}toResponse(){let e=super.toResponse();return e.headers.set("Retry-After",this.retryAfter.toString()),e.headers.set("X-RateLimit-Limit",this.limit.toString()),e.headers.set("X-RateLimit-Remaining",this.remaining.toString()),e}}class I extends a{constructor(e="Internal server error",t,n){super({code:"INTERNAL_SERVER_ERROR",message:e,statusCode:500,context:n,cause:t,retryable:!0,severity:"high",category:"system"})}}class P extends a{retryAfter;constructor(e="Service unavailable",t,n){super({code:"SERVICE_UNAVAILABLE",message:e,statusCode:503,context:n,retryable:!0,severity:"high",category:"system"});this.retryAfter=t}toResponse(){let e=super.toResponse();if(this.retryAfter)e.headers.set("Retry-After",this.retryAfter.toString());return e}}class D extends a{query;operation;constructor(e,t,n,r,i){super({code:"DATABASE_ERROR",message:e,statusCode:500,context:i,cause:r,retryable:!0,severity:"high",category:"database"});this.operation=t,this.query=n}}class k extends a{service;endpoint;constructor(e,t,n,r=502,i,o){super({code:"EXTERNAL_SERVICE_ERROR",message:e,statusCode:r,context:o,cause:i,retryable:!0,severity:"medium",category:"external"});this.service=t,this.endpoint=n}}class M extends a{service;nextAttemptAt;constructor(e,t,n){super({code:"CIRCUIT_BREAKER_OPEN",message:`Circuit breaker is open for service: ${e}. Next attempt at: ${t.toISOString()}`,statusCode:503,context:n,retryable:!0,severity:"medium",category:"external"});this.service=e,this.nextAttemptAt=t}}class _ extends a{businessRule;constructor(e,t,n){super({code:"BUSINESS_LOGIC_ERROR",message:e,statusCode:422,context:n,retryable:!1,severity:"low",category:"business"});this.businessRule=t}}class A extends a{configKey;constructor(e,t,n){super({code:"CONFIGURATION_ERROR",message:e,statusCode:500,context:n,retryable:!1,severity:"critical",category:"system"});this.configKey=t}}class O extends a{path;operation;constructor(e,t,n,r,i){super({code:"FILESYSTEM_ERROR",message:e,statusCode:500,context:i,cause:r,retryable:!1,severity:"medium",category:"system"});this.path=t,this.operation=n}}var ve={validation:(e,t,n)=>new x(e,t,n),authentication:(e,t)=>new T(e,t),authorization:(e,t,n)=>new E(e,t,n),notFound:(e,t,n)=>new w(void 0,e,t,n),methodNotAllowed:(e,t,n)=>new R(e,t,n),timeout:(e,t,n)=>new S(t,e,n),rateLimit:(e,t,n,r)=>new B(void 0,e,t,n,r),internalServer:(e,t,n)=>new I(e,t,n),serviceUnavailable:(e,t,n)=>new P(e,t,n),database:(e,t,n,r,i)=>new D(e,t,n,r,i),externalService:(e,t,n,r,i,o)=>new k(e,t,n,r,i,o),circuitBreakerOpen:(e,t,n)=>new M(e,t,n),businessLogic:(e,t,n)=>new _(e,t,n),configuration:(e,t,n)=>new A(e,t,n),fileSystem:(e,t,n,r,i)=>new O(e,t,n,r,i)};class p extends a{conflictingRoutes;suggestion;constructor(e,t){let n=p.buildMessage(e),r=p.buildSuggestion(e);super({code:"ROUTE_CONFLICT",message:n,statusCode:500,context:t,retryable:!1,severity:"critical",category:"system"});this.conflictingRoutes=e,this.suggestion=r}static buildMessage(e){let t=["Route conflict detected! Multiple routes match the same path pattern.","","Conflicting routes:"];for(let n of e){if(t.push(` \u2022 ${n.method} ${n.path}`),n.name)t.push(` Name: "${n.name}"`);if(n.definedAt)t.push(` Defined at: ${n.definedAt}`)}return t.join(`
3
+ `)}static buildSuggestion(e){let t=[],n=e.some((d)=>!d.path.includes("{")),r=e.some((d)=>d.path.includes("{"));if(n&&r)t.push("\u2022 Static routes should be defined before dynamic routes","\u2022 Consider using route constraints (whereNumber, whereUuid) to differentiate");if(e.filter((d)=>d.path.includes("{")).length>1)t.push("\u2022 Use different parameter names or add constraints:",' router.get("/users/{id}").whereNumber("id")',' router.get("/users/{slug}").whereAlpha("slug")');if(e.some((d)=>d.path.includes("*")))t.push("\u2022 Wildcard routes should be defined last","\u2022 Consider using more specific path prefixes");if(t.length===0)t.push("\u2022 Rename one of the conflicting routes","\u2022 Use route groups with different prefixes","\u2022 Add parameter constraints to differentiate routes");return`How to fix:
4
+ ${t.join(`
5
+ `)}`}toJSON(){return{...super.toJSON(),conflictingRoutes:this.conflictingRoutes,suggestion:this.suggestion}}}class l extends a{dependencyChain;suggestion;constructor(e,t){let n=l.buildMessage(e),r=l.buildSuggestion(e);super({code:"CIRCULAR_DEPENDENCY",message:n,statusCode:500,context:t,retryable:!1,severity:"critical",category:"system"});this.dependencyChain=e,this.suggestion=r}static buildMessage(e){let t=["Circular dependency detected in the dependency injection container!","","Dependency chain:",""];for(let n=0;n<e.length;n++){let r=n===e.length-1,i=n===0?"\u250C\u2500\u25BA":r?"\u2514\u2500\u25BA":"\u251C\u2500\u25BA";if(t.push(` ${i} ${e[n]}`),!r)t.push(" \u2502")}return t.push(" \u2502"),t.push(` \u2514\u2500\u2500 cycles back to: ${e[0]}`),t.join(`
6
+ `)}static buildSuggestion(e){return`How to fix:
7
+
8
+ 1. Break the cycle by introducing an interface:
9
+ \u2022 Create an interface for one of the dependencies
10
+ \u2022 Use lazy injection: container.bind('${e[0]}').lazy()
11
+
12
+ 2. Restructure your dependencies:
13
+ \u2022 Extract shared logic into a separate service
14
+ \u2022 Use events/callbacks instead of direct dependencies
15
+
16
+ 3. Use setter injection instead of constructor injection:
17
+ \u2022 Remove the dependency from the constructor
18
+ \u2022 Set it after instantiation using a setter method
19
+
20
+ 4. Check if the dependency is actually needed:
21
+ \u2022 Sometimes circular dependencies indicate a design issue
22
+ \u2022 Consider if the classes have too many responsibilities
23
+
24
+ Dependency chain involved:
25
+ ${e.map((t,n)=>` ${n+1}. ${t}`).join(`
26
+ `)}`}toJSON(){return{...super.toJSON(),dependencyChain:this.dependencyChain,suggestion:this.suggestion}}}class L extends a{middlewareName;configErrors;suggestion;constructor(e,t,n){let r=`Middleware "${e}" configuration error:
27
+ ${t.map((i)=>` \u2022 ${i}`).join(`
28
+ `)}`;super({code:"MIDDLEWARE_CONFIGURATION_ERROR",message:r,statusCode:500,context:n,retryable:!1,severity:"high",category:"system"});this.middlewareName=e,this.configErrors=t,this.suggestion=this.buildSuggestion()}buildSuggestion(){return`How to fix:
29
+ \u2022 Check the middleware documentation for required options
30
+ \u2022 Ensure all required configuration values are provided
31
+ \u2022 Verify configuration value types match expected types
32
+
33
+ Example configuration:
34
+ router.use(new ${this.middlewareName}({
35
+ // Add required options here
36
+ }))`}}class v extends a{requestedPath;requestedMethod;similarRoutes;suggestion;constructor(e,t,n=[],r){let i=v.buildMessage(e,t,n);super({code:"ROUTE_NOT_FOUND",message:i,statusCode:404,context:r,retryable:!1,severity:"low",category:"business"});this.requestedPath=t,this.requestedMethod=e,this.similarRoutes=n,this.suggestion=this.buildSuggestion()}static buildMessage(e,t,n){let r=[`Route not found: ${e} ${t}`];if(n.length>0){r.push(""),r.push("Did you mean one of these routes?");for(let i of n.slice(0,5))if(r.push(` \u2022 ${i.method} ${i.path}`),i.similarity)r.push(` (${Math.round(i.similarity*100)}% match)`)}return r.join(`
37
+ `)}buildSuggestion(){let e=[`\u2022 Verify the HTTP method is correct (you used ${this.requestedMethod})`,"\u2022 Check for typos in the URL path","\u2022 Ensure the route is registered before the server starts","\u2022 Check if the route requires specific middleware (e.g., auth)"];if(this.requestedPath.includes("//"))e.push("\u2022 Remove duplicate slashes from the URL");if(!this.requestedPath.startsWith("/"))e.push("\u2022 Ensure the path starts with a forward slash (/)");return`How to fix:
38
+ ${e.join(`
39
+ `)}`}}class q extends a{handlerRef;suggestion;constructor(e,t,n){let r=`Failed to resolve handler "${e}": ${t}`;super({code:"HANDLER_RESOLUTION_ERROR",message:r,statusCode:500,context:n,retryable:!1,severity:"high",category:"system"});this.handlerRef=e,this.suggestion=this.buildSuggestion(e)}buildSuggestion(e){let t=e.includes("@"),n=e.includes("/");if(t){let[r,i]=e.split("@");return`How to fix:
40
+ \u2022 Ensure the controller "${r}" is registered in the container
41
+ \u2022 Verify the method "${i}" exists and is public
42
+ \u2022 Check the controller file is imported
43
+
44
+ Example:
45
+ // Register the controller
46
+ container.singleton('${r}', ${r})
47
+
48
+ // Define the route
49
+ router.get('/path', '${e}')`}if(n)return`How to fix:
50
+ \u2022 Ensure the action class exists at the specified path
51
+ \u2022 Verify the action has a "handle" method
52
+ \u2022 Check the action file is properly exported
53
+
54
+ Example:
55
+ // Action class at ${e}.ts
56
+ export default class ${e.split("/").pop()} {
57
+ handle(req: Request): Response {
58
+ return new Response('OK')
59
+ }
60
+ }`;return`How to fix:
61
+ \u2022 Verify the handler reference is correct
62
+ \u2022 Ensure the handler function/class is exported
63
+ \u2022 Check for circular dependencies in the handler module`}}class N extends a{modelName;paramName;paramValue;suggestion;constructor(e,t,n,r,i){let o=`Failed to bind model "${e}" for parameter "${t}" with value "${n}": ${r}`;super({code:"MODEL_BINDING_ERROR",message:o,statusCode:404,context:i,retryable:!1,severity:"low",category:"business"});this.modelName=e,this.paramName=t,this.paramValue=n,this.suggestion=this.buildSuggestion()}buildSuggestion(){return`How to fix:
64
+ \u2022 Verify the ${this.paramName} "${this.paramValue}" exists in your data source
65
+ \u2022 Check if the model resolver is correctly configured
66
+ \u2022 Ensure the route parameter matches the model's identifier field
67
+
68
+ Example model binding:
69
+ router.model('${this.paramName}', async (value) => {
70
+ const ${this.modelName.toLowerCase()} = await db.${this.modelName.toLowerCase()}s.findUnique({
71
+ where: { id: value }
72
+ })
73
+ if (!${this.modelName.toLowerCase()}) {
74
+ throw new Error('${this.modelName} not found')
75
+ }
76
+ return ${this.modelName.toLowerCase()}
77
+ })`}}function xe(e,t,n=5){let r=[];for(let i of t){let o=ie(e,i.path);if(o>0.3)r.push({method:i.method,path:i.path,similarity:o})}return r.sort((i,o)=>(o.similarity||0)-(i.similarity||0)).slice(0,n)}function ie(e,t){let n=e.length,r=t.length;if(n===0)return r===0?1:0;if(r===0)return 0;let i=[];for(let s=0;s<=n;s++)i[s]=[s];for(let s=0;s<=r;s++)i[0][s]=s;for(let s=1;s<=n;s++)for(let c=1;c<=r;c++){let y=e[s-1]===t[c-1]?0:1;i[s][c]=Math.min(i[s-1][c]+1,i[s][c-1]+1,i[s-1][c-1]+y)}let o=i[n][r],d=Math.max(n,r);return 1-o/d}function Te(e){let t=[],n=new Set;for(let r=0;r<e.length;r++){let i=e[r],o=`${i.method}:${i.path}`;if(n.has(o))continue;let d=[];for(let s=r+1;s<e.length;s++){let c=e[s];if(i.method===c.method&&se(i.path,c.path)){if(d.length===0)d.push({method:i.method,path:i.path,name:i.name});d.push({method:c.method,path:c.path,name:c.name}),n.add(`${c.method}:${c.path}`)}}if(d.length>0)t.push(d);n.add(o)}return t}function se(e,t){if(e===t)return!0;let n=e.split("/").filter(Boolean),r=t.split("/").filter(Boolean);if(n.length!==r.length){let o=e.includes("*"),d=t.includes("*");if(!o&&!d)return!1}let i=Math.max(n.length,r.length);for(let o=0;o<i;o++){let d=n[o]||"",s=r[o]||"";if(d==="*"||s==="*")return!0;let c=d.startsWith("{")&&d.endsWith("}"),y=s.startsWith("{")&&s.endsWith("}");if(!c&&!y){if(d!==s)return!1}}return!0}var Ee={routeConflict:(e,t)=>new p(e,t),circularDependency:(e,t)=>new l(e,t),middlewareConfig:(e,t,n)=>new L(e,t,n),routeNotFound:(e,t,n,r)=>new v(e,t,n,r),handlerResolution:(e,t,n)=>new q(e,t,n),modelBinding:(e,t,n,r,i)=>new N(e,t,n,r,i)};var oe=Symbol("injectable"),h=Symbol("inject"),Se=Symbol("optional"),Be=Symbol("tagged");class g{bindings=new Map;tagIndex=new Map;instances=new Map;scopedInstances=new Map;interceptors=new Map;parent;children=new Set;options;constructor(e={}){this.options={autoRegister:e.autoRegister??!0,strictMode:e.strictMode??!1,maxDepth:e.maxDepth??50,enableDecorators:e.enableDecorators??!0,enableInterception:e.enableInterception??!1,defaultScope:e.defaultScope??"transient"}}bind(e){return new F(this,e)}register(e){let t=this.bindings.get(e.token);if(t?.metadata?.tags)for(let n of t.metadata.tags)this.tagIndex.get(n)?.delete(e.token);if(this.bindings.set(e.token,e),e.metadata?.tags)for(let n of e.metadata.tags){let r=this.tagIndex.get(n);if(!r)r=new Set,this.tagIndex.set(n,r);r.add(e.token)}return this}singleton(e,t){return this.bind(e).to(t).inSingletonScope().build()}transient(e,t){return this.bind(e).to(t).inTransientScope().build()}value(e,t){return this.bind(e).toValue(t).build()}factory(e,t){return this.bind(e).toFactory(t).build()}resolve(e,t){let n={container:this,token:e,environment:t?.environment||"development",requestId:t?.requestId||this.generateRequestId(),depth:t?.depth||0,resolving:t?.resolving||new Set,parent:t?.parent};return this.resolveInternal(e,n)}resolveAll(e){let t=new Set;if(this.bindings.has(e))t.add(e);if(typeof e==="string")for(let n of this.tagIndex.get(e)??[])t.add(n);return Array.from(t,(n)=>this.resolve(n))}resolveTagged(e){let t=this.tagIndex.get(e);if(!t||t.size===0)return[];return Array.from(t,(n)=>this.resolve(n))}getTaggedBindings(e){let t=this.tagIndex.get(e);if(!t||t.size===0)return[];let n=[];for(let r of t){let i=this.bindings.get(r);if(i)n.push(i)}return n}addInterceptor(e,t){let n=this.tokenToString(e);if(!this.interceptors.has(n))this.interceptors.set(n,[]);this.interceptors.get(n).push(t)}registerController(e){this.singleton(e,e)}getController(e){return this.resolve(e)}isBound(e){return this.bindings.has(e)||(this.parent?.isBound(e)??!1)}unbind(e){let t=this.bindings.get(e);if(t?.metadata?.tags)for(let n of t.metadata.tags)this.tagIndex.get(n)?.delete(e);return this.bindings.delete(e),this.instances.delete(e),this}createChild(e){let t=new g({...this.options,...e});return t.parent=this,this.children.add(t),t}createScope(e){let t=this.createChild();return t.scopedInstances.set(e,new Map),t}getBindings(){return new Map(this.bindings)}clear(){return this.bindings.clear(),this.tagIndex.clear(),this.instances.clear(),this.scopedInstances.clear(),this}intercept(e,t){if(!this.interceptors.has(e))this.interceptors.set(e,[]);return this.interceptors.get(e).push(t),this}resolveInternal(e,t){if(t.resolving.has(e)){let n=Array.from(t.resolving).map((r)=>this.tokenToString(r));throw n.push(this.tokenToString(e)),new l(n)}if(t.depth>this.options.maxDepth){let n=Array.from(t.resolving).map((r)=>this.tokenToString(r));throw Error(`Maximum resolution depth exceeded (${this.options.maxDepth}).
78
+ This usually indicates a circular or very deep dependency chain.
79
+ Current resolution chain:
80
+ ${n.map((r,i)=>` ${i+1}. ${r}`).join(`
81
+ `)}`)}t.resolving.add(e),t.depth++;try{let n=this.bindings.get(e);if(n){if(n.metadata.when&&!n.metadata.when(t))throw Error(`Contextual binding condition not met for: ${this.tokenToString(e)}`);return this.createInstance(n,t)}if(this.parent){let r={resolving:new Set,depth:0,container:this.parent,token:e};return this.parent.resolveInternal(e,r)}if(this.options.autoRegister&&typeof e==="function")return this.autoRegisterAndResolve(e,t);if(this.options.strictMode)throw Error(`No binding found for: ${this.tokenToString(e)}`);if(typeof e==="function")return this.createInstanceFromConstructor(e,t);throw Error(`Cannot resolve: ${this.tokenToString(e)}`)}finally{t.resolving.delete(e),t.depth--}}createInstance(e,t){let n;if(e.metadata.scope==="singleton"&&this.instances.has(e.token))n=this.instances.get(e.token);else if(e.metadata.scope==="scoped"&&t.requestId){let i=this.scopedInstances.get(t.requestId);if(i?.has(e.token))n=i.get(e.token);else{if(n=this.createNewInstance(e,t),!i)this.scopedInstances.set(t.requestId,new Map);this.scopedInstances.get(t.requestId).set(e.token,n)}}else if(n=this.createNewInstance(e,t),e.metadata.scope==="singleton")this.instances.set(e.token,n);let r=this.tokenToString(e.token);if(this.interceptors.has(r)){let i=this.interceptors.get(r);for(let o of i)n=o(n)}return n}createNewInstance(e,t){if(e.value!==void 0)return e.value;if(e.factory){let n=this.resolveDependencies(e.metadata.dependencies||[],t);return e.factory(...n)}if(e.instance)return e.instance;if(e.implementation)return this.createInstanceFromConstructor(e.implementation,t);throw Error(`Invalid binding configuration for: ${this.tokenToString(e.token)}`)}createInstanceFromConstructor(e,t){let n=this.getConstructorDependencies(e),r=this.resolveDependencies(n,t),i=new e(...r);if(this.options.enableDecorators)this.applyDecorators(i,e);return i}getConstructorDependencies(e){let t=Reflect.getMetadata?.(h,e)||e[h];if(!t&&e.constructor)t=e.constructor[h];if(!t&&typeof e==="function"&&e.prototype){let r=e[h];if(r)t=r}if(!t&&typeof e==="function"){let r=e[h];if(r)t=r}if(t)return t.map((r)=>r.token);let n=Reflect.getMetadata?.("design:paramtypes",e);if(n)return n;return this.parseConstructorDependencies(e)}parseConstructorDependencies(e){let n=e.toString().match(/constructor\s*\(([^)]*)\)/);if(!n||!n[1])return[];return n[1].split(",").map((r)=>r.trim().split(":")[0].trim()).filter((r)=>r.length>0)}resolveDependencies(e,t){return e.map((n)=>this.resolveInternal(n,t))}autoRegisterAndResolve(e,t){let n=Reflect.getMetadata?.(oe,e),r={token:e,implementation:e,metadata:{scope:n?.scope||this.options.defaultScope,tags:n?.tags}};return this.register(r),this.resolveInternal(e,t)}applyDecorators(e,t){let n=Reflect.getMetadata?.("decorators",t);if(n)for(let r of n)r(e)}hasTag(e,t){return e.metadata.tags?.includes(t)??!1}tokenToString(e){if(typeof e==="string")return e;if(typeof e==="symbol")return e.toString();if(typeof e==="function")return e.name||"anonymous";return"unknown"}generateRequestId(){return`req_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}}class F{container;binding;constructor(e,t){this.container=e;this.binding={token:t,metadata:{scope:"transient"}}}to(e){return this.binding.implementation=e,this}toValue(e){return this.binding.value=e,this.binding.metadata.scope="singleton",this}toFactory(e){return this.binding.factory=e,this}toInstance(e){return this.binding.instance=e,this.binding.metadata.scope="singleton",this}inSingletonScope(){return this.binding.metadata.scope="singleton",this}inTransientScope(){return this.binding.metadata.scope="transient",this}inScopedScope(){return this.binding.metadata.scope="scoped",this}inRequestScope(){return this.binding.metadata.scope="request",this}withTags(...e){return this.binding.metadata.tags=[...this.binding.metadata.tags||[],...e],this}when(e){return this.binding.metadata.when=e,this}lazy(){return this.binding.metadata.lazy=!0,this}build(){return this.container.register(this.binding),this.container}}var m=null;function Ie(){if(!m)m=new g;return m}function Pe(e){m=e}function De(e){return new g(e)}class j{environments=new Map;currentEnvironment;variables=new Map;constructor(e="development"){this.currentEnvironment=e,this.loadEnvironmentVariables()}register(e){return this.environments.set(e.name,e),this}setEnvironment(e){if(!this.environments.has(e))throw Error(`Environment ${e} is not registered`);return this.currentEnvironment=e,this.loadEnvironmentVariables(),this}getCurrentEnvironment(){return this.currentEnvironment}getEnvironment(e){return this.environments.get(e||this.currentEnvironment)}is(...e){return e.includes(this.currentEnvironment)}get(e,t){return this.variables.get(e)??t}set(e,t){return this.variables.set(e,t),this}hasFeature(e){return this.getEnvironment()?.features.includes(e)??!1}loadEnvironmentVariables(){let e=this.getEnvironment();if(e)for(let[t,n]of Object.entries(e.variables))this.variables.set(t,n)}}class V{container;binding;constructor(e,t){this.container=e;this.binding={token:t,conditions:[],priority:0,metadata:{scope:"transient"}}}when(e){return this.binding.conditions.push(e),this}whenEnvironment(...e){let t={type:"environment",predicate:(n)=>e.includes(n.environment||"development"),description:`Environment is one of: ${e.join(", ")}`};return this.when(t)}whenTag(e){let t={type:"tag",predicate:(n)=>n.parent?.token?.toString().includes(e)??!1,description:`Parent has tag: ${e}`};return this.when(t)}whenParent(e){let t={type:"parent",predicate:(n)=>n.parent?.token===e,description:`Parent token is: ${e.toString()}`};return this.when(t)}whenRequest(e){let t={type:"request",predicate:e,description:"Custom request condition"};return this.when(t)}withPriority(e){return this.binding.priority=e,this}withFallback(e){return this.binding.fallback=e,this}to(e){return this.binding.implementation=e,this}toValue(e){return this.binding.value=e,this.binding.metadata.scope="singleton",this}toFactory(e){return this.binding.factory=e,this}inSingletonScope(){return this.binding.metadata.scope="singleton",this}inTransientScope(){return this.binding.metadata.scope="transient",this}build(){return this.container.registerContextualBinding(this.binding),this.container}}class ae extends g{contextualBindings=new Map;environmentManager;constructor(e){super(e);this.environmentManager=new j}bindContextual(e){return new V(this,e)}registerContextualBinding(e){if(!this.contextualBindings.has(e.token))this.contextualBindings.set(e.token,[]);let t=this.contextualBindings.get(e.token);return t.push(e),t.sort((n,r)=>r.priority-n.priority),this}getEnvironmentManager(){return this.environmentManager}forDevelopment(e){return this.bindContextual(e).whenEnvironment("development")}forProduction(e){return this.bindContextual(e).whenEnvironment("production")}forTesting(e){return this.bindContextual(e).whenEnvironment("test","testing")}forStaging(e){return this.bindContextual(e).whenEnvironment("staging")}resolve(e,t){let n={container:this,token:e,environment:t?.environment||this.environmentManager.getCurrentEnvironment(),requestId:t?.requestId||this.generateContextualRequestId(),depth:t?.depth||0,resolving:t?.resolving||new Set,parent:t?.parent},r=this.findContextualBinding(e,n);if(r)return this.createInstanceFromContextualBinding(r,n);return super.resolve(e,n)}findContextualBinding(e,t){let n=this.contextualBindings.get(e);if(!n)return;for(let r of n)if(this.evaluateConditions(r.conditions,t))return r;return}evaluateConditions(e,t){return e.every((n)=>{try{return n.predicate(t)}catch(r){return console.warn(`Error evaluating binding condition: ${n.description}`,r),!1}})}createInstanceFromContextualBinding(e,t){try{return this.createInstance(e,t)}catch(n){if(e.fallback)return console.warn(`Contextual binding failed, using fallback for ${e.token.toString()}`),this.createInstance(e.fallback,t);throw n}}generateContextualRequestId(){return`req_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}}class de{static development(){return{name:"development",variables:{DEBUG:!0,LOG_LEVEL:"debug",CACHE_TTL:60,DB_POOL_SIZE:5},services:{logger:"ConsoleLogger",cache:"MemoryCache",database:"SQLiteDatabase"},features:["hot-reload","debug-toolbar","detailed-errors"]}}static production(){return{name:"production",variables:{DEBUG:!1,LOG_LEVEL:"error",CACHE_TTL:3600,DB_POOL_SIZE:20},services:{logger:"FileLogger",cache:"RedisCache",database:"PostgreSQLDatabase"},features:["performance-monitoring","error-tracking"]}}static testing(){return{name:"test",variables:{DEBUG:!1,LOG_LEVEL:"warn",CACHE_TTL:1,DB_POOL_SIZE:1},services:{logger:"NullLogger",cache:"MemoryCache",database:"InMemoryDatabase"},features:["test-doubles","fast-teardown"]}}static staging(){return{name:"staging",variables:{DEBUG:!0,LOG_LEVEL:"info",CACHE_TTL:1800,DB_POOL_SIZE:10},services:{logger:"FileLogger",cache:"RedisCache",database:"PostgreSQLDatabase"},features:["performance-monitoring","debug-toolbar"]}}}class ce{static environment(...e){return{type:"environment",predicate:(t)=>e.includes(t.environment||"development"),description:`Environment is one of: ${e.join(", ")}`}}static feature(e){return{type:"custom",predicate:(t)=>t.container.getEnvironmentManager().hasFeature(e),description:`Feature ${e} is enabled`}}static envVar(e,t){return{type:"custom",predicate:(n)=>n.container.getEnvironmentManager().get(e)===t,description:`Environment variable ${e} equals ${t}`}}static requestPattern(e){return{type:"request",predicate:(t)=>e.test(t.requestId||""),description:`Request ID matches pattern: ${e.toString()}`}}static timeRange(e,t){return{type:"custom",predicate:()=>{let n=new Date().getHours();return n>=e&&n<=t},description:`Time is between ${e}:00 and ${t}:00`}}static custom(e,t){return{type:"custom",predicate:e,description:t||"Custom condition"}}}class u{version;dependencies;environment;priority=0;boot(e){}shutdown(e){}singleton(e,t,n){e.singleton(t,n)}transient(e,t,n){e.transient(t,n)}value(e,t,n){e.value(t,n)}factory(e,t,n){e.factory(t,n)}when(e,t){return{bind:(n)=>e.bind(n).when(t)}}forEnvironment(e,...t){return this.when(e,(n)=>t.includes(n.environment||"development"))}}class U extends u{isDeferred(){return!0}}class ue{providers=new Map;deferredProviders=new Map;loadedProviders=new Set;bootedProviders=new Set;container;constructor(e){this.container=e}register(e){if(this.isConditionalProvider(e)){let t=e.shouldLoad(this.container);if(t instanceof Promise)t.then((n)=>{if(n)this.doRegister(e)});else if(!t)return this}return this.doRegister(e),this}async boot(){let e=Array.from(this.providers.values()).sort((t,n)=>(n.priority||0)-(t.priority||0));this.validateDependencies(e);for(let t of e)if(!this.loadedProviders.has(t.name))await this.loadProvider(t);for(let t of e)if(!this.bootedProviders.has(t.name))await this.bootProvider(t)}async shutdown(){let e=Array.from(this.providers.values()).reverse();for(let t of e)if(t.shutdown)try{await t.shutdown(this.container)}catch(n){console.error(`Error shutting down provider ${t.name}:`,n)}this.providers.clear(),this.deferredProviders.clear(),this.loadedProviders.clear(),this.bootedProviders.clear()}getProvider(e){return this.providers.get(e)}getProviders(){return Array.from(this.providers.values())}async loadDeferredProvider(e){for(let[t,n]of this.deferredProviders)if(n.provides().includes(e)&&!this.loadedProviders.has(t))await this.loadProvider(n),await this.bootProvider(n),this.deferredProviders.delete(t)}doRegister(e){if(this.providers.has(e.name))throw Error(`Provider ${e.name} is already registered`);if(this.providers.set(e.name,e),this.isDeferredProvider(e))this.deferredProviders.set(e.name,e)}async loadProvider(e){try{await e.register(this.container),this.loadedProviders.add(e.name)}catch(t){throw Error(`Failed to load provider ${e.name}: ${t}`)}}async bootProvider(e){if(e.boot)try{await e.boot(this.container),this.bootedProviders.add(e.name)}catch(t){throw Error(`Failed to boot provider ${e.name}: ${t}`)}else this.bootedProviders.add(e.name)}validateDependencies(e){let t=new Set(e.map((n)=>n.name));for(let n of e)if(n.dependencies){for(let r of n.dependencies)if(!t.has(r))throw Error(`Provider ${n.name} depends on ${r}, but it's not registered`)}}isDeferredProvider(e){return"provides"in e&&"isDeferred"in e}isConditionalProvider(e){return"shouldLoad"in e}}class le extends u{name="config";priority=100;register(e){e.singleton("config",H),this.forEnvironment(e,"development").bind("config.debug").toValue(!0),this.forEnvironment(e,"production").bind("config.debug").toValue(!1),this.forEnvironment(e,"test").bind("config.debug").toValue(!1)}}class ge extends u{name="logging";priority=90;register(e){e.factory("logger",(t)=>new f(t.get("logging",{}))),this.forEnvironment(e,"development").bind("logger").toFactory(()=>new G),this.forEnvironment(e,"production").bind("logger").toFactory((t)=>new K(t.get("logging.file","./app.log")))}}class he extends u{name="database";dependencies=["config","logging"];register(e){e.singleton("database",W),e.transient("userRepository",z),e.transient("postRepository",J)}async boot(e){await e.resolve("database").connect()}async shutdown(e){await e.resolve("database").disconnect()}}class pe extends u{name="cache";dependencies=["config"];register(e){e.singleton("cache",X),this.forEnvironment(e,"development").bind("cache.store").toFactory(()=>new Y),this.forEnvironment(e,"production").bind("cache.store").toFactory((t)=>new Z(t.get("cache.redis")))}}class me extends u{name="auth";dependencies=["config","database"];register(e){e.singleton("authService",Q),e.singleton("jwtService",ee),e.transient("authGuard",te)}}class fe extends u{name="validation";register(e){e.singleton("validator",ne),e.factory("validationPipe",(t)=>new re(t))}}class ye extends U{name="events";provides(){return["eventBus","eventDispatcher",b,C]}register(e){e.singleton("eventBus",b),e.singleton("eventDispatcher",C)}}class H{get(e,t){return t}}class f{config;constructor(e){this.config=e}log(e){console.log(e)}}class G extends f{constructor(){super({})}}class K extends f{filePath;constructor(e){super({});this.filePath=e}}class W{async connect(){}async disconnect(){}}class z{db;constructor(e){this.db=e}}class J{db;constructor(e){this.db=e}}class X{store;constructor(e){this.store=e}}class Y{cache=new Map}class Z{config;constructor(e){this.config=e}}class Q{jwt;userRepo;constructor(e,t){this.jwt=e;this.userRepo=t}}class ee{config;constructor(e){this.config=e}}class te{auth;constructor(e){this.auth=e}}class ne{validate(e,t){return!0}}class re{validator;constructor(e){this.validator=e}}class b{emit(e,t){}}class C{bus;constructor(e){this.bus=e}}
82
+ export{a as Sq,x as Tq,T as Uq,E as Vq,w as Wq,R as Xq,S as Yq,B as Zq,I as _q,P as $q,D as ar,k as br,M as cr,_ as dr,A as er,O as fr,ve as gr,p as hr,l as ir,L as jr,v as kr,q as lr,N as mr,xe as nr,Te as or,Ee as pr,oe as qr,h as rr,Se as sr,Be as tr,g as ur,F as vr,Ie as wr,Pe as xr,De as yr,j as zr,V as Ar,ae as Br,de as Cr,ce as Dr,u as Er,U as Fr,ue as Gr,le as Hr,ge as Ir,he as Jr,pe as Kr,me as Lr,fe as Mr,ye as Nr,H as Or,f as Pr,G as Qr,K as Rr,W as Sr,z as Tr,J as Ur,X as Vr,Y as Wr,Z as Xr,Q as Yr,ee as Zr,te as _r,ne as $r,re as as,b as bs,C as cs};
@@ -0,0 +1,12 @@
1
+ // @bun
2
+ import{If as T,Jf as I}from"./chunk-dxg045wj.js";import{gj as M}from"./chunk-ryvmyskt.js";import{Vm as R}from"./chunk-2g8m379z.js";import"./chunk-ezqwq17j.js";import"./chunk-wm805tte.js";import"./chunk-58tfvayh.js";import"./chunk-brpgjyqg.js";import"./chunk-2rr178et.js";import{Mo as O}from"./chunk-5be9x5cq.js";import"./chunk-5zrnk2kq.js";import"./chunk-p0qhpnqh.js";import"./chunk-nf3kv7kv.js";import o from"path";import p from"fs";var Z=5,U=1;function q(n=process.env){return n.STX_DEBUG==="true"||n.STX_DEBUG==="1"}function g(...n){if(q())console.log("[stx:bundler]",...n)}var N=[];function G(n,i,c){N.push({filePath:n||"<inline>",message:i,details:c})}function ie(){return N.slice()}function ce(){N.length=0}var A;function ae(n){A=n}function Q(){if(A)return A;try{let n=M.strict;return typeof n==="object"&&n!==null?n.bundlerFallback??"warn":"warn"}catch{return"warn"}}var C=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function le(n){let i=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,c;while((c=i.exec(n))!==null){let d=c[1];if(!C.some((s)=>s.test(d)))return g("detected user import:",d),!0}let f=/^[ \t]*import[ \t]+['"]([^'"]+)['"]/gm;while((c=f.exec(n))!==null){let d=c[1];if(/\.css(?:\?.*)?$/.test(d))continue;if(!C.some((s)=>s.test(d)))return g("detected side-effect import:",d),!0}return!1}function K(n,i,c,f){let d=(s,t)=>{let e=s===c?i:o.dirname(s),r=o.resolve(e,t),u=[r,`${r}.ts`,`${r}.tsx`,`${r}.js`,`${r}.mjs`,`${r}.jsx`,o.join(r,"index.ts"),o.join(r,"index.tsx"),o.join(r,"index.js"),o.join(r,"index.mjs")];for(let h of u)try{if(p.existsSync(h)&&p.statSync(h,{throwIfNoEntry:!1})?.isFile())return h}catch{}return r};return{name:"stx-client-bundle",setup(s){s.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(t)=>({path:t.path,external:!0})),s.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(t)=>({path:t.path,external:!0})),s.onResolve({filter:/^\//},(t)=>{if(p.existsSync(t.path))return{path:t.path};return{path:t.path,external:!0}}),s.onResolve({filter:/^\.\.?\//},(t)=>{let e=d(t.importer,t.path);return f.add(e),{path:e}}),s.onResolve({filter:/^[@~]\//},(t)=>{let e=o.resolve(n,t.path.slice(2)),r=[e,`${e}.ts`,`${e}.tsx`,`${e}.js`,`${e}.mjs`,`${e}.jsx`,o.join(e,"index.ts"),o.join(e,"index.tsx"),o.join(e,"index.js"),o.join(e,"index.mjs")];for(let u of r)if(p.existsSync(u)&&p.statSync(u,{throwIfNoEntry:!1})?.isFile())return g(`resolved ${t.path[0]}/ import:`,t.path,"\u2192",u),f.add(u),{path:u};return console.warn(`[stx:bundler] could not resolve ${t.path[0]}/ import:`,t.path),{path:e}}),s.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(t)=>{let e=o.extname(t.path).toLowerCase(),r=e===".json"?"json":e===".tsx"?"tsx":e===".jsx"?"jsx":e===".ts"||e===".mts"||e===".cts"?"ts":"js";if(t.path!==c)f.add(t.path);return{contents:p.readFileSync(t.path,"utf8"),loader:r}})}}}var _=new Map,L=Symbol.for("stx.client-bundle-build-queue");function W(n){let i=globalThis,c=(i[L]??Promise.resolve()).then(n,n);return i[L]=c.then(()=>{return},()=>{return}),c}async function ue(n,i,c={}){let f=c.projectRoot||process.cwd(),d=c.minify??!1,s=c.cacheDir||R(f,"bundle-cache"),t=new Bun.CryptoHasher("md5");t.update(`${Z}\x00${n}\x00${i}`);let e=t.digest("hex").slice(0,12),r=o.join(s,`${e}.js`),u=o.join(s,`${e}.deps.json`),h=Bun.file(r);if(await h.exists()){let x=Bun.file(u),b=!0;if(await x.exists())try{let B=JSON.parse(await x.text());if(B.metadataVersion!==U||!Array.isArray(B.files))b=!1;for(let m of Array.isArray(B.files)?B.files:[])try{if(p.statSync(m.path).mtimeMs!==m.mtimeMs){b=!1;break}}catch{b=!1;break}}catch{b=!1}if(b)return g("cache hit:",e),await h.text();g("cache invalidated by dep change:",e)}let v=_.get(e);if(v)return await v;let S=W(()=>Y(n,i,{projectRoot:f,minify:d,cacheDir:s,hash:e,cachePath:r,depsPath:u}));_.set(e,S);try{return await S}finally{_.delete(e)}}async function Y(n,i,c){let{projectRoot:f,minify:d,cacheDir:s,hash:t,cachePath:e,depsPath:r}=c,u=R(f,"bundle-tmp"),h=o.join(u,`${t}.ts`),v=o.join(u,"out",t);p.mkdirSync(u,{recursive:!0}),p.mkdirSync(v,{recursive:!0});let S=o.dirname(i),x=[],b=/^(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,B=/^(export\s+)?(?:async\s+)?function\s+(\w+)/gm,m;while((m=b.exec(n))!==null){if(m[1])continue;if(m[2])m[2].split(",").forEach((y)=>{let l=y.split(":")[0].trim();if(l)x.push(l)});else if(m[3])x.push(m[3])}while((m=B.exec(n))!==null){if(m[1])continue;x.push(m[2])}let V=x.length>0?`
3
+ export { ${x.join(", ")} }`:"";await Bun.write(h,n+V),g("bundling:",t,"from:",o.basename(i));let F=new Set;try{let y=await Bun.build({entrypoints:[h],outdir:v,target:"browser",format:"esm",minify:d,plugins:[K(f,S,h,F)],define:{"process.env.NODE_ENV":d?'"production"':'"development"',...O()},root:f});if(!y.success){let a=y.logs.filter((w)=>w.level==="error").map((w)=>w.message).join(", ");return console.warn("[stx:bundler] build failed:",a),n}let l="";for(let a of y.outputs){l=await a.text();break}let j=[];for(let a of l.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let w of a[1].split(",")){let E=w.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(E){j.push([E[2],E[1]]);continue}let D=w.trim();if(/^[A-Za-z_$][\w$]*$/.test(D))j.push([D,D])}let J=l.match(/^\s*import\s+[^;]+;?\s*$/gm)||[];l=l.replace(/^\s*import\s+[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim();let k=`__stxBundle_${t}`,z=j.map(([a,w])=>`${JSON.stringify(a)}: ${w}`).join(", "),H=j.map(([a])=>`var ${a} = undefined;`).join(`
4
+ `),P=j.map(([a])=>`${a} = ${k}[${JSON.stringify(a)}];`).join(`
5
+ `);if(l=`${J.join(`
6
+ `)}
7
+ ${H}
8
+ var ${k} = (function() {
9
+ ${l}
10
+ return { ${z} };
11
+ })();
12
+ ${P}`.trim(),g("bundled:",t,"output:",l.length,"bytes"),x.length>0&&j.length===0)return console.warn(`[stx:bundler] dropped every binding for ${o.basename(i)} (${t}); serving the unbundled source and not caching this result`),n;p.mkdirSync(s,{recursive:!0}),await Bun.write(e,l);let X=Array.from(F).map((a)=>{try{return{path:a,mtimeMs:p.statSync(a).mtimeMs}}catch{return null}}).filter((a)=>a!==null);return await Bun.write(r,JSON.stringify({metadataVersion:U,files:X})),l}catch(y){let l=T(y,i||void 0),j=I(y,i||void 0);if(console.warn(`[stx:bundler] error: ${j}`),G(i||"",j,l),Q()==="error")throw y;return n}finally{try{p.rmSync(h,{force:!0}),p.rmSync(v,{recursive:!0,force:!0})}catch{}}}export{ue as bundleClientScript,ce as clearBundleFailures,ie as getBundleFailures,le as hasUserImports,W as queueClientBundleBuild,G as recordBundleFailure,Q as resolveBundlerFallback,ae as setBundlerFallbackMode,q as shouldLogBundlerDiagnostics};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{pl as a,ql as b}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{b as processComponents,a as processESImports};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{we as a}from"./chunk-nhmtg01n.js";import"./chunk-nf3kv7kv.js";export{a as processDeferDirectives};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- var p={},b=[],m={};function A(){return p}function _(){return m}function w(){p={},b.length=0,m={}}function h(t){p=c(p,t)}function c(t,e){return{title:e.title??t.title,titleTemplate:e.titleTemplate??t.titleTemplate,base:e.base??t.base,meta:[...t.meta||[],...e.meta||[]],link:[...t.link||[],...e.link||[]],script:[...t.script||[],...e.script||[]],style:[...t.style||[],...e.style||[]],htmlAttrs:{...t.htmlAttrs,...e.htmlAttrs},bodyAttrs:{...t.bodyAttrs,...e.bodyAttrs}}}function f(t){h($(t))}function $(t){let e=[];if(t.description)e.push({name:"description",content:t.description});if(t.keywords){let a=Array.isArray(t.keywords)?t.keywords.join(", "):t.keywords;e.push({name:"keywords",content:a})}if(t.author)e.push({name:"author",content:t.author});if(t.robots)e.push({name:"robots",content:t.robots});let r=t.ogTitle??t.title,i=t.ogDescription??t.description;if(r)e.push({property:"og:title",content:r});if(i)e.push({property:"og:description",content:i});if(t.ogImage)e.push({property:"og:image",content:t.ogImage});if(t.ogUrl)e.push({property:"og:url",content:t.ogUrl});if(t.ogType)e.push({property:"og:type",content:t.ogType});if(t.ogSiteName)e.push({property:"og:site_name",content:t.ogSiteName});if(t.ogLocale)e.push({property:"og:locale",content:t.ogLocale});let n=t.twitterTitle??t.title,s=t.twitterDescription??t.description,l=t.twitterImage??t.ogImage;if(t.twitterCard)e.push({name:"twitter:card",content:t.twitterCard});if(n)e.push({name:"twitter:title",content:n});if(s)e.push({name:"twitter:description",content:s});if(l)e.push({name:"twitter:image",content:l});if(t.twitterSite)e.push({name:"twitter:site",content:t.twitterSite});if(t.twitterCreator)e.push({name:"twitter:creator",content:t.twitterCreator});if(t.articleAuthor)e.push({property:"article:author",content:t.articleAuthor});if(t.articlePublishedTime)e.push({property:"article:published_time",content:t.articlePublishedTime});if(t.articleModifiedTime)e.push({property:"article:modified_time",content:t.articleModifiedTime});if(t.articleSection)e.push({property:"article:section",content:t.articleSection});if(t.articleTags)for(let a of t.articleTags)e.push({property:"article:tag",content:a});let o=[];if(t.canonical)o.push({rel:"canonical",href:t.canonical});return{title:t.title,titleTemplate:t.titleTemplate,meta:e,link:o}}function k(t){if(m={...m,...t},t.title||t.description)f({title:t.title,description:t.description})}function x(t){let e=typeof t==="function"?t():t;h({title:e})}function j(t=p){let e=[];if(t.title){let r=t.title;if(t.titleTemplate)r=typeof t.titleTemplate==="function"?t.titleTemplate(r):t.titleTemplate.replace("%s",r);e.push(`<title>${u(r)}</title>`)}if(t.base){let r=Object.entries(t.base).map(([i,n])=>`${i}="${u(n)}"`).join(" ");e.push(`<base ${r}>`)}for(let r of t.meta||[]){let i=Object.entries(r).filter(([n,s])=>s!==void 0).map(([n,s])=>{return`${n==="httpEquiv"?"http-equiv":n}="${u(String(s))}"`}).join(" ");e.push(`<meta ${i}>`)}for(let r of t.link||[]){let i=Object.entries(r).filter(([n,s])=>s!==void 0).map(([n,s])=>`${n}="${u(String(s))}"`).join(" ");e.push(`<link ${i}>`)}for(let r of t.script||[]){let{content:i,...n}=r,s=Object.entries(n).filter(([l,o])=>o!==void 0).map(([l,o])=>{if(typeof o==="boolean")return o?l:"";return`${l}="${u(String(o))}"`}).filter(Boolean).join(" ");if(i)e.push(`<script ${s}>${i}</script>`);else e.push(`<script ${s}></script>`)}for(let r of t.style||[]){let i=r.type?` type="${r.type}"`:"";e.push(`<style${i}>${r.content}</style>`)}return e.join(`
3
- `)}function S(t=p){if(!t.htmlAttrs)return"";return Object.entries(t.htmlAttrs).map(([e,r])=>`${e}="${u(r)}"`).join(" ")}function H(t=p){if(!t.bodyAttrs)return"";return Object.entries(t.bodyAttrs).map(([e,r])=>`${e}="${u(r)}"`).join(" ")}function u(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function C(t=p){if(typeof document>"u")return;if(t.title){let e=t.title;if(t.titleTemplate)e=typeof t.titleTemplate==="function"?t.titleTemplate(e):t.titleTemplate.replace("%s",e);document.title=e}for(let e of t.meta||[]){let r=e.name?`meta[name="${e.name}"]`:e.property?`meta[property="${e.property}"]`:null;if(r){let i=document.querySelector(r);if(!i){if(i=document.createElement("meta"),e.name)i.setAttribute("name",e.name);if(e.property)i.setAttribute("property",e.property);document.head.appendChild(i)}i.setAttribute("content",e.content)}}for(let e of t.link||[]){let r=`link[rel="${e.rel}"]${e.href?`[href="${e.href}"]`:""}`,i=document.querySelector(r);if(!i)i=document.createElement("link"),document.head.appendChild(i);for(let[n,s]of Object.entries(e))if(s!==void 0)i.setAttribute(n,String(s))}if(t.htmlAttrs)for(let[e,r]of Object.entries(t.htmlAttrs))if(e==="class")for(let i of String(r).split(/\s+/).filter(Boolean))document.documentElement.classList.add(i);else document.documentElement.setAttribute(e,r);if(t.bodyAttrs)for(let[e,r]of Object.entries(t.bodyAttrs))document.body.setAttribute(e,r)}function O(t){let e="";return{content:t.replace(/@head\s*([\s\S]*?)@endhead/g,(r,i)=>{return e+=i.trim()+`
4
- `,""}),headContent:e.trim()}}function M(t,e){return t.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(r,i,n,s)=>{let l=i?n:e[(s||"").trim()]??s,o=e.__stx_runtime_head??{};return e.__stx_runtime_head=c(o,{title:l}),""})}function D(t,e){return t.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(r,i,n,s,l,o)=>{let a=s?l:o,d=s?a:e[(a||"").trim()]??a,y=n.includes(":")?{property:n,content:d}:{name:n,content:d},T=e.__stx_runtime_head??{};return e.__stx_runtime_head=c(T,{meta:[y]}),""})}export{A as En,_ as Fn,w as Gn,h as Hn,c as In,f as Jn,$ as Kn,k as Ln,x as Mn,j as Nn,S as On,H as Pn,C as Qn,O as Rn,M as Sn,D as Tn};
2
+ var p={},b=[],m={};function _(){return p}function w(){return m}function k(){p={},b.length=0,m={}}function h(t){p=c(p,t)}function c(t,e){return{title:e.title??t.title,titleTemplate:e.titleTemplate??t.titleTemplate,base:e.base??t.base,meta:[...t.meta||[],...e.meta||[]],link:[...t.link||[],...e.link||[]],script:[...t.script||[],...e.script||[]],style:[...t.style||[],...e.style||[]],htmlAttrs:{...t.htmlAttrs,...e.htmlAttrs},bodyAttrs:{...t.bodyAttrs,...e.bodyAttrs}}}function f(t){h(A(t))}function A(t){let e=[];if(t.description)e.push({name:"description",content:t.description});if(t.keywords){let a=Array.isArray(t.keywords)?t.keywords.join(", "):t.keywords;e.push({name:"keywords",content:a})}if(t.author)e.push({name:"author",content:t.author});if(t.robots)e.push({name:"robots",content:t.robots});let r=t.ogTitle??t.title,i=t.ogDescription??t.description;if(r)e.push({property:"og:title",content:r});if(i)e.push({property:"og:description",content:i});if(t.ogImage)e.push({property:"og:image",content:t.ogImage});if(t.ogUrl)e.push({property:"og:url",content:t.ogUrl});if(t.ogType)e.push({property:"og:type",content:t.ogType});if(t.ogSiteName)e.push({property:"og:site_name",content:t.ogSiteName});if(t.ogLocale)e.push({property:"og:locale",content:t.ogLocale});let n=t.twitterTitle??t.title,s=t.twitterDescription??t.description,l=t.twitterImage??t.ogImage;if(t.twitterCard)e.push({name:"twitter:card",content:t.twitterCard});if(n)e.push({name:"twitter:title",content:n});if(s)e.push({name:"twitter:description",content:s});if(l)e.push({name:"twitter:image",content:l});if(t.twitterSite)e.push({name:"twitter:site",content:t.twitterSite});if(t.twitterCreator)e.push({name:"twitter:creator",content:t.twitterCreator});if(t.articleAuthor)e.push({property:"article:author",content:t.articleAuthor});if(t.articlePublishedTime)e.push({property:"article:published_time",content:t.articlePublishedTime});if(t.articleModifiedTime)e.push({property:"article:modified_time",content:t.articleModifiedTime});if(t.articleSection)e.push({property:"article:section",content:t.articleSection});if(t.articleTags)for(let a of t.articleTags)e.push({property:"article:tag",content:a});let o=[];if(t.canonical)o.push({rel:"canonical",href:t.canonical});return{title:t.title,titleTemplate:t.titleTemplate,meta:e,link:o}}function x(t){if(m={...m,...t},t.title||t.description)f({title:t.title,description:t.description})}function j(t){let e=typeof t==="function"?t():t;h({title:e})}function S(t=p){let e=[];if(t.title){let r=t.title;if(t.titleTemplate)r=typeof t.titleTemplate==="function"?t.titleTemplate(r):t.titleTemplate.replace("%s",r);e.push(`<title>${u(r)}</title>`)}if(t.base){let r=Object.entries(t.base).map(([i,n])=>`${i}="${u(n)}"`).join(" ");e.push(`<base ${r}>`)}for(let r of t.meta||[]){let i=Object.entries(r).filter(([n,s])=>s!==void 0).map(([n,s])=>`${n==="httpEquiv"?"http-equiv":n}="${u(String(s))}"`).join(" ");e.push(`<meta ${i}>`)}for(let r of t.link||[]){let i=Object.entries(r).filter(([n,s])=>s!==void 0).map(([n,s])=>`${n}="${u(String(s))}"`).join(" ");e.push(`<link ${i}>`)}for(let r of t.script||[]){let{content:i,...n}=r,s=Object.entries(n).filter(([l,o])=>o!==void 0).map(([l,o])=>{if(typeof o==="boolean")return o?l:"";return`${l}="${u(String(o))}"`}).filter(Boolean).join(" ");if(i)e.push(`<script ${s}>${i}</script>`);else e.push(`<script ${s}></script>`)}for(let r of t.style||[]){let i=r.type?` type="${r.type}"`:"";e.push(`<style${i}>${r.content}</style>`)}return e.join(`
3
+ `)}function H(t=p){if(!t.htmlAttrs)return"";return Object.entries(t.htmlAttrs).map(([e,r])=>`${e}="${u(r)}"`).join(" ")}function C(t=p){if(!t.bodyAttrs)return"";return Object.entries(t.bodyAttrs).map(([e,r])=>`${e}="${u(r)}"`).join(" ")}function u(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function O(t=p){if(typeof document>"u")return;if(t.title){let e=t.title;if(t.titleTemplate)e=typeof t.titleTemplate==="function"?t.titleTemplate(e):t.titleTemplate.replace("%s",e);document.title=e}for(let e of t.meta||[]){let r=e.name?`meta[name="${e.name}"]`:e.property?`meta[property="${e.property}"]`:null;if(r){let i=document.querySelector(r);if(!i){if(i=document.createElement("meta"),e.name)i.setAttribute("name",e.name);if(e.property)i.setAttribute("property",e.property);document.head.appendChild(i)}i.setAttribute("content",e.content)}}for(let e of t.link||[]){let r=`link[rel="${e.rel}"]${e.href?`[href="${e.href}"]`:""}`,i=document.querySelector(r);if(!i)i=document.createElement("link"),document.head.appendChild(i);for(let[n,s]of Object.entries(e))if(s!==void 0)i.setAttribute(n,String(s))}if(t.htmlAttrs)for(let[e,r]of Object.entries(t.htmlAttrs))if(e==="class")for(let i of String(r).split(/\s+/).filter(Boolean))document.documentElement.classList.add(i);else document.documentElement.setAttribute(e,r);if(t.bodyAttrs)for(let[e,r]of Object.entries(t.bodyAttrs))document.body.setAttribute(e,r)}function M(t){let e="";return{content:t.replace(/@head\s*([\s\S]*?)@endhead/g,(r,i)=>(e+=i.trim()+`
4
+ `,"")),headContent:e.trim()}}function D(t,e){return t.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(r,i,n,s)=>{let l=i?n:e[(s||"").trim()]??s,o=e.__stx_runtime_head??{};return e.__stx_runtime_head=c(o,{title:l}),""})}function v(t,e){return t.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(r,i,n,s,l,o)=>{let a=s?l:o,d=s?a:e[(a||"").trim()]??a,y=n.includes(":")?{property:n,content:d}:{name:n,content:d},T=e.__stx_runtime_head??{};return e.__stx_runtime_head=c(T,{meta:[y]}),""})}export{_ as En,w as Fn,k as Gn,h as Hn,c as In,f as Jn,A as Kn,x as Ln,j as Mn,S as Nn,H as On,C as Pn,O as Qn,M as Rn,D as Sn,v as Tn};