@tanstack/react-router 1.114.15 → 1.114.17
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.d.cts +2 -1
- package/dist/cjs/typePrimitives.d.cts +4 -62
- package/dist/cjs/useMatch.cjs.map +1 -1
- package/dist/cjs/useMatch.d.cts +1 -2
- package/dist/cjs/useParams.cjs.map +1 -1
- package/dist/cjs/useParams.d.cts +1 -2
- package/dist/cjs/useSearch.cjs.map +1 -1
- package/dist/cjs/useSearch.d.cts +1 -2
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/typePrimitives.d.ts +4 -62
- package/dist/esm/useMatch.d.ts +1 -2
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useParams.d.ts +1 -2
- package/dist/esm/useParams.js.map +1 -1
- package/dist/esm/useSearch.d.ts +1 -2
- package/dist/esm/useSearch.js.map +1 -1
- package/package.json +3 -3
- package/src/index.tsx +28 -1
- package/src/typePrimitives.ts +17 -189
- package/src/useMatch.tsx +1 -5
- package/src/useParams.tsx +1 -1
- package/src/useSearch.tsx +1 -1
package/dist/cjs/index.d.cts
CHANGED
|
@@ -44,7 +44,8 @@ useStableCallback, } from './utils.cjs';
|
|
|
44
44
|
export { CatchNotFound, DefaultGlobalNotFound } from './not-found.cjs';
|
|
45
45
|
export { notFound, isNotFound } from '@tanstack/router-core';
|
|
46
46
|
export type { NotFoundError } from '@tanstack/router-core';
|
|
47
|
-
export
|
|
47
|
+
export type { ValidateLinkOptions, InferStructuralSharing, ValidateUseSearchOptions, ValidateUseParamsOptions, ValidateLinkOptionsArray, } from './typePrimitives.cjs';
|
|
48
|
+
export type { ValidateFromPath, ValidateToPath, ValidateSearch, ValidateParams, InferFrom, InferTo, InferMaskTo, InferMaskFrom, ValidateNavigateOptions, ValidateNavigateOptionsArray, ValidateRedirectOptions, ValidateRedirectOptionsArray, ValidateId, InferStrict, InferShouldThrow, InferSelected, ValidateUseSearchResult, ValidateUseParamsResult, } from '@tanstack/router-core';
|
|
48
49
|
export { ScriptOnce } from './ScriptOnce.cjs';
|
|
49
50
|
export { Asset } from './Asset.cjs';
|
|
50
51
|
export { HeadContent } from './HeadContent.cjs';
|
|
@@ -1,67 +1,8 @@
|
|
|
1
|
-
import { AnyRouter, Constrain,
|
|
1
|
+
import { AnyRouter, Constrain, InferFrom, InferMaskFrom, InferMaskTo, InferSelected, InferShouldThrow, InferStrict, InferTo, RegisteredRouter } from '@tanstack/router-core';
|
|
2
2
|
import { LinkComponentProps } from './link.cjs';
|
|
3
3
|
import { UseParamsOptions } from './useParams.cjs';
|
|
4
4
|
import { UseSearchOptions } from './useSearch.cjs';
|
|
5
|
-
export type ValidateFromPath<TRouter extends AnyRouter = RegisteredRouter, TFrom = string> = FromPathOption<TRouter, TFrom>;
|
|
6
|
-
export type ValidateToPath<TRouter extends AnyRouter = RegisteredRouter, TTo extends string | undefined = undefined, TFrom extends string = string> = ToPathOption<TRouter, TFrom, TTo>;
|
|
7
|
-
export type ValidateSearch<TRouter extends AnyRouter = RegisteredRouter, TTo extends string | undefined = undefined, TFrom extends string = string> = SearchParamOptions<TRouter, TFrom, TTo>;
|
|
8
|
-
export type ValidateParams<TRouter extends AnyRouter = RegisteredRouter, TTo extends string | undefined = undefined, TFrom extends string = string> = PathParamOptions<TRouter, TFrom, TTo>;
|
|
9
|
-
/**
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
12
|
-
export type InferFrom<TOptions, TDefaultFrom extends string = string> = TOptions extends {
|
|
13
|
-
from: infer TFrom extends string;
|
|
14
|
-
} ? TFrom : TDefaultFrom;
|
|
15
|
-
/**
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
export type InferTo<TOptions> = TOptions extends {
|
|
19
|
-
to: infer TTo extends string;
|
|
20
|
-
} ? TTo : undefined;
|
|
21
|
-
/**
|
|
22
|
-
* @internal
|
|
23
|
-
*/
|
|
24
|
-
export type InferMaskTo<TOptions> = TOptions extends {
|
|
25
|
-
mask: {
|
|
26
|
-
to: infer TTo extends string;
|
|
27
|
-
};
|
|
28
|
-
} ? TTo : '';
|
|
29
|
-
export type InferMaskFrom<TOptions> = TOptions extends {
|
|
30
|
-
mask: {
|
|
31
|
-
from: infer TFrom extends string;
|
|
32
|
-
};
|
|
33
|
-
} ? TFrom : string;
|
|
34
|
-
export type ValidateNavigateOptions<TRouter extends AnyRouter = RegisteredRouter, TOptions = unknown, TDefaultFrom extends string = string> = Constrain<TOptions, NavigateOptions<TRouter, InferFrom<TOptions, TDefaultFrom>, InferTo<TOptions>, InferMaskFrom<TOptions>, InferMaskTo<TOptions>>>;
|
|
35
|
-
export type ValidateNavigateOptionsArray<TRouter extends AnyRouter = RegisteredRouter, TOptions extends ReadonlyArray<any> = ReadonlyArray<unknown>, TDefaultFrom extends string = string> = {
|
|
36
|
-
[K in keyof TOptions]: ValidateNavigateOptions<TRouter, TOptions[K], TDefaultFrom>;
|
|
37
|
-
};
|
|
38
|
-
export type ValidateRedirectOptions<TRouter extends AnyRouter = RegisteredRouter, TOptions = unknown, TDefaultFrom extends string = string> = Constrain<TOptions, Redirect<TRouter, InferFrom<TOptions, TDefaultFrom>, InferTo<TOptions>, InferMaskFrom<TOptions>, InferMaskTo<TOptions>>>;
|
|
39
|
-
export type ValidateRedirectOptionsArray<TRouter extends AnyRouter = RegisteredRouter, TOptions extends ReadonlyArray<any> = ReadonlyArray<unknown>, TDefaultFrom extends string = string> = {
|
|
40
|
-
[K in keyof TOptions]: ValidateRedirectOptions<TRouter, TOptions[K], TDefaultFrom>;
|
|
41
|
-
};
|
|
42
5
|
export type ValidateLinkOptions<TRouter extends AnyRouter = RegisteredRouter, TOptions = unknown, TDefaultFrom extends string = string, TComp = 'a'> = Constrain<TOptions, LinkComponentProps<TComp, TRouter, InferFrom<TOptions, TDefaultFrom>, InferTo<TOptions>, InferMaskFrom<TOptions>, InferMaskTo<TOptions>>>;
|
|
43
|
-
export type ValidateLinkOptionsArray<TRouter extends AnyRouter = RegisteredRouter, TOptions extends ReadonlyArray<any> = ReadonlyArray<unknown>, TDefaultFrom extends string = string, TComp = 'a'> = {
|
|
44
|
-
[K in keyof TOptions]: ValidateLinkOptions<TRouter, TOptions[K], TDefaultFrom, TComp>;
|
|
45
|
-
};
|
|
46
|
-
export type ValidateId<TRouter extends AnyRouter = RegisteredRouter, TId extends string = string> = ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>;
|
|
47
|
-
/**
|
|
48
|
-
* @internal
|
|
49
|
-
*/
|
|
50
|
-
export type InferStrict<TOptions> = TOptions extends {
|
|
51
|
-
strict: infer TStrict extends boolean;
|
|
52
|
-
} ? TStrict : true;
|
|
53
|
-
/**
|
|
54
|
-
* @internal
|
|
55
|
-
*/
|
|
56
|
-
export type InferShouldThrow<TOptions> = TOptions extends {
|
|
57
|
-
shouldThrow: infer TShouldThrow extends boolean;
|
|
58
|
-
} ? TShouldThrow : true;
|
|
59
|
-
/**
|
|
60
|
-
* @internal
|
|
61
|
-
*/
|
|
62
|
-
export type InferSelected<TOptions> = TOptions extends {
|
|
63
|
-
select: (...args: Array<any>) => infer TSelected;
|
|
64
|
-
} ? TSelected : unknown;
|
|
65
6
|
/**
|
|
66
7
|
* @internal
|
|
67
8
|
*/
|
|
@@ -69,6 +10,7 @@ export type InferStructuralSharing<TOptions> = TOptions extends {
|
|
|
69
10
|
structuralSharing: infer TStructuralSharing;
|
|
70
11
|
} ? TStructuralSharing : unknown;
|
|
71
12
|
export type ValidateUseSearchOptions<TOptions, TRouter extends AnyRouter = RegisteredRouter> = Constrain<TOptions, UseSearchOptions<TRouter, InferFrom<TOptions>, InferStrict<TOptions>, InferShouldThrow<TOptions>, InferSelected<TOptions>, InferStructuralSharing<TOptions>>>;
|
|
72
|
-
export type ValidateUseSearchResult<TOptions, TRouter extends AnyRouter = RegisteredRouter> = UseSearchResult<TRouter, InferFrom<TOptions>, InferStrict<TOptions>, InferSelected<TOptions>>;
|
|
73
13
|
export type ValidateUseParamsOptions<TOptions, TRouter extends AnyRouter = RegisteredRouter> = Constrain<TOptions, UseParamsOptions<TRouter, InferFrom<TOptions>, InferStrict<TOptions>, InferShouldThrow<TOptions>, InferSelected<TOptions>, InferSelected<TOptions>>>;
|
|
74
|
-
export type
|
|
14
|
+
export type ValidateLinkOptionsArray<TRouter extends AnyRouter = RegisteredRouter, TOptions extends ReadonlyArray<any> = ReadonlyArray<unknown>, TDefaultFrom extends string = string, TComp = 'a'> = {
|
|
15
|
+
[K in keyof TOptions]: ValidateLinkOptions<TRouter, TOptions[K], TDefaultFrom, TComp>;
|
|
16
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMatch.cjs","sources":["../../src/useMatch.tsx"],"sourcesContent":["import * as React from 'react'\nimport invariant from 'tiny-invariant'\nimport { useRouterState } from './useRouterState'\nimport { dummyMatchContext, matchContext } from './matchContext'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRouter,\n MakeRouteMatch,\n MakeRouteMatchUnion,\n RegisteredRouter,\n StrictOrFrom,\n ThrowOrOptional,\n} from '@tanstack/router-core'\n\nexport interface UseMatchBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing extends boolean,\n> {\n select?: (\n match: MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n shouldThrow?: TThrow\n}\n\nexport type UseMatchRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseMatchBaseOptions<\n TRouter,\n TFrom,\n true,\n true,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n) => UseMatchResult<TRouter, TFrom, true, TSelected>\n\nexport type UseMatchOptions<\n TRouter extends AnyRouter,\n TFrom extends string | undefined,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing extends boolean,\n> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseMatchBaseOptions<\n TRouter,\n TFrom,\n TStrict,\n TThrow,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>\n\nexport type UseMatchResult<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TSelected,\n> = unknown extends TSelected\n ? TStrict extends true\n ? MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>\n : MakeRouteMatchUnion<TRouter>\n : TSelected\n\nexport
|
|
1
|
+
{"version":3,"file":"useMatch.cjs","sources":["../../src/useMatch.tsx"],"sourcesContent":["import * as React from 'react'\nimport invariant from 'tiny-invariant'\nimport { useRouterState } from './useRouterState'\nimport { dummyMatchContext, matchContext } from './matchContext'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRouter,\n MakeRouteMatch,\n MakeRouteMatchUnion,\n RegisteredRouter,\n StrictOrFrom,\n ThrowConstraint,\n ThrowOrOptional,\n} from '@tanstack/router-core'\n\nexport interface UseMatchBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing extends boolean,\n> {\n select?: (\n match: MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n shouldThrow?: TThrow\n}\n\nexport type UseMatchRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseMatchBaseOptions<\n TRouter,\n TFrom,\n true,\n true,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n) => UseMatchResult<TRouter, TFrom, true, TSelected>\n\nexport type UseMatchOptions<\n TRouter extends AnyRouter,\n TFrom extends string | undefined,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing extends boolean,\n> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseMatchBaseOptions<\n TRouter,\n TFrom,\n TStrict,\n TThrow,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>\n\nexport type UseMatchResult<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TSelected,\n> = unknown extends TSelected\n ? TStrict extends true\n ? MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>\n : MakeRouteMatchUnion<TRouter>\n : TSelected\n\nexport function useMatch<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string | undefined = undefined,\n TStrict extends boolean = true,\n TThrow extends boolean = true,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts: UseMatchOptions<\n TRouter,\n TFrom,\n TStrict,\n ThrowConstraint<TStrict, TThrow>,\n TSelected,\n TStructuralSharing\n >,\n): ThrowOrOptional<UseMatchResult<TRouter, TFrom, TStrict, TSelected>, TThrow> {\n const nearestMatchId = React.useContext(\n opts.from ? dummyMatchContext : matchContext,\n )\n\n const matchSelection = useRouterState({\n select: (state: any) => {\n const match = state.matches.find((d: any) =>\n opts.from ? opts.from === d.routeId : d.id === nearestMatchId,\n )\n invariant(\n !((opts.shouldThrow ?? true) && !match),\n `Could not find ${opts.from ? `an active match from \"${opts.from}\"` : 'a nearest match!'}`,\n )\n\n if (match === undefined) {\n return undefined\n }\n\n return opts.select ? opts.select(match) : match\n },\n structuralSharing: opts.structuralSharing,\n } as any)\n\n return matchSelection as any\n}\n"],"names":["React","dummyMatchContext","matchContext","useRouterState"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA6EO,SAAS,SAQd,MAQ6E;AAC7E,QAAM,iBAAiBA,iBAAM;AAAA,IAC3B,KAAK,OAAOC,iCAAoBC,aAAAA;AAAAA,EAClC;AAEA,QAAM,iBAAiBC,eAAAA,eAAe;AAAA,IACpC,QAAQ,CAAC,UAAe;AAChB,YAAA,QAAQ,MAAM,QAAQ;AAAA,QAAK,CAAC,MAChC,KAAK,OAAO,KAAK,SAAS,EAAE,UAAU,EAAE,OAAO;AAAA,MACjD;AACA;AAAA,QACE,GAAG,KAAK,eAAe,SAAS,CAAC;AAAA,QACjC,kBAAkB,KAAK,OAAO,yBAAyB,KAAK,IAAI,MAAM,kBAAkB;AAAA,MAC1F;AAEA,UAAI,UAAU,QAAW;AAChB,eAAA;AAAA,MAAA;AAGT,aAAO,KAAK,SAAS,KAAK,OAAO,KAAK,IAAI;AAAA,IAC5C;AAAA,IACA,mBAAmB,KAAK;AAAA,EAAA,CAClB;AAED,SAAA;AACT;;"}
|
package/dist/cjs/useMatch.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StructuralSharingOption, ValidateSelected } from './structuralSharing.cjs';
|
|
2
|
-
import { AnyRouter, MakeRouteMatch, MakeRouteMatchUnion, RegisteredRouter, StrictOrFrom, ThrowOrOptional } from '@tanstack/router-core';
|
|
2
|
+
import { AnyRouter, MakeRouteMatch, MakeRouteMatchUnion, RegisteredRouter, StrictOrFrom, ThrowConstraint, ThrowOrOptional } from '@tanstack/router-core';
|
|
3
3
|
export interface UseMatchBaseOptions<TRouter extends AnyRouter, TFrom, TStrict extends boolean, TThrow extends boolean, TSelected, TStructuralSharing extends boolean> {
|
|
4
4
|
select?: (match: MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>) => ValidateSelected<TRouter, TSelected, TStructuralSharing>;
|
|
5
5
|
shouldThrow?: TThrow;
|
|
@@ -7,5 +7,4 @@ export interface UseMatchBaseOptions<TRouter extends AnyRouter, TFrom, TStrict e
|
|
|
7
7
|
export type UseMatchRoute<out TFrom> = <TRouter extends AnyRouter = RegisteredRouter, TSelected = unknown, TStructuralSharing extends boolean = boolean>(opts?: UseMatchBaseOptions<TRouter, TFrom, true, true, TSelected, TStructuralSharing> & StructuralSharingOption<TRouter, TSelected, TStructuralSharing>) => UseMatchResult<TRouter, TFrom, true, TSelected>;
|
|
8
8
|
export type UseMatchOptions<TRouter extends AnyRouter, TFrom extends string | undefined, TStrict extends boolean, TThrow extends boolean, TSelected, TStructuralSharing extends boolean> = StrictOrFrom<TRouter, TFrom, TStrict> & UseMatchBaseOptions<TRouter, TFrom, TStrict, TThrow, TSelected, TStructuralSharing> & StructuralSharingOption<TRouter, TSelected, TStructuralSharing>;
|
|
9
9
|
export type UseMatchResult<TRouter extends AnyRouter, TFrom, TStrict extends boolean, TSelected> = unknown extends TSelected ? TStrict extends true ? MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict> : MakeRouteMatchUnion<TRouter> : TSelected;
|
|
10
|
-
export type ThrowConstraint<TStrict extends boolean, TThrow extends boolean> = TStrict extends false ? (TThrow extends true ? never : TThrow) : TThrow;
|
|
11
10
|
export declare function useMatch<TRouter extends AnyRouter = RegisteredRouter, const TFrom extends string | undefined = undefined, TStrict extends boolean = true, TThrow extends boolean = true, TSelected = unknown, TStructuralSharing extends boolean = boolean>(opts: UseMatchOptions<TRouter, TFrom, TStrict, ThrowConstraint<TStrict, TThrow>, TSelected, TStructuralSharing>): ThrowOrOptional<UseMatchResult<TRouter, TFrom, TStrict, TSelected>, TThrow>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useParams.cjs","sources":["../../src/useParams.tsx"],"sourcesContent":["import { useMatch } from './useMatch'\nimport type {
|
|
1
|
+
{"version":3,"file":"useParams.cjs","sources":["../../src/useParams.tsx"],"sourcesContent":["import { useMatch } from './useMatch'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRouter,\n RegisteredRouter,\n ResolveUseParams,\n StrictOrFrom,\n ThrowConstraint,\n ThrowOrOptional,\n UseParamsResult,\n} from '@tanstack/router-core'\n\nexport interface UseParamsBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing,\n> {\n select?: (\n params: ResolveUseParams<TRouter, TFrom, TStrict>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n shouldThrow?: TThrow\n}\n\nexport type UseParamsOptions<\n TRouter extends AnyRouter,\n TFrom extends string | undefined,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing,\n> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseParamsBaseOptions<\n TRouter,\n TFrom,\n TStrict,\n TThrow,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>\n\nexport type UseParamsRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseParamsBaseOptions<\n TRouter,\n TFrom,\n /* TStrict */ true,\n /* TThrow */ true,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n) => UseParamsResult<TRouter, TFrom, true, TSelected>\n\nexport function useParams<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string | undefined = undefined,\n TStrict extends boolean = true,\n TThrow extends boolean = true,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts: UseParamsOptions<\n TRouter,\n TFrom,\n TStrict,\n ThrowConstraint<TStrict, TThrow>,\n TSelected,\n TStructuralSharing\n >,\n): ThrowOrOptional<\n UseParamsResult<TRouter, TFrom, TStrict, TSelected>,\n TThrow\n> {\n return useMatch({\n from: opts.from!,\n strict: opts.strict,\n shouldThrow: opts.shouldThrow,\n structuralSharing: opts.structuralSharing,\n select: (match: any) => {\n return opts.select ? opts.select(match.params) : match.params\n },\n }) as any\n}\n"],"names":["useMatch"],"mappings":";;;AA+DO,SAAS,UAQd,MAWA;AACA,SAAOA,kBAAS;AAAA,IACd,MAAM,KAAK;AAAA,IACX,QAAQ,KAAK;AAAA,IACb,aAAa,KAAK;AAAA,IAClB,mBAAmB,KAAK;AAAA,IACxB,QAAQ,CAAC,UAAe;AACtB,aAAO,KAAK,SAAS,KAAK,OAAO,MAAM,MAAM,IAAI,MAAM;AAAA,IAAA;AAAA,EACzD,CACD;AACH;;"}
|
package/dist/cjs/useParams.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ThrowConstraint } from './useMatch.cjs';
|
|
2
1
|
import { StructuralSharingOption, ValidateSelected } from './structuralSharing.cjs';
|
|
3
|
-
import { AnyRouter, RegisteredRouter, ResolveUseParams, StrictOrFrom, ThrowOrOptional, UseParamsResult } from '@tanstack/router-core';
|
|
2
|
+
import { AnyRouter, RegisteredRouter, ResolveUseParams, StrictOrFrom, ThrowConstraint, ThrowOrOptional, UseParamsResult } from '@tanstack/router-core';
|
|
4
3
|
export interface UseParamsBaseOptions<TRouter extends AnyRouter, TFrom, TStrict extends boolean, TThrow extends boolean, TSelected, TStructuralSharing> {
|
|
5
4
|
select?: (params: ResolveUseParams<TRouter, TFrom, TStrict>) => ValidateSelected<TRouter, TSelected, TStructuralSharing>;
|
|
6
5
|
shouldThrow?: TThrow;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSearch.cjs","sources":["../../src/useSearch.tsx"],"sourcesContent":["import { useMatch } from './useMatch'\nimport type {
|
|
1
|
+
{"version":3,"file":"useSearch.cjs","sources":["../../src/useSearch.tsx"],"sourcesContent":["import { useMatch } from './useMatch'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRouter,\n RegisteredRouter,\n ResolveUseSearch,\n StrictOrFrom,\n ThrowConstraint,\n ThrowOrOptional,\n UseSearchResult,\n} from '@tanstack/router-core'\n\nexport interface UseSearchBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing,\n> {\n select?: (\n state: ResolveUseSearch<TRouter, TFrom, TStrict>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n shouldThrow?: TThrow\n}\n\nexport type UseSearchOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing,\n> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseSearchBaseOptions<\n TRouter,\n TFrom,\n TStrict,\n TThrow,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>\n\nexport type UseSearchRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseSearchBaseOptions<\n TRouter,\n TFrom,\n /* TStrict */ true,\n /* TThrow */ true,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n) => UseSearchResult<TRouter, TFrom, true, TSelected>\n\nexport function useSearch<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string | undefined = undefined,\n TStrict extends boolean = true,\n TThrow extends boolean = true,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts: UseSearchOptions<\n TRouter,\n TFrom,\n TStrict,\n ThrowConstraint<TStrict, TThrow>,\n TSelected,\n TStructuralSharing\n >,\n): ThrowOrOptional<\n UseSearchResult<TRouter, TFrom, TStrict, TSelected>,\n TThrow\n> {\n return useMatch({\n from: opts.from!,\n strict: opts.strict,\n shouldThrow: opts.shouldThrow,\n structuralSharing: opts.structuralSharing,\n select: (match: any) => {\n return opts.select ? opts.select(match.search) : match.search\n },\n }) as any\n}\n"],"names":["useMatch"],"mappings":";;;AA+DO,SAAS,UAQd,MAWA;AACA,SAAOA,kBAAS;AAAA,IACd,MAAM,KAAK;AAAA,IACX,QAAQ,KAAK;AAAA,IACb,aAAa,KAAK;AAAA,IAClB,mBAAmB,KAAK;AAAA,IACxB,QAAQ,CAAC,UAAe;AACtB,aAAO,KAAK,SAAS,KAAK,OAAO,MAAM,MAAM,IAAI,MAAM;AAAA,IAAA;AAAA,EACzD,CACD;AACH;;"}
|
package/dist/cjs/useSearch.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ThrowConstraint } from './useMatch.cjs';
|
|
2
1
|
import { StructuralSharingOption, ValidateSelected } from './structuralSharing.cjs';
|
|
3
|
-
import { AnyRouter, RegisteredRouter, ResolveUseSearch, StrictOrFrom, ThrowOrOptional, UseSearchResult } from '@tanstack/router-core';
|
|
2
|
+
import { AnyRouter, RegisteredRouter, ResolveUseSearch, StrictOrFrom, ThrowConstraint, ThrowOrOptional, UseSearchResult } from '@tanstack/router-core';
|
|
4
3
|
export interface UseSearchBaseOptions<TRouter extends AnyRouter, TFrom, TStrict extends boolean, TThrow extends boolean, TSelected, TStructuralSharing> {
|
|
5
4
|
select?: (state: ResolveUseSearch<TRouter, TFrom, TStrict>) => ValidateSelected<TRouter, TSelected, TStructuralSharing>;
|
|
6
5
|
shouldThrow?: TThrow;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -44,7 +44,8 @@ useStableCallback, } from './utils.js';
|
|
|
44
44
|
export { CatchNotFound, DefaultGlobalNotFound } from './not-found.js';
|
|
45
45
|
export { notFound, isNotFound } from '@tanstack/router-core';
|
|
46
46
|
export type { NotFoundError } from '@tanstack/router-core';
|
|
47
|
-
export
|
|
47
|
+
export type { ValidateLinkOptions, InferStructuralSharing, ValidateUseSearchOptions, ValidateUseParamsOptions, ValidateLinkOptionsArray, } from './typePrimitives.js';
|
|
48
|
+
export type { ValidateFromPath, ValidateToPath, ValidateSearch, ValidateParams, InferFrom, InferTo, InferMaskTo, InferMaskFrom, ValidateNavigateOptions, ValidateNavigateOptionsArray, ValidateRedirectOptions, ValidateRedirectOptionsArray, ValidateId, InferStrict, InferShouldThrow, InferSelected, ValidateUseSearchResult, ValidateUseParamsResult, } from '@tanstack/router-core';
|
|
48
49
|
export { ScriptOnce } from './ScriptOnce.js';
|
|
49
50
|
export { Asset } from './Asset.js';
|
|
50
51
|
export { HeadContent } from './HeadContent.js';
|
|
@@ -1,67 +1,8 @@
|
|
|
1
|
-
import { AnyRouter, Constrain,
|
|
1
|
+
import { AnyRouter, Constrain, InferFrom, InferMaskFrom, InferMaskTo, InferSelected, InferShouldThrow, InferStrict, InferTo, RegisteredRouter } from '@tanstack/router-core';
|
|
2
2
|
import { LinkComponentProps } from './link.js';
|
|
3
3
|
import { UseParamsOptions } from './useParams.js';
|
|
4
4
|
import { UseSearchOptions } from './useSearch.js';
|
|
5
|
-
export type ValidateFromPath<TRouter extends AnyRouter = RegisteredRouter, TFrom = string> = FromPathOption<TRouter, TFrom>;
|
|
6
|
-
export type ValidateToPath<TRouter extends AnyRouter = RegisteredRouter, TTo extends string | undefined = undefined, TFrom extends string = string> = ToPathOption<TRouter, TFrom, TTo>;
|
|
7
|
-
export type ValidateSearch<TRouter extends AnyRouter = RegisteredRouter, TTo extends string | undefined = undefined, TFrom extends string = string> = SearchParamOptions<TRouter, TFrom, TTo>;
|
|
8
|
-
export type ValidateParams<TRouter extends AnyRouter = RegisteredRouter, TTo extends string | undefined = undefined, TFrom extends string = string> = PathParamOptions<TRouter, TFrom, TTo>;
|
|
9
|
-
/**
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
12
|
-
export type InferFrom<TOptions, TDefaultFrom extends string = string> = TOptions extends {
|
|
13
|
-
from: infer TFrom extends string;
|
|
14
|
-
} ? TFrom : TDefaultFrom;
|
|
15
|
-
/**
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
export type InferTo<TOptions> = TOptions extends {
|
|
19
|
-
to: infer TTo extends string;
|
|
20
|
-
} ? TTo : undefined;
|
|
21
|
-
/**
|
|
22
|
-
* @internal
|
|
23
|
-
*/
|
|
24
|
-
export type InferMaskTo<TOptions> = TOptions extends {
|
|
25
|
-
mask: {
|
|
26
|
-
to: infer TTo extends string;
|
|
27
|
-
};
|
|
28
|
-
} ? TTo : '';
|
|
29
|
-
export type InferMaskFrom<TOptions> = TOptions extends {
|
|
30
|
-
mask: {
|
|
31
|
-
from: infer TFrom extends string;
|
|
32
|
-
};
|
|
33
|
-
} ? TFrom : string;
|
|
34
|
-
export type ValidateNavigateOptions<TRouter extends AnyRouter = RegisteredRouter, TOptions = unknown, TDefaultFrom extends string = string> = Constrain<TOptions, NavigateOptions<TRouter, InferFrom<TOptions, TDefaultFrom>, InferTo<TOptions>, InferMaskFrom<TOptions>, InferMaskTo<TOptions>>>;
|
|
35
|
-
export type ValidateNavigateOptionsArray<TRouter extends AnyRouter = RegisteredRouter, TOptions extends ReadonlyArray<any> = ReadonlyArray<unknown>, TDefaultFrom extends string = string> = {
|
|
36
|
-
[K in keyof TOptions]: ValidateNavigateOptions<TRouter, TOptions[K], TDefaultFrom>;
|
|
37
|
-
};
|
|
38
|
-
export type ValidateRedirectOptions<TRouter extends AnyRouter = RegisteredRouter, TOptions = unknown, TDefaultFrom extends string = string> = Constrain<TOptions, Redirect<TRouter, InferFrom<TOptions, TDefaultFrom>, InferTo<TOptions>, InferMaskFrom<TOptions>, InferMaskTo<TOptions>>>;
|
|
39
|
-
export type ValidateRedirectOptionsArray<TRouter extends AnyRouter = RegisteredRouter, TOptions extends ReadonlyArray<any> = ReadonlyArray<unknown>, TDefaultFrom extends string = string> = {
|
|
40
|
-
[K in keyof TOptions]: ValidateRedirectOptions<TRouter, TOptions[K], TDefaultFrom>;
|
|
41
|
-
};
|
|
42
5
|
export type ValidateLinkOptions<TRouter extends AnyRouter = RegisteredRouter, TOptions = unknown, TDefaultFrom extends string = string, TComp = 'a'> = Constrain<TOptions, LinkComponentProps<TComp, TRouter, InferFrom<TOptions, TDefaultFrom>, InferTo<TOptions>, InferMaskFrom<TOptions>, InferMaskTo<TOptions>>>;
|
|
43
|
-
export type ValidateLinkOptionsArray<TRouter extends AnyRouter = RegisteredRouter, TOptions extends ReadonlyArray<any> = ReadonlyArray<unknown>, TDefaultFrom extends string = string, TComp = 'a'> = {
|
|
44
|
-
[K in keyof TOptions]: ValidateLinkOptions<TRouter, TOptions[K], TDefaultFrom, TComp>;
|
|
45
|
-
};
|
|
46
|
-
export type ValidateId<TRouter extends AnyRouter = RegisteredRouter, TId extends string = string> = ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>;
|
|
47
|
-
/**
|
|
48
|
-
* @internal
|
|
49
|
-
*/
|
|
50
|
-
export type InferStrict<TOptions> = TOptions extends {
|
|
51
|
-
strict: infer TStrict extends boolean;
|
|
52
|
-
} ? TStrict : true;
|
|
53
|
-
/**
|
|
54
|
-
* @internal
|
|
55
|
-
*/
|
|
56
|
-
export type InferShouldThrow<TOptions> = TOptions extends {
|
|
57
|
-
shouldThrow: infer TShouldThrow extends boolean;
|
|
58
|
-
} ? TShouldThrow : true;
|
|
59
|
-
/**
|
|
60
|
-
* @internal
|
|
61
|
-
*/
|
|
62
|
-
export type InferSelected<TOptions> = TOptions extends {
|
|
63
|
-
select: (...args: Array<any>) => infer TSelected;
|
|
64
|
-
} ? TSelected : unknown;
|
|
65
6
|
/**
|
|
66
7
|
* @internal
|
|
67
8
|
*/
|
|
@@ -69,6 +10,7 @@ export type InferStructuralSharing<TOptions> = TOptions extends {
|
|
|
69
10
|
structuralSharing: infer TStructuralSharing;
|
|
70
11
|
} ? TStructuralSharing : unknown;
|
|
71
12
|
export type ValidateUseSearchOptions<TOptions, TRouter extends AnyRouter = RegisteredRouter> = Constrain<TOptions, UseSearchOptions<TRouter, InferFrom<TOptions>, InferStrict<TOptions>, InferShouldThrow<TOptions>, InferSelected<TOptions>, InferStructuralSharing<TOptions>>>;
|
|
72
|
-
export type ValidateUseSearchResult<TOptions, TRouter extends AnyRouter = RegisteredRouter> = UseSearchResult<TRouter, InferFrom<TOptions>, InferStrict<TOptions>, InferSelected<TOptions>>;
|
|
73
13
|
export type ValidateUseParamsOptions<TOptions, TRouter extends AnyRouter = RegisteredRouter> = Constrain<TOptions, UseParamsOptions<TRouter, InferFrom<TOptions>, InferStrict<TOptions>, InferShouldThrow<TOptions>, InferSelected<TOptions>, InferSelected<TOptions>>>;
|
|
74
|
-
export type
|
|
14
|
+
export type ValidateLinkOptionsArray<TRouter extends AnyRouter = RegisteredRouter, TOptions extends ReadonlyArray<any> = ReadonlyArray<unknown>, TDefaultFrom extends string = string, TComp = 'a'> = {
|
|
15
|
+
[K in keyof TOptions]: ValidateLinkOptions<TRouter, TOptions[K], TDefaultFrom, TComp>;
|
|
16
|
+
};
|
package/dist/esm/useMatch.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StructuralSharingOption, ValidateSelected } from './structuralSharing.js';
|
|
2
|
-
import { AnyRouter, MakeRouteMatch, MakeRouteMatchUnion, RegisteredRouter, StrictOrFrom, ThrowOrOptional } from '@tanstack/router-core';
|
|
2
|
+
import { AnyRouter, MakeRouteMatch, MakeRouteMatchUnion, RegisteredRouter, StrictOrFrom, ThrowConstraint, ThrowOrOptional } from '@tanstack/router-core';
|
|
3
3
|
export interface UseMatchBaseOptions<TRouter extends AnyRouter, TFrom, TStrict extends boolean, TThrow extends boolean, TSelected, TStructuralSharing extends boolean> {
|
|
4
4
|
select?: (match: MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>) => ValidateSelected<TRouter, TSelected, TStructuralSharing>;
|
|
5
5
|
shouldThrow?: TThrow;
|
|
@@ -7,5 +7,4 @@ export interface UseMatchBaseOptions<TRouter extends AnyRouter, TFrom, TStrict e
|
|
|
7
7
|
export type UseMatchRoute<out TFrom> = <TRouter extends AnyRouter = RegisteredRouter, TSelected = unknown, TStructuralSharing extends boolean = boolean>(opts?: UseMatchBaseOptions<TRouter, TFrom, true, true, TSelected, TStructuralSharing> & StructuralSharingOption<TRouter, TSelected, TStructuralSharing>) => UseMatchResult<TRouter, TFrom, true, TSelected>;
|
|
8
8
|
export type UseMatchOptions<TRouter extends AnyRouter, TFrom extends string | undefined, TStrict extends boolean, TThrow extends boolean, TSelected, TStructuralSharing extends boolean> = StrictOrFrom<TRouter, TFrom, TStrict> & UseMatchBaseOptions<TRouter, TFrom, TStrict, TThrow, TSelected, TStructuralSharing> & StructuralSharingOption<TRouter, TSelected, TStructuralSharing>;
|
|
9
9
|
export type UseMatchResult<TRouter extends AnyRouter, TFrom, TStrict extends boolean, TSelected> = unknown extends TSelected ? TStrict extends true ? MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict> : MakeRouteMatchUnion<TRouter> : TSelected;
|
|
10
|
-
export type ThrowConstraint<TStrict extends boolean, TThrow extends boolean> = TStrict extends false ? (TThrow extends true ? never : TThrow) : TThrow;
|
|
11
10
|
export declare function useMatch<TRouter extends AnyRouter = RegisteredRouter, const TFrom extends string | undefined = undefined, TStrict extends boolean = true, TThrow extends boolean = true, TSelected = unknown, TStructuralSharing extends boolean = boolean>(opts: UseMatchOptions<TRouter, TFrom, TStrict, ThrowConstraint<TStrict, TThrow>, TSelected, TStructuralSharing>): ThrowOrOptional<UseMatchResult<TRouter, TFrom, TStrict, TSelected>, TThrow>;
|
package/dist/esm/useMatch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMatch.js","sources":["../../src/useMatch.tsx"],"sourcesContent":["import * as React from 'react'\nimport invariant from 'tiny-invariant'\nimport { useRouterState } from './useRouterState'\nimport { dummyMatchContext, matchContext } from './matchContext'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRouter,\n MakeRouteMatch,\n MakeRouteMatchUnion,\n RegisteredRouter,\n StrictOrFrom,\n ThrowOrOptional,\n} from '@tanstack/router-core'\n\nexport interface UseMatchBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing extends boolean,\n> {\n select?: (\n match: MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n shouldThrow?: TThrow\n}\n\nexport type UseMatchRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseMatchBaseOptions<\n TRouter,\n TFrom,\n true,\n true,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n) => UseMatchResult<TRouter, TFrom, true, TSelected>\n\nexport type UseMatchOptions<\n TRouter extends AnyRouter,\n TFrom extends string | undefined,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing extends boolean,\n> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseMatchBaseOptions<\n TRouter,\n TFrom,\n TStrict,\n TThrow,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>\n\nexport type UseMatchResult<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TSelected,\n> = unknown extends TSelected\n ? TStrict extends true\n ? MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>\n : MakeRouteMatchUnion<TRouter>\n : TSelected\n\nexport
|
|
1
|
+
{"version":3,"file":"useMatch.js","sources":["../../src/useMatch.tsx"],"sourcesContent":["import * as React from 'react'\nimport invariant from 'tiny-invariant'\nimport { useRouterState } from './useRouterState'\nimport { dummyMatchContext, matchContext } from './matchContext'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRouter,\n MakeRouteMatch,\n MakeRouteMatchUnion,\n RegisteredRouter,\n StrictOrFrom,\n ThrowConstraint,\n ThrowOrOptional,\n} from '@tanstack/router-core'\n\nexport interface UseMatchBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing extends boolean,\n> {\n select?: (\n match: MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n shouldThrow?: TThrow\n}\n\nexport type UseMatchRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseMatchBaseOptions<\n TRouter,\n TFrom,\n true,\n true,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n) => UseMatchResult<TRouter, TFrom, true, TSelected>\n\nexport type UseMatchOptions<\n TRouter extends AnyRouter,\n TFrom extends string | undefined,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing extends boolean,\n> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseMatchBaseOptions<\n TRouter,\n TFrom,\n TStrict,\n TThrow,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>\n\nexport type UseMatchResult<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TSelected,\n> = unknown extends TSelected\n ? TStrict extends true\n ? MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>\n : MakeRouteMatchUnion<TRouter>\n : TSelected\n\nexport function useMatch<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string | undefined = undefined,\n TStrict extends boolean = true,\n TThrow extends boolean = true,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts: UseMatchOptions<\n TRouter,\n TFrom,\n TStrict,\n ThrowConstraint<TStrict, TThrow>,\n TSelected,\n TStructuralSharing\n >,\n): ThrowOrOptional<UseMatchResult<TRouter, TFrom, TStrict, TSelected>, TThrow> {\n const nearestMatchId = React.useContext(\n opts.from ? dummyMatchContext : matchContext,\n )\n\n const matchSelection = useRouterState({\n select: (state: any) => {\n const match = state.matches.find((d: any) =>\n opts.from ? opts.from === d.routeId : d.id === nearestMatchId,\n )\n invariant(\n !((opts.shouldThrow ?? true) && !match),\n `Could not find ${opts.from ? `an active match from \"${opts.from}\"` : 'a nearest match!'}`,\n )\n\n if (match === undefined) {\n return undefined\n }\n\n return opts.select ? opts.select(match) : match\n },\n structuralSharing: opts.structuralSharing,\n } as any)\n\n return matchSelection as any\n}\n"],"names":[],"mappings":";;;;AA6EO,SAAS,SAQd,MAQ6E;AAC7E,QAAM,iBAAiB,MAAM;AAAA,IAC3B,KAAK,OAAO,oBAAoB;AAAA,EAClC;AAEA,QAAM,iBAAiB,eAAe;AAAA,IACpC,QAAQ,CAAC,UAAe;AAChB,YAAA,QAAQ,MAAM,QAAQ;AAAA,QAAK,CAAC,MAChC,KAAK,OAAO,KAAK,SAAS,EAAE,UAAU,EAAE,OAAO;AAAA,MACjD;AACA;AAAA,QACE,GAAG,KAAK,eAAe,SAAS,CAAC;AAAA,QACjC,kBAAkB,KAAK,OAAO,yBAAyB,KAAK,IAAI,MAAM,kBAAkB;AAAA,MAC1F;AAEA,UAAI,UAAU,QAAW;AAChB,eAAA;AAAA,MAAA;AAGT,aAAO,KAAK,SAAS,KAAK,OAAO,KAAK,IAAI;AAAA,IAC5C;AAAA,IACA,mBAAmB,KAAK;AAAA,EAAA,CAClB;AAED,SAAA;AACT;"}
|
package/dist/esm/useParams.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ThrowConstraint } from './useMatch.js';
|
|
2
1
|
import { StructuralSharingOption, ValidateSelected } from './structuralSharing.js';
|
|
3
|
-
import { AnyRouter, RegisteredRouter, ResolveUseParams, StrictOrFrom, ThrowOrOptional, UseParamsResult } from '@tanstack/router-core';
|
|
2
|
+
import { AnyRouter, RegisteredRouter, ResolveUseParams, StrictOrFrom, ThrowConstraint, ThrowOrOptional, UseParamsResult } from '@tanstack/router-core';
|
|
4
3
|
export interface UseParamsBaseOptions<TRouter extends AnyRouter, TFrom, TStrict extends boolean, TThrow extends boolean, TSelected, TStructuralSharing> {
|
|
5
4
|
select?: (params: ResolveUseParams<TRouter, TFrom, TStrict>) => ValidateSelected<TRouter, TSelected, TStructuralSharing>;
|
|
6
5
|
shouldThrow?: TThrow;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useParams.js","sources":["../../src/useParams.tsx"],"sourcesContent":["import { useMatch } from './useMatch'\nimport type {
|
|
1
|
+
{"version":3,"file":"useParams.js","sources":["../../src/useParams.tsx"],"sourcesContent":["import { useMatch } from './useMatch'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRouter,\n RegisteredRouter,\n ResolveUseParams,\n StrictOrFrom,\n ThrowConstraint,\n ThrowOrOptional,\n UseParamsResult,\n} from '@tanstack/router-core'\n\nexport interface UseParamsBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing,\n> {\n select?: (\n params: ResolveUseParams<TRouter, TFrom, TStrict>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n shouldThrow?: TThrow\n}\n\nexport type UseParamsOptions<\n TRouter extends AnyRouter,\n TFrom extends string | undefined,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing,\n> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseParamsBaseOptions<\n TRouter,\n TFrom,\n TStrict,\n TThrow,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>\n\nexport type UseParamsRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseParamsBaseOptions<\n TRouter,\n TFrom,\n /* TStrict */ true,\n /* TThrow */ true,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n) => UseParamsResult<TRouter, TFrom, true, TSelected>\n\nexport function useParams<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string | undefined = undefined,\n TStrict extends boolean = true,\n TThrow extends boolean = true,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts: UseParamsOptions<\n TRouter,\n TFrom,\n TStrict,\n ThrowConstraint<TStrict, TThrow>,\n TSelected,\n TStructuralSharing\n >,\n): ThrowOrOptional<\n UseParamsResult<TRouter, TFrom, TStrict, TSelected>,\n TThrow\n> {\n return useMatch({\n from: opts.from!,\n strict: opts.strict,\n shouldThrow: opts.shouldThrow,\n structuralSharing: opts.structuralSharing,\n select: (match: any) => {\n return opts.select ? opts.select(match.params) : match.params\n },\n }) as any\n}\n"],"names":[],"mappings":";AA+DO,SAAS,UAQd,MAWA;AACA,SAAO,SAAS;AAAA,IACd,MAAM,KAAK;AAAA,IACX,QAAQ,KAAK;AAAA,IACb,aAAa,KAAK;AAAA,IAClB,mBAAmB,KAAK;AAAA,IACxB,QAAQ,CAAC,UAAe;AACtB,aAAO,KAAK,SAAS,KAAK,OAAO,MAAM,MAAM,IAAI,MAAM;AAAA,IAAA;AAAA,EACzD,CACD;AACH;"}
|
package/dist/esm/useSearch.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ThrowConstraint } from './useMatch.js';
|
|
2
1
|
import { StructuralSharingOption, ValidateSelected } from './structuralSharing.js';
|
|
3
|
-
import { AnyRouter, RegisteredRouter, ResolveUseSearch, StrictOrFrom, ThrowOrOptional, UseSearchResult } from '@tanstack/router-core';
|
|
2
|
+
import { AnyRouter, RegisteredRouter, ResolveUseSearch, StrictOrFrom, ThrowConstraint, ThrowOrOptional, UseSearchResult } from '@tanstack/router-core';
|
|
4
3
|
export interface UseSearchBaseOptions<TRouter extends AnyRouter, TFrom, TStrict extends boolean, TThrow extends boolean, TSelected, TStructuralSharing> {
|
|
5
4
|
select?: (state: ResolveUseSearch<TRouter, TFrom, TStrict>) => ValidateSelected<TRouter, TSelected, TStructuralSharing>;
|
|
6
5
|
shouldThrow?: TThrow;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSearch.js","sources":["../../src/useSearch.tsx"],"sourcesContent":["import { useMatch } from './useMatch'\nimport type {
|
|
1
|
+
{"version":3,"file":"useSearch.js","sources":["../../src/useSearch.tsx"],"sourcesContent":["import { useMatch } from './useMatch'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRouter,\n RegisteredRouter,\n ResolveUseSearch,\n StrictOrFrom,\n ThrowConstraint,\n ThrowOrOptional,\n UseSearchResult,\n} from '@tanstack/router-core'\n\nexport interface UseSearchBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing,\n> {\n select?: (\n state: ResolveUseSearch<TRouter, TFrom, TStrict>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n shouldThrow?: TThrow\n}\n\nexport type UseSearchOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing,\n> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseSearchBaseOptions<\n TRouter,\n TFrom,\n TStrict,\n TThrow,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>\n\nexport type UseSearchRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseSearchBaseOptions<\n TRouter,\n TFrom,\n /* TStrict */ true,\n /* TThrow */ true,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n) => UseSearchResult<TRouter, TFrom, true, TSelected>\n\nexport function useSearch<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string | undefined = undefined,\n TStrict extends boolean = true,\n TThrow extends boolean = true,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts: UseSearchOptions<\n TRouter,\n TFrom,\n TStrict,\n ThrowConstraint<TStrict, TThrow>,\n TSelected,\n TStructuralSharing\n >,\n): ThrowOrOptional<\n UseSearchResult<TRouter, TFrom, TStrict, TSelected>,\n TThrow\n> {\n return useMatch({\n from: opts.from!,\n strict: opts.strict,\n shouldThrow: opts.shouldThrow,\n structuralSharing: opts.structuralSharing,\n select: (match: any) => {\n return opts.select ? opts.select(match.search) : match.search\n },\n }) as any\n}\n"],"names":[],"mappings":";AA+DO,SAAS,UAQd,MAWA;AACA,SAAO,SAAS;AAAA,IACd,MAAM,KAAK;AAAA,IACX,QAAQ,KAAK;AAAA,IACb,aAAa,KAAK;AAAA,IAClB,mBAAmB,KAAK;AAAA,IACxB,QAAQ,CAAC,UAAe;AACtB,aAAO,KAAK,SAAS,KAAK,OAAO,MAAM,MAAM,IAAI,MAAM;AAAA,IAAA;AAAA,EACzD,CACD;AACH;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-router",
|
|
3
|
-
"version": "1.114.
|
|
3
|
+
"version": "1.114.17",
|
|
4
4
|
"description": "Modern and scalable routing for React applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"jsesc": "^3.1.0",
|
|
54
54
|
"tiny-invariant": "^1.3.3",
|
|
55
55
|
"tiny-warning": "^1.0.3",
|
|
56
|
-
"@tanstack/
|
|
57
|
-
"@tanstack/
|
|
56
|
+
"@tanstack/router-core": "1.114.17",
|
|
57
|
+
"@tanstack/history": "1.114.12"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@testing-library/jest-dom": "^6.6.3",
|
package/src/index.tsx
CHANGED
|
@@ -330,7 +330,34 @@ export { CatchNotFound, DefaultGlobalNotFound } from './not-found'
|
|
|
330
330
|
export { notFound, isNotFound } from '@tanstack/router-core'
|
|
331
331
|
export type { NotFoundError } from '@tanstack/router-core'
|
|
332
332
|
|
|
333
|
-
export
|
|
333
|
+
export type {
|
|
334
|
+
ValidateLinkOptions,
|
|
335
|
+
InferStructuralSharing,
|
|
336
|
+
ValidateUseSearchOptions,
|
|
337
|
+
ValidateUseParamsOptions,
|
|
338
|
+
ValidateLinkOptionsArray,
|
|
339
|
+
} from './typePrimitives'
|
|
340
|
+
|
|
341
|
+
export type {
|
|
342
|
+
ValidateFromPath,
|
|
343
|
+
ValidateToPath,
|
|
344
|
+
ValidateSearch,
|
|
345
|
+
ValidateParams,
|
|
346
|
+
InferFrom,
|
|
347
|
+
InferTo,
|
|
348
|
+
InferMaskTo,
|
|
349
|
+
InferMaskFrom,
|
|
350
|
+
ValidateNavigateOptions,
|
|
351
|
+
ValidateNavigateOptionsArray,
|
|
352
|
+
ValidateRedirectOptions,
|
|
353
|
+
ValidateRedirectOptionsArray,
|
|
354
|
+
ValidateId,
|
|
355
|
+
InferStrict,
|
|
356
|
+
InferShouldThrow,
|
|
357
|
+
InferSelected,
|
|
358
|
+
ValidateUseSearchResult,
|
|
359
|
+
ValidateUseParamsResult,
|
|
360
|
+
} from '@tanstack/router-core'
|
|
334
361
|
|
|
335
362
|
export { ScriptOnce } from './ScriptOnce'
|
|
336
363
|
export { Asset } from './Asset'
|
package/src/typePrimitives.ts
CHANGED
|
@@ -1,135 +1,19 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
AnyRouter,
|
|
3
3
|
Constrain,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
InferFrom,
|
|
5
|
+
InferMaskFrom,
|
|
6
|
+
InferMaskTo,
|
|
7
|
+
InferSelected,
|
|
8
|
+
InferShouldThrow,
|
|
9
|
+
InferStrict,
|
|
10
|
+
InferTo,
|
|
9
11
|
RegisteredRouter,
|
|
10
|
-
RouteIds,
|
|
11
|
-
SearchParamOptions,
|
|
12
|
-
ToPathOption,
|
|
13
|
-
UseParamsResult,
|
|
14
|
-
UseSearchResult,
|
|
15
12
|
} from '@tanstack/router-core'
|
|
16
13
|
import type { LinkComponentProps } from './link'
|
|
17
14
|
import type { UseParamsOptions } from './useParams'
|
|
18
15
|
import type { UseSearchOptions } from './useSearch'
|
|
19
16
|
|
|
20
|
-
export type ValidateFromPath<
|
|
21
|
-
TRouter extends AnyRouter = RegisteredRouter,
|
|
22
|
-
TFrom = string,
|
|
23
|
-
> = FromPathOption<TRouter, TFrom>
|
|
24
|
-
|
|
25
|
-
export type ValidateToPath<
|
|
26
|
-
TRouter extends AnyRouter = RegisteredRouter,
|
|
27
|
-
TTo extends string | undefined = undefined,
|
|
28
|
-
TFrom extends string = string,
|
|
29
|
-
> = ToPathOption<TRouter, TFrom, TTo>
|
|
30
|
-
|
|
31
|
-
export type ValidateSearch<
|
|
32
|
-
TRouter extends AnyRouter = RegisteredRouter,
|
|
33
|
-
TTo extends string | undefined = undefined,
|
|
34
|
-
TFrom extends string = string,
|
|
35
|
-
> = SearchParamOptions<TRouter, TFrom, TTo>
|
|
36
|
-
|
|
37
|
-
export type ValidateParams<
|
|
38
|
-
TRouter extends AnyRouter = RegisteredRouter,
|
|
39
|
-
TTo extends string | undefined = undefined,
|
|
40
|
-
TFrom extends string = string,
|
|
41
|
-
> = PathParamOptions<TRouter, TFrom, TTo>
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
46
|
-
export type InferFrom<
|
|
47
|
-
TOptions,
|
|
48
|
-
TDefaultFrom extends string = string,
|
|
49
|
-
> = TOptions extends {
|
|
50
|
-
from: infer TFrom extends string
|
|
51
|
-
}
|
|
52
|
-
? TFrom
|
|
53
|
-
: TDefaultFrom
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @internal
|
|
57
|
-
*/
|
|
58
|
-
export type InferTo<TOptions> = TOptions extends {
|
|
59
|
-
to: infer TTo extends string
|
|
60
|
-
}
|
|
61
|
-
? TTo
|
|
62
|
-
: undefined
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @internal
|
|
66
|
-
*/
|
|
67
|
-
export type InferMaskTo<TOptions> = TOptions extends {
|
|
68
|
-
mask: { to: infer TTo extends string }
|
|
69
|
-
}
|
|
70
|
-
? TTo
|
|
71
|
-
: ''
|
|
72
|
-
|
|
73
|
-
export type InferMaskFrom<TOptions> = TOptions extends {
|
|
74
|
-
mask: { from: infer TFrom extends string }
|
|
75
|
-
}
|
|
76
|
-
? TFrom
|
|
77
|
-
: string
|
|
78
|
-
|
|
79
|
-
export type ValidateNavigateOptions<
|
|
80
|
-
TRouter extends AnyRouter = RegisteredRouter,
|
|
81
|
-
TOptions = unknown,
|
|
82
|
-
TDefaultFrom extends string = string,
|
|
83
|
-
> = Constrain<
|
|
84
|
-
TOptions,
|
|
85
|
-
NavigateOptions<
|
|
86
|
-
TRouter,
|
|
87
|
-
InferFrom<TOptions, TDefaultFrom>,
|
|
88
|
-
InferTo<TOptions>,
|
|
89
|
-
InferMaskFrom<TOptions>,
|
|
90
|
-
InferMaskTo<TOptions>
|
|
91
|
-
>
|
|
92
|
-
>
|
|
93
|
-
|
|
94
|
-
export type ValidateNavigateOptionsArray<
|
|
95
|
-
TRouter extends AnyRouter = RegisteredRouter,
|
|
96
|
-
TOptions extends ReadonlyArray<any> = ReadonlyArray<unknown>,
|
|
97
|
-
TDefaultFrom extends string = string,
|
|
98
|
-
> = {
|
|
99
|
-
[K in keyof TOptions]: ValidateNavigateOptions<
|
|
100
|
-
TRouter,
|
|
101
|
-
TOptions[K],
|
|
102
|
-
TDefaultFrom
|
|
103
|
-
>
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export type ValidateRedirectOptions<
|
|
107
|
-
TRouter extends AnyRouter = RegisteredRouter,
|
|
108
|
-
TOptions = unknown,
|
|
109
|
-
TDefaultFrom extends string = string,
|
|
110
|
-
> = Constrain<
|
|
111
|
-
TOptions,
|
|
112
|
-
Redirect<
|
|
113
|
-
TRouter,
|
|
114
|
-
InferFrom<TOptions, TDefaultFrom>,
|
|
115
|
-
InferTo<TOptions>,
|
|
116
|
-
InferMaskFrom<TOptions>,
|
|
117
|
-
InferMaskTo<TOptions>
|
|
118
|
-
>
|
|
119
|
-
>
|
|
120
|
-
|
|
121
|
-
export type ValidateRedirectOptionsArray<
|
|
122
|
-
TRouter extends AnyRouter = RegisteredRouter,
|
|
123
|
-
TOptions extends ReadonlyArray<any> = ReadonlyArray<unknown>,
|
|
124
|
-
TDefaultFrom extends string = string,
|
|
125
|
-
> = {
|
|
126
|
-
[K in keyof TOptions]: ValidateRedirectOptions<
|
|
127
|
-
TRouter,
|
|
128
|
-
TOptions[K],
|
|
129
|
-
TDefaultFrom
|
|
130
|
-
>
|
|
131
|
-
}
|
|
132
|
-
|
|
133
17
|
export type ValidateLinkOptions<
|
|
134
18
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
135
19
|
TOptions = unknown,
|
|
@@ -147,52 +31,6 @@ export type ValidateLinkOptions<
|
|
|
147
31
|
>
|
|
148
32
|
>
|
|
149
33
|
|
|
150
|
-
export type ValidateLinkOptionsArray<
|
|
151
|
-
TRouter extends AnyRouter = RegisteredRouter,
|
|
152
|
-
TOptions extends ReadonlyArray<any> = ReadonlyArray<unknown>,
|
|
153
|
-
TDefaultFrom extends string = string,
|
|
154
|
-
TComp = 'a',
|
|
155
|
-
> = {
|
|
156
|
-
[K in keyof TOptions]: ValidateLinkOptions<
|
|
157
|
-
TRouter,
|
|
158
|
-
TOptions[K],
|
|
159
|
-
TDefaultFrom,
|
|
160
|
-
TComp
|
|
161
|
-
>
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export type ValidateId<
|
|
165
|
-
TRouter extends AnyRouter = RegisteredRouter,
|
|
166
|
-
TId extends string = string,
|
|
167
|
-
> = ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* @internal
|
|
171
|
-
*/
|
|
172
|
-
export type InferStrict<TOptions> = TOptions extends {
|
|
173
|
-
strict: infer TStrict extends boolean
|
|
174
|
-
}
|
|
175
|
-
? TStrict
|
|
176
|
-
: true
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* @internal
|
|
180
|
-
*/
|
|
181
|
-
export type InferShouldThrow<TOptions> = TOptions extends {
|
|
182
|
-
shouldThrow: infer TShouldThrow extends boolean
|
|
183
|
-
}
|
|
184
|
-
? TShouldThrow
|
|
185
|
-
: true
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* @internal
|
|
189
|
-
*/
|
|
190
|
-
export type InferSelected<TOptions> = TOptions extends {
|
|
191
|
-
select: (...args: Array<any>) => infer TSelected
|
|
192
|
-
}
|
|
193
|
-
? TSelected
|
|
194
|
-
: unknown
|
|
195
|
-
|
|
196
34
|
/**
|
|
197
35
|
* @internal
|
|
198
36
|
*/
|
|
@@ -217,16 +55,6 @@ export type ValidateUseSearchOptions<
|
|
|
217
55
|
>
|
|
218
56
|
>
|
|
219
57
|
|
|
220
|
-
export type ValidateUseSearchResult<
|
|
221
|
-
TOptions,
|
|
222
|
-
TRouter extends AnyRouter = RegisteredRouter,
|
|
223
|
-
> = UseSearchResult<
|
|
224
|
-
TRouter,
|
|
225
|
-
InferFrom<TOptions>,
|
|
226
|
-
InferStrict<TOptions>,
|
|
227
|
-
InferSelected<TOptions>
|
|
228
|
-
>
|
|
229
|
-
|
|
230
58
|
export type ValidateUseParamsOptions<
|
|
231
59
|
TOptions,
|
|
232
60
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
@@ -241,16 +69,16 @@ export type ValidateUseParamsOptions<
|
|
|
241
69
|
InferSelected<TOptions>
|
|
242
70
|
>
|
|
243
71
|
>
|
|
244
|
-
|
|
245
|
-
export type ValidateUseParamsResult<
|
|
246
|
-
TOptions,
|
|
72
|
+
export type ValidateLinkOptionsArray<
|
|
247
73
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
248
|
-
> =
|
|
249
|
-
|
|
250
|
-
|
|
74
|
+
TOptions extends ReadonlyArray<any> = ReadonlyArray<unknown>,
|
|
75
|
+
TDefaultFrom extends string = string,
|
|
76
|
+
TComp = 'a',
|
|
77
|
+
> = {
|
|
78
|
+
[K in keyof TOptions]: ValidateLinkOptions<
|
|
251
79
|
TRouter,
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
80
|
+
TOptions[K],
|
|
81
|
+
TDefaultFrom,
|
|
82
|
+
TComp
|
|
255
83
|
>
|
|
256
|
-
|
|
84
|
+
}
|
package/src/useMatch.tsx
CHANGED
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
MakeRouteMatchUnion,
|
|
13
13
|
RegisteredRouter,
|
|
14
14
|
StrictOrFrom,
|
|
15
|
+
ThrowConstraint,
|
|
15
16
|
ThrowOrOptional,
|
|
16
17
|
} from '@tanstack/router-core'
|
|
17
18
|
|
|
@@ -74,11 +75,6 @@ export type UseMatchResult<
|
|
|
74
75
|
: MakeRouteMatchUnion<TRouter>
|
|
75
76
|
: TSelected
|
|
76
77
|
|
|
77
|
-
export type ThrowConstraint<
|
|
78
|
-
TStrict extends boolean,
|
|
79
|
-
TThrow extends boolean,
|
|
80
|
-
> = TStrict extends false ? (TThrow extends true ? never : TThrow) : TThrow
|
|
81
|
-
|
|
82
78
|
export function useMatch<
|
|
83
79
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
84
80
|
const TFrom extends string | undefined = undefined,
|
package/src/useParams.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useMatch } from './useMatch'
|
|
2
|
-
import type { ThrowConstraint } from './useMatch'
|
|
3
2
|
import type {
|
|
4
3
|
StructuralSharingOption,
|
|
5
4
|
ValidateSelected,
|
|
@@ -9,6 +8,7 @@ import type {
|
|
|
9
8
|
RegisteredRouter,
|
|
10
9
|
ResolveUseParams,
|
|
11
10
|
StrictOrFrom,
|
|
11
|
+
ThrowConstraint,
|
|
12
12
|
ThrowOrOptional,
|
|
13
13
|
UseParamsResult,
|
|
14
14
|
} from '@tanstack/router-core'
|
package/src/useSearch.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useMatch } from './useMatch'
|
|
2
|
-
import type { ThrowConstraint } from './useMatch'
|
|
3
2
|
import type {
|
|
4
3
|
StructuralSharingOption,
|
|
5
4
|
ValidateSelected,
|
|
@@ -9,6 +8,7 @@ import type {
|
|
|
9
8
|
RegisteredRouter,
|
|
10
9
|
ResolveUseSearch,
|
|
11
10
|
StrictOrFrom,
|
|
11
|
+
ThrowConstraint,
|
|
12
12
|
ThrowOrOptional,
|
|
13
13
|
UseSearchResult,
|
|
14
14
|
} from '@tanstack/router-core'
|