@remix-run/router 1.2.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 +6 -0
- 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/dist/router.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v1.2.0
|
|
2
|
+
* @remix-run/router v1.2.1-pre.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -1790,7 +1790,10 @@ function createRouter(init) {
|
|
|
1790
1790
|
replace = result.location === state.location.pathname + state.location.search;
|
|
1791
1791
|
}
|
|
1792
1792
|
|
|
1793
|
-
await startRedirectNavigation(state, result,
|
|
1793
|
+
await startRedirectNavigation(state, result, {
|
|
1794
|
+
submission,
|
|
1795
|
+
replace
|
|
1796
|
+
});
|
|
1794
1797
|
return {
|
|
1795
1798
|
shortCircuited: true
|
|
1796
1799
|
};
|
|
@@ -1845,9 +1848,17 @@ function createRouter(init) {
|
|
|
1845
1848
|
}, submission);
|
|
1846
1849
|
|
|
1847
1850
|
loadingNavigation = navigation;
|
|
1848
|
-
}
|
|
1851
|
+
} // If this was a redirect from an action we don't have a "submission" but
|
|
1852
|
+
// we have it on the loading navigation so use that if available
|
|
1853
|
+
|
|
1849
1854
|
|
|
1850
|
-
let
|
|
1855
|
+
let activeSubmission = submission ? submission : loadingNavigation.formMethod && loadingNavigation.formAction && loadingNavigation.formData && loadingNavigation.formEncType ? {
|
|
1856
|
+
formMethod: loadingNavigation.formMethod,
|
|
1857
|
+
formAction: loadingNavigation.formAction,
|
|
1858
|
+
formData: loadingNavigation.formData,
|
|
1859
|
+
formEncType: loadingNavigation.formEncType
|
|
1860
|
+
} : undefined;
|
|
1861
|
+
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
|
|
1851
1862
|
// about to reload. Note that if this is an action reload we would have
|
|
1852
1863
|
// already cancelled all pending deferreds so this would be a no-op
|
|
1853
1864
|
|
|
@@ -1926,7 +1937,9 @@ function createRouter(init) {
|
|
|
1926
1937
|
let redirect = findRedirect(results);
|
|
1927
1938
|
|
|
1928
1939
|
if (redirect) {
|
|
1929
|
-
await startRedirectNavigation(state, redirect,
|
|
1940
|
+
await startRedirectNavigation(state, redirect, {
|
|
1941
|
+
replace
|
|
1942
|
+
});
|
|
1930
1943
|
return {
|
|
1931
1944
|
shortCircuited: true
|
|
1932
1945
|
};
|
|
@@ -2056,7 +2069,10 @@ function createRouter(init) {
|
|
|
2056
2069
|
updateState({
|
|
2057
2070
|
fetchers: new Map(state.fetchers)
|
|
2058
2071
|
});
|
|
2059
|
-
return startRedirectNavigation(state, actionResult,
|
|
2072
|
+
return startRedirectNavigation(state, actionResult, {
|
|
2073
|
+
submission,
|
|
2074
|
+
isFetchActionRedirect: true
|
|
2075
|
+
});
|
|
2060
2076
|
} // Process any non-redirect errors thrown
|
|
2061
2077
|
|
|
2062
2078
|
|
|
@@ -2133,7 +2149,9 @@ function createRouter(init) {
|
|
|
2133
2149
|
let redirect = findRedirect(results);
|
|
2134
2150
|
|
|
2135
2151
|
if (redirect) {
|
|
2136
|
-
return startRedirectNavigation(state, redirect
|
|
2152
|
+
return startRedirectNavigation(state, redirect, {
|
|
2153
|
+
submission
|
|
2154
|
+
});
|
|
2137
2155
|
} // Process and commit output from loaders
|
|
2138
2156
|
|
|
2139
2157
|
|
|
@@ -2279,9 +2297,15 @@ function createRouter(init) {
|
|
|
2279
2297
|
*/
|
|
2280
2298
|
|
|
2281
2299
|
|
|
2282
|
-
async function startRedirectNavigation(state, redirect,
|
|
2300
|
+
async function startRedirectNavigation(state, redirect, _temp) {
|
|
2283
2301
|
var _window;
|
|
2284
2302
|
|
|
2303
|
+
let {
|
|
2304
|
+
submission,
|
|
2305
|
+
replace,
|
|
2306
|
+
isFetchActionRedirect
|
|
2307
|
+
} = _temp === void 0 ? {} : _temp;
|
|
2308
|
+
|
|
2285
2309
|
if (redirect.revalidate) {
|
|
2286
2310
|
isRevalidationRequired = true;
|
|
2287
2311
|
}
|
|
@@ -2311,24 +2335,33 @@ function createRouter(init) {
|
|
|
2311
2335
|
|
|
2312
2336
|
|
|
2313
2337
|
pendingNavigationController = null;
|
|
2314
|
-
let redirectHistoryAction = replace === true ? Action.Replace : Action.Push;
|
|
2338
|
+
let redirectHistoryAction = replace === true ? Action.Replace : Action.Push; // Use the incoming submission if provided, fallback on the active one in
|
|
2339
|
+
// state.navigation
|
|
2340
|
+
|
|
2315
2341
|
let {
|
|
2316
2342
|
formMethod,
|
|
2317
2343
|
formAction,
|
|
2318
2344
|
formEncType,
|
|
2319
2345
|
formData
|
|
2320
|
-
} = state.navigation;
|
|
2346
|
+
} = state.navigation;
|
|
2347
|
+
|
|
2348
|
+
if (!submission && formMethod && formAction && formData && formEncType) {
|
|
2349
|
+
submission = {
|
|
2350
|
+
formMethod,
|
|
2351
|
+
formAction,
|
|
2352
|
+
formEncType,
|
|
2353
|
+
formData
|
|
2354
|
+
};
|
|
2355
|
+
} // If this was a 307/308 submission we want to preserve the HTTP method and
|
|
2321
2356
|
// re-submit the GET/POST/PUT/PATCH/DELETE as a submission navigation to the
|
|
2322
2357
|
// redirected location
|
|
2323
2358
|
|
|
2324
|
-
|
|
2359
|
+
|
|
2360
|
+
if (redirectPreserveMethodStatusCodes.has(redirect.status) && submission && isMutationMethod(submission.formMethod)) {
|
|
2325
2361
|
await startNavigation(redirectHistoryAction, redirectLocation, {
|
|
2326
|
-
submission: {
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
formEncType,
|
|
2330
|
-
formData
|
|
2331
|
-
}
|
|
2362
|
+
submission: _extends({}, submission, {
|
|
2363
|
+
formAction: redirect.location
|
|
2364
|
+
})
|
|
2332
2365
|
});
|
|
2333
2366
|
} else {
|
|
2334
2367
|
// Otherwise, we kick off a new loading navigation, preserving the
|
|
@@ -2337,10 +2370,10 @@ function createRouter(init) {
|
|
|
2337
2370
|
overrideNavigation: {
|
|
2338
2371
|
state: "loading",
|
|
2339
2372
|
location: redirectLocation,
|
|
2340
|
-
formMethod: formMethod
|
|
2341
|
-
formAction: formAction
|
|
2342
|
-
formEncType: formEncType
|
|
2343
|
-
formData: formData
|
|
2373
|
+
formMethod: submission ? submission.formMethod : undefined,
|
|
2374
|
+
formAction: submission ? submission.formAction : undefined,
|
|
2375
|
+
formEncType: submission ? submission.formEncType : undefined,
|
|
2376
|
+
formData: submission ? submission.formData : undefined
|
|
2344
2377
|
}
|
|
2345
2378
|
});
|
|
2346
2379
|
}
|
|
@@ -2585,10 +2618,10 @@ function createStaticHandler(routes, opts) {
|
|
|
2585
2618
|
* return it directly.
|
|
2586
2619
|
*/
|
|
2587
2620
|
|
|
2588
|
-
async function query(request,
|
|
2621
|
+
async function query(request, _temp2) {
|
|
2589
2622
|
let {
|
|
2590
2623
|
requestContext
|
|
2591
|
-
} =
|
|
2624
|
+
} = _temp2 === void 0 ? {} : _temp2;
|
|
2592
2625
|
let url = new URL(request.url);
|
|
2593
2626
|
let method = request.method.toLowerCase();
|
|
2594
2627
|
let location = createLocation("", createPath(url), null, "default");
|
|
@@ -2674,11 +2707,11 @@ function createStaticHandler(routes, opts) {
|
|
|
2674
2707
|
*/
|
|
2675
2708
|
|
|
2676
2709
|
|
|
2677
|
-
async function queryRoute(request,
|
|
2710
|
+
async function queryRoute(request, _temp3) {
|
|
2678
2711
|
let {
|
|
2679
2712
|
routeId,
|
|
2680
2713
|
requestContext
|
|
2681
|
-
} =
|
|
2714
|
+
} = _temp3 === void 0 ? {} : _temp3;
|
|
2682
2715
|
let url = new URL(request.url);
|
|
2683
2716
|
let method = request.method.toLowerCase();
|
|
2684
2717
|
let location = createLocation("", createPath(url), null, "default");
|
|
@@ -3459,12 +3492,12 @@ function getShortCircuitMatches(routes) {
|
|
|
3459
3492
|
};
|
|
3460
3493
|
}
|
|
3461
3494
|
|
|
3462
|
-
function getInternalRouterError(status,
|
|
3495
|
+
function getInternalRouterError(status, _temp4) {
|
|
3463
3496
|
let {
|
|
3464
3497
|
pathname,
|
|
3465
3498
|
routeId,
|
|
3466
3499
|
method
|
|
3467
|
-
} =
|
|
3500
|
+
} = _temp4 === void 0 ? {} : _temp4;
|
|
3468
3501
|
let statusText = "Unknown Server Error";
|
|
3469
3502
|
let errorMessage = "Unknown @remix-run/router error";
|
|
3470
3503
|
|