@remix-run/router 1.0.0 → 1.0.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.0.0
2
+ * @remix-run/router v1.0.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -76,7 +76,7 @@ function createMemoryHistory(options) {
76
76
  } = options;
77
77
  let entries; // Declare so we can access from createMemoryLocation
78
78
 
79
- entries = initialEntries.map((entry, index) => createMemoryLocation(entry, null, index === 0 ? "default" : undefined));
79
+ entries = initialEntries.map((entry, index) => createMemoryLocation(entry, typeof entry === "string" ? null : entry.state, index === 0 ? "default" : undefined));
80
80
  let index = clampIndex(initialIndex == null ? entries.length - 1 : initialIndex);
81
81
  let action = Action.Pop;
82
82
  let listener = null;
@@ -179,8 +179,6 @@ function createBrowserHistory(options) {
179
179
  }
180
180
 
181
181
  function createBrowserLocation(window, globalHistory) {
182
- var _globalHistory$state, _globalHistory$state2;
183
-
184
182
  let {
185
183
  pathname,
186
184
  search,
@@ -191,7 +189,7 @@ function createBrowserHistory(options) {
191
189
  search,
192
190
  hash
193
191
  }, // state defaults to `null` because `window.history.state` does
194
- ((_globalHistory$state = globalHistory.state) == null ? void 0 : _globalHistory$state.usr) || null, ((_globalHistory$state2 = globalHistory.state) == null ? void 0 : _globalHistory$state2.key) || "default");
192
+ globalHistory.state && globalHistory.state.usr || null, globalHistory.state && globalHistory.state.key || "default");
195
193
  }
196
194
 
197
195
  function createBrowserHref(window, to) {
@@ -215,8 +213,6 @@ function createHashHistory(options) {
215
213
  }
216
214
 
217
215
  function createHashLocation(window, globalHistory) {
218
- var _globalHistory$state3, _globalHistory$state4;
219
-
220
216
  let {
221
217
  pathname = "/",
222
218
  search = "",
@@ -227,7 +223,7 @@ function createHashHistory(options) {
227
223
  search,
228
224
  hash
229
225
  }, // state defaults to `null` because `window.history.state` does
230
- ((_globalHistory$state3 = globalHistory.state) == null ? void 0 : _globalHistory$state3.usr) || null, ((_globalHistory$state4 = globalHistory.state) == null ? void 0 : _globalHistory$state4.key) || "default");
226
+ globalHistory.state && globalHistory.state.usr || null, globalHistory.state && globalHistory.state.key || "default");
231
227
  }
232
228
 
233
229
  function createHashHref(window, to) {
@@ -303,7 +299,7 @@ function createLocation(current, to, state, key) {
303
299
  // full Locations now and avoid the need to run through this flow at all
304
300
  // But that's a pretty big refactor to the current test suite so going to
305
301
  // keep as is for the time being and just let any incoming keys take precedence
306
- key: (to == null ? void 0 : to.key) || key || createKey()
302
+ key: to && to.key || key || createKey()
307
303
  });
308
304
 
309
305
  return location;
@@ -379,7 +375,7 @@ function getUrlBasedHistory(getLocation, createHref, validateLocation, options)
379
375
  function push(to, state) {
380
376
  action = Action.Push;
381
377
  let location = createLocation(history.location, to, state);
382
- validateLocation == null ? void 0 : validateLocation(location, to);
378
+ if (validateLocation) validateLocation(location, to);
383
379
  let historyState = getHistoryState(location);
384
380
  let url = history.createHref(location); // try...catch because iOS limits us to 100 pushState calls :/
385
381
 
@@ -402,7 +398,7 @@ function getUrlBasedHistory(getLocation, createHref, validateLocation, options)
402
398
  function replace(to, state) {
403
399
  action = Action.Replace;
404
400
  let location = createLocation(history.location, to, state);
405
- validateLocation == null ? void 0 : validateLocation(location, to);
401
+ if (validateLocation) validateLocation(location, to);
406
402
  let historyState = getHistoryState(location);
407
403
  let url = history.createHref(location);
408
404
  globalHistory.replaceState(historyState, "", url);
@@ -994,8 +990,6 @@ class DeferredData {
994
990
  }
995
991
 
996
992
  onSettle(promise, key, error, data) {
997
- var _this$subscriber2;
998
-
999
993
  if (this.controller.signal.aborted && error instanceof AbortedDeferredError) {
1000
994
  this.unlistenAbortSignal();
1001
995
  Object.defineProperty(promise, "_error", {
@@ -1011,20 +1005,20 @@ class DeferredData {
1011
1005
  this.unlistenAbortSignal();
1012
1006
  }
1013
1007
 
1014
- if (error) {
1015
- var _this$subscriber;
1008
+ const subscriber = this.subscriber;
1016
1009
 
1010
+ if (error) {
1017
1011
  Object.defineProperty(promise, "_error", {
1018
1012
  get: () => error
1019
1013
  });
1020
- (_this$subscriber = this.subscriber) == null ? void 0 : _this$subscriber.call(this, false);
1014
+ subscriber && subscriber(false);
1021
1015
  return Promise.reject(error);
1022
1016
  }
1023
1017
 
1024
1018
  Object.defineProperty(promise, "_data", {
1025
1019
  get: () => data
1026
1020
  });
1027
- (_this$subscriber2 = this.subscriber) == null ? void 0 : _this$subscriber2.call(this, false);
1021
+ subscriber && subscriber(false);
1028
1022
  return data;
1029
1023
  }
1030
1024
 
@@ -1033,11 +1027,10 @@ class DeferredData {
1033
1027
  }
1034
1028
 
1035
1029
  cancel() {
1036
- var _this$subscriber3;
1037
-
1038
1030
  this.controller.abort();
1039
1031
  this.pendingKeys.forEach((v, k) => this.pendingKeys.delete(k));
1040
- (_this$subscriber3 = this.subscriber) == null ? void 0 : _this$subscriber3.call(this, true);
1032
+ let subscriber = this.subscriber;
1033
+ subscriber && subscriber(true);
1041
1034
  }
1042
1035
 
1043
1036
  async resolveData(signal) {
@@ -1169,8 +1162,6 @@ const IDLE_FETCHER = {
1169
1162
  */
1170
1163
 
1171
1164
  function createRouter(init) {
1172
- var _init$hydrationData, _init$hydrationData2, _init$hydrationData3;
1173
-
1174
1165
  invariant(init.routes.length > 0, "You must provide a non-empty routes array to createRouter");
1175
1166
  let dataRoutes = convertRoutesToDataRoutes(init.routes); // Cleanup function for history
1176
1167
 
@@ -1216,9 +1207,9 @@ function createRouter(init) {
1216
1207
  restoreScrollPosition: null,
1217
1208
  preventScrollReset: false,
1218
1209
  revalidation: "idle",
1219
- loaderData: ((_init$hydrationData = init.hydrationData) == null ? void 0 : _init$hydrationData.loaderData) || {},
1220
- actionData: ((_init$hydrationData2 = init.hydrationData) == null ? void 0 : _init$hydrationData2.actionData) || null,
1221
- errors: ((_init$hydrationData3 = init.hydrationData) == null ? void 0 : _init$hydrationData3.errors) || initialErrors,
1210
+ loaderData: init.hydrationData && init.hydrationData.loaderData || {},
1211
+ actionData: init.hydrationData && init.hydrationData.actionData || null,
1212
+ errors: init.hydrationData && init.hydrationData.errors || initialErrors,
1222
1213
  fetchers: new Map()
1223
1214
  }; // -- Stateful internal variables to manage navigations --
1224
1215
  // Current navigation in progress (to be committed in completeNavigation)
@@ -1285,14 +1276,12 @@ function createRouter(init) {
1285
1276
 
1286
1277
 
1287
1278
  function dispose() {
1288
- var _pendingNavigationCon;
1289
-
1290
1279
  if (unlistenHistory) {
1291
1280
  unlistenHistory();
1292
1281
  }
1293
1282
 
1294
1283
  subscribers.clear();
1295
- (_pendingNavigationCon = pendingNavigationController) == null ? void 0 : _pendingNavigationCon.abort();
1284
+ pendingNavigationController && pendingNavigationController.abort();
1296
1285
  state.fetchers.forEach((_, key) => deleteFetcher(key));
1297
1286
  } // Subscribe to state updates for the router
1298
1287
 
@@ -1368,8 +1357,8 @@ function createRouter(init) {
1368
1357
  submission,
1369
1358
  error
1370
1359
  } = normalizeNavigateOptions(to, opts);
1371
- let location = createLocation(state.location, path, opts == null ? void 0 : opts.state);
1372
- let historyAction = (opts == null ? void 0 : opts.replace) === true || submission != null ? Action.Replace : Action.Push;
1360
+ let location = createLocation(state.location, path, opts && opts.state);
1361
+ let historyAction = (opts && opts.replace) === true || submission != null ? Action.Replace : Action.Push;
1373
1362
  let preventScrollReset = opts && "preventScrollReset" in opts ? opts.preventScrollReset === true : undefined;
1374
1363
  return await startNavigation(historyAction, location, {
1375
1364
  submission,
@@ -1377,7 +1366,7 @@ function createRouter(init) {
1377
1366
  // render at the right error boundary after we match routes
1378
1367
  pendingError: error,
1379
1368
  preventScrollReset,
1380
- replace: opts == null ? void 0 : opts.replace
1369
+ replace: opts && opts.replace
1381
1370
  });
1382
1371
  } // Revalidate all current loaders. If a navigation is in progress or if this
1383
1372
  // is interrupted by a navigation, allow this to "succeed" by calling all
@@ -1417,20 +1406,18 @@ function createRouter(init) {
1417
1406
 
1418
1407
 
1419
1408
  async function startNavigation(historyAction, location, opts) {
1420
- var _pendingNavigationCon2;
1421
-
1422
1409
  // Abort any in-progress navigations and start a new one. Unset any ongoing
1423
1410
  // uninterrupted revalidations unless told otherwise, since we want this
1424
1411
  // new navigation to update history normally
1425
- (_pendingNavigationCon2 = pendingNavigationController) == null ? void 0 : _pendingNavigationCon2.abort();
1412
+ pendingNavigationController && pendingNavigationController.abort();
1426
1413
  pendingNavigationController = null;
1427
1414
  pendingAction = historyAction;
1428
- isUninterruptedRevalidation = (opts == null ? void 0 : opts.startUninterruptedRevalidation) === true; // Save the current scroll position every time we start a new navigation,
1415
+ isUninterruptedRevalidation = (opts && opts.startUninterruptedRevalidation) === true; // Save the current scroll position every time we start a new navigation,
1429
1416
  // and track whether we should reset scroll on completion
1430
1417
 
1431
1418
  saveScrollPosition(state.location, state.matches);
1432
- pendingPreventScrollReset = (opts == null ? void 0 : opts.preventScrollReset) === true;
1433
- let loadingNavigation = opts == null ? void 0 : opts.overrideNavigation;
1419
+ pendingPreventScrollReset = (opts && opts.preventScrollReset) === true;
1420
+ let loadingNavigation = opts && opts.overrideNavigation;
1434
1421
  let matches = matchRoutes(dataRoutes, location, init.basename); // Short circuit with a 404 on the root error boundary if we match nothing
1435
1422
 
1436
1423
  if (!matches) {
@@ -1461,11 +1448,11 @@ function createRouter(init) {
1461
1448
 
1462
1449
 
1463
1450
  pendingNavigationController = new AbortController();
1464
- let request = createRequest(location, pendingNavigationController.signal, opts == null ? void 0 : opts.submission);
1451
+ let request = createRequest(location, pendingNavigationController.signal, opts && opts.submission);
1465
1452
  let pendingActionData;
1466
1453
  let pendingError;
1467
1454
 
1468
- if (opts != null && opts.pendingError) {
1455
+ if (opts && opts.pendingError) {
1469
1456
  // If we have a pendingError, it means the user attempted a GET submission
1470
1457
  // with binary FormData so assign here and skip to handleLoaders. That
1471
1458
  // way we handle calling loaders above the boundary etc. It's not really
@@ -1473,7 +1460,7 @@ function createRouter(init) {
1473
1460
  pendingError = {
1474
1461
  [findNearestBoundary(matches).route.id]: opts.pendingError
1475
1462
  };
1476
- } else if (opts != null && opts.submission) {
1463
+ } else if (opts && opts.submission) {
1477
1464
  // Call action if we received an action submission
1478
1465
  let actionOutput = await handleAction(request, location, opts.submission, matches, {
1479
1466
  replace: opts.replace
@@ -1499,7 +1486,7 @@ function createRouter(init) {
1499
1486
  shortCircuited,
1500
1487
  loaderData,
1501
1488
  errors
1502
- } = await handleLoaders(request, location, matches, loadingNavigation, opts == null ? void 0 : opts.submission, opts == null ? void 0 : opts.replace, pendingActionData, pendingError);
1489
+ } = await handleLoaders(request, location, matches, loadingNavigation, opts && opts.submission, opts && opts.replace, pendingActionData, pendingError);
1503
1490
 
1504
1491
  if (shortCircuited) {
1505
1492
  return;
@@ -1551,7 +1538,7 @@ function createRouter(init) {
1551
1538
  location: createLocation(state.location, result.location)
1552
1539
  }, submission);
1553
1540
 
1554
- await startRedirectNavigation(result, redirectNavigation, opts == null ? void 0 : opts.replace);
1541
+ await startRedirectNavigation(result, redirectNavigation, opts && opts.replace);
1555
1542
  return {
1556
1543
  shortCircuited: true
1557
1544
  };
@@ -1565,7 +1552,7 @@ function createRouter(init) {
1565
1552
  // back to PUSH so that the user can use the back button to get back to
1566
1553
  // the pre-submission form location to try again
1567
1554
 
1568
- if ((opts == null ? void 0 : opts.replace) !== true) {
1555
+ if ((opts && opts.replace) !== true) {
1569
1556
  pendingAction = Action.Push;
1570
1557
  }
1571
1558
 
@@ -1609,7 +1596,7 @@ function createRouter(init) {
1609
1596
  // about to reload. Note that if this is an action reload we would have
1610
1597
  // already cancelled all pending deferreds so this would be a no-op
1611
1598
 
1612
- cancelActiveDeferreds(routeId => !(matches != null && matches.some(m => m.route.id === routeId)) || (matchesToLoad == null ? void 0 : matchesToLoad.some(m => m.route.id === routeId))); // Short circuit if we have no loaders to run
1599
+ cancelActiveDeferreds(routeId => !(matches && matches.some(m => m.route.id === routeId)) || matchesToLoad && matchesToLoad.some(m => m.route.id === routeId)); // Short circuit if we have no loaders to run
1613
1600
 
1614
1601
  if (matchesToLoad.length === 0 && revalidatingFetchers.length === 0) {
1615
1602
  completeNavigation(location, {
@@ -1630,12 +1617,11 @@ function createRouter(init) {
1630
1617
 
1631
1618
  if (!isUninterruptedRevalidation) {
1632
1619
  revalidatingFetchers.forEach(_ref2 => {
1633
- var _state$fetchers$get;
1634
-
1635
1620
  let [key] = _ref2;
1621
+ const fetcher = state.fetchers.get(key);
1636
1622
  let revalidatingFetcher = {
1637
1623
  state: "loading",
1638
- data: (_state$fetchers$get = state.fetchers.get(key)) == null ? void 0 : _state$fetchers$get.data,
1624
+ data: fetcher && fetcher.data,
1639
1625
  formMethod: undefined,
1640
1626
  formAction: undefined,
1641
1627
  formEncType: undefined,
@@ -1733,7 +1719,7 @@ function createRouter(init) {
1733
1719
  let {
1734
1720
  path,
1735
1721
  submission
1736
- } = normalizeNavigateOptions(href, opts);
1722
+ } = normalizeNavigateOptions(href, opts, true);
1737
1723
  let match = getTargetMatch(matches, path);
1738
1724
 
1739
1725
  if (submission) {
@@ -1750,8 +1736,6 @@ function createRouter(init) {
1750
1736
 
1751
1737
 
1752
1738
  async function handleFetcherAction(key, routeId, path, match, submission) {
1753
- var _state$fetchers$get2;
1754
-
1755
1739
  interruptActiveLoads();
1756
1740
  fetchLoadMatches.delete(key);
1757
1741
 
@@ -1764,10 +1748,12 @@ function createRouter(init) {
1764
1748
  } // Put this fetcher into it's submitting state
1765
1749
 
1766
1750
 
1751
+ let existingFetcher = state.fetchers.get(key);
1752
+
1767
1753
  let fetcher = _extends({
1768
1754
  state: "submitting"
1769
1755
  }, submission, {
1770
- data: ((_state$fetchers$get2 = state.fetchers.get(key)) == null ? void 0 : _state$fetchers$get2.data) || undefined
1756
+ data: existingFetcher && existingFetcher.data
1771
1757
  });
1772
1758
 
1773
1759
  state.fetchers.set(key, fetcher);
@@ -1850,12 +1836,11 @@ function createRouter(init) {
1850
1836
  let [staleKey] = _ref5;
1851
1837
  return staleKey !== key;
1852
1838
  }).forEach(_ref6 => {
1853
- var _state$fetchers$get3;
1854
-
1855
1839
  let [staleKey] = _ref6;
1840
+ let existingFetcher = state.fetchers.get(staleKey);
1856
1841
  let revalidatingFetcher = {
1857
1842
  state: "loading",
1858
- data: (_state$fetchers$get3 = state.fetchers.get(staleKey)) == null ? void 0 : _state$fetchers$get3.data,
1843
+ data: existingFetcher && existingFetcher.data,
1859
1844
  formMethod: undefined,
1860
1845
  formAction: undefined,
1861
1846
  formEncType: undefined,
@@ -1910,10 +1895,8 @@ function createRouter(init) {
1910
1895
  // navigation and complete it with the fetcher data
1911
1896
 
1912
1897
  if (state.navigation.state === "loading" && loadId > pendingNavigationLoadId) {
1913
- var _pendingNavigationCon3;
1914
-
1915
1898
  invariant(pendingAction, "Expected pending action");
1916
- (_pendingNavigationCon3 = pendingNavigationController) == null ? void 0 : _pendingNavigationCon3.abort();
1899
+ pendingNavigationController && pendingNavigationController.abort();
1917
1900
  completeNavigation(state.navigation.location, {
1918
1901
  matches,
1919
1902
  loaderData,
@@ -1936,16 +1919,15 @@ function createRouter(init) {
1936
1919
 
1937
1920
 
1938
1921
  async function handleFetcherLoader(key, routeId, path, match) {
1939
- var _state$fetchers$get4;
1922
+ let existingFetcher = state.fetchers.get(key); // Put this fetcher into it's loading state
1940
1923
 
1941
- // Put this fetcher into it's loading state
1942
1924
  let loadingFetcher = {
1943
1925
  state: "loading",
1944
1926
  formMethod: undefined,
1945
1927
  formAction: undefined,
1946
1928
  formEncType: undefined,
1947
1929
  formData: undefined,
1948
- data: ((_state$fetchers$get4 = state.fetchers.get(key)) == null ? void 0 : _state$fetchers$get4.data) || undefined
1930
+ data: existingFetcher && existingFetcher.data
1949
1931
  };
1950
1932
  state.fetchers.set(key, loadingFetcher);
1951
1933
  updateState({
@@ -2544,7 +2526,11 @@ function getStaticContextFromError(routes, context, error) {
2544
2526
  } // Normalize navigation options by converting formMethod=GET formData objects to
2545
2527
  // URLSearchParams so they behave identically to links with query params
2546
2528
 
2547
- function normalizeNavigateOptions(to, opts) {
2529
+ function normalizeNavigateOptions(to, opts, isFetcher) {
2530
+ if (isFetcher === void 0) {
2531
+ isFetcher = false;
2532
+ }
2533
+
2548
2534
  let path = typeof to === "string" ? to : createPath(to); // Return location verbatim on non-submission navigations
2549
2535
 
2550
2536
  if (!opts || !("formMethod" in opts) && !("formData" in opts)) {
@@ -2560,7 +2546,7 @@ function normalizeNavigateOptions(to, opts) {
2560
2546
  submission: {
2561
2547
  formMethod: opts.formMethod,
2562
2548
  formAction: createHref(parsePath(path)),
2563
- formEncType: (opts == null ? void 0 : opts.formEncType) || "application/x-www-form-urlencoded",
2549
+ formEncType: opts && opts.formEncType || "application/x-www-form-urlencoded",
2564
2550
  formData: opts.formData
2565
2551
  }
2566
2552
  };
@@ -2577,7 +2563,14 @@ function normalizeNavigateOptions(to, opts) {
2577
2563
  let parsedPath = parsePath(path);
2578
2564
 
2579
2565
  try {
2580
- let searchParams = convertFormDataToSearchParams(opts.formData);
2566
+ let searchParams = convertFormDataToSearchParams(opts.formData); // Since fetcher GET submissions only run a single loader (as opposed to
2567
+ // navigation GET submissions which run all loaders), we need to preserve
2568
+ // any incoming ?index params
2569
+
2570
+ if (isFetcher && parsedPath.search && hasNakedIndexQuery(parsedPath.search)) {
2571
+ searchParams.append("index", "");
2572
+ }
2573
+
2581
2574
  parsedPath.search = "?" + searchParams;
2582
2575
  } catch (e) {
2583
2576
  return {
@@ -2634,7 +2627,7 @@ function getMatchesToLoad(state, matches, submission, location, isRevalidationRe
2634
2627
  cancelledDeferredRoutes.some(id => id === match.route.id) || shouldRevalidateLoader(state.location, state.matches[index], submission, location, match, isRevalidationRequired, actionResult))); // Pick fetcher.loads that need to be revalidated
2635
2628
 
2636
2629
  let revalidatingFetchers = [];
2637
- fetchLoadMatches == null ? void 0 : fetchLoadMatches.forEach((_ref10, key) => {
2630
+ fetchLoadMatches && fetchLoadMatches.forEach((_ref10, key) => {
2638
2631
  let [href, match] = _ref10;
2639
2632
 
2640
2633
  // This fetcher was cancelled from a prior action submission - force reload
@@ -2663,12 +2656,11 @@ function isNewLoader(currentLoaderData, currentMatch, match) {
2663
2656
  }
2664
2657
 
2665
2658
  function isNewRouteInstance(currentMatch, match) {
2666
- var _currentMatch$route$p;
2667
-
2659
+ let currentPath = currentMatch.route.path;
2668
2660
  return (// param change for this match, /users/123 -> /users/456
2669
2661
  currentMatch.pathname !== match.pathname || // splat param changed, which is not present in match.path
2670
2662
  // e.g. /files/images/avatar.jpg -> files/finances.xls
2671
- ((_currentMatch$route$p = currentMatch.route.path) == null ? void 0 : _currentMatch$route$p.endsWith("*")) && currentMatch.params["*"] !== match.params["*"]
2663
+ currentPath && currentPath.endsWith("*") && currentMatch.params["*"] !== match.params["*"]
2672
2664
  );
2673
2665
  }
2674
2666
 
@@ -2741,8 +2733,6 @@ async function callLoaderOrAction(type, request, match, skipRedirects, isRouteRe
2741
2733
  }
2742
2734
 
2743
2735
  if (result instanceof Response) {
2744
- var _result$headers$get;
2745
-
2746
2736
  // Process redirects
2747
2737
  let status = result.status;
2748
2738
  let location = result.headers.get("Location"); // For SSR single-route requests, we want to hand Responses back directly
@@ -2769,8 +2759,9 @@ async function callLoaderOrAction(type, request, match, skipRedirects, isRouteRe
2769
2759
  }
2770
2760
 
2771
2761
  let data;
2762
+ let contentType = result.headers.get("Content-Type");
2772
2763
 
2773
- if ((_result$headers$get = result.headers.get("Content-Type")) != null && _result$headers$get.startsWith("application/json")) {
2764
+ if (contentType && contentType.startsWith("application/json")) {
2774
2765
  data = await result.json();
2775
2766
  } else {
2776
2767
  data = await result.text();
@@ -2882,7 +2873,7 @@ function processRouteLoaderData(matches, matchesToLoad, results, pendingError, a
2882
2873
  loaderHeaders[id] = result.headers;
2883
2874
  }
2884
2875
  } else if (isDeferredResult(result)) {
2885
- activeDeferreds == null ? void 0 : activeDeferreds.set(id, result.deferredData);
2876
+ activeDeferreds && activeDeferreds.set(id, result.deferredData);
2886
2877
  loaderData[id] = result.deferredData.data; // TODO: Add statusCode/headers once we wire up streaming in Remix
2887
2878
  } else {
2888
2879
  loaderData[id] = result.data; // Error status codes always override success status codes, but if all
@@ -2923,11 +2914,9 @@ function processLoaderData(state, matches, matchesToLoad, results, pendingError,
2923
2914
  let result = fetcherResults[index]; // Process fetcher non-redirect errors
2924
2915
 
2925
2916
  if (isErrorResult(result)) {
2926
- var _errors;
2927
-
2928
2917
  let boundaryMatch = findNearestBoundary(state.matches, match.route.id);
2929
2918
 
2930
- if (!((_errors = errors) != null && _errors[boundaryMatch.route.id])) {
2919
+ if (!(errors && errors[boundaryMatch.route.id])) {
2931
2920
  errors = _extends({}, errors, {
2932
2921
  [boundaryMatch.route.id]: result.error
2933
2922
  });
@@ -3037,7 +3026,7 @@ function isErrorResult(result) {
3037
3026
  }
3038
3027
 
3039
3028
  function isRedirectResult(result) {
3040
- return (result == null ? void 0 : result.type) === ResultType.redirect;
3029
+ return (result && result.type) === ResultType.redirect;
3041
3030
  }
3042
3031
 
3043
3032
  async function resolveDeferredResults(currentMatches, matchesToLoad, results, signal, isFetcher, currentLoaderData) {
@@ -3045,7 +3034,7 @@ async function resolveDeferredResults(currentMatches, matchesToLoad, results, si
3045
3034
  let result = results[index];
3046
3035
  let match = matchesToLoad[index];
3047
3036
  let currentMatch = currentMatches.find(m => m.route.id === match.route.id);
3048
- let isRevalidatingLoader = currentMatch != null && !isNewRouteInstance(currentMatch, match) && (currentLoaderData == null ? void 0 : currentLoaderData[match.route.id]) !== undefined;
3037
+ let isRevalidatingLoader = currentMatch != null && !isNewRouteInstance(currentMatch, match) && (currentLoaderData && currentLoaderData[match.route.id]) !== undefined;
3049
3038
 
3050
3039
  if (isDeferredResult(result) && (isFetcher || isRevalidatingLoader)) {
3051
3040
  // Note: we do not have to touch activeDeferreds here since we race them