@koi-design/callkit 1.0.23 → 1.0.24-beta.2
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/index.d.ts +8 -0
- package/dist/index.global.js +92 -47
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +45 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -4
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,12 @@ declare class Call {
|
|
|
24
24
|
private callKit;
|
|
25
25
|
constructor(callKit: CallKit);
|
|
26
26
|
callStart(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Refer
|
|
29
|
+
* @param referTo - The referral target. If a `Session`, a REFER w/Replaces is sent.
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
callRefer(referTo: string, options?: any): Promise<void>;
|
|
27
33
|
/**
|
|
28
34
|
* Hang up
|
|
29
35
|
* @param isUnprompted Whether to actively hang up
|
|
@@ -381,6 +387,7 @@ declare class Connect {
|
|
|
381
387
|
setMute(mute: boolean): Promise<void>;
|
|
382
388
|
mute(): Promise<void>;
|
|
383
389
|
unmute(): Promise<void>;
|
|
390
|
+
refer(referTo: string, options?: any): Promise<void>;
|
|
384
391
|
}
|
|
385
392
|
|
|
386
393
|
declare class User {
|
|
@@ -427,6 +434,7 @@ declare class CallKit {
|
|
|
427
434
|
}): Promise<void>;
|
|
428
435
|
logout(): Promise<void>;
|
|
429
436
|
call(extno?: string | number): Promise<void>;
|
|
437
|
+
refer(uri: string, options?: any): Promise<void>;
|
|
430
438
|
register(): Promise<void>;
|
|
431
439
|
unregister(): Promise<void>;
|
|
432
440
|
hangup(): Promise<void>;
|
package/dist/index.global.js
CHANGED
|
@@ -1065,9 +1065,9 @@ var WebCall = (() => {
|
|
|
1065
1065
|
}
|
|
1066
1066
|
});
|
|
1067
1067
|
|
|
1068
|
-
// node_modules/.pnpm/debug@4.
|
|
1068
|
+
// node_modules/.pnpm/debug@4.4.1/node_modules/debug/src/common.js
|
|
1069
1069
|
var require_common = __commonJS({
|
|
1070
|
-
"node_modules/.pnpm/debug@4.
|
|
1070
|
+
"node_modules/.pnpm/debug@4.4.1/node_modules/debug/src/common.js"(exports, module) {
|
|
1071
1071
|
function setup(env) {
|
|
1072
1072
|
createDebug.debug = createDebug;
|
|
1073
1073
|
createDebug.default = createDebug;
|
|
@@ -1168,50 +1168,64 @@ var WebCall = (() => {
|
|
|
1168
1168
|
createDebug.namespaces = namespaces;
|
|
1169
1169
|
createDebug.names = [];
|
|
1170
1170
|
createDebug.skips = [];
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1171
|
+
const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
|
|
1172
|
+
for (const ns of split) {
|
|
1173
|
+
if (ns[0] === "-") {
|
|
1174
|
+
createDebug.skips.push(ns.slice(1));
|
|
1175
|
+
} else {
|
|
1176
|
+
createDebug.names.push(ns);
|
|
1177
1177
|
}
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
function matchesTemplate(search, template) {
|
|
1181
|
+
let searchIndex = 0;
|
|
1182
|
+
let templateIndex = 0;
|
|
1183
|
+
let starIndex = -1;
|
|
1184
|
+
let matchIndex = 0;
|
|
1185
|
+
while (searchIndex < search.length) {
|
|
1186
|
+
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
|
|
1187
|
+
if (template[templateIndex] === "*") {
|
|
1188
|
+
starIndex = templateIndex;
|
|
1189
|
+
matchIndex = searchIndex;
|
|
1190
|
+
templateIndex++;
|
|
1191
|
+
} else {
|
|
1192
|
+
searchIndex++;
|
|
1193
|
+
templateIndex++;
|
|
1194
|
+
}
|
|
1195
|
+
} else if (starIndex !== -1) {
|
|
1196
|
+
templateIndex = starIndex + 1;
|
|
1197
|
+
matchIndex++;
|
|
1198
|
+
searchIndex = matchIndex;
|
|
1181
1199
|
} else {
|
|
1182
|
-
|
|
1200
|
+
return false;
|
|
1183
1201
|
}
|
|
1184
1202
|
}
|
|
1203
|
+
while (templateIndex < template.length && template[templateIndex] === "*") {
|
|
1204
|
+
templateIndex++;
|
|
1205
|
+
}
|
|
1206
|
+
return templateIndex === template.length;
|
|
1185
1207
|
}
|
|
1186
1208
|
function disable() {
|
|
1187
1209
|
const namespaces = [
|
|
1188
|
-
...createDebug.names
|
|
1189
|
-
...createDebug.skips.map(
|
|
1210
|
+
...createDebug.names,
|
|
1211
|
+
...createDebug.skips.map((namespace) => "-" + namespace)
|
|
1190
1212
|
].join(",");
|
|
1191
1213
|
createDebug.enable("");
|
|
1192
1214
|
return namespaces;
|
|
1193
1215
|
}
|
|
1194
1216
|
function enabled(name) {
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
}
|
|
1198
|
-
let i;
|
|
1199
|
-
let len;
|
|
1200
|
-
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
|
1201
|
-
if (createDebug.skips[i].test(name)) {
|
|
1217
|
+
for (const skip of createDebug.skips) {
|
|
1218
|
+
if (matchesTemplate(name, skip)) {
|
|
1202
1219
|
return false;
|
|
1203
1220
|
}
|
|
1204
1221
|
}
|
|
1205
|
-
for (
|
|
1206
|
-
if (
|
|
1222
|
+
for (const ns of createDebug.names) {
|
|
1223
|
+
if (matchesTemplate(name, ns)) {
|
|
1207
1224
|
return true;
|
|
1208
1225
|
}
|
|
1209
1226
|
}
|
|
1210
1227
|
return false;
|
|
1211
1228
|
}
|
|
1212
|
-
function toNamespace(regexp) {
|
|
1213
|
-
return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*");
|
|
1214
|
-
}
|
|
1215
1229
|
function coerce(val) {
|
|
1216
1230
|
if (val instanceof Error) {
|
|
1217
1231
|
return val.stack || val.message;
|
|
@@ -1228,9 +1242,9 @@ var WebCall = (() => {
|
|
|
1228
1242
|
}
|
|
1229
1243
|
});
|
|
1230
1244
|
|
|
1231
|
-
// node_modules/.pnpm/debug@4.
|
|
1245
|
+
// node_modules/.pnpm/debug@4.4.1/node_modules/debug/src/browser.js
|
|
1232
1246
|
var require_browser = __commonJS({
|
|
1233
|
-
"node_modules/.pnpm/debug@4.
|
|
1247
|
+
"node_modules/.pnpm/debug@4.4.1/node_modules/debug/src/browser.js"(exports, module) {
|
|
1234
1248
|
exports.formatArgs = formatArgs;
|
|
1235
1249
|
exports.save = save;
|
|
1236
1250
|
exports.load = load;
|
|
@@ -1372,7 +1386,7 @@ var WebCall = (() => {
|
|
|
1372
1386
|
function load() {
|
|
1373
1387
|
let r;
|
|
1374
1388
|
try {
|
|
1375
|
-
r = exports.storage.getItem("debug");
|
|
1389
|
+
r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
|
|
1376
1390
|
} catch (error) {
|
|
1377
1391
|
}
|
|
1378
1392
|
if (!r && typeof process !== "undefined" && "env" in process) {
|
|
@@ -1513,9 +1527,9 @@ var WebCall = (() => {
|
|
|
1513
1527
|
}
|
|
1514
1528
|
});
|
|
1515
1529
|
|
|
1516
|
-
// node_modules/.pnpm/debug@4.
|
|
1530
|
+
// node_modules/.pnpm/debug@4.4.1/node_modules/debug/src/node.js
|
|
1517
1531
|
var require_node = __commonJS({
|
|
1518
|
-
"node_modules/.pnpm/debug@4.
|
|
1532
|
+
"node_modules/.pnpm/debug@4.4.1/node_modules/debug/src/node.js"(exports, module) {
|
|
1519
1533
|
var tty = __require("tty");
|
|
1520
1534
|
var util = __require("util");
|
|
1521
1535
|
exports.init = init;
|
|
@@ -1687,9 +1701,9 @@ var WebCall = (() => {
|
|
|
1687
1701
|
}
|
|
1688
1702
|
});
|
|
1689
1703
|
|
|
1690
|
-
// node_modules/.pnpm/debug@4.
|
|
1704
|
+
// node_modules/.pnpm/debug@4.4.1/node_modules/debug/src/index.js
|
|
1691
1705
|
var require_src = __commonJS({
|
|
1692
|
-
"node_modules/.pnpm/debug@4.
|
|
1706
|
+
"node_modules/.pnpm/debug@4.4.1/node_modules/debug/src/index.js"(exports, module) {
|
|
1693
1707
|
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
|
|
1694
1708
|
module.exports = require_browser();
|
|
1695
1709
|
} else {
|
|
@@ -3321,6 +3335,10 @@ var WebCall = (() => {
|
|
|
3321
3335
|
* Server initiated call
|
|
3322
3336
|
*/
|
|
3323
3337
|
KIT_INVITE: "invite",
|
|
3338
|
+
// /**
|
|
3339
|
+
// * Referral
|
|
3340
|
+
// */
|
|
3341
|
+
// KIT_REFER: 'refer',
|
|
3324
3342
|
/**
|
|
3325
3343
|
* Connecting
|
|
3326
3344
|
*/
|
|
@@ -3585,6 +3603,17 @@ var WebCall = (() => {
|
|
|
3585
3603
|
this.callKit.socket.send(SocketSendEvent.CALL, queryTrain);
|
|
3586
3604
|
});
|
|
3587
3605
|
}
|
|
3606
|
+
/**
|
|
3607
|
+
* Refer
|
|
3608
|
+
* @param referTo - The referral target. If a `Session`, a REFER w/Replaces is sent.
|
|
3609
|
+
* @returns
|
|
3610
|
+
*/
|
|
3611
|
+
async callRefer(referTo, options) {
|
|
3612
|
+
if (!this.callKit.config.check())
|
|
3613
|
+
return;
|
|
3614
|
+
this.callKit.logger.debug("callRefer");
|
|
3615
|
+
this.callKit.connect.refer(referTo, options);
|
|
3616
|
+
}
|
|
3588
3617
|
/**
|
|
3589
3618
|
* Hang up
|
|
3590
3619
|
* @param isUnprompted Whether to actively hang up
|
|
@@ -3689,12 +3718,7 @@ var WebCall = (() => {
|
|
|
3689
3718
|
}
|
|
3690
3719
|
};
|
|
3691
3720
|
validate = () => {
|
|
3692
|
-
const {
|
|
3693
|
-
userPart,
|
|
3694
|
-
fsIp,
|
|
3695
|
-
fsPassword,
|
|
3696
|
-
fsPort
|
|
3697
|
-
} = this.config.userInfo;
|
|
3721
|
+
const { userPart, fsIp, fsPassword, fsPort } = this.config.userInfo;
|
|
3698
3722
|
if (!userPart || !fsIp || !fsPort || !fsPassword) {
|
|
3699
3723
|
return false;
|
|
3700
3724
|
}
|
|
@@ -18347,13 +18371,7 @@ var WebCall = (() => {
|
|
|
18347
18371
|
this.mediaStream = await navigator.mediaDevices.getUserMedia(constrains);
|
|
18348
18372
|
return this.mediaStream;
|
|
18349
18373
|
};
|
|
18350
|
-
const {
|
|
18351
|
-
userPart,
|
|
18352
|
-
fsIp,
|
|
18353
|
-
fsPort,
|
|
18354
|
-
iceInfo,
|
|
18355
|
-
wsUrl
|
|
18356
|
-
} = userInfo;
|
|
18374
|
+
const { userPart, fsIp, fsPort, iceInfo, wsUrl } = userInfo;
|
|
18357
18375
|
const connectConfig = {
|
|
18358
18376
|
uri: UserAgent.makeURI(`sip:${userPart}@${fsIp}:${fsPort}`),
|
|
18359
18377
|
displayName: userPart,
|
|
@@ -18454,7 +18472,9 @@ var WebCall = (() => {
|
|
|
18454
18472
|
const { request: request2 } = this.currentSession;
|
|
18455
18473
|
const headerNames = Object.keys(request2.headers);
|
|
18456
18474
|
const xHeaders = {};
|
|
18457
|
-
headerNames.filter(
|
|
18475
|
+
headerNames.filter(
|
|
18476
|
+
(name) => name.toLocaleLowerCase().startsWith("x-antaios")
|
|
18477
|
+
).forEach((name) => {
|
|
18458
18478
|
xHeaders[name.toLocaleLowerCase()] = request2.getHeader(name);
|
|
18459
18479
|
});
|
|
18460
18480
|
this.callKit.logger.debug("get invite data", xHeaders);
|
|
@@ -18480,6 +18500,20 @@ var WebCall = (() => {
|
|
|
18480
18500
|
onRegister: () => {
|
|
18481
18501
|
this.callKit.logger.debug("connect onRegister");
|
|
18482
18502
|
}
|
|
18503
|
+
// onRefer: (referral) => {
|
|
18504
|
+
// this.callKit.trigger(KitEvent.KIT_REFER, {
|
|
18505
|
+
// referAccept: () => {
|
|
18506
|
+
// this.setConnectStatus(CallStatus.connecting);
|
|
18507
|
+
// referral.accept().then(() => {
|
|
18508
|
+
// referral.makeInviter().invite();
|
|
18509
|
+
// });
|
|
18510
|
+
// },
|
|
18511
|
+
// referReject: () => {
|
|
18512
|
+
// referral.reject();
|
|
18513
|
+
// this.callKit.callCenter.callEnd(true, false);
|
|
18514
|
+
// }
|
|
18515
|
+
// });
|
|
18516
|
+
// }
|
|
18483
18517
|
};
|
|
18484
18518
|
await this.userAgent.start().catch((err) => {
|
|
18485
18519
|
this.callKit.callCenter.callEnd(false, true);
|
|
@@ -18687,6 +18721,11 @@ var WebCall = (() => {
|
|
|
18687
18721
|
}
|
|
18688
18722
|
await this.setMute(false);
|
|
18689
18723
|
}
|
|
18724
|
+
async refer(referTo, options) {
|
|
18725
|
+
this.callKit.logger.debug("connect refer");
|
|
18726
|
+
const target = UserAgent.makeURI(referTo);
|
|
18727
|
+
this.currentSession.refer(target, options);
|
|
18728
|
+
}
|
|
18690
18729
|
};
|
|
18691
18730
|
|
|
18692
18731
|
// package/socket.ts
|
|
@@ -19133,6 +19172,12 @@ var WebCall = (() => {
|
|
|
19133
19172
|
this.logger.debug("call");
|
|
19134
19173
|
this.callCenter.callStart();
|
|
19135
19174
|
}
|
|
19175
|
+
async refer(uri, options) {
|
|
19176
|
+
if (!this.config.check())
|
|
19177
|
+
return;
|
|
19178
|
+
this.logger.debug("refer");
|
|
19179
|
+
this.callCenter.callRefer(uri, options);
|
|
19180
|
+
}
|
|
19136
19181
|
async register() {
|
|
19137
19182
|
if (!this.config.check())
|
|
19138
19183
|
return;
|