@stacksjs/stx 0.2.582 → 0.2.583

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 (166) hide show
  1. package/dist/{chunk-ayy9mmrw.js → chunk-02qaqamv.js} +6 -6
  2. package/dist/{chunk-6w2yqtrd.js → chunk-07anexcg.js} +1 -1
  3. package/dist/{chunk-dvgvvy5b.js → chunk-09zwhsf9.js} +1 -1
  4. package/dist/{chunk-cb2pyg5t.js → chunk-0dfgefjv.js} +2 -2
  5. package/dist/chunk-0fx3ppnt.js +2 -0
  6. package/dist/chunk-0sfexf9t.js +2 -0
  7. package/dist/chunk-2927nax9.js +2 -0
  8. package/dist/{chunk-eww6sdzz.js → chunk-2943qhdt.js} +1 -1
  9. package/dist/{chunk-9jh2ake5.js → chunk-2nehykbm.js} +5 -5
  10. package/dist/chunk-2rj0ttas.js +2 -0
  11. package/dist/chunk-3ae39ttg.js +2 -0
  12. package/dist/{chunk-q2a58n2a.js → chunk-440yjsk5.js} +1 -1
  13. package/dist/{chunk-kp0hg06s.js → chunk-4pkpr5cg.js} +2 -2
  14. package/dist/{chunk-g4crr86j.js → chunk-4pmgr32a.js} +3 -3
  15. package/dist/chunk-521pe0hb.js +18 -0
  16. package/dist/chunk-58z26y07.js +2 -0
  17. package/dist/chunk-5r9k9s3m.js +2 -0
  18. package/dist/{chunk-vx75fb0d.js → chunk-6fc8vw2v.js} +2 -2
  19. package/dist/{chunk-43h8q2cm.js → chunk-6m3me7yj.js} +6 -6
  20. package/dist/chunk-76vza4ve.js +2 -0
  21. package/dist/{chunk-c1r7zq0q.js → chunk-8tq83fq7.js} +71 -71
  22. package/dist/chunk-8y8bbsh5.js +2 -0
  23. package/dist/{chunk-620szfcp.js → chunk-96mb3brj.js} +2 -2
  24. package/dist/chunk-9kzycb15.js +2 -0
  25. package/dist/{chunk-djft0m5h.js → chunk-ac6v3s3k.js} +1 -1
  26. package/dist/chunk-agfhb2qd.js +2 -0
  27. package/dist/chunk-ay6dzpt4.js +2 -0
  28. package/dist/{chunk-dtcc09x1.js → chunk-b9njk81d.js} +1 -1
  29. package/dist/chunk-bfbcmfww.js +2 -0
  30. package/dist/chunk-br01jvra.js +2 -0
  31. package/dist/{chunk-v8p5p2kp.js → chunk-c12y2bet.js} +1 -1
  32. package/dist/chunk-c2nwchk0.js +2 -0
  33. package/dist/{chunk-3qrrv6af.js → chunk-cby4mkjf.js} +1 -1
  34. package/dist/{chunk-qazn64pm.js → chunk-ck1yca7g.js} +1 -1
  35. package/dist/chunk-cxqrwvc5.js +2 -0
  36. package/dist/chunk-czea8zr1.js +2 -0
  37. package/dist/chunk-d99kfx3k.js +2 -0
  38. package/dist/{chunk-7hkc96de.js → chunk-dhq80e4r.js} +4 -4
  39. package/dist/{chunk-cdgwkzms.js → chunk-dm1qh2vq.js} +1 -1
  40. package/dist/{chunk-5pgbsc3a.js → chunk-dskrwa8f.js} +1 -1
  41. package/dist/{chunk-zk2xk0wd.js → chunk-dvc15djp.js} +2 -2
  42. package/dist/chunk-e6ycqvdm.js +2 -0
  43. package/dist/{chunk-8v19753h.js → chunk-e809x7m0.js} +1 -1
  44. package/dist/{chunk-ta3wn842.js → chunk-en7xxgtb.js} +2 -2
  45. package/dist/chunk-fvx6pd66.js +2 -0
  46. package/dist/{chunk-xpnpg967.js → chunk-g9zeybqh.js} +2 -2
  47. package/dist/{chunk-zz02hwec.js → chunk-h3z9b6bw.js} +22 -22
  48. package/dist/{chunk-yk3fbzx5.js → chunk-hp9nxva6.js} +3 -3
  49. package/dist/chunk-hrbjapvr.js +2 -0
  50. package/dist/{chunk-pmpb34md.js → chunk-hzqyfdpy.js} +5 -5
  51. package/dist/chunk-jc4mxq56.js +2 -0
  52. package/dist/chunk-jdpyxt8j.js +2 -0
  53. package/dist/{chunk-4rkvwm6v.js → chunk-je1as16r.js} +9 -9
  54. package/dist/chunk-k0zev8wc.js +2 -0
  55. package/dist/{chunk-nrfh7gaa.js → chunk-kfwmqacd.js} +1 -1
  56. package/dist/{chunk-t61vdbje.js → chunk-ktvr45qg.js} +6 -6
  57. package/dist/{chunk-y8q1n7hx.js → chunk-ky1426s1.js} +6 -6
  58. package/dist/{chunk-rr8a7d4q.js → chunk-m417sp42.js} +3 -3
  59. package/dist/{chunk-101ekf6y.js → chunk-mjj24qpb.js} +2 -2
  60. package/dist/{chunk-ev5f79mg.js → chunk-mt9x626h.js} +3 -3
  61. package/dist/{chunk-faghmmrs.js → chunk-n4e02qdz.js} +85 -85
  62. package/dist/{chunk-yy3ser06.js → chunk-nh3svtvj.js} +3 -3
  63. package/dist/{chunk-yfq2v7x5.js → chunk-nhd9m8h5.js} +6 -6
  64. package/dist/chunk-nx8rf4qd.js +2 -0
  65. package/dist/{chunk-t8wpzqs4.js → chunk-pbwk8tzz.js} +1 -1
  66. package/dist/chunk-pe5bk9ns.js +2 -0
  67. package/dist/chunk-qb2j34sp.js +2 -0
  68. package/dist/chunk-qknfceta.js +2 -0
  69. package/dist/{chunk-0vnngvy1.js → chunk-qn8gdw21.js} +4 -4
  70. package/dist/chunk-sf98zgw2.js +2 -0
  71. package/dist/chunk-sgsp4dph.js +2 -0
  72. package/dist/{chunk-jtbzmbzz.js → chunk-sv08pd66.js} +2 -2
  73. package/dist/{chunk-30rf7k4n.js → chunk-tfxmzat6.js} +24 -24
  74. package/dist/chunk-tms7amrb.js +2 -0
  75. package/dist/chunk-v0zgarvv.js +2 -0
  76. package/dist/chunk-vczw73ga.js +2 -0
  77. package/dist/{chunk-be2ba3hj.js → chunk-vkc51n9m.js} +2 -2
  78. package/dist/{chunk-1v1mew46.js → chunk-vke73gts.js} +1 -1
  79. package/dist/{chunk-c0s3k64c.js → chunk-w6wtxj54.js} +2 -2
  80. package/dist/chunk-webrqm20.js +2 -0
  81. package/dist/chunk-wngqr949.js +2 -0
  82. package/dist/{chunk-71sdgv7e.js → chunk-wyn5rfzk.js} +105 -35
  83. package/dist/{chunk-yhpyqsbr.js → chunk-x552npae.js} +2 -2
  84. package/dist/{chunk-3wy8q3aq.js → chunk-xp7fxc6p.js} +5 -5
  85. package/dist/{chunk-t4g2fptt.js → chunk-xytkfa48.js} +4 -4
  86. package/dist/chunk-xyzy84x0.js +2 -0
  87. package/dist/chunk-y1jffvkj.js +2 -0
  88. package/dist/{chunk-74j18qk0.js → chunk-y8h823cb.js} +28 -28
  89. package/dist/chunk-yas134jv.js +2 -0
  90. package/dist/{chunk-tszkg6sj.js → chunk-ycj0342k.js} +1 -1
  91. package/dist/{chunk-mxe21m6q.js → chunk-yd55vynh.js} +1 -1
  92. package/dist/{chunk-hzfhn2vr.js → chunk-ye66wc53.js} +2 -2
  93. package/dist/{chunk-k9th7hc4.js → chunk-ym1sb5bg.js} +2 -2
  94. package/dist/chunk-yn2d8x8m.js +3 -0
  95. package/dist/chunk-ze86h6vp.js +2 -0
  96. package/dist/cli.js +44 -44
  97. package/dist/client/signals-authoring-runtime.js +13 -6
  98. package/dist/client/signals-binding-utils-runtime.js +14 -1
  99. package/dist/client/signals-component-api-runtime.js +3 -1
  100. package/dist/client/signals-event-shorthand-runtime.js +1 -1
  101. package/dist/client/signals-expression-runtime.js +1 -1
  102. package/dist/client/signals-host-runtime.js +20 -0
  103. package/dist/client/signals-manifest-hydration-runtime.js +7 -0
  104. package/dist/client/signals-model-runtime.js +2 -0
  105. package/dist/client/signals-mount-runtime.js +5 -1
  106. package/dist/client/signals-process-element-runtime.js +22 -7
  107. package/dist/component-model.d.ts +1 -1
  108. package/dist/component-model.js +6 -3
  109. package/dist/composition-api.js +3 -2
  110. package/dist/craft-entry.js +2 -2
  111. package/dist/craft.js +2 -2
  112. package/dist/native/compiler/bundle.js +8 -3
  113. package/dist/native/compiler/html-to-ir.d.ts +3 -1
  114. package/dist/native/compiler/html-to-ir.js +28 -1
  115. package/dist/native/runtime/binding-tree.js +12 -0
  116. package/dist/native/runtime/craft-bridge.js +2 -1
  117. package/dist/native/runtime/jsc-globals.d.ts +10 -3
  118. package/dist/native/runtime/jsc-globals.js +23 -4
  119. package/dist/native/runtime/native-host.d.ts +4 -0
  120. package/dist/native/runtime/native-host.js +273 -21
  121. package/dist/native/runtime/shared-screen.js +1 -0
  122. package/dist/native/testing.js +1 -1
  123. package/dist/pwa.js +3 -3
  124. package/dist/ssg.js +7 -7
  125. package/package.json +5 -5
  126. package/dist/chunk-0047meje.js +0 -2
  127. package/dist/chunk-1cat8kdj.js +0 -2
  128. package/dist/chunk-1dwnp35v.js +0 -2
  129. package/dist/chunk-2dnr5qfk.js +0 -2
  130. package/dist/chunk-2v73cjbc.js +0 -2
  131. package/dist/chunk-3akgppsy.js +0 -2
  132. package/dist/chunk-4t67wmcg.js +0 -2
  133. package/dist/chunk-51zn42jy.js +0 -2
  134. package/dist/chunk-5702x95v.js +0 -2
  135. package/dist/chunk-60c2bsh9.js +0 -2
  136. package/dist/chunk-79v4d9qh.js +0 -2
  137. package/dist/chunk-7pp2vx1g.js +0 -2
  138. package/dist/chunk-8zm6tkqb.js +0 -2
  139. package/dist/chunk-a1z36dt5.js +0 -2
  140. package/dist/chunk-atsf1fe0.js +0 -2
  141. package/dist/chunk-b8qd6h1q.js +0 -2
  142. package/dist/chunk-ccxs40xy.js +0 -2
  143. package/dist/chunk-cg8hg6cs.js +0 -3
  144. package/dist/chunk-cp442y7a.js +0 -2
  145. package/dist/chunk-d4en5d3s.js +0 -2
  146. package/dist/chunk-dh80d57p.js +0 -2
  147. package/dist/chunk-dyqte1xq.js +0 -2
  148. package/dist/chunk-e4n4v022.js +0 -2
  149. package/dist/chunk-g2fw68zm.js +0 -2
  150. package/dist/chunk-hcgm37dy.js +0 -2
  151. package/dist/chunk-hd2bn5q7.js +0 -2
  152. package/dist/chunk-j1nqnmcd.js +0 -18
  153. package/dist/chunk-k7jqkt93.js +0 -2
  154. package/dist/chunk-mqy7g74k.js +0 -2
  155. package/dist/chunk-ne03tfje.js +0 -2
  156. package/dist/chunk-p2sns0bn.js +0 -2
  157. package/dist/chunk-s1sycp43.js +0 -2
  158. package/dist/chunk-sp46w7z9.js +0 -2
  159. package/dist/chunk-sy1bk1ry.js +0 -2
  160. package/dist/chunk-tpd5nwa3.js +0 -2
  161. package/dist/chunk-tpt4bgs5.js +0 -2
  162. package/dist/chunk-vq0cb1m9.js +0 -2
  163. package/dist/chunk-y1bppxgw.js +0 -2
  164. package/dist/chunk-yv5rwthv.js +0 -2
  165. package/dist/chunk-z1r4tdqy.js +0 -2
  166. package/dist/chunk-zv288w4e.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Gi,Ki,Xi}from"./chunk-zk2xk0wd.js";import{W,Qt,en,qr,Gr,zn,tn,nn,Kr,Hn}from"./chunk-c0s3k64c.js";function X(e,a,i,o,u){let y=!0,s=new Set,h=(l)=>o.get?o.get(l):l,r=()=>h(e());return Object.defineProperty(r,"_isSignal",{value:!0}),Object.defineProperty(r,"modifiers",{get:a}),r.set=(l)=>{if(!y)return;let m=a(),d=o.set?o.set(l,m):l;if(m.trim&&typeof d==="string")d=d.trim();if(m.number&&typeof d==="string"&&d!==""){let n=Number(d);if(!Number.isNaN(n))d=n}if(Object.is(e(),d))return;e.set(d),i(d)},r.update=(l)=>r.set(l(r())),r.input=(l)=>{if(!a().lazy)r.set(l)},r.change=(l)=>{if(a().lazy)r.set(l)},r.subscribe=(l)=>{if(!y)return()=>{};let m=e.subscribe((d,n)=>l(h(d),h(n)));return s.add(m),()=>{m(),s.delete(m)}},Object.defineProperty(r,"value",{get:r,set:r.set}),u(()=>{y=!1,s.forEach((l)=>l()),s.clear()}),r}function Q(e,a=!0,i){if(!a||!e||typeof window>"u")return;let o=window;if(!o.__STX_DATA__){let y=document.querySelector("script[data-stx-server-data]");try{let s=JSON.parse(y?.textContent||"{}");o.__STX_DATA__=s&&typeof s==="object"&&!Array.isArray(s)?s:{}}catch{o.__STX_DATA__={}}}let u=o.__STX_DATA__;if(u&&Object.prototype.hasOwnProperty.call(u,e))try{return{data:i?i(u[e]):u[e]}}catch(y){return{data:null,error:y instanceof Error?y:Error(String(y))}}return}function Y(e){if(typeof window>"u")return;let a=window;if(e===void 0)a.__STX_DATA__={};else{if(!a.__STX_DATA__)try{let i=JSON.parse(document.querySelector("script[data-stx-server-data]")?.textContent||"{}");a.__STX_DATA__=i&&typeof i==="object"&&!Array.isArray(i)?i:{}}catch{a.__STX_DATA__={}}if(a.__STX_DATA__)delete a.__STX_DATA__[e]}}function J(e){let a=null;try{a=typeof indexedDB<"u"?indexedDB:null}catch{a=null}if(!a)return null;let i=a,o=e||"stx-kept",u=null,y=()=>{if(!u)u=new Promise((h,r)=>{let l=i.open(o,1);l.onupgradeneeded=()=>{l.result.createObjectStore("kv")},l.onsuccess=()=>h(l.result),l.onerror=()=>r(l.error),l.onblocked=()=>r(Error("blocked"))}),u.catch(()=>{u=null});return u},s=(h,r)=>y().then((l)=>new Promise((m,d)=>{let n=l.transaction("kv",h),p=r(n.objectStore("kv"));n.oncomplete=()=>m(p?p.result:void 0),n.onerror=()=>d(n.error),n.onabort=()=>d(n.error)}));return{get:(h)=>s("readonly",(r)=>r.get(h)),set:(h,r)=>s("readwrite",(l)=>{l.put(r,h)}),remove:(h)=>s("readwrite",(r)=>{r.delete(h)}),removePrefix:(h)=>s("readwrite",(r)=>{r.delete(IDBKeyRange.bound(h,`${h}\uFFFF`))})}}function Z(e,a){let i=e||{},o=null;if(i.storage!==void 0)o=i.storage;else try{o=typeof localStorage<"u"?localStorage:null}catch{o=null}let u=null,y=i.backend!==void 0;if(y)u=i.backend||null;let s=()=>{if(y)return u;y=!0;try{u=a?a():null}catch{u=null}if(u){let t=u;t.get("__stx_probe__").catch(()=>{if(u===t)u=null})}return u},h=i.limit||32768,r=i.defer||((t)=>{let c=typeof requestIdleCallback==="function"?requestIdleCallback:null;if(c)c(t,{timeout:200});else setTimeout(t,16)}),l=new Map,m=new Set,d=new Map,n=!1,p=Promise.resolve(),v=(t)=>{try{return JSON.parse(t)}catch{return t}},f=(t,c)=>{if(!o)return!1;try{return o.setItem(t,c),!0}catch{return!1}},E=(t)=>{try{if(o)o.removeItem(t)}catch{}},S=()=>{if(n=!1,!d.size)return p;let t=Array.from(d.entries());return d.clear(),p=p.then(()=>Promise.all(t.map(([c,g])=>{if(!u){m.delete(c);try{f(c,JSON.stringify(g===void 0?null:g))}catch{}return}let _;try{return _={v:g},u.set(c,_).catch(()=>{let x;try{x=JSON.stringify(g)}catch{return}return u?u.set(c,{j:x}).catch(()=>{f(c,x)}):void 0})}catch{return}}))).then(()=>{}),p},N=(t,c)=>{if(d.set(t,c),m.add(t),n)return;n=!0,r(()=>{S()})},D=(t)=>{if(!t||typeof t!=="object")return;let c=t;if("v"in c)return{value:c.v};if(typeof c.j==="string")return{value:v(c.j)};return},k={peek(t){if(l.has(t))return{value:l.get(t)};let c=null;try{c=o?o.getItem(t):null}catch{c=null}if(c===null||c===void 0)return;let g=v(c);return l.set(t,g),{value:g}},load(t){let c=k.peek(t),g=c?null:s();if(c||!g)return Promise.resolve(c);return g.get(t).then((_)=>{if(l.has(t))return{value:l.get(t)};let x=D(_);if(x)l.set(t,x.value),m.add(t);return x},()=>{return})},set(t,c){if(l.set(t,c),u&&m.has(t)){N(t,c);return}let g;try{g=JSON.stringify(c===void 0?null:c)}catch{return}if(g.length<=h&&f(t,g))return;if(!s()){if(g.length>h)f(t,g);return}E(t),N(t,c)},forget(t){for(let g of Array.from(l.keys()))if(g.indexOf(t)===0)l.delete(g);for(let g of Array.from(d.keys()))if(g.indexOf(t)===0)d.delete(g);for(let g of Array.from(m))if(g.indexOf(t)===0)m.delete(g);try{if(o)for(let g=o.length-1;g>=0;g--){let _=o.key(g);if(_&&_.indexOf(t)===0)o.removeItem(_)}}catch{}let c=s();if(!c)return p;return p=p.then(()=>c.removePrefix(t)).catch(()=>{}),p},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 k}function ee(e,a){if(!e)return!1;if(e===a.key)return!0;if(!a.url)return!1;if(e===a.url)return!0;try{let i=typeof location<"u"&&location.origin&&location.origin!=="null"?location.origin:"http://localhost",o=new URL(e,i),u=new URL(a.url,i);if(o.origin!==u.origin||o.pathname!==u.pathname)return!1;return!o.search||o.search===u.search}catch{return!1}}function te(e){let a=e.prefix||"stx:kept:",i=e.matches||((n,p)=>n===p.key||n===p.url),o=new Set,u=new Map,y,s=(n)=>n===void 0?y:n,h=(n,p)=>{let v=s(p);if(v===!1||v===null||v==="")return null;return`${a}${v===void 0?"":`${v}:`}query:${n}`},r=(n)=>{let p=n&&n.value;if(!p||typeof p!=="object"||!("d"in p))return;return{data:p.d,at:Number(p.at)||0}},l=()=>{let n=globalThis;return n.__stx_outboxes instanceof Map?n.__stx_outboxes:null},m={setScope(n){y=n},scope:()=>y,keyFor:h,seed(n,p){let v=h(n,p);return v?r(e.kept.peek(v)):void 0},restore(n,p){let v=h(n,p);return v?e.kept.load(v).then(r):Promise.resolve(void 0)},persist(n,p,v){let f=h(n,v);if(f)e.kept.set(f,{d:p,at:Date.now()})},overlay(n,p,v){let f=l();if(!f||!f.size)return p;let E=p;return f.forEach((S)=>{try{E=S.overlay(n,E,v)}catch{}}),E},watch(n){return o.add(n),()=>{o.delete(n)}},cachedQuery(n,p){let v=u.get(n);if(v){if(p&&v.__options)v.__options(p);return v}let f=p||{},E=f.initial===void 0?null:f.initial,S=()=>typeof f.scope==="function"?f.scope():f.scope,N=()=>(typeof f.url==="function"?f.url():f.url)||null,D=()=>({key:n,url:N()}),k=S(),t=E,c=0,g=e.sharedRequest(),_=0,x=m.seed(n,k);if(x)t=x.data;let I=e.state(m.overlay(D(),t)),U=e.state(!1),q=e.state(!1),K=e.state(null),P=e.state(x?x.at:0),R=0,F=()=>{I.set(m.overlay(D(),t))},z=(b)=>{let w=R;m.restore(n,b).then((T)=>{if(!T||w!==R||c)return;t=T.data,P.set(T.at),F()})};if(!x)z(k);let wt=()=>{let b=S();if(b===k)return;k=b,R++,_=0,q.set(!1),U.set(!1),c=0;let w=m.seed(n,k);if(t=w?w.data:E,P.set(w?w.at:0),F(),!w)z(k)},_t=(b,w)=>{let T=f.timeoutMs||15000,C=typeof AbortController<"u"?new AbortController:null,O=null,j=new Promise((M,V)=>{O=setTimeout(()=>{if(C)C.abort();V(Error("The request took too long."))},T)}),A;if(f.load)A=f.load({force:b,url:w,signal:C?C.signal:void 0});else if(w){let M=f.fetch||((L,H)=>fetch(L,H)),V={method:"GET",headers:{Accept:"application/json"}};if(b)V.cache="no-cache";if(C)V.signal=C.signal;A=M(w,V).then((L)=>{if(!L.ok)return L.json().catch(()=>null).then((H)=>{throw Error(H&&(H.error||H.message)||`Request failed (${L.status})`)});return L.json()})}else return Promise.resolve(I());return Promise.race([A,j]).then((M)=>{if(O)clearTimeout(O);return f.transform?f.transform(M):M},(M)=>{if(O)clearTimeout(O);throw M})},G=(b)=>{let w=R,T=N(),C=()=>{if(w!==R)return Promise.resolve(I());if(_++,q.set(!0),c===0&&!P())U.set(!0);let j=()=>{if(w!==R)return;if(_=Math.max(0,_-1),!_)q.set(!1),U.set(!1)};return _t(b,T).then((A)=>{if(w!==R||T!==N())return j(),I();return t=A,c=Date.now(),P.set(c),K.set(null),m.persist(n,A,k),F(),j(),I()},(A)=>{if(w===R&&T===N())K.set(A&&A.message?A.message:"Could not load.");return j(),I()})},O=`${w} ${T||""}`;return b?g.fresh(O,C):g.run(O,C)},B={data:I,loading:U,isFetching:q,error:K,updatedAt:P,get key(){return n},load(b){if(wt(),!b&&c&&Date.now()-c<(f.staleTime||0))return Promise.resolve(I());return G(!!b)},refresh(){return B.load(!0)},set(b){t=typeof b==="function"?b(t):b,m.persist(n,t,k),F()},invalidate(){c=0},__options(b){f={...f,...b}}};if(o.add({target:D,updated:()=>{if(c||P())G(!1)},outbox:(b)=>{if(b)t=m.overlay(D(),t,b.id),c=0,G(!0);F()}}),u.set(n,B),f.immediate)B.load();return B}},d=typeof window<"u"?window:typeof addEventListener==="function"?globalThis:null;if(e.listen!==!1&&d&&typeof d.addEventListener==="function")d.addEventListener("stx:updated",(n)=>{let p=n.detail||{};if(p.kind!=="api"||typeof p.url!=="string")return;o.forEach((v)=>{if(i(p.url,v.target()))v.updated()})}),d.addEventListener("stx:outbox",(n)=>{let p=n.detail||{},v=p.sent&&typeof p.sent.id==="string"?p.sent:null;o.forEach((f)=>{if(v){let E=Array.isArray(v.affects)?v.affects:[],S=f.target();if(!E.some((N)=>i(N,S)))return}f.outbox(v)})});return m}function ne(e){let a=e&&e.covers||((s,h)=>Object.is(s,h)),i=[],o=[],u=0,y=(s,h)=>{let r;try{r=Promise.resolve(h())}catch(d){r=Promise.reject(d)}let l={key:s,promise:r};i.push(l);let m=()=>{let d=i.indexOf(l);if(d!==-1)i.splice(d,1)};return r.then(m,m),r};return{run(s,h){for(let r of i)if(a(r.key,s))return r.promise;for(let r of o)if(a(r.key,s))return r.promise;return y(s,h)},fresh(s,h){for(let d of o)if(a(d.key,s))return d.promise;let r=i.filter((d)=>a(d.key,s)).map((d)=>d.promise);if(!r.length)return y(s,h);let l={key:s,promise:null},m=()=>{};return l.promise=Promise.all(r.map((d)=>d.then(m,m))).then(()=>{let d=o.indexOf(l);if(d!==-1)o.splice(d,1);return y(s,h)}),o.push(l),l.promise},latest(){let s=++u;return()=>s===u},get busy(){return i.length>0||o.length>0}}}var re=` function useColorMode(options) {
2
+ import{Gi,Ki,Xi}from"./chunk-dvc15djp.js";import{W,Qt,en,Gr,zn,Hn,tn,nn,Kr,Un}from"./chunk-w6wtxj54.js";function X(t,a,i,r,d,y){let o=!0,u=new Set,f=(p)=>r.get?r.get(p):p,l=()=>f(t());return Object.defineProperty(l,"_isSignal",{value:!0}),Object.defineProperty(l,"modifiers",{get:a}),l.set=(p)=>{if(!o)return;let h=a(),e=r.set?r.set(p,h):p;if(h.trim&&typeof e==="string")e=e.trim();if(h.number&&typeof e==="string"&&e!==""){let s=Number(e);if(!Number.isNaN(s))e=s}if(Object.is(t(),e))return;t.set(e),i(e)},l.update=(p)=>l.set(p(l())),l.input=(p)=>{if(!a().lazy)l.set(p)},l.change=(p)=>{if(a().lazy)l.set(p)},l.subscribe=(p)=>{if(!o)return()=>{};let h=t.subscribe((e,s)=>p(f(e),f(s)));return u.add(h),()=>{h(),u.delete(h)}},Object.defineProperty(l,"value",{get:l,set:l.set}),d(()=>{o=!1,u.forEach((p)=>p()),u.clear()}),y?.(()=>{o=!0}),l}function Q(t,a=!0,i){if(!a||!t||typeof window>"u")return;let r=window;if(!r.__STX_DATA__){let y=document.querySelector("script[data-stx-server-data]");try{let o=JSON.parse(y?.textContent||"{}");r.__STX_DATA__=o&&typeof o==="object"&&!Array.isArray(o)?o:{}}catch{r.__STX_DATA__={}}}let d=r.__STX_DATA__;if(d&&Object.prototype.hasOwnProperty.call(d,t))try{return{data:i?i(d[t]):d[t]}}catch(y){return{data:null,error:y instanceof Error?y:Error(String(y))}}return}function Y(t){if(typeof window>"u")return;let a=window;if(t===void 0)a.__STX_DATA__={};else{if(!a.__STX_DATA__)try{let i=JSON.parse(document.querySelector("script[data-stx-server-data]")?.textContent||"{}");a.__STX_DATA__=i&&typeof i==="object"&&!Array.isArray(i)?i:{}}catch{a.__STX_DATA__={}}if(a.__STX_DATA__)delete a.__STX_DATA__[t]}}function J(t){let a=null;try{a=typeof indexedDB<"u"?indexedDB:null}catch{a=null}if(!a)return null;let i=a,r=t||"stx-kept",d=null,y=()=>{if(!d)d=new Promise((u,f)=>{let l=i.open(r,1);l.onupgradeneeded=()=>{l.result.createObjectStore("kv")},l.onsuccess=()=>u(l.result),l.onerror=()=>f(l.error),l.onblocked=()=>f(Error("blocked"))}),d.catch(()=>{d=null});return d},o=(u,f)=>y().then((l)=>new Promise((p,h)=>{let e=l.transaction("kv",u),s=f(e.objectStore("kv"));e.oncomplete=()=>p(s?s.result:void 0),e.onerror=()=>h(e.error),e.onabort=()=>h(e.error)}));return{get:(u)=>o("readonly",(f)=>f.get(u)),set:(u,f)=>o("readwrite",(l)=>{l.put(f,u)}),remove:(u)=>o("readwrite",(f)=>{f.delete(u)}),removePrefix:(u)=>o("readwrite",(f)=>{f.delete(IDBKeyRange.bound(u,`${u}\uFFFF`))})}}function Z(t,a){let i=t||{},r=null;if(i.storage!==void 0)r=i.storage;else try{r=typeof localStorage<"u"?localStorage:null}catch{r=null}let d=null,y=i.backend!==void 0;if(y)d=i.backend||null;let o=()=>{if(y)return d;y=!0;try{d=a?a():null}catch{d=null}if(d){let n=d;n.get("__stx_probe__").catch(()=>{if(d===n)d=null})}return d},u=i.limit||32768,f=i.defer||((n)=>{let c=typeof requestIdleCallback==="function"?requestIdleCallback:null;if(c)c(n,{timeout:200});else setTimeout(n,16)}),l=new Map,p=new Set,h=new Map,e=!1,s=Promise.resolve(),v=(n)=>{try{return JSON.parse(n)}catch{return n}},m=(n,c)=>{if(!r)return!1;try{return r.setItem(n,c),!0}catch{return!1}},E=(n)=>{try{if(r)r.removeItem(n)}catch{}},S=()=>{if(e=!1,!h.size)return s;let n=Array.from(h.entries());return h.clear(),s=s.then(()=>Promise.all(n.map(([c,g])=>{if(!d){p.delete(c);try{m(c,JSON.stringify(g===void 0?null:g))}catch{}return}let _;try{return _={v:g},d.set(c,_).catch(()=>{let x;try{x=JSON.stringify(g)}catch{return}return d?d.set(c,{j:x}).catch(()=>{m(c,x)}):void 0})}catch{return}}))).then(()=>{}),s},N=(n,c)=>{if(h.set(n,c),p.add(n),e)return;e=!0,f(()=>{S()})},D=(n)=>{if(!n||typeof n!=="object")return;let c=n;if("v"in c)return{value:c.v};if(typeof c.j==="string")return{value:v(c.j)};return},k={peek(n){if(l.has(n))return{value:l.get(n)};let c=null;try{c=r?r.getItem(n):null}catch{c=null}if(c===null||c===void 0)return;let g=v(c);return l.set(n,g),{value:g}},load(n){let c=k.peek(n),g=c?null:o();if(c||!g)return Promise.resolve(c);return g.get(n).then((_)=>{if(l.has(n))return{value:l.get(n)};let x=D(_);if(x)l.set(n,x.value),p.add(n);return x},()=>{return})},set(n,c){if(l.set(n,c),d&&p.has(n)){N(n,c);return}let g;try{g=JSON.stringify(c===void 0?null:c)}catch{return}if(g.length<=u&&m(n,g))return;if(!o()){if(g.length>u)m(n,g);return}E(n),N(n,c)},forget(n){for(let g of Array.from(l.keys()))if(g.indexOf(n)===0)l.delete(g);for(let g of Array.from(h.keys()))if(g.indexOf(n)===0)h.delete(g);for(let g of Array.from(p))if(g.indexOf(n)===0)p.delete(g);try{if(r)for(let g=r.length-1;g>=0;g--){let _=r.key(g);if(_&&_.indexOf(n)===0)r.removeItem(_)}}catch{}let c=o();if(!c)return s;return s=s.then(()=>c.removePrefix(n)).catch(()=>{}),s},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 k}function ee(t,a){if(!t)return!1;if(t===a.key)return!0;if(!a.url)return!1;if(t===a.url)return!0;try{let i=typeof location<"u"&&location.origin&&location.origin!=="null"?location.origin:"http://localhost",r=new URL(t,i),d=new URL(a.url,i);if(r.origin!==d.origin||r.pathname!==d.pathname)return!1;return!r.search||r.search===d.search}catch{return!1}}function te(t){let a=t.prefix||"stx:kept:",i=t.matches||((e,s)=>e===s.key||e===s.url),r=new Set,d=new Map,y,o=(e)=>e===void 0?y:e,u=(e,s)=>{let v=o(s);if(v===!1||v===null||v==="")return null;return`${a}${v===void 0?"":`${v}:`}query:${e}`},f=(e)=>{let s=e&&e.value;if(!s||typeof s!=="object"||!("d"in s))return;return{data:s.d,at:Number(s.at)||0}},l=()=>{let e=globalThis;return e.__stx_outboxes instanceof Map?e.__stx_outboxes:null},p={setScope(e){y=e},scope:()=>y,keyFor:u,seed(e,s){let v=u(e,s);return v?f(t.kept.peek(v)):void 0},restore(e,s){let v=u(e,s);return v?t.kept.load(v).then(f):Promise.resolve(void 0)},persist(e,s,v){let m=u(e,v);if(m)t.kept.set(m,{d:s,at:Date.now()})},overlay(e,s,v){let m=l();if(!m||!m.size)return s;let E=s;return m.forEach((S)=>{try{E=S.overlay(e,E,v)}catch{}}),E},watch(e){return r.add(e),()=>{r.delete(e)}},cachedQuery(e,s){let v=d.get(e);if(v){if(s&&v.__options)v.__options(s);return v}let m=s||{},E=m.initial===void 0?null:m.initial,S=()=>typeof m.scope==="function"?m.scope():m.scope,N=()=>(typeof m.url==="function"?m.url():m.url)||null,D=()=>({key:e,url:N()}),k=S(),n=E,c=0,g=t.sharedRequest(),_=0,x=p.seed(e,k);if(x)n=x.data;let I=t.state(p.overlay(D(),n)),U=t.state(!1),q=t.state(!1),K=t.state(null),P=t.state(x?x.at:0),R=0,F=()=>{I.set(p.overlay(D(),n))},z=(b)=>{let w=R;p.restore(e,b).then((T)=>{if(!T||w!==R||c)return;n=T.data,P.set(T.at),F()})};if(!x)z(k);let wt=()=>{let b=S();if(b===k)return;k=b,R++,_=0,q.set(!1),U.set(!1),c=0;let w=p.seed(e,k);if(n=w?w.data:E,P.set(w?w.at:0),F(),!w)z(k)},_t=(b,w)=>{let T=m.timeoutMs||15000,C=typeof AbortController<"u"?new AbortController:null,O=null,j=new Promise((M,V)=>{O=setTimeout(()=>{if(C)C.abort();V(Error("The request took too long."))},T)}),A;if(m.load)A=m.load({force:b,url:w,signal:C?C.signal:void 0});else if(w){let M=m.fetch||((L,H)=>fetch(L,H)),V={method:"GET",headers:{Accept:"application/json"}};if(b)V.cache="no-cache";if(C)V.signal=C.signal;A=M(w,V).then((L)=>{if(!L.ok)return L.json().catch(()=>null).then((H)=>{throw Error(H&&(H.error||H.message)||`Request failed (${L.status})`)});return L.json()})}else return Promise.resolve(I());return Promise.race([A,j]).then((M)=>{if(O)clearTimeout(O);return m.transform?m.transform(M):M},(M)=>{if(O)clearTimeout(O);throw M})},G=(b)=>{let w=R,T=N(),C=()=>{if(w!==R)return Promise.resolve(I());if(_++,q.set(!0),c===0&&!P())U.set(!0);let j=()=>{if(w!==R)return;if(_=Math.max(0,_-1),!_)q.set(!1),U.set(!1)};return _t(b,T).then((A)=>{if(w!==R||T!==N())return j(),I();return n=A,c=Date.now(),P.set(c),K.set(null),p.persist(e,A,k),F(),j(),I()},(A)=>{if(w===R&&T===N())K.set(A&&A.message?A.message:"Could not load.");return j(),I()})},O=`${w} ${T||""}`;return b?g.fresh(O,C):g.run(O,C)},B={data:I,loading:U,isFetching:q,error:K,updatedAt:P,get key(){return e},load(b){if(wt(),!b&&c&&Date.now()-c<(m.staleTime||0))return Promise.resolve(I());return G(!!b)},refresh(){return B.load(!0)},set(b){n=typeof b==="function"?b(n):b,p.persist(e,n,k),F()},invalidate(){c=0},__options(b){m={...m,...b}}};if(r.add({target:D,updated:()=>{if(c||P())G(!1)},outbox:(b)=>{if(b)n=p.overlay(D(),n,b.id),c=0,G(!0);F()}}),d.set(e,B),m.immediate)B.load();return B}},h=typeof window<"u"?window:typeof addEventListener==="function"?globalThis:null;if(t.listen!==!1&&h&&typeof h.addEventListener==="function")h.addEventListener("stx:updated",(e)=>{let s=e.detail||{};if(s.kind!=="api"||typeof s.url!=="string")return;r.forEach((v)=>{if(i(s.url,v.target()))v.updated()})}),h.addEventListener("stx:outbox",(e)=>{let s=e.detail||{},v=s.sent&&typeof s.sent.id==="string"?s.sent:null;r.forEach((m)=>{if(v){let E=Array.isArray(v.affects)?v.affects:[],S=m.target();if(!E.some((N)=>i(N,S)))return}m.outbox(v)})});return p}function ne(t){let a=t&&t.covers||((o,u)=>Object.is(o,u)),i=[],r=[],d=0,y=(o,u)=>{let f;try{f=Promise.resolve(u())}catch(h){f=Promise.reject(h)}let l={key:o,promise:f};i.push(l);let p=()=>{let h=i.indexOf(l);if(h!==-1)i.splice(h,1)};return f.then(p,p),f};return{run(o,u){for(let f of i)if(a(f.key,o))return f.promise;for(let f of r)if(a(f.key,o))return f.promise;return y(o,u)},fresh(o,u){for(let h of r)if(a(h.key,o))return h.promise;let f=i.filter((h)=>a(h.key,o)).map((h)=>h.promise);if(!f.length)return y(o,u);let l={key:o,promise:null},p=()=>{};return l.promise=Promise.all(f.map((h)=>h.then(p,p))).then(()=>{let h=r.indexOf(l);if(h!==-1)r.splice(h,1);return y(o,u)}),r.push(l),l.promise},latest(){let o=++d;return()=>o===d},get busy(){return i.length>0||r.length>0}}}var re=` function useColorMode(options) {
3
3
  options = options || {};
4
4
  // The pre-paint boot script (stacksjs/stx#1794) publishes the app's
5
5
  // configured options here. Reading them makes a bare useColorMode() agree
@@ -281,7 +281,7 @@ catch (e) {} }
281
281
  function usePreferredLight() { return useMediaQuery('(prefers-color-scheme: light)'); }
282
282
  function usePreferredReducedMotion() { return useMediaQuery('(prefers-reduced-motion: reduce)'); }
283
283
  function usePreferredContrast() { return useMediaQuery('(prefers-contrast: more)'); }
284
- `;function oe(e){return` var __stxGeneratedIdCounter = 0;
284
+ `;function oe(t){return` var __stxGeneratedIdCounter = 0;
285
285
 
286
286
  // Stable, scope-aware DOM ids for component authoring. A component setup
287
287
  // runs with window.__STX_CURRENT_ELEMENT__ pointing at its compiled root, so
@@ -305,7 +305,7 @@ catch (e) {} }
305
305
  return normalizedPrefix + '-' + __stxGeneratedIdCounter;
306
306
  }
307
307
 
308
- var createModelSignal = ${e};
308
+ var createModelSignal = ${t};
309
309
  function useModel(name, options) {
310
310
  if (typeof name !== 'string') { options = name || {}; name = 'modelValue'; }
311
311
  options = options || {};
@@ -314,7 +314,7 @@ catch (e) {} }
314
314
  var modifiers = useReactiveProp(modifierName, {});
315
315
  var emit = window.stx.defineEmits(['update:' + name]);
316
316
  return createModelSignal(source, function() { return modifiers() || {}; },
317
- function(value) { emit('update:' + name, value); }, options, onDestroy);
317
+ function(value) { emit('update:' + name, value); }, options, onDestroy, onMount);
318
318
  }
319
319
 
320
320
  // Reactive prop binding. Bridges the gap between a parent's clientReactive
@@ -389,7 +389,15 @@ catch (e) {} }
389
389
  var initial;
390
390
  var lastRaw = null;
391
391
  var initialAttribute = readAttribute();
392
- if (initialAttribute.has) {
392
+ var initialDirectValues = root && root.__stx_direct_prop_values;
393
+ var initialDirect = initialDirectValues && (initialDirectValues[name] || initialDirectValues[kebabName] || initialDirectValues[lowerName]);
394
+ if (initialDirect && initialDirect.raw === initialAttribute.raw) {
395
+ lastRaw = initialAttribute.raw;
396
+ initial = initialDirect.value;
397
+ Object.keys(initialDirectValues).forEach(function(key) {
398
+ if (initialDirectValues[key] === initialDirect) delete initialDirectValues[key];
399
+ });
400
+ } else if (initialAttribute.has) {
393
401
  lastRaw = initialAttribute.raw;
394
402
  initial = parse(lastRaw);
395
403
  } else if (typeof staticValue === 'string' && (opts.parse || typeof defaultValue !== 'string')) {
@@ -433,9 +441,8 @@ catch (e) {} }
433
441
  }
434
442
  if (next !== s()) s.set(next);
435
443
  }
436
- var observer = new MutationObserver(sync);
437
444
  var connected = true;
438
- observer.observe(root, { attributes: true, attributeFilter: attributeNames });
445
+ var stopObserving = stxHost.observeAttributes(root, attributeNames, sync);
439
446
  // An :if hides a component and shows it again with the same setup, so
440
447
  // the link to the parent is dropped on unmount and made again on mount.
441
448
  // Disconnected for good, a component re-shown in an :if kept the prop it
@@ -444,12 +451,12 @@ catch (e) {} }
444
451
  if (connected) return;
445
452
  connected = true;
446
453
  register();
447
- observer.observe(root, { attributes: true, attributeFilter: attributeNames });
454
+ stopObserving = stxHost.observeAttributes(root, attributeNames, sync);
448
455
  sync();
449
456
  });
450
457
  onDestroy(function() {
451
458
  connected = false;
452
- observer.disconnect();
459
+ stopObserving();
453
460
  attributeNames.forEach(function(attributeName) {
454
461
  if (propSignals[attributeName] === s) delete propSignals[attributeName];
455
462
  });
@@ -561,6 +568,17 @@ catch (e) {} }
561
568
  return false;
562
569
  }
563
570
 
571
+ function bindFormControlReset(el, key, read, write) {
572
+ if (!stxHost.onFormReset) return;
573
+ var bindings = el.__stx_form_resets || (el.__stx_form_resets = {});
574
+ if (bindings[key]) return;
575
+ var initial = peek(read);
576
+ bindings[key] = true;
577
+ var stop = stxHost.onFormReset(el, function() { write(initial); });
578
+ el.__stx_destroy = el.__stx_destroy || [];
579
+ el.__stx_destroy.push(function() { stop(); delete bindings[key]; });
580
+ }
581
+
564
582
  function syncComponentPropSignal(el, name, value) {
565
583
  if (!el || !el.getAttribute || value === undefined) return;
566
584
  var scopeId = el.getAttribute('data-stx-scope');
@@ -577,7 +595,6 @@ catch (e) {} }
577
595
  var propSignal = propSignals && (propSignals[name] || propSignals[camelName]);
578
596
  if (!propSignal && scopeVars)
579
597
  propSignal = scopeVars[name] || scopeVars[camelName];
580
- if (!propSignal || !propSignal._isSignal || typeof propSignal.set !== 'function') return;
581
598
  var directValues = el.__stx_direct_prop_values || (el.__stx_direct_prop_values = {});
582
599
  var directValue = {
583
600
  raw: el.hasAttribute(name) ? el.getAttribute(name) : null,
@@ -585,6 +602,9 @@ catch (e) {} }
585
602
  };
586
603
  directValues[name] = directValue;
587
604
  directValues[camelName] = directValue;
605
+ // The parent binding can run before child setup. Keep the typed value
606
+ // even then: JSON attributes cannot retain validators or other callbacks.
607
+ if (!propSignal || !propSignal._isSignal || typeof propSignal.set !== 'function') return;
588
608
  // This runs inside the parent binding effect. Reading the child prop
589
609
  // signal normally would subscribe that effect to its own output. Parent
590
610
  // expressions that return a fresh array or object would then recurse:
@@ -1209,7 +1229,9 @@ else {
1209
1229
  el.__stx_component_emits = el.__stx_component_emits || Object.create(null);
1210
1230
  el.__stx_component_emits[event] = true;
1211
1231
  }
1212
- target.dispatchEvent(new CustomEvent(event, { detail: payload, bubbles: true, cancelable: true }));
1232
+ var emitted = new CustomEvent(event, { detail: payload, bubbles: true, cancelable: true });
1233
+ emitted.__stx_emit_args = Array.prototype.slice.call(arguments, 1);
1234
+ stxHost.emitComponentEvent(target, emitted);
1213
1235
  };
1214
1236
  },
1215
1237
  defineExpose: function(exposed) {
@@ -2364,7 +2386,7 @@ finally {
2364
2386
  if (bareIdMatch) {
2365
2387
  const fn = scope[bareIdMatch[1]];
2366
2388
  if (typeof fn === 'function' && !fn._isSignal) {
2367
- return ($event) => fn($event);
2389
+ return (...args) => fn(...args);
2368
2390
  }
2369
2391
  }
2370
2392
 
@@ -2436,7 +2458,7 @@ finally {
2436
2458
  function findElementScope(el) {
2437
2459
  let current = el;
2438
2460
  while (current && current !== document) {
2439
- // Check element-local scope first (from stx.mount())
2461
+ // Explicit element-local mounts own their scope, ahead of a registry.
2440
2462
  if (current.__stx_scope) {
2441
2463
  return current.__stx_scope;
2442
2464
  }
@@ -2709,11 +2731,11 @@ catch (e) {
2709
2731
  }
2710
2732
  throw e;
2711
2733
  }
2712
- }`;function Te(e,a){return` // ==========================================================================
2734
+ }`;function Te(t,a){return` // ==========================================================================
2713
2735
  // Declarative Data Fetching (Feature #6 - useFetch)
2714
2736
  // ==========================================================================
2715
2737
 
2716
- var readHydratedData = ${e};
2738
+ var readHydratedData = ${t};
2717
2739
  var clearServerData = ${a};
2718
2740
 
2719
2741
  function useFetch(urlOrFn, options = {}) {
@@ -3889,6 +3911,11 @@ catch (e) {
3889
3911
  node.setAttribute(name, next);
3890
3912
  },
3891
3913
  removeAttribute: function(node, name) { node.removeAttribute(name); },
3914
+ observeAttributes: function(node, names, callback) {
3915
+ var observer = new MutationObserver(callback);
3916
+ observer.observe(node, { attributes: true, attributeFilter: names });
3917
+ return function() { observer.disconnect(); };
3918
+ },
3892
3919
  setStyle: function(node, value) {
3893
3920
  if (typeof value === 'object' && value !== null) {
3894
3921
  Object.assign(node.style, value);
@@ -3921,6 +3948,21 @@ catch (e) {
3921
3948
  // parameter silently makes every touch listener blocking again, so it stays
3922
3949
  // in the signature and each host decides what to do with it.
3923
3950
  listen: function(node, event, handler, options) { node.addEventListener(event, handler, options); },
3951
+ emitComponentEvent: function(node, event) { return node.dispatchEvent(event); },
3952
+ onFormReset: function(node, callback) {
3953
+ var active = true;
3954
+ var document = node.ownerDocument;
3955
+ var listener = function(event) {
3956
+ if (event.target !== node.form) return;
3957
+ // The reset event precedes the browser default action and may be
3958
+ // canceled by a later listener. Synchronize models only afterward.
3959
+ queueMicrotask(function() {
3960
+ if (active && !event.defaultPrevented) callback();
3961
+ });
3962
+ };
3963
+ document.addEventListener('reset', listener, true);
3964
+ return function() { active = false; document.removeEventListener('reset', listener, true); };
3965
+ },
3924
3966
 
3925
3967
  // Returns the PREVIOUS visibility. bindShow needs to know whether it just
3926
3968
  // revealed something, and asking the node afterwards is the one read-back
@@ -4879,10 +4921,10 @@ else if (!value && isInserted) {
4879
4921
  }
4880
4922
  });
4881
4923
  }
4882
- `;function je(e,a,i,o,u){return` // One request for every caller that wants the same answer: run joins one
4924
+ `;function je(t,a,i,r,d){return` // One request for every caller that wants the same answer: run joins one
4883
4925
  // in flight, fresh waits one out and asks again, latest replaces a request
4884
4926
  // counter. See shared-request.ts; cached queries are built on it.
4885
- var sharedRequest = (${u});
4927
+ var sharedRequest = (${d});
4886
4928
 
4887
4929
  // A value kept between visits, for a phone app between launches: the tab a
4888
4930
  // user opens right after starting the app draws last time's data at once
@@ -4898,8 +4940,8 @@ else if (!value && isInserted) {
4898
4940
  // off the critical path and read back asynchronously. Values kept before it
4899
4941
  // are read where they are.
4900
4942
  var STX_KEPT_PREFIX = 'stx:kept:';
4901
- var __stxKept = (${e})(undefined, ${a});
4902
- var __stxQueries = (${i})({ state: state, kept: __stxKept, prefix: STX_KEPT_PREFIX, matches: ${o}, sharedRequest: sharedRequest });
4943
+ var __stxKept = (${t})(undefined, ${a});
4944
+ var __stxQueries = (${i})({ state: state, kept: __stxKept, prefix: STX_KEPT_PREFIX, matches: ${r}, sharedRequest: sharedRequest });
4903
4945
  function stxKeptPrefix(scope) {
4904
4946
  return STX_KEPT_PREFIX + (scope === undefined || scope === null || scope === '' ? '' : String(scope) + ':');
4905
4947
  }
@@ -5385,6 +5427,11 @@ else if (!value && isInserted) {
5385
5427
  // that no longer exists in the host tree. Browser hydration keeps its
5386
5428
  // existing behaviour because it does not pass resolvedNodes here.
5387
5429
  if (resolvedNodes && node.__stxId !== undefined && node.isConnected === false) continue;
5430
+ if (resolvedNodes && node.hasAttribute && node.hasAttribute('data-stx-scope')
5431
+ && !hasPendingLoopBoundary(node)) {
5432
+ node.__stx_parent_scope = resolveComponentCallerScope(node, scope);
5433
+ bindParentComponentProps(node, node.__stx_parent_scope);
5434
+ }
5388
5435
  processElement(node, scope, true);
5389
5436
  }
5390
5437
  return true;
@@ -5414,6 +5461,8 @@ else if (!value && isInserted) {
5414
5461
  if (!mounted) return;
5415
5462
  mounted = false;
5416
5463
  disposeEffects();
5464
+ disposeSubtreeEffects(root);
5465
+ disposeSubtreeScopes(root);
5417
5466
  var hooks = localDestroyHooks.splice(0, localDestroyHooks.length);
5418
5467
  for (var i = 0; i < hooks.length; i++) {
5419
5468
  try { hooks[i](); }
@@ -5481,6 +5530,8 @@ catch (e) {
5481
5530
  }
5482
5531
  };
5483
5532
 
5533
+ bindFormControlReset(el, 'model', getValue, setValue);
5534
+
5484
5535
  if (tag === 'input' && type === 'checkbox') {
5485
5536
  var syncCheckbox = () => {
5486
5537
  var current = getValue();
@@ -5775,7 +5826,11 @@ else {
5775
5826
  if (typeof scope === 'object' && scope !== null) {
5776
5827
  scope.$el = root;
5777
5828
  scope.$refs = scope.$refs || {};
5778
- root.__stx_scope = scope; // Store isolated scope on element
5829
+ // An auto-mounted page can start with a shared component. That
5830
+ // wrapper already owns a component scope: the page supplies its
5831
+ // caller, not a replacement for its handlers/refs/prop signals.
5832
+ if (root.hasAttribute('data-stx-component-wrapper')) root.__stx_parent_scope = scope;
5833
+ else root.__stx_scope = scope;
5779
5834
  Object.assign(componentScope, scope); // Keep for backwards compat
5780
5835
  }
5781
5836
 
@@ -6762,7 +6817,7 @@ finally {
6762
6817
  collectSubscribers(subscribers, reached);
6763
6818
  reached.forEach(function(e) { e(); });
6764
6819
  }
6765
- `;function Je(e,a,i){return`${e} // ==========================================================================
6820
+ `;function Je(t,a,i){return`${t} // ==========================================================================
6766
6821
  // Reactive Core
6767
6822
  // ==========================================================================
6768
6823
 
@@ -7031,7 +7086,7 @@ else {
7031
7086
 
7032
7087
  return value;
7033
7088
  }
7034
- `;function tt(e,a,i){return` // skipChildren: this element's bindings only, because something else already
7089
+ `;function tt(t,a,i){return` // skipChildren: this element's bindings only, because something else already
7035
7090
  // knows where the rest are. The manifest path passes it for every entry, so
7036
7091
  // the tree is never walked; see processFromManifest.
7037
7092
  function processElement(el, scope = componentScope, skipChildren) {
@@ -7054,8 +7109,12 @@ else {
7054
7109
  return;
7055
7110
  }
7056
7111
 
7057
- if (el.nodeType === Node.ELEMENT_NODE && el.tagName === 'BUTTON' && el.hasAttribute && el.hasAttribute('@click')) {
7058
-
7112
+ if (el.nodeType === Node.ELEMENT_NODE && el.hasAttribute
7113
+ && el.hasAttribute('data-stx-scope') && !hasPendingLoopBoundary(el)) {
7114
+ // A page walk can reach a component before the dedicated scope pass.
7115
+ // Resolve its caller before props/events bind and their guards latch.
7116
+ el.__stx_parent_scope = el.__stx_parent_scope || resolveComponentCallerScope(el, scope);
7117
+ bindParentComponentProps(el, el.__stx_parent_scope);
7059
7118
  }
7060
7119
  if (el.nodeType === Node.ELEMENT_NODE && el.hasAttribute) {
7061
7120
  // x-data elements: the reactive bridge has registered their scope into window.stx._scopes.
@@ -7301,7 +7360,7 @@ catch (e2) {
7301
7360
  };
7302
7361
 
7303
7362
  // Known directive names to exclude from generic :attr binding
7304
- var DIRECTIVE_NAMES = ${e};
7363
+ var DIRECTIVE_NAMES = ${t};
7305
7364
 
7306
7365
  // A bound value cannot introduce a URL scheme the page did not ask for.
7307
7366
  // This is the client half of url-safety.ts: the server refuses a scheme
@@ -7382,6 +7441,13 @@ catch (e2) {
7382
7441
  var bindingScope = el.__stx_parent_scope && parentBindingNames.includes(attrName)
7383
7442
  ? el.__stx_parent_scope
7384
7443
  : attrCapturedScope;
7444
+ if ((attrName === 'value' || attrName === 'checked') && attrName in el) {
7445
+ var modelName = value.trim().match(/^([a-zA-Z_$][\\w$]*)(?:\\(\\))?$/);
7446
+ var resetModel = modelName && bindingScope[modelName[1]];
7447
+ if (resetModel && resetModel._isSignal && typeof resetModel.set === 'function') {
7448
+ bindFormControlReset(el, attrName, resetModel, function(initial) { resetModel.set(initial); });
7449
+ }
7450
+ }
7385
7451
  effect(() => {
7386
7452
  if (!attributesVisible()) return;
7387
7453
  const v = evalAttrExpr(value, bindingScope);
@@ -7535,6 +7601,9 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
7535
7601
  if (refOwnerScope.$refs) refOwnerScope.$refs[value] = el;
7536
7602
  }
7537
7603
  else {
7604
+ // Manifest hydration receives the page scope for each node. A
7605
+ // component-local ref still belongs to the node's owning scope.
7606
+ if (refOwnerScope && refOwnerScope.$refs) refOwnerScope.$refs[value] = el;
7538
7607
  if (scope.$refs) scope.$refs[value] = el;
7539
7608
  if (componentScope.$refs) componentScope.$refs[value] = el;
7540
7609
  }
@@ -7544,7 +7613,7 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
7544
7613
  // it silently returned undefined.
7545
7614
  var refTarget = refCaller && refOwnerScope
7546
7615
  ? refOwnerScope[value]
7547
- : (scope && scope[value]) || componentScope[value];
7616
+ : (refOwnerScope && refOwnerScope[value]) || (scope && scope[value]) || componentScope[value];
7548
7617
  if (refTarget && typeof refTarget === 'function' && refTarget._isSignal && typeof refTarget.set === 'function') {
7549
7618
  refTarget.set(el);
7550
7619
  }
@@ -7602,9 +7671,10 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
7602
7671
  // Vue-style component handlers receive the emitted payload directly.
7603
7672
  // Native root events still receive the Event object so server-only
7604
7673
  // components can forward clicks and other browser events.
7605
- var handlerEvent = isForwardedComponentEvent && event instanceof CustomEvent
7606
- ? event.detail
7607
- : event;
7674
+ var emittedArgs = isForwardedComponentEvent && event instanceof CustomEvent
7675
+ && Array.isArray(event.__stx_emit_args) ? event.__stx_emit_args : null;
7676
+ var handlerEvent = emittedArgs ? emittedArgs[0]
7677
+ : isForwardedComponentEvent && event instanceof CustomEvent ? event.detail : event;
7608
7678
 
7609
7679
  // Skip an opener click that reaches UI which just became visible in
7610
7680
  // this frame. A click whose target is inside the revealed subtree is
@@ -7637,7 +7707,7 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
7637
7707
  try {
7638
7708
  if (!value || /^__[A-Z_]+__$/.test(value.trim())) return;
7639
7709
  var shorthandFn = parseEventShorthand(value, eventCapturedScope);
7640
- if (shorthandFn) { shorthandFn(handlerEvent); return; }
7710
+ if (shorthandFn) { shorthandFn.apply(null, emittedArgs || [handlerEvent]); return; }
7641
7711
  // Check if any scope values are signals (x-data pattern)
7642
7712
  // A derived value reads like a signal in a handler, as it does in a
7643
7713
  // binding: \`pick(selectedPackage)\` passes the package. Leaving it
@@ -7805,7 +7875,7 @@ catch (e) {
7805
7875
  },
7806
7876
  });
7807
7877
  }
7808
- `;function rt(e){return` // Component mount system
7878
+ `;function rt(t){return` // Component mount system
7809
7879
  var mountQueue = [];
7810
7880
 
7811
7881
  // MERGE, never replace (#1804). Three client bundles assign window.stx and
@@ -7912,7 +7982,7 @@ catch (e) {
7912
7982
  confirm: stxConfirm,
7913
7983
  helpers: globalHelpers,
7914
7984
 
7915
- ${e}
7985
+ ${t}
7916
7986
 
7917
7987
  _mountCallbacks: mountCallbacks,
7918
7988
  _destroyCallbacks: destroyCallbacks,
@@ -10101,7 +10171,7 @@ else if (timer === null) {
10101
10171
  subscribe: subscribe
10102
10172
  };
10103
10173
  }
10104
- `;function Ne(){let e=xt(Zt());try{let i=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(e);return i=i.replace(/\}(var |let |const |function )/g,"};$1"),i}catch{return e}}function xt(e){let a=[],i=0,o="console.log(";while(i<e.length){let u=e.indexOf(o,i);if(u===-1){a.push(e.slice(i));break}a.push(e.slice(i,u));let y=1,s=u+o.length;while(s<e.length&&y>0){let h=e[s];if(h==='"'||h==="'"||h==="`"){let r=h;s++;while(s<e.length&&e[s]!==r){if(e[s]==="\\")s++;s++}s++;continue}if(h==="(")y++;else if(h===")")y--;s++}a.push("0"),i=s}return a.join("")}function Zt(){return`${ae}${Me}
10174
+ `;function Ne(){let t=xt(Zt());try{let i=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t);return i=i.replace(/\}(var |let |const |function )/g,"};$1"),i}catch{return t}}function xt(t){let a=[],i=0,r="console.log(";while(i<t.length){let d=t.indexOf(r,i);if(d===-1){a.push(t.slice(i));break}a.push(t.slice(i,d));let y=1,o=d+r.length;while(o<t.length&&y>0){let u=t[o];if(u==='"'||u==="'"||u==="`"){let f=u;o++;while(o<t.length&&t[o]!==f){if(t[o]==="\\")o++;o++}o++;continue}if(u==="(")y++;else if(u===")")y--;o++}a.push("0"),i=o}return a.join("")}function Zt(){return`${ae}${Me}
10105
10175
  ${Je(ie,Se,Ee)}
10106
10176
 
10107
10177
  ${Oe}
@@ -10179,5 +10249,5 @@ ${lt}
10179
10249
  ${ct}
10180
10250
  ${at}
10181
10251
  })();
10182
- `}var gd={state:W,derived:Qt,effect:en,batch:qr,onMount:Gr,onDestroy:zn,isSignal:tn,isDerived:nn,untrack:Kr,peek:Hn,generateSignalsRuntime:Ne,generateSignalsRuntimeDev:Zt};
10183
- export{Ne,Zt,gd};
10252
+ `}var gu={state:W,derived:Qt,effect:en,batch:Gr,onMount:zn,onDestroy:Hn,isSignal:tn,isDerived:nn,untrack:Kr,peek:Un,generateSignalsRuntime:Ne,generateSignalsRuntimeDev:Zt};
10253
+ export{Ne,Zt,gu};
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import x from"fs";import u from"path";import p from"fs";import w from"path";var y=["components","layouts","partials","emails"];function P(e){return e.split(/[\\/]/).filter(Boolean).slice(0,-1).some((a)=>y.includes(a))}function b(e){return P(e.replace(/^\//,""))}function Ks(e,t){let a=e.filter((i)=>!b(i.pattern)),r=["// Auto-generated by STX - do not edit"];if(a.length===0)r.push("// No page routes found \u2014 route paths stay typed as string.","export {}","");else{r.push("declare module '@stacksjs/stx' {"," interface KnownRoutes {");for(let i of a){let c=[];for(let l of i.params){let d=i.pattern.includes(`:${l}?`)?"?":"";c.push(`${l}${d}: string`)}let s=c.join("; ");r.push(` '${i.pattern}': { ${s} }`)}r.push(" }","}","","export {}","")}let n=r.join(`
3
3
  `),o=w.join(t,"route-types.d.ts");try{if(p.existsSync(o)&&p.readFileSync(o,"utf8")===n)return;p.mkdirSync(t,{recursive:!0}),p.writeFileSync(o,n)}catch{}}function Xs(e,t,a){let r=process.cwd(),n=w.relative(r,a),o=e.filter((c)=>!b(c.pattern)),i=["// Auto-generated by stx \u2014 do not edit",`// Source: ${n||"pages"}/`,"","export const routes = ["];for(let c of o){let s=w.relative(r,c.filePath).replace(/\\/g,"/"),l=JSON.stringify(c.params),d=c.layout?`, layout: '${w.relative(r,c.layout).replace(/\\/g,"/")}'`:"";i.push(` { pattern: '${c.pattern}', filePath: '${s}', isDynamic: ${c.isDynamic}, params: ${l}${d} },`)}i.push("] as const",""),i.push("export type RouteName = typeof routes[number]['pattern']",""),p.mkdirSync(t,{recursive:!0}),p.writeFileSync(w.join(t,"routes.ts"),i.join(`
4
- `))}import I from"path";var N=Object.freeze(["ico","png","jpg","jpeg","gif","webp","avif","svg","bmp","tif","tiff","heic","css","js","mjs","cjs","map","wasm","webmanifest","json","xml","txt","rss","atom","woff","woff2","ttf","otf","eot","mp3","mp4","m4a","m4v","mov","webm","ogg","ogv","oga","wav","flac","avi","mkv","pdf","csv","doc","docx","xls","xlsx","ppt","pptx","rtf","odt","zip","gz","tgz","tar","rar","7z","bz2","xz","php","phtml","asp","aspx","jsp","cgi","env","ini","yml","yaml","toml","sql","bak","old","swp","log","conf","cfg","exe","dmg","pkg","apk","ipa","msi","iso","bin","dll"]),D=N.flatMap((e)=>e===e.toUpperCase()?[e]:[e,e.toUpperCase()]).join("|"),G=new RegExp(`\\.(?:${D})$`),E=`(?![^/]*\\.(?:${D})$)`;function nt(e){let t=e,a=t.search(/[?#]/);if(a!==-1)t=t.slice(0,a);let r=t.slice(t.lastIndexOf("/")+1);return r.length>0&&G.test(r)}function R(e,t){let r=I.relative(t,e).replace(/\.(stx|md)$/,"");if(r=r.split(I.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 Z(e,t={}){let a=t.page?E:"",r=[],n="",o=0;while(o<e.length){let i=e.slice(o),c=/^\/:([^/?*]+)\?/.exec(i);if(c){r.push(c[1]);let d=o+c[0].length===e.length;n+=`(?:/${d?a:""}([^/]+))?`,o+=c[0].length;continue}let s=/^:([^/?*]+)\*/.exec(i);if(s){r.push(s[1]),n+="(.+)",o+=s[0].length;continue}let l=/^:([^/?*]+)/.exec(i);if(l){r.push(l[1]);let d=o+l[0].length===e.length;n+=`${d?a:""}([^/]+)`,o+=l[0].length;continue}n+=e[o].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),o+=1}return{regex:new RegExp(`^${n}$`),params:r}}function Rn(e,t){let a=e===""?"/":e;for(let r of t){let n=a.match(r.regex);if(n){let o={};return r.params.forEach((i,c)=>{o[i]=n[c+1]}),{route:r,params:o}}}return null}function yr(e,t={}){let a=e.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return Z(a,t)}import j from"fs";import L from"path";function _(e,t){let a=[],r=L.dirname(e);while(r.startsWith(t)||r===t){let n=L.join(r,"_layout.stx");if(j.existsSync(n))a.unshift(n);if(r===t)break;r=L.dirname(r)}return a}function B(e,t){let a=[];if(!x.existsSync(e))return a;let r=x.readdirSync(e,{withFileTypes:!0});for(let n of r){let o=u.join(e,n.name);if(n.isDirectory()){if(n.name.startsWith("."))continue;if(y.includes(n.name))continue;a.push(...B(o,t))}else if(n.isFile()){let i=u.extname(n.name);if(t.includes(i)){if(n.name.startsWith("_")&&n.name!=="_layout.stx")continue;if(n.name==="_layout.stx")continue;a.push(o)}}}return a}class An{routes;pagesDir;pagesDirs;config;constructor(e,t={}){this.config=t;let a=t.pagesDirs&&t.pagesDirs.length>0?t.pagesDirs:[t.pagesDir||"pages"];this.pagesDirs=a.map((s)=>u.resolve(e,s)),this.pagesDir=this.pagesDirs[0];let r=t.extensions||[".stx"],n=(s)=>{let l=u.resolve(e,s);try{return x.realpathSync(l)}catch{return l}},o=(t.exclude??[]).filter((s)=>typeof s==="string"&&s.trim()!=="").map(n),i=(s)=>{if(o.length===0)return!1;let l=n(s);return o.some((d)=>l===d||l.startsWith(`${d}${u.sep}`))},c=new Set;this.routes=[];for(let s of this.pagesDirs){let l=B(s,r).filter((h)=>!i(h)),d=new Map;for(let h of l){let g=R(h,s),m=t.pagesDirs?g.replace(/:[\w]+/g,":param"):g;if(t.pagesDirs&&d.has(m))throw Error(`Conflicting layer pages for ${g}: ${d.get(m)} and ${h}`);if(d.set(m,h),c.has(m))continue;c.add(m);let{regex:H,params:M}=Z(g,{page:!0}),C=t.layouts!==!1?_(h,s):[];this.routes.push({pattern:g,regex:H,params:M,filePath:h,isDynamic:M.length>0,layout:C.length>0?C[C.length-1]:void 0})}}if(this.routes.sort((s,l)=>{if(!s.isDynamic&&l.isDynamic)return-1;if(s.isDynamic&&!l.isDynamic)return 1;let d=s.pattern.split("/").length,h=l.pattern.split("/").length;if(d!==h)return h-d;return s.pattern.localeCompare(l.pattern)}),t.emit!==!1){let s=u.resolve(e,t.stateDir||process.env.STX_DIR?.trim()||".stx");Ks(this.routes,s),Xs(this.routes,s,this.pagesDir)}}match(e){let t=e===""?"/":e;for(let a of this.routes){let r=t.match(a.regex);if(r){let n={};return a.params.forEach((o,i)=>{n[o]=r[i+1]}),{route:a,params:n}}}return null}resolve(e,t){let a=this.routes.find((n)=>n.pattern===e||n.filePath.includes(e));if(!a)return"#not-found";let r=a.pattern;if(t)for(let[n,o]of Object.entries(t))r=r.replace(`:${n}`,encodeURIComponent(o));return r}addRoute(e){this.routes.push(e),this.routes.sort((t,a)=>{if(!t.isDynamic&&a.isDynamic)return-1;if(t.isDynamic&&!a.isDynamic)return 1;return t.pattern.localeCompare(a.pattern)})}getLayout(e){return e.layout??null}}function br(e,t){let a=[`${t}.stx`,"error.stx"];for(let r of a){let n=u.join(e,r);if(x.existsSync(n))return n}return null}function wr(e,t){return e.map((a)=>{let r=u.relative(t,a.filePath),n=a.isDynamic?" (dynamic)":"";return`${a.pattern} \u2192 ${r}${n}`})}var f={},k="";function Xc(e){k=e.replace(/\/$/,"")}function Jc(e,t,a={}){f[e]={path:t,name:e,params:a}}function Yc(e){for(let[t,a]of Object.entries(e))if(typeof a==="string")f[t]={path:a,name:t};else f[t]={...a,name:t}}function Pn(e,t={},a=!1){let r=f[e];if(!r)return console.warn(`Route [${e}] not defined.`),"#undefined-route";let n={...r.params,...t},o=r.path;o=o.replace(/:(\w+)/g,(c,s)=>{let l=n[s];if(l===void 0)return console.warn(`Missing parameter [${s}] for route [${e}].`),`:${s}`;return delete n[s],encodeURIComponent(String(l))});let i=Object.entries(n);if(i.length>0){let c=i.map(([s,l])=>`${encodeURIComponent(s)}=${encodeURIComponent(String(l))}`).join("&");o+=(o.includes("?")?"&":"?")+c}return a&&k?`${k}${o}`:o}function Zc(){for(let e of Object.keys(f))delete f[e];k=""}import F from"fs";import U from"path";function Qc(e,t={}){return{type:"redirect",path:e,options:{replace:t.replace??!1,external:t.external??!1,redirectCode:t.redirectCode??302}}}function el(e){return{type:"abort",error:typeof e==="string"?{statusCode:500,message:e}:e}}function tl(e,t={}){return{handler:e,mode:t.mode??"universal"}}function O(e){let t={};if(!e)return t;let a=e.split(";");for(let r of a){let[n,...o]=r.split("=");if(n){let i=n.trim(),c=o.join("=").trim();if(i)t[i]=decodeURIComponent(c)}}return t}function S(e,t,a={}){let r=`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(a.expires){let n=typeof a.expires==="number"?new Date(Date.now()+a.expires*1000):a.expires;r+=`; Expires=${n.toUTCString()}`}if(a.path)r+=`; Path=${a.path}`;if(a.domain)r+=`; Domain=${a.domain}`;if(a.secure)r+="; Secure";if(a.httpOnly)r+="; HttpOnly";if(a.sameSite)r+=`; SameSite=${a.sameSite}`;return r}function Yi(e,t){let a=e.headers.get("cookie")||"",r=O(a);return{get(n){return r[n]},set(n,o,i={}){r[n]=o,t.append("Set-Cookie",S(n,o,i))},delete(n){delete r[n],t.append("Set-Cookie",S(n,"",{expires:new Date(0),path:"/"}))},getAll(){return{...r}}}}function Zi(){return{get(e){if(typeof document>"u")return;return O(document.cookie)[e]},set(e,t,a={}){if(typeof document>"u")return;document.cookie=S(e,t,a)},delete(e){if(typeof document>"u")return;document.cookie=S(e,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return O(document.cookie)}}}function Qi(){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,a){if(!e)return;try{window.localStorage.setItem(t,a)}catch{}},remove(t){if(!e)return;try{window.localStorage.removeItem(t)}catch{}},isAvailable(){return e}}}var v=new Map;function Js(e,t){v.set(e,t)}function ea(e){return v.get(e)}function nl(e){return v.has(e)}function rt(){v.clear()}function st(){return Array.from(v.keys())}async function ot(e,t="middleware"){let a=U.resolve(e,t);if(!F.existsSync(a))return;let r=F.readdirSync(a);for(let n of r){if(!n.endsWith(".ts")&&!n.endsWith(".js"))continue;if(n.includes(".test.")||n.includes(".spec."))continue;let o=n.replace(/\.(ts|js)$/,""),i=U.join(a,n);try{let s=(await import(i)).default;if(s&&typeof s.handler==="function")Js(o,s);else if(typeof s==="function")Js(o,{handler:s,mode:"universal"})}catch(c){console.warn(`Failed to load middleware '${o}' from ${i}:`,c)}}}function K(e){let t={};if(!e)return t;let a=new URLSearchParams(e);for(let[r,n]of a)t[r]=n;return t}function it(e,t,a,r=""){return{path:e,params:t,query:K(r),fullPath:r?`${e}?${r}`:e,meta:a}}function at(e,t,a,r){let n=r?.isServer??typeof window>"u",o=!n,i=new Headers;return{to:e,from:t,isClient:o,isServer:n,cookies:n&&a?Yi(a,i):Zi(),storage:Qi(),state:{},request:a,responseHeaders:i}}async function ct(e,t){let a=Array.isArray(e)?e:[e],r=t.isServer;for(let n of a){let o=ea(n);if(!o)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(o.mode==="server"&&!r)continue;try{let i=await o.handler(t);if(i){if(i.type==="redirect")return{passed:!1,redirect:i,state:t.state,responseHeaders:t.responseHeaders};if(i.type==="abort")return{passed:!1,abort:i,state:t.state,responseHeaders:t.responseHeaders}}}catch(i){return console.error(`Error in middleware '${n}':`,i),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:i instanceof Error?i.message:"Middleware error"}},state:t.state,responseHeaders:t.responseHeaders}}}return{passed:!0,state:t.state,responseHeaders:t.responseHeaders}}function vr(e){let a=e.replace(/\\/g,"/").split("/").filter(Boolean),r=a.lastIndexOf("layouts"),n=r>=0?a[r+1]:a.at(-1);if(!n)return"app";return n.replace(/\.stx$/i,"")||"app"}function Ee(e){let t=e.match(/<meta\b[^>]*name=["']stx-layout["'][^>]*content=["']([^"']+)["'][^>]*>/i),a=e.match(/<meta\b[^>]*name=["']stx-layout-group["'][^>]*content=["']([^"']+)["'][^>]*>/i),r=e.match(/<!--\s*stx-layout:\s*([^ ]+)\s*-->/i),n=t?.[1]||r?.[1]||"";return{layout:n,group:a?.[1]||vr(n)}}var A,T;function W(e){let t=[],a="log(",r=0;while(r<e.length){let n=e.indexOf("log(",r);if(n===-1){t.push(e.slice(r));break}let o=n>0?e[n-1]:" ",i=/\bfunction\s+$/.test(e.slice(Math.max(0,n-16),n));if(/[\w$.]/.test(o)||i){t.push(e.slice(r,n+4)),r=n+4;continue}t.push(e.slice(r,n));let c=1,s=n+4;while(s<e.length&&c>0){let l=e[s];if(l==='"'||l==="'"||l==="`"){let d=l;s++;while(s<e.length&&e[s]!==d){if(e[s]==="\\")s++;s++}s++;continue}if(l==="(")c++;else if(l===")")c--;s++}t.push("0"),r=s}return t.join("")}function q(e,t=!1){try{return new Bun.Transpiler(t?{loader:"js",minify:{whitespace:!0,identifiers:!0}}:{loader:"js",minifyWhitespace:!0}).transformSync(e).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return e}}function X(){return`
4
+ `))}import I from"path";var N=Object.freeze(["ico","png","jpg","jpeg","gif","webp","avif","svg","bmp","tif","tiff","heic","css","js","mjs","cjs","map","wasm","webmanifest","json","xml","txt","rss","atom","woff","woff2","ttf","otf","eot","mp3","mp4","m4a","m4v","mov","webm","ogg","ogv","oga","wav","flac","avi","mkv","pdf","csv","doc","docx","xls","xlsx","ppt","pptx","rtf","odt","zip","gz","tgz","tar","rar","7z","bz2","xz","php","phtml","asp","aspx","jsp","cgi","env","ini","yml","yaml","toml","sql","bak","old","swp","log","conf","cfg","exe","dmg","pkg","apk","ipa","msi","iso","bin","dll"]),D=N.flatMap((e)=>e===e.toUpperCase()?[e]:[e,e.toUpperCase()]).join("|"),G=new RegExp(`\\.(?:${D})$`),E=`(?![^/]*\\.(?:${D})$)`;function nt(e){let t=e,a=t.search(/[?#]/);if(a!==-1)t=t.slice(0,a);let r=t.slice(t.lastIndexOf("/")+1);return r.length>0&&G.test(r)}function R(e,t){let r=I.relative(t,e).replace(/\.(stx|md)$/,"");if(r=r.split(I.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 Z(e,t={}){let a=t.page?E:"",r=[],n="",o=0;while(o<e.length){let i=e.slice(o),c=/^\/:([^/?*]+)\?/.exec(i);if(c){r.push(c[1]);let d=o+c[0].length===e.length;n+=`(?:/${d?a:""}([^/]+))?`,o+=c[0].length;continue}let s=/^:([^/?*]+)\*/.exec(i);if(s){r.push(s[1]),n+="(.+)",o+=s[0].length;continue}let l=/^:([^/?*]+)/.exec(i);if(l){r.push(l[1]);let d=o+l[0].length===e.length;n+=`${d?a:""}([^/]+)`,o+=l[0].length;continue}n+=e[o].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),o+=1}return{regex:new RegExp(`^${n}$`),params:r}}function Rn(e,t){let a=e===""?"/":e;for(let r of t){let n=a.match(r.regex);if(n){let o={};return r.params.forEach((i,c)=>{o[i]=n[c+1]}),{route:r,params:o}}}return null}function br(e,t={}){let a=e.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return Z(a,t)}import j from"fs";import L from"path";function _(e,t){let a=[],r=L.dirname(e);while(r.startsWith(t)||r===t){let n=L.join(r,"_layout.stx");if(j.existsSync(n))a.unshift(n);if(r===t)break;r=L.dirname(r)}return a}function B(e,t){let a=[];if(!x.existsSync(e))return a;let r=x.readdirSync(e,{withFileTypes:!0});for(let n of r){let o=u.join(e,n.name);if(n.isDirectory()){if(n.name.startsWith("."))continue;if(y.includes(n.name))continue;a.push(...B(o,t))}else if(n.isFile()){let i=u.extname(n.name);if(t.includes(i)){if(n.name.startsWith("_")&&n.name!=="_layout.stx")continue;if(n.name==="_layout.stx")continue;a.push(o)}}}return a}class An{routes;pagesDir;pagesDirs;config;constructor(e,t={}){this.config=t;let a=t.pagesDirs&&t.pagesDirs.length>0?t.pagesDirs:[t.pagesDir||"pages"];this.pagesDirs=a.map((s)=>u.resolve(e,s)),this.pagesDir=this.pagesDirs[0];let r=t.extensions||[".stx"],n=(s)=>{let l=u.resolve(e,s);try{return x.realpathSync(l)}catch{return l}},o=(t.exclude??[]).filter((s)=>typeof s==="string"&&s.trim()!=="").map(n),i=(s)=>{if(o.length===0)return!1;let l=n(s);return o.some((d)=>l===d||l.startsWith(`${d}${u.sep}`))},c=new Set;this.routes=[];for(let s of this.pagesDirs){let l=B(s,r).filter((h)=>!i(h)),d=new Map;for(let h of l){let g=R(h,s),m=t.pagesDirs?g.replace(/:[\w]+/g,":param"):g;if(t.pagesDirs&&d.has(m))throw Error(`Conflicting layer pages for ${g}: ${d.get(m)} and ${h}`);if(d.set(m,h),c.has(m))continue;c.add(m);let{regex:H,params:M}=Z(g,{page:!0}),C=t.layouts!==!1?_(h,s):[];this.routes.push({pattern:g,regex:H,params:M,filePath:h,isDynamic:M.length>0,layout:C.length>0?C[C.length-1]:void 0})}}if(this.routes.sort((s,l)=>{if(!s.isDynamic&&l.isDynamic)return-1;if(s.isDynamic&&!l.isDynamic)return 1;let d=s.pattern.split("/").length,h=l.pattern.split("/").length;if(d!==h)return h-d;return s.pattern.localeCompare(l.pattern)}),t.emit!==!1){let s=u.resolve(e,t.stateDir||process.env.STX_DIR?.trim()||".stx");Ks(this.routes,s),Xs(this.routes,s,this.pagesDir)}}match(e){let t=e===""?"/":e;for(let a of this.routes){let r=t.match(a.regex);if(r){let n={};return a.params.forEach((o,i)=>{n[o]=r[i+1]}),{route:a,params:n}}}return null}resolve(e,t){let a=this.routes.find((n)=>n.pattern===e||n.filePath.includes(e));if(!a)return"#not-found";let r=a.pattern;if(t)for(let[n,o]of Object.entries(t))r=r.replace(`:${n}`,encodeURIComponent(o));return r}addRoute(e){this.routes.push(e),this.routes.sort((t,a)=>{if(!t.isDynamic&&a.isDynamic)return-1;if(t.isDynamic&&!a.isDynamic)return 1;return t.pattern.localeCompare(a.pattern)})}getLayout(e){return e.layout??null}}function vr(e,t){let a=[`${t}.stx`,"error.stx"];for(let r of a){let n=u.join(e,r);if(x.existsSync(n))return n}return null}function wr(e,t){return e.map((a)=>{let r=u.relative(t,a.filePath),n=a.isDynamic?" (dynamic)":"";return`${a.pattern} \u2192 ${r}${n}`})}var f={},k="";function Xc(e){k=e.replace(/\/$/,"")}function Jc(e,t,a={}){f[e]={path:t,name:e,params:a}}function Yc(e){for(let[t,a]of Object.entries(e))if(typeof a==="string")f[t]={path:a,name:t};else f[t]={...a,name:t}}function Pn(e,t={},a=!1){let r=f[e];if(!r)return console.warn(`Route [${e}] not defined.`),"#undefined-route";let n={...r.params,...t},o=r.path;o=o.replace(/:(\w+)/g,(c,s)=>{let l=n[s];if(l===void 0)return console.warn(`Missing parameter [${s}] for route [${e}].`),`:${s}`;return delete n[s],encodeURIComponent(String(l))});let i=Object.entries(n);if(i.length>0){let c=i.map(([s,l])=>`${encodeURIComponent(s)}=${encodeURIComponent(String(l))}`).join("&");o+=(o.includes("?")?"&":"?")+c}return a&&k?`${k}${o}`:o}function Zc(){for(let e of Object.keys(f))delete f[e];k=""}import F from"fs";import U from"path";function Qc(e,t={}){return{type:"redirect",path:e,options:{replace:t.replace??!1,external:t.external??!1,redirectCode:t.redirectCode??302}}}function el(e){return{type:"abort",error:typeof e==="string"?{statusCode:500,message:e}:e}}function tl(e,t={}){return{handler:e,mode:t.mode??"universal"}}function O(e){let t={};if(!e)return t;let a=e.split(";");for(let r of a){let[n,...o]=r.split("=");if(n){let i=n.trim(),c=o.join("=").trim();if(i)t[i]=decodeURIComponent(c)}}return t}function S(e,t,a={}){let r=`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(a.expires){let n=typeof a.expires==="number"?new Date(Date.now()+a.expires*1000):a.expires;r+=`; Expires=${n.toUTCString()}`}if(a.path)r+=`; Path=${a.path}`;if(a.domain)r+=`; Domain=${a.domain}`;if(a.secure)r+="; Secure";if(a.httpOnly)r+="; HttpOnly";if(a.sameSite)r+=`; SameSite=${a.sameSite}`;return r}function Yi(e,t){let a=e.headers.get("cookie")||"",r=O(a);return{get(n){return r[n]},set(n,o,i={}){r[n]=o,t.append("Set-Cookie",S(n,o,i))},delete(n){delete r[n],t.append("Set-Cookie",S(n,"",{expires:new Date(0),path:"/"}))},getAll(){return{...r}}}}function Zi(){return{get(e){if(typeof document>"u")return;return O(document.cookie)[e]},set(e,t,a={}){if(typeof document>"u")return;document.cookie=S(e,t,a)},delete(e){if(typeof document>"u")return;document.cookie=S(e,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return O(document.cookie)}}}function Qi(){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,a){if(!e)return;try{window.localStorage.setItem(t,a)}catch{}},remove(t){if(!e)return;try{window.localStorage.removeItem(t)}catch{}},isAvailable(){return e}}}var v=new Map;function Js(e,t){v.set(e,t)}function ea(e){return v.get(e)}function nl(e){return v.has(e)}function rt(){v.clear()}function st(){return Array.from(v.keys())}async function ot(e,t="middleware"){let a=U.resolve(e,t);if(!F.existsSync(a))return;let r=F.readdirSync(a);for(let n of r){if(!n.endsWith(".ts")&&!n.endsWith(".js"))continue;if(n.includes(".test.")||n.includes(".spec."))continue;let o=n.replace(/\.(ts|js)$/,""),i=U.join(a,n);try{let s=(await import(i)).default;if(s&&typeof s.handler==="function")Js(o,s);else if(typeof s==="function")Js(o,{handler:s,mode:"universal"})}catch(c){console.warn(`Failed to load middleware '${o}' from ${i}:`,c)}}}function K(e){let t={};if(!e)return t;let a=new URLSearchParams(e);for(let[r,n]of a)t[r]=n;return t}function it(e,t,a,r=""){return{path:e,params:t,query:K(r),fullPath:r?`${e}?${r}`:e,meta:a}}function at(e,t,a,r){let n=r?.isServer??typeof window>"u",o=!n,i=new Headers;return{to:e,from:t,isClient:o,isServer:n,cookies:n&&a?Yi(a,i):Zi(),storage:Qi(),state:{},request:a,responseHeaders:i}}async function ct(e,t){let a=Array.isArray(e)?e:[e],r=t.isServer;for(let n of a){let o=ea(n);if(!o)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(o.mode==="server"&&!r)continue;try{let i=await o.handler(t);if(i){if(i.type==="redirect")return{passed:!1,redirect:i,state:t.state,responseHeaders:t.responseHeaders};if(i.type==="abort")return{passed:!1,abort:i,state:t.state,responseHeaders:t.responseHeaders}}}catch(i){return console.error(`Error in middleware '${n}':`,i),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:i instanceof Error?i.message:"Middleware error"}},state:t.state,responseHeaders:t.responseHeaders}}}return{passed:!0,state:t.state,responseHeaders:t.responseHeaders}}function xr(e){let a=e.replace(/\\/g,"/").split("/").filter(Boolean),r=a.lastIndexOf("layouts"),n=r>=0?a[r+1]:a.at(-1);if(!n)return"app";return n.replace(/\.stx$/i,"")||"app"}function Ee(e){let t=e.match(/<meta\b[^>]*name=["']stx-layout["'][^>]*content=["']([^"']+)["'][^>]*>/i),a=e.match(/<meta\b[^>]*name=["']stx-layout-group["'][^>]*content=["']([^"']+)["'][^>]*>/i),r=e.match(/<!--\s*stx-layout:\s*([^ ]+)\s*-->/i),n=t?.[1]||r?.[1]||"";return{layout:n,group:a?.[1]||xr(n)}}var A,T;function W(e){let t=[],a="log(",r=0;while(r<e.length){let n=e.indexOf("log(",r);if(n===-1){t.push(e.slice(r));break}let o=n>0?e[n-1]:" ",i=/\bfunction\s+$/.test(e.slice(Math.max(0,n-16),n));if(/[\w$.]/.test(o)||i){t.push(e.slice(r,n+4)),r=n+4;continue}t.push(e.slice(r,n));let c=1,s=n+4;while(s<e.length&&c>0){let l=e[s];if(l==='"'||l==="'"||l==="`"){let d=l;s++;while(s<e.length&&e[s]!==d){if(e[s]==="\\")s++;s++}s++;continue}if(l==="(")c++;else if(l===")")c--;s++}t.push("0"),r=s}return t.join("")}function q(e,t=!1){try{return new Bun.Transpiler(t?{loader:"js",minify:{whitespace:!0,identifiers:!0}}:{loader:"js",minifyWhitespace:!0}).transformSync(e).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return e}}function X(){return`
5
5
  ;(function(){
6
6
  'use strict';
7
7
  var ROUTER_REV=7;
@@ -3897,4 +3897,4 @@ else {
3897
3897
 
3898
3898
  if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',init);else init();
3899
3899
  })();
3900
- `}function Te(){if(A)return A;return A=q(W(X()),!0),A}function rl(){if(T)return T;return T=q(X()),T}export{Ks,Xs,nt,Z,Rn,yr,An,br,wr,Xc,Jc,Yc,Pn,Zc,Qc,el,tl,Yi,Zi,Qi,Js,ea,nl,rt,st,ot,it,at,ct,vr,Ee,Te,rl};
3900
+ `}function Te(){if(A)return A;return A=q(W(X()),!0),A}function rl(){if(T)return T;return T=q(X()),T}export{Ks,Xs,nt,Z,Rn,br,An,vr,wr,Xc,Jc,Yc,Pn,Zc,Qc,el,tl,Yi,Zi,Qi,Js,ea,nl,rt,st,ot,it,at,ct,xr,Ee,Te,rl};
@@ -1,7 +1,7 @@
1
1
  // @bun
2
- import S from"fs";import _ from"path";function Tr(e){let{token:t,baseUrl:i="https://api.netlify.com/api/v1"}=e;async function s(n,r,l={}){let p=`${i}${r}`,f={Authorization:`Bearer ${t}`,"User-Agent":"stx-deploy/1.0"},u;if(l.rawBody)f["Content-Type"]=l.contentType||"application/octet-stream",u=l.rawBody;else if(l.body)f["Content-Type"]="application/json",u=JSON.stringify(l.body);let o=await fetch(p,{method:n,headers:f,body:u});if(!o.ok){let g=Error(`Netlify API error: ${o.status} ${o.statusText}`);g.status=o.status;try{let b=await o.json();g.message=b.message||g.message,g.code=b.code,g.details=b}catch{}throw g}let a=await o.text();if(!a)return{};return JSON.parse(a)}return{async getSite(n){return s("GET",`/sites/${n}`)},async listSites(){return s("GET","/sites")},async createSite(n){let r={};if(n)r.name=n;return s("POST","/sites",{body:r})},async createDeploy(n,r){let l={files:r.files,draft:r.draft??!0,async:r.async??!0};if(r.title)l.title=r.title;if(r.branch)l.branch=r.branch;if(r.functions)l.functions=r.functions;return s("POST",`/sites/${n}/deploys`,{body:l})},async uploadFile(n,r,l){let p=r.startsWith("/")?r.slice(1):r;await s("PUT",`/deploys/${n}/files/${p}`,{rawBody:l,contentType:"application/octet-stream"})},async uploadFiles(n,r){let p=[...r],f=async()=>{while(p.length>0){let o=p.shift();if(o)await this.uploadFile(n,o.path,o.content)}},u=Array.from({length:Math.min(5,r.length)},()=>f());await Promise.all(u)},async getDeploy(n){return s("GET",`/deploys/${n}`)},async waitForDeploy(n,r={}){let{timeout:l=300000,pollInterval:p=2000,onProgress:f}=r,u=Date.now();while(!0){let o=await this.getDeploy(n);if(f)f(o);if(o.state==="ready")return o;if(o.state==="error"){let a=Error(`Deploy failed: ${o.error_message||"Unknown error"}`);throw a.status=500,a.details=o,a}if(Date.now()-u>l){let a=Error(`Deploy timed out after ${l}ms`);throw a.status=408,a.details=o,a}await new Promise((a)=>setTimeout(a,p))}},async lockDeploy(n){return s("POST",`/deploys/${n}/lock`)},async unlockDeploy(n){return s("POST",`/deploys/${n}/unlock`)}}}async function lo(e){let t=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(t)).map((s)=>s.toString(16).padStart(2,"0")).join("")}async function Mn(e,t={}){let{ignore:i=["node_modules",".git",".env*","*.map"]}=t,s=[],n=new Bun.Glob("**/*");for await(let r of n.scan({cwd:e,onlyFiles:!0,dot:!1})){if(i.some((a)=>{if(a.includes("*"))return new RegExp(`^${a.replace(/\*/g,".*")}$`).test(r);return r.includes(a)}))continue;let p=`${e}/${r}`,u=await Bun.file(p).arrayBuffer(),o=await lo(u);s.push({path:r,content:new Uint8Array(u),sha1:o})}return s}function $r(e){let t={};for(let i of e)t[`/${i.path}`]=i.sha1;return t}function Rr(e,t){let i=new Set(t.map((s)=>s.startsWith("/")?s.slice(1):s));return e.filter((s)=>i.has(s.path))}function jt(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;if(e<1073741824)return`${(e/1048576).toFixed(1)} MB`;return`${(e/1073741824).toFixed(1)} GB`}function ft(e){return e.reduce((t,i)=>t+i.content.byteLength,0)}import m from"fs";import y from"path";function uo(e){let t=[];if(t.push("[build]"),t.push(` command = "${d(e.build.command)}"`),t.push(` publish = "${d(e.build.publish)}"`),e.build.functions)t.push(` functions = "${d(e.build.functions)}"`);if(e.build.edge_functions)t.push(` edge_functions = "${d(e.build.edge_functions)}"`);if(e.build.environment&&Object.keys(e.build.environment).length>0){t.push(""),t.push("[build.environment]");for(let[i,s]of Object.entries(e.build.environment))t.push(` ${i} = "${d(s)}"`)}if(e.functions){if(t.push(""),t.push("[functions]"),e.functions.directory)t.push(` directory = "${d(e.functions.directory)}"`);if(e.functions.node_bundler)t.push(` node_bundler = "${e.functions.node_bundler}"`);if(e.functions.external_node_modules&&e.functions.external_node_modules.length>0)t.push(` external_node_modules = [${e.functions.external_node_modules.map((i)=>`"${i}"`).join(", ")}]`)}if(e.edge_functions&&e.edge_functions.length>0){t.push("");for(let i of e.edge_functions)t.push("[[edge_functions]]"),t.push(` function = "${d(i.function)}"`),t.push(` path = "${d(i.path)}"`)}if(e.redirects&&e.redirects.length>0){t.push("");for(let i of e.redirects){if(t.push("[[redirects]]"),t.push(` from = "${d(i.from)}"`),t.push(` to = "${d(i.to)}"`),i.status!==void 0)t.push(` status = ${i.status}`);if(i.force!==void 0)t.push(` force = ${i.force}`);if(i.conditions&&Object.keys(i.conditions).length>0){t.push(" [redirects.conditions]");for(let[s,n]of Object.entries(i.conditions))t.push(` ${s} = "${d(n)}"`)}}}if(e.headers&&e.headers.length>0){t.push("");for(let i of e.headers){t.push("[[headers]]"),t.push(` for = "${d(i.for)}"`),t.push(" [headers.values]");for(let[s,n]of Object.entries(i.values))t.push(` ${s} = "${d(n)}"`)}}if(e.plugins&&e.plugins.length>0){t.push("");for(let i of e.plugins)if(t.push("[[plugins]]"),t.push(` package = "${d(i.package)}"`),i.inputs&&Object.keys(i.inputs).length>0){t.push(" [plugins.inputs]");for(let[s,n]of Object.entries(i.inputs))if(typeof n==="string")t.push(` ${s} = "${d(n)}"`);else if(typeof n==="boolean"||typeof n==="number")t.push(` ${s} = ${n}`)}}if(e.context&&Object.keys(e.context).length>0)for(let[i,s]of Object.entries(e.context)){if(t.push(""),t.push(`[context.${i}]`),s.command)t.push(` command = "${d(s.command)}"`);if(s.publish)t.push(` publish = "${d(s.publish)}"`);if(s.environment&&Object.keys(s.environment).length>0){t.push(` [context.${i}.environment]`);for(let[n,r]of Object.entries(s.environment))t.push(` ${n} = "${d(r)}"`)}}return t.join(`
2
+ import S from"fs";import _ from"path";function $r(e){let{token:t,baseUrl:i="https://api.netlify.com/api/v1"}=e;async function s(n,r,l={}){let p=`${i}${r}`,f={Authorization:`Bearer ${t}`,"User-Agent":"stx-deploy/1.0"},u;if(l.rawBody)f["Content-Type"]=l.contentType||"application/octet-stream",u=l.rawBody;else if(l.body)f["Content-Type"]="application/json",u=JSON.stringify(l.body);let o=await fetch(p,{method:n,headers:f,body:u});if(!o.ok){let g=Error(`Netlify API error: ${o.status} ${o.statusText}`);g.status=o.status;try{let b=await o.json();g.message=b.message||g.message,g.code=b.code,g.details=b}catch{}throw g}let a=await o.text();if(!a)return{};return JSON.parse(a)}return{async getSite(n){return s("GET",`/sites/${n}`)},async listSites(){return s("GET","/sites")},async createSite(n){let r={};if(n)r.name=n;return s("POST","/sites",{body:r})},async createDeploy(n,r){let l={files:r.files,draft:r.draft??!0,async:r.async??!0};if(r.title)l.title=r.title;if(r.branch)l.branch=r.branch;if(r.functions)l.functions=r.functions;return s("POST",`/sites/${n}/deploys`,{body:l})},async uploadFile(n,r,l){let p=r.startsWith("/")?r.slice(1):r;await s("PUT",`/deploys/${n}/files/${p}`,{rawBody:l,contentType:"application/octet-stream"})},async uploadFiles(n,r){let p=[...r],f=async()=>{while(p.length>0){let o=p.shift();if(o)await this.uploadFile(n,o.path,o.content)}},u=Array.from({length:Math.min(5,r.length)},()=>f());await Promise.all(u)},async getDeploy(n){return s("GET",`/deploys/${n}`)},async waitForDeploy(n,r={}){let{timeout:l=300000,pollInterval:p=2000,onProgress:f}=r,u=Date.now();while(!0){let o=await this.getDeploy(n);if(f)f(o);if(o.state==="ready")return o;if(o.state==="error"){let a=Error(`Deploy failed: ${o.error_message||"Unknown error"}`);throw a.status=500,a.details=o,a}if(Date.now()-u>l){let a=Error(`Deploy timed out after ${l}ms`);throw a.status=408,a.details=o,a}await new Promise((a)=>setTimeout(a,p))}},async lockDeploy(n){return s("POST",`/deploys/${n}/lock`)},async unlockDeploy(n){return s("POST",`/deploys/${n}/unlock`)}}}async function lo(e){let t=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(t)).map((s)=>s.toString(16).padStart(2,"0")).join("")}async function Mn(e,t={}){let{ignore:i=["node_modules",".git",".env*","*.map"]}=t,s=[],n=new Bun.Glob("**/*");for await(let r of n.scan({cwd:e,onlyFiles:!0,dot:!1})){if(i.some((a)=>{if(a.includes("*"))return new RegExp(`^${a.replace(/\*/g,".*")}$`).test(r);return r.includes(a)}))continue;let p=`${e}/${r}`,u=await Bun.file(p).arrayBuffer(),o=await lo(u);s.push({path:r,content:new Uint8Array(u),sha1:o})}return s}function Rr(e){let t={};for(let i of e)t[`/${i.path}`]=i.sha1;return t}function Ar(e,t){let i=new Set(t.map((s)=>s.startsWith("/")?s.slice(1):s));return e.filter((s)=>i.has(s.path))}function jt(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;if(e<1073741824)return`${(e/1048576).toFixed(1)} MB`;return`${(e/1073741824).toFixed(1)} GB`}function ft(e){return e.reduce((t,i)=>t+i.content.byteLength,0)}import m from"fs";import y from"path";function uo(e){let t=[];if(t.push("[build]"),t.push(` command = "${d(e.build.command)}"`),t.push(` publish = "${d(e.build.publish)}"`),e.build.functions)t.push(` functions = "${d(e.build.functions)}"`);if(e.build.edge_functions)t.push(` edge_functions = "${d(e.build.edge_functions)}"`);if(e.build.environment&&Object.keys(e.build.environment).length>0){t.push(""),t.push("[build.environment]");for(let[i,s]of Object.entries(e.build.environment))t.push(` ${i} = "${d(s)}"`)}if(e.functions){if(t.push(""),t.push("[functions]"),e.functions.directory)t.push(` directory = "${d(e.functions.directory)}"`);if(e.functions.node_bundler)t.push(` node_bundler = "${e.functions.node_bundler}"`);if(e.functions.external_node_modules&&e.functions.external_node_modules.length>0)t.push(` external_node_modules = [${e.functions.external_node_modules.map((i)=>`"${i}"`).join(", ")}]`)}if(e.edge_functions&&e.edge_functions.length>0){t.push("");for(let i of e.edge_functions)t.push("[[edge_functions]]"),t.push(` function = "${d(i.function)}"`),t.push(` path = "${d(i.path)}"`)}if(e.redirects&&e.redirects.length>0){t.push("");for(let i of e.redirects){if(t.push("[[redirects]]"),t.push(` from = "${d(i.from)}"`),t.push(` to = "${d(i.to)}"`),i.status!==void 0)t.push(` status = ${i.status}`);if(i.force!==void 0)t.push(` force = ${i.force}`);if(i.conditions&&Object.keys(i.conditions).length>0){t.push(" [redirects.conditions]");for(let[s,n]of Object.entries(i.conditions))t.push(` ${s} = "${d(n)}"`)}}}if(e.headers&&e.headers.length>0){t.push("");for(let i of e.headers){t.push("[[headers]]"),t.push(` for = "${d(i.for)}"`),t.push(" [headers.values]");for(let[s,n]of Object.entries(i.values))t.push(` ${s} = "${d(n)}"`)}}if(e.plugins&&e.plugins.length>0){t.push("");for(let i of e.plugins)if(t.push("[[plugins]]"),t.push(` package = "${d(i.package)}"`),i.inputs&&Object.keys(i.inputs).length>0){t.push(" [plugins.inputs]");for(let[s,n]of Object.entries(i.inputs))if(typeof n==="string")t.push(` ${s} = "${d(n)}"`);else if(typeof n==="boolean"||typeof n==="number")t.push(` ${s} = ${n}`)}}if(e.context&&Object.keys(e.context).length>0)for(let[i,s]of Object.entries(e.context)){if(t.push(""),t.push(`[context.${i}]`),s.command)t.push(` command = "${d(s.command)}"`);if(s.publish)t.push(` publish = "${d(s.publish)}"`);if(s.environment&&Object.keys(s.environment).length>0){t.push(` [context.${i}.environment]`);for(let[n,r]of Object.entries(s.environment))t.push(` ${n} = "${d(r)}"`)}}return t.join(`
3
3
  `)+`
4
- `}function d(e){return e.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}async function Nn(e){let t={framework:"stx",buildCommand:"bun run build",outputDir:"dist"},i=y.join(e,"package.json");if(await Bun.file(i).exists())try{let u=JSON.parse(await Bun.file(i).text());if(u.scripts?.build)t.buildCommand="bun run build";let o={...u.dependencies,...u.devDependencies};if(o["@stacksjs/stx"]||o.stx)t.framework="stx"}catch{}let s=y.join(e,"stx.config.ts"),n=y.join(e,".config","stx.config.ts");if(await Bun.file(s).exists()||await Bun.file(n).exists())t.framework="stx";let r=["dist","build","out","public",".output"];for(let u of r){let o=y.join(e,u);if(m.existsSync(o)&&m.statSync(o).isDirectory()){t.outputDir=u;break}}let l=["functions","netlify/functions","api"];for(let u of l){let o=y.join(e,u);if(m.existsSync(o)&&m.statSync(o).isDirectory()){t.functionsDir=u;break}}let p=y.join(e,"netlify","edge-functions");if(m.existsSync(p))t.edgeFunctionsDir="netlify/edge-functions";let f=y.join(e,t.outputDir||"dist");if(m.existsSync(f)){let u=m.existsSync(y.join(f,"index.html")),o=m.readdirSync(f).filter((a)=>a.endsWith(".html"));t.isSPA=u&&o.length===1}return t}function Ln(e={}){let t={build:{command:e.buildCommand||"bun run build",publish:e.outputDir||"dist"}};if(e.functionsDir)t.build.functions=e.functionsDir,t.functions={directory:e.functionsDir,node_bundler:"esbuild"};if(e.edgeFunctionsDir)t.build.edge_functions=e.edgeFunctionsDir;if(t.headers=[{for:"/*",values:{"X-Frame-Options":"DENY","X-Content-Type-Options":"nosniff","X-XSS-Protection":"1; mode=block","Referrer-Policy":"strict-origin-when-cross-origin"}},{for:"/assets/*",values:{"Cache-Control":"public, max-age=31536000, immutable"}}],e.isSPA!==!1)t.redirects=[{from:"/*",to:"/index.html",status:200}];return t.context={production:{environment:{NODE_ENV:"production"}},"deploy-preview":{environment:{NODE_ENV:"development"}}},t}async function Ar(e,t){let i=await Nn(e),s=t||Ln(i),n=uo(s),r=y.join(e,"netlify.toml");return await Bun.write(r,n),r}function Pr(e){return m.existsSync(y.join(e,"netlify.toml"))}async function dl(e={}){let t=Date.now(),i=[],s=e.cwd||process.cwd(),n=(c)=>{i.push(c)},r=(c)=>{if(e.onProgress)e.onProgress(c)},l=_.resolve(s,e.directory||"dist"),p=e.token||process.env.NETLIFY_AUTH_TOKEN,f=e.siteId||process.env.NETLIFY_SITE_ID;if(!p)throw new Ie(`No Netlify auth token found.
4
+ `}function d(e){return e.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}async function Nn(e){let t={framework:"stx",buildCommand:"bun run build",outputDir:"dist"},i=y.join(e,"package.json");if(await Bun.file(i).exists())try{let u=JSON.parse(await Bun.file(i).text());if(u.scripts?.build)t.buildCommand="bun run build";let o={...u.dependencies,...u.devDependencies};if(o["@stacksjs/stx"]||o.stx)t.framework="stx"}catch{}let s=y.join(e,"stx.config.ts"),n=y.join(e,".config","stx.config.ts");if(await Bun.file(s).exists()||await Bun.file(n).exists())t.framework="stx";let r=["dist","build","out","public",".output"];for(let u of r){let o=y.join(e,u);if(m.existsSync(o)&&m.statSync(o).isDirectory()){t.outputDir=u;break}}let l=["functions","netlify/functions","api"];for(let u of l){let o=y.join(e,u);if(m.existsSync(o)&&m.statSync(o).isDirectory()){t.functionsDir=u;break}}let p=y.join(e,"netlify","edge-functions");if(m.existsSync(p))t.edgeFunctionsDir="netlify/edge-functions";let f=y.join(e,t.outputDir||"dist");if(m.existsSync(f)){let u=m.existsSync(y.join(f,"index.html")),o=m.readdirSync(f).filter((a)=>a.endsWith(".html"));t.isSPA=u&&o.length===1}return t}function Ln(e={}){let t={build:{command:e.buildCommand||"bun run build",publish:e.outputDir||"dist"}};if(e.functionsDir)t.build.functions=e.functionsDir,t.functions={directory:e.functionsDir,node_bundler:"esbuild"};if(e.edgeFunctionsDir)t.build.edge_functions=e.edgeFunctionsDir;if(t.headers=[{for:"/*",values:{"X-Frame-Options":"DENY","X-Content-Type-Options":"nosniff","X-XSS-Protection":"1; mode=block","Referrer-Policy":"strict-origin-when-cross-origin"}},{for:"/assets/*",values:{"Cache-Control":"public, max-age=31536000, immutable"}}],e.isSPA!==!1)t.redirects=[{from:"/*",to:"/index.html",status:200}];return t.context={production:{environment:{NODE_ENV:"production"}},"deploy-preview":{environment:{NODE_ENV:"development"}}},t}async function Pr(e,t){let i=await Nn(e),s=t||Ln(i),n=uo(s),r=y.join(e,"netlify.toml");return await Bun.write(r,n),r}function Ir(e){return m.existsSync(y.join(e,"netlify.toml"))}async function ul(e={}){let t=Date.now(),i=[],s=e.cwd||process.cwd(),n=(c)=>{i.push(c)},r=(c)=>{if(e.onProgress)e.onProgress(c)},l=_.resolve(s,e.directory||"dist"),p=e.token||process.env.NETLIFY_AUTH_TOKEN,f=e.siteId||process.env.NETLIFY_SITE_ID;if(!p)throw new Ie(`No Netlify auth token found.
5
5
 
6
6
  To deploy to Netlify:
7
7
  1. Create account at https://app.netlify.com
@@ -19,12 +19,12 @@ Find your site ID at: https://app.netlify.com/sites/YOUR_SITE/settings/general`,
19
19
 
20
20
  Run \`stx build\` first or specify a different directory with --directory`,"NO_BUILD_DIR");if(!(S.readdirSync(l).length>0))throw new Ie(`Build directory is empty: ${l}
21
21
 
22
- Run \`stx build\` to generate files`,"EMPTY_BUILD_DIR");if(e.dryRun){r({stage:"collect",message:"Collecting files..."});let c=await Mn(l),w=ft(c);return n(`Would deploy ${c.length} files (${jt(w)})`),n(`From: ${l}`),n(`To: Site ${f}`),n(`Mode: ${e.production?"production":"draft"}`),{success:!0,url:`https://${f}.netlify.app (dry-run)`,deployId:"dry-run",logs:i,duration:Date.now()-t,filesUploaded:c.length,totalSize:w}}let o=Tr({token:p});r({stage:"collect",message:"Verifying site..."});try{let c=await o.getSite(f);n(`Deploying to: ${c.name} (${c.url})`)}catch(c){if(c.status===404)throw new Ie(`Site not found: ${f}
22
+ Run \`stx build\` to generate files`,"EMPTY_BUILD_DIR");if(e.dryRun){r({stage:"collect",message:"Collecting files..."});let c=await Mn(l),w=ft(c);return n(`Would deploy ${c.length} files (${jt(w)})`),n(`From: ${l}`),n(`To: Site ${f}`),n(`Mode: ${e.production?"production":"draft"}`),{success:!0,url:`https://${f}.netlify.app (dry-run)`,deployId:"dry-run",logs:i,duration:Date.now()-t,filesUploaded:c.length,totalSize:w}}let o=$r({token:p});r({stage:"collect",message:"Verifying site..."});try{let c=await o.getSite(f);n(`Deploying to: ${c.name} (${c.url})`)}catch(c){if(c.status===404)throw new Ie(`Site not found: ${f}
23
23
 
24
- Check your site ID or create a new site at https://app.netlify.com`,"SITE_NOT_FOUND");throw c}r({stage:"collect",message:"Collecting files..."});let a=await Mn(l),g=ft(a);if(n(`Found ${a.length} files (${jt(g)})`),a.length===0)throw new Ie(`No files found in ${l}`,"NO_FILES");let b=$r(a);r({stage:"upload",message:"Creating deploy...",percent:0});let D=await o.createDeploy(f,{title:e.message||"Deploy from stx CLI",draft:!e.production,files:b});n(`Created deploy: ${D.id}`);let h=Rr(a,D.required||[]);if(n(`Uploading ${h.length} files...`),h.length>0){let c=0,w=ft(h);for(let x of h){await o.uploadFile(D.id,x.path,x.content),c++;let C=Math.round(c/h.length*100);r({stage:"upload",message:`Uploading: ${x.path}`,percent:C,details:{uploaded:c,total:h.length}})}n(`Uploaded ${jt(w)}`)}else n("All files already on CDN (no upload needed)");r({stage:"process",message:"Processing deploy..."});let N=await o.waitForDeploy(D.id,{onProgress:(c)=>{r({stage:"process",message:`Status: ${c.state}`,details:c})}}),P=Date.now()-t;if(r({stage:"done",message:"Deploy complete!"}),n(`Deploy complete in ${(P/1000).toFixed(1)}s`),n(`URL: ${N.deploy_ssl_url}`),e.production)n(`Site: ${N.ssl_url}`);if(e.open){let c=e.production?N.ssl_url:N.deploy_ssl_url;I(c)}return{success:!0,url:N.deploy_ssl_url,siteUrl:e.production?N.ssl_url:void 0,deployId:N.id,logs:i,duration:P,filesUploaded:h.length,totalSize:ft(h)}}async function ul(e={}){let t=e.directory||process.cwd(),i;if(Pr(t))i=_.join(t,"netlify.toml");else{let s=await Nn(t);i=await Ar(t,Ln(s))}if(e.siteId){let s=_.join(t,".env.local"),n="";if(await Bun.file(s).exists()){if(n=await Bun.file(s).text(),n=n.split(`
24
+ Check your site ID or create a new site at https://app.netlify.com`,"SITE_NOT_FOUND");throw c}r({stage:"collect",message:"Collecting files..."});let a=await Mn(l),g=ft(a);if(n(`Found ${a.length} files (${jt(g)})`),a.length===0)throw new Ie(`No files found in ${l}`,"NO_FILES");let b=Rr(a);r({stage:"upload",message:"Creating deploy...",percent:0});let D=await o.createDeploy(f,{title:e.message||"Deploy from stx CLI",draft:!e.production,files:b});n(`Created deploy: ${D.id}`);let h=Ar(a,D.required||[]);if(n(`Uploading ${h.length} files...`),h.length>0){let c=0,w=ft(h);for(let x of h){await o.uploadFile(D.id,x.path,x.content),c++;let C=Math.round(c/h.length*100);r({stage:"upload",message:`Uploading: ${x.path}`,percent:C,details:{uploaded:c,total:h.length}})}n(`Uploaded ${jt(w)}`)}else n("All files already on CDN (no upload needed)");r({stage:"process",message:"Processing deploy..."});let N=await o.waitForDeploy(D.id,{onProgress:(c)=>{r({stage:"process",message:`Status: ${c.state}`,details:c})}}),P=Date.now()-t;if(r({stage:"done",message:"Deploy complete!"}),n(`Deploy complete in ${(P/1000).toFixed(1)}s`),n(`URL: ${N.deploy_ssl_url}`),e.production)n(`Site: ${N.ssl_url}`);if(e.open){let c=e.production?N.ssl_url:N.deploy_ssl_url;I(c)}return{success:!0,url:N.deploy_ssl_url,siteUrl:e.production?N.ssl_url:void 0,deployId:N.id,logs:i,duration:P,filesUploaded:h.length,totalSize:ft(h)}}async function dl(e={}){let t=e.directory||process.cwd(),i;if(Ir(t))i=_.join(t,"netlify.toml");else{let s=await Nn(t);i=await Pr(t,Ln(s))}if(e.siteId){let s=_.join(t,".env.local"),n="";if(await Bun.file(s).exists()){if(n=await Bun.file(s).text(),n=n.split(`
25
25
  `).filter((r)=>!r.startsWith("NETLIFY_SITE_ID=")).join(`
26
26
  `),n&&!n.endsWith(`
27
27
  `))n+=`
28
28
  `}n+=`NETLIFY_SITE_ID=${e.siteId}
29
29
  `,await Bun.write(s,n)}return{configPath:i,siteId:e.siteId}}class Ie extends Error{code;constructor(e,t){super(e);this.name="DeployError",this.code=t}}function I(e){let t=process.platform,i=t==="darwin"?"open":t==="win32"?"start":"xdg-open";Bun.spawn([i,e],{stdio:["ignore","ignore","ignore"]})}
30
- export{Tr,lo,Mn,$r,Rr,jt,ft,uo,Nn,Ln,Ar,Pr,dl,ul,Ie};
30
+ export{$r,lo,Mn,Rr,Ar,jt,ft,uo,Nn,Ln,Pr,Ir,ul,dl,Ie};