@coventia/softphone 0.2.1 → 0.4.0
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/{call-VKq1I8yP.d.cts → call-C6YpT6uR.d.cts} +107 -1
- package/dist/{call-VKq1I8yP.d.ts → call-C6YpT6uR.d.ts} +107 -1
- package/dist/chunk-5E5OEXS2.js +14 -0
- package/dist/chunk-5E5OEXS2.js.map +1 -0
- package/dist/{chunk-LMJXX4YM.js → chunk-UHNLEBBO.js} +4 -2
- package/dist/chunk-UHNLEBBO.js.map +1 -0
- package/dist/element/index.d.ts +124 -9
- package/dist/element/index.js +1837 -413
- package/dist/element/index.js.map +1 -1
- package/dist/{engine-BlQBo2Ys.d.cts → engine-CDdaSojx.d.cts} +1 -1
- package/dist/{engine-C0BOkIcW.d.ts → engine-DPft99Wj.d.ts} +1 -1
- package/dist/index.cjs +213 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -6
- package/dist/index.d.ts +16 -6
- package/dist/index.js +75 -10
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +2 -0
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +2 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +1 -1
- package/dist/{softphone-DlGV12Xp.d.cts → softphone-CY5d2WWY.d.cts} +28 -10
- package/dist/{softphone-Cyq3hiIM.d.ts → softphone-DXgmTyrX.d.ts} +28 -10
- package/dist/softphone.css +364 -35
- package/dist/{sources-IRKNQPWW.js → sources-ONYQW733.js} +125 -6
- package/dist/sources-ONYQW733.js.map +1 -0
- package/dist/testing/index.d.cts +2 -2
- package/dist/testing/index.d.ts +2 -2
- package/dist/ui/index.cjs +1450 -33
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.d.cts +25 -3
- package/dist/ui/index.d.ts +25 -3
- package/dist/ui/index.js +1445 -36
- package/dist/ui/index.js.map +1 -1
- package/dist/zadarma/index.d.cts +2 -2
- package/dist/zadarma/index.d.ts +2 -2
- package/package.json +1 -1
- package/dist/chunk-LMJXX4YM.js.map +0 -1
- package/dist/sources-IRKNQPWW.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { S as Softphone } from './softphone-
|
|
2
|
-
export { A as AudioDevices } from './softphone-
|
|
3
|
-
import { S as SoftphoneConfig } from './call-
|
|
4
|
-
export { C as CALL_TRANSITIONS, a as Call, b as CallDirection, c as CallEvent, d as CallEventMap, e as CallOptions, f as CallState, g as Contact, E as ERROR_CATALOGUE, F as FatalErrorCode, h as FatalSoftphoneError, H as HangupReason, i as HoldOriginator, I as INITIAL_STATES, L as LogLevel, N as NonFatalErrorCode, j as NonFatalSoftphoneError, R as RemoteParty,
|
|
1
|
+
import { S as Softphone } from './softphone-CY5d2WWY.cjs';
|
|
2
|
+
export { A as AudioDevices } from './softphone-CY5d2WWY.cjs';
|
|
3
|
+
import { S as SoftphoneConfig, O as OutboundNumberRefusal } from './call-C6YpT6uR.cjs';
|
|
4
|
+
export { C as CALL_TRANSITIONS, a as Call, b as CallDirection, c as CallEvent, d as CallEventMap, e as CallOptions, f as CallState, g as Contact, E as ERROR_CATALOGUE, F as FatalErrorCode, h as FatalSoftphoneError, H as HangupReason, i as HoldOriginator, I as INITIAL_STATES, L as LogLevel, N as NonFatalErrorCode, j as NonFatalSoftphoneError, k as OutboundNumber, l as OutboundNumberKind, m as OutboundNumberSettings, n as OutboundNumberState, o as OutboundNumbersSource, R as RemoteParty, p as RingtoneOption, q as RingtoneSettings, r as RingtoneSource, s as SoftphoneError, t as SoftphoneErrorCode, u as SoftphoneEvent, v as SoftphoneEventMap, w as SoftphoneState, T as TokenEndpointOptions, x as TokenSource, y as TypedEmitter, V as VoiceToken, z as canTransition, A as isFatal, B as isTerminal } from './call-C6YpT6uR.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Construct a softphone.
|
|
@@ -19,6 +19,16 @@ export { C as CALL_TRANSITIONS, a as Call, b as CallDirection, c as CallEvent, d
|
|
|
19
19
|
*/
|
|
20
20
|
declare function createSoftphone(config: SoftphoneConfig): Softphone;
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* A change of outbound number the request limits refused (outbound-number-per-agent.md §5.3–§5.5). Structural,
|
|
24
|
+
* like `isSoftphoneError`: the concrete error is a plain `Error` with a `refusal`, so a host — or a second copy
|
|
25
|
+
* of the SDK on the page — can recognise it without sharing a class.
|
|
26
|
+
*/
|
|
27
|
+
interface OutboundNumberRefusedError extends Error {
|
|
28
|
+
readonly refusal: OutboundNumberRefusal;
|
|
29
|
+
}
|
|
30
|
+
declare function isOutboundNumberRefused(value: unknown): value is OutboundNumberRefusedError;
|
|
31
|
+
|
|
22
32
|
/**
|
|
23
33
|
* Browser-capability probes.
|
|
24
34
|
*
|
|
@@ -57,6 +67,6 @@ declare function isWebRtcSupported(): boolean;
|
|
|
57
67
|
* - `MockProvider` — lives at @coventia/softphone/testing, so it never lands in a production bundle.
|
|
58
68
|
*/
|
|
59
69
|
|
|
60
|
-
declare const VERSION = "0.
|
|
70
|
+
declare const VERSION = "0.4.0";
|
|
61
71
|
|
|
62
|
-
export { Softphone, SoftphoneConfig, VERSION, createSoftphone, isBrowser, isWebRtcSupported };
|
|
72
|
+
export { OutboundNumberRefusal, type OutboundNumberRefusedError, Softphone, SoftphoneConfig, VERSION, createSoftphone, isBrowser, isOutboundNumberRefused, isWebRtcSupported };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { S as Softphone } from './softphone-
|
|
2
|
-
export { A as AudioDevices } from './softphone-
|
|
3
|
-
import { S as SoftphoneConfig } from './call-
|
|
4
|
-
export { C as CALL_TRANSITIONS, a as Call, b as CallDirection, c as CallEvent, d as CallEventMap, e as CallOptions, f as CallState, g as Contact, E as ERROR_CATALOGUE, F as FatalErrorCode, h as FatalSoftphoneError, H as HangupReason, i as HoldOriginator, I as INITIAL_STATES, L as LogLevel, N as NonFatalErrorCode, j as NonFatalSoftphoneError, R as RemoteParty,
|
|
1
|
+
import { S as Softphone } from './softphone-DXgmTyrX.js';
|
|
2
|
+
export { A as AudioDevices } from './softphone-DXgmTyrX.js';
|
|
3
|
+
import { S as SoftphoneConfig, O as OutboundNumberRefusal } from './call-C6YpT6uR.js';
|
|
4
|
+
export { C as CALL_TRANSITIONS, a as Call, b as CallDirection, c as CallEvent, d as CallEventMap, e as CallOptions, f as CallState, g as Contact, E as ERROR_CATALOGUE, F as FatalErrorCode, h as FatalSoftphoneError, H as HangupReason, i as HoldOriginator, I as INITIAL_STATES, L as LogLevel, N as NonFatalErrorCode, j as NonFatalSoftphoneError, k as OutboundNumber, l as OutboundNumberKind, m as OutboundNumberSettings, n as OutboundNumberState, o as OutboundNumbersSource, R as RemoteParty, p as RingtoneOption, q as RingtoneSettings, r as RingtoneSource, s as SoftphoneError, t as SoftphoneErrorCode, u as SoftphoneEvent, v as SoftphoneEventMap, w as SoftphoneState, T as TokenEndpointOptions, x as TokenSource, y as TypedEmitter, V as VoiceToken, z as canTransition, A as isFatal, B as isTerminal } from './call-C6YpT6uR.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Construct a softphone.
|
|
@@ -19,6 +19,16 @@ export { C as CALL_TRANSITIONS, a as Call, b as CallDirection, c as CallEvent, d
|
|
|
19
19
|
*/
|
|
20
20
|
declare function createSoftphone(config: SoftphoneConfig): Softphone;
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* A change of outbound number the request limits refused (outbound-number-per-agent.md §5.3–§5.5). Structural,
|
|
24
|
+
* like `isSoftphoneError`: the concrete error is a plain `Error` with a `refusal`, so a host — or a second copy
|
|
25
|
+
* of the SDK on the page — can recognise it without sharing a class.
|
|
26
|
+
*/
|
|
27
|
+
interface OutboundNumberRefusedError extends Error {
|
|
28
|
+
readonly refusal: OutboundNumberRefusal;
|
|
29
|
+
}
|
|
30
|
+
declare function isOutboundNumberRefused(value: unknown): value is OutboundNumberRefusedError;
|
|
31
|
+
|
|
22
32
|
/**
|
|
23
33
|
* Browser-capability probes.
|
|
24
34
|
*
|
|
@@ -57,6 +67,6 @@ declare function isWebRtcSupported(): boolean;
|
|
|
57
67
|
* - `MockProvider` — lives at @coventia/softphone/testing, so it never lands in a production bundle.
|
|
58
68
|
*/
|
|
59
69
|
|
|
60
|
-
declare const VERSION = "0.
|
|
70
|
+
declare const VERSION = "0.4.0";
|
|
61
71
|
|
|
62
|
-
export { Softphone, SoftphoneConfig, VERSION, createSoftphone, isBrowser, isWebRtcSupported };
|
|
72
|
+
export { OutboundNumberRefusal, type OutboundNumberRefusedError, Softphone, SoftphoneConfig, VERSION, createSoftphone, isBrowser, isOutboundNumberRefused, isWebRtcSupported };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isBrowser } from './chunk-KAXEMJ7E.js';
|
|
2
2
|
export { isBrowser, isWebRtcSupported } from './chunk-KAXEMJ7E.js';
|
|
3
3
|
export { CallEvent, SoftphoneEvent } from './chunk-7R6LOOAI.js';
|
|
4
|
+
export { isOutboundNumberRefused } from './chunk-5E5OEXS2.js';
|
|
4
5
|
import { isFatal } from './chunk-2ZSOGGPO.js';
|
|
5
6
|
export { ERROR_CATALOGUE, isFatal } from './chunk-2ZSOGGPO.js';
|
|
6
7
|
import { cachedTokenSource } from './chunk-MHOJHG5E.js';
|
|
@@ -284,7 +285,7 @@ function coventiaBackend(config, tokenSource, fallbackBaseUrl) {
|
|
|
284
285
|
}
|
|
285
286
|
let pending = null;
|
|
286
287
|
const load = () => {
|
|
287
|
-
pending ??= import('./sources-
|
|
288
|
+
pending ??= import('./sources-ONYQW733.js').then(
|
|
288
289
|
(m) => m.coventiaSources({ ...config, baseUrl, tokenSource })
|
|
289
290
|
);
|
|
290
291
|
return pending;
|
|
@@ -295,7 +296,17 @@ function coventiaBackend(config, tokenSource, fallbackBaseUrl) {
|
|
|
295
296
|
resolveContact: async (number) => (await load()).resolveContact(number),
|
|
296
297
|
listAgents: async () => (await load()).listAgents(),
|
|
297
298
|
transferOutcomes: async (params) => (await load()).transferOutcomes(params),
|
|
298
|
-
presence: async (callbacks) => (await load()).presence(callbacks)
|
|
299
|
+
presence: async (callbacks) => (await load()).presence(callbacks),
|
|
300
|
+
ringtones: {
|
|
301
|
+
get: async (signal) => (await load()).ringtones.get(signal),
|
|
302
|
+
setMine: async (id) => (await load()).ringtones.setMine(id),
|
|
303
|
+
cached: async () => (await load()).ringtones.cached?.() ?? null
|
|
304
|
+
},
|
|
305
|
+
outboundNumbers: {
|
|
306
|
+
get: async (signal) => (await load()).outboundNumbers.get(signal),
|
|
307
|
+
setMine: async (id) => (await load()).outboundNumbers.setMine(id),
|
|
308
|
+
cached: async () => (await load()).outboundNumbers.cached?.() ?? null
|
|
309
|
+
}
|
|
299
310
|
};
|
|
300
311
|
}
|
|
301
312
|
|
|
@@ -506,13 +517,30 @@ var BrowserAudioDevices = class {
|
|
|
506
517
|
outputs = [];
|
|
507
518
|
currentInputId = null;
|
|
508
519
|
currentOutputId = null;
|
|
520
|
+
currentRingtoneOutputId = null;
|
|
509
521
|
canSelectOutput;
|
|
522
|
+
canSelectRingtoneOutput;
|
|
510
523
|
#engine;
|
|
511
524
|
#onChange;
|
|
525
|
+
/**
|
|
526
|
+
* What the user CHOSE, remembered across reloads — distinct from the `current*` fields, which are
|
|
527
|
+
* what is usable right now. Keeping them apart is what stops a fresh page load from wiping a saved
|
|
528
|
+
* choice: until the microphone has been granted, Chrome enumerates every device with a blank id, so
|
|
529
|
+
* "is the saved device in the list?" is no on every first enumeration. The preference survives
|
|
530
|
+
* that; `current*` simply reads `null` until the device is really there.
|
|
531
|
+
*/
|
|
532
|
+
#preferred;
|
|
533
|
+
/** The input the engine was last told about — it starts on the system default (`null`). */
|
|
534
|
+
#engineInputId = null;
|
|
512
535
|
constructor(engine, onChange) {
|
|
513
536
|
this.#engine = engine;
|
|
514
537
|
this.#onChange = onChange;
|
|
515
538
|
this.canSelectOutput = isBrowser() && typeof HTMLMediaElement !== "undefined" && "setSinkId" in HTMLMediaElement.prototype;
|
|
539
|
+
this.canSelectRingtoneOutput = this.canSelectOutput;
|
|
540
|
+
this.#preferred = readStoredDevices();
|
|
541
|
+
this.currentInputId = this.#preferred.input;
|
|
542
|
+
this.currentOutputId = this.#preferred.output;
|
|
543
|
+
this.currentRingtoneOutputId = this.#preferred.ringtone;
|
|
516
544
|
if (isBrowser() && navigator.mediaDevices) {
|
|
517
545
|
void this.refresh();
|
|
518
546
|
navigator.mediaDevices.addEventListener?.("devicechange", () => void this.refresh());
|
|
@@ -528,26 +556,63 @@ var BrowserAudioDevices = class {
|
|
|
528
556
|
}
|
|
529
557
|
this.inputs = all.filter((d) => d.kind === "audioinput");
|
|
530
558
|
this.outputs = all.filter((d) => d.kind === "audiooutput");
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
if (this.currentOutputId && !this.outputs.some((d) => d.deviceId === this.currentOutputId)) {
|
|
535
|
-
this.currentOutputId = null;
|
|
536
|
-
}
|
|
559
|
+
this.currentInputId = usable(this.#preferred.input, this.inputs);
|
|
560
|
+
this.currentOutputId = usable(this.#preferred.output, this.outputs);
|
|
561
|
+
this.currentRingtoneOutputId = usable(this.#preferred.ringtone, this.outputs);
|
|
537
562
|
this.#onChange();
|
|
563
|
+
if (this.currentInputId && this.currentInputId !== this.#engineInputId) {
|
|
564
|
+
await this.#tellEngine(this.currentInputId);
|
|
565
|
+
}
|
|
538
566
|
}
|
|
539
567
|
async setInput(deviceId) {
|
|
540
568
|
this.currentInputId = deviceId;
|
|
569
|
+
this.#remember({ input: deviceId });
|
|
541
570
|
this.#onChange();
|
|
571
|
+
await this.#tellEngine(deviceId);
|
|
572
|
+
}
|
|
573
|
+
async #tellEngine(deviceId) {
|
|
574
|
+
this.#engineInputId = deviceId;
|
|
542
575
|
await this.#engine.setInputDevice?.(deviceId);
|
|
543
576
|
}
|
|
544
577
|
async setOutput(deviceId) {
|
|
545
578
|
this.currentOutputId = deviceId;
|
|
579
|
+
this.#remember({ output: deviceId });
|
|
546
580
|
this.#onChange();
|
|
547
581
|
}
|
|
548
|
-
async setRingtoneOutput() {
|
|
582
|
+
async setRingtoneOutput(deviceId) {
|
|
583
|
+
this.currentRingtoneOutputId = deviceId;
|
|
584
|
+
this.#remember({ ringtone: deviceId });
|
|
585
|
+
this.#onChange();
|
|
586
|
+
}
|
|
587
|
+
#remember(patch) {
|
|
588
|
+
this.#preferred = { ...this.#preferred, ...patch };
|
|
589
|
+
writeStoredDevices(this.#preferred);
|
|
549
590
|
}
|
|
550
591
|
};
|
|
592
|
+
var DEVICES_KEY = "coventia-softphone:devices";
|
|
593
|
+
var NO_DEVICES = { input: null, output: null, ringtone: null };
|
|
594
|
+
function usable(id, list) {
|
|
595
|
+
return id && list.some((d) => d.deviceId === id) ? id : null;
|
|
596
|
+
}
|
|
597
|
+
function readStoredDevices() {
|
|
598
|
+
if (!isBrowser()) return NO_DEVICES;
|
|
599
|
+
try {
|
|
600
|
+
const raw = JSON.parse(globalThis.localStorage?.getItem(DEVICES_KEY) ?? "null");
|
|
601
|
+
if (!raw || typeof raw !== "object") return NO_DEVICES;
|
|
602
|
+
const pick = (v) => typeof v === "string" && v ? v : null;
|
|
603
|
+
const r = raw;
|
|
604
|
+
return { input: pick(r.input), output: pick(r.output), ringtone: pick(r.ringtone) };
|
|
605
|
+
} catch {
|
|
606
|
+
return NO_DEVICES;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
function writeStoredDevices(devices) {
|
|
610
|
+
if (!isBrowser()) return;
|
|
611
|
+
try {
|
|
612
|
+
globalThis.localStorage?.setItem(DEVICES_KEY, JSON.stringify(devices));
|
|
613
|
+
} catch {
|
|
614
|
+
}
|
|
615
|
+
}
|
|
551
616
|
var SoftphoneImpl = class extends Emitter {
|
|
552
617
|
#state = "stopped";
|
|
553
618
|
#lastError = null;
|
|
@@ -950,7 +1015,7 @@ function isCallEngine(value) {
|
|
|
950
1015
|
}
|
|
951
1016
|
|
|
952
1017
|
// src/index.ts
|
|
953
|
-
var VERSION = "0.
|
|
1018
|
+
var VERSION = "0.4.0";
|
|
954
1019
|
|
|
955
1020
|
export { CALL_TRANSITIONS, INITIAL_STATES, VERSION, canTransition, createSoftphone, isTerminal };
|
|
956
1021
|
//# sourceMappingURL=index.js.map
|