react-router 8.5.0 → 8.5.1
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 +44 -1
- 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 +50 -396
- package/dist/development/index-react-server.js +43 -15
- package/dist/development/index.js +1 -1
- package/dist/development/lib/actions.js +1 -1
- package/dist/development/lib/await.js +58 -0
- package/dist/development/lib/components.d.ts +41 -5
- package/dist/development/lib/components.js +62 -4
- package/dist/development/lib/context.d.ts +2 -2
- package/dist/development/lib/context.js +1 -1
- package/dist/development/lib/dom/dom.js +1 -1
- package/dist/development/lib/dom/lib.js +1 -1
- package/dist/development/lib/dom/server.js +1 -1
- package/dist/development/lib/dom/ssr/components.js +1 -1
- package/dist/development/lib/dom/ssr/data.js +1 -1
- package/dist/development/lib/dom/ssr/errorBoundaries.js +1 -1
- package/dist/development/lib/dom/ssr/fallback.js +1 -1
- package/dist/development/lib/dom/ssr/fog-of-war.js +12 -3
- 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.d.ts +2 -2
- package/dist/development/lib/dom/ssr/route-discovery.js +3 -3
- package/dist/development/lib/dom/ssr/routeModules.js +1 -1
- package/dist/development/lib/dom/ssr/routes-test-stub.js +1 -1
- package/dist/development/lib/dom/ssr/routes.js +1 -1
- package/dist/development/lib/dom/ssr/server.js +1 -1
- package/dist/development/lib/dom/ssr/single-fetch.d.ts +1 -1
- package/dist/development/lib/dom/ssr/single-fetch.js +7 -7
- package/dist/development/lib/dom-export/dom-router-provider.js +1 -1
- package/dist/development/lib/dom-export/hydrated-router.js +2 -2
- package/dist/development/lib/errors.js +1 -1
- package/dist/development/lib/hooks.d.ts +0 -3
- package/dist/development/lib/hooks.js +5 -6
- package/dist/development/lib/href.js +1 -1
- package/dist/development/lib/router/history.js +1 -1
- 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 +6 -1
- package/dist/development/lib/router/navigation.js +1 -1
- package/dist/development/lib/router/router.d.ts +2 -0
- package/dist/development/lib/router/router.js +58 -28
- package/dist/development/lib/router/url.js +1 -1
- package/dist/development/lib/router/utils.d.ts +7 -0
- package/dist/development/lib/router/utils.js +1 -1
- package/dist/development/lib/rsc/browser.js +3 -3
- package/dist/development/lib/rsc/errorBoundaries.js +1 -1
- 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.ssr.js +1 -1
- 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 +13 -5
- package/dist/development/lib/server-runtime/serverHandoff.js +1 -1
- package/dist/development/lib/server-runtime/sessions/cookieStorage.js +1 -1
- package/dist/development/lib/server-runtime/sessions/memoryStorage.js +1 -1
- package/dist/development/lib/server-runtime/sessions.js +2 -2
- 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/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 +1 -1
- package/dist/development/vendor/turbo-stream-v2/unflatten.js +23 -3
- 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 +50 -396
- package/dist/production/index-react-server.js +43 -15
- package/dist/production/index.js +1 -1
- package/dist/production/lib/actions.js +1 -1
- package/dist/production/lib/await.js +58 -0
- package/dist/production/lib/components.d.ts +41 -5
- package/dist/production/lib/components.js +62 -4
- package/dist/production/lib/context.d.ts +2 -2
- package/dist/production/lib/context.js +1 -1
- package/dist/production/lib/dom/dom.js +1 -1
- package/dist/production/lib/dom/lib.js +1 -1
- package/dist/production/lib/dom/server.js +1 -1
- package/dist/production/lib/dom/ssr/components.js +1 -1
- package/dist/production/lib/dom/ssr/data.js +1 -1
- package/dist/production/lib/dom/ssr/errorBoundaries.js +1 -1
- package/dist/production/lib/dom/ssr/fallback.js +1 -1
- package/dist/production/lib/dom/ssr/fog-of-war.js +12 -3
- 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.d.ts +2 -2
- package/dist/production/lib/dom/ssr/route-discovery.js +3 -3
- package/dist/production/lib/dom/ssr/routeModules.js +1 -1
- package/dist/production/lib/dom/ssr/routes-test-stub.js +1 -1
- package/dist/production/lib/dom/ssr/routes.js +1 -1
- package/dist/production/lib/dom/ssr/server.js +1 -1
- package/dist/production/lib/dom/ssr/single-fetch.d.ts +1 -1
- package/dist/production/lib/dom/ssr/single-fetch.js +7 -7
- package/dist/production/lib/dom-export/dom-router-provider.js +1 -1
- package/dist/production/lib/dom-export/hydrated-router.js +2 -2
- package/dist/production/lib/errors.js +1 -1
- package/dist/production/lib/hooks.d.ts +0 -3
- package/dist/production/lib/hooks.js +5 -6
- package/dist/production/lib/href.js +1 -1
- package/dist/production/lib/router/history.js +1 -1
- 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 +6 -1
- package/dist/production/lib/router/navigation.js +1 -1
- package/dist/production/lib/router/router.d.ts +2 -0
- package/dist/production/lib/router/router.js +58 -28
- package/dist/production/lib/router/url.js +1 -1
- package/dist/production/lib/router/utils.d.ts +7 -0
- package/dist/production/lib/router/utils.js +1 -1
- package/dist/production/lib/rsc/browser.js +3 -3
- package/dist/production/lib/rsc/errorBoundaries.js +1 -1
- 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.ssr.js +1 -1
- 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 +13 -5
- package/dist/production/lib/server-runtime/serverHandoff.js +1 -1
- package/dist/production/lib/server-runtime/sessions/cookieStorage.js +1 -1
- package/dist/production/lib/server-runtime/sessions/memoryStorage.js +1 -1
- package/dist/production/lib/server-runtime/sessions.js +2 -2
- 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/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 +1 -1
- package/dist/production/vendor/turbo-stream-v2/unflatten.js +23 -3
- package/dist/production/vendor/turbo-stream-v2/utils.js +1 -1
- package/docs/explanation/backend-for-frontend.md +0 -3
- package/docs/explanation/code-splitting.md +0 -3
- package/docs/explanation/concurrency.md +0 -3
- package/docs/explanation/hot-module-replacement.md +0 -3
- package/docs/explanation/lazy-route-discovery.md +0 -3
- package/docs/explanation/progressive-enhancement.md +0 -3
- package/docs/explanation/race-conditions.md +0 -3
- package/docs/explanation/react-transitions.md +0 -3
- package/docs/explanation/sessions-and-cookies.md +1 -1
- package/docs/explanation/state-management.md +0 -3
- package/docs/explanation/styling.md +0 -3
- package/docs/explanation/type-safety.md +0 -3
- package/docs/how-to/accessibility.md +0 -6
- package/docs/how-to/client-data.md +0 -3
- package/docs/how-to/data-strategy.md +0 -3
- package/docs/how-to/error-boundary.md +0 -3
- package/docs/how-to/error-reporting.md +0 -3
- package/docs/how-to/fetchers.md +0 -3
- package/docs/how-to/file-route-conventions.md +0 -3
- package/docs/how-to/file-uploads.md +0 -3
- package/docs/how-to/form-validation.md +0 -3
- package/docs/how-to/headers.md +0 -3
- package/docs/how-to/instrumentation.md +0 -3
- package/docs/how-to/middleware.md +6 -3
- package/docs/how-to/navigation-blocking.md +0 -3
- package/docs/how-to/optimize-revalidation.md +0 -3
- package/docs/how-to/pre-rendering.md +0 -3
- package/docs/how-to/presets.md +0 -3
- package/docs/how-to/react-server-components.md +0 -3
- package/docs/how-to/resource-routes.md +0 -3
- package/docs/how-to/route-discovery.md +4 -2
- package/docs/how-to/route-module-type-safety.md +0 -3
- package/docs/how-to/security.md +0 -3
- package/docs/how-to/server-bundles.md +0 -3
- package/docs/how-to/spa.md +0 -3
- package/docs/how-to/status.md +0 -3
- package/docs/how-to/suspense.md +22 -6
- package/docs/how-to/using-handle.md +0 -3
- package/docs/how-to/view-transitions.md +0 -3
- package/docs/start/framework/data-loading.md +9 -0
- package/docs/upgrading/future.md +0 -12
- package/docs/upgrading/v7.md +3 -33
- package/package.json +1 -1
- package/dist/development/lib/dom/global.d.ts +0 -35
- package/dist/production/lib/dom/global.d.ts +0 -35
|
@@ -31,7 +31,7 @@ type RouterFetchContext = {
|
|
|
31
31
|
navigationType: null;
|
|
32
32
|
};
|
|
33
33
|
type RouterFetch = (request: Request, context: RouterFetchContext) => Promise<Response>;
|
|
34
|
-
declare function getTurboStreamSingleFetchDataStrategy(getRouter: () => Router, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, fetchImplementation?: RouterFetch, isApiOnly?: boolean, serverOrigin?: string): DataStrategyFunction;
|
|
34
|
+
declare function getTurboStreamSingleFetchDataStrategy(getRouter: () => Router, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, fetchImplementation?: RouterFetch, isApiOnly?: boolean, serverOrigin?: string, isSpaMode?: boolean): DataStrategyFunction;
|
|
35
35
|
declare function decodeViaTurboStream(body: ReadableStream<Uint8Array>, global: Window | typeof globalThis): Promise<{
|
|
36
36
|
done: Promise<void>;
|
|
37
37
|
value: unknown;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -56,7 +56,7 @@ function StreamTransfer({ context, identifier, reader, textDecoder, nonce }) {
|
|
|
56
56
|
nonce
|
|
57
57
|
})));
|
|
58
58
|
}
|
|
59
|
-
function getTurboStreamSingleFetchDataStrategy(getRouter, manifest, routeModules, ssr, fetchImplementation = (request) => fetch(request), isApiOnly = false, serverOrigin) {
|
|
59
|
+
function getTurboStreamSingleFetchDataStrategy(getRouter, manifest, routeModules, ssr, fetchImplementation = (request) => fetch(request), isApiOnly = false, serverOrigin, isSpaMode = false) {
|
|
60
60
|
let dataStrategy = getSingleFetchDataStrategyImpl(getRouter, (match) => {
|
|
61
61
|
let manifestRoute = manifest.routes[match.route.id];
|
|
62
62
|
invariant(manifestRoute, "Route not found in manifest");
|
|
@@ -64,10 +64,10 @@ function getTurboStreamSingleFetchDataStrategy(getRouter, manifest, routeModules
|
|
|
64
64
|
hasLoader: manifestRoute.hasLoader,
|
|
65
65
|
hasClientLoader: manifestRoute.hasClientLoader
|
|
66
66
|
};
|
|
67
|
-
}, fetchAndDecodeViaTurboStream(fetchImplementation, serverOrigin), ssr, void 0, isApiOnly);
|
|
67
|
+
}, fetchAndDecodeViaTurboStream(fetchImplementation, serverOrigin), ssr, void 0, isApiOnly, isSpaMode);
|
|
68
68
|
return async (args) => args.runClientMiddleware(dataStrategy);
|
|
69
69
|
}
|
|
70
|
-
function getSingleFetchDataStrategyImpl(getRouter, getRouteInfo, fetchAndDecode, ssr, shouldAllowOptOut = () => true, isApiOnly = false) {
|
|
70
|
+
function getSingleFetchDataStrategyImpl(getRouter, getRouteInfo, fetchAndDecode, ssr, shouldAllowOptOut = () => true, isApiOnly = false, isSpaMode = false) {
|
|
71
71
|
return async (args) => {
|
|
72
72
|
let { request, matches, fetcherKey } = args;
|
|
73
73
|
let router = getRouter();
|
|
@@ -78,7 +78,7 @@ function getSingleFetchDataStrategyImpl(getRouter, getRouteInfo, fetchAndDecode,
|
|
|
78
78
|
});
|
|
79
79
|
if (!ssr && !foundRevalidatingServerLoader) return nonSsrStrategy(args, getRouteInfo, fetchAndDecode);
|
|
80
80
|
if (fetcherKey) return singleFetchLoaderFetcherStrategy(args, fetchAndDecode);
|
|
81
|
-
return singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, fetchAndDecode, ssr, shouldAllowOptOut, isApiOnly);
|
|
81
|
+
return singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, fetchAndDecode, ssr, shouldAllowOptOut, isApiOnly, isSpaMode);
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
async function singleFetchActionStrategy(args, fetchAndDecode) {
|
|
@@ -113,7 +113,7 @@ async function nonSsrStrategy(args, getRouteInfo, fetchAndDecode) {
|
|
|
113
113
|
}));
|
|
114
114
|
return results;
|
|
115
115
|
}
|
|
116
|
-
async function singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, fetchAndDecode, ssr, shouldAllowOptOut = () => true, isApiOnly = false) {
|
|
116
|
+
async function singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, fetchAndDecode, ssr, shouldAllowOptOut = () => true, isApiOnly = false, isSpaMode = false) {
|
|
117
117
|
let routesParams = /* @__PURE__ */ new Set();
|
|
118
118
|
let foundOptOutRoute = false;
|
|
119
119
|
let routeDfds = args.matches.map(() => createDeferred());
|
|
@@ -162,7 +162,7 @@ async function singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, f
|
|
|
162
162
|
}
|
|
163
163
|
})));
|
|
164
164
|
await Promise.all(routeDfds.map((d) => d.promise));
|
|
165
|
-
if ((!router.state.initialized && router.state.navigation.state === "idle" && !isApiOnly || routesParams.size === 0) && !window.__reactRouterHdrActive) singleFetchDfd.resolve({ routes: {} });
|
|
165
|
+
if ((!router.state.initialized && router.state.navigation.state === "idle" && !isApiOnly && !isSpaMode || routesParams.size === 0) && !window.__reactRouterHdrActive) singleFetchDfd.resolve({ routes: {} });
|
|
166
166
|
else {
|
|
167
167
|
let targetRoutes = ssr && foundOptOutRoute && routesParams.size > 0 ? [...routesParams.keys()] : void 0;
|
|
168
168
|
try {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -89,7 +89,7 @@ function createHydratedRouter({ getContext, instrumentations, fetch: fetchImplem
|
|
|
89
89
|
mapRouteProperties: UNSAFE_defaultMapRouteProperties,
|
|
90
90
|
hydrationRouteProperties: UNSAFE_hydrationRouteProperties,
|
|
91
91
|
instrumentations,
|
|
92
|
-
dataStrategy: UNSAFE_getTurboStreamSingleFetchDataStrategy(() => router, ssrInfo.manifest, ssrInfo.routeModules, ssr, fetchImplementation, ssrInfo.context.unstable_apiOnly === true, ssrInfo.context.unstable_apiServerOrigin),
|
|
92
|
+
dataStrategy: UNSAFE_getTurboStreamSingleFetchDataStrategy(() => router, ssrInfo.manifest, ssrInfo.routeModules, ssr, fetchImplementation, ssrInfo.context.unstable_apiOnly === true, ssrInfo.context.unstable_apiServerOrigin, ssrInfo.context.isSpaMode),
|
|
93
93
|
patchRoutesOnNavigation: discoveryRuntime ? UNSAFE_getCustomPatchRoutesOnNavigationFunction(() => router, discoveryRuntime) : UNSAFE_getPatchRoutesOnNavigationFunction(() => router, ssrInfo.manifest, ssrInfo.routeModules, ssr, ssrInfo.context.routeDiscovery, ssrInfo.context.isSpaMode, ssrInfo.context.basename, fetchImplementation, ssrInfo.context.unstable_apiServerOrigin, isApiOnly)
|
|
94
94
|
});
|
|
95
95
|
ssrInfo.router = router;
|
|
@@ -192,9 +192,6 @@ interface NavigateFunction {
|
|
|
192
192
|
*
|
|
193
193
|
* [MODES: framework, data]
|
|
194
194
|
*
|
|
195
|
-
* <br/>
|
|
196
|
-
* <br/>
|
|
197
|
-
*
|
|
198
195
|
* To prevent {@link ScrollRestoration | `<ScrollRestoration>`} from resetting
|
|
199
196
|
* the scroll position, use the `preventScrollReset` option.
|
|
200
197
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -212,9 +212,6 @@ const navigateEffectWarning = "You should call navigate() in a React.useEffect()
|
|
|
212
212
|
*
|
|
213
213
|
* [MODES: framework, data]
|
|
214
214
|
*
|
|
215
|
-
* <br/>
|
|
216
|
-
* <br/>
|
|
217
|
-
*
|
|
218
215
|
* To prevent {@link ScrollRestoration | `<ScrollRestoration>`} from resetting
|
|
219
216
|
* the scroll position, use the `preventScrollReset` option.
|
|
220
217
|
*
|
|
@@ -1110,7 +1107,8 @@ function useRouteError() {
|
|
|
1110
1107
|
* @returns The resolved value from the nearest {@link Await} component
|
|
1111
1108
|
*/
|
|
1112
1109
|
function useAsyncValue() {
|
|
1113
|
-
|
|
1110
|
+
let value = React$1.useContext(AwaitContext);
|
|
1111
|
+
return value && "status" in value && !("_tracked" in value) ? value.status === "fulfilled" ? value.value : void 0 : value?._data;
|
|
1114
1112
|
}
|
|
1115
1113
|
/**
|
|
1116
1114
|
* Returns the rejection value from the closest {@link Await | `<Await>`}.
|
|
@@ -1138,7 +1136,8 @@ function useAsyncValue() {
|
|
|
1138
1136
|
* @returns The error that was thrown in the nearest {@link Await} component
|
|
1139
1137
|
*/
|
|
1140
1138
|
function useAsyncError() {
|
|
1141
|
-
|
|
1139
|
+
let value = React$1.useContext(AwaitContext);
|
|
1140
|
+
return value && "status" in value && !("_tracked" in value) ? value.status === "rejected" ? value.reason : void 0 : value?._error;
|
|
1142
1141
|
}
|
|
1143
1142
|
let blockerId = 0;
|
|
1144
1143
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -14,12 +14,17 @@ var V6RegExMatcher = class {
|
|
|
14
14
|
#routes = [];
|
|
15
15
|
#branches = [];
|
|
16
16
|
#basename;
|
|
17
|
+
#matchCost = 0;
|
|
17
18
|
constructor(basename) {
|
|
18
19
|
this.#basename = basename;
|
|
19
20
|
}
|
|
20
21
|
update(routes) {
|
|
21
22
|
this.#routes = routes;
|
|
22
23
|
this.#branches = flattenAndRankRoutes(routes);
|
|
24
|
+
this.#matchCost = this.#branches.reduce((total, branch) => total + branch.routesMeta.length, 0);
|
|
25
|
+
}
|
|
26
|
+
get matchCost() {
|
|
27
|
+
return this.#matchCost;
|
|
23
28
|
}
|
|
24
29
|
match(locationArg, allowPartial = false) {
|
|
25
30
|
return matchRoutesImpl(this.#routes, locationArg, this.#basename, allowPartial, this.#branches);
|
|
@@ -353,6 +353,8 @@ interface StaticHandler {
|
|
|
353
353
|
* The set of data routes managed by this handler
|
|
354
354
|
*/
|
|
355
355
|
dataRoutes: DataRouteObject[];
|
|
356
|
+
/** @private Estimated route metadata visits per regex match. */
|
|
357
|
+
readonly _matchCost?: number;
|
|
356
358
|
/**
|
|
357
359
|
* @private
|
|
358
360
|
* PRIVATE - DO NOT USE
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -408,7 +408,7 @@ function createRouter(init) {
|
|
|
408
408
|
pendingPreventScrollReset = false;
|
|
409
409
|
pendingViewTransitionEnabled = false;
|
|
410
410
|
isUninterruptedRevalidation = false;
|
|
411
|
-
isRevalidationRequired =
|
|
411
|
+
isRevalidationRequired = fetchReloadIds.size > 0;
|
|
412
412
|
}
|
|
413
413
|
async function navigate(to, opts) {
|
|
414
414
|
if (pendingDiscoveryCancellation) await pendingDiscoveryCancellation;
|
|
@@ -446,8 +446,9 @@ function createRouter(init) {
|
|
|
446
446
|
validateNavigationTarget(to == null ? init.history.createHref(state.location) : typeof to === "string" ? to : createPath(to), init.history.createHref(nextLocation.mask || nextLocation), init.history.createURL("/"), "reject");
|
|
447
447
|
let userReplace = opts && opts.replace != null ? opts.replace : void 0;
|
|
448
448
|
let historyAction = "PUSH";
|
|
449
|
+
let currentPath = state.location.pathname + state.location.search;
|
|
449
450
|
if (userReplace === true) historyAction = "REPLACE";
|
|
450
|
-
else if (userReplace === false) {} else if (submission != null && isMutationMethod(submission.formMethod) && submission.formAction ===
|
|
451
|
+
else if (userReplace === false) {} else if (submission != null && isMutationMethod(submission.formMethod) && (submission.formAction === currentPath || nextLocation.pathname + nextLocation.search === currentPath)) historyAction = "REPLACE";
|
|
451
452
|
let preventScrollReset = opts && "preventScrollReset" in opts ? opts.preventScrollReset === true : void 0;
|
|
452
453
|
let flushSync = (opts && opts.flushSync) === true;
|
|
453
454
|
let blockerKey = shouldBlockNavigation({
|
|
@@ -789,12 +790,16 @@ function createRouter(init) {
|
|
|
789
790
|
abortFetcher(rf.key);
|
|
790
791
|
if (rf.controller) fetchControllers.set(rf.key, rf.controller);
|
|
791
792
|
});
|
|
792
|
-
let abortPendingFetchRevalidations = () => revalidatingFetchers.forEach((
|
|
793
|
+
let abortPendingFetchRevalidations = () => revalidatingFetchers.forEach((rf) => {
|
|
794
|
+
if (fetchControllers.get(rf.key) === rf.controller) abortFetcher(rf.key);
|
|
795
|
+
});
|
|
793
796
|
if (pendingNavigationController) pendingNavigationController.signal.addEventListener("abort", abortPendingFetchRevalidations);
|
|
794
797
|
let { loaderResults, fetcherResults } = await callLoadersAndMaybeResolveData(dsMatches, revalidatingFetchers, request, location, scopedContext, dataStrategyInitiator, historyAction);
|
|
795
798
|
if (request.signal.aborted) return { shortCircuited: true };
|
|
796
799
|
if (pendingNavigationController) pendingNavigationController.signal.removeEventListener("abort", abortPendingFetchRevalidations);
|
|
797
|
-
revalidatingFetchers.forEach((rf) =>
|
|
800
|
+
revalidatingFetchers.forEach((rf) => {
|
|
801
|
+
if (fetchControllers.get(rf.key) === rf.controller) fetchControllers.delete(rf.key);
|
|
802
|
+
});
|
|
798
803
|
let redirect = findRedirect(loaderResults);
|
|
799
804
|
if (redirect) {
|
|
800
805
|
await startRedirectNavigation(request, redirect.result, true, dataStrategyInitiator, { replace });
|
|
@@ -923,30 +928,39 @@ function createRouter(init) {
|
|
|
923
928
|
return;
|
|
924
929
|
}
|
|
925
930
|
if (fetchersQueuedForDeletion.has(key)) {
|
|
926
|
-
if (
|
|
931
|
+
if (isErrorResult(actionResult)) {
|
|
927
932
|
updateFetcherState(key, getDoneFetcher(void 0));
|
|
928
933
|
return;
|
|
929
934
|
}
|
|
930
|
-
} else {
|
|
931
935
|
if (isRedirectResult(actionResult)) {
|
|
936
|
+
isRevalidationRequired = true;
|
|
937
|
+
actionResult = {
|
|
938
|
+
type: "data",
|
|
939
|
+
data: void 0
|
|
940
|
+
};
|
|
941
|
+
}
|
|
942
|
+
} else {
|
|
943
|
+
if (isRedirectResult(actionResult)) if (pendingNavigationLoadId > originatingLoadId) {
|
|
944
|
+
isRevalidationRequired = true;
|
|
945
|
+
actionResult = {
|
|
946
|
+
type: "data",
|
|
947
|
+
data: void 0
|
|
948
|
+
};
|
|
949
|
+
} else {
|
|
932
950
|
fetchControllers.delete(key);
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
return startRedirectNavigation(fetchRequest, actionResult, false, "fetcher", {
|
|
940
|
-
fetcherSubmission: submission,
|
|
941
|
-
preventScrollReset
|
|
942
|
-
});
|
|
943
|
-
}
|
|
951
|
+
fetchRedirectIds.add(key);
|
|
952
|
+
updateFetcherState(key, getLoadingFetcher(submission));
|
|
953
|
+
return startRedirectNavigation(fetchRequest, actionResult, false, "fetcher", {
|
|
954
|
+
fetcherSubmission: submission,
|
|
955
|
+
preventScrollReset
|
|
956
|
+
});
|
|
944
957
|
}
|
|
945
958
|
if (isErrorResult(actionResult)) {
|
|
946
959
|
setFetcherError(key, routeId, actionResult.error);
|
|
947
960
|
return;
|
|
948
961
|
}
|
|
949
962
|
}
|
|
963
|
+
isRevalidationRequired = true;
|
|
950
964
|
let nextLocation = state.navigation.location || state.location;
|
|
951
965
|
let revalidationRequest = createClientSideRequest(init.history, nextLocation, abortController.signal);
|
|
952
966
|
let matches = state.navigation.state !== "idle" ? dataRouteMatcher.match(state.navigation.location) : state.matches;
|
|
@@ -966,7 +980,9 @@ function createRouter(init) {
|
|
|
966
980
|
if (rf.controller) fetchControllers.set(staleKey, rf.controller);
|
|
967
981
|
});
|
|
968
982
|
updateState({ fetchers: workingFetchers });
|
|
969
|
-
let abortPendingFetchRevalidations = () => revalidatingFetchers.forEach((rf) =>
|
|
983
|
+
let abortPendingFetchRevalidations = () => revalidatingFetchers.forEach((rf) => {
|
|
984
|
+
if (fetchControllers.get(rf.key) === rf.controller) abortFetcher(rf.key);
|
|
985
|
+
});
|
|
970
986
|
abortController.signal.addEventListener("abort", abortPendingFetchRevalidations);
|
|
971
987
|
let { loaderResults, fetcherResults } = await callLoadersAndMaybeResolveData(dsMatches, revalidatingFetchers, revalidationRequest, nextLocation, scopedContext, "fetcher");
|
|
972
988
|
if (abortController.signal.aborted) {
|
|
@@ -976,7 +992,9 @@ function createRouter(init) {
|
|
|
976
992
|
abortController.signal.removeEventListener("abort", abortPendingFetchRevalidations);
|
|
977
993
|
fetchReloadIds.delete(key);
|
|
978
994
|
fetchControllers.delete(key);
|
|
979
|
-
revalidatingFetchers.forEach((r) =>
|
|
995
|
+
revalidatingFetchers.forEach((r) => {
|
|
996
|
+
if (fetchControllers.get(r.key) === r.controller) fetchControllers.delete(r.key);
|
|
997
|
+
});
|
|
980
998
|
let fetcherIsMounted = state.fetchers.has(key);
|
|
981
999
|
let getRedirectStateWithDoneFetcher = (s) => {
|
|
982
1000
|
if (!fetcherIsMounted) return s;
|
|
@@ -1005,6 +1023,7 @@ function createRouter(init) {
|
|
|
1005
1023
|
if (state.navigation.state === "loading" && loadId > pendingNavigationLoadId) {
|
|
1006
1024
|
invariant(pendingAction, "Expected pending action");
|
|
1007
1025
|
pendingNavigationController && pendingNavigationController.abort();
|
|
1026
|
+
markFetchRedirectsDone(finalFetchers);
|
|
1008
1027
|
completeNavigation(state.navigation.location, {
|
|
1009
1028
|
matches,
|
|
1010
1029
|
loaderData,
|
|
@@ -1017,7 +1036,7 @@ function createRouter(init) {
|
|
|
1017
1036
|
loaderData: mergeLoaderData(state.loaderData, loaderData, matches, errors),
|
|
1018
1037
|
fetchers: finalFetchers
|
|
1019
1038
|
});
|
|
1020
|
-
isRevalidationRequired =
|
|
1039
|
+
isRevalidationRequired = fetchReloadIds.size > 0;
|
|
1021
1040
|
}
|
|
1022
1041
|
}
|
|
1023
1042
|
async function handleFetcherLoader(key, loadMatch, matches, scopedContext, flushSync, preventScrollReset, submission) {
|
|
@@ -1877,6 +1896,9 @@ function createStaticHandler(routes, opts) {
|
|
|
1877
1896
|
}
|
|
1878
1897
|
return {
|
|
1879
1898
|
dataRoutes,
|
|
1899
|
+
get _matchCost() {
|
|
1900
|
+
return dataRouteMatcher instanceof V6RegExMatcher ? dataRouteMatcher.matchCost : void 0;
|
|
1901
|
+
},
|
|
1880
1902
|
match,
|
|
1881
1903
|
query,
|
|
1882
1904
|
queryRoute
|
|
@@ -2262,6 +2284,9 @@ const loadLazyRouteProperty = ({ key, route, manifest, mapRouteProperties }) =>
|
|
|
2262
2284
|
}
|
|
2263
2285
|
})();
|
|
2264
2286
|
cache[key] = propertyPromise;
|
|
2287
|
+
propertyPromise.catch(() => {
|
|
2288
|
+
if (cache[key] === propertyPromise) delete cache[key];
|
|
2289
|
+
});
|
|
2265
2290
|
return propertyPromise;
|
|
2266
2291
|
};
|
|
2267
2292
|
const lazyRouteFunctionCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -2303,7 +2328,9 @@ function loadLazyRoute(route, type, manifest, mapRouteProperties, lazyRoutePrope
|
|
|
2303
2328
|
});
|
|
2304
2329
|
})();
|
|
2305
2330
|
lazyRouteFunctionCache.set(routeToUpdate, lazyRoutePromise);
|
|
2306
|
-
lazyRoutePromise.catch(() => {
|
|
2331
|
+
lazyRoutePromise.catch(() => {
|
|
2332
|
+
if (lazyRouteFunctionCache.get(routeToUpdate) === lazyRoutePromise) lazyRouteFunctionCache.delete(routeToUpdate);
|
|
2333
|
+
});
|
|
2307
2334
|
return {
|
|
2308
2335
|
lazyRoutePromise,
|
|
2309
2336
|
lazyHandlerPromise: lazyRoutePromise
|
|
@@ -2595,10 +2622,13 @@ async function callLoaderOrAction({ request, path, pattern, match, lazyHandlerPr
|
|
|
2595
2622
|
pathname,
|
|
2596
2623
|
routeId: match.route.id
|
|
2597
2624
|
});
|
|
2598
|
-
} else
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2625
|
+
} else {
|
|
2626
|
+
await lazyRoutePromise;
|
|
2627
|
+
return {
|
|
2628
|
+
type: "data",
|
|
2629
|
+
result: void 0
|
|
2630
|
+
};
|
|
2631
|
+
}
|
|
2602
2632
|
}
|
|
2603
2633
|
else if (!handler) {
|
|
2604
2634
|
let url = new URL(request.url);
|
|
@@ -2793,12 +2823,12 @@ function processRouteLoaderData(matches, results, pendingActionResult, isStaticH
|
|
|
2793
2823
|
function processLoaderData(state, matches, results, pendingActionResult, revalidatingFetchers, fetcherResults, workingFetchers) {
|
|
2794
2824
|
let { loaderData, errors } = processRouteLoaderData(matches, results, pendingActionResult);
|
|
2795
2825
|
revalidatingFetchers.filter((f) => !f.matches || f.matches.some((m) => m.shouldLoad)).forEach((rf) => {
|
|
2796
|
-
let { key,
|
|
2826
|
+
let { key, routeId, controller } = rf;
|
|
2797
2827
|
if (controller && controller.signal.aborted) return;
|
|
2798
2828
|
let result = fetcherResults[key];
|
|
2799
2829
|
invariant(result, "Did not find corresponding fetcher result");
|
|
2800
2830
|
if (isErrorResult(result)) {
|
|
2801
|
-
let boundaryMatch = findNearestBoundary(state.matches,
|
|
2831
|
+
let boundaryMatch = findNearestBoundary(state.matches, routeId);
|
|
2802
2832
|
if (!(errors && errors[boundaryMatch.route.id])) errors = {
|
|
2803
2833
|
...errors,
|
|
2804
2834
|
[boundaryMatch.route.id]: result.error
|
|
@@ -185,6 +185,13 @@ interface DataFunctionArgs<Context> {
|
|
|
185
185
|
* In Framework mode, this is a normalized URL with React-Router-specific
|
|
186
186
|
* implementation details removed (`.data` suffixes, `index`/`_routes` search
|
|
187
187
|
* params). For the raw incoming URL, use `request.url`.
|
|
188
|
+
*
|
|
189
|
+
* This normalization preserves standard URL pathname encoding and casing.
|
|
190
|
+
* For example, a request to `/%61dmin.data` produces a `url.pathname` of
|
|
191
|
+
* `/%61dmin`. This is not a canonical representation of the matched route.
|
|
192
|
+
* For authorization, attach {@link https://reactrouter.com/how-to/middleware#authentication server middleware}
|
|
193
|
+
* to the protected route or a common ancestor instead of relying on literal
|
|
194
|
+
* pathname-prefix comparisons.
|
|
188
195
|
*/
|
|
189
196
|
url: URL;
|
|
190
197
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -17,7 +17,7 @@ import { RSCRouterContext } from "../context.js";
|
|
|
17
17
|
import { createRequestInit } from "../dom/ssr/data.js";
|
|
18
18
|
import { getSingleFetchDataStrategyImpl, singleFetchUrl, stripIndexParam } from "../dom/ssr/single-fetch.js";
|
|
19
19
|
import { noActionDefinedError, shouldHydrateRouteLoader } from "../dom/ssr/routes.js";
|
|
20
|
-
import { getPathsWithAncestors, handleClientVersionMismatch } from "../dom/ssr/fog-of-war.js";
|
|
20
|
+
import { getManifestPathsParam, getPathsWithAncestors, handleClientVersionMismatch } from "../dom/ssr/fog-of-war.js";
|
|
21
21
|
import { FrameworkContext, setIsHydrated } from "../dom/ssr/components.js";
|
|
22
22
|
import { RouterProvider } from "../components.js";
|
|
23
23
|
import { RSCRouterGlobalErrorBoundary } from "./errorBoundaries.js";
|
|
@@ -539,7 +539,7 @@ function getManifestUrl(paths, clientVersion) {
|
|
|
539
539
|
else {
|
|
540
540
|
let basename = (window.__reactRouterDataRouter.basename ?? "").replace(/^\/|\/$/g, "");
|
|
541
541
|
url = new URL(`${basename}/.manifest`, window.location.origin);
|
|
542
|
-
url.searchParams.set("paths", paths
|
|
542
|
+
url.searchParams.set("paths", getManifestPathsParam(paths));
|
|
543
543
|
}
|
|
544
544
|
if (clientVersion !== void 0) url.searchParams.set("version", clientVersion);
|
|
545
545
|
return url;
|