@tanstack/react-router 0.0.1-beta.5 → 0.0.1-beta.7

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.
@@ -975,6 +975,12 @@ function functionalUpdate(updater, previous) {
975
975
 
976
976
  return updater;
977
977
  }
978
+ function pick(parent, keys) {
979
+ return keys.reduce((obj, key) => {
980
+ obj[key] = parent[key];
981
+ return obj;
982
+ }, {});
983
+ }
978
984
 
979
985
  function joinPaths(paths) {
980
986
  return cleanPath(paths.filter(Boolean).join('/'));
@@ -1792,6 +1798,25 @@ function createRouter(userOptions) {
1792
1798
  cascadeLoaderData(router.state.matches);
1793
1799
  router.listeners.forEach(listener => listener(router));
1794
1800
  },
1801
+ dehydrateState: () => {
1802
+ return _extends({}, pick(router.state, ['status', 'location', 'lastUpdated']), {
1803
+ matches: router.state.matches.map(match => pick(match, ['matchId', 'status', 'routeLoaderData', 'loaderData', 'isInvalid', 'invalidAt']))
1804
+ });
1805
+ },
1806
+ hydrateState: dehydratedState => {
1807
+ // Match the routes
1808
+ const matches = router.matchRoutes(router.location.pathname, {
1809
+ strictParseParams: true
1810
+ });
1811
+ router.state = _extends({}, router.state, dehydratedState, {
1812
+ matches: matches.map(match => {
1813
+ const dehydratedMatch = dehydratedState.matches.find(d => d.matchId === match.matchId);
1814
+ invariant(dehydratedMatch, 'Oh no! Dehydrated route matches did not match the active state of the router 😬');
1815
+ Object.assign(match, dehydratedMatch);
1816
+ return match;
1817
+ })
1818
+ });
1819
+ },
1795
1820
  mount: () => {
1796
1821
  const next = router.__.buildLocation({
1797
1822
  to: '.',
@@ -2351,11 +2376,7 @@ function createRouter(userOptions) {
2351
2376
  const recurseRoutes = (routeConfigs, parent) => {
2352
2377
  return routeConfigs.map(routeConfig => {
2353
2378
  const routeOptions = routeConfig.options;
2354
- const route = createRoute(routeConfig, routeOptions, parent, router); // {
2355
- // pendingMs: routeOptions.pendingMs ?? router.defaultPendingMs,
2356
- // pendingMinMs: routeOptions.pendingMinMs ?? router.defaultPendingMinMs,
2357
- // }
2358
-
2379
+ const route = createRoute(routeConfig, routeOptions, parent, router);
2359
2380
  const existingRoute = router.routesById[route.routeId];
2360
2381
 
2361
2382
  if (existingRoute) {
@@ -2794,13 +2815,6 @@ class CatchBoundary extends React.Component {
2794
2815
  this.state = {
2795
2816
  error: false
2796
2817
  };
2797
-
2798
- this.reset = () => {
2799
- this.setState({
2800
- error: false,
2801
- info: false
2802
- });
2803
- };
2804
2818
  }
2805
2819
 
2806
2820
  componentDidCatch(error, info) {
@@ -2888,5 +2902,5 @@ function Prompt(_ref6) {
2888
2902
  return children != null ? children : null;
2889
2903
  }
2890
2904
 
2891
- export { DefaultErrorBoundary, MatchesProvider, Outlet, Prompt, RouterProvider, cascadeLoaderData, cleanPath, createBrowserHistory, createHashHistory, createMemoryHistory, createReactRouter, createRoute, createRouteConfig, createRouteMatch, createRouter, decode, defaultParseSearch, defaultStringifySearch, encode, functionalUpdate, interpolatePath, invariant, joinPaths, last, matchByPath, matchPathname, parsePathname, parseSearchWith, replaceEqualDeep, resolvePath, rootRouteId, stringifySearchWith, trimPath, trimPathLeft, trimPathRight, usePrompt, warning };
2905
+ export { DefaultErrorBoundary, MatchesProvider, Outlet, Prompt, RouterProvider, cascadeLoaderData, cleanPath, createBrowserHistory, createHashHistory, createMemoryHistory, createReactRouter, createRoute, createRouteConfig, createRouteMatch, createRouter, decode, defaultParseSearch, defaultStringifySearch, encode, functionalUpdate, interpolatePath, invariant, joinPaths, last, matchByPath, matchPathname, parsePathname, parseSearchWith, pick, replaceEqualDeep, resolvePath, rootRouteId, stringifySearchWith, trimPath, trimPathLeft, trimPathRight, usePrompt, warning };
2892
2906
  //# sourceMappingURL=index.js.map