@remix-run/router 1.8.0-pre.0 → 1.9.0-pre.0
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 +15 -1
- package/dist/index.d.ts +4 -4
- package/dist/router.cjs.js +48 -37
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +1 -4
- package/dist/router.js +41 -37
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +48 -37
- 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 +22 -17
- package/index.ts +6 -4
- package/package.json +1 -1
- package/router.ts +58 -56
- package/utils.ts +28 -18
package/dist/router.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v1.
|
|
2
|
+
* @remix-run/router v1.9.0-pre.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -629,6 +629,10 @@
|
|
|
629
629
|
* Route action function signature
|
|
630
630
|
*/
|
|
631
631
|
|
|
632
|
+
/**
|
|
633
|
+
* Arguments passed to shouldRevalidate function
|
|
634
|
+
*/
|
|
635
|
+
|
|
632
636
|
/**
|
|
633
637
|
* Route shouldRevalidate function signature. This runs after any submission
|
|
634
638
|
* (navigation or fetcher), so we flatten the navigation/fetcher submission
|
|
@@ -1467,7 +1471,7 @@
|
|
|
1467
1471
|
* @private
|
|
1468
1472
|
* Utility class we use to hold auto-unwrapped 4xx/5xx Response bodies
|
|
1469
1473
|
*/
|
|
1470
|
-
class
|
|
1474
|
+
class ErrorResponseImpl {
|
|
1471
1475
|
constructor(status, statusText, data, internal) {
|
|
1472
1476
|
if (internal === void 0) {
|
|
1473
1477
|
internal = false;
|
|
@@ -1484,6 +1488,9 @@
|
|
|
1484
1488
|
}
|
|
1485
1489
|
}
|
|
1486
1490
|
|
|
1491
|
+
// We don't want the class exported since usage of it at runtime is an
|
|
1492
|
+
// implementation detail, but we do want to export the shape so folks can
|
|
1493
|
+
// build their own abstractions around instances via isRouteErrorResponse()
|
|
1487
1494
|
/**
|
|
1488
1495
|
* Check if the given error is an ErrorResponse generated from a 4xx/5xx
|
|
1489
1496
|
* Response thrown from an action/loader
|
|
@@ -2468,8 +2475,7 @@
|
|
|
2468
2475
|
fetchers: new Map(state.fetchers)
|
|
2469
2476
|
});
|
|
2470
2477
|
return startRedirectNavigation(state, actionResult, {
|
|
2471
|
-
submission
|
|
2472
|
-
isFetchActionRedirect: true
|
|
2478
|
+
fetcherSubmission: submission
|
|
2473
2479
|
});
|
|
2474
2480
|
}
|
|
2475
2481
|
}
|
|
@@ -2684,18 +2690,15 @@
|
|
|
2684
2690
|
async function startRedirectNavigation(state, redirect, _temp) {
|
|
2685
2691
|
let {
|
|
2686
2692
|
submission,
|
|
2687
|
-
|
|
2688
|
-
|
|
2693
|
+
fetcherSubmission,
|
|
2694
|
+
replace
|
|
2689
2695
|
} = _temp === void 0 ? {} : _temp;
|
|
2690
2696
|
if (redirect.revalidate) {
|
|
2691
2697
|
isRevalidationRequired = true;
|
|
2692
2698
|
}
|
|
2693
|
-
let redirectLocation = createLocation(state.location, redirect.location,
|
|
2694
|
-
_extends({
|
|
2699
|
+
let redirectLocation = createLocation(state.location, redirect.location, {
|
|
2695
2700
|
_isRedirect: true
|
|
2696
|
-
}
|
|
2697
|
-
_isFetchActionRedirect: true
|
|
2698
|
-
} : {}));
|
|
2701
|
+
});
|
|
2699
2702
|
invariant(redirectLocation, "Expected a location on the redirect navigation");
|
|
2700
2703
|
if (isBrowser) {
|
|
2701
2704
|
let isDocumentReload = false;
|
|
@@ -2727,11 +2730,19 @@
|
|
|
2727
2730
|
|
|
2728
2731
|
// Use the incoming submission if provided, fallback on the active one in
|
|
2729
2732
|
// state.navigation
|
|
2730
|
-
let
|
|
2733
|
+
let {
|
|
2734
|
+
formMethod,
|
|
2735
|
+
formAction,
|
|
2736
|
+
formEncType
|
|
2737
|
+
} = state.navigation;
|
|
2738
|
+
if (!submission && !fetcherSubmission && formMethod && formAction && formEncType) {
|
|
2739
|
+
submission = getSubmissionFromNavigation(state.navigation);
|
|
2740
|
+
}
|
|
2731
2741
|
|
|
2732
2742
|
// If this was a 307/308 submission we want to preserve the HTTP method and
|
|
2733
2743
|
// re-submit the GET/POST/PUT/PATCH/DELETE as a submission navigation to the
|
|
2734
2744
|
// redirected location
|
|
2745
|
+
let activeSubmission = submission || fetcherSubmission;
|
|
2735
2746
|
if (redirectPreserveMethodStatusCodes.has(redirect.status) && activeSubmission && isMutationMethod(activeSubmission.formMethod)) {
|
|
2736
2747
|
await startNavigation(redirectHistoryAction, redirectLocation, {
|
|
2737
2748
|
submission: _extends({}, activeSubmission, {
|
|
@@ -2740,20 +2751,14 @@
|
|
|
2740
2751
|
// Preserve this flag across redirects
|
|
2741
2752
|
preventScrollReset: pendingPreventScrollReset
|
|
2742
2753
|
});
|
|
2743
|
-
} else if (isFetchActionRedirect) {
|
|
2744
|
-
// For a fetch action redirect, we kick off a new loading navigation
|
|
2745
|
-
// without the fetcher submission, but we send it along for shouldRevalidate
|
|
2746
|
-
await startNavigation(redirectHistoryAction, redirectLocation, {
|
|
2747
|
-
overrideNavigation: getLoadingNavigation(redirectLocation),
|
|
2748
|
-
fetcherSubmission: activeSubmission,
|
|
2749
|
-
// Preserve this flag across redirects
|
|
2750
|
-
preventScrollReset: pendingPreventScrollReset
|
|
2751
|
-
});
|
|
2752
2754
|
} else {
|
|
2753
|
-
// If we have a submission, we will preserve it through the
|
|
2754
|
-
|
|
2755
|
+
// If we have a navigation submission, we will preserve it through the
|
|
2756
|
+
// redirect navigation
|
|
2757
|
+
let overrideNavigation = getLoadingNavigation(redirectLocation, submission);
|
|
2755
2758
|
await startNavigation(redirectHistoryAction, redirectLocation, {
|
|
2756
2759
|
overrideNavigation,
|
|
2760
|
+
// Send fetcher submissions through for shouldRevalidate
|
|
2761
|
+
fetcherSubmission,
|
|
2757
2762
|
// Preserve this flag across redirects
|
|
2758
2763
|
preventScrollReset: pendingPreventScrollReset
|
|
2759
2764
|
});
|
|
@@ -3272,7 +3277,7 @@
|
|
|
3272
3277
|
});
|
|
3273
3278
|
if (request.signal.aborted) {
|
|
3274
3279
|
let method = isRouteRequest ? "queryRoute" : "query";
|
|
3275
|
-
throw new Error(method + "() call aborted");
|
|
3280
|
+
throw new Error(method + "() call aborted: " + request.method + " " + request.url);
|
|
3276
3281
|
}
|
|
3277
3282
|
}
|
|
3278
3283
|
if (isRedirectResult(result)) {
|
|
@@ -3391,7 +3396,7 @@
|
|
|
3391
3396
|
}))]);
|
|
3392
3397
|
if (request.signal.aborted) {
|
|
3393
3398
|
let method = isRouteRequest ? "queryRoute" : "query";
|
|
3394
|
-
throw new Error(method + "() call aborted");
|
|
3399
|
+
throw new Error(method + "() call aborted: " + request.method + " " + request.url);
|
|
3395
3400
|
}
|
|
3396
3401
|
|
|
3397
3402
|
// Process and commit output from loaders
|
|
@@ -3848,7 +3853,17 @@
|
|
|
3848
3853
|
if (match.route.lazy) {
|
|
3849
3854
|
if (handler) {
|
|
3850
3855
|
// Run statically defined handler in parallel with lazy()
|
|
3851
|
-
let
|
|
3856
|
+
let handlerError;
|
|
3857
|
+
let values = await Promise.all([
|
|
3858
|
+
// If the handler throws, don't let it immediately bubble out,
|
|
3859
|
+
// since we need to let the lazy() execution finish so we know if this
|
|
3860
|
+
// route has a boundary that can handle the error
|
|
3861
|
+
runHandler(handler).catch(e => {
|
|
3862
|
+
handlerError = e;
|
|
3863
|
+
}), loadLazyRouteModule(match.route, mapRouteProperties, manifest)]);
|
|
3864
|
+
if (handlerError) {
|
|
3865
|
+
throw handlerError;
|
|
3866
|
+
}
|
|
3852
3867
|
result = values[0];
|
|
3853
3868
|
} else {
|
|
3854
3869
|
// Load lazy route module, then run any returned handler
|
|
@@ -3956,7 +3971,7 @@
|
|
|
3956
3971
|
if (resultType === ResultType.error) {
|
|
3957
3972
|
return {
|
|
3958
3973
|
type: resultType,
|
|
3959
|
-
error: new
|
|
3974
|
+
error: new ErrorResponseImpl(status, result.statusText, data),
|
|
3960
3975
|
headers: result.headers
|
|
3961
3976
|
};
|
|
3962
3977
|
}
|
|
@@ -4235,7 +4250,7 @@
|
|
|
4235
4250
|
errorMessage = "Invalid request method \"" + method.toUpperCase() + "\"";
|
|
4236
4251
|
}
|
|
4237
4252
|
}
|
|
4238
|
-
return new
|
|
4253
|
+
return new ErrorResponseImpl(status || 500, statusText, new Error(errorMessage), true);
|
|
4239
4254
|
}
|
|
4240
4255
|
|
|
4241
4256
|
// Find any returned redirect errors, starting from the lowest match
|
|
@@ -4483,8 +4498,7 @@
|
|
|
4483
4498
|
formData: submission.formData,
|
|
4484
4499
|
json: submission.json,
|
|
4485
4500
|
text: submission.text,
|
|
4486
|
-
data
|
|
4487
|
-
" _hasFetcherDoneAnything ": true
|
|
4501
|
+
data
|
|
4488
4502
|
};
|
|
4489
4503
|
return fetcher;
|
|
4490
4504
|
} else {
|
|
@@ -4496,8 +4510,7 @@
|
|
|
4496
4510
|
formData: undefined,
|
|
4497
4511
|
json: undefined,
|
|
4498
4512
|
text: undefined,
|
|
4499
|
-
data
|
|
4500
|
-
" _hasFetcherDoneAnything ": true
|
|
4513
|
+
data
|
|
4501
4514
|
};
|
|
4502
4515
|
return fetcher;
|
|
4503
4516
|
}
|
|
@@ -4511,8 +4524,7 @@
|
|
|
4511
4524
|
formData: submission.formData,
|
|
4512
4525
|
json: submission.json,
|
|
4513
4526
|
text: submission.text,
|
|
4514
|
-
data: existingFetcher ? existingFetcher.data : undefined
|
|
4515
|
-
" _hasFetcherDoneAnything ": true
|
|
4527
|
+
data: existingFetcher ? existingFetcher.data : undefined
|
|
4516
4528
|
};
|
|
4517
4529
|
return fetcher;
|
|
4518
4530
|
}
|
|
@@ -4525,8 +4537,7 @@
|
|
|
4525
4537
|
formData: undefined,
|
|
4526
4538
|
json: undefined,
|
|
4527
4539
|
text: undefined,
|
|
4528
|
-
data
|
|
4529
|
-
" _hasFetcherDoneAnything ": true
|
|
4540
|
+
data
|
|
4530
4541
|
};
|
|
4531
4542
|
return fetcher;
|
|
4532
4543
|
}
|
|
@@ -4534,12 +4545,12 @@
|
|
|
4534
4545
|
|
|
4535
4546
|
exports.AbortedDeferredError = AbortedDeferredError;
|
|
4536
4547
|
exports.Action = Action;
|
|
4537
|
-
exports.ErrorResponse = ErrorResponse;
|
|
4538
4548
|
exports.IDLE_BLOCKER = IDLE_BLOCKER;
|
|
4539
4549
|
exports.IDLE_FETCHER = IDLE_FETCHER;
|
|
4540
4550
|
exports.IDLE_NAVIGATION = IDLE_NAVIGATION;
|
|
4541
4551
|
exports.UNSAFE_DEFERRED_SYMBOL = UNSAFE_DEFERRED_SYMBOL;
|
|
4542
4552
|
exports.UNSAFE_DeferredData = DeferredData;
|
|
4553
|
+
exports.UNSAFE_ErrorResponseImpl = ErrorResponseImpl;
|
|
4543
4554
|
exports.UNSAFE_convertRoutesToDataRoutes = convertRoutesToDataRoutes;
|
|
4544
4555
|
exports.UNSAFE_getPathContributingMatches = getPathContributingMatches;
|
|
4545
4556
|
exports.UNSAFE_invariant = invariant;
|