reroute-js 0.34.8 → 0.35.0

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 (186) hide show
  1. package/cli/bin.d.ts +1 -1
  2. package/cli/bin.js +178 -71
  3. package/cli/bin.js.map +8 -8
  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/index.d.ts +1 -1
  13. package/cli/src/commands/init.d.ts +1 -1
  14. package/cli/src/commands/lib/assets.d.ts +1 -1
  15. package/cli/src/commands/lib/bundler.d.ts +1 -1
  16. package/cli/src/commands/lib/command.d.ts +1 -1
  17. package/cli/src/commands/lib/env.d.ts +1 -1
  18. package/cli/src/commands/lib/index.d.ts +1 -1
  19. package/cli/src/commands/lib/log.d.ts +1 -1
  20. package/cli/src/commands/lib/markdown/availability.d.ts +1 -1
  21. package/cli/src/commands/lib/markdown/index.d.ts +1 -1
  22. package/cli/src/commands/lib/markdown/processor.d.ts +1 -1
  23. package/cli/src/commands/lib/production.d.ts +1 -1
  24. package/cli/src/commands/lib/server.d.ts +1 -1
  25. package/cli/src/commands/lib/streaming/analyzer.d.ts +1 -1
  26. package/cli/src/commands/lib/streaming/suspense.d.ts +1 -1
  27. package/cli/src/commands/lib/tailwind.d.ts +1 -1
  28. package/cli/src/commands/lib/terminal-ui.d.ts +1 -1
  29. package/cli/src/commands/lib/version.d.ts +1 -1
  30. package/cli/src/commands/og.d.ts +1 -1
  31. package/cli/src/commands/start.d.ts +1 -1
  32. package/cli/src/index.d.ts +1 -1
  33. package/core/index.d.ts +1 -1
  34. package/core/index.js +174 -67
  35. package/core/index.js.map +8 -8
  36. package/core/src/bundler/hash.d.ts +1 -1
  37. package/core/src/bundler/index.d.ts +1 -1
  38. package/core/src/config.d.ts +3 -1
  39. package/core/src/config.d.ts.map +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/discovery.d.ts.map +1 -1
  58. package/core/src/robots/generator.d.ts +1 -1
  59. package/core/src/robots/index.d.ts +1 -1
  60. package/core/src/robots/policies.d.ts +1 -1
  61. package/core/src/rss/discovery.d.ts +4 -4
  62. package/core/src/rss/discovery.d.ts.map +1 -1
  63. package/core/src/rss/generator.d.ts +1 -1
  64. package/core/src/rss/index.d.ts +1 -1
  65. package/core/src/sitemap/discovery.d.ts +3 -3
  66. package/core/src/sitemap/discovery.d.ts.map +1 -1
  67. package/core/src/sitemap/generator.d.ts +1 -1
  68. package/core/src/sitemap/index.d.ts +1 -1
  69. package/core/src/ssr/index.d.ts +1 -1
  70. package/core/src/ssr/lib/cache.d.ts +1 -1
  71. package/core/src/ssr/lib/collections.d.ts +1 -1
  72. package/core/src/ssr/lib/compression.d.ts +1 -1
  73. package/core/src/ssr/lib/compute/content.d.ts +1 -1
  74. package/core/src/ssr/lib/compute/index.d.ts +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/mime.d.ts +1 -1
  84. package/core/src/ssr/lib/modules.d.ts +1 -1
  85. package/core/src/ssr/lib/path.d.ts +1 -1
  86. package/core/src/ssr/lib/preload.d.ts +1 -1
  87. package/core/src/ssr/lib/scripts/collections.d.ts +1 -1
  88. package/core/src/ssr/lib/scripts/data.d.ts +1 -1
  89. package/core/src/ssr/lib/scripts/escape.d.ts +1 -1
  90. package/core/src/ssr/lib/scripts/feeds.d.ts +1 -1
  91. package/core/src/ssr/lib/scripts/index.d.ts +1 -1
  92. package/core/src/ssr/lib/seed.d.ts +1 -1
  93. package/core/src/ssr/lib/serialize.d.ts +1 -1
  94. package/core/src/ssr/lib/setup.d.ts +1 -1
  95. package/core/src/ssr/lib/styles.d.ts +1 -1
  96. package/core/src/ssr/lib/template.d.ts +1 -1
  97. package/core/src/ssr/lib/types.d.ts +1 -1
  98. package/core/src/ssr/render.d.ts +1 -1
  99. package/core/src/ssr/stream.d.ts +1 -1
  100. package/elysia/index.d.ts +1 -1
  101. package/elysia/index.js +189 -82
  102. package/elysia/index.js.map +13 -13
  103. package/elysia/src/index.d.ts +1 -1
  104. package/elysia/src/libs/assets.d.ts +1 -1
  105. package/elysia/src/libs/cache.d.ts +1 -1
  106. package/elysia/src/libs/caching.d.ts +1 -1
  107. package/elysia/src/libs/http.d.ts +1 -1
  108. package/elysia/src/libs/image.d.ts +1 -1
  109. package/elysia/src/libs/index.d.ts +1 -1
  110. package/elysia/src/libs/llms.d.ts +1 -1
  111. package/elysia/src/libs/response.d.ts +1 -1
  112. package/elysia/src/libs/serving.d.ts +1 -1
  113. package/elysia/src/plugin.d.ts +1 -1
  114. package/elysia/src/plugin.d.ts.map +1 -1
  115. package/elysia/src/routes/artifacts.d.ts +1 -1
  116. package/elysia/src/routes/content.d.ts +1 -1
  117. package/elysia/src/routes/image.d.ts +1 -1
  118. package/elysia/src/routes/index.d.ts +1 -1
  119. package/elysia/src/routes/internal.d.ts +1 -1
  120. package/elysia/src/routes/llms.d.ts +1 -1
  121. package/elysia/src/routes/llms.d.ts.map +1 -1
  122. package/elysia/src/routes/og.d.ts +1 -1
  123. package/elysia/src/routes/redirects.d.ts +1 -1
  124. package/elysia/src/routes/redirects.d.ts.map +1 -1
  125. package/elysia/src/routes/robots.d.ts +1 -1
  126. package/elysia/src/routes/rss.d.ts +1 -1
  127. package/elysia/src/routes/rss.d.ts.map +1 -1
  128. package/elysia/src/routes/search.d.ts +1 -1
  129. package/elysia/src/routes/sitemap.d.ts +1 -2
  130. package/elysia/src/routes/sitemap.d.ts.map +1 -1
  131. package/elysia/src/routes/ssr.d.ts +1 -1
  132. package/elysia/src/routes/static.d.ts +1 -1
  133. package/elysia/src/types.d.ts +1 -1
  134. package/package.json +1 -1
  135. package/react/index.d.ts +1 -1
  136. package/react/index.js +2 -2
  137. package/react/index.js.map +1 -1
  138. package/react/src/components/ClientOnly.d.ts +1 -1
  139. package/react/src/components/ContentRoute.d.ts +1 -1
  140. package/react/src/components/Image.d.ts +1 -1
  141. package/react/src/components/LazyRoute.d.ts +1 -1
  142. package/react/src/components/Link.d.ts +1 -1
  143. package/react/src/components/Markdown.d.ts +1 -1
  144. package/react/src/components/Outlet.d.ts +1 -1
  145. package/react/src/components/index.d.ts +1 -1
  146. package/react/src/hooks/index.d.ts +1 -1
  147. package/react/src/hooks/useContent.d.ts +1 -1
  148. package/react/src/hooks/useData.d.ts +1 -1
  149. package/react/src/hooks/useFeed.d.ts +1 -1
  150. package/react/src/hooks/useLayoutData.d.ts +1 -1
  151. package/react/src/hooks/useLlms.d.ts +1 -1
  152. package/react/src/hooks/useNavigate.d.ts +1 -1
  153. package/react/src/hooks/useParams.d.ts +1 -1
  154. package/react/src/hooks/useRouter.d.ts +1 -1
  155. package/react/src/hooks/useSearch.d.ts +1 -1
  156. package/react/src/hooks/useSearchParams.d.ts +1 -1
  157. package/react/src/hooks/useToc.d.ts +1 -1
  158. package/react/src/index.d.ts +1 -1
  159. package/react/src/lib/collection.d.ts +1 -1
  160. package/react/src/lib/content.d.ts +1 -1
  161. package/react/src/lib/head.d.ts +1 -1
  162. package/react/src/lib/index.d.ts +1 -1
  163. package/react/src/lib/lazy-route.d.ts +1 -1
  164. package/react/src/lib/route-loader.d.ts +1 -1
  165. package/react/src/providers/ContentProvider.d.ts +1 -1
  166. package/react/src/providers/RerouteProvider.d.ts +1 -1
  167. package/react/src/providers/RouterProvider.d.ts +1 -1
  168. package/react/src/providers/index.d.ts +1 -1
  169. package/react/src/types/any.d.ts +1 -1
  170. package/react/src/types/index.d.ts +1 -1
  171. package/react/src/types/router.d.ts +1 -1
  172. package/telemetry/react.d.ts +1 -1
  173. package/telemetry/react.js +2 -2
  174. package/telemetry/react.js.map +1 -1
  175. package/telemetry/server.d.ts +1 -1
  176. package/telemetry/server.js +2 -2
  177. package/telemetry/server.js.map +5 -5
  178. package/telemetry/src/react/api.d.ts +1 -1
  179. package/telemetry/src/react/context.d.ts +1 -1
  180. package/telemetry/src/react/index.d.ts +1 -1
  181. package/telemetry/src/react/telemetry.d.ts +1 -1
  182. package/telemetry/src/server/context.d.ts +1 -1
  183. package/telemetry/src/server/index.d.ts +1 -1
  184. package/telemetry/src/server/instrumentation.d.ts +1 -1
  185. package/telemetry/src/server/plugin.d.ts +1 -1
  186. package/telemetry/src/server/sourcemap.d.ts +1 -1
package/elysia/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * reroute-js v0.34.8
2
+ * reroute-js v0.35.0
3
3
  *
4
4
  * @license MIT
5
5
  * @copyright 2025 stewones <hi@stewan.io>
package/elysia/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * reroute-js v0.34.8
2
+ * reroute-js v0.35.0
3
3
  *
4
4
  * @license MIT
5
5
  * @copyright 2025 stewones <hi@stewan.io>
@@ -3117,9 +3117,9 @@ async function discoverCollectionRoutes(cwd, collections2, isWatchMode, llmsConf
3117
3117
  }
3118
3118
  return collectionsMap;
3119
3119
  }
3120
- async function loadRouteModule(clientDir, routePath, isWatchMode) {
3120
+ async function loadRouteModule(cwd, routePath, isWatchMode) {
3121
3121
  try {
3122
- const abs = join(clientDir, "routes", routePath);
3122
+ const abs = join(cwd, "src", "client", "routes", routePath);
3123
3123
  const modUrl = `${pathToFileURL6(abs).href}${isWatchMode ? `?t=${Date.now()}` : ""}`;
3124
3124
  return await import(modUrl);
3125
3125
  } catch {
@@ -3152,24 +3152,47 @@ function createEntriesFromArray(array, routePath) {
3152
3152
  }
3153
3153
  return entries;
3154
3154
  }
3155
- async function discoverSSRDataRoutes(_cwd, clientDir, staticRoutes, isWatchMode) {
3155
+ async function discoverSSRDataRoutes(cwd, staticRoutes, isWatchMode) {
3156
3156
  const ssrDataRoutes = new Map;
3157
- for (const route of staticRoutes) {
3158
- const mod = await loadRouteModule(clientDir, route.path, isWatchMode);
3159
- if (!mod)
3160
- continue;
3161
- const ssr = mod?.ssr;
3162
- const dataFn = ssr?.data;
3163
- if (typeof dataFn !== "function")
3164
- continue;
3165
- const result = await callDataFunction(dataFn, route.path);
3166
- const arrays = findArraysInData(result);
3167
- for (const array of arrays) {
3168
- 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")
3166
+ continue;
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)
3169
3182
  continue;
3170
- const entries = createEntriesFromArray(array, route.path);
3171
- if (entries.length > 0) {
3172
- ssrDataRoutes.set(route.path, entries);
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
+ }
3173
3196
  }
3174
3197
  }
3175
3198
  }
@@ -3292,12 +3315,12 @@ function addStaticSection(parts, section, routes, baseUrl, isSingleCollection, t
3292
3315
  parts.push("");
3293
3316
  }
3294
3317
  async function generateLLMsIndex(options) {
3295
- const { cwd, clientDir, collections: collections2, baseUrl, isWatchMode, llmsConfig } = options;
3318
+ const { cwd, collections: collections2, baseUrl, isWatchMode, llmsConfig } = options;
3296
3319
  const parts = [];
3297
3320
  addIndexHeader(parts, llmsConfig);
3298
3321
  const staticRoutes = await discoverStaticRoutes(cwd, isWatchMode);
3299
3322
  const collectionsMap = await discoverCollectionRoutes(cwd, collections2, isWatchMode, llmsConfig);
3300
- const ssrDataRoutes = await discoverSSRDataRoutes(cwd, clientDir, staticRoutes, isWatchMode);
3323
+ const ssrDataRoutes = await discoverSSRDataRoutes(cwd, staticRoutes, isWatchMode);
3301
3324
  const isSingleCollection = collections2.length === 1;
3302
3325
  const targetCollection = isSingleCollection ? collections2[0] : null;
3303
3326
  const { sections, rootRoutes } = groupStaticRoutes(staticRoutes, llmsConfig);
@@ -3346,7 +3369,7 @@ function buildHeader(baseUrl, llmsConfig) {
3346
3369
  }
3347
3370
  return parts;
3348
3371
  }
3349
- async function discoverAllRoutes(cwd, clientDir, collections2, isWatchMode, llmsConfig) {
3372
+ async function discoverAllRoutes(cwd, collections2, isWatchMode, llmsConfig) {
3350
3373
  const {
3351
3374
  discoverStaticRoutes: discoverStaticRoutes2,
3352
3375
  discoverCollectionRoutes: discoverCollectionRoutes2,
@@ -3354,7 +3377,7 @@ async function discoverAllRoutes(cwd, clientDir, collections2, isWatchMode, llms
3354
3377
  } = await Promise.resolve().then(() => (init_index_generator(), exports_index_generator));
3355
3378
  const staticRoutes = await discoverStaticRoutes2(cwd, isWatchMode);
3356
3379
  const collectionsMap = await discoverCollectionRoutes2(cwd, collections2, isWatchMode, llmsConfig);
3357
- const ssrDataRoutes = await discoverSSRDataRoutes2(cwd, clientDir, staticRoutes, isWatchMode);
3380
+ const ssrDataRoutes = await discoverSSRDataRoutes2(cwd, staticRoutes, isWatchMode);
3358
3381
  const allRoutes = [];
3359
3382
  for (const route of staticRoutes) {
3360
3383
  if (!shouldExcludeRoute(route.path, llmsConfig?.excludeRoutes)) {
@@ -3444,9 +3467,9 @@ function buildFooter(parts) {
3444
3467
  parts.push("Formats: .txt | .md | Accept: text/plain | Accept: text/markdown");
3445
3468
  }
3446
3469
  async function generateLLMsFullContent(options) {
3447
- const { cwd, clientDir, collections: collections2, baseUrl, isWatchMode, llmsConfig } = options;
3470
+ const { cwd, collections: collections2, baseUrl, isWatchMode, llmsConfig } = options;
3448
3471
  const parts = buildHeader(baseUrl, llmsConfig);
3449
- const allRoutes = await discoverAllRoutes(cwd, clientDir, collections2, isWatchMode, llmsConfig);
3472
+ const allRoutes = await discoverAllRoutes(cwd, collections2, isWatchMode, llmsConfig);
3450
3473
  const maxItems = llmsConfig?.maxItems || 1e4;
3451
3474
  const routesToProcess = allRoutes.slice(0, maxItems);
3452
3475
  const extracted = await extractRouteContents(routesToProcess, options);
@@ -3613,6 +3636,9 @@ function getRedirectSourcePaths(redirects) {
3613
3636
  }
3614
3637
  const sources = [];
3615
3638
  for (const redirect of redirects) {
3639
+ if (redirect.enabled === false) {
3640
+ continue;
3641
+ }
3616
3642
  if (typeof redirect.source === "string") {
3617
3643
  sources.push(redirect.source);
3618
3644
  }
@@ -3863,30 +3889,58 @@ async function discoverCollectionContent(cwd, collection, isWatchMode, baseUrl)
3863
3889
  }
3864
3890
  return entries;
3865
3891
  }
3866
- async function discoverSSRDataRoutes2(_cwd, clientDir, staticRoutes, isWatchMode, baseUrl, sitemapConfig) {
3892
+ async function discoverSSRDataRoutes2(cwd, staticRoutes, isWatchMode, baseUrl, sitemapConfig) {
3867
3893
  const ssrDataRoutes = new Map;
3868
- for (const route of staticRoutes) {
3869
- if (sitemapConfig?.excludeDiscovery?.includes(route.pattern)) {
3870
- continue;
3871
- }
3872
- try {
3873
- const abs = join(clientDir, "routes", route.path);
3874
- const mod = await import(Bun.pathToFileURL(abs).href + (isWatchMode ? `?t=${Date.now()}` : ""));
3875
- const ssr = mod?.ssr;
3894
+ const bundledRoutes = globalThis.__REROUTE_ROUTES__;
3895
+ if (bundledRoutes && Array.isArray(bundledRoutes)) {
3896
+ for (const route of staticRoutes) {
3897
+ if (sitemapConfig?.excludeDiscovery?.includes(route.pattern)) {
3898
+ continue;
3899
+ }
3900
+ const bundledRoute = bundledRoutes.find((r) => r?.pattern === route.pattern);
3901
+ if (!bundledRoute)
3902
+ continue;
3903
+ const ssr = bundledRoute?.ssr;
3876
3904
  const dataFn = ssr?.data;
3877
3905
  if (typeof dataFn === "function") {
3878
- const mockSet = { status: 200 };
3879
- const result = await dataFn({
3880
- pathname: route.pattern,
3881
- params: {},
3882
- set: mockSet
3883
- });
3884
- const entries = extractEntriesFromData(result, route.pattern, baseUrl, sitemapConfig);
3885
- if (entries.length > 0) {
3886
- ssrDataRoutes.set(route.pattern, entries);
3887
- }
3906
+ try {
3907
+ const mockSet = { status: 200 };
3908
+ const result = await dataFn({
3909
+ pathname: route.pattern,
3910
+ params: {},
3911
+ set: mockSet
3912
+ });
3913
+ const entries = extractEntriesFromData(result, route.pattern, baseUrl, sitemapConfig);
3914
+ if (entries.length > 0) {
3915
+ ssrDataRoutes.set(route.pattern, entries);
3916
+ }
3917
+ } catch {}
3888
3918
  }
3889
- } catch {}
3919
+ }
3920
+ } else {
3921
+ for (const route of staticRoutes) {
3922
+ if (sitemapConfig?.excludeDiscovery?.includes(route.pattern)) {
3923
+ continue;
3924
+ }
3925
+ try {
3926
+ const routeModulePath = join(cwd, "src", "client", "routes", route.path);
3927
+ const mod = await import(Bun.pathToFileURL(routeModulePath).href + (isWatchMode ? `?t=${Date.now()}` : ""));
3928
+ const ssr = mod?.ssr;
3929
+ const dataFn = ssr?.data;
3930
+ if (typeof dataFn === "function") {
3931
+ const mockSet = { status: 200 };
3932
+ const result = await dataFn({
3933
+ pathname: route.pattern,
3934
+ params: {},
3935
+ set: mockSet
3936
+ });
3937
+ const entries = extractEntriesFromData(result, route.pattern, baseUrl, sitemapConfig);
3938
+ if (entries.length > 0) {
3939
+ ssrDataRoutes.set(route.pattern, entries);
3940
+ }
3941
+ }
3942
+ } catch {}
3943
+ }
3890
3944
  }
3891
3945
  return ssrDataRoutes;
3892
3946
  }
@@ -3996,7 +4050,7 @@ function createEntryFromItem(item, routePattern, baseUrl, sitemapConfig) {
3996
4050
  }
3997
4051
  return entry;
3998
4052
  }
3999
- async function discoverSitemapData(cwd, clientDir, collections2, baseUrl, isWatchMode, sitemapConfig) {
4053
+ async function discoverSitemapData(cwd, collections2, baseUrl, isWatchMode, sitemapConfig) {
4000
4054
  const { staticRoutes, dynamicRoutes } = await discoverRoutes(cwd, isWatchMode);
4001
4055
  const collectionsMap = new Map;
4002
4056
  for (const collection of collections2) {
@@ -4005,7 +4059,7 @@ async function discoverSitemapData(cwd, clientDir, collections2, baseUrl, isWatc
4005
4059
  collectionsMap.set(collection, entries);
4006
4060
  }
4007
4061
  }
4008
- const ssrDataRoutes = await discoverSSRDataRoutes2(cwd, clientDir, staticRoutes, isWatchMode, baseUrl, sitemapConfig);
4062
+ const ssrDataRoutes = await discoverSSRDataRoutes2(cwd, staticRoutes, isWatchMode, baseUrl, sitemapConfig);
4009
4063
  return {
4010
4064
  staticRoutes,
4011
4065
  dynamicRoutes,
@@ -4120,10 +4174,10 @@ async function discoverCollectionFeedItems(cwd, collection, isWatchMode, baseUrl
4120
4174
  sortByPubDate(items);
4121
4175
  return items;
4122
4176
  }
4123
- async function discoverSSRDataFeedItems(_cwd, clientDir, routePattern, routePath, isWatchMode, baseUrl, rssConfig) {
4177
+ async function discoverSSRDataFeedItems(cwd, routePattern, routePath, isWatchMode, baseUrl, rssConfig) {
4124
4178
  const items = [];
4125
4179
  try {
4126
- const abs = join(clientDir, "routes", routePath);
4180
+ const abs = join(cwd, "src", "client", "routes", routePath);
4127
4181
  const mod = await import(pathToFileURL7(abs).href + (isWatchMode ? `?t=${Date.now()}` : ""));
4128
4182
  const ssr = mod?.ssr;
4129
4183
  const dataFn = ssr?.data;
@@ -4259,7 +4313,7 @@ function createRSSItemFromData(item, routePattern, baseUrl, rssConfig) {
4259
4313
  }
4260
4314
  return rssItem;
4261
4315
  }
4262
- async function discoverRSSData(cwd, clientDir, collections2, baseUrl, isWatchMode, rssConfig) {
4316
+ async function discoverRSSData(cwd, collections2, baseUrl, isWatchMode, rssConfig) {
4263
4317
  const collectionsMap = new Map;
4264
4318
  for (const collection of collections2) {
4265
4319
  const items = await discoverCollectionFeedItems(cwd, collection, isWatchMode, baseUrl, rssConfig);
@@ -4268,18 +4322,48 @@ async function discoverRSSData(cwd, clientDir, collections2, baseUrl, isWatchMod
4268
4322
  }
4269
4323
  }
4270
4324
  const ssrDataFeeds = new Map;
4271
- const { discoverRoutes: discoverRoutes2 } = await Promise.resolve().then(() => (init_discovery4(), exports_discovery));
4272
- const { staticRoutes } = await discoverRoutes2(cwd, isWatchMode);
4273
- for (const route of staticRoutes) {
4274
- if (rssConfig?.excludeDiscovery?.includes(route.pattern)) {
4275
- continue;
4325
+ const bundledRoutes = globalThis.__REROUTE_ROUTES__;
4326
+ if (bundledRoutes && Array.isArray(bundledRoutes)) {
4327
+ const { discoverRoutes: discoverRoutes2 } = await Promise.resolve().then(() => (init_discovery4(), exports_discovery));
4328
+ const { staticRoutes } = await discoverRoutes2(cwd, isWatchMode);
4329
+ for (const route of staticRoutes) {
4330
+ if (rssConfig?.excludeDiscovery?.includes(route.pattern)) {
4331
+ continue;
4332
+ }
4333
+ const bundledRoute = bundledRoutes.find((r) => r?.pattern === route.pattern);
4334
+ if (!bundledRoute)
4335
+ continue;
4336
+ const ssr = bundledRoute?.ssr;
4337
+ const dataFn = ssr?.data;
4338
+ if (typeof dataFn === "function") {
4339
+ try {
4340
+ const mockSet = { status: 200 };
4341
+ const result = await dataFn({
4342
+ pathname: route.pattern,
4343
+ params: {},
4344
+ set: mockSet
4345
+ });
4346
+ const items = extractRSSItemsFromData(result, route.pattern, baseUrl, rssConfig);
4347
+ if (items.length > 0) {
4348
+ ssrDataFeeds.set(route.pattern, items);
4349
+ }
4350
+ } catch {}
4351
+ }
4276
4352
  }
4277
- const items = await discoverSSRDataFeedItems(cwd, clientDir, route.pattern, route.path, isWatchMode, baseUrl, rssConfig);
4278
- if (items.length > 0) {
4279
- ssrDataFeeds.set(route.pattern, items);
4353
+ } else {
4354
+ const { discoverRoutes: discoverRoutes2 } = await Promise.resolve().then(() => (init_discovery4(), exports_discovery));
4355
+ const { staticRoutes } = await discoverRoutes2(cwd, isWatchMode);
4356
+ for (const route of staticRoutes) {
4357
+ if (rssConfig?.excludeDiscovery?.includes(route.pattern)) {
4358
+ continue;
4359
+ }
4360
+ const items = await discoverSSRDataFeedItems(cwd, route.pattern, route.path, isWatchMode, baseUrl, rssConfig);
4361
+ if (items.length > 0) {
4362
+ ssrDataFeeds.set(route.pattern, items);
4363
+ }
4280
4364
  }
4281
4365
  }
4282
- const layoutFeeds = await discoverLayoutFeedItems(cwd, clientDir, isWatchMode, baseUrl, rssConfig);
4366
+ const layoutFeeds = await discoverLayoutFeedItems(cwd, isWatchMode, baseUrl, rssConfig);
4283
4367
  for (const [pattern, items] of layoutFeeds.entries()) {
4284
4368
  const existing = ssrDataFeeds.get(pattern) || [];
4285
4369
  ssrDataFeeds.set(pattern, [...existing, ...items]);
@@ -4303,13 +4387,13 @@ async function loadLayouts(cwd, isWatchMode) {
4303
4387
  return;
4304
4388
  }
4305
4389
  }
4306
- async function processLayoutForRSS(layout, clientDir, isWatchMode, baseUrl, rssConfig) {
4390
+ async function processLayoutForRSS(layout, cwd, isWatchMode, baseUrl, rssConfig) {
4307
4391
  const pattern = String(layout?.pattern || "/");
4308
4392
  const path2 = String(layout?.path || "");
4309
4393
  if (!path2)
4310
4394
  return null;
4311
4395
  try {
4312
- const abs = join(clientDir, "routes", path2);
4396
+ const abs = join(cwd, "src", "client", "routes", path2);
4313
4397
  const layoutMod = await import(pathToFileURL7(abs).href + (isWatchMode ? `?t=${Date.now()}` : ""));
4314
4398
  const ssr = layoutMod?.ssr;
4315
4399
  const dataFn = ssr?.data;
@@ -4328,16 +4412,39 @@ async function processLayoutForRSS(layout, clientDir, isWatchMode, baseUrl, rssC
4328
4412
  } catch {}
4329
4413
  return null;
4330
4414
  }
4331
- async function discoverLayoutFeedItems(cwd, clientDir, isWatchMode, baseUrl, rssConfig) {
4415
+ async function discoverLayoutFeedItems(cwd, isWatchMode, baseUrl, rssConfig) {
4332
4416
  const layoutFeeds = new Map;
4333
4417
  const layouts2 = await loadLayouts(cwd, isWatchMode);
4334
4418
  if (!Array.isArray(layouts2)) {
4335
4419
  return layoutFeeds;
4336
4420
  }
4337
- for (const layout of layouts2) {
4338
- const result = await processLayoutForRSS(layout, clientDir, isWatchMode, baseUrl, rssConfig);
4339
- if (result) {
4340
- layoutFeeds.set(result.pattern, result.items);
4421
+ const bundledLayouts = globalThis.__REROUTE_LAYOUTS__;
4422
+ if (bundledLayouts && Array.isArray(bundledLayouts)) {
4423
+ for (const layout of bundledLayouts) {
4424
+ const pattern = String(layout?.pattern || "/");
4425
+ const ssr = layout?.ssr;
4426
+ const dataFn = ssr?.data;
4427
+ if (typeof dataFn === "function") {
4428
+ try {
4429
+ const mockSet = { status: 200 };
4430
+ const result = await dataFn({
4431
+ pathname: pattern,
4432
+ params: {},
4433
+ set: mockSet
4434
+ });
4435
+ const items = extractRSSItemsFromData(result, pattern, baseUrl, rssConfig);
4436
+ if (items.length > 0) {
4437
+ layoutFeeds.set(pattern, items);
4438
+ }
4439
+ } catch {}
4440
+ }
4441
+ }
4442
+ } else {
4443
+ for (const layout of layouts2) {
4444
+ const result = await processLayoutForRSS(layout, cwd, isWatchMode, baseUrl, rssConfig);
4445
+ if (result) {
4446
+ layoutFeeds.set(result.pattern, result.items);
4447
+ }
4341
4448
  }
4342
4449
  }
4343
4450
  return layoutFeeds;
@@ -6108,7 +6215,6 @@ function registerLLMsRoutes(app, options) {
6108
6215
  }
6109
6216
  const content2 = await generateLLMsIndex({
6110
6217
  cwd,
6111
- clientDir,
6112
6218
  collections: collections2,
6113
6219
  baseUrl,
6114
6220
  isWatchMode,
@@ -6175,7 +6281,6 @@ function registerLLMsRoutes(app, options) {
6175
6281
  }
6176
6282
  const content2 = await generateLLMsIndex({
6177
6283
  cwd,
6178
- clientDir,
6179
6284
  collections: [collection],
6180
6285
  baseUrl,
6181
6286
  isWatchMode,
@@ -6655,7 +6760,11 @@ function registerRedirectRoutes(app, rules) {
6655
6760
  if (!rules || rules.length === 0) {
6656
6761
  return app;
6657
6762
  }
6658
- const compiled = compileRedirects(rules);
6763
+ const enabledRules = rules.filter((rule) => rule.enabled !== false);
6764
+ if (enabledRules.length === 0) {
6765
+ return app;
6766
+ }
6767
+ const compiled = compileRedirects(enabledRules);
6659
6768
  console.log(`[reroute] Registered ${compiled.length} redirect rule${compiled.length === 1 ? "" : "s"}`);
6660
6769
  async function processRedirectDestination(match, url) {
6661
6770
  if (typeof match.destination === "function") {
@@ -6749,7 +6858,7 @@ function createFeedTitle(configTitle, name) {
6749
6858
  async function discoverSSRRoutes(cwd, isWatchMode) {
6750
6859
  try {
6751
6860
  const { discoverSitemapData: discoverSitemapData2 } = await Promise.resolve().then(() => (init_core(), exports_core));
6752
- const sitemapData = await discoverSitemapData2(cwd, "", [], "", isWatchMode);
6861
+ const sitemapData = await discoverSitemapData2(cwd, [], "", isWatchMode);
6753
6862
  const staticRoutes = sitemapData.staticRoutes.filter((r) => !r.pattern.includes(":")).map((r) => ({ pattern: r.pattern, path: r.path }));
6754
6863
  const routesPath = join(cwd, ".reroute", "routes.ts");
6755
6864
  const routesMod = await import(`${Bun.pathToFileURL(routesPath).href}${isWatchMode ? `?t=${Date.now()}` : ""}`);
@@ -6766,14 +6875,14 @@ async function discoverSSRRoutes(cwd, isWatchMode) {
6766
6875
  return [];
6767
6876
  }
6768
6877
  }
6769
- async function registerMainFeedRoute(app, cwd, clientDir, collections2, baseUrl, isWatchMode, rssCache, format, limit, maxAge, ttlMs, feedTitle, feedDescription, rssConfig) {
6878
+ async function registerMainFeedRoute(app, cwd, collections2, baseUrl, isWatchMode, rssCache, format, limit, maxAge, ttlMs, feedTitle, feedDescription, rssConfig) {
6770
6879
  app.get("/feed.xml", async () => {
6771
6880
  try {
6772
6881
  const cached = getIfValid(rssCache, "rss:main");
6773
6882
  if (cached) {
6774
6883
  return feedResponse(cached.xml, format, { maxAge, cacheStatus: "HIT" });
6775
6884
  }
6776
- const discovery5 = await discoverRSSData(cwd, clientDir, collections2, baseUrl, isWatchMode, rssConfig);
6885
+ const discovery5 = await discoverRSSData(cwd, collections2, baseUrl, isWatchMode, rssConfig);
6777
6886
  const allItems = [
6778
6887
  ...Array.from(discovery5.collections.values()).flat(),
6779
6888
  ...Array.from(discovery5.ssrDataFeeds.values()).flat()
@@ -6812,7 +6921,7 @@ function registerCollectionFeedRoutes(app, collections2, options) {
6812
6921
  cacheStatus: "HIT"
6813
6922
  });
6814
6923
  }
6815
- const discovery5 = await discoverRSSData(options.cwd, options.clientDir, [collection], options.baseUrl, options.isWatchMode, options.rssConfig);
6924
+ const discovery5 = await discoverRSSData(options.cwd, [collection], options.baseUrl, options.isWatchMode, options.rssConfig);
6816
6925
  const items = discovery5.collections.get(collection) ?? [];
6817
6926
  if (items.length === 0)
6818
6927
  throw new NotFoundError9;
@@ -6852,7 +6961,7 @@ async function discoverRoutesWithFeeds(ssrDataRoutes, collections2, options) {
6852
6961
  if (options.rssConfig?.excludeRoutes?.includes(route.pattern))
6853
6962
  continue;
6854
6963
  try {
6855
- const items = await discoverSSRDataFeedItems(options.cwd, options.clientDir, route.pattern, route.path, options.isWatchMode, options.baseUrl, options.rssConfig);
6964
+ const items = await discoverSSRDataFeedItems(options.cwd, route.pattern, route.path, options.isWatchMode, options.baseUrl, options.rssConfig);
6856
6965
  if (items.length > 0) {
6857
6966
  routesWithFeeds.push(route);
6858
6967
  options.availableFeeds.push(`${route.pattern}/feed.xml`);
@@ -6871,9 +6980,9 @@ async function generateSSRDataFeed(route, options) {
6871
6980
  cacheStatus: "HIT"
6872
6981
  });
6873
6982
  }
6874
- let items = await discoverSSRDataFeedItems(options.cwd, options.clientDir, route.pattern, route.path, options.isWatchMode, options.baseUrl, options.rssConfig);
6983
+ let items = await discoverSSRDataFeedItems(options.cwd, route.pattern, route.path, options.isWatchMode, options.baseUrl, options.rssConfig);
6875
6984
  if (items.length === 0 && route.isLayout) {
6876
- const discovery5 = await discoverRSSData(options.cwd, options.clientDir, [], options.baseUrl, options.isWatchMode, options.rssConfig);
6985
+ const discovery5 = await discoverRSSData(options.cwd, [], options.baseUrl, options.isWatchMode, options.rssConfig);
6877
6986
  items = discovery5.ssrDataFeeds.get(route.pattern) ?? [];
6878
6987
  }
6879
6988
  if (items.length === 0)
@@ -6929,7 +7038,7 @@ async function registerRSSRoutes(app, options) {
6929
7038
  const feedTitle = rssConfig?.title ?? "Feed";
6930
7039
  const feedDescription = rssConfig?.description ?? "Latest updates";
6931
7040
  const availableFeeds = ["/feed.xml"];
6932
- registerMainFeedRoute(app, cwd, clientDir, collections2, baseUrl, isWatchMode, rssCache, format, limit, maxAge, ttlMs, feedTitle, feedDescription, rssConfig);
7041
+ registerMainFeedRoute(app, cwd, collections2, baseUrl, isWatchMode, rssCache, format, limit, maxAge, ttlMs, feedTitle, feedDescription, rssConfig);
6933
7042
  const ssrDataRoutes = await discoverSSRRoutes(cwd, isWatchMode);
6934
7043
  registerCollectionFeedRoutes(app, collections2, {
6935
7044
  cwd,
@@ -6954,7 +7063,6 @@ async function registerRSSRoutes(app, options) {
6954
7063
  });
6955
7064
  registerSSRDataFeedRoutes(app, routesWithFeeds, {
6956
7065
  cwd,
6957
- clientDir,
6958
7066
  baseUrl,
6959
7067
  isWatchMode,
6960
7068
  rssCache,
@@ -7096,8 +7204,8 @@ function registerSearchRoute(app, cwd, directive, maxAge, searchConfig) {
7096
7204
  init_core();
7097
7205
  import { NotFoundError as NotFoundError10 } from "elysia";
7098
7206
  async function generateAndCacheSitemap(options, _ttlMs) {
7099
- const { cwd, clientDir, collections: collections2, baseUrl, isWatchMode, sitemapConfig } = options;
7100
- const discovery5 = await discoverSitemapData(cwd, clientDir, collections2, baseUrl, isWatchMode, sitemapConfig);
7207
+ const { cwd, collections: collections2, baseUrl, isWatchMode, sitemapConfig } = options;
7208
+ const discovery5 = await discoverSitemapData(cwd, collections2, baseUrl, isWatchMode, sitemapConfig);
7101
7209
  const result = await generateSitemap(discovery5, baseUrl, {
7102
7210
  changefreq: sitemapConfig?.changefreq,
7103
7211
  priority: sitemapConfig?.priority,
@@ -7987,7 +8095,6 @@ var reroute = () => async (app) => {
7987
8095
  try {
7988
8096
  registerSitemapRoutes(app, {
7989
8097
  cwd,
7990
- clientDir,
7991
8098
  collections: collections2,
7992
8099
  baseUrl: sitemapBaseUrl,
7993
8100
  maxAge,
@@ -8051,4 +8158,4 @@ export {
8051
8158
  reroute
8052
8159
  };
8053
8160
 
8054
- //# debugId=794C5B3C9776FAC764756E2164756E21
8161
+ //# debugId=877E08DDB6C5228B64756E2164756E21