reroute-js 0.34.7 → 0.34.9

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 (187) hide show
  1. package/cli/bin.d.ts +1 -1
  2. package/cli/bin.js +199 -78
  3. package/cli/bin.js.map +13 -13
  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 +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/tailwind.d.ts +1 -1
  29. package/cli/src/commands/lib/terminal-ui.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 +194 -74
  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/full-generator.d.ts.map +1 -1
  48. package/core/src/llms/index-generator.d.ts +2 -3
  49. package/core/src/llms/index-generator.d.ts.map +1 -1
  50. package/core/src/llms/index.d.ts +1 -1
  51. package/core/src/og/discovery.d.ts +1 -1
  52. package/core/src/og/index.d.ts +1 -1
  53. package/core/src/og/meta.d.ts +1 -1
  54. package/core/src/og/render.d.ts +1 -1
  55. package/core/src/og/types.d.ts +1 -1
  56. package/core/src/robots/discovery.d.ts +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 +4 -4
  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 +3 -3
  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 +4 -2
  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/routes.d.ts +1 -1
  77. package/core/src/ssr/lib/data.d.ts +1 -1
  78. package/core/src/ssr/lib/html.d.ts +1 -1
  79. package/core/src/ssr/lib/imports.d.ts +1 -1
  80. package/core/src/ssr/lib/index.d.ts +1 -1
  81. package/core/src/ssr/lib/layouts.d.ts +1 -1
  82. package/core/src/ssr/lib/metadata.d.ts +1 -1
  83. package/core/src/ssr/lib/metadata.d.ts.map +1 -1
  84. package/core/src/ssr/lib/mime.d.ts +1 -1
  85. package/core/src/ssr/lib/modules.d.ts +1 -1
  86. package/core/src/ssr/lib/path.d.ts +1 -1
  87. package/core/src/ssr/lib/preload.d.ts +1 -1
  88. package/core/src/ssr/lib/preload.d.ts.map +1 -1
  89. package/core/src/ssr/lib/scripts/collections.d.ts +1 -1
  90. package/core/src/ssr/lib/scripts/data.d.ts +1 -1
  91. package/core/src/ssr/lib/scripts/escape.d.ts +1 -1
  92. package/core/src/ssr/lib/scripts/feeds.d.ts +1 -1
  93. package/core/src/ssr/lib/scripts/index.d.ts +1 -1
  94. package/core/src/ssr/lib/seed.d.ts +1 -1
  95. package/core/src/ssr/lib/serialize.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/template.d.ts +1 -1
  99. package/core/src/ssr/lib/types.d.ts +1 -1
  100. package/core/src/ssr/render.d.ts +1 -1
  101. package/core/src/ssr/stream.d.ts +1 -1
  102. package/elysia/index.d.ts +1 -1
  103. package/elysia/index.js +204 -88
  104. package/elysia/index.js.map +16 -16
  105. package/elysia/src/index.d.ts +1 -1
  106. package/elysia/src/libs/assets.d.ts +1 -1
  107. package/elysia/src/libs/cache.d.ts +1 -1
  108. package/elysia/src/libs/caching.d.ts +1 -1
  109. package/elysia/src/libs/http.d.ts +1 -1
  110. package/elysia/src/libs/image.d.ts +1 -1
  111. package/elysia/src/libs/index.d.ts +1 -1
  112. package/elysia/src/libs/llms.d.ts +1 -1
  113. package/elysia/src/libs/response.d.ts +1 -1
  114. package/elysia/src/libs/serving.d.ts +1 -1
  115. package/elysia/src/plugin.d.ts +1 -1
  116. package/elysia/src/plugin.d.ts.map +1 -1
  117. package/elysia/src/routes/artifacts.d.ts +1 -1
  118. package/elysia/src/routes/content.d.ts +1 -1
  119. package/elysia/src/routes/image.d.ts +1 -1
  120. package/elysia/src/routes/index.d.ts +1 -1
  121. package/elysia/src/routes/internal.d.ts +1 -1
  122. package/elysia/src/routes/llms.d.ts +1 -1
  123. package/elysia/src/routes/llms.d.ts.map +1 -1
  124. package/elysia/src/routes/og.d.ts +1 -1
  125. package/elysia/src/routes/redirects.d.ts +1 -1
  126. package/elysia/src/routes/robots.d.ts +1 -1
  127. package/elysia/src/routes/rss.d.ts +1 -1
  128. package/elysia/src/routes/rss.d.ts.map +1 -1
  129. package/elysia/src/routes/search.d.ts +1 -1
  130. package/elysia/src/routes/sitemap.d.ts +1 -2
  131. package/elysia/src/routes/sitemap.d.ts.map +1 -1
  132. package/elysia/src/routes/ssr.d.ts +1 -1
  133. package/elysia/src/routes/static.d.ts +1 -1
  134. package/elysia/src/types.d.ts +1 -1
  135. package/package.json +1 -1
  136. package/react/index.d.ts +1 -1
  137. package/react/index.js +2 -2
  138. package/react/index.js.map +1 -1
  139. package/react/src/components/ClientOnly.d.ts +1 -1
  140. package/react/src/components/ContentRoute.d.ts +1 -1
  141. package/react/src/components/Image.d.ts +1 -1
  142. package/react/src/components/LazyRoute.d.ts +1 -1
  143. package/react/src/components/Link.d.ts +1 -1
  144. package/react/src/components/Markdown.d.ts +1 -1
  145. package/react/src/components/Outlet.d.ts +1 -1
  146. package/react/src/components/index.d.ts +1 -1
  147. package/react/src/hooks/index.d.ts +1 -1
  148. package/react/src/hooks/useContent.d.ts +1 -1
  149. package/react/src/hooks/useData.d.ts +1 -1
  150. package/react/src/hooks/useFeed.d.ts +1 -1
  151. package/react/src/hooks/useLayoutData.d.ts +1 -1
  152. package/react/src/hooks/useLlms.d.ts +1 -1
  153. package/react/src/hooks/useNavigate.d.ts +1 -1
  154. package/react/src/hooks/useParams.d.ts +1 -1
  155. package/react/src/hooks/useRouter.d.ts +1 -1
  156. package/react/src/hooks/useSearch.d.ts +1 -1
  157. package/react/src/hooks/useSearchParams.d.ts +1 -1
  158. package/react/src/hooks/useToc.d.ts +1 -1
  159. package/react/src/index.d.ts +1 -1
  160. package/react/src/lib/collection.d.ts +1 -1
  161. package/react/src/lib/content.d.ts +1 -1
  162. package/react/src/lib/head.d.ts +1 -1
  163. package/react/src/lib/index.d.ts +1 -1
  164. package/react/src/lib/lazy-route.d.ts +1 -1
  165. package/react/src/lib/route-loader.d.ts +1 -1
  166. package/react/src/providers/ContentProvider.d.ts +1 -1
  167. package/react/src/providers/RerouteProvider.d.ts +1 -1
  168. package/react/src/providers/RouterProvider.d.ts +1 -1
  169. package/react/src/providers/index.d.ts +1 -1
  170. package/react/src/types/any.d.ts +1 -1
  171. package/react/src/types/index.d.ts +1 -1
  172. package/react/src/types/router.d.ts +1 -1
  173. package/telemetry/react.d.ts +1 -1
  174. package/telemetry/react.js +2 -2
  175. package/telemetry/react.js.map +1 -1
  176. package/telemetry/server.d.ts +1 -1
  177. package/telemetry/server.js +3 -2
  178. package/telemetry/server.js.map +10 -10
  179. package/telemetry/src/react/api.d.ts +1 -1
  180. package/telemetry/src/react/context.d.ts +1 -1
  181. package/telemetry/src/react/index.d.ts +1 -1
  182. package/telemetry/src/react/telemetry.d.ts +1 -1
  183. package/telemetry/src/server/context.d.ts +1 -1
  184. package/telemetry/src/server/index.d.ts +1 -1
  185. package/telemetry/src/server/instrumentation.d.ts +1 -1
  186. package/telemetry/src/server/plugin.d.ts +1 -1
  187. package/telemetry/src/server/sourcemap.d.ts +1 -1
package/elysia/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * reroute-js v0.34.7
2
+ * reroute-js v0.34.9
3
3
  *
4
4
  * @license MIT
5
5
  * @copyright 2025 stewones <hi@stewan.io>
@@ -1045,9 +1045,11 @@ function matchPatternUtil(pattern, pathname) {
1045
1045
  return params;
1046
1046
  }
1047
1047
  function createBundledRoutesModule(bundledRoutes, bundledLayouts) {
1048
+ const bundledNotFoundRoutes = globalThis.__REROUTE_NOT_FOUND_ROUTES__;
1048
1049
  return {
1049
1050
  routes: bundledRoutes,
1050
1051
  layouts: bundledLayouts,
1052
+ notFoundRoutes: bundledNotFoundRoutes,
1051
1053
  matchRoute: (pathname) => {
1052
1054
  for (const route of bundledRoutes) {
1053
1055
  const pattern = String(route?.pattern || "");
@@ -1872,8 +1874,10 @@ async function extractRouteMetadata(pathname, clientDir, cwd, isWatchMode, curre
1872
1874
  let lang;
1873
1875
  let statusOverride = currentStatusOverride;
1874
1876
  try {
1875
- const routesPath = join(cwd, ".reroute", "routes.ts");
1876
- const m = await dynamicImport(routesPath, isWatchMode);
1877
+ const m = await loadRoutesModule(cwd, isWatchMode);
1878
+ if (!m) {
1879
+ return { head, lang, statusOverride: statusOverride || 404 };
1880
+ }
1877
1881
  const pathnameOnly = pathname.split("?")[0];
1878
1882
  const match = typeof m.matchRoute === "function" ? m.matchRoute(pathnameOnly) : null;
1879
1883
  const r = match?.route;
@@ -1954,6 +1958,7 @@ function extractSSRLang(ssr) {
1954
1958
  var init_metadata2 = __esm(() => {
1955
1959
  init_metadata();
1956
1960
  init_meta();
1961
+ init_compute();
1957
1962
  init_imports();
1958
1963
  });
1959
1964
 
@@ -1991,6 +1996,16 @@ async function preloadContentModule(pathname, clientDir, cwd, isWatchMode) {
1991
1996
  }
1992
1997
  async function isContentCollection(clientDir, collection) {
1993
1998
  try {
1999
+ const isProduction = clientDir.endsWith(".reroute");
2000
+ if (isProduction) {
2001
+ const collectionFile = join(clientDir, "collections", `${collection}.js`);
2002
+ try {
2003
+ const s2 = await stat4(collectionFile);
2004
+ return s2?.isFile() ?? false;
2005
+ } catch {
2006
+ return false;
2007
+ }
2008
+ }
1994
2009
  const maybeDir = join(clientDir, "routes", collection, "content");
1995
2010
  const s = await stat4(maybeDir);
1996
2011
  return typeof s?.isDirectory === "function" ? s.isDirectory() : true;
@@ -2441,7 +2456,7 @@ async function performSSRSetupInternal(options, streaming) {
2441
2456
  return css;
2442
2457
  });
2443
2458
  let statusOverride = preloadResult.statusOverride;
2444
- if (computeResult.statusContainer.value) {
2459
+ if (computeResult.statusContainer.value !== undefined) {
2445
2460
  statusOverride = computeResult.statusContainer.value;
2446
2461
  }
2447
2462
  const metadataResult = await withSpan("ssr.extract.metadata", async (span) => {
@@ -2649,10 +2664,10 @@ async function renderSSRDocument(options) {
2649
2664
  return script;
2650
2665
  });
2651
2666
  let statusOverride = setup2.preloadStatusOverride;
2652
- if (setup2.statusContainer.value) {
2667
+ if (setup2.statusContainer.value !== undefined) {
2653
2668
  statusOverride = setup2.statusContainer.value;
2654
2669
  }
2655
- if (setup2.metadataResult.statusOverride) {
2670
+ if (setup2.metadataResult.statusOverride !== undefined) {
2656
2671
  statusOverride = setup2.metadataResult.statusOverride;
2657
2672
  }
2658
2673
  const extraHead = setup2.bundlePreload + setup2.preloadExtraHead;
@@ -3102,9 +3117,9 @@ async function discoverCollectionRoutes(cwd, collections2, isWatchMode, llmsConf
3102
3117
  }
3103
3118
  return collectionsMap;
3104
3119
  }
3105
- async function loadRouteModule(clientDir, routePath, isWatchMode) {
3120
+ async function loadRouteModule(cwd, routePath, isWatchMode) {
3106
3121
  try {
3107
- const abs = join(clientDir, "routes", routePath);
3122
+ const abs = join(cwd, "src", "client", "routes", routePath);
3108
3123
  const modUrl = `${pathToFileURL6(abs).href}${isWatchMode ? `?t=${Date.now()}` : ""}`;
3109
3124
  return await import(modUrl);
3110
3125
  } catch {
@@ -3137,24 +3152,47 @@ function createEntriesFromArray(array, routePath) {
3137
3152
  }
3138
3153
  return entries;
3139
3154
  }
3140
- async function discoverSSRDataRoutes(_cwd, clientDir, staticRoutes, isWatchMode) {
3155
+ async function discoverSSRDataRoutes(cwd, staticRoutes, isWatchMode) {
3141
3156
  const ssrDataRoutes = new Map;
3142
- for (const route of staticRoutes) {
3143
- const mod = await loadRouteModule(clientDir, route.path, isWatchMode);
3144
- if (!mod)
3145
- continue;
3146
- const ssr = mod?.ssr;
3147
- const dataFn = ssr?.data;
3148
- if (typeof dataFn !== "function")
3149
- continue;
3150
- const result = await callDataFunction(dataFn, route.path);
3151
- const arrays = findArraysInData(result);
3152
- for (const array of arrays) {
3153
- if (array.length === 0)
3157
+ const bundledRoutes = globalThis.__REROUTE_ROUTES__;
3158
+ if (bundledRoutes && Array.isArray(bundledRoutes)) {
3159
+ for (const route of staticRoutes) {
3160
+ const bundledRoute = bundledRoutes.find((r) => r?.path === route.path);
3161
+ if (!bundledRoute)
3162
+ continue;
3163
+ const ssr = bundledRoute?.ssr;
3164
+ const dataFn = ssr?.data;
3165
+ if (typeof dataFn !== "function")
3154
3166
  continue;
3155
- const entries = createEntriesFromArray(array, route.path);
3156
- if (entries.length > 0) {
3157
- ssrDataRoutes.set(route.path, entries);
3167
+ const result = await callDataFunction(dataFn, route.path);
3168
+ const arrays = findArraysInData(result);
3169
+ for (const array of arrays) {
3170
+ if (array.length === 0)
3171
+ continue;
3172
+ const entries = createEntriesFromArray(array, route.path);
3173
+ if (entries.length > 0) {
3174
+ ssrDataRoutes.set(route.path, entries);
3175
+ }
3176
+ }
3177
+ }
3178
+ } else {
3179
+ for (const route of staticRoutes) {
3180
+ const mod = await loadRouteModule(cwd, route.path, isWatchMode);
3181
+ if (!mod)
3182
+ continue;
3183
+ const ssr = mod?.ssr;
3184
+ const dataFn = ssr?.data;
3185
+ if (typeof dataFn !== "function")
3186
+ continue;
3187
+ const result = await callDataFunction(dataFn, route.path);
3188
+ const arrays = findArraysInData(result);
3189
+ for (const array of arrays) {
3190
+ if (array.length === 0)
3191
+ continue;
3192
+ const entries = createEntriesFromArray(array, route.path);
3193
+ if (entries.length > 0) {
3194
+ ssrDataRoutes.set(route.path, entries);
3195
+ }
3158
3196
  }
3159
3197
  }
3160
3198
  }
@@ -3277,12 +3315,12 @@ function addStaticSection(parts, section, routes, baseUrl, isSingleCollection, t
3277
3315
  parts.push("");
3278
3316
  }
3279
3317
  async function generateLLMsIndex(options) {
3280
- const { cwd, clientDir, collections: collections2, baseUrl, isWatchMode, llmsConfig } = options;
3318
+ const { cwd, collections: collections2, baseUrl, isWatchMode, llmsConfig } = options;
3281
3319
  const parts = [];
3282
3320
  addIndexHeader(parts, llmsConfig);
3283
3321
  const staticRoutes = await discoverStaticRoutes(cwd, isWatchMode);
3284
3322
  const collectionsMap = await discoverCollectionRoutes(cwd, collections2, isWatchMode, llmsConfig);
3285
- const ssrDataRoutes = await discoverSSRDataRoutes(cwd, clientDir, staticRoutes, isWatchMode);
3323
+ const ssrDataRoutes = await discoverSSRDataRoutes(cwd, staticRoutes, isWatchMode);
3286
3324
  const isSingleCollection = collections2.length === 1;
3287
3325
  const targetCollection = isSingleCollection ? collections2[0] : null;
3288
3326
  const { sections, rootRoutes } = groupStaticRoutes(staticRoutes, llmsConfig);
@@ -3331,7 +3369,7 @@ function buildHeader(baseUrl, llmsConfig) {
3331
3369
  }
3332
3370
  return parts;
3333
3371
  }
3334
- async function discoverAllRoutes(cwd, clientDir, collections2, isWatchMode, llmsConfig) {
3372
+ async function discoverAllRoutes(cwd, collections2, isWatchMode, llmsConfig) {
3335
3373
  const {
3336
3374
  discoverStaticRoutes: discoverStaticRoutes2,
3337
3375
  discoverCollectionRoutes: discoverCollectionRoutes2,
@@ -3339,7 +3377,7 @@ async function discoverAllRoutes(cwd, clientDir, collections2, isWatchMode, llms
3339
3377
  } = await Promise.resolve().then(() => (init_index_generator(), exports_index_generator));
3340
3378
  const staticRoutes = await discoverStaticRoutes2(cwd, isWatchMode);
3341
3379
  const collectionsMap = await discoverCollectionRoutes2(cwd, collections2, isWatchMode, llmsConfig);
3342
- const ssrDataRoutes = await discoverSSRDataRoutes2(cwd, clientDir, staticRoutes, isWatchMode);
3380
+ const ssrDataRoutes = await discoverSSRDataRoutes2(cwd, staticRoutes, isWatchMode);
3343
3381
  const allRoutes = [];
3344
3382
  for (const route of staticRoutes) {
3345
3383
  if (!shouldExcludeRoute(route.path, llmsConfig?.excludeRoutes)) {
@@ -3429,9 +3467,9 @@ function buildFooter(parts) {
3429
3467
  parts.push("Formats: .txt | .md | Accept: text/plain | Accept: text/markdown");
3430
3468
  }
3431
3469
  async function generateLLMsFullContent(options) {
3432
- const { cwd, clientDir, collections: collections2, baseUrl, isWatchMode, llmsConfig } = options;
3470
+ const { cwd, collections: collections2, baseUrl, isWatchMode, llmsConfig } = options;
3433
3471
  const parts = buildHeader(baseUrl, llmsConfig);
3434
- const allRoutes = await discoverAllRoutes(cwd, clientDir, collections2, isWatchMode, llmsConfig);
3472
+ const allRoutes = await discoverAllRoutes(cwd, collections2, isWatchMode, llmsConfig);
3435
3473
  const maxItems = llmsConfig?.maxItems || 1e4;
3436
3474
  const routesToProcess = allRoutes.slice(0, maxItems);
3437
3475
  const extracted = await extractRouteContents(routesToProcess, options);
@@ -3848,30 +3886,58 @@ async function discoverCollectionContent(cwd, collection, isWatchMode, baseUrl)
3848
3886
  }
3849
3887
  return entries;
3850
3888
  }
3851
- async function discoverSSRDataRoutes2(_cwd, clientDir, staticRoutes, isWatchMode, baseUrl, sitemapConfig) {
3889
+ async function discoverSSRDataRoutes2(cwd, staticRoutes, isWatchMode, baseUrl, sitemapConfig) {
3852
3890
  const ssrDataRoutes = new Map;
3853
- for (const route of staticRoutes) {
3854
- if (sitemapConfig?.excludeDiscovery?.includes(route.pattern)) {
3855
- continue;
3856
- }
3857
- try {
3858
- const abs = join(clientDir, "routes", route.path);
3859
- const mod = await import(Bun.pathToFileURL(abs).href + (isWatchMode ? `?t=${Date.now()}` : ""));
3860
- const ssr = mod?.ssr;
3891
+ const bundledRoutes = globalThis.__REROUTE_ROUTES__;
3892
+ if (bundledRoutes && Array.isArray(bundledRoutes)) {
3893
+ for (const route of staticRoutes) {
3894
+ if (sitemapConfig?.excludeDiscovery?.includes(route.pattern)) {
3895
+ continue;
3896
+ }
3897
+ const bundledRoute = bundledRoutes.find((r) => r?.pattern === route.pattern);
3898
+ if (!bundledRoute)
3899
+ continue;
3900
+ const ssr = bundledRoute?.ssr;
3861
3901
  const dataFn = ssr?.data;
3862
3902
  if (typeof dataFn === "function") {
3863
- const mockSet = { status: 200 };
3864
- const result = await dataFn({
3865
- pathname: route.pattern,
3866
- params: {},
3867
- set: mockSet
3868
- });
3869
- const entries = extractEntriesFromData(result, route.pattern, baseUrl, sitemapConfig);
3870
- if (entries.length > 0) {
3871
- ssrDataRoutes.set(route.pattern, entries);
3872
- }
3903
+ try {
3904
+ const mockSet = { status: 200 };
3905
+ const result = await dataFn({
3906
+ pathname: route.pattern,
3907
+ params: {},
3908
+ set: mockSet
3909
+ });
3910
+ const entries = extractEntriesFromData(result, route.pattern, baseUrl, sitemapConfig);
3911
+ if (entries.length > 0) {
3912
+ ssrDataRoutes.set(route.pattern, entries);
3913
+ }
3914
+ } catch {}
3873
3915
  }
3874
- } catch {}
3916
+ }
3917
+ } else {
3918
+ for (const route of staticRoutes) {
3919
+ if (sitemapConfig?.excludeDiscovery?.includes(route.pattern)) {
3920
+ continue;
3921
+ }
3922
+ try {
3923
+ const routeModulePath = join(cwd, "src", "client", "routes", route.path);
3924
+ const mod = await import(Bun.pathToFileURL(routeModulePath).href + (isWatchMode ? `?t=${Date.now()}` : ""));
3925
+ const ssr = mod?.ssr;
3926
+ const dataFn = ssr?.data;
3927
+ if (typeof dataFn === "function") {
3928
+ const mockSet = { status: 200 };
3929
+ const result = await dataFn({
3930
+ pathname: route.pattern,
3931
+ params: {},
3932
+ set: mockSet
3933
+ });
3934
+ const entries = extractEntriesFromData(result, route.pattern, baseUrl, sitemapConfig);
3935
+ if (entries.length > 0) {
3936
+ ssrDataRoutes.set(route.pattern, entries);
3937
+ }
3938
+ }
3939
+ } catch {}
3940
+ }
3875
3941
  }
3876
3942
  return ssrDataRoutes;
3877
3943
  }
@@ -3981,7 +4047,7 @@ function createEntryFromItem(item, routePattern, baseUrl, sitemapConfig) {
3981
4047
  }
3982
4048
  return entry;
3983
4049
  }
3984
- async function discoverSitemapData(cwd, clientDir, collections2, baseUrl, isWatchMode, sitemapConfig) {
4050
+ async function discoverSitemapData(cwd, collections2, baseUrl, isWatchMode, sitemapConfig) {
3985
4051
  const { staticRoutes, dynamicRoutes } = await discoverRoutes(cwd, isWatchMode);
3986
4052
  const collectionsMap = new Map;
3987
4053
  for (const collection of collections2) {
@@ -3990,7 +4056,7 @@ async function discoverSitemapData(cwd, clientDir, collections2, baseUrl, isWatc
3990
4056
  collectionsMap.set(collection, entries);
3991
4057
  }
3992
4058
  }
3993
- const ssrDataRoutes = await discoverSSRDataRoutes2(cwd, clientDir, staticRoutes, isWatchMode, baseUrl, sitemapConfig);
4059
+ const ssrDataRoutes = await discoverSSRDataRoutes2(cwd, staticRoutes, isWatchMode, baseUrl, sitemapConfig);
3994
4060
  return {
3995
4061
  staticRoutes,
3996
4062
  dynamicRoutes,
@@ -4105,10 +4171,10 @@ async function discoverCollectionFeedItems(cwd, collection, isWatchMode, baseUrl
4105
4171
  sortByPubDate(items);
4106
4172
  return items;
4107
4173
  }
4108
- async function discoverSSRDataFeedItems(_cwd, clientDir, routePattern, routePath, isWatchMode, baseUrl, rssConfig) {
4174
+ async function discoverSSRDataFeedItems(cwd, routePattern, routePath, isWatchMode, baseUrl, rssConfig) {
4109
4175
  const items = [];
4110
4176
  try {
4111
- const abs = join(clientDir, "routes", routePath);
4177
+ const abs = join(cwd, "src", "client", "routes", routePath);
4112
4178
  const mod = await import(pathToFileURL7(abs).href + (isWatchMode ? `?t=${Date.now()}` : ""));
4113
4179
  const ssr = mod?.ssr;
4114
4180
  const dataFn = ssr?.data;
@@ -4244,7 +4310,7 @@ function createRSSItemFromData(item, routePattern, baseUrl, rssConfig) {
4244
4310
  }
4245
4311
  return rssItem;
4246
4312
  }
4247
- async function discoverRSSData(cwd, clientDir, collections2, baseUrl, isWatchMode, rssConfig) {
4313
+ async function discoverRSSData(cwd, collections2, baseUrl, isWatchMode, rssConfig) {
4248
4314
  const collectionsMap = new Map;
4249
4315
  for (const collection of collections2) {
4250
4316
  const items = await discoverCollectionFeedItems(cwd, collection, isWatchMode, baseUrl, rssConfig);
@@ -4253,18 +4319,48 @@ async function discoverRSSData(cwd, clientDir, collections2, baseUrl, isWatchMod
4253
4319
  }
4254
4320
  }
4255
4321
  const ssrDataFeeds = new Map;
4256
- const { discoverRoutes: discoverRoutes2 } = await Promise.resolve().then(() => (init_discovery4(), exports_discovery));
4257
- const { staticRoutes } = await discoverRoutes2(cwd, isWatchMode);
4258
- for (const route of staticRoutes) {
4259
- if (rssConfig?.excludeDiscovery?.includes(route.pattern)) {
4260
- continue;
4322
+ const bundledRoutes = globalThis.__REROUTE_ROUTES__;
4323
+ if (bundledRoutes && Array.isArray(bundledRoutes)) {
4324
+ const { discoverRoutes: discoverRoutes2 } = await Promise.resolve().then(() => (init_discovery4(), exports_discovery));
4325
+ const { staticRoutes } = await discoverRoutes2(cwd, isWatchMode);
4326
+ for (const route of staticRoutes) {
4327
+ if (rssConfig?.excludeDiscovery?.includes(route.pattern)) {
4328
+ continue;
4329
+ }
4330
+ const bundledRoute = bundledRoutes.find((r) => r?.pattern === route.pattern);
4331
+ if (!bundledRoute)
4332
+ continue;
4333
+ const ssr = bundledRoute?.ssr;
4334
+ const dataFn = ssr?.data;
4335
+ if (typeof dataFn === "function") {
4336
+ try {
4337
+ const mockSet = { status: 200 };
4338
+ const result = await dataFn({
4339
+ pathname: route.pattern,
4340
+ params: {},
4341
+ set: mockSet
4342
+ });
4343
+ const items = extractRSSItemsFromData(result, route.pattern, baseUrl, rssConfig);
4344
+ if (items.length > 0) {
4345
+ ssrDataFeeds.set(route.pattern, items);
4346
+ }
4347
+ } catch {}
4348
+ }
4261
4349
  }
4262
- const items = await discoverSSRDataFeedItems(cwd, clientDir, route.pattern, route.path, isWatchMode, baseUrl, rssConfig);
4263
- if (items.length > 0) {
4264
- ssrDataFeeds.set(route.pattern, items);
4350
+ } else {
4351
+ const { discoverRoutes: discoverRoutes2 } = await Promise.resolve().then(() => (init_discovery4(), exports_discovery));
4352
+ const { staticRoutes } = await discoverRoutes2(cwd, isWatchMode);
4353
+ for (const route of staticRoutes) {
4354
+ if (rssConfig?.excludeDiscovery?.includes(route.pattern)) {
4355
+ continue;
4356
+ }
4357
+ const items = await discoverSSRDataFeedItems(cwd, route.pattern, route.path, isWatchMode, baseUrl, rssConfig);
4358
+ if (items.length > 0) {
4359
+ ssrDataFeeds.set(route.pattern, items);
4360
+ }
4265
4361
  }
4266
4362
  }
4267
- const layoutFeeds = await discoverLayoutFeedItems(cwd, clientDir, isWatchMode, baseUrl, rssConfig);
4363
+ const layoutFeeds = await discoverLayoutFeedItems(cwd, isWatchMode, baseUrl, rssConfig);
4268
4364
  for (const [pattern, items] of layoutFeeds.entries()) {
4269
4365
  const existing = ssrDataFeeds.get(pattern) || [];
4270
4366
  ssrDataFeeds.set(pattern, [...existing, ...items]);
@@ -4288,13 +4384,13 @@ async function loadLayouts(cwd, isWatchMode) {
4288
4384
  return;
4289
4385
  }
4290
4386
  }
4291
- async function processLayoutForRSS(layout, clientDir, isWatchMode, baseUrl, rssConfig) {
4387
+ async function processLayoutForRSS(layout, cwd, isWatchMode, baseUrl, rssConfig) {
4292
4388
  const pattern = String(layout?.pattern || "/");
4293
4389
  const path2 = String(layout?.path || "");
4294
4390
  if (!path2)
4295
4391
  return null;
4296
4392
  try {
4297
- const abs = join(clientDir, "routes", path2);
4393
+ const abs = join(cwd, "src", "client", "routes", path2);
4298
4394
  const layoutMod = await import(pathToFileURL7(abs).href + (isWatchMode ? `?t=${Date.now()}` : ""));
4299
4395
  const ssr = layoutMod?.ssr;
4300
4396
  const dataFn = ssr?.data;
@@ -4313,16 +4409,39 @@ async function processLayoutForRSS(layout, clientDir, isWatchMode, baseUrl, rssC
4313
4409
  } catch {}
4314
4410
  return null;
4315
4411
  }
4316
- async function discoverLayoutFeedItems(cwd, clientDir, isWatchMode, baseUrl, rssConfig) {
4412
+ async function discoverLayoutFeedItems(cwd, isWatchMode, baseUrl, rssConfig) {
4317
4413
  const layoutFeeds = new Map;
4318
4414
  const layouts2 = await loadLayouts(cwd, isWatchMode);
4319
4415
  if (!Array.isArray(layouts2)) {
4320
4416
  return layoutFeeds;
4321
4417
  }
4322
- for (const layout of layouts2) {
4323
- const result = await processLayoutForRSS(layout, clientDir, isWatchMode, baseUrl, rssConfig);
4324
- if (result) {
4325
- layoutFeeds.set(result.pattern, result.items);
4418
+ const bundledLayouts = globalThis.__REROUTE_LAYOUTS__;
4419
+ if (bundledLayouts && Array.isArray(bundledLayouts)) {
4420
+ for (const layout of bundledLayouts) {
4421
+ const pattern = String(layout?.pattern || "/");
4422
+ const ssr = layout?.ssr;
4423
+ const dataFn = ssr?.data;
4424
+ if (typeof dataFn === "function") {
4425
+ try {
4426
+ const mockSet = { status: 200 };
4427
+ const result = await dataFn({
4428
+ pathname: pattern,
4429
+ params: {},
4430
+ set: mockSet
4431
+ });
4432
+ const items = extractRSSItemsFromData(result, pattern, baseUrl, rssConfig);
4433
+ if (items.length > 0) {
4434
+ layoutFeeds.set(pattern, items);
4435
+ }
4436
+ } catch {}
4437
+ }
4438
+ }
4439
+ } else {
4440
+ for (const layout of layouts2) {
4441
+ const result = await processLayoutForRSS(layout, cwd, isWatchMode, baseUrl, rssConfig);
4442
+ if (result) {
4443
+ layoutFeeds.set(result.pattern, result.items);
4444
+ }
4326
4445
  }
4327
4446
  }
4328
4447
  return layoutFeeds;
@@ -4626,10 +4745,10 @@ async function renderSSRDocumentStream(options) {
4626
4745
  if (debug)
4627
4746
  console.log(`[renderStream] ${pathname} - performSSRSetup: ${(performance.now() - t0).toFixed(2)}ms`);
4628
4747
  let statusOverride = setup2.preloadStatusOverride;
4629
- if (setup2.statusContainer.value) {
4748
+ if (setup2.statusContainer.value !== undefined) {
4630
4749
  statusOverride = setup2.statusContainer.value;
4631
4750
  }
4632
- if (setup2.metadataResult.statusOverride) {
4751
+ if (setup2.metadataResult.statusOverride !== undefined) {
4633
4752
  statusOverride = setup2.metadataResult.statusOverride;
4634
4753
  }
4635
4754
  const encoder = new TextEncoder;
@@ -4849,6 +4968,7 @@ __export(exports_core, {
4849
4968
  preloadContentModule: () => preloadContentModule,
4850
4969
  performSSRSetup: () => performSSRSetup,
4851
4970
  mergeLayoutData: () => mergeLayoutData,
4971
+ loadRoutesModule: () => loadRoutesModule,
4852
4972
  loadOGImageComponent: () => loadOGImageComponent,
4853
4973
  loadIndexHtml: () => loadIndexHtml,
4854
4974
  loadConfig: () => loadConfig,
@@ -6092,7 +6212,6 @@ function registerLLMsRoutes(app, options) {
6092
6212
  }
6093
6213
  const content2 = await generateLLMsIndex({
6094
6214
  cwd,
6095
- clientDir,
6096
6215
  collections: collections2,
6097
6216
  baseUrl,
6098
6217
  isWatchMode,
@@ -6159,7 +6278,6 @@ function registerLLMsRoutes(app, options) {
6159
6278
  }
6160
6279
  const content2 = await generateLLMsIndex({
6161
6280
  cwd,
6162
- clientDir,
6163
6281
  collections: [collection],
6164
6282
  baseUrl,
6165
6283
  isWatchMode,
@@ -6733,7 +6851,7 @@ function createFeedTitle(configTitle, name) {
6733
6851
  async function discoverSSRRoutes(cwd, isWatchMode) {
6734
6852
  try {
6735
6853
  const { discoverSitemapData: discoverSitemapData2 } = await Promise.resolve().then(() => (init_core(), exports_core));
6736
- const sitemapData = await discoverSitemapData2(cwd, "", [], "", isWatchMode);
6854
+ const sitemapData = await discoverSitemapData2(cwd, [], "", isWatchMode);
6737
6855
  const staticRoutes = sitemapData.staticRoutes.filter((r) => !r.pattern.includes(":")).map((r) => ({ pattern: r.pattern, path: r.path }));
6738
6856
  const routesPath = join(cwd, ".reroute", "routes.ts");
6739
6857
  const routesMod = await import(`${Bun.pathToFileURL(routesPath).href}${isWatchMode ? `?t=${Date.now()}` : ""}`);
@@ -6750,14 +6868,14 @@ async function discoverSSRRoutes(cwd, isWatchMode) {
6750
6868
  return [];
6751
6869
  }
6752
6870
  }
6753
- async function registerMainFeedRoute(app, cwd, clientDir, collections2, baseUrl, isWatchMode, rssCache, format, limit, maxAge, ttlMs, feedTitle, feedDescription, rssConfig) {
6871
+ async function registerMainFeedRoute(app, cwd, collections2, baseUrl, isWatchMode, rssCache, format, limit, maxAge, ttlMs, feedTitle, feedDescription, rssConfig) {
6754
6872
  app.get("/feed.xml", async () => {
6755
6873
  try {
6756
6874
  const cached = getIfValid(rssCache, "rss:main");
6757
6875
  if (cached) {
6758
6876
  return feedResponse(cached.xml, format, { maxAge, cacheStatus: "HIT" });
6759
6877
  }
6760
- const discovery5 = await discoverRSSData(cwd, clientDir, collections2, baseUrl, isWatchMode, rssConfig);
6878
+ const discovery5 = await discoverRSSData(cwd, collections2, baseUrl, isWatchMode, rssConfig);
6761
6879
  const allItems = [
6762
6880
  ...Array.from(discovery5.collections.values()).flat(),
6763
6881
  ...Array.from(discovery5.ssrDataFeeds.values()).flat()
@@ -6796,7 +6914,7 @@ function registerCollectionFeedRoutes(app, collections2, options) {
6796
6914
  cacheStatus: "HIT"
6797
6915
  });
6798
6916
  }
6799
- const discovery5 = await discoverRSSData(options.cwd, options.clientDir, [collection], options.baseUrl, options.isWatchMode, options.rssConfig);
6917
+ const discovery5 = await discoverRSSData(options.cwd, [collection], options.baseUrl, options.isWatchMode, options.rssConfig);
6800
6918
  const items = discovery5.collections.get(collection) ?? [];
6801
6919
  if (items.length === 0)
6802
6920
  throw new NotFoundError9;
@@ -6836,7 +6954,7 @@ async function discoverRoutesWithFeeds(ssrDataRoutes, collections2, options) {
6836
6954
  if (options.rssConfig?.excludeRoutes?.includes(route.pattern))
6837
6955
  continue;
6838
6956
  try {
6839
- const items = await discoverSSRDataFeedItems(options.cwd, options.clientDir, route.pattern, route.path, options.isWatchMode, options.baseUrl, options.rssConfig);
6957
+ const items = await discoverSSRDataFeedItems(options.cwd, route.pattern, route.path, options.isWatchMode, options.baseUrl, options.rssConfig);
6840
6958
  if (items.length > 0) {
6841
6959
  routesWithFeeds.push(route);
6842
6960
  options.availableFeeds.push(`${route.pattern}/feed.xml`);
@@ -6855,9 +6973,9 @@ async function generateSSRDataFeed(route, options) {
6855
6973
  cacheStatus: "HIT"
6856
6974
  });
6857
6975
  }
6858
- let items = await discoverSSRDataFeedItems(options.cwd, options.clientDir, route.pattern, route.path, options.isWatchMode, options.baseUrl, options.rssConfig);
6976
+ let items = await discoverSSRDataFeedItems(options.cwd, route.pattern, route.path, options.isWatchMode, options.baseUrl, options.rssConfig);
6859
6977
  if (items.length === 0 && route.isLayout) {
6860
- const discovery5 = await discoverRSSData(options.cwd, options.clientDir, [], options.baseUrl, options.isWatchMode, options.rssConfig);
6978
+ const discovery5 = await discoverRSSData(options.cwd, [], options.baseUrl, options.isWatchMode, options.rssConfig);
6861
6979
  items = discovery5.ssrDataFeeds.get(route.pattern) ?? [];
6862
6980
  }
6863
6981
  if (items.length === 0)
@@ -6913,7 +7031,7 @@ async function registerRSSRoutes(app, options) {
6913
7031
  const feedTitle = rssConfig?.title ?? "Feed";
6914
7032
  const feedDescription = rssConfig?.description ?? "Latest updates";
6915
7033
  const availableFeeds = ["/feed.xml"];
6916
- registerMainFeedRoute(app, cwd, clientDir, collections2, baseUrl, isWatchMode, rssCache, format, limit, maxAge, ttlMs, feedTitle, feedDescription, rssConfig);
7034
+ registerMainFeedRoute(app, cwd, collections2, baseUrl, isWatchMode, rssCache, format, limit, maxAge, ttlMs, feedTitle, feedDescription, rssConfig);
6917
7035
  const ssrDataRoutes = await discoverSSRRoutes(cwd, isWatchMode);
6918
7036
  registerCollectionFeedRoutes(app, collections2, {
6919
7037
  cwd,
@@ -6938,7 +7056,6 @@ async function registerRSSRoutes(app, options) {
6938
7056
  });
6939
7057
  registerSSRDataFeedRoutes(app, routesWithFeeds, {
6940
7058
  cwd,
6941
- clientDir,
6942
7059
  baseUrl,
6943
7060
  isWatchMode,
6944
7061
  rssCache,
@@ -7080,8 +7197,8 @@ function registerSearchRoute(app, cwd, directive, maxAge, searchConfig) {
7080
7197
  init_core();
7081
7198
  import { NotFoundError as NotFoundError10 } from "elysia";
7082
7199
  async function generateAndCacheSitemap(options, _ttlMs) {
7083
- const { cwd, clientDir, collections: collections2, baseUrl, isWatchMode, sitemapConfig } = options;
7084
- const discovery5 = await discoverSitemapData(cwd, clientDir, collections2, baseUrl, isWatchMode, sitemapConfig);
7200
+ const { cwd, collections: collections2, baseUrl, isWatchMode, sitemapConfig } = options;
7201
+ const discovery5 = await discoverSitemapData(cwd, collections2, baseUrl, isWatchMode, sitemapConfig);
7085
7202
  const result = await generateSitemap(discovery5, baseUrl, {
7086
7203
  changefreq: sitemapConfig?.changefreq,
7087
7204
  priority: sitemapConfig?.priority,
@@ -7971,7 +8088,6 @@ var reroute = () => async (app) => {
7971
8088
  try {
7972
8089
  registerSitemapRoutes(app, {
7973
8090
  cwd,
7974
- clientDir,
7975
8091
  collections: collections2,
7976
8092
  baseUrl: sitemapBaseUrl,
7977
8093
  maxAge,
@@ -8035,4 +8151,4 @@ export {
8035
8151
  reroute
8036
8152
  };
8037
8153
 
8038
- //# debugId=242505316A422AEB64756E2164756E21
8154
+ //# debugId=93E7F00FB12AB24D64756E2164756E21