@tanstack/router-core 0.0.1-beta.19 → 0.0.1-beta.191
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/LICENSE +21 -0
- package/build/cjs/defer.js +39 -0
- package/build/cjs/defer.js.map +1 -0
- package/build/cjs/fileRoute.js +29 -0
- package/build/cjs/fileRoute.js.map +1 -0
- package/build/cjs/history.js +228 -0
- package/build/cjs/history.js.map +1 -0
- package/build/cjs/index.js +86 -0
- package/build/cjs/{packages/router-core/src/index.js.map → index.js.map} +1 -1
- package/build/cjs/{packages/router-core/src/path.js → path.js} +45 -56
- package/build/cjs/path.js.map +1 -0
- package/build/cjs/{packages/router-core/src/qss.js → qss.js} +10 -16
- package/build/cjs/qss.js.map +1 -0
- package/build/cjs/route.js +114 -0
- package/build/cjs/route.js.map +1 -0
- package/build/cjs/router.js +1267 -0
- package/build/cjs/router.js.map +1 -0
- package/build/cjs/scroll-restoration.js +139 -0
- package/build/cjs/scroll-restoration.js.map +1 -0
- package/build/cjs/{packages/router-core/src/searchParams.js → searchParams.js} +32 -19
- package/build/cjs/searchParams.js.map +1 -0
- package/build/cjs/{packages/router-core/src/utils.js → utils.js} +69 -64
- package/build/cjs/utils.js.map +1 -0
- package/build/esm/index.js +1746 -2121
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +59 -49
- package/build/stats-react.json +197 -211
- package/build/types/defer.d.ts +19 -0
- package/build/types/fileRoute.d.ts +35 -0
- package/build/types/history.d.ts +36 -0
- package/build/types/index.d.ts +13 -609
- package/build/types/link.d.ts +96 -0
- package/build/types/path.d.ts +16 -0
- package/build/types/qss.d.ts +2 -0
- package/build/types/route.d.ts +251 -0
- package/build/types/routeInfo.d.ts +22 -0
- package/build/types/router.d.ts +260 -0
- package/build/types/scroll-restoration.d.ts +6 -0
- package/build/types/searchParams.d.ts +5 -0
- package/build/types/utils.d.ts +44 -0
- package/build/umd/index.development.js +1978 -2243
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +13 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +11 -7
- package/src/defer.ts +55 -0
- package/src/fileRoute.ts +161 -0
- package/src/history.ts +300 -0
- package/src/index.ts +5 -10
- package/src/link.ts +136 -125
- package/src/path.ts +37 -17
- package/src/qss.ts +1 -2
- package/src/route.ts +948 -218
- package/src/routeInfo.ts +45 -211
- package/src/router.ts +1778 -1075
- package/src/scroll-restoration.ts +179 -0
- package/src/searchParams.ts +31 -9
- package/src/utils.ts +84 -49
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -33
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
- package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js +0 -33
- package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js.map +0 -1
- package/build/cjs/node_modules/history/index.js +0 -815
- package/build/cjs/node_modules/history/index.js.map +0 -1
- package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js +0 -30
- package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js.map +0 -1
- package/build/cjs/packages/router-core/src/index.js +0 -58
- package/build/cjs/packages/router-core/src/path.js.map +0 -1
- package/build/cjs/packages/router-core/src/qss.js.map +0 -1
- package/build/cjs/packages/router-core/src/route.js +0 -147
- package/build/cjs/packages/router-core/src/route.js.map +0 -1
- package/build/cjs/packages/router-core/src/routeConfig.js +0 -69
- package/build/cjs/packages/router-core/src/routeConfig.js.map +0 -1
- package/build/cjs/packages/router-core/src/routeMatch.js +0 -220
- package/build/cjs/packages/router-core/src/routeMatch.js.map +0 -1
- package/build/cjs/packages/router-core/src/router.js +0 -870
- package/build/cjs/packages/router-core/src/router.js.map +0 -1
- package/build/cjs/packages/router-core/src/searchParams.js.map +0 -1
- package/build/cjs/packages/router-core/src/utils.js.map +0 -1
- package/src/frameworks.ts +0 -11
- package/src/routeConfig.ts +0 -511
- package/src/routeMatch.ts +0 -312
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { Store } from '@tanstack/store';
|
|
2
|
+
import { LinkInfo, LinkOptions, NavigateOptions, ToOptions, ResolveRelativePath } from './link';
|
|
3
|
+
import { Route, AnySearchSchema, AnyRoute, AnyContext, AnyPathParams, RegisteredRouteComponent, RegisteredErrorRouteComponent, RegisteredPendingRouteComponent, RouteMask } from './route';
|
|
4
|
+
import { RoutesById, RoutesByPath, ParseRoute, FullSearchSchema, RouteById, RoutePaths, RouteIds } from './routeInfo';
|
|
5
|
+
import { NoInfer, PickAsRequired, Timeout, Updater, NonNullableUpdater } from './utils';
|
|
6
|
+
import { HistoryState, RouterHistory } from './history';
|
|
7
|
+
declare global {
|
|
8
|
+
interface Window {
|
|
9
|
+
__TSR_DEHYDRATED__?: HydrationCtx;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export interface Register {
|
|
13
|
+
}
|
|
14
|
+
export interface LocationState {
|
|
15
|
+
}
|
|
16
|
+
export type AnyRouter = Router<any, any>;
|
|
17
|
+
export type RegisteredRouter = Register extends {
|
|
18
|
+
router: infer TRouter extends AnyRouter;
|
|
19
|
+
} ? TRouter : AnyRouter;
|
|
20
|
+
export interface ParsedLocation<TSearchObj extends AnySearchSchema = {}> {
|
|
21
|
+
href: string;
|
|
22
|
+
pathname: string;
|
|
23
|
+
search: TSearchObj;
|
|
24
|
+
searchStr: string;
|
|
25
|
+
state: HistoryState;
|
|
26
|
+
hash: string;
|
|
27
|
+
maskedLocation?: ParsedLocation<TSearchObj>;
|
|
28
|
+
unmaskOnReload?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface FromLocation {
|
|
31
|
+
pathname: string;
|
|
32
|
+
search?: unknown;
|
|
33
|
+
hash?: string;
|
|
34
|
+
}
|
|
35
|
+
export type SearchSerializer = (searchObj: Record<string, any>) => string;
|
|
36
|
+
export type SearchParser = (searchStr: string) => Record<string, any>;
|
|
37
|
+
export type HydrationCtx = {
|
|
38
|
+
router: DehydratedRouter;
|
|
39
|
+
payload: Record<string, any>;
|
|
40
|
+
};
|
|
41
|
+
export interface RouteMatch<TRouteTree extends AnyRoute = AnyRoute, TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id']> {
|
|
42
|
+
id: string;
|
|
43
|
+
key?: string;
|
|
44
|
+
routeId: TRouteId;
|
|
45
|
+
pathname: string;
|
|
46
|
+
params: RouteById<TRouteTree, TRouteId>['types']['allParams'];
|
|
47
|
+
status: 'pending' | 'success' | 'error';
|
|
48
|
+
isFetching: boolean;
|
|
49
|
+
invalid: boolean;
|
|
50
|
+
error: unknown;
|
|
51
|
+
paramsError: unknown;
|
|
52
|
+
searchError: unknown;
|
|
53
|
+
updatedAt: number;
|
|
54
|
+
maxAge: number;
|
|
55
|
+
preloadMaxAge: number;
|
|
56
|
+
loaderData: RouteById<TRouteTree, TRouteId>['types']['loader'];
|
|
57
|
+
loadPromise?: Promise<void>;
|
|
58
|
+
__resolveLoadPromise?: () => void;
|
|
59
|
+
routeContext: RouteById<TRouteTree, TRouteId>['types']['routeContext'];
|
|
60
|
+
context: RouteById<TRouteTree, TRouteId>['types']['context'];
|
|
61
|
+
routeSearch: RouteById<TRouteTree, TRouteId>['types']['searchSchema'];
|
|
62
|
+
search: FullSearchSchema<TRouteTree> & RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema'];
|
|
63
|
+
fetchedAt: number;
|
|
64
|
+
abortController: AbortController;
|
|
65
|
+
}
|
|
66
|
+
export type AnyRouteMatch = RouteMatch<any>;
|
|
67
|
+
export type RouterContextOptions<TRouteTree extends AnyRoute> = AnyContext extends TRouteTree['types']['routerContext'] ? {
|
|
68
|
+
context?: TRouteTree['types']['routerContext'];
|
|
69
|
+
} : {
|
|
70
|
+
context: TRouteTree['types']['routerContext'];
|
|
71
|
+
};
|
|
72
|
+
export interface RouterOptions<TRouteTree extends AnyRoute, TDehydrated extends Record<string, any>> {
|
|
73
|
+
history?: RouterHistory;
|
|
74
|
+
stringifySearch?: SearchSerializer;
|
|
75
|
+
parseSearch?: SearchParser;
|
|
76
|
+
defaultPreload?: false | 'intent';
|
|
77
|
+
defaultPreloadDelay?: number;
|
|
78
|
+
reloadOnWindowFocus?: boolean;
|
|
79
|
+
defaultComponent?: RegisteredRouteComponent<unknown, AnySearchSchema, AnyPathParams, AnyContext, AnyContext>;
|
|
80
|
+
defaultErrorComponent?: RegisteredErrorRouteComponent<AnySearchSchema, AnyPathParams, AnyContext, AnyContext>;
|
|
81
|
+
defaultPendingComponent?: RegisteredPendingRouteComponent<AnySearchSchema, AnyPathParams, AnyContext, AnyContext>;
|
|
82
|
+
defaultMaxAge?: number;
|
|
83
|
+
defaultGcMaxAge?: number;
|
|
84
|
+
defaultPreloadMaxAge?: number;
|
|
85
|
+
caseSensitive?: boolean;
|
|
86
|
+
routeTree?: TRouteTree;
|
|
87
|
+
basepath?: string;
|
|
88
|
+
createRoute?: (opts: {
|
|
89
|
+
route: AnyRoute;
|
|
90
|
+
router: AnyRouter;
|
|
91
|
+
}) => void;
|
|
92
|
+
context?: TRouteTree['types']['routerContext'];
|
|
93
|
+
dehydrate?: () => TDehydrated;
|
|
94
|
+
hydrate?: (dehydrated: TDehydrated) => void;
|
|
95
|
+
routeMasks?: RouteMask<TRouteTree>[];
|
|
96
|
+
unmaskOnReload?: boolean;
|
|
97
|
+
}
|
|
98
|
+
export interface RouterState<TRouteTree extends AnyRoute = AnyRoute> {
|
|
99
|
+
status: 'idle' | 'pending';
|
|
100
|
+
isFetching: boolean;
|
|
101
|
+
matchesById: Record<string, RouteMatch<TRouteTree>>;
|
|
102
|
+
matchIds: string[];
|
|
103
|
+
pendingMatchIds: string[];
|
|
104
|
+
matches: RouteMatch<TRouteTree>[];
|
|
105
|
+
pendingMatches: RouteMatch<TRouteTree>[];
|
|
106
|
+
renderedMatchIds: string[];
|
|
107
|
+
renderedMatches: RouteMatch<TRouteTree>[];
|
|
108
|
+
location: ParsedLocation<FullSearchSchema<TRouteTree>>;
|
|
109
|
+
resolvedLocation: ParsedLocation<FullSearchSchema<TRouteTree>>;
|
|
110
|
+
lastUpdated: number;
|
|
111
|
+
}
|
|
112
|
+
export type ListenerFn<TEvent extends RouterEvent> = (event: TEvent) => void;
|
|
113
|
+
export interface BuildNextOptions {
|
|
114
|
+
to?: string | number | null;
|
|
115
|
+
params?: true | Updater<unknown>;
|
|
116
|
+
search?: true | Updater<unknown>;
|
|
117
|
+
hash?: true | Updater<string>;
|
|
118
|
+
state?: true | NonNullableUpdater<LocationState>;
|
|
119
|
+
mask?: {
|
|
120
|
+
to?: string | number | null;
|
|
121
|
+
params?: true | Updater<unknown>;
|
|
122
|
+
search?: true | Updater<unknown>;
|
|
123
|
+
hash?: true | Updater<string>;
|
|
124
|
+
state?: true | NonNullableUpdater<LocationState>;
|
|
125
|
+
unmaskOnReload?: boolean;
|
|
126
|
+
};
|
|
127
|
+
from?: string;
|
|
128
|
+
}
|
|
129
|
+
export interface CommitLocationOptions {
|
|
130
|
+
replace?: boolean;
|
|
131
|
+
resetScroll?: boolean;
|
|
132
|
+
}
|
|
133
|
+
export interface MatchLocation {
|
|
134
|
+
to?: string | number | null;
|
|
135
|
+
fuzzy?: boolean;
|
|
136
|
+
caseSensitive?: boolean;
|
|
137
|
+
from?: string;
|
|
138
|
+
}
|
|
139
|
+
export interface MatchRouteOptions {
|
|
140
|
+
pending?: boolean;
|
|
141
|
+
caseSensitive?: boolean;
|
|
142
|
+
includeSearch?: boolean;
|
|
143
|
+
fuzzy?: boolean;
|
|
144
|
+
}
|
|
145
|
+
export interface DehydratedRouterState {
|
|
146
|
+
matchIds: string[];
|
|
147
|
+
dehydratedMatches: DehydratedRouteMatch[];
|
|
148
|
+
}
|
|
149
|
+
export type DehydratedRouteMatch = Pick<RouteMatch, 'fetchedAt' | 'invalid' | 'maxAge' | 'preloadMaxAge' | 'id' | 'loaderData' | 'status' | 'updatedAt'>;
|
|
150
|
+
export interface DehydratedRouter {
|
|
151
|
+
state: DehydratedRouterState;
|
|
152
|
+
}
|
|
153
|
+
export type RouterConstructorOptions<TRouteTree extends AnyRoute, TDehydrated extends Record<string, any>> = Omit<RouterOptions<TRouteTree, TDehydrated>, 'context'> & RouterContextOptions<TRouteTree>;
|
|
154
|
+
export declare const componentTypes: readonly ["component", "errorComponent", "pendingComponent"];
|
|
155
|
+
export type RouterEvents = {
|
|
156
|
+
onBeforeLoad: {
|
|
157
|
+
type: 'onBeforeLoad';
|
|
158
|
+
from: ParsedLocation;
|
|
159
|
+
to: ParsedLocation;
|
|
160
|
+
pathChanged: boolean;
|
|
161
|
+
};
|
|
162
|
+
onLoad: {
|
|
163
|
+
type: 'onLoad';
|
|
164
|
+
from: ParsedLocation;
|
|
165
|
+
to: ParsedLocation;
|
|
166
|
+
pathChanged: boolean;
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
export type RouterEvent = RouterEvents[keyof RouterEvents];
|
|
170
|
+
export type RouterListener<TRouterEvent extends RouterEvent> = {
|
|
171
|
+
eventType: TRouterEvent['type'];
|
|
172
|
+
fn: ListenerFn<TRouterEvent>;
|
|
173
|
+
};
|
|
174
|
+
export declare class Router<TRouteTree extends AnyRoute = AnyRoute, TDehydrated extends Record<string, any> = Record<string, any>> {
|
|
175
|
+
#private;
|
|
176
|
+
types: {
|
|
177
|
+
RootRoute: TRouteTree;
|
|
178
|
+
};
|
|
179
|
+
options: PickAsRequired<RouterOptions<TRouteTree, TDehydrated>, 'stringifySearch' | 'parseSearch' | 'context'>;
|
|
180
|
+
history: RouterHistory;
|
|
181
|
+
basepath: string;
|
|
182
|
+
routeTree: TRouteTree;
|
|
183
|
+
routesById: RoutesById<TRouteTree>;
|
|
184
|
+
routesByPath: RoutesByPath<TRouteTree>;
|
|
185
|
+
flatRoutes: ParseRoute<TRouteTree>[];
|
|
186
|
+
navigateTimeout: undefined | Timeout;
|
|
187
|
+
nextAction: undefined | 'push' | 'replace';
|
|
188
|
+
navigationPromise: undefined | Promise<void>;
|
|
189
|
+
__store: Store<RouterState<TRouteTree>>;
|
|
190
|
+
state: RouterState<TRouteTree>;
|
|
191
|
+
dehydratedData?: TDehydrated;
|
|
192
|
+
resetNextScroll: boolean;
|
|
193
|
+
tempLocationKey: string;
|
|
194
|
+
constructor(options: RouterConstructorOptions<TRouteTree, TDehydrated>);
|
|
195
|
+
subscribers: Set<RouterListener<RouterEvent>>;
|
|
196
|
+
subscribe: <TType extends keyof RouterEvents>(eventType: TType, fn: ListenerFn<RouterEvents[TType]>) => () => void;
|
|
197
|
+
reset: () => void;
|
|
198
|
+
mount: () => () => void;
|
|
199
|
+
update: (opts?: RouterOptions<any, any>) => this;
|
|
200
|
+
cancelMatches: () => void;
|
|
201
|
+
cancelMatch: (id: string) => void;
|
|
202
|
+
safeLoad: (opts?: {
|
|
203
|
+
next?: ParsedLocation;
|
|
204
|
+
}) => Promise<void>;
|
|
205
|
+
latestLoadPromise: Promise<void>;
|
|
206
|
+
load: (opts?: {
|
|
207
|
+
next?: ParsedLocation;
|
|
208
|
+
throwOnError?: boolean;
|
|
209
|
+
__dehydratedMatches?: DehydratedRouteMatch[];
|
|
210
|
+
}) => Promise<void>;
|
|
211
|
+
getRoute: (id: string) => Route;
|
|
212
|
+
preloadRoute: (navigateOpts?: BuildNextOptions & {
|
|
213
|
+
maxAge?: number;
|
|
214
|
+
}) => Promise<readonly [RouteMatch<TRouteTree, ParseRoute<TRouteTree>["id"]>, RouteMatch<TRouteTree, ParseRoute<TRouteTree>["id"]>[]]>;
|
|
215
|
+
cleanMatches: () => void;
|
|
216
|
+
matchRoutes: (pathname: string, locationSearch: AnySearchSchema, opts?: {
|
|
217
|
+
throwOnError?: boolean;
|
|
218
|
+
debug?: boolean;
|
|
219
|
+
}) => RouteMatch<TRouteTree>[];
|
|
220
|
+
loadMatches: (matchIds: string[], opts?: {
|
|
221
|
+
preload?: boolean;
|
|
222
|
+
maxAge?: number;
|
|
223
|
+
}) => Promise<void>;
|
|
224
|
+
resolvePath: (from: string, path: string) => string;
|
|
225
|
+
navigate: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string = "", TMaskFrom extends RoutePaths<TRouteTree> = TFrom, TMaskTo extends string = "">({ from, to, ...rest }: NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>) => Promise<void>;
|
|
226
|
+
matchRoute: <TRouteTree_1 extends AnyRoute = AnyRoute, TFrom extends RoutePaths<TRouteTree_1> = "/", TTo extends string = "", TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>>(location: ToOptions<TRouteTree_1, TFrom, TTo, "/", "">, opts?: MatchRouteOptions) => false | RouteById<TRouteTree_1, TResolved>["types"]["allParams"];
|
|
227
|
+
buildLink: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string = "">(dest: LinkOptions<TRouteTree, TFrom, TTo, TFrom, "">) => LinkInfo;
|
|
228
|
+
dehydrate: () => DehydratedRouter;
|
|
229
|
+
hydrate: (__do_not_use_server_ctx?: HydrationCtx) => Promise<void>;
|
|
230
|
+
injectedHtml: (string | (() => Promise<string> | string))[];
|
|
231
|
+
injectHtml: (html: string | (() => Promise<string> | string)) => Promise<void>;
|
|
232
|
+
dehydrateData: <T>(key: any, getData: T | (() => T | Promise<T>)) => () => T | undefined;
|
|
233
|
+
hydrateData: <T = unknown>(key: any) => T | undefined;
|
|
234
|
+
buildLocation: (opts?: BuildNextOptions) => ParsedLocation;
|
|
235
|
+
getRouteMatch: (id: string) => undefined | RouteMatch<TRouteTree>;
|
|
236
|
+
setRouteMatch: (id: string, updater: (prev: RouteMatch<TRouteTree>) => RouteMatch<TRouteTree>) => void;
|
|
237
|
+
setRouteMatchData: (id: string, updater: (prev: any) => any, opts?: {
|
|
238
|
+
updatedAt?: number;
|
|
239
|
+
maxAge?: number;
|
|
240
|
+
}) => void;
|
|
241
|
+
invalidate: (opts?: {
|
|
242
|
+
matchId?: string;
|
|
243
|
+
reload?: boolean;
|
|
244
|
+
__fromFocus?: boolean;
|
|
245
|
+
}) => Promise<void>;
|
|
246
|
+
}
|
|
247
|
+
export type AnyRedirect = Redirect<any, any, any>;
|
|
248
|
+
export type Redirect<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> = TFrom, TMaskTo extends string = ''> = NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {
|
|
249
|
+
code?: number;
|
|
250
|
+
};
|
|
251
|
+
export declare function redirect<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = ''>(opts: Redirect<TRouteTree, TFrom, TTo>): Redirect<TRouteTree, TFrom, TTo>;
|
|
252
|
+
export declare function isRedirect(obj: any): obj is AnyRedirect;
|
|
253
|
+
export declare class SearchParamError extends Error {
|
|
254
|
+
}
|
|
255
|
+
export declare class PathParamError extends Error {
|
|
256
|
+
}
|
|
257
|
+
export declare function lazyFn<T extends Record<string, (...args: any[]) => any>, TKey extends keyof T = 'default'>(fn: () => Promise<T>, key?: TKey): (...args: Parameters<T[TKey]>) => Promise<ReturnType<T[TKey]>>;
|
|
258
|
+
export declare function isMatchInvalid(match: AnyRouteMatch, opts?: {
|
|
259
|
+
preload?: boolean;
|
|
260
|
+
}): boolean;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AnyRouter, ParsedLocation } from './router';
|
|
2
|
+
export type ScrollRestorationOptions = {
|
|
3
|
+
getKey?: (location: ParsedLocation) => string;
|
|
4
|
+
};
|
|
5
|
+
export declare function watchScrollPositions(router: AnyRouter, opts?: ScrollRestorationOptions): () => void;
|
|
6
|
+
export declare function restoreScrollPositions(router: AnyRouter, opts?: ScrollRestorationOptions): void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AnySearchSchema } from './route';
|
|
2
|
+
export declare const defaultParseSearch: (searchStr: string) => AnySearchSchema;
|
|
3
|
+
export declare const defaultStringifySearch: (search: Record<string, any>) => string;
|
|
4
|
+
export declare function parseSearchWith(parser: (str: string) => any): (searchStr: string) => AnySearchSchema;
|
|
5
|
+
export declare function stringifySearchWith(stringify: (search: any) => string, parser?: (str: string) => any): (search: Record<string, any>) => string;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
2
|
+
export type IsAny<T, Y, N> = 1 extends 0 & T ? Y : N;
|
|
3
|
+
export type IsAnyBoolean<T> = 1 extends 0 & T ? true : false;
|
|
4
|
+
export type IsKnown<T, Y, N> = unknown extends T ? N : Y;
|
|
5
|
+
export type PickAsRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
|
6
|
+
export type PickAsPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
7
|
+
export type PickUnsafe<T, K> = K extends keyof T ? Pick<T, K> : never;
|
|
8
|
+
export type PickExtra<T, K> = {
|
|
9
|
+
[TKey in keyof K as string extends TKey ? never : TKey extends keyof T ? never : TKey]: K[TKey];
|
|
10
|
+
};
|
|
11
|
+
export type PickRequired<T> = {
|
|
12
|
+
[K in keyof T as undefined extends T[K] ? never : K]: T[K];
|
|
13
|
+
};
|
|
14
|
+
export type Expand<T> = T extends object ? T extends infer O ? {
|
|
15
|
+
[K in keyof O]: O[K];
|
|
16
|
+
} : never : T;
|
|
17
|
+
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => any ? I : never;
|
|
18
|
+
export type Values<O> = O[ValueKeys<O>];
|
|
19
|
+
export type ValueKeys<O> = Extract<keyof O, PropertyKey>;
|
|
20
|
+
export type DeepAwaited<T> = T extends Promise<infer A> ? DeepAwaited<A> : T extends Record<infer A, Promise<infer B>> ? {
|
|
21
|
+
[K in A]: DeepAwaited<B>;
|
|
22
|
+
} : T;
|
|
23
|
+
export type PathParamMask<TRoutePath extends string> = TRoutePath extends `${infer L}/$${infer C}/${infer R}` ? PathParamMask<`${L}/${string}/${R}`> : TRoutePath extends `${infer L}/$${infer C}` ? PathParamMask<`${L}/${string}`> : TRoutePath;
|
|
24
|
+
export type Timeout = ReturnType<typeof setTimeout>;
|
|
25
|
+
export type Updater<TPrevious, TResult = TPrevious> = TResult | ((prev?: TPrevious) => TResult);
|
|
26
|
+
export type NonNullableUpdater<TPrevious, TResult = TPrevious> = TResult | ((prev: TPrevious) => TResult);
|
|
27
|
+
export type PickExtract<T, U> = {
|
|
28
|
+
[K in keyof T as T[K] extends U ? K : never]: T[K];
|
|
29
|
+
};
|
|
30
|
+
export type PickExclude<T, U> = {
|
|
31
|
+
[K in keyof T as T[K] extends U ? never : K]: T[K];
|
|
32
|
+
};
|
|
33
|
+
export declare function last<T>(arr: T[]): T | undefined;
|
|
34
|
+
export declare function functionalUpdate<TResult>(updater: Updater<TResult> | NonNullableUpdater<TResult>, previous: TResult): TResult;
|
|
35
|
+
export declare function pick<T, K extends keyof T>(parent: T, keys: K[]): Pick<T, K>;
|
|
36
|
+
/**
|
|
37
|
+
* This function returns `a` if `b` is deeply equal.
|
|
38
|
+
* If not, it will replace any deeply equal children of `b` with those of `a`.
|
|
39
|
+
* This can be used for structural sharing between immutable JSON values for example.
|
|
40
|
+
* Do not use this with signals
|
|
41
|
+
*/
|
|
42
|
+
export declare function replaceEqualDeep<T>(prev: any, _next: T): T;
|
|
43
|
+
export declare function isPlainObject(o: any): boolean;
|
|
44
|
+
export declare function partialDeepEqual(a: any, b: any): boolean;
|