reroute-js 1.0.0-alpha.16 → 1.0.0-alpha.18

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 (210) hide show
  1. package/cli/bin.d.ts +1 -1
  2. package/cli/bin.js +89 -52
  3. package/cli/bin.js.map +14 -13
  4. package/cli/index.d.ts +1 -1
  5. package/cli/index.js +573 -19
  6. package/cli/index.js.map +51 -4
  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 +2 -2
  10. package/cli/src/commands/build.d.ts.map +1 -1
  11. package/cli/src/commands/dev.d.ts +4 -3
  12. package/cli/src/commands/dev.d.ts.map +1 -1
  13. package/cli/src/commands/gen.d.ts +1 -1
  14. package/cli/src/commands/gen.d.ts.map +1 -1
  15. package/cli/src/commands/index.d.ts +1 -1
  16. package/cli/src/commands/init.d.ts +1 -1
  17. package/cli/src/commands/lib/assets.d.ts +1 -1
  18. package/cli/src/commands/lib/bundler.d.ts +1 -1
  19. package/cli/src/commands/lib/command.d.ts +1 -1
  20. package/cli/src/commands/lib/env.d.ts +1 -1
  21. package/cli/src/commands/lib/index.d.ts +1 -1
  22. package/cli/src/commands/lib/log.d.ts +1 -1
  23. package/cli/src/commands/lib/markdown/availability.d.ts +1 -1
  24. package/cli/src/commands/lib/markdown/index.d.ts +1 -1
  25. package/cli/src/commands/lib/markdown/processor.d.ts +1 -1
  26. package/cli/src/commands/lib/production.d.ts +1 -1
  27. package/cli/src/commands/lib/server.d.ts +1 -1
  28. package/cli/src/commands/lib/streaming/analyzer.d.ts +1 -1
  29. package/cli/src/commands/lib/streaming/suspense.d.ts +1 -1
  30. package/cli/src/commands/lib/terminal-ui.d.ts +2 -2
  31. package/cli/src/commands/lib/terminal-ui.d.ts.map +1 -1
  32. package/cli/src/commands/lib/theme.d.ts +4 -2
  33. package/cli/src/commands/lib/theme.d.ts.map +1 -1
  34. package/cli/src/commands/lib/version.d.ts +1 -1
  35. package/cli/src/commands/lib/watch.d.ts +1 -1
  36. package/cli/src/commands/og.d.ts +1 -1
  37. package/cli/src/commands/og.d.ts.map +1 -1
  38. package/cli/src/commands/start.d.ts +2 -2
  39. package/cli/src/commands/start.d.ts.map +1 -1
  40. package/cli/src/index.d.ts +1 -1
  41. package/core/index.d.ts +1 -1
  42. package/core/index.js +33 -3
  43. package/core/index.js.map +7 -6
  44. package/core/src/app-paths.d.ts +32 -0
  45. package/core/src/app-paths.d.ts.map +1 -0
  46. package/core/src/bundler/hash.d.ts +1 -1
  47. package/core/src/bundler/index.d.ts +1 -1
  48. package/core/src/config.d.ts +15 -2
  49. package/core/src/config.d.ts.map +1 -1
  50. package/core/src/content/discovery.d.ts +1 -1
  51. package/core/src/content/index.d.ts +1 -1
  52. package/core/src/content/metadata.d.ts +1 -1
  53. package/core/src/i18n/catalog.d.ts +1 -1
  54. package/core/src/i18n/discover.d.ts +1 -1
  55. package/core/src/i18n/index.d.ts +1 -1
  56. package/core/src/i18n/messages.d.ts +1 -1
  57. package/core/src/i18n/negotiate.d.ts +1 -1
  58. package/core/src/i18n/pathname.d.ts +1 -1
  59. package/core/src/i18n/resolve.d.ts +1 -1
  60. package/core/src/i18n/types.d.ts +1 -1
  61. package/core/src/index.d.ts +2 -1
  62. package/core/src/index.d.ts.map +1 -1
  63. package/core/src/llms/discovery.d.ts +1 -1
  64. package/core/src/llms/extractor.d.ts +1 -1
  65. package/core/src/llms/formatter.d.ts +1 -1
  66. package/core/src/llms/full-generator.d.ts +1 -1
  67. package/core/src/llms/index-generator.d.ts +1 -1
  68. package/core/src/llms/index.d.ts +1 -1
  69. package/core/src/og/discovery.d.ts +1 -1
  70. package/core/src/og/index.d.ts +1 -1
  71. package/core/src/og/meta.d.ts +1 -1
  72. package/core/src/og/render.d.ts +1 -1
  73. package/core/src/og/types.d.ts +1 -1
  74. package/core/src/robots/discovery.d.ts +1 -1
  75. package/core/src/robots/generator.d.ts +1 -1
  76. package/core/src/robots/index.d.ts +1 -1
  77. package/core/src/robots/policies.d.ts +1 -1
  78. package/core/src/rss/discovery.d.ts +1 -1
  79. package/core/src/rss/generator.d.ts +1 -1
  80. package/core/src/rss/index.d.ts +1 -1
  81. package/core/src/sitemap/discovery.d.ts +1 -1
  82. package/core/src/sitemap/generator.d.ts +1 -1
  83. package/core/src/sitemap/index.d.ts +1 -1
  84. package/core/src/ssr/index.d.ts +1 -1
  85. package/core/src/ssr/lib/cache.d.ts +1 -1
  86. package/core/src/ssr/lib/cleanup.d.ts +1 -1
  87. package/core/src/ssr/lib/collections.d.ts +1 -1
  88. package/core/src/ssr/lib/compression.d.ts +1 -1
  89. package/core/src/ssr/lib/compute/content.d.ts +1 -1
  90. package/core/src/ssr/lib/compute/index.d.ts +1 -1
  91. package/core/src/ssr/lib/compute/layouts.d.ts +1 -1
  92. package/core/src/ssr/lib/compute/routes.d.ts +1 -1
  93. package/core/src/ssr/lib/content-path.d.ts +1 -1
  94. package/core/src/ssr/lib/data.d.ts +1 -1
  95. package/core/src/ssr/lib/html.d.ts +1 -1
  96. package/core/src/ssr/lib/imports.d.ts +1 -1
  97. package/core/src/ssr/lib/index.d.ts +1 -1
  98. package/core/src/ssr/lib/layouts.d.ts +1 -1
  99. package/core/src/ssr/lib/metadata.d.ts +1 -1
  100. package/core/src/ssr/lib/mime.d.ts +1 -1
  101. package/core/src/ssr/lib/modules.d.ts +1 -1
  102. package/core/src/ssr/lib/path.d.ts +1 -1
  103. package/core/src/ssr/lib/preload.d.ts +1 -1
  104. package/core/src/ssr/lib/route-match.d.ts +1 -1
  105. package/core/src/ssr/lib/scripts/collections.d.ts +1 -1
  106. package/core/src/ssr/lib/scripts/data.d.ts +1 -1
  107. package/core/src/ssr/lib/scripts/escape.d.ts +1 -1
  108. package/core/src/ssr/lib/scripts/feeds.d.ts +1 -1
  109. package/core/src/ssr/lib/scripts/index.d.ts +1 -1
  110. package/core/src/ssr/lib/seed.d.ts +1 -1
  111. package/core/src/ssr/lib/serialize.d.ts +1 -1
  112. package/core/src/ssr/lib/setup.d.ts +1 -1
  113. package/core/src/ssr/lib/styles.d.ts +1 -1
  114. package/core/src/ssr/lib/template.d.ts +1 -1
  115. package/core/src/ssr/lib/types.d.ts +1 -1
  116. package/core/src/ssr/render.d.ts +1 -1
  117. package/core/src/ssr/stream.d.ts +1 -1
  118. package/elysia/index.d.ts +1 -1
  119. package/elysia/index.js +64 -19
  120. package/elysia/index.js.map +9 -7
  121. package/elysia/src/index.d.ts +1 -1
  122. package/elysia/src/libs/assets.d.ts +1 -1
  123. package/elysia/src/libs/cache.d.ts +1 -1
  124. package/elysia/src/libs/caching.d.ts +1 -1
  125. package/elysia/src/libs/http.d.ts +1 -1
  126. package/elysia/src/libs/i18n.d.ts +1 -1
  127. package/elysia/src/libs/image.d.ts +1 -1
  128. package/elysia/src/libs/index.d.ts +1 -1
  129. package/elysia/src/libs/llms.d.ts +1 -1
  130. package/elysia/src/libs/response.d.ts +1 -1
  131. package/elysia/src/libs/serving.d.ts +1 -1
  132. package/elysia/src/plugin.d.ts +1 -1
  133. package/elysia/src/plugin.d.ts.map +1 -1
  134. package/elysia/src/routes/artifacts.d.ts +1 -1
  135. package/elysia/src/routes/content.d.ts +1 -1
  136. package/elysia/src/routes/image.d.ts +1 -1
  137. package/elysia/src/routes/index.d.ts +1 -1
  138. package/elysia/src/routes/internal.d.ts +1 -1
  139. package/elysia/src/routes/liveReloadClient.d.ts +1 -1
  140. package/elysia/src/routes/llms.d.ts +1 -1
  141. package/elysia/src/routes/og.d.ts +1 -1
  142. package/elysia/src/routes/redirects.d.ts +1 -1
  143. package/elysia/src/routes/robots.d.ts +1 -1
  144. package/elysia/src/routes/rss.d.ts +1 -1
  145. package/elysia/src/routes/search.d.ts +1 -1
  146. package/elysia/src/routes/sitemap.d.ts +1 -1
  147. package/elysia/src/routes/ssr.d.ts +1 -1
  148. package/elysia/src/routes/static.d.ts +1 -1
  149. package/elysia/src/routes/themeCssRefresh.d.ts +1 -1
  150. package/elysia/src/types.d.ts +1 -1
  151. package/package.json +1 -1
  152. package/react/index.d.ts +1 -1
  153. package/react/index.js +11 -3
  154. package/react/index.js.map +3 -3
  155. package/react/src/components/ClientOnly.d.ts +1 -1
  156. package/react/src/components/ContentRoute.d.ts +1 -1
  157. package/react/src/components/Image.d.ts +1 -1
  158. package/react/src/components/LazyRoute.d.ts +1 -1
  159. package/react/src/components/Link.d.ts +1 -1
  160. package/react/src/components/Markdown.d.ts +1 -1
  161. package/react/src/components/Outlet.d.ts +1 -1
  162. package/react/src/components/index.d.ts +1 -1
  163. package/react/src/hooks/index.d.ts +1 -1
  164. package/react/src/hooks/useContent.d.ts +1 -1
  165. package/react/src/hooks/useData.d.ts +1 -1
  166. package/react/src/hooks/useFeed.d.ts +1 -1
  167. package/react/src/hooks/useLayoutData.d.ts +1 -1
  168. package/react/src/hooks/useLlms.d.ts +1 -1
  169. package/react/src/hooks/useNavigate.d.ts +1 -1
  170. package/react/src/hooks/useParams.d.ts +1 -1
  171. package/react/src/hooks/useRouter.d.ts +1 -1
  172. package/react/src/hooks/useSearch.d.ts +1 -1
  173. package/react/src/hooks/useSearchParams.d.ts +1 -1
  174. package/react/src/hooks/useToc.d.ts +1 -1
  175. package/react/src/i18n/LocaleProvider.d.ts +1 -1
  176. package/react/src/i18n/helpers.d.ts +1 -1
  177. package/react/src/i18n/index.d.ts +1 -1
  178. package/react/src/index.d.ts +1 -1
  179. package/react/src/lib/collection.d.ts +1 -1
  180. package/react/src/lib/content.d.ts +1 -1
  181. package/react/src/lib/head.d.ts +1 -1
  182. package/react/src/lib/index.d.ts +1 -1
  183. package/react/src/lib/lazy-route.d.ts +1 -1
  184. package/react/src/lib/lazy-route.d.ts.map +1 -1
  185. package/react/src/lib/route-loader.d.ts +1 -1
  186. package/react/src/providers/ContentProvider.d.ts +1 -1
  187. package/react/src/providers/RerouteProvider.d.ts +1 -1
  188. package/react/src/providers/RouterProvider.d.ts +1 -1
  189. package/react/src/providers/index.d.ts +1 -1
  190. package/react/src/types/any.d.ts +1 -1
  191. package/react/src/types/index.d.ts +1 -1
  192. package/react/src/types/router.d.ts +1 -1
  193. package/telemetry/react.d.ts +1 -1
  194. package/telemetry/react.js +2 -2
  195. package/telemetry/react.js.map +1 -1
  196. package/telemetry/server.d.ts +1 -1
  197. package/telemetry/server.js +6 -2
  198. package/telemetry/server.js.map +5 -5
  199. package/telemetry/src/react/api.d.ts +1 -1
  200. package/telemetry/src/react/context.d.ts +1 -1
  201. package/telemetry/src/react/index.d.ts +1 -1
  202. package/telemetry/src/react/telemetry.d.ts +1 -1
  203. package/telemetry/src/server/context.d.ts +1 -1
  204. package/telemetry/src/server/headers/extractor.d.ts +1 -1
  205. package/telemetry/src/server/headers/index.d.ts +1 -1
  206. package/telemetry/src/server/headers/presets.d.ts +1 -1
  207. package/telemetry/src/server/index.d.ts +1 -1
  208. package/telemetry/src/server/instrumentation.d.ts +1 -1
  209. package/telemetry/src/server/plugin.d.ts +1 -1
  210. package/telemetry/src/server/sourcemap.d.ts +1 -1
package/cli/bin.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * reroute-js v1.0.0-alpha.16
2
+ * reroute-js v1.0.0-alpha.18
3
3
  *
4
4
  * @license MIT
5
5
  * @copyright 2026 stewones <hi@stewan.io>
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.16
4
+ * reroute-js v1.0.0-alpha.18
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.16";
71
+ return "1.0.0-alpha.18";
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 "44faab0";
89
+ return "ee1178f";
90
90
  }
91
91
  return "dev";
92
92
  }
@@ -363,6 +363,31 @@ var init_init = __esm(() => {
363
363
  ];
364
364
  });
365
365
 
366
+ // packages/core/src/app-paths.ts
367
+ import { posix } from "node:path";
368
+ function toPosix(p) {
369
+ return p.replace(/\\/g, "/");
370
+ }
371
+ function resolveAppPaths(config = {}) {
372
+ const src = config.app?.src ?? DEFAULT_APP_SRC;
373
+ const server = config.app?.server ?? DEFAULT_APP_SERVER;
374
+ const clientDir = toPosix(posix.dirname(src));
375
+ return {
376
+ src,
377
+ clientDir,
378
+ routesDir: toPosix(posix.join(clientDir, "routes")),
379
+ cssEntry: toPosix(posix.join(clientDir, "index.css")),
380
+ assetsDir: toPosix(posix.join(clientDir, "assets")),
381
+ server
382
+ };
383
+ }
384
+ function importFromReroute(relPath) {
385
+ const cleaned = toPosix(relPath).replace(/^\.\//, "").replace(/\.(tsx|ts|jsx|js)$/, "");
386
+ return `../${cleaned}`;
387
+ }
388
+ var DEFAULT_APP_SRC = "./src/client/App", DEFAULT_APP_SERVER = "./src/index.ts";
389
+ var init_app_paths = () => {};
390
+
366
391
  // packages/core/src/bundler/hash.ts
367
392
  async function generateContentHash(content) {
368
393
  const data = new TextEncoder().encode(content);
@@ -3697,7 +3722,7 @@ function createI18nScript(i18n) {
3697
3722
  }
3698
3723
  }
3699
3724
  function createContentCaptureScript() {
3700
- return `<script>(function(){try{var w=window;w.__REROUTE_INITIAL_HYDRATION__=true;var h={};document.querySelectorAll('[data-reroute-key]').forEach(function(el){var k=el.getAttribute('data-reroute-key');if(k)h[k]=el.innerHTML;});w.__REROUTE_CONTENT_HTML__=h;var r=document.querySelector('[data-reroute-route="ssr"]');if(r)w.__REROUTE_ROUTE_HTML__=r.innerHTML;}catch(e){}})();</script>`;
3725
+ return `<script>(function(){try{var w=window;w.__REROUTE_INITIAL_HYDRATION__=true;var h={};document.querySelectorAll('[data-reroute-key]').forEach(function(el){var k=el.getAttribute('data-reroute-key');if(k)h[k]=el.innerHTML;});w.__REROUTE_CONTENT_HTML__=h;var r=document.querySelector('[data-reroute-route="ssr"]');if(r){w.__REROUTE_ROUTE_HTML__=r.innerHTML;}else{var root=document.getElementById('root');if(root)w.__REROUTE_ROUTE_HTML__=root.innerHTML;}}catch(e){}})();</script>`;
3701
3726
  }
3702
3727
  function createSSRExportsScript(pathname) {
3703
3728
  try {
@@ -6895,6 +6920,7 @@ var init_ssr = __esm(() => {
6895
6920
 
6896
6921
  // packages/core/src/index.ts
6897
6922
  var init_src = __esm(() => {
6923
+ init_app_paths();
6898
6924
  init_bundler();
6899
6925
  init_config();
6900
6926
  init_content();
@@ -6911,6 +6937,8 @@ var init_src = __esm(() => {
6911
6937
  var exports_core = {};
6912
6938
  __export(exports_core, {
6913
6939
  AI_CRAWLERS: () => AI_CRAWLERS,
6940
+ DEFAULT_APP_SERVER: () => DEFAULT_APP_SERVER,
6941
+ DEFAULT_APP_SRC: () => DEFAULT_APP_SRC,
6914
6942
  DEFAULT_COOKIE: () => DEFAULT_COOKIE,
6915
6943
  DEFAULT_LOCALE: () => DEFAULT_LOCALE,
6916
6944
  DEFAULT_LOCALES_DIR: () => DEFAULT_LOCALES_DIR,
@@ -7006,6 +7034,7 @@ __export(exports_core, {
7006
7034
  hreflangTags: () => hreflangTags,
7007
7035
  htmlToMarkdown: () => htmlToMarkdown,
7008
7036
  importContentModuleForPath: () => importContentModuleForPath,
7037
+ importFromReroute: () => importFromReroute,
7009
7038
  inlineThemeCSS: () => inlineThemeCSS,
7010
7039
  isCompressible: () => isCompressible,
7011
7040
  isThenable: () => isThenable,
@@ -7039,6 +7068,7 @@ __export(exports_core, {
7039
7068
  renderSSRDocumentStream: () => renderSSRDocumentStream,
7040
7069
  resetSSRAccessTracking: () => resetSSRAccessTracking,
7041
7070
  resetSSRContentResults: () => resetSSRContentResults,
7071
+ resolveAppPaths: () => resolveAppPaths,
7042
7072
  resolveLocale: () => resolveLocale,
7043
7073
  seedSSRModuleForPath: () => seedSSRModuleForPath,
7044
7074
  setGlobalCollections: () => setGlobalCollections,
@@ -7784,8 +7814,9 @@ import { createHash as createHash2 } from "node:crypto";
7784
7814
  import { existsSync as existsSync5, readFileSync as readFileSync4 } from "node:fs";
7785
7815
  import { mkdir as mkdir2, readdir as readdir7, unlink as unlink2, writeFile } from "node:fs/promises";
7786
7816
  import { dirname as dirname6, isAbsolute, join as join10, resolve as resolve2 } from "node:path";
7787
- function getCssPaths(cwd) {
7788
- const input = join10(cwd, "src/client/index.css");
7817
+ async function getCssPaths(cwd) {
7818
+ const paths = resolveAppPaths(await loadConfig(cwd));
7819
+ const input = join10(cwd, paths.cssEntry);
7789
7820
  const bundlesDir = join10(cwd, ".reroute/bundles");
7790
7821
  return { input, bundlesDir };
7791
7822
  }
@@ -7843,7 +7874,7 @@ async function pruneStaleThemeCss(bundlesDir, keep) {
7843
7874
  }
7844
7875
  }
7845
7876
  async function syncThemeCss(cwd) {
7846
- const { input, bundlesDir } = getCssPaths(cwd);
7877
+ const { input, bundlesDir } = await getCssPaths(cwd);
7847
7878
  if (!existsSync5(input)) {
7848
7879
  return false;
7849
7880
  }
@@ -7867,6 +7898,7 @@ ${message}`);
7867
7898
  }
7868
7899
  var HASHED_THEME_RE2, IMPORT_RE;
7869
7900
  var init_theme = __esm(() => {
7901
+ init_core();
7870
7902
  HASHED_THEME_RE2 = /^index\.[a-z0-9]{8,}\.css$/i;
7871
7903
  IMPORT_RE = /@import\s+(?:url\(\s*)?(?:'([^']+)'|"([^"]+)"|([^'")\s]+))\s*\)?\s*([^;]*);/g;
7872
7904
  });
@@ -7972,7 +8004,7 @@ async function ensureOutputDir(cwd, options = {}) {
7972
8004
  await mkdir3(join12(cwd, ".reroute/streaming"), { recursive: true });
7973
8005
  } catch {}
7974
8006
  }
7975
- async function writeStubFiles(cwd) {
8007
+ async function writeStubFiles(cwd, serverImport) {
7976
8008
  const STUB_ROUTES = `// \uD83D\uDEA8 Auto-generated stub by Reroute - DO NOT EDIT \uD83D\uDEA8
7977
8009
  // This will be replaced by actual routes
7978
8010
  /* eslint-disable */
@@ -8038,14 +8070,14 @@ export const bundle = {
8038
8070
 
8039
8071
  export * from './artifacts';
8040
8072
  `;
8041
- const STUB_ENTRY = `// \uD83D\uDEA8 Auto-generated stub by Reroute - DO NOT EDIT \uD83D\uDEA8
8073
+ const stubEntry = `// \uD83D\uDEA8 Auto-generated stub by Reroute - DO NOT EDIT \uD83D\uDEA8
8042
8074
  // Server entry wrapper for compiled binary builds
8043
8075
  /* eslint-disable */
8044
8076
  // @ts-nocheck
8045
8077
 
8046
8078
  import './artifacts';
8047
8079
  import './routes'; // Import routes (bundles all route components)
8048
- import '../src/index';
8080
+ import '${serverImport}';
8049
8081
  `;
8050
8082
  await Bun.write(join12(cwd, OUTPUT_ROUTES), STUB_ROUTES);
8051
8083
  await Bun.write(join12(cwd, OUTPUT_ROUTES_CLIENT), STUB_ROUTES);
@@ -8054,7 +8086,7 @@ import '../src/index';
8054
8086
  await Bun.write(join12(cwd, OUTPUT_ARTIFACTS_CLIENT), STUB_ARTIFACTS_CLIENT);
8055
8087
  await Bun.write(join12(cwd, OUTPUT_ARTIFACTS_SERVER), STUB_ARTIFACTS_SERVER);
8056
8088
  await Bun.write(join12(cwd, OUTPUT_INDEX), STUB_INDEX);
8057
- await Bun.write(join12(cwd, ".reroute/entry.ts"), STUB_ENTRY);
8089
+ await Bun.write(join12(cwd, ".reroute/entry.ts"), stubEntry);
8058
8090
  console.log("[reroute/gen] Initialized stub files");
8059
8091
  }
8060
8092
  function shouldSkipFile(relativePath, entryName) {
@@ -8188,7 +8220,7 @@ function generateRouteTree(files) {
8188
8220
  notFoundRoutes
8189
8221
  };
8190
8222
  }
8191
- function getImportPath(filePath, streamingMap) {
8223
+ function getImportPath(filePath, streamingMap, routesImportBase) {
8192
8224
  const isMarkdown = /\.(md|mdx)$/.test(filePath);
8193
8225
  if (isMarkdown) {
8194
8226
  const pathWithoutExt2 = filePath.replace(/\.(md|mdx)$/, "");
@@ -8200,17 +8232,17 @@ function getImportPath(filePath, streamingMap) {
8200
8232
  return `./streaming/${pathWithoutExt2}`;
8201
8233
  }
8202
8234
  const pathWithoutExt = filePath.replace(/\.(tsx|ts)$/, "");
8203
- return `../src/client/routes/${pathWithoutExt}`;
8235
+ return `${routesImportBase}/${pathWithoutExt}`;
8204
8236
  }
8205
- function generateTypeScript(tree, streamingMap, client = false) {
8237
+ function generateTypeScript(tree, streamingMap, client, routesImportBase) {
8206
8238
  const helperImport = "import { createLazyRoute } from 'reroute-js/react';";
8207
8239
  const ssrHelper = "const _ssr = (m: any) => m.ssr;";
8208
8240
  const metaHelper = "const _meta = (m: any) => m.meta;";
8209
8241
  const metaImports = [
8210
- ...tree.routes.map((r, i) => `import * as Route${i}Module from '${getImportPath(r.filePath, streamingMap)}';
8242
+ ...tree.routes.map((r, i) => `import * as Route${i}Module from '${getImportPath(r.filePath, streamingMap, routesImportBase)}';
8211
8243
  const Route${i}SSR = _ssr(Route${i}Module);
8212
8244
  const Route${i}Meta = _meta(Route${i}Module);`),
8213
- ...tree.layouts.map((l, i) => `import * as Layout${i}Module from '${getImportPath(l.filePath, streamingMap)}';
8245
+ ...tree.layouts.map((l, i) => `import * as Layout${i}Module from '${getImportPath(l.filePath, streamingMap, routesImportBase)}';
8214
8246
  const Layout${i}SSR = _ssr(Layout${i}Module);
8215
8247
  const Layout${i}Meta = _meta(Layout${i}Module);`)
8216
8248
  ].join(`
@@ -8218,28 +8250,28 @@ const Layout${i}Meta = _meta(Layout${i}Module);`)
8218
8250
  const serverEagerImports = client ? "" : [
8219
8251
  ...tree.routes.map((_route, i) => `const Route${i}Eager = Route${i}Module.default;`),
8220
8252
  ...tree.layouts.map((_layout, i) => `const Layout${i}Eager = Layout${i}Module.default;`),
8221
- ...tree.notFoundRoutes.map((nf, i) => `import NotFound${i}Eager from '${getImportPath(nf.filePath, streamingMap)}';`)
8253
+ ...tree.notFoundRoutes.map((nf, i) => `import NotFound${i}Eager from '${getImportPath(nf.filePath, streamingMap, routesImportBase)}';`)
8222
8254
  ].join(`
8223
8255
  `);
8224
8256
  const eagerImports = client ? metaImports : [metaImports, serverEagerImports].filter(Boolean).join(`
8225
8257
  `);
8226
8258
  const lazyWrappers = [
8227
8259
  ...tree.routes.map((r, i) => {
8228
- const importPath = getImportPath(r.filePath, streamingMap);
8260
+ const importPath = getImportPath(r.filePath, streamingMap, routesImportBase);
8229
8261
  if (client) {
8230
8262
  return `const Route${i} = createLazyRoute(() => import('${importPath}'), "${r.pattern}");`;
8231
8263
  }
8232
8264
  return `const Route${i} = createLazyRoute(() => import('${importPath}'), "${r.pattern}", Route${i}Eager);`;
8233
8265
  }),
8234
8266
  ...tree.layouts.map((l, i) => {
8235
- const importPath = getImportPath(l.filePath, streamingMap);
8267
+ const importPath = getImportPath(l.filePath, streamingMap, routesImportBase);
8236
8268
  if (client) {
8237
8269
  return `const Layout${i} = createLazyRoute(() => import('${importPath}'), "${l.pattern}");`;
8238
8270
  }
8239
8271
  return `const Layout${i} = createLazyRoute(() => import('${importPath}'), "${l.pattern}", Layout${i}Eager);`;
8240
8272
  }),
8241
8273
  ...tree.notFoundRoutes.map((nf, i) => {
8242
- const importPath = getImportPath(nf.filePath, streamingMap);
8274
+ const importPath = getImportPath(nf.filePath, streamingMap, routesImportBase);
8243
8275
  if (client) {
8244
8276
  return `const NotFound${i} = createLazyRoute(() => import('${importPath}'), "${nf.notFoundBasePattern || "/"}");`;
8245
8277
  }
@@ -8619,8 +8651,8 @@ async function buildSingleContentChunk(cwd, collection, fileRef, contentDir, arg
8619
8651
  locale
8620
8652
  };
8621
8653
  }
8622
- async function buildContentChunks(cwd, args = [], defaultLocale = "en-US") {
8623
- const routesRoot = join12(cwd, ROUTES_DIR);
8654
+ async function buildContentChunks(cwd, args = [], defaultLocale = "en-US", routesDir) {
8655
+ const routesRoot = join12(cwd, routesDir);
8624
8656
  console.log(`[reroute/content] scan ${routesRoot}`);
8625
8657
  const collections2 = await readdir8(routesRoot, { withFileTypes: true });
8626
8658
  const results = [];
@@ -8738,7 +8770,7 @@ async function buildSearchIndex(cwd, config2, args = []) {
8738
8770
  minHeadingLevel = 1,
8739
8771
  maxHeadingLevel = 6
8740
8772
  } = searchConfig;
8741
- const routesRoot = join12(cwd, ROUTES_DIR);
8773
+ const routesRoot = join12(cwd, resolveAppPaths(config2).routesDir);
8742
8774
  const collections2 = await readdir8(routesRoot, { withFileTypes: true });
8743
8775
  const i18n2 = await discoverI18n(cwd, config2.i18n);
8744
8776
  const defaultLocale = i18n2.defaultLocale;
@@ -8813,7 +8845,7 @@ async function buildSearchIndex(cwd, config2, args = []) {
8813
8845
  }
8814
8846
  async function preprocessMarkdownFiles(cwd, config2) {
8815
8847
  console.log("[reroute/markdown] Starting markdown preprocessing...");
8816
- const routesPath = join12(cwd, ROUTES_DIR);
8848
+ const routesPath = join12(cwd, resolveAppPaths(config2).routesDir);
8817
8849
  const markdownDir = join12(cwd, ".reroute", "markdown");
8818
8850
  try {
8819
8851
  await rm(markdownDir, { force: true, recursive: true });
@@ -9054,6 +9086,8 @@ async function generate(cwd, args = [], options = {}) {
9054
9086
  console.log("[reroute/gen] Starting generation...");
9055
9087
  }
9056
9088
  const config2 = await loadConfig(cwd);
9089
+ const paths = resolveAppPaths(config2);
9090
+ const routesImportBase = importFromReroute(paths.routesDir);
9057
9091
  const streamingEnabled = config2.streaming?.enabled ?? false;
9058
9092
  const perfTrack = async (name, fn) => {
9059
9093
  const stepStart = performance.now();
@@ -9067,10 +9101,10 @@ async function generate(cwd, args = [], options = {}) {
9067
9101
  };
9068
9102
  await ensureOutputDir(cwd, { clean });
9069
9103
  if (writeStubs) {
9070
- await writeStubFiles(cwd);
9104
+ await writeStubFiles(cwd, importFromReroute(paths.server));
9071
9105
  }
9072
9106
  await perfTrack("Markdown preprocessing", () => preprocessMarkdownFiles(cwd, config2));
9073
- const routesPath = join12(cwd, ROUTES_DIR);
9107
+ const routesPath = join12(cwd, paths.routesDir);
9074
9108
  try {
9075
9109
  await perfTrack("Routes generation", async () => {
9076
9110
  const files = await scanDirectory(routesPath);
@@ -9078,8 +9112,8 @@ async function generate(cwd, args = [], options = {}) {
9078
9112
  const all = Array.from(new Set([...files, ...nfFiles]));
9079
9113
  const tree = generateRouteTree(all.map((f) => f.replace(/\\/g, "/")));
9080
9114
  const streamingAnalyses = streamingEnabled ? await buildStreamingWrappersForTree(cwd, routesPath, tree, config2) : new Map;
9081
- const serverRoutes = generateTypeScript(tree, streamingAnalyses, false);
9082
- const clientRoutes = generateTypeScript(tree, streamingAnalyses, true);
9115
+ const serverRoutes = generateTypeScript(tree, streamingAnalyses, false, routesImportBase);
9116
+ const clientRoutes = generateTypeScript(tree, streamingAnalyses, true, routesImportBase);
9083
9117
  await Bun.write(join12(cwd, OUTPUT_ROUTES), serverRoutes);
9084
9118
  await Bun.write(join12(cwd, OUTPUT_ROUTES_CLIENT), clientRoutes);
9085
9119
  });
@@ -9108,7 +9142,7 @@ async function generate(cwd, args = [], options = {}) {
9108
9142
  console.warn("[reroute/gen] Failed to write i18n.json:", error);
9109
9143
  }
9110
9144
  try {
9111
- await perfTrack("Content building", () => buildContentChunks(cwd, args, defaultLocale));
9145
+ await perfTrack("Content building", () => buildContentChunks(cwd, args, defaultLocale, paths.routesDir));
9112
9146
  if (!showPerformance) {
9113
9147
  console.log(`[reroute/gen] Generated content: ${join12(cwd, OUTPUT_CONTENT_TS)} + collections/*.js`);
9114
9148
  }
@@ -9200,12 +9234,12 @@ async function generate(cwd, args = [], options = {}) {
9200
9234
  const ogTemplatePath = config2.ogImage.defaultTemplate.startsWith(".") ? `../${config2.ogImage.defaultTemplate}` : config2.ogImage.defaultTemplate;
9201
9235
  indexLines.push(`import OGTemplate from '${ogTemplatePath}';`);
9202
9236
  }
9203
- const ogFiles = await scanOgFiles(join12(cwd, ROUTES_DIR));
9237
+ const ogFiles = await scanOgFiles(join12(cwd, paths.routesDir));
9204
9238
  const ogImports = [];
9205
9239
  for (let i = 0;i < ogFiles.length; i++) {
9206
9240
  const ogFile = ogFiles[i];
9207
9241
  const importName = `OGRoute${i}`;
9208
- const importPath = `../src/client/routes/${ogFile.replace(/\.(tsx|ts)$/, "")}`;
9242
+ const importPath = `${routesImportBase}/${ogFile.replace(/\.(tsx|ts)$/, "")}`;
9209
9243
  indexLines.push(`import ${importName} from '${importPath}';`);
9210
9244
  ogImports.push({ path: ogFile, name: importName });
9211
9245
  }
@@ -9313,7 +9347,7 @@ async function generate(cwd, args = [], options = {}) {
9313
9347
  "",
9314
9348
  "import './artifacts.server'; // SSR bundle (eager routes)",
9315
9349
  "import './routes'; // Route metadata for compiled binary discovery",
9316
- "import '../src/index'; // Import user's server entry"
9350
+ `import '${importFromReroute(paths.server)}'; // Import user's server entry`
9317
9351
  ];
9318
9352
  await Bun.write(join12(cwd, ".reroute/entry.ts"), entryLines.join(`
9319
9353
  `));
@@ -9526,7 +9560,8 @@ async function startGenWatch(cwd, args) {
9526
9560
  });
9527
9561
  });
9528
9562
  }
9529
- const routesPath = join12(cwd, ROUTES_DIR);
9563
+ const watchPaths = resolveAppPaths(loadedConfig);
9564
+ const routesPath = join12(cwd, watchPaths.routesDir);
9530
9565
  console.log(`[reroute/watch] \uD83D\uDCC1 Watching ${routesPath}...`);
9531
9566
  const routesWatcher = watch(routesPath, { recursive: true }, (_ev, filename) => {
9532
9567
  if (!filename)
@@ -9562,7 +9597,7 @@ async function startGenWatch(cwd, args) {
9562
9597
  redirectContentOnNegotiate: watchI18n.redirectContentOnNegotiate,
9563
9598
  catalogs: watchI18n.catalogs
9564
9599
  }, null, 2));
9565
- await buildContentChunks(cwd, args, watchI18n.defaultLocale);
9600
+ await buildContentChunks(cwd, args, watchI18n.defaultLocale, watchPaths.routesDir);
9566
9601
  const contentTime = ((performance.now() - contentStart) / 1000).toFixed(2);
9567
9602
  console.log(`[reroute/watch] └─ Content: ${contentTime}s`);
9568
9603
  if (loadedConfig.search?.enabled) {
@@ -9592,7 +9627,7 @@ async function startGenWatch(cwd, args) {
9592
9627
  });
9593
9628
  });
9594
9629
  });
9595
- const clientPath = join12(cwd, "src", "client");
9630
+ const clientPath = join12(cwd, watchPaths.clientDir);
9596
9631
  console.log(`[reroute/watch] \uD83D\uDCE6 Watching ${clientPath}...`);
9597
9632
  async function rebuildWatchedClient(changed) {
9598
9633
  const label = changed.length === 1 ? changed[0] : `${changed.length} files`;
@@ -9685,7 +9720,7 @@ async function gen(args) {
9685
9720
  });
9686
9721
  process.exit(0);
9687
9722
  }
9688
- var ROUTES_DIR = "src/client/routes", OUTPUT_DIR = ".reroute", OUTPUT_ROUTES = ".reroute/routes.ts", OUTPUT_ROUTES_CLIENT = ".reroute/routes.client.ts", OUTPUT_CONTENT_TS = ".reroute/content.ts", OUTPUT_COLLECTIONS_DIR = ".reroute/collections", OUTPUT_SEARCH_INDEX = ".reroute/search.json", OUTPUT_ARTIFACTS = ".reroute/artifacts.ts", OUTPUT_ARTIFACTS_SERVER = ".reroute/artifacts.server.ts", OUTPUT_ARTIFACTS_CLIENT = ".reroute/artifacts.client.ts", OUTPUT_INDEX = ".reroute/index.ts";
9723
+ var OUTPUT_DIR = ".reroute", OUTPUT_ROUTES = ".reroute/routes.ts", OUTPUT_ROUTES_CLIENT = ".reroute/routes.client.ts", OUTPUT_CONTENT_TS = ".reroute/content.ts", OUTPUT_COLLECTIONS_DIR = ".reroute/collections", OUTPUT_SEARCH_INDEX = ".reroute/search.json", OUTPUT_ARTIFACTS = ".reroute/artifacts.ts", OUTPUT_ARTIFACTS_SERVER = ".reroute/artifacts.server.ts", OUTPUT_ARTIFACTS_CLIENT = ".reroute/artifacts.client.ts", OUTPUT_INDEX = ".reroute/index.ts";
9689
9724
  var init_gen = __esm(() => {
9690
9725
  init_core();
9691
9726
  init_env();
@@ -104358,9 +104393,9 @@ function setupProcessOutput(box, process2, screen, colorizeLogPrefix2) {
104358
104393
  screen.render();
104359
104394
  });
104360
104395
  }
104361
- function setupTerminalUIHandlers(screen, grid, genProcess, serverProcess, outputBuffer, blessed, colorizeLogPrefix2) {
104396
+ function setupTerminalUIHandlers(screen, grid, genProcess, serverProcess, outputBuffer, blessed, colorizeLogPrefix2, serverEntry = "src/index.ts") {
104362
104397
  const genBox = createLogBox(grid, blessed, 0, 0, " reroute gen --watch ", "cyan");
104363
- const serverBox = createLogBox(grid, blessed, 0, 1, " bun --watch src/index.ts ", "green");
104398
+ const serverBox = createLogBox(grid, blessed, 0, 1, ` bun --watch ${serverEntry} `, "green");
104364
104399
  setupScrollingKeys(genBox, screen);
104365
104400
  setupScrollingKeys(serverBox, screen);
104366
104401
  setupMouseSupport(genBox, screen);
@@ -104457,7 +104492,8 @@ async function startTui(port) {
104457
104492
  genProcess.kill();
104458
104493
  process.exit(1);
104459
104494
  });
104460
- const serverProcess = spawn("bun", ["--watch", "src/index.ts"], {
104495
+ const { server: server2 } = resolveAppPaths(await loadConfig(process.cwd()));
104496
+ const serverProcess = spawn("bun", ["--watch", server2], {
104461
104497
  stdio: ["ignore", "pipe", "pipe"],
104462
104498
  env: {
104463
104499
  ...process.env,
@@ -104488,13 +104524,14 @@ async function startTui(port) {
104488
104524
  screen
104489
104525
  });
104490
104526
  const { setupTerminalUIHandlers: setupTerminalUIHandlers2 } = await Promise.resolve().then(() => exports_terminal_ui);
104491
- setupTerminalUIHandlers2(screen, grid, genProcess, serverProcess, outputBuffer, blessed, colorizeLogPrefix);
104527
+ setupTerminalUIHandlers2(screen, grid, genProcess, serverProcess, outputBuffer, blessed, colorizeLogPrefix, server2);
104492
104528
  }
104493
104529
  async function startDefault(port) {
104494
104530
  process.env.PORT = String(port);
104495
104531
  process.env.REROUTE_DEV = "1";
104496
104532
  const session = await startGenWatch(process.cwd(), ["--watch"]);
104497
- const entry = join14(process.cwd(), "src/index.ts");
104533
+ const { server: server2 } = resolveAppPaths(await loadConfig(process.cwd()));
104534
+ const entry = join14(process.cwd(), server2);
104498
104535
  if (!existsSync7(entry)) {
104499
104536
  session.close();
104500
104537
  throw new Error(`[reroute/dev] Missing ${entry}`);
@@ -104548,6 +104585,7 @@ async function dev(args) {
104548
104585
  }
104549
104586
  }
104550
104587
  var init_dev = __esm(() => {
104588
+ init_core();
104551
104589
  init_gen();
104552
104590
  init_command();
104553
104591
  init_log();
@@ -104634,7 +104672,8 @@ async function start(args) {
104634
104672
  `));
104635
104673
  process.stdout.write(`${colorizeLogPrefixAnsi("[reroute/start] Starting server...")}
104636
104674
  `);
104637
- const serverProcess = spawn2("bun", ["src/index.ts"], {
104675
+ const { server: server2 } = resolveAppPaths(await loadConfig(process.cwd()));
104676
+ const serverProcess = spawn2("bun", [server2], {
104638
104677
  stdio: ["ignore", "pipe", "pipe"],
104639
104678
  env: {
104640
104679
  ...process.env,
@@ -104690,6 +104729,7 @@ async function start(args) {
104690
104729
  }
104691
104730
  }
104692
104731
  var init_start = __esm(() => {
104732
+ init_core();
104693
104733
  init_log();
104694
104734
  });
104695
104735
 
@@ -104850,10 +104890,8 @@ async function runGenCommand(rerouteCmd, useShell, noCompression) {
104850
104890
  }
104851
104891
  async function copyAssets(cwd) {
104852
104892
  const config2 = await loadConfig(cwd);
104853
- const appSrc = config2.app?.src ?? "./src/client/App";
104854
- const dirname8 = __require("node:path").dirname;
104855
- const assetsPath = dirname8(appSrc);
104856
- const sourceAssetsDir = join17(cwd, assetsPath, "assets");
104893
+ const { assetsDir } = resolveAppPaths(config2);
104894
+ const sourceAssetsDir = join17(cwd, assetsDir);
104857
104895
  const rerouteAssetsDir = join17(cwd, ".reroute", "assets");
104858
104896
  process.stdout.write(colorizeLogPrefixAnsi(`[reroute/build] Copying assets...
104859
104897
  `));
@@ -107340,7 +107378,7 @@ async function findRoutesWithOG(cwd) {
107340
107378
  }
107341
107379
  } catch {
107342
107380
  console.warn("⚠️ .reroute/manifest.json not found, scanning routes directory...");
107343
- const routesPath = join19(cwd, ROUTES_DIR2);
107381
+ const routesPath = join19(cwd, resolveAppPaths(await loadConfig(cwd)).routesDir);
107344
107382
  await scanForOgTemplates(routesPath, "", routes);
107345
107383
  await addContentRoutes(routesPath, routes);
107346
107384
  }
@@ -107378,7 +107416,7 @@ ogImage: {
107378
107416
  console.error("❌ No routes found for OG image generation");
107379
107417
  console.log(`
107380
107418
  Make sure you have:`);
107381
- console.log(" 1. Routes defined in src/client/routes/");
107419
+ console.log(` 1. Routes defined in ${resolveAppPaths(config2).routesDir}/`);
107382
107420
  console.log(" 2. Run `reroute dev` or `reroute build` first to generate .reroute/manifest.json");
107383
107421
  console.log(`
107384
107422
  Or create [og].tsx files in your routes for custom OG templates.`);
@@ -107483,7 +107521,6 @@ Or create [og].tsx files in your routes for custom OG templates.`);
107483
107521
  list.focus();
107484
107522
  screen.render();
107485
107523
  }
107486
- var ROUTES_DIR2 = "src/client/routes";
107487
107524
  var init_og2 = __esm(() => {
107488
107525
  init_core();
107489
107526
  });
@@ -107592,7 +107629,7 @@ async function getVersionString2() {
107592
107629
  }
107593
107630
  async function getVersion2() {
107594
107631
  if (true) {
107595
- return "1.0.0-alpha.16";
107632
+ return "1.0.0-alpha.18";
107596
107633
  }
107597
107634
  const possiblePaths = [
107598
107635
  path3.join(import.meta.dir, "../../../package.json"),
@@ -107609,10 +107646,10 @@ async function getVersion2() {
107609
107646
  }
107610
107647
  async function getCommit2() {
107611
107648
  if (true) {
107612
- return "44faab0";
107649
+ return "ee1178f";
107613
107650
  }
107614
107651
  return "dev";
107615
107652
  }
107616
107653
  main();
107617
107654
 
107618
- //# debugId=04F6A76937DD767764756E2164756E21
107655
+ //# debugId=8378878696E4AA1264756E2164756E21