@remix-run/router 0.0.0-experimental-3ec205f42 → 0.0.0-experimental-73fcb9b28
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/dist/router.cjs.js +21 -51
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +4 -12
- package/dist/router.js +21 -50
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +21 -51
- 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 +18 -60
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-73fcb9b28
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -1880,7 +1880,6 @@ function createRouter(init) {
|
|
|
1880
1880
|
|
|
1881
1881
|
// AbortControllers for any in-flight fetchers
|
|
1882
1882
|
let fetchControllers = new Map();
|
|
1883
|
-
let landedFetcherControllers = new Map();
|
|
1884
1883
|
|
|
1885
1884
|
// Track loads based on the order in which they started
|
|
1886
1885
|
let incrementingLoadId = 0;
|
|
@@ -2055,11 +2054,10 @@ function createRouter(init) {
|
|
|
2055
2054
|
// Iterate over a local copy so that if flushSync is used and we end up
|
|
2056
2055
|
// removing and adding a new subscriber due to the useCallback dependencies,
|
|
2057
2056
|
// we don't get ourselves into a loop calling the new subscriber immediately
|
|
2058
|
-
debugger;
|
|
2059
2057
|
[...subscribers].forEach(subscriber => subscriber(state, {
|
|
2060
2058
|
deletedFetchers: deletedFetchersKeys,
|
|
2061
|
-
|
|
2062
|
-
|
|
2059
|
+
viewTransitionOpts: opts.viewTransitionOpts,
|
|
2060
|
+
flushSync: opts.flushSync === true
|
|
2063
2061
|
}));
|
|
2064
2062
|
|
|
2065
2063
|
// Remove idle fetchers from state since we only care about in-flight fetchers.
|
|
@@ -2219,7 +2217,7 @@ function createRouter(init) {
|
|
|
2219
2217
|
historyAction = Action.Replace;
|
|
2220
2218
|
}
|
|
2221
2219
|
let preventScrollReset = opts && "preventScrollReset" in opts ? opts.preventScrollReset === true : undefined;
|
|
2222
|
-
let flushSync = (opts && opts.
|
|
2220
|
+
let flushSync = (opts && opts.flushSync) === true;
|
|
2223
2221
|
let blockerKey = shouldBlockNavigation({
|
|
2224
2222
|
currentLocation,
|
|
2225
2223
|
nextLocation,
|
|
@@ -2257,7 +2255,7 @@ function createRouter(init) {
|
|
|
2257
2255
|
pendingError: error,
|
|
2258
2256
|
preventScrollReset,
|
|
2259
2257
|
replace: opts && opts.replace,
|
|
2260
|
-
enableViewTransition: opts && opts.
|
|
2258
|
+
enableViewTransition: opts && opts.viewTransition,
|
|
2261
2259
|
flushSync
|
|
2262
2260
|
});
|
|
2263
2261
|
}
|
|
@@ -2696,7 +2694,7 @@ function createRouter(init) {
|
|
|
2696
2694
|
if (pendingNavigationController) {
|
|
2697
2695
|
pendingNavigationController.signal.removeEventListener("abort", abortPendingFetchRevalidations);
|
|
2698
2696
|
}
|
|
2699
|
-
revalidatingFetchers.forEach(rf =>
|
|
2697
|
+
revalidatingFetchers.forEach(rf => fetchControllers.delete(rf.key));
|
|
2700
2698
|
|
|
2701
2699
|
// If any loaders returned a redirect Response, start a new REPLACE navigation
|
|
2702
2700
|
let redirect = findRedirect(loaderResults);
|
|
@@ -2794,7 +2792,7 @@ function createRouter(init) {
|
|
|
2794
2792
|
throw new Error("router.fetch() was called during the server render, but it shouldn't be. " + "You are likely calling a useFetcher() method in the body of your component. " + "Try moving it to a useEffect or a callback.");
|
|
2795
2793
|
}
|
|
2796
2794
|
if (fetchControllers.has(key)) abortFetcher(key);
|
|
2797
|
-
let flushSync = (opts && opts.
|
|
2795
|
+
let flushSync = (opts && opts.flushSync) === true;
|
|
2798
2796
|
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
2799
2797
|
let normalizedPath = normalizeTo(state.location, state.matches, basename, future.v7_prependBasename, href, future.v7_relativeSplatPath, routeId, opts == null ? void 0 : opts.relative);
|
|
2800
2798
|
let matches = matchRoutes(routesToUse, normalizedPath, basename);
|
|
@@ -2902,9 +2900,9 @@ function createRouter(init) {
|
|
|
2902
2900
|
let actionResult = actionResults[match.route.id];
|
|
2903
2901
|
if (fetchRequest.signal.aborted) {
|
|
2904
2902
|
// We can delete this so long as we weren't aborted by our own fetcher
|
|
2905
|
-
// re-submit which would have put
|
|
2903
|
+
// re-submit which would have put _new_ controller is in fetchControllers
|
|
2906
2904
|
if (fetchControllers.get(key) === abortController) {
|
|
2907
|
-
|
|
2905
|
+
fetchControllers.delete(key);
|
|
2908
2906
|
}
|
|
2909
2907
|
return;
|
|
2910
2908
|
}
|
|
@@ -2920,7 +2918,7 @@ function createRouter(init) {
|
|
|
2920
2918
|
// Let SuccessResult's fall through for revalidation
|
|
2921
2919
|
} else {
|
|
2922
2920
|
if (isRedirectResult(actionResult)) {
|
|
2923
|
-
|
|
2921
|
+
fetchControllers.delete(key);
|
|
2924
2922
|
if (pendingNavigationLoadId > originatingLoadId) {
|
|
2925
2923
|
// A new navigation was kicked off after our action started, so that
|
|
2926
2924
|
// should take precedence over this redirect navigation. We already
|
|
@@ -2991,8 +2989,8 @@ function createRouter(init) {
|
|
|
2991
2989
|
}
|
|
2992
2990
|
abortController.signal.removeEventListener("abort", abortPendingFetchRevalidations);
|
|
2993
2991
|
fetchReloadIds.delete(key);
|
|
2994
|
-
|
|
2995
|
-
revalidatingFetchers.forEach(r =>
|
|
2992
|
+
fetchControllers.delete(key);
|
|
2993
|
+
revalidatingFetchers.forEach(r => fetchControllers.delete(r.key));
|
|
2996
2994
|
let redirect = findRedirect(loaderResults);
|
|
2997
2995
|
if (redirect) {
|
|
2998
2996
|
return startRedirectNavigation(revalidationRequest, redirect.result, false);
|
|
@@ -3095,7 +3093,7 @@ function createRouter(init) {
|
|
|
3095
3093
|
// We can delete this so long as we weren't aborted by our our own fetcher
|
|
3096
3094
|
// re-load which would have put _new_ controller is in fetchControllers
|
|
3097
3095
|
if (fetchControllers.get(key) === abortController) {
|
|
3098
|
-
|
|
3096
|
+
fetchControllers.delete(key);
|
|
3099
3097
|
}
|
|
3100
3098
|
if (fetchRequest.signal.aborted) {
|
|
3101
3099
|
return;
|
|
@@ -3324,21 +3322,6 @@ function createRouter(init) {
|
|
|
3324
3322
|
flushSync: (opts && opts.flushSync) === true
|
|
3325
3323
|
});
|
|
3326
3324
|
}
|
|
3327
|
-
|
|
3328
|
-
// When a fetcher "lands" (i.e., the loader/action resolves) we remove the
|
|
3329
|
-
// `AbortController` from `fetchControllers` which indicates in-flight fetchers.
|
|
3330
|
-
// But because those loaders/actions could still be streaming data via Promises,
|
|
3331
|
-
// we need to hang onto the `AbortController` so we can still abort the fetcher
|
|
3332
|
-
// during subsequent streaming.
|
|
3333
|
-
function markFetcherAsLanded(key) {
|
|
3334
|
-
// Move this controller to landedFetcherControllers so we can still abort
|
|
3335
|
-
// while data is being subsequently streamed down
|
|
3336
|
-
let controller = fetchControllers.get(key);
|
|
3337
|
-
if (controller) {
|
|
3338
|
-
landedFetcherControllers.set(key, controller);
|
|
3339
|
-
}
|
|
3340
|
-
fetchControllers.delete(key);
|
|
3341
|
-
}
|
|
3342
3325
|
function setFetcherError(key, routeId, error, opts) {
|
|
3343
3326
|
if (opts === void 0) {
|
|
3344
3327
|
opts = {};
|
|
@@ -3373,7 +3356,6 @@ function createRouter(init) {
|
|
|
3373
3356
|
if (fetchControllers.has(key) && !(fetcher && fetcher.state === "loading" && fetchReloadIds.has(key))) {
|
|
3374
3357
|
abortFetcher(key);
|
|
3375
3358
|
}
|
|
3376
|
-
landedFetcherControllers.delete(key);
|
|
3377
3359
|
fetchLoadMatches.delete(key);
|
|
3378
3360
|
fetchReloadIds.delete(key);
|
|
3379
3361
|
fetchRedirectIds.delete(key);
|
|
@@ -3397,10 +3379,10 @@ function createRouter(init) {
|
|
|
3397
3379
|
fetchers: new Map(state.fetchers)
|
|
3398
3380
|
});
|
|
3399
3381
|
}
|
|
3400
|
-
function abortFetcher(key
|
|
3382
|
+
function abortFetcher(key) {
|
|
3401
3383
|
let controller = fetchControllers.get(key);
|
|
3402
3384
|
invariant(controller, "Expected fetch controller: " + key);
|
|
3403
|
-
controller.abort(
|
|
3385
|
+
controller.abort();
|
|
3404
3386
|
fetchControllers.delete(key);
|
|
3405
3387
|
}
|
|
3406
3388
|
function markFetchersDone(keys) {
|
|
@@ -3712,18 +3694,6 @@ function createRouter(init) {
|
|
|
3712
3694
|
encodeLocation: to => init.history.encodeLocation(to),
|
|
3713
3695
|
getFetcher,
|
|
3714
3696
|
deleteFetcher: deleteFetcherAndUpdateState,
|
|
3715
|
-
abortFetcher(key, _temp3) {
|
|
3716
|
-
let {
|
|
3717
|
-
reason,
|
|
3718
|
-
data
|
|
3719
|
-
} = _temp3 === void 0 ? {} : _temp3;
|
|
3720
|
-
if (fetchControllers.has(key)) {
|
|
3721
|
-
abortFetcher(key, reason);
|
|
3722
|
-
} else if (landedFetcherControllers.has(key)) {
|
|
3723
|
-
landedFetcherControllers.get(key).abort(reason);
|
|
3724
|
-
}
|
|
3725
|
-
updateFetcherState(key, getDoneFetcher(typeof data === "undefined" ? null : data));
|
|
3726
|
-
},
|
|
3727
3697
|
dispose,
|
|
3728
3698
|
getBlocker,
|
|
3729
3699
|
deleteBlocker,
|
|
@@ -3797,12 +3767,12 @@ function createStaticHandler(routes, opts) {
|
|
|
3797
3767
|
* where the client will handle the bubbling and we may need to return data
|
|
3798
3768
|
* for the handling route
|
|
3799
3769
|
*/
|
|
3800
|
-
async function query(request,
|
|
3770
|
+
async function query(request, _temp3) {
|
|
3801
3771
|
let {
|
|
3802
3772
|
requestContext,
|
|
3803
3773
|
skipLoaderErrorBubbling,
|
|
3804
3774
|
dataStrategy
|
|
3805
|
-
} =
|
|
3775
|
+
} = _temp3 === void 0 ? {} : _temp3;
|
|
3806
3776
|
let url = new URL(request.url);
|
|
3807
3777
|
let method = request.method;
|
|
3808
3778
|
let location = createLocation("", createPath(url), null, "default");
|
|
@@ -3894,12 +3864,12 @@ function createStaticHandler(routes, opts) {
|
|
|
3894
3864
|
* - `opts.requestContext` is an optional server context that will be passed
|
|
3895
3865
|
* to actions/loaders in the `context` parameter
|
|
3896
3866
|
*/
|
|
3897
|
-
async function queryRoute(request,
|
|
3867
|
+
async function queryRoute(request, _temp4) {
|
|
3898
3868
|
let {
|
|
3899
3869
|
routeId,
|
|
3900
3870
|
requestContext,
|
|
3901
3871
|
dataStrategy
|
|
3902
|
-
} =
|
|
3872
|
+
} = _temp4 === void 0 ? {} : _temp4;
|
|
3903
3873
|
let url = new URL(request.url);
|
|
3904
3874
|
let method = request.method;
|
|
3905
3875
|
let location = createLocation("", createPath(url), null, "default");
|
|
@@ -5174,14 +5144,14 @@ function getShortCircuitMatches(routes) {
|
|
|
5174
5144
|
route
|
|
5175
5145
|
};
|
|
5176
5146
|
}
|
|
5177
|
-
function getInternalRouterError(status,
|
|
5147
|
+
function getInternalRouterError(status, _temp5) {
|
|
5178
5148
|
let {
|
|
5179
5149
|
pathname,
|
|
5180
5150
|
routeId,
|
|
5181
5151
|
method,
|
|
5182
5152
|
type,
|
|
5183
5153
|
message
|
|
5184
|
-
} =
|
|
5154
|
+
} = _temp5 === void 0 ? {} : _temp5;
|
|
5185
5155
|
let statusText = "Unknown Server Error";
|
|
5186
5156
|
let errorMessage = "Unknown @remix-run/router error";
|
|
5187
5157
|
if (status === 400) {
|