@stacksjs/stx 0.2.855 → 0.2.858

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 (226) hide show
  1. package/dist/chunk-0ts3p84y.js +2 -0
  2. package/dist/{chunk-zme05d1n.js → chunk-0vptj943.js} +2 -2
  3. package/dist/{chunk-0dmpc70r.js → chunk-0z2gqttt.js} +16 -16
  4. package/dist/{chunk-1qybwj8k.js → chunk-1347hwt5.js} +15 -15
  5. package/dist/chunk-139mxsyc.js +2 -0
  6. package/dist/chunk-1barsha6.js +2 -0
  7. package/dist/chunk-1fnx7ze9.js +2 -0
  8. package/dist/chunk-1g06wfs9.js +2 -0
  9. package/dist/{chunk-w032x0zm.js → chunk-1nankvf6.js} +2 -2
  10. package/dist/chunk-1nasq00e.js +2 -0
  11. package/dist/{chunk-csgfws3j.js → chunk-1z2am28h.js} +2 -2
  12. package/dist/chunk-2102tvxh.js +2 -0
  13. package/dist/{chunk-yzvp90yk.js → chunk-252enthj.js} +2 -2
  14. package/dist/{chunk-2j2qzv8g.js → chunk-27zp4q77.js} +2 -2
  15. package/dist/{chunk-77kanny8.js → chunk-2bks42z4.js} +9 -9
  16. package/dist/chunk-39cwa35j.js +2 -0
  17. package/dist/{chunk-fj5jw2jd.js → chunk-3b7q7d7j.js} +6 -6
  18. package/dist/{chunk-9z7fnv33.js → chunk-3evwxrpx.js} +1 -1
  19. package/dist/chunk-3rcegvgg.js +2 -0
  20. package/dist/chunk-3wvq28hz.js +2 -0
  21. package/dist/{chunk-68pvvd7v.js → chunk-3zjyhhg4.js} +3 -3
  22. package/dist/{chunk-mhjxx64x.js → chunk-4ezfen91.js} +25 -25
  23. package/dist/{chunk-a2fngjfx.js → chunk-4h9kkkh7.js} +1 -1
  24. package/dist/{chunk-gxqtbbz0.js → chunk-5xy1z71a.js} +5 -5
  25. package/dist/{chunk-63rvsnt2.js → chunk-69zj9q02.js} +3 -3
  26. package/dist/chunk-6d74qdc6.js +2 -0
  27. package/dist/chunk-6m4v1tsq.js +2 -0
  28. package/dist/{chunk-9hvfmqs1.js → chunk-6qbha6fb.js} +9 -9
  29. package/dist/{chunk-q0jmc3m4.js → chunk-71s4hpkj.js} +9 -9
  30. package/dist/chunk-75e4wzzs.js +3 -0
  31. package/dist/{chunk-11y3106w.js → chunk-78amng8s.js} +5 -5
  32. package/dist/chunk-7ambc4f7.js +2 -0
  33. package/dist/{chunk-ngnvyqk3.js → chunk-7fgfzaah.js} +2 -2
  34. package/dist/{chunk-4wrddn8m.js → chunk-8623gte8.js} +9 -9
  35. package/dist/{chunk-mpmnbvy4.js → chunk-8cpqcn19.js} +5 -5
  36. package/dist/chunk-8nmc3rh7.js +2 -0
  37. package/dist/chunk-8pn7ah12.js +2 -0
  38. package/dist/chunk-8zwwmnpb.js +2 -0
  39. package/dist/chunk-98bgx3ws.js +2 -0
  40. package/dist/{chunk-car6nhfe.js → chunk-9n8t7v78.js} +2 -2
  41. package/dist/chunk-a4v8z93r.js +2 -0
  42. package/dist/chunk-a58w524e.js +2 -0
  43. package/dist/chunk-a6v6x2pg.js +2 -0
  44. package/dist/{chunk-krtkxnz6.js → chunk-admnvsmx.js} +2 -2
  45. package/dist/{chunk-hgy98n76.js → chunk-afrqm7w5.js} +4 -4
  46. package/dist/{chunk-t3a3wbjk.js → chunk-az9b4bj4.js} +2 -2
  47. package/dist/chunk-b62mr2kz.js +2 -0
  48. package/dist/chunk-b7vxb2y6.js +2 -0
  49. package/dist/chunk-bb20hnqd.js +2 -0
  50. package/dist/chunk-bc3sknxf.js +2 -0
  51. package/dist/{chunk-fphnst8a.js → chunk-bef0wr53.js} +5 -5
  52. package/dist/{chunk-cy60hmv2.js → chunk-bhzh7mj1.js} +1 -1
  53. package/dist/{chunk-jn6mdfrs.js → chunk-bxn4b0wm.js} +2 -2
  54. package/dist/{chunk-yscys65t.js → chunk-c7eew8qs.js} +1 -1
  55. package/dist/chunk-cbrbrkp1.js +2 -0
  56. package/dist/{chunk-fba71th7.js → chunk-cqkr291c.js} +7 -7
  57. package/dist/{chunk-mmdqdkbd.js → chunk-d6am6en8.js} +1 -1
  58. package/dist/chunk-d8djpp7f.js +2 -0
  59. package/dist/chunk-dk6t4h48.js +2 -0
  60. package/dist/chunk-dkbm7117.js +2 -0
  61. package/dist/chunk-e44bse67.js +2 -0
  62. package/dist/{chunk-kvafq9gy.js → chunk-e763qsg0.js} +2 -2
  63. package/dist/{chunk-pm241ehv.js → chunk-e7thwrt5.js} +2 -2
  64. package/dist/{chunk-wzv7k91a.js → chunk-e8we717q.js} +2 -2
  65. package/dist/{chunk-q0ycypnt.js → chunk-eazccp6e.js} +2 -2
  66. package/dist/{chunk-zqb294v2.js → chunk-egwtv5hp.js} +3 -3
  67. package/dist/chunk-ewnfgczq.js +2 -0
  68. package/dist/chunk-f1v5hvbt.js +2 -0
  69. package/dist/{chunk-anva219c.js → chunk-f1vvhbmw.js} +2 -2
  70. package/dist/{chunk-pwem4sed.js → chunk-fbnykfnv.js} +4 -4
  71. package/dist/{chunk-0vg0j7xa.js → chunk-fd7e162p.js} +3 -3
  72. package/dist/{chunk-fhrvxfq9.js → chunk-ff3j7jnf.js} +2 -2
  73. package/dist/{chunk-j2wcawmf.js → chunk-fw50vydb.js} +2 -2
  74. package/dist/{chunk-te82sjhy.js → chunk-fxk1psd8.js} +31 -31
  75. package/dist/chunk-g6epqcb3.js +2 -0
  76. package/dist/{chunk-9n3584wt.js → chunk-g8d24rfk.js} +2 -2
  77. package/dist/{chunk-ya6f7mt5.js → chunk-gjbnzn7k.js} +4 -4
  78. package/dist/chunk-gmvypdm8.js +2 -0
  79. package/dist/{chunk-4dfz7cdr.js → chunk-gz0j98dy.js} +5 -5
  80. package/dist/{chunk-csksn1kg.js → chunk-hjh5wt5f.js} +2 -2
  81. package/dist/chunk-hmgry6dn.js +2 -0
  82. package/dist/{chunk-s37af6rd.js → chunk-jafn7f7f.js} +2 -2
  83. package/dist/chunk-jbv1srnh.js +2 -0
  84. package/dist/{chunk-mv48q1p4.js → chunk-jdqmk5sv.js} +75 -75
  85. package/dist/{chunk-d4gy4yz0.js → chunk-jgvwzt1t.js} +2 -2
  86. package/dist/chunk-jhm1228j.js +4 -0
  87. package/dist/{chunk-k0arm18k.js → chunk-jtag68hg.js} +2 -2
  88. package/dist/chunk-jwtp4csj.js +20 -0
  89. package/dist/{chunk-9r999ees.js → chunk-jwwsxym6.js} +2 -2
  90. package/dist/chunk-jzynkjfc.js +2 -0
  91. package/dist/{chunk-n77xrpv9.js → chunk-k19ba3jz.js} +2 -2
  92. package/dist/chunk-k1qajhpx.js +2 -0
  93. package/dist/{chunk-tm8a2b69.js → chunk-kedgfk9z.js} +4 -4
  94. package/dist/{chunk-f9thwm8c.js → chunk-kq3h2rjq.js} +9 -9
  95. package/dist/chunk-ksxbfyef.js +3 -0
  96. package/dist/chunk-m28j4ym7.js +2 -0
  97. package/dist/{chunk-4nhbbcr9.js → chunk-m2rm2gxv.js} +5 -5
  98. package/dist/{chunk-v8p8t3t4.js → chunk-me16tftr.js} +1 -1
  99. package/dist/{chunk-bkefg64w.js → chunk-mh45hcsa.js} +5 -5
  100. package/dist/{chunk-279n7sde.js → chunk-mxazxwc4.js} +4 -4
  101. package/dist/chunk-mzembfxk.js +2 -0
  102. package/dist/{chunk-hpwtjb4a.js → chunk-mzes9ds7.js} +2 -2
  103. package/dist/{chunk-ynd2nfvs.js → chunk-mzg1wq86.js} +27 -27
  104. package/dist/chunk-ngzjwp2e.js +2 -0
  105. package/dist/chunk-nj9n0en9.js +2 -0
  106. package/dist/{chunk-w835crjw.js → chunk-nv5xhfwz.js} +2 -2
  107. package/dist/chunk-nyasqjnt.js +2 -0
  108. package/dist/{chunk-vw73gsxx.js → chunk-pa8xkctc.js} +7 -7
  109. package/dist/{chunk-ybq56wam.js → chunk-pb09xy77.js} +2 -2
  110. package/dist/chunk-pn0rmd8d.js +2 -0
  111. package/dist/chunk-pvx1hrqq.js +2 -0
  112. package/dist/chunk-q78dsejp.js +2 -0
  113. package/dist/chunk-q87hkwfg.js +3 -0
  114. package/dist/{chunk-fzkyk5j4.js → chunk-q93jcdgj.js} +8 -8
  115. package/dist/chunk-qe6631me.js +2 -0
  116. package/dist/{chunk-e8zpzt9s.js → chunk-qv52et0d.js} +1 -1
  117. package/dist/{chunk-4cd94cd5.js → chunk-qvwzaxdd.js} +5 -5
  118. package/dist/chunk-qw1f97s7.js +2 -0
  119. package/dist/chunk-rcn0yyh2.js +2 -0
  120. package/dist/{chunk-xfb7fdeq.js → chunk-rq9pqd4s.js} +10 -10
  121. package/dist/{chunk-7hp50cpd.js → chunk-s322kcw7.js} +6 -6
  122. package/dist/chunk-shy2hkvj.js +2 -0
  123. package/dist/{chunk-w7p34cr3.js → chunk-smve11g0.js} +1 -1
  124. package/dist/{chunk-7kc9xwht.js → chunk-snmq7yn4.js} +4 -4
  125. package/dist/{chunk-v4bqmzj9.js → chunk-sny8rqe8.js} +2 -2
  126. package/dist/chunk-t9h3e3bp.js +2 -0
  127. package/dist/{chunk-ctb1bj28.js → chunk-tjer45j7.js} +3 -3
  128. package/dist/{chunk-qxk9grjm.js → chunk-tk67pqaf.js} +3 -3
  129. package/dist/{chunk-h1f3dpvq.js → chunk-tpw435g0.js} +2 -2
  130. package/dist/chunk-ts9bvjzh.js +2 -0
  131. package/dist/chunk-tzvgjrp4.js +2 -0
  132. package/dist/{chunk-7tteg9bn.js → chunk-v8b1wz1b.js} +1 -1
  133. package/dist/{chunk-ma4ftg5p.js → chunk-va1hj69e.js} +5 -5
  134. package/dist/{chunk-r69en2jg.js → chunk-w7s3afam.js} +1 -1
  135. package/dist/chunk-w9aa8xte.js +2 -0
  136. package/dist/{chunk-zswtgwxg.js → chunk-wd4z5w4d.js} +1 -1
  137. package/dist/chunk-wegkgjmf.js +2 -0
  138. package/dist/chunk-wn065q3f.js +2 -0
  139. package/dist/{chunk-fbpqkrvb.js → chunk-wskdnfh9.js} +6 -6
  140. package/dist/{chunk-jr346anv.js → chunk-xhvw0t0f.js} +2 -2
  141. package/dist/{chunk-xn2gyhes.js → chunk-xz1csyq9.js} +10 -10
  142. package/dist/chunk-y2dtqrrz.js +2 -0
  143. package/dist/{chunk-2rxr5cj6.js → chunk-y67r0d0c.js} +9 -9
  144. package/dist/chunk-yss7n9db.js +2 -0
  145. package/dist/chunk-z6p0yxwd.js +2 -0
  146. package/dist/{chunk-5erremft.js → chunk-z703xzhy.js} +2 -2
  147. package/dist/chunk-zcpwc47w.js +2 -0
  148. package/dist/{chunk-33ph9zb2.js → chunk-zn9dp7yn.js} +5 -5
  149. package/dist/chunk-zsmrq1w3.js +2 -0
  150. package/dist/cli.js +18 -18
  151. package/dist/client-script-bundler.d.ts +21 -0
  152. package/dist/client-script-bundler.js +14 -0
  153. package/dist/component-client-factories.js +6 -5
  154. package/dist/craft-entry.js +2 -2
  155. package/dist/craft.js +2 -2
  156. package/dist/index.d.ts +2 -0
  157. package/dist/index.js +1 -0
  158. package/dist/pwa.js +3 -3
  159. package/dist/ssg.js +8 -8
  160. package/dist/utils.js +3 -2
  161. package/package.json +5 -5
  162. package/dist/chunk-05f4tjsq.js +0 -2
  163. package/dist/chunk-0xwmweqm.js +0 -2
  164. package/dist/chunk-161ksm7f.js +0 -2
  165. package/dist/chunk-1p968nww.js +0 -2
  166. package/dist/chunk-2y20dvab.js +0 -2
  167. package/dist/chunk-33yeb861.js +0 -2
  168. package/dist/chunk-3pm6d9zj.js +0 -2
  169. package/dist/chunk-3wt0nh3p.js +0 -2
  170. package/dist/chunk-463zkecq.js +0 -2
  171. package/dist/chunk-5758n8sm.js +0 -2
  172. package/dist/chunk-5dykcrnv.js +0 -2
  173. package/dist/chunk-5ppe8d51.js +0 -2
  174. package/dist/chunk-5xcxc9f8.js +0 -2
  175. package/dist/chunk-6bm19d4k.js +0 -2
  176. package/dist/chunk-6w3gv9d6.js +0 -2
  177. package/dist/chunk-81z64a84.js +0 -2
  178. package/dist/chunk-8gsd2n0j.js +0 -2
  179. package/dist/chunk-8kqqxqyp.js +0 -2
  180. package/dist/chunk-8qe34jb8.js +0 -3
  181. package/dist/chunk-bk0arddt.js +0 -2
  182. package/dist/chunk-bz4bskx3.js +0 -2
  183. package/dist/chunk-c557w9e6.js +0 -2
  184. package/dist/chunk-cfmjtyzm.js +0 -2
  185. package/dist/chunk-ck9zengd.js +0 -2
  186. package/dist/chunk-cwt26rvt.js +0 -3
  187. package/dist/chunk-dbag44ta.js +0 -2
  188. package/dist/chunk-dee5mtdv.js +0 -2
  189. package/dist/chunk-dfcnaaym.js +0 -2
  190. package/dist/chunk-dm10y06z.js +0 -2
  191. package/dist/chunk-dw9vnhc4.js +0 -2
  192. package/dist/chunk-eegs2at0.js +0 -2
  193. package/dist/chunk-ehp792dy.js +0 -3
  194. package/dist/chunk-enxnw50k.js +0 -2
  195. package/dist/chunk-f858fazq.js +0 -2
  196. package/dist/chunk-fsg958xx.js +0 -2
  197. package/dist/chunk-ggthncvg.js +0 -2
  198. package/dist/chunk-gn1dmfdv.js +0 -2
  199. package/dist/chunk-gsn5vvw4.js +0 -2
  200. package/dist/chunk-hfcagm39.js +0 -2
  201. package/dist/chunk-hfe2byfx.js +0 -2
  202. package/dist/chunk-hmys6w75.js +0 -2
  203. package/dist/chunk-hqtj4ngq.js +0 -2
  204. package/dist/chunk-j3s5y2k5.js +0 -2
  205. package/dist/chunk-kez50h8a.js +0 -2
  206. package/dist/chunk-kfq4mwem.js +0 -2
  207. package/dist/chunk-knd3m4t4.js +0 -2
  208. package/dist/chunk-m3kc2a3v.js +0 -2
  209. package/dist/chunk-mjp2sp74.js +0 -2
  210. package/dist/chunk-mx79sfyr.js +0 -2
  211. package/dist/chunk-n6w82yf2.js +0 -2
  212. package/dist/chunk-ns5epsng.js +0 -2
  213. package/dist/chunk-p91288ce.js +0 -2
  214. package/dist/chunk-pesgcwrj.js +0 -20
  215. package/dist/chunk-pw6n7a9k.js +0 -2
  216. package/dist/chunk-q1z8edtn.js +0 -2
  217. package/dist/chunk-qccpfn5x.js +0 -2
  218. package/dist/chunk-syww37qd.js +0 -2
  219. package/dist/chunk-vbsr76qe.js +0 -2
  220. package/dist/chunk-vgaqznwt.js +0 -2
  221. package/dist/chunk-vw9h1x2m.js +0 -2
  222. package/dist/chunk-w165qe5q.js +0 -2
  223. package/dist/chunk-wz54wsm7.js +0 -2
  224. package/dist/chunk-x2vybq9n.js +0 -2
  225. package/dist/chunk-x4077p94.js +0 -2
  226. package/dist/chunk-z0qfspzg.js +0 -4
@@ -90,6 +90,27 @@ export declare function rewriteRegistryImports(code: string, reads: string[]): s
90
90
  * every cache key below, so neither build is ever served the other's code.
91
91
  */
92
92
  export declare function withModuleSubstitutes<T>(modules: ReadonlyMap<string, string>, run: () => Promise<T>): Promise<T>;
93
+ /**
94
+ * Run `run` as work done on behalf of a Bun bundler callback (`onLoad`,
95
+ * `onResolve`). Bun never settles a `Bun.build` started from inside one: the
96
+ * outer build waits for its callback, the callback for the inner build, and
97
+ * the process idles forever. Anything that would start a client bundle build
98
+ * within `run` throws instead (`assertBundleBuildCanSettle`), so the failure
99
+ * is an error that names the page, not a build that never ends.
100
+ *
101
+ * `bun-plugin-stx` wraps the one render it cannot move out of its loader in
102
+ * this: a `.stx` file that is imported rather than an entrypoint. Entrypoints
103
+ * are rendered in `onStart`, where a build does settle.
104
+ */
105
+ export declare function withinBundlerCallback<T>(run: () => Promise<T>): Promise<T>;
106
+ /** Whether the current async work is inside `withinBundlerCallback`. */
107
+ export declare function isWithinBundlerCallback(): boolean;
108
+ /**
109
+ * Refuse a client bundle build that could never finish. Called right before
110
+ * each cold `Bun.build`; a cache hit never reaches it, so a page whose bundle
111
+ * is already on disk still renders from inside a loader.
112
+ */
113
+ export declare function assertBundleBuildCanSettle(filePath: string): void;
93
114
  /** The substitutes in force (`withModuleSubstitutes`), as part of a cache key: empty with none. */
94
115
  export declare function moduleSubstitutionKey(): string;
95
116
  /**
@@ -252,6 +252,18 @@ export function withModuleSubstitutes(modules, run) {
252
252
  hasher.update(`${file}\x00${contents}\x00`);
253
253
  return moduleSubstitutes.run({ modules, key: hasher.digest("hex").slice(0, 12) }, run);
254
254
  }
255
+ const bundlerCallbackScope = new AsyncLocalStorage;
256
+ export function withinBundlerCallback(run) {
257
+ return bundlerCallbackScope.run(!0, run);
258
+ }
259
+ export function isWithinBundlerCallback() {
260
+ return bundlerCallbackScope.getStore() === !0;
261
+ }
262
+ export function assertBundleBuildCanSettle(filePath) {
263
+ if (!isWithinBundlerCallback())
264
+ return;
265
+ throw Error(`The client script of ${filePath} needs bundling, and it is being rendered inside a Bun.build loader, where Bun never finishes a second build. Make the page an entrypoint of the build (bun-plugin-stx renders entrypoints before the bundler starts), or render it once outside the build so its bundle is cached.`);
266
+ }
255
267
  export function moduleSubstitutionKey() {
256
268
  return moduleSubstitutes.getStore()?.key ?? "";
257
269
  }
@@ -422,6 +434,7 @@ export async function bundleClientScript(code, filePath, options = {}) {
422
434
  options.collectInputs.push(...(bundleMemo.get(cachePath)?.files ?? []).map((dep) => dep.path));
423
435
  return shared;
424
436
  }
437
+ assertBundleBuildCanSettle(filePath);
425
438
  const build = queueClientBundleBuild(() => buildBundle(code, filePath, { projectRoot, minify, cacheDir, hash, cachePath, depsPath, collectInputs: options.collectInputs, externalizeUserModules, serverApi, expose, throwOnFailure: options.throwOnFailure, substitutes: substituted?.modules }));
426
439
  inFlightBundles.set(hash, build);
427
440
  try {
@@ -444,6 +457,7 @@ export async function bundleClientEntriesSplit(entries, options) {
444
457
  byFile.set(path.basename(file).replace(/\.ts$/, ""), name);
445
458
  }
446
459
  const [firstFile, firstSource] = [...virtual][0], inputFiles = new Set;
460
+ assertBundleBuildCanSettle(options.filePath);
447
461
  try {
448
462
  const result = await Bun.build({
449
463
  entrypoints: [...virtual.keys()],
@@ -1,5 +1,6 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { scanAtElementPosition } from "./html-masking.js";
3
+ import { escapeScriptBody } from "./script-emit.js";
3
4
  export const COMPONENT_CLIENT_FACTORIES_CONTEXT_KEY = "__stx_component_client_factories";
4
5
  function registryFrom(context) {
5
6
  const registry = context[COMPONENT_CLIENT_FACTORIES_CONTEXT_KEY];
@@ -37,7 +38,7 @@ export function injectComponentClientFactories(html, context) {
37
38
  edits.push({
38
39
  start: match.index,
39
40
  end: match.index + match[0].length,
40
- replacement: `(${body})(${match[2]});`
41
+ replacement: escapeScriptBody(`(${body})(${match[2]});`)
41
42
  });
42
43
  match = invocation.exec(html);
43
44
  }
@@ -45,12 +46,12 @@ export function injectComponentClientFactories(html, context) {
45
46
  const repeatedFactories = [...registry].filter(([, factory]) => factory.instances > 1);
46
47
  if (repeatedFactories.length === 0)
47
48
  return applyFactoryEdits(html, edits);
48
- const prelude = `<script data-stx-scoped data-stx-run="always" data-stx-component-factories>
49
+ const definitions = repeatedFactories.map(([id, factory]) => ` try { factories[${JSON.stringify(id)}] = factories[${JSON.stringify(id)}] || ${factory.body}; }
50
+ catch (e) { console.error('[stx] component factory ' + ${JSON.stringify(id)} + ' failed to register; instances of it will not hydrate.', e); }`).join(`
51
+ `), prelude = `<script data-stx-scoped data-stx-run="always" data-stx-component-factories>
49
52
  (function() {
50
53
  const factories = window.__stxComponentFactories = window.__stxComponentFactories || {};
51
- ${repeatedFactories.map(([id, factory]) => ` try { factories[${JSON.stringify(id)}] = factories[${JSON.stringify(id)}] || ${factory.body}; }
52
- catch (e) { console.error('[stx] component factory ' + ${JSON.stringify(id)} + ' failed to register; instances of it will not hydrate.', e); }`).join(`
53
- `)}
54
+ ${escapeScriptBody(definitions)}
54
55
  })();
55
56
  </script>`;
56
57
  let insertionPoint;
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import"./chunk-mv48q1p4.js";import{Eo,Ea,Ta}from"./chunk-csksn1kg.js";import"./chunk-te82sjhy.js";import"./chunk-0dmpc70r.js";import"./chunk-ngnvyqk3.js";import"./chunk-xppm4cs4.js";import"./chunk-v4bqmzj9.js";import"./chunk-e8zpzt9s.js";import"./chunk-kvafq9gy.js";import"./chunk-9r999ees.js";import"./chunk-1qybwj8k.js";import"./chunk-vw73gsxx.js";import"./chunk-tm8a2b69.js";import"./chunk-k0arm18k.js";import"./chunk-9hvfmqs1.js";import"./chunk-ynd2nfvs.js";import"./chunk-q0jmc3m4.js";import"./chunk-xfb7fdeq.js";import"./chunk-4wrddn8m.js";import"./chunk-279n7sde.js";import"./chunk-t5q31st4.js";import"./chunk-68pvvd7v.js";import{xu,$a,Th,$h,Ra,To,ns,Aa,Pa,Rh,Ah,Ia,Oa,Na,Ma}from"./chunk-fzkyk5j4.js";import"./chunk-hgy98n76.js";import"./chunk-8qe34jb8.js";import"./chunk-v8p8t3t4.js";import"./chunk-7hp50cpd.js";import"./chunk-zswtgwxg.js";import"./chunk-qxk9grjm.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
2
+ import"./chunk-jdqmk5sv.js";import{Eo,Ea,Ta}from"./chunk-hjh5wt5f.js";import"./chunk-fxk1psd8.js";import"./chunk-0z2gqttt.js";import"./chunk-7fgfzaah.js";import"./chunk-xppm4cs4.js";import"./chunk-sny8rqe8.js";import"./chunk-qv52et0d.js";import"./chunk-e763qsg0.js";import"./chunk-jwwsxym6.js";import"./chunk-1347hwt5.js";import"./chunk-pa8xkctc.js";import"./chunk-kedgfk9z.js";import"./chunk-jtag68hg.js";import"./chunk-6qbha6fb.js";import"./chunk-mzg1wq86.js";import"./chunk-71s4hpkj.js";import"./chunk-rq9pqd4s.js";import"./chunk-8623gte8.js";import"./chunk-mxazxwc4.js";import"./chunk-t5q31st4.js";import"./chunk-3zjyhhg4.js";import{Su,$a,Ah,Ph,Ra,To,ns,Aa,Pa,Ih,Oh,Ia,Oa,Na,Ma}from"./chunk-q93jcdgj.js";import"./chunk-afrqm7w5.js";import"./chunk-75e4wzzs.js";import"./chunk-me16tftr.js";import"./chunk-s322kcw7.js";import"./chunk-wd4z5w4d.js";import"./chunk-tk67pqaf.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
3
3
  `),scripts:t.scripts.join(`
4
4
  `),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
5
5
  `),scripts:t.scripts.join(`
6
6
  `),hydrationData:i,metadata:{renderTime:s,cacheHit:!1,totalSize:a.length,componentCount:t.metadata.componentCount}}}function V(t,e){let n=[],r=[],a=[],i=new Map,s=[];return y(t.tree,(o,c)=>{if(o.type==="component"&&o.componentName){if(T(o.componentName))n.push(o.componentName)}if(o.type==="element"&&o.tag){let p=J(o);if(p)s.push(p);if(o.props){for(let[l,f]of Object.entries(o.props))if(l.startsWith("on")&&typeof f==="string"){let g=`handler_${i.size}`;i.set(g,f)}}}if(o.isStatic&&o.type==="element")r.push(b(o));else if(!o.isStatic&&o.type!=="text")a.push(o.tag||o.componentName||"unknown")}),{nativeComponents:n,staticHTML:r,dynamicParts:a,eventHandlers:i,nativeWidgets:s}}function Y(t,e={}){let n=R(t),r=P(n,e),a=new Map,i=[];return y(n.tree,(s)=>{if(s.type==="component"&&s.componentName){if(T(s.componentName)){i.push(s.componentName);let o=`<!--craft:${s.componentName}:${s.hydrationKey||"default"}-->`;a.set(s.hydrationKey||s.componentName,o)}}}),{staticHTML:r,dynamicPlaceholders:a,craftComponents:i}}function M(t){let e={type:"fragment",children:[]},n=e,r=[e],a=t,i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(a.length>0){let s=a.match(/^<(@?[\w-]+)([^>]*)>/);if(s){let[p,l,f]=s,g=z(f),u=l.startsWith("@craft-"),C=u?l:l.toLowerCase(),S={type:u?"component":"element",tag:C,props:g,children:[],componentName:u?C.slice(1):void 0,isStatic:!v(f),hydrationKey:F()};if(n.children=n.children||[],n.children.push(S),!i.has(C)&&!f.endsWith("/"))r.push(S),n=S;a=a.slice(p.length);continue}let o=a.match(/^<\/(@?[\w-]+)>/);if(o){let[p,l]=o,g=l.startsWith("@craft-")?l:l.toLowerCase();while(r.length>1){let u=r.pop();if(n=r[r.length-1],u.tag===g)break}a=a.slice(p.length);continue}let c=a.match(/^[^<]+/);if(c){let p=c[0];if(p.trim()){let l={type:"text",text:p,isStatic:!v(p)};n.children=n.children||[],n.children.push(l)}a=a.slice(p.length);continue}a=a.slice(1)}return e}function z(t){let e={},n=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,r;while((r=n.exec(t))!==null){let[,a,i,s,o]=r,c=i??s??o??!0;e[a]=c}return e}function y(t,e,n=[]){if(e(t,n),t.children)t.children.forEach((r,a)=>{y(r,e,[...n,`${a}`])})}function h(t,e){switch(t.type){case"text":return x(t.text||"",e);case"element":case"component":{let n=t.tag||"div",r=N(t.props||{},e),a=(t.children||[]).map((i)=>h(i,e)).join("");if(!t.children||t.children.length===0){if(["input","br","hr","img","meta","link"].includes(n))return`<${n}${r} />`}return`<${n}${r}>${a}</${n}>`}case"fragment":return(t.children||[]).map((n)=>h(n,e)).join("");case"slot":return`<!--slot:${t.slotName||"default"}-->`;default:return""}}function b(t){if(t.type==="text")return t.text||"";let e=t.tag||"div",n=N(t.props||{},{});return`<${e}${n}></${e}>`}function N(t,e){let n=[];for(let[r,a]of Object.entries(t))if(a===!0)n.push(` ${r}`);else if(a!==!1&&a!==null&&a!==void 0){let i=x(String(a),e);n.push(` ${r}="${k(i)}"`)}return n.join("")}async function H(t,e){return h(t,e)}function P(t,e){let n=[];return y(t.tree,(r)=>{if(r.isStatic)n.push(h(r,e))}),n.join("")}function j(t,e,n){let r={templateId:e.id,context:n,dynamicParts:Array.from(e.dynamicParts.entries())},a=`
7
7
  <script data-craft-hydration>
8
8
  window.__CRAFT_HYDRATION__ = ${JSON.stringify(r)};
9
- </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{xu as CRAFT_BRIDGE_SCRIPT,To as CRAFT_COMPONENTS,Aa as CRAFT_COMPONENT_RUNTIME,ns as CRAFT_COMPONENT_STYLES,Eo as NATIVE_COMPONENTS,Ia as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Ea as compileToNative,Ta as createHotReloadServer,Oa as findCraftBinary,$a as generateCraftBridgeScript,V as generateCraftOptimizations,Ma as getAvailableFormats,Na as getAvailableTargets,Ah as getCraftComponents,G as getSSRCacheStats,Ra as injectCraftBridge,Th as isCraftEnvironment,Y as prerenderForCraft,Pa as processCraftComponents,$h as processCraftDirective,Rh as registerCraftComponent,Q as renderSSR};
9
+ </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{Su as CRAFT_BRIDGE_SCRIPT,To as CRAFT_COMPONENTS,Aa as CRAFT_COMPONENT_RUNTIME,ns as CRAFT_COMPONENT_STYLES,Eo as NATIVE_COMPONENTS,Ia as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Ea as compileToNative,Ta as createHotReloadServer,Oa as findCraftBinary,$a as generateCraftBridgeScript,V as generateCraftOptimizations,Ma as getAvailableFormats,Na as getAvailableTargets,Oh as getCraftComponents,G as getSSRCacheStats,Ra as injectCraftBridge,Ah as isCraftEnvironment,Y as prerenderForCraft,Pa as processCraftComponents,Ph as processCraftDirective,Ih as registerCraftComponent,Q as renderSSR};
package/dist/craft.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import"./chunk-mv48q1p4.js";import{Eo,Ea,Ta}from"./chunk-csksn1kg.js";import"./chunk-te82sjhy.js";import"./chunk-0dmpc70r.js";import"./chunk-ngnvyqk3.js";import"./chunk-xppm4cs4.js";import"./chunk-v4bqmzj9.js";import"./chunk-e8zpzt9s.js";import"./chunk-kvafq9gy.js";import"./chunk-9r999ees.js";import"./chunk-1qybwj8k.js";import"./chunk-vw73gsxx.js";import"./chunk-tm8a2b69.js";import"./chunk-k0arm18k.js";import"./chunk-9hvfmqs1.js";import"./chunk-ynd2nfvs.js";import"./chunk-q0jmc3m4.js";import"./chunk-xfb7fdeq.js";import"./chunk-4wrddn8m.js";import"./chunk-279n7sde.js";import"./chunk-t5q31st4.js";import"./chunk-68pvvd7v.js";import{xu,$a,Th,$h,Ra,To,ns,Aa,Pa,Rh,Ah,Ia,Oa,Na,Ma}from"./chunk-fzkyk5j4.js";import"./chunk-hgy98n76.js";import"./chunk-8qe34jb8.js";import"./chunk-v8p8t3t4.js";import"./chunk-7hp50cpd.js";import"./chunk-zswtgwxg.js";import"./chunk-qxk9grjm.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
2
+ import"./chunk-jdqmk5sv.js";import{Eo,Ea,Ta}from"./chunk-hjh5wt5f.js";import"./chunk-fxk1psd8.js";import"./chunk-0z2gqttt.js";import"./chunk-7fgfzaah.js";import"./chunk-xppm4cs4.js";import"./chunk-sny8rqe8.js";import"./chunk-qv52et0d.js";import"./chunk-e763qsg0.js";import"./chunk-jwwsxym6.js";import"./chunk-1347hwt5.js";import"./chunk-pa8xkctc.js";import"./chunk-kedgfk9z.js";import"./chunk-jtag68hg.js";import"./chunk-6qbha6fb.js";import"./chunk-mzg1wq86.js";import"./chunk-71s4hpkj.js";import"./chunk-rq9pqd4s.js";import"./chunk-8623gte8.js";import"./chunk-mxazxwc4.js";import"./chunk-t5q31st4.js";import"./chunk-3zjyhhg4.js";import{Su,$a,Ah,Ph,Ra,To,ns,Aa,Pa,Ih,Oh,Ia,Oa,Na,Ma}from"./chunk-q93jcdgj.js";import"./chunk-afrqm7w5.js";import"./chunk-75e4wzzs.js";import"./chunk-me16tftr.js";import"./chunk-s322kcw7.js";import"./chunk-wd4z5w4d.js";import"./chunk-tk67pqaf.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
3
3
  `),scripts:t.scripts.join(`
4
4
  `),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
5
5
  `),scripts:t.scripts.join(`
6
6
  `),hydrationData:i,metadata:{renderTime:s,cacheHit:!1,totalSize:a.length,componentCount:t.metadata.componentCount}}}function V(t,e){let n=[],r=[],a=[],i=new Map,s=[];return y(t.tree,(o,c)=>{if(o.type==="component"&&o.componentName){if(T(o.componentName))n.push(o.componentName)}if(o.type==="element"&&o.tag){let p=J(o);if(p)s.push(p);if(o.props){for(let[l,f]of Object.entries(o.props))if(l.startsWith("on")&&typeof f==="string"){let g=`handler_${i.size}`;i.set(g,f)}}}if(o.isStatic&&o.type==="element")r.push(b(o));else if(!o.isStatic&&o.type!=="text")a.push(o.tag||o.componentName||"unknown")}),{nativeComponents:n,staticHTML:r,dynamicParts:a,eventHandlers:i,nativeWidgets:s}}function Y(t,e={}){let n=R(t),r=P(n,e),a=new Map,i=[];return y(n.tree,(s)=>{if(s.type==="component"&&s.componentName){if(T(s.componentName)){i.push(s.componentName);let o=`<!--craft:${s.componentName}:${s.hydrationKey||"default"}-->`;a.set(s.hydrationKey||s.componentName,o)}}}),{staticHTML:r,dynamicPlaceholders:a,craftComponents:i}}function M(t){let e={type:"fragment",children:[]},n=e,r=[e],a=t,i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(a.length>0){let s=a.match(/^<(@?[\w-]+)([^>]*)>/);if(s){let[p,l,f]=s,g=z(f),u=l.startsWith("@craft-"),C=u?l:l.toLowerCase(),S={type:u?"component":"element",tag:C,props:g,children:[],componentName:u?C.slice(1):void 0,isStatic:!v(f),hydrationKey:F()};if(n.children=n.children||[],n.children.push(S),!i.has(C)&&!f.endsWith("/"))r.push(S),n=S;a=a.slice(p.length);continue}let o=a.match(/^<\/(@?[\w-]+)>/);if(o){let[p,l]=o,g=l.startsWith("@craft-")?l:l.toLowerCase();while(r.length>1){let u=r.pop();if(n=r[r.length-1],u.tag===g)break}a=a.slice(p.length);continue}let c=a.match(/^[^<]+/);if(c){let p=c[0];if(p.trim()){let l={type:"text",text:p,isStatic:!v(p)};n.children=n.children||[],n.children.push(l)}a=a.slice(p.length);continue}a=a.slice(1)}return e}function z(t){let e={},n=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,r;while((r=n.exec(t))!==null){let[,a,i,s,o]=r,c=i??s??o??!0;e[a]=c}return e}function y(t,e,n=[]){if(e(t,n),t.children)t.children.forEach((r,a)=>{y(r,e,[...n,`${a}`])})}function h(t,e){switch(t.type){case"text":return x(t.text||"",e);case"element":case"component":{let n=t.tag||"div",r=N(t.props||{},e),a=(t.children||[]).map((i)=>h(i,e)).join("");if(!t.children||t.children.length===0){if(["input","br","hr","img","meta","link"].includes(n))return`<${n}${r} />`}return`<${n}${r}>${a}</${n}>`}case"fragment":return(t.children||[]).map((n)=>h(n,e)).join("");case"slot":return`<!--slot:${t.slotName||"default"}-->`;default:return""}}function b(t){if(t.type==="text")return t.text||"";let e=t.tag||"div",n=N(t.props||{},{});return`<${e}${n}></${e}>`}function N(t,e){let n=[];for(let[r,a]of Object.entries(t))if(a===!0)n.push(` ${r}`);else if(a!==!1&&a!==null&&a!==void 0){let i=x(String(a),e);n.push(` ${r}="${k(i)}"`)}return n.join("")}async function H(t,e){return h(t,e)}function P(t,e){let n=[];return y(t.tree,(r)=>{if(r.isStatic)n.push(h(r,e))}),n.join("")}function j(t,e,n){let r={templateId:e.id,context:n,dynamicParts:Array.from(e.dynamicParts.entries())},a=`
7
7
  <script data-craft-hydration>
8
8
  window.__CRAFT_HYDRATION__ = ${JSON.stringify(r)};
9
- </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{xu as CRAFT_BRIDGE_SCRIPT,To as CRAFT_COMPONENTS,Aa as CRAFT_COMPONENT_RUNTIME,ns as CRAFT_COMPONENT_STYLES,Eo as NATIVE_COMPONENTS,Ia as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Ea as compileToNative,Ta as createHotReloadServer,Oa as findCraftBinary,$a as generateCraftBridgeScript,V as generateCraftOptimizations,Ma as getAvailableFormats,Na as getAvailableTargets,Ah as getCraftComponents,G as getSSRCacheStats,Ra as injectCraftBridge,Th as isCraftEnvironment,Y as prerenderForCraft,Pa as processCraftComponents,$h as processCraftDirective,Rh as registerCraftComponent,Q as renderSSR};
9
+ </script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{Su as CRAFT_BRIDGE_SCRIPT,To as CRAFT_COMPONENTS,Aa as CRAFT_COMPONENT_RUNTIME,ns as CRAFT_COMPONENT_STYLES,Eo as NATIVE_COMPONENTS,Ia as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Ea as compileToNative,Ta as createHotReloadServer,Oa as findCraftBinary,$a as generateCraftBridgeScript,V as generateCraftOptimizations,Ma as getAvailableFormats,Na as getAvailableTargets,Oh as getCraftComponents,G as getSSRCacheStats,Ra as injectCraftBridge,Ah as isCraftEnvironment,Y as prerenderForCraft,Pa as processCraftComponents,Ph as processCraftDirective,Ih as registerCraftComponent,Q as renderSSR};
package/dist/index.d.ts CHANGED
@@ -253,6 +253,8 @@ export * from './loading-indicator.js';
253
253
  export * from './reactive-bindings.js';
254
254
  export * from './client-helpers.js';
255
255
  export * from './client-script.js';
256
+ // The guard a bundler plugin puts around a render it has to do inside a loader.
257
+ export { isWithinBundlerCallback, withinBundlerCallback } from './client-script-bundler.js';
256
258
  /*
257
259
  * The authoring surface, as data.
258
260
  *
package/dist/index.js CHANGED
@@ -146,6 +146,7 @@ export * from "./loading-indicator.js";
146
146
  export * from "./reactive-bindings.js";
147
147
  export * from "./client-helpers.js";
148
148
  export * from "./client-script.js";
149
+ export { isWithinBundlerCallback, withinBundlerCallback } from "./client-script-bundler.js";
149
150
  export * from "./runtime-globals.js";
150
151
  export * from "./strip-literals.js";
151
152
  export * from "./resolve-stx-targets.js";
package/dist/pwa.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{so,Ut,Al,Mg}from"./chunk-ctb1bj28.js";import{ro,ji,Ig,Og,Ng}from"./chunk-33ph9zb2.js";import{Tl,$l,Rl,Ag,Pg}from"./chunk-j2wcawmf.js";import{We,Pn,Bi}from"./chunk-krtkxnz6.js";import{Dg,Lg,jg,Bg,oo,ky}from"./chunk-fhrvxfq9.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-vgaqznwt.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{so,Wt,Pl,jg}from"./chunk-tjer45j7.js";import{ro,ji,Mg,Dg,Lg}from"./chunk-zn9dp7yn.js";import{$l,Rl,Al,Og,Ng}from"./chunk-fw50vydb.js";import{qe,Pn,Bi}from"./chunk-admnvsmx.js";import{Bg,Fg,zg,Hg,oo,Ey}from"./chunk-ff3j7jnf.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-pvx1hrqq.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=We(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=so(n,t);if(a){let s=Ut(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 ji(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,$l as auditBuildOutput,Tl as auditConfig,re as buildPwaAssets,Rl as calculateAuditResult,Pg as formatAuditResult,Bi as formatSize,j as generateManifest,_ as generateManifestJson,Og as generateManifestLink,F as generateOfflinePage,We as generatePrecacheManifest,Pn as generatePrecacheManifestJs,M as generatePwaIcons,ro as generatePwaTags,so as generateServiceWorker,Mg as generateServiceWorkerAuto,Ig as generateSwRegistrationScript,Ng as generateThemeColorMeta,N as getExpectedIconPaths,Ut as getServiceWorkerFileName,ji as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,Al as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,oo as pwaDirectives,Dg as pwaInstallDirective,jg as pwaOfflineDirective,Bg as pwaPushDirective,Lg as pwaUpdateDirective,ky as registerPwaDirectives,Ag 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=qe(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=so(n,t);if(a){let s=Wt(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 ji(n,t)}function se(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,Rl as auditBuildOutput,$l as auditConfig,re as buildPwaAssets,Al as calculateAuditResult,Ng as formatAuditResult,Bi as formatSize,j as generateManifest,_ as generateManifestJson,Dg as generateManifestLink,F as generateOfflinePage,qe as generatePrecacheManifest,Pn as generatePrecacheManifestJs,M as generatePwaIcons,ro as generatePwaTags,so as generateServiceWorker,jg as generateServiceWorkerAuto,Mg as generateSwRegistrationScript,Lg as generateThemeColorMeta,N as getExpectedIconPaths,Wt as getServiceWorkerFileName,ji as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,Pl as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,oo as pwaDirectives,Bg as pwaInstallDirective,zg as pwaOfflineDirective,Hg as pwaPushDirective,Fg as pwaUpdateDirective,Ey as registerPwaDirectives,Og as runPwaAudit,D as validateManifest};
package/dist/ssg.js CHANGED
@@ -1,13 +1,13 @@
1
1
  // @bun
2
- import"./chunk-hpwtjb4a.js";import{x,dl}from"./chunk-0dmpc70r.js";import"./chunk-ngnvyqk3.js";import"./chunk-xppm4cs4.js";import{Pt,y}from"./chunk-mv48q1p4.js";import"./chunk-v4bqmzj9.js";import"./chunk-e8zpzt9s.js";import"./chunk-kvafq9gy.js";import{Ct,Et,Tt,$t,Rt,At}from"./chunk-9r999ees.js";import{a}from"./chunk-1qybwj8k.js";import{As}from"./chunk-vw73gsxx.js";import"./chunk-tm8a2b69.js";import"./chunk-4cd94cd5.js";import{ye,rn,sn}from"./chunk-pesgcwrj.js";import"./chunk-k0arm18k.js";import{b}from"./chunk-9hvfmqs1.js";import{wt,i}from"./chunk-ynd2nfvs.js";import"./chunk-q0jmc3m4.js";import"./chunk-xfb7fdeq.js";import{ys}from"./chunk-4wrddn8m.js";import"./chunk-279n7sde.js";import"./chunk-t5q31st4.js";import{sc,oc,ic}from"./chunk-qa4vs1qg.js";import{tn,tr,nr}from"./chunk-cwt26rvt.js";import{nn}from"./chunk-yzvp90yk.js";import"./chunk-8qe34jb8.js";import"./chunk-v8p8t3t4.js";import{X,ve}from"./chunk-7hp50cpd.js";import"./chunk-zswtgwxg.js";import"./chunk-qxk9grjm.js";import{c}from"./chunk-ehp792dy.js";import{r,me}from"./chunk-7kc9xwht.js";import D from"fs";import f from"path";import{createHash as vt}from"crypto";function kt(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=kt(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 Ot(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 Ot(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 Lt;function Ut(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=dl(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=nn(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=(Lt??=new Bun.Transpiler({loader:"ts",target:"bun"})).transformSync(e.content);if(!/\bgetStaticPaths\b/.test(r(u)))continue;let g=Ut(u);if(/\bdefineStaticPaths\b/.test(r(g))&&Pt(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)&&ys(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 _t(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-mzes9ds7.js";import{x,pl}from"./chunk-0z2gqttt.js";import"./chunk-7fgfzaah.js";import"./chunk-xppm4cs4.js";import{It,y}from"./chunk-jdqmk5sv.js";import"./chunk-sny8rqe8.js";import"./chunk-qv52et0d.js";import"./chunk-e763qsg0.js";import{Et,Tt,$t,Rt,At,Pt}from"./chunk-jwwsxym6.js";import{a}from"./chunk-1347hwt5.js";import{As}from"./chunk-pa8xkctc.js";import"./chunk-kedgfk9z.js";import"./chunk-qvwzaxdd.js";import{be,sn,on}from"./chunk-jwtp4csj.js";import"./chunk-jtag68hg.js";import{b}from"./chunk-6qbha6fb.js";import{vt,i}from"./chunk-mzg1wq86.js";import"./chunk-71s4hpkj.js";import"./chunk-rq9pqd4s.js";import{ys}from"./chunk-8623gte8.js";import"./chunk-mxazxwc4.js";import"./chunk-t5q31st4.js";import{sc,oc,ic}from"./chunk-qa4vs1qg.js";import{nn,tr,nr}from"./chunk-q87hkwfg.js";import{rn}from"./chunk-252enthj.js";import"./chunk-75e4wzzs.js";import"./chunk-me16tftr.js";import{X,xe}from"./chunk-s322kcw7.js";import"./chunk-wd4z5w4d.js";import"./chunk-tk67pqaf.js";import{c}from"./chunk-ksxbfyef.js";import{r,he}from"./chunk-snmq7yn4.js";import D from"fs";import f from"path";import{createHash as bt}from"crypto";function kt(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 Ct(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=kt(w);let p=Ct(w);if(!s.has(p))s.set(p,w);let P=n.integrity?` data-stx-integrity="sha384-${bt("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 Ot(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 Ot(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 Lt;function Ut(t){let n=r(t),{depths:s}=he(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=pl(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=rn(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=(Lt??=new Bun.Transpiler({loader:"ts",target:"bun"})).transformSync(e.content);if(!/\bgetStaticPaths\b/.test(r(u)))continue;let g=Ut(u);if(/\bdefineStaticPaths\b/.test(r(g))&&It(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)&&ys(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 _t(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 A of ye(R))w.add(A);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 A of be(R))w.add(A);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 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"?>
10
+ ${S}`}if(S=await xe(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,13 +37,13 @@ ${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();sn();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-81z64a84.js");try{E=m(await d(process.cwd()))}catch{}}let{prepareImageDelivery:S}=await import("./chunk-463zkecq.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 A=new pt(e.cacheDir,E);if(e.cache)await A.load();try{let{generateCss:d}=await import("./chunk-81z64a84.js");await d('<div class="bg-black"></div>')}catch{}Ct();let yt=s?.routeMiddleware?.dir||"middleware";await Tt(process.cwd(),yt);let J=Et();if(J.length>0)console.log(`Loaded ${J.length} middleware: ${J.join(", ")}`);let St=s?.routeMiddleware?.global||[];ic(s?.layoutsDir,c(process.cwd()));let Z=X(".",{pagesDir:e.pagesDir,pagesDirs:s?._layerPageDirs});console.log(`Found ${Z.length} routes`);let L=[];for(let d of Z)try{let m=await _t(d);for(let k of m)L.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=L.length+u.failedCount,console.log(`Generating ${L.length} pages...`);let U=[],Q=[];for(let d=0;d<L.length;d+=e.concurrency)Q.push(L.slice(d,d+e.concurrency));for(let d of Q)await Promise.all(d.map(async(m)=>{let{route:k,url:h,params:_,props:xt,revalidate:rt}=m;try{await e.hooks.onPageStart?.(h);let M=await Bun.file(k.filePath).text(),T=Yt(M),bt=T?.middleware?Array.isArray(T.middleware)?T.middleware:[T.middleware]:[],nt=[...St,...bt];if(nt.length>0){let B=$t(h,_,T||{}),N=Rt(B,null,void 0,{isServer:!0}),j=await At(nt,N);if(j.redirect){let C=typeof j.redirect==="string"?j.redirect:j.redirect.path||j.redirect,H=Zt(String(C),h),O=Qt(h,e);await D.promises.mkdir(f.dirname(O),{recursive:!0}),await Bun.write(O,H),u.successCount++,u.pages.push({route:h,outputPath:O,size:Buffer.byteLength(H),cached:!1}),U.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=T?.validate;if(typeof it==="function")try{if(!await it({params:_})){console.warn(`Validation failed for ${h}, skipping...`);return}}catch{}let I=null,st=!1;if(e.cache){if(I=A.get(h,k.filePath),I)st=!0,u.cachedCount++}if(!I){let B=await mt(k,_,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:
40
+ </rss>`}async function Vt(t={}){let n=Date.now();on();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-jzynkjfc.js");try{E=m(await d(process.cwd()))}catch{}}let{prepareImageDelivery:S}=await import("./chunk-1g06wfs9.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 A=new pt(e.cacheDir,E);if(e.cache)await A.load();try{let{generateCss:d}=await import("./chunk-jzynkjfc.js");await d('<div class="bg-black"></div>')}catch{}Et();let wt=s?.routeMiddleware?.dir||"middleware";await $t(process.cwd(),wt);let J=Tt();if(J.length>0)console.log(`Loaded ${J.length} middleware: ${J.join(", ")}`);let yt=s?.routeMiddleware?.global||[];ic(s?.layoutsDir,c(process.cwd()));let Z=X(".",{pagesDir:e.pagesDir,pagesDirs:s?._layerPageDirs});console.log(`Found ${Z.length} routes`);let L=[];for(let d of Z)try{let m=await _t(d);for(let k of m)L.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=L.length+u.failedCount,console.log(`Generating ${L.length} pages...`);let U=[],Q=[];for(let d=0;d<L.length;d+=e.concurrency)Q.push(L.slice(d,d+e.concurrency));for(let d of Q)await Promise.all(d.map(async(m)=>{let{route:k,url:h,params:_,props:St,revalidate:rt}=m;try{await e.hooks.onPageStart?.(h);let M=await Bun.file(k.filePath).text(),T=Yt(M),xt=T?.middleware?Array.isArray(T.middleware)?T.middleware:[T.middleware]:[],nt=[...yt,...xt];if(nt.length>0){let B=Rt(h,_,T||{}),N=At(B,null,void 0,{isServer:!0}),j=await Pt(nt,N);if(j.redirect){let C=typeof j.redirect==="string"?j.redirect:j.redirect.path||j.redirect,H=Zt(String(C),h),O=Qt(h,e);await D.promises.mkdir(f.dirname(O),{recursive:!0}),await Bun.write(O,H),u.successCount++,u.pages.push({route:h,outputPath:O,size:Buffer.byteLength(H),cached:!1}),U.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=T?.validate;if(typeof it==="function")try{if(!await it({params:_})){console.warn(`Validation failed for ${h}, skipping...`);return}}catch{}let I=null,st=!1;if(e.cache){if(I=A.get(h,k.filePath),I)st=!0,u.cachedCount++}if(!I){let B=await mt(k,_,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:
41
41
  ${B.includeFailures.join(`
42
42
  `)}
43
43
  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:
44
44
  ${B.serverScriptFailures.join(`
45
45
  `)}
46
- Set ssg.failOnServerScriptError to false to build anyway.`);if(e.cache)A.set(h,k.filePath,B.dependencies,I)}let G;if(e.trailingSlash)G=f.join(e.outputDir,h,"index.html");else G=h==="/"?f.join(e.outputDir,"index.html"):f.join(e.outputDir,`${h}.html`);if(e.chunkIslands){let{html:B,chunks:N}=ot(I,{integrity:e.integrityIslands,minify:e.minify});if(N.length>0){let j=f.join(e.outputDir,"_stx","islands");await D.promises.mkdir(j,{recursive:!0});for(let C of N){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 O=Buffer.byteLength(C.code,"utf8");v+=O,w[C.hash]={bytes:O,file:`/_stx/islands/${C.hash}.js`}}}if(p[h]=N.map((C)=>C.hash),I=B,e.prefetchIslands)I=ct(I)}}if(await D.promises.mkdir(f.dirname(G),{recursive:!0}),await Bun.write(G,I),!Wt(h,I,T,e.sitemapExclude))U.push({loc:h,lastmod:new Date().toISOString().split("T")[0],priority:h==="/"?1:0.8});let at={route:h,outputPath:G,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(M){u.failedCount++,u.errors.push({route:h,error:M}),await e.hooks.onError?.(M,h),console.error(`Error generating ${h}:`,M)}}));let tt=rn();if(tt.length>0){let d=tt.map((m)=>`${m.filePath}: ${m.message}`).join(`
46
+ Set ssg.failOnServerScriptError to false to build anyway.`);if(e.cache)A.set(h,k.filePath,B.dependencies,I)}let G;if(e.trailingSlash)G=f.join(e.outputDir,h,"index.html");else G=h==="/"?f.join(e.outputDir,"index.html"):f.join(e.outputDir,`${h}.html`);if(e.chunkIslands){let{html:B,chunks:N}=ot(I,{integrity:e.integrityIslands,minify:e.minify});if(N.length>0){let j=f.join(e.outputDir,"_stx","islands");await D.promises.mkdir(j,{recursive:!0});for(let C of N){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 O=Buffer.byteLength(C.code,"utf8");v+=O,w[C.hash]={bytes:O,file:`/_stx/islands/${C.hash}.js`}}}if(p[h]=N.map((C)=>C.hash),I=B,e.prefetchIslands)I=ct(I)}}if(await D.promises.mkdir(f.dirname(G),{recursive:!0}),await Bun.write(G,I),!Wt(h,I,T,e.sitemapExclude))U.push({loc:h,lastmod:new Date().toISOString().split("T")[0],priority:h==="/"?1:0.8});let at={route:h,outputPath:G,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(M){u.failedCount++,u.errors.push({route:h,error:M}),await e.hooks.onError?.(M,h),console.error(`Error generating ${h}:`,M)}}));let tt=sn();if(tt.length>0){let d=tt.map((m)=>`${m.filePath}: ${m.message}`).join(`
47
47
  `);throw Error(`Client script bundling failed:
48
48
  ${d}`)}if(e.cache)await A.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>
49
49
  <html lang="en">
@@ -66,7 +66,7 @@ ${d}`)}if(e.cache)await A.save();if(e.generate404){let d=f.join(e.pagesDir,"404.
66
66
  <a href="/">Go home</a>
67
67
  </div>
68
68
  </body>
69
- </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},_=await i(await Bun.file(m).text(),{},m,h,k);await Bun.write(f.join(e.outputDir,`${d}.html`),_)}}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&&U.length>0){let d=qt(U,e.domain),m=f.join(e.outputDir,"sitemap.xml");await Bun.write(m,d),u.sitemapPath=m,console.log(`Generated sitemap.xml with ${U.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=As({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=sc(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=oc(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=nr();if(et)await Y(et,f.join(e.outputDir,tr)),console.log(`Copied assets from ${tn}`)}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?`
69
+ </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},_=await i(await Bun.file(m).text(),{},m,h,k);await Bun.write(f.join(e.outputDir,`${d}.html`),_)}}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&&U.length>0){let d=qt(U,e.domain),m=f.join(e.outputDir,"sitemap.xml");await Bun.write(m,d),u.sitemapPath=m,console.log(`Generated sitemap.xml with ${U.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=As({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=sc(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=oc(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=nr();if(et)await Y(et,f.join(e.outputDir,tr)),console.log(`Copied assets from ${nn}`)}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?`
70
70
  Island chunks: ${u.islandChunks.count} (${(u.islandChunks.totalBytes/1024).toFixed(1)} KB lifted out of inline HTML)`:"";return console.log(`
71
71
  Build complete!
72
72
  Total: ${u.totalPages} pages
@@ -75,7 +75,7 @@ Build complete!
75
75
  Failed: ${u.failedCount}
76
76
  Time: ${u.buildTime}ms${P}
77
77
  `),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(`
78
- `)){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 wt(t)}function Zt(t,n){return`<!DOCTYPE html>
78
+ `)){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 vt(t)}function Zt(t,n){return`<!DOCTYPE html>
79
79
  <html>
80
80
  <head>
81
81
  <meta charset="utf-8">
package/dist/utils.js CHANGED
@@ -29,6 +29,7 @@ import { CLIENT_LOOP_NAMES_KEY, inheritedClientLoopNames } from "./loop-binding.
29
29
  import { isFallthroughAttribute } from "./builtins/attrs.js";
30
30
  import { StxValidationError } from "./errors/types.js";
31
31
  import { validateClientScript } from "./script-validation.js";
32
+ import { escapeScriptBody } from "./script-emit.js";
32
33
  function renderExternalComponentScript(script, context, filePath) {
33
34
  const opening = /^<script\b([^>]*)>/i.exec(script);
34
35
  if (!opening || !/(?:^|\s)src\s*=/i.test(opening[1] ?? ""))
@@ -1142,8 +1143,8 @@ ${bridge}
1142
1143
  return (${island.factoryBody})(__scopeId);
1143
1144
  }` : island.factoryBody, factoryId = hydrateTrigger ? null : registerComponentClientFactory(parentContext, factoryBody), wrappedContent = factoryId ? `window.__stxComponentFactories[${JSON.stringify(factoryId)}](${JSON.stringify(scopeId)});` : `(${factoryBody})(${JSON.stringify(scopeId)});`;
1144
1145
  if (hydrateTrigger)
1145
- return `${vendorStyleTags}<script type="stx/island" data-stx-island="${scopeId}" data-stx-scoped data-stx-owner="${scopeId}"${attrs}>${wrappedContent}</script>`;
1146
- return `${vendorStyleTags}<script data-stx-scoped data-stx-run="always" data-stx-owner="${scopeId}"${attrs}>${wrappedContent}</script>`;
1146
+ return `${vendorStyleTags}<script type="stx/island" data-stx-island="${scopeId}" data-stx-scoped data-stx-owner="${scopeId}"${attrs}>${escapeScriptBody(wrappedContent)}</script>`;
1147
+ return `${vendorStyleTags}<script data-stx-scoped data-stx-run="always" data-stx-owner="${scopeId}"${attrs}>${escapeScriptBody(wrappedContent)}</script>`;
1147
1148
  }));
1148
1149
  output = output + `
1149
1150
  ` + scopedScripts.join(`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.2.855",
4
+ "version": "0.2.858",
5
5
  "description": "A performant UI Framework. Powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -127,14 +127,14 @@
127
127
  },
128
128
  "dependencies": {
129
129
  "@stacksjs/clapp": "^0.2.17",
130
- "@stacksjs/desktop": "0.2.855",
131
- "@stacksjs/sanitizer": "0.2.855",
130
+ "@stacksjs/desktop": "0.2.858",
131
+ "@stacksjs/sanitizer": "0.2.858",
132
132
  "@stacksjs/ts-css": "^0.3.21",
133
133
  "@stacksjs/ts-i18n": "^0.1.11",
134
134
  "@types/dom-speech-recognition": "^0.0.12",
135
- "bun-plugin-stx": "0.2.855",
135
+ "bun-plugin-stx": "0.2.858",
136
136
  "bunfig": "^0.15.21",
137
- "stx-router": "0.2.855",
137
+ "stx-router": "0.2.858",
138
138
  "ts-broadcasting": "^0.0.13",
139
139
  "ts-images": "^0.2.22",
140
140
  "ts-syntax-highlighter": "^0.2.1"
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Hr,Vr,Xg,Jg,Yg,Zg,Qg}from"./chunk-pm241ehv.js";export{Hr as collectMessageCatalogs,Jg as loadPageMessages,Yg as messageAreasIn,Zg as pageLanguages,Xg as pageMessagesEnabled,Qg as pageMessagesScript,Vr as pathSpellings};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Tl,$l,Rl,Ag,Pg}from"./chunk-j2wcawmf.js";export{$l as auditBuildOutput,Tl as auditConfig,Rl as calculateAuditResult,Pg as formatAuditResult,Ag as runPwaAudit};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{ko,bh,wh}from"./chunk-pwem4sed.js";import"./chunk-pesgcwrj.js";import"./chunk-4cd94cd5.js";import"./chunk-hpwtjb4a.js";import"./chunk-4wrddn8m.js";import"./chunk-7hp50cpd.js";import"./chunk-zswtgwxg.js";import"./chunk-1qybwj8k.js";import"./chunk-qxk9grjm.js";import"./chunk-kvafq9gy.js";import"./chunk-tm8a2b69.js";import"./chunk-vw73gsxx.js";import"./chunk-9r999ees.js";import"./chunk-mv48q1p4.js";import"./chunk-e8zpzt9s.js";import"./chunk-v4bqmzj9.js";import"./chunk-0dmpc70r.js";import"./chunk-xppm4cs4.js";import"./chunk-ngnvyqk3.js";export{wh as clearComposableCache,bh as getComposableScript,ko as listComposableModules};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{sr,Re}from"./chunk-hpwtjb4a.js";export{sr as describeBuildFailure,Re as formatBuildFailure};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{fh,So,gh,mh,hh,yh}from"./chunk-fbpqkrvb.js";import"./chunk-pesgcwrj.js";import"./chunk-4cd94cd5.js";import"./chunk-hpwtjb4a.js";import"./chunk-4wrddn8m.js";import"./chunk-7hp50cpd.js";import"./chunk-zswtgwxg.js";import"./chunk-1qybwj8k.js";import"./chunk-qxk9grjm.js";import"./chunk-kvafq9gy.js";import"./chunk-tm8a2b69.js";import"./chunk-vw73gsxx.js";import"./chunk-9r999ees.js";import"./chunk-mv48q1p4.js";import"./chunk-e8zpzt9s.js";import"./chunk-v4bqmzj9.js";import"./chunk-0dmpc70r.js";import"./chunk-xppm4cs4.js";import"./chunk-ngnvyqk3.js";export{yh as clearStoreCache,fh as getStoreScript,hh as getStoreScriptFor,mh as pageStoresAll,So as storesRead,gh as storesReadInFiles};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{va,Gl}from"./chunk-q0ycypnt.js";import"./chunk-h1f3dpvq.js";import"./chunk-68pvvd7v.js";export{Gl as createImageHandler,va as handleImageRequest};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{g,vi,Qc,el,hg,yg,bg,wg,vg,Ks,xg,Be,Z,Fe,Sg,Rr,kg,rl,sl,ki,ze,s,xn,ol,m,ge,iy}from"./chunk-mv48q1p4.js";import"./chunk-e8zpzt9s.js";import"./chunk-v4bqmzj9.js";import"./chunk-0dmpc70r.js";import"./chunk-xppm4cs4.js";import"./chunk-ngnvyqk3.js";export{sl as SIGNAL_COMPOSABLE_CALL,ge as clearComponentCache,ki as componentClientSignalNames,vi as convertToCommonJS,m as createDetailedErrorMessage,vg as extractDirectiveNames,Qc as extractScriptFromTemplate,g as extractVariables,s as fileExists,iy as getComponentCacheStats,yg as getPositionInfo,Z as getSharedTranspiler,ol as getSourceLineInfo,wg as hasDirectives,el as hasVariables,kg as isHydrateTrigger,xg as isJavaScriptScript,ze as renderComponentWithSlot,xn as resolveTemplatePath,Sg as scopeOnRootElement,Ks as scopeSequenceKey,Be as shouldTranspileTypeScript,rl as slotContentHasExpressions,Fe as transpileTypeScript,Rr as userComponentFileExists,bg as validateDirective,hg as validateTemplate};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{dt,pt,ft}from"./chunk-w032x0zm.js";export{dt as createContext,pt as updateContextStoryFiles,ft as updateContextTree};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{zo,Ho,Vo,Fh,gs,zh}from"./chunk-q0jmc3m4.js";export{gs as clearImageDeliveryCatalog,Fh as deliveredImage,Vo as efficientDeliverySources,zo as getImageDelivery,Ho as isTransparentImage,zh as prepareImageDelivery};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Vi,Ui,Wi,Wg,qi,Ki,qg,Gi,Xi,Il,Kg}from"./chunk-jr346anv.js";export{Vi as VideoProcessorCache,Il as analyzeVideo,Wg as clearVideoCache,Xi as generateDASHManifest,Gi as generateHLSManifest,qi as generatePoster,qg as generateSpriteSheet,Ki as generateThumbnails,Ui as getCachedVideoResult,Kg as processVideo,Wi as setCachedVideoResult};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Hh,Vh,zf,ms}from"./chunk-q0jmc3m4.js";import"./chunk-8qe34jb8.js";import"./chunk-v8p8t3t4.js";import"./chunk-zswtgwxg.js";import{Tr}from"./chunk-mv48q1p4.js";import"./chunk-e8zpzt9s.js";import"./chunk-v4bqmzj9.js";import{it}from"./chunk-0dmpc70r.js";import"./chunk-xppm4cs4.js";import"./chunk-ngnvyqk3.js";export{it as freeIdentifiers,ms as processComponents,zf as processESImports,Tr as rendersAsElement,Hh as resetMarginStackWarnings,Vh as resetTemplateLoopWarnings};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{ri,si,oi,ii,$s,Rs,ey,ty,ny,ry,As,sy}from"./chunk-vw73gsxx.js";import"./chunk-0dmpc70r.js";export{sy as generateDefaultRobotsTxt,As as generateRobotsTxt,ty as generateSitemap,ny as generateSitemapIndex,ii as injectSeoTags,$s as metaDirective,ri as processMetaDirectives,oi as processSeoDirective,si as processStructuredData,ey as registerSeoDirectives,ry as scanForSitemapEntries,Rs as structuredDataDirective};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{jh,Ff,Ye,fc,Bh,us,ds,ps}from"./chunk-xfb7fdeq.js";import"./chunk-q0jmc3m4.js";import"./chunk-8qe34jb8.js";import"./chunk-v8p8t3t4.js";import"./chunk-zswtgwxg.js";import"./chunk-mv48q1p4.js";import"./chunk-e8zpzt9s.js";import"./chunk-v4bqmzj9.js";import"./chunk-0dmpc70r.js";import"./chunk-xppm4cs4.js";import"./chunk-ngnvyqk3.js";export{Bh as clearOnceStore,fc as onceStore,Ye as partialsCache,us as processIncludes,ds as processStackPushDirectives,ps as processStackReplacements,jh as resetUnscopedSignalWarnings,Ff as topLevelElements};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{ai,ci,_t,de,hr,Ps,yr,Is,Os,Yf,Zf,Qf,br,eg,tg,ng,rg,Pc,Ic,Oc,li,Nc,sg,Ct,Et,Tt,$t,Rt,At,nt,og}from"./chunk-9r999ees.js";export{yr as Router,ng as abortNavigation,Ps as bracketPathToRegex,Ct as clearMiddleware,Ic as createClientCookieManager,Rt as createMiddlewareContext,$t as createRouteLocation,Pc as createServerCookieManager,Oc as createStorageManager,rg as defineMiddleware,Zf as defineRoute,Qf as defineRoutes,Is as findErrorPage,Os as formatRoutes,ci as generateRouteManifest,ai as generateRouteTypes,Nc as getMiddleware,Et as getMiddlewareNames,nt as getRouterScript,og as getRouterScriptDev,sg as hasMiddleware,_t as isFileRequestPath,Tt as loadMiddlewareFromDirectory,hr as matchRoute,tg as navigateTo,de as patternToRegex,li as registerMiddleware,eg as resetRoutes,br as route,At as runMiddleware,Yf as setAppUrl};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{xe,Gs,_g,ay,Cg,cy,Sn,p,W,Q,kn,ke,Eg,Ci,Tg,ly,E,Ei,$g,uy,A,dy}from"./chunk-mv48q1p4.js";import"./chunk-e8zpzt9s.js";import"./chunk-v4bqmzj9.js";import"./chunk-0dmpc70r.js";import"./chunk-xppm4cs4.js";import"./chunk-ngnvyqk3.js";export{$g as applyFilters,cy as clearCustomFilters,Eg as clientLoopScopes,Gs as defaultFilters,kn as escapeAttributeValue,p as escapeHtml,W as escapeHtmlValue,Q as escapeInterpolatedHtmlValue,A as evaluateExpression,xe as findMustacheEnd,Cg as getAllFilters,Tg as interpolateScriptAttributes,Ci as interpolateScriptExpressions,ly as interpolateScriptsInTemplate,E as processExpressions,Ei as processExpressionsChunked,_g as registerFilter,ay as registerFilters,Sn as replaceInterpolations,uy as resetRejectedExpressionWarnings,dy as unescapeHtml,ke as usesSignalsInScript};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Mf,dc,Mh,pc,Df,Lf,dn,cr,Dh,jf,Bf,Lh,b}from"./chunk-9hvfmqs1.js";import"./chunk-k0arm18k.js";import"./chunk-mv48q1p4.js";import"./chunk-e8zpzt9s.js";import"./chunk-v4bqmzj9.js";import"./chunk-0dmpc70r.js";import"./chunk-xppm4cs4.js";import"./chunk-ngnvyqk3.js";export{dn as buildCss,jf as extractClassNames,Lf as fingerprintConfig,Bf as generateCss,Dh as getCachedCSS,Mf as getCssServeAsset,b as injectCss,dc as loadCssEngine,pc as loadCssEngineConfig,cr as rebuildCss,Mh as resetCssCache,Df as resolveUserCssConfig,Lh as withLinkedModuleBundles};