@stacksjs/bun-router 0.0.27 → 0.1.0

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 (102) hide show
  1. package/dist/chunk-0gjq8ttx.js +14 -0
  2. package/dist/chunk-0t5vz87j.js +35 -0
  3. package/dist/chunk-30rkn2ym.js +2 -0
  4. package/dist/chunk-38cmrard.js +2 -0
  5. package/dist/chunk-3qna6dwd.js +2 -0
  6. package/dist/chunk-4d5fmta0.js +2 -0
  7. package/dist/chunk-4x3b4b4q.js +2 -0
  8. package/dist/chunk-5be9x5cq.js +3 -0
  9. package/dist/chunk-5mxby3fd.js +1654 -0
  10. package/dist/chunk-5n0ckcmc.js +3 -0
  11. package/dist/chunk-5ncn73tp.js +3 -0
  12. package/dist/chunk-5s0pnsd6.js +12 -0
  13. package/dist/chunk-5s1pr62n.js +3 -0
  14. package/dist/chunk-67wgad4f.js +60 -0
  15. package/dist/chunk-6bbmkwng.js +3 -0
  16. package/dist/chunk-6s1kbajm.js +7851 -0
  17. package/dist/chunk-6sjvhy5f.js +3 -0
  18. package/dist/chunk-6xed4va1.js +2 -0
  19. package/dist/chunk-73k79n7q.js +15413 -0
  20. package/dist/chunk-748n6ydj.js +2 -0
  21. package/dist/chunk-7qnxdedn.js +321 -0
  22. package/dist/chunk-7rsf8tes.js +898 -0
  23. package/dist/chunk-8aspmtf1.js +2 -0
  24. package/dist/chunk-8wpj3fqe.js +351 -0
  25. package/dist/chunk-8yfdg595.js +2 -0
  26. package/dist/chunk-90eze7av.js +3 -0
  27. package/dist/chunk-9805tt8n.js +341 -0
  28. package/dist/chunk-9dvwyej7.js +2 -0
  29. package/dist/chunk-9ght4n4r.js +216 -0
  30. package/dist/chunk-a2w45krb.js +2 -0
  31. package/dist/chunk-a3wahyg7.js +3 -0
  32. package/dist/chunk-a547f2ab.js +48 -0
  33. package/dist/chunk-bqdycvtc.js +2 -0
  34. package/dist/chunk-brpgjyqg.js +3 -0
  35. package/dist/chunk-cd03rk3x.js +2 -0
  36. package/dist/chunk-csfrpsp7.js +185 -0
  37. package/dist/chunk-ct0m17q5.js +2 -0
  38. package/dist/chunk-dhbvvr5h.js +2 -0
  39. package/dist/chunk-dhptcsya.js +943 -0
  40. package/dist/chunk-dq93zag9.js +2 -0
  41. package/dist/chunk-dxg045wj.js +5 -0
  42. package/dist/chunk-e3qej0jr.js +4 -0
  43. package/dist/chunk-edrtesh7.js +2 -0
  44. package/dist/chunk-ejcws37w.js +2 -0
  45. package/dist/chunk-ex5fkjah.js +397 -0
  46. package/dist/chunk-ex890p45.js +51 -0
  47. package/dist/chunk-f69cpnhw.js +2 -0
  48. package/dist/chunk-fjf53b44.js +2 -0
  49. package/dist/chunk-fjzye4qj.js +2 -0
  50. package/dist/chunk-gfd23b6t.js +2 -0
  51. package/dist/chunk-habv0vef.js +12 -0
  52. package/dist/chunk-hmgedrmr.js +11 -0
  53. package/dist/chunk-hz6fc788.js +2 -0
  54. package/dist/chunk-jff6j9y3.js +10 -0
  55. package/dist/chunk-jmeb7n8k.js +70 -0
  56. package/dist/chunk-jrf5a2ap.js +2 -0
  57. package/dist/chunk-jy2jhcpy.js +246 -0
  58. package/dist/chunk-kc659vhx.js +4 -0
  59. package/dist/chunk-kjtjbcq4.js +71 -0
  60. package/dist/chunk-krkchy8v.js +4 -0
  61. package/dist/chunk-kxp888dn.js +4540 -0
  62. package/dist/chunk-m249t3je.js +3 -0
  63. package/dist/chunk-m9yabnjx.js +2 -0
  64. package/dist/chunk-mekrq9wd.js +2 -0
  65. package/dist/chunk-mmxv535f.js +82 -0
  66. package/dist/chunk-mypn7jss.js +2 -0
  67. package/dist/chunk-n18x1k3c.js +2 -0
  68. package/dist/chunk-nkddjzsa.js +2 -0
  69. package/dist/chunk-pjmhqmr9.js +2 -0
  70. package/dist/chunk-qyrnsaq1.js +2 -0
  71. package/dist/chunk-r19ff2qm.js +62 -0
  72. package/dist/chunk-r338fssq.js +2 -0
  73. package/dist/chunk-s36z58x2.js +29 -0
  74. package/dist/chunk-s3dn1kwx.js +231 -0
  75. package/dist/chunk-s79dd325.js +471 -0
  76. package/dist/chunk-sw0chtw4.js +4 -0
  77. package/dist/chunk-ta38j9em.js +2 -0
  78. package/dist/chunk-tpfgntwj.js +4211 -0
  79. package/dist/chunk-vr10sbbh.js +3 -0
  80. package/dist/chunk-vsh4390q.js +358 -0
  81. package/dist/chunk-vv3gb1m5.js +84 -0
  82. package/dist/chunk-vw8rwv6e.js +2 -0
  83. package/dist/chunk-w4r464v5.js +288 -0
  84. package/dist/chunk-wcrqs5z9.js +2 -0
  85. package/dist/chunk-x6d1rmwa.js +2 -0
  86. package/dist/chunk-x7ft15zz.js +2 -0
  87. package/dist/chunk-x8trwn7j.js +3 -0
  88. package/dist/chunk-xg9xscqz.js +1 -0
  89. package/dist/chunk-xhepdj1f.js +2 -0
  90. package/dist/chunk-xv2em0q4.js +4 -0
  91. package/dist/chunk-ypw6g0te.js +2 -0
  92. package/dist/chunk-z8szsm21.js +2 -0
  93. package/dist/chunk-zetqzgf3.js +194 -0
  94. package/dist/chunk-zfbh14qe.js +2 -0
  95. package/dist/chunk-zhx0hxdd.js +28 -0
  96. package/dist/cli.js +67 -3240
  97. package/dist/container/index.js +1 -321
  98. package/dist/index.js +80 -13987
  99. package/package.json +1 -1
  100. package/dist/chunk-1ahs68ys.js +0 -18
  101. package/dist/chunk-cgptvjdf.js +0 -18131
  102. package/dist/chunk-g3ybefhg.js +0 -1923
@@ -0,0 +1,341 @@
1
+ // @bun
2
+ var c=0;function l(){return`suspense-${++c}-${Date.now().toString(36)}`}function y(s,t={},n){let e=/@suspense(?:\s*\(([^)]*)\))?\s*([\s\S]*?)@fallback\s*([\s\S]*?)@endsuspense/gi;return s.replace(e,(r,i,o,d)=>{let u=l(),a=p(i||"");return f(u,o.trim(),d.trim(),a)})}function p(s){let t={},n=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,e;while((e=n.exec(s))!==null){let r=e[1],i=e[2]||e[3],o=e[4];switch(r){case"id":t.id=i;break;case"timeout":t.timeout=o?parseInt(o,10):void 0;break}}return t}function f(s,t,n,e){let r=e.timeout||30000,i=e.id||s;return`
3
+ <div class="stx-suspense" data-suspense-id="${s}" data-custom-id="${i}" data-status="pending">
4
+ <div class="stx-suspense-fallback" data-suspense-fallback="${s}">
5
+ ${n}
6
+ </div>
7
+ <div class="stx-suspense-content" data-suspense-content="${s}" style="display: none;">
8
+ ${t}
9
+ </div>
10
+ </div>
11
+ <script>
12
+ (function() {
13
+ const suspenseId = '${s}';
14
+ const customId = '${i}';
15
+ const timeout = ${r};
16
+
17
+ const container = document.querySelector('[data-suspense-id="' + suspenseId + '"]');
18
+ const fallbackEl = document.querySelector('[data-suspense-fallback="' + suspenseId + '"]');
19
+ const contentEl = document.querySelector('[data-suspense-content="' + suspenseId + '"]');
20
+
21
+ if (!container || !fallbackEl || !contentEl) return;
22
+
23
+ // State
24
+ const pending = new Set();
25
+ const resolved = new Set();
26
+ let status = 'pending';
27
+ let error = null;
28
+ let timeoutTimer = null;
29
+
30
+ // Update UI based on state
31
+ function updateUI() {
32
+ container.setAttribute('data-status', status);
33
+
34
+ if (status === 'resolved') {
35
+ fallbackEl.style.display = 'none';
36
+ contentEl.style.display = '';
37
+ }
38
+ else if (status === 'rejected') {
39
+ fallbackEl.style.display = 'none';
40
+ contentEl.style.display = '';
41
+ // Show error in content area if needed
42
+ }
43
+ else {
44
+ fallbackEl.style.display = '';
45
+ contentEl.style.display = 'none';
46
+ }
47
+ }
48
+
49
+ // Check if all children are resolved
50
+ function checkResolved() {
51
+ if (pending.size === 0 && resolved.size > 0) {
52
+ clearTimeout(timeoutTimer);
53
+ status = 'resolved';
54
+ updateUI();
55
+
56
+ container.dispatchEvent(new CustomEvent('stx:suspense:resolved', {
57
+ detail: { suspenseId: suspenseId, customId: customId },
58
+ bubbles: true
59
+ }));
60
+ }
61
+ }
62
+
63
+ // Register an async child
64
+ function register(childId) {
65
+ if (status === 'resolved') {
66
+ // Reset if we get a new child after resolution
67
+ status = 'pending';
68
+ updateUI();
69
+ }
70
+ pending.add(childId);
71
+
72
+ // Start timeout on first registration
73
+ if (pending.size === 1 && !timeoutTimer) {
74
+ timeoutTimer = setTimeout(function() {
75
+ if (status === 'pending') {
76
+ error = new Error('Suspense timeout after ' + timeout + 'ms');
77
+ status = 'rejected';
78
+ updateUI();
79
+
80
+ container.dispatchEvent(new CustomEvent('stx:suspense:timeout', {
81
+ detail: { suspenseId: suspenseId, customId: customId, pending: Array.from(pending) },
82
+ bubbles: true
83
+ }));
84
+ }
85
+ }, timeout);
86
+ }
87
+ }
88
+
89
+ // Resolve a child
90
+ function resolve(childId) {
91
+ pending.delete(childId);
92
+ resolved.add(childId);
93
+ checkResolved();
94
+ }
95
+
96
+ // Reject a child
97
+ function reject(childId, err) {
98
+ pending.delete(childId);
99
+ error = err;
100
+ status = 'rejected';
101
+ clearTimeout(timeoutTimer);
102
+ updateUI();
103
+
104
+ container.dispatchEvent(new CustomEvent('stx:suspense:error', {
105
+ detail: { suspenseId: suspenseId, customId: customId, error: err, childId: childId },
106
+ bubbles: true
107
+ }));
108
+ }
109
+
110
+ // Reset the boundary
111
+ function reset() {
112
+ pending.clear();
113
+ resolved.clear();
114
+ status = 'pending';
115
+ error = null;
116
+ clearTimeout(timeoutTimer);
117
+ timeoutTimer = null;
118
+ updateUI();
119
+ }
120
+
121
+ // Expose API globally for async components to use
122
+ window.STX = window.STX || {};
123
+ window.STX.suspense = window.STX.suspense || {
124
+ boundaries: {},
125
+ // Find the nearest suspense boundary for a child
126
+ findBoundary: function(element) {
127
+ const boundary = element.closest('[data-suspense-id]');
128
+ if (boundary) {
129
+ return boundary.getAttribute('data-suspense-id');
130
+ }
131
+ return null;
132
+ },
133
+ register: function(childId, boundaryId) {
134
+ if (!boundaryId) {
135
+ // Find nearest boundary
136
+ const asyncEl = document.querySelector('[data-async-id="' + childId + '"]');
137
+ if (asyncEl) {
138
+ boundaryId = this.findBoundary(asyncEl);
139
+ }
140
+ }
141
+ if (boundaryId && this.boundaries[boundaryId]) {
142
+ this.boundaries[boundaryId].register(childId);
143
+ }
144
+ },
145
+ resolve: function(childId, boundaryId) {
146
+ if (!boundaryId) {
147
+ const asyncEl = document.querySelector('[data-async-id="' + childId + '"]');
148
+ if (asyncEl) {
149
+ boundaryId = this.findBoundary(asyncEl);
150
+ }
151
+ }
152
+ if (boundaryId && this.boundaries[boundaryId]) {
153
+ this.boundaries[boundaryId].resolve(childId);
154
+ }
155
+ },
156
+ reject: function(childId, error, boundaryId) {
157
+ if (!boundaryId) {
158
+ const asyncEl = document.querySelector('[data-async-id="' + childId + '"]');
159
+ if (asyncEl) {
160
+ boundaryId = this.findBoundary(asyncEl);
161
+ }
162
+ }
163
+ if (boundaryId && this.boundaries[boundaryId]) {
164
+ this.boundaries[boundaryId].reject(childId, error);
165
+ }
166
+ }
167
+ };
168
+
169
+ // Register this boundary
170
+ window.STX.suspense.boundaries[suspenseId] = {
171
+ id: suspenseId,
172
+ customId: customId,
173
+ getStatus: function() { return status; },
174
+ getPending: function() { return Array.from(pending); },
175
+ getResolved: function() { return Array.from(resolved); },
176
+ getError: function() { return error; },
177
+ register: register,
178
+ resolve: resolve,
179
+ reject: reject,
180
+ reset: reset
181
+ };
182
+
183
+ // Initial state - if no async children register within a tick, show content
184
+ setTimeout(function() {
185
+ if (pending.size === 0 && resolved.size === 0) {
186
+ status = 'resolved';
187
+ updateUI();
188
+ }
189
+ }, 0);
190
+ })();
191
+ </script>
192
+ `}function b(s,t,n){return{id:s,fallback:n,content:t}}async function m(s){let t=s.map((e)=>`
193
+ <div id="stx-ssr-suspense-${e.id}" class="stx-ssr-suspense">
194
+ ${e.fallback}
195
+ </div>
196
+ `).join(`
197
+ `);async function*n(){for(let e of s)try{let r=await e.content;yield`
198
+ <script>
199
+ (function() {
200
+ const el = document.getElementById('stx-ssr-suspense-${e.id}');
201
+ if (el) {
202
+ el.innerHTML = ${JSON.stringify(r)};
203
+ el.classList.add('stx-ssr-suspense-resolved');
204
+ }
205
+ })();
206
+ </script>
207
+ `}catch(r){yield`
208
+ <script>
209
+ (function() {
210
+ const el = document.getElementById('stx-ssr-suspense-${e.id}');
211
+ if (el) {
212
+ el.classList.add('stx-ssr-suspense-error');
213
+ console.error('SSR Suspense error for ${e.id}:', ${JSON.stringify(String(r))});
214
+ }
215
+ })();
216
+ </script>
217
+ `}}return{initial:t,streaming:n()}}function I(){return`
218
+ /* STX Suspense Styles */
219
+ .stx-suspense {
220
+ position: relative;
221
+ }
222
+
223
+ .stx-suspense[data-status="pending"] .stx-suspense-fallback {
224
+ display: block;
225
+ }
226
+
227
+ .stx-suspense[data-status="pending"] .stx-suspense-content {
228
+ display: none;
229
+ }
230
+
231
+ .stx-suspense[data-status="resolved"] .stx-suspense-fallback {
232
+ display: none;
233
+ }
234
+
235
+ .stx-suspense[data-status="resolved"] .stx-suspense-content {
236
+ display: block;
237
+ }
238
+
239
+ /* SSR Suspense */
240
+ .stx-ssr-suspense {
241
+ transition: opacity 0.3s ease;
242
+ }
243
+
244
+ .stx-ssr-suspense-resolved {
245
+ animation: stx-suspense-fade-in 0.3s ease;
246
+ }
247
+
248
+ @keyframes stx-suspense-fade-in {
249
+ from { opacity: 0; }
250
+ to { opacity: 1; }
251
+ }
252
+
253
+ /* Skeleton fallback helper */
254
+ .stx-suspense-skeleton {
255
+ background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
256
+ background-size: 200% 100%;
257
+ animation: stx-suspense-shimmer 1.5s infinite;
258
+ border-radius: 0.25rem;
259
+ }
260
+
261
+ @keyframes stx-suspense-shimmer {
262
+ 0% { background-position: 200% 0; }
263
+ 100% { background-position: -200% 0; }
264
+ }
265
+
266
+ /* Dark mode */
267
+ @media (prefers-color-scheme: dark) {
268
+ .stx-suspense-skeleton {
269
+ background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
270
+ background-size: 200% 100%;
271
+ }
272
+ }
273
+ `}function g(){return`
274
+ // STX Suspense Runtime
275
+ (function() {
276
+ if (typeof window === 'undefined') return;
277
+
278
+ window.STX = window.STX || {};
279
+
280
+ // Suspense boundary management is set up per-boundary in the HTML
281
+ // This just provides additional utilities
282
+
283
+ window.STX.suspense = window.STX.suspense || {
284
+ boundaries: {},
285
+ findBoundary: function(element) {
286
+ const boundary = element.closest('[data-suspense-id]');
287
+ return boundary ? boundary.getAttribute('data-suspense-id') : null;
288
+ },
289
+ register: function(childId, boundaryId) {},
290
+ resolve: function(childId, boundaryId) {},
291
+ reject: function(childId, error, boundaryId) {}
292
+ };
293
+
294
+ // Wait for all suspense boundaries to resolve
295
+ window.STX.suspense.waitForAll = function() {
296
+ return new Promise(function(resolve, reject) {
297
+ const boundaries = Object.values(window.STX.suspense.boundaries);
298
+ if (boundaries.length === 0) {
299
+ resolve();
300
+ return;
301
+ }
302
+
303
+ let resolved = 0;
304
+ let rejected = false;
305
+
306
+ boundaries.forEach(function(boundary) {
307
+ if (boundary.getStatus() === 'resolved') {
308
+ resolved++;
309
+ if (resolved === boundaries.length) resolve();
310
+ }
311
+ else if (boundary.getStatus() === 'rejected') {
312
+ if (!rejected) {
313
+ rejected = true;
314
+ reject(boundary.getError());
315
+ }
316
+ }
317
+ else {
318
+ // Listen for resolution
319
+ const container = document.querySelector('[data-suspense-id="' + boundary.id + '"]');
320
+ if (container) {
321
+ container.addEventListener('stx:suspense:resolved', function() {
322
+ resolved++;
323
+ if (resolved === boundaries.length && !rejected) resolve();
324
+ }, { once: true });
325
+
326
+ container.addEventListener('stx:suspense:error', function(e) {
327
+ if (!rejected) {
328
+ rejected = true;
329
+ reject(e.detail.error);
330
+ }
331
+ }, { once: true });
332
+ }
333
+ }
334
+ });
335
+ });
336
+ };
337
+
338
+ console.log('[stx] Suspense runtime initialized');
339
+ })();
340
+ `}
341
+ export{y as Fe,b as Ge,m as He,I as Ie,g as Je};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Df as a,Ef as b}from"./chunk-zhx0hxdd.js";import"./chunk-e3qej0jr.js";import"./chunk-tpfgntwj.js";import"./chunk-jff6j9y3.js";import"./chunk-csfrpsp7.js";import"./chunk-0t5vz87j.js";import"./chunk-krkchy8v.js";import"./chunk-brpgjyqg.js";import"./chunk-5mxby3fd.js";import"./chunk-5be9x5cq.js";import"./chunk-jmeb7n8k.js";import"./chunk-kc659vhx.js";import"./chunk-a3wahyg7.js";export{a as getComposableScript,b as clearComposableCache};
@@ -0,0 +1,216 @@
1
+ // @bun
2
+ function L(v,c){let{itemHeight:a,containerHeight:g,overscan:l=3,keyProperty:x="id",dynamicHeight:d=!1,estimatedItemHeight:u=a,direction:w="vertical"}=c,e=[...v],t=0,n=new Map;function f(){if(d)return m();let i=Math.max(0,Math.floor(t/a)-l),r=Math.ceil(g/a),h=Math.min(e.length-1,i+r+l*2);return{startIndex:i,endIndex:h}}function m(){let i=0,r=0,h=e.length-1;for(let p=0;p<e.length;p++){let M=n.get(p)||u;if(i+M>t){r=Math.max(0,p-l);break}i+=M}i=0;for(let p=0;p<e.length;p++){let M=n.get(p)||u;if(i+=M,i>t+g){h=Math.min(e.length-1,p+l);break}}return{startIndex:r,endIndex:h}}function H(){if(d){let i=0;for(let r=0;r<e.length;r++)i+=n.get(r)||u;return i}return e.length*a}function y(i){if(d){let r=0;for(let h=0;h<i;h++)r+=n.get(h)||u;return r}return i*a}function I(){let{startIndex:i,endIndex:r}=f();return{startIndex:i,endIndex:r,scrollTop:t,totalHeight:H(),visibleItems:e.slice(i,r+1),itemHeights:new Map(n)}}function S(i,r="auto"){let h=y(i);s(h,r)}function s(i,r="auto"){t=Math.max(0,Math.min(i,H()-g))}function o(){f()}function b(i){e=[...i],n.clear(),o()}function $(){e=[],n.clear()}return{scrollToIndex:S,scrollToOffset:s,getState:I,refresh:o,setItems:b,destroy:$}}function T(v,c={},a){let g=/@virtualList\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@endvirtualList/gi;return v.replace(g,(l,x,d,u)=>{let w=x.trim(),e=c[w];if(!e||!Array.isArray(e))return`<!-- virtualList: items "${w}" not found or not an array -->`;let t={itemHeight:50,containerHeight:400,overscan:3};if(d)try{let s=d.trim(),o=Function(`return ${s}`)();t={...t,...o}}catch{}let n=`vlist-${Math.random().toString(36).substring(2,9)}`,f=Math.ceil(t.containerHeight/t.itemHeight),m=t.overscan||3,H=0,y=Math.min(e.length-1,f+m),I="";for(let s=H;s<=y&&s<e.length;s++){let o=e[s],b=u.replace(/\{\{\s*item\s*\}\}/g,typeof o==="object"?JSON.stringify(o):String(o)).replace(/\{\{\s*item\.(\w+)\s*\}\}/g,($,i)=>{if(typeof o==="object"&&o!==null)return String(o[i]??"");return""}).replace(/\{\{\s*index\s*\}\}/g,String(s));I+=`
3
+ <div class="virtual-item ${t.itemClass||""}"
4
+ style="position: absolute; top: ${s*t.itemHeight}px; height: ${t.itemHeight}px; width: 100%;"
5
+ data-index="${s}">
6
+ ${b}
7
+ </div>`}let S=e.length*t.itemHeight;return`
8
+ <div id="${n}"
9
+ class="virtual-list-container ${t.containerClass||""}"
10
+ style="position: relative; height: ${t.containerHeight}px; overflow-y: auto;"
11
+ data-item-height="${t.itemHeight}"
12
+ data-total-items="${e.length}"
13
+ data-overscan="${m}">
14
+ <div class="virtual-list-viewport ${t.viewportClass||""}"
15
+ style="position: relative; height: ${S}px; width: 100%;">
16
+ ${I}
17
+ </div>
18
+ </div>
19
+ <script data-virtual-list="${n}">
20
+ (function() {
21
+ const container = document.getElementById('${n}');
22
+ if (!container) return;
23
+
24
+ const viewport = container.querySelector('.virtual-list-viewport');
25
+ const itemHeight = ${t.itemHeight};
26
+ const totalItems = ${e.length};
27
+ const overscan = ${m};
28
+ const containerHeight = ${t.containerHeight};
29
+ const items = ${JSON.stringify(e)};
30
+ const template = ${JSON.stringify(u.trim())};
31
+
32
+ let lastStartIndex = 0;
33
+
34
+ function renderItems(scrollTop) {
35
+ const startIndex = Math.max(0, Math.floor(scrollTop / itemHeight) - overscan);
36
+ const visibleCount = Math.ceil(containerHeight / itemHeight);
37
+ const endIndex = Math.min(totalItems - 1, startIndex + visibleCount + overscan * 2);
38
+
39
+ if (startIndex === lastStartIndex) return;
40
+ lastStartIndex = startIndex;
41
+
42
+ // Clear and re-render
43
+ viewport.innerHTML = '';
44
+
45
+ for (let i = startIndex; i <= endIndex; i++) {
46
+ const item = items[i];
47
+ const div = document.createElement('div');
48
+ div.className = 'virtual-item ${t.itemClass||""}';
49
+ div.style.cssText = 'position: absolute; top: ' + (i * itemHeight) + 'px; height: ' + itemHeight + 'px; width: 100%;';
50
+ div.dataset.index = i;
51
+
52
+ let html = template
53
+ .replace(/\\{\\{\\s*item\\s*\\}\\}/g, typeof item === 'object' ? JSON.stringify(item) : String(item))
54
+ .replace(/\\{\\{\\s*item\\.(\\w+)\\s*\\}\\}/g, (_, prop) => {
55
+ return typeof item === 'object' && item !== null ? String(item[prop] ?? '') : '';
56
+ })
57
+ .replace(/\\{\\{\\s*index\\s*\\}\\}/g, String(i));
58
+
59
+ div.innerHTML = html;
60
+ viewport.appendChild(div);
61
+ }
62
+ }
63
+
64
+ container.addEventListener('scroll', function() {
65
+ requestAnimationFrame(() => renderItems(container.scrollTop));
66
+ });
67
+
68
+ // Expose API
69
+ container.__virtualList = {
70
+ scrollToIndex: function(index) {
71
+ container.scrollTop = index * itemHeight;
72
+ },
73
+ refresh: function() {
74
+ renderItems(container.scrollTop);
75
+ }
76
+ };
77
+ })();
78
+ </script>
79
+ `})}function R(){return`
80
+ .virtual-list-container {
81
+ position: relative;
82
+ overflow-y: auto;
83
+ overflow-x: hidden;
84
+ }
85
+
86
+ .virtual-list-container::-webkit-scrollbar {
87
+ width: 8px;
88
+ }
89
+
90
+ .virtual-list-container::-webkit-scrollbar-track {
91
+ background: rgba(0, 0, 0, 0.1);
92
+ border-radius: 4px;
93
+ }
94
+
95
+ .virtual-list-container::-webkit-scrollbar-thumb {
96
+ background: rgba(0, 0, 0, 0.3);
97
+ border-radius: 4px;
98
+ }
99
+
100
+ .virtual-list-container::-webkit-scrollbar-thumb:hover {
101
+ background: rgba(0, 0, 0, 0.5);
102
+ }
103
+
104
+ .virtual-list-viewport {
105
+ position: relative;
106
+ width: 100%;
107
+ }
108
+
109
+ .virtual-item {
110
+ position: absolute;
111
+ left: 0;
112
+ right: 0;
113
+ box-sizing: border-box;
114
+ }
115
+
116
+ /* Loading placeholder for items */
117
+ .virtual-item-placeholder {
118
+ background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
119
+ background-size: 200% 100%;
120
+ animation: virtual-shimmer 1.5s infinite;
121
+ }
122
+
123
+ @keyframes virtual-shimmer {
124
+ 0% { background-position: 200% 0; }
125
+ 100% { background-position: -200% 0; }
126
+ }
127
+ `}function k(v,c){let a=null,g=()=>{if(!a)a=L(v(),c);return a};return{visibleItems:()=>{return g().getState().visibleItems},totalHeight:()=>{return g().getState().totalHeight},containerProps:()=>({style:{height:`${c.containerHeight}px`,overflow:"auto",position:"relative"},onScroll:(l)=>{let x=l.target;if(a)a.scrollToOffset(x.scrollTop)}}),itemProps:(l)=>({style:{position:"absolute",top:`${l*c.itemHeight}px`,height:`${c.itemHeight}px`,width:"100%"},"data-index":l}),scrollToIndex:(l)=>{g().scrollToIndex(l)}}}function N(v,c={},a){let g=/@infiniteList\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@loading\s*([\s\S]*?)@endinfiniteList/gi;return v.replace(g,(l,x,d,u,w)=>{let e=x.trim(),t=c[e];if(!t||!Array.isArray(t))return`<!-- infiniteList: items "${e}" not found or not an array -->`;let n={itemHeight:50,containerHeight:400,overscan:3,threshold:100,hasMore:!0};if(d)try{let H=Function(`return ${d.trim()}`)();n={...n,...H}}catch{}let f=`ilist-${Math.random().toString(36).substring(2,9)}`,m=T(`@virtualList(${e}, ${JSON.stringify({itemHeight:n.itemHeight,containerHeight:n.containerHeight,overscan:n.overscan,containerClass:n.containerClass})})${u}@endvirtualList`,c);return m=m.replace("</script>",`
128
+ // Infinite scroll detection
129
+ container.addEventListener('scroll', function() {
130
+ const scrollBottom = container.scrollTop + container.clientHeight;
131
+ const threshold = ${n.threshold};
132
+ const totalHeight = viewport.offsetHeight;
133
+
134
+ if (scrollBottom >= totalHeight - threshold) {
135
+ container.dispatchEvent(new CustomEvent('loadmore', { bubbles: true }));
136
+ }
137
+ });
138
+ </script>`),`
139
+ <div id="${f}" class="infinite-list-wrapper">
140
+ ${m}
141
+ <div class="infinite-list-loading" style="display: none;">
142
+ ${w}
143
+ </div>
144
+ </div>
145
+ `})}function O(v,c={},a){let g=/@virtualGrid\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@endvirtualGrid/gi;return v.replace(g,(l,x,d,u)=>{let w=x.trim(),e=c[w];if(!e||!Array.isArray(e))return`<!-- virtualGrid: items "${w}" not found or not an array -->`;let t={columns:3,rowHeight:100,containerHeight:400,gap:10,overscan:2};if(d)try{let o=Function(`return ${d.trim()}`)();t={...t,...o}}catch{}let n=`vgrid-${Math.random().toString(36).substring(2,9)}`,f=Math.ceil(e.length/t.columns),m=f*(t.rowHeight+(t.gap||0)),H=Math.ceil(t.containerHeight/(t.rowHeight+(t.gap||0))),y=t.overscan||2,I=0,S=Math.min(f-1,H+y),s="";for(let o=I;o<=S;o++)for(let b=0;b<t.columns;b++){let $=o*t.columns+b;if($>=e.length)break;let i=e[$],r=b*(100/t.columns),h=o*(t.rowHeight+(t.gap||0)),p=u.replace(/\{\{\s*item\s*\}\}/g,typeof i==="object"?JSON.stringify(i):String(i)).replace(/\{\{\s*item\.(\w+)\s*\}\}/g,(M,C)=>{if(typeof i==="object"&&i!==null)return String(i[C]??"");return""}).replace(/\{\{\s*index\s*\}\}/g,String($));s+=`
146
+ <div class="virtual-grid-item"
147
+ style="position: absolute; top: ${h}px; left: ${r}%; width: calc(${100/t.columns}% - ${t.gap||0}px); height: ${t.rowHeight}px;"
148
+ data-index="${$}">
149
+ ${p}
150
+ </div>`}return`
151
+ <div id="${n}"
152
+ class="virtual-grid-container"
153
+ style="position: relative; height: ${t.containerHeight}px; overflow-y: auto;">
154
+ <div class="virtual-grid-viewport"
155
+ style="position: relative; height: ${m}px; width: 100%;">
156
+ ${s}
157
+ </div>
158
+ </div>
159
+ <script data-virtual-grid="${n}">
160
+ (function() {
161
+ const container = document.getElementById('${n}');
162
+ if (!container) return;
163
+
164
+ const viewport = container.querySelector('.virtual-grid-viewport');
165
+ const columns = ${t.columns};
166
+ const rowHeight = ${t.rowHeight};
167
+ const gap = ${t.gap||0};
168
+ const totalItems = ${e.length};
169
+ const overscan = ${y};
170
+ const containerHeight = ${t.containerHeight};
171
+ const items = ${JSON.stringify(e)};
172
+ const template = ${JSON.stringify(u.trim())};
173
+
174
+ let lastStartRow = 0;
175
+
176
+ function renderItems(scrollTop) {
177
+ const startRow = Math.max(0, Math.floor(scrollTop / (rowHeight + gap)) - overscan);
178
+ const visibleRowCount = Math.ceil(containerHeight / (rowHeight + gap));
179
+ const endRow = Math.min(Math.ceil(totalItems / columns) - 1, startRow + visibleRowCount + overscan * 2);
180
+
181
+ if (startRow === lastStartRow) return;
182
+ lastStartRow = startRow;
183
+
184
+ viewport.innerHTML = '';
185
+
186
+ for (let row = startRow; row <= endRow; row++) {
187
+ for (let col = 0; col < columns; col++) {
188
+ const index = row * columns + col;
189
+ if (index >= totalItems) break;
190
+
191
+ const item = items[index];
192
+ const div = document.createElement('div');
193
+ div.className = 'virtual-grid-item';
194
+ div.style.cssText = 'position: absolute; top: ' + (row * (rowHeight + gap)) + 'px; left: ' + (col * (100 / columns)) + '%; width: calc(' + (100 / columns) + '% - ' + gap + 'px); height: ' + rowHeight + 'px;';
195
+ div.dataset.index = index;
196
+
197
+ let html = template
198
+ .replace(/\\{\\{\\s*item\\s*\\}\\}/g, typeof item === 'object' ? JSON.stringify(item) : String(item))
199
+ .replace(/\\{\\{\\s*item\\.(\\w+)\\s*\\}\\}/g, (_, prop) => {
200
+ return typeof item === 'object' && item !== null ? String(item[prop] ?? '') : '';
201
+ })
202
+ .replace(/\\{\\{\\s*index\\s*\\}\\}/g, String(index));
203
+
204
+ div.innerHTML = html;
205
+ viewport.appendChild(div);
206
+ }
207
+ }
208
+ }
209
+
210
+ container.addEventListener('scroll', function() {
211
+ requestAnimationFrame(() => renderItems(container.scrollTop));
212
+ });
213
+ })();
214
+ </script>
215
+ `})}var _={createVirtualList:L,processVirtualListDirectives:T,processInfiniteListDirectives:N,processVirtualGridDirectives:O,generateVirtualListCSS:R,useVirtualList:k};
216
+ export{L as Td,T as Ud,R as Vd,k as Wd,N as Xd,O as Yd,_ as Zd};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{xe as a,ye as b}from"./chunk-kjtjbcq4.js";import"./chunk-a3wahyg7.js";export{a as processTeleportDirectives,b as ensureTeleportTargets};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ var d=Object.defineProperty;var e=(a)=>a;function f(a,b){this[a]=e.bind(null,b)}var g=(a,b)=>{for(var c in b)d(a,c,{get:b[c],enumerable:!0,configurable:!0,set:f.bind(b,c)})};var h=import.meta.require;
3
+ export{g as Yu,h as Zu};
@@ -0,0 +1,48 @@
1
+ // @bun
2
+ import{We as q,Xe as J}from"./chunk-6s1kbajm.js";import{Ll as Rt,Zl as Ct,bm as ot,dj as St,em as Dt,fj as j,fm as Pt,rg as O,sj as bt,uj as yt,xm as $t,yj as nt,zj as it}from"./chunk-tpfgntwj.js";import{in as At}from"./chunk-jff6j9y3.js";import{Un as H}from"./chunk-brpgjyqg.js";import{Lo as z}from"./chunk-5mxby3fd.js";import{Zu as Nt}from"./chunk-a3wahyg7.js";import T from"fs";import g from"path";import Y from"fs";import Mt from"path";var N="resources/assets",Z="assets";function K(t=process.cwd()){let n=Mt.resolve(t,N);return Y.existsSync(n)&&Y.statSync(n).isDirectory()?n:null}import{createHash as Ot}from"crypto";function Q(t){return Ot("sha256").update(t).digest("hex").slice(0,8)}function tt(t=!1){let n=t?J():q(),i=Q(n);return{content:n,filename:`runtime.${i}.js`,hash:i}}function et(){let t=z(),n=Q(t);return{content:t,filename:`router.${n}.js`,hash:n}}function xe(t){return{runtimeTag:t.runtime?`<script src="/__stx/${t.runtime.filename}"></script>`:"",routerTag:t.router?`<script src="/__stx/${t.router.filename}"></script>`:"",cssTag:t.css?`<link rel="stylesheet" href="/__stx/${t.css.filename}">`:""}}import gt from"path";import k from"path";var jt=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function It(t,n,i){let e={fullTag:i,content:n,attrs:t};if(/\bserver\b/.test(t))return{...e,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...e,type:"client"};if(jt.test(n))return{...e,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...e,type:"client"};return{...e,type:"server"}}var Lt=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function rt(t){let n=[],i=[],e=[],r=0;while(r<t.length){let a=t.indexOf("<",r);if(a===-1)break;let c=it(t,a);if(c>a){r=c;continue}let s=nt(t,a);if(s>a){let o=t.slice(a,s),p=Lt.exec(o);if(p){let l=It(p[1],p[2],o);switch(l.type){case"signals":n.push(l);break;case"client":i.push(l);break;case"server":e.push(l);break}}r=s;continue}r=a+(t.startsWith("<!--",a)?4:1)}return{signals:n,client:i,server:e}}var{require:kt}=import.meta,Bt="stx-page-head:",Ft=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,C=null;function Ht(){if(C!==null)return C;try{let{getRouterScript:t}=kt("stx-router");C=`<script>${t()}</script>`}catch{C=""}return C}async function Te(t,n){if(n===!1)return null;if(n&&typeof n==="string"){let e=k.resolve(t,n);if(await Bun.file(e).exists())return e;return null}let i=k.join(t,"app.stx");if(await Bun.file(i).exists())return i;return null}async function ve(t,n){try{let i=await Bun.file(t).text(),e=i,r=i.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(r)e=r[1].trim();let a=rt(i),c=[...a.client.map((d)=>d.fullTag),...a.signals.map((d)=>d.fullTag)],s=[],o=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,p;while((p=o.exec(i))!==null)s.push(p[0]);let l=e;for(let d of a.server)l=l.replace(d.fullTag,"");for(let d of a.client)l=l.replace(d.fullTag,"");l=l.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let f="<!--__STX_PAGE_SLOT__-->";if(l=l.replace(/<slot\s*\/>/gi,f).replace(/<slot\s*>\s*<\/slot>/gi,f),!l.includes(f))return console.warn(`[stx] Shell ${t} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:m,extractVariables:b,defaultConfig:v,loadStxConfig:w}=await import("./chunk-kxp888dn.js"),y=await w(),x={__filename:t,__dirname:k.dirname(t)};for(let d of c){let _=d.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(_&&!d.includes("client")&&!d.includes('type="module"'))await b(_[1],x,t)}let $=await m(l,x,t,{...v,...y,...n},new Set),S=$.indexOf(f);if(S===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:$.substring(0,S),afterSlot:$.substring(S+f.length),filePath:t,shellScripts:c,shellStyles:s}}catch(i){return console.error(`[stx] Error processing shell ${t}:`,i),null}}function Ee(t,n,i){let e,r="",a=n.match(Ft);if(a){n=n.replace(a[0],"");try{let p=Buffer.from(a[1],"base64").toString("utf8"),l=p.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(l)e=l[1].trim();r=p.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let c=i||e||"stx App",s=Ht(),o="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>${c}</title>
8
+ ${r?` ${r}
9
+ `:""} ${t.shellStyles.join(`
10
+ `)}
11
+ </head>
12
+ <body>
13
+ ${t.beforeSlot}
14
+ <div data-stx-content>${n}</div>
15
+ ${t.afterSlot}
16
+ ${t.shellScripts.filter((p)=>!p.includes("server")).join(`
17
+ `)}
18
+ ${o}
19
+ ${s}
20
+ </body>
21
+ </html>`}function D(t,n={}){let i=t.trim();if(!ot(i))return t;let e=[],r=i.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(r){let o=r[1],p=/<style\b[^>]*>[\s\S]*?<\/style>/gi,l;while((l=p.exec(o))!==null)e.push(l[0])}if(n.preserveHead&&r){let o=[],p=/<title\b[^>]*>[\s\S]*?<\/title>|<meta\b[^>]*>|<link\b[^>]*>/gi,l;while((l=p.exec(r[1]))!==null){if(/<meta\b[^>]*(?:\bcharset|name="viewport")/i.test(l[0]))continue;o.push(l[0])}if(o.length>0)e.unshift(`<!--${Bt}${Buffer.from(o.join(`
22
+ `),"utf8").toString("base64")}-->`)}let a=i.match(/<body\b[^>]*>/i),c=i.lastIndexOf("</body>");if(a&&c!==-1){let o=a.index+a[0].length,p=i.slice(o,c).trim();if(e.length>0)return e.join(`
23
+ `)+`
24
+ `+p;return p}let s=i;if(s=s.replace(/<!DOCTYPE\b[^>]*>/i,""),s=s.replace(/<html\b[^>]*>/i,""),s=s.replace(/<\/html\s*>/i,""),r)s=s.replace(/<head\b[^>]*>[\s\S]*?<\/head>/i,e.join(`
25
+ `));return s=s.replace(/<body\b[^>]*>/i,""),s=s.replace(/<\/body\s*>/i,""),s.trim()}function Ae(t){return t.headers.get("X-STX-Router")==="true"}function st(t,n="main"){let i=t.trim(),e=[],r=[],a=i.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(a){let S=a[1],d=/<style\b[^>]*>[\s\S]*?<\/style>/gi,_;while((_=d.exec(S))!==null)e.push(_[0]);let E=/<script\b[^>]*data-stx-route-params[^>]*>[\s\S]*?<\/script>/gi;while((_=E.exec(S))!==null)r.push(_[0])}let c=n.replace(/^[.#]/,"").toLowerCase(),s=new RegExp(`<${c}\\b[^>]*>`,"i"),o=i.match(s);if(!o||o.index===void 0)return D(t);let p=o.index+o[0].length,l=new RegExp(`<${c}\\b[^>]*>`,"gi"),f=new RegExp(`</${c}\\s*>`,"gi");l.lastIndex=p,f.lastIndex=p;let m=1,b=-1;while(m>0){let S=l.exec(i),d=f.exec(i);if(!d)break;if(S&&S.index<d.index)m++,f.lastIndex=S.index+S[0].length;else if(m--,b=d.index,m>0)l.lastIndex=d.index+d[0].length}if(b===-1)return D(t);let v=i.slice(p,b).trim(),w=[],y=i.match(/<body\b[^>]*>/i),x=i.lastIndexOf("</body>");if(y&&y.index!==void 0&&x!==-1){let S=[[y.index+y[0].length,o.index],[b+`</${c}>`.length,x]],d=/<script\b[^>]*>[\s\S]*?<\/script>/gi;for(let[_,E]of S){if(_>=E)continue;let I=i.slice(_,E),R;d.lastIndex=0;while((R=d.exec(I))!==null)w.push(R[0])}}let $=[];if(e.length>0)$.push(e.join(`
26
+ `));if(r.length>0)$.push(r.join(`
27
+ `));if(w.length>0)$.push(w.join(`
28
+ `));return $.push(v),$.join(`
29
+ `)}import{createHash as le}from"crypto";var lt=/<script(\s[^>]*)?>([\s\S]*?)<\/script>/gi;function Vt(t){let n=(i)=>i.replace(/[^\n]/g," ");return t.replace(/<!--[\s\S]*?-->/g,n).replace(/\{\{--[\s\S]*?--\}\}/g,n)}function Gt(t){let n=[],i=Vt(t);lt.lastIndex=0;let e;while((e=lt.exec(i))!==null){let r=(e[1]||"").trim(),a=(e[0].match(/^<script(?:\s[^>]*)?>/i)?.[0]??"<script>").length,c=(e[0].match(/<\/script\s*>$/i)?.[0]??"</script>").length,s=e.index+a,o=e.index+e[0].length-c,p=t.slice(s,o);if(/\bsrc\s*=/.test(r))continue;let l=r.match(/\btype\s*=\s*["']([^"']+)["']/i);if(l&&!/^(?:module|text\/(?:javascript|typescript))$/i.test(l[1]))continue;let f=/\bserver\b/.test(r)?"server":/\bclient\b/.test(r)?"client":"plain",m=P(t,s);n.push({kind:f,code:p,startLine:m,attrs:r})}return n}function P(t,n){let i=1;for(let e=0;e<n&&e<t.length;e++)if(t.charCodeAt(e)===10)i++;return i}function B(t,n){let i=t.lastIndexOf(`
30
+ `,n-1)+1;return n-i+1}function dt(t){let n=t.split(""),i=(r,a)=>{for(let c=r;c<a&&c<n.length;c++)if(n[c]!==`
31
+ `)n[c]=" "},e=[/<script(?:\s[^>]*)?>[\s\S]*?<\/script>/gi,/<style(?:\s[^>]*)?>[\s\S]*?<\/style>/gi,/<!--[\s\S]*?-->/g,/\{\{--[\s\S]*?--\}\}/g,/@verbatim\b[\s\S]*?@endverbatim\b/g];for(let r of e){r.lastIndex=0;let a;while((a=r.exec(t))!==null)i(a.index,a.index+a[0].length)}return n.join("")}function Xt(t){let n=0,i="";for(let e=0;e<t.length;e++){let r=t[e];if(i){if(r==="\\"){e++;continue}if(r===i)i="";continue}if(r==='"'||r==="'"||r==="`"){i=r;continue}if(r==="("||r==="["||r==="{"){n++;continue}if(r===")"||r==="]"||r==="}"){n--;continue}if(r==="|"&&n===0){if(t[e+1]==="|"){e++;continue}if(t[e-1]==="|")continue;return t.slice(0,e)}}return t}var mt=new Set([":for","x-for","v-for"]),M=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,F="__stx_interpolated",ct="__StxElement",ht="__StxTemplateValue",Wt=`type ${ht}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function at(t){return t.replace(/\{\{[\s\S]*?\}\}/g,F).replace(/\{!![\s\S]*?!!\}/g,F)}function Me(t){return t.replace(/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/g,(n)=>{let i=n.split(`
32
+ `).length-1,e=n.length-i;return`0${" ".repeat(Math.max(0,e-1))}${`
33
+ `.repeat(i)}`})}var Ut=["foreach","endforeach","forelse","endforelse","for","endfor","while","endwhile","empty","if","elseif","else","endif","unless","endunless","isset","endisset","switch","case","default","endswitch","auth","endauth","guest","endguest","env","endenv","once","endonce","break","continue"],Yt=new RegExp(String.raw`^[ \t]*@(?:${Ut.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");function Oe(t){return t.replace(Yt,(n)=>n.replace(/[^\n]/g," "))}var pt=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);function Zt(t){let n=dt(t),i=[],e=/(@?)\{\{([\s\S]*?)\}\}|(@?)\{!!([\s\S]*?)!!\}/g,r;while((r=e.exec(n))!==null){if(r[1]||r[3])continue;let a=r[2]??r[4]??"",c=r[2]!==void 0?2:3,s=Xt(a);if(!s.trim())continue;let o=r.index+c+(s.length-s.trimStart().length);i.push({code:s.trim(),line:P(n,o),column:B(n,o),kind:"interpolation"})}M.lastIndex=0;while((r=M.exec(n))!==null){let a=r[1],c=r[3]??"",s=a.replace(/\..*$/,"").replace(/^([^:].*?):.*$/,"$1");if(pt.has(s)||pt.has(a))continue;if(!c.trim())continue;let o=r.index+r[0].indexOf(r[2],r[0].indexOf(a)+a.length)+1;if(mt.has(s)){let l=c.match(/\s+(?:in|of)\s+/);if(!l||l.index===void 0)continue;let f=c.slice(l.index+l[0].length),m=l.index+l[0].length+(f.length-f.trimStart().length);i.push({code:at(f.trim()),line:P(n,o+m),column:B(n,o+m),kind:"directive",attribute:s});continue}let p=c.length-c.trimStart().length;i.push({code:at(c.trim()),line:P(n,o+p),column:B(n,o+p),kind:"directive",attribute:s})}return i.sort((a,c)=>a.line-c.line||a.column-c.column),i}function Kt(t){let n=new Map,i=(s,o)=>{let p=s.split(/[,[\]{}()\s]+/).filter(Boolean);for(let l of p){let f=l.replace(/^\.\.\./,"").trim();if(!/^\$?[A-Z_$][\w$]*$/i.test(f))continue;let m=p.length===1?o:void 0,b=n.get(f);if(!b)n.set(f,{name:f,iterable:m});else if(b.iterable!==m)b.iterable=void 0}},e=/^\$?[A-Z_$][\w$]*$/i,r=(s)=>{let o=s.trim();return e.test(o)?o:void 0};for(let s of t.matchAll(/@for(?:each|else)\s*\(([\s\S]*?)\)/g)){let o=s[1].match(/^([\s\S]*?)\bas\b([\s\S]*)$/);if(!o)continue;i(o[2].replace(/=>/g," "),r(o[1]))}for(let s of t.matchAll(/@for\s*\(\s*(?:let|const|var)\s+([\w$]+)/g))i(s[1]);let a=dt(t);M.lastIndex=0;let c;while((c=M.exec(a))!==null){let s=c[1].replace(/\..*$/,"");if(!mt.has(s))continue;let o=c[3].match(/\s+(?:in|of)\s+/);if(!o||o.index===void 0)continue;i(c[3].slice(0,o.index),r(c[3].slice(o.index+o[0].length)))}for(let s of t.matchAll(/@(?:php|js|ts)\b([\s\S]*?)@end(?:php|js|ts)\b/g))for(let o of s[1].matchAll(/\b(?:const|let|var|function|class)\s+([\w$]+)/g))i(o[1]);return[...n.values()].sort((s,o)=>s.name.localeCompare(o.name))}function A(t){let n=new Set;for(let i of t.matchAll(/^\s*(?:export\s+)?(?:const|let|var)\s+([\w$]+)/gm))n.add(i[1]);for(let i of t.matchAll(/^\s*(?:export\s+)?(?:async\s+)?function\s*\*?\s*([\w$]+)/gm))n.add(i[1]);for(let i of t.matchAll(/^\s*(?:export\s+)?class\s+([\w$]+)/gm))n.add(i[1]);for(let i of t.matchAll(/^\s*(?:export\s+)?(?:const|let|var)\s*[[{]([^\]}]*)[\]}]/gm))for(let e of i[1].split(",")){let r=e.split(":").pop().split("=")[0].replace(/^\.\.\./,"").trim();if(/^[A-Z_$][\w$]*$/i.test(r))n.add(r)}return[...n].sort()}function zt(){return["declare var window: any",...H.map((t)=>`declare var ${t}: any`)].join(`
34
+ `)}var qt=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore"];function Jt(){return qt.map((t)=>`declare var ${t}: any`).join(`
35
+ `)}function xt(t){let n=/\bdefineClientPayload\s*\(\s*\{([\s\S]*?)\}\s*\)/g,i,e=!1,r=new Set,a=O(t);while((i=n.exec(a))!==null){e=!0;for(let c of Qt(i[1])){let s=c.split(":")[0].trim();if(/^[A-Za-z_$][\w$]*$/.test(s))r.add(s)}}return e?[...r]:null}function Qt(t){let n=[],i=0,e="";for(let r of t){if(r===","&&i===0){n.push(e),e="";continue}if(r==="("||r==="["||r==="{")i++;else if(r===")"||r==="]"||r==="}")i--;e+=r}return n.push(e),n.filter((r)=>r.trim().length>0)}function te(t){let n=/^[ \t]*import\b[\s\S]*?(?:from\s*['"][^'"]*['"]|['"][^'"]*['"])[ \t]*;?[ \t]*$/gm,i=[],e=t.replace(n,(r)=>{return i.push(r.trim()),r.split(`
36
+ `).map(()=>"").join(`
37
+ `)});return{imports:i.join(`
38
+ `),body:e}}function je(t){let n=xt(t);if(!n){let c=A(t);if(c.length===0)return"";return["",`// ${ie}`,...c.map((s)=>`declare var ${s}: any`)].join(`
39
+ `)}if(n.length===0)return"";let{imports:i,body:e}=te(t),r=e.replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class)\b)/gm,""),a=["",`// ${ne}`];if(i)a.push(i);return a.push(`async function ${ut}() {`,r,` return { ${n.join(", ")} }`,"}",`type ${ft} = Awaited<ReturnType<typeof ${ut}>>`,...n.map((c)=>`declare var ${c}: ${ft}[${JSON.stringify(c)}]`)),a.join(`
40
+ `)}function ee(t){let n=O(t).split(""),i=0;for(let e=0;e<n.length;e++){let r=n[e];if(r==="{"||r==="("||r==="["){i++;continue}if(r==="}"||r===")"||r==="]"){i=Math.max(0,i-1);continue}if(i>0&&r!==`
41
+ `)n[e]=" "}return A(n.join(""))}function Ie(t,n){if(xt(t)!==null)return[];let i=O(n),e=new Set(H);return ee(t).filter((r)=>{if(e.has(r))return!1;if(A(n).includes(r))return!1;return new RegExp(`(?<![.#\\w$])${r}(?![\\w$])`).test(i)})}var ne="stx: types for the declared client payload (#1868)",ie="stx: untyped bridge names \u2014 declare a defineClientPayload to check these (#1868)",ut="__stxServerScope",ft="__StxClientPayload";var re=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","$errors","$csrf","props","slot"];var oe=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;function se(t){let n=t.code.trim();if(!n)return null;if(t.attribute?.startsWith("@")){if(oe.test(n))return null;let e=";(($event: any): void => { ";return{text:`${e}${n} });`,prefixLength:e.length}}let i=";void ((";return{text:`${i}${n}));`,prefixLength:i.length}}function Le(t,n={}){let i=Gt(t),e=t.split(`
42
+ `),r=Array.from({length:e.length},()=>""),a=new Map;for(let s of i)s.code.split(`
43
+ `).forEach((o,p)=>{let l=s.startLine-1+p;if(l<r.length)r[l]=o});let c=(s,o)=>{if(r.push(s),o)a.set(r.length,o)};if(n.globals!==!1){if(c(""),n.runtimeGlobals!==!1)for(let o of zt().split(`
44
+ `))c(o);for(let o of Jt().split(`
45
+ `))c(o);for(let o of re)c(`declare var ${o}: any`);c(`declare var ${F}: any`);let s=new Set(i.flatMap((o)=>A(o.code)));c(`type ${ct}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);for(let o of Kt(t)){if(s.has(o.name))continue;let p=o.iterable&&s.has(o.iterable)?`${ct}<typeof ${o.iterable}>`:"any";c(`declare var ${o.name}: ${p}`)}}if(n.templateExpressions!==!1){let s=Zt(t).map((o)=>({expression:o,statement:se(o)})).filter((o)=>o.statement!==null);if(s.length>0){let o=[...new Set(i.flatMap((l)=>A(l.code)))].filter((l)=>/^[A-Z_$][\w$]*$/i.test(l)),p=0;if(o.length>0){c(Wt);for(let l of o)c(`type __StxT_${l} = ${ht}<typeof ${l}>`);c(`;((${o.map((l)=>`${l}: __StxT_${l}`).join(", ")}) => {`),p=1}for(let{expression:l,statement:f}of s){let m=" ".repeat(p);c(m+f.text,{line:l.line,column:l.column,expression:l,prefixLength:f.prefixLength+m.length})}if(p>0)c("});")}}return c("export {}"),{text:r.join(`
46
+ `),lineMap:a,sourceLineCount:e.length}}function Ne(t,n,i){let e=t.lineMap.get(n);if(!e)return n<=t.sourceLineCount?{line:n,column:i}:null;let r=Math.max(0,i-1-(e.prefixLength??0));return{line:e.line,column:e.column+r,expression:e.expression}}function ce(t={}){let n=new Set;return{context:new Proxy(t,{get(i,e){if(e in i)return i[e];if(typeof e==="string"&&!e.startsWith("__"))n.add(e);return},has(i,e){if(e in i)return!0;if(typeof e==="string"&&!e.startsWith("__"))n.add(e);return!1}}),accessedKeys:n}}async function _t(t,n,i={}){let e=gt.resolve(t),r=await Bun.file(e).text(),a=le("sha256").update(r).digest("hex").slice(0,16);bt();let c={};try{c=await j()}catch{}let s=[],o=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,p;while((p=o.exec(r))!==null){let x=p[1];if(/\bserver\b/.test(x))s.push(p[2])}let l=new Set(s.flatMap((x)=>A(x))),{context:f}=ce({__filename:e,__dirname:gt.dirname(e),__stx_serverDeclared:l}),m=new Set,b={...St,...c,...i,buildMode:"compile",strict:!1},v=await $t(r,f,e,b,m),w=D(v),y=yt();return{route:n,sourceFile:t,html:v,fragment:w,placeholders:y,hasServerScripts:s.length>0,serverScriptContent:s,dependencies:Array.from(m),contentHash:a,streamTemplates:f.__streamTemplates}}import V from"fs";import wt from"path";function Tt(t,n,i){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:i}}function vt(t,n){let i=wt.join(n,"manifest.json");V.writeFileSync(i,JSON.stringify(t,null,2))}function Je(t){let n=wt.join(t,"manifest.json");if(!V.existsSync(n))return null;try{let i=V.readFileSync(n,"utf-8"),e=JSON.parse(i);if(e.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${e.version}`),null;return e}catch(i){return console.warn("[stx] Failed to load manifest:",i),null}}var ae=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function Et(t,n){let i=0,e=0;if(!T.existsSync(t))return{copied:i,bytes:e};T.mkdirSync(n,{recursive:!0});function r(a,c){let s=T.readdirSync(a,{withFileTypes:!0});for(let o of s){if(ae.has(o.name))continue;let p=g.join(a,o.name),l=g.join(c,o.name);if(o.isDirectory())T.mkdirSync(l,{recursive:!0}),r(p,l);else if(o.isFile()){if(T.existsSync(l))continue;T.copyFileSync(p,l),i++,e+=T.statSync(l).size}}}return r(t,n),{copied:i,bytes:e}}async function dn(t={}){let n=Date.now(),i=g.resolve(t.root||process.cwd()),e=g.resolve(i,t.outputDir||".output");console.log("[stx build] Starting production build...");let r={};try{r=await j()}catch{}let a=t.componentsDir??r.componentsDir??"components",c=t.partialsDir??r.partialsDir??"partials",s=t.layoutsDir??r.layoutsDir??"layouts",o=t.publicDir??r.publicDir??"public",p=r.app?.head||{},l=r.app?.colorMode,f=r.router?.container||"main";if(T.existsSync(e))T.rmSync(e,{recursive:!0});let m=[g.join(e,"public","__stx"),g.join(e,"public","assets"),g.join(e,"server","pages"),g.join(e,"server","fragments")];for(let h of m)T.mkdirSync(h,{recursive:!0});console.log("[stx build] Discovering routes...");let b=Pt(i),v=["components","layouts","partials"],w=b.filter((h)=>{return!v.some((u)=>h.pattern.startsWith(`/${u}/`)||h.pattern===`/${u}`)});console.log(`[stx build] Found ${w.length} page routes (${b.length-w.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let y=tt(t.debug),x=et();await Bun.write(g.join(e,"public","__stx",y.filename),y.content),await Bun.write(g.join(e,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${y.filename} (${(y.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${x.filename} (${(x.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let $=[],S=[];for(let h of w)try{let u=await _t(h.filePath,h.pattern,{componentsDir:a,partialsDir:c,layoutsDir:s,debug:t.debug});if($.push(u),u.html=u.html.replace(/runtime\.__STX_HASH__\.js/g,y.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),u.html=Dt(u.html,p,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...l&&{colorMode:l}}),l)u.html=Rt(u.html,l);if(p.htmlAttrs)u.html=Ct(u.html,p.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(u.html)){let L=u.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(L&&L[1]){let U=L[1];u.html=u.html.replace(" "+U,""),u.html=u.html.replace(/<body([^>]*)>/,`<body$1 ${U}>`)}}u.html=u.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),u.html=await At(u.html),u.fragment=st(u.html,f);let G=h.pattern==="/"?"index":h.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),X=g.join("server","pages",`${G}.compiled.json`),W=g.join("server","fragments",`${G}.html`);await Bun.write(g.join(e,X),JSON.stringify(u,null,2)),await Bun.write(g.join(e,W),u.fragment),S.push({pattern:h.pattern,compiledPath:X,fragmentPath:W,isDynamic:u.hasServerScripts,hasParams:h.pattern.includes(":")||h.pattern.includes("[")}),console.log(`[stx build] \u2713 ${h.pattern}`)}catch(u){console.error(`[stx build] \u2717 ${h.pattern}:`,u instanceof Error?u.message:u)}let d=g.resolve(i,o);if(T.existsSync(d)){let{copied:h,bytes:u}=Et(d,g.join(e,"public"));if(h>0)console.log(`[stx build] Copied ${h} public asset${h===1?"":"s"} (${(u/1024).toFixed(1)}KB) from ${o}/`)}let _=K(i);if(_){let{copied:h,bytes:u}=Et(_,g.join(e,"public",Z));if(h>0)console.log(`[stx build] Copied ${h} asset${h===1?"":"s"} (${(u/1024).toFixed(1)}KB) from ${N}/`)}let E={runtime:y.filename,router:x.filename},I=Tt(S,E,e);vt(I,e);let R=Date.now()-n;return console.log(`
47
+ [stx build] Done in ${R}ms \u2014 ${$.length} pages compiled`),{pageCount:$.length,assets:E,outputDir:e,duration:R}}
48
+ export{It as u,rt as v,Te as w,ve as x,Ee as y,D as z,Ae as A,st as B,Z as C,K as D,Q as E,tt as F,et as G,xe as H,Gt as I,Me as J,Oe as K,Zt as L,Jt as M,je as N,Ie as O,Le as P,Ne as Q,_t as R,Tt as S,vt as T,Je as U,dn as V};