@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.
@@ -0,0 +1,148 @@
1
+ //
2
+ /* eslint-disable no-unused-vars */
3
+ /* global window, document */
4
+ const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
5
+ const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
6
+ const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
7
+ const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
8
+ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
9
+
10
+ class Softphone {
11
+ url = 'https://softphone.wazo.io';
12
+ width = 500;
13
+ height = 600;
14
+ displayed = false;
15
+ iframe = null;
16
+
17
+ onLinkEnabled(link ) {}
18
+
19
+ onCallMade(call ) {}
20
+ onCallIncoming(call ) {}
21
+ onCallEnded(call , card , direction , fromExtension ) {}
22
+ onAuthenticated(session ) {}
23
+
24
+ init(url , width , height ) {
25
+ if (url) {
26
+ this.url = url;
27
+ }
28
+ if (width) {
29
+ this.width = width;
30
+ }
31
+ if (height) {
32
+ this.height = height;
33
+ }
34
+
35
+ window.addEventListener('message', this._onMessage.bind(this), false);
36
+
37
+ this._createIframe();
38
+ }
39
+
40
+ parseLinks() {
41
+ const links = this._getLinks();
42
+
43
+ links.forEach(link => {
44
+ link.setAttribute('data-wazo-parsed', true);
45
+ link.addEventListener('click', this._onLinkClick.bind(this));
46
+ this.onLinkEnabled(link);
47
+ });
48
+ }
49
+
50
+ makeCall(number ) {
51
+ this.displaySoftphone();
52
+
53
+ if (this.iframe) {
54
+ this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
55
+ }
56
+ }
57
+
58
+ toggleSoftphoneDisplay() {
59
+ if (this.displayed) {
60
+ this.hideSoftphone();
61
+ } else {
62
+ this.displaySoftphone();
63
+ }
64
+
65
+ this.displayed = !this.displayed;
66
+ }
67
+
68
+ displaySoftphone() {
69
+ if (!this.iframe) {
70
+ this._createIframe();
71
+ }
72
+
73
+ if (this.iframe) {
74
+ this.iframe.style.display = 'block';
75
+ }
76
+ }
77
+
78
+ hideSoftphone() {
79
+ if (this.iframe) {
80
+ this.iframe.style.display = 'none';
81
+ }
82
+ }
83
+
84
+ _createIframe() {
85
+ this.iframe = document.createElement('iframe');
86
+ // $FlowFixMe
87
+ this.iframe.width = this.width;
88
+ // $FlowFixMe
89
+ this.iframe.height = this.height;
90
+ // $FlowFixMe
91
+ this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
92
+ this.iframe.style.position = 'absolute';
93
+ this.iframe.style.left = '0';
94
+ this.iframe.style.bottom = '0';
95
+ this.iframe.style.border = '1px solid #aaa';
96
+ this.iframe.src = this.url;
97
+ this.iframe.style.display = 'none';
98
+ this.iframe.id = 'wazo-softphone';
99
+
100
+ // $FlowFixMe
101
+ document.body.appendChild(this.iframe);
102
+ }
103
+
104
+ _getLinks() {
105
+ return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
106
+ .filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
107
+ }
108
+
109
+ _onLinkClick(e ) {
110
+ e.preventDefault();
111
+ const number = e.target.href.split(':')[1];
112
+
113
+ this.makeCall(number);
114
+ }
115
+
116
+ _onAuthenticated() {
117
+ this.parseLinks();
118
+ }
119
+
120
+ _onMessage(event ) {
121
+ if (!event.data) {
122
+ return;
123
+ }
124
+
125
+ switch (event.data.type) {
126
+ case SDK_ON_CALL_MADE:
127
+ this.onCallMade(event.data.callSession);
128
+ break;
129
+ case SDK_CALL_ENDED: {
130
+ const { callSession, content, direction, userExtension } = event.data;
131
+ this.onCallEnded(callSession, content, direction, userExtension);
132
+ break;
133
+ }
134
+ case SDK_CALL_INCOMING:
135
+ this.onCallIncoming(event.data.callSession);
136
+ break;
137
+ case SDK_AUTHENTICATED:
138
+ // $FlowFixMe
139
+ this._onAuthenticated(event.data.session);
140
+ this.onAuthenticated(event.data.session);
141
+ break;
142
+ }
143
+ }
144
+ }
145
+
146
+ var Softphone$1 = new Softphone();
147
+
148
+ export default Softphone$1;
@@ -13969,6 +13969,153 @@ class Checker {
13969
13969
  }
13970
13970
  }
13971
13971
 
13972
+ //
13973
+ /* eslint-disable no-unused-vars */
13974
+ /* global window, document */
13975
+ const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13976
+ const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13977
+ const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13978
+ const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13979
+ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
13980
+
13981
+ class Softphone {
13982
+ url = 'https://softphone.wazo.io';
13983
+ width = 500;
13984
+ height = 600;
13985
+ displayed = false;
13986
+ iframe = null;
13987
+
13988
+ onLinkEnabled(link ) {}
13989
+
13990
+ onCallMade(call ) {}
13991
+ onCallIncoming(call ) {}
13992
+ onCallEnded(call , card , direction , fromExtension ) {}
13993
+ onAuthenticated(session ) {}
13994
+
13995
+ init(url , width , height ) {
13996
+ if (url) {
13997
+ this.url = url;
13998
+ }
13999
+ if (width) {
14000
+ this.width = width;
14001
+ }
14002
+ if (height) {
14003
+ this.height = height;
14004
+ }
14005
+
14006
+ window.addEventListener('message', this._onMessage.bind(this), false);
14007
+
14008
+ this._createIframe();
14009
+ }
14010
+
14011
+ parseLinks() {
14012
+ const links = this._getLinks();
14013
+
14014
+ links.forEach(link => {
14015
+ link.setAttribute('data-wazo-parsed', true);
14016
+ link.addEventListener('click', this._onLinkClick.bind(this));
14017
+ this.onLinkEnabled(link);
14018
+ });
14019
+ }
14020
+
14021
+ makeCall(number ) {
14022
+ this.displaySoftphone();
14023
+
14024
+ if (this.iframe) {
14025
+ this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
14026
+ }
14027
+ }
14028
+
14029
+ toggleSoftphoneDisplay() {
14030
+ if (this.displayed) {
14031
+ this.hideSoftphone();
14032
+ } else {
14033
+ this.displaySoftphone();
14034
+ }
14035
+
14036
+ this.displayed = !this.displayed;
14037
+ }
14038
+
14039
+ displaySoftphone() {
14040
+ if (!this.iframe) {
14041
+ this._createIframe();
14042
+ }
14043
+
14044
+ if (this.iframe) {
14045
+ this.iframe.style.display = 'block';
14046
+ }
14047
+ }
14048
+
14049
+ hideSoftphone() {
14050
+ if (this.iframe) {
14051
+ this.iframe.style.display = 'none';
14052
+ }
14053
+ }
14054
+
14055
+ _createIframe() {
14056
+ this.iframe = document.createElement('iframe');
14057
+ // $FlowFixMe
14058
+ this.iframe.width = this.width;
14059
+ // $FlowFixMe
14060
+ this.iframe.height = this.height;
14061
+ // $FlowFixMe
14062
+ this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
14063
+ this.iframe.style.position = 'absolute';
14064
+ this.iframe.style.left = '0';
14065
+ this.iframe.style.bottom = '0';
14066
+ this.iframe.style.border = '1px solid #aaa';
14067
+ this.iframe.src = this.url;
14068
+ this.iframe.style.display = 'none';
14069
+ this.iframe.id = 'wazo-softphone';
14070
+
14071
+ // $FlowFixMe
14072
+ document.body.appendChild(this.iframe);
14073
+ }
14074
+
14075
+ _getLinks() {
14076
+ return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
14077
+ .filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
14078
+ }
14079
+
14080
+ _onLinkClick(e ) {
14081
+ e.preventDefault();
14082
+ const number = e.target.href.split(':')[1];
14083
+
14084
+ this.makeCall(number);
14085
+ }
14086
+
14087
+ _onAuthenticated() {
14088
+ this.parseLinks();
14089
+ }
14090
+
14091
+ _onMessage(event ) {
14092
+ if (!event.data) {
14093
+ return;
14094
+ }
14095
+
14096
+ switch (event.data.type) {
14097
+ case SDK_ON_CALL_MADE:
14098
+ this.onCallMade(event.data.callSession);
14099
+ break;
14100
+ case SDK_CALL_ENDED: {
14101
+ const { callSession, content, direction, userExtension } = event.data;
14102
+ this.onCallEnded(callSession, content, direction, userExtension);
14103
+ break;
14104
+ }
14105
+ case SDK_CALL_INCOMING:
14106
+ this.onCallIncoming(event.data.callSession);
14107
+ break;
14108
+ case SDK_AUTHENTICATED:
14109
+ // $FlowFixMe
14110
+ this._onAuthenticated(event.data.session);
14111
+ this.onAuthenticated(event.data.session);
14112
+ break;
14113
+ }
14114
+ }
14115
+ }
14116
+
14117
+ var Softphone$1 = new Softphone();
14118
+
13972
14119
  /* global window */
13973
14120
 
13974
14121
  const Wazo = {
@@ -13989,6 +14136,7 @@ const Wazo = {
13989
14136
  loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
13990
14137
  Features: Features$1,
13991
14138
  Checker,
14139
+ Softphone: Softphone$1,
13992
14140
 
13993
14141
  // Domain
13994
14142
  domain: {
@@ -12838,6 +12838,153 @@ class Checker {
12838
12838
  }
12839
12839
  }
12840
12840
 
12841
+ //
12842
+ /* eslint-disable no-unused-vars */
12843
+ /* global window, document */
12844
+ const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
12845
+ const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
12846
+ const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
12847
+ const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
12848
+ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
12849
+
12850
+ class Softphone {
12851
+ url = 'https://softphone.wazo.io';
12852
+ width = 500;
12853
+ height = 600;
12854
+ displayed = false;
12855
+ iframe = null;
12856
+
12857
+ onLinkEnabled(link ) {}
12858
+
12859
+ onCallMade(call ) {}
12860
+ onCallIncoming(call ) {}
12861
+ onCallEnded(call , card , direction , fromExtension ) {}
12862
+ onAuthenticated(session ) {}
12863
+
12864
+ init(url , width , height ) {
12865
+ if (url) {
12866
+ this.url = url;
12867
+ }
12868
+ if (width) {
12869
+ this.width = width;
12870
+ }
12871
+ if (height) {
12872
+ this.height = height;
12873
+ }
12874
+
12875
+ window.addEventListener('message', this._onMessage.bind(this), false);
12876
+
12877
+ this._createIframe();
12878
+ }
12879
+
12880
+ parseLinks() {
12881
+ const links = this._getLinks();
12882
+
12883
+ links.forEach(link => {
12884
+ link.setAttribute('data-wazo-parsed', true);
12885
+ link.addEventListener('click', this._onLinkClick.bind(this));
12886
+ this.onLinkEnabled(link);
12887
+ });
12888
+ }
12889
+
12890
+ makeCall(number ) {
12891
+ this.displaySoftphone();
12892
+
12893
+ if (this.iframe) {
12894
+ this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
12895
+ }
12896
+ }
12897
+
12898
+ toggleSoftphoneDisplay() {
12899
+ if (this.displayed) {
12900
+ this.hideSoftphone();
12901
+ } else {
12902
+ this.displaySoftphone();
12903
+ }
12904
+
12905
+ this.displayed = !this.displayed;
12906
+ }
12907
+
12908
+ displaySoftphone() {
12909
+ if (!this.iframe) {
12910
+ this._createIframe();
12911
+ }
12912
+
12913
+ if (this.iframe) {
12914
+ this.iframe.style.display = 'block';
12915
+ }
12916
+ }
12917
+
12918
+ hideSoftphone() {
12919
+ if (this.iframe) {
12920
+ this.iframe.style.display = 'none';
12921
+ }
12922
+ }
12923
+
12924
+ _createIframe() {
12925
+ this.iframe = document.createElement('iframe');
12926
+ // $FlowFixMe
12927
+ this.iframe.width = this.width;
12928
+ // $FlowFixMe
12929
+ this.iframe.height = this.height;
12930
+ // $FlowFixMe
12931
+ this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
12932
+ this.iframe.style.position = 'absolute';
12933
+ this.iframe.style.left = '0';
12934
+ this.iframe.style.bottom = '0';
12935
+ this.iframe.style.border = '1px solid #aaa';
12936
+ this.iframe.src = this.url;
12937
+ this.iframe.style.display = 'none';
12938
+ this.iframe.id = 'wazo-softphone';
12939
+
12940
+ // $FlowFixMe
12941
+ document.body.appendChild(this.iframe);
12942
+ }
12943
+
12944
+ _getLinks() {
12945
+ return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
12946
+ .filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
12947
+ }
12948
+
12949
+ _onLinkClick(e ) {
12950
+ e.preventDefault();
12951
+ const number = e.target.href.split(':')[1];
12952
+
12953
+ this.makeCall(number);
12954
+ }
12955
+
12956
+ _onAuthenticated() {
12957
+ this.parseLinks();
12958
+ }
12959
+
12960
+ _onMessage(event ) {
12961
+ if (!event.data) {
12962
+ return;
12963
+ }
12964
+
12965
+ switch (event.data.type) {
12966
+ case SDK_ON_CALL_MADE:
12967
+ this.onCallMade(event.data.callSession);
12968
+ break;
12969
+ case SDK_CALL_ENDED: {
12970
+ const { callSession, content, direction, userExtension } = event.data;
12971
+ this.onCallEnded(callSession, content, direction, userExtension);
12972
+ break;
12973
+ }
12974
+ case SDK_CALL_INCOMING:
12975
+ this.onCallIncoming(event.data.callSession);
12976
+ break;
12977
+ case SDK_AUTHENTICATED:
12978
+ // $FlowFixMe
12979
+ this._onAuthenticated(event.data.session);
12980
+ this.onAuthenticated(event.data.session);
12981
+ break;
12982
+ }
12983
+ }
12984
+ }
12985
+
12986
+ var Softphone$1 = new Softphone();
12987
+
12841
12988
  /* global window */
12842
12989
 
12843
12990
  const Wazo = {
@@ -12858,6 +13005,7 @@ const Wazo = {
12858
13005
  loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
12859
13006
  Features: Features$1,
12860
13007
  Checker,
13008
+ Softphone: Softphone$1,
12861
13009
 
12862
13010
  // Domain
12863
13011
  domain: {
@@ -12843,6 +12843,153 @@ class Checker {
12843
12843
  }
12844
12844
  }
12845
12845
 
12846
+ //
12847
+ /* eslint-disable no-unused-vars */
12848
+ /* global window, document */
12849
+ const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
12850
+ const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
12851
+ const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
12852
+ const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
12853
+ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
12854
+
12855
+ class Softphone {
12856
+ url = 'https://softphone.wazo.io';
12857
+ width = 500;
12858
+ height = 600;
12859
+ displayed = false;
12860
+ iframe = null;
12861
+
12862
+ onLinkEnabled(link ) {}
12863
+
12864
+ onCallMade(call ) {}
12865
+ onCallIncoming(call ) {}
12866
+ onCallEnded(call , card , direction , fromExtension ) {}
12867
+ onAuthenticated(session ) {}
12868
+
12869
+ init(url , width , height ) {
12870
+ if (url) {
12871
+ this.url = url;
12872
+ }
12873
+ if (width) {
12874
+ this.width = width;
12875
+ }
12876
+ if (height) {
12877
+ this.height = height;
12878
+ }
12879
+
12880
+ window.addEventListener('message', this._onMessage.bind(this), false);
12881
+
12882
+ this._createIframe();
12883
+ }
12884
+
12885
+ parseLinks() {
12886
+ const links = this._getLinks();
12887
+
12888
+ links.forEach(link => {
12889
+ link.setAttribute('data-wazo-parsed', true);
12890
+ link.addEventListener('click', this._onLinkClick.bind(this));
12891
+ this.onLinkEnabled(link);
12892
+ });
12893
+ }
12894
+
12895
+ makeCall(number ) {
12896
+ this.displaySoftphone();
12897
+
12898
+ if (this.iframe) {
12899
+ this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
12900
+ }
12901
+ }
12902
+
12903
+ toggleSoftphoneDisplay() {
12904
+ if (this.displayed) {
12905
+ this.hideSoftphone();
12906
+ } else {
12907
+ this.displaySoftphone();
12908
+ }
12909
+
12910
+ this.displayed = !this.displayed;
12911
+ }
12912
+
12913
+ displaySoftphone() {
12914
+ if (!this.iframe) {
12915
+ this._createIframe();
12916
+ }
12917
+
12918
+ if (this.iframe) {
12919
+ this.iframe.style.display = 'block';
12920
+ }
12921
+ }
12922
+
12923
+ hideSoftphone() {
12924
+ if (this.iframe) {
12925
+ this.iframe.style.display = 'none';
12926
+ }
12927
+ }
12928
+
12929
+ _createIframe() {
12930
+ this.iframe = document.createElement('iframe');
12931
+ // $FlowFixMe
12932
+ this.iframe.width = this.width;
12933
+ // $FlowFixMe
12934
+ this.iframe.height = this.height;
12935
+ // $FlowFixMe
12936
+ this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
12937
+ this.iframe.style.position = 'absolute';
12938
+ this.iframe.style.left = '0';
12939
+ this.iframe.style.bottom = '0';
12940
+ this.iframe.style.border = '1px solid #aaa';
12941
+ this.iframe.src = this.url;
12942
+ this.iframe.style.display = 'none';
12943
+ this.iframe.id = 'wazo-softphone';
12944
+
12945
+ // $FlowFixMe
12946
+ document.body.appendChild(this.iframe);
12947
+ }
12948
+
12949
+ _getLinks() {
12950
+ return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
12951
+ .filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
12952
+ }
12953
+
12954
+ _onLinkClick(e ) {
12955
+ e.preventDefault();
12956
+ const number = e.target.href.split(':')[1];
12957
+
12958
+ this.makeCall(number);
12959
+ }
12960
+
12961
+ _onAuthenticated() {
12962
+ this.parseLinks();
12963
+ }
12964
+
12965
+ _onMessage(event ) {
12966
+ if (!event.data) {
12967
+ return;
12968
+ }
12969
+
12970
+ switch (event.data.type) {
12971
+ case SDK_ON_CALL_MADE:
12972
+ this.onCallMade(event.data.callSession);
12973
+ break;
12974
+ case SDK_CALL_ENDED: {
12975
+ const { callSession, content, direction, userExtension } = event.data;
12976
+ this.onCallEnded(callSession, content, direction, userExtension);
12977
+ break;
12978
+ }
12979
+ case SDK_CALL_INCOMING:
12980
+ this.onCallIncoming(event.data.callSession);
12981
+ break;
12982
+ case SDK_AUTHENTICATED:
12983
+ // $FlowFixMe
12984
+ this._onAuthenticated(event.data.session);
12985
+ this.onAuthenticated(event.data.session);
12986
+ break;
12987
+ }
12988
+ }
12989
+ }
12990
+
12991
+ var Softphone$1 = new Softphone();
12992
+
12846
12993
  /* global window */
12847
12994
 
12848
12995
  const Wazo = {
@@ -12863,6 +13010,7 @@ const Wazo = {
12863
13010
  loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
12864
13011
  Features: Features$1,
12865
13012
  Checker,
13013
+ Softphone: Softphone$1,
12866
13014
 
12867
13015
  // Domain
12868
13016
  domain: {