@tanstack/react-query-persist-client 4.39.0 → 4.39.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.
@@ -0,0 +1,53 @@
1
+ 'use client';
2
+ import { extends as _extends } from './_virtual/_rollupPluginBabelHelpers.esm.js';
3
+ import * as React from 'react';
4
+ import { persistQueryClientRestore, persistQueryClientSubscribe } from '@tanstack/query-persist-client-core';
5
+ import { QueryClientProvider, IsRestoringProvider } from '@tanstack/react-query';
6
+
7
+ const PersistQueryClientProvider = ({
8
+ client,
9
+ children,
10
+ persistOptions,
11
+ onSuccess,
12
+ ...props
13
+ }) => {
14
+ const [isRestoring, setIsRestoring] = React.useState(true);
15
+ const refs = React.useRef({
16
+ persistOptions,
17
+ onSuccess
18
+ });
19
+ const didRestore = React.useRef(false);
20
+ React.useEffect(() => {
21
+ refs.current = {
22
+ persistOptions,
23
+ onSuccess
24
+ };
25
+ });
26
+ React.useEffect(() => {
27
+ const options = { ...refs.current.persistOptions,
28
+ queryClient: client
29
+ };
30
+
31
+ if (!didRestore.current) {
32
+ didRestore.current = true;
33
+ setIsRestoring(true);
34
+ persistQueryClientRestore(options).then(async () => {
35
+ try {
36
+ await (refs.current.onSuccess == null ? void 0 : refs.current.onSuccess());
37
+ } finally {
38
+ setIsRestoring(false);
39
+ }
40
+ });
41
+ }
42
+
43
+ return isRestoring ? undefined : persistQueryClientSubscribe(options);
44
+ }, [client, isRestoring]);
45
+ return /*#__PURE__*/React.createElement(QueryClientProvider, _extends({
46
+ client: client
47
+ }, props), /*#__PURE__*/React.createElement(IsRestoringProvider, {
48
+ value: isRestoring
49
+ }, children));
50
+ };
51
+
52
+ export { PersistQueryClientProvider };
53
+ //# sourceMappingURL=PersistQueryClientProvider.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PersistQueryClientProvider.esm.js","sources":["../../src/PersistQueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport {\n persistQueryClientRestore,\n persistQueryClientSubscribe,\n} from '@tanstack/query-persist-client-core'\nimport { IsRestoringProvider, QueryClientProvider } from '@tanstack/react-query'\nimport type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'\nimport type { QueryClientProviderProps } 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 const didRestore = React.useRef(false)\n\n React.useEffect(() => {\n refs.current = { persistOptions, onSuccess }\n })\n\n React.useEffect(() => {\n const options = {\n ...refs.current.persistOptions,\n queryClient: client,\n }\n if (!didRestore.current) {\n didRestore.current = true\n setIsRestoring(true)\n persistQueryClientRestore(options).then(async () => {\n try {\n await refs.current.onSuccess?.()\n } finally {\n setIsRestoring(false)\n }\n })\n }\n return isRestoring ? undefined : persistQueryClientSubscribe(options)\n }, [client, isRestoring])\n\n return (\n <QueryClientProvider client={client} {...props}>\n <IsRestoringProvider value={isRestoring}>{children}</IsRestoringProvider>\n </QueryClientProvider>\n )\n}\n"],"names":["onSuccess","queryClient","persistQueryClientRestore"],"mappings":";;;;;;AAgBO;;;;;;AAAoC;;AAQzC;;AAA4CA;AAAlB;AAC1B;;;;AAGmCA;;;;;AAM/BC;;;AAEF;;;AAGEC;;;AAGG;;AAEA;;AAEJ;;AACD;AACD;AAED;AACuB;;AACE;;AAG1B;;"}
@@ -0,0 +1,77 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js');
7
+ var React = require('react');
8
+ var queryPersistClientCore = require('@tanstack/query-persist-client-core');
9
+ var reactQuery = require('@tanstack/react-query');
10
+
11
+ function _interopNamespace(e) {
12
+ if (e && e.__esModule) return e;
13
+ var n = Object.create(null);
14
+ if (e) {
15
+ Object.keys(e).forEach(function (k) {
16
+ if (k !== 'default') {
17
+ var d = Object.getOwnPropertyDescriptor(e, k);
18
+ Object.defineProperty(n, k, d.get ? d : {
19
+ enumerable: true,
20
+ get: function () { return e[k]; }
21
+ });
22
+ }
23
+ });
24
+ }
25
+ n["default"] = e;
26
+ return Object.freeze(n);
27
+ }
28
+
29
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
30
+
31
+ const PersistQueryClientProvider = ({
32
+ client,
33
+ children,
34
+ persistOptions,
35
+ onSuccess,
36
+ ...props
37
+ }) => {
38
+ const [isRestoring, setIsRestoring] = React__namespace.useState(true);
39
+ const refs = React__namespace.useRef({
40
+ persistOptions,
41
+ onSuccess
42
+ });
43
+ const didRestore = React__namespace.useRef(false);
44
+ React__namespace.useEffect(() => {
45
+ refs.current = {
46
+ persistOptions,
47
+ onSuccess
48
+ };
49
+ });
50
+ React__namespace.useEffect(() => {
51
+ const options = { ...refs.current.persistOptions,
52
+ queryClient: client
53
+ };
54
+
55
+ if (!didRestore.current) {
56
+ didRestore.current = true;
57
+ setIsRestoring(true);
58
+ queryPersistClientCore.persistQueryClientRestore(options).then(async () => {
59
+ try {
60
+ await (refs.current.onSuccess == null ? void 0 : refs.current.onSuccess());
61
+ } finally {
62
+ setIsRestoring(false);
63
+ }
64
+ });
65
+ }
66
+
67
+ return isRestoring ? undefined : queryPersistClientCore.persistQueryClientSubscribe(options);
68
+ }, [client, isRestoring]);
69
+ return /*#__PURE__*/React__namespace.createElement(reactQuery.QueryClientProvider, _rollupPluginBabelHelpers["extends"]({
70
+ client: client
71
+ }, props), /*#__PURE__*/React__namespace.createElement(reactQuery.IsRestoringProvider, {
72
+ value: isRestoring
73
+ }, children));
74
+ };
75
+
76
+ exports.PersistQueryClientProvider = PersistQueryClientProvider;
77
+ //# sourceMappingURL=PersistQueryClientProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PersistQueryClientProvider.js","sources":["../../src/PersistQueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport {\n persistQueryClientRestore,\n persistQueryClientSubscribe,\n} from '@tanstack/query-persist-client-core'\nimport { IsRestoringProvider, QueryClientProvider } from '@tanstack/react-query'\nimport type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'\nimport type { QueryClientProviderProps } 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 const didRestore = React.useRef(false)\n\n React.useEffect(() => {\n refs.current = { persistOptions, onSuccess }\n })\n\n React.useEffect(() => {\n const options = {\n ...refs.current.persistOptions,\n queryClient: client,\n }\n if (!didRestore.current) {\n didRestore.current = true\n setIsRestoring(true)\n persistQueryClientRestore(options).then(async () => {\n try {\n await refs.current.onSuccess?.()\n } finally {\n setIsRestoring(false)\n }\n })\n }\n return isRestoring ? undefined : persistQueryClientSubscribe(options)\n }, [client, isRestoring])\n\n return (\n <QueryClientProvider client={client} {...props}>\n <IsRestoringProvider value={isRestoring}>{children}</IsRestoringProvider>\n </QueryClientProvider>\n )\n}\n"],"names":["onSuccess","queryClient","persistQueryClientRestore"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBO;;;;;;AAAoC;;AAQzC;;AAA4CA;AAAlB;AAC1B;;;;AAGmCA;;;;;AAM/BC;;;AAEF;;;AAGEC;;;AAGG;;AAEA;;AAEJ;;AACD;AACD;AAED;AACuB;;AACE;;AAG1B;;"}
@@ -0,0 +1,53 @@
1
+ 'use client';
2
+ import { extends as _extends } from './_virtual/_rollupPluginBabelHelpers.mjs';
3
+ import * as React from 'react';
4
+ import { persistQueryClientRestore, persistQueryClientSubscribe } from '@tanstack/query-persist-client-core';
5
+ import { QueryClientProvider, IsRestoringProvider } from '@tanstack/react-query';
6
+
7
+ const PersistQueryClientProvider = ({
8
+ client,
9
+ children,
10
+ persistOptions,
11
+ onSuccess,
12
+ ...props
13
+ }) => {
14
+ const [isRestoring, setIsRestoring] = React.useState(true);
15
+ const refs = React.useRef({
16
+ persistOptions,
17
+ onSuccess
18
+ });
19
+ const didRestore = React.useRef(false);
20
+ React.useEffect(() => {
21
+ refs.current = {
22
+ persistOptions,
23
+ onSuccess
24
+ };
25
+ });
26
+ React.useEffect(() => {
27
+ const options = { ...refs.current.persistOptions,
28
+ queryClient: client
29
+ };
30
+
31
+ if (!didRestore.current) {
32
+ didRestore.current = true;
33
+ setIsRestoring(true);
34
+ persistQueryClientRestore(options).then(async () => {
35
+ try {
36
+ await (refs.current.onSuccess == null ? void 0 : refs.current.onSuccess());
37
+ } finally {
38
+ setIsRestoring(false);
39
+ }
40
+ });
41
+ }
42
+
43
+ return isRestoring ? undefined : persistQueryClientSubscribe(options);
44
+ }, [client, isRestoring]);
45
+ return /*#__PURE__*/React.createElement(QueryClientProvider, _extends({
46
+ client: client
47
+ }, props), /*#__PURE__*/React.createElement(IsRestoringProvider, {
48
+ value: isRestoring
49
+ }, children));
50
+ };
51
+
52
+ export { PersistQueryClientProvider };
53
+ //# sourceMappingURL=PersistQueryClientProvider.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PersistQueryClientProvider.mjs","sources":["../../src/PersistQueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport {\n persistQueryClientRestore,\n persistQueryClientSubscribe,\n} from '@tanstack/query-persist-client-core'\nimport { IsRestoringProvider, QueryClientProvider } from '@tanstack/react-query'\nimport type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'\nimport type { QueryClientProviderProps } 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 const didRestore = React.useRef(false)\n\n React.useEffect(() => {\n refs.current = { persistOptions, onSuccess }\n })\n\n React.useEffect(() => {\n const options = {\n ...refs.current.persistOptions,\n queryClient: client,\n }\n if (!didRestore.current) {\n didRestore.current = true\n setIsRestoring(true)\n persistQueryClientRestore(options).then(async () => {\n try {\n await refs.current.onSuccess?.()\n } finally {\n setIsRestoring(false)\n }\n })\n }\n return isRestoring ? undefined : persistQueryClientSubscribe(options)\n }, [client, isRestoring])\n\n return (\n <QueryClientProvider client={client} {...props}>\n <IsRestoringProvider value={isRestoring}>{children}</IsRestoringProvider>\n </QueryClientProvider>\n )\n}\n"],"names":["onSuccess","queryClient","persistQueryClientRestore"],"mappings":";;;;;;AAgBO;;;;;;AAAoC;;AAQzC;;AAA4CA;AAAlB;AAC1B;;;;AAGmCA;;;;;AAM/BC;;;AAEF;;;AAGEC;;;AAGG;;AAEA;;AAEJ;;AACD;AACD;AAED;AACuB;;AACE;;AAG1B;;"}
@@ -0,0 +1,19 @@
1
+ function _extends() {
2
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
3
+ for (var i = 1; i < arguments.length; i++) {
4
+ var source = arguments[i];
5
+
6
+ for (var key in source) {
7
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
8
+ target[key] = source[key];
9
+ }
10
+ }
11
+ }
12
+
13
+ return target;
14
+ };
15
+ return _extends.apply(this, arguments);
16
+ }
17
+
18
+ export { _extends as extends };
19
+ //# sourceMappingURL=_rollupPluginBabelHelpers.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_rollupPluginBabelHelpers.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ function _extends() {
6
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
7
+ for (var i = 1; i < arguments.length; i++) {
8
+ var source = arguments[i];
9
+
10
+ for (var key in source) {
11
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
12
+ target[key] = source[key];
13
+ }
14
+ }
15
+ }
16
+
17
+ return target;
18
+ };
19
+ return _extends.apply(this, arguments);
20
+ }
21
+
22
+ exports["extends"] = _extends;
23
+ //# sourceMappingURL=_rollupPluginBabelHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_rollupPluginBabelHelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,19 @@
1
+ function _extends() {
2
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
3
+ for (var i = 1; i < arguments.length; i++) {
4
+ var source = arguments[i];
5
+
6
+ for (var key in source) {
7
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
8
+ target[key] = source[key];
9
+ }
10
+ }
11
+ }
12
+
13
+ return target;
14
+ };
15
+ return _extends.apply(this, arguments);
16
+ }
17
+
18
+ export { _extends as extends };
19
+ //# sourceMappingURL=_rollupPluginBabelHelpers.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_rollupPluginBabelHelpers.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,3 @@
1
+ export * from '@tanstack/query-persist-client-core';
2
+ export { PersistQueryClientProvider } from './PersistQueryClientProvider.esm.js';
3
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var queryPersistClientCore = require('@tanstack/query-persist-client-core');
6
+ var PersistQueryClientProvider = require('./PersistQueryClientProvider.js');
7
+
8
+
9
+
10
+ exports.PersistQueryClientProvider = PersistQueryClientProvider.PersistQueryClientProvider;
11
+ Object.keys(queryPersistClientCore).forEach(function (k) {
12
+ if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
13
+ enumerable: true,
14
+ get: function () { return queryPersistClientCore[k]; }
15
+ });
16
+ });
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
@@ -0,0 +1,3 @@
1
+ export * from '@tanstack/query-persist-client-core';
2
+ export { PersistQueryClientProvider } from './PersistQueryClientProvider.mjs';
3
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,342 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@tanstack/react-query')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'react', '@tanstack/react-query'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactQueryPersistClient = {}, global.React, global.ReactQuery));
5
+ })(this, (function (exports, React, reactQuery) { 'use strict';
6
+
7
+ function _interopNamespace(e) {
8
+ if (e && e.__esModule) return e;
9
+ var n = Object.create(null);
10
+ if (e) {
11
+ Object.keys(e).forEach(function (k) {
12
+ if (k !== 'default') {
13
+ var d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: function () { return e[k]; }
17
+ });
18
+ }
19
+ });
20
+ }
21
+ n["default"] = e;
22
+ return Object.freeze(n);
23
+ }
24
+
25
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
26
+
27
+ // TYPES
28
+ // FUNCTIONS
29
+ function dehydrateMutation(mutation) {
30
+ return {
31
+ mutationKey: mutation.options.mutationKey,
32
+ state: mutation.state
33
+ };
34
+ } // Most config is not dehydrated but instead meant to configure again when
35
+ // consuming the de/rehydrated data, typically with useQuery on the client.
36
+ // Sometimes it might make sense to prefetch data on the server and include
37
+ // in the html-payload, but not consume it on the initial render.
38
+
39
+
40
+ function dehydrateQuery(query) {
41
+ return {
42
+ state: query.state,
43
+ queryKey: query.queryKey,
44
+ queryHash: query.queryHash
45
+ };
46
+ }
47
+
48
+ function defaultShouldDehydrateMutation(mutation) {
49
+ return mutation.state.isPaused;
50
+ }
51
+ function defaultShouldDehydrateQuery(query) {
52
+ return query.state.status === 'success';
53
+ }
54
+ function dehydrate(client, options = {}) {
55
+ const mutations = [];
56
+ const queries = [];
57
+
58
+ if (options.dehydrateMutations !== false) {
59
+ const shouldDehydrateMutation = options.shouldDehydrateMutation || defaultShouldDehydrateMutation;
60
+ client.getMutationCache().getAll().forEach(mutation => {
61
+ if (shouldDehydrateMutation(mutation)) {
62
+ mutations.push(dehydrateMutation(mutation));
63
+ }
64
+ });
65
+ }
66
+
67
+ if (options.dehydrateQueries !== false) {
68
+ const shouldDehydrateQuery = options.shouldDehydrateQuery || defaultShouldDehydrateQuery;
69
+ client.getQueryCache().getAll().forEach(query => {
70
+ if (shouldDehydrateQuery(query)) {
71
+ queries.push(dehydrateQuery(query));
72
+ }
73
+ });
74
+ }
75
+
76
+ return {
77
+ mutations,
78
+ queries
79
+ };
80
+ }
81
+ function hydrate(client, dehydratedState, options) {
82
+ if (typeof dehydratedState !== 'object' || dehydratedState === null) {
83
+ return;
84
+ }
85
+
86
+ const mutationCache = client.getMutationCache();
87
+ const queryCache = client.getQueryCache(); // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
88
+
89
+ const mutations = dehydratedState.mutations || []; // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
90
+
91
+ const queries = dehydratedState.queries || [];
92
+ mutations.forEach(dehydratedMutation => {
93
+ var _options$defaultOptio;
94
+
95
+ mutationCache.build(client, { ...(options == null ? void 0 : (_options$defaultOptio = options.defaultOptions) == null ? void 0 : _options$defaultOptio.mutations),
96
+ mutationKey: dehydratedMutation.mutationKey
97
+ }, dehydratedMutation.state);
98
+ });
99
+ queries.forEach(({
100
+ queryKey,
101
+ state,
102
+ queryHash
103
+ }) => {
104
+ var _options$defaultOptio2;
105
+
106
+ const query = queryCache.get(queryHash); // Do not hydrate if an existing query exists with newer data
107
+
108
+ if (query) {
109
+ if (query.state.dataUpdatedAt < state.dataUpdatedAt) {
110
+ // omit fetchStatus from dehydrated state
111
+ // so that query stays in its current fetchStatus
112
+ const {
113
+ fetchStatus: _ignored,
114
+ ...dehydratedQueryState
115
+ } = state;
116
+ query.setState(dehydratedQueryState);
117
+ }
118
+
119
+ return;
120
+ } // Restore query
121
+
122
+
123
+ queryCache.build(client, { ...(options == null ? void 0 : (_options$defaultOptio2 = options.defaultOptions) == null ? void 0 : _options$defaultOptio2.queries),
124
+ queryKey,
125
+ queryHash
126
+ }, // Reset fetch status to idle to avoid
127
+ // query being stuck in fetching state upon hydration
128
+ { ...state,
129
+ fetchStatus: 'idle'
130
+ });
131
+ });
132
+ }
133
+
134
+ /**
135
+ * Checks if emitted event is about cache change and not about observers.
136
+ * Useful for persist, where we only want to trigger save when cache is changed.
137
+ */
138
+ const cacheableEventTypes = ['added', 'removed', 'updated'];
139
+
140
+ function isCacheableEventType(eventType) {
141
+ return cacheableEventTypes.includes(eventType);
142
+ }
143
+ /**
144
+ * Restores persisted data to the QueryCache
145
+ * - data obtained from persister.restoreClient
146
+ * - data is hydrated using hydrateOptions
147
+ * If data is expired, busted, empty, or throws, it runs persister.removeClient
148
+ */
149
+
150
+
151
+ async function persistQueryClientRestore({
152
+ queryClient,
153
+ persister,
154
+ maxAge = 1000 * 60 * 60 * 24,
155
+ buster = '',
156
+ hydrateOptions
157
+ }) {
158
+ try {
159
+ const persistedClient = await persister.restoreClient();
160
+
161
+ if (persistedClient) {
162
+ if (persistedClient.timestamp) {
163
+ const expired = Date.now() - persistedClient.timestamp > maxAge;
164
+ const busted = persistedClient.buster !== buster;
165
+
166
+ if (expired || busted) {
167
+ persister.removeClient();
168
+ } else {
169
+ hydrate(queryClient, persistedClient.clientState, hydrateOptions);
170
+ }
171
+ } else {
172
+ persister.removeClient();
173
+ }
174
+ }
175
+ } catch (err) {
176
+ {
177
+ queryClient.getLogger().error(err);
178
+ queryClient.getLogger().warn('Encountered an error attempting to restore client cache from persisted location. As a precaution, the persisted cache will be discarded.');
179
+ }
180
+
181
+ persister.removeClient();
182
+ }
183
+ }
184
+ /**
185
+ * Persists data from the QueryCache
186
+ * - data dehydrated using dehydrateOptions
187
+ * - data is persisted using persister.persistClient
188
+ */
189
+
190
+ async function persistQueryClientSave({
191
+ queryClient,
192
+ persister,
193
+ buster = '',
194
+ dehydrateOptions
195
+ }) {
196
+ const persistClient = {
197
+ buster,
198
+ timestamp: Date.now(),
199
+ clientState: dehydrate(queryClient, dehydrateOptions)
200
+ };
201
+ await persister.persistClient(persistClient);
202
+ }
203
+ /**
204
+ * Subscribe to QueryCache and MutationCache updates (for persisting)
205
+ * @returns an unsubscribe function (to discontinue monitoring)
206
+ */
207
+
208
+ function persistQueryClientSubscribe(props) {
209
+ const unsubscribeQueryCache = props.queryClient.getQueryCache().subscribe(event => {
210
+ if (isCacheableEventType(event.type)) {
211
+ persistQueryClientSave(props);
212
+ }
213
+ });
214
+ const unusbscribeMutationCache = props.queryClient.getMutationCache().subscribe(event => {
215
+ if (isCacheableEventType(event.type)) {
216
+ persistQueryClientSave(props);
217
+ }
218
+ });
219
+ return () => {
220
+ unsubscribeQueryCache();
221
+ unusbscribeMutationCache();
222
+ };
223
+ }
224
+ /**
225
+ * Restores persisted data to QueryCache and persists further changes.
226
+ */
227
+
228
+ function persistQueryClient(props) {
229
+ let hasUnsubscribed = false;
230
+ let persistQueryClientUnsubscribe;
231
+
232
+ const unsubscribe = () => {
233
+ hasUnsubscribed = true;
234
+ persistQueryClientUnsubscribe == null ? void 0 : persistQueryClientUnsubscribe();
235
+ }; // Attempt restore
236
+
237
+
238
+ const restorePromise = persistQueryClientRestore(props).then(() => {
239
+ if (!hasUnsubscribed) {
240
+ // Subscribe to changes in the query cache to trigger the save
241
+ persistQueryClientUnsubscribe = persistQueryClientSubscribe(props);
242
+ }
243
+ });
244
+ return [unsubscribe, restorePromise];
245
+ }
246
+
247
+ const removeOldestQuery = ({
248
+ persistedClient
249
+ }) => {
250
+ const mutations = [...persistedClient.clientState.mutations];
251
+ const queries = [...persistedClient.clientState.queries];
252
+ const client = { ...persistedClient,
253
+ clientState: {
254
+ mutations,
255
+ queries
256
+ }
257
+ }; // sort queries by dataUpdatedAt (oldest first)
258
+
259
+ const sortedQueries = [...queries].sort((a, b) => a.state.dataUpdatedAt - b.state.dataUpdatedAt); // clean oldest query
260
+
261
+ if (sortedQueries.length > 0) {
262
+ const oldestData = sortedQueries.shift();
263
+ client.clientState.queries = queries.filter(q => q !== oldestData);
264
+ return client;
265
+ }
266
+
267
+ return undefined;
268
+ };
269
+
270
+ function _extends() {
271
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
272
+ for (var i = 1; i < arguments.length; i++) {
273
+ var source = arguments[i];
274
+
275
+ for (var key in source) {
276
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
277
+ target[key] = source[key];
278
+ }
279
+ }
280
+ }
281
+
282
+ return target;
283
+ };
284
+ return _extends.apply(this, arguments);
285
+ }
286
+
287
+ const PersistQueryClientProvider = ({
288
+ client,
289
+ children,
290
+ persistOptions,
291
+ onSuccess,
292
+ ...props
293
+ }) => {
294
+ const [isRestoring, setIsRestoring] = React__namespace.useState(true);
295
+ const refs = React__namespace.useRef({
296
+ persistOptions,
297
+ onSuccess
298
+ });
299
+ const didRestore = React__namespace.useRef(false);
300
+ React__namespace.useEffect(() => {
301
+ refs.current = {
302
+ persistOptions,
303
+ onSuccess
304
+ };
305
+ });
306
+ React__namespace.useEffect(() => {
307
+ const options = { ...refs.current.persistOptions,
308
+ queryClient: client
309
+ };
310
+
311
+ if (!didRestore.current) {
312
+ didRestore.current = true;
313
+ setIsRestoring(true);
314
+ persistQueryClientRestore(options).then(async () => {
315
+ try {
316
+ await (refs.current.onSuccess == null ? void 0 : refs.current.onSuccess());
317
+ } finally {
318
+ setIsRestoring(false);
319
+ }
320
+ });
321
+ }
322
+
323
+ return isRestoring ? undefined : persistQueryClientSubscribe(options);
324
+ }, [client, isRestoring]);
325
+ return /*#__PURE__*/React__namespace.createElement(reactQuery.QueryClientProvider, _extends({
326
+ client: client
327
+ }, props), /*#__PURE__*/React__namespace.createElement(reactQuery.IsRestoringProvider, {
328
+ value: isRestoring
329
+ }, children));
330
+ };
331
+
332
+ exports.PersistQueryClientProvider = PersistQueryClientProvider;
333
+ exports.persistQueryClient = persistQueryClient;
334
+ exports.persistQueryClientRestore = persistQueryClientRestore;
335
+ exports.persistQueryClientSave = persistQueryClientSave;
336
+ exports.persistQueryClientSubscribe = persistQueryClientSubscribe;
337
+ exports.removeOldestQuery = removeOldestQuery;
338
+
339
+ Object.defineProperty(exports, '__esModule', { value: true });
340
+
341
+ }));
342
+ //# sourceMappingURL=index.development.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.development.js","sources":["../../../query-core/build/lib/hydration.mjs","../../../query-persist-client-core/build/lib/persist.mjs","../../../query-persist-client-core/build/lib/retryStrategies.mjs","../../src/PersistQueryClientProvider.tsx"],"sourcesContent":["// TYPES\n// FUNCTIONS\nfunction dehydrateMutation(mutation) {\n return {\n mutationKey: mutation.options.mutationKey,\n state: mutation.state\n };\n} // Most config is not dehydrated but instead meant to configure again when\n// consuming the de/rehydrated data, typically with useQuery on the client.\n// Sometimes it might make sense to prefetch data on the server and include\n// in the html-payload, but not consume it on the initial render.\n\n\nfunction dehydrateQuery(query) {\n return {\n state: query.state,\n queryKey: query.queryKey,\n queryHash: query.queryHash\n };\n}\n\nfunction defaultShouldDehydrateMutation(mutation) {\n return mutation.state.isPaused;\n}\nfunction defaultShouldDehydrateQuery(query) {\n return query.state.status === 'success';\n}\nfunction dehydrate(client, options = {}) {\n const mutations = [];\n const queries = [];\n\n if (options.dehydrateMutations !== false) {\n const shouldDehydrateMutation = options.shouldDehydrateMutation || defaultShouldDehydrateMutation;\n client.getMutationCache().getAll().forEach(mutation => {\n if (shouldDehydrateMutation(mutation)) {\n mutations.push(dehydrateMutation(mutation));\n }\n });\n }\n\n if (options.dehydrateQueries !== false) {\n const shouldDehydrateQuery = options.shouldDehydrateQuery || defaultShouldDehydrateQuery;\n client.getQueryCache().getAll().forEach(query => {\n if (shouldDehydrateQuery(query)) {\n queries.push(dehydrateQuery(query));\n }\n });\n }\n\n return {\n mutations,\n queries\n };\n}\nfunction hydrate(client, dehydratedState, options) {\n if (typeof dehydratedState !== 'object' || dehydratedState === null) {\n return;\n }\n\n const mutationCache = client.getMutationCache();\n const queryCache = client.getQueryCache(); // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n\n const mutations = dehydratedState.mutations || []; // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n\n const queries = dehydratedState.queries || [];\n mutations.forEach(dehydratedMutation => {\n var _options$defaultOptio;\n\n mutationCache.build(client, { ...(options == null ? void 0 : (_options$defaultOptio = options.defaultOptions) == null ? void 0 : _options$defaultOptio.mutations),\n mutationKey: dehydratedMutation.mutationKey\n }, dehydratedMutation.state);\n });\n queries.forEach(({\n queryKey,\n state,\n queryHash\n }) => {\n var _options$defaultOptio2;\n\n const query = queryCache.get(queryHash); // Do not hydrate if an existing query exists with newer data\n\n if (query) {\n if (query.state.dataUpdatedAt < state.dataUpdatedAt) {\n // omit fetchStatus from dehydrated state\n // so that query stays in its current fetchStatus\n const {\n fetchStatus: _ignored,\n ...dehydratedQueryState\n } = state;\n query.setState(dehydratedQueryState);\n }\n\n return;\n } // Restore query\n\n\n queryCache.build(client, { ...(options == null ? void 0 : (_options$defaultOptio2 = options.defaultOptions) == null ? void 0 : _options$defaultOptio2.queries),\n queryKey,\n queryHash\n }, // Reset fetch status to idle to avoid\n // query being stuck in fetching state upon hydration\n { ...state,\n fetchStatus: 'idle'\n });\n });\n}\n\nexport { defaultShouldDehydrateMutation, defaultShouldDehydrateQuery, dehydrate, hydrate };\n//# sourceMappingURL=hydration.mjs.map\n","import { hydrate, dehydrate } from '@tanstack/query-core';\n\n/**\n * Checks if emitted event is about cache change and not about observers.\n * Useful for persist, where we only want to trigger save when cache is changed.\n */\nconst cacheableEventTypes = ['added', 'removed', 'updated'];\n\nfunction isCacheableEventType(eventType) {\n return cacheableEventTypes.includes(eventType);\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 */\n\n\nasync function persistQueryClientRestore({\n queryClient,\n persister,\n maxAge = 1000 * 60 * 60 * 24,\n buster = '',\n hydrateOptions\n}) {\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\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.getLogger().warn('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 * Persists data from the QueryCache\n * - data dehydrated using dehydrateOptions\n * - data is persisted using persister.persistClient\n */\n\nasync function persistQueryClientSave({\n queryClient,\n persister,\n buster = '',\n dehydrateOptions\n}) {\n const persistClient = {\n buster,\n timestamp: Date.now(),\n clientState: dehydrate(queryClient, dehydrateOptions)\n };\n await persister.persistClient(persistClient);\n}\n/**\n * Subscribe to QueryCache and MutationCache updates (for persisting)\n * @returns an unsubscribe function (to discontinue monitoring)\n */\n\nfunction persistQueryClientSubscribe(props) {\n const unsubscribeQueryCache = props.queryClient.getQueryCache().subscribe(event => {\n if (isCacheableEventType(event.type)) {\n persistQueryClientSave(props);\n }\n });\n const unusbscribeMutationCache = props.queryClient.getMutationCache().subscribe(event => {\n if (isCacheableEventType(event.type)) {\n persistQueryClientSave(props);\n }\n });\n return () => {\n unsubscribeQueryCache();\n unusbscribeMutationCache();\n };\n}\n/**\n * Restores persisted data to QueryCache and persists further changes.\n */\n\nfunction persistQueryClient(props) {\n let hasUnsubscribed = false;\n let persistQueryClientUnsubscribe;\n\n const unsubscribe = () => {\n hasUnsubscribed = true;\n persistQueryClientUnsubscribe == null ? void 0 : persistQueryClientUnsubscribe();\n }; // Attempt restore\n\n\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 return [unsubscribe, restorePromise];\n}\n\nexport { persistQueryClient, persistQueryClientRestore, persistQueryClientSave, persistQueryClientSubscribe };\n//# sourceMappingURL=persist.mjs.map\n","const removeOldestQuery = ({\n persistedClient\n}) => {\n const mutations = [...persistedClient.clientState.mutations];\n const queries = [...persistedClient.clientState.queries];\n const client = { ...persistedClient,\n clientState: {\n mutations,\n queries\n }\n }; // sort queries by dataUpdatedAt (oldest first)\n\n const sortedQueries = [...queries].sort((a, b) => a.state.dataUpdatedAt - b.state.dataUpdatedAt); // clean oldest query\n\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\nexport { removeOldestQuery };\n//# sourceMappingURL=retryStrategies.mjs.map\n","'use client'\nimport * as React from 'react'\n\nimport {\n persistQueryClientRestore,\n persistQueryClientSubscribe,\n} from '@tanstack/query-persist-client-core'\nimport { IsRestoringProvider, QueryClientProvider } from '@tanstack/react-query'\nimport type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'\nimport type { QueryClientProviderProps } 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 const didRestore = React.useRef(false)\n\n React.useEffect(() => {\n refs.current = { persistOptions, onSuccess }\n })\n\n React.useEffect(() => {\n const options = {\n ...refs.current.persistOptions,\n queryClient: client,\n }\n if (!didRestore.current) {\n didRestore.current = true\n setIsRestoring(true)\n persistQueryClientRestore(options).then(async () => {\n try {\n await refs.current.onSuccess?.()\n } finally {\n setIsRestoring(false)\n }\n })\n }\n return isRestoring ? undefined : persistQueryClientSubscribe(options)\n }, [client, isRestoring])\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","didRestore","useEffect","current","options","queryClient","persistQueryClientRestore","then","undefined","persistQueryClientSubscribe","QueryClientProvider","IsRestoringProvider"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;EACA;EACA,SAAS,iBAAiB,CAAC,QAAQ,EAAE;EACrC,EAAE,OAAO;EACT,IAAI,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,WAAW;EAC7C,IAAI,KAAK,EAAE,QAAQ,CAAC,KAAK;EACzB,GAAG,CAAC;EACJ,CAAC;EACD;EACA;EACA;AACA;AACA;EACA,SAAS,cAAc,CAAC,KAA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F,CADF,CAAA;EAKD;;;;;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@tanstack/react-query")):"function"==typeof define&&define.amd?define(["exports","react","@tanstack/react-query"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactQueryPersistClient={},e.React,e.ReactQuery)}(this,(function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var s=n(t);function i(e){return e.state.isPaused}function u(e){return"success"===e.state.status}function a(e,t={}){const r=[],n=[];if(!1!==t.dehydrateMutations){const n=t.shouldDehydrateMutation||i;e.getMutationCache().getAll().forEach((e=>{n(e)&&r.push(function(e){return{mutationKey:e.options.mutationKey,state:e.state}}(e))}))}if(!1!==t.dehydrateQueries){const r=t.shouldDehydrateQuery||u;e.getQueryCache().getAll().forEach((e=>{r(e)&&n.push(function(e){return{state:e.state,queryKey:e.queryKey,queryHash:e.queryHash}}(e))}))}return{mutations:r,queries:n}}const o=["added","removed","updated"];function c(e){return o.includes(e)}async function l({queryClient:e,persister:t,maxAge:r=864e5,buster:n="",hydrateOptions:s}){try{const i=await t.restoreClient();if(i)if(i.timestamp){const u=Date.now()-i.timestamp>r,a=i.buster!==n;u||a?t.removeClient():function(e,t,r){if("object"!=typeof t||null===t)return;const n=e.getMutationCache(),s=e.getQueryCache(),i=t.mutations||[],u=t.queries||[];i.forEach((t=>{var s;n.build(e,{...null==r||null==(s=r.defaultOptions)?void 0:s.mutations,mutationKey:t.mutationKey},t.state)})),u.forEach((({queryKey:t,state:n,queryHash:i})=>{var u;const a=s.get(i);if(a){if(a.state.dataUpdatedAt<n.dataUpdatedAt){const{fetchStatus:e,...t}=n;a.setState(t)}}else s.build(e,{...null==r||null==(u=r.defaultOptions)?void 0:u.queries,queryKey:t,queryHash:i},{...n,fetchStatus:"idle"})}))}(e,i.clientState,s)}else t.removeClient()}catch(e){t.removeClient()}}async function f({queryClient:e,persister:t,buster:r="",dehydrateOptions:n}){const s={buster:r,timestamp:Date.now(),clientState:a(e,n)};await t.persistClient(s)}function d(e){const t=e.queryClient.getQueryCache().subscribe((t=>{c(t.type)&&f(e)})),r=e.queryClient.getMutationCache().subscribe((t=>{c(t.type)&&f(e)}));return()=>{t(),r()}}function y(){return y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},y.apply(this,arguments)}e.PersistQueryClientProvider=({client:e,children:t,persistOptions:n,onSuccess:i,...u})=>{const[a,o]=s.useState(!0),c=s.useRef({persistOptions:n,onSuccess:i}),f=s.useRef(!1);return s.useEffect((()=>{c.current={persistOptions:n,onSuccess:i}})),s.useEffect((()=>{const t={...c.current.persistOptions,queryClient:e};return f.current||(f.current=!0,o(!0),l(t).then((async()=>{try{await(null==c.current.onSuccess?void 0:c.current.onSuccess())}finally{o(!1)}}))),a?void 0:d(t)}),[e,a]),s.createElement(r.QueryClientProvider,y({client:e},u),s.createElement(r.IsRestoringProvider,{value:a},t))},e.persistQueryClient=function(e){let t,r=!1;return[()=>{r=!0,null==t||t()},l(e).then((()=>{r||(t=d(e))}))]},e.persistQueryClientRestore=l,e.persistQueryClientSave=f,e.persistQueryClientSubscribe=d,e.removeOldestQuery=({persistedClient:e})=>{const t=[...e.clientState.mutations],r=[...e.clientState.queries],n={...e,clientState:{mutations:t,queries:r}},s=[...r].sort(((e,t)=>e.state.dataUpdatedAt-t.state.dataUpdatedAt));if(s.length>0){const e=s.shift();return n.clientState.queries=r.filter((t=>t!==e)),n}},Object.defineProperty(e,"__esModule",{value:!0})}));
2
+ //# sourceMappingURL=index.production.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.production.js","sources":["../../../query-core/build/lib/hydration.mjs","../../../query-persist-client-core/build/lib/persist.mjs","../../src/PersistQueryClientProvider.tsx","../../../query-persist-client-core/build/lib/retryStrategies.mjs"],"sourcesContent":["// TYPES\n// FUNCTIONS\nfunction dehydrateMutation(mutation) {\n return {\n mutationKey: mutation.options.mutationKey,\n state: mutation.state\n };\n} // Most config is not dehydrated but instead meant to configure again when\n// consuming the de/rehydrated data, typically with useQuery on the client.\n// Sometimes it might make sense to prefetch data on the server and include\n// in the html-payload, but not consume it on the initial render.\n\n\nfunction dehydrateQuery(query) {\n return {\n state: query.state,\n queryKey: query.queryKey,\n queryHash: query.queryHash\n };\n}\n\nfunction defaultShouldDehydrateMutation(mutation) {\n return mutation.state.isPaused;\n}\nfunction defaultShouldDehydrateQuery(query) {\n return query.state.status === 'success';\n}\nfunction dehydrate(client, options = {}) {\n const mutations = [];\n const queries = [];\n\n if (options.dehydrateMutations !== false) {\n const shouldDehydrateMutation = options.shouldDehydrateMutation || defaultShouldDehydrateMutation;\n client.getMutationCache().getAll().forEach(mutation => {\n if (shouldDehydrateMutation(mutation)) {\n mutations.push(dehydrateMutation(mutation));\n }\n });\n }\n\n if (options.dehydrateQueries !== false) {\n const shouldDehydrateQuery = options.shouldDehydrateQuery || defaultShouldDehydrateQuery;\n client.getQueryCache().getAll().forEach(query => {\n if (shouldDehydrateQuery(query)) {\n queries.push(dehydrateQuery(query));\n }\n });\n }\n\n return {\n mutations,\n queries\n };\n}\nfunction hydrate(client, dehydratedState, options) {\n if (typeof dehydratedState !== 'object' || dehydratedState === null) {\n return;\n }\n\n const mutationCache = client.getMutationCache();\n const queryCache = client.getQueryCache(); // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n\n const mutations = dehydratedState.mutations || []; // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n\n const queries = dehydratedState.queries || [];\n mutations.forEach(dehydratedMutation => {\n var _options$defaultOptio;\n\n mutationCache.build(client, { ...(options == null ? void 0 : (_options$defaultOptio = options.defaultOptions) == null ? void 0 : _options$defaultOptio.mutations),\n mutationKey: dehydratedMutation.mutationKey\n }, dehydratedMutation.state);\n });\n queries.forEach(({\n queryKey,\n state,\n queryHash\n }) => {\n var _options$defaultOptio2;\n\n const query = queryCache.get(queryHash); // Do not hydrate if an existing query exists with newer data\n\n if (query) {\n if (query.state.dataUpdatedAt < state.dataUpdatedAt) {\n // omit fetchStatus from dehydrated state\n // so that query stays in its current fetchStatus\n const {\n fetchStatus: _ignored,\n ...dehydratedQueryState\n } = state;\n query.setState(dehydratedQueryState);\n }\n\n return;\n } // Restore query\n\n\n queryCache.build(client, { ...(options == null ? void 0 : (_options$defaultOptio2 = options.defaultOptions) == null ? void 0 : _options$defaultOptio2.queries),\n queryKey,\n queryHash\n }, // Reset fetch status to idle to avoid\n // query being stuck in fetching state upon hydration\n { ...state,\n fetchStatus: 'idle'\n });\n });\n}\n\nexport { defaultShouldDehydrateMutation, defaultShouldDehydrateQuery, dehydrate, hydrate };\n//# sourceMappingURL=hydration.mjs.map\n","import { hydrate, dehydrate } from '@tanstack/query-core';\n\n/**\n * Checks if emitted event is about cache change and not about observers.\n * Useful for persist, where we only want to trigger save when cache is changed.\n */\nconst cacheableEventTypes = ['added', 'removed', 'updated'];\n\nfunction isCacheableEventType(eventType) {\n return cacheableEventTypes.includes(eventType);\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 */\n\n\nasync function persistQueryClientRestore({\n queryClient,\n persister,\n maxAge = 1000 * 60 * 60 * 24,\n buster = '',\n hydrateOptions\n}) {\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\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.getLogger().warn('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 * Persists data from the QueryCache\n * - data dehydrated using dehydrateOptions\n * - data is persisted using persister.persistClient\n */\n\nasync function persistQueryClientSave({\n queryClient,\n persister,\n buster = '',\n dehydrateOptions\n}) {\n const persistClient = {\n buster,\n timestamp: Date.now(),\n clientState: dehydrate(queryClient, dehydrateOptions)\n };\n await persister.persistClient(persistClient);\n}\n/**\n * Subscribe to QueryCache and MutationCache updates (for persisting)\n * @returns an unsubscribe function (to discontinue monitoring)\n */\n\nfunction persistQueryClientSubscribe(props) {\n const unsubscribeQueryCache = props.queryClient.getQueryCache().subscribe(event => {\n if (isCacheableEventType(event.type)) {\n persistQueryClientSave(props);\n }\n });\n const unusbscribeMutationCache = props.queryClient.getMutationCache().subscribe(event => {\n if (isCacheableEventType(event.type)) {\n persistQueryClientSave(props);\n }\n });\n return () => {\n unsubscribeQueryCache();\n unusbscribeMutationCache();\n };\n}\n/**\n * Restores persisted data to QueryCache and persists further changes.\n */\n\nfunction persistQueryClient(props) {\n let hasUnsubscribed = false;\n let persistQueryClientUnsubscribe;\n\n const unsubscribe = () => {\n hasUnsubscribed = true;\n persistQueryClientUnsubscribe == null ? void 0 : persistQueryClientUnsubscribe();\n }; // Attempt restore\n\n\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 return [unsubscribe, restorePromise];\n}\n\nexport { persistQueryClient, persistQueryClientRestore, persistQueryClientSave, persistQueryClientSubscribe };\n//# sourceMappingURL=persist.mjs.map\n","'use client'\nimport * as React from 'react'\n\nimport {\n persistQueryClientRestore,\n persistQueryClientSubscribe,\n} from '@tanstack/query-persist-client-core'\nimport { IsRestoringProvider, QueryClientProvider } from '@tanstack/react-query'\nimport type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'\nimport type { QueryClientProviderProps } 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 const didRestore = React.useRef(false)\n\n React.useEffect(() => {\n refs.current = { persistOptions, onSuccess }\n })\n\n React.useEffect(() => {\n const options = {\n ...refs.current.persistOptions,\n queryClient: client,\n }\n if (!didRestore.current) {\n didRestore.current = true\n setIsRestoring(true)\n persistQueryClientRestore(options).then(async () => {\n try {\n await refs.current.onSuccess?.()\n } finally {\n setIsRestoring(false)\n }\n })\n }\n return isRestoring ? undefined : persistQueryClientSubscribe(options)\n }, [client, isRestoring])\n\n return (\n <QueryClientProvider client={client} {...props}>\n <IsRestoringProvider value={isRestoring}>{children}</IsRestoringProvider>\n </QueryClientProvider>\n )\n}\n","const removeOldestQuery = ({\n persistedClient\n}) => {\n const mutations = [...persistedClient.clientState.mutations];\n const queries = [...persistedClient.clientState.queries];\n const client = { ...persistedClient,\n clientState: {\n mutations,\n queries\n }\n }; // sort queries by dataUpdatedAt (oldest first)\n\n const sortedQueries = [...queries].sort((a, b) => a.state.dataUpdatedAt - b.state.dataUpdatedAt); // clean oldest query\n\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\nexport { removeOldestQuery };\n//# sourceMappingURL=retryStrategies.mjs.map\n"],"names":["defaultShouldDehydrateMutation","mutation","state","isPaused","defaultShouldDehydrateQuery","query","status","dehydrate","client","options","mutations","queries","dehydrateMutations","shouldDehydrateMutation","getMutationCache","getAll","forEach","push","mutationKey","dehydrateMutation","dehydrateQueries","shouldDehydrateQuery","getQueryCache","queryKey","queryHash","dehydrateQuery","cacheableEventTypes","isCacheableEventType","eventType","includes","async","persistQueryClientRestore","queryClient","persister","maxAge","buster","hydrateOptions","persistedClient","restoreClient","timestamp","expired","Date","now","busted","removeClient","dehydratedState","mutationCache","queryCache","dehydratedMutation","_options$defaultOptio","build","defaultOptions","_options$defaultOptio2","get","dataUpdatedAt","fetchStatus","_ignored","dehydratedQueryState","setState","hydrate","clientState","err","persistQueryClientSave","dehydrateOptions","persistClient","persistQueryClientSubscribe","props","unsubscribeQueryCache","subscribe","event","type","unusbscribeMutationCache","children","persistOptions","onSuccess","isRestoring","setIsRestoring","React","useState","refs","useRef","didRestore","useEffect","current","then","undefined","QueryClientProvider","_extends","createElement","IsRestoringProvider","value","persistQueryClientUnsubscribe","hasUnsubscribed","sortedQueries","sort","a","b","length","oldestData","shift","filter","q"],"mappings":"opBAqBA,SAASA,EAA+BC,GACtC,OAAOA,EAASC,MAAMC,SAExB,SAASC,EAA4BC,GACnC,MAA8B,YAAvBA,EAAMH,MAAMI,OAErB,SAASC,EAAUC,EAAQC,EAAU,IACnC,MAAMC,EAAY,GACZC,EAAU,GAEhB,IAAmC,IAA/BF,EAAQG,mBAA8B,CACxC,MAAMC,EAA0BJ,EAAQI,yBAA2Bb,EACnEQ,EAAOM,mBAAmBC,SAASC,SAAQf,IACrCY,EAAwBZ,IAC1BS,EAAUO,KAjClB,SAA2BhB,GACzB,MAAO,CACLiB,YAAajB,EAASQ,QAAQS,YAC9BhB,MAAOD,EAASC,OA8BGiB,CAAkBlB,OAKvC,IAAiC,IAA7BQ,EAAQW,iBAA4B,CACtC,MAAMC,EAAuBZ,EAAQY,sBAAwBjB,EAC7DI,EAAOc,gBAAgBP,SAASC,SAAQX,IAClCgB,EAAqBhB,IACvBM,EAAQM,KA/BhB,SAAwBZ,GACtB,MAAO,CACLH,MAAOG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kB,EACe,MAAjCD,GAAiDA,KAI5B5D,EAA0BmC,GAAOkB,MAAK,KACtDQ,IAEHD,EAAgC1B,EAA4BC,sHE7GxC,EACxB7B,sBAEA,MAAM3B,EAAY,IAAI2B,EAAgBuB,YAAYlD,WAC5CC,EAAU,IAAI0B,EAAgBuB,YAAYjD,SAC1CH,EAAS,IAAK6B,EAClBuB,YAAa,CACXlD,YACAC,YAIEkF,EAAgB,IAAIlF,GAASmF,MAAK,CAACC,EAAGC,IAAMD,EAAE7F,MAAMoD,cAAgB0C,EAAE9F,MAAMoD,gBAElF,GAAIuC,EAAcI,OAAS,EAAG,CAC5B,MAAMC,EAAaL,EAAcM,QAEjC,OADA3F,EAAOoD,YAAYjD,QAAUA,EAAQyF,QAAOC,GAAKA,IAAMH,IAChD1F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-query-persist-client",
3
- "version": "4.39.0",
3
+ "version": "4.39.2",
4
4
  "description": "React bindings to work with persisters in TanStack/react-query",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -38,13 +38,13 @@
38
38
  "react-17": "npm:react@^17.0.2",
39
39
  "react-dom": "^18.2.0",
40
40
  "react-dom-17": "npm:react-dom@^17.0.2",
41
- "@tanstack/react-query": "4.39.0"
41
+ "@tanstack/react-query": "4.39.2"
42
42
  },
43
43
  "dependencies": {
44
- "@tanstack/query-persist-client-core": "4.39.0"
44
+ "@tanstack/query-persist-client-core": "4.39.2"
45
45
  },
46
46
  "peerDependencies": {
47
- "@tanstack/react-query": "^4.39.0"
47
+ "@tanstack/react-query": "^4.39.2"
48
48
  },
49
49
  "scripts": {}
50
50
  }