@remix-run/router 0.0.0-experimental-4a8a492a → 0.0.0-experimental-e0f088aa

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @remix-run/router v0.0.0-experimental-4a8a492a
2
+ * @remix-run/router v0.0.0-experimental-e0f088aa
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1883,8 +1883,17 @@
1883
1883
  function updateState(newState, viewTransitionOpts) {
1884
1884
  state = _extends({}, state, newState);
1885
1885
  subscribers.forEach(subscriber => subscriber(state, {
1886
- viewTransitionOpts
1886
+ unstable_viewTransitionOpts: viewTransitionOpts
1887
1887
  }));
1888
+
1889
+ // Remove idle fetchers from state since we only care about in-flight fetchers.
1890
+ // We keep fetchLoadeMatches around for revalidations purposes.
1891
+ // The React layer persists the data for completed fetchers.
1892
+ state.fetchers.forEach((fetcher, key) => {
1893
+ if (fetcher.state === "idle") {
1894
+ state.fetchers.delete(key);
1895
+ }
1896
+ });
1888
1897
  }
1889
1898
 
1890
1899
  // Complete a navigation returning the state.navigation back to the IDLE_NAVIGATION
@@ -2436,9 +2445,6 @@
2436
2445
  fetchers: new Map(state.fetchers)
2437
2446
  } : {});
2438
2447
  }
2439
- function getFetcher(key) {
2440
- return state.fetchers.get(key) || IDLE_FETCHER;
2441
- }
2442
2448
 
2443
2449
  // Trigger a fetcher load/submit for the given fetcher key
2444
2450
  function fetch(key, routeId, href, opts) {
@@ -2626,7 +2632,7 @@
2626
2632
  let doneFetcher = getDoneFetcher(actionResult.data);
2627
2633
  state.fetchers.set(key, doneFetcher);
2628
2634
  }
2629
- let didAbortFetchLoads = abortStaleFetchLoads(loadId);
2635
+ abortStaleFetchLoads(loadId);
2630
2636
 
2631
2637
  // If we are currently in a navigation loading state and this fetcher is
2632
2638
  // more recent than the navigation, we want the newer data so abort the
@@ -2644,12 +2650,11 @@
2644
2650
  // otherwise just update with the fetcher data, preserving any existing
2645
2651
  // loaderData for loaders that did not need to reload. We have to
2646
2652
  // manually merge here since we aren't going through completeNavigation
2647
- updateState(_extends({
2653
+ updateState({
2648
2654
  errors,
2649
- loaderData: mergeLoaderData(state.loaderData, loaderData, matches, errors)
2650
- }, didAbortFetchLoads || revalidatingFetchers.length > 0 ? {
2655
+ loaderData: mergeLoaderData(state.loaderData, loaderData, matches, errors),
2651
2656
  fetchers: new Map(state.fetchers)
2652
- } : {}));
2657
+ });
2653
2658
  isRevalidationRequired = false;
2654
2659
  }
2655
2660
  }
@@ -2881,6 +2886,7 @@
2881
2886
  }
2882
2887
  function deleteFetcher(key) {
2883
2888
  let fetcher = state.fetchers.get(key);
2889
+
2884
2890
  // Don't abort the controller if this is a deletion of a fetcher.submit()
2885
2891
  // in it's loading phase since - we don't want to abort the corresponding
2886
2892
  // revalidation and want them to complete and land
@@ -2900,8 +2906,8 @@
2900
2906
  }
2901
2907
  function markFetchersDone(keys) {
2902
2908
  for (let key of keys) {
2903
- let fetcher = getFetcher(key);
2904
- let doneFetcher = getDoneFetcher(fetcher.data);
2909
+ let fetcher = state.fetchers.get(key);
2910
+ let doneFetcher = getDoneFetcher(fetcher ? fetcher.data : undefined);
2905
2911
  state.fetchers.set(key, doneFetcher);
2906
2912
  }
2907
2913
  }
@@ -3072,6 +3078,9 @@
3072
3078
  get routes() {
3073
3079
  return dataRoutes;
3074
3080
  },
3081
+ get window() {
3082
+ return routerWindow;
3083
+ },
3075
3084
  initialize,
3076
3085
  subscribe,
3077
3086
  enableScrollRestoration,
@@ -3082,7 +3091,6 @@
3082
3091
  // hash-aware URLs in DOM paths
3083
3092
  createHref: to => init.history.createHref(to),
3084
3093
  encodeLocation: to => init.history.encodeLocation(to),
3085
- getFetcher,
3086
3094
  deleteFetcher,
3087
3095
  dispose,
3088
3096
  getBlocker,
@@ -4268,7 +4276,7 @@
4268
4276
  }
4269
4277
  function getShortCircuitMatches(routes) {
4270
4278
  // Prefer a root layout route if present, otherwise shim in a route object
4271
- let route = routes.find(r => r.index || !r.path || r.path === "/") || {
4279
+ let route = routes.length === 1 ? routes[0] : routes.find(r => r.index || !r.path || r.path === "/") || {
4272
4280
  id: "__shim-error-route__"
4273
4281
  };
4274
4282
  return {