@meetelise/chat 1.20.231 → 1.20.232
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/package.json +1 -1
- package/public/demo/index.html +3 -5
- package/public/dist/index.js +13 -13
- package/src/WebComponent/pubnub-message.ts +40 -38
package/package.json
CHANGED
package/public/demo/index.html
CHANGED
|
@@ -131,15 +131,13 @@
|
|
|
131
131
|
};
|
|
132
132
|
|
|
133
133
|
MEChat.start({
|
|
134
|
-
|
|
135
|
-
//
|
|
136
|
-
|
|
134
|
+
organization: "elise-ai",
|
|
135
|
+
//building: "test-yardi-building",
|
|
136
|
+
building: "930196d8-3527-11ee-a65a-b70940a36fe6",
|
|
137
137
|
onWidgetLoaded: onWidgetLoaded,
|
|
138
138
|
// organization: "00f18938-9632-40b9-8d7f-f30e219c94fc",
|
|
139
139
|
// building: "19e21cda-d05b-11ee-b3bd-cf9cc1ace7e5",
|
|
140
140
|
// 123 Main Street
|
|
141
|
-
organization: "test-company",
|
|
142
|
-
building: "e2e-test-yardi-building",
|
|
143
141
|
// organization: "edward-rose",
|
|
144
142
|
// building: "rivers-edge-apartments",
|
|
145
143
|
// // mobileStyles: {
|
package/public/dist/index.js
CHANGED
|
@@ -3511,19 +3511,19 @@ otherwise there's some empty space at the bottom of the button, which interferes
|
|
|
3511
3511
|
transform: rotate(360deg);
|
|
3512
3512
|
}
|
|
3513
3513
|
}
|
|
3514
|
-
`,Qr=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}([ae("mini-loader")],Qr);var Vr=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a};let Kr=class extends re{constructor(){super(...arguments),this.onMount=()=>({}),this.loadingPreviews=!0,this.websitePreviewInfo=[],this.imagesToDisplay=[],this.imageUrlError=[]}isMessageStillStreamingChunks(){if(!this.message)return!1;const e=this.message.chunks.find((e=>e.isDone));return!e||this.message.chunks.length===e.order}updated(e){if(this.onMount(),!e.has("message"))return;if(!this.message)return;const{hyperlinks:t,markedText:n}=this.mapAndMarkHyperLinks(this.message.message),i=/(https?:\/\/[^\s]+)/g,r=[],o=[];this.parsedMessage=U`${n.split("\n").map((e=>{const n=this.sanitizeMarkdownText(e),a=this.preserveHTMLTags(n);return a?U`${a.map((e=>{if(t.find((t=>t.id===e))){const n=t.find((t=>t.id===e));if(!n)return;return o.push({redirectTo:null==n?void 0:n.link,source:null==n?void 0:n.link}),U`<a
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3514
|
+
`,Qr=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}([ae("mini-loader")],Qr);var Vr=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a};let Kr=class extends re{constructor(){super(...arguments),this.onMount=()=>({}),this.loadingPreviews=!0,this.websitePreviewInfo=[],this.imagesToDisplay=[],this.imageUrlError=[]}isMessageStillStreamingChunks(){if(!this.message)return!1;const e=this.message.chunks.find((e=>e.isDone));return!e||this.message.chunks.length===e.order}updated(e){if(this.onMount(),!e.has("message"))return;if(!this.message)return;const{hyperlinks:t,markedText:n}=this.mapAndMarkHyperLinks(this.message.message),i=/(https?:\/\/[^\s]+)/g,r=[],o=[];this.parsedMessage=U`${n.trim().split("\n").map((e=>{const n=this.sanitizeMarkdownText(e),a=this.preserveHTMLTags(n);return a?U`${a.map((e=>{if(t.find((t=>t.id===e))){const n=t.find((t=>t.id===e));if(!n)return;return o.push({redirectTo:null==n?void 0:n.link,source:null==n?void 0:n.link}),U`<a
|
|
3515
|
+
class="redirect-link"
|
|
3516
|
+
href="${null==n?void 0:n.link}"
|
|
3517
|
+
target="_blank"
|
|
3518
|
+
rel="noopener noreferrer"
|
|
3519
|
+
>${null==n?void 0:n.hyperlink}
|
|
3520
|
+
</a>`}if(i.test(e)){const t=this.removeTrailingPunctuation(e);return r.push(this.getLinkData(t)),U`<a
|
|
3521
|
+
class="redirect-link"
|
|
3522
|
+
href="${t}"
|
|
3523
|
+
target="_blank"
|
|
3524
|
+
rel="noopener noreferrer"
|
|
3525
|
+
>${t}
|
|
3526
|
+
</a>`}return U`${Wr(Gr().sanitize(e))} `}))}<br />`:U``}))}`,this.imagesToDisplay=o,Promise.all(r).then((e=>{this.websitePreviewInfo=e}))}preserveHTMLTags(e){var t;const n=e.match(/(<\/?[a-z][^>]*>[^<]*<\/?[a-z]*>|[\w':#$()-]+[.,?!]?|\S)/gi);return null!==(t=null==n?void 0:n.filter((e=>""!==e.trim())))&&void 0!==t?t:[]}sanitizeMarkdownText(e){return e.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*?)\*\*/gim,"<b>$1</b>").replace(/\*(.*?)\*/gim,"<i>$1</i>").trim()}removeTrailingPunctuation(e){return[".",",","!","?",":",";"].includes(e[e.length-1])?this.removeTrailingPunctuation(e.slice(0,-1)):e}mapAndMarkHyperLinks(e){const t=Array.from(e.matchAll(/<https?:\/\/[^|]+\|[^>]+>|<a href="[^"]+"(?: target="[^"]*")?>[^<]+<\/a>|\[.*?\]\([^)]*\.[^)]*\)/g)),n=[],i=t.map((t=>{const n=t[0];if(void 0===t.index)return;const i=e[t.index-1],r=e[t.index+n.length];if(n.startsWith("<https")||n.startsWith("<http"))return{matchedLink:n,link:n.split("|")[0].replace("<",""),hyperlink:n.split("|")[1].replace(">",""),addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)};if(n.startsWith("<a href=")){const e=n.match(/href="([^"]+)"/),t=n.match(/>[^<]+</);return{matchedLink:n,link:e?e[1]:"",hyperlink:t?t[0].slice(1,-1):"",addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)}}{const[e,t]=n.split("](");return{matchedLink:n,link:t?t.slice(0,-1):"",hyperlink:e?e.slice(1):"",addSpaceBefore:!(!i||" "===i),addSpaceAfter:!(!r||" "===r)}}}));return i.forEach((t=>{if(t&&t.link&&t.hyperlink){const i=Ir().replace(/-/g,"");n.push({link:this.removeTrailingPunctuation(t.link),hyperlink:this.removeTrailingPunctuation(t.hyperlink),mark:t.matchedLink,id:i}),e=e.replace(t.matchedLink,`${t.addSpaceBefore?" ":""}${i}${t.addSpaceAfter?" ":""}`)}})),{hyperlinks:n,markedText:e}}async getLinkData(e){var n,i,r,o;try{const a=(await t().get(e)).data,s=(new DOMParser).parseFromString(a,"text/html");return s?{title:null!==(i=null===(n=s.querySelector("title"))||void 0===n?void 0:n.textContent)&&void 0!==i?i:null,description:(null===(r=s.querySelector('meta[name="description"]'))||void 0===r?void 0:r.getAttribute("content"))||null,image:(null===(o=s.querySelector('meta[property="og:image"]'))||void 0===o?void 0:o.getAttribute("content"))||null,favicon:null,link:e}:{title:null,description:null,image:null,favicon:null,link:e}}catch(t){return console.error("Error fetching website details:",t),{title:null,description:null,image:null,favicon:null,link:e}}}render(){return this.message?U`<div class="message-inner-body">
|
|
3527
3527
|
${this.isMessageStillStreamingChunks()?U`<div class="message-loader"><mini-loader></mini-loader></div>`:""}
|
|
3528
3528
|
<p
|
|
3529
3529
|
class=${fe({"message-text":!0,"webchat-font__desktop":!dn(),"webchat-font__mobile":dn()})}
|
|
@@ -87,44 +87,46 @@ export class PubnubMessage extends LitElement {
|
|
|
87
87
|
const urlRegex = /(https?:\/\/[^\s]+)/g; // Regular expression to match URLs
|
|
88
88
|
const loadingWebsitePreviews: Promise<WebsitePreview>[] = [];
|
|
89
89
|
const imagesToDisplay: ImageToDisplay[] = [];
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
90
|
+
this.parsedMessage = html`${markedText
|
|
91
|
+
.trim()
|
|
92
|
+
.split("\n")
|
|
93
|
+
.map((line) => {
|
|
94
|
+
const sanitizedLine = this.sanitizeMarkdownText(line);
|
|
95
|
+
const allWords = this.preserveHTMLTags(sanitizedLine);
|
|
96
|
+
if (!allWords) return html``;
|
|
97
|
+
return html`${allWords.map((word) => {
|
|
98
|
+
if (hyperlinks.find((obj) => obj.id === word)) {
|
|
99
|
+
// EliseAI made hyperlink
|
|
100
|
+
const link = hyperlinks.find((obj) => obj.id === word);
|
|
101
|
+
if (!link) return;
|
|
102
|
+
imagesToDisplay.push({
|
|
103
|
+
redirectTo: link?.link,
|
|
104
|
+
source: link?.link,
|
|
105
|
+
});
|
|
106
|
+
return html`<a
|
|
107
|
+
class="redirect-link"
|
|
108
|
+
href="${link?.link}"
|
|
109
|
+
target="_blank"
|
|
110
|
+
rel="noopener noreferrer"
|
|
111
|
+
>${link?.hyperlink}
|
|
112
|
+
</a>`;
|
|
113
|
+
}
|
|
114
|
+
if (urlRegex.test(word)) {
|
|
115
|
+
// general url
|
|
116
|
+
const link = this.removeTrailingPunctuation(word);
|
|
117
|
+
loadingWebsitePreviews.push(this.getLinkData(link));
|
|
118
|
+
return html`<a
|
|
119
|
+
class="redirect-link"
|
|
120
|
+
href="${link}"
|
|
121
|
+
target="_blank"
|
|
122
|
+
rel="noopener noreferrer"
|
|
123
|
+
>${link}
|
|
124
|
+
</a>`;
|
|
125
|
+
} else {
|
|
126
|
+
return html`${unsafeHTML(DOMPurify.sanitize(word))} `;
|
|
127
|
+
}
|
|
128
|
+
})}<br />`;
|
|
129
|
+
})}`;
|
|
128
130
|
this.imagesToDisplay = imagesToDisplay;
|
|
129
131
|
Promise.all(loadingWebsitePreviews).then((results) => {
|
|
130
132
|
this.websitePreviewInfo = results;
|