@remix-run/router 1.21.1 → 1.22.0-pre-v6.1

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/dist/router.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @remix-run/router v1.21.1
2
+ * @remix-run/router v1.22.0-pre-v6.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1398,6 +1398,7 @@ function createRouter(init) {
1398
1398
  // SSR did the initial scroll restoration.
1399
1399
  let initialScrollRestored = init.hydrationData != null;
1400
1400
  let initialMatches = matchRoutes(dataRoutes, init.history.location, basename);
1401
+ let initialMatchesIsFOW = false;
1401
1402
  let initialErrors = null;
1402
1403
  if (initialMatches == null && !patchRoutesOnNavigationImpl) {
1403
1404
  // If we do not match a user-provided-route, fall back to the root
@@ -1436,6 +1437,7 @@ function createRouter(init) {
1436
1437
  if (future.v7_partialHydration) {
1437
1438
  let fogOfWar = checkFogOfWar(null, dataRoutes, init.history.location.pathname);
1438
1439
  if (fogOfWar.active && fogOfWar.matches) {
1440
+ initialMatchesIsFOW = true;
1439
1441
  initialMatches = fogOfWar.matches;
1440
1442
  }
1441
1443
  }
@@ -1917,7 +1919,9 @@ function createRouter(init) {
1917
1919
  pendingViewTransitionEnabled = (opts && opts.enableViewTransition) === true;
1918
1920
  let routesToUse = inFlightDataRoutes || dataRoutes;
1919
1921
  let loadingNavigation = opts && opts.overrideNavigation;
1920
- let matches = matchRoutes(routesToUse, location, basename);
1922
+ let matches = opts != null && opts.initialHydration && state.matches && state.matches.length > 0 && !initialMatchesIsFOW ?
1923
+ // `matchRoutes()` has already been called if we're in here via `router.initialize()`
1924
+ state.matches : matchRoutes(routesToUse, location, basename);
1921
1925
  let flushSync = (opts && opts.flushSync) === true;
1922
1926
  let fogOfWar = checkFogOfWar(matches, routesToUse, location.pathname);
1923
1927
  if (fogOfWar.active && fogOfWar.matches) {
@@ -2426,7 +2430,7 @@ function createRouter(init) {
2426
2430
  let abortController = new AbortController();
2427
2431
  let fetchRequest = createClientSideRequest(init.history, path, abortController.signal, submission);
2428
2432
  if (isFogOfWar) {
2429
- let discoverResult = await discoverRoutes(requestMatches, path, fetchRequest.signal);
2433
+ let discoverResult = await discoverRoutes(requestMatches, new URL(fetchRequest.url).pathname, fetchRequest.signal);
2430
2434
  if (discoverResult.type === "aborted") {
2431
2435
  return;
2432
2436
  } else if (discoverResult.type === "error") {
@@ -2603,7 +2607,7 @@ function createRouter(init) {
2603
2607
  let abortController = new AbortController();
2604
2608
  let fetchRequest = createClientSideRequest(init.history, path, abortController.signal);
2605
2609
  if (isFogOfWar) {
2606
- let discoverResult = await discoverRoutes(matches, path, fetchRequest.signal);
2610
+ let discoverResult = await discoverRoutes(matches, new URL(fetchRequest.url).pathname, fetchRequest.signal);
2607
2611
  if (discoverResult.type === "aborted") {
2608
2612
  return;
2609
2613
  } else if (discoverResult.type === "error") {
@@ -3138,6 +3142,7 @@ function createRouter(init) {
3138
3142
  let localManifest = manifest;
3139
3143
  try {
3140
3144
  await patchRoutesOnNavigationImpl({
3145
+ signal,
3141
3146
  path: pathname,
3142
3147
  matches: partialMatches,
3143
3148
  patch: (routeId, children) => {
@@ -4350,17 +4355,23 @@ async function convertDataStrategyResultToDataResult(dataStrategyResult) {
4350
4355
  }
4351
4356
  if (type === ResultType.error) {
4352
4357
  if (isDataWithResponseInit(result)) {
4353
- var _result$init2;
4358
+ var _result$init3, _result$init4;
4354
4359
  if (result.data instanceof Error) {
4355
- var _result$init;
4360
+ var _result$init, _result$init2;
4356
4361
  return {
4357
4362
  type: ResultType.error,
4358
4363
  error: result.data,
4359
- statusCode: (_result$init = result.init) == null ? void 0 : _result$init.status
4364
+ statusCode: (_result$init = result.init) == null ? void 0 : _result$init.status,
4365
+ headers: (_result$init2 = result.init) != null && _result$init2.headers ? new Headers(result.init.headers) : undefined
4360
4366
  };
4361
4367
  }
4362
4368
  // Convert thrown data() to ErrorResponse instances
4363
- result = new ErrorResponseImpl(((_result$init2 = result.init) == null ? void 0 : _result$init2.status) || 500, undefined, result.data);
4369
+ return {
4370
+ type: ResultType.error,
4371
+ error: new ErrorResponseImpl(((_result$init3 = result.init) == null ? void 0 : _result$init3.status) || 500, undefined, result.data),
4372
+ statusCode: isRouteErrorResponse(result) ? result.status : undefined,
4373
+ headers: (_result$init4 = result.init) != null && _result$init4.headers ? new Headers(result.init.headers) : undefined
4374
+ };
4364
4375
  }
4365
4376
  return {
4366
4377
  type: ResultType.error,
@@ -4369,21 +4380,21 @@ async function convertDataStrategyResultToDataResult(dataStrategyResult) {
4369
4380
  };
4370
4381
  }
4371
4382
  if (isDeferredData(result)) {
4372
- var _result$init3, _result$init4;
4383
+ var _result$init5, _result$init6;
4373
4384
  return {
4374
4385
  type: ResultType.deferred,
4375
4386
  deferredData: result,
4376
- statusCode: (_result$init3 = result.init) == null ? void 0 : _result$init3.status,
4377
- headers: ((_result$init4 = result.init) == null ? void 0 : _result$init4.headers) && new Headers(result.init.headers)
4387
+ statusCode: (_result$init5 = result.init) == null ? void 0 : _result$init5.status,
4388
+ headers: ((_result$init6 = result.init) == null ? void 0 : _result$init6.headers) && new Headers(result.init.headers)
4378
4389
  };
4379
4390
  }
4380
4391
  if (isDataWithResponseInit(result)) {
4381
- var _result$init5, _result$init6;
4392
+ var _result$init7, _result$init8;
4382
4393
  return {
4383
4394
  type: ResultType.data,
4384
4395
  data: result.data,
4385
- statusCode: (_result$init5 = result.init) == null ? void 0 : _result$init5.status,
4386
- headers: (_result$init6 = result.init) != null && _result$init6.headers ? new Headers(result.init.headers) : undefined
4396
+ statusCode: (_result$init7 = result.init) == null ? void 0 : _result$init7.status,
4397
+ headers: (_result$init8 = result.init) != null && _result$init8.headers ? new Headers(result.init.headers) : undefined
4387
4398
  };
4388
4399
  }
4389
4400
  return {