@tanstack/router-core 0.0.1-beta.145 → 0.0.1-beta.147
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/fileRoute.js +29 -0
- package/build/cjs/fileRoute.js.map +1 -0
- package/build/cjs/index.js +2 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/route.js +0 -44
- package/build/cjs/route.js.map +1 -1
- package/build/esm/index.js +11 -44
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +139 -107
- package/build/types/index.d.ts +47 -3
- package/build/umd/index.development.js +11 -43
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +3 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/fileRoute.ts +122 -0
- package/src/index.ts +1 -0
- package/src/link.ts +3 -1
- package/src/route.ts +12 -48
package/build/types/index.d.ts
CHANGED
|
@@ -406,7 +406,9 @@ type UpdatableRouteOptions<TLoader, TSearchSchema extends AnySearchSchema, TFull
|
|
|
406
406
|
caseSensitive?: boolean;
|
|
407
407
|
wrapInSuspense?: boolean;
|
|
408
408
|
component?: RegisteredRouteComponent<RouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TContext>>;
|
|
409
|
-
errorComponent?:
|
|
409
|
+
errorComponent?: RegisteredRouteErrorComponent<{
|
|
410
|
+
error: unknown;
|
|
411
|
+
} & Partial<RouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TContext>>>;
|
|
410
412
|
pendingComponent?: RegisteredRouteComponent<RouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TContext>>;
|
|
411
413
|
preSearchFilters?: SearchFilter<TFullSearchSchema>[];
|
|
412
414
|
postSearchFilters?: SearchFilter<TFullSearchSchema>[];
|
|
@@ -541,7 +543,7 @@ declare class RouterContext<TRouterContext extends {}> {
|
|
|
541
543
|
createRootRoute: <TLoader = unknown, TSearchSchema extends AnySearchSchema = {}, TContext extends RouteContext = RouteContext>(options?: Omit<RouteOptions<AnyRoute, "__root__", "", {}, TSearchSchema, {}, {}, AnyPathParams, Record<never, string>, Record<never, string>, AnyContext, AnyContext, RouteContext, RouteContext>, "caseSensitive" | "path" | "getParentRoute" | "stringifyParams" | "parseParams" | "id"> | undefined) => RootRoute<TLoader, TSearchSchema, TContext, TRouterContext>;
|
|
542
544
|
}
|
|
543
545
|
declare class RootRoute<TLoader = unknown, TSearchSchema extends AnySearchSchema = {}, TContext extends RouteContext = RouteContext, TRouterContext extends {} = {}> extends Route<any, '/', '/', string, RootRouteId, TLoader, TSearchSchema, TSearchSchema, {}, {}, TRouterContext, TRouterContext, MergeParamsFromParent<TRouterContext, TContext>, MergeParamsFromParent<TRouterContext, TContext>, TRouterContext, any, any> {
|
|
544
|
-
constructor(options?: Omit<RouteOptions<AnyRoute, RootRouteId, '',
|
|
546
|
+
constructor(options?: Omit<RouteOptions<AnyRoute, RootRouteId, '', TLoader, TSearchSchema, {}, {}>, 'path' | 'id' | 'getParentRoute' | 'caseSensitive' | 'parseParams' | 'stringifyParams'>);
|
|
545
547
|
}
|
|
546
548
|
type ResolveFullPath<TParentRoute extends AnyRoute, TPath extends string, TPrefixed extends RoutePrefix<TParentRoute['fullPath'], TPath> = RoutePrefix<TParentRoute['fullPath'], TPath>> = TPrefixed extends RootRouteId ? '/' : TPrefixed;
|
|
547
549
|
type RoutePrefix<TPrefix extends string, TPath extends string> = string extends TPath ? RootRouteId : TPath extends string ? TPrefix extends RootRouteId ? TPath extends '/' ? '/' : `/${TrimPath<TPath>}` : `${TPrefix}/${TPath}` extends '/' ? '/' : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TPath>}`>}` : never;
|
|
@@ -645,6 +647,7 @@ type CleanPath<T extends string> = T extends `${infer L}//${infer R}` ? CleanPat
|
|
|
645
647
|
type Split<S, TIncludeTrailingSlash = true> = S extends unknown ? string extends S ? string[] : S extends string ? CleanPath<S> extends '' ? [] : TIncludeTrailingSlash extends true ? CleanPath<S> extends `${infer T}/` ? [...Split<T>, '/'] : CleanPath<S> extends `/${infer U}` ? Split<U> : CleanPath<S> extends `${infer T}/${infer U}` ? [...Split<T>, ...Split<U>] : [S] : CleanPath<S> extends `${infer T}/${infer U}` ? [...Split<T>, ...Split<U>] : S extends string ? [S] : never : never : never;
|
|
646
648
|
type ParsePathParams<T extends string> = Split<T>[number] extends infer U ? U extends `$${infer V}` ? V : never : never;
|
|
647
649
|
type Join<T, Delimiter extends string = '/'> = T extends [] ? '' : T extends [infer L extends string] ? L : T extends [infer L extends string, ...infer Tail extends [...string[]]] ? CleanPath<`${L}${Delimiter}${Join<Tail>}`> : never;
|
|
650
|
+
type Last<T extends any[]> = T extends [...infer _, infer L] ? L : never;
|
|
648
651
|
type RelativeToPathAutoComplete<AllPaths extends string, TFrom extends string, TTo extends string, SplitPaths extends string[] = Split<AllPaths, false>> = TTo extends `..${infer _}` ? SplitPaths extends [
|
|
649
652
|
...Split<ResolveRelativePath<TFrom, TTo>, false>,
|
|
650
653
|
...infer TToRest
|
|
@@ -728,9 +731,50 @@ declare function matchByPath(basepath: string, from: string, matchLocation: Pick
|
|
|
728
731
|
declare function encode(obj: any, pfx?: string): string;
|
|
729
732
|
declare function decode(str: any): {};
|
|
730
733
|
|
|
734
|
+
interface FileRoutesByPath {
|
|
735
|
+
}
|
|
736
|
+
declare class FileRoute<TFilePath extends keyof FileRoutesByPath, TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'], TPath extends string = Last<Split<TFilePath>>, TCustomId extends string = TPath extends `_${infer T}` ? T : string> {
|
|
737
|
+
path: TFilePath;
|
|
738
|
+
constructor(path: TFilePath);
|
|
739
|
+
createRoute: <TFullPath extends ResolveFullPath<TParentRoute, TPath, string extends TPath ? "__root__" : TPath extends string ? TParentRoute["fullPath"] extends infer T ? T extends TParentRoute["fullPath"] ? T extends "__root__" ? TPath extends "/" ? "/" : `/${TrimPath<TPath>}` : `${T}/${TPath}` extends "/" ? "/" : `/${TrimPathLeft<`${TrimPathRight<T>}/${TrimPath<TPath>}`>}` : never : never : never> = ResolveFullPath<TParentRoute, TPath, string extends TPath ? "__root__" : TPath extends string ? TParentRoute["fullPath"] extends infer T ? T extends TParentRoute["fullPath"] ? T extends "__root__" ? TPath extends "/" ? "/" : `/${TrimPath<TPath>}` : `${T}/${TPath}` extends "/" ? "/" : `/${TrimPathLeft<`${TrimPathRight<T>}/${TrimPath<TPath>}`>}` : never : never : never>, TId extends ResolveId<TParentRoute, TCustomId, TPath> = ResolveId<TParentRoute, TCustomId, TPath>, TLoader = unknown, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends Record<ParsePathParams<TPath>, any> = Record<ParsePathParams<TPath>, string>, TAllParams extends IsAny<TParentRoute["__types"]["allParams"], TParams, TParentRoute["__types"]["allParams"] & TParams> = IsAny<TParentRoute["__types"]["allParams"], TParams, TParentRoute["__types"]["allParams"] & TParams>, TParentContext extends TParentRoute["__types"]["routeContext"] = TParentRoute["__types"]["routeContext"], TAllParentContext extends TParentRoute["__types"]["context"] = TParentRoute["__types"]["context"], TRouteContext extends RouteContext = RouteContext, TContext extends IsAny<TParentRoute["__types"]["context"], TRouteContext, TParentRoute["__types"]["context"] & TRouteContext> = IsAny<TParentRoute["__types"]["context"], TRouteContext, TParentRoute["__types"]["context"] & TRouteContext>, TRouterContext extends AnyContext = AnyContext, TChildren extends unknown = unknown, TRoutesInfo extends DefaultRoutesInfo = DefaultRoutesInfo>(options: Omit<RouteOptions<TParentRoute, TCustomId, TPath, TLoader, InferFullSearchSchema<TParentRoute>, TSearchSchema, TFullSearchSchema, TParentRoute["__types"]["allParams"], TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext>, "path" | "getParentRoute" | "id"> & {
|
|
740
|
+
meta?: RouteMeta | undefined;
|
|
741
|
+
} & {
|
|
742
|
+
key?: false | GetKeyFn<TFullSearchSchema, TAllParams> | null | undefined;
|
|
743
|
+
caseSensitive?: boolean | undefined;
|
|
744
|
+
wrapInSuspense?: boolean | undefined;
|
|
745
|
+
component?: ((props: RouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TContext>) => unknown) | undefined;
|
|
746
|
+
errorComponent?: ((props: {
|
|
747
|
+
error: unknown;
|
|
748
|
+
} & Partial<RouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TContext>>) => unknown) | undefined;
|
|
749
|
+
pendingComponent?: ((props: RouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TContext>) => unknown) | undefined;
|
|
750
|
+
preSearchFilters?: SearchFilter<TFullSearchSchema, TFullSearchSchema>[] | undefined;
|
|
751
|
+
postSearchFilters?: SearchFilter<TFullSearchSchema, TFullSearchSchema>[] | undefined;
|
|
752
|
+
preloadMaxAge?: number | undefined;
|
|
753
|
+
maxAge?: number | undefined;
|
|
754
|
+
gcMaxAge?: number | undefined;
|
|
755
|
+
beforeLoad?: ((opts: LoaderContext<TSearchSchema, TFullSearchSchema, TAllParams, NoInfer<TRouteContext>, TContext>) => void | Promise<void>) | undefined;
|
|
756
|
+
onBeforeLoadError?: ((err: any) => void) | undefined;
|
|
757
|
+
onValidateSearchError?: ((err: any) => void) | undefined;
|
|
758
|
+
onParseParamsError?: ((err: any) => void) | undefined;
|
|
759
|
+
onLoadError?: ((err: any) => void) | undefined;
|
|
760
|
+
onError?: ((err: any) => void) | undefined;
|
|
761
|
+
onLoaded?: ((matchContext: {
|
|
762
|
+
params: TAllParams;
|
|
763
|
+
search: TFullSearchSchema;
|
|
764
|
+
}) => void | ((match: {
|
|
765
|
+
params: TAllParams;
|
|
766
|
+
search: TFullSearchSchema;
|
|
767
|
+
}) => void) | undefined) | undefined;
|
|
768
|
+
onTransition?: ((match: {
|
|
769
|
+
params: TAllParams;
|
|
770
|
+
search: TFullSearchSchema;
|
|
771
|
+
}) => void) | undefined;
|
|
772
|
+
}) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TLoader, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext, TRouterContext, TChildren, TRoutesInfo>;
|
|
773
|
+
}
|
|
774
|
+
|
|
731
775
|
declare const defaultParseSearch: (searchStr: string) => AnySearchSchema;
|
|
732
776
|
declare const defaultStringifySearch: (search: Record<string, any>) => string;
|
|
733
777
|
declare function parseSearchWith(parser: (str: string) => any): (searchStr: string) => AnySearchSchema;
|
|
734
778
|
declare function stringifySearchWith(stringify: (search: any) => string): (search: Record<string, any>) => string;
|
|
735
779
|
|
|
736
|
-
export { ActiveOptions, AnyContext, AnyPathParams, AnyRedirect, AnyRootRoute, AnyRoute, AnyRouteMatch, AnyRouteProps, AnyRouteWithRouterContext, AnyRouter, AnyRoutesInfo, AnySearchSchema, BaseRouteOptions, BuildNextOptions, CheckId, CheckIdError, CheckPath, CheckPathError, CheckRelativePath, ComponentFromRoute, ComponentPropsFromRoute, DeepAwaited, DefaultRoutesInfo, DefinedPathParamWarning, DehydratedRouter, DehydratedRouterState, Expand, FromLocation, GetKeyFn, HydrationCtx, InferFullSearchSchema, IsAny, IsAnyBoolean, IsKnown, LinkInfo, LinkOptions, ListenerFn, LoaderContext, LoaderFn, LocationState, MatchLocation, MatchRouteOptions, MergeParamsFromParent, MergeUnion, MetaOptions, NavigateOptions, NoInfer, ParamsFallback, ParentParams, ParseParamsFn, ParseParamsObj, ParseParamsOption, ParsePathParams, ParseRoute, ParseRouteChild, ParseRouteChildren, ParsedLocation, ParsedPath, PathParamError, PathParamMask, PathParamOptions, PickAsPartial, PickAsRequired, PickExclude, PickExtra, PickExtract, PickRequired, PickUnsafe, PreloadableObj, Redirect, Register, RegisterRouteComponent, RegisterRouteErrorComponent, RegisteredRouteComponent, RegisteredRouteErrorComponent, RegisteredRouter, RegisteredRouterPair, RegisteredRoutesInfo, RelativeToPathAutoComplete, ResolveFullPath, ResolveFullSearchSchema, ResolveId, ResolveRelativePath, RootRoute, RootRouteId, Route, RouteById, RouteByPath, RouteContext, RouteLoaderFromRoute, RouteMatch, RouteMeta, RouteOptions, RoutePathOptions, RoutePathOptionsIntersection, RouteProps, Router, RouterConstructorOptions, RouterContext, RouterContextOptions, RouterHistory, RouterLocation, RouterOptions, RouterState, RoutesById, RoutesByPath, RoutesInfo, RoutesInfoInner, SearchFilter, SearchParamError, SearchParamOptions, SearchParser, SearchSchemaValidator, SearchSchemaValidatorFn, SearchSchemaValidatorObj, SearchSerializer, Segment, Split, StreamedPromise, Timeout, ToIdOption, ToOptions, ToPathOption, TrimPath, TrimPathLeft, TrimPathRight, UnionToIntersection, UnloaderFn, UpdatableRouteOptions, Updater, UseLoaderResult, UseLoaderResultPromise, ValueKeys, Values, cleanPath, componentTypes, createBrowserHistory, createHashHistory, createMemoryHistory, decode, defaultParseSearch, defaultStringifySearch, encode, functionalUpdate, interpolatePath, isPlainObject, isRedirect, joinPaths, last, lazyFn, matchByPath, matchPathname, parsePathname, parseSearchWith, partialDeepEqual, pick, redirect, replaceEqualDeep, resolvePath, rootRouteId, stringifySearchWith, trimPath, trimPathLeft, trimPathRight };
|
|
780
|
+
export { ActiveOptions, AnyContext, AnyPathParams, AnyRedirect, AnyRootRoute, AnyRoute, AnyRouteMatch, AnyRouteProps, AnyRouteWithRouterContext, AnyRouter, AnyRoutesInfo, AnySearchSchema, BaseRouteOptions, BuildNextOptions, CheckId, CheckIdError, CheckPath, CheckPathError, CheckRelativePath, ComponentFromRoute, ComponentPropsFromRoute, DeepAwaited, DefaultRoutesInfo, DefinedPathParamWarning, DehydratedRouter, DehydratedRouterState, Expand, FileRoute, FileRoutesByPath, FromLocation, GetKeyFn, HydrationCtx, InferFullSearchSchema, IsAny, IsAnyBoolean, IsKnown, Join, Last, LinkInfo, LinkOptions, ListenerFn, LoaderContext, LoaderFn, LocationState, MatchLocation, MatchRouteOptions, MergeParamsFromParent, MergeUnion, MetaOptions, NavigateOptions, NoInfer, ParamsFallback, ParentParams, ParseParamsFn, ParseParamsObj, ParseParamsOption, ParsePathParams, ParseRoute, ParseRouteChild, ParseRouteChildren, ParsedLocation, ParsedPath, PathParamError, PathParamMask, PathParamOptions, PickAsPartial, PickAsRequired, PickExclude, PickExtra, PickExtract, PickRequired, PickUnsafe, PreloadableObj, Redirect, Register, RegisterRouteComponent, RegisterRouteErrorComponent, RegisteredRouteComponent, RegisteredRouteErrorComponent, RegisteredRouter, RegisteredRouterPair, RegisteredRoutesInfo, RelativeToPathAutoComplete, ResolveFullPath, ResolveFullSearchSchema, ResolveId, ResolveRelativePath, RootRoute, RootRouteId, Route, RouteById, RouteByPath, RouteContext, RouteLoaderFromRoute, RouteMatch, RouteMeta, RouteOptions, RoutePathOptions, RoutePathOptionsIntersection, RouteProps, Router, RouterConstructorOptions, RouterContext, RouterContextOptions, RouterHistory, RouterLocation, RouterOptions, RouterState, RoutesById, RoutesByPath, RoutesInfo, RoutesInfoInner, SearchFilter, SearchParamError, SearchParamOptions, SearchParser, SearchSchemaValidator, SearchSchemaValidatorFn, SearchSchemaValidatorObj, SearchSerializer, Segment, Split, StreamedPromise, Timeout, ToIdOption, ToOptions, ToPathOption, TrimPath, TrimPathLeft, TrimPathRight, UnionToIntersection, UnloaderFn, UpdatableRouteOptions, Updater, UseLoaderResult, UseLoaderResultPromise, ValueKeys, Values, cleanPath, componentTypes, createBrowserHistory, createHashHistory, createMemoryHistory, decode, defaultParseSearch, defaultStringifySearch, encode, functionalUpdate, interpolatePath, isPlainObject, isRedirect, joinPaths, last, lazyFn, matchByPath, matchPathname, parsePathname, parseSearchWith, partialDeepEqual, pick, redirect, replaceEqualDeep, resolvePath, rootRouteId, stringifySearchWith, trimPath, trimPathLeft, trimPathRight };
|
|
@@ -653,49 +653,16 @@
|
|
|
653
653
|
}
|
|
654
654
|
}
|
|
655
655
|
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
// const bRoute = new Route({
|
|
667
|
-
// getParentRoute: () => aRoute,
|
|
668
|
-
// path: 'b',
|
|
669
|
-
// })
|
|
670
|
-
|
|
671
|
-
// const rootIsRoot = rootRoute.isRoot
|
|
672
|
-
// // ^?
|
|
673
|
-
// const aIsRoot = aRoute.isRoot
|
|
674
|
-
// // ^?
|
|
675
|
-
|
|
676
|
-
// const rId = rootRoute.id
|
|
677
|
-
// // ^?
|
|
678
|
-
// const aId = aRoute.id
|
|
679
|
-
// // ^?
|
|
680
|
-
// const bId = bRoute.id
|
|
681
|
-
// // ^?
|
|
682
|
-
|
|
683
|
-
// const rPath = rootRoute.fullPath
|
|
684
|
-
// // ^?
|
|
685
|
-
// const aPath = aRoute.fullPath
|
|
686
|
-
// // ^?
|
|
687
|
-
// const bPath = bRoute.fullPath
|
|
688
|
-
// // ^?
|
|
689
|
-
|
|
690
|
-
// const rSearch = rootRoute.__types.fullSearchSchema
|
|
691
|
-
// // ^?
|
|
692
|
-
// const aSearch = aRoute.__types.fullSearchSchema
|
|
693
|
-
// // ^?
|
|
694
|
-
// const bSearch = bRoute.__types.fullSearchSchema
|
|
695
|
-
// // ^?
|
|
696
|
-
|
|
697
|
-
// const config = rootRoute.addChildren([aRoute.addChildren([bRoute])])
|
|
698
|
-
// // ^?
|
|
656
|
+
class FileRoute {
|
|
657
|
+
constructor(path) {
|
|
658
|
+
this.path = path;
|
|
659
|
+
}
|
|
660
|
+
createRoute = options => {
|
|
661
|
+
const route = new Route(options);
|
|
662
|
+
route.isRoot = false;
|
|
663
|
+
return route;
|
|
664
|
+
};
|
|
665
|
+
}
|
|
699
666
|
|
|
700
667
|
/**
|
|
701
668
|
* @tanstack/store/src/index.ts
|
|
@@ -1879,6 +1846,7 @@
|
|
|
1879
1846
|
};
|
|
1880
1847
|
}
|
|
1881
1848
|
|
|
1849
|
+
exports.FileRoute = FileRoute;
|
|
1882
1850
|
exports.PathParamError = PathParamError;
|
|
1883
1851
|
exports.RootRoute = RootRoute;
|
|
1884
1852
|
exports.Route = Route;
|