@stacksjs/stx 0.2.826 → 0.2.830

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 (237) hide show
  1. package/dist/chunk-02zvytqx.js +2 -0
  2. package/dist/{chunk-bt0amey5.js → chunk-04z1xyrb.js} +2 -2
  3. package/dist/{chunk-8ycrmsba.js → chunk-0fthaykk.js} +3 -3
  4. package/dist/chunk-0hnrc2z3.js +2 -0
  5. package/dist/chunk-0jhem1jn.js +2 -0
  6. package/dist/{chunk-f0txsdpa.js → chunk-0rvntfhj.js} +3 -3
  7. package/dist/chunk-17zrprh0.js +2 -0
  8. package/dist/chunk-1bpx9b0m.js +2 -0
  9. package/dist/{chunk-wy0gghvh.js → chunk-1vzncfka.js} +2 -2
  10. package/dist/{chunk-h864en4b.js → chunk-267rpvw5.js} +7 -7
  11. package/dist/{chunk-2vqpz4qv.js → chunk-2qngyyaz.js} +2 -2
  12. package/dist/{chunk-7yb82rm6.js → chunk-2x9zhezb.js} +2 -2
  13. package/dist/{chunk-981z8va1.js → chunk-3p7r3ajd.js} +2 -2
  14. package/dist/chunk-42c92rp3.js +2 -0
  15. package/dist/{chunk-vwtejkb5.js → chunk-47rbtjp1.js} +50 -50
  16. package/dist/chunk-48jzgbbs.js +2 -0
  17. package/dist/chunk-4a3r1kh1.js +43 -0
  18. package/dist/chunk-4hq9v6hq.js +2 -0
  19. package/dist/chunk-4z0jpzdq.js +3 -0
  20. package/dist/{chunk-6qvn1h09.js → chunk-5201w0f1.js} +3 -3
  21. package/dist/{chunk-21syn2j5.js → chunk-54anhwg5.js} +2 -2
  22. package/dist/chunk-5nwmwmjg.js +2 -0
  23. package/dist/chunk-67nq6csk.js +2 -0
  24. package/dist/chunk-6aak0b7c.js +2 -0
  25. package/dist/chunk-6fh00yz2.js +2 -0
  26. package/dist/chunk-6jpmjvbs.js +2 -0
  27. package/dist/{chunk-7sh9fa3q.js → chunk-6k26n0sj.js} +2 -2
  28. package/dist/chunk-6r4teng3.js +2 -0
  29. package/dist/{chunk-d6d2s7n6.js → chunk-6tjm38e4.js} +2 -2
  30. package/dist/{chunk-06hc6rs6.js → chunk-716jrdcg.js} +1 -1
  31. package/dist/chunk-72n804gy.js +2 -0
  32. package/dist/{chunk-3yh6y00f.js → chunk-7k9yahng.js} +6 -6
  33. package/dist/chunk-7kecdwv3.js +25 -0
  34. package/dist/{chunk-wf0n9gpj.js → chunk-7p8m82pj.js} +4 -4
  35. package/dist/{chunk-t9vwggkw.js → chunk-7zf4a66r.js} +6 -6
  36. package/dist/{chunk-x5vxkypk.js → chunk-8d7vh5kq.js} +6 -6
  37. package/dist/{chunk-e648sx8w.js → chunk-8fys3apk.js} +2 -2
  38. package/dist/chunk-8kb9t029.js +2 -0
  39. package/dist/chunk-8n8vj099.js +2 -0
  40. package/dist/{chunk-r9e0r6jx.js → chunk-8y8kgw9s.js} +3 -3
  41. package/dist/chunk-a5m09xb5.js +2 -0
  42. package/dist/{chunk-gjf8cjdt.js → chunk-ac9ncbfw.js} +3 -3
  43. package/dist/chunk-ahd8jdzx.js +2 -0
  44. package/dist/chunk-ay7ggc4k.js +2 -0
  45. package/dist/{chunk-mv3yhspn.js → chunk-b1q40vq4.js} +2 -2
  46. package/dist/{chunk-1d67wtj4.js → chunk-b5syjezp.js} +3 -3
  47. package/dist/{chunk-3axb6t08.js → chunk-b7tb00nz.js} +2 -2
  48. package/dist/chunk-bmm6vtsx.js +2 -0
  49. package/dist/{chunk-8ttmzcxb.js → chunk-c9mdvpf5.js} +29 -29
  50. package/dist/{chunk-5emrarpf.js → chunk-car6nhfe.js} +2 -2
  51. package/dist/{chunk-e4jwhmpb.js → chunk-cca18z35.js} +31 -31
  52. package/dist/{chunk-he5njpsd.js → chunk-cdm6yc10.js} +1 -1
  53. package/dist/chunk-cfrgrnej.js +2 -0
  54. package/dist/{chunk-vzbyn4nh.js → chunk-ckg6q98b.js} +5 -5
  55. package/dist/{chunk-eycaj8mk.js → chunk-ckqgk94e.js} +2 -2
  56. package/dist/{chunk-k81trehg.js → chunk-cv1zc9dg.js} +2 -2
  57. package/dist/chunk-cw8vpk41.js +2 -0
  58. package/dist/chunk-db1c0c3c.js +2 -0
  59. package/dist/{chunk-928y0wer.js → chunk-ddxbc914.js} +105 -105
  60. package/dist/chunk-dptjfnvq.js +2 -0
  61. package/dist/chunk-e240xqcn.js +2 -0
  62. package/dist/{chunk-cxz4cdcn.js → chunk-e75dntfb.js} +2 -2
  63. package/dist/{chunk-wceg59n0.js → chunk-ekh3mxyp.js} +2 -2
  64. package/dist/{chunk-4mj9dem1.js → chunk-em8tv6nz.js} +2 -2
  65. package/dist/{chunk-7qk4exw1.js → chunk-ema1c29k.js} +2 -2
  66. package/dist/{chunk-w45njn1r.js → chunk-en0xmvkx.js} +2 -2
  67. package/dist/{chunk-z23arg8m.js → chunk-f49x34sr.js} +2 -2
  68. package/dist/{chunk-8w9spdbn.js → chunk-f6b7av6b.js} +9 -9
  69. package/dist/{chunk-8p86mpfv.js → chunk-f6wwwgsf.js} +2 -2
  70. package/dist/{chunk-9gmceny5.js → chunk-f7jgda7x.js} +5 -5
  71. package/dist/chunk-fb90n0by.js +2 -0
  72. package/dist/{chunk-b4x5ndt9.js → chunk-fwktw49p.js} +4 -4
  73. package/dist/{chunk-y2bf32vg.js → chunk-fykcqp0m.js} +10 -10
  74. package/dist/chunk-g4qzy5hv.js +2 -0
  75. package/dist/chunk-g4yyfmje.js +2 -0
  76. package/dist/{chunk-tksjakyv.js → chunk-gcf97wgx.js} +1 -1
  77. package/dist/chunk-gg48cgx3.js +2 -0
  78. package/dist/chunk-gh439e80.js +2 -0
  79. package/dist/{chunk-tgk2hcxv.js → chunk-h5pmh5h3.js} +6 -6
  80. package/dist/{chunk-076fj387.js → chunk-hd378dgy.js} +1 -1
  81. package/dist/{chunk-9kj5p5jq.js → chunk-j14fd8kd.js} +8 -8
  82. package/dist/chunk-jp6sbk05.js +2 -0
  83. package/dist/chunk-k6ye0159.js +3 -0
  84. package/dist/{chunk-sk0tmtd3.js → chunk-kny4jmyq.js} +13 -13
  85. package/dist/chunk-kshem79d.js +2 -0
  86. package/dist/chunk-m3tnxk01.js +2 -0
  87. package/dist/chunk-m9bbhg46.js +3 -0
  88. package/dist/chunk-m9dj8pgb.js +2 -0
  89. package/dist/{chunk-bq7cfqk3.js → chunk-mww0j2w4.js} +2 -2
  90. package/dist/{chunk-qj4r08jb.js → chunk-mxvevxb8.js} +4 -4
  91. package/dist/{chunk-btxnrqxf.js → chunk-myje6fhm.js} +5 -5
  92. package/dist/{chunk-1f7d1c0y.js → chunk-mypygxdm.js} +2 -2
  93. package/dist/{chunk-76eh43e9.js → chunk-nfpsaaqm.js} +2 -2
  94. package/dist/chunk-pe5qqem0.js +2 -0
  95. package/dist/{chunk-rptnx3s6.js → chunk-pj2t51hn.js} +29 -29
  96. package/dist/chunk-pj49gnc8.js +2 -0
  97. package/dist/{chunk-67kbsav0.js → chunk-q5pwvr98.js} +1 -1
  98. package/dist/{chunk-2nj9aewf.js → chunk-qadce16v.js} +1 -1
  99. package/dist/chunk-qg2tpvdw.js +2 -0
  100. package/dist/{chunk-d9yjpdyn.js → chunk-qkemyc40.js} +6 -6
  101. package/dist/{chunk-q7zwv88b.js → chunk-qnrgfm9v.js} +2 -2
  102. package/dist/{chunk-b64y3yh0.js → chunk-qw780t39.js} +10 -10
  103. package/dist/{chunk-0scyzg9r.js → chunk-qy6dtm1a.js} +25 -26
  104. package/dist/{chunk-cmf6ar8v.js → chunk-r14j0fx3.js} +5 -5
  105. package/dist/{chunk-p1sfwzmb.js → chunk-r4ncb4h4.js} +1 -1
  106. package/dist/chunk-rb8rdpnt.js +2 -0
  107. package/dist/chunk-rgdyf3af.js +3 -0
  108. package/dist/{chunk-xpy9yjyx.js → chunk-rkdsgfhd.js} +13 -13
  109. package/dist/{chunk-bfbh0hfn.js → chunk-rmygv0n0.js} +6 -6
  110. package/dist/{chunk-mfy2ayv0.js → chunk-ryxkgt1j.js} +3 -3
  111. package/dist/{chunk-n7arptzc.js → chunk-s53wjw7y.js} +3 -3
  112. package/dist/chunk-s5bwrq6g.js +2 -0
  113. package/dist/{chunk-p1fpferp.js → chunk-s5dhvnnd.js} +6 -6
  114. package/dist/{chunk-q45xwvf6.js → chunk-t04jw3j4.js} +3 -3
  115. package/dist/{chunk-4qhz8q0d.js → chunk-t37tszbc.js} +22 -22
  116. package/dist/chunk-t59bc7na.js +3 -0
  117. package/dist/{chunk-f05tmz4z.js → chunk-taws6jfs.js} +9 -9
  118. package/dist/{chunk-bwsz6sv4.js → chunk-tgdswtya.js} +5 -5
  119. package/dist/chunk-tx02ffyc.js +2 -0
  120. package/dist/chunk-txzap6yn.js +2 -0
  121. package/dist/chunk-v1mwhvf8.js +2 -0
  122. package/dist/chunk-v8wtfrbr.js +2 -0
  123. package/dist/chunk-vb4xzz5c.js +2 -0
  124. package/dist/chunk-vcsvhbtj.js +2 -0
  125. package/dist/{chunk-me6kgvsm.js → chunk-vpnyqf0h.js} +1 -1
  126. package/dist/{chunk-mwxbdpb1.js → chunk-vyv76w55.js} +2 -2
  127. package/dist/chunk-w39cfxa6.js +2 -0
  128. package/dist/{chunk-tjhcrj3z.js → chunk-w80efvh7.js} +11 -11
  129. package/dist/chunk-wb6w807m.js +2 -0
  130. package/dist/chunk-webf565c.js +2 -0
  131. package/dist/chunk-wpyhavjy.js +2 -0
  132. package/dist/{chunk-j3st59hv.js → chunk-wr7bmkne.js} +2 -2
  133. package/dist/chunk-wt7qhv5b.js +2 -0
  134. package/dist/{chunk-y8p85kcj.js → chunk-wvds0s9m.js} +2 -2
  135. package/dist/chunk-wxj5srvb.js +2 -0
  136. package/dist/chunk-x6nrn79w.js +2 -0
  137. package/dist/chunk-xdwnbr9b.js +4 -0
  138. package/dist/chunk-xg4ww72k.js +2 -0
  139. package/dist/chunk-xgjr0pzy.js +2 -0
  140. package/dist/{chunk-qz3fdmrc.js → chunk-xn9jg1q5.js} +3 -3
  141. package/dist/chunk-xrspzeqx.js +2 -0
  142. package/dist/chunk-y00nqtdw.js +2 -0
  143. package/dist/{chunk-cmnze7at.js → chunk-ybq56wam.js} +2 -2
  144. package/dist/{chunk-cgtpbr01.js → chunk-yex0t4q2.js} +48 -48
  145. package/dist/chunk-yng848qe.js +2 -0
  146. package/dist/{chunk-y9bj3566.js → chunk-yrw5ensv.js} +3 -3
  147. package/dist/{chunk-pvj0bpqg.js → chunk-z25w7kmr.js} +4 -4
  148. package/dist/chunk-z77hnfkb.js +2 -0
  149. package/dist/{chunk-8qy616yt.js → chunk-zcnehb8p.js} +8 -8
  150. package/dist/{chunk-x6863pzd.js → chunk-zhjr4xvv.js} +5 -5
  151. package/dist/chunk-zj50tqxf.js +2 -0
  152. package/dist/chunk-zt74q4c8.js +2 -0
  153. package/dist/chunk-zty254tw.js +2 -0
  154. package/dist/{chunk-j737tnvt.js → chunk-zvvv6x8c.js} +4 -4
  155. package/dist/{chunk-g25rz48g.js → chunk-zxs92ebc.js} +6 -6
  156. package/dist/cli.js +23 -23
  157. package/dist/client/signals-authoring-runtime.js +6 -7
  158. package/dist/craft-entry.js +2 -2
  159. package/dist/craft.js +2 -2
  160. package/dist/loops.d.ts +2 -0
  161. package/dist/loops.js +22 -3
  162. package/dist/performance-utils.d.ts +2 -0
  163. package/dist/performance-utils.js +7 -0
  164. package/dist/process.js +16 -10
  165. package/dist/pwa.js +3 -3
  166. package/dist/ssg.js +11 -11
  167. package/package.json +5 -5
  168. package/dist/chunk-09285y4b.js +0 -2
  169. package/dist/chunk-0jvrzpfs.js +0 -2
  170. package/dist/chunk-19gk9k01.js +0 -2
  171. package/dist/chunk-2c5bwrnh.js +0 -2
  172. package/dist/chunk-2fwssv2z.js +0 -2
  173. package/dist/chunk-2v3r330m.js +0 -3
  174. package/dist/chunk-2vk7dtvs.js +0 -2
  175. package/dist/chunk-30rpspzt.js +0 -43
  176. package/dist/chunk-3bf48zrh.js +0 -2
  177. package/dist/chunk-4amybnpc.js +0 -2
  178. package/dist/chunk-4zjxj8ex.js +0 -2
  179. package/dist/chunk-58e92xts.js +0 -2
  180. package/dist/chunk-6h1qa3hw.js +0 -2
  181. package/dist/chunk-7pz76f28.js +0 -2
  182. package/dist/chunk-82v1egn6.js +0 -2
  183. package/dist/chunk-897gqcby.js +0 -2
  184. package/dist/chunk-9z9c025j.js +0 -2
  185. package/dist/chunk-a8fy7jv8.js +0 -2
  186. package/dist/chunk-akj26p4b.js +0 -3
  187. package/dist/chunk-b22yj5j5.js +0 -2
  188. package/dist/chunk-brhas9mp.js +0 -3
  189. package/dist/chunk-c1e45rtv.js +0 -2
  190. package/dist/chunk-cgamtmxv.js +0 -2
  191. package/dist/chunk-d0jcw9h6.js +0 -2
  192. package/dist/chunk-erf2g5b2.js +0 -2
  193. package/dist/chunk-exke928x.js +0 -2
  194. package/dist/chunk-fwk0gjbq.js +0 -2
  195. package/dist/chunk-g4sdthck.js +0 -2
  196. package/dist/chunk-g8nqmnb7.js +0 -2
  197. package/dist/chunk-gnt36wgk.js +0 -25
  198. package/dist/chunk-h67pm636.js +0 -2
  199. package/dist/chunk-hb8jxg45.js +0 -2
  200. package/dist/chunk-hfgzqapw.js +0 -2
  201. package/dist/chunk-hhats9b3.js +0 -2
  202. package/dist/chunk-htdbm0sd.js +0 -2
  203. package/dist/chunk-j0hrk24j.js +0 -2
  204. package/dist/chunk-jjbdtj4w.js +0 -2
  205. package/dist/chunk-jzc3rw49.js +0 -2
  206. package/dist/chunk-jzgyrxye.js +0 -2
  207. package/dist/chunk-k0xdvegc.js +0 -2
  208. package/dist/chunk-kep17bvj.js +0 -2
  209. package/dist/chunk-kfn7g24h.js +0 -2
  210. package/dist/chunk-kq5k2qbz.js +0 -2
  211. package/dist/chunk-ksxtrmy2.js +0 -2
  212. package/dist/chunk-m934bzg2.js +0 -2
  213. package/dist/chunk-mfc5d181.js +0 -2
  214. package/dist/chunk-mmeck545.js +0 -2
  215. package/dist/chunk-mz6qjee1.js +0 -2
  216. package/dist/chunk-ndjmt3vg.js +0 -3
  217. package/dist/chunk-p9dma8k0.js +0 -2
  218. package/dist/chunk-pby6dxnc.js +0 -2
  219. package/dist/chunk-prt4ntb0.js +0 -2
  220. package/dist/chunk-q2ynwst2.js +0 -2
  221. package/dist/chunk-q5bct2ks.js +0 -2
  222. package/dist/chunk-qp7dajd2.js +0 -2
  223. package/dist/chunk-r2hjn9ds.js +0 -2
  224. package/dist/chunk-s2zsa16d.js +0 -2
  225. package/dist/chunk-s8b6re34.js +0 -2
  226. package/dist/chunk-sddp2398.js +0 -2
  227. package/dist/chunk-sv4emtcj.js +0 -2
  228. package/dist/chunk-tcyvwy8p.js +0 -2
  229. package/dist/chunk-tg18j1yf.js +0 -2
  230. package/dist/chunk-tj7dh2dz.js +0 -2
  231. package/dist/chunk-tsvnhc0c.js +0 -4
  232. package/dist/chunk-v2ps4gnx.js +0 -2
  233. package/dist/chunk-vafxrky2.js +0 -2
  234. package/dist/chunk-wpendr22.js +0 -3
  235. package/dist/chunk-x30gh7vt.js +0 -2
  236. package/dist/chunk-x5r1cty7.js +0 -2
  237. package/dist/chunk-zd3dsp6p.js +0 -2
package/dist/loops.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { yieldDuringRendering } from "./performance-utils.js";
1
2
  import { loopBoundNames, parseLoopBinding, readsAnyName } from "./loop-binding.js";
2
3
  import { extractClientSignalNames } from "./signal-processing.js";
3
4
  import { processConditionals } from "./conditionals.js";
@@ -371,6 +372,22 @@ export function reportDeferredLoopWarnings(html) {
371
372
  });
372
373
  }
373
374
  export function processLoops(template, context, filePath, options, deferWarnings = !1) {
375
+ const steps = processLoopSteps(template, context, filePath, options, deferWarnings);
376
+ let next = steps.next();
377
+ while (!next.done)
378
+ next = steps.next();
379
+ return next.value;
380
+ }
381
+ export async function processLoopsAsync(template, context, filePath, options, deferWarnings = !1) {
382
+ const steps = processLoopSteps(template, context, filePath, options, deferWarnings);
383
+ let next = steps.next();
384
+ while (!next.done) {
385
+ await yieldDuringRendering();
386
+ next = steps.next();
387
+ }
388
+ return next.value;
389
+ }
390
+ function* processLoopSteps(template, context, filePath, options, deferWarnings = !1) {
374
391
  let output = template;
375
392
  const clientSignals = new Set(context.__stx_client_signal_names || []);
376
393
  for (const name of extractClientSignalNames(template))
@@ -425,7 +442,7 @@ export function processLoops(template, context, filePath, options, deferWarnings
425
442
  }
426
443
  return null;
427
444
  }
428
- function processForeachWithContext(template, ctx) {
445
+ function* processForeachWithContext(template, ctx) {
429
446
  let result = template;
430
447
  while (!0) {
431
448
  const match = findMatchingForeach(result);
@@ -478,6 +495,8 @@ export function processLoops(template, context, filePath, options, deferWarnings
478
495
  let loopResult = "";
479
496
  const boundNames = new Set(loopBoundNames(`${arrayExpr} as ${itemVar}`)), items = array, sanitizeCache = ctx[SANITIZE_CACHE] ?? new WeakMap;
480
497
  for (let index = 0;index < items.length; index++) {
498
+ if (index % 16 === 0)
499
+ yield;
481
500
  const item = items[index], loopContext = {
482
501
  index,
483
502
  iteration: index + 1,
@@ -520,7 +539,7 @@ export function processLoops(template, context, filePath, options, deferWarnings
520
539
  } else
521
540
  itemContext[indexName] = index;
522
541
  let processedContent = processForelse(content, itemContext);
523
- processedContent = processLoops(processedContent, itemContext, filePath, options, !0);
542
+ processedContent = yield* processLoopSteps(processedContent, itemContext, filePath, options, !0);
524
543
  processedContent = processConditionals(processedContent, itemContext, filePath);
525
544
  processedContent = processLoopControl(processedContent, itemContext);
526
545
  const breakAt = processedContent.indexOf(BREAK_MARKER), continueAt = processedContent.indexOf(CONTINUE_MARKER), stopAt = breakAt < 0 ? continueAt : continueAt < 0 ? breakAt : Math.min(breakAt, continueAt);
@@ -542,7 +561,7 @@ export function processLoops(template, context, filePath, options, deferWarnings
542
561
  }
543
562
  return result;
544
563
  }
545
- output = processForeachWithContext(output, context);
564
+ output = yield* processForeachWithContext(output, context);
546
565
  output = processForLoops(output, context, filePath, options);
547
566
  const maxWhileIterations = options?.loops?.maxWhileIterations ?? DEFAULT_MAX_WHILE_ITERATIONS;
548
567
  output = processWhileLoops(output, context, maxWhileIterations);
@@ -315,4 +315,6 @@ export declare function applyDefaultBudgets(monitor?: PerformanceMonitor): void;
315
315
  * Reset the performance monitor instance (useful for testing)
316
316
  */
317
317
  export declare function resetPerformanceMonitor(): void;
318
+ /** Bound consecutive render work across components, stages and collection rows. */
319
+ export declare function yieldDuringRendering(): Promise<void>;
318
320
  export {};
@@ -464,3 +464,10 @@ export function applyDefaultBudgets(monitor = getPerformanceMonitor()) {
464
464
  export function resetPerformanceMonitor() {
465
465
  _performanceMonitor = null;
466
466
  }
467
+ let lastRenderYield = 0;
468
+ export async function yieldDuringRendering() {
469
+ if (performance.now() - lastRenderYield < 16)
470
+ return;
471
+ await new Promise((resolve) => setTimeout(resolve, 0));
472
+ lastRenderYield = performance.now();
473
+ }
package/dist/process.js CHANGED
@@ -28,11 +28,11 @@ import { processBasicFormDirectives, processErrorDirective, processFormInputDire
28
28
  import { processTranslateDirective } from "./i18n.js";
29
29
  import { processIncludes, processStackPushDirectives, processStackReplacements } from "./includes.js";
30
30
  import { processJsDirectives, processTsDirectives } from "./js-ts.js";
31
- import { processLoops, reportDeferredLoopWarnings } from "./loops.js";
31
+ import { processLoopsAsync, reportDeferredLoopWarnings } from "./loops.js";
32
32
  import { processMarkdownDirectives } from "./markdown.js";
33
33
  import { processMethodDirectives } from "./method-spoofing.js";
34
34
  import { runPostProcessingMiddleware, runPreProcessingMiddleware } from "./middleware.js";
35
- import { performanceMonitor } from "./performance-utils.js";
35
+ import { performanceMonitor, yieldDuringRendering } from "./performance-utils.js";
36
36
  import { processRouteDirectives } from "./routes.js";
37
37
  import { injectSeoTags, processMetaDirectives, processSeoDirective, processStructuredData } from "./seo.js";
38
38
  import { fileExists, resolveTemplatePath, scopeSequenceKey } from "./utils.js";
@@ -369,13 +369,6 @@ function restoreEscapedMustaches(html) {
369
369
  return before.lastIndexOf("<") > before.lastIndexOf(">") ? `{{${content}}}` : `{<!--stx-literal-->{${content}}}`;
370
370
  });
371
371
  }
372
- let lastRenderYield = 0;
373
- async function yieldDuringRendering() {
374
- if (performance.now() - lastRenderYield < 16)
375
- return;
376
- await new Promise((resolve) => setTimeout(resolve, 0));
377
- lastRenderYield = performance.now();
378
- }
379
372
  export async function processDirectives(template, context, filePath, options, dependencies) {
380
373
  await yieldDuringRendering();
381
374
  if (options.ssr === !1 && !options.autoShell && options.buildMode === "spa")
@@ -824,11 +817,13 @@ async function interpolateClientScriptExpressions(output, context, filePath) {
824
817
  }
825
818
  async function processOtherDirectives(template, context, filePath, options, dependencies) {
826
819
  let output = template;
820
+ await yieldDuringRendering();
827
821
  const opts = options;
828
822
  output = await extractServerScriptVariables(output, context, filePath, options);
829
823
  output = await processJsDirectives(output, context, filePath);
830
824
  output = await processTsDirectives(output, context, filePath);
831
825
  output = await interpolateClientScriptExpressions(output, context, filePath);
826
+ await yieldDuringRendering();
832
827
  output = await processCustomDirectives(output, context, filePath, opts);
833
828
  if (usesSignalsInScript(output)) {
834
829
  output = convertSignalDirectivesToAttributes(output, context);
@@ -836,11 +831,14 @@ async function processOtherDirectives(template, context, filePath, options, depe
836
831
  output = convertServerLoopAttributesToDirectives(output, context);
837
832
  }
838
833
  output = preEvalLiteralReactiveIfs(output);
834
+ await yieldDuringRendering();
839
835
  const { processStreamDirectives } = await importOnce("stx/streaming", () => import("./streaming.js"));
840
836
  output = processStreamDirectives(output, context);
841
- output = processLoops(output, context, filePath, opts, !0);
837
+ output = await processLoopsAsync(output, context, filePath, opts, !0);
838
+ await yieldDuringRendering();
842
839
  output = await processDynamicComponents(output, context, filePath, opts, dependencies);
843
840
  output = await processComponents(output, context, filePath, opts, dependencies);
841
+ await yieldDuringRendering();
844
842
  output = processAnimationDirectives(output, context, filePath, opts);
845
843
  const { processDeferDirectives } = await importOnce("stx/defer", () => import("./defer.js"));
846
844
  output = processDeferDirectives(output, context, filePath);
@@ -862,6 +860,7 @@ async function processOtherDirectives(template, context, filePath, options, depe
862
860
  output = processVirtualListDirectives(output, context, filePath);
863
861
  output = processVirtualGridDirectives(output, context, filePath);
864
862
  output = processInfiniteListDirectives(output, context, filePath);
863
+ await yieldDuringRendering();
865
864
  const { processPartialHydrationDirectives, processStaticDirectives } = await importOnce("stx/partial-hydration", () => import("./partial-hydration.js"));
866
865
  output = processPartialHydrationDirectives(output, context, filePath);
867
866
  output = processStaticDirectives(output);
@@ -886,10 +885,12 @@ async function processOtherDirectives(template, context, filePath, options, depe
886
885
  output = processMethodDirectives(output);
887
886
  output = await processIncludes(output, context, filePath, opts, dependencies);
888
887
  output = await processComponents(output, context, filePath, opts, dependencies);
888
+ await yieldDuringRendering();
889
889
  output = output.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g, "");
890
890
  output = processRefAttributes(output);
891
891
  output = processConditionals(output, context, filePath);
892
892
  output = reportDeferredLoopWarnings(output);
893
+ await yieldDuringRendering();
893
894
  if (context.__stxProcessingDepth === 1)
894
895
  output = injectComponentClientFactories(output, context);
895
896
  output = processStatusDirective(output, context, { filePath, buildMode: opts.buildMode });
@@ -901,6 +902,7 @@ async function processOtherDirectives(template, context, filePath, options, depe
901
902
  output = await processMarkdownFileDirectives(output, context, filePath, opts);
902
903
  output = await processMarkdownDirectives(output, context, filePath);
903
904
  output = await processTranslateDirective(output, context, filePath, opts);
905
+ await yieldDuringRendering();
904
906
  output = processA11yDirectives(output, context, filePath, opts);
905
907
  output = processMetaDirectives(output, context, filePath, opts);
906
908
  output = processStructuredData(output, context, filePath);
@@ -912,6 +914,7 @@ async function processOtherDirectives(template, context, filePath, options, depe
912
914
  if (!opts.skipEventDirectives)
913
915
  output = processEventDirectives(output, context, filePath);
914
916
  output = processReactiveDirectives(output, context, filePath, options.skipSignalsRuntime === !0 && Number(context.__stxProcessingDepth) > 0);
917
+ await yieldDuringRendering();
915
918
  if (opts.debug) {
916
919
  const hasXData = /\bx-data\s*=/.test(output), hasSignals = hasSignalsSyntax(template);
917
920
  if (hasXData && hasSignals)
@@ -921,6 +924,7 @@ async function processOtherDirectives(template, context, filePath, options, depe
921
924
  }
922
925
  output = processServerBindings(output, context);
923
926
  output = await processExpressions(output, context, filePath);
927
+ await yieldDuringRendering();
924
928
  output = addCloakToUnresolvedExpressions(output);
925
929
  output = addCloakToConditionalDirectives(output);
926
930
  output = processTemplateBindings(output);
@@ -928,8 +932,10 @@ async function processOtherDirectives(template, context, filePath, options, depe
928
932
  output = processXElementDirectives(output);
929
933
  const pageFilePath = context.__originalFilePath || filePath, serverData = extractBridgeData(context);
930
934
  output = await processSignals(output, opts, pageFilePath, serverData);
935
+ await yieldDuringRendering();
931
936
  output = processAppearanceBootstrapDirective(output, context);
932
937
  output = await runPostProcessingMiddleware(output, context, filePath, opts);
938
+ await yieldDuringRendering();
933
939
  if (opts.media?.image?.autoSiblings) {
934
940
  const publicDir = opts.publicDir || "public", { rewriteImagesWithSiblings } = await importOnce("stx/image-optimization/auto-sibling", () => import("./image-optimization/auto-sibling.js"));
935
941
  output = await rewriteImagesWithSiblings(output, { publicDir });
package/dist/pwa.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{eo,Ht,kl,Tg}from"./chunk-j737tnvt.js";import{Qs,Ii,_g,Cg,Eg}from"./chunk-bfbh0hfn.js";import{vl,xl,Sl,Sg,kg}from"./chunk-4mj9dem1.js";import{Ue,Tn,Oi}from"./chunk-y9bj3566.js";import{$g,Rg,Ag,Pg,to,fy}from"./chunk-1f7d1c0y.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-x5r1cty7.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{eo,Vt,_l,Rg}from"./chunk-zvvv6x8c.js";import{Qs,Oi,Eg,Tg,$g}from"./chunk-rmygv0n0.js";import{xl,Sl,kl,_g,Cg}from"./chunk-em8tv6nz.js";import{We,$n,Ni}from"./chunk-yrw5ensv.js";import{Ag,Pg,Ig,Og,to,my}from"./chunk-mypygxdm.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-y00nqtdw.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=Ue(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=eo(n,t);if(a){let s=Ht(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 Ii(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,xl as auditBuildOutput,vl as auditConfig,re as buildPwaAssets,Sl as calculateAuditResult,kg as formatAuditResult,Oi as formatSize,j as generateManifest,_ as generateManifestJson,Cg as generateManifestLink,F as generateOfflinePage,Ue as generatePrecacheManifest,Tn as generatePrecacheManifestJs,M as generatePwaIcons,Qs as generatePwaTags,eo as generateServiceWorker,Tg as generateServiceWorkerAuto,_g as generateSwRegistrationScript,Eg as generateThemeColorMeta,N as getExpectedIconPaths,Ht as getServiceWorkerFileName,Ii as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,kl as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,to as pwaDirectives,$g as pwaInstallDirective,Ag as pwaOfflineDirective,Pg as pwaPushDirective,Rg as pwaUpdateDirective,fy as registerPwaDirectives,Sg 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=We(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=eo(n,t);if(a){let s=Vt(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 Oi(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,xl as auditConfig,re as buildPwaAssets,kl as calculateAuditResult,Cg as formatAuditResult,Ni as formatSize,j as generateManifest,_ as generateManifestJson,Tg as generateManifestLink,F as generateOfflinePage,We as generatePrecacheManifest,$n as generatePrecacheManifestJs,M as generatePwaIcons,Qs as generatePwaTags,eo as generateServiceWorker,Rg as generateServiceWorkerAuto,Eg as generateSwRegistrationScript,$g as generateThemeColorMeta,N as getExpectedIconPaths,Vt as getServiceWorkerFileName,Oi as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,_l as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,to as pwaDirectives,Ag as pwaInstallDirective,Ig as pwaOfflineDirective,Og as pwaPushDirective,Pg as pwaUpdateDirective,my as registerPwaDirectives,_g as runPwaAudit,D as validateManifest};
package/dist/ssg.js CHANGED
@@ -1,13 +1,13 @@
1
1
  // @bun
2
- import"./chunk-7sh9fa3q.js";import{x,sl}from"./chunk-8ttmzcxb.js";import"./chunk-bt0amey5.js";import"./chunk-r9e0r6jx.js";import{Rt,y}from"./chunk-928y0wer.js";import"./chunk-2vqpz4qv.js";import"./chunk-e648sx8w.js";import"./chunk-k81trehg.js";import{kt,_t,Ct,Et,Tt,$t}from"./chunk-qj4r08jb.js";import{a}from"./chunk-rptnx3s6.js";import{Es}from"./chunk-xpy9yjyx.js";import"./chunk-wf0n9gpj.js";import"./chunk-bwsz6sv4.js";import{he,en,tn}from"./chunk-9kj5p5jq.js";import"./chunk-8p86mpfv.js";import{b}from"./chunk-y2bf32vg.js";import{yt,i}from"./chunk-vwtejkb5.js";import"./chunk-8qy616yt.js";import"./chunk-tjhcrj3z.js";import{ps}from"./chunk-f05tmz4z.js";import"./chunk-gnt36wgk.js";import"./chunk-c84pxd2k.js";import{Za,Qa,ec}from"./chunk-gjf8cjdt.js";import{Zt,Yn,Zn}from"./chunk-ndjmt3vg.js";import{Qt}from"./chunk-bq7cfqk3.js";import"./chunk-2v3r330m.js";import"./chunk-wceg59n0.js";import{X,we}from"./chunk-d9yjpdyn.js";import"./chunk-2nj9aewf.js";import"./chunk-1d67wtj4.js";import{c}from"./chunk-brhas9mp.js";import{r,ge}from"./chunk-b4x5ndt9.js";import D from"fs";import f from"path";import{createHash as vt}from"crypto";function Pt(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 It(t){return Bun.hash(t).toString(16)}function ot(t,n={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let s=new Map,o=t.replace(Dt,(e,u,g,v)=>{let w=v.trim();if(!w)return e;if(/\bdata-stx-src=/.test(g))return e;if(n.minify)w=Pt(w);let p=It(w);if(!s.has(p))s.set(p,w);let P=n.integrity?` data-stx-integrity="sha384-${vt("sha384").update(w).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${u}" data-stx-src="/_stx/islands/${p}.js"${P}${g}></script>`}),l=Array.from(s,([e,u])=>({hash:e,code:u}));return{html:o,chunks:l}}var Bt=new Set(["visible","idle"]);function ct(t){if(!t.includes("data-stx-src="))return t;let n=new Map,s=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,o;while((o=s.exec(t))!==null)n.set(o[1],o[2]);let l=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,u;while((u=e.exec(t))!==null)if(Bt.has(n.get(u[1])||""))l.add(u[2]);let g=/<\/head\s*>/iy,v=y(t,(p,P)=>(g.lastIndex=P,g.exec(p)?g.lastIndex:-1))[0]?.start??-1;if(l.size===0||v===-1)return t;let w=Array.from(l).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 K(t){let n=t.trim();if(!n)return null;let s=/^https?:\/\//i.test(n)?n:`https://${n}`;try{return new URL(s).origin+new URL(s).pathname.replace(/\/$/,"")}catch{return null}}function Ft(t){for(let n of jt){let s=t[n];if(!s)continue;let o=K(s);if(o)return{url:o,source:"env",via:n}}return null}function lt(t){if(!t||typeof t!=="object")return null;let n=t,s=n.site?.url??n.url??n.app?.url;return typeof s==="string"?K(s):null}async function At(t){let{existsSync:n}=await import("fs"),s=await import("path");for(let o of["site.config.ts","site.config.js",".config/site.config.ts"]){let l=s.resolve(t,o);if(!n(l))continue;try{let e=await import(l),u=lt(e.default??e);if(u)return u}catch{}}return null}async function ut(t={}){let n=t.cwd??process.cwd(),s=t.env??process.env;if(t.explicit){let u=K(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 l=await At(n);if(l)return{url:l,source:"site.config",via:"url"};let e=Ft(s);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 q(t){return async()=>({paths:await t(),fallback:!1})}var Ot;function Lt(t){let n=r(t),{depths:s}=ge(n),o=/\b(?:async\s+)?function\s+getStaticPaths\s*\(/g,l;while((l=o.exec(n))!==null){if(s[l.index]!==0)continue;let u=x(n,"(",")",o.lastIndex-1),g=n.indexOf("{",u+1),v=x(n,"{","}",g);if(u<0||g<0||v<0)break;return t.slice(l.index,v+1)}let e=/\b(?:const|let|var)\s+getStaticPaths\s*=/g;while((l=e.exec(n))!==null){if(s[l.index]!==0)continue;let u=sl(n,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 n="read";try{let s=await Bun.file(t).text();n="parse";let o=Qt(s),l=[...o.server,...o.client,...o.signals].filter((e)=>/(?:^|\s)server(?:\s|=|$)/i.test(r(e.attrs))).sort((e,u)=>s.indexOf(e.fullTag)-s.indexOf(u.fullTag));for(let e of l){if(!/\bgetStaticPaths\b/.test(r(e.content)))continue;let u=(Ot??=new Bun.Transpiler({loader:"ts",target:"bun"})).transformSync(e.content);if(!/\bgetStaticPaths\b/.test(r(u)))continue;let g=Lt(u);if(/\bdefineStaticPaths\b/.test(r(g))&&Rt(u,"defineStaticPaths"))throw SyntaxError("Cannot evaluate a module-local defineStaticPaths binding during isolated hook extraction");n="execute";let v=Function("defineStaticPaths",`return (${g})`)(q);if(typeof v!=="function")throw TypeError("getStaticPaths must be a function");let w=await v();n="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(s){return{kind:"error",phase:n,error:s instanceof Error?s:Error(String(s))}}}class pt{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,n=""){this.cacheDir=t,this.salt=n}async load(){if(this.loaded)return;let t=f.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let n=JSON.parse(await Bun.file(t).text());for(let[s,o]of Object.entries(n))this.cache.set(s,o)}catch{}this.loaded=!0}async save(){await D.promises.mkdir(this.cacheDir,{recursive:!0});let t=f.join(this.cacheDir,"build-cache.json"),n={};for(let[s,o]of this.cache)n[s]=o;await Bun.write(t,JSON.stringify(n))}getHash(t,n){let s=D.statSync(t),o=`${this.salt}|${t}:${s.mtimeMs}`;for(let e of n)if(D.existsSync(e)){let u=D.statSync(e);o+=`:${e}:${u.mtimeMs}`}let l=0;for(let e=0;e<o.length;e++){let u=o.charCodeAt(e);l=(l<<5)-l+u,l=l&l}return Math.abs(l).toString(36)}get(t,n){let s=this.cache.get(t);if(!s)return null;let o=ft(n).some((u)=>D.existsSync(u)),l=[n,...s.dependencies??[]].some((u)=>u.endsWith(".stx")&&D.existsSync(u)&&ps(D.readFileSync(u,"utf8")).some((g)=>/\bserver\b/.test(g.attrs)));if(o||l)return this.cache.delete(t),null;let e=this.getHash(n,s.dependencies??[]);if(s.hash!==e)return this.cache.delete(t),null;return s.html}set(t,n,s,o){let l=this.getHash(n,s);this.cache.set(t,{hash:l,html:o,generatedAt:Date.now(),dependencies:s})}}class ht{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let n=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return f.join(this.cacheDir,"isr",n)}async get(t){let n=this.getFilePath(t);if(!await Bun.file(n).exists())return null;try{return JSON.parse(await Bun.file(n).text())}catch{return null}}async set(t,n){let s=this.getFilePath(t);await D.promises.mkdir(f.dirname(s),{recursive:!0}),await Bun.write(s,JSON.stringify(n))}async invalidate(t){let n=this.getFilePath(t);if(await Bun.file(n).exists())await D.promises.unlink(n)}async invalidatePattern(t){let n=f.join(this.cacheDir,"isr");if(!D.existsSync(n))return;let s=await D.promises.readdir(n);for(let o of s){let l=o.replace(/_/g,"/").replace(".json","");if(t.test(l))await D.promises.unlink(f.join(n,o))}}async needsRevalidation(t){let n=await this.get(t);if(!n)return!0;return Date.now()>n.revalidateAfter}}async function Ut(t){let n=[];if(!t.isDynamic)n.push({url:t.pattern,params:{}});else{let s=await gt(t.filePath);if(s.kind==="error")throw Error(`getStaticPaths ${s.phase} failed for ${t.pattern} (${t.filePath}): ${s.error.message}`,{cause:s.error});if(s.kind==="absent")return console.warn(`Warning: Dynamic route ${t.pattern} (${t.filePath}) has no getStaticPaths`),n;let o=s.value;if(o.paths.length===0)return console.info(`getStaticPaths returned no paths for dynamic route ${t.pattern} (${t.filePath})`),n;for(let l of o.paths){let e=t.pattern;for(let[u,g]of Object.entries(l.params))e=e.replace(`:${u}`,g).replace(`:${u}*`,g);n.push({url:e,params:l.params,props:l.props,revalidate:l.revalidate})}}return n}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 n of ft(t))if(await Bun.file(n).exists())try{let s=await import(n);if(typeof s.default==="function")return await s.default();else if(typeof s.default==="object")return s.default;else if(typeof s.getData==="function")return await s.getData();else{let{default:o,...l}=s;return l}}catch(s){console.error(`Error loading data file ${n}:`,s)}return null}async function Gt(t,n,s){let o=t.match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return null;let l=o[1];if(!l.includes("getStaticProps"))return null;try{let e=l.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticProps\s*\([^)]*\)\s*\{([\s\S]*?)\n\}/);if(!e)return null;return await Function("params",`
2
+ import"./chunk-6k26n0sj.js";import{x,ol}from"./chunk-c9mdvpf5.js";import"./chunk-04z1xyrb.js";import"./chunk-8y8kgw9s.js";import{At,y}from"./chunk-ddxbc914.js";import"./chunk-2qngyyaz.js";import"./chunk-8fys3apk.js";import"./chunk-cv1zc9dg.js";import{_t,Ct,Et,Tt,$t,Rt}from"./chunk-mxvevxb8.js";import{a}from"./chunk-pj2t51hn.js";import{Es}from"./chunk-rkdsgfhd.js";import"./chunk-7p8m82pj.js";import"./chunk-tgdswtya.js";import{ye,tn,nn}from"./chunk-j14fd8kd.js";import"./chunk-f6wwwgsf.js";import{b}from"./chunk-fykcqp0m.js";import{bt,i}from"./chunk-47rbtjp1.js";import"./chunk-zcnehb8p.js";import"./chunk-w80efvh7.js";import{ps}from"./chunk-taws6jfs.js";import"./chunk-7kecdwv3.js";import"./chunk-c84pxd2k.js";import{Qa,ec,tc}from"./chunk-ac9ncbfw.js";import{Qt,Zn,Qn}from"./chunk-4z0jpzdq.js";import{en}from"./chunk-mww0j2w4.js";import"./chunk-rgdyf3af.js";import"./chunk-ekh3mxyp.js";import{G,ve}from"./chunk-qkemyc40.js";import"./chunk-qadce16v.js";import"./chunk-b5syjezp.js";import{c}from"./chunk-k6ye0159.js";import{r,me}from"./chunk-fwktw49p.js";import D from"fs";import f from"path";import{createHash as vt}from"crypto";function Pt(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var kt=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Dt(t){return Bun.hash(t).toString(16)}function ot(t,n={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let s=new Map,o=t.replace(kt,(e,u,g,v)=>{let w=v.trim();if(!w)return e;if(/\bdata-stx-src=/.test(g))return e;if(n.minify)w=Pt(w);let p=Dt(w);if(!s.has(p))s.set(p,w);let P=n.integrity?` data-stx-integrity="sha384-${vt("sha384").update(w).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${u}" data-stx-src="/_stx/islands/${p}.js"${P}${g}></script>`}),l=Array.from(s,([e,u])=>({hash:e,code:u}));return{html:o,chunks:l}}var It=new Set(["visible","idle"]);function ct(t){if(!t.includes("data-stx-src="))return t;let n=new Map,s=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,o;while((o=s.exec(t))!==null)n.set(o[1],o[2]);let l=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,u;while((u=e.exec(t))!==null)if(It.has(n.get(u[1])||""))l.add(u[2]);let g=/<\/head\s*>/iy,v=y(t,(p,P)=>(g.lastIndex=P,g.exec(p)?g.lastIndex:-1))[0]?.start??-1;if(l.size===0||v===-1)return t;let w=Array.from(l).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 Bt=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function X(t){let n=t.trim();if(!n)return null;let s=/^https?:\/\//i.test(n)?n:`https://${n}`;try{return new URL(s).origin+new URL(s).pathname.replace(/\/$/,"")}catch{return null}}function jt(t){for(let n of Bt){let s=t[n];if(!s)continue;let o=X(s);if(o)return{url:o,source:"env",via:n}}return null}function lt(t){if(!t||typeof t!=="object")return null;let n=t,s=n.site?.url??n.url??n.app?.url;return typeof s==="string"?X(s):null}async function Ft(t){let{existsSync:n}=await import("fs"),s=await import("path");for(let o of["site.config.ts","site.config.js",".config/site.config.ts"]){let l=s.resolve(t,o);if(!n(l))continue;try{let e=await import(l),u=lt(e.default??e);if(u)return u}catch{}}return null}async function ut(t={}){let n=t.cwd??process.cwd(),s=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 l=await Ft(n);if(l)return{url:l,source:"site.config",via:"url"};let e=jt(s);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 n=r(t),{depths:s}=me(n),o=/\b(?:async\s+)?function\s+getStaticPaths\s*\(/g,l;while((l=o.exec(n))!==null){if(s[l.index]!==0)continue;let u=x(n,"(",")",o.lastIndex-1),g=n.indexOf("{",u+1),v=x(n,"{","}",g);if(u<0||g<0||v<0)break;return t.slice(l.index,v+1)}let e=/\b(?:const|let|var)\s+getStaticPaths\s*=/g;while((l=e.exec(n))!==null){if(s[l.index]!==0)continue;let u=ol(n,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 n="read";try{let s=await Bun.file(t).text();n="parse";let o=en(s),l=[...o.server,...o.client,...o.signals].filter((e)=>/(?:^|\s)server(?:\s|=|$)/i.test(r(e.attrs))).sort((e,u)=>s.indexOf(e.fullTag)-s.indexOf(u.fullTag));for(let e of l){if(!/\bgetStaticPaths\b/.test(r(e.content)))continue;let u=(Ot??=new Bun.Transpiler({loader:"ts",target:"bun"})).transformSync(e.content);if(!/\bgetStaticPaths\b/.test(r(u)))continue;let g=Lt(u);if(/\bdefineStaticPaths\b/.test(r(g))&&At(u,"defineStaticPaths"))throw SyntaxError("Cannot evaluate a module-local defineStaticPaths binding during isolated hook extraction");n="execute";let v=Function("defineStaticPaths",`return (${g})`)(J);if(typeof v!=="function")throw TypeError("getStaticPaths must be a function");let w=await v();n="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(s){return{kind:"error",phase:n,error:s instanceof Error?s:Error(String(s))}}}class pt{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,n=""){this.cacheDir=t,this.salt=n}async load(){if(this.loaded)return;let t=f.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let n=JSON.parse(await Bun.file(t).text());for(let[s,o]of Object.entries(n))this.cache.set(s,o)}catch{}this.loaded=!0}async save(){await D.promises.mkdir(this.cacheDir,{recursive:!0});let t=f.join(this.cacheDir,"build-cache.json"),n={};for(let[s,o]of this.cache)n[s]=o;await Bun.write(t,JSON.stringify(n))}getHash(t,n){let s=D.statSync(t),o=`${this.salt}|${t}:${s.mtimeMs}`;for(let e of n)if(D.existsSync(e)){let u=D.statSync(e);o+=`:${e}:${u.mtimeMs}`}let l=0;for(let e=0;e<o.length;e++){let u=o.charCodeAt(e);l=(l<<5)-l+u,l=l&l}return Math.abs(l).toString(36)}get(t,n){let s=this.cache.get(t);if(!s)return null;let o=ft(n).some((u)=>D.existsSync(u)),l=[n,...s.dependencies??[]].some((u)=>u.endsWith(".stx")&&D.existsSync(u)&&ps(D.readFileSync(u,"utf8")).some((g)=>/\bserver\b/.test(g.attrs)));if(o||l)return this.cache.delete(t),null;let e=this.getHash(n,s.dependencies??[]);if(s.hash!==e)return this.cache.delete(t),null;return s.html}set(t,n,s,o){let l=this.getHash(n,s);this.cache.set(t,{hash:l,html:o,generatedAt:Date.now(),dependencies:s})}}class ht{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let n=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return f.join(this.cacheDir,"isr",n)}async get(t){let n=this.getFilePath(t);if(!await Bun.file(n).exists())return null;try{return JSON.parse(await Bun.file(n).text())}catch{return null}}async set(t,n){let s=this.getFilePath(t);await D.promises.mkdir(f.dirname(s),{recursive:!0}),await Bun.write(s,JSON.stringify(n))}async invalidate(t){let n=this.getFilePath(t);if(await Bun.file(n).exists())await D.promises.unlink(n)}async invalidatePattern(t){let n=f.join(this.cacheDir,"isr");if(!D.existsSync(n))return;let s=await D.promises.readdir(n);for(let o of s){let l=o.replace(/_/g,"/").replace(".json","");if(t.test(l))await D.promises.unlink(f.join(n,o))}}async needsRevalidation(t){let n=await this.get(t);if(!n)return!0;return Date.now()>n.revalidateAfter}}async function Ut(t){let n=[];if(!t.isDynamic)n.push({url:t.pattern,params:{}});else{let s=await gt(t.filePath);if(s.kind==="error")throw Error(`getStaticPaths ${s.phase} failed for ${t.pattern} (${t.filePath}): ${s.error.message}`,{cause:s.error});if(s.kind==="absent")return console.warn(`Warning: Dynamic route ${t.pattern} (${t.filePath}) has no getStaticPaths`),n;let o=s.value;if(o.paths.length===0)return console.info(`getStaticPaths returned no paths for dynamic route ${t.pattern} (${t.filePath})`),n;for(let l of o.paths){let e=t.pattern;for(let[u,g]of Object.entries(l.params))e=e.replace(`:${u}`,g).replace(`:${u}*`,g);n.push({url:e,params:l.params,props:l.props,revalidate:l.revalidate})}}return n}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 n of ft(t))if(await Bun.file(n).exists())try{let s=await import(n);if(typeof s.default==="function")return await s.default();else if(typeof s.default==="object")return s.default;else if(typeof s.getData==="function")return await s.getData();else{let{default:o,...l}=s;return l}}catch(s){console.error(`Error loading data file ${n}:`,s)}return null}async function Gt(t,n,s){let o=t.match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!o)return null;let l=o[1];if(!l.includes("getStaticProps"))return null;try{let e=l.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
7
  `)(n)}catch(e){return console.error(`Error executing getStaticProps in ${s}:`,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 mt(t,n,s={},o,l){let e=await Bun.file(t.filePath).text(),u=await Mt(t.filePath),g=await Gt(e,n,t.filePath),v={...u||{},...g||{},...s,params:n,$route:{path:t.pattern,params:n}},w=new Set,p=[],P=[],E={...l,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 S=await i(e,v,t.filePath,E,w);for(let R of[t.filePath,...w])for(let T of he(R))w.add(T);if(Object.keys(n).length>0){let R=`<script>if(window.stx)window.stx._rp=${JSON.stringify(n)};else window.__stx_rp=${JSON.stringify(n)};</script>`;if(S.includes("</head>"))S=S.replace("</head>",`${R}
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 S=await i(e,v,t.filePath,E,w);for(let R of[t.filePath,...w])for(let T of ye(R))w.add(T);if(Object.keys(n).length>0){let R=`<script>if(window.stx)window.stx._rp=${JSON.stringify(n)};else window.__stx_rp=${JSON.stringify(n)};</script>`;if(S.includes("</head>"))S=S.replace("</head>",`${R}
9
9
  </head>`);else S=`${R}
10
- ${S}`}if(S=await we(S,{router:o.router}),S=await b(S),o.minify!==!1)return{html:Ht(S),dependencies:Array.from(w),includeFailures:p,serverScriptFailures:P};return{html:S,dependencies:Array.from(w),includeFailures:p,serverScriptFailures:P}}function Ht(t){let n=[],s=0,o=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi,l;while((l=o.exec(t))!==null){let u=t.slice(s,l.index);n.push(u.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><"));let g=l[1],v=l[2],w=l[3];v=v.replace(/([^:"\\'`])\/\/(?!\/)(?![*!])([^\n]*)/g,"$1"),n.push(g+v+w),s=l.index+l[0].length}let e=t.slice(s);return n.push(e.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><")),n.join("").trim()}function zt(t){let n=0;for(let s=0;s<t.length;s++){let o=t.charCodeAt(s);n=(n<<5)-n+o,n=n&n}return`"${Math.abs(n).toString(36)}"`}function Wt(t,n,s,o){if(s?.sitemap===!1)return!0;if(/<meta[^>]+name=["']robots["'][^>]+content=["'][^"']*noindex/i.test(n))return!0;return o.some((l)=>{if(l instanceof RegExp)return l.test(t);return l.endsWith("/")?t===l.slice(0,-1)||t.startsWith(l):t===l})}function qt(t,n){return`<?xml version="1.0" encoding="UTF-8"?>
10
+ ${S}`}if(S=await ve(S,{router:o.router}),S=await b(S),o.minify!==!1)return{html:Ht(S),dependencies:Array.from(w),includeFailures:p,serverScriptFailures:P};return{html:S,dependencies:Array.from(w),includeFailures:p,serverScriptFailures:P}}function Ht(t){let n=[],s=0,o=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi,l;while((l=o.exec(t))!==null){let u=t.slice(s,l.index);n.push(u.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><"));let g=l[1],v=l[2],w=l[3];v=v.replace(/([^:"\\'`])\/\/(?!\/)(?![*!])([^\n]*)/g,"$1"),n.push(g+v+w),s=l.index+l[0].length}let e=t.slice(s);return n.push(e.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><")),n.join("").trim()}function zt(t){let n=0;for(let s=0;s<t.length;s++){let o=t.charCodeAt(s);n=(n<<5)-n+o,n=n&n}return`"${Math.abs(n).toString(36)}"`}function Wt(t,n,s,o){if(s?.sitemap===!1)return!0;if(/<meta[^>]+name=["']robots["'][^>]+content=["'][^"']*noindex/i.test(n))return!0;return o.some((l)=>{if(l instanceof RegExp)return l.test(t);return l.endsWith("/")?t===l.slice(0,-1)||t.startsWith(l):t===l})}function qt(t,n){return`<?xml version="1.0" encoding="UTF-8"?>
11
11
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
12
12
  ${t.map((o)=>{let l=new URL(o.loc,n).href,e=` <url>
13
13
  <loc>${F(l)}</loc>`;if(o.lastmod)e+=`
@@ -37,16 +37,16 @@ ${t.map((o)=>{let l=new URL(o.loc,n).href,e=` <url>
37
37
  ${s.join(`
38
38
  `)}
39
39
  </channel>
40
- </rss>`}async function Vt(t={}){let n=Date.now();tn();let s=await a(process.cwd()),o=s.build||{},l=await ut({explicit:t.domain||o.domain,stxConfig:s});if(l.source==="fallback"&&(t.sitemap??o.sitemap??!0))console.warn(dt());let e={router:t.router??s?.router??{},pagesDir:t.pagesDir||o.pagesDir||"pages",outputDir:t.outputDir||o.outputDir||"dist",baseUrl:t.baseUrl||o.baseUrl||"/",domain:l.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||c(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||s?.partialsDir||"",componentsDir:t.componentsDir||s?.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-fwk0gjbq.js");try{E=m(await d(process.cwd()))}catch{}}let{prepareImageDelivery:S}=await import("./chunk-s8b6re34.js"),R=await S(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-fwk0gjbq.js");await d('<div class="bg-black"></div>')}catch{}kt();let wt=s?.routeMiddleware?.dir||"middleware";await Ct(process.cwd(),wt);let J=_t();if(J.length>0)console.log(`Loaded ${J.length} middleware: ${J.join(", ")}`);let St=s?.routeMiddleware?.global||[];ec(s?.layoutsDir,c(process.cwd()));let Z=X(".",{pagesDir:e.pagesDir,pagesDirs:s?._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:G,props:xt,revalidate:rt}=m;try{await e.hooks.onPageStart?.(h);let A=await Bun.file(k.filePath).text(),O=Yt(A),bt=O?.middleware?Array.isArray(O.middleware)?O.middleware:[O.middleware]:[],nt=[...St,...bt];if(nt.length>0){let B=Et(h,G,O||{}),L=Tt(B,null,void 0,{isServer:!0}),j=await $t(nt,L);if(j.redirect){let C=typeof j.redirect==="string"?j.redirect:j.redirect.path||j.redirect,H=te(String(C),h),U=ee(h,e);await D.promises.mkdir(f.dirname(U),{recursive:!0}),await Bun.write(U,H),u.successCount++,u.pages.push({route:h,outputPath:U,size:Buffer.byteLength(H),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",`
40
+ </rss>`}async function Vt(t={}){let n=Date.now();nn();let s=await a(process.cwd()),o=s.build||{},l=await ut({explicit:t.domain||o.domain,stxConfig:s});if(l.source==="fallback"&&(t.sitemap??o.sitemap??!0))console.warn(dt());let e={router:t.router??s?.router??{},pagesDir:t.pagesDir||o.pagesDir||"pages",outputDir:t.outputDir||o.outputDir||"dist",baseUrl:t.baseUrl||o.baseUrl||"/",domain:l.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||c(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||s?.partialsDir||"",componentsDir:t.componentsDir||s?.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-yng848qe.js");try{E=m(await d(process.cwd()))}catch{}}let{prepareImageDelivery:S}=await import("./chunk-pj49gnc8.js"),R=await S(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-yng848qe.js");await d('<div class="bg-black"></div>')}catch{}_t();let wt=s?.routeMiddleware?.dir||"middleware";await Et(process.cwd(),wt);let V=Ct();if(V.length>0)console.log(`Loaded ${V.length} middleware: ${V.join(", ")}`);let yt=s?.routeMiddleware?.global||[];tc(s?.layoutsDir,c(process.cwd()));let Z=G(".",{pagesDir:e.pagesDir,pagesDirs:s?._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:St,revalidate:rt}=m;try{await e.hooks.onPageStart?.(h);let A=await Bun.file(k.filePath).text(),O=Yt(A),xt=O?.middleware?Array.isArray(O.middleware)?O.middleware:[O.middleware]:[],nt=[...yt,...xt];if(nt.length>0){let B=Tt(h,N,O||{}),L=$t(B,null,void 0,{isServer:!0}),j=await Rt(nt,L);if(j.redirect){let C=typeof j.redirect==="string"?j.redirect:j.redirect.path||j.redirect,z=Zt(String(C),h),U=te(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:G})){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 mt(k,G,xt,e,s);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 mt(k,N,St,e,s);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(h,k.filePath,B.dependencies,I)}let N;if(e.trailingSlash)N=f.join(e.outputDir,h,"index.html");else N=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 H=f.join(j,`${C.hash}.js`);if(!await Bun.file(H).exists())await Bun.write(H,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(N),{recursive:!0}),await Bun.write(N,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:N,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=en();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=tn();if(tt.length>0){let d=tt.map((m)=>`${m.filePath}: ${m.message}`).join(`
50
50
  `);throw Error(`Client script bundling failed:
51
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={...s,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">
@@ -69,7 +69,7 @@ ${d}`)}if(e.cache)await T.save();if(e.generate404){let d=f.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=f.join(e.pagesDir,`${d}.stx`);if(await Bun.file(m).exists()){let k=new Set,h={...s,minifyClient:!0,debug:!1,cache:!1},G=await i(await Bun.file(m).text(),{},m,h,k);await Bun.write(f.join(e.outputDir,`${d}.html`),G)}}let V=f.join(e.pagesDir,"error.stx");if(await Bun.file(V).exists()){let d=new Set,m={...s,minifyClient:!0,debug:!1,cache:!1},k=await i(await Bun.file(V).text(),{},V,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=Es({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=Jt(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 z=Za(e.outputDir);if(z.assets>0)console.log(`Externalized ${z.assets} asset(s) from ${z.pages} page(s) (${(z.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let W=Qa(e.outputDir);if(W.assets>0)console.log(`Externalized ${W.assets} repeated asset(s) from ${W.pages} page(s) (${(W.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=Zn();if(et)await Y(et,f.join(e.outputDir,Yn)),console.log(`Copied assets from ${Zt}`)}catch(E){throw await e.hooks.onError?.(E),E}if(u.buildTime=Date.now()-n,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?`
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={...s,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={...s,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=Es({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=Jt(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=Qa(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=ec(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=Qn();if(et)await Y(et,f.join(e.outputDir,Zn)),console.log(`Copied assets from ${Qt}`)}catch(E){throw await e.hooks.onError?.(E),E}if(u.buildTime=Date.now()-n,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,n){await D.promises.mkdir(n,{recursive:!0});let s=await D.promises.readdir(t,{withFileTypes:!0});for(let o of s){let l=f.join(t,o.name),e=f.join(n,o.name);if(o.isDirectory())await D.promises.mkdir(e,{recursive:!0}),await Y(l,e);else await D.promises.copyFile(l,e)}}function Kt(t={}){let n=t.cacheDir||c(process.cwd(),"ssg-cache"),s=new ht(n),o=t.revalidate||3600;return{async get(l){let e=await s.get(l);if(!e)return null;if(Date.now()>e.revalidateAfter)this.revalidate(l).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(l){let u=X(".",{pagesDir:t.pagesDir||"pages"}).find((P)=>l.match(P.regex)!==null);if(!u){console.warn(`Route not found for revalidation: ${l}`);return}let g=l.match(u.regex),v={};if(g)u.params.forEach((P,E)=>{v[P]=g[E+1]});let w=await a(),{html:p}=await mt(u,v,{},t,w);await s.set(l,{html:p,generatedAt:Date.now(),revalidateAfter:Date.now()+o*1000,etag:zt(p)}),console.log(`Revalidated: ${l}`)},async invalidate(l){if(typeof l==="string")await s.invalidate(l);else await s.invalidatePattern(l)}}}function Xt(){return{name:"markdown",extensions:[".md",".mdx"],async load(t){let n=await Bun.file(t).text(),s=n.match(/^---\n([\s\S]*?)\n---/),o={},l=n;if(s){let w=s[1];l=n.slice(s[0].length).trim();for(let p of w.split(`
81
- `)){let P=p.indexOf(":");if(P>0){let E=p.slice(0,P).trim(),S=p.slice(P+1).trim();if(S==="true")S=!0;else if(S==="false")S=!1;else if(/^\d+$/.test(S))S=parseInt(S,10);else if(/^\d+\.\d+$/.test(S))S=parseFloat(S);else if(S.startsWith("[")&&S.endsWith("]"))S=S.slice(1,-1).split(",").map((R)=>R.trim().replace(/^['"]|['"]$/g,""));o[E]=S}}}let e=l.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 Yt(t){return yt(t)}function te(t,n){return`<!DOCTYPE html>
80
+ `),u}async function Y(t,n){await D.promises.mkdir(n,{recursive:!0});let s=await D.promises.readdir(t,{withFileTypes:!0});for(let o of s){let l=f.join(t,o.name),e=f.join(n,o.name);if(o.isDirectory())await D.promises.mkdir(e,{recursive:!0}),await Y(l,e);else await D.promises.copyFile(l,e)}}function Kt(t={}){let n=t.cacheDir||c(process.cwd(),"ssg-cache"),s=new ht(n),o=t.revalidate||3600;return{async get(l){let e=await s.get(l);if(!e)return null;if(Date.now()>e.revalidateAfter)this.revalidate(l).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(l){let u=G(".",{pagesDir:t.pagesDir||"pages"}).find((P)=>l.match(P.regex)!==null);if(!u){console.warn(`Route not found for revalidation: ${l}`);return}let g=l.match(u.regex),v={};if(g)u.params.forEach((P,E)=>{v[P]=g[E+1]});let w=await a(),{html:p}=await mt(u,v,{},t,w);await s.set(l,{html:p,generatedAt:Date.now(),revalidateAfter:Date.now()+o*1000,etag:zt(p)}),console.log(`Revalidated: ${l}`)},async invalidate(l){if(typeof l==="string")await s.invalidate(l);else await s.invalidatePattern(l)}}}function Xt(){return{name:"markdown",extensions:[".md",".mdx"],async load(t){let n=await Bun.file(t).text(),s=n.match(/^---\n([\s\S]*?)\n---/),o={},l=n;if(s){let w=s[1];l=n.slice(s[0].length).trim();for(let p of w.split(`
81
+ `)){let P=p.indexOf(":");if(P>0){let E=p.slice(0,P).trim(),S=p.slice(P+1).trim();if(S==="true")S=!0;else if(S==="false")S=!1;else if(/^\d+$/.test(S))S=parseInt(S,10);else if(/^\d+\.\d+$/.test(S))S=parseFloat(S);else if(S.startsWith("[")&&S.endsWith("]"))S=S.slice(1,-1).split(",").map((R)=>R.trim().replace(/^['"]|['"]$/g,""));o[E]=S}}}let e=l.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 Yt(t){return bt(t)}function Zt(t,n){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 ee(t,n){if(t==="/"||t==="")return f.join(n.outputDir,"index.html");let s=t.replace(/^\/|\/$/g,"");if(n.trailingSlash)return f.join(n.outputDir,s,"index.html");return f.join(n.outputDir,`${s}.html`)}var Te={generateStaticSite:Vt,createISRHandler:Kt,defineStaticPaths:q,createMarkdownLoader:Xt};export{Kt as createISRHandler,Xt as createMarkdownLoader,Nt as declaresPageAction,Te as default,q as defineStaticPaths,Vt as generateStaticSite,Wt as isExcludedFromSitemap};
93
+ </html>`}function te(t,n){if(t==="/"||t==="")return f.join(n.outputDir,"index.html");let s=t.replace(/^\/|\/$/g,"");if(n.trailingSlash)return f.join(n.outputDir,s,"index.html");return f.join(n.outputDir,`${s}.html`)}var Fe={generateStaticSite:Vt,createISRHandler:Kt,defineStaticPaths:J,createMarkdownLoader:Xt};export{Kt as createISRHandler,Xt as createMarkdownLoader,Nt as declaresPageAction,Fe as default,J as defineStaticPaths,Vt 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.826",
4
+ "version": "0.2.830",
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.21",
130
130
  "@stacksjs/clapp": "^0.2.16",
131
- "@stacksjs/desktop": "0.2.826",
132
- "@stacksjs/sanitizer": "0.2.826",
131
+ "@stacksjs/desktop": "0.2.830",
132
+ "@stacksjs/sanitizer": "0.2.830",
133
133
  "@stacksjs/ts-i18n": "^0.1.11",
134
- "bun-plugin-stx": "0.2.826",
134
+ "bun-plugin-stx": "0.2.830",
135
135
  "bunfig": "^0.15.21",
136
- "stx-router": "0.2.826",
136
+ "stx-router": "0.2.830",
137
137
  "ts-broadcasting": "^0.0.11",
138
138
  "ts-images": "^0.2.22",
139
139
  "ts-syntax-highlighter": "^0.2.1"
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{So,va,xa,bh}from"./chunk-6qvn1h09.js";export{So as NATIVE_COMPONENTS,va as compileToNative,xa as createHotReloadServer,bh as default};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{er,$e}from"./chunk-7sh9fa3q.js";export{er as describeBuildFailure,$e as formatBuildFailure};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{ia,Qg,aa,em,jl,Bl,tm,nm}from"./chunk-b64y3yh0.js";import"./chunk-h864en4b.js";import"./chunk-9kj5p5jq.js";import"./chunk-bwsz6sv4.js";import"./chunk-7sh9fa3q.js";import"./chunk-f05tmz4z.js";import"./chunk-d9yjpdyn.js";import"./chunk-2nj9aewf.js";import"./chunk-rptnx3s6.js";import"./chunk-1d67wtj4.js";import"./chunk-k81trehg.js";import"./chunk-wf0n9gpj.js";import"./chunk-xpy9yjyx.js";import"./chunk-qj4r08jb.js";import{Pt,Zf}from"./chunk-928y0wer.js";import"./chunk-e648sx8w.js";import"./chunk-2vqpz4qv.js";import"./chunk-8ttmzcxb.js";import"./chunk-r9e0r6jx.js";import"./chunk-bt0amey5.js";export{ia as buildScriptVirtualFile,Qg as buildVirtualSource,Pt as extractScriptBlocks,Zf as extractTemplateExpressions,jl as findRuntimeTypeDeclarations,Bl as findStxModuleDeclarations,nm as formatTypecheckDiagnostics,em as sourcePathFor,tm as typecheckStxFiles,aa as virtualPathFor};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{xe,hi,yi,ig,Nt,Xc,ag,Gc,Gh,De,yn,Le}from"./chunk-928y0wer.js";import{nl,r}from"./chunk-b4x5ndt9.js";import"./chunk-e648sx8w.js";import"./chunk-2vqpz4qv.js";import"./chunk-8ttmzcxb.js";import"./chunk-r9e0r6jx.js";import"./chunk-bt0amey5.js";export{xe as BROWSER_CORE_IMPORTS,ig as STX_AUTO_IMPORTS,hi as extractAndStripCssImports,De as extractBridgeData,nl as findInterpolationEnd,Gc as generateAutoImportDestructuring,Gh as generateBrowserAutoImportDestructuring,yn as generateServerDataBridge,Nt as injectBrowserCoreAutoImports,Le as processClientScript,ag as referencesName,yi as renderVendorStyleTags,r as stripCommentsAndLiterals,Xc as transformAutoImports};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Lr,so,Fg,El,oo}from"./chunk-x6863pzd.js";export{Fg as buildModuleRegistryScript,oo as buildSharedModuleRegistries,El as exportsMutableBinding,Lr as registeredModuleIdsIn,so as registeredModuleNamesIn};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{U}from"./chunk-928y0wer.js";function n(t){return U(t)}
3
- export{n};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Nf,us}from"./chunk-8qy616yt.js";import"./chunk-2v3r330m.js";import"./chunk-wceg59n0.js";import"./chunk-2nj9aewf.js";import{kr}from"./chunk-928y0wer.js";import"./chunk-e648sx8w.js";import"./chunk-2vqpz4qv.js";import{st}from"./chunk-8ttmzcxb.js";import"./chunk-r9e0r6jx.js";import"./chunk-bt0amey5.js";export{st as freeIdentifiers,us as processComponents,Nf as processESImports,kr as rendersAsElement};
@@ -1,43 +0,0 @@
1
- // @bun
2
- import{Q,ee,te,Nn,me,Te,gt,Xt,Mn,Dn,Ln,ne,jn,Bn}from"./chunk-akj26p4b.js";import{xt}from"./chunk-mv3yhspn.js";function Al(s,r={}){let{src:e,alt:t,width:n,height:a,sizes:i="100vw",loading:m="lazy",priority:o=!1,quality:u=te,placeholder:l="none",formats:f=ee,widths:y=Q,decoding:c="async",fetchpriority:h,objectFit:d,objectPosition:g}=s,{class:p,style:v}=s,{processedImage:w,variants:I,optimize:b=!0,isDev:A=!1}=r;if(I&&I.length>0)return K(s,I,w);if(A||!b)return Z(s);return G(s)}function K(s,r,e){let{src:t,alt:n,width:a,height:i,sizes:m="100vw",loading:o="lazy",priority:u=!1,decoding:l="async",fetchpriority:f,objectFit:y,objectPosition:c,placeholder:h="none"}=s,{class:d,style:g}=s,p=Dn(r),v=Mn(r),w=typeof m==="object"?Xt(m):m,I=e?e.aspectRatio:a&&i?Number(a)/Number(i):void 0,b=[];if(I)b.push(`aspect-ratio: ${I}`);if(y)b.push(`object-fit: ${y}`);if(c)b.push(`object-position: ${c}`);if(g)b.push(g);let A=b.length>0?` style="${b.join("; ")}"`:"",S=d?` class="${d}"`:"",F=u?"":` loading="${o}"`,R=` decoding="${l}"`,C=f?` fetchpriority="${f}"`:u?' fetchpriority="high"':"",E=["avif","webp","jpeg","png"],M=[];for(let k of E){let z=p.get(k);if(z&&z.length>0){let O=gt(z),J=ne(k);M.push(` <source type="${J}" srcset="${O}" sizes="${w}" />`)}}let U="",L="",T;if(h!=="none"&&e?.placeholder){let k=`img-${Math.random().toString(36).slice(2,8)}`;if(U=`<div class="stx-image-wrapper" id="${k}">`,L="</div>",h==="blur")T=`
3
- #${k} {
4
- position: relative;
5
- background-image: url('${e.placeholder}');
6
- background-size: cover;
7
- background-position: center;
8
- }
9
- #${k} img {
10
- transition: opacity 0.3s ease;
11
- }
12
- #${k}.loaded img {
13
- opacity: 1;
14
- }
15
- `.trim();else if(h==="color")T=`
16
- #${k} {
17
- background-color: ${e.placeholder};
18
- }
19
- `.trim()}let _=a?` width="${a}"`:e?` width="${e.width}"`:"",H=i?` height="${i}"`:e?` height="${e.height}"`:"",Y=`${U}<picture>
20
- ${M.join(`
21
- `)}
22
- <img
23
- src="${v?.url||t}"
24
- alt="${B(n)}"${_}${H}${S}${A}${F}${R}${C}
25
- />
26
- </picture>${L}`,V;if(u&&v){let k=p.get("webp"),z=k?.[Math.floor(k.length/2)]||v,O=ne(z.format);V=`<link rel="preload" as="image" href="${z.url}" type="${O}" />`}return{html:Y,preloadLink:V,placeholderCss:T}}function Z(s){let{src:r,alt:e,width:t,height:n,loading:a="lazy",decoding:i="async",priority:m=!1,fetchpriority:o,objectFit:u,objectPosition:l}=s,{class:f,style:y}=s,c=[];if(u)c.push(`object-fit: ${u}`);if(l)c.push(`object-position: ${l}`);if(y)c.push(y);let h=c.length>0?` style="${c.join("; ")}"`:"",d=f?` class="${f}"`:"",g=t?` width="${t}"`:"",p=n?` height="${n}"`:"",v=m?"":` loading="${a}"`,w=` decoding="${i}"`,I=o?` fetchpriority="${o}"`:m?' fetchpriority="high"':"";return{html:`<img src="${r}" alt="${B(e)}"${g}${p}${d}${h}${v}${w}${I} />`}}function G(s){let{src:r,alt:e,width:t,height:n,sizes:a="100vw",loading:i="lazy",priority:m=!1,quality:o=te,formats:u=ee,widths:l=Q,decoding:f="async",fetchpriority:y,objectFit:c,objectPosition:h}=s,{class:d,style:g}=s,p=[];if(c)p.push(`object-fit: ${c}`);if(h)p.push(`object-position: ${h}`);if(g)p.push(g);let v=p.length>0?` style="${p.join("; ")}"`:"",w=d?` class="${d}"`:"",I=t?` width="${t}"`:"",b=n?` height="${n}"`:"",A=m?"":` loading="${i}"`,S=` decoding="${f}"`,F=y?` fetchpriority="${y}"`:m?' fetchpriority="high"':"",R=typeof a==="object"?Xt(a):a,C=`
27
- data-stx-image
28
- data-src="${r}"
29
- data-sizes="${R}"
30
- data-quality="${o}"
31
- data-formats="${u.join(",")}"
32
- data-widths="${l.join(",")}"
33
- `.replace(/\s+/g," ").trim();return{html:`<img src="${r}" alt="${B(e)}"${I}${b}${w}${v}${A}${S}${F} ${C} />`}}function ra(s){let r=s.match(/<Image\s+([^>]*?)\/?>/);if(!r)return null;let e=r[1],t={},n=/(\w+)(?:=(?:"([^"]*)"|'([^']*)'|(\{[^}]+\})))?/g,a;while((a=n.exec(e))!==null){let[,i,m,o,u]=a,l=m??o??u??!0;switch(i){case"src":t.src=String(l);break;case"alt":t.alt=String(l);break;case"width":t.width=Number(l)||l;break;case"height":t.height=Number(l)||l;break;case"sizes":t.sizes=String(l);break;case"loading":t.loading=l;break;case"priority":t.priority=l===!0||l==="true";break;case"quality":t.quality=Number(l);break;case"placeholder":t.placeholder=l;break;case"class":t.class=String(l);break;case"style":t.style=String(l);break;case"decoding":t.decoding=l;break;case"fetchpriority":t.fetchpriority=l;break;case"objectFit":t.objectFit=l;break;case"objectPosition":t.objectPosition=String(l);break}}if(!t.src||!t.alt)return null;return t}async function Pl(s,r){let e=/<Image\s+[^>]*?\/?>/g,t=[],n=[],a=s,i,m=[];while((i=e.exec(s))!==null)m.push({match:i[0],index:i.index});for(let o=m.length-1;o>=0;o--){let{match:u}=m[o],l=ra(u);if(l){let f=await r(l);if(a=a.replace(u,f.html),f.preloadLink)t.push(f.preloadLink);if(f.placeholderCss)n.push(f.placeholderCss)}}return{html:a,preloadLinks:t,styles:n}}function B(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}var D=new Map;function Il(){D.clear()}async function X(s,r){let e=`${s}:${JSON.stringify(r)}`;if(D.has(e))return D.get(e);try{let t=await Te(s,r);return D.set(e,t),t}catch{return null}}function sa(){return xt({name:"image",hasEndTag:!1,description:"Render an optimized image with responsive variants",transform:async(s,r,e)=>{let{src:t,alt:n,options:a}=se(s,r,e);if(!t)return console.warn("@image directive: missing src argument"),"<!-- @image: missing src -->";let i={widths:a.widths||(a.width?[a.width]:Q),formats:a.formats||ee,quality:a.quality||te,placeholder:(a.placeholder==="color"?"dominant-color":a.placeholder)||"none"};if(!await me())return q(t,n||"",a);let o=await X(t,i);if(!o)return q(t,n||"",a);return ae(o,n||"",a)}})}function se(s,r,e){if(r.src)return{src:String(r.src),alt:String(r.alt||""),options:r.options||{}};let n=s.trim();if(n.startsWith("@image(")||n.startsWith("("))n=n.replace(/^@image\(/,"").replace(/^\(/,"").replace(/\)$/,"");let a=re(n),i=a[0]||"",m=a[1]||"",o={};if(i&&!i.startsWith("/")&&!i.startsWith(".")&&!i.startsWith("http")){let u=e[i];if(typeof u==="string")i=u}if(a[2])try{if(typeof a[2]==="string")o=JSON.parse(a[2]);else o=a[2]}catch{}return{src:i,alt:m,options:o}}function re(s){let r=[],e="",t=!1,n="",a=0,i=0;for(let m=0;m<s.length;m++){let o=s[m],u=m>0?s[m-1]:"";if((o==='"'||o==="'")&&u!=="\\"){if(!t)t=!0,n=o;else if(o===n)t=!1,n="";else e+=o;continue}if(!t){if(o==="{")a++;if(o==="}")a--;if(o==="[")i++;if(o==="]")i--;if(o===","&&a===0&&i===0){r.push(e.trim()),e="";continue}}e+=o}if(e.trim())r.push(e.trim());return r}function q(s,r,e){let t=[`src="${x(s)}"`];if(r)t.push(`alt="${x(r)}"`);if(e.width)t.push(`width="${e.width}"`);if(e.height)t.push(`height="${e.height}"`);if(e.class)t.push(`class="${x(e.class)}"`);if(e.style)t.push(`style="${x(e.style)}"`);if(e.lazy!==!1)t.push('loading="lazy"');return t.push('decoding="async"'),`<img ${t.join(" ")} />`}function ae(s,r,e){let{variants:t,placeholder:n,width:a,height:i,aspectRatio:m}=s,o=new Map;for(let g of t){let p=o.get(g.format)||[];p.push(g),o.set(g.format,p)}let u=["avif","webp","jpeg","png"],l=[];for(let g of u){let p=o.get(g);if(p&&p.length>0){let v=gt(p),w=ne(g),I=e.sizes||"100vw";l.push(` <source type="${w}" srcset="${x(v)}" sizes="${x(I)}" />`)}}let f=o.get("jpeg")||[],y=f.length>0?f[Math.floor(f.length/2)]:t[Math.floor(t.length/2)],c=[`src="${y?.url||s.src}"`,`alt="${x(r)}"`];if(e.width||a)c.push(`width="${e.width||a}"`);if(e.height||i)c.push(`height="${e.height||i}"`);if(e.class)c.push(`class="${x(e.class)}"`);let h=[];if(m)h.push(`aspect-ratio: ${m.toFixed(4)}`);if(e.style)h.push(e.style);if(h.length>0)c.push(`style="${h.join("; ")}"`);if(e.lazy!==!1&&!e.priority)c.push('loading="lazy"');if(c.push('decoding="async"'),e.priority)c.push('fetchpriority="high"');let d=`<picture>
34
- `;if(d+=l.join(`
35
- `)+`
36
- `,d+=` <img ${c.join(" ")} />
37
- `,d+="</picture>",e.placeholder&&n){let g=`stx-img-${Math.random().toString(36).slice(2,8)}`;if(e.placeholder==="blur"||e.placeholder==="thumbhash"){let p=n.replace(/'/g,"%27").replace(/"/g,"%22");d=`<div id="${g}" class="stx-image-placeholder" style="background-image: url('${p}'); background-size: cover;">
38
- ${d}
39
- </div>`}else if(e.placeholder==="color"){let p=n.replace(/[^a-zA-Z0-9#(),.\s%-]/g,"");d=`<div id="${g}" class="stx-image-placeholder" style="background-color: ${p};">
40
- ${d}
41
- </div>`}}if(e.priority&&y){let g=ne(y.format);d=`<link rel="preload" as="image" href="${x(y.url)}" type="${g}" />
42
- `+d}return d}function x(s){return s.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var Ol=sa();import P from"fs";import j from"path";function Nl(s={}){let{inputDirs:r=["public","src/assets","assets"],outputDir:e="dist/images",baseUrl:t="/images",formats:n=ee,widths:a=Q,quality:i=te,placeholder:m="none",concurrency:o=4,cache:u=!0,cacheDir:l=".stx/image-cache",referencedOnly:f=!1,verbose:y=!1}=s,c={imageReferences:new Set,processedImages:new Map,stats:{totalImages:0,optimizedImages:0,savedBytes:0,variants:0}};return{name:"stx-image-optimization",async setup(h){if(!await me()){console.warn("[stx-images] no image backend available, optimization disabled");return}if(u)await P.promises.mkdir(l,{recursive:!0});if(y){let g=await Nn();console.log("[stx-images] Plugin initialized"),console.log(` Backend: ${g?"sharp (native fast path) + ts-images":"ts-images (pure TS)"}`),console.log(` Input dirs: ${r.join(", ")}`),console.log(` Output dir: ${e}`),console.log(` Formats: ${n.join(", ")}`),console.log(` Widths: ${a.join(", ")}`)}},async buildStart(){c.imageReferences.clear(),c.processedImages.clear(),c.stats={totalImages:0,optimizedImages:0,savedBytes:0,variants:0}},async transform(h,d){if(d.endsWith(".html")||d.endsWith(".stx")){let g=ie(h);for(let p of g)c.imageReferences.add(p)}if(h.includes("<Image")||h.includes("@image"))return await ce(h,{formats:n,widths:a,quality:i,placeholder:m,outputDir:e,baseUrl:t,processedImages:c.processedImages});return h},async buildEnd(h){if(!await me())return;await P.promises.mkdir(e,{recursive:!0});let g=[];for(let w of r){if(!P.existsSync(w))continue;let I=await N(w);g.push(...I)}let p=f?g.filter((w)=>oe(w,c.imageReferences)):g;if(c.stats.totalImages=p.length,y)console.log(`[stx-images] Processing ${p.length} images...`);let v=W(p,o);for(let w of v)await Promise.all(w.map(async(I)=>{try{let b=await Te(I,{formats:n,widths:a,quality:i,placeholder:m,outputDir:e,baseUrl:t});c.processedImages.set(I,b),c.stats.optimizedImages++,c.stats.variants+=b.variants.length;let A=P.statSync(I).size,S=jn(b.variants);if(c.stats.savedBytes+=Math.max(0,A-S/b.variants.length),y)console.log(` \u2713 ${j.basename(I)} \u2192 ${b.variants.length} variants`)}catch(b){console.error(`[stx-images] Error processing ${I}:`,b)}}));if(console.log("[stx-images] Optimization complete:"),console.log(` Images: ${c.stats.optimizedImages}/${c.stats.totalImages}`),console.log(` Variants: ${c.stats.variants}`),c.stats.savedBytes>0)console.log(` Saved: ~${Bn(c.stats.savedBytes)}`)}}}function ie(s){let r=[],e=/src=["']([^"']+\.(jpg|jpeg|png|webp|avif|gif))["']/gi,t;while((t=e.exec(s))!==null)r.push(t[1]);let n=/<Image[^>]+src=["']([^"']+)["']/gi;while((t=n.exec(s))!==null)r.push(t[1]);let a=/@image\s*\(\s*['"]([^'"]+)['"]/gi;while((t=a.exec(s))!==null)r.push(t[1]);let i=/background(?:-image)?:\s*url\(["']?([^"')]+\.(jpg|jpeg|png|webp|avif|gif))["']?\)/gi;while((t=i.exec(s))!==null)r.push(t[1]);return r}function oe(s,r){let e=j.basename(s);for(let t of r)if(t.endsWith(e)||t.includes(e))return!0;return!1}async function ce(s,r){return s}async function N(s){let r=[];async function e(t){let n=await P.promises.readdir(t,{withFileTypes:!0});for(let a of n){let i=j.join(t,a.name);if(a.isDirectory())await e(i);else if(a.isFile()&&Ln(i))r.push(i)}}return await e(s),r}function W(s,r){let e=[];for(let t=0;t<s.length;t+=r)e.push(s.slice(t,t+r));return e}async function Ml(s,r,e={}){if(!await me())throw Error("No image backend available \u2014 install sharp or ensure ts-images is bundled");return Te(s,{...e,outputDir:r})}async function Dl(s,r,e={}){let{formats:t=ee,widths:n=Q,quality:a=te,placeholder:i="none",concurrency:m=4,verbose:o=!1}=e;if(!await me())throw Error("No image backend available \u2014 install sharp or ensure ts-images is bundled");await P.promises.mkdir(r,{recursive:!0});let l=await N(s),f=[],y={totalImages:l.length,optimizedImages:0,savedBytes:0,variants:0},c=W(l,m);for(let h of c){let d=await Promise.all(h.map(async(g)=>{try{let p=await Te(g,{formats:t,widths:n,quality:a,placeholder:i,outputDir:r,baseUrl:"/"});if(y.optimizedImages++,y.variants+=p.variants.length,o)console.log(` \u2713 ${j.basename(g)}`);return p}catch(p){return console.error(`Error processing ${g}:`,p),null}}));f.push(...d.filter((g)=>g!==null))}return{processed:f,stats:y}}function oa(s){let r={};for(let e of s)r[e.src]={variants:e.variants,placeholder:e.placeholder};return r}async function Ll(s,r){let e=oa(s);await Bun.write(r,JSON.stringify(e,null,2))}var Zg={enabled:!0,widths:[320,640,768,1024,1280,1536,1920],formats:["webp","jpeg"],quality:80,devOptimize:!1,cacheDir:".stx/image-cache",placeholder:"none",inputDirs:["public","src/assets","assets"],outputDir:"dist/images",baseUrl:"/images"};
43
- export{Al,ra,Pl,Il,sa,Ol,Nl,Ml,Dl,oa,Ll,Zg};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{ma,mm}from"./chunk-67kbsav0.js";export{ma as definePlugin,mm as pluginManager};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{vn,xi}from"./chunk-e648sx8w.js";import"./chunk-2vqpz4qv.js";export{xi as generateRuntimeConfigTypes,vn as prepareRuntimeConfig};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{jf,Mh,Dh,Lh,jh,Bf,Ff,Bh,Fh,Xo,zh,lr,ur,ws}from"./chunk-8p86mpfv.js";import{nt}from"./chunk-5emrarpf.js";import"./chunk-928y0wer.js";import"./chunk-e648sx8w.js";import"./chunk-2vqpz4qv.js";import"./chunk-8ttmzcxb.js";import"./chunk-r9e0r6jx.js";import"./chunk-bt0amey5.js";export{jh as __setSignalsGeneratorsForTest,nt as cacheEngineFingerprint,ur as cacheTemplate,lr as checkCache,zh as clearDevCaches,Ff as getCachedRouterScript,Bf as getCachedSignalsRuntime,Bh as getServeClientAsset,Xo as getServeModuleBundle,ws as hashFilePath,Dh as invalidateFileCache,Lh as invalidateFileCacheByDir,Mh as readFileCached,Fh as registerServeModuleBundle,jf as templateCache};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Kg}from"./chunk-q45xwvf6.js";import"./chunk-vwtejkb5.js";import"./chunk-y2bf32vg.js";import"./chunk-tjhcrj3z.js";import"./chunk-c84pxd2k.js";import"./chunk-8qy616yt.js";import"./chunk-2v3r330m.js";import"./chunk-gnt36wgk.js";import"./chunk-wceg59n0.js";import"./chunk-f05tmz4z.js";import"./chunk-d9yjpdyn.js";import"./chunk-2nj9aewf.js";import"./chunk-8p86mpfv.js";import"./chunk-rptnx3s6.js";import"./chunk-1d67wtj4.js";import"./chunk-k81trehg.js";import"./chunk-wf0n9gpj.js";import"./chunk-xpy9yjyx.js";import"./chunk-qj4r08jb.js";import"./chunk-928y0wer.js";import"./chunk-e648sx8w.js";import"./chunk-2vqpz4qv.js";import"./chunk-8ttmzcxb.js";import"./chunk-r9e0r6jx.js";import"./chunk-bt0amey5.js";export{Kg as startInteractive};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{ql}from"./chunk-mwxbdpb1.js";export{ql as rewriteImagesWithSiblings};