@compilot/react-sdk 2.3.40-dev → 2.3.43-dev
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.
|
@@ -134,14 +134,10 @@ function _typeof(o) {
|
|
|
134
134
|
var toStateKey = function toStateKey(key) {
|
|
135
135
|
return key.join(":");
|
|
136
136
|
};
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
142
|
-
get: function get() {}
|
|
143
|
-
});
|
|
144
|
-
var compareState = function compareState(a, b) {
|
|
137
|
+
|
|
138
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
139
|
+
var GlobalStateContext = /*#__PURE__*/react.createContext([{}, function (_) {}]);
|
|
140
|
+
var compareStateValues = function compareStateValues(a, b) {
|
|
145
141
|
if (a === b) {
|
|
146
142
|
return 0;
|
|
147
143
|
}
|
|
@@ -152,56 +148,37 @@ var compareState = function compareState(a, b) {
|
|
|
152
148
|
};
|
|
153
149
|
var GlobalStateProvider = function GlobalStateProvider(_ref) {
|
|
154
150
|
var children = _ref.children;
|
|
155
|
-
var
|
|
156
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
157
|
-
state = _useState2[0],
|
|
158
|
-
setState = _useState2[1];
|
|
159
|
-
var set = react.useCallback(function (key, setterFn) {
|
|
160
|
-
setState(function (state) {
|
|
161
|
-
var stateKey = toStateKey(key);
|
|
162
|
-
var keyValue = state[stateKey];
|
|
163
|
-
var newValue = setterFn(state[stateKey]);
|
|
164
|
-
if (compareState(keyValue, newValue) !== 0) {
|
|
165
|
-
return _objectSpread2(_objectSpread2({}, state), {}, _defineProperty({}, stateKey, newValue));
|
|
166
|
-
}
|
|
167
|
-
return state;
|
|
168
|
-
});
|
|
169
|
-
}, [state, setState]);
|
|
170
|
-
var get = react.useCallback(function (key) {
|
|
171
|
-
return state[toStateKey(key)];
|
|
172
|
-
}, [state]);
|
|
173
|
-
var value = react.useMemo(function () {
|
|
174
|
-
return {
|
|
175
|
-
set: set,
|
|
176
|
-
get: get
|
|
177
|
-
};
|
|
178
|
-
}, [get, set]);
|
|
151
|
+
var value = react.useState({});
|
|
179
152
|
return /*#__PURE__*/jsxRuntime.jsx(GlobalStateContext.Provider, {
|
|
180
153
|
value: value,
|
|
181
154
|
children: children
|
|
182
155
|
});
|
|
183
156
|
};
|
|
184
157
|
function useGlobalState(_ref2) {
|
|
158
|
+
var _state$stateKey;
|
|
185
159
|
var key = _ref2.key,
|
|
186
160
|
defaultValue = _ref2.defaultValue;
|
|
187
161
|
var _useContext = react.useContext(GlobalStateContext),
|
|
188
|
-
|
|
189
|
-
|
|
162
|
+
_useContext2 = _slicedToArray(_useContext, 2),
|
|
163
|
+
state = _useContext2[0],
|
|
164
|
+
setState = _useContext2[1];
|
|
165
|
+
var stateKey = toStateKey(key);
|
|
190
166
|
var memoizedDefaultValue = react.useMemo(function () {
|
|
191
167
|
return defaultValue;
|
|
192
168
|
}, []);
|
|
193
|
-
var
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
169
|
+
var stateValue = (_state$stateKey = state[stateKey]) !== null && _state$stateKey !== void 0 ? _state$stateKey : memoizedDefaultValue;
|
|
170
|
+
var setterFn = react.useCallback(function (setterFn) {
|
|
171
|
+
setState(function (state) {
|
|
172
|
+
var newValue = setterFn(stateValue);
|
|
173
|
+
if (compareStateValues(stateValue, newValue) !== 0) {
|
|
174
|
+
return _objectSpread2(_objectSpread2({}, state), {}, _defineProperty({}, stateKey, newValue));
|
|
175
|
+
}
|
|
176
|
+
return state;
|
|
200
177
|
});
|
|
201
|
-
}, [
|
|
178
|
+
}, [stateKey, stateValue, setState]);
|
|
202
179
|
return react.useMemo(function () {
|
|
203
|
-
return [
|
|
204
|
-
}, [
|
|
180
|
+
return [stateValue, setterFn];
|
|
181
|
+
}, [stateValue, setterFn]);
|
|
205
182
|
}
|
|
206
183
|
|
|
207
184
|
var ComPilotContext = /*#__PURE__*/react.createContext(null);
|
|
@@ -765,15 +742,13 @@ var useAuthenticate = function useAuthenticate(loginParams) {
|
|
|
765
742
|
});
|
|
766
743
|
react.useEffect(function () {
|
|
767
744
|
var unsubscribe = webSdk.watchIsAuthenticated(config, {
|
|
768
|
-
onIsAuthenticatedChange:
|
|
769
|
-
mutationState.setData(isAuthenticated);
|
|
770
|
-
},
|
|
745
|
+
onIsAuthenticatedChange: mutationState.setData,
|
|
771
746
|
onIsLoadingChange: mutationState.setPending
|
|
772
747
|
});
|
|
773
748
|
return function () {
|
|
774
749
|
unsubscribe();
|
|
775
750
|
};
|
|
776
|
-
}, [config._internal.
|
|
751
|
+
}, [config._internal.identifier, mutationState.setData, mutationState.setPending]);
|
|
777
752
|
return mutationState;
|
|
778
753
|
};
|
|
779
754
|
|
|
@@ -134,14 +134,10 @@ function _typeof(o) {
|
|
|
134
134
|
var toStateKey = function toStateKey(key) {
|
|
135
135
|
return key.join(":");
|
|
136
136
|
};
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
142
|
-
get: function get() {}
|
|
143
|
-
});
|
|
144
|
-
var compareState = function compareState(a, b) {
|
|
137
|
+
|
|
138
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
139
|
+
var GlobalStateContext = /*#__PURE__*/react.createContext([{}, function (_) {}]);
|
|
140
|
+
var compareStateValues = function compareStateValues(a, b) {
|
|
145
141
|
if (a === b) {
|
|
146
142
|
return 0;
|
|
147
143
|
}
|
|
@@ -152,56 +148,37 @@ var compareState = function compareState(a, b) {
|
|
|
152
148
|
};
|
|
153
149
|
var GlobalStateProvider = function GlobalStateProvider(_ref) {
|
|
154
150
|
var children = _ref.children;
|
|
155
|
-
var
|
|
156
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
157
|
-
state = _useState2[0],
|
|
158
|
-
setState = _useState2[1];
|
|
159
|
-
var set = react.useCallback(function (key, setterFn) {
|
|
160
|
-
setState(function (state) {
|
|
161
|
-
var stateKey = toStateKey(key);
|
|
162
|
-
var keyValue = state[stateKey];
|
|
163
|
-
var newValue = setterFn(state[stateKey]);
|
|
164
|
-
if (compareState(keyValue, newValue) !== 0) {
|
|
165
|
-
return _objectSpread2(_objectSpread2({}, state), {}, _defineProperty({}, stateKey, newValue));
|
|
166
|
-
}
|
|
167
|
-
return state;
|
|
168
|
-
});
|
|
169
|
-
}, [state, setState]);
|
|
170
|
-
var get = react.useCallback(function (key) {
|
|
171
|
-
return state[toStateKey(key)];
|
|
172
|
-
}, [state]);
|
|
173
|
-
var value = react.useMemo(function () {
|
|
174
|
-
return {
|
|
175
|
-
set: set,
|
|
176
|
-
get: get
|
|
177
|
-
};
|
|
178
|
-
}, [get, set]);
|
|
151
|
+
var value = react.useState({});
|
|
179
152
|
return /*#__PURE__*/jsxRuntime.jsx(GlobalStateContext.Provider, {
|
|
180
153
|
value: value,
|
|
181
154
|
children: children
|
|
182
155
|
});
|
|
183
156
|
};
|
|
184
157
|
function useGlobalState(_ref2) {
|
|
158
|
+
var _state$stateKey;
|
|
185
159
|
var key = _ref2.key,
|
|
186
160
|
defaultValue = _ref2.defaultValue;
|
|
187
161
|
var _useContext = react.useContext(GlobalStateContext),
|
|
188
|
-
|
|
189
|
-
|
|
162
|
+
_useContext2 = _slicedToArray(_useContext, 2),
|
|
163
|
+
state = _useContext2[0],
|
|
164
|
+
setState = _useContext2[1];
|
|
165
|
+
var stateKey = toStateKey(key);
|
|
190
166
|
var memoizedDefaultValue = react.useMemo(function () {
|
|
191
167
|
return defaultValue;
|
|
192
168
|
}, []);
|
|
193
|
-
var
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
169
|
+
var stateValue = (_state$stateKey = state[stateKey]) !== null && _state$stateKey !== void 0 ? _state$stateKey : memoizedDefaultValue;
|
|
170
|
+
var setterFn = react.useCallback(function (setterFn) {
|
|
171
|
+
setState(function (state) {
|
|
172
|
+
var newValue = setterFn(stateValue);
|
|
173
|
+
if (compareStateValues(stateValue, newValue) !== 0) {
|
|
174
|
+
return _objectSpread2(_objectSpread2({}, state), {}, _defineProperty({}, stateKey, newValue));
|
|
175
|
+
}
|
|
176
|
+
return state;
|
|
200
177
|
});
|
|
201
|
-
}, [
|
|
178
|
+
}, [stateKey, stateValue, setState]);
|
|
202
179
|
return react.useMemo(function () {
|
|
203
|
-
return [
|
|
204
|
-
}, [
|
|
180
|
+
return [stateValue, setterFn];
|
|
181
|
+
}, [stateValue, setterFn]);
|
|
205
182
|
}
|
|
206
183
|
|
|
207
184
|
var ComPilotContext = /*#__PURE__*/react.createContext(null);
|
|
@@ -765,15 +742,13 @@ var useAuthenticate = function useAuthenticate(loginParams) {
|
|
|
765
742
|
});
|
|
766
743
|
react.useEffect(function () {
|
|
767
744
|
var unsubscribe = webSdk.watchIsAuthenticated(config, {
|
|
768
|
-
onIsAuthenticatedChange:
|
|
769
|
-
mutationState.setData(isAuthenticated);
|
|
770
|
-
},
|
|
745
|
+
onIsAuthenticatedChange: mutationState.setData,
|
|
771
746
|
onIsLoadingChange: mutationState.setPending
|
|
772
747
|
});
|
|
773
748
|
return function () {
|
|
774
749
|
unsubscribe();
|
|
775
750
|
};
|
|
776
|
-
}, [config._internal.
|
|
751
|
+
}, [config._internal.identifier, mutationState.setData, mutationState.setPending]);
|
|
777
752
|
return mutationState;
|
|
778
753
|
};
|
|
779
754
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useState,
|
|
1
|
+
import { useEffect, useState, createContext, useContext, useMemo, useCallback } from 'react';
|
|
2
2
|
import { load, authenticate, isAuthenticated, watchIsAuthenticated, watchCustomerStatus, watchWidgetVisibleState, getCustomerStatus, disconnect, getTxAuthDataSignature, getIdentityId, getIdentityWallets, attachWalletToIdentity, openWidget, isOpen } from '@compilot/web-sdk';
|
|
3
3
|
export * from '@compilot/web-sdk';
|
|
4
4
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
@@ -131,14 +131,10 @@ function _typeof(o) {
|
|
|
131
131
|
var toStateKey = function toStateKey(key) {
|
|
132
132
|
return key.join(":");
|
|
133
133
|
};
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
139
|
-
get: function get() {}
|
|
140
|
-
});
|
|
141
|
-
var compareState = function compareState(a, b) {
|
|
134
|
+
|
|
135
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
136
|
+
var GlobalStateContext = /*#__PURE__*/createContext([{}, function (_) {}]);
|
|
137
|
+
var compareStateValues = function compareStateValues(a, b) {
|
|
142
138
|
if (a === b) {
|
|
143
139
|
return 0;
|
|
144
140
|
}
|
|
@@ -149,56 +145,37 @@ var compareState = function compareState(a, b) {
|
|
|
149
145
|
};
|
|
150
146
|
var GlobalStateProvider = function GlobalStateProvider(_ref) {
|
|
151
147
|
var children = _ref.children;
|
|
152
|
-
var
|
|
153
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
154
|
-
state = _useState2[0],
|
|
155
|
-
setState = _useState2[1];
|
|
156
|
-
var set = useCallback(function (key, setterFn) {
|
|
157
|
-
setState(function (state) {
|
|
158
|
-
var stateKey = toStateKey(key);
|
|
159
|
-
var keyValue = state[stateKey];
|
|
160
|
-
var newValue = setterFn(state[stateKey]);
|
|
161
|
-
if (compareState(keyValue, newValue) !== 0) {
|
|
162
|
-
return _objectSpread2(_objectSpread2({}, state), {}, _defineProperty({}, stateKey, newValue));
|
|
163
|
-
}
|
|
164
|
-
return state;
|
|
165
|
-
});
|
|
166
|
-
}, [state, setState]);
|
|
167
|
-
var get = useCallback(function (key) {
|
|
168
|
-
return state[toStateKey(key)];
|
|
169
|
-
}, [state]);
|
|
170
|
-
var value = useMemo(function () {
|
|
171
|
-
return {
|
|
172
|
-
set: set,
|
|
173
|
-
get: get
|
|
174
|
-
};
|
|
175
|
-
}, [get, set]);
|
|
148
|
+
var value = useState({});
|
|
176
149
|
return /*#__PURE__*/jsx(GlobalStateContext.Provider, {
|
|
177
150
|
value: value,
|
|
178
151
|
children: children
|
|
179
152
|
});
|
|
180
153
|
};
|
|
181
154
|
function useGlobalState(_ref2) {
|
|
155
|
+
var _state$stateKey;
|
|
182
156
|
var key = _ref2.key,
|
|
183
157
|
defaultValue = _ref2.defaultValue;
|
|
184
158
|
var _useContext = useContext(GlobalStateContext),
|
|
185
|
-
|
|
186
|
-
|
|
159
|
+
_useContext2 = _slicedToArray(_useContext, 2),
|
|
160
|
+
state = _useContext2[0],
|
|
161
|
+
setState = _useContext2[1];
|
|
162
|
+
var stateKey = toStateKey(key);
|
|
187
163
|
var memoizedDefaultValue = useMemo(function () {
|
|
188
164
|
return defaultValue;
|
|
189
165
|
}, []);
|
|
190
|
-
var
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
166
|
+
var stateValue = (_state$stateKey = state[stateKey]) !== null && _state$stateKey !== void 0 ? _state$stateKey : memoizedDefaultValue;
|
|
167
|
+
var setterFn = useCallback(function (setterFn) {
|
|
168
|
+
setState(function (state) {
|
|
169
|
+
var newValue = setterFn(stateValue);
|
|
170
|
+
if (compareStateValues(stateValue, newValue) !== 0) {
|
|
171
|
+
return _objectSpread2(_objectSpread2({}, state), {}, _defineProperty({}, stateKey, newValue));
|
|
172
|
+
}
|
|
173
|
+
return state;
|
|
197
174
|
});
|
|
198
|
-
}, [
|
|
175
|
+
}, [stateKey, stateValue, setState]);
|
|
199
176
|
return useMemo(function () {
|
|
200
|
-
return [
|
|
201
|
-
}, [
|
|
177
|
+
return [stateValue, setterFn];
|
|
178
|
+
}, [stateValue, setterFn]);
|
|
202
179
|
}
|
|
203
180
|
|
|
204
181
|
var ComPilotContext = /*#__PURE__*/createContext(null);
|
|
@@ -762,15 +739,13 @@ var useAuthenticate = function useAuthenticate(loginParams) {
|
|
|
762
739
|
});
|
|
763
740
|
useEffect(function () {
|
|
764
741
|
var unsubscribe = watchIsAuthenticated(config, {
|
|
765
|
-
onIsAuthenticatedChange:
|
|
766
|
-
mutationState.setData(isAuthenticated);
|
|
767
|
-
},
|
|
742
|
+
onIsAuthenticatedChange: mutationState.setData,
|
|
768
743
|
onIsLoadingChange: mutationState.setPending
|
|
769
744
|
});
|
|
770
745
|
return function () {
|
|
771
746
|
unsubscribe();
|
|
772
747
|
};
|
|
773
|
-
}, [config._internal.
|
|
748
|
+
}, [config._internal.identifier, mutationState.setData, mutationState.setPending]);
|
|
774
749
|
return mutationState;
|
|
775
750
|
};
|
|
776
751
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthenticate.d.ts","sourceRoot":"../../../../src/hooks","sources":["useAuthenticate.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,0CAAuC;AAGzE;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,iBACZ,WAAW,KACxB,kBAAkB,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"useAuthenticate.d.ts","sourceRoot":"../../../../src/hooks","sources":["useAuthenticate.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,0CAAuC;AAGzE;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,iBACZ,WAAW,KACxB,kBAAkB,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,cAAc,CA+B3D,CAAC"}
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@compilot/react-sdk",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.43-dev",
|
|
4
4
|
"description": "ComPilot React SDK",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "ISC",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"pino": "^9.5.0",
|
|
35
35
|
"zod": "^3.23.8",
|
|
36
|
-
"@compilot/web-sdk": "2.3.
|
|
37
|
-
"@nexeraid/identity-api-client": "2.3.
|
|
38
|
-
"@nexeraid/identity-schemas": "2.
|
|
39
|
-
"@nexeraid/logger": "2.3.
|
|
36
|
+
"@compilot/web-sdk": "2.3.43-dev",
|
|
37
|
+
"@nexeraid/identity-api-client": "2.3.41-dev",
|
|
38
|
+
"@nexeraid/identity-schemas": "2.4.0-dev",
|
|
39
|
+
"@nexeraid/logger": "2.3.41-dev"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"react": ">=17.0.0 <20.0.0"
|