@tanstack/react-router 0.0.1-beta.208 → 0.0.1-beta.209

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.
@@ -488,7 +488,7 @@ class Router {
488
488
  constructor(options) {
489
489
  this.options = {
490
490
  defaultPreloadDelay: 50,
491
- meta: undefined,
491
+ context: undefined,
492
492
  ...options,
493
493
  stringifySearch: options?.stringifySearch ?? defaultStringifySearch,
494
494
  parseSearch: options?.parseSearch ?? defaultParseSearch
@@ -692,9 +692,9 @@ function RouterProvider({
692
692
  const options = {
693
693
  ...router.options,
694
694
  ...rest,
695
- meta: {
696
- ...router.options.meta,
697
- ...rest?.meta
695
+ context: {
696
+ ...router.options.context,
697
+ ...rest?.context
698
698
  }
699
699
  };
700
700
  const history = React.useState(() => options.history ?? createBrowserHistory())[0];
@@ -903,16 +903,16 @@ function RouterProvider({
903
903
  paramsError: parseErrors[index],
904
904
  searchError: undefined,
905
905
  loadPromise: Promise.resolve(),
906
- meta: undefined,
906
+ context: undefined,
907
907
  abortController: new AbortController(),
908
908
  fetchedAt: 0
909
909
  };
910
910
  return routeMatch;
911
911
  });
912
912
 
913
- // Take each match and resolve its search params and meta
913
+ // Take each match and resolve its search params and context
914
914
  // This has to happen after the matches are created or found
915
- // so that we can use the parent match's search params and meta
915
+ // so that we can use the parent match's search params and context
916
916
  matches.forEach((match, i) => {
917
917
  const parentMatch = matches[i - 1];
918
918
  const route = looseRoutesById[match.routeId];
@@ -1166,13 +1166,13 @@ function RouterProvider({
1166
1166
  if (match.searchError) {
1167
1167
  handleError(match.searchError, 'VALIDATE_SEARCH');
1168
1168
  }
1169
- const parentMeta = parentMatch?.meta ?? options.meta ?? {};
1170
- const beforeLoadMeta = (await route.options.beforeLoad?.({
1169
+ const parentContext = parentMatch?.context ?? options.context ?? {};
1170
+ const beforeLoadContext = (await route.options.beforeLoad?.({
1171
1171
  search: match.search,
1172
1172
  abortController: match.abortController,
1173
1173
  params: match.params,
1174
1174
  preload: !!preload,
1175
- meta: parentMeta,
1175
+ context: parentContext,
1176
1176
  location: state.location,
1177
1177
  // TODO: This might need to be latestLocationRef.current...?
1178
1178
  navigate: opts => navigate({
@@ -1180,13 +1180,13 @@ function RouterProvider({
1180
1180
  from: match.pathname
1181
1181
  })
1182
1182
  })) ?? {};
1183
- const meta = {
1184
- ...parentMeta,
1185
- ...beforeLoadMeta
1183
+ const context = {
1184
+ ...parentContext,
1185
+ ...beforeLoadContext
1186
1186
  };
1187
1187
  matches[index] = match = {
1188
1188
  ...match,
1189
- meta: replaceEqualDeep(match.meta, meta)
1189
+ context: replaceEqualDeep(match.context, context)
1190
1190
  };
1191
1191
  } catch (err) {
1192
1192
  handleError(err, 'BEFORE_LOAD');
@@ -1232,7 +1232,7 @@ function RouterProvider({
1232
1232
  preload: !!preload,
1233
1233
  parentMatchPromise,
1234
1234
  abortController: match.abortController,
1235
- meta: match.meta,
1235
+ context: match.context,
1236
1236
  location: state.location,
1237
1237
  navigate: opts => navigate({
1238
1238
  ...opts,
@@ -1787,10 +1787,10 @@ function useMatch(opts) {
1787
1787
  });
1788
1788
  return matchSelection;
1789
1789
  }
1790
- function useRouteMeta(opts) {
1790
+ function useRouteContext(opts) {
1791
1791
  return useMatch({
1792
1792
  ...opts,
1793
- select: match => opts?.select ? opts.select(match.meta) : match.meta
1793
+ select: match => opts?.select ? opts.select(match.context) : match.context
1794
1794
  });
1795
1795
  }
1796
1796
  function useSearch(opts) {
@@ -1867,7 +1867,7 @@ function Matches() {
1867
1867
  return /*#__PURE__*/React.createElement(ErrorComponent, {
1868
1868
  ...props,
1869
1869
  useMatch: route.useMatch,
1870
- useRouteMeta: route.useRouteMeta,
1870
+ useRouteContext: route.useRouteContext,
1871
1871
  useSearch: route.useSearch,
1872
1872
  useParams: route.useParams
1873
1873
  });
@@ -1923,7 +1923,7 @@ function Match({
1923
1923
  return /*#__PURE__*/React.createElement(routeErrorComponent, {
1924
1924
  ...props,
1925
1925
  useMatch: route.useMatch,
1926
- useRouteMeta: route.useRouteMeta,
1926
+ useRouteContext: route.useRouteContext,
1927
1927
  useSearch: route.useSearch,
1928
1928
  useParams: route.useParams
1929
1929
  });
@@ -1933,7 +1933,7 @@ function Match({
1933
1933
  }, /*#__PURE__*/React.createElement(ResolvedSuspenseBoundary, {
1934
1934
  fallback: /*#__PURE__*/React.createElement(PendingComponent, {
1935
1935
  useMatch: route.useMatch,
1936
- useRouteMeta: route.useRouteMeta,
1936
+ useRouteContext: route.useRouteContext,
1937
1937
  useSearch: route.useSearch,
1938
1938
  useParams: route.useParams
1939
1939
  })
@@ -1966,7 +1966,7 @@ function MatchInner({
1966
1966
  if (comp) {
1967
1967
  return /*#__PURE__*/React.createElement(comp, {
1968
1968
  useMatch: route.useMatch,
1969
- useRouteMeta: route.useRouteMeta,
1969
+ useRouteContext: route.useRouteContext,
1970
1970
  useSearch: route.useSearch,
1971
1971
  useParams: route.useParams
1972
1972
  });
@@ -2142,14 +2142,8 @@ function shallow(objA, objB) {
2142
2142
 
2143
2143
  const rootRouteId = '__root__';
2144
2144
 
2145
- // export type MetaOptions = keyof PickRequired<RouteMeta> extends never
2146
- // ? {
2147
- // meta?: RouteMeta
2148
- // }
2149
- // : {
2150
- // meta: RouteMeta
2151
- // }
2152
2145
  // The parse type here allows a zod schema to be passed directly to the validator
2146
+
2153
2147
  class Route {
2154
2148
  // Set up in this.init()
2155
2149
 
@@ -2213,11 +2207,11 @@ class Route {
2213
2207
  from: this.id
2214
2208
  });
2215
2209
  };
2216
- useRouteMeta = opts => {
2210
+ useRouteContext = opts => {
2217
2211
  return useMatch({
2218
2212
  ...opts,
2219
2213
  from: this.id,
2220
- select: d => opts?.select ? opts.select(d.meta) : d.meta
2214
+ select: d => opts?.select ? opts.select(d.context) : d.context
2221
2215
  });
2222
2216
  };
2223
2217
  useSearch = opts => {
@@ -2233,9 +2227,8 @@ class Route {
2233
2227
  });
2234
2228
  };
2235
2229
  }
2236
- class RouterMeta {
2237
- constructor() {}
2238
- createRootRoute = options => {
2230
+ function rootRouteWithContext() {
2231
+ return options => {
2239
2232
  return new RootRoute(options);
2240
2233
  };
2241
2234
  }
@@ -2259,5 +2252,5 @@ class FileRoute {
2259
2252
  };
2260
2253
  }
2261
2254
 
2262
- export { Block, CatchBoundary, CatchBoundaryImpl, ErrorComponent, FileRoute, Link, MatchRoute, Matches, Navigate, Outlet, PathParamError, RootRoute, Route, Router, RouterMeta, RouterProvider, SearchParamError, cleanPath, componentTypes, createRouteMask, decode, defaultParseSearch, defaultStringifySearch, encode, functionalUpdate, getInitialRouterState, getRouteMatch, interpolatePath, isPlainObject, isRedirect, isServer, joinPaths, last, lazyFn, lazyRouteComponent, matchByPath, matchPathname, matchesContext, parsePathname, parseSearchWith, partialDeepEqual, pick, redirect, replaceEqualDeep, resolvePath, rootRouteId, routerContext, shallow, stringifySearchWith, trimPath, trimPathLeft, trimPathRight, typedNavigate, useBlocker, useLinkProps, useMatch, useMatchRoute, useMatches, useNavigate, useParams, useRouteMeta, useRouter, useRouterState, useSearch, useStableCallback };
2255
+ export { Block, CatchBoundary, CatchBoundaryImpl, ErrorComponent, FileRoute, Link, MatchRoute, Matches, Navigate, Outlet, PathParamError, RootRoute, Route, Router, RouterProvider, SearchParamError, cleanPath, componentTypes, createRouteMask, decode, defaultParseSearch, defaultStringifySearch, encode, functionalUpdate, getInitialRouterState, getRouteMatch, interpolatePath, isPlainObject, isRedirect, isServer, joinPaths, last, lazyFn, lazyRouteComponent, matchByPath, matchPathname, matchesContext, parsePathname, parseSearchWith, partialDeepEqual, pick, redirect, replaceEqualDeep, resolvePath, rootRouteId, rootRouteWithContext, routerContext, shallow, stringifySearchWith, trimPath, trimPathLeft, trimPathRight, typedNavigate, useBlocker, useLinkProps, useMatch, useMatchRoute, useMatches, useNavigate, useParams, useRouteContext, useRouter, useRouterState, useSearch, useStableCallback };
2263
2256
  //# sourceMappingURL=index.js.map