reroute-js 1.0.0-alpha.4 → 1.0.0-alpha.5
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 +733 -669
- package/cli/bin.js.map +10 -10
- package/cli/index.d.ts +1 -1
- package/cli/index.js +37 -25
- package/cli/index.js.map +3 -3
- 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 +5 -6
- package/cli/src/commands/dev.d.ts.map +1 -1
- package/cli/src/commands/gen.d.ts +4 -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 +2 -1
- package/cli/src/commands/lib/server.d.ts.map +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 +201 -158
- package/core/index.js.map +5 -5
- 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/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/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/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 +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 +8 -3
- package/core/src/ssr/lib/imports.d.ts.map +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 +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 +6 -1
- package/core/src/ssr/lib/seed.d.ts.map +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 +278 -209
- package/elysia/index.js.map +11 -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/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 +2 -2
- package/elysia/src/routes/content.d.ts.map +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/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 +1 -1
- package/elysia/src/routes/static.d.ts +1 -1
- package/elysia/src/routes/themeCssRefresh.d.ts +17 -0
- package/elysia/src/routes/themeCssRefresh.d.ts.map +1 -0
- package/elysia/src/types.d.ts +1 -1
- package/package.json +1 -1
- package/react/index.d.ts +1 -1
- package/react/index.js +71 -71
- 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/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 +16 -16
- package/telemetry/react.js.map +2 -2
- package/telemetry/server.d.ts +1 -1
- package/telemetry/server.js +28 -220
- package/telemetry/server.js.map +5 -4
- 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 v1.0.0-alpha.
|
|
2
|
+
* reroute-js v1.0.0-alpha.5
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2026 stewones <hi@stewan.io>
|
|
@@ -390,14 +390,14 @@ var init_negotiate = () => {};
|
|
|
390
390
|
// packages/core/src/i18n/pathname.ts
|
|
391
391
|
var exports_pathname = {};
|
|
392
392
|
__export(exports_pathname, {
|
|
393
|
-
|
|
394
|
-
parseContentPath: () => parseContentPath,
|
|
395
|
-
normalizePathname: () => normalizePathname,
|
|
396
|
-
looksLikeLocale: () => looksLikeLocale,
|
|
397
|
-
localizeHref: () => localizeHref,
|
|
398
|
-
localizeContentHref: () => localizeContentHref,
|
|
393
|
+
contentKey: () => contentKey,
|
|
399
394
|
hreflangTags: () => hreflangTags,
|
|
400
|
-
|
|
395
|
+
localizeContentHref: () => localizeContentHref,
|
|
396
|
+
localizeHref: () => localizeHref,
|
|
397
|
+
looksLikeLocale: () => looksLikeLocale,
|
|
398
|
+
normalizePathname: () => normalizePathname,
|
|
399
|
+
parseContentPath: () => parseContentPath,
|
|
400
|
+
toOgLocale: () => toOgLocale
|
|
401
401
|
});
|
|
402
402
|
function looksLikeLocale(segment) {
|
|
403
403
|
return /^[a-z]{2}(?:-[A-Za-z0-9]{2,8})*$/i.test(segment);
|
|
@@ -1049,11 +1049,39 @@ function cleanupPathScopedSSRData(pathname) {
|
|
|
1049
1049
|
}
|
|
1050
1050
|
|
|
1051
1051
|
// packages/core/src/ssr/lib/imports.ts
|
|
1052
|
+
import { copyFile, realpath, stat as stat3, unlink } from "node:fs/promises";
|
|
1053
|
+
import { basename as basename2, dirname, extname as extname2, join as join3 } from "node:path";
|
|
1052
1054
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
1055
|
+
function clearWatchImportCache() {
|
|
1056
|
+
watchImportCache.clear();
|
|
1057
|
+
}
|
|
1058
|
+
function bustCopyPath(absolutePath) {
|
|
1059
|
+
const dir = dirname(absolutePath);
|
|
1060
|
+
const ext = extname2(absolutePath);
|
|
1061
|
+
const base = basename2(absolutePath, ext);
|
|
1062
|
+
const token = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
1063
|
+
return join3(dir, `${base}.bust-${token}${ext}`);
|
|
1064
|
+
}
|
|
1053
1065
|
async function dynamicImport(absolutePath, isWatchMode) {
|
|
1054
1066
|
const href = pathToFileURL3(absolutePath).href;
|
|
1055
|
-
|
|
1056
|
-
|
|
1067
|
+
if (!isWatchMode) {
|
|
1068
|
+
return await import(href);
|
|
1069
|
+
}
|
|
1070
|
+
const resolved = await realpath(absolutePath);
|
|
1071
|
+
const mtimeMs = (await stat3(resolved)).mtimeMs;
|
|
1072
|
+
const cached = watchImportCache.get(resolved);
|
|
1073
|
+
if (cached && cached.mtimeMs === mtimeMs) {
|
|
1074
|
+
return cached.mod;
|
|
1075
|
+
}
|
|
1076
|
+
const tmp = bustCopyPath(resolved);
|
|
1077
|
+
await copyFile(resolved, tmp);
|
|
1078
|
+
try {
|
|
1079
|
+
const mod = await import(pathToFileURL3(tmp).href);
|
|
1080
|
+
watchImportCache.set(resolved, { mtimeMs, mod });
|
|
1081
|
+
return mod;
|
|
1082
|
+
} finally {
|
|
1083
|
+
await unlink(tmp).catch(() => {});
|
|
1084
|
+
}
|
|
1057
1085
|
}
|
|
1058
1086
|
function isThenable(value) {
|
|
1059
1087
|
return typeof value === "object" && value !== null && typeof value.then === "function";
|
|
@@ -1061,7 +1089,10 @@ function isThenable(value) {
|
|
|
1061
1089
|
function toPromise(input) {
|
|
1062
1090
|
return input instanceof Promise ? input : Promise.resolve(input);
|
|
1063
1091
|
}
|
|
1064
|
-
var
|
|
1092
|
+
var watchImportCache;
|
|
1093
|
+
var init_imports = __esm(() => {
|
|
1094
|
+
watchImportCache = new Map;
|
|
1095
|
+
});
|
|
1065
1096
|
|
|
1066
1097
|
// packages/core/src/ssr/lib/collections.ts
|
|
1067
1098
|
async function loadCollections(cwd, isWatchMode) {
|
|
@@ -1851,7 +1882,7 @@ var init_compute = __esm(() => {
|
|
|
1851
1882
|
});
|
|
1852
1883
|
|
|
1853
1884
|
// packages/core/src/ssr/lib/modules.ts
|
|
1854
|
-
import { readdir as readdir3, stat as
|
|
1885
|
+
import { readdir as readdir3, stat as stat4 } from "node:fs/promises";
|
|
1855
1886
|
async function importContentModuleForPath(pathname, clientDir, cwd, isWatchMode) {
|
|
1856
1887
|
try {
|
|
1857
1888
|
const resolved = resolveContentPathParts(pathname);
|
|
@@ -1909,7 +1940,7 @@ async function tryChunkImport(collection, name, cwd, isWatchMode) {
|
|
|
1909
1940
|
let latestM = 0;
|
|
1910
1941
|
for (const f of matches) {
|
|
1911
1942
|
try {
|
|
1912
|
-
const s = await
|
|
1943
|
+
const s = await stat4(join(chunkDir, f));
|
|
1913
1944
|
if (s.mtimeMs >= latestM) {
|
|
1914
1945
|
latestM = s.mtimeMs;
|
|
1915
1946
|
latest = f;
|
|
@@ -1966,6 +1997,16 @@ function touchModule(key) {
|
|
|
1966
1997
|
evictLRUModule();
|
|
1967
1998
|
}
|
|
1968
1999
|
}
|
|
2000
|
+
function clearSSRModuleStores() {
|
|
2001
|
+
const g = globalThis;
|
|
2002
|
+
if (g.__REROUTE_SSR_MODULES__) {
|
|
2003
|
+
g.__REROUTE_SSR_MODULES__ = {};
|
|
2004
|
+
}
|
|
2005
|
+
if (g.__REROUTE_SSR_EXPORTS__) {
|
|
2006
|
+
g.__REROUTE_SSR_EXPORTS__ = {};
|
|
2007
|
+
}
|
|
2008
|
+
moduleAccessOrder.length = 0;
|
|
2009
|
+
}
|
|
1969
2010
|
async function seedSSRModuleForPath(pathname, clientDir, cwd, isWatchMode) {
|
|
1970
2011
|
try {
|
|
1971
2012
|
const resolved = resolveContentPathParts(pathname);
|
|
@@ -2950,7 +2991,7 @@ var init_metadata2 = __esm(() => {
|
|
|
2950
2991
|
});
|
|
2951
2992
|
|
|
2952
2993
|
// packages/core/src/ssr/lib/preload.ts
|
|
2953
|
-
import { readdir as readdir5, stat as
|
|
2994
|
+
import { readdir as readdir5, stat as stat5 } from "node:fs/promises";
|
|
2954
2995
|
async function preloadContentModule(pathname, clientDir, cwd, isWatchMode) {
|
|
2955
2996
|
let extraHead = "";
|
|
2956
2997
|
let hydrationScript = "";
|
|
@@ -2984,14 +3025,14 @@ async function isContentCollection(clientDir, collection) {
|
|
|
2984
3025
|
if (isProduction) {
|
|
2985
3026
|
const collectionFile = join(clientDir, "collections", `${collection}.js`);
|
|
2986
3027
|
try {
|
|
2987
|
-
const s2 = await
|
|
3028
|
+
const s2 = await stat5(collectionFile);
|
|
2988
3029
|
return s2?.isFile() ?? false;
|
|
2989
3030
|
} catch {
|
|
2990
3031
|
return false;
|
|
2991
3032
|
}
|
|
2992
3033
|
}
|
|
2993
3034
|
const maybeDir = join(clientDir, "routes", collection, "content");
|
|
2994
|
-
const s = await
|
|
3035
|
+
const s = await stat5(maybeDir);
|
|
2995
3036
|
return typeof s?.isDirectory === "function" ? s.isDirectory() : true;
|
|
2996
3037
|
} catch {
|
|
2997
3038
|
return false;
|
|
@@ -3002,7 +3043,7 @@ async function findLatestCandidate(chunkDir, candidates) {
|
|
|
3002
3043
|
let latestM = 0;
|
|
3003
3044
|
for (const candidateName of candidates) {
|
|
3004
3045
|
try {
|
|
3005
|
-
const s = await
|
|
3046
|
+
const s = await stat5(join(chunkDir, candidateName));
|
|
3006
3047
|
if (s.mtimeMs >= latestM) {
|
|
3007
3048
|
latestM = s.mtimeMs;
|
|
3008
3049
|
latest = candidateName;
|
|
@@ -3390,15 +3431,15 @@ var init_scripts = __esm(() => {
|
|
|
3390
3431
|
// packages/core/src/ssr/lib/styles.ts
|
|
3391
3432
|
async function inlineThemeCSS(clientDir, minify = false, isWatchMode = false) {
|
|
3392
3433
|
try {
|
|
3434
|
+
if (isWatchMode) {
|
|
3435
|
+
const timestamp = Date.now();
|
|
3436
|
+
return `<link rel="stylesheet" href="/.reroute/index.css?t=${timestamp}" data-reroute="theme">`;
|
|
3437
|
+
}
|
|
3393
3438
|
const bundledCss = globalThis.__REROUTE_THEME_CSS__;
|
|
3394
3439
|
if (bundledCss) {
|
|
3395
3440
|
const css2 = minify ? minifyCSS(bundledCss) : bundledCss;
|
|
3396
3441
|
return `<style data-reroute="theme">${css2}</style>`;
|
|
3397
3442
|
}
|
|
3398
|
-
if (isWatchMode) {
|
|
3399
|
-
const timestamp = Date.now();
|
|
3400
|
-
return `<link rel="stylesheet" href="/.reroute/index.css?t=${timestamp}" data-reroute="theme">`;
|
|
3401
|
-
}
|
|
3402
3443
|
const candidates = [
|
|
3403
3444
|
join(clientDir, "..", ".reroute", "index.css"),
|
|
3404
3445
|
join(clientDir, "..", "..", ".reroute", "index.css"),
|
|
@@ -4117,10 +4158,10 @@ var init_extractor = __esm(() => {
|
|
|
4117
4158
|
// packages/core/src/llms/index-generator.ts
|
|
4118
4159
|
var exports_index_generator = {};
|
|
4119
4160
|
__export(exports_index_generator, {
|
|
4120
|
-
|
|
4121
|
-
discoverStaticRoutes: () => discoverStaticRoutes,
|
|
4161
|
+
discoverCollectionRoutes: () => discoverCollectionRoutes,
|
|
4122
4162
|
discoverSSRDataRoutes: () => discoverSSRDataRoutes,
|
|
4123
|
-
|
|
4163
|
+
discoverStaticRoutes: () => discoverStaticRoutes,
|
|
4164
|
+
generateLLMsIndex: () => generateLLMsIndex
|
|
4124
4165
|
});
|
|
4125
4166
|
import { pathToFileURL as pathToFileURL6 } from "node:url";
|
|
4126
4167
|
async function discoverStaticRoutes(cwd, isWatchMode) {
|
|
@@ -4903,10 +4944,10 @@ var init_robots = __esm(() => {
|
|
|
4903
4944
|
// packages/core/src/sitemap/discovery.ts
|
|
4904
4945
|
var exports_discovery = {};
|
|
4905
4946
|
__export(exports_discovery, {
|
|
4906
|
-
|
|
4907
|
-
discoverSSRDataRoutes: () => discoverSSRDataRoutes2,
|
|
4947
|
+
discoverCollectionContent: () => discoverCollectionContent,
|
|
4908
4948
|
discoverRoutes: () => discoverRoutes,
|
|
4909
|
-
|
|
4949
|
+
discoverSSRDataRoutes: () => discoverSSRDataRoutes2,
|
|
4950
|
+
discoverSitemapData: () => discoverSitemapData
|
|
4910
4951
|
});
|
|
4911
4952
|
async function loadRoutesModule2(cwd, isWatchMode) {
|
|
4912
4953
|
let routes = globalThis.__REROUTE_ROUTES__;
|
|
@@ -6190,137 +6231,139 @@ var init_src = __esm(() => {
|
|
|
6190
6231
|
// packages/core/index.ts
|
|
6191
6232
|
var exports_core = {};
|
|
6192
6233
|
__export(exports_core, {
|
|
6193
|
-
|
|
6194
|
-
toOgLocale: () => toOgLocale,
|
|
6195
|
-
toBytes: () => toBytes,
|
|
6196
|
-
stripStart: () => stripStart,
|
|
6197
|
-
stripHtmlTags: () => stripHtmlTags,
|
|
6198
|
-
stripEnd: () => stripEnd,
|
|
6199
|
-
statusCache: () => statusCache,
|
|
6200
|
-
ssrCache: () => ssrCache,
|
|
6201
|
-
splitTemplate: () => splitTemplate,
|
|
6202
|
-
shouldExcludeRoute: () => shouldExcludeRoute,
|
|
6203
|
-
setGlobalSSRData: () => setGlobalSSRData,
|
|
6204
|
-
setGlobalCollections: () => setGlobalCollections,
|
|
6205
|
-
seedSSRModuleForPath: () => seedSSRModuleForPath,
|
|
6206
|
-
resolveLocale: () => resolveLocale,
|
|
6207
|
-
resetSSRAccessTracking: () => resetSSRAccessTracking,
|
|
6208
|
-
renderSSRDocumentStream: () => renderSSRDocumentStream,
|
|
6209
|
-
renderSSRDocument: () => renderSSRDocument,
|
|
6210
|
-
renderOGImageToPNG: () => renderOGImageToPNG,
|
|
6211
|
-
removeOverriddenMetaTags: () => removeOverriddenMetaTags,
|
|
6212
|
-
processCollections: () => processCollections,
|
|
6213
|
-
preloadContentModule: () => preloadContentModule,
|
|
6214
|
-
performSSRSetup: () => performSSRSetup,
|
|
6215
|
-
parseCookieValue: () => parseCookieValue,
|
|
6216
|
-
parseContentPath: () => parseContentPath,
|
|
6217
|
-
normalizePathname: () => normalizePathname,
|
|
6218
|
-
negotiateLocale: () => negotiateLocale,
|
|
6219
|
-
mergeLayoutData: () => mergeLayoutData,
|
|
6220
|
-
matchRoutes: () => matchRoutes,
|
|
6221
|
-
matchRoutePattern: () => matchRoutePattern,
|
|
6222
|
-
lookupMessage: () => lookupMessage,
|
|
6223
|
-
looksLikeLocale: () => looksLikeLocale,
|
|
6224
|
-
localizeHref: () => localizeHref,
|
|
6225
|
-
localizeContentHref: () => localizeContentHref,
|
|
6226
|
-
loadRoutesModule: () => loadRoutesModule,
|
|
6227
|
-
loadOGImageComponent: () => loadOGImageComponent,
|
|
6228
|
-
loadIndexHtml: () => loadIndexHtml,
|
|
6229
|
-
loadConfig: () => loadConfig,
|
|
6230
|
-
loadCollections: () => loadCollections,
|
|
6231
|
-
listContentFiles: () => listContentFiles,
|
|
6232
|
-
join: () => join,
|
|
6233
|
-
isThenable: () => isThenable,
|
|
6234
|
-
isCompressible: () => isCompressible,
|
|
6235
|
-
inlineThemeCSS: () => inlineThemeCSS,
|
|
6236
|
-
importContentModuleForPath: () => importContentModuleForPath,
|
|
6237
|
-
htmlToMarkdown: () => htmlToMarkdown,
|
|
6238
|
-
hreflangTags: () => hreflangTags,
|
|
6239
|
-
gzipIfAccepted: () => gzipIfAccepted,
|
|
6240
|
-
getSitemapExcludedRoutes: () => getSitemapExcludedRoutes,
|
|
6241
|
-
getRedirectSourcePaths: () => getRedirectSourcePaths,
|
|
6242
|
-
getPatternDepth: () => getPatternDepth,
|
|
6243
|
-
getMimeType: () => getMimeType,
|
|
6244
|
-
getMessage: () => getMessage,
|
|
6245
|
-
getMatchingLayouts: () => getMatchingLayouts,
|
|
6246
|
-
getContentMeta: () => getContentMeta,
|
|
6247
|
-
generateSitemapXML: () => generateSitemapXML,
|
|
6248
|
-
generateSitemapIndexXML: () => generateSitemapIndexXML,
|
|
6249
|
-
generateSitemap: () => generateSitemap,
|
|
6250
|
-
generateRobots: () => generateRobots,
|
|
6251
|
-
generateRSSXML: () => generateRSSXML,
|
|
6252
|
-
generateOGImageMetaTags: () => generateOGImageMetaTags,
|
|
6253
|
-
generateLLMsIndex: () => generateLLMsIndex,
|
|
6254
|
-
generateLLMsFullContent: () => generateLLMsFullContent,
|
|
6255
|
-
generateLLMsFooter: () => generateLLMsFooter,
|
|
6256
|
-
generateHydrationScripts: () => generateHydrationScripts,
|
|
6257
|
-
generateFeed: () => generateFeed,
|
|
6258
|
-
generateContentHash: () => generateContentHash,
|
|
6259
|
-
generateCollectionScripts: () => generateCollectionScripts,
|
|
6260
|
-
generateAtomXML: () => generateAtomXML,
|
|
6261
|
-
formatMessage: () => formatMessage,
|
|
6262
|
-
formatAsText: () => formatAsText,
|
|
6263
|
-
formatAsMarkdown: () => formatAsMarkdown,
|
|
6264
|
-
findOGImageForPath: () => findOGImageForPath,
|
|
6265
|
-
extractTitle: () => extractTitle,
|
|
6266
|
-
extractParamsFromPath: () => extractParamsFromPath,
|
|
6267
|
-
extractPageMetadata: () => extractPageMetadata,
|
|
6268
|
-
extractContentForLLMs: () => extractContentForLLMs,
|
|
6269
|
-
extname: () => extname,
|
|
6270
|
-
escapeXml: () => escapeXml2,
|
|
6271
|
-
escapeJsonForScript: () => escapeJsonForScript,
|
|
6272
|
-
dynamicImport: () => dynamicImport,
|
|
6273
|
-
duplicateQueryParamData: () => duplicateQueryParamData,
|
|
6274
|
-
discoverSitemapData: () => discoverSitemapData,
|
|
6275
|
-
discoverSSRDataRoutes: () => discoverSSRDataRoutes2,
|
|
6276
|
-
discoverSSRDataFeedItems: () => discoverSSRDataFeedItems,
|
|
6277
|
-
discoverRoutesForRobots: () => discoverRoutesForRobots,
|
|
6278
|
-
discoverRoutes: () => discoverRoutes,
|
|
6279
|
-
discoverRobotsData: () => discoverRobotsData,
|
|
6280
|
-
discoverRSSData: () => discoverRSSData,
|
|
6281
|
-
discoverI18n: () => discoverI18n,
|
|
6282
|
-
discoverCollections: () => discoverCollections,
|
|
6283
|
-
discoverCollectionContent: () => discoverCollectionContent,
|
|
6284
|
-
defineConfig: () => defineConfig,
|
|
6285
|
-
deduplicateMetaTags: () => deduplicateMetaTags,
|
|
6286
|
-
createTranslator: () => createTranslator,
|
|
6287
|
-
createLlmsScript: () => createLlmsScript,
|
|
6288
|
-
createLayoutDataKey: () => createLayoutDataKey,
|
|
6289
|
-
createLayoutCacheKey: () => createLayoutCacheKey,
|
|
6290
|
-
createFeedsScript: () => createFeedsScript,
|
|
6291
|
-
createDataScript: () => createDataScript,
|
|
6292
|
-
createCollectionScript: () => createCollectionScript,
|
|
6293
|
-
createBundlePreload: () => createBundlePreload,
|
|
6294
|
-
contentNegotiateRedirect: () => contentNegotiateRedirect,
|
|
6295
|
-
contentKey: () => contentKey,
|
|
6296
|
-
computeSSRDataForPath: () => computeSSRDataForPath,
|
|
6297
|
-
computeSSRData: () => computeSSRData,
|
|
6298
|
-
computeRouteData: () => computeRouteData,
|
|
6299
|
-
computeLayoutData: () => computeLayoutData,
|
|
6300
|
-
computeContentData: () => computeContentData,
|
|
6301
|
-
compressStreamIfAccepted: () => compressStreamIfAccepted,
|
|
6302
|
-
compareRouteSpecificity: () => compareRouteSpecificity,
|
|
6303
|
-
cleanupPathScopedSSRData: () => cleanupPathScopedSSRData,
|
|
6304
|
-
buildLocaleCookie: () => buildLocaleCookie,
|
|
6305
|
-
buildHeadFromMeta: () => buildHeadFromMeta,
|
|
6306
|
-
blockSearchCrawlers: () => blockSearchCrawlers,
|
|
6307
|
-
blockAITrainingCrawlers: () => blockAITrainingCrawlers,
|
|
6308
|
-
blockAICrawlers: () => blockAICrawlers,
|
|
6309
|
-
basename: () => basename,
|
|
6310
|
-
applyIndexTemplate: () => applyIndexTemplate,
|
|
6311
|
-
allowSearchCrawlers: () => allowSearchCrawlers,
|
|
6312
|
-
allowAICrawlers: () => allowAICrawlers,
|
|
6313
|
-
acceptsGzip: () => acceptsGzip,
|
|
6314
|
-
acceptsBrotli: () => acceptsBrotli,
|
|
6315
|
-
TTLCache: () => TTLCache,
|
|
6316
|
-
SSRDataCache: () => SSRDataCache,
|
|
6317
|
-
SEARCH_CRAWLERS: () => SEARCH_CRAWLERS,
|
|
6318
|
-
LRUCache: () => LRUCache,
|
|
6319
|
-
DefaultOGTemplate: () => DefaultOGTemplate,
|
|
6320
|
-
DEFAULT_LOCALES_DIR: () => DEFAULT_LOCALES_DIR,
|
|
6321
|
-
DEFAULT_LOCALE: () => DEFAULT_LOCALE,
|
|
6234
|
+
AI_CRAWLERS: () => AI_CRAWLERS,
|
|
6322
6235
|
DEFAULT_COOKIE: () => DEFAULT_COOKIE,
|
|
6323
|
-
|
|
6236
|
+
DEFAULT_LOCALE: () => DEFAULT_LOCALE,
|
|
6237
|
+
DEFAULT_LOCALES_DIR: () => DEFAULT_LOCALES_DIR,
|
|
6238
|
+
DefaultOGTemplate: () => DefaultOGTemplate,
|
|
6239
|
+
LRUCache: () => LRUCache,
|
|
6240
|
+
SEARCH_CRAWLERS: () => SEARCH_CRAWLERS,
|
|
6241
|
+
SSRDataCache: () => SSRDataCache,
|
|
6242
|
+
TTLCache: () => TTLCache,
|
|
6243
|
+
acceptsBrotli: () => acceptsBrotli,
|
|
6244
|
+
acceptsGzip: () => acceptsGzip,
|
|
6245
|
+
allowAICrawlers: () => allowAICrawlers,
|
|
6246
|
+
allowSearchCrawlers: () => allowSearchCrawlers,
|
|
6247
|
+
applyIndexTemplate: () => applyIndexTemplate,
|
|
6248
|
+
basename: () => basename,
|
|
6249
|
+
blockAICrawlers: () => blockAICrawlers,
|
|
6250
|
+
blockAITrainingCrawlers: () => blockAITrainingCrawlers,
|
|
6251
|
+
blockSearchCrawlers: () => blockSearchCrawlers,
|
|
6252
|
+
buildHeadFromMeta: () => buildHeadFromMeta,
|
|
6253
|
+
buildLocaleCookie: () => buildLocaleCookie,
|
|
6254
|
+
cleanupPathScopedSSRData: () => cleanupPathScopedSSRData,
|
|
6255
|
+
clearSSRModuleStores: () => clearSSRModuleStores,
|
|
6256
|
+
clearWatchImportCache: () => clearWatchImportCache,
|
|
6257
|
+
compareRouteSpecificity: () => compareRouteSpecificity,
|
|
6258
|
+
compressStreamIfAccepted: () => compressStreamIfAccepted,
|
|
6259
|
+
computeContentData: () => computeContentData,
|
|
6260
|
+
computeLayoutData: () => computeLayoutData,
|
|
6261
|
+
computeRouteData: () => computeRouteData,
|
|
6262
|
+
computeSSRData: () => computeSSRData,
|
|
6263
|
+
computeSSRDataForPath: () => computeSSRDataForPath,
|
|
6264
|
+
contentKey: () => contentKey,
|
|
6265
|
+
contentNegotiateRedirect: () => contentNegotiateRedirect,
|
|
6266
|
+
createBundlePreload: () => createBundlePreload,
|
|
6267
|
+
createCollectionScript: () => createCollectionScript,
|
|
6268
|
+
createDataScript: () => createDataScript,
|
|
6269
|
+
createFeedsScript: () => createFeedsScript,
|
|
6270
|
+
createLayoutCacheKey: () => createLayoutCacheKey,
|
|
6271
|
+
createLayoutDataKey: () => createLayoutDataKey,
|
|
6272
|
+
createLlmsScript: () => createLlmsScript,
|
|
6273
|
+
createTranslator: () => createTranslator,
|
|
6274
|
+
deduplicateMetaTags: () => deduplicateMetaTags,
|
|
6275
|
+
defineConfig: () => defineConfig,
|
|
6276
|
+
discoverCollectionContent: () => discoverCollectionContent,
|
|
6277
|
+
discoverCollections: () => discoverCollections,
|
|
6278
|
+
discoverI18n: () => discoverI18n,
|
|
6279
|
+
discoverRSSData: () => discoverRSSData,
|
|
6280
|
+
discoverRobotsData: () => discoverRobotsData,
|
|
6281
|
+
discoverRoutes: () => discoverRoutes,
|
|
6282
|
+
discoverRoutesForRobots: () => discoverRoutesForRobots,
|
|
6283
|
+
discoverSSRDataFeedItems: () => discoverSSRDataFeedItems,
|
|
6284
|
+
discoverSSRDataRoutes: () => discoverSSRDataRoutes2,
|
|
6285
|
+
discoverSitemapData: () => discoverSitemapData,
|
|
6286
|
+
duplicateQueryParamData: () => duplicateQueryParamData,
|
|
6287
|
+
dynamicImport: () => dynamicImport,
|
|
6288
|
+
escapeJsonForScript: () => escapeJsonForScript,
|
|
6289
|
+
escapeXml: () => escapeXml2,
|
|
6290
|
+
extname: () => extname,
|
|
6291
|
+
extractContentForLLMs: () => extractContentForLLMs,
|
|
6292
|
+
extractPageMetadata: () => extractPageMetadata,
|
|
6293
|
+
extractParamsFromPath: () => extractParamsFromPath,
|
|
6294
|
+
extractTitle: () => extractTitle,
|
|
6295
|
+
findOGImageForPath: () => findOGImageForPath,
|
|
6296
|
+
formatAsMarkdown: () => formatAsMarkdown,
|
|
6297
|
+
formatAsText: () => formatAsText,
|
|
6298
|
+
formatMessage: () => formatMessage,
|
|
6299
|
+
generateAtomXML: () => generateAtomXML,
|
|
6300
|
+
generateCollectionScripts: () => generateCollectionScripts,
|
|
6301
|
+
generateContentHash: () => generateContentHash,
|
|
6302
|
+
generateFeed: () => generateFeed,
|
|
6303
|
+
generateHydrationScripts: () => generateHydrationScripts,
|
|
6304
|
+
generateLLMsFooter: () => generateLLMsFooter,
|
|
6305
|
+
generateLLMsFullContent: () => generateLLMsFullContent,
|
|
6306
|
+
generateLLMsIndex: () => generateLLMsIndex,
|
|
6307
|
+
generateOGImageMetaTags: () => generateOGImageMetaTags,
|
|
6308
|
+
generateRSSXML: () => generateRSSXML,
|
|
6309
|
+
generateRobots: () => generateRobots,
|
|
6310
|
+
generateSitemap: () => generateSitemap,
|
|
6311
|
+
generateSitemapIndexXML: () => generateSitemapIndexXML,
|
|
6312
|
+
generateSitemapXML: () => generateSitemapXML,
|
|
6313
|
+
getContentMeta: () => getContentMeta,
|
|
6314
|
+
getMatchingLayouts: () => getMatchingLayouts,
|
|
6315
|
+
getMessage: () => getMessage,
|
|
6316
|
+
getMimeType: () => getMimeType,
|
|
6317
|
+
getPatternDepth: () => getPatternDepth,
|
|
6318
|
+
getRedirectSourcePaths: () => getRedirectSourcePaths,
|
|
6319
|
+
getSitemapExcludedRoutes: () => getSitemapExcludedRoutes,
|
|
6320
|
+
gzipIfAccepted: () => gzipIfAccepted,
|
|
6321
|
+
hreflangTags: () => hreflangTags,
|
|
6322
|
+
htmlToMarkdown: () => htmlToMarkdown,
|
|
6323
|
+
importContentModuleForPath: () => importContentModuleForPath,
|
|
6324
|
+
inlineThemeCSS: () => inlineThemeCSS,
|
|
6325
|
+
isCompressible: () => isCompressible,
|
|
6326
|
+
isThenable: () => isThenable,
|
|
6327
|
+
join: () => join,
|
|
6328
|
+
listContentFiles: () => listContentFiles,
|
|
6329
|
+
loadCollections: () => loadCollections,
|
|
6330
|
+
loadConfig: () => loadConfig,
|
|
6331
|
+
loadIndexHtml: () => loadIndexHtml,
|
|
6332
|
+
loadOGImageComponent: () => loadOGImageComponent,
|
|
6333
|
+
loadRoutesModule: () => loadRoutesModule,
|
|
6334
|
+
localizeContentHref: () => localizeContentHref,
|
|
6335
|
+
localizeHref: () => localizeHref,
|
|
6336
|
+
looksLikeLocale: () => looksLikeLocale,
|
|
6337
|
+
lookupMessage: () => lookupMessage,
|
|
6338
|
+
matchRoutePattern: () => matchRoutePattern,
|
|
6339
|
+
matchRoutes: () => matchRoutes,
|
|
6340
|
+
mergeLayoutData: () => mergeLayoutData,
|
|
6341
|
+
negotiateLocale: () => negotiateLocale,
|
|
6342
|
+
normalizePathname: () => normalizePathname,
|
|
6343
|
+
parseContentPath: () => parseContentPath,
|
|
6344
|
+
parseCookieValue: () => parseCookieValue,
|
|
6345
|
+
performSSRSetup: () => performSSRSetup,
|
|
6346
|
+
preloadContentModule: () => preloadContentModule,
|
|
6347
|
+
processCollections: () => processCollections,
|
|
6348
|
+
removeOverriddenMetaTags: () => removeOverriddenMetaTags,
|
|
6349
|
+
renderOGImageToPNG: () => renderOGImageToPNG,
|
|
6350
|
+
renderSSRDocument: () => renderSSRDocument,
|
|
6351
|
+
renderSSRDocumentStream: () => renderSSRDocumentStream,
|
|
6352
|
+
resetSSRAccessTracking: () => resetSSRAccessTracking,
|
|
6353
|
+
resolveLocale: () => resolveLocale,
|
|
6354
|
+
seedSSRModuleForPath: () => seedSSRModuleForPath,
|
|
6355
|
+
setGlobalCollections: () => setGlobalCollections,
|
|
6356
|
+
setGlobalSSRData: () => setGlobalSSRData,
|
|
6357
|
+
shouldExcludeRoute: () => shouldExcludeRoute,
|
|
6358
|
+
splitTemplate: () => splitTemplate,
|
|
6359
|
+
ssrCache: () => ssrCache,
|
|
6360
|
+
statusCache: () => statusCache,
|
|
6361
|
+
stripEnd: () => stripEnd,
|
|
6362
|
+
stripHtmlTags: () => stripHtmlTags,
|
|
6363
|
+
stripStart: () => stripStart,
|
|
6364
|
+
toBytes: () => toBytes,
|
|
6365
|
+
toOgLocale: () => toOgLocale,
|
|
6366
|
+
toPromise: () => toPromise
|
|
6324
6367
|
});
|
|
6325
6368
|
var init_core = __esm(() => {
|
|
6326
6369
|
init_src();
|
|
@@ -6334,7 +6377,7 @@ import { createElement as createElement2 } from "react";
|
|
|
6334
6377
|
|
|
6335
6378
|
// packages/elysia/src/libs/image.ts
|
|
6336
6379
|
import { existsSync } from "node:fs";
|
|
6337
|
-
import { join as
|
|
6380
|
+
import { join as join4 } from "node:path";
|
|
6338
6381
|
import sharp from "sharp";
|
|
6339
6382
|
var imageCache = new Map;
|
|
6340
6383
|
var MAX_CACHE_SIZE = 100;
|
|
@@ -6377,8 +6420,8 @@ async function loadFromDiskCache(cacheKey) {
|
|
|
6377
6420
|
if (!diskCacheDir)
|
|
6378
6421
|
return null;
|
|
6379
6422
|
try {
|
|
6380
|
-
const cachePath =
|
|
6381
|
-
const imagePath =
|
|
6423
|
+
const cachePath = join4(diskCacheDir, `${cacheKey}.json`);
|
|
6424
|
+
const imagePath = join4(diskCacheDir, `${cacheKey}.img`);
|
|
6382
6425
|
if (!(existsSync(cachePath) && existsSync(imagePath))) {
|
|
6383
6426
|
return null;
|
|
6384
6427
|
}
|
|
@@ -6400,8 +6443,8 @@ async function saveToDiskCache(cacheKey, result) {
|
|
|
6400
6443
|
if (!diskCacheDir)
|
|
6401
6444
|
return;
|
|
6402
6445
|
try {
|
|
6403
|
-
const cachePath =
|
|
6404
|
-
const imagePath =
|
|
6446
|
+
const cachePath = join4(diskCacheDir, `${cacheKey}.json`);
|
|
6447
|
+
const imagePath = join4(diskCacheDir, `${cacheKey}.img`);
|
|
6405
6448
|
await Bun.write(cachePath, JSON.stringify({
|
|
6406
6449
|
contentType: result.contentType,
|
|
6407
6450
|
format: result.format,
|
|
@@ -6760,7 +6803,7 @@ function registerContentRoutes(app, cwd, collectionCache, directive, maxAge, isW
|
|
|
6760
6803
|
if (!collectionPath)
|
|
6761
6804
|
throw new NotFoundError3;
|
|
6762
6805
|
const cacheKey = `content:${collectionPath}`;
|
|
6763
|
-
const cached = collectionCache.get(cacheKey);
|
|
6806
|
+
const cached = isWatchMode ? undefined : collectionCache.get(cacheKey);
|
|
6764
6807
|
if (cached) {
|
|
6765
6808
|
if (isOtelAvailable2()) {
|
|
6766
6809
|
const currentSpan = trace3.getActiveSpan();
|
|
@@ -6783,19 +6826,20 @@ function registerContentRoutes(app, cwd, collectionCache, directive, maxAge, isW
|
|
|
6783
6826
|
}
|
|
6784
6827
|
throw new NotFoundError3;
|
|
6785
6828
|
}
|
|
6786
|
-
const
|
|
6787
|
-
const mod = await import(url);
|
|
6829
|
+
const mod = await dynamicImport(collectionFile, isWatchMode);
|
|
6788
6830
|
const items = mod.items ?? [];
|
|
6789
6831
|
const body = JSON.stringify({ collection: collectionPath, items });
|
|
6790
6832
|
const response = new Response(body, {
|
|
6791
6833
|
status: 200,
|
|
6792
6834
|
headers: {
|
|
6793
6835
|
"content-type": "application/json; charset=utf-8",
|
|
6794
|
-
"cache-control": buildCacheControl(maxAge, directive),
|
|
6836
|
+
"cache-control": isWatchMode ? buildDevCacheControl() : buildCacheControl(maxAge, directive),
|
|
6795
6837
|
"Reroute-Cache": "MISS"
|
|
6796
6838
|
}
|
|
6797
6839
|
});
|
|
6798
|
-
|
|
6840
|
+
if (!isWatchMode) {
|
|
6841
|
+
collectionCache.set(cacheKey, response);
|
|
6842
|
+
}
|
|
6799
6843
|
if (isOtelAvailable2()) {
|
|
6800
6844
|
const currentSpan = trace3.getActiveSpan();
|
|
6801
6845
|
currentSpan?.setAttributes({
|
|
@@ -6822,7 +6866,7 @@ function registerContentRoutes(app, cwd, collectionCache, directive, maxAge, isW
|
|
|
6822
6866
|
// packages/elysia/src/routes/image.ts
|
|
6823
6867
|
init_core();
|
|
6824
6868
|
import { existsSync as existsSync2 } from "node:fs";
|
|
6825
|
-
import { join as
|
|
6869
|
+
import { join as join5 } from "node:path";
|
|
6826
6870
|
function parseNumericParam(value) {
|
|
6827
6871
|
if (!value)
|
|
6828
6872
|
return;
|
|
@@ -6869,8 +6913,8 @@ function registerImageRoutes(app, options) {
|
|
|
6869
6913
|
}
|
|
6870
6914
|
function resolveInternalImagePath(url, clientDir2) {
|
|
6871
6915
|
const cleanUrl = url.startsWith("/") ? url.slice(1) : url;
|
|
6872
|
-
const imagePath =
|
|
6873
|
-
const normalizedPath =
|
|
6916
|
+
const imagePath = join5(clientDir2, cleanUrl);
|
|
6917
|
+
const normalizedPath = join5(clientDir2, cleanUrl);
|
|
6874
6918
|
if (!normalizedPath.startsWith(clientDir2)) {
|
|
6875
6919
|
return { error: "Access denied" };
|
|
6876
6920
|
}
|
|
@@ -7021,6 +7065,26 @@ function jsonError(message, status = 500) {
|
|
|
7021
7065
|
});
|
|
7022
7066
|
}
|
|
7023
7067
|
|
|
7068
|
+
// packages/elysia/src/routes/themeCssRefresh.ts
|
|
7069
|
+
function refreshThemeCss() {
|
|
7070
|
+
const href = `/.reroute/index.css?t=${Date.now()}`;
|
|
7071
|
+
const next = document.createElement("link");
|
|
7072
|
+
next.rel = "stylesheet";
|
|
7073
|
+
next.setAttribute("data-reroute", "theme");
|
|
7074
|
+
next.href = href;
|
|
7075
|
+
const existing = document.querySelector('link[data-reroute="theme"]');
|
|
7076
|
+
const style = document.querySelector('style[data-reroute="theme"]');
|
|
7077
|
+
const previous = existing ?? style;
|
|
7078
|
+
if (previous) {
|
|
7079
|
+
previous.removeAttribute("data-reroute");
|
|
7080
|
+
next.onload = () => previous.remove();
|
|
7081
|
+
previous.after(next);
|
|
7082
|
+
return true;
|
|
7083
|
+
}
|
|
7084
|
+
document.head.appendChild(next);
|
|
7085
|
+
return true;
|
|
7086
|
+
}
|
|
7087
|
+
|
|
7024
7088
|
// packages/elysia/src/routes/internal.ts
|
|
7025
7089
|
function parsePathname(p) {
|
|
7026
7090
|
try {
|
|
@@ -7078,20 +7142,24 @@ function registerInternalRoutes(app, opts) {
|
|
|
7078
7142
|
async function handleKeyRequest(pathname, dataKey, headers2) {
|
|
7079
7143
|
const { computeSSRData: computeSSRData2 } = await Promise.resolve().then(() => (init_core(), exports_core));
|
|
7080
7144
|
const cacheKey = `${pathname}:promises`;
|
|
7081
|
-
let promiseData = dataCache?.get(cacheKey);
|
|
7145
|
+
let promiseData = isWatchMode ? undefined : dataCache?.get(cacheKey);
|
|
7082
7146
|
const promiseDataCached = promiseData !== undefined;
|
|
7083
7147
|
if (!promiseData) {
|
|
7084
7148
|
const sp = extractSearchParams(pathname);
|
|
7085
7149
|
const { data } = await computeSSRData2(pathname, clientDir, cwd, isWatchMode, { streaming: true, maxAge }, sp);
|
|
7086
7150
|
promiseData = data;
|
|
7087
|
-
|
|
7151
|
+
if (!isWatchMode) {
|
|
7152
|
+
dataCache?.set(cacheKey, promiseData);
|
|
7153
|
+
}
|
|
7088
7154
|
}
|
|
7089
7155
|
if (promiseData && typeof promiseData === "object") {
|
|
7090
7156
|
const value = promiseData[dataKey];
|
|
7091
7157
|
if (value instanceof Promise) {
|
|
7092
7158
|
const resolved = await value;
|
|
7093
7159
|
const resolvedCacheKey = `${pathname}:${dataKey}:resolved`;
|
|
7094
|
-
|
|
7160
|
+
if (!isWatchMode) {
|
|
7161
|
+
dataCache?.set(resolvedCacheKey, resolved);
|
|
7162
|
+
}
|
|
7095
7163
|
return jsonWithCache({ data: resolved }, dataCacheControl || "no-cache", headers2, promiseDataCached ? "HIT" : "MISS");
|
|
7096
7164
|
}
|
|
7097
7165
|
if (value !== undefined) {
|
|
@@ -7103,7 +7171,7 @@ function registerInternalRoutes(app, opts) {
|
|
|
7103
7171
|
async function handleFullDataRequest(pathname) {
|
|
7104
7172
|
const { computeSSRData: computeSSRData2 } = await Promise.resolve().then(() => (init_core(), exports_core));
|
|
7105
7173
|
const cacheKey = `${pathname}:streaming`;
|
|
7106
|
-
let data = dataCache?.get(cacheKey);
|
|
7174
|
+
let data = isWatchMode ? undefined : dataCache?.get(cacheKey);
|
|
7107
7175
|
const cacheHit = data !== undefined;
|
|
7108
7176
|
if (data === undefined) {
|
|
7109
7177
|
const sp = extractSearchParams(pathname);
|
|
@@ -7114,7 +7182,9 @@ function registerInternalRoutes(app, opts) {
|
|
|
7114
7182
|
console.error("[__reroute_data] Error computing data:", error);
|
|
7115
7183
|
data = null;
|
|
7116
7184
|
}
|
|
7117
|
-
|
|
7185
|
+
if (!isWatchMode) {
|
|
7186
|
+
dataCache?.set(cacheKey, data);
|
|
7187
|
+
}
|
|
7118
7188
|
}
|
|
7119
7189
|
return { data, cacheHit };
|
|
7120
7190
|
}
|
|
@@ -7218,14 +7288,7 @@ function triggerFullReload(reason) {
|
|
|
7218
7288
|
window.location.reload();
|
|
7219
7289
|
}
|
|
7220
7290
|
|
|
7221
|
-
|
|
7222
|
-
const theme = document.querySelector('link[data-reroute="theme"]');
|
|
7223
|
-
if (!(theme instanceof HTMLLinkElement)) return false;
|
|
7224
|
-
const url = new URL(theme.href, location.href);
|
|
7225
|
-
url.searchParams.set('t', String(Date.now()));
|
|
7226
|
-
theme.href = url.toString();
|
|
7227
|
-
return true;
|
|
7228
|
-
}
|
|
7291
|
+
FUNCTION_REFRESH_THEME_CSS
|
|
7229
7292
|
|
|
7230
7293
|
function showRebuildNotice() {
|
|
7231
7294
|
if (rebuildNotice) return;
|
|
@@ -7360,11 +7423,8 @@ function connect() {
|
|
|
7360
7423
|
showRebuildNotice();
|
|
7361
7424
|
} else if (e.data === 'reload:css') {
|
|
7362
7425
|
hideRebuildNotice();
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
} else {
|
|
7366
|
-
triggerFullReload('Build complete, reloading...');
|
|
7367
|
-
}
|
|
7426
|
+
refreshThemeCss();
|
|
7427
|
+
console.log('[reroute] ✓ Theme CSS refreshed');
|
|
7368
7428
|
} else if (e.data === 'reload' || e.data === 'reload:full') {
|
|
7369
7429
|
triggerFullReload('Build complete, reloading...');
|
|
7370
7430
|
}
|
|
@@ -7385,7 +7445,7 @@ function connect() {
|
|
|
7385
7445
|
|
|
7386
7446
|
restoreScrollPosition();
|
|
7387
7447
|
connect();
|
|
7388
|
-
|
|
7448
|
+
`.replace("FUNCTION_REFRESH_THEME_CSS", refreshThemeCss.toString());
|
|
7389
7449
|
function registerLiveReloadRoutes(app, state) {
|
|
7390
7450
|
console.log("[reroute] Registering SSE endpoint at /__reroute_watch");
|
|
7391
7451
|
app.get("/__reroute_watch", () => {
|
|
@@ -8036,14 +8096,14 @@ function registerOGRoutes(app, options) {
|
|
|
8036
8096
|
}
|
|
8037
8097
|
return;
|
|
8038
8098
|
}
|
|
8039
|
-
function getFontPaths(fontPath, baseDir,
|
|
8099
|
+
function getFontPaths(fontPath, baseDir, join6) {
|
|
8040
8100
|
const fontRelativePath = fontPath.replace(/^(\.\/)?src\/client\/assets\//, "").replace(/^assets\//, "");
|
|
8041
8101
|
return [
|
|
8042
|
-
|
|
8043
|
-
|
|
8044
|
-
|
|
8045
|
-
|
|
8046
|
-
|
|
8102
|
+
join6(clientDir, "assets", fontRelativePath),
|
|
8103
|
+
join6(baseDir, ".reroute", "assets", fontRelativePath),
|
|
8104
|
+
join6(cwd, ".reroute", "assets", fontRelativePath),
|
|
8105
|
+
join6(cwd, fontPath),
|
|
8106
|
+
join6(baseDir, fontPath)
|
|
8047
8107
|
];
|
|
8048
8108
|
}
|
|
8049
8109
|
async function tryLoadFont(font, possiblePaths, existsSync3) {
|
|
@@ -8066,14 +8126,14 @@ function registerOGRoutes(app, options) {
|
|
|
8066
8126
|
if (!ogConfig.fonts || ogConfig.fonts.length === 0) {
|
|
8067
8127
|
return [];
|
|
8068
8128
|
}
|
|
8069
|
-
const { join:
|
|
8129
|
+
const { join: join6, dirname: dirname2 } = await import("node:path");
|
|
8070
8130
|
const { existsSync: existsSync3 } = await import("node:fs");
|
|
8071
8131
|
const isCompiledBinary = typeof Bun !== "undefined" && process.argv[0]?.endsWith(process.argv[1]);
|
|
8072
|
-
const baseDir = isCompiledBinary ?
|
|
8132
|
+
const baseDir = isCompiledBinary ? dirname2(process.argv[1]) : cwd;
|
|
8073
8133
|
const loadedFonts = [];
|
|
8074
8134
|
for (const font of ogConfig.fonts) {
|
|
8075
8135
|
try {
|
|
8076
|
-
const possiblePaths = getFontPaths(font.path, baseDir,
|
|
8136
|
+
const possiblePaths = getFontPaths(font.path, baseDir, join6);
|
|
8077
8137
|
const loadedFont = await tryLoadFont(font, possiblePaths, existsSync3);
|
|
8078
8138
|
if (loadedFont) {
|
|
8079
8139
|
loadedFonts.push(loadedFont);
|
|
@@ -8786,16 +8846,16 @@ function registerSitemapRoutes(app, options) {
|
|
|
8786
8846
|
// packages/elysia/src/routes/ssr.ts
|
|
8787
8847
|
init_core();
|
|
8788
8848
|
init_server2();
|
|
8789
|
-
import { join as
|
|
8849
|
+
import { join as join7 } from "node:path";
|
|
8790
8850
|
import { trace as trace4 } from "@opentelemetry/api";
|
|
8791
8851
|
import { NotFoundError as NotFoundError10 } from "elysia";
|
|
8792
8852
|
|
|
8793
8853
|
// packages/elysia/src/libs/i18n.ts
|
|
8794
8854
|
init_core();
|
|
8795
|
-
import { join as
|
|
8855
|
+
import { join as join6 } from "node:path";
|
|
8796
8856
|
var cachedI18n = null;
|
|
8797
8857
|
async function loadI18nState(cwd) {
|
|
8798
|
-
const path2 =
|
|
8858
|
+
const path2 = join6(cwd, ".reroute", "i18n.json");
|
|
8799
8859
|
try {
|
|
8800
8860
|
const file = Bun.file(path2);
|
|
8801
8861
|
if (!await file.exists()) {
|
|
@@ -8809,8 +8869,8 @@ async function loadI18nState(cwd) {
|
|
|
8809
8869
|
catalogs: {}
|
|
8810
8870
|
};
|
|
8811
8871
|
}
|
|
8812
|
-
const
|
|
8813
|
-
const mtime =
|
|
8872
|
+
const stat6 = await file.stat();
|
|
8873
|
+
const mtime = stat6?.mtime?.getTime?.() ?? Date.now();
|
|
8814
8874
|
if (cachedI18n && cachedI18n.cwd === cwd && cachedI18n.mtime === mtime) {
|
|
8815
8875
|
return cachedI18n.data;
|
|
8816
8876
|
}
|
|
@@ -8832,7 +8892,7 @@ async function loadI18nState(cwd) {
|
|
|
8832
8892
|
async function listContentCollections(cwd) {
|
|
8833
8893
|
try {
|
|
8834
8894
|
const { readdir: readdir6 } = await import("node:fs/promises");
|
|
8835
|
-
const dir =
|
|
8895
|
+
const dir = join6(cwd, ".reroute", "collections");
|
|
8836
8896
|
const entries = await readdir6(dir);
|
|
8837
8897
|
return entries.filter((f) => f.endsWith(".js")).map((f) => f.replace(/\.js$/, ""));
|
|
8838
8898
|
} catch {
|
|
@@ -8977,7 +9037,7 @@ function registerSSRRoutes(app, options) {
|
|
|
8977
9037
|
let contentRoutes = [];
|
|
8978
9038
|
let dynamicRoutes = [];
|
|
8979
9039
|
try {
|
|
8980
|
-
const manifestPath =
|
|
9040
|
+
const manifestPath = join7(cwd, ".reroute", "manifest.json");
|
|
8981
9041
|
const { readFileSync } = __require("node:fs");
|
|
8982
9042
|
const manifestText = readFileSync(manifestPath, "utf-8");
|
|
8983
9043
|
const manifest = JSON.parse(manifestText);
|
|
@@ -9100,7 +9160,7 @@ function registerSSRRoutes(app, options) {
|
|
|
9100
9160
|
head,
|
|
9101
9161
|
lang: i18n2.effectiveLang,
|
|
9102
9162
|
appId,
|
|
9103
|
-
maxAge: serverMaxAge,
|
|
9163
|
+
maxAge: isWatchMode ? 0 : serverMaxAge,
|
|
9104
9164
|
searchParams,
|
|
9105
9165
|
ogConfig: options.ogConfig,
|
|
9106
9166
|
ogMetaConfig: options.ogMetaConfig,
|
|
@@ -9283,7 +9343,7 @@ function registerSSRRoutes(app, options) {
|
|
|
9283
9343
|
head,
|
|
9284
9344
|
lang: i18n2.effectiveLang,
|
|
9285
9345
|
appId,
|
|
9286
|
-
maxAge: serverMaxAge,
|
|
9346
|
+
maxAge: isWatchMode ? 0 : serverMaxAge,
|
|
9287
9347
|
searchParams,
|
|
9288
9348
|
ogConfig: options.ogConfig,
|
|
9289
9349
|
ogMetaConfig: options.ogMetaConfig,
|
|
@@ -9621,7 +9681,7 @@ var reroute = () => async (app) => {
|
|
|
9621
9681
|
};
|
|
9622
9682
|
const clientDir = existsSync3(`${cwd}/.reroute/assets`) ? `${cwd}/.reroute` : `${cwd}/src/client`;
|
|
9623
9683
|
const shouldIgnore = !ignorePatterns.length ? () => false : (file) => ignorePatterns.find((pattern) => typeof pattern === "string" ? file.includes(pattern) : pattern.test(file));
|
|
9624
|
-
const isWatchMode = Array.isArray(process.execArgv) && process.execArgv.includes("--watch") || Array.isArray(process.argv) && process.argv.includes("--watch");
|
|
9684
|
+
const isWatchMode = process.env.REROUTE_DEV === "1" || Array.isArray(process.execArgv) && process.execArgv.includes("--watch") || Array.isArray(process.argv) && process.argv.includes("--watch");
|
|
9625
9685
|
const dataCacheControl = browserCacheEnabled ? `${browserDirective}, max-age=${browserMaxAge}` : undefined;
|
|
9626
9686
|
if (isWatchMode) {
|
|
9627
9687
|
console.log(`[reroute] Live reload enabled`);
|
|
@@ -9640,6 +9700,15 @@ var reroute = () => async (app) => {
|
|
|
9640
9700
|
if (body?.mode === "css")
|
|
9641
9701
|
mode = "css";
|
|
9642
9702
|
} catch {}
|
|
9703
|
+
if (mode === "full") {
|
|
9704
|
+
ssrCache.clear();
|
|
9705
|
+
statusCache.clear();
|
|
9706
|
+
collectionCache.clear();
|
|
9707
|
+
dataCache.clear();
|
|
9708
|
+
fileCache.clear();
|
|
9709
|
+
clearWatchImportCache();
|
|
9710
|
+
clearSSRModuleStores();
|
|
9711
|
+
}
|
|
9643
9712
|
console.log(`[reroute] Reload notification received (${mode}), notifying ${liveReloadState.clients.size} browser(s)...`);
|
|
9644
9713
|
notifyReload(mode);
|
|
9645
9714
|
return new Response(JSON.stringify({
|
|
@@ -9884,4 +9953,4 @@ export {
|
|
|
9884
9953
|
reroute
|
|
9885
9954
|
};
|
|
9886
9955
|
|
|
9887
|
-
//# debugId=
|
|
9956
|
+
//# debugId=B1AFDFD64E8F0A7D64756E2164756E21
|