@remix-run/router 1.21.1 → 1.21.2-pre-v6.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 -0
- package/dist/router.cjs.js +22 -12
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.js +22 -12
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +22 -12
- 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 +25 -6
package/package.json
CHANGED
package/router.ts
CHANGED
|
@@ -829,6 +829,7 @@ export function createRouter(init: RouterInit): Router {
|
|
|
829
829
|
let initialScrollRestored = init.hydrationData != null;
|
|
830
830
|
|
|
831
831
|
let initialMatches = matchRoutes(dataRoutes, init.history.location, basename);
|
|
832
|
+
let initialMatchesIsFOW = false;
|
|
832
833
|
let initialErrors: RouteData | null = null;
|
|
833
834
|
|
|
834
835
|
if (initialMatches == null && !patchRoutesOnNavigationImpl) {
|
|
@@ -874,6 +875,7 @@ export function createRouter(init: RouterInit): Router {
|
|
|
874
875
|
init.history.location.pathname
|
|
875
876
|
);
|
|
876
877
|
if (fogOfWar.active && fogOfWar.matches) {
|
|
878
|
+
initialMatchesIsFOW = true;
|
|
877
879
|
initialMatches = fogOfWar.matches;
|
|
878
880
|
}
|
|
879
881
|
}
|
|
@@ -1522,7 +1524,14 @@ export function createRouter(init: RouterInit): Router {
|
|
|
1522
1524
|
|
|
1523
1525
|
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
1524
1526
|
let loadingNavigation = opts && opts.overrideNavigation;
|
|
1525
|
-
let matches =
|
|
1527
|
+
let matches =
|
|
1528
|
+
opts?.initialHydration &&
|
|
1529
|
+
state.matches &&
|
|
1530
|
+
state.matches.length > 0 &&
|
|
1531
|
+
!initialMatchesIsFOW
|
|
1532
|
+
? // `matchRoutes()` has already been called if we're in here via `router.initialize()`
|
|
1533
|
+
state.matches
|
|
1534
|
+
: matchRoutes(routesToUse, location, basename);
|
|
1526
1535
|
let flushSync = (opts && opts.flushSync) === true;
|
|
1527
1536
|
|
|
1528
1537
|
let fogOfWar = checkFogOfWar(matches, routesToUse, location.pathname);
|
|
@@ -5052,15 +5061,25 @@ async function convertDataStrategyResultToDataResult(
|
|
|
5052
5061
|
type: ResultType.error,
|
|
5053
5062
|
error: result.data,
|
|
5054
5063
|
statusCode: result.init?.status,
|
|
5064
|
+
headers: result.init?.headers
|
|
5065
|
+
? new Headers(result.init.headers)
|
|
5066
|
+
: undefined,
|
|
5055
5067
|
};
|
|
5056
5068
|
}
|
|
5057
5069
|
|
|
5058
5070
|
// Convert thrown data() to ErrorResponse instances
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5071
|
+
return {
|
|
5072
|
+
type: ResultType.error,
|
|
5073
|
+
error: new ErrorResponseImpl(
|
|
5074
|
+
result.init?.status || 500,
|
|
5075
|
+
undefined,
|
|
5076
|
+
result.data
|
|
5077
|
+
),
|
|
5078
|
+
statusCode: isRouteErrorResponse(result) ? result.status : undefined,
|
|
5079
|
+
headers: result.init?.headers
|
|
5080
|
+
? new Headers(result.init.headers)
|
|
5081
|
+
: undefined,
|
|
5082
|
+
};
|
|
5064
5083
|
}
|
|
5065
5084
|
return {
|
|
5066
5085
|
type: ResultType.error,
|