@stacksjs/stx 0.2.736 → 0.2.740

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 (198) hide show
  1. package/dist/{chunk-as108kr9.js → chunk-06jys4zk.js} +4 -4
  2. package/dist/{chunk-2t00wxz0.js → chunk-0ckh7cy1.js} +1 -1
  3. package/dist/{chunk-h1rq3935.js → chunk-0yewaggn.js} +6 -6
  4. package/dist/{chunk-hxy0qwqs.js → chunk-13tac9ac.js} +5 -5
  5. package/dist/chunk-1wak0s76.js +2 -0
  6. package/dist/{chunk-fv4s2yjf.js → chunk-26wrcfr7.js} +1 -1
  7. package/dist/{chunk-ez35607j.js → chunk-27agaezn.js} +2 -2
  8. package/dist/{chunk-nqfpvejh.js → chunk-2hrdh72h.js} +1 -1
  9. package/dist/chunk-2tt2whvk.js +2 -0
  10. package/dist/{chunk-j8r7r1wv.js → chunk-3f25fntg.js} +2 -2
  11. package/dist/chunk-3f4kf3fe.js +2 -0
  12. package/dist/{chunk-dnqzrktd.js → chunk-3kw9m62d.js} +2 -2
  13. package/dist/chunk-4yz476ss.js +2 -0
  14. package/dist/chunk-4z7bnc9j.js +2 -0
  15. package/dist/{chunk-pgz6yy2m.js → chunk-55qv90h9.js} +9 -9
  16. package/dist/{chunk-3fwdxxh1.js → chunk-5f6x6fyp.js} +4 -4
  17. package/dist/chunk-67xtpw2q.js +2 -0
  18. package/dist/chunk-6dz075xn.js +2 -0
  19. package/dist/{chunk-4c86wr9a.js → chunk-6ew10ptg.js} +2 -2
  20. package/dist/chunk-6vajjyj8.js +2 -0
  21. package/dist/chunk-75wdm7kd.js +2 -0
  22. package/dist/{chunk-x0014jes.js → chunk-7emrpfha.js} +6 -6
  23. package/dist/chunk-7vt4k3jv.js +2 -0
  24. package/dist/chunk-840t4gws.js +2 -0
  25. package/dist/{chunk-74fepz6h.js → chunk-888xnaex.js} +2 -2
  26. package/dist/{chunk-my4m7bk0.js → chunk-88kpnrgj.js} +1 -1
  27. package/dist/chunk-8bw9yd5m.js +2 -0
  28. package/dist/chunk-8nq4879f.js +2 -0
  29. package/dist/chunk-8qdrv49k.js +2 -0
  30. package/dist/{chunk-x9wwd2ee.js → chunk-91pycazt.js} +2 -2
  31. package/dist/{chunk-dhy6n39n.js → chunk-9bbs9d9q.js} +2 -2
  32. package/dist/{chunk-qf2aa8qe.js → chunk-9v98dzxt.js} +4 -4
  33. package/dist/{chunk-62awa752.js → chunk-9zrbhs3p.js} +1 -1
  34. package/dist/chunk-a0mze6dz.js +2 -0
  35. package/dist/chunk-af9ptz0x.js +2 -0
  36. package/dist/{chunk-s7q5wrsa.js → chunk-agxvydxe.js} +1 -1
  37. package/dist/chunk-aj6m4pqt.js +2 -0
  38. package/dist/{chunk-4hv1camf.js → chunk-amsbfc3y.js} +30 -30
  39. package/dist/{chunk-rj4j7qcj.js → chunk-amyxgejb.js} +1 -1
  40. package/dist/chunk-ascwd65c.js +2 -0
  41. package/dist/chunk-at0k9j3q.js +3 -0
  42. package/dist/{chunk-narz7105.js → chunk-b107z777.js} +2 -2
  43. package/dist/{chunk-1t0xwfy2.js → chunk-b4ejzx20.js} +18 -18
  44. package/dist/{chunk-agjysd2b.js → chunk-b8ryfxay.js} +1 -1
  45. package/dist/{chunk-xaddgvkx.js → chunk-byaasw3f.js} +2 -2
  46. package/dist/{chunk-630yrhzv.js → chunk-cka9p9v5.js} +2 -2
  47. package/dist/chunk-cmm2mkr1.js +2 -0
  48. package/dist/{chunk-3e40sm05.js → chunk-crk5dzxb.js} +4 -4
  49. package/dist/chunk-d4ahp771.js +2 -0
  50. package/dist/chunk-dw7ajrvf.js +2 -0
  51. package/dist/chunk-e2ar36jw.js +2 -0
  52. package/dist/{chunk-hez09ssh.js → chunk-e43cxztn.js} +2 -2
  53. package/dist/chunk-ejhd435r.js +2 -0
  54. package/dist/{chunk-r3j4m04w.js → chunk-eks1mjr3.js} +2 -2
  55. package/dist/chunk-eyekxtjn.js +2 -0
  56. package/dist/{chunk-6pqsf6tq.js → chunk-f17tdyp3.js} +5 -5
  57. package/dist/{chunk-hnmqnncv.js → chunk-f2yfe5e2.js} +1 -1
  58. package/dist/{chunk-jpfp8f5r.js → chunk-f6bpxqj9.js} +5 -5
  59. package/dist/{chunk-z7ry4w8w.js → chunk-fveqk208.js} +1 -1
  60. package/dist/{chunk-ph2yg39f.js → chunk-gwes6c9v.js} +1 -1
  61. package/dist/{chunk-3dyhn59d.js → chunk-gyvaz4cb.js} +1 -1
  62. package/dist/{chunk-qc93ce5h.js → chunk-h2y36t58.js} +2 -2
  63. package/dist/chunk-h4ab99hb.js +2 -0
  64. package/dist/{chunk-5cr84pp2.js → chunk-h58sctng.js} +4 -4
  65. package/dist/{chunk-79sjdpfy.js → chunk-h6jba844.js} +1 -1
  66. package/dist/chunk-h75rev1h.js +2 -0
  67. package/dist/chunk-h9140mn0.js +2 -0
  68. package/dist/chunk-hjatgram.js +2 -0
  69. package/dist/{chunk-y6964t7z.js → chunk-hq00hf2e.js} +3 -3
  70. package/dist/{chunk-r3hden6p.js → chunk-j3cbj356.js} +2 -2
  71. package/dist/chunk-j4gxcnd5.js +2 -0
  72. package/dist/{chunk-m5nzpjej.js → chunk-jeh671tw.js} +1 -1
  73. package/dist/chunk-jka3p99a.js +2 -0
  74. package/dist/{chunk-g2kfmmfa.js → chunk-jydd8cdc.js} +5 -5
  75. package/dist/chunk-k38vsxt8.js +2 -0
  76. package/dist/{chunk-88rftjjk.js → chunk-k8gxa1jf.js} +4 -4
  77. package/dist/chunk-kgxqj66x.js +2 -0
  78. package/dist/{chunk-2kz9d366.js → chunk-kjh118s3.js} +7 -7
  79. package/dist/{chunk-3xyvc3g1.js → chunk-kp2rkczm.js} +5 -5
  80. package/dist/chunk-m45r8w14.js +2 -0
  81. package/dist/{chunk-x5dc06p5.js → chunk-md36aysy.js} +6 -6
  82. package/dist/{chunk-h16qbyjd.js → chunk-n8mb6510.js} +2 -2
  83. package/dist/{chunk-q7fh1xka.js → chunk-njdppe81.js} +6 -6
  84. package/dist/{chunk-vvrn688m.js → chunk-nt3hva3f.js} +4 -4
  85. package/dist/{chunk-f2c3t1ky.js → chunk-nybty1zx.js} +2 -2
  86. package/dist/{chunk-rbmt5w9v.js → chunk-nzwcbt98.js} +2 -2
  87. package/dist/{chunk-3cwvp8vc.js → chunk-p766mk6b.js} +8 -8
  88. package/dist/{chunk-00y2xpfk.js → chunk-pwt6467e.js} +1 -1
  89. package/dist/chunk-pzm8bc99.js +2 -0
  90. package/dist/{chunk-05qf3e2p.js → chunk-q1db41k8.js} +3 -3
  91. package/dist/chunk-qjm2q9we.js +2 -0
  92. package/dist/{chunk-j28r2d0q.js → chunk-r2cfezt5.js} +2 -2
  93. package/dist/{chunk-018149qp.js → chunk-rner9txv.js} +2 -2
  94. package/dist/chunk-rpe1tskt.js +2 -0
  95. package/dist/{chunk-1dss61y2.js → chunk-rsfs0x3d.js} +1 -1
  96. package/dist/{chunk-arbhrz4x.js → chunk-rthn3eq6.js} +60 -60
  97. package/dist/{chunk-wnt00y7f.js → chunk-sc1wkke5.js} +12 -12
  98. package/dist/{chunk-e25aeftz.js → chunk-sj7hm8dm.js} +2 -2
  99. package/dist/{chunk-755wsp41.js → chunk-smq3x9a2.js} +27 -7
  100. package/dist/{chunk-zkx2m308.js → chunk-sv4d9jgf.js} +10 -10
  101. package/dist/{chunk-r1qcq029.js → chunk-t8ap5qet.js} +6 -6
  102. package/dist/chunk-tbgz73ta.js +2 -0
  103. package/dist/chunk-tpwxvpnt.js +2 -0
  104. package/dist/{chunk-hnqpqtk2.js → chunk-ttsrhr95.js} +6 -6
  105. package/dist/{chunk-dmnncw90.js → chunk-vtmd3ssd.js} +3 -3
  106. package/dist/chunk-vvbszwjs.js +2 -0
  107. package/dist/{chunk-mwxbdpb1.js → chunk-vyv76w55.js} +2 -2
  108. package/dist/chunk-w07kke19.js +2 -0
  109. package/dist/{chunk-serrx31a.js → chunk-w1sdxmx3.js} +2 -2
  110. package/dist/{chunk-39nkd53v.js → chunk-w34w1hrg.js} +2 -2
  111. package/dist/chunk-w6dyqh92.js +2 -0
  112. package/dist/{chunk-2mqzpzy7.js → chunk-w9are744.js} +4 -4
  113. package/dist/chunk-wbcqtpkm.js +2 -0
  114. package/dist/chunk-wy8er1ps.js +2 -0
  115. package/dist/chunk-wzkjzh7w.js +2 -0
  116. package/dist/{chunk-d9hw6n2d.js → chunk-x0c8xq0s.js} +3 -3
  117. package/dist/{chunk-eqxezwg4.js → chunk-x0vws901.js} +1 -1
  118. package/dist/{chunk-zqnttswy.js → chunk-xa8bzf00.js} +3 -3
  119. package/dist/chunk-xrspzeqx.js +2 -0
  120. package/dist/chunk-xt786nk0.js +2 -0
  121. package/dist/{chunk-v402swbm.js → chunk-xzv8t0nd.js} +1 -1
  122. package/dist/{chunk-z8jq4qe7.js → chunk-yvwesavg.js} +9 -9
  123. package/dist/{chunk-e3egwyax.js → chunk-yxtqk5p8.js} +2 -2
  124. package/dist/{chunk-9chqvq23.js → chunk-yygtmm7t.js} +3 -3
  125. package/dist/{chunk-np6gcwgs.js → chunk-yz4jpwp3.js} +19 -19
  126. package/dist/{chunk-h0xyzp7v.js → chunk-z82a0dpd.js} +3 -3
  127. package/dist/chunk-zgnqyta0.js +2 -0
  128. package/dist/chunk-zvfr6022.js +2 -0
  129. package/dist/{chunk-wk50m71x.js → chunk-zzeas8x5.js} +1 -1
  130. package/dist/cli.js +19 -19
  131. package/dist/client/signals-class-runtime.js +1 -0
  132. package/dist/client/signals-component-props-runtime.js +1 -0
  133. package/dist/client/signals-expression-compiler-runtime.js +8 -0
  134. package/dist/client/signals-expression-runtime.js +2 -1
  135. package/dist/client/signals-for-runtime.js +4 -2
  136. package/dist/client/signals-if-chain-runtime.js +1 -0
  137. package/dist/client/signals-if-runtime.js +2 -1
  138. package/dist/client/signals-model-runtime.js +1 -0
  139. package/dist/client/signals-process-element-runtime.js +2 -0
  140. package/dist/client/signals-show-runtime.js +1 -0
  141. package/dist/client/signals-style-runtime.js +1 -0
  142. package/dist/craft-entry.js +2 -2
  143. package/dist/craft.js +2 -2
  144. package/dist/native/runtime/binding-diagnostics.d.ts +3 -0
  145. package/dist/native/runtime/binding-diagnostics.js +20 -0
  146. package/dist/native/runtime/shared-screen.js +2 -0
  147. package/dist/pwa.js +3 -3
  148. package/dist/ssg.js +27 -27
  149. package/package.json +5 -5
  150. package/dist/chunk-0ajbe55p.js +0 -2
  151. package/dist/chunk-0ee76md1.js +0 -2
  152. package/dist/chunk-0g9a1kks.js +0 -2
  153. package/dist/chunk-1pgr2n0h.js +0 -2
  154. package/dist/chunk-2hpt1f4r.js +0 -2
  155. package/dist/chunk-336t7zzz.js +0 -2
  156. package/dist/chunk-362sjw8c.js +0 -2
  157. package/dist/chunk-3j8x8mhx.js +0 -2
  158. package/dist/chunk-3n3vmhtd.js +0 -2
  159. package/dist/chunk-5wpgbwap.js +0 -2
  160. package/dist/chunk-5zrz59dy.js +0 -2
  161. package/dist/chunk-6h1qa3hw.js +0 -2
  162. package/dist/chunk-6jn0p1a9.js +0 -2
  163. package/dist/chunk-6t78kw7s.js +0 -2
  164. package/dist/chunk-8w1ep4w3.js +0 -2
  165. package/dist/chunk-918xy0ra.js +0 -2
  166. package/dist/chunk-9q15h90v.js +0 -2
  167. package/dist/chunk-a0c2qg2b.js +0 -2
  168. package/dist/chunk-a49at1ah.js +0 -2
  169. package/dist/chunk-a64crz43.js +0 -2
  170. package/dist/chunk-ak04tgvw.js +0 -2
  171. package/dist/chunk-azatpcm0.js +0 -2
  172. package/dist/chunk-b2x1wd97.js +0 -2
  173. package/dist/chunk-c1481efw.js +0 -2
  174. package/dist/chunk-c8yrvpr7.js +0 -2
  175. package/dist/chunk-e18z6ntg.js +0 -2
  176. package/dist/chunk-ejhvxggz.js +0 -2
  177. package/dist/chunk-enpchwv1.js +0 -2
  178. package/dist/chunk-jbryd6s7.js +0 -3
  179. package/dist/chunk-jkqe35rg.js +0 -2
  180. package/dist/chunk-jresy8fn.js +0 -2
  181. package/dist/chunk-m6d2bq3y.js +0 -2
  182. package/dist/chunk-mt789hbw.js +0 -2
  183. package/dist/chunk-mvbw706e.js +0 -2
  184. package/dist/chunk-n14zxb4g.js +0 -2
  185. package/dist/chunk-nfg5tjn2.js +0 -2
  186. package/dist/chunk-nvtp22qp.js +0 -2
  187. package/dist/chunk-q6tmvtqq.js +0 -2
  188. package/dist/chunk-rgv7rjrs.js +0 -2
  189. package/dist/chunk-t98sz9rb.js +0 -2
  190. package/dist/chunk-tdvmf3ge.js +0 -2
  191. package/dist/chunk-vresxjg7.js +0 -2
  192. package/dist/chunk-w9qxsp09.js +0 -2
  193. package/dist/chunk-wke3dw59.js +0 -2
  194. package/dist/chunk-wva9vscy.js +0 -2
  195. package/dist/chunk-wy2kct6z.js +0 -2
  196. package/dist/chunk-xbc84n7q.js +0 -2
  197. package/dist/chunk-ysk3rmz2.js +0 -2
  198. package/dist/chunk-zx5wbfxd.js +0 -2
@@ -208,7 +208,7 @@ else {
208
208
  return expression;
209
209
  }
210
210
  // Use passedScope instead of componentScope to preserve context through nested processing
211
- const scope = mergeTemplateScopes(globalHelpers, passedScope, (capturedScope || {}), extraScope);
211
+ var scope = mergeTemplateScopes(globalHelpers, passedScope, (capturedScope || {}), extraScope);
212
212
  const unwrapScope = createAutoUnwrapProxy(scope, function(prop) {
213
213
  if (typeof prop !== 'string') return false;
214
214
  return expressionCallsSignal(expression, prop)
@@ -218,6 +218,7 @@ else {
218
218
  return fn(...__stxArgs(fn, unwrapScope));
219
219
  }
220
220
  catch (e) {
221
+ reportUnknownBinding(e, expression, scope || {}, el);
221
222
  if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] Expression error:', expression, e);
222
223
  return '';
223
224
  }
@@ -229,7 +230,7 @@ catch (e) {
229
230
  const evalLazy = (expression, extraScope = {}) => {
230
231
  try {
231
232
  if (/^__[A-Z_]+__$/.test(expression.trim())) return expression;
232
- const scope = mergeTemplateScopes(globalHelpers, passedScope, (capturedScope || {}), extraScope);
233
+ var scope = mergeTemplateScopes(globalHelpers, passedScope, (capturedScope || {}), extraScope);
233
234
  const unwrapScope = createAutoUnwrapProxy(scope, function(prop) {
234
235
  if (typeof prop !== 'string') return false;
235
236
  return expressionCallsSignal(expression, prop)
@@ -242,6 +243,7 @@ catch (e) {
242
243
  const fn = __stxCompileScoped(unwrapScope, [], 'return ' + expression + '');
243
244
  return fn(...__stxArgs(fn, unwrapScope));
244
245
  } catch (e) {
246
+ reportUnknownBinding(e, expression, scope || {}, el);
245
247
  if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] Expression error:', expression, e);
246
248
  return '';
247
249
  }
@@ -92,6 +92,7 @@ catch (e1) {
92
92
  return fn2(...__stxArgs(fn2, scope));
93
93
  }
94
94
  catch (e2) {
95
+ reportUnknownBinding(e2, expression, scope, b.el);
95
96
  if (!(e2 instanceof ReferenceError) && !(e2 instanceof TypeError)) console.warn('[STX] Expression error:', expression, e2);
96
97
  return '';
97
98
  }
@@ -72,7 +72,7 @@ export const SIGNALS_IF_RUNTIME = ` const detachedBranches = new Set();
72
72
  return expression;
73
73
  }
74
74
  try {
75
- const scope = mergeTemplateScopes(globalHelpers, capturedComponentScope, (capturedElementScope || {}));
75
+ var scope = mergeTemplateScopes(globalHelpers, capturedComponentScope, (capturedElementScope || {}));
76
76
  const unwrapScope = createExpressionAutoUnwrapProxy(scope, expression);
77
77
  const fn = __stxCompileScoped(unwrapScope, [], 'return ' + expression + '');
78
78
  return fn(...__stxArgs(fn, unwrapScope));
@@ -85,6 +85,7 @@ catch (e1) {
85
85
  return fn2(...__stxArgs(fn2, scope2));
86
86
  }
87
87
  catch (e2) {
88
+ reportUnknownBinding(e2, expression, scope || {}, el);
88
89
  if (!(e2 instanceof ReferenceError) && !(e2 instanceof TypeError)) console.warn('[STX] Expression error:', expression, e2);
89
90
  return '';
90
91
  }
@@ -25,6 +25,7 @@ export const SIGNALS_MODEL_RUNTIME = ` function bindModel(el, expr, passedScope
25
25
  return fn(...__stxArgs(fn, unwrapScope));
26
26
  }
27
27
  catch (e) {
28
+ reportUnknownBinding(e, expr, capturedScope, el);
28
29
  if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] ' + attrName + ' get error:', expr, e);
29
30
  return '';
30
31
  }
@@ -119,6 +119,7 @@ catch (e) {
119
119
  bindingNode.textContent = maybeUnwrapSignal(fn(...__stxArgs(fn, capturedScope)));
120
120
  }
121
121
  catch (e2) {
122
+ reportUnknownBinding(e2, expr, capturedScope, parentEl);
122
123
  if (!(e2 instanceof ReferenceError) && !(e2 instanceof TypeError)) console.warn('[STX] Expression error:', expr, e2);
123
124
  bindingNode.textContent = '';
124
125
  }
@@ -259,6 +260,7 @@ catch (e) {
259
260
  return retried;
260
261
  }
261
262
  catch (e2) {
263
+ reportUnknownBinding(e2, expr, activeScope, el);
262
264
  if (!(e2 instanceof ReferenceError) && !(e2 instanceof TypeError)) console.warn('[STX] Attribute expression error:', expr, e2);
263
265
  // ReferenceError/TypeError stay unlogged HERE on purpose: a signal
264
266
  // may not exist yet on an effect's first pass, and warning on every
@@ -32,6 +32,7 @@ export const SIGNALS_SHOW_RUNTIME = ` function bindShow(el, expr, passedScope =
32
32
  var fn2 = __stxCompileScoped(capturedScope, [], 'return ' + expr);
33
33
  value = fn2(...__stxArgs(fn2, capturedScope));
34
34
  } catch (e2) {
35
+ reportUnknownBinding(e2, expr, capturedScope, el);
35
36
  // Suppress ReferenceError/TypeError during async init \u2014 a signal
36
37
  // or object may not be ready yet on the first effect run, and
37
38
  // the next pass will re-evaluate once data arrives.
@@ -20,6 +20,7 @@ catch (e1) {
20
20
  return fn2(...__stxArgs(fn2, capturedScope));
21
21
  }
22
22
  catch (e2) {
23
+ reportUnknownBinding(e2, expr, capturedScope, el);
23
24
  if (!(e2 instanceof ReferenceError) && !(e2 instanceof TypeError)) console.warn('[STX] Style expression error:', expr, e2);
24
25
  return {};
25
26
  }
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{co,fa,ga}from"./chunk-9chqvq23.js";import"./chunk-4hv1camf.js";import"./chunk-zkx2m308.js";import"./chunk-ez35607j.js";import"./chunk-zn3c0ew5.js";import"./chunk-arbhrz4x.js";import"./chunk-rbmt5w9v.js";import"./chunk-e3egwyax.js";import"./chunk-4c86wr9a.js";import"./chunk-2mqzpzy7.js";import"./chunk-z8jq4qe7.js";import"./chunk-q7fh1xka.js";import"./chunk-3fwdxxh1.js";import"./chunk-e25aeftz.js";import"./chunk-x0014jes.js";import"./chunk-1t0xwfy2.js";import"./chunk-vvrn688m.js";import"./chunk-h1rq3935.js";import"./chunk-2kz9d366.js";import"./chunk-y6964t7z.js";import"./chunk-x9wwd2ee.js";import"./chunk-hez09ssh.js";import{Jl,oa,Hm,Vm,ia,ao,Wr,aa,ca,Um,Wm,la,ua,da,pa}from"./chunk-wnt00y7f.js";import"./chunk-as108kr9.js";import"./chunk-jbryd6s7.js";import"./chunk-r3j4m04w.js";import"./chunk-jpfp8f5r.js";import"./chunk-m5nzpjej.js";import"./chunk-h0xyzp7v.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
2
+ import{lo,ga,ma}from"./chunk-yygtmm7t.js";import"./chunk-amsbfc3y.js";import"./chunk-sv4d9jgf.js";import"./chunk-27agaezn.js";import"./chunk-zn3c0ew5.js";import"./chunk-rthn3eq6.js";import"./chunk-nzwcbt98.js";import"./chunk-yxtqk5p8.js";import"./chunk-6ew10ptg.js";import"./chunk-w9are744.js";import"./chunk-yvwesavg.js";import"./chunk-njdppe81.js";import"./chunk-5f6x6fyp.js";import"./chunk-sj7hm8dm.js";import"./chunk-7emrpfha.js";import"./chunk-b4ejzx20.js";import"./chunk-nt3hva3f.js";import"./chunk-0yewaggn.js";import"./chunk-kjh118s3.js";import"./chunk-hq00hf2e.js";import"./chunk-91pycazt.js";import"./chunk-e43cxztn.js";import{Yl,ia,Hm,Vm,aa,co,Wr,ca,la,Um,Wm,ua,da,pa,fa}from"./chunk-sc1wkke5.js";import"./chunk-06jys4zk.js";import"./chunk-at0k9j3q.js";import"./chunk-eks1mjr3.js";import"./chunk-f6bpxqj9.js";import"./chunk-jeh671tw.js";import"./chunk-z82a0dpd.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
3
3
  `),scripts:t.scripts.join(`
4
4
  `),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
5
5
  `),scripts:t.scripts.join(`
6
6
  `),hydrationData:i,metadata:{renderTime:s,cacheHit:!1,totalSize:a.length,componentCount:t.metadata.componentCount}}}function V(t,e){let n=[],r=[],a=[],i=new Map,s=[];return y(t.tree,(o,c)=>{if(o.type==="component"&&o.componentName){if(T(o.componentName))n.push(o.componentName)}if(o.type==="element"&&o.tag){let p=J(o);if(p)s.push(p);if(o.props){for(let[l,f]of Object.entries(o.props))if(l.startsWith("on")&&typeof f==="string"){let g=`handler_${i.size}`;i.set(g,f)}}}if(o.isStatic&&o.type==="element")r.push(b(o));else if(!o.isStatic&&o.type!=="text")a.push(o.tag||o.componentName||"unknown")}),{nativeComponents:n,staticHTML:r,dynamicParts:a,eventHandlers:i,nativeWidgets:s}}function Y(t,e={}){let n=R(t),r=P(n,e),a=new Map,i=[];return y(n.tree,(s)=>{if(s.type==="component"&&s.componentName){if(T(s.componentName)){i.push(s.componentName);let o=`<!--craft:${s.componentName}:${s.hydrationKey||"default"}-->`;a.set(s.hydrationKey||s.componentName,o)}}}),{staticHTML:r,dynamicPlaceholders:a,craftComponents:i}}function M(t){let e={type:"fragment",children:[]},n=e,r=[e],a=t,i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(a.length>0){let s=a.match(/^<(@?[\w-]+)([^>]*)>/);if(s){let[p,l,f]=s,g=z(f),u=l.startsWith("@craft-"),C=u?l:l.toLowerCase(),S={type:u?"component":"element",tag:C,props:g,children:[],componentName:u?C.slice(1):void 0,isStatic:!v(f),hydrationKey:F()};if(n.children=n.children||[],n.children.push(S),!i.has(C)&&!f.endsWith("/"))r.push(S),n=S;a=a.slice(p.length);continue}let o=a.match(/^<\/(@?[\w-]+)>/);if(o){let[p,l]=o,g=l.startsWith("@craft-")?l:l.toLowerCase();while(r.length>1){let u=r.pop();if(n=r[r.length-1],u.tag===g)break}a=a.slice(p.length);continue}let c=a.match(/^[^<]+/);if(c){let p=c[0];if(p.trim()){let l={type:"text",text:p,isStatic:!v(p)};n.children=n.children||[],n.children.push(l)}a=a.slice(p.length);continue}a=a.slice(1)}return e}function z(t){let e={},n=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,r;while((r=n.exec(t))!==null){let[,a,i,s,o]=r,c=i??s??o??!0;e[a]=c}return e}function y(t,e,n=[]){if(e(t,n),t.children)t.children.forEach((r,a)=>{y(r,e,[...n,`${a}`])})}function h(t,e){switch(t.type){case"text":return x(t.text||"",e);case"element":case"component":{let n=t.tag||"div",r=N(t.props||{},e),a=(t.children||[]).map((i)=>h(i,e)).join("");if(!t.children||t.children.length===0){if(["input","br","hr","img","meta","link"].includes(n))return`<${n}${r} />`}return`<${n}${r}>${a}</${n}>`}case"fragment":return(t.children||[]).map((n)=>h(n,e)).join("");case"slot":return`<!--slot:${t.slotName||"default"}-->`;default:return""}}function b(t){if(t.type==="text")return t.text||"";let e=t.tag||"div",n=N(t.props||{},{});return`<${e}${n}></${e}>`}function N(t,e){let n=[];for(let[r,a]of Object.entries(t))if(a===!0)n.push(` ${r}`);else if(a!==!1&&a!==null&&a!==void 0){let i=x(String(a),e);n.push(` ${r}="${k(i)}"`)}return n.join("")}async function H(t,e){return h(t,e)}function P(t,e){let n=[];return y(t.tree,(r)=>{if(r.isStatic)n.push(h(r,e))}),n.join("")}function j(t,e,n){let r={templateId:e.id,context:n,dynamicParts:Array.from(e.dynamicParts.entries())},a=`
7
7
  <script data-craft-hydration>
8
8
  window.__CRAFT_HYDRATION__ = ${JSON.stringify(r)};
9
- </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{Jl as CRAFT_BRIDGE_SCRIPT,ao as CRAFT_COMPONENTS,aa as CRAFT_COMPONENT_RUNTIME,Wr as CRAFT_COMPONENT_STYLES,co as NATIVE_COMPONENTS,la as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,fa as compileToNative,ga as createHotReloadServer,ua as findCraftBinary,oa as generateCraftBridgeScript,V as generateCraftOptimizations,pa as getAvailableFormats,da as getAvailableTargets,Wm as getCraftComponents,G as getSSRCacheStats,ia as injectCraftBridge,Hm as isCraftEnvironment,Y as prerenderForCraft,ca as processCraftComponents,Vm as processCraftDirective,Um as registerCraftComponent,Q as renderSSR};
9
+ </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{Yl as CRAFT_BRIDGE_SCRIPT,co as CRAFT_COMPONENTS,ca as CRAFT_COMPONENT_RUNTIME,Wr as CRAFT_COMPONENT_STYLES,lo as NATIVE_COMPONENTS,ua as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,ga as compileToNative,ma as createHotReloadServer,da as findCraftBinary,ia as generateCraftBridgeScript,V as generateCraftOptimizations,fa as getAvailableFormats,pa as getAvailableTargets,Wm as getCraftComponents,G as getSSRCacheStats,aa as injectCraftBridge,Hm as isCraftEnvironment,Y as prerenderForCraft,la as processCraftComponents,Vm as processCraftDirective,Um as registerCraftComponent,Q as renderSSR};
package/dist/craft.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{co,fa,ga}from"./chunk-9chqvq23.js";import"./chunk-4hv1camf.js";import"./chunk-zkx2m308.js";import"./chunk-ez35607j.js";import"./chunk-zn3c0ew5.js";import"./chunk-arbhrz4x.js";import"./chunk-rbmt5w9v.js";import"./chunk-e3egwyax.js";import"./chunk-4c86wr9a.js";import"./chunk-2mqzpzy7.js";import"./chunk-z8jq4qe7.js";import"./chunk-q7fh1xka.js";import"./chunk-3fwdxxh1.js";import"./chunk-e25aeftz.js";import"./chunk-x0014jes.js";import"./chunk-1t0xwfy2.js";import"./chunk-vvrn688m.js";import"./chunk-h1rq3935.js";import"./chunk-2kz9d366.js";import"./chunk-y6964t7z.js";import"./chunk-x9wwd2ee.js";import"./chunk-hez09ssh.js";import{Jl,oa,Hm,Vm,ia,ao,Wr,aa,ca,Um,Wm,la,ua,da,pa}from"./chunk-wnt00y7f.js";import"./chunk-as108kr9.js";import"./chunk-jbryd6s7.js";import"./chunk-r3j4m04w.js";import"./chunk-jpfp8f5r.js";import"./chunk-m5nzpjej.js";import"./chunk-h0xyzp7v.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
2
+ import{lo,ga,ma}from"./chunk-yygtmm7t.js";import"./chunk-amsbfc3y.js";import"./chunk-sv4d9jgf.js";import"./chunk-27agaezn.js";import"./chunk-zn3c0ew5.js";import"./chunk-rthn3eq6.js";import"./chunk-nzwcbt98.js";import"./chunk-yxtqk5p8.js";import"./chunk-6ew10ptg.js";import"./chunk-w9are744.js";import"./chunk-yvwesavg.js";import"./chunk-njdppe81.js";import"./chunk-5f6x6fyp.js";import"./chunk-sj7hm8dm.js";import"./chunk-7emrpfha.js";import"./chunk-b4ejzx20.js";import"./chunk-nt3hva3f.js";import"./chunk-0yewaggn.js";import"./chunk-kjh118s3.js";import"./chunk-hq00hf2e.js";import"./chunk-91pycazt.js";import"./chunk-e43cxztn.js";import{Yl,ia,Hm,Vm,aa,co,Wr,ca,la,Um,Wm,ua,da,pa,fa}from"./chunk-sc1wkke5.js";import"./chunk-06jys4zk.js";import"./chunk-at0k9j3q.js";import"./chunk-eks1mjr3.js";import"./chunk-f6bpxqj9.js";import"./chunk-jeh671tw.js";import"./chunk-z82a0dpd.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
3
3
  `),scripts:t.scripts.join(`
4
4
  `),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
5
5
  `),scripts:t.scripts.join(`
6
6
  `),hydrationData:i,metadata:{renderTime:s,cacheHit:!1,totalSize:a.length,componentCount:t.metadata.componentCount}}}function V(t,e){let n=[],r=[],a=[],i=new Map,s=[];return y(t.tree,(o,c)=>{if(o.type==="component"&&o.componentName){if(T(o.componentName))n.push(o.componentName)}if(o.type==="element"&&o.tag){let p=J(o);if(p)s.push(p);if(o.props){for(let[l,f]of Object.entries(o.props))if(l.startsWith("on")&&typeof f==="string"){let g=`handler_${i.size}`;i.set(g,f)}}}if(o.isStatic&&o.type==="element")r.push(b(o));else if(!o.isStatic&&o.type!=="text")a.push(o.tag||o.componentName||"unknown")}),{nativeComponents:n,staticHTML:r,dynamicParts:a,eventHandlers:i,nativeWidgets:s}}function Y(t,e={}){let n=R(t),r=P(n,e),a=new Map,i=[];return y(n.tree,(s)=>{if(s.type==="component"&&s.componentName){if(T(s.componentName)){i.push(s.componentName);let o=`<!--craft:${s.componentName}:${s.hydrationKey||"default"}-->`;a.set(s.hydrationKey||s.componentName,o)}}}),{staticHTML:r,dynamicPlaceholders:a,craftComponents:i}}function M(t){let e={type:"fragment",children:[]},n=e,r=[e],a=t,i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(a.length>0){let s=a.match(/^<(@?[\w-]+)([^>]*)>/);if(s){let[p,l,f]=s,g=z(f),u=l.startsWith("@craft-"),C=u?l:l.toLowerCase(),S={type:u?"component":"element",tag:C,props:g,children:[],componentName:u?C.slice(1):void 0,isStatic:!v(f),hydrationKey:F()};if(n.children=n.children||[],n.children.push(S),!i.has(C)&&!f.endsWith("/"))r.push(S),n=S;a=a.slice(p.length);continue}let o=a.match(/^<\/(@?[\w-]+)>/);if(o){let[p,l]=o,g=l.startsWith("@craft-")?l:l.toLowerCase();while(r.length>1){let u=r.pop();if(n=r[r.length-1],u.tag===g)break}a=a.slice(p.length);continue}let c=a.match(/^[^<]+/);if(c){let p=c[0];if(p.trim()){let l={type:"text",text:p,isStatic:!v(p)};n.children=n.children||[],n.children.push(l)}a=a.slice(p.length);continue}a=a.slice(1)}return e}function z(t){let e={},n=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,r;while((r=n.exec(t))!==null){let[,a,i,s,o]=r,c=i??s??o??!0;e[a]=c}return e}function y(t,e,n=[]){if(e(t,n),t.children)t.children.forEach((r,a)=>{y(r,e,[...n,`${a}`])})}function h(t,e){switch(t.type){case"text":return x(t.text||"",e);case"element":case"component":{let n=t.tag||"div",r=N(t.props||{},e),a=(t.children||[]).map((i)=>h(i,e)).join("");if(!t.children||t.children.length===0){if(["input","br","hr","img","meta","link"].includes(n))return`<${n}${r} />`}return`<${n}${r}>${a}</${n}>`}case"fragment":return(t.children||[]).map((n)=>h(n,e)).join("");case"slot":return`<!--slot:${t.slotName||"default"}-->`;default:return""}}function b(t){if(t.type==="text")return t.text||"";let e=t.tag||"div",n=N(t.props||{},{});return`<${e}${n}></${e}>`}function N(t,e){let n=[];for(let[r,a]of Object.entries(t))if(a===!0)n.push(` ${r}`);else if(a!==!1&&a!==null&&a!==void 0){let i=x(String(a),e);n.push(` ${r}="${k(i)}"`)}return n.join("")}async function H(t,e){return h(t,e)}function P(t,e){let n=[];return y(t.tree,(r)=>{if(r.isStatic)n.push(h(r,e))}),n.join("")}function j(t,e,n){let r={templateId:e.id,context:n,dynamicParts:Array.from(e.dynamicParts.entries())},a=`
7
7
  <script data-craft-hydration>
8
8
  window.__CRAFT_HYDRATION__ = ${JSON.stringify(r)};
9
- </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{Jl as CRAFT_BRIDGE_SCRIPT,ao as CRAFT_COMPONENTS,aa as CRAFT_COMPONENT_RUNTIME,Wr as CRAFT_COMPONENT_STYLES,co as NATIVE_COMPONENTS,la as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,fa as compileToNative,ga as createHotReloadServer,ua as findCraftBinary,oa as generateCraftBridgeScript,V as generateCraftOptimizations,pa as getAvailableFormats,da as getAvailableTargets,Wm as getCraftComponents,G as getSSRCacheStats,ia as injectCraftBridge,Hm as isCraftEnvironment,Y as prerenderForCraft,ca as processCraftComponents,Vm as processCraftDirective,Um as registerCraftComponent,Q as renderSSR};
9
+ </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{Yl as CRAFT_BRIDGE_SCRIPT,co as CRAFT_COMPONENTS,ca as CRAFT_COMPONENT_RUNTIME,Wr as CRAFT_COMPONENT_STYLES,lo as NATIVE_COMPONENTS,ua as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,ga as compileToNative,ma as createHotReloadServer,da as findCraftBinary,ia as generateCraftBridgeScript,V as generateCraftOptimizations,fa as getAvailableFormats,pa as getAvailableTargets,Wm as getCraftComponents,G as getSSRCacheStats,aa as injectCraftBridge,Hm as isCraftEnvironment,Y as prerenderForCraft,la as processCraftComponents,Vm as processCraftDirective,Um as registerCraftComponent,Q as renderSSR};
@@ -0,0 +1,3 @@
1
+ /** First-evaluation diagnostics: let JavaScript, not an identifier heuristic, resolve names. */
2
+ export declare function createBindingDiagnostics(source: string): BindingDiagnosticReporter;
3
+ export type BindingDiagnosticReporter = (error: unknown, expression: string, scope: Record<string, unknown>, node?: { __stxId?: string }) => void;
@@ -0,0 +1,20 @@
1
+ export function createBindingDiagnostics(source) {
2
+ const reported = new WeakMap, unowned = new Set;
3
+ return (error, expression, scope, node) => {
4
+ if (!error || typeof error !== "object" || !("name" in error) || error.name !== "ReferenceError")
5
+ return;
6
+ const message = "message" in error ? String(error.message) : "", match = /^(?:Can't find variable: ([\w$]+)|([\w$]+) is not defined)$/.exec(message), name = match?.[1] ?? match?.[2], mentioned = expression.match(/[A-Za-z_$][\w$]*/g) ?? [];
7
+ if (!name || name in scope || !mentioned.includes(name))
8
+ return;
9
+ let seen = node ? reported.get(node) : unowned;
10
+ if (!seen)
11
+ reported.set(node, seen = new Set);
12
+ const key = `${name}\x00${expression}`;
13
+ if (seen.has(key))
14
+ return;
15
+ if (seen.size >= 128)
16
+ return;
17
+ seen.add(key);
18
+ console.warn(`[STX Native] unknown-binding: ${source}: ${node?.__stxId ?? "binding"}: ${name} is not in the setup scope (${JSON.stringify(expression)})`);
19
+ };
20
+ }
@@ -1,6 +1,7 @@
1
1
  import { createNode } from "../compiler/ir.js";
2
2
  import { STXBridge } from "../bridge/protocol.js";
3
3
  import { materializeNativeBindingTree } from "./binding-tree.js";
4
+ import { createBindingDiagnostics } from "./binding-diagnostics.js";
4
5
  import { installCraftBridge } from "./craft-bridge.js";
5
6
  import { createNativeHost } from "./native-host.js";
6
7
  import { createNativeViewOperations, nativeViewError } from "./view-operations.js";
@@ -37,6 +38,7 @@ export function prepareSharedNativeScreen(document, manifest, bridge, options =
37
38
  });
38
39
  }
39
40
  });
41
+ Object.assign(host, { reportBindingError: createBindingDiagnostics(document.meta.source ?? "native screen") });
40
42
  protocol.on("APPEARANCE", (message) => {
41
43
  const scheme = message.payload?.colorScheme;
42
44
  if (scheme === "light" || scheme === "dark") {
package/dist/pwa.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{Vs,Ft,ol,ag}from"./chunk-88rftjjk.js";import{Hs,bi,sg,og,ig}from"./chunk-qf2aa8qe.js";import{nl,rl,sl,ng,rg}from"./chunk-narz7105.js";import{Ve,_n,vi}from"./chunk-j28r2d0q.js";import{cg,lg,ug,dg,Us,Lh}from"./chunk-dhy6n39n.js";import B from"fs";import w from"path";import O from"fs";import u from"path";var v=[72,96,128,144,152,192,384,512],S=[120,152,167,180],P=[16,32];async function M(n,t){let e={success:!0,generatedFiles:[],errors:[],warnings:[]},r=n.pwa?.icons;if(!r?.src)return e.errors.push("No source icon specified in pwa.icons.src"),e.success=!1,e;let o=u.isAbsolute(r.src)?r.src:u.resolve(process.cwd(),r.src);if(!await Bun.file(o).exists())return e.errors.push(`Source icon not found: ${o}`),e.success=!1,e;let a=u.resolve(t,r.outputDir||"pwa-icons");try{O.mkdirSync(a,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${a}`),e.success=!1,e}let s=r.sizes||v,l=r.generateWebP??!0,p=r.generateAppleIcons??!0;try{let c;try{c=await import("sharp")}catch{return e.errors.push(`sharp is not installed. Install it with: bun add sharp
3
- Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-n14zxb4g.js"),o=await Bun.file(e).text();return await r(o,{},e,n,new Set)}catch(r){console.warn(`[PWA] Failed to process custom offline page: ${r}`)}else console.warn(`[PWA] Custom offline page not found: ${e}`)}return E(n)}function E(n){let t=n.pwa?.offline,e=n.pwa?.manifest,r=t?.fallbackTitle||"You are offline",o=t?.fallbackMessage||"Please check your internet connection and try again.",a=e?.themeColor||"#4f46e5",s=e?.shortName||e?.name||"App";return`<!DOCTYPE html>
2
+ import{Us,Ft,il,ag}from"./chunk-k8gxa1jf.js";import{Vs,vi,sg,og,ig}from"./chunk-9v98dzxt.js";import{rl,sl,ol,ng,rg}from"./chunk-b107z777.js";import{Ve,_n,wi}from"./chunk-r2cfezt5.js";import{cg,lg,ug,dg,Ws,Lh}from"./chunk-9bbs9d9q.js";import B from"fs";import w from"path";import O from"fs";import u from"path";var v=[72,96,128,144,152,192,384,512],S=[120,152,167,180],P=[16,32];async function M(n,t){let e={success:!0,generatedFiles:[],errors:[],warnings:[]},r=n.pwa?.icons;if(!r?.src)return e.errors.push("No source icon specified in pwa.icons.src"),e.success=!1,e;let o=u.isAbsolute(r.src)?r.src:u.resolve(process.cwd(),r.src);if(!await Bun.file(o).exists())return e.errors.push(`Source icon not found: ${o}`),e.success=!1,e;let a=u.resolve(t,r.outputDir||"pwa-icons");try{O.mkdirSync(a,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${a}`),e.success=!1,e}let s=r.sizes||v,l=r.generateWebP??!0,p=r.generateAppleIcons??!0;try{let c;try{c=await import("sharp")}catch{return e.errors.push(`sharp is not installed. Install it with: bun add sharp
3
+ Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-h9140mn0.js"),o=await Bun.file(e).text();return await r(o,{},e,n,new Set)}catch(r){console.warn(`[PWA] Failed to process custom offline page: ${r}`)}else console.warn(`[PWA] Custom offline page not found: ${e}`)}return E(n)}function E(n){let t=n.pwa?.offline,e=n.pwa?.manifest,r=t?.fallbackTitle||"You are offline",o=t?.fallbackMessage||"Please check your internet connection and try again.",a=e?.themeColor||"#4f46e5",s=e?.shortName||e?.name||"App";return`<!DOCTYPE html>
4
4
  <html lang="en">
5
5
  <head>
6
6
  <meta charset="UTF-8">
@@ -233,4 +233,4 @@ Icon generation requires the sharp package for image processing.`),e.success=!1,
233
233
  }, 5000);
234
234
  </script>
235
235
  </body>
236
- </html>`}function b(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=Ve(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=Vs(n,t);if(a){let s=Ft(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function ae(n,t){return bi(n,t)}function se(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,rl as auditBuildOutput,nl as auditConfig,re as buildPwaAssets,sl as calculateAuditResult,rg as formatAuditResult,vi as formatSize,j as generateManifest,_ as generateManifestJson,og as generateManifestLink,F as generateOfflinePage,Ve as generatePrecacheManifest,_n as generatePrecacheManifestJs,M as generatePwaIcons,Hs as generatePwaTags,Vs as generateServiceWorker,ag as generateServiceWorkerAuto,sg as generateSwRegistrationScript,ig as generateThemeColorMeta,N as getExpectedIconPaths,Ft as getServiceWorkerFileName,bi as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,ol as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,Us as pwaDirectives,cg as pwaInstallDirective,ug as pwaOfflineDirective,dg as pwaPushDirective,lg as pwaUpdateDirective,Lh as registerPwaDirectives,ng as runPwaAudit,D as validateManifest};
236
+ </html>`}function b(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=Ve(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=Us(n,t);if(a){let s=Ft(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function ae(n,t){return vi(n,t)}function se(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,sl as auditBuildOutput,rl as auditConfig,re as buildPwaAssets,ol as calculateAuditResult,rg as formatAuditResult,wi as formatSize,j as generateManifest,_ as generateManifestJson,og as generateManifestLink,F as generateOfflinePage,Ve as generatePrecacheManifest,_n as generatePrecacheManifestJs,M as generatePwaIcons,Vs as generatePwaTags,Us as generateServiceWorker,ag as generateServiceWorkerAuto,sg as generateSwRegistrationScript,ig as generateThemeColorMeta,N as getExpectedIconPaths,Ft as getServiceWorkerFileName,vi as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,il as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,Ws as pwaDirectives,cg as pwaInstallDirective,ug as pwaOfflineDirective,dg as pwaPushDirective,lg as pwaUpdateDirective,Lh as registerPwaDirectives,ng as runPwaAudit,D as validateManifest};
package/dist/ssg.js CHANGED
@@ -1,29 +1,29 @@
1
1
  // @bun
2
- import"./chunk-1xjv71dw.js";import{b,Fc}from"./chunk-zkx2m308.js";import"./chunk-ez35607j.js";import"./chunk-zn3c0ew5.js";import{Tt,S}from"./chunk-arbhrz4x.js";import"./chunk-rbmt5w9v.js";import"./chunk-e3egwyax.js";import"./chunk-4c86wr9a.js";import{xt,St,kt,_t,Ct,Et}from"./chunk-2mqzpzy7.js";import{a}from"./chunk-z8jq4qe7.js";import{ms}from"./chunk-q7fh1xka.js";import"./chunk-3fwdxxh1.js";import"./chunk-hxy0qwqs.js";import{Te,Yt,Zt}from"./chunk-5cr84pp2.js";import"./chunk-e25aeftz.js";import{y}from"./chunk-x0014jes.js";import{mt,i}from"./chunk-1t0xwfy2.js";import"./chunk-vvrn688m.js";import"./chunk-h1rq3935.js";import"./chunk-2kz9d366.js";import"./chunk-y6964t7z.js";import"./chunk-x9wwd2ee.js";import{Ma,La,ja}from"./chunk-dmnncw90.js";import{Xt,Gn,Xn}from"./chunk-9adx6f4k.js";import{Jt}from"./chunk-my4m7bk0.js";import"./chunk-jbryd6s7.js";import"./chunk-r3j4m04w.js";import{G,be}from"./chunk-jpfp8f5r.js";import"./chunk-m5nzpjej.js";import"./chunk-h0xyzp7v.js";import{l}from"./chunk-qc93ce5h.js";import{s,ge}from"./chunk-05qf3e2p.js";import D from"fs";import h from"path";import{createHash as Pt}from"crypto";function $t(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var Dt=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Rt(t){return Bun.hash(t).toString(16)}function ot(t,r={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let o=new Map,n=t.replace(Dt,(e,u,f,v)=>{let w=v.trim();if(!w)return e;if(/\bdata-stx-src=/.test(f))return e;if(r.minify)w=$t(w);let g=Rt(w);if(!o.has(g))o.set(g,w);let P=r.integrity?` data-stx-integrity="sha384-${Pt("sha384").update(w).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${u}" data-stx-src="/_stx/islands/${g}.js"${P}${f}></script>`}),c=Array.from(o,([e,u])=>({hash:e,code:u}));return{html:n,chunks:c}}var It=new Set(["visible","idle"]);function ct(t){if(!t.includes("data-stx-src="))return t;let r=new Map,o=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,n;while((n=o.exec(t))!==null)r.set(n[1],n[2]);let c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,u;while((u=e.exec(t))!==null)if(It.has(r.get(u[1])||""))c.add(u[2]);let f=/<\/head\s*>/iy,v=S(t,(g,P)=>(f.lastIndex=P,f.exec(g)?f.lastIndex:-1))[0]?.start??-1;if(c.size===0||v===-1)return t;let w=Array.from(c).filter((g)=>!t.includes(`rel="prefetch" href="${g}"`)).map((g)=>`<link rel="prefetch" href="${g}" as="script">`).join("");if(!w)return t;return t.slice(0,v)+w+t.slice(v)}var Bt=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function X(t){let r=t.trim();if(!r)return null;let o=/^https?:\/\//i.test(r)?r:`https://${r}`;try{return new URL(o).origin+new URL(o).pathname.replace(/\/$/,"")}catch{return null}}function jt(t){for(let r of Bt){let o=t[r];if(!o)continue;let n=X(o);if(n)return{url:n,source:"env",via:r}}return null}function lt(t){if(!t||typeof t!=="object")return null;let r=t,o=r.site?.url??r.url??r.app?.url;return typeof o==="string"?X(o):null}async function Ft(t){let{existsSync:r}=await import("fs"),o=await import("path");for(let n of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=o.resolve(t,n);if(!r(c))continue;try{let e=await import(c),u=lt(e.default??e);if(u)return u}catch{}}return null}async function ut(t={}){let r=t.cwd??process.cwd(),o=t.env??process.env;if(t.explicit){let u=X(t.explicit);if(u)return{url:u,source:"option"}}let n=lt(t.stxConfig);if(n)return{url:n,source:"stx.config",via:"site.url"};let c=await Ft(r);if(c)return{url:c,source:"site.config",via:"url"};let e=jt(o);if(e)return e;return{url:"http://localhost",source:"fallback"}}function dt(){return["No site URL configured \u2014 sitemap.xml and robots.txt will point at http://localhost."," Set one in stx.config.ts (site: { url: 'https://example.com' }), in site.config.ts,"," via --domain, or with SITE_URL in the build environment."].join(`
3
- `)}function J(t){return async()=>({paths:await t(),fallback:!1})}var At;function Ot(t){let r=s(t),{depths:o}=ge(r),n=/\b(?:async\s+)?function\s+getStaticPaths\s*\(/g,c;while((c=n.exec(r))!==null){if(o[c.index]!==0)continue;let u=b(r,"(",")",n.lastIndex-1),f=r.indexOf("{",u+1),v=b(r,"{","}",f);if(u<0||f<0||v<0)break;return t.slice(c.index,v+1)}let e=/\b(?:const|let|var)\s+getStaticPaths\s*=/g;while((c=e.exec(r))!==null){if(o[c.index]!==0)continue;let u=Fc(r,e.lastIndex).endPos;return t.slice(e.lastIndex,u).trim()}throw SyntaxError("Could not extract getStaticPaths; use a top-level function or const declaration")}async function gt(t){let r="read";try{let o=await Bun.file(t).text();r="parse";let n=Jt(o),c=[...n.server,...n.client,...n.signals].filter((e)=>/(?:^|\s)server(?:\s|=|$)/i.test(s(e.attrs))).sort((e,u)=>o.indexOf(e.fullTag)-o.indexOf(u.fullTag));for(let e of c){if(!/\bgetStaticPaths\b/.test(s(e.content)))continue;let u=(At??=new Bun.Transpiler({loader:"ts",target:"bun"})).transformSync(e.content);if(!/\bgetStaticPaths\b/.test(s(u)))continue;let f=Ot(u);if(/\bdefineStaticPaths\b/.test(s(f))&&Tt(u,"defineStaticPaths"))throw SyntaxError("Cannot evaluate a module-local defineStaticPaths binding during isolated hook extraction");r="execute";let v=Function("defineStaticPaths",`return (${f})`)(J);if(typeof v!=="function")throw TypeError("getStaticPaths must be a function");let w=await v();r="result";let g=Array.isArray(w)?{paths:w}:w;if(!g||typeof g!=="object"||!("paths"in g)||!Array.isArray(g.paths))throw TypeError("getStaticPaths must return { paths: [...] } or an array of paths");for(let P of g.paths)if(!P||typeof P!=="object"||!P.params||typeof P.params!=="object"||Array.isArray(P.params))throw TypeError("Each getStaticPaths path must contain a params object");return{kind:"ok",value:g}}return{kind:"absent"}}catch(o){return{kind:"error",phase:r,error:o instanceof Error?o:Error(String(o))}}}class pt{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,r=""){this.cacheDir=t,this.salt=r}async load(){if(this.loaded)return;let t=h.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let r=JSON.parse(await Bun.file(t).text());for(let[o,n]of Object.entries(r))this.cache.set(o,n)}catch{}this.loaded=!0}async save(){await D.promises.mkdir(this.cacheDir,{recursive:!0});let t=h.join(this.cacheDir,"build-cache.json"),r={};for(let[o,n]of this.cache)r[o]=n;await Bun.write(t,JSON.stringify(r))}getHash(t,r){let o=D.statSync(t),n=`${this.salt}|${t}:${o.mtimeMs}`;for(let e of r)if(D.existsSync(e)){let u=D.statSync(e);n+=`:${e}:${u.mtimeMs}`}let c=0;for(let e=0;e<n.length;e++){let u=n.charCodeAt(e);c=(c<<5)-c+u,c=c&c}return Math.abs(c).toString(36)}get(t,r){let o=this.cache.get(t);if(!o)return null;let n=this.getHash(r,o.dependencies??[]);if(o.hash!==n)return this.cache.delete(t),null;return o.html}set(t,r,o,n){let c=this.getHash(r,o);this.cache.set(t,{hash:c,html:n,generatedAt:Date.now(),dependencies:o})}}class ht{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let r=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return h.join(this.cacheDir,"isr",r)}async get(t){let r=this.getFilePath(t);if(!await Bun.file(r).exists())return null;try{return JSON.parse(await Bun.file(r).text())}catch{return null}}async set(t,r){let o=this.getFilePath(t);await D.promises.mkdir(h.dirname(o),{recursive:!0}),await Bun.write(o,JSON.stringify(r))}async invalidate(t){let r=this.getFilePath(t);if(await Bun.file(r).exists())await D.promises.unlink(r)}async invalidatePattern(t){let r=h.join(this.cacheDir,"isr");if(!D.existsSync(r))return;let o=await D.promises.readdir(r);for(let n of o){let c=n.replace(/_/g,"/").replace(".json","");if(t.test(c))await D.promises.unlink(h.join(r,n))}}async needsRevalidation(t){let r=await this.get(t);if(!r)return!0;return Date.now()>r.revalidateAfter}}async function Lt(t){let r=[];if(!t.isDynamic)r.push({url:t.pattern,params:{}});else{let o=await gt(t.filePath);if(o.kind==="error")throw Error(`getStaticPaths ${o.phase} failed for ${t.pattern} (${t.filePath}): ${o.error.message}`,{cause:o.error});if(o.kind==="absent")return console.warn(`Warning: Dynamic route ${t.pattern} (${t.filePath}) has no getStaticPaths`),r;let n=o.value;if(n.paths.length===0)return console.info(`getStaticPaths returned no paths for dynamic route ${t.pattern} (${t.filePath})`),r;for(let c of n.paths){let e=t.pattern;for(let[u,f]of Object.entries(c.params))e=e.replace(`:${u}`,f).replace(`:${u}*`,f);r.push({url:e,params:c.params,props:c.props,revalidate:c.revalidate})}}return r}async function Ut(t){let r=[t.replace(/\.stx$/,".data.ts"),t.replace(/\.stx$/,".data.js"),t+".data.ts",t+".data.js"];for(let o of r)if(await Bun.file(o).exists())try{let n=await import(o);if(typeof n.default==="function")return await n.default();else if(typeof n.default==="object")return n.default;else if(typeof n.getData==="function")return await n.getData();else{let{default:c,...e}=n;return e}}catch(n){console.error(`Error loading data file ${o}:`,n)}return null}async function Mt(t,r,o){let n=t.match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!n)return null;let c=n[1];if(!c.includes("getStaticProps"))return null;try{let e=c.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticProps\s*\([^)]*\)\s*\{([\s\S]*?)\n\}/);if(!e)return null;return await Function("params",`
2
+ import"./chunk-1xjv71dw.js";import{b,zc}from"./chunk-sv4d9jgf.js";import"./chunk-27agaezn.js";import"./chunk-zn3c0ew5.js";import{Tt,S}from"./chunk-rthn3eq6.js";import"./chunk-nzwcbt98.js";import"./chunk-yxtqk5p8.js";import"./chunk-6ew10ptg.js";import{xt,St,kt,_t,Ct,Et}from"./chunk-w9are744.js";import{a}from"./chunk-yvwesavg.js";import{hs}from"./chunk-njdppe81.js";import"./chunk-5f6x6fyp.js";import"./chunk-13tac9ac.js";import{Te,Yt,Zt}from"./chunk-h58sctng.js";import"./chunk-sj7hm8dm.js";import{y}from"./chunk-7emrpfha.js";import{mt,i}from"./chunk-b4ejzx20.js";import"./chunk-nt3hva3f.js";import"./chunk-0yewaggn.js";import{rs}from"./chunk-kjh118s3.js";import"./chunk-hq00hf2e.js";import"./chunk-91pycazt.js";import{La,ja,Ba}from"./chunk-vtmd3ssd.js";import{Xt,Gn,Xn}from"./chunk-9adx6f4k.js";import{Jt}from"./chunk-88kpnrgj.js";import"./chunk-at0k9j3q.js";import"./chunk-eks1mjr3.js";import{G,be}from"./chunk-f6bpxqj9.js";import"./chunk-jeh671tw.js";import"./chunk-z82a0dpd.js";import{l}from"./chunk-h2y36t58.js";import{s,ge}from"./chunk-q1db41k8.js";import D from"fs";import f from"path";import{createHash as $t}from"crypto";function Dt(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var Rt=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function It(t){return Bun.hash(t).toString(16)}function ot(t,r={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let n=new Map,o=t.replace(Rt,(e,u,g,v)=>{let w=v.trim();if(!w)return e;if(/\bdata-stx-src=/.test(g))return e;if(r.minify)w=Dt(w);let p=It(w);if(!n.has(p))n.set(p,w);let P=r.integrity?` data-stx-integrity="sha384-${$t("sha384").update(w).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${u}" data-stx-src="/_stx/islands/${p}.js"${P}${g}></script>`}),c=Array.from(n,([e,u])=>({hash:e,code:u}));return{html:o,chunks:c}}var Bt=new Set(["visible","idle"]);function ct(t){if(!t.includes("data-stx-src="))return t;let r=new Map,n=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,o;while((o=n.exec(t))!==null)r.set(o[1],o[2]);let c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,u;while((u=e.exec(t))!==null)if(Bt.has(r.get(u[1])||""))c.add(u[2]);let g=/<\/head\s*>/iy,v=S(t,(p,P)=>(g.lastIndex=P,g.exec(p)?g.lastIndex:-1))[0]?.start??-1;if(c.size===0||v===-1)return t;let w=Array.from(c).filter((p)=>!t.includes(`rel="prefetch" href="${p}"`)).map((p)=>`<link rel="prefetch" href="${p}" as="script">`).join("");if(!w)return t;return t.slice(0,v)+w+t.slice(v)}var jt=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function X(t){let r=t.trim();if(!r)return null;let n=/^https?:\/\//i.test(r)?r:`https://${r}`;try{return new URL(n).origin+new URL(n).pathname.replace(/\/$/,"")}catch{return null}}function Ft(t){for(let r of jt){let n=t[r];if(!n)continue;let o=X(n);if(o)return{url:o,source:"env",via:r}}return null}function lt(t){if(!t||typeof t!=="object")return null;let r=t,n=r.site?.url??r.url??r.app?.url;return typeof n==="string"?X(n):null}async function At(t){let{existsSync:r}=await import("fs"),n=await import("path");for(let o of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=n.resolve(t,o);if(!r(c))continue;try{let e=await import(c),u=lt(e.default??e);if(u)return u}catch{}}return null}async function ut(t={}){let r=t.cwd??process.cwd(),n=t.env??process.env;if(t.explicit){let u=X(t.explicit);if(u)return{url:u,source:"option"}}let o=lt(t.stxConfig);if(o)return{url:o,source:"stx.config",via:"site.url"};let c=await At(r);if(c)return{url:c,source:"site.config",via:"url"};let e=Ft(n);if(e)return e;return{url:"http://localhost",source:"fallback"}}function dt(){return["No site URL configured \u2014 sitemap.xml and robots.txt will point at http://localhost."," Set one in stx.config.ts (site: { url: 'https://example.com' }), in site.config.ts,"," via --domain, or with SITE_URL in the build environment."].join(`
3
+ `)}function J(t){return async()=>({paths:await t(),fallback:!1})}var Ot;function Lt(t){let r=s(t),{depths:n}=ge(r),o=/\b(?:async\s+)?function\s+getStaticPaths\s*\(/g,c;while((c=o.exec(r))!==null){if(n[c.index]!==0)continue;let u=b(r,"(",")",o.lastIndex-1),g=r.indexOf("{",u+1),v=b(r,"{","}",g);if(u<0||g<0||v<0)break;return t.slice(c.index,v+1)}let e=/\b(?:const|let|var)\s+getStaticPaths\s*=/g;while((c=e.exec(r))!==null){if(n[c.index]!==0)continue;let u=zc(r,e.lastIndex).endPos;return t.slice(e.lastIndex,u).trim()}throw SyntaxError("Could not extract getStaticPaths; use a top-level function or const declaration")}async function gt(t){let r="read";try{let n=await Bun.file(t).text();r="parse";let o=Jt(n),c=[...o.server,...o.client,...o.signals].filter((e)=>/(?:^|\s)server(?:\s|=|$)/i.test(s(e.attrs))).sort((e,u)=>n.indexOf(e.fullTag)-n.indexOf(u.fullTag));for(let e of c){if(!/\bgetStaticPaths\b/.test(s(e.content)))continue;let u=(Ot??=new Bun.Transpiler({loader:"ts",target:"bun"})).transformSync(e.content);if(!/\bgetStaticPaths\b/.test(s(u)))continue;let g=Lt(u);if(/\bdefineStaticPaths\b/.test(s(g))&&Tt(u,"defineStaticPaths"))throw SyntaxError("Cannot evaluate a module-local defineStaticPaths binding during isolated hook extraction");r="execute";let v=Function("defineStaticPaths",`return (${g})`)(J);if(typeof v!=="function")throw TypeError("getStaticPaths must be a function");let w=await v();r="result";let p=Array.isArray(w)?{paths:w}:w;if(!p||typeof p!=="object"||!("paths"in p)||!Array.isArray(p.paths))throw TypeError("getStaticPaths must return { paths: [...] } or an array of paths");for(let P of p.paths)if(!P||typeof P!=="object"||!P.params||typeof P.params!=="object"||Array.isArray(P.params))throw TypeError("Each getStaticPaths path must contain a params object");return{kind:"ok",value:p}}return{kind:"absent"}}catch(n){return{kind:"error",phase:r,error:n instanceof Error?n:Error(String(n))}}}class pt{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,r=""){this.cacheDir=t,this.salt=r}async load(){if(this.loaded)return;let t=f.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let r=JSON.parse(await Bun.file(t).text());for(let[n,o]of Object.entries(r))this.cache.set(n,o)}catch{}this.loaded=!0}async save(){await D.promises.mkdir(this.cacheDir,{recursive:!0});let t=f.join(this.cacheDir,"build-cache.json"),r={};for(let[n,o]of this.cache)r[n]=o;await Bun.write(t,JSON.stringify(r))}getHash(t,r){let n=D.statSync(t),o=`${this.salt}|${t}:${n.mtimeMs}`;for(let e of r)if(D.existsSync(e)){let u=D.statSync(e);o+=`:${e}:${u.mtimeMs}`}let c=0;for(let e=0;e<o.length;e++){let u=o.charCodeAt(e);c=(c<<5)-c+u,c=c&c}return Math.abs(c).toString(36)}get(t,r){let n=this.cache.get(t);if(!n)return null;let o=ft(r).some((u)=>D.existsSync(u)),c=[r,...n.dependencies??[]].some((u)=>u.endsWith(".stx")&&D.existsSync(u)&&rs(D.readFileSync(u,"utf8")).some((g)=>/\bserver\b/.test(g.attrs)));if(o||c)return this.cache.delete(t),null;let e=this.getHash(r,n.dependencies??[]);if(n.hash!==e)return this.cache.delete(t),null;return n.html}set(t,r,n,o){let c=this.getHash(r,n);this.cache.set(t,{hash:c,html:o,generatedAt:Date.now(),dependencies:n})}}class ht{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let r=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return f.join(this.cacheDir,"isr",r)}async get(t){let r=this.getFilePath(t);if(!await Bun.file(r).exists())return null;try{return JSON.parse(await Bun.file(r).text())}catch{return null}}async set(t,r){let n=this.getFilePath(t);await D.promises.mkdir(f.dirname(n),{recursive:!0}),await Bun.write(n,JSON.stringify(r))}async invalidate(t){let r=this.getFilePath(t);if(await Bun.file(r).exists())await D.promises.unlink(r)}async invalidatePattern(t){let r=f.join(this.cacheDir,"isr");if(!D.existsSync(r))return;let n=await D.promises.readdir(r);for(let o of n){let c=o.replace(/_/g,"/").replace(".json","");if(t.test(c))await D.promises.unlink(f.join(r,o))}}async needsRevalidation(t){let r=await this.get(t);if(!r)return!0;return Date.now()>r.revalidateAfter}}async function Ut(t){let r=[];if(!t.isDynamic)r.push({url:t.pattern,params:{}});else{let n=await gt(t.filePath);if(n.kind==="error")throw Error(`getStaticPaths ${n.phase} failed for ${t.pattern} (${t.filePath}): ${n.error.message}`,{cause:n.error});if(n.kind==="absent")return console.warn(`Warning: Dynamic route ${t.pattern} (${t.filePath}) has no getStaticPaths`),r;let o=n.value;if(o.paths.length===0)return console.info(`getStaticPaths returned no paths for dynamic route ${t.pattern} (${t.filePath})`),r;for(let c of o.paths){let e=t.pattern;for(let[u,g]of Object.entries(c.params))e=e.replace(`:${u}`,g).replace(`:${u}*`,g);r.push({url:e,params:c.params,props:c.props,revalidate:c.revalidate})}}return r}function ft(t){return[t.replace(/\.stx$/,".data.ts"),t.replace(/\.stx$/,".data.js"),t+".data.ts",t+".data.js"]}async function Mt(t){for(let r of ft(t))if(await Bun.file(r).exists())try{let n=await import(r);if(typeof n.default==="function")return await n.default();else if(typeof n.default==="object")return n.default;else if(typeof n.getData==="function")return await n.getData();else{let{default:o,...c}=n;return c}}catch(n){console.error(`Error loading data file ${r}:`,n)}return null}async function Gt(t,r,n){let o=t.match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return null;let c=o[1];if(!c.includes("getStaticProps"))return null;try{let e=c.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticProps\s*\([^)]*\)\s*\{([\s\S]*?)\n\}/);if(!e)return null;return await Function("params",`
4
4
  return (async function getStaticProps() {
5
5
  ${e[1]}
6
6
  })()
7
- `)(r)}catch(e){return console.error(`Error executing getStaticProps in ${o}:`,e),null}}function Gt(t){return/(?:^|[^\w$.])(?:export\s+)?(?:async\s+)?function\s+action\s*\(/.test(t)||/(?:^|[^\w$.])(?:export\s+)?(?:const|let|var)\s+action\s*=/.test(t)}async function ft(t,r,o={},n,c){let e=await Bun.file(t.filePath).text(),u=await Ut(t.filePath),f=await Mt(e,r,t.filePath),v={...u||{},...f||{},...o,params:r,$route:{path:t.pattern,params:r}},w=new Set,g=[],P=[],E={...c,minifyClient:!0,...n.partialsDir?{partialsDir:n.partialsDir}:{},...n.componentsDir?{componentsDir:n.componentsDir}:{},debug:!1,cache:!1,autoShell:!0,onIncludeError:(R)=>{g.push(`${h.relative(process.cwd(),R.templatePath)}: ${R.message}
8
- resolved against partialsDir: ${R.partialsDir}`)},onServerScriptError:(R)=>{P.push(`${h.relative(process.cwd(),R.sourcePath)} (${R.kind}): ${R.message}`)}};if(Gt(e))console.warn(`Warning: ${t.pattern} exports a page action, which cannot run in a static build. Its form will submit to a file. Serve this route with the production server, or point the form's action at a route handler.`);let x=await i(e,v,t.filePath,E,w);for(let R of[t.filePath,...w])for(let T of Te(R))w.add(T);if(Object.keys(r).length>0){let R=`<script>if(window.stx)window.stx._rp=${JSON.stringify(r)};else window.__stx_rp=${JSON.stringify(r)};</script>`;if(x.includes("</head>"))x=x.replace("</head>",`${R}
7
+ `)(r)}catch(e){return console.error(`Error executing getStaticProps in ${n}:`,e),null}}function Nt(t){return/(?:^|[^\w$.])(?:export\s+)?(?:async\s+)?function\s+action\s*\(/.test(t)||/(?:^|[^\w$.])(?:export\s+)?(?:const|let|var)\s+action\s*=/.test(t)}async function wt(t,r,n={},o,c){let e=await Bun.file(t.filePath).text(),u=await Mt(t.filePath),g=await Gt(e,r,t.filePath),v={...u||{},...g||{},...n,params:r,$route:{path:t.pattern,params:r}},w=new Set,p=[],P=[],E={...c,minifyClient:!0,...o.partialsDir?{partialsDir:o.partialsDir}:{},...o.componentsDir?{componentsDir:o.componentsDir}:{},debug:!1,cache:!1,autoShell:!0,onIncludeError:(R)=>{p.push(`${f.relative(process.cwd(),R.templatePath)}: ${R.message}
8
+ resolved against partialsDir: ${R.partialsDir}`)},onServerScriptError:(R)=>{P.push(`${f.relative(process.cwd(),R.sourcePath)} (${R.kind}): ${R.message}`)}};if(Nt(e))console.warn(`Warning: ${t.pattern} exports a page action, which cannot run in a static build. Its form will submit to a file. Serve this route with the production server, or point the form's action at a route handler.`);let x=await i(e,v,t.filePath,E,w);for(let R of[t.filePath,...w])for(let T of Te(R))w.add(T);if(Object.keys(r).length>0){let R=`<script>if(window.stx)window.stx._rp=${JSON.stringify(r)};else window.__stx_rp=${JSON.stringify(r)};</script>`;if(x.includes("</head>"))x=x.replace("</head>",`${R}
9
9
  </head>`);else x=`${R}
10
- ${x}`}if(x=await be(x,{router:n.router}),x=await y(x),n.minify!==!1)return{html:Nt(x),dependencies:Array.from(w),includeFailures:g,serverScriptFailures:P};return{html:x,dependencies:Array.from(w),includeFailures:g,serverScriptFailures:P}}function Nt(t){let r=[],o=0,n=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi,c;while((c=n.exec(t))!==null){let u=t.slice(o,c.index);r.push(u.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><"));let f=c[1],v=c[2],w=c[3];v=v.replace(/([^:"\\'`])\/\/(?!\/)(?![*!])([^\n]*)/g,"$1"),r.push(f+v+w),o=c.index+c[0].length}let e=t.slice(o);return r.push(e.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><")),r.join("").trim()}function Ht(t){let r=0;for(let o=0;o<t.length;o++){let n=t.charCodeAt(o);r=(r<<5)-r+n,r=r&r}return`"${Math.abs(r).toString(36)}"`}function zt(t,r,o,n){if(o?.sitemap===!1)return!0;if(/<meta[^>]+name=["']robots["'][^>]+content=["'][^"']*noindex/i.test(r))return!0;return n.some((c)=>{if(c instanceof RegExp)return c.test(t);return c.endsWith("/")?t===c.slice(0,-1)||t.startsWith(c):t===c})}function Wt(t,r){return`<?xml version="1.0" encoding="UTF-8"?>
10
+ ${x}`}if(x=await be(x,{router:o.router}),x=await y(x),o.minify!==!1)return{html:Ht(x),dependencies:Array.from(w),includeFailures:p,serverScriptFailures:P};return{html:x,dependencies:Array.from(w),includeFailures:p,serverScriptFailures:P}}function Ht(t){let r=[],n=0,o=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi,c;while((c=o.exec(t))!==null){let u=t.slice(n,c.index);r.push(u.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><"));let g=c[1],v=c[2],w=c[3];v=v.replace(/([^:"\\'`])\/\/(?!\/)(?![*!])([^\n]*)/g,"$1"),r.push(g+v+w),n=c.index+c[0].length}let e=t.slice(n);return r.push(e.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><")),r.join("").trim()}function zt(t){let r=0;for(let n=0;n<t.length;n++){let o=t.charCodeAt(n);r=(r<<5)-r+o,r=r&r}return`"${Math.abs(r).toString(36)}"`}function Wt(t,r,n,o){if(n?.sitemap===!1)return!0;if(/<meta[^>]+name=["']robots["'][^>]+content=["'][^"']*noindex/i.test(r))return!0;return o.some((c)=>{if(c instanceof RegExp)return c.test(t);return c.endsWith("/")?t===c.slice(0,-1)||t.startsWith(c):t===c})}function qt(t,r){return`<?xml version="1.0" encoding="UTF-8"?>
11
11
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
12
- ${t.map((n)=>{let c=new URL(n.loc,r).href,e=` <url>
13
- <loc>${F(c)}</loc>`;if(n.lastmod)e+=`
14
- <lastmod>${n.lastmod}</lastmod>`;if(n.changefreq)e+=`
15
- <changefreq>${n.changefreq}</changefreq>`;if(n.priority!==void 0)e+=`
16
- <priority>${n.priority}</priority>`;return e+=`
12
+ ${t.map((o)=>{let c=new URL(o.loc,r).href,e=` <url>
13
+ <loc>${F(c)}</loc>`;if(o.lastmod)e+=`
14
+ <lastmod>${o.lastmod}</lastmod>`;if(o.changefreq)e+=`
15
+ <changefreq>${o.changefreq}</changefreq>`;if(o.priority!==void 0)e+=`
16
+ <priority>${o.priority}</priority>`;return e+=`
17
17
  </url>`,e}).join(`
18
18
  `)}
19
- </urlset>`}function F(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function qt(t,r){let o=r.map((n)=>{let c=" <item>";if(c+=`
20
- <title>${F(n.title)}</title>`,c+=`
21
- <link>${F(n.link)}</link>`,n.description)c+=`
22
- <description>${F(n.description)}</description>`;if(n.pubDate)c+=`
23
- <pubDate>${n.pubDate.toUTCString()}</pubDate>`;if(n.author)c+=`
24
- <author>${F(n.author)}</author>`;if(n.categories)for(let e of n.categories)c+=`
25
- <category>${F(e)}</category>`;if(n.guid)c+=`
26
- <guid>${F(n.guid)}</guid>`;return c+=`
19
+ </urlset>`}function F(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function Vt(t,r){let n=r.map((o)=>{let c=" <item>";if(c+=`
20
+ <title>${F(o.title)}</title>`,c+=`
21
+ <link>${F(o.link)}</link>`,o.description)c+=`
22
+ <description>${F(o.description)}</description>`;if(o.pubDate)c+=`
23
+ <pubDate>${o.pubDate.toUTCString()}</pubDate>`;if(o.author)c+=`
24
+ <author>${F(o.author)}</author>`;if(o.categories)for(let e of o.categories)c+=`
25
+ <category>${F(e)}</category>`;if(o.guid)c+=`
26
+ <guid>${F(o.guid)}</guid>`;return c+=`
27
27
  </item>`,c});return`<?xml version="1.0" encoding="UTF-8"?>
28
28
  <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
29
29
  <channel>
@@ -34,21 +34,21 @@ ${t.map((n)=>{let c=new URL(n.loc,r).href,e=` <url>
34
34
  ${t.copyright?`<copyright>${F(t.copyright)}</copyright>`:""}
35
35
  <lastBuildDate>${new Date().toUTCString()}</lastBuildDate>
36
36
  <atom:link href="${t.link}/rss.xml" rel="self" type="application/rss+xml"/>
37
- ${o.join(`
37
+ ${n.join(`
38
38
  `)}
39
39
  </channel>
40
- </rss>`}async function Vt(t={}){let r=Date.now();Zt();let o=await a(process.cwd()),n=o.build||{},c=await ut({explicit:t.domain||n.domain,stxConfig:o});if(c.source==="fallback"&&(t.sitemap??n.sitemap??!0))console.warn(dt());let e={router:t.router??o?.router??{},pagesDir:t.pagesDir||n.pagesDir||"pages",outputDir:t.outputDir||n.outputDir||"dist",baseUrl:t.baseUrl||n.baseUrl||"/",domain:c.url,revalidate:t.revalidate??n.revalidate??!1,sitemap:t.sitemap??n.sitemap??!0,sitemapExclude:t.sitemapExclude||n.sitemapExclude||[],robots:t.robots??n.robots??!0,rss:t.rss??n.rss??!1,concurrency:t.concurrency||n.concurrency||10,cache:t.cache??n.cache??!0,cacheDir:t.cacheDir||n.cacheDir||l(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??n.minify??!0,generate404:t.generate404??n.generate404??!0,publicDir:t.publicDir||n.publicDir||"public",trailingSlash:t.trailingSlash??n.trailingSlash??!1,cleanOutput:t.cleanOutput??n.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||o?.partialsDir||"",componentsDir:t.componentsDir||o?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},u={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},f=new Set,v=0,w={},g={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&D.existsSync(e.outputDir))await D.promises.rm(e.outputDir,{recursive:!0});await D.promises.mkdir(e.outputDir,{recursive:!0});let E=e.cacheSalt;if(!E){let{resolveUserCssConfig:d,fingerprintConfig:m}=await import("./chunk-ejhvxggz.js");try{E=m(await d(process.cwd()))}catch{}}let{prepareImageDelivery:x}=await import("./chunk-enpchwv1.js"),R=await x(e.publicDir,e.outputDir);if(R.count>0)console.log(`Optimized ${R.count} image(s) for responsive delivery`),E=[E,R.fingerprint].filter(Boolean).join(":");let T=new pt(e.cacheDir,E);if(e.cache)await T.load();try{let{generateCss:d}=await import("./chunk-ejhvxggz.js");await d('<div class="bg-black"></div>')}catch{}xt();let wt=o?.routeMiddleware?.dir||"middleware";await kt(process.cwd(),wt);let V=St();if(V.length>0)console.log(`Loaded ${V.length} middleware: ${V.join(", ")}`);let yt=o?.routeMiddleware?.global||[];ja(o?.layoutsDir,l(process.cwd()));let Z=G(".",{pagesDir:e.pagesDir,pagesDirs:o?._layerPageDirs});console.log(`Found ${Z.length} routes`);let M=[];for(let d of Z)try{let m=await Lt(d);for(let k of m)M.push({route:d,url:k.url,params:k.params,props:k.props,revalidate:k.revalidate??e.revalidate})}catch(m){let k=m instanceof Error?m:Error(String(m));u.failedCount++,u.errors.push({route:d.pattern,error:k}),await e.hooks.onError?.(k,d.pattern),console.error(`Error discovering paths for ${d.pattern}:`,k)}u.totalPages=M.length+u.failedCount,console.log(`Generating ${M.length} pages...`);let _=[],Q=[];for(let d=0;d<M.length;d+=e.concurrency)Q.push(M.slice(d,d+e.concurrency));for(let d of Q)await Promise.all(d.map(async(m)=>{let{route:k,url:p,params:N,props:bt,revalidate:rt}=m;try{await e.hooks.onPageStart?.(p);let A=await Bun.file(k.filePath).text(),O=te(A),vt=O?.middleware?Array.isArray(O.middleware)?O.middleware:[O.middleware]:[],nt=[...yt,...vt];if(nt.length>0){let B=_t(p,N,O||{}),L=Ct(B,null,void 0,{isServer:!0}),j=await Et(nt,L);if(j.redirect){let C=typeof j.redirect==="string"?j.redirect:j.redirect.path||j.redirect,z=ee(String(C),p),U=re(p,e);await D.promises.mkdir(h.dirname(U),{recursive:!0}),await Bun.write(U,z),u.successCount++,u.pages.push({route:p,outputPath:U,size:Buffer.byteLength(z),cached:!1}),_.push({loc:p,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${p} \u2192 redirect to ${C}`);return}if(j.abort){let C=typeof j.abort==="string"?j.abort:j.abort?.error?.message||"aborted";console.warn(` \u21B3 ${p} \u2014 middleware aborted: ${C}`);return}}let it=A.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(it)try{if(!await Function("route",`
40
+ </rss>`}async function Kt(t={}){let r=Date.now();Zt();let n=await a(process.cwd()),o=n.build||{},c=await ut({explicit:t.domain||o.domain,stxConfig:n});if(c.source==="fallback"&&(t.sitemap??o.sitemap??!0))console.warn(dt());let e={router:t.router??n?.router??{},pagesDir:t.pagesDir||o.pagesDir||"pages",outputDir:t.outputDir||o.outputDir||"dist",baseUrl:t.baseUrl||o.baseUrl||"/",domain:c.url,revalidate:t.revalidate??o.revalidate??!1,sitemap:t.sitemap??o.sitemap??!0,sitemapExclude:t.sitemapExclude||o.sitemapExclude||[],robots:t.robots??o.robots??!0,rss:t.rss??o.rss??!1,concurrency:t.concurrency||o.concurrency||10,cache:t.cache??o.cache??!0,cacheDir:t.cacheDir||o.cacheDir||l(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??o.minify??!0,generate404:t.generate404??o.generate404??!0,publicDir:t.publicDir||o.publicDir||"public",trailingSlash:t.trailingSlash??o.trailingSlash??!1,cleanOutput:t.cleanOutput??o.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||n?.partialsDir||"",componentsDir:t.componentsDir||n?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},u={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},g=new Set,v=0,w={},p={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&D.existsSync(e.outputDir))await D.promises.rm(e.outputDir,{recursive:!0});await D.promises.mkdir(e.outputDir,{recursive:!0});let E=e.cacheSalt;if(!E){let{resolveUserCssConfig:d,fingerprintConfig:m}=await import("./chunk-3f4kf3fe.js");try{E=m(await d(process.cwd()))}catch{}}let{prepareImageDelivery:x}=await import("./chunk-af9ptz0x.js"),R=await x(e.publicDir,e.outputDir);if(R.count>0)console.log(`Optimized ${R.count} image(s) for responsive delivery`),E=[E,R.fingerprint].filter(Boolean).join(":");let T=new pt(e.cacheDir,E);if(e.cache)await T.load();try{let{generateCss:d}=await import("./chunk-3f4kf3fe.js");await d('<div class="bg-black"></div>')}catch{}xt();let yt=n?.routeMiddleware?.dir||"middleware";await kt(process.cwd(),yt);let V=St();if(V.length>0)console.log(`Loaded ${V.length} middleware: ${V.join(", ")}`);let bt=n?.routeMiddleware?.global||[];Ba(n?.layoutsDir,l(process.cwd()));let Z=G(".",{pagesDir:e.pagesDir,pagesDirs:n?._layerPageDirs});console.log(`Found ${Z.length} routes`);let M=[];for(let d of Z)try{let m=await Ut(d);for(let k of m)M.push({route:d,url:k.url,params:k.params,props:k.props,revalidate:k.revalidate??e.revalidate})}catch(m){let k=m instanceof Error?m:Error(String(m));u.failedCount++,u.errors.push({route:d.pattern,error:k}),await e.hooks.onError?.(k,d.pattern),console.error(`Error discovering paths for ${d.pattern}:`,k)}u.totalPages=M.length+u.failedCount,console.log(`Generating ${M.length} pages...`);let _=[],Q=[];for(let d=0;d<M.length;d+=e.concurrency)Q.push(M.slice(d,d+e.concurrency));for(let d of Q)await Promise.all(d.map(async(m)=>{let{route:k,url:h,params:N,props:vt,revalidate:rt}=m;try{await e.hooks.onPageStart?.(h);let A=await Bun.file(k.filePath).text(),O=ee(A),Pt=O?.middleware?Array.isArray(O.middleware)?O.middleware:[O.middleware]:[],nt=[...bt,...Pt];if(nt.length>0){let B=_t(h,N,O||{}),L=Ct(B,null,void 0,{isServer:!0}),j=await Et(nt,L);if(j.redirect){let C=typeof j.redirect==="string"?j.redirect:j.redirect.path||j.redirect,z=re(String(C),h),U=ne(h,e);await D.promises.mkdir(f.dirname(U),{recursive:!0}),await Bun.write(U,z),u.successCount++,u.pages.push({route:h,outputPath:U,size:Buffer.byteLength(z),cached:!1}),_.push({loc:h,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${h} \u2192 redirect to ${C}`);return}if(j.abort){let C=typeof j.abort==="string"?j.abort:j.abort?.error?.message||"aborted";console.warn(` \u21B3 ${h} \u2014 middleware aborted: ${C}`);return}}let it=A.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(it)try{if(!await Function("route",`
41
41
  const validate = ${it[1]};
42
42
  return validate(route);
43
- `)({params:N})){console.warn(`Validation failed for ${p}, skipping...`);return}}catch{}let I=null,st=!1;if(e.cache){if(I=T.get(p,k.filePath),I)st=!0,u.cachedCount++}if(!I){let B=await ft(k,N,bt,e,o);if(I=B.html,e.failOnIncludeError&&B.includeFailures.length>0)throw Error(`${B.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
43
+ `)({params:N})){console.warn(`Validation failed for ${h}, skipping...`);return}}catch{}let I=null,st=!1;if(e.cache){if(I=T.get(h,k.filePath),I)st=!0,u.cachedCount++}if(!I){let B=await wt(k,N,vt,e,n);if(I=B.html,e.failOnIncludeError&&B.includeFailures.length>0)throw Error(`${B.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
44
44
  ${B.includeFailures.join(`
45
45
  `)}
46
46
  Set ssg.failOnIncludeError to false to build anyway.`);if(e.failOnServerScriptError&&B.serverScriptFailures.length>0)throw Error(`${B.serverScriptFailures.length} <script server> block(s) failed, so this page would have shipped with the content they produce missing:
47
47
  ${B.serverScriptFailures.join(`
48
48
  `)}
49
- Set ssg.failOnServerScriptError to false to build anyway.`);if(e.cache)T.set(p,k.filePath,B.dependencies,I)}let H;if(e.trailingSlash)H=h.join(e.outputDir,p,"index.html");else H=p==="/"?h.join(e.outputDir,"index.html"):h.join(e.outputDir,`${p}.html`);if(e.chunkIslands){let{html:B,chunks:L}=ot(I,{integrity:e.integrityIslands,minify:e.minify});if(L.length>0){let j=h.join(e.outputDir,"_stx","islands");await D.promises.mkdir(j,{recursive:!0});for(let C of L){let z=h.join(j,`${C.hash}.js`);if(!await Bun.file(z).exists())await Bun.write(z,C.code);if(!f.has(C.hash)){f.add(C.hash);let U=Buffer.byteLength(C.code,"utf8");v+=U,w[C.hash]={bytes:U,file:`/_stx/islands/${C.hash}.js`}}}if(g[p]=L.map((C)=>C.hash),I=B,e.prefetchIslands)I=ct(I)}}if(await D.promises.mkdir(h.dirname(H),{recursive:!0}),await Bun.write(H,I),!zt(p,I,O,e.sitemapExclude))_.push({loc:p,lastmod:new Date().toISOString().split("T")[0],priority:p==="/"?1:0.8});let at={route:p,outputPath:H,size:Buffer.byteLength(I,"utf8"),cached:st};if(rt!==!1)at.revalidateAt=Date.now()+rt*1000;u.pages.push(at),u.successCount++,await e.hooks.onPageEnd?.(p,I)}catch(A){u.failedCount++,u.errors.push({route:p,error:A}),await e.hooks.onError?.(A,p),console.error(`Error generating ${p}:`,A)}}));let tt=Yt();if(tt.length>0){let d=tt.map((m)=>`${m.filePath}: ${m.message}`).join(`
49
+ Set ssg.failOnServerScriptError to false to build anyway.`);if(e.cache)T.set(h,k.filePath,B.dependencies,I)}let H;if(e.trailingSlash)H=f.join(e.outputDir,h,"index.html");else H=h==="/"?f.join(e.outputDir,"index.html"):f.join(e.outputDir,`${h}.html`);if(e.chunkIslands){let{html:B,chunks:L}=ot(I,{integrity:e.integrityIslands,minify:e.minify});if(L.length>0){let j=f.join(e.outputDir,"_stx","islands");await D.promises.mkdir(j,{recursive:!0});for(let C of L){let z=f.join(j,`${C.hash}.js`);if(!await Bun.file(z).exists())await Bun.write(z,C.code);if(!g.has(C.hash)){g.add(C.hash);let U=Buffer.byteLength(C.code,"utf8");v+=U,w[C.hash]={bytes:U,file:`/_stx/islands/${C.hash}.js`}}}if(p[h]=L.map((C)=>C.hash),I=B,e.prefetchIslands)I=ct(I)}}if(await D.promises.mkdir(f.dirname(H),{recursive:!0}),await Bun.write(H,I),!Wt(h,I,O,e.sitemapExclude))_.push({loc:h,lastmod:new Date().toISOString().split("T")[0],priority:h==="/"?1:0.8});let at={route:h,outputPath:H,size:Buffer.byteLength(I,"utf8"),cached:st};if(rt!==!1)at.revalidateAt=Date.now()+rt*1000;u.pages.push(at),u.successCount++,await e.hooks.onPageEnd?.(h,I)}catch(A){u.failedCount++,u.errors.push({route:h,error:A}),await e.hooks.onError?.(A,h),console.error(`Error generating ${h}:`,A)}}));let tt=Yt();if(tt.length>0){let d=tt.map((m)=>`${m.filePath}: ${m.message}`).join(`
50
50
  `);throw Error(`Client script bundling failed:
51
- ${d}`)}if(e.cache)await T.save();if(e.generate404){let d=h.join(e.pagesDir,"404.stx");if(await Bun.file(d).exists()){let m=new Set,k={...o,minifyClient:!0,debug:!1,cache:!1},p=await i(await Bun.file(d).text(),{},d,k,m);await Bun.write(h.join(e.outputDir,"404.html"),p)}else await Bun.write(h.join(e.outputDir,"404.html"),`<!DOCTYPE html>
51
+ ${d}`)}if(e.cache)await T.save();if(e.generate404){let d=f.join(e.pagesDir,"404.stx");if(await Bun.file(d).exists()){let m=new Set,k={...n,minifyClient:!0,debug:!1,cache:!1},h=await i(await Bun.file(d).text(),{},d,k,m);await Bun.write(f.join(e.outputDir,"404.html"),h)}else await Bun.write(f.join(e.outputDir,"404.html"),`<!DOCTYPE html>
52
52
  <html lang="en">
53
53
  <head>
54
54
  <meta charset="UTF-8">
@@ -69,7 +69,7 @@ ${d}`)}if(e.cache)await T.save();if(e.generate404){let d=h.join(e.pagesDir,"404.
69
69
  <a href="/">Go home</a>
70
70
  </div>
71
71
  </body>
72
- </html>`)}for(let d of[500]){let m=h.join(e.pagesDir,`${d}.stx`);if(await Bun.file(m).exists()){let k=new Set,p={...o,minifyClient:!0,debug:!1,cache:!1},N=await i(await Bun.file(m).text(),{},m,p,k);await Bun.write(h.join(e.outputDir,`${d}.html`),N)}}let K=h.join(e.pagesDir,"error.stx");if(await Bun.file(K).exists()){let d=new Set,m={...o,minifyClient:!0,debug:!1,cache:!1},k=await i(await Bun.file(K).text(),{},K,m,d);await Bun.write(h.join(e.outputDir,"error.html"),k)}if(e.sitemap&&_.length>0){let d=Wt(_,e.domain),m=h.join(e.outputDir,"sitemap.xml");await Bun.write(m,d),u.sitemapPath=m,console.log(`Generated sitemap.xml with ${_.length} URLs`)}if(e.robots!==!1){let d=typeof e.robots==="object"?e.robots:{},m=[...e.sitemapExclude.filter((p)=>typeof p==="string"),...d.disallow||[]],k=ms({rules:[{userAgent:d.userAgent||"*",allow:d.allow||["/"],...m.length>0?{disallow:m}:{}}],...d.sitemap!==!1&&u.sitemapPath?{sitemap:new URL("/sitemap.xml",e.domain).href}:{}});await Bun.write(h.join(e.outputDir,"robots.txt"),k),console.log("Generated robots.txt")}if(e.rss){let d=typeof e.rss==="object"?e.rss:{title:"Site Feed",description:"Latest updates",link:e.domain},m=[];if(d.getItems)m=await d.getItems();let k=qt(d,m),p=h.join(e.outputDir,"rss.xml");await Bun.write(p,k),u.rssPath=p,console.log(`Generated rss.xml with ${m.length} items`)}let W=Ma(e.outputDir);if(W.assets>0)console.log(`Externalized ${W.assets} asset(s) from ${W.pages} page(s) (${(W.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let q=La(e.outputDir);if(q.assets>0)console.log(`Externalized ${q.assets} repeated asset(s) from ${q.pages} page(s) (${(q.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(e.publicDir&&D.existsSync(e.publicDir))await Y(e.publicDir,e.outputDir),console.log(`Copied public assets from ${e.publicDir}`);let et=Xn();if(et)await Y(et,h.join(e.outputDir,Gn)),console.log(`Copied assets from ${Xt}`)}catch(E){throw await e.hooks.onError?.(E),E}if(u.buildTime=Date.now()-r,f.size>0){u.islandChunks={count:f.size,totalBytes:v};let E={generatedChunks:f.size,totalBytes:v,chunks:w,pages:g};await Bun.write(h.join(e.outputDir,"_stx","islands-manifest.json"),JSON.stringify(E,null,2))}await e.hooks.onBuildEnd?.(u);let P=u.islandChunks?`
72
+ </html>`)}for(let d of[500]){let m=f.join(e.pagesDir,`${d}.stx`);if(await Bun.file(m).exists()){let k=new Set,h={...n,minifyClient:!0,debug:!1,cache:!1},N=await i(await Bun.file(m).text(),{},m,h,k);await Bun.write(f.join(e.outputDir,`${d}.html`),N)}}let K=f.join(e.pagesDir,"error.stx");if(await Bun.file(K).exists()){let d=new Set,m={...n,minifyClient:!0,debug:!1,cache:!1},k=await i(await Bun.file(K).text(),{},K,m,d);await Bun.write(f.join(e.outputDir,"error.html"),k)}if(e.sitemap&&_.length>0){let d=qt(_,e.domain),m=f.join(e.outputDir,"sitemap.xml");await Bun.write(m,d),u.sitemapPath=m,console.log(`Generated sitemap.xml with ${_.length} URLs`)}if(e.robots!==!1){let d=typeof e.robots==="object"?e.robots:{},m=[...e.sitemapExclude.filter((h)=>typeof h==="string"),...d.disallow||[]],k=hs({rules:[{userAgent:d.userAgent||"*",allow:d.allow||["/"],...m.length>0?{disallow:m}:{}}],...d.sitemap!==!1&&u.sitemapPath?{sitemap:new URL("/sitemap.xml",e.domain).href}:{}});await Bun.write(f.join(e.outputDir,"robots.txt"),k),console.log("Generated robots.txt")}if(e.rss){let d=typeof e.rss==="object"?e.rss:{title:"Site Feed",description:"Latest updates",link:e.domain},m=[];if(d.getItems)m=await d.getItems();let k=Vt(d,m),h=f.join(e.outputDir,"rss.xml");await Bun.write(h,k),u.rssPath=h,console.log(`Generated rss.xml with ${m.length} items`)}let W=La(e.outputDir);if(W.assets>0)console.log(`Externalized ${W.assets} asset(s) from ${W.pages} page(s) (${(W.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let q=ja(e.outputDir);if(q.assets>0)console.log(`Externalized ${q.assets} repeated asset(s) from ${q.pages} page(s) (${(q.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(e.publicDir&&D.existsSync(e.publicDir))await Y(e.publicDir,e.outputDir),console.log(`Copied public assets from ${e.publicDir}`);let et=Xn();if(et)await Y(et,f.join(e.outputDir,Gn)),console.log(`Copied assets from ${Xt}`)}catch(E){throw await e.hooks.onError?.(E),E}if(u.buildTime=Date.now()-r,g.size>0){u.islandChunks={count:g.size,totalBytes:v};let E={generatedChunks:g.size,totalBytes:v,chunks:w,pages:p};await Bun.write(f.join(e.outputDir,"_stx","islands-manifest.json"),JSON.stringify(E,null,2))}await e.hooks.onBuildEnd?.(u);let P=u.islandChunks?`
73
73
  Island chunks: ${u.islandChunks.count} (${(u.islandChunks.totalBytes/1024).toFixed(1)} KB lifted out of inline HTML)`:"";return console.log(`
74
74
  Build complete!
75
75
  Total: ${u.totalPages} pages
@@ -77,8 +77,8 @@ Build complete!
77
77
  Cached: ${u.cachedCount}
78
78
  Failed: ${u.failedCount}
79
79
  Time: ${u.buildTime}ms${P}
80
- `),u}async function Y(t,r){await D.promises.mkdir(r,{recursive:!0});let o=await D.promises.readdir(t,{withFileTypes:!0});for(let n of o){let c=h.join(t,n.name),e=h.join(r,n.name);if(n.isDirectory())await D.promises.mkdir(e,{recursive:!0}),await Y(c,e);else await D.promises.copyFile(c,e)}}function Kt(t={}){let r=t.cacheDir||l(process.cwd(),"ssg-cache"),o=new ht(r),n=t.revalidate||3600;return{async get(c){let e=await o.get(c);if(!e)return null;if(Date.now()>e.revalidateAfter)this.revalidate(c).catch(console.error);return{html:e.html,headers:{"Cache-Control":`public, max-age=${n}, stale-while-revalidate=${n*2}`,ETag:e.etag,"X-ISR-Generated":new Date(e.generatedAt).toISOString(),...e.headers}}},async revalidate(c){let u=G(".",{pagesDir:t.pagesDir||"pages"}).find((P)=>c.match(P.regex)!==null);if(!u){console.warn(`Route not found for revalidation: ${c}`);return}let f=c.match(u.regex),v={};if(f)u.params.forEach((P,E)=>{v[P]=f[E+1]});let w=await a(),{html:g}=await ft(u,v,{},t,w);await o.set(c,{html:g,generatedAt:Date.now(),revalidateAfter:Date.now()+n*1000,etag:Ht(g)}),console.log(`Revalidated: ${c}`)},async invalidate(c){if(typeof c==="string")await o.invalidate(c);else await o.invalidatePattern(c)}}}function Qt(){return{name:"markdown",extensions:[".md",".mdx"],async load(t){let r=await Bun.file(t).text(),o=r.match(/^---\n([\s\S]*?)\n---/),n={},c=r;if(o){let w=o[1];c=r.slice(o[0].length).trim();for(let g of w.split(`
81
- `)){let P=g.indexOf(":");if(P>0){let E=g.slice(0,P).trim(),x=g.slice(P+1).trim();if(x==="true")x=!0;else if(x==="false")x=!1;else if(/^\d+$/.test(x))x=parseInt(x,10);else if(/^\d+\.\d+$/.test(x))x=parseFloat(x);else if(x.startsWith("[")&&x.endsWith("]"))x=x.slice(1,-1).split(",").map((R)=>R.trim().replace(/^['"]|['"]$/g,""));n[E]=x}}}let e=c.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/`([^`]+)`/gim,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/gim,'<a href="$2">$1</a>').replace(/\n/gim,"<br>"),u=[],f=/<h([1-6])>([^<]+)<\/h[1-6]>/gi,v;while((v=f.exec(e))!==null){let w=parseInt(v[1],10),g=v[2],P=g.toLowerCase().replace(/[^a-z0-9]+/g,"-");u.push({id:P,text:g,level:w})}return{content:e,data:n,toc:u}}}}function te(t){return mt(t)}function ee(t,r){return`<!DOCTYPE html>
80
+ `),u}async function Y(t,r){await D.promises.mkdir(r,{recursive:!0});let n=await D.promises.readdir(t,{withFileTypes:!0});for(let o of n){let c=f.join(t,o.name),e=f.join(r,o.name);if(o.isDirectory())await D.promises.mkdir(e,{recursive:!0}),await Y(c,e);else await D.promises.copyFile(c,e)}}function Qt(t={}){let r=t.cacheDir||l(process.cwd(),"ssg-cache"),n=new ht(r),o=t.revalidate||3600;return{async get(c){let e=await n.get(c);if(!e)return null;if(Date.now()>e.revalidateAfter)this.revalidate(c).catch(console.error);return{html:e.html,headers:{"Cache-Control":`public, max-age=${o}, stale-while-revalidate=${o*2}`,ETag:e.etag,"X-ISR-Generated":new Date(e.generatedAt).toISOString(),...e.headers}}},async revalidate(c){let u=G(".",{pagesDir:t.pagesDir||"pages"}).find((P)=>c.match(P.regex)!==null);if(!u){console.warn(`Route not found for revalidation: ${c}`);return}let g=c.match(u.regex),v={};if(g)u.params.forEach((P,E)=>{v[P]=g[E+1]});let w=await a(),{html:p}=await wt(u,v,{},t,w);await n.set(c,{html:p,generatedAt:Date.now(),revalidateAfter:Date.now()+o*1000,etag:zt(p)}),console.log(`Revalidated: ${c}`)},async invalidate(c){if(typeof c==="string")await n.invalidate(c);else await n.invalidatePattern(c)}}}function te(){return{name:"markdown",extensions:[".md",".mdx"],async load(t){let r=await Bun.file(t).text(),n=r.match(/^---\n([\s\S]*?)\n---/),o={},c=r;if(n){let w=n[1];c=r.slice(n[0].length).trim();for(let p of w.split(`
81
+ `)){let P=p.indexOf(":");if(P>0){let E=p.slice(0,P).trim(),x=p.slice(P+1).trim();if(x==="true")x=!0;else if(x==="false")x=!1;else if(/^\d+$/.test(x))x=parseInt(x,10);else if(/^\d+\.\d+$/.test(x))x=parseFloat(x);else if(x.startsWith("[")&&x.endsWith("]"))x=x.slice(1,-1).split(",").map((R)=>R.trim().replace(/^['"]|['"]$/g,""));o[E]=x}}}let e=c.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/`([^`]+)`/gim,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/gim,'<a href="$2">$1</a>').replace(/\n/gim,"<br>"),u=[],g=/<h([1-6])>([^<]+)<\/h[1-6]>/gi,v;while((v=g.exec(e))!==null){let w=parseInt(v[1],10),p=v[2],P=p.toLowerCase().replace(/[^a-z0-9]+/g,"-");u.push({id:P,text:p,level:w})}return{content:e,data:o,toc:u}}}}function ee(t){return mt(t)}function re(t,r){return`<!DOCTYPE html>
82
82
  <html>
83
83
  <head>
84
84
  <meta charset="utf-8">
@@ -90,4 +90,4 @@ Build complete!
90
90
  <p>Redirecting to <a href="${t}">${t}</a>...</p>
91
91
  <script>window.location.replace('${t}')</script>
92
92
  </body>
93
- </html>`}function re(t,r){if(t==="/"||t==="")return h.join(r.outputDir,"index.html");let o=t.replace(/^\/|\/$/g,"");if(r.trailingSlash)return h.join(r.outputDir,o,"index.html");return h.join(r.outputDir,`${o}.html`)}var Fe={generateStaticSite:Vt,createISRHandler:Kt,defineStaticPaths:J,createMarkdownLoader:Qt};export{Kt as createISRHandler,Qt as createMarkdownLoader,Gt as declaresPageAction,Fe as default,J as defineStaticPaths,Vt as generateStaticSite,zt as isExcludedFromSitemap};
93
+ </html>`}function ne(t,r){if(t==="/"||t==="")return f.join(r.outputDir,"index.html");let n=t.replace(/^\/|\/$/g,"");if(r.trailingSlash)return f.join(r.outputDir,n,"index.html");return f.join(r.outputDir,`${n}.html`)}var Oe={generateStaticSite:Kt,createISRHandler:Qt,defineStaticPaths:J,createMarkdownLoader:te};export{Qt as createISRHandler,te as createMarkdownLoader,Nt as declaresPageAction,Oe as default,J as defineStaticPaths,Kt as generateStaticSite,Wt as isExcludedFromSitemap};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.2.736",
4
+ "version": "0.2.740",
5
5
  "description": "A performant UI Framework. Powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -128,12 +128,12 @@
128
128
  "dependencies": {
129
129
  "@stacksjs/ts-css": "^0.3.11",
130
130
  "@stacksjs/clapp": "^0.2.16",
131
- "@stacksjs/desktop": "0.2.736",
132
- "@stacksjs/sanitizer": "0.2.736",
131
+ "@stacksjs/desktop": "0.2.740",
132
+ "@stacksjs/sanitizer": "0.2.740",
133
133
  "@stacksjs/ts-i18n": "^0.1.11",
134
- "bun-plugin-stx": "0.2.736",
134
+ "bun-plugin-stx": "0.2.740",
135
135
  "bunfig": "^0.15.21",
136
- "stx-router": "0.2.736",
136
+ "stx-router": "0.2.740",
137
137
  "ts-broadcasting": "^0.0.11",
138
138
  "ts-images": "^0.2.22",
139
139
  "ts-syntax-highlighter": "^0.2.1"