reroute-js 0.20.2 → 0.20.4

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 (173) hide show
  1. package/cli/bin.d.ts +1 -1
  2. package/cli/bin.js +316 -117
  3. package/cli/bin.js.map +16 -15
  4. package/cli/index.d.ts +1 -1
  5. package/cli/index.js +4 -4
  6. package/cli/index.js.map +1 -1
  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 +3 -2
  10. package/cli/src/commands/build.d.ts.map +1 -1
  11. package/cli/src/commands/dev.d.ts +1 -1
  12. package/cli/src/commands/gen.d.ts +1 -1
  13. package/cli/src/commands/gen.d.ts.map +1 -1
  14. package/cli/src/commands/index.d.ts +1 -1
  15. package/cli/src/commands/init.d.ts +1 -1
  16. package/cli/src/commands/lib/assets.d.ts +24 -0
  17. package/cli/src/commands/lib/assets.d.ts.map +1 -0
  18. package/cli/src/commands/lib/command.d.ts +1 -1
  19. package/cli/src/commands/lib/env.d.ts +1 -1
  20. package/cli/src/commands/lib/index.d.ts +1 -1
  21. package/cli/src/commands/lib/log.d.ts +1 -1
  22. package/cli/src/commands/lib/markdown/availability.d.ts +1 -1
  23. package/cli/src/commands/lib/markdown/index.d.ts +1 -1
  24. package/cli/src/commands/lib/markdown/processor.d.ts +1 -1
  25. package/cli/src/commands/lib/production.d.ts +1 -1
  26. package/cli/src/commands/lib/server.d.ts +1 -1
  27. package/cli/src/commands/lib/streaming/analyzer.d.ts +1 -1
  28. package/cli/src/commands/lib/streaming/suspense.d.ts +1 -1
  29. package/cli/src/commands/lib/tailwind.d.ts +1 -1
  30. package/cli/src/commands/lib/version.d.ts +1 -1
  31. package/cli/src/commands/og.d.ts +1 -1
  32. package/cli/src/commands/start.d.ts +1 -1
  33. package/cli/src/index.d.ts +1 -1
  34. package/core/index.d.ts +1 -1
  35. package/core/index.js +150 -40
  36. package/core/index.js.map +12 -12
  37. package/core/src/bundler/hash.d.ts +1 -1
  38. package/core/src/bundler/index.d.ts +1 -1
  39. package/core/src/config.d.ts +1 -1
  40. package/core/src/content/discovery.d.ts +1 -1
  41. package/core/src/content/index.d.ts +1 -1
  42. package/core/src/content/metadata.d.ts +1 -1
  43. package/core/src/index.d.ts +1 -1
  44. package/core/src/llms/extractor.d.ts +1 -1
  45. package/core/src/llms/formatter.d.ts +1 -1
  46. package/core/src/llms/full-generator.d.ts +1 -1
  47. package/core/src/llms/index-generator.d.ts +1 -1
  48. package/core/src/llms/index-generator.d.ts.map +1 -1
  49. package/core/src/llms/index.d.ts +1 -1
  50. package/core/src/og/discovery.d.ts +1 -1
  51. package/core/src/og/index.d.ts +1 -1
  52. package/core/src/og/meta.d.ts +1 -1
  53. package/core/src/og/render.d.ts +1 -1
  54. package/core/src/og/types.d.ts +1 -1
  55. package/core/src/robots/discovery.d.ts +1 -1
  56. package/core/src/robots/discovery.d.ts.map +1 -1
  57. package/core/src/robots/generator.d.ts +1 -1
  58. package/core/src/robots/index.d.ts +1 -1
  59. package/core/src/robots/policies.d.ts +1 -1
  60. package/core/src/rss/discovery.d.ts +1 -1
  61. package/core/src/rss/discovery.d.ts.map +1 -1
  62. package/core/src/rss/generator.d.ts +1 -1
  63. package/core/src/rss/index.d.ts +1 -1
  64. package/core/src/sitemap/discovery.d.ts +1 -1
  65. package/core/src/sitemap/discovery.d.ts.map +1 -1
  66. package/core/src/sitemap/generator.d.ts +1 -1
  67. package/core/src/sitemap/index.d.ts +1 -1
  68. package/core/src/ssr/index.d.ts +1 -1
  69. package/core/src/ssr/lib/cache.d.ts +1 -1
  70. package/core/src/ssr/lib/collections.d.ts +1 -1
  71. package/core/src/ssr/lib/compression.d.ts +1 -1
  72. package/core/src/ssr/lib/compute/content.d.ts +1 -1
  73. package/core/src/ssr/lib/compute/index.d.ts +1 -1
  74. package/core/src/ssr/lib/compute/index.d.ts.map +1 -1
  75. package/core/src/ssr/lib/compute/layouts.d.ts +1 -1
  76. package/core/src/ssr/lib/compute/layouts.d.ts.map +1 -1
  77. package/core/src/ssr/lib/compute/routes.d.ts +1 -1
  78. package/core/src/ssr/lib/compute/routes.d.ts.map +1 -1
  79. package/core/src/ssr/lib/data.d.ts +1 -1
  80. package/core/src/ssr/lib/data.d.ts.map +1 -1
  81. package/core/src/ssr/lib/html.d.ts +1 -1
  82. package/core/src/ssr/lib/imports.d.ts +1 -1
  83. package/core/src/ssr/lib/index.d.ts +1 -1
  84. package/core/src/ssr/lib/layouts.d.ts +1 -1
  85. package/core/src/ssr/lib/metadata.d.ts +1 -1
  86. package/core/src/ssr/lib/mime.d.ts +1 -1
  87. package/core/src/ssr/lib/modules.d.ts +1 -1
  88. package/core/src/ssr/lib/path.d.ts +1 -1
  89. package/core/src/ssr/lib/preload.d.ts +1 -1
  90. package/core/src/ssr/lib/scripts/collections.d.ts +1 -1
  91. package/core/src/ssr/lib/scripts/data.d.ts +1 -1
  92. package/core/src/ssr/lib/scripts/escape.d.ts +1 -1
  93. package/core/src/ssr/lib/scripts/feeds.d.ts +1 -1
  94. package/core/src/ssr/lib/scripts/index.d.ts +1 -1
  95. package/core/src/ssr/lib/seed.d.ts +1 -1
  96. package/core/src/ssr/lib/setup.d.ts +1 -1
  97. package/core/src/ssr/lib/styles.d.ts +1 -1
  98. package/core/src/ssr/lib/styles.d.ts.map +1 -1
  99. package/core/src/ssr/lib/template.d.ts +1 -1
  100. package/core/src/ssr/lib/types.d.ts +1 -1
  101. package/core/src/ssr/render.d.ts +1 -1
  102. package/core/src/ssr/stream.d.ts +1 -1
  103. package/core/src/ssr/stream.d.ts.map +1 -1
  104. package/elysia/index.d.ts +1 -1
  105. package/elysia/index.js +169 -45
  106. package/elysia/index.js.map +15 -14
  107. package/elysia/src/index.d.ts +1 -1
  108. package/elysia/src/libs/assets.d.ts +15 -0
  109. package/elysia/src/libs/assets.d.ts.map +1 -0
  110. package/elysia/src/libs/cache.d.ts +1 -1
  111. package/elysia/src/libs/caching.d.ts +1 -1
  112. package/elysia/src/libs/http.d.ts +1 -1
  113. package/elysia/src/libs/image.d.ts +1 -1
  114. package/elysia/src/libs/index.d.ts +2 -1
  115. package/elysia/src/libs/index.d.ts.map +1 -1
  116. package/elysia/src/libs/llms.d.ts +1 -1
  117. package/elysia/src/libs/response.d.ts +1 -1
  118. package/elysia/src/libs/serving.d.ts +1 -1
  119. package/elysia/src/plugin.d.ts +1 -1
  120. package/elysia/src/plugin.d.ts.map +1 -1
  121. package/elysia/src/routes/artifacts.d.ts +1 -1
  122. package/elysia/src/routes/content.d.ts +1 -1
  123. package/elysia/src/routes/image.d.ts +1 -1
  124. package/elysia/src/routes/index.d.ts +1 -1
  125. package/elysia/src/routes/internal.d.ts +1 -1
  126. package/elysia/src/routes/llms.d.ts +1 -1
  127. package/elysia/src/routes/og.d.ts +1 -1
  128. package/elysia/src/routes/redirects.d.ts +1 -1
  129. package/elysia/src/routes/robots.d.ts +1 -1
  130. package/elysia/src/routes/rss.d.ts +1 -1
  131. package/elysia/src/routes/search.d.ts +1 -1
  132. package/elysia/src/routes/sitemap.d.ts +1 -1
  133. package/elysia/src/routes/ssr.d.ts +1 -1
  134. package/elysia/src/routes/static.d.ts +1 -1
  135. package/elysia/src/types.d.ts +1 -1
  136. package/package.json +1 -1
  137. package/react/index.d.ts +1 -1
  138. package/react/index.js +2 -2
  139. package/react/index.js.map +1 -1
  140. package/react/src/components/ClientOnly.d.ts +1 -1
  141. package/react/src/components/ContentRoute.d.ts +1 -1
  142. package/react/src/components/Image.d.ts +1 -1
  143. package/react/src/components/LazyRoute.d.ts +1 -1
  144. package/react/src/components/Link.d.ts +1 -1
  145. package/react/src/components/Markdown.d.ts +1 -1
  146. package/react/src/components/Outlet.d.ts +1 -1
  147. package/react/src/components/index.d.ts +1 -1
  148. package/react/src/hooks/index.d.ts +1 -1
  149. package/react/src/hooks/useContent.d.ts +1 -1
  150. package/react/src/hooks/useData.d.ts +1 -1
  151. package/react/src/hooks/useFeed.d.ts +1 -1
  152. package/react/src/hooks/useLayoutData.d.ts +1 -1
  153. package/react/src/hooks/useLlms.d.ts +1 -1
  154. package/react/src/hooks/useNavigate.d.ts +1 -1
  155. package/react/src/hooks/useParams.d.ts +1 -1
  156. package/react/src/hooks/useRouter.d.ts +1 -1
  157. package/react/src/hooks/useSearch.d.ts +1 -1
  158. package/react/src/hooks/useSearchParams.d.ts +1 -1
  159. package/react/src/hooks/useToc.d.ts +1 -1
  160. package/react/src/index.d.ts +1 -1
  161. package/react/src/lib/collection.d.ts +1 -1
  162. package/react/src/lib/content.d.ts +1 -1
  163. package/react/src/lib/head.d.ts +1 -1
  164. package/react/src/lib/index.d.ts +1 -1
  165. package/react/src/lib/lazy-route.d.ts +1 -1
  166. package/react/src/lib/route-loader.d.ts +1 -1
  167. package/react/src/providers/ContentProvider.d.ts +1 -1
  168. package/react/src/providers/RerouteProvider.d.ts +1 -1
  169. package/react/src/providers/RouterProvider.d.ts +1 -1
  170. package/react/src/providers/index.d.ts +1 -1
  171. package/react/src/types/any.d.ts +1 -1
  172. package/react/src/types/index.d.ts +1 -1
  173. package/react/src/types/router.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 v0.20.2
4
+ * reroute-js v0.20.4
5
5
  *
6
6
  * @license MIT
7
7
  * @copyright 2025 stewones <hi@stewan.io>
@@ -48,7 +48,7 @@ async function getVersionString() {
48
48
  }
49
49
  async function getVersion() {
50
50
  if (true) {
51
- return "0.20.2";
51
+ return "0.20.4";
52
52
  }
53
53
  const possiblePaths = [
54
54
  path.join(import.meta.dir, "../../../../package.json"),
@@ -66,7 +66,7 @@ async function getVersion() {
66
66
  }
67
67
  async function getCommit() {
68
68
  if (true) {
69
- return "16c343b";
69
+ return "b55c7e7";
70
70
  }
71
71
  return "dev";
72
72
  }
@@ -944,9 +944,13 @@ async function computeLayoutData(pathname, clientDir, _cwd, isWatchMode, options
944
944
  if (typeof layout?.path !== "string")
945
945
  continue;
946
946
  try {
947
- const abs = join2(clientDir, "routes", String(layout.path));
948
- const mod = await dynamicImport(abs, isWatchMode);
949
- const dataFn = mod?.ssr?.data;
947
+ let ssrExport = layout?.ssr;
948
+ if (!ssrExport) {
949
+ const abs = join2(clientDir, "routes", String(layout.path));
950
+ const mod = await dynamicImport(abs, isWatchMode);
951
+ ssrExport = mod?.ssr;
952
+ }
953
+ const dataFn = ssrExport?.data;
950
954
  if (typeof dataFn !== "function")
951
955
  continue;
952
956
  const pattern = String(layout.pattern || "/");
@@ -1042,9 +1046,13 @@ async function computeRouteData(pathname, clientDir, _cwd, isWatchMode, options2
1042
1046
  if (!route || typeof route.path !== "string") {
1043
1047
  return { data: ssrData, pendingTasks };
1044
1048
  }
1045
- const abs = join2(clientDir, "routes", String(route.path));
1046
- const mod = await dynamicImport(abs, isWatchMode);
1047
- const dataFn = mod?.ssr?.data;
1049
+ let ssrExport = route?.ssr;
1050
+ if (!ssrExport) {
1051
+ const abs = join2(clientDir, "routes", String(route.path));
1052
+ const mod = await dynamicImport(abs, isWatchMode);
1053
+ ssrExport = mod?.ssr;
1054
+ }
1055
+ const dataFn = ssrExport?.data;
1048
1056
  if (typeof dataFn !== "function") {
1049
1057
  return { data: ssrData, pendingTasks };
1050
1058
  }
@@ -1176,6 +1184,24 @@ var init_routes = __esm(() => {
1176
1184
  });
1177
1185
 
1178
1186
  // packages/core/src/ssr/lib/compute/index.ts
1187
+ function matchPatternUtil(pattern, pathname) {
1188
+ const patternParts = pattern.split("/").filter(Boolean);
1189
+ const pathnameParts = pathname.split("/").filter(Boolean);
1190
+ if (patternParts.length !== pathnameParts.length) {
1191
+ return null;
1192
+ }
1193
+ const params = {};
1194
+ for (let i = 0;i < patternParts.length; i++) {
1195
+ const patternPart = patternParts[i];
1196
+ const pathnamePart = pathnameParts[i];
1197
+ if (patternPart.startsWith(":")) {
1198
+ params[patternPart.slice(1)] = pathnamePart;
1199
+ } else if (patternPart !== pathnamePart) {
1200
+ return null;
1201
+ }
1202
+ }
1203
+ return params;
1204
+ }
1179
1205
  async function computeSSRData(pathname, clientDir, cwd, isWatchMode, options2 = {}, searchParams) {
1180
1206
  const ssrData = {};
1181
1207
  let error;
@@ -1184,8 +1210,27 @@ async function computeSSRData(pathname, clientDir, cwd, isWatchMode, options2 =
1184
1210
  const streaming = options2.streaming === true;
1185
1211
  let routesModule;
1186
1212
  try {
1187
- const routesPath = join2(cwd, ".reroute", "routes.ts");
1188
- routesModule = await dynamicImport(routesPath, isWatchMode);
1213
+ const bundledRoutes = globalThis.__REROUTE_ROUTES__;
1214
+ const bundledLayouts = globalThis.__REROUTE_LAYOUTS__;
1215
+ if (bundledRoutes && bundledLayouts) {
1216
+ routesModule = {
1217
+ routes: bundledRoutes,
1218
+ layouts: bundledLayouts,
1219
+ matchRoute: (pathname2) => {
1220
+ for (const route of bundledRoutes) {
1221
+ const pattern = String(route?.pattern || "");
1222
+ const match = matchPatternUtil(pattern, pathname2);
1223
+ if (match) {
1224
+ return { route, params: match };
1225
+ }
1226
+ }
1227
+ return null;
1228
+ }
1229
+ };
1230
+ } else {
1231
+ const routesPath = join2(cwd, ".reroute", "routes.ts");
1232
+ routesModule = await dynamicImport(routesPath, isWatchMode);
1233
+ }
1189
1234
  } catch {
1190
1235
  return {
1191
1236
  data: ssrData,
@@ -1373,6 +1418,24 @@ var init_seed = __esm(() => {
1373
1418
  });
1374
1419
 
1375
1420
  // packages/core/src/ssr/lib/data.ts
1421
+ function matchPattern(pattern, pathname) {
1422
+ const patternParts = pattern.split("/").filter(Boolean);
1423
+ const pathnameParts = pathname.split("/").filter(Boolean);
1424
+ if (patternParts.length !== pathnameParts.length) {
1425
+ return null;
1426
+ }
1427
+ const params = {};
1428
+ for (let i = 0;i < patternParts.length; i++) {
1429
+ const patternPart = patternParts[i];
1430
+ const pathnamePart = pathnameParts[i];
1431
+ if (patternPart.startsWith(":")) {
1432
+ params[patternPart.slice(1)] = pathnamePart;
1433
+ } else if (patternPart !== pathnamePart) {
1434
+ return null;
1435
+ }
1436
+ }
1437
+ return params;
1438
+ }
1376
1439
  async function computeSSRDataForPath(params) {
1377
1440
  const { pathname, clientDir, cwd, isWatchMode, searchParams } = params;
1378
1441
  const allData = {};
@@ -1380,16 +1443,24 @@ async function computeSSRDataForPath(params) {
1380
1443
  await seedSSRModuleForPath(pathname, clientDir, cwd, isWatchMode);
1381
1444
  } catch {}
1382
1445
  try {
1383
- const routesPath = join2(cwd, ".reroute", "routes.ts");
1384
- const m = await dynamicImport(routesPath, isWatchMode);
1385
- const matchingLayouts = getMatchingLayouts(pathname, m?.layouts);
1446
+ let layouts = globalThis.__REROUTE_LAYOUTS__;
1447
+ if (!layouts) {
1448
+ const routesPath = join2(cwd, ".reroute", "routes.ts");
1449
+ const m = await dynamicImport(routesPath, isWatchMode);
1450
+ layouts = m?.layouts;
1451
+ }
1452
+ const matchingLayouts = getMatchingLayouts(pathname, layouts);
1386
1453
  for (const layout of matchingLayouts) {
1387
1454
  if (typeof layout?.path !== "string")
1388
1455
  continue;
1389
1456
  try {
1390
- const abs = join2(clientDir, "routes", String(layout.path));
1391
- const mod = await dynamicImport(abs, isWatchMode);
1392
- const dataFn = mod?.ssr?.data;
1457
+ let ssrExport = layout?.ssr;
1458
+ if (!ssrExport) {
1459
+ const abs = join2(clientDir, "routes", String(layout.path));
1460
+ const mod = await dynamicImport(abs, isWatchMode);
1461
+ ssrExport = mod?.ssr;
1462
+ }
1463
+ const dataFn = ssrExport?.data;
1393
1464
  if (typeof dataFn !== "function")
1394
1465
  continue;
1395
1466
  const pattern = String(layout.pattern || "/");
@@ -1425,16 +1496,37 @@ async function computeSSRDataForPath(params) {
1425
1496
  }
1426
1497
  } catch {}
1427
1498
  try {
1428
- const routesPath = join2(cwd, ".reroute", "routes.ts");
1429
- const m = await dynamicImport(routesPath, isWatchMode);
1499
+ let routes = globalThis.__REROUTE_ROUTES__;
1500
+ let matchRouteFn;
1501
+ if (!routes) {
1502
+ const routesPath = join2(cwd, ".reroute", "routes.ts");
1503
+ const m = await dynamicImport(routesPath, isWatchMode);
1504
+ routes = m?.routes;
1505
+ matchRouteFn = m?.matchRoute;
1506
+ } else {
1507
+ matchRouteFn = (pathname2) => {
1508
+ for (const route of routes || []) {
1509
+ const pattern = String(route?.pattern || "");
1510
+ const match2 = matchPattern(pattern, pathname2);
1511
+ if (match2) {
1512
+ return { route, params: match2 };
1513
+ }
1514
+ }
1515
+ return null;
1516
+ };
1517
+ }
1430
1518
  const pathnameOnly = pathname.split("?")[0];
1431
- const match = typeof m.matchRoute === "function" ? m.matchRoute(pathnameOnly) : null;
1519
+ const match = typeof matchRouteFn === "function" ? matchRouteFn(pathnameOnly) : null;
1432
1520
  const r = match?.route;
1433
1521
  const paramsValue = match?.params || {};
1434
1522
  if (r && typeof r.path === "string") {
1435
- const abs = join2(clientDir, "routes", String(r.path));
1436
- const mod = await dynamicImport(abs, isWatchMode);
1437
- const dataFn = mod?.ssr?.data;
1523
+ let ssrExport = r?.ssr;
1524
+ if (!ssrExport) {
1525
+ const abs = join2(clientDir, "routes", String(r.path));
1526
+ const mod = await dynamicImport(abs, isWatchMode);
1527
+ ssrExport = mod?.ssr;
1528
+ }
1529
+ const dataFn = ssrExport?.data;
1438
1530
  if (typeof dataFn === "function") {
1439
1531
  const rawResult = dataFn({
1440
1532
  pathname,
@@ -2189,6 +2281,11 @@ var init_scripts = __esm(() => {
2189
2281
  // packages/core/src/ssr/lib/styles.ts
2190
2282
  async function inlineTailwindCSS(clientDir, minify = false) {
2191
2283
  try {
2284
+ const bundledCss = globalThis.__REROUTE_THEME_CSS__;
2285
+ if (bundledCss) {
2286
+ const css2 = minify ? minifyCSS(bundledCss) : bundledCss;
2287
+ return `<style data-reroute="tailwind">${css2}</style>`;
2288
+ }
2192
2289
  const candidates = [
2193
2290
  join2(clientDir, "..", ".reroute", "theme.css"),
2194
2291
  join2(clientDir, "..", "..", ".reroute", "theme.css"),
@@ -2743,10 +2840,13 @@ import { pathToFileURL as pathToFileURL6 } from "node:url";
2743
2840
  async function discoverStaticRoutes(cwd, isWatchMode) {
2744
2841
  const routes = [];
2745
2842
  try {
2746
- const routesPath = join2(cwd, ".reroute", "routes.ts");
2747
- const url = pathToFileURL6(routesPath).href;
2748
- const mod = await import(`${url}${isWatchMode ? `?t=${Date.now()}` : ""}`);
2749
- const routesList = mod?.routes;
2843
+ let routesList = globalThis.__REROUTE_ROUTES__;
2844
+ if (!routesList) {
2845
+ const routesPath = join2(cwd, ".reroute", "routes.ts");
2846
+ const url = pathToFileURL6(routesPath).href;
2847
+ const mod = await import(`${url}${isWatchMode ? `?t=${Date.now()}` : ""}`);
2848
+ routesList = mod?.routes;
2849
+ }
2750
2850
  if (Array.isArray(routesList)) {
2751
2851
  for (const route of routesList) {
2752
2852
  const pattern = String(route?.pattern || "");
@@ -3219,10 +3319,13 @@ var init_og = __esm(() => {
3219
3319
  async function discoverRoutesForRobots(cwd, isWatchMode) {
3220
3320
  const routes = [];
3221
3321
  try {
3222
- const routesPath = join2(cwd, ".reroute", "routes.ts");
3223
- const url = Bun.pathToFileURL(routesPath).href;
3224
- const mod = await import(`${url}${isWatchMode ? `?t=${Date.now()}` : ""}`);
3225
- const routesArray = mod?.routes;
3322
+ let routesArray = globalThis.__REROUTE_ROUTES__;
3323
+ if (!routesArray) {
3324
+ const routesPath = join2(cwd, ".reroute", "routes.ts");
3325
+ const url = Bun.pathToFileURL(routesPath).href;
3326
+ const mod = await import(`${url}${isWatchMode ? `?t=${Date.now()}` : ""}`);
3327
+ routesArray = mod?.routes;
3328
+ }
3226
3329
  if (Array.isArray(routesArray)) {
3227
3330
  for (const route of routesArray) {
3228
3331
  const pattern = String(route?.pattern || "");
@@ -3403,10 +3506,13 @@ async function discoverRoutes(cwd, isWatchMode) {
3403
3506
  const staticRoutes = [];
3404
3507
  const dynamicRoutes = [];
3405
3508
  try {
3406
- const routesPath = join2(cwd, ".reroute", "routes.ts");
3407
- const url = Bun.pathToFileURL(routesPath).href;
3408
- const mod = await import(`${url}${isWatchMode ? `?t=${Date.now()}` : ""}`);
3409
- const routes = mod?.routes;
3509
+ let routes = globalThis.__REROUTE_ROUTES__;
3510
+ if (!routes) {
3511
+ const routesPath = join2(cwd, ".reroute", "routes.ts");
3512
+ const url = Bun.pathToFileURL(routesPath).href;
3513
+ const mod = await import(`${url}${isWatchMode ? `?t=${Date.now()}` : ""}`);
3514
+ routes = mod?.routes;
3515
+ }
3410
3516
  if (Array.isArray(routes)) {
3411
3517
  for (const route of routes) {
3412
3518
  const pattern = String(route?.pattern || "");
@@ -3880,10 +3986,13 @@ async function discoverRSSData(cwd, clientDir, collections2, baseUrl, isWatchMod
3880
3986
  async function discoverLayoutFeedItems(cwd, clientDir, isWatchMode, baseUrl, rssConfig) {
3881
3987
  const layoutFeeds = new Map;
3882
3988
  try {
3883
- const routesPath = join2(cwd, ".reroute", "routes.ts");
3884
- const url = pathToFileURL7(routesPath).href;
3885
- const mod = await import(`${url}${isWatchMode ? `?t=${Date.now()}` : ""}`);
3886
- const layouts2 = mod?.layouts;
3989
+ let layouts2 = globalThis.__REROUTE_LAYOUTS__;
3990
+ if (!layouts2) {
3991
+ const routesPath = join2(cwd, ".reroute", "routes.ts");
3992
+ const url = pathToFileURL7(routesPath).href;
3993
+ const mod = await import(`${url}${isWatchMode ? `?t=${Date.now()}` : ""}`);
3994
+ layouts2 = mod?.layouts;
3995
+ }
3887
3996
  if (Array.isArray(layouts2)) {
3888
3997
  for (const layout of layouts2) {
3889
3998
  const pattern = String(layout?.pattern || "/");
@@ -4231,8 +4340,9 @@ async function streamSSRContent(writer, encoder, ctx) {
4231
4340
  try {
4232
4341
  const combinedHead = deduplicateMetaTags([ctx.inlineStyleTag, ctx.head, ctx.extraHead].filter(Boolean).join(`
4233
4342
  `));
4234
- const headContent = `${ctx.headWithLang.replace(/<html([^>]*)>/i, `<html$1 lang="${ctx.pageLang}">`)}${combinedHead ? `
4235
- ${combinedHead}` : ""}</head><body>`;
4343
+ const headWithLangAndContent = ctx.headWithLang.replace(/<html([^>]*)>/i, `<html$1 lang="${ctx.pageLang}">`).replace(/<\/head>/i, `${combinedHead ? `${combinedHead}
4344
+ ` : ""}</head>`);
4345
+ const headContent = `${headWithLangAndContent}<body>`;
4236
4346
  await writer.write(encoder.encode(headContent));
4237
4347
  await writer.write(encoder.encode(ctx.rootStart));
4238
4348
  const componentWithPathname = cloneElement2(ctx.rootComponent, {
@@ -8751,6 +8861,31 @@ import { watch } from "node:fs";
8751
8861
  import { mkdir as mkdir2, readdir as readdir5, rm } from "node:fs/promises";
8752
8862
  import { dirname as dirname5, join as join9 } from "node:path";
8753
8863
  import { pathToFileURL as pathToFileURL8 } from "node:url";
8864
+ async function bundleThemeCssIntoArtifacts(cwd) {
8865
+ const themeCssPath = join9(cwd, ".reroute", "theme.css");
8866
+ const artifactsPath = join9(cwd, OUTPUT_ARTIFACTS);
8867
+ try {
8868
+ const cssContent = await Bun.file(themeCssPath).text();
8869
+ if (!cssContent)
8870
+ return;
8871
+ let artifactsContent = await Bun.file(artifactsPath).text();
8872
+ if (artifactsContent.includes("__REROUTE_THEME_CSS__")) {
8873
+ return;
8874
+ }
8875
+ const cssLine = `
8876
+ // Bundled theme.css for compiled binary support
8877
+ (globalThis as any).__REROUTE_THEME_CSS__ = ${JSON.stringify(cssContent)};
8878
+ `;
8879
+ const exportIndex = artifactsContent.lastIndexOf("export type RerouteBundle");
8880
+ if (exportIndex !== -1) {
8881
+ artifactsContent = artifactsContent.slice(0, exportIndex) + cssLine + `
8882
+ ` + artifactsContent.slice(exportIndex);
8883
+ } else {
8884
+ artifactsContent += cssLine;
8885
+ }
8886
+ await Bun.write(artifactsPath, artifactsContent);
8887
+ } catch {}
8888
+ }
8754
8889
  async function ensureOutputDir(cwd, options2 = {}) {
8755
8890
  const { clean = true } = options2;
8756
8891
  try {
@@ -8824,6 +8959,7 @@ export * from './artifacts';
8824
8959
  // @ts-nocheck
8825
8960
 
8826
8961
  import './artifacts';
8962
+ import './routes'; // Import routes (bundles all route components)
8827
8963
  import '../src/index';
8828
8964
  `;
8829
8965
  await Bun.write(join9(cwd, OUTPUT_ROUTES), STUB_ROUTES);
@@ -8966,9 +9102,14 @@ function getImportPath(filePath, streamingMap) {
8966
9102
  }
8967
9103
  function generateTypeScript(tree, streamingMap) {
8968
9104
  const helperImport = "import { createLazyRoute } from 'reroute-js/react';";
9105
+ const ssrHelper = "const _ssr = (m: any) => m.ssr;";
8969
9106
  const eagerImports = [
8970
- ...tree.routes.map((r, i) => `import Route${i}Eager from '${getImportPath(r.filePath, streamingMap)}';`),
8971
- ...tree.layouts.map((l, i) => `import Layout${i}Eager from '${getImportPath(l.filePath, streamingMap)}';`),
9107
+ ...tree.routes.map((r, i) => `import * as Route${i}Module from '${getImportPath(r.filePath, streamingMap)}';
9108
+ const Route${i}Eager = Route${i}Module.default;
9109
+ const Route${i}SSR = _ssr(Route${i}Module);`),
9110
+ ...tree.layouts.map((l, i) => `import * as Layout${i}Module from '${getImportPath(l.filePath, streamingMap)}';
9111
+ const Layout${i}Eager = Layout${i}Module.default;
9112
+ const Layout${i}SSR = _ssr(Layout${i}Module);`),
8972
9113
  ...tree.notFoundRoutes.map((nf, i) => `import NotFound${i}Eager from '${getImportPath(nf.filePath, streamingMap)}';`)
8973
9114
  ].join(`
8974
9115
  `);
@@ -8994,6 +9135,7 @@ function generateTypeScript(tree, streamingMap) {
8994
9135
  component: Route${i},
8995
9136
  params: ${JSON.stringify(r.params)},
8996
9137
  isDynamic: ${r.isDynamic},
9138
+ ssr: Route${i}SSR,
8997
9139
  } as const`;
8998
9140
  }).join(`,
8999
9141
  `);
@@ -9009,6 +9151,7 @@ function generateTypeScript(tree, streamingMap) {
9009
9151
  pattern: "${l.pattern}",
9010
9152
  path: "${l.path}",
9011
9153
  component: Layout${i},
9154
+ ssr: Layout${i}SSR,
9012
9155
  } as const`;
9013
9156
  }).join(`,
9014
9157
  `);
@@ -9026,6 +9169,8 @@ function generateTypeScript(tree, streamingMap) {
9026
9169
 
9027
9170
  ${helperImport}
9028
9171
 
9172
+ ${ssrHelper}
9173
+
9029
9174
  ${eagerImports}
9030
9175
 
9031
9176
  ${lazyWrappers}
@@ -9090,6 +9235,10 @@ function matchPattern(pattern: string, pathname: string): Record<string, string>
9090
9235
 
9091
9236
  return params;
9092
9237
  }
9238
+
9239
+ // Set globals for compiled binary support (sitemap/RSS/robots discovery)
9240
+ (globalThis as any).__REROUTE_ROUTES__ = routes;
9241
+ (globalThis as any).__REROUTE_LAYOUTS__ = layouts;
9093
9242
  `;
9094
9243
  }
9095
9244
  async function buildStreamingWrappersForTree(cwd, routesPath, tree, config2) {
@@ -9648,6 +9797,7 @@ async function generate(cwd, args = [], options2 = {}) {
9648
9797
  "// @ts-nocheck",
9649
9798
  "",
9650
9799
  "import './artifacts'; // Import artifacts (sets globals for SSR)",
9800
+ "import './routes'; // Import routes (bundles all route components)",
9651
9801
  "import '../src/index'; // Import user's server entry"
9652
9802
  ];
9653
9803
  await Bun.write(join9(cwd, ".reroute/entry.ts"), entryLines.join(`
@@ -9677,6 +9827,7 @@ async function gen(args) {
9677
9827
  if (!watchMode) {
9678
9828
  await generate(cwd, args);
9679
9829
  await buildTailwindIfConfigured(cwd, isProd);
9830
+ await bundleThemeCssIntoArtifacts(cwd);
9680
9831
  checkMarkdownIfConfigured(cwd);
9681
9832
  const genEndTime2 = performance.now();
9682
9833
  const totalDuration2 = ((genEndTime2 - genStartTime) / 1000).toFixed(2);
@@ -9690,6 +9841,7 @@ async function gen(args) {
9690
9841
  await generate(cwd, args);
9691
9842
  try {
9692
9843
  await buildTailwindIfConfigured(cwd, isProd);
9844
+ await bundleThemeCssIntoArtifacts(cwd);
9693
9845
  checkMarkdownIfConfigured(cwd);
9694
9846
  } catch {}
9695
9847
  const genEndTime = performance.now();
@@ -10484,29 +10636,62 @@ var init_start = __esm(() => {
10484
10636
  init_log();
10485
10637
  });
10486
10638
 
10639
+ // packages/cli/src/commands/lib/assets.ts
10640
+ import {
10641
+ cpSync,
10642
+ existsSync as existsSync8,
10643
+ mkdirSync,
10644
+ readdirSync
10645
+ } from "node:fs";
10646
+ import { join as join12 } from "node:path";
10647
+ function copyAssetsToReroute(cwd, sourceAssetsDir, rerouteAssetsDir) {
10648
+ if (!existsSync8(sourceAssetsDir)) {
10649
+ return 0;
10650
+ }
10651
+ const rerouteDir = join12(cwd, ".reroute");
10652
+ if (!existsSync8(rerouteDir)) {
10653
+ mkdirSync(rerouteDir, { recursive: true });
10654
+ }
10655
+ cpSync(sourceAssetsDir, rerouteAssetsDir, { recursive: true });
10656
+ return countFiles(rerouteAssetsDir);
10657
+ }
10658
+ function countFiles(dir) {
10659
+ let count = 0;
10660
+ const entries = readdirSync(dir, { withFileTypes: true });
10661
+ for (const entry of entries) {
10662
+ if (entry.isDirectory()) {
10663
+ count += countFiles(join12(dir, entry.name));
10664
+ } else {
10665
+ count++;
10666
+ }
10667
+ }
10668
+ return count;
10669
+ }
10670
+ var init_assets = () => {};
10671
+
10487
10672
  // packages/cli/src/commands/build.ts
10488
10673
  var exports_build = {};
10489
10674
  __export(exports_build, {
10490
10675
  default: () => build
10491
10676
  });
10492
10677
  import { spawn as spawn4 } from "node:child_process";
10493
- import { existsSync as existsSync8, readFileSync as readFileSync5 } from "node:fs";
10494
- import { join as join12 } from "node:path";
10678
+ import { existsSync as existsSync9, readFileSync as readFileSync5 } from "node:fs";
10679
+ import { join as join13 } from "node:path";
10495
10680
  function getRerouteCommand3() {
10496
- const binPath = join12(import.meta.dir, "..", "..", "bin.ts");
10497
- const isBunDev = existsSync8(binPath);
10681
+ const binPath = join13(import.meta.dir, "..", "..", "bin.ts");
10682
+ const isBunDev = existsSync9(binPath);
10498
10683
  if (isBunDev) {
10499
10684
  return `bun ${binPath}`;
10500
10685
  }
10501
10686
  const cwd = process.cwd();
10502
10687
  const nodeModulesPaths = [
10503
- join12(cwd, "node_modules", ".bin", "reroute"),
10504
- join12(cwd, "..", "node_modules", ".bin", "reroute"),
10505
- join12(cwd, "..", "..", "node_modules", ".bin", "reroute"),
10506
- join12(cwd, "..", "..", "..", "node_modules", ".bin", "reroute")
10688
+ join13(cwd, "node_modules", ".bin", "reroute"),
10689
+ join13(cwd, "..", "node_modules", ".bin", "reroute"),
10690
+ join13(cwd, "..", "..", "node_modules", ".bin", "reroute"),
10691
+ join13(cwd, "..", "..", "..", "node_modules", ".bin", "reroute")
10507
10692
  ];
10508
10693
  for (const binPath2 of nodeModulesPaths) {
10509
- if (existsSync8(binPath2)) {
10694
+ if (existsSync9(binPath2)) {
10510
10695
  return binPath2;
10511
10696
  }
10512
10697
  }
@@ -10514,8 +10699,8 @@ function getRerouteCommand3() {
10514
10699
  }
10515
10700
  function getOutputName() {
10516
10701
  const cwd = process.cwd();
10517
- const packageJsonPath = join12(cwd, "package.json");
10518
- if (existsSync8(packageJsonPath)) {
10702
+ const packageJsonPath = join13(cwd, "package.json");
10703
+ if (existsSync9(packageJsonPath)) {
10519
10704
  try {
10520
10705
  const packageJson = JSON.parse(readFileSync5(packageJsonPath, "utf-8"));
10521
10706
  const name = packageJson.name;
@@ -10579,6 +10764,18 @@ async function build(args) {
10579
10764
  });
10580
10765
  process.stdout.write(colorizeLogPrefixAnsi(`[reroute/build] Generation complete
10581
10766
  `));
10767
+ const cwd = process.cwd();
10768
+ const config2 = await loadConfig(cwd);
10769
+ const assetsPath = config2.options?.assets || "src/client";
10770
+ const sourceAssetsDir = join13(cwd, assetsPath, "assets");
10771
+ const rerouteAssetsDir = join13(cwd, ".reroute", "assets");
10772
+ process.stdout.write(colorizeLogPrefixAnsi(`[reroute/build] Copying assets...
10773
+ `));
10774
+ const fileCount = copyAssetsToReroute(cwd, sourceAssetsDir, rerouteAssetsDir);
10775
+ if (fileCount > 0) {
10776
+ process.stdout.write(colorizeLogPrefixAnsi(`[reroute/build] Copied ${fileCount} assets to ${rerouteAssetsDir}
10777
+ `));
10778
+ }
10582
10779
  process.stdout.write(`${colorizeLogPrefixAnsi(`[reroute/build] Building binary to ${outputPath}...`)}
10583
10780
  `);
10584
10781
  const buildArgs = [
@@ -10603,7 +10800,7 @@ async function build(args) {
10603
10800
  return arg !== "--outfile" && arg !== "-o" && arg !== "--minify" && arg !== "--no-minify" && arg !== "--prod";
10604
10801
  });
10605
10802
  buildArgs.push(...filteredArgs, "--outfile", outputPath);
10606
- await new Promise((resolve2, reject) => {
10803
+ await new Promise((_resolve, reject) => {
10607
10804
  const buildProcess = spawn4("bun", buildArgs, {
10608
10805
  stdio: "inherit"
10609
10806
  });
@@ -10613,7 +10810,7 @@ async function build(args) {
10613
10810
  } else {
10614
10811
  process.stdout.write(colorizeLogPrefixAnsi(`[reroute/build] Build complete: ${outputPath}
10615
10812
  `));
10616
- resolve2();
10813
+ process.exit(0);
10617
10814
  }
10618
10815
  });
10619
10816
  buildProcess.on("error", (error) => {
@@ -10627,6 +10824,8 @@ async function build(args) {
10627
10824
  }
10628
10825
  }
10629
10826
  var init_build = __esm(() => {
10827
+ init_core();
10828
+ init_assets();
10630
10829
  init_log();
10631
10830
  });
10632
10831
 
@@ -10635,23 +10834,23 @@ var exports_command = {};
10635
10834
  __export(exports_command, {
10636
10835
  getRerouteCommand: () => getRerouteCommand4
10637
10836
  });
10638
- import { existsSync as existsSync9 } from "node:fs";
10639
- import { join as join13 } from "node:path";
10837
+ import { existsSync as existsSync10 } from "node:fs";
10838
+ import { join as join14 } from "node:path";
10640
10839
  function getRerouteCommand4() {
10641
- const binPath = join13(import.meta.dir, "..", "..", "bin.ts");
10642
- const isBunDev = existsSync9(binPath);
10840
+ const binPath = join14(import.meta.dir, "..", "..", "bin.ts");
10841
+ const isBunDev = existsSync10(binPath);
10643
10842
  if (isBunDev) {
10644
10843
  return `bun ${binPath}`;
10645
10844
  }
10646
10845
  const cwd = process.cwd();
10647
10846
  const nodeModulesPaths = [
10648
- join13(cwd, "node_modules", ".bin", "reroute"),
10649
- join13(cwd, "..", "node_modules", ".bin", "reroute"),
10650
- join13(cwd, "..", "..", "node_modules", ".bin", "reroute"),
10651
- join13(cwd, "..", "..", "..", "node_modules", ".bin", "reroute")
10847
+ join14(cwd, "node_modules", ".bin", "reroute"),
10848
+ join14(cwd, "..", "node_modules", ".bin", "reroute"),
10849
+ join14(cwd, "..", "..", "node_modules", ".bin", "reroute"),
10850
+ join14(cwd, "..", "..", "..", "node_modules", ".bin", "reroute")
10652
10851
  ];
10653
10852
  for (const binPath2 of nodeModulesPaths) {
10654
- if (existsSync9(binPath2)) {
10853
+ if (existsSync10(binPath2)) {
10655
10854
  return binPath2;
10656
10855
  }
10657
10856
  }
@@ -10664,24 +10863,24 @@ var exports_analyze = {};
10664
10863
  __export(exports_analyze, {
10665
10864
  default: () => analyze
10666
10865
  });
10667
- import { existsSync as existsSync10, statSync } from "node:fs";
10866
+ import { existsSync as existsSync11, statSync } from "node:fs";
10668
10867
  import { readdir as readdir6, readFile, stat as stat5, writeFile } from "node:fs/promises";
10669
- import { basename as basename3, join as join14, relative as relative3 } from "node:path";
10868
+ import { basename as basename3, join as join15, relative as relative3 } from "node:path";
10670
10869
  import Table from "cli-table3";
10671
10870
  async function findBundles(cwd) {
10672
10871
  const bundles = [];
10673
- const chunksDir = join14(cwd, ".reroute", "chunks");
10674
- if (existsSync10(chunksDir)) {
10872
+ const chunksDir = join15(cwd, ".reroute", "chunks");
10873
+ if (existsSync11(chunksDir)) {
10675
10874
  const collections2 = await readdir6(chunksDir, { withFileTypes: true });
10676
10875
  for (const collection of collections2) {
10677
10876
  if (!collection.isDirectory())
10678
10877
  continue;
10679
- const collectionDir = join14(chunksDir, collection.name);
10878
+ const collectionDir = join15(chunksDir, collection.name);
10680
10879
  const files = await readdir6(collectionDir);
10681
10880
  for (const file of files) {
10682
10881
  if (!file.endsWith(".js"))
10683
10882
  continue;
10684
- const filePath = join14(collectionDir, file);
10883
+ const filePath = join15(collectionDir, file);
10685
10884
  const stats = await stat5(filePath);
10686
10885
  const content2 = await Bun.file(filePath).arrayBuffer();
10687
10886
  const gzippedSize = Bun.gzipSync(new Uint8Array(content2)).length;
@@ -10696,11 +10895,11 @@ async function findBundles(cwd) {
10696
10895
  }
10697
10896
  }
10698
10897
  }
10699
- const distDir = join14(cwd, "dist");
10700
- if (existsSync10(distDir)) {
10898
+ const distDir = join15(cwd, "dist");
10899
+ if (existsSync11(distDir)) {
10701
10900
  const files = await readdir6(distDir);
10702
10901
  for (const file of files) {
10703
- const filePath = join14(distDir, file);
10902
+ const filePath = join15(distDir, file);
10704
10903
  const stats = statSync(filePath);
10705
10904
  if (stats.isFile() && !file.endsWith(".map") && !file.endsWith(".d.ts")) {
10706
10905
  const content2 = await Bun.file(filePath).arrayBuffer();
@@ -10720,13 +10919,13 @@ async function findBundles(cwd) {
10720
10919
  }
10721
10920
  async function findBrowserEntry(cwd) {
10722
10921
  try {
10723
- const clientDir = join14(cwd, "src", "client");
10724
- const tsxEntry = join14(clientDir, "index.tsx");
10725
- const tsEntry = join14(clientDir, "index.ts");
10922
+ const clientDir = join15(cwd, "src", "client");
10923
+ const tsxEntry = join15(clientDir, "index.tsx");
10924
+ const tsEntry = join15(clientDir, "index.ts");
10726
10925
  let sourceEntry = null;
10727
- if (existsSync10(tsxEntry)) {
10926
+ if (existsSync11(tsxEntry)) {
10728
10927
  sourceEntry = tsxEntry;
10729
- } else if (existsSync10(tsEntry)) {
10928
+ } else if (existsSync11(tsEntry)) {
10730
10929
  sourceEntry = tsEntry;
10731
10930
  }
10732
10931
  if (!sourceEntry)
@@ -10755,12 +10954,12 @@ async function findBrowserEntry(cwd) {
10755
10954
  console.warn("[reroute/analyze] Browser build produced no outputs");
10756
10955
  return null;
10757
10956
  }
10758
- const tempDir = join14(cwd, ".reroute", "browser");
10957
+ const tempDir = join15(cwd, ".reroute", "browser");
10759
10958
  await import("node:fs/promises").then((fs) => fs.mkdir(tempDir, { recursive: true }));
10760
10959
  const output = result.outputs[0];
10761
10960
  const code = await output.text();
10762
10961
  const actualHash = await generateContentHash2(code);
10763
- const bundlePath = join14(tempDir, `index.${actualHash}.js`);
10962
+ const bundlePath = join15(tempDir, `index.${actualHash}.js`);
10764
10963
  await writeFile(bundlePath, code, "utf-8");
10765
10964
  const mapOutput = result.outputs.find((o) => o.path.endsWith(".map"));
10766
10965
  if (mapOutput) {
@@ -10812,8 +11011,8 @@ function calculateStats(bundles) {
10812
11011
  }
10813
11012
  async function getInstalledPackageSizes(cwd) {
10814
11013
  const packageSizes = new Map;
10815
- const nodeModulesDir = join14(cwd, "node_modules");
10816
- if (!existsSync10(nodeModulesDir))
11014
+ const nodeModulesDir = join15(cwd, "node_modules");
11015
+ if (!existsSync11(nodeModulesDir))
10817
11016
  return packageSizes;
10818
11017
  try {
10819
11018
  const { execSync } = await import("node:child_process");
@@ -10851,7 +11050,7 @@ async function getInstalledPackageSizes(cwd) {
10851
11050
  }
10852
11051
  async function buildDependencyTree(entryPath, cwd) {
10853
11052
  try {
10854
- if (!existsSync10(entryPath))
11053
+ if (!existsSync11(entryPath))
10855
11054
  return null;
10856
11055
  const root = {
10857
11056
  name: basename3(entryPath),
@@ -10871,7 +11070,7 @@ async function buildDependencyTree(entryPath, cwd) {
10871
11070
  if (!pkgNode) {
10872
11071
  pkgNode = {
10873
11072
  name: pkgName || "unknown",
10874
- path: join14(cwd, "node_modules", pkgName || ""),
11073
+ path: join15(cwd, "node_modules", pkgName || ""),
10875
11074
  size: 0,
10876
11075
  children: []
10877
11076
  };
@@ -10892,7 +11091,7 @@ async function buildDependencyTree(entryPath, cwd) {
10892
11091
  if (!child) {
10893
11092
  child = {
10894
11093
  name: part,
10895
- path: join14(cwd, ...parts.slice(0, i + 1)),
11094
+ path: join15(cwd, ...parts.slice(0, i + 1)),
10896
11095
  size: 0,
10897
11096
  children: []
10898
11097
  };
@@ -10916,7 +11115,7 @@ async function buildDependencyTree(entryPath, cwd) {
10916
11115
  const modulePattern = /\/\/\s*(.+?\.(?:ts|tsx|js|jsx|mjs|cjs))\s*$/gm;
10917
11116
  const nodeModulesNode = {
10918
11117
  name: "node_modules",
10919
- path: join14(cwd, "node_modules"),
11118
+ path: join15(cwd, "node_modules"),
10920
11119
  size: 0,
10921
11120
  children: []
10922
11121
  };
@@ -10982,7 +11181,7 @@ async function buildTreeFromSourceMap(bundlePath, cwd) {
10982
11181
  if (sourcePath.startsWith("/") || sourcePath.match(/^[A-Za-z]:\\/))
10983
11182
  return sourcePath;
10984
11183
  const bundleDir = bundlePath.substring(0, bundlePath.lastIndexOf("/"));
10985
- return join14(bundleDir, sourceRoot || "", sourcePath);
11184
+ return join15(bundleDir, sourceRoot || "", sourcePath);
10986
11185
  }, computeSizes = function(node) {
10987
11186
  if (node.children && node.children.length > 0) {
10988
11187
  node.size = node.children.reduce((s, c) => s + computeSizes(c), 0);
@@ -10990,7 +11189,7 @@ async function buildTreeFromSourceMap(bundlePath, cwd) {
10990
11189
  return node.size;
10991
11190
  };
10992
11191
  const mapPath = `${bundlePath}.map`;
10993
- if (!existsSync10(mapPath))
11192
+ if (!existsSync11(mapPath))
10994
11193
  return null;
10995
11194
  const [bundle, mapJson] = await Promise.all([
10996
11195
  readFile(bundlePath, "utf-8"),
@@ -11054,7 +11253,7 @@ async function buildTreeFromSourceMap(bundlePath, cwd) {
11054
11253
  };
11055
11254
  const nodeModulesNode = {
11056
11255
  name: "node_modules",
11057
- path: join14(cwd, "node_modules"),
11256
+ path: join15(cwd, "node_modules"),
11058
11257
  size: 0,
11059
11258
  children: []
11060
11259
  };
@@ -11094,7 +11293,7 @@ async function buildTreeFromSourceMap(bundlePath, cwd) {
11094
11293
  if (!pkgNode) {
11095
11294
  pkgNode = {
11096
11295
  name: pkgName || "unknown",
11097
- path: join14(cwd, "node_modules", pkgName || ""),
11296
+ path: join15(cwd, "node_modules", pkgName || ""),
11098
11297
  size: 0,
11099
11298
  children: []
11100
11299
  };
@@ -11115,7 +11314,7 @@ async function buildTreeFromSourceMap(bundlePath, cwd) {
11115
11314
  if (!child) {
11116
11315
  child = {
11117
11316
  name: part,
11118
- path: join14(cwd, ...parts.slice(0, i2 + 1)),
11317
+ path: join15(cwd, ...parts.slice(0, i2 + 1)),
11119
11318
  size: 0,
11120
11319
  children: []
11121
11320
  };
@@ -11145,11 +11344,11 @@ async function generateHTMLReport(stats, depTree, mainInfo, browserDepTree, brow
11145
11344
  let actualServerBinarySize = null;
11146
11345
  let actualServerBinaryGzipped = null;
11147
11346
  try {
11148
- const distDir = join14(process.cwd(), "dist");
11149
- if (existsSync10(distDir)) {
11347
+ const distDir = join15(process.cwd(), "dist");
11348
+ if (existsSync11(distDir)) {
11150
11349
  const files = await readdir6(distDir);
11151
11350
  for (const file of files) {
11152
- const filePath = join14(distDir, file);
11351
+ const filePath = join15(distDir, file);
11153
11352
  const stats2 = statSync(filePath);
11154
11353
  if (stats2.isFile() && !file.includes(".")) {
11155
11354
  actualServerBinarySize = stats2.size;
@@ -12631,11 +12830,11 @@ async function printConsoleReport(stats, depTree, mainInfo, browserDepTree, brow
12631
12830
  let actualServerBinarySize = null;
12632
12831
  let actualServerBinaryGzipped = null;
12633
12832
  try {
12634
- const distDir = join14(process.cwd(), "dist");
12635
- if (existsSync10(distDir)) {
12833
+ const distDir = join15(process.cwd(), "dist");
12834
+ if (existsSync11(distDir)) {
12636
12835
  const files = await readdir6(distDir);
12637
12836
  for (const file of files) {
12638
- const filePath = join14(distDir, file);
12837
+ const filePath = join15(distDir, file);
12639
12838
  const stats2 = statSync(filePath);
12640
12839
  if (stats2.isFile() && !file.includes(".")) {
12641
12840
  actualServerBinarySize = stats2.size;
@@ -12669,8 +12868,8 @@ async function analyze(args) {
12669
12868
  const isProd = isProductionMode(args);
12670
12869
  const searchIndex = args.indexOf("--search");
12671
12870
  const initialSearch = searchIndex !== -1 && args[searchIndex + 1] ? args[searchIndex + 1] : "";
12672
- const rerouteIndexPath = join14(cwd, ".reroute", "index.ts");
12673
- if (!existsSync10(rerouteIndexPath)) {
12871
+ const rerouteIndexPath = join15(cwd, ".reroute", "index.ts");
12872
+ if (!existsSync11(rerouteIndexPath)) {
12674
12873
  console.log(colorizeLogPrefixAnsi(`[reroute/analyze] .reroute artifacts not found, running build...
12675
12874
  `));
12676
12875
  const { spawn: spawn5 } = await import("node:child_process");
@@ -12732,12 +12931,12 @@ async function analyze(args) {
12732
12931
  let entry = null;
12733
12932
  let depTree = null;
12734
12933
  let mainInfo = null;
12735
- const srcEntry = join14(cwd, "src", "index.ts");
12736
- if (existsSync10(srcEntry)) {
12934
+ const srcEntry = join15(cwd, "src", "index.ts");
12935
+ if (existsSync11(srcEntry)) {
12737
12936
  console.log(colorizeLogPrefixAnsi(`[reroute/analyze] Building server binary for analysis...
12738
12937
  `));
12739
12938
  const { mkdir: mkdir3 } = await import("node:fs/promises");
12740
- const serverAnalysisDir = join14(cwd, ".reroute", "server");
12939
+ const serverAnalysisDir = join15(cwd, ".reroute", "server");
12741
12940
  await mkdir3(serverAnalysisDir, { recursive: true });
12742
12941
  const result = await Bun.build({
12743
12942
  entrypoints: [srcEntry],
@@ -12750,7 +12949,7 @@ async function analyze(args) {
12750
12949
  if (result.success && result.outputs.length > 0) {
12751
12950
  const output = result.outputs[0];
12752
12951
  const code = await output.text();
12753
- const analysisEntry = join14(serverAnalysisDir, "index.js");
12952
+ const analysisEntry = join15(serverAnalysisDir, "index.js");
12754
12953
  await writeFile(analysisEntry, code, "utf-8");
12755
12954
  const mapOutput = result.outputs.find((o) => o.path.endsWith(".map"));
12756
12955
  if (mapOutput) {
@@ -12768,8 +12967,8 @@ async function analyze(args) {
12768
12967
  `));
12769
12968
  const installedSizes = await getInstalledPackageSizes(cwd);
12770
12969
  if (depTree) {
12771
- const packageJsonPath = join14(cwd, "package.json");
12772
- if (existsSync10(packageJsonPath)) {
12970
+ const packageJsonPath = join15(cwd, "package.json");
12971
+ if (existsSync11(packageJsonPath)) {
12773
12972
  try {
12774
12973
  const packageJson = JSON.parse(await readFile(packageJsonPath, "utf-8"));
12775
12974
  const runtimeDeps = packageJson.dependencies || {};
@@ -12780,7 +12979,7 @@ async function analyze(args) {
12780
12979
  if (!trackedPkgs.has(pkgName) && installedSizes.has(pkgName)) {
12781
12980
  nodeModulesNode.children?.push({
12782
12981
  name: pkgName,
12783
- path: join14(cwd, "node_modules", pkgName),
12982
+ path: join15(cwd, "node_modules", pkgName),
12784
12983
  size: installedSizes.get(pkgName) || 0
12785
12984
  });
12786
12985
  }
@@ -12811,10 +13010,10 @@ async function analyze(args) {
12811
13010
  const fullOutput = args.includes("--full");
12812
13011
  await printConsoleReport(stats, depTree, mainInfo, browserDepTree, browserInfo, fullOutput);
12813
13012
  if (outputHtml || openBrowser) {
12814
- const htmlPath = join14(cwd, ".reroute", "analysis.html");
13013
+ const htmlPath = join15(cwd, ".reroute", "analysis.html");
12815
13014
  const html2 = await generateHTMLReport(stats, depTree, mainInfo, browserDepTree, browserInfo, initialSearch);
12816
13015
  const { mkdir: mkdir3 } = await import("node:fs/promises");
12817
- await mkdir3(join14(cwd, ".reroute"), { recursive: true });
13016
+ await mkdir3(join15(cwd, ".reroute"), { recursive: true });
12818
13017
  await writeFile(htmlPath, html2, "utf-8");
12819
13018
  console.log(colorizeLogPrefixAnsi(`[reroute/analyze] HTML report generated: ${relative3(cwd, htmlPath)}
12820
13019
  `));
@@ -12878,7 +13077,7 @@ __export(exports_og, {
12878
13077
  });
12879
13078
  import { spawn as spawn5 } from "node:child_process";
12880
13079
  import { readdir as readdir7 } from "node:fs/promises";
12881
- import { join as join15 } from "node:path";
13080
+ import { join as join16 } from "node:path";
12882
13081
  async function findAvailablePort() {
12883
13082
  const server = Bun.serve({
12884
13083
  port: 0,
@@ -12932,14 +13131,14 @@ Error output:`, errorOutput);
12932
13131
  return { port, process: proc };
12933
13132
  }
12934
13133
  async function findRoutesWithOG(cwd) {
12935
- const routesPath = join15(cwd, ROUTES_DIR2);
13134
+ const routesPath = join16(cwd, ROUTES_DIR2);
12936
13135
  const routes = [];
12937
13136
  async function scan(dir, base = "") {
12938
13137
  try {
12939
13138
  const entries = await readdir7(dir, { withFileTypes: true });
12940
13139
  for (const entry of entries) {
12941
- const fullPath = join15(dir, entry.name);
12942
- const relativePath = join15(base, entry.name);
13140
+ const fullPath = join16(dir, entry.name);
13141
+ const relativePath = join16(base, entry.name);
12943
13142
  if (entry.isDirectory()) {
12944
13143
  if (entry.name === "content")
12945
13144
  continue;
@@ -12956,7 +13155,7 @@ async function findRoutesWithOG(cwd) {
12956
13155
  const entries = await readdir7(routesPath, { withFileTypes: true });
12957
13156
  for (const entry of entries) {
12958
13157
  if (entry.isDirectory()) {
12959
- const contentDir = join15(routesPath, entry.name, "content");
13158
+ const contentDir = join16(routesPath, entry.name, "content");
12960
13159
  try {
12961
13160
  const contentFiles = await readdir7(contentDir);
12962
13161
  if (contentFiles.length > 0) {
@@ -13201,7 +13400,7 @@ async function getVersionString2() {
13201
13400
  }
13202
13401
  async function getVersion2() {
13203
13402
  if (true) {
13204
- return "0.20.2";
13403
+ return "0.20.4";
13205
13404
  }
13206
13405
  const possiblePaths = [
13207
13406
  path3.join(import.meta.dir, "../../../package.json"),
@@ -13218,10 +13417,10 @@ async function getVersion2() {
13218
13417
  }
13219
13418
  async function getCommit2() {
13220
13419
  if (true) {
13221
- return "16c343b";
13420
+ return "b55c7e7";
13222
13421
  }
13223
13422
  return "dev";
13224
13423
  }
13225
13424
  main();
13226
13425
 
13227
- //# debugId=15E81E873286047B64756E2164756E21
13426
+ //# debugId=87B653DED7FC6A5164756E2164756E21