react-router 8.5.2 → 8.5.3
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 +50 -0
- package/dist/development/dom-export.js +1 -1
- package/dist/development/index-react-server-client.js +1 -1
- package/dist/development/index-react-server.d.ts +3 -2
- package/dist/development/index-react-server.js +41 -36
- package/dist/development/index.js +1 -1
- package/dist/development/lib/actions.js +1 -1
- package/dist/development/lib/await.js +1 -1
- package/dist/development/lib/components.js +10 -8
- package/dist/development/lib/context.js +3 -2
- package/dist/development/lib/dom/dom.js +4 -2
- package/dist/development/lib/dom/lib.js +12 -5
- package/dist/development/lib/dom/server.js +5 -3
- package/dist/development/lib/dom/ssr/components.js +4 -1
- package/dist/development/lib/dom/ssr/data.js +1 -1
- package/dist/development/lib/dom/ssr/errorBoundaries.js +2 -1
- package/dist/development/lib/dom/ssr/fallback.js +2 -1
- package/dist/development/lib/dom/ssr/fog-of-war.js +1 -1
- package/dist/development/lib/dom/ssr/hydration.js +1 -1
- package/dist/development/lib/dom/ssr/invariant.js +1 -1
- package/dist/development/lib/dom/ssr/links.js +1 -1
- package/dist/development/lib/dom/ssr/markup.js +1 -1
- package/dist/development/lib/dom/ssr/route-discovery.js +1 -1
- package/dist/development/lib/dom/ssr/routeModules.js +1 -1
- package/dist/development/lib/dom/ssr/routes-test-stub.js +3 -1
- package/dist/development/lib/dom/ssr/routes.js +2 -1
- package/dist/development/lib/dom/ssr/server.js +1 -1
- package/dist/development/lib/dom/ssr/single-fetch.js +1 -1
- package/dist/development/lib/dom-export/dom-router-provider.js +1 -1
- package/dist/development/lib/dom-export/hydrated-router.js +1 -1
- package/dist/development/lib/errors.js +1 -1
- package/dist/development/lib/hooks.d.ts +30 -0
- package/dist/development/lib/hooks.js +39 -5
- package/dist/development/lib/href.js +1 -1
- package/dist/development/lib/router/history.js +10 -4
- package/dist/development/lib/router/instrumentation.js +1 -1
- package/dist/development/lib/router/matcher-route-pattern.js +1 -1
- package/dist/development/lib/router/matcher-route-pattern.preload.js +1 -1
- package/dist/development/lib/router/matcher.js +1 -1
- package/dist/development/lib/router/navigation.js +1 -1
- package/dist/development/lib/router/router.js +22 -8
- package/dist/development/lib/router/url.js +1 -1
- package/dist/development/lib/router/utils.d.ts +2 -0
- package/dist/development/lib/router/utils.js +8 -2
- package/dist/development/lib/rsc/browser.js +2 -2
- package/dist/development/lib/rsc/errorBoundaries.js +3 -2
- package/dist/development/lib/rsc/html-stream/browser.js +1 -1
- package/dist/development/lib/rsc/html-stream/server.js +1 -1
- package/dist/development/lib/rsc/route-modules.js +1 -1
- package/dist/development/lib/rsc/server.rsc.d.ts +2 -1
- package/dist/development/lib/rsc/server.ssr.d.ts +1 -0
- package/dist/development/lib/rsc/server.ssr.js +5 -4
- package/dist/development/lib/server-runtime/cookies.js +1 -1
- package/dist/development/lib/server-runtime/crypto.js +1 -1
- package/dist/development/lib/server-runtime/data.js +1 -1
- package/dist/development/lib/server-runtime/dev.js +1 -1
- package/dist/development/lib/server-runtime/entry.js +1 -1
- package/dist/development/lib/server-runtime/errors.js +1 -1
- package/dist/development/lib/server-runtime/headers.js +1 -1
- package/dist/development/lib/server-runtime/invariant.js +1 -1
- package/dist/development/lib/server-runtime/mode.js +1 -1
- package/dist/development/lib/server-runtime/routeMatching.js +1 -1
- package/dist/development/lib/server-runtime/routes.js +1 -1
- package/dist/development/lib/server-runtime/server.js +1 -1
- package/dist/development/lib/server-runtime/serverHandoff.js +1 -1
- package/dist/development/lib/server-runtime/sessions/cookieStorage.js +3 -2
- package/dist/development/lib/server-runtime/sessions/memoryStorage.js +1 -1
- package/dist/development/lib/server-runtime/sessions.d.ts +1 -1
- package/dist/development/lib/server-runtime/sessions.js +5 -3
- package/dist/development/lib/server-runtime/single-fetch.js +1 -1
- package/dist/development/lib/server-runtime/urls.js +1 -1
- package/dist/development/lib/server-runtime/warnings.js +1 -1
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/route-module-annotations.d.ts +16 -9
- package/dist/development/route-pattern.js +1 -1
- package/dist/development/vendor/turbo-stream-v2/flatten.js +1 -1
- package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +9 -8
- package/dist/development/vendor/turbo-stream-v2/unflatten.js +1 -1
- package/dist/development/vendor/turbo-stream-v2/utils.js +1 -1
- package/dist/production/dom-export.js +1 -1
- package/dist/production/index-react-server-client.js +1 -1
- package/dist/production/index-react-server.d.ts +3 -2
- package/dist/production/index-react-server.js +41 -36
- package/dist/production/index.js +1 -1
- package/dist/production/lib/actions.js +1 -1
- package/dist/production/lib/await.js +1 -1
- package/dist/production/lib/components.js +10 -8
- package/dist/production/lib/context.js +3 -2
- package/dist/production/lib/dom/dom.js +4 -2
- package/dist/production/lib/dom/lib.js +12 -5
- package/dist/production/lib/dom/server.js +5 -3
- package/dist/production/lib/dom/ssr/components.js +4 -1
- package/dist/production/lib/dom/ssr/data.js +1 -1
- package/dist/production/lib/dom/ssr/errorBoundaries.js +2 -1
- package/dist/production/lib/dom/ssr/fallback.js +1 -1
- package/dist/production/lib/dom/ssr/fog-of-war.js +1 -1
- package/dist/production/lib/dom/ssr/hydration.js +1 -1
- package/dist/production/lib/dom/ssr/invariant.js +1 -1
- package/dist/production/lib/dom/ssr/links.js +1 -1
- package/dist/production/lib/dom/ssr/markup.js +1 -1
- package/dist/production/lib/dom/ssr/route-discovery.js +1 -1
- package/dist/production/lib/dom/ssr/routeModules.js +1 -1
- package/dist/production/lib/dom/ssr/routes-test-stub.js +3 -1
- package/dist/production/lib/dom/ssr/routes.js +2 -1
- package/dist/production/lib/dom/ssr/server.js +1 -1
- package/dist/production/lib/dom/ssr/single-fetch.js +1 -1
- package/dist/production/lib/dom-export/dom-router-provider.js +1 -1
- package/dist/production/lib/dom-export/hydrated-router.js +1 -1
- package/dist/production/lib/errors.js +1 -1
- package/dist/production/lib/hooks.d.ts +30 -0
- package/dist/production/lib/hooks.js +38 -4
- package/dist/production/lib/href.js +1 -1
- package/dist/production/lib/router/history.js +10 -4
- package/dist/production/lib/router/instrumentation.js +1 -1
- package/dist/production/lib/router/matcher-route-pattern.js +1 -1
- package/dist/production/lib/router/matcher-route-pattern.preload.js +1 -1
- package/dist/production/lib/router/matcher.js +1 -1
- package/dist/production/lib/router/navigation.js +1 -1
- package/dist/production/lib/router/router.js +22 -8
- package/dist/production/lib/router/url.js +1 -1
- package/dist/production/lib/router/utils.d.ts +2 -0
- package/dist/production/lib/router/utils.js +8 -2
- package/dist/production/lib/rsc/browser.js +2 -2
- package/dist/production/lib/rsc/errorBoundaries.js +3 -2
- package/dist/production/lib/rsc/html-stream/browser.js +1 -1
- package/dist/production/lib/rsc/html-stream/server.js +1 -1
- package/dist/production/lib/rsc/route-modules.js +1 -1
- package/dist/production/lib/rsc/server.rsc.d.ts +2 -1
- package/dist/production/lib/rsc/server.ssr.d.ts +1 -0
- package/dist/production/lib/rsc/server.ssr.js +5 -4
- package/dist/production/lib/server-runtime/cookies.js +1 -1
- package/dist/production/lib/server-runtime/crypto.js +1 -1
- package/dist/production/lib/server-runtime/data.js +1 -1
- package/dist/production/lib/server-runtime/dev.js +1 -1
- package/dist/production/lib/server-runtime/entry.js +1 -1
- package/dist/production/lib/server-runtime/errors.js +1 -1
- package/dist/production/lib/server-runtime/headers.js +1 -1
- package/dist/production/lib/server-runtime/invariant.js +1 -1
- package/dist/production/lib/server-runtime/mode.js +1 -1
- package/dist/production/lib/server-runtime/routeMatching.js +1 -1
- package/dist/production/lib/server-runtime/routes.js +1 -1
- package/dist/production/lib/server-runtime/server.js +1 -1
- package/dist/production/lib/server-runtime/serverHandoff.js +1 -1
- package/dist/production/lib/server-runtime/sessions/cookieStorage.js +3 -2
- package/dist/production/lib/server-runtime/sessions/memoryStorage.js +1 -1
- package/dist/production/lib/server-runtime/sessions.d.ts +1 -1
- package/dist/production/lib/server-runtime/sessions.js +5 -3
- package/dist/production/lib/server-runtime/single-fetch.js +1 -1
- package/dist/production/lib/server-runtime/urls.js +1 -1
- package/dist/production/lib/server-runtime/warnings.js +1 -1
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/route-module-annotations.d.ts +16 -9
- package/dist/production/route-pattern.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/flatten.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +9 -8
- package/dist/production/vendor/turbo-stream-v2/unflatten.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/utils.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.3
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -143,12 +143,14 @@ function Links({ nonce, crossOrigin }) {
|
|
|
143
143
|
return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, typeof criticalCss === "string" ? /* @__PURE__ */ React$1.createElement("style", {
|
|
144
144
|
[CRITICAL_CSS_DATA_ATTRIBUTE]: "",
|
|
145
145
|
nonce,
|
|
146
|
+
suppressHydrationWarning: true,
|
|
146
147
|
dangerouslySetInnerHTML: { __html: criticalCss }
|
|
147
148
|
}) : null, typeof criticalCss === "object" ? /* @__PURE__ */ React$1.createElement("link", {
|
|
148
149
|
[CRITICAL_CSS_DATA_ATTRIBUTE]: "",
|
|
149
150
|
rel: "stylesheet",
|
|
150
151
|
href: criticalCss.href,
|
|
151
152
|
nonce,
|
|
153
|
+
suppressHydrationWarning: true,
|
|
152
154
|
crossOrigin
|
|
153
155
|
}) : null, keyedLinks.map(({ key, link }) => isPageLinkDescriptor(link) ? /* @__PURE__ */ React$1.createElement(PrefetchPageLinks, {
|
|
154
156
|
key,
|
|
@@ -158,6 +160,7 @@ function Links({ nonce, crossOrigin }) {
|
|
|
158
160
|
}) : /* @__PURE__ */ React$1.createElement("link", {
|
|
159
161
|
key,
|
|
160
162
|
nonce,
|
|
163
|
+
suppressHydrationWarning: true,
|
|
161
164
|
...link,
|
|
162
165
|
crossOrigin: link.crossOrigin ?? crossOrigin
|
|
163
166
|
})));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.3
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -49,6 +49,7 @@ function RemixRootDefaultErrorBoundary({ error, isOutsideRemixApp }) {
|
|
|
49
49
|
console.error(error);
|
|
50
50
|
let heyDeveloper = /* @__PURE__ */ React$1.createElement("script", {
|
|
51
51
|
nonce,
|
|
52
|
+
suppressHydrationWarning: true,
|
|
52
53
|
dangerouslySetInnerHTML: { __html: `
|
|
53
54
|
console.log(
|
|
54
55
|
"💿 Hey developer 👋. 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."
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.3
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -69,6 +69,7 @@ function processRoutes(routes, context, manifest, routeModules, parentId) {
|
|
|
69
69
|
id: route.id,
|
|
70
70
|
path: route.path,
|
|
71
71
|
index: route.index,
|
|
72
|
+
caseSensitive: route.caseSensitive,
|
|
72
73
|
Component: route.Component ? withComponentProps(route.Component) : void 0,
|
|
73
74
|
HydrateFallback: route.HydrateFallback ? withHydrateFallbackProps(route.HydrateFallback) : void 0,
|
|
74
75
|
ErrorBoundary: route.ErrorBoundary ? withErrorBoundaryProps(route.ErrorBoundary) : void 0,
|
|
@@ -91,6 +92,7 @@ function processRoutes(routes, context, manifest, routeModules, parentId) {
|
|
|
91
92
|
id: route.id,
|
|
92
93
|
path: route.path,
|
|
93
94
|
index: route.index,
|
|
95
|
+
caseSensitive: route.caseSensitive,
|
|
94
96
|
parentId,
|
|
95
97
|
hasAction: route.action != null,
|
|
96
98
|
hasLoader: route.loader != null,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.3
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -114,6 +114,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
let dataRoute = {
|
|
117
|
+
caseSensitive: route.caseSensitive,
|
|
117
118
|
id: route.id,
|
|
118
119
|
index: route.index,
|
|
119
120
|
path: route.path
|
|
@@ -884,6 +884,36 @@ type UseRoute<RouteId extends keyof RouteModules | unknown> = {
|
|
|
884
884
|
loaderData: RouteId extends keyof RouteModules ? GetLoaderData<RouteModules[RouteId]> | undefined : unknown;
|
|
885
885
|
actionData: RouteId extends keyof RouteModules ? GetActionData<RouteModules[RouteId]> | undefined : unknown;
|
|
886
886
|
};
|
|
887
|
+
/**
|
|
888
|
+
* Returns the current route's `handle`, `loaderData`, and `actionData`, or
|
|
889
|
+
* those of a matched route identified by `routeId`.
|
|
890
|
+
*
|
|
891
|
+
* Omit `routeId` to read the current route. Pass a route ID to infer the
|
|
892
|
+
* fields from registered route module types. Without an ID, the fields
|
|
893
|
+
* are typed as `unknown`.
|
|
894
|
+
*
|
|
895
|
+
* @example
|
|
896
|
+
* import { unstable_useRoute as useRoute } from "react-router";
|
|
897
|
+
*
|
|
898
|
+
* let currentRoute = useRoute();
|
|
899
|
+
* let rootRoute = useRoute("root");
|
|
900
|
+
*
|
|
901
|
+
* // A registered non-root route may not currently be matched:
|
|
902
|
+
* let dashboard = useRoute("routes/dashboard");
|
|
903
|
+
* if (dashboard) {
|
|
904
|
+
* console.log(dashboard.handle, dashboard.loaderData);
|
|
905
|
+
* }
|
|
906
|
+
*
|
|
907
|
+
* @name unstable_useRoute
|
|
908
|
+
* @public
|
|
909
|
+
* @category Hooks
|
|
910
|
+
* @mode framework
|
|
911
|
+
* @mode data
|
|
912
|
+
* @param args An optional route ID. Omit it to read the current route.
|
|
913
|
+
* @returns An object with the route's `handle`, `loaderData`, and
|
|
914
|
+
* `actionData`, or `undefined` if the specified route is not matched.
|
|
915
|
+
* Individual fields can be `undefined` when the handle or data is unavailable.
|
|
916
|
+
*/
|
|
887
917
|
declare function useRoute<Args extends UseRouteArgs>(...args: Args): UseRouteResult<Args>;
|
|
888
918
|
/**
|
|
889
919
|
* A single route match returned from {@link unstable_useRouterState}. Mirrors
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.3
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -12,7 +12,7 @@ import { createPath, invariant, parsePath, warning } from "./router/history.js";
|
|
|
12
12
|
import { getNavigatorCurrentUrl, validateNavigationTarget } from "./router/navigation.js";
|
|
13
13
|
import { convertRouteMatchToUiMatch, decodePath, getResolveToMatches, getRoutePattern, isBrowser, isRouteErrorResponse, joinPaths, matchPath, matchRoutes, parseToInfo, resolveTo, stripBasename } from "./router/utils.js";
|
|
14
14
|
import { IDLE_BLOCKER, hasInvalidProtocol } from "./router/router.js";
|
|
15
|
-
import { AwaitContext, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, IsDataRouteContext, LocationContext, NavigationContext, RSCRouterContext, RouteContext, RouteErrorContext, RouteIdContext } from "./context.js";
|
|
15
|
+
import { AwaitContext, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, IsDataRouteContext, LocationContext, NavigationContext, RSCErrorAlreadyReportedContext, RSCRouterContext, RouteContext, RouteErrorContext, RouteIdContext } from "./context.js";
|
|
16
16
|
import { decodeRedirectErrorDigest, decodeRouteErrorResponseDigest } from "./errors.js";
|
|
17
17
|
import * as React$1 from "react";
|
|
18
18
|
//#region lib/hooks.tsx
|
|
@@ -620,6 +620,7 @@ function useRoutesImpl(routes, locationArg, dataRouterOpts) {
|
|
|
620
620
|
}
|
|
621
621
|
function DefaultErrorComponent() {
|
|
622
622
|
let error = useRouteError();
|
|
623
|
+
React$1.useContext(RSCErrorAlreadyReportedContext);
|
|
623
624
|
let message = isRouteErrorResponse(error) ? `${error.status} ${error.statusText}` : error instanceof Error ? error.message : JSON.stringify(error);
|
|
624
625
|
let stack = error instanceof Error ? error.stack : null;
|
|
625
626
|
return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, /* @__PURE__ */ React$1.createElement("h2", null, "Unexpected Application Error!"), /* @__PURE__ */ React$1.createElement("h3", { style: { fontStyle: "italic" } }, message), stack ? /* @__PURE__ */ React$1.createElement("pre", { style: {
|
|
@@ -1255,17 +1256,20 @@ function useBlocker(shouldBlock) {
|
|
|
1255
1256
|
});
|
|
1256
1257
|
}, [basename, shouldBlock]);
|
|
1257
1258
|
let activeBlockerKey = React$1.useRef("");
|
|
1259
|
+
let activeBlockerRouter = React$1.useRef(null);
|
|
1258
1260
|
React$1.useEffect(() => {
|
|
1259
1261
|
let key = String(++blockerId);
|
|
1260
1262
|
activeBlockerKey.current = key;
|
|
1263
|
+
activeBlockerRouter.current = router;
|
|
1261
1264
|
setBlockerKey(key);
|
|
1262
1265
|
return () => {
|
|
1263
1266
|
activeBlockerKey.current = "";
|
|
1267
|
+
activeBlockerRouter.current = null;
|
|
1264
1268
|
router.deleteBlocker(key);
|
|
1265
1269
|
};
|
|
1266
1270
|
}, [router]);
|
|
1267
|
-
React$1.
|
|
1268
|
-
if (blockerKey !== "" && blockerKey === activeBlockerKey.current) router.getBlocker(blockerKey, blockerFunction);
|
|
1271
|
+
React$1.useLayoutEffect(() => {
|
|
1272
|
+
if (blockerKey !== "" && blockerKey === activeBlockerKey.current && router === activeBlockerRouter.current) router.getBlocker(blockerKey, blockerFunction);
|
|
1269
1273
|
}, [
|
|
1270
1274
|
router,
|
|
1271
1275
|
blockerKey,
|
|
@@ -1297,6 +1301,36 @@ function warningOnce(key, cond, message) {
|
|
|
1297
1301
|
warning(false, message);
|
|
1298
1302
|
}
|
|
1299
1303
|
}
|
|
1304
|
+
/**
|
|
1305
|
+
* Returns the current route's `handle`, `loaderData`, and `actionData`, or
|
|
1306
|
+
* those of a matched route identified by `routeId`.
|
|
1307
|
+
*
|
|
1308
|
+
* Omit `routeId` to read the current route. Pass a route ID to infer the
|
|
1309
|
+
* fields from registered route module types. Without an ID, the fields
|
|
1310
|
+
* are typed as `unknown`.
|
|
1311
|
+
*
|
|
1312
|
+
* @example
|
|
1313
|
+
* import { unstable_useRoute as useRoute } from "react-router";
|
|
1314
|
+
*
|
|
1315
|
+
* let currentRoute = useRoute();
|
|
1316
|
+
* let rootRoute = useRoute("root");
|
|
1317
|
+
*
|
|
1318
|
+
* // A registered non-root route may not currently be matched:
|
|
1319
|
+
* let dashboard = useRoute("routes/dashboard");
|
|
1320
|
+
* if (dashboard) {
|
|
1321
|
+
* console.log(dashboard.handle, dashboard.loaderData);
|
|
1322
|
+
* }
|
|
1323
|
+
*
|
|
1324
|
+
* @name unstable_useRoute
|
|
1325
|
+
* @public
|
|
1326
|
+
* @category Hooks
|
|
1327
|
+
* @mode framework
|
|
1328
|
+
* @mode data
|
|
1329
|
+
* @param args An optional route ID. Omit it to read the current route.
|
|
1330
|
+
* @returns An object with the route's `handle`, `loaderData`, and
|
|
1331
|
+
* `actionData`, or `undefined` if the specified route is not matched.
|
|
1332
|
+
* Individual fields can be `undefined` when the handle or data is unavailable.
|
|
1333
|
+
*/
|
|
1300
1334
|
function useRoute(...args) {
|
|
1301
1335
|
const currentRouteId = useCurrentRouteId("useRoute");
|
|
1302
1336
|
const id = args[0] ?? currentRouteId;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.3
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -111,11 +111,12 @@ function createMemoryHistory(options = {}) {
|
|
|
111
111
|
action = "POP";
|
|
112
112
|
let nextIndex = clampIndex(index + delta);
|
|
113
113
|
let nextLocation = entries[nextIndex];
|
|
114
|
+
let actualDelta = nextIndex - index;
|
|
114
115
|
index = nextIndex;
|
|
115
116
|
if (listener) listener({
|
|
116
117
|
action,
|
|
117
118
|
location: nextLocation,
|
|
118
|
-
delta
|
|
119
|
+
delta: actualDelta
|
|
119
120
|
});
|
|
120
121
|
},
|
|
121
122
|
listen(fn) {
|
|
@@ -164,11 +165,16 @@ function createHashHistory(options = {}) {
|
|
|
164
165
|
function createHashLocation(window, globalHistory) {
|
|
165
166
|
let { pathname = "/", search = "", hash = "" } = parsePath(window.location.hash.substring(1));
|
|
166
167
|
if (!pathname.startsWith("/") && !pathname.startsWith(".")) pathname = "/" + pathname;
|
|
167
|
-
|
|
168
|
+
let maskedLocation = globalHistory.state?.masked;
|
|
169
|
+
return createLocation("", maskedLocation || {
|
|
168
170
|
pathname,
|
|
169
171
|
search,
|
|
170
172
|
hash
|
|
171
|
-
}, globalHistory.state && globalHistory.state.usr || null, globalHistory.state && globalHistory.state.key || "default"
|
|
173
|
+
}, globalHistory.state && globalHistory.state.usr || null, globalHistory.state && globalHistory.state.key || "default", maskedLocation ? {
|
|
174
|
+
pathname,
|
|
175
|
+
search,
|
|
176
|
+
hash
|
|
177
|
+
} : void 0);
|
|
172
178
|
}
|
|
173
179
|
function createHashHref(window, to) {
|
|
174
180
|
let base = window.document.querySelector("base");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.3
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -213,6 +213,7 @@ function createRouter(init) {
|
|
|
213
213
|
blockers: /* @__PURE__ */ new Map()
|
|
214
214
|
};
|
|
215
215
|
let pendingAction = "POP";
|
|
216
|
+
let pendingActionData;
|
|
216
217
|
let pendingPopstateDelta = 0;
|
|
217
218
|
let pendingDiscoveryCancellation;
|
|
218
219
|
let pendingPopstateNavigationDfd = null;
|
|
@@ -227,6 +228,7 @@ function createRouter(init) {
|
|
|
227
228
|
let fetchControllers = /* @__PURE__ */ new Map();
|
|
228
229
|
let incrementingLoadId = 0;
|
|
229
230
|
let pendingNavigationLoadId = -1;
|
|
231
|
+
let pendingNavigationDiscoverySignal = null;
|
|
230
232
|
let fetchReloadIds = /* @__PURE__ */ new Map();
|
|
231
233
|
let fetchRedirectIds = /* @__PURE__ */ new Set();
|
|
232
234
|
let fetchLoadMatches = /* @__PURE__ */ new Map();
|
|
@@ -340,10 +342,10 @@ function createRouter(init) {
|
|
|
340
342
|
}
|
|
341
343
|
function completeNavigation(location, newState, { flushSync } = {}) {
|
|
342
344
|
let isActionReload = state.actionData != null && state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && state.navigation.state === "loading" && location.state?._isRedirect !== true;
|
|
345
|
+
let actionDataForCommit = newState.actionData || (isActionReload ? pendingActionData : void 0);
|
|
343
346
|
let actionData;
|
|
344
|
-
if (
|
|
347
|
+
if (actionDataForCommit) if (Object.keys(actionDataForCommit).length > 0) actionData = actionDataForCommit;
|
|
345
348
|
else actionData = null;
|
|
346
|
-
else if (isActionReload) actionData = state.actionData;
|
|
347
349
|
else actionData = null;
|
|
348
350
|
let loaderData = newState.loaderData ? mergeLoaderData(state.loaderData, newState.loaderData, newState.matches || [], newState.errors) : state.loaderData;
|
|
349
351
|
let blockers = state.blockers;
|
|
@@ -405,6 +407,7 @@ function createRouter(init) {
|
|
|
405
407
|
function resetPendingNavigation() {
|
|
406
408
|
pendingPopstateDelta = 0;
|
|
407
409
|
pendingAction = "POP";
|
|
410
|
+
pendingActionData = void 0;
|
|
408
411
|
pendingPreventScrollReset = false;
|
|
409
412
|
pendingViewTransitionEnabled = false;
|
|
410
413
|
isUninterruptedRevalidation = false;
|
|
@@ -514,6 +517,7 @@ function createRouter(init) {
|
|
|
514
517
|
pendingNavigationController && pendingNavigationController.abort();
|
|
515
518
|
pendingNavigationController = null;
|
|
516
519
|
pendingAction = historyAction;
|
|
520
|
+
if (!opts?.overrideNavigation) pendingActionData = void 0;
|
|
517
521
|
isUninterruptedRevalidation = (opts && opts.startUninterruptedRevalidation) === true;
|
|
518
522
|
saveScrollPosition(state.location, state.matches);
|
|
519
523
|
pendingPreventScrollReset = (opts && opts.preventScrollReset) === true;
|
|
@@ -579,6 +583,7 @@ function createRouter(init) {
|
|
|
579
583
|
fogOfWar.active = false;
|
|
580
584
|
request = createClientSideRequest(init.history, request.url, request.signal);
|
|
581
585
|
}
|
|
586
|
+
if (pendingActionResult) pendingActionData = getActionDataForCommit(pendingActionResult).actionData;
|
|
582
587
|
let { shortCircuited, matches: updatedMatches, loaderData, errors, workingFetchers } = await handleLoaders(request, dataStrategyInitiator, location, matches, historyAction, scopedContext, fogOfWar.active, loadingNavigation, opts && opts.submission, opts && opts.fetcherSubmission, opts && opts.replace, opts && opts.initialHydration === true, flushSync, pendingActionResult, opts && opts.callSiteDefaultShouldRevalidate);
|
|
583
588
|
if (shortCircuited) return;
|
|
584
589
|
pendingNavigationController = null;
|
|
@@ -724,6 +729,7 @@ function createRouter(init) {
|
|
|
724
729
|
let activeSubmission = submission || fetcherSubmission || getSubmissionFromNavigation(loadingNavigation);
|
|
725
730
|
let shouldUpdateNavigationState = !isUninterruptedRevalidation && !initialHydration;
|
|
726
731
|
if (isFogOfWar) {
|
|
732
|
+
pendingNavigationDiscoverySignal = request.signal;
|
|
727
733
|
if (shouldUpdateNavigationState) {
|
|
728
734
|
let actionData = getUpdatedActionData(pendingActionResult);
|
|
729
735
|
updateState({
|
|
@@ -732,6 +738,7 @@ function createRouter(init) {
|
|
|
732
738
|
}, { flushSync });
|
|
733
739
|
}
|
|
734
740
|
let discoverResult = await discoverRoutes(matches, location.pathname, request.signal);
|
|
741
|
+
if (pendingNavigationDiscoverySignal === request.signal) pendingNavigationDiscoverySignal = null;
|
|
735
742
|
if (future.unstable_customRouteDiscovery && request.signal.aborted || discoverResult.type === "aborted") return { shortCircuited: true };
|
|
736
743
|
else if (discoverResult.type === "cancelled") {
|
|
737
744
|
await cancelDiscoveryNavigation();
|
|
@@ -833,7 +840,10 @@ function createRouter(init) {
|
|
|
833
840
|
};
|
|
834
841
|
}
|
|
835
842
|
function getUpdatedActionData(pendingActionResult) {
|
|
836
|
-
if (pendingActionResult && !isErrorResult(pendingActionResult[1])) return {
|
|
843
|
+
if (pendingActionResult && !isErrorResult(pendingActionResult[1])) return {
|
|
844
|
+
...state.actionData,
|
|
845
|
+
[pendingActionResult[0]]: pendingActionResult[1].data
|
|
846
|
+
};
|
|
837
847
|
else if (state.actionData) if (Object.keys(state.actionData).length === 0) return null;
|
|
838
848
|
else return state.actionData;
|
|
839
849
|
}
|
|
@@ -880,6 +890,9 @@ function createRouter(init) {
|
|
|
880
890
|
fetchLoadMatches.set(key, loadMatch);
|
|
881
891
|
await handleFetcherLoader(key, loadMatch, matches, scopedContext, flushSync, preventScrollReset, submission);
|
|
882
892
|
}
|
|
893
|
+
function isNavigationAwaitingDiscovery() {
|
|
894
|
+
return pendingNavigationDiscoverySignal?.aborted === false;
|
|
895
|
+
}
|
|
883
896
|
async function handleFetcherAction(key, routeId, path, requestMatches, scopedContext, isFogOfWar, flushSync, preventScrollReset, submission, callSiteDefaultShouldRevalidate) {
|
|
884
897
|
if (!future.unstable_customRouteDiscovery) interruptActiveLoads();
|
|
885
898
|
fetchLoadMatches.delete(key);
|
|
@@ -963,9 +976,10 @@ function createRouter(init) {
|
|
|
963
976
|
}
|
|
964
977
|
}
|
|
965
978
|
isRevalidationRequired = true;
|
|
966
|
-
let
|
|
979
|
+
let revalidationLocation = !isNavigationAwaitingDiscovery() ? state.navigation.location : void 0;
|
|
980
|
+
let nextLocation = revalidationLocation || state.location;
|
|
967
981
|
let revalidationRequest = createClientSideRequest(init.history, nextLocation, abortController.signal);
|
|
968
|
-
let matches =
|
|
982
|
+
let matches = revalidationLocation ? dataRouteMatcher.match(revalidationLocation) : state.matches;
|
|
969
983
|
invariant(matches, "Didn't find any matches after fetcher action");
|
|
970
984
|
let loadId = ++incrementingLoadId;
|
|
971
985
|
fetchReloadIds.set(key, loadId);
|
|
@@ -1022,7 +1036,7 @@ function createRouter(init) {
|
|
|
1022
1036
|
if (fetcherIsMounted) finalFetchers.set(key, getDoneFetcher(actionResult.data));
|
|
1023
1037
|
let { loaderData, errors } = processLoaderData(state, matches, loaderResults, void 0, revalidatingFetchers, fetcherResults, finalFetchers);
|
|
1024
1038
|
abortStaleFetchLoads(loadId, finalFetchers);
|
|
1025
|
-
if (state.navigation.state === "loading" && loadId > pendingNavigationLoadId) {
|
|
1039
|
+
if (state.navigation.state === "loading" && loadId > pendingNavigationLoadId && !isNavigationAwaitingDiscovery()) {
|
|
1026
1040
|
invariant(pendingAction, "Expected pending action");
|
|
1027
1041
|
pendingNavigationController && pendingNavigationController.abort();
|
|
1028
1042
|
markFetchRedirectsDone(finalFetchers);
|
|
@@ -1035,7 +1049,7 @@ function createRouter(init) {
|
|
|
1035
1049
|
} else {
|
|
1036
1050
|
updateState({
|
|
1037
1051
|
errors,
|
|
1038
|
-
loaderData: mergeLoaderData(state.loaderData, loaderData, matches, errors),
|
|
1052
|
+
loaderData: mergeLoaderData(state.loaderData, loaderData, state.matches, errors),
|
|
1039
1053
|
fetchers: finalFetchers
|
|
1040
1054
|
});
|
|
1041
1055
|
isRevalidationRequired = fetchReloadIds.size > 0;
|
|
@@ -788,6 +788,8 @@ interface PathMatch<ParamKey extends string = string> {
|
|
|
788
788
|
* Performs pattern matching on a URL pathname and returns information about
|
|
789
789
|
* the match.
|
|
790
790
|
*
|
|
791
|
+
* Throws if the pattern contains more than 12 optional (`?`) markers.
|
|
792
|
+
*
|
|
791
793
|
* @public
|
|
792
794
|
* @category Utils
|
|
793
795
|
* @param pattern The pattern to match against the URL pathname. This can be a
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.3
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -461,10 +461,13 @@ function generatePath(originalPath, params = {}) {
|
|
|
461
461
|
validateDocumentNavigationTarget(result);
|
|
462
462
|
return result;
|
|
463
463
|
}
|
|
464
|
+
const MAX_OPTIONAL_PATH_SEGMENTS = 12;
|
|
464
465
|
/**
|
|
465
466
|
* Performs pattern matching on a URL pathname and returns information about
|
|
466
467
|
* the match.
|
|
467
468
|
*
|
|
469
|
+
* Throws if the pattern contains more than 12 optional (`?`) markers.
|
|
470
|
+
*
|
|
468
471
|
* @public
|
|
469
472
|
* @category Utils
|
|
470
473
|
* @param pattern The pattern to match against the URL pathname. This can be a
|
|
@@ -481,7 +484,10 @@ function matchPath(pattern, pathname) {
|
|
|
481
484
|
caseSensitive: false,
|
|
482
485
|
end: true
|
|
483
486
|
};
|
|
484
|
-
let
|
|
487
|
+
let { path } = pattern;
|
|
488
|
+
let optionalSegments = 0;
|
|
489
|
+
for (let index = path.indexOf("?"); index !== -1; index = path.indexOf("?", index + 1)) if (++optionalSegments > MAX_OPTIONAL_PATH_SEGMENTS) throw new Error(`Path pattern ${JSON.stringify(path)} exceeds the limit of ${MAX_OPTIONAL_PATH_SEGMENTS} optional segments.`);
|
|
490
|
+
let [matcher, compiledParams] = compilePath(path, pattern.caseSensitive, pattern.end);
|
|
485
491
|
return matchPathImpl(pattern, pathname, matcher, compiledParams);
|
|
486
492
|
}
|
|
487
493
|
function matchPathImpl(pattern, pathname, matcher, compiledParams) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.3
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -583,13 +583,13 @@ async function fetchAndApplyManifestPatches(paths, createFromReadableStream, fet
|
|
|
583
583
|
if (!response.body || response.status < 200 || response.status >= 300) throw new Error("Unable to fetch new route matches from the server");
|
|
584
584
|
let payload = await createFromReadableStream(response.body, { temporaryReferences: void 0 });
|
|
585
585
|
if (payload.type !== "manifest") throw new Error("Failed to patch routes");
|
|
586
|
-
paths.forEach((p) => addToFifoQueue(p, discoveredPaths));
|
|
587
586
|
let patches = await payload.patches;
|
|
588
587
|
React$1.startTransition(() => {
|
|
589
588
|
patches.forEach((p) => {
|
|
590
589
|
window.__reactRouterDataRouter.patchRoutes(p.parentId ?? null, [createRouteFromServerManifest(p)]);
|
|
591
590
|
});
|
|
592
591
|
});
|
|
592
|
+
paths.forEach((p) => addToFifoQueue(p, discoveredPaths));
|
|
593
593
|
}
|
|
594
594
|
function addToFifoQueue(path, queue) {
|
|
595
595
|
if (queue.size >= discoveredPathsMaxSize) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.3
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
import { isRouteErrorResponse } from "../router/utils.js";
|
|
12
|
+
import { RSCErrorAlreadyReportedContext } from "../context.js";
|
|
12
13
|
import { useRouteError } from "../hooks.js";
|
|
13
14
|
import React from "react";
|
|
14
15
|
//#region lib/rsc/errorBoundaries.tsx
|
|
@@ -52,7 +53,7 @@ function ErrorWrapper({ renderAppShell, title, children }) {
|
|
|
52
53
|
} }, children)));
|
|
53
54
|
}
|
|
54
55
|
function RSCDefaultRootErrorBoundaryImpl({ error, renderAppShell }) {
|
|
55
|
-
console.error(error);
|
|
56
|
+
if (!React.useContext(RSCErrorAlreadyReportedContext)) console.error(error);
|
|
56
57
|
let heyDeveloper = /* @__PURE__ */ React.createElement("script", { dangerouslySetInnerHTML: { __html: `
|
|
57
58
|
console.log(
|
|
58
59
|
"💿 Hey developer 👋. 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."
|