@tanstack/router-core 0.0.1-beta.160 → 0.0.1-beta.162
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.map +1 -1
- package/build/cjs/route.js.map +1 -1
- package/build/cjs/router.js +40 -34
- package/build/cjs/router.js.map +1 -1
- package/build/esm/index.js +40 -34
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +116 -116
- package/build/types/index.d.ts +22 -22
- package/build/umd/index.development.js +40 -34
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +2 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/fileRoute.ts +5 -5
- package/src/link.ts +8 -8
- package/src/route.ts +13 -13
- package/src/routeInfo.ts +2 -2
- package/src/router.ts +58 -51
package/build/types/index.d.ts
CHANGED
|
@@ -114,8 +114,8 @@ type RouteByPath<TRouteTree extends AnyRoute, TPath> = Extract<ParseRoute<TRoute
|
|
|
114
114
|
fullPath: TPath;
|
|
115
115
|
}>;
|
|
116
116
|
type RoutePaths<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree>['fullPath'] | '/';
|
|
117
|
-
type FullSearchSchema<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['
|
|
118
|
-
type AllParams<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['
|
|
117
|
+
type FullSearchSchema<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['types']['fullSearchSchema']> & {};
|
|
118
|
+
type AllParams<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['types']['allParams']>;
|
|
119
119
|
|
|
120
120
|
declare global {
|
|
121
121
|
interface Window {
|
|
@@ -156,7 +156,7 @@ interface RouteMatch<TRouteTree extends AnyRoute = AnyRoute, TRoute extends AnyR
|
|
|
156
156
|
key?: string;
|
|
157
157
|
routeId: string;
|
|
158
158
|
pathname: string;
|
|
159
|
-
params: TRoute['
|
|
159
|
+
params: TRoute['types']['allParams'];
|
|
160
160
|
status: 'pending' | 'success' | 'error';
|
|
161
161
|
isFetching: boolean;
|
|
162
162
|
invalid: boolean;
|
|
@@ -166,21 +166,21 @@ interface RouteMatch<TRouteTree extends AnyRoute = AnyRoute, TRoute extends AnyR
|
|
|
166
166
|
updatedAt: number;
|
|
167
167
|
invalidAt: number;
|
|
168
168
|
preloadInvalidAt: number;
|
|
169
|
-
loaderData: TRoute['
|
|
169
|
+
loaderData: TRoute['types']['loader'];
|
|
170
170
|
loadPromise?: Promise<void>;
|
|
171
171
|
__resolveLoadPromise?: () => void;
|
|
172
|
-
routeContext: TRoute['
|
|
173
|
-
context: TRoute['
|
|
174
|
-
routeSearch: TRoute['
|
|
175
|
-
search: FullSearchSchema<TRouteTree> & TRoute['
|
|
172
|
+
routeContext: TRoute['types']['routeContext'];
|
|
173
|
+
context: TRoute['types']['context'];
|
|
174
|
+
routeSearch: TRoute['types']['searchSchema'];
|
|
175
|
+
search: FullSearchSchema<TRouteTree> & TRoute['types']['fullSearchSchema'];
|
|
176
176
|
fetchedAt: number;
|
|
177
177
|
abortController: AbortController;
|
|
178
178
|
}
|
|
179
179
|
type AnyRouteMatch = RouteMatch<AnyRoute, AnyRoute>;
|
|
180
|
-
type RouterContextOptions<TRouteTree extends AnyRoute> = AnyContext extends TRouteTree['
|
|
181
|
-
context?: TRouteTree['
|
|
180
|
+
type RouterContextOptions<TRouteTree extends AnyRoute> = AnyContext extends TRouteTree['types']['routerContext'] ? {
|
|
181
|
+
context?: TRouteTree['types']['routerContext'];
|
|
182
182
|
} : {
|
|
183
|
-
context: TRouteTree['
|
|
183
|
+
context: TRouteTree['types']['routerContext'];
|
|
184
184
|
};
|
|
185
185
|
interface RouterOptions<TRouteTree extends AnyRoute, TDehydrated extends Record<string, any>> {
|
|
186
186
|
history?: RouterHistory;
|
|
@@ -202,7 +202,7 @@ interface RouterOptions<TRouteTree extends AnyRoute, TDehydrated extends Record<
|
|
|
202
202
|
router: AnyRouter;
|
|
203
203
|
}) => void;
|
|
204
204
|
onRouteChange?: () => void;
|
|
205
|
-
context?: TRouteTree['
|
|
205
|
+
context?: TRouteTree['types']['routerContext'];
|
|
206
206
|
Wrap?: React.ComponentType<{
|
|
207
207
|
children: React.ReactNode;
|
|
208
208
|
dehydratedState?: TDehydrated;
|
|
@@ -303,7 +303,7 @@ declare class Router<TRouteTree extends AnyRoute = AnyRoute, TDehydrated extends
|
|
|
303
303
|
reload: () => Promise<void>;
|
|
304
304
|
resolvePath: (from: string, path: string) => string;
|
|
305
305
|
navigate: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string = "">({ from, to, search, hash, replace, params, }: NavigateOptions<TRouteTree, TFrom, TTo>) => Promise<void>;
|
|
306
|
-
matchRoute: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string = "", TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>>(location: ToOptions<TRouteTree, TFrom, TTo, ResolveRelativePath<TFrom, NoInfer<TTo>>>, opts?: MatchRouteOptions) => false | RouteById<TRouteTree, TResolved>["
|
|
306
|
+
matchRoute: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string = "", TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>>(location: ToOptions<TRouteTree, TFrom, TTo, ResolveRelativePath<TFrom, NoInfer<TTo>>>, opts?: MatchRouteOptions) => false | RouteById<TRouteTree, TResolved>["types"]["allParams"];
|
|
307
307
|
buildLink: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string = "">({ from, to, search, params, hash, target, replace, activeOptions, preload, preloadDelay: userPreloadDelay, disabled, state, }: LinkOptions<TRouteTree, TFrom, TTo>) => LinkInfo;
|
|
308
308
|
dehydrate: () => DehydratedRouter;
|
|
309
309
|
hydrate: (__do_not_use_server_ctx?: HydrationCtx) => Promise<void>;
|
|
@@ -374,7 +374,7 @@ type MetaOptions = keyof PickRequired<RouteMeta> extends never ? {
|
|
|
374
374
|
type AnyRouteProps = RouteProps<any, any, any, any, any>;
|
|
375
375
|
type ComponentPropsFromRoute<TRoute> = TRoute extends Route<infer TParentRoute, infer TPath, infer TFullPath, infer TCustomId, infer TId, infer TLoader, infer TSearchSchema, infer TFullSearchSchema, infer TParams, infer TAllParams, infer TParentContext, infer TAllParentContext, infer TRouteContext, infer TContext, infer TRouterContext, infer TChildren, infer TRouteTree> ? RouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TContext> : never;
|
|
376
376
|
type ComponentFromRoute<TRoute> = RegisteredRouteComponent<ComponentPropsFromRoute<TRoute>>;
|
|
377
|
-
type RouteLoaderFromRoute<TRoute extends AnyRoute> = LoaderFn<TRoute['
|
|
377
|
+
type RouteLoaderFromRoute<TRoute extends AnyRoute> = LoaderFn<TRoute['types']['loader'], TRoute['types']['searchSchema'], TRoute['types']['fullSearchSchema'], TRoute['types']['allParams'], TRoute['types']['routeContext'], TRoute['types']['context']>;
|
|
378
378
|
type RouteProps<TLoader extends any = unknown, TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TContext extends AnyContext = AnyContext> = {
|
|
379
379
|
useMatch: () => RouteMatch<any, any>;
|
|
380
380
|
useLoader: () => UseLoaderResult<TLoader>;
|
|
@@ -491,11 +491,11 @@ type ResolveId<TParentRoute, TCustomId extends string, TPath extends string> = T
|
|
|
491
491
|
} ? RoutePrefix<TParentId, string extends TCustomId ? TPath : TCustomId> : RootRouteId;
|
|
492
492
|
type InferFullSearchSchema<TRoute> = TRoute extends {
|
|
493
493
|
isRoot: true;
|
|
494
|
-
|
|
494
|
+
types: {
|
|
495
495
|
searchSchema: infer TSearchSchema;
|
|
496
496
|
};
|
|
497
497
|
} ? TSearchSchema : TRoute extends {
|
|
498
|
-
|
|
498
|
+
types: {
|
|
499
499
|
fullSearchSchema: infer TFullSearchSchema;
|
|
500
500
|
};
|
|
501
501
|
} ? TFullSearchSchema : {};
|
|
@@ -531,8 +531,8 @@ type RouteConstraints = {
|
|
|
531
531
|
TChildren: unknown;
|
|
532
532
|
TRouteTree: AnyRoute;
|
|
533
533
|
};
|
|
534
|
-
declare class Route<TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute, TPath extends RouteConstraints['TPath'] = '/', TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, TPath>, TCustomId extends RouteConstraints['TCustomId'] = string, TId extends RouteConstraints['TId'] = ResolveId<TParentRoute, TCustomId, TPath>, TLoader = unknown, TSearchSchema extends RouteConstraints['TSearchSchema'] = {}, TFullSearchSchema extends RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends RouteConstraints['TParams'] = Record<ParsePathParams<TPath>, string>, TAllParams extends RouteConstraints['TAllParams'] = MergeParamsFromParent<TParentRoute['
|
|
535
|
-
|
|
534
|
+
declare class Route<TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute, TPath extends RouteConstraints['TPath'] = '/', TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, TPath>, TCustomId extends RouteConstraints['TCustomId'] = string, TId extends RouteConstraints['TId'] = ResolveId<TParentRoute, TCustomId, TPath>, TLoader = unknown, TSearchSchema extends RouteConstraints['TSearchSchema'] = {}, TFullSearchSchema extends RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends RouteConstraints['TParams'] = Record<ParsePathParams<TPath>, string>, TAllParams extends RouteConstraints['TAllParams'] = MergeParamsFromParent<TParentRoute['types']['allParams'], TParams>, TParentContext extends RouteConstraints['TParentContext'] = TParentRoute['types']['routeContext'], TAllParentContext extends RouteConstraints['TAllParentContext'] = TParentRoute['types']['context'], TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext, TAllContext extends RouteConstraints['TAllContext'] = MergeParamsFromParent<TParentRoute['types']['context'], TRouteContext>, TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext, TChildren extends RouteConstraints['TChildren'] = unknown, TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute> {
|
|
535
|
+
types: {
|
|
536
536
|
parentRoute: TParentRoute;
|
|
537
537
|
path: TPath;
|
|
538
538
|
to: TrimPathRight<TFullPath>;
|
|
@@ -593,12 +593,12 @@ type TrimLeft<T extends string, S extends string> = T extends `${S}${infer U}` ?
|
|
|
593
593
|
type TrimRight<T extends string, S extends string> = T extends `${infer U}${S}` ? U : T;
|
|
594
594
|
type Trim<T extends string, S extends string> = TrimLeft<TrimRight<T, S>, S>;
|
|
595
595
|
type RemoveUnderScores<T extends string> = Replace<Replace<TrimRight<TrimLeft<T, '/_'>, '_'>, '_/', '/'>, '/_', '/'>;
|
|
596
|
-
type ResolveFilePath<TParentRoute extends AnyRoute, TFilePath extends string> = TParentRoute['id'] extends RootRouteId ? TrimPathLeft<TFilePath> : Replace<TrimPathLeft<TFilePath>, TrimPathLeft<TParentRoute['
|
|
596
|
+
type ResolveFilePath<TParentRoute extends AnyRoute, TFilePath extends string> = TParentRoute['id'] extends RootRouteId ? TrimPathLeft<TFilePath> : Replace<TrimPathLeft<TFilePath>, TrimPathLeft<TParentRoute['types']['customId']>, ''>;
|
|
597
597
|
type FileRoutePath<TParentRoute extends AnyRoute, TFilePath extends string> = ResolveFilePath<TParentRoute, TFilePath> extends `_${infer _}` ? string : ResolveFilePath<TParentRoute, TFilePath>;
|
|
598
598
|
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>>> {
|
|
599
599
|
path: TFilePath;
|
|
600
600
|
constructor(path: TFilePath);
|
|
601
|
-
createRoute: <TLoader = unknown, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends Record<string, any> = (TrimLeft<TrimRight<Split<TPath, true>[number], "_">, "_"> extends infer T ? T extends TrimLeft<TrimRight<Split<TPath, true>[number], "_">, "_"> ? T extends `$${infer L}` ? L : never : never : never) extends never ? AnyPathParams : Record<TrimLeft<TrimRight<Split<TPath, true>[number], "_">, "_"> extends infer T ? T extends TrimLeft<TrimRight<Split<TPath, true>[number], "_">, "_"> ? T extends `$${infer L}` ? L : never : never : never, string>, TAllParams extends Record<string, any> = IsAny<TParentRoute["
|
|
601
|
+
createRoute: <TLoader = unknown, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends Record<string, any> = (TrimLeft<TrimRight<Split<TPath, true>[number], "_">, "_"> extends infer T ? T extends TrimLeft<TrimRight<Split<TPath, true>[number], "_">, "_"> ? T extends `$${infer L}` ? L : never : never : never) extends never ? AnyPathParams : Record<TrimLeft<TrimRight<Split<TPath, true>[number], "_">, "_"> extends infer T ? T extends TrimLeft<TrimRight<Split<TPath, true>[number], "_">, "_"> ? T extends `$${infer L}` ? L : never : never : never, string>, TAllParams extends Record<string, any> = 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 = 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"> & {
|
|
602
602
|
meta?: RouteMeta | undefined;
|
|
603
603
|
} & {
|
|
604
604
|
key?: false | GetKeyFn<TFullSearchSchema, TAllParams> | null | undefined;
|
|
@@ -677,7 +677,7 @@ type ToOptions<TRouteTree extends AnyRoute = AnyRoute, TFrom extends RoutePaths<
|
|
|
677
677
|
state?: LocationState;
|
|
678
678
|
from?: TFrom;
|
|
679
679
|
} & CheckPath<TRouteTree, NoInfer<TResolvedTo>, {}> & SearchParamOptions<TRouteTree, TFrom, TResolvedTo> & PathParamOptions<TRouteTree, TFrom, TResolvedTo>;
|
|
680
|
-
type SearchParamOptions<TRouteTree extends AnyRoute, TFrom, TTo, TFromSchema = UnionToIntersection<FullSearchSchema<TRouteTree> & RouteByPath<TRouteTree, TFrom> extends never ? {} : RouteByPath<TRouteTree, TFrom>['
|
|
680
|
+
type SearchParamOptions<TRouteTree extends AnyRoute, TFrom, TTo, TFromSchema = UnionToIntersection<FullSearchSchema<TRouteTree> & RouteByPath<TRouteTree, TFrom> extends never ? {} : RouteByPath<TRouteTree, TFrom>['types']['fullSearchSchema']>, TToSchema = Partial<RouteByPath<TRouteTree, TFrom>['types']['fullSearchSchema']> & Omit<RouteByPath<TRouteTree, TTo>['types']['fullSearchSchema'], keyof PickRequired<RouteByPath<TRouteTree, TFrom>['types']['fullSearchSchema']>>, TFromFullSchema = UnionToIntersection<FullSearchSchema<TRouteTree> & TFromSchema>, TToFullSchema = UnionToIntersection<FullSearchSchema<TRouteTree> & TToSchema>> = keyof PickRequired<TToSchema> extends never ? {
|
|
681
681
|
search?: true | SearchReducer<TFromFullSchema, TToFullSchema>;
|
|
682
682
|
} : {
|
|
683
683
|
search: SearchReducer<TFromFullSchema, TToFullSchema>;
|
|
@@ -685,7 +685,7 @@ type SearchParamOptions<TRouteTree extends AnyRoute, TFrom, TTo, TFromSchema = U
|
|
|
685
685
|
type SearchReducer<TFrom, TTo> = {
|
|
686
686
|
[TKey in keyof TTo]: TTo[TKey];
|
|
687
687
|
} | ((current: TFrom) => TTo);
|
|
688
|
-
type PathParamOptions<TRouteTree extends AnyRoute, TFrom, TTo, TFromSchema = UnionToIntersection<RouteByPath<TRouteTree, TFrom> extends never ? {} : RouteByPath<TRouteTree, TFrom>['
|
|
688
|
+
type PathParamOptions<TRouteTree extends AnyRoute, TFrom, TTo, TFromSchema = UnionToIntersection<RouteByPath<TRouteTree, TFrom> extends never ? {} : RouteByPath<TRouteTree, TFrom>['types']['allParams']>, TToSchema = Partial<RouteByPath<TRouteTree, TFrom>['types']['allParams']> & Omit<RouteByPath<TRouteTree, TTo>['types']['allParams'], keyof PickRequired<RouteByPath<TRouteTree, TFrom>['types']['allParams']>>, TFromFullParams = UnionToIntersection<AllParams<TRouteTree> & TFromSchema>, TToFullParams = UnionToIntersection<AllParams<TRouteTree> & TToSchema>> = keyof PickRequired<TToSchema> extends never ? {
|
|
689
689
|
params?: ParamsReducer<TFromFullParams, TToFullParams>;
|
|
690
690
|
} : {
|
|
691
691
|
params: ParamsReducer<TFromFullParams, TToFullParams>;
|
|
@@ -811,7 +811,6 @@
|
|
|
811
811
|
onUpdate: () => {
|
|
812
812
|
const prev = this.state;
|
|
813
813
|
const next = this.__store.state;
|
|
814
|
-
console.log(Object.values(next.matchesById).find(d => d.status === 'error'));
|
|
815
814
|
const matchesByIdChanged = prev.matchesById !== next.matchesById;
|
|
816
815
|
let matchesChanged;
|
|
817
816
|
let pendingMatchesChanged;
|
|
@@ -1238,7 +1237,6 @@
|
|
|
1238
1237
|
throw errorHandlerErr;
|
|
1239
1238
|
}
|
|
1240
1239
|
}
|
|
1241
|
-
console.log('set error');
|
|
1242
1240
|
this.setRouteMatch(match.id, s => ({
|
|
1243
1241
|
...s,
|
|
1244
1242
|
error: err,
|
|
@@ -1291,17 +1289,17 @@
|
|
|
1291
1289
|
const latest = this.getRouteMatch(match.id);
|
|
1292
1290
|
return latest && latest.fetchedAt !== fetchedAt ? latest.loadPromise : undefined;
|
|
1293
1291
|
};
|
|
1292
|
+
const handleIfRedirect = err => {
|
|
1293
|
+
if (isRedirect(err)) {
|
|
1294
|
+
if (!opts?.preload) {
|
|
1295
|
+
this.navigate(err);
|
|
1296
|
+
}
|
|
1297
|
+
return true;
|
|
1298
|
+
}
|
|
1299
|
+
return false;
|
|
1300
|
+
};
|
|
1294
1301
|
const load = async () => {
|
|
1295
1302
|
let latestPromise;
|
|
1296
|
-
const handleError = err => {
|
|
1297
|
-
if (isRedirect(err)) {
|
|
1298
|
-
if (!opts?.preload) {
|
|
1299
|
-
this.navigate(err);
|
|
1300
|
-
}
|
|
1301
|
-
return true;
|
|
1302
|
-
}
|
|
1303
|
-
return false;
|
|
1304
|
-
};
|
|
1305
1303
|
try {
|
|
1306
1304
|
const componentsPromise = Promise.all(componentTypes.map(async type => {
|
|
1307
1305
|
const component = route.options[type];
|
|
@@ -1318,39 +1316,48 @@
|
|
|
1318
1316
|
if (latestPromise = checkLatest()) return await latestPromise;
|
|
1319
1317
|
this.setRouteMatchData(match.id, () => loader, opts);
|
|
1320
1318
|
} catch (loaderError) {
|
|
1319
|
+
let latestError = loaderError;
|
|
1321
1320
|
if (latestPromise = checkLatest()) return await latestPromise;
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1321
|
+
if (handleIfRedirect(loaderError)) return;
|
|
1322
|
+
if (route.options.onLoadError) {
|
|
1323
|
+
try {
|
|
1324
|
+
route.options.onLoadError(loaderError);
|
|
1325
|
+
} catch (onLoadError) {
|
|
1326
|
+
latestError = onLoadError;
|
|
1327
|
+
if (handleIfRedirect(onLoadError)) return;
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
if ((!route.options.onLoadError || latestError !== loaderError) && route.options.onError) {
|
|
1331
|
+
try {
|
|
1332
|
+
route.options.onError(latestError);
|
|
1333
|
+
} catch (onErrorError) {
|
|
1334
|
+
if (handleIfRedirect(onErrorError)) return;
|
|
1329
1335
|
}
|
|
1330
|
-
} catch (errorHandlerErr) {
|
|
1331
|
-
error = errorHandlerErr;
|
|
1332
|
-
handleError(error);
|
|
1333
1336
|
}
|
|
1334
|
-
console.log('set error');
|
|
1335
1337
|
this.setRouteMatch(match.id, s => ({
|
|
1336
1338
|
...s,
|
|
1337
|
-
error:
|
|
1339
|
+
error: loaderError,
|
|
1338
1340
|
status: 'error',
|
|
1339
1341
|
isFetching: false,
|
|
1340
1342
|
updatedAt: Date.now()
|
|
1341
1343
|
}));
|
|
1342
|
-
console.log(this.getRouteMatch(match.id)?.status);
|
|
1343
1344
|
}
|
|
1344
1345
|
};
|
|
1345
|
-
|
|
1346
|
-
this.
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1346
|
+
let loadPromise;
|
|
1347
|
+
this.__store.batch(() => {
|
|
1348
|
+
this.setRouteMatch(match.id, s => ({
|
|
1349
|
+
...s,
|
|
1350
|
+
// status: s.status !== 'success' ? 'pending' : s.status,
|
|
1351
|
+
isFetching: true,
|
|
1352
|
+
fetchedAt,
|
|
1353
|
+
invalid: false
|
|
1354
|
+
}));
|
|
1355
|
+
loadPromise = load();
|
|
1356
|
+
this.setRouteMatch(match.id, s => ({
|
|
1357
|
+
...s,
|
|
1358
|
+
loadPromise
|
|
1359
|
+
}));
|
|
1360
|
+
});
|
|
1354
1361
|
await loadPromise;
|
|
1355
1362
|
})());
|
|
1356
1363
|
});
|
|
@@ -1786,7 +1793,6 @@
|
|
|
1786
1793
|
const updatedAt = opts?.updatedAt ?? Date.now();
|
|
1787
1794
|
const preloadInvalidAt = updatedAt + (opts?.maxAge ?? route.options.preloadMaxAge ?? this.options.defaultPreloadMaxAge ?? 5000);
|
|
1788
1795
|
const invalidAt = updatedAt + (opts?.maxAge ?? route.options.maxAge ?? this.options.defaultMaxAge ?? Infinity);
|
|
1789
|
-
console.log('set success');
|
|
1790
1796
|
this.setRouteMatch(id, s => ({
|
|
1791
1797
|
...s,
|
|
1792
1798
|
error: undefined,
|