webitel-sdk 26.4.20 → 26.4.22
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 +94 -57
- package/index.cjs.map +1 -1
- package/index.mjs +94 -57
- package/index.mjs.map +1 -1
- package/package.json +2 -1
- package/sip/webrtc/session.d.ts.map +1 -1
- package/socket/client.d.ts +1 -0
- package/socket/client.d.ts.map +1 -1
- package/socket/task.d.ts +21 -5
- 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) {
|
|
@@ -66149,7 +66150,9 @@ var Session$2 = class {
|
|
|
66149
66150
|
});
|
|
66150
66151
|
}
|
|
66151
66152
|
setMediaConfig(s) {
|
|
66152
|
-
|
|
66153
|
+
setTimeout(() => {
|
|
66154
|
+
this.session.sendInfo("application/json", JSON.stringify(s));
|
|
66155
|
+
}, 500);
|
|
66153
66156
|
}
|
|
66154
66157
|
};
|
|
66155
66158
|
//#endregion
|
|
@@ -66682,7 +66685,7 @@ _defineProperty(SipPhone$1, "userAgent", `Webitel-Phone/${version$1}`);
|
|
|
66682
66685
|
_defineProperty(SipPhone$1, "sipVersion", version$1);
|
|
66683
66686
|
//#endregion
|
|
66684
66687
|
//#region src/version.ts
|
|
66685
|
-
const version = "26.4.
|
|
66688
|
+
const version = "26.4.22";
|
|
66686
66689
|
//#endregion
|
|
66687
66690
|
//#region src/socket/errors.ts
|
|
66688
66691
|
/**
|
|
@@ -66828,6 +66831,75 @@ var PauseNotAllowedError = class PauseNotAllowedError extends Error {
|
|
|
66828
66831
|
};
|
|
66829
66832
|
_defineProperty(PauseNotAllowedError, "id", "app.agent.set_pause.not_allow");
|
|
66830
66833
|
//#endregion
|
|
66834
|
+
//#region src/socket/utils.ts
|
|
66835
|
+
/**
|
|
66836
|
+
* Рекурсивно конвертує ключі обʼєкта/масиву в camelCase.
|
|
66837
|
+
* @function
|
|
66838
|
+
* @param {unknown} input - Вхідне значення.
|
|
66839
|
+
* @returns {unknown} - Значення з camelCase-ключами.
|
|
66840
|
+
*/
|
|
66841
|
+
function camelizeKeys(input) {
|
|
66842
|
+
if (Array.isArray(input)) return input.map(camelizeKeys);
|
|
66843
|
+
if (input && typeof input === "object") {
|
|
66844
|
+
const res = {};
|
|
66845
|
+
for (const [key, value] of Object.entries(input)) res[camelCase(key)] = camelizeKeys(value);
|
|
66846
|
+
return res;
|
|
66847
|
+
}
|
|
66848
|
+
return input;
|
|
66849
|
+
}
|
|
66850
|
+
/**
|
|
66851
|
+
* Функція, що форматує URI WebSocket.
|
|
66852
|
+
* @function
|
|
66853
|
+
* @param {string} host - Хост.
|
|
66854
|
+
* @returns {string} - URI WebSocket.
|
|
66855
|
+
*/
|
|
66856
|
+
function formatWebSocketUri(host) {
|
|
66857
|
+
return host.replace(/^http/, "ws");
|
|
66858
|
+
}
|
|
66859
|
+
/**
|
|
66860
|
+
* Функція, що форматує базовий URI.
|
|
66861
|
+
* @function
|
|
66862
|
+
* @param {string} host - Хост.
|
|
66863
|
+
* @returns {string} - Базовий URI.
|
|
66864
|
+
*/
|
|
66865
|
+
function formatBaseUri(host) {
|
|
66866
|
+
let res = host.replace(/^ws/, "http");
|
|
66867
|
+
if (res.endsWith("/")) res = res.slice(0, -1);
|
|
66868
|
+
if (res.endsWith("/ws")) res = res.slice(0, -3);
|
|
66869
|
+
return res;
|
|
66870
|
+
}
|
|
66871
|
+
/**
|
|
66872
|
+
* Функція, що розбиває рядок на частини заданої довжини.
|
|
66873
|
+
* @function
|
|
66874
|
+
* @param {string} str - Рядок.
|
|
66875
|
+
* @param {number} len - Довжина частини.
|
|
66876
|
+
* @returns {string[]} - Масив частин рядка.
|
|
66877
|
+
*/
|
|
66878
|
+
function chunkString(str, len) {
|
|
66879
|
+
const size = Math.ceil(str.length / len);
|
|
66880
|
+
const r = new Array(size);
|
|
66881
|
+
let offset = 0;
|
|
66882
|
+
for (let i = 0; i < size; i++) {
|
|
66883
|
+
r[i] = str.substring(offset, offset + len);
|
|
66884
|
+
offset += len;
|
|
66885
|
+
}
|
|
66886
|
+
return r;
|
|
66887
|
+
}
|
|
66888
|
+
function generateId() {
|
|
66889
|
+
return String(Date.now().toString(32) + Math.random().toString(16)).replace(/\./g, "");
|
|
66890
|
+
}
|
|
66891
|
+
function generateTimestampFilename() {
|
|
66892
|
+
const now = /* @__PURE__ */ new Date();
|
|
66893
|
+
const pad = (num) => String(num).padStart(2, "0");
|
|
66894
|
+
const year = now.getFullYear();
|
|
66895
|
+
const month = pad(now.getMonth() + 1);
|
|
66896
|
+
const day = pad(now.getDate());
|
|
66897
|
+
const hours = pad(now.getHours());
|
|
66898
|
+
const minutes = pad(now.getMinutes());
|
|
66899
|
+
const seconds = pad(now.getSeconds());
|
|
66900
|
+
return `${`${year}-${month}-${day}`}_${`${hours}_${minutes}_${seconds}`}`;
|
|
66901
|
+
}
|
|
66902
|
+
//#endregion
|
|
66831
66903
|
//#region src/socket/task.ts
|
|
66832
66904
|
/**
|
|
66833
66905
|
* Перелік станів завдання.
|
|
@@ -67315,6 +67387,15 @@ var Task = class {
|
|
|
67315
67387
|
return this.communication.destination;
|
|
67316
67388
|
}
|
|
67317
67389
|
/**
|
|
67390
|
+
* Превʼю чату в camelCase (сире значення по сокету — snake_case).
|
|
67391
|
+
* @returns {ThreadPreview | undefined}
|
|
67392
|
+
*/
|
|
67393
|
+
get thread() {
|
|
67394
|
+
const raw = this.distribute.communication.thread;
|
|
67395
|
+
if (!raw) return;
|
|
67396
|
+
return camelizeKeys(raw);
|
|
67397
|
+
}
|
|
67398
|
+
/**
|
|
67318
67399
|
* Отримати ім'я для відображення.
|
|
67319
67400
|
* @returns {string | null}
|
|
67320
67401
|
*/
|
|
@@ -68041,60 +68122,6 @@ function removeWaitingList(list, attemptId) {
|
|
|
68041
68122
|
return false;
|
|
68042
68123
|
}
|
|
68043
68124
|
//#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
68125
|
//#region src/screen/storage.ts
|
|
68099
68126
|
var StorageMediaCapture = class extends EventEmitter {
|
|
68100
68127
|
constructor(id, name, mediaStream, iceServers, sdpResolver, token) {
|
|
@@ -69504,7 +69531,7 @@ var Conversation = class {
|
|
|
69504
69531
|
clearTimeout(this._autoAnswerTimerId);
|
|
69505
69532
|
this._autoAnswerTimerId = null;
|
|
69506
69533
|
}
|
|
69507
|
-
this.member = wrapChannelMember(member);
|
|
69534
|
+
this.member = wrapChannelMember(member) || {};
|
|
69508
69535
|
if (!this.members.some((m) => m.id === this.member.id)) this.members.push(this.member);
|
|
69509
69536
|
this.inviteId = null;
|
|
69510
69537
|
}
|
|
@@ -70967,6 +70994,16 @@ var Client = class extends EventEmitter {
|
|
|
70967
70994
|
};
|
|
70968
70995
|
return this.registerCallClient(this.connectionInfo.b2bua ? new SipPhone$1(this, audioProcessing) : new SipPhone(this.instanceId, this._config.debug, audioProcessing));
|
|
70969
70996
|
}
|
|
70997
|
+
async latency() {
|
|
70998
|
+
const ack = {
|
|
70999
|
+
client_ts: 0,
|
|
71000
|
+
client_ack_ts: 0,
|
|
71001
|
+
server_ts: 0,
|
|
71002
|
+
server_ack_ts: 0
|
|
71003
|
+
};
|
|
71004
|
+
Object.assign(ack, await this.request(`latency_start`, ack));
|
|
71005
|
+
return this.calculateLatency(ack);
|
|
71006
|
+
}
|
|
70970
71007
|
async calculateLatency(ack) {
|
|
70971
71008
|
ack.client_ts = Date.now();
|
|
70972
71009
|
Object.assign(ack, await this.request(`latency_ack`, {
|