@tanstack/query-async-storage-persister 5.101.3 → 5.102.0

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 (53) hide show
  1. package/build/legacy/asyncThrottle.cjs +31 -62
  2. package/build/legacy/asyncThrottle.cjs.map +1 -1
  3. package/build/legacy/asyncThrottle.d.cts +9 -1
  4. package/build/legacy/asyncThrottle.d.cts.map +1 -0
  5. package/build/legacy/asyncThrottle.d.ts +9 -1
  6. package/build/legacy/asyncThrottle.d.ts.map +1 -0
  7. package/build/legacy/asyncThrottle.js +28 -35
  8. package/build/legacy/asyncThrottle.js.map +1 -1
  9. package/build/legacy/index.cjs +45 -83
  10. package/build/legacy/index.cjs.map +1 -1
  11. package/build/legacy/index.d.cts +34 -2
  12. package/build/legacy/index.d.cts.map +1 -0
  13. package/build/legacy/index.d.ts +34 -2
  14. package/build/legacy/index.d.ts.map +1 -0
  15. package/build/legacy/index.js +44 -58
  16. package/build/legacy/index.js.map +1 -1
  17. package/build/legacy/utils.cjs +5 -30
  18. package/build/legacy/utils.cjs.map +1 -1
  19. package/build/legacy/utils.d.cts +6 -1
  20. package/build/legacy/utils.d.cts.map +1 -0
  21. package/build/legacy/utils.d.ts +6 -1
  22. package/build/legacy/utils.d.ts.map +1 -0
  23. package/build/legacy/utils.js +5 -6
  24. package/build/legacy/utils.js.map +1 -1
  25. package/build/modern/asyncThrottle.cjs +31 -62
  26. package/build/modern/asyncThrottle.cjs.map +1 -1
  27. package/build/modern/asyncThrottle.d.cts +9 -1
  28. package/build/modern/asyncThrottle.d.cts.map +1 -0
  29. package/build/modern/asyncThrottle.d.ts +9 -1
  30. package/build/modern/asyncThrottle.d.ts.map +1 -0
  31. package/build/modern/asyncThrottle.js +28 -35
  32. package/build/modern/asyncThrottle.js.map +1 -1
  33. package/build/modern/index.cjs +45 -83
  34. package/build/modern/index.cjs.map +1 -1
  35. package/build/modern/index.d.cts +34 -2
  36. package/build/modern/index.d.cts.map +1 -0
  37. package/build/modern/index.d.ts +34 -2
  38. package/build/modern/index.d.ts.map +1 -0
  39. package/build/modern/index.js +44 -58
  40. package/build/modern/index.js.map +1 -1
  41. package/build/modern/utils.cjs +5 -30
  42. package/build/modern/utils.cjs.map +1 -1
  43. package/build/modern/utils.d.cts +6 -1
  44. package/build/modern/utils.d.cts.map +1 -0
  45. package/build/modern/utils.d.ts +6 -1
  46. package/build/modern/utils.d.ts.map +1 -0
  47. package/build/modern/utils.js +5 -6
  48. package/build/modern/utils.js.map +1 -1
  49. package/package.json +5 -7
  50. package/build/legacy/_tsup-dts-rollup.d.cts +0 -50
  51. package/build/legacy/_tsup-dts-rollup.d.ts +0 -50
  52. package/build/modern/_tsup-dts-rollup.d.cts +0 -50
  53. package/build/modern/_tsup-dts-rollup.d.ts +0 -50
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { asyncThrottle } from './asyncThrottle'\nimport { noop } from './utils'\nimport type {\n AsyncStorage,\n MaybePromise,\n PersistedClient,\n Persister,\n Promisable,\n} from '@tanstack/query-persist-client-core'\n\nexport type AsyncPersistRetryer = (props: {\n persistedClient: PersistedClient\n error: Error\n errorCount: number\n}) => Promisable<PersistedClient | undefined>\n\ninterface CreateAsyncStoragePersisterOptions {\n /** The storage client used for setting and retrieving items from cache.\n * For SSR pass in `undefined`. Note that window.localStorage can be\n * `null` in Android WebViews depending on how they are configured.\n */\n storage: AsyncStorage<string> | undefined | null\n /** The key to use when storing the cache */\n key?: string\n /** To avoid spamming,\n * pass a time in ms to throttle saving the cache to disk */\n throttleTime?: number\n /**\n * How to serialize the data to storage.\n * @default `JSON.stringify`\n */\n serialize?: (client: PersistedClient) => MaybePromise<string>\n /**\n * How to deserialize the data from storage.\n * @default `JSON.parse`\n */\n deserialize?: (cachedString: string) => MaybePromise<PersistedClient>\n\n retry?: AsyncPersistRetryer\n}\n\nexport const createAsyncStoragePersister = ({\n storage,\n key = `REACT_QUERY_OFFLINE_CACHE`,\n throttleTime = 1000,\n serialize = JSON.stringify,\n deserialize = JSON.parse,\n retry,\n}: CreateAsyncStoragePersisterOptions): Persister => {\n if (storage) {\n const trySave = async (\n persistedClient: PersistedClient,\n ): Promise<Error | undefined> => {\n try {\n const serialized = await serialize(persistedClient)\n await storage.setItem(key, serialized)\n return\n } catch (error) {\n return error as Error\n }\n }\n\n return {\n persistClient: asyncThrottle(\n async (persistedClient) => {\n let client: PersistedClient | undefined = persistedClient\n let error = await trySave(client)\n let errorCount = 0\n while (error && client) {\n errorCount++\n client = await retry?.({\n persistedClient: client,\n error,\n errorCount,\n })\n\n if (client) {\n error = await trySave(client)\n }\n }\n },\n { interval: throttleTime },\n ),\n restoreClient: async () => {\n const cacheString = await storage.getItem(key)\n\n if (!cacheString) {\n return\n }\n\n return await deserialize(cacheString)\n },\n removeClient: () => storage.removeItem(key),\n }\n }\n\n return {\n persistClient: noop,\n restoreClient: () => Promise.resolve(undefined),\n removeClient: noop,\n }\n}\n"],"mappings":";AAAA,SAAS,qBAAqB;AAC9B,SAAS,YAAY;AAwCd,IAAM,8BAA8B,CAAC;AAAA,EAC1C;AAAA,EACA,MAAM;AAAA,EACN,eAAe;AAAA,EACf,YAAY,KAAK;AAAA,EACjB,cAAc,KAAK;AAAA,EACnB;AACF,MAAqD;AACnD,MAAI,SAAS;AACX,UAAM,UAAU,OACd,oBAC+B;AAC/B,UAAI;AACF,cAAM,aAAa,MAAM,UAAU,eAAe;AAClD,cAAM,QAAQ,QAAQ,KAAK,UAAU;AACrC;AAAA,MACF,SAAS,OAAO;AACd,eAAO;AAAA,MACT;AAAA,IACF;AAEA,WAAO;AAAA,MACL,eAAe;AAAA,QACb,OAAO,oBAAoB;AACzB,cAAI,SAAsC;AAC1C,cAAI,QAAQ,MAAM,QAAQ,MAAM;AAChC,cAAI,aAAa;AACjB,iBAAO,SAAS,QAAQ;AACtB;AACA,qBAAS,MAAM,QAAQ;AAAA,cACrB,iBAAiB;AAAA,cACjB;AAAA,cACA;AAAA,YACF,CAAC;AAED,gBAAI,QAAQ;AACV,sBAAQ,MAAM,QAAQ,MAAM;AAAA,YAC9B;AAAA,UACF;AAAA,QACF;AAAA,QACA,EAAE,UAAU,aAAa;AAAA,MAC3B;AAAA,MACA,eAAe,YAAY;AACzB,cAAM,cAAc,MAAM,QAAQ,QAAQ,GAAG;AAE7C,YAAI,CAAC,aAAa;AAChB;AAAA,QACF;AAEA,eAAO,MAAM,YAAY,WAAW;AAAA,MACtC;AAAA,MACA,cAAc,MAAM,QAAQ,WAAW,GAAG;AAAA,IAC5C;AAAA,EACF;AAEA,SAAO;AAAA,IACL,eAAe;AAAA,IACf,eAAe,MAAM,QAAQ,QAAQ,MAAS;AAAA,IAC9C,cAAc;AAAA,EAChB;AACF;","names":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["import { asyncThrottle } from './asyncThrottle'\nimport { noop } from './utils'\nimport type {\n AsyncStorage,\n MaybePromise,\n PersistedClient,\n Persister,\n Promisable,\n} from '@tanstack/query-persist-client-core'\n\nexport type AsyncPersistRetryer = (props: {\n persistedClient: PersistedClient\n error: Error\n errorCount: number\n}) => Promisable<PersistedClient | undefined>\n\ninterface CreateAsyncStoragePersisterOptions {\n /** The storage client used for setting and retrieving items from cache.\n * For SSR pass in `undefined`. Note that window.localStorage can be\n * `null` in Android WebViews depending on how they are configured.\n */\n storage: AsyncStorage<string> | undefined | null\n /** The key to use when storing the cache */\n key?: string\n /** To avoid spamming,\n * pass a time in ms to throttle saving the cache to disk */\n throttleTime?: number\n /**\n * How to serialize the data to storage.\n * @default `JSON.stringify`\n */\n serialize?: (client: PersistedClient) => MaybePromise<string>\n /**\n * How to deserialize the data from storage.\n * @default `JSON.parse`\n */\n deserialize?: (cachedString: string) => MaybePromise<PersistedClient>\n\n retry?: AsyncPersistRetryer\n}\n\nexport const createAsyncStoragePersister = ({\n storage,\n key = `REACT_QUERY_OFFLINE_CACHE`,\n throttleTime = 1000,\n serialize = JSON.stringify,\n deserialize = JSON.parse,\n retry,\n}: CreateAsyncStoragePersisterOptions): Persister => {\n if (storage) {\n const trySave = async (\n persistedClient: PersistedClient,\n ): Promise<Error | undefined> => {\n try {\n const serialized = await serialize(persistedClient)\n await storage.setItem(key, serialized)\n return\n } catch (error) {\n return error as Error\n }\n }\n\n return {\n persistClient: asyncThrottle(\n async (persistedClient) => {\n let client: PersistedClient | undefined = persistedClient\n let error = await trySave(client)\n let errorCount = 0\n while (error && client) {\n errorCount++\n client = await retry?.({\n persistedClient: client,\n error,\n errorCount,\n })\n\n if (client) {\n error = await trySave(client)\n }\n }\n },\n { interval: throttleTime },\n ),\n restoreClient: async () => {\n const cacheString = await storage.getItem(key)\n\n if (!cacheString) {\n return\n }\n\n return await deserialize(cacheString)\n },\n removeClient: () => storage.removeItem(key),\n }\n }\n\n return {\n persistClient: noop,\n restoreClient: () => Promise.resolve(undefined),\n removeClient: noop,\n }\n}\n"],"mappings":";;;AAyCA,MAAa,+BAA+B,EAC1C,SACA,MAAM,6BACN,eAAe,KACf,YAAY,KAAK,WACjB,cAAc,KAAK,OACnB,YACmD;CACnD,IAAI,SAAS;EACX,MAAM,UAAU,OACd,oBAC+B;GAC/B,IAAI;IACF,MAAM,aAAa,MAAM,UAAU,eAAe;IAClD,MAAM,QAAQ,QAAQ,KAAK,UAAU;IACrC;GACF,SAAS,OAAO;IACd,OAAO;GACT;EACF;EAEA,OAAO;GACL,eAAe,cACb,OAAO,oBAAoB;IACzB,IAAI,SAAsC;IAC1C,IAAI,QAAQ,MAAM,QAAQ,MAAM;IAChC,IAAI,aAAa;IACjB,OAAO,SAAS,QAAQ;KACtB;KACA,SAAS,MAAM,QAAQ;MACrB,iBAAiB;MACjB;MACA;KACF,CAAC;KAED,IAAI,QACF,QAAQ,MAAM,QAAQ,MAAM;IAEhC;GACF,GACA,EAAE,UAAU,aAAa,CAC3B;GACA,eAAe,YAAY;IACzB,MAAM,cAAc,MAAM,QAAQ,QAAQ,GAAG;IAE7C,IAAI,CAAC,aACH;IAGF,OAAO,MAAM,YAAY,WAAW;GACtC;GACA,oBAAoB,QAAQ,WAAW,GAAG;EAC5C;CACF;CAEA,OAAO;EACL,eAAe;EACf,qBAAqB,QAAQ,QAAQ,KAAA,CAAS;EAC9C,cAAc;CAChB;AACF"}
@@ -1,32 +1,7 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/utils.ts
3
+ function noop() {}
4
+ //#endregion
5
+ exports.noop = noop;
19
6
 
20
- // src/utils.ts
21
- var utils_exports = {};
22
- __export(utils_exports, {
23
- noop: () => noop
24
- });
25
- module.exports = __toCommonJS(utils_exports);
26
- function noop() {
27
- }
28
- // Annotate the CommonJS export names for ESM import in node:
29
- 0 && (module.exports = {
30
- noop
31
- });
32
7
  //# sourceMappingURL=utils.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils.ts"],"sourcesContent":["export function noop(): void\nexport function noop(): undefined\nexport function noop() {}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,SAAS,OAAO;AAAC;","names":[]}
1
+ {"version":3,"file":"utils.cjs","names":[],"sources":["../../src/utils.ts"],"sourcesContent":["export function noop(): void\nexport function noop(): undefined\nexport function noop() {}\n"],"mappings":";;AAEA,SAAgB,OAAO,CAAC"}
@@ -1 +1,6 @@
1
- export { noop } from './_tsup-dts-rollup.cjs';
1
+ //#region src/utils.d.ts
2
+ declare function noop(): void;
3
+ declare function noop(): undefined;
4
+ //#endregion
5
+ export { noop };
6
+ //# sourceMappingURL=utils.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.cts","names":[],"sources":["../../src/utils.ts"],"mappings":";iBAAgB;iBACA"}
@@ -1 +1,6 @@
1
- export { noop } from './_tsup-dts-rollup.js';
1
+ //#region src/utils.d.ts
2
+ declare function noop(): void;
3
+ declare function noop(): undefined;
4
+ //#endregion
5
+ export { noop };
6
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","names":[],"sources":["../../src/utils.ts"],"mappings":";iBAAgB;iBACA"}
@@ -1,7 +1,6 @@
1
- // src/utils.ts
2
- function noop() {
3
- }
4
- export {
5
- noop
6
- };
1
+ //#region src/utils.ts
2
+ function noop() {}
3
+ //#endregion
4
+ export { noop };
5
+
7
6
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils.ts"],"sourcesContent":["export function noop(): void\nexport function noop(): undefined\nexport function noop() {}\n"],"mappings":";AAEO,SAAS,OAAO;AAAC;","names":[]}
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../../src/utils.ts"],"sourcesContent":["export function noop(): void\nexport function noop(): undefined\nexport function noop() {}\n"],"mappings":";AAEA,SAAgB,OAAO,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/query-async-storage-persister",
3
- "version": "5.101.3",
3
+ "version": "5.102.0",
4
4
  "description": "A persister for asynchronous storages, to be used with TanStack/Query",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -40,8 +40,8 @@
40
40
  "!src/__tests__"
41
41
  ],
42
42
  "dependencies": {
43
- "@tanstack/query-core": "5.101.3",
44
- "@tanstack/query-persist-client-core": "5.101.3"
43
+ "@tanstack/query-core": "5.102.0",
44
+ "@tanstack/query-persist-client-core": "5.102.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "npm-run-all2": "^5.0.0",
@@ -52,17 +52,15 @@
52
52
  "compile": "tsc --build",
53
53
  "test:eslint": "eslint --concurrency=auto ./src",
54
54
  "test:types": "npm-run-all --serial test:types:*",
55
- "test:types:ts54": "node ../../node_modules/typescript54/lib/tsc.js --build",
56
- "test:types:ts55": "node ../../node_modules/typescript55/lib/tsc.js --build",
57
55
  "test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js --build",
58
56
  "test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js --build",
59
57
  "test:types:ts58": "node ../../node_modules/typescript58/lib/tsc.js --build",
60
58
  "test:types:ts59": "node ../../node_modules/typescript59/lib/tsc.js --build",
61
59
  "test:types:tscurrent": "tsc --build",
62
- "test:types:ts60": "node ../../node_modules/typescript60/lib/tsc.js --build",
60
+ "test:types:ts70": "node ../../node_modules/typescript70/lib/tsc.js --build",
63
61
  "test:lib": "vitest",
64
62
  "test:lib:dev": "pnpm run test:lib --watch",
65
63
  "test:build": "publint --strict && attw --pack",
66
- "build": "tsup --tsconfig tsconfig.prod.json"
64
+ "build": "tsdown --tsconfig tsconfig.prod.json"
67
65
  }
68
66
  }
@@ -1,50 +0,0 @@
1
- import type { AsyncStorage } from '@tanstack/query-persist-client-core';
2
- import type { MaybePromise } from '@tanstack/query-persist-client-core';
3
- import type { PersistedClient } from '@tanstack/query-persist-client-core';
4
- import type { Persister } from '@tanstack/query-persist-client-core';
5
- import type { Promisable } from '@tanstack/query-persist-client-core';
6
-
7
- export declare type AsyncPersistRetryer = (props: {
8
- persistedClient: PersistedClient;
9
- error: Error;
10
- errorCount: number;
11
- }) => Promisable<PersistedClient | undefined>;
12
-
13
- export declare function asyncThrottle<TArgs extends ReadonlyArray<unknown>>(func: (...args: TArgs) => Promise<void>, { interval, onError }?: AsyncThrottleOptions): (...args: TArgs) => Promise<void>;
14
-
15
- declare interface AsyncThrottleOptions {
16
- interval?: number;
17
- onError?: (error: unknown) => void;
18
- }
19
-
20
- export declare const createAsyncStoragePersister: ({ storage, key, throttleTime, serialize, deserialize, retry, }: CreateAsyncStoragePersisterOptions) => Persister;
21
-
22
- declare interface CreateAsyncStoragePersisterOptions {
23
- /** The storage client used for setting and retrieving items from cache.
24
- * For SSR pass in `undefined`. Note that window.localStorage can be
25
- * `null` in Android WebViews depending on how they are configured.
26
- */
27
- storage: AsyncStorage<string> | undefined | null;
28
- /** The key to use when storing the cache */
29
- key?: string;
30
- /** To avoid spamming,
31
- * pass a time in ms to throttle saving the cache to disk */
32
- throttleTime?: number;
33
- /**
34
- * How to serialize the data to storage.
35
- * @default `JSON.stringify`
36
- */
37
- serialize?: (client: PersistedClient) => MaybePromise<string>;
38
- /**
39
- * How to deserialize the data from storage.
40
- * @default `JSON.parse`
41
- */
42
- deserialize?: (cachedString: string) => MaybePromise<PersistedClient>;
43
- retry?: AsyncPersistRetryer;
44
- }
45
-
46
- export declare function noop(): void;
47
-
48
- export declare function noop(): undefined;
49
-
50
- export { }
@@ -1,50 +0,0 @@
1
- import type { AsyncStorage } from '@tanstack/query-persist-client-core';
2
- import type { MaybePromise } from '@tanstack/query-persist-client-core';
3
- import type { PersistedClient } from '@tanstack/query-persist-client-core';
4
- import type { Persister } from '@tanstack/query-persist-client-core';
5
- import type { Promisable } from '@tanstack/query-persist-client-core';
6
-
7
- export declare type AsyncPersistRetryer = (props: {
8
- persistedClient: PersistedClient;
9
- error: Error;
10
- errorCount: number;
11
- }) => Promisable<PersistedClient | undefined>;
12
-
13
- export declare function asyncThrottle<TArgs extends ReadonlyArray<unknown>>(func: (...args: TArgs) => Promise<void>, { interval, onError }?: AsyncThrottleOptions): (...args: TArgs) => Promise<void>;
14
-
15
- declare interface AsyncThrottleOptions {
16
- interval?: number;
17
- onError?: (error: unknown) => void;
18
- }
19
-
20
- export declare const createAsyncStoragePersister: ({ storage, key, throttleTime, serialize, deserialize, retry, }: CreateAsyncStoragePersisterOptions) => Persister;
21
-
22
- declare interface CreateAsyncStoragePersisterOptions {
23
- /** The storage client used for setting and retrieving items from cache.
24
- * For SSR pass in `undefined`. Note that window.localStorage can be
25
- * `null` in Android WebViews depending on how they are configured.
26
- */
27
- storage: AsyncStorage<string> | undefined | null;
28
- /** The key to use when storing the cache */
29
- key?: string;
30
- /** To avoid spamming,
31
- * pass a time in ms to throttle saving the cache to disk */
32
- throttleTime?: number;
33
- /**
34
- * How to serialize the data to storage.
35
- * @default `JSON.stringify`
36
- */
37
- serialize?: (client: PersistedClient) => MaybePromise<string>;
38
- /**
39
- * How to deserialize the data from storage.
40
- * @default `JSON.parse`
41
- */
42
- deserialize?: (cachedString: string) => MaybePromise<PersistedClient>;
43
- retry?: AsyncPersistRetryer;
44
- }
45
-
46
- export declare function noop(): void;
47
-
48
- export declare function noop(): undefined;
49
-
50
- export { }
@@ -1,50 +0,0 @@
1
- import type { AsyncStorage } from '@tanstack/query-persist-client-core';
2
- import type { MaybePromise } from '@tanstack/query-persist-client-core';
3
- import type { PersistedClient } from '@tanstack/query-persist-client-core';
4
- import type { Persister } from '@tanstack/query-persist-client-core';
5
- import type { Promisable } from '@tanstack/query-persist-client-core';
6
-
7
- export declare type AsyncPersistRetryer = (props: {
8
- persistedClient: PersistedClient;
9
- error: Error;
10
- errorCount: number;
11
- }) => Promisable<PersistedClient | undefined>;
12
-
13
- export declare function asyncThrottle<TArgs extends ReadonlyArray<unknown>>(func: (...args: TArgs) => Promise<void>, { interval, onError }?: AsyncThrottleOptions): (...args: TArgs) => Promise<void>;
14
-
15
- declare interface AsyncThrottleOptions {
16
- interval?: number;
17
- onError?: (error: unknown) => void;
18
- }
19
-
20
- export declare const createAsyncStoragePersister: ({ storage, key, throttleTime, serialize, deserialize, retry, }: CreateAsyncStoragePersisterOptions) => Persister;
21
-
22
- declare interface CreateAsyncStoragePersisterOptions {
23
- /** The storage client used for setting and retrieving items from cache.
24
- * For SSR pass in `undefined`. Note that window.localStorage can be
25
- * `null` in Android WebViews depending on how they are configured.
26
- */
27
- storage: AsyncStorage<string> | undefined | null;
28
- /** The key to use when storing the cache */
29
- key?: string;
30
- /** To avoid spamming,
31
- * pass a time in ms to throttle saving the cache to disk */
32
- throttleTime?: number;
33
- /**
34
- * How to serialize the data to storage.
35
- * @default `JSON.stringify`
36
- */
37
- serialize?: (client: PersistedClient) => MaybePromise<string>;
38
- /**
39
- * How to deserialize the data from storage.
40
- * @default `JSON.parse`
41
- */
42
- deserialize?: (cachedString: string) => MaybePromise<PersistedClient>;
43
- retry?: AsyncPersistRetryer;
44
- }
45
-
46
- export declare function noop(): void;
47
-
48
- export declare function noop(): undefined;
49
-
50
- export { }
@@ -1,50 +0,0 @@
1
- import type { AsyncStorage } from '@tanstack/query-persist-client-core';
2
- import type { MaybePromise } from '@tanstack/query-persist-client-core';
3
- import type { PersistedClient } from '@tanstack/query-persist-client-core';
4
- import type { Persister } from '@tanstack/query-persist-client-core';
5
- import type { Promisable } from '@tanstack/query-persist-client-core';
6
-
7
- export declare type AsyncPersistRetryer = (props: {
8
- persistedClient: PersistedClient;
9
- error: Error;
10
- errorCount: number;
11
- }) => Promisable<PersistedClient | undefined>;
12
-
13
- export declare function asyncThrottle<TArgs extends ReadonlyArray<unknown>>(func: (...args: TArgs) => Promise<void>, { interval, onError }?: AsyncThrottleOptions): (...args: TArgs) => Promise<void>;
14
-
15
- declare interface AsyncThrottleOptions {
16
- interval?: number;
17
- onError?: (error: unknown) => void;
18
- }
19
-
20
- export declare const createAsyncStoragePersister: ({ storage, key, throttleTime, serialize, deserialize, retry, }: CreateAsyncStoragePersisterOptions) => Persister;
21
-
22
- declare interface CreateAsyncStoragePersisterOptions {
23
- /** The storage client used for setting and retrieving items from cache.
24
- * For SSR pass in `undefined`. Note that window.localStorage can be
25
- * `null` in Android WebViews depending on how they are configured.
26
- */
27
- storage: AsyncStorage<string> | undefined | null;
28
- /** The key to use when storing the cache */
29
- key?: string;
30
- /** To avoid spamming,
31
- * pass a time in ms to throttle saving the cache to disk */
32
- throttleTime?: number;
33
- /**
34
- * How to serialize the data to storage.
35
- * @default `JSON.stringify`
36
- */
37
- serialize?: (client: PersistedClient) => MaybePromise<string>;
38
- /**
39
- * How to deserialize the data from storage.
40
- * @default `JSON.parse`
41
- */
42
- deserialize?: (cachedString: string) => MaybePromise<PersistedClient>;
43
- retry?: AsyncPersistRetryer;
44
- }
45
-
46
- export declare function noop(): void;
47
-
48
- export declare function noop(): undefined;
49
-
50
- export { }