@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,302 @@
1
+ // @bun
2
+ function H(j,z){let k=z.pwa?.manifest?.themeColor||"#4f46e5";return`<div class="stx-pwa-install" style="display:none;">
3
+ ${j}
4
+ </div>
5
+ <script>
6
+ (function() {
7
+ let deferredPrompt;
8
+ const installContainer = document.querySelector('.stx-pwa-install');
9
+ const installBtn = installContainer?.querySelector('button, [data-pwa-install]') || installContainer;
10
+
11
+ window.addEventListener('beforeinstallprompt', (e) => {
12
+ e.preventDefault();
13
+ deferredPrompt = e;
14
+ if (installContainer) {
15
+ installContainer.style.display = 'block';
16
+ }
17
+ });
18
+
19
+ if (installBtn) {
20
+ installBtn.addEventListener('click', async () => {
21
+ if (!deferredPrompt) return;
22
+ deferredPrompt.prompt();
23
+ const { outcome } = await deferredPrompt.userChoice;
24
+ console.log('[PWA] Install prompt outcome:', outcome);
25
+ deferredPrompt = null;
26
+ if (installContainer) {
27
+ installContainer.style.display = 'none';
28
+ }
29
+ });
30
+ }
31
+
32
+ window.addEventListener('appinstalled', () => {
33
+ console.log('[PWA] App installed');
34
+ deferredPrompt = null;
35
+ if (installContainer) {
36
+ installContainer.style.display = 'none';
37
+ }
38
+ });
39
+
40
+ // Check if already installed
41
+ if (window.matchMedia('(display-mode: standalone)').matches) {
42
+ if (installContainer) {
43
+ installContainer.style.display = 'none';
44
+ }
45
+ }
46
+ })();
47
+ </script>`}function J(j,z){let k=z.pwa?.updates,E=k?.message||"A new version is available. Reload to update?",q=k?.autoReload||!1,F=j.trim().length>0,G=`
48
+ <div class="stx-pwa-update-banner" style="
49
+ position: fixed;
50
+ bottom: 0;
51
+ left: 0;
52
+ right: 0;
53
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
54
+ color: white;
55
+ padding: 16px 24px;
56
+ display: flex;
57
+ align-items: center;
58
+ justify-content: space-between;
59
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
60
+ box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
61
+ z-index: 99999;
62
+ transform: translateY(100%);
63
+ transition: transform 0.3s ease;
64
+ ">
65
+ <span style="font-size: 14px;">${E}</span>
66
+ <div style="display: flex; gap: 12px;">
67
+ <button data-pwa-dismiss style="
68
+ background: transparent;
69
+ border: 1px solid rgba(255,255,255,0.5);
70
+ color: white;
71
+ padding: 8px 16px;
72
+ border-radius: 6px;
73
+ cursor: pointer;
74
+ font-size: 14px;
75
+ ">Later</button>
76
+ <button data-pwa-reload style="
77
+ background: white;
78
+ border: none;
79
+ color: #667eea;
80
+ padding: 8px 16px;
81
+ border-radius: 6px;
82
+ cursor: pointer;
83
+ font-weight: 600;
84
+ font-size: 14px;
85
+ ">Update Now</button>
86
+ </div>
87
+ </div>`;return`${F?`<div class="stx-pwa-update" style="display:none;">${j}</div>`:G}
88
+ <script>
89
+ (function() {
90
+ const updateContainer = document.querySelector('.stx-pwa-update, .stx-pwa-update-banner');
91
+ const dismissBtn = updateContainer?.querySelector('[data-pwa-dismiss]');
92
+ const reloadBtn = updateContainer?.querySelector('[data-pwa-reload], button');
93
+ const autoReload = ${q};
94
+ let newWorker = null;
95
+
96
+ function showUpdate() {
97
+ if (updateContainer) {
98
+ if (updateContainer.classList.contains('stx-pwa-update-banner')) {
99
+ updateContainer.style.transform = 'translateY(0)';
100
+ }
101
+ else {
102
+ updateContainer.style.display = 'block';
103
+ }
104
+ }
105
+ if (autoReload) {
106
+ setTimeout(() => window.location.reload(), 1000);
107
+ }
108
+ }
109
+
110
+ function hideUpdate() {
111
+ if (updateContainer) {
112
+ if (updateContainer.classList.contains('stx-pwa-update-banner')) {
113
+ updateContainer.style.transform = 'translateY(100%)';
114
+ }
115
+ else {
116
+ updateContainer.style.display = 'none';
117
+ }
118
+ }
119
+ }
120
+
121
+ if (dismissBtn) {
122
+ dismissBtn.addEventListener('click', hideUpdate);
123
+ }
124
+
125
+ if (reloadBtn) {
126
+ reloadBtn.addEventListener('click', () => {
127
+ if (newWorker) {
128
+ newWorker.postMessage({ type: 'SKIP_WAITING' });
129
+ }
130
+ window.location.reload();
131
+ });
132
+ }
133
+
134
+ // Listen for service worker updates
135
+ if ('serviceWorker' in navigator) {
136
+ navigator.serviceWorker.ready.then((registration) => {
137
+ registration.addEventListener('updatefound', () => {
138
+ newWorker = registration.installing;
139
+ if (newWorker) {
140
+ newWorker.addEventListener('statechange', () => {
141
+ if (newWorker.state === 'installed' && navigator.serviceWorker.controller) {
142
+ showUpdate();
143
+ }
144
+ });
145
+ }
146
+ });
147
+ });
148
+
149
+ // Handle controller change (after skipWaiting)
150
+ navigator.serviceWorker.addEventListener('controllerchange', () => {
151
+ window.location.reload();
152
+ });
153
+ }
154
+
155
+ // Also listen for custom event
156
+ window.addEventListener('pwa-update-available', showUpdate);
157
+ })();
158
+ </script>`}function L(j,z){let k=j.trim().length>0,E=`
159
+ <div class="stx-offline-indicator" style="
160
+ position: fixed;
161
+ top: 16px;
162
+ right: 16px;
163
+ background: #ef4444;
164
+ color: white;
165
+ padding: 12px 20px;
166
+ border-radius: 8px;
167
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
168
+ font-size: 14px;
169
+ font-weight: 500;
170
+ box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
171
+ z-index: 99999;
172
+ display: none;
173
+ align-items: center;
174
+ gap: 8px;
175
+ ">
176
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
177
+ <path d="M1 1l22 22M16.72 11.06A10.94 10.94 0 0 1 19 12.55M5 12.55a10.94 10.94 0 0 1 5.17-2.39M10.71 5.05A16 16 0 0 1 22.58 9M1.42 9a15.91 15.91 0 0 1 4.7-2.88M8.53 16.11a6 6 0 0 1 6.95 0"/>
178
+ <circle cx="12" cy="20" r="1"/>
179
+ </svg>
180
+ <span>You are offline</span>
181
+ </div>`;return`${k?`<div class="stx-offline-indicator" style="display:none;">${j}</div>`:`
182
+ <div class="stx-offline-indicator" style="
183
+ position: fixed;
184
+ top: 16px;
185
+ right: 16px;
186
+ background: #ef4444;
187
+ color: white;
188
+ padding: 12px 20px;
189
+ border-radius: 8px;
190
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
191
+ font-size: 14px;
192
+ font-weight: 500;
193
+ box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
194
+ z-index: 99999;
195
+ display: none;
196
+ align-items: center;
197
+ gap: 8px;
198
+ ">
199
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
200
+ <path d="M1 1l22 22M16.72 11.06A10.94 10.94 0 0 1 19 12.55M5 12.55a10.94 10.94 0 0 1 5.17-2.39M10.71 5.05A16 16 0 0 1 22.58 9M1.42 9a15.91 15.91 0 0 1 4.7-2.88M8.53 16.11a6 6 0 0 1 6.95 0"/>
201
+ <circle cx="12" cy="20" r="1"/>
202
+ </svg>
203
+ <span>You are offline</span>
204
+ </div>`}
205
+ <script>
206
+ (function() {
207
+ const indicator = document.querySelector('.stx-offline-indicator');
208
+
209
+ function updateStatus() {
210
+ if (indicator) {
211
+ indicator.style.display = navigator.onLine ? 'none' : 'flex';
212
+ }
213
+ }
214
+
215
+ window.addEventListener('online', updateStatus);
216
+ window.addEventListener('offline', updateStatus);
217
+ updateStatus();
218
+ })();
219
+ </script>`}function M(j,z){let k=z.pwa?.push,E=k?.vapidPublicKey||"",q=k?.subscriptionEndpoint||"/api/push/subscribe";return`<div class="stx-pwa-push" style="display:none;">
220
+ ${j}
221
+ </div>
222
+ <script>
223
+ (function() {
224
+ const pushContainer = document.querySelector('.stx-pwa-push');
225
+ const pushBtn = pushContainer?.querySelector('button, [data-pwa-push]') || pushContainer;
226
+ const vapidKey = '${E}';
227
+ const endpoint = '${q}';
228
+
229
+ async function checkPushSupport() {
230
+ if (!('serviceWorker' in navigator) || !('PushManager' in window)) {
231
+ console.log('[PWA] Push notifications not supported');
232
+ return false;
233
+ }
234
+ return true;
235
+ }
236
+
237
+ async function subscribeToPush() {
238
+ try {
239
+ const registration = await navigator.serviceWorker.ready;
240
+
241
+ // Check existing subscription
242
+ let subscription = await registration.pushManager.getSubscription();
243
+
244
+ if (!subscription && vapidKey) {
245
+ // Convert VAPID key
246
+ const urlBase64ToUint8Array = (base64String) => {
247
+ const padding = '='.repeat((4 - base64String.length % 4) % 4);
248
+ const base64 = (base64String + padding).replace(/-/g, '+').replace(/_/g, '/');
249
+ const rawData = window.atob(base64);
250
+ const outputArray = new Uint8Array(rawData.length);
251
+ for (let i = 0; i < rawData.length; ++i) {
252
+ outputArray[i] = rawData.charCodeAt(i);
253
+ }
254
+ return outputArray;
255
+ };
256
+
257
+ subscription = await registration.pushManager.subscribe({
258
+ userVisibleOnly: true,
259
+ applicationServerKey: urlBase64ToUint8Array(vapidKey)
260
+ });
261
+
262
+ // Send subscription to server
263
+ if (endpoint) {
264
+ await fetch(endpoint, {
265
+ method: 'POST',
266
+ headers: { 'Content-Type': 'application/json' },
267
+ body: JSON.stringify(subscription)
268
+ });
269
+ }
270
+
271
+ console.log('[PWA] Push subscription created');
272
+ return subscription;
273
+ }
274
+
275
+ return subscription;
276
+ }
277
+ catch (error) {
278
+ console.error('[PWA] Push subscription failed:', error);
279
+ return null;
280
+ }
281
+ }
282
+
283
+ async function init() {
284
+ if (await checkPushSupport()) {
285
+ const permission = await Notification.requestPermission();
286
+ if (permission === 'granted' && pushContainer) {
287
+ pushContainer.style.display = 'block';
288
+ }
289
+ }
290
+ }
291
+
292
+ if (pushBtn) {
293
+ pushBtn.addEventListener('click', subscribeToPush);
294
+ }
295
+
296
+ // Check support on load
297
+ if (pushContainer) {
298
+ init();
299
+ }
300
+ })();
301
+ </script>`}var N={name:"pwa.installButton",handler:(j,z,k,E)=>{let q=k.__stx_options||{};return H(j,q)},hasEndTag:!0,description:"Renders a PWA install prompt button that appears when the app can be installed"},Q={name:"pwa.updatePrompt",handler:(j,z,k,E)=>{let q=k.__stx_options||{};return J(j,q)},hasEndTag:!0,description:"Renders a PWA update notification UI when a new version is available"},T={name:"pwa.offlineIndicator",handler:(j,z,k,E)=>{let q=k.__stx_options||{};return L(j,q)},hasEndTag:!0,description:"Renders an offline status indicator that shows when the user loses connection"},V={name:"pwa.pushSubscribe",handler:(j,z,k,E)=>{let q=k.__stx_options||{};return M(j,q)},hasEndTag:!0,description:"Renders a push notification subscription button"},X=[N,Q,T,V];function Z(j){return[...j,...X]}
302
+ export{N as _t,Q as $t,T as au,V as bu,X as cu,Z as du};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Wi as a,Xi as b,Yi as c}from"./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{a as listComposableModules,b as getComposableScript,c as clearComposableCache};
@@ -0,0 +1,29 @@
1
+ // @bun
2
+ import{Fh as x,Kh as B,Lh as c,Mh as u,Nh as n}from"./chunk-q8szpd6w.js";import{hu as v}from"./chunk-pw0rzgpv.js";import{resolve as JJ,basename as WJ,extname as _J,join as LJ}from"path";import{mkdir as QJ}from"fs/promises";var ZJ={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0};class V{config;constructor(K={}){this.config={...ZJ,...K}}async get(K,J){return c(K,J,"video",this.config)}async set(K,J,X){return u(K,J,X,"video",this.config)}async clear(){return n("video",this.config)}updateConfig(K){this.config={...this.config,...K}}}var S=null;function D(K){if(!S)S=new V(K);else if(K)S.updateConfig(K);return S}async function q(K,J,X){let N=X?{directory:`${X.outputDir}/../.cache`}:{};return D(N).get(K,J)}async function b(K,J,X,N){let Z=N?{directory:`${N.outputDir}/../.cache`}:{};return D(Z).set(K,J,X)}async function $J(){return D().clear()}import{resolve as y,basename as P,extname as f,join as U}from"path";import{mkdir as g}from"fs/promises";async function m(){try{return await import("ts-videos")}catch{return null}}async function h(K,J,X,N){let Z=await m();if(!Z)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let $=y(K);if(!await B($))return null;await g(X,{recursive:!0});let Y=await x($),z=P(K,f(K)),G=J.format||"webp",M=J.timestamp||0,E=`${z}-poster-${Y}.${G}`,W=U(X,E),Q=await Z.extractThumbnails($,{timestamps:[M],width:J.width||1280,height:J.height,format:G,quality:J.quality||85,outputDir:X,outputPattern:E.replace(`.${G}`,"")});if(Q&&Q.length>0){let _=Q[0];return{path:W,url:`${N}/${E}`,width:_.width||J.width||1280,height:_.height||720,timestamp:M,size:_.size||0}}return null}catch($){return console.warn(`[stx-media] Failed to generate poster: ${$}`),null}}async function d(K,J,X,N){let Z=await m();if(!Z)return[];try{let $=y(K);if(!await B($))return[];await g(X,{recursive:!0});let Y=await x($),z=P(K,f(K)),G=J.format||"webp",W=(await new Z.Input($).getInfo()).duration||60,Q=J.count||10,_=J.interval||W/Q,O=[];for(let w=0;w<Q&&w*_<W;w++)O.push(w*_);let L=await Z.extractThumbnails($,{timestamps:O,width:J.width||320,format:G,quality:J.quality||80,outputDir:X,outputPattern:`${z}-thumb-${Y}`});if(L&&L.length>0)return L.map((w,j)=>({path:w.path||U(X,`${z}-thumb-${Y}-${j}.${G}`),url:`${N}/${z}-thumb-${Y}-${j}.${G}`,width:w.width||J.width||320,height:w.height||180,timestamp:O[j],size:w.size||0}));return[]}catch($){return console.warn(`[stx-media] Failed to generate thumbnails: ${$}`),[]}}async function zJ(K,J,X,N){let Z=await m();if(!Z)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let $=y(K);if(!await B($))return null;await g(X,{recursive:!0});let Y=await x($),z=P(K,f(K)),E=(await new Z.Input($).getInfo()).duration||60,W=J.columns||10,Q=J.interval||5,_=J.thumbnailWidth||160,O=J.thumbnailHeight||90,L=J.format||"jpeg",w=Math.ceil(E/Q),j=Math.ceil(w/W),F=`${z}-sprite-${Y}.${L}`,k=U(X,F),T=[];for(let I=0;I<w;I++)T.push(I*Q);let A=await Z.extractThumbnails($,{timestamps:T,width:_,height:O,format:L,quality:J.quality||70,outputDir:U(X,".temp")});if(!A||A.length===0)return null;try{let I=await import("ts-images"),H=W*_,kJ=j*O,jJ=await I.createSprite({images:A.map((YJ)=>YJ.path),columns:W,padding:0,outputPath:k,format:L,quality:J.quality||70});return{url:`${N}/${F}`,path:k,columns:W,rows:j,thumbnailWidth:_,thumbnailHeight:O,interval:Q,totalFrames:w}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch($){return console.warn(`[stx-media] Failed to generate sprite sheet: ${$}`),null}}import{resolve as r,basename as e,extname as i,join as C}from"path";import{mkdir as R,writeFile as o}from"fs/promises";async function t(){try{return await import("ts-videos")}catch{return null}}var s=[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000},{label:"360p",width:640,height:360,bitrate:600000,audioBitrate:64000}];async function p(K,J,X,N,Z){let $=await t();if(!$)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let Y=r(K);if(!await B(Y))return null;let z=await x(Y),G=e(K,i(K)),M=C(X,`${G}-${z}-hls`);await R(M,{recursive:!0});let E=J.length>0?J:s,W=Z?.segmentDuration||6,O=(await new $.Input(Y).getInfo()).duration||0,L=[],w=0;for(let k of E){let T=C(M,k.label);await R(T,{recursive:!0});let A=`${k.label}.m3u8`,I=C(T,A);try{let H=await $.generateHLS(Y,{outputDir:T,segmentDuration:W,width:k.width,height:k.height,videoBitrate:k.bitrate,audioBitrate:k.audioBitrate,playlistName:k.label});if(H)L.push({quality:k,url:`${N}/${G}-${z}-hls/${k.label}/${A}`,path:I}),w+=H.segmentCount||Math.ceil(O/W)}catch(H){console.warn(`[stx-media] Failed to generate HLS for ${k.label}: ${H}`)}}if(L.length===0)return null;let j=C(M,"master.m3u8"),F=GJ(L,N,G,z);return await o(j,F),{manifestUrl:`${N}/${G}-${z}-hls/master.m3u8`,manifestPath:j,playlists:L,segmentCount:w,duration:O}}catch(Y){return console.warn(`[stx-media] Failed to generate HLS manifest: ${Y}`),null}}function GJ(K,J,X,N){let Z=["#EXTM3U","#EXT-X-VERSION:3"];for(let $ of K){let{quality:Y}=$,z=Y.bitrate+(Y.audioBitrate||128000),G=`${Y.width}x${Y.height||Math.round(Y.width*9/16)}`;Z.push(`#EXT-X-STREAM-INF:BANDWIDTH=${z},RESOLUTION=${G},NAME="${Y.label}"`,`${Y.label}/${Y.label}.m3u8`)}return Z.join(`
3
+ `)}async function l(K,J,X,N,Z){let $=await t();if(!$)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let Y=r(K);if(!await B(Y))return null;let z=await x(Y),G=e(K,i(K)),M=C(X,`${G}-${z}-dash`);await R(M,{recursive:!0});let E=J.length>0?J:s,W=Z?.segmentDuration||4,Q=Z?.minBufferTime||2,L=(await new $.Input(Y).getInfo()).duration||0,w=[],j=[];for(let A of E){let I=C(M,A.label);await R(I,{recursive:!0});try{if(await $.generateDASH(Y,{outputDir:I,segmentDuration:W,width:A.width,height:A.height,videoBitrate:A.bitrate,audioBitrate:A.audioBitrate})){if(w.push({bandwidth:A.bitrate,width:A.width,height:A.height||Math.round(A.width*9/16),url:`${N}/${G}-${z}-dash/${A.label}/video`}),A.audioBitrate)j.push({bandwidth:A.audioBitrate,url:`${N}/${G}-${z}-dash/${A.label}/audio`})}}catch(H){console.warn(`[stx-media] Failed to generate DASH for ${A.label}: ${H}`)}}if(w.length===0)return null;let F=C(M,"manifest.mpd"),k=NJ(w,j,L,W,Q);await o(F,k);let T=[{type:"video",representations:w}];if(j.length>0)T.push({type:"audio",representations:j});return{manifestUrl:`${N}/${G}-${z}-dash/manifest.mpd`,manifestPath:F,adaptationSets:T,duration:L}}catch(Y){return console.warn(`[stx-media] Failed to generate DASH manifest: ${Y}`),null}}function NJ(K,J,X,N,Z){let $=a(X),Y=a(Z),z=`<?xml version="1.0" encoding="UTF-8"?>
4
+ <MPD xmlns="urn:mpeg:dash:schema:mpd:2011"
5
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6
+ xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd"
7
+ type="static"
8
+ mediaPresentationDuration="${$}"
9
+ minBufferTime="${Y}"
10
+ profiles="urn:mpeg:dash:profile:isoff-on-demand:2011">
11
+ <Period>
12
+ <AdaptationSet mimeType="video/mp4" codecs="avc1.64001f" segmentAlignment="true" startWithSAP="1">
13
+ `;for(let G=0;G<K.length;G++){let M=K[G];z+=` <Representation id="video${G}" bandwidth="${M.bandwidth}" width="${M.width}" height="${M.height}">
14
+ <BaseURL>${M.url}/</BaseURL>
15
+ <SegmentBase indexRange="0-999">
16
+ <Initialization range="0-999"/>
17
+ </SegmentBase>
18
+ </Representation>
19
+ `}if(z+=` </AdaptationSet>
20
+ `,J.length>0){z+=` <AdaptationSet mimeType="audio/mp4" codecs="mp4a.40.2" segmentAlignment="true" startWithSAP="1">
21
+ `;for(let G=0;G<J.length;G++){let M=J[G];z+=` <Representation id="audio${G}" bandwidth="${M.bandwidth}">
22
+ <BaseURL>${M.url}/</BaseURL>
23
+ <SegmentBase indexRange="0-999">
24
+ <Initialization range="0-999"/>
25
+ </SegmentBase>
26
+ </Representation>
27
+ `}z+=` </AdaptationSet>
28
+ `}return z+=` </Period>
29
+ </MPD>`,z}function a(K){let J=Math.floor(K/3600),X=Math.floor(K%3600/60),N=Math.floor(K%60),Z="PT";if(J>0)Z+=`${J}H`;if(X>0)Z+=`${X}M`;return Z+=`${N}S`,Z}async function KJ(){try{return await import("ts-videos")}catch{return null}}function MJ(K){switch(K){case"very-low":return 500000;case"low":return 1e6;case"medium":return 2500000;case"high":return 5000000;case"very-high":return 1e7;case"lossless":return 0;default:return 2500000}}function OJ(K){switch(K){case"youtube":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};case"twitter":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"instagram-feed":return{codec:"h264",maxWidth:1080,maxHeight:1080,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"instagram-story":case"instagram-reels":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"tiktok":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"discord":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:60,bitrate:8000000,audioCodec:"aac",audioBitrate:192000};case"linkedin":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"facebook":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"web-progressive":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000,twoPass:!0};case"web-streaming":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};default:return{}}}async function XJ(K){let J=await KJ();if(!J)return null;try{let X=JJ(K),Z=await new J.Input(X).getInfo();return{duration:Z.duration||0,width:Z.width||0,height:Z.height||0,frameRate:Z.frameRate||0,bitrate:Z.bitrate||0,codec:Z.videoCodec||"",audioCodec:Z.audioCodec}}catch(X){return console.warn(`[stx-media] Failed to analyze video: ${X}`),null}}async function wJ(K,J,X,N){let Z=await KJ();if(!Z)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:K,processed:!1};let $=await q(K,J,X);if($)return $;try{let Y=JJ(K);if(!await B(Y))return{src:K,processed:!1,errors:[`Source file not found: ${K}`]};let z=X.outputDir||"dist/videos",G=X.baseUrl||"/videos";await QJ(z,{recursive:!0});let M=await x(Y),E=WJ(K,_J(K)),W={src:K,processed:!0,hash:M};N?.({percentage:5,stage:"analyzing"}),W.metadata=await XJ(Y)||void 0;let Q={};if(J.quality)Q.bitrate=MJ(J.quality);if(J.platform)Object.assign(Q,OJ(J.platform));if(J.transcode)Object.assign(Q,J.transcode);if(Object.keys(Q).length>0||J.process){N?.({percentage:10,stage:"transcoding"});let _=`${E}-${M}.mp4`,O=LJ(z,_);try{let L=await AJ(Y,O,Q,Z,(w)=>N?.({percentage:10+w*0.5,stage:"transcoding"}));if(L)W.transcoded={path:O,url:`${G}/${_}`,duration:L.duration,size:L.size,video:{codec:Q.codec||"h264",width:L.width,height:L.height,bitrate:L.bitrate,frameRate:L.frameRate},audio:L.audioCodec?{codec:Q.audioCodec||"aac",bitrate:Q.audioBitrate||128000,sampleRate:Q.sampleRate||48000,channels:Q.channels||2}:void 0}}catch(L){W.errors=W.errors||[],W.errors.push(`Transcoding failed: ${L}`)}}if(J.generatePoster){N?.({percentage:65,stage:"generating-poster"});let _=typeof J.generatePoster==="object"?J.generatePoster:{timestamp:0},O=await h(Y,_,z,G);if(O)W.poster=O}if(X.thumbnails?.enabled){N?.({percentage:70,stage:"generating-thumbnails"});let _=await d(Y,X.thumbnails,z,G);if(_.length>0)W.thumbnails=_}if(J.streaming){N?.({percentage:80,stage:"generating-manifests"});let _=typeof J.streaming==="object"?J.streaming:X.streaming||{format:"hls"};if(_.format==="hls"||_.format===void 0){let O=await p(Y,_.qualities||X.streaming?.defaultQualities||[],z,G);if(O)W.streaming={...W.streaming,hls:O}}if(_.format==="dash"){let O=await l(Y,_.qualities||X.streaming?.defaultQualities||[],z,G);if(O)W.streaming={...W.streaming,dash:O}}}if(J.spriteSheet)N?.({percentage:90,stage:"generating-sprite-sheet"});return N?.({percentage:100,stage:"complete"}),await b(K,J,W,X),W}catch(Y){return{src:K,processed:!1,errors:[`Processing failed: ${Y}`]}}}async function AJ(K,J,X,N,Z){try{let Y=await new N.Conversion(K,J,{videoCodec:X.codec,videoBitrate:X.bitrate,width:X.maxWidth,height:X.maxHeight,frameRate:X.frameRate,audioCodec:X.audioCodec,audioBitrate:X.audioBitrate,sampleRate:X.sampleRate,channels:X.channels}).run((z)=>{Z?.(z.percentage/100)});return{duration:Y.duration||0,size:Y.size||0,width:Y.width||X.maxWidth||0,height:Y.height||X.maxHeight||0,bitrate:Y.bitrate||X.bitrate||0,frameRate:Y.frameRate||X.frameRate||30,audioCodec:Y.audioCodec}}catch($){return console.error(`[stx-media] Transcoding failed: ${$}`),null}}export{V as uh,q as vh,b as wh,$J as xh,h as yh,d as zh,zJ as Ah,p as Bh,l as Ch,XJ as Dh,wJ as Eh};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{ef as a}from"./chunk-7s0wfa4e.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{a as startInteractive};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{bt as a,ct as b}from"./chunk-0ae6chzd.js";import"./chunk-pw0rzgpv.js";export{b as warnUnbalancedTags,a as findUnbalancedTags};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{$k as h,Uk as a,Vk as b,Wk as c,Xk as d,Yk as e,Zk as f,_k as g,al as i}from"./chunk-2zkj69dg.js";import"./chunk-zgvga8rc.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{a as shouldLogBundlerDiagnostics,e as setBundlerFallbackMode,f as resolveBundlerFallback,b as recordBundleFailure,h as queueClientBundleBuild,g as hasUserImports,c as getBundleFailures,d as clearBundleFailures,i as bundleClientScript};
@@ -0,0 +1,30 @@
1
+ // @bun
2
+ import S from"fs";import C from"path";function D(K){let{token:L,baseUrl:V="https://api.netlify.com/api/v1"}=K;async function W(Q,X,Z={}){let H=`${V}${X}`,B={Authorization:`Bearer ${L}`,"User-Agent":"stx-deploy/1.0"},$;if(Z.rawBody)B["Content-Type"]=Z.contentType||"application/octet-stream",$=Z.rawBody;else if(Z.body)B["Content-Type"]="application/json",$=JSON.stringify(Z.body);let Y=await fetch(H,{method:Q,headers:B,body:$});if(!Y.ok){let O=Error(`Netlify API error: ${Y.status} ${Y.statusText}`);O.status=Y.status;try{let E=await Y.json();O.message=E.message||O.message,O.code=E.code,O.details=E}catch{}throw O}let _=await Y.text();if(!_)return{};return JSON.parse(_)}return{async getSite(Q){return W("GET",`/sites/${Q}`)},async listSites(){return W("GET","/sites")},async createSite(Q){let X={};if(Q)X.name=Q;return W("POST","/sites",{body:X})},async createDeploy(Q,X){let Z={files:X.files,draft:X.draft??!0,async:X.async??!0};if(X.title)Z.title=X.title;if(X.branch)Z.branch=X.branch;if(X.functions)Z.functions=X.functions;return W("POST",`/sites/${Q}/deploys`,{body:Z})},async uploadFile(Q,X,Z){let H=X.startsWith("/")?X.slice(1):X;await W("PUT",`/deploys/${Q}/files/${H}`,{rawBody:Z,contentType:"application/octet-stream"})},async uploadFiles(Q,X){let H=[...X],B=async()=>{while(H.length>0){let Y=H.shift();if(Y)await this.uploadFile(Q,Y.path,Y.content)}},$=Array.from({length:Math.min(5,X.length)},()=>B());await Promise.all($)},async getDeploy(Q){return W("GET",`/deploys/${Q}`)},async waitForDeploy(Q,X={}){let{timeout:Z=300000,pollInterval:H=2000,onProgress:B}=X,$=Date.now();while(!0){let Y=await this.getDeploy(Q);if(B)B(Y);if(Y.state==="ready")return Y;if(Y.state==="error"){let _=Error(`Deploy failed: ${Y.error_message||"Unknown error"}`);throw _.status=500,_.details=Y,_}if(Date.now()-$>Z){let _=Error(`Deploy timed out after ${Z}ms`);throw _.status=408,_.details=Y,_}await new Promise((_)=>setTimeout(_,H))}},async lockDeploy(Q){return W("POST",`/deploys/${Q}/lock`)},async unlockDeploy(Q){return W("POST",`/deploys/${Q}/unlock`)}}}async function h(K){let L=await crypto.subtle.digest("SHA-1",K);return Array.from(new Uint8Array(L)).map((W)=>W.toString(16).padStart(2,"0")).join("")}async function x(K,L={}){let{ignore:V=["node_modules",".git",".env*","*.map"]}=L,W=[],Q=new Bun.Glob("**/*");for await(let X of Q.scan({cwd:K,onlyFiles:!0,dot:!1})){if(V.some((_)=>{if(_.includes("*"))return new RegExp(`^${_.replace(/\*/g,".*")}$`).test(X);return X.includes(_)}))continue;let H=`${K}/${X}`,$=await Bun.file(H).arrayBuffer(),Y=await h($);W.push({path:X,content:new Uint8Array($),sha1:Y})}return W}function T(K){let L={};for(let V of K)L[`/${V.path}`]=V.sha1;return L}function v(K,L){let V=new Set(L.map((W)=>W.startsWith("/")?W.slice(1):W));return K.filter((W)=>V.has(W.path))}function z(K){if(K<1024)return`${K} B`;if(K<1048576)return`${(K/1024).toFixed(1)} KB`;if(K<1073741824)return`${(K/1048576).toFixed(1)} MB`;return`${(K/1073741824).toFixed(1)} GB`}function N(K){return K.reduce((L,V)=>L+V.content.byteLength,0)}import U from"fs";import M from"path";function u(K){let L=[];if(L.push("[build]"),L.push(` command = "${G(K.build.command)}"`),L.push(` publish = "${G(K.build.publish)}"`),K.build.functions)L.push(` functions = "${G(K.build.functions)}"`);if(K.build.edge_functions)L.push(` edge_functions = "${G(K.build.edge_functions)}"`);if(K.build.environment&&Object.keys(K.build.environment).length>0){L.push(""),L.push("[build.environment]");for(let[V,W]of Object.entries(K.build.environment))L.push(` ${V} = "${G(W)}"`)}if(K.functions){if(L.push(""),L.push("[functions]"),K.functions.directory)L.push(` directory = "${G(K.functions.directory)}"`);if(K.functions.node_bundler)L.push(` node_bundler = "${K.functions.node_bundler}"`);if(K.functions.external_node_modules&&K.functions.external_node_modules.length>0)L.push(` external_node_modules = [${K.functions.external_node_modules.map((V)=>`"${V}"`).join(", ")}]`)}if(K.edge_functions&&K.edge_functions.length>0){L.push("");for(let V of K.edge_functions)L.push("[[edge_functions]]"),L.push(` function = "${G(V.function)}"`),L.push(` path = "${G(V.path)}"`)}if(K.redirects&&K.redirects.length>0){L.push("");for(let V of K.redirects){if(L.push("[[redirects]]"),L.push(` from = "${G(V.from)}"`),L.push(` to = "${G(V.to)}"`),V.status!==void 0)L.push(` status = ${V.status}`);if(V.force!==void 0)L.push(` force = ${V.force}`);if(V.conditions&&Object.keys(V.conditions).length>0){L.push(" [redirects.conditions]");for(let[W,Q]of Object.entries(V.conditions))L.push(` ${W} = "${G(Q)}"`)}}}if(K.headers&&K.headers.length>0){L.push("");for(let V of K.headers){L.push("[[headers]]"),L.push(` for = "${G(V.for)}"`),L.push(" [headers.values]");for(let[W,Q]of Object.entries(V.values))L.push(` ${W} = "${G(Q)}"`)}}if(K.plugins&&K.plugins.length>0){L.push("");for(let V of K.plugins)if(L.push("[[plugins]]"),L.push(` package = "${G(V.package)}"`),V.inputs&&Object.keys(V.inputs).length>0){L.push(" [plugins.inputs]");for(let[W,Q]of Object.entries(V.inputs))if(typeof Q==="string")L.push(` ${W} = "${G(Q)}"`);else if(typeof Q==="boolean"||typeof Q==="number")L.push(` ${W} = ${Q}`)}}if(K.context&&Object.keys(K.context).length>0)for(let[V,W]of Object.entries(K.context)){if(L.push(""),L.push(`[context.${V}]`),W.command)L.push(` command = "${G(W.command)}"`);if(W.publish)L.push(` publish = "${G(W.publish)}"`);if(W.environment&&Object.keys(W.environment).length>0){L.push(` [context.${V}.environment]`);for(let[Q,X]of Object.entries(W.environment))L.push(` ${Q} = "${G(X)}"`)}}return L.join(`
3
+ `)+`
4
+ `}function G(K){return K.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}async function j(K){let L={framework:"stx",buildCommand:"bun run build",outputDir:"dist"},V=M.join(K,"package.json");if(await Bun.file(V).exists())try{let $=JSON.parse(await Bun.file(V).text());if($.scripts?.build)L.buildCommand="bun run build";let Y={...$.dependencies,...$.devDependencies};if(Y["@stacksjs/stx"]||Y.stx)L.framework="stx"}catch{}let W=M.join(K,"stx.config.ts"),Q=M.join(K,".config","stx.config.ts");if(await Bun.file(W).exists()||await Bun.file(Q).exists())L.framework="stx";let X=["dist","build","out","public",".output"];for(let $ of X){let Y=M.join(K,$);if(U.existsSync(Y)&&U.statSync(Y).isDirectory()){L.outputDir=$;break}}let Z=["functions","netlify/functions","api"];for(let $ of Z){let Y=M.join(K,$);if(U.existsSync(Y)&&U.statSync(Y).isDirectory()){L.functionsDir=$;break}}let H=M.join(K,"netlify","edge-functions");if(U.existsSync(H))L.edgeFunctionsDir="netlify/edge-functions";let B=M.join(K,L.outputDir||"dist");if(U.existsSync(B)){let $=U.existsSync(M.join(B,"index.html")),Y=U.readdirSync(B).filter((_)=>_.endsWith(".html"));L.isSPA=$&&Y.length===1}return L}function q(K={}){let L={build:{command:K.buildCommand||"bun run build",publish:K.outputDir||"dist"}};if(K.functionsDir)L.build.functions=K.functionsDir,L.functions={directory:K.functionsDir,node_bundler:"esbuild"};if(K.edgeFunctionsDir)L.build.edge_functions=K.edgeFunctionsDir;if(L.headers=[{for:"/*",values:{"X-Frame-Options":"DENY","X-Content-Type-Options":"nosniff","X-XSS-Protection":"1; mode=block","Referrer-Policy":"strict-origin-when-cross-origin"}},{for:"/assets/*",values:{"Cache-Control":"public, max-age=31536000, immutable"}}],K.isSPA!==!1)L.redirects=[{from:"/*",to:"/index.html",status:200}];return L.context={production:{environment:{NODE_ENV:"production"}},"deploy-preview":{environment:{NODE_ENV:"development"}}},L}async function b(K,L){let V=await j(K),W=L||q(V),Q=u(W),X=M.join(K,"netlify.toml");return await Bun.write(X,Q),X}function P(K){return U.existsSync(M.join(K,"netlify.toml"))}async function n(K={}){let L=Date.now(),V=[],W=K.cwd||process.cwd(),Q=(A)=>{V.push(A)},X=(A)=>{if(K.onProgress)K.onProgress(A)},Z=C.resolve(W,K.directory||"dist"),H=K.token||process.env.NETLIFY_AUTH_TOKEN,B=K.siteId||process.env.NETLIFY_SITE_ID;if(!H)throw new R(`No Netlify auth token found.
5
+
6
+ To deploy to Netlify:
7
+ 1. Create account at https://app.netlify.com
8
+ 2. Get token at https://app.netlify.com/user/applications#personal-access-tokens
9
+ 3. Set NETLIFY_AUTH_TOKEN environment variable
10
+
11
+ export NETLIFY_AUTH_TOKEN=your_token_here`,"NO_TOKEN");if(!B)throw new R(`No Netlify site ID found.
12
+
13
+ Either:
14
+ 1. Set NETLIFY_SITE_ID environment variable
15
+ 2. Pass --site-id option
16
+ 3. Run \`stx deploy --init\` to set up
17
+
18
+ Find your site ID at: https://app.netlify.com/sites/YOUR_SITE/settings/general`,"NO_SITE_ID");if(!S.existsSync(Z))throw new R(`Build directory not found: ${Z}
19
+
20
+ Run \`stx build\` first or specify a different directory with --directory`,"NO_BUILD_DIR");if(!(S.readdirSync(Z).length>0))throw new R(`Build directory is empty: ${Z}
21
+
22
+ Run \`stx build\` to generate files`,"EMPTY_BUILD_DIR");if(K.dryRun){X({stage:"collect",message:"Collecting files..."});let A=await x(Z),F=N(A);return Q(`Would deploy ${A.length} files (${z(F)})`),Q(`From: ${Z}`),Q(`To: Site ${B}`),Q(`Mode: ${K.production?"production":"draft"}`),{success:!0,url:`https://${B}.netlify.app (dry-run)`,deployId:"dry-run",logs:V,duration:Date.now()-L,filesUploaded:A.length,totalSize:F}}let Y=D({token:H});X({stage:"collect",message:"Verifying site..."});try{let A=await Y.getSite(B);Q(`Deploying to: ${A.name} (${A.url})`)}catch(A){if(A.status===404)throw new R(`Site not found: ${B}
23
+
24
+ Check your site ID or create a new site at https://app.netlify.com`,"SITE_NOT_FOUND");throw A}X({stage:"collect",message:"Collecting files..."});let _=await x(Z),O=N(_);if(Q(`Found ${_.length} files (${z(O)})`),_.length===0)throw new R(`No files found in ${Z}`,"NO_FILES");let E=T(_);X({stage:"upload",message:"Creating deploy...",percent:0});let k=await Y.createDeploy(B,{title:K.message||"Deploy from stx CLI",draft:!K.production,files:E});Q(`Created deploy: ${k.id}`);let w=v(_,k.required||[]);if(Q(`Uploading ${w.length} files...`),w.length>0){let A=0,F=N(w);for(let I of w){await Y.uploadFile(k.id,I.path,I.content),A++;let y=Math.round(A/w.length*100);X({stage:"upload",message:`Uploading: ${I.path}`,percent:y,details:{uploaded:A,total:w.length}})}Q(`Uploaded ${z(F)}`)}else Q("All files already on CDN (no upload needed)");X({stage:"process",message:"Processing deploy..."});let J=await Y.waitForDeploy(k.id,{onProgress:(A)=>{X({stage:"process",message:`Status: ${A.state}`,details:A})}}),m=Date.now()-L;if(X({stage:"done",message:"Deploy complete!"}),Q(`Deploy complete in ${(m/1000).toFixed(1)}s`),Q(`URL: ${J.deploy_ssl_url}`),K.production)Q(`Site: ${J.ssl_url}`);if(K.open){let A=K.production?J.ssl_url:J.deploy_ssl_url;d(A)}return{success:!0,url:J.deploy_ssl_url,siteUrl:K.production?J.ssl_url:void 0,deployId:J.id,logs:V,duration:m,filesUploaded:w.length,totalSize:N(w)}}async function i(K={}){let L=K.directory||process.cwd(),V;if(P(L))V=C.join(L,"netlify.toml");else{let W=await j(L);V=await b(L,q(W))}if(K.siteId){let W=C.join(L,".env.local"),Q="";if(await Bun.file(W).exists()){if(Q=await Bun.file(W).text(),Q=Q.split(`
25
+ `).filter((X)=>!X.startsWith("NETLIFY_SITE_ID=")).join(`
26
+ `),Q&&!Q.endsWith(`
27
+ `))Q+=`
28
+ `}Q+=`NETLIFY_SITE_ID=${K.siteId}
29
+ `,await Bun.write(W,Q)}return{configPath:V,siteId:K.siteId}}class R extends Error{code;constructor(K,L){super(K);this.name="DeployError",this.code=L}}function d(K){let L=process.platform,V=L==="darwin"?"open":L==="win32"?"start":"xdg-open";Bun.spawn([V,K],{stdio:["ignore","ignore","ignore"]})}
30
+ export{D as sf,h as tf,x as uf,T as vf,v as wf,z as xf,N as yf,u as zf,j as Af,q as Bf,b as Cf,P as Df,n as Ef,i as Ff,R as Gf};
@@ -0,0 +1,84 @@
1
+ // @bun
2
+ var P=0;function W(){return`stx-defer-${++P}`}function X(E){let z=E.match(/on:\s*['"]?(\w+)(?:\((\d+)\))?['"]?/);if(z)return{trigger:z[1],value:z[2]};return{trigger:"immediate"}}function Y(E,z,A){let{trigger:F,value:w}=X(z),j=A,J,G,q,K=A.match(/@placeholder\s*([\s\S]*?)(?=@loading|@error|$)/);if(K)J=K[1].trim(),j=j.replace(/@placeholder[\s\S]*?(?=@loading|@error|$)/,"");let N=A.match(/@loading\s*([\s\S]*?)(?=@error|$)/);if(N)G=N[1].trim(),j=j.replace(/@loading[\s\S]*?(?=@error|$)/,"");let O=A.match(/@error(?:\s*\(\s*(\w+)\s*\))?\s*([\s\S]*)$/);if(O)q=O[2].trim(),j=j.replace(/@error(?:\s*\(\s*\w+\s*\))?[\s\S]*$/,"");return j=j.trim(),{trigger:F,triggerValue:w,content:j,placeholder:J,loading:G,error:q}}function Z(E,z){let{trigger:A,triggerValue:F}=z,w;switch(A){case"visible":w=`
3
+ const observer = new IntersectionObserver((entries) => {
4
+ if (entries[0].isIntersecting) {
5
+ observer.disconnect();
6
+ loadContent();
7
+ }
8
+ }, { threshold: 0.1 });
9
+ observer.observe(container);
10
+ `;break;case"idle":w=`
11
+ if ('requestIdleCallback' in window) {
12
+ requestIdleCallback(() => loadContent(), { timeout: 3000 });
13
+ }
14
+ else {
15
+ setTimeout(loadContent, 200);
16
+ }
17
+ `;break;case"interaction":w=`
18
+ const events = ['click', 'focus', 'touchstart'];
19
+ const handler = () => {
20
+ events.forEach(e => container.removeEventListener(e, handler));
21
+ loadContent();
22
+ };
23
+ events.forEach(e => container.addEventListener(e, handler, { once: true, passive: true }));
24
+ `;break;case"hover":w=`
25
+ const handler = () => {
26
+ container.removeEventListener('mouseenter', handler);
27
+ container.removeEventListener('focusin', handler);
28
+ loadContent();
29
+ };
30
+ container.addEventListener('mouseenter', handler, { once: true });
31
+ container.addEventListener('focusin', handler, { once: true });
32
+ `;break;case"timer":w=`
33
+ setTimeout(loadContent, ${F||"1000"});
34
+ `;break;case"immediate":default:w=`
35
+ Promise.resolve().then(loadContent);
36
+ `;break}return`
37
+ <script>
38
+ (function() {
39
+ const container = document.getElementById('${E}');
40
+ if (!container) return;
41
+
42
+ const contentEl = container.querySelector('[data-defer-content]');
43
+ const placeholderEl = container.querySelector('[data-defer-placeholder]');
44
+ const loadingEl = container.querySelector('[data-defer-loading]');
45
+ const errorEl = container.querySelector('[data-defer-error]');
46
+
47
+ function showElement(el) {
48
+ if (el) el.style.display = '';
49
+ }
50
+ function hideElement(el) {
51
+ if (el) el.style.display = 'none';
52
+ }
53
+
54
+ function loadContent() {
55
+ hideElement(placeholderEl);
56
+ showElement(loadingEl);
57
+
58
+ // Simulate async load (content is already rendered but hidden)
59
+ Promise.resolve().then(() => {
60
+ hideElement(loadingEl);
61
+ showElement(contentEl);
62
+ container.dispatchEvent(new CustomEvent('defer:loaded'));
63
+ }).catch((err) => {
64
+ hideElement(loadingEl);
65
+ if (errorEl) {
66
+ showElement(errorEl);
67
+ }
68
+ console.error('Defer load error:', err);
69
+ });
70
+ }
71
+
72
+ ${w}
73
+ })();
74
+ </script>
75
+ `}function _(E,z,A){P=0;let F=/@defer\s*\(([^)]*)\)\s*([\s\S]*?)@enddefer/g;return E.replace(F,(w,j,J)=>{let G=W(),q=Y(w,j,J),K=q.placeholder?`<div data-defer-placeholder>${q.placeholder}</div>`:"",N=q.loading?`<div data-defer-loading style="display: none;">${q.loading}</div>`:'<div data-defer-loading style="display: none;"></div>',O=q.error?`<div data-defer-error style="display: none;">${q.error}</div>`:"",Q=`<div data-defer-content style="display: none;">${q.content}</div>`,U=Z(G,q);return`
76
+ <div id="${G}" class="stx-defer" data-defer-trigger="${q.trigger}">
77
+ ${K}
78
+ ${N}
79
+ ${Q}
80
+ ${O}
81
+ </div>
82
+ ${U}
83
+ `})}
84
+ export{_ as aj};
@@ -0,0 +1,18 @@
1
+ // @bun
2
+ import{Bl as D,Cl as b,Eo as y,Ir as k,Mo as x,Sl as F,Ul as T,Yp as M,lq as R}from"./chunk-r6p4ws0a.js";import{hu as C}from"./chunk-pw0rzgpv.js";function j(K){return K.endsWith(".md")||K.endsWith(".markdown")}function w(K){let G=[];$(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let J=[...G];$(/<code\b[^>]*>[\s\S]*?<\/code>/gi,J);function $(N,Y){let E;while((E=N.exec(K))!==null){let q=E.index,z=q+E[0].length;if(Y?.some((U)=>q>=U.start&&z<=U.end))continue;G.push({start:q,end:z})}}if(G.length===0)return K;G.sort((N,Y)=>N.start-Y.start);let X="",Q=0;for(let N of G){if(N.start<Q)continue;X+=K.slice(Q,N.start),X+=`@raw${K.slice(N.start,N.end)}@endraw`,Q=N.end}return X+=K.slice(Q),X}async function H(K,G={}){let{data:J,content:$}=D(K),Q=await(G.renderer??((N)=>b(N)))($);return{html:w(Q),frontmatter:J??{}}}import{dirname as P,resolve as B}from"path";function f(K){let G=K,J=y(K);if(J)G=J.content.trim();let $=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,X=[],Q=[],N=[],Y=(z)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(z),E;while((E=$.exec(K))!==null){let z=E[1],U=E[2],Z=E[0],_=z.includes("server");if(Y(U))N.push(Z);else if(_)Q.push(U);else X.push(Z)}let q=G;{let z=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,U,Z=[];while((U=z.exec(q))!==null){let _=U.index+U[0].length,L=q.indexOf("</script>",_);if(L===-1)continue;Z.push({start:U.index,end:L+9}),z.lastIndex=L+9}for(let _=Z.length-1;_>=0;_--)q=q.substring(0,Z[_].start)+q.substring(Z[_].end)}for(let z of X)q=q.replace(z,"");return{templateContent:q,serverScripts:Q,clientScripts:X,signalsScripts:N}}function v(K,G){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>${(G||"stx").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</title>
8
+ </head>
9
+ <body>
10
+ ${K}
11
+ </body>
12
+ </html>`}function V(K,G,J){if(K&&typeof K==="object")K[G]=J}async function p(K,G={}){let J=B(K),$=Bun.file(J);if(!await $.exists())throw Error(`Template file not found: ${J}`);let X=await $.text(),Q=null;if(j(J)){let N=await H(X,{renderer:G.markdownRenderer});X=N.html,Q=N.frontmatter}if(Q)G={...G,context:{...Q,...G.context||{}}};if(G.layout){let N=B(G.layout),Y=Bun.file(N);if(!await Y.exists())throw Error(`Layout template not found: ${N}`);let{layout:E,injectCSS:q,...z}=G,U=await I(X,J,{...z,injectCSS:!1}),Z=await Y.text(),_={...G.context||{},content:U},L={...z,context:_,injectCSS:q};return I(Z,N,L)}return I(X,J,G)}async function a(K,G={},J={}){return I(K,process.cwd(),{context:G,...J})}async function I(K,G,J={}){let{templateContent:$,serverScripts:X,clientScripts:Q}=f(K),N={...k,...J.options},Y={__filename:G,__dirname:P(G),__stx:{},__stx_options:N,__stx_sfc_mode:!0,__stx_inject_css:J.injectCSS===!0,__stxServeContext:void 0,setResponseStatus:(z)=>{if(Number.isInteger(z)&&z>=100&&z<=599)V(J.context,"__stxResponseStatus",z)},notFound:(z=404)=>{let U=Number.isInteger(z)&&z>=400&&z<=599?z:404;V(J.context,"__stxResponseStatus",U)},setResponseHeader:(z,U)=>{if(!z)return;let Z=J.context?.__stxResponseHeaders||{};Z[String(z)]=String(U),V(J.context,"__stxResponseHeaders",Z)},definePageMeta:()=>{},...J.context||{}};for(let z of X)await x(z,Y,G);let E=new Set,q=$;if(q=await R(q,Y,G,N,E),J.templateOnly){if(q=q.replace(/<script data-stx-scoped>[\s\S]*?<\/script>\s*/gi,""),q=q.replace(/<!-- stx SEO Tags -->[\s\S]*?(?=<)/i,""),Q.length>0)q+=`
13
+ ${Q.join(`
14
+ `)}`}else{if(J.processClientScripts!==!1&&Q.length>0){let z=Y.__stx_event_bindings||[],U=F(Y),_=(await Promise.all(Q.map(async(W)=>{let A=W.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!A)return W;return await T(A[1],{eventBindings:z,templateContent:q,serverData:U,filePath:G})}))).join(`
15
+ `);if(q.match(/(<\/body>)/i))q=q.replace(/(<\/body>)/i,`${_}
16
+ $1`);else q+=`
17
+ ${_}`}q=await M(q)}if(J.wrapInDocument){if(!q.trim().toLowerCase().startsWith("<!doctype")&&!q.trim().toLowerCase().startsWith("<html"))q=v(q,J.title)}if(J.injectCSS)try{let{injectCrosswindCSS:z}=await import("./chunk-1yk07x7b.js");q=await z(q)}catch{}return q}
18
+ export{j as kk,w as lk,H as mk,p as nk,a as ok,I as pk};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{existsSync as U,statSync as V}from"fs";import z from"path";var W=/[*?[\]{}]/;function X(D){return W.test(D)}async function $(D,E={}){let H=E.cwd??process.cwd(),N=E.recursive!==!1,Q=E.ignorePaths??[],J=globalThis.Bun.Glob,K=new Set,F=(j)=>{if(j.includes(`${z.sep}node_modules${z.sep}`)||j.includes(`${z.sep}dist${z.sep}`))return;if(Q.some((q)=>q&&j.includes(z.normalize(q))))return;K.add(j)},R=async(j)=>{try{for await(let q of new J(j).scan({cwd:H,absolute:!0}))F(q)}catch{}};for(let j of D){if(!j)continue;if(X(j)){await R(j);continue}let q=z.resolve(H,j);if(!U(q))continue;if(V(q).isDirectory()){for await(let T of new J(N?"**/*.stx":"*.stx").scan({cwd:q,absolute:!0}))F(T);continue}F(q)}return[...K].sort()}
3
+ export{X as es,$ as fs};
@@ -0,0 +1,8 @@
1
+ // @bun
2
+ import{hs as _}from"./chunk-xp3fp266.js";import"./chunk-pw0rzgpv.js";function W(j,G,H=240){return j.slice(G,G+H)}var v=[{rule:"route-params",pattern:/\blocation\s*\.\s*pathname\s*\.\s*(?:match|split)\s*\(/g,primitive:"useRoute() / useRouteParams() / useRouteParam(name)",why:"parsing the URL by hand re-implements the router and does not update on SPA navigation"},{rule:"alert",pattern:/(?<![.#\w$])(?:(?:window|globalThis)\s*\.\s*)?alert\s*\(/g,primitive:"stxAlert(message)",why:"themed, focus-trapped and non-blocking \u2014 but `await` it if the code after it "+"depended on the native dialog blocking until dismissal",reject:(j)=>/\b(?:async\s+)?function\s+alert\s*\(/.test(j)||/\b(?:const|let|var)\s+alert\s*=/.test(j)},{rule:"search-params",pattern:/new\s+URLSearchParams\s*\(/g,primitive:"useSearchParams()",why:"reactive, and writes back through the router instead of history.replaceState",reject:(j,G)=>{let H=j.indexOf("(",G);if(H===-1)return!0;let Q=j.slice(H+1,j.indexOf(")",H)+1);return!/\b(?:location|search|href|url)\b/i.test(Q)}},{rule:"navigate",pattern:/\blocation\s*\.\s*(?:assign|replace)\s*\(|\blocation\s*\.\s*href\s*=/g,primitive:"navigate(path) / goBack()",why:"a full document load throws away every store and the scroll position; navigate() is an SPA transition",reject:(j,G)=>/^[^\n]*?(?:['"`]\s*)?(?:mailto:|tel:|sms:|https?:\/\/|\/\/)/.test(W(j,G,160))},{rule:"fetch",pattern:/new\s+AbortController\s*\(/g,primitive:"useFetch(url) / useAsyncData(key, fn)",why:"cancellation, loading and error state are already wired; hand-rolling them is where the races live"},{rule:"polling",pattern:/setInterval\s*\(/g,primitive:"useEventSource() / useSSE() / useWebSocket() / useChannel()",why:"polling burns requests and lags; the push primitives are delivered",reject:(j,G)=>!/\bfetch\s*\(|\$fetch\b|useFetch\b|\.get\s*\(|axios\b/.test(W(j,G))},{rule:"debounce",pattern:/\bclearTimeout\s*\(/g,primitive:"useDebounce(fn, ms) / useThrottle(fn, ms)",why:"a hand-held timer handle per call site is the usual source of stale-result bugs",requires:(j)=>/setTimeout\s*\(/.test(j)},{rule:"click-outside",pattern:/document\s*\.\s*addEventListener\s*\(\s*['"](?:click|mousedown|pointerdown)['"]/g,primitive:"useClickOutside(ref, fn)",why:"the document-level listener plus the blur race is exactly what this composable exists to remove"},{rule:"focus",pattern:/\.\s*(?:getElementById|querySelector)\s*\([^)]*\)\s*(?:\?\.)?\s*\.?focus\s*\(/g,primitive:"useFocus(ref) with x-ref",why:"a query by id breaks under nested scopes and SPA navigation; a ref does not"},{rule:"clipboard",pattern:/navigator\s*\.\s*(?:clipboard|share)\b/g,primitive:"useClipboard() / useShare()",why:"permission state, the copied flag and the unsupported-browser fallback are already handled"},{rule:"watch",pattern:/\beffect\s*\(\s*\(\s*\)\s*=>\s*\{[^}]*\bvoid\s+\w+\s*\(\s*\)/g,primitive:"watch(source, cb) / watchMultiple([...], cb)",why:"the `void a(); void b()` dance is a manual dependency list; watch takes one directly"}],U=["confirm","tooltip",...v.map((j)=>j.rule)];function N(j,G){let H=1;for(let Q=0;Q<G;Q++)if(j[Q]===`
3
+ `)H++;return H}function P(j,G){let H=j.lastIndexOf(`
4
+ `,G)+1,Q=j.indexOf(`
5
+ `,G);return j.slice(H,Q===-1?j.length:Q).trim().slice(0,120)}function q(j,G){let H=j.slice(0,G),Q=H.lastIndexOf("function"),X=H.lastIndexOf("=>"),M=Math.max(Q,X);if(M===-1)return!1;let z=j.slice(Math.max(0,M-120),M);return/\basync\b[^;{}]*$/.test(z)}function L(j){return/\b(?:async\s+)?function\s+confirm\s*\(/.test(j)||/\b(?:const|let|var)\s+confirm\s*=/.test(j)||/\bimport\s*\{[^}]*\bconfirm\b[^}]*\}/.test(j)}function O(j,G,H){if(L(j))return j;let Q=/(^|[^\w$.])(?:(?:window|globalThis)\s*\.\s*)?confirm\s*\(/g,X=F(j),M="",z=0,Y;while((Y=Q.exec(X))!==null){let Z=Y.index+Y[1].length,$=N(j,Z),J=P(j,Z);if(/stxConfirm\s*\($/.test(j.slice(0,Z+8)))continue;let D=q(j,Z);if(H.push({file:G,line:$,rule:"confirm",applied:D,snippet:J,reason:D?void 0:"stxConfirm() returns a Promise and native confirm() is synchronous, so this needs `await` inside an async function. Rewriting it here would make the condition always true."}),D)M+=j.slice(z,Z)+"await stxConfirm(",z=Z+(Y[0].length-Y[1].length)}return M+j.slice(z)}function w(j,G,H){let Q=/(<[a-z][\w-]*\b[^>]*?)\stitle=(["'])(.*?)\2/gis,X=C(j),M="",z=0,Y;while((Y=Q.exec(X))!==null){let[Z,$,J,D]=Y,K=N(j,Y.index),B=P(j,Y.index),V=$.match(/^<([A-Za-z][\w-]*)/)?.[1]??"";if(/^[A-Z]/.test(V)){H.push({file:G,line:K,rule:"tooltip",applied:!1,snippet:B,reason:`\`title\` on <${V}> is a component prop, not an HTML attribute \u2014 `+"adding x-tooltip here would put a tooltip on a component and may duplicate text it already renders."});continue}if(/\bx-tooltip[=\s]/.test($)||D.trim()===""){H.push({file:G,line:K,rule:"tooltip",applied:!1,snippet:B,reason:/\bx-tooltip[=\s]/.test($)?"already has x-tooltip":"empty title"});continue}H.push({file:G,line:K,rule:"tooltip",applied:!0,snippet:B}),M+=j.slice(z,Y.index)+`${$} x-tooltip=${J}${D}${J} title=${J}${D}${J}`,z=Y.index+Z.length}return M+j.slice(z)}function C(j){return j.replace(/<!--[\s\S]*?-->/g,(G)=>G.replace(/[^\n]/g," ")).replace(/\{\{--[\s\S]*?--\}\}/g,(G)=>G.replace(/[^\n]/g," "))}function E(j){let G=(H)=>H.replace(/[^\n]/g," ");return j.replace(/\/\*[\s\S]*?\*\//g,G).replace(/\/\/[^\n]*/g,G)}function F(j,G=!1){let H=C(j);return(G?E(H):_(H)).replace(/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi,(X,M)=>/\bclient\b/i.test(M)?X:X.replace(/[^\n]/g," "))}function S(j,G,H,Q){let X=F(j),M=F(j,!0);for(let z of v){if(!H.includes(z.rule))continue;if(z.requires&&!z.requires(j))continue;z.pattern.lastIndex=0;let Y,Z=/['"]/.test(z.pattern.source)?M:X;z.pattern.lastIndex=0;while((Y=z.pattern.exec(Z))!==null){if(z.reject?.(j,Y.index))continue;Q.push({file:G,line:N(j,Y.index),rule:z.rule,applied:!1,snippet:P(j,Y.index),reason:`${z.primitive} \u2014 ${z.why}`})}}}function k(j,G={}){let H=G.rules??U,Q=G.file??"<source>",X=[];S(j,Q,H,X);let M=j;if(H.includes("confirm"))M=O(M,Q,X);if(H.includes("tooltip"))M=w(M,Q,X);X.sort((Z,$)=>Z.line-$.line);let z=new Set,Y=X.filter((Z)=>{let $=`${Z.rule}:${Z.line}`;if(z.has($))return!1;return z.add($),!0});return{code:M,findings:Y}}var I=new Set(["confirm","tooltip"]);function A(j,G){if(j.length===0)return"No hand-rolled equivalents found.";let H=j.filter((z)=>z.applied),Q=j.filter((z)=>!z.applied&&I.has(z.rule)),X=j.filter((z)=>!z.applied&&!I.has(z.rule)),M=[];if(H.length>0){M.push(G?`Rewrote ${H.length} site(s):`:`Would rewrite ${H.length} site(s) (pass --fix):`);for(let z of H)M.push(` ${z.file}:${z.line} [${z.rule}] ${z.snippet}`)}if(Q.length>0){M.push("",`Needs a human \u2014 ${Q.length} site(s):`);for(let z of Q)M.push(` ${z.file}:${z.line} [${z.rule}] ${z.snippet}
6
+ ${z.reason}`)}if(X.length>0){M.push("",`An stx primitive already covers this \u2014 ${X.length} site(s):`);for(let z of X)M.push(` ${z.file}:${z.line} [${z.rule}] ${z.snippet}
7
+ use ${z.reason}`)}return M.join(`
8
+ `)}export{A as formatCodemodFindings,k as codemodSource};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{xj as o,yj as p,zj as q}from"./chunk-whq99ytc.js";import{Fj as a,Gj as b,Hj as c,Ij as d,Jj as e,Kj as f,Lj as g,Mj as h,Nj as i,Oj as j,Pj as k,Qj as l,Rj as m,Sj as n}from"./chunk-3es366z4.js";import"./chunk-kjr22neh.js";import"./chunk-pw0rzgpv.js";export{n as useOptimistic,l as untrack,a as state,g as runMountCallbacks,h as runDestroyCallbacks,i as pendingLifecycleCounts,m as peek,e as onMount,f as onDestroy,j as isSignal,k as isDerived,p as generateSignalsRuntimeDev,o as generateSignalsRuntime,c as effect,b as derived,q as default,d as batch};
@@ -0,0 +1,8 @@
1
+ // @bun
2
+ var P=new Map([["craft-button",{name:"Button",zigType:"craft.Button",props:[{name:"variant",type:"string",required:!1,default:"primary"},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onclick",type:"callback",required:!1}],children:"single"}],["craft-text-input",{name:"TextInput",zigType:"craft.TextInput",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-textarea",{name:"TextArea",zigType:"craft.TextArea",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"rows",type:"number",required:!1,default:3},{name:"disabled",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-checkbox",{name:"Checkbox",zigType:"craft.Checkbox",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"label",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-select",{name:"Select",zigType:"craft.Select",props:[{name:"value",type:"string",required:!1},{name:"options",type:"array",required:!0},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-slider",{name:"Slider",zigType:"craft.Slider",props:[{name:"value",type:"number",required:!1,default:0},{name:"min",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"step",type:"number",required:!1,default:1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-toggle",{name:"Toggle",zigType:"craft.Toggle",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-modal",{name:"Modal",zigType:"craft.Modal",props:[{name:"open",type:"boolean",required:!1,default:!1},{name:"title",type:"string",required:!1},{name:"closable",type:"boolean",required:!1,default:!0},{name:"onclose",type:"callback",required:!1}],children:"multiple"}],["craft-alert",{name:"Alert",zigType:"craft.Alert",props:[{name:"variant",type:"string",required:!1,default:"info"},{name:"title",type:"string",required:!1},{name:"dismissible",type:"boolean",required:!1,default:!1}],children:"single"}],["craft-progress",{name:"ProgressBar",zigType:"craft.ProgressBar",props:[{name:"value",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"indeterminate",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-spinner",{name:"Spinner",zigType:"craft.Spinner",props:[{name:"size",type:"number",required:!1,default:24}],children:"none"}],["craft-avatar",{name:"Avatar",zigType:"craft.Avatar",props:[{name:"src",type:"string",required:!1},{name:"alt",type:"string",required:!1},{name:"size",type:"number",required:!1,default:40}],children:"none"}],["craft-badge",{name:"Badge",zigType:"craft.Badge",props:[{name:"variant",type:"string",required:!1,default:"default"}],children:"single"}],["craft-card",{name:"Card",zigType:"craft.Card",props:[{name:"padding",type:"number",required:!1,default:16}],children:"multiple"}],["craft-sidebar",{name:"Sidebar",zigType:"craft.NativeSidebar",props:[{name:"id",type:"string",required:!1},{name:"variant",type:"string",required:!1,default:"desktop"},{name:"material",type:"string",required:!1,default:"sidebar"},{name:"backgroundEffect",type:"string",required:!1,default:"shimmer"},{name:"allowsVibrancy",type:"boolean",required:!1,default:!0},{name:"materialOpacity",type:"number",required:!1,default:0.68},{name:"minWidth",type:"number",required:!1,default:240},{name:"maxWidth",type:"number",required:!1,default:340},{name:"canCollapse",type:"boolean",required:!1,default:!0},{name:"selectedItem",type:"string",required:!1},{name:"sections",type:"array",required:!1}],children:"multiple",platform:["macos"],fallback:"aside"}],["craft-sidebar-section",{name:"SidebarSection",zigType:"craft.NativeSidebarSection",props:[{name:"id",type:"string",required:!0},{name:"title",type:"string",required:!1},{name:"header",type:"string",required:!1}],children:"multiple",platform:["macos"],fallback:"section"}],["craft-sidebar-item",{name:"SidebarItem",zigType:"craft.NativeSidebarItem",props:[{name:"id",type:"string",required:!0},{name:"label",type:"string",required:!0},{name:"icon",type:"string",required:!1},{name:"badge",type:"string",required:!1},{name:"tintColor",type:"color",required:!1}],children:"none",platform:["macos"],fallback:"button"}],["craft-accordion",{name:"Accordion",zigType:"craft.Accordion",props:[{name:"title",type:"string",required:!0},{name:"open",type:"boolean",required:!1,default:!1}],children:"multiple"}],["craft-tabs",{name:"TabView",zigType:"craft.TabView",props:[{name:"activeTab",type:"number",required:!1,default:0},{name:"ontabchange",type:"callback",required:!1}],children:"multiple"}],["craft-tooltip",{name:"Tooltip",zigType:"craft.Tooltip",props:[{name:"content",type:"string",required:!0},{name:"position",type:"string",required:!1,default:"top"}],children:"single"}],["craft-date-picker",{name:"DatePicker",zigType:"craft.DatePicker",props:[{name:"value",type:"string",required:!1},{name:"min",type:"string",required:!1},{name:"max",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-time-picker",{name:"TimePicker",zigType:"craft.TimePicker",props:[{name:"value",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-color-picker",{name:"ColorPicker",zigType:"craft.ColorPicker",props:[{name:"value",type:"color",required:!1,default:"#000000"},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-data-table",{name:"DataTable",zigType:"craft.DataTable",props:[{name:"data",type:"array",required:!0},{name:"columns",type:"array",required:!0},{name:"sortable",type:"boolean",required:!1,default:!1},{name:"paginated",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-virtual-list",{name:"VirtualList",zigType:"craft.VirtualList",props:[{name:"items",type:"array",required:!0},{name:"itemHeight",type:"number",required:!1,default:48},{name:"renderItem",type:"callback",required:!0}],children:"none"}],["craft-tree-view",{name:"TreeView",zigType:"craft.TreeView",props:[{name:"data",type:"object",required:!0},{name:"expandable",type:"boolean",required:!1,default:!0}],children:"none"}]]);async function k(j,q={}){let F=performance.now(),G={target:q.target||"universal",format:q.format||"zig",optimize:q.optimize??!0,treeShake:q.treeShake??!0,hotReload:q.hotReload??!1,debug:q.debug??!1,sourceMaps:q.sourceMaps??!1,bundle:q.bundle??!0,minify:q.minify??!1,components:q.components||P},Q=typeof j==="string"?I(j):j,U=z(Q.tree,G),W=f(U),K=G.treeShake?m(U,W):U,X=new Map;if(G.target==="universal"){let $=["macos","windows","linux","ios","android"];for(let _ of $){let R=J(K,{...G,target:_});X.set(_,R)}}else{let $=J(K,G);X.set(G.target,$)}let Y=s(K,G,X),x=r(Q,K,G),M={compilationTime:performance.now()-F,totalComponents:B(Q.tree),nativeComponents:b(K),webComponents:B(Q.tree)-b(K),bundleSize:Y.length,treeShakenSize:G.treeShake?g(U,K):Y.length,warnings:[],errors:[]},L;if(G.sourceMaps)L=p(Q,K);return{code:Y,platformCode:X,dependencies:W,manifest:x,sourceMaps:L,stats:M}}function I(j){let q={type:"fragment",children:[]},F=j.match(/<body[^>]*>([\s\S]*?)<\/body>/i),G=F?F[1]:j;return A(G,q),{id:E(),hash:D(j),tree:q,scripts:i(j),styles:a(j),staticParts:new Map,dynamicParts:new Map,dependencies:[],metadata:{hasSlots:!1,hasDynamicContent:j.includes("{{"),hasEventHandlers:j.includes("onclick")||j.includes("onchange"),hasAsyncContent:!1,componentCount:0,maxDepth:0,estimatedSize:j.length}}}function A(j,q){let F=/<(@?[\w-]+)([^>]*)(?:\/>|>([\s\S]*?)<\/\1>)/g,G;while((G=F.exec(j))!==null){let[,Q,U,W]=G,K=Q.startsWith("@craft-"),X={type:K?"component":"element",tag:K?Q.slice(1):Q,props:S(U),children:[],componentName:K?Q.slice(1):void 0};if(W){let Y=W.replace(/<[^>]+>/g,"").trim();if(Y)X.children=X.children??[],X.children.push({type:"text",text:Y});A(W,X)}q.children=q.children??[],q.children.push(X)}}function S(j){let q={},F=/([\w-:@]+)(?:=["']([^"']*)["'])?/g,G;while((G=F.exec(j))!==null){let[,Q,U]=G;q[Q]=U??!0}return q}function z(j,q){return Z(j,q)}function Z(j,q){let F=j.componentName?q.components?.get(j.componentName):void 0,G="craft.View";if(F)G=F.zigType;else if(j.type==="text")G="craft.Text";else if(j.tag)G=T(j.tag);let Q={};if(j.props)for(let[X,Y]of Object.entries(j.props))Q[X]=N(Y);let U=[];if(j.children)for(let X of j.children)U.push(Z(X,q));let W=new Map;if(j.props){for(let[X,Y]of Object.entries(j.props))if(X.startsWith("on")&&typeof Y==="string")W.set(X.slice(2).toLowerCase(),Y)}let K=C(j);return{type:y(j,F),zigType:G,props:Q,children:U,events:W,styles:K,id:j.hydrationKey,key:j.props?.key}}function T(j){return{div:"craft.View",span:"craft.Text",p:"craft.Text",h1:"craft.Text",h2:"craft.Text",h3:"craft.Text",h4:"craft.Text",h5:"craft.Text",h6:"craft.Text",button:"craft.Button",input:"craft.TextInput",textarea:"craft.TextArea",select:"craft.Select",img:"craft.Image",a:"craft.Link",ul:"craft.List",ol:"craft.List",li:"craft.ListItem",form:"craft.Form",label:"craft.Label",nav:"craft.View",header:"craft.View",footer:"craft.View",main:"craft.View",section:"craft.View",article:"craft.View",aside:"craft.View"}[j.toLowerCase()]||"craft.View"}function N(j){if(typeof j==="string"){if(j.startsWith("{{")&&j.endsWith("}}"))return{type:"binding",path:j.slice(2,-2).trim()};if(j.includes("(")&&j.includes(")"))return{type:"callback",handler:j};return{type:"literal",value:j}}if(typeof j==="number"||typeof j==="boolean")return{type:"literal",value:j};return{type:"literal",value:String(j)}}function y(j,q){if(q){let G=q.name.toLowerCase();if(G.includes("button"))return"button";if(G.includes("input")||G.includes("text"))return"input";if(G.includes("image")||G.includes("avatar"))return"image";if(G.includes("list")||G.includes("table"))return"list";if(G.includes("scroll"))return"scroll";return"custom"}if(j.type==="text")return"text";let F=j.tag?.toLowerCase();if(F==="button")return"button";if(F==="input"||F==="textarea")return"input";if(F==="img")return"image";if(F==="ul"||F==="ol")return"list";return"view"}function C(j){let q=j.props?.style,F={},G={};if(q){let Q=q.split(";").filter(Boolean);for(let U of Q){let[W,K]=U.split(":").map((X)=>X.trim());if(!W||!K)continue;switch(W){case"display":F.display=K;break;case"flex-direction":F.flexDirection=K;break;case"justify-content":F.justifyContent=h(K);break;case"align-items":F.alignItems=v(K);break;case"gap":F.gap=Number.parseInt(K,10);break;case"padding":F.padding=Number.parseInt(K,10);break;case"margin":F.margin=Number.parseInt(K,10);break;case"width":F.width=K==="auto"?"auto":Number.parseInt(K,10);break;case"height":F.height=K==="auto"?"auto":Number.parseInt(K,10);break;case"background-color":case"background":G.backgroundColor=K;break;case"border-color":G.borderColor=K;break;case"border-width":G.borderWidth=Number.parseInt(K,10);break;case"border-radius":G.borderRadius=Number.parseInt(K,10);break;case"opacity":G.opacity=Number.parseFloat(K);break}}}return{layout:F,appearance:G}}function h(j){return{"flex-start":"start","flex-end":"end",center:"center","space-between":"between","space-around":"around"}[j]||"start"}function v(j){return{"flex-start":"start","flex-end":"end",center:"center",stretch:"stretch"}[j]||"start"}function f(j){let q=[],F=new Set;function G(Q,U){let W=Q.id||E();if(F.has(W))return;F.add(W);let K={id:W,type:"component",path:Q.zigType,dependencies:U?[U]:[],size:w(Q),isStatic:u(Q)};q.push(K);for(let X of Q.children)G(X,W)}return G(j),q}function w(j){let q=100;return q+=Object.keys(j.props).length*20,q+=j.events.size*50,q}function u(j){for(let q of Object.values(j.props))if(q.type!=="literal")return!1;return j.events.size===0}function m(j,q){return j}function g(j,q){let F=0;function G(Q){F+=w(Q);for(let U of Q.children)G(U)}return G(q),F}function J(j,q){switch(q.format){case"zig":return H(j,q);case"typescript":return c(j,q);case"json":return JSON.stringify(j,null,q.minify?0:2);default:return H(j,q)}}function H(j,q){let F=[];return F.push("// Auto-generated by stx compiler"),F.push("// Target: "+q.target),F.push(""),F.push('const std = @import("std");'),F.push('const craft = @import("craft");'),F.push(""),F.push("pub fn render(allocator: std.mem.Allocator) !craft.Element {"),F.push(" return try build(allocator);"),F.push("}"),F.push(""),O(j,F,0),F.join(`
3
+ `)}function O(j,q,F){let G=" ".repeat(F);if(F===0)q.push("fn build(allocator: std.mem.Allocator) !craft.Element {");let Q=`node_${F}`;q.push(`${G} var ${Q} = try ${j.zigType}.init(allocator);`);for(let[U,W]of Object.entries(j.props))if(W.type==="literal"){let K=typeof W.value==="string"?`"${W.value}"`:String(W.value);q.push(`${G} ${Q}.set${l(U)}(${K});`)}for(let U=0;U<j.children.length;U++){let W=j.children[U];if(W.type==="text"){let K=W.props.text?.type==="literal"?String(W.props.text.value):"";q.push(`${G} try ${Q}.addChild(try craft.Text.init(allocator, "${K}"));`)}else O(W,q,F+1),q.push(`${G} try ${Q}.addChild(node_${F+1});`)}if(F===0)q.push(` return ${Q}.element();`),q.push("}")}function c(j,q){let F=[];return F.push("// Auto-generated by stx compiler"),F.push("// Target: "+q.target),F.push(""),F.push('import { Craft } from "@stacksjs/craft";'),F.push(""),F.push("export function render(): Craft.Element {"),F.push(" return "+V(j,1)+";"),F.push("}"),F.join(`
4
+ `)}function V(j,q){let F=" ".repeat(q),G=[];for(let[K,X]of Object.entries(j.props))if(X.type==="literal"){let Y=typeof X.value==="string"?`"${X.value}"`:String(X.value);G.push(`${K}: ${Y}`)}let Q=G.length>0?`{ ${G.join(", ")} }`:"{}",U=j.children.map((K)=>K.type==="text"?`"${K.props.text?.type==="literal"?K.props.text.value:""}"`:V(K,q+1)),W=U.length>0?`,
5
+ ${F} [${U.join(`,
6
+ ${F} `)}]`:"";return`Craft.create("${j.zigType}", ${Q}${W})`}function s(j,q,F){if(q.target==="universal"){let G=[];G.push("// Universal entry point"),G.push("");for(let[Q,U]of F)G.push(`// --- ${Q.toUpperCase()} ---`),G.push(`#if ${Q.toUpperCase()}`),G.push(U),G.push("#endif"),G.push("");return G.join(`
7
+ `)}return F.get(q.target)||J(j,q)}function r(j,q,F){let G=[];function Q(U){G.push({name:U.zigType,hash:D(JSON.stringify(U.props)),props:Object.keys(U.props),events:Array.from(U.events.keys()),slots:[],isNative:U.zigType.startsWith("craft.")});for(let W of U.children)Q(W)}return Q(q),{version:"1.0.0",components:G,entry:j.id,assets:[],styles:j.styles}}function p(j,q){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}var d=0;function E(){return`id_${++d}`}function D(j){let q=0;for(let F=0;F<j.length;F++){let G=j.charCodeAt(F);q=(q<<5)-q+G,q=q&q}return Math.abs(q).toString(36)}function l(j){return j.charAt(0).toUpperCase()+j.slice(1)}function i(j){let q=[],F=/<script[^>]*>([\s\S]*?)<\/script>/gi,G;while((G=F.exec(j))!==null)q.push(G[1]);return q}function a(j){let q=[],F=/<style[^>]*>([\s\S]*?)<\/style>/gi,G;while((G=F.exec(j))!==null)q.push(G[1]);return q}function B(j){let q=j.type==="component"?1:0;if(j.children)for(let F of j.children)q+=B(F);return q}function b(j){let q=j.zigType.startsWith("craft.")?1:0;for(let F of j.children)q+=b(F);return q}function o(j){return{start:async()=>{console.log("[craft-compiler] Hot reload server started")},stop:async()=>{console.log("[craft-compiler] Hot reload server stopped")},notifyChange:(q)=>{console.log(`[craft-compiler] File changed: ${q}`)}}}var t={compileToNative:k,createHotReloadServer:o,NATIVE_COMPONENTS:P},e=t;
8
+ export{P as Tj,k as Uj,o as Vj,e as Wj};
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import z from"fs";function B(x){return[...x].sort().map((b)=>{try{let j=z.statSync(b);return`${b}:${j.size}:${j.mtimeMs}`}catch{return`${b}:missing`}}).join(`
3
+ `)}function C(x,b,j){let q=x.get(b);return q!==void 0&&q.signature===j?q.value:void 0}function D(x,b,j,q){return x.set(b,{signature:j,value:q}),q}
4
+ export{B as Zi,C as _i,D as $i};