react-router 7.8.2 → 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 +22 -0
- package/dist/development/{chunk-5UALIXAM.mjs → chunk-3TJX7VNY.mjs} +93 -57
- package/dist/development/{chunk-CSDGKXLR.js → chunk-4J2JOVAI.js} +135 -135
- package/dist/development/{chunk-PVWAREVJ.mjs → chunk-EAIS2CTK.mjs} +43 -44
- package/dist/development/{chunk-ZO66TDGB.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-REDRD2MB.mjs → chunk-47NS5WEV.mjs} +43 -44
- package/dist/production/{chunk-JNT5PWCQ.js → chunk-CSESPFUI.js} +135 -135
- package/dist/production/{chunk-Z56HUDN5.js → chunk-LQAK2UKE.js} +37 -38
- package/dist/production/{chunk-KWHRV2I7.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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
|
|
2
|
-
* react-router v7.
|
|
2
|
+
* react-router v7.9.0-pre.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -362,13 +362,13 @@ function createBrowserURLImpl(to, isAbsolute = false) {
|
|
|
362
362
|
}
|
|
363
363
|
|
|
364
364
|
// lib/router/utils.ts
|
|
365
|
-
function
|
|
365
|
+
function createContext(defaultValue) {
|
|
366
366
|
return { defaultValue };
|
|
367
367
|
}
|
|
368
368
|
var _map;
|
|
369
|
-
var
|
|
369
|
+
var RouterContextProvider = class {
|
|
370
370
|
/**
|
|
371
|
-
* Create a new `
|
|
371
|
+
* Create a new `RouterContextProvider` instance
|
|
372
372
|
* @param init An optional initial context map to populate the provider with
|
|
373
373
|
*/
|
|
374
374
|
constructor(init) {
|
|
@@ -428,7 +428,7 @@ var unsupportedLazyRouteFunctionKeys = /* @__PURE__ */ new Set([
|
|
|
428
428
|
"path",
|
|
429
429
|
"id",
|
|
430
430
|
"index",
|
|
431
|
-
"
|
|
431
|
+
"middleware",
|
|
432
432
|
"children"
|
|
433
433
|
]);
|
|
434
434
|
function isUnsupportedLazyRouteFunctionKey(key) {
|
|
@@ -1466,7 +1466,7 @@ function createRouter(init) {
|
|
|
1466
1466
|
pendingNavigationController.signal,
|
|
1467
1467
|
opts && opts.submission
|
|
1468
1468
|
);
|
|
1469
|
-
let scopedContext = init.
|
|
1469
|
+
let scopedContext = init.getContext ? await init.getContext() : new RouterContextProvider();
|
|
1470
1470
|
let pendingActionResult;
|
|
1471
1471
|
if (opts && opts.pendingError) {
|
|
1472
1472
|
pendingActionResult = [
|
|
@@ -1756,7 +1756,7 @@ function createRouter(init) {
|
|
|
1756
1756
|
pendingActionResult
|
|
1757
1757
|
);
|
|
1758
1758
|
pendingNavigationLoadId = ++incrementingLoadId;
|
|
1759
|
-
if (!init.dataStrategy && !dsMatches.some((m) => m.shouldLoad) && !dsMatches.some((m) => m.route.
|
|
1759
|
+
if (!init.dataStrategy && !dsMatches.some((m) => m.shouldLoad) && !dsMatches.some((m) => m.route.middleware) && revalidatingFetchers.length === 0) {
|
|
1760
1760
|
let updatedFetchers2 = markFetchRedirectsDone();
|
|
1761
1761
|
completeNavigation(
|
|
1762
1762
|
location,
|
|
@@ -1910,7 +1910,7 @@ function createRouter(init) {
|
|
|
1910
1910
|
setFetcherError(key, routeId, error, { flushSync });
|
|
1911
1911
|
return;
|
|
1912
1912
|
}
|
|
1913
|
-
let scopedContext = init.
|
|
1913
|
+
let scopedContext = init.getContext ? await init.getContext() : new RouterContextProvider();
|
|
1914
1914
|
let preventScrollReset = (opts && opts.preventScrollReset) === true;
|
|
1915
1915
|
if (submission && isMutationMethod(submission.formMethod)) {
|
|
1916
1916
|
await handleFetcherAction(
|
|
@@ -2761,13 +2761,13 @@ function createStaticHandler(routes, opts) {
|
|
|
2761
2761
|
skipLoaderErrorBubbling,
|
|
2762
2762
|
skipRevalidation,
|
|
2763
2763
|
dataStrategy,
|
|
2764
|
-
|
|
2764
|
+
generateMiddlewareResponse
|
|
2765
2765
|
} = {}) {
|
|
2766
2766
|
let url = new URL(request.url);
|
|
2767
2767
|
let method = request.method;
|
|
2768
2768
|
let location = createLocation("", createPath(url), null, "default");
|
|
2769
2769
|
let matches = matchRoutes(dataRoutes, location, basename);
|
|
2770
|
-
requestContext = requestContext != null ? requestContext : new
|
|
2770
|
+
requestContext = requestContext != null ? requestContext : new RouterContextProvider();
|
|
2771
2771
|
if (!isValidMethod(method) && method !== "HEAD") {
|
|
2772
2772
|
let error = getInternalRouterError(405, { method });
|
|
2773
2773
|
let { matches: methodNotAllowedMatches, route } = getShortCircuitMatches(dataRoutes);
|
|
@@ -2805,8 +2805,8 @@ function createStaticHandler(routes, opts) {
|
|
|
2805
2805
|
}
|
|
2806
2806
|
if (generateMiddlewareResponse) {
|
|
2807
2807
|
invariant(
|
|
2808
|
-
requestContext instanceof
|
|
2809
|
-
"When using middleware in `staticHandler.query()`, any provided `requestContext` must be an instance of `
|
|
2808
|
+
requestContext instanceof RouterContextProvider,
|
|
2809
|
+
"When using middleware in `staticHandler.query()`, any provided `requestContext` must be an instance of `RouterContextProvider`"
|
|
2810
2810
|
);
|
|
2811
2811
|
try {
|
|
2812
2812
|
await loadLazyMiddlewareForMatches(
|
|
@@ -2835,7 +2835,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2835
2835
|
dataStrategy || null,
|
|
2836
2836
|
skipLoaderErrorBubbling === true,
|
|
2837
2837
|
null,
|
|
2838
|
-
"filterMatchesToLoad" in opts2 ? _nullishCoalesce(opts2.filterMatchesToLoad, () => ( null)) : null,
|
|
2838
|
+
"filterMatchesToLoad" in opts2 ? _nullishCoalesce(opts2.filterMatchesToLoad, () => ( null)) : _nullishCoalesce(filterMatchesToLoad, () => ( null)),
|
|
2839
2839
|
skipRevalidation === true
|
|
2840
2840
|
);
|
|
2841
2841
|
if (isResponse(result2)) {
|
|
@@ -2933,13 +2933,13 @@ function createStaticHandler(routes, opts) {
|
|
|
2933
2933
|
routeId,
|
|
2934
2934
|
requestContext,
|
|
2935
2935
|
dataStrategy,
|
|
2936
|
-
|
|
2936
|
+
generateMiddlewareResponse
|
|
2937
2937
|
} = {}) {
|
|
2938
2938
|
let url = new URL(request.url);
|
|
2939
2939
|
let method = request.method;
|
|
2940
2940
|
let location = createLocation("", createPath(url), null, "default");
|
|
2941
2941
|
let matches = matchRoutes(dataRoutes, location, basename);
|
|
2942
|
-
requestContext = requestContext != null ? requestContext : new
|
|
2942
|
+
requestContext = requestContext != null ? requestContext : new RouterContextProvider();
|
|
2943
2943
|
if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") {
|
|
2944
2944
|
throw getInternalRouterError(405, { method });
|
|
2945
2945
|
} else if (!matches) {
|
|
@@ -2956,8 +2956,8 @@ function createStaticHandler(routes, opts) {
|
|
|
2956
2956
|
}
|
|
2957
2957
|
if (generateMiddlewareResponse) {
|
|
2958
2958
|
invariant(
|
|
2959
|
-
requestContext instanceof
|
|
2960
|
-
"When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `
|
|
2959
|
+
requestContext instanceof RouterContextProvider,
|
|
2960
|
+
"When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `RouterContextProvider`"
|
|
2961
2961
|
);
|
|
2962
2962
|
await loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties);
|
|
2963
2963
|
let response = await runServerMiddlewarePipeline(
|
|
@@ -3947,11 +3947,11 @@ function isNonNullable(value) {
|
|
|
3947
3947
|
}
|
|
3948
3948
|
function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties) {
|
|
3949
3949
|
let promises = matches.map(({ route }) => {
|
|
3950
|
-
if (typeof route.lazy !== "object" || !route.lazy.
|
|
3950
|
+
if (typeof route.lazy !== "object" || !route.lazy.middleware) {
|
|
3951
3951
|
return void 0;
|
|
3952
3952
|
}
|
|
3953
3953
|
return loadLazyRouteProperty({
|
|
3954
|
-
key: "
|
|
3954
|
+
key: "middleware",
|
|
3955
3955
|
route,
|
|
3956
3956
|
manifest,
|
|
3957
3957
|
mapRouteProperties
|
|
@@ -3969,7 +3969,7 @@ async function defaultDataStrategy(args) {
|
|
|
3969
3969
|
return keyedResults;
|
|
3970
3970
|
}
|
|
3971
3971
|
async function defaultDataStrategyWithMiddleware(args) {
|
|
3972
|
-
if (!args.matches.some((m) => m.route.
|
|
3972
|
+
if (!args.matches.some((m) => m.route.middleware)) {
|
|
3973
3973
|
return defaultDataStrategy(args);
|
|
3974
3974
|
}
|
|
3975
3975
|
return runClientMiddlewarePipeline(args, () => defaultDataStrategy(args));
|
|
@@ -4023,7 +4023,7 @@ function runClientMiddlewarePipeline(args, handler) {
|
|
|
4023
4023
|
async function runMiddlewarePipeline(args, handler, processResult, isResult, errorHandler) {
|
|
4024
4024
|
let { matches, request, params, context } = args;
|
|
4025
4025
|
let tuples = matches.flatMap(
|
|
4026
|
-
(m) => m.route.
|
|
4026
|
+
(m) => m.route.middleware ? m.route.middleware.map((fn) => [m.route.id, fn]) : []
|
|
4027
4027
|
);
|
|
4028
4028
|
let result = await callRouteMiddleware(
|
|
4029
4029
|
{ request, params, context },
|
|
@@ -4086,7 +4086,7 @@ async function callRouteMiddleware(args, middlewares, handler, processResult, is
|
|
|
4086
4086
|
}
|
|
4087
4087
|
function getDataStrategyMatchLazyPromises(mapRouteProperties, manifest, request, match, lazyRoutePropertiesToSkip) {
|
|
4088
4088
|
let lazyMiddlewarePromise = loadLazyRouteProperty({
|
|
4089
|
-
key: "
|
|
4089
|
+
key: "middleware",
|
|
4090
4090
|
route: match.route,
|
|
4091
4091
|
manifest,
|
|
4092
4092
|
mapRouteProperties
|
|
@@ -4186,9 +4186,9 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
4186
4186
|
context: scopedContext,
|
|
4187
4187
|
matches
|
|
4188
4188
|
};
|
|
4189
|
-
let
|
|
4189
|
+
let runClientMiddleware = isStaticHandler ? () => {
|
|
4190
4190
|
throw new Error(
|
|
4191
|
-
"You cannot call `
|
|
4191
|
+
"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`"
|
|
4192
4192
|
);
|
|
4193
4193
|
} : (cb) => {
|
|
4194
4194
|
let typedDataStrategyArgs = dataStrategyArgs;
|
|
@@ -4196,9 +4196,9 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
4196
4196
|
return cb({
|
|
4197
4197
|
...typedDataStrategyArgs,
|
|
4198
4198
|
fetcherKey,
|
|
4199
|
-
|
|
4199
|
+
runClientMiddleware: () => {
|
|
4200
4200
|
throw new Error(
|
|
4201
|
-
"Cannot call `
|
|
4201
|
+
"Cannot call `runClientMiddleware()` from within an `runClientMiddleware` handler"
|
|
4202
4202
|
);
|
|
4203
4203
|
}
|
|
4204
4204
|
});
|
|
@@ -4207,7 +4207,7 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
4207
4207
|
let results = await dataStrategyImpl({
|
|
4208
4208
|
...dataStrategyArgs,
|
|
4209
4209
|
fetcherKey,
|
|
4210
|
-
|
|
4210
|
+
runClientMiddleware
|
|
4211
4211
|
});
|
|
4212
4212
|
try {
|
|
4213
4213
|
await Promise.all(
|
|
@@ -5708,7 +5708,7 @@ function getTurboStreamSingleFetchDataStrategy(getRouter, manifest, routeModules
|
|
|
5708
5708
|
ssr,
|
|
5709
5709
|
basename
|
|
5710
5710
|
);
|
|
5711
|
-
return async (args) => args.
|
|
5711
|
+
return async (args) => args.runClientMiddleware(dataStrategy);
|
|
5712
5712
|
}
|
|
5713
5713
|
function getSingleFetchDataStrategyImpl(getRouter, getRouteInfo, fetchAndDecode, ssr, basename, shouldAllowOptOut = () => true) {
|
|
5714
5714
|
return async (args) => {
|
|
@@ -6107,6 +6107,7 @@ var FetchersContext = React2.createContext(
|
|
|
6107
6107
|
FetchersContext.displayName = "Fetchers";
|
|
6108
6108
|
var AwaitContext = React2.createContext(null);
|
|
6109
6109
|
AwaitContext.displayName = "Await";
|
|
6110
|
+
var AwaitContextProvider = (props) => React2.createElement(AwaitContext.Provider, props);
|
|
6110
6111
|
var NavigationContext = React2.createContext(
|
|
6111
6112
|
null
|
|
6112
6113
|
);
|
|
@@ -7130,7 +7131,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
7130
7131
|
Object.assign(dataRoute, {
|
|
7131
7132
|
...dataRoute,
|
|
7132
7133
|
...getRouteComponents(route, routeModule, isSpaMode),
|
|
7133
|
-
|
|
7134
|
+
middleware: routeModule.clientMiddleware,
|
|
7134
7135
|
handle: routeModule.handle,
|
|
7135
7136
|
shouldRevalidate: getShouldRevalidateFunction(
|
|
7136
7137
|
dataRoute.path,
|
|
@@ -7272,17 +7273,14 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
7272
7273
|
}
|
|
7273
7274
|
});
|
|
7274
7275
|
} : void 0,
|
|
7275
|
-
|
|
7276
|
-
let {
|
|
7276
|
+
middleware: route.hasClientMiddleware ? async () => {
|
|
7277
|
+
let { clientMiddleware } = route.clientMiddlewareModule ? await Promise.resolve().then(() => _interopRequireWildcard(require(
|
|
7277
7278
|
/* @vite-ignore */
|
|
7278
7279
|
/* webpackIgnore: true */
|
|
7279
7280
|
route.clientMiddlewareModule
|
|
7280
7281
|
))) : await getLazyRoute();
|
|
7281
|
-
invariant2(
|
|
7282
|
-
|
|
7283
|
-
"No `unstable_clientMiddleware` export found"
|
|
7284
|
-
);
|
|
7285
|
-
return unstable_clientMiddleware;
|
|
7282
|
+
invariant2(clientMiddleware, "No `clientMiddleware` export found");
|
|
7283
|
+
return clientMiddleware;
|
|
7286
7284
|
} : void 0,
|
|
7287
7285
|
shouldRevalidate: async () => {
|
|
7288
7286
|
let lazyRoute = await getLazyRoute();
|
|
@@ -7363,7 +7361,7 @@ async function loadRouteModuleWithBlockingLinks(route, routeModules) {
|
|
|
7363
7361
|
return {
|
|
7364
7362
|
Component: getRouteModuleComponent(routeModule),
|
|
7365
7363
|
ErrorBoundary: routeModule.ErrorBoundary,
|
|
7366
|
-
|
|
7364
|
+
clientMiddleware: routeModule.clientMiddleware,
|
|
7367
7365
|
clientAction: routeModule.clientAction,
|
|
7368
7366
|
clientLoader: routeModule.clientLoader,
|
|
7369
7367
|
handle: routeModule.handle,
|
|
@@ -8301,4 +8299,5 @@ function BoundaryShell({
|
|
|
8301
8299
|
|
|
8302
8300
|
|
|
8303
8301
|
|
|
8304
|
-
|
|
8302
|
+
|
|
8303
|
+
exports.Action = Action; exports.createMemoryHistory = createMemoryHistory; exports.createBrowserHistory = createBrowserHistory; exports.createHashHistory = createHashHistory; exports.invariant = invariant; exports.warning = warning; exports.createPath = createPath; exports.parsePath = parsePath; exports.createContext = createContext; exports.RouterContextProvider = RouterContextProvider; exports.convertRoutesToDataRoutes = convertRoutesToDataRoutes; exports.matchRoutes = matchRoutes; exports.generatePath = generatePath; exports.matchPath = matchPath; exports.stripBasename = stripBasename; exports.resolvePath = resolvePath; exports.getResolveToMatches = getResolveToMatches; exports.resolveTo = resolveTo; exports.joinPaths = joinPaths; exports.data = data; exports.redirect = redirect; exports.redirectDocument = redirectDocument; exports.replace = replace; exports.ErrorResponseImpl = ErrorResponseImpl; exports.isRouteErrorResponse = isRouteErrorResponse; exports.encode = encode; exports.IDLE_NAVIGATION = IDLE_NAVIGATION; exports.IDLE_FETCHER = IDLE_FETCHER; exports.IDLE_BLOCKER = IDLE_BLOCKER; exports.createRouter = createRouter; exports.createStaticHandler = createStaticHandler; exports.getStaticContextFromError = getStaticContextFromError; exports.isDataWithResponseInit = isDataWithResponseInit; exports.isResponse = isResponse; exports.isRedirectStatusCode = isRedirectStatusCode; exports.isRedirectResponse = isRedirectResponse; exports.isMutationMethod = isMutationMethod; exports.createRequestInit = createRequestInit; exports.SingleFetchRedirectSymbol = SingleFetchRedirectSymbol; exports.SINGLE_FETCH_REDIRECT_STATUS = SINGLE_FETCH_REDIRECT_STATUS; exports.NO_BODY_STATUS_CODES = NO_BODY_STATUS_CODES; exports.StreamTransfer = StreamTransfer; exports.getTurboStreamSingleFetchDataStrategy = getTurboStreamSingleFetchDataStrategy; exports.getSingleFetchDataStrategyImpl = getSingleFetchDataStrategyImpl; exports.stripIndexParam = stripIndexParam; exports.singleFetchUrl = singleFetchUrl; exports.decodeViaTurboStream = decodeViaTurboStream; exports.DataRouterContext = DataRouterContext; exports.DataRouterStateContext = DataRouterStateContext; exports.RSCRouterContext = RSCRouterContext; exports.ViewTransitionContext = ViewTransitionContext; exports.FetchersContext = FetchersContext; exports.AwaitContext = AwaitContext; exports.AwaitContextProvider = AwaitContextProvider; exports.NavigationContext = NavigationContext; exports.LocationContext = LocationContext; exports.RouteContext = RouteContext; exports.ENABLE_DEV_WARNINGS = ENABLE_DEV_WARNINGS; exports.warnOnce = warnOnce; exports.useHref = useHref; exports.useInRouterContext = useInRouterContext; exports.useLocation = useLocation; exports.useNavigationType = useNavigationType; exports.useMatch = useMatch; exports.useNavigate = useNavigate; exports.useOutletContext = useOutletContext; exports.useOutlet = useOutlet; exports.useParams = useParams; exports.useResolvedPath = useResolvedPath; exports.useRoutes = useRoutes; exports.useRoutesImpl = useRoutesImpl; exports._renderMatches = _renderMatches; exports.useRouteId = useRouteId; exports.useNavigation = useNavigation; exports.useRevalidator = useRevalidator; exports.useMatches = useMatches; exports.useLoaderData = useLoaderData; exports.useRouteLoaderData = useRouteLoaderData; exports.useActionData = useActionData; exports.useRouteError = useRouteError; exports.useAsyncValue = useAsyncValue; exports.useAsyncError = useAsyncError; exports.useBlocker = useBlocker; exports.RemixErrorBoundary = RemixErrorBoundary; exports.createServerRoutes = createServerRoutes; exports.createClientRoutesWithHMRRevalidationOptOut = createClientRoutesWithHMRRevalidationOptOut; exports.noActionDefinedError = noActionDefinedError; exports.createClientRoutes = createClientRoutes; exports.shouldHydrateRouteLoader = shouldHydrateRouteLoader; exports.getPatchRoutesOnNavigationFunction = getPatchRoutesOnNavigationFunction; exports.useFogOFWarDiscovery = useFogOFWarDiscovery; exports.getManifestPath = getManifestPath; exports.FrameworkContext = FrameworkContext; exports.usePrefetchBehavior = usePrefetchBehavior; exports.CRITICAL_CSS_DATA_ATTRIBUTE = CRITICAL_CSS_DATA_ATTRIBUTE; exports.Links = Links; exports.PrefetchPageLinks = PrefetchPageLinks; exports.Meta = Meta; exports.setIsHydrated = setIsHydrated; exports.Scripts = Scripts; exports.mergeRefs = mergeRefs;
|
|
@@ -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-47NS5WEV.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,
|