@stacksjs/stx 0.2.195 → 0.2.197

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 (129) hide show
  1. package/dist/chunk-0ae6chzd.js +4 -0
  2. package/dist/chunk-0w0mrtme.js +2 -0
  3. package/dist/chunk-0y46fbkx.js +3 -0
  4. package/dist/chunk-118a77bs.js +4471 -0
  5. package/dist/chunk-12nvcvtn.js +3 -0
  6. package/dist/chunk-14ynv5ah.js +2 -0
  7. package/dist/chunk-1e25ksp6.js +3 -0
  8. package/dist/chunk-1mhc4g86.js +43 -0
  9. package/dist/chunk-1thssz8x.js +2 -0
  10. package/dist/chunk-1yk07x7b.js +2 -0
  11. package/dist/chunk-2zkj69dg.js +13 -0
  12. package/dist/chunk-338316c2.js +2 -0
  13. package/dist/chunk-3952ykhb.js +1655 -0
  14. package/dist/chunk-3es366z4.js +3 -0
  15. package/dist/chunk-3m49eb4v.js +2 -0
  16. package/dist/chunk-3nmpfsw5.js +2 -0
  17. package/dist/chunk-3vy1q9da.js +2 -0
  18. package/dist/chunk-4a4h28pp.js +3022 -0
  19. package/dist/chunk-4pf61rcb.js +2 -0
  20. package/dist/chunk-5anpcnde.js +2 -0
  21. package/dist/chunk-5mkkre22.js +505 -0
  22. package/dist/chunk-5n0dt838.js +2 -0
  23. package/dist/chunk-5s2y052b.js +2 -0
  24. package/dist/chunk-5v64c8tr.js +2 -0
  25. package/dist/chunk-5xd7vge2.js +2 -0
  26. package/dist/chunk-6bxcjdp4.js +2 -0
  27. package/dist/chunk-6msvxnbr.js +2 -0
  28. package/dist/chunk-7kger0se.js +1280 -0
  29. package/dist/chunk-7ry55nms.js +3 -0
  30. package/dist/chunk-7s0wfa4e.js +24 -0
  31. package/dist/chunk-7w4c5w2b.js +2 -0
  32. package/dist/chunk-8src5smc.js +15 -0
  33. package/dist/chunk-937effkz.js +2 -0
  34. package/dist/chunk-9b82d4g5.js +3 -0
  35. package/dist/chunk-9xh78snm.js +3 -0
  36. package/dist/chunk-a2899x2t.js +2 -0
  37. package/dist/chunk-abpw3b39.js +2 -0
  38. package/dist/chunk-avwj12at.js +194 -0
  39. package/dist/chunk-b6jhznkh.js +71 -0
  40. package/dist/chunk-bpa2jeyw.js +3 -0
  41. package/dist/chunk-cbc56wpd.js +3 -0
  42. package/dist/chunk-dhpy0h9y.js +2 -0
  43. package/dist/chunk-dtmwr674.js +302 -0
  44. package/dist/chunk-dxfcyj8t.js +2 -0
  45. package/dist/chunk-e0460y7f.js +29 -0
  46. package/dist/chunk-ede7zpjf.js +2 -0
  47. package/dist/chunk-ehfzp7xe.js +2 -0
  48. package/dist/chunk-fd77g6t6.js +2 -0
  49. package/dist/chunk-fnkxbnka.js +30 -0
  50. package/dist/chunk-fvjh7rx0.js +84 -0
  51. package/dist/chunk-g19skgmw.js +18 -0
  52. package/dist/chunk-gcnrdgrq.js +3 -0
  53. package/dist/chunk-h2wpnxrh.js +8 -0
  54. package/dist/chunk-hb83d0qc.js +2 -0
  55. package/dist/chunk-hncp9gz6.js +8 -0
  56. package/dist/chunk-ht51fz7w.js +4 -0
  57. package/dist/chunk-hyrjade7.js +321 -0
  58. package/dist/chunk-hyyzp99b.js +2 -0
  59. package/dist/chunk-jpbk42j7.js +2 -0
  60. package/dist/chunk-jr5tp4ks.js +2 -0
  61. package/dist/chunk-k03b9z9e.js +898 -0
  62. package/dist/chunk-kjr22neh.js +3 -0
  63. package/dist/chunk-mjt5e2jy.js +2 -0
  64. package/dist/chunk-mkm91b6w.js +2 -0
  65. package/dist/chunk-mtr2f82n.js +2 -0
  66. package/dist/chunk-n8zpm7xb.js +397 -0
  67. package/dist/chunk-ndnc7k2n.js +22 -0
  68. package/dist/chunk-nenge2m2.js +2 -0
  69. package/dist/chunk-nngpktr2.js +2 -0
  70. package/dist/chunk-nsjyn31z.js +2 -0
  71. package/dist/chunk-nye9brje.js +147 -0
  72. package/dist/chunk-p5kp35dy.js +2 -0
  73. package/dist/chunk-pw0rzgpv.js +3 -0
  74. package/dist/chunk-q020t182.js +2 -0
  75. package/dist/chunk-q4gp9egt.js +4 -0
  76. package/dist/chunk-q8szpd6w.js +3 -0
  77. package/dist/chunk-q9n5swx7.js +3 -0
  78. package/dist/chunk-qpcwahse.js +2 -0
  79. package/dist/chunk-qz75kx6n.js +231 -0
  80. package/dist/chunk-r41nsgym.js +116 -0
  81. package/dist/chunk-r4qnvxhv.js +18 -0
  82. package/dist/chunk-r6p4ws0a.js +3809 -0
  83. package/dist/chunk-rdf7d42n.js +2 -0
  84. package/dist/chunk-rs2fa3g1.js +2 -0
  85. package/dist/chunk-ryjpp51z.js +499 -0
  86. package/dist/chunk-s018d32j.js +30 -0
  87. package/dist/chunk-spn8e3b3.js +2 -0
  88. package/dist/chunk-sry9atvv.js +2 -0
  89. package/dist/chunk-st5qggks.js +3 -0
  90. package/dist/chunk-tywvd1zc.js +11 -0
  91. package/dist/chunk-v3ryxw4v.js +2 -0
  92. package/dist/chunk-va9k88da.js +2 -0
  93. package/dist/chunk-vgk5v31k.js +216 -0
  94. package/dist/chunk-vj320kyr.js +2 -0
  95. package/dist/chunk-vr3qtsj4.js +2 -0
  96. package/dist/chunk-w0ng9e1m.js +341 -0
  97. package/dist/chunk-w29sv5jf.js +2 -0
  98. package/dist/chunk-whq99ytc.js +7987 -0
  99. package/dist/chunk-wnaddtv3.js +288 -0
  100. package/dist/chunk-wtengj6h.js +2 -0
  101. package/dist/chunk-x0ks1fer.js +1194 -0
  102. package/dist/chunk-x0zh76yv.js +4 -0
  103. package/dist/chunk-x13f5bbe.js +358 -0
  104. package/dist/chunk-xfp10a23.js +2 -0
  105. package/dist/chunk-xp3fp266.js +11 -0
  106. package/dist/chunk-xz019t7t.js +2 -0
  107. package/dist/chunk-y35rktea.js +12 -0
  108. package/dist/chunk-y4hkqsgw.js +4 -0
  109. package/dist/chunk-yab6d6kb.js +28 -0
  110. package/dist/chunk-yckd6ks5.js +3 -0
  111. package/dist/chunk-ycn1vnv2.js +5 -0
  112. package/dist/chunk-yf3bmmkk.js +8 -0
  113. package/dist/chunk-ygr11tgz.js +3 -0
  114. package/dist/chunk-ymccpdg6.js +351 -0
  115. package/dist/chunk-yr2wc2pa.js +3 -0
  116. package/dist/chunk-yv340gxj.js +2 -0
  117. package/dist/chunk-z2sp0k8d.js +3 -0
  118. package/dist/chunk-z5cm0bwn.js +11 -0
  119. package/dist/chunk-zda3hvde.js +14 -0
  120. package/dist/chunk-zgvga8rc.js +5 -0
  121. package/dist/chunk-zqbw8zqq.js +3 -0
  122. package/dist/cli.js +108 -27481
  123. package/dist/craft-entry.js +9 -5
  124. package/dist/craft.js +7 -18503
  125. package/dist/database.js +2 -2
  126. package/dist/pwa.js +8 -16603
  127. package/dist/ssg.js +52 -15512
  128. package/dist/visual-testing.js +1 -1
  129. package/package.json +5 -5
@@ -0,0 +1,216 @@
1
+ // @bun
2
+ function w(Z,M){let{itemHeight:K,containerHeight:P,overscan:F=3,keyProperty:$="id",dynamicHeight:Q=!1,estimatedItemHeight:U=K,direction:G="vertical"}=M,k=[...Z],j=0,z=new Map;function _(){if(Q)return X();let q=Math.max(0,Math.floor(j/K)-F),A=Math.ceil(P/K),W=Math.min(k.length-1,q+A+F*2);return{startIndex:q,endIndex:W}}function X(){let q=0,A=0,W=k.length-1;for(let Y=0;Y<k.length;Y++){let V=z.get(Y)||U;if(q+V>j){A=Math.max(0,Y-F);break}q+=V}q=0;for(let Y=0;Y<k.length;Y++){let V=z.get(Y)||U;if(q+=V,q>j+P){W=Math.min(k.length-1,Y+F);break}}return{startIndex:A,endIndex:W}}function S(){if(Q){let q=0;for(let A=0;A<k.length;A++)q+=z.get(A)||U;return q}return k.length*K}function O(q){if(Q){let A=0;for(let W=0;W<q;W++)A+=z.get(W)||U;return A}return q*K}function N(){let{startIndex:q,endIndex:A}=_();return{startIndex:q,endIndex:A,scrollTop:j,totalHeight:S(),visibleItems:k.slice(q,A+1),itemHeights:new Map(z)}}function T(q,A="auto"){let W=O(q);J(W,A)}function J(q,A="auto"){j=Math.max(0,Math.min(q,S()-P))}function B(){_()}function y(q){k=[...q],z.clear(),B()}function D(){k=[],z.clear()}return{scrollToIndex:T,scrollToOffset:J,getState:N,refresh:B,setItems:y,destroy:D}}function C(Z,M={},K){let P=/@virtualList\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@endvirtualList/gi;return Z.replace(P,(F,$,Q,U)=>{let G=$.trim(),k=M[G];if(!k||!Array.isArray(k))return`<!-- virtualList: items "${G}" not found or not an array -->`;let j={itemHeight:50,containerHeight:400,overscan:3};if(Q)try{let J=Q.trim(),B=Function(`return ${J}`)();j={...j,...B}}catch{}let z=`vlist-${Math.random().toString(36).substring(2,9)}`,_=Math.ceil(j.containerHeight/j.itemHeight),X=j.overscan||3,S=0,O=Math.min(k.length-1,_+X),N="";for(let J=S;J<=O&&J<k.length;J++){let B=k[J],y=U.replace(/\{\{\s*item\s*\}\}/g,typeof B==="object"?JSON.stringify(B):String(B)).replace(/\{\{\s*item\.(\w+)\s*\}\}/g,(D,q)=>{if(typeof B==="object"&&B!==null)return String(B[q]??"");return""}).replace(/\{\{\s*index\s*\}\}/g,String(J));N+=`
3
+ <div class="virtual-item ${j.itemClass||""}"
4
+ style="position: absolute; top: ${J*j.itemHeight}px; height: ${j.itemHeight}px; width: 100%;"
5
+ data-index="${J}">
6
+ ${y}
7
+ </div>`}let T=k.length*j.itemHeight;return`
8
+ <div id="${z}"
9
+ class="virtual-list-container ${j.containerClass||""}"
10
+ style="position: relative; height: ${j.containerHeight}px; overflow-y: auto;"
11
+ data-item-height="${j.itemHeight}"
12
+ data-total-items="${k.length}"
13
+ data-overscan="${X}">
14
+ <div class="virtual-list-viewport ${j.viewportClass||""}"
15
+ style="position: relative; height: ${T}px; width: 100%;">
16
+ ${N}
17
+ </div>
18
+ </div>
19
+ <script data-virtual-list="${z}">
20
+ (function() {
21
+ const container = document.getElementById('${z}');
22
+ if (!container) return;
23
+
24
+ const viewport = container.querySelector('.virtual-list-viewport');
25
+ const itemHeight = ${j.itemHeight};
26
+ const totalItems = ${k.length};
27
+ const overscan = ${X};
28
+ const containerHeight = ${j.containerHeight};
29
+ const items = ${JSON.stringify(k)};
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 ${j.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 b(){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 L(Z,M){let K=null,P=()=>{if(!K)K=w(Z(),M);return K};return{visibleItems:()=>{return P().getState().visibleItems},totalHeight:()=>{return P().getState().totalHeight},containerProps:()=>({style:{height:`${M.containerHeight}px`,overflow:"auto",position:"relative"},onScroll:(F)=>{let $=F.target;if(K)K.scrollToOffset($.scrollTop)}}),itemProps:(F)=>({style:{position:"absolute",top:`${F*M.itemHeight}px`,height:`${M.itemHeight}px`,width:"100%"},"data-index":F}),scrollToIndex:(F)=>{P().scrollToIndex(F)}}}function E(Z,M={},K){let P=/@infiniteList\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@loading\s*([\s\S]*?)@endinfiniteList/gi;return Z.replace(P,(F,$,Q,U,G)=>{let k=$.trim(),j=M[k];if(!j||!Array.isArray(j))return`<!-- infiniteList: items "${k}" not found or not an array -->`;let z={itemHeight:50,containerHeight:400,overscan:3,threshold:100,hasMore:!0};if(Q)try{let S=Function(`return ${Q.trim()}`)();z={...z,...S}}catch{}let _=`ilist-${Math.random().toString(36).substring(2,9)}`,X=C(`@virtualList(${k}, ${JSON.stringify({itemHeight:z.itemHeight,containerHeight:z.containerHeight,overscan:z.overscan,containerClass:z.containerClass})})${U}@endvirtualList`,M);return X=X.replace("</script>",`
128
+ // Infinite scroll detection
129
+ container.addEventListener('scroll', function() {
130
+ const scrollBottom = container.scrollTop + container.clientHeight;
131
+ const threshold = ${z.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="${_}" class="infinite-list-wrapper">
140
+ ${X}
141
+ <div class="infinite-list-loading" style="display: none;">
142
+ ${G}
143
+ </div>
144
+ </div>
145
+ `})}function f(Z,M={},K){let P=/@virtualGrid\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@endvirtualGrid/gi;return Z.replace(P,(F,$,Q,U)=>{let G=$.trim(),k=M[G];if(!k||!Array.isArray(k))return`<!-- virtualGrid: items "${G}" not found or not an array -->`;let j={columns:3,rowHeight:100,containerHeight:400,gap:10,overscan:2};if(Q)try{let B=Function(`return ${Q.trim()}`)();j={...j,...B}}catch{}let z=`vgrid-${Math.random().toString(36).substring(2,9)}`,_=Math.ceil(k.length/j.columns),X=_*(j.rowHeight+(j.gap||0)),S=Math.ceil(j.containerHeight/(j.rowHeight+(j.gap||0))),O=j.overscan||2,N=0,T=Math.min(_-1,S+O),J="";for(let B=N;B<=T;B++)for(let y=0;y<j.columns;y++){let D=B*j.columns+y;if(D>=k.length)break;let q=k[D],A=y*(100/j.columns),W=B*(j.rowHeight+(j.gap||0)),Y=U.replace(/\{\{\s*item\s*\}\}/g,typeof q==="object"?JSON.stringify(q):String(q)).replace(/\{\{\s*item\.(\w+)\s*\}\}/g,(V,R)=>{if(typeof q==="object"&&q!==null)return String(q[R]??"");return""}).replace(/\{\{\s*index\s*\}\}/g,String(D));J+=`
146
+ <div class="virtual-grid-item"
147
+ style="position: absolute; top: ${W}px; left: ${A}%; width: calc(${100/j.columns}% - ${j.gap||0}px); height: ${j.rowHeight}px;"
148
+ data-index="${D}">
149
+ ${Y}
150
+ </div>`}return`
151
+ <div id="${z}"
152
+ class="virtual-grid-container"
153
+ style="position: relative; height: ${j.containerHeight}px; overflow-y: auto;">
154
+ <div class="virtual-grid-viewport"
155
+ style="position: relative; height: ${X}px; width: 100%;">
156
+ ${J}
157
+ </div>
158
+ </div>
159
+ <script data-virtual-grid="${z}">
160
+ (function() {
161
+ const container = document.getElementById('${z}');
162
+ if (!container) return;
163
+
164
+ const viewport = container.querySelector('.virtual-grid-viewport');
165
+ const columns = ${j.columns};
166
+ const rowHeight = ${j.rowHeight};
167
+ const gap = ${j.gap||0};
168
+ const totalItems = ${k.length};
169
+ const overscan = ${O};
170
+ const containerHeight = ${j.containerHeight};
171
+ const items = ${JSON.stringify(k)};
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 v={createVirtualList:w,processVirtualListDirectives:C,processInfiniteListDirectives:E,processVirtualGridDirectives:f,generateVirtualListCSS:b,useVirtualList:L};
216
+ export{w as fi,C as gi,b as hi,L as ii,E as ji,f as ki,v as li};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{$e as f,Ye as c,Ze as d,_e as e,af as g,bf as h}from"./chunk-r4qnvxhv.js";import{Bg as b,yg as a}from"./chunk-ndnc7k2n.js";import"./chunk-yab6d6kb.js";import"./chunk-ht51fz7w.js";import"./chunk-r6p4ws0a.js";import"./chunk-8src5smc.js";import"./chunk-gcnrdgrq.js";import"./chunk-xp3fp266.js";import"./chunk-nye9brje.js";import"./chunk-tywvd1zc.js";import"./chunk-cbc56wpd.js";import"./chunk-x0zh76yv.js";import"./chunk-0ae6chzd.js";import"./chunk-kjr22neh.js";import"./chunk-3952ykhb.js";import"./chunk-dtmwr674.js";import"./chunk-pw0rzgpv.js";export{d as virtualPathFor,g as typecheckStxFiles,e as sourcePathFor,h as formatTypecheckDiagnostics,f as findRuntimeTypeDeclarations,b as extractTemplateExpressions,a as extractScriptBlocks,c as buildVirtualSource};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{l as a,m as b,n as c}from"./chunk-q9n5swx7.js";import"./chunk-pw0rzgpv.js";export{c as updateContextTree,b as updateContextStoryFiles,a as createContext};
@@ -0,0 +1,341 @@
1
+ // @bun
2
+ var J=0;function K(){return`suspense-${++J}-${Date.now().toString(36)}`}function N(q,v={},w){let j=/@suspense(?:\s*\(([^)]*)\))?\s*([\s\S]*?)@fallback\s*([\s\S]*?)@endsuspense/gi;return q.replace(j,(z,A,B,D)=>{let E=K(),F=L(A||"");return M(E,B.trim(),D.trim(),F)})}function L(q){let v={},w=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,j;while((j=w.exec(q))!==null){let z=j[1],A=j[2]||j[3],B=j[4];switch(z){case"id":v.id=A;break;case"timeout":v.timeout=B?parseInt(B,10):void 0;break}}return v}function M(q,v,w,j){let z=j.timeout||30000,A=j.id||q;return`
3
+ <div class="stx-suspense" data-suspense-id="${q}" data-custom-id="${A}" data-status="pending">
4
+ <div class="stx-suspense-fallback" data-suspense-fallback="${q}">
5
+ ${w}
6
+ </div>
7
+ <div class="stx-suspense-content" data-suspense-content="${q}" style="display: none;">
8
+ ${v}
9
+ </div>
10
+ </div>
11
+ <script>
12
+ (function() {
13
+ const suspenseId = '${q}';
14
+ const customId = '${A}';
15
+ const timeout = ${z};
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 Q(q,v,w){return{id:q,fallback:w,content:v}}async function T(q){let v=q.map((j)=>`
193
+ <div id="stx-ssr-suspense-${j.id}" class="stx-ssr-suspense">
194
+ ${j.fallback}
195
+ </div>
196
+ `).join(`
197
+ `);async function*w(){for(let j of q)try{let z=await j.content;yield`
198
+ <script>
199
+ (function() {
200
+ const el = document.getElementById('stx-ssr-suspense-${j.id}');
201
+ if (el) {
202
+ el.innerHTML = ${JSON.stringify(z)};
203
+ el.classList.add('stx-ssr-suspense-resolved');
204
+ }
205
+ })();
206
+ </script>
207
+ `}catch(z){yield`
208
+ <script>
209
+ (function() {
210
+ const el = document.getElementById('stx-ssr-suspense-${j.id}');
211
+ if (el) {
212
+ el.classList.add('stx-ssr-suspense-error');
213
+ console.error('SSR Suspense error for ${j.id}:', ${JSON.stringify(String(z))});
214
+ }
215
+ })();
216
+ </script>
217
+ `}}return{initial:v,streaming:w()}}function U(){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 W(){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{N as Qh,Q as Rh,T as Sh,U as Th,W as Uh};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{$p as c,Zp as a,_p as b,aq as d,bq as e,cq as f,dq as g,eq as h,fq as i,gq as j,hq as k}from"./chunk-r6p4ws0a.js";import"./chunk-8src5smc.js";import"./chunk-gcnrdgrq.js";import"./chunk-xp3fp266.js";import"./chunk-nye9brje.js";import"./chunk-tywvd1zc.js";import"./chunk-cbc56wpd.js";import"./chunk-x0zh76yv.js";import"./chunk-0ae6chzd.js";import"./chunk-kjr22neh.js";import"./chunk-3952ykhb.js";import"./chunk-dtmwr674.js";import"./chunk-pw0rzgpv.js";export{a as scanScriptTags,k as rewriteStxImportSpecifiers,i as processSignals,g as processScriptSetup,e as preEvalLiteralReactiveIfs,b as parseLoopExpression,c as hasSignalsSyntax,j as findMarkupIndexOutsideScripts,h as extractExports,f as convertSignalLoopsToAttributes,d as convertSignalDirectivesToAttributes};