webitel-sdk 26.4.20 → 26.4.21
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/index.cjs +90 -55
- package/index.cjs.map +1 -1
- package/index.mjs +90 -55
- package/index.mjs.map +1 -1
- package/package.json +2 -1
- package/socket/client.d.ts +1 -0
- package/socket/client.d.ts.map +1 -1
- package/socket/task.d.ts +19 -4
- package/socket/task.d.ts.map +1 -1
- package/socket/utils.d.ts +7 -0
- package/socket/utils.d.ts.map +1 -1
- package/version.d.ts +1 -1
package/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import globalAxios from "axios";
|
|
|
2
2
|
import { EventEmitter } from "ee-ts";
|
|
3
3
|
import JsSIP from "jssip/lib/JsSIP.js";
|
|
4
4
|
import { EventEmitter as EventEmitter$1 } from "events";
|
|
5
|
+
import { camelCase } from "case-anything";
|
|
5
6
|
import { EventEmitter as EventEmitter$2 } from "ee-ts/lib/ee.js";
|
|
6
7
|
//#region src/url-shim.ts
|
|
7
8
|
function parse(path, _parseQueryString = false) {
|
|
@@ -66682,7 +66683,7 @@ _defineProperty(SipPhone$1, "userAgent", `Webitel-Phone/${version$1}`);
|
|
|
66682
66683
|
_defineProperty(SipPhone$1, "sipVersion", version$1);
|
|
66683
66684
|
//#endregion
|
|
66684
66685
|
//#region src/version.ts
|
|
66685
|
-
const version = "26.4.
|
|
66686
|
+
const version = "26.4.21";
|
|
66686
66687
|
//#endregion
|
|
66687
66688
|
//#region src/socket/errors.ts
|
|
66688
66689
|
/**
|
|
@@ -66828,6 +66829,75 @@ var PauseNotAllowedError = class PauseNotAllowedError extends Error {
|
|
|
66828
66829
|
};
|
|
66829
66830
|
_defineProperty(PauseNotAllowedError, "id", "app.agent.set_pause.not_allow");
|
|
66830
66831
|
//#endregion
|
|
66832
|
+
//#region src/socket/utils.ts
|
|
66833
|
+
/**
|
|
66834
|
+
* Рекурсивно конвертує ключі обʼєкта/масиву в camelCase.
|
|
66835
|
+
* @function
|
|
66836
|
+
* @param {unknown} input - Вхідне значення.
|
|
66837
|
+
* @returns {unknown} - Значення з camelCase-ключами.
|
|
66838
|
+
*/
|
|
66839
|
+
function camelizeKeys(input) {
|
|
66840
|
+
if (Array.isArray(input)) return input.map(camelizeKeys);
|
|
66841
|
+
if (input && typeof input === "object") {
|
|
66842
|
+
const res = {};
|
|
66843
|
+
for (const [key, value] of Object.entries(input)) res[camelCase(key)] = camelizeKeys(value);
|
|
66844
|
+
return res;
|
|
66845
|
+
}
|
|
66846
|
+
return input;
|
|
66847
|
+
}
|
|
66848
|
+
/**
|
|
66849
|
+
* Функція, що форматує URI WebSocket.
|
|
66850
|
+
* @function
|
|
66851
|
+
* @param {string} host - Хост.
|
|
66852
|
+
* @returns {string} - URI WebSocket.
|
|
66853
|
+
*/
|
|
66854
|
+
function formatWebSocketUri(host) {
|
|
66855
|
+
return host.replace(/^http/, "ws");
|
|
66856
|
+
}
|
|
66857
|
+
/**
|
|
66858
|
+
* Функція, що форматує базовий URI.
|
|
66859
|
+
* @function
|
|
66860
|
+
* @param {string} host - Хост.
|
|
66861
|
+
* @returns {string} - Базовий URI.
|
|
66862
|
+
*/
|
|
66863
|
+
function formatBaseUri(host) {
|
|
66864
|
+
let res = host.replace(/^ws/, "http");
|
|
66865
|
+
if (res.endsWith("/")) res = res.slice(0, -1);
|
|
66866
|
+
if (res.endsWith("/ws")) res = res.slice(0, -3);
|
|
66867
|
+
return res;
|
|
66868
|
+
}
|
|
66869
|
+
/**
|
|
66870
|
+
* Функція, що розбиває рядок на частини заданої довжини.
|
|
66871
|
+
* @function
|
|
66872
|
+
* @param {string} str - Рядок.
|
|
66873
|
+
* @param {number} len - Довжина частини.
|
|
66874
|
+
* @returns {string[]} - Масив частин рядка.
|
|
66875
|
+
*/
|
|
66876
|
+
function chunkString(str, len) {
|
|
66877
|
+
const size = Math.ceil(str.length / len);
|
|
66878
|
+
const r = new Array(size);
|
|
66879
|
+
let offset = 0;
|
|
66880
|
+
for (let i = 0; i < size; i++) {
|
|
66881
|
+
r[i] = str.substring(offset, offset + len);
|
|
66882
|
+
offset += len;
|
|
66883
|
+
}
|
|
66884
|
+
return r;
|
|
66885
|
+
}
|
|
66886
|
+
function generateId() {
|
|
66887
|
+
return String(Date.now().toString(32) + Math.random().toString(16)).replace(/\./g, "");
|
|
66888
|
+
}
|
|
66889
|
+
function generateTimestampFilename() {
|
|
66890
|
+
const now = /* @__PURE__ */ new Date();
|
|
66891
|
+
const pad = (num) => String(num).padStart(2, "0");
|
|
66892
|
+
const year = now.getFullYear();
|
|
66893
|
+
const month = pad(now.getMonth() + 1);
|
|
66894
|
+
const day = pad(now.getDate());
|
|
66895
|
+
const hours = pad(now.getHours());
|
|
66896
|
+
const minutes = pad(now.getMinutes());
|
|
66897
|
+
const seconds = pad(now.getSeconds());
|
|
66898
|
+
return `${`${year}-${month}-${day}`}_${`${hours}_${minutes}_${seconds}`}`;
|
|
66899
|
+
}
|
|
66900
|
+
//#endregion
|
|
66831
66901
|
//#region src/socket/task.ts
|
|
66832
66902
|
/**
|
|
66833
66903
|
* Перелік станів завдання.
|
|
@@ -67315,6 +67385,15 @@ var Task = class {
|
|
|
67315
67385
|
return this.communication.destination;
|
|
67316
67386
|
}
|
|
67317
67387
|
/**
|
|
67388
|
+
* Превʼю чату в camelCase (сире значення по сокету — snake_case).
|
|
67389
|
+
* @returns {ThreadPreview | undefined}
|
|
67390
|
+
*/
|
|
67391
|
+
get thread() {
|
|
67392
|
+
const raw = this.distribute.communication.thread;
|
|
67393
|
+
if (!raw) return;
|
|
67394
|
+
return camelizeKeys(raw);
|
|
67395
|
+
}
|
|
67396
|
+
/**
|
|
67318
67397
|
* Отримати ім'я для відображення.
|
|
67319
67398
|
* @returns {string | null}
|
|
67320
67399
|
*/
|
|
@@ -68041,60 +68120,6 @@ function removeWaitingList(list, attemptId) {
|
|
|
68041
68120
|
return false;
|
|
68042
68121
|
}
|
|
68043
68122
|
//#endregion
|
|
68044
|
-
//#region src/socket/utils.ts
|
|
68045
|
-
/**
|
|
68046
|
-
* Функція, що форматує URI WebSocket.
|
|
68047
|
-
* @function
|
|
68048
|
-
* @param {string} host - Хост.
|
|
68049
|
-
* @returns {string} - URI WebSocket.
|
|
68050
|
-
*/
|
|
68051
|
-
function formatWebSocketUri(host) {
|
|
68052
|
-
return host.replace(/^http/, "ws");
|
|
68053
|
-
}
|
|
68054
|
-
/**
|
|
68055
|
-
* Функція, що форматує базовий URI.
|
|
68056
|
-
* @function
|
|
68057
|
-
* @param {string} host - Хост.
|
|
68058
|
-
* @returns {string} - Базовий URI.
|
|
68059
|
-
*/
|
|
68060
|
-
function formatBaseUri(host) {
|
|
68061
|
-
let res = host.replace(/^ws/, "http");
|
|
68062
|
-
if (res.endsWith("/")) res = res.slice(0, -1);
|
|
68063
|
-
if (res.endsWith("/ws")) res = res.slice(0, -3);
|
|
68064
|
-
return res;
|
|
68065
|
-
}
|
|
68066
|
-
/**
|
|
68067
|
-
* Функція, що розбиває рядок на частини заданої довжини.
|
|
68068
|
-
* @function
|
|
68069
|
-
* @param {string} str - Рядок.
|
|
68070
|
-
* @param {number} len - Довжина частини.
|
|
68071
|
-
* @returns {string[]} - Масив частин рядка.
|
|
68072
|
-
*/
|
|
68073
|
-
function chunkString(str, len) {
|
|
68074
|
-
const size = Math.ceil(str.length / len);
|
|
68075
|
-
const r = new Array(size);
|
|
68076
|
-
let offset = 0;
|
|
68077
|
-
for (let i = 0; i < size; i++) {
|
|
68078
|
-
r[i] = str.substring(offset, offset + len);
|
|
68079
|
-
offset += len;
|
|
68080
|
-
}
|
|
68081
|
-
return r;
|
|
68082
|
-
}
|
|
68083
|
-
function generateId() {
|
|
68084
|
-
return String(Date.now().toString(32) + Math.random().toString(16)).replace(/\./g, "");
|
|
68085
|
-
}
|
|
68086
|
-
function generateTimestampFilename() {
|
|
68087
|
-
const now = /* @__PURE__ */ new Date();
|
|
68088
|
-
const pad = (num) => String(num).padStart(2, "0");
|
|
68089
|
-
const year = now.getFullYear();
|
|
68090
|
-
const month = pad(now.getMonth() + 1);
|
|
68091
|
-
const day = pad(now.getDate());
|
|
68092
|
-
const hours = pad(now.getHours());
|
|
68093
|
-
const minutes = pad(now.getMinutes());
|
|
68094
|
-
const seconds = pad(now.getSeconds());
|
|
68095
|
-
return `${`${year}-${month}-${day}`}_${`${hours}_${minutes}_${seconds}`}`;
|
|
68096
|
-
}
|
|
68097
|
-
//#endregion
|
|
68098
68123
|
//#region src/screen/storage.ts
|
|
68099
68124
|
var StorageMediaCapture = class extends EventEmitter {
|
|
68100
68125
|
constructor(id, name, mediaStream, iceServers, sdpResolver, token) {
|
|
@@ -70967,6 +70992,16 @@ var Client = class extends EventEmitter {
|
|
|
70967
70992
|
};
|
|
70968
70993
|
return this.registerCallClient(this.connectionInfo.b2bua ? new SipPhone$1(this, audioProcessing) : new SipPhone(this.instanceId, this._config.debug, audioProcessing));
|
|
70969
70994
|
}
|
|
70995
|
+
async latency() {
|
|
70996
|
+
const ack = {
|
|
70997
|
+
client_ts: 0,
|
|
70998
|
+
client_ack_ts: 0,
|
|
70999
|
+
server_ts: 0,
|
|
71000
|
+
server_ack_ts: 0
|
|
71001
|
+
};
|
|
71002
|
+
Object.assign(ack, await this.request(`latency_start`, ack));
|
|
71003
|
+
return this.calculateLatency(ack);
|
|
71004
|
+
}
|
|
70970
71005
|
async calculateLatency(ack) {
|
|
70971
71006
|
ack.client_ts = Date.now();
|
|
70972
71007
|
Object.assign(ack, await this.request(`latency_ack`, {
|