@remix-run/router 0.0.0-experimental-c9f8a7b2 → 0.0.0-experimental-e960cf1a
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 +8 -199
- package/dist/index.d.ts +2 -2
- package/dist/router.cjs.js +138 -90
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +3 -2
- package/dist/router.js +135 -91
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +138 -90
- package/dist/router.umd.js.map +1 -1
- package/dist/router.umd.min.js +2 -2
- package/dist/router.umd.min.js.map +1 -1
- package/dist/utils.d.ts +13 -0
- package/index.ts +5 -0
- package/package.json +1 -1
- package/router.ts +243 -124
- package/utils.ts +25 -9
package/dist/router.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v0.0.0-experimental-
|
|
2
|
+
* @remix-run/router v0.0.0-experimental-e960cf1a
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -889,7 +889,7 @@ function rankRouteBranches(branches) {
|
|
|
889
889
|
branches.sort((a, b) => a.score !== b.score ? b.score - a.score // Higher score first
|
|
890
890
|
: compareIndexes(a.routesMeta.map(meta => meta.childrenIndex), b.routesMeta.map(meta => meta.childrenIndex)));
|
|
891
891
|
}
|
|
892
|
-
const paramRe =
|
|
892
|
+
const paramRe = /^:\w+$/;
|
|
893
893
|
const dynamicSegmentValue = 3;
|
|
894
894
|
const indexRouteValue = 2;
|
|
895
895
|
const emptySegmentValue = 1;
|
|
@@ -979,7 +979,7 @@ function generatePath(originalPath, params) {
|
|
|
979
979
|
// Apply the splat
|
|
980
980
|
return stringify(params[star]);
|
|
981
981
|
}
|
|
982
|
-
const keyMatch = segment.match(/^:(
|
|
982
|
+
const keyMatch = segment.match(/^:(\w+)(\??)$/);
|
|
983
983
|
if (keyMatch) {
|
|
984
984
|
const [, key, optional] = keyMatch;
|
|
985
985
|
let param = params[key];
|
|
@@ -1061,7 +1061,7 @@ function compilePath(path, caseSensitive, end) {
|
|
|
1061
1061
|
let regexpSource = "^" + path.replace(/\/*\*?$/, "") // Ignore trailing / and /*, we'll handle it below
|
|
1062
1062
|
.replace(/^\/*/, "/") // Make sure it has a leading /
|
|
1063
1063
|
.replace(/[\\.*+^${}|()[\]]/g, "\\$&") // Escape special regex chars
|
|
1064
|
-
.replace(/\/:(
|
|
1064
|
+
.replace(/\/:(\w+)(\?)?/g, (_, paramName, isOptional) => {
|
|
1065
1065
|
params.push({
|
|
1066
1066
|
paramName,
|
|
1067
1067
|
isOptional: isOptional != null
|
|
@@ -1654,6 +1654,8 @@ function createRouter(init) {
|
|
|
1654
1654
|
const isBrowser = typeof routerWindow !== "undefined" && typeof routerWindow.document !== "undefined" && typeof routerWindow.document.createElement !== "undefined";
|
|
1655
1655
|
const isServer = !isBrowser;
|
|
1656
1656
|
invariant(init.routes.length > 0, "You must provide a non-empty routes array to createRouter");
|
|
1657
|
+
const dataStrategy = init.unstable_dataStrategy || defaultDataStrategy;
|
|
1658
|
+
const callLoaderOrAction = createCallLoaderOrAction(dataStrategy);
|
|
1657
1659
|
let mapRouteProperties;
|
|
1658
1660
|
if (init.mapRouteProperties) {
|
|
1659
1661
|
mapRouteProperties = init.mapRouteProperties;
|
|
@@ -1715,28 +1717,18 @@ function createRouter(init) {
|
|
|
1715
1717
|
[route.id]: error
|
|
1716
1718
|
};
|
|
1717
1719
|
}
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
// provided with hydrationData for every route with a loader, and no loaders
|
|
1731
|
-
// were marked for explicit hydration
|
|
1732
|
-
let loaderData = init.hydrationData ? init.hydrationData.loaderData : null;
|
|
1733
|
-
let errors = init.hydrationData ? init.hydrationData.errors : null;
|
|
1734
|
-
initialized = initialMatches.every(m => m.route.loader && m.route.loader.hydrate !== true && (loaderData && loaderData[m.route.id] !== undefined || errors && errors[m.route.id] !== undefined));
|
|
1735
|
-
} else {
|
|
1736
|
-
// Without partial hydration - we're initialized if we were provided any
|
|
1737
|
-
// hydrationData - which is expected to be complete
|
|
1738
|
-
initialized = init.hydrationData != null;
|
|
1739
|
-
}
|
|
1720
|
+
|
|
1721
|
+
// "Initialized" here really means "Can `RouterProvider` render my route tree?"
|
|
1722
|
+
// Prior to `route.HydrateFallback`, we only had a root `fallbackElement` so we used
|
|
1723
|
+
// `state.initialized` to render that instead of `<DataRoutes>`. Now that we
|
|
1724
|
+
// support route level fallbacks we can always render and we'll just render
|
|
1725
|
+
// as deep as we have data for and detect the nearest ancestor HydrateFallback
|
|
1726
|
+
let initialized = future.v7_partialHydration ||
|
|
1727
|
+
// All initialMatches need to be loaded before we're ready. If we have lazy
|
|
1728
|
+
// functions around still then we'll need to run them in initialize()
|
|
1729
|
+
!initialMatches.some(m => m.route.lazy) && (
|
|
1730
|
+
// And we have to either have no loaders or have been provided hydrationData
|
|
1731
|
+
!initialMatches.some(m => m.route.loader) || init.hydrationData != null);
|
|
1740
1732
|
let router;
|
|
1741
1733
|
let state = {
|
|
1742
1734
|
historyAction: init.history.action,
|
|
@@ -1903,7 +1895,7 @@ function createRouter(init) {
|
|
|
1903
1895
|
// in the normal navigation flow. For SSR it's expected that lazy modules are
|
|
1904
1896
|
// resolved prior to router creation since we can't go into a fallbackElement
|
|
1905
1897
|
// UI for SSR'd apps
|
|
1906
|
-
if (!state.initialized) {
|
|
1898
|
+
if (!state.initialized || future.v7_partialHydration && state.matches.some(m => isUnhydratedRoute(state, m.route))) {
|
|
1907
1899
|
startNavigation(Action.Pop, state.location, {
|
|
1908
1900
|
initialHydration: true
|
|
1909
1901
|
});
|
|
@@ -2482,10 +2474,9 @@ function createRouter(init) {
|
|
|
2482
2474
|
pendingNavigationController.signal.addEventListener("abort", abortPendingFetchRevalidations);
|
|
2483
2475
|
}
|
|
2484
2476
|
let {
|
|
2485
|
-
results,
|
|
2486
2477
|
loaderResults,
|
|
2487
2478
|
fetcherResults
|
|
2488
|
-
} = await
|
|
2479
|
+
} = await loadDataAndMaybeResolveDeferred(state.matches, matches, matchesToLoad, revalidatingFetchers, request);
|
|
2489
2480
|
if (request.signal.aborted) {
|
|
2490
2481
|
return {
|
|
2491
2482
|
shortCircuited: true
|
|
@@ -2501,7 +2492,7 @@ function createRouter(init) {
|
|
|
2501
2492
|
revalidatingFetchers.forEach(rf => fetchControllers.delete(rf.key));
|
|
2502
2493
|
|
|
2503
2494
|
// If any loaders returned a redirect Response, start a new REPLACE navigation
|
|
2504
|
-
let redirect = findRedirect(
|
|
2495
|
+
let redirect = findRedirect([...loaderResults, ...fetcherResults]);
|
|
2505
2496
|
if (redirect) {
|
|
2506
2497
|
if (redirect.idx >= matchesToLoad.length) {
|
|
2507
2498
|
// If this redirect came from a fetcher make sure we mark it in
|
|
@@ -2706,10 +2697,9 @@ function createRouter(init) {
|
|
|
2706
2697
|
let abortPendingFetchRevalidations = () => revalidatingFetchers.forEach(rf => abortFetcher(rf.key));
|
|
2707
2698
|
abortController.signal.addEventListener("abort", abortPendingFetchRevalidations);
|
|
2708
2699
|
let {
|
|
2709
|
-
results,
|
|
2710
2700
|
loaderResults,
|
|
2711
2701
|
fetcherResults
|
|
2712
|
-
} = await
|
|
2702
|
+
} = await loadDataAndMaybeResolveDeferred(state.matches, matches, matchesToLoad, revalidatingFetchers, revalidationRequest);
|
|
2713
2703
|
if (abortController.signal.aborted) {
|
|
2714
2704
|
return;
|
|
2715
2705
|
}
|
|
@@ -2717,7 +2707,7 @@ function createRouter(init) {
|
|
|
2717
2707
|
fetchReloadIds.delete(key);
|
|
2718
2708
|
fetchControllers.delete(key);
|
|
2719
2709
|
revalidatingFetchers.forEach(r => fetchControllers.delete(r.key));
|
|
2720
|
-
let redirect = findRedirect(
|
|
2710
|
+
let redirect = findRedirect([...loaderResults, ...fetcherResults]);
|
|
2721
2711
|
if (redirect) {
|
|
2722
2712
|
if (redirect.idx >= matchesToLoad.length) {
|
|
2723
2713
|
// If this redirect came from a fetcher make sure we mark it in
|
|
@@ -2927,28 +2917,36 @@ function createRouter(init) {
|
|
|
2927
2917
|
});
|
|
2928
2918
|
}
|
|
2929
2919
|
}
|
|
2930
|
-
async function
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
return
|
|
2937
|
-
}
|
|
2938
|
-
|
|
2920
|
+
async function loadDataAndMaybeResolveDeferred(currentMatches, matches, matchesToLoad, fetchersToLoad, request) {
|
|
2921
|
+
let [loaderResults, ...fetcherResults] = await Promise.all([matchesToLoad.length ? dataStrategy({
|
|
2922
|
+
matches: matchesToLoad.map(m => finesseToAgnosticDataStrategyMatch(m, mapRouteProperties, manifest)),
|
|
2923
|
+
request,
|
|
2924
|
+
type: "loader",
|
|
2925
|
+
defaultStrategy(match) {
|
|
2926
|
+
return callLoaderOrActionImplementation("loader", request, match, matches, basename, future.v7_relativeSplatPath);
|
|
2927
|
+
}
|
|
2928
|
+
}) : [], ...fetchersToLoad.map(f => {
|
|
2929
|
+
if (!f.matches || !f.match || !f.controller) {
|
|
2930
|
+
return Promise.resolve({
|
|
2939
2931
|
type: ResultType.error,
|
|
2940
2932
|
error: getInternalRouterError(404, {
|
|
2941
2933
|
pathname: f.path
|
|
2942
2934
|
})
|
|
2943
|
-
};
|
|
2944
|
-
return error;
|
|
2935
|
+
});
|
|
2945
2936
|
}
|
|
2937
|
+
return dataStrategy({
|
|
2938
|
+
matches: [finesseToAgnosticDataStrategyMatch(f.match, mapRouteProperties, manifest)],
|
|
2939
|
+
request,
|
|
2940
|
+
type: "loader",
|
|
2941
|
+
defaultStrategy(match) {
|
|
2942
|
+
invariant(f.controller, "Expected controller for fetcher in defaultStrategy");
|
|
2943
|
+
invariant(f.matches, "Expected matches for fetcher in defaultStrategy");
|
|
2944
|
+
return callLoaderOrActionImplementation("loader", createClientSideRequest(init.history, f.path, f.controller.signal), match, f.matches, basename, future.v7_relativeSplatPath);
|
|
2945
|
+
}
|
|
2946
|
+
}).then(r => r[0]);
|
|
2946
2947
|
})]);
|
|
2947
|
-
let loaderResults = results.slice(0, matchesToLoad.length);
|
|
2948
|
-
let fetcherResults = results.slice(matchesToLoad.length);
|
|
2949
2948
|
await Promise.all([resolveDeferredResults(currentMatches, matchesToLoad, loaderResults, loaderResults.map(() => request.signal), false, state.loaderData), resolveDeferredResults(currentMatches, fetchersToLoad.map(f => f.match), fetcherResults, fetchersToLoad.map(f => f.controller ? f.controller.signal : null), true)]);
|
|
2950
2949
|
return {
|
|
2951
|
-
results,
|
|
2952
2950
|
loaderResults,
|
|
2953
2951
|
fetcherResults
|
|
2954
2952
|
};
|
|
@@ -3259,6 +3257,8 @@ const UNSAFE_DEFERRED_SYMBOL = Symbol("deferred");
|
|
|
3259
3257
|
|
|
3260
3258
|
function createStaticHandler(routes, opts) {
|
|
3261
3259
|
invariant(routes.length > 0, "You must provide a non-empty routes array to createStaticHandler");
|
|
3260
|
+
const dataStrategy = (opts == null ? void 0 : opts.dataStrategy) || defaultDataStrategy;
|
|
3261
|
+
const callLoaderOrAction = createCallLoaderOrAction(dataStrategy);
|
|
3262
3262
|
let manifest = {};
|
|
3263
3263
|
let basename = (opts ? opts.basename : null) || "/";
|
|
3264
3264
|
let mapRouteProperties;
|
|
@@ -3275,8 +3275,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3275
3275
|
}
|
|
3276
3276
|
// Config driven behavior flags
|
|
3277
3277
|
let future = _extends({
|
|
3278
|
-
v7_relativeSplatPath: false
|
|
3279
|
-
v7_throwAbortReason: false
|
|
3278
|
+
v7_relativeSplatPath: false
|
|
3280
3279
|
}, opts ? opts.future : null);
|
|
3281
3280
|
let dataRoutes = convertRoutesToDataRoutes(routes, mapRouteProperties, undefined, manifest);
|
|
3282
3281
|
|
|
@@ -3499,7 +3498,8 @@ function createStaticHandler(routes, opts) {
|
|
|
3499
3498
|
requestContext
|
|
3500
3499
|
});
|
|
3501
3500
|
if (request.signal.aborted) {
|
|
3502
|
-
|
|
3501
|
+
let method = isRouteRequest ? "queryRoute" : "query";
|
|
3502
|
+
throw new Error(method + "() call aborted: " + request.method + " " + request.url);
|
|
3503
3503
|
}
|
|
3504
3504
|
}
|
|
3505
3505
|
if (isRedirectResult(result)) {
|
|
@@ -3611,13 +3611,21 @@ function createStaticHandler(routes, opts) {
|
|
|
3611
3611
|
activeDeferreds: null
|
|
3612
3612
|
};
|
|
3613
3613
|
}
|
|
3614
|
-
let results = await
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3614
|
+
let results = await dataStrategy({
|
|
3615
|
+
matches: matchesToLoad.map(m => finesseToAgnosticDataStrategyMatch(m, mapRouteProperties, manifest)),
|
|
3616
|
+
request,
|
|
3617
|
+
type: "loader",
|
|
3618
|
+
defaultStrategy(match) {
|
|
3619
|
+
return callLoaderOrActionImplementation("loader", request, match, matches, basename, future.v7_relativeSplatPath, {
|
|
3620
|
+
isStaticRequest: true,
|
|
3621
|
+
isRouteRequest,
|
|
3622
|
+
requestContext
|
|
3623
|
+
});
|
|
3624
|
+
}
|
|
3625
|
+
});
|
|
3619
3626
|
if (request.signal.aborted) {
|
|
3620
|
-
|
|
3627
|
+
let method = isRouteRequest ? "queryRoute" : "query";
|
|
3628
|
+
throw new Error(method + "() call aborted: " + request.method + " " + request.url);
|
|
3621
3629
|
}
|
|
3622
3630
|
|
|
3623
3631
|
// Process and commit output from loaders
|
|
@@ -3649,6 +3657,14 @@ function createStaticHandler(routes, opts) {
|
|
|
3649
3657
|
//#region Helpers
|
|
3650
3658
|
////////////////////////////////////////////////////////////////////////////////
|
|
3651
3659
|
|
|
3660
|
+
function defaultDataStrategy(_ref3) {
|
|
3661
|
+
let {
|
|
3662
|
+
defaultStrategy,
|
|
3663
|
+
matches
|
|
3664
|
+
} = _ref3;
|
|
3665
|
+
return Promise.all(matches.map(match => defaultStrategy(match)));
|
|
3666
|
+
}
|
|
3667
|
+
|
|
3652
3668
|
/**
|
|
3653
3669
|
* Given an existing StaticHandlerContext and an error thrown at render time,
|
|
3654
3670
|
* provide an updated StaticHandlerContext suitable for a second SSR render
|
|
@@ -3662,13 +3678,6 @@ function getStaticContextFromError(routes, context, error) {
|
|
|
3662
3678
|
});
|
|
3663
3679
|
return newContext;
|
|
3664
3680
|
}
|
|
3665
|
-
function throwStaticHandlerAbortedError(request, isRouteRequest, future) {
|
|
3666
|
-
if (future.v7_throwAbortReason && request.signal.reason !== undefined) {
|
|
3667
|
-
throw request.signal.reason;
|
|
3668
|
-
}
|
|
3669
|
-
let method = isRouteRequest ? "queryRoute" : "query";
|
|
3670
|
-
throw new Error(method + "() call aborted: " + request.method + " " + request.url);
|
|
3671
|
-
}
|
|
3672
3681
|
function isSubmissionNavigation(opts) {
|
|
3673
3682
|
return opts != null && ("formData" in opts && opts.formData != null || "body" in opts && opts.body !== undefined);
|
|
3674
3683
|
}
|
|
@@ -3753,8 +3762,8 @@ function normalizeNavigateOptions(normalizeFormMethod, isFetcher, path, opts) {
|
|
|
3753
3762
|
}
|
|
3754
3763
|
let text = typeof opts.body === "string" ? opts.body : opts.body instanceof FormData || opts.body instanceof URLSearchParams ?
|
|
3755
3764
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#plain-text-form-data
|
|
3756
|
-
Array.from(opts.body.entries()).reduce((acc,
|
|
3757
|
-
let [name, value] =
|
|
3765
|
+
Array.from(opts.body.entries()).reduce((acc, _ref4) => {
|
|
3766
|
+
let [name, value] = _ref4;
|
|
3758
3767
|
return "" + acc + name + "=" + value + "\n";
|
|
3759
3768
|
}, "") : String(opts.body);
|
|
3760
3769
|
return {
|
|
@@ -3865,24 +3874,18 @@ function getMatchesToLoad(history, state, matches, submission, location, isIniti
|
|
|
3865
3874
|
let boundaryId = pendingError ? Object.keys(pendingError)[0] : undefined;
|
|
3866
3875
|
let boundaryMatches = getLoaderMatchesUntilBoundary(matches, boundaryId);
|
|
3867
3876
|
let navigationMatches = boundaryMatches.filter((match, index) => {
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3877
|
+
if (isInitialLoad) {
|
|
3878
|
+
// On initial hydration we don't do any shouldRevalidate stuff - we just
|
|
3879
|
+
// call the unhydrated loaders
|
|
3880
|
+
return isUnhydratedRoute(state, match.route);
|
|
3881
|
+
}
|
|
3882
|
+
if (match.route.lazy) {
|
|
3872
3883
|
// We haven't loaded this route yet so we don't know if it's got a loader!
|
|
3873
3884
|
return true;
|
|
3874
3885
|
}
|
|
3875
|
-
if (route.loader == null) {
|
|
3886
|
+
if (match.route.loader == null) {
|
|
3876
3887
|
return false;
|
|
3877
3888
|
}
|
|
3878
|
-
if (isInitialLoad) {
|
|
3879
|
-
if (route.loader.hydrate) {
|
|
3880
|
-
return true;
|
|
3881
|
-
}
|
|
3882
|
-
return state.loaderData[route.id] === undefined && (
|
|
3883
|
-
// Don't re-run if the loader ran and threw an error
|
|
3884
|
-
!state.errors || state.errors[route.id] === undefined);
|
|
3885
|
-
}
|
|
3886
3889
|
|
|
3887
3890
|
// Always call the loader on new route instances and pending defer cancellations
|
|
3888
3891
|
if (isNewLoader(state.loaderData, state.matches[index], match) || cancelledDeferredRoutes.some(id => id === match.route.id)) {
|
|
@@ -3984,6 +3987,20 @@ function getMatchesToLoad(history, state, matches, submission, location, isIniti
|
|
|
3984
3987
|
});
|
|
3985
3988
|
return [navigationMatches, revalidatingFetchers];
|
|
3986
3989
|
}
|
|
3990
|
+
|
|
3991
|
+
// Is this route unhydrated (when v7_partialHydration=true) such that we need
|
|
3992
|
+
// to call it's loader on the initial router creation
|
|
3993
|
+
function isUnhydratedRoute(state, route) {
|
|
3994
|
+
if (!route.loader) {
|
|
3995
|
+
return false;
|
|
3996
|
+
}
|
|
3997
|
+
if (route.loader.hydrate) {
|
|
3998
|
+
return true;
|
|
3999
|
+
}
|
|
4000
|
+
return state.loaderData[route.id] === undefined && (!state.errors ||
|
|
4001
|
+
// Loader ran but errored - don't re-run
|
|
4002
|
+
state.errors[route.id] === undefined);
|
|
4003
|
+
}
|
|
3987
4004
|
function isNewLoader(currentLoaderData, currentMatch, match) {
|
|
3988
4005
|
let isNew =
|
|
3989
4006
|
// [a] -> [a, b]
|
|
@@ -4025,7 +4042,7 @@ function shouldRevalidateLoader(loaderMatch, arg) {
|
|
|
4025
4042
|
*/
|
|
4026
4043
|
async function loadLazyRouteModule(route, mapRouteProperties, manifest) {
|
|
4027
4044
|
if (!route.lazy) {
|
|
4028
|
-
return;
|
|
4045
|
+
return route;
|
|
4029
4046
|
}
|
|
4030
4047
|
let lazyRoute = await route.lazy();
|
|
4031
4048
|
|
|
@@ -4033,7 +4050,7 @@ async function loadLazyRouteModule(route, mapRouteProperties, manifest) {
|
|
|
4033
4050
|
// call then we can return - first lazy() to finish wins because the return
|
|
4034
4051
|
// value of lazy is expected to be static
|
|
4035
4052
|
if (!route.lazy) {
|
|
4036
|
-
return;
|
|
4053
|
+
return route;
|
|
4037
4054
|
}
|
|
4038
4055
|
let routeToUpdate = manifest[route.id];
|
|
4039
4056
|
invariant(routeToUpdate, "No route found in manifest");
|
|
@@ -4069,8 +4086,42 @@ async function loadLazyRouteModule(route, mapRouteProperties, manifest) {
|
|
|
4069
4086
|
Object.assign(routeToUpdate, _extends({}, mapRouteProperties(routeToUpdate), {
|
|
4070
4087
|
lazy: undefined
|
|
4071
4088
|
}));
|
|
4089
|
+
return routeToUpdate;
|
|
4090
|
+
}
|
|
4091
|
+
function createCallLoaderOrAction(dataStrategy) {
|
|
4092
|
+
return async function (type, request, match, matches, manifest, mapRouteProperties, basename, v7_relativeSplatPath, opts) {
|
|
4093
|
+
if (opts === void 0) {
|
|
4094
|
+
opts = {};
|
|
4095
|
+
}
|
|
4096
|
+
let [result] = await dataStrategy({
|
|
4097
|
+
matches: [finesseToAgnosticDataStrategyMatch(match, mapRouteProperties, manifest)],
|
|
4098
|
+
request,
|
|
4099
|
+
type,
|
|
4100
|
+
defaultStrategy(match) {
|
|
4101
|
+
return callLoaderOrActionImplementation(type, request, match, matches, basename, v7_relativeSplatPath, opts);
|
|
4102
|
+
}
|
|
4103
|
+
});
|
|
4104
|
+
return result;
|
|
4105
|
+
};
|
|
4072
4106
|
}
|
|
4073
|
-
|
|
4107
|
+
function finesseToAgnosticDataStrategyMatch(match, mapRouteProperties, manifest) {
|
|
4108
|
+
let loadRoutePromise;
|
|
4109
|
+
if (match.route.lazy) {
|
|
4110
|
+
try {
|
|
4111
|
+
loadRoutePromise = loadLazyRouteModule(match.route, mapRouteProperties, manifest);
|
|
4112
|
+
} catch (error) {
|
|
4113
|
+
loadRoutePromise = Promise.reject(error);
|
|
4114
|
+
}
|
|
4115
|
+
}
|
|
4116
|
+
if (!loadRoutePromise) {
|
|
4117
|
+
loadRoutePromise = Promise.resolve(match.route);
|
|
4118
|
+
}
|
|
4119
|
+
loadRoutePromise.catch(() => {});
|
|
4120
|
+
return _extends({}, match, {
|
|
4121
|
+
route: Object.assign(loadRoutePromise, match.route)
|
|
4122
|
+
});
|
|
4123
|
+
}
|
|
4124
|
+
async function callLoaderOrActionImplementation(type, request, match, matches, basename, v7_relativeSplatPath, opts) {
|
|
4074
4125
|
if (opts === void 0) {
|
|
4075
4126
|
opts = {};
|
|
4076
4127
|
}
|
|
@@ -4101,15 +4152,15 @@ async function callLoaderOrAction(type, request, match, matches, manifest, mapRo
|
|
|
4101
4152
|
// route has a boundary that can handle the error
|
|
4102
4153
|
runHandler(handler).catch(e => {
|
|
4103
4154
|
handlerError = e;
|
|
4104
|
-
}),
|
|
4155
|
+
}), match.route]);
|
|
4105
4156
|
if (handlerError) {
|
|
4106
4157
|
throw handlerError;
|
|
4107
4158
|
}
|
|
4108
4159
|
result = values[0];
|
|
4109
4160
|
} else {
|
|
4110
4161
|
// Load lazy route module, then run any returned handler
|
|
4111
|
-
await
|
|
4112
|
-
handler =
|
|
4162
|
+
let route = await match.route;
|
|
4163
|
+
handler = route[type];
|
|
4113
4164
|
if (handler) {
|
|
4114
4165
|
// Handler still run even if we got interrupted to maintain consistency
|
|
4115
4166
|
// with un-abortable behavior of handler execution on non-lazy or
|
|
@@ -4160,7 +4211,7 @@ async function callLoaderOrAction(type, request, match, matches, manifest, mapRo
|
|
|
4160
4211
|
|
|
4161
4212
|
// Support relative routing in internal redirects
|
|
4162
4213
|
if (!ABSOLUTE_URL_REGEX.test(location)) {
|
|
4163
|
-
location = normalizeTo(new URL(request.url), matches.slice(0, matches.
|
|
4214
|
+
location = normalizeTo(new URL(request.url), matches.slice(0, matches.findIndex(m => m.route.id === match.route.id) + 1), basename, true, location, v7_relativeSplatPath);
|
|
4164
4215
|
} else if (!opts.isStaticRequest) {
|
|
4165
4216
|
// Strip off the protocol+origin for same-origin + same-basename absolute
|
|
4166
4217
|
// redirects. If this is a static request, we can let it go back to the
|
|
@@ -4206,11 +4257,7 @@ async function callLoaderOrAction(type, request, match, matches, manifest, mapRo
|
|
|
4206
4257
|
// Check between word boundaries instead of startsWith() due to the last
|
|
4207
4258
|
// paragraph of https://httpwg.org/specs/rfc9110.html#field.content-type
|
|
4208
4259
|
if (contentType && /\bapplication\/json\b/.test(contentType)) {
|
|
4209
|
-
|
|
4210
|
-
data = null;
|
|
4211
|
-
} else {
|
|
4212
|
-
data = await result.json();
|
|
4213
|
-
}
|
|
4260
|
+
data = await result.json();
|
|
4214
4261
|
} else {
|
|
4215
4262
|
data = await result.text();
|
|
4216
4263
|
}
|
|
@@ -4812,6 +4859,7 @@ exports.Action = Action;
|
|
|
4812
4859
|
exports.IDLE_BLOCKER = IDLE_BLOCKER;
|
|
4813
4860
|
exports.IDLE_FETCHER = IDLE_FETCHER;
|
|
4814
4861
|
exports.IDLE_NAVIGATION = IDLE_NAVIGATION;
|
|
4862
|
+
exports.ResultType = ResultType;
|
|
4815
4863
|
exports.UNSAFE_DEFERRED_SYMBOL = UNSAFE_DEFERRED_SYMBOL;
|
|
4816
4864
|
exports.UNSAFE_DeferredData = DeferredData;
|
|
4817
4865
|
exports.UNSAFE_ErrorResponseImpl = ErrorResponseImpl;
|