@tanstack/react-query-persist-client 5.0.0-alpha.9 → 5.0.0-alpha.91
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/build/legacy/PersistQueryClientProvider.cjs +80 -0
- package/build/legacy/PersistQueryClientProvider.cjs.map +1 -0
- package/build/legacy/PersistQueryClientProvider.d.cts +10 -0
- package/build/legacy/PersistQueryClientProvider.d.ts +10 -0
- package/build/legacy/PersistQueryClientProvider.js +46 -0
- package/build/legacy/PersistQueryClientProvider.js.map +1 -0
- package/build/legacy/index.cjs +27 -0
- package/build/legacy/index.cjs.map +1 -0
- package/build/legacy/index.d.cts +3 -0
- package/build/legacy/index.d.ts +3 -0
- package/build/legacy/index.js +4 -0
- package/build/legacy/index.js.map +1 -0
- package/build/modern/PersistQueryClientProvider.cjs +79 -0
- package/build/modern/PersistQueryClientProvider.cjs.map +1 -0
- package/build/modern/PersistQueryClientProvider.d.cts +10 -0
- package/build/modern/PersistQueryClientProvider.d.ts +10 -0
- package/build/modern/PersistQueryClientProvider.js +45 -0
- package/build/modern/PersistQueryClientProvider.js.map +1 -0
- package/build/modern/index.cjs +27 -0
- package/build/modern/index.cjs.map +1 -0
- package/build/modern/index.d.cts +3 -0
- package/build/modern/index.d.ts +3 -0
- package/build/modern/index.js +4 -0
- package/build/modern/index.js.map +1 -0
- package/package.json +24 -18
- package/src/PersistQueryClientProvider.tsx +9 -6
- package/src/__tests__/PersistQueryClientProvider.test.tsx +74 -9
- package/src/__tests__/utils.ts +2 -2
- package/build/lib/PersistQueryClientProvider.d.ts +0 -7
- package/build/lib/PersistQueryClientProvider.esm.js +0 -51
- package/build/lib/PersistQueryClientProvider.esm.js.map +0 -1
- package/build/lib/PersistQueryClientProvider.js +0 -72
- package/build/lib/PersistQueryClientProvider.js.map +0 -1
- package/build/lib/PersistQueryClientProvider.mjs +0 -51
- package/build/lib/PersistQueryClientProvider.mjs.map +0 -1
- package/build/lib/__tests__/PersistQueryClientProvider.test.d.ts +0 -1
- package/build/lib/__tests__/utils.d.ts +0 -7
- package/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js +0 -17
- package/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js.map +0 -1
- package/build/lib/_virtual/_rollupPluginBabelHelpers.js +0 -19
- package/build/lib/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
- package/build/lib/_virtual/_rollupPluginBabelHelpers.mjs +0 -17
- package/build/lib/_virtual/_rollupPluginBabelHelpers.mjs.map +0 -1
- package/build/lib/index.d.ts +0 -2
- package/build/lib/index.esm.js +0 -3
- package/build/lib/index.esm.js.map +0 -1
- package/build/lib/index.js +0 -15
- package/build/lib/index.js.map +0 -1
- package/build/lib/index.mjs +0 -3
- package/build/lib/index.mjs.map +0 -1
- package/build/umd/index.development.js +0 -320
- package/build/umd/index.development.js.map +0 -1
- package/build/umd/index.production.js +0 -2
- package/build/umd/index.production.js.map +0 -1
|
@@ -2,19 +2,19 @@ import * as React from 'react'
|
|
|
2
2
|
import { render, waitFor } from '@testing-library/react'
|
|
3
3
|
import { vi } from 'vitest'
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from '
|
|
9
|
-
import {
|
|
5
|
+
import { QueryClient, useQueries, useQuery } from '@tanstack/react-query'
|
|
6
|
+
import { persistQueryClientSave } from '@tanstack/query-persist-client-core'
|
|
7
|
+
|
|
8
|
+
import { PersistQueryClientProvider } from '../PersistQueryClientProvider'
|
|
9
|
+
import { createQueryClient, queryKey, sleep } from './utils'
|
|
10
10
|
import type {
|
|
11
11
|
PersistedClient,
|
|
12
12
|
Persister,
|
|
13
13
|
} from '@tanstack/query-persist-client-core'
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
import type {
|
|
15
|
+
DefinedUseQueryResult,
|
|
16
|
+
UseQueryResult,
|
|
17
|
+
} from '@tanstack/react-query'
|
|
18
18
|
|
|
19
19
|
const createMockPersister = (): Persister => {
|
|
20
20
|
let storedState: PersistedClient | undefined
|
|
@@ -303,10 +303,13 @@ describe('PersistQueryClientProvider', () => {
|
|
|
303
303
|
|
|
304
304
|
queryClient.clear()
|
|
305
305
|
|
|
306
|
+
let fetched = false
|
|
307
|
+
|
|
306
308
|
function Page() {
|
|
307
309
|
const state = useQuery({
|
|
308
310
|
queryKey: key,
|
|
309
311
|
queryFn: async () => {
|
|
312
|
+
fetched = true
|
|
310
313
|
await sleep(10)
|
|
311
314
|
return 'fetched'
|
|
312
315
|
},
|
|
@@ -338,6 +341,8 @@ describe('PersistQueryClientProvider', () => {
|
|
|
338
341
|
|
|
339
342
|
expect(states).toHaveLength(2)
|
|
340
343
|
|
|
344
|
+
expect(fetched).toBe(false)
|
|
345
|
+
|
|
341
346
|
expect(states[0]).toMatchObject({
|
|
342
347
|
status: 'pending',
|
|
343
348
|
fetchStatus: 'idle',
|
|
@@ -401,6 +406,66 @@ describe('PersistQueryClientProvider', () => {
|
|
|
401
406
|
await waitFor(() => rendered.getByText('fetched'))
|
|
402
407
|
})
|
|
403
408
|
|
|
409
|
+
test('should await onSuccess after successful restoring', async () => {
|
|
410
|
+
const key = queryKey()
|
|
411
|
+
|
|
412
|
+
const queryClient = createQueryClient()
|
|
413
|
+
await queryClient.prefetchQuery({
|
|
414
|
+
queryKey: key,
|
|
415
|
+
queryFn: () => Promise.resolve('hydrated'),
|
|
416
|
+
})
|
|
417
|
+
|
|
418
|
+
const persister = createMockPersister()
|
|
419
|
+
|
|
420
|
+
await persistQueryClientSave({ queryClient, persister })
|
|
421
|
+
|
|
422
|
+
queryClient.clear()
|
|
423
|
+
|
|
424
|
+
const states: Array<string> = []
|
|
425
|
+
|
|
426
|
+
function Page() {
|
|
427
|
+
const { data, fetchStatus } = useQuery({
|
|
428
|
+
queryKey: key,
|
|
429
|
+
queryFn: async () => {
|
|
430
|
+
states.push('fetching')
|
|
431
|
+
await sleep(10)
|
|
432
|
+
states.push('fetched')
|
|
433
|
+
return 'fetched'
|
|
434
|
+
},
|
|
435
|
+
})
|
|
436
|
+
|
|
437
|
+
return (
|
|
438
|
+
<div>
|
|
439
|
+
<h1>{data}</h1>
|
|
440
|
+
<h2>fetchStatus: {fetchStatus}</h2>
|
|
441
|
+
</div>
|
|
442
|
+
)
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
const rendered = render(
|
|
446
|
+
<PersistQueryClientProvider
|
|
447
|
+
client={queryClient}
|
|
448
|
+
persistOptions={{ persister }}
|
|
449
|
+
onSuccess={async () => {
|
|
450
|
+
states.push('onSuccess')
|
|
451
|
+
await sleep(20)
|
|
452
|
+
states.push('onSuccess done')
|
|
453
|
+
}}
|
|
454
|
+
>
|
|
455
|
+
<Page />
|
|
456
|
+
</PersistQueryClientProvider>,
|
|
457
|
+
)
|
|
458
|
+
|
|
459
|
+
await waitFor(() => rendered.getByText('hydrated'))
|
|
460
|
+
await waitFor(() => rendered.getByText('fetched'))
|
|
461
|
+
expect(states).toEqual([
|
|
462
|
+
'onSuccess',
|
|
463
|
+
'onSuccess done',
|
|
464
|
+
'fetching',
|
|
465
|
+
'fetched',
|
|
466
|
+
])
|
|
467
|
+
})
|
|
468
|
+
|
|
404
469
|
test('should remove cache after non-successful restoring', async () => {
|
|
405
470
|
const key = queryKey()
|
|
406
471
|
const consoleMock = vi.spyOn(console, 'error')
|
package/src/__tests__/utils.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { act } from '@testing-library/react'
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
3
|
+
import { QueryClient } from '@tanstack/react-query'
|
|
4
|
+
import type { QueryClientConfig } from '@tanstack/react-query'
|
|
5
5
|
|
|
6
6
|
export function createQueryClient(config?: QueryClientConfig): QueryClient {
|
|
7
7
|
return new QueryClient(config)
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core';
|
|
2
|
-
import type { QueryClientProviderProps } from '@tanstack/react-query';
|
|
3
|
-
export declare type PersistQueryClientProviderProps = QueryClientProviderProps & {
|
|
4
|
-
persistOptions: Omit<PersistQueryClientOptions, 'queryClient'>;
|
|
5
|
-
onSuccess?: () => void;
|
|
6
|
-
};
|
|
7
|
-
export declare const PersistQueryClientProvider: ({ client, children, persistOptions, onSuccess, ...props }: PersistQueryClientProviderProps) => JSX.Element;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { extends as _extends } from './_virtual/_rollupPluginBabelHelpers.esm.js';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { persistQueryClient } 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
|
-
React.useEffect(() => {
|
|
20
|
-
refs.current = {
|
|
21
|
-
persistOptions,
|
|
22
|
-
onSuccess
|
|
23
|
-
};
|
|
24
|
-
});
|
|
25
|
-
React.useEffect(() => {
|
|
26
|
-
let isStale = false;
|
|
27
|
-
setIsRestoring(true);
|
|
28
|
-
const [unsubscribe, promise] = persistQueryClient({
|
|
29
|
-
...refs.current.persistOptions,
|
|
30
|
-
queryClient: client
|
|
31
|
-
});
|
|
32
|
-
promise.then(() => {
|
|
33
|
-
if (!isStale) {
|
|
34
|
-
refs.current.onSuccess == null ? void 0 : refs.current.onSuccess();
|
|
35
|
-
setIsRestoring(false);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
return () => {
|
|
39
|
-
isStale = true;
|
|
40
|
-
unsubscribe();
|
|
41
|
-
};
|
|
42
|
-
}, [client]);
|
|
43
|
-
return /*#__PURE__*/React.createElement(QueryClientProvider, _extends({
|
|
44
|
-
client: client
|
|
45
|
-
}, props), /*#__PURE__*/React.createElement(IsRestoringProvider, {
|
|
46
|
-
value: isRestoring
|
|
47
|
-
}, children));
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export { PersistQueryClientProvider };
|
|
51
|
-
//# sourceMappingURL=PersistQueryClientProvider.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PersistQueryClientProvider.esm.js","sources":["../../src/PersistQueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'\nimport { persistQueryClient } from '@tanstack/query-persist-client-core'\nimport type { QueryClientProviderProps } from '@tanstack/react-query'\nimport { QueryClientProvider, 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":["onSuccess","queryClient","isStale","unsubscribe"],"mappings":";;;;;;AAaO;;;;;;AAM0B;;AAE/B;;AAA4CA;AAAU;;;;AAGnBA;;AACnC;;;;AAKE;AACE;AACAC;AACF;;;;;AAME;AACF;AAEA;AACEC;AACAC;;AAEJ;AAEA;AACuB;;AACE;;AAG3B;;"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js');
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var queryPersistClientCore = require('@tanstack/query-persist-client-core');
|
|
7
|
-
var reactQuery = require('@tanstack/react-query');
|
|
8
|
-
|
|
9
|
-
function _interopNamespaceDefault(e) {
|
|
10
|
-
var n = Object.create(null);
|
|
11
|
-
if (e) {
|
|
12
|
-
Object.keys(e).forEach(function (k) {
|
|
13
|
-
if (k !== 'default') {
|
|
14
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: function () { return e[k]; }
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
n.default = e;
|
|
23
|
-
return Object.freeze(n);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
27
|
-
|
|
28
|
-
const PersistQueryClientProvider = ({
|
|
29
|
-
client,
|
|
30
|
-
children,
|
|
31
|
-
persistOptions,
|
|
32
|
-
onSuccess,
|
|
33
|
-
...props
|
|
34
|
-
}) => {
|
|
35
|
-
const [isRestoring, setIsRestoring] = React__namespace.useState(true);
|
|
36
|
-
const refs = React__namespace.useRef({
|
|
37
|
-
persistOptions,
|
|
38
|
-
onSuccess
|
|
39
|
-
});
|
|
40
|
-
React__namespace.useEffect(() => {
|
|
41
|
-
refs.current = {
|
|
42
|
-
persistOptions,
|
|
43
|
-
onSuccess
|
|
44
|
-
};
|
|
45
|
-
});
|
|
46
|
-
React__namespace.useEffect(() => {
|
|
47
|
-
let isStale = false;
|
|
48
|
-
setIsRestoring(true);
|
|
49
|
-
const [unsubscribe, promise] = queryPersistClientCore.persistQueryClient({
|
|
50
|
-
...refs.current.persistOptions,
|
|
51
|
-
queryClient: client
|
|
52
|
-
});
|
|
53
|
-
promise.then(() => {
|
|
54
|
-
if (!isStale) {
|
|
55
|
-
refs.current.onSuccess == null ? void 0 : refs.current.onSuccess();
|
|
56
|
-
setIsRestoring(false);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
return () => {
|
|
60
|
-
isStale = true;
|
|
61
|
-
unsubscribe();
|
|
62
|
-
};
|
|
63
|
-
}, [client]);
|
|
64
|
-
return /*#__PURE__*/React__namespace.createElement(reactQuery.QueryClientProvider, _rollupPluginBabelHelpers.extends({
|
|
65
|
-
client: client
|
|
66
|
-
}, props), /*#__PURE__*/React__namespace.createElement(reactQuery.IsRestoringProvider, {
|
|
67
|
-
value: isRestoring
|
|
68
|
-
}, children));
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
exports.PersistQueryClientProvider = PersistQueryClientProvider;
|
|
72
|
-
//# sourceMappingURL=PersistQueryClientProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PersistQueryClientProvider.js","sources":["../../src/PersistQueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'\nimport { persistQueryClient } from '@tanstack/query-persist-client-core'\nimport type { QueryClientProviderProps } from '@tanstack/react-query'\nimport { QueryClientProvider, 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":["onSuccess","queryClient","isStale","unsubscribe"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAaO;;;;;;AAM0B;;AAE/B;;AAA4CA;AAAU;;;;AAGnBA;;AACnC;;;;AAKE;AACE;AACAC;AACF;;;;;AAME;AACF;AAEA;AACEC;AACAC;;AAEJ;AAEA;AACuB;;AACE;;AAG3B;;"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { extends as _extends } from './_virtual/_rollupPluginBabelHelpers.mjs';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { persistQueryClient } 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
|
-
React.useEffect(() => {
|
|
20
|
-
refs.current = {
|
|
21
|
-
persistOptions,
|
|
22
|
-
onSuccess
|
|
23
|
-
};
|
|
24
|
-
});
|
|
25
|
-
React.useEffect(() => {
|
|
26
|
-
let isStale = false;
|
|
27
|
-
setIsRestoring(true);
|
|
28
|
-
const [unsubscribe, promise] = persistQueryClient({
|
|
29
|
-
...refs.current.persistOptions,
|
|
30
|
-
queryClient: client
|
|
31
|
-
});
|
|
32
|
-
promise.then(() => {
|
|
33
|
-
if (!isStale) {
|
|
34
|
-
refs.current.onSuccess?.();
|
|
35
|
-
setIsRestoring(false);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
return () => {
|
|
39
|
-
isStale = true;
|
|
40
|
-
unsubscribe();
|
|
41
|
-
};
|
|
42
|
-
}, [client]);
|
|
43
|
-
return /*#__PURE__*/React.createElement(QueryClientProvider, _extends({
|
|
44
|
-
client: client
|
|
45
|
-
}, props), /*#__PURE__*/React.createElement(IsRestoringProvider, {
|
|
46
|
-
value: isRestoring
|
|
47
|
-
}, children));
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export { PersistQueryClientProvider };
|
|
51
|
-
//# sourceMappingURL=PersistQueryClientProvider.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PersistQueryClientProvider.mjs","sources":["../../src/PersistQueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'\nimport { persistQueryClient } from '@tanstack/query-persist-client-core'\nimport type { QueryClientProviderProps } from '@tanstack/react-query'\nimport { QueryClientProvider, 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":["onSuccess","queryClient","refs","isStale","unsubscribe"],"mappings":";;;;;;AAaO;;;;;;AAM0B;;AAE/B;;AAA4CA;AAAU;;;;AAGnBA;;AACnC;;;;AAKE;AACE;AACAC;AACF;;;AAIIC;;AAEF;AACF;AAEA;AACEC;AACAC;;AAEJ;AAEA;AACuB;;AACE;;AAG3B;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { QueryClientConfig } from '@tanstack/query-core';
|
|
3
|
-
import { QueryClient } from '@tanstack/query-core';
|
|
4
|
-
export declare function createQueryClient(config?: QueryClientConfig): QueryClient;
|
|
5
|
-
export declare function queryKey(): Array<string>;
|
|
6
|
-
export declare function sleep(timeout: number): Promise<void>;
|
|
7
|
-
export declare function setActTimeout(fn: () => void, ms?: number): NodeJS.Timeout;
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
for (var key in source) {
|
|
6
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
7
|
-
target[key] = source[key];
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
return target;
|
|
12
|
-
};
|
|
13
|
-
return _extends.apply(this, arguments);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export { _extends as extends };
|
|
17
|
-
//# sourceMappingURL=_rollupPluginBabelHelpers.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_rollupPluginBabelHelpers.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function _extends() {
|
|
4
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
5
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
6
|
-
var source = arguments[i];
|
|
7
|
-
for (var key in source) {
|
|
8
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
9
|
-
target[key] = source[key];
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
return target;
|
|
14
|
-
};
|
|
15
|
-
return _extends.apply(this, arguments);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
exports.extends = _extends;
|
|
19
|
-
//# sourceMappingURL=_rollupPluginBabelHelpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_rollupPluginBabelHelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
for (var key in source) {
|
|
6
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
7
|
-
target[key] = source[key];
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
return target;
|
|
12
|
-
};
|
|
13
|
-
return _extends.apply(this, arguments);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export { _extends as extends };
|
|
17
|
-
//# sourceMappingURL=_rollupPluginBabelHelpers.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_rollupPluginBabelHelpers.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
|
package/build/lib/index.d.ts
DELETED
package/build/lib/index.esm.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/build/lib/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var queryPersistClientCore = require('@tanstack/query-persist-client-core');
|
|
4
|
-
var PersistQueryClientProvider = require('./PersistQueryClientProvider.js');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
exports.PersistQueryClientProvider = PersistQueryClientProvider.PersistQueryClientProvider;
|
|
9
|
-
Object.keys(queryPersistClientCore).forEach(function (k) {
|
|
10
|
-
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () { return queryPersistClientCore[k]; }
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
//# sourceMappingURL=index.js.map
|
package/build/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
|
package/build/lib/index.mjs
DELETED
package/build/lib/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|