@tanstack/react-router 1.162.4 → 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.
- package/dist/cjs/index.cjs +0 -25
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +2 -5
- package/dist/cjs/index.dev.cjs +0 -25
- package/dist/cjs/index.dev.cjs.map +1 -1
- package/dist/cjs/utils.cjs +0 -7
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/esm/index.d.ts +2 -5
- package/dist/esm/index.dev.js +1 -11
- package/dist/esm/index.dev.js.map +1 -1
- package/dist/esm/index.js +1 -11
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils.js +1 -8
- package/dist/esm/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/index.tsx +1 -15
package/dist/cjs/index.cjs
CHANGED
|
@@ -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");
|
|
@@ -27,7 +26,6 @@ const useRouter = require("./useRouter.cjs");
|
|
|
27
26
|
const useRouterState = require("./useRouterState.cjs");
|
|
28
27
|
const useLocation = require("./useLocation.cjs");
|
|
29
28
|
const useCanGoBack = require("./useCanGoBack.cjs");
|
|
30
|
-
const utils = require("./utils.cjs");
|
|
31
29
|
const notFound = require("./not-found.cjs");
|
|
32
30
|
const ScriptOnce = require("./ScriptOnce.cjs");
|
|
33
31
|
const Asset = require("./Asset.cjs");
|
|
@@ -38,26 +36,14 @@ Object.defineProperty(exports, "DEFAULT_PROTOCOL_ALLOWLIST", {
|
|
|
38
36
|
enumerable: true,
|
|
39
37
|
get: () => routerCore.DEFAULT_PROTOCOL_ALLOWLIST
|
|
40
38
|
});
|
|
41
|
-
Object.defineProperty(exports, "PathParamError", {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
get: () => routerCore.PathParamError
|
|
44
|
-
});
|
|
45
39
|
Object.defineProperty(exports, "SearchParamError", {
|
|
46
40
|
enumerable: true,
|
|
47
41
|
get: () => routerCore.SearchParamError
|
|
48
42
|
});
|
|
49
|
-
Object.defineProperty(exports, "TSR_DEFERRED_PROMISE", {
|
|
50
|
-
enumerable: true,
|
|
51
|
-
get: () => routerCore.TSR_DEFERRED_PROMISE
|
|
52
|
-
});
|
|
53
43
|
Object.defineProperty(exports, "cleanPath", {
|
|
54
44
|
enumerable: true,
|
|
55
45
|
get: () => routerCore.cleanPath
|
|
56
46
|
});
|
|
57
|
-
Object.defineProperty(exports, "componentTypes", {
|
|
58
|
-
enumerable: true,
|
|
59
|
-
get: () => routerCore.componentTypes
|
|
60
|
-
});
|
|
61
47
|
Object.defineProperty(exports, "composeRewrites", {
|
|
62
48
|
enumerable: true,
|
|
63
49
|
get: () => routerCore.composeRewrites
|
|
@@ -82,10 +68,6 @@ Object.defineProperty(exports, "defaultParseSearch", {
|
|
|
82
68
|
enumerable: true,
|
|
83
69
|
get: () => routerCore.defaultParseSearch
|
|
84
70
|
});
|
|
85
|
-
Object.defineProperty(exports, "defaultSerializeError", {
|
|
86
|
-
enumerable: true,
|
|
87
|
-
get: () => routerCore.defaultSerializeError
|
|
88
|
-
});
|
|
89
71
|
Object.defineProperty(exports, "defaultStringifySearch", {
|
|
90
72
|
enumerable: true,
|
|
91
73
|
get: () => routerCore.defaultStringifySearch
|
|
@@ -98,10 +80,6 @@ Object.defineProperty(exports, "functionalUpdate", {
|
|
|
98
80
|
enumerable: true,
|
|
99
81
|
get: () => routerCore.functionalUpdate
|
|
100
82
|
});
|
|
101
|
-
Object.defineProperty(exports, "getInitialRouterState", {
|
|
102
|
-
enumerable: true,
|
|
103
|
-
get: () => routerCore.getInitialRouterState
|
|
104
|
-
});
|
|
105
83
|
Object.defineProperty(exports, "interpolatePath", {
|
|
106
84
|
enumerable: true,
|
|
107
85
|
get: () => routerCore.interpolatePath
|
|
@@ -221,7 +199,6 @@ exports.useChildMatches = Matches.useChildMatches;
|
|
|
221
199
|
exports.useMatchRoute = Matches.useMatchRoute;
|
|
222
200
|
exports.useMatches = Matches.useMatches;
|
|
223
201
|
exports.useParentMatches = Matches.useParentMatches;
|
|
224
|
-
exports.matchContext = matchContext.matchContext;
|
|
225
202
|
exports.Match = Match.Match;
|
|
226
203
|
exports.Outlet = Match.Outlet;
|
|
227
204
|
exports.useMatch = useMatch.useMatch;
|
|
@@ -254,8 +231,6 @@ exports.useRouter = useRouter.useRouter;
|
|
|
254
231
|
exports.useRouterState = useRouterState.useRouterState;
|
|
255
232
|
exports.useLocation = useLocation.useLocation;
|
|
256
233
|
exports.useCanGoBack = useCanGoBack.useCanGoBack;
|
|
257
|
-
exports.useLayoutEffect = utils.useLayoutEffect;
|
|
258
|
-
exports.useStableCallback = utils.useStableCallback;
|
|
259
234
|
exports.CatchNotFound = notFound.CatchNotFound;
|
|
260
235
|
exports.DefaultGlobalNotFound = notFound.DefaultGlobalNotFound;
|
|
261
236
|
exports.ScriptOnce = ScriptOnce.ScriptOnce;
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { defer,
|
|
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 {
|
|
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';
|
|
@@ -37,8 +36,6 @@ export { useRouter } from './useRouter.cjs';
|
|
|
37
36
|
export { useRouterState } from './useRouterState.cjs';
|
|
38
37
|
export { useLocation } from './useLocation.cjs';
|
|
39
38
|
export { useCanGoBack } from './useCanGoBack.cjs';
|
|
40
|
-
export { useLayoutEffect, // SSR
|
|
41
|
-
useStableCallback, } from './utils.cjs';
|
|
42
39
|
export { CatchNotFound, DefaultGlobalNotFound } from './not-found.cjs';
|
|
43
40
|
export { notFound, isNotFound } from '@tanstack/router-core';
|
|
44
41
|
export type { NotFoundError } from '@tanstack/router-core';
|
package/dist/cjs/index.dev.cjs
CHANGED
|
@@ -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");
|
|
@@ -27,7 +26,6 @@ const useRouter = require("./useRouter.cjs");
|
|
|
27
26
|
const useRouterState = require("./useRouterState.cjs");
|
|
28
27
|
const useLocation = require("./useLocation.cjs");
|
|
29
28
|
const useCanGoBack = require("./useCanGoBack.cjs");
|
|
30
|
-
const utils = require("./utils.cjs");
|
|
31
29
|
const notFound = require("./not-found.cjs");
|
|
32
30
|
const ScriptOnce = require("./ScriptOnce.cjs");
|
|
33
31
|
const Asset = require("./Asset.cjs");
|
|
@@ -38,26 +36,14 @@ Object.defineProperty(exports, "DEFAULT_PROTOCOL_ALLOWLIST", {
|
|
|
38
36
|
enumerable: true,
|
|
39
37
|
get: () => routerCore.DEFAULT_PROTOCOL_ALLOWLIST
|
|
40
38
|
});
|
|
41
|
-
Object.defineProperty(exports, "PathParamError", {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
get: () => routerCore.PathParamError
|
|
44
|
-
});
|
|
45
39
|
Object.defineProperty(exports, "SearchParamError", {
|
|
46
40
|
enumerable: true,
|
|
47
41
|
get: () => routerCore.SearchParamError
|
|
48
42
|
});
|
|
49
|
-
Object.defineProperty(exports, "TSR_DEFERRED_PROMISE", {
|
|
50
|
-
enumerable: true,
|
|
51
|
-
get: () => routerCore.TSR_DEFERRED_PROMISE
|
|
52
|
-
});
|
|
53
43
|
Object.defineProperty(exports, "cleanPath", {
|
|
54
44
|
enumerable: true,
|
|
55
45
|
get: () => routerCore.cleanPath
|
|
56
46
|
});
|
|
57
|
-
Object.defineProperty(exports, "componentTypes", {
|
|
58
|
-
enumerable: true,
|
|
59
|
-
get: () => routerCore.componentTypes
|
|
60
|
-
});
|
|
61
47
|
Object.defineProperty(exports, "composeRewrites", {
|
|
62
48
|
enumerable: true,
|
|
63
49
|
get: () => routerCore.composeRewrites
|
|
@@ -82,10 +68,6 @@ Object.defineProperty(exports, "defaultParseSearch", {
|
|
|
82
68
|
enumerable: true,
|
|
83
69
|
get: () => routerCore.defaultParseSearch
|
|
84
70
|
});
|
|
85
|
-
Object.defineProperty(exports, "defaultSerializeError", {
|
|
86
|
-
enumerable: true,
|
|
87
|
-
get: () => routerCore.defaultSerializeError
|
|
88
|
-
});
|
|
89
71
|
Object.defineProperty(exports, "defaultStringifySearch", {
|
|
90
72
|
enumerable: true,
|
|
91
73
|
get: () => routerCore.defaultStringifySearch
|
|
@@ -98,10 +80,6 @@ Object.defineProperty(exports, "functionalUpdate", {
|
|
|
98
80
|
enumerable: true,
|
|
99
81
|
get: () => routerCore.functionalUpdate
|
|
100
82
|
});
|
|
101
|
-
Object.defineProperty(exports, "getInitialRouterState", {
|
|
102
|
-
enumerable: true,
|
|
103
|
-
get: () => routerCore.getInitialRouterState
|
|
104
|
-
});
|
|
105
83
|
Object.defineProperty(exports, "interpolatePath", {
|
|
106
84
|
enumerable: true,
|
|
107
85
|
get: () => routerCore.interpolatePath
|
|
@@ -221,7 +199,6 @@ exports.useChildMatches = Matches.useChildMatches;
|
|
|
221
199
|
exports.useMatchRoute = Matches.useMatchRoute;
|
|
222
200
|
exports.useMatches = Matches.useMatches;
|
|
223
201
|
exports.useParentMatches = Matches.useParentMatches;
|
|
224
|
-
exports.matchContext = matchContext.matchContext;
|
|
225
202
|
exports.Match = Match.Match;
|
|
226
203
|
exports.Outlet = Match.Outlet;
|
|
227
204
|
exports.useMatch = useMatch.useMatch;
|
|
@@ -254,8 +231,6 @@ exports.useRouter = useRouter.useRouter;
|
|
|
254
231
|
exports.useRouterState = useRouterState.useRouterState;
|
|
255
232
|
exports.useLocation = useLocation.useLocation;
|
|
256
233
|
exports.useCanGoBack = useCanGoBack.useCanGoBack;
|
|
257
|
-
exports.useLayoutEffect = utils.useLayoutEffect;
|
|
258
|
-
exports.useStableCallback = utils.useStableCallback;
|
|
259
234
|
exports.CatchNotFound = notFound.CatchNotFound;
|
|
260
235
|
exports.DefaultGlobalNotFound = notFound.DefaultGlobalNotFound;
|
|
261
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/cjs/utils.cjs
CHANGED
|
@@ -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
|
package/dist/cjs/utils.cjs.map
CHANGED
|
@@ -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;
|
|
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;;;;;;"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { defer,
|
|
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 {
|
|
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';
|
|
@@ -37,8 +36,6 @@ export { useRouter } from './useRouter.js';
|
|
|
37
36
|
export { useRouterState } from './useRouterState.js';
|
|
38
37
|
export { useLocation } from './useLocation.js';
|
|
39
38
|
export { useCanGoBack } from './useCanGoBack.js';
|
|
40
|
-
export { useLayoutEffect, // SSR
|
|
41
|
-
useStableCallback, } from './utils.js';
|
|
42
39
|
export { CatchNotFound, DefaultGlobalNotFound } from './not-found.js';
|
|
43
40
|
export { notFound, isNotFound } from '@tanstack/router-core';
|
|
44
41
|
export type { NotFoundError } from '@tanstack/router-core';
|
package/dist/esm/index.dev.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_PROTOCOL_ALLOWLIST,
|
|
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";
|
|
@@ -25,7 +24,6 @@ import { useRouter } from "./useRouter.js";
|
|
|
25
24
|
import { useRouterState } from "./useRouterState.js";
|
|
26
25
|
import { useLocation } from "./useLocation.js";
|
|
27
26
|
import { useCanGoBack } from "./useCanGoBack.js";
|
|
28
|
-
import { useLayoutEffect, useStableCallback } from "./utils.js";
|
|
29
27
|
import { CatchNotFound, DefaultGlobalNotFound } from "./not-found.js";
|
|
30
28
|
import { ScriptOnce } from "./ScriptOnce.js";
|
|
31
29
|
import { Asset } from "./Asset.js";
|
|
@@ -53,7 +51,6 @@ export {
|
|
|
53
51
|
Navigate,
|
|
54
52
|
NotFoundRoute,
|
|
55
53
|
Outlet,
|
|
56
|
-
PathParamError,
|
|
57
54
|
RootRoute,
|
|
58
55
|
Route,
|
|
59
56
|
RouteApi,
|
|
@@ -64,9 +61,7 @@ export {
|
|
|
64
61
|
Scripts,
|
|
65
62
|
ScrollRestoration,
|
|
66
63
|
SearchParamError,
|
|
67
|
-
TSR_DEFERRED_PROMISE,
|
|
68
64
|
cleanPath,
|
|
69
|
-
componentTypes,
|
|
70
65
|
composeRewrites,
|
|
71
66
|
createBrowserHistory,
|
|
72
67
|
createControlledPromise,
|
|
@@ -86,11 +81,9 @@ export {
|
|
|
86
81
|
createSerializationAdapter,
|
|
87
82
|
deepEqual,
|
|
88
83
|
defaultParseSearch,
|
|
89
|
-
defaultSerializeError,
|
|
90
84
|
defaultStringifySearch,
|
|
91
85
|
defer,
|
|
92
86
|
functionalUpdate,
|
|
93
|
-
getInitialRouterState,
|
|
94
87
|
getRouteApi,
|
|
95
88
|
interpolatePath,
|
|
96
89
|
isMatch,
|
|
@@ -102,7 +95,6 @@ export {
|
|
|
102
95
|
lazyFn,
|
|
103
96
|
lazyRouteComponent,
|
|
104
97
|
linkOptions,
|
|
105
|
-
matchContext,
|
|
106
98
|
notFound,
|
|
107
99
|
parseSearchWith,
|
|
108
100
|
redirect,
|
|
@@ -122,7 +114,6 @@ export {
|
|
|
122
114
|
useChildMatches,
|
|
123
115
|
useElementScrollRestoration,
|
|
124
116
|
useHydrated,
|
|
125
|
-
useLayoutEffect,
|
|
126
117
|
useLinkProps,
|
|
127
118
|
useLoaderData,
|
|
128
119
|
useLoaderDeps,
|
|
@@ -137,7 +128,6 @@ export {
|
|
|
137
128
|
useRouter,
|
|
138
129
|
useRouterState,
|
|
139
130
|
useSearch,
|
|
140
|
-
useStableCallback,
|
|
141
131
|
useTags
|
|
142
132
|
};
|
|
143
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,
|
|
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";
|
|
@@ -25,7 +24,6 @@ import { useRouter } from "./useRouter.js";
|
|
|
25
24
|
import { useRouterState } from "./useRouterState.js";
|
|
26
25
|
import { useLocation } from "./useLocation.js";
|
|
27
26
|
import { useCanGoBack } from "./useCanGoBack.js";
|
|
28
|
-
import { useLayoutEffect, useStableCallback } from "./utils.js";
|
|
29
27
|
import { CatchNotFound, DefaultGlobalNotFound } from "./not-found.js";
|
|
30
28
|
import { ScriptOnce } from "./ScriptOnce.js";
|
|
31
29
|
import { Asset } from "./Asset.js";
|
|
@@ -53,7 +51,6 @@ export {
|
|
|
53
51
|
Navigate,
|
|
54
52
|
NotFoundRoute,
|
|
55
53
|
Outlet,
|
|
56
|
-
PathParamError,
|
|
57
54
|
RootRoute,
|
|
58
55
|
Route,
|
|
59
56
|
RouteApi,
|
|
@@ -64,9 +61,7 @@ export {
|
|
|
64
61
|
Scripts,
|
|
65
62
|
ScrollRestoration,
|
|
66
63
|
SearchParamError,
|
|
67
|
-
TSR_DEFERRED_PROMISE,
|
|
68
64
|
cleanPath,
|
|
69
|
-
componentTypes,
|
|
70
65
|
composeRewrites,
|
|
71
66
|
createBrowserHistory,
|
|
72
67
|
createControlledPromise,
|
|
@@ -86,11 +81,9 @@ export {
|
|
|
86
81
|
createSerializationAdapter,
|
|
87
82
|
deepEqual,
|
|
88
83
|
defaultParseSearch,
|
|
89
|
-
defaultSerializeError,
|
|
90
84
|
defaultStringifySearch,
|
|
91
85
|
defer,
|
|
92
86
|
functionalUpdate,
|
|
93
|
-
getInitialRouterState,
|
|
94
87
|
getRouteApi,
|
|
95
88
|
interpolatePath,
|
|
96
89
|
isMatch,
|
|
@@ -102,7 +95,6 @@ export {
|
|
|
102
95
|
lazyFn,
|
|
103
96
|
lazyRouteComponent,
|
|
104
97
|
linkOptions,
|
|
105
|
-
matchContext,
|
|
106
98
|
notFound,
|
|
107
99
|
parseSearchWith,
|
|
108
100
|
redirect,
|
|
@@ -122,7 +114,6 @@ export {
|
|
|
122
114
|
useChildMatches,
|
|
123
115
|
useElementScrollRestoration,
|
|
124
116
|
useHydrated,
|
|
125
|
-
useLayoutEffect,
|
|
126
117
|
useLinkProps,
|
|
127
118
|
useLoaderData,
|
|
128
119
|
useLoaderDeps,
|
|
@@ -137,7 +128,6 @@ export {
|
|
|
137
128
|
useRouter,
|
|
138
129
|
useRouterState,
|
|
139
130
|
useSearch,
|
|
140
|
-
useStableCallback,
|
|
141
131
|
useTags
|
|
142
132
|
};
|
|
143
133
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
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
|
package/dist/esm/utils.js.map
CHANGED
|
@@ -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;
|
|
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.
|
|
3
|
+
"version": "1.162.5",
|
|
4
4
|
"description": "Modern and scalable routing for React applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -81,8 +81,8 @@
|
|
|
81
81
|
"isbot": "^5.1.22",
|
|
82
82
|
"tiny-invariant": "^1.3.3",
|
|
83
83
|
"tiny-warning": "^1.0.3",
|
|
84
|
-
"@tanstack/
|
|
85
|
-
"@tanstack/
|
|
84
|
+
"@tanstack/history": "1.161.4",
|
|
85
|
+
"@tanstack/router-core": "1.162.5"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@testing-library/jest-dom": "^6.6.3",
|
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'
|
|
@@ -304,11 +295,6 @@ export { useRouterState } from './useRouterState'
|
|
|
304
295
|
export { useLocation } from './useLocation'
|
|
305
296
|
export { useCanGoBack } from './useCanGoBack'
|
|
306
297
|
|
|
307
|
-
export {
|
|
308
|
-
useLayoutEffect, // SSR
|
|
309
|
-
useStableCallback,
|
|
310
|
-
} from './utils'
|
|
311
|
-
|
|
312
298
|
export { CatchNotFound, DefaultGlobalNotFound } from './not-found'
|
|
313
299
|
export { notFound, isNotFound } from '@tanstack/router-core'
|
|
314
300
|
export type { NotFoundError } from '@tanstack/router-core'
|