@readyfor/api-client-base 1.162.0-pr1409.3463941 → 1.162.0-pr1547.75ec076
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,24 +6,11 @@ let swr = require("swr");
|
|
|
6
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
7
|
// src/react/ApiClientConfigProvider.tsx
|
|
8
8
|
const ApiClientConfigContext = (0, react.createContext)(require_apiClientConfigStore.store);
|
|
9
|
-
const isConfigEqual = (prev, next) => {
|
|
10
|
-
const prevRecord = prev;
|
|
11
|
-
const nextRecord = next;
|
|
12
|
-
return [.../* @__PURE__ */ new Set([...Object.keys(prevRecord), ...Object.keys(nextRecord)])].every((key) => prevRecord[key] === nextRecord[key]);
|
|
13
|
-
};
|
|
14
|
-
const syncConfig = (config) => {
|
|
15
|
-
if (!isConfigEqual(require_apiClientConfigStore.store.getState(), config)) require_apiClientConfigStore.store.setState(() => config);
|
|
16
|
-
};
|
|
17
|
-
const isBrowser = typeof window !== "undefined";
|
|
18
|
-
const useIsomorphicLayoutEffect = isBrowser ? react.useLayoutEffect : react.useEffect;
|
|
19
9
|
const ApiClientConfigProvider = (props) => {
|
|
20
10
|
const { swr: swr$1, ...config } = props.config;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
isMountedRef.current = true;
|
|
25
|
-
syncConfig(config);
|
|
26
|
-
});
|
|
11
|
+
(0, react.useEffect)(() => {
|
|
12
|
+
require_apiClientConfigStore.store.setState(() => config);
|
|
13
|
+
}, [config]);
|
|
27
14
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ApiClientConfigContext.Provider, {
|
|
28
15
|
value: require_apiClientConfigStore.store,
|
|
29
16
|
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-DbTqjD1_.mjs";
|
|
2
|
-
import { createContext, useContext, useEffect,
|
|
2
|
+
import { createContext, useContext, useEffect, 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";
|
|
@@ -29,24 +29,11 @@ const createSwrConfig = (config) => ({
|
|
|
29
29
|
});
|
|
30
30
|
// src/react/ApiClientConfigProvider.tsx
|
|
31
31
|
const ApiClientConfigContext = createContext(store);
|
|
32
|
-
const isConfigEqual = (prev, next) => {
|
|
33
|
-
const prevRecord = prev;
|
|
34
|
-
const nextRecord = next;
|
|
35
|
-
return [.../* @__PURE__ */ new Set([...Object.keys(prevRecord), ...Object.keys(nextRecord)])].every((key) => prevRecord[key] === nextRecord[key]);
|
|
36
|
-
};
|
|
37
|
-
const syncConfig = (config) => {
|
|
38
|
-
if (!isConfigEqual(store.getState(), config)) store.setState(() => config);
|
|
39
|
-
};
|
|
40
|
-
const isBrowser = typeof window !== "undefined";
|
|
41
|
-
const useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : useEffect;
|
|
42
32
|
const ApiClientConfigProvider = (props) => {
|
|
43
33
|
const { swr, ...config } = props.config;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
isMountedRef.current = true;
|
|
48
|
-
syncConfig(config);
|
|
49
|
-
});
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
store.setState(() => config);
|
|
36
|
+
}, [config]);
|
|
50
37
|
return /* @__PURE__ */ jsx(ApiClientConfigContext.Provider, {
|
|
51
38
|
value: store,
|
|
52
39
|
children: /* @__PURE__ */ jsx(SWRConfig, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@readyfor/api-client-base",
|
|
3
|
-
"version": "1.162.0-
|
|
3
|
+
"version": "1.162.0-pr1547.75ec076",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -30,11 +30,9 @@
|
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/qs": "6.15.1",
|
|
32
32
|
"@types/react": "19.3.0",
|
|
33
|
-
"@types/react-dom": "19.3.0",
|
|
34
33
|
"@types/use-sync-external-store": "1.7.0",
|
|
35
34
|
"qs": "^6.15.2",
|
|
36
35
|
"react": "19.3.1",
|
|
37
|
-
"react-dom": "19.3.1",
|
|
38
36
|
"swr": "2.5.1",
|
|
39
37
|
"use-sync-external-store": "1.7.0",
|
|
40
38
|
"zod": "^4.3.6"
|