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
|
*
|
|
@@ -33,7 +33,8 @@ function createCookieSessionStorage({ cookie: cookieArg } = {}) {
|
|
|
33
33
|
warnOnceAboutSigningSessionCookie(cookie);
|
|
34
34
|
return {
|
|
35
35
|
async getSession(cookieHeader, options) {
|
|
36
|
-
|
|
36
|
+
let data = cookieHeader && await cookie.parse(cookieHeader, options);
|
|
37
|
+
return createSession(typeof data === "object" && data !== null && !Array.isArray(data) ? data : {});
|
|
37
38
|
},
|
|
38
39
|
async commitSession(session, options) {
|
|
39
40
|
let serializedCookie = await cookie.serialize(session.data, options);
|
|
@@ -50,7 +50,7 @@ interface Session<Data = SessionData, FlashData = Data> {
|
|
|
50
50
|
/**
|
|
51
51
|
* Removes a value from the session.
|
|
52
52
|
*/
|
|
53
|
-
unset(name: keyof Data & string): void;
|
|
53
|
+
unset(name: (keyof Data | keyof FlashData) & string): void;
|
|
54
54
|
}
|
|
55
55
|
type FlashSessionData<Data, FlashData> = Partial<Data & { [Key in keyof FlashData as FlashDataKey<Key & string>]: FlashData[Key] }>;
|
|
56
56
|
type FlashDataKey<Key extends string> = `__flash_${Key}__`;
|
|
@@ -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
|
*
|
|
@@ -55,6 +55,7 @@ const createSession = (initialData = {}, id = "") => {
|
|
|
55
55
|
},
|
|
56
56
|
unset(name) {
|
|
57
57
|
map.delete(name);
|
|
58
|
+
map.delete(flash(name));
|
|
58
59
|
}
|
|
59
60
|
};
|
|
60
61
|
};
|
|
@@ -88,8 +89,9 @@ function createSessionStorage({ cookie: cookieArg, createData, readData, updateD
|
|
|
88
89
|
warnOnceAboutSigningSessionCookie(cookie);
|
|
89
90
|
return {
|
|
90
91
|
async getSession(cookieHeader, options) {
|
|
91
|
-
let
|
|
92
|
-
|
|
92
|
+
let parsedId = cookieHeader && await cookie.parse(cookieHeader, options);
|
|
93
|
+
let id = typeof parsedId === "string" && parsedId ? parsedId : "";
|
|
94
|
+
return createSession((id ? await readData(id) : null) || {}, id);
|
|
93
95
|
},
|
|
94
96
|
async commitSession(session, options) {
|
|
95
97
|
let { id, data } = session;
|
|
@@ -14,24 +14,31 @@ type Props = {
|
|
|
14
14
|
loaderData: unknown;
|
|
15
15
|
actionData: unknown;
|
|
16
16
|
};
|
|
17
|
-
type
|
|
17
|
+
type MatchInfo = {
|
|
18
|
+
id: string;
|
|
18
19
|
module: RouteModule;
|
|
19
|
-
matches: Array<MatchInfo>;
|
|
20
20
|
};
|
|
21
|
-
type
|
|
21
|
+
type MatchInfoWithLoaderData = {
|
|
22
22
|
id: string;
|
|
23
|
+
module?: never;
|
|
24
|
+
loaderData: unknown;
|
|
25
|
+
};
|
|
26
|
+
type AnyMatchInfo = MatchInfo | MatchInfoWithLoaderData;
|
|
27
|
+
type RouteInfo = Props & {
|
|
23
28
|
module: RouteModule;
|
|
29
|
+
matches: Array<AnyMatchInfo>;
|
|
24
30
|
};
|
|
25
|
-
type
|
|
31
|
+
type MatchData<T extends AnyMatchInfo> = T extends MatchInfo ? GetLoaderData<T["module"]> : T extends MatchInfoWithLoaderData ? T["loaderData"] : never;
|
|
32
|
+
type MetaMatch<T extends AnyMatchInfo> = Pretty<{
|
|
26
33
|
id: T["id"];
|
|
27
34
|
params: Record<string, string | undefined>;
|
|
28
35
|
pathname: string;
|
|
29
36
|
meta: MetaDescriptor[];
|
|
30
|
-
loaderData:
|
|
37
|
+
loaderData: MatchData<T>;
|
|
31
38
|
handle?: unknown;
|
|
32
39
|
error?: unknown;
|
|
33
40
|
}>;
|
|
34
|
-
type MetaMatches<T extends Array<
|
|
41
|
+
type MetaMatches<T extends Array<AnyMatchInfo>> = T extends [infer F extends AnyMatchInfo, ...infer R extends Array<AnyMatchInfo>] ? [MetaMatch<F>, ...MetaMatches<R>] : T extends [] ? [] : Array<MetaMatch<AnyMatchInfo> | undefined>;
|
|
35
42
|
type HasErrorBoundary<T extends RouteInfo> = T["module"] extends {
|
|
36
43
|
ErrorBoundary: Func;
|
|
37
44
|
} ? true : false;
|
|
@@ -68,14 +75,14 @@ type CreateHydrateFallbackProps<T extends RouteInfo, RSCEnabled extends boolean>
|
|
|
68
75
|
/** The data returned from the `loader` or `clientLoader` */loaderData?: T["loaderData"]; /** The data returned from the `action` or `clientAction` following an action submission. */
|
|
69
76
|
actionData?: T["actionData"];
|
|
70
77
|
});
|
|
71
|
-
type Match<T extends
|
|
78
|
+
type Match<T extends AnyMatchInfo> = Pretty<{
|
|
72
79
|
id: T["id"];
|
|
73
80
|
params: Record<string, string | undefined>;
|
|
74
81
|
pathname: string;
|
|
75
|
-
loaderData:
|
|
82
|
+
loaderData: MatchData<T>;
|
|
76
83
|
handle: unknown;
|
|
77
84
|
}>;
|
|
78
|
-
type Matches<T extends Array<
|
|
85
|
+
type Matches<T extends Array<AnyMatchInfo>> = T extends [infer F extends AnyMatchInfo, ...infer R extends Array<AnyMatchInfo>] ? [Match<F>, ...Matches<R>] : Array<Match<AnyMatchInfo> | undefined>;
|
|
79
86
|
type CreateComponentProps<T extends RouteInfo, RSCEnabled extends boolean> = {
|
|
80
87
|
/**
|
|
81
88
|
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
|
@@ -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,13 +9,12 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
import "../../lib/router/utils.js";
|
|
12
|
-
import {
|
|
12
|
+
import { createLineSplittingTransform } from "./utils.js";
|
|
13
13
|
import { flatten } from "./flatten.js";
|
|
14
14
|
import { unflatten } from "./unflatten.js";
|
|
15
15
|
//#region vendor/turbo-stream-v2/turbo-stream.ts
|
|
16
16
|
async function decode(readable, options) {
|
|
17
17
|
const { plugins } = options ?? {};
|
|
18
|
-
const done = new Deferred();
|
|
19
18
|
const reader = readable.pipeThrough(createLineSplittingTransform()).getReader();
|
|
20
19
|
const decoder = {
|
|
21
20
|
values: [],
|
|
@@ -24,14 +23,16 @@ async function decode(readable, options) {
|
|
|
24
23
|
plugins
|
|
25
24
|
};
|
|
26
25
|
const decoded = await decodeInitial.call(decoder, reader);
|
|
27
|
-
let donePromise
|
|
28
|
-
if (decoded.done)
|
|
29
|
-
else donePromise = decodeDeferred.call(decoder, reader).
|
|
26
|
+
let donePromise;
|
|
27
|
+
if (decoded.done) donePromise = Promise.resolve();
|
|
28
|
+
else donePromise = decodeDeferred.call(decoder, reader).catch((reason) => {
|
|
30
29
|
for (const deferred of Object.values(decoder.deferred)) deferred.reject(reason);
|
|
31
|
-
|
|
30
|
+
throw reason;
|
|
32
31
|
});
|
|
32
|
+
const finished = donePromise.then(() => reader.closed);
|
|
33
|
+
finished.catch(() => {});
|
|
33
34
|
return {
|
|
34
|
-
done:
|
|
35
|
+
done: finished,
|
|
35
36
|
value: decoded.value
|
|
36
37
|
};
|
|
37
38
|
}
|
|
@@ -2504,7 +2504,8 @@ type RouteDiscovery = {
|
|
|
2504
2504
|
* @param opts.clientVersion A version derived from the client build output used
|
|
2505
2505
|
* to detect stale clients during lazy route discovery.
|
|
2506
2506
|
* @param opts.onError An optional error handler that will be called with any
|
|
2507
|
-
* errors that occur during the request processing.
|
|
2507
|
+
* errors that occur during the request processing. Defaults to logging errors
|
|
2508
|
+
* with `console.error` unless the request was aborted.
|
|
2508
2509
|
* @param opts.request The [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
2509
2510
|
* to match against.
|
|
2510
2511
|
* @param opts.requestContext An instance of {@link RouterContextProvider}
|
|
@@ -2737,7 +2738,7 @@ interface Session<Data = SessionData, FlashData = Data> {
|
|
|
2737
2738
|
/**
|
|
2738
2739
|
* Removes a value from the session.
|
|
2739
2740
|
*/
|
|
2740
|
-
unset(name: keyof Data & string): void;
|
|
2741
|
+
unset(name: (keyof Data | keyof FlashData) & string): void;
|
|
2741
2742
|
}
|
|
2742
2743
|
type FlashSessionData<Data, FlashData> = Partial<Data & { [Key in keyof FlashData as FlashDataKey<Key & string>]: FlashData[Key] }>;
|
|
2743
2744
|
type FlashDataKey<Key extends string> = `__flash_${Key}__`;
|
|
@@ -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
|
*
|
|
@@ -521,10 +521,13 @@ const PATH_PARAM_OVERESCAPED = {
|
|
|
521
521
|
function encodePathParam(value) {
|
|
522
522
|
return encodeURIComponent(value).replace(/%(?:24|26|2B|2C|3A|3B|3D|40)/g, (match) => PATH_PARAM_OVERESCAPED[match]);
|
|
523
523
|
}
|
|
524
|
+
const MAX_OPTIONAL_PATH_SEGMENTS = 12;
|
|
524
525
|
/**
|
|
525
526
|
* Performs pattern matching on a URL pathname and returns information about
|
|
526
527
|
* the match.
|
|
527
528
|
*
|
|
529
|
+
* Throws if the pattern contains more than 12 optional (`?`) markers.
|
|
530
|
+
*
|
|
528
531
|
* @public
|
|
529
532
|
* @category Utils
|
|
530
533
|
* @param pattern The pattern to match against the URL pathname. This can be a
|
|
@@ -541,7 +544,10 @@ function matchPath(pattern, pathname) {
|
|
|
541
544
|
caseSensitive: false,
|
|
542
545
|
end: true
|
|
543
546
|
};
|
|
544
|
-
let
|
|
547
|
+
let { path } = pattern;
|
|
548
|
+
let optionalSegments = 0;
|
|
549
|
+
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.`);
|
|
550
|
+
let [matcher, compiledParams] = compilePath(path, pattern.caseSensitive, pattern.end);
|
|
545
551
|
return matchPathImpl(pattern, pathname, matcher, compiledParams);
|
|
546
552
|
}
|
|
547
553
|
function matchPathImpl(pattern, pathname, matcher, compiledParams) {
|
|
@@ -2495,7 +2501,8 @@ const Await = (async (props) => {
|
|
|
2495
2501
|
* @param opts.clientVersion A version derived from the client build output used
|
|
2496
2502
|
* to detect stale clients during lazy route discovery.
|
|
2497
2503
|
* @param opts.onError An optional error handler that will be called with any
|
|
2498
|
-
* errors that occur during the request processing.
|
|
2504
|
+
* errors that occur during the request processing. Defaults to logging errors
|
|
2505
|
+
* with `console.error` unless the request was aborted.
|
|
2499
2506
|
* @param opts.request The [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
2500
2507
|
* to match against.
|
|
2501
2508
|
* @param opts.requestContext An instance of {@link RouterContextProvider}
|
|
@@ -2514,6 +2521,9 @@ async function matchRSCServerRequest({ allowedActionOrigins, createTemporaryRefe
|
|
|
2514
2521
|
return response;
|
|
2515
2522
|
};
|
|
2516
2523
|
let url = new URL(request.url);
|
|
2524
|
+
onError ??= (error) => {
|
|
2525
|
+
if (!request.signal.aborted) console.error(isRouteErrorResponse(error) && error.error ? error.error : error);
|
|
2526
|
+
};
|
|
2517
2527
|
basename = basename || "/";
|
|
2518
2528
|
let normalizedPath = url.pathname;
|
|
2519
2529
|
if (url.pathname.endsWith("/_.rsc")) normalizedPath = url.pathname.replace(/_\.rsc$/, "");
|
|
@@ -2712,11 +2722,18 @@ function tagResourceResponse(response) {
|
|
|
2712
2722
|
});
|
|
2713
2723
|
}
|
|
2714
2724
|
async function generateRenderResponse(request, staticHandler, basename, isDataRequest, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, generateResponse, temporaryReferences, allowedActionOrigins, routeDiscovery, clientVersion) {
|
|
2725
|
+
if (isMutationMethod(request.method)) try {
|
|
2726
|
+
throwIfPotentialCSRFAttack(request, allowedActionOrigins);
|
|
2727
|
+
} catch (error) {
|
|
2728
|
+
onError?.(error);
|
|
2729
|
+
return tagResourceResponse(new Response("Bad Request", { status: 400 }));
|
|
2730
|
+
}
|
|
2715
2731
|
let statusCode = 200;
|
|
2716
2732
|
let url = new URL(request.url);
|
|
2717
2733
|
let isSubmission = isMutationMethod(request.method);
|
|
2718
2734
|
let routeIdsToLoad = !isSubmission && url.searchParams.has("_routes") ? url.searchParams.get("_routes").split(",") : null;
|
|
2719
2735
|
let actionResult;
|
|
2736
|
+
let handledSubmission = false;
|
|
2720
2737
|
const ctx = {
|
|
2721
2738
|
request,
|
|
2722
2739
|
runningAction: false
|
|
@@ -2730,39 +2747,24 @@ async function generateRenderResponse(request, staticHandler, basename, isDataRe
|
|
|
2730
2747
|
async generateMiddlewareResponse(query) {
|
|
2731
2748
|
let formState;
|
|
2732
2749
|
let skipRevalidation = false;
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
}
|
|
2746
|
-
if (!potentialCSRFAttackError) {
|
|
2747
|
-
ctx.runningAction = true;
|
|
2748
|
-
let result = await processServerAction(request, basename, decodeReply, loadServerAction, decodeAction, decodeFormState, onError, temporaryReferences).finally(() => {
|
|
2749
|
-
ctx.runningAction = false;
|
|
2750
|
-
});
|
|
2751
|
-
if (isResponse(result)) return generateRedirectResponse(result, actionResult, basename, isDataRequest, generateResponse, temporaryReferences, result === ctx.redirect ? void 0 : ctx.redirect?.headers);
|
|
2752
|
-
skipRevalidation = result?.skipRevalidation ?? false;
|
|
2753
|
-
actionResult = result?.actionResult;
|
|
2754
|
-
formState = result?.formState;
|
|
2755
|
-
request = result?.revalidationRequest ?? request;
|
|
2756
|
-
if (ctx.redirect) return generateRedirectResponse(ctx.redirect, actionResult, basename, isDataRequest, generateResponse, temporaryReferences, void 0);
|
|
2757
|
-
}
|
|
2750
|
+
if (isSubmission && !handledSubmission) {
|
|
2751
|
+
handledSubmission = true;
|
|
2752
|
+
ctx.runningAction = true;
|
|
2753
|
+
let result = await processServerAction(request, basename, decodeReply, loadServerAction, decodeAction, decodeFormState, onError, temporaryReferences).finally(() => {
|
|
2754
|
+
ctx.runningAction = false;
|
|
2755
|
+
});
|
|
2756
|
+
if (isResponse(result)) return generateRedirectResponse(result, actionResult, basename, isDataRequest, generateResponse, temporaryReferences, result === ctx.redirect ? void 0 : ctx.redirect?.headers);
|
|
2757
|
+
skipRevalidation = result?.skipRevalidation ?? false;
|
|
2758
|
+
actionResult = result?.actionResult;
|
|
2759
|
+
formState = result?.formState;
|
|
2760
|
+
request = result?.revalidationRequest ?? request;
|
|
2761
|
+
if (ctx.redirect) return generateRedirectResponse(ctx.redirect, actionResult, basename, isDataRequest, generateResponse, temporaryReferences, void 0);
|
|
2758
2762
|
}
|
|
2759
2763
|
let staticContext = await query(request, skipRevalidation ? { filterMatchesToLoad: () => false } : void 0);
|
|
2760
2764
|
if (isResponse(staticContext)) return generateRedirectResponse(staticContext, actionResult, basename, isDataRequest, generateResponse, temporaryReferences, ctx.redirect?.headers);
|
|
2761
|
-
if (
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
staticContext.statusCode = 400;
|
|
2765
|
-
}
|
|
2765
|
+
if (staticContext.errors) Object.values(staticContext.errors).forEach((error) => {
|
|
2766
|
+
if (!isRouteErrorResponse(error) || error.error) onError?.(error);
|
|
2767
|
+
});
|
|
2766
2768
|
return generateStaticContextResponse(staticHandler, basename, generateResponse, statusCode, routeIdsToLoad, isDataRequest, isSubmission, actionResult, formState, staticContext, temporaryReferences, skipRevalidation, ctx.redirect?.headers, routeDiscovery, clientVersion);
|
|
2767
2769
|
}
|
|
2768
2770
|
}));
|
|
@@ -3284,6 +3286,7 @@ const createSession = (initialData = {}, id = "") => {
|
|
|
3284
3286
|
},
|
|
3285
3287
|
unset(name) {
|
|
3286
3288
|
map.delete(name);
|
|
3289
|
+
map.delete(flash(name));
|
|
3287
3290
|
}
|
|
3288
3291
|
};
|
|
3289
3292
|
};
|
|
@@ -3317,8 +3320,9 @@ function createSessionStorage({ cookie: cookieArg, createData, readData, updateD
|
|
|
3317
3320
|
warnOnceAboutSigningSessionCookie(cookie);
|
|
3318
3321
|
return {
|
|
3319
3322
|
async getSession(cookieHeader, options) {
|
|
3320
|
-
let
|
|
3321
|
-
|
|
3323
|
+
let parsedId = cookieHeader && await cookie.parse(cookieHeader, options);
|
|
3324
|
+
let id = typeof parsedId === "string" && parsedId ? parsedId : "";
|
|
3325
|
+
return createSession((id ? await readData(id) : null) || {}, id);
|
|
3322
3326
|
},
|
|
3323
3327
|
async commitSession(session, options) {
|
|
3324
3328
|
let { id, data } = session;
|
|
@@ -3364,7 +3368,8 @@ function createCookieSessionStorage({ cookie: cookieArg } = {}) {
|
|
|
3364
3368
|
warnOnceAboutSigningSessionCookie(cookie);
|
|
3365
3369
|
return {
|
|
3366
3370
|
async getSession(cookieHeader, options) {
|
|
3367
|
-
|
|
3371
|
+
let data = cookieHeader && await cookie.parse(cookieHeader, options);
|
|
3372
|
+
return createSession(typeof data === "object" && data !== null && !Array.isArray(data) ? data : {});
|
|
3368
3373
|
},
|
|
3369
3374
|
async commitSession(session, options) {
|
|
3370
3375
|
let serializedCookie = await cookie.serialize(session.data, options);
|
package/dist/production/index.js
CHANGED
|
@@ -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
|
*
|
|
@@ -284,13 +284,14 @@ function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, use
|
|
|
284
284
|
encodeLocation: router.encodeLocation,
|
|
285
285
|
go: (n) => router.navigate(n),
|
|
286
286
|
push: (to, state, opts) => router.navigate(to, {
|
|
287
|
-
|
|
288
|
-
|
|
287
|
+
...opts,
|
|
288
|
+
replace: opts?.replace === false ? false : void 0,
|
|
289
|
+
state: state !== void 0 ? state : opts?.state
|
|
289
290
|
}),
|
|
290
291
|
replace: (to, state, opts) => router.navigate(to, {
|
|
292
|
+
...opts,
|
|
291
293
|
replace: true,
|
|
292
|
-
state
|
|
293
|
-
preventScrollReset: opts?.preventScrollReset
|
|
294
|
+
state: state !== void 0 ? state : opts?.state
|
|
294
295
|
})
|
|
295
296
|
};
|
|
296
297
|
}, [router]);
|
|
@@ -343,6 +344,7 @@ function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, use
|
|
|
343
344
|
fetchers: state.fetchers,
|
|
344
345
|
fetcherData: fetcherData.current
|
|
345
346
|
}), [state.fetchers]);
|
|
347
|
+
let discoveryRuntime = React$1.useContext(FrameworkContext)?.routeDiscoveryRuntime;
|
|
346
348
|
return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, /* @__PURE__ */ React$1.createElement(DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React$1.createElement(DataRouterStateContext.Provider, { value: dataRouterState }, /* @__PURE__ */ React$1.createElement(DataRouterNavigationContext.Provider, { value: dataRouterNavigation }, /* @__PURE__ */ React$1.createElement(DataRouterDataContext.Provider, { value: dataRouterData }, /* @__PURE__ */ React$1.createElement(FetchersContext.Provider, { value: fetchersContext }, /* @__PURE__ */ React$1.createElement(ViewTransitionContext.Provider, { value: vtContext }, /* @__PURE__ */ React$1.createElement(Router, {
|
|
347
349
|
basename,
|
|
348
350
|
location: state.location,
|
|
@@ -354,7 +356,8 @@ function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, use
|
|
|
354
356
|
manifest: router.manifest,
|
|
355
357
|
state,
|
|
356
358
|
isStatic: false,
|
|
357
|
-
onError
|
|
359
|
+
onError,
|
|
360
|
+
discoveryRuntime
|
|
358
361
|
})))))))), null);
|
|
359
362
|
}
|
|
360
363
|
function getOptimisticRouterState(currentState, newState) {
|
|
@@ -367,10 +370,9 @@ function getOptimisticRouterState(currentState, newState) {
|
|
|
367
370
|
};
|
|
368
371
|
}
|
|
369
372
|
const MemoizedDataRoutes = React$1.memo(DataRoutes);
|
|
370
|
-
function DataRoutes({ routes, manifest, state, isStatic, onError }) {
|
|
373
|
+
function DataRoutes({ routes, manifest, state, isStatic, onError, discoveryRuntime }) {
|
|
371
374
|
let dataRouterContext = React$1.useContext(DataRouterContext);
|
|
372
375
|
invariant(dataRouterContext, "You must render this element inside a <DataRouterContext.Provider> element");
|
|
373
|
-
let discoveryRuntime = React$1.useContext(FrameworkContext)?.routeDiscoveryRuntime;
|
|
374
376
|
React$1.useEffect(() => {
|
|
375
377
|
if (state.initialized) discoveryRuntime?.markReady();
|
|
376
378
|
}, [state.initialized, discoveryRuntime]);
|
|
@@ -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
|
*
|
|
@@ -19,6 +19,7 @@ DataRouterDataContext.displayName = "DataRouterData";
|
|
|
19
19
|
const DataRouterNavigationContext = React$1.createContext(null);
|
|
20
20
|
DataRouterNavigationContext.displayName = "DataRouterNavigation";
|
|
21
21
|
const RSCRouterContext = React$1.createContext(false);
|
|
22
|
+
const RSCErrorAlreadyReportedContext = React$1.createContext(false);
|
|
22
23
|
function useIsRSCRouterContext() {
|
|
23
24
|
return React$1.useContext(RSCRouterContext);
|
|
24
25
|
}
|
|
@@ -46,4 +47,4 @@ RouteIdContext.displayName = "RouteId";
|
|
|
46
47
|
const RouteErrorContext = React$1.createContext(null);
|
|
47
48
|
RouteErrorContext.displayName = "RouteError";
|
|
48
49
|
//#endregion
|
|
49
|
-
export { AwaitContext, AwaitContextProvider, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, IsDataRouteContext, LocationContext, NavigationContext, RSCRouterContext, RouteContext, RouteErrorContext, RouteIdContext, ViewTransitionContext, useIsRSCRouterContext };
|
|
50
|
+
export { AwaitContext, AwaitContextProvider, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, IsDataRouteContext, LocationContext, NavigationContext, RSCErrorAlreadyReportedContext, RSCRouterContext, RouteContext, RouteErrorContext, RouteIdContext, ViewTransitionContext, useIsRSCRouterContext };
|
|
@@ -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
|
*
|
|
@@ -27,7 +27,8 @@ function isModifiedEvent(event) {
|
|
|
27
27
|
return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
|
|
28
28
|
}
|
|
29
29
|
function shouldProcessLinkClick(event, target) {
|
|
30
|
-
|
|
30
|
+
let element = event.currentTarget;
|
|
31
|
+
return event.button === 0 && (!target || target === "_self") && !isModifiedEvent(event) && !((element?.localName === "a" || element?.localName === "area") && element.hasAttribute("href") && element.hasAttribute("download"));
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
34
|
* Creates a URLSearchParams object using the given initializer.
|
|
@@ -86,6 +87,7 @@ const supportedFormEncTypes = new Set([
|
|
|
86
87
|
"text/plain"
|
|
87
88
|
]);
|
|
88
89
|
function getFormEncType(encType) {
|
|
90
|
+
encType = encType?.toLowerCase() ?? null;
|
|
89
91
|
if (encType != null && !supportedFormEncTypes.has(encType)) {
|
|
90
92
|
warning(false, `"${encType}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${defaultEncType}"`);
|
|
91
93
|
return 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
|
*
|
|
@@ -329,6 +329,8 @@ const Link = React$1.forwardRef(function LinkWithRef({ onClick, discover = "rend
|
|
|
329
329
|
return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, link, /* @__PURE__ */ React$1.createElement(PrefetchPageLinks, { page: href })) : link;
|
|
330
330
|
});
|
|
331
331
|
Link.displayName = "Link";
|
|
332
|
+
const subscribeToNothing = () => () => {};
|
|
333
|
+
const getClientSpaFallback = () => false;
|
|
332
334
|
/**
|
|
333
335
|
* Wraps {@link Link | `<Link>`} with additional props for styling active and
|
|
334
336
|
* pending states.
|
|
@@ -377,7 +379,9 @@ const NavLink = React$1.forwardRef(function NavLinkWithRef({ "aria-current": ari
|
|
|
377
379
|
let location = useLocation();
|
|
378
380
|
let routerNavigation = React$1.useContext(DataRouterNavigationContext);
|
|
379
381
|
let { navigator, basename } = React$1.useContext(NavigationContext);
|
|
380
|
-
let
|
|
382
|
+
let isSpaMode = React$1.useContext(FrameworkContext)?.isSpaMode === true;
|
|
383
|
+
let isSpaFallback = React$1.useSyncExternalStore(subscribeToNothing, getClientSpaFallback, () => isSpaMode);
|
|
384
|
+
let isTransitioning = routerNavigation != null && useViewTransitionState(path) && viewTransition === true && !isSpaFallback;
|
|
381
385
|
let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
|
|
382
386
|
let locationPathname = location.pathname;
|
|
383
387
|
let nextLocationPathname = routerNavigation?.navigation.location ? routerNavigation.navigation.location.pathname : null;
|
|
@@ -388,8 +392,8 @@ const NavLink = React$1.forwardRef(function NavLinkWithRef({ "aria-current": ari
|
|
|
388
392
|
}
|
|
389
393
|
if (nextLocationPathname && basename) nextLocationPathname = stripBasename(nextLocationPathname, basename) || nextLocationPathname;
|
|
390
394
|
const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
|
|
391
|
-
let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
|
|
392
|
-
let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(endSlashPosition) === "/");
|
|
395
|
+
let isActive = !isSpaFallback && (locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/");
|
|
396
|
+
let isPending = !isSpaFallback && nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(endSlashPosition) === "/");
|
|
393
397
|
let renderProps = {
|
|
394
398
|
isActive,
|
|
395
399
|
isPending,
|
|
@@ -1108,7 +1112,10 @@ function useScrollRestoration({ getKey, storageKey } = {}) {
|
|
|
1108
1112
|
React$1.useLayoutEffect(() => {
|
|
1109
1113
|
try {
|
|
1110
1114
|
let sessionPositions = sessionStorage.getItem(storageKey || SCROLL_RESTORATION_STORAGE_KEY);
|
|
1111
|
-
if (sessionPositions)
|
|
1115
|
+
if (sessionPositions) {
|
|
1116
|
+
let parsedPositions = JSON.parse(sessionPositions);
|
|
1117
|
+
savedScrollPositions = parsedPositions && typeof parsedPositions === "object" && !Array.isArray(parsedPositions) ? parsedPositions : {};
|
|
1118
|
+
}
|
|
1112
1119
|
} catch {}
|
|
1113
1120
|
}, [storageKey]);
|
|
1114
1121
|
React$1.useLayoutEffect(() => {
|
|
@@ -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
|
*
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
11
|
+
import { PROTOCOL_RELATIVE_URL_REGEX } from "../router/url.js";
|
|
12
12
|
import { createPath, invariant, parsePath, warning } from "../router/history.js";
|
|
13
13
|
import { convertRoutesToDataRoutes, isRouteErrorResponse } from "../router/utils.js";
|
|
14
14
|
import { IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION } from "../router/router.js";
|
|
@@ -314,9 +314,11 @@ function createHref(to) {
|
|
|
314
314
|
return typeof to === "string" ? to : createPath(to);
|
|
315
315
|
}
|
|
316
316
|
function encodeLocation(to) {
|
|
317
|
+
let base = "http://localhost";
|
|
317
318
|
let href = typeof to === "string" ? to : createPath(to);
|
|
318
319
|
href = href.replace(/ $/, "%20");
|
|
319
|
-
|
|
320
|
+
if (PROTOCOL_RELATIVE_URL_REGEX.test(href)) href = base + href;
|
|
321
|
+
let encoded = new URL(href, base);
|
|
320
322
|
return {
|
|
321
323
|
pathname: encoded.pathname,
|
|
322
324
|
search: encoded.search,
|