@stacksjs/stx 0.2.504 → 0.2.507

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 (133) hide show
  1. package/dist/browser-core-imports.d.ts +1 -1
  2. package/dist/browser-core-imports.js +1 -2
  3. package/dist/builtins/attrs.d.ts +2 -0
  4. package/dist/builtins/attrs.js +102 -0
  5. package/dist/{chunk-ygetbydb.js → chunk-068ank60.js} +3 -3
  6. package/dist/{chunk-81byredt.js → chunk-06v0c3fz.js} +1 -1
  7. package/dist/{chunk-x96ardq0.js → chunk-0vnr7mz7.js} +8 -8
  8. package/dist/{chunk-czmw5xsd.js → chunk-1149d93e.js} +2 -2
  9. package/dist/chunk-1b7dd8rn.js +2 -0
  10. package/dist/{chunk-49p5j9ab.js → chunk-1verz406.js} +5 -5
  11. package/dist/{chunk-78yx6xxn.js → chunk-2wr0sk42.js} +1 -1
  12. package/dist/chunk-36rwfhnb.js +2 -0
  13. package/dist/{chunk-dn9fxpwt.js → chunk-38xtsdk9.js} +2 -2
  14. package/dist/chunk-3pczp9c0.js +2 -0
  15. package/dist/{chunk-fesb4h31.js → chunk-46wre9ep.js} +3 -3
  16. package/dist/chunk-4w358hpx.js +2 -0
  17. package/dist/{chunk-gxs2p0y7.js → chunk-5dh041x0.js} +1 -1
  18. package/dist/{chunk-133ggr0t.js → chunk-5tbqdz94.js} +2 -2
  19. package/dist/{chunk-zv0vgamy.js → chunk-5tkzfw4s.js} +3 -3
  20. package/dist/{chunk-38mtn4ce.js → chunk-5zm23zrb.js} +36 -10
  21. package/dist/{chunk-azza6dcr.js → chunk-68tzytfz.js} +1 -1
  22. package/dist/chunk-76g4jw9g.js +2 -0
  23. package/dist/{chunk-a771dfsg.js → chunk-7p6y0b47.js} +1 -1
  24. package/dist/{chunk-17fan751.js → chunk-7sjmpfwy.js} +3 -3
  25. package/dist/chunk-7z28hk7r.js +2 -0
  26. package/dist/{chunk-667d6fz8.js → chunk-8nx5asjr.js} +1 -1
  27. package/dist/{chunk-d5x1t498.js → chunk-8ptefdpy.js} +1 -1
  28. package/dist/chunk-8zj1ebs5.js +2 -0
  29. package/dist/{chunk-p4gbvge6.js → chunk-91y360rc.js} +1 -1
  30. package/dist/chunk-96kr2xrt.js +2828 -0
  31. package/dist/{chunk-5cyz97t4.js → chunk-9p3rtfbv.js} +4 -4
  32. package/dist/chunk-9xw416q3.js +2 -0
  33. package/dist/chunk-9z76qhdm.js +2 -0
  34. package/dist/{chunk-jt842kx3.js → chunk-9z8mxp15.js} +1 -1
  35. package/dist/{chunk-bcgfg3x0.js → chunk-ag1j84s6.js} +1 -1
  36. package/dist/{chunk-d4k4nyj0.js → chunk-ba88n1j7.js} +2 -2
  37. package/dist/chunk-c2vwq6gr.js +2 -0
  38. package/dist/{chunk-cpj9b887.js → chunk-cb1c9mvc.js} +1 -1
  39. package/dist/{chunk-cctb8fnj.js → chunk-ces3vdjp.js} +1 -1
  40. package/dist/{chunk-szkqmwjg.js → chunk-cprcfp0j.js} +1 -1
  41. package/dist/chunk-dn4tww9q.js +2 -0
  42. package/dist/chunk-dv94gdv4.js +2 -0
  43. package/dist/chunk-e4zks32s.js +2 -0
  44. package/dist/{chunk-amd52bnv.js → chunk-ea19gveh.js} +3 -3
  45. package/dist/chunk-fkv8jmse.js +2 -0
  46. package/dist/{chunk-mfcdbqvd.js → chunk-fwvqbx49.js} +5 -5
  47. package/dist/chunk-g1r4v0mc.js +3 -0
  48. package/dist/{chunk-798epzq5.js → chunk-g495xx4v.js} +5 -5
  49. package/dist/{chunk-9836wtag.js → chunk-gw9ax7xx.js} +1 -1
  50. package/dist/{chunk-0gp4sj0v.js → chunk-h37bbgg8.js} +1 -1
  51. package/dist/chunk-h3rrsq05.js +2 -0
  52. package/dist/{chunk-ywv2838m.js → chunk-h87zhtw8.js} +1 -1
  53. package/dist/{chunk-2abv46yw.js → chunk-hka18tmt.js} +1 -1
  54. package/dist/chunk-j08y5n2k.js +2 -0
  55. package/dist/chunk-j7nd8zfe.js +2 -0
  56. package/dist/{chunk-bt51kf9z.js → chunk-k2331dfx.js} +1 -1
  57. package/dist/{chunk-kr5ap3qn.js → chunk-k5syze27.js} +1 -1
  58. package/dist/{chunk-5q27xq7w.js → chunk-mq6expbd.js} +1 -1
  59. package/dist/{chunk-0kj3qs23.js → chunk-mvqhf6dn.js} +1 -1
  60. package/dist/chunk-mz7snf2b.js +2 -0
  61. package/dist/chunk-n1hd2fx6.js +2 -0
  62. package/dist/{chunk-37hm4er5.js → chunk-nnrtwpvy.js} +1 -1
  63. package/dist/chunk-pecwdp57.js +2 -0
  64. package/dist/{chunk-5kq996qy.js → chunk-ph1xz7k5.js} +2 -2
  65. package/dist/{chunk-qcj12mtw.js → chunk-pj562qnx.js} +1 -1
  66. package/dist/chunk-pzcw3trh.js +2 -0
  67. package/dist/{chunk-fd6abk20.js → chunk-qt31at4s.js} +3 -3
  68. package/dist/{chunk-88xqy2b9.js → chunk-r14mvycg.js} +4 -4
  69. package/dist/chunk-r5fzxtbc.js +2 -0
  70. package/dist/{chunk-3y8ykqpx.js → chunk-rvwtyrj4.js} +1 -1
  71. package/dist/chunk-rx90ktrb.js +45 -0
  72. package/dist/{chunk-kbhm1wqt.js → chunk-s87qrma5.js} +2 -2
  73. package/dist/chunk-spg0fzyv.js +2 -0
  74. package/dist/{chunk-xevnx24r.js → chunk-tnxprz69.js} +2 -2
  75. package/dist/{chunk-a5c75hxe.js → chunk-v74acg2k.js} +1 -1
  76. package/dist/chunk-w925gtgg.js +2 -0
  77. package/dist/{chunk-rnnead1w.js → chunk-w9kj6t7s.js} +1 -1
  78. package/dist/{chunk-2242bx8y.js → chunk-w9mxt96c.js} +35 -35
  79. package/dist/{chunk-hmyyq2hh.js → chunk-z2775k8r.js} +1 -1
  80. package/dist/{chunk-6k4f583z.js → chunk-zz5b1g50.js} +2 -2
  81. package/dist/cli.js +9 -9
  82. package/dist/component-renderer.js +84 -36
  83. package/dist/composables/index.d.ts +4 -0
  84. package/dist/composables/index.js +5 -1
  85. package/dist/composables/use-timer.d.ts +8 -0
  86. package/dist/composables/use-timer.js +4 -0
  87. package/dist/config.js +24 -7
  88. package/dist/craft-entry.js +2 -2
  89. package/dist/craft.js +2 -2
  90. package/dist/native/compiler/html-to-ir.d.ts +3 -1
  91. package/dist/native/compiler/html-to-ir.js +13 -0
  92. package/dist/native/runtime/craft-bridge.js +3 -1
  93. package/dist/native/runtime/craft.d.ts +2 -0
  94. package/dist/native/runtime/native-host.d.ts +1 -0
  95. package/dist/native/runtime/native-host.js +1 -0
  96. package/dist/pwa.js +1 -1
  97. package/dist/runtime-globals.js +4 -0
  98. package/dist/signals.js +34 -8
  99. package/dist/ssg.js +2 -2
  100. package/dist/stx-module.d.ts +4 -0
  101. package/dist/stx.d.ts +8 -0
  102. package/dist/utils.d.ts +3 -1
  103. package/dist/utils.js +12 -2
  104. package/package.json +6 -6
  105. package/stx-module.d.ts +4 -0
  106. package/stx.d.ts +8 -0
  107. package/dist/chunk-0np4t9ka.js +0 -2828
  108. package/dist/chunk-18pxh9sv.js +0 -2
  109. package/dist/chunk-2grygc4b.js +0 -2
  110. package/dist/chunk-3kxh9rsp.js +0 -2
  111. package/dist/chunk-5c1qesrs.js +0 -2
  112. package/dist/chunk-5yrn6whx.js +0 -2
  113. package/dist/chunk-7dmrxhq7.js +0 -2
  114. package/dist/chunk-9kt6g57t.js +0 -2
  115. package/dist/chunk-b3nz1qmj.js +0 -2
  116. package/dist/chunk-d161ndyz.js +0 -2
  117. package/dist/chunk-f6n6nrdq.js +0 -2
  118. package/dist/chunk-fgvdq014.js +0 -2
  119. package/dist/chunk-hzjk2027.js +0 -2
  120. package/dist/chunk-k0zadypg.js +0 -2
  121. package/dist/chunk-kxt6xb4j.js +0 -2
  122. package/dist/chunk-mba6khev.js +0 -2
  123. package/dist/chunk-pykeaf4h.js +0 -2
  124. package/dist/chunk-qky9zfvx.js +0 -2
  125. package/dist/chunk-rrvfgmqb.js +0 -2
  126. package/dist/chunk-s4c8vf27.js +0 -2
  127. package/dist/chunk-srhgfsz3.js +0 -2
  128. package/dist/chunk-t1x0x5sw.js +0 -2
  129. package/dist/chunk-txd6fq1x.js +0 -2
  130. package/dist/chunk-w78v0xek.js +0 -45
  131. package/dist/chunk-wrghqec5.js +0 -2
  132. package/dist/chunk-wy36z6qp.js +0 -2
  133. package/dist/chunk-xsc9zbaj.js +0 -3
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Ni,Li,ji}from"./chunk-xsc9zbaj.js";import{V,Dn,Xt,jr,Br,On,Gt,Jt,Fr,Mn}from"./chunk-x81vcxzs.js";function z(r,d=!0,u){if(!d||!r||typeof window>"u")return;let s=window;if(!s.__STX_DATA__){let y=document.querySelector("script[data-stx-server-data]");try{let h=JSON.parse(y?.textContent||"{}");s.__STX_DATA__=h&&typeof h==="object"&&!Array.isArray(h)?h:{}}catch{s.__STX_DATA__={}}}let i=s.__STX_DATA__;if(i&&Object.prototype.hasOwnProperty.call(i,r))try{return{data:u?u(i[r]):i[r]}}catch(y){return{data:null,error:y instanceof Error?y:Error(String(y))}}return}function X(r){if(typeof window>"u")return;let d=window;if(r===void 0)d.__STX_DATA__={};else{if(!d.__STX_DATA__)try{let u=JSON.parse(document.querySelector("script[data-stx-server-data]")?.textContent||"{}");d.__STX_DATA__=u&&typeof u==="object"&&!Array.isArray(u)?u:{}}catch{d.__STX_DATA__={}}if(d.__STX_DATA__)delete d.__STX_DATA__[r]}}function Q(r){let d=null;try{d=typeof indexedDB<"u"?indexedDB:null}catch{d=null}if(!d)return null;let u=d,s=r||"stx-kept",i=null,y=()=>{if(!i)i=new Promise((f,l)=>{let a=u.open(s,1);a.onupgradeneeded=()=>{a.result.createObjectStore("kv")},a.onsuccess=()=>f(a.result),a.onerror=()=>l(a.error),a.onblocked=()=>l(Error("blocked"))}),i.catch(()=>{i=null});return i},h=(f,l)=>y().then((a)=>new Promise((v,g)=>{let t=a.transaction("kv",f),o=l(t.objectStore("kv"));t.oncomplete=()=>v(o?o.result:void 0),t.onerror=()=>g(t.error),t.onabort=()=>g(t.error)}));return{get:(f)=>h("readonly",(l)=>l.get(f)),set:(f,l)=>h("readwrite",(a)=>{a.put(l,f)}),remove:(f)=>h("readwrite",(l)=>{l.delete(f)}),removePrefix:(f)=>h("readwrite",(l)=>{l.delete(IDBKeyRange.bound(f,`${f}\uFFFF`))})}}function G(r,d){let u=r||{},s=null;if(u.storage!==void 0)s=u.storage;else try{s=typeof localStorage<"u"?localStorage:null}catch{s=null}let i=null,y=u.backend!==void 0;if(y)i=u.backend||null;let h=()=>{if(y)return i;y=!0;try{i=d?d():null}catch{i=null}if(i){let e=i;e.get("__stx_probe__").catch(()=>{if(i===e)i=null})}return i},f=u.limit||32768,l=u.defer||((e)=>{let n=typeof requestIdleCallback==="function"?requestIdleCallback:null;if(n)n(e,{timeout:200});else setTimeout(e,16)}),a=new Map,v=new Set,g=new Map,t=!1,o=Promise.resolve(),m=(e)=>{try{return JSON.parse(e)}catch{return e}},p=(e,n)=>{if(!s)return!1;try{return s.setItem(e,n),!0}catch{return!1}},T=(e)=>{try{if(s)s.removeItem(e)}catch{}},S=()=>{if(t=!1,!g.size)return o;let e=Array.from(g.entries());return g.clear(),o=o.then(()=>Promise.all(e.map(([n,c])=>{if(!i){v.delete(n);try{p(n,JSON.stringify(c===void 0?null:c))}catch{}return}let _;try{return _={v:c},i.set(n,_).catch(()=>{let w;try{w=JSON.stringify(c)}catch{return}return i?i.set(n,{j:w}).catch(()=>{p(n,w)}):void 0})}catch{return}}))).then(()=>{}),o},R=(e,n)=>{if(g.set(e,n),v.add(e),t)return;t=!0,l(()=>{S()})},O=(e)=>{if(!e||typeof e!=="object")return;let n=e;if("v"in n)return{value:n.v};if(typeof n.j==="string")return{value:m(n.j)};return},E={peek(e){if(a.has(e))return{value:a.get(e)};let n=null;try{n=s?s.getItem(e):null}catch{n=null}if(n===null||n===void 0)return;let c=m(n);return a.set(e,c),{value:c}},load(e){let n=E.peek(e),c=n?null:h();if(n||!c)return Promise.resolve(n);return c.get(e).then((_)=>{if(a.has(e))return{value:a.get(e)};let w=O(_);if(w)a.set(e,w.value),v.add(e);return w},()=>{return})},set(e,n){if(a.set(e,n),i&&v.has(e)){R(e,n);return}let c;try{c=JSON.stringify(n===void 0?null:n)}catch{return}if(c.length<=f&&p(e,c))return;if(!h()){if(c.length>f)p(e,c);return}T(e),R(e,n)},forget(e){for(let c of Array.from(a.keys()))if(c.indexOf(e)===0)a.delete(c);for(let c of Array.from(g.keys()))if(c.indexOf(e)===0)g.delete(c);for(let c of Array.from(v))if(c.indexOf(e)===0)v.delete(c);try{if(s)for(let c=s.length-1;c>=0;c--){let _=s.key(c);if(_&&_.indexOf(e)===0)s.removeItem(_)}}catch{}let n=h();if(!n)return o;return o=o.then(()=>n.removePrefix(e)).catch(()=>{}),o},flush(){return S()}};try{if(typeof document<"u"&&document.addEventListener)document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")S()});if(typeof addEventListener==="function")addEventListener("pagehide",()=>{S()})}catch{}return E}function J(r,d){if(!r)return!1;if(r===d.key)return!0;if(!d.url)return!1;if(r===d.url)return!0;try{let u=typeof location<"u"&&location.origin&&location.origin!=="null"?location.origin:"http://localhost",s=new URL(r,u),i=new URL(d.url,u);if(s.origin!==i.origin||s.pathname!==i.pathname)return!1;return!s.search||s.search===i.search}catch{return!1}}function Y(r){let d=r.prefix||"stx:kept:",u=r.matches||((t,o)=>t===o.key||t===o.url),s=new Set,i=new Map,y,h=(t)=>t===void 0?y:t,f=(t,o)=>{let m=h(o);if(m===!1||m===null||m==="")return null;return`${d}${m===void 0?"":`${m}:`}query:${t}`},l=(t)=>{let o=t&&t.value;if(!o||typeof o!=="object"||!("d"in o))return;return{data:o.d,at:Number(o.at)||0}},a=()=>{let t=globalThis;return t.__stx_outboxes instanceof Map?t.__stx_outboxes:null},v={setScope(t){y=t},scope:()=>y,keyFor:f,seed(t,o){let m=f(t,o);return m?l(r.kept.peek(m)):void 0},restore(t,o){let m=f(t,o);return m?r.kept.load(m).then(l):Promise.resolve(void 0)},persist(t,o,m){let p=f(t,m);if(p)r.kept.set(p,{d:o,at:Date.now()})},overlay(t,o,m){let p=a();if(!p||!p.size)return o;let T=o;return p.forEach((S)=>{try{T=S.overlay(t,T,m)}catch{}}),T},watch(t){return s.add(t),()=>{s.delete(t)}},cachedQuery(t,o){let m=i.get(t);if(m){if(o&&m.__options)m.__options(o);return m}let p=o||{},T=p.initial===void 0?null:p.initial,S=()=>typeof p.scope==="function"?p.scope():p.scope,R=()=>(typeof p.url==="function"?p.url():p.url)||null,O=()=>({key:t,url:R()}),E=S(),e=T,n=0,c=null,_=v.seed(t,E);if(_)e=_.data;let w=r.state(v.overlay(O(),e)),H=r.state(!1),q=r.state(!1),B=r.state(null),I=r.state(_?_.at:0),N=0,P=()=>{w.set(v.overlay(O(),e))},W=(b)=>{let x=N;v.restore(t,b).then((C)=>{if(!C||x!==N||n)return;e=C.data,I.set(C.at),P()})};if(!_)W(E);let ee=()=>{let b=S();if(b===E)return;E=b,N++,c=null,n=0;let x=v.seed(t,E);if(e=x?x.data:T,I.set(x?x.at:0),P(),!x)W(E)},te=(b)=>{let x=R(),C=p.timeoutMs||15000,A=typeof AbortController<"u"?new AbortController:null,k=null,ne=new Promise((D,L)=>{k=setTimeout(()=>{if(A)A.abort();L(Error("The request took too long."))},C)}),K;if(p.load)K=p.load({force:b,url:x,signal:A?A.signal:void 0});else if(x){let D=p.fetch||((M,F)=>fetch(M,F)),L={method:"GET",headers:{Accept:"application/json"}};if(b)L.cache="no-cache";if(A)L.signal=A.signal;K=D(x,L).then((M)=>{if(!M.ok)return M.json().catch(()=>null).then((F)=>{throw Error(F&&(F.error||F.message)||`Request failed (${M.status})`)});return M.json()})}else return Promise.resolve(w());return Promise.race([K,ne]).then((D)=>{if(k)clearTimeout(k);return p.transform?p.transform(D):D},(D)=>{if(k)clearTimeout(k);throw D})},U=(b)=>{if(c)return c;let x=N;if(q.set(!0),n===0&&!I())H.set(!0);let C=()=>{if(x!==N)return;c=null,q.set(!1),H.set(!1)},A=te(b).then((k)=>{if(x!==N)return w();return e=k,n=Date.now(),I.set(n),B.set(null),v.persist(t,k,E),P(),C(),w()},(k)=>{if(x===N)B.set(k&&k.message?k.message:"Could not load.");return C(),w()});return c=A,A},j={data:w,loading:H,isFetching:q,error:B,updatedAt:I,get key(){return t},load(b){if(ee(),!b&&n&&Date.now()-n<(p.staleTime||0))return Promise.resolve(w());return U(!!b)},refresh(){return j.load(!0)},set(b){e=typeof b==="function"?b(e):b,v.persist(t,e,E),P()},invalidate(){n=0},__options(b){p={...p,...b}}};if(s.add({target:O,updated:()=>{if(n||I())U(!1)},outbox:(b)=>{if(b)e=v.overlay(O(),e,b.id),n=0,U(!0);P()}}),i.set(t,j),p.immediate)j.load();return j}},g=typeof window<"u"?window:typeof addEventListener==="function"?globalThis:null;if(r.listen!==!1&&g&&typeof g.addEventListener==="function")g.addEventListener("stx:updated",(t)=>{let o=t.detail||{};if(o.kind!=="api"||typeof o.url!=="string")return;s.forEach((m)=>{if(u(o.url,m.target()))m.updated()})}),g.addEventListener("stx:outbox",(t)=>{let o=t.detail||{},m=o.sent&&typeof o.sent.id==="string"?o.sent:null;s.forEach((p)=>{if(m){let T=Array.isArray(m.affects)?m.affects:[],S=p.target();if(!T.some((R)=>u(R,S)))return}p.outbox(m)})});return v}function Z(r,d,u,s,i){let y=!0,h=new Set,f=(a)=>s.get?s.get(a):a,l=()=>f(r());return Object.defineProperty(l,"_isSignal",{value:!0}),Object.defineProperty(l,"modifiers",{get:d}),l.set=(a)=>{if(!y)return;let v=d(),g=s.set?s.set(a,v):a;if(v.trim&&typeof g==="string")g=g.trim();if(v.number&&typeof g==="string"&&g!==""){let t=Number(g);if(!Number.isNaN(t))g=t}if(Object.is(r(),g))return;r.set(g),u(g)},l.update=(a)=>l.set(a(l())),l.input=(a)=>{if(!d().lazy)l.set(a)},l.change=(a)=>{if(d().lazy)l.set(a)},l.subscribe=(a)=>{if(!y)return()=>{};let v=r.subscribe((g,t)=>a(f(g),f(t)));return h.add(v),()=>{v(),h.delete(v)}},Object.defineProperty(l,"value",{get:l,set:l.set}),i(()=>{y=!1,h.forEach((a)=>a()),h.clear()}),l}function De(){let r=re(Kt());try{let u=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(r);return u=u.replace(/\}(var |let |const |function )/g,"};$1"),u}catch{return r}}function re(r){let d=[],u=0,s="console.log(";while(u<r.length){let i=r.indexOf(s,u);if(i===-1){d.push(r.slice(u));break}d.push(r.slice(u,i));let y=1,h=i+s.length;while(h<r.length&&y>0){let f=r[h];if(f==='"'||f==="'"||f==="`"){let l=f;h++;while(h<r.length&&r[h]!==l){if(r[h]==="\\")h++;h++}h++;continue}if(f==="(")y++;else if(f===")")y--;h++}d.push("0"),u=h}return d.join("")}function Kt(){return`
2
+ import{Ni,Li,ji}from"./chunk-g1r4v0mc.js";import{V,Dn,Xt,jr,Br,On,Gt,Jt,Fr,Mn}from"./chunk-x81vcxzs.js";function W(r,d=!0,u){if(!d||!r||typeof window>"u")return;let s=window;if(!s.__STX_DATA__){let y=document.querySelector("script[data-stx-server-data]");try{let h=JSON.parse(y?.textContent||"{}");s.__STX_DATA__=h&&typeof h==="object"&&!Array.isArray(h)?h:{}}catch{s.__STX_DATA__={}}}let i=s.__STX_DATA__;if(i&&Object.prototype.hasOwnProperty.call(i,r))try{return{data:u?u(i[r]):i[r]}}catch(y){return{data:null,error:y instanceof Error?y:Error(String(y))}}return}function X(r){if(typeof window>"u")return;let d=window;if(r===void 0)d.__STX_DATA__={};else{if(!d.__STX_DATA__)try{let u=JSON.parse(document.querySelector("script[data-stx-server-data]")?.textContent||"{}");d.__STX_DATA__=u&&typeof u==="object"&&!Array.isArray(u)?u:{}}catch{d.__STX_DATA__={}}if(d.__STX_DATA__)delete d.__STX_DATA__[r]}}function Q(r){let d=null;try{d=typeof indexedDB<"u"?indexedDB:null}catch{d=null}if(!d)return null;let u=d,s=r||"stx-kept",i=null,y=()=>{if(!i)i=new Promise((f,l)=>{let a=u.open(s,1);a.onupgradeneeded=()=>{a.result.createObjectStore("kv")},a.onsuccess=()=>f(a.result),a.onerror=()=>l(a.error),a.onblocked=()=>l(Error("blocked"))}),i.catch(()=>{i=null});return i},h=(f,l)=>y().then((a)=>new Promise((v,g)=>{let t=a.transaction("kv",f),o=l(t.objectStore("kv"));t.oncomplete=()=>v(o?o.result:void 0),t.onerror=()=>g(t.error),t.onabort=()=>g(t.error)}));return{get:(f)=>h("readonly",(l)=>l.get(f)),set:(f,l)=>h("readwrite",(a)=>{a.put(l,f)}),remove:(f)=>h("readwrite",(l)=>{l.delete(f)}),removePrefix:(f)=>h("readwrite",(l)=>{l.delete(IDBKeyRange.bound(f,`${f}\uFFFF`))})}}function G(r,d){let u=r||{},s=null;if(u.storage!==void 0)s=u.storage;else try{s=typeof localStorage<"u"?localStorage:null}catch{s=null}let i=null,y=u.backend!==void 0;if(y)i=u.backend||null;let h=()=>{if(y)return i;y=!0;try{i=d?d():null}catch{i=null}if(i){let e=i;e.get("__stx_probe__").catch(()=>{if(i===e)i=null})}return i},f=u.limit||32768,l=u.defer||((e)=>{let n=typeof requestIdleCallback==="function"?requestIdleCallback:null;if(n)n(e,{timeout:200});else setTimeout(e,16)}),a=new Map,v=new Set,g=new Map,t=!1,o=Promise.resolve(),m=(e)=>{try{return JSON.parse(e)}catch{return e}},p=(e,n)=>{if(!s)return!1;try{return s.setItem(e,n),!0}catch{return!1}},T=(e)=>{try{if(s)s.removeItem(e)}catch{}},S=()=>{if(t=!1,!g.size)return o;let e=Array.from(g.entries());return g.clear(),o=o.then(()=>Promise.all(e.map(([n,c])=>{if(!i){v.delete(n);try{p(n,JSON.stringify(c===void 0?null:c))}catch{}return}let _;try{return _={v:c},i.set(n,_).catch(()=>{let w;try{w=JSON.stringify(c)}catch{return}return i?i.set(n,{j:w}).catch(()=>{p(n,w)}):void 0})}catch{return}}))).then(()=>{}),o},R=(e,n)=>{if(g.set(e,n),v.add(e),t)return;t=!0,l(()=>{S()})},O=(e)=>{if(!e||typeof e!=="object")return;let n=e;if("v"in n)return{value:n.v};if(typeof n.j==="string")return{value:m(n.j)};return},E={peek(e){if(a.has(e))return{value:a.get(e)};let n=null;try{n=s?s.getItem(e):null}catch{n=null}if(n===null||n===void 0)return;let c=m(n);return a.set(e,c),{value:c}},load(e){let n=E.peek(e),c=n?null:h();if(n||!c)return Promise.resolve(n);return c.get(e).then((_)=>{if(a.has(e))return{value:a.get(e)};let w=O(_);if(w)a.set(e,w.value),v.add(e);return w},()=>{return})},set(e,n){if(a.set(e,n),i&&v.has(e)){R(e,n);return}let c;try{c=JSON.stringify(n===void 0?null:n)}catch{return}if(c.length<=f&&p(e,c))return;if(!h()){if(c.length>f)p(e,c);return}T(e),R(e,n)},forget(e){for(let c of Array.from(a.keys()))if(c.indexOf(e)===0)a.delete(c);for(let c of Array.from(g.keys()))if(c.indexOf(e)===0)g.delete(c);for(let c of Array.from(v))if(c.indexOf(e)===0)v.delete(c);try{if(s)for(let c=s.length-1;c>=0;c--){let _=s.key(c);if(_&&_.indexOf(e)===0)s.removeItem(_)}}catch{}let n=h();if(!n)return o;return o=o.then(()=>n.removePrefix(e)).catch(()=>{}),o},flush(){return S()}};try{if(typeof document<"u"&&document.addEventListener)document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden")S()});if(typeof addEventListener==="function")addEventListener("pagehide",()=>{S()})}catch{}return E}function J(r,d){if(!r)return!1;if(r===d.key)return!0;if(!d.url)return!1;if(r===d.url)return!0;try{let u=typeof location<"u"&&location.origin&&location.origin!=="null"?location.origin:"http://localhost",s=new URL(r,u),i=new URL(d.url,u);if(s.origin!==i.origin||s.pathname!==i.pathname)return!1;return!s.search||s.search===i.search}catch{return!1}}function Y(r){let d=r.prefix||"stx:kept:",u=r.matches||((t,o)=>t===o.key||t===o.url),s=new Set,i=new Map,y,h=(t)=>t===void 0?y:t,f=(t,o)=>{let m=h(o);if(m===!1||m===null||m==="")return null;return`${d}${m===void 0?"":`${m}:`}query:${t}`},l=(t)=>{let o=t&&t.value;if(!o||typeof o!=="object"||!("d"in o))return;return{data:o.d,at:Number(o.at)||0}},a=()=>{let t=globalThis;return t.__stx_outboxes instanceof Map?t.__stx_outboxes:null},v={setScope(t){y=t},scope:()=>y,keyFor:f,seed(t,o){let m=f(t,o);return m?l(r.kept.peek(m)):void 0},restore(t,o){let m=f(t,o);return m?r.kept.load(m).then(l):Promise.resolve(void 0)},persist(t,o,m){let p=f(t,m);if(p)r.kept.set(p,{d:o,at:Date.now()})},overlay(t,o,m){let p=a();if(!p||!p.size)return o;let T=o;return p.forEach((S)=>{try{T=S.overlay(t,T,m)}catch{}}),T},watch(t){return s.add(t),()=>{s.delete(t)}},cachedQuery(t,o){let m=i.get(t);if(m){if(o&&m.__options)m.__options(o);return m}let p=o||{},T=p.initial===void 0?null:p.initial,S=()=>typeof p.scope==="function"?p.scope():p.scope,R=()=>(typeof p.url==="function"?p.url():p.url)||null,O=()=>({key:t,url:R()}),E=S(),e=T,n=0,c=null,_=v.seed(t,E);if(_)e=_.data;let w=r.state(v.overlay(O(),e)),H=r.state(!1),q=r.state(!1),B=r.state(null),I=r.state(_?_.at:0),N=0,P=()=>{w.set(v.overlay(O(),e))},z=(b)=>{let x=N;v.restore(t,b).then((C)=>{if(!C||x!==N||n)return;e=C.data,I.set(C.at),P()})};if(!_)z(E);let ee=()=>{let b=S();if(b===E)return;E=b,N++,c=null,n=0;let x=v.seed(t,E);if(e=x?x.data:T,I.set(x?x.at:0),P(),!x)z(E)},te=(b)=>{let x=R(),C=p.timeoutMs||15000,A=typeof AbortController<"u"?new AbortController:null,k=null,ne=new Promise((D,L)=>{k=setTimeout(()=>{if(A)A.abort();L(Error("The request took too long."))},C)}),K;if(p.load)K=p.load({force:b,url:x,signal:A?A.signal:void 0});else if(x){let D=p.fetch||((M,F)=>fetch(M,F)),L={method:"GET",headers:{Accept:"application/json"}};if(b)L.cache="no-cache";if(A)L.signal=A.signal;K=D(x,L).then((M)=>{if(!M.ok)return M.json().catch(()=>null).then((F)=>{throw Error(F&&(F.error||F.message)||`Request failed (${M.status})`)});return M.json()})}else return Promise.resolve(w());return Promise.race([K,ne]).then((D)=>{if(k)clearTimeout(k);return p.transform?p.transform(D):D},(D)=>{if(k)clearTimeout(k);throw D})},U=(b)=>{if(c)return c;let x=N;if(q.set(!0),n===0&&!I())H.set(!0);let C=()=>{if(x!==N)return;c=null,q.set(!1),H.set(!1)},A=te(b).then((k)=>{if(x!==N)return w();return e=k,n=Date.now(),I.set(n),B.set(null),v.persist(t,k,E),P(),C(),w()},(k)=>{if(x===N)B.set(k&&k.message?k.message:"Could not load.");return C(),w()});return c=A,A},j={data:w,loading:H,isFetching:q,error:B,updatedAt:I,get key(){return t},load(b){if(ee(),!b&&n&&Date.now()-n<(p.staleTime||0))return Promise.resolve(w());return U(!!b)},refresh(){return j.load(!0)},set(b){e=typeof b==="function"?b(e):b,v.persist(t,e,E),P()},invalidate(){n=0},__options(b){p={...p,...b}}};if(s.add({target:O,updated:()=>{if(n||I())U(!1)},outbox:(b)=>{if(b)e=v.overlay(O(),e,b.id),n=0,U(!0);P()}}),i.set(t,j),p.immediate)j.load();return j}},g=typeof window<"u"?window:typeof addEventListener==="function"?globalThis:null;if(r.listen!==!1&&g&&typeof g.addEventListener==="function")g.addEventListener("stx:updated",(t)=>{let o=t.detail||{};if(o.kind!=="api"||typeof o.url!=="string")return;s.forEach((m)=>{if(u(o.url,m.target()))m.updated()})}),g.addEventListener("stx:outbox",(t)=>{let o=t.detail||{},m=o.sent&&typeof o.sent.id==="string"?o.sent:null;s.forEach((p)=>{if(m){let T=Array.isArray(m.affects)?m.affects:[],S=p.target();if(!T.some((R)=>u(R,S)))return}p.outbox(m)})});return v}function Z(r,d,u,s,i){let y=!0,h=new Set,f=(a)=>s.get?s.get(a):a,l=()=>f(r());return Object.defineProperty(l,"_isSignal",{value:!0}),Object.defineProperty(l,"modifiers",{get:d}),l.set=(a)=>{if(!y)return;let v=d(),g=s.set?s.set(a,v):a;if(v.trim&&typeof g==="string")g=g.trim();if(v.number&&typeof g==="string"&&g!==""){let t=Number(g);if(!Number.isNaN(t))g=t}if(Object.is(r(),g))return;r.set(g),u(g)},l.update=(a)=>l.set(a(l())),l.input=(a)=>{if(!d().lazy)l.set(a)},l.change=(a)=>{if(d().lazy)l.set(a)},l.subscribe=(a)=>{if(!y)return()=>{};let v=r.subscribe((g,t)=>a(f(g),f(t)));return h.add(v),()=>{v(),h.delete(v)}},Object.defineProperty(l,"value",{get:l,set:l.set}),i(()=>{y=!1,h.forEach((a)=>a()),h.clear()}),l}function De(){let r=re(Kt());try{let u=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(r);return u=u.replace(/\}(var |let |const |function )/g,"};$1"),u}catch{return r}}function re(r){let d=[],u=0,s="console.log(";while(u<r.length){let i=r.indexOf(s,u);if(i===-1){d.push(r.slice(u));break}d.push(r.slice(u,i));let y=1,h=i+s.length;while(h<r.length&&y>0){let f=r[h];if(f==='"'||f==="'"||f==="`"){let l=f;h++;while(h<r.length&&r[h]!==l){if(r[h]==="\\")h++;h++}h++;continue}if(f==="(")y++;else if(f===")")y--;h++}d.push("0"),u=h}return d.join("")}function Kt(){return`
3
3
  // STX Signals Runtime (Development Build)
4
4
  console.log('[stx] signals runtime loading');
5
5
  // Pre-initialization shim: capture onMount/onDestroy calls made before the runtime IIFE runs
@@ -1385,7 +1385,7 @@ finally {
1385
1385
  // Declarative Data Fetching (Feature #6 - useFetch)
1386
1386
  // ==========================================================================
1387
1387
 
1388
- var readHydratedData = ${z.toString()};
1388
+ var readHydratedData = ${W.toString()};
1389
1389
  var clearServerData = ${X.toString()};
1390
1390
 
1391
1391
  function useFetch(urlOrFn, options = {}) {
@@ -2928,6 +2928,13 @@ catch (e) {
2928
2928
  } catch(e) {}
2929
2929
  }
2930
2930
  }
2931
+ // Normalize a signal returned by an interpolation expression before the
2932
+ // DOM coerces it to text. The proxy handles ordinary signal references,
2933
+ // but a helper or pipe can return the signal function itself.
2934
+ const maybeUnwrapSignal = (v) => {
2935
+ if (v && typeof v === 'function' && (v._isSignal || v._isDerived)) return v();
2936
+ return v;
2937
+ };
2931
2938
  if (el.nodeType === Node.TEXT_NODE) {
2932
2939
  // DOM textContent is specified as a string, but lightweight DOM
2933
2940
  // implementations and user-created nodes can retain a numeric value
@@ -2967,13 +2974,15 @@ catch (e) {
2967
2974
  const pipeResult = parsePipeExpression(expr, capturedScope);
2968
2975
  if (pipeResult) {
2969
2976
  const unwrapScope = createExpressionAutoUnwrapProxy(capturedScope, expr);
2970
- bindingNode.textContent = executePipeExpression(pipeResult.valueExpr, pipeResult.pipes, unwrapScope);
2977
+ bindingNode.textContent = maybeUnwrapSignal(
2978
+ executePipeExpression(pipeResult.valueExpr, pipeResult.pipes, unwrapScope),
2979
+ );
2971
2980
  }
2972
2981
  else {
2973
2982
  // Use auto-unwrap proxy (Feature #1)
2974
2983
  const unwrapScope = createExpressionAutoUnwrapProxy(capturedScope, expr);
2975
2984
  const fn = __stxCompileScoped(capturedScope, [], 'return ' + expr);
2976
- bindingNode.textContent = fn(...__stxArgs(fn, unwrapScope));
2985
+ bindingNode.textContent = maybeUnwrapSignal(fn(...__stxArgs(fn, unwrapScope)));
2977
2986
  }
2978
2987
  }
2979
2988
  catch (e) {
@@ -2982,7 +2991,7 @@ catch (e) {
2982
2991
  // Retry without auto-unwrap so signal functions remain callable.
2983
2992
  try {
2984
2993
  const fn = __stxCompileScoped(capturedScope, [], 'return ' + expr);
2985
- bindingNode.textContent = fn(...__stxArgs(fn, capturedScope));
2994
+ bindingNode.textContent = maybeUnwrapSignal(fn(...__stxArgs(fn, capturedScope)));
2986
2995
  }
2987
2996
  catch (e2) {
2988
2997
  if (!(e2 instanceof ReferenceError) && !(e2 instanceof TypeError)) console.warn('[STX] Expression error:', expr, e2);
@@ -3091,10 +3100,6 @@ else if (part) {
3091
3100
  // appearing in the Proxy Object.keys), call it to get the value.
3092
3101
  // Without this, :text="step" sets textContent to the stringified
3093
3102
  // signal function instead of the value.
3094
- const maybeUnwrapSignal = (v) => {
3095
- if (v && typeof v === 'function' && (v._isSignal || v._isDerived)) return v();
3096
- return v;
3097
- };
3098
3103
  const evalAttrExpr = (rawExpr, evaluationScope) => {
3099
3104
  const activeScope = evaluationScope || attrCapturedScope;
3100
3105
  // Decode HTML entities that browsers may encode in attribute values
@@ -5591,7 +5596,14 @@ else if (!value && isInserted) {
5591
5596
  // the branch is bound in the first frame all the same. A branch
5592
5597
  // shown while detached (inside content not on the page yet) waits a
5593
5598
  // macrotask, when it has been placed.
5594
- if (el.isConnected) queueMicrotask(function() { peek(hydrateShownBranch); });
5599
+ if (el.isConnected) {
5600
+ // A native host sends the insertion as soon as its current
5601
+ // mutation turn ends. Hydrating in a later microtask would put the
5602
+ // handler registration in a second batch, leaving a same-turn tap
5603
+ // with the source expression instead of a native handler id.
5604
+ if (stxHost.isNative) peek(hydrateShownBranch);
5605
+ else queueMicrotask(function() { peek(hydrateShownBranch); });
5606
+ }
5595
5607
  else setTimeout(hydrateShownBranch, 0);
5596
5608
  }
5597
5609
  }
@@ -5679,6 +5691,9 @@ else if (!value && isInserted) {
5679
5691
  return debounced;
5680
5692
  }
5681
5693
 
5694
+ // VueUse-compatible alias; both names use the same callback contract.
5695
+ var useDebounceFn = useDebounce;
5696
+
5682
5697
  function useDebouncedValue(getter, delay) {
5683
5698
  delay = delay || 250;
5684
5699
  var current = getter();
@@ -5706,6 +5721,9 @@ else if (!value && isInserted) {
5706
5721
  };
5707
5722
  }
5708
5723
 
5724
+ // VueUse-compatible alias; keep the existing value-ref shape.
5725
+ var refDebounced = useDebouncedValue;
5726
+
5709
5727
  function useThrottle(fn, limit) {
5710
5728
  limit = limit || 250;
5711
5729
  var timer = null;
@@ -5734,6 +5752,8 @@ else if (timer === null) {
5734
5752
  return throttled;
5735
5753
  }
5736
5754
 
5755
+ var useThrottleFn = useThrottle;
5756
+
5737
5757
  function useInterval(interval, options, thirdOptions) {
5738
5758
  // Accept the callback-first form too \u2014 useInterval(fn, 1000) is what most
5739
5759
  // callers reach for, and silently ignoring the callback (the previous
@@ -5842,6 +5862,8 @@ else if (timer === null) {
5842
5862
  };
5843
5863
  }
5844
5864
 
5865
+ var useTimeoutFn = useTimeout;
5866
+
5845
5867
  function useToggle(initial) {
5846
5868
  var current = !!initial;
5847
5869
  var listeners = [];
@@ -7737,10 +7759,14 @@ catch (e) {} }
7737
7759
  watch,
7738
7760
  watchEffect,
7739
7761
  useDebounce,
7762
+ useDebounceFn,
7740
7763
  useDebouncedValue,
7764
+ refDebounced,
7741
7765
  useThrottle,
7766
+ useThrottleFn,
7742
7767
  useInterval,
7743
7768
  useTimeout,
7769
+ useTimeoutFn,
7744
7770
  useToggle,
7745
7771
  useCounter,
7746
7772
  useClickOutside,
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{t,i,D}from"./chunk-798epzq5.js";import{Ss}from"./chunk-c57j92td.js";import E from"path";var S;async function W(){if(S!==void 0)return S;try{let e=await import("@stacksjs/ts-i18n");S=e.loadLocale??null}catch{S=null}return S}var T={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},v={},L={},k={};function J(e,a=0){if(a<=0)return!1;return Date.now()-e.loadedAt>a}async function G(e,a){if({...T,...a.i18n}.cache&&v[e]){let r=v[e],l=a.i18n?.cacheMaxAge??0;if(!J(r,l))return r.translations}if(L[e]?.state==="loading")return L[e].promise;k[e]="loading";let n=C(e,a).then((r)=>(k[e]="loaded",delete L[e],r)).catch((r)=>{throw k[e]="error",L[e]={promise:n,state:"error",error:r instanceof Error?r:Error(String(r))},r});return L[e]={promise:n,state:"loading"},n}async function C(e,a){let s={...T,...a.i18n},n=E.isAbsolute(s.translationsDir)?s.translationsDir:E.resolve(a.root||process.cwd(),s.translationsDir);try{let r=await W(),l=r?await r(e,{translationsDir:n,defaultLocale:s.defaultLocale,sources:ee(s.format)}):await Y(e,s,n);if(l===void 0){let u=e!==s.defaultLocale?await C(s.defaultLocale,a):{};if(s.cache)v[e]={translations:u,loadedAt:Date.now(),locale:e};return u}let c=l;if(s.cache)v[e]={translations:c,loadedAt:Date.now(),locale:e};return c}catch(r){if(a.debug)console.error(`Error loading translation file for locale "${e}":`,r);if(e!==s.defaultLocale)return C(s.defaultLocale,a);return{}}}async function Y(e,a,s){let n=E.join(s,`${e}${Z(a.format)}`);try{let r=await import(n);return r.default||r}catch(r){try{let l=await Bun.file(n).text();if(a.format==="yaml"||a.format==="yml")return Q(l);if(a.format==="json")return JSON.parse(l);throw r}catch{return}}}function Z(e){switch(e){case"yaml":return".yaml";case"yml":return".yml";case"js":return".js";case"ts":return".ts";case"json":default:return".json"}}function Q(e){let a={},s=e.split(`
2
+ import{t,i,D}from"./chunk-g495xx4v.js";import{Ss}from"./chunk-c57j92td.js";import E from"path";var S;async function W(){if(S!==void 0)return S;try{let e=await import("@stacksjs/ts-i18n");S=e.loadLocale??null}catch{S=null}return S}var T={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},v={},L={},k={};function J(e,a=0){if(a<=0)return!1;return Date.now()-e.loadedAt>a}async function G(e,a){if({...T,...a.i18n}.cache&&v[e]){let r=v[e],l=a.i18n?.cacheMaxAge??0;if(!J(r,l))return r.translations}if(L[e]?.state==="loading")return L[e].promise;k[e]="loading";let n=C(e,a).then((r)=>(k[e]="loaded",delete L[e],r)).catch((r)=>{throw k[e]="error",L[e]={promise:n,state:"error",error:r instanceof Error?r:Error(String(r))},r});return L[e]={promise:n,state:"loading"},n}async function C(e,a){let s={...T,...a.i18n},n=E.isAbsolute(s.translationsDir)?s.translationsDir:E.resolve(a.root||process.cwd(),s.translationsDir);try{let r=await W(),l=r?await r(e,{translationsDir:n,defaultLocale:s.defaultLocale,sources:ee(s.format)}):await Y(e,s,n);if(l===void 0){let u=e!==s.defaultLocale?await C(s.defaultLocale,a):{};if(s.cache)v[e]={translations:u,loadedAt:Date.now(),locale:e};return u}let c=l;if(s.cache)v[e]={translations:c,loadedAt:Date.now(),locale:e};return c}catch(r){if(a.debug)console.error(`Error loading translation file for locale "${e}":`,r);if(e!==s.defaultLocale)return C(s.defaultLocale,a);return{}}}async function Y(e,a,s){let n=E.join(s,`${e}${Z(a.format)}`);try{let r=await import(n);return r.default||r}catch(r){try{let l=await Bun.file(n).text();if(a.format==="yaml"||a.format==="yml")return Q(l);if(a.format==="json")return JSON.parse(l);throw r}catch{return}}}function Z(e){switch(e){case"yaml":return".yaml";case"yml":return".yml";case"js":return".js";case"ts":return".ts";case"json":default:return".json"}}function Q(e){let a={},s=e.split(`
3
3
  `),n=[{obj:a,indent:-1}];for(let r of s){let l=r.replace(/#.*$/,"").trimEnd();if(!l.trim())continue;let c=l.search(/\S/);if(c===-1)continue;while(n.length>1&&n[n.length-1].indent>=c)n.pop();let u=n[n.length-1].obj,o=l.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(o){let[,,g,f]=o,p=g.trim(),m=f.trim();if(m==="")u[p]={},n.push({obj:u[p],indent:c});else u[p]=X(m)}}return a}function X(e){if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1);let a=e.toLowerCase();if(a==="true"||a==="yes")return!0;if(a==="false"||a==="no")return!1;if(a==="null"||a==="~")return null;let s=Number(e);if(!Number.isNaN(s)&&e!=="")return s;return e}function ee(e){switch(e){case"yaml":case"yml":return["yaml"];case"js":case"ts":return["ts"];case"json":default:return["json"]}}async function te(e,a){return G(e,a)}function re(e,a){for(let s of e){let n=s.trim(),r=n.match(/^\{(\d+)\}\s*(.*)$/);if(r){let c=Number.parseInt(r[1],10);if(a===c)return r[2];continue}let l=n.match(/^\[(\d+),(\d+|\*)\]\s*(.*)$/);if(l){let c=Number.parseInt(l[1],10),u=l[2]==="*"?Number.POSITIVE_INFINITY:Number.parseInt(l[2],10);if(a>=c&&a<=u)return l[3];continue}}if(e.length===2)return a===1?e[0].trim():e[1].trim();if(a<e.length)return e[a].trim();return e[e.length-1].trim()}function ne(e,a={}){return j(e,a)}function j(e,a){let s="",n=0;while(n<e.length)if(e[n]==="{"){let r=ie(e,n);if(r===-1){s+=e[n],n++;continue}let l=e.slice(n+1,r);s+=se(l,a),n=r+1}else if(e[n]==="'"&&n+1<e.length)if(e[n+1]==="'")s+="'",n+=2;else if(e[n+1]==="{"||e[n+1]==="}")s+=e[n+1],n+=2;else s+=e[n],n++;else s+=e[n],n++;return s}function ie(e,a){let s=0;for(let n=a;n<e.length;n++)if(e[n]==="{")s++;else if(e[n]==="}"){if(s--,s===0)return n}return-1}function se(e,a){let s=ae(e);if(s.length===0)return`{${e}}`;let n=s[0].trim(),r=a[n];if(s.length===1)return r!==void 0?String(r):`{${n}}`;switch(s[1].trim().toLowerCase()){case"plural":return oe(r,s.slice(2).join(","),a);case"select":return ce(r,s.slice(2).join(","));case"selectordinal":return ue(r,s.slice(2).join(","));case"number":return ge(r,s[2]?.trim());case"date":return pe(r,s[2]?.trim());case"time":return fe(r,s[2]?.trim());default:return r!==void 0?String(r):`{${e}}`}}function ae(e){let a=[],s="",n=0;for(let r=0;r<e.length;r++){let l=e[r];if(l==="{")n++,s+=l;else if(l==="}")n--,s+=l;else if(l===","&&n===0)a.push(s),s="";else s+=l}if(s)a.push(s);return a}function oe(e,a,s){let n=Number(e)||0,r=P(a),l=`=${n}`;if(r[l])return R(r[l],n,s);let c=le(n);if(r[c])return R(r[c],n,s);if(r.other)return R(r.other,n,s);return String(n)}function R(e,a,s){let n=e.replace(/#/g,String(a));return j(n,s)}function le(e){let a=Math.abs(e),s=Math.floor(a),n=String(e).includes(".")?String(e).split(".")[1].length:0;if(s===1&&n===0)return"one";return"other"}function ce(e,a){let s=String(e||""),n=P(a);if(n[s])return n[s];return n.other||String(e)}function ue(e,a){let s=Number(e)||0,n=P(a),r=de(s);if(n[r])return n[r].replace(/#/g,String(s));if(n.other)return n.other.replace(/#/g,String(s));return String(s)}function de(e){let a=Math.abs(e),s=a%10,n=a%100;if(s===1&&n!==11)return"one";if(s===2&&n!==12)return"two";if(s===3&&n!==13)return"few";return"other"}function P(e){let a={},s=/(\w+|=\d+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,n=s.exec(e);while(n!==null)a[n[1]]=n[2],n=s.exec(e);return a}function ge(e,a){let s=Number(e);if(Number.isNaN(s))return String(e);switch(a){case"integer":return Math.floor(s).toLocaleString();case"percent":return`${(s*100).toFixed(0)}%`;case"currency":return s.toLocaleString(void 0,{style:"currency",currency:"USD"});default:return s.toLocaleString()}}function pe(e,a){let s=e instanceof Date?e:new Date(String(e));if(Number.isNaN(s.getTime()))return String(e);let n={};switch(a){case"short":n.dateStyle="short";break;case"medium":n.dateStyle="medium";break;case"long":n.dateStyle="long";break;case"full":n.dateStyle="full";break;default:n.dateStyle="medium"}return s.toLocaleDateString(void 0,n)}function fe(e,a){let s=e instanceof Date?e:new Date(String(e));if(Number.isNaN(s.getTime()))return String(e);let n={};switch(a){case"short":n.timeStyle="short";break;case"medium":n.timeStyle="medium";break;case"long":n.timeStyle="long";break;case"full":n.timeStyle="full";break;default:n.timeStyle="short"}return s.toLocaleTimeString(void 0,n)}function me(e){return/\{[^}]+,\s*(?:plural|select|selectordinal|number|date|time)\s*,/.test(e)}function N(e,a,s=!0,n={}){let r=e.split("."),l=a;for(let u of r){if(l===void 0||l===null)break;l=l[u]}if(l===void 0||l===null)return s?e:"";let c=String(l);if(me(c))return ne(c,n);if(c.includes("|")&&"count"in n){let u=Number(n.count),o=c.split("|");c=re(o,u)}for(let[u,o]of Object.entries(n)){let g=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");c=c.replace(new RegExp(`:${g}`,"g"),String(o))}return c}var O=new Set(["ar","arc","ckb","dv","fa","he","khw","ks","nqo","prs","ps","sd","syr","ug","ur","uz-af","yi"]),be=new Set(["adlm","arab","aran","hebr","nkoo","rohg","syrc","thaa","yezi"]);function _(e){if(!e)return"ltr";let a=e.trim().toLowerCase().replace(/_/g,"-").split("-"),s=a[0];if(!s)return"ltr";let n=a[1]?.length===4?a[1]:void 0;if(n)return be.has(n)?"rtl":"ltr";if(a.length>1&&O.has(`${s}-${a[1]}`))return"rtl";return O.has(s)?"rtl":"ltr"}async function mi(e,a,s,n){let r=e,l=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)([\s\S]*?)@endtranslate/g,c={...T,...n.i18n},u=await te(c.locale,n);a.__translations=u,a.__locale=c.locale,a.__i18nConfig=c,r=await F(r,l,async(f,p,m,w,h)=>{try{let b={};if(m)try{let d=[()=>JSON.parse(m),()=>{let x=`{"data":${m}}`,A=JSON.parse(x);return typeof A.data==="object"?A.data:{}},()=>D(m,a)];for(let x of d)try{if(b=x(),Object.keys(b).length>0)break}catch{}}catch(d){if(n.debug)console.error("Error parsing parameters for @translate directive:",d)}return N(p,u,c.fallbackToKey,b)||w.trim()}catch(b){if(n.debug)console.error("Error processing @translate directive:",b);return i("Translate",`Error in @translate('${p}'): ${b instanceof Error?b.message:String(b)}`,t.EVALUATION_ERROR)}});let o=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]+\})\s*)?\)/g;if(n.debug){console.warn(`Processing translations in template. Sections: ${r.includes("<h2>Translation with Parameters</h2>")?"Parameters section found":"Parameters section missing"}`);let f=[...r.matchAll(o)];console.warn(`Found ${f.length} @translate matches`),f.forEach((p,m)=>console.warn(`Match ${m}: ${p[0]}, Key: ${p[1]}, Params: ${p[2]||"none"}`))}return r=await F(r,/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)/g,async(f,p,m,w)=>{try{let h={};if(m)try{let b=[()=>JSON.parse(m),()=>{let y=`{"data":${m}}`,d=JSON.parse(y);return typeof d.data==="object"?d.data:{}},()=>D(m,a)];for(let y of b)try{if(h=y(),Object.keys(h).length>0)break}catch{}}catch(b){if(n.debug)console.error("Error parsing parameters for @translate directive:",b)}return N(p,u,c.fallbackToKey,h)}catch(h){if(n.debug)console.error("Error processing @translate directive:",h);return i("Translate",`Error in @translate('${p}'): ${h instanceof Error?h.message:String(h)}`,t.EVALUATION_ERROR)}}),r}async function F(e,a,s){let n=[];return e.replace(a,(l,...c)=>{let u=s(l,...c).then((o)=>({match:l,replacement:o}));return n.push(u),l}),(await Promise.all(n)).reduce((l,{match:c,replacement:u})=>l.replace(c,u),e)}function q(e,a){if(!e||_(e)!=="rtl")return!1;return!a||a.trim().toLowerCase()!=="rtl"}function V(e){if(!e)return!1;return e.trim().split(/\s+/)[0]?.toLowerCase()==="presentation"||e.trim().split(/\s+/)[0]?.toLowerCase()==="none"}function I(e,a){let s=new RegExp(`\\b${a}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i").exec(e);if(!s)return null;return s[2]??s[3]??s[4]??null}function hi(e,a,s,n){let r=e;r=r.replace(/@a11y\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(c,u,o)=>{let f={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[u]||"Make this element accessible";return`<!-- a11y-hint: ${o||f} -->`});let l=/@screenReader\(([^@]*)\)@endScreenReader/g;return r=r.replace(l,(c,u)=>`<span class="sr-only">${u.trim()}</span>`),r=r.replace(/@ariaDescribe\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(c,u,o)=>`<span id="${`desc-${u}`}" class="sr-only">${o}</span>`),r}function he(){return typeof globalThis.document<"u"&&typeof globalThis.document.createElement==="function"}function ye(e){let a=new Map,s=e.replace(/<(\/?)([A-Z][\w:.-]*)(?=[\s/>])/g,(r,l,c)=>{let u=a.get(c);if(!u)u=`stx-a11y-component-${a.size}`,a.set(c,u);return`<${l}${u}`}),n=new Map([...a.entries()].map(([r,l])=>[l,r]));return{protectedSource:s,restore:(r)=>r.replace(/<(\/?)(stx-a11y-component-\d+)(?=[\s/>])/g,(l,c,u)=>{let o=n.get(u);return o?`<${c}${o}`:l})}}function xe(e,a){let s=[],n=/<img\s+([^>]*)>/gi,r;r=n.exec(e);while(r!==null){let d=r[1];if(!/\balt\s*=/i.test(d))s.push({type:"missing-alt",element:r[0].substring(0,100),message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"});r=n.exec(e)}let l=/<button([^>]*)>\s*<\/button>/gi;r=l.exec(e);while(r!==null){let d=r[1];if(!/\baria-label\s*=/i.test(d)&&!/\btitle\s*=/i.test(d))s.push({type:"missing-accessible-name",element:r[0].substring(0,100),message:"Empty button missing accessible name",impact:"critical",help:"Add text content, aria-label, or title",helpUrl:"https://web.dev/learn/accessibility/aria-html/"});r=l.exec(e)}let c=/<a\s+([^>]*)>\s*<\/a>/gi;r=c.exec(e);while(r!==null){let d=r[1];if(!/\baria-label\s*=/i.test(d)&&!/\btitle\s*=/i.test(d))s.push({type:"link-missing-text",element:r[0].substring(0,100),message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"});r=c.exec(e)}let u=/<(input|select|textarea)\s+([^>]*)>/gi;r=u.exec(e);while(r!==null){let d=r[2];if(/\btype\s*=\s*["']hidden["']/i.test(d)){r=u.exec(e);continue}let x=/\baria-label\s*=/i.test(d)||/\baria-labelledby\s*=/i.test(d),A=d.match(/\bid\s*=\s*["']([^"']+)["']/i);if(!x){let B=A&&new RegExp(`<label[^>]*\\bfor\\s*=\\s*["']${A[1]}["']`,"i").test(e),U=r.index,M=e.substring(0,U),Ae=e.substring(U),H=(M.match(/<label\b/gi)||[]).length,z=(M.match(/<\/label>/gi)||[]).length,K=H>z;if(!B&&!K)s.push({type:"input-missing-label",element:r[0].substring(0,100),message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})}r=u.exec(e)}let o=/<h([1-6])[^>]*>/gi,g=[];r=o.exec(e);while(r!==null)g.push(Number.parseInt(r[1],10)),r=o.exec(e);let f=0;for(let d of g){if(f>0&&d>f+1)s.push({type:"heading-skip",element:`<h${d}>`,message:`Heading level skipped from h${f} to h${d}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});f=d}if(/<html\b/i.test(e)&&!/<html[^>]*\slang\s*=/i.test(e))s.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});let p=e.match(/<html\b([^>]*)>/i);if(p&&q(I(p[1],"lang"),I(p[1],"dir")))s.push({type:"missing-dir",element:p[0].substring(0,100),message:'Document language is right-to-left but dir="rtl" is not set',impact:"serious",help:'Add dir="rtl" to the html element so the layout mirrors the text',helpUrl:"https://www.w3.org/International/questions/qa-html-dir"});let m=/<table([^>]*)>([\s\S]*?)<\/table>/gi;r=m.exec(e);while(r!==null){let d=r[2];if(!V(I(r[1],"role"))&&!/<th\b/i.test(d))s.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});r=m.exec(e)}let w=/<(video|audio)[^>]*\sautoplay\s[^>]*>/gi;r=w.exec(e);while(r!==null){if(!/\bmuted\b/i.test(r[0]))s.push({type:"autoplay-audio",element:`<${r[1]}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"});r=w.exec(e)}let h=/\btabindex\s*=\s*["']([1-9]\d*)["']/gi;r=h.exec(e);while(r!==null)s.push({type:"positive-tabindex",element:`tabindex="${r[1]}"`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"}),r=h.exec(e);let b=/<iframe\s+([^>]*)>/gi;r=b.exec(e);while(r!==null){let d=r[1];if(!/\btitle\s*=/i.test(d)&&!/\baria-label\s*=/i.test(d))s.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"});r=b.exec(e)}let y=/<([a-z]+)\s+([^>]*role\s*=\s*["']button["'][^>]*)>/gi;r=y.exec(e);while(r!==null){let d=r[1].toLowerCase(),x=r[2];if(d!=="button"&&!/\btabindex\s*=/i.test(x))s.push({type:"button-not-focusable",element:r[0].substring(0,100),message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"});r=y.exec(e)}return s}async function we(e,a){let{protectedSource:s}=ye(e);if(!he())return xe(s,a);let n=[];try{let r=globalThis.document.createElement("div");r.innerHTML=s,r.querySelectorAll("img").forEach((o)=>{if(!o.hasAttribute("alt"))n.push({type:"missing-alt",element:`<${o.outerHTML}>`,message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"})}),r.querySelectorAll('button, a, [role="button"]').forEach((o)=>{if(!(o.hasAttribute("aria-label")||o.hasAttribute("aria-labelledby")||o.textContent&&o.textContent.trim().length>0))n.push({type:"missing-accessible-name",element:`<${o.outerHTML}>`,message:"Interactive element missing accessible name",impact:"critical",help:"Add text content, aria-label, or aria-labelledby",helpUrl:"https://web.dev/learn/accessibility/aria-html/"})}),r.querySelectorAll("input, select, textarea").forEach((o)=>{let g=o.getAttribute("id"),f=g&&r.querySelector(`label[for="${g}"]`),p=o.hasAttribute("aria-label")||o.hasAttribute("aria-labelledby"),m=o.closest("label")!==null;if(!f&&!p&&!m)n.push({type:"input-missing-label",element:`<${o.outerHTML}>`,message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})});let l=Array.from(r.querySelectorAll("h1, h2, h3, h4, h5, h6")),c=0;for(let o of l){let g=Number.parseInt(o.tagName.charAt(1));if(c>0&&g>c+1)n.push({type:"heading-skip",element:`<${o.outerHTML}>`,message:`Heading level skipped from h${c} to h${g}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});c=g}let u=r.querySelector("html");if(s.includes("<html")&&u&&!u.hasAttribute("lang"))n.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});if(u&&q(u.getAttribute("lang"),u.getAttribute("dir")))n.push({type:"missing-dir",element:"<html>",message:'Document language is right-to-left but dir="rtl" is not set',impact:"serious",help:'Add dir="rtl" to the html element so the layout mirrors the text',helpUrl:"https://www.w3.org/International/questions/qa-html-dir"});if(r.querySelectorAll("a").forEach((o)=>{let g=o.textContent&&o.textContent.trim().length>0,f=o.hasAttribute("aria-label")||o.hasAttribute("aria-labelledby"),p=o.hasAttribute("title"),m=o.querySelector("img[alt]");if(!g&&!f&&!p&&!m)n.push({type:"link-missing-text",element:`<${o.outerHTML}>`,message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"})}),s.includes("<nav")||s.includes("<header")){if(!r.querySelector('a[href="#main"], a[href="#content"], .skip-link, [class*="skip"]')&&r.querySelectorAll("a").length>5)n.push({type:"missing-skip-link",element:"<nav>",message:"Consider adding a skip navigation link",impact:"minor",help:"Add a skip link to allow keyboard users to bypass navigation",helpUrl:"https://web.dev/learn/accessibility/focus/#skip-links"})}if(r.querySelectorAll("table").forEach((o)=>{if(V(o.getAttribute("role")))return;let g=o.querySelector("caption");if(!o.querySelector("th"))n.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});if(!g&&!o.hasAttribute("aria-label")&&!o.hasAttribute("aria-labelledby"))n.push({type:"table-missing-caption",element:"<table>",message:"Table missing caption or accessible name",impact:"minor",help:"Add a caption element or aria-label to describe the table",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"})}),r.querySelectorAll('[style*="color"]').forEach((o)=>{let g=o.getAttribute("style")||"";if(g.includes("color:")&&!g.includes("background"))n.push({type:"potential-contrast-issue",element:`<${o.tagName.toLowerCase()}>`,message:"Element has inline color style - verify contrast ratio",impact:"minor",help:"Ensure text has sufficient contrast ratio (4.5:1 for normal text)",helpUrl:"https://web.dev/learn/accessibility/color-contrast/"})}),r.querySelectorAll("video[autoplay], audio[autoplay]").forEach((o)=>{if(!o.hasAttribute("muted"))n.push({type:"autoplay-audio",element:`<${o.tagName.toLowerCase()}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"})}),r.querySelectorAll("[tabindex]").forEach((o)=>{if(Number.parseInt(o.getAttribute("tabindex")||"0")>0)n.push({type:"positive-tabindex",element:`<${o.tagName.toLowerCase()}>`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"})}),r.querySelectorAll('[role="button"]').forEach((o)=>{if(!o.hasAttribute("tabindex"))n.push({type:"button-not-focusable",element:`<${o.outerHTML}>`,message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"})}),s.includes("<body")&&!r.querySelector('main, [role="main"]'))n.push({type:"missing-main-landmark",element:"<body>",message:"Document missing main landmark region",impact:"moderate",help:"Add a main element to identify the primary content",helpUrl:"https://web.dev/learn/accessibility/structure/#landmarks"});r.querySelectorAll("iframe").forEach((o)=>{if(!o.hasAttribute("title")&&!o.hasAttribute("aria-label"))n.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"})})}catch(r){console.error(`Error checking accessibility in ${a}:`,r)}return n}async function yi(e,a={}){let s={},{recursive:n=!0,ignorePaths:r=[]}=a,l=Array.isArray(e)?e:[e],c=await Ss(l,{recursive:n,ignorePaths:r}),u=[];for(let o of c)try{let g=await Bun.file(o).text();if(o.endsWith("good-a11y.stx"))continue;let f=await we(g,o);if(u.push(o),f.length>0)s[o]=f}catch(g){console.error(`Error scanning ${o}:`,g)}return{results:s,scannedFiles:u}}var bi={name:"a11y",handler:(e,a,s,n)=>{if(!a.length)return e;let r=a[0].replace(/['"]/g,""),l=a.length>1?a[1].replace(/['"]/g,""):"",u={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[r]||"Make this element accessible";return`<!-- a11y-hint: ${l||u} -->${e}`},hasEndTag:!1},vi={name:"screenReader",handler:(e)=>`<span class="sr-only">${e}</span>`,hasEndTag:!0};
4
4
  export{mi,hi,yi,bi,vi};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{al}from"./chunk-ph1xz7k5.js";import"./chunk-fwvqbx49.js";import"./chunk-5zm23zrb.js";import"./chunk-qt31at4s.js";import"./chunk-96kr2xrt.js";import"./chunk-68tzytfz.js";import"./chunk-c57j92td.js";import"./chunk-kp4mzspk.js";import"./chunk-v74acg2k.js";import"./chunk-zz5b1g50.js";import"./chunk-5tbqdz94.js";import"./chunk-9p3rtfbv.js";import"./chunk-g495xx4v.js";import"./chunk-ba88n1j7.js";import"./chunk-g1r4v0mc.js";import"./chunk-xd4zvm4x.js";import"./chunk-e6y6s7q8.js";export{al as buildForProduction};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{M,ce}from"./chunk-0np4t9ka.js";import{de,C,Xe}from"./chunk-6k4f583z.js";import{Qe,G,ke}from"./chunk-xd4zvm4x.js";import{Ae,ne,_,re,fo,Er,go,Ot}from"./chunk-mfcdbqvd.js";import{Kr}from"./chunk-fd6abk20.js";import{Mt}from"./chunk-2etevws0.js";import F from"zlib";import{promisify as Z}from"util";var ee=Z(F.brotliCompress),te=Z(F.gzip),se=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],oe=["text/event-stream","multipart/x-mixed-replace"],ae=1024;function ie(t){if(!t)return!1;let e=t.toLowerCase();if(oe.some((o)=>e.startsWith(o)))return!1;return se.some((o)=>e.startsWith(o))}function pe(t){let e=new Map;for(let o of t.split(",")){let[r,...a]=o.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of a){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function ue(t){if(!t)return null;let e=pe(t),o=e.get("*"),r=(a)=>e.get(a)??o??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var J=33554432,H=new Map,U=0;function le(t,e){if(e.length>J/8)return;H.set(t,e),U+=e.length;for(let[o,r]of H){if(U<=J)break;H.delete(o),U-=r.length}}async function It(t,e,o={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!ie(e.headers.get("content-type")))return e;let r=ue(t.headers.get("accept-encoding"));if(!r)return e;let a;try{a=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(a,{status:e.status,statusText:e.statusText,headers:Q(e.headers)});if(a.length<(o.threshold??ae))return f();try{let h=o.quality??5,g=`${r}:${h}:${a.length}:${Bun.hash(a)}`,l=H.get(g);if(!l)l=r==="br"?await ee(a,{params:{[F.constants.BROTLI_PARAM_QUALITY]:h,[F.constants.BROTLI_PARAM_SIZE_HINT]:a.length}}):await te(a),le(g,l);if(l.length>=a.length)return f();let m=Q(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function Q(t){let e=new Headers(t),o=e.get("Vary");if(!o)return e.set("Vary","Accept-Encoding"),e;if(!o.split(",").some((a)=>a.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${o}, Accept-Encoding`);return e}import K from"fs";import P from"path";var{serve:me}=globalThis.Bun;class q{now;entries=new M(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,o){let r,a=async()=>{let s=r??await o();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",_(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return a();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${ne(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let S=new Headers(s.headers);return S.set("Cache-Control","private, no-store"),S.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:S})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let b=this.generation,k=async()=>{let s=await o();r=s;let S=(s.headers.get("Vary")??"").toLowerCase().split(",").map((y)=>y.trim()).filter(Boolean);if(s.status!==200||s.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(s.headers.get("Cache-Control")??"")||S.some((y)=>y!=="x-stx-router"&&y!=="accept-encoding"))return null;let B=await s.clone().arrayBuffer();if(B.byteLength>1048576)return null;s.headers.set("Vary",_(s.headers.get("Vary")).Vary);let n={body:B,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===b)this.entries.set(h,n);return n},v=this.pending.get(h);if(!v){if(this.pending.size>=1000)return a();v=k().finally(()=>{if(this.pending.get(h)===v)this.pending.delete(h)}),this.pending.set(h,v)}if(g&&m<e.maxAge+(e.swr??0))return v.catch(()=>{}),l(g);let E=await v;return E?l(E):a()}}var fe={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function Qc(t={}){let e=P.resolve(t.outputDir||".output"),o=t.port??3000,r=fo(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let a=Mt(r.routeRules),f=new q,h=Kr(e,r.apiRoutes??[]),g=Bun.file(P.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?C(l):void 0,b=new Map,k=new Map,v=new Map,E=new Map;for(let n of r.routes)try{let y=P.join(e,n.compiledPath),i=JSON.parse(await Bun.file(y).text());if(m)i.html=Xe(i.html,m);b.set(n.pattern,i),v.set(n.pattern,ke(i.html)),E.set(n.pattern,ce(i.html));let X=P.join(e,n.fragmentPath);if(await Bun.file(X).exists()){let A=await Bun.file(X).text();k.set(n.pattern,m?Xe(A,m):A)}}catch(y){console.warn(`[stx] Failed to load route ${n.pattern}:`,y)}let s=new Map,S=[];for(let n of r.routes)if(n.hasParams){let{regex:y,params:i}=G(n.pattern,{page:!0});S.push({regex:y,route:n,paramNames:i})}else s.set(n.pattern,n);let B=me({port:o,async fetch(n){return It(n,await de(m??C(),async()=>{let i=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[i])return t.apiRoutes[i](n);let X=await h(n);if(X)return X;if((n.method==="GET"||n.method==="HEAD")&&i!=="/"){let p=P.resolve(e,"public"),d;try{d=decodeURIComponent(i)}catch{d=i}if(!d.includes("\x00")){let u=P.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${P.sep}`))try{if(K.existsSync(u)&&K.statSync(u).isFile()){let R=P.extname(u).toLowerCase(),L=fe[R]||"application/octet-stream",N=i.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(i);return new Response(Bun.file(u),{headers:{"Content-Type":L,"Cache-Control":N?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=ne(n),w=null,W={};if(w=s.get(i)||null,!w)for(let{regex:p,route:d,paramNames:u}of S){let c=i.match(p);if(c){w=d,u.forEach((R,L)=>{W[R]=c[L+1]});break}}if(!w){let p=Qe(i)?null:s.get("/404")||null;if(p){let d=b.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let O=a(i),Y=Object.keys(O).length>0;return f.respond(n,O.cache,async()=>{let p=b.get(w.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let c=k.get(w.pattern);if(c){let R=v.get(w.pattern);return new Response(c,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...E.has(w.pattern)?{"X-STX-Runtime":E.get(w.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},..._(),...O.cache?{}:{"Cache-Control":Ae}}})}}let d=Er(n.method),u=b.get(w.pattern);if(!u){let c=s.get("/500")||null;if(c){let R=b.get(c.pattern);if(R)return new Response(R.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(w.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",..._(),"Cache-Control":"public, max-age=60"}});try{let{html:c,boundaries:R,redirect:L,cookies:N,status:I,headers:D}=await Ot(u,{params:W,request:n,method:n.method,__stx_strict_hydration:Y,__stx_runtime_config:m});if(L)return go(L,N,D);if(R&&R.length>0){let{renderStreamingPage:T,streamToResponse:z}=await import("./chunk-37hm4er5.js"),j=new Headers({..._(),...D,"Cache-Control":"private, no-store"});for(let V of N??[])j.append("Set-Cookie",V);if(A&&!d){let V=ke(c);j.set("X-STX-Fragment","true"),j.set("X-STX-Runtime",ce(c)?"true":"false"),j.set("X-STX-Layout",V.layout),j.set("X-STX-Layout-Group",V.group)}return z(T(A&&!d?re(c,r.routerContainer||"main"):c,R,{timeoutMs:30000}),{status:I??u.status??200,headers:j})}let x=new Headers({"Content-Type":"text/html",..._(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let T of N??[])x.append("Set-Cookie",T);for(let[T,z]of Object.entries(D??{}))x.set(T,z);if(x.set("Vary",_(x.get("Vary")).Vary),A&&!d){let T=ke(c);return x.set("X-STX-Fragment","true"),x.set("X-STX-Runtime",ce(c)?"true":"false"),x.set("X-STX-Layout",T.layout),x.set("X-STX-Layout-Group",T.group),new Response(re(c,r.routerContainer||"main"),{status:I??u.status??200,headers:x})}return new Response(c,{status:I??u.status??200,headers:x})}catch(c){if(console.error(`[stx] Hydration error for ${i}:`,c),Y)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${B.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${b.size} pre-loaded)`),{port:B.port,stop:()=>{f.invalidate(),B.stop()},invalidate:(n)=>f.invalidate(n)}}
2
+ import{M,ce}from"./chunk-96kr2xrt.js";import{de,C,Xe}from"./chunk-zz5b1g50.js";import{Qe,G,ke}from"./chunk-xd4zvm4x.js";import{Ae,ne,T,re,fo,Er,go,Ot}from"./chunk-fwvqbx49.js";import{Kr}from"./chunk-qt31at4s.js";import{Mt}from"./chunk-2etevws0.js";import F from"zlib";import{promisify as Z}from"util";var ee=Z(F.brotliCompress),te=Z(F.gzip),se=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],oe=["text/event-stream","multipart/x-mixed-replace"],ae=1024;function ie(t){if(!t)return!1;let e=t.toLowerCase();if(oe.some((o)=>e.startsWith(o)))return!1;return se.some((o)=>e.startsWith(o))}function pe(t){let e=new Map;for(let o of t.split(",")){let[r,...a]=o.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of a){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function ue(t){if(!t)return null;let e=pe(t),o=e.get("*"),r=(a)=>e.get(a)??o??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var J=33554432,H=new Map,U=0;function le(t,e){if(e.length>J/8)return;H.set(t,e),U+=e.length;for(let[o,r]of H){if(U<=J)break;H.delete(o),U-=r.length}}async function It(t,e,o={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!ie(e.headers.get("content-type")))return e;let r=ue(t.headers.get("accept-encoding"));if(!r)return e;let a;try{a=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(a,{status:e.status,statusText:e.statusText,headers:Q(e.headers)});if(a.length<(o.threshold??ae))return f();try{let h=o.quality??5,g=`${r}:${h}:${a.length}:${Bun.hash(a)}`,l=H.get(g);if(!l)l=r==="br"?await ee(a,{params:{[F.constants.BROTLI_PARAM_QUALITY]:h,[F.constants.BROTLI_PARAM_SIZE_HINT]:a.length}}):await te(a),le(g,l);if(l.length>=a.length)return f();let m=Q(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function Q(t){let e=new Headers(t),o=e.get("Vary");if(!o)return e.set("Vary","Accept-Encoding"),e;if(!o.split(",").some((a)=>a.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${o}, Accept-Encoding`);return e}import K from"fs";import A from"path";var{serve:me}=globalThis.Bun;class q{now;entries=new M(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,o){let r,a=async()=>{let s=r??await o();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",T(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return a();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${ne(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let S=new Headers(s.headers);return S.set("Cache-Control","private, no-store"),S.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:S})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let b=this.generation,k=async()=>{let s=await o();r=s;let S=(s.headers.get("Vary")??"").toLowerCase().split(",").map((y)=>y.trim()).filter(Boolean);if(s.status!==200||s.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(s.headers.get("Cache-Control")??"")||S.some((y)=>y!=="x-stx-router"&&y!=="accept-encoding"))return null;let L=await s.clone().arrayBuffer();if(L.byteLength>1048576)return null;s.headers.set("Vary",T(s.headers.get("Vary")).Vary);let n={body:L,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===b)this.entries.set(h,n);return n},v=this.pending.get(h);if(!v){if(this.pending.size>=1000)return a();v=k().finally(()=>{if(this.pending.get(h)===v)this.pending.delete(h)}),this.pending.set(h,v)}if(g&&m<e.maxAge+(e.swr??0))return v.catch(()=>{}),l(g);let B=await v;return B?l(B):a()}}var fe={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function Qc(t={}){let e=A.resolve(t.outputDir||".output"),o=t.port??3000,r=fo(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let a=Mt(r.routeRules),f=new q,h=Kr(e,r.apiRoutes??[]),g=Bun.file(A.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?C(l):void 0,b=new Map,k=new Map,v=new Map,B=new Map;for(let n of r.routes)try{let y=A.join(e,n.compiledPath),i=JSON.parse(await Bun.file(y).text());if(m)i.html=Xe(i.html,m);b.set(n.pattern,i),v.set(n.pattern,ke(i.html)),B.set(n.pattern,ce(i.html));let _=A.join(e,n.fragmentPath);if(await Bun.file(_).exists()){let E=await Bun.file(_).text();k.set(n.pattern,m?Xe(E,m):E)}}catch(y){console.warn(`[stx] Failed to load route ${n.pattern}:`,y)}let s=new Map,S=[];for(let n of r.routes)if(n.hasParams){let{regex:y,params:i}=G(n.pattern,{page:!0});S.push({regex:y,route:n,paramNames:i})}else s.set(n.pattern,n);let L=me({port:o,async fetch(n){return It(n,await de(m??C(),async()=>{let i=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[i])return t.apiRoutes[i](n);let _=await h(n);if(_)return _;if((n.method==="GET"||n.method==="HEAD")&&i!=="/"){let p=A.resolve(e,"public"),d;try{d=decodeURIComponent(i)}catch{d=i}if(!d.includes("\x00")){let u=A.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${A.sep}`))try{if(K.existsSync(u)&&K.statSync(u).isFile()){let R=A.extname(u).toLowerCase(),j=fe[R]||"application/octet-stream",N=i.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(i);return new Response(Bun.file(u),{headers:{"Content-Type":j,"Cache-Control":N?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let E=ne(n),w=null,W={};if(w=s.get(i)||null,!w)for(let{regex:p,route:d,paramNames:u}of S){let c=i.match(p);if(c){w=d,u.forEach((R,j)=>{W[R]=c[j+1]});break}}if(!w){let p=Qe(i)?null:s.get("/404")||null;if(p){let d=b.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let O=a(i),Y=Object.keys(O).length>0;return f.respond(n,O.cache,async()=>{let p=b.get(w.pattern);if(E&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let c=k.get(w.pattern);if(c){let R=v.get(w.pattern);return new Response(c,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...B.has(w.pattern)?{"X-STX-Runtime":B.get(w.pattern)?"true":"false"}:{},...R?{"X-STX-Layout":R.layout,"X-STX-Layout-Group":R.group}:{},...T(),...O.cache?{}:{"Cache-Control":Ae}}})}}let d=Er(n.method),u=b.get(w.pattern);if(!u){let c=s.get("/500")||null;if(c){let R=b.get(c.pattern);if(R)return new Response(R.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(w.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",...T(),"Cache-Control":"public, max-age=60"}});try{let{html:c,boundaries:R,redirect:j,cookies:N,status:I,headers:D}=await Ot(u,{params:W,request:n,method:n.method,__stx_strict_hydration:Y,__stx_runtime_config:m});if(j)return go(j,N,D);if(R&&R.length>0){let{renderStreamingPage:P,streamToResponse:z}=await import("./chunk-nnrtwpvy.js"),X=new Headers({...T(),...D,"Cache-Control":"private, no-store"});for(let V of N??[])X.append("Set-Cookie",V);if(E&&!d){let V=ke(c);X.set("X-STX-Fragment","true"),X.set("X-STX-Runtime",ce(c)?"true":"false"),X.set("X-STX-Layout",V.layout),X.set("X-STX-Layout-Group",V.group)}return z(P(E&&!d?re(c,r.routerContainer||"main"):c,R,{timeoutMs:30000}),{status:I??u.status??200,headers:X})}let x=new Headers({"Content-Type":"text/html",...T(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let P of N??[])x.append("Set-Cookie",P);for(let[P,z]of Object.entries(D??{}))x.set(P,z);if(x.set("Vary",T(x.get("Vary")).Vary),E&&!d){let P=ke(c);return x.set("X-STX-Fragment","true"),x.set("X-STX-Runtime",ce(c)?"true":"false"),x.set("X-STX-Layout",P.layout),x.set("X-STX-Layout-Group",P.group),new Response(re(c,r.routerContainer||"main"),{status:I??u.status??200,headers:x})}return new Response(c,{status:I??u.status??200,headers:x})}catch(c){if(console.error(`[stx] Hydration error for ${i}:`,c),Y)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${L.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${b.size} pre-loaded)`),{port:L.port,stop:()=>{f.invalidate(),L.stop()},invalidate:(n)=>f.invalidate(n)}}
3
3
  export{It,Qc};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{jn,Me,Le,he,Jo,Vn,Z,K,an,u,n,I}from"./chunk-0np4t9ka.js";import{dirname as C,resolve as R}from"path";function h(o){return o.endsWith(".md")||o.endsWith(".markdown")}function _(o){let e=[];g(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let r=[...e];g(/<code\b[^>]*>[\s\S]*?<\/code>/gi,r);function g(s,p){let m;while((m=s.exec(o))!==null){let t=m.index,i=t+m[0].length;if(p?.some((l)=>t>=l.start&&i<=l.end))continue;e.push({start:t,end:i})}}if(e.length===0)return o;e.sort((s,p)=>s.start-p.start);let a="",c=0;for(let s of e){if(s.start<c)continue;a+=o.slice(c,s.start),a+=`@raw${o.slice(s.start,s.end)}@endraw`,c=s.end}return a+=o.slice(c),a}async function b(o,e={}){let{data:r,content:g}=jn(o),c=await(e.renderer??((s)=>Me(s)))(g);return{html:_(c),frontmatter:r??{}}}function k(o){let e=o,r=Z(o);if(r)e=r.content.trim();let g=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,a=[],c=[],s=[],p=(i)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(i),m;while((m=g.exec(o))!==null){let i=m[1],l=m[2],f=m[0],d=i.includes("server");if(p(l))s.push(f);else if(d)c.push(l);else a.push(f)}let t=e;{let i=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,l,f=[];while((l=i.exec(t))!==null){let d=l.index+l[0].length,x=t.indexOf("</script>",d);if(x===-1)continue;f.push({start:l.index,end:x+9}),i.lastIndex=x+9}for(let d=f.length-1;d>=0;d--)t=t.substring(0,f[d].start)+t.substring(f[d].end)}for(let i of a)t=t.replace(i,"");return{templateContent:t,serverScripts:c,clientScripts:a,signalsScripts:s}}function v(o,e){return`<!DOCTYPE html>
2
+ import{jn,Me,Le,he,Jo,Vn,Z,K,an,u,n,R}from"./chunk-96kr2xrt.js";import{dirname as k,resolve as _}from"path";function h(o){return o.endsWith(".md")||o.endsWith(".markdown")}function C(o){let e=[];g(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let r=[...e];g(/<code\b[^>]*>[\s\S]*?<\/code>/gi,r);function g(s,p){let m;while((m=s.exec(o))!==null){let t=m.index,i=t+m[0].length;if(p?.some((l)=>t>=l.start&&i<=l.end))continue;e.push({start:t,end:i})}}if(e.length===0)return o;e.sort((s,p)=>s.start-p.start);let a="",c=0;for(let s of e){if(s.start<c)continue;a+=o.slice(c,s.start),a+=`@raw${o.slice(s.start,s.end)}@endraw`,c=s.end}return a+=o.slice(c),a}async function b(o,e={}){let{data:r,content:g}=jn(o),c=await(e.renderer??((s)=>Me(s)))(g);return{html:C(c),frontmatter:r??{}}}function v(o){let e=o,r=Z(o);if(r)e=r.content.trim();let g=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,a=[],c=[],s=[],p=(i)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(i),m;while((m=g.exec(o))!==null){let i=m[1],l=m[2],f=m[0],d=i.includes("server");if(p(l))s.push(f);else if(d)c.push(l);else a.push(f)}let t=e;{let i=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,l,f=[];while((l=i.exec(t))!==null){let d=l.index+l[0].length,x=t.indexOf("</script>",d);if(x===-1)continue;f.push({start:l.index,end:x+9}),i.lastIndex=x+9}for(let d=f.length-1;d>=0;d--)t=t.substring(0,f[d].start)+t.substring(f[d].end)}for(let i of a)t=t.replace(i,"");return{templateContent:t,serverScripts:c,clientScripts:a,signalsScripts:s}}function M(o,e){return`<!DOCTYPE html>
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta charset="UTF-8">
@@ -9,10 +9,10 @@ import{jn,Me,Le,he,Jo,Vn,Z,K,an,u,n,I}from"./chunk-0np4t9ka.js";import{dirname a
9
9
  <body>
10
10
  ${o}
11
11
  </body>
12
- </html>`}async function Io(o,e={}){let r=R(o),g=Bun.file(r);if(!await g.exists())throw Error(`Template file not found: ${r}`);let a=await g.text(),c=null;if(h(r)){let s=await b(a,{renderer:e.markdownRenderer});a=s.html,c=s.frontmatter}if(c)e={...e,context:{...c,...e.context||{}}};if(e.layout){let s=R(e.layout),p=Bun.file(s);if(!await p.exists())throw Error(`Layout template not found: ${s}`);let{layout:m,injectCSS:t,...i}=e,l={...e.context||{}};an(l);let f=await S(a,r,{...i,context:{...l,__stx_defer_server_data:!0},injectCSS:!1}),d=await p.text(),x={...l,content:f},w={...i,context:x,injectCSS:t};return S(d,s,w)}return S(a,r,e)}async function S(o,e,r={}){let{templateContent:g,serverScripts:a,clientScripts:c}=k(o),s={...I,...r.options},p={__filename:e,__dirname:C(e),__stx:{},__stx_options:s,__stx_sfc_mode:!0,__stx_inject_css:r.injectCSS===!0,__stxServeContext:void 0,...Vn(r.context??{}),definePageMeta:()=>{},...r.context||{}};for(let i of a)await u(i,p,e);let m=new Set,t=g;if(t=await n(t,p,e,s,m),Jo(p,r.context),r.templateOnly){if(t=t.replace(/<script data-stx-scoped>[\s\S]*?<\/script>\s*/gi,""),t=t.replace(/<!-- stx SEO Tags -->[\s\S]*?(?=<)/i,""),c.length>0)t+=`
12
+ </html>`}async function Io(o,e={}){let r=_(o),g=Bun.file(r);if(!await g.exists())throw Error(`Template file not found: ${r}`);let a=await g.text(),c=null;if(h(r)){let s=await b(a,{renderer:e.markdownRenderer});a=s.html,c=s.frontmatter}if(c)e={...e,context:{...c,...e.context||{}}};if(e.layout){let s=_(e.layout),p=Bun.file(s);if(!await p.exists())throw Error(`Layout template not found: ${s}`);let{layout:m,injectCSS:t,...i}=e,l={...e.context||{}};an(l);let f=await S(a,r,{...i,context:{...l,__stx_defer_server_data:!0},injectCSS:!1}),d=await p.text(),x={...l,content:f},w={...i,context:x,injectCSS:t};return S(d,s,w)}return S(a,r,e)}async function S(o,e,r={}){let{templateContent:g,serverScripts:a,clientScripts:c}=v(o),s={...R,...r.options},p={__filename:e,__dirname:k(e),__stx:{},__stx_options:s,__stx_sfc_mode:!0,__stx_inject_css:r.injectCSS===!0,__stxServeContext:void 0,...Vn(r.context??{}),definePageMeta:()=>{},...r.context||{}};for(let i of a)await u(i,p,e);let m=new Set,t=g;if(t=await n(t,p,e,s,m),Jo(p,r.context),r.templateOnly){if(t=t.replace(/<script data-stx-scoped>[\s\S]*?<\/script>\s*/gi,""),t=t.replace(/<!-- stx SEO Tags -->[\s\S]*?(?=<)/i,""),c.length>0)t+=`
13
13
  ${c.join(`
14
14
  `)}`}else{if(r.processClientScripts!==!1&&c.length>0){let i=p.__stx_event_bindings||[],l=Le(p),d=(await Promise.all(c.map(async(w)=>{let y=w.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!y)return w;return await he(y[1],{eventBindings:i,templateContent:t,serverData:l,filePath:e})}))).join(`
15
15
  `);if(t.match(/(<\/body>)/i))t=t.replace(/(<\/body>)/i,`${d}
16
16
  $1`);else t+=`
17
- ${d}`}t=await K(t)}if(r.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=v(t,r.title)}if(r.injectCSS)try{let{injectCss:i}=await import("./chunk-mba6khev.js");t=await i(t)}catch{}return t}
17
+ ${d}`}t=await K(t)}if(r.wrapInDocument){if(!t.trim().toLowerCase().startsWith("<!doctype")&&!t.trim().toLowerCase().startsWith("<html"))t=M(t,r.title)}if(r.injectCSS)try{let{injectCss:i}=await import("./chunk-e4zks32s.js");t=await i(t)}catch{}return t}
18
18
  export{Io};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{nd,rd}from"./chunk-5dh041x0.js";import"./chunk-s87qrma5.js";import"./chunk-qt31at4s.js";import"./chunk-2hc5mbw8.js";import"./chunk-96kr2xrt.js";import"./chunk-68tzytfz.js";import"./chunk-c57j92td.js";import"./chunk-kp4mzspk.js";import"./chunk-v74acg2k.js";import"./chunk-zz5b1g50.js";import"./chunk-5tbqdz94.js";import"./chunk-9p3rtfbv.js";import"./chunk-g495xx4v.js";import"./chunk-ba88n1j7.js";import"./chunk-g1r4v0mc.js";import"./chunk-xd4zvm4x.js";import"./chunk-e6y6s7q8.js";export{rd as clearStoreCache,nd as getStoreScript};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{ts,ns,rs,Wd,Un,qd}from"./chunk-0np4t9ka.js";export{Un as clearImageDeliveryCatalog,Wd as deliveredImage,rs as efficientDeliverySources,ts as getImageDelivery,ns as isTransparentImage,qd as prepareImageDelivery};
2
+ import{ts,ns,rs,Wd,Un,qd}from"./chunk-96kr2xrt.js";export{Un as clearImageDeliveryCatalog,Wd as deliveredImage,rs as efficientDeliverySources,ts as getImageDelivery,ns as isTransparentImage,qd as prepareImageDelivery};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{vr,eo,_n,wr,xr,Dt,dt,to,Tn,Rn,Sr,kr,el,tl,Re}from"./chunk-49p5j9ab.js";export{Re as DeployError,eo as calculateSha1,_n as collectDeployFiles,Rn as createDefaultNetlifyConfig,wr as createFileManifest,vr as createNetlifyClient,el as deploy,Tn as detectProjectConfig,xr as filterRequiredFiles,Dt as formatSize,to as generateNetlifyToml,dt as getTotalSize,kr as hasNetlifyConfig,tl as initNetlify,Sr as writeNetlifyConfig};
2
+ import{vr,eo,Tn,wr,xr,Dt,dt,to,_n,Rn,Sr,kr,el,tl,Re}from"./chunk-1verz406.js";export{Re as DeployError,eo as calculateSha1,Tn as collectDeployFiles,Rn as createDefaultNetlifyConfig,wr as createFileManifest,vr as createNetlifyClient,el as deploy,_n as detectProjectConfig,xr as filterRequiredFiles,Dt as formatSize,to as generateNetlifyToml,dt as getTotalSize,kr as hasNetlifyConfig,tl as initNetlify,Sr as writeNetlifyConfig};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{vt,Wr,qr,Kr,_d,Xr}from"./chunk-qt31at4s.js";import"./chunk-kp4mzspk.js";import"./chunk-zz5b1g50.js";import"./chunk-xd4zvm4x.js";export{qr as buildServerApi,_d as createServerApi,vt as discoverServerApi,Wr as generateApiTypes,Xr as isServerApiSource,Kr as productionApiDispatcher};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{$e,_e,Te}from"./chunk-czmw5xsd.js";import{it,at,Ee,Ws,ct,lt}from"./chunk-c322rrge.js";import o from"fs";import i from"path";var c=[];function m(a){c=[];for(let e of a.storyFiles)if(c.push({text:e.fileName.toLowerCase(),original:e.fileName,type:"story",storyId:e.id}),c.push({text:e.relativePath.toLowerCase(),original:e.relativePath,type:"story",storyId:e.id}),e.story)for(let t of e.story.variants)c.push({text:t.title.toLowerCase(),original:t.title,type:"story",storyId:e.id,variantId:t.id})}function f(){return JSON.stringify(c)}async function F(a={}){let e=Date.now();it();let t=await $e({mode:"build"});if(!t.config.enabled){Ee("Story feature is disabled in config.");return}let n=await ct(t);_e(t,n);let l=lt(t.config,n);Te(t,l),at(n.length);let d=a.outDir??t.config.outDir,s=i.resolve(t.root,d);await o.promises.mkdir(s,{recursive:!0}),console.log(` Building to ${d}...`);let g=v(t);await o.promises.writeFile(i.join(s,"index.html"),g);let y={files:n.map((r)=>({id:r.id,fileName:r.fileName,relativePath:r.relativePath,treePath:r.treePath})),tree:l};await o.promises.writeFile(i.join(s,"stories.json"),JSON.stringify(y,null,2));let u={theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets};await o.promises.writeFile(i.join(s,"config.json"),JSON.stringify(u,null,2));let p=i.join(s,"stories");await o.promises.mkdir(p,{recursive:!0});for(let r of n){let b=await o.promises.readFile(r.path,"utf-8");await o.promises.writeFile(i.join(p,`${r.id}.stx`),b)}m(t);let h=f();await o.promises.writeFile(i.join(s,"search-index.json"),h);let x=Date.now()-e;Ws(n.length,d,x)}function v(a){let{theme:e}=a.config,t=e.title||"STX Story";return`<!DOCTYPE html>
2
+ import{$e,Te,_e}from"./chunk-1149d93e.js";import{it,at,Ee,Ws,ct,lt}from"./chunk-c322rrge.js";import o from"fs";import i from"path";var c=[];function m(a){c=[];for(let e of a.storyFiles)if(c.push({text:e.fileName.toLowerCase(),original:e.fileName,type:"story",storyId:e.id}),c.push({text:e.relativePath.toLowerCase(),original:e.relativePath,type:"story",storyId:e.id}),e.story)for(let t of e.story.variants)c.push({text:t.title.toLowerCase(),original:t.title,type:"story",storyId:e.id,variantId:t.id})}function f(){return JSON.stringify(c)}async function F(a={}){let e=Date.now();it();let t=await $e({mode:"build"});if(!t.config.enabled){Ee("Story feature is disabled in config.");return}let n=await ct(t);Te(t,n);let l=lt(t.config,n);_e(t,l),at(n.length);let d=a.outDir??t.config.outDir,s=i.resolve(t.root,d);await o.promises.mkdir(s,{recursive:!0}),console.log(` Building to ${d}...`);let g=v(t);await o.promises.writeFile(i.join(s,"index.html"),g);let y={files:n.map((r)=>({id:r.id,fileName:r.fileName,relativePath:r.relativePath,treePath:r.treePath})),tree:l};await o.promises.writeFile(i.join(s,"stories.json"),JSON.stringify(y,null,2));let u={theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets};await o.promises.writeFile(i.join(s,"config.json"),JSON.stringify(u,null,2));let p=i.join(s,"stories");await o.promises.mkdir(p,{recursive:!0});for(let r of n){let b=await o.promises.readFile(r.path,"utf-8");await o.promises.writeFile(i.join(p,`${r.id}.stx`),b)}m(t);let h=f();await o.promises.writeFile(i.join(s,"search-index.json"),h);let x=Date.now()-e;Ws(n.length,d,x)}function v(a){let{theme:e}=a.config,t=e.title||"STX Story";return`<!DOCTYPE html>
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta charset="UTF-8">