@tanstack/router-core 0.0.1-beta.26 → 0.0.1-beta.29
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/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -2
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/build/cjs/{packages/router-core/src/index.js → index.js} +22 -6
- 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} +4 -28
- package/build/cjs/path.js.map +1 -0
- package/build/cjs/{packages/router-core/src/qss.js → qss.js} +8 -13
- package/build/cjs/qss.js.map +1 -0
- package/build/cjs/{packages/router-core/src/route.js → route.js} +7 -16
- package/build/cjs/route.js.map +1 -0
- package/build/cjs/{packages/router-core/src/routeConfig.js → routeConfig.js} +10 -12
- package/build/cjs/routeConfig.js.map +1 -0
- package/build/cjs/{packages/router-core/src/routeMatch.js → routeMatch.js} +15 -35
- package/build/cjs/routeMatch.js.map +1 -0
- package/build/cjs/{packages/router-core/src/router.js → router.js} +103 -159
- package/build/cjs/router.js.map +1 -0
- package/build/cjs/{packages/router-core/src/searchParams.js → searchParams.js} +7 -10
- package/build/cjs/searchParams.js.map +1 -0
- package/build/cjs/{packages/router-core/src/utils.js → utils.js} +10 -24
- package/build/cjs/utils.js.map +1 -0
- package/build/esm/index.js +150 -1112
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +59 -49
- package/build/stats-react.json +155 -155
- package/build/types/index.d.ts +34 -20
- package/build/umd/index.development.js +145 -290
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/route.ts +8 -5
- package/src/routeConfig.ts +6 -10
- package/src/routeMatch.ts +1 -1
- package/src/router.ts +114 -51
- 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/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.map +0 -1
- package/build/cjs/packages/router-core/src/routeConfig.js.map +0 -1
- package/build/cjs/packages/router-core/src/routeMatch.js.map +0 -1
- 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/build/types/index.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ interface RouteMatch<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo
|
|
|
66
66
|
invalidate: () => void;
|
|
67
67
|
hasLoaders: () => boolean;
|
|
68
68
|
}
|
|
69
|
-
declare function createRouteMatch<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo>(router: Router<any, any>, route: Route<TAllRouteInfo, TRouteInfo>, opts: {
|
|
69
|
+
declare function createRouteMatch<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo>(router: Router<any, any, any>, route: Route<TAllRouteInfo, TRouteInfo>, opts: {
|
|
70
70
|
parentMatch?: RouteMatch<any, any>;
|
|
71
71
|
matchId: string;
|
|
72
72
|
params: TRouteInfo['allParams'];
|
|
@@ -115,6 +115,14 @@ declare function warning(cond: any, message: string): cond is true;
|
|
|
115
115
|
declare function functionalUpdate<TResult>(updater: Updater<TResult>, previous: TResult): TResult;
|
|
116
116
|
declare function pick<T, K extends keyof T>(parent: T, keys: K[]): Pick<T, K>;
|
|
117
117
|
|
|
118
|
+
interface RegisterRouter {
|
|
119
|
+
}
|
|
120
|
+
type RegisteredRouter = RegisterRouter extends {
|
|
121
|
+
router: Router<infer TRouteConfig, infer TAllRouteInfo, infer TRouterContext>;
|
|
122
|
+
} ? Router<TRouteConfig, TAllRouteInfo, TRouterContext> : Router;
|
|
123
|
+
type RegisteredAllRouteInfo = RegisterRouter extends {
|
|
124
|
+
router: Router<infer TRouteConfig, infer TAllRouteInfo, infer TRouterContext>;
|
|
125
|
+
} ? TAllRouteInfo : AnyAllRouteInfo;
|
|
118
126
|
interface LocationState {
|
|
119
127
|
}
|
|
120
128
|
interface Location<TSearchObj extends AnySearchSchema = {}, TState extends LocationState = LocationState> {
|
|
@@ -135,7 +143,7 @@ interface FromLocation {
|
|
|
135
143
|
type SearchSerializer = (searchObj: Record<string, any>) => string;
|
|
136
144
|
type SearchParser = (searchStr: string) => Record<string, any>;
|
|
137
145
|
type FilterRoutesFn = <TRoute extends Route<any, RouteInfo>>(routeConfigs: TRoute[]) => TRoute[];
|
|
138
|
-
interface RouterOptions<TRouteConfig extends AnyRouteConfig> {
|
|
146
|
+
interface RouterOptions<TRouteConfig extends AnyRouteConfig, TRouterContext> {
|
|
139
147
|
history?: BrowserHistory | MemoryHistory | HashHistory;
|
|
140
148
|
stringifySearch?: SearchSerializer;
|
|
141
149
|
parseSearch?: SearchParser;
|
|
@@ -153,11 +161,12 @@ interface RouterOptions<TRouteConfig extends AnyRouteConfig> {
|
|
|
153
161
|
routeConfig?: TRouteConfig;
|
|
154
162
|
basepath?: string;
|
|
155
163
|
useServerData?: boolean;
|
|
156
|
-
createRouter?: (router: Router<any, any>) => void;
|
|
164
|
+
createRouter?: (router: Router<any, any, any>) => void;
|
|
157
165
|
createRoute?: (opts: {
|
|
158
166
|
route: AnyRoute;
|
|
159
|
-
router: Router<any, any>;
|
|
167
|
+
router: Router<any, any, any>;
|
|
160
168
|
}) => void;
|
|
169
|
+
context?: TRouterContext;
|
|
161
170
|
loadComponent?: (component: GetFrameworkGeneric<'Component'>) => Promise<GetFrameworkGeneric<'Component'>>;
|
|
162
171
|
}
|
|
163
172
|
interface Action<TPayload = unknown, TResponse = unknown> {
|
|
@@ -215,7 +224,7 @@ interface PendingState {
|
|
|
215
224
|
location: Location;
|
|
216
225
|
matches: RouteMatch[];
|
|
217
226
|
}
|
|
218
|
-
type Listener = (router: Router<any, any>) => void;
|
|
227
|
+
type Listener = (router: Router<any, any, any>) => void;
|
|
219
228
|
type ListenerFn = () => void;
|
|
220
229
|
interface BuildNextOptions {
|
|
221
230
|
to?: string | number | null;
|
|
@@ -244,22 +253,26 @@ interface MatchRouteOptions {
|
|
|
244
253
|
pending: boolean;
|
|
245
254
|
caseSensitive?: boolean;
|
|
246
255
|
}
|
|
247
|
-
interface DehydratedRouterState extends Pick<RouterState, 'status' | 'location' | 'lastUpdated'> {
|
|
256
|
+
interface DehydratedRouterState extends Pick<RouterState, 'status' | 'location' | 'lastUpdated' | 'location'> {
|
|
248
257
|
matches: DehydratedRouteMatch[];
|
|
249
258
|
}
|
|
259
|
+
interface DehydratedRouter<TRouterContext = unknown> {
|
|
260
|
+
location: Router['location'];
|
|
261
|
+
state: DehydratedRouterState;
|
|
262
|
+
context: TRouterContext;
|
|
263
|
+
}
|
|
250
264
|
interface DehydratedRouteMatch extends Pick<RouteMatch<any, any>, 'matchId' | 'status' | 'routeLoaderData' | 'loaderData' | 'isInvalid' | 'invalidAt'> {
|
|
251
265
|
}
|
|
252
266
|
interface RouterContext {
|
|
253
267
|
}
|
|
254
|
-
interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig
|
|
268
|
+
interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>, TRouterContext = unknown> {
|
|
255
269
|
types: {
|
|
256
270
|
RouteConfig: TRouteConfig;
|
|
257
271
|
AllRouteInfo: TAllRouteInfo;
|
|
258
272
|
};
|
|
259
273
|
history: BrowserHistory | MemoryHistory | HashHistory;
|
|
260
|
-
options: PickAsRequired<RouterOptions<TRouteConfig>, 'stringifySearch' | 'parseSearch'>;
|
|
274
|
+
options: PickAsRequired<RouterOptions<TRouteConfig, TRouterContext>, 'stringifySearch' | 'parseSearch' | 'context'>;
|
|
261
275
|
basepath: string;
|
|
262
|
-
context: RouterContext;
|
|
263
276
|
listeners: Listener[];
|
|
264
277
|
location: Location<TAllRouteInfo['fullSearchSchema']>;
|
|
265
278
|
navigateTimeout?: Timeout;
|
|
@@ -267,7 +280,7 @@ interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInf
|
|
|
267
280
|
state: RouterState<TAllRouteInfo['fullSearchSchema']>;
|
|
268
281
|
routeTree: Route<TAllRouteInfo, RouteInfo>;
|
|
269
282
|
routesById: RoutesById<TAllRouteInfo>;
|
|
270
|
-
navigationPromise
|
|
283
|
+
navigationPromise?: Promise<void>;
|
|
271
284
|
startedLoadingAt: number;
|
|
272
285
|
resolveNavigation: () => void;
|
|
273
286
|
subscribe: (listener: Listener) => () => void;
|
|
@@ -275,7 +288,7 @@ interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInf
|
|
|
275
288
|
notify: () => void;
|
|
276
289
|
mount: () => () => void;
|
|
277
290
|
onFocus: () => void;
|
|
278
|
-
update: <TRouteConfig extends RouteConfig = RouteConfig>(opts?: RouterOptions<TRouteConfig>) => Router<TRouteConfig>;
|
|
291
|
+
update: <TRouteConfig extends RouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>, TRouterContext = unknown>(opts?: RouterOptions<TRouteConfig, TRouterContext>) => Router<TRouteConfig, TAllRouteInfo, TRouterContext>;
|
|
279
292
|
buildNext: (opts: BuildNextOptions) => Location;
|
|
280
293
|
cancelMatches: () => void;
|
|
281
294
|
load: (next?: Location) => Promise<void>;
|
|
@@ -306,8 +319,8 @@ interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInf
|
|
|
306
319
|
navigate: <TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'>(opts: NavigateOptionsAbsolute<TAllRouteInfo, TFrom, TTo>) => Promise<void>;
|
|
307
320
|
matchRoute: <TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'>(matchLocation: ToOptions<TAllRouteInfo, TFrom, TTo>, opts?: MatchRouteOptions) => boolean;
|
|
308
321
|
buildLink: <TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'>(opts: LinkOptions<TAllRouteInfo, TFrom, TTo>) => LinkInfo;
|
|
309
|
-
|
|
310
|
-
|
|
322
|
+
dehydrate: () => DehydratedRouter<TRouterContext>;
|
|
323
|
+
hydrate: (dehydratedRouter: DehydratedRouter<TRouterContext>) => void;
|
|
311
324
|
__: {
|
|
312
325
|
buildRouteTree: (routeConfig: RouteConfig) => Route<TAllRouteInfo, AnyRouteInfo>;
|
|
313
326
|
parseLocation: (location: History['location'], previousLocation?: Location) => Location;
|
|
@@ -318,11 +331,11 @@ interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInf
|
|
|
318
331
|
}) => Promise<void>;
|
|
319
332
|
};
|
|
320
333
|
}
|
|
321
|
-
declare function createRouter<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig
|
|
334
|
+
declare function createRouter<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>, TRouterContext = unknown>(userOptions?: RouterOptions<TRouteConfig, TRouterContext>): Router<TRouteConfig, TAllRouteInfo, TRouterContext>;
|
|
322
335
|
|
|
323
|
-
interface AnyRoute extends Route<any, any> {
|
|
336
|
+
interface AnyRoute extends Route<any, any, any> {
|
|
324
337
|
}
|
|
325
|
-
interface Route<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo> {
|
|
338
|
+
interface Route<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo, TRouterContext = unknown> {
|
|
326
339
|
routeInfo: TRouteInfo;
|
|
327
340
|
routeId: TRouteInfo['id'];
|
|
328
341
|
routeRouteId: TRouteInfo['routeId'];
|
|
@@ -331,14 +344,14 @@ interface Route<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRo
|
|
|
331
344
|
parentRoute?: AnyRoute;
|
|
332
345
|
childRoutes?: AnyRoute[];
|
|
333
346
|
options: RouteOptions;
|
|
334
|
-
router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo>;
|
|
347
|
+
router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo, TRouterContext>;
|
|
335
348
|
buildLink: <TTo extends string = '.'>(options: Omit<LinkOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>, 'from'>) => LinkInfo;
|
|
336
349
|
matchRoute: <TTo extends string = '.', TResolved extends string = ResolveRelativePath<TRouteInfo['id'], TTo>>(matchLocation: CheckRelativePath<TAllRouteInfo, TRouteInfo['fullPath'], NoInfer<TTo>> & Omit<ToOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>, 'from'>, opts?: MatchRouteOptions) => RouteInfoByPath<TAllRouteInfo, TResolved>['allParams'];
|
|
337
350
|
navigate: <TTo extends string = '.'>(options: Omit<LinkOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>, 'from'>) => Promise<void>;
|
|
338
351
|
action: unknown extends TRouteInfo['actionResponse'] ? Action<TRouteInfo['actionPayload'], TRouteInfo['actionResponse']> | undefined : Action<TRouteInfo['actionPayload'], TRouteInfo['actionResponse']>;
|
|
339
352
|
loader: unknown extends TRouteInfo['routeLoaderData'] ? Action<LoaderContext<TRouteInfo['fullSearchSchema'], TRouteInfo['allParams']>, TRouteInfo['routeLoaderData']> | undefined : Loader<TRouteInfo['fullSearchSchema'], TRouteInfo['allParams'], TRouteInfo['routeLoaderData']>;
|
|
340
353
|
}
|
|
341
|
-
declare function createRoute<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo>(routeConfig: RouteConfig, options: TRouteInfo['options'], parent: undefined | Route<TAllRouteInfo, any>, router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo>): Route<TAllRouteInfo, TRouteInfo>;
|
|
354
|
+
declare function createRoute<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo, TRouterContext = unknown>(routeConfig: RouteConfig, options: TRouteInfo['options'], parent: undefined | Route<TAllRouteInfo, any>, router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo, TRouterContext>): Route<TAllRouteInfo, TRouteInfo, TRouterContext>;
|
|
342
355
|
|
|
343
356
|
interface AnyAllRouteInfo {
|
|
344
357
|
routeConfig: AnyRouteConfig;
|
|
@@ -455,7 +468,8 @@ type RouteOptions<TRouteId extends string = string, TPath extends string = strin
|
|
|
455
468
|
loaderGcMaxAge?: number;
|
|
456
469
|
action?: ActionFn<TActionPayload, TActionResponse>;
|
|
457
470
|
beforeLoad?: (opts: {
|
|
458
|
-
|
|
471
|
+
router: Router<any, any, unknown>;
|
|
472
|
+
match: RouteMatch;
|
|
459
473
|
}) => Promise<void> | void;
|
|
460
474
|
onLoaded?: (matchContext: {
|
|
461
475
|
params: TAllParams;
|
|
@@ -617,4 +631,4 @@ declare const defaultStringifySearch: (search: Record<string, any>) => string;
|
|
|
617
631
|
declare function parseSearchWith(parser: (str: string) => any): (searchStr: string) => AnySearchSchema;
|
|
618
632
|
declare function stringifySearchWith(stringify: (search: any) => string): (search: Record<string, any>) => string;
|
|
619
633
|
|
|
620
|
-
export { Action, ActionFn, ActionState, AllRouteInfo, AnyAllRouteInfo, AnyLoaderData, AnyPathParams, AnyRoute, AnyRouteConfig, AnyRouteConfigWithChildren, AnyRouteInfo, AnySearchSchema, BuildNextOptions, CheckId, CheckIdError, CheckPath, CheckPathError, CheckRelativePath, DeepAwaited, DefaultAllRouteInfo, DefinedPathParamWarning, Expand, FilterRoutesFn, FrameworkGenerics, FromLocation, GetFrameworkGeneric, IsAny, IsAnyBoolean, IsKnown, LinkInfo, LinkOptions, ListenerFn, Loader, LoaderContext, LoaderFn, LoaderState, Location, LocationState, MatchCacheEntry, MatchLocation, MatchRouteOptions, NavigateOptionsAbsolute, NoInfer, ParentParams, ParsePathParams, ParseRouteConfig, PathParamMask, PendingState, PickAsPartial, PickAsRequired, PickExclude, PickExtra, PickExtract, PickRequired, PickUnsafe, RelativeToPathAutoComplete, ResolveRelativePath, RootRouteId, Route, RouteConfig, RouteConfigRoute, RouteInfo, RouteInfoById, RouteInfoByPath, RouteMatch, RouteMeta, RouteOptions, Router, RouterContext, RouterOptions, RouterState, RoutesById, RoutesInfoInner, SearchFilter, SearchParser, SearchSchemaValidator, SearchSchemaValidatorFn, SearchSchemaValidatorObj, SearchSerializer, Segment, Split, Timeout, ToIdOption, ToOptions, ToPathOption, UnionToIntersection, UnloaderFn, Updater, ValidFromPath, ValueKeys, Values, cleanPath, createRoute, createRouteConfig, createRouteMatch, createRouter, decode, defaultParseSearch, defaultStringifySearch, encode, functionalUpdate, interpolatePath, joinPaths, last, matchByPath, matchPathname, parsePathname, parseSearchWith, pick, replaceEqualDeep, resolvePath, rootRouteId, stringifySearchWith, trimPath, trimPathLeft, trimPathRight, warning };
|
|
634
|
+
export { Action, ActionFn, ActionState, AllRouteInfo, AnyAllRouteInfo, AnyLoaderData, AnyPathParams, AnyRoute, AnyRouteConfig, AnyRouteConfigWithChildren, AnyRouteInfo, AnySearchSchema, BuildNextOptions, CheckId, CheckIdError, CheckPath, CheckPathError, CheckRelativePath, DeepAwaited, DefaultAllRouteInfo, DefinedPathParamWarning, DehydratedRouter, DehydratedRouterState, Expand, FilterRoutesFn, FrameworkGenerics, FromLocation, GetFrameworkGeneric, IsAny, IsAnyBoolean, IsKnown, LinkInfo, LinkOptions, ListenerFn, Loader, LoaderContext, LoaderFn, LoaderState, Location, LocationState, MatchCacheEntry, MatchLocation, MatchRouteOptions, NavigateOptionsAbsolute, NoInfer, ParentParams, ParsePathParams, ParseRouteConfig, PathParamMask, PendingState, PickAsPartial, PickAsRequired, PickExclude, PickExtra, PickExtract, PickRequired, PickUnsafe, RegisterRouter, RegisteredAllRouteInfo, RegisteredRouter, RelativeToPathAutoComplete, ResolveRelativePath, RootRouteId, Route, RouteConfig, RouteConfigRoute, RouteInfo, RouteInfoById, RouteInfoByPath, RouteMatch, RouteMeta, RouteOptions, Router, RouterContext, RouterOptions, RouterState, RoutesById, RoutesInfoInner, SearchFilter, SearchParser, SearchSchemaValidator, SearchSchemaValidatorFn, SearchSchemaValidatorObj, SearchSerializer, Segment, Split, Timeout, ToIdOption, ToOptions, ToPathOption, UnionToIntersection, UnloaderFn, Updater, ValidFromPath, ValueKeys, Values, cleanPath, createRoute, createRouteConfig, createRouteMatch, createRouter, decode, defaultParseSearch, defaultStringifySearch, encode, functionalUpdate, interpolatePath, joinPaths, last, matchByPath, matchPathname, parsePathname, parseSearchWith, pick, replaceEqualDeep, resolvePath, rootRouteId, stringifySearchWith, trimPath, trimPathLeft, trimPathRight, warning };
|