react-router 0.0.0-experimental-54614613e → 0.0.0-experimental-c8b52c995
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 +40 -0
- package/dist/development/{chunk-VTWKMGAY.mjs → chunk-4K5PIBZY.mjs} +118 -51
- package/dist/development/dom-export.js +84 -36
- package/dist/development/dom-export.mjs +2 -2
- package/dist/development/index.js +118 -51
- package/dist/development/index.mjs +2 -2
- package/dist/development/lib/types/route-module.js +1 -1
- package/dist/development/lib/types/route-module.mjs +1 -1
- package/dist/production/{chunk-JDCHZVDC.mjs → chunk-UDVCEGG6.mjs} +118 -51
- package/dist/production/dom-export.js +84 -36
- package/dist/production/dom-export.mjs +2 -2
- package/dist/production/index.js +118 -51
- package/dist/production/index.mjs +2 -2
- package/dist/production/lib/types/route-module.js +1 -1
- package/dist/production/lib/types/route-module.mjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# `react-router`
|
|
2
2
|
|
|
3
|
+
## 7.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add granular object-based API for `route.lazy` to support lazy loading of individual route properties, for example: ([#13294](https://github.com/remix-run/react-router/pull/13294))
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
createBrowserRouter([
|
|
11
|
+
{
|
|
12
|
+
path: "/show/:showId",
|
|
13
|
+
lazy: {
|
|
14
|
+
loader: async () => (await import("./show.loader.js")).loader,
|
|
15
|
+
action: async () => (await import("./show.action.js")).action,
|
|
16
|
+
Component: async () => (await import("./show.component.js")).Component,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
]);
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**Breaking change for `route.unstable_lazyMiddleware` consumers**
|
|
23
|
+
|
|
24
|
+
The `route.unstable_lazyMiddleware` property is no longer supported. If you want to lazily load middleware, you must use the new object-based `route.lazy` API with `route.lazy.unstable_middleware`, for example:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
createBrowserRouter([
|
|
28
|
+
{
|
|
29
|
+
path: "/show/:showId",
|
|
30
|
+
lazy: {
|
|
31
|
+
unstable_middleware: async () =>
|
|
32
|
+
(await import("./show.middleware.js")).middleware,
|
|
33
|
+
// etc.
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
]);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- Introduce `unstable_subResourceIntegrity` future flag that enables generation of an importmap with integrity for the scripts that will be loaded by the browser. ([#13163](https://github.com/remix-run/react-router/pull/13163))
|
|
42
|
+
|
|
3
43
|
## 7.4.1
|
|
4
44
|
|
|
5
45
|
### Patch Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-c8b52c995
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -3610,19 +3610,29 @@ var loadLazyRouteProperty = ({
|
|
|
3610
3610
|
return propertyPromise;
|
|
3611
3611
|
};
|
|
3612
3612
|
var lazyRouteFunctionCache = /* @__PURE__ */ new WeakMap();
|
|
3613
|
-
|
|
3613
|
+
function loadLazyRoute(route, type, manifest, mapRouteProperties2) {
|
|
3614
3614
|
let routeToUpdate = manifest[route.id];
|
|
3615
3615
|
invariant(routeToUpdate, "No route found in manifest");
|
|
3616
3616
|
if (!route.lazy) {
|
|
3617
|
-
return
|
|
3617
|
+
return {
|
|
3618
|
+
lazyRoutePromise: void 0,
|
|
3619
|
+
lazyHandlerPromise: void 0
|
|
3620
|
+
};
|
|
3618
3621
|
}
|
|
3619
3622
|
if (typeof route.lazy === "function") {
|
|
3620
3623
|
let cachedPromise = lazyRouteFunctionCache.get(routeToUpdate);
|
|
3621
3624
|
if (cachedPromise) {
|
|
3622
|
-
|
|
3623
|
-
|
|
3625
|
+
return {
|
|
3626
|
+
lazyRoutePromise: cachedPromise,
|
|
3627
|
+
lazyHandlerPromise: cachedPromise
|
|
3628
|
+
};
|
|
3624
3629
|
}
|
|
3625
|
-
let
|
|
3630
|
+
let lazyRoutePromise2 = (async () => {
|
|
3631
|
+
invariant(
|
|
3632
|
+
typeof route.lazy === "function",
|
|
3633
|
+
"No lazy route function found"
|
|
3634
|
+
);
|
|
3635
|
+
let lazyRoute = await route.lazy();
|
|
3626
3636
|
let routeUpdates = {};
|
|
3627
3637
|
for (let lazyRouteProperty in lazyRoute) {
|
|
3628
3638
|
let lazyValue = lazyRoute[lazyRouteProperty];
|
|
@@ -3656,22 +3666,39 @@ async function loadLazyRoute(route, manifest, mapRouteProperties2) {
|
|
|
3656
3666
|
...mapRouteProperties2(routeToUpdate),
|
|
3657
3667
|
lazy: void 0
|
|
3658
3668
|
});
|
|
3659
|
-
});
|
|
3660
|
-
lazyRouteFunctionCache.set(routeToUpdate,
|
|
3661
|
-
|
|
3662
|
-
|
|
3669
|
+
})();
|
|
3670
|
+
lazyRouteFunctionCache.set(routeToUpdate, lazyRoutePromise2);
|
|
3671
|
+
return {
|
|
3672
|
+
lazyRoutePromise: lazyRoutePromise2,
|
|
3673
|
+
lazyHandlerPromise: lazyRoutePromise2
|
|
3674
|
+
};
|
|
3663
3675
|
}
|
|
3664
3676
|
let lazyKeys = Object.keys(route.lazy);
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
)
|
|
3674
|
-
|
|
3677
|
+
let lazyPropertyPromises = [];
|
|
3678
|
+
let lazyHandlerPromise = void 0;
|
|
3679
|
+
for (let key of lazyKeys) {
|
|
3680
|
+
let promise = loadLazyRouteProperty({
|
|
3681
|
+
key,
|
|
3682
|
+
route,
|
|
3683
|
+
manifest,
|
|
3684
|
+
mapRouteProperties: mapRouteProperties2
|
|
3685
|
+
});
|
|
3686
|
+
if (promise) {
|
|
3687
|
+
lazyPropertyPromises.push(promise);
|
|
3688
|
+
if (key === type) {
|
|
3689
|
+
lazyHandlerPromise = promise;
|
|
3690
|
+
}
|
|
3691
|
+
}
|
|
3692
|
+
}
|
|
3693
|
+
let lazyRoutePromise = Promise.all(lazyPropertyPromises).then(() => {
|
|
3694
|
+
});
|
|
3695
|
+
return {
|
|
3696
|
+
lazyRoutePromise,
|
|
3697
|
+
lazyHandlerPromise
|
|
3698
|
+
};
|
|
3699
|
+
}
|
|
3700
|
+
function isNonNullable(value) {
|
|
3701
|
+
return value !== void 0;
|
|
3675
3702
|
}
|
|
3676
3703
|
function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2) {
|
|
3677
3704
|
let promises = matches.map(({ route }) => {
|
|
@@ -3684,7 +3711,7 @@ function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2) {
|
|
|
3684
3711
|
manifest,
|
|
3685
3712
|
mapRouteProperties: mapRouteProperties2
|
|
3686
3713
|
});
|
|
3687
|
-
}).filter(
|
|
3714
|
+
}).filter(isNonNullable);
|
|
3688
3715
|
return promises.length > 0 ? Promise.all(promises) : void 0;
|
|
3689
3716
|
}
|
|
3690
3717
|
async function defaultDataStrategy(args) {
|
|
@@ -3807,27 +3834,28 @@ async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLo
|
|
|
3807
3834
|
manifest,
|
|
3808
3835
|
mapRouteProperties2
|
|
3809
3836
|
);
|
|
3810
|
-
let
|
|
3811
|
-
(m) =>
|
|
3837
|
+
let lazyRoutePromises = matches.map(
|
|
3838
|
+
(m) => loadLazyRoute(m.route, type, manifest, mapRouteProperties2)
|
|
3812
3839
|
);
|
|
3813
3840
|
if (loadMiddlewarePromise) {
|
|
3814
3841
|
await loadMiddlewarePromise;
|
|
3815
3842
|
}
|
|
3816
3843
|
let dsMatches = matches.map((match, i) => {
|
|
3817
|
-
let
|
|
3844
|
+
let { lazyRoutePromise, lazyHandlerPromise } = lazyRoutePromises[i];
|
|
3818
3845
|
let shouldLoad = matchesToLoad.some((m) => m.route.id === match.route.id);
|
|
3819
3846
|
let resolve = async (handlerOverride) => {
|
|
3820
3847
|
if (handlerOverride && request.method === "GET" && (match.route.lazy || match.route.loader)) {
|
|
3821
3848
|
shouldLoad = true;
|
|
3822
3849
|
}
|
|
3823
|
-
return shouldLoad ? callLoaderOrAction(
|
|
3850
|
+
return shouldLoad ? callLoaderOrAction({
|
|
3824
3851
|
type,
|
|
3825
3852
|
request,
|
|
3826
3853
|
match,
|
|
3827
|
-
|
|
3854
|
+
lazyHandlerPromise,
|
|
3855
|
+
lazyRoutePromise,
|
|
3828
3856
|
handlerOverride,
|
|
3829
3857
|
scopedContext
|
|
3830
|
-
) : Promise.resolve({ type: "data" /* data */, result: void 0 });
|
|
3858
|
+
}) : Promise.resolve({ type: "data" /* data */, result: void 0 });
|
|
3831
3859
|
};
|
|
3832
3860
|
return {
|
|
3833
3861
|
...match,
|
|
@@ -3842,13 +3870,24 @@ async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLo
|
|
|
3842
3870
|
fetcherKey,
|
|
3843
3871
|
context: scopedContext
|
|
3844
3872
|
});
|
|
3873
|
+
let allLazyRoutePromises = lazyRoutePromises.flatMap(
|
|
3874
|
+
(promiseMap) => Object.values(promiseMap).filter(isNonNullable)
|
|
3875
|
+
);
|
|
3845
3876
|
try {
|
|
3846
|
-
await Promise.all(
|
|
3877
|
+
await Promise.all(allLazyRoutePromises);
|
|
3847
3878
|
} catch (e) {
|
|
3848
3879
|
}
|
|
3849
3880
|
return results;
|
|
3850
3881
|
}
|
|
3851
|
-
async function callLoaderOrAction(
|
|
3882
|
+
async function callLoaderOrAction({
|
|
3883
|
+
type,
|
|
3884
|
+
request,
|
|
3885
|
+
match,
|
|
3886
|
+
lazyHandlerPromise,
|
|
3887
|
+
lazyRoutePromise,
|
|
3888
|
+
handlerOverride,
|
|
3889
|
+
scopedContext
|
|
3890
|
+
}) {
|
|
3852
3891
|
let result;
|
|
3853
3892
|
let onReject;
|
|
3854
3893
|
let runHandler = (handler) => {
|
|
@@ -3885,7 +3924,7 @@ async function callLoaderOrAction(type, request, match, loadRoutePromise, handle
|
|
|
3885
3924
|
};
|
|
3886
3925
|
try {
|
|
3887
3926
|
let handler = match.route[type];
|
|
3888
|
-
if (
|
|
3927
|
+
if (lazyHandlerPromise || lazyRoutePromise) {
|
|
3889
3928
|
if (handler) {
|
|
3890
3929
|
let handlerError;
|
|
3891
3930
|
let [value] = await Promise.all([
|
|
@@ -3895,17 +3934,19 @@ async function callLoaderOrAction(type, request, match, loadRoutePromise, handle
|
|
|
3895
3934
|
runHandler(handler).catch((e) => {
|
|
3896
3935
|
handlerError = e;
|
|
3897
3936
|
}),
|
|
3898
|
-
|
|
3937
|
+
// Ensure all lazy route promises are resolved before continuing
|
|
3938
|
+
lazyHandlerPromise,
|
|
3939
|
+
lazyRoutePromise
|
|
3899
3940
|
]);
|
|
3900
3941
|
if (handlerError !== void 0) {
|
|
3901
3942
|
throw handlerError;
|
|
3902
3943
|
}
|
|
3903
3944
|
result = value;
|
|
3904
3945
|
} else {
|
|
3905
|
-
await
|
|
3946
|
+
await lazyHandlerPromise;
|
|
3906
3947
|
handler = match.route[type];
|
|
3907
3948
|
if (handler) {
|
|
3908
|
-
result = await runHandler(handler);
|
|
3949
|
+
[result] = await Promise.all([runHandler(handler), lazyRoutePromise]);
|
|
3909
3950
|
} else if (type === "action") {
|
|
3910
3951
|
let url = new URL(request.url);
|
|
3911
3952
|
let pathname = url.pathname + url.search;
|
|
@@ -6754,6 +6795,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
6754
6795
|
unstable_middleware: routeModule.unstable_clientMiddleware,
|
|
6755
6796
|
handle: routeModule.handle,
|
|
6756
6797
|
shouldRevalidate: getShouldRevalidateFunction(
|
|
6798
|
+
dataRoute.path,
|
|
6757
6799
|
routeModule,
|
|
6758
6800
|
route,
|
|
6759
6801
|
ssr,
|
|
@@ -6906,6 +6948,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
6906
6948
|
shouldRevalidate: async () => {
|
|
6907
6949
|
let lazyRoute = await getLazyRoute();
|
|
6908
6950
|
return getShouldRevalidateFunction(
|
|
6951
|
+
dataRoute.path,
|
|
6909
6952
|
lazyRoute,
|
|
6910
6953
|
route,
|
|
6911
6954
|
ssr,
|
|
@@ -6933,7 +6976,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
6933
6976
|
return dataRoute;
|
|
6934
6977
|
});
|
|
6935
6978
|
}
|
|
6936
|
-
function getShouldRevalidateFunction(route, manifestRoute, ssr, needsRevalidation) {
|
|
6979
|
+
function getShouldRevalidateFunction(path, route, manifestRoute, ssr, needsRevalidation) {
|
|
6937
6980
|
if (needsRevalidation) {
|
|
6938
6981
|
return wrapShouldRevalidateForHdr(
|
|
6939
6982
|
manifestRoute.id,
|
|
@@ -6942,11 +6985,16 @@ function getShouldRevalidateFunction(route, manifestRoute, ssr, needsRevalidatio
|
|
|
6942
6985
|
);
|
|
6943
6986
|
}
|
|
6944
6987
|
if (!ssr && manifestRoute.hasLoader && !manifestRoute.hasClientLoader) {
|
|
6988
|
+
let myParams = path ? compilePath(path)[1].map((p) => p.paramName) : [];
|
|
6989
|
+
const didParamsChange = (opts) => myParams.some((p) => opts.currentParams[p] !== opts.nextParams[p]);
|
|
6945
6990
|
if (route.shouldRevalidate) {
|
|
6946
6991
|
let fn = route.shouldRevalidate;
|
|
6947
|
-
return (opts) => fn({
|
|
6992
|
+
return (opts) => fn({
|
|
6993
|
+
...opts,
|
|
6994
|
+
defaultShouldRevalidate: didParamsChange(opts)
|
|
6995
|
+
});
|
|
6948
6996
|
} else {
|
|
6949
|
-
return () =>
|
|
6997
|
+
return (opts) => didParamsChange(opts);
|
|
6950
6998
|
}
|
|
6951
6999
|
}
|
|
6952
7000
|
if (ssr && route.shouldRevalidate) {
|
|
@@ -7675,7 +7723,7 @@ function mergeRefs(...refs) {
|
|
|
7675
7723
|
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
7676
7724
|
try {
|
|
7677
7725
|
if (isBrowser) {
|
|
7678
|
-
window.__reactRouterVersion = "0.0.0-experimental-
|
|
7726
|
+
window.__reactRouterVersion = "0.0.0-experimental-c8b52c995";
|
|
7679
7727
|
}
|
|
7680
7728
|
} catch (e) {
|
|
7681
7729
|
}
|
|
@@ -9697,9 +9745,6 @@ var createRequestHandler = (build, mode) => {
|
|
|
9697
9745
|
let errorHandler;
|
|
9698
9746
|
return async function requestHandler(request, initialContext) {
|
|
9699
9747
|
_build = typeof build === "function" ? await build() : build;
|
|
9700
|
-
let loadContext = _build.future.unstable_middleware ? new unstable_RouterContextProvider(
|
|
9701
|
-
initialContext
|
|
9702
|
-
) : initialContext || {};
|
|
9703
9748
|
if (typeof build === "function") {
|
|
9704
9749
|
let derived = derive(_build, mode);
|
|
9705
9750
|
routes = derived.routes;
|
|
@@ -9713,18 +9758,8 @@ var createRequestHandler = (build, mode) => {
|
|
|
9713
9758
|
staticHandler = derived.staticHandler;
|
|
9714
9759
|
errorHandler = derived.errorHandler;
|
|
9715
9760
|
}
|
|
9716
|
-
let url = new URL(request.url);
|
|
9717
|
-
let normalizedBasename = _build.basename || "/";
|
|
9718
|
-
let normalizedPath = url.pathname;
|
|
9719
|
-
if (stripBasename(normalizedPath, normalizedBasename) === "/_root.data") {
|
|
9720
|
-
normalizedPath = normalizedBasename;
|
|
9721
|
-
} else if (normalizedPath.endsWith(".data")) {
|
|
9722
|
-
normalizedPath = normalizedPath.replace(/\.data$/, "");
|
|
9723
|
-
}
|
|
9724
|
-
if (stripBasename(normalizedPath, normalizedBasename) !== "/" && normalizedPath.endsWith("/")) {
|
|
9725
|
-
normalizedPath = normalizedPath.slice(0, -1);
|
|
9726
|
-
}
|
|
9727
9761
|
let params = {};
|
|
9762
|
+
let loadContext;
|
|
9728
9763
|
let handleError = (error) => {
|
|
9729
9764
|
if (mode === "development" /* Development */) {
|
|
9730
9765
|
getDevServerHooks()?.processRequestError?.(error);
|
|
@@ -9735,6 +9770,38 @@ var createRequestHandler = (build, mode) => {
|
|
|
9735
9770
|
request
|
|
9736
9771
|
});
|
|
9737
9772
|
};
|
|
9773
|
+
if (_build.future.unstable_middleware) {
|
|
9774
|
+
if (initialContext == null) {
|
|
9775
|
+
loadContext = new unstable_RouterContextProvider();
|
|
9776
|
+
} else {
|
|
9777
|
+
try {
|
|
9778
|
+
loadContext = new unstable_RouterContextProvider(
|
|
9779
|
+
initialContext
|
|
9780
|
+
);
|
|
9781
|
+
} catch (e) {
|
|
9782
|
+
let error = new Error(
|
|
9783
|
+
`Unable to create initial \`unstable_RouterContextProvider\` instance. Please confirm you are returning an instance of \`Map<unstable_routerContext, unknown>\` from your \`getLoadContext\` function.
|
|
9784
|
+
|
|
9785
|
+
Error: ${e instanceof Error ? e.toString() : e}`
|
|
9786
|
+
);
|
|
9787
|
+
handleError(error);
|
|
9788
|
+
return returnLastResortErrorResponse(error, serverMode);
|
|
9789
|
+
}
|
|
9790
|
+
}
|
|
9791
|
+
} else {
|
|
9792
|
+
loadContext = initialContext || {};
|
|
9793
|
+
}
|
|
9794
|
+
let url = new URL(request.url);
|
|
9795
|
+
let normalizedBasename = _build.basename || "/";
|
|
9796
|
+
let normalizedPath = url.pathname;
|
|
9797
|
+
if (stripBasename(normalizedPath, normalizedBasename) === "/_root.data") {
|
|
9798
|
+
normalizedPath = normalizedBasename;
|
|
9799
|
+
} else if (normalizedPath.endsWith(".data")) {
|
|
9800
|
+
normalizedPath = normalizedPath.replace(/\.data$/, "");
|
|
9801
|
+
}
|
|
9802
|
+
if (stripBasename(normalizedPath, normalizedBasename) !== "/" && normalizedPath.endsWith("/")) {
|
|
9803
|
+
normalizedPath = normalizedPath.slice(0, -1);
|
|
9804
|
+
}
|
|
9738
9805
|
if (!_build.ssr) {
|
|
9739
9806
|
if (_build.prerender.length === 0) {
|
|
9740
9807
|
request.headers.set("X-React-Router-SPA-Mode", "yes");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-c8b52c995
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -2898,19 +2898,29 @@ var loadLazyRouteProperty = ({
|
|
|
2898
2898
|
return propertyPromise;
|
|
2899
2899
|
};
|
|
2900
2900
|
var lazyRouteFunctionCache = /* @__PURE__ */ new WeakMap();
|
|
2901
|
-
|
|
2901
|
+
function loadLazyRoute(route, type, manifest, mapRouteProperties2) {
|
|
2902
2902
|
let routeToUpdate = manifest[route.id];
|
|
2903
2903
|
invariant(routeToUpdate, "No route found in manifest");
|
|
2904
2904
|
if (!route.lazy) {
|
|
2905
|
-
return
|
|
2905
|
+
return {
|
|
2906
|
+
lazyRoutePromise: void 0,
|
|
2907
|
+
lazyHandlerPromise: void 0
|
|
2908
|
+
};
|
|
2906
2909
|
}
|
|
2907
2910
|
if (typeof route.lazy === "function") {
|
|
2908
2911
|
let cachedPromise = lazyRouteFunctionCache.get(routeToUpdate);
|
|
2909
2912
|
if (cachedPromise) {
|
|
2910
|
-
|
|
2911
|
-
|
|
2913
|
+
return {
|
|
2914
|
+
lazyRoutePromise: cachedPromise,
|
|
2915
|
+
lazyHandlerPromise: cachedPromise
|
|
2916
|
+
};
|
|
2912
2917
|
}
|
|
2913
|
-
let
|
|
2918
|
+
let lazyRoutePromise2 = (async () => {
|
|
2919
|
+
invariant(
|
|
2920
|
+
typeof route.lazy === "function",
|
|
2921
|
+
"No lazy route function found"
|
|
2922
|
+
);
|
|
2923
|
+
let lazyRoute = await route.lazy();
|
|
2914
2924
|
let routeUpdates = {};
|
|
2915
2925
|
for (let lazyRouteProperty in lazyRoute) {
|
|
2916
2926
|
let lazyValue = lazyRoute[lazyRouteProperty];
|
|
@@ -2944,22 +2954,39 @@ async function loadLazyRoute(route, manifest, mapRouteProperties2) {
|
|
|
2944
2954
|
...mapRouteProperties2(routeToUpdate),
|
|
2945
2955
|
lazy: void 0
|
|
2946
2956
|
});
|
|
2947
|
-
});
|
|
2948
|
-
lazyRouteFunctionCache.set(routeToUpdate,
|
|
2949
|
-
|
|
2950
|
-
|
|
2957
|
+
})();
|
|
2958
|
+
lazyRouteFunctionCache.set(routeToUpdate, lazyRoutePromise2);
|
|
2959
|
+
return {
|
|
2960
|
+
lazyRoutePromise: lazyRoutePromise2,
|
|
2961
|
+
lazyHandlerPromise: lazyRoutePromise2
|
|
2962
|
+
};
|
|
2951
2963
|
}
|
|
2952
2964
|
let lazyKeys = Object.keys(route.lazy);
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
)
|
|
2962
|
-
|
|
2965
|
+
let lazyPropertyPromises = [];
|
|
2966
|
+
let lazyHandlerPromise = void 0;
|
|
2967
|
+
for (let key of lazyKeys) {
|
|
2968
|
+
let promise = loadLazyRouteProperty({
|
|
2969
|
+
key,
|
|
2970
|
+
route,
|
|
2971
|
+
manifest,
|
|
2972
|
+
mapRouteProperties: mapRouteProperties2
|
|
2973
|
+
});
|
|
2974
|
+
if (promise) {
|
|
2975
|
+
lazyPropertyPromises.push(promise);
|
|
2976
|
+
if (key === type) {
|
|
2977
|
+
lazyHandlerPromise = promise;
|
|
2978
|
+
}
|
|
2979
|
+
}
|
|
2980
|
+
}
|
|
2981
|
+
let lazyRoutePromise = Promise.all(lazyPropertyPromises).then(() => {
|
|
2982
|
+
});
|
|
2983
|
+
return {
|
|
2984
|
+
lazyRoutePromise,
|
|
2985
|
+
lazyHandlerPromise
|
|
2986
|
+
};
|
|
2987
|
+
}
|
|
2988
|
+
function isNonNullable(value) {
|
|
2989
|
+
return value !== void 0;
|
|
2963
2990
|
}
|
|
2964
2991
|
function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2) {
|
|
2965
2992
|
let promises = matches.map(({ route }) => {
|
|
@@ -2972,7 +2999,7 @@ function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2) {
|
|
|
2972
2999
|
manifest,
|
|
2973
3000
|
mapRouteProperties: mapRouteProperties2
|
|
2974
3001
|
});
|
|
2975
|
-
}).filter(
|
|
3002
|
+
}).filter(isNonNullable);
|
|
2976
3003
|
return promises.length > 0 ? Promise.all(promises) : void 0;
|
|
2977
3004
|
}
|
|
2978
3005
|
async function defaultDataStrategy(args) {
|
|
@@ -3095,27 +3122,28 @@ async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLo
|
|
|
3095
3122
|
manifest,
|
|
3096
3123
|
mapRouteProperties2
|
|
3097
3124
|
);
|
|
3098
|
-
let
|
|
3099
|
-
(m) =>
|
|
3125
|
+
let lazyRoutePromises = matches.map(
|
|
3126
|
+
(m) => loadLazyRoute(m.route, type, manifest, mapRouteProperties2)
|
|
3100
3127
|
);
|
|
3101
3128
|
if (loadMiddlewarePromise) {
|
|
3102
3129
|
await loadMiddlewarePromise;
|
|
3103
3130
|
}
|
|
3104
3131
|
let dsMatches = matches.map((match, i) => {
|
|
3105
|
-
let
|
|
3132
|
+
let { lazyRoutePromise, lazyHandlerPromise } = lazyRoutePromises[i];
|
|
3106
3133
|
let shouldLoad = matchesToLoad.some((m) => m.route.id === match.route.id);
|
|
3107
3134
|
let resolve = async (handlerOverride) => {
|
|
3108
3135
|
if (handlerOverride && request.method === "GET" && (match.route.lazy || match.route.loader)) {
|
|
3109
3136
|
shouldLoad = true;
|
|
3110
3137
|
}
|
|
3111
|
-
return shouldLoad ? callLoaderOrAction(
|
|
3138
|
+
return shouldLoad ? callLoaderOrAction({
|
|
3112
3139
|
type,
|
|
3113
3140
|
request,
|
|
3114
3141
|
match,
|
|
3115
|
-
|
|
3142
|
+
lazyHandlerPromise,
|
|
3143
|
+
lazyRoutePromise,
|
|
3116
3144
|
handlerOverride,
|
|
3117
3145
|
scopedContext
|
|
3118
|
-
) : Promise.resolve({ type: "data" /* data */, result: void 0 });
|
|
3146
|
+
}) : Promise.resolve({ type: "data" /* data */, result: void 0 });
|
|
3119
3147
|
};
|
|
3120
3148
|
return {
|
|
3121
3149
|
...match,
|
|
@@ -3130,13 +3158,24 @@ async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLo
|
|
|
3130
3158
|
fetcherKey,
|
|
3131
3159
|
context: scopedContext
|
|
3132
3160
|
});
|
|
3161
|
+
let allLazyRoutePromises = lazyRoutePromises.flatMap(
|
|
3162
|
+
(promiseMap) => Object.values(promiseMap).filter(isNonNullable)
|
|
3163
|
+
);
|
|
3133
3164
|
try {
|
|
3134
|
-
await Promise.all(
|
|
3165
|
+
await Promise.all(allLazyRoutePromises);
|
|
3135
3166
|
} catch (e) {
|
|
3136
3167
|
}
|
|
3137
3168
|
return results;
|
|
3138
3169
|
}
|
|
3139
|
-
async function callLoaderOrAction(
|
|
3170
|
+
async function callLoaderOrAction({
|
|
3171
|
+
type,
|
|
3172
|
+
request,
|
|
3173
|
+
match,
|
|
3174
|
+
lazyHandlerPromise,
|
|
3175
|
+
lazyRoutePromise,
|
|
3176
|
+
handlerOverride,
|
|
3177
|
+
scopedContext
|
|
3178
|
+
}) {
|
|
3140
3179
|
let result;
|
|
3141
3180
|
let onReject;
|
|
3142
3181
|
let runHandler = (handler) => {
|
|
@@ -3173,7 +3212,7 @@ async function callLoaderOrAction(type, request, match, loadRoutePromise, handle
|
|
|
3173
3212
|
};
|
|
3174
3213
|
try {
|
|
3175
3214
|
let handler = match.route[type];
|
|
3176
|
-
if (
|
|
3215
|
+
if (lazyHandlerPromise || lazyRoutePromise) {
|
|
3177
3216
|
if (handler) {
|
|
3178
3217
|
let handlerError;
|
|
3179
3218
|
let [value] = await Promise.all([
|
|
@@ -3183,17 +3222,19 @@ async function callLoaderOrAction(type, request, match, loadRoutePromise, handle
|
|
|
3183
3222
|
runHandler(handler).catch((e) => {
|
|
3184
3223
|
handlerError = e;
|
|
3185
3224
|
}),
|
|
3186
|
-
|
|
3225
|
+
// Ensure all lazy route promises are resolved before continuing
|
|
3226
|
+
lazyHandlerPromise,
|
|
3227
|
+
lazyRoutePromise
|
|
3187
3228
|
]);
|
|
3188
3229
|
if (handlerError !== void 0) {
|
|
3189
3230
|
throw handlerError;
|
|
3190
3231
|
}
|
|
3191
3232
|
result = value;
|
|
3192
3233
|
} else {
|
|
3193
|
-
await
|
|
3234
|
+
await lazyHandlerPromise;
|
|
3194
3235
|
handler = match.route[type];
|
|
3195
3236
|
if (handler) {
|
|
3196
|
-
result = await runHandler(handler);
|
|
3237
|
+
[result] = await Promise.all([runHandler(handler), lazyRoutePromise]);
|
|
3197
3238
|
} else if (type === "action") {
|
|
3198
3239
|
let url = new URL(request.url);
|
|
3199
3240
|
let pathname = url.pathname + url.search;
|
|
@@ -5214,6 +5255,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
5214
5255
|
unstable_middleware: routeModule.unstable_clientMiddleware,
|
|
5215
5256
|
handle: routeModule.handle,
|
|
5216
5257
|
shouldRevalidate: getShouldRevalidateFunction(
|
|
5258
|
+
dataRoute.path,
|
|
5217
5259
|
routeModule,
|
|
5218
5260
|
route,
|
|
5219
5261
|
ssr,
|
|
@@ -5366,6 +5408,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
5366
5408
|
shouldRevalidate: async () => {
|
|
5367
5409
|
let lazyRoute = await getLazyRoute();
|
|
5368
5410
|
return getShouldRevalidateFunction(
|
|
5411
|
+
dataRoute.path,
|
|
5369
5412
|
lazyRoute,
|
|
5370
5413
|
route,
|
|
5371
5414
|
ssr,
|
|
@@ -5393,7 +5436,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
5393
5436
|
return dataRoute;
|
|
5394
5437
|
});
|
|
5395
5438
|
}
|
|
5396
|
-
function getShouldRevalidateFunction(route, manifestRoute, ssr, needsRevalidation) {
|
|
5439
|
+
function getShouldRevalidateFunction(path, route, manifestRoute, ssr, needsRevalidation) {
|
|
5397
5440
|
if (needsRevalidation) {
|
|
5398
5441
|
return wrapShouldRevalidateForHdr(
|
|
5399
5442
|
manifestRoute.id,
|
|
@@ -5402,11 +5445,16 @@ function getShouldRevalidateFunction(route, manifestRoute, ssr, needsRevalidatio
|
|
|
5402
5445
|
);
|
|
5403
5446
|
}
|
|
5404
5447
|
if (!ssr && manifestRoute.hasLoader && !manifestRoute.hasClientLoader) {
|
|
5448
|
+
let myParams = path ? compilePath(path)[1].map((p) => p.paramName) : [];
|
|
5449
|
+
const didParamsChange = (opts) => myParams.some((p) => opts.currentParams[p] !== opts.nextParams[p]);
|
|
5405
5450
|
if (route.shouldRevalidate) {
|
|
5406
5451
|
let fn = route.shouldRevalidate;
|
|
5407
|
-
return (opts) => fn({
|
|
5452
|
+
return (opts) => fn({
|
|
5453
|
+
...opts,
|
|
5454
|
+
defaultShouldRevalidate: didParamsChange(opts)
|
|
5455
|
+
});
|
|
5408
5456
|
} else {
|
|
5409
|
-
return () =>
|
|
5457
|
+
return (opts) => didParamsChange(opts);
|
|
5410
5458
|
}
|
|
5411
5459
|
}
|
|
5412
5460
|
if (ssr && route.shouldRevalidate) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-c8b52c995
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
matchRoutes,
|
|
26
26
|
shouldHydrateRouteLoader,
|
|
27
27
|
useFogOFWarDiscovery
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-4K5PIBZY.mjs";
|
|
29
29
|
|
|
30
30
|
// lib/dom-export/dom-router-provider.tsx
|
|
31
31
|
import * as React from "react";
|