@contentful/field-editor-shared 3.1.3 → 3.1.4-canary.8
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.
|
@@ -76,7 +76,9 @@ function useContentTypes(source) {
|
|
|
76
76
|
}
|
|
77
77
|
const unsubscribe = navigator.onSlideInNavigation(({ oldSlideLevel, newSlideLevel })=>{
|
|
78
78
|
if (oldSlideLevel > newSlideLevel) {
|
|
79
|
-
void queryClient.invalidateQueries(
|
|
79
|
+
void queryClient.invalidateQueries({
|
|
80
|
+
queryKey
|
|
81
|
+
});
|
|
80
82
|
}
|
|
81
83
|
});
|
|
82
84
|
return unsubscribe;
|
|
@@ -86,7 +88,9 @@ function useContentTypes(source) {
|
|
|
86
88
|
queryKey
|
|
87
89
|
]);
|
|
88
90
|
const invalidate = ()=>{
|
|
89
|
-
return queryClient.invalidateQueries(
|
|
91
|
+
return queryClient.invalidateQueries({
|
|
92
|
+
queryKey
|
|
93
|
+
});
|
|
90
94
|
};
|
|
91
95
|
return {
|
|
92
96
|
contentTypes,
|
package/dist/cjs/queryClient.js
CHANGED
|
@@ -62,8 +62,29 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
62
62
|
}
|
|
63
63
|
return newObj;
|
|
64
64
|
}
|
|
65
|
+
const rqVersion = require('@tanstack/react-query').version;
|
|
66
|
+
const RQ_MAJOR = parseInt(rqVersion ?? '4', 10);
|
|
67
|
+
const IS_V5 = RQ_MAJOR >= 5;
|
|
65
68
|
const clientContext = /*#__PURE__*/ _react.createContext(undefined);
|
|
66
69
|
let sharedQueryClientInstance;
|
|
70
|
+
function createDefaultQueryClient() {
|
|
71
|
+
return new _reactquery.QueryClient({
|
|
72
|
+
defaultOptions: {
|
|
73
|
+
queries: {
|
|
74
|
+
...IS_V5 ? {
|
|
75
|
+
throwOnError: false
|
|
76
|
+
} : {
|
|
77
|
+
useErrorBoundary: false
|
|
78
|
+
},
|
|
79
|
+
refetchOnWindowFocus: false,
|
|
80
|
+
refetchOnReconnect: true,
|
|
81
|
+
refetchOnMount: false,
|
|
82
|
+
staleTime: Infinity,
|
|
83
|
+
retry: false
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
67
88
|
function useMaybeHostQueryClient() {
|
|
68
89
|
try {
|
|
69
90
|
return (0, _reactquery.useQueryClient)();
|
|
@@ -80,18 +101,7 @@ function useQueryClient() {
|
|
|
80
101
|
}
|
|
81
102
|
if (hostClient) return hostClient;
|
|
82
103
|
if (!sharedQueryClientInstance) {
|
|
83
|
-
sharedQueryClientInstance =
|
|
84
|
-
defaultOptions: {
|
|
85
|
-
queries: {
|
|
86
|
-
useErrorBoundary: false,
|
|
87
|
-
refetchOnWindowFocus: false,
|
|
88
|
-
refetchOnReconnect: true,
|
|
89
|
-
refetchOnMount: false,
|
|
90
|
-
staleTime: Infinity,
|
|
91
|
-
retry: false
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
});
|
|
104
|
+
sharedQueryClientInstance = createDefaultQueryClient();
|
|
95
105
|
}
|
|
96
106
|
return sharedQueryClientInstance;
|
|
97
107
|
}, [
|
|
@@ -99,18 +109,35 @@ function useQueryClient() {
|
|
|
99
109
|
hostClient
|
|
100
110
|
]);
|
|
101
111
|
}
|
|
102
|
-
function
|
|
112
|
+
function useQueryV4(queryKey, queryFn, options) {
|
|
103
113
|
return (0, _reactquery.useQuery)(queryKey, queryFn, {
|
|
104
114
|
...options,
|
|
105
115
|
context: clientContext
|
|
106
116
|
});
|
|
107
117
|
}
|
|
118
|
+
function useQueryV5(queryKey, queryFn, options) {
|
|
119
|
+
const queryClient = useQueryClient();
|
|
120
|
+
return (0, _reactquery.useQuery)({
|
|
121
|
+
queryKey,
|
|
122
|
+
queryFn: queryFn,
|
|
123
|
+
...options,
|
|
124
|
+
client: queryClient
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
const useQuery = IS_V5 ? useQueryV5 : useQueryV4;
|
|
108
128
|
function SharedQueryClientProvider({ children, client: providedClient }) {
|
|
109
129
|
const internalClient = useQueryClient();
|
|
110
130
|
const client = _react.useMemo(()=>providedClient ?? internalClient, [
|
|
111
131
|
providedClient,
|
|
112
132
|
internalClient
|
|
113
133
|
]);
|
|
134
|
+
if (IS_V5) {
|
|
135
|
+
return /*#__PURE__*/ _react.createElement(_reactquery.QueryClientProvider, {
|
|
136
|
+
client: client
|
|
137
|
+
}, /*#__PURE__*/ _react.createElement(clientContext.Provider, {
|
|
138
|
+
value: client
|
|
139
|
+
}, children));
|
|
140
|
+
}
|
|
114
141
|
return /*#__PURE__*/ _react.createElement(clientContext.Provider, {
|
|
115
142
|
value: client
|
|
116
143
|
}, children);
|
|
@@ -55,7 +55,9 @@ export function useContentTypes(source) {
|
|
|
55
55
|
}
|
|
56
56
|
const unsubscribe = navigator.onSlideInNavigation(({ oldSlideLevel, newSlideLevel })=>{
|
|
57
57
|
if (oldSlideLevel > newSlideLevel) {
|
|
58
|
-
void queryClient.invalidateQueries(
|
|
58
|
+
void queryClient.invalidateQueries({
|
|
59
|
+
queryKey
|
|
60
|
+
});
|
|
59
61
|
}
|
|
60
62
|
});
|
|
61
63
|
return unsubscribe;
|
|
@@ -65,7 +67,9 @@ export function useContentTypes(source) {
|
|
|
65
67
|
queryKey
|
|
66
68
|
]);
|
|
67
69
|
const invalidate = ()=>{
|
|
68
|
-
return queryClient.invalidateQueries(
|
|
70
|
+
return queryClient.invalidateQueries({
|
|
71
|
+
queryKey
|
|
72
|
+
});
|
|
69
73
|
};
|
|
70
74
|
return {
|
|
71
75
|
contentTypes,
|
package/dist/esm/queryClient.js
CHANGED
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { QueryClient, useQuery as
|
|
2
|
+
import { QueryClient, QueryClientProvider, useQuery as useRQv4, useQueryClient as useHostQueryClientV4 } from '@tanstack/react-query';
|
|
3
|
+
const rqVersion = require('@tanstack/react-query').version;
|
|
4
|
+
const RQ_MAJOR = parseInt(rqVersion ?? '4', 10);
|
|
5
|
+
const IS_V5 = RQ_MAJOR >= 5;
|
|
3
6
|
const clientContext = /*#__PURE__*/ React.createContext(undefined);
|
|
4
7
|
let sharedQueryClientInstance;
|
|
8
|
+
function createDefaultQueryClient() {
|
|
9
|
+
return new QueryClient({
|
|
10
|
+
defaultOptions: {
|
|
11
|
+
queries: {
|
|
12
|
+
...IS_V5 ? {
|
|
13
|
+
throwOnError: false
|
|
14
|
+
} : {
|
|
15
|
+
useErrorBoundary: false
|
|
16
|
+
},
|
|
17
|
+
refetchOnWindowFocus: false,
|
|
18
|
+
refetchOnReconnect: true,
|
|
19
|
+
refetchOnMount: false,
|
|
20
|
+
staleTime: Infinity,
|
|
21
|
+
retry: false
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
5
26
|
function useMaybeHostQueryClient() {
|
|
6
27
|
try {
|
|
7
|
-
return
|
|
28
|
+
return useHostQueryClientV4();
|
|
8
29
|
} catch {
|
|
9
30
|
return undefined;
|
|
10
31
|
}
|
|
@@ -18,18 +39,7 @@ export function useQueryClient() {
|
|
|
18
39
|
}
|
|
19
40
|
if (hostClient) return hostClient;
|
|
20
41
|
if (!sharedQueryClientInstance) {
|
|
21
|
-
sharedQueryClientInstance =
|
|
22
|
-
defaultOptions: {
|
|
23
|
-
queries: {
|
|
24
|
-
useErrorBoundary: false,
|
|
25
|
-
refetchOnWindowFocus: false,
|
|
26
|
-
refetchOnReconnect: true,
|
|
27
|
-
refetchOnMount: false,
|
|
28
|
-
staleTime: Infinity,
|
|
29
|
-
retry: false
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
});
|
|
42
|
+
sharedQueryClientInstance = createDefaultQueryClient();
|
|
33
43
|
}
|
|
34
44
|
return sharedQueryClientInstance;
|
|
35
45
|
}, [
|
|
@@ -37,18 +47,35 @@ export function useQueryClient() {
|
|
|
37
47
|
hostClient
|
|
38
48
|
]);
|
|
39
49
|
}
|
|
40
|
-
|
|
41
|
-
return
|
|
50
|
+
function useQueryV4(queryKey, queryFn, options) {
|
|
51
|
+
return useRQv4(queryKey, queryFn, {
|
|
42
52
|
...options,
|
|
43
53
|
context: clientContext
|
|
44
54
|
});
|
|
45
55
|
}
|
|
56
|
+
function useQueryV5(queryKey, queryFn, options) {
|
|
57
|
+
const queryClient = useQueryClient();
|
|
58
|
+
return useRQv4({
|
|
59
|
+
queryKey,
|
|
60
|
+
queryFn: queryFn,
|
|
61
|
+
...options,
|
|
62
|
+
client: queryClient
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
export const useQuery = IS_V5 ? useQueryV5 : useQueryV4;
|
|
46
66
|
export function SharedQueryClientProvider({ children, client: providedClient }) {
|
|
47
67
|
const internalClient = useQueryClient();
|
|
48
68
|
const client = React.useMemo(()=>providedClient ?? internalClient, [
|
|
49
69
|
providedClient,
|
|
50
70
|
internalClient
|
|
51
71
|
]);
|
|
72
|
+
if (IS_V5) {
|
|
73
|
+
return /*#__PURE__*/ React.createElement(QueryClientProvider, {
|
|
74
|
+
client: client
|
|
75
|
+
}, /*#__PURE__*/ React.createElement(clientContext.Provider, {
|
|
76
|
+
value: client
|
|
77
|
+
}, children));
|
|
78
|
+
}
|
|
52
79
|
return /*#__PURE__*/ React.createElement(clientContext.Provider, {
|
|
53
80
|
value: client
|
|
54
81
|
}, children);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { QueryClient, type
|
|
2
|
+
import { QueryClient, type QueryFunction, type QueryKey, type UseQueryOptions, type UseQueryResult } from '@tanstack/react-query';
|
|
3
3
|
export declare function useQueryClient(): QueryClient;
|
|
4
|
-
export declare
|
|
4
|
+
export declare const 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'>) => UseQueryResult<TData, TError>;
|
|
5
5
|
/**
|
|
6
6
|
* Provides access to a query client either by sharing an existing client or
|
|
7
7
|
* creating a new one.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-shared",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.4-canary.8+19ccc7b3",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@contentful/app-sdk": "^4.29.0",
|
|
63
63
|
"@lingui/core": "^5.3.0",
|
|
64
|
-
"@tanstack/react-query": "^4.3.9",
|
|
64
|
+
"@tanstack/react-query": "^4.3.9 || ^5.0.0",
|
|
65
65
|
"react": ">=18.3.1",
|
|
66
66
|
"react-dom": ">=18.3.1"
|
|
67
67
|
},
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"publishConfig": {
|
|
74
74
|
"registry": "https://npm.pkg.github.com/"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "19ccc7b3b29cefce418f5d611081a4f3d18d0d54"
|
|
77
77
|
}
|