@tanstack/react-router 0.0.1-beta.53 → 0.0.1-beta.55

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.
@@ -14,8 +14,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
14
14
 
15
15
  var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js');
16
16
  var React = require('react');
17
- var routerCore = require('@tanstack/router-core');
18
- var useStore = require('./useStore.js');
17
+ var router = require('@tanstack/router');
18
+ var reactStore = require('@tanstack/react-store');
19
19
 
20
20
  function _interopNamespace(e) {
21
21
  if (e && e.__esModule) return e;
@@ -52,7 +52,7 @@ function lazy(importer) {
52
52
  //
53
53
 
54
54
  function useLinkProps(options) {
55
- const router = useRouter();
55
+ const router$1 = useRouter();
56
56
  const {
57
57
  // custom props
58
58
  type,
@@ -84,7 +84,7 @@ function useLinkProps(options) {
84
84
  onTouchEnd,
85
85
  ...rest
86
86
  } = options;
87
- const linkInfo = router.buildLink(options);
87
+ const linkInfo = router$1.buildLink(options);
88
88
  if (linkInfo.type === 'external') {
89
89
  const {
90
90
  href
@@ -120,10 +120,10 @@ function useLinkProps(options) {
120
120
  };
121
121
 
122
122
  // Get the active props
123
- const resolvedActiveProps = isActive ? routerCore.functionalUpdate(activeProps, {}) ?? {} : {};
123
+ const resolvedActiveProps = isActive ? router.functionalUpdate(activeProps, {}) ?? {} : {};
124
124
 
125
125
  // Get the inactive props
126
- const resolvedInactiveProps = isActive ? {} : routerCore.functionalUpdate(inactiveProps, {}) ?? {};
126
+ const resolvedInactiveProps = isActive ? {} : router.functionalUpdate(inactiveProps, {}) ?? {};
127
127
  return {
128
128
  ...resolvedActiveProps,
129
129
  ...resolvedInactiveProps,
@@ -159,7 +159,7 @@ const Link = /*#__PURE__*/React__namespace.forwardRef((props, ref) => {
159
159
  });
160
160
  const matchesContext = /*#__PURE__*/React__namespace.createContext(null);
161
161
  const routerContext = /*#__PURE__*/React__namespace.createContext(null);
162
- class ReactRouter extends routerCore.Router {
162
+ class ReactRouter extends router.Router {
163
163
  constructor(opts) {
164
164
  super({
165
165
  ...opts,
@@ -177,7 +177,7 @@ function RouterProvider({
177
177
  ...rest
178
178
  }) {
179
179
  router.update(rest);
180
- const currentMatches = useStore.useStore(router.store, s => s.currentMatches, undefined);
180
+ const currentMatches = reactStore.useStore(router.store, s => s.currentMatches, undefined);
181
181
  React__namespace.useEffect(router.mount, [router]);
182
182
  return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(routerContext.Provider, {
183
183
  value: {
@@ -189,51 +189,45 @@ function RouterProvider({
189
189
  }
190
190
  function useRouter() {
191
191
  const value = React__namespace.useContext(routerContext);
192
- routerCore.warning(!value, 'useRouter must be used inside a <Router> component!');
192
+ router.warning(!value, 'useRouter must be used inside a <Router> component!');
193
193
  return value.router;
194
194
  }
195
195
  function useRouterStore(selector, shallow) {
196
196
  const router = useRouter();
197
- return useStore.useStore(router.store, selector, shallow);
197
+ return reactStore.useStore(router.store, selector, shallow);
198
198
  }
199
199
  function useMatches() {
200
200
  return React__namespace.useContext(matchesContext);
201
201
  }
202
202
  function useMatch(opts) {
203
- const router = useRouter();
203
+ const router$1 = useRouter();
204
204
  const nearestMatch = useMatches()[0];
205
- const match = opts?.from ? router.store.state.currentMatches.find(d => d.route.id === opts?.from) : nearestMatch;
206
- routerCore.invariant(match, `Could not find ${opts?.from ? `an active match from "${opts.from}"` : 'a nearest match!'}`);
205
+ const match = opts?.from ? router$1.store.state.currentMatches.find(d => d.route.id === opts?.from) : nearestMatch;
206
+ router.invariant(match, `Could not find ${opts?.from ? `an active match from "${opts.from}"` : 'a nearest match!'}`);
207
207
  if (opts?.strict ?? true) {
208
- routerCore.invariant(nearestMatch.route.id == match?.route.id, `useMatch("${match?.route.id}") is being called in a component that is meant to render the '${nearestMatch.route.id}' route. Did you mean to 'useMatch("${match?.route.id}", { strict: false })' or 'useRoute("${match?.route.id}")' instead?`);
208
+ router.invariant(nearestMatch.route.id == match?.route.id, `useMatch("${match?.route.id}") is being called in a component that is meant to render the '${nearestMatch.route.id}' route. Did you mean to 'useMatch("${match?.route.id}", { strict: false })' or 'useRoute("${match?.route.id}")' instead?`);
209
209
  }
210
- useStore.useStore(match.store, d => opts?.track?.(match) ?? match, opts?.shallow);
210
+ reactStore.useStore(match.store, d => opts?.track?.(match) ?? match, opts?.shallow);
211
211
  return match;
212
212
  }
213
213
  function useRoute(routeId) {
214
- const router = useRouter();
215
- const resolvedRoute = router.getRoute(routeId);
216
- routerCore.invariant(resolvedRoute, `Could not find a route for route "${routeId}"! Did you forget to add it to your route config?`);
214
+ const router$1 = useRouter();
215
+ const resolvedRoute = router$1.getRoute(routeId);
216
+ router.invariant(resolvedRoute, `Could not find a route for route "${routeId}"! Did you forget to add it to your route config?`);
217
217
  return resolvedRoute;
218
218
  }
219
- function useLoaderData(opts) {
220
- const match = useMatch(opts);
221
- routerCore.invariant(match, `Could not find ${opts?.from ? `an active match from "${opts.from}"` : 'a nearest match!'}`);
222
- useStore.useStore(match.store, d => opts?.track?.(d.loaderData) ?? d.loaderData);
223
- return match.store.state.loaderData;
224
- }
225
219
  function useSearch(opts) {
226
220
  const match = useMatch(opts);
227
- useStore.useStore(match.store, d => opts?.track?.(d.search) ?? d.search);
221
+ reactStore.useStore(match.store, d => opts?.track?.(d.search) ?? d.search);
228
222
  return match.store.state.search;
229
223
  }
230
224
  function useParams(opts) {
231
- const router = useRouter();
232
- useStore.useStore(router.store, d => {
233
- const params = routerCore.last(d.currentMatches)?.params;
225
+ const router$1 = useRouter();
226
+ reactStore.useStore(router$1.store, d => {
227
+ const params = router.last(d.currentMatches)?.params;
234
228
  return opts?.track?.(params) ?? params;
235
229
  });
236
- return routerCore.last(router.store.state.currentMatches)?.params;
230
+ return router.last(router$1.store.state.currentMatches)?.params;
237
231
  }
238
232
  function useNavigate(defaultOpts) {
239
233
  const router = useRouter();
@@ -284,23 +278,23 @@ function SubOutlet({
284
278
  matches,
285
279
  match
286
280
  }) {
287
- const router = useRouter();
288
- useStore.useStore(match.store);
281
+ const router$1 = useRouter();
282
+ reactStore.useStore(match.store);
289
283
  const defaultPending = React__namespace.useCallback(() => null, []);
290
284
  const Inner = React__namespace.useCallback(props => {
291
285
  if (props.match.store.state.status === 'error') {
292
286
  throw props.match.store.state.error;
293
287
  }
294
288
  if (props.match.store.state.status === 'success') {
295
- return /*#__PURE__*/React__namespace.createElement(props.match.component ?? router.options.defaultComponent ?? Outlet);
289
+ return /*#__PURE__*/React__namespace.createElement(props.match.component ?? router$1.options.defaultComponent ?? Outlet);
296
290
  }
297
- if (props.match.store.state.status === 'loading') {
291
+ if (props.match.store.state.status === 'pending') {
298
292
  throw props.match.__loadPromise;
299
293
  }
300
- routerCore.invariant(false, 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!');
294
+ router.invariant(false, 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!');
301
295
  }, []);
302
- const PendingComponent = match.pendingComponent ?? router.options.defaultPendingComponent ?? defaultPending;
303
- const errorComponent = match.errorComponent ?? router.options.defaultErrorComponent;
296
+ const PendingComponent = match.pendingComponent ?? router$1.options.defaultPendingComponent ?? defaultPending;
297
+ const errorComponent = match.errorComponent ?? router$1.options.defaultErrorComponent;
304
298
  return /*#__PURE__*/React__namespace.createElement(matchesContext.Provider, {
305
299
  value: matches
306
300
  }, /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
@@ -339,34 +333,24 @@ class CatchBoundary extends React__namespace.Component {
339
333
  // router's location key changes.
340
334
  function CatchBoundaryInner(props) {
341
335
  const [activeErrorState, setActiveErrorState] = React__namespace.useState(props.errorState);
342
- useRouter();
336
+ const router = useRouter();
343
337
  const errorComponent = props.errorComponent ?? DefaultErrorBoundary;
344
-
345
- // React.useEffect(() => {
346
- // if (activeErrorState) {
347
- // let prevKey = router.store.state.currentLocation.key
348
- // return createRoot((dispose) => {
349
- // createEffect(() => {
350
- // if (router.store.state.currentLocation.key !== prevKey) {
351
- // prevKey = router.store.state.currentLocation.key
352
- // setActiveErrorState({} as any)
353
- // }
354
- // })
355
-
356
- // return dispose
357
- // })
358
- // }
359
-
360
- // return
361
- // }, [activeErrorState])
362
-
338
+ const prevKeyRef = React__namespace.useRef('');
339
+ React__namespace.useEffect(() => {
340
+ if (activeErrorState) {
341
+ if (router.store.state.currentLocation.key !== prevKeyRef.current) {
342
+ setActiveErrorState({});
343
+ }
344
+ }
345
+ prevKeyRef.current = router.store.state.currentLocation.key;
346
+ }, [activeErrorState, router.store.state.currentLocation.key]);
363
347
  React__namespace.useEffect(() => {
364
348
  if (props.errorState.error) {
365
349
  setActiveErrorState(props.errorState);
366
350
  }
367
- props.reset();
351
+ // props.reset()
368
352
  }, [props.errorState.error]);
369
- if (props.errorState.error) {
353
+ if (props.errorState.error && activeErrorState.error) {
370
354
  return /*#__PURE__*/React__namespace.createElement(errorComponent, activeErrorState);
371
355
  }
372
356
  return props.children;
@@ -397,16 +381,6 @@ function DefaultErrorBoundary({
397
381
  }
398
382
  }, error.message) : null)));
399
383
  }
400
- function useAction(action, opts) {
401
- useStore.useStore(action.store, d => opts?.track?.(d) ?? d, true);
402
- const [ref] = React__namespace.useState({});
403
- Object.assign(ref, {
404
- ...action,
405
- latestSubmission: action.store.state.submissions[action.store.state.submissions.length - 1],
406
- pendingSubmissions: React__namespace.useMemo(() => action.store.state.submissions.filter(d => d.status === 'pending'), [action.store.state.submissions])
407
- });
408
- return ref;
409
- }
410
384
 
411
385
  // TODO: While we migrate away from the history package, these need to be disabled
412
386
  // export function usePrompt(message: string, when: boolean | any): void {
@@ -435,7 +409,10 @@ function useAction(action, opts) {
435
409
  // return (children ?? null) as ReactNode
436
410
  // }
437
411
 
438
- exports.useStore = useStore.useStore;
412
+ Object.defineProperty(exports, 'useStore', {
413
+ enumerable: true,
414
+ get: function () { return reactStore.useStore; }
415
+ });
439
416
  exports.DefaultErrorBoundary = DefaultErrorBoundary;
440
417
  exports.Link = Link;
441
418
  exports.MatchRoute = MatchRoute;
@@ -445,9 +422,7 @@ exports.RouterProvider = RouterProvider;
445
422
  exports.lazy = lazy;
446
423
  exports.matchesContext = matchesContext;
447
424
  exports.routerContext = routerContext;
448
- exports.useAction = useAction;
449
425
  exports.useLinkProps = useLinkProps;
450
- exports.useLoaderData = useLoaderData;
451
426
  exports.useMatch = useMatch;
452
427
  exports.useMatchRoute = useMatchRoute;
453
428
  exports.useMatches = useMatches;
@@ -457,10 +432,10 @@ exports.useRoute = useRoute;
457
432
  exports.useRouter = useRouter;
458
433
  exports.useRouterStore = useRouterStore;
459
434
  exports.useSearch = useSearch;
460
- Object.keys(routerCore).forEach(function (k) {
435
+ Object.keys(router).forEach(function (k) {
461
436
  if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
462
437
  enumerable: true,
463
- get: function () { return routerCore[k]; }
438
+ get: function () { return router[k]; }
464
439
  });
465
440
  });
466
441
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/index.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport {\n Route,\n RegisteredAllRouteInfo,\n RegisteredRouter,\n RouterStore,\n last,\n warning,\n RouterOptions,\n RouteMatch,\n MatchRouteOptions,\n RouteConfig,\n AnyRouteConfig,\n AnyAllRouteInfo,\n DefaultAllRouteInfo,\n functionalUpdate,\n AllRouteInfo,\n ValidFromPath,\n LinkOptions,\n RouteInfoByPath,\n ResolveRelativePath,\n NoInfer,\n ToOptions,\n invariant,\n Router,\n Expand,\n Action,\n ActionStore,\n ActionSubmission,\n} from '@tanstack/router-core'\nimport { useStore } from './useStore'\n\n//\n\nexport * from '@tanstack/router-core'\n\nexport { useStore }\n\n//\n\ntype ReactNode = any\n\nexport type SyncRouteComponent<TProps = {}> = (props: TProps) => ReactNode\n\nexport type RouteComponent<TProps = {}> = SyncRouteComponent<TProps> & {\n preload?: () => Promise<void>\n}\n\nexport function lazy(\n importer: () => Promise<{ default: SyncRouteComponent }>,\n): RouteComponent {\n const lazyComp = React.lazy(importer as any)\n let preloaded: Promise<SyncRouteComponent>\n\n const finalComp = lazyComp as unknown as RouteComponent\n\n finalComp.preload = async () => {\n if (!preloaded) {\n await importer()\n }\n }\n\n return finalComp\n}\n\nexport type LinkPropsOptions<\n TFrom extends RegisteredAllRouteInfo['routePaths'] = '/',\n TTo extends string = '.',\n> = LinkOptions<RegisteredAllRouteInfo, TFrom, TTo> & {\n // A function that returns additional props for the `active` state of this link. These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)\n activeProps?:\n | React.AnchorHTMLAttributes<HTMLAnchorElement>\n | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>)\n // A function that returns additional props for the `inactive` state of this link. These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)\n inactiveProps?:\n | React.AnchorHTMLAttributes<HTMLAnchorElement>\n | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>)\n}\n\nexport type MakeUseMatchRouteOptions<\n TFrom extends RegisteredAllRouteInfo['routePaths'] = '/',\n TTo extends string = '.',\n> = ToOptions<RegisteredAllRouteInfo, TFrom, TTo> & MatchRouteOptions\n\nexport type MakeMatchRouteOptions<\n TFrom extends RegisteredAllRouteInfo['routePaths'] = '/',\n TTo extends string = '.',\n> = ToOptions<RegisteredAllRouteInfo, TFrom, TTo> &\n MatchRouteOptions & {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?:\n | ReactNode\n | ((\n params: RouteInfoByPath<\n RegisteredAllRouteInfo,\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['allParams'],\n ) => ReactNode)\n }\n\nexport type MakeLinkPropsOptions<\n TFrom extends ValidFromPath<RegisteredAllRouteInfo> = '/',\n TTo extends string = '.',\n> = LinkPropsOptions<TFrom, TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement>\n\nexport type MakeLinkOptions<\n TFrom extends RegisteredAllRouteInfo['routePaths'] = '/',\n TTo extends string = '.',\n> = LinkPropsOptions<TFrom, TTo> &\n React.AnchorHTMLAttributes<HTMLAnchorElement> &\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?: ReactNode | ((state: { isActive: boolean }) => ReactNode)\n }\n\ndeclare module '@tanstack/router-core' {\n interface FrameworkGenerics {\n Component: RouteComponent\n ErrorComponent: RouteComponent<{\n error: unknown\n info: { componentStack: string }\n }>\n }\n\n interface RouterOptions<TRouteConfig, TRouterContext> {\n // ssrFooter?: () => JSX.Element | Node\n }\n}\n\nexport type PromptProps = {\n message: string\n when?: boolean | any\n children?: ReactNode\n}\n\n//\n\nexport function useLinkProps<\n TFrom extends ValidFromPath<RegisteredAllRouteInfo> = '/',\n TTo extends string = '.',\n>(\n options: MakeLinkPropsOptions<TFrom, TTo>,\n): React.AnchorHTMLAttributes<HTMLAnchorElement> {\n const router = useRouter()\n\n const {\n // custom props\n type,\n children,\n target,\n activeProps = () => ({ className: 'active' }),\n inactiveProps = () => ({}),\n activeOptions,\n disabled,\n // fromCurrent,\n hash,\n search,\n params,\n to = '.',\n preload,\n preloadDelay,\n preloadMaxAge,\n replace,\n // element props\n style,\n className,\n onClick,\n onFocus,\n onMouseEnter,\n onMouseLeave,\n onTouchStart,\n onTouchEnd,\n ...rest\n } = options\n\n const linkInfo = router.buildLink(options as any)\n\n if (linkInfo.type === 'external') {\n const { href } = linkInfo\n return { href }\n }\n\n const { handleClick, handleFocus, handleEnter, handleLeave, isActive, next } =\n linkInfo\n\n const reactHandleClick = (e: Event) => {\n if (React.startTransition) {\n // This is a hack for react < 18\n React.startTransition(() => {\n handleClick(e)\n })\n } else {\n handleClick(e)\n }\n }\n\n const composeHandlers =\n (handlers: (undefined | ((e: any) => void))[]) =>\n (e: React.SyntheticEvent) => {\n if (e.persist) e.persist()\n handlers.filter(Boolean).forEach((handler) => {\n if (e.defaultPrevented) return\n handler!(e)\n })\n }\n\n // Get the active props\n const resolvedActiveProps: React.HTMLAttributes<HTMLAnchorElement> = isActive\n ? functionalUpdate(activeProps as any, {}) ?? {}\n : {}\n\n // Get the inactive props\n const resolvedInactiveProps: React.HTMLAttributes<HTMLAnchorElement> =\n isActive ? {} : functionalUpdate(inactiveProps, {}) ?? {}\n\n return {\n ...resolvedActiveProps,\n ...resolvedInactiveProps,\n ...rest,\n href: disabled ? undefined : next.href,\n onClick: composeHandlers([onClick, reactHandleClick]),\n onFocus: composeHandlers([onFocus, handleFocus]),\n onMouseEnter: composeHandlers([onMouseEnter, handleEnter]),\n onMouseLeave: composeHandlers([onMouseLeave, handleLeave]),\n target,\n style: {\n ...style,\n ...resolvedActiveProps.style,\n ...resolvedInactiveProps.style,\n },\n className:\n [\n className,\n resolvedActiveProps.className,\n resolvedInactiveProps.className,\n ]\n .filter(Boolean)\n .join(' ') || undefined,\n ...(disabled\n ? {\n role: 'link',\n 'aria-disabled': true,\n }\n : undefined),\n ['data-status']: isActive ? 'active' : undefined,\n }\n}\n\nexport interface LinkFn<\n TDefaultFrom extends RegisteredAllRouteInfo['routePaths'] = '/',\n TDefaultTo extends string = '.',\n> {\n <\n TFrom extends RegisteredAllRouteInfo['routePaths'] = TDefaultFrom,\n TTo extends string = TDefaultTo,\n >(\n props: MakeLinkOptions<TFrom, TTo> & React.RefAttributes<HTMLAnchorElement>,\n ): ReactNode\n}\n\nexport const Link: LinkFn = React.forwardRef((props: any, ref) => {\n const linkProps = useLinkProps(props)\n\n return (\n <a\n {...{\n ref: ref as any,\n ...linkProps,\n children:\n typeof props.children === 'function'\n ? props.children({\n isActive: (linkProps as any)['data-status'] === 'active',\n })\n : props.children,\n }}\n />\n )\n}) as any\n\ntype MatchesContextValue = RouteMatch[]\n\nexport const matchesContext = React.createContext<MatchesContextValue>(null!)\nexport const routerContext = React.createContext<{ router: RegisteredRouter }>(\n null!,\n)\n\nexport type MatchesProviderProps = {\n value: MatchesContextValue\n children: ReactNode\n}\n\nexport class ReactRouter<\n TRouteConfig extends AnyRouteConfig = RouteConfig,\n TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>,\n TRouterContext = unknown,\n> extends Router<TRouteConfig, TAllRouteInfo, TRouterContext> {\n constructor(opts: RouterOptions<TRouteConfig, TRouterContext>) {\n super({\n ...opts,\n loadComponent: async (component) => {\n if (component.preload) {\n await component.preload()\n }\n\n return component as any\n },\n })\n }\n}\n\nexport type RouterProps<\n TRouteConfig extends AnyRouteConfig = RouteConfig,\n TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,\n TRouterContext = unknown,\n> = RouterOptions<TRouteConfig, TRouterContext> & {\n router: Router<TRouteConfig, TAllRouteInfo, TRouterContext>\n}\n\nexport function RouterProvider<\n TRouteConfig extends AnyRouteConfig = RouteConfig,\n TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,\n TRouterContext = unknown,\n>({\n router,\n ...rest\n}: RouterProps<TRouteConfig, TAllRouteInfo, TRouterContext>) {\n router.update(rest)\n\n const currentMatches = useStore(\n router.store,\n (s) => s.currentMatches,\n undefined,\n )\n\n React.useEffect(router.mount, [router])\n\n return (\n <>\n <routerContext.Provider value={{ router: router as any }}>\n <matchesContext.Provider value={[undefined!, ...currentMatches]}>\n <Outlet />\n </matchesContext.Provider>\n </routerContext.Provider>\n </>\n )\n}\n\nexport function useRouter(): RegisteredRouter {\n const value = React.useContext(routerContext)\n warning(!value, 'useRouter must be used inside a <Router> component!')\n return value.router\n}\n\nexport function useRouterStore<T = RouterStore>(\n selector?: (state: Router['store']) => T,\n shallow?: boolean,\n): T {\n const router = useRouter()\n return useStore(router.store, selector as any, shallow)\n}\n\nexport function useMatches(): RouteMatch[] {\n return React.useContext(matchesContext)\n}\n\nexport function useMatch<\n TFrom extends keyof RegisteredAllRouteInfo['routeInfoById'],\n TStrict extends boolean = true,\n TRouteMatch = RouteMatch<\n RegisteredAllRouteInfo,\n RegisteredAllRouteInfo['routeInfoById'][TFrom]\n >,\n>(opts?: {\n from: TFrom\n strict?: TStrict\n track?: (match: TRouteMatch) => any\n shallow?: boolean\n}): TStrict extends true ? TRouteMatch : TRouteMatch | undefined {\n const router = useRouter()\n const nearestMatch = useMatches()[0]!\n const match = opts?.from\n ? router.store.state.currentMatches.find((d) => d.route.id === opts?.from)\n : nearestMatch\n\n invariant(\n match,\n `Could not find ${\n opts?.from ? `an active match from \"${opts.from}\"` : 'a nearest match!'\n }`,\n )\n\n if (opts?.strict ?? true) {\n invariant(\n nearestMatch.route.id == match?.route.id,\n `useMatch(\"${\n match?.route.id as string\n }\") is being called in a component that is meant to render the '${\n nearestMatch.route.id\n }' route. Did you mean to 'useMatch(\"${\n match?.route.id as string\n }\", { strict: false })' or 'useRoute(\"${\n match?.route.id as string\n }\")' instead?`,\n )\n }\n\n useStore(\n match!.store,\n (d) => opts?.track?.(match as any) ?? match,\n opts?.shallow,\n )\n\n return match as any\n}\n\nexport function useRoute<\n TId extends keyof RegisteredAllRouteInfo['routeInfoById'] = '/',\n>(\n routeId: TId,\n): Route<RegisteredAllRouteInfo, RegisteredAllRouteInfo['routeInfoById'][TId]> {\n const router = useRouter()\n const resolvedRoute = router.getRoute(routeId as any)\n\n invariant(\n resolvedRoute,\n `Could not find a route for route \"${\n routeId as string\n }\"! Did you forget to add it to your route config?`,\n )\n\n return resolvedRoute as any\n}\n\nexport function useLoaderData<\n TFrom extends keyof RegisteredAllRouteInfo['routeInfoById'] = '/',\n TStrict extends boolean = true,\n TLoaderData = RegisteredAllRouteInfo['routeInfoById'][TFrom]['loaderData'],\n>(opts?: {\n from: TFrom\n strict?: TStrict\n track?: (loaderData: TLoaderData) => any\n}): TStrict extends true ? TLoaderData : TLoaderData | undefined {\n const match = useMatch(opts)\n\n invariant(\n match,\n `Could not find ${\n opts?.from ? `an active match from \"${opts.from}\"` : 'a nearest match!'\n }`,\n )\n\n useStore(\n (match as any).store,\n (d: any) => opts?.track?.(d.loaderData) ?? d.loaderData,\n )\n\n return (match as unknown as RouteMatch).store.state.loaderData as any\n}\n\nexport function useSearch<\n TFrom extends keyof RegisteredAllRouteInfo['routeInfoById'],\n TStrict extends boolean = true,\n TSearch = RegisteredAllRouteInfo['routeInfoById'][TFrom]['fullSearchSchema'],\n TSelected = TSearch,\n>(opts?: {\n from: TFrom\n strict?: TStrict\n track?: (search: TSearch) => TSelected\n}): TStrict extends true ? TSelected : TSelected | undefined {\n const match = useMatch(opts)\n useStore(\n (match as any).store,\n (d: any) => opts?.track?.(d.search) ?? d.search,\n )\n\n return (match as unknown as RouteMatch).store.state.search as any\n}\n\nexport function useParams<\n TFrom extends keyof RegisteredAllRouteInfo['routeInfoById'] = '/',\n TDefaultSelected = Expand<\n RegisteredAllRouteInfo['allParams'] &\n RegisteredAllRouteInfo['routeInfoById'][TFrom]['allParams']\n >,\n TSelected = TDefaultSelected,\n>(opts?: {\n from: TFrom\n track?: (search: TDefaultSelected) => TSelected\n}): TSelected {\n const router = useRouter()\n useStore(router.store, (d) => {\n const params = last(d.currentMatches)?.params as any\n return opts?.track?.(params) ?? params\n })\n\n return last(router.store.state.currentMatches)?.params as any\n}\n\nexport function useNavigate<\n TDefaultFrom extends keyof RegisteredAllRouteInfo['routeInfoById'] = '/',\n>(defaultOpts?: { from?: TDefaultFrom }) {\n const router = useRouter()\n return <\n TFrom extends keyof RegisteredAllRouteInfo['routeInfoById'] = TDefaultFrom,\n TTo extends string = '.',\n >(\n opts?: MakeLinkOptions<TFrom, TTo>,\n ) => {\n return router.navigate({ ...defaultOpts, ...(opts as any) })\n }\n}\n\nexport function useMatchRoute() {\n const router = useRouter()\n\n return <\n TFrom extends ValidFromPath<RegisteredAllRouteInfo> = '/',\n TTo extends string = '.',\n >(\n opts: MakeUseMatchRouteOptions<TFrom, TTo>,\n ) => {\n const { pending, caseSensitive, ...rest } = opts\n\n return router.matchRoute(rest as any, {\n pending,\n caseSensitive,\n })\n }\n}\n\nexport function MatchRoute<\n TFrom extends ValidFromPath<RegisteredAllRouteInfo> = '/',\n TTo extends string = '.',\n>(props: MakeMatchRouteOptions<TFrom, TTo>): any {\n const matchRoute = useMatchRoute()\n const params = matchRoute(props)\n\n if (!params) {\n return null\n }\n\n if (typeof props.children === 'function') {\n return (props.children as any)(params)\n }\n\n return params ? props.children : null\n}\n\nexport function Outlet() {\n const matches = useMatches().slice(1)\n const match = matches[0]\n\n if (!match) {\n return null\n }\n\n return <SubOutlet matches={matches} match={match} />\n}\n\nfunction SubOutlet({\n matches,\n match,\n}: {\n matches: RouteMatch[]\n match: RouteMatch\n}) {\n const router = useRouter()\n useStore(match!.store)\n\n const defaultPending = React.useCallback(() => null, [])\n\n const Inner = React.useCallback((props: { match: RouteMatch }): any => {\n if (props.match.store.state.status === 'error') {\n throw props.match.store.state.error\n }\n\n if (props.match.store.state.status === 'success') {\n return React.createElement(\n (props.match.component as any) ??\n router.options.defaultComponent ??\n Outlet,\n )\n }\n\n if (props.match.store.state.status === 'loading') {\n throw props.match.__loadPromise\n }\n\n invariant(\n false,\n 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!',\n )\n }, [])\n\n const PendingComponent = (match.pendingComponent ??\n router.options.defaultPendingComponent ??\n defaultPending) as any\n\n const errorComponent =\n match.errorComponent ?? router.options.defaultErrorComponent\n\n return (\n <matchesContext.Provider value={matches}>\n <React.Suspense fallback={<PendingComponent />}>\n <CatchBoundary\n key={match.route.id}\n errorComponent={errorComponent}\n match={match as any}\n >\n <Inner match={match} />\n </CatchBoundary>\n </React.Suspense>\n {/* Provide a suffix suspense boundary to make sure the router is\n ready to be dehydrated on the server */}\n {/* {router.options.ssrFooter && match.id === rootRouteId ? (\n <React.Suspense fallback={null}>\n {(() => {\n if (router.store.pending) {\n throw router.navigationPromise\n }\n\n return router.options.ssrFooter()\n })()}\n </React.Suspense>\n ) : null} */}\n </matchesContext.Provider>\n )\n}\n\nclass CatchBoundary extends React.Component<{\n children: any\n errorComponent: any\n match: RouteMatch\n}> {\n state = {\n error: false,\n info: undefined,\n }\n\n componentDidCatch(error: any, info: any) {\n console.error(`Error in route match: ${this.props.match.id}`)\n console.error(error)\n\n this.setState({\n error,\n info,\n })\n }\n\n render() {\n return (\n <CatchBoundaryInner\n {...this.props}\n errorState={this.state}\n reset={() => this.setState({})}\n />\n )\n }\n}\n\n// This is the messiest thing ever... I'm either seriously tired (likely) or\n// there has to be a better way to reset error boundaries when the\n// router's location key changes.\nfunction CatchBoundaryInner(props: {\n children: any\n errorComponent: any\n errorState: { error: unknown; info: any }\n reset: () => void\n}) {\n const [activeErrorState, setActiveErrorState] = React.useState(\n props.errorState,\n )\n const router = useRouter()\n const errorComponent = props.errorComponent ?? DefaultErrorBoundary\n\n // React.useEffect(() => {\n // if (activeErrorState) {\n // let prevKey = router.store.state.currentLocation.key\n // return createRoot((dispose) => {\n // createEffect(() => {\n // if (router.store.state.currentLocation.key !== prevKey) {\n // prevKey = router.store.state.currentLocation.key\n // setActiveErrorState({} as any)\n // }\n // })\n\n // return dispose\n // })\n // }\n\n // return\n // }, [activeErrorState])\n\n React.useEffect(() => {\n if (props.errorState.error) {\n setActiveErrorState(props.errorState)\n }\n props.reset()\n }, [props.errorState.error])\n\n if (props.errorState.error) {\n return React.createElement(errorComponent, activeErrorState)\n }\n\n return props.children\n}\n\nexport function DefaultErrorBoundary({ error }: { error: any }) {\n return (\n <div style={{ padding: '.5rem', maxWidth: '100%' }}>\n <strong style={{ fontSize: '1.2rem' }}>Something went wrong!</strong>\n <div style={{ height: '.5rem' }} />\n <div>\n <pre>\n {error.message ? (\n <code\n style={{\n fontSize: '.7em',\n border: '1px solid red',\n borderRadius: '.25rem',\n padding: '.5rem',\n color: 'red',\n }}\n >\n {error.message}\n </code>\n ) : null}\n </pre>\n </div>\n </div>\n )\n}\n\nexport function useAction<\n TKey extends string = string,\n TPayload = unknown,\n TResponse = unknown,\n TError = Error,\n>(\n action: Action<TKey, TPayload, TResponse, TError>,\n opts?: {\n track?: (actionStore: ActionStore<TPayload, TResponse, TError>) => any\n },\n): Action & {\n latestSubmission: ActionSubmission<TPayload, TResponse, TError>\n pendingSubmissions: ActionSubmission<TPayload, TResponse, TError>[]\n} {\n useStore(action.store, (d) => opts?.track?.(d) ?? d, true)\n\n const [ref] = React.useState({})\n\n Object.assign(ref, {\n ...action,\n latestSubmission:\n action.store.state.submissions[action.store.state.submissions.length - 1],\n pendingSubmissions: React.useMemo(\n () =>\n action.store.state.submissions.filter((d) => d.status === 'pending'),\n [action.store.state.submissions],\n ),\n })\n\n return ref as any\n}\n\n// TODO: While we migrate away from the history package, these need to be disabled\n// export function usePrompt(message: string, when: boolean | any): void {\n// const router = useRouter()\n\n// React.useEffect(() => {\n// if (!when) return\n\n// let unblock = router.getHistory().block((transition) => {\n// if (window.confirm(message)) {\n// unblock()\n// transition.retry()\n// } else {\n// router.setStore((s) => {\n// s.currentLocation.pathname = window.location.pathname\n// })\n// }\n// })\n\n// return unblock\n// }, [when, message])\n// }\n\n// export function Prompt({ message, when, children }: PromptProps) {\n// usePrompt(message, when ?? true)\n// return (children ?? null) as ReactNode\n// }\n"],"names":["lazy","importer","lazyComp","React","finalComp","preload","useLinkProps","options","router","useRouter","type","children","target","activeProps","className","inactiveProps","activeOptions","disabled","hash","search","params","to","preloadDelay","preloadMaxAge","replace","style","onClick","onFocus","onMouseEnter","onMouseLeave","onTouchStart","onTouchEnd","rest","linkInfo","buildLink","href","handleClick","handleFocus","handleEnter","handleLeave","isActive","next","reactHandleClick","e","startTransition","composeHandlers","handlers","persist","filter","Boolean","forEach","handler","defaultPrevented","resolvedActiveProps","functionalUpdate","resolvedInactiveProps","undefined","join","role","Link","forwardRef","props","ref","linkProps","_extends","matchesContext","createContext","routerContext","ReactRouter","Router","constructor","opts","loadComponent","component","RouterProvider","update","currentMatches","useStore","store","s","useEffect","mount","value","useContext","warning","useRouterStore","selector","shallow","useMatches","useMatch","nearestMatch","match","from","state","find","d","route","id","invariant","strict","track","useRoute","routeId","resolvedRoute","getRoute","useLoaderData","loaderData","useSearch","useParams","last","useNavigate","defaultOpts","navigate","useMatchRoute","pending","caseSensitive","matchRoute","MatchRoute","Outlet","matches","slice","SubOutlet","defaultPending","useCallback","Inner","status","error","createElement","defaultComponent","__loadPromise","PendingComponent","pendingComponent","defaultPendingComponent","errorComponent","defaultErrorComponent","CatchBoundary","Component","info","componentDidCatch","console","setState","render","CatchBoundaryInner","activeErrorState","setActiveErrorState","useState","errorState","DefaultErrorBoundary","reset","padding","maxWidth","fontSize","height","message","border","borderRadius","color","useAction","action","Object","assign","latestSubmission","submissions","length","pendingSubmissions","useMemo"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA;;AAUO,SAASA,IAAI,CAClBC,QAAwD,EACxC;AAChB,EAAA,MAAMC,QAAQ,gBAAGC,gBAAK,CAACH,IAAI,CAACC,QAAQ,CAAQ,CAAA;EAG5C,MAAMG,SAAS,GAAGF,QAAqC,CAAA;EAEvDE,SAAS,CAACC,OAAO,GAAG,YAAY;IACd;AACd,MAAA,MAAMJ,QAAQ,EAAE,CAAA;AAClB,KAAA;GACD,CAAA;AAED,EAAA,OAAOG,SAAS,CAAA;AAClB,CAAA;AAwEA;;AAEO,SAASE,YAAY,CAI1BC,OAAyC,EACM;EAC/C,MAAMC,MAAM,GAAGC,SAAS,EAAE,CAAA;EAE1B,MAAM;AACJ;IACAC,IAAI;IACJC,QAAQ;IACRC,MAAM;AACNC,IAAAA,WAAW,GAAG,OAAO;AAAEC,MAAAA,SAAS,EAAE,QAAA;AAAS,KAAC,CAAC;AAC7CC,IAAAA,aAAa,GAAG,OAAO,EAAE,CAAC;IAC1BC,aAAa;IACbC,QAAQ;AACR;IACAC,IAAI;IACJC,MAAM;IACNC,MAAM;AACNC,IAAAA,EAAE,GAAG,GAAG;IACRhB,OAAO;IACPiB,YAAY;IACZC,aAAa;IACbC,OAAO;AACP;IACAC,KAAK;IACLX,SAAS;IACTY,OAAO;IACPC,OAAO;IACPC,YAAY;IACZC,YAAY;IACZC,YAAY;IACZC,UAAU;I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C,CAAA;AAEhCc,EAAAA,MAAM,CAACC,MAAM,CAAClG,GAAG,EAAE;AACjB,IAAA,GAAGgG,MAAM;IACTG,gBAAgB,EACdH,MAAM,CAAChF,KAAK,CAACe,KAAK,CAACqE,WAAW,CAACJ,MAAM,CAAChF,KAAK,CAACe,KAAK,CAACqE,WAAW,CAACC,MAAM,GAAG,CAAC,CAAC;AAC3EC,IAAAA,kBAAkB,EAAEjK,gBAAK,CAACkK,OAAO,CAC/B,MACEP,MAAM,CAAChF,KAAK,CAACe,KAAK,CAACqE,WAAW,CAAClH,MAAM,CAAE+C,CAAC,IAAKA,CAAC,CAAC8B,MAAM,KAAK,SAAS,CAAC,EACtE,CAACiC,MAAM,CAAChF,KAAK,CAACe,KAAK,CAACqE,WAAW,CAAC,CAAA;AAEpC,GAAC,CAAC,CAAA;AAEF,EAAA,OAAOpG,GAAG,CAAA;AACZ,CAAA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/index.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport {\n Route,\n RegisteredAllRouteInfo,\n RegisteredRouter,\n RouterStore,\n last,\n warning,\n RouterOptions,\n RouteMatch,\n MatchRouteOptions,\n RouteConfig,\n AnyRouteConfig,\n AnyAllRouteInfo,\n DefaultAllRouteInfo,\n functionalUpdate,\n AllRouteInfo,\n ValidFromPath,\n LinkOptions,\n RouteInfoByPath,\n ResolveRelativePath,\n NoInfer,\n ToOptions,\n invariant,\n Router,\n Expand,\n} from '@tanstack/router'\nimport { useStore } from '@tanstack/react-store'\n\n//\n\nexport * from '@tanstack/router'\n\nexport { useStore }\n\n//\n\ntype ReactNode = any\n\nexport type SyncRouteComponent<TProps = {}> = (props: TProps) => ReactNode\n\nexport type RouteComponent<TProps = {}> = SyncRouteComponent<TProps> & {\n preload?: () => Promise<void>\n}\n\nexport function lazy(\n importer: () => Promise<{ default: SyncRouteComponent }>,\n): RouteComponent {\n const lazyComp = React.lazy(importer as any)\n let preloaded: Promise<SyncRouteComponent>\n\n const finalComp = lazyComp as unknown as RouteComponent\n\n finalComp.preload = async () => {\n if (!preloaded) {\n await importer()\n }\n }\n\n return finalComp\n}\n\nexport type LinkPropsOptions<\n TFrom extends RegisteredAllRouteInfo['routePaths'] = '/',\n TTo extends string = '.',\n> = LinkOptions<RegisteredAllRouteInfo, TFrom, TTo> & {\n // A function that returns additional props for the `active` state of this link. These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)\n activeProps?:\n | React.AnchorHTMLAttributes<HTMLAnchorElement>\n | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>)\n // A function that returns additional props for the `inactive` state of this link. These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)\n inactiveProps?:\n | React.AnchorHTMLAttributes<HTMLAnchorElement>\n | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>)\n}\n\nexport type MakeUseMatchRouteOptions<\n TFrom extends RegisteredAllRouteInfo['routePaths'] = '/',\n TTo extends string = '.',\n> = ToOptions<RegisteredAllRouteInfo, TFrom, TTo> & MatchRouteOptions\n\nexport type MakeMatchRouteOptions<\n TFrom extends RegisteredAllRouteInfo['routePaths'] = '/',\n TTo extends string = '.',\n> = ToOptions<RegisteredAllRouteInfo, TFrom, TTo> &\n MatchRouteOptions & {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?:\n | ReactNode\n | ((\n params: RouteInfoByPath<\n RegisteredAllRouteInfo,\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['allParams'],\n ) => ReactNode)\n }\n\nexport type MakeLinkPropsOptions<\n TFrom extends ValidFromPath<RegisteredAllRouteInfo> = '/',\n TTo extends string = '.',\n> = LinkPropsOptions<TFrom, TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement>\n\nexport type MakeLinkOptions<\n TFrom extends RegisteredAllRouteInfo['routePaths'] = '/',\n TTo extends string = '.',\n> = LinkPropsOptions<TFrom, TTo> &\n React.AnchorHTMLAttributes<HTMLAnchorElement> &\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?: ReactNode | ((state: { isActive: boolean }) => ReactNode)\n }\n\ndeclare module '@tanstack/router' {\n interface FrameworkGenerics {\n Component: RouteComponent\n ErrorComponent: RouteComponent<{\n error: unknown\n info: { componentStack: string }\n }>\n }\n\n interface RouterOptions<TRouteConfig, TRouterContext> {\n // ssrFooter?: () => JSX.Element | Node\n }\n}\n\nexport type PromptProps = {\n message: string\n when?: boolean | any\n children?: ReactNode\n}\n\n//\n\nexport function useLinkProps<\n TFrom extends ValidFromPath<RegisteredAllRouteInfo> = '/',\n TTo extends string = '.',\n>(\n options: MakeLinkPropsOptions<TFrom, TTo>,\n): React.AnchorHTMLAttributes<HTMLAnchorElement> {\n const router = useRouter()\n\n const {\n // custom props\n type,\n children,\n target,\n activeProps = () => ({ className: 'active' }),\n inactiveProps = () => ({}),\n activeOptions,\n disabled,\n // fromCurrent,\n hash,\n search,\n params,\n to = '.',\n preload,\n preloadDelay,\n preloadMaxAge,\n replace,\n // element props\n style,\n className,\n onClick,\n onFocus,\n onMouseEnter,\n onMouseLeave,\n onTouchStart,\n onTouchEnd,\n ...rest\n } = options\n\n const linkInfo = router.buildLink(options as any)\n\n if (linkInfo.type === 'external') {\n const { href } = linkInfo\n return { href }\n }\n\n const { handleClick, handleFocus, handleEnter, handleLeave, isActive, next } =\n linkInfo\n\n const reactHandleClick = (e: Event) => {\n if (React.startTransition) {\n // This is a hack for react < 18\n React.startTransition(() => {\n handleClick(e)\n })\n } else {\n handleClick(e)\n }\n }\n\n const composeHandlers =\n (handlers: (undefined | ((e: any) => void))[]) =>\n (e: React.SyntheticEvent) => {\n if (e.persist) e.persist()\n handlers.filter(Boolean).forEach((handler) => {\n if (e.defaultPrevented) return\n handler!(e)\n })\n }\n\n // Get the active props\n const resolvedActiveProps: React.HTMLAttributes<HTMLAnchorElement> = isActive\n ? functionalUpdate(activeProps as any, {}) ?? {}\n : {}\n\n // Get the inactive props\n const resolvedInactiveProps: React.HTMLAttributes<HTMLAnchorElement> =\n isActive ? {} : functionalUpdate(inactiveProps, {}) ?? {}\n\n return {\n ...resolvedActiveProps,\n ...resolvedInactiveProps,\n ...rest,\n href: disabled ? undefined : next.href,\n onClick: composeHandlers([onClick, reactHandleClick]),\n onFocus: composeHandlers([onFocus, handleFocus]),\n onMouseEnter: composeHandlers([onMouseEnter, handleEnter]),\n onMouseLeave: composeHandlers([onMouseLeave, handleLeave]),\n target,\n style: {\n ...style,\n ...resolvedActiveProps.style,\n ...resolvedInactiveProps.style,\n },\n className:\n [\n className,\n resolvedActiveProps.className,\n resolvedInactiveProps.className,\n ]\n .filter(Boolean)\n .join(' ') || undefined,\n ...(disabled\n ? {\n role: 'link',\n 'aria-disabled': true,\n }\n : undefined),\n ['data-status']: isActive ? 'active' : undefined,\n }\n}\n\nexport interface LinkFn<\n TDefaultFrom extends RegisteredAllRouteInfo['routePaths'] = '/',\n TDefaultTo extends string = '.',\n> {\n <\n TFrom extends RegisteredAllRouteInfo['routePaths'] = TDefaultFrom,\n TTo extends string = TDefaultTo,\n >(\n props: MakeLinkOptions<TFrom, TTo> & React.RefAttributes<HTMLAnchorElement>,\n ): ReactNode\n}\n\nexport const Link: LinkFn = React.forwardRef((props: any, ref) => {\n const linkProps = useLinkProps(props)\n\n return (\n <a\n {...{\n ref: ref as any,\n ...linkProps,\n children:\n typeof props.children === 'function'\n ? props.children({\n isActive: (linkProps as any)['data-status'] === 'active',\n })\n : props.children,\n }}\n />\n )\n}) as any\n\ntype MatchesContextValue = RouteMatch[]\n\nexport const matchesContext = React.createContext<MatchesContextValue>(null!)\nexport const routerContext = React.createContext<{ router: RegisteredRouter }>(\n null!,\n)\n\nexport type MatchesProviderProps = {\n value: MatchesContextValue\n children: ReactNode\n}\n\nexport class ReactRouter<\n TRouteConfig extends AnyRouteConfig = RouteConfig,\n TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>,\n TRouterContext = unknown,\n> extends Router<TRouteConfig, TAllRouteInfo, TRouterContext> {\n constructor(opts: RouterOptions<TRouteConfig, TRouterContext>) {\n super({\n ...opts,\n loadComponent: async (component) => {\n if (component.preload) {\n await component.preload()\n }\n\n return component as any\n },\n })\n }\n}\n\nexport type RouterProps<\n TRouteConfig extends AnyRouteConfig = RouteConfig,\n TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,\n TRouterContext = unknown,\n> = RouterOptions<TRouteConfig, TRouterContext> & {\n router: Router<TRouteConfig, TAllRouteInfo, TRouterContext>\n}\n\nexport function RouterProvider<\n TRouteConfig extends AnyRouteConfig = RouteConfig,\n TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,\n TRouterContext = unknown,\n>({\n router,\n ...rest\n}: RouterProps<TRouteConfig, TAllRouteInfo, TRouterContext>) {\n router.update(rest)\n\n const currentMatches = useStore(\n router.store,\n (s) => s.currentMatches,\n undefined,\n )\n\n React.useEffect(router.mount, [router])\n\n return (\n <>\n <routerContext.Provider value={{ router: router as any }}>\n <matchesContext.Provider value={[undefined!, ...currentMatches]}>\n <Outlet />\n </matchesContext.Provider>\n </routerContext.Provider>\n </>\n )\n}\n\nexport function useRouter(): RegisteredRouter {\n const value = React.useContext(routerContext)\n warning(!value, 'useRouter must be used inside a <Router> component!')\n return value.router\n}\n\nexport function useRouterStore<T = RouterStore>(\n selector?: (state: Router['store']) => T,\n shallow?: boolean,\n): T {\n const router = useRouter()\n return useStore(router.store, selector as any, shallow)\n}\n\nexport function useMatches(): RouteMatch[] {\n return React.useContext(matchesContext)\n}\n\nexport function useMatch<\n TFrom extends keyof RegisteredAllRouteInfo['routeInfoById'],\n TStrict extends boolean = true,\n TRouteMatch = RouteMatch<\n RegisteredAllRouteInfo,\n RegisteredAllRouteInfo['routeInfoById'][TFrom]\n >,\n>(opts?: {\n from: TFrom\n strict?: TStrict\n track?: (match: TRouteMatch) => any\n shallow?: boolean\n}): TStrict extends true ? TRouteMatch : TRouteMatch | undefined {\n const router = useRouter()\n const nearestMatch = useMatches()[0]!\n const match = opts?.from\n ? router.store.state.currentMatches.find((d) => d.route.id === opts?.from)\n : nearestMatch\n\n invariant(\n match,\n `Could not find ${\n opts?.from ? `an active match from \"${opts.from}\"` : 'a nearest match!'\n }`,\n )\n\n if (opts?.strict ?? true) {\n invariant(\n nearestMatch.route.id == match?.route.id,\n `useMatch(\"${\n match?.route.id as string\n }\") is being called in a component that is meant to render the '${\n nearestMatch.route.id\n }' route. Did you mean to 'useMatch(\"${\n match?.route.id as string\n }\", { strict: false })' or 'useRoute(\"${\n match?.route.id as string\n }\")' instead?`,\n )\n }\n\n useStore(\n match!.store,\n (d) => opts?.track?.(match as any) ?? match,\n opts?.shallow,\n )\n\n return match as any\n}\n\nexport function useRoute<\n TId extends keyof RegisteredAllRouteInfo['routeInfoById'] = '/',\n>(\n routeId: TId,\n): Route<RegisteredAllRouteInfo, RegisteredAllRouteInfo['routeInfoById'][TId]> {\n const router = useRouter()\n const resolvedRoute = router.getRoute(routeId as any)\n\n invariant(\n resolvedRoute,\n `Could not find a route for route \"${\n routeId as string\n }\"! Did you forget to add it to your route config?`,\n )\n\n return resolvedRoute as any\n}\n\nexport function useSearch<\n TFrom extends keyof RegisteredAllRouteInfo['routeInfoById'],\n TStrict extends boolean = true,\n TSearch = RegisteredAllRouteInfo['routeInfoById'][TFrom]['fullSearchSchema'],\n TSelected = TSearch,\n>(opts?: {\n from: TFrom\n strict?: TStrict\n track?: (search: TSearch) => TSelected\n}): TStrict extends true ? TSelected : TSelected | undefined {\n const match = useMatch(opts)\n useStore(\n (match as any).store,\n (d: any) => opts?.track?.(d.search) ?? d.search,\n )\n\n return (match as unknown as RouteMatch).store.state.search as any\n}\n\nexport function useParams<\n TFrom extends keyof RegisteredAllRouteInfo['routeInfoById'] = '/',\n TDefaultSelected = Expand<\n RegisteredAllRouteInfo['allParams'] &\n RegisteredAllRouteInfo['routeInfoById'][TFrom]['allParams']\n >,\n TSelected = TDefaultSelected,\n>(opts?: {\n from: TFrom\n track?: (search: TDefaultSelected) => TSelected\n}): TSelected {\n const router = useRouter()\n useStore(router.store, (d) => {\n const params = last(d.currentMatches)?.params as any\n return opts?.track?.(params) ?? params\n })\n\n return last(router.store.state.currentMatches)?.params as any\n}\n\nexport function useNavigate<\n TDefaultFrom extends keyof RegisteredAllRouteInfo['routeInfoById'] = '/',\n>(defaultOpts?: { from?: TDefaultFrom }) {\n const router = useRouter()\n return <\n TFrom extends keyof RegisteredAllRouteInfo['routeInfoById'] = TDefaultFrom,\n TTo extends string = '.',\n >(\n opts?: MakeLinkOptions<TFrom, TTo>,\n ) => {\n return router.navigate({ ...defaultOpts, ...(opts as any) })\n }\n}\n\nexport function useMatchRoute() {\n const router = useRouter()\n\n return <\n TFrom extends ValidFromPath<RegisteredAllRouteInfo> = '/',\n TTo extends string = '.',\n >(\n opts: MakeUseMatchRouteOptions<TFrom, TTo>,\n ) => {\n const { pending, caseSensitive, ...rest } = opts\n\n return router.matchRoute(rest as any, {\n pending,\n caseSensitive,\n })\n }\n}\n\nexport function MatchRoute<\n TFrom extends ValidFromPath<RegisteredAllRouteInfo> = '/',\n TTo extends string = '.',\n>(props: MakeMatchRouteOptions<TFrom, TTo>): any {\n const matchRoute = useMatchRoute()\n const params = matchRoute(props)\n\n if (!params) {\n return null\n }\n\n if (typeof props.children === 'function') {\n return (props.children as any)(params)\n }\n\n return params ? props.children : null\n}\n\nexport function Outlet() {\n const matches = useMatches().slice(1)\n const match = matches[0]\n\n if (!match) {\n return null\n }\n\n return <SubOutlet matches={matches} match={match} />\n}\n\nfunction SubOutlet({\n matches,\n match,\n}: {\n matches: RouteMatch[]\n match: RouteMatch\n}) {\n const router = useRouter()\n useStore(match!.store)\n\n const defaultPending = React.useCallback(() => null, [])\n\n const Inner = React.useCallback((props: { match: RouteMatch }): any => {\n if (props.match.store.state.status === 'error') {\n throw props.match.store.state.error\n }\n\n if (props.match.store.state.status === 'success') {\n return React.createElement(\n (props.match.component as any) ??\n router.options.defaultComponent ??\n Outlet,\n )\n }\n\n if (props.match.store.state.status === 'pending') {\n throw props.match.__loadPromise\n }\n\n invariant(\n false,\n 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!',\n )\n }, [])\n\n const PendingComponent = (match.pendingComponent ??\n router.options.defaultPendingComponent ??\n defaultPending) as any\n\n const errorComponent =\n match.errorComponent ?? router.options.defaultErrorComponent\n\n return (\n <matchesContext.Provider value={matches}>\n <React.Suspense fallback={<PendingComponent />}>\n <CatchBoundary\n key={match.route.id}\n errorComponent={errorComponent}\n match={match as any}\n >\n <Inner match={match} />\n </CatchBoundary>\n </React.Suspense>\n {/* Provide a suffix suspense boundary to make sure the router is\n ready to be dehydrated on the server */}\n {/* {router.options.ssrFooter && match.id === rootRouteId ? (\n <React.Suspense fallback={null}>\n {(() => {\n if (router.store.pending) {\n throw router.navigationPromise\n }\n\n return router.options.ssrFooter()\n })()}\n </React.Suspense>\n ) : null} */}\n </matchesContext.Provider>\n )\n}\n\nclass CatchBoundary extends React.Component<{\n children: any\n errorComponent: any\n match: RouteMatch\n}> {\n state = {\n error: false,\n info: undefined,\n }\n\n componentDidCatch(error: any, info: any) {\n console.error(`Error in route match: ${this.props.match.id}`)\n console.error(error)\n\n this.setState({\n error,\n info,\n })\n }\n\n render() {\n return (\n <CatchBoundaryInner\n {...this.props}\n errorState={this.state}\n reset={() => this.setState({})}\n />\n )\n }\n}\n\n// This is the messiest thing ever... I'm either seriously tired (likely) or\n// there has to be a better way to reset error boundaries when the\n// router's location key changes.\nfunction CatchBoundaryInner(props: {\n children: any\n errorComponent: any\n errorState: { error: unknown; info: any }\n reset: () => void\n}) {\n const [activeErrorState, setActiveErrorState] = React.useState(\n props.errorState,\n )\n const router = useRouter()\n const errorComponent = props.errorComponent ?? DefaultErrorBoundary\n const prevKeyRef = React.useRef('' as any)\n\n React.useEffect(() => {\n if (activeErrorState) {\n if (router.store.state.currentLocation.key !== prevKeyRef.current) {\n setActiveErrorState({} as any)\n }\n }\n\n prevKeyRef.current = router.store.state.currentLocation.key\n }, [activeErrorState, router.store.state.currentLocation.key])\n\n React.useEffect(() => {\n if (props.errorState.error) {\n setActiveErrorState(props.errorState)\n }\n // props.reset()\n }, [props.errorState.error])\n\n if (props.errorState.error && activeErrorState.error) {\n return React.createElement(errorComponent, activeErrorState)\n }\n\n return props.children\n}\n\nexport function DefaultErrorBoundary({ error }: { error: any }) {\n return (\n <div style={{ padding: '.5rem', maxWidth: '100%' }}>\n <strong style={{ fontSize: '1.2rem' }}>Something went wrong!</strong>\n <div style={{ height: '.5rem' }} />\n <div>\n <pre>\n {error.message ? (\n <code\n style={{\n fontSize: '.7em',\n border: '1px solid red',\n borderRadius: '.25rem',\n padding: '.5rem',\n color: 'red',\n }}\n >\n {error.message}\n </code>\n ) : null}\n </pre>\n </div>\n </div>\n )\n}\n\n// TODO: While we migrate away from the history package, these need to be disabled\n// export function usePrompt(message: string, when: boolean | any): void {\n// const router = useRouter()\n\n// React.useEffect(() => {\n// if (!when) return\n\n// let unblock = router.getHistory().block((transition) => {\n// if (window.confirm(message)) {\n// unblock()\n// transition.retry()\n// } else {\n// router.setStore((s) => {\n// s.currentLocation.pathname = window.location.pathname\n// })\n// }\n// })\n\n// return unblock\n// }, [when, message])\n// }\n\n// export function Prompt({ message, when, children }: PromptProps) {\n// usePrompt(message, when ?? true)\n// return (children ?? null) as ReactNode\n// }\n"],"names":["lazy","importer","lazyComp","React","finalComp","preload","useLinkProps","options","router","useRouter","type","children","target","activeProps","className","inactiveProps","activeOptions","disabled","hash","search","params","to","preloadDelay","preloadMaxAge","replace","style","onClick","onFocus","onMouseEnter","onMouseLeave","onTouchStart","onTouchEnd","rest","linkInfo","buildLink","href","handleClick","handleFocus","handleEnter","handleLeave","isActive","next","reactHandleClick","e","startTransition","composeHandlers","handlers","persist","filter","Boolean","forEach","handler","defaultPrevented","resolvedActiveProps","functionalUpdate","resolvedInactiveProps","undefined","join","role","Link","forwardRef","props","ref","linkProps","_extends","matchesContext","createContext","routerContext","ReactRouter","Router","constructor","opts","loadComponent","component","RouterProvider","update","currentMatches","useStore","store","s","useEffect","mount","value","useContext","warning","useRouterStore","selector","shallow","useMatches","useMatch","nearestMatch","match","from","state","find","d","route","id","invariant","strict","track","useRoute","routeId","resolvedRoute","getRoute","useSearch","useParams","last","useNavigate","defaultOpts","navigate","useMatchRoute","pending","caseSensitive","matchRoute","MatchRoute","Outlet","matches","slice","SubOutlet","defaultPending","useCallback","Inner","status","error","createElement","defaultComponent","__loadPromise","PendingComponent","pendingComponent","defaultPendingComponent","errorComponent","defaultErrorComponent","CatchBoundary","Component","info","componentDidCatch","console","setState","render","CatchBoundaryInner","activeErrorState","setActiveErrorState","useState","errorState","DefaultErrorBoundary","prevKeyRef","useRef","currentLocation","key","current","padding","maxWidth","fontSize","height","message","border","borderRadius","color"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA;;AAUO,SAASA,IAAI,CAClBC,QAAwD,EACxC;AAChB,EAAA,MAAMC,QAAQ,gBAAGC,gBAAK,CAACH,IAAI,CAACC,QAAQ,CAAQ,CAAA;EAG5C,MAAMG,SAAS,GAAGF,QAAqC,CAAA;EAEvDE,SAAS,CAACC,OAAO,GAAG,YAAY;IACd;AACd,MAAA,MAAMJ,QAAQ,EAAE,CAAA;AAClB,KAAA;GACD,CAAA;AAED,EAAA,OAAOG,SAAS,CAAA;AAClB,CAAA;AAwEA;;AAEO,SAASE,YAAY,CAI1BC,OAAyC,EACM;EAC/C,MAAMC,QAAM,GAAGC,SAAS,EAAE,CAAA;EAE1B,MAAM;AACJ;IACAC,IAAI;IACJC,QAAQ;IACRC,MAAM;AACNC,IAAAA,WAAW,GAAG,OAA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AAA;AAEV,CAAA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -9,9 +9,10 @@
9
9
  * @license MIT
10
10
  */
11
11
  import * as React from 'react';
12
- import { functionalUpdate, Router, warning, invariant, last } from '@tanstack/router-core';
13
- export * from '@tanstack/router-core';
14
- import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector';
12
+ import { functionalUpdate, Router, warning, invariant, last } from '@tanstack/router';
13
+ export * from '@tanstack/router';
14
+ import { useStore } from '@tanstack/react-store';
15
+ export { useStore } from '@tanstack/react-store';
15
16
 
16
17
  function _extends() {
17
18
  _extends = Object.assign ? Object.assign.bind() : function (target) {
@@ -28,52 +29,6 @@ function _extends() {
28
29
  return _extends.apply(this, arguments);
29
30
  }
30
31
 
31
- function useStore(store, selector = d => d, compareShallow) {
32
- const slice = useSyncExternalStoreWithSelector(store.subscribe, () => store.state, () => store.state, selector, compareShallow ? shallow : undefined);
33
- return slice;
34
- }
35
- function shallow(objA, objB) {
36
- if (Object.is(objA, objB)) {
37
- return true;
38
- }
39
- if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
40
- return false;
41
- }
42
-
43
- // if (objA instanceof Map && objB instanceof Map) {
44
- // if (objA.size !== objB.size) return false
45
-
46
- // for (const [key, value] of objA) {
47
- // if (!Object.is(value, objB.get(key))) {
48
- // return false
49
- // }
50
- // }
51
- // return true
52
- // }
53
-
54
- // if (objA instanceof Set && objB instanceof Set) {
55
- // if (objA.size !== objB.size) return false
56
-
57
- // for (const value of objA) {
58
- // if (!objB.has(value)) {
59
- // return false
60
- // }
61
- // }
62
- // return true
63
- // }
64
-
65
- const keysA = Object.keys(objA);
66
- if (keysA.length !== Object.keys(objB).length) {
67
- return false;
68
- }
69
- for (let i = 0; i < keysA.length; i++) {
70
- if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !Object.is(objA[keysA[i]], objB[keysA[i]])) {
71
- return false;
72
- }
73
- }
74
- return true;
75
- }
76
-
77
32
  //
78
33
 
79
34
  function lazy(importer) {
@@ -253,12 +208,6 @@ function useRoute(routeId) {
253
208
  invariant(resolvedRoute, `Could not find a route for route "${routeId}"! Did you forget to add it to your route config?`);
254
209
  return resolvedRoute;
255
210
  }
256
- function useLoaderData(opts) {
257
- const match = useMatch(opts);
258
- invariant(match, `Could not find ${opts?.from ? `an active match from "${opts.from}"` : 'a nearest match!'}`);
259
- useStore(match.store, d => opts?.track?.(d.loaderData) ?? d.loaderData);
260
- return match.store.state.loaderData;
261
- }
262
211
  function useSearch(opts) {
263
212
  const match = useMatch(opts);
264
213
  useStore(match.store, d => opts?.track?.(d.search) ?? d.search);
@@ -331,7 +280,7 @@ function SubOutlet({
331
280
  if (props.match.store.state.status === 'success') {
332
281
  return /*#__PURE__*/React.createElement(props.match.component ?? router.options.defaultComponent ?? Outlet);
333
282
  }
334
- if (props.match.store.state.status === 'loading') {
283
+ if (props.match.store.state.status === 'pending') {
335
284
  throw props.match.__loadPromise;
336
285
  }
337
286
  invariant(false, 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!');
@@ -376,34 +325,24 @@ class CatchBoundary extends React.Component {
376
325
  // router's location key changes.
377
326
  function CatchBoundaryInner(props) {
378
327
  const [activeErrorState, setActiveErrorState] = React.useState(props.errorState);
379
- useRouter();
328
+ const router = useRouter();
380
329
  const errorComponent = props.errorComponent ?? DefaultErrorBoundary;
381
-
382
- // React.useEffect(() => {
383
- // if (activeErrorState) {
384
- // let prevKey = router.store.state.currentLocation.key
385
- // return createRoot((dispose) => {
386
- // createEffect(() => {
387
- // if (router.store.state.currentLocation.key !== prevKey) {
388
- // prevKey = router.store.state.currentLocation.key
389
- // setActiveErrorState({} as any)
390
- // }
391
- // })
392
-
393
- // return dispose
394
- // })
395
- // }
396
-
397
- // return
398
- // }, [activeErrorState])
399
-
330
+ const prevKeyRef = React.useRef('');
331
+ React.useEffect(() => {
332
+ if (activeErrorState) {
333
+ if (router.store.state.currentLocation.key !== prevKeyRef.current) {
334
+ setActiveErrorState({});
335
+ }
336
+ }
337
+ prevKeyRef.current = router.store.state.currentLocation.key;
338
+ }, [activeErrorState, router.store.state.currentLocation.key]);
400
339
  React.useEffect(() => {
401
340
  if (props.errorState.error) {
402
341
  setActiveErrorState(props.errorState);
403
342
  }
404
- props.reset();
343
+ // props.reset()
405
344
  }, [props.errorState.error]);
406
- if (props.errorState.error) {
345
+ if (props.errorState.error && activeErrorState.error) {
407
346
  return /*#__PURE__*/React.createElement(errorComponent, activeErrorState);
408
347
  }
409
348
  return props.children;
@@ -434,16 +373,6 @@ function DefaultErrorBoundary({
434
373
  }
435
374
  }, error.message) : null)));
436
375
  }
437
- function useAction(action, opts) {
438
- useStore(action.store, d => opts?.track?.(d) ?? d, true);
439
- const [ref] = React.useState({});
440
- Object.assign(ref, {
441
- ...action,
442
- latestSubmission: action.store.state.submissions[action.store.state.submissions.length - 1],
443
- pendingSubmissions: React.useMemo(() => action.store.state.submissions.filter(d => d.status === 'pending'), [action.store.state.submissions])
444
- });
445
- return ref;
446
- }
447
376
 
448
377
  // TODO: While we migrate away from the history package, these need to be disabled
449
378
  // export function usePrompt(message: string, when: boolean | any): void {
@@ -472,5 +401,5 @@ function useAction(action, opts) {
472
401
  // return (children ?? null) as ReactNode
473
402
  // }
474
403
 
475
- export { DefaultErrorBoundary, Link, MatchRoute, Outlet, ReactRouter, RouterProvider, lazy, matchesContext, routerContext, useAction, useLinkProps, useLoaderData, useMatch, useMatchRoute, useMatches, useNavigate, useParams, useRoute, useRouter, useRouterStore, useSearch, useStore };
404
+ export { DefaultErrorBoundary, Link, MatchRoute, Outlet, ReactRouter, RouterProvider, lazy, matchesContext, routerContext, useLinkProps, useMatch, useMatchRoute, useMatches, useNavigate, useParams, useRoute, useRouter, useRouterStore, useSearch };
476
405
  //# sourceMappingURL=index.js.map