@unifold/react-provider 0.1.52 → 0.1.54
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/dist/index.d.mts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +9 -3
- package/dist/index.mjs +9 -3
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
3
4
|
|
|
4
5
|
interface UnifoldConfig {
|
|
5
6
|
publishableKey: string;
|
|
@@ -7,10 +8,18 @@ interface UnifoldConfig {
|
|
|
7
8
|
interface UnifoldProviderProps {
|
|
8
9
|
children: React.ReactNode;
|
|
9
10
|
publishableKey: string;
|
|
11
|
+
/**
|
|
12
|
+
* Bring your own TanStack QueryClient. When provided, UnifoldProvider will
|
|
13
|
+
* use this client and will NOT wrap children in a QueryClientProvider
|
|
14
|
+
* (it assumes one already exists higher in the tree).
|
|
15
|
+
*
|
|
16
|
+
* When omitted, an internal QueryClient is created automatically.
|
|
17
|
+
*/
|
|
18
|
+
queryClient?: QueryClient;
|
|
10
19
|
}
|
|
11
|
-
declare function UnifoldProvider({ children, publishableKey, }: UnifoldProviderProps): react_jsx_runtime.JSX.Element;
|
|
20
|
+
declare function UnifoldProvider({ children, publishableKey, queryClient: externalQueryClient, }: UnifoldProviderProps): react_jsx_runtime.JSX.Element;
|
|
12
21
|
declare function useUnifold(): {
|
|
13
22
|
publishableKey: string;
|
|
14
23
|
};
|
|
15
24
|
|
|
16
|
-
export { type UnifoldConfig, UnifoldProvider, useUnifold };
|
|
25
|
+
export { type UnifoldConfig, UnifoldProvider, type UnifoldProviderProps, useUnifold };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
3
4
|
|
|
4
5
|
interface UnifoldConfig {
|
|
5
6
|
publishableKey: string;
|
|
@@ -7,10 +8,18 @@ interface UnifoldConfig {
|
|
|
7
8
|
interface UnifoldProviderProps {
|
|
8
9
|
children: React.ReactNode;
|
|
9
10
|
publishableKey: string;
|
|
11
|
+
/**
|
|
12
|
+
* Bring your own TanStack QueryClient. When provided, UnifoldProvider will
|
|
13
|
+
* use this client and will NOT wrap children in a QueryClientProvider
|
|
14
|
+
* (it assumes one already exists higher in the tree).
|
|
15
|
+
*
|
|
16
|
+
* When omitted, an internal QueryClient is created automatically.
|
|
17
|
+
*/
|
|
18
|
+
queryClient?: QueryClient;
|
|
10
19
|
}
|
|
11
|
-
declare function UnifoldProvider({ children, publishableKey, }: UnifoldProviderProps): react_jsx_runtime.JSX.Element;
|
|
20
|
+
declare function UnifoldProvider({ children, publishableKey, queryClient: externalQueryClient, }: UnifoldProviderProps): react_jsx_runtime.JSX.Element;
|
|
12
21
|
declare function useUnifold(): {
|
|
13
22
|
publishableKey: string;
|
|
14
23
|
};
|
|
15
24
|
|
|
16
|
-
export { type UnifoldConfig, UnifoldProvider, useUnifold };
|
|
25
|
+
export { type UnifoldConfig, UnifoldProvider, type UnifoldProviderProps, useUnifold };
|
package/dist/index.js
CHANGED
|
@@ -40,9 +40,11 @@ var createQueryClient = () => new import_react_query.QueryClient({
|
|
|
40
40
|
});
|
|
41
41
|
function UnifoldProvider({
|
|
42
42
|
children,
|
|
43
|
-
publishableKey
|
|
43
|
+
publishableKey,
|
|
44
|
+
queryClient: externalQueryClient
|
|
44
45
|
}) {
|
|
45
|
-
const [
|
|
46
|
+
const [internalQueryClient] = (0, import_react.useState)(() => createQueryClient());
|
|
47
|
+
const queryClient = externalQueryClient ?? internalQueryClient;
|
|
46
48
|
(0, import_react.useEffect)(() => {
|
|
47
49
|
if (!publishableKey || publishableKey.trim() === "") {
|
|
48
50
|
throw new Error(
|
|
@@ -67,7 +69,11 @@ function UnifoldProvider({
|
|
|
67
69
|
}),
|
|
68
70
|
[publishableKey]
|
|
69
71
|
);
|
|
70
|
-
|
|
72
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(UnifoldContext.Provider, { value: contextValue, children });
|
|
73
|
+
if (externalQueryClient) {
|
|
74
|
+
return content;
|
|
75
|
+
}
|
|
76
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_query.QueryClientProvider, { client: queryClient, children: content });
|
|
71
77
|
}
|
|
72
78
|
function useUnifold() {
|
|
73
79
|
const context = (0, import_react.useContext)(UnifoldContext);
|
package/dist/index.mjs
CHANGED
|
@@ -20,9 +20,11 @@ var createQueryClient = () => new QueryClient({
|
|
|
20
20
|
});
|
|
21
21
|
function UnifoldProvider({
|
|
22
22
|
children,
|
|
23
|
-
publishableKey
|
|
23
|
+
publishableKey,
|
|
24
|
+
queryClient: externalQueryClient
|
|
24
25
|
}) {
|
|
25
|
-
const [
|
|
26
|
+
const [internalQueryClient] = useState(() => createQueryClient());
|
|
27
|
+
const queryClient = externalQueryClient ?? internalQueryClient;
|
|
26
28
|
useEffect(() => {
|
|
27
29
|
if (!publishableKey || publishableKey.trim() === "") {
|
|
28
30
|
throw new Error(
|
|
@@ -47,7 +49,11 @@ function UnifoldProvider({
|
|
|
47
49
|
}),
|
|
48
50
|
[publishableKey]
|
|
49
51
|
);
|
|
50
|
-
|
|
52
|
+
const content = /* @__PURE__ */ jsx(UnifoldContext.Provider, { value: contextValue, children });
|
|
53
|
+
if (externalQueryClient) {
|
|
54
|
+
return content;
|
|
55
|
+
}
|
|
56
|
+
return /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: content });
|
|
51
57
|
}
|
|
52
58
|
function useUnifold() {
|
|
53
59
|
const context = useContext(UnifoldContext);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unifold/react-provider",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.54",
|
|
4
4
|
"description": "Unifold React Provider - Core provider and context for Unifold React SDKs",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"react-dom": "^18.2.0 || ^19.0.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@tanstack/react-query": "^5.
|
|
23
|
+
"@tanstack/react-query": "^5.90.11"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/react": "^19.0.0",
|