@stacksjs/stx 0.2.194 → 0.2.196

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 (130) 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/variable-extractor.js +12 -2
  129. package/dist/visual-testing.js +1 -1
  130. package/package.json +5 -5
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ var K={},Y=[],O={};function I(){return K}function h(){return O}function D(){K={},Y.length=0,O={}}function U(j){K=Q(K,j)}function Q(j,z){return{title:z.title??j.title,titleTemplate:z.titleTemplate??j.titleTemplate,base:z.base??j.base,meta:[...j.meta||[],...z.meta||[]],link:[...j.link||[],...z.link||[]],script:[...j.script||[],...z.script||[]],style:[...j.style||[],...z.style||[]],htmlAttrs:{...j.htmlAttrs,...z.htmlAttrs},bodyAttrs:{...j.bodyAttrs,...z.bodyAttrs}}}function Z(j){U(_(j))}function _(j){let z=[];if(j.description)z.push({name:"description",content:j.description});if(j.keywords){let L=Array.isArray(j.keywords)?j.keywords.join(", "):j.keywords;z.push({name:"keywords",content:L})}if(j.author)z.push({name:"author",content:j.author});if(j.robots)z.push({name:"robots",content:j.robots});let A=j.ogTitle??j.title,B=j.ogDescription??j.description;if(A)z.push({property:"og:title",content:A});if(B)z.push({property:"og:description",content:B});if(j.ogImage)z.push({property:"og:image",content:j.ogImage});if(j.ogUrl)z.push({property:"og:url",content:j.ogUrl});if(j.ogType)z.push({property:"og:type",content:j.ogType});if(j.ogSiteName)z.push({property:"og:site_name",content:j.ogSiteName});if(j.ogLocale)z.push({property:"og:locale",content:j.ogLocale});let E=j.twitterTitle??j.title,F=j.twitterDescription??j.description,J=j.twitterImage??j.ogImage;if(j.twitterCard)z.push({name:"twitter:card",content:j.twitterCard});if(E)z.push({name:"twitter:title",content:E});if(F)z.push({name:"twitter:description",content:F});if(J)z.push({name:"twitter:image",content:J});if(j.twitterSite)z.push({name:"twitter:site",content:j.twitterSite});if(j.twitterCreator)z.push({name:"twitter:creator",content:j.twitterCreator});if(j.articleAuthor)z.push({property:"article:author",content:j.articleAuthor});if(j.articlePublishedTime)z.push({property:"article:published_time",content:j.articlePublishedTime});if(j.articleModifiedTime)z.push({property:"article:modified_time",content:j.articleModifiedTime});if(j.articleSection)z.push({property:"article:section",content:j.articleSection});if(j.articleTags)for(let L of j.articleTags)z.push({property:"article:tag",content:L});let G=[];if(j.canonical)G.push({rel:"canonical",href:j.canonical});return{title:j.title,titleTemplate:j.titleTemplate,meta:z,link:G}}function S(j){if(O={...O,...j},j.title||j.description)Z({title:j.title,description:j.description})}function P(j){let z=typeof j==="function"?j():j;U({title:z})}function C(j=K){let z=[];if(j.title){let A=j.title;if(j.titleTemplate)A=typeof j.titleTemplate==="function"?j.titleTemplate(A):j.titleTemplate.replace("%s",A);z.push(`<title>${N(A)}</title>`)}if(j.base){let A=Object.entries(j.base).map(([B,E])=>`${B}="${N(E)}"`).join(" ");z.push(`<base ${A}>`)}for(let A of j.meta||[]){let B=Object.entries(A).filter(([E,F])=>F!==void 0).map(([E,F])=>{return`${E==="httpEquiv"?"http-equiv":E}="${N(String(F))}"`}).join(" ");z.push(`<meta ${B}>`)}for(let A of j.link||[]){let B=Object.entries(A).filter(([E,F])=>F!==void 0).map(([E,F])=>`${E}="${N(String(F))}"`).join(" ");z.push(`<link ${B}>`)}for(let A of j.script||[]){let{content:B,...E}=A,F=Object.entries(E).filter(([J,G])=>G!==void 0).map(([J,G])=>{if(typeof G==="boolean")return G?J:"";return`${J}="${N(String(G))}"`}).filter(Boolean).join(" ");if(B)z.push(`<script ${F}>${B}</script>`);else z.push(`<script ${F}></script>`)}for(let A of j.style||[]){let B=A.type?` type="${A.type}"`:"";z.push(`<style${B}>${A.content}</style>`)}return z.join(`
3
+ `)}function M(j=K){if(!j.htmlAttrs)return"";return Object.entries(j.htmlAttrs).map(([z,A])=>`${z}="${N(A)}"`).join(" ")}function V(j=K){if(!j.bodyAttrs)return"";return Object.entries(j.bodyAttrs).map(([z,A])=>`${z}="${N(A)}"`).join(" ")}function N(j){return j.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function w(j=K){if(typeof document>"u")return;if(j.title){let z=j.title;if(j.titleTemplate)z=typeof j.titleTemplate==="function"?j.titleTemplate(z):j.titleTemplate.replace("%s",z);document.title=z}for(let z of j.meta||[]){let A=z.name?`meta[name="${z.name}"]`:z.property?`meta[property="${z.property}"]`:null;if(A){let B=document.querySelector(A);if(!B){if(B=document.createElement("meta"),z.name)B.setAttribute("name",z.name);if(z.property)B.setAttribute("property",z.property);document.head.appendChild(B)}B.setAttribute("content",z.content)}}for(let z of j.link||[]){let A=`link[rel="${z.rel}"]${z.href?`[href="${z.href}"]`:""}`,B=document.querySelector(A);if(!B)B=document.createElement("link"),document.head.appendChild(B);for(let[E,F]of Object.entries(z))if(F!==void 0)B.setAttribute(E,String(F))}if(j.htmlAttrs)for(let[z,A]of Object.entries(j.htmlAttrs))if(z==="class")for(let B of String(A).split(/\s+/).filter(Boolean))document.documentElement.classList.add(B);else document.documentElement.setAttribute(z,A);if(j.bodyAttrs)for(let[z,A]of Object.entries(j.bodyAttrs))document.body.setAttribute(z,A)}function y(j){let z="";return{content:j.replace(/@head\s*([\s\S]*?)@endhead/g,(B,E)=>{return z+=E.trim()+`
4
+ `,""}),headContent:z.trim()}}function x(j,z){return j.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(A,B,E,F)=>{let J=B?E:z[(F||"").trim()]??F,G=z.__stx_runtime_head??{};return z.__stx_runtime_head=Q(G,{title:J}),""})}function T(j,z){return j.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(A,B,E,F,J,G)=>{let L=F?J:G,R=F?L:z[(L||"").trim()]??L,W=E.includes(":")?{property:E,content:R}:{name:E,content:R},X=z.__stx_runtime_head??{};return z.__stx_runtime_head=Q(X,{meta:[W]}),""})}export{I as Ns,h as Os,D as Ps,U as Qs,Q as Rs,Z as Ss,_ as Ts,S as Us,P as Vs,C as Ws,M as Xs,V as Ys,w as Zs,y as _s,x as $s,T as at};
@@ -0,0 +1,358 @@
1
+ // @bun
2
+ var U=0;function N(){return`async-${++U}-${Date.now().toString(36)}`}function X(j,q={},K){let z=/@async\s*\(([^)]*)\)\s*([\s\S]*?)@error\s*([\s\S]*?)@endasync/gi,F=/@async\s*\(([^)]*)\)\s*([\s\S]*?)@endasync/gi,w=j;return w=w.replace(z,(B,D,J,L)=>{let M=N(),T=P(D);return Q(M,T,J.trim(),L.trim())}),w=w.replace(F,(B,D,J)=>{let L=N(),M=P(D);return Q(L,M,J.trim(),'<div class="stx-async-error">Failed to load component</div>')}),w}function P(j){let q={component:"",timeout:30000,delay:200,suspensible:!0,retries:0},K=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,z;while((z=K.exec(j))!==null){let F=z[1],w=z[2]||z[3],B=z[4],D=z[5];switch(F){case"component":q.component=w||D||"";break;case"timeout":q.timeout=B?parseInt(B,10):30000;break;case"delay":q.delay=B?parseInt(B,10):200;break;case"suspensible":q.suspensible=D==="true";break;case"retries":q.retries=B?parseInt(B,10):0;break;case"loadingComponent":q.loadingComponent=w||D;break;case"errorComponent":q.errorComponent=w||D;break}}return q}function Q(j,q,K,z){let{component:F,timeout:w,delay:B,suspensible:D,retries:J}=q;return`
3
+ <div class="stx-async-component" data-async-id="${j}" data-component="${F}" data-status="pending">
4
+ <div class="stx-async-loading" data-async-loading="${j}">
5
+ ${K}
6
+ </div>
7
+ <div class="stx-async-content" data-async-content="${j}" style="display: none;">
8
+ </div>
9
+ <div class="stx-async-error" data-async-error="${j}" style="display: none;">
10
+ ${z}
11
+ </div>
12
+ </div>
13
+ <script>
14
+ (function() {
15
+ const asyncId = '${j}';
16
+ const componentPath = '${F}';
17
+ const timeout = ${w};
18
+ const delay = ${B};
19
+ const suspensible = ${D};
20
+ const maxRetries = ${J};
21
+
22
+ const container = document.querySelector('[data-async-id="' + asyncId + '"]');
23
+ const loadingEl = document.querySelector('[data-async-loading="' + asyncId + '"]');
24
+ const contentEl = document.querySelector('[data-async-content="' + asyncId + '"]');
25
+ const errorEl = document.querySelector('[data-async-error="' + asyncId + '"]');
26
+
27
+ if (!container || !loadingEl || !contentEl || !errorEl) return;
28
+
29
+ let attempts = 0;
30
+ let delayTimer = null;
31
+ let timeoutTimer = null;
32
+ let resolved = false;
33
+ let aborted = false;
34
+
35
+ // AbortController + container detachment guards (stacksjs/stx#1720). Without
36
+ // these, an in-flight fetch from a previous page would write innerHTML on
37
+ // a detached container after the user SPA-navigated away, or \u2014 for
38
+ // components removed via :if/parent toggle \u2014 would log a "rejected" state
39
+ // on a node that no longer exists. The router dispatches stx:navigate
40
+ // when a navigation starts; we treat that as a teardown signal. The
41
+ // isConnected check covers non-router unmounts (:if false, parent remove).
42
+ const controller = new AbortController();
43
+ function teardown() {
44
+ if (aborted) return;
45
+ aborted = true;
46
+ controller.abort();
47
+ clearTimeout(delayTimer);
48
+ clearTimeout(timeoutTimer);
49
+ window.removeEventListener('stx:navigate', teardown);
50
+ }
51
+ window.addEventListener('stx:navigate', teardown);
52
+
53
+ // Update state
54
+ function setState(status) {
55
+ container.setAttribute('data-status', status);
56
+ loadingEl.style.display = status === 'loading' ? '' : 'none';
57
+ contentEl.style.display = status === 'resolved' ? '' : 'none';
58
+ errorEl.style.display = status === 'rejected' ? '' : 'none';
59
+ }
60
+
61
+ // Show loading after delay
62
+ function showLoading() {
63
+ if (!resolved) {
64
+ setState('loading');
65
+ }
66
+ }
67
+
68
+ // Load component
69
+ async function loadComponent() {
70
+ attempts++;
71
+
72
+ // Start delay timer for loading state
73
+ delayTimer = setTimeout(showLoading, delay);
74
+
75
+ // Start timeout timer
76
+ timeoutTimer = setTimeout(function() {
77
+ if (!resolved) {
78
+ handleError(new Error('Component load timeout after ' + timeout + 'ms'));
79
+ }
80
+ }, timeout);
81
+
82
+ try {
83
+ // Notify Suspense boundary if suspensible
84
+ if (suspensible && window.STX && window.STX.suspense) {
85
+ window.STX.suspense.register(asyncId);
86
+ }
87
+
88
+ // Fetch the component with the AbortController signal so a teardown
89
+ // (SPA navigation, component unmount) cancels the in-flight request.
90
+ const response = await fetch('/_stx/component/' + encodeURIComponent(componentPath), {
91
+ signal: controller.signal
92
+ });
93
+
94
+ if (!response.ok) {
95
+ throw new Error('Failed to load component: ' + response.statusText);
96
+ }
97
+
98
+ const html = await response.text();
99
+
100
+ // Clear timers
101
+ clearTimeout(delayTimer);
102
+ clearTimeout(timeoutTimer);
103
+
104
+ // Belt-and-suspenders: if the container was removed between the fetch
105
+ // starting and now (e.g. :if flipped to false, or a non-router parent
106
+ // mutation), bail before writing innerHTML on a detached node.
107
+ if (aborted || !container.isConnected) return;
108
+
109
+ resolved = true;
110
+ contentEl.innerHTML = html;
111
+ setState('resolved');
112
+
113
+ // Execute any scripts in the loaded component
114
+ contentEl.querySelectorAll('script').forEach(function(script) {
115
+ const newScript = document.createElement('script');
116
+ if (script.src) {
117
+ newScript.src = script.src;
118
+ }
119
+ else {
120
+ newScript.textContent = script.textContent;
121
+ }
122
+ script.parentNode.replaceChild(newScript, script);
123
+ });
124
+
125
+ // Process signals/bindings on the loaded content ({{ }}, :attr, @event, etc.)
126
+ if (window.stx && window.stx._latestSetup) {
127
+ window.dispatchEvent(new Event('stx:load'));
128
+ }
129
+
130
+ // Notify Suspense boundary
131
+ if (suspensible && window.STX && window.STX.suspense) {
132
+ window.STX.suspense.resolve(asyncId);
133
+ }
134
+
135
+ // Dispatch loaded event
136
+ container.dispatchEvent(new CustomEvent('stx:async:loaded', {
137
+ detail: { asyncId: asyncId, component: componentPath },
138
+ bubbles: true
139
+ }));
140
+
141
+ // Load succeeded \u2014 drop the navigate-teardown listener so it doesn't
142
+ // accumulate per async component across an app's lifetime.
143
+ window.removeEventListener('stx:navigate', teardown);
144
+ }
145
+ catch (error) {
146
+ // AbortError fires when teardown() runs during an in-flight fetch.
147
+ // That's not a load failure \u2014 the component is being unmounted, so
148
+ // don't render the rejected state, don't retry, don't dispatch error.
149
+ if (aborted || (error && error.name === 'AbortError')) return;
150
+ handleError(error);
151
+ }
152
+ }
153
+
154
+ // Handle errors
155
+ function handleError(error) {
156
+ clearTimeout(delayTimer);
157
+ clearTimeout(timeoutTimer);
158
+
159
+ // The container may have been removed (e.g., a non-router :if toggle)
160
+ // between the failure and now. No DOM left to write the error state to.
161
+ if (aborted || !container.isConnected) return;
162
+
163
+ if (attempts < maxRetries) {
164
+ // Retry
165
+ console.warn('[stx:async:' + asyncId + '] Retrying... (' + attempts + '/' + maxRetries + ')');
166
+ setTimeout(loadComponent, 1000 * attempts); // Exponential backoff
167
+ return;
168
+ }
169
+
170
+ resolved = true;
171
+ setState('rejected');
172
+
173
+ // Update error content with error message
174
+ const errorMsgEl = errorEl.querySelector('[data-error-message]');
175
+ if (errorMsgEl) {
176
+ errorMsgEl.textContent = error.message;
177
+ }
178
+
179
+ // Notify Suspense boundary
180
+ if (suspensible && window.STX && window.STX.suspense) {
181
+ window.STX.suspense.reject(asyncId, error);
182
+ }
183
+
184
+ // Dispatch error event
185
+ container.dispatchEvent(new CustomEvent('stx:async:error', {
186
+ detail: { asyncId: asyncId, component: componentPath, error: error },
187
+ bubbles: true
188
+ }));
189
+
190
+ console.error('[stx:async:' + asyncId + ']', error);
191
+
192
+ // Final error state \u2014 no more retries. Drop the navigate listener so it
193
+ // doesn't outlive the (failed) component.
194
+ window.removeEventListener('stx:navigate', teardown);
195
+ }
196
+
197
+ // Retry function
198
+ function retry() {
199
+ resolved = false;
200
+ attempts = 0;
201
+ setState('pending');
202
+ loadComponent();
203
+ }
204
+
205
+ // Expose retry function
206
+ window['$stxAsyncRetry_' + asyncId.replace(/-/g, '_')] = retry;
207
+
208
+ // Make $retry available within the error content
209
+ errorEl.querySelectorAll('[onclick*="$retry"]').forEach(function(el) {
210
+ const onclick = el.getAttribute('onclick');
211
+ if (onclick) {
212
+ el.setAttribute('onclick', onclick.replace(/\\$retry\\(\\)/g, "window['$stxAsyncRetry_" + asyncId.replace(/-/g, '_') + "']()"));
213
+ }
214
+ });
215
+
216
+ // Expose API
217
+ window.STX = window.STX || {};
218
+ window.STX.asyncComponents = window.STX.asyncComponents || {};
219
+ window.STX.asyncComponents[asyncId] = {
220
+ getStatus: function() { return container.getAttribute('data-status'); },
221
+ retry: retry,
222
+ getAttempts: function() { return attempts; }
223
+ };
224
+
225
+ // Start loading
226
+ loadComponent();
227
+ })();
228
+ </script>
229
+ `}function Y(j){return{__asyncComponent:!0,...typeof j==="function"?{loader:j}:j}}function Z(j){return typeof j==="object"&&j!==null&&"__asyncComponent"in j&&j.__asyncComponent===!0}function _(){return`
230
+ /* STX Async Component Styles */
231
+ .stx-async-component {
232
+ position: relative;
233
+ }
234
+
235
+ .stx-async-loading {
236
+ display: flex;
237
+ align-items: center;
238
+ justify-content: center;
239
+ min-height: 100px;
240
+ }
241
+
242
+ .stx-async-error {
243
+ padding: 1rem;
244
+ border: 1px solid #ef4444;
245
+ border-radius: 0.5rem;
246
+ background-color: #fef2f2;
247
+ color: #991b1b;
248
+ }
249
+
250
+ .stx-async-error button {
251
+ margin-top: 0.5rem;
252
+ padding: 0.5rem 1rem;
253
+ border: 1px solid #ef4444;
254
+ border-radius: 0.25rem;
255
+ background-color: #ef4444;
256
+ color: white;
257
+ cursor: pointer;
258
+ }
259
+
260
+ .stx-async-error button:hover {
261
+ background-color: #dc2626;
262
+ }
263
+
264
+ /* Loading spinner animation */
265
+ @keyframes stx-async-spin {
266
+ to { transform: rotate(360deg); }
267
+ }
268
+
269
+ .stx-async-spinner {
270
+ width: 24px;
271
+ height: 24px;
272
+ border: 2px solid #e5e7eb;
273
+ border-top-color: #3b82f6;
274
+ border-radius: 50%;
275
+ animation: stx-async-spin 0.8s linear infinite;
276
+ }
277
+
278
+ /* Skeleton loading */
279
+ .stx-async-skeleton {
280
+ background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
281
+ background-size: 200% 100%;
282
+ animation: stx-async-shimmer 1.5s infinite;
283
+ border-radius: 0.25rem;
284
+ }
285
+
286
+ @keyframes stx-async-shimmer {
287
+ 0% { background-position: 200% 0; }
288
+ 100% { background-position: -200% 0; }
289
+ }
290
+
291
+ /* Dark mode */
292
+ @media (prefers-color-scheme: dark) {
293
+ .stx-async-error {
294
+ background-color: #450a0a;
295
+ color: #fecaca;
296
+ }
297
+
298
+ .stx-async-skeleton {
299
+ background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
300
+ background-size: 200% 100%;
301
+ }
302
+ }
303
+ `}function $(){return`
304
+ // STX Async Component Runtime
305
+ (function() {
306
+ if (typeof window === 'undefined') return;
307
+
308
+ window.STX = window.STX || {};
309
+ window.STX.asyncComponents = window.STX.asyncComponents || {};
310
+
311
+ // Load a component dynamically
312
+ window.STX.loadComponent = async function(componentPath, targetSelector, options) {
313
+ options = options || {};
314
+ const target = document.querySelector(targetSelector);
315
+ if (!target) {
316
+ throw new Error('Target element not found: ' + targetSelector);
317
+ }
318
+
319
+ const loadingHtml = options.loading || '<div class="stx-async-spinner"></div>';
320
+ target.innerHTML = loadingHtml;
321
+
322
+ try {
323
+ const response = await fetch('/_stx/component/' + encodeURIComponent(componentPath));
324
+ if (!response.ok) {
325
+ throw new Error('Failed to load: ' + response.statusText);
326
+ }
327
+
328
+ const html = await response.text();
329
+ target.innerHTML = html;
330
+
331
+ // Execute scripts
332
+ target.querySelectorAll('script').forEach(function(script) {
333
+ const newScript = document.createElement('script');
334
+ if (script.src) {
335
+ newScript.src = script.src;
336
+ }
337
+ else {
338
+ newScript.textContent = script.textContent;
339
+ }
340
+ script.parentNode.replaceChild(newScript, script);
341
+ });
342
+
343
+ if (options.onLoad) options.onLoad();
344
+ return true;
345
+ }
346
+ catch (error) {
347
+ if (options.error) {
348
+ target.innerHTML = options.error;
349
+ }
350
+ if (options.onError) options.onError(error);
351
+ throw error;
352
+ }
353
+ };
354
+
355
+ console.log('[stx] Async component runtime initialized');
356
+ })();
357
+ `}
358
+ export{X as Vh,Y as Wh,Z as Xh,_ as Yh,$ as Zh};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{$f as g,Vf as a,Wf as b,Xf as c,Yf as d,Zf as e,_f as f,ag as h}from"./chunk-9b82d4g5.js";import"./chunk-pw0rzgpv.js";export{g as timingPlugin,c as pluginManager,a as definePlugin,f as debugPlugin,h as createVariablesPlugin,e as createFilterPlugin,d as createDirectivePlugin,b as PluginManager};
@@ -0,0 +1,11 @@
1
+ // @bun
2
+ function G(j,x){let g=j[x],v=x+1;while(v<j.length){if(j[v]==="\\"){v+=2;continue}if(j[v]===g)return v+1;v++}return j.length}function H(j,x){let g=x+1;while(g<j.length){if(j[g]==="\\"){g+=2;continue}if(j[g]==="`")return g+1;if(j[g]==="$"&&j[g+1]==="{"){if(g=F(j,g+2),g<j.length)g++;continue}g++}return j.length}function F(j,x){let g=1,v=x;while(v<j.length){let z=j[v];if(z==="\\"){v+=2;continue}if(z==='"'||z==="'"){v=G(j,v);continue}if(z==="`"){v=H(j,v);continue}if(z==="/"&&j[v+1]==="/"){while(v<j.length&&j[v]!==`
3
+ `)v++;continue}if(z==="/"&&j[v+1]==="*"){v+=2;while(v<j.length&&j.slice(v,v+2)!=="*/")v++;v+=2;continue}if(z==="{"){g++,v++;continue}if(z==="}"){if(g--,g===0)return v;v++;continue}v++}return j.length}function J(j){let x="",g=0;while(g<j.length){let v=j.slice(g,g+2);if(v==="//"){while(g<j.length&&j[g]!==`
4
+ `)x+=" ",g++;continue}if(v==="/*"){while(g<j.length&&j.slice(g,g+2)!=="*/")x+=j[g]===`
5
+ `?`
6
+ `:" ",g++;x+=" ",g+=2;continue}let z=j[g];if(z==='"'||z==="'"){let B=z;x+=" ",g++;while(g<j.length&&j[g]!==B){if(j[g]==="\\"){x+=" ",g+=2;continue}x+=j[g]===`
7
+ `?`
8
+ `:" ",g++}x+=" ",g++;continue}if(z==="`"){x+=" ",g++;while(g<j.length&&j[g]!=="`"){if(j[g]==="\\"){x+=" ",g+=2;continue}if(j[g]==="$"&&j[g+1]==="{"){let B=g+2,D=F(j,B);if(x+=" ",x+=J(j.slice(B,D)),D<j.length)x+=" ";g=D+1;continue}x+=j[g]===`
9
+ `?`
10
+ `:" ",g++}x+=" ",g++;continue}x+=z,g++}return x}
11
+ export{F as gs,J as hs};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Tf as a,Uf as b}from"./chunk-1e25ksp6.js";import"./chunk-ygr11tgz.js";import"./chunk-pw0rzgpv.js";export{a as handleImageRequest,b as createImageHandler};
@@ -0,0 +1,12 @@
1
+ // @bun
2
+ import{Kl as Y,tq as x}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";import A from"path";var C=["broadcast","calculateDistance","canNotify","clearCookies","clearFetchCache","clearStorage","copyToClipboard","createShareableFile","defineForm","getBatteryLevel","getCookie","getCurrentPosition","getStorageKeys","getStorageSize","getVoices","hasBattery","hasCameraPermission","hasGeolocationPermission","hasMicrophonePermission","hasNotificationPermission","hasResizeObserver","hexToHsl","hexToRgb","isBroadcastChannelSupported","isCharging","isDeviceMotionSupported","isDeviceOrientationSupported","isEventSourceSupported","isEyeDropperSupported","isInFullscreen","isMutationObserverSupported","isPermissionGranted","isSpeechRecognitionSupported","isSpeechSynthesisSupported","isWakeLockSupported","isWebSocketSupported","notify","parseCookies","pickColor","prefetch","removeCookie","requestMediaPermissions","requestMotionPermission","requestNotificationPermission","requestOrientationPermission","setCookie","share","shareCurrentPage","shareFiles","shareText","shareURL","shareWithFallback","speak","stopSpeaking","toggleFullscreen","useAsyncData","useAttributeObserver","useAutoLogout","useAutoWakeLock","useBattery","useBreakpoint","useBroadcastChannel","useChannel","useChildListObserver","useClipboard","useColorHistory","useConditionalWakeLock","useCookies","useCopySelection","useDeviceMotion","useDeviceOrientation","useElementSize","useElementTextSelection","useElementVisibility","useEventSource","useEyeDropper","useFavicon","useForm","useFullscreen","useGeolocation","useGeolocationWatch","useHotkey","useIdle","useIdleState","useInfiniteScroll","useIntersectionObserver","useIntersectionObserverMultiple","useIsDesktop","useIsMobile","useIsTablet","useKeyPressed","useKeySequence","useKeyboard","useLastActive","useLazyLoad","useMeta","useMouse","useMouseInElement","useMutationObserver","useNetwork","useNotification","useOnline","useParallax","usePermission","usePermissions","usePointer","usePost","useResizeObserver","useResizeObserverMultiple","useSSE","useScroll","useSelectionPopup","useShare","useSpeechRecognition","useSpeechSynthesis","useStorage","useTextObserver","useTextSelection","useTitle","useVisibility","useWakeLock","useWindowSize"],y=new Set(C);var Z=new Map,I=new Set,P=new Set(C);function R(){Z.clear()}function D(G){let H=new Map;for(let z of G){let K=A.basename(z);if(K.endsWith(".d.ts"))continue;let J=K.replace(/\.[jt]s$/,"");if(J==="index")continue;if(J===K)continue;let X=H.get(J);if(X&&!X.endsWith(".js"))continue;H.set(J,z)}return[...H.values()].sort()}function L(G,H){let z=H.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(?:^|[^\\w$.])(?:const|let|var|function|class)\\s+${z}\\b`).test(G)}function k(G){if(!G)return[];let H=G.replace(/<script\b[^>]*\bdata-stx-runtime\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-framework-composables\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-stores\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-composables\b[^>]*>[\s\S]*?<\/script>/gi,""),z=[];for(let K of P){if(I.has(K))continue;let J=K.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");if(new RegExp(`(^|[^\\w$.])${J}\\s*\\(`).test(H))z.push(K)}return z.sort()}async function _(G,H){let z=k(G);if(z.length===0)return null;let K=H??A.join(import.meta.dir,"composables"),J=`${K}\x00${z.join(",")}`,X=Z.get(J);if(X!==void 0)return X||null;let T=x({loader:"ts",target:"browser",define:Y()}),B=new Set(z),F=[],w=new Set,$=[];try{let q=new Bun.Glob("*.{ts,js}");for await(let j of q.scan({cwd:K,absolute:!0}))$.push(j)}catch{return Z.set(J,""),null}$=D($);for(let q of $){let j;try{j=await Bun.file(q).text()}catch{continue}let W=[];try{W=T.scan(j).exports.filter((Q)=>Q!=="default")}catch{continue}if(!W.some((Q)=>B.has(Q)))continue;try{j=j.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),j=j.replace(/^import\s+type\s+.*$/gm,""),j=j.replace(/^export\s+\*\s+(?:as\s+\w+\s+)?from\s*['"][^'"]+['"]\s*;?\s*$/gm,""),j=j.replace(/^export\s+(?:type\s+)?\{[\s\S]*?\}\s*(?:from\s*['"][^'"]+['"]\s*)?;?\s*$/gm,""),j=j.replace(/^export\s+default\s+/gm,""),j=j.replace(/^export\s+(?=(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\b)/gm,""),F.push(`// ${A.basename(q).replace(/\.[jt]s$/,"")}
3
+ ${T.transformSync(j).trim()}`);for(let Q of W)w.add(Q)}catch(Q){console.warn(`[stx] framework composable ${A.basename(q)} could not be bundled:`,Q)}}let U=z.filter((q)=>!w.has(q)&&!L(G,q));if(U.length>0)console.warn(`[stx] could not bundle ${U.join(", ")} from @stacksjs/stx/composables \u2014 `+"calls to them will throw ReferenceError in the browser. Import them explicitly so the bundler inlines them, or use a runtime equivalent from window.stx.");if(F.length===0)return Z.set(J,""),null;let M=[...w].map((q)=>` try { if (!(${JSON.stringify(q)} in __s)) { __s[${JSON.stringify(q)}] = ${q}; if (!(${JSON.stringify(q)} in window)) window[${JSON.stringify(q)}] = ${q}; } } catch (e) {}`).join(`
4
+ `),V=`<script data-stx-framework-composables>
5
+ ;(function(){
6
+ var __s = window.stx = window.stx || {};
7
+ ${F.join(`
8
+
9
+ `)}
10
+ ${M}
11
+ })();
12
+ </script>`;return Z.set(J,V),V}function v(G){I.clear();for(let H of G)I.add(H)}export{D as selectComposableFiles,k as referencedFrameworkComposables,_ as getFrameworkComposableScript,R as clearFrameworkComposableCache,v as __setRuntimeOwnedForTest};
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{Fj as _}from"./chunk-3es366z4.js";function Y(q,z){let B={};for(let C of q)B[C]=_(z(C));return new Proxy({},{get:(C,G)=>B[G]?.(),set:(C,G,L)=>{if(B[G])B[G].set(L);else B[G]=_(L);return!0},has:(C,G)=>(G in B),deleteProperty:(C,G)=>{return delete B[G],!0},ownKeys:()=>Reflect.ownKeys(B),getOwnPropertyDescriptor:(C,G)=>(G in B)?{enumerable:!0,configurable:!0,writable:!0,value:B[G]()}:void 0})}function T(q,z){let B={};for(let C of z)B[C]=q[C];return B}function $(q,z){let B=Object.keys(q),C=Y(B,(I)=>z?.[I]??q[I].getDefaultValue()),G=Y(B,()=>[]),L=Y(B,()=>!1),W=Y(B,()=>!1),X=Y(B,()=>!1),J=_(!1);async function M(I){X[I]=!0;let Q=await q[I].validate(C[I],C);return G[I]=Q,X[I]=!1,Q.length===0}async function O(){J.set(!0);let I=await Promise.all(B.map(M));return J.set(!1),I.every(Boolean)}function j(){for(let I of B)C[I]=z?.[I]??q[I].getDefaultValue(),G[I]=[],L[I]=!1,W[I]=!1}function A(I){for(let Q of B)if(Q in I)C[Q]=I[Q],W[Q]=!0}function H(I,Q){C[I]=Q,W[I]=!0}function K(I,Q=!0){if(L[I]=Q,Q)M(I)}function U(I){return{value:C[I],errors:G[I],touched:L[I],dirty:W[I],valid:G[I].length===0,validating:X[I]}}function k(I){return async(Q)=>{Q?.preventDefault?.();for(let N of B)L[N]=!0;if(await O())await I(T(C,B))}}return{values:C,errors:G,touched:L,dirty:W,get isValid(){return B.every((I)=>G[I].length===0)},get isValidating(){return J()||B.some((I)=>X[I])},get isDirty(){return B.some((I)=>W[I])},validate:O,validateField:M,reset:j,setValues:A,setFieldValue:H,setFieldTouched:K,getFieldState:U,handleSubmit:k}}var E=$;class Z{rules=[];defaultValue="";addRule(q){let z=new Z;return z.rules=[...this.rules,q],z.defaultValue=this.defaultValue,z}required(q="This field is required"){return this.addRule({name:"required",message:q,validate:(z)=>{if(z===null||z===void 0)return q;if(typeof z==="string"&&z.trim()==="")return q;if(Array.isArray(z)&&z.length===0)return q;return!0}})}email(q="Please enter a valid email"){return this.addRule({name:"email",message:q,validate:(z)=>{if(!z)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(z))||q}})}url(q="Please enter a valid URL"){return this.addRule({name:"url",message:q,validate:(z)=>{if(!z)return!0;try{return new URL(String(z)),!0}catch{return q}}})}min(q,z){let B=z||`Must be at least ${q} characters`;return this.addRule({name:"min",message:B,validate:(C)=>{if(!C)return!0;return String(C).length>=q||B}})}max(q,z){let B=z||`Must be no more than ${q} characters`;return this.addRule({name:"max",message:B,validate:(C)=>{if(!C)return!0;return String(C).length<=q||B}})}length(q,z,B){let C=B||`Must be between ${q} and ${z} characters`;return this.addRule({name:"length",message:C,validate:(G)=>{if(!G)return!0;let L=String(G).length;return L>=q&&L<=z||C}})}pattern(q,z="Invalid format"){return this.addRule({name:"pattern",message:z,validate:(B)=>{if(!B)return!0;return q.test(String(B))||z}})}hasUppercase(q="Must contain an uppercase letter"){return this.pattern(/[A-Z]/,q)}hasLowercase(q="Must contain a lowercase letter"){return this.pattern(/[a-z]/,q)}hasNumber(q="Must contain a number"){return this.pattern(/\d/,q)}hasSpecial(q="Must contain a special character"){return this.pattern(/[!@#$%^&*(),.?":{}|<>]/,q)}alphanumeric(q="Only letters and numbers allowed"){return this.pattern(/^[a-zA-Z0-9]+$/,q)}startsWithLetter(q="Must start with a letter"){return this.pattern(/^[a-zA-Z]/,q)}noSpaces(q="Spaces are not allowed"){return this.addRule({name:"noSpaces",message:q,validate:(z)=>{if(!z)return!0;return!String(z).includes(" ")||q}})}number(q="Must be a number"){let z=this.addRule({name:"number",message:q,validate:(B)=>{if(!B&&B!==0)return!0;return!Number.isNaN(Number(B))||q}});return z.defaultValue=0,z}integer(q="Must be a whole number"){return this.addRule({name:"integer",message:q,validate:(z)=>{if(!z&&z!==0)return!0;return Number.isInteger(Number(z))||q}})}positive(q="Must be a positive number"){return this.addRule({name:"positive",message:q,validate:(z)=>{if(!z&&z!==0)return!0;return Number(z)>0||q}})}negative(q="Must be a negative number"){return this.addRule({name:"negative",message:q,validate:(z)=>{if(!z&&z!==0)return!0;return Number(z)<0||q}})}minValue(q,z){let B=z||`Must be at least ${q}`;return this.addRule({name:"minValue",message:B,validate:(C)=>{if(!C&&C!==0)return!0;return Number(C)>=q||B}})}maxValue(q,z){let B=z||`Must be no more than ${q}`;return this.addRule({name:"maxValue",message:B,validate:(C)=>{if(!C&&C!==0)return!0;return Number(C)<=q||B}})}between(q,z,B){let C=B||`Must be between ${q} and ${z}`;return this.addRule({name:"between",message:C,validate:(G)=>{if(!G&&G!==0)return!0;let L=Number(G);return L>=q&&L<=z||C}})}matches(q,z){let B=z||`Must match ${q}`;return this.addRule({name:"matches",message:B,validate:(C,G)=>{if(!G)return!0;return C===G[q]||B}})}oneOf(q,z){let B=z||`Must be one of: ${q.join(", ")}`;return this.addRule({name:"oneOf",message:B,validate:(C)=>{if(!C)return!0;return q.includes(C)||B}})}notOneOf(q,z){let B=z||`Cannot be one of: ${q.join(", ")}`;return this.addRule({name:"notOneOf",message:B,validate:(C)=>{if(!C)return!0;return!q.includes(C)||B}})}date(q="Must be a valid date"){return this.addRule({name:"date",message:q,validate:(z)=>{if(!z)return!0;let B=new Date(String(z));return!Number.isNaN(B.getTime())||q}})}before(q,z){let B=new Date(q),C=z||`Must be before ${B.toLocaleDateString()}`;return this.addRule({name:"before",message:C,validate:(G)=>{if(!G)return!0;return new Date(String(G))<B||C}})}after(q,z){let B=new Date(q),C=z||`Must be after ${B.toLocaleDateString()}`;return this.addRule({name:"after",message:C,validate:(G)=>{if(!G)return!0;return new Date(String(G))>B||C}})}custom(q,z="Invalid value"){return this.addRule({name:"custom",message:z,validate:q})}async(q,z="Invalid value"){return this.addRule({name:"async",message:z,async:!0,validate:q})}when(q,z){let B=new Z;B.rules=[...this.rules],B.defaultValue=this.defaultValue;for(let C of z.getRules())B.rules.push({...C,validate:(G,L)=>{if(!q(G,L||{}))return!0;return C.validate(G,L)}});return B}getRules(){return this.rules}getDefaultValue(){return this.defaultValue}default(q){let z=new Z;return z.rules=[...this.rules],z.defaultValue=q,z}async validate(q,z){let B=[];for(let C of this.rules){let G=await C.validate(q,z);if(G!==!0)B.push(G)}return B}validateSync(q,z){let B=[];for(let C of this.rules){if(C.async)continue;let G=C.validate(q,z);if(G!==!0)B.push(G)}return B}}var y=new Z;function w(q,z,B){let C=/@error\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderror/g;return q.replace(C,(G,L,W)=>{try{let X=L.trim().split("."),J=z;for(let O of X)if(J&&typeof J==="object"&&O in J)J=J[O];else return"";let M=J;if(!M||!Array.isArray(M)||M.length===0)return"";return M.map((O)=>{return W.replace(/\{\{\s*message\s*\}\}/g,O)}).join(`
3
+ `)}catch{return""}})}function D(q,z,B){let C=/@errors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderrors/g;return q.replace(C,(G,L,W)=>{try{let X=L.trim().split("."),J=z;for(let O of X)if(J&&typeof J==="object"&&O in J)J=J[O];else return"";let M=J;if(!M||!Array.isArray(M)||M.length===0)return"";return M.map((O)=>W.replace(/\{\{\s*message\s*\}\}/g,O)).join(`
4
+ `)}catch{return""}})}function S(q,z,B){let C=/@hasErrors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@endhasErrors/g;return q.replace(C,(G,L,W)=>{try{let X=L.trim().split("."),J=z;for(let O of X)if(J&&typeof J==="object"&&O in J)J=J[O];else return"";let M=J;if(!M||!Array.isArray(M)||M.length===0)return"";return W}catch{return""}})}function V(q,z,B){let C=q;return C=w(C,z,B),C=D(C,z,B),C=S(C,z,B),C}export{$ as Bi,E as Ci,Z as Di,y as Ei,w as Fi,D as Gi,S as Hi,V as Ii};
@@ -0,0 +1,28 @@
1
+ // @bun
2
+ import{$i as U,Zi as _,_i as v}from"./chunk-ht51fz7w.js";import{Il as C,Jl as N,Kl as E,Kr as S,tq as T}from"./chunk-r6p4ws0a.js";import{dt as y}from"./chunk-kjr22neh.js";import L from"path";var j=new Map,M=new Map,b=["composables","functions"];function K(V){let J=L.basename(V,".ts");return J==="index"||J==="types"||V.endsWith(".d.ts")}async function F(V){if(V)return L.resolve(V);let J=`<default>:${process.cwd()}`,Q=M.get(J);if(Q!==void 0)return Q;let z=await h();if(z!==null)M.set(J,z);return z}async function h(){let V=await S(),J=V.root||process.cwd(),Q=V.composablesDir;if(Q)return L.resolve(J,Q);for(let z of b){let Z=L.resolve(J,z);try{let W=new Bun.Glob("**/*.ts");for await(let Y of W.scan({cwd:Z,absolute:!0}))if(!K(Y))return Z}catch{}}return null}async function s(V){let J=await F(V);if(!J)return[];let Q=[];try{let W=new Bun.Glob("**/*.ts");for await(let Y of W.scan({cwd:J,absolute:!0}))if(!K(Y))Q.push(Y)}catch{return[]}Q.sort();let z=T({loader:"ts",target:"browser",define:E()}),Z=[];for(let W of Q)try{let Y=await Bun.file(W).text(),G=z.scan(Y).exports.filter(($)=>$!=="default");if(G.length>0)Z.push({file:W,names:G})}catch{}return Z}function u(V,J){return new RegExp(`\\b${J.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(V)}function f(V,J,Q){let z=new Map;for(let{file:G,names:$}of V)for(let O of $)if(!z.has(O))z.set(O,G);let Z=(G)=>{let $=[];for(let[O,P]of z)if(u(G,O))$.push(P);return $},W=new Set,Y=Z(Q);while(Y.length>0){let G=[];for(let $ of Y){if(W.has($))continue;W.add($);for(let O of Z(J.get($)??""))if(!W.has(O))G.push(O)}Y=G}return W}async function i(V,J){let Q=await F(V);if(!Q)return null;let z=[];try{let q=new Bun.Glob("**/*.ts");for await(let H of q.scan({cwd:Q,absolute:!0})){if(K(H))continue;z.push(H)}}catch{return U(j,Q,"",""),null}let Z=_(z);if(z.length===0)return U(j,Q,Z,""),null;z.sort();let W=T({loader:"ts",target:"browser",define:E()}),Y=new Map,G=[];for(let q of z)try{let H=await Bun.file(q).text();Y.set(q,H);let w=W.scan(H).exports.filter((X)=>X!=="default");if(w.length>0)G.push({file:q,names:w})}catch{Y.set(q,"")}let $=J===void 0?new Set(z):f(G,Y,J);if($.size===0)return null;let O=z.filter((q)=>$.has(q)),P=`${Q}\x00${O.join("\x00")}`,B=v(j,P,Z);if(B!==void 0)return B||null;let A=[],R=new Set,I=new Set;for(let q of O)try{let H=Y.get(q)??await Bun.file(q).text(),w=L.basename(q,".ts");for(let X of H.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(X[1])I.add(X[1]);try{for(let X of W.scan(H).exports)if(X!=="default")R.add(X)}catch{}H=C(H),H=N(H),H=H.replace(/^export\s+(default\s+)?/gm,""),H=W.transformSync(H),A.push(`// Composable: ${w}
3
+ ${H.trim()}`)}catch(H){console.warn(`[stx] Failed to load composable ${q}:`,H)}if(A.length===0||R.size===0)return U(j,P,Z,""),null;let D=[...R].map((q)=>` try { __c[${JSON.stringify(q)}] = ${q}; } catch (e) {}`).join(`
4
+ `),g=JSON.stringify([...R]),k=A.join(`
5
+
6
+ `),x=`;(function(){
7
+ window.__composables = window.__composables || {};
8
+ var __c = window.__composables;
9
+ var __stx = window.stx || {};
10
+ ${y.filter((q)=>!I.has(q)&&new RegExp(`\\b${q}\\b`).test(k)).map((q)=>`var ${q} = __stx[${JSON.stringify(q)}];`).join(`
11
+ `)}
12
+ ${k}
13
+ ${D}
14
+ var __names = ${g};
15
+ for (var __i = 0; __i < __names.length; __i++) {
16
+ var __n = __names[__i];
17
+ if (!(__n in __c)) continue;
18
+ var __takenByBuiltin = !!(window.stx && __n in window.stx);
19
+ if (__takenByBuiltin || __n in window) {
20
+ console.warn('[stx] composable "' + __n + '" is not available as a bare identifier: '
21
+ + (__takenByBuiltin ? 'a built-in of that name already exists' : 'window already defines that property')
22
+ + '. Rename it, or use: import { ' + __n + ' } from "@composables"');
23
+ continue;
24
+ }
25
+ window[__n] = __c[__n];
26
+ }
27
+ })();`;return U(j,P,Z,x),x}function o(){j.clear(),M.clear()}
28
+ export{s as Wi,i as Xi,o as Yi};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import k from"fs";import q from"path";var x="resources/assets",D="assets";function F(m=process.cwd()){let g=q.resolve(m,x);return k.existsSync(g)&&k.statSync(g).isDirectory()?g:null}
3
+ export{x as yk,D as zk,F as Ak};
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ import{Zt as y}from"./chunk-3952ykhb.js";import N from"fs";import B from"path";var Y="_stx";function L(M){return Bun.hash(M).toString(16).slice(0,8)}function T(M){let C=[],v=(q)=>{for(let g of N.readdirSync(q,{withFileTypes:!0})){let j=B.join(q,g.name);if(g.isDirectory())v(j);else if(g.isFile()&&j.endsWith(".html"))C.push(j)}};if(N.existsSync(M))v(M);return C}var S=[{pattern:/<script\b([^>]*\bdata-stx-runtime\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"runtime",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(M)=>`<script data-stx-runtime src="${M}"></script>`},{pattern:/<script\b([^>]*\bdata-stx-router\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"router",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(M)=>`<script data-stx-router src="${M}"></script>`},{pattern:/<style\b([^>]*\bdata-crosswind=(?:"generated"|'generated')[^>]*)>([\s\S]*?)<\/style>/gi,prefix:"crosswind",extension:"css",contentType:"text/css; charset=utf-8",replace:(M)=>`<link data-crosswind="generated" rel="stylesheet" href="${M}">`}];function _(M,C=`/${Y}`){let v=[],q=new Set,g=0,j=M;for(let G of S)j=j.replace(G.pattern,(R,K,W)=>{if(/\b(?:src|href)\s*=/.test(K)||!W.trim())return R;let Q=`${G.prefix}.${L(W)}.${G.extension}`;if(!q.has(Q))q.add(Q),v.push({filename:Q,contents:W,contentType:G.contentType});return g+=W.length,G.replace(`${C}/${Q}`)});return{html:j,assets:v,bytesInlined:g}}function a(M){let C={pages:0,assets:0,bytesInlined:0},v=B.join(M,Y),q=new Set;for(let g of T(M)){let j=N.readFileSync(g,"utf8"),{html:G,assets:R,bytesInlined:K}=_(j);if(G===j)continue;for(let W of R){if(q.has(W.filename))continue;q.add(W.filename),N.mkdirSync(v,{recursive:!0}),N.writeFileSync(B.join(v,W.filename),W.contents),C.assets++}N.writeFileSync(g,G),C.bytesInlined+=K,C.pages++}return C}import z from"fs";import P from"path";var I=1024,E=/<(script|style)\b([^>]*)>([\s\S]*?)<\/\1>/gi,d=new Set(["","module","text/javascript","application/javascript","module/javascript"]);function b(M){return Bun.hash(M).toString(16).slice(0,8)}function p(M){let C=[],v=(q)=>{for(let g of z.readdirSync(q,{withFileTypes:!0})){let j=P.join(q,g.name);if(g.isDirectory())v(j);else if(g.isFile()&&j.endsWith(".html"))C.push(j)}};if(z.existsSync(M))v(M);return C}function D(M,C){let v=M.match(new RegExp(`\\b${C}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i"));if(!v)return;return v[2]??v[3]??v[4]??""}function m(M,C,v){if(v.length<I)return!1;if(/\b(?:src|href)\s*=/i.test(C))return!1;if(M.toLowerCase()==="script"){if(!d.has((D(C,"type")??"").trim().toLowerCase()))return!1;return!0}return!0}function o(M){let C=[];for(let v of M.matchAll(/<template\b[^>]*>[\s\S]*?<\/template>/gi))C.push([v.index,v.index+v[0].length]);return C}function s(M){let C={pages:0,assets:0,bytesInlined:0},v=p(M);if(v.length<2)return C;let q=new Map,g=new Map;for(let Q of v){let O=z.readFileSync(Q,"utf8");q.set(Q,O);let x=o(O);for(let U of O.matchAll(E)){let[w,V,J,$]=U;if(!m(V,J,$))continue;if(x.some(([A,k])=>U.index>=A&&U.index<k))continue;let H=`${V.toLowerCase()}\x00${$}`,X=g.get(H);if(X)X.push({file:Q,whole:w,tag:V,attrs:J,body:$});else g.set(H,[{file:Q,whole:w,tag:V,attrs:J,body:$}])}}let j=[...g.values()].filter((Q)=>new Set(Q.map((O)=>O.file)).size>1);if(j.length===0)return C;let G=P.join(M,Y),R=new Map(q),K=new Map,W=[];for(let Q of j){let{tag:O,body:x}=Q[0],U=O.toLowerCase()==="script",w=`${U?"chunk":"style"}.${b(x)}.${U?"js":"css"}`;W.push({filename:w,contents:x,contentType:U?"text/javascript; charset=utf-8":"text/css; charset=utf-8"});let V=`/${Y}/${w}`;for(let J of Q){let $=U?`<script${J.attrs} src="${V}"></script>`:`<link${J.attrs} rel="stylesheet" href="${V}">`,H=R.get(J.file),X=H.replace(J.whole,()=>$);if(X===H)continue;R.set(J.file,X),K.set(J.file,(K.get(J.file)??0)+J.body.length)}}z.mkdirSync(G,{recursive:!0});for(let Q of W)z.writeFileSync(P.join(G,Q.filename),Q.contents),C.assets++;for(let[Q,O]of R){if(O===q.get(Q))continue;z.writeFileSync(Q,O),C.pages++,C.bytesInlined+=K.get(Q)??0}return C}y();import Z from"fs";import F from"path";var h="layout-types.d.ts";function f(M){let C=[],v=(q,g)=>{let j;try{j=Z.readdirSync(q,{withFileTypes:!0})}catch{return}for(let G of j){if(G.name.startsWith("."))continue;let R=F.join(q,G.name);if(G.isDirectory())v(R,g?`${g}/${G.name}`:G.name);else if(G.isFile()&&G.name.endsWith(".stx")&&G.name!=="_layout.stx"){let K=G.name.slice(0,-4);C.push(g?`${g}/${K}`:K)}}};return v(M,""),C.sort()}function c(M){let C=["// Auto-generated by stx \u2014 do not edit.","//","// Makes `definePageMeta({ layout })` reject a name with no layout behind it.","// Include this file in your tsconfig (it lives in the stx state directory,","// `.stx/` by default) for the check to apply.",""];if(M.length===0)return C.push("// No layouts found \u2014 `layout` stays typed as `string`.","export {}",""),C.join(`
3
+ `);return C.push("declare module '@stacksjs/stx' {"," interface KnownLayouts {",...M.map((v)=>` '${v}': true`)," }","}","","export {}",""),C.join(`
4
+ `)}function HM(M,C){if(!M)return[];let v=F.isAbsolute(M)?M:F.resolve(process.cwd(),M),q=f(v),g=c(q),j=F.join(C,h);try{if(Z.existsSync(j)&&Z.readFileSync(j,"utf8")===g)return q;Z.mkdirSync(C,{recursive:!0}),Z.writeFileSync(j,g)}catch{}return q}
5
+ export{Y as qk,_ as rk,a as sk,s as tk,h as uk,f as vk,c as wk,HM as xk};
@@ -0,0 +1,8 @@
1
+ // @bun
2
+ import Q from"fs";import U from"path";function W(H){let v=[],j=H.pwa;if(v.push({id:"pwa-enabled",name:"PWA Enabled",category:"required",passed:j?.enabled===!0,message:j?.enabled?"PWA is enabled":"PWA is not enabled in config"}),!j?.enabled)return v;v.push({id:"manifest-name",name:"App Name",category:"required",passed:Boolean(j.manifest?.name),message:j.manifest?.name?`App name: "${j.manifest.name}"`:"Missing required manifest name"}),v.push({id:"manifest-short-name",name:"Short Name",category:"recommended",passed:Boolean(j.manifest?.shortName),message:j.manifest?.shortName?`Short name: "${j.manifest.shortName}"`:"Short name not set (will use full name)"}),v.push({id:"manifest-description",name:"App Description",category:"recommended",passed:Boolean(j.manifest?.description),message:j.manifest?.description?"Description is set":"App description not provided"}),v.push({id:"manifest-theme-color",name:"Theme Color",category:"required",passed:Boolean(j.manifest?.themeColor),message:j.manifest?.themeColor?`Theme color: ${j.manifest.themeColor}`:"Theme color not set"}),v.push({id:"manifest-background-color",name:"Background Color",category:"required",passed:Boolean(j.manifest?.backgroundColor),message:j.manifest?.backgroundColor?`Background color: ${j.manifest.backgroundColor}`:"Background color not set"}),v.push({id:"manifest-display",name:"Display Mode",category:"required",passed:["standalone","fullscreen","minimal-ui"].includes(j.manifest?.display||""),message:j.manifest?.display?`Display mode: ${j.manifest.display}`:"Display mode should be standalone, fullscreen, or minimal-ui"}),v.push({id:"manifest-start-url",name:"Start URL",category:"required",passed:Boolean(j.manifest?.startUrl),message:j.manifest?.startUrl?`Start URL: ${j.manifest.startUrl}`:"Start URL not set"}),v.push({id:"icons-source",name:"Icon Source",category:"required",passed:Boolean(j.icons?.src),message:j.icons?.src?`Icon source: ${j.icons.src}`:"No icon source configured"});let J=j.icons?.sizes||[];v.push({id:"icons-192",name:"192x192 Icon",category:"required",passed:J.includes(192),message:J.includes(192)?"192x192 icon will be generated":"Missing 192x192 icon (required for Android)"}),v.push({id:"icons-512",name:"512x512 Icon",category:"required",passed:J.includes(512),message:J.includes(512)?"512x512 icon will be generated":"Missing 512x512 icon (required for splash screen)"}),v.push({id:"icons-maskable",name:"Maskable Icon",category:"recommended",passed:j.icons?.purpose?.includes("maskable")||!1,message:j.icons?.purpose?.includes("maskable")?"Maskable icon purpose is set":"Consider adding maskable icon purpose for adaptive icons"}),v.push({id:"sw-configured",name:"Service Worker",category:"required",passed:Boolean(j.serviceWorker),message:j.serviceWorker?"Service worker is configured":"Service worker configuration missing"}),v.push({id:"sw-cache-version",name:"Cache Version",category:"recommended",passed:Boolean(j.serviceWorker?.cacheVersion),message:j.serviceWorker?.cacheVersion?`Cache version: ${j.serviceWorker.cacheVersion}`:"Set cache version for proper cache busting"}),v.push({id:"offline-enabled",name:"Offline Support",category:"required",passed:j.offline?.enabled===!0,message:j.offline?.enabled?"Offline support is enabled":"Offline support is disabled"});let L=j.routes||[];return v.push({id:"caching-strategies",name:"Caching Strategies",category:"recommended",passed:L.length>0,message:L.length>0?`${L.length} route caching strategies configured`:"No custom caching strategies defined"}),v.push({id:"push-config",name:"Push Notifications",category:"optional",passed:!j.push?.enabled||Boolean(j.push?.vapidPublicKey),message:j.push?.enabled?j.push?.vapidPublicKey?"Push notifications configured with VAPID key":"Push enabled but missing VAPID key":"Push notifications not enabled"}),v.push({id:"share-target",name:"Share Target",category:"optional",passed:!0,message:j.shareTarget?.enabled?`Share target enabled at ${j.shareTarget.action}`:"Share target not enabled"}),v.push({id:"auto-inject",name:"Auto-injection",category:"recommended",passed:j.autoInject!==!1,message:j.autoInject!==!1?"PWA tags will be auto-injected":"Auto-injection disabled - manual tag insertion required"}),v}function X(H){let v=[],j=U.join(H,"manifest.json"),J=Q.existsSync(j);if(v.push({id:"build-manifest",name:"Manifest File",category:"required",passed:J,message:J?"manifest.json exists":"manifest.json not found in build output"}),J)try{let M=JSON.parse(Q.readFileSync(j,"utf-8"));v.push({id:"build-manifest-valid",name:"Valid Manifest JSON",category:"required",passed:!0,message:"Manifest is valid JSON"}),v.push({id:"build-manifest-icons",name:"Manifest Icons",category:"required",passed:Array.isArray(M.icons)&&M.icons.length>0,message:M.icons?.length?`${M.icons.length} icons defined in manifest`:"No icons defined in manifest"})}catch{v.push({id:"build-manifest-valid",name:"Valid Manifest JSON",category:"required",passed:!1,message:"Manifest is not valid JSON"})}let L=U.join(H,"sw.js"),N=Q.existsSync(L);v.push({id:"build-sw",name:"Service Worker File",category:"required",passed:N,message:N?"Service worker (sw.js) exists":"Service worker not found in build output"});let K=U.join(H,"offline.html"),T=Q.existsSync(K);v.push({id:"build-offline",name:"Offline Page",category:"recommended",passed:T,message:T?"Offline page exists":"No offline.html found"});let I=U.join(H,"pwa-icons");if(Q.existsSync(I)){let M=Q.readdirSync(I).filter((V)=>V.endsWith(".png")||V.endsWith(".webp"));v.push({id:"build-icons",name:"Generated Icons",category:"required",passed:M.length>0,message:M.length>0?`${M.length} icon files generated`:"No icon files found"})}else v.push({id:"build-icons",name:"Generated Icons",category:"required",passed:!1,message:"Icons directory not found"});return v}function Y(H){let v=H.filter((I)=>I.category==="required"),j=H.filter((I)=>I.category==="recommended"),J=v.filter((I)=>I.passed).length,L=j.filter((I)=>I.passed).length,N=v.length>0?J/v.length*70:70,K=j.length>0?L/j.length*30:30;return{score:Math.round(N+K),passed:H.filter((I)=>I.passed).length,failed:H.filter((I)=>!I.passed&&I.category==="required").length,warnings:H.filter((I)=>!I.passed&&I.category!=="required").length,checks:H}}function A(H,v){let j=W(H),J=v&&Q.existsSync(v)?X(v):[];return Y([...j,...J])}function B(H){let v=[];v.push(`
3
+ === PWA Audit Report ===
4
+ `);let j=H.score>=90?"32":H.score>=70?"33":"31";v.push(`Score: \x1B[${j}m${H.score}/100\x1B[0m`),v.push(`Passed: ${H.passed} | Failed: ${H.failed} | Warnings: ${H.warnings}
5
+ `);let J=["required","recommended","optional"];for(let L of J){let N=H.checks.filter((K)=>K.category===L);if(N.length===0)continue;v.push(`
6
+ ${L.toUpperCase()}:`);for(let K of N){let T=K.passed?"\x1B[32m\u2713\x1B[0m":"\x1B[31m\u2717\x1B[0m";if(v.push(` ${T} ${K.name}: ${K.message}`),K.details)v.push(` ${K.details}`)}}return v.push(""),v.join(`
7
+ `)}
8
+ export{W as Bk,X as Ck,Y as Dk,A as Ek,B as Fk};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{hu as l}from"./chunk-pw0rzgpv.js";import U from"fs";import G from"path";import I from"os";import H from"crypto";import{generatePlaceholder as m,processImage as g}from"ts-images";var d=[320,640,768,1024,1280,1536,1920],h=["webp","jpeg"],b=80,u=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],P={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"},N=null,W=!1;async function Y(){if(W)return N;W=!0;try{let J=await import("sharp");return N=J.default||J,N}catch{return null}}async function e(){return await Y()!==null}async function t(){return!0}async function JJ(J,K={}){let{widths:Z=d,formats:$=h,quality:q=b,fit:C="cover",placeholder:X="none",outputDir:Q=".stx/images",baseUrl:_="/images"}=K,j,x;if(typeof J==="string"){if(x=J,!await Bun.file(J).exists())throw new L(`Image not found: ${J}`,"NOT_FOUND");j=await Bun.file(J).arrayBuffer().then((V)=>Buffer.from(V))}else x="buffer-input",j=J;let w=H.createHash("sha256").update(j).digest("hex").slice(0,12),y=await O(j),{width:B,height:D}=y,A=B/D;await U.promises.mkdir(Q,{recursive:!0});let T=[],v=G.basename(x,G.extname(x)),z=Z.filter((V)=>V<=B);if(!z.includes(B)&&B<=Math.max(...Z))z.push(B);z.sort((V,R)=>V-R);for(let V of z){let R=Math.round(V/A);for(let F of $){let S=`${v}-${V}w-${w}.${F}`,k=G.join(Q,S),c=`${_}/${S}`,E=await n(j,{width:V,height:R,format:F,quality:q,fit:C});await Bun.write(k,E),T.push({path:k,url:c,width:V,height:R,format:F,size:E.length})}}let M;if(X!=="none")M=await o(j,X);return{src:x,variants:T,placeholder:M,width:B,height:D,aspectRatio:A,hash:w}}async function O(J){let K=typeof J==="string"?Buffer.from(await Bun.file(J).arrayBuffer()):J,Z=await Y();if(Z){let q=await Z(K).metadata();return{width:q.width||0,height:q.height||0,format:q.format||"unknown",hasAlpha:q.hasAlpha}}return p(K)}function p(J){if(J[0]===137&&J[1]===80&&J[2]===78&&J[3]===71){let K=J.readUInt32BE(16),Z=J.readUInt32BE(20);return{width:K,height:Z,format:"png",hasAlpha:!0}}if(J[0]===255&&J[1]===216){let K=2;while(K<J.length){if(J[K]!==255)break;let Z=J[K+1];if(Z>=192&&Z<=207&&Z!==196&&Z!==200&&Z!==204){let q=J.readUInt16BE(K+5);return{width:J.readUInt16BE(K+7),height:q,format:"jpeg",hasAlpha:!1}}let $=J.readUInt16BE(K+2);K+=2+$}}if(J.toString("utf8",0,4)==="RIFF"&&J.toString("utf8",8,12)==="WEBP"){let K=J.toString("utf8",12,16);if(K==="VP8 "){let Z=J.readUInt16LE(26)&16383,$=J.readUInt16LE(28)&16383;return{width:Z,height:$,format:"webp",hasAlpha:!1}}if(K==="VP8L"){let Z=J.readUInt32LE(21),$=(Z&16383)+1,q=(Z>>14&16383)+1;return{width:$,height:q,format:"webp",hasAlpha:!0}}}if(J.toString("utf8",0,3)==="GIF"){let K=J.readUInt16LE(6),Z=J.readUInt16LE(8);return{width:K,height:Z,format:"gif",hasAlpha:!0}}throw new L("Unable to parse image dimensions","PARSE_ERROR")}async function n(J,K){let Z=await Y();if(Z){let q=Z(J).resize(K.width,K.height,{fit:K.fit});switch(K.format){case"webp":q=q.webp({quality:K.quality});break;case"avif":q=q.avif({quality:K.quality});break;case"jpeg":q=q.jpeg({quality:K.quality});break;case"png":q=q.png({quality:K.quality});break}return q.toBuffer()}let $=G.join(I.tmpdir(),`stx-img-${H.randomBytes(8).toString("hex")}.${K.format}`);try{return await g({input:J,output:$,format:K.format,quality:K.quality,resize:{width:K.width,height:K.height,fit:K.fit}}),Buffer.from(await Bun.file($).arrayBuffer())}finally{await U.promises.unlink($).catch(()=>{})}}async function o(J,K){let Z=await Y();if(K==="blur"&&Z){let X=(await Z(J).resize(20).blur(10).toBuffer()).toString("base64"),Q=await O(J);return`data:${P[Q.format]||"image/jpeg"};base64,${X}`}if(K==="dominant-color"&&Z){let{dominant:C}=await Z(J).resize(1,1).toBuffer().then(async(X)=>{let Q=await Z(X).metadata();return{dominant:{r:128,g:128,b:128}}}).catch(()=>({dominant:{r:128,g:128,b:128}}));return`rgb(${C.r}, ${C.g}, ${C.b})`}let $=await O(J),q=G.join(I.tmpdir(),`stx-ph-${H.randomBytes(8).toString("hex")}.${$.format==="unknown"?"bin":$.format}`);try{await Bun.write(q,J);let C=K==="blur"?"blur":K==="thumbhash"?"thumbhash":"dominant-color",Q=await m(q,{strategy:C,width:C==="thumbhash"?void 0:32});if(K==="dominant-color"&&Q.dominantColor)return Q.dominantColor;if(Q.dataURL)return Q.dataURL;return"rgb(128, 128, 128)"}catch{return"rgb(128, 128, 128)"}finally{await U.promises.unlink(q).catch(()=>{})}}function KJ(J,K){return(K?J.filter(($)=>$.format===K):J).sort(($,q)=>$.width-q.width).map(($)=>`${$.url} ${$.width}w`).join(", ")}function ZJ(J){if(!J||Object.keys(J).length===0)return"100vw";return Object.entries(J).sort((Z,$)=>{let q=Number.parseInt(Z[0].replace(/\D/g,""))||0;return(Number.parseInt($[0].replace(/\D/g,""))||0)-q}).map(([Z,$])=>`(max-width: ${Z}) ${$}`).join(", ")+", 100vw"}function $J(J){let K=J.filter(($)=>$.format==="jpeg");if(K.length===0)return J[Math.floor(J.length/2)];let Z=K.sort(($,q)=>$.width-q.width);return Z[Math.floor(Z.length/2)]}function qJ(J){let K=new Map;for(let Z of J){let $=K.get(Z.format)||[];$.push(Z),K.set(Z.format,$)}return K}function CJ(J){let K=G.extname(J).toLowerCase();return u.includes(K)}function QJ(J){return P[J]||"application/octet-stream"}function VJ(J){return J.reduce((K,Z)=>K+Z.size,0)}function XJ(J){if(J<1024)return`${J} B`;if(J<1048576)return`${(J/1024).toFixed(1)} KB`;return`${(J/1048576).toFixed(2)} MB`}class L extends Error{code;constructor(J,K){super(J);this.name="ImageProcessingError",this.code=K}}
3
+ export{d as bg,h as cg,b as dg,e as eg,t as fg,JJ as gg,O as hg,n as ig,KJ as jg,ZJ as kg,$J as lg,qJ as mg,CJ as ng,QJ as og,VJ as pg,XJ as qg,L as rg};