react-router 8.1.0 → 8.3.0
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 +83 -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 +109 -19
- package/dist/development/index-react-server.js +176 -45
- package/dist/development/index.js +1 -1
- package/dist/development/lib/actions.js +1 -1
- package/dist/development/lib/components.js +1 -1
- 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 +25 -25
- package/dist/development/lib/dom/lib.d.ts +2 -1
- package/dist/development/lib/dom/lib.js +5 -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 +26 -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 +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 +33 -6
- package/dist/development/lib/hooks.js +34 -7
- package/dist/development/lib/href.d.ts +24 -8
- package/dist/development/lib/href.js +31 -11
- package/dist/development/lib/router/history.d.ts +6 -0
- package/dist/development/lib/router/history.js +7 -1
- package/dist/development/lib/router/instrumentation.js +1 -1
- package/dist/development/lib/router/router.js +2 -2
- 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 +61 -5
- package/dist/development/lib/rsc/browser.js +34 -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 +29 -10
- package/dist/development/lib/rsc/route-modules.js +1 -1
- package/dist/development/lib/rsc/server.rsc.d.ts +8 -3
- package/dist/development/lib/rsc/server.ssr.d.ts +29 -6
- package/dist/development/lib/rsc/server.ssr.js +27 -12
- package/dist/development/lib/server-runtime/cookies.d.ts +28 -2
- package/dist/development/lib/server-runtime/cookies.js +17 -3
- 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.d.ts +12 -0
- package/dist/development/lib/server-runtime/server.js +13 -1
- 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 +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/vendor/turbo-stream-v2/flatten.js +1 -1
- package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +1 -1
- package/dist/development/vendor/turbo-stream-v2/unflatten.js +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 +109 -19
- package/dist/production/index-react-server.js +176 -45
- package/dist/production/index.js +1 -1
- package/dist/production/lib/actions.js +1 -1
- package/dist/production/lib/components.js +1 -1
- 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 +25 -25
- package/dist/production/lib/dom/lib.d.ts +2 -1
- package/dist/production/lib/dom/lib.js +5 -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 +26 -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 +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 +33 -6
- package/dist/production/lib/hooks.js +34 -7
- package/dist/production/lib/href.d.ts +24 -8
- package/dist/production/lib/href.js +31 -11
- package/dist/production/lib/router/history.d.ts +6 -0
- package/dist/production/lib/router/history.js +7 -1
- package/dist/production/lib/router/instrumentation.js +1 -1
- package/dist/production/lib/router/router.js +2 -2
- 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 +61 -5
- package/dist/production/lib/rsc/browser.js +34 -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 +29 -10
- package/dist/production/lib/rsc/route-modules.js +1 -1
- package/dist/production/lib/rsc/server.rsc.d.ts +8 -3
- package/dist/production/lib/rsc/server.ssr.d.ts +29 -6
- package/dist/production/lib/rsc/server.ssr.js +27 -12
- package/dist/production/lib/server-runtime/cookies.d.ts +28 -2
- package/dist/production/lib/server-runtime/cookies.js +17 -3
- 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.d.ts +12 -0
- package/dist/production/lib/server-runtime/server.js +13 -1
- 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 +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/vendor/turbo-stream-v2/flatten.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/unflatten.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/utils.js +1 -1
- package/docs/explanation/hot-module-replacement.md +1 -1
- package/docs/explanation/sessions-and-cookies.md +13 -13
- package/docs/explanation/state-management.md +2 -2
- package/docs/how-to/data-strategy.md +1 -1
- 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/deploying.md +4 -0
- 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/docs/upgrading/component-routes.md +1 -1
- package/docs/upgrading/future.md +33 -0
- package/docs/upgrading/router-provider.md +5 -5
- package/docs/upgrading/v7.md +39 -22
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,88 @@
|
|
|
1
1
|
# `react-router`
|
|
2
2
|
|
|
3
|
+
## v8.3.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Encode path params in `href`/`generatePath` per RFC 3986 path-segment rules instead of `encodeURIComponent` ([#15310](https://github.com/remix-run/react-router/pull/15310))
|
|
8
|
+
- Characters that are valid literally in a path segment (`$ & + , ; = : @` — RFC 3986 `pchar`) are no longer percent-encoded, so values like a semver build `1.0.0+1` interpolate unchanged instead of becoming `1.0.0%2B1`
|
|
9
|
+
- Structural/unsafe characters (`/ ? # %`, whitespace, non-ASCII) are still escaped exactly as before
|
|
10
|
+
- Use `crypto.randomUUID()` for `createMemorySessionStorage` session ids ([#15302](https://github.com/remix-run/react-router/pull/15302))
|
|
11
|
+
- `createMemorySessionStorage` is only intended for local development and testing - sessions are lost when the server restarts
|
|
12
|
+
- Fix `NavLink` not applying its `pending` state when `to` has a trailing slash ([#15300](https://github.com/remix-run/react-router/pull/15300))
|
|
13
|
+
- Preserve RSC route component metadata so routes with a `clientLoader` can skip unnecessary server requests once their components have rendered while still fetching missing server-rendered elements ([#15323](https://github.com/remix-run/react-router/pull/15323))
|
|
14
|
+
- Harden RSC CSRF code paths ([#15311](https://github.com/remix-run/react-router/pull/15311))
|
|
15
|
+
- Fix server crash (`TypeError: Invalid state: Unable to enqueue`) when a request is aborted while the RSC HTML stream has a pending flush ([#15286](https://github.com/remix-run/react-router/pull/15286))
|
|
16
|
+
- Handle cancellation of the `injectRSCPayload` readable side, clear the pending flush, and cancel the underlying RSC payload stream
|
|
17
|
+
|
|
18
|
+
### Unstable Changes
|
|
19
|
+
|
|
20
|
+
⚠️ _[Unstable features](https://reactrouter.com/community/api-development-strategy#unstable-flags) are not recommended for production use_
|
|
21
|
+
|
|
22
|
+
- Detect stale RSC clients during lazy route discovery and reload the destination document ([#15318](https://github.com/remix-run/react-router/pull/15318))
|
|
23
|
+
|
|
24
|
+
#### Migration
|
|
25
|
+
|
|
26
|
+
Apps using the default RSC Framework entry do not need to make any changes. Apps with a custom `entry.rsc.tsx` should import the generated client version and pass it to `unstable_matchRSCServerRequest`:
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import clientVersion from "virtual:react-router/unstable_rsc/client-version";
|
|
30
|
+
|
|
31
|
+
return unstable_matchRSCServerRequest({
|
|
32
|
+
// ...
|
|
33
|
+
clientVersion,
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
- Add CSP nonce support to RSC document rendering ([#15320](https://github.com/remix-run/react-router/pull/15320))
|
|
38
|
+
|
|
39
|
+
- Add `nonce` options to `unstable_routeRSCServerRequest` and `unstable_RSCStaticRouter`
|
|
40
|
+
- Forward the nonce to the HTML renderer and apply it to injected RSC payload scripts and nonce-aware framework components
|
|
41
|
+
|
|
42
|
+
To adopt nonce-based CSP, update your `entry.ssr.tsx` (run `react-router reveal entry.ssr` first in RSC Framework Mode) to generate a fresh nonce for each request. Pass it to `routeRSCServerRequest`, spread the `renderHTML` options into React's HTML renderer, pass `options.nonce` to `RSCStaticRouter`, and use the same nonce in the `Content-Security-Policy` response header:
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
const nonce = crypto.randomUUID();
|
|
46
|
+
const response = await routeRSCServerRequest({
|
|
47
|
+
request,
|
|
48
|
+
serverResponse,
|
|
49
|
+
createFromReadableStream,
|
|
50
|
+
nonce,
|
|
51
|
+
async renderHTML(getPayload, options) {
|
|
52
|
+
const payload = getPayload();
|
|
53
|
+
return renderHTMLToReadableStream(
|
|
54
|
+
<RSCStaticRouter getPayload={getPayload} nonce={options.nonce} />,
|
|
55
|
+
{
|
|
56
|
+
...options,
|
|
57
|
+
bootstrapScriptContent,
|
|
58
|
+
formState: await payload.formState,
|
|
59
|
+
signal: request.signal,
|
|
60
|
+
},
|
|
61
|
+
);
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
response.headers.set(
|
|
65
|
+
"Content-Security-Policy",
|
|
66
|
+
`script-src 'self' 'nonce-${nonce}'`,
|
|
67
|
+
);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## v8.2.0
|
|
71
|
+
|
|
72
|
+
### Patch Changes
|
|
73
|
+
|
|
74
|
+
- Fix `href()` to properly stringify and URL-encode param values, matching `generatePath()` ([#15277](https://github.com/remix-run/react-router/pull/15277))
|
|
75
|
+
- splat params preserve path separators while encoding each segment individually
|
|
76
|
+
- Fix dynamic param extraction for routes with optional static segments ([#15200](https://github.com/remix-run/react-router/pull/15200))
|
|
77
|
+
- When a route path contains optional static segments (e.g. `/school?/user/:id`), the internal regex's incorrectly shifted parameter indices resulting in incorrect parameter extraction
|
|
78
|
+
- Consecutive optional static segments (e.g. `/one?/two?`) were only partially handled
|
|
79
|
+
- Preserve navigation blocker state through a revalidation ([#15246](https://github.com/remix-run/react-router/pull/15246))
|
|
80
|
+
- Fix route ranking for dynamic parameters with static extension suffixes ([#15273](https://github.com/remix-run/react-router/pull/15273))
|
|
81
|
+
- These were not being detected as dynamic param segments and instead got incorrectly scored higher as a static segment
|
|
82
|
+
- This meant they could potentially tie truly static routes like `/sitemap.xml` and outrank them based on definition order
|
|
83
|
+
- These are now correctly identified as dynamic parameter segments and scored correctly
|
|
84
|
+
- Use ReactFormState types instead of unknown ([#15263](https://github.com/remix-run/react-router/pull/15263))
|
|
85
|
+
|
|
3
86
|
## v8.1.0
|
|
4
87
|
|
|
5
88
|
### Minor Changes
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { CookieParseOptions, CookieParseOptions as CookieParseOptions$1, CookieSerializeOptions, CookieSerializeOptions as CookieSerializeOptions$1 } from "cookie-es";
|
|
4
4
|
import { BrowserRouter, Form, HashRouter, Link, Links, MemoryRouter, Meta, NavLink, Navigate, Outlet, Route, Router, RouterProvider, Routes, ScrollRestoration, StaticRouter, StaticRouterProvider, unstable_HistoryRouter } from "react-router/internal/react-server-client";
|
|
5
|
+
import { ReactFormState } from "react-dom/client";
|
|
5
6
|
|
|
6
7
|
//#region lib/router/history.d.ts
|
|
7
8
|
/**
|
|
@@ -2317,14 +2318,14 @@ type RSCRenderPayload = {
|
|
|
2317
2318
|
type: "render";
|
|
2318
2319
|
actionData: Record<string, any> | null;
|
|
2319
2320
|
basename: string | undefined;
|
|
2321
|
+
clientVersion?: string;
|
|
2320
2322
|
errors: Record<string, any> | null;
|
|
2321
2323
|
loaderData: Record<string, any>;
|
|
2322
2324
|
location: Location;
|
|
2323
2325
|
routeDiscovery: RouteDiscovery;
|
|
2324
2326
|
matches: RSCRouteMatch[];
|
|
2325
2327
|
patches?: Promise<RSCRouteManifest[]>;
|
|
2326
|
-
|
|
2327
|
-
formState?: unknown;
|
|
2328
|
+
formState?: ReactFormState;
|
|
2328
2329
|
};
|
|
2329
2330
|
type RSCManifestPayload = {
|
|
2330
2331
|
type: "manifest";
|
|
@@ -2350,7 +2351,7 @@ type RSCMatch = {
|
|
|
2350
2351
|
payload: RSCPayload;
|
|
2351
2352
|
};
|
|
2352
2353
|
type DecodeActionFunction = (formData: FormData) => Promise<() => Promise<unknown>>;
|
|
2353
|
-
type DecodeFormStateFunction = (result: unknown, formData: FormData) =>
|
|
2354
|
+
type DecodeFormStateFunction = (result: unknown, formData: FormData) => Promise<ReactFormState | undefined>;
|
|
2354
2355
|
type DecodeReplyFunction = (reply: FormData | string, options: {
|
|
2355
2356
|
temporaryReferences: unknown;
|
|
2356
2357
|
}) => Promise<unknown[]>;
|
|
@@ -2420,6 +2421,8 @@ type RouteDiscovery = {
|
|
|
2420
2421
|
* encoding the {@link unstable_RSCPayload}.
|
|
2421
2422
|
* @param opts.loadServerAction Your `react-server-dom-xyz/server`'s
|
|
2422
2423
|
* `loadServerAction` function, used to load a server action by ID.
|
|
2424
|
+
* @param opts.clientVersion A version derived from the client build output used
|
|
2425
|
+
* to detect stale clients during lazy route discovery.
|
|
2423
2426
|
* @param opts.onError An optional error handler that will be called with any
|
|
2424
2427
|
* errors that occur during the request processing.
|
|
2425
2428
|
* @param opts.request The [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
@@ -2443,6 +2446,7 @@ declare function matchRSCServerRequest({
|
|
|
2443
2446
|
loadServerAction,
|
|
2444
2447
|
decodeAction,
|
|
2445
2448
|
decodeFormState,
|
|
2449
|
+
clientVersion,
|
|
2446
2450
|
onError,
|
|
2447
2451
|
request,
|
|
2448
2452
|
routes,
|
|
@@ -2456,6 +2460,7 @@ declare function matchRSCServerRequest({
|
|
|
2456
2460
|
decodeFormState?: DecodeFormStateFunction;
|
|
2457
2461
|
requestContext?: RouterContextProvider;
|
|
2458
2462
|
loadServerAction?: LoadServerActionFunction;
|
|
2463
|
+
clientVersion?: string;
|
|
2459
2464
|
onError?: (error: unknown) => void;
|
|
2460
2465
|
request: Request;
|
|
2461
2466
|
routes: RSCRouteConfigEntry[];
|
|
@@ -2489,14 +2494,30 @@ type Pages = Register extends {
|
|
|
2489
2494
|
type Args = { [K in keyof Pages]: ToArgs<Pages[K]["params"]> };
|
|
2490
2495
|
type ToArgs<Params extends Record<string, string | undefined>> = Equal<Params, {}> extends true ? [] : Partial<Params> extends Params ? [Params] | [] : [Params];
|
|
2491
2496
|
/**
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2497
|
+
* Returns a resolved URL path for the specified route.
|
|
2498
|
+
*
|
|
2499
|
+
* Param values are percent-encoded for use in a path segment: characters that
|
|
2500
|
+
* would change the URL structure (`/`, `?`, `#`, `%`, whitespace, non-ASCII)
|
|
2501
|
+
* are escaped, while characters that RFC 3986 allows literally in a path
|
|
2502
|
+
* segment (`$ & + , ; = : @`) are kept as-is. Note this differs from query-string
|
|
2503
|
+
* encoding (`encodeURIComponent`/`URLSearchParams`), where those characters are
|
|
2504
|
+
* delimiters and must be escaped. Splat (`*`) values are encoded per segment,
|
|
2505
|
+
* preserving `/` separators.
|
|
2506
|
+
*
|
|
2507
|
+
* See [RFC 3986 §3.3](https://datatracker.ietf.org/doc/html/rfc3986#section-3.3)
|
|
2508
|
+
*
|
|
2509
|
+
* @example
|
|
2510
|
+
* const h = href("/:lang?/about", { lang: "en" })
|
|
2511
|
+
* // -> `/en/about`
|
|
2512
|
+
*
|
|
2513
|
+
* <Link to={href("/products/:id", { id: "abc123" })} />
|
|
2514
|
+
*
|
|
2515
|
+
* @public
|
|
2516
|
+
* @category Utils
|
|
2517
|
+
* @mode framework
|
|
2518
|
+
* @param path The route path to resolve
|
|
2519
|
+
* @param args The route params to use when resolving the path
|
|
2520
|
+
* @returns The resolved URL path
|
|
2500
2521
|
*/
|
|
2501
2522
|
declare function href<Path extends keyof Args>(path: Path, ...args: Args[Path]): string;
|
|
2502
2523
|
//#endregion
|
|
@@ -2552,13 +2573,39 @@ interface Cookie {
|
|
|
2552
2573
|
}
|
|
2553
2574
|
/**
|
|
2554
2575
|
* Creates a logical container for managing a browser cookie from the server.
|
|
2576
|
+
*
|
|
2577
|
+
* @public
|
|
2578
|
+
* @category Utils
|
|
2579
|
+
* @mode framework
|
|
2580
|
+
* @mode data
|
|
2581
|
+
* @param name The name of the cookie.
|
|
2582
|
+
* @param cookieOptions Options for parsing and serializing the cookie.
|
|
2583
|
+
* @returns A {@link Cookie} object for parsing and serializing the cookie.
|
|
2555
2584
|
*/
|
|
2556
2585
|
declare const createCookie: (name: string, cookieOptions?: CookieOptions) => Cookie;
|
|
2586
|
+
/**
|
|
2587
|
+
* A function that determines whether a value is a React Router {@link Cookie}
|
|
2588
|
+
* object.
|
|
2589
|
+
*
|
|
2590
|
+
* @public
|
|
2591
|
+
* @category Utils
|
|
2592
|
+
* @mode framework
|
|
2593
|
+
* @mode data
|
|
2594
|
+
* @param object The value to check.
|
|
2595
|
+
* @returns `true` if the value is a React Router {@link Cookie} object;
|
|
2596
|
+
* otherwise, `false`.
|
|
2597
|
+
*/
|
|
2557
2598
|
type IsCookieFunction = (object: any) => object is Cookie;
|
|
2558
2599
|
/**
|
|
2559
|
-
* Returns true if
|
|
2600
|
+
* Returns `true` if a value is a React Router {@link Cookie} object.
|
|
2560
2601
|
*
|
|
2561
|
-
* @
|
|
2602
|
+
* @public
|
|
2603
|
+
* @category Utils
|
|
2604
|
+
* @mode framework
|
|
2605
|
+
* @mode data
|
|
2606
|
+
* @param object The value to check.
|
|
2607
|
+
* @returns `true` if the value is a React Router {@link Cookie} object;
|
|
2608
|
+
* otherwise, `false`.
|
|
2562
2609
|
*/
|
|
2563
2610
|
declare const isCookie: IsCookieFunction;
|
|
2564
2611
|
//#endregion
|
|
@@ -2620,13 +2667,37 @@ type CreateSessionFunction = <Data = SessionData, FlashData = Data>(initialData?
|
|
|
2620
2667
|
*
|
|
2621
2668
|
* Note: This function is typically not invoked directly by application code.
|
|
2622
2669
|
* Instead, use a `SessionStorage` object's `getSession` method.
|
|
2670
|
+
*
|
|
2671
|
+
* @category Utils
|
|
2672
|
+
* @param initialData The initial data for the session.
|
|
2673
|
+
* @param id The identifier for the session. Defaults to an empty string for a
|
|
2674
|
+
* new session.
|
|
2675
|
+
* @returns A new {@link Session} object.
|
|
2623
2676
|
*/
|
|
2624
2677
|
declare const createSession: CreateSessionFunction;
|
|
2678
|
+
/**
|
|
2679
|
+
* A function that determines whether a value is a React Router {@link Session}
|
|
2680
|
+
* object.
|
|
2681
|
+
*
|
|
2682
|
+
* @public
|
|
2683
|
+
* @category Utils
|
|
2684
|
+
* @mode framework
|
|
2685
|
+
* @mode data
|
|
2686
|
+
* @param object The value to check.
|
|
2687
|
+
* @returns `true` if the value is a React Router {@link Session} object;
|
|
2688
|
+
* otherwise, `false`.
|
|
2689
|
+
*/
|
|
2625
2690
|
type IsSessionFunction = (object: any) => object is Session;
|
|
2626
2691
|
/**
|
|
2627
|
-
* Returns true if
|
|
2692
|
+
* Returns `true` if a value is a React Router {@link Session} object.
|
|
2628
2693
|
*
|
|
2629
|
-
* @
|
|
2694
|
+
* @public
|
|
2695
|
+
* @category Utils
|
|
2696
|
+
* @mode framework
|
|
2697
|
+
* @mode data
|
|
2698
|
+
* @param object The value to check.
|
|
2699
|
+
* @returns `true` if the value is a React Router {@link Session} object;
|
|
2700
|
+
* otherwise, `false`.
|
|
2630
2701
|
*/
|
|
2631
2702
|
declare const isSession: IsSessionFunction;
|
|
2632
2703
|
/**
|
|
@@ -2693,6 +2764,11 @@ interface SessionIdStorageStrategy<Data = SessionData, FlashData = Data> {
|
|
|
2693
2764
|
*
|
|
2694
2765
|
* Note: This is a low-level API that should only be used if none of the
|
|
2695
2766
|
* existing session storage options meet your requirements.
|
|
2767
|
+
*
|
|
2768
|
+
* @category Utils
|
|
2769
|
+
* @param strategy The strategy used to store session identifiers and data.
|
|
2770
|
+
* @returns A {@link SessionStorage} object that persists session data using the
|
|
2771
|
+
* provided strategy.
|
|
2696
2772
|
*/
|
|
2697
2773
|
declare function createSessionStorage<Data = SessionData, FlashData = Data>({
|
|
2698
2774
|
cookie: cookieArg,
|
|
@@ -2718,6 +2794,14 @@ interface CookieSessionStorageOptions {
|
|
|
2718
2794
|
* needed, and can help to simplify some load-balanced scenarios. However, it
|
|
2719
2795
|
* also has the limitation that serialized session data may not exceed the
|
|
2720
2796
|
* browser's maximum cookie size. Trade-offs!
|
|
2797
|
+
*
|
|
2798
|
+
* @public
|
|
2799
|
+
* @category Utils
|
|
2800
|
+
* @mode framework
|
|
2801
|
+
* @mode data
|
|
2802
|
+
* @param options Options for creating the cookie-backed session storage.
|
|
2803
|
+
* @returns A {@link SessionStorage} object that stores all session data in its
|
|
2804
|
+
* cookie.
|
|
2721
2805
|
*/
|
|
2722
2806
|
declare function createCookieSessionStorage<Data = SessionData, FlashData = Data>({
|
|
2723
2807
|
cookie: cookieArg
|
|
@@ -2732,11 +2816,17 @@ interface MemorySessionStorageOptions {
|
|
|
2732
2816
|
cookie?: SessionIdStorageStrategy["cookie"];
|
|
2733
2817
|
}
|
|
2734
2818
|
/**
|
|
2735
|
-
* Creates and returns a simple in-memory SessionStorage object
|
|
2736
|
-
*
|
|
2819
|
+
* Creates and returns a simple in-memory SessionStorage object.
|
|
2820
|
+
*
|
|
2821
|
+
* Intended for local development and testing. It does not scale beyond a single
|
|
2822
|
+
* process, and all session data is lost when the server process stops/restarts.
|
|
2737
2823
|
*
|
|
2738
|
-
*
|
|
2739
|
-
*
|
|
2824
|
+
* @public
|
|
2825
|
+
* @category Utils
|
|
2826
|
+
* @mode framework
|
|
2827
|
+
* @mode data
|
|
2828
|
+
* @param options Options for creating the in-memory session storage.
|
|
2829
|
+
* @returns A {@link SessionStorage} object that stores session data in memory.
|
|
2740
2830
|
*/
|
|
2741
2831
|
declare function createMemorySessionStorage<Data = SessionData, FlashData = Data>({
|
|
2742
2832
|
cookie
|