react-router 7.8.2-pre.1 → 7.9.0-pre.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 -10
- package/dist/development/{chunk-7QFLQWWN.mjs → chunk-3TJX7VNY.mjs} +93 -57
- package/dist/{production/chunk-IK7IYG3O.js → development/chunk-4J2JOVAI.js} +135 -135
- package/dist/development/{chunk-ZVD2KUIM.mjs → chunk-EAIS2CTK.mjs} +43 -44
- package/dist/development/{chunk-ZVMYUFGA.js → chunk-ECJT65VE.js} +37 -38
- package/dist/{production/context-jKip1TFB.d.mts → development/context-BH6Jwdoy.d.mts} +39 -32
- package/dist/development/dom-export.d.mts +3 -3
- package/dist/development/dom-export.d.ts +2 -2
- package/dist/development/dom-export.js +14 -14
- package/dist/development/dom-export.mjs +14 -14
- package/dist/development/{index-react-server-client-DRhjXpk2.d.mts → index-react-server-client-1cWMpKk4.d.mts} +13 -13
- package/dist/{production/index-react-server-client-BKpa2trA.d.ts → development/index-react-server-client-CMC2eQAY.d.ts} +12 -12
- package/dist/development/index-react-server-client.d.mts +3 -3
- package/dist/development/index-react-server-client.d.ts +2 -2
- package/dist/development/index-react-server-client.js +4 -4
- package/dist/development/index-react-server-client.mjs +4 -4
- package/dist/development/index-react-server.d.mts +229 -37
- package/dist/development/index-react-server.d.ts +229 -37
- package/dist/development/index-react-server.js +89 -39
- package/dist/development/index-react-server.mjs +88 -36
- package/dist/development/index.d.mts +31 -24
- package/dist/development/index.d.ts +29 -22
- package/dist/development/index.js +182 -144
- package/dist/development/index.mjs +9 -7
- package/dist/development/lib/types/internal.d.mts +6 -6
- package/dist/development/lib/types/internal.d.ts +5 -5
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/development/{route-data-DAVP2QQ0.d.mts → route-data-BQkq8Erj.d.mts} +12 -12
- package/dist/development/{routeModules-rOzWJJ9x.d.ts → routeModules-DSKAn01V.d.ts} +175 -168
- package/dist/production/{chunk-VHBXOG2Z.mjs → chunk-47NS5WEV.mjs} +43 -44
- package/dist/{development/chunk-IVOVRAK2.js → production/chunk-CSESPFUI.js} +135 -135
- package/dist/production/{chunk-5WPGWA23.js → chunk-LQAK2UKE.js} +37 -38
- package/dist/production/{chunk-LR4OTIMG.mjs → chunk-SCSBSW2J.mjs} +93 -57
- package/dist/{development/context-jKip1TFB.d.mts → production/context-BH6Jwdoy.d.mts} +39 -32
- package/dist/production/dom-export.d.mts +3 -3
- package/dist/production/dom-export.d.ts +2 -2
- package/dist/production/dom-export.js +14 -14
- package/dist/production/dom-export.mjs +14 -14
- package/dist/production/{index-react-server-client-DRhjXpk2.d.mts → index-react-server-client-1cWMpKk4.d.mts} +13 -13
- package/dist/{development/index-react-server-client-BKpa2trA.d.ts → production/index-react-server-client-CMC2eQAY.d.ts} +12 -12
- package/dist/production/index-react-server-client.d.mts +3 -3
- package/dist/production/index-react-server-client.d.ts +2 -2
- package/dist/production/index-react-server-client.js +4 -4
- package/dist/production/index-react-server-client.mjs +4 -4
- package/dist/production/index-react-server.d.mts +229 -37
- package/dist/production/index-react-server.d.ts +229 -37
- package/dist/production/index-react-server.js +89 -39
- package/dist/production/index-react-server.mjs +88 -36
- package/dist/production/index.d.mts +31 -24
- package/dist/production/index.d.ts +29 -22
- package/dist/production/index.js +182 -144
- package/dist/production/index.mjs +9 -7
- package/dist/production/lib/types/internal.d.mts +6 -6
- package/dist/production/lib/types/internal.d.ts +5 -5
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/production/{route-data-DAVP2QQ0.d.mts → route-data-BQkq8Erj.d.mts} +12 -12
- package/dist/production/{routeModules-rOzWJJ9x.d.ts → routeModules-DSKAn01V.d.ts} +175 -168
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,27 +1,50 @@
|
|
|
1
1
|
# `react-router`
|
|
2
2
|
|
|
3
|
-
## 7.
|
|
3
|
+
## 7.9.0-pre.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Stabilize middleware and context APIs. ([#14215](https://github.com/remix-run/react-router/pull/14215))
|
|
8
|
+
|
|
9
|
+
We have removed the `unstable_` prefix from the following APIs and they are now considered stable and ready for production use:
|
|
10
|
+
- [`RouterContextProvider`](https://reactrouter.com/api/utils/RouterContextProvider)
|
|
11
|
+
- [`createContext`](https://reactrouter.com/api/utils/createContext)
|
|
12
|
+
- `createBrowserRouter` [`getContext`](https://reactrouter.com/api/data-routers/createBrowserRouter#optsgetcontext) option
|
|
13
|
+
- `<HydratedRouter>` [`getContext`](https://reactrouter.com/api/framework-routers/HydratedRouter#getcontext) prop
|
|
14
|
+
|
|
15
|
+
Please see the [Middleware Docs](https://reactrouter.com/how-to/middleware), the [Middleware RFC](https://github.com/remix-run/remix/discussions/7642), and the [Client-side Context RFC](https://github.com/remix-run/react-router/discussions/9856) for more information.
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Add react-server Await component implementation ([#14261](https://github.com/remix-run/react-router/pull/14261))
|
|
20
|
+
- In RSC Data Mode when using a custom basename, fix hydration errors for routes that only have client loaders ([#14264](https://github.com/remix-run/react-router/pull/14264))
|
|
21
|
+
- Make `href` function available in a react-server context ([#14262](https://github.com/remix-run/react-router/pull/14262))
|
|
22
|
+
- decode each time `getPayload()` is called to allow for "in-context" decoding and hoisting of contextual assets ([#14248](https://github.com/remix-run/react-router/pull/14248))
|
|
23
|
+
- `href()` now correctly processes routes that have an extension after the parameter or are a single optional parameter. ([#13797](https://github.com/remix-run/react-router/pull/13797))
|
|
24
|
+
|
|
25
|
+
## 7.8.2
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
6
28
|
|
|
7
|
-
- [UNSTABLE] Remove Data Mode `future.unstable_middleware` flag from `createBrowserRouter` ([#14213](https://github.com/remix-run/react-router/pull/14213))
|
|
29
|
+
- \[UNSTABLE] Remove Data Mode `future.unstable_middleware` flag from `createBrowserRouter` ([#14213](https://github.com/remix-run/react-router/pull/14213))
|
|
8
30
|
- This is only needed as a Framework Mode flag because of the route modules and the `getLoadContext` type behavior change
|
|
9
31
|
- In Data Mode, it's an opt-in feature because it's just a new property on a route object, so there's no behavior changes that necessitate a flag
|
|
10
32
|
|
|
11
|
-
-
|
|
12
|
-
- [REMOVE] Update type as a follow up to https://github.com/remix-run/react-router/pull/14151 ([#14212](https://github.com/remix-run/react-router/pull/14212))
|
|
13
|
-
|
|
14
|
-
## 7.8.2-pre.0
|
|
33
|
+
- \[UNSTABLE] Add `<RouterProvider unstable_onError>`/`<HydratedRouter unstable_onError>` prop for client side error reporting ([#14162](https://github.com/remix-run/react-router/pull/14162))
|
|
15
34
|
|
|
16
|
-
|
|
35
|
+
- server action revalidation opt out via $SKIP_REVALIDATION field ([#14154](https://github.com/remix-run/react-router/pull/14154))
|
|
17
36
|
|
|
18
|
-
- [UNSTABLE] Add `<RouterProvider unstable_onError>`/`<HydratedRouter unstable_onError>` prop for client side error reporting ([#14162](https://github.com/remix-run/react-router/pull/14162))
|
|
19
37
|
- Properly escape interpolated param values in `generatePath()` ([#13530](https://github.com/remix-run/react-router/pull/13530))
|
|
38
|
+
|
|
20
39
|
- Maintain `ReadonlyMap` and `ReadonlySet` types in server response data. ([#13092](https://github.com/remix-run/react-router/pull/13092))
|
|
21
|
-
|
|
40
|
+
|
|
41
|
+
- \[UNSTABLE] Delay serialization of `.data` redirects to 202 responses until after middleware chain ([#14205](https://github.com/remix-run/react-router/pull/14205))
|
|
42
|
+
|
|
22
43
|
- Fix `TypeError` if you throw from `patchRoutesOnNavigation` when no partial matches exist ([#14198](https://github.com/remix-run/react-router/pull/14198))
|
|
44
|
+
|
|
23
45
|
- Fix `basename` usage without a leading slash in data routers ([#11671](https://github.com/remix-run/react-router/pull/11671))
|
|
24
|
-
|
|
46
|
+
|
|
47
|
+
- \[UNSTABLE] Update client middleware so it returns the data strategy results allowing for more advanced post-processing middleware ([#14151](https://github.com/remix-run/react-router/pull/14151))
|
|
25
48
|
|
|
26
49
|
## 7.8.1
|
|
27
50
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v7.
|
|
2
|
+
* react-router v7.9.0-pre.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
Outlet,
|
|
17
17
|
RSCRouterContext,
|
|
18
18
|
RemixErrorBoundary,
|
|
19
|
+
RouterContextProvider,
|
|
19
20
|
RouterProvider,
|
|
20
21
|
SINGLE_FETCH_REDIRECT_STATUS,
|
|
21
22
|
SingleFetchRedirectSymbol,
|
|
@@ -23,6 +24,7 @@ import {
|
|
|
23
24
|
StreamTransfer,
|
|
24
25
|
convertRoutesToDataRoutes,
|
|
25
26
|
createBrowserHistory,
|
|
27
|
+
createContext,
|
|
26
28
|
createMemoryRouter,
|
|
27
29
|
createRequestInit,
|
|
28
30
|
createRouter,
|
|
@@ -51,14 +53,12 @@ import {
|
|
|
51
53
|
singleFetchUrl,
|
|
52
54
|
stripBasename,
|
|
53
55
|
stripIndexParam,
|
|
54
|
-
unstable_RouterContextProvider,
|
|
55
|
-
unstable_createContext,
|
|
56
56
|
useRouteError,
|
|
57
57
|
warnOnce,
|
|
58
58
|
withComponentProps,
|
|
59
59
|
withErrorBoundaryProps,
|
|
60
60
|
withHydrateFallbackProps
|
|
61
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-EAIS2CTK.mjs";
|
|
62
62
|
|
|
63
63
|
// lib/dom/ssr/server.tsx
|
|
64
64
|
import * as React from "react";
|
|
@@ -145,7 +145,7 @@ function createRoutesStub(routes, _context) {
|
|
|
145
145
|
frameworkContextRef.current = {
|
|
146
146
|
future: {
|
|
147
147
|
unstable_subResourceIntegrity: future?.unstable_subResourceIntegrity === true,
|
|
148
|
-
|
|
148
|
+
v8_middleware: future?.v8_middleware === true
|
|
149
149
|
},
|
|
150
150
|
manifest: {
|
|
151
151
|
routes: {},
|
|
@@ -162,7 +162,7 @@ function createRoutesStub(routes, _context) {
|
|
|
162
162
|
// @ts-expect-error `StubRouteObject` is stricter about `loader`/`action`
|
|
163
163
|
// types compared to `AgnosticRouteObject`
|
|
164
164
|
convertRoutesToDataRoutes(routes, (r) => r),
|
|
165
|
-
_context !== void 0 ? _context : future?.
|
|
165
|
+
_context !== void 0 ? _context : future?.v8_middleware ? new RouterContextProvider() : {},
|
|
166
166
|
frameworkContextRef.current.manifest,
|
|
167
167
|
frameworkContextRef.current.routeModules
|
|
168
168
|
);
|
|
@@ -612,7 +612,7 @@ function createStaticHandlerDataRoutes(manifest, future, parentId = "", routesBy
|
|
|
612
612
|
hasErrorBoundary: route.id === "root" || route.module.ErrorBoundary != null,
|
|
613
613
|
id: route.id,
|
|
614
614
|
path: route.path,
|
|
615
|
-
|
|
615
|
+
middleware: route.module.middleware,
|
|
616
616
|
// Need to use RR's version in the param typed here to permit the optional
|
|
617
617
|
// context even though we know it'll always be provided in remix
|
|
618
618
|
loader: route.module.loader ? async (args) => {
|
|
@@ -785,7 +785,7 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
|
|
|
785
785
|
requestContext: loadContext,
|
|
786
786
|
skipLoaderErrorBubbling: true,
|
|
787
787
|
skipRevalidation: true,
|
|
788
|
-
|
|
788
|
+
generateMiddlewareResponse: build.future.v8_middleware ? async (query) => {
|
|
789
789
|
try {
|
|
790
790
|
let innerResult = await query(handlerRequest);
|
|
791
791
|
return handleQueryResult(innerResult);
|
|
@@ -849,7 +849,7 @@ async function singleFetchLoaders(build, serverMode, staticHandler, request, han
|
|
|
849
849
|
requestContext: loadContext,
|
|
850
850
|
filterMatchesToLoad: (m) => !loadRouteIds || loadRouteIds.has(m.route.id),
|
|
851
851
|
skipLoaderErrorBubbling: true,
|
|
852
|
-
|
|
852
|
+
generateMiddlewareResponse: build.future.v8_middleware ? async (query) => {
|
|
853
853
|
try {
|
|
854
854
|
let innerResult = await query(handlerRequest);
|
|
855
855
|
return handleQueryResult(innerResult);
|
|
@@ -1066,15 +1066,15 @@ var createRequestHandler = (build, mode) => {
|
|
|
1066
1066
|
request
|
|
1067
1067
|
});
|
|
1068
1068
|
};
|
|
1069
|
-
if (_build.future.
|
|
1070
|
-
if (initialContext && !(initialContext instanceof
|
|
1069
|
+
if (_build.future.v8_middleware) {
|
|
1070
|
+
if (initialContext && !(initialContext instanceof RouterContextProvider)) {
|
|
1071
1071
|
let error = new Error(
|
|
1072
|
-
"Invalid `context` value provided to `handleRequest`. When middleware is enabled you must return an instance of `
|
|
1072
|
+
"Invalid `context` value provided to `handleRequest`. When middleware is enabled you must return an instance of `RouterContextProvider` from your `getLoadContext` function."
|
|
1073
1073
|
);
|
|
1074
1074
|
handleError(error);
|
|
1075
1075
|
return returnLastResortErrorResponse(error, serverMode);
|
|
1076
1076
|
}
|
|
1077
|
-
loadContext = initialContext || new
|
|
1077
|
+
loadContext = initialContext || new RouterContextProvider();
|
|
1078
1078
|
} else {
|
|
1079
1079
|
loadContext = initialContext || {};
|
|
1080
1080
|
}
|
|
@@ -1302,7 +1302,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
1302
1302
|
try {
|
|
1303
1303
|
let result = await staticHandler.query(request, {
|
|
1304
1304
|
requestContext: loadContext,
|
|
1305
|
-
|
|
1305
|
+
generateMiddlewareResponse: build.future.v8_middleware ? async (query) => {
|
|
1306
1306
|
try {
|
|
1307
1307
|
let innerResult = await query(request);
|
|
1308
1308
|
if (!isResponse(innerResult)) {
|
|
@@ -1438,7 +1438,7 @@ async function handleResourceRequest(serverMode, build, staticHandler, routeId,
|
|
|
1438
1438
|
let result = await staticHandler.queryRoute(request, {
|
|
1439
1439
|
routeId,
|
|
1440
1440
|
requestContext: loadContext,
|
|
1441
|
-
|
|
1441
|
+
generateMiddlewareResponse: build.future.v8_middleware ? async (queryRoute) => {
|
|
1442
1442
|
try {
|
|
1443
1443
|
let innerResult = await queryRoute(request);
|
|
1444
1444
|
return handleQueryRouteResult(innerResult);
|
|
@@ -1658,22 +1658,27 @@ function createMemorySessionStorage({ cookie } = {}) {
|
|
|
1658
1658
|
// lib/href.ts
|
|
1659
1659
|
function href(path, ...args) {
|
|
1660
1660
|
let params = args[0];
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
);
|
|
1661
|
+
let result = path.replace(/\/*\*?$/, "").replace(
|
|
1662
|
+
/\/:([\w-]+)(\?)?/g,
|
|
1663
|
+
// same regex as in .\router\utils.ts: compilePath().
|
|
1664
|
+
(_, param, questionMark) => {
|
|
1665
|
+
const isRequired = questionMark === void 0;
|
|
1666
|
+
const value = params ? params[param] : void 0;
|
|
1667
|
+
if (isRequired && value === void 0) {
|
|
1668
|
+
throw new Error(
|
|
1669
|
+
`Path '${path}' requires param '${param}' but it was not provided`
|
|
1670
|
+
);
|
|
1671
|
+
}
|
|
1672
|
+
return value === void 0 ? "" : "/" + value;
|
|
1674
1673
|
}
|
|
1675
|
-
|
|
1676
|
-
|
|
1674
|
+
);
|
|
1675
|
+
if (path.endsWith("*")) {
|
|
1676
|
+
const value = params ? params["*"] : void 0;
|
|
1677
|
+
if (value !== void 0) {
|
|
1678
|
+
result += "/" + value;
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
return result || "/";
|
|
1677
1682
|
}
|
|
1678
1683
|
|
|
1679
1684
|
// lib/rsc/browser.tsx
|
|
@@ -1681,7 +1686,14 @@ import * as React4 from "react";
|
|
|
1681
1686
|
import * as ReactDOM from "react-dom";
|
|
1682
1687
|
|
|
1683
1688
|
// lib/dom/ssr/hydration.tsx
|
|
1684
|
-
function getHydrationData(
|
|
1689
|
+
function getHydrationData({
|
|
1690
|
+
state,
|
|
1691
|
+
routes,
|
|
1692
|
+
getRouteInfo,
|
|
1693
|
+
location: location2,
|
|
1694
|
+
basename,
|
|
1695
|
+
isSpaMode
|
|
1696
|
+
}) {
|
|
1685
1697
|
let hydrationData = {
|
|
1686
1698
|
...state,
|
|
1687
1699
|
loaderData: { ...state.loaderData }
|
|
@@ -1933,7 +1945,7 @@ function createCallServer({
|
|
|
1933
1945
|
function createRouterFromPayload({
|
|
1934
1946
|
fetchImplementation,
|
|
1935
1947
|
createFromReadableStream,
|
|
1936
|
-
|
|
1948
|
+
getContext,
|
|
1937
1949
|
payload
|
|
1938
1950
|
}) {
|
|
1939
1951
|
const globalVar = window;
|
|
@@ -1971,17 +1983,17 @@ function createRouterFromPayload({
|
|
|
1971
1983
|
}, []);
|
|
1972
1984
|
globalVar.__reactRouterDataRouter = createRouter({
|
|
1973
1985
|
routes,
|
|
1974
|
-
|
|
1986
|
+
getContext,
|
|
1975
1987
|
basename: payload.basename,
|
|
1976
1988
|
history: createBrowserHistory(),
|
|
1977
|
-
hydrationData: getHydrationData(
|
|
1978
|
-
{
|
|
1989
|
+
hydrationData: getHydrationData({
|
|
1990
|
+
state: {
|
|
1979
1991
|
loaderData: payload.loaderData,
|
|
1980
1992
|
actionData: payload.actionData,
|
|
1981
1993
|
errors: payload.errors
|
|
1982
1994
|
},
|
|
1983
1995
|
routes,
|
|
1984
|
-
(routeId) => {
|
|
1996
|
+
getRouteInfo: (routeId) => {
|
|
1985
1997
|
let match = payload.matches.find((m) => m.id === routeId);
|
|
1986
1998
|
invariant(match, "Route not found in payload");
|
|
1987
1999
|
return {
|
|
@@ -1990,10 +2002,10 @@ function createRouterFromPayload({
|
|
|
1990
2002
|
hasHydrateFallback: match.hydrateFallbackElement != null
|
|
1991
2003
|
};
|
|
1992
2004
|
},
|
|
1993
|
-
payload.location,
|
|
1994
|
-
|
|
1995
|
-
false
|
|
1996
|
-
),
|
|
2005
|
+
location: payload.location,
|
|
2006
|
+
basename: payload.basename,
|
|
2007
|
+
isSpaMode: false
|
|
2008
|
+
}),
|
|
1997
2009
|
async patchRoutesOnNavigation({ path, signal }) {
|
|
1998
2010
|
if (discoveredPaths.has(path)) {
|
|
1999
2011
|
return;
|
|
@@ -2081,7 +2093,7 @@ function createRouterFromPayload({
|
|
|
2081
2093
|
routeModules: globalVar.__reactRouterRouteModules
|
|
2082
2094
|
};
|
|
2083
2095
|
}
|
|
2084
|
-
var renderedRoutesContext =
|
|
2096
|
+
var renderedRoutesContext = createContext();
|
|
2085
2097
|
function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, createFromReadableStream, fetchImplementation) {
|
|
2086
2098
|
let dataStrategy = getSingleFetchDataStrategyImpl(
|
|
2087
2099
|
getRouter,
|
|
@@ -2108,7 +2120,7 @@ function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, createFromReada
|
|
|
2108
2120
|
return M.route.hasComponent && !M.route.element;
|
|
2109
2121
|
}
|
|
2110
2122
|
);
|
|
2111
|
-
return async (args) => args.
|
|
2123
|
+
return async (args) => args.runClientMiddleware(async () => {
|
|
2112
2124
|
let context = args.context;
|
|
2113
2125
|
context.set(renderedRoutesContext, []);
|
|
2114
2126
|
let results = await dataStrategy(args);
|
|
@@ -2194,22 +2206,17 @@ function RSCHydratedRouter({
|
|
|
2194
2206
|
fetch: fetchImplementation = fetch,
|
|
2195
2207
|
payload,
|
|
2196
2208
|
routeDiscovery = "eager",
|
|
2197
|
-
|
|
2209
|
+
getContext
|
|
2198
2210
|
}) {
|
|
2199
2211
|
if (payload.type !== "render") throw new Error("Invalid payload type");
|
|
2200
2212
|
let { router, routeModules } = React4.useMemo(
|
|
2201
2213
|
() => createRouterFromPayload({
|
|
2202
2214
|
payload,
|
|
2203
2215
|
fetchImplementation,
|
|
2204
|
-
|
|
2216
|
+
getContext,
|
|
2205
2217
|
createFromReadableStream
|
|
2206
2218
|
}),
|
|
2207
|
-
[
|
|
2208
|
-
createFromReadableStream,
|
|
2209
|
-
payload,
|
|
2210
|
-
fetchImplementation,
|
|
2211
|
-
unstable_getContext
|
|
2212
|
-
]
|
|
2219
|
+
[createFromReadableStream, payload, fetchImplementation, getContext]
|
|
2213
2220
|
);
|
|
2214
2221
|
React4.useEffect(() => {
|
|
2215
2222
|
setIsHydrated();
|
|
@@ -2281,7 +2288,7 @@ function RSCHydratedRouter({
|
|
|
2281
2288
|
future: {
|
|
2282
2289
|
// These flags have no runtime impact so can always be false. If we add
|
|
2283
2290
|
// flags that drive runtime behavior they'll need to be proxied through.
|
|
2284
|
-
|
|
2291
|
+
v8_middleware: false,
|
|
2285
2292
|
unstable_subResourceIntegrity: false
|
|
2286
2293
|
},
|
|
2287
2294
|
isSpaMode: false,
|
|
@@ -2574,19 +2581,48 @@ async function routeRSCServerRequest({
|
|
|
2574
2581
|
if (!serverResponse.body) {
|
|
2575
2582
|
throw new Error("Missing body in server response");
|
|
2576
2583
|
}
|
|
2584
|
+
const detectRedirectResponse = serverResponse.clone();
|
|
2577
2585
|
let serverResponseB = null;
|
|
2578
2586
|
if (hydrate) {
|
|
2579
2587
|
serverResponseB = serverResponse.clone();
|
|
2580
2588
|
}
|
|
2581
2589
|
const body = serverResponse.body;
|
|
2582
|
-
let
|
|
2590
|
+
let buffer;
|
|
2591
|
+
let streamControllers = [];
|
|
2592
|
+
const createStream = () => {
|
|
2593
|
+
if (!buffer) {
|
|
2594
|
+
buffer = [];
|
|
2595
|
+
return body.pipeThrough(
|
|
2596
|
+
new TransformStream({
|
|
2597
|
+
transform(chunk, controller) {
|
|
2598
|
+
buffer.push(chunk);
|
|
2599
|
+
controller.enqueue(chunk);
|
|
2600
|
+
streamControllers.forEach((c) => c.enqueue(chunk));
|
|
2601
|
+
},
|
|
2602
|
+
flush() {
|
|
2603
|
+
streamControllers.forEach((c) => c.close());
|
|
2604
|
+
streamControllers = [];
|
|
2605
|
+
}
|
|
2606
|
+
})
|
|
2607
|
+
);
|
|
2608
|
+
}
|
|
2609
|
+
return new ReadableStream({
|
|
2610
|
+
start(controller) {
|
|
2611
|
+
buffer.forEach((chunk) => controller.enqueue(chunk));
|
|
2612
|
+
streamControllers.push(controller);
|
|
2613
|
+
}
|
|
2614
|
+
});
|
|
2615
|
+
};
|
|
2583
2616
|
const getPayload = async () => {
|
|
2584
|
-
|
|
2585
|
-
payloadPromise = createFromReadableStream(body);
|
|
2586
|
-
return payloadPromise;
|
|
2617
|
+
return createFromReadableStream(createStream());
|
|
2587
2618
|
};
|
|
2588
2619
|
try {
|
|
2589
|
-
|
|
2620
|
+
if (!detectRedirectResponse.body) {
|
|
2621
|
+
throw new Error("Failed to clone server response");
|
|
2622
|
+
}
|
|
2623
|
+
const payload = await createFromReadableStream(
|
|
2624
|
+
detectRedirectResponse.body
|
|
2625
|
+
);
|
|
2590
2626
|
if (serverResponse.status === SINGLE_FETCH_REDIRECT_STATUS && payload.type === "redirect") {
|
|
2591
2627
|
const headers2 = new Headers(serverResponse.headers);
|
|
2592
2628
|
headers2.delete("Content-Encoding");
|
|
@@ -2697,7 +2733,7 @@ function RSCStaticRouter({ getPayload }) {
|
|
|
2697
2733
|
future: {
|
|
2698
2734
|
// These flags have no runtime impact so can always be false. If we add
|
|
2699
2735
|
// flags that drive runtime behavior they'll need to be proxied through.
|
|
2700
|
-
|
|
2736
|
+
v8_middleware: false,
|
|
2701
2737
|
unstable_subResourceIntegrity: false
|
|
2702
2738
|
},
|
|
2703
2739
|
isSpaMode: false,
|