react-router 8.5.0 → 8.5.2
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 +70 -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 +75 -415
- package/dist/development/index-react-server.js +106 -20
- 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 +65 -25
- package/dist/development/lib/components.js +69 -15
- package/dist/development/lib/context.d.ts +2 -2
- package/dist/development/lib/context.js +1 -1
- package/dist/development/lib/dom/dom.js +13 -4
- package/dist/development/lib/dom/lib.d.ts +2 -2
- package/dist/development/lib/dom/lib.js +11 -4
- 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.d.ts +1 -0
- 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.d.ts +1 -1
- package/dist/development/lib/dom-export/hydrated-router.js +5 -3
- package/dist/development/lib/errors.js +1 -1
- package/dist/development/lib/hooks.d.ts +0 -3
- package/dist/development/lib/hooks.js +13 -9
- package/dist/development/lib/href.js +4 -4
- 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 +17 -2
- package/dist/development/lib/router/router.d.ts +2 -0
- package/dist/development/lib/router/router.js +62 -29
- package/dist/development/lib/router/url.js +1 -1
- package/dist/development/lib/router/utils.d.ts +13 -5
- package/dist/development/lib/router/utils.js +17 -8
- package/dist/development/lib/rsc/browser.js +28 -5
- 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.rsc.d.ts +2 -0
- 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 +21 -10
- 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/lib/types/route-module-annotations.d.ts +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 +75 -66
- 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 +75 -415
- package/dist/production/index-react-server.js +106 -20
- 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 +65 -25
- package/dist/production/lib/components.js +69 -15
- package/dist/production/lib/context.d.ts +2 -2
- package/dist/production/lib/context.js +1 -1
- package/dist/production/lib/dom/dom.js +13 -4
- package/dist/production/lib/dom/lib.d.ts +2 -2
- package/dist/production/lib/dom/lib.js +11 -4
- 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.d.ts +1 -0
- 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.d.ts +1 -1
- package/dist/production/lib/dom-export/hydrated-router.js +5 -3
- package/dist/production/lib/errors.js +1 -1
- package/dist/production/lib/hooks.d.ts +0 -3
- package/dist/production/lib/hooks.js +13 -9
- package/dist/production/lib/href.js +4 -4
- 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 +17 -2
- package/dist/production/lib/router/router.d.ts +2 -0
- package/dist/production/lib/router/router.js +62 -29
- package/dist/production/lib/router/url.js +1 -1
- package/dist/production/lib/router/utils.d.ts +13 -5
- package/dist/production/lib/router/utils.js +17 -8
- package/dist/production/lib/rsc/browser.js +28 -5
- 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.rsc.d.ts +2 -0
- 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 +21 -10
- 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/lib/types/route-module-annotations.d.ts +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 +75 -66
- 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 +14 -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
|
@@ -32,8 +32,8 @@ type FetchersContextObject = {
|
|
|
32
32
|
fetcherData: Map<string, any>;
|
|
33
33
|
};
|
|
34
34
|
declare const FetchersContext: React$1.Context<FetchersContextObject | null>;
|
|
35
|
-
declare const AwaitContext: React$1.Context<TrackedPromise | null>;
|
|
36
|
-
declare const AwaitContextProvider: (props: React$1.ComponentProps<typeof AwaitContext.Provider>) => React$1.FunctionComponentElement<React$1.ProviderProps<TrackedPromise | null>>;
|
|
35
|
+
declare const AwaitContext: React$1.Context<TrackedPromise | PromiseSettledResult<unknown> | null>;
|
|
36
|
+
declare const AwaitContextProvider: (props: React$1.ComponentProps<typeof AwaitContext.Provider>) => React$1.FunctionComponentElement<React$1.ProviderProps<TrackedPromise | PromiseSettledResult<unknown> | null>>;
|
|
37
37
|
interface NavigateOptions {
|
|
38
38
|
/** Replace the current entry in the history stack instead of pushing a new one */
|
|
39
39
|
replace?: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.2
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import { warning } from "../router/history.js";
|
|
11
|
+
import { createPath, parsePath, warning } from "../router/history.js";
|
|
12
12
|
import { stripBasename } from "../router/utils.js";
|
|
13
13
|
const defaultEncType = "application/x-www-form-urlencoded";
|
|
14
14
|
function isHtmlElement(object) {
|
|
@@ -92,6 +92,15 @@ function getFormEncType(encType) {
|
|
|
92
92
|
}
|
|
93
93
|
return encType;
|
|
94
94
|
}
|
|
95
|
+
function stripBasenameFromAction(action, basename) {
|
|
96
|
+
if (basename === "/") return action;
|
|
97
|
+
let path = parsePath(action);
|
|
98
|
+
let pathname = stripBasename(path.pathname || "", basename);
|
|
99
|
+
return pathname == null ? null : createPath({
|
|
100
|
+
...path,
|
|
101
|
+
pathname
|
|
102
|
+
});
|
|
103
|
+
}
|
|
95
104
|
function getFormSubmissionInfo(target, basename) {
|
|
96
105
|
let method;
|
|
97
106
|
let action;
|
|
@@ -100,7 +109,7 @@ function getFormSubmissionInfo(target, basename) {
|
|
|
100
109
|
let body;
|
|
101
110
|
if (isFormElement(target)) {
|
|
102
111
|
let attr = target.getAttribute("action");
|
|
103
|
-
action = attr ?
|
|
112
|
+
action = attr ? stripBasenameFromAction(attr, basename) : null;
|
|
104
113
|
method = target.getAttribute("method") || "get";
|
|
105
114
|
encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
|
|
106
115
|
formData = new FormData(target);
|
|
@@ -108,7 +117,7 @@ function getFormSubmissionInfo(target, basename) {
|
|
|
108
117
|
let form = target.form;
|
|
109
118
|
if (form == null) throw new Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);
|
|
110
119
|
let attr = target.getAttribute("formaction") || form.getAttribute("action");
|
|
111
|
-
action = attr ?
|
|
120
|
+
action = attr ? stripBasenameFromAction(attr, basename) : null;
|
|
112
121
|
method = target.getAttribute("formmethod") || form.getAttribute("method") || "get";
|
|
113
122
|
encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
|
|
114
123
|
formData = new FormData(form, target);
|
|
@@ -69,7 +69,7 @@ interface DOMRouterOpts {
|
|
|
69
69
|
*
|
|
70
70
|
* You will almost always include a complete set of `loaderData` to hydrate a
|
|
71
71
|
* server-rendered app. But in advanced use-cases (such as Framework Mode's
|
|
72
|
-
* [`clientLoader`](../../start/framework/route-module#
|
|
72
|
+
* [`clientLoader`](../../start/framework/route-module#clientloader)), you may
|
|
73
73
|
* want to include `loaderData` for only some routes that were loaded/rendered
|
|
74
74
|
* on the server. This allows you to hydrate _some_ of the routes (such as the
|
|
75
75
|
* app layout/shell) while showing a `HydrateFallback` component and running
|
|
@@ -208,7 +208,7 @@ interface DOMRouterOpts {
|
|
|
208
208
|
* To combat this, we introduced [`route.lazy`](../../start/data/route-object#lazy)
|
|
209
209
|
* in [v6.9.0](https://github.com/remix-run/react-router/blob/main/CHANGELOG.md#v690)
|
|
210
210
|
* which lets you lazily load the route _implementation_ ([`loader`](../../start/data/route-object#loader),
|
|
211
|
-
* [`Component`](../../start/data/route-object#
|
|
211
|
+
* [`Component`](../../start/data/route-object#component), etc.) while still
|
|
212
212
|
* providing the route _definition_ aspects up front (`path`, `index`, etc.).
|
|
213
213
|
* This is a good middle ground. React Router still knows about your route
|
|
214
214
|
* definitions (the lightweight part) up front and can perform synchronous
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.2
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { ABSOLUTE_URL_REGEX } from "../router/url.js";
|
|
12
12
|
import { createBrowserHistory, createHashHistory, createPath, invariant, warning } from "../router/history.js";
|
|
13
|
+
import { validateDocumentNavigationTarget } from "../router/navigation.js";
|
|
13
14
|
import { ErrorResponseImpl, SUPPORTED_ERROR_TYPES, defaultMapRouteProperties, joinPaths, matchPath, parseToInfo, resolveTo, stripBasename } from "../router/utils.js";
|
|
14
15
|
import { IDLE_FETCHER, createRouter } from "../router/router.js";
|
|
15
16
|
import { DataRouterNavigationContext, NavigationContext, RouteContext, ViewTransitionContext } from "../context.js";
|
|
@@ -314,10 +315,12 @@ const Link = React$1.forwardRef(function LinkWithRef({ onClick, discover = "rend
|
|
|
314
315
|
if (!event.defaultPrevented) internalOnClick(event);
|
|
315
316
|
}
|
|
316
317
|
let isSpaLink = !(parsed.isExternal || reloadDocument);
|
|
318
|
+
let renderedHref = (isSpaLink ? maskedHref : void 0) || parsed.absoluteURL || href;
|
|
319
|
+
validateDocumentNavigationTarget(renderedHref);
|
|
317
320
|
let link = /* @__PURE__ */ React$1.createElement("a", {
|
|
318
321
|
...rest,
|
|
319
322
|
...prefetchHandlers,
|
|
320
|
-
href:
|
|
323
|
+
href: renderedHref,
|
|
321
324
|
onClick: isSpaLink ? handleClick : onClick,
|
|
322
325
|
ref: mergeRefs(forwardedRef, prefetchRef),
|
|
323
326
|
target,
|
|
@@ -562,7 +565,9 @@ function ScrollRestoration({ getKey, storageKey, ...props }) {
|
|
|
562
565
|
if (typeof storedY === "number") window.scrollTo(0, storedY);
|
|
563
566
|
} catch (error) {
|
|
564
567
|
console.error(error);
|
|
565
|
-
|
|
568
|
+
try {
|
|
569
|
+
sessionStorage.removeItem(storageKey);
|
|
570
|
+
} catch {}
|
|
566
571
|
}
|
|
567
572
|
}).toString();
|
|
568
573
|
if (props.nonce == null && remixContext?.nonce) props.nonce = remixContext.nonce;
|
|
@@ -872,7 +877,9 @@ function useFormAction(action, { relative } = {}) {
|
|
|
872
877
|
}
|
|
873
878
|
if ((!action || action === ".") && match.route.index) path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
|
|
874
879
|
if (basename !== "/") path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
|
|
875
|
-
|
|
880
|
+
let formAction = createPath(path);
|
|
881
|
+
validateDocumentNavigationTarget(formAction);
|
|
882
|
+
return formAction;
|
|
876
883
|
}
|
|
877
884
|
/**
|
|
878
885
|
* Useful for creating complex, dynamic user interfaces that require multiple,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.2
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -29,6 +29,12 @@ function getPathsWithAncestors(paths) {
|
|
|
29
29
|
function isFogOfWarEnabled(routeDiscovery, ssr) {
|
|
30
30
|
return routeDiscovery.mode === "lazy" && ssr;
|
|
31
31
|
}
|
|
32
|
+
const MANIFEST_MATCH_COST_LIMIT = 5e4;
|
|
33
|
+
const MANIFEST_MATCH_COST_SEGMENT_THRESHOLD = 10;
|
|
34
|
+
function shouldUseInitialRouteDiscovery(pathname, matchCost = 0) {
|
|
35
|
+
let segmentCount = pathname.split("/").length - 1;
|
|
36
|
+
return Math.max(segmentCount - 1, 0) * pathname.length + 1 > 7680 || segmentCount > MANIFEST_MATCH_COST_SEGMENT_THRESHOLD && segmentCount * matchCost > MANIFEST_MATCH_COST_LIMIT;
|
|
37
|
+
}
|
|
32
38
|
function getPartialManifest({ sri, ...manifest }, router) {
|
|
33
39
|
let routeIds = new Set(router.state.matches.map((m) => m.route.id));
|
|
34
40
|
let segments = router.state.location.pathname.split("/").filter(Boolean);
|
|
@@ -108,6 +114,9 @@ function useFogOFWarDiscovery(router, manifest, routeModules, ssr, routeDiscover
|
|
|
108
114
|
isApiOnly
|
|
109
115
|
]);
|
|
110
116
|
}
|
|
117
|
+
function getManifestPathsParam(paths) {
|
|
118
|
+
return paths.slice().sort().map((path) => path.replace(/,/g, "%2C")).join(",");
|
|
119
|
+
}
|
|
111
120
|
function getManifestPath(_manifestPath, basename) {
|
|
112
121
|
let manifestPath = _manifestPath || "/__manifest";
|
|
113
122
|
return basename == null ? manifestPath : joinPaths([basename, manifestPath]);
|
|
@@ -160,7 +169,7 @@ async function handleClientVersionMismatch(needsReload, version, errorReloadPath
|
|
|
160
169
|
async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename, manifestPath, patchRoutes, signal, fetchImplementation = (request) => fetch(request), serverOrigin, isApiOnly = false) {
|
|
161
170
|
paths = getPathsWithAncestors(paths);
|
|
162
171
|
const searchParams = new URLSearchParams();
|
|
163
|
-
searchParams.set("paths", paths
|
|
172
|
+
searchParams.set("paths", getManifestPathsParam(paths));
|
|
164
173
|
searchParams.set("version", manifest.version);
|
|
165
174
|
let url = new URL(getManifestPath(manifestPath, basename), serverOrigin ?? window.location.origin);
|
|
166
175
|
url.search = searchParams.toString();
|
|
@@ -207,4 +216,4 @@ function debounce(callback, wait) {
|
|
|
207
216
|
};
|
|
208
217
|
}
|
|
209
218
|
//#endregion
|
|
210
|
-
export { URL_LIMIT, getManifestPath, getPartialManifest, getPatchRoutesOnNavigationFunction, getPathsWithAncestors, handleClientVersionMismatch, isFogOfWarEnabled, useFogOFWarDiscovery };
|
|
219
|
+
export { URL_LIMIT, getManifestPath, getManifestPathsParam, getPartialManifest, getPatchRoutesOnNavigationFunction, getPathsWithAncestors, handleClientVersionMismatch, isFogOfWarEnabled, shouldUseInitialRouteDiscovery, useFogOFWarDiscovery };
|
|
@@ -22,6 +22,7 @@ declare function getHydrationData({
|
|
|
22
22
|
routes: DataRouteObject[];
|
|
23
23
|
getRouteInfo: (routeId: string) => {
|
|
24
24
|
clientLoader: ClientLoaderFunction | undefined;
|
|
25
|
+
clientMiddleware?: DataRouteObject["middleware"];
|
|
25
26
|
hasLoader: boolean;
|
|
26
27
|
hasHydrateFallback: boolean;
|
|
27
28
|
};
|
|
@@ -4,7 +4,7 @@ import { Router } from "../../router/router.js";
|
|
|
4
4
|
import { ClientOnErrorFunction } from "../../components.js";
|
|
5
5
|
import { RouteModules } from "./routeModules.js";
|
|
6
6
|
import { RouterFetch } from "./single-fetch.js";
|
|
7
|
-
import {
|
|
7
|
+
import { ServerHandoff } from "../../server-runtime/serverHandoff.js";
|
|
8
8
|
import { AssetsManifest } from "./entry.js";
|
|
9
9
|
|
|
10
10
|
//#region lib/dom/ssr/route-discovery.d.ts
|
|
@@ -37,7 +37,7 @@ type RouteDiscoverySsrInfo = {
|
|
|
37
37
|
manifest: AssetsManifest;
|
|
38
38
|
routeModules: RouteModules;
|
|
39
39
|
router: Router | undefined;
|
|
40
|
-
context: Pick<
|
|
40
|
+
context: Pick<ServerHandoff, "ssr" | "routeDiscovery" | "isSpaMode" | "basename" | "unstable_apiServerOrigin" | "unstable_apiOnly">;
|
|
41
41
|
};
|
|
42
42
|
declare class RouteDiscoveryRuntime {
|
|
43
43
|
private ssrInfo;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.2
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import { createPath, invariant } from "../../router/history.js";
|
|
12
12
|
import { DiscoveryCancelledError, getRoutePattern, prependBasename } from "../../router/utils.js";
|
|
13
13
|
import { createClientRoutes } from "./routes.js";
|
|
14
|
-
import { getManifestPath, getPathsWithAncestors, handleClientVersionMismatch, isFogOfWarEnabled } from "./fog-of-war.js";
|
|
14
|
+
import { getManifestPath, getManifestPathsParam, getPathsWithAncestors, handleClientVersionMismatch, isFogOfWarEnabled } from "./fog-of-war.js";
|
|
15
15
|
import { useFrameworkContext } from "./components.js";
|
|
16
16
|
import * as React$1 from "react";
|
|
17
17
|
//#region lib/dom/ssr/route-discovery.ts
|
|
@@ -158,7 +158,7 @@ var RouteDiscoveryRuntime = class {
|
|
|
158
158
|
requestUrl(paths) {
|
|
159
159
|
let { manifest, context } = this.ssrInfo;
|
|
160
160
|
let params = new URLSearchParams();
|
|
161
|
-
params.set("paths", paths
|
|
161
|
+
params.set("paths", getManifestPathsParam(paths));
|
|
162
162
|
params.set("version", manifest.version);
|
|
163
163
|
let url = new URL(getManifestPath(context.routeDiscovery.manifestPath, context.basename), context.unstable_apiServerOrigin ?? window.location.origin);
|
|
164
164
|
url.search = params.toString();
|
|
@@ -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.2
|
|
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 {
|
|
@@ -15,7 +15,7 @@ interface HydratedRouterProps {
|
|
|
15
15
|
* Context factory function to be passed through to {@link createBrowserRouter}.
|
|
16
16
|
* This function will be called to create a fresh `context` instance on each
|
|
17
17
|
* navigation/fetch and made available to
|
|
18
|
-
* [`clientAction`](../../start/framework/route-module#
|
|
18
|
+
* [`clientAction`](../../start/framework/route-module#clientaction)/[`clientLoader`](../../start/framework/route-module#clientloader)
|
|
19
19
|
* functions.
|
|
20
20
|
*/
|
|
21
21
|
getContext?: RouterInit["getContext"];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.2
|
|
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;
|
|
@@ -126,7 +126,9 @@ function HydratedRouter(props) {
|
|
|
126
126
|
}
|
|
127
127
|
let [criticalCss, setCriticalCss] = React$1.useState(process.env.NODE_ENV === "development" ? ssrInfo?.context.criticalCss : void 0);
|
|
128
128
|
React$1.useEffect(() => {
|
|
129
|
-
if (process.env.NODE_ENV === "development")
|
|
129
|
+
if (process.env.NODE_ENV === "development") React$1.startTransition(() => {
|
|
130
|
+
setCriticalCss(void 0);
|
|
131
|
+
});
|
|
130
132
|
}, []);
|
|
131
133
|
React$1.useEffect(() => {
|
|
132
134
|
if (process.env.NODE_ENV === "development" && criticalCss === void 0) document.querySelectorAll(`[${CRITICAL_CSS_DATA_ATTRIBUTE}]`).forEach((element) => element.remove());
|
|
@@ -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.2
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
import { createPath, invariant, parsePath, warning } from "./router/history.js";
|
|
12
|
-
import { convertRouteMatchToUiMatch, decodePath, getResolveToMatches, getRoutePattern, isBrowser, isRouteErrorResponse, joinPaths, matchPath, matchRoutes, parseToInfo, resolveTo, stripBasename } from "./router/utils.js";
|
|
13
12
|
import { getNavigatorCurrentUrl, validateNavigationTarget } from "./router/navigation.js";
|
|
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
15
|
import { AwaitContext, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, IsDataRouteContext, LocationContext, NavigationContext, RSCRouterContext, RouteContext, RouteErrorContext, RouteIdContext } from "./context.js";
|
|
16
16
|
import { decodeRedirectErrorDigest, decodeRouteErrorResponseDigest } from "./errors.js";
|
|
@@ -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
|
*
|
|
@@ -1095,7 +1092,8 @@ function useRouteError() {
|
|
|
1095
1092
|
* @returns The resolved value from the nearest {@link Await} component
|
|
1096
1093
|
*/
|
|
1097
1094
|
function useAsyncValue() {
|
|
1098
|
-
|
|
1095
|
+
let value = React$1.useContext(AwaitContext);
|
|
1096
|
+
return value && "status" in value && !("_tracked" in value) ? value.status === "fulfilled" ? value.value : void 0 : value?._data;
|
|
1099
1097
|
}
|
|
1100
1098
|
/**
|
|
1101
1099
|
* Returns the rejection value from the closest {@link Await | `<Await>`}.
|
|
@@ -1123,7 +1121,8 @@ function useAsyncValue() {
|
|
|
1123
1121
|
* @returns The error that was thrown in the nearest {@link Await} component
|
|
1124
1122
|
*/
|
|
1125
1123
|
function useAsyncError() {
|
|
1126
|
-
|
|
1124
|
+
let value = React$1.useContext(AwaitContext);
|
|
1125
|
+
return value && "status" in value && !("_tracked" in value) ? value.status === "rejected" ? value.reason : void 0 : value?._error;
|
|
1127
1126
|
}
|
|
1128
1127
|
let blockerId = 0;
|
|
1129
1128
|
/**
|
|
@@ -1255,13 +1254,18 @@ function useBlocker(shouldBlock) {
|
|
|
1255
1254
|
historyAction
|
|
1256
1255
|
});
|
|
1257
1256
|
}, [basename, shouldBlock]);
|
|
1257
|
+
let activeBlockerKey = React$1.useRef("");
|
|
1258
1258
|
React$1.useEffect(() => {
|
|
1259
1259
|
let key = String(++blockerId);
|
|
1260
|
+
activeBlockerKey.current = key;
|
|
1260
1261
|
setBlockerKey(key);
|
|
1261
|
-
return () =>
|
|
1262
|
+
return () => {
|
|
1263
|
+
activeBlockerKey.current = "";
|
|
1264
|
+
router.deleteBlocker(key);
|
|
1265
|
+
};
|
|
1262
1266
|
}, [router]);
|
|
1263
1267
|
React$1.useEffect(() => {
|
|
1264
|
-
if (blockerKey !== "") router.getBlocker(blockerKey, blockerFunction);
|
|
1268
|
+
if (blockerKey !== "" && blockerKey === activeBlockerKey.current) router.getBlocker(blockerKey, blockerFunction);
|
|
1265
1269
|
}, [
|
|
1266
1270
|
router,
|
|
1267
1271
|
blockerKey,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.2
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -44,14 +44,14 @@ function href(path, ...args) {
|
|
|
44
44
|
let result = trimTrailingSplat(path).replace(/\/:([\w-]+)(\?)?/g, (_, param, questionMark) => {
|
|
45
45
|
const isRequired = questionMark === void 0;
|
|
46
46
|
const value = params?.[param];
|
|
47
|
-
if (isRequired && value
|
|
47
|
+
if (isRequired && value == null) throw new Error(`Path '${path}' requires param '${param}' but it was not provided`);
|
|
48
48
|
return value == null ? "" : "/" + encodePathParam(stringify(value));
|
|
49
49
|
});
|
|
50
50
|
if (path.endsWith("*")) {
|
|
51
51
|
const value = params?.["*"];
|
|
52
|
-
if (value
|
|
52
|
+
if (value != null) result += "/" + stringify(value).split("/").map(encodePathParam).join("/");
|
|
53
53
|
}
|
|
54
|
-
return result || "/";
|
|
54
|
+
return result.replace(/^\/{2,}/, "/") || "/";
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* Removes a trailing splat and any number of slashes from the end of the path.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.5.
|
|
2
|
+
* react-router v8.5.2
|
|
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);
|