@epam/ai-dial-chat-overlay 1.1.0-dev.74 → 1.1.0-dev.78
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.d.ts +3 -3
- package/index.d.ts.map +1 -1
- package/index.js +84 -69
- package/lib/ChatOverlay.d.ts +10 -2
- package/lib/ChatOverlay.d.ts.map +1 -1
- package/lib/internal/deferred-request.d.ts +2 -0
- package/lib/internal/deferred-request.d.ts.map +1 -1
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { ChatOverlay } from './lib/ChatOverlay';
|
|
1
|
+
export { ChatOverlay, ChatOverlayRequestError } from './lib/ChatOverlay';
|
|
2
2
|
export { ChatOverlayManager, OverlayPosition } from './lib/ChatOverlayManager';
|
|
3
3
|
export type { ChatOverlayManagerOptions } from './lib/ChatOverlayManager';
|
|
4
|
-
export type { ChatOverlayOptions, CreateConversationPayload, CreateConversationResponse, CreateLocalConversationResponse, DeleteConversationPayload, DeleteConversationResponse, GetConversationsResponse, GetMessagesResponse, GetSelectedConversationsResponse, OverlayChatMessage, OverlayConversation, OverlayConversationError, RenameConversationPayload, RenameConversationResponse, SelectConversationPayload, SelectConversationResponse, SendMessageResponse, SetOverlayOptionsResponse, SetSystemPromptResponse, SetTemperatureResponse, } from '@epam/ai-dial-chat-shared';
|
|
5
|
-
export { OverlayEventType, OverlayFeature, OverlayRequestType, } from '@epam/ai-dial-chat-shared';
|
|
4
|
+
export type { ChatOverlayOptions, CreateConversationPayload, CreateConversationResponse, CreateLocalConversationResponse, DeleteConversationPayload, DeleteConversationResponse, GetConversationsResponse, GetMessagesResponse, GetSelectedConversationsResponse, OverlayChatMessage, OverlayConversation, OverlayConversationError, OverlayRequestError, RenameConversationPayload, RenameConversationResponse, SelectConversationPayload, SelectConversationResponse, SendMessageResponse, SetOverlayOptionsResponse, SetSystemPromptResponse, SetTemperatureResponse, } from '@epam/ai-dial-chat-shared';
|
|
5
|
+
export { OverlayAuthUiMode, OverlayEventType, OverlayFeature, OverlayRequestErrorCode, OverlayRequestType, } from '@epam/ai-dial-chat-shared';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC/E,YAAY,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAE1E,YAAY,EACV,kBAAkB,EAClB,yBAAyB,EACzB,0BAA0B,EAC1B,+BAA+B,EAC/B,yBAAyB,EACzB,0BAA0B,EAC1B,wBAAwB,EACxB,mBAAmB,EACnB,gCAAgC,EAChC,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,yBAAyB,EACzB,0BAA0B,EAC1B,yBAAyB,EACzB,0BAA0B,EAC1B,mBAAmB,EACnB,yBAAyB,EACzB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,2BAA2B,CAAC"}
|
package/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OverlayAuthUiMode as e, OverlayEventType as t, OverlayEventType as n, OverlayFeature as r, OverlayFeature as i, OverlayRequestErrorCode as a, OverlayRequestType as o, OverlayRequestType as s, isOverlayMessageEvent as c, isOverlayMessageResponse as l } from "@epam/ai-dial-chat-shared";
|
|
2
2
|
//#region src/lib/internal/default-loader.ts
|
|
3
|
-
var
|
|
3
|
+
var u = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentation\" aria-hidden=\"true\"><circle cx=\"25\" cy=\"25\" r=\"20\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"4\" stroke-linecap=\"round\" stroke-dasharray=\"31.4 31.4\"><animateTransform attributeName=\"transform\" type=\"rotate\" from=\"0 25 25\" to=\"360 25 25\" dur=\"1s\" repeatCount=\"indefinite\" /></circle></svg>", d = 0, f = () => (d += 1, `dial-overlay-${Date.now()}-${d}`), p = class {
|
|
4
|
+
requestType;
|
|
4
5
|
requestId;
|
|
5
6
|
responseType;
|
|
6
7
|
promise;
|
|
@@ -9,7 +10,7 @@ var c = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentati
|
|
|
9
10
|
settled = !1;
|
|
10
11
|
timeoutHandle;
|
|
11
12
|
constructor(e, t) {
|
|
12
|
-
this.requestId =
|
|
13
|
+
this.requestType = e, this.requestId = f(), this.responseType = `${e}/RESPONSE`, this.promise = new Promise((e, t) => {
|
|
13
14
|
this.resolveFn = e, this.rejectFn = t;
|
|
14
15
|
}), this.timeoutHandle = setTimeout(() => {
|
|
15
16
|
this.reject(/* @__PURE__ */ Error(`ChatOverlay: request "${e}" timed out after ${t}ms`));
|
|
@@ -24,9 +25,9 @@ var c = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentati
|
|
|
24
25
|
reject(e) {
|
|
25
26
|
this.settled || (this.settled = !0, clearTimeout(this.timeoutHandle), this.rejectFn(e));
|
|
26
27
|
}
|
|
27
|
-
},
|
|
28
|
+
}, m = (e, t) => {
|
|
28
29
|
Object.assign(e.style, t);
|
|
29
|
-
},
|
|
30
|
+
}, h = class {
|
|
30
31
|
promise;
|
|
31
32
|
resolveFn;
|
|
32
33
|
rejectFn;
|
|
@@ -42,24 +43,30 @@ var c = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentati
|
|
|
42
43
|
reject(e) {
|
|
43
44
|
this.settled || (this.settled = !0, this.rejectFn(e));
|
|
44
45
|
}
|
|
45
|
-
},
|
|
46
|
+
}, g = 1e4, _ = "data-dial-overlay-loader", v = class extends Error {
|
|
47
|
+
code;
|
|
48
|
+
requestType;
|
|
49
|
+
constructor(e, t) {
|
|
50
|
+
super(`ChatOverlay: request "${e}" failed [${t.code}]: ${t.message}`), this.name = "ChatOverlayRequestError", this.code = t.code, this.requestType = e;
|
|
51
|
+
}
|
|
52
|
+
}, y = (e) => {
|
|
46
53
|
if (typeof e != "string") return e;
|
|
47
54
|
let t = document.querySelector(e);
|
|
48
55
|
if (!t) throw Error(`ChatOverlay: no element matches selector "${e}"`);
|
|
49
56
|
return t;
|
|
50
|
-
},
|
|
57
|
+
}, b = (e) => {
|
|
51
58
|
let t = document.createElement("iframe");
|
|
52
59
|
t.src = e.domain, t.name = "overlay", t.setAttribute("aria-label", "DIAL Chat"), t.setAttribute("sandbox", "allow-same-origin allow-scripts allow-modals allow-forms allow-popups allow-downloads allow-popups-to-escape-sandbox");
|
|
53
60
|
let n = ["clipboard-write"];
|
|
54
|
-
return e.enabledFeatures?.includes(
|
|
61
|
+
return e.enabledFeatures?.includes(i.VoiceInput) && n.push("microphone"), t.setAttribute("allow", n.join("; ")), m(t, {
|
|
55
62
|
border: "none",
|
|
56
63
|
display: "block",
|
|
57
64
|
width: "100%",
|
|
58
65
|
height: "100%"
|
|
59
66
|
}), t;
|
|
60
|
-
},
|
|
67
|
+
}, x = (e) => {
|
|
61
68
|
let t = document.createElement("div");
|
|
62
|
-
return t.setAttribute(
|
|
69
|
+
return t.setAttribute(_, ""), t.innerHTML = e.loaderInnerHTML ?? u, m(t, {
|
|
63
70
|
position: "absolute",
|
|
64
71
|
inset: "0",
|
|
65
72
|
zIndex: "2",
|
|
@@ -69,14 +76,14 @@ var c = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentati
|
|
|
69
76
|
boxSizing: "border-box",
|
|
70
77
|
background: "#ffffff",
|
|
71
78
|
color: "#2764d9"
|
|
72
|
-
}), e.loaderClass && (t.className = e.loaderClass), e.loaderStyles &&
|
|
73
|
-
},
|
|
79
|
+
}), e.loaderClass && (t.className = e.loaderClass), e.loaderStyles && m(t, e.loaderStyles), t;
|
|
80
|
+
}, S = class {
|
|
74
81
|
root;
|
|
75
82
|
iframe;
|
|
76
83
|
loader;
|
|
77
84
|
options;
|
|
78
85
|
targetOrigin;
|
|
79
|
-
readyGate = new
|
|
86
|
+
readyGate = new h();
|
|
80
87
|
pendingRequests = /* @__PURE__ */ new Map();
|
|
81
88
|
eventSubscribers = /* @__PURE__ */ new Map();
|
|
82
89
|
messageListener = (e) => {
|
|
@@ -84,62 +91,62 @@ var c = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentati
|
|
|
84
91
|
};
|
|
85
92
|
isDestroyed = !1;
|
|
86
93
|
constructor(e, t) {
|
|
87
|
-
this.root =
|
|
94
|
+
this.root = y(e), this.options = { ...t }, this.targetOrigin = new URL(t.domain).origin, this.iframe = b(this.options), this.loader = x(this.options);
|
|
88
95
|
let n = window.getComputedStyle(this.root).position;
|
|
89
|
-
(n === "static" || n === "") &&
|
|
96
|
+
(n === "static" || n === "") && m(this.root, { position: "relative" }), this.root.appendChild(this.loader), this.root.appendChild(this.iframe), window.addEventListener("message", this.messageListener), this.readyGate.promise.catch(() => void 0);
|
|
90
97
|
}
|
|
91
98
|
ready() {
|
|
92
99
|
return this.readyGate.promise;
|
|
93
100
|
}
|
|
94
101
|
getMessages() {
|
|
95
|
-
return this.send(
|
|
102
|
+
return this.send(s.GetMessages);
|
|
96
103
|
}
|
|
97
104
|
sendMessage(e) {
|
|
98
105
|
let t = { content: e };
|
|
99
|
-
return this.send(
|
|
106
|
+
return this.send(s.SendMessage, t);
|
|
100
107
|
}
|
|
101
108
|
setInputContent(e) {
|
|
102
109
|
let t = { content: e };
|
|
103
|
-
return this.send(
|
|
110
|
+
return this.send(s.SetInputContent, t);
|
|
104
111
|
}
|
|
105
112
|
setSystemPrompt(e) {
|
|
106
113
|
let t = { systemPrompt: e };
|
|
107
|
-
return this.send(
|
|
114
|
+
return this.send(s.SetSystemPrompt, t);
|
|
108
115
|
}
|
|
109
116
|
setTemperature(e) {
|
|
110
117
|
let t = { temperature: e };
|
|
111
|
-
return this.send(
|
|
118
|
+
return this.send(s.SetTemperature, t);
|
|
112
119
|
}
|
|
113
120
|
getConversations() {
|
|
114
|
-
return this.send(
|
|
121
|
+
return this.send(s.GetConversations);
|
|
115
122
|
}
|
|
116
123
|
getSelectedConversations() {
|
|
117
|
-
return this.send(
|
|
124
|
+
return this.send(s.GetSelectedConversations);
|
|
118
125
|
}
|
|
119
126
|
selectConversation(e) {
|
|
120
127
|
let t = { id: e };
|
|
121
|
-
return this.send(
|
|
128
|
+
return this.send(s.SelectConversation, t);
|
|
122
129
|
}
|
|
123
130
|
createConversation(e) {
|
|
124
131
|
let t = { ...e };
|
|
125
|
-
return this.send(
|
|
132
|
+
return this.send(s.CreateConversation, t);
|
|
126
133
|
}
|
|
127
134
|
createLocalConversation() {
|
|
128
|
-
return this.send(
|
|
135
|
+
return this.send(s.CreateLocalConversation);
|
|
129
136
|
}
|
|
130
137
|
deleteConversation(e) {
|
|
131
138
|
let t = { id: e };
|
|
132
|
-
return this.send(
|
|
139
|
+
return this.send(s.DeleteConversation, t);
|
|
133
140
|
}
|
|
134
141
|
renameConversation(e, t) {
|
|
135
142
|
let n = {
|
|
136
143
|
id: e,
|
|
137
144
|
newName: t
|
|
138
145
|
};
|
|
139
|
-
return this.send(
|
|
146
|
+
return this.send(s.RenameConversation, n);
|
|
140
147
|
}
|
|
141
148
|
setOverlayOptions(e) {
|
|
142
|
-
return this.options.theme = e.theme ?? this.options.theme, this.options.modelId = e.modelId ?? this.options.modelId, this.options.overlayConversationId = e.overlayConversationId ?? this.options.overlayConversationId, this.options.enabledFeatures = e.enabledFeatures ?? this.options.enabledFeatures, this.sendCurrentOverlayOptions();
|
|
149
|
+
return this.options.theme = e.theme ?? this.options.theme, this.options.modelId = e.modelId ?? this.options.modelId, this.options.overlayConversationId = e.overlayConversationId ?? this.options.overlayConversationId, this.options.enabledFeatures = e.enabledFeatures ?? this.options.enabledFeatures, Object.hasOwn(e, "auth") && (this.options.auth = e.auth), this.sendCurrentOverlayOptions();
|
|
143
150
|
}
|
|
144
151
|
subscribe(e, t) {
|
|
145
152
|
let n = this.eventSubscribers.get(e) ?? /* @__PURE__ */ new Set(), r = t;
|
|
@@ -162,14 +169,16 @@ var c = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentati
|
|
|
162
169
|
}
|
|
163
170
|
sendCurrentOverlayOptions() {
|
|
164
171
|
let e = { hostDomain: window.location.origin };
|
|
165
|
-
|
|
172
|
+
this.options.theme !== void 0 && (e.theme = this.options.theme), this.options.modelId !== void 0 && (e.modelId = this.options.modelId), this.options.overlayConversationId !== void 0 && (e.overlayConversationId = this.options.overlayConversationId), this.options.enabledFeatures !== void 0 && (e.enabledFeatures = this.options.enabledFeatures);
|
|
173
|
+
let t = this.options.auth?.providerUiModes;
|
|
174
|
+
return t !== void 0 && Object.keys(t).length > 0 && (e.authProviderUiModes = t), this.send(s.SetOverlayOptions, e, { bypassReadyGate: !0 });
|
|
166
175
|
}
|
|
167
176
|
send(e, t, n) {
|
|
168
177
|
return this.isDestroyed ? Promise.reject(/* @__PURE__ */ Error("ChatOverlay: instance was destroyed")) : n?.bypassReadyGate ? this.dispatchRequest(e, t) : this.readyGate.promise.then(() => this.dispatchRequest(e, t));
|
|
169
178
|
}
|
|
170
179
|
dispatchRequest(e, t) {
|
|
171
180
|
if (this.isDestroyed) return Promise.reject(/* @__PURE__ */ Error("ChatOverlay: instance was destroyed"));
|
|
172
|
-
let n = this.options.requestTimeout ??
|
|
181
|
+
let n = this.options.requestTimeout ?? g, r = new p(e, n);
|
|
173
182
|
this.pendingRequests.set(r.requestId, r), r.promise.finally(() => {
|
|
174
183
|
this.pendingRequests.delete(r.requestId);
|
|
175
184
|
}).catch(() => void 0);
|
|
@@ -184,19 +193,25 @@ var c = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentati
|
|
|
184
193
|
handleMessage(e) {
|
|
185
194
|
if (e.source !== this.iframe.contentWindow) return;
|
|
186
195
|
let t = e.data;
|
|
187
|
-
if (
|
|
196
|
+
if (l(t)) {
|
|
188
197
|
this.handleResponse(t);
|
|
189
198
|
return;
|
|
190
199
|
}
|
|
191
|
-
|
|
200
|
+
c(t) && this.handleEvent(t);
|
|
192
201
|
}
|
|
193
202
|
handleResponse(e) {
|
|
194
203
|
let t = this.pendingRequests.get(e.requestId);
|
|
195
|
-
!t || !t.matches(e.type, e.requestId)
|
|
204
|
+
if (!(!t || !t.matches(e.type, e.requestId))) {
|
|
205
|
+
if (this.pendingRequests.delete(e.requestId), e.error) {
|
|
206
|
+
t.reject(new v(t.requestType, e.error));
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
t.resolve(e.payload);
|
|
210
|
+
}
|
|
196
211
|
}
|
|
197
212
|
handleEvent(e) {
|
|
198
|
-
let
|
|
199
|
-
|
|
213
|
+
let t = e.type;
|
|
214
|
+
t === n.Ready && this.sendCurrentOverlayOptions().catch(() => void 0), t === (this.options.loaderHideEvent ?? n.Ready) && this.hideLoader(), t === n.ReadyToInteract && this.readyGate.resolve(!0), this.notifySubscribers(t, e.payload);
|
|
200
215
|
}
|
|
201
216
|
hideLoader() {
|
|
202
217
|
this.loader.style.display = "none";
|
|
@@ -204,41 +219,41 @@ var c = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentati
|
|
|
204
219
|
notifySubscribers(e, t) {
|
|
205
220
|
this.eventSubscribers.get(e)?.forEach((e) => e(t));
|
|
206
221
|
}
|
|
207
|
-
},
|
|
208
|
-
if (document.getElementById(
|
|
222
|
+
}, C = 768, w = 380, T = 600, E = 999999, D = "24px", O = "<svg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" aria-hidden=\"true\" focusable=\"false\"><path fill=\"currentColor\" d=\"M4 4h16v12H7l-3 3V4z\"/></svg>", k = "<svg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" aria-hidden=\"true\" focusable=\"false\"><path fill=\"currentColor\" d=\"M18.3 5.71 12 12.01l-6.3-6.3-1.4 1.41 6.29 6.29-6.29 6.29 1.4 1.41 6.3-6.3 6.3 6.3 1.4-1.41-6.29-6.29 6.29-6.29z\"/></svg>", A = "<svg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" aria-hidden=\"true\" focusable=\"false\"><path fill=\"currentColor\" d=\"M4 4h6v2H6v4H4V4zm10 0h6v6h-2V6h-4V4zM4 14h2v4h4v2H4v-6zm14 0h2v6h-6v-2h4v-4z\"/></svg>", j = "dial-overlay-manager-styles", M = () => {
|
|
223
|
+
if (document.getElementById(j)) return;
|
|
209
224
|
let e = document.createElement("style");
|
|
210
|
-
e.id =
|
|
211
|
-
},
|
|
225
|
+
e.id = j, e.textContent = "\n.dial-overlay-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 48px;\n height: 48px;\n border: none;\n border-radius: 999px;\n cursor: pointer;\n background: #2764d9;\n color: #ffffff;\n}\n.dial-overlay-btn:hover,\n.dial-overlay-btn:focus-visible {\n background: #1d4fb8;\n outline: 2px solid #1d4fb8;\n outline-offset: 2px;\n}\n", document.head.appendChild(e);
|
|
226
|
+
}, N = (e, t) => {
|
|
212
227
|
let n = document.createElement("button");
|
|
213
228
|
return n.type = "button", n.className = "dial-overlay-btn", n.setAttribute("aria-label", e), n.innerHTML = t, n;
|
|
214
|
-
},
|
|
229
|
+
}, P = (e) => typeof e == "number" ? `${e}px` : e, F = /* @__PURE__ */ function(e) {
|
|
215
230
|
return e.LeftBottom = "left-bottom", e.LeftTop = "left-top", e.RightBottom = "right-bottom", e.RightTop = "right-top", e;
|
|
216
|
-
}({}),
|
|
231
|
+
}({}), I = {
|
|
217
232
|
"right-bottom": {
|
|
218
|
-
insetInlineEnd:
|
|
219
|
-
insetBlockEnd:
|
|
233
|
+
insetInlineEnd: D,
|
|
234
|
+
insetBlockEnd: D,
|
|
220
235
|
insetInlineStart: "auto",
|
|
221
236
|
insetBlockStart: "auto"
|
|
222
237
|
},
|
|
223
238
|
"right-top": {
|
|
224
|
-
insetInlineEnd:
|
|
225
|
-
insetBlockStart:
|
|
239
|
+
insetInlineEnd: D,
|
|
240
|
+
insetBlockStart: D,
|
|
226
241
|
insetInlineStart: "auto",
|
|
227
242
|
insetBlockEnd: "auto"
|
|
228
243
|
},
|
|
229
244
|
"left-bottom": {
|
|
230
|
-
insetInlineStart:
|
|
231
|
-
insetBlockEnd:
|
|
245
|
+
insetInlineStart: D,
|
|
246
|
+
insetBlockEnd: D,
|
|
232
247
|
insetInlineEnd: "auto",
|
|
233
248
|
insetBlockStart: "auto"
|
|
234
249
|
},
|
|
235
250
|
"left-top": {
|
|
236
|
-
insetInlineStart:
|
|
237
|
-
insetBlockStart:
|
|
251
|
+
insetInlineStart: D,
|
|
252
|
+
insetBlockStart: D,
|
|
238
253
|
insetInlineEnd: "auto",
|
|
239
254
|
insetBlockEnd: "auto"
|
|
240
255
|
}
|
|
241
|
-
},
|
|
256
|
+
}, L = class {
|
|
242
257
|
overlays = /* @__PURE__ */ new Map();
|
|
243
258
|
abortController = new AbortController();
|
|
244
259
|
isDestroyed = !1;
|
|
@@ -250,9 +265,9 @@ var c = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentati
|
|
|
250
265
|
}
|
|
251
266
|
createOverlay(e) {
|
|
252
267
|
if (this.overlays.has(e.overlayId)) throw Error(`ChatOverlayManager: overlay "${e.overlayId}" already exists`);
|
|
253
|
-
|
|
268
|
+
M();
|
|
254
269
|
let t = document.createElement("div");
|
|
255
|
-
t.setAttribute("data-dial-overlay-container", e.overlayId),
|
|
270
|
+
t.setAttribute("data-dial-overlay-container", e.overlayId), m(t, {
|
|
256
271
|
display: "flex",
|
|
257
272
|
flexDirection: "column",
|
|
258
273
|
overflow: "hidden",
|
|
@@ -261,24 +276,24 @@ var c = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentati
|
|
|
261
276
|
background: "#ffffff"
|
|
262
277
|
});
|
|
263
278
|
let n = document.createElement("div");
|
|
264
|
-
|
|
279
|
+
m(n, {
|
|
265
280
|
display: "flex",
|
|
266
281
|
justifyContent: "flex-end",
|
|
267
282
|
gap: "8px",
|
|
268
283
|
padding: "8px"
|
|
269
284
|
});
|
|
270
|
-
let r =
|
|
285
|
+
let r = N(e.closeButtonAriaLabel ?? "Collapse", k);
|
|
271
286
|
n.appendChild(r);
|
|
272
287
|
let i;
|
|
273
|
-
e.allowFullscreen && (i =
|
|
288
|
+
e.allowFullscreen && (i = N(e.fullscreenButtonAriaLabel ?? "Open full screen", A), n.appendChild(i));
|
|
274
289
|
let a = document.createElement("div");
|
|
275
|
-
|
|
290
|
+
m(a, {
|
|
276
291
|
flex: "1",
|
|
277
292
|
minHeight: "0"
|
|
278
293
|
}), t.appendChild(n), t.appendChild(a), document.body.appendChild(t);
|
|
279
|
-
let o = new
|
|
294
|
+
let o = new S(a, e);
|
|
280
295
|
e.allowFullscreen && o.allowFullscreen();
|
|
281
|
-
let s =
|
|
296
|
+
let s = N(e.toggleButtonAriaLabel ?? "Open chat", O);
|
|
282
297
|
document.body.appendChild(s);
|
|
283
298
|
let c = {
|
|
284
299
|
overlay: o,
|
|
@@ -363,16 +378,16 @@ var c = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentati
|
|
|
363
378
|
return t;
|
|
364
379
|
}
|
|
365
380
|
applyLayout(e) {
|
|
366
|
-
let { options: t, container: n, toggleButton: r } = e, i = t.position ?? "right-bottom", a = String(t.zIndex ??
|
|
367
|
-
if (
|
|
381
|
+
let { options: t, container: n, toggleButton: r } = e, i = t.position ?? "right-bottom", a = String(t.zIndex ?? E);
|
|
382
|
+
if (m(r, {
|
|
368
383
|
position: "fixed",
|
|
369
384
|
zIndex: a,
|
|
370
|
-
...
|
|
371
|
-
}),
|
|
385
|
+
...I[i]
|
|
386
|
+
}), m(n, {
|
|
372
387
|
position: "fixed",
|
|
373
388
|
zIndex: a
|
|
374
|
-
}), window.innerWidth <=
|
|
375
|
-
|
|
389
|
+
}), window.innerWidth <= C) {
|
|
390
|
+
m(n, {
|
|
376
391
|
insetInlineStart: "0",
|
|
377
392
|
insetInlineEnd: "0",
|
|
378
393
|
insetBlockStart: "0",
|
|
@@ -383,12 +398,12 @@ var c = "<svg viewBox=\"0 0 50 50\" width=\"32\" height=\"32\" role=\"presentati
|
|
|
383
398
|
});
|
|
384
399
|
return;
|
|
385
400
|
}
|
|
386
|
-
|
|
387
|
-
width:
|
|
388
|
-
height:
|
|
389
|
-
...
|
|
401
|
+
m(n, {
|
|
402
|
+
width: P(t.width ?? w),
|
|
403
|
+
height: P(t.height ?? T),
|
|
404
|
+
...I[i]
|
|
390
405
|
});
|
|
391
406
|
}
|
|
392
407
|
};
|
|
393
408
|
//#endregion
|
|
394
|
-
export {
|
|
409
|
+
export { S as ChatOverlay, L as ChatOverlayManager, v as ChatOverlayRequestError, e as OverlayAuthUiMode, t as OverlayEventType, r as OverlayFeature, F as OverlayPosition, a as OverlayRequestErrorCode, o as OverlayRequestType };
|
package/lib/ChatOverlay.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import { ChatOverlayOptions, CreateConversationResponse, CreateLocalConversationResponse, DeleteConversationResponse, GetConversationsResponse, GetMessagesResponse, GetSelectedConversationsResponse, OverlayEventType, RenameConversationResponse, SelectConversationResponse, SendMessageResponse, SetOverlayOptionsResponse, SetSystemPromptResponse, SetTemperatureResponse } from '@epam/ai-dial-chat-shared';
|
|
1
|
+
import { ChatOverlayOptions, CreateConversationResponse, CreateLocalConversationResponse, DeleteConversationResponse, GetConversationsResponse, GetMessagesResponse, GetSelectedConversationsResponse, OverlayRequestError, OverlayEventType, RenameConversationResponse, SelectConversationResponse, SendMessageResponse, SetOverlayOptionsResponse, SetSystemPromptResponse, SetTemperatureResponse } from '@epam/ai-dial-chat-shared';
|
|
2
|
+
/** Error returned by the embedded chat for a well-formed overlay request. */
|
|
3
|
+
export declare class ChatOverlayRequestError extends Error {
|
|
4
|
+
/** Stable embedded-chat error code. */
|
|
5
|
+
readonly code: OverlayRequestError['code'];
|
|
6
|
+
/** Request type that failed. */
|
|
7
|
+
readonly requestType: string;
|
|
8
|
+
constructor(requestType: string, error: OverlayRequestError);
|
|
9
|
+
}
|
|
2
10
|
/**
|
|
3
11
|
* A single embedded DIAL Chat iframe controlled over the `@DIAL_OVERLAY`
|
|
4
12
|
* `postMessage` protocol. Construct with a root element (or selector) and
|
|
@@ -55,7 +63,7 @@ export declare class ChatOverlay {
|
|
|
55
63
|
* embedded app. Bypasses the readiness gate — it is also how the initial
|
|
56
64
|
* handshake options exchange happens, before `ready()` resolves.
|
|
57
65
|
*/
|
|
58
|
-
setOverlayOptions(options: Partial<Pick<ChatOverlayOptions, 'theme' | 'modelId' | 'overlayConversationId' | 'enabledFeatures'>>): Promise<SetOverlayOptionsResponse>;
|
|
66
|
+
setOverlayOptions(options: Partial<Pick<ChatOverlayOptions, 'theme' | 'modelId' | 'overlayConversationId' | 'enabledFeatures' | 'auth'>>): Promise<SetOverlayOptionsResponse>;
|
|
59
67
|
/** Registers `callback` to be invoked with each `eventType` event's payload. */
|
|
60
68
|
subscribe<T = unknown>(eventType: OverlayEventType, callback: (payload: T) => void): () => void;
|
|
61
69
|
/** Grants the iframe permission to enter fullscreen. */
|
package/lib/ChatOverlay.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatOverlay.d.ts","sourceRoot":"","sources":["../../src/lib/ChatOverlay.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EAEvB,KA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AE,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAQnE,2DAA2D;IAC3D,kBAAkB,CAChB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,0BAA0B,CAAC;IAQtC;;;;OAIG;IACH,iBAAiB,CACf,OAAO,EAAE,OAAO,CACd,IAAI,CACF,kBAAkB,EAChB,OAAO,GACP,SAAS,GACT,uBAAuB,GACvB,iBAAiB,GACjB,MAAM,CACT,CACF,GACA,OAAO,CAAC,yBAAyB,CAAC;IAarC,gFAAgF;IAChF,SAAS,CAAC,CAAC,GAAG,OAAO,EACnB,SAAS,EAAE,gBAAgB,EAC3B,QAAQ,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,GAC7B,MAAM,IAAI;IAYb,wDAAwD;IACxD,eAAe,IAAI,IAAI;IAWvB,iDAAiD;IAC3C,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAMrC;;;OAGG;IACH,OAAO,IAAI,IAAI;IAef,OAAO,CAAC,yBAAyB;IA8BjC,OAAO,CAAC,IAAI;IAkBZ,OAAO,CAAC,eAAe;IA+BvB,OAAO,CAAC,aAAa;IAcrB,OAAO,CAAC,cAAc;IAetB,OAAO,CAAC,WAAW;IAmBnB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,iBAAiB;CAO1B"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** A single outstanding overlay request: owns its `requestId` and resolves/rejects when the matching response arrives or the timeout elapses. */
|
|
2
2
|
export declare class DeferredRequest<T = unknown> {
|
|
3
|
+
/** Exact request type sent to the embedded app. */
|
|
4
|
+
readonly requestType: string;
|
|
3
5
|
/** Unique id used to match this request to its response message. */
|
|
4
6
|
readonly requestId: string;
|
|
5
7
|
/** Exact response type expected for this request. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deferred-request.d.ts","sourceRoot":"","sources":["../../../src/lib/internal/deferred-request.ts"],"names":[],"mappings":"AA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C,EAAE,OAAO,GAAG,IAAI;CAQ/B"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epam/ai-dial-chat-overlay",
|
|
3
3
|
"description": "Embeddable postMessage-based ChatOverlay/ChatOverlayManager widget for hosting a DIAL Chat instance inside a third-party page",
|
|
4
|
-
"version": "1.1.0-dev.
|
|
4
|
+
"version": "1.1.0-dev.78",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"@epam/ai-dial-chat-shared": "1.1.0-dev.
|
|
19
|
+
"@epam/ai-dial-chat-shared": "1.1.0-dev.78"
|
|
20
20
|
},
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|