@meetelise/chat 1.20.241 → 1.20.242
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
CHANGED
package/public/dist/index.js
CHANGED
|
@@ -3621,7 +3621,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
|
|
|
3621
3621
|
transform: rotate(360deg);
|
|
3622
3622
|
}
|
|
3623
3623
|
}
|
|
3624
|
-
`,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}([ae("mini-loader")],Vr);var 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};let Kr=class extends re{constructor(){super(...arguments),this.onMount=()=>({}),this.loadingPreviews=!0,this.websitePreviewInfo=[],this.imagesToDisplay=[],this.imageUrlError=[],this.isLeadMessage=!1}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){var t;if(this.onMount(),!e.has("message"))return;if(!this.message)return;try{
|
|
3624
|
+
`,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}([ae("mini-loader")],Vr);var 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};let Kr=class extends re{constructor(){super(...arguments),this.onMount=()=>({}),this.loadingPreviews=!0,this.websitePreviewInfo=[],this.imagesToDisplay=[],this.imageUrlError=[],this.isLeadMessage=!1}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){var t;if(this.onMount(),!e.has("message"))return;if(!this.message)return;try{this.isMessageStillStreamingChunks()||this.isLeadMessage||!this.invalidMarkdownText(this.message.message)||si({logType:ai.error,logTitle:"INVALID_MARKDOWN",logData:{message:this.message.message,chatId:null===(t=this.myPubnub)||void 0===t?void 0:t.channel},buildingSlug:this.buildingSlug})}catch(e){console.error("Error parsing markdown:",e)}const{hyperlinks:n,markedText:i}=this.mapAndMarkHyperLinks(this.message.message),r=/(https?:\/\/[^\s]+)/g,o=[],a=[];this.parsedMessage=U`${i.trim().split("\n").map((e=>{const t=this.sanitizeMarkdownText(e),i=this.preserveHTMLTags(t);return i?U`${i.map((e=>{if(n.find((t=>t.id===e))){const t=n.find((t=>t.id===e));if(!t)return;return a.push({redirectTo:null==t?void 0:t.link,source:null==t?void 0:t.link}),U`<a
|
|
3625
3625
|
class="redirect-link"
|
|
3626
3626
|
href="${null==t?void 0:t.link}"
|
|
3627
3627
|
target="_blank"
|
|
@@ -3633,7 +3633,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
|
|
|
3633
3633
|
target="_blank"
|
|
3634
3634
|
rel="noopener noreferrer"
|
|
3635
3635
|
>${t}
|
|
3636
|
-
</a>`}return U`${Wr(Gr().sanitize(e))} `}))}<br />`:U``}))}`,this.imagesToDisplay=a,Promise.all(o).then((e=>{this.websitePreviewInfo=e}))}invalidMarkdownText(e){try{return[/\*\*[^*\n]
|
|
3636
|
+
</a>`}return U`${Wr(Gr().sanitize(e))} `}))}<br />`:U``}))}`,this.imagesToDisplay=a,Promise.all(o).then((e=>{this.websitePreviewInfo=e}))}invalidMarkdownText(e){try{return[/\*\*[^*\n]*\*$/,/__[^_\n]*_$/,/`[^`\n]*`$/,/\[[^\]\n]*\]$/,/\[[^\]]*\]\([^)\n]*\)$/,/^(#+)\s*$/,/(^|[^!])\[[^\]]*\]\(([^)]+)\s*\)$/,/(?:^|\s)[*_]{1,2}(?:\s|$)/].some((t=>t.test(e)))}catch(e){return!1}}preserveHTMLTags(e){var t;const n=e.match(/(<\/?[a-z][^>]*>[^<]*<\/?[a-z]*>|[^\s]+[.,?!]?|\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">
|
|
3637
3637
|
${this.isMessageStillStreamingChunks()?U`<div class="message-loader"><mini-loader></mini-loader></div>`:""}
|
|
3638
3638
|
<p
|
|
3639
3639
|
class=${fe({"message-text":!0,"webchat-font__desktop":!dn(),"webchat-font__mobile":dn()})}
|
|
@@ -91,6 +91,7 @@ export class PubnubMessage extends LitElement {
|
|
|
91
91
|
|
|
92
92
|
try {
|
|
93
93
|
if (
|
|
94
|
+
!this.isMessageStillStreamingChunks() &&
|
|
94
95
|
!this.isLeadMessage &&
|
|
95
96
|
this.invalidMarkdownText(this.message.message)
|
|
96
97
|
) {
|
|
@@ -164,13 +165,13 @@ export class PubnubMessage extends LitElement {
|
|
|
164
165
|
private invalidMarkdownText(text: string): boolean {
|
|
165
166
|
try {
|
|
166
167
|
const markdownErrors = [
|
|
167
|
-
/\*\*[^*\n]
|
|
168
|
-
/__[^_\n]
|
|
169
|
-
/`[^`\n]
|
|
170
|
-
/\[[^\]\n]
|
|
171
|
-
/\[[^\]]*\]\([^)\n]
|
|
168
|
+
/\*\*[^*\n]*\*$/, // Unclosed bold (excluding newline)
|
|
169
|
+
/__[^_\n]*_$/, // Unclosed italic (excluding newline)
|
|
170
|
+
/`[^`\n]*`$/, // Unclosed code (excluding newline)
|
|
171
|
+
/\[[^\]\n]*\]$/, // Unclosed link text (excluding newline)
|
|
172
|
+
/\[[^\]]*\]\([^)\n]*\)$/, // Unclosed link URL (excluding newline)
|
|
172
173
|
/^(#+)\s*$/, // Header without text
|
|
173
|
-
/(^|[^!])\[[^\]]*\]\(([^)]+)\s
|
|
174
|
+
/(^|[^!])\[[^\]]*\]\(([^)]+)\s*\)$/, // Improperly formatted link
|
|
174
175
|
/(?:^|\s)[*_]{1,2}(?:\s|$)/, // Improper use of bold or italic
|
|
175
176
|
];
|
|
176
177
|
|