react-router 0.0.0-experimental-e89ad3012 → 0.0.0-experimental-d5a247381
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 +81 -0
- package/dist/development/{chunk-3O4L5GVQ.mjs → chunk-5CZ4IYHY.mjs} +137 -96
- package/dist/{production/chunk-X3M2F3OK.js → development/chunk-HTLIKYA4.js} +130 -130
- package/dist/development/{chunk-JJHCVRDZ.js → chunk-JKTJNTER.js} +155 -114
- package/dist/{production/chunk-J6PLTU3O.mjs → development/chunk-WD74EEJO.mjs} +28 -5
- package/dist/development/{components-BkK38HPd.d.mts → components-uUh0svuC.d.mts} +6 -3
- package/dist/development/{context-CphUWOpx.d.mts → context-DZWGFcKX.d.mts} +86 -61
- package/dist/development/dom-export.d.mts +2 -2
- package/dist/development/dom-export.js +3 -3
- package/dist/development/dom-export.mjs +3 -3
- package/dist/development/{index-react-server-client-pe1TAKAq.d.mts → index-react-server-client-BUK-oRcG.d.mts} +27 -20
- package/dist/{production/index-react-server-client-D-lyvxf_.d.ts → development/index-react-server-client-DSU6bZil.d.ts} +30 -20
- package/dist/development/index-react-server-client.d.mts +4 -4
- 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 +71 -48
- package/dist/development/index-react-server.d.ts +71 -48
- package/dist/development/index-react-server.js +106 -110
- package/dist/development/index-react-server.mjs +106 -110
- package/dist/development/index.d.mts +12 -13
- package/dist/development/index.d.ts +8 -9
- package/dist/development/index.js +126 -103
- package/dist/development/index.mjs +3 -3
- package/dist/development/lib/types/internal.d.mts +2 -2
- package/dist/development/lib/types/internal.d.ts +1 -1
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/development/{route-data-DJXZgnJq.d.mts → route-data-UTmTa8an.d.mts} +1 -1
- package/dist/{production/routeModules-DH3xUx4Z.d.ts → development/routeModules-D5bppTB2.d.ts} +86 -61
- package/dist/production/{chunk-NFNPXIQE.js → chunk-4OSWJNZY.js} +155 -114
- package/dist/{development/chunk-ROJMZUUV.js → production/chunk-CXNNH7ML.js} +130 -130
- package/dist/{development/chunk-XKV32KFX.mjs → production/chunk-EPFW5H4E.mjs} +28 -5
- package/dist/production/{chunk-QI3NR5VQ.mjs → chunk-G3S3XTKQ.mjs} +137 -96
- package/dist/production/{components-BkK38HPd.d.mts → components-uUh0svuC.d.mts} +6 -3
- package/dist/production/{context-CphUWOpx.d.mts → context-DZWGFcKX.d.mts} +86 -61
- package/dist/production/dom-export.d.mts +2 -2
- package/dist/production/dom-export.js +3 -3
- package/dist/production/dom-export.mjs +3 -3
- package/dist/production/{index-react-server-client-pe1TAKAq.d.mts → index-react-server-client-BUK-oRcG.d.mts} +27 -20
- package/dist/{development/index-react-server-client-D-lyvxf_.d.ts → production/index-react-server-client-DSU6bZil.d.ts} +30 -20
- package/dist/production/index-react-server-client.d.mts +4 -4
- 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 +71 -48
- package/dist/production/index-react-server.d.ts +71 -48
- package/dist/production/index-react-server.js +106 -110
- package/dist/production/index-react-server.mjs +106 -110
- package/dist/production/index.d.mts +12 -13
- package/dist/production/index.d.ts +8 -9
- package/dist/production/index.js +126 -103
- package/dist/production/index.mjs +3 -3
- package/dist/production/lib/types/internal.d.mts +2 -2
- package/dist/production/lib/types/internal.d.ts +1 -1
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/production/{route-data-DJXZgnJq.d.mts → route-data-UTmTa8an.d.mts} +1 -1
- package/dist/{development/routeModules-DH3xUx4Z.d.ts → production/routeModules-D5bppTB2.d.ts} +86 -61
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,86 @@
|
|
|
1
1
|
# `react-router`
|
|
2
2
|
|
|
3
|
+
## 7.8.0-pre.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add `nonce` prop to `Links` & `PrefetchPageLinks` ([#14048](https://github.com/remix-run/react-router/pull/14048))
|
|
8
|
+
- Add `loaderData` arguments/properties alongside existing `data` arguments/properties to provide consistency and clarity between `loaderData` and `actionData` across the board ([#14047](https://github.com/remix-run/react-router/pull/14047))
|
|
9
|
+
- Updated types: `Route.MetaArgs`, `Route.MetaMatch`, `MetaArgs`, `MetaMatch`, `Route.ComponentProps.matches`, `UIMatch`
|
|
10
|
+
- `@deprecated` warnings have been added to the existing `data` properties to point users to new `loaderData` properties, in preparation for removing the `data` properties in a future major release
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [UNSTABLE] Ensure resource route errors go through `handleError` w/middleware enabled ([#14078](https://github.com/remix-run/react-router/pull/14078))
|
|
15
|
+
- Prevent _"Did not find corresponding fetcher result"_ console error when navigating during a `fetcher.submit` revalidation ([#14114](https://github.com/remix-run/react-router/pull/14114))
|
|
16
|
+
- Switch Lazy Route Discovery manifest URL generation to usea standalone `URLSearchParams` instance instead of `URL.searchParams` to avoid a major performance bottleneck in Chrome ([#14084](https://github.com/remix-run/react-router/pull/14084))
|
|
17
|
+
- [UNSTABLE] Propagate returned Response from server middleware if next wasn't called ([#14093](https://github.com/remix-run/react-router/pull/14093))
|
|
18
|
+
- [UNSTABLE] Allow server middlewares to return `data()` values which will be converted into a `Response` ([#14093](https://github.com/remix-run/react-router/pull/14093))
|
|
19
|
+
- [UNSTABLE] Update middleware error handling so that the `next` function never throws and instead handles any middleware errors at the proper `ErrorBoundary` and returns the `Response` up through the ancestor `next` function ([#14118](https://github.com/remix-run/react-router/pull/14118))
|
|
20
|
+
- - [UNSTABLE] When middleware is enabled, make the `context` parameter read-only (via `Readonly<unstable_RouterContextProvider>`) so that TypeScript will not allow you to write arbitrary fields to it in loaders, actions, or middleware. ([#14097](https://github.com/remix-run/react-router/pull/14097))
|
|
21
|
+
- [UNSTABLE] Rename and alter the signature/functionality of the `unstable_respond` API in `staticHandler.query`/`staticHandler.queryRoute` ([#14103](https://github.com/remix-run/react-router/pull/14103))
|
|
22
|
+
- The API has been renamed to `unstable_generateMiddlewareResponse` for clarity
|
|
23
|
+
- The main functional change is that instead of running the loaders/actions before calling `unstable_respond` and handing you the result, we now pass a `query`/`queryRoute` function as a parameter and you execute the loaders/actions inside your callback, giving you full access to pre-processing and error handling
|
|
24
|
+
- The `query` version of the API now has a signature of `(query: (r: Request) => Promise<StaticHandlerContext | Response>) => Promise<Response>`
|
|
25
|
+
- The `queryRoute` version of the API now has a signature of `(queryRoute: (r: Request) => Promise<Response>) => Promise<Response>`
|
|
26
|
+
- This allows for more advanced usages such as running logic before/after calling `query` and direct error handling of errors thrown from query
|
|
27
|
+
- ⚠️ This is a breaking change if you've adopted the `staticHandler` `unstable_respond` API
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
let response = await staticHandler.query(request, {
|
|
31
|
+
requestContext: new unstable_RouterContextProvider(),
|
|
32
|
+
async unstable_generateMiddlewareResponse(query) {
|
|
33
|
+
try {
|
|
34
|
+
// At this point we've run middleware top-down so we need to call the
|
|
35
|
+
// handlers and generate the Response to bubble back up the middleware
|
|
36
|
+
let result = await query(request);
|
|
37
|
+
if (isResponse(result)) {
|
|
38
|
+
return result; // Redirects, etc.
|
|
39
|
+
}
|
|
40
|
+
return await generateHtmlResponse(result);
|
|
41
|
+
} catch (error: unknown) {
|
|
42
|
+
return generateErrorResponse(error);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
- [UNSTABLE] Convert internal middleware implementations to use the new `unstable_generateMiddlewareResponse` API ([#14103](https://github.com/remix-run/react-router/pull/14103))
|
|
49
|
+
- Adjust internal RSC usage of `React.use` to avoid Webpack compilation errors when using React 18 ([#14113](https://github.com/remix-run/react-router/pull/14113))
|
|
50
|
+
- [UNSTABLE] Change `getLoadContext` signature (`type GetLoadContextFunction`) when `future.unstable_middleware` is enabled so that it returns an `unstable_RouterContextProvider` instance instead of a `Map` used to contruct the instance internally ([#14097](https://github.com/remix-run/react-router/pull/14097))
|
|
51
|
+
- This also removes the `type unstable_InitialContext` export
|
|
52
|
+
- ⚠️ This is a breaking change if you have adopted middleware and are using a custom server with a `getLoadContext` function
|
|
53
|
+
|
|
54
|
+
- Remove dependency on `@types/node` in TypeScript declaration files ([#14059](https://github.com/remix-run/react-router/pull/14059))
|
|
55
|
+
- Fix types for `UIMatch` to reflect that the `loaderData`/`data` properties may be `undefined` ([#12206](https://github.com/remix-run/react-router/pull/12206))
|
|
56
|
+
- When an `ErrorBoundary` is being rendered, not all active matches will have loader data available, since it may have been their `loader` that threw to trigger the boundary
|
|
57
|
+
- The `UIMatch.data` type was not correctly handing this and would always reflect the presence of data, leading to the unexpected runtime errors when an `ErrorBoundary` was rendered
|
|
58
|
+
- ⚠️ This may cause some type errors to show up in your code for unguarded `match.data` accesses - you should properly guard for `undefined` values in those scenarios.
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
// app/root.tsx
|
|
62
|
+
export function loader() {
|
|
63
|
+
someFunctionThatThrows(); // ❌ Throws an Error
|
|
64
|
+
return { title: "My Title" };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function Layout({ children }: { children: React.ReactNode }) {
|
|
68
|
+
let matches = useMatches();
|
|
69
|
+
let rootMatch = matches[0] as UIMatch<Awaited<ReturnType<typeof loader>>>;
|
|
70
|
+
// ^ rootMatch.data is incorrectly typed here, so TypeScript does not
|
|
71
|
+
// complain if you do the following which throws an error at runtime:
|
|
72
|
+
let { title } = rootMatch.data; // 💥
|
|
73
|
+
|
|
74
|
+
return <html>...</html>;
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
- [UNSTABLE] Run client middleware on client navigations even if no loaders exist ([#14106](https://github.com/remix-run/react-router/pull/14106))
|
|
79
|
+
- [UNSTABLE] Change the `unstable_getContext` signature on `RouterProvider`/`HydratedRouter`/`unstable_RSCHydratedRouter` so that it returns an `unstable_RouterContextProvider` instance instead of a `Map` used to contruct the instance internally ([#14097](https://github.com/remix-run/react-router/pull/14097))
|
|
80
|
+
- ⚠️ This is a breaking change if you have adopted the `unstable_getContext` prop
|
|
81
|
+
|
|
82
|
+
- Fix RSC Data Mode issue where routes that return `false` from `shouldRevalidate` would be replaced by an `<Outlet />` ([#14071](https://github.com/remix-run/react-router/pull/14071))
|
|
83
|
+
|
|
3
84
|
## 7.7.1
|
|
4
85
|
|
|
5
86
|
### Patch Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-d5a247381
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -380,11 +380,11 @@ var unstable_RouterContextProvider = class {
|
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
382
|
/**
|
|
383
|
-
* Access a value from the context. If no value has been set for the
|
|
384
|
-
*
|
|
385
|
-
*
|
|
383
|
+
* Access a value from the context. If no value has been set for the context,
|
|
384
|
+
* it will return the context's `defaultValue` if provided, or throw an error
|
|
385
|
+
* if no `defaultValue` was set.
|
|
386
386
|
* @param context The context to get the value for
|
|
387
|
-
* @returns The value for the context, or the
|
|
387
|
+
* @returns The value for the context, or the context's `defaultValue` if no
|
|
388
388
|
* value was set
|
|
389
389
|
*/
|
|
390
390
|
get(context) {
|
|
@@ -397,8 +397,8 @@ var unstable_RouterContextProvider = class {
|
|
|
397
397
|
throw new Error("No value found for context");
|
|
398
398
|
}
|
|
399
399
|
/**
|
|
400
|
-
* Set a value for the context. If the context already has a value set,
|
|
401
|
-
*
|
|
400
|
+
* Set a value for the context. If the context already has a value set, this
|
|
401
|
+
* will overwrite it.
|
|
402
402
|
*
|
|
403
403
|
* @param context The context to set the value for
|
|
404
404
|
* @param value The value to set for the context
|
|
@@ -2781,7 +2781,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2781
2781
|
mapRouteProperties2
|
|
2782
2782
|
);
|
|
2783
2783
|
let renderedStaticContext;
|
|
2784
|
-
let response = await
|
|
2784
|
+
let response = await runServerMiddlewarePipeline(
|
|
2785
2785
|
{
|
|
2786
2786
|
request,
|
|
2787
2787
|
matches,
|
|
@@ -2790,7 +2790,6 @@ function createStaticHandler(routes, opts) {
|
|
|
2790
2790
|
// this to the proper type knowing it's not an `AppLoadContext`
|
|
2791
2791
|
context: requestContext
|
|
2792
2792
|
},
|
|
2793
|
-
true,
|
|
2794
2793
|
async () => {
|
|
2795
2794
|
let res = await generateMiddlewareResponse(
|
|
2796
2795
|
async (revalidationRequest) => {
|
|
@@ -2913,7 +2912,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2913
2912
|
"When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `unstable_RouterContextProvider`"
|
|
2914
2913
|
);
|
|
2915
2914
|
await loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2);
|
|
2916
|
-
let response = await
|
|
2915
|
+
let response = await runServerMiddlewarePipeline(
|
|
2917
2916
|
{
|
|
2918
2917
|
request,
|
|
2919
2918
|
matches,
|
|
@@ -2922,7 +2921,6 @@ function createStaticHandler(routes, opts) {
|
|
|
2922
2921
|
// this to the proper type knowing it's not an `AppLoadContext`
|
|
2923
2922
|
context: requestContext
|
|
2924
2923
|
},
|
|
2925
|
-
true,
|
|
2926
2924
|
async () => {
|
|
2927
2925
|
let res = await generateMiddlewareResponse(
|
|
2928
2926
|
async (innerRequest) => {
|
|
@@ -2945,7 +2943,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2945
2943
|
},
|
|
2946
2944
|
(error) => {
|
|
2947
2945
|
if (isResponse(error)) {
|
|
2948
|
-
return error;
|
|
2946
|
+
return Promise.resolve(error);
|
|
2949
2947
|
}
|
|
2950
2948
|
throw error;
|
|
2951
2949
|
}
|
|
@@ -3919,60 +3917,110 @@ async function defaultDataStrategyWithMiddleware(args) {
|
|
|
3919
3917
|
if (!args.matches.some((m) => m.route.unstable_middleware)) {
|
|
3920
3918
|
return defaultDataStrategy(args);
|
|
3921
3919
|
}
|
|
3922
|
-
return
|
|
3920
|
+
return runClientMiddlewarePipeline(
|
|
3923
3921
|
args,
|
|
3924
|
-
false,
|
|
3925
3922
|
() => defaultDataStrategy(args),
|
|
3926
3923
|
(error, routeId) => ({ [routeId]: { type: "error", result: error } })
|
|
3927
3924
|
);
|
|
3928
3925
|
}
|
|
3929
|
-
async function
|
|
3926
|
+
async function runServerMiddlewarePipeline(args, handler, errorHandler) {
|
|
3930
3927
|
let { matches, request, params, context } = args;
|
|
3931
|
-
let
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3928
|
+
let tuples = matches.flatMap(
|
|
3929
|
+
(m) => m.route.unstable_middleware ? m.route.unstable_middleware.map((fn) => [m.route.id, fn]) : []
|
|
3930
|
+
);
|
|
3931
|
+
let result = await callServerRouteMiddleware(
|
|
3932
|
+
{ request, params, context },
|
|
3933
|
+
tuples,
|
|
3934
|
+
handler,
|
|
3935
|
+
errorHandler
|
|
3936
|
+
);
|
|
3937
|
+
if (isDataWithResponseInit(result)) {
|
|
3938
|
+
return new Response(
|
|
3939
|
+
typeof result.data === "string" ? result.data : JSON.stringify(result.data),
|
|
3940
|
+
{ ...result.init }
|
|
3937
3941
|
);
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3942
|
+
}
|
|
3943
|
+
if (isResponse(result)) {
|
|
3944
|
+
return result;
|
|
3945
|
+
}
|
|
3946
|
+
invariant(false, `Expected a Response to be returned from route middleware`);
|
|
3947
|
+
}
|
|
3948
|
+
async function callServerRouteMiddleware(args, middlewares, handler, errorHandler, idx = 0) {
|
|
3949
|
+
let { request } = args;
|
|
3950
|
+
if (request.signal.aborted) {
|
|
3951
|
+
if (request.signal.reason) {
|
|
3952
|
+
throw request.signal.reason;
|
|
3953
|
+
}
|
|
3954
|
+
throw new Error(
|
|
3955
|
+
`Request aborted without an \`AbortSignal.reason\`: ${request.method} ${request.url}`
|
|
3944
3956
|
);
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
}
|
|
3958
|
-
} else {
|
|
3959
|
-
return middlewareState.handlerResult;
|
|
3957
|
+
}
|
|
3958
|
+
let tuple = middlewares[idx];
|
|
3959
|
+
if (!tuple) {
|
|
3960
|
+
let result = await handler();
|
|
3961
|
+
return result;
|
|
3962
|
+
}
|
|
3963
|
+
let [routeId, middleware] = tuple;
|
|
3964
|
+
let nextCalled = false;
|
|
3965
|
+
let nextResult = void 0;
|
|
3966
|
+
let next = async () => {
|
|
3967
|
+
if (nextCalled) {
|
|
3968
|
+
throw new Error("You may only call `next()` once per middleware");
|
|
3960
3969
|
}
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3970
|
+
nextCalled = true;
|
|
3971
|
+
try {
|
|
3972
|
+
let result = await callServerRouteMiddleware(
|
|
3973
|
+
args,
|
|
3974
|
+
middlewares,
|
|
3975
|
+
handler,
|
|
3976
|
+
errorHandler,
|
|
3977
|
+
idx + 1
|
|
3978
|
+
);
|
|
3979
|
+
nextResult = result;
|
|
3980
|
+
return nextResult;
|
|
3981
|
+
} catch (e) {
|
|
3982
|
+
nextResult = await errorHandler(e, routeId);
|
|
3983
|
+
return nextResult;
|
|
3964
3984
|
}
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3985
|
+
};
|
|
3986
|
+
try {
|
|
3987
|
+
let result = await middleware(
|
|
3988
|
+
{
|
|
3989
|
+
request: args.request,
|
|
3990
|
+
params: args.params,
|
|
3991
|
+
context: args.context
|
|
3992
|
+
},
|
|
3993
|
+
next
|
|
3968
3994
|
);
|
|
3969
|
-
if (
|
|
3995
|
+
if (nextCalled) {
|
|
3996
|
+
return typeof result === "undefined" ? nextResult : result;
|
|
3997
|
+
} else if (isResponse(result) || isDataWithResponseInit(result)) {
|
|
3970
3998
|
return result;
|
|
3999
|
+
} else {
|
|
4000
|
+
nextResult = await next();
|
|
4001
|
+
return nextResult;
|
|
3971
4002
|
}
|
|
3972
|
-
|
|
4003
|
+
} catch (error) {
|
|
4004
|
+
let response = await errorHandler(error, routeId);
|
|
4005
|
+
return response;
|
|
3973
4006
|
}
|
|
3974
4007
|
}
|
|
3975
|
-
async function
|
|
4008
|
+
async function runClientMiddlewarePipeline(args, handler, errorHandler) {
|
|
4009
|
+
let { matches, request, params, context } = args;
|
|
4010
|
+
let tuples = matches.flatMap(
|
|
4011
|
+
(m) => m.route.unstable_middleware ? m.route.unstable_middleware.map((fn) => [m.route.id, fn]) : []
|
|
4012
|
+
);
|
|
4013
|
+
let handlerResult = {};
|
|
4014
|
+
await callClientRouteMiddleware(
|
|
4015
|
+
{ request, params, context },
|
|
4016
|
+
tuples,
|
|
4017
|
+
handler,
|
|
4018
|
+
errorHandler,
|
|
4019
|
+
handlerResult
|
|
4020
|
+
);
|
|
4021
|
+
return handlerResult;
|
|
4022
|
+
}
|
|
4023
|
+
async function callClientRouteMiddleware(args, middlewares, handler, errorHandler, handlerResult = {}, idx = 0) {
|
|
3976
4024
|
let { request } = args;
|
|
3977
4025
|
if (request.signal.aborted) {
|
|
3978
4026
|
if (request.signal.reason) {
|
|
@@ -3984,28 +4032,30 @@ async function callRouteMiddleware(args, middlewares, propagateResult, middlewar
|
|
|
3984
4032
|
}
|
|
3985
4033
|
let tuple = middlewares[idx];
|
|
3986
4034
|
if (!tuple) {
|
|
3987
|
-
|
|
3988
|
-
|
|
4035
|
+
let result = await handler();
|
|
4036
|
+
Object.assign(handlerResult, result);
|
|
4037
|
+
return;
|
|
3989
4038
|
}
|
|
3990
4039
|
let [routeId, middleware] = tuple;
|
|
3991
4040
|
let nextCalled = false;
|
|
3992
|
-
let nextResult = void 0;
|
|
3993
4041
|
let next = async () => {
|
|
3994
4042
|
if (nextCalled) {
|
|
3995
4043
|
throw new Error("You may only call `next()` once per middleware");
|
|
3996
4044
|
}
|
|
3997
4045
|
nextCalled = true;
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4046
|
+
try {
|
|
4047
|
+
let result = await callClientRouteMiddleware(
|
|
4048
|
+
args,
|
|
4049
|
+
middlewares,
|
|
4050
|
+
handler,
|
|
4051
|
+
errorHandler,
|
|
4052
|
+
handlerResult,
|
|
4053
|
+
idx + 1
|
|
4054
|
+
);
|
|
4055
|
+
Object.assign(handlerResult, result);
|
|
4056
|
+
} catch (e) {
|
|
4057
|
+
let result = await errorHandler(e, routeId);
|
|
4058
|
+
Object.assign(handlerResult, result);
|
|
4009
4059
|
}
|
|
4010
4060
|
};
|
|
4011
4061
|
try {
|
|
@@ -4017,33 +4067,18 @@ async function callRouteMiddleware(args, middlewares, propagateResult, middlewar
|
|
|
4017
4067
|
},
|
|
4018
4068
|
next
|
|
4019
4069
|
);
|
|
4020
|
-
if (
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
} else {
|
|
4026
|
-
nextResult = await next();
|
|
4027
|
-
return nextResult;
|
|
4028
|
-
}
|
|
4029
|
-
} else {
|
|
4030
|
-
if (typeof result !== "undefined") {
|
|
4031
|
-
console.warn(
|
|
4032
|
-
"client middlewares are not intended to return values, the value will be ignored",
|
|
4033
|
-
result
|
|
4034
|
-
);
|
|
4035
|
-
}
|
|
4036
|
-
if (!nextCalled) {
|
|
4037
|
-
await next();
|
|
4038
|
-
}
|
|
4070
|
+
if (typeof result !== "undefined") {
|
|
4071
|
+
console.warn(
|
|
4072
|
+
"client middlewares are not intended to return values, the value will be ignored",
|
|
4073
|
+
result
|
|
4074
|
+
);
|
|
4039
4075
|
}
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
middlewareState.middlewareError = { routeId, error };
|
|
4043
|
-
} else if (middlewareState.middlewareError.error !== error) {
|
|
4044
|
-
middlewareState.middlewareError = { routeId, error };
|
|
4076
|
+
if (!nextCalled) {
|
|
4077
|
+
await next();
|
|
4045
4078
|
}
|
|
4046
|
-
|
|
4079
|
+
} catch (error) {
|
|
4080
|
+
let result = await errorHandler(error, routeId);
|
|
4081
|
+
Object.assign(handlerResult, result);
|
|
4047
4082
|
}
|
|
4048
4083
|
}
|
|
4049
4084
|
function getDataStrategyMatchLazyPromises(mapRouteProperties2, manifest, request, match, lazyRoutePropertiesToSkip) {
|
|
@@ -4154,9 +4189,8 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
4154
4189
|
);
|
|
4155
4190
|
} : (cb) => {
|
|
4156
4191
|
let typedDataStrategyArgs = dataStrategyArgs;
|
|
4157
|
-
return
|
|
4192
|
+
return runClientMiddlewarePipeline(
|
|
4158
4193
|
typedDataStrategyArgs,
|
|
4159
|
-
false,
|
|
4160
4194
|
() => cb({
|
|
4161
4195
|
...typedDataStrategyArgs,
|
|
4162
4196
|
fetcherKey,
|
|
@@ -4494,11 +4528,12 @@ function processLoaderData(state, matches, results, pendingActionResult, revalid
|
|
|
4494
4528
|
);
|
|
4495
4529
|
revalidatingFetchers.filter((f) => !f.matches || f.matches.some((m) => m.shouldLoad)).forEach((rf) => {
|
|
4496
4530
|
let { key, match, controller } = rf;
|
|
4497
|
-
let result = fetcherResults[key];
|
|
4498
|
-
invariant(result, "Did not find corresponding fetcher result");
|
|
4499
4531
|
if (controller && controller.signal.aborted) {
|
|
4500
4532
|
return;
|
|
4501
|
-
}
|
|
4533
|
+
}
|
|
4534
|
+
let result = fetcherResults[key];
|
|
4535
|
+
invariant(result, "Did not find corresponding fetcher result");
|
|
4536
|
+
if (isErrorResult(result)) {
|
|
4502
4537
|
let boundaryMatch = findNearestBoundary(state.matches, match?.route.id);
|
|
4503
4538
|
if (!(errors && errors[boundaryMatch.route.id])) {
|
|
4504
4539
|
errors = {
|
|
@@ -7164,6 +7199,12 @@ async function bubbleMiddlewareErrors(singleFetchPromise, matches, routesParams,
|
|
|
7164
7199
|
let routeResult = fetchedData.routes[match.route.id];
|
|
7165
7200
|
if ("error" in routeResult) {
|
|
7166
7201
|
middlewareError = routeResult.error;
|
|
7202
|
+
if (results[match.route.id]?.result == null) {
|
|
7203
|
+
results[match.route.id] = {
|
|
7204
|
+
type: "error",
|
|
7205
|
+
result: middlewareError
|
|
7206
|
+
};
|
|
7207
|
+
}
|
|
7167
7208
|
break;
|
|
7168
7209
|
}
|
|
7169
7210
|
}
|
|
@@ -8867,7 +8908,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
|
|
|
8867
8908
|
try {
|
|
8868
8909
|
if (isBrowser) {
|
|
8869
8910
|
window.__reactRouterVersion = // @ts-expect-error
|
|
8870
|
-
"0.0.0-experimental-
|
|
8911
|
+
"0.0.0-experimental-d5a247381";
|
|
8871
8912
|
}
|
|
8872
8913
|
} catch (e) {
|
|
8873
8914
|
}
|