@unblu/embedded-app-component 7.37.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/LICENSE.md +184 -0
- package/README.md +21 -0
- package/dist/lib/index.d.ts +36 -0
- package/dist/lib/index.js +27 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/internal/internal-embedded-api.d.ts +16 -0
- package/dist/lib/internal/internal-embedded-api.js +18 -0
- package/dist/lib/internal/internal-embedded-api.js.map +1 -0
- package/dist/lib/internal/module/embedded-meta-module.d.ts +16 -0
- package/dist/lib/internal/module/embedded-meta-module.js +16 -0
- package/dist/lib/internal/module/embedded-meta-module.js.map +1 -0
- package/dist/lib/internal/module/general-module.d.ts +16 -0
- package/dist/lib/internal/module/general-module.js +16 -0
- package/dist/lib/internal/module/general-module.js.map +1 -0
- package/dist/lib/shared/api-state.d.ts +8 -0
- package/dist/lib/shared/api-state.js +10 -0
- package/dist/lib/shared/api-state.js.map +1 -0
- package/dist/lib/shared/conversation.d.ts +320 -0
- package/dist/lib/shared/conversation.js +384 -0
- package/dist/lib/shared/conversation.js.map +1 -0
- package/dist/lib/shared/internal/api-bridge.d.ts +36 -0
- package/dist/lib/shared/internal/api-bridge.js +97 -0
- package/dist/lib/shared/internal/api-bridge.js.map +1 -0
- package/dist/lib/shared/internal/event.d.ts +6 -0
- package/dist/lib/shared/internal/event.js +2 -0
- package/dist/lib/shared/internal/event.js.map +1 -0
- package/dist/lib/shared/internal/initialized-unblu-api.d.ts +6 -0
- package/dist/lib/shared/internal/initialized-unblu-api.js +2 -0
- package/dist/lib/shared/internal/initialized-unblu-api.js.map +1 -0
- package/dist/lib/shared/internal/initialized-unblu-element.d.ts +6 -0
- package/dist/lib/shared/internal/initialized-unblu-element.js +2 -0
- package/dist/lib/shared/internal/initialized-unblu-element.js.map +1 -0
- package/dist/lib/shared/internal/java-error-codes.d.ts +5 -0
- package/dist/lib/shared/internal/java-error-codes.js +6 -0
- package/dist/lib/shared/internal/java-error-codes.js.map +1 -0
- package/dist/lib/shared/internal/module/agent-availability-module.d.ts +14 -0
- package/dist/lib/shared/internal/module/agent-availability-module.js +13 -0
- package/dist/lib/shared/internal/module/agent-availability-module.js.map +1 -0
- package/dist/lib/shared/internal/module/base-general-module.d.ts +31 -0
- package/dist/lib/shared/internal/module/base-general-module.js +46 -0
- package/dist/lib/shared/internal/module/base-general-module.js.map +1 -0
- package/dist/lib/shared/internal/module/conversation-module.d.ts +57 -0
- package/dist/lib/shared/internal/module/conversation-module.js +49 -0
- package/dist/lib/shared/internal/module/conversation-module.js.map +1 -0
- package/dist/lib/shared/internal/module/module.d.ts +10 -0
- package/dist/lib/shared/internal/module/module.js +16 -0
- package/dist/lib/shared/internal/module/module.js.map +1 -0
- package/dist/lib/shared/internal/unblu-api-factory.d.ts +9 -0
- package/dist/lib/shared/internal/unblu-api-factory.js +2 -0
- package/dist/lib/shared/internal/unblu-api-factory.js.map +1 -0
- package/dist/lib/shared/internal/unblu-util.d.ts +63 -0
- package/dist/lib/shared/internal/unblu-util.js +220 -0
- package/dist/lib/shared/internal/unblu-util.js.map +1 -0
- package/dist/lib/shared/internal/util/event-emitter.d.ts +44 -0
- package/dist/lib/shared/internal/util/event-emitter.js +85 -0
- package/dist/lib/shared/internal/util/event-emitter.js.map +1 -0
- package/dist/lib/shared/model/agent-availability-state.d.ts +18 -0
- package/dist/lib/shared/model/agent-availability-state.js +20 -0
- package/dist/lib/shared/model/agent-availability-state.js.map +1 -0
- package/dist/lib/shared/model/call-state.d.ts +26 -0
- package/dist/lib/shared/model/call-state.js +28 -0
- package/dist/lib/shared/model/call-state.js.map +1 -0
- package/dist/lib/shared/model/configuration.d.ts +46 -0
- package/dist/lib/shared/model/configuration.js +2 -0
- package/dist/lib/shared/model/configuration.js.map +1 -0
- package/dist/lib/shared/model/connection-state.d.ts +27 -0
- package/dist/lib/shared/model/connection-state.js +29 -0
- package/dist/lib/shared/model/connection-state.js.map +1 -0
- package/dist/lib/shared/model/conversation-info.d.ts +34 -0
- package/dist/lib/shared/model/conversation-info.js +2 -0
- package/dist/lib/shared/model/conversation-info.js.map +1 -0
- package/dist/lib/shared/model/conversation-message-info.d.ts +14 -0
- package/dist/lib/shared/model/conversation-message-info.js +2 -0
- package/dist/lib/shared/model/conversation-message-info.js.map +1 -0
- package/dist/lib/shared/model/conversation-recipient-type.d.ts +10 -0
- package/dist/lib/shared/model/conversation-recipient-type.js +12 -0
- package/dist/lib/shared/model/conversation-recipient-type.js.map +1 -0
- package/dist/lib/shared/model/conversation-recipient.d.ts +14 -0
- package/dist/lib/shared/model/conversation-recipient.js +2 -0
- package/dist/lib/shared/model/conversation-recipient.js.map +1 -0
- package/dist/lib/shared/model/conversation-state.d.ts +37 -0
- package/dist/lib/shared/model/conversation-state.js +39 -0
- package/dist/lib/shared/model/conversation-state.js.map +1 -0
- package/dist/lib/shared/model/conversation-type.d.ts +43 -0
- package/dist/lib/shared/model/conversation-type.js +45 -0
- package/dist/lib/shared/model/conversation-type.js.map +1 -0
- package/dist/lib/shared/model/customaction/custom-action-invocation.d.ts +27 -0
- package/dist/lib/shared/model/customaction/custom-action-invocation.js +2 -0
- package/dist/lib/shared/model/customaction/custom-action-invocation.js.map +1 -0
- package/dist/lib/shared/model/customaction/custom-conversation-action-invocation.d.ts +6 -0
- package/dist/lib/shared/model/customaction/custom-conversation-action-invocation.js +2 -0
- package/dist/lib/shared/model/customaction/custom-conversation-action-invocation.js.map +1 -0
- package/dist/lib/shared/model/customaction/custom-message-action-invocation.d.ts +16 -0
- package/dist/lib/shared/model/customaction/custom-message-action-invocation.js +2 -0
- package/dist/lib/shared/model/customaction/custom-message-action-invocation.js.map +1 -0
- package/dist/lib/shared/model/customaction/custom-person-action-invocation.d.ts +11 -0
- package/dist/lib/shared/model/customaction/custom-person-action-invocation.js +2 -0
- package/dist/lib/shared/model/customaction/custom-person-action-invocation.js.map +1 -0
- package/dist/lib/shared/model/invitation-status.d.ts +14 -0
- package/dist/lib/shared/model/invitation-status.js +16 -0
- package/dist/lib/shared/model/invitation-status.js.map +1 -0
- package/dist/lib/shared/model/invitation.d.ts +24 -0
- package/dist/lib/shared/model/invitation.js +2 -0
- package/dist/lib/shared/model/invitation.js.map +1 -0
- package/dist/lib/shared/model/new-conversation-interceptor-result.d.ts +14 -0
- package/dist/lib/shared/model/new-conversation-interceptor-result.js +2 -0
- package/dist/lib/shared/model/new-conversation-interceptor-result.js.map +1 -0
- package/dist/lib/shared/model/person-info.d.ts +4 -0
- package/dist/lib/shared/model/person-info.js +2 -0
- package/dist/lib/shared/model/person-info.js.map +1 -0
- package/dist/lib/shared/new-conversation-interceptor.d.ts +24 -0
- package/dist/lib/shared/new-conversation-interceptor.js +2 -0
- package/dist/lib/shared/new-conversation-interceptor.js.map +1 -0
- package/dist/lib/shared/unblu-api-error.d.ts +117 -0
- package/dist/lib/shared/unblu-api-error.js +122 -0
- package/dist/lib/shared/unblu-api-error.js.map +1 -0
- package/dist/lib/unblu-embedded-api.d.ts +537 -0
- package/dist/lib/unblu-embedded-api.js +473 -0
- package/dist/lib/unblu-embedded-api.js.map +1 -0
- package/dist/lib/unblu-embedded-app-element.d.ts +703 -0
- package/dist/lib/unblu-embedded-app-element.js +844 -0
- package/dist/lib/unblu-embedded-app-element.js.map +1 -0
- package/dist/lib/view-mode.d.ts +5 -0
- package/dist/lib/view-mode.js +7 -0
- package/dist/lib/view-mode.js.map +1 -0
- package/package.json +23 -0
|
@@ -0,0 +1,844 @@
|
|
|
1
|
+
import { UnbluApiError, UnbluErrorType } from "./shared/unblu-api-error";
|
|
2
|
+
import { InternalEmbeddedApi } from "./internal/internal-embedded-api";
|
|
3
|
+
import { IntegrationType, UnbluUtil } from "./shared/internal/unblu-util";
|
|
4
|
+
import { ApiBridge } from "./shared/internal/api-bridge";
|
|
5
|
+
import { ViewMode } from "./view-mode";
|
|
6
|
+
import { ApiState } from "./shared/api-state";
|
|
7
|
+
import { UnbluEmbeddedApi } from "./unblu-embedded-api";
|
|
8
|
+
/**
|
|
9
|
+
* #### This is a custom element which can be used to integrate Unblu into a webpage at a specific location.
|
|
10
|
+
* By itself this contains only the definition of the custom element and will load further JavaScript from the collaboration server on initialization to provide the full functionality.
|
|
11
|
+
*
|
|
12
|
+
* To use the custom element just place a tag named "unblu-embedded-app" somewhere into the webpage`s `body`.
|
|
13
|
+
*
|
|
14
|
+
* ```html
|
|
15
|
+
* ...
|
|
16
|
+
* <body>
|
|
17
|
+
* ...
|
|
18
|
+
* <div>
|
|
19
|
+
* <unblu-embedded-app></unblu-embedded-app>
|
|
20
|
+
* </div>
|
|
21
|
+
* ...
|
|
22
|
+
* </body>
|
|
23
|
+
* ...
|
|
24
|
+
* ```
|
|
25
|
+
* The size and positioning fully depends on the styles applied to the element by the website it is embedded into.
|
|
26
|
+
* The styling within the unblu embedded app can't be influenced by the website's styles however as a shadow root is used for its content.
|
|
27
|
+
* Unblu provides a large list of configuration properties to nicely integrate the unblu embedded app's visual appearance with the website it is embedded into.
|
|
28
|
+
*
|
|
29
|
+
* The example above will simply add the unblu embedded app into the `DOM` but it won't initialize anything.
|
|
30
|
+
* To initialize the element with Unblu content at least the attribute {@link ATTR_API_KEY} or property {@link UnbluEmbeddedAppElement.apiKey} need to be defined.
|
|
31
|
+
* If {@link UnbluEmbeddedAppElement.autoInit} is set to true (default), it will automatically start the initialization, as soon as the API key is defined either via its attribute {@link ATTR_API_KEY} or property {@link UnbluEmbeddedAppElement.apiKey}.
|
|
32
|
+
* If not a call to {@link UnbluEmbeddedAppElement.initialize} has to be done to trigger the initialization.
|
|
33
|
+
*
|
|
34
|
+
* **Initializing**:
|
|
35
|
+
*
|
|
36
|
+
* Initialization can either be done manually or automatically.
|
|
37
|
+
* If the element is configured to do automatic initialization {@link ATTR_AUTO_INIT} / {@link UnbluEmbeddedAppElement.autoInit} the initialization will be automatically started as soon as at least the API key {@link ATTR_API_KEY} / {@link UnbluEmbeddedAppElement.apiKey} is defined.
|
|
38
|
+
* If you intent to define other attributes/properties relevant for the initialization these must all be set in the same JavaScript execution cycle.
|
|
39
|
+
* If automatic initialization is disabled the initialization must be done manually by calling the {@link UnbluEmbeddedAppElement.initialize} method.
|
|
40
|
+
*
|
|
41
|
+
* There are additional attributes/properties which can be defined to define from where and how the Unblu JavaScript code is loaded from the collaboration server.
|
|
42
|
+
* - {@link ATTR_API_KEY} / {@link UnbluEmbeddedAppElement.apiKey}
|
|
43
|
+
* - {@link ATTR_ENTRY_PATH} / {@link UnbluEmbeddedAppElement.entryPath}
|
|
44
|
+
* - {@link ATTR_SERVER_URL} / {@link UnbluEmbeddedAppElement.serverUrl}
|
|
45
|
+
* - {@link ATTR_NAMED_AREA} / {@link UnbluEmbeddedAppElement.namedArea}
|
|
46
|
+
* - {@link ATTR_ACCESS_TOKEN} / {@link UnbluEmbeddedAppElement.accessToken}
|
|
47
|
+
* - {@link ATTR_LOCALE} / {@link UnbluEmbeddedAppElement.locale}
|
|
48
|
+
* - {@link ATTR_INIT_TIMEOUT} / {@link UnbluEmbeddedAppElement.initTimeout}
|
|
49
|
+
* - {@link ATTR_AUTO_INIT} / {@link UnbluEmbeddedAppElement.autoInit}
|
|
50
|
+
*
|
|
51
|
+
* The Unblu UI inside the custom element will always fill the whole content of the unblu-embedded-app independent of what size it is given.
|
|
52
|
+
*
|
|
53
|
+
* **Note**: if there already is a floating Unblu UI on the website integrated via the visitor JS API, the embedded app will automatically deinitialize it as there can always only one active instance of Unblu on the page.
|
|
54
|
+
*
|
|
55
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements | MDN Custom Element}
|
|
56
|
+
* @noInheritDoc
|
|
57
|
+
*/
|
|
58
|
+
export class UnbluEmbeddedAppElement extends HTMLElement {
|
|
59
|
+
constructor() {
|
|
60
|
+
super(...arguments);
|
|
61
|
+
this._autoInit = true;
|
|
62
|
+
this._reinitTrigger = -1;
|
|
63
|
+
//read only properties
|
|
64
|
+
this._state = ApiState.INITIAL;
|
|
65
|
+
}
|
|
66
|
+
addEventListener(type, listener, options) {
|
|
67
|
+
super.addEventListener(type, listener, options);
|
|
68
|
+
}
|
|
69
|
+
removeEventListener(type, listener, options) {
|
|
70
|
+
super.removeEventListener(type, listener, options);
|
|
71
|
+
}
|
|
72
|
+
// noinspection JSUnusedGlobalSymbols
|
|
73
|
+
static get observedAttributes() {
|
|
74
|
+
return [this.ATTR_SERVER_URL, this.ATTR_ENTRY_PATH, this.ATTR_API_KEY, this.ATTR_LOCALE, this.ATTR_NAMED_AREA, this.ATTR_ACCESS_TOKEN, this.ATTR_CONVERSATION_ID, this.ATTR_VIEW_MODE, this.ATTR_FULLSCREEN, this.ATTR_INIT_TIMEOUT, this.ATTR_AUTO_INIT];
|
|
75
|
+
}
|
|
76
|
+
// ------- attribute and properties handling -------
|
|
77
|
+
// noinspection JSUnusedGlobalSymbols
|
|
78
|
+
attributeChangedCallback(attrName, oldVal, newVal) {
|
|
79
|
+
console.debug("attributeChangedCallback", attrName, newVal, "old:", oldVal);
|
|
80
|
+
switch (attrName) {
|
|
81
|
+
case UnbluEmbeddedAppElement.ATTR_SERVER_URL:
|
|
82
|
+
this.serverUrl = newVal;
|
|
83
|
+
break;
|
|
84
|
+
case UnbluEmbeddedAppElement.ATTR_ENTRY_PATH:
|
|
85
|
+
this.entryPath = newVal;
|
|
86
|
+
break;
|
|
87
|
+
case UnbluEmbeddedAppElement.ATTR_API_KEY:
|
|
88
|
+
this.apiKey = newVal;
|
|
89
|
+
break;
|
|
90
|
+
case UnbluEmbeddedAppElement.ATTR_LOCALE:
|
|
91
|
+
this.locale = newVal;
|
|
92
|
+
break;
|
|
93
|
+
case UnbluEmbeddedAppElement.ATTR_NAMED_AREA:
|
|
94
|
+
this.namedArea = newVal;
|
|
95
|
+
break;
|
|
96
|
+
case UnbluEmbeddedAppElement.ATTR_ACCESS_TOKEN:
|
|
97
|
+
this.accessToken = newVal;
|
|
98
|
+
break;
|
|
99
|
+
case UnbluEmbeddedAppElement.ATTR_CONVERSATION_ID:
|
|
100
|
+
this.conversationId = newVal;
|
|
101
|
+
break;
|
|
102
|
+
case UnbluEmbeddedAppElement.ATTR_VIEW_MODE:
|
|
103
|
+
this.viewMode = ViewMode[newVal];
|
|
104
|
+
break;
|
|
105
|
+
case UnbluEmbeddedAppElement.ATTR_FULLSCREEN:
|
|
106
|
+
this.fullscreen = newVal === 'true';
|
|
107
|
+
break;
|
|
108
|
+
case UnbluEmbeddedAppElement.ATTR_INIT_TIMEOUT:
|
|
109
|
+
this.initTimeout = Number.parseInt(newVal) || 30000;
|
|
110
|
+
break;
|
|
111
|
+
case UnbluEmbeddedAppElement.ATTR_AUTO_INIT:
|
|
112
|
+
this.autoInit = newVal === 'true';
|
|
113
|
+
break;
|
|
114
|
+
default:
|
|
115
|
+
throw 'Unknown attribute changed! attrName: ' + attrName + ' oldVal: ' + oldVal + ' newVal: ' + newVal;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The URL to the collaboration server.
|
|
120
|
+
*
|
|
121
|
+
* If not specified it is assumed that the server is reachable on the same domain of the current webpage at the defined {@link UnbluEmbeddedAppElement.entryPath}
|
|
122
|
+
*
|
|
123
|
+
* **Note**: Changes to this property trigger a reinitialization of Unblu if {@link UnbluEmbeddedAppElement.autoInit} is true.
|
|
124
|
+
*
|
|
125
|
+
* @see {@link UnbluEmbeddedAppElement.ATTR_SERVER_URL} to set this as an attribute
|
|
126
|
+
* @param serverUrl
|
|
127
|
+
*/
|
|
128
|
+
set serverUrl(serverUrl) {
|
|
129
|
+
serverUrl = UnbluUtil.sanitizeParameter(serverUrl);
|
|
130
|
+
if (this._serverUrl === serverUrl) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
this._serverUrl = serverUrl;
|
|
134
|
+
this.autoReinitIfEnabled();
|
|
135
|
+
}
|
|
136
|
+
get serverUrl() {
|
|
137
|
+
return this._serverUrl;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* The entry path on the collaboration server.
|
|
141
|
+
*
|
|
142
|
+
* @default "/unblu".
|
|
143
|
+
*
|
|
144
|
+
* **Note**: Changes to this property trigger a reinitialization of Unblu if {@link UnbluEmbeddedAppElement.autoInit} is true.
|
|
145
|
+
*
|
|
146
|
+
* @see {@link UnbluEmbeddedAppElement.ATTR_ENTRY_PATH} to set this as an attribute
|
|
147
|
+
* @param entryPath
|
|
148
|
+
*/
|
|
149
|
+
set entryPath(entryPath) {
|
|
150
|
+
entryPath = UnbluUtil.sanitizeParameter(entryPath);
|
|
151
|
+
if (this._entryPath === entryPath) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
this._entryPath = entryPath;
|
|
155
|
+
this.autoReinitIfEnabled();
|
|
156
|
+
}
|
|
157
|
+
get entryPath() {
|
|
158
|
+
return this._entryPath;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* The API Key to connect this app with a specific Unblu account.
|
|
162
|
+
* This is the minimum configuration that has to be done to trigger the initialization of Unblu.
|
|
163
|
+
*
|
|
164
|
+
* **Note**: Changes to this property trigger a reinitialization of Unblu if {@link UnbluEmbeddedAppElement.autoInit} is true.
|
|
165
|
+
*
|
|
166
|
+
* @see {@link UnbluEmbeddedAppElement.ATTR_API_KEY} to set this as an attribute
|
|
167
|
+
* @param apiKey
|
|
168
|
+
*/
|
|
169
|
+
set apiKey(apiKey) {
|
|
170
|
+
apiKey = UnbluUtil.sanitizeParameter(apiKey);
|
|
171
|
+
if (this._apiKey === apiKey) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
this._apiKey = apiKey;
|
|
175
|
+
this.autoReinitIfEnabled();
|
|
176
|
+
}
|
|
177
|
+
get apiKey() {
|
|
178
|
+
return this._apiKey;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* The locale (language) used for all Unblu UIs.
|
|
182
|
+
* If not specified this is derived from the webpage or the browser.
|
|
183
|
+
*
|
|
184
|
+
* **Note**: Changes to this property trigger a reinitialization of Unblu if {@link UnbluEmbeddedAppElement.autoInit} is true.
|
|
185
|
+
*
|
|
186
|
+
* @see {@link UnbluEmbeddedAppElement.ATTR_LOCALE} to set this as an attribute
|
|
187
|
+
* @param locale
|
|
188
|
+
*/
|
|
189
|
+
set locale(locale) {
|
|
190
|
+
locale = UnbluUtil.sanitizeParameter(locale);
|
|
191
|
+
if (this._locale === locale) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
this._locale = locale;
|
|
195
|
+
this.autoReinitIfEnabled();
|
|
196
|
+
}
|
|
197
|
+
get locale() {
|
|
198
|
+
return this._locale;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* The named area for which the configuration should be loaded and with which new queue requests will be labeled.
|
|
202
|
+
* If not specified this can be derived from meta tags on the webpage.
|
|
203
|
+
*
|
|
204
|
+
* **Note**: Changes to this property trigger a reinitialization of Unblu if {@link UnbluEmbeddedAppElement.autoInit} is true.
|
|
205
|
+
* If this is not desired it can be prevented by changing the named area via a meta tag, however in this case this will only effect the queue routing and not the configuration.
|
|
206
|
+
* Alternatively you can disable the auto init.
|
|
207
|
+
*
|
|
208
|
+
* @see {@link UnbluEmbeddedAppElement.ATTR_NAMED_AREA} to set this as an attribute
|
|
209
|
+
* @param namedArea
|
|
210
|
+
*/
|
|
211
|
+
set namedArea(namedArea) {
|
|
212
|
+
namedArea = UnbluUtil.sanitizeParameter(namedArea);
|
|
213
|
+
if (this._namedArea === namedArea) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
this._namedArea = namedArea;
|
|
217
|
+
this.autoReinitIfEnabled();
|
|
218
|
+
}
|
|
219
|
+
get namedArea() {
|
|
220
|
+
return this._namedArea;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* The access token used to log the user in before initializing Unblu.
|
|
224
|
+
*
|
|
225
|
+
* **Note**: Changes to this property trigger a reinitialization of Unblu if {@link UnbluEmbeddedAppElement.autoInit} is true.
|
|
226
|
+
*
|
|
227
|
+
* @see {@link UnbluEmbeddedAppElement.ATTR_ACCESS_TOKEN} to set this as an attribute
|
|
228
|
+
* @param accessToken
|
|
229
|
+
*/
|
|
230
|
+
set accessToken(accessToken) {
|
|
231
|
+
accessToken = UnbluUtil.sanitizeParameter(accessToken);
|
|
232
|
+
if (this._accessToken === accessToken) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
this._accessToken = accessToken;
|
|
236
|
+
this.autoReinitIfEnabled();
|
|
237
|
+
}
|
|
238
|
+
get accessToken() {
|
|
239
|
+
return this._accessToken;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Opens the conversation for the given conversation ID.
|
|
243
|
+
*
|
|
244
|
+
* This can be set already before Unblu is initialized.
|
|
245
|
+
* The conversation will then be opened as soon as Unblu gets initialized.
|
|
246
|
+
*
|
|
247
|
+
* If the conversation doesn't exist or the user doesn't have the right to access it, a dialog will be displayed with the respective error message.
|
|
248
|
+
* In such a case the conversation ID will be reset to `null`.
|
|
249
|
+
*
|
|
250
|
+
* @see {@link UnbluEmbeddedAppElement.ATTR_CONVERSATION_ID} to set this as an attribute
|
|
251
|
+
* @param conversationId The id of the conversation to open
|
|
252
|
+
*/
|
|
253
|
+
set conversationId(conversationId) {
|
|
254
|
+
conversationId = UnbluUtil.sanitizeParameter(conversationId);
|
|
255
|
+
this._conversationId = conversationId;
|
|
256
|
+
if (this._initializedApi) {
|
|
257
|
+
// noinspection JSIgnoredPromiseFromCall
|
|
258
|
+
this._initializedApi.openConversation(conversationId);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
get conversationId() {
|
|
262
|
+
return this._conversationId;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Sets the view mode of the embedded app element.
|
|
266
|
+
*
|
|
267
|
+
* Depending on the view mode the UI is displayed the following way:
|
|
268
|
+
* - {@link ViewMode.SPLIT}: The UI will be divided into two parts.
|
|
269
|
+
* The list of conversations is displayed on the left and the active conversation on the right side.
|
|
270
|
+
*
|
|
271
|
+
* - {@link ViewMode.SINGLE}: Both the conversation list and the active conversation will be displayed in the same view using UI navigation to switch between them.
|
|
272
|
+
*
|
|
273
|
+
* - {@link ViewMode.AUTO}: The UI will automatically switch back and forth between the two other modes depending on the available width.
|
|
274
|
+
* The trigger point when to switch between the two modes can be configured on the Unblu collaboration server.
|
|
275
|
+
*
|
|
276
|
+
* This value can be set even if the API is not initialized yet.
|
|
277
|
+
* The value will then be applied on initialization.
|
|
278
|
+
*
|
|
279
|
+
* @see {@link UnbluEmbeddedAppElement.ATTR_VIEW_MODE} to set this as an attribute
|
|
280
|
+
* @see {@link UnbluEmbeddedApi.setViewMode} to set this on the initialized {@link UnbluEmbeddedApi}
|
|
281
|
+
* @param viewMode The new view mode to use
|
|
282
|
+
* @default {@link ViewMode.AUTO}
|
|
283
|
+
*/
|
|
284
|
+
set viewMode(viewMode) {
|
|
285
|
+
if (viewMode == null) {
|
|
286
|
+
viewMode = ViewMode.AUTO;
|
|
287
|
+
}
|
|
288
|
+
this._viewMode = viewMode;
|
|
289
|
+
if (this._initializedApi) {
|
|
290
|
+
// noinspection JSIgnoredPromiseFromCall
|
|
291
|
+
this._initializedApi.setViewMode(viewMode);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
get viewMode() {
|
|
295
|
+
if (this._viewMode) {
|
|
296
|
+
return this._viewMode;
|
|
297
|
+
}
|
|
298
|
+
return ViewMode.AUTO;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* When this attribute is set to true, the embedded app element will ignore the position and size set to its element and will used fixed positioning to display itself to cover the whole website.
|
|
302
|
+
*
|
|
303
|
+
* This is useful when the user is currently in a call.
|
|
304
|
+
*
|
|
305
|
+
* This can be set even if the API is not initialized yet.
|
|
306
|
+
* The value will then be applied on initialization.
|
|
307
|
+
*
|
|
308
|
+
* **Note**: The user itself can also toggle this inside the UI.
|
|
309
|
+
*
|
|
310
|
+
* @see {@link UnbluEmbeddedAppElement.ATTR_FULLSCREEN} to set this as an attribute
|
|
311
|
+
* @see {@link UnbluEmbeddedApi.setFullscreen} to set this on the initialized {@link UnbluEmbeddedApi}
|
|
312
|
+
* @param fullscreen True to enable fullscreen, false otherwise.
|
|
313
|
+
*
|
|
314
|
+
* @default false
|
|
315
|
+
*/
|
|
316
|
+
set fullscreen(fullscreen) {
|
|
317
|
+
this._fullscreen = fullscreen;
|
|
318
|
+
if (this._initializedApi) {
|
|
319
|
+
// noinspection JSIgnoredPromiseFromCall
|
|
320
|
+
this._initializedApi.setFullscreen(fullscreen);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
get fullscreen() {
|
|
324
|
+
if (this._fullscreen) {
|
|
325
|
+
return this._fullscreen;
|
|
326
|
+
}
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* The timeout im milliseconds that should be waited for the Unblu integration to load.
|
|
331
|
+
*
|
|
332
|
+
* @default 30'000 (30 seconds).
|
|
333
|
+
*
|
|
334
|
+
* @see {@link UnbluEmbeddedAppElement.ATTR_INIT_TIMEOUT} to set this as an attribute
|
|
335
|
+
* @param initTimeout
|
|
336
|
+
*/
|
|
337
|
+
set initTimeout(initTimeout) {
|
|
338
|
+
this._initTimeout = initTimeout;
|
|
339
|
+
}
|
|
340
|
+
get initTimeout() {
|
|
341
|
+
return this._initTimeout;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Defines if Unblu automatically tries to (re-)initialize as soon as an attribute or property changes that triggers (re-)initialization.
|
|
345
|
+
* Attributes/properties that trigger a (re-)initialization have a note in their documentation.
|
|
346
|
+
* At least the attribute {@link ATTR_API_KEY} or property {@link UnbluEmbeddedAppElement.apiKey} has to be configured to trigger an initialization.
|
|
347
|
+
*
|
|
348
|
+
* If this property gets set from false to true, it will automatically initialize if it is not already initialized.
|
|
349
|
+
* If it is already initialized, it will NOT deinitialize.
|
|
350
|
+
*
|
|
351
|
+
* @default true.
|
|
352
|
+
*
|
|
353
|
+
* @see {@link UnbluEmbeddedAppElement.ATTR_AUTO_INIT} to set this as an attribute
|
|
354
|
+
* @param autoInit
|
|
355
|
+
*/
|
|
356
|
+
set autoInit(autoInit) {
|
|
357
|
+
if (this._autoInit === autoInit) {
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
this._autoInit = autoInit;
|
|
361
|
+
if (autoInit && (this.apiState === ApiState.INITIAL || this.apiState === ApiState.DEINITIALIZING || this.apiState === ApiState.DEINITIALIZED)) {
|
|
362
|
+
this.autoReinitIfEnabled();
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
get autoInit() {
|
|
366
|
+
return this._autoInit;
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* The current state of the API.
|
|
370
|
+
* @see {@link UnbluEmbeddedAppElement.STATE_CHANGE} to listen for changes or use one of the following for specific states.
|
|
371
|
+
* @see {@link UnbluEmbeddedAppElement.READY} for {@link ApiState.INITIALIZED}
|
|
372
|
+
* @see {@link UnbluEmbeddedAppElement.DEINITIALIZING} for {@link ApiState.DEINITIALIZING}
|
|
373
|
+
* @see {@link UnbluEmbeddedAppElement.DEINITIALIZED} for {@link ApiState.DEINITIALIZED}
|
|
374
|
+
* @see {@link UnbluEmbeddedAppElement.ERROR} for {@link ApiState.ERROR}
|
|
375
|
+
*
|
|
376
|
+
* @readonly
|
|
377
|
+
*/
|
|
378
|
+
get apiState() {
|
|
379
|
+
return this._state;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Initializes the app element to connect to the configured collaboration server and load the UI.
|
|
383
|
+
*
|
|
384
|
+
* If the API is already initializing or fully initialized, additional calls to this function will return the same instance of {@link UnbluEmbeddedApi}.
|
|
385
|
+
*
|
|
386
|
+
* This needs to be called if {@link UnbluEmbeddedAppElement.autoInit} is set to false.
|
|
387
|
+
*
|
|
388
|
+
* @return UnbluEmbeddedApi after initialization was successful
|
|
389
|
+
*
|
|
390
|
+
* @see {@link UnbluEmbeddedAppElement.deinitialize}
|
|
391
|
+
* @see {@link UnbluEmbeddedApi.deinitialize}
|
|
392
|
+
*/
|
|
393
|
+
async initialize() {
|
|
394
|
+
return this.internalInitialize(true);
|
|
395
|
+
}
|
|
396
|
+
// noinspection JSUnusedGlobalSymbols
|
|
397
|
+
async connectedCallback() {
|
|
398
|
+
console.debug("connectedCallback");
|
|
399
|
+
this._connected = true;
|
|
400
|
+
if (this._autoInit) {
|
|
401
|
+
await this.internalInitialize(false);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
// noinspection JSUnusedGlobalSymbols
|
|
405
|
+
adoptedCallback() {
|
|
406
|
+
console.debug("adoptedCallback");
|
|
407
|
+
}
|
|
408
|
+
// noinspection JSUnusedGlobalSymbols
|
|
409
|
+
async disconnectedCallback() {
|
|
410
|
+
console.debug("disconnectedCallback");
|
|
411
|
+
this._connected = false;
|
|
412
|
+
await this.deinitialize();
|
|
413
|
+
}
|
|
414
|
+
isConfigured() {
|
|
415
|
+
return this.apiKey != null && this.apiKey.length > 0;
|
|
416
|
+
}
|
|
417
|
+
async internalInitialize(explicit) {
|
|
418
|
+
console.debug("initialize");
|
|
419
|
+
if (this._initialization) {
|
|
420
|
+
return this._initialization;
|
|
421
|
+
}
|
|
422
|
+
if (!this._connected) {
|
|
423
|
+
console.log("Initialize request is not executed as the element is not attached to the DOM.");
|
|
424
|
+
if (explicit) {
|
|
425
|
+
//throw an error as it was explicitly triggered from the outside
|
|
426
|
+
throw new UnbluApiError(UnbluErrorType.CONFIGURATION_MISSING, 'Error initializing Unblu as the element is not attached to the DOM!');
|
|
427
|
+
}
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
if (!this.isConfigured()) {
|
|
431
|
+
console.log("Initialize request is not executed as the element is not configured.");
|
|
432
|
+
if (explicit) {
|
|
433
|
+
//throw an error as it was explicitly triggered from the outside
|
|
434
|
+
throw new UnbluApiError(UnbluErrorType.CONFIGURATION_MISSING, 'Error initializing Unblu as configuration is missing!');
|
|
435
|
+
}
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
if (!(this.apiState === ApiState.INITIAL || this.apiState === ApiState.DEINITIALIZING || this.apiState === ApiState.DEINITIALIZED)) {
|
|
439
|
+
console.log("Initialize request is not executed as apiState is wrong. ApiState: ", this.apiState);
|
|
440
|
+
if (explicit) {
|
|
441
|
+
//throw an error as it was explicitly triggered from the outside
|
|
442
|
+
throw new UnbluApiError(UnbluErrorType.ILLEGAL_STATE, 'Error initializing Unblu as it is in the wrong state! ApiState: ' + this.apiState + '. It may needs to be properly deinitialized first');
|
|
443
|
+
}
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
return this._initialization = new Promise(async (resolve, reject) => {
|
|
447
|
+
if (this.apiState == ApiState.DEINITIALIZING) {
|
|
448
|
+
//wait for the deinitialization to finish
|
|
449
|
+
try {
|
|
450
|
+
await this.deinitialize();
|
|
451
|
+
}
|
|
452
|
+
catch (e) {
|
|
453
|
+
console.debug("Error while waiting for deinit during initialization request", e);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
try {
|
|
457
|
+
await this.internalStartUp();
|
|
458
|
+
this.setApiState(ApiState.INITIALIZED);
|
|
459
|
+
this.dispatchEvent(new CustomEvent(UnbluEmbeddedAppElement.READY, { detail: this._initializedApi }));
|
|
460
|
+
resolve(this._initializedApi);
|
|
461
|
+
}
|
|
462
|
+
catch (e) {
|
|
463
|
+
this.handleStartupError(e);
|
|
464
|
+
reject(e);
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
async internalStartUp() {
|
|
469
|
+
this.setApiState(ApiState.INITIALIZING);
|
|
470
|
+
this._configuration = this.createConfigFromProperties();
|
|
471
|
+
await UnbluUtil.deinitializeFloatingIfNeeded();
|
|
472
|
+
await UnbluUtil.deinitializeEmbeddedIfNeeded(this);
|
|
473
|
+
if (!UnbluUtil.isUnbluLoaded(IntegrationType.embedded)) {
|
|
474
|
+
if (this._configuration.namedArea) {
|
|
475
|
+
UnbluUtil.setNamedArea(this._configuration.namedArea);
|
|
476
|
+
}
|
|
477
|
+
if (this._configuration.locale) {
|
|
478
|
+
UnbluUtil.setLocale(this._configuration.locale);
|
|
479
|
+
}
|
|
480
|
+
if (this.accessToken) {
|
|
481
|
+
await UnbluUtil.loginWithSecureToken(this._configuration.serverUrl || '', this._configuration.apiKey, this._configuration.entryPath || '/unblu', this._configuration.accessToken);
|
|
482
|
+
}
|
|
483
|
+
await UnbluEmbeddedAppElement.injectUnblu(this._configuration);
|
|
484
|
+
}
|
|
485
|
+
const apiBridge = new ApiBridge(UnbluUtil.getUnbluObject(), 'internal-embedded');
|
|
486
|
+
await apiBridge.waitUntilLoaded(this._configuration.initTimeout || 30000);
|
|
487
|
+
const internalApi = new InternalEmbeddedApi(apiBridge, this._configuration);
|
|
488
|
+
internalApi.checkCompatibility();
|
|
489
|
+
await internalApi.meta.setUnbluEmbeddedAppElement(this);
|
|
490
|
+
// Check internalApi waitUntilInitialized
|
|
491
|
+
await internalApi.meta.waitUntilInitialized();
|
|
492
|
+
this._initializedApi = new UnbluEmbeddedApi(internalApi);
|
|
493
|
+
//conversation id and fullscreen will be overwritten by the populatePropertiesAndEvents as it waits for the current value
|
|
494
|
+
const conversationIdToOpen = this._conversationId;
|
|
495
|
+
const fullscreenToSet = this._fullscreen;
|
|
496
|
+
const viewModeToSet = this._viewMode;
|
|
497
|
+
await this.populatePropertiesAndEvents();
|
|
498
|
+
if (conversationIdToOpen) {
|
|
499
|
+
try {
|
|
500
|
+
await this._initializedApi.openConversation(conversationIdToOpen);
|
|
501
|
+
}
|
|
502
|
+
catch (e) {
|
|
503
|
+
console.log("Could not open conversation from attr/property", e);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
//only set the values if they were really defined
|
|
507
|
+
if (fullscreenToSet !== undefined) {
|
|
508
|
+
this.fullscreen = fullscreenToSet;
|
|
509
|
+
}
|
|
510
|
+
if (viewModeToSet !== undefined) {
|
|
511
|
+
this.viewMode = viewModeToSet;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
createConfigFromProperties() {
|
|
515
|
+
return {
|
|
516
|
+
apiKey: this.apiKey,
|
|
517
|
+
serverUrl: this.serverUrl,
|
|
518
|
+
entryPath: this.entryPath,
|
|
519
|
+
locale: this.locale,
|
|
520
|
+
namedArea: this.namedArea,
|
|
521
|
+
initTimeout: this.initTimeout,
|
|
522
|
+
accessToken: this.accessToken
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
static async injectUnblu(config) {
|
|
526
|
+
const serverUrl = config.serverUrl || '';
|
|
527
|
+
const apiKey = config.apiKey;
|
|
528
|
+
const unbluPath = config.entryPath || '/unblu';
|
|
529
|
+
let unbluUrl = `${serverUrl}${unbluPath}/embedded-visitor.js?x-unblu-apikey=${apiKey}`;
|
|
530
|
+
try {
|
|
531
|
+
await UnbluUtil.loadScript(unbluUrl, config.initTimeout);
|
|
532
|
+
}
|
|
533
|
+
catch (e) {
|
|
534
|
+
throw new UnbluApiError(UnbluErrorType.ERROR_LOADING_UNBLU, 'Error loading unblu snippet: ' + e + ' check the configuration.');
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
handleStartupError(error) {
|
|
538
|
+
this._initialization = null;
|
|
539
|
+
this._initializedApi = null;
|
|
540
|
+
this.setApiState(ApiState.ERROR);
|
|
541
|
+
this.dispatchEvent(new CustomEvent(UnbluEmbeddedAppElement.ERROR, { detail: error }));
|
|
542
|
+
//this.eventEmitter.emit(ApiState.ERROR, error)
|
|
543
|
+
if (UnbluErrorType.UNSUPPORTED_BROWSER != error.type) {
|
|
544
|
+
console.error(error);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
async populatePropertiesAndEvents() {
|
|
548
|
+
await this._initializedApi.on(UnbluEmbeddedApi.ACTIVE_CONVERSATION_CHANGE, (conversation) => {
|
|
549
|
+
const conversationId = conversation ? conversation.getConversationId() : null;
|
|
550
|
+
this._conversationId = conversationId;
|
|
551
|
+
this.dispatchEvent(new CustomEvent(UnbluEmbeddedAppElement.ACTIVE_CONVERSATION_CHANGE, { detail: conversationId }));
|
|
552
|
+
});
|
|
553
|
+
await this._initializedApi.on(UnbluEmbeddedApi.FULLSCREEN_CHANGE, (fullscreen) => {
|
|
554
|
+
this._fullscreen = fullscreen;
|
|
555
|
+
this.dispatchEvent(new CustomEvent(UnbluEmbeddedAppElement.FULLSCREEN_CHANGE, { detail: fullscreen }));
|
|
556
|
+
});
|
|
557
|
+
await this._initializedApi.on(UnbluEmbeddedApi.VIEW_MODE_CHANGE, (viewMode) => {
|
|
558
|
+
this._viewMode = viewMode;
|
|
559
|
+
this.dispatchEvent(new CustomEvent(UnbluEmbeddedAppElement.VIEW_MODE_CHANGE, { detail: viewMode }));
|
|
560
|
+
});
|
|
561
|
+
// noinspection ES6MissingAwait
|
|
562
|
+
this._initializedApi.on(UnbluEmbeddedApi.DEINITIALIZING, () => {
|
|
563
|
+
this._conversationId = null;
|
|
564
|
+
this._initializedApi = null;
|
|
565
|
+
this._initialization = null;
|
|
566
|
+
this.setApiState(ApiState.DEINITIALIZING);
|
|
567
|
+
this.dispatchEvent(new CustomEvent(UnbluEmbeddedAppElement.DEINITIALIZING, { detail: null }));
|
|
568
|
+
});
|
|
569
|
+
// noinspection ES6MissingAwait
|
|
570
|
+
this._initializedApi.on(UnbluEmbeddedApi.DEINITIALIZED, () => {
|
|
571
|
+
this.setApiState(ApiState.DEINITIALIZED);
|
|
572
|
+
this.dispatchEvent(new CustomEvent(UnbluEmbeddedAppElement.DEINITIALIZED, { detail: null }));
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
setApiState(apiState) {
|
|
576
|
+
this._state = apiState;
|
|
577
|
+
this.dispatchEvent(new CustomEvent(UnbluEmbeddedAppElement.STATE_CHANGE, { detail: apiState }));
|
|
578
|
+
}
|
|
579
|
+
autoReinitIfEnabled() {
|
|
580
|
+
clearTimeout(this._reinitTrigger);
|
|
581
|
+
if (!this.autoInit || !this._connected) {
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
this._reinitTrigger = window.setTimeout(async () => {
|
|
585
|
+
this._reinitTrigger = -1;
|
|
586
|
+
await this.deinitialize();
|
|
587
|
+
await this.internalInitialize(false);
|
|
588
|
+
}, 0);
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Deinitializes the app element and destroys all of its containing UI.
|
|
592
|
+
* By changing one of the attributes that trigger a reinitialization (e.g. {@link UnbluEmbeddedAppElement.apiKey}) the app element will be automatically initialized again (if the value is really changed).
|
|
593
|
+
*
|
|
594
|
+
* **Note**: Calling this method will not remove the element itself out of the DOM.
|
|
595
|
+
*/
|
|
596
|
+
deinitialize() {
|
|
597
|
+
console.debug("deinitialize");
|
|
598
|
+
if (this._ongoingDeinitialization) {
|
|
599
|
+
return this._ongoingDeinitialization;
|
|
600
|
+
}
|
|
601
|
+
if (this.apiState === ApiState.INITIAL || this.apiState === ApiState.DEINITIALIZED) {
|
|
602
|
+
//nothing to do in this case
|
|
603
|
+
return Promise.resolve();
|
|
604
|
+
}
|
|
605
|
+
return this._ongoingDeinitialization = new Promise(async (resolve, reject) => {
|
|
606
|
+
if (this.apiState === ApiState.INITIALIZING) {
|
|
607
|
+
//wait for the initialization to be done
|
|
608
|
+
try {
|
|
609
|
+
await this.initialize();
|
|
610
|
+
}
|
|
611
|
+
catch (e) {
|
|
612
|
+
console.debug("Error while waiting for init during deinitialization request", e);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
//deinitialize
|
|
616
|
+
try {
|
|
617
|
+
if (this._initializedApi) {
|
|
618
|
+
if (this._configuration.namedArea) {
|
|
619
|
+
UnbluUtil.removeNamedArea();
|
|
620
|
+
}
|
|
621
|
+
await this._initializedApi.deinitialize();
|
|
622
|
+
}
|
|
623
|
+
this._ongoingDeinitialization = null;
|
|
624
|
+
}
|
|
625
|
+
catch (e) {
|
|
626
|
+
this._ongoingDeinitialization = null;
|
|
627
|
+
this._initializedApi = null;
|
|
628
|
+
this._initialization = null;
|
|
629
|
+
reject(e);
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
resolve();
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Event emitted whenever the API state changes
|
|
638
|
+
*
|
|
639
|
+
* @see {@link StateChangeEvent} for the event type
|
|
640
|
+
* @see {@link UnbluEmbeddedAppElement.addEventListener} for listener registration
|
|
641
|
+
* @see {@link UnbluEmbeddedAppElement.removeEventListener} to remove a listener
|
|
642
|
+
* @event stateChange
|
|
643
|
+
*/
|
|
644
|
+
UnbluEmbeddedAppElement.STATE_CHANGE = 'stateChange';
|
|
645
|
+
/**
|
|
646
|
+
* Event emitted as soon as the API is initialized.
|
|
647
|
+
*
|
|
648
|
+
* It usually makes sense to use this event to wait for APIs on this element to be ready. E.g. the {@link UnbluEmbeddedAppElement.personInfo} or {@link UnbluEmbeddedAppElement.agentAvailable}.
|
|
649
|
+
* You will find a note in the documentation of the properties when they are only available after initialization.
|
|
650
|
+
*
|
|
651
|
+
* @see {@link ReadyEvent} for the event type
|
|
652
|
+
* @see {@link UnbluEmbeddedAppElement.addEventListener} for listener registration
|
|
653
|
+
* @see {@link UnbluEmbeddedAppElement.removeEventListener} to remove a listener
|
|
654
|
+
* @event ready
|
|
655
|
+
*/
|
|
656
|
+
UnbluEmbeddedAppElement.READY = 'ready';
|
|
657
|
+
/**
|
|
658
|
+
* Event emitted if the API initialization fails.
|
|
659
|
+
*
|
|
660
|
+
* It usually makes sense to use this event if there is some general action that has to be triggered when the API initialization fails.
|
|
661
|
+
*
|
|
662
|
+
* @see {@link ErrorEvent} for the event type
|
|
663
|
+
* @see {@link UnbluEmbeddedAppElement.addEventListener} for listener registration
|
|
664
|
+
* @see {@link UnbluEmbeddedAppElement.removeEventListener} to remove a listener
|
|
665
|
+
* @event error
|
|
666
|
+
*/
|
|
667
|
+
UnbluEmbeddedAppElement.ERROR = 'error';
|
|
668
|
+
/**
|
|
669
|
+
* Event emitted when the de-initialization of the API is started..
|
|
670
|
+
*
|
|
671
|
+
* It usually makes sense to use this event to clean up resources and/or unregistering of listeners so they don't try to use the API again until it is initialized again.
|
|
672
|
+
*
|
|
673
|
+
* @see {@link DeinitializationStartedEvent} for the event type
|
|
674
|
+
* @see {@link UnbluEmbeddedAppElement.addEventListener} for listener registration
|
|
675
|
+
* @see {@link UnbluEmbeddedAppElement.removeEventListener} to remove a listener
|
|
676
|
+
* @see {@link UnbluEmbeddedApi.DEINITIALIZING} for the event on the initialized {@link UnbluEmbeddedApi} instance
|
|
677
|
+
* @event deinitializing
|
|
678
|
+
*/
|
|
679
|
+
UnbluEmbeddedAppElement.DEINITIALIZING = 'deinitializing';
|
|
680
|
+
/**
|
|
681
|
+
* Event emitted when the de-initialization of the API has finished.
|
|
682
|
+
*
|
|
683
|
+
* It usually makes sense to use this event if a re-initialization is required after de-init.
|
|
684
|
+
*
|
|
685
|
+
* @see {@link DeinitializationFinishedEvent} for the event type
|
|
686
|
+
* @see {@link UnbluEmbeddedAppElement.addEventListener} for listener registration
|
|
687
|
+
* @see {@link UnbluEmbeddedAppElement.removeEventListener} to remove a listener
|
|
688
|
+
* @see {@link UnbluEmbeddedApi.DEINITIALIZED} for the event on the initialized {@link UnbluEmbeddedApi} instance
|
|
689
|
+
* @event deinitialized
|
|
690
|
+
*/
|
|
691
|
+
UnbluEmbeddedAppElement.DEINITIALIZED = 'deinitialized';
|
|
692
|
+
/**
|
|
693
|
+
* Event emitted every time one of the conversations accessible to the current user changes or one is added or removed.
|
|
694
|
+
*
|
|
695
|
+
* @see {@link ActiveConversationChangeEvent} for the event type
|
|
696
|
+
* @see {@link UnbluEmbeddedAppElement.addEventListener} for listener registration
|
|
697
|
+
* @see {@link UnbluEmbeddedAppElement.removeEventListener} to remove a listener
|
|
698
|
+
* @see {@link UnbluEmbeddedApi.ACTIVE_CONVERSATION_CHANGE} for the event on the initialized {@link UnbluEmbeddedApi} instance
|
|
699
|
+
* @event activeConversationChange
|
|
700
|
+
*/
|
|
701
|
+
UnbluEmbeddedAppElement.ACTIVE_CONVERSATION_CHANGE = 'activeConversationChange';
|
|
702
|
+
/**
|
|
703
|
+
* Event emitted every time the embedded app switches to fullscreen mode or back.
|
|
704
|
+
*
|
|
705
|
+
* @see {@link UnbluEmbeddedAppElement.FULLSCREEN_CHANGE}
|
|
706
|
+
* @see {@link UnbluEmbeddedAppElement.addEventListener}
|
|
707
|
+
* @see {@link UnbluEmbeddedAppElement.removeEventListener}
|
|
708
|
+
* @see {@link UnbluEmbeddedApi.FULLSCREEN_CHANGE} for the event on the initialized {@link UnbluEmbeddedApi} instance
|
|
709
|
+
* @event fullscreenChange
|
|
710
|
+
*/
|
|
711
|
+
UnbluEmbeddedAppElement.FULLSCREEN_CHANGE = 'fullscreenChange';
|
|
712
|
+
/**
|
|
713
|
+
* Event emitted every time the view mode changes.
|
|
714
|
+
*
|
|
715
|
+
* @see {@link UnbluEmbeddedAppElement.VIEW_MODE_CHANGE}
|
|
716
|
+
* @see {@link UnbluEmbeddedAppElement.addEventListener}
|
|
717
|
+
* @see {@link UnbluEmbeddedAppElement.removeEventListener}
|
|
718
|
+
* @see {@link UnbluEmbeddedApi.VIEW_MODE_CHANGE} for the event on the initialized {@link UnbluEmbeddedApi} instance
|
|
719
|
+
* @event viewModeChange
|
|
720
|
+
*/
|
|
721
|
+
UnbluEmbeddedAppElement.VIEW_MODE_CHANGE = 'viewModeChange';
|
|
722
|
+
/**
|
|
723
|
+
* The URL to the collaboration server.
|
|
724
|
+
*
|
|
725
|
+
* If not specified it is assumed that the server is reachable on the domain of the current webpage at the defined {@link UnbluEmbeddedAppElement.entryPath}
|
|
726
|
+
*
|
|
727
|
+
* **Note**: Changes to this attribute trigger a reinitialization of Unblu if {@link UnbluEmbeddedAppElement.ATTR_AUTO_INIT} is true.
|
|
728
|
+
*
|
|
729
|
+
* @see {@link UnbluEmbeddedAppElement.serverUrl} to set or get this via a property
|
|
730
|
+
*/
|
|
731
|
+
UnbluEmbeddedAppElement.ATTR_SERVER_URL = 'server-url';
|
|
732
|
+
/**
|
|
733
|
+
* The path pointing to the root of the Unblu collaboration server.
|
|
734
|
+
*
|
|
735
|
+
* @default "/unblu".
|
|
736
|
+
*
|
|
737
|
+
* **Note**: Changes to this attribute trigger a reinitialization of Unblu if {@link UnbluEmbeddedAppElement.ATTR_AUTO_INIT} is true.
|
|
738
|
+
*
|
|
739
|
+
* @see {@link UnbluEmbeddedAppElement.entryPath} to set or get this via a property
|
|
740
|
+
*/
|
|
741
|
+
UnbluEmbeddedAppElement.ATTR_ENTRY_PATH = 'entry-path';
|
|
742
|
+
/**
|
|
743
|
+
* The API Key to connect this app with a specific Unblu account
|
|
744
|
+
* This is the minimum configuration that has to be done to trigger the initialization of Unblu.
|
|
745
|
+
*
|
|
746
|
+
* **Note**: Changes to this attribute trigger a reinitialization of Unblu if {@link UnbluEmbeddedAppElement.ATTR_AUTO_INIT} is true.
|
|
747
|
+
*
|
|
748
|
+
* @see {@link UnbluEmbeddedAppElement.apiKey} to set or get this via a property
|
|
749
|
+
*/
|
|
750
|
+
UnbluEmbeddedAppElement.ATTR_API_KEY = 'api-key';
|
|
751
|
+
/**
|
|
752
|
+
* The locale (language) used for all Unblu UIs.
|
|
753
|
+
* If not specified this is derived from the webpage or the browser.
|
|
754
|
+
*
|
|
755
|
+
* **Note**: Changes to this attribute trigger a reinitialization of Unblu if {@link UnbluEmbeddedAppElement.ATTR_AUTO_INIT} is true.
|
|
756
|
+
*
|
|
757
|
+
* @see [https://www.unblu.com/en/docs/4.3/articles/installation-and-operation/selecting-the-language.html | Setting the Language / Locale] for more information on the detection.
|
|
758
|
+
* @see {@link UnbluEmbeddedAppElement.locale} to set or get this via a property
|
|
759
|
+
*/
|
|
760
|
+
UnbluEmbeddedAppElement.ATTR_LOCALE = 'locale';
|
|
761
|
+
/**
|
|
762
|
+
* The named area for which the configuration should be loaded and with which new queue requests will be labeled.
|
|
763
|
+
* If not specified this can be derived from the corresponding meta tag on the webpage or the domain.
|
|
764
|
+
*
|
|
765
|
+
* **Note**: Changes to this attribute trigger a reinitialization of Unblu if {@link UnbluEmbeddedAppElement.ATTR_AUTO_INIT} is true.
|
|
766
|
+
* If this is not desired it can be prevented by changing the named area via a meta tag, however in this case this will only effect the queue routing and not the configuration.
|
|
767
|
+
* Alternatively you can disable the automatic initialization.
|
|
768
|
+
*
|
|
769
|
+
* @see {@link https://www.unblu.com/en/docs/latest/knowledge-base/named-areas.html | Named Area} for further details.
|
|
770
|
+
* @see {@link UnbluEmbeddedAppElement.namedArea} to set or get this via a property
|
|
771
|
+
*/
|
|
772
|
+
UnbluEmbeddedAppElement.ATTR_NAMED_AREA = 'named-area';
|
|
773
|
+
/**
|
|
774
|
+
* The access token used to log the user in before initializing Unblu.
|
|
775
|
+
*
|
|
776
|
+
* **Note**: Changes to this attribute trigger a reinitialization of Unblu if {@link UnbluEmbeddedAppElement.ATTR_AUTO_INIT} is true.
|
|
777
|
+
*
|
|
778
|
+
* @see {@link UnbluEmbeddedAppElement.accessToken} to set or get this via a property
|
|
779
|
+
*/
|
|
780
|
+
UnbluEmbeddedAppElement.ATTR_ACCESS_TOKEN = 'access-token';
|
|
781
|
+
/**
|
|
782
|
+
* Opens the conversation with the specified ID.
|
|
783
|
+
* If Unblu is not initialized yet, it will wait for the initialization and then automatically open the specified conversation.
|
|
784
|
+
* If Unblu is already initialized, the conversation will be opened directly.
|
|
785
|
+
*
|
|
786
|
+
* If the conversation doesn't exist or the user doesn't have the right to access it, a dialog will be displayed with the respective error message.
|
|
787
|
+
*
|
|
788
|
+
* @see {@link UnbluEmbeddedAppElement.openConversation} to set this value and also retrieve a promise to know, when the conversation was opened.
|
|
789
|
+
* @see {@link UnbluEmbeddedAppElement.conversationId} to read the value as property. This will always represent the currently opened conversation.
|
|
790
|
+
*/
|
|
791
|
+
UnbluEmbeddedAppElement.ATTR_CONVERSATION_ID = 'conversation-id';
|
|
792
|
+
/**
|
|
793
|
+
* Sets the view mode of the embedded app element.
|
|
794
|
+
*
|
|
795
|
+
* Depending on the view mode the UI is displayed the following way:
|
|
796
|
+
* - {@link ViewMode.SPLIT}: The UI will be divided into two parts.
|
|
797
|
+
* The list of conversations is displayed on the left and the active conversation on the right side.
|
|
798
|
+
*
|
|
799
|
+
* - {@link ViewMode.SINGLE}: Both the conversation list and the active conversation will be displayed in the same view using UI navigation to switch between them.
|
|
800
|
+
*
|
|
801
|
+
* - {@link ViewMode.AUTO}: The UI will automatically switch back and forth between the two other modes depending on the available width.
|
|
802
|
+
* The trigger point when to switch between the two modes can be configured on the Unblu collaboration server.
|
|
803
|
+
*
|
|
804
|
+
* This value can be set even if the API is not initialized yet.
|
|
805
|
+
* The value will then be applied on initialization.
|
|
806
|
+
*
|
|
807
|
+
* @see {@link UnbluEmbeddedAppElement.viewMode} to set or get this via a property
|
|
808
|
+
* @default {@link ViewMode.AUTO}
|
|
809
|
+
*/
|
|
810
|
+
UnbluEmbeddedAppElement.ATTR_VIEW_MODE = 'view-mode';
|
|
811
|
+
/**
|
|
812
|
+
* When this attribute is set to true, the embedded app will ignore the position and size set to its element and will used fixed positioning to display itself to cover the whole website.
|
|
813
|
+
*
|
|
814
|
+
* This is useful when the user is currently in a call.
|
|
815
|
+
*
|
|
816
|
+
* This can be set even if the API is not initialized yet.
|
|
817
|
+
* The value will then be applied on initialization.
|
|
818
|
+
*
|
|
819
|
+
* **Note**: The user itself can also toggle this inside the UI.
|
|
820
|
+
*
|
|
821
|
+
* @see {@link UnbluEmbeddedAppElement.fullscreen} to set or get this via a property
|
|
822
|
+
* @default false
|
|
823
|
+
*/
|
|
824
|
+
UnbluEmbeddedAppElement.ATTR_FULLSCREEN = 'fullscreen';
|
|
825
|
+
/**
|
|
826
|
+
* The timeout im milliseconds that should be waited for the Unblu integration to load.
|
|
827
|
+
*
|
|
828
|
+
* @default 30'000 (30 seconds).
|
|
829
|
+
*
|
|
830
|
+
* @see {@link UnbluEmbeddedAppElement.initTimeout} to set or get this via a property
|
|
831
|
+
*/
|
|
832
|
+
UnbluEmbeddedAppElement.ATTR_INIT_TIMEOUT = 'init-timeout';
|
|
833
|
+
/**
|
|
834
|
+
* Defines if Unblu automatically tries to (re-)initialize as soon as an attribute or property changes that triggers (re-)initialization.
|
|
835
|
+
*
|
|
836
|
+
* To trigger a initialization at least the attribute {@link ATTR_API_KEY} or property {@link UnbluEmbeddedAppElement.apiKey}.
|
|
837
|
+
*
|
|
838
|
+
* @default true.
|
|
839
|
+
*
|
|
840
|
+
* @see {@link UnbluEmbeddedAppElement.autoInit} to set or get this via a property
|
|
841
|
+
*/
|
|
842
|
+
UnbluEmbeddedAppElement.ATTR_AUTO_INIT = 'auto-init';
|
|
843
|
+
window.customElements.define('unblu-embedded-app', UnbluEmbeddedAppElement);
|
|
844
|
+
//# sourceMappingURL=unblu-embedded-app-element.js.map
|