@wazo/sdk 0.37.43 → 0.38.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/wazo-sdk.js +1 -1
- package/esm/index.js +148 -0
- package/esm/simple/Auth.js +148 -0
- package/esm/simple/Configuration.js +148 -0
- package/esm/simple/Phone.js +148 -0
- package/esm/simple/Softphone.js +148 -0
- package/esm/simple/index.js +148 -0
- package/esm/simple/room/LocalParticipant.js +148 -0
- package/esm/simple/room/Participant.js +148 -0
- package/esm/simple/room/RemoteParticipant.js +148 -0
- package/esm/simple/room/Room.js +148 -0
- package/esm/simple/room/SipRoom.js +148 -0
- package/esm/simple/room/Stream.js +148 -0
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +148 -0
- package/esm/simple/utils.js +148 -0
- package/lib/index.js +148 -0
- package/lib/simple/Auth.js +148 -0
- package/lib/simple/Configuration.js +148 -0
- package/lib/simple/Phone.js +148 -0
- package/lib/simple/Softphone.js +150 -0
- package/lib/simple/index.js +148 -0
- package/lib/simple/room/LocalParticipant.js +148 -0
- package/lib/simple/room/Participant.js +148 -0
- package/lib/simple/room/RemoteParticipant.js +148 -0
- package/lib/simple/room/Room.js +148 -0
- package/lib/simple/room/SipRoom.js +148 -0
- package/lib/simple/room/Stream.js +148 -0
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +148 -0
- package/lib/simple/utils.js +148 -0
- package/package.json +1 -1
- package/src/simple/Softphone.js +148 -0
- package/src/simple/index.js +2 -0
package/esm/index.js
CHANGED
|
@@ -14107,6 +14107,153 @@ const createLocalVideoStream = async (options ) => createLocalStream('vid
|
|
|
14107
14107
|
|
|
14108
14108
|
const createLocalAudioStream = async (options ) => createLocalStream('audio', options);
|
|
14109
14109
|
|
|
14110
|
+
//
|
|
14111
|
+
/* eslint-disable no-unused-vars */
|
|
14112
|
+
/* global window, document */
|
|
14113
|
+
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
14114
|
+
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
14115
|
+
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
14116
|
+
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
14117
|
+
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
14118
|
+
|
|
14119
|
+
class Softphone {
|
|
14120
|
+
url = 'https://softphone.wazo.io';
|
|
14121
|
+
width = 500;
|
|
14122
|
+
height = 600;
|
|
14123
|
+
displayed = false;
|
|
14124
|
+
iframe = null;
|
|
14125
|
+
|
|
14126
|
+
onLinkEnabled(link ) {}
|
|
14127
|
+
|
|
14128
|
+
onCallMade(call ) {}
|
|
14129
|
+
onCallIncoming(call ) {}
|
|
14130
|
+
onCallEnded(call , card , direction , fromExtension ) {}
|
|
14131
|
+
onAuthenticated(session ) {}
|
|
14132
|
+
|
|
14133
|
+
init(url , width , height ) {
|
|
14134
|
+
if (url) {
|
|
14135
|
+
this.url = url;
|
|
14136
|
+
}
|
|
14137
|
+
if (width) {
|
|
14138
|
+
this.width = width;
|
|
14139
|
+
}
|
|
14140
|
+
if (height) {
|
|
14141
|
+
this.height = height;
|
|
14142
|
+
}
|
|
14143
|
+
|
|
14144
|
+
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
14145
|
+
|
|
14146
|
+
this._createIframe();
|
|
14147
|
+
}
|
|
14148
|
+
|
|
14149
|
+
parseLinks() {
|
|
14150
|
+
const links = this._getLinks();
|
|
14151
|
+
|
|
14152
|
+
links.forEach(link => {
|
|
14153
|
+
link.setAttribute('data-wazo-parsed', true);
|
|
14154
|
+
link.addEventListener('click', this._onLinkClick.bind(this));
|
|
14155
|
+
this.onLinkEnabled(link);
|
|
14156
|
+
});
|
|
14157
|
+
}
|
|
14158
|
+
|
|
14159
|
+
makeCall(number ) {
|
|
14160
|
+
this.displaySoftphone();
|
|
14161
|
+
|
|
14162
|
+
if (this.iframe) {
|
|
14163
|
+
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
14164
|
+
}
|
|
14165
|
+
}
|
|
14166
|
+
|
|
14167
|
+
toggleSoftphoneDisplay() {
|
|
14168
|
+
if (this.displayed) {
|
|
14169
|
+
this.hideSoftphone();
|
|
14170
|
+
} else {
|
|
14171
|
+
this.displaySoftphone();
|
|
14172
|
+
}
|
|
14173
|
+
|
|
14174
|
+
this.displayed = !this.displayed;
|
|
14175
|
+
}
|
|
14176
|
+
|
|
14177
|
+
displaySoftphone() {
|
|
14178
|
+
if (!this.iframe) {
|
|
14179
|
+
this._createIframe();
|
|
14180
|
+
}
|
|
14181
|
+
|
|
14182
|
+
if (this.iframe) {
|
|
14183
|
+
this.iframe.style.display = 'block';
|
|
14184
|
+
}
|
|
14185
|
+
}
|
|
14186
|
+
|
|
14187
|
+
hideSoftphone() {
|
|
14188
|
+
if (this.iframe) {
|
|
14189
|
+
this.iframe.style.display = 'none';
|
|
14190
|
+
}
|
|
14191
|
+
}
|
|
14192
|
+
|
|
14193
|
+
_createIframe() {
|
|
14194
|
+
this.iframe = document.createElement('iframe');
|
|
14195
|
+
// $FlowFixMe
|
|
14196
|
+
this.iframe.width = this.width;
|
|
14197
|
+
// $FlowFixMe
|
|
14198
|
+
this.iframe.height = this.height;
|
|
14199
|
+
// $FlowFixMe
|
|
14200
|
+
this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
|
|
14201
|
+
this.iframe.style.position = 'absolute';
|
|
14202
|
+
this.iframe.style.left = '0';
|
|
14203
|
+
this.iframe.style.bottom = '0';
|
|
14204
|
+
this.iframe.style.border = '1px solid #aaa';
|
|
14205
|
+
this.iframe.src = this.url;
|
|
14206
|
+
this.iframe.style.display = 'none';
|
|
14207
|
+
this.iframe.id = 'wazo-softphone';
|
|
14208
|
+
|
|
14209
|
+
// $FlowFixMe
|
|
14210
|
+
document.body.appendChild(this.iframe);
|
|
14211
|
+
}
|
|
14212
|
+
|
|
14213
|
+
_getLinks() {
|
|
14214
|
+
return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
|
|
14215
|
+
.filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
|
|
14216
|
+
}
|
|
14217
|
+
|
|
14218
|
+
_onLinkClick(e ) {
|
|
14219
|
+
e.preventDefault();
|
|
14220
|
+
const number = e.target.href.split(':')[1];
|
|
14221
|
+
|
|
14222
|
+
this.makeCall(number);
|
|
14223
|
+
}
|
|
14224
|
+
|
|
14225
|
+
_onAuthenticated() {
|
|
14226
|
+
this.parseLinks();
|
|
14227
|
+
}
|
|
14228
|
+
|
|
14229
|
+
_onMessage(event ) {
|
|
14230
|
+
if (!event.data) {
|
|
14231
|
+
return;
|
|
14232
|
+
}
|
|
14233
|
+
|
|
14234
|
+
switch (event.data.type) {
|
|
14235
|
+
case SDK_ON_CALL_MADE:
|
|
14236
|
+
this.onCallMade(event.data.callSession);
|
|
14237
|
+
break;
|
|
14238
|
+
case SDK_CALL_ENDED: {
|
|
14239
|
+
const { callSession, content, direction, userExtension } = event.data;
|
|
14240
|
+
this.onCallEnded(callSession, content, direction, userExtension);
|
|
14241
|
+
break;
|
|
14242
|
+
}
|
|
14243
|
+
case SDK_CALL_INCOMING:
|
|
14244
|
+
this.onCallIncoming(event.data.callSession);
|
|
14245
|
+
break;
|
|
14246
|
+
case SDK_AUTHENTICATED:
|
|
14247
|
+
// $FlowFixMe
|
|
14248
|
+
this._onAuthenticated(event.data.session);
|
|
14249
|
+
this.onAuthenticated(event.data.session);
|
|
14250
|
+
break;
|
|
14251
|
+
}
|
|
14252
|
+
}
|
|
14253
|
+
}
|
|
14254
|
+
|
|
14255
|
+
var Softphone$1 = new Softphone();
|
|
14256
|
+
|
|
14110
14257
|
/* global window */
|
|
14111
14258
|
|
|
14112
14259
|
const Wazo = {
|
|
@@ -14127,6 +14274,7 @@ const Wazo = {
|
|
|
14127
14274
|
loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
|
|
14128
14275
|
Features: Features$1,
|
|
14129
14276
|
Checker,
|
|
14277
|
+
Softphone: Softphone$1,
|
|
14130
14278
|
|
|
14131
14279
|
// Domain
|
|
14132
14280
|
domain: {
|
package/esm/simple/Auth.js
CHANGED
|
@@ -13668,6 +13668,153 @@ class Checker {
|
|
|
13668
13668
|
}
|
|
13669
13669
|
}
|
|
13670
13670
|
|
|
13671
|
+
//
|
|
13672
|
+
/* eslint-disable no-unused-vars */
|
|
13673
|
+
/* global window, document */
|
|
13674
|
+
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
13675
|
+
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
13676
|
+
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
13677
|
+
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
13678
|
+
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
13679
|
+
|
|
13680
|
+
class Softphone {
|
|
13681
|
+
url = 'https://softphone.wazo.io';
|
|
13682
|
+
width = 500;
|
|
13683
|
+
height = 600;
|
|
13684
|
+
displayed = false;
|
|
13685
|
+
iframe = null;
|
|
13686
|
+
|
|
13687
|
+
onLinkEnabled(link ) {}
|
|
13688
|
+
|
|
13689
|
+
onCallMade(call ) {}
|
|
13690
|
+
onCallIncoming(call ) {}
|
|
13691
|
+
onCallEnded(call , card , direction , fromExtension ) {}
|
|
13692
|
+
onAuthenticated(session ) {}
|
|
13693
|
+
|
|
13694
|
+
init(url , width , height ) {
|
|
13695
|
+
if (url) {
|
|
13696
|
+
this.url = url;
|
|
13697
|
+
}
|
|
13698
|
+
if (width) {
|
|
13699
|
+
this.width = width;
|
|
13700
|
+
}
|
|
13701
|
+
if (height) {
|
|
13702
|
+
this.height = height;
|
|
13703
|
+
}
|
|
13704
|
+
|
|
13705
|
+
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
13706
|
+
|
|
13707
|
+
this._createIframe();
|
|
13708
|
+
}
|
|
13709
|
+
|
|
13710
|
+
parseLinks() {
|
|
13711
|
+
const links = this._getLinks();
|
|
13712
|
+
|
|
13713
|
+
links.forEach(link => {
|
|
13714
|
+
link.setAttribute('data-wazo-parsed', true);
|
|
13715
|
+
link.addEventListener('click', this._onLinkClick.bind(this));
|
|
13716
|
+
this.onLinkEnabled(link);
|
|
13717
|
+
});
|
|
13718
|
+
}
|
|
13719
|
+
|
|
13720
|
+
makeCall(number ) {
|
|
13721
|
+
this.displaySoftphone();
|
|
13722
|
+
|
|
13723
|
+
if (this.iframe) {
|
|
13724
|
+
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
13725
|
+
}
|
|
13726
|
+
}
|
|
13727
|
+
|
|
13728
|
+
toggleSoftphoneDisplay() {
|
|
13729
|
+
if (this.displayed) {
|
|
13730
|
+
this.hideSoftphone();
|
|
13731
|
+
} else {
|
|
13732
|
+
this.displaySoftphone();
|
|
13733
|
+
}
|
|
13734
|
+
|
|
13735
|
+
this.displayed = !this.displayed;
|
|
13736
|
+
}
|
|
13737
|
+
|
|
13738
|
+
displaySoftphone() {
|
|
13739
|
+
if (!this.iframe) {
|
|
13740
|
+
this._createIframe();
|
|
13741
|
+
}
|
|
13742
|
+
|
|
13743
|
+
if (this.iframe) {
|
|
13744
|
+
this.iframe.style.display = 'block';
|
|
13745
|
+
}
|
|
13746
|
+
}
|
|
13747
|
+
|
|
13748
|
+
hideSoftphone() {
|
|
13749
|
+
if (this.iframe) {
|
|
13750
|
+
this.iframe.style.display = 'none';
|
|
13751
|
+
}
|
|
13752
|
+
}
|
|
13753
|
+
|
|
13754
|
+
_createIframe() {
|
|
13755
|
+
this.iframe = document.createElement('iframe');
|
|
13756
|
+
// $FlowFixMe
|
|
13757
|
+
this.iframe.width = this.width;
|
|
13758
|
+
// $FlowFixMe
|
|
13759
|
+
this.iframe.height = this.height;
|
|
13760
|
+
// $FlowFixMe
|
|
13761
|
+
this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
|
|
13762
|
+
this.iframe.style.position = 'absolute';
|
|
13763
|
+
this.iframe.style.left = '0';
|
|
13764
|
+
this.iframe.style.bottom = '0';
|
|
13765
|
+
this.iframe.style.border = '1px solid #aaa';
|
|
13766
|
+
this.iframe.src = this.url;
|
|
13767
|
+
this.iframe.style.display = 'none';
|
|
13768
|
+
this.iframe.id = 'wazo-softphone';
|
|
13769
|
+
|
|
13770
|
+
// $FlowFixMe
|
|
13771
|
+
document.body.appendChild(this.iframe);
|
|
13772
|
+
}
|
|
13773
|
+
|
|
13774
|
+
_getLinks() {
|
|
13775
|
+
return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
|
|
13776
|
+
.filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
|
|
13777
|
+
}
|
|
13778
|
+
|
|
13779
|
+
_onLinkClick(e ) {
|
|
13780
|
+
e.preventDefault();
|
|
13781
|
+
const number = e.target.href.split(':')[1];
|
|
13782
|
+
|
|
13783
|
+
this.makeCall(number);
|
|
13784
|
+
}
|
|
13785
|
+
|
|
13786
|
+
_onAuthenticated() {
|
|
13787
|
+
this.parseLinks();
|
|
13788
|
+
}
|
|
13789
|
+
|
|
13790
|
+
_onMessage(event ) {
|
|
13791
|
+
if (!event.data) {
|
|
13792
|
+
return;
|
|
13793
|
+
}
|
|
13794
|
+
|
|
13795
|
+
switch (event.data.type) {
|
|
13796
|
+
case SDK_ON_CALL_MADE:
|
|
13797
|
+
this.onCallMade(event.data.callSession);
|
|
13798
|
+
break;
|
|
13799
|
+
case SDK_CALL_ENDED: {
|
|
13800
|
+
const { callSession, content, direction, userExtension } = event.data;
|
|
13801
|
+
this.onCallEnded(callSession, content, direction, userExtension);
|
|
13802
|
+
break;
|
|
13803
|
+
}
|
|
13804
|
+
case SDK_CALL_INCOMING:
|
|
13805
|
+
this.onCallIncoming(event.data.callSession);
|
|
13806
|
+
break;
|
|
13807
|
+
case SDK_AUTHENTICATED:
|
|
13808
|
+
// $FlowFixMe
|
|
13809
|
+
this._onAuthenticated(event.data.session);
|
|
13810
|
+
this.onAuthenticated(event.data.session);
|
|
13811
|
+
break;
|
|
13812
|
+
}
|
|
13813
|
+
}
|
|
13814
|
+
}
|
|
13815
|
+
|
|
13816
|
+
var Softphone$1 = new Softphone();
|
|
13817
|
+
|
|
13671
13818
|
/* global window */
|
|
13672
13819
|
|
|
13673
13820
|
const Wazo = {
|
|
@@ -13688,6 +13835,7 @@ const Wazo = {
|
|
|
13688
13835
|
loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
|
|
13689
13836
|
Features: Features$1,
|
|
13690
13837
|
Checker,
|
|
13838
|
+
Softphone: Softphone$1,
|
|
13691
13839
|
|
|
13692
13840
|
// Domain
|
|
13693
13841
|
domain: {
|
|
@@ -13651,6 +13651,153 @@ class Checker {
|
|
|
13651
13651
|
}
|
|
13652
13652
|
}
|
|
13653
13653
|
|
|
13654
|
+
//
|
|
13655
|
+
/* eslint-disable no-unused-vars */
|
|
13656
|
+
/* global window, document */
|
|
13657
|
+
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
13658
|
+
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
13659
|
+
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
13660
|
+
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
13661
|
+
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
13662
|
+
|
|
13663
|
+
class Softphone {
|
|
13664
|
+
url = 'https://softphone.wazo.io';
|
|
13665
|
+
width = 500;
|
|
13666
|
+
height = 600;
|
|
13667
|
+
displayed = false;
|
|
13668
|
+
iframe = null;
|
|
13669
|
+
|
|
13670
|
+
onLinkEnabled(link ) {}
|
|
13671
|
+
|
|
13672
|
+
onCallMade(call ) {}
|
|
13673
|
+
onCallIncoming(call ) {}
|
|
13674
|
+
onCallEnded(call , card , direction , fromExtension ) {}
|
|
13675
|
+
onAuthenticated(session ) {}
|
|
13676
|
+
|
|
13677
|
+
init(url , width , height ) {
|
|
13678
|
+
if (url) {
|
|
13679
|
+
this.url = url;
|
|
13680
|
+
}
|
|
13681
|
+
if (width) {
|
|
13682
|
+
this.width = width;
|
|
13683
|
+
}
|
|
13684
|
+
if (height) {
|
|
13685
|
+
this.height = height;
|
|
13686
|
+
}
|
|
13687
|
+
|
|
13688
|
+
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
13689
|
+
|
|
13690
|
+
this._createIframe();
|
|
13691
|
+
}
|
|
13692
|
+
|
|
13693
|
+
parseLinks() {
|
|
13694
|
+
const links = this._getLinks();
|
|
13695
|
+
|
|
13696
|
+
links.forEach(link => {
|
|
13697
|
+
link.setAttribute('data-wazo-parsed', true);
|
|
13698
|
+
link.addEventListener('click', this._onLinkClick.bind(this));
|
|
13699
|
+
this.onLinkEnabled(link);
|
|
13700
|
+
});
|
|
13701
|
+
}
|
|
13702
|
+
|
|
13703
|
+
makeCall(number ) {
|
|
13704
|
+
this.displaySoftphone();
|
|
13705
|
+
|
|
13706
|
+
if (this.iframe) {
|
|
13707
|
+
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
13708
|
+
}
|
|
13709
|
+
}
|
|
13710
|
+
|
|
13711
|
+
toggleSoftphoneDisplay() {
|
|
13712
|
+
if (this.displayed) {
|
|
13713
|
+
this.hideSoftphone();
|
|
13714
|
+
} else {
|
|
13715
|
+
this.displaySoftphone();
|
|
13716
|
+
}
|
|
13717
|
+
|
|
13718
|
+
this.displayed = !this.displayed;
|
|
13719
|
+
}
|
|
13720
|
+
|
|
13721
|
+
displaySoftphone() {
|
|
13722
|
+
if (!this.iframe) {
|
|
13723
|
+
this._createIframe();
|
|
13724
|
+
}
|
|
13725
|
+
|
|
13726
|
+
if (this.iframe) {
|
|
13727
|
+
this.iframe.style.display = 'block';
|
|
13728
|
+
}
|
|
13729
|
+
}
|
|
13730
|
+
|
|
13731
|
+
hideSoftphone() {
|
|
13732
|
+
if (this.iframe) {
|
|
13733
|
+
this.iframe.style.display = 'none';
|
|
13734
|
+
}
|
|
13735
|
+
}
|
|
13736
|
+
|
|
13737
|
+
_createIframe() {
|
|
13738
|
+
this.iframe = document.createElement('iframe');
|
|
13739
|
+
// $FlowFixMe
|
|
13740
|
+
this.iframe.width = this.width;
|
|
13741
|
+
// $FlowFixMe
|
|
13742
|
+
this.iframe.height = this.height;
|
|
13743
|
+
// $FlowFixMe
|
|
13744
|
+
this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
|
|
13745
|
+
this.iframe.style.position = 'absolute';
|
|
13746
|
+
this.iframe.style.left = '0';
|
|
13747
|
+
this.iframe.style.bottom = '0';
|
|
13748
|
+
this.iframe.style.border = '1px solid #aaa';
|
|
13749
|
+
this.iframe.src = this.url;
|
|
13750
|
+
this.iframe.style.display = 'none';
|
|
13751
|
+
this.iframe.id = 'wazo-softphone';
|
|
13752
|
+
|
|
13753
|
+
// $FlowFixMe
|
|
13754
|
+
document.body.appendChild(this.iframe);
|
|
13755
|
+
}
|
|
13756
|
+
|
|
13757
|
+
_getLinks() {
|
|
13758
|
+
return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
|
|
13759
|
+
.filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
|
|
13760
|
+
}
|
|
13761
|
+
|
|
13762
|
+
_onLinkClick(e ) {
|
|
13763
|
+
e.preventDefault();
|
|
13764
|
+
const number = e.target.href.split(':')[1];
|
|
13765
|
+
|
|
13766
|
+
this.makeCall(number);
|
|
13767
|
+
}
|
|
13768
|
+
|
|
13769
|
+
_onAuthenticated() {
|
|
13770
|
+
this.parseLinks();
|
|
13771
|
+
}
|
|
13772
|
+
|
|
13773
|
+
_onMessage(event ) {
|
|
13774
|
+
if (!event.data) {
|
|
13775
|
+
return;
|
|
13776
|
+
}
|
|
13777
|
+
|
|
13778
|
+
switch (event.data.type) {
|
|
13779
|
+
case SDK_ON_CALL_MADE:
|
|
13780
|
+
this.onCallMade(event.data.callSession);
|
|
13781
|
+
break;
|
|
13782
|
+
case SDK_CALL_ENDED: {
|
|
13783
|
+
const { callSession, content, direction, userExtension } = event.data;
|
|
13784
|
+
this.onCallEnded(callSession, content, direction, userExtension);
|
|
13785
|
+
break;
|
|
13786
|
+
}
|
|
13787
|
+
case SDK_CALL_INCOMING:
|
|
13788
|
+
this.onCallIncoming(event.data.callSession);
|
|
13789
|
+
break;
|
|
13790
|
+
case SDK_AUTHENTICATED:
|
|
13791
|
+
// $FlowFixMe
|
|
13792
|
+
this._onAuthenticated(event.data.session);
|
|
13793
|
+
this.onAuthenticated(event.data.session);
|
|
13794
|
+
break;
|
|
13795
|
+
}
|
|
13796
|
+
}
|
|
13797
|
+
}
|
|
13798
|
+
|
|
13799
|
+
var Softphone$1 = new Softphone();
|
|
13800
|
+
|
|
13654
13801
|
/* global window */
|
|
13655
13802
|
|
|
13656
13803
|
const Wazo = {
|
|
@@ -13671,6 +13818,7 @@ const Wazo = {
|
|
|
13671
13818
|
loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
|
|
13672
13819
|
Features: Features$1,
|
|
13673
13820
|
Checker,
|
|
13821
|
+
Softphone: Softphone$1,
|
|
13674
13822
|
|
|
13675
13823
|
// Domain
|
|
13676
13824
|
domain: {
|
package/esm/simple/Phone.js
CHANGED
|
@@ -13559,6 +13559,153 @@ class Checker {
|
|
|
13559
13559
|
}
|
|
13560
13560
|
}
|
|
13561
13561
|
|
|
13562
|
+
//
|
|
13563
|
+
/* eslint-disable no-unused-vars */
|
|
13564
|
+
/* global window, document */
|
|
13565
|
+
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
13566
|
+
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
13567
|
+
const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
|
|
13568
|
+
const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
|
|
13569
|
+
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
13570
|
+
|
|
13571
|
+
class Softphone {
|
|
13572
|
+
url = 'https://softphone.wazo.io';
|
|
13573
|
+
width = 500;
|
|
13574
|
+
height = 600;
|
|
13575
|
+
displayed = false;
|
|
13576
|
+
iframe = null;
|
|
13577
|
+
|
|
13578
|
+
onLinkEnabled(link ) {}
|
|
13579
|
+
|
|
13580
|
+
onCallMade(call ) {}
|
|
13581
|
+
onCallIncoming(call ) {}
|
|
13582
|
+
onCallEnded(call , card , direction , fromExtension ) {}
|
|
13583
|
+
onAuthenticated(session ) {}
|
|
13584
|
+
|
|
13585
|
+
init(url , width , height ) {
|
|
13586
|
+
if (url) {
|
|
13587
|
+
this.url = url;
|
|
13588
|
+
}
|
|
13589
|
+
if (width) {
|
|
13590
|
+
this.width = width;
|
|
13591
|
+
}
|
|
13592
|
+
if (height) {
|
|
13593
|
+
this.height = height;
|
|
13594
|
+
}
|
|
13595
|
+
|
|
13596
|
+
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
13597
|
+
|
|
13598
|
+
this._createIframe();
|
|
13599
|
+
}
|
|
13600
|
+
|
|
13601
|
+
parseLinks() {
|
|
13602
|
+
const links = this._getLinks();
|
|
13603
|
+
|
|
13604
|
+
links.forEach(link => {
|
|
13605
|
+
link.setAttribute('data-wazo-parsed', true);
|
|
13606
|
+
link.addEventListener('click', this._onLinkClick.bind(this));
|
|
13607
|
+
this.onLinkEnabled(link);
|
|
13608
|
+
});
|
|
13609
|
+
}
|
|
13610
|
+
|
|
13611
|
+
makeCall(number ) {
|
|
13612
|
+
this.displaySoftphone();
|
|
13613
|
+
|
|
13614
|
+
if (this.iframe) {
|
|
13615
|
+
this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
|
|
13616
|
+
}
|
|
13617
|
+
}
|
|
13618
|
+
|
|
13619
|
+
toggleSoftphoneDisplay() {
|
|
13620
|
+
if (this.displayed) {
|
|
13621
|
+
this.hideSoftphone();
|
|
13622
|
+
} else {
|
|
13623
|
+
this.displaySoftphone();
|
|
13624
|
+
}
|
|
13625
|
+
|
|
13626
|
+
this.displayed = !this.displayed;
|
|
13627
|
+
}
|
|
13628
|
+
|
|
13629
|
+
displaySoftphone() {
|
|
13630
|
+
if (!this.iframe) {
|
|
13631
|
+
this._createIframe();
|
|
13632
|
+
}
|
|
13633
|
+
|
|
13634
|
+
if (this.iframe) {
|
|
13635
|
+
this.iframe.style.display = 'block';
|
|
13636
|
+
}
|
|
13637
|
+
}
|
|
13638
|
+
|
|
13639
|
+
hideSoftphone() {
|
|
13640
|
+
if (this.iframe) {
|
|
13641
|
+
this.iframe.style.display = 'none';
|
|
13642
|
+
}
|
|
13643
|
+
}
|
|
13644
|
+
|
|
13645
|
+
_createIframe() {
|
|
13646
|
+
this.iframe = document.createElement('iframe');
|
|
13647
|
+
// $FlowFixMe
|
|
13648
|
+
this.iframe.width = this.width;
|
|
13649
|
+
// $FlowFixMe
|
|
13650
|
+
this.iframe.height = this.height;
|
|
13651
|
+
// $FlowFixMe
|
|
13652
|
+
this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
|
|
13653
|
+
this.iframe.style.position = 'absolute';
|
|
13654
|
+
this.iframe.style.left = '0';
|
|
13655
|
+
this.iframe.style.bottom = '0';
|
|
13656
|
+
this.iframe.style.border = '1px solid #aaa';
|
|
13657
|
+
this.iframe.src = this.url;
|
|
13658
|
+
this.iframe.style.display = 'none';
|
|
13659
|
+
this.iframe.id = 'wazo-softphone';
|
|
13660
|
+
|
|
13661
|
+
// $FlowFixMe
|
|
13662
|
+
document.body.appendChild(this.iframe);
|
|
13663
|
+
}
|
|
13664
|
+
|
|
13665
|
+
_getLinks() {
|
|
13666
|
+
return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
|
|
13667
|
+
.filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
|
|
13668
|
+
}
|
|
13669
|
+
|
|
13670
|
+
_onLinkClick(e ) {
|
|
13671
|
+
e.preventDefault();
|
|
13672
|
+
const number = e.target.href.split(':')[1];
|
|
13673
|
+
|
|
13674
|
+
this.makeCall(number);
|
|
13675
|
+
}
|
|
13676
|
+
|
|
13677
|
+
_onAuthenticated() {
|
|
13678
|
+
this.parseLinks();
|
|
13679
|
+
}
|
|
13680
|
+
|
|
13681
|
+
_onMessage(event ) {
|
|
13682
|
+
if (!event.data) {
|
|
13683
|
+
return;
|
|
13684
|
+
}
|
|
13685
|
+
|
|
13686
|
+
switch (event.data.type) {
|
|
13687
|
+
case SDK_ON_CALL_MADE:
|
|
13688
|
+
this.onCallMade(event.data.callSession);
|
|
13689
|
+
break;
|
|
13690
|
+
case SDK_CALL_ENDED: {
|
|
13691
|
+
const { callSession, content, direction, userExtension } = event.data;
|
|
13692
|
+
this.onCallEnded(callSession, content, direction, userExtension);
|
|
13693
|
+
break;
|
|
13694
|
+
}
|
|
13695
|
+
case SDK_CALL_INCOMING:
|
|
13696
|
+
this.onCallIncoming(event.data.callSession);
|
|
13697
|
+
break;
|
|
13698
|
+
case SDK_AUTHENTICATED:
|
|
13699
|
+
// $FlowFixMe
|
|
13700
|
+
this._onAuthenticated(event.data.session);
|
|
13701
|
+
this.onAuthenticated(event.data.session);
|
|
13702
|
+
break;
|
|
13703
|
+
}
|
|
13704
|
+
}
|
|
13705
|
+
}
|
|
13706
|
+
|
|
13707
|
+
var Softphone$1 = new Softphone();
|
|
13708
|
+
|
|
13562
13709
|
/* global window */
|
|
13563
13710
|
|
|
13564
13711
|
const Wazo = {
|
|
@@ -13579,6 +13726,7 @@ const Wazo = {
|
|
|
13579
13726
|
loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
|
|
13580
13727
|
Features: Features$1,
|
|
13581
13728
|
Checker,
|
|
13729
|
+
Softphone: Softphone$1,
|
|
13582
13730
|
|
|
13583
13731
|
// Domain
|
|
13584
13732
|
domain: {
|