@coventia/softphone 0.2.1 → 0.3.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-CaPDWVk3.d.cts} +44 -1
- package/dist/{call-VKq1I8yP.d.ts → call-CaPDWVk3.d.ts} +44 -1
- package/dist/{chunk-LMJXX4YM.js → chunk-UHNLEBBO.js} +4 -2
- package/dist/chunk-UHNLEBBO.js.map +1 -0
- package/dist/element/index.d.ts +68 -9
- package/dist/element/index.js +962 -114
- package/dist/element/index.js.map +1 -1
- package/dist/{engine-C0BOkIcW.d.ts → engine-BgBsIcEa.d.ts} +1 -1
- package/dist/{engine-BlQBo2Ys.d.cts → engine-CU2rEo3g.d.cts} +1 -1
- package/dist/index.cjs +120 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +69 -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-Cyq3hiIM.d.ts → softphone-DEt0TtQw.d.ts} +26 -10
- package/dist/{softphone-DlGV12Xp.d.cts → softphone-dZMkW8V1.d.cts} +26 -10
- package/dist/softphone.css +110 -12
- package/dist/{sources-IRKNQPWW.js → sources-M3GYMS6V.js} +54 -3
- package/dist/sources-M3GYMS6V.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 +885 -28
- 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 +885 -31
- 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, k as
|
|
1
|
+
import { S as Softphone } from './softphone-dZMkW8V1.cjs';
|
|
2
|
+
export { A as AudioDevices } from './softphone-dZMkW8V1.cjs';
|
|
3
|
+
import { S as SoftphoneConfig } from './call-CaPDWVk3.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, R as RemoteParty, k as RingtoneOption, l as RingtoneSettings, m as RingtoneSource, n as SoftphoneError, o as SoftphoneErrorCode, p as SoftphoneEvent, q as SoftphoneEventMap, r as SoftphoneState, T as TokenEndpointOptions, s as TokenSource, t as TypedEmitter, V as VoiceToken, u as canTransition, v as isFatal, w as isTerminal } from './call-CaPDWVk3.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Construct a softphone.
|
|
@@ -57,6 +57,6 @@ declare function isWebRtcSupported(): boolean;
|
|
|
57
57
|
* - `MockProvider` — lives at @coventia/softphone/testing, so it never lands in a production bundle.
|
|
58
58
|
*/
|
|
59
59
|
|
|
60
|
-
declare const VERSION = "0.
|
|
60
|
+
declare const VERSION = "0.3.0";
|
|
61
61
|
|
|
62
62
|
export { Softphone, SoftphoneConfig, VERSION, createSoftphone, isBrowser, 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, k as
|
|
1
|
+
import { S as Softphone } from './softphone-DEt0TtQw.js';
|
|
2
|
+
export { A as AudioDevices } from './softphone-DEt0TtQw.js';
|
|
3
|
+
import { S as SoftphoneConfig } from './call-CaPDWVk3.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, R as RemoteParty, k as RingtoneOption, l as RingtoneSettings, m as RingtoneSource, n as SoftphoneError, o as SoftphoneErrorCode, p as SoftphoneEvent, q as SoftphoneEventMap, r as SoftphoneState, T as TokenEndpointOptions, s as TokenSource, t as TypedEmitter, V as VoiceToken, u as canTransition, v as isFatal, w as isTerminal } from './call-CaPDWVk3.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Construct a softphone.
|
|
@@ -57,6 +57,6 @@ declare function isWebRtcSupported(): boolean;
|
|
|
57
57
|
* - `MockProvider` — lives at @coventia/softphone/testing, so it never lands in a production bundle.
|
|
58
58
|
*/
|
|
59
59
|
|
|
60
|
-
declare const VERSION = "0.
|
|
60
|
+
declare const VERSION = "0.3.0";
|
|
61
61
|
|
|
62
62
|
export { Softphone, SoftphoneConfig, VERSION, createSoftphone, isBrowser, isWebRtcSupported };
|
package/dist/index.js
CHANGED
|
@@ -284,7 +284,7 @@ function coventiaBackend(config, tokenSource, fallbackBaseUrl) {
|
|
|
284
284
|
}
|
|
285
285
|
let pending = null;
|
|
286
286
|
const load = () => {
|
|
287
|
-
pending ??= import('./sources-
|
|
287
|
+
pending ??= import('./sources-M3GYMS6V.js').then(
|
|
288
288
|
(m) => m.coventiaSources({ ...config, baseUrl, tokenSource })
|
|
289
289
|
);
|
|
290
290
|
return pending;
|
|
@@ -295,7 +295,12 @@ function coventiaBackend(config, tokenSource, fallbackBaseUrl) {
|
|
|
295
295
|
resolveContact: async (number) => (await load()).resolveContact(number),
|
|
296
296
|
listAgents: async () => (await load()).listAgents(),
|
|
297
297
|
transferOutcomes: async (params) => (await load()).transferOutcomes(params),
|
|
298
|
-
presence: async (callbacks) => (await load()).presence(callbacks)
|
|
298
|
+
presence: async (callbacks) => (await load()).presence(callbacks),
|
|
299
|
+
ringtones: {
|
|
300
|
+
get: async (signal) => (await load()).ringtones.get(signal),
|
|
301
|
+
setMine: async (id) => (await load()).ringtones.setMine(id),
|
|
302
|
+
cached: async () => (await load()).ringtones.cached?.() ?? null
|
|
303
|
+
}
|
|
299
304
|
};
|
|
300
305
|
}
|
|
301
306
|
|
|
@@ -506,13 +511,30 @@ var BrowserAudioDevices = class {
|
|
|
506
511
|
outputs = [];
|
|
507
512
|
currentInputId = null;
|
|
508
513
|
currentOutputId = null;
|
|
514
|
+
currentRingtoneOutputId = null;
|
|
509
515
|
canSelectOutput;
|
|
516
|
+
canSelectRingtoneOutput;
|
|
510
517
|
#engine;
|
|
511
518
|
#onChange;
|
|
519
|
+
/**
|
|
520
|
+
* What the user CHOSE, remembered across reloads — distinct from the `current*` fields, which are
|
|
521
|
+
* what is usable right now. Keeping them apart is what stops a fresh page load from wiping a saved
|
|
522
|
+
* choice: until the microphone has been granted, Chrome enumerates every device with a blank id, so
|
|
523
|
+
* "is the saved device in the list?" is no on every first enumeration. The preference survives
|
|
524
|
+
* that; `current*` simply reads `null` until the device is really there.
|
|
525
|
+
*/
|
|
526
|
+
#preferred;
|
|
527
|
+
/** The input the engine was last told about — it starts on the system default (`null`). */
|
|
528
|
+
#engineInputId = null;
|
|
512
529
|
constructor(engine, onChange) {
|
|
513
530
|
this.#engine = engine;
|
|
514
531
|
this.#onChange = onChange;
|
|
515
532
|
this.canSelectOutput = isBrowser() && typeof HTMLMediaElement !== "undefined" && "setSinkId" in HTMLMediaElement.prototype;
|
|
533
|
+
this.canSelectRingtoneOutput = this.canSelectOutput;
|
|
534
|
+
this.#preferred = readStoredDevices();
|
|
535
|
+
this.currentInputId = this.#preferred.input;
|
|
536
|
+
this.currentOutputId = this.#preferred.output;
|
|
537
|
+
this.currentRingtoneOutputId = this.#preferred.ringtone;
|
|
516
538
|
if (isBrowser() && navigator.mediaDevices) {
|
|
517
539
|
void this.refresh();
|
|
518
540
|
navigator.mediaDevices.addEventListener?.("devicechange", () => void this.refresh());
|
|
@@ -528,26 +550,63 @@ var BrowserAudioDevices = class {
|
|
|
528
550
|
}
|
|
529
551
|
this.inputs = all.filter((d) => d.kind === "audioinput");
|
|
530
552
|
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
|
-
}
|
|
553
|
+
this.currentInputId = usable(this.#preferred.input, this.inputs);
|
|
554
|
+
this.currentOutputId = usable(this.#preferred.output, this.outputs);
|
|
555
|
+
this.currentRingtoneOutputId = usable(this.#preferred.ringtone, this.outputs);
|
|
537
556
|
this.#onChange();
|
|
557
|
+
if (this.currentInputId && this.currentInputId !== this.#engineInputId) {
|
|
558
|
+
await this.#tellEngine(this.currentInputId);
|
|
559
|
+
}
|
|
538
560
|
}
|
|
539
561
|
async setInput(deviceId) {
|
|
540
562
|
this.currentInputId = deviceId;
|
|
563
|
+
this.#remember({ input: deviceId });
|
|
541
564
|
this.#onChange();
|
|
565
|
+
await this.#tellEngine(deviceId);
|
|
566
|
+
}
|
|
567
|
+
async #tellEngine(deviceId) {
|
|
568
|
+
this.#engineInputId = deviceId;
|
|
542
569
|
await this.#engine.setInputDevice?.(deviceId);
|
|
543
570
|
}
|
|
544
571
|
async setOutput(deviceId) {
|
|
545
572
|
this.currentOutputId = deviceId;
|
|
573
|
+
this.#remember({ output: deviceId });
|
|
546
574
|
this.#onChange();
|
|
547
575
|
}
|
|
548
|
-
async setRingtoneOutput() {
|
|
576
|
+
async setRingtoneOutput(deviceId) {
|
|
577
|
+
this.currentRingtoneOutputId = deviceId;
|
|
578
|
+
this.#remember({ ringtone: deviceId });
|
|
579
|
+
this.#onChange();
|
|
580
|
+
}
|
|
581
|
+
#remember(patch) {
|
|
582
|
+
this.#preferred = { ...this.#preferred, ...patch };
|
|
583
|
+
writeStoredDevices(this.#preferred);
|
|
549
584
|
}
|
|
550
585
|
};
|
|
586
|
+
var DEVICES_KEY = "coventia-softphone:devices";
|
|
587
|
+
var NO_DEVICES = { input: null, output: null, ringtone: null };
|
|
588
|
+
function usable(id, list) {
|
|
589
|
+
return id && list.some((d) => d.deviceId === id) ? id : null;
|
|
590
|
+
}
|
|
591
|
+
function readStoredDevices() {
|
|
592
|
+
if (!isBrowser()) return NO_DEVICES;
|
|
593
|
+
try {
|
|
594
|
+
const raw = JSON.parse(globalThis.localStorage?.getItem(DEVICES_KEY) ?? "null");
|
|
595
|
+
if (!raw || typeof raw !== "object") return NO_DEVICES;
|
|
596
|
+
const pick = (v) => typeof v === "string" && v ? v : null;
|
|
597
|
+
const r = raw;
|
|
598
|
+
return { input: pick(r.input), output: pick(r.output), ringtone: pick(r.ringtone) };
|
|
599
|
+
} catch {
|
|
600
|
+
return NO_DEVICES;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
function writeStoredDevices(devices) {
|
|
604
|
+
if (!isBrowser()) return;
|
|
605
|
+
try {
|
|
606
|
+
globalThis.localStorage?.setItem(DEVICES_KEY, JSON.stringify(devices));
|
|
607
|
+
} catch {
|
|
608
|
+
}
|
|
609
|
+
}
|
|
551
610
|
var SoftphoneImpl = class extends Emitter {
|
|
552
611
|
#state = "stopped";
|
|
553
612
|
#lastError = null;
|
|
@@ -950,7 +1009,7 @@ function isCallEngine(value) {
|
|
|
950
1009
|
}
|
|
951
1010
|
|
|
952
1011
|
// src/index.ts
|
|
953
|
-
var VERSION = "0.
|
|
1012
|
+
var VERSION = "0.3.0";
|
|
954
1013
|
|
|
955
1014
|
export { CALL_TRANSITIONS, INITIAL_STATES, VERSION, canTransition, createSoftphone, isTerminal };
|
|
956
1015
|
//# sourceMappingURL=index.js.map
|