@stacksjs/stx 0.2.428 → 0.2.430

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/dist/{chunk-m9m03bcp.js → chunk-00h762q8.js} +1 -1
  2. package/dist/{chunk-prgv92bc.js → chunk-0hd9xzf2.js} +1 -1
  3. package/dist/{chunk-y5b468c3.js → chunk-0sg48cd0.js} +1 -1
  4. package/dist/{chunk-awg10gdf.js → chunk-1gqd0mdg.js} +1 -1
  5. package/dist/chunk-1qf3wc23.js +2 -0
  6. package/dist/chunk-1sqf2vvk.js +2 -0
  7. package/dist/{chunk-xs68rj51.js → chunk-21rqr54j.js} +2 -2
  8. package/dist/chunk-2mzy3z72.js +2 -0
  9. package/dist/chunk-35qj567j.js +2 -0
  10. package/dist/chunk-386zrhbf.js +2 -0
  11. package/dist/chunk-3hv5ggdq.js +2 -0
  12. package/dist/chunk-4fqtfhv2.js +2 -0
  13. package/dist/chunk-4rvwz6jn.js +2 -0
  14. package/dist/{chunk-t3wh1jbk.js → chunk-4wf68rht.js} +3 -3
  15. package/dist/{chunk-8a0r2j8f.js → chunk-4xemkkm8.js} +2 -2
  16. package/dist/chunk-513vzzf5.js +2 -0
  17. package/dist/{chunk-89b2r1q0.js → chunk-5f0r0g18.js} +2 -2
  18. package/dist/chunk-5f6nfpm7.js +2 -0
  19. package/dist/chunk-67r98kff.js +2 -0
  20. package/dist/{chunk-v6hjn4xn.js → chunk-6gnza26n.js} +1 -1
  21. package/dist/chunk-6wynj5pv.js +2 -0
  22. package/dist/{chunk-ckew8xkb.js → chunk-718avy9p.js} +1 -1
  23. package/dist/{chunk-pnrtj8xp.js → chunk-78ac2603.js} +1 -1
  24. package/dist/chunk-7gsdrmh1.js +2 -0
  25. package/dist/{chunk-4ya53yrh.js → chunk-84gsk8fk.js} +1 -1
  26. package/dist/{chunk-m2xk6a2p.js → chunk-85pvq4a2.js} +1 -1
  27. package/dist/chunk-8f39se4k.js +2 -0
  28. package/dist/{chunk-t1b2kzhn.js → chunk-98hj1mvn.js} +1 -1
  29. package/dist/{chunk-vfk725vm.js → chunk-bjnvymb7.js} +2 -2
  30. package/dist/{chunk-a8g6y9kw.js → chunk-c0ants8t.js} +4 -4
  31. package/dist/{chunk-dyhb8ey9.js → chunk-cr3f21mg.js} +1 -1
  32. package/dist/{chunk-n5gwwjch.js → chunk-d50dn3jp.js} +1 -1
  33. package/dist/chunk-db6sq3d2.js +2 -0
  34. package/dist/{chunk-mg7jhx5v.js → chunk-djdf6agj.js} +1 -1
  35. package/dist/{chunk-frvfpmes.js → chunk-e1vsbjtw.js} +2 -2
  36. package/dist/{chunk-hvme6tw2.js → chunk-e6j0tynb.js} +1 -1
  37. package/dist/{chunk-k3ths2yp.js → chunk-f3dk4y9n.js} +41 -41
  38. package/dist/{chunk-jbrdebzs.js → chunk-fb7bfyjz.js} +2 -2
  39. package/dist/{chunk-5qmj2aq7.js → chunk-gc0w2cx7.js} +3 -3
  40. package/dist/chunk-h03hamnb.js +2 -0
  41. package/dist/chunk-h3anf0qz.js +2 -0
  42. package/dist/{chunk-9v3zrsfy.js → chunk-h873ye0z.js} +2 -2
  43. package/dist/{chunk-thdbqsxq.js → chunk-hnx1jgfp.js} +1 -1
  44. package/dist/{chunk-5562x3jp.js → chunk-hr5db6bk.js} +1 -1
  45. package/dist/{chunk-xdjevnv6.js → chunk-hxn9gk7h.js} +82 -73
  46. package/dist/{chunk-wdxct95c.js → chunk-je7ymnck.js} +1 -1
  47. package/dist/{chunk-mevm81je.js → chunk-jeand25b.js} +1 -1
  48. package/dist/{chunk-60ment0t.js → chunk-jkks9x5g.js} +3 -3
  49. package/dist/{chunk-rb0v8enr.js → chunk-jp602m75.js} +1 -1
  50. package/dist/{chunk-qh7kx90q.js → chunk-jv9gvzvy.js} +1 -1
  51. package/dist/{chunk-k7m5f5mx.js → chunk-k0v70ttf.js} +1 -1
  52. package/dist/{chunk-2x9jd5w0.js → chunk-ktedzx9e.js} +1 -1
  53. package/dist/chunk-mdr0sr41.js +2 -0
  54. package/dist/{chunk-48kgnqpk.js → chunk-mjgqhhap.js} +3 -3
  55. package/dist/chunk-mkzxhfae.js +2 -0
  56. package/dist/{chunk-0yv4gk8g.js → chunk-n4203761.js} +1 -1
  57. package/dist/{chunk-pcfdd3jv.js → chunk-n58q81vv.js} +1 -1
  58. package/dist/chunk-n7nvj7dk.js +2 -0
  59. package/dist/{chunk-w1s1hhrg.js → chunk-pdp961ge.js} +1 -1
  60. package/dist/{chunk-62chbqev.js → chunk-rnbgn7xn.js} +1 -1
  61. package/dist/{chunk-26gfsa9w.js → chunk-rnjkfhh0.js} +1 -1
  62. package/dist/{chunk-1p8hc1ve.js → chunk-rqfhknzj.js} +1 -1
  63. package/dist/{chunk-wgas6fb9.js → chunk-veqtn1rd.js} +1 -1
  64. package/dist/{chunk-9wbt987t.js → chunk-vpz0t82q.js} +1 -1
  65. package/dist/{chunk-yaebdyfr.js → chunk-w3j0ppg4.js} +2 -2
  66. package/dist/{chunk-s295vp9x.js → chunk-wr9ac0cv.js} +2 -2
  67. package/dist/{chunk-6jgjmycb.js → chunk-x38d7mvy.js} +1 -1
  68. package/dist/{chunk-ptjqacjd.js → chunk-y438dzvn.js} +2 -2
  69. package/dist/chunk-z21mv6bz.js +2 -0
  70. package/dist/{chunk-k1bm8hsv.js → chunk-z52txevf.js} +1 -1
  71. package/dist/cli.js +10 -10
  72. package/dist/craft-entry.js +2 -2
  73. package/dist/craft.js +2 -2
  74. package/dist/index.d.ts +1 -0
  75. package/dist/index.js +1 -0
  76. package/dist/pwa.js +1 -1
  77. package/dist/ssg.js +2 -2
  78. package/dist/utils.js +10 -1
  79. package/package.json +5 -5
  80. package/dist/chunk-0wwpej8f.js +0 -2
  81. package/dist/chunk-18c2va7t.js +0 -2
  82. package/dist/chunk-1ey2myy4.js +0 -2
  83. package/dist/chunk-5mfhk69g.js +0 -2
  84. package/dist/chunk-8ghw6h48.js +0 -2
  85. package/dist/chunk-9gmyvvry.js +0 -2
  86. package/dist/chunk-9j72har9.js +0 -2
  87. package/dist/chunk-cm1vzy7d.js +0 -2
  88. package/dist/chunk-cnmz9543.js +0 -2
  89. package/dist/chunk-e06jpx5x.js +0 -2
  90. package/dist/chunk-e90n9tzp.js +0 -2
  91. package/dist/chunk-gfpk07wd.js +0 -2
  92. package/dist/chunk-k8grzx71.js +0 -2
  93. package/dist/chunk-ncrcacdr.js +0 -2
  94. package/dist/chunk-nsta4z55.js +0 -2
  95. package/dist/chunk-phvxs54d.js +0 -2
  96. package/dist/chunk-r3sj53m1.js +0 -2
  97. package/dist/chunk-t8kadtva.js +0 -2
  98. package/dist/chunk-wr78aadr.js +0 -2
  99. package/dist/chunk-y9epxz9w.js +0 -2
  100. package/dist/chunk-zsc4qb0g.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./chunk-yaebdyfr.js";import"./chunk-axydabse.js";import{y,I,O,N}from"./chunk-xdjevnv6.js";import"./chunk-89b2r1q0.js";import"./chunk-3ry9ca1s.js";import"./chunk-12pvnn1e.js";import"./chunk-48kgnqpk.js";import"./chunk-jbrdebzs.js";import"./chunk-k8sqs7j2.js";import"./chunk-ptjqacjd.js";import"./chunk-pcfdd3jv.js";import"./chunk-b7973zvk.js";import"./chunk-2x9jd5w0.js";import f from"path";var b=["applyOfflineUpdate","broadcast","cacheMedia","calculateDistance","canNotify","clearCookies","clearFetchCache","clearOfflineData","clearStorage","copyToClipboard","createShareableFile","defineForm","getBatteryLevel","getCookie","getCurrentPosition","getStorageKeys","getStorageSize","getVoices","hasBattery","hasCameraPermission","hasGeolocationPermission","hasMicrophonePermission","hasNotificationPermission","hasResizeObserver","hexToHsl","hexToRgb","isBroadcastChannelSupported","isCharging","isDeviceMotionSupported","isDeviceOrientationSupported","isEventSourceSupported","isEyeDropperSupported","isInFullscreen","isMutationObserverSupported","isPermissionGranted","isSpeechRecognitionSupported","isSpeechSynthesisSupported","isWakeLockSupported","isWebSocketSupported","notify","onOfflineUpdateReady","parseCookies","pickColor","prefetch","removeCookie","requestMediaPermissions","requestMotionPermission","requestNotificationPermission","requestOrientationPermission","setCookie","share","shareCurrentPage","shareFiles","shareText","shareURL","shareWithFallback","speak","stopSpeaking","toggleFullscreen","useAsyncData","useAttributeObserver","useAutoLogout","useAutoWakeLock","useBattery","useBreakpoint","useBroadcastChannel","useChannel","useChildListObserver","useClipboard","useColorHistory","useConditionalWakeLock","useCookies","useCopySelection","useDeviceMotion","useDeviceOrientation","useElementSize","useElementTextSelection","useElementVisibility","useEventSource","useEyeDropper","useFavicon","useForm","useFullscreen","useGeolocation","useGeolocationWatch","useHotkey","useIdle","useIdleState","useInfiniteScroll","useIntersectionObserver","useIntersectionObserverMultiple","useIsDesktop","useIsMobile","useIsTablet","useKeyPressed","useKeySequence","useKeyboard","useLastActive","useLazyLoad","useMeta","useMouse","useMouseInElement","useMutationObserver","useNetwork","useNotification","useOnline","useOutbox","useParallax","usePermission","usePermissions","usePointer","usePost","useResizeObserver","useResizeObserverMultiple","useSSE","useScroll","useSelectionPopup","useShare","useSpeechRecognition","useSpeechSynthesis","useStorage","useTextObserver","useTextSelection","useTitle","useVisibility","useWakeLock","useWindowSize"],L=new Set(b);var l=new Map,h=I(64),S=new Set,v=0,E=new Set(b);function W(){l.clear(),h.clear()}function R(o){let n=new Map;for(let r of o){let a=f.basename(r);if(a.endsWith(".d.ts"))continue;let t=a.replace(/\.[jt]s$/,"");if(t==="index")continue;if(t===a)continue;let i=n.get(t);if(i&&!i.endsWith(".js"))continue;n.set(t,r)}return[...n.values()].sort()}function P(o,n){let r=n.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(?:^|[^\\w$.])(?:const|let|var|function|class)\\s+${r}\\b`).test(o)}function M(o){if(!o)return[];let n=O(o,v),r=h.get(n);if(r)return r.slice();let a=o.replace(/<script\b[^>]*\bdata-stx-runtime\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-framework-composables\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-stores\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-composables\b[^>]*>[\s\S]*?<\/script>/gi,""),t=[];for(let i of E){if(S.has(i))continue;let u=i.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");if(new RegExp(`(^|[^\\w$.])${u}\\s*\\(`).test(a))t.push(i)}return t.sort(),h.set(n,t),t.slice()}async function U(o,n){let r=M(o);if(r.length===0)return null;let a=n??f.join(import.meta.dir,"composables"),t=`${a}\x00${r.join(",")}`,i=l.get(t);if(i!==void 0)return i||null;let u=N({loader:"ts",target:"browser",define:y()}),k=new Set(r),m=[],d=new Set,p=[];try{let s=new Bun.Glob("*.{ts,js}");for await(let e of s.scan({cwd:a,absolute:!0}))p.push(e)}catch{return l.set(t,""),null}p=R(p);for(let s of p){let e;try{e=await Bun.file(s).text()}catch{continue}let g=[];try{g=u.scan(e).exports.filter((c)=>c!=="default")}catch{continue}if(!g.some((c)=>k.has(c)))continue;try{e=e.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^import\s+type\s+.*$/gm,""),e=e.replace(/^export\s+\*\s+(?:as\s+\w+\s+)?from\s*['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^export\s+(?:type\s+)?\{[\s\S]*?\}\s*(?:from\s*['"][^'"]+['"]\s*)?;?\s*$/gm,""),e=e.replace(/^export\s+default\s+/gm,""),e=e.replace(/^export\s+(?=(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\b)/gm,""),m.push(`// ${f.basename(s).replace(/\.[jt]s$/,"")}
2
+ import"./chunk-w3j0ppg4.js";import"./chunk-axydabse.js";import{y,I,O,N}from"./chunk-hxn9gk7h.js";import"./chunk-5f0r0g18.js";import"./chunk-3ry9ca1s.js";import"./chunk-12pvnn1e.js";import"./chunk-mjgqhhap.js";import"./chunk-fb7bfyjz.js";import"./chunk-k8sqs7j2.js";import"./chunk-y438dzvn.js";import"./chunk-n58q81vv.js";import"./chunk-b7973zvk.js";import"./chunk-ktedzx9e.js";import f from"path";var b=["applyOfflineUpdate","broadcast","cacheMedia","calculateDistance","canNotify","clearCookies","clearFetchCache","clearOfflineData","clearStorage","copyToClipboard","createShareableFile","defineForm","getBatteryLevel","getCookie","getCurrentPosition","getStorageKeys","getStorageSize","getVoices","hasBattery","hasCameraPermission","hasGeolocationPermission","hasMicrophonePermission","hasNotificationPermission","hasResizeObserver","hexToHsl","hexToRgb","isBroadcastChannelSupported","isCharging","isDeviceMotionSupported","isDeviceOrientationSupported","isEventSourceSupported","isEyeDropperSupported","isInFullscreen","isMutationObserverSupported","isPermissionGranted","isSpeechRecognitionSupported","isSpeechSynthesisSupported","isWakeLockSupported","isWebSocketSupported","notify","onOfflineUpdateReady","parseCookies","pickColor","prefetch","removeCookie","requestMediaPermissions","requestMotionPermission","requestNotificationPermission","requestOrientationPermission","setCookie","share","shareCurrentPage","shareFiles","shareText","shareURL","shareWithFallback","speak","stopSpeaking","toggleFullscreen","useAsyncData","useAttributeObserver","useAutoLogout","useAutoWakeLock","useBattery","useBreakpoint","useBroadcastChannel","useChannel","useChildListObserver","useClipboard","useColorHistory","useConditionalWakeLock","useCookies","useCopySelection","useDeviceMotion","useDeviceOrientation","useElementSize","useElementTextSelection","useElementVisibility","useEventSource","useEyeDropper","useFavicon","useForm","useFullscreen","useGeolocation","useGeolocationWatch","useHotkey","useIdle","useIdleState","useInfiniteScroll","useIntersectionObserver","useIntersectionObserverMultiple","useIsDesktop","useIsMobile","useIsTablet","useKeyPressed","useKeySequence","useKeyboard","useLastActive","useLazyLoad","useMeta","useMouse","useMouseInElement","useMutationObserver","useNetwork","useNotification","useOnline","useOutbox","useParallax","usePermission","usePermissions","usePointer","usePost","useResizeObserver","useResizeObserverMultiple","useSSE","useScroll","useSelectionPopup","useShare","useSpeechRecognition","useSpeechSynthesis","useStorage","useTextObserver","useTextSelection","useTitle","useVisibility","useWakeLock","useWindowSize"],L=new Set(b);var l=new Map,h=I(64),S=new Set,v=0,E=new Set(b);function W(){l.clear(),h.clear()}function R(o){let n=new Map;for(let r of o){let a=f.basename(r);if(a.endsWith(".d.ts"))continue;let t=a.replace(/\.[jt]s$/,"");if(t==="index")continue;if(t===a)continue;let i=n.get(t);if(i&&!i.endsWith(".js"))continue;n.set(t,r)}return[...n.values()].sort()}function P(o,n){let r=n.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(?:^|[^\\w$.])(?:const|let|var|function|class)\\s+${r}\\b`).test(o)}function M(o){if(!o)return[];let n=O(o,v),r=h.get(n);if(r)return r.slice();let a=o.replace(/<script\b[^>]*\bdata-stx-runtime\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-framework-composables\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-stores\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-composables\b[^>]*>[\s\S]*?<\/script>/gi,""),t=[];for(let i of E){if(S.has(i))continue;let u=i.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");if(new RegExp(`(^|[^\\w$.])${u}\\s*\\(`).test(a))t.push(i)}return t.sort(),h.set(n,t),t.slice()}async function U(o,n){let r=M(o);if(r.length===0)return null;let a=n??f.join(import.meta.dir,"composables"),t=`${a}\x00${r.join(",")}`,i=l.get(t);if(i!==void 0)return i||null;let u=N({loader:"ts",target:"browser",define:y()}),k=new Set(r),m=[],d=new Set,p=[];try{let s=new Bun.Glob("*.{ts,js}");for await(let e of s.scan({cwd:a,absolute:!0}))p.push(e)}catch{return l.set(t,""),null}p=R(p);for(let s of p){let e;try{e=await Bun.file(s).text()}catch{continue}let g=[];try{g=u.scan(e).exports.filter((c)=>c!=="default")}catch{continue}if(!g.some((c)=>k.has(c)))continue;try{e=e.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^import\s+type\s+.*$/gm,""),e=e.replace(/^export\s+\*\s+(?:as\s+\w+\s+)?from\s*['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^export\s+(?:type\s+)?\{[\s\S]*?\}\s*(?:from\s*['"][^'"]+['"]\s*)?;?\s*$/gm,""),e=e.replace(/^export\s+default\s+/gm,""),e=e.replace(/^export\s+(?=(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\b)/gm,""),m.push(`// ${f.basename(s).replace(/\.[jt]s$/,"")}
3
3
  ${u.transformSync(e).trim()}`);for(let c of g)d.add(c)}catch(c){console.warn(`[stx] framework composable ${f.basename(s)} could not be bundled:`,c)}}let w=r.filter((s)=>!d.has(s)&&!P(o,s));if(w.length>0)console.warn(`[stx] could not bundle ${w.join(", ")} from @stacksjs/stx/composables \u2014 `+"calls to them will throw ReferenceError in the browser. Import them explicitly so the bundler inlines them, or use a runtime equivalent from window.stx.");if(m.length===0)return l.set(t,""),null;let C=[...d].map((s)=>` try { if (!(${JSON.stringify(s)} in __s)) { __s[${JSON.stringify(s)}] = ${s}; if (!(${JSON.stringify(s)} in window)) window[${JSON.stringify(s)}] = ${s}; } } catch (e) {}`).join(`
4
4
  `),x=`<script data-stx-framework-composables>
5
5
  ;(function(){
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- function m(e,t={}){return{enterFrom:t.enterClass||`${e}-enter-from`,enterActive:t.enterActiveClass||`${e}-enter-active`,enterTo:t.enterToClass||`${e}-enter-to`,leaveFrom:t.leaveClass||`${e}-leave-from`,leaveActive:t.leaveActiveClass||`${e}-leave-active`,leaveTo:t.leaveToClass||`${e}-leave-to`}}function u(e){let t=getComputedStyle(e),o=t.transitionDuration||"0s",n=t.animationDuration||"0s",s=(a)=>{let i=a.match(/^([\d.]+)(s|ms)?$/);if(!i)return 0;let r=parseFloat(i[1]);return(i[2]||"s")==="ms"?r:r*1000};return Math.max(s(o),s(n))}function v(e,t){return new Promise((o)=>{let n=t??u(e);if(n===0){o();return}let s=!1,a=()=>{if(s)return;s=!0,e.removeEventListener("transitionend",i),e.removeEventListener("animationend",i),o()},i=(r)=>{if(r.target===e)a()};e.addEventListener("transitionend",i),e.addEventListener("animationend",i),setTimeout(a,n+50)})}function f(e){e.offsetHeight}async function wl(e,t={}){let o=t.name||"stx",n=m(o,t),s=typeof t.duration==="object"?t.duration.enter:t.duration;if(t.onBeforeEnter?.(e),e.classList.add(n.enterFrom),e.classList.add(n.enterActive),f(e),e.classList.remove(n.enterFrom),e.classList.add(n.enterTo),t.onEnter)await new Promise((a)=>{t.onEnter(e,a)});else await v(e,s);e.classList.remove(n.enterActive),e.classList.remove(n.enterTo),t.onAfterEnter?.(e)}async function xl(e,t={}){let o=t.name||"stx",n=m(o,t),s=typeof t.duration==="object"?t.duration.leave:t.duration;if(t.onBeforeLeave?.(e),e.classList.add(n.leaveFrom),e.classList.add(n.leaveActive),f(e),e.classList.remove(n.leaveFrom),e.classList.add(n.leaveTo),t.onLeave)await new Promise((a)=>{t.onLeave(e,a)});else await v(e,s);e.classList.remove(n.leaveActive),e.classList.remove(n.leaveTo),t.onAfterLeave?.(e)}function Sl(e,t={},o){let n=/@transition\s*\(([^)]*)\)([\s\S]*?)@endtransition/gi;return e.replace(n,(s,a,i)=>{let r=p(a),l=r.name||"stx",c=r.duration||300,d=`stx-transition-${Math.random().toString(36).slice(2,9)}`;return`
2
+ function m(e,t={}){return{enterFrom:t.enterClass||`${e}-enter-from`,enterActive:t.enterActiveClass||`${e}-enter-active`,enterTo:t.enterToClass||`${e}-enter-to`,leaveFrom:t.leaveClass||`${e}-leave-from`,leaveActive:t.leaveActiveClass||`${e}-leave-active`,leaveTo:t.leaveToClass||`${e}-leave-to`}}function u(e){let t=getComputedStyle(e),o=t.transitionDuration||"0s",n=t.animationDuration||"0s",s=(a)=>{let i=a.match(/^([\d.]+)(s|ms)?$/);if(!i)return 0;let r=parseFloat(i[1]);return(i[2]||"s")==="ms"?r:r*1000};return Math.max(s(o),s(n))}function v(e,t){return new Promise((o)=>{let n=t??u(e);if(n===0){o();return}let s=!1,a=()=>{if(s)return;s=!0,e.removeEventListener("transitionend",i),e.removeEventListener("animationend",i),o()},i=(r)=>{if(r.target===e)a()};e.addEventListener("transitionend",i),e.addEventListener("animationend",i),setTimeout(a,n+50)})}function f(e){e.offsetHeight}async function vl(e,t={}){let o=t.name||"stx",n=m(o,t),s=typeof t.duration==="object"?t.duration.enter:t.duration;if(t.onBeforeEnter?.(e),e.classList.add(n.enterFrom),e.classList.add(n.enterActive),f(e),e.classList.remove(n.enterFrom),e.classList.add(n.enterTo),t.onEnter)await new Promise((a)=>{t.onEnter(e,a)});else await v(e,s);e.classList.remove(n.enterActive),e.classList.remove(n.enterTo),t.onAfterEnter?.(e)}async function xl(e,t={}){let o=t.name||"stx",n=m(o,t),s=typeof t.duration==="object"?t.duration.leave:t.duration;if(t.onBeforeLeave?.(e),e.classList.add(n.leaveFrom),e.classList.add(n.leaveActive),f(e),e.classList.remove(n.leaveFrom),e.classList.add(n.leaveTo),t.onLeave)await new Promise((a)=>{t.onLeave(e,a)});else await v(e,s);e.classList.remove(n.leaveActive),e.classList.remove(n.leaveTo),t.onAfterLeave?.(e)}function Sl(e,t={},o){let n=/@transition\s*\(([^)]*)\)([\s\S]*?)@endtransition/gi;return e.replace(n,(s,a,i)=>{let r=p(a),l=r.name||"stx",c=r.duration||300,d=`stx-transition-${Math.random().toString(36).slice(2,9)}`;return`
3
3
  <div
4
4
  class="stx-transition-wrapper"
5
5
  data-transition="${l}"
@@ -318,4 +318,4 @@ else {
318
318
  console.log('[stx] Transition runtime initialized');
319
319
  })();
320
320
  `}function $l(e){let t=/@transition\.([a-z-]+)(?:\.(\d+))?="([^"]+)"/gi;return e.replace(t,(o,n,s,a)=>{let i=s||"300",r=`stx-t-${Math.random().toString(36).slice(2,7)}`;return`data-stx-transition="${n}" data-stx-transition-duration="${i}" data-stx-transition-condition="${a}" data-stx-transition-id="${r}"`})}
321
- export{wl,xl,Sl,kl,Cl,$l};
321
+ export{vl,xl,Sl,kl,Cl,$l};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import S from"fs";import _ from"path";function gr(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 qs(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 wn(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 qs(u);s.push({path:r,content:new Uint8Array(u),sha1:o})}return s}function mr(e){let t={};for(let i of e)t[`/${i.path}`]=i.sha1;return t}function hr(e,t){let i=new Set(t.map((s)=>s.startsWith("/")?s.slice(1):s));return e.filter((s)=>i.has(s.path))}function Rt(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 lt(e){return e.reduce((t,i)=>t+i.content.byteLength,0)}import m from"fs";import y from"path";function Ks(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 gr(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 qs(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 vn(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 qs(u);s.push({path:r,content:new Uint8Array(u),sha1:o})}return s}function mr(e){let t={};for(let i of e)t[`/${i.path}`]=i.sha1;return t}function hr(e,t){let i=new Set(t.map((s)=>s.startsWith("/")?s.slice(1):s));return e.filter((s)=>i.has(s.path))}function Rt(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 lt(e){return e.reduce((t,i)=>t+i.content.byteLength,0)}import m from"fs";import y from"path";function Ks(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
4
  `}function d(e){return e.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}async function xn(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 Sn(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 yr(e,t){let i=await xn(e),s=t||Sn(i),n=Ks(s),r=y.join(e,"netlify.toml");return await Bun.write(r,n),r}function br(e){return m.existsSync(y.join(e,"netlify.toml"))}async function Bc(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 Te(`No Netlify auth token found.
5
5
 
@@ -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 Te(`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 wn(l),w=lt(c);return n(`Would deploy ${c.length} files (${Rt(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=gr({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 Te(`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 vn(l),w=lt(c);return n(`Would deploy ${c.length} files (${Rt(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=gr({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 Te(`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 wn(l),g=lt(a);if(n(`Found ${a.length} files (${Rt(g)})`),a.length===0)throw new Te(`No files found in ${l}`,"NO_FILES");let b=mr(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=hr(a,D.required||[]);if(n(`Uploading ${h.length} files...`),h.length>0){let c=0,w=lt(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 ${Rt(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:lt(h)}}async function Fc(e={}){let t=e.directory||process.cwd(),i;if(br(t))i=_.join(t,"netlify.toml");else{let s=await xn(t);i=await yr(t,Sn(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 vn(l),g=lt(a);if(n(`Found ${a.length} files (${Rt(g)})`),a.length===0)throw new Te(`No files found in ${l}`,"NO_FILES");let b=mr(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=hr(a,D.required||[]);if(n(`Uploading ${h.length} files...`),h.length>0){let c=0,w=lt(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 ${Rt(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:lt(h)}}async function Fc(e={}){let t=e.directory||process.cwd(),i;if(br(t))i=_.join(t,"netlify.toml");else{let s=await xn(t);i=await yr(t,Sn(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 Te 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{gr,qs,wn,mr,hr,Rt,lt,Ks,xn,Sn,yr,br,Bc,Fc,Te};
30
+ export{gr,qs,vn,mr,hr,Rt,lt,Ks,xn,Sn,yr,br,Bc,Fc,Te};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Jl,fi,$a,Yl,Zl,Ql,eu,tu,Ea,Ta,nu,ru,su,iu}from"./chunk-0yv4gk8g.js";import"./chunk-xdjevnv6.js";import"./chunk-2x9jd5w0.js";import"./chunk-3ry9ca1s.js";import"./chunk-k8sqs7j2.js";import"./chunk-pcfdd3jv.js";import"./chunk-ptjqacjd.js";import"./chunk-jbrdebzs.js";import"./chunk-48kgnqpk.js";import"./chunk-89b2r1q0.js";import"./chunk-axydabse.js";import"./chunk-yaebdyfr.js";import"./chunk-12pvnn1e.js";import"./chunk-b7973zvk.js";export{$a as SUSPENSE_RESOLVER_RUNTIME,fi as buildSuspenseResolveScript,tu as createStreamRenderer,Ql as extractStreamBoundaries,iu as generateHydrationRuntime,Ta as islandDirective,ru as processSectionDirectives,Zl as processStreamDirectives,nu as registerStreamingDirectives,Yl as renderStreamingPage,Jl as streamTemplate,eu as streamTemplateSimple,su as streamToResponse,Ea as streamingSuspenseDirective};
2
+ import{Jl,fi,$a,Yl,Zl,Ql,eu,tu,Ea,Ta,nu,ru,su,iu}from"./chunk-n4203761.js";import"./chunk-hxn9gk7h.js";import"./chunk-ktedzx9e.js";import"./chunk-3ry9ca1s.js";import"./chunk-k8sqs7j2.js";import"./chunk-n58q81vv.js";import"./chunk-y438dzvn.js";import"./chunk-fb7bfyjz.js";import"./chunk-mjgqhhap.js";import"./chunk-5f0r0g18.js";import"./chunk-axydabse.js";import"./chunk-w3j0ppg4.js";import"./chunk-12pvnn1e.js";import"./chunk-b7973zvk.js";export{$a as SUSPENSE_RESOLVER_RUNTIME,fi as buildSuspenseResolveScript,tu as createStreamRenderer,Ql as extractStreamBoundaries,iu as generateHydrationRuntime,Ta as islandDirective,ru as processSectionDirectives,Zl as processStreamDirectives,nu as registerStreamingDirectives,Yl as renderStreamingPage,Jl as streamTemplate,eu as streamTemplateSimple,su as streamToResponse,Ea as streamingSuspenseDirective};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{V,ae}from"./chunk-xdjevnv6.js";import{le,S,Ke}from"./chunk-ptjqacjd.js";import{Ze,X,xe}from"./chunk-12pvnn1e.js";import{_e,ne,C,re,ii,wr,oi,Pt}from"./chunk-5qmj2aq7.js";import{Hr}from"./chunk-xs68rj51.js";import{It}from"./chunk-8zf5q1m3.js";import H from"zlib";import{promisify as Y}from"util";var Q=Y(H.brotliCompress),Z=Y(H.gzip),K=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ee=["text/event-stream","multipart/x-mixed-replace"],te=1024;function se(t){if(!t)return!1;let e=t.toLowerCase();if(ee.some((i)=>e.startsWith(i)))return!1;return K.some((i)=>e.startsWith(i))}function oe(t){let e=new Map;for(let i of t.split(",")){let[s,...c]=i.trim().split(";"),l=s.trim().toLowerCase();if(!l)continue;let m=1;for(let f of c){let x=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(f);if(!x)continue;let g=Number.parseFloat(x[1]);if(Number.isFinite(g))m=g}e.set(l,m)}return e}function ie(t){if(!t)return null;let e=oe(t),i=e.get("*"),s=(c)=>e.get(c)??i??0;if(s("br")>0)return"br";if(s("gzip")>0)return"gzip";return null}async function At(t,e,i={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!se(e.headers.get("content-type")))return e;let s=ie(t.headers.get("accept-encoding"));if(!s)return e;let c;try{c=new Uint8Array(await e.arrayBuffer())}catch{return e}let l=()=>new Response(c,{status:e.status,statusText:e.statusText,headers:q(e.headers)});if(c.length<(i.threshold??te))return l();try{let m=s==="br"?await Q(c,{params:{[H.constants.BROTLI_PARAM_QUALITY]:i.quality??5,[H.constants.BROTLI_PARAM_SIZE_HINT]:c.length}}):await Z(c);if(m.length>=c.length)return l();let f=q(e.headers);return f.set("Content-Encoding",s),f.set("Content-Length",String(m.length)),new Response(m,{status:e.status,statusText:e.statusText,headers:f})}catch{return l()}}function q(t){let e=new Headers(t),i=e.get("Vary");if(!i)return e.set("Vary","Accept-Encoding"),e;if(!i.split(",").some((c)=>c.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${i}, Accept-Encoding`);return e}import J from"fs";import M from"path";var{serve:ce}=globalThis.Bun;class G{now;entries=new V(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,i){let s,c=async()=>{let r=s??await i();return r.headers.set("Cache-Control","private, no-store"),r.headers.set("Vary",C(r.headers.get("Vary")).Vary),r};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return c();let l=new URL(t.url),m=`${l.origin}${l.pathname}${l.search}|${ne(t)?"fragment":"document"}`,f=this.entries.get(m),x=(r)=>{let T=new Headers(r.headers);return T.set("Cache-Control","private, no-store"),T.set("Age",String(Math.max(0,Math.floor((this.now()-r.created)/1000)))),new Response(r.body.slice(0),{headers:T})},g=f?(this.now()-f.created)/1000:1/0;if(f&&g<e.maxAge)return x(f);let b=this.generation,O=async()=>{let r=await i();s=r;let T=(r.headers.get("Vary")??"").toLowerCase().split(",").map((R)=>R.trim()).filter(Boolean);if(r.status!==200||r.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(r.headers.get("Cache-Control")??"")||T.some((R)=>R!=="x-stx-router"&&R!=="accept-encoding"))return null;let L=await r.clone().arrayBuffer();if(L.byteLength>1048576)return null;r.headers.set("Vary",C(r.headers.get("Vary")).Vary);let n={body:L,headers:Array.from(r.headers.entries()),created:this.now(),path:l.pathname};if(this.generation===b)this.entries.set(m,n);return n},v=this.pending.get(m);if(!v){if(this.pending.size>=1000)return c();v=O().finally(()=>{if(this.pending.get(m)===v)this.pending.delete(m)}),this.pending.set(m,v)}if(f&&g<e.maxAge+(e.swr??0))return v.catch(()=>{}),x(f);let E=await v;return E?x(E):c()}}var pe={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function ol(t={}){let e=M.resolve(t.outputDir||".output"),i=t.port??3000,s=ii(e);if(!s)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${s.routes.length} routes...`);let c=It(s.routeRules),l=new G,m=Hr(e,s.apiRoutes??[]),f=Bun.file(M.join(e,"server/runtime-config.json")),x=t.runtimeConfig??(await f.exists()?await f.json():void 0),g=x?S(x):void 0,b=new Map,O=new Map,v=new Map,E=new Map;for(let n of s.routes)try{let R=M.join(e,n.compiledPath),o=JSON.parse(await Bun.file(R).text());if(g)o.html=Ke(o.html,g);b.set(n.pattern,o),v.set(n.pattern,xe(o.html)),E.set(n.pattern,ae(o.html));let _=M.join(e,n.fragmentPath);if(await Bun.file(_).exists()){let A=await Bun.file(_).text();O.set(n.pattern,g?Ke(A,g):A)}}catch(R){console.warn(`[stx] Failed to load route ${n.pattern}:`,R)}let r=new Map,T=[];for(let n of s.routes)if(n.hasParams){let{regex:R,params:o}=X(n.pattern,{page:!0});T.push({regex:R,route:n,paramNames:o})}else r.set(n.pattern,n);let L=ce({port:i,async fetch(n){return At(n,await le(g??S(),async()=>{let o=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[o])return t.apiRoutes[o](n);let _=await m(n);if(_)return _;if((n.method==="GET"||n.method==="HEAD")&&o!=="/"){let p=M.resolve(e,"public"),d;try{d=decodeURIComponent(o)}catch{d=o}if(!d.includes("\x00")){let u=M.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${M.sep}`))try{if(J.existsSync(u)&&J.statSync(u).isFile()){let h=M.extname(u).toLowerCase(),j=pe[h]||"application/octet-stream",B=o.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(o);return new Response(Bun.file(u),{headers:{"Content-Type":j,"Cache-Control":B?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=ne(n),y=null,U={};if(y=r.get(o)||null,!y)for(let{regex:p,route:d,paramNames:u}of T){let a=o.match(p);if(a){y=d,u.forEach((h,j)=>{U[h]=a[j+1]});break}}if(!y){let p=Ze(o)?null:r.get("/404")||null;if(p){let d=b.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let k=c(o),W=Object.keys(k).length>0;return l.respond(n,k.cache,async()=>{let p=b.get(y.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let a=O.get(y.pattern);if(a){let h=v.get(y.pattern);return new Response(a,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...E.has(y.pattern)?{"X-STX-Runtime":E.get(y.pattern)?"true":"false"}:{},...h?{"X-STX-Layout":h.layout,"X-STX-Layout-Group":h.group}:{},...C(),...k.cache?{}:{"Cache-Control":_e}}})}}let d=wr(n.method),u=b.get(y.pattern);if(!u){let a=r.get("/500")||null;if(a){let h=b.get(a.pattern);if(h)return new Response(h.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(y.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",...C(),"Cache-Control":"public, max-age=60"}});try{let{html:a,boundaries:h,redirect:j,cookies:B,status:I,headers:z}=await Pt(u,{params:U,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:g});if(j)return oi(j,B,z);if(h&&h.length>0){let{renderStreamingPage:P,streamToResponse:D}=await import("./chunk-dyhb8ey9.js"),N=new Headers({...C(),...z,"Cache-Control":"private, no-store"});for(let F of B??[])N.append("Set-Cookie",F);if(A&&!d){let F=xe(a);N.set("X-STX-Fragment","true"),N.set("X-STX-Runtime",ae(a)?"true":"false"),N.set("X-STX-Layout",F.layout),N.set("X-STX-Layout-Group",F.group)}return D(P(A&&!d?re(a,s.routerContainer||"main"):a,h,{timeoutMs:30000}),{status:I??u.status??200,headers:N})}let w=new Headers({"Content-Type":"text/html",...C(),...k.cache?{}:{"Cache-Control":"private, no-store"}});for(let P of B??[])w.append("Set-Cookie",P);for(let[P,D]of Object.entries(z??{}))w.set(P,D);if(w.set("Vary",C(w.get("Vary")).Vary),A&&!d){let P=xe(a);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",ae(a)?"true":"false"),w.set("X-STX-Layout",P.layout),w.set("X-STX-Layout-Group",P.group),new Response(re(a,s.routerContainer||"main"),{status:I??u.status??200,headers:w})}return new Response(a,{status:I??u.status??200,headers:w})}catch(a){if(console.error(`[stx] Hydration error for ${o}:`,a),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${L.port}`),console.log(`[stx] Serving ${s.routes.length} routes (${b.size} pre-loaded)`),{port:L.port,stop:()=>{l.invalidate(),L.stop()},invalidate:(n)=>l.invalidate(n)}}
2
+ import{V,ae}from"./chunk-hxn9gk7h.js";import{le,S,Ke}from"./chunk-y438dzvn.js";import{Ze,X,xe}from"./chunk-12pvnn1e.js";import{_e,ne,C,re,ii,vr,oi,Pt}from"./chunk-gc0w2cx7.js";import{Hr}from"./chunk-21rqr54j.js";import{It}from"./chunk-8zf5q1m3.js";import H from"zlib";import{promisify as Y}from"util";var Q=Y(H.brotliCompress),Z=Y(H.gzip),K=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ee=["text/event-stream","multipart/x-mixed-replace"],te=1024;function se(t){if(!t)return!1;let e=t.toLowerCase();if(ee.some((i)=>e.startsWith(i)))return!1;return K.some((i)=>e.startsWith(i))}function oe(t){let e=new Map;for(let i of t.split(",")){let[s,...c]=i.trim().split(";"),l=s.trim().toLowerCase();if(!l)continue;let m=1;for(let f of c){let x=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(f);if(!x)continue;let g=Number.parseFloat(x[1]);if(Number.isFinite(g))m=g}e.set(l,m)}return e}function ie(t){if(!t)return null;let e=oe(t),i=e.get("*"),s=(c)=>e.get(c)??i??0;if(s("br")>0)return"br";if(s("gzip")>0)return"gzip";return null}async function At(t,e,i={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!se(e.headers.get("content-type")))return e;let s=ie(t.headers.get("accept-encoding"));if(!s)return e;let c;try{c=new Uint8Array(await e.arrayBuffer())}catch{return e}let l=()=>new Response(c,{status:e.status,statusText:e.statusText,headers:q(e.headers)});if(c.length<(i.threshold??te))return l();try{let m=s==="br"?await Q(c,{params:{[H.constants.BROTLI_PARAM_QUALITY]:i.quality??5,[H.constants.BROTLI_PARAM_SIZE_HINT]:c.length}}):await Z(c);if(m.length>=c.length)return l();let f=q(e.headers);return f.set("Content-Encoding",s),f.set("Content-Length",String(m.length)),new Response(m,{status:e.status,statusText:e.statusText,headers:f})}catch{return l()}}function q(t){let e=new Headers(t),i=e.get("Vary");if(!i)return e.set("Vary","Accept-Encoding"),e;if(!i.split(",").some((c)=>c.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${i}, Accept-Encoding`);return e}import J from"fs";import M from"path";var{serve:ce}=globalThis.Bun;class G{now;entries=new V(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,i){let s,c=async()=>{let r=s??await i();return r.headers.set("Cache-Control","private, no-store"),r.headers.set("Vary",C(r.headers.get("Vary")).Vary),r};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return c();let l=new URL(t.url),m=`${l.origin}${l.pathname}${l.search}|${ne(t)?"fragment":"document"}`,f=this.entries.get(m),x=(r)=>{let T=new Headers(r.headers);return T.set("Cache-Control","private, no-store"),T.set("Age",String(Math.max(0,Math.floor((this.now()-r.created)/1000)))),new Response(r.body.slice(0),{headers:T})},g=f?(this.now()-f.created)/1000:1/0;if(f&&g<e.maxAge)return x(f);let b=this.generation,O=async()=>{let r=await i();s=r;let T=(r.headers.get("Vary")??"").toLowerCase().split(",").map((R)=>R.trim()).filter(Boolean);if(r.status!==200||r.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(r.headers.get("Cache-Control")??"")||T.some((R)=>R!=="x-stx-router"&&R!=="accept-encoding"))return null;let L=await r.clone().arrayBuffer();if(L.byteLength>1048576)return null;r.headers.set("Vary",C(r.headers.get("Vary")).Vary);let n={body:L,headers:Array.from(r.headers.entries()),created:this.now(),path:l.pathname};if(this.generation===b)this.entries.set(m,n);return n},v=this.pending.get(m);if(!v){if(this.pending.size>=1000)return c();v=O().finally(()=>{if(this.pending.get(m)===v)this.pending.delete(m)}),this.pending.set(m,v)}if(f&&g<e.maxAge+(e.swr??0))return v.catch(()=>{}),x(f);let E=await v;return E?x(E):c()}}var pe={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function ol(t={}){let e=M.resolve(t.outputDir||".output"),i=t.port??3000,s=ii(e);if(!s)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${s.routes.length} routes...`);let c=It(s.routeRules),l=new G,m=Hr(e,s.apiRoutes??[]),f=Bun.file(M.join(e,"server/runtime-config.json")),x=t.runtimeConfig??(await f.exists()?await f.json():void 0),g=x?S(x):void 0,b=new Map,O=new Map,v=new Map,E=new Map;for(let n of s.routes)try{let R=M.join(e,n.compiledPath),o=JSON.parse(await Bun.file(R).text());if(g)o.html=Ke(o.html,g);b.set(n.pattern,o),v.set(n.pattern,xe(o.html)),E.set(n.pattern,ae(o.html));let _=M.join(e,n.fragmentPath);if(await Bun.file(_).exists()){let A=await Bun.file(_).text();O.set(n.pattern,g?Ke(A,g):A)}}catch(R){console.warn(`[stx] Failed to load route ${n.pattern}:`,R)}let r=new Map,T=[];for(let n of s.routes)if(n.hasParams){let{regex:R,params:o}=X(n.pattern,{page:!0});T.push({regex:R,route:n,paramNames:o})}else r.set(n.pattern,n);let L=ce({port:i,async fetch(n){return At(n,await le(g??S(),async()=>{let o=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[o])return t.apiRoutes[o](n);let _=await m(n);if(_)return _;if((n.method==="GET"||n.method==="HEAD")&&o!=="/"){let p=M.resolve(e,"public"),d;try{d=decodeURIComponent(o)}catch{d=o}if(!d.includes("\x00")){let u=M.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${M.sep}`))try{if(J.existsSync(u)&&J.statSync(u).isFile()){let h=M.extname(u).toLowerCase(),j=pe[h]||"application/octet-stream",B=o.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(o);return new Response(Bun.file(u),{headers:{"Content-Type":j,"Cache-Control":B?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=ne(n),y=null,U={};if(y=r.get(o)||null,!y)for(let{regex:p,route:d,paramNames:u}of T){let a=o.match(p);if(a){y=d,u.forEach((h,j)=>{U[h]=a[j+1]});break}}if(!y){let p=Ze(o)?null:r.get("/404")||null;if(p){let d=b.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let k=c(o),W=Object.keys(k).length>0;return l.respond(n,k.cache,async()=>{let p=b.get(y.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let a=O.get(y.pattern);if(a){let h=v.get(y.pattern);return new Response(a,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...E.has(y.pattern)?{"X-STX-Runtime":E.get(y.pattern)?"true":"false"}:{},...h?{"X-STX-Layout":h.layout,"X-STX-Layout-Group":h.group}:{},...C(),...k.cache?{}:{"Cache-Control":_e}}})}}let d=vr(n.method),u=b.get(y.pattern);if(!u){let a=r.get("/500")||null;if(a){let h=b.get(a.pattern);if(h)return new Response(h.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(y.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",...C(),"Cache-Control":"public, max-age=60"}});try{let{html:a,boundaries:h,redirect:j,cookies:B,status:I,headers:z}=await Pt(u,{params:U,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:g});if(j)return oi(j,B,z);if(h&&h.length>0){let{renderStreamingPage:P,streamToResponse:D}=await import("./chunk-cr3f21mg.js"),N=new Headers({...C(),...z,"Cache-Control":"private, no-store"});for(let F of B??[])N.append("Set-Cookie",F);if(A&&!d){let F=xe(a);N.set("X-STX-Fragment","true"),N.set("X-STX-Runtime",ae(a)?"true":"false"),N.set("X-STX-Layout",F.layout),N.set("X-STX-Layout-Group",F.group)}return D(P(A&&!d?re(a,s.routerContainer||"main"):a,h,{timeoutMs:30000}),{status:I??u.status??200,headers:N})}let w=new Headers({"Content-Type":"text/html",...C(),...k.cache?{}:{"Cache-Control":"private, no-store"}});for(let P of B??[])w.append("Set-Cookie",P);for(let[P,D]of Object.entries(z??{}))w.set(P,D);if(w.set("Vary",C(w.get("Vary")).Vary),A&&!d){let P=xe(a);return w.set("X-STX-Fragment","true"),w.set("X-STX-Runtime",ae(a)?"true":"false"),w.set("X-STX-Layout",P.layout),w.set("X-STX-Layout-Group",P.group),new Response(re(a,s.routerContainer||"main"),{status:I??u.status??200,headers:w})}return new Response(a,{status:I??u.status??200,headers:w})}catch(a){if(console.error(`[stx] Hydration error for ${o}:`,a),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${L.port}`),console.log(`[stx] Serving ${s.routes.length} routes (${b.size} pre-loaded)`),{port:L.port,stop:()=>{l.invalidate(),L.stop()},invalidate:(n)=>l.invalidate(n)}}
3
3
  export{At,ol};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ru,Fi,Au,zi,Ja,Ya,vt,en,Pu,Za,Qa,ec,f}from"./chunk-hxn9gk7h.js";import"./chunk-ktedzx9e.js";import"./chunk-3ry9ca1s.js";import"./chunk-k8sqs7j2.js";import"./chunk-n58q81vv.js";import"./chunk-y438dzvn.js";import"./chunk-fb7bfyjz.js";import"./chunk-mjgqhhap.js";import"./chunk-5f0r0g18.js";import"./chunk-axydabse.js";import"./chunk-w3j0ppg4.js";import"./chunk-12pvnn1e.js";import"./chunk-b7973zvk.js";export{vt as buildCss,Za as extractClassNames,Ya as fingerprintConfig,Qa as generateCss,Pu as getCachedCSS,Ru as getCssServeAsset,f as injectCss,Fi as loadCssEngine,zi as loadCssEngineConfig,en as rebuildCss,Au as resetCssCache,Ja as resolveUserCssConfig,ec as withLinkedModuleBundles};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{pi,wa,Ht,fl,xa,Sa,ka,gl}from"./chunk-s295vp9x.js";export{Ht as Validator,wa as defineForm,xa as processErrorDirective,Sa as processErrorsDirective,gl as processFormValidationDirectives,ka as processHasErrorsDirective,pi as useForm,fl as v};
2
+ import{pi,va,Ht,fl,xa,Sa,ka,gl}from"./chunk-wr9ac0cv.js";export{Ht as Validator,va as defineForm,xa as processErrorDirective,Sa as processErrorsDirective,gl as processFormValidationDirectives,ka as processHasErrorsDirective,pi as useForm,fl as v};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Ce,$e,Ee}from"./chunk-qxre7vw6.js";import"./chunk-yaebdyfr.js";import"./chunk-axydabse.js";import{d}from"./chunk-xdjevnv6.js";import"./chunk-89b2r1q0.js";import"./chunk-3ry9ca1s.js";import"./chunk-12pvnn1e.js";import"./chunk-48kgnqpk.js";import"./chunk-jbrdebzs.js";import"./chunk-k8sqs7j2.js";import"./chunk-ptjqacjd.js";import"./chunk-pcfdd3jv.js";import"./chunk-b7973zvk.js";import{it,lr,ot,Ms,ke,Ns,ur,at,js,ct}from"./chunk-6t7mxb0b.js";import"./chunk-2x9jd5w0.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(p)=>{if(p==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{Ns("Config file changed, restarting...");try{await e.onChange()}catch(l){ke(`Failed to restart: ${l}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var st=".stx/story/analytics.json",dt=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,st),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:dt,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:pt(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let p=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),l=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),g=l.length>0?l.reduce((i,m)=>i+m,0)/l.length:0,y=Object.entries(c).sort((i,m)=>m[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:p.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:g}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function pt(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var lt=".stx/story/bookmarks.json",mt=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,lt),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:mt,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:ut(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function ut(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
2
+ import{Ce,$e,Ee}from"./chunk-qxre7vw6.js";import"./chunk-w3j0ppg4.js";import"./chunk-axydabse.js";import{d}from"./chunk-hxn9gk7h.js";import"./chunk-5f0r0g18.js";import"./chunk-3ry9ca1s.js";import"./chunk-12pvnn1e.js";import"./chunk-mjgqhhap.js";import"./chunk-fb7bfyjz.js";import"./chunk-k8sqs7j2.js";import"./chunk-y438dzvn.js";import"./chunk-n58q81vv.js";import"./chunk-b7973zvk.js";import{it,lr,ot,Ms,ke,Ns,ur,at,js,ct}from"./chunk-6t7mxb0b.js";import"./chunk-ktedzx9e.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(p)=>{if(p==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{Ns("Config file changed, restarting...");try{await e.onChange()}catch(l){ke(`Failed to restart: ${l}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var st=".stx/story/analytics.json",dt=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,st),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:dt,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:pt(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let p=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),l=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),g=l.length>0?l.reduce((i,m)=>i+m,0)/l.length:0,y=Object.entries(c).sort((i,m)=>m[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:p.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:g}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function pt(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var lt=".stx/story/bookmarks.json",mt=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,lt),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:mt,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:ut(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function ut(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
3
3
  <script>
4
4
  (function() {
5
5
  const ws = new WebSocket('${t}');
@@ -556,7 +556,7 @@ window.__stxPerformance = {
556
556
 
557
557
  window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
558
558
  </script>
559
- `}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:p}=await import("./chunk-e06jpx5x.js"),l={},g=h(n);if(g)try{await d(g,l,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}if(r.props)Object.assign(l,r.props);let i=await p(n,l,e,{},new Set),m=Z(n),u=h(n);return i=Q(i),i=tt(i,l),{html:i,css:m,js:u,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await d(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-e06jpx5x.js"),c={...r},n=h(e);if(n)try{await d(n,c,"inline-template.stx")}catch{}let l=await a(e,c,"inline-template.stx",{},new Set);return l=Q(l),l=tt(l,c),{html:l,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
559
+ `}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:p}=await import("./chunk-1qf3wc23.js"),l={},g=h(n);if(g)try{await d(g,l,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}if(r.props)Object.assign(l,r.props);let i=await p(n,l,e,{},new Set),m=Z(n),u=h(n);return i=Q(i),i=tt(i,l),{html:i,css:m,js:u,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await d(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-1qf3wc23.js"),c={...r},n=h(e);if(n)try{await d(n,c,"inline-template.stx")}catch{}let l=await a(e,c,"inline-template.stx",{},new Set);return l=Q(l),l=tt(l,c),{html:l,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
560
560
  `)}function Q(t){return t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function h(t){let e=[],r=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
561
561
  `)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}async function rt(t,e){let r=await at(t);$e(t,r);let s=ct(t.config,r);Ee(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),p=N(),l=Bun.serve({port:e.port,hostname:o,fetch:async(i,m)=>{let f=new URL(i.url).pathname;if(f==="/__hmr"){if(m.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(f.startsWith("/api/"))return xt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,f,e.port)},websocket:{open(i){p.open(i)},close(i){p.close(i)},message(i,m){p.message(i,m)}}}),g=`http://${o}:${e.port}`,y=js(t,async(i,m)=>{console.log(` [${i}] ${m.relativePath}`);let u=await at(t);$e(t,u);let f=ct(t.config,u);if(Ee(t,f),i==="add")H(m.id,{fileName:m.fileName});else if(i==="unlink")O(m.id);else V(m.id,{fileName:m.fileName})});if(e.open){let i=g;try{let{exec:m}=await import("child_process"),u=process.platform;m(`${u==="darwin"?"open":u==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:l,url:g,close:async()=>{y(),l.stop()}}}async function xt(t,e,r,s){let{presetsManager:o,bookmarksManager:a,analyticsTracker:c}=s;if(e==="/api/stories")return Response.json({files:t.storyFiles.map((n)=>({id:n.id,fileName:n.fileName,relativePath:n.relativePath,treePath:n.treePath})),tree:t.tree});if(e.startsWith("/api/story/")){let n=e.slice(11),p=t.storyFiles.find((l)=>l.id===n);if(!p)return new Response("Story not found",{status:404});try{let l=await Bun.file(p.path).text();return Response.json({id:p.id,fileName:p.fileName,relativePath:p.relativePath,content:l})}catch{return new Response("Error reading story",{status:500})}}if(e==="/api/config")return Response.json({theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets});if(e.startsWith("/api/render/")){let n=new URL(r.url),p=e.slice(12).split("/"),l=p[0],g=p[1]||"default",y,i=n.searchParams.get("props");if(i)try{y=JSON.parse(i)}catch{}let m=t.storyFiles.find((u)=>u.id===l);if(!m)return new Response("Story not found",{status:404});try{let u=await Y(t,m,g,y);return Response.json({html:u.html,css:u.css,js:u.js,errors:u.errors,duration:u.duration})}catch(u){return Response.json({html:"",css:"",js:"",errors:[u instanceof Error?u.message:String(u)],duration:0},{status:500})}}if(e==="/api/presets"&&r.method==="GET")return Response.json({presets:o.getAllPresets()});if(e==="/api/presets"&&r.method==="POST")try{let n=await r.json(),p=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(p)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/presets/")&&!e.includes("/use")&&r.method==="GET"){let n=e.slice(13),p=o.getPreset(n);if(!p)return new Response("Preset not found",{status:404});return Response.json(p)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),p=o.usePreset(n);if(!p)return new Response("Preset not found",{status:404});return await o.save(),Response.json(p)}if(e.startsWith("/api/presets/")&&r.method==="DELETE"){let n=e.slice(13);if(!o.deletePreset(n))return new Response("Preset not found",{status:404});return await o.save(),Response.json({success:!0})}if(e==="/api/bookmarks"&&r.method==="GET")return Response.json({bookmarks:a.getAllBookmarks()});if(e==="/api/bookmarks"&&r.method==="POST")try{let n=await r.json(),p=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(p)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),p=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(p)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/bookmarks/")&&e!=="/api/bookmarks/toggle"&&r.method==="GET"){let n=e.slice(15),p=a.getBookmark(n);if(!p)return new Response("Bookmark not found",{status:404});return Response.json(p)}if(e.startsWith("/api/bookmarks/")&&r.method==="DELETE"){let n=e.slice(15);if(!a.deleteBookmark(n))return new Response("Bookmark not found",{status:404});return await a.save(),Response.json({success:!0})}if(e==="/api/analytics/track"&&r.method==="POST")try{let n=await r.json();if(n.type==="view"&&n.componentId)c.trackView(n.componentId,n.variantId);else if(n.type==="prop_change"&&n.componentId&&n.propName)c.trackPropChange(n.componentId,n.propName,null);else if(n.type==="variant_switch"&&n.componentId&&n.variantId)c.trackVariantSwitch(n.componentId,n.variantId);else if(n.type==="search"&&n.query)c.trackSearch(n.query,0);return await c.save(),Response.json({success:!0})}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/analytics/summary"&&r.method==="GET")return Response.json({mostViewed:c.getMostViewedComponents(10),mostChangedProps:c.getMostChangedProps(10),searchAnalytics:c.getSearchAnalytics()});if(e.startsWith("/api/analytics/component/")&&r.method==="GET"){let n=e.slice(25),p=t.storyFiles.find((g)=>g.id===n),l=c.getComponentAnalytics(n,p?.fileName||n);return Response.json(l)}return new Response("Not found",{status:404})}function wt(t,e,r){let s=kt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function kt(t,e){let{theme:r}=t.config,s=r.title||"STX Story",o=`ws://localhost:${e}/__hmr`,a=F(o);return`<!DOCTYPE html>
562
562
  <html lang="en" class="${r.darkClass||"dark"}">
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{yt,Fr,zr,Hr,mu,Vr}from"./chunk-xs68rj51.js";import"./chunk-k8sqs7j2.js";import"./chunk-ptjqacjd.js";import"./chunk-12pvnn1e.js";export{zr as buildServerApi,mu as createServerApi,yt as discoverServerApi,Fr as generateApiTypes,Vr as isServerApiSource,Hr as productionApiDispatcher};
2
+ import{yt,Fr,zr,Hr,mu,Vr}from"./chunk-21rqr54j.js";import"./chunk-k8sqs7j2.js";import"./chunk-y438dzvn.js";import"./chunk-12pvnn1e.js";export{zr as buildServerApi,mu as createServerApi,yt as discoverServerApi,Fr as generateApiTypes,Vr as isServerApiSource,Hr as productionApiDispatcher};