@webitel/ui-sdk 25.10.15 → 25.10.16
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/package.json +1 -1
- package/src/api/websocket/{WebSocketClientController.js → WebSocketClientController.ts} +3 -37
- package/types/api/websocket/WebSocketClientController.d.ts +4 -4
- package/types/api/websocket/websocketErrorEventHandler.d.ts +1 -1
- /package/src/api/websocket/{websocketErrorEventHandler.js → websocketErrorEventHandler.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webitel/ui-sdk",
|
|
3
|
-
"version": "25.10.
|
|
3
|
+
"version": "25.10.16",
|
|
4
4
|
"private": false,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"make-all": "npm version patch --git-tag-version false && npm run build && (npm run build:types || true) && (npm run lint:fix || true) && npm run publish-lib",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { shallowReactive } from 'vue';
|
|
2
2
|
import { Client } from 'webitel-sdk';
|
|
3
3
|
|
|
4
4
|
import eventBus from '../../scripts/eventBus.js';
|
|
@@ -20,8 +20,8 @@ class WebSocketClientController {
|
|
|
20
20
|
[WebSocketClientEvent.AFTER_AUTH]: [],
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
getCliInstance() {
|
|
24
|
-
if (!this.cli) this.cli =
|
|
23
|
+
getCliInstance(createCliInstance = this._createCliInstance) {
|
|
24
|
+
if (!this.cli) this.cli = createCliInstance();
|
|
25
25
|
return this.cli;
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -43,10 +43,6 @@ class WebSocketClientController {
|
|
|
43
43
|
const token = localStorage.getItem('access-token');
|
|
44
44
|
const configCli = getConfig();
|
|
45
45
|
|
|
46
|
-
if (typeof configCli.registerWebDevice === 'undefined') {
|
|
47
|
-
configCli.registerWebDevice = true;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
46
|
const config = {
|
|
51
47
|
endpoint,
|
|
52
48
|
token,
|
|
@@ -58,10 +54,6 @@ class WebSocketClientController {
|
|
|
58
54
|
// const cli = new Client(config);
|
|
59
55
|
const cli = shallowReactive(new Client(config));
|
|
60
56
|
|
|
61
|
-
// why reactive? https://github.com/vuejs/core/discussions/7811#discussioncomment-5181921
|
|
62
|
-
cli.conversationStore = reactive(cli.conversationStore);
|
|
63
|
-
cli.callStore = reactive(cli.callStore);
|
|
64
|
-
|
|
65
57
|
this._on[WebSocketClientEvent.AFTER_AUTH].forEach((callback) => callback());
|
|
66
58
|
this._on[WebSocketClientEvent.ERROR].forEach((callback) =>
|
|
67
59
|
cli.on('error', callback),
|
|
@@ -78,32 +70,6 @@ class WebSocketClientController {
|
|
|
78
70
|
|
|
79
71
|
await cli.auth();
|
|
80
72
|
|
|
81
|
-
/*
|
|
82
|
-
cli.phone.ua contains "configuration" property, which has no setter so cannot be wrapped with reactivity.
|
|
83
|
-
so that, reactivity breaks
|
|
84
|
-
for more info, see WTEL-4236
|
|
85
|
-
*/
|
|
86
|
-
await new Promise((resolve, reject) => {
|
|
87
|
-
const timeout = setTimeout(() => {
|
|
88
|
-
console.error('Phone user agent is not connected :(');
|
|
89
|
-
resolve();
|
|
90
|
-
}, 5000);
|
|
91
|
-
|
|
92
|
-
const markUa = () =>
|
|
93
|
-
cli.phone?.ua && (cli.phone.ua = markRaw(cli.phone.ua));
|
|
94
|
-
|
|
95
|
-
if (cli.phone?.ua) {
|
|
96
|
-
markUa();
|
|
97
|
-
clearTimeout(timeout);
|
|
98
|
-
resolve();
|
|
99
|
-
} else
|
|
100
|
-
cli.on('phone_connected', () => {
|
|
101
|
-
markUa();
|
|
102
|
-
clearTimeout(timeout);
|
|
103
|
-
resolve();
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
|
|
107
73
|
window.cli = cli;
|
|
108
74
|
return cli;
|
|
109
75
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
declare const webSocketClientController: WebSocketClientController;
|
|
1
|
+
import { Client } from 'webitel-sdk';
|
|
3
2
|
declare class WebSocketClientController {
|
|
4
3
|
cli: any;
|
|
5
4
|
Event: Readonly<{
|
|
@@ -11,9 +10,10 @@ declare class WebSocketClientController {
|
|
|
11
10
|
error: ((error: any) => any)[];
|
|
12
11
|
afterAuth: any[];
|
|
13
12
|
};
|
|
14
|
-
getCliInstance(): any;
|
|
13
|
+
getCliInstance(createCliInstance?: () => Promise<import("vue").ShallowReactive<Client>>): any;
|
|
15
14
|
destroyCliInstance(): Promise<void>;
|
|
16
15
|
addEventListener(event: any, callback: any): void;
|
|
17
16
|
_createCliInstance: () => Promise<import("vue").ShallowReactive<Client>>;
|
|
18
17
|
}
|
|
19
|
-
|
|
18
|
+
declare const webSocketClientController: WebSocketClientController;
|
|
19
|
+
export default webSocketClientController;
|
|
File without changes
|