@tanstack/react-router 1.162.2 → 1.162.5

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.
@@ -18,8 +18,7 @@ function RouterContextProvider({
18
18
  }
19
19
  });
20
20
  }
21
- const routerContext$1 = routerContext.getRouterContext();
22
- const provider = /* @__PURE__ */ jsxRuntime.jsx(routerContext$1.Provider, { value: router, children });
21
+ const provider = /* @__PURE__ */ jsxRuntime.jsx(routerContext.routerContext.Provider, { value: router, children });
23
22
  if (router.options.Wrap) {
24
23
  return /* @__PURE__ */ jsxRuntime.jsx(router.options.Wrap, { children: provider });
25
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RouterProvider.cjs","sources":["../../src/RouterProvider.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Matches } from './Matches'\nimport { getRouterContext } from './routerContext'\nimport type {\n AnyRouter,\n RegisteredRouter,\n RouterOptions,\n} from '@tanstack/router-core'\n\n/**\n * Low-level provider that places the router into React context and optionally\n * updates router options from props. Most apps should use `RouterProvider`.\n */\nexport function RouterContextProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({\n router,\n children,\n ...rest\n}: RouterProps<TRouter, TDehydrated> & {\n children: React.ReactNode\n}) {\n if (Object.keys(rest).length > 0) {\n // Allow the router to update options on the router instance\n router.update({\n ...router.options,\n ...rest,\n context: {\n ...router.options.context,\n ...rest.context,\n },\n })\n }\n\n const routerContext = getRouterContext()\n\n const provider = (\n <routerContext.Provider value={router as AnyRouter}>\n {children}\n </routerContext.Provider>\n )\n\n if (router.options.Wrap) {\n return <router.options.Wrap>{provider}</router.options.Wrap>\n }\n\n return provider\n}\n\n/**\n * Top-level component that renders the active route matches and provides the\n * router to the React tree via context.\n *\n * Accepts the same options as `createRouter` via props to update the router\n * instance after creation.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouterFunction\n */\nexport function RouterProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({ router, ...rest }: RouterProps<TRouter, TDehydrated>) {\n return (\n <RouterContextProvider router={router} {...rest}>\n <Matches />\n </RouterContextProvider>\n )\n}\n\nexport type RouterProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n> = Omit<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n NonNullable<TRouter['options']['defaultStructuralSharing']>,\n TRouter['history'],\n TDehydrated\n >,\n 'context'\n> & {\n router: TRouter\n context?: Partial<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n NonNullable<TRouter['options']['defaultStructuralSharing']>,\n TRouter['history'],\n TDehydrated\n >['context']\n >\n}\n"],"names":["routerContext","getRouterContext","jsx","Matches"],"mappings":";;;;;AAaO,SAAS,sBAGd;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAEG;AACD,MAAI,OAAO,KAAK,IAAI,EAAE,SAAS,GAAG;AAEhC,WAAO,OAAO;AAAA,MACZ,GAAG,OAAO;AAAA,MACV,GAAG;AAAA,MACH,SAAS;AAAA,QACP,GAAG,OAAO,QAAQ;AAAA,QAClB,GAAG,KAAK;AAAA,MAAA;AAAA,IACV,CACD;AAAA,EACH;AAEA,QAAMA,kBAAgBC,cAAAA,iBAAA;AAEtB,QAAM,WACJC,2BAAAA,IAACF,gBAAc,UAAd,EAAuB,OAAO,QAC5B,UACH;AAGF,MAAI,OAAO,QAAQ,MAAM;AACvB,WAAOE,2BAAAA,IAAC,OAAO,QAAQ,MAAf,EAAqB,UAAA,UAAS;AAAA,EACxC;AAEA,SAAO;AACT;AAWO,SAAS,eAGd,EAAE,QAAQ,GAAG,QAA2C;AACxD,wCACG,uBAAA,EAAsB,QAAiB,GAAG,MACzC,UAAAA,+BAACC,QAAAA,WAAQ,GACX;AAEJ;;;"}
1
+ {"version":3,"file":"RouterProvider.cjs","sources":["../../src/RouterProvider.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Matches } from './Matches'\nimport { routerContext } from './routerContext'\nimport type {\n AnyRouter,\n RegisteredRouter,\n RouterOptions,\n} from '@tanstack/router-core'\n\n/**\n * Low-level provider that places the router into React context and optionally\n * updates router options from props. Most apps should use `RouterProvider`.\n */\nexport function RouterContextProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({\n router,\n children,\n ...rest\n}: RouterProps<TRouter, TDehydrated> & {\n children: React.ReactNode\n}) {\n if (Object.keys(rest).length > 0) {\n // Allow the router to update options on the router instance\n router.update({\n ...router.options,\n ...rest,\n context: {\n ...router.options.context,\n ...rest.context,\n },\n })\n }\n\n const provider = (\n <routerContext.Provider value={router as AnyRouter}>\n {children}\n </routerContext.Provider>\n )\n\n if (router.options.Wrap) {\n return <router.options.Wrap>{provider}</router.options.Wrap>\n }\n\n return provider\n}\n\n/**\n * Top-level component that renders the active route matches and provides the\n * router to the React tree via context.\n *\n * Accepts the same options as `createRouter` via props to update the router\n * instance after creation.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouterFunction\n */\nexport function RouterProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({ router, ...rest }: RouterProps<TRouter, TDehydrated>) {\n return (\n <RouterContextProvider router={router} {...rest}>\n <Matches />\n </RouterContextProvider>\n )\n}\n\nexport type RouterProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n> = Omit<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n NonNullable<TRouter['options']['defaultStructuralSharing']>,\n TRouter['history'],\n TDehydrated\n >,\n 'context'\n> & {\n router: TRouter\n context?: Partial<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n NonNullable<TRouter['options']['defaultStructuralSharing']>,\n TRouter['history'],\n TDehydrated\n >['context']\n >\n}\n"],"names":["jsx","routerContext","Matches"],"mappings":";;;;;AAaO,SAAS,sBAGd;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAEG;AACD,MAAI,OAAO,KAAK,IAAI,EAAE,SAAS,GAAG;AAEhC,WAAO,OAAO;AAAA,MACZ,GAAG,OAAO;AAAA,MACV,GAAG;AAAA,MACH,SAAS;AAAA,QACP,GAAG,OAAO,QAAQ;AAAA,QAClB,GAAG,KAAK;AAAA,MAAA;AAAA,IACV,CACD;AAAA,EACH;AAEA,QAAM,WACJA,2BAAAA,IAACC,4BAAc,UAAd,EAAuB,OAAO,QAC5B,UACH;AAGF,MAAI,OAAO,QAAQ,MAAM;AACvB,WAAOD,2BAAAA,IAAC,OAAO,QAAQ,MAAf,EAAqB,UAAA,UAAS;AAAA,EACxC;AAEA,SAAO;AACT;AAWO,SAAS,eAGd,EAAE,QAAQ,GAAG,QAA2C;AACxD,wCACG,uBAAA,EAAsB,QAAiB,GAAG,MACzC,UAAAA,+BAACE,QAAAA,WAAQ,GACX;AAEJ;;;"}
@@ -9,7 +9,6 @@ const fileRoute = require("./fileRoute.cjs");
9
9
  const lazyRouteComponent = require("./lazyRouteComponent.cjs");
10
10
  const link = require("./link.cjs");
11
11
  const Matches = require("./Matches.cjs");
12
- const matchContext = require("./matchContext.cjs");
13
12
  const Match = require("./Match.cjs");
14
13
  const useMatch = require("./useMatch.cjs");
15
14
  const useLoaderDeps = require("./useLoaderDeps.cjs");
@@ -22,13 +21,11 @@ const useBlocker = require("./useBlocker.cjs");
22
21
  const useNavigate = require("./useNavigate.cjs");
23
22
  const useParams = require("./useParams.cjs");
24
23
  const useSearch = require("./useSearch.cjs");
25
- const routerContext = require("./routerContext.cjs");
26
24
  const useRouteContext = require("./useRouteContext.cjs");
27
25
  const useRouter = require("./useRouter.cjs");
28
26
  const useRouterState = require("./useRouterState.cjs");
29
27
  const useLocation = require("./useLocation.cjs");
30
28
  const useCanGoBack = require("./useCanGoBack.cjs");
31
- const utils = require("./utils.cjs");
32
29
  const notFound = require("./not-found.cjs");
33
30
  const ScriptOnce = require("./ScriptOnce.cjs");
34
31
  const Asset = require("./Asset.cjs");
@@ -39,26 +36,14 @@ Object.defineProperty(exports, "DEFAULT_PROTOCOL_ALLOWLIST", {
39
36
  enumerable: true,
40
37
  get: () => routerCore.DEFAULT_PROTOCOL_ALLOWLIST
41
38
  });
42
- Object.defineProperty(exports, "PathParamError", {
43
- enumerable: true,
44
- get: () => routerCore.PathParamError
45
- });
46
39
  Object.defineProperty(exports, "SearchParamError", {
47
40
  enumerable: true,
48
41
  get: () => routerCore.SearchParamError
49
42
  });
50
- Object.defineProperty(exports, "TSR_DEFERRED_PROMISE", {
51
- enumerable: true,
52
- get: () => routerCore.TSR_DEFERRED_PROMISE
53
- });
54
43
  Object.defineProperty(exports, "cleanPath", {
55
44
  enumerable: true,
56
45
  get: () => routerCore.cleanPath
57
46
  });
58
- Object.defineProperty(exports, "componentTypes", {
59
- enumerable: true,
60
- get: () => routerCore.componentTypes
61
- });
62
47
  Object.defineProperty(exports, "composeRewrites", {
63
48
  enumerable: true,
64
49
  get: () => routerCore.composeRewrites
@@ -83,10 +68,6 @@ Object.defineProperty(exports, "defaultParseSearch", {
83
68
  enumerable: true,
84
69
  get: () => routerCore.defaultParseSearch
85
70
  });
86
- Object.defineProperty(exports, "defaultSerializeError", {
87
- enumerable: true,
88
- get: () => routerCore.defaultSerializeError
89
- });
90
71
  Object.defineProperty(exports, "defaultStringifySearch", {
91
72
  enumerable: true,
92
73
  get: () => routerCore.defaultStringifySearch
@@ -99,10 +80,6 @@ Object.defineProperty(exports, "functionalUpdate", {
99
80
  enumerable: true,
100
81
  get: () => routerCore.functionalUpdate
101
82
  });
102
- Object.defineProperty(exports, "getInitialRouterState", {
103
- enumerable: true,
104
- get: () => routerCore.getInitialRouterState
105
- });
106
83
  Object.defineProperty(exports, "interpolatePath", {
107
84
  enumerable: true,
108
85
  get: () => routerCore.interpolatePath
@@ -222,7 +199,6 @@ exports.useChildMatches = Matches.useChildMatches;
222
199
  exports.useMatchRoute = Matches.useMatchRoute;
223
200
  exports.useMatches = Matches.useMatches;
224
201
  exports.useParentMatches = Matches.useParentMatches;
225
- exports.matchContext = matchContext.matchContext;
226
202
  exports.Match = Match.Match;
227
203
  exports.Outlet = Match.Outlet;
228
204
  exports.useMatch = useMatch.useMatch;
@@ -250,14 +226,11 @@ exports.Navigate = useNavigate.Navigate;
250
226
  exports.useNavigate = useNavigate.useNavigate;
251
227
  exports.useParams = useParams.useParams;
252
228
  exports.useSearch = useSearch.useSearch;
253
- exports.getRouterContext = routerContext.getRouterContext;
254
229
  exports.useRouteContext = useRouteContext.useRouteContext;
255
230
  exports.useRouter = useRouter.useRouter;
256
231
  exports.useRouterState = useRouterState.useRouterState;
257
232
  exports.useLocation = useLocation.useLocation;
258
233
  exports.useCanGoBack = useCanGoBack.useCanGoBack;
259
- exports.useLayoutEffect = utils.useLayoutEffect;
260
- exports.useStableCallback = utils.useStableCallback;
261
234
  exports.CatchNotFound = notFound.CatchNotFound;
262
235
  exports.DefaultGlobalNotFound = notFound.DefaultGlobalNotFound;
263
236
  exports.ScriptOnce = ScriptOnce.ScriptOnce;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- export { defer, TSR_DEFERRED_PROMISE, isMatch, joinPaths, cleanPath, trimPathLeft, trimPathRight, trimPath, resolvePath, interpolatePath, rootRouteId, defaultSerializeError, defaultParseSearch, defaultStringifySearch, parseSearchWith, stringifySearchWith, functionalUpdate, replaceEqualDeep, isPlainObject, isPlainArray, deepEqual, createControlledPromise, retainSearchParams, stripSearchParams, createSerializationAdapter, } from '@tanstack/router-core';
1
+ export { defer, isMatch, joinPaths, cleanPath, trimPathLeft, trimPathRight, trimPath, resolvePath, interpolatePath, rootRouteId, defaultParseSearch, defaultStringifySearch, parseSearchWith, stringifySearchWith, functionalUpdate, replaceEqualDeep, isPlainObject, isPlainArray, deepEqual, createControlledPromise, retainSearchParams, stripSearchParams, createSerializationAdapter, } from '@tanstack/router-core';
2
2
  export type { AnyRoute, DeferredPromiseState, DeferredPromise, ParsedLocation, RemoveTrailingSlashes, RemoveLeadingSlashes, ActiveOptions, ResolveRelativePath, RootRouteId, AnyPathParams, ResolveParams, ResolveOptionalParams, ResolveRequiredParams, SearchSchemaInput, AnyContext, RouteContext, PreloadableObj, RoutePathOptions, StaticDataRouteOption, RoutePathOptionsIntersection, UpdatableStaticRouteOption, MetaDescriptor, RouteLinkEntry, ParseParamsFn, SearchFilter, ResolveId, InferFullSearchSchema, InferFullSearchSchemaInput, ErrorRouteProps, ErrorComponentProps, NotFoundRouteProps, TrimPath, TrimPathLeft, TrimPathRight, StringifyParamsFn, ParamsOptions, InferAllParams, InferAllContext, LooseReturnType, LooseAsyncReturnType, ContextReturnType, ContextAsyncReturnType, ResolveLoaderData, ResolveRouteContext, SearchSerializer, SearchParser, TrailingSlashOption, Manifest, RouterManagedTag, ControlledPromise, Constrain, Expand, MergeAll, Assign, IntersectAssign, ResolveValidatorInput, ResolveValidatorOutput, Register, AnyValidator, DefaultValidator, ValidatorFn, AnySchema, AnyValidatorAdapter, AnyValidatorFn, AnyValidatorObj, ResolveValidatorInputFn, ResolveValidatorOutputFn, ResolveSearchValidatorInput, ResolveSearchValidatorInputFn, Validator, ValidatorAdapter, ValidatorObj, FileRoutesByPath, RouteById, RootRouteOptions, CreateFileRoute, SerializationAdapter, AnySerializationAdapter, SerializableExtensions, } from '@tanstack/router-core';
3
3
  export { createHistory, createBrowserHistory, createHashHistory, createMemoryHistory, } from '@tanstack/history';
4
4
  export type { BlockerFn, HistoryLocation, RouterHistory, ParsedPath, HistoryState, } from '@tanstack/history';
@@ -14,7 +14,6 @@ export type { InferDescendantToPaths, RelativeToPath, RelativeToParentPath, Rela
14
14
  export type { UseLinkPropsOptions, ActiveLinkOptions, LinkProps, LinkComponent, LinkComponentProps, CreateLinkProps, } from './link.cjs';
15
15
  export { Matches, useMatchRoute, MatchRoute, useMatches, useParentMatches, useChildMatches, } from './Matches.cjs';
16
16
  export type { UseMatchRouteOptions, MakeMatchRouteOptions } from './Matches.cjs';
17
- export { matchContext } from './matchContext.cjs';
18
17
  export { Match, Outlet } from './Match.cjs';
19
18
  export { useMatch } from './useMatch.cjs';
20
19
  export { useLoaderDeps } from './useLoaderDeps.cjs';
@@ -23,7 +22,7 @@ export { redirect, isRedirect, createRouterConfig, DEFAULT_PROTOCOL_ALLOWLIST, }
23
22
  export { RouteApi, getRouteApi, Route, createRoute, RootRoute, rootRouteWithContext, createRootRoute, createRootRouteWithContext, createRouteMask, NotFoundRoute, } from './route.cjs';
24
23
  export type { AnyRootRoute, AsyncRouteComponent, RouteComponent, ErrorRouteComponent, NotFoundRouteComponent, DefaultRouteTypes, RouteTypes, } from './route.cjs';
25
24
  export { createRouter, Router } from './router.cjs';
26
- export { componentTypes, lazyFn, SearchParamError, PathParamError, getInitialRouterState, } from '@tanstack/router-core';
25
+ export { lazyFn, SearchParamError } from '@tanstack/router-core';
27
26
  export { RouterProvider, RouterContextProvider } from './RouterProvider.cjs';
28
27
  export type { RouterProps } from './RouterProvider.cjs';
29
28
  export { useElementScrollRestoration, ScrollRestoration, } from './ScrollRestoration.cjs';
@@ -32,14 +31,11 @@ export { useBlocker, Block } from './useBlocker.cjs';
32
31
  export { useNavigate, Navigate } from './useNavigate.cjs';
33
32
  export { useParams } from './useParams.cjs';
34
33
  export { useSearch } from './useSearch.cjs';
35
- export { getRouterContext, } from './routerContext.cjs';
36
34
  export { useRouteContext } from './useRouteContext.cjs';
37
35
  export { useRouter } from './useRouter.cjs';
38
36
  export { useRouterState } from './useRouterState.cjs';
39
37
  export { useLocation } from './useLocation.cjs';
40
38
  export { useCanGoBack } from './useCanGoBack.cjs';
41
- export { useLayoutEffect, // SSR
42
- useStableCallback, } from './utils.cjs';
43
39
  export { CatchNotFound, DefaultGlobalNotFound } from './not-found.cjs';
44
40
  export { notFound, isNotFound } from '@tanstack/router-core';
45
41
  export type { NotFoundError } from '@tanstack/router-core';
@@ -9,7 +9,6 @@ const fileRoute = require("./fileRoute.cjs");
9
9
  const lazyRouteComponent = require("./lazyRouteComponent.cjs");
10
10
  const link = require("./link.cjs");
11
11
  const Matches = require("./Matches.cjs");
12
- const matchContext = require("./matchContext.cjs");
13
12
  const Match = require("./Match.cjs");
14
13
  const useMatch = require("./useMatch.cjs");
15
14
  const useLoaderDeps = require("./useLoaderDeps.cjs");
@@ -22,13 +21,11 @@ const useBlocker = require("./useBlocker.cjs");
22
21
  const useNavigate = require("./useNavigate.cjs");
23
22
  const useParams = require("./useParams.cjs");
24
23
  const useSearch = require("./useSearch.cjs");
25
- const routerContext = require("./routerContext.cjs");
26
24
  const useRouteContext = require("./useRouteContext.cjs");
27
25
  const useRouter = require("./useRouter.cjs");
28
26
  const useRouterState = require("./useRouterState.cjs");
29
27
  const useLocation = require("./useLocation.cjs");
30
28
  const useCanGoBack = require("./useCanGoBack.cjs");
31
- const utils = require("./utils.cjs");
32
29
  const notFound = require("./not-found.cjs");
33
30
  const ScriptOnce = require("./ScriptOnce.cjs");
34
31
  const Asset = require("./Asset.cjs");
@@ -39,26 +36,14 @@ Object.defineProperty(exports, "DEFAULT_PROTOCOL_ALLOWLIST", {
39
36
  enumerable: true,
40
37
  get: () => routerCore.DEFAULT_PROTOCOL_ALLOWLIST
41
38
  });
42
- Object.defineProperty(exports, "PathParamError", {
43
- enumerable: true,
44
- get: () => routerCore.PathParamError
45
- });
46
39
  Object.defineProperty(exports, "SearchParamError", {
47
40
  enumerable: true,
48
41
  get: () => routerCore.SearchParamError
49
42
  });
50
- Object.defineProperty(exports, "TSR_DEFERRED_PROMISE", {
51
- enumerable: true,
52
- get: () => routerCore.TSR_DEFERRED_PROMISE
53
- });
54
43
  Object.defineProperty(exports, "cleanPath", {
55
44
  enumerable: true,
56
45
  get: () => routerCore.cleanPath
57
46
  });
58
- Object.defineProperty(exports, "componentTypes", {
59
- enumerable: true,
60
- get: () => routerCore.componentTypes
61
- });
62
47
  Object.defineProperty(exports, "composeRewrites", {
63
48
  enumerable: true,
64
49
  get: () => routerCore.composeRewrites
@@ -83,10 +68,6 @@ Object.defineProperty(exports, "defaultParseSearch", {
83
68
  enumerable: true,
84
69
  get: () => routerCore.defaultParseSearch
85
70
  });
86
- Object.defineProperty(exports, "defaultSerializeError", {
87
- enumerable: true,
88
- get: () => routerCore.defaultSerializeError
89
- });
90
71
  Object.defineProperty(exports, "defaultStringifySearch", {
91
72
  enumerable: true,
92
73
  get: () => routerCore.defaultStringifySearch
@@ -99,10 +80,6 @@ Object.defineProperty(exports, "functionalUpdate", {
99
80
  enumerable: true,
100
81
  get: () => routerCore.functionalUpdate
101
82
  });
102
- Object.defineProperty(exports, "getInitialRouterState", {
103
- enumerable: true,
104
- get: () => routerCore.getInitialRouterState
105
- });
106
83
  Object.defineProperty(exports, "interpolatePath", {
107
84
  enumerable: true,
108
85
  get: () => routerCore.interpolatePath
@@ -222,7 +199,6 @@ exports.useChildMatches = Matches.useChildMatches;
222
199
  exports.useMatchRoute = Matches.useMatchRoute;
223
200
  exports.useMatches = Matches.useMatches;
224
201
  exports.useParentMatches = Matches.useParentMatches;
225
- exports.matchContext = matchContext.matchContext;
226
202
  exports.Match = Match.Match;
227
203
  exports.Outlet = Match.Outlet;
228
204
  exports.useMatch = useMatch.useMatch;
@@ -250,14 +226,11 @@ exports.Navigate = useNavigate.Navigate;
250
226
  exports.useNavigate = useNavigate.useNavigate;
251
227
  exports.useParams = useParams.useParams;
252
228
  exports.useSearch = useSearch.useSearch;
253
- exports.getRouterContext = routerContext.getRouterContext;
254
229
  exports.useRouteContext = useRouteContext.useRouteContext;
255
230
  exports.useRouter = useRouter.useRouter;
256
231
  exports.useRouterState = useRouterState.useRouterState;
257
232
  exports.useLocation = useLocation.useLocation;
258
233
  exports.useCanGoBack = useCanGoBack.useCanGoBack;
259
- exports.useLayoutEffect = utils.useLayoutEffect;
260
- exports.useStableCallback = utils.useStableCallback;
261
234
  exports.CatchNotFound = notFound.CatchNotFound;
262
235
  exports.DefaultGlobalNotFound = notFound.DefaultGlobalNotFound;
263
236
  exports.ScriptOnce = ScriptOnce.ScriptOnce;
@@ -1 +1 @@
1
- {"version":3,"file":"index.dev.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.dev.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -19,15 +19,5 @@ function _interopNamespaceDefault(e) {
19
19
  }
20
20
  const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
21
21
  const routerContext = React__namespace.createContext(null);
22
- function getRouterContext() {
23
- if (typeof document === "undefined") {
24
- return routerContext;
25
- }
26
- if (window.__TSR_ROUTER_CONTEXT__) {
27
- return window.__TSR_ROUTER_CONTEXT__;
28
- }
29
- window.__TSR_ROUTER_CONTEXT__ = routerContext;
30
- return routerContext;
31
- }
32
- exports.getRouterContext = getRouterContext;
22
+ exports.routerContext = routerContext;
33
23
  //# sourceMappingURL=routerContext.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"routerContext.cjs","sources":["../../src/routerContext.tsx"],"sourcesContent":["import * as React from 'react'\nimport type { AnyRouter } from '@tanstack/router-core'\n\ndeclare global {\n interface Window {\n __TSR_ROUTER_CONTEXT__?: React.Context<AnyRouter>\n }\n}\n\nconst routerContext = React.createContext<AnyRouter>(null!)\n\nexport function getRouterContext() {\n if (typeof document === 'undefined') {\n return routerContext\n }\n\n if (window.__TSR_ROUTER_CONTEXT__) {\n return window.__TSR_ROUTER_CONTEXT__\n }\n\n window.__TSR_ROUTER_CONTEXT__ = routerContext as any\n\n return routerContext\n}\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;AASA,MAAM,gBAAgBA,iBAAM,cAAyB,IAAK;AAEnD,SAAS,mBAAmB;AACjC,MAAI,OAAO,aAAa,aAAa;AACnC,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,wBAAwB;AACjC,WAAO,OAAO;AAAA,EAChB;AAEA,SAAO,yBAAyB;AAEhC,SAAO;AACT;;"}
1
+ {"version":3,"file":"routerContext.cjs","sources":["../../src/routerContext.tsx"],"sourcesContent":["import * as React from 'react'\nimport type { AnyRouter } from '@tanstack/router-core'\n\nexport const routerContext = React.createContext<AnyRouter>(null!)\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;AAGO,MAAM,gBAAgBA,iBAAM,cAAyB,IAAK;;"}
@@ -1,8 +1,3 @@
1
1
  import { AnyRouter } from '@tanstack/router-core';
2
2
  import * as React from 'react';
3
- declare global {
4
- interface Window {
5
- __TSR_ROUTER_CONTEXT__?: React.Context<AnyRouter>;
6
- }
7
- }
8
- export declare function getRouterContext(): React.Context<AnyRouter>;
3
+ export declare const routerContext: React.Context<AnyRouter>;
@@ -21,7 +21,7 @@ function _interopNamespaceDefault(e) {
21
21
  }
22
22
  const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
23
23
  function useRouter(opts) {
24
- const value = React__namespace.useContext(routerContext.getRouterContext());
24
+ const value = React__namespace.useContext(routerContext.routerContext);
25
25
  warning(
26
26
  !((opts?.warn ?? true) && !value),
27
27
  "useRouter must be used inside a <RouterProvider> component!"
@@ -1 +1 @@
1
- {"version":3,"file":"useRouter.cjs","sources":["../../src/useRouter.tsx"],"sourcesContent":["import * as React from 'react'\nimport warning from 'tiny-warning'\nimport { getRouterContext } from './routerContext'\nimport type { AnyRouter, RegisteredRouter } from '@tanstack/router-core'\n\n/**\n * Access the current TanStack Router instance from React context.\n * Must be used within a `RouterProvider`.\n *\n * Options:\n * - `warn`: Log a warning if no router context is found (default: true).\n *\n * @returns The registered router instance.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterHook\n */\nexport function useRouter<TRouter extends AnyRouter = RegisteredRouter>(opts?: {\n warn?: boolean\n}): TRouter {\n const value = React.useContext(getRouterContext())\n warning(\n !((opts?.warn ?? true) && !value),\n 'useRouter must be used inside a <RouterProvider> component!',\n )\n return value as any\n}\n"],"names":["React","getRouterContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAeO,SAAS,UAAwD,MAE5D;AACV,QAAM,QAAQA,iBAAM,WAAWC,cAAAA,iBAAA,CAAkB;AACjD;AAAA,IACE,GAAG,MAAM,QAAQ,SAAS,CAAC;AAAA,IAC3B;AAAA,EAAA;AAEF,SAAO;AACT;;"}
1
+ {"version":3,"file":"useRouter.cjs","sources":["../../src/useRouter.tsx"],"sourcesContent":["import * as React from 'react'\nimport warning from 'tiny-warning'\nimport { routerContext } from './routerContext'\nimport type { AnyRouter, RegisteredRouter } from '@tanstack/router-core'\n\n/**\n * Access the current TanStack Router instance from React context.\n * Must be used within a `RouterProvider`.\n *\n * Options:\n * - `warn`: Log a warning if no router context is found (default: true).\n *\n * @returns The registered router instance.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterHook\n */\nexport function useRouter<TRouter extends AnyRouter = RegisteredRouter>(opts?: {\n warn?: boolean\n}): TRouter {\n const value = React.useContext(routerContext)\n warning(\n !((opts?.warn ?? true) && !value),\n 'useRouter must be used inside a <RouterProvider> component!',\n )\n return value as any\n}\n"],"names":["React","routerContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAeO,SAAS,UAAwD,MAE5D;AACV,QAAM,QAAQA,iBAAM,WAAWC,2BAAa;AAC5C;AAAA,IACE,GAAG,MAAM,QAAQ,SAAS,CAAC;AAAA,IAC3B;AAAA,EAAA;AAEF,SAAO;AACT;;"}
@@ -20,12 +20,6 @@ function _interopNamespaceDefault(e) {
20
20
  const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
21
21
  const REACT_USE = "use";
22
22
  const reactUse = React__namespace[REACT_USE];
23
- function useStableCallback(fn) {
24
- const fnRef = React__namespace.useRef(fn);
25
- fnRef.current = fn;
26
- const ref = React__namespace.useRef((...args) => fnRef.current(...args));
27
- return ref.current;
28
- }
29
23
  const useLayoutEffect = typeof window !== "undefined" ? React__namespace.useLayoutEffect : React__namespace.useEffect;
30
24
  function usePrevious(value) {
31
25
  const ref = React__namespace.useRef({
@@ -65,5 +59,4 @@ exports.useForwardedRef = useForwardedRef;
65
59
  exports.useIntersectionObserver = useIntersectionObserver;
66
60
  exports.useLayoutEffect = useLayoutEffect;
67
61
  exports.usePrevious = usePrevious;
68
- exports.useStableCallback = useStableCallback;
69
62
  //# sourceMappingURL=utils.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","sources":["../../src/utils.ts"],"sourcesContent":["import * as React from 'react'\n\n// Safe version of React.use() that will not cause compilation errors against\n// React 18 with Webpack, which statically analyzes imports and fails when it\n// sees React.use referenced (since 'use' is not exported from React 18).\n// This uses a dynamic string lookup to avoid the static analysis.\nconst REACT_USE = 'use'\n\n/**\n * React.use if available (React 19+), undefined otherwise.\n * Use dynamic lookup to avoid Webpack compilation errors with React 18.\n */\nexport const reactUse:\n | (<T>(usable: Promise<T> | React.Context<T>) => T)\n | undefined = (React as any)[REACT_USE]\n\nexport function useStableCallback<T extends (...args: Array<any>) => any>(\n fn: T,\n): T {\n const fnRef = React.useRef(fn)\n fnRef.current = fn\n\n const ref = React.useRef((...args: Array<any>) => fnRef.current(...args))\n return ref.current as T\n}\n\nexport const useLayoutEffect =\n typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect\n\n/**\n * Taken from https://www.developerway.com/posts/implementing-advanced-use-previous-hook#part3\n */\nexport function usePrevious<T>(value: T): T | null {\n // initialise the ref with previous and current values\n const ref = React.useRef<{ value: T; prev: T | null }>({\n value: value,\n prev: null,\n })\n\n const current = ref.current.value\n\n // if the value passed into hook doesn't match what we store as \"current\"\n // move the \"current\" to the \"previous\"\n // and store the passed value as \"current\"\n if (value !== current) {\n ref.current = {\n value: value,\n prev: current,\n }\n }\n\n // return the previous value only\n return ref.current.prev\n}\n\n/**\n * React hook to wrap `IntersectionObserver`.\n *\n * This hook will create an `IntersectionObserver` and observe the ref passed to it.\n *\n * When the intersection changes, the callback will be called with the `IntersectionObserverEntry`.\n *\n * @param ref - The ref to observe\n * @param intersectionObserverOptions - The options to pass to the IntersectionObserver\n * @param options - The options to pass to the hook\n * @param callback - The callback to call when the intersection changes\n * @returns The IntersectionObserver instance\n * @example\n * ```tsx\n * const MyComponent = () => {\n * const ref = React.useRef<HTMLDivElement>(null)\n * useIntersectionObserver(\n * ref,\n * (entry) => { doSomething(entry) },\n * { rootMargin: '10px' },\n * { disabled: false }\n * )\n * return <div ref={ref} />\n * ```\n */\nexport function useIntersectionObserver<T extends Element>(\n ref: React.RefObject<T | null>,\n callback: (entry: IntersectionObserverEntry | undefined) => void,\n intersectionObserverOptions: IntersectionObserverInit = {},\n options: { disabled?: boolean } = {},\n) {\n React.useEffect(() => {\n if (\n !ref.current ||\n options.disabled ||\n typeof IntersectionObserver !== 'function'\n ) {\n return\n }\n\n const observer = new IntersectionObserver(([entry]) => {\n callback(entry)\n }, intersectionObserverOptions)\n\n observer.observe(ref.current)\n\n return () => {\n observer.disconnect()\n }\n }, [callback, intersectionObserverOptions, options.disabled, ref])\n}\n\n/**\n * React hook to take a `React.ForwardedRef` and returns a `ref` that can be used on a DOM element.\n *\n * @param ref - The forwarded ref\n * @returns The inner ref returned by `useRef`\n * @example\n * ```tsx\n * const MyComponent = React.forwardRef((props, ref) => {\n * const innerRef = useForwardedRef(ref)\n * return <div ref={innerRef} />\n * })\n * ```\n */\nexport function useForwardedRef<T>(ref?: React.ForwardedRef<T>) {\n const innerRef = React.useRef<T>(null)\n React.useImperativeHandle(ref, () => innerRef.current!, [])\n return innerRef\n}\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;AAMA,MAAM,YAAY;AAMX,MAAM,WAEIA,iBAAc,SAAS;AAEjC,SAAS,kBACd,IACG;AACH,QAAM,QAAQA,iBAAM,OAAO,EAAE;AAC7B,QAAM,UAAU;AAEhB,QAAM,MAAMA,iBAAM,OAAO,IAAI,SAAqB,MAAM,QAAQ,GAAG,IAAI,CAAC;AACxE,SAAO,IAAI;AACb;AAEO,MAAM,kBACX,OAAO,WAAW,cAAcA,iBAAM,kBAAkBA,iBAAM;AAKzD,SAAS,YAAe,OAAoB;AAEjD,QAAM,MAAMA,iBAAM,OAAqC;AAAA,IACrD;AAAA,IACA,MAAM;AAAA,EAAA,CACP;AAED,QAAM,UAAU,IAAI,QAAQ;AAK5B,MAAI,UAAU,SAAS;AACrB,QAAI,UAAU;AAAA,MACZ;AAAA,MACA,MAAM;AAAA,IAAA;AAAA,EAEV;AAGA,SAAO,IAAI,QAAQ;AACrB;AA2BO,SAAS,wBACd,KACA,UACA,8BAAwD,CAAA,GACxD,UAAkC,IAClC;AACAA,mBAAM,UAAU,MAAM;AACpB,QACE,CAAC,IAAI,WACL,QAAQ,YACR,OAAO,yBAAyB,YAChC;AACA;AAAA,IACF;AAEA,UAAM,WAAW,IAAI,qBAAqB,CAAC,CAAC,KAAK,MAAM;AACrD,eAAS,KAAK;AAAA,IAChB,GAAG,2BAA2B;AAE9B,aAAS,QAAQ,IAAI,OAAO;AAE5B,WAAO,MAAM;AACX,eAAS,WAAA;AAAA,IACX;AAAA,EACF,GAAG,CAAC,UAAU,6BAA6B,QAAQ,UAAU,GAAG,CAAC;AACnE;AAeO,SAAS,gBAAmB,KAA6B;AAC9D,QAAM,WAAWA,iBAAM,OAAU,IAAI;AACrCA,mBAAM,oBAAoB,KAAK,MAAM,SAAS,SAAU,CAAA,CAAE;AAC1D,SAAO;AACT;;;;;;;"}
1
+ {"version":3,"file":"utils.cjs","sources":["../../src/utils.ts"],"sourcesContent":["import * as React from 'react'\n\n// Safe version of React.use() that will not cause compilation errors against\n// React 18 with Webpack, which statically analyzes imports and fails when it\n// sees React.use referenced (since 'use' is not exported from React 18).\n// This uses a dynamic string lookup to avoid the static analysis.\nconst REACT_USE = 'use'\n\n/**\n * React.use if available (React 19+), undefined otherwise.\n * Use dynamic lookup to avoid Webpack compilation errors with React 18.\n */\nexport const reactUse:\n | (<T>(usable: Promise<T> | React.Context<T>) => T)\n | undefined = (React as any)[REACT_USE]\n\nexport function useStableCallback<T extends (...args: Array<any>) => any>(\n fn: T,\n): T {\n const fnRef = React.useRef(fn)\n fnRef.current = fn\n\n const ref = React.useRef((...args: Array<any>) => fnRef.current(...args))\n return ref.current as T\n}\n\nexport const useLayoutEffect =\n typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect\n\n/**\n * Taken from https://www.developerway.com/posts/implementing-advanced-use-previous-hook#part3\n */\nexport function usePrevious<T>(value: T): T | null {\n // initialise the ref with previous and current values\n const ref = React.useRef<{ value: T; prev: T | null }>({\n value: value,\n prev: null,\n })\n\n const current = ref.current.value\n\n // if the value passed into hook doesn't match what we store as \"current\"\n // move the \"current\" to the \"previous\"\n // and store the passed value as \"current\"\n if (value !== current) {\n ref.current = {\n value: value,\n prev: current,\n }\n }\n\n // return the previous value only\n return ref.current.prev\n}\n\n/**\n * React hook to wrap `IntersectionObserver`.\n *\n * This hook will create an `IntersectionObserver` and observe the ref passed to it.\n *\n * When the intersection changes, the callback will be called with the `IntersectionObserverEntry`.\n *\n * @param ref - The ref to observe\n * @param intersectionObserverOptions - The options to pass to the IntersectionObserver\n * @param options - The options to pass to the hook\n * @param callback - The callback to call when the intersection changes\n * @returns The IntersectionObserver instance\n * @example\n * ```tsx\n * const MyComponent = () => {\n * const ref = React.useRef<HTMLDivElement>(null)\n * useIntersectionObserver(\n * ref,\n * (entry) => { doSomething(entry) },\n * { rootMargin: '10px' },\n * { disabled: false }\n * )\n * return <div ref={ref} />\n * ```\n */\nexport function useIntersectionObserver<T extends Element>(\n ref: React.RefObject<T | null>,\n callback: (entry: IntersectionObserverEntry | undefined) => void,\n intersectionObserverOptions: IntersectionObserverInit = {},\n options: { disabled?: boolean } = {},\n) {\n React.useEffect(() => {\n if (\n !ref.current ||\n options.disabled ||\n typeof IntersectionObserver !== 'function'\n ) {\n return\n }\n\n const observer = new IntersectionObserver(([entry]) => {\n callback(entry)\n }, intersectionObserverOptions)\n\n observer.observe(ref.current)\n\n return () => {\n observer.disconnect()\n }\n }, [callback, intersectionObserverOptions, options.disabled, ref])\n}\n\n/**\n * React hook to take a `React.ForwardedRef` and returns a `ref` that can be used on a DOM element.\n *\n * @param ref - The forwarded ref\n * @returns The inner ref returned by `useRef`\n * @example\n * ```tsx\n * const MyComponent = React.forwardRef((props, ref) => {\n * const innerRef = useForwardedRef(ref)\n * return <div ref={innerRef} />\n * })\n * ```\n */\nexport function useForwardedRef<T>(ref?: React.ForwardedRef<T>) {\n const innerRef = React.useRef<T>(null)\n React.useImperativeHandle(ref, () => innerRef.current!, [])\n return innerRef\n}\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;AAMA,MAAM,YAAY;AAMX,MAAM,WAEIA,iBAAc,SAAS;AAYjC,MAAM,kBACX,OAAO,WAAW,cAAcA,iBAAM,kBAAkBA,iBAAM;AAKzD,SAAS,YAAe,OAAoB;AAEjD,QAAM,MAAMA,iBAAM,OAAqC;AAAA,IACrD;AAAA,IACA,MAAM;AAAA,EAAA,CACP;AAED,QAAM,UAAU,IAAI,QAAQ;AAK5B,MAAI,UAAU,SAAS;AACrB,QAAI,UAAU;AAAA,MACZ;AAAA,MACA,MAAM;AAAA,IAAA;AAAA,EAEV;AAGA,SAAO,IAAI,QAAQ;AACrB;AA2BO,SAAS,wBACd,KACA,UACA,8BAAwD,CAAA,GACxD,UAAkC,IAClC;AACAA,mBAAM,UAAU,MAAM;AACpB,QACE,CAAC,IAAI,WACL,QAAQ,YACR,OAAO,yBAAyB,YAChC;AACA;AAAA,IACF;AAEA,UAAM,WAAW,IAAI,qBAAqB,CAAC,CAAC,KAAK,MAAM;AACrD,eAAS,KAAK;AAAA,IAChB,GAAG,2BAA2B;AAE9B,aAAS,QAAQ,IAAI,OAAO;AAE5B,WAAO,MAAM;AACX,eAAS,WAAA;AAAA,IACX;AAAA,EACF,GAAG,CAAC,UAAU,6BAA6B,QAAQ,UAAU,GAAG,CAAC;AACnE;AAeO,SAAS,gBAAmB,KAA6B;AAC9D,QAAM,WAAWA,iBAAM,OAAU,IAAI;AACrCA,mBAAM,oBAAoB,KAAK,MAAM,SAAS,SAAU,CAAA,CAAE;AAC1D,SAAO;AACT;;;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { Matches } from "./Matches.js";
3
- import { getRouterContext } from "./routerContext.js";
3
+ import { routerContext } from "./routerContext.js";
4
4
  function RouterContextProvider({
5
5
  router,
6
6
  children,
@@ -16,7 +16,6 @@ function RouterContextProvider({
16
16
  }
17
17
  });
18
18
  }
19
- const routerContext = getRouterContext();
20
19
  const provider = /* @__PURE__ */ jsx(routerContext.Provider, { value: router, children });
21
20
  if (router.options.Wrap) {
22
21
  return /* @__PURE__ */ jsx(router.options.Wrap, { children: provider });
@@ -1 +1 @@
1
- {"version":3,"file":"RouterProvider.js","sources":["../../src/RouterProvider.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Matches } from './Matches'\nimport { getRouterContext } from './routerContext'\nimport type {\n AnyRouter,\n RegisteredRouter,\n RouterOptions,\n} from '@tanstack/router-core'\n\n/**\n * Low-level provider that places the router into React context and optionally\n * updates router options from props. Most apps should use `RouterProvider`.\n */\nexport function RouterContextProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({\n router,\n children,\n ...rest\n}: RouterProps<TRouter, TDehydrated> & {\n children: React.ReactNode\n}) {\n if (Object.keys(rest).length > 0) {\n // Allow the router to update options on the router instance\n router.update({\n ...router.options,\n ...rest,\n context: {\n ...router.options.context,\n ...rest.context,\n },\n })\n }\n\n const routerContext = getRouterContext()\n\n const provider = (\n <routerContext.Provider value={router as AnyRouter}>\n {children}\n </routerContext.Provider>\n )\n\n if (router.options.Wrap) {\n return <router.options.Wrap>{provider}</router.options.Wrap>\n }\n\n return provider\n}\n\n/**\n * Top-level component that renders the active route matches and provides the\n * router to the React tree via context.\n *\n * Accepts the same options as `createRouter` via props to update the router\n * instance after creation.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouterFunction\n */\nexport function RouterProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({ router, ...rest }: RouterProps<TRouter, TDehydrated>) {\n return (\n <RouterContextProvider router={router} {...rest}>\n <Matches />\n </RouterContextProvider>\n )\n}\n\nexport type RouterProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n> = Omit<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n NonNullable<TRouter['options']['defaultStructuralSharing']>,\n TRouter['history'],\n TDehydrated\n >,\n 'context'\n> & {\n router: TRouter\n context?: Partial<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n NonNullable<TRouter['options']['defaultStructuralSharing']>,\n TRouter['history'],\n TDehydrated\n >['context']\n >\n}\n"],"names":[],"mappings":";;;AAaO,SAAS,sBAGd;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAEG;AACD,MAAI,OAAO,KAAK,IAAI,EAAE,SAAS,GAAG;AAEhC,WAAO,OAAO;AAAA,MACZ,GAAG,OAAO;AAAA,MACV,GAAG;AAAA,MACH,SAAS;AAAA,QACP,GAAG,OAAO,QAAQ;AAAA,QAClB,GAAG,KAAK;AAAA,MAAA;AAAA,IACV,CACD;AAAA,EACH;AAEA,QAAM,gBAAgB,iBAAA;AAEtB,QAAM,WACJ,oBAAC,cAAc,UAAd,EAAuB,OAAO,QAC5B,UACH;AAGF,MAAI,OAAO,QAAQ,MAAM;AACvB,WAAO,oBAAC,OAAO,QAAQ,MAAf,EAAqB,UAAA,UAAS;AAAA,EACxC;AAEA,SAAO;AACT;AAWO,SAAS,eAGd,EAAE,QAAQ,GAAG,QAA2C;AACxD,6BACG,uBAAA,EAAsB,QAAiB,GAAG,MACzC,UAAA,oBAAC,WAAQ,GACX;AAEJ;"}
1
+ {"version":3,"file":"RouterProvider.js","sources":["../../src/RouterProvider.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Matches } from './Matches'\nimport { routerContext } from './routerContext'\nimport type {\n AnyRouter,\n RegisteredRouter,\n RouterOptions,\n} from '@tanstack/router-core'\n\n/**\n * Low-level provider that places the router into React context and optionally\n * updates router options from props. Most apps should use `RouterProvider`.\n */\nexport function RouterContextProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({\n router,\n children,\n ...rest\n}: RouterProps<TRouter, TDehydrated> & {\n children: React.ReactNode\n}) {\n if (Object.keys(rest).length > 0) {\n // Allow the router to update options on the router instance\n router.update({\n ...router.options,\n ...rest,\n context: {\n ...router.options.context,\n ...rest.context,\n },\n })\n }\n\n const provider = (\n <routerContext.Provider value={router as AnyRouter}>\n {children}\n </routerContext.Provider>\n )\n\n if (router.options.Wrap) {\n return <router.options.Wrap>{provider}</router.options.Wrap>\n }\n\n return provider\n}\n\n/**\n * Top-level component that renders the active route matches and provides the\n * router to the React tree via context.\n *\n * Accepts the same options as `createRouter` via props to update the router\n * instance after creation.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createRouterFunction\n */\nexport function RouterProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({ router, ...rest }: RouterProps<TRouter, TDehydrated>) {\n return (\n <RouterContextProvider router={router} {...rest}>\n <Matches />\n </RouterContextProvider>\n )\n}\n\nexport type RouterProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n> = Omit<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n NonNullable<TRouter['options']['defaultStructuralSharing']>,\n TRouter['history'],\n TDehydrated\n >,\n 'context'\n> & {\n router: TRouter\n context?: Partial<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n NonNullable<TRouter['options']['defaultStructuralSharing']>,\n TRouter['history'],\n TDehydrated\n >['context']\n >\n}\n"],"names":[],"mappings":";;;AAaO,SAAS,sBAGd;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAEG;AACD,MAAI,OAAO,KAAK,IAAI,EAAE,SAAS,GAAG;AAEhC,WAAO,OAAO;AAAA,MACZ,GAAG,OAAO;AAAA,MACV,GAAG;AAAA,MACH,SAAS;AAAA,QACP,GAAG,OAAO,QAAQ;AAAA,QAClB,GAAG,KAAK;AAAA,MAAA;AAAA,IACV,CACD;AAAA,EACH;AAEA,QAAM,WACJ,oBAAC,cAAc,UAAd,EAAuB,OAAO,QAC5B,UACH;AAGF,MAAI,OAAO,QAAQ,MAAM;AACvB,WAAO,oBAAC,OAAO,QAAQ,MAAf,EAAqB,UAAA,UAAS;AAAA,EACxC;AAEA,SAAO;AACT;AAWO,SAAS,eAGd,EAAE,QAAQ,GAAG,QAA2C;AACxD,6BACG,uBAAA,EAAsB,QAAiB,GAAG,MACzC,UAAA,oBAAC,WAAQ,GACX;AAEJ;"}
@@ -1,4 +1,4 @@
1
- export { defer, TSR_DEFERRED_PROMISE, isMatch, joinPaths, cleanPath, trimPathLeft, trimPathRight, trimPath, resolvePath, interpolatePath, rootRouteId, defaultSerializeError, defaultParseSearch, defaultStringifySearch, parseSearchWith, stringifySearchWith, functionalUpdate, replaceEqualDeep, isPlainObject, isPlainArray, deepEqual, createControlledPromise, retainSearchParams, stripSearchParams, createSerializationAdapter, } from '@tanstack/router-core';
1
+ export { defer, isMatch, joinPaths, cleanPath, trimPathLeft, trimPathRight, trimPath, resolvePath, interpolatePath, rootRouteId, defaultParseSearch, defaultStringifySearch, parseSearchWith, stringifySearchWith, functionalUpdate, replaceEqualDeep, isPlainObject, isPlainArray, deepEqual, createControlledPromise, retainSearchParams, stripSearchParams, createSerializationAdapter, } from '@tanstack/router-core';
2
2
  export type { AnyRoute, DeferredPromiseState, DeferredPromise, ParsedLocation, RemoveTrailingSlashes, RemoveLeadingSlashes, ActiveOptions, ResolveRelativePath, RootRouteId, AnyPathParams, ResolveParams, ResolveOptionalParams, ResolveRequiredParams, SearchSchemaInput, AnyContext, RouteContext, PreloadableObj, RoutePathOptions, StaticDataRouteOption, RoutePathOptionsIntersection, UpdatableStaticRouteOption, MetaDescriptor, RouteLinkEntry, ParseParamsFn, SearchFilter, ResolveId, InferFullSearchSchema, InferFullSearchSchemaInput, ErrorRouteProps, ErrorComponentProps, NotFoundRouteProps, TrimPath, TrimPathLeft, TrimPathRight, StringifyParamsFn, ParamsOptions, InferAllParams, InferAllContext, LooseReturnType, LooseAsyncReturnType, ContextReturnType, ContextAsyncReturnType, ResolveLoaderData, ResolveRouteContext, SearchSerializer, SearchParser, TrailingSlashOption, Manifest, RouterManagedTag, ControlledPromise, Constrain, Expand, MergeAll, Assign, IntersectAssign, ResolveValidatorInput, ResolveValidatorOutput, Register, AnyValidator, DefaultValidator, ValidatorFn, AnySchema, AnyValidatorAdapter, AnyValidatorFn, AnyValidatorObj, ResolveValidatorInputFn, ResolveValidatorOutputFn, ResolveSearchValidatorInput, ResolveSearchValidatorInputFn, Validator, ValidatorAdapter, ValidatorObj, FileRoutesByPath, RouteById, RootRouteOptions, CreateFileRoute, SerializationAdapter, AnySerializationAdapter, SerializableExtensions, } from '@tanstack/router-core';
3
3
  export { createHistory, createBrowserHistory, createHashHistory, createMemoryHistory, } from '@tanstack/history';
4
4
  export type { BlockerFn, HistoryLocation, RouterHistory, ParsedPath, HistoryState, } from '@tanstack/history';
@@ -14,7 +14,6 @@ export type { InferDescendantToPaths, RelativeToPath, RelativeToParentPath, Rela
14
14
  export type { UseLinkPropsOptions, ActiveLinkOptions, LinkProps, LinkComponent, LinkComponentProps, CreateLinkProps, } from './link.js';
15
15
  export { Matches, useMatchRoute, MatchRoute, useMatches, useParentMatches, useChildMatches, } from './Matches.js';
16
16
  export type { UseMatchRouteOptions, MakeMatchRouteOptions } from './Matches.js';
17
- export { matchContext } from './matchContext.js';
18
17
  export { Match, Outlet } from './Match.js';
19
18
  export { useMatch } from './useMatch.js';
20
19
  export { useLoaderDeps } from './useLoaderDeps.js';
@@ -23,7 +22,7 @@ export { redirect, isRedirect, createRouterConfig, DEFAULT_PROTOCOL_ALLOWLIST, }
23
22
  export { RouteApi, getRouteApi, Route, createRoute, RootRoute, rootRouteWithContext, createRootRoute, createRootRouteWithContext, createRouteMask, NotFoundRoute, } from './route.js';
24
23
  export type { AnyRootRoute, AsyncRouteComponent, RouteComponent, ErrorRouteComponent, NotFoundRouteComponent, DefaultRouteTypes, RouteTypes, } from './route.js';
25
24
  export { createRouter, Router } from './router.js';
26
- export { componentTypes, lazyFn, SearchParamError, PathParamError, getInitialRouterState, } from '@tanstack/router-core';
25
+ export { lazyFn, SearchParamError } from '@tanstack/router-core';
27
26
  export { RouterProvider, RouterContextProvider } from './RouterProvider.js';
28
27
  export type { RouterProps } from './RouterProvider.js';
29
28
  export { useElementScrollRestoration, ScrollRestoration, } from './ScrollRestoration.js';
@@ -32,14 +31,11 @@ export { useBlocker, Block } from './useBlocker.js';
32
31
  export { useNavigate, Navigate } from './useNavigate.js';
33
32
  export { useParams } from './useParams.js';
34
33
  export { useSearch } from './useSearch.js';
35
- export { getRouterContext, } from './routerContext.js';
36
34
  export { useRouteContext } from './useRouteContext.js';
37
35
  export { useRouter } from './useRouter.js';
38
36
  export { useRouterState } from './useRouterState.js';
39
37
  export { useLocation } from './useLocation.js';
40
38
  export { useCanGoBack } from './useCanGoBack.js';
41
- export { useLayoutEffect, // SSR
42
- useStableCallback, } from './utils.js';
43
39
  export { CatchNotFound, DefaultGlobalNotFound } from './not-found.js';
44
40
  export { notFound, isNotFound } from '@tanstack/router-core';
45
41
  export type { NotFoundError } from '@tanstack/router-core';
@@ -1,4 +1,4 @@
1
- import { DEFAULT_PROTOCOL_ALLOWLIST, PathParamError, SearchParamError, TSR_DEFERRED_PROMISE, cleanPath, componentTypes, composeRewrites, createControlledPromise, createRouterConfig, createSerializationAdapter, deepEqual, defaultParseSearch, defaultSerializeError, defaultStringifySearch, defer, functionalUpdate, getInitialRouterState, interpolatePath, isMatch, isNotFound, isPlainArray, isPlainObject, isRedirect, joinPaths, lazyFn, notFound, parseSearchWith, redirect, replaceEqualDeep, resolvePath, retainSearchParams, rootRouteId, stringifySearchWith, stripSearchParams, trimPath, trimPathLeft, trimPathRight } from "@tanstack/router-core";
1
+ import { DEFAULT_PROTOCOL_ALLOWLIST, SearchParamError, cleanPath, composeRewrites, createControlledPromise, createRouterConfig, createSerializationAdapter, deepEqual, defaultParseSearch, defaultStringifySearch, defer, functionalUpdate, interpolatePath, isMatch, isNotFound, isPlainArray, isPlainObject, isRedirect, joinPaths, lazyFn, notFound, parseSearchWith, redirect, replaceEqualDeep, resolvePath, retainSearchParams, rootRouteId, stringifySearchWith, stripSearchParams, trimPath, trimPathLeft, trimPathRight } from "@tanstack/router-core";
2
2
  import { createBrowserHistory, createHashHistory, createHistory, createMemoryHistory } from "@tanstack/history";
3
3
  import { Await, useAwaited } from "./awaited.js";
4
4
  import { CatchBoundary, ErrorComponent } from "./CatchBoundary.js";
@@ -7,7 +7,6 @@ import { FileRoute, FileRouteLoader, LazyRoute, createFileRoute, createLazyFileR
7
7
  import { lazyRouteComponent } from "./lazyRouteComponent.js";
8
8
  import { Link, createLink, linkOptions, useLinkProps } from "./link.js";
9
9
  import { MatchRoute, Matches, useChildMatches, useMatchRoute, useMatches, useParentMatches } from "./Matches.js";
10
- import { matchContext } from "./matchContext.js";
11
10
  import { Match, Outlet } from "./Match.js";
12
11
  import { useMatch } from "./useMatch.js";
13
12
  import { useLoaderDeps } from "./useLoaderDeps.js";
@@ -20,13 +19,11 @@ import { Block, useBlocker } from "./useBlocker.js";
20
19
  import { Navigate, useNavigate } from "./useNavigate.js";
21
20
  import { useParams } from "./useParams.js";
22
21
  import { useSearch } from "./useSearch.js";
23
- import { getRouterContext } from "./routerContext.js";
24
22
  import { useRouteContext } from "./useRouteContext.js";
25
23
  import { useRouter } from "./useRouter.js";
26
24
  import { useRouterState } from "./useRouterState.js";
27
25
  import { useLocation } from "./useLocation.js";
28
26
  import { useCanGoBack } from "./useCanGoBack.js";
29
- import { useLayoutEffect, useStableCallback } from "./utils.js";
30
27
  import { CatchNotFound, DefaultGlobalNotFound } from "./not-found.js";
31
28
  import { ScriptOnce } from "./ScriptOnce.js";
32
29
  import { Asset } from "./Asset.js";
@@ -54,7 +51,6 @@ export {
54
51
  Navigate,
55
52
  NotFoundRoute,
56
53
  Outlet,
57
- PathParamError,
58
54
  RootRoute,
59
55
  Route,
60
56
  RouteApi,
@@ -65,9 +61,7 @@ export {
65
61
  Scripts,
66
62
  ScrollRestoration,
67
63
  SearchParamError,
68
- TSR_DEFERRED_PROMISE,
69
64
  cleanPath,
70
- componentTypes,
71
65
  composeRewrites,
72
66
  createBrowserHistory,
73
67
  createControlledPromise,
@@ -87,13 +81,10 @@ export {
87
81
  createSerializationAdapter,
88
82
  deepEqual,
89
83
  defaultParseSearch,
90
- defaultSerializeError,
91
84
  defaultStringifySearch,
92
85
  defer,
93
86
  functionalUpdate,
94
- getInitialRouterState,
95
87
  getRouteApi,
96
- getRouterContext,
97
88
  interpolatePath,
98
89
  isMatch,
99
90
  isNotFound,
@@ -104,7 +95,6 @@ export {
104
95
  lazyFn,
105
96
  lazyRouteComponent,
106
97
  linkOptions,
107
- matchContext,
108
98
  notFound,
109
99
  parseSearchWith,
110
100
  redirect,
@@ -124,7 +114,6 @@ export {
124
114
  useChildMatches,
125
115
  useElementScrollRestoration,
126
116
  useHydrated,
127
- useLayoutEffect,
128
117
  useLinkProps,
129
118
  useLoaderData,
130
119
  useLoaderDeps,
@@ -139,7 +128,6 @@ export {
139
128
  useRouter,
140
129
  useRouterState,
141
130
  useSearch,
142
- useStableCallback,
143
131
  useTags
144
132
  };
145
133
  //# sourceMappingURL=index.dev.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.dev.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.dev.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { DEFAULT_PROTOCOL_ALLOWLIST, PathParamError, SearchParamError, TSR_DEFERRED_PROMISE, cleanPath, componentTypes, composeRewrites, createControlledPromise, createRouterConfig, createSerializationAdapter, deepEqual, defaultParseSearch, defaultSerializeError, defaultStringifySearch, defer, functionalUpdate, getInitialRouterState, interpolatePath, isMatch, isNotFound, isPlainArray, isPlainObject, isRedirect, joinPaths, lazyFn, notFound, parseSearchWith, redirect, replaceEqualDeep, resolvePath, retainSearchParams, rootRouteId, stringifySearchWith, stripSearchParams, trimPath, trimPathLeft, trimPathRight } from "@tanstack/router-core";
1
+ import { DEFAULT_PROTOCOL_ALLOWLIST, SearchParamError, cleanPath, composeRewrites, createControlledPromise, createRouterConfig, createSerializationAdapter, deepEqual, defaultParseSearch, defaultStringifySearch, defer, functionalUpdate, interpolatePath, isMatch, isNotFound, isPlainArray, isPlainObject, isRedirect, joinPaths, lazyFn, notFound, parseSearchWith, redirect, replaceEqualDeep, resolvePath, retainSearchParams, rootRouteId, stringifySearchWith, stripSearchParams, trimPath, trimPathLeft, trimPathRight } from "@tanstack/router-core";
2
2
  import { createBrowserHistory, createHashHistory, createHistory, createMemoryHistory } from "@tanstack/history";
3
3
  import { Await, useAwaited } from "./awaited.js";
4
4
  import { CatchBoundary, ErrorComponent } from "./CatchBoundary.js";
@@ -7,7 +7,6 @@ import { FileRoute, FileRouteLoader, LazyRoute, createFileRoute, createLazyFileR
7
7
  import { lazyRouteComponent } from "./lazyRouteComponent.js";
8
8
  import { Link, createLink, linkOptions, useLinkProps } from "./link.js";
9
9
  import { MatchRoute, Matches, useChildMatches, useMatchRoute, useMatches, useParentMatches } from "./Matches.js";
10
- import { matchContext } from "./matchContext.js";
11
10
  import { Match, Outlet } from "./Match.js";
12
11
  import { useMatch } from "./useMatch.js";
13
12
  import { useLoaderDeps } from "./useLoaderDeps.js";
@@ -20,13 +19,11 @@ import { Block, useBlocker } from "./useBlocker.js";
20
19
  import { Navigate, useNavigate } from "./useNavigate.js";
21
20
  import { useParams } from "./useParams.js";
22
21
  import { useSearch } from "./useSearch.js";
23
- import { getRouterContext } from "./routerContext.js";
24
22
  import { useRouteContext } from "./useRouteContext.js";
25
23
  import { useRouter } from "./useRouter.js";
26
24
  import { useRouterState } from "./useRouterState.js";
27
25
  import { useLocation } from "./useLocation.js";
28
26
  import { useCanGoBack } from "./useCanGoBack.js";
29
- import { useLayoutEffect, useStableCallback } from "./utils.js";
30
27
  import { CatchNotFound, DefaultGlobalNotFound } from "./not-found.js";
31
28
  import { ScriptOnce } from "./ScriptOnce.js";
32
29
  import { Asset } from "./Asset.js";
@@ -54,7 +51,6 @@ export {
54
51
  Navigate,
55
52
  NotFoundRoute,
56
53
  Outlet,
57
- PathParamError,
58
54
  RootRoute,
59
55
  Route,
60
56
  RouteApi,
@@ -65,9 +61,7 @@ export {
65
61
  Scripts,
66
62
  ScrollRestoration,
67
63
  SearchParamError,
68
- TSR_DEFERRED_PROMISE,
69
64
  cleanPath,
70
- componentTypes,
71
65
  composeRewrites,
72
66
  createBrowserHistory,
73
67
  createControlledPromise,
@@ -87,13 +81,10 @@ export {
87
81
  createSerializationAdapter,
88
82
  deepEqual,
89
83
  defaultParseSearch,
90
- defaultSerializeError,
91
84
  defaultStringifySearch,
92
85
  defer,
93
86
  functionalUpdate,
94
- getInitialRouterState,
95
87
  getRouteApi,
96
- getRouterContext,
97
88
  interpolatePath,
98
89
  isMatch,
99
90
  isNotFound,
@@ -104,7 +95,6 @@ export {
104
95
  lazyFn,
105
96
  lazyRouteComponent,
106
97
  linkOptions,
107
- matchContext,
108
98
  notFound,
109
99
  parseSearchWith,
110
100
  redirect,
@@ -124,7 +114,6 @@ export {
124
114
  useChildMatches,
125
115
  useElementScrollRestoration,
126
116
  useHydrated,
127
- useLayoutEffect,
128
117
  useLinkProps,
129
118
  useLoaderData,
130
119
  useLoaderDeps,
@@ -139,7 +128,6 @@ export {
139
128
  useRouter,
140
129
  useRouterState,
141
130
  useSearch,
142
- useStableCallback,
143
131
  useTags
144
132
  };
145
133
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,8 +1,3 @@
1
1
  import { AnyRouter } from '@tanstack/router-core';
2
2
  import * as React from 'react';
3
- declare global {
4
- interface Window {
5
- __TSR_ROUTER_CONTEXT__?: React.Context<AnyRouter>;
6
- }
7
- }
8
- export declare function getRouterContext(): React.Context<AnyRouter>;
3
+ export declare const routerContext: React.Context<AnyRouter>;
@@ -1,16 +1,6 @@
1
1
  import * as React from "react";
2
2
  const routerContext = React.createContext(null);
3
- function getRouterContext() {
4
- if (typeof document === "undefined") {
5
- return routerContext;
6
- }
7
- if (window.__TSR_ROUTER_CONTEXT__) {
8
- return window.__TSR_ROUTER_CONTEXT__;
9
- }
10
- window.__TSR_ROUTER_CONTEXT__ = routerContext;
11
- return routerContext;
12
- }
13
3
  export {
14
- getRouterContext
4
+ routerContext
15
5
  };
16
6
  //# sourceMappingURL=routerContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"routerContext.js","sources":["../../src/routerContext.tsx"],"sourcesContent":["import * as React from 'react'\nimport type { AnyRouter } from '@tanstack/router-core'\n\ndeclare global {\n interface Window {\n __TSR_ROUTER_CONTEXT__?: React.Context<AnyRouter>\n }\n}\n\nconst routerContext = React.createContext<AnyRouter>(null!)\n\nexport function getRouterContext() {\n if (typeof document === 'undefined') {\n return routerContext\n }\n\n if (window.__TSR_ROUTER_CONTEXT__) {\n return window.__TSR_ROUTER_CONTEXT__\n }\n\n window.__TSR_ROUTER_CONTEXT__ = routerContext as any\n\n return routerContext\n}\n"],"names":[],"mappings":";AASA,MAAM,gBAAgB,MAAM,cAAyB,IAAK;AAEnD,SAAS,mBAAmB;AACjC,MAAI,OAAO,aAAa,aAAa;AACnC,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,wBAAwB;AACjC,WAAO,OAAO;AAAA,EAChB;AAEA,SAAO,yBAAyB;AAEhC,SAAO;AACT;"}
1
+ {"version":3,"file":"routerContext.js","sources":["../../src/routerContext.tsx"],"sourcesContent":["import * as React from 'react'\nimport type { AnyRouter } from '@tanstack/router-core'\n\nexport const routerContext = React.createContext<AnyRouter>(null!)\n"],"names":[],"mappings":";AAGO,MAAM,gBAAgB,MAAM,cAAyB,IAAK;"}
@@ -1,8 +1,8 @@
1
1
  import * as React from "react";
2
2
  import warning from "tiny-warning";
3
- import { getRouterContext } from "./routerContext.js";
3
+ import { routerContext } from "./routerContext.js";
4
4
  function useRouter(opts) {
5
- const value = React.useContext(getRouterContext());
5
+ const value = React.useContext(routerContext);
6
6
  warning(
7
7
  !((opts?.warn ?? true) && !value),
8
8
  "useRouter must be used inside a <RouterProvider> component!"
@@ -1 +1 @@
1
- {"version":3,"file":"useRouter.js","sources":["../../src/useRouter.tsx"],"sourcesContent":["import * as React from 'react'\nimport warning from 'tiny-warning'\nimport { getRouterContext } from './routerContext'\nimport type { AnyRouter, RegisteredRouter } from '@tanstack/router-core'\n\n/**\n * Access the current TanStack Router instance from React context.\n * Must be used within a `RouterProvider`.\n *\n * Options:\n * - `warn`: Log a warning if no router context is found (default: true).\n *\n * @returns The registered router instance.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterHook\n */\nexport function useRouter<TRouter extends AnyRouter = RegisteredRouter>(opts?: {\n warn?: boolean\n}): TRouter {\n const value = React.useContext(getRouterContext())\n warning(\n !((opts?.warn ?? true) && !value),\n 'useRouter must be used inside a <RouterProvider> component!',\n )\n return value as any\n}\n"],"names":[],"mappings":";;;AAeO,SAAS,UAAwD,MAE5D;AACV,QAAM,QAAQ,MAAM,WAAW,iBAAA,CAAkB;AACjD;AAAA,IACE,GAAG,MAAM,QAAQ,SAAS,CAAC;AAAA,IAC3B;AAAA,EAAA;AAEF,SAAO;AACT;"}
1
+ {"version":3,"file":"useRouter.js","sources":["../../src/useRouter.tsx"],"sourcesContent":["import * as React from 'react'\nimport warning from 'tiny-warning'\nimport { routerContext } from './routerContext'\nimport type { AnyRouter, RegisteredRouter } from '@tanstack/router-core'\n\n/**\n * Access the current TanStack Router instance from React context.\n * Must be used within a `RouterProvider`.\n *\n * Options:\n * - `warn`: Log a warning if no router context is found (default: true).\n *\n * @returns The registered router instance.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterHook\n */\nexport function useRouter<TRouter extends AnyRouter = RegisteredRouter>(opts?: {\n warn?: boolean\n}): TRouter {\n const value = React.useContext(routerContext)\n warning(\n !((opts?.warn ?? true) && !value),\n 'useRouter must be used inside a <RouterProvider> component!',\n )\n return value as any\n}\n"],"names":[],"mappings":";;;AAeO,SAAS,UAAwD,MAE5D;AACV,QAAM,QAAQ,MAAM,WAAW,aAAa;AAC5C;AAAA,IACE,GAAG,MAAM,QAAQ,SAAS,CAAC;AAAA,IAC3B;AAAA,EAAA;AAEF,SAAO;AACT;"}
package/dist/esm/utils.js CHANGED
@@ -1,12 +1,6 @@
1
1
  import * as React from "react";
2
2
  const REACT_USE = "use";
3
3
  const reactUse = React[REACT_USE];
4
- function useStableCallback(fn) {
5
- const fnRef = React.useRef(fn);
6
- fnRef.current = fn;
7
- const ref = React.useRef((...args) => fnRef.current(...args));
8
- return ref.current;
9
- }
10
4
  const useLayoutEffect = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
11
5
  function usePrevious(value) {
12
6
  const ref = React.useRef({
@@ -46,7 +40,6 @@ export {
46
40
  useForwardedRef,
47
41
  useIntersectionObserver,
48
42
  useLayoutEffect,
49
- usePrevious,
50
- useStableCallback
43
+ usePrevious
51
44
  };
52
45
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../src/utils.ts"],"sourcesContent":["import * as React from 'react'\n\n// Safe version of React.use() that will not cause compilation errors against\n// React 18 with Webpack, which statically analyzes imports and fails when it\n// sees React.use referenced (since 'use' is not exported from React 18).\n// This uses a dynamic string lookup to avoid the static analysis.\nconst REACT_USE = 'use'\n\n/**\n * React.use if available (React 19+), undefined otherwise.\n * Use dynamic lookup to avoid Webpack compilation errors with React 18.\n */\nexport const reactUse:\n | (<T>(usable: Promise<T> | React.Context<T>) => T)\n | undefined = (React as any)[REACT_USE]\n\nexport function useStableCallback<T extends (...args: Array<any>) => any>(\n fn: T,\n): T {\n const fnRef = React.useRef(fn)\n fnRef.current = fn\n\n const ref = React.useRef((...args: Array<any>) => fnRef.current(...args))\n return ref.current as T\n}\n\nexport const useLayoutEffect =\n typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect\n\n/**\n * Taken from https://www.developerway.com/posts/implementing-advanced-use-previous-hook#part3\n */\nexport function usePrevious<T>(value: T): T | null {\n // initialise the ref with previous and current values\n const ref = React.useRef<{ value: T; prev: T | null }>({\n value: value,\n prev: null,\n })\n\n const current = ref.current.value\n\n // if the value passed into hook doesn't match what we store as \"current\"\n // move the \"current\" to the \"previous\"\n // and store the passed value as \"current\"\n if (value !== current) {\n ref.current = {\n value: value,\n prev: current,\n }\n }\n\n // return the previous value only\n return ref.current.prev\n}\n\n/**\n * React hook to wrap `IntersectionObserver`.\n *\n * This hook will create an `IntersectionObserver` and observe the ref passed to it.\n *\n * When the intersection changes, the callback will be called with the `IntersectionObserverEntry`.\n *\n * @param ref - The ref to observe\n * @param intersectionObserverOptions - The options to pass to the IntersectionObserver\n * @param options - The options to pass to the hook\n * @param callback - The callback to call when the intersection changes\n * @returns The IntersectionObserver instance\n * @example\n * ```tsx\n * const MyComponent = () => {\n * const ref = React.useRef<HTMLDivElement>(null)\n * useIntersectionObserver(\n * ref,\n * (entry) => { doSomething(entry) },\n * { rootMargin: '10px' },\n * { disabled: false }\n * )\n * return <div ref={ref} />\n * ```\n */\nexport function useIntersectionObserver<T extends Element>(\n ref: React.RefObject<T | null>,\n callback: (entry: IntersectionObserverEntry | undefined) => void,\n intersectionObserverOptions: IntersectionObserverInit = {},\n options: { disabled?: boolean } = {},\n) {\n React.useEffect(() => {\n if (\n !ref.current ||\n options.disabled ||\n typeof IntersectionObserver !== 'function'\n ) {\n return\n }\n\n const observer = new IntersectionObserver(([entry]) => {\n callback(entry)\n }, intersectionObserverOptions)\n\n observer.observe(ref.current)\n\n return () => {\n observer.disconnect()\n }\n }, [callback, intersectionObserverOptions, options.disabled, ref])\n}\n\n/**\n * React hook to take a `React.ForwardedRef` and returns a `ref` that can be used on a DOM element.\n *\n * @param ref - The forwarded ref\n * @returns The inner ref returned by `useRef`\n * @example\n * ```tsx\n * const MyComponent = React.forwardRef((props, ref) => {\n * const innerRef = useForwardedRef(ref)\n * return <div ref={innerRef} />\n * })\n * ```\n */\nexport function useForwardedRef<T>(ref?: React.ForwardedRef<T>) {\n const innerRef = React.useRef<T>(null)\n React.useImperativeHandle(ref, () => innerRef.current!, [])\n return innerRef\n}\n"],"names":[],"mappings":";AAMA,MAAM,YAAY;AAMX,MAAM,WAEI,MAAc,SAAS;AAEjC,SAAS,kBACd,IACG;AACH,QAAM,QAAQ,MAAM,OAAO,EAAE;AAC7B,QAAM,UAAU;AAEhB,QAAM,MAAM,MAAM,OAAO,IAAI,SAAqB,MAAM,QAAQ,GAAG,IAAI,CAAC;AACxE,SAAO,IAAI;AACb;AAEO,MAAM,kBACX,OAAO,WAAW,cAAc,MAAM,kBAAkB,MAAM;AAKzD,SAAS,YAAe,OAAoB;AAEjD,QAAM,MAAM,MAAM,OAAqC;AAAA,IACrD;AAAA,IACA,MAAM;AAAA,EAAA,CACP;AAED,QAAM,UAAU,IAAI,QAAQ;AAK5B,MAAI,UAAU,SAAS;AACrB,QAAI,UAAU;AAAA,MACZ;AAAA,MACA,MAAM;AAAA,IAAA;AAAA,EAEV;AAGA,SAAO,IAAI,QAAQ;AACrB;AA2BO,SAAS,wBACd,KACA,UACA,8BAAwD,CAAA,GACxD,UAAkC,IAClC;AACA,QAAM,UAAU,MAAM;AACpB,QACE,CAAC,IAAI,WACL,QAAQ,YACR,OAAO,yBAAyB,YAChC;AACA;AAAA,IACF;AAEA,UAAM,WAAW,IAAI,qBAAqB,CAAC,CAAC,KAAK,MAAM;AACrD,eAAS,KAAK;AAAA,IAChB,GAAG,2BAA2B;AAE9B,aAAS,QAAQ,IAAI,OAAO;AAE5B,WAAO,MAAM;AACX,eAAS,WAAA;AAAA,IACX;AAAA,EACF,GAAG,CAAC,UAAU,6BAA6B,QAAQ,UAAU,GAAG,CAAC;AACnE;AAeO,SAAS,gBAAmB,KAA6B;AAC9D,QAAM,WAAW,MAAM,OAAU,IAAI;AACrC,QAAM,oBAAoB,KAAK,MAAM,SAAS,SAAU,CAAA,CAAE;AAC1D,SAAO;AACT;"}
1
+ {"version":3,"file":"utils.js","sources":["../../src/utils.ts"],"sourcesContent":["import * as React from 'react'\n\n// Safe version of React.use() that will not cause compilation errors against\n// React 18 with Webpack, which statically analyzes imports and fails when it\n// sees React.use referenced (since 'use' is not exported from React 18).\n// This uses a dynamic string lookup to avoid the static analysis.\nconst REACT_USE = 'use'\n\n/**\n * React.use if available (React 19+), undefined otherwise.\n * Use dynamic lookup to avoid Webpack compilation errors with React 18.\n */\nexport const reactUse:\n | (<T>(usable: Promise<T> | React.Context<T>) => T)\n | undefined = (React as any)[REACT_USE]\n\nexport function useStableCallback<T extends (...args: Array<any>) => any>(\n fn: T,\n): T {\n const fnRef = React.useRef(fn)\n fnRef.current = fn\n\n const ref = React.useRef((...args: Array<any>) => fnRef.current(...args))\n return ref.current as T\n}\n\nexport const useLayoutEffect =\n typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect\n\n/**\n * Taken from https://www.developerway.com/posts/implementing-advanced-use-previous-hook#part3\n */\nexport function usePrevious<T>(value: T): T | null {\n // initialise the ref with previous and current values\n const ref = React.useRef<{ value: T; prev: T | null }>({\n value: value,\n prev: null,\n })\n\n const current = ref.current.value\n\n // if the value passed into hook doesn't match what we store as \"current\"\n // move the \"current\" to the \"previous\"\n // and store the passed value as \"current\"\n if (value !== current) {\n ref.current = {\n value: value,\n prev: current,\n }\n }\n\n // return the previous value only\n return ref.current.prev\n}\n\n/**\n * React hook to wrap `IntersectionObserver`.\n *\n * This hook will create an `IntersectionObserver` and observe the ref passed to it.\n *\n * When the intersection changes, the callback will be called with the `IntersectionObserverEntry`.\n *\n * @param ref - The ref to observe\n * @param intersectionObserverOptions - The options to pass to the IntersectionObserver\n * @param options - The options to pass to the hook\n * @param callback - The callback to call when the intersection changes\n * @returns The IntersectionObserver instance\n * @example\n * ```tsx\n * const MyComponent = () => {\n * const ref = React.useRef<HTMLDivElement>(null)\n * useIntersectionObserver(\n * ref,\n * (entry) => { doSomething(entry) },\n * { rootMargin: '10px' },\n * { disabled: false }\n * )\n * return <div ref={ref} />\n * ```\n */\nexport function useIntersectionObserver<T extends Element>(\n ref: React.RefObject<T | null>,\n callback: (entry: IntersectionObserverEntry | undefined) => void,\n intersectionObserverOptions: IntersectionObserverInit = {},\n options: { disabled?: boolean } = {},\n) {\n React.useEffect(() => {\n if (\n !ref.current ||\n options.disabled ||\n typeof IntersectionObserver !== 'function'\n ) {\n return\n }\n\n const observer = new IntersectionObserver(([entry]) => {\n callback(entry)\n }, intersectionObserverOptions)\n\n observer.observe(ref.current)\n\n return () => {\n observer.disconnect()\n }\n }, [callback, intersectionObserverOptions, options.disabled, ref])\n}\n\n/**\n * React hook to take a `React.ForwardedRef` and returns a `ref` that can be used on a DOM element.\n *\n * @param ref - The forwarded ref\n * @returns The inner ref returned by `useRef`\n * @example\n * ```tsx\n * const MyComponent = React.forwardRef((props, ref) => {\n * const innerRef = useForwardedRef(ref)\n * return <div ref={innerRef} />\n * })\n * ```\n */\nexport function useForwardedRef<T>(ref?: React.ForwardedRef<T>) {\n const innerRef = React.useRef<T>(null)\n React.useImperativeHandle(ref, () => innerRef.current!, [])\n return innerRef\n}\n"],"names":[],"mappings":";AAMA,MAAM,YAAY;AAMX,MAAM,WAEI,MAAc,SAAS;AAYjC,MAAM,kBACX,OAAO,WAAW,cAAc,MAAM,kBAAkB,MAAM;AAKzD,SAAS,YAAe,OAAoB;AAEjD,QAAM,MAAM,MAAM,OAAqC;AAAA,IACrD;AAAA,IACA,MAAM;AAAA,EAAA,CACP;AAED,QAAM,UAAU,IAAI,QAAQ;AAK5B,MAAI,UAAU,SAAS;AACrB,QAAI,UAAU;AAAA,MACZ;AAAA,MACA,MAAM;AAAA,IAAA;AAAA,EAEV;AAGA,SAAO,IAAI,QAAQ;AACrB;AA2BO,SAAS,wBACd,KACA,UACA,8BAAwD,CAAA,GACxD,UAAkC,IAClC;AACA,QAAM,UAAU,MAAM;AACpB,QACE,CAAC,IAAI,WACL,QAAQ,YACR,OAAO,yBAAyB,YAChC;AACA;AAAA,IACF;AAEA,UAAM,WAAW,IAAI,qBAAqB,CAAC,CAAC,KAAK,MAAM;AACrD,eAAS,KAAK;AAAA,IAChB,GAAG,2BAA2B;AAE9B,aAAS,QAAQ,IAAI,OAAO;AAE5B,WAAO,MAAM;AACX,eAAS,WAAA;AAAA,IACX;AAAA,EACF,GAAG,CAAC,UAAU,6BAA6B,QAAQ,UAAU,GAAG,CAAC;AACnE;AAeO,SAAS,gBAAmB,KAA6B;AAC9D,QAAM,WAAW,MAAM,OAAU,IAAI;AACrC,QAAM,oBAAoB,KAAK,MAAM,SAAS,SAAU,CAAA,CAAE;AAC1D,SAAO;AACT;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-router",
3
- "version": "1.162.2",
3
+ "version": "1.162.5",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -82,7 +82,7 @@
82
82
  "tiny-invariant": "^1.3.3",
83
83
  "tiny-warning": "^1.0.3",
84
84
  "@tanstack/history": "1.161.4",
85
- "@tanstack/router-core": "1.162.2"
85
+ "@tanstack/router-core": "1.162.5"
86
86
  },
87
87
  "devDependencies": {
88
88
  "@testing-library/jest-dom": "^6.6.3",
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react'
2
2
  import { Matches } from './Matches'
3
- import { getRouterContext } from './routerContext'
3
+ import { routerContext } from './routerContext'
4
4
  import type {
5
5
  AnyRouter,
6
6
  RegisteredRouter,
@@ -33,8 +33,6 @@ export function RouterContextProvider<
33
33
  })
34
34
  }
35
35
 
36
- const routerContext = getRouterContext()
37
-
38
36
  const provider = (
39
37
  <routerContext.Provider value={router as AnyRouter}>
40
38
  {children}
package/src/index.tsx CHANGED
@@ -1,6 +1,5 @@
1
1
  export {
2
2
  defer,
3
- TSR_DEFERRED_PROMISE,
4
3
  isMatch,
5
4
  joinPaths,
6
5
  cleanPath,
@@ -10,7 +9,6 @@ export {
10
9
  resolvePath,
11
10
  interpolatePath,
12
11
  rootRouteId,
13
- defaultSerializeError,
14
12
  defaultParseSearch,
15
13
  defaultStringifySearch,
16
14
  parseSearchWith,
@@ -236,7 +234,6 @@ export {
236
234
 
237
235
  export type { UseMatchRouteOptions, MakeMatchRouteOptions } from './Matches'
238
236
 
239
- export { matchContext } from './matchContext'
240
237
  export { Match, Outlet } from './Match'
241
238
 
242
239
  export { useMatch } from './useMatch'
@@ -274,13 +271,7 @@ export type {
274
271
 
275
272
  export { createRouter, Router } from './router'
276
273
 
277
- export {
278
- componentTypes,
279
- lazyFn,
280
- SearchParamError,
281
- PathParamError,
282
- getInitialRouterState,
283
- } from '@tanstack/router-core'
274
+ export { lazyFn, SearchParamError } from '@tanstack/router-core'
284
275
 
285
276
  export { RouterProvider, RouterContextProvider } from './RouterProvider'
286
277
  export type { RouterProps } from './RouterProvider'
@@ -298,21 +289,12 @@ export { useNavigate, Navigate } from './useNavigate'
298
289
  export { useParams } from './useParams'
299
290
  export { useSearch } from './useSearch'
300
291
 
301
- export {
302
- getRouterContext, // SSR
303
- } from './routerContext'
304
-
305
292
  export { useRouteContext } from './useRouteContext'
306
293
  export { useRouter } from './useRouter'
307
294
  export { useRouterState } from './useRouterState'
308
295
  export { useLocation } from './useLocation'
309
296
  export { useCanGoBack } from './useCanGoBack'
310
297
 
311
- export {
312
- useLayoutEffect, // SSR
313
- useStableCallback,
314
- } from './utils'
315
-
316
298
  export { CatchNotFound, DefaultGlobalNotFound } from './not-found'
317
299
  export { notFound, isNotFound } from '@tanstack/router-core'
318
300
  export type { NotFoundError } from '@tanstack/router-core'
@@ -1,24 +1,4 @@
1
1
  import * as React from 'react'
2
2
  import type { AnyRouter } from '@tanstack/router-core'
3
3
 
4
- declare global {
5
- interface Window {
6
- __TSR_ROUTER_CONTEXT__?: React.Context<AnyRouter>
7
- }
8
- }
9
-
10
- const routerContext = React.createContext<AnyRouter>(null!)
11
-
12
- export function getRouterContext() {
13
- if (typeof document === 'undefined') {
14
- return routerContext
15
- }
16
-
17
- if (window.__TSR_ROUTER_CONTEXT__) {
18
- return window.__TSR_ROUTER_CONTEXT__
19
- }
20
-
21
- window.__TSR_ROUTER_CONTEXT__ = routerContext as any
22
-
23
- return routerContext
24
- }
4
+ export const routerContext = React.createContext<AnyRouter>(null!)
package/src/useRouter.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react'
2
2
  import warning from 'tiny-warning'
3
- import { getRouterContext } from './routerContext'
3
+ import { routerContext } from './routerContext'
4
4
  import type { AnyRouter, RegisteredRouter } from '@tanstack/router-core'
5
5
 
6
6
  /**
@@ -16,7 +16,7 @@ import type { AnyRouter, RegisteredRouter } from '@tanstack/router-core'
16
16
  export function useRouter<TRouter extends AnyRouter = RegisteredRouter>(opts?: {
17
17
  warn?: boolean
18
18
  }): TRouter {
19
- const value = React.useContext(getRouterContext())
19
+ const value = React.useContext(routerContext)
20
20
  warning(
21
21
  !((opts?.warn ?? true) && !value),
22
22
  'useRouter must be used inside a <RouterProvider> component!',