react-router 7.5.3 → 7.6.0-pre.0
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/CHANGELOG.md +57 -0
- package/dist/development/{chunk-AYJ5UCUI.mjs → chunk-RXI6MVY4.mjs} +903 -139
- package/dist/development/dom-export.d.mts +2 -2
- package/dist/development/dom-export.d.ts +1 -2
- package/dist/development/dom-export.js +34 -6102
- package/dist/development/dom-export.mjs +6 -3
- package/dist/development/index.d.mts +33 -67
- package/dist/development/index.d.ts +1893 -197
- package/dist/development/index.js +905 -141
- package/dist/development/index.mjs +2 -2
- package/dist/development/lib/types/route-module.d.mts +1 -2
- package/dist/development/lib/types/route-module.d.ts +1 -2
- package/dist/development/lib/types/route-module.js +1 -1
- package/dist/development/lib/types/route-module.mjs +1 -1
- package/dist/{production/fog-of-war-BLArG-qZ.d.ts → development/lib-CCSAGgcP.d.mts} +57 -12
- package/dist/{production/route-data-C12CLHiN.d.mts → development/route-data-B9_30zbP.d.ts} +11 -1
- package/dist/development/{route-data-C12CLHiN.d.mts → route-data-C6QaL0wu.d.mts} +11 -1
- package/dist/production/{chunk-KKWFQRUV.mjs → chunk-TW7XT4WH.mjs} +903 -139
- package/dist/production/dom-export.d.mts +2 -2
- package/dist/production/dom-export.d.ts +1 -2
- package/dist/production/dom-export.js +34 -6102
- package/dist/production/dom-export.mjs +6 -3
- package/dist/production/index.d.mts +33 -67
- package/dist/production/index.d.ts +1893 -197
- package/dist/production/index.js +905 -141
- package/dist/production/index.mjs +2 -2
- package/dist/production/lib/types/route-module.d.mts +1 -2
- package/dist/production/lib/types/route-module.d.ts +1 -2
- package/dist/production/lib/types/route-module.js +1 -1
- package/dist/production/lib/types/route-module.mjs +1 -1
- package/dist/{development/fog-of-war-BLArG-qZ.d.ts → production/lib-CCSAGgcP.d.mts} +57 -12
- package/dist/{development/route-data-C12CLHiN.d.ts → production/route-data-B9_30zbP.d.ts} +11 -1
- package/dist/production/{route-data-C12CLHiN.d.ts → route-data-C6QaL0wu.d.mts} +11 -1
- package/package.json +5 -3
- package/dist/development/data-CQbyyGzl.d.mts +0 -11
- package/dist/development/data-CQbyyGzl.d.ts +0 -11
- package/dist/development/fog-of-war-D2zsXvum.d.mts +0 -1691
- package/dist/production/data-CQbyyGzl.d.mts +0 -11
- package/dist/production/data-CQbyyGzl.d.ts +0 -11
- package/dist/production/fog-of-war-D2zsXvum.d.mts +0 -1691
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v7.
|
|
2
|
+
* react-router v7.6.0-pre.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -307,14 +307,7 @@ function getUrlBasedHistory(getLocation, createHref2, validateLocation, options
|
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
309
|
function createURL(to) {
|
|
310
|
-
|
|
311
|
-
let href2 = typeof to === "string" ? to : createPath(to);
|
|
312
|
-
href2 = href2.replace(/ $/, "%20");
|
|
313
|
-
invariant(
|
|
314
|
-
base,
|
|
315
|
-
`No window.location.(origin|href) available to create URL for href: ${href2}`
|
|
316
|
-
);
|
|
317
|
-
return new URL(href2, base);
|
|
310
|
+
return createBrowserURLImpl(to);
|
|
318
311
|
}
|
|
319
312
|
let history = {
|
|
320
313
|
get action() {
|
|
@@ -354,6 +347,19 @@ function getUrlBasedHistory(getLocation, createHref2, validateLocation, options
|
|
|
354
347
|
};
|
|
355
348
|
return history;
|
|
356
349
|
}
|
|
350
|
+
function createBrowserURLImpl(to, isAbsolute = false) {
|
|
351
|
+
let base = "http://localhost";
|
|
352
|
+
if (typeof window !== "undefined") {
|
|
353
|
+
base = window.location.origin !== "null" ? window.location.origin : window.location.href;
|
|
354
|
+
}
|
|
355
|
+
invariant(base, "No window.location.(origin|href) available to create URL");
|
|
356
|
+
let href2 = typeof to === "string" ? to : createPath(to);
|
|
357
|
+
href2 = href2.replace(/ $/, "%20");
|
|
358
|
+
if (!isAbsolute && href2.startsWith("//")) {
|
|
359
|
+
href2 = base + href2;
|
|
360
|
+
}
|
|
361
|
+
return new URL(href2, base);
|
|
362
|
+
}
|
|
357
363
|
|
|
358
364
|
// lib/router/utils.ts
|
|
359
365
|
function unstable_createContext(defaultValue) {
|
|
@@ -650,19 +656,19 @@ function generatePath(originalPath, params = {}) {
|
|
|
650
656
|
path = path.replace(/\*$/, "/*");
|
|
651
657
|
}
|
|
652
658
|
const prefix = path.startsWith("/") ? "/" : "";
|
|
653
|
-
const
|
|
659
|
+
const stringify2 = (p) => p == null ? "" : typeof p === "string" ? p : String(p);
|
|
654
660
|
const segments = path.split(/\/+/).map((segment, index, array) => {
|
|
655
661
|
const isLastSegment = index === array.length - 1;
|
|
656
662
|
if (isLastSegment && segment === "*") {
|
|
657
663
|
const star = "*";
|
|
658
|
-
return
|
|
664
|
+
return stringify2(params[star]);
|
|
659
665
|
}
|
|
660
666
|
const keyMatch = segment.match(/^:([\w-]+)(\??)$/);
|
|
661
667
|
if (keyMatch) {
|
|
662
668
|
const [, key, optional] = keyMatch;
|
|
663
669
|
let param = params[key];
|
|
664
670
|
invariant(optional === "?" || param != null, `Missing ":${key}" param`);
|
|
665
|
-
return
|
|
671
|
+
return stringify2(param);
|
|
666
672
|
}
|
|
667
673
|
return segment.replace(/\?$/g, "");
|
|
668
674
|
}).filter((segment) => !!segment);
|
|
@@ -974,53 +980,57 @@ function createRouter(init) {
|
|
|
974
980
|
let initialMatches = matchRoutes(dataRoutes, init.history.location, basename);
|
|
975
981
|
let initialMatchesIsFOW = false;
|
|
976
982
|
let initialErrors = null;
|
|
983
|
+
let initialized;
|
|
977
984
|
if (initialMatches == null && !init.patchRoutesOnNavigation) {
|
|
978
985
|
let error = getInternalRouterError(404, {
|
|
979
986
|
pathname: init.history.location.pathname
|
|
980
987
|
});
|
|
981
988
|
let { matches, route } = getShortCircuitMatches(dataRoutes);
|
|
989
|
+
initialized = true;
|
|
982
990
|
initialMatches = matches;
|
|
983
991
|
initialErrors = { [route.id]: error };
|
|
984
|
-
}
|
|
985
|
-
if (initialMatches && !init.hydrationData) {
|
|
986
|
-
let fogOfWar = checkFogOfWar(
|
|
987
|
-
initialMatches,
|
|
988
|
-
dataRoutes,
|
|
989
|
-
init.history.location.pathname
|
|
990
|
-
);
|
|
991
|
-
if (fogOfWar.active) {
|
|
992
|
-
initialMatches = null;
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
let initialized;
|
|
996
|
-
if (!initialMatches) {
|
|
997
|
-
initialized = false;
|
|
998
|
-
initialMatches = [];
|
|
999
|
-
let fogOfWar = checkFogOfWar(
|
|
1000
|
-
null,
|
|
1001
|
-
dataRoutes,
|
|
1002
|
-
init.history.location.pathname
|
|
1003
|
-
);
|
|
1004
|
-
if (fogOfWar.active && fogOfWar.matches) {
|
|
1005
|
-
initialMatchesIsFOW = true;
|
|
1006
|
-
initialMatches = fogOfWar.matches;
|
|
1007
|
-
}
|
|
1008
|
-
} else if (initialMatches.some((m) => m.route.lazy)) {
|
|
1009
|
-
initialized = false;
|
|
1010
|
-
} else if (!initialMatches.some((m) => m.route.loader)) {
|
|
1011
|
-
initialized = true;
|
|
1012
992
|
} else {
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
993
|
+
if (initialMatches && !init.hydrationData) {
|
|
994
|
+
let fogOfWar = checkFogOfWar(
|
|
995
|
+
initialMatches,
|
|
996
|
+
dataRoutes,
|
|
997
|
+
init.history.location.pathname
|
|
1018
998
|
);
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
999
|
+
if (fogOfWar.active) {
|
|
1000
|
+
initialMatches = null;
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
if (!initialMatches) {
|
|
1004
|
+
initialized = false;
|
|
1005
|
+
initialMatches = [];
|
|
1006
|
+
let fogOfWar = checkFogOfWar(
|
|
1007
|
+
null,
|
|
1008
|
+
dataRoutes,
|
|
1009
|
+
init.history.location.pathname
|
|
1023
1010
|
);
|
|
1011
|
+
if (fogOfWar.active && fogOfWar.matches) {
|
|
1012
|
+
initialMatchesIsFOW = true;
|
|
1013
|
+
initialMatches = fogOfWar.matches;
|
|
1014
|
+
}
|
|
1015
|
+
} else if (initialMatches.some((m) => m.route.lazy)) {
|
|
1016
|
+
initialized = false;
|
|
1017
|
+
} else if (!initialMatches.some((m) => m.route.loader)) {
|
|
1018
|
+
initialized = true;
|
|
1019
|
+
} else {
|
|
1020
|
+
let loaderData = init.hydrationData ? init.hydrationData.loaderData : null;
|
|
1021
|
+
let errors = init.hydrationData ? init.hydrationData.errors : null;
|
|
1022
|
+
if (errors) {
|
|
1023
|
+
let idx = initialMatches.findIndex(
|
|
1024
|
+
(m) => errors[m.route.id] !== void 0
|
|
1025
|
+
);
|
|
1026
|
+
initialized = initialMatches.slice(0, idx + 1).every(
|
|
1027
|
+
(m) => !shouldLoadRouteOnHydration(m.route, loaderData, errors)
|
|
1028
|
+
);
|
|
1029
|
+
} else {
|
|
1030
|
+
initialized = initialMatches.every(
|
|
1031
|
+
(m) => !shouldLoadRouteOnHydration(m.route, loaderData, errors)
|
|
1032
|
+
);
|
|
1033
|
+
}
|
|
1024
1034
|
}
|
|
1025
1035
|
}
|
|
1026
1036
|
let router;
|
|
@@ -2036,6 +2046,10 @@ function createRouter(init) {
|
|
|
2036
2046
|
fetchReloadIds.delete(key);
|
|
2037
2047
|
fetchControllers.delete(key);
|
|
2038
2048
|
revalidatingFetchers.forEach((r) => fetchControllers.delete(r.key));
|
|
2049
|
+
if (state.fetchers.has(key)) {
|
|
2050
|
+
let doneFetcher = getDoneFetcher(actionResult.data);
|
|
2051
|
+
state.fetchers.set(key, doneFetcher);
|
|
2052
|
+
}
|
|
2039
2053
|
let redirect2 = findRedirect(loaderResults);
|
|
2040
2054
|
if (redirect2) {
|
|
2041
2055
|
return startRedirectNavigation(
|
|
@@ -2063,10 +2077,6 @@ function createRouter(init) {
|
|
|
2063
2077
|
revalidatingFetchers,
|
|
2064
2078
|
fetcherResults
|
|
2065
2079
|
);
|
|
2066
|
-
if (state.fetchers.has(key)) {
|
|
2067
|
-
let doneFetcher = getDoneFetcher(actionResult.data);
|
|
2068
|
-
state.fetchers.set(key, doneFetcher);
|
|
2069
|
-
}
|
|
2070
2080
|
abortStaleFetchLoads(loadId);
|
|
2071
2081
|
if (state.navigation.state === "loading" && loadId > pendingNavigationLoadId) {
|
|
2072
2082
|
invariant(pendingAction, "Expected pending action");
|
|
@@ -2202,7 +2212,7 @@ function createRouter(init) {
|
|
|
2202
2212
|
if (redirect2.response.headers.has("X-Remix-Reload-Document")) {
|
|
2203
2213
|
isDocumentReload = true;
|
|
2204
2214
|
} else if (ABSOLUTE_URL_REGEX.test(location)) {
|
|
2205
|
-
const url =
|
|
2215
|
+
const url = createBrowserURLImpl(location, true);
|
|
2206
2216
|
isDocumentReload = // Hard reload if it's an absolute URL to a new origin
|
|
2207
2217
|
url.origin !== routerWindow.location.origin || // Hard reload if it's an absolute URL that does not match our basename
|
|
2208
2218
|
stripBasename(url.pathname, basename) == null;
|
|
@@ -2269,6 +2279,9 @@ function createRouter(init) {
|
|
|
2269
2279
|
});
|
|
2270
2280
|
return dataResults;
|
|
2271
2281
|
}
|
|
2282
|
+
if (request.signal.aborted) {
|
|
2283
|
+
return dataResults;
|
|
2284
|
+
}
|
|
2272
2285
|
for (let [routeId, result] of Object.entries(results)) {
|
|
2273
2286
|
if (isRedirectDataStrategyResult(result)) {
|
|
2274
2287
|
let response = result.result;
|
|
@@ -2783,12 +2796,16 @@ function createStaticHandler(routes, opts) {
|
|
|
2783
2796
|
dataRoutes,
|
|
2784
2797
|
renderedStaticContext,
|
|
2785
2798
|
error,
|
|
2786
|
-
findNearestBoundary(matches, routeId).route.id
|
|
2799
|
+
skipLoaderErrorBubbling ? routeId : findNearestBoundary(matches, routeId).route.id
|
|
2787
2800
|
)
|
|
2788
2801
|
);
|
|
2789
2802
|
} else {
|
|
2790
|
-
let
|
|
2791
|
-
|
|
2803
|
+
let boundaryRouteId = skipLoaderErrorBubbling ? routeId : findNearestBoundary(
|
|
2804
|
+
matches,
|
|
2805
|
+
matches.find(
|
|
2806
|
+
(m) => m.route.id === routeId || m.route.loader
|
|
2807
|
+
)?.route.id || routeId
|
|
2808
|
+
).route.id;
|
|
2792
2809
|
return respond({
|
|
2793
2810
|
matches,
|
|
2794
2811
|
location,
|
|
@@ -2796,7 +2813,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2796
2813
|
loaderData: {},
|
|
2797
2814
|
actionData: null,
|
|
2798
2815
|
errors: {
|
|
2799
|
-
[
|
|
2816
|
+
[boundaryRouteId]: error
|
|
2800
2817
|
},
|
|
2801
2818
|
statusCode: isRouteErrorResponse(error) ? error.status : 500,
|
|
2802
2819
|
actionHeaders: {},
|
|
@@ -3575,7 +3592,7 @@ function shouldLoadRouteOnHydration(route, loaderData, errors) {
|
|
|
3575
3592
|
if (!route.loader) {
|
|
3576
3593
|
return false;
|
|
3577
3594
|
}
|
|
3578
|
-
let hasData = loaderData != null &&
|
|
3595
|
+
let hasData = loaderData != null && route.id in loaderData;
|
|
3579
3596
|
let hasError = errors != null && errors[route.id] !== void 0;
|
|
3580
3597
|
if (!hasData && hasError) {
|
|
3581
3598
|
return false;
|
|
@@ -4784,10 +4801,10 @@ var RouteContext = React.createContext({
|
|
|
4784
4801
|
RouteContext.displayName = "Route";
|
|
4785
4802
|
var RouteErrorContext = React.createContext(null);
|
|
4786
4803
|
RouteErrorContext.displayName = "RouteError";
|
|
4804
|
+
var ENABLE_DEV_WARNINGS = true;
|
|
4787
4805
|
|
|
4788
4806
|
// lib/hooks.tsx
|
|
4789
4807
|
import * as React2 from "react";
|
|
4790
|
-
var ENABLE_DEV_WARNINGS = true;
|
|
4791
4808
|
function useHref(to, { relative } = {}) {
|
|
4792
4809
|
invariant(
|
|
4793
4810
|
useInRouterContext(),
|
|
@@ -4795,13 +4812,13 @@ function useHref(to, { relative } = {}) {
|
|
|
4795
4812
|
// router loaded. We can help them understand how to avoid that.
|
|
4796
4813
|
`useHref() may be used only in the context of a <Router> component.`
|
|
4797
4814
|
);
|
|
4798
|
-
let { basename, navigator
|
|
4815
|
+
let { basename, navigator } = React2.useContext(NavigationContext);
|
|
4799
4816
|
let { hash, pathname, search } = useResolvedPath(to, { relative });
|
|
4800
4817
|
let joinedPathname = pathname;
|
|
4801
4818
|
if (basename !== "/") {
|
|
4802
4819
|
joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname]);
|
|
4803
4820
|
}
|
|
4804
|
-
return
|
|
4821
|
+
return navigator.createHref({ pathname: joinedPathname, search, hash });
|
|
4805
4822
|
}
|
|
4806
4823
|
function useInRouterContext() {
|
|
4807
4824
|
return React2.useContext(LocationContext) != null;
|
|
@@ -4850,7 +4867,7 @@ function useNavigateUnstable() {
|
|
|
4850
4867
|
`useNavigate() may be used only in the context of a <Router> component.`
|
|
4851
4868
|
);
|
|
4852
4869
|
let dataRouterContext = React2.useContext(DataRouterContext);
|
|
4853
|
-
let { basename, navigator
|
|
4870
|
+
let { basename, navigator } = React2.useContext(NavigationContext);
|
|
4854
4871
|
let { matches } = React2.useContext(RouteContext);
|
|
4855
4872
|
let { pathname: locationPathname } = useLocation();
|
|
4856
4873
|
let routePathnamesJson = JSON.stringify(getResolveToMatches(matches));
|
|
@@ -4863,7 +4880,7 @@ function useNavigateUnstable() {
|
|
|
4863
4880
|
warning(activeRef.current, navigateEffectWarning);
|
|
4864
4881
|
if (!activeRef.current) return;
|
|
4865
4882
|
if (typeof to === "number") {
|
|
4866
|
-
|
|
4883
|
+
navigator.go(to);
|
|
4867
4884
|
return;
|
|
4868
4885
|
}
|
|
4869
4886
|
let path = resolveTo(
|
|
@@ -4875,7 +4892,7 @@ function useNavigateUnstable() {
|
|
|
4875
4892
|
if (dataRouterContext == null && basename !== "/") {
|
|
4876
4893
|
path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
|
|
4877
4894
|
}
|
|
4878
|
-
(!!options.replace ?
|
|
4895
|
+
(!!options.replace ? navigator.replace : navigator.push)(
|
|
4879
4896
|
path,
|
|
4880
4897
|
options.state,
|
|
4881
4898
|
options
|
|
@@ -4883,7 +4900,7 @@ function useNavigateUnstable() {
|
|
|
4883
4900
|
},
|
|
4884
4901
|
[
|
|
4885
4902
|
basename,
|
|
4886
|
-
|
|
4903
|
+
navigator,
|
|
4887
4904
|
routePathnamesJson,
|
|
4888
4905
|
locationPathname,
|
|
4889
4906
|
dataRouterContext
|
|
@@ -4931,7 +4948,7 @@ function useRoutesImpl(routes, locationArg, dataRouterState, future) {
|
|
|
4931
4948
|
// router loaded. We can help them understand how to avoid that.
|
|
4932
4949
|
`useRoutes() may be used only in the context of a <Router> component.`
|
|
4933
4950
|
);
|
|
4934
|
-
let { navigator
|
|
4951
|
+
let { navigator, static: isStatic } = React2.useContext(NavigationContext);
|
|
4935
4952
|
let { matches: parentMatches } = React2.useContext(RouteContext);
|
|
4936
4953
|
let routeMatch = parentMatches[parentMatches.length - 1];
|
|
4937
4954
|
let parentParams = routeMatch ? routeMatch.params : {};
|
|
@@ -4985,12 +5002,12 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
4985
5002
|
pathname: joinPaths([
|
|
4986
5003
|
parentPathnameBase,
|
|
4987
5004
|
// Re-encode pathnames that were decoded inside matchRoutes
|
|
4988
|
-
|
|
5005
|
+
navigator.encodeLocation ? navigator.encodeLocation(match.pathname).pathname : match.pathname
|
|
4989
5006
|
]),
|
|
4990
5007
|
pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([
|
|
4991
5008
|
parentPathnameBase,
|
|
4992
5009
|
// Re-encode pathnames that were decoded inside matchRoutes
|
|
4993
|
-
|
|
5010
|
+
navigator.encodeLocation ? navigator.encodeLocation(match.pathnameBase).pathname : match.pathnameBase
|
|
4994
5011
|
])
|
|
4995
5012
|
})
|
|
4996
5013
|
),
|
|
@@ -5240,14 +5257,12 @@ function useNavigation() {
|
|
|
5240
5257
|
function useRevalidator() {
|
|
5241
5258
|
let dataRouterContext = useDataRouterContext("useRevalidator" /* UseRevalidator */);
|
|
5242
5259
|
let state = useDataRouterState("useRevalidator" /* UseRevalidator */);
|
|
5260
|
+
let revalidate = React2.useCallback(async () => {
|
|
5261
|
+
await dataRouterContext.router.revalidate();
|
|
5262
|
+
}, [dataRouterContext.router]);
|
|
5243
5263
|
return React2.useMemo(
|
|
5244
|
-
() => ({
|
|
5245
|
-
|
|
5246
|
-
await dataRouterContext.router.revalidate();
|
|
5247
|
-
},
|
|
5248
|
-
state: state.revalidation
|
|
5249
|
-
}),
|
|
5250
|
-
[dataRouterContext.router, state.revalidation]
|
|
5264
|
+
() => ({ revalidate, state: state.revalidation }),
|
|
5265
|
+
[revalidate, state.revalidation]
|
|
5251
5266
|
);
|
|
5252
5267
|
}
|
|
5253
5268
|
function useMatches() {
|
|
@@ -5369,7 +5384,6 @@ function warnOnce(condition, message) {
|
|
|
5369
5384
|
}
|
|
5370
5385
|
|
|
5371
5386
|
// lib/components.tsx
|
|
5372
|
-
var ENABLE_DEV_WARNINGS2 = true;
|
|
5373
5387
|
function mapRouteProperties(route) {
|
|
5374
5388
|
let updates = {
|
|
5375
5389
|
// Note: this check also occurs in createRoutesFromChildren so update
|
|
@@ -5377,7 +5391,7 @@ function mapRouteProperties(route) {
|
|
|
5377
5391
|
hasErrorBoundary: route.hasErrorBoundary || route.ErrorBoundary != null || route.errorElement != null
|
|
5378
5392
|
};
|
|
5379
5393
|
if (route.Component) {
|
|
5380
|
-
if (
|
|
5394
|
+
if (ENABLE_DEV_WARNINGS) {
|
|
5381
5395
|
if (route.element) {
|
|
5382
5396
|
warning(
|
|
5383
5397
|
false,
|
|
@@ -5391,7 +5405,7 @@ function mapRouteProperties(route) {
|
|
|
5391
5405
|
});
|
|
5392
5406
|
}
|
|
5393
5407
|
if (route.HydrateFallback) {
|
|
5394
|
-
if (
|
|
5408
|
+
if (ENABLE_DEV_WARNINGS) {
|
|
5395
5409
|
if (route.hydrateFallbackElement) {
|
|
5396
5410
|
warning(
|
|
5397
5411
|
false,
|
|
@@ -5405,7 +5419,7 @@ function mapRouteProperties(route) {
|
|
|
5405
5419
|
});
|
|
5406
5420
|
}
|
|
5407
5421
|
if (route.ErrorBoundary) {
|
|
5408
|
-
if (
|
|
5422
|
+
if (ENABLE_DEV_WARNINGS) {
|
|
5409
5423
|
if (route.errorElement) {
|
|
5410
5424
|
warning(
|
|
5411
5425
|
false,
|
|
@@ -5585,7 +5599,7 @@ function RouterProvider({
|
|
|
5585
5599
|
setInterruption(void 0);
|
|
5586
5600
|
}
|
|
5587
5601
|
}, [vtContext.isTransitioning, interruption]);
|
|
5588
|
-
let
|
|
5602
|
+
let navigator = React3.useMemo(() => {
|
|
5589
5603
|
return {
|
|
5590
5604
|
createHref: router.createHref,
|
|
5591
5605
|
encodeLocation: router.encodeLocation,
|
|
@@ -5605,11 +5619,11 @@ function RouterProvider({
|
|
|
5605
5619
|
let dataRouterContext = React3.useMemo(
|
|
5606
5620
|
() => ({
|
|
5607
5621
|
router,
|
|
5608
|
-
navigator
|
|
5622
|
+
navigator,
|
|
5609
5623
|
static: false,
|
|
5610
5624
|
basename
|
|
5611
5625
|
}),
|
|
5612
|
-
[router,
|
|
5626
|
+
[router, navigator, basename]
|
|
5613
5627
|
);
|
|
5614
5628
|
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React3.createElement(DataRouterStateContext.Provider, { value: state }, /* @__PURE__ */ React3.createElement(FetchersContext.Provider, { value: fetcherData.current }, /* @__PURE__ */ React3.createElement(ViewTransitionContext.Provider, { value: vtContext }, /* @__PURE__ */ React3.createElement(
|
|
5615
5629
|
Router,
|
|
@@ -5617,7 +5631,7 @@ function RouterProvider({
|
|
|
5617
5631
|
basename,
|
|
5618
5632
|
location: state.location,
|
|
5619
5633
|
navigationType: state.historyAction,
|
|
5620
|
-
navigator
|
|
5634
|
+
navigator
|
|
5621
5635
|
},
|
|
5622
5636
|
/* @__PURE__ */ React3.createElement(
|
|
5623
5637
|
MemoizedDataRoutes,
|
|
@@ -5720,7 +5734,7 @@ function Router({
|
|
|
5720
5734
|
children = null,
|
|
5721
5735
|
location: locationProp,
|
|
5722
5736
|
navigationType = "POP" /* Pop */,
|
|
5723
|
-
navigator
|
|
5737
|
+
navigator,
|
|
5724
5738
|
static: staticProp = false
|
|
5725
5739
|
}) {
|
|
5726
5740
|
invariant(
|
|
@@ -5731,11 +5745,11 @@ function Router({
|
|
|
5731
5745
|
let navigationContext = React3.useMemo(
|
|
5732
5746
|
() => ({
|
|
5733
5747
|
basename,
|
|
5734
|
-
navigator
|
|
5748
|
+
navigator,
|
|
5735
5749
|
static: staticProp,
|
|
5736
5750
|
future: {}
|
|
5737
5751
|
}),
|
|
5738
|
-
[basename,
|
|
5752
|
+
[basename, navigator, staticProp]
|
|
5739
5753
|
);
|
|
5740
5754
|
if (typeof locationProp === "string") {
|
|
5741
5755
|
locationProp = parsePath(locationProp);
|
|
@@ -6293,7 +6307,669 @@ function createHtml(html) {
|
|
|
6293
6307
|
|
|
6294
6308
|
// lib/dom/ssr/single-fetch.tsx
|
|
6295
6309
|
import * as React4 from "react";
|
|
6296
|
-
|
|
6310
|
+
|
|
6311
|
+
// vendor/turbo-stream-v2/utils.ts
|
|
6312
|
+
var HOLE = -1;
|
|
6313
|
+
var NAN = -2;
|
|
6314
|
+
var NEGATIVE_INFINITY = -3;
|
|
6315
|
+
var NEGATIVE_ZERO = -4;
|
|
6316
|
+
var NULL = -5;
|
|
6317
|
+
var POSITIVE_INFINITY = -6;
|
|
6318
|
+
var UNDEFINED = -7;
|
|
6319
|
+
var TYPE_BIGINT = "B";
|
|
6320
|
+
var TYPE_DATE = "D";
|
|
6321
|
+
var TYPE_ERROR = "E";
|
|
6322
|
+
var TYPE_MAP = "M";
|
|
6323
|
+
var TYPE_NULL_OBJECT = "N";
|
|
6324
|
+
var TYPE_PROMISE = "P";
|
|
6325
|
+
var TYPE_REGEXP = "R";
|
|
6326
|
+
var TYPE_SET = "S";
|
|
6327
|
+
var TYPE_SYMBOL = "Y";
|
|
6328
|
+
var TYPE_URL = "U";
|
|
6329
|
+
var TYPE_PREVIOUS_RESOLVED = "Z";
|
|
6330
|
+
var Deferred2 = class {
|
|
6331
|
+
constructor() {
|
|
6332
|
+
this.promise = new Promise((resolve, reject) => {
|
|
6333
|
+
this.resolve = resolve;
|
|
6334
|
+
this.reject = reject;
|
|
6335
|
+
});
|
|
6336
|
+
}
|
|
6337
|
+
};
|
|
6338
|
+
function createLineSplittingTransform() {
|
|
6339
|
+
const decoder = new TextDecoder();
|
|
6340
|
+
let leftover = "";
|
|
6341
|
+
return new TransformStream({
|
|
6342
|
+
transform(chunk, controller) {
|
|
6343
|
+
const str = decoder.decode(chunk, { stream: true });
|
|
6344
|
+
const parts = (leftover + str).split("\n");
|
|
6345
|
+
leftover = parts.pop() || "";
|
|
6346
|
+
for (const part of parts) {
|
|
6347
|
+
controller.enqueue(part);
|
|
6348
|
+
}
|
|
6349
|
+
},
|
|
6350
|
+
flush(controller) {
|
|
6351
|
+
if (leftover) {
|
|
6352
|
+
controller.enqueue(leftover);
|
|
6353
|
+
}
|
|
6354
|
+
}
|
|
6355
|
+
});
|
|
6356
|
+
}
|
|
6357
|
+
|
|
6358
|
+
// vendor/turbo-stream-v2/flatten.ts
|
|
6359
|
+
function flatten(input) {
|
|
6360
|
+
const { indices } = this;
|
|
6361
|
+
const existing = indices.get(input);
|
|
6362
|
+
if (existing) return [existing];
|
|
6363
|
+
if (input === void 0) return UNDEFINED;
|
|
6364
|
+
if (input === null) return NULL;
|
|
6365
|
+
if (Number.isNaN(input)) return NAN;
|
|
6366
|
+
if (input === Number.POSITIVE_INFINITY) return POSITIVE_INFINITY;
|
|
6367
|
+
if (input === Number.NEGATIVE_INFINITY) return NEGATIVE_INFINITY;
|
|
6368
|
+
if (input === 0 && 1 / input < 0) return NEGATIVE_ZERO;
|
|
6369
|
+
const index = this.index++;
|
|
6370
|
+
indices.set(input, index);
|
|
6371
|
+
stringify.call(this, input, index);
|
|
6372
|
+
return index;
|
|
6373
|
+
}
|
|
6374
|
+
function stringify(input, index) {
|
|
6375
|
+
const { deferred, plugins, postPlugins } = this;
|
|
6376
|
+
const str = this.stringified;
|
|
6377
|
+
const stack = [[input, index]];
|
|
6378
|
+
while (stack.length > 0) {
|
|
6379
|
+
const [input2, index2] = stack.pop();
|
|
6380
|
+
const partsForObj = (obj) => Object.keys(obj).map((k) => `"_${flatten.call(this, k)}":${flatten.call(this, obj[k])}`).join(",");
|
|
6381
|
+
let error = null;
|
|
6382
|
+
switch (typeof input2) {
|
|
6383
|
+
case "boolean":
|
|
6384
|
+
case "number":
|
|
6385
|
+
case "string":
|
|
6386
|
+
str[index2] = JSON.stringify(input2);
|
|
6387
|
+
break;
|
|
6388
|
+
case "bigint":
|
|
6389
|
+
str[index2] = `["${TYPE_BIGINT}","${input2}"]`;
|
|
6390
|
+
break;
|
|
6391
|
+
case "symbol": {
|
|
6392
|
+
const keyFor = Symbol.keyFor(input2);
|
|
6393
|
+
if (!keyFor) {
|
|
6394
|
+
error = new Error(
|
|
6395
|
+
"Cannot encode symbol unless created with Symbol.for()"
|
|
6396
|
+
);
|
|
6397
|
+
} else {
|
|
6398
|
+
str[index2] = `["${TYPE_SYMBOL}",${JSON.stringify(keyFor)}]`;
|
|
6399
|
+
}
|
|
6400
|
+
break;
|
|
6401
|
+
}
|
|
6402
|
+
case "object": {
|
|
6403
|
+
if (!input2) {
|
|
6404
|
+
str[index2] = `${NULL}`;
|
|
6405
|
+
break;
|
|
6406
|
+
}
|
|
6407
|
+
const isArray = Array.isArray(input2);
|
|
6408
|
+
let pluginHandled = false;
|
|
6409
|
+
if (!isArray && plugins) {
|
|
6410
|
+
for (const plugin of plugins) {
|
|
6411
|
+
const pluginResult = plugin(input2);
|
|
6412
|
+
if (Array.isArray(pluginResult)) {
|
|
6413
|
+
pluginHandled = true;
|
|
6414
|
+
const [pluginIdentifier, ...rest] = pluginResult;
|
|
6415
|
+
str[index2] = `[${JSON.stringify(pluginIdentifier)}`;
|
|
6416
|
+
if (rest.length > 0) {
|
|
6417
|
+
str[index2] += `,${rest.map((v) => flatten.call(this, v)).join(",")}`;
|
|
6418
|
+
}
|
|
6419
|
+
str[index2] += "]";
|
|
6420
|
+
break;
|
|
6421
|
+
}
|
|
6422
|
+
}
|
|
6423
|
+
}
|
|
6424
|
+
if (!pluginHandled) {
|
|
6425
|
+
let result = isArray ? "[" : "{";
|
|
6426
|
+
if (isArray) {
|
|
6427
|
+
for (let i = 0; i < input2.length; i++)
|
|
6428
|
+
result += (i ? "," : "") + (i in input2 ? flatten.call(this, input2[i]) : HOLE);
|
|
6429
|
+
str[index2] = `${result}]`;
|
|
6430
|
+
} else if (input2 instanceof Date) {
|
|
6431
|
+
str[index2] = `["${TYPE_DATE}",${input2.getTime()}]`;
|
|
6432
|
+
} else if (input2 instanceof URL) {
|
|
6433
|
+
str[index2] = `["${TYPE_URL}",${JSON.stringify(input2.href)}]`;
|
|
6434
|
+
} else if (input2 instanceof RegExp) {
|
|
6435
|
+
str[index2] = `["${TYPE_REGEXP}",${JSON.stringify(
|
|
6436
|
+
input2.source
|
|
6437
|
+
)},${JSON.stringify(input2.flags)}]`;
|
|
6438
|
+
} else if (input2 instanceof Set) {
|
|
6439
|
+
if (input2.size > 0) {
|
|
6440
|
+
str[index2] = `["${TYPE_SET}",${[...input2].map((val) => flatten.call(this, val)).join(",")}]`;
|
|
6441
|
+
} else {
|
|
6442
|
+
str[index2] = `["${TYPE_SET}"]`;
|
|
6443
|
+
}
|
|
6444
|
+
} else if (input2 instanceof Map) {
|
|
6445
|
+
if (input2.size > 0) {
|
|
6446
|
+
str[index2] = `["${TYPE_MAP}",${[...input2].flatMap(([k, v]) => [
|
|
6447
|
+
flatten.call(this, k),
|
|
6448
|
+
flatten.call(this, v)
|
|
6449
|
+
]).join(",")}]`;
|
|
6450
|
+
} else {
|
|
6451
|
+
str[index2] = `["${TYPE_MAP}"]`;
|
|
6452
|
+
}
|
|
6453
|
+
} else if (input2 instanceof Promise) {
|
|
6454
|
+
str[index2] = `["${TYPE_PROMISE}",${index2}]`;
|
|
6455
|
+
deferred[index2] = input2;
|
|
6456
|
+
} else if (input2 instanceof Error) {
|
|
6457
|
+
str[index2] = `["${TYPE_ERROR}",${JSON.stringify(input2.message)}`;
|
|
6458
|
+
if (input2.name !== "Error") {
|
|
6459
|
+
str[index2] += `,${JSON.stringify(input2.name)}`;
|
|
6460
|
+
}
|
|
6461
|
+
str[index2] += "]";
|
|
6462
|
+
} else if (Object.getPrototypeOf(input2) === null) {
|
|
6463
|
+
str[index2] = `["${TYPE_NULL_OBJECT}",{${partsForObj(input2)}}]`;
|
|
6464
|
+
} else if (isPlainObject(input2)) {
|
|
6465
|
+
str[index2] = `{${partsForObj(input2)}}`;
|
|
6466
|
+
} else {
|
|
6467
|
+
error = new Error("Cannot encode object with prototype");
|
|
6468
|
+
}
|
|
6469
|
+
}
|
|
6470
|
+
break;
|
|
6471
|
+
}
|
|
6472
|
+
default: {
|
|
6473
|
+
const isArray = Array.isArray(input2);
|
|
6474
|
+
let pluginHandled = false;
|
|
6475
|
+
if (!isArray && plugins) {
|
|
6476
|
+
for (const plugin of plugins) {
|
|
6477
|
+
const pluginResult = plugin(input2);
|
|
6478
|
+
if (Array.isArray(pluginResult)) {
|
|
6479
|
+
pluginHandled = true;
|
|
6480
|
+
const [pluginIdentifier, ...rest] = pluginResult;
|
|
6481
|
+
str[index2] = `[${JSON.stringify(pluginIdentifier)}`;
|
|
6482
|
+
if (rest.length > 0) {
|
|
6483
|
+
str[index2] += `,${rest.map((v) => flatten.call(this, v)).join(",")}`;
|
|
6484
|
+
}
|
|
6485
|
+
str[index2] += "]";
|
|
6486
|
+
break;
|
|
6487
|
+
}
|
|
6488
|
+
}
|
|
6489
|
+
}
|
|
6490
|
+
if (!pluginHandled) {
|
|
6491
|
+
error = new Error("Cannot encode function or unexpected type");
|
|
6492
|
+
}
|
|
6493
|
+
}
|
|
6494
|
+
}
|
|
6495
|
+
if (error) {
|
|
6496
|
+
let pluginHandled = false;
|
|
6497
|
+
if (postPlugins) {
|
|
6498
|
+
for (const plugin of postPlugins) {
|
|
6499
|
+
const pluginResult = plugin(input2);
|
|
6500
|
+
if (Array.isArray(pluginResult)) {
|
|
6501
|
+
pluginHandled = true;
|
|
6502
|
+
const [pluginIdentifier, ...rest] = pluginResult;
|
|
6503
|
+
str[index2] = `[${JSON.stringify(pluginIdentifier)}`;
|
|
6504
|
+
if (rest.length > 0) {
|
|
6505
|
+
str[index2] += `,${rest.map((v) => flatten.call(this, v)).join(",")}`;
|
|
6506
|
+
}
|
|
6507
|
+
str[index2] += "]";
|
|
6508
|
+
break;
|
|
6509
|
+
}
|
|
6510
|
+
}
|
|
6511
|
+
}
|
|
6512
|
+
if (!pluginHandled) {
|
|
6513
|
+
throw error;
|
|
6514
|
+
}
|
|
6515
|
+
}
|
|
6516
|
+
}
|
|
6517
|
+
}
|
|
6518
|
+
var objectProtoNames = Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
|
|
6519
|
+
function isPlainObject(thing) {
|
|
6520
|
+
const proto = Object.getPrototypeOf(thing);
|
|
6521
|
+
return proto === Object.prototype || proto === null || Object.getOwnPropertyNames(proto).sort().join("\0") === objectProtoNames;
|
|
6522
|
+
}
|
|
6523
|
+
|
|
6524
|
+
// vendor/turbo-stream-v2/unflatten.ts
|
|
6525
|
+
var globalObj = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : void 0;
|
|
6526
|
+
function unflatten(parsed) {
|
|
6527
|
+
const { hydrated, values } = this;
|
|
6528
|
+
if (typeof parsed === "number") return hydrate.call(this, parsed);
|
|
6529
|
+
if (!Array.isArray(parsed) || !parsed.length) throw new SyntaxError();
|
|
6530
|
+
const startIndex = values.length;
|
|
6531
|
+
for (const value of parsed) {
|
|
6532
|
+
values.push(value);
|
|
6533
|
+
}
|
|
6534
|
+
hydrated.length = values.length;
|
|
6535
|
+
return hydrate.call(this, startIndex);
|
|
6536
|
+
}
|
|
6537
|
+
function hydrate(index) {
|
|
6538
|
+
const { hydrated, values, deferred, plugins } = this;
|
|
6539
|
+
let result;
|
|
6540
|
+
const stack = [
|
|
6541
|
+
[
|
|
6542
|
+
index,
|
|
6543
|
+
(v) => {
|
|
6544
|
+
result = v;
|
|
6545
|
+
}
|
|
6546
|
+
]
|
|
6547
|
+
];
|
|
6548
|
+
let postRun = [];
|
|
6549
|
+
while (stack.length > 0) {
|
|
6550
|
+
const [index2, set] = stack.pop();
|
|
6551
|
+
switch (index2) {
|
|
6552
|
+
case UNDEFINED:
|
|
6553
|
+
set(void 0);
|
|
6554
|
+
continue;
|
|
6555
|
+
case NULL:
|
|
6556
|
+
set(null);
|
|
6557
|
+
continue;
|
|
6558
|
+
case NAN:
|
|
6559
|
+
set(NaN);
|
|
6560
|
+
continue;
|
|
6561
|
+
case POSITIVE_INFINITY:
|
|
6562
|
+
set(Infinity);
|
|
6563
|
+
continue;
|
|
6564
|
+
case NEGATIVE_INFINITY:
|
|
6565
|
+
set(-Infinity);
|
|
6566
|
+
continue;
|
|
6567
|
+
case NEGATIVE_ZERO:
|
|
6568
|
+
set(-0);
|
|
6569
|
+
continue;
|
|
6570
|
+
}
|
|
6571
|
+
if (hydrated[index2]) {
|
|
6572
|
+
set(hydrated[index2]);
|
|
6573
|
+
continue;
|
|
6574
|
+
}
|
|
6575
|
+
const value = values[index2];
|
|
6576
|
+
if (!value || typeof value !== "object") {
|
|
6577
|
+
hydrated[index2] = value;
|
|
6578
|
+
set(value);
|
|
6579
|
+
continue;
|
|
6580
|
+
}
|
|
6581
|
+
if (Array.isArray(value)) {
|
|
6582
|
+
if (typeof value[0] === "string") {
|
|
6583
|
+
const [type, b, c] = value;
|
|
6584
|
+
switch (type) {
|
|
6585
|
+
case TYPE_DATE:
|
|
6586
|
+
set(hydrated[index2] = new Date(b));
|
|
6587
|
+
continue;
|
|
6588
|
+
case TYPE_URL:
|
|
6589
|
+
set(hydrated[index2] = new URL(b));
|
|
6590
|
+
continue;
|
|
6591
|
+
case TYPE_BIGINT:
|
|
6592
|
+
set(hydrated[index2] = BigInt(b));
|
|
6593
|
+
continue;
|
|
6594
|
+
case TYPE_REGEXP:
|
|
6595
|
+
set(hydrated[index2] = new RegExp(b, c));
|
|
6596
|
+
continue;
|
|
6597
|
+
case TYPE_SYMBOL:
|
|
6598
|
+
set(hydrated[index2] = Symbol.for(b));
|
|
6599
|
+
continue;
|
|
6600
|
+
case TYPE_SET:
|
|
6601
|
+
const newSet = /* @__PURE__ */ new Set();
|
|
6602
|
+
hydrated[index2] = newSet;
|
|
6603
|
+
for (let i = value.length - 1; i > 0; i--)
|
|
6604
|
+
stack.push([
|
|
6605
|
+
value[i],
|
|
6606
|
+
(v) => {
|
|
6607
|
+
newSet.add(v);
|
|
6608
|
+
}
|
|
6609
|
+
]);
|
|
6610
|
+
set(newSet);
|
|
6611
|
+
continue;
|
|
6612
|
+
case TYPE_MAP:
|
|
6613
|
+
const map = /* @__PURE__ */ new Map();
|
|
6614
|
+
hydrated[index2] = map;
|
|
6615
|
+
for (let i = value.length - 2; i > 0; i -= 2) {
|
|
6616
|
+
const r = [];
|
|
6617
|
+
stack.push([
|
|
6618
|
+
value[i + 1],
|
|
6619
|
+
(v) => {
|
|
6620
|
+
r[1] = v;
|
|
6621
|
+
}
|
|
6622
|
+
]);
|
|
6623
|
+
stack.push([
|
|
6624
|
+
value[i],
|
|
6625
|
+
(k) => {
|
|
6626
|
+
r[0] = k;
|
|
6627
|
+
}
|
|
6628
|
+
]);
|
|
6629
|
+
postRun.push(() => {
|
|
6630
|
+
map.set(r[0], r[1]);
|
|
6631
|
+
});
|
|
6632
|
+
}
|
|
6633
|
+
set(map);
|
|
6634
|
+
continue;
|
|
6635
|
+
case TYPE_NULL_OBJECT:
|
|
6636
|
+
const obj = /* @__PURE__ */ Object.create(null);
|
|
6637
|
+
hydrated[index2] = obj;
|
|
6638
|
+
for (const key of Object.keys(b).reverse()) {
|
|
6639
|
+
const r = [];
|
|
6640
|
+
stack.push([
|
|
6641
|
+
b[key],
|
|
6642
|
+
(v) => {
|
|
6643
|
+
r[1] = v;
|
|
6644
|
+
}
|
|
6645
|
+
]);
|
|
6646
|
+
stack.push([
|
|
6647
|
+
Number(key.slice(1)),
|
|
6648
|
+
(k) => {
|
|
6649
|
+
r[0] = k;
|
|
6650
|
+
}
|
|
6651
|
+
]);
|
|
6652
|
+
postRun.push(() => {
|
|
6653
|
+
obj[r[0]] = r[1];
|
|
6654
|
+
});
|
|
6655
|
+
}
|
|
6656
|
+
set(obj);
|
|
6657
|
+
continue;
|
|
6658
|
+
case TYPE_PROMISE:
|
|
6659
|
+
if (hydrated[b]) {
|
|
6660
|
+
set(hydrated[index2] = hydrated[b]);
|
|
6661
|
+
} else {
|
|
6662
|
+
const d = new Deferred2();
|
|
6663
|
+
deferred[b] = d;
|
|
6664
|
+
set(hydrated[index2] = d.promise);
|
|
6665
|
+
}
|
|
6666
|
+
continue;
|
|
6667
|
+
case TYPE_ERROR:
|
|
6668
|
+
const [, message, errorType] = value;
|
|
6669
|
+
let error = errorType && globalObj && globalObj[errorType] ? new globalObj[errorType](message) : new Error(message);
|
|
6670
|
+
hydrated[index2] = error;
|
|
6671
|
+
set(error);
|
|
6672
|
+
continue;
|
|
6673
|
+
case TYPE_PREVIOUS_RESOLVED:
|
|
6674
|
+
set(hydrated[index2] = hydrated[b]);
|
|
6675
|
+
continue;
|
|
6676
|
+
default:
|
|
6677
|
+
if (Array.isArray(plugins)) {
|
|
6678
|
+
const r = [];
|
|
6679
|
+
const vals = value.slice(1);
|
|
6680
|
+
for (let i = 0; i < vals.length; i++) {
|
|
6681
|
+
const v = vals[i];
|
|
6682
|
+
stack.push([
|
|
6683
|
+
v,
|
|
6684
|
+
(v2) => {
|
|
6685
|
+
r[i] = v2;
|
|
6686
|
+
}
|
|
6687
|
+
]);
|
|
6688
|
+
}
|
|
6689
|
+
postRun.push(() => {
|
|
6690
|
+
for (const plugin of plugins) {
|
|
6691
|
+
const result2 = plugin(value[0], ...r);
|
|
6692
|
+
if (result2) {
|
|
6693
|
+
set(hydrated[index2] = result2.value);
|
|
6694
|
+
return;
|
|
6695
|
+
}
|
|
6696
|
+
}
|
|
6697
|
+
throw new SyntaxError();
|
|
6698
|
+
});
|
|
6699
|
+
continue;
|
|
6700
|
+
}
|
|
6701
|
+
throw new SyntaxError();
|
|
6702
|
+
}
|
|
6703
|
+
} else {
|
|
6704
|
+
const array = [];
|
|
6705
|
+
hydrated[index2] = array;
|
|
6706
|
+
for (let i = 0; i < value.length; i++) {
|
|
6707
|
+
const n = value[i];
|
|
6708
|
+
if (n !== HOLE) {
|
|
6709
|
+
stack.push([
|
|
6710
|
+
n,
|
|
6711
|
+
(v) => {
|
|
6712
|
+
array[i] = v;
|
|
6713
|
+
}
|
|
6714
|
+
]);
|
|
6715
|
+
}
|
|
6716
|
+
}
|
|
6717
|
+
set(array);
|
|
6718
|
+
continue;
|
|
6719
|
+
}
|
|
6720
|
+
} else {
|
|
6721
|
+
const object = {};
|
|
6722
|
+
hydrated[index2] = object;
|
|
6723
|
+
for (const key of Object.keys(value).reverse()) {
|
|
6724
|
+
const r = [];
|
|
6725
|
+
stack.push([
|
|
6726
|
+
value[key],
|
|
6727
|
+
(v) => {
|
|
6728
|
+
r[1] = v;
|
|
6729
|
+
}
|
|
6730
|
+
]);
|
|
6731
|
+
stack.push([
|
|
6732
|
+
Number(key.slice(1)),
|
|
6733
|
+
(k) => {
|
|
6734
|
+
r[0] = k;
|
|
6735
|
+
}
|
|
6736
|
+
]);
|
|
6737
|
+
postRun.push(() => {
|
|
6738
|
+
object[r[0]] = r[1];
|
|
6739
|
+
});
|
|
6740
|
+
}
|
|
6741
|
+
set(object);
|
|
6742
|
+
continue;
|
|
6743
|
+
}
|
|
6744
|
+
}
|
|
6745
|
+
while (postRun.length > 0) {
|
|
6746
|
+
postRun.pop()();
|
|
6747
|
+
}
|
|
6748
|
+
return result;
|
|
6749
|
+
}
|
|
6750
|
+
|
|
6751
|
+
// vendor/turbo-stream-v2/turbo-stream.ts
|
|
6752
|
+
async function decode(readable, options) {
|
|
6753
|
+
const { plugins } = options ?? {};
|
|
6754
|
+
const done = new Deferred2();
|
|
6755
|
+
const reader = readable.pipeThrough(createLineSplittingTransform()).getReader();
|
|
6756
|
+
const decoder = {
|
|
6757
|
+
values: [],
|
|
6758
|
+
hydrated: [],
|
|
6759
|
+
deferred: {},
|
|
6760
|
+
plugins
|
|
6761
|
+
};
|
|
6762
|
+
const decoded = await decodeInitial.call(decoder, reader);
|
|
6763
|
+
let donePromise = done.promise;
|
|
6764
|
+
if (decoded.done) {
|
|
6765
|
+
done.resolve();
|
|
6766
|
+
} else {
|
|
6767
|
+
donePromise = decodeDeferred.call(decoder, reader).then(done.resolve).catch((reason) => {
|
|
6768
|
+
for (const deferred of Object.values(decoder.deferred)) {
|
|
6769
|
+
deferred.reject(reason);
|
|
6770
|
+
}
|
|
6771
|
+
done.reject(reason);
|
|
6772
|
+
});
|
|
6773
|
+
}
|
|
6774
|
+
return {
|
|
6775
|
+
done: donePromise.then(() => reader.closed),
|
|
6776
|
+
value: decoded.value
|
|
6777
|
+
};
|
|
6778
|
+
}
|
|
6779
|
+
async function decodeInitial(reader) {
|
|
6780
|
+
const read = await reader.read();
|
|
6781
|
+
if (!read.value) {
|
|
6782
|
+
throw new SyntaxError();
|
|
6783
|
+
}
|
|
6784
|
+
let line;
|
|
6785
|
+
try {
|
|
6786
|
+
line = JSON.parse(read.value);
|
|
6787
|
+
} catch (reason) {
|
|
6788
|
+
throw new SyntaxError();
|
|
6789
|
+
}
|
|
6790
|
+
return {
|
|
6791
|
+
done: read.done,
|
|
6792
|
+
value: unflatten.call(this, line)
|
|
6793
|
+
};
|
|
6794
|
+
}
|
|
6795
|
+
async function decodeDeferred(reader) {
|
|
6796
|
+
let read = await reader.read();
|
|
6797
|
+
while (!read.done) {
|
|
6798
|
+
if (!read.value) continue;
|
|
6799
|
+
const line = read.value;
|
|
6800
|
+
switch (line[0]) {
|
|
6801
|
+
case TYPE_PROMISE: {
|
|
6802
|
+
const colonIndex = line.indexOf(":");
|
|
6803
|
+
const deferredId = Number(line.slice(1, colonIndex));
|
|
6804
|
+
const deferred = this.deferred[deferredId];
|
|
6805
|
+
if (!deferred) {
|
|
6806
|
+
throw new Error(`Deferred ID ${deferredId} not found in stream`);
|
|
6807
|
+
}
|
|
6808
|
+
const lineData = line.slice(colonIndex + 1);
|
|
6809
|
+
let jsonLine;
|
|
6810
|
+
try {
|
|
6811
|
+
jsonLine = JSON.parse(lineData);
|
|
6812
|
+
} catch (reason) {
|
|
6813
|
+
throw new SyntaxError();
|
|
6814
|
+
}
|
|
6815
|
+
const value = unflatten.call(this, jsonLine);
|
|
6816
|
+
deferred.resolve(value);
|
|
6817
|
+
break;
|
|
6818
|
+
}
|
|
6819
|
+
case TYPE_ERROR: {
|
|
6820
|
+
const colonIndex = line.indexOf(":");
|
|
6821
|
+
const deferredId = Number(line.slice(1, colonIndex));
|
|
6822
|
+
const deferred = this.deferred[deferredId];
|
|
6823
|
+
if (!deferred) {
|
|
6824
|
+
throw new Error(`Deferred ID ${deferredId} not found in stream`);
|
|
6825
|
+
}
|
|
6826
|
+
const lineData = line.slice(colonIndex + 1);
|
|
6827
|
+
let jsonLine;
|
|
6828
|
+
try {
|
|
6829
|
+
jsonLine = JSON.parse(lineData);
|
|
6830
|
+
} catch (reason) {
|
|
6831
|
+
throw new SyntaxError();
|
|
6832
|
+
}
|
|
6833
|
+
const value = unflatten.call(this, jsonLine);
|
|
6834
|
+
deferred.reject(value);
|
|
6835
|
+
break;
|
|
6836
|
+
}
|
|
6837
|
+
default:
|
|
6838
|
+
throw new SyntaxError();
|
|
6839
|
+
}
|
|
6840
|
+
read = await reader.read();
|
|
6841
|
+
}
|
|
6842
|
+
}
|
|
6843
|
+
function encode(input, options) {
|
|
6844
|
+
const { plugins, postPlugins, signal } = options ?? {};
|
|
6845
|
+
const encoder2 = {
|
|
6846
|
+
deferred: {},
|
|
6847
|
+
index: 0,
|
|
6848
|
+
indices: /* @__PURE__ */ new Map(),
|
|
6849
|
+
stringified: [],
|
|
6850
|
+
plugins,
|
|
6851
|
+
postPlugins,
|
|
6852
|
+
signal
|
|
6853
|
+
};
|
|
6854
|
+
const textEncoder = new TextEncoder();
|
|
6855
|
+
let lastSentIndex = 0;
|
|
6856
|
+
const readable = new ReadableStream({
|
|
6857
|
+
async start(controller) {
|
|
6858
|
+
const id = flatten.call(encoder2, input);
|
|
6859
|
+
if (Array.isArray(id)) {
|
|
6860
|
+
throw new Error("This should never happen");
|
|
6861
|
+
}
|
|
6862
|
+
if (id < 0) {
|
|
6863
|
+
controller.enqueue(textEncoder.encode(`${id}
|
|
6864
|
+
`));
|
|
6865
|
+
} else {
|
|
6866
|
+
controller.enqueue(
|
|
6867
|
+
textEncoder.encode(`[${encoder2.stringified.join(",")}]
|
|
6868
|
+
`)
|
|
6869
|
+
);
|
|
6870
|
+
lastSentIndex = encoder2.stringified.length - 1;
|
|
6871
|
+
}
|
|
6872
|
+
const seenPromises = /* @__PURE__ */ new WeakSet();
|
|
6873
|
+
if (Object.keys(encoder2.deferred).length) {
|
|
6874
|
+
let raceDone;
|
|
6875
|
+
const racePromise = new Promise((resolve, reject) => {
|
|
6876
|
+
raceDone = resolve;
|
|
6877
|
+
if (signal) {
|
|
6878
|
+
const rejectPromise = () => reject(signal.reason || new Error("Signal was aborted."));
|
|
6879
|
+
if (signal.aborted) {
|
|
6880
|
+
rejectPromise();
|
|
6881
|
+
} else {
|
|
6882
|
+
signal.addEventListener("abort", (event) => {
|
|
6883
|
+
rejectPromise();
|
|
6884
|
+
});
|
|
6885
|
+
}
|
|
6886
|
+
}
|
|
6887
|
+
});
|
|
6888
|
+
while (Object.keys(encoder2.deferred).length > 0) {
|
|
6889
|
+
for (const [deferredId, deferred] of Object.entries(
|
|
6890
|
+
encoder2.deferred
|
|
6891
|
+
)) {
|
|
6892
|
+
if (seenPromises.has(deferred)) continue;
|
|
6893
|
+
seenPromises.add(
|
|
6894
|
+
// biome-ignore lint/suspicious/noAssignInExpressions: <explanation>
|
|
6895
|
+
encoder2.deferred[Number(deferredId)] = Promise.race([
|
|
6896
|
+
racePromise,
|
|
6897
|
+
deferred
|
|
6898
|
+
]).then(
|
|
6899
|
+
(resolved) => {
|
|
6900
|
+
const id2 = flatten.call(encoder2, resolved);
|
|
6901
|
+
if (Array.isArray(id2)) {
|
|
6902
|
+
controller.enqueue(
|
|
6903
|
+
textEncoder.encode(
|
|
6904
|
+
`${TYPE_PROMISE}${deferredId}:[["${TYPE_PREVIOUS_RESOLVED}",${id2[0]}]]
|
|
6905
|
+
`
|
|
6906
|
+
)
|
|
6907
|
+
);
|
|
6908
|
+
encoder2.index++;
|
|
6909
|
+
lastSentIndex++;
|
|
6910
|
+
} else if (id2 < 0) {
|
|
6911
|
+
controller.enqueue(
|
|
6912
|
+
textEncoder.encode(
|
|
6913
|
+
`${TYPE_PROMISE}${deferredId}:${id2}
|
|
6914
|
+
`
|
|
6915
|
+
)
|
|
6916
|
+
);
|
|
6917
|
+
} else {
|
|
6918
|
+
const values = encoder2.stringified.slice(lastSentIndex + 1).join(",");
|
|
6919
|
+
controller.enqueue(
|
|
6920
|
+
textEncoder.encode(
|
|
6921
|
+
`${TYPE_PROMISE}${deferredId}:[${values}]
|
|
6922
|
+
`
|
|
6923
|
+
)
|
|
6924
|
+
);
|
|
6925
|
+
lastSentIndex = encoder2.stringified.length - 1;
|
|
6926
|
+
}
|
|
6927
|
+
},
|
|
6928
|
+
(reason) => {
|
|
6929
|
+
if (!reason || typeof reason !== "object" || !(reason instanceof Error)) {
|
|
6930
|
+
reason = new Error("An unknown error occurred");
|
|
6931
|
+
}
|
|
6932
|
+
const id2 = flatten.call(encoder2, reason);
|
|
6933
|
+
if (Array.isArray(id2)) {
|
|
6934
|
+
controller.enqueue(
|
|
6935
|
+
textEncoder.encode(
|
|
6936
|
+
`${TYPE_ERROR}${deferredId}:[["${TYPE_PREVIOUS_RESOLVED}",${id2[0]}]]
|
|
6937
|
+
`
|
|
6938
|
+
)
|
|
6939
|
+
);
|
|
6940
|
+
encoder2.index++;
|
|
6941
|
+
lastSentIndex++;
|
|
6942
|
+
} else if (id2 < 0) {
|
|
6943
|
+
controller.enqueue(
|
|
6944
|
+
textEncoder.encode(`${TYPE_ERROR}${deferredId}:${id2}
|
|
6945
|
+
`)
|
|
6946
|
+
);
|
|
6947
|
+
} else {
|
|
6948
|
+
const values = encoder2.stringified.slice(lastSentIndex + 1).join(",");
|
|
6949
|
+
controller.enqueue(
|
|
6950
|
+
textEncoder.encode(
|
|
6951
|
+
`${TYPE_ERROR}${deferredId}:[${values}]
|
|
6952
|
+
`
|
|
6953
|
+
)
|
|
6954
|
+
);
|
|
6955
|
+
lastSentIndex = encoder2.stringified.length - 1;
|
|
6956
|
+
}
|
|
6957
|
+
}
|
|
6958
|
+
).finally(() => {
|
|
6959
|
+
delete encoder2.deferred[Number(deferredId)];
|
|
6960
|
+
})
|
|
6961
|
+
);
|
|
6962
|
+
}
|
|
6963
|
+
await Promise.race(Object.values(encoder2.deferred));
|
|
6964
|
+
}
|
|
6965
|
+
raceDone();
|
|
6966
|
+
}
|
|
6967
|
+
await Promise.all(Object.values(encoder2.deferred));
|
|
6968
|
+
controller.close();
|
|
6969
|
+
}
|
|
6970
|
+
});
|
|
6971
|
+
return readable;
|
|
6972
|
+
}
|
|
6297
6973
|
|
|
6298
6974
|
// lib/dom/ssr/data.ts
|
|
6299
6975
|
async function createRequestInit(request) {
|
|
@@ -6318,6 +6994,8 @@ async function createRequestInit(request) {
|
|
|
6318
6994
|
|
|
6319
6995
|
// lib/dom/ssr/single-fetch.tsx
|
|
6320
6996
|
var SingleFetchRedirectSymbol = Symbol("SingleFetchRedirect");
|
|
6997
|
+
var SingleFetchNoResultError = class extends Error {
|
|
6998
|
+
};
|
|
6321
6999
|
var SINGLE_FETCH_REDIRECT_STATUS = 202;
|
|
6322
7000
|
var NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([100, 101, 204, 205]);
|
|
6323
7001
|
function StreamTransfer({
|
|
@@ -6446,7 +7124,7 @@ async function singleFetchActionStrategy(args, fetchAndDecode, basename) {
|
|
|
6446
7124
|
});
|
|
6447
7125
|
return result2;
|
|
6448
7126
|
});
|
|
6449
|
-
if (isResponse(result.result) || isRouteErrorResponse(result.result)) {
|
|
7127
|
+
if (isResponse(result.result) || isRouteErrorResponse(result.result) || isDataWithResponseInit(result.result)) {
|
|
6450
7128
|
return { [actionMatch.route.id]: result };
|
|
6451
7129
|
}
|
|
6452
7130
|
return {
|
|
@@ -6544,8 +7222,39 @@ async function singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, f
|
|
|
6544
7222
|
}
|
|
6545
7223
|
}
|
|
6546
7224
|
await resolvePromise;
|
|
7225
|
+
await bubbleMiddlewareErrors(
|
|
7226
|
+
singleFetchDfd.promise,
|
|
7227
|
+
args.matches,
|
|
7228
|
+
routesParams,
|
|
7229
|
+
results
|
|
7230
|
+
);
|
|
6547
7231
|
return results;
|
|
6548
7232
|
}
|
|
7233
|
+
async function bubbleMiddlewareErrors(singleFetchPromise, matches, routesParams, results) {
|
|
7234
|
+
try {
|
|
7235
|
+
let middlewareError;
|
|
7236
|
+
let fetchedData = await singleFetchPromise;
|
|
7237
|
+
if ("routes" in fetchedData) {
|
|
7238
|
+
for (let match of matches) {
|
|
7239
|
+
if (match.route.id in fetchedData.routes) {
|
|
7240
|
+
let routeResult = fetchedData.routes[match.route.id];
|
|
7241
|
+
if ("error" in routeResult) {
|
|
7242
|
+
middlewareError = routeResult.error;
|
|
7243
|
+
break;
|
|
7244
|
+
}
|
|
7245
|
+
}
|
|
7246
|
+
}
|
|
7247
|
+
}
|
|
7248
|
+
if (middlewareError !== void 0) {
|
|
7249
|
+
Array.from(routesParams.values()).forEach((routeId) => {
|
|
7250
|
+
if (results[routeId].result instanceof SingleFetchNoResultError) {
|
|
7251
|
+
results[routeId].result = middlewareError;
|
|
7252
|
+
}
|
|
7253
|
+
});
|
|
7254
|
+
}
|
|
7255
|
+
} catch (e) {
|
|
7256
|
+
}
|
|
7257
|
+
}
|
|
6549
7258
|
async function singleFetchLoaderFetcherStrategy(args, fetchAndDecode, basename) {
|
|
6550
7259
|
let fetcherMatch = args.matches.find((m) => m.unstable_shouldCallHandler());
|
|
6551
7260
|
invariant2(fetcherMatch, "No fetcher match found");
|
|
@@ -6704,12 +7413,16 @@ function unwrapSingleFetchResult(result, routeId) {
|
|
|
6704
7413
|
});
|
|
6705
7414
|
}
|
|
6706
7415
|
let routeResult = result.routes[routeId];
|
|
6707
|
-
if (
|
|
7416
|
+
if (routeResult == null) {
|
|
7417
|
+
throw new SingleFetchNoResultError(
|
|
7418
|
+
`No result found for routeId "${routeId}"`
|
|
7419
|
+
);
|
|
7420
|
+
} else if ("error" in routeResult) {
|
|
6708
7421
|
throw routeResult.error;
|
|
6709
7422
|
} else if ("data" in routeResult) {
|
|
6710
7423
|
return routeResult.data;
|
|
6711
7424
|
} else {
|
|
6712
|
-
throw new Error(`
|
|
7425
|
+
throw new Error(`Invalid response found for routeId "${routeId}"`);
|
|
6713
7426
|
}
|
|
6714
7427
|
}
|
|
6715
7428
|
function createDeferred2() {
|
|
@@ -6787,14 +7500,14 @@ function RemixRootDefaultErrorBoundary({
|
|
|
6787
7500
|
dangerouslySetInnerHTML: {
|
|
6788
7501
|
__html: `
|
|
6789
7502
|
console.log(
|
|
6790
|
-
"\u{1F4BF} Hey developer \u{1F44B}. You can provide a way better UX than this when your app throws errors. Check out https://
|
|
7503
|
+
"\u{1F4BF} Hey developer \u{1F44B}. You can provide a way better UX than this when your app throws errors. Check out https://reactrouter.com/how-to/error-boundary for more information."
|
|
6791
7504
|
);
|
|
6792
7505
|
`
|
|
6793
7506
|
}
|
|
6794
7507
|
}
|
|
6795
7508
|
);
|
|
6796
7509
|
if (isRouteErrorResponse(error)) {
|
|
6797
|
-
return /* @__PURE__ */ React5.createElement(BoundaryShell, { title: "Unhandled Thrown Response!" }, /* @__PURE__ */ React5.createElement("h1", { style: { fontSize: "24px" } }, error.status, " ", error.statusText), heyDeveloper);
|
|
7510
|
+
return /* @__PURE__ */ React5.createElement(BoundaryShell, { title: "Unhandled Thrown Response!" }, /* @__PURE__ */ React5.createElement("h1", { style: { fontSize: "24px" } }, error.status, " ", error.statusText), ENABLE_DEV_WARNINGS ? heyDeveloper : null);
|
|
6798
7511
|
}
|
|
6799
7512
|
let errorInstance;
|
|
6800
7513
|
if (error instanceof Error) {
|
|
@@ -6847,7 +7560,7 @@ function BoundaryShell({
|
|
|
6847
7560
|
// lib/dom/ssr/fallback.tsx
|
|
6848
7561
|
import * as React6 from "react";
|
|
6849
7562
|
function RemixRootDefaultHydrateFallback() {
|
|
6850
|
-
return /* @__PURE__ */ React6.createElement(BoundaryShell, { title: "Loading...", renderScripts: true }, /* @__PURE__ */ React6.createElement(
|
|
7563
|
+
return /* @__PURE__ */ React6.createElement(BoundaryShell, { title: "Loading...", renderScripts: true }, ENABLE_DEV_WARNINGS ? /* @__PURE__ */ React6.createElement(
|
|
6851
7564
|
"script",
|
|
6852
7565
|
{
|
|
6853
7566
|
dangerouslySetInnerHTML: {
|
|
@@ -6855,13 +7568,13 @@ function RemixRootDefaultHydrateFallback() {
|
|
|
6855
7568
|
console.log(
|
|
6856
7569
|
"\u{1F4BF} Hey developer \u{1F44B}. You can provide a way better UX than this " +
|
|
6857
7570
|
"when your app is loading JS modules and/or running \`clientLoader\` " +
|
|
6858
|
-
"functions. Check out https://
|
|
7571
|
+
"functions. Check out https://reactrouter.com/start/framework/route-module#hydratefallback " +
|
|
6859
7572
|
"for more information."
|
|
6860
7573
|
);
|
|
6861
7574
|
`
|
|
6862
7575
|
}
|
|
6863
7576
|
}
|
|
6864
|
-
));
|
|
7577
|
+
) : null);
|
|
6865
7578
|
}
|
|
6866
7579
|
|
|
6867
7580
|
// lib/dom/ssr/routes.tsx
|
|
@@ -7274,8 +7987,8 @@ var nextPaths = /* @__PURE__ */ new Set();
|
|
|
7274
7987
|
var discoveredPathsMaxSize = 1e3;
|
|
7275
7988
|
var discoveredPaths = /* @__PURE__ */ new Set();
|
|
7276
7989
|
var URL_LIMIT = 7680;
|
|
7277
|
-
function isFogOfWarEnabled(ssr) {
|
|
7278
|
-
return ssr === true;
|
|
7990
|
+
function isFogOfWarEnabled(routeDiscovery, ssr) {
|
|
7991
|
+
return routeDiscovery.mode === "lazy" && ssr === true;
|
|
7279
7992
|
}
|
|
7280
7993
|
function getPartialManifest({ sri, ...manifest }, router) {
|
|
7281
7994
|
let routeIds = new Set(router.state.matches.map((m) => m.route.id));
|
|
@@ -7302,8 +8015,8 @@ function getPartialManifest({ sri, ...manifest }, router) {
|
|
|
7302
8015
|
sri: sri ? true : void 0
|
|
7303
8016
|
};
|
|
7304
8017
|
}
|
|
7305
|
-
function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, isSpaMode, basename) {
|
|
7306
|
-
if (!isFogOfWarEnabled(ssr)) {
|
|
8018
|
+
function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, routeDiscovery, isSpaMode, basename) {
|
|
8019
|
+
if (!isFogOfWarEnabled(routeDiscovery, ssr)) {
|
|
7307
8020
|
return void 0;
|
|
7308
8021
|
}
|
|
7309
8022
|
return async ({ path, patch, signal, fetcherKey }) => {
|
|
@@ -7318,14 +8031,16 @@ function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, isSpaMo
|
|
|
7318
8031
|
ssr,
|
|
7319
8032
|
isSpaMode,
|
|
7320
8033
|
basename,
|
|
8034
|
+
routeDiscovery.manifestPath,
|
|
7321
8035
|
patch,
|
|
7322
8036
|
signal
|
|
7323
8037
|
);
|
|
7324
8038
|
};
|
|
7325
8039
|
}
|
|
7326
|
-
function useFogOFWarDiscovery(router, manifest, routeModules, ssr, isSpaMode) {
|
|
8040
|
+
function useFogOFWarDiscovery(router, manifest, routeModules, ssr, routeDiscovery, isSpaMode) {
|
|
7327
8041
|
React8.useEffect(() => {
|
|
7328
|
-
if (!isFogOfWarEnabled(ssr) ||
|
|
8042
|
+
if (!isFogOfWarEnabled(routeDiscovery, ssr) || // @ts-expect-error - TS doesn't know about this yet
|
|
8043
|
+
window.navigator?.connection?.saveData === true) {
|
|
7329
8044
|
return;
|
|
7330
8045
|
}
|
|
7331
8046
|
function registerElement(el) {
|
|
@@ -7359,6 +8074,7 @@ function useFogOFWarDiscovery(router, manifest, routeModules, ssr, isSpaMode) {
|
|
|
7359
8074
|
ssr,
|
|
7360
8075
|
isSpaMode,
|
|
7361
8076
|
router.basename,
|
|
8077
|
+
routeDiscovery.manifestPath,
|
|
7362
8078
|
router.patchRoutes
|
|
7363
8079
|
);
|
|
7364
8080
|
} catch (e) {
|
|
@@ -7375,15 +8091,21 @@ function useFogOFWarDiscovery(router, manifest, routeModules, ssr, isSpaMode) {
|
|
|
7375
8091
|
attributeFilter: ["data-discover", "href", "action"]
|
|
7376
8092
|
});
|
|
7377
8093
|
return () => observer.disconnect();
|
|
7378
|
-
}, [ssr, isSpaMode, manifest, routeModules, router]);
|
|
8094
|
+
}, [ssr, isSpaMode, manifest, routeModules, router, routeDiscovery]);
|
|
8095
|
+
}
|
|
8096
|
+
function getManifestPath(_manifestPath, basename) {
|
|
8097
|
+
let manifestPath = _manifestPath || "/__manifest";
|
|
8098
|
+
if (basename == null) {
|
|
8099
|
+
return manifestPath;
|
|
8100
|
+
}
|
|
8101
|
+
return `${basename}${manifestPath}`.replace(/\/+/g, "/");
|
|
7379
8102
|
}
|
|
7380
8103
|
var MANIFEST_VERSION_STORAGE_KEY = "react-router-manifest-version";
|
|
7381
|
-
async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename, patchRoutes, signal) {
|
|
7382
|
-
let
|
|
7383
|
-
|
|
7384
|
-
|
|
8104
|
+
async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename, manifestPath, patchRoutes, signal) {
|
|
8105
|
+
let url = new URL(
|
|
8106
|
+
getManifestPath(manifestPath, basename),
|
|
8107
|
+
window.location.origin
|
|
7385
8108
|
);
|
|
7386
|
-
let url = new URL(manifestPath, window.location.origin);
|
|
7387
8109
|
paths.sort().forEach((path) => url.searchParams.append("p", path));
|
|
7388
8110
|
url.searchParams.set("version", manifest.version);
|
|
7389
8111
|
if (url.toString().length > URL_LIMIT) {
|
|
@@ -7410,7 +8132,9 @@ async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, ro
|
|
|
7410
8132
|
}
|
|
7411
8133
|
sessionStorage.setItem(MANIFEST_VERSION_STORAGE_KEY, manifest.version);
|
|
7412
8134
|
window.location.href = errorReloadPath;
|
|
7413
|
-
|
|
8135
|
+
console.warn("Detected manifest version mismatch, reloading...");
|
|
8136
|
+
await new Promise(() => {
|
|
8137
|
+
});
|
|
7414
8138
|
} else if (res.status >= 400) {
|
|
7415
8139
|
throw new Error(await res.text());
|
|
7416
8140
|
}
|
|
@@ -7789,10 +8513,17 @@ function isValidMetaTag(tagName) {
|
|
|
7789
8513
|
}
|
|
7790
8514
|
var isHydrated = false;
|
|
7791
8515
|
function Scripts(props) {
|
|
7792
|
-
let {
|
|
8516
|
+
let {
|
|
8517
|
+
manifest,
|
|
8518
|
+
serverHandoffString,
|
|
8519
|
+
isSpaMode,
|
|
8520
|
+
renderMeta,
|
|
8521
|
+
routeDiscovery,
|
|
8522
|
+
ssr
|
|
8523
|
+
} = useFrameworkContext();
|
|
7793
8524
|
let { router, static: isStatic, staticContext } = useDataRouterContext2();
|
|
7794
8525
|
let { matches: routerMatches } = useDataRouterStateContext();
|
|
7795
|
-
let enableFogOfWar = isFogOfWarEnabled(ssr);
|
|
8526
|
+
let enableFogOfWar = isFogOfWarEnabled(routeDiscovery, ssr);
|
|
7796
8527
|
if (renderMeta) {
|
|
7797
8528
|
renderMeta.didRenderScripts = true;
|
|
7798
8529
|
}
|
|
@@ -7948,7 +8679,7 @@ function mergeRefs(...refs) {
|
|
|
7948
8679
|
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
7949
8680
|
try {
|
|
7950
8681
|
if (isBrowser) {
|
|
7951
|
-
window.__reactRouterVersion = "7.
|
|
8682
|
+
window.__reactRouterVersion = "7.6.0-pre.0";
|
|
7952
8683
|
}
|
|
7953
8684
|
} catch (e) {
|
|
7954
8685
|
}
|
|
@@ -8208,11 +8939,11 @@ var NavLink = React10.forwardRef(
|
|
|
8208
8939
|
let path = useResolvedPath(to, { relative: rest.relative });
|
|
8209
8940
|
let location = useLocation();
|
|
8210
8941
|
let routerState = React10.useContext(DataRouterStateContext);
|
|
8211
|
-
let { navigator
|
|
8942
|
+
let { navigator, basename } = React10.useContext(NavigationContext);
|
|
8212
8943
|
let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
|
|
8213
8944
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
8214
8945
|
useViewTransitionState(path) && viewTransition === true;
|
|
8215
|
-
let toPathname =
|
|
8946
|
+
let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
|
|
8216
8947
|
let locationPathname = location.pathname;
|
|
8217
8948
|
let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
|
|
8218
8949
|
if (!caseSensitive) {
|
|
@@ -8789,7 +9520,7 @@ function StaticRouter({
|
|
|
8789
9520
|
function StaticRouterProvider({
|
|
8790
9521
|
context,
|
|
8791
9522
|
router,
|
|
8792
|
-
hydrate = true,
|
|
9523
|
+
hydrate: hydrate2 = true,
|
|
8793
9524
|
nonce
|
|
8794
9525
|
}) {
|
|
8795
9526
|
invariant(
|
|
@@ -8805,7 +9536,7 @@ function StaticRouterProvider({
|
|
|
8805
9536
|
};
|
|
8806
9537
|
let fetchersContext = /* @__PURE__ */ new Map();
|
|
8807
9538
|
let hydrateScript = "";
|
|
8808
|
-
if (
|
|
9539
|
+
if (hydrate2 !== false) {
|
|
8809
9540
|
let data2 = {
|
|
8810
9541
|
loaderData: context.loaderData,
|
|
8811
9542
|
actionData: context.actionData,
|
|
@@ -9072,6 +9803,7 @@ function ServerRouter({
|
|
|
9072
9803
|
future: context.future,
|
|
9073
9804
|
ssr: context.ssr,
|
|
9074
9805
|
isSpaMode: context.isSpaMode,
|
|
9806
|
+
routeDiscovery: context.routeDiscovery,
|
|
9075
9807
|
serializeError: context.serializeError,
|
|
9076
9808
|
renderMeta: context.renderMeta
|
|
9077
9809
|
}
|
|
@@ -9121,7 +9853,8 @@ function createRoutesStub(routes, unstable_getContext) {
|
|
|
9121
9853
|
},
|
|
9122
9854
|
routeModules: {},
|
|
9123
9855
|
ssr: false,
|
|
9124
|
-
isSpaMode: false
|
|
9856
|
+
isSpaMode: false,
|
|
9857
|
+
routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" }
|
|
9125
9858
|
};
|
|
9126
9859
|
let patched = processRoutes(
|
|
9127
9860
|
// @ts-expect-error `StubRouteObject` is stricter about `loader`/`action`
|
|
@@ -9140,6 +9873,37 @@ function createRoutesStub(routes, unstable_getContext) {
|
|
|
9140
9873
|
return /* @__PURE__ */ React13.createElement(FrameworkContext.Provider, { value: remixContextRef.current }, /* @__PURE__ */ React13.createElement(RouterProvider, { router: routerRef.current }));
|
|
9141
9874
|
};
|
|
9142
9875
|
}
|
|
9876
|
+
function withComponentProps(Component4) {
|
|
9877
|
+
return function Wrapped() {
|
|
9878
|
+
return React13.createElement(Component4, {
|
|
9879
|
+
params: useParams(),
|
|
9880
|
+
loaderData: useLoaderData(),
|
|
9881
|
+
actionData: useActionData(),
|
|
9882
|
+
matches: useMatches()
|
|
9883
|
+
});
|
|
9884
|
+
};
|
|
9885
|
+
}
|
|
9886
|
+
function withHydrateFallbackProps(HydrateFallback) {
|
|
9887
|
+
return function Wrapped() {
|
|
9888
|
+
const props = {
|
|
9889
|
+
params: useParams(),
|
|
9890
|
+
loaderData: useLoaderData(),
|
|
9891
|
+
actionData: useActionData()
|
|
9892
|
+
};
|
|
9893
|
+
return React13.createElement(HydrateFallback, props);
|
|
9894
|
+
};
|
|
9895
|
+
}
|
|
9896
|
+
function withErrorBoundaryProps(ErrorBoundary) {
|
|
9897
|
+
return function Wrapped() {
|
|
9898
|
+
const props = {
|
|
9899
|
+
params: useParams(),
|
|
9900
|
+
loaderData: useLoaderData(),
|
|
9901
|
+
actionData: useActionData(),
|
|
9902
|
+
error: useRouteError()
|
|
9903
|
+
};
|
|
9904
|
+
return React13.createElement(ErrorBoundary, props);
|
|
9905
|
+
};
|
|
9906
|
+
}
|
|
9143
9907
|
function processRoutes(routes, manifest, routeModules, parentId) {
|
|
9144
9908
|
return routes.map((route) => {
|
|
9145
9909
|
if (!route.id) {
|
|
@@ -9151,9 +9915,9 @@ function processRoutes(routes, manifest, routeModules, parentId) {
|
|
|
9151
9915
|
id: route.id,
|
|
9152
9916
|
path: route.path,
|
|
9153
9917
|
index: route.index,
|
|
9154
|
-
Component: route.Component,
|
|
9155
|
-
HydrateFallback: route.HydrateFallback,
|
|
9156
|
-
ErrorBoundary: route.ErrorBoundary,
|
|
9918
|
+
Component: route.Component ? withComponentProps(route.Component) : void 0,
|
|
9919
|
+
HydrateFallback: route.HydrateFallback ? withHydrateFallbackProps(route.HydrateFallback) : void 0,
|
|
9920
|
+
ErrorBoundary: route.ErrorBoundary ? withErrorBoundaryProps(route.ErrorBoundary) : void 0,
|
|
9157
9921
|
action: route.action,
|
|
9158
9922
|
loader: route.loader,
|
|
9159
9923
|
handle: route.handle,
|
|
@@ -9182,8 +9946,8 @@ function processRoutes(routes, manifest, routeModules, parentId) {
|
|
|
9182
9946
|
};
|
|
9183
9947
|
manifest.routes[newRoute.id] = entryRoute;
|
|
9184
9948
|
routeModules[route.id] = {
|
|
9185
|
-
default:
|
|
9186
|
-
ErrorBoundary:
|
|
9949
|
+
default: newRoute.Component || Outlet,
|
|
9950
|
+
ErrorBoundary: newRoute.ErrorBoundary || void 0,
|
|
9187
9951
|
handle: route.handle,
|
|
9188
9952
|
links: route.links,
|
|
9189
9953
|
meta: route.meta,
|
|
@@ -9205,7 +9969,7 @@ function processRoutes(routes, manifest, routeModules, parentId) {
|
|
|
9205
9969
|
import { parse, serialize } from "cookie";
|
|
9206
9970
|
|
|
9207
9971
|
// lib/server-runtime/crypto.ts
|
|
9208
|
-
var encoder = new TextEncoder();
|
|
9972
|
+
var encoder = /* @__PURE__ */ new TextEncoder();
|
|
9209
9973
|
var sign = async (value, secret) => {
|
|
9210
9974
|
let data2 = encoder.encode(value);
|
|
9211
9975
|
let key = await createKey2(secret, ["sign"]);
|
|
@@ -9655,9 +10419,6 @@ function createServerHandoffString(serverHandoff) {
|
|
|
9655
10419
|
return escapeHtml2(JSON.stringify(serverHandoff));
|
|
9656
10420
|
}
|
|
9657
10421
|
|
|
9658
|
-
// lib/server-runtime/single-fetch.ts
|
|
9659
|
-
import { encode } from "turbo-stream";
|
|
9660
|
-
|
|
9661
10422
|
// lib/server-runtime/headers.ts
|
|
9662
10423
|
import { splitCookiesString } from "set-cookie-parser";
|
|
9663
10424
|
function getDocumentHeaders(build, context) {
|
|
@@ -10090,7 +10851,10 @@ Error: ${e instanceof Error ? e.toString() : e}`
|
|
|
10090
10851
|
}
|
|
10091
10852
|
}
|
|
10092
10853
|
}
|
|
10093
|
-
let manifestUrl =
|
|
10854
|
+
let manifestUrl = getManifestPath(
|
|
10855
|
+
_build.routeDiscovery.manifestPath,
|
|
10856
|
+
normalizedBasename
|
|
10857
|
+
);
|
|
10094
10858
|
if (url.pathname === manifestUrl) {
|
|
10095
10859
|
try {
|
|
10096
10860
|
let res = await handleManifestRequest(_build, routes, url);
|
|
@@ -10100,7 +10864,7 @@ Error: ${e instanceof Error ? e.toString() : e}`
|
|
|
10100
10864
|
return new Response("Unknown Server Error", { status: 500 });
|
|
10101
10865
|
}
|
|
10102
10866
|
}
|
|
10103
|
-
let matches = matchServerRoutes(routes,
|
|
10867
|
+
let matches = matchServerRoutes(routes, normalizedPath, _build.basename);
|
|
10104
10868
|
if (matches && matches.length > 0) {
|
|
10105
10869
|
Object.assign(params, matches[0].params);
|
|
10106
10870
|
}
|
|
@@ -10288,17 +11052,21 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
10288
11052
|
actionData: context.actionData,
|
|
10289
11053
|
errors: serializeErrors2(context.errors, serverMode)
|
|
10290
11054
|
};
|
|
11055
|
+
let baseServerHandoff = {
|
|
11056
|
+
basename: build.basename,
|
|
11057
|
+
future: build.future,
|
|
11058
|
+
routeDiscovery: build.routeDiscovery,
|
|
11059
|
+
ssr: build.ssr,
|
|
11060
|
+
isSpaMode: isSpaMode2
|
|
11061
|
+
};
|
|
10291
11062
|
let entryContext = {
|
|
10292
11063
|
manifest: build.assets,
|
|
10293
11064
|
routeModules: createEntryRouteModules(build.routes),
|
|
10294
11065
|
staticHandlerContext: context,
|
|
10295
11066
|
criticalCss,
|
|
10296
11067
|
serverHandoffString: createServerHandoffString({
|
|
10297
|
-
|
|
10298
|
-
criticalCss
|
|
10299
|
-
future: build.future,
|
|
10300
|
-
ssr: build.ssr,
|
|
10301
|
-
isSpaMode: isSpaMode2
|
|
11068
|
+
...baseServerHandoff,
|
|
11069
|
+
criticalCss
|
|
10302
11070
|
}),
|
|
10303
11071
|
serverHandoffStream: encodeViaTurboStream(
|
|
10304
11072
|
state,
|
|
@@ -10309,6 +11077,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
10309
11077
|
renderMeta: {},
|
|
10310
11078
|
future: build.future,
|
|
10311
11079
|
ssr: build.ssr,
|
|
11080
|
+
routeDiscovery: build.routeDiscovery,
|
|
10312
11081
|
isSpaMode: isSpaMode2,
|
|
10313
11082
|
serializeError: (err) => serializeError(err, serverMode)
|
|
10314
11083
|
};
|
|
@@ -10351,12 +11120,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
10351
11120
|
entryContext = {
|
|
10352
11121
|
...entryContext,
|
|
10353
11122
|
staticHandlerContext: context,
|
|
10354
|
-
serverHandoffString: createServerHandoffString(
|
|
10355
|
-
basename: build.basename,
|
|
10356
|
-
future: build.future,
|
|
10357
|
-
ssr: build.ssr,
|
|
10358
|
-
isSpaMode: isSpaMode2
|
|
10359
|
-
}),
|
|
11123
|
+
serverHandoffString: createServerHandoffString(baseServerHandoff),
|
|
10360
11124
|
serverHandoffStream: encodeViaTurboStream(
|
|
10361
11125
|
state2,
|
|
10362
11126
|
request.signal,
|