@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.
@@ -13840,6 +13840,153 @@ class Checker {
13840
13840
  }
13841
13841
  }
13842
13842
 
13843
+ //
13844
+ /* eslint-disable no-unused-vars */
13845
+ /* global window, document */
13846
+ const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13847
+ const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13848
+ const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13849
+ const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13850
+ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
13851
+
13852
+ class Softphone {
13853
+ url = 'https://softphone.wazo.io';
13854
+ width = 500;
13855
+ height = 600;
13856
+ displayed = false;
13857
+ iframe = null;
13858
+
13859
+ onLinkEnabled(link ) {}
13860
+
13861
+ onCallMade(call ) {}
13862
+ onCallIncoming(call ) {}
13863
+ onCallEnded(call , card , direction , fromExtension ) {}
13864
+ onAuthenticated(session ) {}
13865
+
13866
+ init(url , width , height ) {
13867
+ if (url) {
13868
+ this.url = url;
13869
+ }
13870
+ if (width) {
13871
+ this.width = width;
13872
+ }
13873
+ if (height) {
13874
+ this.height = height;
13875
+ }
13876
+
13877
+ window.addEventListener('message', this._onMessage.bind(this), false);
13878
+
13879
+ this._createIframe();
13880
+ }
13881
+
13882
+ parseLinks() {
13883
+ const links = this._getLinks();
13884
+
13885
+ links.forEach(link => {
13886
+ link.setAttribute('data-wazo-parsed', true);
13887
+ link.addEventListener('click', this._onLinkClick.bind(this));
13888
+ this.onLinkEnabled(link);
13889
+ });
13890
+ }
13891
+
13892
+ makeCall(number ) {
13893
+ this.displaySoftphone();
13894
+
13895
+ if (this.iframe) {
13896
+ this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
13897
+ }
13898
+ }
13899
+
13900
+ toggleSoftphoneDisplay() {
13901
+ if (this.displayed) {
13902
+ this.hideSoftphone();
13903
+ } else {
13904
+ this.displaySoftphone();
13905
+ }
13906
+
13907
+ this.displayed = !this.displayed;
13908
+ }
13909
+
13910
+ displaySoftphone() {
13911
+ if (!this.iframe) {
13912
+ this._createIframe();
13913
+ }
13914
+
13915
+ if (this.iframe) {
13916
+ this.iframe.style.display = 'block';
13917
+ }
13918
+ }
13919
+
13920
+ hideSoftphone() {
13921
+ if (this.iframe) {
13922
+ this.iframe.style.display = 'none';
13923
+ }
13924
+ }
13925
+
13926
+ _createIframe() {
13927
+ this.iframe = document.createElement('iframe');
13928
+ // $FlowFixMe
13929
+ this.iframe.width = this.width;
13930
+ // $FlowFixMe
13931
+ this.iframe.height = this.height;
13932
+ // $FlowFixMe
13933
+ this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
13934
+ this.iframe.style.position = 'absolute';
13935
+ this.iframe.style.left = '0';
13936
+ this.iframe.style.bottom = '0';
13937
+ this.iframe.style.border = '1px solid #aaa';
13938
+ this.iframe.src = this.url;
13939
+ this.iframe.style.display = 'none';
13940
+ this.iframe.id = 'wazo-softphone';
13941
+
13942
+ // $FlowFixMe
13943
+ document.body.appendChild(this.iframe);
13944
+ }
13945
+
13946
+ _getLinks() {
13947
+ return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
13948
+ .filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
13949
+ }
13950
+
13951
+ _onLinkClick(e ) {
13952
+ e.preventDefault();
13953
+ const number = e.target.href.split(':')[1];
13954
+
13955
+ this.makeCall(number);
13956
+ }
13957
+
13958
+ _onAuthenticated() {
13959
+ this.parseLinks();
13960
+ }
13961
+
13962
+ _onMessage(event ) {
13963
+ if (!event.data) {
13964
+ return;
13965
+ }
13966
+
13967
+ switch (event.data.type) {
13968
+ case SDK_ON_CALL_MADE:
13969
+ this.onCallMade(event.data.callSession);
13970
+ break;
13971
+ case SDK_CALL_ENDED: {
13972
+ const { callSession, content, direction, userExtension } = event.data;
13973
+ this.onCallEnded(callSession, content, direction, userExtension);
13974
+ break;
13975
+ }
13976
+ case SDK_CALL_INCOMING:
13977
+ this.onCallIncoming(event.data.callSession);
13978
+ break;
13979
+ case SDK_AUTHENTICATED:
13980
+ // $FlowFixMe
13981
+ this._onAuthenticated(event.data.session);
13982
+ this.onAuthenticated(event.data.session);
13983
+ break;
13984
+ }
13985
+ }
13986
+ }
13987
+
13988
+ var Softphone$1 = new Softphone();
13989
+
13843
13990
  /* global window */
13844
13991
 
13845
13992
  const Wazo = {
@@ -13860,6 +14007,7 @@ const Wazo = {
13860
14007
  loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
13861
14008
  Features: Features$1,
13862
14009
  Checker,
14010
+ Softphone: Softphone$1,
13863
14011
 
13864
14012
  // Domain
13865
14013
  domain: {
@@ -13921,6 +13921,153 @@ class Checker {
13921
13921
  }
13922
13922
  }
13923
13923
 
13924
+ //
13925
+ /* eslint-disable no-unused-vars */
13926
+ /* global window, document */
13927
+ const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13928
+ const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13929
+ const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13930
+ const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13931
+ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
13932
+
13933
+ class Softphone {
13934
+ url = 'https://softphone.wazo.io';
13935
+ width = 500;
13936
+ height = 600;
13937
+ displayed = false;
13938
+ iframe = null;
13939
+
13940
+ onLinkEnabled(link ) {}
13941
+
13942
+ onCallMade(call ) {}
13943
+ onCallIncoming(call ) {}
13944
+ onCallEnded(call , card , direction , fromExtension ) {}
13945
+ onAuthenticated(session ) {}
13946
+
13947
+ init(url , width , height ) {
13948
+ if (url) {
13949
+ this.url = url;
13950
+ }
13951
+ if (width) {
13952
+ this.width = width;
13953
+ }
13954
+ if (height) {
13955
+ this.height = height;
13956
+ }
13957
+
13958
+ window.addEventListener('message', this._onMessage.bind(this), false);
13959
+
13960
+ this._createIframe();
13961
+ }
13962
+
13963
+ parseLinks() {
13964
+ const links = this._getLinks();
13965
+
13966
+ links.forEach(link => {
13967
+ link.setAttribute('data-wazo-parsed', true);
13968
+ link.addEventListener('click', this._onLinkClick.bind(this));
13969
+ this.onLinkEnabled(link);
13970
+ });
13971
+ }
13972
+
13973
+ makeCall(number ) {
13974
+ this.displaySoftphone();
13975
+
13976
+ if (this.iframe) {
13977
+ this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
13978
+ }
13979
+ }
13980
+
13981
+ toggleSoftphoneDisplay() {
13982
+ if (this.displayed) {
13983
+ this.hideSoftphone();
13984
+ } else {
13985
+ this.displaySoftphone();
13986
+ }
13987
+
13988
+ this.displayed = !this.displayed;
13989
+ }
13990
+
13991
+ displaySoftphone() {
13992
+ if (!this.iframe) {
13993
+ this._createIframe();
13994
+ }
13995
+
13996
+ if (this.iframe) {
13997
+ this.iframe.style.display = 'block';
13998
+ }
13999
+ }
14000
+
14001
+ hideSoftphone() {
14002
+ if (this.iframe) {
14003
+ this.iframe.style.display = 'none';
14004
+ }
14005
+ }
14006
+
14007
+ _createIframe() {
14008
+ this.iframe = document.createElement('iframe');
14009
+ // $FlowFixMe
14010
+ this.iframe.width = this.width;
14011
+ // $FlowFixMe
14012
+ this.iframe.height = this.height;
14013
+ // $FlowFixMe
14014
+ this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
14015
+ this.iframe.style.position = 'absolute';
14016
+ this.iframe.style.left = '0';
14017
+ this.iframe.style.bottom = '0';
14018
+ this.iframe.style.border = '1px solid #aaa';
14019
+ this.iframe.src = this.url;
14020
+ this.iframe.style.display = 'none';
14021
+ this.iframe.id = 'wazo-softphone';
14022
+
14023
+ // $FlowFixMe
14024
+ document.body.appendChild(this.iframe);
14025
+ }
14026
+
14027
+ _getLinks() {
14028
+ return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
14029
+ .filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
14030
+ }
14031
+
14032
+ _onLinkClick(e ) {
14033
+ e.preventDefault();
14034
+ const number = e.target.href.split(':')[1];
14035
+
14036
+ this.makeCall(number);
14037
+ }
14038
+
14039
+ _onAuthenticated() {
14040
+ this.parseLinks();
14041
+ }
14042
+
14043
+ _onMessage(event ) {
14044
+ if (!event.data) {
14045
+ return;
14046
+ }
14047
+
14048
+ switch (event.data.type) {
14049
+ case SDK_ON_CALL_MADE:
14050
+ this.onCallMade(event.data.callSession);
14051
+ break;
14052
+ case SDK_CALL_ENDED: {
14053
+ const { callSession, content, direction, userExtension } = event.data;
14054
+ this.onCallEnded(callSession, content, direction, userExtension);
14055
+ break;
14056
+ }
14057
+ case SDK_CALL_INCOMING:
14058
+ this.onCallIncoming(event.data.callSession);
14059
+ break;
14060
+ case SDK_AUTHENTICATED:
14061
+ // $FlowFixMe
14062
+ this._onAuthenticated(event.data.session);
14063
+ this.onAuthenticated(event.data.session);
14064
+ break;
14065
+ }
14066
+ }
14067
+ }
14068
+
14069
+ var Softphone$1 = new Softphone();
14070
+
13924
14071
  /* global window */
13925
14072
 
13926
14073
  const Wazo = {
@@ -13941,6 +14088,7 @@ const Wazo = {
13941
14088
  loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
13942
14089
  Features: Features$1,
13943
14090
  Checker,
14091
+ Softphone: Softphone$1,
13944
14092
 
13945
14093
  // Domain
13946
14094
  domain: {
@@ -13979,6 +13979,153 @@ class Checker {
13979
13979
  }
13980
13980
  }
13981
13981
 
13982
+ //
13983
+ /* eslint-disable no-unused-vars */
13984
+ /* global window, document */
13985
+ const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13986
+ const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13987
+ const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13988
+ const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13989
+ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
13990
+
13991
+ class Softphone {
13992
+ url = 'https://softphone.wazo.io';
13993
+ width = 500;
13994
+ height = 600;
13995
+ displayed = false;
13996
+ iframe = null;
13997
+
13998
+ onLinkEnabled(link ) {}
13999
+
14000
+ onCallMade(call ) {}
14001
+ onCallIncoming(call ) {}
14002
+ onCallEnded(call , card , direction , fromExtension ) {}
14003
+ onAuthenticated(session ) {}
14004
+
14005
+ init(url , width , height ) {
14006
+ if (url) {
14007
+ this.url = url;
14008
+ }
14009
+ if (width) {
14010
+ this.width = width;
14011
+ }
14012
+ if (height) {
14013
+ this.height = height;
14014
+ }
14015
+
14016
+ window.addEventListener('message', this._onMessage.bind(this), false);
14017
+
14018
+ this._createIframe();
14019
+ }
14020
+
14021
+ parseLinks() {
14022
+ const links = this._getLinks();
14023
+
14024
+ links.forEach(link => {
14025
+ link.setAttribute('data-wazo-parsed', true);
14026
+ link.addEventListener('click', this._onLinkClick.bind(this));
14027
+ this.onLinkEnabled(link);
14028
+ });
14029
+ }
14030
+
14031
+ makeCall(number ) {
14032
+ this.displaySoftphone();
14033
+
14034
+ if (this.iframe) {
14035
+ this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
14036
+ }
14037
+ }
14038
+
14039
+ toggleSoftphoneDisplay() {
14040
+ if (this.displayed) {
14041
+ this.hideSoftphone();
14042
+ } else {
14043
+ this.displaySoftphone();
14044
+ }
14045
+
14046
+ this.displayed = !this.displayed;
14047
+ }
14048
+
14049
+ displaySoftphone() {
14050
+ if (!this.iframe) {
14051
+ this._createIframe();
14052
+ }
14053
+
14054
+ if (this.iframe) {
14055
+ this.iframe.style.display = 'block';
14056
+ }
14057
+ }
14058
+
14059
+ hideSoftphone() {
14060
+ if (this.iframe) {
14061
+ this.iframe.style.display = 'none';
14062
+ }
14063
+ }
14064
+
14065
+ _createIframe() {
14066
+ this.iframe = document.createElement('iframe');
14067
+ // $FlowFixMe
14068
+ this.iframe.width = this.width;
14069
+ // $FlowFixMe
14070
+ this.iframe.height = this.height;
14071
+ // $FlowFixMe
14072
+ this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
14073
+ this.iframe.style.position = 'absolute';
14074
+ this.iframe.style.left = '0';
14075
+ this.iframe.style.bottom = '0';
14076
+ this.iframe.style.border = '1px solid #aaa';
14077
+ this.iframe.src = this.url;
14078
+ this.iframe.style.display = 'none';
14079
+ this.iframe.id = 'wazo-softphone';
14080
+
14081
+ // $FlowFixMe
14082
+ document.body.appendChild(this.iframe);
14083
+ }
14084
+
14085
+ _getLinks() {
14086
+ return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
14087
+ .filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
14088
+ }
14089
+
14090
+ _onLinkClick(e ) {
14091
+ e.preventDefault();
14092
+ const number = e.target.href.split(':')[1];
14093
+
14094
+ this.makeCall(number);
14095
+ }
14096
+
14097
+ _onAuthenticated() {
14098
+ this.parseLinks();
14099
+ }
14100
+
14101
+ _onMessage(event ) {
14102
+ if (!event.data) {
14103
+ return;
14104
+ }
14105
+
14106
+ switch (event.data.type) {
14107
+ case SDK_ON_CALL_MADE:
14108
+ this.onCallMade(event.data.callSession);
14109
+ break;
14110
+ case SDK_CALL_ENDED: {
14111
+ const { callSession, content, direction, userExtension } = event.data;
14112
+ this.onCallEnded(callSession, content, direction, userExtension);
14113
+ break;
14114
+ }
14115
+ case SDK_CALL_INCOMING:
14116
+ this.onCallIncoming(event.data.callSession);
14117
+ break;
14118
+ case SDK_AUTHENTICATED:
14119
+ // $FlowFixMe
14120
+ this._onAuthenticated(event.data.session);
14121
+ this.onAuthenticated(event.data.session);
14122
+ break;
14123
+ }
14124
+ }
14125
+ }
14126
+
14127
+ var Softphone$1 = new Softphone();
14128
+
13982
14129
  /* global window */
13983
14130
 
13984
14131
  const Wazo = {
@@ -13999,6 +14146,7 @@ const Wazo = {
13999
14146
  loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
14000
14147
  Features: Features$1,
14001
14148
  Checker,
14149
+ Softphone: Softphone$1,
14002
14150
 
14003
14151
  // Domain
14004
14152
  domain: {
@@ -13965,6 +13965,153 @@ class Checker {
13965
13965
  }
13966
13966
  }
13967
13967
 
13968
+ //
13969
+ /* eslint-disable no-unused-vars */
13970
+ /* global window, document */
13971
+ const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13972
+ const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13973
+ const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13974
+ const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13975
+ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
13976
+
13977
+ class Softphone {
13978
+ url = 'https://softphone.wazo.io';
13979
+ width = 500;
13980
+ height = 600;
13981
+ displayed = false;
13982
+ iframe = null;
13983
+
13984
+ onLinkEnabled(link ) {}
13985
+
13986
+ onCallMade(call ) {}
13987
+ onCallIncoming(call ) {}
13988
+ onCallEnded(call , card , direction , fromExtension ) {}
13989
+ onAuthenticated(session ) {}
13990
+
13991
+ init(url , width , height ) {
13992
+ if (url) {
13993
+ this.url = url;
13994
+ }
13995
+ if (width) {
13996
+ this.width = width;
13997
+ }
13998
+ if (height) {
13999
+ this.height = height;
14000
+ }
14001
+
14002
+ window.addEventListener('message', this._onMessage.bind(this), false);
14003
+
14004
+ this._createIframe();
14005
+ }
14006
+
14007
+ parseLinks() {
14008
+ const links = this._getLinks();
14009
+
14010
+ links.forEach(link => {
14011
+ link.setAttribute('data-wazo-parsed', true);
14012
+ link.addEventListener('click', this._onLinkClick.bind(this));
14013
+ this.onLinkEnabled(link);
14014
+ });
14015
+ }
14016
+
14017
+ makeCall(number ) {
14018
+ this.displaySoftphone();
14019
+
14020
+ if (this.iframe) {
14021
+ this.iframe.contentWindow.postMessage({ type: SDK_CLICK_TO_CALL, number }, '*');
14022
+ }
14023
+ }
14024
+
14025
+ toggleSoftphoneDisplay() {
14026
+ if (this.displayed) {
14027
+ this.hideSoftphone();
14028
+ } else {
14029
+ this.displaySoftphone();
14030
+ }
14031
+
14032
+ this.displayed = !this.displayed;
14033
+ }
14034
+
14035
+ displaySoftphone() {
14036
+ if (!this.iframe) {
14037
+ this._createIframe();
14038
+ }
14039
+
14040
+ if (this.iframe) {
14041
+ this.iframe.style.display = 'block';
14042
+ }
14043
+ }
14044
+
14045
+ hideSoftphone() {
14046
+ if (this.iframe) {
14047
+ this.iframe.style.display = 'none';
14048
+ }
14049
+ }
14050
+
14051
+ _createIframe() {
14052
+ this.iframe = document.createElement('iframe');
14053
+ // $FlowFixMe
14054
+ this.iframe.width = this.width;
14055
+ // $FlowFixMe
14056
+ this.iframe.height = this.height;
14057
+ // $FlowFixMe
14058
+ this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
14059
+ this.iframe.style.position = 'absolute';
14060
+ this.iframe.style.left = '0';
14061
+ this.iframe.style.bottom = '0';
14062
+ this.iframe.style.border = '1px solid #aaa';
14063
+ this.iframe.src = this.url;
14064
+ this.iframe.style.display = 'none';
14065
+ this.iframe.id = 'wazo-softphone';
14066
+
14067
+ // $FlowFixMe
14068
+ document.body.appendChild(this.iframe);
14069
+ }
14070
+
14071
+ _getLinks() {
14072
+ return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
14073
+ .filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
14074
+ }
14075
+
14076
+ _onLinkClick(e ) {
14077
+ e.preventDefault();
14078
+ const number = e.target.href.split(':')[1];
14079
+
14080
+ this.makeCall(number);
14081
+ }
14082
+
14083
+ _onAuthenticated() {
14084
+ this.parseLinks();
14085
+ }
14086
+
14087
+ _onMessage(event ) {
14088
+ if (!event.data) {
14089
+ return;
14090
+ }
14091
+
14092
+ switch (event.data.type) {
14093
+ case SDK_ON_CALL_MADE:
14094
+ this.onCallMade(event.data.callSession);
14095
+ break;
14096
+ case SDK_CALL_ENDED: {
14097
+ const { callSession, content, direction, userExtension } = event.data;
14098
+ this.onCallEnded(callSession, content, direction, userExtension);
14099
+ break;
14100
+ }
14101
+ case SDK_CALL_INCOMING:
14102
+ this.onCallIncoming(event.data.callSession);
14103
+ break;
14104
+ case SDK_AUTHENTICATED:
14105
+ // $FlowFixMe
14106
+ this._onAuthenticated(event.data.session);
14107
+ this.onAuthenticated(event.data.session);
14108
+ break;
14109
+ }
14110
+ }
14111
+ }
14112
+
14113
+ var Softphone$1 = new Softphone();
14114
+
13968
14115
  /* global window */
13969
14116
 
13970
14117
  const Wazo = {
@@ -13985,6 +14132,7 @@ const Wazo = {
13985
14132
  loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
13986
14133
  Features: Features$1,
13987
14134
  Checker,
14135
+ Softphone: Softphone$1,
13988
14136
 
13989
14137
  // Domain
13990
14138
  domain: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wazo/sdk",
3
- "version": "0.37.43",
3
+ "version": "0.38.0",
4
4
  "description": "Wazo's JavaScript Software Development Kit.",
5
5
  "main": "dist/wazo-sdk.js",
6
6
  "author": "Wazo (http://wazo.io)",