react-router 8.2.0 → 8.3.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 +78 -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 +114 -17
- package/dist/development/index-react-server.js +189 -54
- package/dist/development/index.js +1 -1
- package/dist/development/lib/actions.js +10 -5
- package/dist/development/lib/components.js +6 -3
- package/dist/development/lib/context.d.ts +1 -0
- package/dist/development/lib/context.js +1 -1
- package/dist/development/lib/dom/dom.d.ts +24 -24
- package/dist/development/lib/dom/dom.js +26 -26
- package/dist/development/lib/dom/lib.d.ts +2 -1
- package/dist/development/lib/dom/lib.js +23 -7
- package/dist/development/lib/dom/server.js +1 -1
- package/dist/development/lib/dom/ssr/components.js +2 -2
- 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 +27 -21
- 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/routeModules.js +1 -1
- package/dist/development/lib/dom/ssr/routes-test-stub.d.ts +13 -0
- package/dist/development/lib/dom/ssr/routes-test-stub.js +14 -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.js +5 -5
- 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.js +6 -3
- package/dist/development/lib/href.d.ts +24 -8
- package/dist/development/lib/href.js +28 -11
- package/dist/development/lib/router/history.d.ts +6 -0
- package/dist/development/lib/router/history.js +8 -2
- package/dist/development/lib/router/instrumentation.js +1 -1
- package/dist/development/lib/router/navigation.js +45 -0
- package/dist/development/lib/router/router.d.ts +8 -0
- package/dist/development/lib/router/router.js +31 -17
- package/dist/development/lib/router/url.js +1 -1
- package/dist/development/lib/router/utils.d.ts +12 -0
- package/dist/development/lib/router/utils.js +66 -8
- package/dist/development/lib/rsc/browser.js +37 -24
- 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 +30 -11
- package/dist/development/lib/rsc/route-modules.js +1 -1
- package/dist/development/lib/rsc/server.rsc.d.ts +5 -1
- package/dist/development/lib/rsc/server.ssr.d.ts +29 -6
- package/dist/development/lib/rsc/server.ssr.js +28 -13
- package/dist/development/lib/server-runtime/cookies.d.ts +28 -2
- package/dist/development/lib/server-runtime/cookies.js +18 -4
- package/dist/development/lib/server-runtime/crypto.js +2 -2
- package/dist/development/lib/server-runtime/data.js +1 -1
- package/dist/development/lib/server-runtime/dev.js +2 -2
- 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.d.ts +12 -0
- package/dist/development/lib/server-runtime/server.js +14 -2
- package/dist/development/lib/server-runtime/serverHandoff.js +1 -1
- package/dist/development/lib/server-runtime/sessions/cookieStorage.d.ts +8 -0
- package/dist/development/lib/server-runtime/sessions/cookieStorage.js +9 -1
- package/dist/development/lib/server-runtime/sessions/memoryStorage.d.ts +10 -4
- package/dist/development/lib/server-runtime/sessions/memoryStorage.js +12 -6
- package/dist/development/lib/server-runtime/sessions.d.ts +31 -2
- package/dist/development/lib/server-runtime/sessions.js +20 -3
- package/dist/development/lib/server-runtime/single-fetch.js +2 -2
- 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/vendor/turbo-stream-v2/flatten.js +1 -1
- package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +4 -4
- 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 +114 -17
- package/dist/production/index-react-server.js +189 -54
- package/dist/production/index.js +1 -1
- package/dist/production/lib/actions.js +10 -5
- package/dist/production/lib/components.js +6 -3
- package/dist/production/lib/context.d.ts +1 -0
- package/dist/production/lib/context.js +1 -1
- package/dist/production/lib/dom/dom.d.ts +24 -24
- package/dist/production/lib/dom/dom.js +26 -26
- package/dist/production/lib/dom/lib.d.ts +2 -1
- package/dist/production/lib/dom/lib.js +23 -7
- package/dist/production/lib/dom/server.js +1 -1
- package/dist/production/lib/dom/ssr/components.js +2 -2
- 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 +27 -21
- 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/routeModules.js +1 -1
- package/dist/production/lib/dom/ssr/routes-test-stub.d.ts +13 -0
- package/dist/production/lib/dom/ssr/routes-test-stub.js +14 -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.js +5 -5
- 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.js +6 -3
- package/dist/production/lib/href.d.ts +24 -8
- package/dist/production/lib/href.js +28 -11
- package/dist/production/lib/router/history.d.ts +6 -0
- package/dist/production/lib/router/history.js +8 -2
- package/dist/production/lib/router/instrumentation.js +1 -1
- package/dist/production/lib/router/navigation.js +45 -0
- package/dist/production/lib/router/router.d.ts +8 -0
- package/dist/production/lib/router/router.js +31 -17
- package/dist/production/lib/router/url.js +1 -1
- package/dist/production/lib/router/utils.d.ts +12 -0
- package/dist/production/lib/router/utils.js +66 -8
- package/dist/production/lib/rsc/browser.js +37 -24
- 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 +30 -11
- package/dist/production/lib/rsc/route-modules.js +1 -1
- package/dist/production/lib/rsc/server.rsc.d.ts +5 -1
- package/dist/production/lib/rsc/server.ssr.d.ts +29 -6
- package/dist/production/lib/rsc/server.ssr.js +28 -13
- package/dist/production/lib/server-runtime/cookies.d.ts +28 -2
- package/dist/production/lib/server-runtime/cookies.js +18 -4
- package/dist/production/lib/server-runtime/crypto.js +2 -2
- package/dist/production/lib/server-runtime/data.js +1 -1
- package/dist/production/lib/server-runtime/dev.js +2 -2
- 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.d.ts +12 -0
- package/dist/production/lib/server-runtime/server.js +14 -2
- package/dist/production/lib/server-runtime/serverHandoff.js +1 -1
- package/dist/production/lib/server-runtime/sessions/cookieStorage.d.ts +8 -0
- package/dist/production/lib/server-runtime/sessions/cookieStorage.js +9 -1
- package/dist/production/lib/server-runtime/sessions/memoryStorage.d.ts +10 -4
- package/dist/production/lib/server-runtime/sessions/memoryStorage.js +12 -6
- package/dist/production/lib/server-runtime/sessions.d.ts +31 -2
- package/dist/production/lib/server-runtime/sessions.js +20 -3
- package/dist/production/lib/server-runtime/single-fetch.js +2 -2
- 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/vendor/turbo-stream-v2/flatten.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +4 -4
- package/dist/production/vendor/turbo-stream-v2/unflatten.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/utils.js +1 -1
- package/docs/explanation/sessions-and-cookies.md +13 -13
- package/docs/explanation/state-management.md +2 -2
- package/docs/how-to/presets.md +2 -2
- package/docs/how-to/react-server-components.md +53 -1
- package/docs/how-to/security.md +8 -1
- package/docs/how-to/server-bundles.md +2 -2
- package/docs/start/data/route-object.md +2 -2
- package/docs/start/data/routing.md +1 -1
- package/docs/start/framework/pending-ui.md +1 -1
- package/docs/start/framework/route-module.md +8 -8
- package/docs/start/framework/routing.md +1 -1
- package/package.json +1 -1
|
@@ -10,11 +10,17 @@ interface MemorySessionStorageOptions {
|
|
|
10
10
|
cookie?: SessionIdStorageStrategy["cookie"];
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
|
-
* Creates and returns a simple in-memory SessionStorage object
|
|
14
|
-
* for testing and as a reference implementation.
|
|
13
|
+
* Creates and returns a simple in-memory SessionStorage object.
|
|
15
14
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* Intended for local development and testing. It does not scale beyond a single
|
|
16
|
+
* process, and all session data is lost when the server process stops/restarts.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
* @category Utils
|
|
20
|
+
* @mode framework
|
|
21
|
+
* @mode data
|
|
22
|
+
* @param options Options for creating the in-memory session storage.
|
|
23
|
+
* @returns A {@link SessionStorage} object that stores session data in memory.
|
|
18
24
|
*/
|
|
19
25
|
declare function createMemorySessionStorage<Data = SessionData, FlashData = Data>({
|
|
20
26
|
cookie
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.
|
|
2
|
+
* react-router v8.3.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -11,18 +11,24 @@
|
|
|
11
11
|
import { createSessionStorage } from "../sessions.js";
|
|
12
12
|
//#region lib/server-runtime/sessions/memoryStorage.ts
|
|
13
13
|
/**
|
|
14
|
-
* Creates and returns a simple in-memory SessionStorage object
|
|
15
|
-
* for testing and as a reference implementation.
|
|
14
|
+
* Creates and returns a simple in-memory SessionStorage object.
|
|
16
15
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
16
|
+
* Intended for local development and testing. It does not scale beyond a single
|
|
17
|
+
* process, and all session data is lost when the server process stops/restarts.
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
* @category Utils
|
|
21
|
+
* @mode framework
|
|
22
|
+
* @mode data
|
|
23
|
+
* @param options Options for creating the in-memory session storage.
|
|
24
|
+
* @returns A {@link SessionStorage} object that stores session data in memory.
|
|
19
25
|
*/
|
|
20
26
|
function createMemorySessionStorage({ cookie } = {}) {
|
|
21
27
|
let map = /* @__PURE__ */ new Map();
|
|
22
28
|
return createSessionStorage({
|
|
23
29
|
cookie,
|
|
24
30
|
async createData(data, expires) {
|
|
25
|
-
let id =
|
|
31
|
+
let id = crypto.randomUUID();
|
|
26
32
|
map.set(id, {
|
|
27
33
|
data,
|
|
28
34
|
expires
|
|
@@ -60,13 +60,37 @@ type CreateSessionFunction = <Data = SessionData, FlashData = Data>(initialData?
|
|
|
60
60
|
*
|
|
61
61
|
* Note: This function is typically not invoked directly by application code.
|
|
62
62
|
* Instead, use a `SessionStorage` object's `getSession` method.
|
|
63
|
+
*
|
|
64
|
+
* @category Utils
|
|
65
|
+
* @param initialData The initial data for the session.
|
|
66
|
+
* @param id The identifier for the session. Defaults to an empty string for a
|
|
67
|
+
* new session.
|
|
68
|
+
* @returns A new {@link Session} object.
|
|
63
69
|
*/
|
|
64
70
|
declare const createSession: CreateSessionFunction;
|
|
71
|
+
/**
|
|
72
|
+
* A function that determines whether a value is a React Router {@link Session}
|
|
73
|
+
* object.
|
|
74
|
+
*
|
|
75
|
+
* @public
|
|
76
|
+
* @category Utils
|
|
77
|
+
* @mode framework
|
|
78
|
+
* @mode data
|
|
79
|
+
* @param object The value to check.
|
|
80
|
+
* @returns `true` if the value is a React Router {@link Session} object;
|
|
81
|
+
* otherwise, `false`.
|
|
82
|
+
*/
|
|
65
83
|
type IsSessionFunction = (object: any) => object is Session;
|
|
66
84
|
/**
|
|
67
|
-
* Returns true if
|
|
85
|
+
* Returns `true` if a value is a React Router {@link Session} object.
|
|
68
86
|
*
|
|
69
|
-
* @
|
|
87
|
+
* @public
|
|
88
|
+
* @category Utils
|
|
89
|
+
* @mode framework
|
|
90
|
+
* @mode data
|
|
91
|
+
* @param object The value to check.
|
|
92
|
+
* @returns `true` if the value is a React Router {@link Session} object;
|
|
93
|
+
* otherwise, `false`.
|
|
70
94
|
*/
|
|
71
95
|
declare const isSession: IsSessionFunction;
|
|
72
96
|
/**
|
|
@@ -133,6 +157,11 @@ interface SessionIdStorageStrategy<Data = SessionData, FlashData = Data> {
|
|
|
133
157
|
*
|
|
134
158
|
* Note: This is a low-level API that should only be used if none of the
|
|
135
159
|
* existing session storage options meet your requirements.
|
|
160
|
+
*
|
|
161
|
+
* @category Utils
|
|
162
|
+
* @param strategy The strategy used to store session identifiers and data.
|
|
163
|
+
* @returns A {@link SessionStorage} object that persists session data using the
|
|
164
|
+
* provided strategy.
|
|
136
165
|
*/
|
|
137
166
|
declare function createSessionStorage<Data = SessionData, FlashData = Data>({
|
|
138
167
|
cookie: cookieArg,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.
|
|
2
|
+
* react-router v8.3.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -19,6 +19,12 @@ function flash(name) {
|
|
|
19
19
|
*
|
|
20
20
|
* Note: This function is typically not invoked directly by application code.
|
|
21
21
|
* Instead, use a `SessionStorage` object's `getSession` method.
|
|
22
|
+
*
|
|
23
|
+
* @category Utils
|
|
24
|
+
* @param initialData The initial data for the session.
|
|
25
|
+
* @param id The identifier for the session. Defaults to an empty string for a
|
|
26
|
+
* new session.
|
|
27
|
+
* @returns A new {@link Session} object.
|
|
22
28
|
*/
|
|
23
29
|
const createSession = (initialData = {}, id = "") => {
|
|
24
30
|
let map = new Map(Object.entries(initialData));
|
|
@@ -53,9 +59,15 @@ const createSession = (initialData = {}, id = "") => {
|
|
|
53
59
|
};
|
|
54
60
|
};
|
|
55
61
|
/**
|
|
56
|
-
* Returns true if
|
|
62
|
+
* Returns `true` if a value is a React Router {@link Session} object.
|
|
57
63
|
*
|
|
58
|
-
* @
|
|
64
|
+
* @public
|
|
65
|
+
* @category Utils
|
|
66
|
+
* @mode framework
|
|
67
|
+
* @mode data
|
|
68
|
+
* @param object The value to check.
|
|
69
|
+
* @returns `true` if the value is a React Router {@link Session} object;
|
|
70
|
+
* otherwise, `false`.
|
|
59
71
|
*/
|
|
60
72
|
const isSession = (object) => {
|
|
61
73
|
return object != null && typeof object.id === "string" && typeof object.data !== "undefined" && typeof object.has === "function" && typeof object.get === "function" && typeof object.set === "function" && typeof object.flash === "function" && typeof object.unset === "function";
|
|
@@ -65,6 +77,11 @@ const isSession = (object) => {
|
|
|
65
77
|
*
|
|
66
78
|
* Note: This is a low-level API that should only be used if none of the
|
|
67
79
|
* existing session storage options meet your requirements.
|
|
80
|
+
*
|
|
81
|
+
* @category Utils
|
|
82
|
+
* @param strategy The strategy used to store session identifiers and data.
|
|
83
|
+
* @returns A {@link SessionStorage} object that persists session data using the
|
|
84
|
+
* provided strategy.
|
|
68
85
|
*/
|
|
69
86
|
function createSessionStorage({ cookie: cookieArg, createData, readData, updateData, deleteData }) {
|
|
70
87
|
let cookie = isCookie(cookieArg) ? cookieArg : createCookie(cookieArg?.name || "__session", cookieArg);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.
|
|
2
|
+
* react-router v8.3.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -23,7 +23,7 @@ async function singleFetchAction(build, serverMode, staticHandler, request, load
|
|
|
23
23
|
try {
|
|
24
24
|
try {
|
|
25
25
|
throwIfPotentialCSRFAttack(request, Array.isArray(build.allowedActionOrigins) ? build.allowedActionOrigins : []);
|
|
26
|
-
} catch
|
|
26
|
+
} catch {
|
|
27
27
|
return handleQueryError(/* @__PURE__ */ new Error("Bad Request"), 400);
|
|
28
28
|
}
|
|
29
29
|
return handleQueryResult(await staticHandler.query(request, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.
|
|
2
|
+
* react-router v8.3.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -41,7 +41,7 @@ async function decodeInitial(reader) {
|
|
|
41
41
|
let line;
|
|
42
42
|
try {
|
|
43
43
|
line = JSON.parse(read.value);
|
|
44
|
-
} catch
|
|
44
|
+
} catch {
|
|
45
45
|
throw new SyntaxError();
|
|
46
46
|
}
|
|
47
47
|
return {
|
|
@@ -64,7 +64,7 @@ async function decodeDeferred(reader) {
|
|
|
64
64
|
let jsonLine;
|
|
65
65
|
try {
|
|
66
66
|
jsonLine = JSON.parse(lineData);
|
|
67
|
-
} catch
|
|
67
|
+
} catch {
|
|
68
68
|
throw new SyntaxError();
|
|
69
69
|
}
|
|
70
70
|
const value = unflatten.call(this, jsonLine);
|
|
@@ -80,7 +80,7 @@ async function decodeDeferred(reader) {
|
|
|
80
80
|
let jsonLine;
|
|
81
81
|
try {
|
|
82
82
|
jsonLine = JSON.parse(lineData);
|
|
83
|
-
} catch
|
|
83
|
+
} catch {
|
|
84
84
|
throw new SyntaxError();
|
|
85
85
|
}
|
|
86
86
|
const value = unflatten.call(this, jsonLine);
|
|
@@ -1231,6 +1231,14 @@ interface Router$1 {
|
|
|
1231
1231
|
* @param location
|
|
1232
1232
|
*/
|
|
1233
1233
|
createHref(location: Location | URL): string;
|
|
1234
|
+
/**
|
|
1235
|
+
* @private
|
|
1236
|
+
* PRIVATE - DO NOT USE
|
|
1237
|
+
*
|
|
1238
|
+
* Utility function to create a URL for the given location
|
|
1239
|
+
* @param location
|
|
1240
|
+
*/
|
|
1241
|
+
createURL?(to: To): URL;
|
|
1234
1242
|
/**
|
|
1235
1243
|
* @private
|
|
1236
1244
|
* PRIVATE - DO NOT USE
|
|
@@ -2318,13 +2326,13 @@ type RSCRenderPayload = {
|
|
|
2318
2326
|
type: "render";
|
|
2319
2327
|
actionData: Record<string, any> | null;
|
|
2320
2328
|
basename: string | undefined;
|
|
2329
|
+
clientVersion?: string;
|
|
2321
2330
|
errors: Record<string, any> | null;
|
|
2322
2331
|
loaderData: Record<string, any>;
|
|
2323
2332
|
location: Location;
|
|
2324
2333
|
routeDiscovery: RouteDiscovery;
|
|
2325
2334
|
matches: RSCRouteMatch[];
|
|
2326
2335
|
patches?: Promise<RSCRouteManifest[]>;
|
|
2327
|
-
nonce?: string;
|
|
2328
2336
|
formState?: ReactFormState;
|
|
2329
2337
|
};
|
|
2330
2338
|
type RSCManifestPayload = {
|
|
@@ -2421,6 +2429,8 @@ type RouteDiscovery = {
|
|
|
2421
2429
|
* encoding the {@link unstable_RSCPayload}.
|
|
2422
2430
|
* @param opts.loadServerAction Your `react-server-dom-xyz/server`'s
|
|
2423
2431
|
* `loadServerAction` function, used to load a server action by ID.
|
|
2432
|
+
* @param opts.clientVersion A version derived from the client build output used
|
|
2433
|
+
* to detect stale clients during lazy route discovery.
|
|
2424
2434
|
* @param opts.onError An optional error handler that will be called with any
|
|
2425
2435
|
* errors that occur during the request processing.
|
|
2426
2436
|
* @param opts.request The [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
@@ -2444,6 +2454,7 @@ declare function matchRSCServerRequest({
|
|
|
2444
2454
|
loadServerAction,
|
|
2445
2455
|
decodeAction,
|
|
2446
2456
|
decodeFormState,
|
|
2457
|
+
clientVersion,
|
|
2447
2458
|
onError,
|
|
2448
2459
|
request,
|
|
2449
2460
|
routes,
|
|
@@ -2457,6 +2468,7 @@ declare function matchRSCServerRequest({
|
|
|
2457
2468
|
decodeFormState?: DecodeFormStateFunction;
|
|
2458
2469
|
requestContext?: RouterContextProvider;
|
|
2459
2470
|
loadServerAction?: LoadServerActionFunction;
|
|
2471
|
+
clientVersion?: string;
|
|
2460
2472
|
onError?: (error: unknown) => void;
|
|
2461
2473
|
request: Request;
|
|
2462
2474
|
routes: RSCRouteConfigEntry[];
|
|
@@ -2490,14 +2502,30 @@ type Pages = Register extends {
|
|
|
2490
2502
|
type Args = { [K in keyof Pages]: ToArgs<Pages[K]["params"]> };
|
|
2491
2503
|
type ToArgs<Params extends Record<string, string | undefined>> = Equal<Params, {}> extends true ? [] : Partial<Params> extends Params ? [Params] | [] : [Params];
|
|
2492
2504
|
/**
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2505
|
+
* Returns a resolved URL path for the specified route.
|
|
2506
|
+
*
|
|
2507
|
+
* Param values are percent-encoded for use in a path segment: characters that
|
|
2508
|
+
* would change the URL structure (`/`, `?`, `#`, `%`, whitespace, non-ASCII)
|
|
2509
|
+
* are escaped, while characters that RFC 3986 allows literally in a path
|
|
2510
|
+
* segment (`$ & + , ; = : @`) are kept as-is. Note this differs from query-string
|
|
2511
|
+
* encoding (`encodeURIComponent`/`URLSearchParams`), where those characters are
|
|
2512
|
+
* delimiters and must be escaped. Splat (`*`) values are encoded per segment,
|
|
2513
|
+
* preserving `/` separators.
|
|
2514
|
+
*
|
|
2515
|
+
* See [RFC 3986 §3.3](https://datatracker.ietf.org/doc/html/rfc3986#section-3.3)
|
|
2516
|
+
*
|
|
2517
|
+
* @example
|
|
2518
|
+
* const h = href("/:lang?/about", { lang: "en" })
|
|
2519
|
+
* // -> `/en/about`
|
|
2520
|
+
*
|
|
2521
|
+
* <Link to={href("/products/:id", { id: "abc123" })} />
|
|
2522
|
+
*
|
|
2523
|
+
* @public
|
|
2524
|
+
* @category Utils
|
|
2525
|
+
* @mode framework
|
|
2526
|
+
* @param path The route path to resolve
|
|
2527
|
+
* @param args The route params to use when resolving the path
|
|
2528
|
+
* @returns The resolved URL path
|
|
2501
2529
|
*/
|
|
2502
2530
|
declare function href<Path extends keyof Args>(path: Path, ...args: Args[Path]): string;
|
|
2503
2531
|
//#endregion
|
|
@@ -2553,13 +2581,39 @@ interface Cookie {
|
|
|
2553
2581
|
}
|
|
2554
2582
|
/**
|
|
2555
2583
|
* Creates a logical container for managing a browser cookie from the server.
|
|
2584
|
+
*
|
|
2585
|
+
* @public
|
|
2586
|
+
* @category Utils
|
|
2587
|
+
* @mode framework
|
|
2588
|
+
* @mode data
|
|
2589
|
+
* @param name The name of the cookie.
|
|
2590
|
+
* @param cookieOptions Options for parsing and serializing the cookie.
|
|
2591
|
+
* @returns A {@link Cookie} object for parsing and serializing the cookie.
|
|
2556
2592
|
*/
|
|
2557
2593
|
declare const createCookie: (name: string, cookieOptions?: CookieOptions) => Cookie;
|
|
2594
|
+
/**
|
|
2595
|
+
* A function that determines whether a value is a React Router {@link Cookie}
|
|
2596
|
+
* object.
|
|
2597
|
+
*
|
|
2598
|
+
* @public
|
|
2599
|
+
* @category Utils
|
|
2600
|
+
* @mode framework
|
|
2601
|
+
* @mode data
|
|
2602
|
+
* @param object The value to check.
|
|
2603
|
+
* @returns `true` if the value is a React Router {@link Cookie} object;
|
|
2604
|
+
* otherwise, `false`.
|
|
2605
|
+
*/
|
|
2558
2606
|
type IsCookieFunction = (object: any) => object is Cookie;
|
|
2559
2607
|
/**
|
|
2560
|
-
* Returns true if
|
|
2608
|
+
* Returns `true` if a value is a React Router {@link Cookie} object.
|
|
2561
2609
|
*
|
|
2562
|
-
* @
|
|
2610
|
+
* @public
|
|
2611
|
+
* @category Utils
|
|
2612
|
+
* @mode framework
|
|
2613
|
+
* @mode data
|
|
2614
|
+
* @param object The value to check.
|
|
2615
|
+
* @returns `true` if the value is a React Router {@link Cookie} object;
|
|
2616
|
+
* otherwise, `false`.
|
|
2563
2617
|
*/
|
|
2564
2618
|
declare const isCookie: IsCookieFunction;
|
|
2565
2619
|
//#endregion
|
|
@@ -2621,13 +2675,37 @@ type CreateSessionFunction = <Data = SessionData, FlashData = Data>(initialData?
|
|
|
2621
2675
|
*
|
|
2622
2676
|
* Note: This function is typically not invoked directly by application code.
|
|
2623
2677
|
* Instead, use a `SessionStorage` object's `getSession` method.
|
|
2678
|
+
*
|
|
2679
|
+
* @category Utils
|
|
2680
|
+
* @param initialData The initial data for the session.
|
|
2681
|
+
* @param id The identifier for the session. Defaults to an empty string for a
|
|
2682
|
+
* new session.
|
|
2683
|
+
* @returns A new {@link Session} object.
|
|
2624
2684
|
*/
|
|
2625
2685
|
declare const createSession: CreateSessionFunction;
|
|
2686
|
+
/**
|
|
2687
|
+
* A function that determines whether a value is a React Router {@link Session}
|
|
2688
|
+
* object.
|
|
2689
|
+
*
|
|
2690
|
+
* @public
|
|
2691
|
+
* @category Utils
|
|
2692
|
+
* @mode framework
|
|
2693
|
+
* @mode data
|
|
2694
|
+
* @param object The value to check.
|
|
2695
|
+
* @returns `true` if the value is a React Router {@link Session} object;
|
|
2696
|
+
* otherwise, `false`.
|
|
2697
|
+
*/
|
|
2626
2698
|
type IsSessionFunction = (object: any) => object is Session;
|
|
2627
2699
|
/**
|
|
2628
|
-
* Returns true if
|
|
2700
|
+
* Returns `true` if a value is a React Router {@link Session} object.
|
|
2629
2701
|
*
|
|
2630
|
-
* @
|
|
2702
|
+
* @public
|
|
2703
|
+
* @category Utils
|
|
2704
|
+
* @mode framework
|
|
2705
|
+
* @mode data
|
|
2706
|
+
* @param object The value to check.
|
|
2707
|
+
* @returns `true` if the value is a React Router {@link Session} object;
|
|
2708
|
+
* otherwise, `false`.
|
|
2631
2709
|
*/
|
|
2632
2710
|
declare const isSession: IsSessionFunction;
|
|
2633
2711
|
/**
|
|
@@ -2694,6 +2772,11 @@ interface SessionIdStorageStrategy<Data = SessionData, FlashData = Data> {
|
|
|
2694
2772
|
*
|
|
2695
2773
|
* Note: This is a low-level API that should only be used if none of the
|
|
2696
2774
|
* existing session storage options meet your requirements.
|
|
2775
|
+
*
|
|
2776
|
+
* @category Utils
|
|
2777
|
+
* @param strategy The strategy used to store session identifiers and data.
|
|
2778
|
+
* @returns A {@link SessionStorage} object that persists session data using the
|
|
2779
|
+
* provided strategy.
|
|
2697
2780
|
*/
|
|
2698
2781
|
declare function createSessionStorage<Data = SessionData, FlashData = Data>({
|
|
2699
2782
|
cookie: cookieArg,
|
|
@@ -2719,6 +2802,14 @@ interface CookieSessionStorageOptions {
|
|
|
2719
2802
|
* needed, and can help to simplify some load-balanced scenarios. However, it
|
|
2720
2803
|
* also has the limitation that serialized session data may not exceed the
|
|
2721
2804
|
* browser's maximum cookie size. Trade-offs!
|
|
2805
|
+
*
|
|
2806
|
+
* @public
|
|
2807
|
+
* @category Utils
|
|
2808
|
+
* @mode framework
|
|
2809
|
+
* @mode data
|
|
2810
|
+
* @param options Options for creating the cookie-backed session storage.
|
|
2811
|
+
* @returns A {@link SessionStorage} object that stores all session data in its
|
|
2812
|
+
* cookie.
|
|
2722
2813
|
*/
|
|
2723
2814
|
declare function createCookieSessionStorage<Data = SessionData, FlashData = Data>({
|
|
2724
2815
|
cookie: cookieArg
|
|
@@ -2733,11 +2824,17 @@ interface MemorySessionStorageOptions {
|
|
|
2733
2824
|
cookie?: SessionIdStorageStrategy["cookie"];
|
|
2734
2825
|
}
|
|
2735
2826
|
/**
|
|
2736
|
-
* Creates and returns a simple in-memory SessionStorage object
|
|
2737
|
-
* for testing and as a reference implementation.
|
|
2827
|
+
* Creates and returns a simple in-memory SessionStorage object.
|
|
2738
2828
|
*
|
|
2739
|
-
*
|
|
2740
|
-
*
|
|
2829
|
+
* Intended for local development and testing. It does not scale beyond a single
|
|
2830
|
+
* process, and all session data is lost when the server process stops/restarts.
|
|
2831
|
+
*
|
|
2832
|
+
* @public
|
|
2833
|
+
* @category Utils
|
|
2834
|
+
* @mode framework
|
|
2835
|
+
* @mode data
|
|
2836
|
+
* @param options Options for creating the in-memory session storage.
|
|
2837
|
+
* @returns A {@link SessionStorage} object that stores session data in memory.
|
|
2741
2838
|
*/
|
|
2742
2839
|
declare function createMemorySessionStorage<Data = SessionData, FlashData = Data>({
|
|
2743
2840
|
cookie
|