open-chat-studio-widget 0.5.3 → 0.6.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/README.md +1 -0
- package/dist/cjs/{index-D8A4RBzq.js → index-CcvroTR_.js} +3 -3
- package/dist/cjs/{index-D8A4RBzq.js.map → index-CcvroTR_.js.map} +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/open-chat-studio-widget.cjs.entry.js +31 -5
- package/dist/cjs/open-chat-studio-widget.cjs.entry.js.map +1 -1
- package/dist/cjs/open-chat-studio-widget.cjs.js +2 -2
- package/dist/cjs/open-chat-studio-widget.entry.cjs.js.map +1 -1
- package/dist/collection/components/ocs-chat/ocs-chat.js +53 -3
- package/dist/collection/components/ocs-chat/ocs-chat.js.map +1 -1
- package/dist/collection/services/file-attachment-manager.js +2 -1
- package/dist/collection/services/file-attachment-manager.js.map +1 -1
- package/dist/components/open-chat-studio-widget.js +32 -4
- package/dist/components/open-chat-studio-widget.js.map +1 -1
- package/dist/esm/{index-C53whb-B.js → index-BKVXO_5E.js} +3 -3
- package/dist/esm/{index-C53whb-B.js.map → index-BKVXO_5E.js.map} +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/open-chat-studio-widget.entry.js +31 -5
- package/dist/esm/open-chat-studio-widget.entry.js.map +1 -1
- package/dist/esm/open-chat-studio-widget.js +3 -3
- package/dist/open-chat-studio-widget/open-chat-studio-widget.entry.esm.js.map +1 -1
- package/dist/open-chat-studio-widget/open-chat-studio-widget.esm.js +1 -1
- package/dist/open-chat-studio-widget/{p-C53whb-B.js → p-BKVXO_5E.js} +2 -2
- package/dist/open-chat-studio-widget/{p-C53whb-B.js.map → p-BKVXO_5E.js.map} +1 -1
- package/dist/open-chat-studio-widget/p-a0d04423.entry.js +4 -0
- package/dist/open-chat-studio-widget/p-a0d04423.entry.js.map +1 -0
- package/dist/types/components/ocs-chat/ocs-chat.d.ts +12 -0
- package/dist/types/components.d.ts +8 -0
- package/package.json +1 -1
- package/dist/open-chat-studio-widget/p-b9556259.entry.js +0 -4
- package/dist/open-chat-studio-widget/p-b9556259.entry.js.map +0 -1
|
@@ -5063,7 +5063,8 @@ class FileAttachmentManager {
|
|
|
5063
5063
|
let totalSize = existingFiles.reduce((sum, f) => sum + f.file.size, 0);
|
|
5064
5064
|
for (const file of fileArray) {
|
|
5065
5065
|
const extension = this.getFileExtension(file.name);
|
|
5066
|
-
|
|
5066
|
+
const contentType = file.type.split("/")[0];
|
|
5067
|
+
if (contentType != "text" && !this.supportedExtensions.includes(extension)) {
|
|
5067
5068
|
newSelected.push({ file, error: `File type ${extension} not supported` });
|
|
5068
5069
|
continue;
|
|
5069
5070
|
}
|
|
@@ -5399,6 +5400,7 @@ const OcsChat = /*@__PURE__*/ proxyCustomElement(class OcsChat extends HTMLEleme
|
|
|
5399
5400
|
}
|
|
5400
5401
|
this.parseWelcomeMessages();
|
|
5401
5402
|
this.parseStarterQuestions();
|
|
5403
|
+
this.loadInternalPageContext();
|
|
5402
5404
|
}
|
|
5403
5405
|
componentDidLoad() {
|
|
5404
5406
|
const computedStyle = getComputedStyle(this.host);
|
|
@@ -5491,6 +5493,16 @@ const OcsChat = /*@__PURE__*/ proxyCustomElement(class OcsChat extends HTMLEleme
|
|
|
5491
5493
|
}
|
|
5492
5494
|
this.translationManager = new TranslationManager(this.language, customTranslationsObj);
|
|
5493
5495
|
}
|
|
5496
|
+
loadInternalPageContext() {
|
|
5497
|
+
if (this.pageContext === undefined || this.pageContext === null) {
|
|
5498
|
+
return;
|
|
5499
|
+
}
|
|
5500
|
+
if (typeof this.pageContext !== 'object' || Array.isArray(this.pageContext)) {
|
|
5501
|
+
console.error("pageContext is expected to be a plain JavaScript object.");
|
|
5502
|
+
return;
|
|
5503
|
+
}
|
|
5504
|
+
this.internalPageContext = this.pageContext;
|
|
5505
|
+
}
|
|
5494
5506
|
async loadTranslationsFromUrl(url) {
|
|
5495
5507
|
try {
|
|
5496
5508
|
const response = await fetch(url);
|
|
@@ -5623,10 +5635,14 @@ const OcsChat = /*@__PURE__*/ proxyCustomElement(class OcsChat extends HTMLEleme
|
|
|
5623
5635
|
if (this.allowAttachments && attachmentIds.length > 0) {
|
|
5624
5636
|
requestBody.attachment_ids = attachmentIds;
|
|
5625
5637
|
}
|
|
5638
|
+
if (this.internalPageContext) {
|
|
5639
|
+
requestBody.context = this.internalPageContext;
|
|
5640
|
+
}
|
|
5626
5641
|
const data = await this.getChatService().sendMessage(this.sessionId, requestBody);
|
|
5627
5642
|
if (data.status === 'error') {
|
|
5628
5643
|
throw new Error(data.error || 'Failed to send message');
|
|
5629
5644
|
}
|
|
5645
|
+
this.internalPageContext = undefined;
|
|
5630
5646
|
this.startTaskPolling(data.task_id);
|
|
5631
5647
|
}
|
|
5632
5648
|
catch (error) {
|
|
@@ -5713,6 +5729,14 @@ const OcsChat = /*@__PURE__*/ proxyCustomElement(class OcsChat extends HTMLEleme
|
|
|
5713
5729
|
toggleWindowVisibility() {
|
|
5714
5730
|
this.visible = !this.visible;
|
|
5715
5731
|
}
|
|
5732
|
+
/**
|
|
5733
|
+
* Watch for changes to the `pageContext` prop and sync to internal variable.
|
|
5734
|
+
*
|
|
5735
|
+
* @param pageContext - The new value for the field.
|
|
5736
|
+
*/
|
|
5737
|
+
pageContextHandler() {
|
|
5738
|
+
this.loadInternalPageContext();
|
|
5739
|
+
}
|
|
5716
5740
|
/**
|
|
5717
5741
|
* Watch for changes to the `visible` attribute and update accordingly.
|
|
5718
5742
|
*
|
|
@@ -6272,12 +6296,13 @@ const OcsChat = /*@__PURE__*/ proxyCustomElement(class OcsChat extends HTMLEleme
|
|
|
6272
6296
|
if (el) {
|
|
6273
6297
|
this.fileInputRef = el;
|
|
6274
6298
|
}
|
|
6275
|
-
}, id: "ocs-file-input", type: "file", multiple: true, accept: OcsChat.SUPPORTED_FILE_EXTENSIONS.join(','), onChange: (e) => this.handleFileSelect(e), class: "hidden" })), this.allowAttachments && (h("button", { class: "file-attachment-button", onClick: () => { var _a; return (_a = this.fileInputRef) === null || _a === void 0 ? void 0 : _a.click(); }, disabled: this.isTyping || this.isUploadingFiles || this.isLoading, title: this.translationManager.get('attach.add'), "aria-label": this.translationManager.get('attach.add') }, h(PaperClipIcon, null))), h("button", { class: `send-button ${!this.isTyping && !this.isLoading && !!this.messageInput.trim()
|
|
6299
|
+
}, id: "ocs-file-input", type: "file", multiple: true, accept: OcsChat.SUPPORTED_FILE_EXTENSIONS.join(',') + ',text/*', onChange: (e) => this.handleFileSelect(e), class: "hidden" })), this.allowAttachments && (h("button", { class: "file-attachment-button", onClick: () => { var _a; return (_a = this.fileInputRef) === null || _a === void 0 ? void 0 : _a.click(); }, disabled: this.isTyping || this.isUploadingFiles || this.isLoading, title: this.translationManager.get('attach.add'), "aria-label": this.translationManager.get('attach.add') }, h(PaperClipIcon, null))), h("button", { class: `send-button ${!this.isTyping && !this.isLoading && !!this.messageInput.trim()
|
|
6276
6300
|
? 'send-button-enabled'
|
|
6277
6301
|
: 'send-button-disabled'}`, onClick: () => this.sendMessage(this.messageInput), disabled: this.isTyping || this.isUploadingFiles || this.isLoading || !this.messageInput.trim() }, this.isUploadingFiles ? `${this.translationManager.get('status.uploading')}...` : this.translationManager.get('composer.send')))), h("div", { class: "flex items-center justify-center text-[0.8em] font-light w-full text-slate-500 py-[2px]" }, h("p", null, this.translationManager.get('branding.poweredBy'), ' ', " ", h("a", { class: "underline", href: "https://www.dimagi.com", target: "_blank" }, "Dimagi"))))))));
|
|
6278
6302
|
}
|
|
6279
6303
|
get host() { return this; }
|
|
6280
6304
|
static get watchers() { return {
|
|
6305
|
+
"pageContext": ["pageContextHandler"],
|
|
6281
6306
|
"visible": ["visibilityHandler"]
|
|
6282
6307
|
}; }
|
|
6283
6308
|
static get style() { return ocsChatCss; }
|
|
@@ -6303,6 +6328,7 @@ const OcsChat = /*@__PURE__*/ proxyCustomElement(class OcsChat extends HTMLEleme
|
|
|
6303
6328
|
"typingIndicatorText": [1, "typing-indicator-text"],
|
|
6304
6329
|
"language": [1],
|
|
6305
6330
|
"translationsUrl": [1, "translations-url"],
|
|
6331
|
+
"pageContext": [1040, "page-context"],
|
|
6306
6332
|
"error": [32],
|
|
6307
6333
|
"messages": [32],
|
|
6308
6334
|
"sessionId": [32],
|
|
@@ -6324,6 +6350,7 @@ const OcsChat = /*@__PURE__*/ proxyCustomElement(class OcsChat extends HTMLEleme
|
|
|
6324
6350
|
"isButtonDragging": [32],
|
|
6325
6351
|
"buttonWasDragged": [32]
|
|
6326
6352
|
}, undefined, {
|
|
6353
|
+
"pageContext": ["pageContextHandler"],
|
|
6327
6354
|
"visible": ["visibilityHandler"]
|
|
6328
6355
|
}]);
|
|
6329
6356
|
OcsChat.TASK_POLLING_MAX_ATTEMPTS = 120;
|
|
@@ -6336,8 +6363,9 @@ OcsChat.WINDOW_MARGIN = 20;
|
|
|
6336
6363
|
OcsChat.LOCALSTORAGE_TEST_KEY = '__ocs_test__';
|
|
6337
6364
|
OcsChat.MAX_FILE_SIZE_MB = 50;
|
|
6338
6365
|
OcsChat.MAX_TOTAL_SIZE_MB = 50;
|
|
6339
|
-
OcsChat.SUPPORTED_FILE_EXTENSIONS = ['.txt', '.pdf', '.doc', '.docx', '.xls', '.xlsx', '.csv', '.jpg',
|
|
6340
|
-
'.png', '.gif', '.bmp', '.webp', '.svg', '.mp4', '.mov', '.avi', '.mp3', '.wav'
|
|
6366
|
+
OcsChat.SUPPORTED_FILE_EXTENSIONS = ['.txt', '.pdf', '.doc', '.docx', '.xls', '.xlsx', '.csv', '.jpg',
|
|
6367
|
+
'.jpeg', '.png', '.gif', '.bmp', '.webp', '.svg', '.mp4', '.mov', '.avi', '.mp3', '.wav', '.html', '.htm', '.css',
|
|
6368
|
+
'.js', '.xml', '.md', '.ics', '.vcf', '.rtf', '.tsv', '.yaml', '.yml', '.py', '.c'];
|
|
6341
6369
|
function defineCustomElement$1() {
|
|
6342
6370
|
if (typeof customElements === "undefined") {
|
|
6343
6371
|
return;
|