reroute-js 0.41.0 → 0.41.1
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.
- package/cli/bin.d.ts +1 -1
- package/cli/bin.js +111 -48
- package/cli/bin.js.map +5 -5
- package/cli/index.d.ts +1 -1
- package/cli/index.js +4 -4
- package/cli/index.js.map +1 -1
- package/cli/src/cli.d.ts +1 -1
- package/cli/src/commands/analyze.d.ts +1 -1
- package/cli/src/commands/build.d.ts +1 -1
- package/cli/src/commands/dev.d.ts +1 -1
- package/cli/src/commands/gen.d.ts +1 -1
- package/cli/src/commands/gen.d.ts.map +1 -1
- package/cli/src/commands/index.d.ts +1 -1
- package/cli/src/commands/init.d.ts +1 -1
- package/cli/src/commands/lib/assets.d.ts +1 -1
- package/cli/src/commands/lib/bundler.d.ts +1 -1
- package/cli/src/commands/lib/command.d.ts +1 -1
- package/cli/src/commands/lib/env.d.ts +1 -1
- package/cli/src/commands/lib/index.d.ts +1 -1
- package/cli/src/commands/lib/log.d.ts +1 -1
- package/cli/src/commands/lib/markdown/availability.d.ts +1 -1
- package/cli/src/commands/lib/markdown/index.d.ts +1 -1
- package/cli/src/commands/lib/markdown/processor.d.ts +1 -1
- package/cli/src/commands/lib/production.d.ts +1 -1
- package/cli/src/commands/lib/server.d.ts +1 -1
- package/cli/src/commands/lib/streaming/analyzer.d.ts +1 -1
- package/cli/src/commands/lib/streaming/suspense.d.ts +1 -1
- package/cli/src/commands/lib/tailwind.d.ts +1 -1
- package/cli/src/commands/lib/terminal-ui.d.ts +1 -1
- package/cli/src/commands/lib/version.d.ts +1 -1
- package/cli/src/commands/og.d.ts +1 -1
- package/cli/src/commands/start.d.ts +1 -1
- package/cli/src/index.d.ts +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.js +53 -23
- package/core/index.js.map +4 -4
- package/core/src/bundler/hash.d.ts +1 -1
- package/core/src/bundler/index.d.ts +1 -1
- package/core/src/config.d.ts +1 -1
- package/core/src/content/discovery.d.ts +1 -1
- package/core/src/content/index.d.ts +1 -1
- package/core/src/content/metadata.d.ts +1 -1
- package/core/src/index.d.ts +1 -1
- package/core/src/llms/extractor.d.ts +1 -1
- package/core/src/llms/formatter.d.ts +1 -1
- package/core/src/llms/full-generator.d.ts +1 -1
- package/core/src/llms/index-generator.d.ts +1 -1
- package/core/src/llms/index.d.ts +1 -1
- package/core/src/og/discovery.d.ts +1 -1
- package/core/src/og/index.d.ts +1 -1
- package/core/src/og/meta.d.ts +1 -1
- package/core/src/og/render.d.ts +1 -1
- package/core/src/og/types.d.ts +1 -1
- package/core/src/robots/discovery.d.ts +1 -1
- package/core/src/robots/generator.d.ts +1 -1
- package/core/src/robots/index.d.ts +1 -1
- package/core/src/robots/policies.d.ts +1 -1
- package/core/src/rss/discovery.d.ts +1 -1
- package/core/src/rss/discovery.d.ts.map +1 -1
- package/core/src/rss/generator.d.ts +1 -1
- package/core/src/rss/index.d.ts +1 -1
- package/core/src/sitemap/discovery.d.ts +1 -1
- package/core/src/sitemap/discovery.d.ts.map +1 -1
- package/core/src/sitemap/generator.d.ts +1 -1
- package/core/src/sitemap/index.d.ts +1 -1
- package/core/src/ssr/index.d.ts +1 -1
- package/core/src/ssr/lib/cache.d.ts +1 -1
- package/core/src/ssr/lib/collections.d.ts +1 -1
- package/core/src/ssr/lib/compression.d.ts +1 -1
- package/core/src/ssr/lib/compute/content.d.ts +1 -1
- package/core/src/ssr/lib/compute/index.d.ts +1 -1
- package/core/src/ssr/lib/compute/layouts.d.ts +1 -1
- package/core/src/ssr/lib/compute/routes.d.ts +1 -1
- package/core/src/ssr/lib/data.d.ts +1 -1
- package/core/src/ssr/lib/html.d.ts +1 -1
- package/core/src/ssr/lib/imports.d.ts +1 -1
- package/core/src/ssr/lib/index.d.ts +1 -1
- package/core/src/ssr/lib/layouts.d.ts +1 -1
- package/core/src/ssr/lib/metadata.d.ts +1 -1
- package/core/src/ssr/lib/mime.d.ts +1 -1
- package/core/src/ssr/lib/modules.d.ts +1 -1
- package/core/src/ssr/lib/path.d.ts +1 -1
- package/core/src/ssr/lib/preload.d.ts +1 -1
- package/core/src/ssr/lib/scripts/collections.d.ts +1 -1
- package/core/src/ssr/lib/scripts/data.d.ts +1 -1
- package/core/src/ssr/lib/scripts/escape.d.ts +1 -1
- package/core/src/ssr/lib/scripts/feeds.d.ts +1 -1
- package/core/src/ssr/lib/scripts/index.d.ts +1 -1
- package/core/src/ssr/lib/seed.d.ts +1 -1
- package/core/src/ssr/lib/serialize.d.ts +1 -1
- package/core/src/ssr/lib/setup.d.ts +1 -1
- package/core/src/ssr/lib/styles.d.ts +1 -1
- package/core/src/ssr/lib/template.d.ts +1 -1
- package/core/src/ssr/lib/types.d.ts +1 -1
- package/core/src/ssr/render.d.ts +1 -1
- package/core/src/ssr/stream.d.ts +1 -1
- package/elysia/index.d.ts +1 -1
- package/elysia/index.js +228 -104
- package/elysia/index.js.map +9 -9
- package/elysia/src/index.d.ts +1 -1
- package/elysia/src/libs/assets.d.ts +1 -1
- package/elysia/src/libs/cache.d.ts +1 -1
- package/elysia/src/libs/caching.d.ts +1 -1
- package/elysia/src/libs/http.d.ts +1 -1
- package/elysia/src/libs/image.d.ts +1 -1
- package/elysia/src/libs/index.d.ts +1 -1
- package/elysia/src/libs/llms.d.ts +1 -1
- package/elysia/src/libs/response.d.ts +1 -1
- package/elysia/src/libs/serving.d.ts +1 -1
- package/elysia/src/plugin.d.ts +1 -1
- package/elysia/src/plugin.d.ts.map +1 -1
- package/elysia/src/routes/artifacts.d.ts +1 -1
- package/elysia/src/routes/content.d.ts +1 -1
- package/elysia/src/routes/image.d.ts +1 -1
- package/elysia/src/routes/index.d.ts +1 -1
- package/elysia/src/routes/internal.d.ts +1 -1
- package/elysia/src/routes/internal.d.ts.map +1 -1
- package/elysia/src/routes/llms.d.ts +1 -1
- package/elysia/src/routes/og.d.ts +1 -1
- package/elysia/src/routes/og.d.ts.map +1 -1
- package/elysia/src/routes/redirects.d.ts +1 -1
- package/elysia/src/routes/robots.d.ts +1 -1
- package/elysia/src/routes/rss.d.ts +2 -2
- package/elysia/src/routes/rss.d.ts.map +1 -1
- package/elysia/src/routes/search.d.ts +1 -1
- package/elysia/src/routes/sitemap.d.ts +2 -2
- package/elysia/src/routes/sitemap.d.ts.map +1 -1
- package/elysia/src/routes/ssr.d.ts +1 -1
- package/elysia/src/routes/static.d.ts +1 -1
- package/elysia/src/types.d.ts +1 -1
- package/package.json +1 -1
- package/react/index.d.ts +1 -1
- package/react/index.js +2 -2
- package/react/index.js.map +1 -1
- package/react/src/components/ClientOnly.d.ts +1 -1
- package/react/src/components/ContentRoute.d.ts +1 -1
- package/react/src/components/Image.d.ts +1 -1
- package/react/src/components/LazyRoute.d.ts +1 -1
- package/react/src/components/Link.d.ts +1 -1
- package/react/src/components/Markdown.d.ts +1 -1
- package/react/src/components/Outlet.d.ts +1 -1
- package/react/src/components/index.d.ts +1 -1
- package/react/src/hooks/index.d.ts +1 -1
- package/react/src/hooks/useContent.d.ts +1 -1
- package/react/src/hooks/useData.d.ts +1 -1
- package/react/src/hooks/useFeed.d.ts +1 -1
- package/react/src/hooks/useLayoutData.d.ts +1 -1
- package/react/src/hooks/useLlms.d.ts +1 -1
- package/react/src/hooks/useNavigate.d.ts +1 -1
- package/react/src/hooks/useParams.d.ts +1 -1
- package/react/src/hooks/useRouter.d.ts +1 -1
- package/react/src/hooks/useSearch.d.ts +1 -1
- package/react/src/hooks/useSearchParams.d.ts +1 -1
- package/react/src/hooks/useToc.d.ts +1 -1
- package/react/src/index.d.ts +1 -1
- package/react/src/lib/collection.d.ts +1 -1
- package/react/src/lib/content.d.ts +1 -1
- package/react/src/lib/head.d.ts +1 -1
- package/react/src/lib/index.d.ts +1 -1
- package/react/src/lib/lazy-route.d.ts +1 -1
- package/react/src/lib/route-loader.d.ts +1 -1
- package/react/src/providers/ContentProvider.d.ts +1 -1
- package/react/src/providers/RerouteProvider.d.ts +1 -1
- package/react/src/providers/RouterProvider.d.ts +1 -1
- package/react/src/providers/index.d.ts +1 -1
- package/react/src/types/any.d.ts +1 -1
- package/react/src/types/index.d.ts +1 -1
- package/react/src/types/router.d.ts +1 -1
- package/telemetry/react.d.ts +1 -1
- package/telemetry/react.js +2 -2
- package/telemetry/react.js.map +1 -1
- package/telemetry/server.d.ts +1 -1
- package/telemetry/server.js +2 -2
- package/telemetry/server.js.map +1 -1
- package/telemetry/src/react/api.d.ts +1 -1
- package/telemetry/src/react/context.d.ts +1 -1
- package/telemetry/src/react/index.d.ts +1 -1
- package/telemetry/src/react/telemetry.d.ts +1 -1
- package/telemetry/src/server/context.d.ts +1 -1
- package/telemetry/src/server/headers/extractor.d.ts +1 -1
- package/telemetry/src/server/headers/index.d.ts +1 -1
- package/telemetry/src/server/headers/presets.d.ts +1 -1
- package/telemetry/src/server/index.d.ts +1 -1
- package/telemetry/src/server/instrumentation.d.ts +1 -1
- package/telemetry/src/server/plugin.d.ts +1 -1
- package/telemetry/src/server/sourcemap.d.ts +1 -1
package/elysia/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* reroute-js v0.41.
|
|
2
|
+
* reroute-js v0.41.1
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2026 stewones <hi@stewan.io>
|
|
@@ -4061,13 +4061,13 @@ async function discoverSSRDataRoutes2(cwd, staticRoutes, isWatchMode, baseUrl, s
|
|
|
4061
4061
|
const ssrDataRoutes = new Map;
|
|
4062
4062
|
const bundledRoutes = globalThis.__REROUTE_ROUTES__;
|
|
4063
4063
|
if (bundledRoutes && Array.isArray(bundledRoutes)) {
|
|
4064
|
-
|
|
4064
|
+
const routePromises = staticRoutes.map(async (route) => {
|
|
4065
4065
|
if (sitemapConfig?.excludeDiscovery?.some((excluded) => route.pattern.startsWith(excluded))) {
|
|
4066
|
-
|
|
4066
|
+
return null;
|
|
4067
4067
|
}
|
|
4068
4068
|
const bundledRoute = bundledRoutes.find((r) => r?.pattern === route.pattern);
|
|
4069
4069
|
if (!bundledRoute)
|
|
4070
|
-
|
|
4070
|
+
return null;
|
|
4071
4071
|
const ssr = bundledRoute?.ssr;
|
|
4072
4072
|
const dataFn = ssr?.data;
|
|
4073
4073
|
if (typeof dataFn === "function") {
|
|
@@ -4080,15 +4080,22 @@ async function discoverSSRDataRoutes2(cwd, staticRoutes, isWatchMode, baseUrl, s
|
|
|
4080
4080
|
});
|
|
4081
4081
|
const entries = extractEntriesFromData(result, route.pattern, baseUrl, sitemapConfig);
|
|
4082
4082
|
if (entries.length > 0) {
|
|
4083
|
-
|
|
4083
|
+
return { pattern: route.pattern, entries };
|
|
4084
4084
|
}
|
|
4085
4085
|
} catch {}
|
|
4086
4086
|
}
|
|
4087
|
+
return null;
|
|
4088
|
+
});
|
|
4089
|
+
const results = await Promise.all(routePromises);
|
|
4090
|
+
for (const result of results) {
|
|
4091
|
+
if (result) {
|
|
4092
|
+
ssrDataRoutes.set(result.pattern, result.entries);
|
|
4093
|
+
}
|
|
4087
4094
|
}
|
|
4088
4095
|
} else {
|
|
4089
|
-
|
|
4096
|
+
const routePromises = staticRoutes.map(async (route) => {
|
|
4090
4097
|
if (sitemapConfig?.excludeDiscovery?.some((excluded) => route.pattern.startsWith(excluded))) {
|
|
4091
|
-
|
|
4098
|
+
return null;
|
|
4092
4099
|
}
|
|
4093
4100
|
try {
|
|
4094
4101
|
const routeModulePath = join(cwd, "src", "client", "routes", route.path);
|
|
@@ -4104,10 +4111,17 @@ async function discoverSSRDataRoutes2(cwd, staticRoutes, isWatchMode, baseUrl, s
|
|
|
4104
4111
|
});
|
|
4105
4112
|
const entries = extractEntriesFromData(result, route.pattern, baseUrl, sitemapConfig);
|
|
4106
4113
|
if (entries.length > 0) {
|
|
4107
|
-
|
|
4114
|
+
return { pattern: route.pattern, entries };
|
|
4108
4115
|
}
|
|
4109
4116
|
}
|
|
4110
4117
|
} catch {}
|
|
4118
|
+
return null;
|
|
4119
|
+
});
|
|
4120
|
+
const results = await Promise.all(routePromises);
|
|
4121
|
+
for (const result of results) {
|
|
4122
|
+
if (result) {
|
|
4123
|
+
ssrDataRoutes.set(result.pattern, result.entries);
|
|
4124
|
+
}
|
|
4111
4125
|
}
|
|
4112
4126
|
}
|
|
4113
4127
|
return ssrDataRoutes;
|
|
@@ -4483,24 +4497,28 @@ function createRSSItemFromData(item, routePattern, baseUrl, rssConfig) {
|
|
|
4483
4497
|
}
|
|
4484
4498
|
async function discoverRSSData(cwd, collections2, baseUrl, isWatchMode, rssConfig) {
|
|
4485
4499
|
const collectionsMap = new Map;
|
|
4486
|
-
|
|
4500
|
+
const collectionPromises = collections2.map(async (collection) => {
|
|
4487
4501
|
const items = await discoverCollectionFeedItems(cwd, collection, isWatchMode, baseUrl, rssConfig);
|
|
4488
|
-
|
|
4489
|
-
|
|
4502
|
+
return items.length > 0 ? { collection, items } : null;
|
|
4503
|
+
});
|
|
4504
|
+
const collectionResults = await Promise.all(collectionPromises);
|
|
4505
|
+
for (const result of collectionResults) {
|
|
4506
|
+
if (result) {
|
|
4507
|
+
collectionsMap.set(result.collection, result.items);
|
|
4490
4508
|
}
|
|
4491
4509
|
}
|
|
4492
4510
|
const ssrDataFeeds = new Map;
|
|
4493
4511
|
const bundledRoutes = globalThis.__REROUTE_ROUTES__;
|
|
4512
|
+
const { discoverRoutes: discoverRoutes2 } = await Promise.resolve().then(() => (init_discovery4(), exports_discovery));
|
|
4513
|
+
const { staticRoutes } = await discoverRoutes2(cwd, isWatchMode);
|
|
4494
4514
|
if (bundledRoutes && Array.isArray(bundledRoutes)) {
|
|
4495
|
-
const
|
|
4496
|
-
const { staticRoutes } = await discoverRoutes2(cwd, isWatchMode);
|
|
4497
|
-
for (const route of staticRoutes) {
|
|
4515
|
+
const routePromises = staticRoutes.map(async (route) => {
|
|
4498
4516
|
if (rssConfig?.excludeDiscovery?.some((excluded) => route.pattern.startsWith(excluded))) {
|
|
4499
|
-
|
|
4517
|
+
return null;
|
|
4500
4518
|
}
|
|
4501
4519
|
const bundledRoute = bundledRoutes.find((r) => r?.pattern === route.pattern);
|
|
4502
4520
|
if (!bundledRoute)
|
|
4503
|
-
|
|
4521
|
+
return null;
|
|
4504
4522
|
const ssr = bundledRoute?.ssr;
|
|
4505
4523
|
const dataFn = ssr?.data;
|
|
4506
4524
|
if (typeof dataFn === "function") {
|
|
@@ -4513,21 +4531,33 @@ async function discoverRSSData(cwd, collections2, baseUrl, isWatchMode, rssConfi
|
|
|
4513
4531
|
});
|
|
4514
4532
|
const items = extractRSSItemsFromData(result, route.pattern, baseUrl, rssConfig);
|
|
4515
4533
|
if (items.length > 0) {
|
|
4516
|
-
|
|
4534
|
+
return { pattern: route.pattern, items };
|
|
4517
4535
|
}
|
|
4518
4536
|
} catch {}
|
|
4519
4537
|
}
|
|
4538
|
+
return null;
|
|
4539
|
+
});
|
|
4540
|
+
const results = await Promise.all(routePromises);
|
|
4541
|
+
for (const result of results) {
|
|
4542
|
+
if (result) {
|
|
4543
|
+
ssrDataFeeds.set(result.pattern, result.items);
|
|
4544
|
+
}
|
|
4520
4545
|
}
|
|
4521
4546
|
} else {
|
|
4522
|
-
const
|
|
4523
|
-
const { staticRoutes } = await discoverRoutes2(cwd, isWatchMode);
|
|
4524
|
-
for (const route of staticRoutes) {
|
|
4547
|
+
const routePromises = staticRoutes.map(async (route) => {
|
|
4525
4548
|
if (rssConfig?.excludeDiscovery?.some((excluded) => route.pattern.startsWith(excluded))) {
|
|
4526
|
-
|
|
4549
|
+
return null;
|
|
4527
4550
|
}
|
|
4528
4551
|
const items = await discoverSSRDataFeedItems(cwd, route.pattern, route.path, isWatchMode, baseUrl, rssConfig);
|
|
4529
4552
|
if (items.length > 0) {
|
|
4530
|
-
|
|
4553
|
+
return { pattern: route.pattern, items };
|
|
4554
|
+
}
|
|
4555
|
+
return null;
|
|
4556
|
+
});
|
|
4557
|
+
const results = await Promise.all(routePromises);
|
|
4558
|
+
for (const result of results) {
|
|
4559
|
+
if (result) {
|
|
4560
|
+
ssrDataFeeds.set(result.pattern, result.items);
|
|
4531
4561
|
}
|
|
4532
4562
|
}
|
|
4533
4563
|
}
|
|
@@ -6042,6 +6072,8 @@ let hasConnected = false;
|
|
|
6042
6072
|
let wasDisconnected = false;
|
|
6043
6073
|
let reloadTriggered = false;
|
|
6044
6074
|
let rebuildNotice = null;
|
|
6075
|
+
let reconnectAttempts = 0;
|
|
6076
|
+
let isReconnecting = false;
|
|
6045
6077
|
|
|
6046
6078
|
function showRebuildNotice() {
|
|
6047
6079
|
if (rebuildNotice) return;
|
|
@@ -6119,6 +6151,43 @@ function hideRebuildNotice() {
|
|
|
6119
6151
|
}
|
|
6120
6152
|
}
|
|
6121
6153
|
|
|
6154
|
+
// Check if server is ready before attempting SSE connection
|
|
6155
|
+
async function waitForServer() {
|
|
6156
|
+
const maxAttempts = 60; // 30 seconds max
|
|
6157
|
+
for (let i = 0; i < maxAttempts; i++) {
|
|
6158
|
+
try {
|
|
6159
|
+
const res = await fetch('/__reroute_watch.js', { method: 'HEAD' });
|
|
6160
|
+
if (res.ok) return true;
|
|
6161
|
+
} catch {
|
|
6162
|
+
// Server not ready, continue waiting
|
|
6163
|
+
}
|
|
6164
|
+
await new Promise(r => setTimeout(r, 500));
|
|
6165
|
+
}
|
|
6166
|
+
return false;
|
|
6167
|
+
}
|
|
6168
|
+
|
|
6169
|
+
async function scheduleReconnect() {
|
|
6170
|
+
if (reloadTriggered || isReconnecting) return;
|
|
6171
|
+
isReconnecting = true;
|
|
6172
|
+
|
|
6173
|
+
// Exponential backoff: 300ms, 600ms, 1200ms, max 2000ms
|
|
6174
|
+
const delay = Math.min(300 * Math.pow(2, reconnectAttempts), 2000);
|
|
6175
|
+
reconnectAttempts++;
|
|
6176
|
+
|
|
6177
|
+
await new Promise(r => setTimeout(r, delay));
|
|
6178
|
+
|
|
6179
|
+
// Wait for server to be ready before creating EventSource
|
|
6180
|
+
const ready = await waitForServer();
|
|
6181
|
+
isReconnecting = false;
|
|
6182
|
+
|
|
6183
|
+
if (ready && !reloadTriggered) {
|
|
6184
|
+
connect();
|
|
6185
|
+
} else if (!reloadTriggered) {
|
|
6186
|
+
// Server still not ready, try again
|
|
6187
|
+
scheduleReconnect();
|
|
6188
|
+
}
|
|
6189
|
+
}
|
|
6190
|
+
|
|
6122
6191
|
function connect() {
|
|
6123
6192
|
if (reloadTriggered) return;
|
|
6124
6193
|
|
|
@@ -6126,6 +6195,7 @@ function connect() {
|
|
|
6126
6195
|
|
|
6127
6196
|
eventSource.addEventListener('message', (e) => {
|
|
6128
6197
|
if (e.data === 'connected') {
|
|
6198
|
+
reconnectAttempts = 0; // Reset backoff on successful connection
|
|
6129
6199
|
if (hasConnected && wasDisconnected && !reloadTriggered) {
|
|
6130
6200
|
console.log('[reroute] ✓ Server restarted, reloading...');
|
|
6131
6201
|
reloadTriggered = true;
|
|
@@ -6149,11 +6219,12 @@ function connect() {
|
|
|
6149
6219
|
if (reloadTriggered) return;
|
|
6150
6220
|
wasDisconnected = true;
|
|
6151
6221
|
eventSource?.close();
|
|
6152
|
-
if (hasConnected) {
|
|
6222
|
+
if (hasConnected && reconnectAttempts === 0) {
|
|
6223
|
+
// Only log on first disconnect to reduce console spam
|
|
6153
6224
|
console.log('[reroute] \uD83D\uDD04 Server restarting...');
|
|
6154
6225
|
showRebuildNotice();
|
|
6155
6226
|
}
|
|
6156
|
-
|
|
6227
|
+
scheduleReconnect();
|
|
6157
6228
|
});
|
|
6158
6229
|
}
|
|
6159
6230
|
|
|
@@ -6776,6 +6847,7 @@ function registerOGRoutes(app, options) {
|
|
|
6776
6847
|
const width = ogConfig.width ?? 1200;
|
|
6777
6848
|
const height = ogConfig.height ?? 630;
|
|
6778
6849
|
const maxAge = ogConfig.maxAge ?? 3600;
|
|
6850
|
+
const generatingImages = new Set;
|
|
6779
6851
|
function normalizeOgPathname(urlPathname) {
|
|
6780
6852
|
let pathname = urlPathname.replace(/^\/__reroute_og/, "").replace(/\.png$/, "");
|
|
6781
6853
|
if (pathname === "/index" || pathname === "index") {
|
|
@@ -6797,7 +6869,7 @@ function registerOGRoutes(app, options) {
|
|
|
6797
6869
|
}
|
|
6798
6870
|
return;
|
|
6799
6871
|
}
|
|
6800
|
-
async function generateOgImage(pathname, clientDir2, cwd2, isWatchMode2, ogConfig2, width2, height2
|
|
6872
|
+
async function generateOgImage(pathname, clientDir2, cwd2, isWatchMode2, ogConfig2, width2, height2) {
|
|
6801
6873
|
const ogPath = await findOGImageForPath(pathname, clientDir2);
|
|
6802
6874
|
const Component = await loadOgComponent(ogPath, ogConfig2, cwd2, isWatchMode2);
|
|
6803
6875
|
if (!Component) {
|
|
@@ -6867,10 +6939,6 @@ function registerOGRoutes(app, options) {
|
|
|
6867
6939
|
if (maxAge > 0) {
|
|
6868
6940
|
ogCache.set(pathname, { buffer, exp: Date.now() + maxAge * 1000 });
|
|
6869
6941
|
}
|
|
6870
|
-
set.headers["content-type"] = "image/png";
|
|
6871
|
-
set.headers["cache-control"] = `public, max-age=${maxAge}`;
|
|
6872
|
-
set.headers["Reroute-Cache"] = "MISS";
|
|
6873
|
-
return new Response(buffer);
|
|
6874
6942
|
}
|
|
6875
6943
|
app.get("/__reroute_og/*", async ({ request, set }) => {
|
|
6876
6944
|
try {
|
|
@@ -6879,9 +6947,30 @@ function registerOGRoutes(app, options) {
|
|
|
6879
6947
|
const cachedResponse = checkOgCache(pathname, set);
|
|
6880
6948
|
if (cachedResponse)
|
|
6881
6949
|
return cachedResponse;
|
|
6882
|
-
|
|
6950
|
+
if (generatingImages.has(pathname)) {
|
|
6951
|
+
set.status = 404;
|
|
6952
|
+
set.headers["Retry-After"] = "2";
|
|
6953
|
+
return new Response("Image generation in progress", {
|
|
6954
|
+
status: 404,
|
|
6955
|
+
headers: { "Content-Type": "text/plain" }
|
|
6956
|
+
});
|
|
6957
|
+
}
|
|
6958
|
+
generatingImages.add(pathname);
|
|
6959
|
+
generateOgImage(pathname, clientDir, cwd, isWatchMode, ogConfig, width, height).then(() => {
|
|
6960
|
+
console.log(`[reroute/og] Generated image for: ${pathname}`);
|
|
6961
|
+
}).catch((error) => {
|
|
6962
|
+
console.error(`[reroute/og] Failed to generate image for ${pathname}:`, error);
|
|
6963
|
+
}).finally(() => {
|
|
6964
|
+
generatingImages.delete(pathname);
|
|
6965
|
+
});
|
|
6966
|
+
set.status = 404;
|
|
6967
|
+
set.headers["Retry-After"] = "2";
|
|
6968
|
+
return new Response("Image not yet available, please retry", {
|
|
6969
|
+
status: 404,
|
|
6970
|
+
headers: { "Content-Type": "text/plain" }
|
|
6971
|
+
});
|
|
6883
6972
|
} catch (error) {
|
|
6884
|
-
console.error("[reroute] Failed to
|
|
6973
|
+
console.error("[reroute] Failed to handle OG image request:", error);
|
|
6885
6974
|
set.status = 500;
|
|
6886
6975
|
return new Response("Internal Server Error", {
|
|
6887
6976
|
status: 500,
|
|
@@ -7025,6 +7114,23 @@ function registerRobotsRoute(app, options) {
|
|
|
7025
7114
|
// packages/elysia/src/routes/rss.ts
|
|
7026
7115
|
init_core();
|
|
7027
7116
|
import { NotFoundError as NotFoundError8 } from "elysia";
|
|
7117
|
+
var rssDiscoveryCache = new LRUCache(1);
|
|
7118
|
+
async function getOrDiscoverRSSData(cwd, collections2, baseUrl, isWatchMode, rssConfig) {
|
|
7119
|
+
if (isWatchMode) {
|
|
7120
|
+
return discoverRSSData(cwd, collections2, baseUrl, isWatchMode, rssConfig);
|
|
7121
|
+
}
|
|
7122
|
+
const cacheKey = "rss:discovery";
|
|
7123
|
+
const cached = rssDiscoveryCache.get(cacheKey);
|
|
7124
|
+
if (cached && cached.exp > Date.now()) {
|
|
7125
|
+
return cached.discovery;
|
|
7126
|
+
}
|
|
7127
|
+
const discovery5 = await discoverRSSData(cwd, collections2, baseUrl, isWatchMode, rssConfig);
|
|
7128
|
+
rssDiscoveryCache.set(cacheKey, {
|
|
7129
|
+
discovery: discovery5,
|
|
7130
|
+
exp: Date.now() + 5 * 60 * 1000
|
|
7131
|
+
});
|
|
7132
|
+
return discovery5;
|
|
7133
|
+
}
|
|
7028
7134
|
function createFeedTitle(configTitle, name) {
|
|
7029
7135
|
return configTitle ?? `${name.charAt(0).toUpperCase() + name.slice(1)} Feed`;
|
|
7030
7136
|
}
|
|
@@ -7055,7 +7161,7 @@ async function registerMainFeedRoute(app, cwd, collections2, baseUrl, isWatchMod
|
|
|
7055
7161
|
if (cached) {
|
|
7056
7162
|
return feedResponse(cached.xml, format, { maxAge, cacheStatus: "HIT" });
|
|
7057
7163
|
}
|
|
7058
|
-
const discovery5 = await
|
|
7164
|
+
const discovery5 = await getOrDiscoverRSSData(cwd, collections2, baseUrl, isWatchMode, rssConfig);
|
|
7059
7165
|
const allItems = [
|
|
7060
7166
|
...Array.from(discovery5.collections.values()).flat(),
|
|
7061
7167
|
...Array.from(discovery5.ssrDataFeeds.values()).flat()
|
|
@@ -7094,7 +7200,7 @@ function registerCollectionFeedRoutes(app, collections2, options) {
|
|
|
7094
7200
|
cacheStatus: "HIT"
|
|
7095
7201
|
});
|
|
7096
7202
|
}
|
|
7097
|
-
const discovery5 = await
|
|
7203
|
+
const discovery5 = await getOrDiscoverRSSData(options.cwd, [collection], options.baseUrl, options.isWatchMode, options.rssConfig);
|
|
7098
7204
|
const items = discovery5.collections.get(collection) ?? [];
|
|
7099
7205
|
if (items.length === 0)
|
|
7100
7206
|
throw new NotFoundError8;
|
|
@@ -7155,7 +7261,7 @@ async function generateSSRDataFeed(route, options) {
|
|
|
7155
7261
|
}
|
|
7156
7262
|
let items = await discoverSSRDataFeedItems(options.cwd, route.pattern, route.path, options.isWatchMode, options.baseUrl, options.rssConfig);
|
|
7157
7263
|
if (items.length === 0 && route.isLayout) {
|
|
7158
|
-
const discovery5 = await
|
|
7264
|
+
const discovery5 = await getOrDiscoverRSSData(options.cwd, [], options.baseUrl, options.isWatchMode, options.rssConfig);
|
|
7159
7265
|
items = discovery5.ssrDataFeeds.get(route.pattern) ?? [];
|
|
7160
7266
|
}
|
|
7161
7267
|
if (items.length === 0)
|
|
@@ -7212,7 +7318,6 @@ async function registerRSSRoutes(app, options) {
|
|
|
7212
7318
|
const feedDescription = rssConfig?.description ?? "Latest updates";
|
|
7213
7319
|
const availableFeeds = ["/feed.xml"];
|
|
7214
7320
|
registerMainFeedRoute(app, cwd, collections2, baseUrl, isWatchMode, rssCache, format, limit, maxAge, ttlMs, feedTitle, feedDescription, rssConfig);
|
|
7215
|
-
const ssrDataRoutes = await discoverSSRRoutes(cwd, isWatchMode);
|
|
7216
7321
|
registerCollectionFeedRoutes(app, collections2, {
|
|
7217
7322
|
cwd,
|
|
7218
7323
|
clientDir,
|
|
@@ -7226,6 +7331,11 @@ async function registerRSSRoutes(app, options) {
|
|
|
7226
7331
|
rssConfig,
|
|
7227
7332
|
availableFeeds
|
|
7228
7333
|
});
|
|
7334
|
+
if (isWatchMode) {
|
|
7335
|
+
globalThis.__REROUTE_AVAILABLE_FEEDS__ = availableFeeds;
|
|
7336
|
+
return app;
|
|
7337
|
+
}
|
|
7338
|
+
const ssrDataRoutes = await discoverSSRRoutes(cwd, isWatchMode);
|
|
7229
7339
|
const routesWithFeeds = await discoverRoutesWithFeeds(ssrDataRoutes, collections2, {
|
|
7230
7340
|
cwd,
|
|
7231
7341
|
clientDir,
|
|
@@ -7376,9 +7486,26 @@ function registerSearchRoute(app, cwd, directive, maxAge, searchConfig) {
|
|
|
7376
7486
|
// packages/elysia/src/routes/sitemap.ts
|
|
7377
7487
|
init_core();
|
|
7378
7488
|
import { NotFoundError as NotFoundError9 } from "elysia";
|
|
7489
|
+
var sitemapDiscoveryCache = new LRUCache(1);
|
|
7490
|
+
async function getOrDiscoverSitemapData(cwd, collections2, baseUrl, isWatchMode, sitemapConfig) {
|
|
7491
|
+
if (isWatchMode) {
|
|
7492
|
+
return discoverSitemapData(cwd, collections2, baseUrl, isWatchMode, sitemapConfig);
|
|
7493
|
+
}
|
|
7494
|
+
const cacheKey = "sitemap:discovery";
|
|
7495
|
+
const cached = sitemapDiscoveryCache.get(cacheKey);
|
|
7496
|
+
if (cached && cached.exp > Date.now()) {
|
|
7497
|
+
return cached.discovery;
|
|
7498
|
+
}
|
|
7499
|
+
const discovery5 = await discoverSitemapData(cwd, collections2, baseUrl, isWatchMode, sitemapConfig);
|
|
7500
|
+
sitemapDiscoveryCache.set(cacheKey, {
|
|
7501
|
+
discovery: discovery5,
|
|
7502
|
+
exp: Date.now() + 5 * 60 * 1000
|
|
7503
|
+
});
|
|
7504
|
+
return discovery5;
|
|
7505
|
+
}
|
|
7379
7506
|
async function generateAndCacheSitemap(options, _ttlMs) {
|
|
7380
7507
|
const { cwd, collections: collections2, baseUrl, isWatchMode, sitemapConfig } = options;
|
|
7381
|
-
const discovery5 = await
|
|
7508
|
+
const discovery5 = await getOrDiscoverSitemapData(cwd, collections2, baseUrl, isWatchMode, sitemapConfig);
|
|
7382
7509
|
const result = await generateSitemap(discovery5, baseUrl, {
|
|
7383
7510
|
changefreq: sitemapConfig?.changefreq,
|
|
7384
7511
|
priority: sitemapConfig?.priority,
|
|
@@ -8107,8 +8234,24 @@ var reroute = () => async (app) => {
|
|
|
8107
8234
|
const shouldIgnore = !ignorePatterns.length ? () => false : (file) => ignorePatterns.find((pattern) => typeof pattern === "string" ? file.includes(pattern) : pattern.test(file));
|
|
8108
8235
|
const isWatchMode = Array.isArray(process.execArgv) && process.execArgv.includes("--watch") || Array.isArray(process.argv) && process.argv.includes("--watch");
|
|
8109
8236
|
const dataCacheControl = `${directive}, max-age=${maxAge}`;
|
|
8110
|
-
if (isWatchMode)
|
|
8237
|
+
if (isWatchMode) {
|
|
8111
8238
|
console.log(`[reroute] Live reload enabled`);
|
|
8239
|
+
registerLiveReloadRoutes(app, liveReloadState);
|
|
8240
|
+
app.post("/__reroute_rebuilding", () => {
|
|
8241
|
+
console.log("[reroute] Rebuild notification received, notifying browsers...");
|
|
8242
|
+
notifyRebuilding();
|
|
8243
|
+
return new Response(JSON.stringify({ ok: true, clients: liveReloadState.clients.size }), {
|
|
8244
|
+
headers: { "content-type": "application/json" }
|
|
8245
|
+
});
|
|
8246
|
+
});
|
|
8247
|
+
app.post("/__reroute_reload", () => {
|
|
8248
|
+
console.log(`[reroute] Reload notification received, notifying ${liveReloadState.clients.size} browser(s)...`);
|
|
8249
|
+
notifyReload();
|
|
8250
|
+
return new Response(JSON.stringify({ ok: true, clients: liveReloadState.clients.size }), {
|
|
8251
|
+
headers: { "content-type": "application/json" }
|
|
8252
|
+
});
|
|
8253
|
+
});
|
|
8254
|
+
}
|
|
8112
8255
|
const readBundleUrl = async () => {
|
|
8113
8256
|
const bundlesDir = `${cwd}/.reroute/bundles`;
|
|
8114
8257
|
const maxAttempts = isWatchMode ? 500 : 10;
|
|
@@ -8155,25 +8298,6 @@ var reroute = () => async (app) => {
|
|
|
8155
8298
|
isWatchMode,
|
|
8156
8299
|
maxAge
|
|
8157
8300
|
});
|
|
8158
|
-
if (isWatchMode) {
|
|
8159
|
-
registerLiveReloadRoutes(app, liveReloadState);
|
|
8160
|
-
}
|
|
8161
|
-
if (isWatchMode) {
|
|
8162
|
-
app.post("/__reroute_rebuilding", () => {
|
|
8163
|
-
console.log("[reroute] Rebuild notification received, notifying browsers...");
|
|
8164
|
-
notifyRebuilding();
|
|
8165
|
-
return new Response(JSON.stringify({ ok: true, clients: liveReloadState.clients.size }), {
|
|
8166
|
-
headers: { "content-type": "application/json" }
|
|
8167
|
-
});
|
|
8168
|
-
});
|
|
8169
|
-
app.post("/__reroute_reload", () => {
|
|
8170
|
-
console.log(`[reroute] Reload notification received, notifying ${liveReloadState.clients.size} browser(s)...`);
|
|
8171
|
-
notifyReload();
|
|
8172
|
-
return new Response(JSON.stringify({ ok: true, clients: liveReloadState.clients.size }), {
|
|
8173
|
-
headers: { "content-type": "application/json" }
|
|
8174
|
-
});
|
|
8175
|
-
});
|
|
8176
|
-
}
|
|
8177
8301
|
registerArtifactsRoutes(app, cwd, fileCache, {
|
|
8178
8302
|
bundleMaxAge,
|
|
8179
8303
|
directive,
|
|
@@ -8222,6 +8346,39 @@ var reroute = () => async (app) => {
|
|
|
8222
8346
|
console.error("[reroute] Failed to register robots route:", error);
|
|
8223
8347
|
}
|
|
8224
8348
|
}
|
|
8349
|
+
if (sitemapEnabled && sitemapBaseUrl) {
|
|
8350
|
+
try {
|
|
8351
|
+
registerSitemapRoutes(app, {
|
|
8352
|
+
cwd,
|
|
8353
|
+
collections: collections2,
|
|
8354
|
+
baseUrl: sitemapBaseUrl,
|
|
8355
|
+
maxAge,
|
|
8356
|
+
isWatchMode,
|
|
8357
|
+
sitemapCache,
|
|
8358
|
+
sitemapConfig
|
|
8359
|
+
});
|
|
8360
|
+
console.log(`[reroute] Sitemap enabled at ${sitemapBaseUrl}/sitemap.xml`);
|
|
8361
|
+
} catch (error) {
|
|
8362
|
+
console.error("[reroute] Failed to register sitemap routes:", error);
|
|
8363
|
+
}
|
|
8364
|
+
}
|
|
8365
|
+
if (rssEnabled && rssBaseUrl) {
|
|
8366
|
+
try {
|
|
8367
|
+
await registerRSSRoutes(app, {
|
|
8368
|
+
cwd,
|
|
8369
|
+
clientDir,
|
|
8370
|
+
collections: collections2,
|
|
8371
|
+
baseUrl: rssBaseUrl,
|
|
8372
|
+
maxAge,
|
|
8373
|
+
isWatchMode,
|
|
8374
|
+
rssCache,
|
|
8375
|
+
rssConfig
|
|
8376
|
+
});
|
|
8377
|
+
console.log(`[reroute] RSS feeds enabled at ${rssBaseUrl}/feed.xml`);
|
|
8378
|
+
} catch (error) {
|
|
8379
|
+
console.error("[reroute] Failed to register RSS routes:", error);
|
|
8380
|
+
}
|
|
8381
|
+
}
|
|
8225
8382
|
if (llmsEnabled && llmsConfig) {
|
|
8226
8383
|
try {
|
|
8227
8384
|
registerLLMsRoutes(app, {
|
|
@@ -8252,6 +8409,20 @@ var reroute = () => async (app) => {
|
|
|
8252
8409
|
console.error("[reroute] Failed to register LLMs routes:", error);
|
|
8253
8410
|
}
|
|
8254
8411
|
}
|
|
8412
|
+
if (ogEnabled && ogConfig) {
|
|
8413
|
+
try {
|
|
8414
|
+
registerOGRoutes(app, {
|
|
8415
|
+
clientDir,
|
|
8416
|
+
cwd,
|
|
8417
|
+
isWatchMode,
|
|
8418
|
+
ogConfig,
|
|
8419
|
+
ogCache
|
|
8420
|
+
});
|
|
8421
|
+
console.log("[reroute] OG image generation enabled");
|
|
8422
|
+
} catch (error) {
|
|
8423
|
+
console.error("[reroute] Failed to register OG routes:", error);
|
|
8424
|
+
}
|
|
8425
|
+
}
|
|
8255
8426
|
registerSSRRoutes(app, {
|
|
8256
8427
|
rootComponent,
|
|
8257
8428
|
clientDir,
|
|
@@ -8275,53 +8446,6 @@ var reroute = () => async (app) => {
|
|
|
8275
8446
|
baseUrl,
|
|
8276
8447
|
autoCanonical
|
|
8277
8448
|
});
|
|
8278
|
-
if (sitemapEnabled && sitemapBaseUrl) {
|
|
8279
|
-
try {
|
|
8280
|
-
registerSitemapRoutes(app, {
|
|
8281
|
-
cwd,
|
|
8282
|
-
collections: collections2,
|
|
8283
|
-
baseUrl: sitemapBaseUrl,
|
|
8284
|
-
maxAge,
|
|
8285
|
-
isWatchMode,
|
|
8286
|
-
sitemapCache,
|
|
8287
|
-
sitemapConfig
|
|
8288
|
-
});
|
|
8289
|
-
console.log(`[reroute] Sitemap enabled at ${sitemapBaseUrl}/sitemap.xml`);
|
|
8290
|
-
} catch (error) {
|
|
8291
|
-
console.error("[reroute] Failed to register sitemap routes:", error);
|
|
8292
|
-
}
|
|
8293
|
-
}
|
|
8294
|
-
if (rssEnabled && rssBaseUrl) {
|
|
8295
|
-
try {
|
|
8296
|
-
await registerRSSRoutes(app, {
|
|
8297
|
-
cwd,
|
|
8298
|
-
clientDir,
|
|
8299
|
-
collections: collections2,
|
|
8300
|
-
baseUrl: rssBaseUrl,
|
|
8301
|
-
maxAge,
|
|
8302
|
-
isWatchMode,
|
|
8303
|
-
rssCache,
|
|
8304
|
-
rssConfig
|
|
8305
|
-
});
|
|
8306
|
-
console.log(`[reroute] RSS feeds enabled at ${rssBaseUrl}/feed.xml`);
|
|
8307
|
-
} catch (error) {
|
|
8308
|
-
console.error("[reroute] Failed to register RSS routes:", error);
|
|
8309
|
-
}
|
|
8310
|
-
}
|
|
8311
|
-
if (ogEnabled && ogConfig) {
|
|
8312
|
-
try {
|
|
8313
|
-
registerOGRoutes(app, {
|
|
8314
|
-
clientDir,
|
|
8315
|
-
cwd,
|
|
8316
|
-
isWatchMode,
|
|
8317
|
-
ogConfig,
|
|
8318
|
-
ogCache
|
|
8319
|
-
});
|
|
8320
|
-
console.log("[reroute] OG image generation enabled");
|
|
8321
|
-
} catch (error) {
|
|
8322
|
-
console.error("[reroute] Failed to register OG routes:", error);
|
|
8323
|
-
}
|
|
8324
|
-
}
|
|
8325
8449
|
} catch (error) {
|
|
8326
8450
|
console.error("[reroute] Failed to register SSR routes:", error);
|
|
8327
8451
|
throw error;
|
|
@@ -8342,4 +8466,4 @@ export {
|
|
|
8342
8466
|
reroute
|
|
8343
8467
|
};
|
|
8344
8468
|
|
|
8345
|
-
//# debugId=
|
|
8469
|
+
//# debugId=B3B56B145A0DCF8164756E2164756E21
|