@tanstack/react-query-persist-client 4.0.0 → 4.0.2

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 (65) hide show
  1. package/build/cjs/react-query/build/esm/index.js +301 -0
  2. package/build/cjs/react-query/build/esm/index.js.map +1 -0
  3. package/build/cjs/react-query-persist-client/src/PersistQueryClientProvider.js +3 -3
  4. package/build/cjs/react-query-persist-client/src/PersistQueryClientProvider.js.map +1 -1
  5. package/build/esm/index.js +269 -9
  6. package/build/esm/index.js.map +1 -1
  7. package/build/stats-html.html +1 -1
  8. package/build/stats.json +249 -0
  9. package/build/types/packages/query-core/src/focusManager.d.ts +16 -0
  10. package/build/types/packages/query-core/src/hydration.d.ts +34 -0
  11. package/build/types/packages/query-core/src/index.d.ts +20 -0
  12. package/build/types/packages/query-core/src/infiniteQueryBehavior.d.ts +15 -0
  13. package/build/types/packages/query-core/src/infiniteQueryObserver.d.ts +18 -0
  14. package/build/types/packages/query-core/src/logger.d.ts +8 -0
  15. package/build/types/packages/query-core/src/mutation.d.ts +70 -0
  16. package/build/types/packages/query-core/src/mutationCache.d.ts +52 -0
  17. package/build/types/packages/query-core/src/mutationObserver.d.ts +23 -0
  18. package/build/types/packages/query-core/src/notifyManager.d.ts +18 -0
  19. package/build/types/packages/query-core/src/onlineManager.d.ts +16 -0
  20. package/build/types/packages/query-core/src/queriesObserver.d.ts +23 -0
  21. package/build/types/packages/query-core/src/query.d.ts +119 -0
  22. package/build/types/packages/query-core/src/queryCache.d.ts +59 -0
  23. package/build/types/packages/query-core/src/queryClient.d.ts +65 -0
  24. package/build/types/packages/query-core/src/queryObserver.d.ts +61 -0
  25. package/build/types/packages/query-core/src/removable.d.ts +9 -0
  26. package/build/types/packages/query-core/src/retryer.d.ts +33 -0
  27. package/build/types/packages/query-core/src/subscribable.d.ts +10 -0
  28. package/build/types/packages/query-core/src/types.d.ts +417 -0
  29. package/build/types/packages/query-core/src/utils.d.ts +99 -0
  30. package/build/types/packages/react-query/src/Hydrate.d.ts +10 -0
  31. package/build/types/packages/react-query/src/QueryClientProvider.d.ts +24 -0
  32. package/build/types/packages/react-query/src/QueryErrorResetBoundary.d.ts +12 -0
  33. package/build/types/packages/react-query/src/index.d.ts +17 -0
  34. package/build/types/packages/react-query/src/isRestoring.d.ts +3 -0
  35. package/build/types/packages/react-query/src/reactBatchedUpdates.d.ts +2 -0
  36. package/build/types/packages/react-query/src/setBatchUpdatesFn.d.ts +1 -0
  37. package/build/types/packages/react-query/src/types.d.ts +35 -0
  38. package/build/types/packages/react-query/src/useBaseQuery.d.ts +3 -0
  39. package/build/types/packages/react-query/src/useInfiniteQuery.d.ts +5 -0
  40. package/build/types/packages/react-query/src/useIsFetching.d.ts +7 -0
  41. package/build/types/packages/react-query/src/useIsMutating.d.ts +7 -0
  42. package/build/types/packages/react-query/src/useMutation.d.ts +6 -0
  43. package/build/types/packages/react-query/src/useQueries.d.ts +49 -0
  44. package/build/types/packages/react-query/src/useQuery.d.ts +20 -0
  45. package/build/types/packages/react-query/src/utils.d.ts +1 -0
  46. package/build/types/packages/react-query-persist-client/src/PersistQueryClientProvider.d.ts +8 -0
  47. package/build/types/packages/react-query-persist-client/src/__tests__/PersistQueryClientProvider.test.d.ts +1 -0
  48. package/build/types/packages/react-query-persist-client/src/__tests__/persist.test.d.ts +1 -0
  49. package/build/types/packages/react-query-persist-client/src/index.d.ts +3 -0
  50. package/build/types/packages/react-query-persist-client/src/persist.d.ts +58 -0
  51. package/build/types/packages/react-query-persist-client/src/retryStrategies.d.ts +7 -0
  52. package/build/types/tests/utils.d.ts +24 -0
  53. package/build/umd/index.development.js +274 -14
  54. package/build/umd/index.development.js.map +1 -1
  55. package/build/umd/index.production.js +22 -2
  56. package/build/umd/index.production.js.map +1 -1
  57. package/package.json +3 -3
  58. package/build/cjs/PersistQueryClientProvider.js +0 -83
  59. package/build/cjs/PersistQueryClientProvider.js.map +0 -1
  60. package/build/cjs/index.js +0 -27
  61. package/build/cjs/index.js.map +0 -1
  62. package/build/cjs/persist.js +0 -119
  63. package/build/cjs/persist.js.map +0 -1
  64. package/build/cjs/retryStrategies.js +0 -39
  65. package/build/cjs/retryStrategies.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-query-persist-client",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "TODO",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -11,11 +11,11 @@
11
11
  "url": "https://github.com/sponsors/tannerlinsley"
12
12
  },
13
13
  "module": "build/esm/index.js",
14
- "main": "build/cjs/index.js",
14
+ "main": "build/cjs/react-query-persist-client/src/index.js",
15
15
  "browser": "build/umd/index.production.js",
16
16
  "types": "build/types/packages/react-query-persist-client/src/index.d.ts",
17
17
  "files": [
18
- "build",
18
+ "build/*",
19
19
  "src"
20
20
  ],
21
21
  "scripts": {
@@ -1,83 +0,0 @@
1
- /**
2
- * react-query-persist-client
3
- *
4
- * Copyright (c) TanStack
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE.md file in the root directory of this source tree.
8
- *
9
- * @license MIT
10
- */
11
- 'use strict';
12
-
13
- Object.defineProperty(exports, '__esModule', { value: true });
14
-
15
- var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js');
16
- var React = require('react');
17
- var persist = require('./persist.js');
18
- var reactQuery = require('@tanstack/react-query');
19
-
20
- function _interopNamespace(e) {
21
- if (e && e.__esModule) return e;
22
- var n = Object.create(null);
23
- if (e) {
24
- Object.keys(e).forEach(function (k) {
25
- if (k !== 'default') {
26
- var d = Object.getOwnPropertyDescriptor(e, k);
27
- Object.defineProperty(n, k, d.get ? d : {
28
- enumerable: true,
29
- get: function () { return e[k]; }
30
- });
31
- }
32
- });
33
- }
34
- n["default"] = e;
35
- return Object.freeze(n);
36
- }
37
-
38
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
39
-
40
- const PersistQueryClientProvider = ({
41
- client,
42
- children,
43
- persistOptions,
44
- onSuccess,
45
- ...props
46
- }) => {
47
- const [isRestoring, setIsRestoring] = React__namespace.useState(true);
48
- const refs = React__namespace.useRef({
49
- persistOptions,
50
- onSuccess
51
- });
52
- React__namespace.useEffect(() => {
53
- refs.current = {
54
- persistOptions,
55
- onSuccess
56
- };
57
- });
58
- React__namespace.useEffect(() => {
59
- let isStale = false;
60
- setIsRestoring(true);
61
- const [unsubscribe, promise] = persist.persistQueryClient({ ...refs.current.persistOptions,
62
- queryClient: client
63
- });
64
- promise.then(() => {
65
- if (!isStale) {
66
- refs.current.onSuccess == null ? void 0 : refs.current.onSuccess();
67
- setIsRestoring(false);
68
- }
69
- });
70
- return () => {
71
- isStale = true;
72
- unsubscribe();
73
- };
74
- }, [client]);
75
- return /*#__PURE__*/React__namespace.createElement(reactQuery.QueryClientProvider, _rollupPluginBabelHelpers["extends"]({
76
- client: client
77
- }, props), /*#__PURE__*/React__namespace.createElement(reactQuery.IsRestoringProvider, {
78
- value: isRestoring
79
- }, children));
80
- };
81
-
82
- exports.PersistQueryClientProvider = PersistQueryClientProvider;
83
- //# sourceMappingURL=PersistQueryClientProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PersistQueryClientProvider.js","sources":["../../src/PersistQueryClientProvider.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { persistQueryClient, PersistQueryClientOptions } from './persist'\nimport { QueryClientProvider, QueryClientProviderProps, IsRestoringProvider } from '@tanstack/react-query'\n\nexport type PersistQueryClientProviderProps = QueryClientProviderProps & {\n persistOptions: Omit<PersistQueryClientOptions, 'queryClient'>\n onSuccess?: () => void\n}\n\nexport const PersistQueryClientProvider = ({\n client,\n children,\n persistOptions,\n onSuccess,\n ...props\n}: PersistQueryClientProviderProps): JSX.Element => {\n const [isRestoring, setIsRestoring] = React.useState(true)\n const refs = React.useRef({ persistOptions, onSuccess })\n\n React.useEffect(() => {\n refs.current = { persistOptions, onSuccess }\n })\n\n React.useEffect(() => {\n let isStale = false\n setIsRestoring(true)\n const [unsubscribe, promise] = persistQueryClient({\n ...refs.current.persistOptions,\n queryClient: client,\n })\n\n promise.then(() => {\n if (!isStale) {\n refs.current.onSuccess?.()\n setIsRestoring(false)\n }\n })\n\n return () => {\n isStale = true\n unsubscribe()\n }\n }, [client])\n\n return (\n <QueryClientProvider client={client} {...props}>\n <IsRestoringProvider value={isRestoring}>{children}</IsRestoringProvider>\n </QueryClientProvider>\n )\n}\n"],"names":["PersistQueryClientProvider","client","children","persistOptions","onSuccess","props","isRestoring","setIsRestoring","React","useState","refs","useRef","useEffect","current","isStale","unsubscribe","promise","persistQueryClient","queryClient","then","QueryClientProvider","_extends","IsRestoringProvider"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUO,MAAMA,0BAA0B,GAAG,CAAC;AACzCC,EAAAA,MADyC;AAEzCC,EAAAA,QAFyC;AAGzCC,EAAAA,cAHyC;AAIzCC,EAAAA,SAJyC;AAKzC,EAAGC,GAAAA,KAAAA;AALsC,CAAD,KAMU;AAClD,EAAM,MAAA,CAACC,WAAD,EAAcC,cAAd,CAAA,GAAgCC,gBAAK,CAACC,QAAN,CAAe,IAAf,CAAtC,CAAA;AACA,EAAA,MAAMC,IAAI,GAAGF,gBAAK,CAACG,MAAN,CAAa;AAAER,IAAAA,cAAF;AAAkBC,IAAAA,SAAAA;AAAlB,GAAb,CAAb,CAAA;AAEAI,EAAAA,gBAAK,CAACI,SAAN,CAAgB,MAAM;AACpBF,IAAAA,IAAI,CAACG,OAAL,GAAe;AAAEV,MAAAA,cAAF;AAAkBC,MAAAA,SAAAA;AAAlB,KAAf,CAAA;AACD,GAFD,CAAA,CAAA;AAIAI,EAAAA,gBAAK,CAACI,SAAN,CAAgB,MAAM;AACpB,IAAIE,IAAAA,OAAO,GAAG,KAAd,CAAA;AACAP,IAAAA,cAAc,CAAC,IAAD,CAAd,CAAA;AACA,IAAA,MAAM,CAACQ,WAAD,EAAcC,OAAd,CAAyBC,GAAAA,0BAAkB,CAAC,EAChD,GAAGP,IAAI,CAACG,OAAL,CAAaV,cADgC;AAEhDe,MAAAA,WAAW,EAAEjB,MAAAA;AAFmC,KAAD,CAAjD,CAAA;AAKAe,IAAAA,OAAO,CAACG,IAAR,CAAa,MAAM;AACjB,MAAI,IAAA,CAACL,OAAL,EAAc;AACZJ,QAAAA,IAAI,CAACG,OAAL,CAAaT,SAAb,oBAAAM,IAAI,CAACG,OAAL,CAAaT,SAAb,EAAA,CAAA;AACAG,QAAAA,cAAc,CAAC,KAAD,CAAd,CAAA;AACD,OAAA;AACF,KALD,CAAA,CAAA;AAOA,IAAA,OAAO,MAAM;AACXO,MAAAA,OAAO,GAAG,IAAV,CAAA;AACAC,MAAAA,WAAW,EAAA,CAAA;AACZ,KAHD,CAAA;AAID,GAnBD,EAmBG,CAACd,MAAD,CAnBH,CAAA,CAAA;AAqBA,EAAA,oBACEO,+BAACY,8BAAD,EAAAC,oCAAA,CAAA;AAAqB,IAAA,MAAM,EAAEpB,MAAAA;AAA7B,GAAyCI,EAAAA,KAAzC,CACE,eAAAG,gBAAA,CAAA,aAAA,CAACc,8BAAD,EAAA;AAAqB,IAAA,KAAK,EAAEhB,WAAAA;AAA5B,GAA0CJ,EAAAA,QAA1C,CADF,CADF,CAAA;AAKD;;;;"}
@@ -1,27 +0,0 @@
1
- /**
2
- * react-query-persist-client
3
- *
4
- * Copyright (c) TanStack
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE.md file in the root directory of this source tree.
8
- *
9
- * @license MIT
10
- */
11
- 'use strict';
12
-
13
- Object.defineProperty(exports, '__esModule', { value: true });
14
-
15
- var persist = require('./persist.js');
16
- var PersistQueryClientProvider = require('./PersistQueryClientProvider.js');
17
- var retryStrategies = require('./retryStrategies.js');
18
-
19
-
20
-
21
- exports.persistQueryClient = persist.persistQueryClient;
22
- exports.persistQueryClientRestore = persist.persistQueryClientRestore;
23
- exports.persistQueryClientSave = persist.persistQueryClientSave;
24
- exports.persistQueryClientSubscribe = persist.persistQueryClientSubscribe;
25
- exports.PersistQueryClientProvider = PersistQueryClientProvider.PersistQueryClientProvider;
26
- exports.removeOldestQuery = retryStrategies.removeOldestQuery;
27
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,119 +0,0 @@
1
- /**
2
- * react-query-persist-client
3
- *
4
- * Copyright (c) TanStack
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE.md file in the root directory of this source tree.
8
- *
9
- * @license MIT
10
- */
11
- 'use strict';
12
-
13
- Object.defineProperty(exports, '__esModule', { value: true });
14
-
15
- var queryCore = require('@tanstack/query-core');
16
-
17
- /**
18
- * Restores persisted data to the QueryCache
19
- * - data obtained from persister.restoreClient
20
- * - data is hydrated using hydrateOptions
21
- * If data is expired, busted, empty, or throws, it runs persister.removeClient
22
- */
23
- async function persistQueryClientRestore({
24
- queryClient,
25
- persister,
26
- maxAge = 1000 * 60 * 60 * 24,
27
- buster = '',
28
- hydrateOptions
29
- }) {
30
- try {
31
- const persistedClient = await persister.restoreClient();
32
-
33
- if (persistedClient) {
34
- if (persistedClient.timestamp) {
35
- const expired = Date.now() - persistedClient.timestamp > maxAge;
36
- const busted = persistedClient.buster !== buster;
37
-
38
- if (expired || busted) {
39
- persister.removeClient();
40
- } else {
41
- queryCore.hydrate(queryClient, persistedClient.clientState, hydrateOptions);
42
- }
43
- } else {
44
- persister.removeClient();
45
- }
46
- }
47
- } catch (err) {
48
- if (process.env.NODE_ENV !== 'production') {
49
- queryClient.getLogger().error(err);
50
- queryClient.getLogger().warn('Encountered an error attempting to restore client cache from persisted location. As a precaution, the persisted cache will be discarded.');
51
- }
52
-
53
- persister.removeClient();
54
- }
55
- }
56
- /**
57
- * Persists data from the QueryCache
58
- * - data dehydrated using dehydrateOptions
59
- * - data is persisted using persister.persistClient
60
- */
61
-
62
- async function persistQueryClientSave({
63
- queryClient,
64
- persister,
65
- buster = '',
66
- dehydrateOptions
67
- }) {
68
- const persistClient = {
69
- buster,
70
- timestamp: Date.now(),
71
- clientState: queryCore.dehydrate(queryClient, dehydrateOptions)
72
- };
73
- await persister.persistClient(persistClient);
74
- }
75
- /**
76
- * Subscribe to QueryCache and MutationCache updates (for persisting)
77
- * @returns an unsubscribe function (to discontinue monitoring)
78
- */
79
-
80
- function persistQueryClientSubscribe(props) {
81
- const unsubscribeQueryCache = props.queryClient.getQueryCache().subscribe(() => {
82
- persistQueryClientSave(props);
83
- });
84
- const unusbscribeMutationCache = props.queryClient.getMutationCache().subscribe(() => {
85
- persistQueryClientSave(props);
86
- });
87
- return () => {
88
- unsubscribeQueryCache();
89
- unusbscribeMutationCache();
90
- };
91
- }
92
- /**
93
- * Restores persisted data to QueryCache and persists further changes.
94
- */
95
-
96
- function persistQueryClient(props) {
97
- let hasUnsubscribed = false;
98
- let persistQueryClientUnsubscribe;
99
-
100
- const unsubscribe = () => {
101
- hasUnsubscribed = true;
102
- persistQueryClientUnsubscribe == null ? void 0 : persistQueryClientUnsubscribe();
103
- }; // Attempt restore
104
-
105
-
106
- const restorePromise = persistQueryClientRestore(props).then(() => {
107
- if (!hasUnsubscribed) {
108
- // Subscribe to changes in the query cache to trigger the save
109
- persistQueryClientUnsubscribe = persistQueryClientSubscribe(props);
110
- }
111
- });
112
- return [unsubscribe, restorePromise];
113
- }
114
-
115
- exports.persistQueryClient = persistQueryClient;
116
- exports.persistQueryClientRestore = persistQueryClientRestore;
117
- exports.persistQueryClientSave = persistQueryClientSave;
118
- exports.persistQueryClientSubscribe = persistQueryClientSubscribe;
119
- //# sourceMappingURL=persist.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"persist.js","sources":["../../src/persist.ts"],"sourcesContent":["import {\n QueryClient,\n dehydrate,\n DehydratedState,\n DehydrateOptions,\n HydrateOptions,\n hydrate,\n} from '@tanstack/query-core'\n\nexport type Promisable<T> = T | PromiseLike<T>\n\nexport interface Persister {\n persistClient(persistClient: PersistedClient): Promisable<void>\n restoreClient(): Promisable<PersistedClient | undefined>\n removeClient(): Promisable<void>\n}\n\nexport interface PersistedClient {\n timestamp: number\n buster: string\n clientState: DehydratedState\n}\n\nexport interface PersistQueryClienRootOptions {\n /** The QueryClient to persist */\n queryClient: QueryClient\n /** The Persister interface for storing and restoring the cache\n * to/from a persisted location */\n persister: Persister\n /** A unique string that can be used to forcefully\n * invalidate existing caches if they do not share the same buster string */\n buster?: string\n}\n\nexport interface PersistedQueryClientRestoreOptions\n extends PersistQueryClienRootOptions {\n /** The max-allowed age of the cache in milliseconds.\n * If a persisted cache is found that is older than this\n * time, it will be discarded */\n maxAge?: number\n /** The options passed to the hydrate function */\n hydrateOptions?: HydrateOptions\n}\n\nexport interface PersistedQueryClientSaveOptions\n extends PersistQueryClienRootOptions {\n /** The options passed to the dehydrate function */\n dehydrateOptions?: DehydrateOptions\n}\n\nexport interface PersistQueryClientOptions\n extends PersistedQueryClientRestoreOptions,\n PersistedQueryClientSaveOptions,\n PersistQueryClienRootOptions {}\n\n/**\n * Restores persisted data to the QueryCache\n * - data obtained from persister.restoreClient\n * - data is hydrated using hydrateOptions\n * If data is expired, busted, empty, or throws, it runs persister.removeClient\n */\nexport async function persistQueryClientRestore({\n queryClient,\n persister,\n maxAge = 1000 * 60 * 60 * 24,\n buster = '',\n hydrateOptions,\n}: PersistedQueryClientRestoreOptions) {\n try {\n const persistedClient = await persister.restoreClient()\n\n if (persistedClient) {\n if (persistedClient.timestamp) {\n const expired = Date.now() - persistedClient.timestamp > maxAge\n const busted = persistedClient.buster !== buster\n if (expired || busted) {\n persister.removeClient()\n } else {\n hydrate(queryClient, persistedClient.clientState, hydrateOptions)\n }\n } else {\n persister.removeClient()\n }\n }\n } catch (err) {\n if (process.env.NODE_ENV !== 'production') {\n queryClient.getLogger().error(err)\n queryClient\n .getLogger()\n .warn(\n 'Encountered an error attempting to restore client cache from persisted location. As a precaution, the persisted cache will be discarded.'\n )\n }\n persister.removeClient()\n }\n}\n\n/**\n * Persists data from the QueryCache\n * - data dehydrated using dehydrateOptions\n * - data is persisted using persister.persistClient\n */\nexport async function persistQueryClientSave({\n queryClient,\n persister,\n buster = '',\n dehydrateOptions,\n}: PersistedQueryClientSaveOptions) {\n const persistClient: PersistedClient = {\n buster,\n timestamp: Date.now(),\n clientState: dehydrate(queryClient, dehydrateOptions),\n }\n\n await persister.persistClient(persistClient)\n}\n\n/**\n * Subscribe to QueryCache and MutationCache updates (for persisting)\n * @returns an unsubscribe function (to discontinue monitoring)\n */\nexport function persistQueryClientSubscribe(\n props: PersistedQueryClientSaveOptions\n) {\n const unsubscribeQueryCache = props.queryClient\n .getQueryCache()\n .subscribe(() => {\n persistQueryClientSave(props)\n })\n\n const unusbscribeMutationCache = props.queryClient\n .getMutationCache()\n .subscribe(() => {\n persistQueryClientSave(props)\n })\n\n return () => {\n unsubscribeQueryCache()\n unusbscribeMutationCache()\n }\n}\n\n/**\n * Restores persisted data to QueryCache and persists further changes.\n */\nexport function persistQueryClient(\n props: PersistQueryClientOptions\n): [() => void, Promise<void>] {\n let hasUnsubscribed = false\n let persistQueryClientUnsubscribe: (() => void) | undefined\n const unsubscribe = () => {\n hasUnsubscribed = true\n persistQueryClientUnsubscribe?.()\n }\n\n // Attempt restore\n const restorePromise = persistQueryClientRestore(props).then(() => {\n if (!hasUnsubscribed) {\n // Subscribe to changes in the query cache to trigger the save\n persistQueryClientUnsubscribe = persistQueryClientSubscribe(props)\n }\n })\n\n return [unsubscribe, restorePromise]\n}\n"],"names":["persistQueryClientRestore","queryClient","persister","maxAge","buster","hydrateOptions","persistedClient","restoreClient","timestamp","expired","Date","now","busted","removeClient","hydrate","clientState","err","process","env","NODE_ENV","getLogger","error","warn","persistQueryClientSave","dehydrateOptions","persistClient","dehydrate","persistQueryClientSubscribe","props","unsubscribeQueryCache","getQueryCache","subscribe","unusbscribeMutationCache","getMutationCache","persistQueryClient","hasUnsubscribed","persistQueryClientUnsubscribe","unsubscribe","restorePromise","then"],"mappings":"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"}
@@ -1,39 +0,0 @@
1
- /**
2
- * react-query-persist-client
3
- *
4
- * Copyright (c) TanStack
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE.md file in the root directory of this source tree.
8
- *
9
- * @license MIT
10
- */
11
- 'use strict';
12
-
13
- Object.defineProperty(exports, '__esModule', { value: true });
14
-
15
- const removeOldestQuery = ({
16
- persistedClient
17
- }) => {
18
- const mutations = [...persistedClient.clientState.mutations];
19
- const queries = [...persistedClient.clientState.queries];
20
- const client = { ...persistedClient,
21
- clientState: {
22
- mutations,
23
- queries
24
- }
25
- }; // sort queries by dataUpdatedAt (oldest first)
26
-
27
- const sortedQueries = [...queries].sort((a, b) => a.state.dataUpdatedAt - b.state.dataUpdatedAt); // clean oldest query
28
-
29
- if (sortedQueries.length > 0) {
30
- const oldestData = sortedQueries.shift();
31
- client.clientState.queries = queries.filter(q => q !== oldestData);
32
- return client;
33
- }
34
-
35
- return undefined;
36
- };
37
-
38
- exports.removeOldestQuery = removeOldestQuery;
39
- //# sourceMappingURL=retryStrategies.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"retryStrategies.js","sources":["../../src/retryStrategies.ts"],"sourcesContent":["import { PersistedClient } from './persist'\n\nexport type PersistRetryer = (props: {\n persistedClient: PersistedClient\n error: Error\n errorCount: number\n}) => PersistedClient | undefined\n\nexport const removeOldestQuery: PersistRetryer = ({ persistedClient }) => {\n const mutations = [...persistedClient.clientState.mutations]\n const queries = [...persistedClient.clientState.queries]\n const client: PersistedClient = {\n ...persistedClient,\n clientState: { mutations, queries },\n }\n\n // sort queries by dataUpdatedAt (oldest first)\n const sortedQueries = [...queries].sort(\n (a, b) => a.state.dataUpdatedAt - b.state.dataUpdatedAt\n )\n\n // clean oldest query\n if (sortedQueries.length > 0) {\n const oldestData = sortedQueries.shift()\n client.clientState.queries = queries.filter(q => q !== oldestData)\n return client\n }\n\n return undefined\n}\n"],"names":["removeOldestQuery","persistedClient","mutations","clientState","queries","client","sortedQueries","sort","a","b","state","dataUpdatedAt","length","oldestData","shift","filter","q","undefined"],"mappings":";;;;;;;;;;;;;;AAQO,MAAMA,iBAAiC,GAAG,CAAC;AAAEC,EAAAA,eAAAA;AAAF,CAAD,KAAyB;AACxE,EAAMC,MAAAA,SAAS,GAAG,CAAC,GAAGD,eAAe,CAACE,WAAhB,CAA4BD,SAAhC,CAAlB,CAAA;AACA,EAAME,MAAAA,OAAO,GAAG,CAAC,GAAGH,eAAe,CAACE,WAAhB,CAA4BC,OAAhC,CAAhB,CAAA;AACA,EAAA,MAAMC,MAAuB,GAAG,EAC9B,GAAGJ,eAD2B;AAE9BE,IAAAA,WAAW,EAAE;AAAED,MAAAA,SAAF;AAAaE,MAAAA,OAAAA;AAAb,KAAA;AAFiB,GAAhC,CAHwE;;AASxE,EAAME,MAAAA,aAAa,GAAG,CAAC,GAAGF,OAAJ,CAAaG,CAAAA,IAAb,CACpB,CAACC,CAAD,EAAIC,CAAJ,KAAUD,CAAC,CAACE,KAAF,CAAQC,aAAR,GAAwBF,CAAC,CAACC,KAAF,CAAQC,aADtB,CAAtB,CATwE;;AAcxE,EAAA,IAAIL,aAAa,CAACM,MAAd,GAAuB,CAA3B,EAA8B;AAC5B,IAAA,MAAMC,UAAU,GAAGP,aAAa,CAACQ,KAAd,EAAnB,CAAA;AACAT,IAAAA,MAAM,CAACF,WAAP,CAAmBC,OAAnB,GAA6BA,OAAO,CAACW,MAAR,CAAeC,CAAC,IAAIA,CAAC,KAAKH,UAA1B,CAA7B,CAAA;AACA,IAAA,OAAOR,MAAP,CAAA;AACD,GAAA;;AAED,EAAA,OAAOY,SAAP,CAAA;AACD;;;;"}