reroute-js 1.0.0-alpha.2 → 1.0.0-alpha.21
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 +7 -3
- package/cli/bin.d.ts +1 -1
- package/cli/bin.js +1618 -958
- package/cli/bin.js.map +38 -35
- package/cli/index.d.ts +1 -1
- package/cli/index.js +628 -40
- package/cli/index.js.map +53 -5
- package/cli/src/cli.d.ts +1 -1
- package/cli/src/commands/analyze.d.ts +1 -1
- package/cli/src/commands/analyze.d.ts.map +1 -1
- package/cli/src/commands/build.d.ts +2 -2
- package/cli/src/commands/dev.d.ts +6 -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 +7 -1
- package/cli/src/commands/lib/bundler.d.ts.map +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 +2 -2
- package/cli/src/commands/lib/streaming/suspense.d.ts.map +1 -1
- package/cli/src/commands/lib/terminal-ui.d.ts +2 -2
- package/cli/src/commands/lib/terminal-ui.d.ts.map +1 -1
- package/cli/src/commands/lib/theme.d.ts +7 -4
- package/cli/src/commands/lib/theme.d.ts.map +1 -1
- package/cli/src/commands/lib/version.d.ts +1 -1
- package/cli/src/commands/lib/watch.d.ts +26 -0
- package/cli/src/commands/lib/watch.d.ts.map +1 -0
- package/cli/src/commands/og.d.ts +1 -1
- package/cli/src/commands/og.d.ts.map +1 -1
- package/cli/src/commands/start.d.ts +2 -2
- package/cli/src/commands/start.d.ts.map +1 -1
- package/cli/src/index.d.ts +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.js +712 -279
- package/core/index.js.map +25 -23
- package/core/src/app-paths.d.ts +32 -0
- package/core/src/app-paths.d.ts.map +1 -0
- package/core/src/bundler/hash.d.ts +1 -1
- package/core/src/bundler/index.d.ts +1 -1
- package/core/src/config.d.ts +51 -7
- 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 +4 -3
- package/core/src/i18n/resolve.d.ts.map +1 -1
- package/core/src/i18n/types.d.ts +5 -1
- package/core/src/i18n/types.d.ts.map +1 -1
- package/core/src/index.d.ts +2 -1
- package/core/src/index.d.ts.map +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 +6 -1
- package/core/src/llms/extractor.d.ts.map +1 -1
- package/core/src/llms/formatter.d.ts +1 -1
- package/core/src/llms/formatter.d.ts.map +1 -1
- package/core/src/llms/full-generator.d.ts +3 -1
- package/core/src/llms/full-generator.d.ts.map +1 -1
- package/core/src/llms/index-generator.d.ts +6 -3
- package/core/src/llms/index-generator.d.ts.map +1 -1
- package/core/src/llms/index.d.ts +5 -2
- 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 +2 -2
- 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 +7 -2
- 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/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 +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 +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 +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 +2 -2
- package/core/src/ssr/lib/setup.d.ts.map +1 -1
- package/core/src/ssr/lib/styles.d.ts +5 -4
- package/core/src/ssr/lib/styles.d.ts.map +1 -1
- package/core/src/ssr/lib/template.d.ts +1 -1
- package/core/src/ssr/lib/types.d.ts +15 -1
- package/core/src/ssr/lib/types.d.ts.map +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 +971 -432
- package/elysia/index.js.map +38 -33
- package/elysia/src/index.d.ts +1 -1
- package/elysia/src/libs/assets.d.ts +1 -1
- package/elysia/src/libs/cache.d.ts +6 -1
- package/elysia/src/libs/cache.d.ts.map +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 +2 -2
- package/elysia/src/libs/i18n.d.ts.map +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/artifacts.d.ts.map +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/liveReloadClient.d.ts +16 -0
- package/elysia/src/routes/liveReloadClient.d.ts.map +1 -0
- 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 +3 -1
- package/elysia/src/routes/robots.d.ts.map +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 +3 -1
- package/elysia/src/routes/sitemap.d.ts.map +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 +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 +203 -107
- package/react/index.js.map +8 -7
- 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/LocaleProvider.d.ts.map +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/bundle.d.ts +27 -0
- package/react/src/lib/bundle.d.ts.map +1 -0
- 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 +2 -1
- package/react/src/lib/index.d.ts.map +1 -1
- package/react/src/lib/lazy-route.d.ts +7 -21
- package/react/src/lib/lazy-route.d.ts.map +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 +2 -2
- package/react/src/providers/RerouteProvider.d.ts.map +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 +60 -228
- package/telemetry/server.js.map +20 -16
- 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/react/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* reroute-js v1.0.0-alpha.
|
|
2
|
+
* reroute-js v1.0.0-alpha.21
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @copyright 2026 stewones <hi@stewan.io>
|
|
@@ -26,21 +26,21 @@ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
|
26
26
|
// node:path
|
|
27
27
|
var exports_path = {};
|
|
28
28
|
__export(exports_path, {
|
|
29
|
-
|
|
30
|
-
resolve: () => resolve,
|
|
31
|
-
relative: () => relative,
|
|
32
|
-
posix: () => posix,
|
|
33
|
-
parse: () => parse,
|
|
34
|
-
normalize: () => normalize,
|
|
35
|
-
join: () => join,
|
|
36
|
-
isAbsolute: () => isAbsolute,
|
|
37
|
-
format: () => format,
|
|
38
|
-
extname: () => extname,
|
|
39
|
-
dirname: () => dirname,
|
|
40
|
-
delimiter: () => delimiter,
|
|
41
|
-
default: () => path_default,
|
|
29
|
+
_makeLong: () => _makeLong,
|
|
42
30
|
basename: () => basename,
|
|
43
|
-
|
|
31
|
+
default: () => path_default,
|
|
32
|
+
delimiter: () => delimiter,
|
|
33
|
+
dirname: () => dirname,
|
|
34
|
+
extname: () => extname,
|
|
35
|
+
format: () => format,
|
|
36
|
+
isAbsolute: () => isAbsolute,
|
|
37
|
+
join: () => join,
|
|
38
|
+
normalize: () => normalize,
|
|
39
|
+
parse: () => parse,
|
|
40
|
+
posix: () => posix,
|
|
41
|
+
relative: () => relative,
|
|
42
|
+
resolve: () => resolve,
|
|
43
|
+
sep: () => sep
|
|
44
44
|
});
|
|
45
45
|
function assertPath(path) {
|
|
46
46
|
if (typeof path !== "string")
|
|
@@ -556,18 +556,7 @@ function getSnapshot() {
|
|
|
556
556
|
return store.state;
|
|
557
557
|
}
|
|
558
558
|
function getServerSnapshot() {
|
|
559
|
-
return
|
|
560
|
-
}
|
|
561
|
-
function setStoreState(partial) {
|
|
562
|
-
const next = { ...store.state, ...partial };
|
|
563
|
-
if (sameHydration(store.state, next))
|
|
564
|
-
return;
|
|
565
|
-
store.state = next;
|
|
566
|
-
try {
|
|
567
|
-
globalThis.__REROUTE_I18N__ = store.state;
|
|
568
|
-
} catch {}
|
|
569
|
-
for (const listener of store.listeners)
|
|
570
|
-
listener();
|
|
559
|
+
return getSnapshot();
|
|
571
560
|
}
|
|
572
561
|
function seedStore(value) {
|
|
573
562
|
const next = {
|
|
@@ -613,18 +602,12 @@ function LocaleProvider({
|
|
|
613
602
|
return;
|
|
614
603
|
if (!state.locales.includes(next))
|
|
615
604
|
return;
|
|
616
|
-
writeLocaleCookie(state.cookie, next);
|
|
617
|
-
setStoreState({ locale: next });
|
|
618
605
|
if (typeof window === "undefined")
|
|
619
606
|
return;
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
window.location.assign(url);
|
|
625
|
-
return;
|
|
626
|
-
}
|
|
627
|
-
window.location.reload();
|
|
607
|
+
writeLocaleCookie(state.cookie, next);
|
|
608
|
+
const url = new URL(window.location.href);
|
|
609
|
+
url.searchParams.set("lang", next);
|
|
610
|
+
window.location.assign(`${url.pathname}${url.search}${url.hash}`);
|
|
628
611
|
}, [state]);
|
|
629
612
|
const localizePath = useCallback((to) => {
|
|
630
613
|
if (!state.enabled)
|
|
@@ -1279,11 +1262,14 @@ function useContent(params) {
|
|
|
1279
1262
|
if (!g.__REROUTE_SSR_RESULTS__[collection]) {
|
|
1280
1263
|
g.__REROUTE_SSR_RESULTS__[collection] = [];
|
|
1281
1264
|
}
|
|
1265
|
+
const itemKey = (item) => `${item.name || item.slug}\x00${item.locale || ""}`;
|
|
1282
1266
|
const existing = g.__REROUTE_SSR_RESULTS__[collection];
|
|
1283
|
-
const existingKeys = new Set(existing.map(
|
|
1267
|
+
const existingKeys = new Set(existing.map(itemKey));
|
|
1284
1268
|
for (const item of cloned) {
|
|
1285
|
-
|
|
1286
|
-
|
|
1269
|
+
if (!(item.name || item.slug))
|
|
1270
|
+
continue;
|
|
1271
|
+
const key = itemKey(item);
|
|
1272
|
+
if (!existingKeys.has(key)) {
|
|
1287
1273
|
existing.push(item);
|
|
1288
1274
|
existingKeys.add(key);
|
|
1289
1275
|
}
|
|
@@ -1342,6 +1328,39 @@ import { useContext as useContext3 } from "react";
|
|
|
1342
1328
|
// packages/react/src/providers/RerouteProvider.tsx
|
|
1343
1329
|
import { useCallback as useCallback6, useMemo as useMemo6 } from "react";
|
|
1344
1330
|
|
|
1331
|
+
// packages/react/src/lib/bundle.ts
|
|
1332
|
+
function readGlobalBundle(key) {
|
|
1333
|
+
try {
|
|
1334
|
+
return globalThis[key];
|
|
1335
|
+
} catch {
|
|
1336
|
+
return;
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
function readServerBundle() {
|
|
1340
|
+
if (typeof window !== "undefined")
|
|
1341
|
+
return;
|
|
1342
|
+
return readGlobalBundle("__REROUTE_SERVER_BUNDLE__");
|
|
1343
|
+
}
|
|
1344
|
+
function readClientBundle() {
|
|
1345
|
+
if (typeof window === "undefined")
|
|
1346
|
+
return;
|
|
1347
|
+
return readGlobalBundle("__REROUTE_CLIENT_BUNDLE__");
|
|
1348
|
+
}
|
|
1349
|
+
function readInjectedBundle() {
|
|
1350
|
+
return typeof window === "undefined" ? readServerBundle() : readClientBundle();
|
|
1351
|
+
}
|
|
1352
|
+
function missingBundleMessage() {
|
|
1353
|
+
const side = typeof window === "undefined" ? "Run reroute gen so the server bundle loads." : "Run reroute gen so the client bundle is included.";
|
|
1354
|
+
return `RerouteProvider: no route bundle found. ${side} Or pass matchRoute and layouts explicitly.`;
|
|
1355
|
+
}
|
|
1356
|
+
function resolveBundleField(injected, key, prop) {
|
|
1357
|
+
const fromInjected = injected?.[key];
|
|
1358
|
+
if (typeof window === "undefined") {
|
|
1359
|
+
return fromInjected ?? prop;
|
|
1360
|
+
}
|
|
1361
|
+
return prop ?? fromInjected;
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1345
1364
|
// packages/react/src/providers/RouterProvider.tsx
|
|
1346
1365
|
import React, {
|
|
1347
1366
|
createContext as createContext3,
|
|
@@ -2091,7 +2110,7 @@ function RerouteProvider({
|
|
|
2091
2110
|
getContentEntry,
|
|
2092
2111
|
loadContent,
|
|
2093
2112
|
contentBaseUrl,
|
|
2094
|
-
layouts
|
|
2113
|
+
layouts,
|
|
2095
2114
|
matchRoute,
|
|
2096
2115
|
notFoundRoutes,
|
|
2097
2116
|
notFound,
|
|
@@ -2103,7 +2122,16 @@ function RerouteProvider({
|
|
|
2103
2122
|
i18n: i18nProp,
|
|
2104
2123
|
children
|
|
2105
2124
|
}) {
|
|
2106
|
-
const
|
|
2125
|
+
const injected = readInjectedBundle();
|
|
2126
|
+
const resolvedMatchRoute = resolveBundleField(injected, "matchRoute", matchRoute);
|
|
2127
|
+
const resolvedLayouts = resolveBundleField(injected, "layouts", layouts) ?? [];
|
|
2128
|
+
const resolvedNotFoundRoutes = resolveBundleField(injected, "notFoundRoutes", notFoundRoutes);
|
|
2129
|
+
const resolvedContentBaseUrl = resolveBundleField(injected, "contentBaseUrl", contentBaseUrl);
|
|
2130
|
+
const resolvedMarkdownComponents = resolveBundleField(injected, "markdownComponents", markdownComponents);
|
|
2131
|
+
if (!resolvedMatchRoute) {
|
|
2132
|
+
throw new Error(missingBundleMessage());
|
|
2133
|
+
}
|
|
2134
|
+
const loader = loadContent || (resolvedContentBaseUrl ? (c) => import(`${resolvedContentBaseUrl}/${c}.js`) : undefined);
|
|
2107
2135
|
const i18n = i18nProp?.enabled ? i18nProp : readI18nHydration();
|
|
2108
2136
|
const locales = i18n?.locales || [];
|
|
2109
2137
|
const collections = useMemo6(() => {
|
|
@@ -2115,23 +2143,23 @@ function RerouteProvider({
|
|
|
2115
2143
|
}, [i18n?.collections, byCollection]);
|
|
2116
2144
|
const matchRouteWithLocale = useCallback6((path) => {
|
|
2117
2145
|
if (!(i18n?.enabled && locales.length)) {
|
|
2118
|
-
return
|
|
2146
|
+
return resolvedMatchRoute(path);
|
|
2119
2147
|
}
|
|
2120
2148
|
const parsed = parseContentPath(path, locales, collections);
|
|
2121
2149
|
const routingPath = parsed?.routingPathname || path;
|
|
2122
|
-
return
|
|
2123
|
-
}, [i18n?.enabled, locales, collections,
|
|
2150
|
+
return resolvedMatchRoute(routingPath);
|
|
2151
|
+
}, [i18n?.enabled, locales, collections, resolvedMatchRoute]);
|
|
2124
2152
|
return /* @__PURE__ */ jsx5(LocaleProvider, {
|
|
2125
2153
|
value: i18n,
|
|
2126
2154
|
children: /* @__PURE__ */ jsx5(ContentProvider, {
|
|
2127
2155
|
getEntry: getContentEntry,
|
|
2128
2156
|
byCollection: byCollection || null,
|
|
2129
2157
|
loadCollection: loader,
|
|
2130
|
-
markdownComponents,
|
|
2158
|
+
markdownComponents: resolvedMarkdownComponents,
|
|
2131
2159
|
children: /* @__PURE__ */ jsx5(RouterProvider, {
|
|
2132
|
-
layouts,
|
|
2160
|
+
layouts: resolvedLayouts,
|
|
2133
2161
|
matchRoute: matchRouteWithLocale,
|
|
2134
|
-
notFoundRoutes,
|
|
2162
|
+
notFoundRoutes: resolvedNotFoundRoutes,
|
|
2135
2163
|
notFound,
|
|
2136
2164
|
pathname,
|
|
2137
2165
|
searchParams,
|
|
@@ -3728,12 +3756,75 @@ async function collectionSearch(options) {
|
|
|
3728
3756
|
}
|
|
3729
3757
|
}
|
|
3730
3758
|
// packages/react/src/lib/lazy-route.tsx
|
|
3759
|
+
import {
|
|
3760
|
+
createElement,
|
|
3761
|
+
lazy,
|
|
3762
|
+
Suspense,
|
|
3763
|
+
useEffect as useEffect10,
|
|
3764
|
+
useState as useState10
|
|
3765
|
+
} from "react";
|
|
3731
3766
|
var isBrowser3 = typeof window !== "undefined";
|
|
3732
|
-
function
|
|
3767
|
+
function getCapturedRouteHtml() {
|
|
3768
|
+
try {
|
|
3769
|
+
return globalThis.__REROUTE_ROUTE_HTML__ || null;
|
|
3770
|
+
} catch {
|
|
3771
|
+
return null;
|
|
3772
|
+
}
|
|
3773
|
+
}
|
|
3774
|
+
function isInitialHydration3() {
|
|
3775
|
+
try {
|
|
3776
|
+
return !!globalThis.__REROUTE_INITIAL_HYDRATION__;
|
|
3777
|
+
} catch {
|
|
3778
|
+
return false;
|
|
3779
|
+
}
|
|
3780
|
+
}
|
|
3781
|
+
function createLazyRoute(lazyImport, routePattern, serverComponent) {
|
|
3733
3782
|
if (!isBrowser3) {
|
|
3734
|
-
|
|
3783
|
+
let ServerRoute = function(props) {
|
|
3784
|
+
return createElement("div", {
|
|
3785
|
+
"data-reroute-route": "ssr",
|
|
3786
|
+
style: { display: "contents" }
|
|
3787
|
+
}, createElement(Component, props));
|
|
3788
|
+
};
|
|
3789
|
+
if (!serverComponent) {
|
|
3790
|
+
return function MissingServerRoute() {
|
|
3791
|
+
throw new Error(`Missing SSR component for route ${routePattern}`);
|
|
3792
|
+
};
|
|
3793
|
+
}
|
|
3794
|
+
const Component = serverComponent;
|
|
3795
|
+
ServerRoute.displayName = `LazyRoute(${routePattern})`;
|
|
3796
|
+
return ServerRoute;
|
|
3797
|
+
}
|
|
3798
|
+
const LazyComp = lazy(lazyImport);
|
|
3799
|
+
function ClientRoute(props) {
|
|
3800
|
+
const [Resolved, setResolved] = useState10(null);
|
|
3801
|
+
const initialHydration = isInitialHydration3();
|
|
3802
|
+
const capturedHtml = initialHydration ? getCapturedRouteHtml() : null;
|
|
3803
|
+
useEffect10(() => {
|
|
3804
|
+
let alive = true;
|
|
3805
|
+
lazyImport().then((mod) => {
|
|
3806
|
+
if (alive)
|
|
3807
|
+
setResolved(() => mod.default);
|
|
3808
|
+
});
|
|
3809
|
+
return () => {
|
|
3810
|
+
alive = false;
|
|
3811
|
+
};
|
|
3812
|
+
}, []);
|
|
3813
|
+
if (Resolved) {
|
|
3814
|
+
return createElement(Resolved, props);
|
|
3815
|
+
}
|
|
3816
|
+
if (capturedHtml && initialHydration) {
|
|
3817
|
+
return createElement("div", {
|
|
3818
|
+
"data-reroute-route": "ssr",
|
|
3819
|
+
style: { display: "contents" },
|
|
3820
|
+
suppressHydrationWarning: true,
|
|
3821
|
+
dangerouslySetInnerHTML: { __html: capturedHtml }
|
|
3822
|
+
});
|
|
3823
|
+
}
|
|
3824
|
+
return createElement(Suspense, { fallback: null }, createElement(LazyComp, props));
|
|
3735
3825
|
}
|
|
3736
|
-
|
|
3826
|
+
ClientRoute.displayName = `LazyRoute(${routePattern})`;
|
|
3827
|
+
return ClientRoute;
|
|
3737
3828
|
}
|
|
3738
3829
|
async function preloadRoute(lazyImport) {
|
|
3739
3830
|
try {
|
|
@@ -3741,62 +3832,67 @@ async function preloadRoute(lazyImport) {
|
|
|
3741
3832
|
} catch {}
|
|
3742
3833
|
}
|
|
3743
3834
|
export {
|
|
3744
|
-
|
|
3745
|
-
useSearchParams,
|
|
3746
|
-
useSearch,
|
|
3747
|
-
useRouter,
|
|
3748
|
-
useParams,
|
|
3749
|
-
useNavigate,
|
|
3750
|
-
useMarkdownComponents,
|
|
3751
|
-
useLocaleContext,
|
|
3752
|
-
useLocale,
|
|
3753
|
-
useLlms,
|
|
3754
|
-
useLayoutData,
|
|
3755
|
-
useFeed,
|
|
3756
|
-
useData,
|
|
3757
|
-
useContentResolver,
|
|
3758
|
-
useContentLoadCollection,
|
|
3759
|
-
useContentIndex,
|
|
3760
|
-
useContentGetEntry,
|
|
3761
|
-
useContent,
|
|
3762
|
-
t,
|
|
3763
|
-
storeAndDispatchData,
|
|
3764
|
-
shouldSkipInterception,
|
|
3765
|
-
preloadRoute,
|
|
3766
|
-
prefetchRouteDataWithTimeout,
|
|
3767
|
-
prefetchRouteData,
|
|
3768
|
-
prefetchContentModule,
|
|
3769
|
-
prefetchContent,
|
|
3770
|
-
parseLocalUrl,
|
|
3771
|
-
parseContentPath,
|
|
3772
|
-
parseContentHref,
|
|
3773
|
-
needsDataPrefetch,
|
|
3774
|
-
localizeHref,
|
|
3775
|
-
localizeContentHref,
|
|
3776
|
-
isModifiedClick,
|
|
3777
|
-
getRerouteDataStore,
|
|
3778
|
-
fetchRouteData,
|
|
3779
|
-
dispatchDataEvent,
|
|
3780
|
-
createTranslator,
|
|
3781
|
-
createResolverFromGetEntry,
|
|
3782
|
-
createLazyRoute,
|
|
3783
|
-
collectionSearch,
|
|
3784
|
-
applySsrHead,
|
|
3785
|
-
applyRouteHead,
|
|
3786
|
-
applyPageMeta,
|
|
3787
|
-
applyLang,
|
|
3788
|
-
RouterProvider,
|
|
3789
|
-
RouterContext,
|
|
3790
|
-
RerouteProvider,
|
|
3791
|
-
OutletContext,
|
|
3792
|
-
Outlet,
|
|
3793
|
-
Markdown,
|
|
3794
|
-
LocaleProvider,
|
|
3795
|
-
Link,
|
|
3796
|
-
Image,
|
|
3797
|
-
ContentRoute,
|
|
3835
|
+
ClientOnly,
|
|
3798
3836
|
ContentProvider,
|
|
3799
|
-
|
|
3837
|
+
ContentRoute,
|
|
3838
|
+
Image,
|
|
3839
|
+
Link,
|
|
3840
|
+
LocaleProvider,
|
|
3841
|
+
Markdown,
|
|
3842
|
+
Outlet,
|
|
3843
|
+
OutletContext,
|
|
3844
|
+
RerouteProvider,
|
|
3845
|
+
RouterContext,
|
|
3846
|
+
RouterProvider,
|
|
3847
|
+
applyLang,
|
|
3848
|
+
applyPageMeta,
|
|
3849
|
+
applyRouteHead,
|
|
3850
|
+
applySsrHead,
|
|
3851
|
+
collectionSearch,
|
|
3852
|
+
createLazyRoute,
|
|
3853
|
+
createResolverFromGetEntry,
|
|
3854
|
+
createTranslator,
|
|
3855
|
+
dispatchDataEvent,
|
|
3856
|
+
fetchRouteData,
|
|
3857
|
+
getRerouteDataStore,
|
|
3858
|
+
isModifiedClick,
|
|
3859
|
+
localizeContentHref,
|
|
3860
|
+
localizeHref,
|
|
3861
|
+
missingBundleMessage,
|
|
3862
|
+
needsDataPrefetch,
|
|
3863
|
+
parseContentHref,
|
|
3864
|
+
parseContentPath,
|
|
3865
|
+
parseLocalUrl,
|
|
3866
|
+
prefetchContent,
|
|
3867
|
+
prefetchContentModule,
|
|
3868
|
+
prefetchRouteData,
|
|
3869
|
+
prefetchRouteDataWithTimeout,
|
|
3870
|
+
preloadRoute,
|
|
3871
|
+
readClientBundle,
|
|
3872
|
+
readInjectedBundle,
|
|
3873
|
+
readServerBundle,
|
|
3874
|
+
resolveBundleField,
|
|
3875
|
+
shouldSkipInterception,
|
|
3876
|
+
storeAndDispatchData,
|
|
3877
|
+
t,
|
|
3878
|
+
useContent,
|
|
3879
|
+
useContentGetEntry,
|
|
3880
|
+
useContentIndex,
|
|
3881
|
+
useContentLoadCollection,
|
|
3882
|
+
useContentResolver,
|
|
3883
|
+
useData,
|
|
3884
|
+
useFeed,
|
|
3885
|
+
useLayoutData,
|
|
3886
|
+
useLlms,
|
|
3887
|
+
useLocale,
|
|
3888
|
+
useLocaleContext,
|
|
3889
|
+
useMarkdownComponents,
|
|
3890
|
+
useNavigate,
|
|
3891
|
+
useParams,
|
|
3892
|
+
useRouter,
|
|
3893
|
+
useSearch,
|
|
3894
|
+
useSearchParams,
|
|
3895
|
+
useToc
|
|
3800
3896
|
};
|
|
3801
3897
|
|
|
3802
|
-
//# debugId=
|
|
3898
|
+
//# debugId=FE3E1397860AC40E64756E2164756E21
|