@eka-care/medassist-widget-embed 0.2.43 → 0.2.45
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/dist/eka-agents.html +5 -5
- package/dist/iframe.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/eka-agents.html
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<link
|
|
15
15
|
rel="preload"
|
|
16
16
|
as="script"
|
|
17
|
-
href="https://unpkg.com/@eka-care/medassist-widget@0.1.
|
|
17
|
+
href="https://unpkg.com/@eka-care/medassist-widget@0.1.64/dist/medassist-widget.js"
|
|
18
18
|
fetchpriority="high"
|
|
19
19
|
crossorigin
|
|
20
20
|
/>
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
<link
|
|
24
24
|
rel="preload"
|
|
25
25
|
as="style"
|
|
26
|
-
href="https://unpkg.com/@eka-care/medassist-widget@0.1.
|
|
26
|
+
href="https://unpkg.com/@eka-care/medassist-widget@0.1.64/dist/medassist-widget.css"
|
|
27
27
|
onload="this.rel='stylesheet'"
|
|
28
28
|
crossorigin
|
|
29
29
|
/>
|
|
30
30
|
<noscript>
|
|
31
31
|
<link
|
|
32
32
|
rel="stylesheet"
|
|
33
|
-
href="https://unpkg.com/@eka-care/medassist-widget@0.1.
|
|
33
|
+
href="https://unpkg.com/@eka-care/medassist-widget@0.1.64/dist/medassist-widget.css"
|
|
34
34
|
/>
|
|
35
35
|
</noscript>
|
|
36
36
|
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
|
|
63
63
|
<!-- Production: served from unpkg. For local dev swap with: <script src="./src/medassist-widget.js" onload="init()" async></script> -->
|
|
64
64
|
<script
|
|
65
|
-
src="https://unpkg.com/@eka-care/medassist-widget@0.1.
|
|
65
|
+
src="https://unpkg.com/@eka-care/medassist-widget@0.1.64/dist/medassist-widget.js"
|
|
66
66
|
onload="init()"
|
|
67
67
|
fetchpriority="high"
|
|
68
68
|
crossorigin
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
title:p.get("title")||(cfg&&cfg.name)||undefined,
|
|
127
127
|
iconUrl:p.get("iconUrl")||(cfg&&cfg.theme&&cfg.theme.icon_img)||undefined,
|
|
128
128
|
resize:p.get("resize")==="true"||!!(cfg&&cfg.resize),
|
|
129
|
-
connectionType:p.get("connectivity")||(cfg&&cfg.connectivity)||"
|
|
129
|
+
connectionType:p.get("connectivity")||(cfg&&cfg.connectivity)||"socket",
|
|
130
130
|
allowed:cfg&&cfg.allowed,
|
|
131
131
|
initialMessage:cfg&&cfg.initial_message,
|
|
132
132
|
hideWatermark:!!(cfg&&cfg.theme&&cfg.theme.hide_watermark),
|
package/dist/iframe.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(function(){const $=()=>{if(typeof document=="undefined")return null;const{currentScript:e}=document;if(e instanceof HTMLScriptElement)return e;const t=document.getElementsByTagName("script");return t.length?t[t.length-1]:null},W=e=>{if(e==="production"||e==="development"||e==="staging")return e};function F(e){if(!e)return;const t=e.mode==="dark"?"white":e.mode==="light"?"black":void 0;return{...e.background&&{background:e.background},...e.background_img&&{backgroundImage:e.background_img},...e.accent&&{primary:e.accent},...t&&{textColor:t},...e.title_img&&{titleImg:e.title_img}}}function E(e){if(!(!e||typeof document=="undefined"))try{const t=document.createElement("link");t.rel="preload",t.as="image",t.href=e,document.head.appendChild(t)}catch{const t=new Image;t.src=e}}async function R(e,t){const r=`${e.replace(/\/$/,"")}/med-assist/agent-config/${t}`,n=new AbortController,i=setTimeout(()=>n.abort(),1e4);try{const s=await fetch(r,{signal:n.signal,headers:{"ngrok-skip-browser-warning":"69420"}});if(!s.ok)return;const c=await s.json();return c!=null&&c.success&&(c!=null&&c.data)?c.data:void 0}catch{return}finally{clearTimeout(i)}}const _="https://unpkg.com/@eka-care/medassist-widget@latest/dist/",a=$(),C=(()=>{if(!a)return"";try{return new URL(".",a.src||window.location.href).href}catch{return""}})(),m=(()=>{if(!a)return _;const e=a.dataset.widgetAssets;if(e==="local")return`${C}src/`;if(e&&e.length>0)try{return new URL(e,C).href}catch{return e.endsWith("/")?e:`${e}/`}return _})(),l=`${m}medassist-widget.js`,g=`${m}medassist-widget.css`;let f=null,w=null;const d=new URLSearchParams(typeof window!="undefined"?window.location.search:""),S=d.get("agentId"),p=d.get("baseUrl")||"https://matrix.eka.care/reloaded";if(typeof document!="undefined"&&document.head){try{const e=new URL(m).origin,t=new URL(p).origin,r=document.createElement("link");if(r.rel="preconnect",r.href=e,r.crossOrigin="anonymous",document.head.appendChild(r),e!==t){const s=document.createElement("link");s.rel="preconnect",s.href=t,s.crossOrigin="anonymous",document.head.appendChild(s)}const n=document.createElement("link");n.rel="preload",n.as="script",n.href=l,document.head.appendChild(n);const i=document.createElement("link");i.rel="preload",i.as="style",i.href=g,document.head.appendChild(i)}catch{}I(),U()}const b=S&&p?R(p,S):Promise.resolve(void 0);if(typeof document!="undefined"&&document.head){const e=d.get("theme");if(e)try{const t=JSON.parse(e);t.backgroundImage&&E(t.backgroundImage)}catch{}b.then(t=>{var r;const n=(r=t==null?void 0:t.theme)===null||r===void 0?void 0:r.background_img;n&&E(n)})}const A=async()=>{var e,t,r,n,i,s,c;const L=d.get("agentId");if(!L){console.error("Agent ID is required in URL parameters");return}let h=d.get("title")||"Medi Clinic",v=d.get("iconUrl")||void 0;const M=d.get("context"),B=d.get("baseUrl")||"https://matrix.eka.care/reloaded",D=d.get("resize")==="true"?!0:void 0,z=(e=W(d.get("environment")))!==null&&e!==void 0?e:"production",y=d.get("connectivity"),G=y==="sse"||y==="socket"?y:void 0,k=d.get("theme")?(()=>{try{return JSON.parse(d.get("theme")||"{}")}catch{return}})():void 0,J=document.getElementById("root")||document.body;try{const[,,o]=await Promise.all([I(),U(),b]);if(!(window!=null&&window.renderMedAssist)||typeof(window==null?void 0:window.renderMedAssist)!="function")throw new Error("renderMedAssist is not available on window");let u,T,P,O,x=!1;o&&(h=(t=o==null?void 0:o.name)!==null&&t!==void 0?t:h,v=(n=(r=o==null?void 0:o.theme)===null||r===void 0?void 0:r.icon_img)!==null&&n!==void 0?n:v,u=F((i=o==null?void 0:o.theme)!==null&&i!==void 0?i:void 0),T=o==null?void 0:o.allowed,P=o==null?void 0:o.connectivity,O=o==null?void 0:o.initial_message,x=(c=(s=o==null?void 0:o.theme)===null||s===void 0?void 0:s.hide_watermark)!==null&&c!==void 0?c:!1);const N={title:h,iconUrl:v,environment:z,connectionType:P||G||"
|
|
1
|
+
"use strict";(function(){const $=()=>{if(typeof document=="undefined")return null;const{currentScript:e}=document;if(e instanceof HTMLScriptElement)return e;const t=document.getElementsByTagName("script");return t.length?t[t.length-1]:null},W=e=>{if(e==="production"||e==="development"||e==="staging")return e};function F(e){if(!e)return;const t=e.mode==="dark"?"white":e.mode==="light"?"black":void 0;return{...e.background&&{background:e.background},...e.background_img&&{backgroundImage:e.background_img},...e.accent&&{primary:e.accent},...t&&{textColor:t},...e.title_img&&{titleImg:e.title_img}}}function E(e){if(!(!e||typeof document=="undefined"))try{const t=document.createElement("link");t.rel="preload",t.as="image",t.href=e,document.head.appendChild(t)}catch{const t=new Image;t.src=e}}async function R(e,t){const r=`${e.replace(/\/$/,"")}/med-assist/agent-config/${t}`,n=new AbortController,i=setTimeout(()=>n.abort(),1e4);try{const s=await fetch(r,{signal:n.signal,headers:{"ngrok-skip-browser-warning":"69420"}});if(!s.ok)return;const c=await s.json();return c!=null&&c.success&&(c!=null&&c.data)?c.data:void 0}catch{return}finally{clearTimeout(i)}}const _="https://unpkg.com/@eka-care/medassist-widget@latest/dist/",a=$(),C=(()=>{if(!a)return"";try{return new URL(".",a.src||window.location.href).href}catch{return""}})(),m=(()=>{if(!a)return _;const e=a.dataset.widgetAssets;if(e==="local")return`${C}src/`;if(e&&e.length>0)try{return new URL(e,C).href}catch{return e.endsWith("/")?e:`${e}/`}return _})(),l=`${m}medassist-widget.js`,g=`${m}medassist-widget.css`;let f=null,w=null;const d=new URLSearchParams(typeof window!="undefined"?window.location.search:""),S=d.get("agentId"),p=d.get("baseUrl")||"https://matrix.eka.care/reloaded";if(typeof document!="undefined"&&document.head){try{const e=new URL(m).origin,t=new URL(p).origin,r=document.createElement("link");if(r.rel="preconnect",r.href=e,r.crossOrigin="anonymous",document.head.appendChild(r),e!==t){const s=document.createElement("link");s.rel="preconnect",s.href=t,s.crossOrigin="anonymous",document.head.appendChild(s)}const n=document.createElement("link");n.rel="preload",n.as="script",n.href=l,document.head.appendChild(n);const i=document.createElement("link");i.rel="preload",i.as="style",i.href=g,document.head.appendChild(i)}catch{}I(),U()}const b=S&&p?R(p,S):Promise.resolve(void 0);if(typeof document!="undefined"&&document.head){const e=d.get("theme");if(e)try{const t=JSON.parse(e);t.backgroundImage&&E(t.backgroundImage)}catch{}b.then(t=>{var r;const n=(r=t==null?void 0:t.theme)===null||r===void 0?void 0:r.background_img;n&&E(n)})}const A=async()=>{var e,t,r,n,i,s,c;const L=d.get("agentId");if(!L){console.error("Agent ID is required in URL parameters");return}let h=d.get("title")||"Medi Clinic",v=d.get("iconUrl")||void 0;const M=d.get("context"),B=d.get("baseUrl")||"https://matrix.eka.care/reloaded",D=d.get("resize")==="true"?!0:void 0,z=(e=W(d.get("environment")))!==null&&e!==void 0?e:"production",y=d.get("connectivity"),G=y==="sse"||y==="socket"?y:void 0,k=d.get("theme")?(()=>{try{return JSON.parse(d.get("theme")||"{}")}catch{return}})():void 0,J=document.getElementById("root")||document.body;try{const[,,o]=await Promise.all([I(),U(),b]);if(!(window!=null&&window.renderMedAssist)||typeof(window==null?void 0:window.renderMedAssist)!="function")throw new Error("renderMedAssist is not available on window");let u,T,P,O,x=!1;o&&(h=(t=o==null?void 0:o.name)!==null&&t!==void 0?t:h,v=(n=(r=o==null?void 0:o.theme)===null||r===void 0?void 0:r.icon_img)!==null&&n!==void 0?n:v,u=F((i=o==null?void 0:o.theme)!==null&&i!==void 0?i:void 0),T=o==null?void 0:o.allowed,P=o==null?void 0:o.connectivity,O=o==null?void 0:o.initial_message,x=(c=(s=o==null?void 0:o.theme)===null||s===void 0?void 0:s.hide_watermark)!==null&&c!==void 0?c:!1);const N={title:h,iconUrl:v,environment:z,connectionType:P||G||"socket",onClose:()=>{window.parent!==window&&window.parent.postMessage({type:"WIDGET_CLOSE"},"*")},context:M?JSON.parse(M):void 0,baseUrl:B,displayMode:"full",allowed:T,showCloseButton:!1,resize:D,initialMessage:O,hideWatermark:x,theme:{...u!=null?u:{},...k!=null?k:{}}};window.renderMedAssist(J,L,N)}catch(o){throw console.error("Failed to initialize MedAssist widget",o),o}};async function I(){document.querySelector("link[data-medassist-style='true']")||(w||(w=new Promise((t,r)=>{const n=document.createElement("link");n.rel="stylesheet",n.href=g,n.setAttribute("data-medassist-style","true"),n.onload=()=>{t("")},n.onerror=()=>{r(new Error(`Failed to load ${g}`))},document.head.appendChild(n)})),await w)}function U(){return f||(f=new Promise((e,t)=>{const r=document.querySelector(`script[src="${l}"]`);if(r){if(r.dataset.loaded==="true"){e();return}r.addEventListener("load",()=>e()),r.addEventListener("error",i=>t(i.error||new Error("Unknown script loading error")));return}const n=document.createElement("script");n.src=l,n.async=!0,n.dataset.widget="medassist",n.onload=()=>{n.dataset.loaded="true",e()},n.onerror=i=>{if(i instanceof ErrorEvent&&i.error){t(i.error);return}t(new Error(`Failed to load ${l}`))},document.head.appendChild(n)})),f}if(typeof document!="undefined")if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",A);else try{A()}catch(e){console.error("Failed to initialize MedAssist widget",e)}})();
|
package/dist/index.js
CHANGED
|
@@ -138,4 +138,4 @@
|
|
|
138
138
|
}
|
|
139
139
|
</style>
|
|
140
140
|
<div id="medassist-widget-root"></div>
|
|
141
|
-
`)}async loadAndRender(){var t,o,i,n,s;const r=this.shadowRoot;if(!r){console.error("Shadow root is not available");return}this.style.display="";const d=r.getElementById("medassist-open-btn"),l=r.getElementById("medassist-widget-root"),u=this.getAttribute("agent-id");let c=this.getAttribute("icon-url")||this.defaultIconUrl;const w=(t=getEnvironment(this.getAttribute("environment")))!==null&&t!==void 0?t:"production",p=this.getAttribute("connectivity"),f=p==="sse"||p==="socket"?p:void 0;let m=this.getAttribute("title")||"Medi Clinic";const h=this.getAttribute("base-url")||"https://matrix.eka.care/reloaded",A=this.getAttribute("display-mode")==="full"?"full":"widget",U=this.getAttribute("context")?JSON.parse(this.getAttribute("context")||"{}"):void 0,L=this.getAttribute("theme")?(()=>{try{return JSON.parse(this.getAttribute("theme")||"{}")}catch{return}})():void 0,g=(typeof window!="undefined"?window.__ekaMedAssistConfig__:void 0)||{},R={...U||{},...g.context||{}},N=g.auth||void 0,y=g.agentId||u,B=g.baseUrl||h,v=typeof window!="undefined"?(o=window.EkaMedAssist)===null||o===void 0?void 0:o.onClose:void 0,P=this.getAttribute("redirect-url")||void 0,b=g.redirectUrl||P,W=!!b||g.showCloseButton===!0;if(!y){console.error("Agent ID is required");return}if(!l){console.error("Widget root element is missing");return}d&&d.classList.add("hidden"),l.classList.remove("hidden");let _,C,k,E=!1,S,M=!1;try{const a=await this.getAgentConfig();m=(a==null?void 0:a.name)||m,c=((i=a==null?void 0:a.theme)===null||i===void 0?void 0:i.icon_img)||c,_=mapAgentConfigThemeToWidgetTheme((a==null?void 0:a.theme)||void 0),C=a==null?void 0:a.allowed,k=a==null?void 0:a.connectivity,E=(a==null?void 0:a.resize)||(g==null?void 0:g.resize)||!1,S=a==null?void 0:a.initial_message,M=(s=(n=a==null?void 0:a.theme)===null||n===void 0?void 0:n.hide_watermark)!==null&&s!==void 0?s:!1}catch{}const $=k||f||"
|
|
141
|
+
`)}async loadAndRender(){var t,o,i,n,s;const r=this.shadowRoot;if(!r){console.error("Shadow root is not available");return}this.style.display="";const d=r.getElementById("medassist-open-btn"),l=r.getElementById("medassist-widget-root"),u=this.getAttribute("agent-id");let c=this.getAttribute("icon-url")||this.defaultIconUrl;const w=(t=getEnvironment(this.getAttribute("environment")))!==null&&t!==void 0?t:"production",p=this.getAttribute("connectivity"),f=p==="sse"||p==="socket"?p:void 0;let m=this.getAttribute("title")||"Medi Clinic";const h=this.getAttribute("base-url")||"https://matrix.eka.care/reloaded",A=this.getAttribute("display-mode")==="full"?"full":"widget",U=this.getAttribute("context")?JSON.parse(this.getAttribute("context")||"{}"):void 0,L=this.getAttribute("theme")?(()=>{try{return JSON.parse(this.getAttribute("theme")||"{}")}catch{return}})():void 0,g=(typeof window!="undefined"?window.__ekaMedAssistConfig__:void 0)||{},R={...U||{},...g.context||{}},N=g.auth||void 0,y=g.agentId||u,B=g.baseUrl||h,v=typeof window!="undefined"?(o=window.EkaMedAssist)===null||o===void 0?void 0:o.onClose:void 0,P=this.getAttribute("redirect-url")||void 0,b=g.redirectUrl||P,W=!!b||g.showCloseButton===!0;if(!y){console.error("Agent ID is required");return}if(!l){console.error("Widget root element is missing");return}d&&d.classList.add("hidden"),l.classList.remove("hidden");let _,C,k,E=!1,S,M=!1;try{const a=await this.getAgentConfig();m=(a==null?void 0:a.name)||m,c=((i=a==null?void 0:a.theme)===null||i===void 0?void 0:i.icon_img)||c,_=mapAgentConfigThemeToWidgetTheme((a==null?void 0:a.theme)||void 0),C=a==null?void 0:a.allowed,k=a==null?void 0:a.connectivity,E=(a==null?void 0:a.resize)||(g==null?void 0:g.resize)||!1,S=a==null?void 0:a.initial_message,M=(s=(n=a==null?void 0:a.theme)===null||n===void 0?void 0:n.hide_watermark)!==null&&s!==void 0?s:!1}catch{}const $=k||f||"socket",I={title:g.title||m,iconUrl:c||g.iconUrl,showCloseButton:W,allowed:C,environment:w,connectionType:$,onClose:()=>{var a;if((a=this.reactRoot)===null||a===void 0||a.unmount(),this.reactRoot=null,v&&typeof v=="function"&&v(),b){window.location.href=b;return}A==="full"?this.style.display="none":(d&&d.classList.remove("hidden"),l.classList.add("hidden"))},baseUrl:B,context:R,displayMode:A,resize:E||this.getAttribute("resize")==="true",auth:N,initialMessage:S,hideWatermark:M,theme:{..._||{},...L||{},...g.theme||{}}},x=window;if(this.widgetLoaded){this.reactRoot=x.renderMedAssist(l,y,I);return}try{if(await Promise.all([this.loadWidgetCss(),this.loadWidgetScript()]),typeof x.renderMedAssist!="function")throw new Error("renderMedAssist is not available on window");this.reactRoot=x.renderMedAssist(l,y,I),this.widgetLoaded=!0}catch(a){console.error("Failed to load MedAssist widget",a),d&&d.classList.remove("hidden"),l.classList.add("hidden")}}async loadWidgetCss(){const t=this.shadowRoot;if(!t)throw new Error("Shadow root is not available");if(t.querySelector("[data-medassist-style='true']"))return;const o=await getWidgetCssTextPromise(),i=document.createElement("style");i.setAttribute("data-medassist-style","true"),i.textContent=o,t.appendChild(i)}loadWidgetScript(){return widgetScriptPromise||(widgetScriptPromise=new Promise((t,o)=>{const i=document.querySelector(`script[src="${WIDGET_JS_URL}"]`);if(i){if(i.dataset.loaded==="true"){t();return}i.addEventListener("load",()=>t()),i.addEventListener("error",s=>o(s.error||new Error("Unknown script loading error")));return}const n=document.createElement("script");n.src=WIDGET_JS_URL,n.async=!0,n.dataset.widget="medassist",n.onload=()=>{n.dataset.loaded="true",t()},n.onerror=s=>{if(s instanceof ErrorEvent&&s.error){o(s.error);return}o(new Error(`Failed to load ${WIDGET_JS_URL}`))},document.head.appendChild(n)})),widgetScriptPromise}}customElements.define("eka-medassist-widget",MedAssistWidgetLoader);
|