@epam/ai-dial-overlay 0.45.0-rc.9 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.esm.js +25 -2
- package/package.json +2 -2
- package/src/lib/ChatOverlay.d.ts +12 -1
package/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { overlayAppName, OverlayEvents, Task, setStyles, overlayLibName, DeferredRequest, OverlayRequests } from '@epam/ai-dial-shared';
|
|
1
|
+
import { overlayAppName, OverlayEvents, Task, setStyles, Feature, overlayLibName, DeferredRequest, OverlayRequests } from '@epam/ai-dial-shared';
|
|
2
2
|
export { Feature, LikeState, OverlayEvents, PublishActions, Role, UploadStatus, overlayAppName } from '@epam/ai-dial-shared';
|
|
3
3
|
|
|
4
4
|
/******************************************************************************
|
|
@@ -120,6 +120,29 @@ class ChatOverlay {
|
|
|
120
120
|
this.showLoader();
|
|
121
121
|
window.addEventListener('message', this.process);
|
|
122
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Builds the iframe permissions policy string based on enabled features
|
|
125
|
+
* @returns {string} permissions policy string for the iframe `allow` attribute
|
|
126
|
+
*/
|
|
127
|
+
getIframePermissions() {
|
|
128
|
+
const permissions = ['clipboard-write'];
|
|
129
|
+
if (this.hasFeature(Feature.VoiceInput)) {
|
|
130
|
+
permissions.push('microphone');
|
|
131
|
+
}
|
|
132
|
+
return permissions.join('; ');
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Checks if a specific feature is included in the enabled features list
|
|
136
|
+
* @param feature {Feature} feature to check
|
|
137
|
+
* @returns {boolean} true if the feature is enabled
|
|
138
|
+
*/
|
|
139
|
+
hasFeature(feature) {
|
|
140
|
+
const features = this.options.enabledFeatures;
|
|
141
|
+
if (Array.isArray(features)) {
|
|
142
|
+
return features.includes(feature);
|
|
143
|
+
}
|
|
144
|
+
return typeof features === 'string' && features.includes(feature);
|
|
145
|
+
}
|
|
123
146
|
/**
|
|
124
147
|
* Creates iframe add set initial options to it
|
|
125
148
|
* @returns {HTMLIFrameElement} reference to iframe element
|
|
@@ -127,7 +150,7 @@ class ChatOverlay {
|
|
|
127
150
|
initIframe() {
|
|
128
151
|
const iframe = document.createElement('iframe');
|
|
129
152
|
iframe.src = this.options.domain;
|
|
130
|
-
iframe.allow =
|
|
153
|
+
iframe.allow = this.getIframePermissions();
|
|
131
154
|
iframe.name = 'overlay';
|
|
132
155
|
iframe.ariaLabel = 'Chat overlay';
|
|
133
156
|
iframe.sandbox.add('allow-same-origin');
|
package/package.json
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"name": "@epam/ai-dial-overlay",
|
|
3
3
|
"description": "Package for opening dial in overlay",
|
|
4
4
|
"homepage": "https://dialx.ai",
|
|
5
|
-
"version": "0.45.0
|
|
5
|
+
"version": "0.45.0",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@epam/ai-dial-shared": "0.45.0
|
|
7
|
+
"@epam/ai-dial-shared": "0.45.0"
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
10
|
"bugs": {
|
package/src/lib/ChatOverlay.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChatOverlayOptions, CreateConversationResponse, CreateLocalConversationResponse, CreatePlaybackConversationResponse, DeferredRequest, DeleteMessageResponse, ExportConversationResponse, GetConversationsResponse, GetMessagesResponse, GetSelectedConversationsResponse, ImportConversationResponse, LatestExportConversationsFormat, Message, OverlayRequest, OverlayRequests, RenameConversationResponse, SelectConversationResponse, SendMessageResponse, SetSystemPromptResponse, StopSelectedPlaybackConversationResponse, Styles, Task, UpdateMessageResponse } from '@epam/ai-dial-shared';
|
|
1
|
+
import { ChatOverlayOptions, CreateConversationResponse, CreateLocalConversationResponse, CreatePlaybackConversationResponse, DeferredRequest, DeleteMessageResponse, ExportConversationResponse, Feature, GetConversationsResponse, GetMessagesResponse, GetSelectedConversationsResponse, ImportConversationResponse, LatestExportConversationsFormat, Message, OverlayRequest, OverlayRequests, RenameConversationResponse, SelectConversationResponse, SendMessageResponse, SetSystemPromptResponse, StopSelectedPlaybackConversationResponse, Styles, Task, UpdateMessageResponse } from '@epam/ai-dial-shared';
|
|
2
2
|
interface Subscription {
|
|
3
3
|
eventType: string;
|
|
4
4
|
callback: (payload: unknown) => void;
|
|
@@ -21,6 +21,17 @@ export declare class ChatOverlay {
|
|
|
21
21
|
* @param options {ChatOverlayOptions} overlay options (incl. domain, hostDomain, theme, modelId, etc.)
|
|
22
22
|
*/
|
|
23
23
|
constructor(root: HTMLElement | string, options: ChatOverlayOptions);
|
|
24
|
+
/**
|
|
25
|
+
* Builds the iframe permissions policy string based on enabled features
|
|
26
|
+
* @returns {string} permissions policy string for the iframe `allow` attribute
|
|
27
|
+
*/
|
|
28
|
+
protected getIframePermissions(): string;
|
|
29
|
+
/**
|
|
30
|
+
* Checks if a specific feature is included in the enabled features list
|
|
31
|
+
* @param feature {Feature} feature to check
|
|
32
|
+
* @returns {boolean} true if the feature is enabled
|
|
33
|
+
*/
|
|
34
|
+
protected hasFeature(feature: Feature): boolean;
|
|
24
35
|
/**
|
|
25
36
|
* Creates iframe add set initial options to it
|
|
26
37
|
* @returns {HTMLIFrameElement} reference to iframe element
|