@remix-run/router 1.2.0-pre.0 → 1.2.1-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 +8 -2
- package/dist/router.cjs.js +60 -27
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.js +60 -27
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +60 -27
- 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 +50 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# `@remix-run/router`
|
|
2
2
|
|
|
3
|
-
## 1.2.
|
|
3
|
+
## 1.2.1-pre.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Include submission info in `shouldRevalidate` on action redirects ([#9777](https://github.com/remix-run/react-router/pull/9777))
|
|
8
|
+
|
|
9
|
+
## 1.2.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
6
12
|
|
|
@@ -11,7 +17,7 @@
|
|
|
11
17
|
- Fix explicit `replace` on submissions and `PUSH` on submission to new paths ([#9734](https://github.com/remix-run/react-router/pull/9734))
|
|
12
18
|
- Fix a few bugs where loader/action data wasn't properly cleared on errors ([#9735](https://github.com/remix-run/react-router/pull/9735))
|
|
13
19
|
- Prevent `useLoaderData` usage in `errorElement` ([#9735](https://github.com/remix-run/react-router/pull/9735))
|
|
14
|
-
- Skip initial scroll restoration for SSR apps with hydrationData ([#9664](https://github.com/remix-run/react-router/pull/9664))
|
|
20
|
+
- Skip initial scroll restoration for SSR apps with `hydrationData` ([#9664](https://github.com/remix-run/react-router/pull/9664))
|
|
15
21
|
|
|
16
22
|
## 1.1.0
|
|
17
23
|
|
package/dist/router.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v1.2.
|
|
2
|
+
* @remix-run/router v1.2.1-pre.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -1839,7 +1839,10 @@ function createRouter(init) {
|
|
|
1839
1839
|
replace = result.location === state.location.pathname + state.location.search;
|
|
1840
1840
|
}
|
|
1841
1841
|
|
|
1842
|
-
await startRedirectNavigation(state, result,
|
|
1842
|
+
await startRedirectNavigation(state, result, {
|
|
1843
|
+
submission,
|
|
1844
|
+
replace
|
|
1845
|
+
});
|
|
1843
1846
|
return {
|
|
1844
1847
|
shortCircuited: true
|
|
1845
1848
|
};
|
|
@@ -1894,9 +1897,17 @@ function createRouter(init) {
|
|
|
1894
1897
|
}, submission);
|
|
1895
1898
|
|
|
1896
1899
|
loadingNavigation = navigation;
|
|
1897
|
-
}
|
|
1900
|
+
} // If this was a redirect from an action we don't have a "submission" but
|
|
1901
|
+
// we have it on the loading navigation so use that if available
|
|
1902
|
+
|
|
1898
1903
|
|
|
1899
|
-
let
|
|
1904
|
+
let activeSubmission = submission ? submission : loadingNavigation.formMethod && loadingNavigation.formAction && loadingNavigation.formData && loadingNavigation.formEncType ? {
|
|
1905
|
+
formMethod: loadingNavigation.formMethod,
|
|
1906
|
+
formAction: loadingNavigation.formAction,
|
|
1907
|
+
formData: loadingNavigation.formData,
|
|
1908
|
+
formEncType: loadingNavigation.formEncType
|
|
1909
|
+
} : undefined;
|
|
1910
|
+
let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(state, matches, activeSubmission, location, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, pendingActionData, pendingError, fetchLoadMatches); // Cancel pending deferreds for no-longer-matched routes or routes we're
|
|
1900
1911
|
// about to reload. Note that if this is an action reload we would have
|
|
1901
1912
|
// already cancelled all pending deferreds so this would be a no-op
|
|
1902
1913
|
|
|
@@ -1975,7 +1986,9 @@ function createRouter(init) {
|
|
|
1975
1986
|
let redirect = findRedirect(results);
|
|
1976
1987
|
|
|
1977
1988
|
if (redirect) {
|
|
1978
|
-
await startRedirectNavigation(state, redirect,
|
|
1989
|
+
await startRedirectNavigation(state, redirect, {
|
|
1990
|
+
replace
|
|
1991
|
+
});
|
|
1979
1992
|
return {
|
|
1980
1993
|
shortCircuited: true
|
|
1981
1994
|
};
|
|
@@ -2105,7 +2118,10 @@ function createRouter(init) {
|
|
|
2105
2118
|
updateState({
|
|
2106
2119
|
fetchers: new Map(state.fetchers)
|
|
2107
2120
|
});
|
|
2108
|
-
return startRedirectNavigation(state, actionResult,
|
|
2121
|
+
return startRedirectNavigation(state, actionResult, {
|
|
2122
|
+
submission,
|
|
2123
|
+
isFetchActionRedirect: true
|
|
2124
|
+
});
|
|
2109
2125
|
} // Process any non-redirect errors thrown
|
|
2110
2126
|
|
|
2111
2127
|
|
|
@@ -2182,7 +2198,9 @@ function createRouter(init) {
|
|
|
2182
2198
|
let redirect = findRedirect(results);
|
|
2183
2199
|
|
|
2184
2200
|
if (redirect) {
|
|
2185
|
-
return startRedirectNavigation(state, redirect
|
|
2201
|
+
return startRedirectNavigation(state, redirect, {
|
|
2202
|
+
submission
|
|
2203
|
+
});
|
|
2186
2204
|
} // Process and commit output from loaders
|
|
2187
2205
|
|
|
2188
2206
|
|
|
@@ -2328,9 +2346,15 @@ function createRouter(init) {
|
|
|
2328
2346
|
*/
|
|
2329
2347
|
|
|
2330
2348
|
|
|
2331
|
-
async function startRedirectNavigation(state, redirect,
|
|
2349
|
+
async function startRedirectNavigation(state, redirect, _temp) {
|
|
2332
2350
|
var _window;
|
|
2333
2351
|
|
|
2352
|
+
let {
|
|
2353
|
+
submission,
|
|
2354
|
+
replace,
|
|
2355
|
+
isFetchActionRedirect
|
|
2356
|
+
} = _temp === void 0 ? {} : _temp;
|
|
2357
|
+
|
|
2334
2358
|
if (redirect.revalidate) {
|
|
2335
2359
|
isRevalidationRequired = true;
|
|
2336
2360
|
}
|
|
@@ -2360,24 +2384,33 @@ function createRouter(init) {
|
|
|
2360
2384
|
|
|
2361
2385
|
|
|
2362
2386
|
pendingNavigationController = null;
|
|
2363
|
-
let redirectHistoryAction = replace === true ? exports.Action.Replace : exports.Action.Push;
|
|
2387
|
+
let redirectHistoryAction = replace === true ? exports.Action.Replace : exports.Action.Push; // Use the incoming submission if provided, fallback on the active one in
|
|
2388
|
+
// state.navigation
|
|
2389
|
+
|
|
2364
2390
|
let {
|
|
2365
2391
|
formMethod,
|
|
2366
2392
|
formAction,
|
|
2367
2393
|
formEncType,
|
|
2368
2394
|
formData
|
|
2369
|
-
} = state.navigation;
|
|
2395
|
+
} = state.navigation;
|
|
2396
|
+
|
|
2397
|
+
if (!submission && formMethod && formAction && formData && formEncType) {
|
|
2398
|
+
submission = {
|
|
2399
|
+
formMethod,
|
|
2400
|
+
formAction,
|
|
2401
|
+
formEncType,
|
|
2402
|
+
formData
|
|
2403
|
+
};
|
|
2404
|
+
} // If this was a 307/308 submission we want to preserve the HTTP method and
|
|
2370
2405
|
// re-submit the GET/POST/PUT/PATCH/DELETE as a submission navigation to the
|
|
2371
2406
|
// redirected location
|
|
2372
2407
|
|
|
2373
|
-
|
|
2408
|
+
|
|
2409
|
+
if (redirectPreserveMethodStatusCodes.has(redirect.status) && submission && isMutationMethod(submission.formMethod)) {
|
|
2374
2410
|
await startNavigation(redirectHistoryAction, redirectLocation, {
|
|
2375
|
-
submission: {
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
formEncType,
|
|
2379
|
-
formData
|
|
2380
|
-
}
|
|
2411
|
+
submission: _extends({}, submission, {
|
|
2412
|
+
formAction: redirect.location
|
|
2413
|
+
})
|
|
2381
2414
|
});
|
|
2382
2415
|
} else {
|
|
2383
2416
|
// Otherwise, we kick off a new loading navigation, preserving the
|
|
@@ -2386,10 +2419,10 @@ function createRouter(init) {
|
|
|
2386
2419
|
overrideNavigation: {
|
|
2387
2420
|
state: "loading",
|
|
2388
2421
|
location: redirectLocation,
|
|
2389
|
-
formMethod: formMethod
|
|
2390
|
-
formAction: formAction
|
|
2391
|
-
formEncType: formEncType
|
|
2392
|
-
formData: formData
|
|
2422
|
+
formMethod: submission ? submission.formMethod : undefined,
|
|
2423
|
+
formAction: submission ? submission.formAction : undefined,
|
|
2424
|
+
formEncType: submission ? submission.formEncType : undefined,
|
|
2425
|
+
formData: submission ? submission.formData : undefined
|
|
2393
2426
|
}
|
|
2394
2427
|
});
|
|
2395
2428
|
}
|
|
@@ -2634,10 +2667,10 @@ function createStaticHandler(routes, opts) {
|
|
|
2634
2667
|
* return it directly.
|
|
2635
2668
|
*/
|
|
2636
2669
|
|
|
2637
|
-
async function query(request,
|
|
2670
|
+
async function query(request, _temp2) {
|
|
2638
2671
|
let {
|
|
2639
2672
|
requestContext
|
|
2640
|
-
} =
|
|
2673
|
+
} = _temp2 === void 0 ? {} : _temp2;
|
|
2641
2674
|
let url = new URL(request.url);
|
|
2642
2675
|
let method = request.method.toLowerCase();
|
|
2643
2676
|
let location = createLocation("", createPath(url), null, "default");
|
|
@@ -2723,11 +2756,11 @@ function createStaticHandler(routes, opts) {
|
|
|
2723
2756
|
*/
|
|
2724
2757
|
|
|
2725
2758
|
|
|
2726
|
-
async function queryRoute(request,
|
|
2759
|
+
async function queryRoute(request, _temp3) {
|
|
2727
2760
|
let {
|
|
2728
2761
|
routeId,
|
|
2729
2762
|
requestContext
|
|
2730
|
-
} =
|
|
2763
|
+
} = _temp3 === void 0 ? {} : _temp3;
|
|
2731
2764
|
let url = new URL(request.url);
|
|
2732
2765
|
let method = request.method.toLowerCase();
|
|
2733
2766
|
let location = createLocation("", createPath(url), null, "default");
|
|
@@ -3508,12 +3541,12 @@ function getShortCircuitMatches(routes) {
|
|
|
3508
3541
|
};
|
|
3509
3542
|
}
|
|
3510
3543
|
|
|
3511
|
-
function getInternalRouterError(status,
|
|
3544
|
+
function getInternalRouterError(status, _temp4) {
|
|
3512
3545
|
let {
|
|
3513
3546
|
pathname,
|
|
3514
3547
|
routeId,
|
|
3515
3548
|
method
|
|
3516
|
-
} =
|
|
3549
|
+
} = _temp4 === void 0 ? {} : _temp4;
|
|
3517
3550
|
let statusText = "Unknown Server Error";
|
|
3518
3551
|
let errorMessage = "Unknown @remix-run/router error";
|
|
3519
3552
|
|