@wazo/sdk 0.38.1 → 0.38.2
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/README.md +31 -3
- package/dist/wazo-sdk.js +1 -1
- package/esm/index.js +69 -38
- package/esm/simple/Auth.js +69 -38
- package/esm/simple/Configuration.js +69 -38
- package/esm/simple/Phone.js +69 -38
- package/esm/simple/Softphone.js +70 -39
- package/esm/simple/index.js +69 -38
- package/esm/simple/room/LocalParticipant.js +69 -38
- package/esm/simple/room/Participant.js +69 -38
- package/esm/simple/room/RemoteParticipant.js +69 -38
- package/esm/simple/room/Room.js +69 -38
- package/esm/simple/room/SipRoom.js +69 -38
- package/esm/simple/room/Stream.js +69 -38
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +69 -38
- package/esm/simple/utils.js +69 -38
- package/lib/index.js +69 -38
- package/lib/simple/Auth.js +69 -38
- package/lib/simple/Configuration.js +69 -38
- package/lib/simple/Phone.js +69 -38
- package/lib/simple/Softphone.js +70 -39
- package/lib/simple/index.js +69 -38
- package/lib/simple/room/LocalParticipant.js +69 -38
- package/lib/simple/room/Participant.js +69 -38
- package/lib/simple/room/RemoteParticipant.js +69 -38
- package/lib/simple/room/Room.js +69 -38
- package/lib/simple/room/SipRoom.js +69 -38
- package/lib/simple/room/Stream.js +69 -38
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +69 -38
- package/lib/simple/utils.js +69 -38
- package/package.json +1 -1
- package/src/simple/Softphone.js +70 -39
|
@@ -13973,8 +13973,6 @@ class Checker {
|
|
|
13973
13973
|
/* eslint-disable no-unused-vars */
|
|
13974
13974
|
/* global window, document */
|
|
13975
13975
|
const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
|
|
13976
|
-
const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
|
|
13977
|
-
const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
|
|
13978
13976
|
const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
|
|
13979
13977
|
const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
|
|
13980
13978
|
const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
|
|
@@ -13987,6 +13985,7 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
|
|
|
13987
13985
|
const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
|
|
13988
13986
|
const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
|
|
13989
13987
|
const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
|
|
13988
|
+
const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
|
|
13990
13989
|
const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
|
|
13991
13990
|
const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
|
|
13992
13991
|
const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
|
|
@@ -14000,6 +13999,12 @@ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFE
|
|
|
14000
13999
|
const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
|
|
14001
14000
|
const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
|
|
14002
14001
|
const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
|
|
14002
|
+
const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
|
|
14003
|
+
const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
|
|
14004
|
+
const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
|
|
14005
|
+
|
|
14006
|
+
const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
|
|
14007
|
+
const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
|
|
14003
14008
|
|
|
14004
14009
|
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
14005
14010
|
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
@@ -14009,22 +14014,32 @@ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
|
14009
14014
|
const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
|
|
14010
14015
|
|
|
14011
14016
|
class Softphone {
|
|
14012
|
-
|
|
14013
|
-
|
|
14014
|
-
|
|
14015
|
-
|
|
14016
|
-
|
|
14017
|
+
|
|
14018
|
+
|
|
14019
|
+
|
|
14020
|
+
|
|
14021
|
+
|
|
14022
|
+
|
|
14023
|
+
|
|
14024
|
+
// Message waiting for the iframe to be loaded
|
|
14025
|
+
|
|
14017
14026
|
|
|
14018
14027
|
onLinkEnabled(link ) {}
|
|
14019
14028
|
onIFrameLoaded() {}
|
|
14020
14029
|
|
|
14030
|
+
onCallAnswered() {}
|
|
14021
14031
|
onCallMade(call ) {}
|
|
14022
14032
|
onCallIncoming(call ) {}
|
|
14023
14033
|
onCallEnded(call , card , direction , fromExtension ) {}
|
|
14024
14034
|
onCardSaved(card ) {}
|
|
14035
|
+
onCardCanceled() {}
|
|
14025
14036
|
onAuthenticated(session ) {}
|
|
14026
14037
|
onLoggedOut() {}
|
|
14027
|
-
|
|
14038
|
+
|
|
14039
|
+
onSearchOptions(fieldId , query ) {
|
|
14040
|
+
this.onOptionsResults(fieldId, []);
|
|
14041
|
+
}
|
|
14042
|
+
|
|
14028
14043
|
onDisplayLinkedOption(optionId ) {}
|
|
14029
14044
|
onWazoContactSearch(query ) {}
|
|
14030
14045
|
onAgentLoggedIn() {}
|
|
@@ -14047,18 +14062,15 @@ class Softphone {
|
|
|
14047
14062
|
onStopRecording() {}
|
|
14048
14063
|
onUnHandledEvent(event ) {}
|
|
14049
14064
|
|
|
14050
|
-
init({ url, width, height, server, port, language, wrapUpDuration,
|
|
14051
|
-
|
|
14052
|
-
|
|
14053
|
-
|
|
14054
|
-
|
|
14055
|
-
|
|
14056
|
-
this.width = width;
|
|
14057
|
-
}
|
|
14058
|
-
if (height) {
|
|
14059
|
-
this.height = height;
|
|
14060
|
-
}
|
|
14065
|
+
init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
|
|
14066
|
+
this.url = url || 'https://softphone.wazo.io';
|
|
14067
|
+
this.width = width || 500;
|
|
14068
|
+
this.height = height || 600;
|
|
14069
|
+
this.displayed = false;
|
|
14070
|
+
this.iframeLoaded = false;
|
|
14061
14071
|
|
|
14072
|
+
this.iframeLoaded = false;
|
|
14073
|
+
this._pendingMessages = [];
|
|
14062
14074
|
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
14063
14075
|
|
|
14064
14076
|
if (!server) {
|
|
@@ -14066,25 +14078,26 @@ class Softphone {
|
|
|
14066
14078
|
server = 'stack.dev.wazo.io';
|
|
14067
14079
|
}
|
|
14068
14080
|
|
|
14069
|
-
|
|
14070
|
-
|
|
14071
|
-
|
|
14072
|
-
|
|
14073
|
-
|
|
14074
|
-
|
|
14075
|
-
|
|
14076
|
-
|
|
14077
|
-
|
|
14078
|
-
|
|
14079
|
-
});
|
|
14081
|
+
const config = { server };
|
|
14082
|
+
if (language) {
|
|
14083
|
+
config.language = language;
|
|
14084
|
+
}
|
|
14085
|
+
if (port) {
|
|
14086
|
+
config.port = port;
|
|
14087
|
+
}
|
|
14088
|
+
if (wrapUpDuration) {
|
|
14089
|
+
config.wrapUpDuration = wrapUpDuration;
|
|
14090
|
+
}
|
|
14080
14091
|
|
|
14081
|
-
|
|
14082
|
-
this._sendMessage(BRIDGE_ENABLE_CARD);
|
|
14083
|
-
}
|
|
14092
|
+
this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
|
|
14084
14093
|
|
|
14085
|
-
|
|
14086
|
-
|
|
14087
|
-
|
|
14094
|
+
if (enableAgent) {
|
|
14095
|
+
this._sendMessage(BRIDGE_ENABLE_AGENT);
|
|
14096
|
+
}
|
|
14097
|
+
|
|
14098
|
+
this._createIframe(() => {
|
|
14099
|
+
this.iframeLoaded = true;
|
|
14100
|
+
this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
|
|
14088
14101
|
|
|
14089
14102
|
this.onIFrameLoaded();
|
|
14090
14103
|
});
|
|
@@ -14145,6 +14158,18 @@ class Softphone {
|
|
|
14145
14158
|
this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
|
|
14146
14159
|
}
|
|
14147
14160
|
|
|
14161
|
+
setCardValue(field , value ) {
|
|
14162
|
+
this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
|
|
14163
|
+
}
|
|
14164
|
+
|
|
14165
|
+
injectCss(css ) {
|
|
14166
|
+
this._sendMessage(BRIDGE_INJECT_CSS, { css });
|
|
14167
|
+
}
|
|
14168
|
+
|
|
14169
|
+
customizeAppearance(themes , translations , assets ) {
|
|
14170
|
+
this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
|
|
14171
|
+
}
|
|
14172
|
+
|
|
14148
14173
|
_createIframe(cb = () => {}) {
|
|
14149
14174
|
this.iframe = document.createElement('iframe');
|
|
14150
14175
|
// $FlowFixMe
|
|
@@ -14279,6 +14304,12 @@ class Softphone {
|
|
|
14279
14304
|
case BRIDGE_ON_STOP_RECORDING:
|
|
14280
14305
|
this.onStopRecording();
|
|
14281
14306
|
break;
|
|
14307
|
+
case BRIDGE_ON_CARD_CANCELED:
|
|
14308
|
+
this.onCardCanceled();
|
|
14309
|
+
break;
|
|
14310
|
+
case BRIDGE_ON_CALL_ANSWERED:
|
|
14311
|
+
this.onCallAnswered();
|
|
14312
|
+
break;
|
|
14282
14313
|
default:
|
|
14283
14314
|
this.onUnHandledEvent(event);
|
|
14284
14315
|
break;
|
|
@@ -14286,8 +14317,8 @@ class Softphone {
|
|
|
14286
14317
|
}
|
|
14287
14318
|
|
|
14288
14319
|
_sendMessage(type , payload = {}) {
|
|
14289
|
-
if (!this.iframe) {
|
|
14290
|
-
|
|
14320
|
+
if (!this.iframe || !this.iframeLoaded) {
|
|
14321
|
+
this._pendingMessages.push([type, payload]);
|
|
14291
14322
|
return;
|
|
14292
14323
|
}
|
|
14293
14324
|
|
package/esm/simple/utils.js
CHANGED
|
@@ -13957,8 +13957,6 @@ class Checker {
|
|
|
13957
13957
|
/* eslint-disable no-unused-vars */
|
|
13958
13958
|
/* global window, document */
|
|
13959
13959
|
const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
|
|
13960
|
-
const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
|
|
13961
|
-
const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
|
|
13962
13960
|
const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
|
|
13963
13961
|
const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
|
|
13964
13962
|
const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
|
|
@@ -13971,6 +13969,7 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
|
|
|
13971
13969
|
const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
|
|
13972
13970
|
const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
|
|
13973
13971
|
const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
|
|
13972
|
+
const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
|
|
13974
13973
|
const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
|
|
13975
13974
|
const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
|
|
13976
13975
|
const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
|
|
@@ -13984,6 +13983,12 @@ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFE
|
|
|
13984
13983
|
const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
|
|
13985
13984
|
const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
|
|
13986
13985
|
const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
|
|
13986
|
+
const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
|
|
13987
|
+
const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
|
|
13988
|
+
const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
|
|
13989
|
+
|
|
13990
|
+
const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
|
|
13991
|
+
const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
|
|
13987
13992
|
|
|
13988
13993
|
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
13989
13994
|
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
@@ -13993,22 +13998,32 @@ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
|
13993
13998
|
const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
|
|
13994
13999
|
|
|
13995
14000
|
class Softphone {
|
|
13996
|
-
|
|
13997
|
-
|
|
13998
|
-
|
|
13999
|
-
|
|
14000
|
-
|
|
14001
|
+
|
|
14002
|
+
|
|
14003
|
+
|
|
14004
|
+
|
|
14005
|
+
|
|
14006
|
+
|
|
14007
|
+
|
|
14008
|
+
// Message waiting for the iframe to be loaded
|
|
14009
|
+
|
|
14001
14010
|
|
|
14002
14011
|
onLinkEnabled(link ) {}
|
|
14003
14012
|
onIFrameLoaded() {}
|
|
14004
14013
|
|
|
14014
|
+
onCallAnswered() {}
|
|
14005
14015
|
onCallMade(call ) {}
|
|
14006
14016
|
onCallIncoming(call ) {}
|
|
14007
14017
|
onCallEnded(call , card , direction , fromExtension ) {}
|
|
14008
14018
|
onCardSaved(card ) {}
|
|
14019
|
+
onCardCanceled() {}
|
|
14009
14020
|
onAuthenticated(session ) {}
|
|
14010
14021
|
onLoggedOut() {}
|
|
14011
|
-
|
|
14022
|
+
|
|
14023
|
+
onSearchOptions(fieldId , query ) {
|
|
14024
|
+
this.onOptionsResults(fieldId, []);
|
|
14025
|
+
}
|
|
14026
|
+
|
|
14012
14027
|
onDisplayLinkedOption(optionId ) {}
|
|
14013
14028
|
onWazoContactSearch(query ) {}
|
|
14014
14029
|
onAgentLoggedIn() {}
|
|
@@ -14031,18 +14046,15 @@ class Softphone {
|
|
|
14031
14046
|
onStopRecording() {}
|
|
14032
14047
|
onUnHandledEvent(event ) {}
|
|
14033
14048
|
|
|
14034
|
-
init({ url, width, height, server, port, language, wrapUpDuration,
|
|
14035
|
-
|
|
14036
|
-
|
|
14037
|
-
|
|
14038
|
-
|
|
14039
|
-
|
|
14040
|
-
this.width = width;
|
|
14041
|
-
}
|
|
14042
|
-
if (height) {
|
|
14043
|
-
this.height = height;
|
|
14044
|
-
}
|
|
14049
|
+
init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
|
|
14050
|
+
this.url = url || 'https://softphone.wazo.io';
|
|
14051
|
+
this.width = width || 500;
|
|
14052
|
+
this.height = height || 600;
|
|
14053
|
+
this.displayed = false;
|
|
14054
|
+
this.iframeLoaded = false;
|
|
14045
14055
|
|
|
14056
|
+
this.iframeLoaded = false;
|
|
14057
|
+
this._pendingMessages = [];
|
|
14046
14058
|
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
14047
14059
|
|
|
14048
14060
|
if (!server) {
|
|
@@ -14050,25 +14062,26 @@ class Softphone {
|
|
|
14050
14062
|
server = 'stack.dev.wazo.io';
|
|
14051
14063
|
}
|
|
14052
14064
|
|
|
14053
|
-
|
|
14054
|
-
|
|
14055
|
-
|
|
14056
|
-
|
|
14057
|
-
|
|
14058
|
-
|
|
14059
|
-
|
|
14060
|
-
|
|
14061
|
-
|
|
14062
|
-
|
|
14063
|
-
});
|
|
14065
|
+
const config = { server };
|
|
14066
|
+
if (language) {
|
|
14067
|
+
config.language = language;
|
|
14068
|
+
}
|
|
14069
|
+
if (port) {
|
|
14070
|
+
config.port = port;
|
|
14071
|
+
}
|
|
14072
|
+
if (wrapUpDuration) {
|
|
14073
|
+
config.wrapUpDuration = wrapUpDuration;
|
|
14074
|
+
}
|
|
14064
14075
|
|
|
14065
|
-
|
|
14066
|
-
this._sendMessage(BRIDGE_ENABLE_CARD);
|
|
14067
|
-
}
|
|
14076
|
+
this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
|
|
14068
14077
|
|
|
14069
|
-
|
|
14070
|
-
|
|
14071
|
-
|
|
14078
|
+
if (enableAgent) {
|
|
14079
|
+
this._sendMessage(BRIDGE_ENABLE_AGENT);
|
|
14080
|
+
}
|
|
14081
|
+
|
|
14082
|
+
this._createIframe(() => {
|
|
14083
|
+
this.iframeLoaded = true;
|
|
14084
|
+
this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
|
|
14072
14085
|
|
|
14073
14086
|
this.onIFrameLoaded();
|
|
14074
14087
|
});
|
|
@@ -14129,6 +14142,18 @@ class Softphone {
|
|
|
14129
14142
|
this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
|
|
14130
14143
|
}
|
|
14131
14144
|
|
|
14145
|
+
setCardValue(field , value ) {
|
|
14146
|
+
this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
|
|
14147
|
+
}
|
|
14148
|
+
|
|
14149
|
+
injectCss(css ) {
|
|
14150
|
+
this._sendMessage(BRIDGE_INJECT_CSS, { css });
|
|
14151
|
+
}
|
|
14152
|
+
|
|
14153
|
+
customizeAppearance(themes , translations , assets ) {
|
|
14154
|
+
this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
|
|
14155
|
+
}
|
|
14156
|
+
|
|
14132
14157
|
_createIframe(cb = () => {}) {
|
|
14133
14158
|
this.iframe = document.createElement('iframe');
|
|
14134
14159
|
// $FlowFixMe
|
|
@@ -14263,6 +14288,12 @@ class Softphone {
|
|
|
14263
14288
|
case BRIDGE_ON_STOP_RECORDING:
|
|
14264
14289
|
this.onStopRecording();
|
|
14265
14290
|
break;
|
|
14291
|
+
case BRIDGE_ON_CARD_CANCELED:
|
|
14292
|
+
this.onCardCanceled();
|
|
14293
|
+
break;
|
|
14294
|
+
case BRIDGE_ON_CALL_ANSWERED:
|
|
14295
|
+
this.onCallAnswered();
|
|
14296
|
+
break;
|
|
14266
14297
|
default:
|
|
14267
14298
|
this.onUnHandledEvent(event);
|
|
14268
14299
|
break;
|
|
@@ -14270,8 +14301,8 @@ class Softphone {
|
|
|
14270
14301
|
}
|
|
14271
14302
|
|
|
14272
14303
|
_sendMessage(type , payload = {}) {
|
|
14273
|
-
if (!this.iframe) {
|
|
14274
|
-
|
|
14304
|
+
if (!this.iframe || !this.iframeLoaded) {
|
|
14305
|
+
this._pendingMessages.push([type, payload]);
|
|
14275
14306
|
return;
|
|
14276
14307
|
}
|
|
14277
14308
|
|
package/lib/index.js
CHANGED
|
@@ -14122,8 +14122,6 @@ const createLocalAudioStream = async (options ) => createLocalStream('aud
|
|
|
14122
14122
|
/* eslint-disable no-unused-vars */
|
|
14123
14123
|
/* global window, document */
|
|
14124
14124
|
const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
|
|
14125
|
-
const BRIDGE_ENABLE_CARD = 'bridge/ENABLE_CARD';
|
|
14126
|
-
const BRIDGE_CHANGE_REQUIRED_SUBSCRIPTION_TYPE = 'bridge/CHANGE_REQUIRED_SUBSCRIPTION_TYPE';
|
|
14127
14125
|
const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
|
|
14128
14126
|
const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
|
|
14129
14127
|
const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
|
|
@@ -14136,6 +14134,7 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
|
|
|
14136
14134
|
const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
|
|
14137
14135
|
const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
|
|
14138
14136
|
const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
|
|
14137
|
+
const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
|
|
14139
14138
|
const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
|
|
14140
14139
|
const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
|
|
14141
14140
|
const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
|
|
@@ -14149,6 +14148,12 @@ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFE
|
|
|
14149
14148
|
const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
|
|
14150
14149
|
const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
|
|
14151
14150
|
const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
|
|
14151
|
+
const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
|
|
14152
|
+
const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
|
|
14153
|
+
const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
|
|
14154
|
+
|
|
14155
|
+
const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
|
|
14156
|
+
const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
|
|
14152
14157
|
|
|
14153
14158
|
const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
|
|
14154
14159
|
const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
|
|
@@ -14158,22 +14163,32 @@ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
|
|
|
14158
14163
|
const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
|
|
14159
14164
|
|
|
14160
14165
|
class Softphone {
|
|
14161
|
-
|
|
14162
|
-
|
|
14163
|
-
|
|
14164
|
-
|
|
14165
|
-
|
|
14166
|
+
|
|
14167
|
+
|
|
14168
|
+
|
|
14169
|
+
|
|
14170
|
+
|
|
14171
|
+
|
|
14172
|
+
|
|
14173
|
+
// Message waiting for the iframe to be loaded
|
|
14174
|
+
|
|
14166
14175
|
|
|
14167
14176
|
onLinkEnabled(link ) {}
|
|
14168
14177
|
onIFrameLoaded() {}
|
|
14169
14178
|
|
|
14179
|
+
onCallAnswered() {}
|
|
14170
14180
|
onCallMade(call ) {}
|
|
14171
14181
|
onCallIncoming(call ) {}
|
|
14172
14182
|
onCallEnded(call , card , direction , fromExtension ) {}
|
|
14173
14183
|
onCardSaved(card ) {}
|
|
14184
|
+
onCardCanceled() {}
|
|
14174
14185
|
onAuthenticated(session ) {}
|
|
14175
14186
|
onLoggedOut() {}
|
|
14176
|
-
|
|
14187
|
+
|
|
14188
|
+
onSearchOptions(fieldId , query ) {
|
|
14189
|
+
this.onOptionsResults(fieldId, []);
|
|
14190
|
+
}
|
|
14191
|
+
|
|
14177
14192
|
onDisplayLinkedOption(optionId ) {}
|
|
14178
14193
|
onWazoContactSearch(query ) {}
|
|
14179
14194
|
onAgentLoggedIn() {}
|
|
@@ -14196,18 +14211,15 @@ class Softphone {
|
|
|
14196
14211
|
onStopRecording() {}
|
|
14197
14212
|
onUnHandledEvent(event ) {}
|
|
14198
14213
|
|
|
14199
|
-
init({ url, width, height, server, port, language, wrapUpDuration,
|
|
14200
|
-
|
|
14201
|
-
|
|
14202
|
-
|
|
14203
|
-
|
|
14204
|
-
|
|
14205
|
-
this.width = width;
|
|
14206
|
-
}
|
|
14207
|
-
if (height) {
|
|
14208
|
-
this.height = height;
|
|
14209
|
-
}
|
|
14214
|
+
init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
|
|
14215
|
+
this.url = url || 'https://softphone.wazo.io';
|
|
14216
|
+
this.width = width || 500;
|
|
14217
|
+
this.height = height || 600;
|
|
14218
|
+
this.displayed = false;
|
|
14219
|
+
this.iframeLoaded = false;
|
|
14210
14220
|
|
|
14221
|
+
this.iframeLoaded = false;
|
|
14222
|
+
this._pendingMessages = [];
|
|
14211
14223
|
window.addEventListener('message', this._onMessage.bind(this), false);
|
|
14212
14224
|
|
|
14213
14225
|
if (!server) {
|
|
@@ -14215,25 +14227,26 @@ class Softphone {
|
|
|
14215
14227
|
server = 'stack.dev.wazo.io';
|
|
14216
14228
|
}
|
|
14217
14229
|
|
|
14218
|
-
|
|
14219
|
-
|
|
14220
|
-
|
|
14221
|
-
|
|
14222
|
-
|
|
14223
|
-
|
|
14224
|
-
|
|
14225
|
-
|
|
14226
|
-
|
|
14227
|
-
|
|
14228
|
-
});
|
|
14230
|
+
const config = { server };
|
|
14231
|
+
if (language) {
|
|
14232
|
+
config.language = language;
|
|
14233
|
+
}
|
|
14234
|
+
if (port) {
|
|
14235
|
+
config.port = port;
|
|
14236
|
+
}
|
|
14237
|
+
if (wrapUpDuration) {
|
|
14238
|
+
config.wrapUpDuration = wrapUpDuration;
|
|
14239
|
+
}
|
|
14229
14240
|
|
|
14230
|
-
|
|
14231
|
-
this._sendMessage(BRIDGE_ENABLE_CARD);
|
|
14232
|
-
}
|
|
14241
|
+
this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
|
|
14233
14242
|
|
|
14234
|
-
|
|
14235
|
-
|
|
14236
|
-
|
|
14243
|
+
if (enableAgent) {
|
|
14244
|
+
this._sendMessage(BRIDGE_ENABLE_AGENT);
|
|
14245
|
+
}
|
|
14246
|
+
|
|
14247
|
+
this._createIframe(() => {
|
|
14248
|
+
this.iframeLoaded = true;
|
|
14249
|
+
this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
|
|
14237
14250
|
|
|
14238
14251
|
this.onIFrameLoaded();
|
|
14239
14252
|
});
|
|
@@ -14294,6 +14307,18 @@ class Softphone {
|
|
|
14294
14307
|
this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
|
|
14295
14308
|
}
|
|
14296
14309
|
|
|
14310
|
+
setCardValue(field , value ) {
|
|
14311
|
+
this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
|
|
14312
|
+
}
|
|
14313
|
+
|
|
14314
|
+
injectCss(css ) {
|
|
14315
|
+
this._sendMessage(BRIDGE_INJECT_CSS, { css });
|
|
14316
|
+
}
|
|
14317
|
+
|
|
14318
|
+
customizeAppearance(themes , translations , assets ) {
|
|
14319
|
+
this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
|
|
14320
|
+
}
|
|
14321
|
+
|
|
14297
14322
|
_createIframe(cb = () => {}) {
|
|
14298
14323
|
this.iframe = document.createElement('iframe');
|
|
14299
14324
|
// $FlowFixMe
|
|
@@ -14428,6 +14453,12 @@ class Softphone {
|
|
|
14428
14453
|
case BRIDGE_ON_STOP_RECORDING:
|
|
14429
14454
|
this.onStopRecording();
|
|
14430
14455
|
break;
|
|
14456
|
+
case BRIDGE_ON_CARD_CANCELED:
|
|
14457
|
+
this.onCardCanceled();
|
|
14458
|
+
break;
|
|
14459
|
+
case BRIDGE_ON_CALL_ANSWERED:
|
|
14460
|
+
this.onCallAnswered();
|
|
14461
|
+
break;
|
|
14431
14462
|
default:
|
|
14432
14463
|
this.onUnHandledEvent(event);
|
|
14433
14464
|
break;
|
|
@@ -14435,8 +14466,8 @@ class Softphone {
|
|
|
14435
14466
|
}
|
|
14436
14467
|
|
|
14437
14468
|
_sendMessage(type , payload = {}) {
|
|
14438
|
-
if (!this.iframe) {
|
|
14439
|
-
|
|
14469
|
+
if (!this.iframe || !this.iframeLoaded) {
|
|
14470
|
+
this._pendingMessages.push([type, payload]);
|
|
14440
14471
|
return;
|
|
14441
14472
|
}
|
|
14442
14473
|
|