@tanstack/router-core 0.0.1-beta.41 → 0.0.1-beta.49

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 (45) hide show
  1. package/LICENSE +21 -0
  2. package/build/cjs/actions.js +94 -0
  3. package/build/cjs/actions.js.map +1 -0
  4. package/build/cjs/history.js +163 -0
  5. package/build/cjs/history.js.map +1 -0
  6. package/build/cjs/index.js +18 -20
  7. package/build/cjs/index.js.map +1 -1
  8. package/build/cjs/interop.js +175 -0
  9. package/build/cjs/interop.js.map +1 -0
  10. package/build/cjs/path.js +4 -5
  11. package/build/cjs/path.js.map +1 -1
  12. package/build/cjs/route.js +16 -138
  13. package/build/cjs/route.js.map +1 -1
  14. package/build/cjs/routeConfig.js +1 -7
  15. package/build/cjs/routeConfig.js.map +1 -1
  16. package/build/cjs/routeMatch.js +194 -199
  17. package/build/cjs/routeMatch.js.map +1 -1
  18. package/build/cjs/router.js +726 -703
  19. package/build/cjs/router.js.map +1 -1
  20. package/build/cjs/store.js +54 -0
  21. package/build/cjs/store.js.map +1 -0
  22. package/build/esm/index.js +1305 -1114
  23. package/build/esm/index.js.map +1 -1
  24. package/build/stats-html.html +1 -1
  25. package/build/stats-react.json +229 -192
  26. package/build/types/index.d.ts +172 -109
  27. package/build/umd/index.development.js +1381 -2331
  28. package/build/umd/index.development.js.map +1 -1
  29. package/build/umd/index.production.js +1 -1
  30. package/build/umd/index.production.js.map +1 -1
  31. package/package.json +4 -4
  32. package/src/actions.ts +157 -0
  33. package/src/history.ts +199 -0
  34. package/src/index.ts +4 -7
  35. package/src/interop.ts +169 -0
  36. package/src/link.ts +2 -2
  37. package/src/route.ts +34 -239
  38. package/src/routeConfig.ts +3 -34
  39. package/src/routeInfo.ts +6 -21
  40. package/src/routeMatch.ts +270 -285
  41. package/src/router.ts +967 -963
  42. package/src/store.ts +52 -0
  43. package/build/cjs/sharedClone.js +0 -122
  44. package/build/cjs/sharedClone.js.map +0 -1
  45. package/src/sharedClone.ts +0 -118
@@ -8,15 +8,48 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import { BrowserHistory, MemoryHistory, HashHistory } from 'history';
12
- export { createBrowserHistory, createHashHistory, createMemoryHistory } from 'history';
13
11
  export { default as invariant } from 'tiny-invariant';
14
- import { SetStoreFunction } from '@solidjs/reactivity';
12
+
13
+ interface RouterHistory {
14
+ location: RouterLocation;
15
+ listen: (cb: () => void) => () => void;
16
+ push: (path: string, state: any) => void;
17
+ replace: (path: string, state: any) => void;
18
+ go: (index: number) => void;
19
+ back: () => void;
20
+ forward: () => void;
21
+ }
22
+ interface ParsedPath {
23
+ href: string;
24
+ pathname: string;
25
+ search: string;
26
+ hash: string;
27
+ }
28
+ interface RouterLocation extends ParsedPath {
29
+ state: any;
30
+ }
31
+ declare function createBrowserHistory(opts?: {
32
+ getHref?: () => string;
33
+ createHref?: (path: string) => string;
34
+ }): RouterHistory;
35
+ declare function createHashHistory(): RouterHistory;
36
+ declare function createMemoryHistory(opts?: {
37
+ initialEntries: string[];
38
+ initialIndex?: number;
39
+ }): RouterHistory;
15
40
 
16
41
  interface FrameworkGenerics {
17
42
  }
18
43
  type GetFrameworkGeneric<U> = U extends keyof FrameworkGenerics ? FrameworkGenerics[U] : any;
19
44
 
45
+ type Store<TState> = {
46
+ state: TState;
47
+ subscribe: (listener: (next: TState, prev: TState) => void) => () => void;
48
+ setState: (updater: (cb: TState) => void) => void;
49
+ };
50
+ declare function createStore<TState>(initialState: TState, debug?: boolean): Store<TState>;
51
+ declare function batch(cb: () => void): void;
52
+
20
53
  type NoInfer<T> = [T][T extends any ? 0 : never];
21
54
  type IsAny<T, Y, N> = 1 extends 0 & T ? Y : N;
22
55
  type IsAnyBoolean<T> = 1 extends 0 & T ? true : false;
@@ -55,6 +88,7 @@ declare function pick<T, K extends keyof T>(parent: T, keys: K[]): Pick<T, K>;
55
88
 
56
89
  interface RegisterRouter {
57
90
  }
91
+ type AnyRouter = Router<any, any, any>;
58
92
  type RegisteredRouter = RegisterRouter extends {
59
93
  router: Router<infer TRouteConfig, infer TAllRouteInfo, infer TRouterContext>;
60
94
  } ? Router<TRouteConfig, TAllRouteInfo, TRouterContext> : Router;
@@ -63,7 +97,7 @@ type RegisteredAllRouteInfo = RegisterRouter extends {
63
97
  } ? TAllRouteInfo : AnyAllRouteInfo;
64
98
  interface LocationState {
65
99
  }
66
- interface Location<TSearchObj extends AnySearchSchema = {}, TState extends LocationState = LocationState> {
100
+ interface ParsedLocation<TSearchObj extends AnySearchSchema = {}, TState extends LocationState = LocationState> {
67
101
  href: string;
68
102
  pathname: string;
69
103
  search: TSearchObj;
@@ -82,7 +116,7 @@ type SearchSerializer = (searchObj: Record<string, any>) => string;
82
116
  type SearchParser = (searchStr: string) => Record<string, any>;
83
117
  type FilterRoutesFn = <TRoute extends Route<any, RouteInfo>>(routeConfigs: TRoute[]) => TRoute[];
84
118
  interface RouterOptions<TRouteConfig extends AnyRouteConfig, TRouterContext> {
85
- history?: BrowserHistory | MemoryHistory | HashHistory;
119
+ history?: RouterHistory;
86
120
  stringifySearch?: SearchSerializer;
87
121
  parseSearch?: SearchParser;
88
122
  filterRoutes?: FilterRoutesFn;
@@ -99,31 +133,20 @@ interface RouterOptions<TRouteConfig extends AnyRouteConfig, TRouterContext> {
99
133
  routeConfig?: TRouteConfig;
100
134
  basepath?: string;
101
135
  useServerData?: boolean;
102
- createRouter?: (router: Router<any, any, any>) => void;
136
+ createRouter?: (router: AnyRouter) => void;
103
137
  createRoute?: (opts: {
104
138
  route: AnyRoute;
105
- router: Router<any, any, any>;
139
+ router: AnyRouter;
106
140
  }) => void;
107
141
  context?: TRouterContext;
108
142
  loadComponent?: (component: GetFrameworkGeneric<'Component'>) => Promise<GetFrameworkGeneric<'Component'>>;
143
+ onRouteChange?: () => void;
144
+ fetchServerDataFn?: FetchServerDataFn;
109
145
  }
110
- interface Action<TPayload = unknown, TResponse = unknown> {
111
- submit: (submission?: TPayload, actionOpts?: {
112
- invalidate?: boolean;
113
- multi?: boolean;
114
- }) => Promise<TResponse>;
115
- current?: ActionState<TPayload, TResponse>;
116
- latest?: ActionState<TPayload, TResponse>;
117
- submissions: ActionState<TPayload, TResponse>[];
118
- }
119
- interface ActionState<TPayload = unknown, TResponse = unknown> {
120
- submittedAt: number;
121
- status: 'idle' | 'pending' | 'success' | 'error';
122
- submission: TPayload;
123
- isMulti: boolean;
124
- data?: TResponse;
125
- error?: unknown;
126
- }
146
+ type FetchServerDataFn = (ctx: {
147
+ router: AnyRouter;
148
+ routeMatch: RouteMatch;
149
+ }) => Promise<any>;
127
150
  interface Loader<TFullSearchSchema extends AnySearchSchema = {}, TAllParams extends AnyPathParams = {}, TRouteLoaderData = AnyLoaderData> {
128
151
  fetch: keyof PickRequired<TFullSearchSchema> extends never ? keyof TAllParams extends never ? (loaderContext: {
129
152
  signal?: AbortSignal;
@@ -149,13 +172,12 @@ interface LoaderState<TFullSearchSchema extends AnySearchSchema = {}, TAllParams
149
172
  }
150
173
  interface RouterStore<TSearchObj extends AnySearchSchema = {}, TState extends LocationState = LocationState> {
151
174
  status: 'idle' | 'loading';
152
- latestLocation: Location<TSearchObj, TState>;
175
+ latestLocation: ParsedLocation<TSearchObj, TState>;
153
176
  currentMatches: RouteMatch[];
154
- currentLocation: Location<TSearchObj, TState>;
177
+ currentLocation: ParsedLocation<TSearchObj, TState>;
155
178
  pendingMatches?: RouteMatch[];
156
- pendingLocation?: Location<TSearchObj, TState>;
179
+ pendingLocation?: ParsedLocation<TSearchObj, TState>;
157
180
  lastUpdated: number;
158
- actions: Record<string, Action>;
159
181
  loaders: Record<string, Loader>;
160
182
  isFetching: boolean;
161
183
  isPreloading: boolean;
@@ -194,44 +216,51 @@ interface DehydratedRouterState extends Pick<RouterStore, 'status' | 'latestLoca
194
216
  currentMatches: DehydratedRouteMatch[];
195
217
  }
196
218
  interface DehydratedRouter<TRouterContext = unknown> {
197
- store: DehydratedRouterState;
219
+ state: DehydratedRouterState;
198
220
  context: TRouterContext;
199
221
  }
200
222
  type MatchCache = Record<string, MatchCacheEntry>;
201
223
  interface DehydratedRouteMatch {
202
224
  matchId: string;
203
- store: Pick<RouteMatchStore<any, any>, 'status' | 'routeLoaderData' | 'isInvalid' | 'invalidAt'>;
225
+ state: Pick<RouteMatchStore<any, any>, 'status' | 'routeLoaderData' | 'invalid' | 'invalidAt'>;
204
226
  }
205
227
  interface RouterContext {
206
228
  }
207
- interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>, TRouterContext = unknown> {
229
+ declare const defaultFetchServerDataFn: FetchServerDataFn;
230
+ declare class Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>, TRouterContext = unknown> {
231
+ #private;
208
232
  types: {
209
233
  RouteConfig: TRouteConfig;
210
234
  AllRouteInfo: TAllRouteInfo;
211
235
  };
212
- history: BrowserHistory | MemoryHistory | HashHistory;
213
236
  options: PickAsRequired<RouterOptions<TRouteConfig, TRouterContext>, 'stringifySearch' | 'parseSearch' | 'context'>;
214
- store: RouterStore<TAllRouteInfo['fullSearchSchema']>;
215
- setStore: SetStoreFunction<RouterStore<TAllRouteInfo['fullSearchSchema']>>;
237
+ history: RouterHistory;
216
238
  basepath: string;
217
239
  routeTree: Route<TAllRouteInfo, RouteInfo>;
218
240
  routesById: RoutesById<TAllRouteInfo>;
241
+ navigateTimeout: undefined | Timeout;
242
+ nextAction: undefined | 'push' | 'replace';
243
+ navigationPromise: undefined | Promise<void>;
244
+ store: Store<RouterStore<TAllRouteInfo['fullSearchSchema']>>;
245
+ startedLoadingAt: number;
246
+ resolveNavigation: () => void;
247
+ constructor(options?: RouterOptions<TRouteConfig, TRouterContext>);
219
248
  reset: () => void;
220
249
  mount: () => () => void;
221
- update: <TRouteConfig extends RouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>, TRouterContext = unknown>(opts?: RouterOptions<TRouteConfig, TRouterContext>) => Router<TRouteConfig, TAllRouteInfo, TRouterContext>;
222
- buildNext: (opts: BuildNextOptions) => Location;
250
+ update: <TRouteConfig_1 extends RouteConfig<string, string, string, string, AnyLoaderData, AnyLoaderData, {}, AnyLoaderData, {}, {}, {}, {}, {}, {}, unknown> = RouteConfig<string, string, string, string, AnyLoaderData, AnyLoaderData, {}, AnyLoaderData, {}, {}, {}, {}, {}, {}, unknown>, TAllRouteInfo_1 extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig_1>, TRouterContext_1 = unknown>(opts?: RouterOptions<TRouteConfig_1, TRouterContext_1> | undefined) => Router<TRouteConfig_1, TAllRouteInfo_1, TRouterContext_1>;
251
+ buildNext: (opts: BuildNextOptions) => ParsedLocation<{}, LocationState>;
223
252
  cancelMatches: () => void;
224
- load: (next?: Location) => Promise<void>;
253
+ load: (next?: ParsedLocation) => Promise<void>;
225
254
  cleanMatchCache: () => void;
226
- getRoute: <TId extends keyof TAllRouteInfo['routeInfoById']>(id: TId) => Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TId]>;
227
- loadRoute: (navigateOpts: BuildNextOptions) => Promise<RouteMatch[]>;
228
- preloadRoute: (navigateOpts: BuildNextOptions, loaderOpts: {
255
+ getRoute: <TId extends keyof TAllRouteInfo["routeInfoById"]>(id: TId) => Route<TAllRouteInfo, TAllRouteInfo["routeInfoById"][TId], unknown>;
256
+ loadRoute: (navigateOpts?: BuildNextOptions) => Promise<RouteMatch[]>;
257
+ preloadRoute: (navigateOpts: BuildNextOptions | undefined, loaderOpts: {
229
258
  maxAge?: number;
230
259
  gcMaxAge?: number;
231
- }) => Promise<RouteMatch[]>;
260
+ }) => Promise<RouteMatch<DefaultAllRouteInfo, RouteInfo<string, string, string, "/", {}, {}, {}, {}, {}, {}, {}, {}, {}, {}>>[]>;
232
261
  matchRoutes: (pathname: string, opts?: {
233
262
  strictParseParams?: boolean;
234
- }) => RouteMatch[];
263
+ }) => RouteMatch<DefaultAllRouteInfo, RouteInfo<string, string, string, "/", {}, {}, {}, {}, {}, {}, {}, {}, {}, {}>>[];
235
264
  loadMatches: (resolvedMatches: RouteMatch[], loaderOpts?: {
236
265
  preload: true;
237
266
  maxAge: number;
@@ -242,37 +271,55 @@ interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInf
242
271
  gcMaxAge?: never;
243
272
  }) => Promise<void>;
244
273
  loadMatchData: (routeMatch: RouteMatch<any, any>) => Promise<Record<string, unknown>>;
245
- invalidateRoute: (opts: MatchLocation) => void;
246
- reload: () => Promise<void>;
274
+ invalidateRoute: (opts: MatchLocation) => Promise<void>;
275
+ reload: () => void;
247
276
  resolvePath: (from: string, path: string) => string;
248
- navigate: <TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'>(opts: NavigateOptions<TAllRouteInfo, TFrom, TTo>) => Promise<void>;
249
- matchRoute: <TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'>(matchLocation: ToOptions<TAllRouteInfo, TFrom, TTo>, opts?: MatchRouteOptions) => false | TAllRouteInfo['routeInfoById'][ResolveRelativePath<TFrom, NoInfer<TTo>>]['allParams'];
250
- buildLink: <TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'>(opts: LinkOptions<TAllRouteInfo, TFrom, TTo>) => LinkInfo;
277
+ navigate: <TFrom extends ValidFromPath<TAllRouteInfo> = "/", TTo extends string = ".">({ from, to, search, hash, replace, params, }: NavigateOptions<TAllRouteInfo, TFrom, TTo>) => Promise<void>;
278
+ matchRoute: <TFrom extends ValidFromPath<TAllRouteInfo> = "/", TTo extends string = ".">(location: ToOptions<TAllRouteInfo, TFrom, TTo, ResolveRelativePath<TFrom, NoInfer<TTo>>>, opts?: MatchRouteOptions) => false | TAllRouteInfo["routeInfoById"][ResolveRelativePath<TFrom, NoInfer<TTo>>]["allParams"];
279
+ buildLink: <TFrom extends ValidFromPath<TAllRouteInfo> = "/", TTo extends string = ".">({ from, to, search, params, hash, target, replace, activeOptions, preload, preloadMaxAge: userPreloadMaxAge, preloadGcMaxAge: userPreloadGcMaxAge, preloadDelay: userPreloadDelay, disabled, }: LinkOptions<TAllRouteInfo, TFrom, TTo>) => LinkInfo;
251
280
  dehydrate: () => DehydratedRouter<TRouterContext>;
252
281
  hydrate: (dehydratedRouter: DehydratedRouter<TRouterContext>) => void;
282
+ getLoader: <TFrom extends keyof TAllRouteInfo["routeInfoById"] = "/">(opts: {
283
+ from: TFrom;
284
+ }) => unknown extends TAllRouteInfo["routeInfoById"][TFrom]["routeLoaderData"] ? Loader<LoaderContext<TAllRouteInfo["routeInfoById"][TFrom]["fullSearchSchema"], TAllRouteInfo["routeInfoById"][TFrom]["allParams"]>, TAllRouteInfo["routeInfoById"][TFrom]["routeLoaderData"], AnyLoaderData> | undefined : Loader<TAllRouteInfo["routeInfoById"][TFrom]["fullSearchSchema"], TAllRouteInfo["routeInfoById"][TFrom]["allParams"], TAllRouteInfo["routeInfoById"][TFrom]["routeLoaderData"]>;
253
285
  }
254
- declare function createRouter<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>, TRouterContext = unknown>(userOptions?: RouterOptions<TRouteConfig, TRouterContext>): Router<TRouteConfig, TAllRouteInfo, TRouterContext>;
255
286
 
256
287
  interface RouteMatchStore<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo> {
257
- parentMatch?: RouteMatch;
258
288
  routeSearch: TRouteInfo['searchSchema'];
259
289
  search: Expand<TAllRouteInfo['fullSearchSchema'] & TRouteInfo['fullSearchSchema']>;
260
290
  status: 'idle' | 'loading' | 'success' | 'error';
261
291
  updatedAt?: number;
262
292
  error?: unknown;
263
293
  invalid: boolean;
264
- isInvalid: boolean;
265
294
  loaderData: TRouteInfo['loaderData'];
266
295
  routeLoaderData: TRouteInfo['routeLoaderData'];
267
296
  isFetching: boolean;
268
297
  invalidAt: number;
269
298
  }
270
- interface RouteMatch<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo> extends Route<TAllRouteInfo, TRouteInfo> {
271
- store: RouteMatchStore<TAllRouteInfo, TRouteInfo>;
272
- matchId: string;
299
+ declare class RouteMatch<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo> {
300
+ #private;
301
+ route: Route<TAllRouteInfo, TRouteInfo>;
302
+ router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo>;
303
+ store: Store<RouteMatchStore<TAllRouteInfo, TRouteInfo>>;
304
+ id: string;
273
305
  pathname: string;
274
306
  params: TRouteInfo['allParams'];
275
- childMatches: RouteMatch[];
307
+ component: GetFrameworkGeneric<'Component'>;
308
+ errorComponent: GetFrameworkGeneric<'ErrorComponent'>;
309
+ pendingComponent: GetFrameworkGeneric<'Component'>;
310
+ abortController: AbortController;
311
+ onLoaderDataListeners: Set<() => void>;
312
+ parentMatch?: RouteMatch;
313
+ __loadPromise?: Promise<void>;
314
+ __onExit?: void | ((matchContext: {
315
+ params: TRouteInfo['allParams'];
316
+ search: TRouteInfo['fullSearchSchema'];
317
+ }) => void);
318
+ constructor(router: AnyRouter, route: Route<TAllRouteInfo, TRouteInfo>, opts: {
319
+ matchId: string;
320
+ params: TRouteInfo['allParams'];
321
+ pathname: string;
322
+ });
276
323
  cancel: () => void;
277
324
  load: (loaderOpts?: {
278
325
  preload: true;
@@ -282,32 +329,17 @@ interface RouteMatch<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo
282
329
  preload?: false;
283
330
  maxAge?: never;
284
331
  gcMaxAge?: never;
285
- }) => Promise<TRouteInfo['routeLoaderData']>;
332
+ }) => Promise<void>;
286
333
  fetch: (opts?: {
287
334
  maxAge?: number;
288
335
  }) => Promise<TRouteInfo['routeLoaderData']>;
289
- invalidate: () => void;
290
- hasLoaders: () => boolean;
291
- __: {
292
- setParentMatch: (parentMatch?: RouteMatch) => void;
293
- component?: GetFrameworkGeneric<'Component'>;
294
- errorComponent?: GetFrameworkGeneric<'ErrorComponent'>;
295
- pendingComponent?: GetFrameworkGeneric<'Component'>;
296
- loadPromise?: Promise<void>;
297
- onExit?: void | ((matchContext: {
298
- params: TRouteInfo['allParams'];
299
- search: TRouteInfo['fullSearchSchema'];
300
- }) => void);
301
- abortController: AbortController;
302
- validate: () => void;
303
- };
336
+ invalidate: () => Promise<void>;
337
+ __hasLoaders: () => boolean;
338
+ getIsInvalid: () => boolean;
339
+ __setParentMatch: (parentMatch?: RouteMatch) => void;
340
+ __onLoaderData: (listener: () => void) => void;
341
+ __validate: () => void;
304
342
  }
305
- declare function createRouteMatch<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo>(router: Router<any, any, any>, route: Route<TAllRouteInfo, TRouteInfo>, opts: {
306
- parentMatch?: RouteMatch<any, any>;
307
- matchId: string;
308
- params: TRouteInfo['allParams'];
309
- pathname: string;
310
- }): RouteMatch<TAllRouteInfo, TRouteInfo>;
311
343
 
312
344
  declare const rootRouteId: "__root__";
313
345
  type RootRouteId = typeof rootRouteId;
@@ -334,9 +366,8 @@ interface LoaderContext<TFullSearchSchema extends AnySearchSchema = {}, TAllPara
334
366
  search: TFullSearchSchema;
335
367
  signal?: AbortSignal;
336
368
  }
337
- type ActionFn<TActionPayload = unknown, TActionResponse = unknown> = (submission: TActionPayload) => TActionResponse | Promise<TActionResponse>;
338
369
  type UnloaderFn<TPath extends string> = (routeMatch: RouteMatch<any, RouteInfo<string, TPath>>) => void;
339
- type RouteOptions<TRouteId extends string = string, TPath extends string = string, TParentRouteLoaderData extends AnyLoaderData = {}, TRouteLoaderData extends AnyLoaderData = {}, TParentLoaderData extends AnyLoaderData = {}, TLoaderData extends AnyLoaderData = {}, TActionPayload = unknown, TActionResponse = unknown, TParentSearchSchema extends {} = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = TSearchSchema, TParentParams extends AnyPathParams = {}, TParams extends Record<ParsePathParams<TPath>, unknown> = Record<ParsePathParams<TPath>, string>, TAllParams extends AnyPathParams = {}> = ({
370
+ type RouteOptions<TRouteId extends string = string, TPath extends string = string, TParentRouteLoaderData extends AnyLoaderData = {}, TRouteLoaderData extends AnyLoaderData = {}, TParentLoaderData extends AnyLoaderData = {}, TLoaderData extends AnyLoaderData = {}, TParentSearchSchema extends {} = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = TSearchSchema, TParentParams extends AnyPathParams = {}, TParams extends Record<ParsePathParams<TPath>, unknown> = Record<ParsePathParams<TPath>, string>, TAllParams extends AnyPathParams = {}> = ({
340
371
  path: TPath;
341
372
  } | {
342
373
  id: TRouteId;
@@ -351,9 +382,8 @@ type RouteOptions<TRouteId extends string = string, TPath extends string = strin
351
382
  loader?: LoaderFn<TRouteLoaderData, TFullSearchSchema, TAllParams>;
352
383
  loaderMaxAge?: number;
353
384
  loaderGcMaxAge?: number;
354
- action?: ActionFn<TActionPayload, TActionResponse>;
355
385
  beforeLoad?: (opts: {
356
- router: Router<any, any, unknown>;
386
+ router: AnyRouter;
357
387
  match: RouteMatch;
358
388
  }) => Promise<void> | void;
359
389
  onLoadError?: (err: any) => void;
@@ -377,29 +407,29 @@ type RouteOptions<TRouteId extends string = string, TPath extends string = strin
377
407
  stringifyParams: (params: TParams) => Record<ParsePathParams<TPath>, string>;
378
408
  }) & (PickUnsafe<TParentParams, ParsePathParams<TPath>> extends never ? {} : 'Cannot redefined path params in child routes!');
379
409
  type SearchFilter<T, U = T> = (prev: T) => U;
380
- interface RouteConfig<TId extends string = string, TRouteId extends string = string, TPath extends string = string, TFullPath extends string = string, TParentRouteLoaderData extends AnyLoaderData = AnyLoaderData, TRouteLoaderData extends AnyLoaderData = AnyLoaderData, TParentLoaderData extends AnyLoaderData = {}, TLoaderData extends AnyLoaderData = AnyLoaderData, TActionPayload = unknown, TActionResponse = unknown, TParentSearchSchema extends {} = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = {}, TParentParams extends AnyPathParams = {}, TParams extends AnyPathParams = {}, TAllParams extends AnyPathParams = {}, TKnownChildren = unknown> {
410
+ interface RouteConfig<TId extends string = string, TRouteId extends string = string, TPath extends string = string, TFullPath extends string = string, TParentRouteLoaderData extends AnyLoaderData = AnyLoaderData, TRouteLoaderData extends AnyLoaderData = AnyLoaderData, TParentLoaderData extends AnyLoaderData = {}, TLoaderData extends AnyLoaderData = AnyLoaderData, TParentSearchSchema extends {} = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = {}, TParentParams extends AnyPathParams = {}, TParams extends AnyPathParams = {}, TAllParams extends AnyPathParams = {}, TKnownChildren = unknown> {
381
411
  id: TId;
382
412
  routeId: TRouteId;
383
413
  path: NoInfer<TPath>;
384
414
  fullPath: TFullPath;
385
- options: RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams>;
415
+ options: RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, TLoaderData, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams>;
386
416
  children?: TKnownChildren;
387
417
  addChildren: IsAny<TId, any, <TNewChildren extends any>(children: TNewChildren extends AnyRouteConfig[] ? TNewChildren : {
388
418
  error: 'Invalid route detected';
389
419
  route: TNewChildren;
390
- }) => RouteConfig<TId, TRouteId, TPath, TFullPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams, TNewChildren>>;
420
+ }) => RouteConfig<TId, TRouteId, TPath, TFullPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, TLoaderData, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams, TNewChildren>>;
391
421
  createRoute: CreateRouteConfigFn<false, TId, TFullPath, TRouteLoaderData, TLoaderData, TFullSearchSchema, TAllParams>;
392
422
  generate: GenerateFn<TRouteId, TPath, TParentRouteLoaderData, TParentLoaderData, TParentSearchSchema, TParentParams>;
393
423
  }
394
- type GenerateFn<TRouteId extends string = string, TPath extends string = string, TParentRouteLoaderData extends AnyLoaderData = AnyLoaderData, TParentLoaderData extends AnyLoaderData = {}, TParentSearchSchema extends {} = {}, TParentParams extends AnyPathParams = {}> = <TRouteLoaderData extends AnyLoaderData = AnyLoaderData, TActionPayload = unknown, TActionResponse = unknown, TSearchSchema extends AnySearchSchema = {}, TParams extends Record<ParsePathParams<TPath>, unknown> = Record<ParsePathParams<TPath>, string>, TAllParams extends AnyPathParams extends TParams ? Record<ParsePathParams<TPath>, string> : NoInfer<TParams> = AnyPathParams extends TParams ? Record<ParsePathParams<TPath>, string> : NoInfer<TParams>>(options: Omit<RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, Expand<TParentLoaderData & NoInfer<TRouteLoaderData>>, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>>, 'path'>) => void;
395
- type CreateRouteConfigFn<TIsRoot extends boolean = false, TParentId extends string = string, TParentPath extends string = string, TParentRouteLoaderData extends AnyLoaderData = {}, TParentLoaderData extends AnyLoaderData = {}, TParentSearchSchema extends AnySearchSchema = {}, TParentParams extends AnyPathParams = {}> = <TRouteId extends string, TPath extends string, TRouteLoaderData extends AnyLoaderData, TActionPayload, TActionResponse, TSearchSchema extends AnySearchSchema = AnySearchSchema, TParams extends Record<ParsePathParams<TPath>, unknown> = Record<ParsePathParams<TPath>, string>, TAllParams extends AnyPathParams extends TParams ? Record<ParsePathParams<TPath>, string> : NoInfer<TParams> = AnyPathParams extends TParams ? Record<ParsePathParams<TPath>, string> : NoInfer<TParams>, TKnownChildren extends RouteConfig[] = RouteConfig[], TResolvedId extends string = string extends TRouteId ? string extends TPath ? string : TPath : TRouteId>(options?: TIsRoot extends true ? Omit<RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, Expand<TParentLoaderData & NoInfer<TRouteLoaderData>>, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>>, 'path'> & {
424
+ type GenerateFn<TRouteId extends string = string, TPath extends string = string, TParentRouteLoaderData extends AnyLoaderData = AnyLoaderData, TParentLoaderData extends AnyLoaderData = {}, TParentSearchSchema extends {} = {}, TParentParams extends AnyPathParams = {}> = <TRouteLoaderData extends AnyLoaderData = AnyLoaderData, TSearchSchema extends AnySearchSchema = {}, TParams extends Record<ParsePathParams<TPath>, unknown> = Record<ParsePathParams<TPath>, string>, TAllParams extends AnyPathParams extends TParams ? Record<ParsePathParams<TPath>, string> : NoInfer<TParams> = AnyPathParams extends TParams ? Record<ParsePathParams<TPath>, string> : NoInfer<TParams>>(options: Omit<RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, Expand<TParentLoaderData & NoInfer<TRouteLoaderData>>, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>>, 'path'>) => void;
425
+ type CreateRouteConfigFn<TIsRoot extends boolean = false, TParentId extends string = string, TParentPath extends string = string, TParentRouteLoaderData extends AnyLoaderData = {}, TParentLoaderData extends AnyLoaderData = {}, TParentSearchSchema extends AnySearchSchema = {}, TParentParams extends AnyPathParams = {}> = <TRouteId extends string, TPath extends string, TRouteLoaderData extends AnyLoaderData, TSearchSchema extends AnySearchSchema = AnySearchSchema, TParams extends Record<ParsePathParams<TPath>, unknown> = Record<ParsePathParams<TPath>, string>, TAllParams extends AnyPathParams extends TParams ? Record<ParsePathParams<TPath>, string> : NoInfer<TParams> = AnyPathParams extends TParams ? Record<ParsePathParams<TPath>, string> : NoInfer<TParams>, TKnownChildren extends RouteConfig[] = RouteConfig[], TResolvedId extends string = string extends TRouteId ? string extends TPath ? string : TPath : TRouteId>(options?: TIsRoot extends true ? Omit<RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, Expand<TParentLoaderData & NoInfer<TRouteLoaderData>>, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>>, 'path'> & {
396
426
  path?: never;
397
- } : RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, Expand<TParentLoaderData & NoInfer<TRouteLoaderData>>, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>>, children?: TKnownChildren, isRoot?: boolean, parentId?: string, parentPath?: string) => RouteConfig<RoutePrefix<TParentId, TResolvedId>, TResolvedId, TPath, string extends TPath ? '' : RoutePath<RoutePrefix<TParentPath, TPath>>, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, Expand<TParentLoaderData & NoInfer<TRouteLoaderData>>, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>, TKnownChildren>;
427
+ } : RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, Expand<TParentLoaderData & NoInfer<TRouteLoaderData>>, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>>, children?: TKnownChildren, isRoot?: boolean, parentId?: string, parentPath?: string) => RouteConfig<RoutePrefix<TParentId, TResolvedId>, TResolvedId, TPath, string extends TPath ? '' : RoutePath<RoutePrefix<TParentPath, TPath>>, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, Expand<TParentLoaderData & NoInfer<TRouteLoaderData>>, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>, TKnownChildren>;
398
428
  type RoutePath<T extends string> = T extends RootRouteId ? '/' : TrimPathRight<`${T}`>;
399
429
  type RoutePrefix<TPrefix extends string, TId extends string> = string extends TId ? RootRouteId : TId extends string ? `${TPrefix}/${TId}` extends '/' ? '/' : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TId>}`>}` : never;
400
- interface AnyRouteConfig extends RouteConfig<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
430
+ interface AnyRouteConfig extends RouteConfig<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
401
431
  }
402
- interface AnyRouteConfigWithChildren<TChildren> extends RouteConfig<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, TChildren> {
432
+ interface AnyRouteConfigWithChildren<TChildren> extends RouteConfig<any, any, any, any, any, any, any, any, any, any, any, any, any, any, TChildren> {
403
433
  }
404
434
  type TrimPath<T extends string> = '' extends T ? '' : TrimPathRight<TrimPathLeft<T>>;
405
435
  type TrimPathLeft<T extends string> = T extends `${RootRouteId}/${infer U}` ? TrimPathLeft<U> : T extends `/${infer U}` ? TrimPathLeft<U> : T;
@@ -408,21 +438,19 @@ declare const createRouteConfig: CreateRouteConfigFn<true>;
408
438
 
409
439
  interface AnyRoute extends Route<any, any, any> {
410
440
  }
411
- interface Route<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo, TRouterContext = unknown> {
441
+ declare class Route<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo, TRouterContext = unknown> {
412
442
  routeInfo: TRouteInfo;
413
- routeId: TRouteInfo['id'];
414
- routeRouteId: TRouteInfo['routeId'];
415
- routePath: TRouteInfo['path'];
443
+ id: TRouteInfo['id'];
444
+ customId: TRouteInfo['customId'];
445
+ path: TRouteInfo['path'];
416
446
  fullPath: TRouteInfo['fullPath'];
417
- parentRoute?: AnyRoute;
447
+ getParentRoute: () => undefined | AnyRoute;
418
448
  childRoutes?: AnyRoute[];
419
449
  options: RouteOptions;
420
450
  originalIndex: number;
421
- router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo, TRouterContext>;
422
- action: unknown extends TRouteInfo['actionResponse'] ? Action<TRouteInfo['actionPayload'], TRouteInfo['actionResponse']> | undefined : Action<TRouteInfo['actionPayload'], TRouteInfo['actionResponse']>;
423
- loader: unknown extends TRouteInfo['routeLoaderData'] ? Action<LoaderContext<TRouteInfo['fullSearchSchema'], TRouteInfo['allParams']>, TRouteInfo['routeLoaderData']> | undefined : Loader<TRouteInfo['fullSearchSchema'], TRouteInfo['allParams'], TRouteInfo['routeLoaderData']>;
451
+ getRouter: () => Router<TAllRouteInfo['routeConfig'], TAllRouteInfo, TRouterContext>;
452
+ constructor(routeConfig: RouteConfig, options: TRouteInfo['options'], originalIndex: number, parent: undefined | Route<TAllRouteInfo, any>, router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo, TRouterContext>);
424
453
  }
425
- declare function createRoute<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo, TRouterContext = unknown>(routeConfig: RouteConfig, options: TRouteInfo['options'], originalIndex: number, parent: undefined | Route<TAllRouteInfo, any>, router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo, TRouterContext>): Route<TAllRouteInfo, TRouteInfo, TRouterContext>;
426
454
 
427
455
  interface AnyAllRouteInfo {
428
456
  routeConfig: AnyRouteConfig;
@@ -453,8 +481,8 @@ type ParseRouteChildren<TRouteConfig> = TRouteConfig extends AnyRouteConfigWithC
453
481
  type ParseRouteChild<TRouteConfig, TId> = TRouteConfig & {
454
482
  id: TId;
455
483
  } extends AnyRouteConfig ? ParseRouteConfig<TRouteConfig> : never;
456
- type RouteConfigRoute<TRouteConfig> = TRouteConfig extends RouteConfig<infer TId, infer TRouteId, infer TPath, infer TFullPath, infer TParentRouteLoaderData, infer TRouteLoaderData, infer TParentLoaderData, infer TLoaderData, infer TActionPayload, infer TActionResponse, infer TParentSearchSchema, infer TSearchSchema, infer TFullSearchSchema, infer TParentParams, infer TParams, infer TAllParams, any> ? string extends TRouteId ? never : RouteInfo<TId, TRouteId, TPath, TFullPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams> : never;
457
- interface RoutesInfoInner<TRouteConfig extends AnyRouteConfig, TRouteInfo extends RouteInfo<string, string, any, any, any, any, any, any, any, any, any, any, any, any, any, any> = RouteInfo, TRouteInfoById = {
484
+ type RouteConfigRoute<TRouteConfig> = TRouteConfig extends RouteConfig<infer TId, infer TCustomId, infer TPath, infer TFullPath, infer TParentRouteLoaderData, infer TRouteLoaderData, infer TParentLoaderData, infer TLoaderData, infer TParentSearchSchema, infer TSearchSchema, infer TFullSearchSchema, infer TParentParams, infer TParams, infer TAllParams, any> ? string extends TCustomId ? never : RouteInfo<TId, TCustomId, TPath, TFullPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, TLoaderData, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams> : never;
485
+ interface RoutesInfoInner<TRouteConfig extends AnyRouteConfig, TRouteInfo extends RouteInfo<string, string, any, any, any, any, any, any, any, any, any, any, any, any> = RouteInfo, TRouteInfoById = {
458
486
  '/': TRouteInfo;
459
487
  } & {
460
488
  [TInfo in TRouteInfo as TInfo['id']]: TInfo;
@@ -472,25 +500,23 @@ interface RoutesInfoInner<TRouteConfig extends AnyRouteConfig, TRouteInfo extend
472
500
  fullSearchSchema: Partial<UnionToIntersection<TRouteInfo['fullSearchSchema']>>;
473
501
  allParams: Partial<UnionToIntersection<TRouteInfo['allParams']>>;
474
502
  }
475
- interface AnyRouteInfo extends RouteInfo<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
503
+ interface AnyRouteInfo extends RouteInfo<any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
476
504
  }
477
- interface RouteInfo<TId extends string = string, TRouteId extends string = string, TPath extends string = string, TFullPath extends string = '/', TParentRouteLoaderData extends AnyLoaderData = {}, TRouteLoaderData extends AnyLoaderData = {}, TParentLoaderData extends AnyLoaderData = {}, TLoaderData extends AnyLoaderData = {}, TActionPayload = unknown, TActionResponse = unknown, TParentSearchSchema extends {} = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = {}, TParentParams extends AnyPathParams = {}, TParams extends AnyPathParams = {}, TAllParams extends AnyPathParams = {}> {
505
+ interface RouteInfo<TId extends string = string, TCustomId extends string = string, TPath extends string = string, TFullPath extends string = '/', TParentRouteLoaderData extends AnyLoaderData = {}, TRouteLoaderData extends AnyLoaderData = {}, TParentLoaderData extends AnyLoaderData = {}, TLoaderData extends AnyLoaderData = {}, TParentSearchSchema extends {} = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = {}, TParentParams extends AnyPathParams = {}, TParams extends AnyPathParams = {}, TAllParams extends AnyPathParams = {}> {
478
506
  id: TId;
479
- routeId: TRouteId;
507
+ customId: TCustomId;
480
508
  path: TPath;
481
509
  fullPath: TFullPath;
482
510
  parentRouteLoaderData: TParentRouteLoaderData;
483
511
  routeLoaderData: TRouteLoaderData;
484
512
  parentLoaderData: TParentLoaderData;
485
513
  loaderData: TLoaderData;
486
- actionPayload: TActionPayload;
487
- actionResponse: TActionResponse;
488
514
  searchSchema: TSearchSchema;
489
515
  fullSearchSchema: TFullSearchSchema;
490
516
  parentParams: TParentParams;
491
517
  params: TParams;
492
518
  allParams: TAllParams;
493
- options: RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams>;
519
+ options: RouteOptions<TCustomId, TPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, TLoaderData, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams>;
494
520
  }
495
521
  type RoutesById<TAllRouteInfo extends AnyAllRouteInfo> = {
496
522
  [K in keyof TAllRouteInfo['routeInfoById']]: Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][K]>;
@@ -503,7 +529,7 @@ type LinkInfo = {
503
529
  href: string;
504
530
  } | {
505
531
  type: 'internal';
506
- next: Location;
532
+ next: ParsedLocation;
507
533
  handleFocus: (e: any) => void;
508
534
  handleClick: (e: any) => void;
509
535
  handleEnter: (e: any) => void;
@@ -609,8 +635,45 @@ declare function stringifySearchWith(stringify: (search: any) => string): (searc
609
635
  /**
610
636
  * This function returns `a` if `b` is deeply equal.
611
637
  * If not, it will replace any deeply equal children of `b` with those of `a`.
612
- * This can be used for structural sharing between JSON values for example.
638
+ * This can be used for structural sharing between immutable JSON values for example.
639
+ * Do not use this with signals
613
640
  */
614
- declare function sharedClone<T>(prev: any, next: T, touchAll?: boolean): T;
641
+ declare function replaceEqualDeep<T>(prev: any, _next: T): T;
642
+ declare function trackDeep<T>(obj: T): T;
643
+
644
+ interface ActionOptions<TKey extends string = string, TPayload = unknown, TResponse = unknown, TError = Error> {
645
+ key?: TKey;
646
+ action: (payload: TPayload) => TResponse | Promise<TResponse>;
647
+ onLatestSuccess?: ActionCallback<TPayload, TResponse, TError>;
648
+ onEachSuccess?: ActionCallback<TPayload, TResponse, TError>;
649
+ onLatestError?: ActionCallback<TPayload, TResponse, TError>;
650
+ onEachError?: ActionCallback<TPayload, TResponse, TError>;
651
+ onLatestSettled?: ActionCallback<TPayload, TResponse, TError>;
652
+ onEachSettled?: ActionCallback<TPayload, TResponse, TError>;
653
+ maxSubmissions?: number;
654
+ debug?: boolean;
655
+ }
656
+ type ActionCallback<TPayload, TResponse, TError> = (submission: ActionSubmission<TPayload, TResponse, TError>) => void | Promise<void>;
657
+ interface Action<TKey extends string = string, TPayload = unknown, TResponse = unknown, TError = Error> {
658
+ options: ActionOptions<TKey, TPayload, TResponse, TError>;
659
+ submit: (payload?: TPayload) => Promise<TResponse>;
660
+ reset: () => void;
661
+ store: Store<ActionStore<TPayload, TResponse, TError>>;
662
+ }
663
+ interface ActionStore<TPayload = unknown, TResponse = unknown, TError = Error> {
664
+ submissions: ActionSubmission<TPayload, TResponse, TError>[];
665
+ }
666
+ type ActionFn<TActionPayload = unknown, TActionResponse = unknown> = (submission: TActionPayload) => TActionResponse | Promise<TActionResponse>;
667
+ interface ActionSubmission<TPayload = unknown, TResponse = unknown, TError = Error> {
668
+ submittedAt: number;
669
+ status: 'idle' | 'pending' | 'success' | 'error';
670
+ payload: TPayload;
671
+ response?: TResponse;
672
+ error?: TError;
673
+ isInvalid?: boolean;
674
+ invalidate: () => void;
675
+ getIsLatest: () => boolean;
676
+ }
677
+ declare function createAction<TKey extends string, TPayload, TResponse, TError>(options: ActionOptions<TKey, TPayload, TResponse, TError>): Action<TKey, TPayload, TResponse, TError>;
615
678
 
616
- export { Action, ActionFn, ActionState, ActiveOptions, 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, MatchCache, MatchCacheEntry, MatchLocation, MatchRouteOptions, NavigateOptions, NoInfer, ParentParams, ParsePathParams, ParseRouteConfig, PathParamMask, PathParamOptions, PickAsPartial, PickAsRequired, PickExclude, PickExtra, PickExtract, PickRequired, PickUnsafe, RegisterRouter, RegisteredAllRouteInfo, RegisteredRouter, RelativeToPathAutoComplete, ResolveRelativePath, RootRouteId, Route, RouteConfig, RouteConfigRoute, RouteInfo, RouteInfoById, RouteInfoByPath, RouteMatch, RouteMatchStore, RouteMeta, RouteOptions, Router, RouterContext, RouterOptions, RouterStore, RoutesById, RoutesInfoInner, SearchFilter, SearchParamOptions, 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, resolvePath, rootRouteId, sharedClone, stringifySearchWith, trimPath, trimPathLeft, trimPathRight, warning };
679
+ export { Action, ActionFn, ActionOptions, ActionStore, ActionSubmission, ActiveOptions, AllRouteInfo, AnyAllRouteInfo, AnyLoaderData, AnyPathParams, AnyRoute, AnyRouteConfig, AnyRouteConfigWithChildren, AnyRouteInfo, AnyRouter, 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, LocationState, MatchCache, MatchCacheEntry, MatchLocation, MatchRouteOptions, NavigateOptions, NoInfer, ParentParams, ParsePathParams, ParseRouteConfig, ParsedLocation, ParsedPath, PathParamMask, PathParamOptions, PickAsPartial, PickAsRequired, PickExclude, PickExtra, PickExtract, PickRequired, PickUnsafe, RegisterRouter, RegisteredAllRouteInfo, RegisteredRouter, RelativeToPathAutoComplete, ResolveRelativePath, RootRouteId, Route, RouteConfig, RouteConfigRoute, RouteInfo, RouteInfoById, RouteInfoByPath, RouteMatch, RouteMatchStore, RouteMeta, RouteOptions, Router, RouterContext, RouterHistory, RouterLocation, RouterOptions, RouterStore, RoutesById, RoutesInfoInner, SearchFilter, SearchParamOptions, SearchParser, SearchSchemaValidator, SearchSchemaValidatorFn, SearchSchemaValidatorObj, SearchSerializer, Segment, Split, Store, Timeout, ToIdOption, ToOptions, ToPathOption, UnionToIntersection, UnloaderFn, Updater, ValidFromPath, ValueKeys, Values, batch, cleanPath, createAction, createBrowserHistory, createHashHistory, createMemoryHistory, createRouteConfig, createStore, decode, defaultFetchServerDataFn, defaultParseSearch, defaultStringifySearch, encode, functionalUpdate, interpolatePath, joinPaths, last, matchByPath, matchPathname, parsePathname, parseSearchWith, pick, replaceEqualDeep, resolvePath, rootRouteId, stringifySearchWith, trackDeep, trimPath, trimPathLeft, trimPathRight, warning };