@tanstack/router-core 0.0.1-beta.19 → 0.0.1-beta.190

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.
Files changed (82) hide show
  1. package/LICENSE +21 -0
  2. package/build/cjs/defer.js +39 -0
  3. package/build/cjs/defer.js.map +1 -0
  4. package/build/cjs/fileRoute.js +29 -0
  5. package/build/cjs/fileRoute.js.map +1 -0
  6. package/build/cjs/history.js +228 -0
  7. package/build/cjs/history.js.map +1 -0
  8. package/build/cjs/index.js +86 -0
  9. package/build/cjs/{packages/router-core/src/index.js.map → index.js.map} +1 -1
  10. package/build/cjs/{packages/router-core/src/path.js → path.js} +45 -56
  11. package/build/cjs/path.js.map +1 -0
  12. package/build/cjs/{packages/router-core/src/qss.js → qss.js} +10 -16
  13. package/build/cjs/qss.js.map +1 -0
  14. package/build/cjs/route.js +114 -0
  15. package/build/cjs/route.js.map +1 -0
  16. package/build/cjs/router.js +1267 -0
  17. package/build/cjs/router.js.map +1 -0
  18. package/build/cjs/scroll-restoration.js +139 -0
  19. package/build/cjs/scroll-restoration.js.map +1 -0
  20. package/build/cjs/{packages/router-core/src/searchParams.js → searchParams.js} +32 -19
  21. package/build/cjs/searchParams.js.map +1 -0
  22. package/build/cjs/{packages/router-core/src/utils.js → utils.js} +69 -64
  23. package/build/cjs/utils.js.map +1 -0
  24. package/build/esm/index.js +1746 -2121
  25. package/build/esm/index.js.map +1 -1
  26. package/build/stats-html.html +59 -49
  27. package/build/stats-react.json +197 -211
  28. package/build/types/defer.d.ts +19 -0
  29. package/build/types/fileRoute.d.ts +35 -0
  30. package/build/types/history.d.ts +36 -0
  31. package/build/types/index.d.ts +13 -609
  32. package/build/types/link.d.ts +96 -0
  33. package/build/types/path.d.ts +16 -0
  34. package/build/types/qss.d.ts +2 -0
  35. package/build/types/route.d.ts +251 -0
  36. package/build/types/routeInfo.d.ts +22 -0
  37. package/build/types/router.d.ts +260 -0
  38. package/build/types/scroll-restoration.d.ts +6 -0
  39. package/build/types/searchParams.d.ts +5 -0
  40. package/build/types/utils.d.ts +44 -0
  41. package/build/umd/index.development.js +1978 -2243
  42. package/build/umd/index.development.js.map +1 -1
  43. package/build/umd/index.production.js +13 -2
  44. package/build/umd/index.production.js.map +1 -1
  45. package/package.json +11 -7
  46. package/src/defer.ts +55 -0
  47. package/src/fileRoute.ts +161 -0
  48. package/src/history.ts +300 -0
  49. package/src/index.ts +5 -10
  50. package/src/link.ts +136 -125
  51. package/src/path.ts +37 -17
  52. package/src/qss.ts +1 -2
  53. package/src/route.ts +948 -218
  54. package/src/routeInfo.ts +45 -211
  55. package/src/router.ts +1778 -1075
  56. package/src/scroll-restoration.ts +179 -0
  57. package/src/searchParams.ts +31 -9
  58. package/src/utils.ts +84 -49
  59. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -33
  60. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
  61. package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js +0 -33
  62. package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js.map +0 -1
  63. package/build/cjs/node_modules/history/index.js +0 -815
  64. package/build/cjs/node_modules/history/index.js.map +0 -1
  65. package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js +0 -30
  66. package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js.map +0 -1
  67. package/build/cjs/packages/router-core/src/index.js +0 -58
  68. package/build/cjs/packages/router-core/src/path.js.map +0 -1
  69. package/build/cjs/packages/router-core/src/qss.js.map +0 -1
  70. package/build/cjs/packages/router-core/src/route.js +0 -147
  71. package/build/cjs/packages/router-core/src/route.js.map +0 -1
  72. package/build/cjs/packages/router-core/src/routeConfig.js +0 -69
  73. package/build/cjs/packages/router-core/src/routeConfig.js.map +0 -1
  74. package/build/cjs/packages/router-core/src/routeMatch.js +0 -220
  75. package/build/cjs/packages/router-core/src/routeMatch.js.map +0 -1
  76. package/build/cjs/packages/router-core/src/router.js +0 -870
  77. package/build/cjs/packages/router-core/src/router.js.map +0 -1
  78. package/build/cjs/packages/router-core/src/searchParams.js.map +0 -1
  79. package/build/cjs/packages/router-core/src/utils.js.map +0 -1
  80. package/src/frameworks.ts +0 -11
  81. package/src/routeConfig.ts +0 -511
  82. package/src/routeMatch.ts +0 -312
@@ -0,0 +1,19 @@
1
+ export type DeferredPromiseState<T> = {
2
+ uid: string;
3
+ } & ({
4
+ status: 'pending';
5
+ data?: T;
6
+ error?: unknown;
7
+ } | {
8
+ status: 'success';
9
+ data: T;
10
+ } | {
11
+ status: 'error';
12
+ data?: T;
13
+ error: unknown;
14
+ });
15
+ export type DeferredPromise<T> = Promise<T> & {
16
+ __deferredState: DeferredPromiseState<T>;
17
+ };
18
+ export declare function defer<T>(_promise: Promise<T>): DeferredPromise<T>;
19
+ export declare function isDehydratedDeferred(obj: any): boolean;
@@ -0,0 +1,35 @@
1
+ import { AnyRoute, ResolveFullPath, ResolveFullSearchSchema, RouteContext, AnyContext, RouteOptions, InferFullSearchSchema, UpdatableRouteOptions, Route, AnyPathParams, RootRouteId, TrimPathLeft, RouteConstraints } from './route';
2
+ export interface FileRoutesByPath {
3
+ }
4
+ type Replace<S extends string, From extends string, To extends string> = S extends `${infer Start}${From}${infer Rest}` ? `${Start}${To}${Replace<Rest, From, To>}` : S;
5
+ export type TrimLeft<T extends string, S extends string> = T extends `${S}${infer U}` ? U : T;
6
+ export type TrimRight<T extends string, S extends string> = T extends `${infer U}${S}` ? U : T;
7
+ export type Trim<T extends string, S extends string> = TrimLeft<TrimRight<T, S>, S>;
8
+ export type RemoveUnderScores<T extends string> = Replace<Replace<TrimRight<TrimLeft<T, '/_'>, '_'>, '_/', '/'>, '/_', '/'>;
9
+ export type ResolveFilePath<TParentRoute extends AnyRoute, TFilePath extends string> = TParentRoute['id'] extends RootRouteId ? TrimPathLeft<TFilePath> : Replace<TrimPathLeft<TFilePath>, TrimPathLeft<TParentRoute['types']['customId']>, ''>;
10
+ export type FileRoutePath<TParentRoute extends AnyRoute, TFilePath extends string> = ResolveFilePath<TParentRoute, TFilePath> extends `_${infer _}` ? string : ResolveFilePath<TParentRoute, TFilePath>;
11
+ export declare class FileRoute<TFilePath extends keyof FileRoutesByPath, TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'], TId extends RouteConstraints['TId'] = TFilePath, TPath extends RouteConstraints['TPath'] = FileRoutePath<TParentRoute, TFilePath>, TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, RemoveUnderScores<TPath>>> {
12
+ path: TFilePath;
13
+ constructor(path: TFilePath);
14
+ createRoute: <TLoader = unknown, TSearchSchema extends import("./route").AnySearchSchema = {}, TFullSearchSchema extends import("./route").AnySearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends Record<string, any> = (TrimLeft<TrimRight<import("./link").Split<TPath, true>[number], "_">, "_"> extends infer T ? T extends TrimLeft<TrimRight<import("./link").Split<TPath, true>[number], "_">, "_"> ? T extends `$${infer L}` ? L : never : never : never) extends never ? AnyPathParams : Record<TrimLeft<TrimRight<import("./link").Split<TPath, true>[number], "_">, "_"> extends infer T ? T extends TrimLeft<TrimRight<import("./link").Split<TPath, true>[number], "_">, "_"> ? T extends `$${infer L}` ? L : never : never : never, string>, TAllParams extends Record<string, any> = import("./utils").IsAny<TParentRoute["types"]["allParams"], TParams, TParentRoute["types"]["allParams"] & TParams>, TParentContext extends AnyContext = TParentRoute["types"]["routeContext"], TAllParentContext extends string = TParentRoute["types"]["context"], TRouteContext extends RouteContext = RouteContext, TContext extends AnyContext = import("./utils").IsAny<TParentRoute["types"]["context"], TRouteContext, TParentRoute["types"]["context"] & TRouteContext>, TRouterContext extends AnyContext = AnyContext, TChildren extends unknown = unknown, TRouteTree extends AnyRoute = AnyRoute>(options: Omit<RouteOptions<TParentRoute, string, string, TLoader, InferFullSearchSchema<TParentRoute>, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext>, "id" | "path" | "getParentRoute"> & {
15
+ meta?: import("./route").RouteMeta | undefined;
16
+ } & {
17
+ key?: false | import("./route").GetKeyFn<TFullSearchSchema, TAllParams> | null | undefined;
18
+ caseSensitive?: boolean | undefined;
19
+ wrapInSuspense?: boolean | undefined;
20
+ component?: (() => unknown) | undefined;
21
+ errorComponent?: (() => unknown) | undefined;
22
+ pendingComponent?: (() => unknown) | undefined;
23
+ preSearchFilters?: import("./route").SearchFilter<TFullSearchSchema, TFullSearchSchema>[] | undefined;
24
+ postSearchFilters?: import("./route").SearchFilter<TFullSearchSchema, TFullSearchSchema>[] | undefined;
25
+ preloadMaxAge?: number | undefined;
26
+ maxAge?: number | undefined;
27
+ gcMaxAge?: number | undefined;
28
+ onError?: ((err: any) => void) | undefined;
29
+ onEnter?: ((match: import("./router").AnyRouteMatch) => void) | undefined;
30
+ onTransition?: ((match: import("./router").AnyRouteMatch) => void) | undefined;
31
+ onLeave?: ((match: import("./router").AnyRouteMatch) => void) | undefined;
32
+ reloadOnWindowFocus?: boolean | undefined;
33
+ }) => Route<TParentRoute, TPath, TFullPath, TFilePath, TId, TLoader, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext, TRouterContext, TChildren, TRouteTree>;
34
+ }
35
+ export {};
@@ -0,0 +1,36 @@
1
+ export interface RouterHistory {
2
+ location: HistoryLocation;
3
+ subscribe: (cb: () => void) => () => void;
4
+ push: (path: string, state?: any) => void;
5
+ replace: (path: string, state?: any) => void;
6
+ go: (index: number) => void;
7
+ back: () => void;
8
+ forward: () => void;
9
+ createHref: (href: string) => string;
10
+ block: (blockerFn: BlockerFn) => () => void;
11
+ }
12
+ export interface HistoryLocation extends ParsedPath {
13
+ state: HistoryState;
14
+ }
15
+ export interface ParsedPath {
16
+ href: string;
17
+ pathname: string;
18
+ search: string;
19
+ hash: string;
20
+ }
21
+ export interface HistoryState {
22
+ key: string;
23
+ __tempLocation?: HistoryLocation;
24
+ __tempKey?: string;
25
+ }
26
+ type BlockerFn = (retry: () => void, cancel: () => void) => void;
27
+ export declare function createBrowserHistory(opts?: {
28
+ getHref?: () => string;
29
+ createHref?: (path: string) => string;
30
+ }): RouterHistory;
31
+ export declare function createHashHistory(): RouterHistory;
32
+ export declare function createMemoryHistory(opts?: {
33
+ initialEntries: string[];
34
+ initialIndex?: number;
35
+ }): RouterHistory;
36
+ export {};