@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.umd.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
|
*
|
|
@@ -1841,7 +1841,10 @@
|
|
|
1841
1841
|
replace = result.location === state.location.pathname + state.location.search;
|
|
1842
1842
|
}
|
|
1843
1843
|
|
|
1844
|
-
await startRedirectNavigation(state, result,
|
|
1844
|
+
await startRedirectNavigation(state, result, {
|
|
1845
|
+
submission,
|
|
1846
|
+
replace
|
|
1847
|
+
});
|
|
1845
1848
|
return {
|
|
1846
1849
|
shortCircuited: true
|
|
1847
1850
|
};
|
|
@@ -1896,9 +1899,17 @@
|
|
|
1896
1899
|
}, submission);
|
|
1897
1900
|
|
|
1898
1901
|
loadingNavigation = navigation;
|
|
1899
|
-
}
|
|
1902
|
+
} // If this was a redirect from an action we don't have a "submission" but
|
|
1903
|
+
// we have it on the loading navigation so use that if available
|
|
1904
|
+
|
|
1900
1905
|
|
|
1901
|
-
let
|
|
1906
|
+
let activeSubmission = submission ? submission : loadingNavigation.formMethod && loadingNavigation.formAction && loadingNavigation.formData && loadingNavigation.formEncType ? {
|
|
1907
|
+
formMethod: loadingNavigation.formMethod,
|
|
1908
|
+
formAction: loadingNavigation.formAction,
|
|
1909
|
+
formData: loadingNavigation.formData,
|
|
1910
|
+
formEncType: loadingNavigation.formEncType
|
|
1911
|
+
} : undefined;
|
|
1912
|
+
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
|
|
1902
1913
|
// about to reload. Note that if this is an action reload we would have
|
|
1903
1914
|
// already cancelled all pending deferreds so this would be a no-op
|
|
1904
1915
|
|
|
@@ -1977,7 +1988,9 @@
|
|
|
1977
1988
|
let redirect = findRedirect(results);
|
|
1978
1989
|
|
|
1979
1990
|
if (redirect) {
|
|
1980
|
-
await startRedirectNavigation(state, redirect,
|
|
1991
|
+
await startRedirectNavigation(state, redirect, {
|
|
1992
|
+
replace
|
|
1993
|
+
});
|
|
1981
1994
|
return {
|
|
1982
1995
|
shortCircuited: true
|
|
1983
1996
|
};
|
|
@@ -2107,7 +2120,10 @@
|
|
|
2107
2120
|
updateState({
|
|
2108
2121
|
fetchers: new Map(state.fetchers)
|
|
2109
2122
|
});
|
|
2110
|
-
return startRedirectNavigation(state, actionResult,
|
|
2123
|
+
return startRedirectNavigation(state, actionResult, {
|
|
2124
|
+
submission,
|
|
2125
|
+
isFetchActionRedirect: true
|
|
2126
|
+
});
|
|
2111
2127
|
} // Process any non-redirect errors thrown
|
|
2112
2128
|
|
|
2113
2129
|
|
|
@@ -2184,7 +2200,9 @@
|
|
|
2184
2200
|
let redirect = findRedirect(results);
|
|
2185
2201
|
|
|
2186
2202
|
if (redirect) {
|
|
2187
|
-
return startRedirectNavigation(state, redirect
|
|
2203
|
+
return startRedirectNavigation(state, redirect, {
|
|
2204
|
+
submission
|
|
2205
|
+
});
|
|
2188
2206
|
} // Process and commit output from loaders
|
|
2189
2207
|
|
|
2190
2208
|
|
|
@@ -2330,9 +2348,15 @@
|
|
|
2330
2348
|
*/
|
|
2331
2349
|
|
|
2332
2350
|
|
|
2333
|
-
async function startRedirectNavigation(state, redirect,
|
|
2351
|
+
async function startRedirectNavigation(state, redirect, _temp) {
|
|
2334
2352
|
var _window;
|
|
2335
2353
|
|
|
2354
|
+
let {
|
|
2355
|
+
submission,
|
|
2356
|
+
replace,
|
|
2357
|
+
isFetchActionRedirect
|
|
2358
|
+
} = _temp === void 0 ? {} : _temp;
|
|
2359
|
+
|
|
2336
2360
|
if (redirect.revalidate) {
|
|
2337
2361
|
isRevalidationRequired = true;
|
|
2338
2362
|
}
|
|
@@ -2362,24 +2386,33 @@
|
|
|
2362
2386
|
|
|
2363
2387
|
|
|
2364
2388
|
pendingNavigationController = null;
|
|
2365
|
-
let redirectHistoryAction = replace === true ? exports.Action.Replace : exports.Action.Push;
|
|
2389
|
+
let redirectHistoryAction = replace === true ? exports.Action.Replace : exports.Action.Push; // Use the incoming submission if provided, fallback on the active one in
|
|
2390
|
+
// state.navigation
|
|
2391
|
+
|
|
2366
2392
|
let {
|
|
2367
2393
|
formMethod,
|
|
2368
2394
|
formAction,
|
|
2369
2395
|
formEncType,
|
|
2370
2396
|
formData
|
|
2371
|
-
} = state.navigation;
|
|
2397
|
+
} = state.navigation;
|
|
2398
|
+
|
|
2399
|
+
if (!submission && formMethod && formAction && formData && formEncType) {
|
|
2400
|
+
submission = {
|
|
2401
|
+
formMethod,
|
|
2402
|
+
formAction,
|
|
2403
|
+
formEncType,
|
|
2404
|
+
formData
|
|
2405
|
+
};
|
|
2406
|
+
} // If this was a 307/308 submission we want to preserve the HTTP method and
|
|
2372
2407
|
// re-submit the GET/POST/PUT/PATCH/DELETE as a submission navigation to the
|
|
2373
2408
|
// redirected location
|
|
2374
2409
|
|
|
2375
|
-
|
|
2410
|
+
|
|
2411
|
+
if (redirectPreserveMethodStatusCodes.has(redirect.status) && submission && isMutationMethod(submission.formMethod)) {
|
|
2376
2412
|
await startNavigation(redirectHistoryAction, redirectLocation, {
|
|
2377
|
-
submission: {
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
formEncType,
|
|
2381
|
-
formData
|
|
2382
|
-
}
|
|
2413
|
+
submission: _extends({}, submission, {
|
|
2414
|
+
formAction: redirect.location
|
|
2415
|
+
})
|
|
2383
2416
|
});
|
|
2384
2417
|
} else {
|
|
2385
2418
|
// Otherwise, we kick off a new loading navigation, preserving the
|
|
@@ -2388,10 +2421,10 @@
|
|
|
2388
2421
|
overrideNavigation: {
|
|
2389
2422
|
state: "loading",
|
|
2390
2423
|
location: redirectLocation,
|
|
2391
|
-
formMethod: formMethod
|
|
2392
|
-
formAction: formAction
|
|
2393
|
-
formEncType: formEncType
|
|
2394
|
-
formData: formData
|
|
2424
|
+
formMethod: submission ? submission.formMethod : undefined,
|
|
2425
|
+
formAction: submission ? submission.formAction : undefined,
|
|
2426
|
+
formEncType: submission ? submission.formEncType : undefined,
|
|
2427
|
+
formData: submission ? submission.formData : undefined
|
|
2395
2428
|
}
|
|
2396
2429
|
});
|
|
2397
2430
|
}
|
|
@@ -2636,10 +2669,10 @@
|
|
|
2636
2669
|
* return it directly.
|
|
2637
2670
|
*/
|
|
2638
2671
|
|
|
2639
|
-
async function query(request,
|
|
2672
|
+
async function query(request, _temp2) {
|
|
2640
2673
|
let {
|
|
2641
2674
|
requestContext
|
|
2642
|
-
} =
|
|
2675
|
+
} = _temp2 === void 0 ? {} : _temp2;
|
|
2643
2676
|
let url = new URL(request.url);
|
|
2644
2677
|
let method = request.method.toLowerCase();
|
|
2645
2678
|
let location = createLocation("", createPath(url), null, "default");
|
|
@@ -2725,11 +2758,11 @@
|
|
|
2725
2758
|
*/
|
|
2726
2759
|
|
|
2727
2760
|
|
|
2728
|
-
async function queryRoute(request,
|
|
2761
|
+
async function queryRoute(request, _temp3) {
|
|
2729
2762
|
let {
|
|
2730
2763
|
routeId,
|
|
2731
2764
|
requestContext
|
|
2732
|
-
} =
|
|
2765
|
+
} = _temp3 === void 0 ? {} : _temp3;
|
|
2733
2766
|
let url = new URL(request.url);
|
|
2734
2767
|
let method = request.method.toLowerCase();
|
|
2735
2768
|
let location = createLocation("", createPath(url), null, "default");
|
|
@@ -3510,12 +3543,12 @@
|
|
|
3510
3543
|
};
|
|
3511
3544
|
}
|
|
3512
3545
|
|
|
3513
|
-
function getInternalRouterError(status,
|
|
3546
|
+
function getInternalRouterError(status, _temp4) {
|
|
3514
3547
|
let {
|
|
3515
3548
|
pathname,
|
|
3516
3549
|
routeId,
|
|
3517
3550
|
method
|
|
3518
|
-
} =
|
|
3551
|
+
} = _temp4 === void 0 ? {} : _temp4;
|
|
3519
3552
|
let statusText = "Unknown Server Error";
|
|
3520
3553
|
let errorMessage = "Unknown @remix-run/router error";
|
|
3521
3554
|
|