@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.
- package/build/cjs/react-query/build/esm/index.js +301 -0
- package/build/cjs/react-query/build/esm/index.js.map +1 -0
- package/build/cjs/react-query-persist-client/src/PersistQueryClientProvider.js +3 -3
- package/build/cjs/react-query-persist-client/src/PersistQueryClientProvider.js.map +1 -1
- package/build/esm/index.js +269 -9
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats.json +249 -0
- package/build/types/packages/query-core/src/focusManager.d.ts +16 -0
- package/build/types/packages/query-core/src/hydration.d.ts +34 -0
- package/build/types/packages/query-core/src/index.d.ts +20 -0
- package/build/types/packages/query-core/src/infiniteQueryBehavior.d.ts +15 -0
- package/build/types/packages/query-core/src/infiniteQueryObserver.d.ts +18 -0
- package/build/types/packages/query-core/src/logger.d.ts +8 -0
- package/build/types/packages/query-core/src/mutation.d.ts +70 -0
- package/build/types/packages/query-core/src/mutationCache.d.ts +52 -0
- package/build/types/packages/query-core/src/mutationObserver.d.ts +23 -0
- package/build/types/packages/query-core/src/notifyManager.d.ts +18 -0
- package/build/types/packages/query-core/src/onlineManager.d.ts +16 -0
- package/build/types/packages/query-core/src/queriesObserver.d.ts +23 -0
- package/build/types/packages/query-core/src/query.d.ts +119 -0
- package/build/types/packages/query-core/src/queryCache.d.ts +59 -0
- package/build/types/packages/query-core/src/queryClient.d.ts +65 -0
- package/build/types/packages/query-core/src/queryObserver.d.ts +61 -0
- package/build/types/packages/query-core/src/removable.d.ts +9 -0
- package/build/types/packages/query-core/src/retryer.d.ts +33 -0
- package/build/types/packages/query-core/src/subscribable.d.ts +10 -0
- package/build/types/packages/query-core/src/types.d.ts +417 -0
- package/build/types/packages/query-core/src/utils.d.ts +99 -0
- package/build/types/packages/react-query/src/Hydrate.d.ts +10 -0
- package/build/types/packages/react-query/src/QueryClientProvider.d.ts +24 -0
- package/build/types/packages/react-query/src/QueryErrorResetBoundary.d.ts +12 -0
- package/build/types/packages/react-query/src/index.d.ts +17 -0
- package/build/types/packages/react-query/src/isRestoring.d.ts +3 -0
- package/build/types/packages/react-query/src/reactBatchedUpdates.d.ts +2 -0
- package/build/types/packages/react-query/src/setBatchUpdatesFn.d.ts +1 -0
- package/build/types/packages/react-query/src/types.d.ts +35 -0
- package/build/types/packages/react-query/src/useBaseQuery.d.ts +3 -0
- package/build/types/packages/react-query/src/useInfiniteQuery.d.ts +5 -0
- package/build/types/packages/react-query/src/useIsFetching.d.ts +7 -0
- package/build/types/packages/react-query/src/useIsMutating.d.ts +7 -0
- package/build/types/packages/react-query/src/useMutation.d.ts +6 -0
- package/build/types/packages/react-query/src/useQueries.d.ts +49 -0
- package/build/types/packages/react-query/src/useQuery.d.ts +20 -0
- package/build/types/packages/react-query/src/utils.d.ts +1 -0
- package/build/types/packages/react-query-persist-client/src/PersistQueryClientProvider.d.ts +8 -0
- package/build/types/packages/react-query-persist-client/src/__tests__/PersistQueryClientProvider.test.d.ts +1 -0
- package/build/types/packages/react-query-persist-client/src/__tests__/persist.test.d.ts +1 -0
- package/build/types/packages/react-query-persist-client/src/index.d.ts +3 -0
- package/build/types/packages/react-query-persist-client/src/persist.d.ts +58 -0
- package/build/types/packages/react-query-persist-client/src/retryStrategies.d.ts +7 -0
- package/build/types/tests/utils.d.ts +24 -0
- package/build/umd/index.development.js +274 -14
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +22 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +3 -3
- package/build/cjs/PersistQueryClientProvider.js +0 -83
- package/build/cjs/PersistQueryClientProvider.js.map +0 -1
- package/build/cjs/index.js +0 -27
- package/build/cjs/index.js.map +0 -1
- package/build/cjs/persist.js +0 -119
- package/build/cjs/persist.js.map +0 -1
- package/build/cjs/retryStrategies.js +0 -39
- package/build/cjs/retryStrategies.js.map +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MutationKey, MutationFilters } from '@tanstack/query-core';
|
|
2
|
+
import { ContextOptions } from './types';
|
|
3
|
+
interface Options extends ContextOptions {
|
|
4
|
+
}
|
|
5
|
+
export declare function useIsMutating(filters?: MutationFilters, options?: Options): number;
|
|
6
|
+
export declare function useIsMutating(mutationKey?: MutationKey, filters?: Omit<MutationFilters, 'mutationKey'>, options?: Options): number;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MutationFunction, MutationKey } from '@tanstack/query-core';
|
|
2
|
+
import { UseMutationOptions, UseMutationResult } from './types';
|
|
3
|
+
export declare function useMutation<TData = unknown, TError = unknown, TVariables = void, TContext = unknown>(options: UseMutationOptions<TData, TError, TVariables, TContext>): UseMutationResult<TData, TError, TVariables, TContext>;
|
|
4
|
+
export declare function useMutation<TData = unknown, TError = unknown, TVariables = void, TContext = unknown>(mutationFn: MutationFunction<TData, TVariables>, options?: Omit<UseMutationOptions<TData, TError, TVariables, TContext>, 'mutationFn'>): UseMutationResult<TData, TError, TVariables, TContext>;
|
|
5
|
+
export declare function useMutation<TData = unknown, TError = unknown, TVariables = void, TContext = unknown>(mutationKey: MutationKey, options?: Omit<UseMutationOptions<TData, TError, TVariables, TContext>, 'mutationKey'>): UseMutationResult<TData, TError, TVariables, TContext>;
|
|
6
|
+
export declare function useMutation<TData = unknown, TError = unknown, TVariables = void, TContext = unknown>(mutationKey: MutationKey, mutationFn?: MutationFunction<TData, TVariables>, options?: Omit<UseMutationOptions<TData, TError, TVariables, TContext>, 'mutationKey' | 'mutationFn'>): UseMutationResult<TData, TError, TVariables, TContext>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { QueryKey, QueryFunction } from '@tanstack/query-core';
|
|
2
|
+
import { UseQueryOptions, UseQueryResult } from './types';
|
|
3
|
+
declare type UseQueryOptionsForUseQueries<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = Omit<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'context'>;
|
|
4
|
+
declare type MAXIMUM_DEPTH = 20;
|
|
5
|
+
declare type GetOptions<T> = T extends {
|
|
6
|
+
queryFnData: infer TQueryFnData;
|
|
7
|
+
error?: infer TError;
|
|
8
|
+
data: infer TData;
|
|
9
|
+
} ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData> : T extends {
|
|
10
|
+
queryFnData: infer TQueryFnData;
|
|
11
|
+
error?: infer TError;
|
|
12
|
+
} ? UseQueryOptionsForUseQueries<TQueryFnData, TError> : T extends {
|
|
13
|
+
data: infer TData;
|
|
14
|
+
error?: infer TError;
|
|
15
|
+
} ? UseQueryOptionsForUseQueries<unknown, TError, TData> : T extends [infer TQueryFnData, infer TError, infer TData] ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData> : T extends [infer TQueryFnData, infer TError] ? UseQueryOptionsForUseQueries<TQueryFnData, TError> : T extends [infer TQueryFnData] ? UseQueryOptionsForUseQueries<TQueryFnData> : T extends {
|
|
16
|
+
queryFn?: QueryFunction<infer TQueryFnData, infer TQueryKey>;
|
|
17
|
+
select: (data: any) => infer TData;
|
|
18
|
+
} ? UseQueryOptionsForUseQueries<TQueryFnData, unknown, TData, TQueryKey> : T extends {
|
|
19
|
+
queryFn?: QueryFunction<infer TQueryFnData, infer TQueryKey>;
|
|
20
|
+
} ? UseQueryOptionsForUseQueries<TQueryFnData, unknown, TQueryFnData, TQueryKey> : UseQueryOptionsForUseQueries;
|
|
21
|
+
declare type GetResults<T> = T extends {
|
|
22
|
+
queryFnData: any;
|
|
23
|
+
error?: infer TError;
|
|
24
|
+
data: infer TData;
|
|
25
|
+
} ? UseQueryResult<TData, TError> : T extends {
|
|
26
|
+
queryFnData: infer TQueryFnData;
|
|
27
|
+
error?: infer TError;
|
|
28
|
+
} ? UseQueryResult<TQueryFnData, TError> : T extends {
|
|
29
|
+
data: infer TData;
|
|
30
|
+
error?: infer TError;
|
|
31
|
+
} ? UseQueryResult<TData, TError> : T extends [any, infer TError, infer TData] ? UseQueryResult<TData, TError> : T extends [infer TQueryFnData, infer TError] ? UseQueryResult<TQueryFnData, TError> : T extends [infer TQueryFnData] ? UseQueryResult<TQueryFnData> : T extends {
|
|
32
|
+
queryFn?: QueryFunction<unknown, any>;
|
|
33
|
+
select: (data: any) => infer TData;
|
|
34
|
+
} ? UseQueryResult<TData> : T extends {
|
|
35
|
+
queryFn?: QueryFunction<infer TQueryFnData, any>;
|
|
36
|
+
} ? UseQueryResult<TQueryFnData> : UseQueryResult;
|
|
37
|
+
/**
|
|
38
|
+
* QueriesOptions reducer recursively unwraps function arguments to infer/enforce type param
|
|
39
|
+
*/
|
|
40
|
+
export declare type QueriesOptions<T extends any[], Result extends any[] = [], Depth extends ReadonlyArray<number> = []> = Depth['length'] extends MAXIMUM_DEPTH ? UseQueryOptionsForUseQueries[] : T extends [] ? [] : T extends [infer Head] ? [...Result, GetOptions<Head>] : T extends [infer Head, ...infer Tail] ? QueriesOptions<[...Tail], [...Result, GetOptions<Head>], [...Depth, 1]> : unknown[] extends T ? T : T extends UseQueryOptionsForUseQueries<infer TQueryFnData, infer TError, infer TData, infer TQueryKey>[] ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData, TQueryKey>[] : UseQueryOptionsForUseQueries[];
|
|
41
|
+
/**
|
|
42
|
+
* QueriesResults reducer recursively maps type param to results
|
|
43
|
+
*/
|
|
44
|
+
export declare type QueriesResults<T extends any[], Result extends any[] = [], Depth extends ReadonlyArray<number> = []> = Depth['length'] extends MAXIMUM_DEPTH ? UseQueryResult[] : T extends [] ? [] : T extends [infer Head] ? [...Result, GetResults<Head>] : T extends [infer Head, ...infer Tail] ? QueriesResults<[...Tail], [...Result, GetResults<Head>], [...Depth, 1]> : T extends UseQueryOptionsForUseQueries<infer TQueryFnData, infer TError, infer TData, any>[] ? UseQueryResult<unknown extends TData ? TQueryFnData : TData, TError>[] : UseQueryResult[];
|
|
45
|
+
export declare function useQueries<T extends any[]>({ queries, context, }: {
|
|
46
|
+
queries: readonly [...QueriesOptions<T>];
|
|
47
|
+
context?: UseQueryOptions['context'];
|
|
48
|
+
}): QueriesResults<T>;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { QueryFunction, QueryKey } from '@tanstack/query-core';
|
|
2
|
+
import { DefinedUseQueryResult, UseQueryOptions, UseQueryResult } from './types';
|
|
3
|
+
export declare function useQuery<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: Omit<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'initialData'> & {
|
|
4
|
+
initialData?: () => undefined;
|
|
5
|
+
}): UseQueryResult<TData, TError>;
|
|
6
|
+
export declare function useQuery<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: Omit<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'initialData'> & {
|
|
7
|
+
initialData: TQueryFnData | (() => TQueryFnData);
|
|
8
|
+
}): DefinedUseQueryResult<TData, TError>;
|
|
9
|
+
export declare function useQuery<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(queryKey: TQueryKey, options?: Omit<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryKey' | 'initialData'> & {
|
|
10
|
+
initialData?: () => undefined;
|
|
11
|
+
}): UseQueryResult<TData, TError>;
|
|
12
|
+
export declare function useQuery<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(queryKey: TQueryKey, options?: Omit<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryKey' | 'initialData'> & {
|
|
13
|
+
initialData: TQueryFnData | (() => TQueryFnData);
|
|
14
|
+
}): DefinedUseQueryResult<TData, TError>;
|
|
15
|
+
export declare function useQuery<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(queryKey: TQueryKey, queryFn: QueryFunction<TQueryFnData, TQueryKey>, options?: Omit<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryKey' | 'queryFn' | 'initialData'> & {
|
|
16
|
+
initialData?: () => undefined;
|
|
17
|
+
}): UseQueryResult<TData, TError>;
|
|
18
|
+
export declare function useQuery<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(queryKey: TQueryKey, queryFn: QueryFunction<TQueryFnData, TQueryKey>, options?: Omit<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryKey' | 'queryFn' | 'initialData'> & {
|
|
19
|
+
initialData: TQueryFnData | (() => TQueryFnData);
|
|
20
|
+
}): DefinedUseQueryResult<TData, TError>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function shouldThrowError<T extends (...args: any[]) => boolean>(_useErrorBoundary: boolean | T | undefined, params: Parameters<T>): boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { PersistQueryClientOptions } from './persist';
|
|
3
|
+
import { QueryClientProviderProps } from '@tanstack/react-query';
|
|
4
|
+
export declare type PersistQueryClientProviderProps = QueryClientProviderProps & {
|
|
5
|
+
persistOptions: Omit<PersistQueryClientOptions, 'queryClient'>;
|
|
6
|
+
onSuccess?: () => void;
|
|
7
|
+
};
|
|
8
|
+
export declare const PersistQueryClientProvider: ({ client, children, persistOptions, onSuccess, ...props }: PersistQueryClientProviderProps) => JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { QueryClient, DehydratedState, DehydrateOptions, HydrateOptions } from '@tanstack/query-core';
|
|
2
|
+
export declare type Promisable<T> = T | PromiseLike<T>;
|
|
3
|
+
export interface Persister {
|
|
4
|
+
persistClient(persistClient: PersistedClient): Promisable<void>;
|
|
5
|
+
restoreClient(): Promisable<PersistedClient | undefined>;
|
|
6
|
+
removeClient(): Promisable<void>;
|
|
7
|
+
}
|
|
8
|
+
export interface PersistedClient {
|
|
9
|
+
timestamp: number;
|
|
10
|
+
buster: string;
|
|
11
|
+
clientState: DehydratedState;
|
|
12
|
+
}
|
|
13
|
+
export interface PersistQueryClienRootOptions {
|
|
14
|
+
/** The QueryClient to persist */
|
|
15
|
+
queryClient: QueryClient;
|
|
16
|
+
/** The Persister interface for storing and restoring the cache
|
|
17
|
+
* to/from a persisted location */
|
|
18
|
+
persister: Persister;
|
|
19
|
+
/** A unique string that can be used to forcefully
|
|
20
|
+
* invalidate existing caches if they do not share the same buster string */
|
|
21
|
+
buster?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface PersistedQueryClientRestoreOptions extends PersistQueryClienRootOptions {
|
|
24
|
+
/** The max-allowed age of the cache in milliseconds.
|
|
25
|
+
* If a persisted cache is found that is older than this
|
|
26
|
+
* time, it will be discarded */
|
|
27
|
+
maxAge?: number;
|
|
28
|
+
/** The options passed to the hydrate function */
|
|
29
|
+
hydrateOptions?: HydrateOptions;
|
|
30
|
+
}
|
|
31
|
+
export interface PersistedQueryClientSaveOptions extends PersistQueryClienRootOptions {
|
|
32
|
+
/** The options passed to the dehydrate function */
|
|
33
|
+
dehydrateOptions?: DehydrateOptions;
|
|
34
|
+
}
|
|
35
|
+
export interface PersistQueryClientOptions extends PersistedQueryClientRestoreOptions, PersistedQueryClientSaveOptions, PersistQueryClienRootOptions {
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Restores persisted data to the QueryCache
|
|
39
|
+
* - data obtained from persister.restoreClient
|
|
40
|
+
* - data is hydrated using hydrateOptions
|
|
41
|
+
* If data is expired, busted, empty, or throws, it runs persister.removeClient
|
|
42
|
+
*/
|
|
43
|
+
export declare function persistQueryClientRestore({ queryClient, persister, maxAge, buster, hydrateOptions, }: PersistedQueryClientRestoreOptions): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Persists data from the QueryCache
|
|
46
|
+
* - data dehydrated using dehydrateOptions
|
|
47
|
+
* - data is persisted using persister.persistClient
|
|
48
|
+
*/
|
|
49
|
+
export declare function persistQueryClientSave({ queryClient, persister, buster, dehydrateOptions, }: PersistedQueryClientSaveOptions): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Subscribe to QueryCache and MutationCache updates (for persisting)
|
|
52
|
+
* @returns an unsubscribe function (to discontinue monitoring)
|
|
53
|
+
*/
|
|
54
|
+
export declare function persistQueryClientSubscribe(props: PersistedQueryClientSaveOptions): () => void;
|
|
55
|
+
/**
|
|
56
|
+
* Restores persisted data to QueryCache and persists further changes.
|
|
57
|
+
*/
|
|
58
|
+
export declare function persistQueryClient(props: PersistQueryClientOptions): [() => void, Promise<void>];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { MutationOptions, QueryClient, QueryClientConfig } from '@tanstack/query-core';
|
|
4
|
+
export declare function createQueryClient(config?: QueryClientConfig): QueryClient;
|
|
5
|
+
export declare function mockVisibilityState(value: DocumentVisibilityState): jest.SpyInstance<DocumentVisibilityState, []>;
|
|
6
|
+
export declare function mockNavigatorOnLine(value: boolean): jest.SpyInstance<boolean, []>;
|
|
7
|
+
export declare const mockLogger: {
|
|
8
|
+
log: jest.Mock<any, any>;
|
|
9
|
+
warn: jest.Mock<any, any>;
|
|
10
|
+
error: jest.Mock<any, any>;
|
|
11
|
+
};
|
|
12
|
+
export declare function queryKey(): Array<string>;
|
|
13
|
+
export declare function sleep(timeout: number): Promise<void>;
|
|
14
|
+
export declare function setActTimeout(fn: () => void, ms?: number): NodeJS.Timeout;
|
|
15
|
+
/**
|
|
16
|
+
* Assert the parameter is of a specific type.
|
|
17
|
+
*/
|
|
18
|
+
export declare const expectType: <T>(_: T) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Assert the parameter is not typed as `any`
|
|
21
|
+
*/
|
|
22
|
+
export declare const expectTypeNotAny: <T>(_: 0 extends 1 & T ? never : T) => void;
|
|
23
|
+
export declare const executeMutation: (queryClient: QueryClient, options: MutationOptions<any, any, any, any>) => Promise<unknown>;
|
|
24
|
+
export declare function setIsServer(isServer: boolean): () => void;
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
(function (global, factory) {
|
|
12
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('
|
|
13
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react', '
|
|
14
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactQueryPersistClient = {}, global.React
|
|
15
|
-
})(this, (function (exports, React
|
|
12
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('use-sync-external-store/shim')) :
|
|
13
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react', 'use-sync-external-store/shim'], factory) :
|
|
14
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactQueryPersistClient = {}, global.React));
|
|
15
|
+
})(this, (function (exports, React) { 'use strict';
|
|
16
16
|
|
|
17
17
|
function _interopNamespace(e) {
|
|
18
18
|
if (e && e.__esModule) return e;
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
*
|
|
45
45
|
* @license MIT
|
|
46
46
|
*/
|
|
47
|
-
class Subscribable {
|
|
47
|
+
class Subscribable$1 {
|
|
48
48
|
constructor() {
|
|
49
49
|
this.listeners = [];
|
|
50
50
|
this.subscribe = this.subscribe.bind(this);
|
|
@@ -73,16 +73,16 @@
|
|
|
73
73
|
|
|
74
74
|
// TYPES
|
|
75
75
|
// UTILS
|
|
76
|
-
const isServer = typeof window === 'undefined';
|
|
76
|
+
const isServer$1 = typeof window === 'undefined';
|
|
77
77
|
|
|
78
|
-
class FocusManager extends Subscribable {
|
|
78
|
+
class FocusManager$1 extends Subscribable$1 {
|
|
79
79
|
constructor() {
|
|
80
80
|
super();
|
|
81
81
|
|
|
82
82
|
this.setup = onFocus => {
|
|
83
83
|
// addEventListener does not exist in React Native, but window does
|
|
84
84
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
85
|
-
if (!isServer && window.addEventListener) {
|
|
85
|
+
if (!isServer$1 && window.addEventListener) {
|
|
86
86
|
const listener = () => onFocus(); // Listen to visibillitychange and focus
|
|
87
87
|
|
|
88
88
|
|
|
@@ -154,16 +154,16 @@
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
}
|
|
157
|
-
new FocusManager();
|
|
157
|
+
new FocusManager$1();
|
|
158
158
|
|
|
159
|
-
class OnlineManager extends Subscribable {
|
|
159
|
+
class OnlineManager$1 extends Subscribable$1 {
|
|
160
160
|
constructor() {
|
|
161
161
|
super();
|
|
162
162
|
|
|
163
163
|
this.setup = onOnline => {
|
|
164
164
|
// addEventListener does not exist in React Native, but window does
|
|
165
165
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
166
|
-
if (!isServer && window.addEventListener) {
|
|
166
|
+
if (!isServer$1 && window.addEventListener) {
|
|
167
167
|
const listener = () => onOnline(); // Listen to online
|
|
168
168
|
|
|
169
169
|
|
|
@@ -234,7 +234,7 @@
|
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
}
|
|
237
|
-
new OnlineManager();
|
|
237
|
+
new OnlineManager$1();
|
|
238
238
|
|
|
239
239
|
// TYPES
|
|
240
240
|
// FUNCTIONS
|
|
@@ -446,6 +446,266 @@
|
|
|
446
446
|
return _extends.apply(this, arguments);
|
|
447
447
|
}
|
|
448
448
|
|
|
449
|
+
/**
|
|
450
|
+
* react-query
|
|
451
|
+
*
|
|
452
|
+
* Copyright (c) TanStack
|
|
453
|
+
*
|
|
454
|
+
* This source code is licensed under the MIT license found in the
|
|
455
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
456
|
+
*
|
|
457
|
+
* @license MIT
|
|
458
|
+
*/
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* query-core
|
|
462
|
+
*
|
|
463
|
+
* Copyright (c) TanStack
|
|
464
|
+
*
|
|
465
|
+
* This source code is licensed under the MIT license found in the
|
|
466
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
467
|
+
*
|
|
468
|
+
* @license MIT
|
|
469
|
+
*/
|
|
470
|
+
class Subscribable {
|
|
471
|
+
constructor() {
|
|
472
|
+
this.listeners = [];
|
|
473
|
+
this.subscribe = this.subscribe.bind(this);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
subscribe(listener) {
|
|
477
|
+
this.listeners.push(listener);
|
|
478
|
+
this.onSubscribe();
|
|
479
|
+
return () => {
|
|
480
|
+
this.listeners = this.listeners.filter(x => x !== listener);
|
|
481
|
+
this.onUnsubscribe();
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
hasListeners() {
|
|
486
|
+
return this.listeners.length > 0;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
onSubscribe() {// Do nothing
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
onUnsubscribe() {// Do nothing
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// TYPES
|
|
498
|
+
// UTILS
|
|
499
|
+
const isServer = typeof window === 'undefined';
|
|
500
|
+
|
|
501
|
+
class FocusManager extends Subscribable {
|
|
502
|
+
constructor() {
|
|
503
|
+
super();
|
|
504
|
+
|
|
505
|
+
this.setup = onFocus => {
|
|
506
|
+
// addEventListener does not exist in React Native, but window does
|
|
507
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
508
|
+
if (!isServer && window.addEventListener) {
|
|
509
|
+
const listener = () => onFocus(); // Listen to visibillitychange and focus
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
window.addEventListener('visibilitychange', listener, false);
|
|
513
|
+
window.addEventListener('focus', listener, false);
|
|
514
|
+
return () => {
|
|
515
|
+
// Be sure to unsubscribe if a new handler is set
|
|
516
|
+
window.removeEventListener('visibilitychange', listener);
|
|
517
|
+
window.removeEventListener('focus', listener);
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
onSubscribe() {
|
|
524
|
+
if (!this.cleanup) {
|
|
525
|
+
this.setEventListener(this.setup);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
onUnsubscribe() {
|
|
530
|
+
if (!this.hasListeners()) {
|
|
531
|
+
var _this$cleanup;
|
|
532
|
+
|
|
533
|
+
(_this$cleanup = this.cleanup) == null ? void 0 : _this$cleanup.call(this);
|
|
534
|
+
this.cleanup = undefined;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
setEventListener(setup) {
|
|
539
|
+
var _this$cleanup2;
|
|
540
|
+
|
|
541
|
+
this.setup = setup;
|
|
542
|
+
(_this$cleanup2 = this.cleanup) == null ? void 0 : _this$cleanup2.call(this);
|
|
543
|
+
this.cleanup = setup(focused => {
|
|
544
|
+
if (typeof focused === 'boolean') {
|
|
545
|
+
this.setFocused(focused);
|
|
546
|
+
} else {
|
|
547
|
+
this.onFocus();
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
setFocused(focused) {
|
|
553
|
+
this.focused = focused;
|
|
554
|
+
|
|
555
|
+
if (focused) {
|
|
556
|
+
this.onFocus();
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
onFocus() {
|
|
561
|
+
this.listeners.forEach(listener => {
|
|
562
|
+
listener();
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
isFocused() {
|
|
567
|
+
if (typeof this.focused === 'boolean') {
|
|
568
|
+
return this.focused;
|
|
569
|
+
} // document global can be unavailable in react native
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
if (typeof document === 'undefined') {
|
|
573
|
+
return true;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
return [undefined, 'visible', 'prerender'].includes(document.visibilityState);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
}
|
|
580
|
+
new FocusManager();
|
|
581
|
+
|
|
582
|
+
class OnlineManager extends Subscribable {
|
|
583
|
+
constructor() {
|
|
584
|
+
super();
|
|
585
|
+
|
|
586
|
+
this.setup = onOnline => {
|
|
587
|
+
// addEventListener does not exist in React Native, but window does
|
|
588
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
589
|
+
if (!isServer && window.addEventListener) {
|
|
590
|
+
const listener = () => onOnline(); // Listen to online
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
window.addEventListener('online', listener, false);
|
|
594
|
+
window.addEventListener('offline', listener, false);
|
|
595
|
+
return () => {
|
|
596
|
+
// Be sure to unsubscribe if a new handler is set
|
|
597
|
+
window.removeEventListener('online', listener);
|
|
598
|
+
window.removeEventListener('offline', listener);
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
onSubscribe() {
|
|
605
|
+
if (!this.cleanup) {
|
|
606
|
+
this.setEventListener(this.setup);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
onUnsubscribe() {
|
|
611
|
+
if (!this.hasListeners()) {
|
|
612
|
+
var _this$cleanup;
|
|
613
|
+
|
|
614
|
+
(_this$cleanup = this.cleanup) == null ? void 0 : _this$cleanup.call(this);
|
|
615
|
+
this.cleanup = undefined;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
setEventListener(setup) {
|
|
620
|
+
var _this$cleanup2;
|
|
621
|
+
|
|
622
|
+
this.setup = setup;
|
|
623
|
+
(_this$cleanup2 = this.cleanup) == null ? void 0 : _this$cleanup2.call(this);
|
|
624
|
+
this.cleanup = setup(online => {
|
|
625
|
+
if (typeof online === 'boolean') {
|
|
626
|
+
this.setOnline(online);
|
|
627
|
+
} else {
|
|
628
|
+
this.onOnline();
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
setOnline(online) {
|
|
634
|
+
this.online = online;
|
|
635
|
+
|
|
636
|
+
if (online) {
|
|
637
|
+
this.onOnline();
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
onOnline() {
|
|
642
|
+
this.listeners.forEach(listener => {
|
|
643
|
+
listener();
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
isOnline() {
|
|
648
|
+
if (typeof this.online === 'boolean') {
|
|
649
|
+
return this.online;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
if (typeof navigator === 'undefined' || typeof navigator.onLine === 'undefined') {
|
|
653
|
+
return true;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
return navigator.onLine;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
}
|
|
660
|
+
new OnlineManager();
|
|
661
|
+
|
|
662
|
+
const defaultContext = /*#__PURE__*/React__namespace.createContext(undefined);
|
|
663
|
+
const QueryClientSharingContext = /*#__PURE__*/React__namespace.createContext(false); // If we are given a context, we will use it.
|
|
664
|
+
// Otherwise, if contextSharing is on, we share the first and at least one
|
|
665
|
+
// instance of the context across the window
|
|
666
|
+
// to ensure that if React Query is used across
|
|
667
|
+
// different bundles or microfrontends they will
|
|
668
|
+
// all use the same **instance** of context, regardless
|
|
669
|
+
// of module scoping.
|
|
670
|
+
|
|
671
|
+
function getQueryClientContext(context, contextSharing) {
|
|
672
|
+
if (context) {
|
|
673
|
+
return context;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
if (contextSharing && typeof window !== 'undefined') {
|
|
677
|
+
if (!window.ReactQueryClientContext) {
|
|
678
|
+
window.ReactQueryClientContext = defaultContext;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
return window.ReactQueryClientContext;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
return defaultContext;
|
|
685
|
+
}
|
|
686
|
+
const QueryClientProvider = ({
|
|
687
|
+
client,
|
|
688
|
+
children,
|
|
689
|
+
context,
|
|
690
|
+
contextSharing = false
|
|
691
|
+
}) => {
|
|
692
|
+
React__namespace.useEffect(() => {
|
|
693
|
+
client.mount();
|
|
694
|
+
return () => {
|
|
695
|
+
client.unmount();
|
|
696
|
+
};
|
|
697
|
+
}, [client]);
|
|
698
|
+
const Context = getQueryClientContext(context, contextSharing);
|
|
699
|
+
return /*#__PURE__*/React__namespace.createElement(QueryClientSharingContext.Provider, {
|
|
700
|
+
value: !context && contextSharing
|
|
701
|
+
}, /*#__PURE__*/React__namespace.createElement(Context.Provider, {
|
|
702
|
+
value: client
|
|
703
|
+
}, children));
|
|
704
|
+
};
|
|
705
|
+
|
|
706
|
+
const IsRestoringContext = /*#__PURE__*/React__namespace.createContext(false);
|
|
707
|
+
const IsRestoringProvider = IsRestoringContext.Provider;
|
|
708
|
+
|
|
449
709
|
const PersistQueryClientProvider = ({
|
|
450
710
|
client,
|
|
451
711
|
children,
|
|
@@ -481,9 +741,9 @@
|
|
|
481
741
|
unsubscribe();
|
|
482
742
|
};
|
|
483
743
|
}, [client]);
|
|
484
|
-
return /*#__PURE__*/React__namespace.createElement(
|
|
744
|
+
return /*#__PURE__*/React__namespace.createElement(QueryClientProvider, _extends({
|
|
485
745
|
client: client
|
|
486
|
-
}, props), /*#__PURE__*/React__namespace.createElement(
|
|
746
|
+
}, props), /*#__PURE__*/React__namespace.createElement(IsRestoringProvider, {
|
|
487
747
|
value: isRestoring
|
|
488
748
|
}, children));
|
|
489
749
|
};
|