@stacksjs/bun-router 0.1.7 → 0.1.8

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-4wd1d6ay.js +416 -0
  2. package/dist/{chunk-nf3kv7kv.js → chunk-8rrs7556.js} +1 -1
  3. package/dist/{chunk-3y4gaz7v.js → chunk-m4aaj9ay.js} +1 -1
  4. package/dist/cli.js +30 -59
  5. package/dist/container/index.js +1 -1
  6. package/dist/index.js +2 -2
  7. package/package.json +9 -1
  8. package/dist/chunk-03m2j6h7.js +0 -2
  9. package/dist/chunk-08cw7ejr.js +0 -3
  10. package/dist/chunk-0e4g0fyv.js +0 -62
  11. package/dist/chunk-0mmn02yw.js +0 -2
  12. package/dist/chunk-126c9qm3.js +0 -2
  13. package/dist/chunk-12p13817.js +0 -2
  14. package/dist/chunk-14v65c37.js +0 -4
  15. package/dist/chunk-1b6a7t3v.js +0 -231
  16. package/dist/chunk-1wenkmk0.js +0 -2
  17. package/dist/chunk-2152npfd.js +0 -2
  18. package/dist/chunk-26w23krx.js +0 -2
  19. package/dist/chunk-2g8m379z.js +0 -10
  20. package/dist/chunk-2rr178et.js +0 -1654
  21. package/dist/chunk-2w8f3swz.js +0 -29
  22. package/dist/chunk-4r1x4afz.js +0 -12
  23. package/dist/chunk-4wyw66zk.js +0 -2
  24. package/dist/chunk-4z5sf8ag.js +0 -2
  25. package/dist/chunk-58tfvayh.js +0 -4
  26. package/dist/chunk-5be9x5cq.js +0 -3
  27. package/dist/chunk-5dp83qcx.js +0 -397
  28. package/dist/chunk-5f0d9j9a.js +0 -2
  29. package/dist/chunk-5z52b0fc.js +0 -28
  30. package/dist/chunk-5zrnk2kq.js +0 -4
  31. package/dist/chunk-6bbmkwng.js +0 -3
  32. package/dist/chunk-6dmqtdnq.js +0 -2
  33. package/dist/chunk-6e91956t.js +0 -3
  34. package/dist/chunk-6rv8w5jk.js +0 -2
  35. package/dist/chunk-6x1feysm.js +0 -3
  36. package/dist/chunk-7qnxdedn.js +0 -321
  37. package/dist/chunk-7y72hm1x.js +0 -2
  38. package/dist/chunk-8hbhfh6b.js +0 -194
  39. package/dist/chunk-8kfzygg5.js +0 -3
  40. package/dist/chunk-8wpj3fqe.js +0 -351
  41. package/dist/chunk-8wydx2we.js +0 -2
  42. package/dist/chunk-8zjnjvv7.js +0 -2
  43. package/dist/chunk-9805tt8n.js +0 -341
  44. package/dist/chunk-988h4bzr.js +0 -2
  45. package/dist/chunk-9b6a58ac.js +0 -2
  46. package/dist/chunk-a8fcaywb.js +0 -2
  47. package/dist/chunk-bfjwn7yg.js +0 -2
  48. package/dist/chunk-bp2522mm.js +0 -2
  49. package/dist/chunk-brpgjyqg.js +0 -3
  50. package/dist/chunk-bswe62q4.js +0 -48
  51. package/dist/chunk-c3v796c8.js +0 -943
  52. package/dist/chunk-ccqmwdry.js +0 -2
  53. package/dist/chunk-ck0crwnx.js +0 -2
  54. package/dist/chunk-cqgkxcb4.js +0 -2
  55. package/dist/chunk-dntnakjy.js +0 -2
  56. package/dist/chunk-dxg045wj.js +0 -5
  57. package/dist/chunk-e3qej0jr.js +0 -4
  58. package/dist/chunk-ettdpnrw.js +0 -60
  59. package/dist/chunk-ezqwq17j.js +0 -185
  60. package/dist/chunk-ezx3qsez.js +0 -2
  61. package/dist/chunk-f72nnjy4.js +0 -15413
  62. package/dist/chunk-fna5n0ey.js +0 -246
  63. package/dist/chunk-fqhckdt8.js +0 -2
  64. package/dist/chunk-fr6hbx25.js +0 -2
  65. package/dist/chunk-g9cwng6w.js +0 -3
  66. package/dist/chunk-gd3za5x0.js +0 -2
  67. package/dist/chunk-gf28608k.js +0 -2
  68. package/dist/chunk-h1dj6v8q.js +0 -3
  69. package/dist/chunk-hjxe7k2g.js +0 -2
  70. package/dist/chunk-hrkgznbn.js +0 -2
  71. package/dist/chunk-j6h5v0br.js +0 -2
  72. package/dist/chunk-kjtjbcq4.js +0 -71
  73. package/dist/chunk-mgb01qdv.js +0 -14
  74. package/dist/chunk-n24c9whp.js +0 -2
  75. package/dist/chunk-n2j24b0h.js +0 -4540
  76. package/dist/chunk-nhmtg01n.js +0 -84
  77. package/dist/chunk-p0qhpnqh.js +0 -70
  78. package/dist/chunk-p0w1x8y2.js +0 -3
  79. package/dist/chunk-p3dk1w2w.js +0 -216
  80. package/dist/chunk-q4e9pxs7.js +0 -3
  81. package/dist/chunk-q5dv1kyy.js +0 -2
  82. package/dist/chunk-qnqgf9tq.js +0 -2
  83. package/dist/chunk-qvwy1808.js +0 -898
  84. package/dist/chunk-r18f77vc.js +0 -12
  85. package/dist/chunk-r63za1mr.js +0 -2
  86. package/dist/chunk-rft8gw92.js +0 -7851
  87. package/dist/chunk-ryvmyskt.js +0 -4211
  88. package/dist/chunk-sa6mx308.js +0 -2
  89. package/dist/chunk-sw0chtw4.js +0 -4
  90. package/dist/chunk-va0pc7hx.js +0 -2
  91. package/dist/chunk-vcp8dnjq.js +0 -412
  92. package/dist/chunk-vg1erq1q.js +0 -2
  93. package/dist/chunk-vsh4390q.js +0 -358
  94. package/dist/chunk-w0jv49ch.js +0 -11
  95. package/dist/chunk-wm805tte.js +0 -35
  96. package/dist/chunk-xg9xscqz.js +0 -1
  97. package/dist/chunk-xj9h6mc9.js +0 -2
  98. package/dist/chunk-ytvzwrq3.js +0 -51
  99. package/dist/chunk-zde7ebc4.js +0 -288
  100. package/dist/chunk-zmqsv2xy.js +0 -2
@@ -1,321 +0,0 @@
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),r=t.transitionDuration||"0s",a=t.animationDuration||"0s",s=(n)=>{let o=n.match(/^([\d.]+)(s|ms)?$/);if(!o)return 0;let i=parseFloat(o[1]);return(o[2]||"s")==="ms"?i:i*1000};return Math.max(s(r),s(a))}function v(e,t){return new Promise((r)=>{let a=t??u(e);if(a===0){r();return}let s=!1,n=()=>{if(s)return;s=!0,e.removeEventListener("transitionend",o),e.removeEventListener("animationend",o),r()},o=(i)=>{if(i.target===e)n()};e.addEventListener("transitionend",o),e.addEventListener("animationend",o),setTimeout(n,a+50)})}function f(e){e.offsetHeight}async function y(e,t={}){let r=t.name||"stx",a=m(r,t),s=typeof t.duration==="object"?t.duration.enter:t.duration;if(t.onBeforeEnter?.(e),e.classList.add(a.enterFrom),e.classList.add(a.enterActive),f(e),e.classList.remove(a.enterFrom),e.classList.add(a.enterTo),t.onEnter)await new Promise((n)=>{t.onEnter(e,n)});else await v(e,s);e.classList.remove(a.enterActive),e.classList.remove(a.enterTo),t.onAfterEnter?.(e)}async function h(e,t={}){let r=t.name||"stx",a=m(r,t),s=typeof t.duration==="object"?t.duration.leave:t.duration;if(t.onBeforeLeave?.(e),e.classList.add(a.leaveFrom),e.classList.add(a.leaveActive),f(e),e.classList.remove(a.leaveFrom),e.classList.add(a.leaveTo),t.onLeave)await new Promise((n)=>{t.onLeave(e,n)});else await v(e,s);e.classList.remove(a.leaveActive),e.classList.remove(a.leaveTo),t.onAfterLeave?.(e)}function w(e,t={},r){let a=/@transition\s*\(([^)]*)\)([\s\S]*?)@endtransition/gi;return e.replace(a,(s,n,o)=>{let i=p(n),l=i.name||"stx",c=i.duration||300,d=`stx-transition-${Math.random().toString(36).slice(2,9)}`;return`
3
- <div
4
- class="stx-transition-wrapper"
5
- data-transition="${l}"
6
- data-transition-id="${d}"
7
- data-transition-duration="${c}"
8
- ${i.mode?`data-transition-mode="${i.mode}"`:""}
9
- >
10
- ${o.trim()}
11
- </div>
12
- <script>
13
- (function() {
14
- const wrapper = document.querySelector('[data-transition-id="${d}"]');
15
- if (!wrapper) return;
16
-
17
- const name = '${l}';
18
- const duration = ${c};
19
-
20
- // Observe for child changes to trigger transitions
21
- const observer = new MutationObserver(function(mutations) {
22
- mutations.forEach(function(mutation) {
23
- mutation.addedNodes.forEach(function(node) {
24
- if (node.nodeType === 1) {
25
- window.STX?.transition?.enter(node, { name: name, duration: duration });
26
- }
27
- });
28
- mutation.removedNodes.forEach(function(node) {
29
- if (node.nodeType === 1) {
30
- // Leave transition handled before removal
31
- }
32
- });
33
- });
34
- });
35
-
36
- observer.observe(wrapper, { childList: true });
37
-
38
- // Initial enter transition for existing children
39
- Array.from(wrapper.children).forEach(function(child) {
40
- window.STX?.transition?.enter(child, { name: name, duration: duration });
41
- });
42
- })();
43
- </script>
44
- `})}function p(e){let t={},r=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,a;while((a=r.exec(e))!==null){let s=a[1],n=a[2]||a[3]||a[4]||a[5];switch(s){case"name":t.name=n;break;case"duration":t.duration=parseInt(n,10);break;case"mode":t.mode=n;break;case"easing":t.easing=n;break}}return t}function g(){return`
45
- /* STX Transition Presets */
46
-
47
- /* Fade */
48
- .fade-enter-from,
49
- .fade-leave-to {
50
- opacity: 0;
51
- }
52
- .fade-enter-active,
53
- .fade-leave-active {
54
- transition: opacity 0.3s ease;
55
- }
56
- .fade-enter-to,
57
- .fade-leave-from {
58
- opacity: 1;
59
- }
60
-
61
- /* Slide Up */
62
- .slide-up-enter-from,
63
- .slide-up-leave-to {
64
- opacity: 0;
65
- transform: translateY(20px);
66
- }
67
- .slide-up-enter-active,
68
- .slide-up-leave-active {
69
- transition: opacity 0.3s ease, transform 0.3s ease;
70
- }
71
- .slide-up-enter-to,
72
- .slide-up-leave-from {
73
- opacity: 1;
74
- transform: translateY(0);
75
- }
76
-
77
- /* Slide Down */
78
- .slide-down-enter-from,
79
- .slide-down-leave-to {
80
- opacity: 0;
81
- transform: translateY(-20px);
82
- }
83
- .slide-down-enter-active,
84
- .slide-down-leave-active {
85
- transition: opacity 0.3s ease, transform 0.3s ease;
86
- }
87
- .slide-down-enter-to,
88
- .slide-down-leave-from {
89
- opacity: 1;
90
- transform: translateY(0);
91
- }
92
-
93
- /* Slide Left */
94
- .slide-left-enter-from {
95
- opacity: 0;
96
- transform: translateX(20px);
97
- }
98
- .slide-left-leave-to {
99
- opacity: 0;
100
- transform: translateX(-20px);
101
- }
102
- .slide-left-enter-active,
103
- .slide-left-leave-active {
104
- transition: opacity 0.3s ease, transform 0.3s ease;
105
- }
106
- .slide-left-enter-to,
107
- .slide-left-leave-from {
108
- opacity: 1;
109
- transform: translateX(0);
110
- }
111
-
112
- /* Slide Right */
113
- .slide-right-enter-from {
114
- opacity: 0;
115
- transform: translateX(-20px);
116
- }
117
- .slide-right-leave-to {
118
- opacity: 0;
119
- transform: translateX(20px);
120
- }
121
- .slide-right-enter-active,
122
- .slide-right-leave-active {
123
- transition: opacity 0.3s ease, transform 0.3s ease;
124
- }
125
- .slide-right-enter-to,
126
- .slide-right-leave-from {
127
- opacity: 1;
128
- transform: translateX(0);
129
- }
130
-
131
- /* Scale */
132
- .scale-enter-from,
133
- .scale-leave-to {
134
- opacity: 0;
135
- transform: scale(0.9);
136
- }
137
- .scale-enter-active,
138
- .scale-leave-active {
139
- transition: opacity 0.3s ease, transform 0.3s ease;
140
- }
141
- .scale-enter-to,
142
- .scale-leave-from {
143
- opacity: 1;
144
- transform: scale(1);
145
- }
146
-
147
- /* Scale Up (grow) */
148
- .scale-up-enter-from,
149
- .scale-up-leave-to {
150
- opacity: 0;
151
- transform: scale(0.5);
152
- }
153
- .scale-up-enter-active,
154
- .scale-up-leave-active {
155
- transition: opacity 0.3s ease, transform 0.3s ease;
156
- }
157
- .scale-up-enter-to,
158
- .scale-up-leave-from {
159
- opacity: 1;
160
- transform: scale(1);
161
- }
162
-
163
- /* Bounce */
164
- .bounce-enter-active {
165
- animation: bounce-in 0.5s;
166
- }
167
- .bounce-leave-active {
168
- animation: bounce-in 0.5s reverse;
169
- }
170
- @keyframes bounce-in {
171
- 0% {
172
- transform: scale(0);
173
- }
174
- 50% {
175
- transform: scale(1.1);
176
- }
177
- 100% {
178
- transform: scale(1);
179
- }
180
- }
181
-
182
- /* Flip */
183
- .flip-enter-from,
184
- .flip-leave-to {
185
- opacity: 0;
186
- transform: perspective(400px) rotateY(90deg);
187
- }
188
- .flip-enter-active,
189
- .flip-leave-active {
190
- transition: opacity 0.4s ease, transform 0.4s ease;
191
- }
192
- .flip-enter-to,
193
- .flip-leave-from {
194
- opacity: 1;
195
- transform: perspective(400px) rotateY(0);
196
- }
197
-
198
- /* Zoom */
199
- .zoom-enter-from,
200
- .zoom-leave-to {
201
- opacity: 0;
202
- transform: scale(0);
203
- }
204
- .zoom-enter-active,
205
- .zoom-leave-active {
206
- transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
207
- }
208
- .zoom-enter-to,
209
- .zoom-leave-from {
210
- opacity: 1;
211
- transform: scale(1);
212
- }
213
-
214
- /* Collapse (height) */
215
- .collapse-enter-from,
216
- .collapse-leave-to {
217
- opacity: 0;
218
- max-height: 0;
219
- overflow: hidden;
220
- }
221
- .collapse-enter-active,
222
- .collapse-leave-active {
223
- transition: opacity 0.3s ease, max-height 0.3s ease;
224
- overflow: hidden;
225
- }
226
- .collapse-enter-to,
227
- .collapse-leave-from {
228
- opacity: 1;
229
- max-height: 1000px;
230
- }
231
- `}function x(){return`
232
- // STX Transition Runtime
233
- (function() {
234
- if (typeof window === 'undefined') return;
235
-
236
- window.STX = window.STX || {};
237
- window.STX.transition = {
238
- // Perform enter transition
239
- enter: function(el, options) {
240
- options = options || {};
241
- const name = options.name || 'stx';
242
- const duration = options.duration || 300;
243
-
244
- const classes = {
245
- enterFrom: name + '-enter-from',
246
- enterActive: name + '-enter-active',
247
- enterTo: name + '-enter-to'
248
- };
249
-
250
- // Add initial classes
251
- el.classList.add(classes.enterFrom);
252
- el.classList.add(classes.enterActive);
253
-
254
- // Force reflow
255
- void el.offsetHeight;
256
-
257
- // Start transition
258
- el.classList.remove(classes.enterFrom);
259
- el.classList.add(classes.enterTo);
260
-
261
- // Cleanup after transition
262
- setTimeout(function() {
263
- el.classList.remove(classes.enterActive);
264
- el.classList.remove(classes.enterTo);
265
- }, duration + 50);
266
-
267
- return el;
268
- },
269
-
270
- // Perform leave transition
271
- leave: function(el, options) {
272
- return new Promise(function(resolve) {
273
- options = options || {};
274
- const name = options.name || 'stx';
275
- const duration = options.duration || 300;
276
-
277
- const classes = {
278
- leaveFrom: name + '-leave-from',
279
- leaveActive: name + '-leave-active',
280
- leaveTo: name + '-leave-to'
281
- };
282
-
283
- // Add initial classes
284
- el.classList.add(classes.leaveFrom);
285
- el.classList.add(classes.leaveActive);
286
-
287
- // Force reflow
288
- void el.offsetHeight;
289
-
290
- // Start transition
291
- el.classList.remove(classes.leaveFrom);
292
- el.classList.add(classes.leaveTo);
293
-
294
- // Cleanup and resolve after transition
295
- setTimeout(function() {
296
- el.classList.remove(classes.leaveActive);
297
- el.classList.remove(classes.leaveTo);
298
- resolve(el);
299
- }, duration + 50);
300
- });
301
- },
302
-
303
- // Toggle with transition
304
- toggle: function(el, show, options) {
305
- if (show) {
306
- el.style.display = '';
307
- return this.enter(el, options);
308
- }
309
- else {
310
- return this.leave(el, options).then(function() {
311
- el.style.display = 'none';
312
- return el;
313
- });
314
- }
315
- }
316
- };
317
-
318
- console.log('[stx] Transition runtime initialized');
319
- })();
320
- `}function T(e){let t=/@transition\.([a-z-]+)(?:\.(\d+))?="([^"]+)"/gi;return e.replace(t,(r,a,s,n)=>{let o=s||"300",i=`stx-t-${Math.random().toString(36).slice(2,7)}`;return`data-stx-transition="${a}" data-stx-transition-duration="${o}" data-stx-transition-condition="${n}" data-stx-transition-id="${i}"`})}
321
- export{y as ze,h as Ae,w as Be,g as Ce,x as De,T as Ee};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{En as a,Fn as b,Gn as c,Hn as d,In as e,Jn as f,Kn as g,Ln as h,Mn as i,Nn as j,On as k,Pn as l,Qn as m,Rn as n,Sn as o,Tn as p}from"./chunk-58tfvayh.js";import"./chunk-nf3kv7kv.js";export{m as applyHead,h as definePageMeta,a as getHead,b as getPageMeta,e as mergeHeadConfigs,n as processHeadDirective,p as processMetaDirective,o as processTitleDirective,l as renderBodyAttrs,j as renderHead,k as renderHtmlAttrs,c as resetHead,g as seoMetaToHeadConfig,d as useHead,i as usePageTitle,f as useSeoMeta,i as useTitle};
@@ -1,194 +0,0 @@
1
- // @bun
2
- import{Fj as T,Om as k,dj as R,xm as x}from"./chunk-ryvmyskt.js";import{yn as E}from"./chunk-wm805tte.js";import C from"path";var I={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},_=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var q=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function H(e){let t=[],i=0,n;q.lastIndex=0;while((n=q.exec(e))!==null){if(n.index>i){let a=e.slice(i,n.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let s=n[1],r=n[2];t.push({type:"suspense",name:s,content:r}),i=n.index+n[0].length}if(i<e.length){let s=e.slice(i);if(s.trim())t.push({type:t.length===0?"shell":"content",content:s})}if(t.length===0)t.push({type:"shell",content:e});return t}async function W(e,t={},i={}){let n={...R,...i,streaming:{...I,...i.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),y=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),l=y?y[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),u={...t,__filename:e,__dirname:C.dirname(e)};if(l.trim())await E(l,u,e);let p=H(c),m=new Set;if(!p.some((f)=>f.type==="suspense")){let f=n.streaming?.strategy||"auto",g=new RegExp(_.source,"g");if(!(f!=="manual"&&g.test(c))){let o=await x(c,u,e,n,m);for(let d=0;d<o.length;d+=s)r.enqueue(o.slice(d,d+s)),await new Promise((h)=>setTimeout(h,0))}else{let o=[],d=new RegExp(_.source,"g"),h;while((h=d.exec(c))!==null)o.push({name:h[1],content:h[2],start:h.index,end:h.index+h[0].length});let w=0;for(let S of o){if(S.start>w){let v=c.slice(w,S.start);if(v.trim()){let O=await x(v,u,e,n,m);r.enqueue(O),await new Promise((z)=>setTimeout(z,0))}}let b=await x(S.content,u,e,n,m);r.enqueue(b),await new Promise((v)=>setTimeout(v,0)),w=S.end}if(w<c.length){let S=c.slice(w);if(S.trim()){let b=await x(S,u,e,n,m);r.enqueue(b)}}}}else{let f=new Map;for(let o of p)if(o.type==="shell"||o.type==="content"){let d=await x(o.content,u,e,n,m);r.enqueue(d)}else if(o.type==="suspense"&&o.name){let d=`stx-suspense-${o.name}`;r.enqueue(`<div id="${d}" data-suspense="${o.name}" style="display:contents;">
3
- <template data-suspense-fallback>Loading...</template>
4
- </div>`),f.set(o.name,x(o.content,u,e,n,m))}r.enqueue(`
5
- <script>
6
- (function() {
7
- window.__stxSuspense = window.__stxSuspense || {
8
- resolve: function(name, content) {
9
- var el = document.querySelector('[data-suspense="' + name + '"]');
10
- if (el) {
11
- // Create a template to parse the HTML
12
- var template = document.createElement('template');
13
- template.innerHTML = content;
14
- // Replace placeholder with actual content
15
- el.replaceWith(template.content);
16
- }
17
- }
18
- };
19
- })();
20
- </script>`);let g=Array.from(f.entries()).map(async([o,d])=>{r.enqueue(await M(o,d))});await Promise.all(g)}r.close()}catch(a){r.error(a)}}})}async function M(e,t){try{let i=(await t).replace(/`/g,"\\`").replace(/<\/script>/gi,"<\\/script>");return`
21
- <script>
22
- window.__stxSuspense.resolve('${e}', \`${i}\`);
23
- </script>`}catch(i){let n=i instanceof Error?i.message:String(i);return`
24
- <script>
25
- window.__stxSuspense.resolve('${e}', '<div class="stx-error">Error loading content: ${T(n)}</div>');
26
- </script>`}}var A=`
27
- <script>
28
- (function(){
29
- window.__stxSuspense = window.__stxSuspense || {
30
- resolve: function(name, content){
31
- var el = document.querySelector('[data-suspense="' + name + '"]');
32
- if (!el) return;
33
- var t = document.createElement('template');
34
- t.innerHTML = content;
35
- // Keep handles to the inserted nodes \u2014 the fragment is emptied on insert.
36
- var nodes = Array.prototype.slice.call(t.content.childNodes);
37
- el.replaceWith(t.content);
38
- // Hydrate the streamed content so interactive islands/directives inside
39
- // it come alive (no-op when the signals runtime isn't on the page).
40
- if (window.stx && typeof window.stx.hydrate === 'function') {
41
- nodes.forEach(function(n){ if (n.nodeType === 1) window.stx.hydrate(n); });
42
- }
43
- }
44
- };
45
- })();
46
- </script>`;function D(e,t,i){if(!t||t<=0)return e;let n,s=new Promise((r,a)=>{n=setTimeout(()=>a(Error(`streaming boundary "${i}" timed out after ${t}ms`)),t)});return Promise.race([e,s]).finally(()=>clearTimeout(n))}function G(e,t=[],i={}){let n=i.timeoutMs??0;return new ReadableStream({async start(s){try{if(s.enqueue(e),t.length>0)s.enqueue(A),await Promise.all(t.map(async(r)=>{let a=D(r.render(),n,r.id);s.enqueue(await M(r.id,a))}));s.close()}catch(r){s.error(r)}}})}var N=/@stream\s*\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)@endstream/gi;function J(e,t){return e.replace(N,(i,n,s)=>{let r=n.trim(),a=s.split(/@fallback/i),y=a[0].trim(),l=a.length>1?a.slice(1).join("@fallback").trim():"";if(!t.__streamTemplates)t.__streamTemplates={};return t.__streamTemplates[r]=y,`<div data-suspense="${r}">${l}</div>`})}function K(e){let t=e?.streamBoundaries;if(!t||typeof t!=="object")return;let i=Object.entries(t).filter(([,n])=>typeof n==="function");return i.length>0?i.map(([n,s])=>({id:n,render:s})):void 0}async function Q(e,t={},i={}){let n={...R,...i,streaming:{...I,...i.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),y=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),l=y?y[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),u={...t,__filename:e,__dirname:C.dirname(e)};if(l.trim())await E(l,u,e);let p=new Set,m=n.streaming?.strategy||"auto",f=new RegExp(_.source,"g");if(!(m!=="manual"&&f.test(c))){let g=await x(c,u,e,n,p);for(let o=0;o<g.length;o+=s)r.enqueue(g.slice(o,o+s))}else{let g=[],o=new RegExp(_.source,"g"),d;while((d=o.exec(c))!==null)g.push({name:d[1],content:d[2],start:d.index,end:d.index+d[0].length});let h=0;for(let w of g){if(w.start>h){let b=c.slice(h,w.start);if(b.trim()){let v=await x(b,u,e,n,p);r.enqueue(v)}}let S=await x(w.content,u,e,n,p);r.enqueue(S),h=w.end}if(h<c.length){let w=c.slice(h);if(w.trim()){let S=await x(w,u,e,n,p);r.enqueue(S)}}}r.close()}catch(a){r.error(a)}}})}async function Y(e,t={}){let i={...R,...t,streaming:{...I,...t.streaming}},n=await Bun.file(e).text(),s=n.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),r=s?s[1]:"",a=n.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y=a,l={},c;_.lastIndex=0;while((c=_.exec(a))!==null){let p=c[1],m=c[2];l[p]=m}let u=a.replace(_,"");return{renderShell:async(p={})=>{let m={...p,__filename:e,__dirname:C.dirname(e)};return await E(r,m,e),x(u,m,e,i,new Set)},renderSection:async(p,m={})=>{try{if(!l[p])return`<div class="error-message">Section "${T(p)}" not found in template "${T(e)}"</div>`;let f={...m,__filename:e,__dirname:C.dirname(e)};await E(r,f,e);let g=new Set;return await x(l[p],f,e,i,g)}catch(f){let g=f instanceof Error?f.message:String(f);return k("Expression",g,e,l[p]||"",0,l[p]||"")}},getSections:()=>Object.keys(l),getTemplate:()=>y}}var L={name:"suspense",hasEndTag:!0,handler:(e,t,i,n)=>{if(!t||t.length===0)throw Error("Suspense directive requires a name parameter");let s=t[0].replace(/['"`]/g,"");return`<!-- @suspense:${s} -->${e}<!-- @endsuspense:${s} -->`}},j={name:"island",hasEndTag:!0,handler:(e,t,i,n)=>{if(!t||t.length===0)throw Error("Island directive requires a name parameter");let s=t[0].replace(/['"`]/g,""),r=t[1]?t[1].replace(/['"`]/g,""):"lazy",a=`island-${s}-${Math.random().toString(36).substring(2,9)}`,y=e.match(/<script\s+props\s*>([\s\S]*?)<\/script>/i),l=y?y[1].trim():"",c=y?e.replace(y[0],""):e;return`<div data-island="${s}" data-island-id="${a}" data-priority="${r}">
47
- ${c}
48
- <script type="application/json" data-island-props="${a}">
49
- ${l?`{${l}}`:"{}"}
50
- </script>
51
- </div>`}};function Z(e={}){let t=[];if(e.streaming?.enabled)t.push(L);if(e.hydration?.enabled)t.push(j);return t}async function P(e,t,i,n={}){return e}function ee(e,t={}){let i=new TextEncoder,n=e.pipeThrough(new TransformStream({transform(r,a){a.enqueue(i.encode(r))}})),s=new Headers(t.headers);if(!s.has("Content-Type"))s.set("Content-Type","text/html; charset=utf-8");if(!s.has("Transfer-Encoding"))s.set("Transfer-Encoding","chunked");if(!s.has("X-Content-Type-Options"))s.set("X-Content-Type-Options","nosniff");if(!s.has("X-Accel-Buffering"))s.set("X-Accel-Buffering","no");return new Response(n,{...t,headers:s})}function te(e={mode:"full"}){let{mode:t,components:i={},dynamicImports:n=!0}=e,s=Object.entries(i).map(([r,a])=>`'${r}': ${n?`() => import('${a}')`:`require('${a}')`}`).join(`,
52
- `);if(t==="loader")return`
53
- (function() {
54
- window.__stx = window.__stx || {};
55
- window.__stx.islands = new Map();
56
- window.__stx.registerComponent = function(name, component) {
57
- window.__stx.islands.set(name, component);
58
- };
59
- })();`;return`
60
- (function() {
61
- 'use strict';
62
-
63
- // Hydration runtime for stx islands
64
- const stx = {
65
- // Component registry
66
- components: {
67
- ${s}
68
- },
69
-
70
- // Loaded island instances
71
- islands: new Map(),
72
-
73
- // Register a component for hydration
74
- registerComponent: function(name, loader) {
75
- this.components[name] = loader;
76
- },
77
-
78
- // Get props for an island by ID
79
- getIslandProps: function(id) {
80
- const propsScript = document.querySelector('[data-island-props="' + id + '"]');
81
- if (!propsScript) return {};
82
- try {
83
- return JSON.parse(propsScript.textContent || '{}');
84
- }
85
- catch (e) {
86
- console.warn('[stx] Failed to parse island props:', id, e);
87
- return {};
88
- }
89
- },
90
-
91
- // Hydrate a single island
92
- hydrateIsland: async function(element) {
93
- const name = element.dataset.island;
94
- const id = element.dataset.islandId;
95
-
96
- if (!name || this.islands.has(id)) return;
97
-
98
- const loader = this.components[name];
99
- if (!loader) {
100
- console.warn('[stx] Unknown island component:', name);
101
- return;
102
- }
103
-
104
- try {
105
- const component = typeof loader === 'function' ? await loader() : loader;
106
- const props = this.getIslandProps(id);
107
-
108
- // Mark as hydrating
109
- element.dataset.hydrating = 'true';
110
-
111
- // Call component's hydrate method if available
112
- if (component.hydrate) {
113
- await component.hydrate(element, props);
114
- }
115
- else if (component.default && component.default.hydrate) {
116
- await component.default.hydrate(element, props);
117
- }
118
-
119
- // Mark as hydrated
120
- delete element.dataset.hydrating;
121
- element.dataset.hydrated = 'true';
122
- this.islands.set(id, { element, component, props });
123
-
124
- }
125
- catch (error) {
126
- console.error('[stx] Failed to hydrate island:', name, error);
127
- element.dataset.hydrateError = 'true';
128
- }
129
- },
130
-
131
- // Hydrate all islands based on priority
132
- hydrate: function() {
133
- const islands = document.querySelectorAll('[data-island]');
134
-
135
- // Group by priority
136
- const eager = [];
137
- const lazy = [];
138
- const idle = [];
139
-
140
- islands.forEach(function(el) {
141
- const priority = el.dataset.priority || 'lazy';
142
- if (priority === 'eager') eager.push(el);
143
- else if (priority === 'idle') idle.push(el);
144
- else lazy.push(el);
145
- });
146
-
147
- // Hydrate eager immediately
148
- eager.forEach(function(el) { stx.hydrateIsland(el); });
149
-
150
- // Hydrate lazy on intersection
151
- if (lazy.length > 0 && 'IntersectionObserver' in window) {
152
- const observer = new IntersectionObserver(function(entries) {
153
- entries.forEach(function(entry) {
154
- if (entry.isIntersecting) {
155
- observer.unobserve(entry.target);
156
- stx.hydrateIsland(entry.target);
157
- }
158
- });
159
- }, { rootMargin: '50px' });
160
-
161
- lazy.forEach(function(el) { observer.observe(el); });
162
- }
163
- else {
164
- // Fallback: hydrate all lazy immediately
165
- lazy.forEach(function(el) { stx.hydrateIsland(el); });
166
- }
167
-
168
- // Hydrate idle during browser idle time
169
- if (idle.length > 0 && 'requestIdleCallback' in window) {
170
- requestIdleCallback(function() {
171
- idle.forEach(function(el) { stx.hydrateIsland(el); });
172
- });
173
- }
174
- else {
175
- // Fallback: hydrate after a delay
176
- setTimeout(function() {
177
- idle.forEach(function(el) { stx.hydrateIsland(el); });
178
- }, 200);
179
- }
180
- }
181
- };
182
-
183
- // Expose to window
184
- window.__stx = stx;
185
-
186
- // Auto-hydrate on DOMContentLoaded if not SSR
187
- if (document.readyState === 'loading') {
188
- document.addEventListener('DOMContentLoaded', function() { stx.hydrate(); });
189
- }
190
- else {
191
- stx.hydrate();
192
- }
193
- })();`}
194
- export{W as Kf,M as Lf,A as Mf,G as Nf,J as Of,K as Pf,Q as Qf,Y as Rf,L as Sf,j as Tf,Z as Uf,P as Vf,ee as Wf,te as Xf};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{Fj as S}from"./chunk-ryvmyskt.js";import{mn as x,on as w}from"./chunk-wm805tte.js";function E(t,o){let r=1,n=o,e="<template",l="</template";while(n<t.length&&r>0){let s=t.indexOf("<",n);if(s===-1)break;if(n=s,t.startsWith(e,n)&&(n+e.length>=t.length||/[\s>\/]/.test(t[n+e.length]))){r++,n+=e.length;continue}if(t.startsWith(l,n)){let i=t.indexOf(">",n+l.length);if(i!==-1){if(r--,r===0)return i+1;n=i+1;continue}}n++}return r===0?n:-1}var y=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function N(t,o){let r=null;for(let n=o;n<t.length;n++){let e=t[n];if(r){if(e==="\\"){n++;continue}if(e===r)r=null;continue}if(e==='"'||e==="'"){r=e;continue}if(e===">")return n+1}return-1}function z(t){let o=[],r=[],n=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,e=0;while(e<t.length){let l=t.indexOf("<",e);if(l===-1)break;if(t.startsWith("<!--",l)){let u=t.indexOf("-->",l+4);e=u===-1?t.length:u+3;continue}let s=N(t,l+1);if(s===-1)break;let i=t.slice(l,s),a=i.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!a){e=s;continue}let c=a[1]==="/",f=a[2].toLowerCase();if(c){let u=r.lastIndexOf(f);if(u!==-1)r.splice(u);e=s;continue}if(f==="template"&&r.length===0){let u=i.match(n);if(u){let m=E(t,s);if(m!==-1){let p=u[1]||u[2]||u[3];o.push({start:l,end:m,slotName:p,content:t.slice(s,m-11).trim(),propsBinding:u[4]||void 0}),e=m;continue}}}if(!/\/\s*>$/.test(i)&&!y.has(f)){if(r.push(f),f==="script"||f==="style"){let u=t.toLowerCase().indexOf(`</${f}>`,s);if(u!==-1){e=u;continue}}}e=s}return o}function M(t){let o={default:"",named:new Map},r=t,n=z(t);for(let a of n)o.named.set(a.slotName,{name:a.slotName,content:a.content,propsBinding:a.propsBinding});n.sort((a,c)=>c.start-a.start);for(let a of n)r=r.slice(0,a.start)+r.slice(a.end);let e=[],l=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*)>([\s\S]*?)<\/\1>/gi,s;while((s=l.exec(r))!==null){let[a,c,f,u,m,p]=s,d=f.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),h=m.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),g=(d+h).trim(),A=`<${c}${g?" "+g:""}>${p}</${c}>`;e.push({start:s.index,end:s.index+a.length,slotName:u,element:A})}let i=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*?)\/>/gi;while((s=i.exec(r))!==null){let[a,c,f,u,m]=s,p=f.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),d=m.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),h=(p+d).trim(),g=`<${c}${h?" "+h:""} />`;e.push({start:s.index,end:s.index+a.length,slotName:u,element:g})}e.sort((a,c)=>c.start-a.start);for(let a of e){let c=o.named.get(a.slotName);if(c)c.content+=a.element;else o.named.set(a.slotName,{name:a.slotName,content:a.element});r=r.slice(0,a.start)+r.slice(a.end)}return o.default=r.trim(),o}function R(t){let o=t.match(/name\s*=\s*["']([^"']+)["']/),r=o?o[1]:"",n={},e=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,l;while((l=e.exec(t))!==null)n[l[1]]=l[2];let s=t.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),i=s?s[1].trim():"";return{name:r,props:n,defaultContent:i}}async function Z(t,o,r,n){if(!t)return r;let e=t.content;if(t.propsBinding&&Object.keys(o).length>0){let l=t.propsBinding.trim(),s={...n};if(l.startsWith("{")&&l.endsWith("}")){let i=l.slice(1,-1).split(",").map((a)=>a.trim()).filter(Boolean);for(let a of i){let[c,f]=a.split(":").map((m)=>m.trim()),u=f||c;if(o[c]!==void 0)s[u]=o[c]}}else s[l]=o;e=k(e,s)}return e}function k(t,o){return t.replace(/\{\{\s*([^}]+)\s*\}\}/g,(r,n)=>{try{let e=n.trim(),l=b(e,o);return S(String(l??""))}catch{return`{{ ${n} }}`}})}function b(t,o){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test(t)){let n=t.split("."),e=o;for(let l of n)if(e&&typeof e==="object"&&l in e)e=e[l];else return;return e}let r=t.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(r){let[,n,e,l]=r,s=o[n],i=parseInt(l,10);if(typeof s==="number")switch(e){case"+":return s+i;case"-":return s-i;case"*":return s*i;case"/":return s/i}}try{if(!x(t))return;return w(t,Object.keys(o))(...Object.values(o))}catch{return}}async function O(t,o,r){let n=t;n=await v(n,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(l,s,i,a)=>{let c=o.named.get(s),f=a?.trim()||"",u=i||"",m={},p=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,d;while((d=p.exec(u))!==null){let h=d[1],g=d[2];m[h]=b(g,r)}return await Z(c,m,f,r)});let e=/<slot\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return n=n.replace(e,(l,s)=>{if(l.includes("name="))return l;let i=s?.trim()||"";return o.default||i}),n}async function v(t,o,r){let n=[],e=[];t.replace(o,(i,...a)=>{let c=a[a.length-2];return e.push({match:i,index:c}),n.push(r(i,...a.slice(0,-2))),i});let l=await Promise.all(n),s=t;for(let i=e.length-1;i>=0;i--){let{match:a,index:c}=e[i];s=s.slice(0,c)+l[i]+s.slice(c+a.length)}return s}function _(t){let o=M(t);return{defaultSlot:o.default,namedSlots:o.named}}async function T(t,o,r,n){return await O(t,{default:o,named:r},n)}
3
- export{M as o,R as p,Z as q,O as r,_ as s,T as t};