reroute-js 1.0.0-alpha.11 → 1.0.0-alpha.13

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 (208) hide show
  1. package/cli/bin.d.ts +1 -1
  2. package/cli/bin.js +342 -274
  3. package/cli/bin.js.map +9 -8
  4. package/cli/index.d.ts +1 -1
  5. package/cli/index.js +4 -4
  6. package/cli/index.js.map +3 -3
  7. package/cli/src/cli.d.ts +1 -1
  8. package/cli/src/commands/analyze.d.ts +1 -1
  9. package/cli/src/commands/build.d.ts +1 -1
  10. package/cli/src/commands/dev.d.ts +1 -1
  11. package/cli/src/commands/gen.d.ts +1 -1
  12. package/cli/src/commands/gen.d.ts.map +1 -1
  13. package/cli/src/commands/index.d.ts +1 -1
  14. package/cli/src/commands/init.d.ts +1 -1
  15. package/cli/src/commands/lib/assets.d.ts +1 -1
  16. package/cli/src/commands/lib/bundler.d.ts +1 -1
  17. package/cli/src/commands/lib/command.d.ts +1 -1
  18. package/cli/src/commands/lib/env.d.ts +1 -1
  19. package/cli/src/commands/lib/index.d.ts +1 -1
  20. package/cli/src/commands/lib/log.d.ts +1 -1
  21. package/cli/src/commands/lib/markdown/availability.d.ts +1 -1
  22. package/cli/src/commands/lib/markdown/index.d.ts +1 -1
  23. package/cli/src/commands/lib/markdown/processor.d.ts +1 -1
  24. package/cli/src/commands/lib/production.d.ts +1 -1
  25. package/cli/src/commands/lib/server.d.ts +1 -1
  26. package/cli/src/commands/lib/streaming/analyzer.d.ts +1 -1
  27. package/cli/src/commands/lib/streaming/suspense.d.ts +1 -1
  28. package/cli/src/commands/lib/terminal-ui.d.ts +1 -1
  29. package/cli/src/commands/lib/theme.d.ts +2 -2
  30. package/cli/src/commands/lib/theme.d.ts.map +1 -1
  31. package/cli/src/commands/lib/version.d.ts +1 -1
  32. package/cli/src/commands/lib/watch.d.ts +26 -0
  33. package/cli/src/commands/lib/watch.d.ts.map +1 -0
  34. package/cli/src/commands/og.d.ts +1 -1
  35. package/cli/src/commands/start.d.ts +1 -1
  36. package/cli/src/index.d.ts +1 -1
  37. package/core/index.d.ts +1 -1
  38. package/core/index.js +34 -31
  39. package/core/index.js.map +5 -5
  40. package/core/src/bundler/hash.d.ts +1 -1
  41. package/core/src/bundler/index.d.ts +1 -1
  42. package/core/src/config.d.ts +6 -5
  43. package/core/src/config.d.ts.map +1 -1
  44. package/core/src/content/discovery.d.ts +1 -1
  45. package/core/src/content/index.d.ts +1 -1
  46. package/core/src/content/metadata.d.ts +1 -1
  47. package/core/src/i18n/catalog.d.ts +1 -1
  48. package/core/src/i18n/discover.d.ts +1 -1
  49. package/core/src/i18n/index.d.ts +1 -1
  50. package/core/src/i18n/messages.d.ts +1 -1
  51. package/core/src/i18n/negotiate.d.ts +1 -1
  52. package/core/src/i18n/pathname.d.ts +1 -1
  53. package/core/src/i18n/resolve.d.ts +1 -1
  54. package/core/src/i18n/types.d.ts +1 -1
  55. package/core/src/index.d.ts +1 -1
  56. package/core/src/llms/discovery.d.ts +1 -1
  57. package/core/src/llms/extractor.d.ts +1 -1
  58. package/core/src/llms/formatter.d.ts +1 -1
  59. package/core/src/llms/full-generator.d.ts +1 -1
  60. package/core/src/llms/index-generator.d.ts +1 -1
  61. package/core/src/llms/index.d.ts +1 -1
  62. package/core/src/og/discovery.d.ts +1 -1
  63. package/core/src/og/index.d.ts +1 -1
  64. package/core/src/og/meta.d.ts +1 -1
  65. package/core/src/og/render.d.ts +1 -1
  66. package/core/src/og/types.d.ts +1 -1
  67. package/core/src/robots/discovery.d.ts +1 -1
  68. package/core/src/robots/generator.d.ts +1 -1
  69. package/core/src/robots/index.d.ts +1 -1
  70. package/core/src/robots/policies.d.ts +1 -1
  71. package/core/src/rss/discovery.d.ts +1 -1
  72. package/core/src/rss/generator.d.ts +1 -1
  73. package/core/src/rss/index.d.ts +1 -1
  74. package/core/src/sitemap/discovery.d.ts +1 -1
  75. package/core/src/sitemap/generator.d.ts +1 -1
  76. package/core/src/sitemap/index.d.ts +1 -1
  77. package/core/src/ssr/index.d.ts +1 -1
  78. package/core/src/ssr/lib/cache.d.ts +1 -1
  79. package/core/src/ssr/lib/cleanup.d.ts +1 -1
  80. package/core/src/ssr/lib/collections.d.ts +1 -1
  81. package/core/src/ssr/lib/compression.d.ts +1 -1
  82. package/core/src/ssr/lib/compute/content.d.ts +1 -1
  83. package/core/src/ssr/lib/compute/index.d.ts +1 -1
  84. package/core/src/ssr/lib/compute/layouts.d.ts +1 -1
  85. package/core/src/ssr/lib/compute/routes.d.ts +1 -1
  86. package/core/src/ssr/lib/content-path.d.ts +1 -1
  87. package/core/src/ssr/lib/data.d.ts +1 -1
  88. package/core/src/ssr/lib/html.d.ts +1 -1
  89. package/core/src/ssr/lib/imports.d.ts +1 -1
  90. package/core/src/ssr/lib/index.d.ts +1 -1
  91. package/core/src/ssr/lib/layouts.d.ts +1 -1
  92. package/core/src/ssr/lib/metadata.d.ts +1 -1
  93. package/core/src/ssr/lib/mime.d.ts +1 -1
  94. package/core/src/ssr/lib/modules.d.ts +1 -1
  95. package/core/src/ssr/lib/path.d.ts +1 -1
  96. package/core/src/ssr/lib/preload.d.ts +1 -1
  97. package/core/src/ssr/lib/route-match.d.ts +1 -1
  98. package/core/src/ssr/lib/scripts/collections.d.ts +1 -1
  99. package/core/src/ssr/lib/scripts/data.d.ts +1 -1
  100. package/core/src/ssr/lib/scripts/escape.d.ts +1 -1
  101. package/core/src/ssr/lib/scripts/feeds.d.ts +1 -1
  102. package/core/src/ssr/lib/scripts/index.d.ts +1 -1
  103. package/core/src/ssr/lib/seed.d.ts +1 -1
  104. package/core/src/ssr/lib/serialize.d.ts +1 -1
  105. package/core/src/ssr/lib/setup.d.ts +1 -1
  106. package/core/src/ssr/lib/styles.d.ts +7 -4
  107. package/core/src/ssr/lib/styles.d.ts.map +1 -1
  108. package/core/src/ssr/lib/template.d.ts +1 -1
  109. package/core/src/ssr/lib/types.d.ts +1 -1
  110. package/core/src/ssr/render.d.ts +1 -1
  111. package/core/src/ssr/stream.d.ts +1 -1
  112. package/elysia/index.d.ts +1 -1
  113. package/elysia/index.js +114 -60
  114. package/elysia/index.js.map +12 -11
  115. package/elysia/src/index.d.ts +1 -1
  116. package/elysia/src/libs/assets.d.ts +1 -1
  117. package/elysia/src/libs/cache.d.ts +6 -1
  118. package/elysia/src/libs/cache.d.ts.map +1 -1
  119. package/elysia/src/libs/caching.d.ts +1 -1
  120. package/elysia/src/libs/http.d.ts +1 -1
  121. package/elysia/src/libs/i18n.d.ts +1 -1
  122. package/elysia/src/libs/image.d.ts +1 -1
  123. package/elysia/src/libs/index.d.ts +1 -1
  124. package/elysia/src/libs/llms.d.ts +1 -1
  125. package/elysia/src/libs/response.d.ts +1 -1
  126. package/elysia/src/libs/serving.d.ts +1 -1
  127. package/elysia/src/plugin.d.ts +1 -1
  128. package/elysia/src/plugin.d.ts.map +1 -1
  129. package/elysia/src/routes/artifacts.d.ts +1 -1
  130. package/elysia/src/routes/artifacts.d.ts.map +1 -1
  131. package/elysia/src/routes/content.d.ts +1 -1
  132. package/elysia/src/routes/image.d.ts +1 -1
  133. package/elysia/src/routes/index.d.ts +1 -1
  134. package/elysia/src/routes/internal.d.ts +1 -1
  135. package/elysia/src/routes/internal.d.ts.map +1 -1
  136. package/elysia/src/routes/liveReloadClient.d.ts +16 -0
  137. package/elysia/src/routes/liveReloadClient.d.ts.map +1 -0
  138. package/elysia/src/routes/llms.d.ts +1 -1
  139. package/elysia/src/routes/og.d.ts +1 -1
  140. package/elysia/src/routes/redirects.d.ts +1 -1
  141. package/elysia/src/routes/robots.d.ts +1 -1
  142. package/elysia/src/routes/rss.d.ts +1 -1
  143. package/elysia/src/routes/search.d.ts +1 -1
  144. package/elysia/src/routes/sitemap.d.ts +1 -1
  145. package/elysia/src/routes/ssr.d.ts +1 -1
  146. package/elysia/src/routes/ssr.d.ts.map +1 -1
  147. package/elysia/src/routes/static.d.ts +1 -1
  148. package/elysia/src/routes/themeCssRefresh.d.ts +1 -1
  149. package/elysia/src/types.d.ts +1 -1
  150. package/package.json +1 -1
  151. package/react/index.d.ts +1 -1
  152. package/react/index.js +2 -2
  153. package/react/index.js.map +1 -1
  154. package/react/src/components/ClientOnly.d.ts +1 -1
  155. package/react/src/components/ContentRoute.d.ts +1 -1
  156. package/react/src/components/Image.d.ts +1 -1
  157. package/react/src/components/LazyRoute.d.ts +1 -1
  158. package/react/src/components/Link.d.ts +1 -1
  159. package/react/src/components/Markdown.d.ts +1 -1
  160. package/react/src/components/Outlet.d.ts +1 -1
  161. package/react/src/components/index.d.ts +1 -1
  162. package/react/src/hooks/index.d.ts +1 -1
  163. package/react/src/hooks/useContent.d.ts +1 -1
  164. package/react/src/hooks/useData.d.ts +1 -1
  165. package/react/src/hooks/useFeed.d.ts +1 -1
  166. package/react/src/hooks/useLayoutData.d.ts +1 -1
  167. package/react/src/hooks/useLlms.d.ts +1 -1
  168. package/react/src/hooks/useNavigate.d.ts +1 -1
  169. package/react/src/hooks/useParams.d.ts +1 -1
  170. package/react/src/hooks/useRouter.d.ts +1 -1
  171. package/react/src/hooks/useSearch.d.ts +1 -1
  172. package/react/src/hooks/useSearchParams.d.ts +1 -1
  173. package/react/src/hooks/useToc.d.ts +1 -1
  174. package/react/src/i18n/LocaleProvider.d.ts +1 -1
  175. package/react/src/i18n/helpers.d.ts +1 -1
  176. package/react/src/i18n/index.d.ts +1 -1
  177. package/react/src/index.d.ts +1 -1
  178. package/react/src/lib/collection.d.ts +1 -1
  179. package/react/src/lib/content.d.ts +1 -1
  180. package/react/src/lib/head.d.ts +1 -1
  181. package/react/src/lib/index.d.ts +1 -1
  182. package/react/src/lib/lazy-route.d.ts +1 -1
  183. package/react/src/lib/route-loader.d.ts +1 -1
  184. package/react/src/providers/ContentProvider.d.ts +1 -1
  185. package/react/src/providers/RerouteProvider.d.ts +1 -1
  186. package/react/src/providers/RouterProvider.d.ts +1 -1
  187. package/react/src/providers/index.d.ts +1 -1
  188. package/react/src/types/any.d.ts +1 -1
  189. package/react/src/types/index.d.ts +1 -1
  190. package/react/src/types/router.d.ts +1 -1
  191. package/telemetry/react.d.ts +1 -1
  192. package/telemetry/react.js +2 -2
  193. package/telemetry/react.js.map +1 -1
  194. package/telemetry/server.d.ts +1 -1
  195. package/telemetry/server.js +2 -2
  196. package/telemetry/server.js.map +4 -4
  197. package/telemetry/src/react/api.d.ts +1 -1
  198. package/telemetry/src/react/context.d.ts +1 -1
  199. package/telemetry/src/react/index.d.ts +1 -1
  200. package/telemetry/src/react/telemetry.d.ts +1 -1
  201. package/telemetry/src/server/context.d.ts +1 -1
  202. package/telemetry/src/server/headers/extractor.d.ts +1 -1
  203. package/telemetry/src/server/headers/index.d.ts +1 -1
  204. package/telemetry/src/server/headers/presets.d.ts +1 -1
  205. package/telemetry/src/server/index.d.ts +1 -1
  206. package/telemetry/src/server/instrumentation.d.ts +1 -1
  207. package/telemetry/src/server/plugin.d.ts +1 -1
  208. package/telemetry/src/server/sourcemap.d.ts +1 -1
package/cli/bin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
3
  /**
4
- * reroute-js v1.0.0-alpha.11
4
+ * reroute-js v1.0.0-alpha.13
5
5
  *
6
6
  * @license MIT
7
7
  * @copyright 2026 stewones <hi@stewan.io>
@@ -68,7 +68,7 @@ async function getVersionString() {
68
68
  }
69
69
  async function getVersion() {
70
70
  if (true) {
71
- return "1.0.0-alpha.11";
71
+ return "1.0.0-alpha.13";
72
72
  }
73
73
  const possiblePaths = [
74
74
  path.join(import.meta.dir, "../../../../package.json"),
@@ -86,7 +86,7 @@ async function getVersion() {
86
86
  }
87
87
  async function getCommit() {
88
88
  if (true) {
89
- return "560df44";
89
+ return "b24033d";
90
90
  }
91
91
  return "dev";
92
92
  }
@@ -3834,42 +3834,45 @@ var init_scripts = __esm(() => {
3834
3834
  });
3835
3835
 
3836
3836
  // packages/core/src/ssr/lib/styles.ts
3837
- async function inlineThemeCSS(clientDir, minify = false, isWatchMode = false) {
3837
+ import { createHash } from "node:crypto";
3838
+ function themeLink(query) {
3839
+ return `<link rel="stylesheet" href="${THEME_CSS_HREF}?${query}" data-reroute="theme">`;
3840
+ }
3841
+ function hashCss(css) {
3842
+ return createHash("sha1").update(css).digest("hex").slice(0, 12);
3843
+ }
3844
+ async function readThemeCssFromDisk(clientDir) {
3845
+ const candidates = [
3846
+ join2(clientDir, "..", ".reroute", "index.css"),
3847
+ join2(clientDir, "..", "..", ".reroute", "index.css"),
3848
+ join2(clientDir, "..", "..", "..", ".reroute", "index.css"),
3849
+ join2(clientDir, "..", "..", "..", "..", ".reroute", "index.css")
3850
+ ];
3851
+ for (const cssPath of candidates) {
3852
+ if (await Bun.file(cssPath).exists()) {
3853
+ const { readFileSync } = await import("node:fs");
3854
+ return readFileSync(cssPath, "utf-8");
3855
+ }
3856
+ }
3857
+ return "";
3858
+ }
3859
+ function bundledThemeCss() {
3860
+ return globalThis.__REROUTE_THEME_CSS__ || "";
3861
+ }
3862
+ async function inlineThemeCSS(clientDir, isWatchMode = false) {
3838
3863
  try {
3839
3864
  if (isWatchMode) {
3840
- const timestamp = Date.now();
3841
- return `<link rel="stylesheet" href="/.reroute/index.css?t=${timestamp}" data-reroute="theme">`;
3842
- }
3843
- const bundledCss = globalThis.__REROUTE_THEME_CSS__;
3844
- if (bundledCss) {
3845
- const css2 = minify ? minifyCSS(bundledCss) : bundledCss;
3846
- return `<style data-reroute="theme">${css2}</style>`;
3847
- }
3848
- const candidates = [
3849
- join2(clientDir, "..", ".reroute", "index.css"),
3850
- join2(clientDir, "..", "..", ".reroute", "index.css"),
3851
- join2(clientDir, "..", "..", "..", ".reroute", "index.css"),
3852
- join2(clientDir, "..", "..", "..", "..", ".reroute", "index.css")
3853
- ];
3854
- let cssPath = "";
3855
- for (const p of candidates) {
3856
- if (await Bun.file(p).exists()) {
3857
- cssPath = p;
3858
- break;
3859
- }
3865
+ return themeLink(`t=${Date.now()}`);
3860
3866
  }
3861
- if (!cssPath)
3867
+ const css = bundledThemeCss() || await readThemeCssFromDisk(clientDir);
3868
+ if (!css)
3862
3869
  return "";
3863
- const { readFileSync } = await import("node:fs");
3864
- const css = readFileSync(cssPath, "utf-8");
3865
- return `<style data-reroute="theme">${minifyCSS(css)}</style>`;
3870
+ return themeLink(`v=${hashCss(css)}`);
3866
3871
  } catch {
3867
3872
  return "";
3868
3873
  }
3869
3874
  }
3870
- function minifyCSS(css) {
3871
- return css.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\s+/g, " ").replace(/\s*([{}:;,>+~])\s*/g, "$1").replace(/;}/g, "}").trim();
3872
- }
3875
+ var THEME_CSS_HREF = "/.reroute/index.css";
3873
3876
  var init_styles = () => {};
3874
3877
 
3875
3878
  // packages/core/src/ssr/lib/setup.ts
@@ -3976,7 +3979,7 @@ async function performSSRSetupInternal(options, streaming, timeoutState) {
3976
3979
  setGlobalCollections(byCollectionForSSR);
3977
3980
  const usingCachedCSS = !!options.cachedThemeCSS;
3978
3981
  const inlineStyleTag = await withSpan("ssr.inline.css", async (span) => {
3979
- const css = options.cachedThemeCSS ? options.cachedThemeCSS : await inlineThemeCSS(clientDir, !streaming, isWatchMode);
3982
+ const css = options.cachedThemeCSS ? options.cachedThemeCSS : await inlineThemeCSS(clientDir, isWatchMode);
3980
3983
  span.setAttributes({
3981
3984
  "reroute.cached": usingCachedCSS,
3982
3985
  "reroute.css.size": css.length
@@ -7823,6 +7826,51 @@ var init_theme = __esm(() => {
7823
7826
  IMPORT_RE = /@import\s+(?:url\(\s*)?(?:'([^']+)'|"([^"]+)"|([^'")\s]+))\s*\)?\s*([^;]*);/g;
7824
7827
  });
7825
7828
 
7829
+ // packages/cli/src/commands/lib/watch.ts
7830
+ import { createHash as createHash2 } from "node:crypto";
7831
+ import { readFile } from "node:fs/promises";
7832
+ import { join as join11 } from "node:path";
7833
+ function isWatchNoise(name) {
7834
+ return name.split(/[/\\]/).some((part) => part.startsWith(".")) || /\.bust-[^/\\]+$/.test(name);
7835
+ }
7836
+ function createContentFingerprint(options) {
7837
+ const hashes = new Map;
7838
+ const startedAt = Date.now();
7839
+ const settleMs = options?.settleMs ?? 500;
7840
+ return {
7841
+ async changed(absPath) {
7842
+ const settling = Date.now() - startedAt < settleMs;
7843
+ try {
7844
+ const buf = await readFile(absPath);
7845
+ const hash2 = createHash2("sha1").update(buf).digest("hex");
7846
+ const prev = hashes.get(absPath);
7847
+ if (prev === hash2)
7848
+ return false;
7849
+ hashes.set(absPath, hash2);
7850
+ if (prev === undefined)
7851
+ return !settling;
7852
+ return true;
7853
+ } catch {
7854
+ if (hashes.has(absPath)) {
7855
+ hashes.delete(absPath);
7856
+ return !settling;
7857
+ }
7858
+ return false;
7859
+ }
7860
+ }
7861
+ };
7862
+ }
7863
+ async function retainChangedFiles(root, names, fingerprint) {
7864
+ const changed = [];
7865
+ for (const name of names) {
7866
+ if (await fingerprint.changed(join11(root, name))) {
7867
+ changed.push(name);
7868
+ }
7869
+ }
7870
+ return changed;
7871
+ }
7872
+ var init_watch = () => {};
7873
+
7826
7874
  // packages/cli/src/commands/gen.ts
7827
7875
  var exports_gen = {};
7828
7876
  __export(exports_gen, {
@@ -7831,14 +7879,11 @@ __export(exports_gen, {
7831
7879
  });
7832
7880
  import { watch } from "node:fs";
7833
7881
  import { copyFile as copyFile2, mkdir as mkdir3, readdir as readdir7, rm, unlink as unlink2 } from "node:fs/promises";
7834
- import { dirname as dirname7, extname as extname4, join as join11 } from "node:path";
7882
+ import { dirname as dirname7, extname as extname4, join as join12 } from "node:path";
7835
7883
  import { pathToFileURL as pathToFileURL8 } from "node:url";
7836
- function isWatchNoise(name) {
7837
- return name.split(/[/\\]/).some((part) => part.startsWith(".")) || /\.bust-[^/\\]+$/.test(name);
7838
- }
7839
7884
  async function bundleThemeCssIntoArtifacts(cwd) {
7840
- const cssPath = join11(cwd, ".reroute", "index.css");
7841
- const artifactsPath = join11(cwd, OUTPUT_ARTIFACTS);
7885
+ const cssPath = join12(cwd, ".reroute", "index.css");
7886
+ const artifactsPath = join12(cwd, OUTPUT_ARTIFACTS);
7842
7887
  try {
7843
7888
  const cssContent = await Bun.file(cssPath).text();
7844
7889
  if (!cssContent)
@@ -7864,7 +7909,7 @@ async function bundleThemeCssIntoArtifacts(cwd) {
7864
7909
  async function ensureOutputDir(cwd, options = {}) {
7865
7910
  const { clean = true } = options;
7866
7911
  try {
7867
- const outputPath = join11(cwd, OUTPUT_DIR);
7912
+ const outputPath = join12(cwd, OUTPUT_DIR);
7868
7913
  if (clean) {
7869
7914
  let needsCleanup = false;
7870
7915
  try {
@@ -7877,9 +7922,9 @@ async function ensureOutputDir(cwd, options = {}) {
7877
7922
  }
7878
7923
  }
7879
7924
  await mkdir3(outputPath, { recursive: true });
7880
- await mkdir3(join11(cwd, OUTPUT_COLLECTIONS_DIR), { recursive: true });
7881
- await mkdir3(join11(cwd, ".reroute/bundles"), { recursive: true });
7882
- await mkdir3(join11(cwd, ".reroute/streaming"), { recursive: true });
7925
+ await mkdir3(join12(cwd, OUTPUT_COLLECTIONS_DIR), { recursive: true });
7926
+ await mkdir3(join12(cwd, ".reroute/bundles"), { recursive: true });
7927
+ await mkdir3(join12(cwd, ".reroute/streaming"), { recursive: true });
7883
7928
  } catch {}
7884
7929
  }
7885
7930
  async function writeStubFiles(cwd) {
@@ -7937,11 +7982,11 @@ import './artifacts';
7937
7982
  import './routes'; // Import routes (bundles all route components)
7938
7983
  import '../src/index';
7939
7984
  `;
7940
- await Bun.write(join11(cwd, OUTPUT_ROUTES), STUB_ROUTES);
7941
- await Bun.write(join11(cwd, OUTPUT_CONTENT_TS), STUB_CONTENT);
7942
- await Bun.write(join11(cwd, OUTPUT_ARTIFACTS), STUB_ARTIFACTS);
7943
- await Bun.write(join11(cwd, OUTPUT_INDEX), STUB_INDEX);
7944
- await Bun.write(join11(cwd, ".reroute/entry.ts"), STUB_ENTRY);
7985
+ await Bun.write(join12(cwd, OUTPUT_ROUTES), STUB_ROUTES);
7986
+ await Bun.write(join12(cwd, OUTPUT_CONTENT_TS), STUB_CONTENT);
7987
+ await Bun.write(join12(cwd, OUTPUT_ARTIFACTS), STUB_ARTIFACTS);
7988
+ await Bun.write(join12(cwd, OUTPUT_INDEX), STUB_INDEX);
7989
+ await Bun.write(join12(cwd, ".reroute/entry.ts"), STUB_ENTRY);
7945
7990
  console.log("[reroute/gen] Initialized stub files");
7946
7991
  }
7947
7992
  function shouldSkipFile(relativePath, entryName) {
@@ -7963,8 +8008,8 @@ async function scanDirectory(dir, base = "") {
7963
8008
  const files = [];
7964
8009
  const entries = await readdir7(dir, { withFileTypes: true });
7965
8010
  for (const entry of entries) {
7966
- const fullPath = join11(dir, entry.name);
7967
- const relativePath = join11(base, entry.name);
8011
+ const fullPath = join12(dir, entry.name);
8012
+ const relativePath = join12(base, entry.name);
7968
8013
  if (entry.isDirectory()) {
7969
8014
  if (entry.name === "content")
7970
8015
  continue;
@@ -7982,8 +8027,8 @@ async function scan404Files(dir, base = "") {
7982
8027
  const files = [];
7983
8028
  const entries = await readdir7(dir, { withFileTypes: true });
7984
8029
  for (const entry of entries) {
7985
- const fullPath = join11(dir, entry.name);
7986
- const relativePath = join11(base, entry.name);
8030
+ const fullPath = join12(dir, entry.name);
8031
+ const relativePath = join12(base, entry.name);
7987
8032
  if (entry.isDirectory()) {
7988
8033
  const nested = await scan404Files(fullPath, relativePath);
7989
8034
  files.push(...nested);
@@ -7998,8 +8043,8 @@ async function scanOgFiles(dir, base = "") {
7998
8043
  const files = [];
7999
8044
  const entries = await readdir7(dir, { withFileTypes: true });
8000
8045
  for (const entry of entries) {
8001
- const fullPath = join11(dir, entry.name);
8002
- const relativePath = join11(base, entry.name);
8046
+ const fullPath = join12(dir, entry.name);
8047
+ const relativePath = join12(base, entry.name);
8003
8048
  if (entry.isDirectory()) {
8004
8049
  if (entry.name === "content")
8005
8050
  continue;
@@ -8253,7 +8298,7 @@ function matchPattern(route: Route, pathname: string): Record<string, string> |
8253
8298
  `;
8254
8299
  }
8255
8300
  async function buildStreamingWrappersForTree(cwd, routesPath, tree, config2) {
8256
- const streamingDir = join11(cwd, ".reroute", "streaming");
8301
+ const streamingDir = join12(cwd, ".reroute", "streaming");
8257
8302
  const analyses = new Map;
8258
8303
  const candidates = [
8259
8304
  ...tree.routes.map((route) => ({
@@ -8272,7 +8317,7 @@ async function buildStreamingWrappersForTree(cwd, routesPath, tree, config2) {
8272
8317
  for (const candidate of candidates) {
8273
8318
  if (!/\.(tsx|ts)$/.test(candidate.filePath))
8274
8319
  continue;
8275
- const absolutePath = join11(routesPath, candidate.filePath);
8320
+ const absolutePath = join12(routesPath, candidate.filePath);
8276
8321
  const analysis = await analyzeRouteForStreaming({
8277
8322
  absolutePath,
8278
8323
  relativePath: candidate.filePath,
@@ -8281,7 +8326,7 @@ async function buildStreamingWrappersForTree(cwd, routesPath, tree, config2) {
8281
8326
  });
8282
8327
  if (!analysis.needsStreaming)
8283
8328
  continue;
8284
- const wrapperPath = join11(streamingDir, candidate.filePath).replace(/\.(tsx|ts)$/, ".tsx");
8329
+ const wrapperPath = join12(streamingDir, candidate.filePath).replace(/\.(tsx|ts)$/, ".tsx");
8285
8330
  await mkdir3(dirname7(wrapperPath), { recursive: true });
8286
8331
  const code = await generateStreamingWrapper({
8287
8332
  cwd,
@@ -8306,13 +8351,13 @@ function isContentFileName(name) {
8306
8351
  }
8307
8352
  async function listLocaleContentFiles(collectionDir, locale) {
8308
8353
  try {
8309
- const nested = await readdir7(join11(collectionDir, locale), {
8354
+ const nested = await readdir7(join12(collectionDir, locale), {
8310
8355
  withFileTypes: true
8311
8356
  });
8312
8357
  const files = [];
8313
8358
  for (const n of nested) {
8314
8359
  if (n.isFile() && isContentFileName(n.name)) {
8315
- files.push({ relativePath: join11(locale, n.name), locale });
8360
+ files.push({ relativePath: join12(locale, n.name), locale });
8316
8361
  }
8317
8362
  }
8318
8363
  return files;
@@ -8350,7 +8395,7 @@ async function loadContentMeta(absSrc, buildSrc, isMarkdown) {
8350
8395
  if (isMarkdown) {
8351
8396
  return processMarkdownFile(absSrc).frontmatter || {};
8352
8397
  }
8353
- const tmp = join11(dirname7(buildSrc), `.meta-${Date.now()}-${Math.random().toString(36).slice(2)}${extname4(buildSrc)}`);
8398
+ const tmp = join12(dirname7(buildSrc), `.meta-${Date.now()}-${Math.random().toString(36).slice(2)}${extname4(buildSrc)}`);
8354
8399
  try {
8355
8400
  await copyFile2(buildSrc, tmp);
8356
8401
  const m = await import(pathToFileURL8(tmp).href);
@@ -8408,9 +8453,9 @@ async function buildSingleContentChunk(cwd, collection, fileRef, contentDir, arg
8408
8453
  const locale = fileRef.locale || defaultLocale;
8409
8454
  const baseName = file.split("/").pop() || file;
8410
8455
  const name = baseName.replace(/\.(tsx|ts|md|mdx)$/, "");
8411
- const absSrc = join11(contentDir, file);
8456
+ const absSrc = join12(contentDir, file);
8412
8457
  const isMarkdown = /\.(md|mdx)$/.test(file);
8413
- const buildSrc = isMarkdown ? join11(cwd, ".reroute", "markdown", collection, "content", file.replace(/\.(md|mdx)$/, ".tsx")) : absSrc;
8458
+ const buildSrc = isMarkdown ? join12(cwd, ".reroute", "markdown", collection, "content", file.replace(/\.(md|mdx)$/, ".tsx")) : absSrc;
8414
8459
  if (isMarkdown) {
8415
8460
  try {
8416
8461
  const exists = await Bun.file(buildSrc).exists();
@@ -8456,11 +8501,11 @@ async function buildSingleContentChunk(cwd, collection, fileRef, contentDir, arg
8456
8501
  return null;
8457
8502
  }
8458
8503
  const hash2 = await sha8(code);
8459
- const chunkRelDir = join11(".reroute", "bundles");
8460
- const chunkAbsDir = join11(cwd, chunkRelDir);
8504
+ const chunkRelDir = join12(".reroute", "bundles");
8505
+ const chunkAbsDir = join12(cwd, chunkRelDir);
8461
8506
  const localeSuffix = locale !== defaultLocale ? `${locale}-` : "";
8462
8507
  const outFile = `${collection}-${localeSuffix}${name}.${hash2}.js`;
8463
- const absOut = join11(chunkAbsDir, outFile);
8508
+ const absOut = join12(chunkAbsDir, outFile);
8464
8509
  if (sourcemapContent) {
8465
8510
  code = code.replace(/\/\/# sourceMappingURL=.*\.js\.map/, `//# sourceMappingURL=${outFile}.map`);
8466
8511
  }
@@ -8493,7 +8538,7 @@ async function buildSingleContentChunk(cwd, collection, fileRef, contentDir, arg
8493
8538
  };
8494
8539
  }
8495
8540
  async function buildContentChunks(cwd, args = [], defaultLocale = "en-US") {
8496
- const routesRoot = join11(cwd, ROUTES_DIR);
8541
+ const routesRoot = join12(cwd, ROUTES_DIR);
8497
8542
  console.log(`[reroute/content] scan ${routesRoot}`);
8498
8543
  const collections2 = await readdir7(routesRoot, { withFileTypes: true });
8499
8544
  const results = [];
@@ -8501,7 +8546,7 @@ async function buildContentChunks(cwd, args = [], defaultLocale = "en-US") {
8501
8546
  if (!c.isDirectory())
8502
8547
  continue;
8503
8548
  const collection = c.name;
8504
- const contentDir = join11(routesRoot, collection, "content");
8549
+ const contentDir = join12(routesRoot, collection, "content");
8505
8550
  console.log(`[reroute/content] collection ${collection} dir ${contentDir}`);
8506
8551
  const files = await listContentFiles2(contentDir);
8507
8552
  console.log(`[reroute/content] files ${files.length}`);
@@ -8553,7 +8598,7 @@ async function buildContentChunks(cwd, args = [], defaultLocale = "en-US") {
8553
8598
  lines.push("");
8554
8599
  const writes = [];
8555
8600
  writes.push({
8556
- path: join11(cwd, OUTPUT_CONTENT_TS),
8601
+ path: join12(cwd, OUTPUT_CONTENT_TS),
8557
8602
  content: lines.join(`
8558
8603
  `)
8559
8604
  });
@@ -8587,7 +8632,7 @@ async function buildContentChunks(cwd, args = [], defaultLocale = "en-US") {
8587
8632
  js.push("}");
8588
8633
  js.push("");
8589
8634
  writes.push({
8590
- path: join11(cwd, OUTPUT_COLLECTIONS_DIR, `${collection}.js`),
8635
+ path: join12(cwd, OUTPUT_COLLECTIONS_DIR, `${collection}.js`),
8591
8636
  content: js.join(`
8592
8637
  `)
8593
8638
  });
@@ -8611,7 +8656,7 @@ async function buildSearchIndex(cwd, config2, args = []) {
8611
8656
  minHeadingLevel = 1,
8612
8657
  maxHeadingLevel = 6
8613
8658
  } = searchConfig;
8614
- const routesRoot = join11(cwd, ROUTES_DIR);
8659
+ const routesRoot = join12(cwd, ROUTES_DIR);
8615
8660
  const collections2 = await readdir7(routesRoot, { withFileTypes: true });
8616
8661
  const i18n2 = await discoverI18n(cwd, config2.i18n);
8617
8662
  const defaultLocale = i18n2.defaultLocale;
@@ -8623,7 +8668,7 @@ async function buildSearchIndex(cwd, config2, args = []) {
8623
8668
  if (targetCollections.length > 0 && !targetCollections.includes(collection)) {
8624
8669
  continue;
8625
8670
  }
8626
- const contentDir = join11(routesRoot, collection, "content");
8671
+ const contentDir = join12(routesRoot, collection, "content");
8627
8672
  try {
8628
8673
  const files = await listContentFiles2(contentDir);
8629
8674
  for (const fileRef of files) {
@@ -8633,7 +8678,7 @@ async function buildSearchIndex(cwd, config2, args = []) {
8633
8678
  const baseName = file.split("/").pop() || file;
8634
8679
  const name = baseName.replace(/\.(md|mdx)$/, "");
8635
8680
  const locale = fileRef.locale || defaultLocale;
8636
- const filePath = join11(contentDir, file);
8681
+ const filePath = join12(contentDir, file);
8637
8682
  try {
8638
8683
  const processed = processMarkdownFile(filePath);
8639
8684
  const { frontmatter, content: content2 } = processed;
@@ -8681,13 +8726,13 @@ async function buildSearchIndex(cwd, config2, args = []) {
8681
8726
  generated: new Date().toISOString(),
8682
8727
  entries: searchIndex
8683
8728
  };
8684
- await Bun.write(join11(cwd, OUTPUT_SEARCH_INDEX), JSON.stringify(indexData, null, 2));
8685
- console.log(`[reroute/search] Generated search index with ${searchIndex.length} entries: ${join11(cwd, OUTPUT_SEARCH_INDEX)}`);
8729
+ await Bun.write(join12(cwd, OUTPUT_SEARCH_INDEX), JSON.stringify(indexData, null, 2));
8730
+ console.log(`[reroute/search] Generated search index with ${searchIndex.length} entries: ${join12(cwd, OUTPUT_SEARCH_INDEX)}`);
8686
8731
  }
8687
8732
  async function preprocessMarkdownFiles(cwd, config2) {
8688
8733
  console.log("[reroute/markdown] Starting markdown preprocessing...");
8689
- const routesPath = join11(cwd, ROUTES_DIR);
8690
- const markdownDir = join11(cwd, ".reroute", "markdown");
8734
+ const routesPath = join12(cwd, ROUTES_DIR);
8735
+ const markdownDir = join12(cwd, ".reroute", "markdown");
8691
8736
  try {
8692
8737
  await rm(markdownDir, { force: true, recursive: true });
8693
8738
  } catch {}
@@ -8697,8 +8742,8 @@ async function preprocessMarkdownFiles(cwd, config2) {
8697
8742
  try {
8698
8743
  const entries = await readdir7(dir, { withFileTypes: true });
8699
8744
  for (const entry of entries) {
8700
- const fullPath = join11(dir, entry.name);
8701
- const relativePath = join11(base, entry.name);
8745
+ const fullPath = join12(dir, entry.name);
8746
+ const relativePath = join12(base, entry.name);
8702
8747
  if (entry.isDirectory()) {
8703
8748
  const nested = await scanMarkdown(fullPath, relativePath);
8704
8749
  files.push(...nested);
@@ -8720,8 +8765,8 @@ async function preprocessMarkdownFiles(cwd, config2) {
8720
8765
  }
8721
8766
  console.log(`[reroute/markdown] Found ${markdownFiles.length} markdown file(s)`);
8722
8767
  for (const file of markdownFiles) {
8723
- const sourcePath = join11(routesPath, file);
8724
- const targetPath = join11(markdownDir, file.replace(/\.mdx?$/, ".tsx"));
8768
+ const sourcePath = join12(routesPath, file);
8769
+ const targetPath = join12(markdownDir, file.replace(/\.mdx?$/, ".tsx"));
8725
8770
  try {
8726
8771
  const processed = processMarkdownFile(sourcePath);
8727
8772
  const isMdx = file.endsWith(".mdx");
@@ -8747,8 +8792,8 @@ async function preprocessMarkdownFiles(cwd, config2) {
8747
8792
  }
8748
8793
  async function buildEntrypointBundle(cwd, args = []) {
8749
8794
  const buildStartTime = performance.now();
8750
- const clientDir = join11(cwd, "src", "client");
8751
- const entrypoint = join11(clientDir, "index.tsx");
8795
+ const clientDir = join12(cwd, "src", "client");
8796
+ const entrypoint = join12(clientDir, "index.tsx");
8752
8797
  const exists = await Bun.file(entrypoint).exists();
8753
8798
  if (!exists) {
8754
8799
  console.log("[reroute/gen] No index.tsx found, skipping bundle build");
@@ -8756,7 +8801,7 @@ async function buildEntrypointBundle(cwd, args = []) {
8756
8801
  }
8757
8802
  console.log("[reroute/gen] Building entrypoint bundle...");
8758
8803
  const isProd = args.includes("--prod");
8759
- const bundlesDir = join11(cwd, ".reroute", "bundles");
8804
+ const bundlesDir = join12(cwd, ".reroute", "bundles");
8760
8805
  await mkdir3(bundlesDir, { recursive: true });
8761
8806
  const mode = isProd ? "production" : "development";
8762
8807
  const publicEnv = getPublicEnvVars(cwd, mode);
@@ -8858,7 +8903,7 @@ async function buildEntrypointBundle(cwd, args = []) {
8858
8903
  const existingFiles = await readdir7(bundlesDir);
8859
8904
  for (const file of existingFiles) {
8860
8905
  if (/^(index|chunk|asset)\.[a-z0-9]+\.(js|css|js\.map|css\.map)(\.gz|\.br)?$/i.test(file) && !newFiles.has(file.replace(/\.(gz|br)$/, ""))) {
8861
- await rm(join11(bundlesDir, file), { force: true });
8906
+ await rm(join12(bundlesDir, file), { force: true });
8862
8907
  }
8863
8908
  }
8864
8909
  } catch (_error) {}
@@ -8874,7 +8919,7 @@ async function buildEntrypointBundle(cwd, args = []) {
8874
8919
  }
8875
8920
  }
8876
8921
  await Promise.all(outputs.map(async (output) => {
8877
- const destPath = join11(bundlesDir, output.fileName);
8922
+ const destPath = join12(bundlesDir, output.fileName);
8878
8923
  await Bun.write(destPath, output.content);
8879
8924
  if (shouldPreCompress) {
8880
8925
  const shouldCompress = /\.(js|css)$/i.test(output.fileName) && !output.fileName.endsWith(".map");
@@ -8943,7 +8988,7 @@ async function generate(cwd, args = [], options = {}) {
8943
8988
  await writeStubFiles(cwd);
8944
8989
  }
8945
8990
  await perfTrack("Markdown preprocessing", () => preprocessMarkdownFiles(cwd, config2));
8946
- const routesPath = join11(cwd, ROUTES_DIR);
8991
+ const routesPath = join12(cwd, ROUTES_DIR);
8947
8992
  try {
8948
8993
  await perfTrack("Routes generation", async () => {
8949
8994
  const files = await scanDirectory(routesPath);
@@ -8952,10 +8997,10 @@ async function generate(cwd, args = [], options = {}) {
8952
8997
  const tree = generateRouteTree(all.map((f) => f.replace(/\\/g, "/")));
8953
8998
  const streamingAnalyses = streamingEnabled ? await buildStreamingWrappersForTree(cwd, routesPath, tree, config2) : new Map;
8954
8999
  const ts = generateTypeScript(tree, streamingAnalyses);
8955
- await Bun.write(join11(cwd, OUTPUT_ROUTES), ts);
9000
+ await Bun.write(join12(cwd, OUTPUT_ROUTES), ts);
8956
9001
  });
8957
9002
  if (!showPerformance) {
8958
- console.log(`[reroute/gen] Generated routes: ${join11(cwd, OUTPUT_ROUTES)}`);
9003
+ console.log(`[reroute/gen] Generated routes: ${join12(cwd, OUTPUT_ROUTES)}`);
8959
9004
  }
8960
9005
  } catch (error) {
8961
9006
  console.error("[reroute/gen] Failed to generate routes:", error);
@@ -8964,7 +9009,7 @@ async function generate(cwd, args = [], options = {}) {
8964
9009
  const i18n2 = await discoverI18n(cwd, config2.i18n);
8965
9010
  const defaultLocale = i18n2.defaultLocale;
8966
9011
  try {
8967
- await Bun.write(join11(cwd, ".reroute", "i18n.json"), JSON.stringify({
9012
+ await Bun.write(join12(cwd, ".reroute", "i18n.json"), JSON.stringify({
8968
9013
  enabled: i18n2.enabled,
8969
9014
  defaultLocale: i18n2.defaultLocale,
8970
9015
  locales: i18n2.locales,
@@ -8981,7 +9026,7 @@ async function generate(cwd, args = [], options = {}) {
8981
9026
  try {
8982
9027
  await perfTrack("Content building", () => buildContentChunks(cwd, args, defaultLocale));
8983
9028
  if (!showPerformance) {
8984
- console.log(`[reroute/gen] Generated content: ${join11(cwd, OUTPUT_CONTENT_TS)} + collections/*.js`);
9029
+ console.log(`[reroute/gen] Generated content: ${join12(cwd, OUTPUT_CONTENT_TS)} + collections/*.js`);
8985
9030
  }
8986
9031
  } catch (error) {
8987
9032
  console.error("[reroute/gen] Failed to generate content:", error);
@@ -8989,17 +9034,17 @@ async function generate(cwd, args = [], options = {}) {
8989
9034
  }
8990
9035
  try {
8991
9036
  await perfTrack("Manifest generation", async () => {
8992
- const routesPath2 = join11(cwd, OUTPUT_ROUTES);
9037
+ const routesPath2 = join12(cwd, OUTPUT_ROUTES);
8993
9038
  const routesModule = await import(`file://${routesPath2}?t=${Date.now()}`);
8994
9039
  const routes = routesModule.routes || [];
8995
9040
  const staticRoutes = routes.filter((r) => !r.params || r.params.length === 0).map((r) => r.pattern);
8996
9041
  const contentRoutes = [];
8997
- const collectionsDir = join11(cwd, ".reroute", "collections");
9042
+ const collectionsDir = join12(cwd, ".reroute", "collections");
8998
9043
  try {
8999
9044
  const collectionFiles = await readdir7(collectionsDir);
9000
9045
  for (const file of collectionFiles) {
9001
9046
  if (file.endsWith(".js")) {
9002
- const collectionPath = join11(collectionsDir, file);
9047
+ const collectionPath = join12(collectionsDir, file);
9003
9048
  const collectionModule = await import(`file://${collectionPath}?t=${Date.now()}`);
9004
9049
  const items = collectionModule.items || [];
9005
9050
  for (const item of items) {
@@ -9024,7 +9069,7 @@ async function generate(cwd, args = [], options = {}) {
9024
9069
  dynamicRoutes,
9025
9070
  version: 1
9026
9071
  };
9027
- await Bun.write(join11(cwd, ".reroute", "manifest.json"), JSON.stringify(manifest, null, 2));
9072
+ await Bun.write(join12(cwd, ".reroute", "manifest.json"), JSON.stringify(manifest, null, 2));
9028
9073
  });
9029
9074
  } catch (error) {
9030
9075
  console.error("[reroute/gen] Failed to generate manifest:", error);
@@ -9045,7 +9090,7 @@ async function generate(cwd, args = [], options = {}) {
9045
9090
  mdComponentsLines.push("");
9046
9091
  mdComponentsLines.push(`import markdownComponents from '${componentsPath}';`);
9047
9092
  mdComponentsLines.push("export { markdownComponents };");
9048
- await Bun.write(join11(cwd, ".reroute/markdown-components.ts"), mdComponentsLines.join(`
9093
+ await Bun.write(join12(cwd, ".reroute/markdown-components.ts"), mdComponentsLines.join(`
9049
9094
  `));
9050
9095
  }
9051
9096
  const indexLines = [];
@@ -9065,7 +9110,7 @@ async function generate(cwd, args = [], options = {}) {
9065
9110
  const ogTemplatePath = config2.ogImage.defaultTemplate.startsWith(".") ? `../${config2.ogImage.defaultTemplate}` : config2.ogImage.defaultTemplate;
9066
9111
  indexLines.push(`import OGTemplate from '${ogTemplatePath}';`);
9067
9112
  }
9068
- const ogFiles = await scanOgFiles(join11(cwd, ROUTES_DIR));
9113
+ const ogFiles = await scanOgFiles(join12(cwd, ROUTES_DIR));
9069
9114
  const ogImports = [];
9070
9115
  for (let i = 0;i < ogFiles.length; i++) {
9071
9116
  const ogFile = ogFiles[i];
@@ -9111,7 +9156,7 @@ async function generate(cwd, args = [], options = {}) {
9111
9156
  }
9112
9157
  indexLines.push("};");
9113
9158
  }
9114
- const templatePath = join11(cwd, "src", "client", "index.html");
9159
+ const templatePath = join12(cwd, "src", "client", "index.html");
9115
9160
  try {
9116
9161
  const templateContent = await Bun.file(templatePath).text();
9117
9162
  indexLines.push("");
@@ -9123,7 +9168,7 @@ async function generate(cwd, args = [], options = {}) {
9123
9168
  indexLines.push(`(globalThis as any).__REROUTE_CONFIG__ = ${serializeConfig(config2)};`);
9124
9169
  indexLines.push("");
9125
9170
  indexLines.push("export type RerouteBundle = typeof bundle;");
9126
- await Bun.write(join11(cwd, OUTPUT_ARTIFACTS), indexLines.join(`
9171
+ await Bun.write(join12(cwd, OUTPUT_ARTIFACTS), indexLines.join(`
9127
9172
  `));
9128
9173
  const barrelLines = [
9129
9174
  "// \uD83D\uDEA8 Auto-generated by Reroute - DO NOT EDIT \uD83D\uDEA8",
@@ -9133,7 +9178,7 @@ async function generate(cwd, args = [], options = {}) {
9133
9178
  "",
9134
9179
  "export * from './artifacts';"
9135
9180
  ];
9136
- await Bun.write(join11(cwd, OUTPUT_INDEX), barrelLines.join(`
9181
+ await Bun.write(join12(cwd, OUTPUT_INDEX), barrelLines.join(`
9137
9182
  `));
9138
9183
  const entryLines = [
9139
9184
  "// \uD83D\uDEA8 Auto-generated by Reroute - DO NOT EDIT \uD83D\uDEA8",
@@ -9149,10 +9194,10 @@ async function generate(cwd, args = [], options = {}) {
9149
9194
  "import './routes'; // Import routes (bundles all route components)",
9150
9195
  "import '../src/index'; // Import user's server entry"
9151
9196
  ];
9152
- await Bun.write(join11(cwd, ".reroute/entry.ts"), entryLines.join(`
9197
+ await Bun.write(join12(cwd, ".reroute/entry.ts"), entryLines.join(`
9153
9198
  `));
9154
9199
  if (!showPerformance) {
9155
- console.log(`[reroute/gen] Generated artifacts: ${join11(cwd, OUTPUT_ARTIFACTS)}`);
9200
+ console.log(`[reroute/gen] Generated artifacts: ${join12(cwd, OUTPUT_ARTIFACTS)}`);
9156
9201
  }
9157
9202
  await perfTrack("Bundle building", () => buildEntrypointBundle(cwd, args));
9158
9203
  const endTime = performance.now();
@@ -9272,17 +9317,22 @@ async function startGenWatch(cwd, args) {
9272
9317
  const quickDebounce = createDebouncer(50);
9273
9318
  const mediumDebounce = createDebouncer(150);
9274
9319
  const slowDebounce = createDebouncer(300);
9320
+ const fingerprint = createContentFingerprint();
9275
9321
  const loadedConfig = await loadConfig(cwd);
9276
- const configPath = join11(cwd, "reroute.config.ts");
9322
+ const configPath = join12(cwd, "reroute.config.ts");
9277
9323
  let configWatcher = null;
9278
9324
  try {
9279
9325
  configWatcher = watch(configPath, () => {
9280
9326
  mediumDebounce(() => {
9281
- scheduleBuild(async () => {
9282
- console.log("[reroute/watch] \uD83D\uDCDD Config changed, full rebuild...");
9283
- await generate(cwd, args, { clean: true, writeStubs: false });
9284
- await syncThemeCss(cwd);
9285
- }, "config change");
9327
+ fingerprint.changed(configPath).then((changed) => {
9328
+ if (!changed)
9329
+ return;
9330
+ scheduleBuild(async () => {
9331
+ console.log("[reroute/watch] \uD83D\uDCDD Config changed, full rebuild...");
9332
+ await generate(cwd, args, { clean: true, writeStubs: false });
9333
+ await syncThemeCss(cwd);
9334
+ }, "config change");
9335
+ });
9286
9336
  });
9287
9337
  });
9288
9338
  console.log("[reroute/watch] \uD83D\uDCDD Watching reroute.config.ts...");
@@ -9295,14 +9345,18 @@ async function startGenWatch(cwd, args) {
9295
9345
  ];
9296
9346
  const envWatchers = [];
9297
9347
  for (const envFile of envFiles) {
9298
- const envPath = join11(cwd, envFile);
9348
+ const envPath = join12(cwd, envFile);
9299
9349
  try {
9300
9350
  const envWatcher = watch(envPath, () => {
9301
9351
  mediumDebounce(() => {
9302
- scheduleBuild(async () => {
9303
- console.log(`[reroute/watch] \uD83D\uDD10 ${envFile} changed`);
9304
- await buildEntrypointBundle(cwd, args);
9305
- }, `${envFile} change`);
9352
+ fingerprint.changed(envPath).then((changed) => {
9353
+ if (!changed)
9354
+ return;
9355
+ scheduleBuild(async () => {
9356
+ console.log(`[reroute/watch] \uD83D\uDD10 ${envFile} changed`);
9357
+ await buildEntrypointBundle(cwd, args);
9358
+ }, `${envFile} change`);
9359
+ });
9306
9360
  });
9307
9361
  });
9308
9362
  envWatchers.push(envWatcher);
@@ -9314,15 +9368,15 @@ async function startGenWatch(cwd, args) {
9314
9368
  let packagesWatcher = null;
9315
9369
  const isRerouteWorkspace = async () => {
9316
9370
  try {
9317
- const packagesPath = join11(cwd, "..", "..", "packages");
9318
- const exists = await Bun.file(join11(packagesPath, "core", "index.ts")).exists();
9371
+ const packagesPath = join12(cwd, "..", "..", "packages");
9372
+ const exists = await Bun.file(join12(packagesPath, "core", "index.ts")).exists();
9319
9373
  return exists;
9320
9374
  } catch {
9321
9375
  return false;
9322
9376
  }
9323
9377
  };
9324
9378
  if (await isRerouteWorkspace()) {
9325
- const packagesPath = join11(cwd, "..", "..", "packages");
9379
+ const packagesPath = join12(cwd, "..", "..", "packages");
9326
9380
  console.log("[reroute/watch] \uD83D\uDD27 Workspace development mode enabled");
9327
9381
  console.log(`[reroute/watch] \uD83D\uDD27 Watching ${packagesPath}...`);
9328
9382
  packagesWatcher = watch(packagesPath, { recursive: true }, (_ev, filename) => {
@@ -9336,18 +9390,22 @@ async function startGenWatch(cwd, args) {
9336
9390
  if (!/\.(tsx|ts|jsx|js)$/.test(name))
9337
9391
  return;
9338
9392
  slowDebounce(() => {
9339
- scheduleBuild(async () => {
9340
- console.log(`[reroute/watch] \uD83D\uDD27 Package changed: ${name}`);
9341
- await generate(cwd, args, {
9342
- clean: false,
9343
- writeStubs: false
9344
- });
9345
- await syncThemeCss(cwd);
9346
- }, "workspace package change");
9393
+ fingerprint.changed(join12(packagesPath, name)).then((changed) => {
9394
+ if (!changed)
9395
+ return;
9396
+ scheduleBuild(async () => {
9397
+ console.log(`[reroute/watch] \uD83D\uDD27 Package changed: ${name}`);
9398
+ await generate(cwd, args, {
9399
+ clean: false,
9400
+ writeStubs: false
9401
+ });
9402
+ await syncThemeCss(cwd);
9403
+ }, "workspace package change");
9404
+ });
9347
9405
  });
9348
9406
  });
9349
9407
  }
9350
- const routesPath = join11(cwd, ROUTES_DIR);
9408
+ const routesPath = join12(cwd, ROUTES_DIR);
9351
9409
  console.log(`[reroute/watch] \uD83D\uDCC1 Watching ${routesPath}...`);
9352
9410
  const routesWatcher = watch(routesPath, { recursive: true }, (_ev, filename) => {
9353
9411
  if (!filename)
@@ -9356,61 +9414,85 @@ async function startGenWatch(cwd, args) {
9356
9414
  if (isWatchNoise(name))
9357
9415
  return;
9358
9416
  quickDebounce(() => {
9359
- scheduleBuild(async () => {
9360
- const isContentFile = name.includes("/content/") || name.includes("\\content\\");
9361
- const isMarkdown = /\.(md|mdx)$/.test(name);
9362
- const isRoute = /\.(tsx|ts)$/.test(name) && !isContentFile;
9363
- console.log(`[reroute/watch] \uD83D\uDCC1 Changed: ${name}`);
9364
- if (isContentFile) {
9365
- if (isMarkdown) {
9417
+ fingerprint.changed(join12(routesPath, name)).then((changed) => {
9418
+ if (!changed)
9419
+ return;
9420
+ scheduleBuild(async () => {
9421
+ const isContentFile = name.includes("/content/") || name.includes("\\content\\");
9422
+ const isMarkdown = /\.(md|mdx)$/.test(name);
9423
+ const isRoute = /\.(tsx|ts)$/.test(name) && !isContentFile;
9424
+ console.log(`[reroute/watch] \uD83D\uDCC1 Changed: ${name}`);
9425
+ if (isContentFile) {
9426
+ if (isMarkdown) {
9427
+ console.log("[reroute/watch] ├─ Processing markdown...");
9428
+ const mdStart = performance.now();
9429
+ await preprocessMarkdownFiles(cwd, loadedConfig);
9430
+ const mdTime = ((performance.now() - mdStart) / 1000).toFixed(2);
9431
+ console.log(`[reroute/watch] └─ Markdown: ${mdTime}s`);
9432
+ }
9433
+ console.log("[reroute/watch] ├─ Building content chunks...");
9434
+ const contentStart = performance.now();
9435
+ const watchI18n = await discoverI18n(cwd, loadedConfig.i18n);
9436
+ await Bun.write(join12(cwd, ".reroute", "i18n.json"), JSON.stringify({
9437
+ enabled: watchI18n.enabled,
9438
+ defaultLocale: watchI18n.defaultLocale,
9439
+ locales: watchI18n.locales,
9440
+ cookie: watchI18n.cookie,
9441
+ redirectContentOnNegotiate: watchI18n.redirectContentOnNegotiate,
9442
+ catalogs: watchI18n.catalogs
9443
+ }, null, 2));
9444
+ await buildContentChunks(cwd, args, watchI18n.defaultLocale);
9445
+ const contentTime = ((performance.now() - contentStart) / 1000).toFixed(2);
9446
+ console.log(`[reroute/watch] └─ Content: ${contentTime}s`);
9447
+ if (loadedConfig.search?.enabled) {
9448
+ console.log("[reroute/watch] ├─ Rebuilding search index...");
9449
+ const searchStart = performance.now();
9450
+ await buildSearchIndex(cwd, loadedConfig, args);
9451
+ const searchTime = ((performance.now() - searchStart) / 1000).toFixed(2);
9452
+ console.log(`[reroute/watch] └─ Search: ${searchTime}s`);
9453
+ }
9454
+ } else if (isMarkdown && !isContentFile) {
9366
9455
  console.log("[reroute/watch] ├─ Processing markdown...");
9367
9456
  const mdStart = performance.now();
9368
9457
  await preprocessMarkdownFiles(cwd, loadedConfig);
9369
9458
  const mdTime = ((performance.now() - mdStart) / 1000).toFixed(2);
9370
9459
  console.log(`[reroute/watch] └─ Markdown: ${mdTime}s`);
9460
+ await generate(cwd, args, { clean: false, writeStubs: false });
9461
+ } else if (isRoute) {
9462
+ await generate(cwd, args, { clean: false, writeStubs: false });
9463
+ } else {
9464
+ await generate(cwd, args, { clean: false, writeStubs: false });
9371
9465
  }
9372
- console.log("[reroute/watch] ├─ Building content chunks...");
9373
- const contentStart = performance.now();
9374
- const watchI18n = await discoverI18n(cwd, loadedConfig.i18n);
9375
- await Bun.write(join11(cwd, ".reroute", "i18n.json"), JSON.stringify({
9376
- enabled: watchI18n.enabled,
9377
- defaultLocale: watchI18n.defaultLocale,
9378
- locales: watchI18n.locales,
9379
- cookie: watchI18n.cookie,
9380
- redirectContentOnNegotiate: watchI18n.redirectContentOnNegotiate,
9381
- catalogs: watchI18n.catalogs
9382
- }, null, 2));
9383
- await buildContentChunks(cwd, args, watchI18n.defaultLocale);
9384
- const contentTime = ((performance.now() - contentStart) / 1000).toFixed(2);
9385
- console.log(`[reroute/watch] └─ Content: ${contentTime}s`);
9386
- if (loadedConfig.search?.enabled) {
9387
- console.log("[reroute/watch] ├─ Rebuilding search index...");
9388
- const searchStart = performance.now();
9389
- await buildSearchIndex(cwd, loadedConfig, args);
9390
- const searchTime = ((performance.now() - searchStart) / 1000).toFixed(2);
9391
- console.log(`[reroute/watch] └─ Search: ${searchTime}s`);
9392
- }
9393
- } else if (isMarkdown && !isContentFile) {
9394
- console.log("[reroute/watch] ├─ Processing markdown...");
9395
- const mdStart = performance.now();
9396
- await preprocessMarkdownFiles(cwd, loadedConfig);
9397
- const mdTime = ((performance.now() - mdStart) / 1000).toFixed(2);
9398
- console.log(`[reroute/watch] └─ Markdown: ${mdTime}s`);
9399
- await generate(cwd, args, { clean: false, writeStubs: false });
9400
- } else if (isRoute) {
9401
- await generate(cwd, args, { clean: false, writeStubs: false });
9402
- } else {
9403
- await generate(cwd, args, { clean: false, writeStubs: false });
9404
- }
9405
- const themeSynced = await syncThemeCss(cwd);
9406
- if (themeSynced) {
9407
- console.log("[reroute/watch] ├─ index.css synced");
9408
- }
9409
- }, "routes change");
9466
+ const themeSynced = await syncThemeCss(cwd);
9467
+ if (themeSynced) {
9468
+ console.log("[reroute/watch] ├─ index.css synced");
9469
+ }
9470
+ }, "routes change");
9471
+ });
9410
9472
  });
9411
9473
  });
9412
- const clientPath = join11(cwd, "src", "client");
9474
+ const clientPath = join12(cwd, "src", "client");
9413
9475
  console.log(`[reroute/watch] \uD83D\uDCE6 Watching ${clientPath}...`);
9476
+ async function rebuildWatchedClient(changed) {
9477
+ const label = changed.length === 1 ? changed[0] : `${changed.length} files`;
9478
+ console.log(`[reroute/watch] \uD83D\uDCE6 Client changed: ${label}`);
9479
+ if (changed.some((n) => shouldRebuildClientBundle(n))) {
9480
+ console.log("[reroute/watch] ├─ Rebuilding bundle...");
9481
+ const bundleStart = performance.now();
9482
+ try {
9483
+ await buildEntrypointBundle(cwd, args);
9484
+ const bundleTime = ((performance.now() - bundleStart) / 1000).toFixed(2);
9485
+ console.log(`[reroute/watch] └─ Bundle: ${bundleTime}s`);
9486
+ } catch (err) {
9487
+ console.error(`[reroute/watch] ✗ Build failed:`, err);
9488
+ throw err;
9489
+ }
9490
+ }
9491
+ const themeSynced = await syncThemeCss(cwd);
9492
+ if (themeSynced) {
9493
+ console.log("[reroute/watch] ├─ index.css synced");
9494
+ }
9495
+ }
9414
9496
  let pendingClientFiles = new Set;
9415
9497
  const clientWatcher = watch(clientPath, { recursive: true }, (_ev, filename) => {
9416
9498
  if (!filename)
@@ -9428,27 +9510,12 @@ async function startGenWatch(cwd, args) {
9428
9510
  mediumDebounce(() => {
9429
9511
  const names = [...pendingClientFiles];
9430
9512
  pendingClientFiles = new Set;
9431
- const reloadMode = names.every((n) => n.endsWith(".css")) ? "css" : "full";
9432
- const label = names.length === 1 ? names[0] : `${names.length} files`;
9433
- scheduleBuild(async () => {
9434
- console.log(`[reroute/watch] \uD83D\uDCE6 Client changed: ${label}`);
9435
- if (names.some((n) => shouldRebuildClientBundle(n))) {
9436
- console.log("[reroute/watch] ├─ Rebuilding bundle...");
9437
- const bundleStart = performance.now();
9438
- try {
9439
- await buildEntrypointBundle(cwd, args);
9440
- const bundleTime = ((performance.now() - bundleStart) / 1000).toFixed(2);
9441
- console.log(`[reroute/watch] └─ Bundle: ${bundleTime}s`);
9442
- } catch (err) {
9443
- console.error(`[reroute/watch] ✗ Build failed:`, err);
9444
- throw err;
9445
- }
9446
- }
9447
- const themeSynced = await syncThemeCss(cwd);
9448
- if (themeSynced) {
9449
- console.log("[reroute/watch] ├─ index.css synced");
9450
- }
9451
- }, "client change", reloadMode);
9513
+ retainChangedFiles(clientPath, names, fingerprint).then((changed) => {
9514
+ if (changed.length === 0)
9515
+ return;
9516
+ const reloadMode = changed.every((n) => n.endsWith(".css")) ? "css" : "full";
9517
+ scheduleBuild(() => rebuildWatchedClient(changed), "client change", reloadMode);
9518
+ });
9452
9519
  });
9453
9520
  });
9454
9521
  console.log(`[reroute/watch] ✓ Watch mode active - ready for changes!
@@ -9505,6 +9572,7 @@ var init_gen = __esm(() => {
9505
9572
  init_analyzer();
9506
9573
  init_suspense();
9507
9574
  init_theme();
9575
+ init_watch();
9508
9576
  });
9509
9577
 
9510
9578
  // packages/cli/src/commands/lib/command.ts
@@ -9513,19 +9581,19 @@ __export(exports_command, {
9513
9581
  getRerouteCommand: () => getRerouteCommand
9514
9582
  });
9515
9583
  import { existsSync as existsSync6 } from "node:fs";
9516
- import { join as join12 } from "node:path";
9584
+ import { join as join13 } from "node:path";
9517
9585
  function getRerouteCommand() {
9518
- const binPath = join12(import.meta.dir, "..", "..", "bin.ts");
9586
+ const binPath = join13(import.meta.dir, "..", "..", "bin.ts");
9519
9587
  const isBunDev = existsSync6(binPath);
9520
9588
  if (isBunDev) {
9521
9589
  return `bun ${binPath}`;
9522
9590
  }
9523
9591
  const cwd = process.cwd();
9524
9592
  const nodeModulesPaths = [
9525
- join12(cwd, "node_modules", ".bin", "reroute"),
9526
- join12(cwd, "..", "node_modules", ".bin", "reroute"),
9527
- join12(cwd, "..", "..", "node_modules", ".bin", "reroute"),
9528
- join12(cwd, "..", "..", "..", "node_modules", ".bin", "reroute")
9593
+ join13(cwd, "node_modules", ".bin", "reroute"),
9594
+ join13(cwd, "..", "node_modules", ".bin", "reroute"),
9595
+ join13(cwd, "..", "..", "node_modules", ".bin", "reroute"),
9596
+ join13(cwd, "..", "..", "..", "node_modules", ".bin", "reroute")
9529
9597
  ];
9530
9598
  for (const binPath2 of nodeModulesPaths) {
9531
9599
  if (existsSync6(binPath2)) {
@@ -101603,7 +101671,7 @@ var require_lodash = __commonJS(function(exports, module) {
101603
101671
  }
101604
101672
  return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, undefined2, comparator) : [];
101605
101673
  });
101606
- function join13(array, separator) {
101674
+ function join14(array, separator) {
101607
101675
  return array == null ? "" : nativeJoin.call(array, separator);
101608
101676
  }
101609
101677
  function last(array) {
@@ -103535,7 +103603,7 @@ __p += '`;
103535
103603
  lodash.isUndefined = isUndefined;
103536
103604
  lodash.isWeakMap = isWeakMap;
103537
103605
  lodash.isWeakSet = isWeakSet;
103538
- lodash.join = join13;
103606
+ lodash.join = join14;
103539
103607
  lodash.kebabCase = kebabCase;
103540
103608
  lodash.last = last;
103541
103609
  lodash.lastIndexOf = lastIndexOf;
@@ -104217,7 +104285,7 @@ __export(exports_dev, {
104217
104285
  });
104218
104286
  import { spawn } from "node:child_process";
104219
104287
  import { existsSync as existsSync7 } from "node:fs";
104220
- import { join as join13 } from "node:path";
104288
+ import { join as join14 } from "node:path";
104221
104289
  import { pathToFileURL as pathToFileURL9 } from "node:url";
104222
104290
  function parsePort(args) {
104223
104291
  const portIndex = args.findIndex((arg) => arg === "--port" || arg === "-p");
@@ -104305,7 +104373,7 @@ async function startDefault(port) {
104305
104373
  process.env.PORT = String(port);
104306
104374
  process.env.REROUTE_DEV = "1";
104307
104375
  const session = await startGenWatch(process.cwd(), ["--watch"]);
104308
- const entry = join13(process.cwd(), "src/index.ts");
104376
+ const entry = join14(process.cwd(), "src/index.ts");
104309
104377
  if (!existsSync7(entry)) {
104310
104378
  session.close();
104311
104379
  throw new Error(`[reroute/dev] Missing ${entry}`);
@@ -104371,19 +104439,19 @@ __export(exports_start, {
104371
104439
  });
104372
104440
  import { spawn as spawn2 } from "node:child_process";
104373
104441
  import { existsSync as existsSync8 } from "node:fs";
104374
- import { join as join14 } from "node:path";
104442
+ import { join as join15 } from "node:path";
104375
104443
  function getRerouteCommand2() {
104376
- const binPath = join14(import.meta.dir, "..", "..", "bin.ts");
104444
+ const binPath = join15(import.meta.dir, "..", "..", "bin.ts");
104377
104445
  const isBunDev = existsSync8(binPath);
104378
104446
  if (isBunDev) {
104379
104447
  return `bun ${binPath}`;
104380
104448
  }
104381
104449
  const cwd = process.cwd();
104382
104450
  const nodeModulesPaths = [
104383
- join14(cwd, "node_modules", ".bin", "reroute"),
104384
- join14(cwd, "..", "node_modules", ".bin", "reroute"),
104385
- join14(cwd, "..", "..", "node_modules", ".bin", "reroute"),
104386
- join14(cwd, "..", "..", "..", "node_modules", ".bin", "reroute")
104451
+ join15(cwd, "node_modules", ".bin", "reroute"),
104452
+ join15(cwd, "..", "node_modules", ".bin", "reroute"),
104453
+ join15(cwd, "..", "..", "node_modules", ".bin", "reroute"),
104454
+ join15(cwd, "..", "..", "..", "node_modules", ".bin", "reroute")
104387
104455
  ];
104388
104456
  for (const binPath2 of nodeModulesPaths) {
104389
104457
  if (existsSync8(binPath2)) {
@@ -104511,12 +104579,12 @@ import {
104511
104579
  mkdirSync,
104512
104580
  readdirSync
104513
104581
  } from "node:fs";
104514
- import { join as join15 } from "node:path";
104582
+ import { join as join16 } from "node:path";
104515
104583
  function copyAssetsToReroute(cwd, sourceAssetsDir, rerouteAssetsDir) {
104516
104584
  if (!existsSync9(sourceAssetsDir)) {
104517
104585
  return 0;
104518
104586
  }
104519
- const rerouteDir = join15(cwd, ".reroute");
104587
+ const rerouteDir = join16(cwd, ".reroute");
104520
104588
  if (!existsSync9(rerouteDir)) {
104521
104589
  mkdirSync(rerouteDir, { recursive: true });
104522
104590
  }
@@ -104528,7 +104596,7 @@ function countFiles(dir) {
104528
104596
  const entries = readdirSync(dir, { withFileTypes: true });
104529
104597
  for (const entry of entries) {
104530
104598
  if (entry.isDirectory()) {
104531
- count += countFiles(join15(dir, entry.name));
104599
+ count += countFiles(join16(dir, entry.name));
104532
104600
  } else {
104533
104601
  count++;
104534
104602
  }
@@ -104544,19 +104612,19 @@ __export(exports_build, {
104544
104612
  });
104545
104613
  import { spawn as spawn3 } from "node:child_process";
104546
104614
  import { existsSync as existsSync10, readFileSync as readFileSync5, rmSync, unlinkSync } from "node:fs";
104547
- import { join as join16 } from "node:path";
104615
+ import { join as join17 } from "node:path";
104548
104616
  function getRerouteCommand3() {
104549
- const binPath = join16(import.meta.dir, "..", "..", "bin.ts");
104617
+ const binPath = join17(import.meta.dir, "..", "..", "bin.ts");
104550
104618
  const isBunDev = existsSync10(binPath);
104551
104619
  if (isBunDev) {
104552
104620
  return `bun ${binPath}`;
104553
104621
  }
104554
104622
  const cwd = process.cwd();
104555
104623
  const nodeModulesPaths = [
104556
- join16(cwd, "node_modules", ".bin", "reroute"),
104557
- join16(cwd, "..", "node_modules", ".bin", "reroute"),
104558
- join16(cwd, "..", "..", "node_modules", ".bin", "reroute"),
104559
- join16(cwd, "..", "..", "..", "node_modules", ".bin", "reroute")
104624
+ join17(cwd, "node_modules", ".bin", "reroute"),
104625
+ join17(cwd, "..", "node_modules", ".bin", "reroute"),
104626
+ join17(cwd, "..", "..", "node_modules", ".bin", "reroute"),
104627
+ join17(cwd, "..", "..", "..", "node_modules", ".bin", "reroute")
104560
104628
  ];
104561
104629
  for (const binPath2 of nodeModulesPaths) {
104562
104630
  if (existsSync10(binPath2)) {
@@ -104567,7 +104635,7 @@ function getRerouteCommand3() {
104567
104635
  }
104568
104636
  function getOutputName() {
104569
104637
  const cwd = process.cwd();
104570
- const packageJsonPath = join16(cwd, "package.json");
104638
+ const packageJsonPath = join17(cwd, "package.json");
104571
104639
  if (existsSync10(packageJsonPath)) {
104572
104640
  try {
104573
104641
  const packageJson = JSON.parse(readFileSync5(packageJsonPath, "utf-8"));
@@ -104599,7 +104667,7 @@ function parseBuildArgs(args) {
104599
104667
  return { outfile, compileBinary, noCompression, externalArgs };
104600
104668
  }
104601
104669
  function cleanDistFolder(cwd) {
104602
- const distDir = join16(cwd, "dist");
104670
+ const distDir = join17(cwd, "dist");
104603
104671
  if (existsSync10(distDir)) {
104604
104672
  process.stdout.write(colorizeLogPrefixAnsi(`[reroute/build] Cleaning dist folder...
104605
104673
  `));
@@ -104607,7 +104675,7 @@ function cleanDistFolder(cwd) {
104607
104675
  }
104608
104676
  }
104609
104677
  async function cleanRerouteFolder(cwd) {
104610
- const rerouteDir = join16(cwd, ".reroute");
104678
+ const rerouteDir = join17(cwd, ".reroute");
104611
104679
  if (existsSync10(rerouteDir)) {
104612
104680
  process.stdout.write(colorizeLogPrefixAnsi(`[reroute/build] Cleaning .reroute folder...
104613
104681
  `));
@@ -104664,8 +104732,8 @@ async function copyAssets(cwd) {
104664
104732
  const appSrc = config2.app?.src ?? "./src/client/App";
104665
104733
  const dirname8 = __require("node:path").dirname;
104666
104734
  const assetsPath = dirname8(appSrc);
104667
- const sourceAssetsDir = join16(cwd, assetsPath, "assets");
104668
- const rerouteAssetsDir = join16(cwd, ".reroute", "assets");
104735
+ const sourceAssetsDir = join17(cwd, assetsPath, "assets");
104736
+ const rerouteAssetsDir = join17(cwd, ".reroute", "assets");
104669
104737
  process.stdout.write(colorizeLogPrefixAnsi(`[reroute/build] Copying assets...
104670
104738
  `));
104671
104739
  const fileCount = copyAssetsToReroute(cwd, sourceAssetsDir, rerouteAssetsDir);
@@ -104680,9 +104748,9 @@ async function copyAssets(cwd) {
104680
104748
  async function buildBundle(cwd, buildArgs) {
104681
104749
  const external = [...buildArgs.externalArgs, "sharp", "@vercel/og"];
104682
104750
  const buildResult = await Bun.build({
104683
- entrypoints: [join16(cwd, ".reroute/entry.ts")],
104751
+ entrypoints: [join17(cwd, ".reroute/entry.ts")],
104684
104752
  target: "bun",
104685
- outdir: join16(cwd, "dist"),
104753
+ outdir: join17(cwd, "dist"),
104686
104754
  sourcemap: "external",
104687
104755
  ...getCommonBuildOptions(),
104688
104756
  external,
@@ -104725,7 +104793,7 @@ function cleanupBundledFiles(rerouteDir) {
104725
104793
  "markdown-components.ts"
104726
104794
  ];
104727
104795
  for (const file of tsFilesToRemove) {
104728
- const filePath = join16(rerouteDir, file);
104796
+ const filePath = join17(rerouteDir, file);
104729
104797
  if (existsSync10(filePath)) {
104730
104798
  try {
104731
104799
  unlinkSync(filePath);
@@ -104735,7 +104803,7 @@ function cleanupBundledFiles(rerouteDir) {
104735
104803
  }
104736
104804
  const dirsToRemove = ["markdown", "streaming"];
104737
104805
  for (const dir of dirsToRemove) {
104738
- const dirPath = join16(rerouteDir, dir);
104806
+ const dirPath = join17(rerouteDir, dir);
104739
104807
  if (existsSync10(dirPath)) {
104740
104808
  try {
104741
104809
  rmSync(dirPath, { recursive: true });
@@ -104769,7 +104837,7 @@ async function build(args) {
104769
104837
  await runGenCommand(rerouteCmd, useShell, buildArgs.noCompression);
104770
104838
  await copyAssets(cwd);
104771
104839
  await buildBundle(cwd, buildArgs);
104772
- const rerouteDir = join16(cwd, ".reroute");
104840
+ const rerouteDir = join17(cwd, ".reroute");
104773
104841
  cleanupBundledFiles(rerouteDir);
104774
104842
  logBuildComplete(buildStartTime, buildArgs);
104775
104843
  process.exit(0);
@@ -104791,24 +104859,24 @@ __export(exports_analyze, {
104791
104859
  default: () => analyze
104792
104860
  });
104793
104861
  import { existsSync as existsSync11, statSync } from "node:fs";
104794
- import { readdir as readdir8, readFile, stat as stat6, writeFile as writeFile2 } from "node:fs/promises";
104795
- import { basename as basename4, join as join17, relative as relative3 } from "node:path";
104862
+ import { readdir as readdir8, readFile as readFile2, stat as stat6, writeFile as writeFile2 } from "node:fs/promises";
104863
+ import { basename as basename4, join as join18, relative as relative3 } from "node:path";
104796
104864
  import Table from "cli-table3";
104797
104865
  async function findChunkBundles(cwd) {
104798
104866
  const bundles = [];
104799
- const chunksDir = join17(cwd, ".reroute", "chunks");
104867
+ const chunksDir = join18(cwd, ".reroute", "chunks");
104800
104868
  if (!existsSync11(chunksDir))
104801
104869
  return bundles;
104802
104870
  const collections2 = await readdir8(chunksDir, { withFileTypes: true });
104803
104871
  for (const collection of collections2) {
104804
104872
  if (!collection.isDirectory())
104805
104873
  continue;
104806
- const collectionDir = join17(chunksDir, collection.name);
104874
+ const collectionDir = join18(chunksDir, collection.name);
104807
104875
  const files = await readdir8(collectionDir);
104808
104876
  for (const file of files) {
104809
104877
  if (!file.endsWith(".js"))
104810
104878
  continue;
104811
- const filePath = join17(collectionDir, file);
104879
+ const filePath = join18(collectionDir, file);
104812
104880
  const stats = await stat6(filePath);
104813
104881
  const content2 = await Bun.file(filePath).arrayBuffer();
104814
104882
  const gzippedSize = Bun.gzipSync(new Uint8Array(content2)).length;
@@ -104826,12 +104894,12 @@ async function findChunkBundles(cwd) {
104826
104894
  }
104827
104895
  async function findDistBundles(cwd) {
104828
104896
  const bundles = [];
104829
- const distDir = join17(cwd, "dist");
104897
+ const distDir = join18(cwd, "dist");
104830
104898
  if (!existsSync11(distDir))
104831
104899
  return bundles;
104832
104900
  const files = await readdir8(distDir);
104833
104901
  for (const file of files) {
104834
- const filePath = join17(distDir, file);
104902
+ const filePath = join18(distDir, file);
104835
104903
  const stats = statSync(filePath);
104836
104904
  if (stats.isFile() && !file.endsWith(".map") && !file.endsWith(".d.ts")) {
104837
104905
  const content2 = await Bun.file(filePath).arrayBuffer();
@@ -104857,9 +104925,9 @@ async function findBundles(cwd) {
104857
104925
  }
104858
104926
  async function findBrowserEntry(cwd) {
104859
104927
  try {
104860
- const clientDir = join17(cwd, "src", "client");
104861
- const tsxEntry = join17(clientDir, "index.tsx");
104862
- const tsEntry = join17(clientDir, "index.ts");
104928
+ const clientDir = join18(cwd, "src", "client");
104929
+ const tsxEntry = join18(clientDir, "index.tsx");
104930
+ const tsEntry = join18(clientDir, "index.ts");
104863
104931
  let sourceEntry = null;
104864
104932
  if (existsSync11(tsxEntry)) {
104865
104933
  sourceEntry = tsxEntry;
@@ -104892,12 +104960,12 @@ async function findBrowserEntry(cwd) {
104892
104960
  console.warn("[reroute/analyze] Browser build produced no outputs");
104893
104961
  return null;
104894
104962
  }
104895
- const tempDir = join17(cwd, ".reroute", "browser");
104963
+ const tempDir = join18(cwd, ".reroute", "browser");
104896
104964
  await import("node:fs/promises").then((fs) => fs.mkdir(tempDir, { recursive: true }));
104897
104965
  const output = result.outputs[0];
104898
104966
  const code = await output.text();
104899
104967
  const actualHash = await generateContentHash2(code);
104900
- const bundlePath = join17(tempDir, `index.${actualHash}.js`);
104968
+ const bundlePath = join18(tempDir, `index.${actualHash}.js`);
104901
104969
  await writeFile2(bundlePath, code, "utf-8");
104902
104970
  const mapOutput = result.outputs.find((o) => o.path.endsWith(".map"));
104903
104971
  if (mapOutput) {
@@ -104949,7 +105017,7 @@ function calculateStats(bundles) {
104949
105017
  }
104950
105018
  async function getInstalledPackageSizes(cwd) {
104951
105019
  const packageSizes = new Map;
104952
- const nodeModulesDir = join17(cwd, "node_modules");
105020
+ const nodeModulesDir = join18(cwd, "node_modules");
104953
105021
  if (!existsSync11(nodeModulesDir))
104954
105022
  return packageSizes;
104955
105023
  try {
@@ -105005,7 +105073,7 @@ async function buildDependencyTree(entryPath, cwd) {
105005
105073
  if (!pkgNode) {
105006
105074
  pkgNode = {
105007
105075
  name: pkgName || "unknown",
105008
- path: join17(cwd, "node_modules", pkgName || ""),
105076
+ path: join18(cwd, "node_modules", pkgName || ""),
105009
105077
  size: 0,
105010
105078
  children: []
105011
105079
  };
@@ -105026,7 +105094,7 @@ async function buildDependencyTree(entryPath, cwd) {
105026
105094
  if (!child) {
105027
105095
  child = {
105028
105096
  name: part,
105029
- path: join17(cwd, ...parts.slice(0, i + 1)),
105097
+ path: join18(cwd, ...parts.slice(0, i + 1)),
105030
105098
  size: 0,
105031
105099
  children: []
105032
105100
  };
@@ -105053,11 +105121,11 @@ async function buildDependencyTree(entryPath, cwd) {
105053
105121
  }
105054
105122
  return node.size;
105055
105123
  };
105056
- const content2 = await readFile(entryPath, "utf-8");
105124
+ const content2 = await readFile2(entryPath, "utf-8");
105057
105125
  const modulePattern = /\/\/\s*(.+?\.(?:ts|tsx|js|jsx|mjs|cjs))\s*$/gm;
105058
105126
  const nodeModulesNode = {
105059
105127
  name: "node_modules",
105060
- path: join17(cwd, "node_modules"),
105128
+ path: join18(cwd, "node_modules"),
105061
105129
  size: 0,
105062
105130
  children: []
105063
105131
  };
@@ -105123,7 +105191,7 @@ async function buildTreeFromSourceMap(bundlePath, cwd) {
105123
105191
  if (sourcePath.startsWith("/") || sourcePath.match(/^[A-Za-z]:\\/))
105124
105192
  return sourcePath;
105125
105193
  const bundleDir = bundlePath.substring(0, bundlePath.lastIndexOf("/"));
105126
- return join17(bundleDir, sourceRoot || "", sourcePath);
105194
+ return join18(bundleDir, sourceRoot || "", sourcePath);
105127
105195
  }, computeSizes = function(node) {
105128
105196
  if (node.children && node.children.length > 0) {
105129
105197
  node.size = node.children.reduce((s, c) => s + computeSizes(c), 0);
@@ -105134,8 +105202,8 @@ async function buildTreeFromSourceMap(bundlePath, cwd) {
105134
105202
  if (!existsSync11(mapPath))
105135
105203
  return null;
105136
105204
  const [bundle, mapJson] = await Promise.all([
105137
- readFile(bundlePath, "utf-8"),
105138
- readFile(mapPath, "utf-8")
105205
+ readFile2(bundlePath, "utf-8"),
105206
+ readFile2(mapPath, "utf-8")
105139
105207
  ]);
105140
105208
  const map = JSON.parse(mapJson);
105141
105209
  const sourceRoot = map.sourceRoot || "";
@@ -105195,7 +105263,7 @@ async function buildTreeFromSourceMap(bundlePath, cwd) {
105195
105263
  };
105196
105264
  const nodeModulesNode = {
105197
105265
  name: "node_modules",
105198
- path: join17(cwd, "node_modules"),
105266
+ path: join18(cwd, "node_modules"),
105199
105267
  size: 0,
105200
105268
  children: []
105201
105269
  };
@@ -105235,7 +105303,7 @@ async function buildTreeFromSourceMap(bundlePath, cwd) {
105235
105303
  if (!pkgNode) {
105236
105304
  pkgNode = {
105237
105305
  name: pkgName || "unknown",
105238
- path: join17(cwd, "node_modules", pkgName || ""),
105306
+ path: join18(cwd, "node_modules", pkgName || ""),
105239
105307
  size: 0,
105240
105308
  children: []
105241
105309
  };
@@ -105256,7 +105324,7 @@ async function buildTreeFromSourceMap(bundlePath, cwd) {
105256
105324
  if (!child) {
105257
105325
  child = {
105258
105326
  name: part,
105259
- path: join17(cwd, ...parts.slice(0, i2 + 1)),
105327
+ path: join18(cwd, ...parts.slice(0, i2 + 1)),
105260
105328
  size: 0,
105261
105329
  children: []
105262
105330
  };
@@ -105286,15 +105354,15 @@ async function generateHTMLReport(stats, depTree, mainInfo, browserDepTree, brow
105286
105354
  let actualServerBinarySize = null;
105287
105355
  let actualServerBinaryGzipped = null;
105288
105356
  try {
105289
- const distDir = join17(process.cwd(), "dist");
105357
+ const distDir = join18(process.cwd(), "dist");
105290
105358
  if (existsSync11(distDir)) {
105291
105359
  const files = await readdir8(distDir);
105292
105360
  for (const file of files) {
105293
- const filePath = join17(distDir, file);
105361
+ const filePath = join18(distDir, file);
105294
105362
  const stats2 = statSync(filePath);
105295
105363
  if (stats2.isFile() && !file.includes(".")) {
105296
105364
  actualServerBinarySize = stats2.size;
105297
- const content2 = await readFile(filePath);
105365
+ const content2 = await readFile2(filePath);
105298
105366
  actualServerBinaryGzipped = Bun.gzipSync(content2).length;
105299
105367
  break;
105300
105368
  }
@@ -106772,15 +106840,15 @@ async function printConsoleReport(stats, depTree, mainInfo, browserDepTree, brow
106772
106840
  let actualServerBinarySize = null;
106773
106841
  let actualServerBinaryGzipped = null;
106774
106842
  try {
106775
- const distDir = join17(process.cwd(), "dist");
106843
+ const distDir = join18(process.cwd(), "dist");
106776
106844
  if (existsSync11(distDir)) {
106777
106845
  const files = await readdir8(distDir);
106778
106846
  for (const file of files) {
106779
- const filePath = join17(distDir, file);
106847
+ const filePath = join18(distDir, file);
106780
106848
  const stats2 = statSync(filePath);
106781
106849
  if (stats2.isFile() && !file.includes(".")) {
106782
106850
  actualServerBinarySize = stats2.size;
106783
- const content2 = await readFile(filePath);
106851
+ const content2 = await readFile2(filePath);
106784
106852
  actualServerBinaryGzipped = Bun.gzipSync(content2).length;
106785
106853
  break;
106786
106854
  }
@@ -106810,7 +106878,7 @@ async function analyze(args) {
106810
106878
  const isProd = isProductionMode(args);
106811
106879
  const searchIndex = args.indexOf("--search");
106812
106880
  const initialSearch = searchIndex !== -1 && args[searchIndex + 1] ? args[searchIndex + 1] : "";
106813
- const rerouteIndexPath = join17(cwd, ".reroute", "index.ts");
106881
+ const rerouteIndexPath = join18(cwd, ".reroute", "index.ts");
106814
106882
  if (!existsSync11(rerouteIndexPath)) {
106815
106883
  console.log(colorizeLogPrefixAnsi(`[reroute/analyze] .reroute artifacts not found, running build...
106816
106884
  `));
@@ -106858,7 +106926,7 @@ async function analyze(args) {
106858
106926
  }
106859
106927
  try {
106860
106928
  const browserStat = await stat6(browserEntry);
106861
- const browserContent = await readFile(browserEntry);
106929
+ const browserContent = await readFile2(browserEntry);
106862
106930
  const browserGzipped = Bun.gzipSync(browserContent).length;
106863
106931
  browserInfo = {
106864
106932
  name: basename4(browserEntry),
@@ -106873,12 +106941,12 @@ async function analyze(args) {
106873
106941
  let entry = null;
106874
106942
  let depTree = null;
106875
106943
  let mainInfo = null;
106876
- const srcEntry = join17(cwd, "src", "index.ts");
106944
+ const srcEntry = join18(cwd, "src", "index.ts");
106877
106945
  if (existsSync11(srcEntry)) {
106878
106946
  console.log(colorizeLogPrefixAnsi(`[reroute/analyze] Building server binary for analysis...
106879
106947
  `));
106880
106948
  const { mkdir: mkdir4 } = await import("node:fs/promises");
106881
- const serverAnalysisDir = join17(cwd, ".reroute", "server");
106949
+ const serverAnalysisDir = join18(cwd, ".reroute", "server");
106882
106950
  await mkdir4(serverAnalysisDir, { recursive: true });
106883
106951
  const result = await Bun.build({
106884
106952
  entrypoints: [srcEntry],
@@ -106891,7 +106959,7 @@ async function analyze(args) {
106891
106959
  if (result.success && result.outputs.length > 0) {
106892
106960
  const output = result.outputs[0];
106893
106961
  const code = await output.text();
106894
- const analysisEntry = join17(serverAnalysisDir, "index.js");
106962
+ const analysisEntry = join18(serverAnalysisDir, "index.js");
106895
106963
  await writeFile2(analysisEntry, code, "utf-8");
106896
106964
  const mapOutput = result.outputs.find((o) => o.path.endsWith(".map"));
106897
106965
  if (mapOutput) {
@@ -106909,10 +106977,10 @@ async function analyze(args) {
106909
106977
  `));
106910
106978
  const installedSizes = await getInstalledPackageSizes(cwd);
106911
106979
  if (depTree) {
106912
- const packageJsonPath = join17(cwd, "package.json");
106980
+ const packageJsonPath = join18(cwd, "package.json");
106913
106981
  if (existsSync11(packageJsonPath)) {
106914
106982
  try {
106915
- const packageJson = JSON.parse(await readFile(packageJsonPath, "utf-8"));
106983
+ const packageJson = JSON.parse(await readFile2(packageJsonPath, "utf-8"));
106916
106984
  const runtimeDeps = packageJson.dependencies || {};
106917
106985
  const nodeModulesNode = depTree.root.children?.find((c) => c.name === "node_modules");
106918
106986
  if (nodeModulesNode) {
@@ -106921,7 +106989,7 @@ async function analyze(args) {
106921
106989
  if (!trackedPkgs.has(pkgName) && installedSizes.has(pkgName)) {
106922
106990
  nodeModulesNode.children?.push({
106923
106991
  name: pkgName,
106924
- path: join17(cwd, "node_modules", pkgName),
106992
+ path: join18(cwd, "node_modules", pkgName),
106925
106993
  size: installedSizes.get(pkgName) || 0
106926
106994
  });
106927
106995
  }
@@ -106940,7 +107008,7 @@ async function analyze(args) {
106940
107008
  }
106941
107009
  try {
106942
107010
  const entryStat = await stat6(entry);
106943
- const entryContent = await readFile(entry);
107011
+ const entryContent = await readFile2(entry);
106944
107012
  const entryGzipped = Bun.gzipSync(entryContent).length;
106945
107013
  mainInfo = {
106946
107014
  name: basename4(entry),
@@ -106952,10 +107020,10 @@ async function analyze(args) {
106952
107020
  const fullOutput = args.includes("--full");
106953
107021
  await printConsoleReport(stats, depTree, mainInfo, browserDepTree, browserInfo, fullOutput);
106954
107022
  if (outputHtml || openBrowser) {
106955
- const htmlPath = join17(cwd, ".reroute", "analysis.html");
107023
+ const htmlPath = join18(cwd, ".reroute", "analysis.html");
106956
107024
  const html2 = await generateHTMLReport(stats, depTree, mainInfo, browserDepTree, browserInfo, initialSearch);
106957
107025
  const { mkdir: mkdir4 } = await import("node:fs/promises");
106958
- await mkdir4(join17(cwd, ".reroute"), { recursive: true });
107026
+ await mkdir4(join18(cwd, ".reroute"), { recursive: true });
106959
107027
  await writeFile2(htmlPath, html2, "utf-8");
106960
107028
  console.log(colorizeLogPrefixAnsi(`[reroute/analyze] HTML report generated: ${relative3(cwd, htmlPath)}
106961
107029
  `));
@@ -107019,7 +107087,7 @@ __export(exports_og, {
107019
107087
  });
107020
107088
  import { spawn as spawn4 } from "node:child_process";
107021
107089
  import { readdir as readdir9 } from "node:fs/promises";
107022
- import { join as join18 } from "node:path";
107090
+ import { join as join19 } from "node:path";
107023
107091
  function getPortFromConfig(baseUrl) {
107024
107092
  if (!baseUrl)
107025
107093
  return 3000;
@@ -107098,8 +107166,8 @@ async function scanForOgTemplates(dir, base, routes) {
107098
107166
  try {
107099
107167
  const entries = await readdir9(dir, { withFileTypes: true });
107100
107168
  for (const entry of entries) {
107101
- const fullPath = join18(dir, entry.name);
107102
- const relativePath = join18(base, entry.name);
107169
+ const fullPath = join19(dir, entry.name);
107170
+ const relativePath = join19(base, entry.name);
107103
107171
  if (entry.isDirectory()) {
107104
107172
  if (entry.name === "content")
107105
107173
  continue;
@@ -107120,7 +107188,7 @@ async function addContentRoutes(routesPath, routes) {
107120
107188
  for (const entry of entries) {
107121
107189
  if (!entry.isDirectory())
107122
107190
  continue;
107123
- const contentDir = join18(routesPath, entry.name, "content");
107191
+ const contentDir = join19(routesPath, entry.name, "content");
107124
107192
  try {
107125
107193
  const contentFiles = await readdir9(contentDir);
107126
107194
  if (contentFiles.length === 0)
@@ -107137,7 +107205,7 @@ async function addContentRoutes(routesPath, routes) {
107137
107205
  async function findRoutesWithOG(cwd) {
107138
107206
  const routes = [];
107139
107207
  try {
107140
- const manifestPath = join18(cwd, ".reroute", "manifest.json");
107208
+ const manifestPath = join19(cwd, ".reroute", "manifest.json");
107141
107209
  const manifestFile = Bun.file(manifestPath);
107142
107210
  const manifest = await manifestFile.json();
107143
107211
  if (manifest.staticRoutes && Array.isArray(manifest.staticRoutes)) {
@@ -107148,7 +107216,7 @@ async function findRoutesWithOG(cwd) {
107148
107216
  }
107149
107217
  } catch {
107150
107218
  console.warn("⚠️ .reroute/manifest.json not found, scanning routes directory...");
107151
- const routesPath = join18(cwd, ROUTES_DIR2);
107219
+ const routesPath = join19(cwd, ROUTES_DIR2);
107152
107220
  await scanForOgTemplates(routesPath, "", routes);
107153
107221
  await addContentRoutes(routesPath, routes);
107154
107222
  }
@@ -107400,7 +107468,7 @@ async function getVersionString2() {
107400
107468
  }
107401
107469
  async function getVersion2() {
107402
107470
  if (true) {
107403
- return "1.0.0-alpha.11";
107471
+ return "1.0.0-alpha.13";
107404
107472
  }
107405
107473
  const possiblePaths = [
107406
107474
  path3.join(import.meta.dir, "../../../package.json"),
@@ -107417,10 +107485,10 @@ async function getVersion2() {
107417
107485
  }
107418
107486
  async function getCommit2() {
107419
107487
  if (true) {
107420
- return "560df44";
107488
+ return "b24033d";
107421
107489
  }
107422
107490
  return "dev";
107423
107491
  }
107424
107492
  main();
107425
107493
 
107426
- //# debugId=BAC40B7CF280329664756E2164756E21
107494
+ //# debugId=14EA3B0FC77A708C64756E2164756E21