@tanstack/react-router 0.0.1-beta.61 → 0.0.1-beta.63

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.
@@ -52,7 +52,7 @@ function lazy(importer) {
52
52
  //
53
53
 
54
54
  function useLinkProps(options) {
55
- const router$1 = useRouter();
55
+ const router$1 = useRouterContext();
56
56
  const {
57
57
  // custom props
58
58
  type,
@@ -177,7 +177,7 @@ function RouterProvider({
177
177
  ...rest
178
178
  }) {
179
179
  router.update(rest);
180
- const currentMatches = reactStore.useStore(router.store, s => s.currentMatches, undefined);
180
+ const currentMatches = reactStore.useStore(router.store, s => s.currentMatches);
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: {
@@ -187,22 +187,24 @@ function RouterProvider({
187
187
  value: [undefined, ...currentMatches]
188
188
  }, /*#__PURE__*/React__namespace.createElement(Outlet, null))));
189
189
  }
190
- function useRouter() {
190
+ function useRouterContext() {
191
191
  const value = React__namespace.useContext(routerContext);
192
192
  router.warning(!value, 'useRouter must be used inside a <Router> component!');
193
+ reactStore.useStore(value.router.store);
193
194
  return value.router;
194
195
  }
195
- function useRouterStore(selector, shallow) {
196
- const router = useRouter();
197
- return reactStore.useStore(router.store, selector, shallow);
196
+ function useRouter(track, shallow) {
197
+ const router = useRouterContext();
198
+ reactStore.useStore(router.store, track, shallow);
199
+ return router;
198
200
  }
199
201
  function useMatches() {
200
202
  return React__namespace.useContext(matchesContext);
201
203
  }
202
204
  function useMatch(opts) {
203
- const router$1 = useRouter();
205
+ const router$1 = useRouterContext();
204
206
  const nearestMatch = useMatches()[0];
205
- const match = opts?.from ? router$1.store.state.currentMatches.find(d => d.route.id === opts?.from) : nearestMatch;
207
+ const match = opts?.from ? router$1.state.currentMatches.find(d => d.route.id === opts?.from) : nearestMatch;
206
208
  router.invariant(match, `Could not find ${opts?.from ? `an active match from "${opts.from}"` : 'a nearest match!'}`);
207
209
  if (opts?.strict ?? true) {
208
210
  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?`);
@@ -211,26 +213,26 @@ function useMatch(opts) {
211
213
  return match;
212
214
  }
213
215
  function useRoute(routeId) {
214
- const router$1 = useRouter();
216
+ const router$1 = useRouterContext();
215
217
  const resolvedRoute = router$1.getRoute(routeId);
216
218
  router.invariant(resolvedRoute, `Could not find a route for route "${routeId}"! Did you forget to add it to your route config?`);
217
219
  return resolvedRoute;
218
220
  }
219
221
  function useSearch(opts) {
220
222
  const match = useMatch(opts);
221
- reactStore.useStore(match.store, d => opts?.track?.(d.search) ?? d.search);
222
- return match.store.state.search;
223
+ reactStore.useStore(match.store, d => opts?.track?.(d.search) ?? d.search, true);
224
+ return match.state.search;
223
225
  }
224
226
  function useParams(opts) {
225
- const router$1 = useRouter();
227
+ const router$1 = useRouterContext();
226
228
  reactStore.useStore(router$1.store, d => {
227
229
  const params = router.last(d.currentMatches)?.params;
228
230
  return opts?.track?.(params) ?? params;
229
- });
230
- return router.last(router$1.store.state.currentMatches)?.params;
231
+ }, true);
232
+ return router.last(router$1.state.currentMatches)?.params;
231
233
  }
232
234
  function useNavigate(defaultOpts) {
233
- const router = useRouter();
235
+ const router = useRouterContext();
234
236
  return opts => {
235
237
  return router.navigate({
236
238
  ...defaultOpts,
@@ -239,7 +241,7 @@ function useNavigate(defaultOpts) {
239
241
  };
240
242
  }
241
243
  function useMatchRoute() {
242
- const router = useRouter();
244
+ const router = useRouterContext();
243
245
  return opts => {
244
246
  const {
245
247
  pending,
@@ -278,17 +280,17 @@ function SubOutlet({
278
280
  matches,
279
281
  match
280
282
  }) {
281
- const router$1 = useRouter();
282
- reactStore.useStore(match.store);
283
+ const router$1 = useRouterContext();
284
+ reactStore.useStore(match.store, store => [store.status, store.error], true);
283
285
  const defaultPending = React__namespace.useCallback(() => null, []);
284
286
  const Inner = React__namespace.useCallback(props => {
285
- if (props.match.store.state.status === 'error') {
286
- throw props.match.store.state.error;
287
+ if (props.match.state.status === 'error') {
288
+ throw props.match.state.error;
287
289
  }
288
- if (props.match.store.state.status === 'success') {
290
+ if (props.match.state.status === 'success') {
289
291
  return /*#__PURE__*/React__namespace.createElement(props.match.component ?? router$1.options.defaultComponent ?? Outlet);
290
292
  }
291
- if (props.match.store.state.status === 'pending') {
293
+ if (props.match.state.status === 'pending') {
292
294
  throw props.match.__loadPromise;
293
295
  }
294
296
  router.invariant(false, 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!');
@@ -297,7 +299,7 @@ function SubOutlet({
297
299
  const errorComponent = match.errorComponent ?? router$1.options.defaultErrorComponent;
298
300
  return /*#__PURE__*/React__namespace.createElement(matchesContext.Provider, {
299
301
  value: matches
300
- }, /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
302
+ }, match.route.options.wrapInSuspense ?? true ? /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
301
303
  fallback: /*#__PURE__*/React__namespace.createElement(PendingComponent, null)
302
304
  }, /*#__PURE__*/React__namespace.createElement(CatchBoundary, {
303
305
  key: match.route.id,
@@ -305,7 +307,13 @@ function SubOutlet({
305
307
  match: match
306
308
  }, /*#__PURE__*/React__namespace.createElement(Inner, {
307
309
  match: match
308
- }))));
310
+ }))) : /*#__PURE__*/React__namespace.createElement(CatchBoundary, {
311
+ key: match.route.id,
312
+ errorComponent: errorComponent,
313
+ match: match
314
+ }, /*#__PURE__*/React__namespace.createElement(Inner, {
315
+ match: match
316
+ })));
309
317
  }
310
318
 
311
319
  // This is the messiest thing ever... I'm either seriously tired (likely) or
@@ -334,17 +342,17 @@ class CatchBoundary extends React__namespace.Component {
334
342
  }
335
343
  function CatchBoundaryInner(props) {
336
344
  const [activeErrorState, setActiveErrorState] = React__namespace.useState(props.errorState);
337
- const router = useRouter();
345
+ const router = useRouterContext();
338
346
  const errorComponent = props.errorComponent ?? DefaultErrorBoundary;
339
347
  const prevKeyRef = React__namespace.useRef('');
340
348
  React__namespace.useEffect(() => {
341
349
  if (activeErrorState) {
342
- if (router.store.state.currentLocation.key !== prevKeyRef.current) {
350
+ if (router.state.currentLocation.key !== prevKeyRef.current) {
343
351
  setActiveErrorState({});
344
352
  }
345
353
  }
346
- prevKeyRef.current = router.store.state.currentLocation.key;
347
- }, [activeErrorState, router.store.state.currentLocation.key]);
354
+ prevKeyRef.current = router.state.currentLocation.key;
355
+ }, [activeErrorState, router.state.currentLocation.key]);
348
356
  React__namespace.useEffect(() => {
349
357
  if (props.errorState.error) {
350
358
  setActiveErrorState(props.errorState);
@@ -431,7 +439,7 @@ exports.useNavigate = useNavigate;
431
439
  exports.useParams = useParams;
432
440
  exports.useRoute = useRoute;
433
441
  exports.useRouter = useRouter;
434
- exports.useRouterStore = useRouterStore;
442
+ exports.useRouterContext = useRouterContext;
435
443
  exports.useSearch = useSearch;
436
444
  Object.keys(router).forEach(function (k) {
437
445
  if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/index.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport {\n Route,\n RegisteredRoutesInfo,\n RegisteredRouter,\n RouterStore,\n last,\n warning,\n RouterOptions,\n RouteMatch,\n MatchRouteOptions,\n AnyRoute,\n AnyRoutesInfo,\n DefaultRoutesInfo,\n functionalUpdate,\n RoutesInfo,\n ValidFromPath,\n LinkOptions,\n RouteByPath,\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 RegisteredRoutesInfo['routePaths'] = '/',\n TTo extends string = '.',\n> = LinkOptions<RegisteredRoutesInfo, 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 RegisteredRoutesInfo['routePaths'] = '/',\n TTo extends string = '.',\n> = ToOptions<RegisteredRoutesInfo, TFrom, TTo> & MatchRouteOptions\n\nexport type MakeMatchRouteOptions<\n TFrom extends RegisteredRoutesInfo['routePaths'] = '/',\n TTo extends string = '.',\n> = ToOptions<RegisteredRoutesInfo, 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: RouteByPath<\n RegisteredRoutesInfo,\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['__types']['allParams'],\n ) => ReactNode)\n }\n\nexport type MakeLinkPropsOptions<\n TFrom extends ValidFromPath<RegisteredRoutesInfo> = '/',\n TTo extends string = '.',\n> = LinkPropsOptions<TFrom, TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement>\n\nexport type MakeLinkOptions<\n TFrom extends RegisteredRoutesInfo['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<TRouteTree, 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<RegisteredRoutesInfo> = '/',\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 RegisteredRoutesInfo['routePaths'] = '/',\n TDefaultTo extends string = '.',\n> {\n <\n TFrom extends RegisteredRoutesInfo['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 AnyRoute = Route,\n TRoutesInfo extends AnyRoutesInfo = RoutesInfo<TRouteConfig>,\n TRouterContext = unknown,\n> extends Router<TRouteConfig, TRoutesInfo, 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 AnyRoute = Route,\n TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo,\n TRouterContext = unknown,\n> = RouterOptions<TRouteConfig, TRouterContext> & {\n router: Router<TRouteConfig, TRoutesInfo, TRouterContext>\n}\n\nexport function RouterProvider<\n TRouteConfig extends AnyRoute = Route,\n TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo,\n TRouterContext = unknown,\n>({ router, ...rest }: RouterProps<TRouteConfig, TRoutesInfo, 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 RegisteredRoutesInfo['routesById'],\n TStrict extends boolean = true,\n TRouteMatch = RouteMatch<\n RegisteredRoutesInfo,\n RegisteredRoutesInfo['routesById'][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 RegisteredRoutesInfo['routesById'] = '/',\n>(routeId: TId): RegisteredRoutesInfo['routesById'][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 RegisteredRoutesInfo['routesById'],\n TStrict extends boolean = true,\n TSearch = RegisteredRoutesInfo['routesById'][TFrom]['__types']['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 RegisteredRoutesInfo['routesById'] = '/',\n TDefaultSelected = Expand<\n RegisteredRoutesInfo['allParams'] &\n RegisteredRoutesInfo['routesById'][TFrom]['__types']['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 RegisteredRoutesInfo['routesById'] = '/',\n>(defaultOpts?: { from?: TDefaultFrom }) {\n const router = useRouter()\n return <\n TFrom extends keyof RegisteredRoutesInfo['routesById'] = 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<RegisteredRoutesInfo> = '/',\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<RegisteredRoutesInfo> = '/',\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\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.\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 componentDidCatch(error: any, info: any) {\n console.error(`Error in route match: ${this.props.match.id}`)\n console.error(error)\n this.setState({\n error,\n info,\n })\n }\n render() {\n return (\n <CatchBoundaryInner\n {...this.props}\n errorState={this.state}\n reset={() => this.setState({})}\n />\n )\n }\n}\n\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA;;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,OAAO;AAAEC,MAAAA,SAAS,EAAE,QAAA;AAAS,KAAC,CAAC;AAC7CC,IAAAA,aAAa,GAAG,OAAO,EAAE,CAAC;IAC1BC,aAAa;IACbC,QA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AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/index.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport {\n Route,\n RegisteredRoutesInfo,\n RegisteredRouter,\n RouterStore,\n last,\n warning,\n RouterOptions,\n RouteMatch,\n MatchRouteOptions,\n AnyRoute,\n AnyRoutesInfo,\n DefaultRoutesInfo,\n functionalUpdate,\n RoutesInfo,\n ValidFromPath,\n LinkOptions,\n RouteByPath,\n ResolveRelativePath,\n NoInfer,\n ToOptions,\n invariant,\n Router,\n Expand,\n AnyContext,\n AnyRootRoute,\n RootRoute,\n AnySearchSchema,\n AnyPathParams,\n AnyRouteMatch,\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 RegisteredRoutesInfo['routePaths'] = '/',\n TTo extends string = '.',\n> = LinkOptions<RegisteredRoutesInfo, 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 RegisteredRoutesInfo['routePaths'] = '/',\n TTo extends string = '.',\n> = ToOptions<RegisteredRoutesInfo, TFrom, TTo> & MatchRouteOptions\n\nexport type MakeMatchRouteOptions<\n TFrom extends RegisteredRoutesInfo['routePaths'] = '/',\n TTo extends string = '.',\n> = ToOptions<RegisteredRoutesInfo, 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: RouteByPath<\n RegisteredRoutesInfo,\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['__types']['allParams'],\n ) => ReactNode)\n }\n\nexport type MakeLinkPropsOptions<\n TFrom extends ValidFromPath<RegisteredRoutesInfo> = '/',\n TTo extends string = '.',\n> = LinkPropsOptions<TFrom, TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement>\n\nexport type MakeLinkOptions<\n TFrom extends RegisteredRoutesInfo['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<TRouteTree> {\n // ssrFooter?: () => JSX.Element | Node\n }\n\n interface FrameworkRouteOptions {\n wrapInSuspense?: boolean\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<RegisteredRoutesInfo> = '/',\n TTo extends string = '.',\n>(\n options: MakeLinkPropsOptions<TFrom, TTo>,\n): React.AnchorHTMLAttributes<HTMLAnchorElement> {\n const router = useRouterContext()\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 RegisteredRoutesInfo['routePaths'] = '/',\n TDefaultTo extends string = '.',\n> {\n <\n TFrom extends RegisteredRoutesInfo['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 = AnyRouteMatch[]\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 AnyRootRoute = RootRoute,\n TRoutesInfo extends AnyRoutesInfo = RoutesInfo<TRouteConfig>,\n> extends Router<TRouteConfig, TRoutesInfo> {\n constructor(opts: RouterOptions<TRouteConfig>) {\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 AnyRootRoute = RootRoute,\n TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo,\n> = RouterOptions<TRouteConfig> & {\n router: Router<TRouteConfig, TRoutesInfo>\n}\n\nexport function RouterProvider<\n TRouteConfig extends AnyRootRoute = RootRoute,\n TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo,\n>({ router, ...rest }: RouterProps<TRouteConfig, TRoutesInfo>) {\n router.update(rest)\n\n const currentMatches = useStore(router.store, (s) => s.currentMatches)\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 useRouterContext(): RegisteredRouter {\n const value = React.useContext(routerContext)\n warning(!value, 'useRouter must be used inside a <Router> component!')\n\n useStore(value.router.store)\n\n return value.router\n}\n\nexport function useRouter<T = RouterStore>(\n track?: (state: Router['store']) => T,\n shallow?: boolean,\n): RegisteredRouter {\n const router = useRouterContext()\n useStore(router.store, track as any, shallow)\n return router\n}\n\nexport function useMatches(): RouteMatch[] {\n return React.useContext(matchesContext)\n}\n\nexport function useMatch<\n TFrom extends keyof RegisteredRoutesInfo['routesById'],\n TStrict extends boolean = true,\n TRouteMatch = RouteMatch<\n RegisteredRoutesInfo,\n RegisteredRoutesInfo['routesById'][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 = useRouterContext()\n const nearestMatch = useMatches()[0]!\n const match = opts?.from\n ? router.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 as any,\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 RegisteredRoutesInfo['routesById'] = '/',\n>(routeId: TId): RegisteredRoutesInfo['routesById'][TId] {\n const router = useRouterContext()\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 RegisteredRoutesInfo['routesById'],\n TStrict extends boolean = true,\n TSearch = RegisteredRoutesInfo['routesById'][TFrom]['__types']['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 true,\n )\n\n return (match as unknown as RouteMatch).state.search as any\n}\n\nexport function useParams<\n TFrom extends keyof RegisteredRoutesInfo['routesById'] = '/',\n TDefaultSelected = RegisteredRoutesInfo['allParams'] &\n RegisteredRoutesInfo['routesById'][TFrom]['__types']['allParams'],\n TSelected = TDefaultSelected,\n>(opts?: {\n from: TFrom\n track?: (search: TDefaultSelected) => TSelected\n}): TSelected {\n const router = useRouterContext()\n useStore(\n router.store,\n (d) => {\n const params = last(d.currentMatches)?.params as any\n return opts?.track?.(params) ?? params\n },\n true,\n )\n\n return last(router.state.currentMatches)?.params as any\n}\n\nexport function useNavigate<\n TDefaultFrom extends keyof RegisteredRoutesInfo['routesById'] = '/',\n>(defaultOpts?: { from?: TDefaultFrom }) {\n const router = useRouterContext()\n return <\n TFrom extends keyof RegisteredRoutesInfo['routesById'] = 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 = useRouterContext()\n\n return <\n TFrom extends ValidFromPath<RegisteredRoutesInfo> = '/',\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<RegisteredRoutesInfo> = '/',\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 = useRouterContext()\n useStore(match!.store, (store) => [store.status, store.error], true)\n\n const defaultPending = React.useCallback(() => null, [])\n\n const Inner = React.useCallback((props: { match: RouteMatch }): any => {\n if (props.match.state.status === 'error') {\n throw props.match.state.error\n }\n\n if (props.match.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.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 {match.route.options.wrapInSuspense ?? true ? (\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 ) : (\n <CatchBoundary\n key={match.route.id}\n errorComponent={errorComponent}\n match={match as any}\n >\n <Inner match={match} />\n </CatchBoundary>\n )}\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\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.\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 componentDidCatch(error: any, info: any) {\n console.error(`Error in route match: ${this.props.match.id}`)\n console.error(error)\n this.setState({\n error,\n info,\n })\n }\n render() {\n return (\n <CatchBoundaryInner\n {...this.props}\n errorState={this.state}\n reset={() => this.setState({})}\n />\n )\n }\n}\n\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 = useRouterContext()\n const errorComponent = props.errorComponent ?? DefaultErrorBoundary\n const prevKeyRef = React.useRef('' as any)\n\n React.useEffect(() => {\n if (activeErrorState) {\n if (router.state.currentLocation.key !== prevKeyRef.current) {\n setActiveErrorState({} as any)\n }\n }\n\n prevKeyRef.current = router.state.currentLocation.key\n }, [activeErrorState, router.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","useRouterContext","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","useRouter","track","shallow","useMatches","useMatch","nearestMatch","match","from","state","find","d","route","id","invariant","strict","useRoute","routeId","resolvedRoute","getRoute","useSearch","useParams","last","useNavigate","defaultOpts","navigate","useMatchRoute","pending","caseSensitive","matchRoute","MatchRoute","Outlet","matches","slice","SubOutlet","status","error","defaultPending","useCallback","Inner","createElement","defaultComponent","__loadPromise","PendingComponent","pendingComponent","defaultPendingComponent","errorComponent","defaultErrorComponent","wrapInSuspense","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA;;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;AA4EA;;AAEO,SAASE,YAAY,CAI1BC,OAAyC,EACM;EAC/C,MAAMC,QAAM,GAAGC,gBAAgB,EAAE,CAAA;EAEjC,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;IACV,GAAGC,IAAAA;AACL,GAAC,GAAGzB,OAAO,CAAA;AAEX,EAAA,MAAM0B,QAAQ,GAAGzB,QAAM,CAAC0B,SAAS,CAAC3B,OAAO,CAAQ,CAAA;AAEjD,EAAA,IAAI0B,QAAQ,CAACvB,IAAI,KAAK,UAAU,EAAE;IAChC,MAAM;AAAEyB,MAAAA,IAAAA;AAAK,KAAC,GAAGF,QAAQ,CAA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@ function lazy(importer) {
44
44
  //
45
45
 
46
46
  function useLinkProps(options) {
47
- const router = useRouter();
47
+ const router = useRouterContext();
48
48
  const {
49
49
  // custom props
50
50
  type,
@@ -169,7 +169,7 @@ function RouterProvider({
169
169
  ...rest
170
170
  }) {
171
171
  router.update(rest);
172
- const currentMatches = useStore(router.store, s => s.currentMatches, undefined);
172
+ const currentMatches = useStore(router.store, s => s.currentMatches);
173
173
  React.useEffect(router.mount, [router]);
174
174
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(routerContext.Provider, {
175
175
  value: {
@@ -179,22 +179,24 @@ function RouterProvider({
179
179
  value: [undefined, ...currentMatches]
180
180
  }, /*#__PURE__*/React.createElement(Outlet, null))));
181
181
  }
182
- function useRouter() {
182
+ function useRouterContext() {
183
183
  const value = React.useContext(routerContext);
184
184
  warning(!value, 'useRouter must be used inside a <Router> component!');
185
+ useStore(value.router.store);
185
186
  return value.router;
186
187
  }
187
- function useRouterStore(selector, shallow) {
188
- const router = useRouter();
189
- return useStore(router.store, selector, shallow);
188
+ function useRouter(track, shallow) {
189
+ const router = useRouterContext();
190
+ useStore(router.store, track, shallow);
191
+ return router;
190
192
  }
191
193
  function useMatches() {
192
194
  return React.useContext(matchesContext);
193
195
  }
194
196
  function useMatch(opts) {
195
- const router = useRouter();
197
+ const router = useRouterContext();
196
198
  const nearestMatch = useMatches()[0];
197
- const match = opts?.from ? router.store.state.currentMatches.find(d => d.route.id === opts?.from) : nearestMatch;
199
+ const match = opts?.from ? router.state.currentMatches.find(d => d.route.id === opts?.from) : nearestMatch;
198
200
  invariant(match, `Could not find ${opts?.from ? `an active match from "${opts.from}"` : 'a nearest match!'}`);
199
201
  if (opts?.strict ?? true) {
200
202
  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?`);
@@ -203,26 +205,26 @@ function useMatch(opts) {
203
205
  return match;
204
206
  }
205
207
  function useRoute(routeId) {
206
- const router = useRouter();
208
+ const router = useRouterContext();
207
209
  const resolvedRoute = router.getRoute(routeId);
208
210
  invariant(resolvedRoute, `Could not find a route for route "${routeId}"! Did you forget to add it to your route config?`);
209
211
  return resolvedRoute;
210
212
  }
211
213
  function useSearch(opts) {
212
214
  const match = useMatch(opts);
213
- useStore(match.store, d => opts?.track?.(d.search) ?? d.search);
214
- return match.store.state.search;
215
+ useStore(match.store, d => opts?.track?.(d.search) ?? d.search, true);
216
+ return match.state.search;
215
217
  }
216
218
  function useParams(opts) {
217
- const router = useRouter();
219
+ const router = useRouterContext();
218
220
  useStore(router.store, d => {
219
221
  const params = last(d.currentMatches)?.params;
220
222
  return opts?.track?.(params) ?? params;
221
- });
222
- return last(router.store.state.currentMatches)?.params;
223
+ }, true);
224
+ return last(router.state.currentMatches)?.params;
223
225
  }
224
226
  function useNavigate(defaultOpts) {
225
- const router = useRouter();
227
+ const router = useRouterContext();
226
228
  return opts => {
227
229
  return router.navigate({
228
230
  ...defaultOpts,
@@ -231,7 +233,7 @@ function useNavigate(defaultOpts) {
231
233
  };
232
234
  }
233
235
  function useMatchRoute() {
234
- const router = useRouter();
236
+ const router = useRouterContext();
235
237
  return opts => {
236
238
  const {
237
239
  pending,
@@ -270,17 +272,17 @@ function SubOutlet({
270
272
  matches,
271
273
  match
272
274
  }) {
273
- const router = useRouter();
274
- useStore(match.store);
275
+ const router = useRouterContext();
276
+ useStore(match.store, store => [store.status, store.error], true);
275
277
  const defaultPending = React.useCallback(() => null, []);
276
278
  const Inner = React.useCallback(props => {
277
- if (props.match.store.state.status === 'error') {
278
- throw props.match.store.state.error;
279
+ if (props.match.state.status === 'error') {
280
+ throw props.match.state.error;
279
281
  }
280
- if (props.match.store.state.status === 'success') {
282
+ if (props.match.state.status === 'success') {
281
283
  return /*#__PURE__*/React.createElement(props.match.component ?? router.options.defaultComponent ?? Outlet);
282
284
  }
283
- if (props.match.store.state.status === 'pending') {
285
+ if (props.match.state.status === 'pending') {
284
286
  throw props.match.__loadPromise;
285
287
  }
286
288
  invariant(false, 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!');
@@ -289,7 +291,7 @@ function SubOutlet({
289
291
  const errorComponent = match.errorComponent ?? router.options.defaultErrorComponent;
290
292
  return /*#__PURE__*/React.createElement(matchesContext.Provider, {
291
293
  value: matches
292
- }, /*#__PURE__*/React.createElement(React.Suspense, {
294
+ }, match.route.options.wrapInSuspense ?? true ? /*#__PURE__*/React.createElement(React.Suspense, {
293
295
  fallback: /*#__PURE__*/React.createElement(PendingComponent, null)
294
296
  }, /*#__PURE__*/React.createElement(CatchBoundary, {
295
297
  key: match.route.id,
@@ -297,7 +299,13 @@ function SubOutlet({
297
299
  match: match
298
300
  }, /*#__PURE__*/React.createElement(Inner, {
299
301
  match: match
300
- }))));
302
+ }))) : /*#__PURE__*/React.createElement(CatchBoundary, {
303
+ key: match.route.id,
304
+ errorComponent: errorComponent,
305
+ match: match
306
+ }, /*#__PURE__*/React.createElement(Inner, {
307
+ match: match
308
+ })));
301
309
  }
302
310
 
303
311
  // This is the messiest thing ever... I'm either seriously tired (likely) or
@@ -326,17 +334,17 @@ class CatchBoundary extends React.Component {
326
334
  }
327
335
  function CatchBoundaryInner(props) {
328
336
  const [activeErrorState, setActiveErrorState] = React.useState(props.errorState);
329
- const router = useRouter();
337
+ const router = useRouterContext();
330
338
  const errorComponent = props.errorComponent ?? DefaultErrorBoundary;
331
339
  const prevKeyRef = React.useRef('');
332
340
  React.useEffect(() => {
333
341
  if (activeErrorState) {
334
- if (router.store.state.currentLocation.key !== prevKeyRef.current) {
342
+ if (router.state.currentLocation.key !== prevKeyRef.current) {
335
343
  setActiveErrorState({});
336
344
  }
337
345
  }
338
- prevKeyRef.current = router.store.state.currentLocation.key;
339
- }, [activeErrorState, router.store.state.currentLocation.key]);
346
+ prevKeyRef.current = router.state.currentLocation.key;
347
+ }, [activeErrorState, router.state.currentLocation.key]);
340
348
  React.useEffect(() => {
341
349
  if (props.errorState.error) {
342
350
  setActiveErrorState(props.errorState);
@@ -402,5 +410,5 @@ function DefaultErrorBoundary({
402
410
  // return (children ?? null) as ReactNode
403
411
  // }
404
412
 
405
- export { DefaultErrorBoundary, Link, MatchRoute, Outlet, ReactRouter, RouterProvider, lazy, matchesContext, routerContext, useLinkProps, useMatch, useMatchRoute, useMatches, useNavigate, useParams, useRoute, useRouter, useRouterStore, useSearch };
413
+ export { DefaultErrorBoundary, Link, MatchRoute, Outlet, ReactRouter, RouterProvider, lazy, matchesContext, routerContext, useLinkProps, useMatch, useMatchRoute, useMatches, useNavigate, useParams, useRoute, useRouter, useRouterContext, useSearch };
406
414
  //# sourceMappingURL=index.js.map