@tanstack/query-sync-storage-persister 5.90.27 → 5.94.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/query-sync-storage-persister",
3
- "version": "5.90.27",
3
+ "version": "5.94.4",
4
4
  "description": "A persister for synchronous 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.91.2",
44
- "@tanstack/query-persist-client-core": "5.92.4"
43
+ "@tanstack/query-core": "5.94.4",
44
+ "@tanstack/query-persist-client-core": "5.94.4"
45
45
  },
46
46
  "devDependencies": {
47
47
  "npm-run-all2": "^5.0.0",
@@ -1,72 +0,0 @@
1
- import { Options } from 'tsup';
2
- import type { PersistedClient } from '@tanstack/query-persist-client-core';
3
- import type { Persister } from '@tanstack/query-persist-client-core';
4
- import type { PersistRetryer } from '@tanstack/query-persist-client-core';
5
- import { UserConfig } from 'vite';
6
-
7
- /**
8
- * @deprecated use `createAsyncStoragePersister` from `@tanstack/query-async-storage-persister` instead.
9
- */
10
- export declare function createSyncStoragePersister({ storage, key, throttleTime, serialize, deserialize, retry, }: CreateSyncStoragePersisterOptions): Persister;
11
-
12
- declare interface CreateSyncStoragePersisterOptions {
13
- /** The storage client used for setting and retrieving items from cache.
14
- * For SSR pass in `undefined`. Note that window.localStorage can be
15
- * `null` in Android WebViews depending on how they are configured.
16
- */
17
- storage: Storage_2 | undefined | null;
18
- /** The key to use when storing the cache */
19
- key?: string;
20
- /** To avoid spamming,
21
- * pass a time in ms to throttle saving the cache to disk */
22
- throttleTime?: number;
23
- /**
24
- * How to serialize the data to storage.
25
- * @default `JSON.stringify`
26
- */
27
- serialize?: (client: PersistedClient) => string;
28
- /**
29
- * How to deserialize the data from storage.
30
- * @default `JSON.parse`
31
- */
32
- deserialize?: (cachedString: string) => PersistedClient;
33
- retry?: PersistRetryer;
34
- }
35
-
36
- export declare const default_alias: any[];
37
-
38
- export declare const default_alias_1: any[];
39
-
40
- export declare const default_alias_2: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
41
-
42
- export declare const default_alias_3: UserConfig;
43
-
44
- /**
45
- * @param {Object} opts - Options for building configurations.
46
- * @param {string[]} opts.entry - The entry array.
47
- * @returns {import('tsup').Options}
48
- */
49
- export declare function legacyConfig(opts: {
50
- entry: string[];
51
- }): Options;
52
-
53
- /**
54
- * @param {Object} opts - Options for building configurations.
55
- * @param {string[]} opts.entry - The entry array.
56
- * @returns {import('tsup').Options}
57
- */
58
- export declare function modernConfig(opts: {
59
- entry: string[];
60
- }): Options;
61
-
62
- export declare function noop(): void;
63
-
64
- export declare function noop(): undefined;
65
-
66
- declare interface Storage_2 {
67
- getItem: (key: string) => string | null;
68
- setItem: (key: string, value: string) => void;
69
- removeItem: (key: string) => void;
70
- }
71
-
72
- export { }
@@ -1,72 +0,0 @@
1
- import { Options } from 'tsup';
2
- import type { PersistedClient } from '@tanstack/query-persist-client-core';
3
- import type { Persister } from '@tanstack/query-persist-client-core';
4
- import type { PersistRetryer } from '@tanstack/query-persist-client-core';
5
- import { UserConfig } from 'vite';
6
-
7
- /**
8
- * @deprecated use `createAsyncStoragePersister` from `@tanstack/query-async-storage-persister` instead.
9
- */
10
- export declare function createSyncStoragePersister({ storage, key, throttleTime, serialize, deserialize, retry, }: CreateSyncStoragePersisterOptions): Persister;
11
-
12
- declare interface CreateSyncStoragePersisterOptions {
13
- /** The storage client used for setting and retrieving items from cache.
14
- * For SSR pass in `undefined`. Note that window.localStorage can be
15
- * `null` in Android WebViews depending on how they are configured.
16
- */
17
- storage: Storage_2 | undefined | null;
18
- /** The key to use when storing the cache */
19
- key?: string;
20
- /** To avoid spamming,
21
- * pass a time in ms to throttle saving the cache to disk */
22
- throttleTime?: number;
23
- /**
24
- * How to serialize the data to storage.
25
- * @default `JSON.stringify`
26
- */
27
- serialize?: (client: PersistedClient) => string;
28
- /**
29
- * How to deserialize the data from storage.
30
- * @default `JSON.parse`
31
- */
32
- deserialize?: (cachedString: string) => PersistedClient;
33
- retry?: PersistRetryer;
34
- }
35
-
36
- export declare const default_alias: any[];
37
-
38
- export declare const default_alias_1: any[];
39
-
40
- export declare const default_alias_2: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
41
-
42
- export declare const default_alias_3: UserConfig;
43
-
44
- /**
45
- * @param {Object} opts - Options for building configurations.
46
- * @param {string[]} opts.entry - The entry array.
47
- * @returns {import('tsup').Options}
48
- */
49
- export declare function legacyConfig(opts: {
50
- entry: string[];
51
- }): Options;
52
-
53
- /**
54
- * @param {Object} opts - Options for building configurations.
55
- * @param {string[]} opts.entry - The entry array.
56
- * @returns {import('tsup').Options}
57
- */
58
- export declare function modernConfig(opts: {
59
- entry: string[];
60
- }): Options;
61
-
62
- export declare function noop(): void;
63
-
64
- export declare function noop(): undefined;
65
-
66
- declare interface Storage_2 {
67
- getItem: (key: string) => string | null;
68
- setItem: (key: string, value: string) => void;
69
- removeItem: (key: string) => void;
70
- }
71
-
72
- export { }
@@ -1,97 +0,0 @@
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);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- createSyncStoragePersister: () => createSyncStoragePersister
24
- });
25
- module.exports = __toCommonJS(index_exports);
26
- var import_query_core = require("@tanstack/query-core");
27
- var import_utils = require("./utils.cjs");
28
- function createSyncStoragePersister({
29
- storage,
30
- key = `REACT_QUERY_OFFLINE_CACHE`,
31
- throttleTime = 1e3,
32
- serialize = JSON.stringify,
33
- deserialize = JSON.parse,
34
- retry
35
- }) {
36
- if (storage) {
37
- const trySave = (persistedClient) => {
38
- try {
39
- storage.setItem(key, serialize(persistedClient));
40
- return;
41
- } catch (error) {
42
- return error;
43
- }
44
- };
45
- return {
46
- persistClient: throttle((persistedClient) => {
47
- let client = persistedClient;
48
- let error = trySave(client);
49
- let errorCount = 0;
50
- while (error && client) {
51
- errorCount++;
52
- client = retry == null ? void 0 : retry({
53
- persistedClient: client,
54
- error,
55
- errorCount
56
- });
57
- if (client) {
58
- error = trySave(client);
59
- }
60
- }
61
- }, throttleTime),
62
- restoreClient: () => {
63
- const cacheString = storage.getItem(key);
64
- if (!cacheString) {
65
- return;
66
- }
67
- return deserialize(cacheString);
68
- },
69
- removeClient: () => {
70
- storage.removeItem(key);
71
- }
72
- };
73
- }
74
- return {
75
- persistClient: import_utils.noop,
76
- restoreClient: import_utils.noop,
77
- removeClient: import_utils.noop
78
- };
79
- }
80
- function throttle(func, wait = 100) {
81
- let timer = null;
82
- let params;
83
- return function(...args) {
84
- params = args;
85
- if (timer === null) {
86
- timer = import_query_core.timeoutManager.setTimeout(() => {
87
- func(...params);
88
- timer = null;
89
- }, wait);
90
- }
91
- };
92
- }
93
- // Annotate the CommonJS export names for ESM import in node:
94
- 0 && (module.exports = {
95
- createSyncStoragePersister
96
- });
97
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { timeoutManager } from '@tanstack/query-core'\nimport { noop } from './utils'\nimport type { ManagedTimerId } from '@tanstack/query-core'\nimport type {\n PersistRetryer,\n PersistedClient,\n Persister,\n} from '@tanstack/query-persist-client-core'\n\ninterface Storage {\n getItem: (key: string) => string | null\n setItem: (key: string, value: string) => void\n removeItem: (key: string) => void\n}\n\ninterface CreateSyncStoragePersisterOptions {\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: Storage | 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) => string\n /**\n * How to deserialize the data from storage.\n * @default `JSON.parse`\n */\n deserialize?: (cachedString: string) => PersistedClient\n\n retry?: PersistRetryer\n}\n\n/**\n * @deprecated use `createAsyncStoragePersister` from `@tanstack/query-async-storage-persister` instead.\n */\nexport function createSyncStoragePersister({\n storage,\n key = `REACT_QUERY_OFFLINE_CACHE`,\n throttleTime = 1000,\n serialize = JSON.stringify,\n deserialize = JSON.parse,\n retry,\n}: CreateSyncStoragePersisterOptions): Persister {\n if (storage) {\n const trySave = (persistedClient: PersistedClient): Error | undefined => {\n try {\n storage.setItem(key, serialize(persistedClient))\n return\n } catch (error) {\n return error as Error\n }\n }\n return {\n persistClient: throttle((persistedClient) => {\n let client: PersistedClient | undefined = persistedClient\n let error = trySave(client)\n let errorCount = 0\n while (error && client) {\n errorCount++\n client = retry?.({\n persistedClient: client,\n error,\n errorCount,\n })\n\n if (client) {\n error = trySave(client)\n }\n }\n }, throttleTime),\n restoreClient: () => {\n const cacheString = storage.getItem(key)\n\n if (!cacheString) {\n return\n }\n\n return deserialize(cacheString)\n },\n removeClient: () => {\n storage.removeItem(key)\n },\n }\n }\n\n return {\n persistClient: noop,\n restoreClient: noop,\n removeClient: noop,\n }\n}\n\nfunction throttle<TArgs extends Array<any>>(\n func: (...args: TArgs) => any,\n wait = 100,\n) {\n let timer: ManagedTimerId | null = null\n let params: TArgs\n return function (...args: TArgs) {\n params = args\n if (timer === null) {\n timer = timeoutManager.setTimeout(() => {\n func(...params)\n timer = null\n }, wait)\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAA+B;AAC/B,mBAAqB;AA0Cd,SAAS,2BAA2B;AAAA,EACzC;AAAA,EACA,MAAM;AAAA,EACN,eAAe;AAAA,EACf,YAAY,KAAK;AAAA,EACjB,cAAc,KAAK;AAAA,EACnB;AACF,GAAiD;AAC/C,MAAI,SAAS;AACX,UAAM,UAAU,CAAC,oBAAwD;AACvE,UAAI;AACF,gBAAQ,QAAQ,KAAK,UAAU,eAAe,CAAC;AAC/C;AAAA,MACF,SAAS,OAAO;AACd,eAAO;AAAA,MACT;AAAA,IACF;AACA,WAAO;AAAA,MACL,eAAe,SAAS,CAAC,oBAAoB;AAC3C,YAAI,SAAsC;AAC1C,YAAI,QAAQ,QAAQ,MAAM;AAC1B,YAAI,aAAa;AACjB,eAAO,SAAS,QAAQ;AACtB;AACA,mBAAS,+BAAQ;AAAA,YACf,iBAAiB;AAAA,YACjB;AAAA,YACA;AAAA,UACF;AAEA,cAAI,QAAQ;AACV,oBAAQ,QAAQ,MAAM;AAAA,UACxB;AAAA,QACF;AAAA,MACF,GAAG,YAAY;AAAA,MACf,eAAe,MAAM;AACnB,cAAM,cAAc,QAAQ,QAAQ,GAAG;AAEvC,YAAI,CAAC,aAAa;AAChB;AAAA,QACF;AAEA,eAAO,YAAY,WAAW;AAAA,MAChC;AAAA,MACA,cAAc,MAAM;AAClB,gBAAQ,WAAW,GAAG;AAAA,MACxB;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,eAAe;AAAA,IACf,eAAe;AAAA,IACf,cAAc;AAAA,EAChB;AACF;AAEA,SAAS,SACP,MACA,OAAO,KACP;AACA,MAAI,QAA+B;AACnC,MAAI;AACJ,SAAO,YAAa,MAAa;AAC/B,aAAS;AACT,QAAI,UAAU,MAAM;AAClB,cAAQ,iCAAe,WAAW,MAAM;AACtC,aAAK,GAAG,MAAM;AACd,gBAAQ;AAAA,MACV,GAAG,IAAI;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
@@ -1 +0,0 @@
1
- export { createSyncStoragePersister } from './_tsup-dts-rollup.cjs';
@@ -1 +0,0 @@
1
- export { createSyncStoragePersister } from './_tsup-dts-rollup.js';
@@ -1,72 +0,0 @@
1
- // src/index.ts
2
- import { timeoutManager } from "@tanstack/query-core";
3
- import { noop } from "./utils.js";
4
- function createSyncStoragePersister({
5
- storage,
6
- key = `REACT_QUERY_OFFLINE_CACHE`,
7
- throttleTime = 1e3,
8
- serialize = JSON.stringify,
9
- deserialize = JSON.parse,
10
- retry
11
- }) {
12
- if (storage) {
13
- const trySave = (persistedClient) => {
14
- try {
15
- storage.setItem(key, serialize(persistedClient));
16
- return;
17
- } catch (error) {
18
- return error;
19
- }
20
- };
21
- return {
22
- persistClient: throttle((persistedClient) => {
23
- let client = persistedClient;
24
- let error = trySave(client);
25
- let errorCount = 0;
26
- while (error && client) {
27
- errorCount++;
28
- client = retry == null ? void 0 : retry({
29
- persistedClient: client,
30
- error,
31
- errorCount
32
- });
33
- if (client) {
34
- error = trySave(client);
35
- }
36
- }
37
- }, throttleTime),
38
- restoreClient: () => {
39
- const cacheString = storage.getItem(key);
40
- if (!cacheString) {
41
- return;
42
- }
43
- return deserialize(cacheString);
44
- },
45
- removeClient: () => {
46
- storage.removeItem(key);
47
- }
48
- };
49
- }
50
- return {
51
- persistClient: noop,
52
- restoreClient: noop,
53
- removeClient: noop
54
- };
55
- }
56
- function throttle(func, wait = 100) {
57
- let timer = null;
58
- let params;
59
- return function(...args) {
60
- params = args;
61
- if (timer === null) {
62
- timer = timeoutManager.setTimeout(() => {
63
- func(...params);
64
- timer = null;
65
- }, wait);
66
- }
67
- };
68
- }
69
- export {
70
- createSyncStoragePersister
71
- };
72
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { timeoutManager } from '@tanstack/query-core'\nimport { noop } from './utils'\nimport type { ManagedTimerId } from '@tanstack/query-core'\nimport type {\n PersistRetryer,\n PersistedClient,\n Persister,\n} from '@tanstack/query-persist-client-core'\n\ninterface Storage {\n getItem: (key: string) => string | null\n setItem: (key: string, value: string) => void\n removeItem: (key: string) => void\n}\n\ninterface CreateSyncStoragePersisterOptions {\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: Storage | 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) => string\n /**\n * How to deserialize the data from storage.\n * @default `JSON.parse`\n */\n deserialize?: (cachedString: string) => PersistedClient\n\n retry?: PersistRetryer\n}\n\n/**\n * @deprecated use `createAsyncStoragePersister` from `@tanstack/query-async-storage-persister` instead.\n */\nexport function createSyncStoragePersister({\n storage,\n key = `REACT_QUERY_OFFLINE_CACHE`,\n throttleTime = 1000,\n serialize = JSON.stringify,\n deserialize = JSON.parse,\n retry,\n}: CreateSyncStoragePersisterOptions): Persister {\n if (storage) {\n const trySave = (persistedClient: PersistedClient): Error | undefined => {\n try {\n storage.setItem(key, serialize(persistedClient))\n return\n } catch (error) {\n return error as Error\n }\n }\n return {\n persistClient: throttle((persistedClient) => {\n let client: PersistedClient | undefined = persistedClient\n let error = trySave(client)\n let errorCount = 0\n while (error && client) {\n errorCount++\n client = retry?.({\n persistedClient: client,\n error,\n errorCount,\n })\n\n if (client) {\n error = trySave(client)\n }\n }\n }, throttleTime),\n restoreClient: () => {\n const cacheString = storage.getItem(key)\n\n if (!cacheString) {\n return\n }\n\n return deserialize(cacheString)\n },\n removeClient: () => {\n storage.removeItem(key)\n },\n }\n }\n\n return {\n persistClient: noop,\n restoreClient: noop,\n removeClient: noop,\n }\n}\n\nfunction throttle<TArgs extends Array<any>>(\n func: (...args: TArgs) => any,\n wait = 100,\n) {\n let timer: ManagedTimerId | null = null\n let params: TArgs\n return function (...args: TArgs) {\n params = args\n if (timer === null) {\n timer = timeoutManager.setTimeout(() => {\n func(...params)\n timer = null\n }, wait)\n }\n }\n}\n"],"mappings":";AAAA,SAAS,sBAAsB;AAC/B,SAAS,YAAY;AA0Cd,SAAS,2BAA2B;AAAA,EACzC;AAAA,EACA,MAAM;AAAA,EACN,eAAe;AAAA,EACf,YAAY,KAAK;AAAA,EACjB,cAAc,KAAK;AAAA,EACnB;AACF,GAAiD;AAC/C,MAAI,SAAS;AACX,UAAM,UAAU,CAAC,oBAAwD;AACvE,UAAI;AACF,gBAAQ,QAAQ,KAAK,UAAU,eAAe,CAAC;AAC/C;AAAA,MACF,SAAS,OAAO;AACd,eAAO;AAAA,MACT;AAAA,IACF;AACA,WAAO;AAAA,MACL,eAAe,SAAS,CAAC,oBAAoB;AAC3C,YAAI,SAAsC;AAC1C,YAAI,QAAQ,QAAQ,MAAM;AAC1B,YAAI,aAAa;AACjB,eAAO,SAAS,QAAQ;AACtB;AACA,mBAAS,+BAAQ;AAAA,YACf,iBAAiB;AAAA,YACjB;AAAA,YACA;AAAA,UACF;AAEA,cAAI,QAAQ;AACV,oBAAQ,QAAQ,MAAM;AAAA,UACxB;AAAA,QACF;AAAA,MACF,GAAG,YAAY;AAAA,MACf,eAAe,MAAM;AACnB,cAAM,cAAc,QAAQ,QAAQ,GAAG;AAEvC,YAAI,CAAC,aAAa;AAChB;AAAA,QACF;AAEA,eAAO,YAAY,WAAW;AAAA,MAChC;AAAA,MACA,cAAc,MAAM;AAClB,gBAAQ,WAAW,GAAG;AAAA,MACxB;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,eAAe;AAAA,IACf,eAAe;AAAA,IACf,cAAc;AAAA,EAChB;AACF;AAEA,SAAS,SACP,MACA,OAAO,KACP;AACA,MAAI,QAA+B;AACnC,MAAI;AACJ,SAAO,YAAa,MAAa;AAC/B,aAAS;AACT,QAAI,UAAU,MAAM;AAClB,cAAQ,eAAe,WAAW,MAAM;AACtC,aAAK,GAAG,MAAM;AACd,gBAAQ;AAAA,MACV,GAAG,IAAI;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
@@ -1,32 +0,0 @@
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);
19
-
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
- //# sourceMappingURL=utils.cjs.map
@@ -1 +0,0 @@
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 +0,0 @@
1
- export { noop } from './_tsup-dts-rollup.cjs';
@@ -1 +0,0 @@
1
- export { noop } from './_tsup-dts-rollup.js';
@@ -1,7 +0,0 @@
1
- // src/utils.ts
2
- function noop() {
3
- }
4
- export {
5
- noop
6
- };
7
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
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,72 +0,0 @@
1
- import { Options } from 'tsup';
2
- import type { PersistedClient } from '@tanstack/query-persist-client-core';
3
- import type { Persister } from '@tanstack/query-persist-client-core';
4
- import type { PersistRetryer } from '@tanstack/query-persist-client-core';
5
- import { UserConfig } from 'vite';
6
-
7
- /**
8
- * @deprecated use `createAsyncStoragePersister` from `@tanstack/query-async-storage-persister` instead.
9
- */
10
- export declare function createSyncStoragePersister({ storage, key, throttleTime, serialize, deserialize, retry, }: CreateSyncStoragePersisterOptions): Persister;
11
-
12
- declare interface CreateSyncStoragePersisterOptions {
13
- /** The storage client used for setting and retrieving items from cache.
14
- * For SSR pass in `undefined`. Note that window.localStorage can be
15
- * `null` in Android WebViews depending on how they are configured.
16
- */
17
- storage: Storage_2 | undefined | null;
18
- /** The key to use when storing the cache */
19
- key?: string;
20
- /** To avoid spamming,
21
- * pass a time in ms to throttle saving the cache to disk */
22
- throttleTime?: number;
23
- /**
24
- * How to serialize the data to storage.
25
- * @default `JSON.stringify`
26
- */
27
- serialize?: (client: PersistedClient) => string;
28
- /**
29
- * How to deserialize the data from storage.
30
- * @default `JSON.parse`
31
- */
32
- deserialize?: (cachedString: string) => PersistedClient;
33
- retry?: PersistRetryer;
34
- }
35
-
36
- export declare const default_alias: any[];
37
-
38
- export declare const default_alias_1: any[];
39
-
40
- export declare const default_alias_2: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
41
-
42
- export declare const default_alias_3: UserConfig;
43
-
44
- /**
45
- * @param {Object} opts - Options for building configurations.
46
- * @param {string[]} opts.entry - The entry array.
47
- * @returns {import('tsup').Options}
48
- */
49
- export declare function legacyConfig(opts: {
50
- entry: string[];
51
- }): Options;
52
-
53
- /**
54
- * @param {Object} opts - Options for building configurations.
55
- * @param {string[]} opts.entry - The entry array.
56
- * @returns {import('tsup').Options}
57
- */
58
- export declare function modernConfig(opts: {
59
- entry: string[];
60
- }): Options;
61
-
62
- export declare function noop(): void;
63
-
64
- export declare function noop(): undefined;
65
-
66
- declare interface Storage_2 {
67
- getItem: (key: string) => string | null;
68
- setItem: (key: string, value: string) => void;
69
- removeItem: (key: string) => void;
70
- }
71
-
72
- export { }
@@ -1,72 +0,0 @@
1
- import { Options } from 'tsup';
2
- import type { PersistedClient } from '@tanstack/query-persist-client-core';
3
- import type { Persister } from '@tanstack/query-persist-client-core';
4
- import type { PersistRetryer } from '@tanstack/query-persist-client-core';
5
- import { UserConfig } from 'vite';
6
-
7
- /**
8
- * @deprecated use `createAsyncStoragePersister` from `@tanstack/query-async-storage-persister` instead.
9
- */
10
- export declare function createSyncStoragePersister({ storage, key, throttleTime, serialize, deserialize, retry, }: CreateSyncStoragePersisterOptions): Persister;
11
-
12
- declare interface CreateSyncStoragePersisterOptions {
13
- /** The storage client used for setting and retrieving items from cache.
14
- * For SSR pass in `undefined`. Note that window.localStorage can be
15
- * `null` in Android WebViews depending on how they are configured.
16
- */
17
- storage: Storage_2 | undefined | null;
18
- /** The key to use when storing the cache */
19
- key?: string;
20
- /** To avoid spamming,
21
- * pass a time in ms to throttle saving the cache to disk */
22
- throttleTime?: number;
23
- /**
24
- * How to serialize the data to storage.
25
- * @default `JSON.stringify`
26
- */
27
- serialize?: (client: PersistedClient) => string;
28
- /**
29
- * How to deserialize the data from storage.
30
- * @default `JSON.parse`
31
- */
32
- deserialize?: (cachedString: string) => PersistedClient;
33
- retry?: PersistRetryer;
34
- }
35
-
36
- export declare const default_alias: any[];
37
-
38
- export declare const default_alias_1: any[];
39
-
40
- export declare const default_alias_2: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
41
-
42
- export declare const default_alias_3: UserConfig;
43
-
44
- /**
45
- * @param {Object} opts - Options for building configurations.
46
- * @param {string[]} opts.entry - The entry array.
47
- * @returns {import('tsup').Options}
48
- */
49
- export declare function legacyConfig(opts: {
50
- entry: string[];
51
- }): Options;
52
-
53
- /**
54
- * @param {Object} opts - Options for building configurations.
55
- * @param {string[]} opts.entry - The entry array.
56
- * @returns {import('tsup').Options}
57
- */
58
- export declare function modernConfig(opts: {
59
- entry: string[];
60
- }): Options;
61
-
62
- export declare function noop(): void;
63
-
64
- export declare function noop(): undefined;
65
-
66
- declare interface Storage_2 {
67
- getItem: (key: string) => string | null;
68
- setItem: (key: string, value: string) => void;
69
- removeItem: (key: string) => void;
70
- }
71
-
72
- export { }
@@ -1,97 +0,0 @@
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);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- createSyncStoragePersister: () => createSyncStoragePersister
24
- });
25
- module.exports = __toCommonJS(index_exports);
26
- var import_query_core = require("@tanstack/query-core");
27
- var import_utils = require("./utils.cjs");
28
- function createSyncStoragePersister({
29
- storage,
30
- key = `REACT_QUERY_OFFLINE_CACHE`,
31
- throttleTime = 1e3,
32
- serialize = JSON.stringify,
33
- deserialize = JSON.parse,
34
- retry
35
- }) {
36
- if (storage) {
37
- const trySave = (persistedClient) => {
38
- try {
39
- storage.setItem(key, serialize(persistedClient));
40
- return;
41
- } catch (error) {
42
- return error;
43
- }
44
- };
45
- return {
46
- persistClient: throttle((persistedClient) => {
47
- let client = persistedClient;
48
- let error = trySave(client);
49
- let errorCount = 0;
50
- while (error && client) {
51
- errorCount++;
52
- client = retry?.({
53
- persistedClient: client,
54
- error,
55
- errorCount
56
- });
57
- if (client) {
58
- error = trySave(client);
59
- }
60
- }
61
- }, throttleTime),
62
- restoreClient: () => {
63
- const cacheString = storage.getItem(key);
64
- if (!cacheString) {
65
- return;
66
- }
67
- return deserialize(cacheString);
68
- },
69
- removeClient: () => {
70
- storage.removeItem(key);
71
- }
72
- };
73
- }
74
- return {
75
- persistClient: import_utils.noop,
76
- restoreClient: import_utils.noop,
77
- removeClient: import_utils.noop
78
- };
79
- }
80
- function throttle(func, wait = 100) {
81
- let timer = null;
82
- let params;
83
- return function(...args) {
84
- params = args;
85
- if (timer === null) {
86
- timer = import_query_core.timeoutManager.setTimeout(() => {
87
- func(...params);
88
- timer = null;
89
- }, wait);
90
- }
91
- };
92
- }
93
- // Annotate the CommonJS export names for ESM import in node:
94
- 0 && (module.exports = {
95
- createSyncStoragePersister
96
- });
97
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { timeoutManager } from '@tanstack/query-core'\nimport { noop } from './utils'\nimport type { ManagedTimerId } from '@tanstack/query-core'\nimport type {\n PersistRetryer,\n PersistedClient,\n Persister,\n} from '@tanstack/query-persist-client-core'\n\ninterface Storage {\n getItem: (key: string) => string | null\n setItem: (key: string, value: string) => void\n removeItem: (key: string) => void\n}\n\ninterface CreateSyncStoragePersisterOptions {\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: Storage | 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) => string\n /**\n * How to deserialize the data from storage.\n * @default `JSON.parse`\n */\n deserialize?: (cachedString: string) => PersistedClient\n\n retry?: PersistRetryer\n}\n\n/**\n * @deprecated use `createAsyncStoragePersister` from `@tanstack/query-async-storage-persister` instead.\n */\nexport function createSyncStoragePersister({\n storage,\n key = `REACT_QUERY_OFFLINE_CACHE`,\n throttleTime = 1000,\n serialize = JSON.stringify,\n deserialize = JSON.parse,\n retry,\n}: CreateSyncStoragePersisterOptions): Persister {\n if (storage) {\n const trySave = (persistedClient: PersistedClient): Error | undefined => {\n try {\n storage.setItem(key, serialize(persistedClient))\n return\n } catch (error) {\n return error as Error\n }\n }\n return {\n persistClient: throttle((persistedClient) => {\n let client: PersistedClient | undefined = persistedClient\n let error = trySave(client)\n let errorCount = 0\n while (error && client) {\n errorCount++\n client = retry?.({\n persistedClient: client,\n error,\n errorCount,\n })\n\n if (client) {\n error = trySave(client)\n }\n }\n }, throttleTime),\n restoreClient: () => {\n const cacheString = storage.getItem(key)\n\n if (!cacheString) {\n return\n }\n\n return deserialize(cacheString)\n },\n removeClient: () => {\n storage.removeItem(key)\n },\n }\n }\n\n return {\n persistClient: noop,\n restoreClient: noop,\n removeClient: noop,\n }\n}\n\nfunction throttle<TArgs extends Array<any>>(\n func: (...args: TArgs) => any,\n wait = 100,\n) {\n let timer: ManagedTimerId | null = null\n let params: TArgs\n return function (...args: TArgs) {\n params = args\n if (timer === null) {\n timer = timeoutManager.setTimeout(() => {\n func(...params)\n timer = null\n }, wait)\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAA+B;AAC/B,mBAAqB;AA0Cd,SAAS,2BAA2B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 @@
1
- export { createSyncStoragePersister } from './_tsup-dts-rollup.js';
@@ -1,72 +0,0 @@
1
- // src/index.ts
2
- import { timeoutManager } from "@tanstack/query-core";
3
- import { noop } from "./utils.js";
4
- function createSyncStoragePersister({
5
- storage,
6
- key = `REACT_QUERY_OFFLINE_CACHE`,
7
- throttleTime = 1e3,
8
- serialize = JSON.stringify,
9
- deserialize = JSON.parse,
10
- retry
11
- }) {
12
- if (storage) {
13
- const trySave = (persistedClient) => {
14
- try {
15
- storage.setItem(key, serialize(persistedClient));
16
- return;
17
- } catch (error) {
18
- return error;
19
- }
20
- };
21
- return {
22
- persistClient: throttle((persistedClient) => {
23
- let client = persistedClient;
24
- let error = trySave(client);
25
- let errorCount = 0;
26
- while (error && client) {
27
- errorCount++;
28
- client = retry?.({
29
- persistedClient: client,
30
- error,
31
- errorCount
32
- });
33
- if (client) {
34
- error = trySave(client);
35
- }
36
- }
37
- }, throttleTime),
38
- restoreClient: () => {
39
- const cacheString = storage.getItem(key);
40
- if (!cacheString) {
41
- return;
42
- }
43
- return deserialize(cacheString);
44
- },
45
- removeClient: () => {
46
- storage.removeItem(key);
47
- }
48
- };
49
- }
50
- return {
51
- persistClient: noop,
52
- restoreClient: noop,
53
- removeClient: noop
54
- };
55
- }
56
- function throttle(func, wait = 100) {
57
- let timer = null;
58
- let params;
59
- return function(...args) {
60
- params = args;
61
- if (timer === null) {
62
- timer = timeoutManager.setTimeout(() => {
63
- func(...params);
64
- timer = null;
65
- }, wait);
66
- }
67
- };
68
- }
69
- export {
70
- createSyncStoragePersister
71
- };
72
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { timeoutManager } from '@tanstack/query-core'\nimport { noop } from './utils'\nimport type { ManagedTimerId } from '@tanstack/query-core'\nimport type {\n PersistRetryer,\n PersistedClient,\n Persister,\n} from '@tanstack/query-persist-client-core'\n\ninterface Storage {\n getItem: (key: string) => string | null\n setItem: (key: string, value: string) => void\n removeItem: (key: string) => void\n}\n\ninterface CreateSyncStoragePersisterOptions {\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: Storage | 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) => string\n /**\n * How to deserialize the data from storage.\n * @default `JSON.parse`\n */\n deserialize?: (cachedString: string) => PersistedClient\n\n retry?: PersistRetryer\n}\n\n/**\n * @deprecated use `createAsyncStoragePersister` from `@tanstack/query-async-storage-persister` instead.\n */\nexport function createSyncStoragePersister({\n storage,\n key = `REACT_QUERY_OFFLINE_CACHE`,\n throttleTime = 1000,\n serialize = JSON.stringify,\n deserialize = JSON.parse,\n retry,\n}: CreateSyncStoragePersisterOptions): Persister {\n if (storage) {\n const trySave = (persistedClient: PersistedClient): Error | undefined => {\n try {\n storage.setItem(key, serialize(persistedClient))\n return\n } catch (error) {\n return error as Error\n }\n }\n return {\n persistClient: throttle((persistedClient) => {\n let client: PersistedClient | undefined = persistedClient\n let error = trySave(client)\n let errorCount = 0\n while (error && client) {\n errorCount++\n client = retry?.({\n persistedClient: client,\n error,\n errorCount,\n })\n\n if (client) {\n error = trySave(client)\n }\n }\n }, throttleTime),\n restoreClient: () => {\n const cacheString = storage.getItem(key)\n\n if (!cacheString) {\n return\n }\n\n return deserialize(cacheString)\n },\n removeClient: () => {\n storage.removeItem(key)\n },\n }\n }\n\n return {\n persistClient: noop,\n restoreClient: noop,\n removeClient: noop,\n }\n}\n\nfunction throttle<TArgs extends Array<any>>(\n func: (...args: TArgs) => any,\n wait = 100,\n) {\n let timer: ManagedTimerId | null = null\n let params: TArgs\n return function (...args: TArgs) {\n params = args\n if (timer === null) {\n timer = timeoutManager.setTimeout(() => {\n func(...params)\n timer = null\n }, wait)\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F;","names":[]}
@@ -1,32 +0,0 @@
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);
19
-
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
- //# sourceMappingURL=utils.cjs.map
@@ -1 +0,0 @@
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 +0,0 @@
1
- export { noop } from './_tsup-dts-rollup.cjs';
@@ -1 +0,0 @@
1
- export { noop } from './_tsup-dts-rollup.js';
@@ -1,7 +0,0 @@
1
- // src/utils.ts
2
- function noop() {
3
- }
4
- export {
5
- noop
6
- };
7
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
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":[]}