react-router 0.0.0-experimental-d431f1b65 → 0.0.0-experimental-e5dac68cb
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/{browser-Dr0PjLWi.d.mts → browser-Bh26Omrk.d.mts} +8 -0
- package/dist/development/{chunk-F37344ZN.mjs → chunk-USQXBNSR.mjs} +22 -41
- package/dist/development/dom-export.d.mts +2 -1
- package/dist/development/dom-export.js +1 -1
- package/dist/development/dom-export.mjs +2 -2
- package/dist/development/index.d.mts +3 -2
- package/dist/development/index.d.ts +8 -0
- package/dist/development/index.js +22 -41
- package/dist/development/index.mjs +2 -2
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/development/rsc-export.d.mts +14 -3
- package/dist/development/rsc-export.d.ts +14 -3
- package/dist/development/rsc-export.js +96 -46
- package/dist/development/rsc-export.mjs +94 -44
- package/dist/production/{browser-Dr0PjLWi.d.mts → browser-Bh26Omrk.d.mts} +8 -0
- package/dist/production/{chunk-LTAAPV3T.mjs → chunk-SB3D2OAU.mjs} +22 -41
- package/dist/production/dom-export.d.mts +2 -1
- package/dist/production/dom-export.js +1 -1
- package/dist/production/dom-export.mjs +2 -2
- package/dist/production/index.d.mts +3 -2
- package/dist/production/index.d.ts +8 -0
- package/dist/production/index.js +22 -41
- package/dist/production/index.mjs +2 -2
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/production/rsc-export.d.mts +14 -3
- package/dist/production/rsc-export.d.ts +14 -3
- package/dist/production/rsc-export.js +96 -46
- package/dist/production/rsc-export.mjs +94 -44
- package/package.json +1 -1
package/dist/production/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-e5dac68cb
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -5005,10 +5005,6 @@ var DataRouterContext = React.createContext(null);
|
|
|
5005
5005
|
DataRouterContext.displayName = "DataRouter";
|
|
5006
5006
|
var DataRouterStateContext = React.createContext(null);
|
|
5007
5007
|
DataRouterStateContext.displayName = "DataRouterState";
|
|
5008
|
-
var RSCRouterContext = React.createContext(false);
|
|
5009
|
-
function useIsRSCRouterContext() {
|
|
5010
|
-
return React.useContext(RSCRouterContext);
|
|
5011
|
-
}
|
|
5012
5008
|
var ViewTransitionContext = React.createContext({
|
|
5013
5009
|
isTransitioning: false
|
|
5014
5010
|
});
|
|
@@ -5182,7 +5178,6 @@ function useRoutesImpl(routes, locationArg, dataRouterState, future) {
|
|
|
5182
5178
|
// router loaded. We can help them understand how to avoid that.
|
|
5183
5179
|
`useRoutes() may be used only in the context of a <Router> component.`
|
|
5184
5180
|
);
|
|
5185
|
-
let isRSCRouterContext = useIsRSCRouterContext();
|
|
5186
5181
|
let { navigator } = React2.useContext(NavigationContext);
|
|
5187
5182
|
let { matches: parentMatches } = React2.useContext(RouteContext);
|
|
5188
5183
|
let routeMatch = parentMatches[parentMatches.length - 1];
|
|
@@ -5248,8 +5243,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
5248
5243
|
),
|
|
5249
5244
|
parentMatches,
|
|
5250
5245
|
dataRouterState,
|
|
5251
|
-
future
|
|
5252
|
-
isRSCRouterContext
|
|
5246
|
+
future
|
|
5253
5247
|
);
|
|
5254
5248
|
if (locationArg && renderedMatches) {
|
|
5255
5249
|
return /* @__PURE__ */ React2.createElement(
|
|
@@ -5340,7 +5334,7 @@ function RenderedRoute({ routeContext, match, children }) {
|
|
|
5340
5334
|
}
|
|
5341
5335
|
return /* @__PURE__ */ React2.createElement(RouteContext.Provider, { value: routeContext }, children);
|
|
5342
5336
|
}
|
|
5343
|
-
function _renderMatches(matches, parentMatches = [], dataRouterState = null, future = null
|
|
5337
|
+
function _renderMatches(matches, parentMatches = [], dataRouterState = null, future = null) {
|
|
5344
5338
|
if (matches == null) {
|
|
5345
5339
|
if (!dataRouterState) {
|
|
5346
5340
|
return null;
|
|
@@ -5430,9 +5424,6 @@ function _renderMatches(matches, parentMatches = [], dataRouterState = null, fut
|
|
|
5430
5424
|
} else {
|
|
5431
5425
|
children = outlet;
|
|
5432
5426
|
}
|
|
5433
|
-
if (isRSCRouterContext) {
|
|
5434
|
-
children = /* @__PURE__ */ React2.createElement(RedirectBoundary, null, children);
|
|
5435
|
-
}
|
|
5436
5427
|
return /* @__PURE__ */ React2.createElement(
|
|
5437
5428
|
RenderedRoute,
|
|
5438
5429
|
{
|
|
@@ -5459,19 +5450,6 @@ function _renderMatches(matches, parentMatches = [], dataRouterState = null, fut
|
|
|
5459
5450
|
) : getChildren();
|
|
5460
5451
|
}, null);
|
|
5461
5452
|
}
|
|
5462
|
-
var RedirectBoundary = class extends React2.Component {
|
|
5463
|
-
// If the error is Symbol.for("react-router.redirect"), keep rendering children.
|
|
5464
|
-
// If it's anything else, re-throw to bubble it up.
|
|
5465
|
-
static getDerivedStateFromError(error) {
|
|
5466
|
-
if (error === Symbol.for("react-router.redirect")) {
|
|
5467
|
-
return null;
|
|
5468
|
-
}
|
|
5469
|
-
throw error;
|
|
5470
|
-
}
|
|
5471
|
-
render() {
|
|
5472
|
-
return this.props.children;
|
|
5473
|
-
}
|
|
5474
|
-
};
|
|
5475
5453
|
function getDataRouterConsoleError(hookName) {
|
|
5476
5454
|
return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
|
|
5477
5455
|
}
|
|
@@ -8964,7 +8942,7 @@ function mergeRefs(...refs) {
|
|
|
8964
8942
|
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
8965
8943
|
try {
|
|
8966
8944
|
if (isBrowser) {
|
|
8967
|
-
window.__reactRouterVersion = "0.0.0-experimental-
|
|
8945
|
+
window.__reactRouterVersion = "0.0.0-experimental-e5dac68cb";
|
|
8968
8946
|
}
|
|
8969
8947
|
} catch (e) {
|
|
8970
8948
|
}
|
|
@@ -11806,20 +11784,10 @@ function createCallServer({
|
|
|
11806
11784
|
window.location.href = payload.location;
|
|
11807
11785
|
return;
|
|
11808
11786
|
}
|
|
11809
|
-
let reject;
|
|
11810
|
-
const promise = new Promise((resolve, rejectFn) => {
|
|
11811
|
-
reject = rejectFn;
|
|
11812
|
-
});
|
|
11813
|
-
const unsubscribe = window.__router.subscribe(({ navigation }) => {
|
|
11814
|
-
if (navigation.state === "idle") {
|
|
11815
|
-
unsubscribe();
|
|
11816
|
-
reject(Symbol.for("react-router.redirect"));
|
|
11817
|
-
}
|
|
11818
|
-
});
|
|
11819
11787
|
window.__router.navigate(payload.location, {
|
|
11820
11788
|
replace: payload.replace
|
|
11821
11789
|
});
|
|
11822
|
-
return
|
|
11790
|
+
return payload.actionResult;
|
|
11823
11791
|
}
|
|
11824
11792
|
if (payload.type !== "action") {
|
|
11825
11793
|
throw new Error("Unexpected payload type");
|
|
@@ -12160,7 +12128,7 @@ function RSCHydratedRouter({
|
|
|
12160
12128
|
routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" },
|
|
12161
12129
|
routeModules: {}
|
|
12162
12130
|
};
|
|
12163
|
-
return /* @__PURE__ */ React15.createElement(
|
|
12131
|
+
return /* @__PURE__ */ React15.createElement(RSCRouterGlobalErrorBoundary, { location: location2 }, /* @__PURE__ */ React15.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React15.createElement(RouterProvider, { router, flushSync: ReactDOM.flushSync })));
|
|
12164
12132
|
}
|
|
12165
12133
|
function createRouteFromServerManifest(match, payload) {
|
|
12166
12134
|
let hasInitialData = payload && match.id in payload.loaderData;
|
|
@@ -12258,10 +12226,23 @@ var nextPaths2 = /* @__PURE__ */ new Set();
|
|
|
12258
12226
|
var discoveredPathsMaxSize2 = 1e3;
|
|
12259
12227
|
var discoveredPaths2 = /* @__PURE__ */ new Set();
|
|
12260
12228
|
var URL_LIMIT2 = 7680;
|
|
12261
|
-
|
|
12229
|
+
function getManifestUrl(paths) {
|
|
12230
|
+
if (paths.length === 0) {
|
|
12231
|
+
return null;
|
|
12232
|
+
}
|
|
12233
|
+
if (paths.length === 1) {
|
|
12234
|
+
return new URL(`${paths[0]}.manifest`, window.location.origin);
|
|
12235
|
+
}
|
|
12262
12236
|
let basename = (window.__router.basename ?? "").replace(/^\/|\/$/g, "");
|
|
12263
12237
|
let url = new URL(`${basename}/.manifest`, window.location.origin);
|
|
12264
12238
|
paths.sort().forEach((path) => url.searchParams.append("p", path));
|
|
12239
|
+
return url;
|
|
12240
|
+
}
|
|
12241
|
+
async function fetchAndApplyManifestPatches2(paths, decode2, fetchImplementation, signal) {
|
|
12242
|
+
let url = getManifestUrl(paths);
|
|
12243
|
+
if (url == null) {
|
|
12244
|
+
return;
|
|
12245
|
+
}
|
|
12265
12246
|
if (url.toString().length > URL_LIMIT2) {
|
|
12266
12247
|
nextPaths2.clear();
|
|
12267
12248
|
return;
|
|
@@ -12523,7 +12504,7 @@ function RSCStaticRouter({
|
|
|
12523
12504
|
routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" },
|
|
12524
12505
|
routeModules: {}
|
|
12525
12506
|
};
|
|
12526
|
-
return /* @__PURE__ */ React16.createElement(
|
|
12507
|
+
return /* @__PURE__ */ React16.createElement(RSCRouterGlobalErrorBoundary, { location: payload.location }, /* @__PURE__ */ React16.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React16.createElement(
|
|
12527
12508
|
StaticRouterProvider,
|
|
12528
12509
|
{
|
|
12529
12510
|
context,
|
|
@@ -12531,7 +12512,7 @@ function RSCStaticRouter({
|
|
|
12531
12512
|
hydrate: false,
|
|
12532
12513
|
nonce: payload.nonce
|
|
12533
12514
|
}
|
|
12534
|
-
)))
|
|
12515
|
+
)));
|
|
12535
12516
|
}
|
|
12536
12517
|
function isReactServerRequest(url) {
|
|
12537
12518
|
return url.pathname.endsWith(".rsc");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-e5dac68cb
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -135,7 +135,7 @@ import {
|
|
|
135
135
|
withComponentProps,
|
|
136
136
|
withErrorBoundaryProps,
|
|
137
137
|
withHydrateFallbackProps
|
|
138
|
-
} from "./chunk-
|
|
138
|
+
} from "./chunk-SB3D2OAU.mjs";
|
|
139
139
|
export {
|
|
140
140
|
Await,
|
|
141
141
|
BrowserRouter,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ParseOptions, SerializeOptions } from 'cookie';
|
|
2
2
|
export { ParseOptions as CookieParseOptions, SerializeOptions as CookieSerializeOptions } from 'cookie';
|
|
3
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
3
4
|
import * as React from 'react';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -579,7 +580,7 @@ type RedirectFunction = (url: string, init?: number | ResponseInit) => Response;
|
|
|
579
580
|
*
|
|
580
581
|
* @category Utils
|
|
581
582
|
*/
|
|
582
|
-
declare const redirect: RedirectFunction;
|
|
583
|
+
declare const redirect$1: RedirectFunction;
|
|
583
584
|
/**
|
|
584
585
|
* A redirect response that will force a document reload to the new location.
|
|
585
586
|
* Sets the status code and the `Location` header.
|
|
@@ -587,7 +588,7 @@ declare const redirect: RedirectFunction;
|
|
|
587
588
|
*
|
|
588
589
|
* @category Utils
|
|
589
590
|
*/
|
|
590
|
-
declare const redirectDocument: RedirectFunction;
|
|
591
|
+
declare const redirectDocument$1: RedirectFunction;
|
|
591
592
|
/**
|
|
592
593
|
* A redirect response that will perform a `history.replaceState` instead of a
|
|
593
594
|
* `history.pushState` for client-side navigation redirects.
|
|
@@ -596,7 +597,7 @@ declare const redirectDocument: RedirectFunction;
|
|
|
596
597
|
*
|
|
597
598
|
* @category Utils
|
|
598
599
|
*/
|
|
599
|
-
declare const replace: RedirectFunction;
|
|
600
|
+
declare const replace$1: RedirectFunction;
|
|
600
601
|
|
|
601
602
|
/**
|
|
602
603
|
* A Router instance manages all navigation and data loading/mutations
|
|
@@ -1737,6 +1738,15 @@ type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray;
|
|
|
1737
1738
|
*/
|
|
1738
1739
|
type RouteHandle = unknown;
|
|
1739
1740
|
|
|
1741
|
+
type ServerContext = {
|
|
1742
|
+
redirect?: Response;
|
|
1743
|
+
};
|
|
1744
|
+
declare global {
|
|
1745
|
+
var ___reactRouterServerStorage___: AsyncLocalStorage<ServerContext> | undefined;
|
|
1746
|
+
}
|
|
1747
|
+
declare const redirect: typeof redirect$1;
|
|
1748
|
+
declare const redirectDocument: typeof redirectDocument$1;
|
|
1749
|
+
declare const replace: typeof replace$1;
|
|
1740
1750
|
type ServerRouteObjectBase = {
|
|
1741
1751
|
action?: ActionFunction;
|
|
1742
1752
|
clientAction?: ClientActionFunction;
|
|
@@ -1818,6 +1828,7 @@ type ServerRedirectPayload = {
|
|
|
1818
1828
|
location: string;
|
|
1819
1829
|
replace: boolean;
|
|
1820
1830
|
reload: boolean;
|
|
1831
|
+
actionResult?: Promise<unknown>;
|
|
1821
1832
|
};
|
|
1822
1833
|
type ServerPayload = ServerRenderPayload | ServerManifestPayload | ServerActionPayload | ServerRedirectPayload;
|
|
1823
1834
|
type ServerMatch = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ParseOptions, SerializeOptions } from 'cookie';
|
|
2
2
|
export { ParseOptions as CookieParseOptions, SerializeOptions as CookieSerializeOptions } from 'cookie';
|
|
3
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
3
4
|
import * as React from 'react';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -579,7 +580,7 @@ type RedirectFunction = (url: string, init?: number | ResponseInit) => Response;
|
|
|
579
580
|
*
|
|
580
581
|
* @category Utils
|
|
581
582
|
*/
|
|
582
|
-
declare const redirect: RedirectFunction;
|
|
583
|
+
declare const redirect$1: RedirectFunction;
|
|
583
584
|
/**
|
|
584
585
|
* A redirect response that will force a document reload to the new location.
|
|
585
586
|
* Sets the status code and the `Location` header.
|
|
@@ -587,7 +588,7 @@ declare const redirect: RedirectFunction;
|
|
|
587
588
|
*
|
|
588
589
|
* @category Utils
|
|
589
590
|
*/
|
|
590
|
-
declare const redirectDocument: RedirectFunction;
|
|
591
|
+
declare const redirectDocument$1: RedirectFunction;
|
|
591
592
|
/**
|
|
592
593
|
* A redirect response that will perform a `history.replaceState` instead of a
|
|
593
594
|
* `history.pushState` for client-side navigation redirects.
|
|
@@ -596,7 +597,7 @@ declare const redirectDocument: RedirectFunction;
|
|
|
596
597
|
*
|
|
597
598
|
* @category Utils
|
|
598
599
|
*/
|
|
599
|
-
declare const replace: RedirectFunction;
|
|
600
|
+
declare const replace$1: RedirectFunction;
|
|
600
601
|
|
|
601
602
|
/**
|
|
602
603
|
* A Router instance manages all navigation and data loading/mutations
|
|
@@ -1737,6 +1738,15 @@ type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray;
|
|
|
1737
1738
|
*/
|
|
1738
1739
|
type RouteHandle = unknown;
|
|
1739
1740
|
|
|
1741
|
+
type ServerContext = {
|
|
1742
|
+
redirect?: Response;
|
|
1743
|
+
};
|
|
1744
|
+
declare global {
|
|
1745
|
+
var ___reactRouterServerStorage___: AsyncLocalStorage<ServerContext> | undefined;
|
|
1746
|
+
}
|
|
1747
|
+
declare const redirect: typeof redirect$1;
|
|
1748
|
+
declare const redirectDocument: typeof redirectDocument$1;
|
|
1749
|
+
declare const replace: typeof replace$1;
|
|
1740
1750
|
type ServerRouteObjectBase = {
|
|
1741
1751
|
action?: ActionFunction;
|
|
1742
1752
|
clientAction?: ClientActionFunction;
|
|
@@ -1818,6 +1828,7 @@ type ServerRedirectPayload = {
|
|
|
1818
1828
|
location: string;
|
|
1819
1829
|
replace: boolean;
|
|
1820
1830
|
reload: boolean;
|
|
1831
|
+
actionResult?: Promise<unknown>;
|
|
1821
1832
|
};
|
|
1822
1833
|
type ServerPayload = ServerRenderPayload | ServerManifestPayload | ServerActionPayload | ServerRedirectPayload;
|
|
1823
1834
|
type ServerMatch = {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var cookie = require('cookie');
|
|
4
|
+
var async_hooks = require('async_hooks');
|
|
4
5
|
var React = require('react');
|
|
5
6
|
var setCookieParser = require('set-cookie-parser');
|
|
6
7
|
|
|
@@ -25,7 +26,7 @@ function _interopNamespace(e) {
|
|
|
25
26
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
|
-
* react-router v0.0.0-experimental-
|
|
29
|
+
* react-router v0.0.0-experimental-e5dac68cb
|
|
29
30
|
*
|
|
30
31
|
* Copyright (c) Remix Software Inc.
|
|
31
32
|
*
|
|
@@ -2445,6 +2446,31 @@ function prependCookies(parentHeaders, childHeaders) {
|
|
|
2445
2446
|
}
|
|
2446
2447
|
|
|
2447
2448
|
// lib/rsc/server.rsc.ts
|
|
2449
|
+
var ServerStorage = global.___reactRouterServerStorage___ ?? (global.___reactRouterServerStorage___ = new async_hooks.AsyncLocalStorage());
|
|
2450
|
+
var redirect2 = (...args) => {
|
|
2451
|
+
const response = redirect(...args);
|
|
2452
|
+
const ctx = ServerStorage.getStore();
|
|
2453
|
+
if (ctx) {
|
|
2454
|
+
ctx.redirect = response;
|
|
2455
|
+
}
|
|
2456
|
+
return response;
|
|
2457
|
+
};
|
|
2458
|
+
var redirectDocument2 = (...args) => {
|
|
2459
|
+
const response = redirectDocument(...args);
|
|
2460
|
+
const ctx = ServerStorage.getStore();
|
|
2461
|
+
if (ctx) {
|
|
2462
|
+
ctx.redirect = response;
|
|
2463
|
+
}
|
|
2464
|
+
return response;
|
|
2465
|
+
};
|
|
2466
|
+
var replace2 = (...args) => {
|
|
2467
|
+
const response = replace(...args);
|
|
2468
|
+
const ctx = ServerStorage.getStore();
|
|
2469
|
+
if (ctx) {
|
|
2470
|
+
ctx.redirect = response;
|
|
2471
|
+
}
|
|
2472
|
+
return response;
|
|
2473
|
+
};
|
|
2448
2474
|
async function matchRSCServerRequest({
|
|
2449
2475
|
decodeCallServer,
|
|
2450
2476
|
decodeFormAction,
|
|
@@ -2643,62 +2669,86 @@ async function generateRenderResponse(request, routes, isDataRequest, decodeCall
|
|
|
2643
2669
|
hasErrorBoundary: r.ErrorBoundary != null
|
|
2644
2670
|
})
|
|
2645
2671
|
});
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2672
|
+
let actionResult;
|
|
2673
|
+
const ctx = {};
|
|
2674
|
+
const result = await ServerStorage.run(
|
|
2675
|
+
ctx,
|
|
2676
|
+
() => handler.query(request, {
|
|
2677
|
+
skipLoaderErrorBubbling: isDataRequest,
|
|
2678
|
+
skipRevalidation: isSubmission,
|
|
2679
|
+
...routeIdsToLoad ? { filterMatchesToLoad: (m) => routeIdsToLoad.includes(m.route.id) } : null,
|
|
2680
|
+
async unstable_stream(_, query) {
|
|
2681
|
+
let formState;
|
|
2682
|
+
if (request.method === "POST") {
|
|
2683
|
+
let result2 = await processServerAction(
|
|
2684
|
+
request,
|
|
2685
|
+
decodeCallServer,
|
|
2686
|
+
decodeFormAction,
|
|
2687
|
+
decodeFormState,
|
|
2688
|
+
onError
|
|
2689
|
+
);
|
|
2690
|
+
if (isResponse(result2)) {
|
|
2691
|
+
return generateRedirectResponse(
|
|
2692
|
+
statusCode,
|
|
2693
|
+
result2,
|
|
2694
|
+
actionResult,
|
|
2695
|
+
generateResponse
|
|
2696
|
+
);
|
|
2697
|
+
}
|
|
2698
|
+
actionResult = result2?.actionResult;
|
|
2699
|
+
formState = result2?.formState;
|
|
2700
|
+
request = result2?.revalidationRequest ?? request;
|
|
2663
2701
|
}
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2702
|
+
if (ctx.redirect) {
|
|
2703
|
+
return generateRedirectResponse(
|
|
2704
|
+
statusCode,
|
|
2705
|
+
ctx.redirect,
|
|
2706
|
+
actionResult,
|
|
2707
|
+
generateResponse
|
|
2708
|
+
);
|
|
2709
|
+
}
|
|
2710
|
+
let staticContext = await query(request);
|
|
2711
|
+
if (isResponse(staticContext)) {
|
|
2712
|
+
return generateRedirectResponse(
|
|
2713
|
+
statusCode,
|
|
2714
|
+
staticContext,
|
|
2715
|
+
actionResult,
|
|
2716
|
+
generateResponse
|
|
2717
|
+
);
|
|
2718
|
+
}
|
|
2719
|
+
return generateStaticContextResponse(
|
|
2720
|
+
routes,
|
|
2721
|
+
generateResponse,
|
|
2671
2722
|
statusCode,
|
|
2672
|
-
|
|
2673
|
-
|
|
2723
|
+
routeIdsToLoad,
|
|
2724
|
+
isDataRequest,
|
|
2725
|
+
isSubmission,
|
|
2726
|
+
actionResult,
|
|
2727
|
+
formState,
|
|
2728
|
+
staticContext
|
|
2674
2729
|
);
|
|
2675
2730
|
}
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
generateResponse,
|
|
2679
|
-
statusCode,
|
|
2680
|
-
routeIdsToLoad,
|
|
2681
|
-
isDataRequest,
|
|
2682
|
-
isSubmission,
|
|
2683
|
-
actionResult,
|
|
2684
|
-
formState,
|
|
2685
|
-
staticContext
|
|
2686
|
-
);
|
|
2687
|
-
}
|
|
2688
|
-
});
|
|
2731
|
+
})
|
|
2732
|
+
);
|
|
2689
2733
|
if (isRedirectResponse(result)) {
|
|
2690
|
-
return generateRedirectResponse(
|
|
2734
|
+
return generateRedirectResponse(
|
|
2735
|
+
statusCode,
|
|
2736
|
+
result,
|
|
2737
|
+
actionResult,
|
|
2738
|
+
generateResponse
|
|
2739
|
+
);
|
|
2691
2740
|
}
|
|
2692
2741
|
invariant2(isResponse(result), "Expected a response from query");
|
|
2693
2742
|
return result;
|
|
2694
2743
|
}
|
|
2695
|
-
function generateRedirectResponse(statusCode, response, generateResponse) {
|
|
2744
|
+
function generateRedirectResponse(statusCode, response, actionResult, generateResponse) {
|
|
2696
2745
|
let payload = {
|
|
2697
2746
|
type: "redirect",
|
|
2698
2747
|
location: response.headers.get("Location") || "",
|
|
2699
2748
|
reload: response.headers.get("X-Remix-Reload-Document") === "true",
|
|
2700
2749
|
replace: response.headers.get("X-Remix-Replace") === "true",
|
|
2701
|
-
status: response.status
|
|
2750
|
+
status: response.status,
|
|
2751
|
+
actionResult
|
|
2702
2752
|
};
|
|
2703
2753
|
return generateResponse({
|
|
2704
2754
|
statusCode,
|
|
@@ -2977,8 +3027,8 @@ exports.data = data;
|
|
|
2977
3027
|
exports.isCookie = isCookie;
|
|
2978
3028
|
exports.isSession = isSession;
|
|
2979
3029
|
exports.matchRoutes = matchRoutes;
|
|
2980
|
-
exports.redirect =
|
|
2981
|
-
exports.redirectDocument =
|
|
2982
|
-
exports.replace =
|
|
3030
|
+
exports.redirect = redirect2;
|
|
3031
|
+
exports.redirectDocument = redirectDocument2;
|
|
3032
|
+
exports.replace = replace2;
|
|
2983
3033
|
exports.unstable_createContext = unstable_createContext;
|
|
2984
3034
|
exports.unstable_matchRSCServerRequest = matchRSCServerRequest;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { serialize, parse } from 'cookie';
|
|
2
|
+
import { AsyncLocalStorage } from 'async_hooks';
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import { splitCookiesString } from 'set-cookie-parser';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
|
-
* react-router v0.0.0-experimental-
|
|
7
|
+
* react-router v0.0.0-experimental-e5dac68cb
|
|
7
8
|
*
|
|
8
9
|
* Copyright (c) Remix Software Inc.
|
|
9
10
|
*
|
|
@@ -2423,6 +2424,31 @@ function prependCookies(parentHeaders, childHeaders) {
|
|
|
2423
2424
|
}
|
|
2424
2425
|
|
|
2425
2426
|
// lib/rsc/server.rsc.ts
|
|
2427
|
+
var ServerStorage = global.___reactRouterServerStorage___ ?? (global.___reactRouterServerStorage___ = new AsyncLocalStorage());
|
|
2428
|
+
var redirect2 = (...args) => {
|
|
2429
|
+
const response = redirect(...args);
|
|
2430
|
+
const ctx = ServerStorage.getStore();
|
|
2431
|
+
if (ctx) {
|
|
2432
|
+
ctx.redirect = response;
|
|
2433
|
+
}
|
|
2434
|
+
return response;
|
|
2435
|
+
};
|
|
2436
|
+
var redirectDocument2 = (...args) => {
|
|
2437
|
+
const response = redirectDocument(...args);
|
|
2438
|
+
const ctx = ServerStorage.getStore();
|
|
2439
|
+
if (ctx) {
|
|
2440
|
+
ctx.redirect = response;
|
|
2441
|
+
}
|
|
2442
|
+
return response;
|
|
2443
|
+
};
|
|
2444
|
+
var replace2 = (...args) => {
|
|
2445
|
+
const response = replace(...args);
|
|
2446
|
+
const ctx = ServerStorage.getStore();
|
|
2447
|
+
if (ctx) {
|
|
2448
|
+
ctx.redirect = response;
|
|
2449
|
+
}
|
|
2450
|
+
return response;
|
|
2451
|
+
};
|
|
2426
2452
|
async function matchRSCServerRequest({
|
|
2427
2453
|
decodeCallServer,
|
|
2428
2454
|
decodeFormAction,
|
|
@@ -2621,62 +2647,86 @@ async function generateRenderResponse(request, routes, isDataRequest, decodeCall
|
|
|
2621
2647
|
hasErrorBoundary: r.ErrorBoundary != null
|
|
2622
2648
|
})
|
|
2623
2649
|
});
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2650
|
+
let actionResult;
|
|
2651
|
+
const ctx = {};
|
|
2652
|
+
const result = await ServerStorage.run(
|
|
2653
|
+
ctx,
|
|
2654
|
+
() => handler.query(request, {
|
|
2655
|
+
skipLoaderErrorBubbling: isDataRequest,
|
|
2656
|
+
skipRevalidation: isSubmission,
|
|
2657
|
+
...routeIdsToLoad ? { filterMatchesToLoad: (m) => routeIdsToLoad.includes(m.route.id) } : null,
|
|
2658
|
+
async unstable_stream(_, query) {
|
|
2659
|
+
let formState;
|
|
2660
|
+
if (request.method === "POST") {
|
|
2661
|
+
let result2 = await processServerAction(
|
|
2662
|
+
request,
|
|
2663
|
+
decodeCallServer,
|
|
2664
|
+
decodeFormAction,
|
|
2665
|
+
decodeFormState,
|
|
2666
|
+
onError
|
|
2667
|
+
);
|
|
2668
|
+
if (isResponse(result2)) {
|
|
2669
|
+
return generateRedirectResponse(
|
|
2670
|
+
statusCode,
|
|
2671
|
+
result2,
|
|
2672
|
+
actionResult,
|
|
2673
|
+
generateResponse
|
|
2674
|
+
);
|
|
2675
|
+
}
|
|
2676
|
+
actionResult = result2?.actionResult;
|
|
2677
|
+
formState = result2?.formState;
|
|
2678
|
+
request = result2?.revalidationRequest ?? request;
|
|
2641
2679
|
}
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2680
|
+
if (ctx.redirect) {
|
|
2681
|
+
return generateRedirectResponse(
|
|
2682
|
+
statusCode,
|
|
2683
|
+
ctx.redirect,
|
|
2684
|
+
actionResult,
|
|
2685
|
+
generateResponse
|
|
2686
|
+
);
|
|
2687
|
+
}
|
|
2688
|
+
let staticContext = await query(request);
|
|
2689
|
+
if (isResponse(staticContext)) {
|
|
2690
|
+
return generateRedirectResponse(
|
|
2691
|
+
statusCode,
|
|
2692
|
+
staticContext,
|
|
2693
|
+
actionResult,
|
|
2694
|
+
generateResponse
|
|
2695
|
+
);
|
|
2696
|
+
}
|
|
2697
|
+
return generateStaticContextResponse(
|
|
2698
|
+
routes,
|
|
2699
|
+
generateResponse,
|
|
2649
2700
|
statusCode,
|
|
2650
|
-
|
|
2651
|
-
|
|
2701
|
+
routeIdsToLoad,
|
|
2702
|
+
isDataRequest,
|
|
2703
|
+
isSubmission,
|
|
2704
|
+
actionResult,
|
|
2705
|
+
formState,
|
|
2706
|
+
staticContext
|
|
2652
2707
|
);
|
|
2653
2708
|
}
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
generateResponse,
|
|
2657
|
-
statusCode,
|
|
2658
|
-
routeIdsToLoad,
|
|
2659
|
-
isDataRequest,
|
|
2660
|
-
isSubmission,
|
|
2661
|
-
actionResult,
|
|
2662
|
-
formState,
|
|
2663
|
-
staticContext
|
|
2664
|
-
);
|
|
2665
|
-
}
|
|
2666
|
-
});
|
|
2709
|
+
})
|
|
2710
|
+
);
|
|
2667
2711
|
if (isRedirectResponse(result)) {
|
|
2668
|
-
return generateRedirectResponse(
|
|
2712
|
+
return generateRedirectResponse(
|
|
2713
|
+
statusCode,
|
|
2714
|
+
result,
|
|
2715
|
+
actionResult,
|
|
2716
|
+
generateResponse
|
|
2717
|
+
);
|
|
2669
2718
|
}
|
|
2670
2719
|
invariant2(isResponse(result), "Expected a response from query");
|
|
2671
2720
|
return result;
|
|
2672
2721
|
}
|
|
2673
|
-
function generateRedirectResponse(statusCode, response, generateResponse) {
|
|
2722
|
+
function generateRedirectResponse(statusCode, response, actionResult, generateResponse) {
|
|
2674
2723
|
let payload = {
|
|
2675
2724
|
type: "redirect",
|
|
2676
2725
|
location: response.headers.get("Location") || "",
|
|
2677
2726
|
reload: response.headers.get("X-Remix-Reload-Document") === "true",
|
|
2678
2727
|
replace: response.headers.get("X-Remix-Replace") === "true",
|
|
2679
|
-
status: response.status
|
|
2728
|
+
status: response.status,
|
|
2729
|
+
actionResult
|
|
2680
2730
|
};
|
|
2681
2731
|
return generateResponse({
|
|
2682
2732
|
statusCode,
|
|
@@ -2945,4 +2995,4 @@ function canDecodeWithFormData(contentType) {
|
|
|
2945
2995
|
return contentType.match(/\bapplication\/x-www-form-urlencoded\b/) || contentType.match(/\bmultipart\/form-data\b/);
|
|
2946
2996
|
}
|
|
2947
2997
|
|
|
2948
|
-
export { createCookie, createCookieSessionStorage, createMemorySessionStorage, createSession, createSessionStorage, createStaticHandler, data, isCookie, isSession, matchRoutes, redirect, redirectDocument, replace, unstable_createContext, matchRSCServerRequest as unstable_matchRSCServerRequest };
|
|
2998
|
+
export { createCookie, createCookieSessionStorage, createMemorySessionStorage, createSession, createSessionStorage, createStaticHandler, data, isCookie, isSession, matchRoutes, redirect2 as redirect, redirectDocument2 as redirectDocument, replace2 as replace, unstable_createContext, matchRSCServerRequest as unstable_matchRSCServerRequest };
|