@remix-run/router 0.0.0-experimental-9463fb5e → 0.0.0-experimental-8bb3ffdf
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 +181 -0
- package/dist/router.cjs.js +42 -47
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +0 -1
- package/dist/router.js +42 -45
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +42 -47
- 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/package.json +1 -1
- package/router.ts +49 -60
package/dist/router.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v0.0.0-experimental-
|
|
2
|
+
* @remix-run/router v0.0.0-experimental-8bb3ffdf
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -1717,18 +1717,28 @@
|
|
|
1717
1717
|
[route.id]: error
|
|
1718
1718
|
};
|
|
1719
1719
|
}
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1720
|
+
let initialized;
|
|
1721
|
+
let hasLazyRoutes = initialMatches.some(m => m.route.lazy);
|
|
1722
|
+
let hasLoaders = initialMatches.some(m => m.route.loader);
|
|
1723
|
+
if (hasLazyRoutes) {
|
|
1724
|
+
// All initialMatches need to be loaded before we're ready. If we have lazy
|
|
1725
|
+
// functions around still then we'll need to run them in initialize()
|
|
1726
|
+
initialized = false;
|
|
1727
|
+
} else if (!hasLoaders) {
|
|
1728
|
+
// If we've got no loaders to run, then we're good to go
|
|
1729
|
+
initialized = true;
|
|
1730
|
+
} else if (future.v7_partialHydration) {
|
|
1731
|
+
// If partial hydration is enabled, we're initialized so long as we were
|
|
1732
|
+
// provided with hydrationData for every route with a loader, and no loaders
|
|
1733
|
+
// were marked for explicit hydration
|
|
1734
|
+
let loaderData = init.hydrationData ? init.hydrationData.loaderData : null;
|
|
1735
|
+
let errors = init.hydrationData ? init.hydrationData.errors : null;
|
|
1736
|
+
initialized = initialMatches.every(m => m.route.loader && m.route.loader.hydrate !== true && (loaderData && loaderData[m.route.id] !== undefined || errors && errors[m.route.id] !== undefined));
|
|
1737
|
+
} else {
|
|
1738
|
+
// Without partial hydration - we're initialized if we were provided any
|
|
1739
|
+
// hydrationData - which is expected to be complete
|
|
1740
|
+
initialized = init.hydrationData != null;
|
|
1741
|
+
}
|
|
1732
1742
|
let router;
|
|
1733
1743
|
let state = {
|
|
1734
1744
|
historyAction: init.history.action,
|
|
@@ -1895,7 +1905,7 @@
|
|
|
1895
1905
|
// in the normal navigation flow. For SSR it's expected that lazy modules are
|
|
1896
1906
|
// resolved prior to router creation since we can't go into a fallbackElement
|
|
1897
1907
|
// UI for SSR'd apps
|
|
1898
|
-
if (!state.initialized
|
|
1908
|
+
if (!state.initialized) {
|
|
1899
1909
|
startNavigation(Action.Pop, state.location, {
|
|
1900
1910
|
initialHydration: true
|
|
1901
1911
|
});
|
|
@@ -3267,8 +3277,7 @@
|
|
|
3267
3277
|
}
|
|
3268
3278
|
// Config driven behavior flags
|
|
3269
3279
|
let future = _extends({
|
|
3270
|
-
v7_relativeSplatPath: false
|
|
3271
|
-
v7_throwAbortReason: false
|
|
3280
|
+
v7_relativeSplatPath: false
|
|
3272
3281
|
}, opts ? opts.future : null);
|
|
3273
3282
|
let dataRoutes = convertRoutesToDataRoutes(routes, mapRouteProperties, undefined, manifest);
|
|
3274
3283
|
|
|
@@ -3491,7 +3500,8 @@
|
|
|
3491
3500
|
requestContext
|
|
3492
3501
|
});
|
|
3493
3502
|
if (request.signal.aborted) {
|
|
3494
|
-
|
|
3503
|
+
let method = isRouteRequest ? "queryRoute" : "query";
|
|
3504
|
+
throw new Error(method + "() call aborted: " + request.method + " " + request.url);
|
|
3495
3505
|
}
|
|
3496
3506
|
}
|
|
3497
3507
|
if (isRedirectResult(result)) {
|
|
@@ -3609,7 +3619,8 @@
|
|
|
3609
3619
|
requestContext
|
|
3610
3620
|
}))]);
|
|
3611
3621
|
if (request.signal.aborted) {
|
|
3612
|
-
|
|
3622
|
+
let method = isRouteRequest ? "queryRoute" : "query";
|
|
3623
|
+
throw new Error(method + "() call aborted: " + request.method + " " + request.url);
|
|
3613
3624
|
}
|
|
3614
3625
|
|
|
3615
3626
|
// Process and commit output from loaders
|
|
@@ -3654,14 +3665,6 @@
|
|
|
3654
3665
|
});
|
|
3655
3666
|
return newContext;
|
|
3656
3667
|
}
|
|
3657
|
-
function throwStaticHandlerAbortedError(request, isRouteRequest, future) {
|
|
3658
|
-
let method = isRouteRequest ? "queryRoute" : "query";
|
|
3659
|
-
if (future.v7_throwAbortReason && request.signal.reason !== undefined) {
|
|
3660
|
-
throw request.signal.reason;
|
|
3661
|
-
} else {
|
|
3662
|
-
throw new Error(method + "() call aborted: " + request.method + " " + request.url);
|
|
3663
|
-
}
|
|
3664
|
-
}
|
|
3665
3668
|
function isSubmissionNavigation(opts) {
|
|
3666
3669
|
return opts != null && ("formData" in opts && opts.formData != null || "body" in opts && opts.body !== undefined);
|
|
3667
3670
|
}
|
|
@@ -3858,18 +3861,24 @@
|
|
|
3858
3861
|
let boundaryId = pendingError ? Object.keys(pendingError)[0] : undefined;
|
|
3859
3862
|
let boundaryMatches = getLoaderMatchesUntilBoundary(matches, boundaryId);
|
|
3860
3863
|
let navigationMatches = boundaryMatches.filter((match, index) => {
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
}
|
|
3866
|
-
if (match.route.lazy) {
|
|
3864
|
+
let {
|
|
3865
|
+
route
|
|
3866
|
+
} = match;
|
|
3867
|
+
if (route.lazy) {
|
|
3867
3868
|
// We haven't loaded this route yet so we don't know if it's got a loader!
|
|
3868
3869
|
return true;
|
|
3869
3870
|
}
|
|
3870
|
-
if (
|
|
3871
|
+
if (route.loader == null) {
|
|
3871
3872
|
return false;
|
|
3872
3873
|
}
|
|
3874
|
+
if (isInitialLoad) {
|
|
3875
|
+
if (route.loader.hydrate) {
|
|
3876
|
+
return true;
|
|
3877
|
+
}
|
|
3878
|
+
return state.loaderData[route.id] === undefined && (
|
|
3879
|
+
// Don't re-run if the loader ran and threw an error
|
|
3880
|
+
!state.errors || state.errors[route.id] === undefined);
|
|
3881
|
+
}
|
|
3873
3882
|
|
|
3874
3883
|
// Always call the loader on new route instances and pending defer cancellations
|
|
3875
3884
|
if (isNewLoader(state.loaderData, state.matches[index], match) || cancelledDeferredRoutes.some(id => id === match.route.id)) {
|
|
@@ -3971,20 +3980,6 @@
|
|
|
3971
3980
|
});
|
|
3972
3981
|
return [navigationMatches, revalidatingFetchers];
|
|
3973
3982
|
}
|
|
3974
|
-
|
|
3975
|
-
// Is this route unhydrated (when v7_partialHydration=true) such that we need
|
|
3976
|
-
// to call it's loader on the initial router creation
|
|
3977
|
-
function isUnhydratedRoute(state, route) {
|
|
3978
|
-
if (!route.loader) {
|
|
3979
|
-
return false;
|
|
3980
|
-
}
|
|
3981
|
-
if (route.loader.hydrate) {
|
|
3982
|
-
return true;
|
|
3983
|
-
}
|
|
3984
|
-
return state.loaderData[route.id] === undefined && (!state.errors ||
|
|
3985
|
-
// Loader ran but errored - don't re-run
|
|
3986
|
-
state.errors[route.id] === undefined);
|
|
3987
|
-
}
|
|
3988
3983
|
function isNewLoader(currentLoaderData, currentMatch, match) {
|
|
3989
3984
|
let isNew =
|
|
3990
3985
|
// [a] -> [a, b]
|