tanstack-router-cache 0.1.8 → 0.1.10
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/dist/index.d.ts +1 -1
- package/dist/route-cache-static-data.d.ts +31 -2
- package/dist/types.d.ts +7 -31
- package/docs/types.md +5 -11
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,13 +2,13 @@ import type { RouteCacheStaticOption } from "./types";
|
|
|
2
2
|
export { RouterCacheOutlet } from "./components/router-cache-outlet";
|
|
3
3
|
export type { CachedRouteData, CachedRoutes } from "./contexts/router-cache";
|
|
4
4
|
export { RouterCacheProvider } from "./contexts/router-cache";
|
|
5
|
-
export { defineRouteCache } from "./route-cache-static-data";
|
|
6
5
|
export { useRouteCacheActive } from "./hooks/use-route-cache-active";
|
|
7
6
|
export { useRouteCacheActivity } from "./hooks/use-route-cache-activity";
|
|
8
7
|
export { useRouteCacheEffect } from "./hooks/use-route-cache-effect";
|
|
9
8
|
export { useRouteCacheErrorBoundary } from "./hooks/use-route-cache-error-boundary";
|
|
10
9
|
export { useRouteCacheNavigation } from "./hooks/use-route-cache-navigation";
|
|
11
10
|
export { useRouterCache } from "./hooks/use-router-cache";
|
|
11
|
+
export { defineRouteCache } from "./route-cache-static-data";
|
|
12
12
|
export type * from "./types";
|
|
13
13
|
declare module "@tanstack/react-router" {
|
|
14
14
|
interface StaticDataRouteOption {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { StaticDataRouteOption } from "@tanstack/react-router";
|
|
2
|
-
import type { RouteCacheRouteOptions } from "./types";
|
|
3
2
|
type CachedRouteTiming = {
|
|
4
3
|
createdAt?: number;
|
|
5
4
|
staticData: StaticDataRouteOption;
|
|
@@ -10,7 +9,37 @@ type CachedRouteTiming = {
|
|
|
10
9
|
* TanStack Router loader-cache options are returned at the route-option level,
|
|
11
10
|
* while route-cache-specific options are stored under `staticData.routeCache`.
|
|
12
11
|
*/
|
|
13
|
-
export declare function defineRouteCache(options?:
|
|
12
|
+
export declare function defineRouteCache(options?: {
|
|
13
|
+
/**
|
|
14
|
+
* Maximum age, in milliseconds, for a retained route view.
|
|
15
|
+
*
|
|
16
|
+
* Expired cached views are not restored. This only controls the retained
|
|
17
|
+
* mounted view; use TanStack Router's `staleTime`, `preloadStaleTime`,
|
|
18
|
+
* and `gcTime` route options for loader-data caching.
|
|
19
|
+
*
|
|
20
|
+
* @defaultValue `Infinity`
|
|
21
|
+
*/
|
|
22
|
+
maxAge?: number;
|
|
23
|
+
/**
|
|
24
|
+
* TanStack Router loader garbage-collection time, in milliseconds.
|
|
25
|
+
*
|
|
26
|
+
* This is returned as a top-level route option.
|
|
27
|
+
*/
|
|
28
|
+
gcTime?: number;
|
|
29
|
+
/**
|
|
30
|
+
* TanStack Router preload freshness time, in milliseconds.
|
|
31
|
+
*
|
|
32
|
+
* This is returned as a top-level route option.
|
|
33
|
+
*/
|
|
34
|
+
preloadStaleTime?: number;
|
|
35
|
+
/**
|
|
36
|
+
* TanStack Router loader freshness time, in milliseconds.
|
|
37
|
+
*
|
|
38
|
+
* This is returned as a top-level route option and does not control the
|
|
39
|
+
* retained route view lifetime. Use `maxAge` for that.
|
|
40
|
+
*/
|
|
41
|
+
staleTime?: number;
|
|
42
|
+
}): {
|
|
14
43
|
staticData: {
|
|
15
44
|
routeCache: boolean | {
|
|
16
45
|
maxAge: number;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,46 +1,22 @@
|
|
|
1
1
|
/** Visibility mode for a cached route container. */
|
|
2
2
|
export type ActivityMode = "visible" | "hidden";
|
|
3
|
-
/** Route-cache options stored in TanStack Router `staticData.routeCache`. */
|
|
4
|
-
export type RouteCacheOptions = {
|
|
5
|
-
/**
|
|
6
|
-
* Maximum age, in milliseconds, for a retained route view.
|
|
7
|
-
*
|
|
8
|
-
* Expired cached views are not restored. This only controls the retained
|
|
9
|
-
* mounted view; use TanStack Router's `staleTime`, `preloadStaleTime`, and
|
|
10
|
-
* `gcTime` route options for loader-data caching.
|
|
11
|
-
*
|
|
12
|
-
* @defaultValue `Infinity`
|
|
13
|
-
*/
|
|
14
|
-
maxAge?: number;
|
|
15
|
-
};
|
|
16
3
|
/**
|
|
17
4
|
* Static route-cache opt-in value.
|
|
18
5
|
*
|
|
19
6
|
* Use `true` to keep the route view cached with default behavior, or an object
|
|
20
7
|
* when the retained view needs route-cache-specific options.
|
|
21
8
|
*/
|
|
22
|
-
export type RouteCacheStaticOption = boolean |
|
|
23
|
-
/** Options accepted by `defineRouteCache`. */
|
|
24
|
-
export type RouteCacheRouteOptions = RouteCacheOptions & {
|
|
9
|
+
export type RouteCacheStaticOption = boolean | {
|
|
25
10
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* This is returned as a top-level route option.
|
|
29
|
-
*/
|
|
30
|
-
gcTime?: number;
|
|
31
|
-
/**
|
|
32
|
-
* TanStack Router preload freshness time, in milliseconds.
|
|
11
|
+
* Maximum age, in milliseconds, for a retained route view.
|
|
33
12
|
*
|
|
34
|
-
*
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* TanStack Router loader freshness time, in milliseconds.
|
|
13
|
+
* Expired cached views are not restored. This only controls the retained
|
|
14
|
+
* mounted view; use TanStack Router's `staleTime`, `preloadStaleTime`,
|
|
15
|
+
* and `gcTime` route options for loader-data caching.
|
|
39
16
|
*
|
|
40
|
-
*
|
|
41
|
-
* retained route view lifetime. Use `maxAge` for that.
|
|
17
|
+
* @defaultValue `Infinity`
|
|
42
18
|
*/
|
|
43
|
-
|
|
19
|
+
maxAge?: number;
|
|
44
20
|
};
|
|
45
21
|
/** Emitted when navigation to a ready cached route begins. */
|
|
46
22
|
export type RouteCacheNavigationStart = {
|
package/docs/types.md
CHANGED
|
@@ -5,17 +5,11 @@
|
|
|
5
5
|
```ts
|
|
6
6
|
export type ActivityMode = "visible" | "hidden";
|
|
7
7
|
|
|
8
|
-
export type
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export type RouteCacheRouteOptions = RouteCacheOptions & {
|
|
15
|
-
gcTime?: number;
|
|
16
|
-
preloadStaleTime?: number;
|
|
17
|
-
staleTime?: number;
|
|
18
|
-
};
|
|
8
|
+
export type RouteCacheStaticOption =
|
|
9
|
+
| boolean
|
|
10
|
+
| {
|
|
11
|
+
maxAge?: number;
|
|
12
|
+
};
|
|
19
13
|
|
|
20
14
|
export type RouteCacheNavigationStart = {
|
|
21
15
|
pathname: string;
|