react-router 0.0.0-experimental-3d7dcee → 0.0.0-experimental-426e5caec
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 +39 -2
- package/dist/development/{chunk-WJ2QP6HN.mjs → chunk-5HELVQDL.mjs} +179 -249
- package/dist/development/{chunk-S2WJDCRE.js → chunk-KCPD675I.js} +173 -243
- package/dist/{production/chunk-NIW37A6Q.js → development/chunk-KPVSYEOF.js} +135 -135
- package/dist/development/{chunk-QMIAKNRH.mjs → chunk-ZOYSFAC5.mjs} +56 -102
- package/dist/{production/context-DnZM5brG.d.mts → development/context-EwD9faH7.d.mts} +34 -33
- package/dist/development/dom-export.d.mts +3 -3
- package/dist/development/dom-export.d.ts +2 -2
- package/dist/development/dom-export.js +7 -7
- package/dist/development/dom-export.mjs +7 -7
- package/dist/development/{index-react-server-client-zr5eNeut.d.ts → index-react-server-client-CjrUmqhw.d.ts} +12 -12
- package/dist/{production/index-react-server-client-9rHNv-U3.d.mts → development/index-react-server-client-DDdP8ud2.d.mts} +13 -13
- 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 +2 -2
- package/dist/development/index-react-server.d.mts +76 -38
- package/dist/development/index-react-server.d.ts +76 -38
- package/dist/development/index-react-server.js +116 -112
- package/dist/development/index-react-server.mjs +114 -111
- package/dist/development/index.d.mts +53 -15
- package/dist/development/index.d.ts +51 -13
- package/dist/development/index.js +138 -184
- package/dist/development/index.mjs +7 -7
- package/dist/development/lib/types/internal.d.mts +11 -8
- package/dist/development/lib/types/internal.d.ts +10 -7
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/development/{route-data-C24VEkoE.d.mts → route-data-CAnRKu1U.d.mts} +14 -14
- package/dist/development/{routeModules-FY5IBiA_.d.ts → routeModules-CQWjJ9NX.d.ts} +46 -45
- package/dist/production/{chunk-2BFZ6QQU.mjs → chunk-5W7O3ZZ2.mjs} +179 -249
- package/dist/production/{chunk-OFC37UQM.mjs → chunk-DZS627TW.mjs} +56 -102
- package/dist/production/{chunk-7CWVKQLP.js → chunk-NLCKEFES.js} +173 -243
- package/dist/{development/chunk-LSB26UC6.js → production/chunk-TC5SCO6O.js} +135 -135
- package/dist/{development/context-DnZM5brG.d.mts → production/context-EwD9faH7.d.mts} +34 -33
- package/dist/production/dom-export.d.mts +3 -3
- package/dist/production/dom-export.d.ts +2 -2
- package/dist/production/dom-export.js +7 -7
- package/dist/production/dom-export.mjs +7 -7
- package/dist/production/{index-react-server-client-zr5eNeut.d.ts → index-react-server-client-CjrUmqhw.d.ts} +12 -12
- package/dist/{development/index-react-server-client-9rHNv-U3.d.mts → production/index-react-server-client-DDdP8ud2.d.mts} +13 -13
- 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 +2 -2
- package/dist/production/index-react-server.d.mts +76 -38
- package/dist/production/index-react-server.d.ts +76 -38
- package/dist/production/index-react-server.js +116 -112
- package/dist/production/index-react-server.mjs +114 -111
- package/dist/production/index.d.mts +53 -15
- package/dist/production/index.d.ts +51 -13
- package/dist/production/index.js +138 -184
- package/dist/production/index.mjs +7 -7
- package/dist/production/lib/types/internal.d.mts +11 -8
- package/dist/production/lib/types/internal.d.ts +10 -7
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/production/{route-data-C24VEkoE.d.mts → route-data-CAnRKu1U.d.mts} +14 -14
- package/dist/production/{routeModules-FY5IBiA_.d.ts → routeModules-CQWjJ9NX.d.ts} +46 -45
- package/package.json +1 -1
|
@@ -27,7 +27,7 @@ function _interopNamespace(e) {
|
|
|
27
27
|
var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
* react-router v0.0.0-experimental-
|
|
30
|
+
* react-router v0.0.0-experimental-426e5caec
|
|
31
31
|
*
|
|
32
32
|
* Copyright (c) Remix Software Inc.
|
|
33
33
|
*
|
|
@@ -108,13 +108,13 @@ function parsePath(path) {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
// lib/router/utils.ts
|
|
111
|
-
function
|
|
111
|
+
function createContext(defaultValue) {
|
|
112
112
|
return { defaultValue };
|
|
113
113
|
}
|
|
114
114
|
var _map;
|
|
115
|
-
var
|
|
115
|
+
var RouterContextProvider = class {
|
|
116
116
|
/**
|
|
117
|
-
* Create a new `
|
|
117
|
+
* Create a new `RouterContextProvider` instance
|
|
118
118
|
* @param init An optional initial context map to populate the provider with
|
|
119
119
|
*/
|
|
120
120
|
constructor(init) {
|
|
@@ -174,7 +174,7 @@ var unsupportedLazyRouteFunctionKeys = /* @__PURE__ */ new Set([
|
|
|
174
174
|
"path",
|
|
175
175
|
"id",
|
|
176
176
|
"index",
|
|
177
|
-
"
|
|
177
|
+
"middleware",
|
|
178
178
|
"children"
|
|
179
179
|
]);
|
|
180
180
|
function isUnsupportedLazyRouteFunctionKey(key) {
|
|
@@ -695,13 +695,13 @@ function createStaticHandler(routes, opts) {
|
|
|
695
695
|
skipLoaderErrorBubbling,
|
|
696
696
|
skipRevalidation,
|
|
697
697
|
dataStrategy,
|
|
698
|
-
|
|
698
|
+
generateMiddlewareResponse
|
|
699
699
|
} = {}) {
|
|
700
700
|
let url = new URL(request.url);
|
|
701
701
|
let method = request.method;
|
|
702
702
|
let location = createLocation("", createPath(url), null, "default");
|
|
703
703
|
let matches = matchRoutes(dataRoutes, location, basename);
|
|
704
|
-
requestContext = requestContext != null ? requestContext : new
|
|
704
|
+
requestContext = requestContext != null ? requestContext : new RouterContextProvider();
|
|
705
705
|
if (!isValidMethod(method) && method !== "HEAD") {
|
|
706
706
|
let error = getInternalRouterError(405, { method });
|
|
707
707
|
let { matches: methodNotAllowedMatches, route } = getShortCircuitMatches(dataRoutes);
|
|
@@ -739,8 +739,8 @@ function createStaticHandler(routes, opts) {
|
|
|
739
739
|
}
|
|
740
740
|
if (generateMiddlewareResponse) {
|
|
741
741
|
invariant(
|
|
742
|
-
requestContext instanceof
|
|
743
|
-
"When using middleware in `staticHandler.query()`, any provided `requestContext` must be an instance of `
|
|
742
|
+
requestContext instanceof RouterContextProvider,
|
|
743
|
+
"When using middleware in `staticHandler.query()`, any provided `requestContext` must be an instance of `RouterContextProvider`"
|
|
744
744
|
);
|
|
745
745
|
try {
|
|
746
746
|
await loadLazyMiddlewareForMatches(
|
|
@@ -760,7 +760,7 @@ function createStaticHandler(routes, opts) {
|
|
|
760
760
|
},
|
|
761
761
|
async () => {
|
|
762
762
|
let res = await generateMiddlewareResponse(
|
|
763
|
-
async (revalidationRequest) => {
|
|
763
|
+
async (revalidationRequest, opts2 = {}) => {
|
|
764
764
|
let result2 = await queryImpl(
|
|
765
765
|
revalidationRequest,
|
|
766
766
|
location,
|
|
@@ -769,7 +769,7 @@ function createStaticHandler(routes, opts) {
|
|
|
769
769
|
dataStrategy || null,
|
|
770
770
|
skipLoaderErrorBubbling === true,
|
|
771
771
|
null,
|
|
772
|
-
filterMatchesToLoad
|
|
772
|
+
"filterMatchesToLoad" in opts2 ? opts2.filterMatchesToLoad ?? null : null,
|
|
773
773
|
skipRevalidation === true
|
|
774
774
|
);
|
|
775
775
|
if (isResponse(result2)) {
|
|
@@ -782,9 +782,23 @@ function createStaticHandler(routes, opts) {
|
|
|
782
782
|
return res;
|
|
783
783
|
},
|
|
784
784
|
async (error, routeId) => {
|
|
785
|
-
if (
|
|
785
|
+
if (isRedirectResponse(error)) {
|
|
786
786
|
return error;
|
|
787
787
|
}
|
|
788
|
+
if (isResponse(error)) {
|
|
789
|
+
try {
|
|
790
|
+
error = new ErrorResponseImpl(
|
|
791
|
+
error.status,
|
|
792
|
+
error.statusText,
|
|
793
|
+
await parseResponseBody(error)
|
|
794
|
+
);
|
|
795
|
+
} catch (e) {
|
|
796
|
+
error = e;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
if (isDataWithResponseInit(error)) {
|
|
800
|
+
error = dataWithResponseInitToErrorResponse(error);
|
|
801
|
+
}
|
|
788
802
|
if (renderedStaticContext) {
|
|
789
803
|
if (routeId in renderedStaticContext.loaderData) {
|
|
790
804
|
renderedStaticContext.loaderData[routeId] = void 0;
|
|
@@ -853,13 +867,13 @@ function createStaticHandler(routes, opts) {
|
|
|
853
867
|
routeId,
|
|
854
868
|
requestContext,
|
|
855
869
|
dataStrategy,
|
|
856
|
-
|
|
870
|
+
generateMiddlewareResponse
|
|
857
871
|
} = {}) {
|
|
858
872
|
let url = new URL(request.url);
|
|
859
873
|
let method = request.method;
|
|
860
874
|
let location = createLocation("", createPath(url), null, "default");
|
|
861
875
|
let matches = matchRoutes(dataRoutes, location, basename);
|
|
862
|
-
requestContext = requestContext != null ? requestContext : new
|
|
876
|
+
requestContext = requestContext != null ? requestContext : new RouterContextProvider();
|
|
863
877
|
if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") {
|
|
864
878
|
throw getInternalRouterError(405, { method });
|
|
865
879
|
} else if (!matches) {
|
|
@@ -876,8 +890,8 @@ function createStaticHandler(routes, opts) {
|
|
|
876
890
|
}
|
|
877
891
|
if (generateMiddlewareResponse) {
|
|
878
892
|
invariant(
|
|
879
|
-
requestContext instanceof
|
|
880
|
-
"When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `
|
|
893
|
+
requestContext instanceof RouterContextProvider,
|
|
894
|
+
"When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `RouterContextProvider`"
|
|
881
895
|
);
|
|
882
896
|
await loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties);
|
|
883
897
|
let response = await runServerMiddlewarePipeline(
|
|
@@ -910,8 +924,8 @@ function createStaticHandler(routes, opts) {
|
|
|
910
924
|
return res;
|
|
911
925
|
},
|
|
912
926
|
(error) => {
|
|
913
|
-
if (
|
|
914
|
-
return Promise.resolve(
|
|
927
|
+
if (isDataWithResponseInit(error)) {
|
|
928
|
+
return Promise.resolve(dataWithResponseInitToResponse(error));
|
|
915
929
|
}
|
|
916
930
|
if (isResponse(error)) {
|
|
917
931
|
return Promise.resolve(error);
|
|
@@ -1238,8 +1252,12 @@ function createStaticHandler(routes, opts) {
|
|
|
1238
1252
|
basename
|
|
1239
1253
|
);
|
|
1240
1254
|
}
|
|
1241
|
-
if (
|
|
1242
|
-
|
|
1255
|
+
if (isRouteRequest) {
|
|
1256
|
+
if (isResponse(result.result)) {
|
|
1257
|
+
throw result;
|
|
1258
|
+
} else if (isDataWithResponseInit(result.result)) {
|
|
1259
|
+
throw dataWithResponseInitToResponse(result.result);
|
|
1260
|
+
}
|
|
1243
1261
|
}
|
|
1244
1262
|
dataResults[match.route.id] = await convertDataStrategyResultToDataResult(result);
|
|
1245
1263
|
})
|
|
@@ -1474,11 +1492,11 @@ function isNonNullable(value) {
|
|
|
1474
1492
|
}
|
|
1475
1493
|
function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties) {
|
|
1476
1494
|
let promises = matches.map(({ route }) => {
|
|
1477
|
-
if (typeof route.lazy !== "object" || !route.lazy.
|
|
1495
|
+
if (typeof route.lazy !== "object" || !route.lazy.middleware) {
|
|
1478
1496
|
return void 0;
|
|
1479
1497
|
}
|
|
1480
1498
|
return loadLazyRouteProperty({
|
|
1481
|
-
key: "
|
|
1499
|
+
key: "middleware",
|
|
1482
1500
|
route,
|
|
1483
1501
|
manifest,
|
|
1484
1502
|
mapRouteProperties
|
|
@@ -1495,31 +1513,37 @@ async function defaultDataStrategy(args) {
|
|
|
1495
1513
|
});
|
|
1496
1514
|
return keyedResults;
|
|
1497
1515
|
}
|
|
1498
|
-
|
|
1516
|
+
function runServerMiddlewarePipeline(args, handler, errorHandler) {
|
|
1517
|
+
return runMiddlewarePipeline(
|
|
1518
|
+
args,
|
|
1519
|
+
handler,
|
|
1520
|
+
processResult,
|
|
1521
|
+
isResponse,
|
|
1522
|
+
errorHandler
|
|
1523
|
+
);
|
|
1524
|
+
function processResult(result) {
|
|
1525
|
+
return isDataWithResponseInit(result) ? dataWithResponseInitToResponse(result) : result;
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
async function runMiddlewarePipeline(args, handler, processResult, isResult, errorHandler) {
|
|
1499
1529
|
let { matches, request, params, context } = args;
|
|
1500
1530
|
let tuples = matches.flatMap(
|
|
1501
|
-
(m) => m.route.
|
|
1531
|
+
(m) => m.route.middleware ? m.route.middleware.map((fn) => [m.route.id, fn]) : []
|
|
1502
1532
|
);
|
|
1503
|
-
let result = await
|
|
1533
|
+
let result = await callRouteMiddleware(
|
|
1504
1534
|
{ request, params, context },
|
|
1505
1535
|
tuples,
|
|
1506
1536
|
handler,
|
|
1537
|
+
processResult,
|
|
1538
|
+
isResult,
|
|
1507
1539
|
errorHandler
|
|
1508
1540
|
);
|
|
1509
|
-
|
|
1510
|
-
return result;
|
|
1511
|
-
}
|
|
1512
|
-
invariant(false, `Expected a Response to be returned from route middleware`);
|
|
1541
|
+
return result;
|
|
1513
1542
|
}
|
|
1514
|
-
async function
|
|
1543
|
+
async function callRouteMiddleware(args, middlewares, handler, processResult, isResult, errorHandler, idx = 0) {
|
|
1515
1544
|
let { request } = args;
|
|
1516
1545
|
if (request.signal.aborted) {
|
|
1517
|
-
|
|
1518
|
-
throw request.signal.reason;
|
|
1519
|
-
}
|
|
1520
|
-
throw new Error(
|
|
1521
|
-
`Request aborted without an \`AbortSignal.reason\`: ${request.method} ${request.url}`
|
|
1522
|
-
);
|
|
1546
|
+
throw request.signal.reason ?? new Error(`Request aborted: ${request.method} ${request.url}`);
|
|
1523
1547
|
}
|
|
1524
1548
|
let tuple = middlewares[idx];
|
|
1525
1549
|
if (!tuple) {
|
|
@@ -1527,67 +1551,47 @@ async function callServerRouteMiddleware(args, middlewares, handler, errorHandle
|
|
|
1527
1551
|
return result;
|
|
1528
1552
|
}
|
|
1529
1553
|
let [routeId, middleware] = tuple;
|
|
1530
|
-
let
|
|
1531
|
-
let nextResult = void 0;
|
|
1554
|
+
let nextResult;
|
|
1532
1555
|
let next = async () => {
|
|
1533
|
-
if (
|
|
1556
|
+
if (nextResult) {
|
|
1534
1557
|
throw new Error("You may only call `next()` once per middleware");
|
|
1535
1558
|
}
|
|
1536
|
-
nextCalled = true;
|
|
1537
1559
|
try {
|
|
1538
|
-
let result = await
|
|
1560
|
+
let result = await callRouteMiddleware(
|
|
1539
1561
|
args,
|
|
1540
1562
|
middlewares,
|
|
1541
1563
|
handler,
|
|
1564
|
+
processResult,
|
|
1565
|
+
isResult,
|
|
1542
1566
|
errorHandler,
|
|
1543
1567
|
idx + 1
|
|
1544
1568
|
);
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
nextResult =
|
|
1549
|
-
return nextResult;
|
|
1550
|
-
} catch (e) {
|
|
1551
|
-
nextResult = await errorHandler(
|
|
1552
|
-
// Convert thrown data() values to ErrorResponses
|
|
1553
|
-
isDataWithResponseInit(e) ? dataWithResponseInitToErrorResponse(e) : e,
|
|
1554
|
-
routeId
|
|
1555
|
-
);
|
|
1556
|
-
return nextResult;
|
|
1569
|
+
nextResult = { value: result };
|
|
1570
|
+
return nextResult.value;
|
|
1571
|
+
} catch (error) {
|
|
1572
|
+
nextResult = { value: await errorHandler(error, routeId, nextResult) };
|
|
1573
|
+
return nextResult.value;
|
|
1557
1574
|
}
|
|
1558
1575
|
};
|
|
1559
1576
|
try {
|
|
1560
|
-
let
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
params: args.params,
|
|
1564
|
-
context: args.context
|
|
1565
|
-
},
|
|
1566
|
-
next
|
|
1567
|
-
);
|
|
1568
|
-
if (isDataWithResponseInit(result)) {
|
|
1569
|
-
result = dataWithResponseInitToResponse(result);
|
|
1570
|
-
}
|
|
1571
|
-
if (nextCalled) {
|
|
1572
|
-
return typeof result === "undefined" ? nextResult : result;
|
|
1573
|
-
} else if (isResponse(result)) {
|
|
1577
|
+
let value = await middleware(args, next);
|
|
1578
|
+
let result = value != null ? processResult(value) : void 0;
|
|
1579
|
+
if (isResult(result)) {
|
|
1574
1580
|
return result;
|
|
1581
|
+
} else if (nextResult) {
|
|
1582
|
+
return result ?? nextResult.value;
|
|
1575
1583
|
} else {
|
|
1576
|
-
nextResult = await next();
|
|
1577
|
-
return nextResult;
|
|
1584
|
+
nextResult = { value: await next() };
|
|
1585
|
+
return nextResult.value;
|
|
1578
1586
|
}
|
|
1579
|
-
} catch (
|
|
1580
|
-
let response = await errorHandler(
|
|
1581
|
-
// Convert thrown data() values to ErrorResponses
|
|
1582
|
-
isDataWithResponseInit(e) ? dataWithResponseInitToErrorResponse(e) : e,
|
|
1583
|
-
routeId
|
|
1584
|
-
);
|
|
1587
|
+
} catch (error) {
|
|
1588
|
+
let response = await errorHandler(error, routeId, nextResult);
|
|
1585
1589
|
return response;
|
|
1586
1590
|
}
|
|
1587
1591
|
}
|
|
1588
1592
|
function getDataStrategyMatchLazyPromises(mapRouteProperties, manifest, request, match, lazyRoutePropertiesToSkip) {
|
|
1589
1593
|
let lazyMiddlewarePromise = loadLazyRouteProperty({
|
|
1590
|
-
key: "
|
|
1594
|
+
key: "middleware",
|
|
1591
1595
|
route: match.route,
|
|
1592
1596
|
manifest,
|
|
1593
1597
|
mapRouteProperties
|
|
@@ -1687,15 +1691,15 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
1687
1691
|
context: scopedContext,
|
|
1688
1692
|
matches
|
|
1689
1693
|
};
|
|
1690
|
-
let
|
|
1694
|
+
let runClientMiddleware = () => {
|
|
1691
1695
|
throw new Error(
|
|
1692
|
-
"You cannot call `
|
|
1696
|
+
"You cannot call `runClientMiddleware()` from a static handler `dataStrategy`. Middleware is run outside of `dataStrategy` during SSR in order to bubble up the Response. You can enable middleware via the `respond` API in `query`/`queryRoute`"
|
|
1693
1697
|
);
|
|
1694
1698
|
} ;
|
|
1695
1699
|
let results = await dataStrategyImpl({
|
|
1696
1700
|
...dataStrategyArgs,
|
|
1697
1701
|
fetcherKey,
|
|
1698
|
-
|
|
1702
|
+
runClientMiddleware
|
|
1699
1703
|
});
|
|
1700
1704
|
try {
|
|
1701
1705
|
await Promise.all(
|
|
@@ -1807,21 +1811,19 @@ async function callLoaderOrAction({
|
|
|
1807
1811
|
}
|
|
1808
1812
|
return result;
|
|
1809
1813
|
}
|
|
1814
|
+
async function parseResponseBody(response) {
|
|
1815
|
+
let contentType = response.headers.get("Content-Type");
|
|
1816
|
+
if (contentType && /\bapplication\/json\b/.test(contentType)) {
|
|
1817
|
+
return response.body == null ? null : response.json();
|
|
1818
|
+
}
|
|
1819
|
+
return response.text();
|
|
1820
|
+
}
|
|
1810
1821
|
async function convertDataStrategyResultToDataResult(dataStrategyResult) {
|
|
1811
1822
|
let { result, type } = dataStrategyResult;
|
|
1812
1823
|
if (isResponse(result)) {
|
|
1813
1824
|
let data2;
|
|
1814
1825
|
try {
|
|
1815
|
-
|
|
1816
|
-
if (contentType && /\bapplication\/json\b/.test(contentType)) {
|
|
1817
|
-
if (result.body == null) {
|
|
1818
|
-
data2 = null;
|
|
1819
|
-
} else {
|
|
1820
|
-
data2 = await result.json();
|
|
1821
|
-
}
|
|
1822
|
-
} else {
|
|
1823
|
-
data2 = await result.text();
|
|
1824
|
-
}
|
|
1826
|
+
data2 = await parseResponseBody(result);
|
|
1825
1827
|
} catch (e) {
|
|
1826
1828
|
return { type: "error" /* error */, error: e };
|
|
1827
1829
|
}
|
|
@@ -2021,10 +2023,7 @@ function getInternalRouterError(status, {
|
|
|
2021
2023
|
);
|
|
2022
2024
|
}
|
|
2023
2025
|
function dataWithResponseInitToResponse(data2) {
|
|
2024
|
-
return
|
|
2025
|
-
typeof data2.data === "string" ? data2.data : JSON.stringify(data2.data),
|
|
2026
|
-
data2.init || void 0
|
|
2027
|
-
);
|
|
2026
|
+
return Response.json(data2.data, data2.init ?? void 0);
|
|
2028
2027
|
}
|
|
2029
2028
|
function dataWithResponseInitToErrorResponse(data2) {
|
|
2030
2029
|
return new ErrorResponseImpl(
|
|
@@ -2033,15 +2032,6 @@ function dataWithResponseInitToErrorResponse(data2) {
|
|
|
2033
2032
|
data2.data
|
|
2034
2033
|
);
|
|
2035
2034
|
}
|
|
2036
|
-
function errorResponseToResponse(error) {
|
|
2037
|
-
return new Response(
|
|
2038
|
-
typeof error.data === "string" ? error.data : JSON.stringify(error.data),
|
|
2039
|
-
{
|
|
2040
|
-
status: error.status,
|
|
2041
|
-
statusText: error.statusText
|
|
2042
|
-
}
|
|
2043
|
-
);
|
|
2044
|
-
}
|
|
2045
2035
|
function isDataStrategyResult(result) {
|
|
2046
2036
|
return result != null && typeof result === "object" && "type" in result && "result" in result && (result.type === "data" /* data */ || result.type === "error" /* error */);
|
|
2047
2037
|
}
|
|
@@ -2343,9 +2333,13 @@ async function processServerAction(request, basename, decodeReply, loadServerAct
|
|
|
2343
2333
|
}
|
|
2344
2334
|
onError?.(error);
|
|
2345
2335
|
}
|
|
2336
|
+
let maybeFormData = actionArgs.length === 1 ? actionArgs[0] : actionArgs[1];
|
|
2337
|
+
let formData = maybeFormData && typeof maybeFormData === "object" && maybeFormData instanceof FormData ? maybeFormData : null;
|
|
2338
|
+
let skipRevalidation = formData?.has("$SKIP_REVALIDATION") ?? false;
|
|
2346
2339
|
return {
|
|
2347
2340
|
actionResult,
|
|
2348
|
-
revalidationRequest: getRevalidationRequest()
|
|
2341
|
+
revalidationRequest: getRevalidationRequest(),
|
|
2342
|
+
skipRevalidation
|
|
2349
2343
|
};
|
|
2350
2344
|
} else if (isFormRequest) {
|
|
2351
2345
|
const formData = await request.clone().formData();
|
|
@@ -2374,7 +2368,8 @@ async function processServerAction(request, basename, decodeReply, loadServerAct
|
|
|
2374
2368
|
}
|
|
2375
2369
|
return {
|
|
2376
2370
|
formState,
|
|
2377
|
-
revalidationRequest: getRevalidationRequest()
|
|
2371
|
+
revalidationRequest: getRevalidationRequest(),
|
|
2372
|
+
skipRevalidation: false
|
|
2378
2373
|
};
|
|
2379
2374
|
}
|
|
2380
2375
|
}
|
|
@@ -2387,7 +2382,7 @@ async function generateResourceResponse(request, routes, basename, routeId, requ
|
|
|
2387
2382
|
let response = await staticHandler.queryRoute(request, {
|
|
2388
2383
|
routeId,
|
|
2389
2384
|
requestContext,
|
|
2390
|
-
async
|
|
2385
|
+
async generateMiddlewareResponse(queryRoute) {
|
|
2391
2386
|
try {
|
|
2392
2387
|
let response2 = await queryRoute(request);
|
|
2393
2388
|
return generateResourceResponse2(response2);
|
|
@@ -2448,9 +2443,10 @@ async function generateRenderResponse(request, routes, basename, isDataRequest,
|
|
|
2448
2443
|
requestContext,
|
|
2449
2444
|
skipLoaderErrorBubbling: isDataRequest,
|
|
2450
2445
|
skipRevalidation: isSubmission,
|
|
2451
|
-
...routeIdsToLoad ? { filterMatchesToLoad: (m) => routeIdsToLoad.includes(m.route.id) } :
|
|
2452
|
-
async
|
|
2446
|
+
...routeIdsToLoad ? { filterMatchesToLoad: (m) => routeIdsToLoad.includes(m.route.id) } : {},
|
|
2447
|
+
async generateMiddlewareResponse(query) {
|
|
2453
2448
|
let formState;
|
|
2449
|
+
let skipRevalidation = false;
|
|
2454
2450
|
if (request.method === "POST") {
|
|
2455
2451
|
ctx.runningAction = true;
|
|
2456
2452
|
let result2 = await processServerAction(
|
|
@@ -2475,6 +2471,7 @@ async function generateRenderResponse(request, routes, basename, isDataRequest,
|
|
|
2475
2471
|
ctx.redirect?.headers
|
|
2476
2472
|
);
|
|
2477
2473
|
}
|
|
2474
|
+
skipRevalidation = result2?.skipRevalidation ?? false;
|
|
2478
2475
|
actionResult = result2?.actionResult;
|
|
2479
2476
|
formState = result2?.formState;
|
|
2480
2477
|
request = result2?.revalidationRequest ?? request;
|
|
@@ -2490,7 +2487,12 @@ async function generateRenderResponse(request, routes, basename, isDataRequest,
|
|
|
2490
2487
|
);
|
|
2491
2488
|
}
|
|
2492
2489
|
}
|
|
2493
|
-
let staticContext = await query(
|
|
2490
|
+
let staticContext = await query(
|
|
2491
|
+
request,
|
|
2492
|
+
skipRevalidation ? {
|
|
2493
|
+
filterMatchesToLoad: () => false
|
|
2494
|
+
} : void 0
|
|
2495
|
+
);
|
|
2494
2496
|
if (isResponse(staticContext)) {
|
|
2495
2497
|
return generateRedirectResponse(
|
|
2496
2498
|
staticContext,
|
|
@@ -2514,6 +2516,7 @@ async function generateRenderResponse(request, routes, basename, isDataRequest,
|
|
|
2514
2516
|
formState,
|
|
2515
2517
|
staticContext,
|
|
2516
2518
|
temporaryReferences,
|
|
2519
|
+
skipRevalidation,
|
|
2517
2520
|
ctx.redirect?.headers
|
|
2518
2521
|
);
|
|
2519
2522
|
}
|
|
@@ -2565,7 +2568,7 @@ function generateRedirectResponse(response, actionResult, basename, isDataReques
|
|
|
2565
2568
|
{ temporaryReferences }
|
|
2566
2569
|
);
|
|
2567
2570
|
}
|
|
2568
|
-
async function generateStaticContextResponse(routes, basename, generateResponse, statusCode, routeIdsToLoad, isDataRequest, isSubmission, actionResult, formState, staticContext, temporaryReferences, sideEffectRedirectHeaders) {
|
|
2571
|
+
async function generateStaticContextResponse(routes, basename, generateResponse, statusCode, routeIdsToLoad, isDataRequest, isSubmission, actionResult, formState, staticContext, temporaryReferences, skipRevalidation, sideEffectRedirectHeaders) {
|
|
2569
2572
|
statusCode = staticContext.statusCode ?? statusCode;
|
|
2570
2573
|
if (staticContext.errors) {
|
|
2571
2574
|
staticContext.errors = Object.fromEntries(
|
|
@@ -2612,7 +2615,7 @@ async function generateStaticContextResponse(routes, basename, generateResponse,
|
|
|
2612
2615
|
payload = {
|
|
2613
2616
|
type: "action",
|
|
2614
2617
|
actionResult,
|
|
2615
|
-
rerender: renderPayloadPromise()
|
|
2618
|
+
rerender: skipRevalidation ? void 0 : renderPayloadPromise()
|
|
2616
2619
|
};
|
|
2617
2620
|
} else if (isSubmission && isDataRequest) {
|
|
2618
2621
|
payload = {
|
|
@@ -3255,6 +3258,8 @@ Object.defineProperty(exports, "unstable_HistoryRouter", {
|
|
|
3255
3258
|
enumerable: true,
|
|
3256
3259
|
get: function () { return reactServerClient.unstable_HistoryRouter; }
|
|
3257
3260
|
});
|
|
3261
|
+
exports.RouterContextProvider = RouterContextProvider;
|
|
3262
|
+
exports.createContext = createContext;
|
|
3258
3263
|
exports.createCookie = createCookie;
|
|
3259
3264
|
exports.createCookieSessionStorage = createCookieSessionStorage;
|
|
3260
3265
|
exports.createMemorySessionStorage = createMemorySessionStorage;
|
|
@@ -3263,11 +3268,10 @@ exports.createSessionStorage = createSessionStorage;
|
|
|
3263
3268
|
exports.createStaticHandler = createStaticHandler;
|
|
3264
3269
|
exports.data = data;
|
|
3265
3270
|
exports.isCookie = isCookie;
|
|
3271
|
+
exports.isRouteErrorResponse = isRouteErrorResponse;
|
|
3266
3272
|
exports.isSession = isSession;
|
|
3267
3273
|
exports.matchRoutes = matchRoutes;
|
|
3268
3274
|
exports.redirect = redirect2;
|
|
3269
3275
|
exports.redirectDocument = redirectDocument2;
|
|
3270
3276
|
exports.replace = replace2;
|
|
3271
|
-
exports.unstable_RouterContextProvider = unstable_RouterContextProvider;
|
|
3272
|
-
exports.unstable_createContext = unstable_createContext;
|
|
3273
3277
|
exports.unstable_matchRSCServerRequest = matchRSCServerRequest;
|