@tanstack/solid-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 +1 -59
- 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 +1 -59
- 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/dist/source/index.d.ts +2 -1
- package/dist/source/index.jsx +0 -1
- package/dist/source/index.jsx.map +1 -1
- package/dist/source/typePrimitives.d.ts +1 -59
- package/dist/source/useMatch.d.ts +1 -2
- package/dist/source/useMatch.jsx.map +1 -1
- package/dist/source/useParams.d.ts +1 -2
- package/dist/source/useSearch.d.ts +1 -2
- package/package.json +2 -2
- package/src/index.tsx +27 -1
- package/src/typePrimitives.ts +7 -177
- 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
|
@@ -42,7 +42,8 @@ export { useLayoutEffect } from './utils.cjs';
|
|
|
42
42
|
export { CatchNotFound, DefaultGlobalNotFound } from './not-found.cjs';
|
|
43
43
|
export { notFound, isNotFound } from '@tanstack/router-core';
|
|
44
44
|
export type { NotFoundError } from '@tanstack/router-core';
|
|
45
|
-
export
|
|
45
|
+
export type { ValidateLinkOptions, ValidateUseSearchOptions, ValidateUseParamsOptions, ValidateLinkOptionsArray, } from './typePrimitives.cjs';
|
|
46
|
+
export type { ValidateFromPath, ValidateToPath, ValidateSearch, ValidateParams, InferFrom, InferTo, InferMaskTo, InferMaskFrom, ValidateNavigateOptions, ValidateNavigateOptionsArray, ValidateRedirectOptions, ValidateRedirectOptionsArray, ValidateId, InferStrict, InferShouldThrow, InferSelected, ValidateUseSearchResult, ValidateUseParamsResult, } from '@tanstack/router-core';
|
|
46
47
|
export { ScriptOnce } from './ScriptOnce.cjs';
|
|
47
48
|
export { Asset } from './Asset.cjs';
|
|
48
49
|
export { HeadContent, useTags } from './HeadContent.cjs';
|
|
@@ -1,68 +1,10 @@
|
|
|
1
1
|
import { LinkComponentProps } from './link.cjs';
|
|
2
2
|
import { UseParamsOptions } from './useParams.cjs';
|
|
3
3
|
import { UseSearchOptions } from './useSearch.cjs';
|
|
4
|
-
import { AnyRouter, Constrain,
|
|
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
|
-
};
|
|
4
|
+
import { AnyRouter, Constrain, InferFrom, InferMaskFrom, InferMaskTo, InferSelected, InferShouldThrow, InferStrict, InferTo, RegisteredRouter } from '@tanstack/router-core';
|
|
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
6
|
export type ValidateLinkOptionsArray<TRouter extends AnyRouter = RegisteredRouter, TOptions extends ReadonlyArray<any> = ReadonlyArray<unknown>, TDefaultFrom extends string = string, TComp = 'a'> = {
|
|
44
7
|
[K in keyof TOptions]: ValidateLinkOptions<TRouter, TOptions[K], TDefaultFrom, TComp>;
|
|
45
8
|
};
|
|
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
9
|
export type ValidateUseSearchOptions<TOptions, TRouter extends AnyRouter = RegisteredRouter> = Constrain<TOptions, UseSearchOptions<TRouter, InferFrom<TOptions>, InferStrict<TOptions>, InferShouldThrow<TOptions>, InferSelected<TOptions>>>;
|
|
66
|
-
export type ValidateUseSearchResult<TOptions, TRouter extends AnyRouter = RegisteredRouter> = UseSearchResult<TRouter, InferFrom<TOptions>, InferStrict<TOptions>, InferSelected<TOptions>>;
|
|
67
10
|
export type ValidateUseParamsOptions<TOptions, TRouter extends AnyRouter = RegisteredRouter> = Constrain<TOptions, UseParamsOptions<TRouter, InferFrom<TOptions>, InferStrict<TOptions>, InferShouldThrow<TOptions>, InferSelected<TOptions>>>;
|
|
68
|
-
export type ValidateUseParamsResult<TOptions, TRouter extends AnyRouter = RegisteredRouter> = Constrain<TOptions, UseParamsResult<TRouter, InferFrom<TOptions>, InferStrict<TOptions>, InferSelected<TOptions>>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMatch.cjs","sources":["../../src/useMatch.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport invariant from 'tiny-invariant'\nimport { useRouterState } from './useRouterState'\nimport { dummyMatchContext, matchContext } from './matchContext'\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> {\n select?: (\n match: MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>,\n ) => TSelected\n shouldThrow?: TThrow\n}\n\nexport type UseMatchRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchBaseOptions<TRouter, TFrom, true, true, TSelected>,\n) => Solid.Accessor<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> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseMatchBaseOptions<TRouter, TFrom, TStrict, TThrow, TSelected>\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 Solid from 'solid-js'\nimport invariant from 'tiny-invariant'\nimport { useRouterState } from './useRouterState'\nimport { dummyMatchContext, matchContext } from './matchContext'\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> {\n select?: (\n match: MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>,\n ) => TSelected\n shouldThrow?: TThrow\n}\n\nexport type UseMatchRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchBaseOptions<TRouter, TFrom, true, true, TSelected>,\n) => Solid.Accessor<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> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseMatchBaseOptions<TRouter, TFrom, TStrict, TThrow, TSelected>\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>(\n opts: UseMatchOptions<\n TRouter,\n TFrom,\n TStrict,\n ThrowConstraint<TStrict, TThrow>,\n TSelected\n >,\n): Solid.Accessor<\n ThrowOrOptional<UseMatchResult<TRouter, TFrom, TStrict, TSelected>, TThrow>\n> {\n const nearestMatchId = Solid.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\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 } as any)\n\n return matchSelection as any\n}\n"],"names":["useMatch","opts","nearestMatchId","Solid","useContext","from","dummyMatchContext","matchContext","matchSelection","useRouterState","select","state","match","matches","find","d","routeId","id","invariant","shouldThrow","undefined"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsDO,SAASA,SAOdC,MASA;AACA,QAAMC,iBAAiBC,iBAAMC,WAC3BH,KAAKI,OAAOC,iCAAoBC,yBAClC;AAEA,QAAMC,iBAAiBC,eAAAA,eAAe;AAAA,IACpCC,QAAQA,CAACC,UAAe;AACtB,YAAMC,QAAQD,MAAME,QAAQC,KAAK,CAACC,MAChCd,KAAKI,OAAOJ,KAAKI,SAASU,EAAEC,UAAUD,EAAEE,OAAOf,gBACjD;AAEAgB,gBACE,GAAGjB,KAAKkB,eAAe,SAAS,CAACP,QACjC,kBAAkBX,KAAKI,OAAO,yBAAyBJ,KAAKI,IAAI,MAAM,kBAAkB,EAC1F;AAEA,UAAIO,UAAUQ,QAAW;AAChBA,eAAAA;AAAAA,MAAAA;AAGT,aAAOnB,KAAKS,SAAST,KAAKS,OAAOE,KAAK,IAAIA;AAAAA,IAAAA;AAAAA,EAC5C,CACM;AAEDJ,SAAAA;AACT;;"}
|
package/dist/cjs/useMatch.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyRouter, MakeRouteMatch, MakeRouteMatchUnion, RegisteredRouter, StrictOrFrom, ThrowOrOptional } from '@tanstack/router-core';
|
|
1
|
+
import { AnyRouter, MakeRouteMatch, MakeRouteMatchUnion, RegisteredRouter, StrictOrFrom, ThrowConstraint, ThrowOrOptional } from '@tanstack/router-core';
|
|
2
2
|
import * as Solid from 'solid-js';
|
|
3
3
|
export interface UseMatchBaseOptions<TRouter extends AnyRouter, TFrom, TStrict extends boolean, TThrow extends boolean, TSelected> {
|
|
4
4
|
select?: (match: MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>) => TSelected;
|
|
@@ -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>(opts?: UseMatchBaseOptions<TRouter, TFrom, true, true, TSelected>) => Solid.Accessor<UseMatchResult<TRouter, TFrom, true, TSelected>>;
|
|
8
8
|
export type UseMatchOptions<TRouter extends AnyRouter, TFrom extends string | undefined, TStrict extends boolean, TThrow extends boolean, TSelected> = StrictOrFrom<TRouter, TFrom, TStrict> & UseMatchBaseOptions<TRouter, TFrom, TStrict, TThrow, TSelected>;
|
|
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>(opts: UseMatchOptions<TRouter, TFrom, TStrict, ThrowConstraint<TStrict, TThrow>, TSelected>): Solid.Accessor<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 { Accessor } from 'solid-js'\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> {\n select?: (params: ResolveUseParams<TRouter, TFrom, TStrict>) => TSelected\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> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseParamsBaseOptions<TRouter, TFrom, TStrict, TThrow, TSelected>\n\nexport type UseParamsRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseParamsBaseOptions<\n TRouter,\n TFrom,\n /* TStrict */ true,\n /* TThrow */ true,\n TSelected\n >,\n) => Accessor<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>(\n opts: UseParamsOptions<\n TRouter,\n TFrom,\n TStrict,\n ThrowConstraint<TStrict, TThrow>,\n TSelected\n >,\n): Accessor<\n ThrowOrOptional<UseParamsResult<TRouter, TFrom, TStrict, TSelected>, TThrow>\n> {\n return useMatch({\n from: opts.from!,\n strict: opts.strict,\n shouldThrow: opts.shouldThrow,\n select: (match: any) => {\n return opts.select ? opts.select(match.params) : match.params\n },\n } as any) as any\n}\n"],"names":["useParams","opts","useMatch","from","strict","shouldThrow","select","match","params"],"mappings":";;;AA6CO,SAASA,UAOdC,MASA;AACA,SAAOC,kBAAS;AAAA,IACdC,MAAMF,KAAKE;AAAAA,IACXC,QAAQH,KAAKG;AAAAA,IACbC,aAAaJ,KAAKI;AAAAA,IAClBC,QAAQA,CAACC,UAAe;AACtB,aAAON,KAAKK,SAASL,KAAKK,OAAOC,MAAMC,MAAM,IAAID,MAAMC;AAAAA,IAAAA;AAAAA,EACzD,CACM;AACV;;"}
|
package/dist/cjs/useParams.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ThrowConstraint } from './useMatch.cjs';
|
|
2
1
|
import { Accessor } from 'solid-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> {
|
|
5
4
|
select?: (params: ResolveUseParams<TRouter, TFrom, TStrict>) => TSelected;
|
|
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 { Accessor } from 'solid-js'\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> {\n select?: (state: ResolveUseSearch<TRouter, TFrom, TStrict>) => TSelected\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> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseSearchBaseOptions<TRouter, TFrom, TStrict, TThrow, TSelected>\n\nexport type UseSearchRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseSearchBaseOptions<\n TRouter,\n TFrom,\n /* TStrict */ true,\n /* TThrow */ true,\n TSelected\n >,\n) => Accessor<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>(\n opts: UseSearchOptions<\n TRouter,\n TFrom,\n TStrict,\n ThrowConstraint<TStrict, TThrow>,\n TSelected\n >,\n): Accessor<\n ThrowOrOptional<UseSearchResult<TRouter, TFrom, TStrict, TSelected>, TThrow>\n> {\n return useMatch({\n from: opts.from!,\n strict: opts.strict,\n shouldThrow: opts.shouldThrow,\n select: (match: any) => {\n return opts.select ? opts.select(match.search) : match.search\n },\n }) as any\n}\n"],"names":["useSearch","opts","useMatch","from","strict","shouldThrow","select","match","search"],"mappings":";;;AA6CO,SAASA,UAOdC,MASA;AACA,SAAOC,kBAAS;AAAA,IACdC,MAAMF,KAAKE;AAAAA,IACXC,QAAQH,KAAKG;AAAAA,IACbC,aAAaJ,KAAKI;AAAAA,IAClBC,QAAQA,CAACC,UAAe;AACtB,aAAON,KAAKK,SAASL,KAAKK,OAAOC,MAAMC,MAAM,IAAID,MAAMC;AAAAA,IAAAA;AAAAA,EACzD,CACD;AACH;;"}
|
package/dist/cjs/useSearch.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ThrowConstraint } from './useMatch.cjs';
|
|
2
1
|
import { Accessor } from 'solid-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> {
|
|
5
4
|
select?: (state: ResolveUseSearch<TRouter, TFrom, TStrict>) => TSelected;
|
|
6
5
|
shouldThrow?: TThrow;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -42,7 +42,8 @@ export { useLayoutEffect } from './utils.js';
|
|
|
42
42
|
export { CatchNotFound, DefaultGlobalNotFound } from './not-found.js';
|
|
43
43
|
export { notFound, isNotFound } from '@tanstack/router-core';
|
|
44
44
|
export type { NotFoundError } from '@tanstack/router-core';
|
|
45
|
-
export
|
|
45
|
+
export type { ValidateLinkOptions, ValidateUseSearchOptions, ValidateUseParamsOptions, ValidateLinkOptionsArray, } from './typePrimitives.js';
|
|
46
|
+
export type { ValidateFromPath, ValidateToPath, ValidateSearch, ValidateParams, InferFrom, InferTo, InferMaskTo, InferMaskFrom, ValidateNavigateOptions, ValidateNavigateOptionsArray, ValidateRedirectOptions, ValidateRedirectOptionsArray, ValidateId, InferStrict, InferShouldThrow, InferSelected, ValidateUseSearchResult, ValidateUseParamsResult, } from '@tanstack/router-core';
|
|
46
47
|
export { ScriptOnce } from './ScriptOnce.js';
|
|
47
48
|
export { Asset } from './Asset.js';
|
|
48
49
|
export { HeadContent, useTags } from './HeadContent.js';
|
|
@@ -1,68 +1,10 @@
|
|
|
1
1
|
import { LinkComponentProps } from './link.js';
|
|
2
2
|
import { UseParamsOptions } from './useParams.js';
|
|
3
3
|
import { UseSearchOptions } from './useSearch.js';
|
|
4
|
-
import { AnyRouter, Constrain,
|
|
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
|
-
};
|
|
4
|
+
import { AnyRouter, Constrain, InferFrom, InferMaskFrom, InferMaskTo, InferSelected, InferShouldThrow, InferStrict, InferTo, RegisteredRouter } from '@tanstack/router-core';
|
|
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
6
|
export type ValidateLinkOptionsArray<TRouter extends AnyRouter = RegisteredRouter, TOptions extends ReadonlyArray<any> = ReadonlyArray<unknown>, TDefaultFrom extends string = string, TComp = 'a'> = {
|
|
44
7
|
[K in keyof TOptions]: ValidateLinkOptions<TRouter, TOptions[K], TDefaultFrom, TComp>;
|
|
45
8
|
};
|
|
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
9
|
export type ValidateUseSearchOptions<TOptions, TRouter extends AnyRouter = RegisteredRouter> = Constrain<TOptions, UseSearchOptions<TRouter, InferFrom<TOptions>, InferStrict<TOptions>, InferShouldThrow<TOptions>, InferSelected<TOptions>>>;
|
|
66
|
-
export type ValidateUseSearchResult<TOptions, TRouter extends AnyRouter = RegisteredRouter> = UseSearchResult<TRouter, InferFrom<TOptions>, InferStrict<TOptions>, InferSelected<TOptions>>;
|
|
67
10
|
export type ValidateUseParamsOptions<TOptions, TRouter extends AnyRouter = RegisteredRouter> = Constrain<TOptions, UseParamsOptions<TRouter, InferFrom<TOptions>, InferStrict<TOptions>, InferShouldThrow<TOptions>, InferSelected<TOptions>>>;
|
|
68
|
-
export type ValidateUseParamsResult<TOptions, TRouter extends AnyRouter = RegisteredRouter> = Constrain<TOptions, UseParamsResult<TRouter, InferFrom<TOptions>, InferStrict<TOptions>, InferSelected<TOptions>>>;
|
package/dist/esm/useMatch.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyRouter, MakeRouteMatch, MakeRouteMatchUnion, RegisteredRouter, StrictOrFrom, ThrowOrOptional } from '@tanstack/router-core';
|
|
1
|
+
import { AnyRouter, MakeRouteMatch, MakeRouteMatchUnion, RegisteredRouter, StrictOrFrom, ThrowConstraint, ThrowOrOptional } from '@tanstack/router-core';
|
|
2
2
|
import * as Solid from 'solid-js';
|
|
3
3
|
export interface UseMatchBaseOptions<TRouter extends AnyRouter, TFrom, TStrict extends boolean, TThrow extends boolean, TSelected> {
|
|
4
4
|
select?: (match: MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>) => TSelected;
|
|
@@ -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>(opts?: UseMatchBaseOptions<TRouter, TFrom, true, true, TSelected>) => Solid.Accessor<UseMatchResult<TRouter, TFrom, true, TSelected>>;
|
|
8
8
|
export type UseMatchOptions<TRouter extends AnyRouter, TFrom extends string | undefined, TStrict extends boolean, TThrow extends boolean, TSelected> = StrictOrFrom<TRouter, TFrom, TStrict> & UseMatchBaseOptions<TRouter, TFrom, TStrict, TThrow, TSelected>;
|
|
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>(opts: UseMatchOptions<TRouter, TFrom, TStrict, ThrowConstraint<TStrict, TThrow>, TSelected>): Solid.Accessor<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 Solid from 'solid-js'\nimport invariant from 'tiny-invariant'\nimport { useRouterState } from './useRouterState'\nimport { dummyMatchContext, matchContext } from './matchContext'\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> {\n select?: (\n match: MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>,\n ) => TSelected\n shouldThrow?: TThrow\n}\n\nexport type UseMatchRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchBaseOptions<TRouter, TFrom, true, true, TSelected>,\n) => Solid.Accessor<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> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseMatchBaseOptions<TRouter, TFrom, TStrict, TThrow, TSelected>\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 Solid from 'solid-js'\nimport invariant from 'tiny-invariant'\nimport { useRouterState } from './useRouterState'\nimport { dummyMatchContext, matchContext } from './matchContext'\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> {\n select?: (\n match: MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>,\n ) => TSelected\n shouldThrow?: TThrow\n}\n\nexport type UseMatchRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchBaseOptions<TRouter, TFrom, true, true, TSelected>,\n) => Solid.Accessor<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> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseMatchBaseOptions<TRouter, TFrom, TStrict, TThrow, TSelected>\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>(\n opts: UseMatchOptions<\n TRouter,\n TFrom,\n TStrict,\n ThrowConstraint<TStrict, TThrow>,\n TSelected\n >,\n): Solid.Accessor<\n ThrowOrOptional<UseMatchResult<TRouter, TFrom, TStrict, TSelected>, TThrow>\n> {\n const nearestMatchId = Solid.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\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 } as any)\n\n return matchSelection as any\n}\n"],"names":["useMatch","opts","nearestMatchId","Solid","useContext","from","dummyMatchContext","matchContext","matchSelection","useRouterState","select","state","match","matches","find","d","routeId","id","invariant","shouldThrow","undefined"],"mappings":";;;;AAsDO,SAASA,SAOdC,MASA;AACA,QAAMC,iBAAiBC,MAAMC,WAC3BH,KAAKI,OAAOC,oBAAoBC,YAClC;AAEA,QAAMC,iBAAiBC,eAAe;AAAA,IACpCC,QAAQA,CAACC,UAAe;AACtB,YAAMC,QAAQD,MAAME,QAAQC,KAAK,CAACC,MAChCd,KAAKI,OAAOJ,KAAKI,SAASU,EAAEC,UAAUD,EAAEE,OAAOf,gBACjD;AAEAgB,gBACE,GAAGjB,KAAKkB,eAAe,SAAS,CAACP,QACjC,kBAAkBX,KAAKI,OAAO,yBAAyBJ,KAAKI,IAAI,MAAM,kBAAkB,EAC1F;AAEA,UAAIO,UAAUQ,QAAW;AAChBA,eAAAA;AAAAA,MAAAA;AAGT,aAAOnB,KAAKS,SAAST,KAAKS,OAAOE,KAAK,IAAIA;AAAAA,IAAAA;AAAAA,EAC5C,CACM;AAEDJ,SAAAA;AACT;"}
|
package/dist/esm/useParams.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ThrowConstraint } from './useMatch.js';
|
|
2
1
|
import { Accessor } from 'solid-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> {
|
|
5
4
|
select?: (params: ResolveUseParams<TRouter, TFrom, TStrict>) => TSelected;
|
|
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 { Accessor } from 'solid-js'\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> {\n select?: (params: ResolveUseParams<TRouter, TFrom, TStrict>) => TSelected\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> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseParamsBaseOptions<TRouter, TFrom, TStrict, TThrow, TSelected>\n\nexport type UseParamsRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseParamsBaseOptions<\n TRouter,\n TFrom,\n /* TStrict */ true,\n /* TThrow */ true,\n TSelected\n >,\n) => Accessor<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>(\n opts: UseParamsOptions<\n TRouter,\n TFrom,\n TStrict,\n ThrowConstraint<TStrict, TThrow>,\n TSelected\n >,\n): Accessor<\n ThrowOrOptional<UseParamsResult<TRouter, TFrom, TStrict, TSelected>, TThrow>\n> {\n return useMatch({\n from: opts.from!,\n strict: opts.strict,\n shouldThrow: opts.shouldThrow,\n select: (match: any) => {\n return opts.select ? opts.select(match.params) : match.params\n },\n } as any) as any\n}\n"],"names":["useParams","opts","useMatch","from","strict","shouldThrow","select","match","params"],"mappings":";AA6CO,SAASA,UAOdC,MASA;AACA,SAAOC,SAAS;AAAA,IACdC,MAAMF,KAAKE;AAAAA,IACXC,QAAQH,KAAKG;AAAAA,IACbC,aAAaJ,KAAKI;AAAAA,IAClBC,QAAQA,CAACC,UAAe;AACtB,aAAON,KAAKK,SAASL,KAAKK,OAAOC,MAAMC,MAAM,IAAID,MAAMC;AAAAA,IAAAA;AAAAA,EACzD,CACM;AACV;"}
|
package/dist/esm/useSearch.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ThrowConstraint } from './useMatch.js';
|
|
2
1
|
import { Accessor } from 'solid-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> {
|
|
5
4
|
select?: (state: ResolveUseSearch<TRouter, TFrom, TStrict>) => TSelected;
|
|
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 { Accessor } from 'solid-js'\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> {\n select?: (state: ResolveUseSearch<TRouter, TFrom, TStrict>) => TSelected\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> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseSearchBaseOptions<TRouter, TFrom, TStrict, TThrow, TSelected>\n\nexport type UseSearchRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseSearchBaseOptions<\n TRouter,\n TFrom,\n /* TStrict */ true,\n /* TThrow */ true,\n TSelected\n >,\n) => Accessor<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>(\n opts: UseSearchOptions<\n TRouter,\n TFrom,\n TStrict,\n ThrowConstraint<TStrict, TThrow>,\n TSelected\n >,\n): Accessor<\n ThrowOrOptional<UseSearchResult<TRouter, TFrom, TStrict, TSelected>, TThrow>\n> {\n return useMatch({\n from: opts.from!,\n strict: opts.strict,\n shouldThrow: opts.shouldThrow,\n select: (match: any) => {\n return opts.select ? opts.select(match.search) : match.search\n },\n }) as any\n}\n"],"names":["useSearch","opts","useMatch","from","strict","shouldThrow","select","match","search"],"mappings":";AA6CO,SAASA,UAOdC,MASA;AACA,SAAOC,SAAS;AAAA,IACdC,MAAMF,KAAKE;AAAAA,IACXC,QAAQH,KAAKG;AAAAA,IACbC,aAAaJ,KAAKI;AAAAA,IAClBC,QAAQA,CAACC,UAAe;AACtB,aAAON,KAAKK,SAASL,KAAKK,OAAOC,MAAMC,MAAM,IAAID,MAAMC;AAAAA,IAAAA;AAAAA,EACzD,CACD;AACH;"}
|
package/dist/source/index.d.ts
CHANGED
|
@@ -42,7 +42,8 @@ export { useLayoutEffect } from './utils';
|
|
|
42
42
|
export { CatchNotFound, DefaultGlobalNotFound } from './not-found';
|
|
43
43
|
export { notFound, isNotFound } from '@tanstack/router-core';
|
|
44
44
|
export type { NotFoundError } from '@tanstack/router-core';
|
|
45
|
-
export
|
|
45
|
+
export type { ValidateLinkOptions, ValidateUseSearchOptions, ValidateUseParamsOptions, ValidateLinkOptionsArray, } from './typePrimitives';
|
|
46
|
+
export type { ValidateFromPath, ValidateToPath, ValidateSearch, ValidateParams, InferFrom, InferTo, InferMaskTo, InferMaskFrom, ValidateNavigateOptions, ValidateNavigateOptionsArray, ValidateRedirectOptions, ValidateRedirectOptionsArray, ValidateId, InferStrict, InferShouldThrow, InferSelected, ValidateUseSearchResult, ValidateUseParamsResult, } from '@tanstack/router-core';
|
|
46
47
|
export { ScriptOnce } from './ScriptOnce';
|
|
47
48
|
export { Asset } from './Asset';
|
|
48
49
|
export { HeadContent, useTags } from './HeadContent';
|
package/dist/source/index.jsx
CHANGED
|
@@ -34,7 +34,6 @@ export { useCanGoBack } from './useCanGoBack';
|
|
|
34
34
|
export { useLayoutEffect } from './utils';
|
|
35
35
|
export { CatchNotFound, DefaultGlobalNotFound } from './not-found';
|
|
36
36
|
export { notFound, isNotFound } from '@tanstack/router-core';
|
|
37
|
-
export * from './typePrimitives';
|
|
38
37
|
export { ScriptOnce } from './ScriptOnce';
|
|
39
38
|
export { Asset } from './Asset';
|
|
40
39
|
export { HeadContent, useTags } from './HeadContent';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.jsx","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAA;AAEjD,OAAO,EACL,KAAK,EACL,oBAAoB,EACpB,OAAO,EACP,SAAS,EACT,SAAS,EACT,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,WAAW,EACX,aAAa,EACb,eAAe,EACf,aAAa,EACb,cAAc,EACd,WAAW,EACX,MAAM,EACN,MAAM,EACN,WAAW,EACX,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O,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AA+B5D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA"}
|
|
@@ -1,68 +1,10 @@
|
|
|
1
1
|
import type { LinkComponentProps } from './link';
|
|
2
2
|
import type { UseParamsOptions } from './useParams';
|
|
3
3
|
import type { UseSearchOptions } from './useSearch';
|
|
4
|
-
import type { AnyRouter, Constrain,
|
|
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
|
-
};
|
|
4
|
+
import type { AnyRouter, Constrain, InferFrom, InferMaskFrom, InferMaskTo, InferSelected, InferShouldThrow, InferStrict, InferTo, RegisteredRouter } from '@tanstack/router-core';
|
|
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
6
|
export type ValidateLinkOptionsArray<TRouter extends AnyRouter = RegisteredRouter, TOptions extends ReadonlyArray<any> = ReadonlyArray<unknown>, TDefaultFrom extends string = string, TComp = 'a'> = {
|
|
44
7
|
[K in keyof TOptions]: ValidateLinkOptions<TRouter, TOptions[K], TDefaultFrom, TComp>;
|
|
45
8
|
};
|
|
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
9
|
export type ValidateUseSearchOptions<TOptions, TRouter extends AnyRouter = RegisteredRouter> = Constrain<TOptions, UseSearchOptions<TRouter, InferFrom<TOptions>, InferStrict<TOptions>, InferShouldThrow<TOptions>, InferSelected<TOptions>>>;
|
|
66
|
-
export type ValidateUseSearchResult<TOptions, TRouter extends AnyRouter = RegisteredRouter> = UseSearchResult<TRouter, InferFrom<TOptions>, InferStrict<TOptions>, InferSelected<TOptions>>;
|
|
67
10
|
export type ValidateUseParamsOptions<TOptions, TRouter extends AnyRouter = RegisteredRouter> = Constrain<TOptions, UseParamsOptions<TRouter, InferFrom<TOptions>, InferStrict<TOptions>, InferShouldThrow<TOptions>, InferSelected<TOptions>>>;
|
|
68
|
-
export type ValidateUseParamsResult<TOptions, TRouter extends AnyRouter = RegisteredRouter> = Constrain<TOptions, UseParamsResult<TRouter, InferFrom<TOptions>, InferStrict<TOptions>, InferSelected<TOptions>>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Solid from 'solid-js';
|
|
2
|
-
import type { AnyRouter, MakeRouteMatch, MakeRouteMatchUnion, RegisteredRouter, StrictOrFrom, ThrowOrOptional } from '@tanstack/router-core';
|
|
2
|
+
import type { 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> {
|
|
4
4
|
select?: (match: MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>) => TSelected;
|
|
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>(opts?: UseMatchBaseOptions<TRouter, TFrom, true, true, TSelected>) => Solid.Accessor<UseMatchResult<TRouter, TFrom, true, TSelected>>;
|
|
8
8
|
export type UseMatchOptions<TRouter extends AnyRouter, TFrom extends string | undefined, TStrict extends boolean, TThrow extends boolean, TSelected> = StrictOrFrom<TRouter, TFrom, TStrict> & UseMatchBaseOptions<TRouter, TFrom, TStrict, TThrow, TSelected>;
|
|
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>(opts: UseMatchOptions<TRouter, TFrom, TStrict, ThrowConstraint<TStrict, TThrow>, TSelected>): Solid.Accessor<ThrowOrOptional<UseMatchResult<TRouter, TFrom, TStrict, TSelected>, TThrow>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMatch.jsx","sourceRoot":"","sources":["../../src/useMatch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AACjC,OAAO,SAAS,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"useMatch.jsx","sourceRoot":"","sources":["../../src/useMatch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AACjC,OAAO,SAAS,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAmDhE,MAAM,UAAU,QAAQ,CAOtB,IAMC;IAID,MAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CACrC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,YAAY,CAC7C,CAAA;IAED,MAAM,cAAc,GAAG,cAAc,CAAC;QACpC,MAAM,EAAE,CAAC,KAAU,EAAE,EAAE;YACrB,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAC1C,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,cAAc,EAAE,CAChE,CAAA;YAED,SAAS,CACP,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EACvC,kBAAkB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,yBAAyB,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAC3F,CAAA;YAED,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,OAAO,SAAS,CAAA;YAClB,CAAC;YAED,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;QACjD,CAAC;KACK,CAAC,CAAA;IAET,OAAO,cAAqB,CAAA;AAC9B,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { ThrowConstraint } from './useMatch';
|
|
2
1
|
import type { Accessor } from 'solid-js';
|
|
3
|
-
import type { AnyRouter, RegisteredRouter, ResolveUseParams, StrictOrFrom, ThrowOrOptional, UseParamsResult } from '@tanstack/router-core';
|
|
2
|
+
import type { 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> {
|
|
5
4
|
select?: (params: ResolveUseParams<TRouter, TFrom, TStrict>) => TSelected;
|
|
6
5
|
shouldThrow?: TThrow;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { ThrowConstraint } from './useMatch';
|
|
2
1
|
import type { Accessor } from 'solid-js';
|
|
3
|
-
import type { AnyRouter, RegisteredRouter, ResolveUseSearch, StrictOrFrom, ThrowOrOptional, UseSearchResult } from '@tanstack/router-core';
|
|
2
|
+
import type { 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> {
|
|
5
4
|
select?: (state: ResolveUseSearch<TRouter, TFrom, TStrict>) => TSelected;
|
|
6
5
|
shouldThrow?: TThrow;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/solid-router",
|
|
3
|
-
"version": "1.114.
|
|
3
|
+
"version": "1.114.17",
|
|
4
4
|
"description": "Modern and scalable routing for Solid applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"tiny-invariant": "^1.3.3",
|
|
62
62
|
"tiny-warning": "^1.0.3",
|
|
63
63
|
"@tanstack/history": "1.114.12",
|
|
64
|
-
"@tanstack/router-core": "1.114.
|
|
64
|
+
"@tanstack/router-core": "1.114.17"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@solidjs/testing-library": "^0.8.10",
|
package/src/index.tsx
CHANGED
|
@@ -335,7 +335,33 @@ export { CatchNotFound, DefaultGlobalNotFound } from './not-found'
|
|
|
335
335
|
export { notFound, isNotFound } from '@tanstack/router-core'
|
|
336
336
|
export type { NotFoundError } from '@tanstack/router-core'
|
|
337
337
|
|
|
338
|
-
export
|
|
338
|
+
export type {
|
|
339
|
+
ValidateLinkOptions,
|
|
340
|
+
ValidateUseSearchOptions,
|
|
341
|
+
ValidateUseParamsOptions,
|
|
342
|
+
ValidateLinkOptionsArray,
|
|
343
|
+
} from './typePrimitives'
|
|
344
|
+
|
|
345
|
+
export type {
|
|
346
|
+
ValidateFromPath,
|
|
347
|
+
ValidateToPath,
|
|
348
|
+
ValidateSearch,
|
|
349
|
+
ValidateParams,
|
|
350
|
+
InferFrom,
|
|
351
|
+
InferTo,
|
|
352
|
+
InferMaskTo,
|
|
353
|
+
InferMaskFrom,
|
|
354
|
+
ValidateNavigateOptions,
|
|
355
|
+
ValidateNavigateOptionsArray,
|
|
356
|
+
ValidateRedirectOptions,
|
|
357
|
+
ValidateRedirectOptionsArray,
|
|
358
|
+
ValidateId,
|
|
359
|
+
InferStrict,
|
|
360
|
+
InferShouldThrow,
|
|
361
|
+
InferSelected,
|
|
362
|
+
ValidateUseSearchResult,
|
|
363
|
+
ValidateUseParamsResult,
|
|
364
|
+
} from '@tanstack/router-core'
|
|
339
365
|
|
|
340
366
|
export { ScriptOnce } from './ScriptOnce'
|
|
341
367
|
|
package/src/typePrimitives.ts
CHANGED
|
@@ -4,131 +4,16 @@ import type { UseSearchOptions } from './useSearch'
|
|
|
4
4
|
import type {
|
|
5
5
|
AnyRouter,
|
|
6
6
|
Constrain,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
InferFrom,
|
|
8
|
+
InferMaskFrom,
|
|
9
|
+
InferMaskTo,
|
|
10
|
+
InferSelected,
|
|
11
|
+
InferShouldThrow,
|
|
12
|
+
InferStrict,
|
|
13
|
+
InferTo,
|
|
12
14
|
RegisteredRouter,
|
|
13
|
-
RouteIds,
|
|
14
|
-
SearchParamOptions,
|
|
15
|
-
ToPathOption,
|
|
16
|
-
UseParamsResult,
|
|
17
|
-
UseSearchResult,
|
|
18
15
|
} from '@tanstack/router-core'
|
|
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
|
-
export type ValidateRedirectOptions<
|
|
106
|
-
TRouter extends AnyRouter = RegisteredRouter,
|
|
107
|
-
TOptions = unknown,
|
|
108
|
-
TDefaultFrom extends string = string,
|
|
109
|
-
> = Constrain<
|
|
110
|
-
TOptions,
|
|
111
|
-
Redirect<
|
|
112
|
-
TRouter,
|
|
113
|
-
InferFrom<TOptions, TDefaultFrom>,
|
|
114
|
-
InferTo<TOptions>,
|
|
115
|
-
InferMaskFrom<TOptions>,
|
|
116
|
-
InferMaskTo<TOptions>
|
|
117
|
-
>
|
|
118
|
-
>
|
|
119
|
-
|
|
120
|
-
export type ValidateRedirectOptionsArray<
|
|
121
|
-
TRouter extends AnyRouter = RegisteredRouter,
|
|
122
|
-
TOptions extends ReadonlyArray<any> = ReadonlyArray<unknown>,
|
|
123
|
-
TDefaultFrom extends string = string,
|
|
124
|
-
> = {
|
|
125
|
-
[K in keyof TOptions]: ValidateRedirectOptions<
|
|
126
|
-
TRouter,
|
|
127
|
-
TOptions[K],
|
|
128
|
-
TDefaultFrom
|
|
129
|
-
>
|
|
130
|
-
}
|
|
131
|
-
|
|
132
17
|
export type ValidateLinkOptions<
|
|
133
18
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
134
19
|
TOptions = unknown,
|
|
@@ -160,38 +45,6 @@ export type ValidateLinkOptionsArray<
|
|
|
160
45
|
>
|
|
161
46
|
}
|
|
162
47
|
|
|
163
|
-
export type ValidateId<
|
|
164
|
-
TRouter extends AnyRouter = RegisteredRouter,
|
|
165
|
-
TId extends string = string,
|
|
166
|
-
> = ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* @internal
|
|
170
|
-
*/
|
|
171
|
-
export type InferStrict<TOptions> = TOptions extends {
|
|
172
|
-
strict: infer TStrict extends boolean
|
|
173
|
-
}
|
|
174
|
-
? TStrict
|
|
175
|
-
: true
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* @internal
|
|
179
|
-
*/
|
|
180
|
-
export type InferShouldThrow<TOptions> = TOptions extends {
|
|
181
|
-
shouldThrow: infer TShouldThrow extends boolean
|
|
182
|
-
}
|
|
183
|
-
? TShouldThrow
|
|
184
|
-
: true
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* @internal
|
|
188
|
-
*/
|
|
189
|
-
export type InferSelected<TOptions> = TOptions extends {
|
|
190
|
-
select: (...args: Array<any>) => infer TSelected
|
|
191
|
-
}
|
|
192
|
-
? TSelected
|
|
193
|
-
: unknown
|
|
194
|
-
|
|
195
48
|
export type ValidateUseSearchOptions<
|
|
196
49
|
TOptions,
|
|
197
50
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
@@ -206,16 +59,6 @@ export type ValidateUseSearchOptions<
|
|
|
206
59
|
>
|
|
207
60
|
>
|
|
208
61
|
|
|
209
|
-
export type ValidateUseSearchResult<
|
|
210
|
-
TOptions,
|
|
211
|
-
TRouter extends AnyRouter = RegisteredRouter,
|
|
212
|
-
> = UseSearchResult<
|
|
213
|
-
TRouter,
|
|
214
|
-
InferFrom<TOptions>,
|
|
215
|
-
InferStrict<TOptions>,
|
|
216
|
-
InferSelected<TOptions>
|
|
217
|
-
>
|
|
218
|
-
|
|
219
62
|
export type ValidateUseParamsOptions<
|
|
220
63
|
TOptions,
|
|
221
64
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
@@ -229,16 +72,3 @@ export type ValidateUseParamsOptions<
|
|
|
229
72
|
InferSelected<TOptions>
|
|
230
73
|
>
|
|
231
74
|
>
|
|
232
|
-
|
|
233
|
-
export type ValidateUseParamsResult<
|
|
234
|
-
TOptions,
|
|
235
|
-
TRouter extends AnyRouter = RegisteredRouter,
|
|
236
|
-
> = Constrain<
|
|
237
|
-
TOptions,
|
|
238
|
-
UseParamsResult<
|
|
239
|
-
TRouter,
|
|
240
|
-
InferFrom<TOptions>,
|
|
241
|
-
InferStrict<TOptions>,
|
|
242
|
-
InferSelected<TOptions>
|
|
243
|
-
>
|
|
244
|
-
>
|
package/src/useMatch.tsx
CHANGED
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
MakeRouteMatchUnion,
|
|
9
9
|
RegisteredRouter,
|
|
10
10
|
StrictOrFrom,
|
|
11
|
+
ThrowConstraint,
|
|
11
12
|
ThrowOrOptional,
|
|
12
13
|
} from '@tanstack/router-core'
|
|
13
14
|
|
|
@@ -51,11 +52,6 @@ export type UseMatchResult<
|
|
|
51
52
|
: MakeRouteMatchUnion<TRouter>
|
|
52
53
|
: TSelected
|
|
53
54
|
|
|
54
|
-
export type ThrowConstraint<
|
|
55
|
-
TStrict extends boolean,
|
|
56
|
-
TThrow extends boolean,
|
|
57
|
-
> = TStrict extends false ? (TThrow extends true ? never : TThrow) : TThrow
|
|
58
|
-
|
|
59
55
|
export function useMatch<
|
|
60
56
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
61
57
|
const TFrom extends string | undefined = undefined,
|
package/src/useParams.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useMatch } from './useMatch'
|
|
2
|
-
import type { ThrowConstraint } from './useMatch'
|
|
3
2
|
import type { Accessor } from 'solid-js'
|
|
4
3
|
import type {
|
|
5
4
|
AnyRouter,
|
|
6
5
|
RegisteredRouter,
|
|
7
6
|
ResolveUseParams,
|
|
8
7
|
StrictOrFrom,
|
|
8
|
+
ThrowConstraint,
|
|
9
9
|
ThrowOrOptional,
|
|
10
10
|
UseParamsResult,
|
|
11
11
|
} from '@tanstack/router-core'
|
package/src/useSearch.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useMatch } from './useMatch'
|
|
2
|
-
import type { ThrowConstraint } from './useMatch'
|
|
3
2
|
import type { Accessor } from 'solid-js'
|
|
4
3
|
import type {
|
|
5
4
|
AnyRouter,
|
|
6
5
|
RegisteredRouter,
|
|
7
6
|
ResolveUseSearch,
|
|
8
7
|
StrictOrFrom,
|
|
8
|
+
ThrowConstraint,
|
|
9
9
|
ThrowOrOptional,
|
|
10
10
|
UseSearchResult,
|
|
11
11
|
} from '@tanstack/router-core'
|