@webitel/ui-sdk 25.10.15 → 25.10.17
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} +4 -42
- package/src/api/websocket/enums/WebSocketClientEvent.ts +7 -0
- package/types/api/websocket/WebSocketClientController.d.ts +8 -8
- package/types/api/websocket/enums/WebSocketClientEvent.d.ts +5 -0
- 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.17",
|
|
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,15 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { shallowReactive } from 'vue';
|
|
2
2
|
import { Client } from 'webitel-sdk';
|
|
3
3
|
|
|
4
4
|
import eventBus from '../../scripts/eventBus.js';
|
|
5
5
|
import { endpoint, getConfig } from './config.js';
|
|
6
|
+
import { WebSocketClientEvent } from './enums/WebSocketClientEvent';
|
|
6
7
|
import websocketErrorEventHandler from './websocketErrorEventHandler.js';
|
|
7
8
|
|
|
8
|
-
const WebSocketClientEvent = Object.freeze({
|
|
9
|
-
AFTER_AUTH: 'afterAuth',
|
|
10
|
-
ERROR: 'error',
|
|
11
|
-
});
|
|
12
|
-
|
|
13
9
|
class WebSocketClientController {
|
|
14
10
|
cli = null;
|
|
15
11
|
Event = WebSocketClientEvent;
|
|
@@ -20,8 +16,8 @@ class WebSocketClientController {
|
|
|
20
16
|
[WebSocketClientEvent.AFTER_AUTH]: [],
|
|
21
17
|
};
|
|
22
18
|
|
|
23
|
-
getCliInstance() {
|
|
24
|
-
if (!this.cli) this.cli =
|
|
19
|
+
getCliInstance(createCliInstance = this._createCliInstance) {
|
|
20
|
+
if (!this.cli) this.cli = createCliInstance();
|
|
25
21
|
return this.cli;
|
|
26
22
|
}
|
|
27
23
|
|
|
@@ -43,10 +39,6 @@ class WebSocketClientController {
|
|
|
43
39
|
const token = localStorage.getItem('access-token');
|
|
44
40
|
const configCli = getConfig();
|
|
45
41
|
|
|
46
|
-
if (typeof configCli.registerWebDevice === 'undefined') {
|
|
47
|
-
configCli.registerWebDevice = true;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
42
|
const config = {
|
|
51
43
|
endpoint,
|
|
52
44
|
token,
|
|
@@ -58,10 +50,6 @@ class WebSocketClientController {
|
|
|
58
50
|
// const cli = new Client(config);
|
|
59
51
|
const cli = shallowReactive(new Client(config));
|
|
60
52
|
|
|
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
53
|
this._on[WebSocketClientEvent.AFTER_AUTH].forEach((callback) => callback());
|
|
66
54
|
this._on[WebSocketClientEvent.ERROR].forEach((callback) =>
|
|
67
55
|
cli.on('error', callback),
|
|
@@ -78,32 +66,6 @@ class WebSocketClientController {
|
|
|
78
66
|
|
|
79
67
|
await cli.auth();
|
|
80
68
|
|
|
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
69
|
window.cli = cli;
|
|
108
70
|
return cli;
|
|
109
71
|
};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
declare const webSocketClientController: WebSocketClientController;
|
|
1
|
+
import { Client } from 'webitel-sdk';
|
|
3
2
|
declare class WebSocketClientController {
|
|
4
3
|
cli: any;
|
|
5
|
-
Event:
|
|
6
|
-
AFTER_AUTH: "afterAuth";
|
|
7
|
-
ERROR: "error";
|
|
8
|
-
}
|
|
4
|
+
Event: {
|
|
5
|
+
readonly AFTER_AUTH: "afterAuth";
|
|
6
|
+
readonly ERROR: "error";
|
|
7
|
+
};
|
|
9
8
|
_config: {};
|
|
10
9
|
_on: {
|
|
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
|