reroute-js 1.0.0-alpha.7 → 1.0.0-alpha.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/README.md +2 -0
- package/cli/bin.d.ts +1 -1
- package/cli/bin.js +198 -36
- package/cli/bin.js.map +12 -11
- 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/terminal-ui.d.ts +1 -1
- package/cli/src/commands/lib/theme.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 +194 -32
- package/core/index.js.map +12 -11
- package/core/src/bundler/hash.d.ts +1 -1
- package/core/src/bundler/index.d.ts +1 -1
- package/core/src/config.d.ts +26 -2
- package/core/src/config.d.ts.map +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/i18n/catalog.d.ts +1 -1
- package/core/src/i18n/discover.d.ts +1 -1
- package/core/src/i18n/index.d.ts +1 -1
- package/core/src/i18n/messages.d.ts +1 -1
- package/core/src/i18n/negotiate.d.ts +1 -1
- package/core/src/i18n/pathname.d.ts +1 -1
- package/core/src/i18n/resolve.d.ts +1 -1
- package/core/src/i18n/types.d.ts +1 -1
- package/core/src/index.d.ts +1 -1
- package/core/src/llms/discovery.d.ts +35 -0
- package/core/src/llms/discovery.d.ts.map +1 -0
- 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 +4 -1
- package/core/src/llms/index.d.ts.map +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/generator.d.ts.map +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/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/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/cleanup.d.ts +1 -1
- package/core/src/ssr/lib/collections.d.ts +17 -1
- package/core/src/ssr/lib/collections.d.ts.map +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/content-path.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/route-match.d.ts +1 -1
- package/core/src/ssr/lib/scripts/collections.d.ts +2 -2
- package/core/src/ssr/lib/scripts/collections.d.ts.map +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 +2 -2
- package/core/src/ssr/lib/setup.d.ts.map +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/render.d.ts.map +1 -1
- package/core/src/ssr/stream.d.ts +1 -1
- package/core/src/ssr/stream.d.ts.map +1 -1
- package/elysia/index.d.ts +1 -1
- package/elysia/index.js +222 -50
- package/elysia/index.js.map +15 -14
- 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/i18n.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/search.d.ts +1 -1
- package/elysia/src/routes/sitemap.d.ts +1 -1
- package/elysia/src/routes/ssr.d.ts +4 -2
- package/elysia/src/routes/ssr.d.ts.map +1 -1
- package/elysia/src/routes/static.d.ts +1 -1
- package/elysia/src/routes/themeCssRefresh.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 +8 -5
- package/react/index.js.map +3 -3
- 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/useContent.d.ts.map +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/i18n/LocaleProvider.d.ts +1 -1
- package/react/src/i18n/helpers.d.ts +1 -1
- package/react/src/i18n/index.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 +25 -10
- package/telemetry/server.js.map +11 -9
- 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/core/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* reroute-js v1.0.0-alpha.
|
|
2
|
+
* reroute-js v1.0.0-alpha.9
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2026 stewones <hi@stewan.io>
|
|
@@ -1150,6 +1150,21 @@ function setGlobalCollections(byCollectionForSSR) {
|
|
|
1150
1150
|
globalThis.__REROUTE_COLLECTIONS__ = byCollectionForSSR;
|
|
1151
1151
|
} catch {}
|
|
1152
1152
|
}
|
|
1153
|
+
function resetSSRContentResults() {
|
|
1154
|
+
try {
|
|
1155
|
+
globalThis.__REROUTE_SSR_RESULTS__ = {};
|
|
1156
|
+
} catch {}
|
|
1157
|
+
}
|
|
1158
|
+
function takeSSRContentResults() {
|
|
1159
|
+
try {
|
|
1160
|
+
const g = globalThis;
|
|
1161
|
+
const results = g.__REROUTE_SSR_RESULTS__;
|
|
1162
|
+
g.__REROUTE_SSR_RESULTS__ = {};
|
|
1163
|
+
return results;
|
|
1164
|
+
} catch {
|
|
1165
|
+
return;
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1153
1168
|
var init_collections = __esm(() => {
|
|
1154
1169
|
init_imports();
|
|
1155
1170
|
});
|
|
@@ -3270,23 +3285,34 @@ function parseAccessTracking(accessedCollections) {
|
|
|
3270
3285
|
}
|
|
3271
3286
|
return usage;
|
|
3272
3287
|
}
|
|
3273
|
-
function
|
|
3288
|
+
function processCapturedResults(capturedResults, byCollectionForSSR) {
|
|
3274
3289
|
const subset = {};
|
|
3275
3290
|
const partial = {};
|
|
3276
3291
|
try {
|
|
3277
3292
|
const g = globalThis;
|
|
3278
|
-
const ssrResults = g.__REROUTE_SSR_RESULTS__;
|
|
3279
|
-
if (ssrResults
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3293
|
+
const ssrResults = capturedResults ?? g.__REROUTE_SSR_RESULTS__;
|
|
3294
|
+
if (!ssrResults || typeof ssrResults !== "object")
|
|
3295
|
+
return;
|
|
3296
|
+
for (const [collection, items] of Object.entries(ssrResults)) {
|
|
3297
|
+
if (Array.isArray(items) && items.length > 0) {
|
|
3298
|
+
subset[collection] = items;
|
|
3299
|
+
const full = byCollectionForSSR?.[collection] || [];
|
|
3300
|
+
partial[collection] = items.length < full.length;
|
|
3286
3301
|
}
|
|
3287
|
-
return { subset, partial };
|
|
3288
3302
|
}
|
|
3289
|
-
} catch {
|
|
3303
|
+
} catch {
|
|
3304
|
+
return;
|
|
3305
|
+
}
|
|
3306
|
+
if (Object.keys(subset).length === 0)
|
|
3307
|
+
return;
|
|
3308
|
+
return { subset, partial };
|
|
3309
|
+
}
|
|
3310
|
+
function processCollections(accessedCollections, byCollectionForSSR, capturedResults) {
|
|
3311
|
+
const captured = processCapturedResults(capturedResults, byCollectionForSSR);
|
|
3312
|
+
if (captured)
|
|
3313
|
+
return captured;
|
|
3314
|
+
const subset = {};
|
|
3315
|
+
const partial = {};
|
|
3290
3316
|
const sortByDate = (order) => (a, b) => {
|
|
3291
3317
|
const da = a?.meta?.date ? Date.parse(String(a.meta.date)) : 0;
|
|
3292
3318
|
const db = b?.meta?.date ? Date.parse(String(b.meta.date)) : 0;
|
|
@@ -3575,6 +3601,7 @@ async function performSSRSetupInternal(options, streaming, timeoutState) {
|
|
|
3575
3601
|
});
|
|
3576
3602
|
assertNotTimedOut();
|
|
3577
3603
|
resetSSRAccessTracking();
|
|
3604
|
+
resetSSRContentResults();
|
|
3578
3605
|
const bundlePreload = createBundlePreload(bundleUrl);
|
|
3579
3606
|
const preloadResult = await withSpan("ssr.preload", async (span) => {
|
|
3580
3607
|
span.setAttribute("pathname", pathname);
|
|
@@ -3650,12 +3677,12 @@ async function performSSRSetupInternal(options, streaming, timeoutState) {
|
|
|
3650
3677
|
pending: computeResult.pending
|
|
3651
3678
|
};
|
|
3652
3679
|
}
|
|
3653
|
-
function generateCollectionScripts(byCollectionForSSR) {
|
|
3680
|
+
function generateCollectionScripts(byCollectionForSSR, capturedResults) {
|
|
3654
3681
|
try {
|
|
3655
3682
|
const g = globalThis;
|
|
3656
3683
|
const acc = g.__REROUTE_SSR_ACCESSED__;
|
|
3657
3684
|
if (acc) {
|
|
3658
|
-
const { subset, partial } = processCollections(acc, byCollectionForSSR);
|
|
3685
|
+
const { subset, partial } = processCollections(acc, byCollectionForSSR, capturedResults);
|
|
3659
3686
|
if (Object.keys(subset).length > 0) {
|
|
3660
3687
|
return createCollectionScript(subset, partial);
|
|
3661
3688
|
}
|
|
@@ -3807,13 +3834,16 @@ async function renderSSRDocument(options) {
|
|
|
3807
3834
|
}, false);
|
|
3808
3835
|
const duplicatedData = duplicateQueryParamData(setup2.ssrData);
|
|
3809
3836
|
setGlobalSSRData(duplicatedData);
|
|
3837
|
+
let capturedResults;
|
|
3810
3838
|
const appHtml = await withSpan("ssr.render.react", async (span) => {
|
|
3811
3839
|
const componentWithPathname = cloneElement(rootComponent, {
|
|
3812
3840
|
pathname,
|
|
3813
3841
|
searchParams
|
|
3814
3842
|
});
|
|
3815
3843
|
span.setAttribute("reroute.pathname", pathname);
|
|
3844
|
+
resetSSRContentResults();
|
|
3816
3845
|
const html3 = renderToString(componentWithPathname);
|
|
3846
|
+
capturedResults = takeSSRContentResults();
|
|
3817
3847
|
span.setAttribute("reroute.html.final.size", html3.length);
|
|
3818
3848
|
return html3;
|
|
3819
3849
|
});
|
|
@@ -3822,7 +3852,7 @@ async function renderSSRDocument(options) {
|
|
|
3822
3852
|
span.setAttribute("reroute.template.size", template2.length);
|
|
3823
3853
|
return template2;
|
|
3824
3854
|
});
|
|
3825
|
-
const collectionScripts = generateCollectionScripts(setup2.byCollectionForSSR);
|
|
3855
|
+
const collectionScripts = generateCollectionScripts(setup2.byCollectionForSSR, capturedResults);
|
|
3826
3856
|
const config = await loadConfig(cwd);
|
|
3827
3857
|
const browserTelemetryConfigRaw = config.telemetry?.browser;
|
|
3828
3858
|
const { serializeBrowserTelemetryConfig: serializeBrowserTelemetryConfig2 } = await Promise.resolve().then(() => exports_serialize);
|
|
@@ -3840,7 +3870,7 @@ async function renderSSRDocument(options) {
|
|
|
3840
3870
|
if (setup2.metadataResult.statusOverride !== undefined) {
|
|
3841
3871
|
statusOverride = setup2.metadataResult.statusOverride;
|
|
3842
3872
|
}
|
|
3843
|
-
const extraHead = setup2.bundlePreload + setup2.preloadExtraHead;
|
|
3873
|
+
const extraHead = appendLlmsAlternateHead(setup2.bundlePreload + setup2.preloadExtraHead, pathname, statusOverride || 200, config.llms);
|
|
3844
3874
|
const combinedHead = dedent([
|
|
3845
3875
|
dedent(head) || "",
|
|
3846
3876
|
dedent(extraHead),
|
|
@@ -3870,6 +3900,7 @@ async function renderSSRDocument(options) {
|
|
|
3870
3900
|
var init_render = __esm(() => {
|
|
3871
3901
|
init_server2();
|
|
3872
3902
|
init_config();
|
|
3903
|
+
init_discovery3();
|
|
3873
3904
|
init_lib();
|
|
3874
3905
|
init_html();
|
|
3875
3906
|
});
|
|
@@ -4196,6 +4227,112 @@ var init_extractor = __esm(() => {
|
|
|
4196
4227
|
init_render();
|
|
4197
4228
|
});
|
|
4198
4229
|
|
|
4230
|
+
// packages/core/src/llms/discovery.ts
|
|
4231
|
+
function yesNo(value) {
|
|
4232
|
+
return value === false ? "no" : "yes";
|
|
4233
|
+
}
|
|
4234
|
+
function formatContentSignal(policy, whenUndefined = "omit") {
|
|
4235
|
+
if (policy === false)
|
|
4236
|
+
return;
|
|
4237
|
+
if (policy === undefined && whenUndefined === "omit")
|
|
4238
|
+
return;
|
|
4239
|
+
const resolved = {
|
|
4240
|
+
search: true,
|
|
4241
|
+
aiInput: true,
|
|
4242
|
+
aiTrain: true,
|
|
4243
|
+
...policy
|
|
4244
|
+
};
|
|
4245
|
+
return `ai-train=${yesNo(resolved.aiTrain)}, search=${yesNo(resolved.search)}, ai-input=${yesNo(resolved.aiInput)}`;
|
|
4246
|
+
}
|
|
4247
|
+
function markdownTwinPath(pathname) {
|
|
4248
|
+
const path2 = pathname.split("?")[0];
|
|
4249
|
+
if (path2 === "/" || path2 === "")
|
|
4250
|
+
return "/index.md";
|
|
4251
|
+
return `${path2.replace(/\/$/, "")}.md`;
|
|
4252
|
+
}
|
|
4253
|
+
function shouldAdvertiseMarkdownTwin(pathname, llmsConfig) {
|
|
4254
|
+
if (!llmsConfig?.enabled)
|
|
4255
|
+
return false;
|
|
4256
|
+
if (llmsConfig.enableMarkdownExtension === false)
|
|
4257
|
+
return false;
|
|
4258
|
+
if (shouldExcludeRoute(pathname, llmsConfig.excludeRoutes))
|
|
4259
|
+
return false;
|
|
4260
|
+
return true;
|
|
4261
|
+
}
|
|
4262
|
+
function llmsAlternateLinkTag(pathname, llmsConfig) {
|
|
4263
|
+
if (!shouldAdvertiseMarkdownTwin(pathname, llmsConfig))
|
|
4264
|
+
return "";
|
|
4265
|
+
return `<link rel="alternate" type="text/markdown" href="${markdownTwinPath(pathname)}" />`;
|
|
4266
|
+
}
|
|
4267
|
+
function mergeVary(existing, token) {
|
|
4268
|
+
const parts = (existing ?? "").split(",").map((part) => part.trim()).filter(Boolean);
|
|
4269
|
+
if (!parts.some((part) => part.toLowerCase() === token.toLowerCase())) {
|
|
4270
|
+
parts.push(token);
|
|
4271
|
+
}
|
|
4272
|
+
return parts.join(", ");
|
|
4273
|
+
}
|
|
4274
|
+
function appendLinkValues(existing, values) {
|
|
4275
|
+
const current = (existing ?? "").split(",").map((part) => part.trim()).filter(Boolean);
|
|
4276
|
+
for (const value of values) {
|
|
4277
|
+
if (!current.includes(value))
|
|
4278
|
+
current.push(value);
|
|
4279
|
+
}
|
|
4280
|
+
return current.join(", ");
|
|
4281
|
+
}
|
|
4282
|
+
function buildLlmsDiscovery(pathname, llmsConfig) {
|
|
4283
|
+
if (!llmsConfig?.enabled)
|
|
4284
|
+
return null;
|
|
4285
|
+
const linkValues = [];
|
|
4286
|
+
if (shouldAdvertiseMarkdownTwin(pathname, llmsConfig)) {
|
|
4287
|
+
linkValues.push(`<${markdownTwinPath(pathname)}>; rel="alternate"; type="text/markdown"`);
|
|
4288
|
+
}
|
|
4289
|
+
if (llmsConfig.enableIndex !== false) {
|
|
4290
|
+
linkValues.push('</llms.txt>; rel="llms-txt"');
|
|
4291
|
+
}
|
|
4292
|
+
const contentSignal = formatContentSignal(llmsConfig.contentSignal, "default");
|
|
4293
|
+
const vary = llmsConfig.enableContentNegotiation !== false ? "Accept" : undefined;
|
|
4294
|
+
if (linkValues.length === 0 && !contentSignal && !vary)
|
|
4295
|
+
return null;
|
|
4296
|
+
return { linkValues, contentSignal, vary };
|
|
4297
|
+
}
|
|
4298
|
+
function writeHeader(headers2, canonical, value) {
|
|
4299
|
+
const lower = canonical.toLowerCase();
|
|
4300
|
+
if (headers2[lower] !== undefined)
|
|
4301
|
+
headers2[lower] = value;
|
|
4302
|
+
if (headers2[canonical] !== undefined || headers2[lower] === undefined) {
|
|
4303
|
+
headers2[canonical] = value;
|
|
4304
|
+
}
|
|
4305
|
+
}
|
|
4306
|
+
function readHeader(headers2, canonical) {
|
|
4307
|
+
return headers2[canonical] ?? headers2[canonical.toLowerCase()];
|
|
4308
|
+
}
|
|
4309
|
+
function applyLlmsDiscoveryHeaders(headers2, pathname, llmsConfig, status = 200) {
|
|
4310
|
+
if (status < 200 || status >= 300)
|
|
4311
|
+
return;
|
|
4312
|
+
const discovery2 = buildLlmsDiscovery(pathname, llmsConfig);
|
|
4313
|
+
if (!discovery2)
|
|
4314
|
+
return;
|
|
4315
|
+
if (discovery2.linkValues.length > 0) {
|
|
4316
|
+
writeHeader(headers2, "Link", appendLinkValues(readHeader(headers2, "Link"), discovery2.linkValues));
|
|
4317
|
+
}
|
|
4318
|
+
if (discovery2.contentSignal) {
|
|
4319
|
+
writeHeader(headers2, "Content-Signal", discovery2.contentSignal);
|
|
4320
|
+
}
|
|
4321
|
+
if (discovery2.vary) {
|
|
4322
|
+
writeHeader(headers2, "Vary", mergeVary(readHeader(headers2, "Vary"), discovery2.vary));
|
|
4323
|
+
}
|
|
4324
|
+
}
|
|
4325
|
+
function appendLlmsAlternateHead(extraHead, pathname, status, llmsConfig) {
|
|
4326
|
+
if (status !== 200)
|
|
4327
|
+
return extraHead;
|
|
4328
|
+
const tag = llmsAlternateLinkTag(pathname, llmsConfig);
|
|
4329
|
+
return tag ? `${extraHead}
|
|
4330
|
+
${tag}` : extraHead;
|
|
4331
|
+
}
|
|
4332
|
+
var init_discovery3 = __esm(() => {
|
|
4333
|
+
init_extractor();
|
|
4334
|
+
});
|
|
4335
|
+
|
|
4199
4336
|
// packages/core/src/llms/index-generator.ts
|
|
4200
4337
|
var exports_index_generator = {};
|
|
4201
4338
|
__export(exports_index_generator, {
|
|
@@ -4698,6 +4835,7 @@ var init_full_generator = __esm(() => {
|
|
|
4698
4835
|
|
|
4699
4836
|
// packages/core/src/llms/index.ts
|
|
4700
4837
|
var init_llms = __esm(() => {
|
|
4838
|
+
init_discovery3();
|
|
4701
4839
|
init_extractor();
|
|
4702
4840
|
init_full_generator();
|
|
4703
4841
|
init_index_generator();
|
|
@@ -4864,7 +5002,7 @@ async function discoverRobotsData(cwd, isWatchMode, robotsConfig, sitemapConfig,
|
|
|
4864
5002
|
redirectSourcePaths
|
|
4865
5003
|
};
|
|
4866
5004
|
}
|
|
4867
|
-
var
|
|
5005
|
+
var init_discovery4 = () => {};
|
|
4868
5006
|
|
|
4869
5007
|
// packages/core/src/robots/generator.ts
|
|
4870
5008
|
function getEffectivePolicies(policies) {
|
|
@@ -4907,8 +5045,16 @@ function addDisallowDirectives(lines, policy, autoDisallows) {
|
|
|
4907
5045
|
}
|
|
4908
5046
|
}
|
|
4909
5047
|
}
|
|
4910
|
-
function
|
|
5048
|
+
function addContentSignalLine(lines, policy, robotsConfig) {
|
|
5049
|
+
if (policy.userAgent !== "*")
|
|
5050
|
+
return;
|
|
5051
|
+
const value = formatContentSignal(robotsConfig.contentSignal);
|
|
5052
|
+
if (value)
|
|
5053
|
+
lines.push(`Content-Signal: ${value}`);
|
|
5054
|
+
}
|
|
5055
|
+
function addPolicyBlock(lines, policy, autoDisallows, robotsConfig) {
|
|
4911
5056
|
lines.push(`User-agent: ${policy.userAgent}`);
|
|
5057
|
+
addContentSignalLine(lines, policy, robotsConfig);
|
|
4912
5058
|
addAllowDirectives(lines, policy);
|
|
4913
5059
|
addDisallowDirectives(lines, policy, autoDisallows);
|
|
4914
5060
|
if (policy.crawlDelay !== undefined) {
|
|
@@ -4934,7 +5080,7 @@ function generateRobots(discovery2, robotsConfig, sitemapEnabled) {
|
|
|
4934
5080
|
const effectivePolicies = getEffectivePolicies(policies);
|
|
4935
5081
|
const autoDisallows = getAutoDisallows(discovery2);
|
|
4936
5082
|
for (const policy of effectivePolicies) {
|
|
4937
|
-
addPolicyBlock(lines, policy, autoDisallows);
|
|
5083
|
+
addPolicyBlock(lines, policy, autoDisallows, robotsConfig);
|
|
4938
5084
|
}
|
|
4939
5085
|
addGlobalCrawlDelay(lines, crawlDelay, effectivePolicies);
|
|
4940
5086
|
if (customRules) {
|
|
@@ -4946,6 +5092,9 @@ function generateRobots(discovery2, robotsConfig, sitemapEnabled) {
|
|
|
4946
5092
|
`).trim()}
|
|
4947
5093
|
`;
|
|
4948
5094
|
}
|
|
5095
|
+
var init_generator = __esm(() => {
|
|
5096
|
+
init_discovery3();
|
|
5097
|
+
});
|
|
4949
5098
|
|
|
4950
5099
|
// packages/core/src/robots/policies.ts
|
|
4951
5100
|
function blockAICrawlers(crawlers) {
|
|
@@ -5016,7 +5165,8 @@ var init_policies = __esm(() => {
|
|
|
5016
5165
|
|
|
5017
5166
|
// packages/core/src/robots/index.ts
|
|
5018
5167
|
var init_robots = __esm(() => {
|
|
5019
|
-
|
|
5168
|
+
init_discovery4();
|
|
5169
|
+
init_generator();
|
|
5020
5170
|
init_policies();
|
|
5021
5171
|
});
|
|
5022
5172
|
|
|
@@ -5349,7 +5499,7 @@ async function discoverSitemapData(cwd, collections2, baseUrl, isWatchMode, site
|
|
|
5349
5499
|
ssrDataRoutes
|
|
5350
5500
|
};
|
|
5351
5501
|
}
|
|
5352
|
-
var
|
|
5502
|
+
var init_discovery5 = () => {};
|
|
5353
5503
|
|
|
5354
5504
|
// packages/core/src/rss/discovery.ts
|
|
5355
5505
|
import { pathToFileURL as pathToFileURL7 } from "node:url";
|
|
@@ -5617,7 +5767,7 @@ async function discoverRSSData(cwd, collections2, baseUrl, isWatchMode, rssConfi
|
|
|
5617
5767
|
}
|
|
5618
5768
|
const ssrDataFeeds = new Map;
|
|
5619
5769
|
const bundledRoutes = globalThis.__REROUTE_ROUTES__;
|
|
5620
|
-
const { discoverRoutes: discoverRoutes2 } = await Promise.resolve().then(() => (
|
|
5770
|
+
const { discoverRoutes: discoverRoutes2 } = await Promise.resolve().then(() => (init_discovery5(), exports_discovery));
|
|
5621
5771
|
const { staticRoutes } = await discoverRoutes2(cwd, isWatchMode);
|
|
5622
5772
|
if (bundledRoutes && Array.isArray(bundledRoutes)) {
|
|
5623
5773
|
const routePromises = staticRoutes.map(async (route) => {
|
|
@@ -5674,7 +5824,7 @@ async function discoverRSSData(cwd, collections2, baseUrl, isWatchMode, rssConfi
|
|
|
5674
5824
|
ssrDataFeeds
|
|
5675
5825
|
};
|
|
5676
5826
|
}
|
|
5677
|
-
var
|
|
5827
|
+
var init_discovery6 = () => {};
|
|
5678
5828
|
|
|
5679
5829
|
// packages/core/src/rss/generator.ts
|
|
5680
5830
|
function generateRSSXML(feed, options = {}) {
|
|
@@ -5787,7 +5937,7 @@ function escapeXml(unsafe) {
|
|
|
5787
5937
|
|
|
5788
5938
|
// packages/core/src/rss/index.ts
|
|
5789
5939
|
var init_rss = __esm(() => {
|
|
5790
|
-
|
|
5940
|
+
init_discovery6();
|
|
5791
5941
|
});
|
|
5792
5942
|
|
|
5793
5943
|
// packages/core/src/sitemap/generator.ts
|
|
@@ -5932,12 +6082,12 @@ function escapeXml2(unsafe) {
|
|
|
5932
6082
|
return unsafe.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
5933
6083
|
}
|
|
5934
6084
|
var DEFAULT_MAX_URLS = 50000;
|
|
5935
|
-
var
|
|
6085
|
+
var init_generator2 = () => {};
|
|
5936
6086
|
|
|
5937
6087
|
// packages/core/src/sitemap/index.ts
|
|
5938
6088
|
var init_sitemap = __esm(() => {
|
|
5939
|
-
|
|
5940
|
-
|
|
6089
|
+
init_discovery5();
|
|
6090
|
+
init_generator2();
|
|
5941
6091
|
});
|
|
5942
6092
|
|
|
5943
6093
|
// packages/core/src/ssr/stream.ts
|
|
@@ -6015,15 +6165,16 @@ async function renderSSRDocumentStream(options) {
|
|
|
6015
6165
|
const newAttrs = hasLang ? attrs.replace(/lang\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/i, `lang="${pageLang}"`) : `${attrs} lang="${pageLang}"`;
|
|
6016
6166
|
return `<html${newAttrs}>`;
|
|
6017
6167
|
});
|
|
6018
|
-
const
|
|
6019
|
-
if (/<title[\s\S]*?<\/title>/i.test(
|
|
6168
|
+
const extraHeadBase = setup2.bundlePreload + setup2.preloadExtraHead + setup2.metadataResult.perPageHead;
|
|
6169
|
+
if (/<title[\s\S]*?<\/title>/i.test(extraHeadBase)) {
|
|
6020
6170
|
headWithLang = headWithLang.replace(/<title[\s\S]*?<\/title>/i, "");
|
|
6021
6171
|
}
|
|
6022
|
-
if (/<meta\s+name\s*=\s*['"]description['"][^>]*>/i.test(
|
|
6172
|
+
if (/<meta\s+name\s*=\s*['"]description['"][^>]*>/i.test(extraHeadBase)) {
|
|
6023
6173
|
headWithLang = headWithLang.replace(/<meta\s+name\s*=\s*['"]description['"][^>]*>/i, "");
|
|
6024
6174
|
}
|
|
6025
|
-
headWithLang = removeOverriddenMetaTags(headWithLang,
|
|
6175
|
+
headWithLang = removeOverriddenMetaTags(headWithLang, extraHeadBase);
|
|
6026
6176
|
const config = await loadConfig(cwd);
|
|
6177
|
+
const extraHead = appendLlmsAlternateHead(extraHeadBase, pathname, statusOverride || 200, config.llms);
|
|
6027
6178
|
const browserTelemetryConfigRaw = config.telemetry?.browser;
|
|
6028
6179
|
const { serializeBrowserTelemetryConfig: serializeBrowserTelemetryConfig2 } = await Promise.resolve().then(() => exports_serialize);
|
|
6029
6180
|
const browserTelemetryConfig = serializeBrowserTelemetryConfig2(browserTelemetryConfigRaw);
|
|
@@ -6281,6 +6432,7 @@ function unescapeHtmlEntities(str) {
|
|
|
6281
6432
|
var init_stream = __esm(() => {
|
|
6282
6433
|
init_server2();
|
|
6283
6434
|
init_config();
|
|
6435
|
+
init_discovery3();
|
|
6284
6436
|
init_lib();
|
|
6285
6437
|
init_html();
|
|
6286
6438
|
init_imports();
|
|
@@ -6327,12 +6479,15 @@ export {
|
|
|
6327
6479
|
acceptsGzip,
|
|
6328
6480
|
allowAICrawlers,
|
|
6329
6481
|
allowSearchCrawlers,
|
|
6482
|
+
appendLlmsAlternateHead,
|
|
6330
6483
|
applyIndexTemplate,
|
|
6484
|
+
applyLlmsDiscoveryHeaders,
|
|
6331
6485
|
basename,
|
|
6332
6486
|
blockAICrawlers,
|
|
6333
6487
|
blockAITrainingCrawlers,
|
|
6334
6488
|
blockSearchCrawlers,
|
|
6335
6489
|
buildHeadFromMeta,
|
|
6490
|
+
buildLlmsDiscovery,
|
|
6336
6491
|
buildLocaleCookie,
|
|
6337
6492
|
cleanupPathScopedSSRData,
|
|
6338
6493
|
clearSSRModuleStores,
|
|
@@ -6378,6 +6533,7 @@ export {
|
|
|
6378
6533
|
findOGImageForPath,
|
|
6379
6534
|
formatAsMarkdown,
|
|
6380
6535
|
formatAsText,
|
|
6536
|
+
formatContentSignal,
|
|
6381
6537
|
formatMessage,
|
|
6382
6538
|
generateAtomXML,
|
|
6383
6539
|
generateCollectionScripts,
|
|
@@ -6409,6 +6565,7 @@ export {
|
|
|
6409
6565
|
isThenable,
|
|
6410
6566
|
join,
|
|
6411
6567
|
listContentFiles,
|
|
6568
|
+
llmsAlternateLinkTag,
|
|
6412
6569
|
loadCollections,
|
|
6413
6570
|
loadConfig,
|
|
6414
6571
|
loadIndexHtml,
|
|
@@ -6418,9 +6575,11 @@ export {
|
|
|
6418
6575
|
localizeHref,
|
|
6419
6576
|
looksLikeLocale,
|
|
6420
6577
|
lookupMessage,
|
|
6578
|
+
markdownTwinPath,
|
|
6421
6579
|
matchRoutePattern,
|
|
6422
6580
|
matchRoutes,
|
|
6423
6581
|
mergeLayoutData,
|
|
6582
|
+
mergeVary,
|
|
6424
6583
|
negotiateLocale,
|
|
6425
6584
|
normalizePathname,
|
|
6426
6585
|
parseContentPath,
|
|
@@ -6433,10 +6592,12 @@ export {
|
|
|
6433
6592
|
renderSSRDocument,
|
|
6434
6593
|
renderSSRDocumentStream,
|
|
6435
6594
|
resetSSRAccessTracking,
|
|
6595
|
+
resetSSRContentResults,
|
|
6436
6596
|
resolveLocale,
|
|
6437
6597
|
seedSSRModuleForPath,
|
|
6438
6598
|
setGlobalCollections,
|
|
6439
6599
|
setGlobalSSRData,
|
|
6600
|
+
shouldAdvertiseMarkdownTwin,
|
|
6440
6601
|
shouldExcludeRoute,
|
|
6441
6602
|
splitTemplate,
|
|
6442
6603
|
ssrCache,
|
|
@@ -6444,9 +6605,10 @@ export {
|
|
|
6444
6605
|
stripEnd,
|
|
6445
6606
|
stripHtmlTags,
|
|
6446
6607
|
stripStart,
|
|
6608
|
+
takeSSRContentResults,
|
|
6447
6609
|
toBytes,
|
|
6448
6610
|
toOgLocale,
|
|
6449
6611
|
toPromise
|
|
6450
6612
|
};
|
|
6451
6613
|
|
|
6452
|
-
//# debugId=
|
|
6614
|
+
//# debugId=B1DFB764A57413D364756E2164756E21
|