@remix-run/router 0.0.0-experimental-db3389095 → 0.0.0-experimental-e6fb6e074
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 +25 -0
- package/dist/router.cjs.js +42 -44
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.js +41 -43
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +42 -44
- 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 +2 -0
- package/package.json +1 -1
- package/router.ts +52 -50
- package/utils.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# `@remix-run/router`
|
|
2
2
|
|
|
3
|
+
## 1.23.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add `fetcherKey` as a parameter to `patchRoutesOnNavigation` ([#13109](https://github.com/remix-run/react-router/pull/13109))
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Fix regression introduced in `6.29.0` via [#12169](https://github.com/remix-run/react-router/pull/12169) that caused issues navigating to hash routes inside splat routes for applications using Lazy Route Discovery (`patchRoutesOnNavigation`) ([#13108](https://github.com/remix-run/react-router/pull/13108))
|
|
12
|
+
|
|
13
|
+
## 1.22.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- Provide the request `signal` as a parameter to `patchRoutesOnNavigation` ([#12900](https://github.com/remix-run/react-router/pull/12900))
|
|
18
|
+
|
|
19
|
+
- This can be used to abort any manifest fetches if the in-flight navigation/fetcher is aborted
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Do not log v7 deprecation warnings in production builds ([#12794](https://github.com/remix-run/react-router/pull/12794))
|
|
24
|
+
- Strip search parameters from `patchRoutesOnNavigation` `path` param for fetcher calls ([#12899](https://github.com/remix-run/react-router/pull/12899))
|
|
25
|
+
- Properly bubble headers when throwing a `data()` result ([#12845](https://github.com/remix-run/react-router/pull/12845))
|
|
26
|
+
- Optimize route matching by skipping redundant `matchRoutes` calls when possible ([#12169](https://github.com/remix-run/react-router/pull/12169))
|
|
27
|
+
|
|
3
28
|
## 1.21.1
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
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-e6fb6e074
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -1748,6 +1748,7 @@ function createRouter(init) {
|
|
|
1748
1748
|
// SSR did the initial scroll restoration.
|
|
1749
1749
|
let initialScrollRestored = init.hydrationData != null;
|
|
1750
1750
|
let initialMatches = matchRoutes(dataRoutes, init.history.location, basename);
|
|
1751
|
+
let initialMatchesIsFOW = false;
|
|
1751
1752
|
let initialErrors = null;
|
|
1752
1753
|
if (initialMatches == null && !patchRoutesOnNavigationImpl) {
|
|
1753
1754
|
// If we do not match a user-provided-route, fall back to the root
|
|
@@ -1788,6 +1789,7 @@ function createRouter(init) {
|
|
|
1788
1789
|
if (future.v7_partialHydration) {
|
|
1789
1790
|
let fogOfWar = checkFogOfWar(null, dataRoutes, init.history.location.pathname);
|
|
1790
1791
|
if (fogOfWar.active && fogOfWar.matches) {
|
|
1792
|
+
initialMatchesIsFOW = true;
|
|
1791
1793
|
initialMatches = fogOfWar.matches;
|
|
1792
1794
|
}
|
|
1793
1795
|
}
|
|
@@ -2017,13 +2019,9 @@ function createRouter(init) {
|
|
|
2017
2019
|
|
|
2018
2020
|
// Update our state and notify the calling context of the change
|
|
2019
2021
|
function updateState(newState, opts) {
|
|
2020
|
-
var _newState$navigation;
|
|
2021
2022
|
if (opts === void 0) {
|
|
2022
2023
|
opts = {};
|
|
2023
2024
|
}
|
|
2024
|
-
console.log("updateState()", opts.viewTransitionOpts);
|
|
2025
|
-
console.log(" navigation change", state.navigation.state, "->", (_newState$navigation = newState.navigation) == null ? void 0 : _newState$navigation.state);
|
|
2026
|
-
console.log(" revalidation change", state.revalidation, "->", newState.revalidation);
|
|
2027
2025
|
state = _extends({}, state, newState);
|
|
2028
2026
|
|
|
2029
2027
|
// Prep fetcher cleanup so we can tell the UI which fetcher data entries
|
|
@@ -2192,7 +2190,6 @@ function createRouter(init) {
|
|
|
2192
2190
|
// Trigger a navigation event, which can either be a numerical POP or a PUSH
|
|
2193
2191
|
// replace with an optional submission
|
|
2194
2192
|
async function navigate(to, opts) {
|
|
2195
|
-
console.log("navigate()", to, JSON.stringify(state.navigation));
|
|
2196
2193
|
if (typeof to === "number") {
|
|
2197
2194
|
init.history.go(to);
|
|
2198
2195
|
return;
|
|
@@ -2271,8 +2268,6 @@ function createRouter(init) {
|
|
|
2271
2268
|
// is interrupted by a navigation, allow this to "succeed" by calling all
|
|
2272
2269
|
// loaders during the next loader round
|
|
2273
2270
|
function revalidate() {
|
|
2274
|
-
console.log("revalidate()");
|
|
2275
|
-
console.log(" current navigation", JSON.stringify(state.navigation));
|
|
2276
2271
|
interruptActiveLoads();
|
|
2277
2272
|
updateState({
|
|
2278
2273
|
revalidation: "loading"
|
|
@@ -2288,7 +2283,6 @@ function createRouter(init) {
|
|
|
2288
2283
|
// action/location and mark it as uninterrupted, which will skip the history
|
|
2289
2284
|
// update in completeNavigation
|
|
2290
2285
|
if (state.navigation.state === "idle") {
|
|
2291
|
-
console.log("startNavigation() - startUninterruptedRevalidation=true");
|
|
2292
2286
|
startNavigation(state.historyAction, state.location, {
|
|
2293
2287
|
startUninterruptedRevalidation: true
|
|
2294
2288
|
});
|
|
@@ -2298,9 +2292,6 @@ function createRouter(init) {
|
|
|
2298
2292
|
// Otherwise, if we're currently in a loading state, just start a new
|
|
2299
2293
|
// navigation to the navigation.location but do not trigger an uninterrupted
|
|
2300
2294
|
// revalidation so that history correctly updates once the navigation completes
|
|
2301
|
-
console.log("startNavigation() - interrupting", {
|
|
2302
|
-
pendingViewTransitionEnabled
|
|
2303
|
-
});
|
|
2304
2295
|
startNavigation(pendingAction || state.historyAction, state.navigation.location, {
|
|
2305
2296
|
overrideNavigation: state.navigation,
|
|
2306
2297
|
// Proxy through any rending view transition
|
|
@@ -2327,8 +2318,25 @@ function createRouter(init) {
|
|
|
2327
2318
|
pendingViewTransitionEnabled = (opts && opts.enableViewTransition) === true;
|
|
2328
2319
|
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
2329
2320
|
let loadingNavigation = opts && opts.overrideNavigation;
|
|
2330
|
-
let matches =
|
|
2321
|
+
let matches = opts != null && opts.initialHydration && state.matches && state.matches.length > 0 && !initialMatchesIsFOW ?
|
|
2322
|
+
// `matchRoutes()` has already been called if we're in here via `router.initialize()`
|
|
2323
|
+
state.matches : matchRoutes(routesToUse, location, basename);
|
|
2331
2324
|
let flushSync = (opts && opts.flushSync) === true;
|
|
2325
|
+
|
|
2326
|
+
// Short circuit if it's only a hash change and not a revalidation or
|
|
2327
|
+
// mutation submission.
|
|
2328
|
+
//
|
|
2329
|
+
// Ignore on initial page loads because since the initial hydration will always
|
|
2330
|
+
// be "same hash". For example, on /page#hash and submit a <Form method="post">
|
|
2331
|
+
// which will default to a navigation to /page
|
|
2332
|
+
if (matches && state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) {
|
|
2333
|
+
completeNavigation(location, {
|
|
2334
|
+
matches
|
|
2335
|
+
}, {
|
|
2336
|
+
flushSync
|
|
2337
|
+
});
|
|
2338
|
+
return;
|
|
2339
|
+
}
|
|
2332
2340
|
let fogOfWar = checkFogOfWar(matches, routesToUse, location.pathname);
|
|
2333
2341
|
if (fogOfWar.active && fogOfWar.matches) {
|
|
2334
2342
|
matches = fogOfWar.matches;
|
|
@@ -2353,21 +2361,6 @@ function createRouter(init) {
|
|
|
2353
2361
|
return;
|
|
2354
2362
|
}
|
|
2355
2363
|
|
|
2356
|
-
// Short circuit if it's only a hash change and not a revalidation or
|
|
2357
|
-
// mutation submission.
|
|
2358
|
-
//
|
|
2359
|
-
// Ignore on initial page loads because since the initial hydration will always
|
|
2360
|
-
// be "same hash". For example, on /page#hash and submit a <Form method="post">
|
|
2361
|
-
// which will default to a navigation to /page
|
|
2362
|
-
if (state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) {
|
|
2363
|
-
completeNavigation(location, {
|
|
2364
|
-
matches
|
|
2365
|
-
}, {
|
|
2366
|
-
flushSync
|
|
2367
|
-
});
|
|
2368
|
-
return;
|
|
2369
|
-
}
|
|
2370
|
-
|
|
2371
2364
|
// Create a controller/Request for this navigation
|
|
2372
2365
|
pendingNavigationController = new AbortController();
|
|
2373
2366
|
let request = createClientSideRequest(init.history, location, pendingNavigationController.signal, opts && opts.submission);
|
|
@@ -2419,16 +2412,13 @@ function createRouter(init) {
|
|
|
2419
2412
|
}
|
|
2420
2413
|
|
|
2421
2414
|
// Call loaders
|
|
2422
|
-
console.log(" start handleLoaders()");
|
|
2423
2415
|
let {
|
|
2424
2416
|
shortCircuited,
|
|
2425
2417
|
matches: updatedMatches,
|
|
2426
2418
|
loaderData,
|
|
2427
2419
|
errors
|
|
2428
2420
|
} = await handleLoaders(request, location, matches, fogOfWar.active, loadingNavigation, opts && opts.submission, opts && opts.fetcherSubmission, opts && opts.replace, opts && opts.initialHydration === true, flushSync, pendingActionResult);
|
|
2429
|
-
console.log(" end handleLoaders()");
|
|
2430
2421
|
if (shortCircuited) {
|
|
2431
|
-
console.log(" short circuited from handleLoaders()");
|
|
2432
2422
|
return;
|
|
2433
2423
|
}
|
|
2434
2424
|
|
|
@@ -2866,7 +2856,7 @@ function createRouter(init) {
|
|
|
2866
2856
|
let abortController = new AbortController();
|
|
2867
2857
|
let fetchRequest = createClientSideRequest(init.history, path, abortController.signal, submission);
|
|
2868
2858
|
if (isFogOfWar) {
|
|
2869
|
-
let discoverResult = await discoverRoutes(requestMatches,
|
|
2859
|
+
let discoverResult = await discoverRoutes(requestMatches, new URL(fetchRequest.url).pathname, fetchRequest.signal, key);
|
|
2870
2860
|
if (discoverResult.type === "aborted") {
|
|
2871
2861
|
return;
|
|
2872
2862
|
} else if (discoverResult.type === "error") {
|
|
@@ -3052,7 +3042,7 @@ function createRouter(init) {
|
|
|
3052
3042
|
let abortController = new AbortController();
|
|
3053
3043
|
let fetchRequest = createClientSideRequest(init.history, path, abortController.signal);
|
|
3054
3044
|
if (isFogOfWar) {
|
|
3055
|
-
let discoverResult = await discoverRoutes(matches,
|
|
3045
|
+
let discoverResult = await discoverRoutes(matches, new URL(fetchRequest.url).pathname, fetchRequest.signal, key);
|
|
3056
3046
|
if (discoverResult.type === "aborted") {
|
|
3057
3047
|
return;
|
|
3058
3048
|
} else if (discoverResult.type === "error") {
|
|
@@ -3596,7 +3586,7 @@ function createRouter(init) {
|
|
|
3596
3586
|
matches: null
|
|
3597
3587
|
};
|
|
3598
3588
|
}
|
|
3599
|
-
async function discoverRoutes(matches, pathname, signal) {
|
|
3589
|
+
async function discoverRoutes(matches, pathname, signal, fetcherKey) {
|
|
3600
3590
|
if (!patchRoutesOnNavigationImpl) {
|
|
3601
3591
|
return {
|
|
3602
3592
|
type: "success",
|
|
@@ -3610,8 +3600,10 @@ function createRouter(init) {
|
|
|
3610
3600
|
let localManifest = manifest;
|
|
3611
3601
|
try {
|
|
3612
3602
|
await patchRoutesOnNavigationImpl({
|
|
3603
|
+
signal,
|
|
3613
3604
|
path: pathname,
|
|
3614
3605
|
matches: partialMatches,
|
|
3606
|
+
fetcherKey,
|
|
3615
3607
|
patch: (routeId, children) => {
|
|
3616
3608
|
if (signal.aborted) return;
|
|
3617
3609
|
patchRoutesImpl(routeId, children, routesToUse, localManifest, mapRouteProperties);
|
|
@@ -4882,18 +4874,24 @@ async function convertDataStrategyResultToDataResult(dataStrategyResult) {
|
|
|
4882
4874
|
}
|
|
4883
4875
|
if (type === ResultType.error) {
|
|
4884
4876
|
if (isDataWithResponseInit(result)) {
|
|
4885
|
-
var _result$
|
|
4877
|
+
var _result$init3, _result$init4;
|
|
4886
4878
|
if (result.data instanceof Error) {
|
|
4887
|
-
var _result$init;
|
|
4879
|
+
var _result$init, _result$init2;
|
|
4888
4880
|
return {
|
|
4889
4881
|
type: ResultType.error,
|
|
4890
4882
|
error: result.data,
|
|
4891
|
-
statusCode: (_result$init = result.init) == null ? void 0 : _result$init.status
|
|
4883
|
+
statusCode: (_result$init = result.init) == null ? void 0 : _result$init.status,
|
|
4884
|
+
headers: (_result$init2 = result.init) != null && _result$init2.headers ? new Headers(result.init.headers) : undefined
|
|
4892
4885
|
};
|
|
4893
4886
|
}
|
|
4894
4887
|
|
|
4895
4888
|
// Convert thrown data() to ErrorResponse instances
|
|
4896
|
-
|
|
4889
|
+
return {
|
|
4890
|
+
type: ResultType.error,
|
|
4891
|
+
error: new ErrorResponseImpl(((_result$init3 = result.init) == null ? void 0 : _result$init3.status) || 500, undefined, result.data),
|
|
4892
|
+
statusCode: isRouteErrorResponse(result) ? result.status : undefined,
|
|
4893
|
+
headers: (_result$init4 = result.init) != null && _result$init4.headers ? new Headers(result.init.headers) : undefined
|
|
4894
|
+
};
|
|
4897
4895
|
}
|
|
4898
4896
|
return {
|
|
4899
4897
|
type: ResultType.error,
|
|
@@ -4902,21 +4900,21 @@ async function convertDataStrategyResultToDataResult(dataStrategyResult) {
|
|
|
4902
4900
|
};
|
|
4903
4901
|
}
|
|
4904
4902
|
if (isDeferredData(result)) {
|
|
4905
|
-
var _result$
|
|
4903
|
+
var _result$init5, _result$init6;
|
|
4906
4904
|
return {
|
|
4907
4905
|
type: ResultType.deferred,
|
|
4908
4906
|
deferredData: result,
|
|
4909
|
-
statusCode: (_result$
|
|
4910
|
-
headers: ((_result$
|
|
4907
|
+
statusCode: (_result$init5 = result.init) == null ? void 0 : _result$init5.status,
|
|
4908
|
+
headers: ((_result$init6 = result.init) == null ? void 0 : _result$init6.headers) && new Headers(result.init.headers)
|
|
4911
4909
|
};
|
|
4912
4910
|
}
|
|
4913
4911
|
if (isDataWithResponseInit(result)) {
|
|
4914
|
-
var _result$
|
|
4912
|
+
var _result$init7, _result$init8;
|
|
4915
4913
|
return {
|
|
4916
4914
|
type: ResultType.data,
|
|
4917
4915
|
data: result.data,
|
|
4918
|
-
statusCode: (_result$
|
|
4919
|
-
headers: (_result$
|
|
4916
|
+
statusCode: (_result$init7 = result.init) == null ? void 0 : _result$init7.status,
|
|
4917
|
+
headers: (_result$init8 = result.init) != null && _result$init8.headers ? new Headers(result.init.headers) : undefined
|
|
4920
4918
|
};
|
|
4921
4919
|
}
|
|
4922
4920
|
return {
|