@compilot/react-sdk 2.1.14-dev → 2.1.16-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.
- package/dist/compilot-react-sdk.cjs.dev.js +109 -34
- package/dist/compilot-react-sdk.cjs.prod.js +109 -34
- package/dist/compilot-react-sdk.esm.js +110 -35
- package/dist/declarations/src/configuration/ComPilotProvider.d.ts.map +1 -1
- package/dist/declarations/src/hooks/useAuthenticate.d.ts.map +1 -1
- package/dist/declarations/src/hooks/useCustomerStatus.d.ts.map +1 -1
- package/dist/declarations/src/hooks/useOpenWidget.d.ts.map +1 -1
- package/dist/declarations/src/utils/useAsyncMutationState.d.ts.map +1 -1
- package/dist/declarations/src/utils/useAsyncQueryState.d.ts +4 -1
- package/dist/declarations/src/utils/useAsyncQueryState.d.ts.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +3 -3
|
@@ -20,6 +20,47 @@ var AutoLoader = function AutoLoader(_ref) {
|
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
var GlobalStateContext = /*#__PURE__*/react.createContext({});
|
|
24
|
+
var stateClient = function () {
|
|
25
|
+
var state = {};
|
|
26
|
+
var toKey = function toKey(key) {
|
|
27
|
+
return key.join(":");
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
init: function init(key, value) {
|
|
31
|
+
if (!state[toKey(key)]) {
|
|
32
|
+
state[toKey(key)] = value;
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
set: function set(key, value) {
|
|
36
|
+
state[toKey(key)] = value;
|
|
37
|
+
console.log(toKey(key), state[toKey(key)]);
|
|
38
|
+
},
|
|
39
|
+
get: function get(key) {
|
|
40
|
+
return state[toKey(key)];
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}();
|
|
44
|
+
var GlobalStateProvider = function GlobalStateProvider(_ref) {
|
|
45
|
+
var children = _ref.children;
|
|
46
|
+
return /*#__PURE__*/jsxRuntime.jsx(GlobalStateContext.Provider, {
|
|
47
|
+
value: stateClient,
|
|
48
|
+
children: children
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
function useGlobalState(_ref2) {
|
|
52
|
+
var key = _ref2.key,
|
|
53
|
+
defaultValue = _ref2.defaultValue;
|
|
54
|
+
stateClient.init(key, defaultValue);
|
|
55
|
+
return react.useMemo(function () {
|
|
56
|
+
return [stateClient.get(key),
|
|
57
|
+
// we can do this because we always initialize the state
|
|
58
|
+
function (value) {
|
|
59
|
+
return stateClient.set(key, value);
|
|
60
|
+
}];
|
|
61
|
+
}, [key]);
|
|
62
|
+
}
|
|
63
|
+
|
|
23
64
|
var ComPilotContext = /*#__PURE__*/react.createContext(null);
|
|
24
65
|
|
|
25
66
|
/**
|
|
@@ -70,11 +111,13 @@ var ComPilotProvider = function ComPilotProvider(_ref) {
|
|
|
70
111
|
_ref$autoLoad = _ref.autoLoad,
|
|
71
112
|
autoLoad = _ref$autoLoad === void 0 ? true : _ref$autoLoad,
|
|
72
113
|
children = _ref.children;
|
|
73
|
-
return /*#__PURE__*/jsxRuntime.jsx(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
114
|
+
return /*#__PURE__*/jsxRuntime.jsx(GlobalStateProvider, {
|
|
115
|
+
children: /*#__PURE__*/jsxRuntime.jsx(ComPilotContext.Provider, {
|
|
116
|
+
value: config,
|
|
117
|
+
children: /*#__PURE__*/jsxRuntime.jsx(AutoLoader, {
|
|
118
|
+
autoLoad: autoLoad,
|
|
119
|
+
children: children
|
|
120
|
+
})
|
|
78
121
|
})
|
|
79
122
|
});
|
|
80
123
|
};
|
|
@@ -525,17 +568,20 @@ function _slicedToArray(r, e) {
|
|
|
525
568
|
var useAsyncMutationState = function useAsyncMutationState(_ref) {
|
|
526
569
|
var mutationName = _ref.mutationName,
|
|
527
570
|
mutationFn = _ref.mutationFn;
|
|
528
|
-
var
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
571
|
+
var _useGlobalState = useGlobalState({
|
|
572
|
+
key: ["useAsyncMutationState", mutationName],
|
|
573
|
+
defaultValue: {
|
|
574
|
+
data: undefined,
|
|
575
|
+
isIdle: true,
|
|
576
|
+
isPending: false,
|
|
577
|
+
isError: false,
|
|
578
|
+
isSuccess: false,
|
|
579
|
+
error: null
|
|
580
|
+
}
|
|
535
581
|
}),
|
|
536
|
-
|
|
537
|
-
state =
|
|
538
|
-
setState =
|
|
582
|
+
_useGlobalState2 = _slicedToArray(_useGlobalState, 2),
|
|
583
|
+
state = _useGlobalState2[0],
|
|
584
|
+
setState = _useGlobalState2[1];
|
|
539
585
|
var mutateAsync = react.useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
540
586
|
var result,
|
|
541
587
|
_args = arguments;
|
|
@@ -586,23 +632,44 @@ var useAsyncMutationState = function useAsyncMutationState(_ref) {
|
|
|
586
632
|
return _objectSpread2(_objectSpread2({}, state), {}, _defineProperty({}, mutationName, mutateAsync));
|
|
587
633
|
};
|
|
588
634
|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
635
|
+
function _arrayWithoutHoles(r) {
|
|
636
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
function _iterableToArray(r) {
|
|
640
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
function _nonIterableSpread() {
|
|
644
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
function _toConsumableArray(r) {
|
|
648
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
var useAsyncQueryState = function useAsyncQueryState(_ref) {
|
|
652
|
+
var queryKey = _ref.queryKey,
|
|
653
|
+
defaultValue = _ref.defaultValue;
|
|
654
|
+
var _useGlobalState = useGlobalState({
|
|
655
|
+
key: ["useAsyncQueryState"].concat(_toConsumableArray(queryKey)),
|
|
656
|
+
defaultValue: defaultValue === undefined ? {
|
|
657
|
+
isLoading: false,
|
|
658
|
+
isError: false,
|
|
659
|
+
isSuccess: false,
|
|
660
|
+
error: null,
|
|
661
|
+
data: undefined
|
|
662
|
+
} : {
|
|
663
|
+
isLoading: false,
|
|
664
|
+
isError: false,
|
|
665
|
+
isSuccess: true,
|
|
666
|
+
error: null,
|
|
667
|
+
data: defaultValue
|
|
668
|
+
}
|
|
602
669
|
}),
|
|
603
|
-
|
|
604
|
-
state =
|
|
605
|
-
setState =
|
|
670
|
+
_useGlobalState2 = _slicedToArray(_useGlobalState, 2),
|
|
671
|
+
state = _useGlobalState2[0],
|
|
672
|
+
setState = _useGlobalState2[1];
|
|
606
673
|
var setResult = react.useCallback(function (result) {
|
|
607
674
|
setState({
|
|
608
675
|
isLoading: false,
|
|
@@ -675,7 +742,10 @@ var useOpenWidget = function useOpenWidget(loginParams) {
|
|
|
675
742
|
});
|
|
676
743
|
// but open state can change without us mutating it
|
|
677
744
|
// that's the only case for now so we don't need another kind of mutation state
|
|
678
|
-
var _useAsyncQueryState = useAsyncQueryState(
|
|
745
|
+
var _useAsyncQueryState = useAsyncQueryState({
|
|
746
|
+
queryKey: ["useOpenWidget", config._internal.identifier],
|
|
747
|
+
defaultValue: webSdk.isOpen(config)
|
|
748
|
+
}),
|
|
679
749
|
setResult = _useAsyncQueryState.setResult,
|
|
680
750
|
setLoading = _useAsyncQueryState.setLoading,
|
|
681
751
|
queryState = _useAsyncQueryState.state;
|
|
@@ -901,7 +971,10 @@ var useAuthenticate = function useAuthenticate(loginParams) {
|
|
|
901
971
|
mutationName: "authenticate",
|
|
902
972
|
mutationFn: mutationFn
|
|
903
973
|
});
|
|
904
|
-
var _useAsyncQueryState = useAsyncQueryState(
|
|
974
|
+
var _useAsyncQueryState = useAsyncQueryState({
|
|
975
|
+
queryKey: ["useAuthenticate", config._internal.identifier],
|
|
976
|
+
defaultValue: webSdk.isAuthenticated(config)
|
|
977
|
+
}),
|
|
905
978
|
queryState = _useAsyncQueryState.state,
|
|
906
979
|
setResult = _useAsyncQueryState.setResult,
|
|
907
980
|
setLoading = _useAsyncQueryState.setLoading;
|
|
@@ -966,7 +1039,9 @@ var useCustomerStatus = function useCustomerStatus() {
|
|
|
966
1039
|
},
|
|
967
1040
|
refreshInterval = _ref.refreshInterval;
|
|
968
1041
|
var config = useComPilotConfig();
|
|
969
|
-
var _useAsyncQueryState = useAsyncQueryState(
|
|
1042
|
+
var _useAsyncQueryState = useAsyncQueryState({
|
|
1043
|
+
queryKey: ["useCustomerStatus", config._internal.identifier]
|
|
1044
|
+
}),
|
|
970
1045
|
state = _useAsyncQueryState.state,
|
|
971
1046
|
setError = _useAsyncQueryState.setError,
|
|
972
1047
|
setResult = _useAsyncQueryState.setResult,
|
|
@@ -20,6 +20,47 @@ var AutoLoader = function AutoLoader(_ref) {
|
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
var GlobalStateContext = /*#__PURE__*/react.createContext({});
|
|
24
|
+
var stateClient = function () {
|
|
25
|
+
var state = {};
|
|
26
|
+
var toKey = function toKey(key) {
|
|
27
|
+
return key.join(":");
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
init: function init(key, value) {
|
|
31
|
+
if (!state[toKey(key)]) {
|
|
32
|
+
state[toKey(key)] = value;
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
set: function set(key, value) {
|
|
36
|
+
state[toKey(key)] = value;
|
|
37
|
+
console.log(toKey(key), state[toKey(key)]);
|
|
38
|
+
},
|
|
39
|
+
get: function get(key) {
|
|
40
|
+
return state[toKey(key)];
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}();
|
|
44
|
+
var GlobalStateProvider = function GlobalStateProvider(_ref) {
|
|
45
|
+
var children = _ref.children;
|
|
46
|
+
return /*#__PURE__*/jsxRuntime.jsx(GlobalStateContext.Provider, {
|
|
47
|
+
value: stateClient,
|
|
48
|
+
children: children
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
function useGlobalState(_ref2) {
|
|
52
|
+
var key = _ref2.key,
|
|
53
|
+
defaultValue = _ref2.defaultValue;
|
|
54
|
+
stateClient.init(key, defaultValue);
|
|
55
|
+
return react.useMemo(function () {
|
|
56
|
+
return [stateClient.get(key),
|
|
57
|
+
// we can do this because we always initialize the state
|
|
58
|
+
function (value) {
|
|
59
|
+
return stateClient.set(key, value);
|
|
60
|
+
}];
|
|
61
|
+
}, [key]);
|
|
62
|
+
}
|
|
63
|
+
|
|
23
64
|
var ComPilotContext = /*#__PURE__*/react.createContext(null);
|
|
24
65
|
|
|
25
66
|
/**
|
|
@@ -70,11 +111,13 @@ var ComPilotProvider = function ComPilotProvider(_ref) {
|
|
|
70
111
|
_ref$autoLoad = _ref.autoLoad,
|
|
71
112
|
autoLoad = _ref$autoLoad === void 0 ? true : _ref$autoLoad,
|
|
72
113
|
children = _ref.children;
|
|
73
|
-
return /*#__PURE__*/jsxRuntime.jsx(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
114
|
+
return /*#__PURE__*/jsxRuntime.jsx(GlobalStateProvider, {
|
|
115
|
+
children: /*#__PURE__*/jsxRuntime.jsx(ComPilotContext.Provider, {
|
|
116
|
+
value: config,
|
|
117
|
+
children: /*#__PURE__*/jsxRuntime.jsx(AutoLoader, {
|
|
118
|
+
autoLoad: autoLoad,
|
|
119
|
+
children: children
|
|
120
|
+
})
|
|
78
121
|
})
|
|
79
122
|
});
|
|
80
123
|
};
|
|
@@ -525,17 +568,20 @@ function _slicedToArray(r, e) {
|
|
|
525
568
|
var useAsyncMutationState = function useAsyncMutationState(_ref) {
|
|
526
569
|
var mutationName = _ref.mutationName,
|
|
527
570
|
mutationFn = _ref.mutationFn;
|
|
528
|
-
var
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
571
|
+
var _useGlobalState = useGlobalState({
|
|
572
|
+
key: ["useAsyncMutationState", mutationName],
|
|
573
|
+
defaultValue: {
|
|
574
|
+
data: undefined,
|
|
575
|
+
isIdle: true,
|
|
576
|
+
isPending: false,
|
|
577
|
+
isError: false,
|
|
578
|
+
isSuccess: false,
|
|
579
|
+
error: null
|
|
580
|
+
}
|
|
535
581
|
}),
|
|
536
|
-
|
|
537
|
-
state =
|
|
538
|
-
setState =
|
|
582
|
+
_useGlobalState2 = _slicedToArray(_useGlobalState, 2),
|
|
583
|
+
state = _useGlobalState2[0],
|
|
584
|
+
setState = _useGlobalState2[1];
|
|
539
585
|
var mutateAsync = react.useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
540
586
|
var result,
|
|
541
587
|
_args = arguments;
|
|
@@ -586,23 +632,44 @@ var useAsyncMutationState = function useAsyncMutationState(_ref) {
|
|
|
586
632
|
return _objectSpread2(_objectSpread2({}, state), {}, _defineProperty({}, mutationName, mutateAsync));
|
|
587
633
|
};
|
|
588
634
|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
635
|
+
function _arrayWithoutHoles(r) {
|
|
636
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
function _iterableToArray(r) {
|
|
640
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
function _nonIterableSpread() {
|
|
644
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
function _toConsumableArray(r) {
|
|
648
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
var useAsyncQueryState = function useAsyncQueryState(_ref) {
|
|
652
|
+
var queryKey = _ref.queryKey,
|
|
653
|
+
defaultValue = _ref.defaultValue;
|
|
654
|
+
var _useGlobalState = useGlobalState({
|
|
655
|
+
key: ["useAsyncQueryState"].concat(_toConsumableArray(queryKey)),
|
|
656
|
+
defaultValue: defaultValue === undefined ? {
|
|
657
|
+
isLoading: false,
|
|
658
|
+
isError: false,
|
|
659
|
+
isSuccess: false,
|
|
660
|
+
error: null,
|
|
661
|
+
data: undefined
|
|
662
|
+
} : {
|
|
663
|
+
isLoading: false,
|
|
664
|
+
isError: false,
|
|
665
|
+
isSuccess: true,
|
|
666
|
+
error: null,
|
|
667
|
+
data: defaultValue
|
|
668
|
+
}
|
|
602
669
|
}),
|
|
603
|
-
|
|
604
|
-
state =
|
|
605
|
-
setState =
|
|
670
|
+
_useGlobalState2 = _slicedToArray(_useGlobalState, 2),
|
|
671
|
+
state = _useGlobalState2[0],
|
|
672
|
+
setState = _useGlobalState2[1];
|
|
606
673
|
var setResult = react.useCallback(function (result) {
|
|
607
674
|
setState({
|
|
608
675
|
isLoading: false,
|
|
@@ -675,7 +742,10 @@ var useOpenWidget = function useOpenWidget(loginParams) {
|
|
|
675
742
|
});
|
|
676
743
|
// but open state can change without us mutating it
|
|
677
744
|
// that's the only case for now so we don't need another kind of mutation state
|
|
678
|
-
var _useAsyncQueryState = useAsyncQueryState(
|
|
745
|
+
var _useAsyncQueryState = useAsyncQueryState({
|
|
746
|
+
queryKey: ["useOpenWidget", config._internal.identifier],
|
|
747
|
+
defaultValue: webSdk.isOpen(config)
|
|
748
|
+
}),
|
|
679
749
|
setResult = _useAsyncQueryState.setResult,
|
|
680
750
|
setLoading = _useAsyncQueryState.setLoading,
|
|
681
751
|
queryState = _useAsyncQueryState.state;
|
|
@@ -901,7 +971,10 @@ var useAuthenticate = function useAuthenticate(loginParams) {
|
|
|
901
971
|
mutationName: "authenticate",
|
|
902
972
|
mutationFn: mutationFn
|
|
903
973
|
});
|
|
904
|
-
var _useAsyncQueryState = useAsyncQueryState(
|
|
974
|
+
var _useAsyncQueryState = useAsyncQueryState({
|
|
975
|
+
queryKey: ["useAuthenticate", config._internal.identifier],
|
|
976
|
+
defaultValue: webSdk.isAuthenticated(config)
|
|
977
|
+
}),
|
|
905
978
|
queryState = _useAsyncQueryState.state,
|
|
906
979
|
setResult = _useAsyncQueryState.setResult,
|
|
907
980
|
setLoading = _useAsyncQueryState.setLoading;
|
|
@@ -966,7 +1039,9 @@ var useCustomerStatus = function useCustomerStatus() {
|
|
|
966
1039
|
},
|
|
967
1040
|
refreshInterval = _ref.refreshInterval;
|
|
968
1041
|
var config = useComPilotConfig();
|
|
969
|
-
var _useAsyncQueryState = useAsyncQueryState(
|
|
1042
|
+
var _useAsyncQueryState = useAsyncQueryState({
|
|
1043
|
+
queryKey: ["useCustomerStatus", config._internal.identifier]
|
|
1044
|
+
}),
|
|
970
1045
|
state = _useAsyncQueryState.state,
|
|
971
1046
|
setError = _useAsyncQueryState.setError,
|
|
972
1047
|
setResult = _useAsyncQueryState.setResult,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect,
|
|
1
|
+
import { useEffect, createContext, useMemo, useContext, useCallback } from 'react';
|
|
2
2
|
import { load, openWidget, isOpen, watchWidgetVisibleState, getTxAuthDataSignature, authenticate, isAuthenticated, watchIsAuthenticated, watchCustomerStatus, getCustomerStatus, disconnect } from '@compilot/web-sdk';
|
|
3
3
|
export * from '@compilot/web-sdk';
|
|
4
4
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
@@ -17,6 +17,47 @@ var AutoLoader = function AutoLoader(_ref) {
|
|
|
17
17
|
});
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
var GlobalStateContext = /*#__PURE__*/createContext({});
|
|
21
|
+
var stateClient = function () {
|
|
22
|
+
var state = {};
|
|
23
|
+
var toKey = function toKey(key) {
|
|
24
|
+
return key.join(":");
|
|
25
|
+
};
|
|
26
|
+
return {
|
|
27
|
+
init: function init(key, value) {
|
|
28
|
+
if (!state[toKey(key)]) {
|
|
29
|
+
state[toKey(key)] = value;
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
set: function set(key, value) {
|
|
33
|
+
state[toKey(key)] = value;
|
|
34
|
+
console.log(toKey(key), state[toKey(key)]);
|
|
35
|
+
},
|
|
36
|
+
get: function get(key) {
|
|
37
|
+
return state[toKey(key)];
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}();
|
|
41
|
+
var GlobalStateProvider = function GlobalStateProvider(_ref) {
|
|
42
|
+
var children = _ref.children;
|
|
43
|
+
return /*#__PURE__*/jsx(GlobalStateContext.Provider, {
|
|
44
|
+
value: stateClient,
|
|
45
|
+
children: children
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
function useGlobalState(_ref2) {
|
|
49
|
+
var key = _ref2.key,
|
|
50
|
+
defaultValue = _ref2.defaultValue;
|
|
51
|
+
stateClient.init(key, defaultValue);
|
|
52
|
+
return useMemo(function () {
|
|
53
|
+
return [stateClient.get(key),
|
|
54
|
+
// we can do this because we always initialize the state
|
|
55
|
+
function (value) {
|
|
56
|
+
return stateClient.set(key, value);
|
|
57
|
+
}];
|
|
58
|
+
}, [key]);
|
|
59
|
+
}
|
|
60
|
+
|
|
20
61
|
var ComPilotContext = /*#__PURE__*/createContext(null);
|
|
21
62
|
|
|
22
63
|
/**
|
|
@@ -67,11 +108,13 @@ var ComPilotProvider = function ComPilotProvider(_ref) {
|
|
|
67
108
|
_ref$autoLoad = _ref.autoLoad,
|
|
68
109
|
autoLoad = _ref$autoLoad === void 0 ? true : _ref$autoLoad,
|
|
69
110
|
children = _ref.children;
|
|
70
|
-
return /*#__PURE__*/jsx(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
111
|
+
return /*#__PURE__*/jsx(GlobalStateProvider, {
|
|
112
|
+
children: /*#__PURE__*/jsx(ComPilotContext.Provider, {
|
|
113
|
+
value: config,
|
|
114
|
+
children: /*#__PURE__*/jsx(AutoLoader, {
|
|
115
|
+
autoLoad: autoLoad,
|
|
116
|
+
children: children
|
|
117
|
+
})
|
|
75
118
|
})
|
|
76
119
|
});
|
|
77
120
|
};
|
|
@@ -522,17 +565,20 @@ function _slicedToArray(r, e) {
|
|
|
522
565
|
var useAsyncMutationState = function useAsyncMutationState(_ref) {
|
|
523
566
|
var mutationName = _ref.mutationName,
|
|
524
567
|
mutationFn = _ref.mutationFn;
|
|
525
|
-
var
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
568
|
+
var _useGlobalState = useGlobalState({
|
|
569
|
+
key: ["useAsyncMutationState", mutationName],
|
|
570
|
+
defaultValue: {
|
|
571
|
+
data: undefined,
|
|
572
|
+
isIdle: true,
|
|
573
|
+
isPending: false,
|
|
574
|
+
isError: false,
|
|
575
|
+
isSuccess: false,
|
|
576
|
+
error: null
|
|
577
|
+
}
|
|
532
578
|
}),
|
|
533
|
-
|
|
534
|
-
state =
|
|
535
|
-
setState =
|
|
579
|
+
_useGlobalState2 = _slicedToArray(_useGlobalState, 2),
|
|
580
|
+
state = _useGlobalState2[0],
|
|
581
|
+
setState = _useGlobalState2[1];
|
|
536
582
|
var mutateAsync = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
537
583
|
var result,
|
|
538
584
|
_args = arguments;
|
|
@@ -583,23 +629,44 @@ var useAsyncMutationState = function useAsyncMutationState(_ref) {
|
|
|
583
629
|
return _objectSpread2(_objectSpread2({}, state), {}, _defineProperty({}, mutationName, mutateAsync));
|
|
584
630
|
};
|
|
585
631
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
632
|
+
function _arrayWithoutHoles(r) {
|
|
633
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
function _iterableToArray(r) {
|
|
637
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
function _nonIterableSpread() {
|
|
641
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function _toConsumableArray(r) {
|
|
645
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
var useAsyncQueryState = function useAsyncQueryState(_ref) {
|
|
649
|
+
var queryKey = _ref.queryKey,
|
|
650
|
+
defaultValue = _ref.defaultValue;
|
|
651
|
+
var _useGlobalState = useGlobalState({
|
|
652
|
+
key: ["useAsyncQueryState"].concat(_toConsumableArray(queryKey)),
|
|
653
|
+
defaultValue: defaultValue === undefined ? {
|
|
654
|
+
isLoading: false,
|
|
655
|
+
isError: false,
|
|
656
|
+
isSuccess: false,
|
|
657
|
+
error: null,
|
|
658
|
+
data: undefined
|
|
659
|
+
} : {
|
|
660
|
+
isLoading: false,
|
|
661
|
+
isError: false,
|
|
662
|
+
isSuccess: true,
|
|
663
|
+
error: null,
|
|
664
|
+
data: defaultValue
|
|
665
|
+
}
|
|
599
666
|
}),
|
|
600
|
-
|
|
601
|
-
state =
|
|
602
|
-
setState =
|
|
667
|
+
_useGlobalState2 = _slicedToArray(_useGlobalState, 2),
|
|
668
|
+
state = _useGlobalState2[0],
|
|
669
|
+
setState = _useGlobalState2[1];
|
|
603
670
|
var setResult = useCallback(function (result) {
|
|
604
671
|
setState({
|
|
605
672
|
isLoading: false,
|
|
@@ -672,7 +739,10 @@ var useOpenWidget = function useOpenWidget(loginParams) {
|
|
|
672
739
|
});
|
|
673
740
|
// but open state can change without us mutating it
|
|
674
741
|
// that's the only case for now so we don't need another kind of mutation state
|
|
675
|
-
var _useAsyncQueryState = useAsyncQueryState(
|
|
742
|
+
var _useAsyncQueryState = useAsyncQueryState({
|
|
743
|
+
queryKey: ["useOpenWidget", config._internal.identifier],
|
|
744
|
+
defaultValue: isOpen(config)
|
|
745
|
+
}),
|
|
676
746
|
setResult = _useAsyncQueryState.setResult,
|
|
677
747
|
setLoading = _useAsyncQueryState.setLoading,
|
|
678
748
|
queryState = _useAsyncQueryState.state;
|
|
@@ -898,7 +968,10 @@ var useAuthenticate = function useAuthenticate(loginParams) {
|
|
|
898
968
|
mutationName: "authenticate",
|
|
899
969
|
mutationFn: mutationFn
|
|
900
970
|
});
|
|
901
|
-
var _useAsyncQueryState = useAsyncQueryState(
|
|
971
|
+
var _useAsyncQueryState = useAsyncQueryState({
|
|
972
|
+
queryKey: ["useAuthenticate", config._internal.identifier],
|
|
973
|
+
defaultValue: isAuthenticated(config)
|
|
974
|
+
}),
|
|
902
975
|
queryState = _useAsyncQueryState.state,
|
|
903
976
|
setResult = _useAsyncQueryState.setResult,
|
|
904
977
|
setLoading = _useAsyncQueryState.setLoading;
|
|
@@ -963,7 +1036,9 @@ var useCustomerStatus = function useCustomerStatus() {
|
|
|
963
1036
|
},
|
|
964
1037
|
refreshInterval = _ref.refreshInterval;
|
|
965
1038
|
var config = useComPilotConfig();
|
|
966
|
-
var _useAsyncQueryState = useAsyncQueryState(
|
|
1039
|
+
var _useAsyncQueryState = useAsyncQueryState({
|
|
1040
|
+
queryKey: ["useCustomerStatus", config._internal.identifier]
|
|
1041
|
+
}),
|
|
967
1042
|
state = _useAsyncQueryState.state,
|
|
968
1043
|
setError = _useAsyncQueryState.setError,
|
|
969
1044
|
setResult = _useAsyncQueryState.setResult,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComPilotProvider.d.ts","sourceRoot":"../../../../src/configuration","sources":["ComPilotProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ComPilotProvider.d.ts","sourceRoot":"../../../../src/configuration","sources":["ComPilotProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAOhD;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,gBAAgB,8CAI1B,qBAAqB,sBAQvB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,QAAO,MAMpC,CAAC"}
|
|
@@ -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,EACV,kBAAkB,EAEnB,0CAAuC;AAIxC;;;;;;;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,EACV,kBAAkB,EAEnB,0CAAuC;AAIxC;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,iBACZ,WAAW,KACxB,kBAAkB,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,cAAc,CAmD3D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCustomerStatus.d.ts","sourceRoot":"../../../../src/hooks","sources":["useCustomerStatus.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAGjE,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAoC;AAGnE;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,iBAAiB,yBACP,uBAAuB,KAG3C,eAAe,CAAC,cAAc,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"useCustomerStatus.d.ts","sourceRoot":"../../../../src/hooks","sources":["useCustomerStatus.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAGjE,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAoC;AAGnE;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,iBAAiB,yBACP,uBAAuB,KAG3C,eAAe,CAAC,cAAc,GAAG,IAAI,CA6CvC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOpenWidget.d.ts","sourceRoot":"../../../../src/hooks","sources":["useOpenWidget.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,KAAK,EACV,kBAAkB,EAEnB,0CAAuC;AAIxC;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,iBACV,WAAW,KACxB,kBAAkB,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"useOpenWidget.d.ts","sourceRoot":"../../../../src/hooks","sources":["useOpenWidget.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,KAAK,EACV,kBAAkB,EAEnB,0CAAuC;AAIxC;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,iBACV,WAAW,KACxB,kBAAkB,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,YAAY,CAiDzD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAsyncMutationState.d.ts","sourceRoot":"../../../../src/utils","sources":["useAsyncMutationState.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAsyncMutationState.d.ts","sourceRoot":"../../../../src/utils","sources":["useAsyncMutationState.ts"],"names":[],"mappings":"AAKA,KAAK,WAAW,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAEpD,KAAK,sBAAsB,GAAG;IAC5B,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,IAAI,CAAC;IACb,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,KAAK,CAAC;IACjB,KAAK,EAAE,IAAI,CAAC;CACb,CAAC;AAEF,KAAK,yBAAyB,CAAC,WAAW,SAAS,WAAW,IAAI;IAChE,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;IACvC,MAAM,EAAE,KAAK,CAAC;IACd,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,KAAK,EAAE,IAAI,CAAC;CACb,CAAC;AAEF,KAAK,yBAAyB,GAAG;IAC/B,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,KAAK,CAAC;IACd,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,KAAK,CAAC;IACjB,KAAK,EAAE,IAAI,CAAC;CACb,CAAC;AAEF,KAAK,uBAAuB,CAAC,WAAW,SAAS,WAAW,IAAI;IAC9D,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,GAAG,SAAS,CAAC;IACnD,MAAM,EAAE,KAAK,CAAC;IACd,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,IAAI,CAAC;IACd,SAAS,EAAE,KAAK,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,qBAAqB,CAAC,WAAW,SAAS,WAAW,IAC7D,sBAAsB,GACtB,yBAAyB,CAAC,WAAW,CAAC,GACtC,yBAAyB,GACzB,uBAAuB,CAAC,WAAW,CAAC,CAAC;AAEzC,MAAM,MAAM,kBAAkB,CAC5B,WAAW,SAAS,WAAW,EAC/B,aAAa,SAAS,MAAM,IAC1B,qBAAqB,CAAC,WAAW,CAAC,GAAG;KACtC,CAAC,IAAI,aAAa,GAAG,WAAW;CAClC,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAChC,WAAW,SAAS,WAAW,EAC/B,aAAa,SAAS,MAAM,iCAI3B;IACD,YAAY,EAAE,aAAa,CAAC;IAC5B,UAAU,EAAE,WAAW,CAAC;CACzB,KAAG,kBAAkB,CAAC,WAAW,EAAE,aAAa,CAyDhD,CAAC"}
|
|
@@ -27,7 +27,10 @@ export type ErrorAsyncQueryState = {
|
|
|
27
27
|
data: undefined;
|
|
28
28
|
};
|
|
29
29
|
export type AsyncQueryState<T> = InitialAsyncQueryState | SuccessAsyncQueryState<T> | LoadingAsyncQueryState | ErrorAsyncQueryState;
|
|
30
|
-
export declare const useAsyncQueryState: <T>(defaultValue
|
|
30
|
+
export declare const useAsyncQueryState: <T>({ queryKey, defaultValue, }: {
|
|
31
|
+
queryKey: string[];
|
|
32
|
+
defaultValue?: T;
|
|
33
|
+
}) => {
|
|
31
34
|
state: AsyncQueryState<T>;
|
|
32
35
|
setResult: (result: T) => void;
|
|
33
36
|
setError: (error: Error) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAsyncQueryState.d.ts","sourceRoot":"../../../../src/utils","sources":["useAsyncQueryState.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAsyncQueryState.d.ts","sourceRoot":"../../../../src/utils","sources":["useAsyncQueryState.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,KAAK,CAAC;IACjB,KAAK,EAAE,IAAI,CAAC;IACZ,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAAI;IACtC,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,KAAK,EAAE,IAAI,CAAC;IACZ,IAAI,EAAE,CAAC,CAAC;CACT,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,KAAK,CAAC;IACjB,KAAK,EAAE,IAAI,CAAC;IACZ,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,IAAI,CAAC;IACd,SAAS,EAAE,KAAK,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,CAAC,IACzB,sBAAsB,GACtB,sBAAsB,CAAC,CAAC,CAAC,GACzB,sBAAsB,GACtB,oBAAoB,CAAC;AAEzB,eAAO,MAAM,kBAAkB,GAAI,CAAC,+BAGjC;IACD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,YAAY,CAAC,EAAE,CAAC,CAAC;CAClB;;wBAsBY,CAAC;sBAaF,KAAK;;;4BAiCD,OAAO;CAkBtB,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.1.
|
|
3
|
+
"version": "2.1.16-dev",
|
|
4
4
|
"description": "ComPilot React SDK",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "ISC",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"pino": "^9.4.0",
|
|
28
28
|
"zod": "^3.23.8",
|
|
29
|
-
"@compilot/web-sdk": "2.1.
|
|
29
|
+
"@compilot/web-sdk": "2.1.14-dev",
|
|
30
30
|
"@nexeraid/identity-api-client": "2.1.9-dev",
|
|
31
|
-
"@nexeraid/identity-schemas": "2.1.
|
|
31
|
+
"@nexeraid/identity-schemas": "2.1.14-dev",
|
|
32
32
|
"@nexeraid/logger": "2.1.7-dev"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|