@readyfor/api-client-base 1.56.0-pr1408.9c29605 → 1.56.0-pr1409.5db8963
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.
|
@@ -6,11 +6,19 @@ let swr = require("swr");
|
|
|
6
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
7
|
//#region src/react/ApiClientConfigProvider.tsx
|
|
8
8
|
const ApiClientConfigContext = (0, react.createContext)(require_apiClientConfigStore.store);
|
|
9
|
+
const isConfigEqual = (a, b) => {
|
|
10
|
+
const aObj = a;
|
|
11
|
+
const bObj = b;
|
|
12
|
+
const aKeys = Object.keys(aObj);
|
|
13
|
+
return aKeys.length === Object.keys(bObj).length && aKeys.every((key) => aObj[key] === bObj[key]);
|
|
14
|
+
};
|
|
9
15
|
const ApiClientConfigProvider = (props) => {
|
|
10
16
|
const { swr: swr$1, ...config } = props.config;
|
|
11
|
-
(0, react.
|
|
17
|
+
const prevConfigRef = (0, react.useRef)(null);
|
|
18
|
+
if (prevConfigRef.current === null || !isConfigEqual(prevConfigRef.current, config)) {
|
|
12
19
|
require_apiClientConfigStore.store.setState(() => config);
|
|
13
|
-
|
|
20
|
+
prevConfigRef.current = config;
|
|
21
|
+
}
|
|
14
22
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ApiClientConfigContext.Provider, {
|
|
15
23
|
value: require_apiClientConfigStore.store,
|
|
16
24
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(swr.SWRConfig, {
|
package/dist/react/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as mergeRequestInit, r as store } from "../apiClientConfigStore-DDleIkQN.mjs";
|
|
2
|
-
import { createContext, useContext,
|
|
2
|
+
import { createContext, useContext, useMemo, useRef } from "react";
|
|
3
3
|
import { SWRConfig } from "swr";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import { useSyncExternalStore } from "use-sync-external-store/shim/index.js";
|
|
@@ -30,11 +30,19 @@ const createSwrConfig = (config) => ({
|
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/react/ApiClientConfigProvider.tsx
|
|
32
32
|
const ApiClientConfigContext = createContext(store);
|
|
33
|
+
const isConfigEqual = (a, b) => {
|
|
34
|
+
const aObj = a;
|
|
35
|
+
const bObj = b;
|
|
36
|
+
const aKeys = Object.keys(aObj);
|
|
37
|
+
return aKeys.length === Object.keys(bObj).length && aKeys.every((key) => aObj[key] === bObj[key]);
|
|
38
|
+
};
|
|
33
39
|
const ApiClientConfigProvider = (props) => {
|
|
34
40
|
const { swr, ...config } = props.config;
|
|
35
|
-
|
|
41
|
+
const prevConfigRef = useRef(null);
|
|
42
|
+
if (prevConfigRef.current === null || !isConfigEqual(prevConfigRef.current, config)) {
|
|
36
43
|
store.setState(() => config);
|
|
37
|
-
|
|
44
|
+
prevConfigRef.current = config;
|
|
45
|
+
}
|
|
38
46
|
return /* @__PURE__ */ jsx(ApiClientConfigContext.Provider, {
|
|
39
47
|
value: store,
|
|
40
48
|
children: /* @__PURE__ */ jsx(SWRConfig, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@readyfor/api-client-base",
|
|
3
|
-
"version": "1.56.0-
|
|
3
|
+
"version": "1.56.0-pr1409.5db8963",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@types/qs": "6.15.1",
|
|
36
36
|
"@types/react": "19.2.17",
|
|
37
37
|
"@types/use-sync-external-store": "1.5.0",
|
|
38
|
-
"react": "19.2.
|
|
38
|
+
"react": "19.2.8",
|
|
39
39
|
"swr": "2.4.2",
|
|
40
40
|
"use-sync-external-store": "1.6.0"
|
|
41
41
|
},
|