reroute-js 0.34.8 → 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.
- package/cli/bin.d.ts +1 -1
- package/cli/bin.js +175 -71
- package/cli/bin.js.map +6 -6
- 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/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 +171 -67
- package/core/index.js.map +6 -6
- 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/full-generator.d.ts.map +1 -1
- package/core/src/llms/index-generator.d.ts +2 -3
- package/core/src/llms/index-generator.d.ts.map +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 +4 -4
- 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 +3 -3
- 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 +181 -81
- package/elysia/index.js.map +10 -10
- 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/llms.d.ts +1 -1
- package/elysia/src/routes/llms.d.ts.map +1 -1
- package/elysia/src/routes/og.d.ts +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 +1 -1
- 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 +1 -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 +3 -3
- 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/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/core/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* reroute-js v0.34.
|
|
2
|
+
* reroute-js v0.34.9
|
|
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(
|
|
3120
|
+
async function loadRouteModule(cwd, routePath, isWatchMode) {
|
|
3121
3121
|
try {
|
|
3122
|
-
const abs = join(
|
|
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(
|
|
3155
|
+
async function discoverSSRDataRoutes(cwd, staticRoutes, isWatchMode) {
|
|
3156
3156
|
const ssrDataRoutes = new Map;
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
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")
|
|
3169
3166
|
continue;
|
|
3170
|
-
const
|
|
3171
|
-
|
|
3172
|
-
|
|
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
|
+
}
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
3470
|
+
const { cwd, collections: collections2, baseUrl, isWatchMode, llmsConfig } = options;
|
|
3448
3471
|
const parts = buildHeader(baseUrl, llmsConfig);
|
|
3449
|
-
const allRoutes = await discoverAllRoutes(cwd,
|
|
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);
|
|
@@ -3863,30 +3886,58 @@ async function discoverCollectionContent(cwd, collection, isWatchMode, baseUrl)
|
|
|
3863
3886
|
}
|
|
3864
3887
|
return entries;
|
|
3865
3888
|
}
|
|
3866
|
-
async function discoverSSRDataRoutes2(
|
|
3889
|
+
async function discoverSSRDataRoutes2(cwd, staticRoutes, isWatchMode, baseUrl, sitemapConfig) {
|
|
3867
3890
|
const ssrDataRoutes = new Map;
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
const
|
|
3875
|
-
|
|
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;
|
|
3876
3901
|
const dataFn = ssr?.data;
|
|
3877
3902
|
if (typeof dataFn === "function") {
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
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 {}
|
|
3888
3915
|
}
|
|
3889
|
-
}
|
|
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
|
+
}
|
|
3890
3941
|
}
|
|
3891
3942
|
return ssrDataRoutes;
|
|
3892
3943
|
}
|
|
@@ -3996,7 +4047,7 @@ function createEntryFromItem(item, routePattern, baseUrl, sitemapConfig) {
|
|
|
3996
4047
|
}
|
|
3997
4048
|
return entry;
|
|
3998
4049
|
}
|
|
3999
|
-
async function discoverSitemapData(cwd,
|
|
4050
|
+
async function discoverSitemapData(cwd, collections2, baseUrl, isWatchMode, sitemapConfig) {
|
|
4000
4051
|
const { staticRoutes, dynamicRoutes } = await discoverRoutes(cwd, isWatchMode);
|
|
4001
4052
|
const collectionsMap = new Map;
|
|
4002
4053
|
for (const collection of collections2) {
|
|
@@ -4005,7 +4056,7 @@ async function discoverSitemapData(cwd, clientDir, collections2, baseUrl, isWatc
|
|
|
4005
4056
|
collectionsMap.set(collection, entries);
|
|
4006
4057
|
}
|
|
4007
4058
|
}
|
|
4008
|
-
const ssrDataRoutes = await discoverSSRDataRoutes2(cwd,
|
|
4059
|
+
const ssrDataRoutes = await discoverSSRDataRoutes2(cwd, staticRoutes, isWatchMode, baseUrl, sitemapConfig);
|
|
4009
4060
|
return {
|
|
4010
4061
|
staticRoutes,
|
|
4011
4062
|
dynamicRoutes,
|
|
@@ -4120,10 +4171,10 @@ async function discoverCollectionFeedItems(cwd, collection, isWatchMode, baseUrl
|
|
|
4120
4171
|
sortByPubDate(items);
|
|
4121
4172
|
return items;
|
|
4122
4173
|
}
|
|
4123
|
-
async function discoverSSRDataFeedItems(
|
|
4174
|
+
async function discoverSSRDataFeedItems(cwd, routePattern, routePath, isWatchMode, baseUrl, rssConfig) {
|
|
4124
4175
|
const items = [];
|
|
4125
4176
|
try {
|
|
4126
|
-
const abs = join(
|
|
4177
|
+
const abs = join(cwd, "src", "client", "routes", routePath);
|
|
4127
4178
|
const mod = await import(pathToFileURL7(abs).href + (isWatchMode ? `?t=${Date.now()}` : ""));
|
|
4128
4179
|
const ssr = mod?.ssr;
|
|
4129
4180
|
const dataFn = ssr?.data;
|
|
@@ -4259,7 +4310,7 @@ function createRSSItemFromData(item, routePattern, baseUrl, rssConfig) {
|
|
|
4259
4310
|
}
|
|
4260
4311
|
return rssItem;
|
|
4261
4312
|
}
|
|
4262
|
-
async function discoverRSSData(cwd,
|
|
4313
|
+
async function discoverRSSData(cwd, collections2, baseUrl, isWatchMode, rssConfig) {
|
|
4263
4314
|
const collectionsMap = new Map;
|
|
4264
4315
|
for (const collection of collections2) {
|
|
4265
4316
|
const items = await discoverCollectionFeedItems(cwd, collection, isWatchMode, baseUrl, rssConfig);
|
|
@@ -4268,18 +4319,48 @@ async function discoverRSSData(cwd, clientDir, collections2, baseUrl, isWatchMod
|
|
|
4268
4319
|
}
|
|
4269
4320
|
}
|
|
4270
4321
|
const ssrDataFeeds = new Map;
|
|
4271
|
-
const
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
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
|
+
}
|
|
4276
4349
|
}
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
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
|
+
}
|
|
4280
4361
|
}
|
|
4281
4362
|
}
|
|
4282
|
-
const layoutFeeds = await discoverLayoutFeedItems(cwd,
|
|
4363
|
+
const layoutFeeds = await discoverLayoutFeedItems(cwd, isWatchMode, baseUrl, rssConfig);
|
|
4283
4364
|
for (const [pattern, items] of layoutFeeds.entries()) {
|
|
4284
4365
|
const existing = ssrDataFeeds.get(pattern) || [];
|
|
4285
4366
|
ssrDataFeeds.set(pattern, [...existing, ...items]);
|
|
@@ -4303,13 +4384,13 @@ async function loadLayouts(cwd, isWatchMode) {
|
|
|
4303
4384
|
return;
|
|
4304
4385
|
}
|
|
4305
4386
|
}
|
|
4306
|
-
async function processLayoutForRSS(layout,
|
|
4387
|
+
async function processLayoutForRSS(layout, cwd, isWatchMode, baseUrl, rssConfig) {
|
|
4307
4388
|
const pattern = String(layout?.pattern || "/");
|
|
4308
4389
|
const path2 = String(layout?.path || "");
|
|
4309
4390
|
if (!path2)
|
|
4310
4391
|
return null;
|
|
4311
4392
|
try {
|
|
4312
|
-
const abs = join(
|
|
4393
|
+
const abs = join(cwd, "src", "client", "routes", path2);
|
|
4313
4394
|
const layoutMod = await import(pathToFileURL7(abs).href + (isWatchMode ? `?t=${Date.now()}` : ""));
|
|
4314
4395
|
const ssr = layoutMod?.ssr;
|
|
4315
4396
|
const dataFn = ssr?.data;
|
|
@@ -4328,16 +4409,39 @@ async function processLayoutForRSS(layout, clientDir, isWatchMode, baseUrl, rssC
|
|
|
4328
4409
|
} catch {}
|
|
4329
4410
|
return null;
|
|
4330
4411
|
}
|
|
4331
|
-
async function discoverLayoutFeedItems(cwd,
|
|
4412
|
+
async function discoverLayoutFeedItems(cwd, isWatchMode, baseUrl, rssConfig) {
|
|
4332
4413
|
const layoutFeeds = new Map;
|
|
4333
4414
|
const layouts2 = await loadLayouts(cwd, isWatchMode);
|
|
4334
4415
|
if (!Array.isArray(layouts2)) {
|
|
4335
4416
|
return layoutFeeds;
|
|
4336
4417
|
}
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
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
|
+
}
|
|
4341
4445
|
}
|
|
4342
4446
|
}
|
|
4343
4447
|
return layoutFeeds;
|
|
@@ -4955,4 +5059,4 @@ export {
|
|
|
4955
5059
|
AI_CRAWLERS
|
|
4956
5060
|
};
|
|
4957
5061
|
|
|
4958
|
-
//# debugId=
|
|
5062
|
+
//# debugId=AEB73B7AB4DE746C64756E2164756E21
|