react-router 8.3.1 → 8.4.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 +33 -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 +42 -48
- package/dist/development/index-react-server.js +75 -31
- package/dist/development/index.d.ts +2 -2
- package/dist/development/index.js +3 -3
- package/dist/development/lib/actions.js +1 -1
- package/dist/development/lib/components.js +45 -8
- package/dist/development/lib/context.d.ts +13 -5
- package/dist/development/lib/context.js +11 -3
- package/dist/development/lib/dom/dom.js +1 -1
- package/dist/development/lib/dom/lib.js +14 -32
- package/dist/development/lib/dom/server.d.ts +6 -1
- package/dist/development/lib/dom/server.js +40 -14
- package/dist/development/lib/dom/ssr/components.js +15 -23
- package/dist/development/lib/dom/ssr/data.js +1 -1
- package/dist/development/lib/dom/ssr/entry.d.ts +4 -0
- 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 +33 -12
- package/dist/development/lib/dom/ssr/hydration.d.ts +3 -1
- package/dist/development/lib/dom/ssr/hydration.js +6 -4
- 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 +5 -2
- package/dist/development/lib/dom/ssr/routeModules.js +1 -1
- package/dist/development/lib/dom/ssr/routes-test-stub.js +1 -1
- package/dist/development/lib/dom/ssr/routes.js +1 -1
- package/dist/development/lib/dom/ssr/server.js +2 -2
- package/dist/development/lib/dom/ssr/single-fetch.js +10 -19
- package/dist/development/lib/dom-export/dom-router-provider.js +1 -1
- package/dist/development/lib/dom-export/hydrated-router.js +2 -1
- package/dist/development/lib/errors.js +1 -1
- package/dist/development/lib/hooks.js +49 -44
- package/dist/development/lib/href.js +1 -1
- package/dist/development/lib/router/history.js +1 -1
- package/dist/development/lib/router/instrumentation.js +1 -1
- package/dist/development/lib/router/matcher-route-pattern.d.ts +2 -0
- package/dist/development/lib/router/matcher-route-pattern.js +216 -0
- package/dist/development/lib/router/matcher-route-pattern.preload.d.ts +20 -0
- package/dist/development/lib/router/matcher-route-pattern.preload.js +36 -0
- package/dist/development/lib/router/matcher.d.ts +2 -0
- package/dist/development/lib/router/matcher.js +29 -0
- package/dist/development/lib/router/navigation.js +1 -1
- package/dist/development/lib/router/router.d.ts +13 -7
- package/dist/development/lib/router/router.js +81 -66
- package/dist/development/lib/router/url.js +1 -1
- package/dist/development/lib/router/utils.d.ts +6 -1
- package/dist/development/lib/router/utils.js +6 -4
- package/dist/development/lib/rsc/browser.js +2 -1
- 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 +2 -4
- package/dist/development/lib/rsc/route-modules.js +1 -1
- package/dist/development/lib/rsc/server.rsc.d.ts +7 -0
- package/dist/development/lib/rsc/server.ssr.js +25 -21
- 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 +3 -4
- package/dist/development/lib/server-runtime/routes.js +1 -1
- package/dist/development/lib/server-runtime/server.js +7 -6
- package/dist/development/lib/server-runtime/serverHandoff.js +1 -1
- package/dist/development/lib/server-runtime/sessions/cookieStorage.js +1 -1
- package/dist/development/lib/server-runtime/sessions/memoryStorage.js +1 -1
- package/dist/development/lib/server-runtime/sessions.js +1 -1
- package/dist/development/lib/server-runtime/single-fetch.js +1 -1
- package/dist/development/lib/server-runtime/urls.js +1 -1
- package/dist/development/lib/server-runtime/warnings.js +1 -1
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/route-pattern.d.ts +3 -0
- package/dist/development/route-pattern.js +12 -0
- 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 +42 -48
- package/dist/production/index-react-server.js +75 -31
- package/dist/production/index.d.ts +2 -2
- package/dist/production/index.js +3 -3
- package/dist/production/lib/actions.js +1 -1
- package/dist/production/lib/components.js +45 -8
- package/dist/production/lib/context.d.ts +13 -5
- package/dist/production/lib/context.js +11 -3
- package/dist/production/lib/dom/dom.js +1 -1
- package/dist/production/lib/dom/lib.js +14 -32
- package/dist/production/lib/dom/server.d.ts +6 -1
- package/dist/production/lib/dom/server.js +40 -14
- package/dist/production/lib/dom/ssr/components.js +15 -23
- package/dist/production/lib/dom/ssr/data.js +1 -1
- package/dist/production/lib/dom/ssr/entry.d.ts +4 -0
- 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 +33 -12
- package/dist/production/lib/dom/ssr/hydration.d.ts +3 -1
- package/dist/production/lib/dom/ssr/hydration.js +6 -4
- 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 +5 -2
- package/dist/production/lib/dom/ssr/routeModules.js +1 -1
- package/dist/production/lib/dom/ssr/routes-test-stub.js +1 -1
- package/dist/production/lib/dom/ssr/routes.js +1 -1
- package/dist/production/lib/dom/ssr/server.js +2 -2
- package/dist/production/lib/dom/ssr/single-fetch.js +10 -19
- package/dist/production/lib/dom-export/dom-router-provider.js +1 -1
- package/dist/production/lib/dom-export/hydrated-router.js +2 -1
- package/dist/production/lib/errors.js +1 -1
- package/dist/production/lib/hooks.js +49 -44
- package/dist/production/lib/href.js +1 -1
- package/dist/production/lib/router/history.js +1 -1
- package/dist/production/lib/router/instrumentation.js +1 -1
- package/dist/production/lib/router/matcher-route-pattern.d.ts +2 -0
- package/dist/production/lib/router/matcher-route-pattern.js +216 -0
- package/dist/production/lib/router/matcher-route-pattern.preload.d.ts +20 -0
- package/dist/production/lib/router/matcher-route-pattern.preload.js +36 -0
- package/dist/production/lib/router/matcher.d.ts +2 -0
- package/dist/production/lib/router/matcher.js +29 -0
- package/dist/production/lib/router/navigation.js +1 -1
- package/dist/production/lib/router/router.d.ts +13 -7
- package/dist/production/lib/router/router.js +81 -66
- package/dist/production/lib/router/url.js +1 -1
- package/dist/production/lib/router/utils.d.ts +6 -1
- package/dist/production/lib/router/utils.js +6 -4
- package/dist/production/lib/rsc/browser.js +2 -1
- 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 +2 -4
- package/dist/production/lib/rsc/route-modules.js +1 -1
- package/dist/production/lib/rsc/server.rsc.d.ts +7 -0
- package/dist/production/lib/rsc/server.ssr.js +25 -21
- 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 +3 -4
- package/dist/production/lib/server-runtime/routes.js +1 -1
- package/dist/production/lib/server-runtime/server.js +7 -6
- package/dist/production/lib/server-runtime/serverHandoff.js +1 -1
- package/dist/production/lib/server-runtime/sessions/cookieStorage.js +1 -1
- package/dist/production/lib/server-runtime/sessions/memoryStorage.js +1 -1
- package/dist/production/lib/server-runtime/sessions.js +1 -1
- package/dist/production/lib/server-runtime/single-fetch.js +1 -1
- package/dist/production/lib/server-runtime/urls.js +1 -1
- package/dist/production/lib/server-runtime/warnings.js +1 -1
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/route-pattern.d.ts +3 -0
- package/dist/production/route-pattern.js +12 -0
- 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/how-to/fetchers.md +6 -1
- package/docs/how-to/middleware.md +3 -1
- package/docs/how-to/optimize-revalidation.md +178 -5
- package/docs/how-to/react-server-components.md +26 -3
- package/docs/how-to/resource-routes.md +3 -0
- package/docs/start/data/actions.md +2 -1
- package/docs/start/data/route-object.md +21 -6
- package/docs/start/framework/actions.md +4 -2
- package/docs/start/framework/route-module.md +32 -5
- package/docs/upgrading/future.md +68 -0
- package/package.json +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# `react-router`
|
|
2
2
|
|
|
3
|
+
## v8.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Deprecate the `createStaticRouter({ branches })` option ([#15297](https://github.com/remix-run/react-router/pull/15297))
|
|
8
|
+
- `createStaticRouter` now caches route branches internally, ignores `branches`, and logs a deprecation warning when the option is provided
|
|
9
|
+
- The deprecated `EntryContext.branches` property remains available for compatibility but is always an empty array
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Prevent stale route discovery during manifest version-mismatch recovery ([#15489](https://github.com/remix-run/react-router/pull/15489))
|
|
14
|
+
- Keep concurrent manifest responses pending while a document reload is in progress
|
|
15
|
+
- Report a discovery error when a previous reload failed to resolve a version mismatch instead of loading a stale route or reloading repeatedly
|
|
16
|
+
- Fail pending requests if a document reload does not complete within five seconds or the document is restored from the back-forward cache, allowing subsequent requests to recover
|
|
17
|
+
- Preserve lazy route module import errors during SPA navigations instead of replacing them with a missing `dataStrategy` result error ([#15464](https://github.com/remix-run/react-router/pull/15464))
|
|
18
|
+
- Switch to more granular internal router contexts to avoid unnecessary route component re-renders when unrelated data router state changes ([#15376](https://github.com/remix-run/react-router/pull/15376))
|
|
19
|
+
- ⚠️ This contains some breaking changes to exported `UNSAFE_` contexts, so please review carefully if you are using those unsafe exports
|
|
20
|
+
- Correctly escape streamed RSC redirect locations in meta tag attributes ([#15491](https://github.com/remix-run/react-router/pull/15491))
|
|
21
|
+
- Avoid unintended `document.startViewTransition` calls during initial hydration and `router.revalidate()` calls ([#15484](https://github.com/remix-run/react-router/pull/15484))
|
|
22
|
+
- Fix `SingleFetchNoResultError` thrown when a fetcher revalidates against a splat route during lazy route discovery ([#15395](https://github.com/remix-run/react-router/pull/15395))
|
|
23
|
+
- Track discovery per fetcher load so revalidation waits for the current load's discovery, even when the fetcher key is reused, while still restarting interrupted loaders after discovery completes
|
|
24
|
+
- Preserve the underlying decode failure as the `cause` of the `Unable to decode turbo-stream response` error ([#15450](https://github.com/remix-run/react-router/pull/15450))
|
|
25
|
+
|
|
26
|
+
### Unstable Changes
|
|
27
|
+
|
|
28
|
+
⚠️ _[Unstable features](https://reactrouter.com/community/api-development-strategy#unstable-flags) are not recommended for production use_
|
|
29
|
+
|
|
30
|
+
- Add a Data Mode `future.unstable_routePatternMatching` flag for more efficient route matching powered by `@remix-run/route-pattern` ([#15298](https://github.com/remix-run/react-router/pull/15298))
|
|
31
|
+
- Add an `unstable_validateParams` route field to reject invalid parameter values and continue matching
|
|
32
|
+
- Document access control requirements for RSC Server Functions ([#15490](https://github.com/remix-run/react-router/pull/15490))
|
|
33
|
+
- Treat every Server Function as a public endpoint that must perform all of its own access control checks
|
|
34
|
+
- Recommend route actions when access control should be provided by route middleware
|
|
35
|
+
|
|
3
36
|
## v8.3.1
|
|
4
37
|
|
|
5
38
|
### Patch Changes
|
|
@@ -50,7 +50,7 @@ interface Path {
|
|
|
50
50
|
* An entry in a history stack. A location contains information about the
|
|
51
51
|
* URL path, as well as possibly some arbitrary state and a key.
|
|
52
52
|
*/
|
|
53
|
-
interface Location<State = any> extends Path {
|
|
53
|
+
interface Location$1<State = any> extends Path {
|
|
54
54
|
/**
|
|
55
55
|
* A value of arbitrary data associated with this location.
|
|
56
56
|
*/
|
|
@@ -79,7 +79,7 @@ interface Update {
|
|
|
79
79
|
/**
|
|
80
80
|
* The new location.
|
|
81
81
|
*/
|
|
82
|
-
location: Location;
|
|
82
|
+
location: Location$1;
|
|
83
83
|
/**
|
|
84
84
|
* The delta between this location and the former location in the history stack
|
|
85
85
|
*/
|
|
@@ -113,7 +113,7 @@ interface History {
|
|
|
113
113
|
/**
|
|
114
114
|
* The current location. This value is mutable.
|
|
115
115
|
*/
|
|
116
|
-
readonly location: Location;
|
|
116
|
+
readonly location: Location$1;
|
|
117
117
|
/**
|
|
118
118
|
* Returns a valid href for the given `to` value that may be used as
|
|
119
119
|
* the value of an <a href> attribute.
|
|
@@ -597,7 +597,7 @@ interface MapRoutePropertiesFunction {
|
|
|
597
597
|
* onto the route. Either they're meaningful to the router, or they'll get
|
|
598
598
|
* ignored.
|
|
599
599
|
*/
|
|
600
|
-
type UnsupportedLazyRouteObjectKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children";
|
|
600
|
+
type UnsupportedLazyRouteObjectKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children" | "unstable_validateParams";
|
|
601
601
|
/**
|
|
602
602
|
* Keys we cannot change from within a lazy() function. We spread all other keys
|
|
603
603
|
* onto the route. Either they're meaningful to the router, or they'll get
|
|
@@ -655,6 +655,11 @@ type BaseRouteObject = {
|
|
|
655
655
|
* See [`shouldRevalidate`](../../start/data/route-object#shouldRevalidate).
|
|
656
656
|
*/
|
|
657
657
|
shouldRevalidate?: ShouldRevalidateFunction;
|
|
658
|
+
/**
|
|
659
|
+
* A map of route param names to regular expressions used to validate params
|
|
660
|
+
* after a route-pattern match.
|
|
661
|
+
*/
|
|
662
|
+
unstable_validateParams?: Record<string, RegExp>;
|
|
658
663
|
/**
|
|
659
664
|
* The route handle.
|
|
660
665
|
*/
|
|
@@ -791,7 +796,7 @@ interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {}
|
|
|
791
796
|
* Defaults to `/`.
|
|
792
797
|
* @returns An array of matched routes, or `null` if no matches were found.
|
|
793
798
|
*/
|
|
794
|
-
declare function matchRoutes<RouteObjectType extends RouteObject = RouteObject>(routes: RouteObjectType[], locationArg: Partial<Location> | string, basename?: string): RouteMatch<string, RouteObjectType>[] | null;
|
|
799
|
+
declare function matchRoutes<RouteObjectType extends RouteObject = RouteObject>(routes: RouteObjectType[], locationArg: Partial<Location$1> | string, basename?: string): RouteMatch<string, RouteObjectType>[] | null;
|
|
795
800
|
interface UIMatch<Data = unknown, Handle = unknown> {
|
|
796
801
|
id: string;
|
|
797
802
|
pathname: string;
|
|
@@ -811,30 +816,6 @@ interface UIMatch<Data = unknown, Handle = unknown> {
|
|
|
811
816
|
*/
|
|
812
817
|
handle: Handle;
|
|
813
818
|
}
|
|
814
|
-
interface RouteMeta<RouteObjectType extends RouteObject = RouteObject> {
|
|
815
|
-
relativePath: string;
|
|
816
|
-
caseSensitive: boolean;
|
|
817
|
-
childrenIndex: number;
|
|
818
|
-
route: RouteObjectType;
|
|
819
|
-
matcher?: RegExp;
|
|
820
|
-
compiledParams?: CompiledPathParam[];
|
|
821
|
-
}
|
|
822
|
-
/**
|
|
823
|
-
* @private
|
|
824
|
-
* PRIVATE - DO NOT USE
|
|
825
|
-
*
|
|
826
|
-
* A "branch" of routes that match a given route pattern.
|
|
827
|
-
* This is an internal interface not intended for direct external usage.
|
|
828
|
-
*/
|
|
829
|
-
interface RouteBranch<RouteObjectType extends RouteObject = RouteObject> {
|
|
830
|
-
path: string;
|
|
831
|
-
score: number;
|
|
832
|
-
routesMeta: RouteMeta<RouteObjectType>[];
|
|
833
|
-
}
|
|
834
|
-
type CompiledPathParam = {
|
|
835
|
-
paramName: string;
|
|
836
|
-
isOptional?: boolean;
|
|
837
|
-
};
|
|
838
819
|
declare class DataWithResponseInit<D> {
|
|
839
820
|
type: string;
|
|
840
821
|
data: D;
|
|
@@ -1143,9 +1124,10 @@ interface Router$1 {
|
|
|
1143
1124
|
* @private
|
|
1144
1125
|
* PRIVATE - DO NOT USE
|
|
1145
1126
|
*
|
|
1146
|
-
*
|
|
1127
|
+
* Match routes against a location using the router's configured route
|
|
1128
|
+
* matching implementation.
|
|
1147
1129
|
*/
|
|
1148
|
-
|
|
1130
|
+
match(locationArg: Partial<Location$1> | string): DataRouteMatch[] | null;
|
|
1149
1131
|
/**
|
|
1150
1132
|
* @private
|
|
1151
1133
|
* PRIVATE - DO NOT USE
|
|
@@ -1230,7 +1212,7 @@ interface Router$1 {
|
|
|
1230
1212
|
* Utility function to create an href for the given location
|
|
1231
1213
|
* @param location
|
|
1232
1214
|
*/
|
|
1233
|
-
createHref(location: Location | URL): string;
|
|
1215
|
+
createHref(location: Location$1 | URL): string;
|
|
1234
1216
|
/**
|
|
1235
1217
|
* @private
|
|
1236
1218
|
* PRIVATE - DO NOT USE
|
|
@@ -1346,7 +1328,7 @@ interface RouterState {
|
|
|
1346
1328
|
/**
|
|
1347
1329
|
* The current location reflected by the router
|
|
1348
1330
|
*/
|
|
1349
|
-
location: Location;
|
|
1331
|
+
location: Location$1;
|
|
1350
1332
|
/**
|
|
1351
1333
|
* The current set of route matches
|
|
1352
1334
|
*/
|
|
@@ -1407,7 +1389,10 @@ type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "e
|
|
|
1407
1389
|
/**
|
|
1408
1390
|
* Future flags to toggle new feature behavior
|
|
1409
1391
|
*/
|
|
1410
|
-
interface FutureConfig {
|
|
1392
|
+
interface FutureConfig {
|
|
1393
|
+
/** Enables route-pattern matching after calling `unstable_preloadRoutePattern()`. */
|
|
1394
|
+
unstable_routePatternMatching?: boolean;
|
|
1395
|
+
}
|
|
1411
1396
|
/**
|
|
1412
1397
|
* Initialization options for createRouter
|
|
1413
1398
|
*/
|
|
@@ -1439,6 +1424,8 @@ interface StaticHandlerContext {
|
|
|
1439
1424
|
loaderHeaders: Record<string, Headers>;
|
|
1440
1425
|
actionHeaders: Record<string, Headers>;
|
|
1441
1426
|
_deepestRenderedBoundaryId?: string | null;
|
|
1427
|
+
/** @private */
|
|
1428
|
+
_match: StaticHandler["match"];
|
|
1442
1429
|
}
|
|
1443
1430
|
/**
|
|
1444
1431
|
* A StaticHandler instance manages a singular SSR navigation/fetch event
|
|
@@ -1452,10 +1439,10 @@ interface StaticHandler {
|
|
|
1452
1439
|
* @private
|
|
1453
1440
|
* PRIVATE - DO NOT USE
|
|
1454
1441
|
*
|
|
1455
|
-
*
|
|
1456
|
-
* matching
|
|
1442
|
+
* Match routes against a location using the handler's configured route
|
|
1443
|
+
* matching implementation.
|
|
1457
1444
|
*/
|
|
1458
|
-
|
|
1445
|
+
match(locationArg: Partial<Location$1> | string): DataRouteMatch[] | null;
|
|
1459
1446
|
/**
|
|
1460
1447
|
* Perform a query for a given request - executing all matched route
|
|
1461
1448
|
* loaders/actions. Used for document requests.
|
|
@@ -1503,8 +1490,8 @@ interface StaticHandler {
|
|
|
1503
1490
|
}): Promise<any>;
|
|
1504
1491
|
}
|
|
1505
1492
|
type ViewTransitionOpts = {
|
|
1506
|
-
currentLocation: Location;
|
|
1507
|
-
nextLocation: Location;
|
|
1493
|
+
currentLocation: Location$1;
|
|
1494
|
+
nextLocation: Location$1;
|
|
1508
1495
|
};
|
|
1509
1496
|
/**
|
|
1510
1497
|
* Subscriber function signature for changes to router state
|
|
@@ -1522,7 +1509,7 @@ interface RouterSubscriber {
|
|
|
1522
1509
|
* for a given location
|
|
1523
1510
|
*/
|
|
1524
1511
|
interface GetScrollRestorationKeyFunction {
|
|
1525
|
-
(location: Location, matches: UIMatch[]): string | null;
|
|
1512
|
+
(location: Location$1, matches: UIMatch[]): string | null;
|
|
1526
1513
|
}
|
|
1527
1514
|
/**
|
|
1528
1515
|
* Function signature for determining the current scroll position
|
|
@@ -1604,7 +1591,7 @@ type NavigationStates = {
|
|
|
1604
1591
|
};
|
|
1605
1592
|
Loading: {
|
|
1606
1593
|
state: "loading";
|
|
1607
|
-
location: Location;
|
|
1594
|
+
location: Location$1;
|
|
1608
1595
|
matches: DataRouteMatch[];
|
|
1609
1596
|
historyAction: Action;
|
|
1610
1597
|
formMethod: Submission["formMethod"] | undefined;
|
|
@@ -1616,7 +1603,7 @@ type NavigationStates = {
|
|
|
1616
1603
|
};
|
|
1617
1604
|
Submitting: {
|
|
1618
1605
|
state: "submitting";
|
|
1619
|
-
location: Location;
|
|
1606
|
+
location: Location$1;
|
|
1620
1607
|
matches: DataRouteMatch[];
|
|
1621
1608
|
historyAction: Action;
|
|
1622
1609
|
formMethod: Submission["formMethod"];
|
|
@@ -1706,7 +1693,7 @@ interface BlockerBlocked {
|
|
|
1706
1693
|
state: "blocked";
|
|
1707
1694
|
reset: () => void;
|
|
1708
1695
|
proceed: () => void;
|
|
1709
|
-
location: Location;
|
|
1696
|
+
location: Location$1;
|
|
1710
1697
|
}
|
|
1711
1698
|
interface BlockerUnblocked {
|
|
1712
1699
|
state: "unblocked";
|
|
@@ -1718,12 +1705,12 @@ interface BlockerProceeding {
|
|
|
1718
1705
|
state: "proceeding";
|
|
1719
1706
|
reset: undefined;
|
|
1720
1707
|
proceed: undefined;
|
|
1721
|
-
location: Location;
|
|
1708
|
+
location: Location$1;
|
|
1722
1709
|
}
|
|
1723
1710
|
type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
|
|
1724
1711
|
type BlockerFunction = (args: {
|
|
1725
|
-
currentLocation: Location;
|
|
1726
|
-
nextLocation: Location;
|
|
1712
|
+
currentLocation: Location$1;
|
|
1713
|
+
nextLocation: Location$1;
|
|
1727
1714
|
historyAction: Action;
|
|
1728
1715
|
}) => boolean;
|
|
1729
1716
|
interface CreateStaticHandlerOptions {
|
|
@@ -2008,7 +1995,7 @@ type MetaMatches<MatchLoaders extends Record<string, LoaderFunction | ClientLoad
|
|
|
2008
1995
|
interface MetaArgs<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> {
|
|
2009
1996
|
loaderData: (Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown) | undefined;
|
|
2010
1997
|
params: Params;
|
|
2011
|
-
location: Location;
|
|
1998
|
+
location: Location$1;
|
|
2012
1999
|
matches: MetaMatches<MatchLoaders>;
|
|
2013
2000
|
error?: unknown;
|
|
2014
2001
|
}
|
|
@@ -2329,7 +2316,7 @@ type RSCRenderPayload = {
|
|
|
2329
2316
|
clientVersion?: string;
|
|
2330
2317
|
errors: Record<string, any> | null;
|
|
2331
2318
|
loaderData: Record<string, any>;
|
|
2332
|
-
location: Location;
|
|
2319
|
+
location: Location$1;
|
|
2333
2320
|
routeDiscovery: RouteDiscovery;
|
|
2334
2321
|
matches: RSCRouteMatch[];
|
|
2335
2322
|
patches?: Promise<RSCRouteManifest[]>;
|
|
@@ -2377,6 +2364,13 @@ type RouteDiscovery = {
|
|
|
2377
2364
|
* encoding an {@link unstable_RSCPayload} for consumption by an [RSC](https://react.dev/reference/rsc/server-components)
|
|
2378
2365
|
* enabled client router.
|
|
2379
2366
|
*
|
|
2367
|
+
* Treat every React Server Function as a public endpoint. Server Functions are
|
|
2368
|
+
* not inherently associated with a route. Any route middleware that runs is
|
|
2369
|
+
* selected from the URL used to call a Server Function, but the client controls
|
|
2370
|
+
* both the Server Function identifier and the URL. Perform all access control
|
|
2371
|
+
* checks within each Server Function, or use a route action for
|
|
2372
|
+
* middleware-driven access control.
|
|
2373
|
+
*
|
|
2380
2374
|
* @example
|
|
2381
2375
|
* import {
|
|
2382
2376
|
* createTemporaryReferenceSet,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.
|
|
2
|
+
* react-router v8.4.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -207,7 +207,8 @@ const unsupportedLazyRouteObjectKeys = new Set([
|
|
|
207
207
|
"path",
|
|
208
208
|
"id",
|
|
209
209
|
"index",
|
|
210
|
-
"children"
|
|
210
|
+
"children",
|
|
211
|
+
"unstable_validateParams"
|
|
211
212
|
]);
|
|
212
213
|
function isUnsupportedLazyRouteObjectKey(key) {
|
|
213
214
|
return unsupportedLazyRouteObjectKeys.has(key);
|
|
@@ -219,7 +220,8 @@ const unsupportedLazyRouteFunctionKeys = new Set([
|
|
|
219
220
|
"id",
|
|
220
221
|
"index",
|
|
221
222
|
"middleware",
|
|
222
|
-
"children"
|
|
223
|
+
"children",
|
|
224
|
+
"unstable_validateParams"
|
|
223
225
|
]);
|
|
224
226
|
function isUnsupportedLazyRouteFunctionKey(key) {
|
|
225
227
|
return unsupportedLazyRouteFunctionKeys.has(key);
|
|
@@ -1040,6 +1042,23 @@ function getReadonlyContext(context) {
|
|
|
1040
1042
|
return { get: (ctx) => context.get(ctx) };
|
|
1041
1043
|
}
|
|
1042
1044
|
//#endregion
|
|
1045
|
+
//#region lib/router/matcher.ts
|
|
1046
|
+
var V6RegExMatcher = class {
|
|
1047
|
+
#routes = [];
|
|
1048
|
+
#branches = [];
|
|
1049
|
+
#basename;
|
|
1050
|
+
constructor(basename) {
|
|
1051
|
+
this.#basename = basename;
|
|
1052
|
+
}
|
|
1053
|
+
update(routes) {
|
|
1054
|
+
this.#routes = routes;
|
|
1055
|
+
this.#branches = flattenAndRankRoutes(routes);
|
|
1056
|
+
}
|
|
1057
|
+
match(locationArg, allowPartial = false) {
|
|
1058
|
+
return matchRoutesImpl(this.#routes, locationArg, this.#basename, allowPartial, this.#branches);
|
|
1059
|
+
}
|
|
1060
|
+
};
|
|
1061
|
+
//#endregion
|
|
1043
1062
|
//#region lib/router/router.ts
|
|
1044
1063
|
const validMutationMethodsArr = [
|
|
1045
1064
|
"POST",
|
|
@@ -1058,6 +1077,14 @@ const redirectStatusCodes = new Set([
|
|
|
1058
1077
|
308
|
|
1059
1078
|
]);
|
|
1060
1079
|
const ResetLoaderDataSymbol = Symbol("ResetLoaderData");
|
|
1080
|
+
function createDataRouteMatcher(future, basename) {
|
|
1081
|
+
if (future.unstable_routePatternMatching) {
|
|
1082
|
+
let RoutePatternMatcher = void 0;
|
|
1083
|
+
invariant$1(RoutePatternMatcher, "You must call unstable_preloadRoutePattern() from \"react-router/route-pattern\" before enabling future.unstable_routePatternMatching.");
|
|
1084
|
+
return new RoutePatternMatcher(basename);
|
|
1085
|
+
}
|
|
1086
|
+
return new V6RegExMatcher(basename);
|
|
1087
|
+
}
|
|
1061
1088
|
/**
|
|
1062
1089
|
* Create a static handler to perform server-side data loading
|
|
1063
1090
|
*
|
|
@@ -1094,7 +1121,7 @@ function createStaticHandler(routes, opts) {
|
|
|
1094
1121
|
let basename = (opts ? opts.basename : null) || "/";
|
|
1095
1122
|
let _mapRouteProperties = opts?.mapRouteProperties;
|
|
1096
1123
|
let mapRouteProperties = _mapRouteProperties ? _mapRouteProperties : () => ({});
|
|
1097
|
-
({ ...opts?.future });
|
|
1124
|
+
let dataRouteMatcher = createDataRouteMatcher({ ...opts?.future }, basename);
|
|
1098
1125
|
if (opts?.instrumentations) {
|
|
1099
1126
|
let instrumentations = opts.instrumentations;
|
|
1100
1127
|
mapRouteProperties = (route) => {
|
|
@@ -1105,7 +1132,8 @@ function createStaticHandler(routes, opts) {
|
|
|
1105
1132
|
};
|
|
1106
1133
|
}
|
|
1107
1134
|
let dataRoutes = convertRoutesToDataRoutes(routes, mapRouteProperties, void 0, manifest);
|
|
1108
|
-
|
|
1135
|
+
dataRouteMatcher.update(dataRoutes);
|
|
1136
|
+
let match = (locationArg) => dataRouteMatcher.match(locationArg);
|
|
1109
1137
|
/**
|
|
1110
1138
|
* The query() method is intended for document requests, in which we want to
|
|
1111
1139
|
* call an optional action and potentially multiple loaders for all nested
|
|
@@ -1136,7 +1164,7 @@ function createStaticHandler(routes, opts) {
|
|
|
1136
1164
|
let normalizePathImpl = normalizePath || defaultNormalizePath;
|
|
1137
1165
|
let method = request.method;
|
|
1138
1166
|
let location = createLocation("", normalizePathImpl(request), null, "default");
|
|
1139
|
-
let matches =
|
|
1167
|
+
let matches = dataRouteMatcher.match(location);
|
|
1140
1168
|
requestContext = requestContext != null ? requestContext : new RouterContextProvider();
|
|
1141
1169
|
if (!isValidMethod(method) && method !== "HEAD") {
|
|
1142
1170
|
let error = getInternalRouterError(405, { method });
|
|
@@ -1150,7 +1178,8 @@ function createStaticHandler(routes, opts) {
|
|
|
1150
1178
|
errors: { [route.id]: error },
|
|
1151
1179
|
statusCode: error.status,
|
|
1152
1180
|
loaderHeaders: {},
|
|
1153
|
-
actionHeaders: {}
|
|
1181
|
+
actionHeaders: {},
|
|
1182
|
+
_match: match
|
|
1154
1183
|
};
|
|
1155
1184
|
return generateMiddlewareResponse ? generateMiddlewareResponse(() => Promise.resolve(staticContext)) : staticContext;
|
|
1156
1185
|
} else if (!matches) {
|
|
@@ -1165,7 +1194,8 @@ function createStaticHandler(routes, opts) {
|
|
|
1165
1194
|
errors: { [route.id]: error },
|
|
1166
1195
|
statusCode: error.status,
|
|
1167
1196
|
loaderHeaders: {},
|
|
1168
|
-
actionHeaders: {}
|
|
1197
|
+
actionHeaders: {},
|
|
1198
|
+
_match: match
|
|
1169
1199
|
};
|
|
1170
1200
|
return generateMiddlewareResponse ? generateMiddlewareResponse(() => Promise.resolve(staticContext)) : staticContext;
|
|
1171
1201
|
}
|
|
@@ -1188,7 +1218,8 @@ function createStaticHandler(routes, opts) {
|
|
|
1188
1218
|
renderedStaticContext = {
|
|
1189
1219
|
location,
|
|
1190
1220
|
basename,
|
|
1191
|
-
...result
|
|
1221
|
+
...result,
|
|
1222
|
+
_match: match
|
|
1192
1223
|
};
|
|
1193
1224
|
return renderedStaticContext;
|
|
1194
1225
|
});
|
|
@@ -1214,7 +1245,8 @@ function createStaticHandler(routes, opts) {
|
|
|
1214
1245
|
errors: { [skipLoaderErrorBubbling ? routeId : findNearestBoundary(matches, matches.find((m) => m.route.id === routeId || m.route.loader)?.route.id || routeId).route.id]: error },
|
|
1215
1246
|
statusCode: isRouteErrorResponse(error) ? error.status : 500,
|
|
1216
1247
|
actionHeaders: {},
|
|
1217
|
-
loaderHeaders: {}
|
|
1248
|
+
loaderHeaders: {},
|
|
1249
|
+
_match: match
|
|
1218
1250
|
};
|
|
1219
1251
|
return generateMiddlewareResponse(() => Promise.resolve(staticContext));
|
|
1220
1252
|
}
|
|
@@ -1231,7 +1263,8 @@ function createStaticHandler(routes, opts) {
|
|
|
1231
1263
|
return {
|
|
1232
1264
|
location,
|
|
1233
1265
|
basename,
|
|
1234
|
-
...result
|
|
1266
|
+
...result,
|
|
1267
|
+
_match: match
|
|
1235
1268
|
};
|
|
1236
1269
|
}
|
|
1237
1270
|
/**
|
|
@@ -1264,7 +1297,7 @@ function createStaticHandler(routes, opts) {
|
|
|
1264
1297
|
let normalizePathImpl = normalizePath || defaultNormalizePath;
|
|
1265
1298
|
let method = request.method;
|
|
1266
1299
|
let location = createLocation("", normalizePathImpl(request), null, "default");
|
|
1267
|
-
let matches =
|
|
1300
|
+
let matches = dataRouteMatcher.match(location);
|
|
1268
1301
|
requestContext = requestContext != null ? requestContext : new RouterContextProvider();
|
|
1269
1302
|
if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") throw getInternalRouterError(405, { method });
|
|
1270
1303
|
else if (!matches) throw getInternalRouterError(404, { pathname: location.pathname });
|
|
@@ -1445,7 +1478,7 @@ function createStaticHandler(routes, opts) {
|
|
|
1445
1478
|
}
|
|
1446
1479
|
return {
|
|
1447
1480
|
dataRoutes,
|
|
1448
|
-
|
|
1481
|
+
match,
|
|
1449
1482
|
query,
|
|
1450
1483
|
queryRoute
|
|
1451
1484
|
};
|
|
@@ -2337,6 +2370,13 @@ const Await = (async ({ children, resolve, errorElement }) => {
|
|
|
2337
2370
|
* encoding an {@link unstable_RSCPayload} for consumption by an [RSC](https://react.dev/reference/rsc/server-components)
|
|
2338
2371
|
* enabled client router.
|
|
2339
2372
|
*
|
|
2373
|
+
* Treat every React Server Function as a public endpoint. Server Functions are
|
|
2374
|
+
* not inherently associated with a route. Any route middleware that runs is
|
|
2375
|
+
* selected from the URL used to call a Server Function, but the client controls
|
|
2376
|
+
* both the Server Function identifier and the URL. Perform all access control
|
|
2377
|
+
* checks within each Server Function, or use a route action for
|
|
2378
|
+
* middleware-driven access control.
|
|
2379
|
+
*
|
|
2340
2380
|
* @example
|
|
2341
2381
|
* import {
|
|
2342
2382
|
* createTemporaryReferenceSet,
|
|
@@ -2424,11 +2464,12 @@ async function matchRSCServerRequest({ allowedActionOrigins, createTemporaryRefe
|
|
|
2424
2464
|
const requestUrl = new URL(request.url);
|
|
2425
2465
|
if (isManifestRequest(requestUrl)) return await generateManifestResponse(routes, basename, request, generateResponse, temporaryReferences, routeDiscovery, clientVersion);
|
|
2426
2466
|
let isDataRequest = isReactServerRequest(requestUrl);
|
|
2427
|
-
let
|
|
2467
|
+
let staticHandler = createStaticHandler(routes, { basename });
|
|
2468
|
+
let matches = staticHandler.match(url.pathname);
|
|
2428
2469
|
if (matches) await Promise.all(matches.map((m) => explodeLazyRoute(m.route)));
|
|
2429
2470
|
const leafMatch = matches?.[matches.length - 1];
|
|
2430
|
-
if (!isDataRequest && leafMatch && !leafMatch.route.Component && !leafMatch.route.ErrorBoundary) return generateResourceResponse(routerRequest,
|
|
2431
|
-
let response = await generateRenderResponse(routerRequest,
|
|
2471
|
+
if (!isDataRequest && leafMatch && !leafMatch.route.Component && !leafMatch.route.ErrorBoundary) return generateResourceResponse(routerRequest, staticHandler, leafMatch.route.id, requestContext, onError);
|
|
2472
|
+
let response = await generateRenderResponse(routerRequest, staticHandler, basename, isDataRequest, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, generateResponse, temporaryReferences, allowedActionOrigins, routeDiscovery, clientVersion);
|
|
2432
2473
|
response.headers.set("X-Remix-Response", "yes");
|
|
2433
2474
|
return response;
|
|
2434
2475
|
}
|
|
@@ -2461,9 +2502,10 @@ async function generateManifestResponse(routes, basename, request, generateRespo
|
|
|
2461
2502
|
}
|
|
2462
2503
|
let pathParam = url.searchParams.get("paths");
|
|
2463
2504
|
let pathnames = pathParam ? pathParam.split(",").filter(Boolean) : [url.pathname.replace(/\.manifest$/, "")];
|
|
2505
|
+
let staticHandler = routes.length > 0 ? createStaticHandler(routes, { basename }) : void 0;
|
|
2464
2506
|
let routeIds = /* @__PURE__ */ new Set();
|
|
2465
|
-
let matchedRoutes = pathnames.flatMap((pathname) => {
|
|
2466
|
-
let pathnameMatches =
|
|
2507
|
+
let matchedRoutes = staticHandler ? pathnames.flatMap((pathname) => {
|
|
2508
|
+
let pathnameMatches = staticHandler.match(pathname);
|
|
2467
2509
|
return pathnameMatches?.map((m, i) => ({
|
|
2468
2510
|
...m.route,
|
|
2469
2511
|
parentId: pathnameMatches[i - 1]?.route.id
|
|
@@ -2474,10 +2516,10 @@ async function generateManifestResponse(routes, basename, request, generateRespo
|
|
|
2474
2516
|
return true;
|
|
2475
2517
|
}
|
|
2476
2518
|
return false;
|
|
2477
|
-
});
|
|
2519
|
+
}) : [];
|
|
2478
2520
|
let payload = {
|
|
2479
2521
|
type: "manifest",
|
|
2480
|
-
patches: Promise.all([...matchedRoutes.map((route) => getManifestRoute(route)), getAdditionalRoutePatches(pathnames,
|
|
2522
|
+
patches: Promise.all([...matchedRoutes.map((route) => getManifestRoute(route)), staticHandler ? getAdditionalRoutePatches(pathnames, staticHandler, Array.from(routeIds)) : Promise.resolve([])]).then((r) => r.flat(1))
|
|
2481
2523
|
};
|
|
2482
2524
|
return generateResponse({
|
|
2483
2525
|
statusCode: 200,
|
|
@@ -2547,9 +2589,9 @@ async function processServerAction(request, basename, decodeReply, loadServerAct
|
|
|
2547
2589
|
}
|
|
2548
2590
|
}
|
|
2549
2591
|
}
|
|
2550
|
-
async function generateResourceResponse(request,
|
|
2592
|
+
async function generateResourceResponse(request, staticHandler, routeId, requestContext, onError) {
|
|
2551
2593
|
try {
|
|
2552
|
-
return await
|
|
2594
|
+
return await staticHandler.queryRoute(request, {
|
|
2553
2595
|
routeId,
|
|
2554
2596
|
requestContext,
|
|
2555
2597
|
async generateMiddlewareResponse(queryRoute) {
|
|
@@ -2590,12 +2632,11 @@ async function generateResourceResponse(request, routes, basename, routeId, requ
|
|
|
2590
2632
|
});
|
|
2591
2633
|
}
|
|
2592
2634
|
}
|
|
2593
|
-
async function generateRenderResponse(request,
|
|
2635
|
+
async function generateRenderResponse(request, staticHandler, basename, isDataRequest, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, generateResponse, temporaryReferences, allowedActionOrigins, routeDiscovery, clientVersion) {
|
|
2594
2636
|
let statusCode = 200;
|
|
2595
2637
|
let url = new URL(request.url);
|
|
2596
2638
|
let isSubmission = isMutationMethod(request.method);
|
|
2597
2639
|
let routeIdsToLoad = !isSubmission && url.searchParams.has("_routes") ? url.searchParams.get("_routes").split(",") : null;
|
|
2598
|
-
const staticHandler = createStaticHandler(routes, { basename });
|
|
2599
2640
|
let actionResult;
|
|
2600
2641
|
const ctx = {
|
|
2601
2642
|
request,
|
|
@@ -2643,7 +2684,7 @@ async function generateRenderResponse(request, routes, basename, isDataRequest,
|
|
|
2643
2684
|
staticContext.errors[staticContext.matches[0].route.id] = potentialCSRFAttackError;
|
|
2644
2685
|
staticContext.statusCode = 400;
|
|
2645
2686
|
}
|
|
2646
|
-
return generateStaticContextResponse(
|
|
2687
|
+
return generateStaticContextResponse(staticHandler, basename, generateResponse, statusCode, routeIdsToLoad, isDataRequest, isSubmission, actionResult, formState, staticContext, temporaryReferences, skipRevalidation, ctx.redirect?.headers, routeDiscovery, clientVersion);
|
|
2647
2688
|
}
|
|
2648
2689
|
}));
|
|
2649
2690
|
if (isRedirectResponse(result)) return generateRedirectResponse(result, actionResult, basename, isDataRequest, generateResponse, temporaryReferences, ctx.redirect?.headers);
|
|
@@ -2677,7 +2718,7 @@ function generateRedirectResponse(response, actionResult, basename, isDataReques
|
|
|
2677
2718
|
onError: defaultOnError
|
|
2678
2719
|
});
|
|
2679
2720
|
}
|
|
2680
|
-
async function generateStaticContextResponse(
|
|
2721
|
+
async function generateStaticContextResponse(staticHandler, basename, generateResponse, statusCode, routeIdsToLoad, isDataRequest, isSubmission, actionResult, formState, staticContext, temporaryReferences, skipRevalidation, sideEffectRedirectHeaders, routeDiscovery, clientVersion) {
|
|
2681
2722
|
statusCode = staticContext.statusCode ?? statusCode;
|
|
2682
2723
|
if (staticContext.errors) staticContext.errors = Object.fromEntries(Object.entries(staticContext.errors).map(([key, error]) => [key, isRouteErrorResponse(error) ? Object.fromEntries(Object.entries(error)) : error]));
|
|
2683
2724
|
staticContext.matches.forEach((m) => {
|
|
@@ -2698,7 +2739,7 @@ async function generateStaticContextResponse(routes, basename, generateResponse,
|
|
|
2698
2739
|
location: staticContext.location,
|
|
2699
2740
|
formState
|
|
2700
2741
|
};
|
|
2701
|
-
const renderPayloadPromise = () => getRenderPayload(baseRenderPayload,
|
|
2742
|
+
const renderPayloadPromise = () => getRenderPayload(baseRenderPayload, staticHandler, basename, routeIdsToLoad, isDataRequest, staticContext, routeDiscovery);
|
|
2702
2743
|
let payload;
|
|
2703
2744
|
if (actionResult) payload = {
|
|
2704
2745
|
type: "action",
|
|
@@ -2720,7 +2761,8 @@ async function generateStaticContextResponse(routes, basename, generateResponse,
|
|
|
2720
2761
|
onError: defaultOnError
|
|
2721
2762
|
});
|
|
2722
2763
|
}
|
|
2723
|
-
async function getRenderPayload(baseRenderPayload,
|
|
2764
|
+
async function getRenderPayload(baseRenderPayload, staticHandler, basename, routeIdsToLoad, isDataRequest, staticContext, routeDiscovery) {
|
|
2765
|
+
let routes = staticHandler.dataRoutes;
|
|
2724
2766
|
let deepestRenderedRouteIdx = staticContext.matches.length - 1;
|
|
2725
2767
|
let parentIds = {};
|
|
2726
2768
|
staticContext.matches.forEach((m, i) => {
|
|
@@ -2738,7 +2780,9 @@ async function getRenderPayload(baseRenderPayload, routes, basename, routeIdsToL
|
|
|
2738
2780
|
parentId
|
|
2739
2781
|
});
|
|
2740
2782
|
}));
|
|
2741
|
-
let patches
|
|
2783
|
+
let patches;
|
|
2784
|
+
if (routeDiscovery?.mode === "initial" && !isDataRequest) patches = getAllRoutePatches(routes, basename).then((patches) => patches.filter((patch) => !staticContext.matches.some((m) => m.route.id === patch.id)));
|
|
2785
|
+
else patches = getAdditionalRoutePatches(getPathsWithAncestors([staticContext.location.pathname]), staticHandler, staticContext.matches.map((m) => m.route.id));
|
|
2742
2786
|
return {
|
|
2743
2787
|
...baseRenderPayload,
|
|
2744
2788
|
matches: await matchesPromise,
|
|
@@ -2842,13 +2886,13 @@ async function getAllRoutePatches(routes, basename) {
|
|
|
2842
2886
|
for (let route of routes) await traverse(route, void 0);
|
|
2843
2887
|
return patches.filter((p) => !!p.parentId);
|
|
2844
2888
|
}
|
|
2845
|
-
async function getAdditionalRoutePatches(pathnames,
|
|
2889
|
+
async function getAdditionalRoutePatches(pathnames, staticHandler, matchedRouteIds) {
|
|
2846
2890
|
let patchRouteMatches = /* @__PURE__ */ new Map();
|
|
2847
2891
|
let matchedPaths = /* @__PURE__ */ new Set();
|
|
2848
2892
|
for (const pathname of pathnames) {
|
|
2849
2893
|
if (matchedPaths.has(pathname)) continue;
|
|
2850
2894
|
matchedPaths.add(pathname);
|
|
2851
|
-
let matches =
|
|
2895
|
+
let matches = staticHandler.match(pathname) || [];
|
|
2852
2896
|
matches.forEach((m, i) => {
|
|
2853
2897
|
if (patchRouteMatches.get(m.route.id)) return;
|
|
2854
2898
|
patchRouteMatches.set(m.route.id, {
|
|
@@ -4,7 +4,7 @@ import { ActionFunction, ActionFunctionArgs, BaseRouteObject, DataRouteMatch, Da
|
|
|
4
4
|
import { Blocker, BlockerFunction, Fetcher, GetScrollPositionFunction, GetScrollRestorationKeyFunction, HydrationState, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, Navigation, NavigationStates, RelativeRoutingType, RevalidationState, Router, RouterFetchOptions, RouterInit, RouterNavigateOptions, RouterState, RouterSubscriber, StaticHandler, StaticHandlerContext, createRouter, createStaticHandler } from "./lib/router/router.js";
|
|
5
5
|
import { HtmlLinkDescriptor, LinkDescriptor, PageLinkDescriptor } from "./lib/router/links.js";
|
|
6
6
|
import { Await, AwaitProps, ClientOnErrorFunction, IndexRouteProps, LayoutRouteProps, MemoryRouter, MemoryRouterOpts, MemoryRouterProps, Navigate, NavigateProps, Outlet, OutletProps, PathRouteProps, Route, RouteProps, Router as Router$1, RouterProps, RouterProvider, RouterProviderProps, Routes, RoutesProps, WithComponentProps, WithErrorBoundaryProps, WithHydrateFallbackProps, createMemoryRouter, createRoutesFromChildren, createRoutesFromElements, hydrationRouteProperties, renderMatches, withComponentProps, withErrorBoundaryProps, withHydrateFallbackProps } from "./lib/components.js";
|
|
7
|
-
import { AwaitContextProvider, DataRouterContext, DataRouterStateContext, FetchersContext, LocationContext, NavigateOptions, NavigationContext, Navigator, RouteContext, ViewTransitionContext } from "./lib/context.js";
|
|
7
|
+
import { AwaitContextProvider, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, LocationContext, NavigateOptions, NavigationContext, Navigator, RouteContext, ViewTransitionContext } from "./lib/context.js";
|
|
8
8
|
import { Register } from "./lib/types/register.js";
|
|
9
9
|
import { NavigateFunction, unstable_RouterState, unstable_RouterStateActiveVariant, unstable_RouterStatePendingVariant, useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRoute, useRouteError, useRouteLoaderData, useRouterState, useRoutes } from "./lib/hooks.js";
|
|
10
10
|
import { FetcherSubmitOptions, ParamKeyValuePair, SubmitOptions, SubmitTarget, URLSearchParamsInit, createSearchParams } from "./lib/dom/dom.js";
|
|
@@ -41,4 +41,4 @@ import { ClientInstrumentation, InstrumentRequestHandlerFunction, InstrumentRout
|
|
|
41
41
|
declare const unstable_getRequest: typeof getRequest;
|
|
42
42
|
declare const unstable_matchRSCServerRequest: typeof matchRSCServerRequest;
|
|
43
43
|
//#endregion
|
|
44
|
-
export { type ActionFunction, type ActionFunctionArgs, Await, type AwaitProps, type BaseRouteObject, type Blocker, type BlockerFunction, BrowserRouter, type BrowserRouterProps, type ClientActionFunction, type ClientActionFunctionArgs, type ClientInstrumentation, type ClientLoaderFunction, type ClientLoaderFunctionArgs, type ClientOnErrorFunction, type Cookie, type CookieOptions, type CookieParseOptions, type CookieSerializeOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, type DOMRouterOpts, type DataRouteMatch, type DataRouteObject, type Router as DataRouter, type DataStrategyFunction, type DataStrategyFunctionArgs, type DataStrategyMatch, type DataStrategyResult, type DiscoverBehavior, type EntryContext, type ErrorResponse, type Fetcher, type FetcherFormProps, type FetcherSubmitFunction, type FetcherSubmitOptions, type FetcherWithComponents, type FlashSessionData, Form, type FormEncType, type FormMethod, type FormProps, type Future, type GetScrollPositionFunction, type GetScrollRestorationKeyFunction, type HTMLFormMethod, type HandleDataRequestFunction, type HandleDocumentRequestFunction, type HandleErrorFunction, HashRouter, type HashRouterProps, type HeadersArgs, type HeadersFunction, type HistoryRouterProps, type HtmlLinkDescriptor, type HydrationState, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, type IndexRouteObject, type IndexRouteProps, type InitialEntry, type InstrumentRequestHandlerFunction, type InstrumentRouteFunction, type InstrumentRouterFunction, type InstrumentationClientRouterResult, type InstrumentationHandlerResult, type InstrumentationServerHandlerResult, type IsCookieFunction, type IsSessionFunction, type LayoutRouteProps, type LazyRouteFunction, Link, type LinkDescriptor, type LinkProps, Links, type LinksFunction, type LinksProps, type LoaderFunction, type LoaderFunctionArgs, type Location, MemoryRouter, type MemoryRouterOpts, type MemoryRouterProps, Meta, type MetaArgs, type MetaDescriptor, type MetaFunction, type MiddlewareFunction, NavLink, type NavLinkProps, type NavLinkRenderProps, Navigate, type NavigateFunction, type NavigateOptions, type NavigateProps, type Navigation, type NavigationStates, Action as NavigationType, type Navigator, type NonIndexRouteObject, Outlet, type OutletProps, type PageLinkDescriptor, type ParamKeyValuePair, type ParamParseKey, type Params, type PatchRoutesOnNavigationFunction, type PatchRoutesOnNavigationFunctionArgs, type Path, type PathMatch, type PathParam, type PathPattern, type PathRouteProps, type PrefetchBehavior, PrefetchPageLinks, type RedirectFunction, type Register, type RelativeRoutingType, type RequestHandler, type RevalidationState, Route, type RouteMatch, type RouteObject, type RouteProps, Router$1 as Router, type RouterContext, RouterContextProvider, type RouterFetchOptions, type RouterInit, type RouterNavigateOptions, type RouterProps, RouterProvider, type RouterProviderProps, type RouterState, type RouterSubscriber, Routes, type RoutesProps, type RoutesTestStubProps, Scripts, type ScriptsProps, ScrollRestoration, type ScrollRestorationProps, type ServerBuild, type ServerEntryModule, type ServerInstrumentation, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, type SetURLSearchParams, type ShouldRevalidateFunction, type ShouldRevalidateFunctionArgs, type StaticHandler, type StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, type SubmitFunction, type SubmitOptions, type SubmitTarget, type To, type UIMatch, type AssetsManifest as UNSAFE_AssetsManifest, AwaitContextProvider as UNSAFE_AwaitContextProvider, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, type DataWithResponseInit as UNSAFE_DataWithResponseInit, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, FetchersContext as UNSAFE_FetchersContext, FrameworkContext as UNSAFE_FrameworkContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RSCDefaultRootErrorBoundary as UNSAFE_RSCDefaultRootErrorBoundary, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteContext as UNSAFE_RouteContext, type RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, ViewTransitionContext as UNSAFE_ViewTransitionContext, WithComponentProps as UNSAFE_WithComponentProps, WithErrorBoundaryProps as UNSAFE_WithErrorBoundaryProps, WithHydrateFallbackProps as UNSAFE_WithHydrateFallbackProps, createBrowserHistory as UNSAFE_createBrowserHistory, createClientRoutes as UNSAFE_createClientRoutes, createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, createHashHistory as UNSAFE_createHashHistory, createMemoryHistory as UNSAFE_createMemoryHistory, createRouter as UNSAFE_createRouter, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, defaultMapRouteProperties as UNSAFE_defaultMapRouteProperties, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, hydrationRouteProperties as UNSAFE_hydrationRouteProperties, invariant as UNSAFE_invariant, shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, useScrollRestoration as UNSAFE_useScrollRestoration, withComponentProps as UNSAFE_withComponentProps, withErrorBoundaryProps as UNSAFE_withErrorBoundaryProps, withHydrateFallbackProps as UNSAFE_withHydrateFallbackProps, type URLSearchParamsInit, createBrowserRouter, createContext, createCookie, createCookieSessionStorage, createHashRouter, createMemoryRouter, createMemorySessionStorage, createPath, createRequestHandler, createRoutesFromChildren, createRoutesFromElements, createRoutesStub, createSearchParams, createSession, createSessionStorage, createStaticHandler, createStaticRouter, data, generatePath, href, isCookie, isRouteErrorResponse, isSession, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, replace, resolvePath, type BrowserCreateFromReadableStreamFunction as unstable_BrowserCreateFromReadableStreamFunction, type DecodeActionFunction as unstable_DecodeActionFunction, type DecodeFormStateFunction as unstable_DecodeFormStateFunction, type DecodeReplyFunction as unstable_DecodeReplyFunction, type EncodeReplyFunction as unstable_EncodeReplyFunction, HistoryRouter as unstable_HistoryRouter, type LoadServerActionFunction as unstable_LoadServerActionFunction, type RSCHydratedRouterProps as unstable_RSCHydratedRouterProps, type RSCManifestPayload as unstable_RSCManifestPayload, type RSCMatch as unstable_RSCMatch, type RSCPayload as unstable_RSCPayload, type RSCRenderPayload as unstable_RSCRenderPayload, type RSCRouteConfig as unstable_RSCRouteConfig, type RSCRouteConfigEntry as unstable_RSCRouteConfigEntry, type RSCRouteManifest as unstable_RSCRouteManifest, type RSCRouteMatch as unstable_RSCRouteMatch, RSCStaticRouter as unstable_RSCStaticRouter, type RSCStaticRouterProps as unstable_RSCStaticRouterProps, type unstable_RouterState, type unstable_RouterStateActiveVariant, type unstable_RouterStatePendingVariant, type SSRCreateFromReadableStreamFunction as unstable_SSRCreateFromReadableStreamFunction, type unstable_SerializesTo, unstable_getRequest, unstable_matchRSCServerRequest, routeRSCServerRequest as unstable_routeRSCServerRequest, setDevServerHooks as unstable_setDevServerHooks, usePrompt as unstable_usePrompt, useRoute as unstable_useRoute, useRouterState as unstable_useRouterState, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useBlocker, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, useViewTransitionState };
|
|
44
|
+
export { type ActionFunction, type ActionFunctionArgs, Await, type AwaitProps, type BaseRouteObject, type Blocker, type BlockerFunction, BrowserRouter, type BrowserRouterProps, type ClientActionFunction, type ClientActionFunctionArgs, type ClientInstrumentation, type ClientLoaderFunction, type ClientLoaderFunctionArgs, type ClientOnErrorFunction, type Cookie, type CookieOptions, type CookieParseOptions, type CookieSerializeOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, type DOMRouterOpts, type DataRouteMatch, type DataRouteObject, type Router as DataRouter, type DataStrategyFunction, type DataStrategyFunctionArgs, type DataStrategyMatch, type DataStrategyResult, type DiscoverBehavior, type EntryContext, type ErrorResponse, type Fetcher, type FetcherFormProps, type FetcherSubmitFunction, type FetcherSubmitOptions, type FetcherWithComponents, type FlashSessionData, Form, type FormEncType, type FormMethod, type FormProps, type Future, type GetScrollPositionFunction, type GetScrollRestorationKeyFunction, type HTMLFormMethod, type HandleDataRequestFunction, type HandleDocumentRequestFunction, type HandleErrorFunction, HashRouter, type HashRouterProps, type HeadersArgs, type HeadersFunction, type HistoryRouterProps, type HtmlLinkDescriptor, type HydrationState, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, type IndexRouteObject, type IndexRouteProps, type InitialEntry, type InstrumentRequestHandlerFunction, type InstrumentRouteFunction, type InstrumentRouterFunction, type InstrumentationClientRouterResult, type InstrumentationHandlerResult, type InstrumentationServerHandlerResult, type IsCookieFunction, type IsSessionFunction, type LayoutRouteProps, type LazyRouteFunction, Link, type LinkDescriptor, type LinkProps, Links, type LinksFunction, type LinksProps, type LoaderFunction, type LoaderFunctionArgs, type Location, MemoryRouter, type MemoryRouterOpts, type MemoryRouterProps, Meta, type MetaArgs, type MetaDescriptor, type MetaFunction, type MiddlewareFunction, NavLink, type NavLinkProps, type NavLinkRenderProps, Navigate, type NavigateFunction, type NavigateOptions, type NavigateProps, type Navigation, type NavigationStates, Action as NavigationType, type Navigator, type NonIndexRouteObject, Outlet, type OutletProps, type PageLinkDescriptor, type ParamKeyValuePair, type ParamParseKey, type Params, type PatchRoutesOnNavigationFunction, type PatchRoutesOnNavigationFunctionArgs, type Path, type PathMatch, type PathParam, type PathPattern, type PathRouteProps, type PrefetchBehavior, PrefetchPageLinks, type RedirectFunction, type Register, type RelativeRoutingType, type RequestHandler, type RevalidationState, Route, type RouteMatch, type RouteObject, type RouteProps, Router$1 as Router, type RouterContext, RouterContextProvider, type RouterFetchOptions, type RouterInit, type RouterNavigateOptions, type RouterProps, RouterProvider, type RouterProviderProps, type RouterState, type RouterSubscriber, Routes, type RoutesProps, type RoutesTestStubProps, Scripts, type ScriptsProps, ScrollRestoration, type ScrollRestorationProps, type ServerBuild, type ServerEntryModule, type ServerInstrumentation, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, type SetURLSearchParams, type ShouldRevalidateFunction, type ShouldRevalidateFunctionArgs, type StaticHandler, type StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, type SubmitFunction, type SubmitOptions, type SubmitTarget, type To, type UIMatch, type AssetsManifest as UNSAFE_AssetsManifest, AwaitContextProvider as UNSAFE_AwaitContextProvider, DataRouterContext as UNSAFE_DataRouterContext, DataRouterDataContext as UNSAFE_DataRouterDataContext, DataRouterNavigationContext as UNSAFE_DataRouterNavigationContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, type DataWithResponseInit as UNSAFE_DataWithResponseInit, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, FetchersContext as UNSAFE_FetchersContext, FrameworkContext as UNSAFE_FrameworkContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RSCDefaultRootErrorBoundary as UNSAFE_RSCDefaultRootErrorBoundary, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteContext as UNSAFE_RouteContext, type RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, ViewTransitionContext as UNSAFE_ViewTransitionContext, WithComponentProps as UNSAFE_WithComponentProps, WithErrorBoundaryProps as UNSAFE_WithErrorBoundaryProps, WithHydrateFallbackProps as UNSAFE_WithHydrateFallbackProps, createBrowserHistory as UNSAFE_createBrowserHistory, createClientRoutes as UNSAFE_createClientRoutes, createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, createHashHistory as UNSAFE_createHashHistory, createMemoryHistory as UNSAFE_createMemoryHistory, createRouter as UNSAFE_createRouter, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, defaultMapRouteProperties as UNSAFE_defaultMapRouteProperties, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, hydrationRouteProperties as UNSAFE_hydrationRouteProperties, invariant as UNSAFE_invariant, shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, useScrollRestoration as UNSAFE_useScrollRestoration, withComponentProps as UNSAFE_withComponentProps, withErrorBoundaryProps as UNSAFE_withErrorBoundaryProps, withHydrateFallbackProps as UNSAFE_withHydrateFallbackProps, type URLSearchParamsInit, createBrowserRouter, createContext, createCookie, createCookieSessionStorage, createHashRouter, createMemoryRouter, createMemorySessionStorage, createPath, createRequestHandler, createRoutesFromChildren, createRoutesFromElements, createRoutesStub, createSearchParams, createSession, createSessionStorage, createStaticHandler, createStaticRouter, data, generatePath, href, isCookie, isRouteErrorResponse, isSession, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, replace, resolvePath, type BrowserCreateFromReadableStreamFunction as unstable_BrowserCreateFromReadableStreamFunction, type DecodeActionFunction as unstable_DecodeActionFunction, type DecodeFormStateFunction as unstable_DecodeFormStateFunction, type DecodeReplyFunction as unstable_DecodeReplyFunction, type EncodeReplyFunction as unstable_EncodeReplyFunction, HistoryRouter as unstable_HistoryRouter, type LoadServerActionFunction as unstable_LoadServerActionFunction, type RSCHydratedRouterProps as unstable_RSCHydratedRouterProps, type RSCManifestPayload as unstable_RSCManifestPayload, type RSCMatch as unstable_RSCMatch, type RSCPayload as unstable_RSCPayload, type RSCRenderPayload as unstable_RSCRenderPayload, type RSCRouteConfig as unstable_RSCRouteConfig, type RSCRouteConfigEntry as unstable_RSCRouteConfigEntry, type RSCRouteManifest as unstable_RSCRouteManifest, type RSCRouteMatch as unstable_RSCRouteMatch, RSCStaticRouter as unstable_RSCStaticRouter, type RSCStaticRouterProps as unstable_RSCStaticRouterProps, type unstable_RouterState, type unstable_RouterStateActiveVariant, type unstable_RouterStatePendingVariant, type SSRCreateFromReadableStreamFunction as unstable_SSRCreateFromReadableStreamFunction, type unstable_SerializesTo, unstable_getRequest, unstable_matchRSCServerRequest, routeRSCServerRequest as unstable_routeRSCServerRequest, setDevServerHooks as unstable_setDevServerHooks, usePrompt as unstable_usePrompt, useRoute as unstable_useRoute, useRouterState as unstable_useRouterState, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useBlocker, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, useViewTransitionState };
|