react-router 0.0.0-experimental-320d16107 → 0.0.0-experimental-917e6fdc0
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/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 +29 -29
- package/dist/development/index-react-server.js +33 -252
- package/dist/development/index.js +1 -1
- package/dist/development/lib/actions.js +10 -5
- package/dist/development/lib/components.js +10 -8
- package/dist/development/lib/context.d.ts +1 -0
- package/dist/development/lib/context.js +1 -1
- package/dist/development/lib/dom/dom.js +1 -1
- package/dist/development/lib/dom/lib.js +16 -1
- package/dist/development/lib/dom/server.d.ts +1 -6
- package/dist/development/lib/dom/server.js +9 -13
- package/dist/development/lib/dom/ssr/components.js +5 -4
- 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 +4 -3
- package/dist/development/lib/dom/ssr/hydration.d.ts +1 -3
- package/dist/development/lib/dom/ssr/hydration.js +4 -6
- 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.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 +1 -1
- package/dist/development/lib/dom-export/dom-router-provider.js +1 -1
- package/dist/development/lib/dom-export/hydrated-router.js +1 -2
- package/dist/development/lib/errors.js +1 -1
- package/dist/development/lib/hooks.js +7 -7
- 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/navigation.js +45 -0
- package/dist/development/lib/router/router.d.ts +11 -6
- package/dist/development/lib/router/router.js +67 -51
- package/dist/development/lib/router/url.js +1 -1
- package/dist/development/lib/router/utils.d.ts +1 -6
- package/dist/development/lib/router/utils.js +11 -9
- package/dist/development/lib/rsc/browser.js +4 -2
- package/dist/development/lib/rsc/errorBoundaries.js +1 -1
- package/dist/development/lib/rsc/html-stream/browser.js +1 -1
- package/dist/development/lib/rsc/html-stream/server.js +1 -1
- package/dist/development/lib/rsc/route-modules.js +1 -1
- package/dist/development/lib/rsc/server.ssr.js +1 -1
- package/dist/development/lib/server-runtime/cookies.js +1 -1
- package/dist/development/lib/server-runtime/crypto.js +1 -1
- package/dist/development/lib/server-runtime/data.js +1 -1
- package/dist/development/lib/server-runtime/dev.js +1 -1
- package/dist/development/lib/server-runtime/entry.js +1 -1
- package/dist/development/lib/server-runtime/errors.js +1 -1
- package/dist/development/lib/server-runtime/headers.js +1 -1
- package/dist/development/lib/server-runtime/invariant.js +1 -1
- package/dist/development/lib/server-runtime/mode.js +1 -1
- package/dist/development/lib/server-runtime/routeMatching.js +4 -3
- package/dist/development/lib/server-runtime/routes.js +1 -1
- package/dist/development/lib/server-runtime/server.js +6 -8
- 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/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 +29 -29
- package/dist/production/index-react-server.js +33 -252
- package/dist/production/index.js +1 -1
- package/dist/production/lib/actions.js +10 -5
- package/dist/production/lib/components.js +10 -8
- package/dist/production/lib/context.d.ts +1 -0
- package/dist/production/lib/context.js +1 -1
- package/dist/production/lib/dom/dom.js +1 -1
- package/dist/production/lib/dom/lib.js +16 -1
- package/dist/production/lib/dom/server.d.ts +1 -6
- package/dist/production/lib/dom/server.js +9 -13
- package/dist/production/lib/dom/ssr/components.js +5 -4
- 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 +4 -3
- package/dist/production/lib/dom/ssr/hydration.d.ts +1 -3
- package/dist/production/lib/dom/ssr/hydration.js +4 -6
- 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.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 +1 -1
- package/dist/production/lib/dom-export/dom-router-provider.js +1 -1
- package/dist/production/lib/dom-export/hydrated-router.js +1 -2
- package/dist/production/lib/errors.js +1 -1
- package/dist/production/lib/hooks.js +7 -7
- 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/navigation.js +45 -0
- package/dist/production/lib/router/router.d.ts +11 -6
- package/dist/production/lib/router/router.js +67 -51
- package/dist/production/lib/router/url.js +1 -1
- package/dist/production/lib/router/utils.d.ts +1 -6
- package/dist/production/lib/router/utils.js +11 -9
- package/dist/production/lib/rsc/browser.js +4 -2
- package/dist/production/lib/rsc/errorBoundaries.js +1 -1
- package/dist/production/lib/rsc/html-stream/browser.js +1 -1
- package/dist/production/lib/rsc/html-stream/server.js +1 -1
- package/dist/production/lib/rsc/route-modules.js +1 -1
- package/dist/production/lib/rsc/server.ssr.js +1 -1
- package/dist/production/lib/server-runtime/cookies.js +1 -1
- package/dist/production/lib/server-runtime/crypto.js +1 -1
- package/dist/production/lib/server-runtime/data.js +1 -1
- package/dist/production/lib/server-runtime/dev.js +1 -1
- package/dist/production/lib/server-runtime/entry.js +1 -1
- package/dist/production/lib/server-runtime/errors.js +1 -1
- package/dist/production/lib/server-runtime/headers.js +1 -1
- package/dist/production/lib/server-runtime/invariant.js +1 -1
- package/dist/production/lib/server-runtime/mode.js +1 -1
- package/dist/production/lib/server-runtime/routeMatching.js +4 -3
- package/dist/production/lib/server-runtime/routes.js +1 -1
- package/dist/production/lib/server-runtime/server.js +6 -8
- 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/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/package.json +1 -2
- package/dist/development/lib/router/matcher-route-pattern.js +0 -207
- package/dist/development/lib/router/matcher.d.ts +0 -2
- package/dist/development/lib/router/matcher.js +0 -30
- package/dist/production/lib/router/matcher-route-pattern.js +0 -207
- package/dist/production/lib/router/matcher.d.ts +0 -2
- package/dist/production/lib/router/matcher.js +0 -30
|
@@ -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
|
|
53
|
+
interface Location<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;
|
|
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;
|
|
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";
|
|
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,11 +655,6 @@ 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>;
|
|
663
658
|
/**
|
|
664
659
|
* The route handle.
|
|
665
660
|
*/
|
|
@@ -796,7 +791,7 @@ interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {}
|
|
|
796
791
|
* Defaults to `/`.
|
|
797
792
|
* @returns An array of matched routes, or `null` if no matches were found.
|
|
798
793
|
*/
|
|
799
|
-
declare function matchRoutes<RouteObjectType extends RouteObject = RouteObject>(routes: RouteObjectType[], locationArg: Partial<Location
|
|
794
|
+
declare function matchRoutes<RouteObjectType extends RouteObject = RouteObject>(routes: RouteObjectType[], locationArg: Partial<Location> | string, basename?: string): RouteMatch<string, RouteObjectType>[] | null;
|
|
800
795
|
interface UIMatch<Data = unknown, Handle = unknown> {
|
|
801
796
|
id: string;
|
|
802
797
|
pathname: string;
|
|
@@ -1148,10 +1143,9 @@ interface Router$1 {
|
|
|
1148
1143
|
* @private
|
|
1149
1144
|
* PRIVATE - DO NOT USE
|
|
1150
1145
|
*
|
|
1151
|
-
*
|
|
1152
|
-
* matching implementation.
|
|
1146
|
+
* Return the route branches for this router instance
|
|
1153
1147
|
*/
|
|
1154
|
-
|
|
1148
|
+
get branches(): RouteBranch<DataRouteObject>[] | undefined;
|
|
1155
1149
|
/**
|
|
1156
1150
|
* @private
|
|
1157
1151
|
* PRIVATE - DO NOT USE
|
|
@@ -1236,7 +1230,15 @@ interface Router$1 {
|
|
|
1236
1230
|
* Utility function to create an href for the given location
|
|
1237
1231
|
* @param location
|
|
1238
1232
|
*/
|
|
1239
|
-
createHref(location: Location
|
|
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;
|
|
1240
1242
|
/**
|
|
1241
1243
|
* @private
|
|
1242
1244
|
* PRIVATE - DO NOT USE
|
|
@@ -1344,7 +1346,7 @@ interface RouterState {
|
|
|
1344
1346
|
/**
|
|
1345
1347
|
* The current location reflected by the router
|
|
1346
1348
|
*/
|
|
1347
|
-
location: Location
|
|
1349
|
+
location: Location;
|
|
1348
1350
|
/**
|
|
1349
1351
|
* The current set of route matches
|
|
1350
1352
|
*/
|
|
@@ -1405,9 +1407,7 @@ type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "e
|
|
|
1405
1407
|
/**
|
|
1406
1408
|
* Future flags to toggle new feature behavior
|
|
1407
1409
|
*/
|
|
1408
|
-
interface FutureConfig {
|
|
1409
|
-
unstable_routePatternMatching?: boolean;
|
|
1410
|
-
}
|
|
1410
|
+
interface FutureConfig {}
|
|
1411
1411
|
/**
|
|
1412
1412
|
* Initialization options for createRouter
|
|
1413
1413
|
*/
|
|
@@ -1503,8 +1503,8 @@ interface StaticHandler {
|
|
|
1503
1503
|
}): Promise<any>;
|
|
1504
1504
|
}
|
|
1505
1505
|
type ViewTransitionOpts = {
|
|
1506
|
-
currentLocation: Location
|
|
1507
|
-
nextLocation: Location
|
|
1506
|
+
currentLocation: Location;
|
|
1507
|
+
nextLocation: Location;
|
|
1508
1508
|
};
|
|
1509
1509
|
/**
|
|
1510
1510
|
* Subscriber function signature for changes to router state
|
|
@@ -1522,7 +1522,7 @@ interface RouterSubscriber {
|
|
|
1522
1522
|
* for a given location
|
|
1523
1523
|
*/
|
|
1524
1524
|
interface GetScrollRestorationKeyFunction {
|
|
1525
|
-
(location: Location
|
|
1525
|
+
(location: Location, matches: UIMatch[]): string | null;
|
|
1526
1526
|
}
|
|
1527
1527
|
/**
|
|
1528
1528
|
* Function signature for determining the current scroll position
|
|
@@ -1604,7 +1604,7 @@ type NavigationStates = {
|
|
|
1604
1604
|
};
|
|
1605
1605
|
Loading: {
|
|
1606
1606
|
state: "loading";
|
|
1607
|
-
location: Location
|
|
1607
|
+
location: Location;
|
|
1608
1608
|
matches: DataRouteMatch[];
|
|
1609
1609
|
historyAction: Action;
|
|
1610
1610
|
formMethod: Submission["formMethod"] | undefined;
|
|
@@ -1616,7 +1616,7 @@ type NavigationStates = {
|
|
|
1616
1616
|
};
|
|
1617
1617
|
Submitting: {
|
|
1618
1618
|
state: "submitting";
|
|
1619
|
-
location: Location
|
|
1619
|
+
location: Location;
|
|
1620
1620
|
matches: DataRouteMatch[];
|
|
1621
1621
|
historyAction: Action;
|
|
1622
1622
|
formMethod: Submission["formMethod"];
|
|
@@ -1706,7 +1706,7 @@ interface BlockerBlocked {
|
|
|
1706
1706
|
state: "blocked";
|
|
1707
1707
|
reset: () => void;
|
|
1708
1708
|
proceed: () => void;
|
|
1709
|
-
location: Location
|
|
1709
|
+
location: Location;
|
|
1710
1710
|
}
|
|
1711
1711
|
interface BlockerUnblocked {
|
|
1712
1712
|
state: "unblocked";
|
|
@@ -1718,12 +1718,12 @@ interface BlockerProceeding {
|
|
|
1718
1718
|
state: "proceeding";
|
|
1719
1719
|
reset: undefined;
|
|
1720
1720
|
proceed: undefined;
|
|
1721
|
-
location: Location
|
|
1721
|
+
location: Location;
|
|
1722
1722
|
}
|
|
1723
1723
|
type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
|
|
1724
1724
|
type BlockerFunction = (args: {
|
|
1725
|
-
currentLocation: Location
|
|
1726
|
-
nextLocation: Location
|
|
1725
|
+
currentLocation: Location;
|
|
1726
|
+
nextLocation: Location;
|
|
1727
1727
|
historyAction: Action;
|
|
1728
1728
|
}) => boolean;
|
|
1729
1729
|
interface CreateStaticHandlerOptions {
|
|
@@ -2008,7 +2008,7 @@ type MetaMatches<MatchLoaders extends Record<string, LoaderFunction | ClientLoad
|
|
|
2008
2008
|
interface MetaArgs<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> {
|
|
2009
2009
|
loaderData: (Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown) | undefined;
|
|
2010
2010
|
params: Params;
|
|
2011
|
-
location: Location
|
|
2011
|
+
location: Location;
|
|
2012
2012
|
matches: MetaMatches<MatchLoaders>;
|
|
2013
2013
|
error?: unknown;
|
|
2014
2014
|
}
|
|
@@ -2329,7 +2329,7 @@ type RSCRenderPayload = {
|
|
|
2329
2329
|
clientVersion?: string;
|
|
2330
2330
|
errors: Record<string, any> | null;
|
|
2331
2331
|
loaderData: Record<string, any>;
|
|
2332
|
-
location: Location
|
|
2332
|
+
location: Location;
|
|
2333
2333
|
routeDiscovery: RouteDiscovery;
|
|
2334
2334
|
matches: RSCRouteMatch[];
|
|
2335
2335
|
patches?: Promise<RSCRouteManifest[]>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-917e6fdc0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
12
12
|
import * as React from "react";
|
|
13
|
-
import { createMultiMatcher } from "@remix-run/route-pattern/match";
|
|
14
13
|
import { parse, serialize, splitSetCookieString } from "cookie-es";
|
|
15
14
|
import { BrowserRouter, Form, HashRouter, Link, Links, MemoryRouter, Meta, NavLink, Navigate, Outlet, Outlet as Outlet$1, Route, Router, RouterProvider, Routes, ScrollRestoration, StaticRouter, StaticRouterProvider, UNSAFE_AwaitContextProvider, UNSAFE_WithComponentProps, UNSAFE_WithErrorBoundaryProps, UNSAFE_WithHydrateFallbackProps, unstable_HistoryRouter } from "react-router/internal/react-server-client";
|
|
16
15
|
//#region lib/router/url.ts
|
|
@@ -208,8 +207,7 @@ const unsupportedLazyRouteObjectKeys = new Set([
|
|
|
208
207
|
"path",
|
|
209
208
|
"id",
|
|
210
209
|
"index",
|
|
211
|
-
"children"
|
|
212
|
-
"unstable_validateParams"
|
|
210
|
+
"children"
|
|
213
211
|
]);
|
|
214
212
|
function isUnsupportedLazyRouteObjectKey(key) {
|
|
215
213
|
return unsupportedLazyRouteObjectKeys.has(key);
|
|
@@ -221,8 +219,7 @@ const unsupportedLazyRouteFunctionKeys = new Set([
|
|
|
221
219
|
"id",
|
|
222
220
|
"index",
|
|
223
221
|
"middleware",
|
|
224
|
-
"children"
|
|
225
|
-
"unstable_validateParams"
|
|
222
|
+
"children"
|
|
226
223
|
]);
|
|
227
224
|
function isUnsupportedLazyRouteFunctionKey(key) {
|
|
228
225
|
return unsupportedLazyRouteFunctionKeys.has(key);
|
|
@@ -338,11 +335,11 @@ function convertRouteMatchToUiMatch(match, loaderData) {
|
|
|
338
335
|
};
|
|
339
336
|
}
|
|
340
337
|
function flattenAndRankRoutes(routes) {
|
|
341
|
-
let branches = flattenRoutes
|
|
338
|
+
let branches = flattenRoutes(routes);
|
|
342
339
|
rankRouteBranches(branches);
|
|
343
340
|
return branches;
|
|
344
341
|
}
|
|
345
|
-
function flattenRoutes
|
|
342
|
+
function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false) {
|
|
346
343
|
let flattenRoute = (route, index, hasParentOptionalSegments = _hasParentOptionalSegments, relativePath) => {
|
|
347
344
|
let meta = {
|
|
348
345
|
relativePath: relativePath === void 0 ? route.path || "" : relativePath,
|
|
@@ -359,7 +356,7 @@ function flattenRoutes$1(routes, branches = [], parentsMeta = [], parentPath = "
|
|
|
359
356
|
let routesMeta = parentsMeta.concat(meta);
|
|
360
357
|
if (route.children && route.children.length > 0) {
|
|
361
358
|
invariant$1(route.index !== true, `Index routes must not have child routes. Please remove all child routes from route path "${path}".`);
|
|
362
|
-
flattenRoutes
|
|
359
|
+
flattenRoutes(route.children, branches, routesMeta, path, hasParentOptionalSegments);
|
|
363
360
|
}
|
|
364
361
|
if (route.path == null && !route.index) return;
|
|
365
362
|
branches.push({
|
|
@@ -518,13 +515,13 @@ function matchPathImpl(pattern, pathname, matcher, compiledParams) {
|
|
|
518
515
|
let match = pathname.match(matcher);
|
|
519
516
|
if (!match) return null;
|
|
520
517
|
let matchedPathname = match[0];
|
|
521
|
-
let pathnameBase = matchedPathname
|
|
518
|
+
let pathnameBase = removeTrailingSlash(matchedPathname, 1);
|
|
522
519
|
let captureGroups = match.slice(1);
|
|
523
520
|
return {
|
|
524
521
|
params: compiledParams.reduce((memo, { paramName, isOptional }, index) => {
|
|
525
522
|
if (paramName === "*") {
|
|
526
523
|
let splatValue = captureGroups[index] || "";
|
|
527
|
-
pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length)
|
|
524
|
+
pathnameBase = removeTrailingSlash(matchedPathname.slice(0, matchedPathname.length - splatValue.length), 1);
|
|
528
525
|
}
|
|
529
526
|
const value = captureGroups[index];
|
|
530
527
|
if (isOptional && !value) memo[paramName] = void 0;
|
|
@@ -593,7 +590,7 @@ function resolvePath(to, fromPathname = "/") {
|
|
|
593
590
|
let pathname;
|
|
594
591
|
if (toPathname) {
|
|
595
592
|
toPathname = removeDoubleSlashes(toPathname);
|
|
596
|
-
if (toPathname.startsWith("/")) pathname = resolvePathname(toPathname.substring(1), "/");
|
|
593
|
+
if (toPathname.startsWith("/") || toPathname.startsWith("\\")) pathname = resolvePathname(toPathname.substring(1), "/");
|
|
597
594
|
else pathname = resolvePathname(toPathname, fromPathname);
|
|
598
595
|
} else pathname = fromPathname;
|
|
599
596
|
return {
|
|
@@ -654,7 +651,11 @@ function resolveTo(toArg, routePathnames, locationPathname, isPathRelative = fal
|
|
|
654
651
|
}
|
|
655
652
|
const removeDoubleSlashes = (path) => path.replace(/[\\/]{2,}/g, "/");
|
|
656
653
|
const joinPaths = (paths) => removeDoubleSlashes(paths.join("/"));
|
|
657
|
-
|
|
654
|
+
function removeTrailingSlash(path, minLength = 0) {
|
|
655
|
+
let end = path.length;
|
|
656
|
+
while (end > minLength && path.charCodeAt(end - 1) === 47) end--;
|
|
657
|
+
return end === path.length ? path : path.slice(0, end);
|
|
658
|
+
}
|
|
658
659
|
const normalizePathname = (pathname) => removeTrailingSlash(pathname).replace(/^\/*/, "/");
|
|
659
660
|
const normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
|
|
660
661
|
const normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
|
|
@@ -1039,217 +1040,6 @@ function getReadonlyContext(context) {
|
|
|
1039
1040
|
return { get: (ctx) => context.get(ctx) };
|
|
1040
1041
|
}
|
|
1041
1042
|
//#endregion
|
|
1042
|
-
//#region lib/router/matcher-route-pattern.ts
|
|
1043
|
-
var RoutePatternDataRouteMatcher = class {
|
|
1044
|
-
#state;
|
|
1045
|
-
#basename;
|
|
1046
|
-
constructor(basename) {
|
|
1047
|
-
this.#basename = basename;
|
|
1048
|
-
}
|
|
1049
|
-
update(routes) {
|
|
1050
|
-
let branches = flattenRoutes(routes);
|
|
1051
|
-
let matcher = createMultiMatcher();
|
|
1052
|
-
let partialMatcher = createMultiMatcher();
|
|
1053
|
-
for (let branch of branches) {
|
|
1054
|
-
let routePattern = convertReactRouterPathToRoutePattern(branch.path);
|
|
1055
|
-
validateRoutePatternSplat(branch.path, routePattern);
|
|
1056
|
-
routePattern = addOptionalTrailingSlash(routePattern);
|
|
1057
|
-
matcher.add(routePattern, branch);
|
|
1058
|
-
if (!branch.routesMeta[branch.routesMeta.length - 1].route.index) partialMatcher.add(routePattern === "/" ? `/*__rr_partial` : `${routePattern}(/*__rr_partial)`, branch);
|
|
1059
|
-
}
|
|
1060
|
-
this.#state = {
|
|
1061
|
-
branches,
|
|
1062
|
-
matcher,
|
|
1063
|
-
partialMatcher
|
|
1064
|
-
};
|
|
1065
|
-
return branches;
|
|
1066
|
-
}
|
|
1067
|
-
match(locationArg, allowPartial = false) {
|
|
1068
|
-
let pathname = stripBasename((typeof locationArg === "string" ? parsePath(locationArg) : locationArg).pathname || "/", this.#basename);
|
|
1069
|
-
if (pathname == null) return null;
|
|
1070
|
-
let decoded = decodePath(pathname);
|
|
1071
|
-
let url = new URL(decoded, "http://reactrouter.local");
|
|
1072
|
-
invariant$1(this.#state, "Route pattern routes must be initialized before matching.");
|
|
1073
|
-
let matches = this.#state.matcher.matchAll(url);
|
|
1074
|
-
if (allowPartial) matches.push(...this.#state.partialMatcher.matchAll(url));
|
|
1075
|
-
for (let match of prioritizeValidatedMatches(matches)) {
|
|
1076
|
-
let routeMatches = convertRoutePatternMatchToRouteMatches(match, pathname, allowPartial);
|
|
1077
|
-
if (routeMatches && validateRouteMatchParams(routeMatches)) return routeMatches;
|
|
1078
|
-
}
|
|
1079
|
-
return null;
|
|
1080
|
-
}
|
|
1081
|
-
};
|
|
1082
|
-
function validateRoutePatternSplat(routePath, routePattern) {
|
|
1083
|
-
invariant$1(getRoutePatternSplatIndexes(routePattern).length <= 1 && isTerminalRoutePatternSplat(routePattern), `Route path "${routePath}" is not supported with \`future.unstable_routePatternMatching\` because React Router only supports a single splat at the end of a route path.`);
|
|
1084
|
-
}
|
|
1085
|
-
function getRoutePatternSplatIndexes(routePattern) {
|
|
1086
|
-
let splatIndexes = [];
|
|
1087
|
-
for (let i = 0; i < routePattern.length; i++) {
|
|
1088
|
-
let char = routePattern[i];
|
|
1089
|
-
if (char === "\\") {
|
|
1090
|
-
i++;
|
|
1091
|
-
continue;
|
|
1092
|
-
}
|
|
1093
|
-
if (char === "*") splatIndexes.push(i);
|
|
1094
|
-
}
|
|
1095
|
-
return splatIndexes;
|
|
1096
|
-
}
|
|
1097
|
-
function isTerminalRoutePatternSplat(routePattern) {
|
|
1098
|
-
for (let i = 0; i < routePattern.length; i++) {
|
|
1099
|
-
let char = routePattern[i];
|
|
1100
|
-
if (char === "\\") {
|
|
1101
|
-
i++;
|
|
1102
|
-
continue;
|
|
1103
|
-
}
|
|
1104
|
-
if (char !== "*") continue;
|
|
1105
|
-
let suffix = routePattern.slice(i + 1);
|
|
1106
|
-
return /^[a-zA-Z_$][a-zA-Z_$0-9]*$/.test(suffix) || suffix === "";
|
|
1107
|
-
}
|
|
1108
|
-
return true;
|
|
1109
|
-
}
|
|
1110
|
-
function addOptionalTrailingSlash(routePattern) {
|
|
1111
|
-
return routePattern === "/" ? routePattern : `${routePattern.replace(/\/+$/, "")}(/)`;
|
|
1112
|
-
}
|
|
1113
|
-
function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "") {
|
|
1114
|
-
routes.forEach((route, index) => {
|
|
1115
|
-
invariant$1(route.caseSensitive !== true, "`caseSensitive` routes are not supported with `future.unstable_routePatternMatching`.");
|
|
1116
|
-
let meta = {
|
|
1117
|
-
relativePath: route.path || "",
|
|
1118
|
-
caseSensitive: false,
|
|
1119
|
-
childrenIndex: index,
|
|
1120
|
-
route
|
|
1121
|
-
};
|
|
1122
|
-
if (meta.relativePath.startsWith("/")) {
|
|
1123
|
-
invariant$1(meta.relativePath.startsWith(parentPath), `Absolute route path "${meta.relativePath}" nested under path "${parentPath}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`);
|
|
1124
|
-
meta.relativePath = meta.relativePath.slice(parentPath.length);
|
|
1125
|
-
}
|
|
1126
|
-
let routesMeta = parentsMeta.concat(meta);
|
|
1127
|
-
let path = meta.relativePath ? joinPaths([parentPath, meta.relativePath]) : parentPath;
|
|
1128
|
-
if (route.children && route.children.length > 0) {
|
|
1129
|
-
invariant$1(route.index !== true, `Index routes must not have child routes. Please remove all child routes from route path "${path}".`);
|
|
1130
|
-
flattenRoutes(route.children, branches, routesMeta, path);
|
|
1131
|
-
if (route.children?.some((child) => child.index)) return;
|
|
1132
|
-
}
|
|
1133
|
-
if (route.path != null || route.index) branches.push({
|
|
1134
|
-
path,
|
|
1135
|
-
score: 0,
|
|
1136
|
-
routesMeta
|
|
1137
|
-
});
|
|
1138
|
-
});
|
|
1139
|
-
return branches;
|
|
1140
|
-
}
|
|
1141
|
-
function convertReactRouterPathToRoutePattern(path) {
|
|
1142
|
-
warning(path === "*" || !path.endsWith("*") || path.endsWith("/*"), `Route path "${path}" will be treated as if it were "${path.replace(/\*$/, "/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${path.replace(/\*$/, "/*")}".`);
|
|
1143
|
-
if (path.endsWith("*") && path !== "*" && !path.endsWith("/*")) path = path.replace(/\*$/, "/*");
|
|
1144
|
-
path = path.replace(/^\/*/, "/");
|
|
1145
|
-
if (path === "") return "/";
|
|
1146
|
-
let segments = path.split("/");
|
|
1147
|
-
let pattern = segments.shift() || "";
|
|
1148
|
-
for (let i = 0; i < segments.length;) {
|
|
1149
|
-
let optionalRun = [];
|
|
1150
|
-
while (i < segments.length && isOptionalRouteSegment(segments[i])) {
|
|
1151
|
-
optionalRun.push(convertRouteSegment(segments[i].slice(0, -1)));
|
|
1152
|
-
i++;
|
|
1153
|
-
}
|
|
1154
|
-
if (optionalRun.length > 0) {
|
|
1155
|
-
let nested = optionalRun.reduceRight((child, segment) => `/${segment}${child ? `(${child})` : ""}`, "");
|
|
1156
|
-
pattern += `(${nested})`;
|
|
1157
|
-
continue;
|
|
1158
|
-
}
|
|
1159
|
-
pattern += `/${convertRouteSegment(segments[i])}`;
|
|
1160
|
-
i++;
|
|
1161
|
-
}
|
|
1162
|
-
return pattern || "/";
|
|
1163
|
-
}
|
|
1164
|
-
function isOptionalRouteSegment(segment) {
|
|
1165
|
-
return segment.endsWith("?");
|
|
1166
|
-
}
|
|
1167
|
-
function convertRouteSegment(segment) {
|
|
1168
|
-
if (segment === "*") return "*__rr_splat";
|
|
1169
|
-
let paramMatch = segment.match(/^:([\w-]+)(\?)?(.*)$/);
|
|
1170
|
-
if (paramMatch) {
|
|
1171
|
-
let [, paramName, optional, suffix] = paramMatch;
|
|
1172
|
-
let converted = `:${paramName}${escapeRoutePatternLiteral(suffix)}`;
|
|
1173
|
-
return optional ? `(:${paramName})${escapeRoutePatternLiteral(suffix)}` : converted;
|
|
1174
|
-
}
|
|
1175
|
-
return escapeRoutePatternLiteral(segment);
|
|
1176
|
-
}
|
|
1177
|
-
function escapeRoutePatternLiteral(value) {
|
|
1178
|
-
return value.replace(/[\\():*]/g, "\\$&");
|
|
1179
|
-
}
|
|
1180
|
-
function validateRouteMatchParams(matches) {
|
|
1181
|
-
return matches.every(({ route, params }) => route.unstable_validateParams == null || Object.keys(route.unstable_validateParams).length === 0 || Object.entries(route.unstable_validateParams).every(([param, re]) => params[param] != null ? new RegExp(re.source, re.flags).test(params[param]) : true));
|
|
1182
|
-
}
|
|
1183
|
-
function prioritizeValidatedMatches(matches) {
|
|
1184
|
-
let validatedMatches = [];
|
|
1185
|
-
let unvalidatedMatches = [];
|
|
1186
|
-
for (let match of matches) if (match.data.routesMeta.some((meta) => meta.route.unstable_validateParams != null && Object.keys(meta.route.unstable_validateParams).length > 0)) validatedMatches.push(match);
|
|
1187
|
-
else unvalidatedMatches.push(match);
|
|
1188
|
-
return validatedMatches.concat(unvalidatedMatches);
|
|
1189
|
-
}
|
|
1190
|
-
function convertRoutePatternMatchToRouteMatches(match, pathname, allowPartial) {
|
|
1191
|
-
let pathSegments = pathname.replace(/^\//, "").split("/").filter(Boolean);
|
|
1192
|
-
let splatParamName = match.paramsMeta.pathname.find((meta) => meta.type === "*")?.name;
|
|
1193
|
-
let matchedParams = Object.entries(match.params).reduce((params, [key, value]) => {
|
|
1194
|
-
if (key === "__rr_partial" || value === void 0) return params;
|
|
1195
|
-
params[key === "__rr_splat" || key === splatParamName ? "*" : key] = value;
|
|
1196
|
-
return params;
|
|
1197
|
-
}, {});
|
|
1198
|
-
let consumedSegments = 0;
|
|
1199
|
-
let matches = [];
|
|
1200
|
-
for (let i = 0; i < match.data.routesMeta.length; i++) {
|
|
1201
|
-
let meta = match.data.routesMeta[i];
|
|
1202
|
-
let splatBaseSegments = null;
|
|
1203
|
-
let routeSegments = meta.relativePath.replace(/^\//, "").split("/").filter(Boolean);
|
|
1204
|
-
for (let segment of routeSegments) {
|
|
1205
|
-
if (segment === "*") {
|
|
1206
|
-
splatBaseSegments = consumedSegments;
|
|
1207
|
-
consumedSegments = pathSegments.length;
|
|
1208
|
-
break;
|
|
1209
|
-
}
|
|
1210
|
-
if (segment.endsWith("?")) {
|
|
1211
|
-
let routeSegment = segment.slice(0, -1);
|
|
1212
|
-
if (routeSegment.startsWith(":")) {
|
|
1213
|
-
if (matchedParams[routeSegment.slice(1)] !== void 0) consumedSegments++;
|
|
1214
|
-
} else if (pathSegments[consumedSegments] === routeSegment) consumedSegments++;
|
|
1215
|
-
continue;
|
|
1216
|
-
}
|
|
1217
|
-
consumedSegments++;
|
|
1218
|
-
}
|
|
1219
|
-
let routePathname = getRoutePatternMatchPathname(pathSegments, consumedSegments);
|
|
1220
|
-
let pathnameBase = splatBaseSegments == null ? routePathname : getRoutePatternMatchPathname(pathSegments, splatBaseSegments);
|
|
1221
|
-
matches.push({
|
|
1222
|
-
params: matchedParams,
|
|
1223
|
-
pathname: routePathname,
|
|
1224
|
-
pathnameBase,
|
|
1225
|
-
route: meta.route
|
|
1226
|
-
});
|
|
1227
|
-
}
|
|
1228
|
-
if (!allowPartial && pathSegments.length > consumedSegments && !match.data.routesMeta[match.data.routesMeta.length - 1].route.index) return null;
|
|
1229
|
-
return matches;
|
|
1230
|
-
}
|
|
1231
|
-
function getRoutePatternMatchPathname(pathSegments, consumedSegments) {
|
|
1232
|
-
return consumedSegments === 0 ? "/" : `/${pathSegments.slice(0, consumedSegments).join("/")}`;
|
|
1233
|
-
}
|
|
1234
|
-
//#endregion
|
|
1235
|
-
//#region lib/router/matcher.ts
|
|
1236
|
-
var V6RegExMatcher = class {
|
|
1237
|
-
#routes = [];
|
|
1238
|
-
#branches = [];
|
|
1239
|
-
#basename;
|
|
1240
|
-
constructor(basename) {
|
|
1241
|
-
this.#basename = basename;
|
|
1242
|
-
}
|
|
1243
|
-
update(routes) {
|
|
1244
|
-
this.#routes = routes;
|
|
1245
|
-
this.#branches = flattenAndRankRoutes(routes);
|
|
1246
|
-
return this.#branches;
|
|
1247
|
-
}
|
|
1248
|
-
match(locationArg, allowPartial = false) {
|
|
1249
|
-
return matchRoutesImpl(this.#routes, locationArg, this.#basename, allowPartial, this.#branches);
|
|
1250
|
-
}
|
|
1251
|
-
};
|
|
1252
|
-
//#endregion
|
|
1253
1043
|
//#region lib/router/router.ts
|
|
1254
1044
|
const validMutationMethodsArr = [
|
|
1255
1045
|
"POST",
|
|
@@ -1268,9 +1058,6 @@ const redirectStatusCodes = new Set([
|
|
|
1268
1058
|
308
|
|
1269
1059
|
]);
|
|
1270
1060
|
const ResetLoaderDataSymbol = Symbol("ResetLoaderData");
|
|
1271
|
-
function createDataRouteMatcher(future, basename) {
|
|
1272
|
-
return future.unstable_routePatternMatching ? new RoutePatternDataRouteMatcher(basename) : new V6RegExMatcher(basename);
|
|
1273
|
-
}
|
|
1274
1061
|
/**
|
|
1275
1062
|
* Create a static handler to perform server-side data loading
|
|
1276
1063
|
*
|
|
@@ -1307,7 +1094,7 @@ function createStaticHandler(routes, opts) {
|
|
|
1307
1094
|
let basename = (opts ? opts.basename : null) || "/";
|
|
1308
1095
|
let _mapRouteProperties = opts?.mapRouteProperties;
|
|
1309
1096
|
let mapRouteProperties = _mapRouteProperties ? _mapRouteProperties : () => ({});
|
|
1310
|
-
|
|
1097
|
+
({ ...opts?.future });
|
|
1311
1098
|
if (opts?.instrumentations) {
|
|
1312
1099
|
let instrumentations = opts.instrumentations;
|
|
1313
1100
|
mapRouteProperties = (route) => {
|
|
@@ -1318,7 +1105,7 @@ function createStaticHandler(routes, opts) {
|
|
|
1318
1105
|
};
|
|
1319
1106
|
}
|
|
1320
1107
|
let dataRoutes = convertRoutesToDataRoutes(routes, mapRouteProperties, void 0, manifest);
|
|
1321
|
-
let routeBranches =
|
|
1108
|
+
let routeBranches = flattenAndRankRoutes(dataRoutes);
|
|
1322
1109
|
/**
|
|
1323
1110
|
* The query() method is intended for document requests, in which we want to
|
|
1324
1111
|
* call an optional action and potentially multiple loaders for all nested
|
|
@@ -1349,7 +1136,7 @@ function createStaticHandler(routes, opts) {
|
|
|
1349
1136
|
let normalizePathImpl = normalizePath || defaultNormalizePath;
|
|
1350
1137
|
let method = request.method;
|
|
1351
1138
|
let location = createLocation("", normalizePathImpl(request), null, "default");
|
|
1352
|
-
let matches =
|
|
1139
|
+
let matches = matchRoutesImpl(dataRoutes, location, basename, false, routeBranches);
|
|
1353
1140
|
requestContext = requestContext != null ? requestContext : new RouterContextProvider();
|
|
1354
1141
|
if (!isValidMethod(method) && method !== "HEAD") {
|
|
1355
1142
|
let error = getInternalRouterError(405, { method });
|
|
@@ -1477,7 +1264,7 @@ function createStaticHandler(routes, opts) {
|
|
|
1477
1264
|
let normalizePathImpl = normalizePath || defaultNormalizePath;
|
|
1478
1265
|
let method = request.method;
|
|
1479
1266
|
let location = createLocation("", normalizePathImpl(request), null, "default");
|
|
1480
|
-
let matches =
|
|
1267
|
+
let matches = matchRoutesImpl(dataRoutes, location, basename, false, routeBranches);
|
|
1481
1268
|
requestContext = requestContext != null ? requestContext : new RouterContextProvider();
|
|
1482
1269
|
if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") throw getInternalRouterError(405, { method });
|
|
1483
1270
|
else if (!matches) throw getInternalRouterError(404, { pathname: location.pathname });
|
|
@@ -2434,14 +2221,19 @@ function getPathsWithAncestors(paths) {
|
|
|
2434
2221
|
function throwIfPotentialCSRFAttack(request, allowedActionOrigins) {
|
|
2435
2222
|
let originHeader = request.headers.get("origin");
|
|
2436
2223
|
let originDomain = null;
|
|
2224
|
+
let originUrl = null;
|
|
2437
2225
|
try {
|
|
2438
|
-
|
|
2226
|
+
if (typeof originHeader === "string" && originHeader !== "null") {
|
|
2227
|
+
originUrl = new URL(originHeader);
|
|
2228
|
+
originDomain = originUrl.host;
|
|
2229
|
+
} else originDomain = originHeader;
|
|
2439
2230
|
} catch {
|
|
2440
2231
|
throw new Error(`\`origin\` header is not a valid URL. Aborting the action.`);
|
|
2441
2232
|
}
|
|
2442
|
-
let
|
|
2443
|
-
|
|
2444
|
-
|
|
2233
|
+
let requestUrl = new URL(request.url);
|
|
2234
|
+
let originMatchesRequest = originUrl ? originUrl.origin === requestUrl.origin : originDomain === requestUrl.host;
|
|
2235
|
+
if (originDomain && !originMatchesRequest) {
|
|
2236
|
+
if (!isAllowedOrigin(originDomain, allowedActionOrigins)) throw new Error("The `request.url` origin does not match `origin` header from a forwarded action request. Aborting the action.");
|
|
2445
2237
|
}
|
|
2446
2238
|
}
|
|
2447
2239
|
function matchWildcardDomain(domain, pattern) {
|
|
@@ -2538,11 +2330,6 @@ const Await = (async ({ children, resolve, errorElement }) => {
|
|
|
2538
2330
|
}
|
|
2539
2331
|
});
|
|
2540
2332
|
});
|
|
2541
|
-
function createRSCDataRouteMatcher(routes, basename) {
|
|
2542
|
-
let dataRouteMatcher = createDataRouteMatcher({}, basename ?? "/");
|
|
2543
|
-
dataRouteMatcher.update(routes);
|
|
2544
|
-
return dataRouteMatcher;
|
|
2545
|
-
}
|
|
2546
2333
|
/**
|
|
2547
2334
|
* Matches the given routes to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
2548
2335
|
* and returns an [RSC](https://react.dev/reference/rsc/server-components)
|
|
@@ -2637,7 +2424,7 @@ async function matchRSCServerRequest({ allowedActionOrigins, createTemporaryRefe
|
|
|
2637
2424
|
const requestUrl = new URL(request.url);
|
|
2638
2425
|
if (isManifestRequest(requestUrl)) return await generateManifestResponse(routes, basename, request, generateResponse, temporaryReferences, routeDiscovery, clientVersion);
|
|
2639
2426
|
let isDataRequest = isReactServerRequest(requestUrl);
|
|
2640
|
-
let matches =
|
|
2427
|
+
let matches = matchRoutes(routes, url.pathname, basename);
|
|
2641
2428
|
if (matches) await Promise.all(matches.map((m) => explodeLazyRoute(m.route)));
|
|
2642
2429
|
const leafMatch = matches?.[matches.length - 1];
|
|
2643
2430
|
if (!isDataRequest && leafMatch && !leafMatch.route.Component && !leafMatch.route.ErrorBoundary) return generateResourceResponse(routerRequest, routes, basename, leafMatch.route.id, requestContext, onError);
|
|
@@ -2674,10 +2461,9 @@ async function generateManifestResponse(routes, basename, request, generateRespo
|
|
|
2674
2461
|
}
|
|
2675
2462
|
let pathParam = url.searchParams.get("paths");
|
|
2676
2463
|
let pathnames = pathParam ? pathParam.split(",").filter(Boolean) : [url.pathname.replace(/\.manifest$/, "")];
|
|
2677
|
-
let dataRouteMatcher = createRSCDataRouteMatcher(routes, basename);
|
|
2678
2464
|
let routeIds = /* @__PURE__ */ new Set();
|
|
2679
2465
|
let matchedRoutes = pathnames.flatMap((pathname) => {
|
|
2680
|
-
let pathnameMatches =
|
|
2466
|
+
let pathnameMatches = matchRoutes(routes, pathname, basename);
|
|
2681
2467
|
return pathnameMatches?.map((m, i) => ({
|
|
2682
2468
|
...m.route,
|
|
2683
2469
|
parentId: pathnameMatches[i - 1]?.route.id
|
|
@@ -2691,7 +2477,7 @@ async function generateManifestResponse(routes, basename, request, generateRespo
|
|
|
2691
2477
|
});
|
|
2692
2478
|
let payload = {
|
|
2693
2479
|
type: "manifest",
|
|
2694
|
-
patches: Promise.all([...matchedRoutes.map((route) => getManifestRoute(route)), getAdditionalRoutePatches(pathnames,
|
|
2480
|
+
patches: Promise.all([...matchedRoutes.map((route) => getManifestRoute(route)), getAdditionalRoutePatches(pathnames, routes, basename, Array.from(routeIds))]).then((r) => r.flat(1))
|
|
2695
2481
|
};
|
|
2696
2482
|
return generateResponse({
|
|
2697
2483
|
statusCode: 200,
|
|
@@ -2952,12 +2738,7 @@ async function getRenderPayload(baseRenderPayload, routes, basename, routeIdsToL
|
|
|
2952
2738
|
parentId
|
|
2953
2739
|
});
|
|
2954
2740
|
}));
|
|
2955
|
-
let patches;
|
|
2956
|
-
if (routeDiscovery?.mode === "initial" && !isDataRequest) patches = getAllRoutePatches(routes, basename).then((patches) => patches.filter((patch) => !staticContext.matches.some((m) => m.route.id === patch.id)));
|
|
2957
|
-
else {
|
|
2958
|
-
let dataRouteMatcher = createRSCDataRouteMatcher(routes, basename);
|
|
2959
|
-
patches = getAdditionalRoutePatches(getPathsWithAncestors([staticContext.location.pathname]), dataRouteMatcher, staticContext.matches.map((m) => m.route.id));
|
|
2960
|
-
}
|
|
2741
|
+
let patches = routeDiscovery?.mode === "initial" && !isDataRequest ? getAllRoutePatches(routes, basename).then((patches) => patches.filter((patch) => !staticContext.matches.some((m) => m.route.id === patch.id))) : getAdditionalRoutePatches(getPathsWithAncestors([staticContext.location.pathname]), routes, basename, staticContext.matches.map((m) => m.route.id));
|
|
2961
2742
|
return {
|
|
2962
2743
|
...baseRenderPayload,
|
|
2963
2744
|
matches: await matchesPromise,
|
|
@@ -3061,13 +2842,13 @@ async function getAllRoutePatches(routes, basename) {
|
|
|
3061
2842
|
for (let route of routes) await traverse(route, void 0);
|
|
3062
2843
|
return patches.filter((p) => !!p.parentId);
|
|
3063
2844
|
}
|
|
3064
|
-
async function getAdditionalRoutePatches(pathnames,
|
|
2845
|
+
async function getAdditionalRoutePatches(pathnames, routes, basename, matchedRouteIds) {
|
|
3065
2846
|
let patchRouteMatches = /* @__PURE__ */ new Map();
|
|
3066
2847
|
let matchedPaths = /* @__PURE__ */ new Set();
|
|
3067
2848
|
for (const pathname of pathnames) {
|
|
3068
2849
|
if (matchedPaths.has(pathname)) continue;
|
|
3069
2850
|
matchedPaths.add(pathname);
|
|
3070
|
-
let matches =
|
|
2851
|
+
let matches = matchRoutes(routes, pathname, basename) || [];
|
|
3071
2852
|
matches.forEach((m, i) => {
|
|
3072
2853
|
if (patchRouteMatches.get(m.route.id)) return;
|
|
3073
2854
|
patchRouteMatches.set(m.route.id, {
|