@insight-health/aura 0.0.8 → 0.0.9
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/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C={insightBaseUrl:"https://anywhere.insighthealth.ai"};let w=null;function E(){return w}function B(s){w={...C,...s}}function I(s){B(s)}function g(){const s=E();if(!s)throw new Error("Aura SDK not configured. Call configure() first to set global configuration.");return s}function b(){return"0.0.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C={insightBaseUrl:"https://anywhere.insighthealth.ai"};let w=null;function E(){return w}function B(s){w={...C,...s}}function I(s){B(s)}function g(){const s=E();if(!s)throw new Error("Aura SDK not configured. Call configure() first to set global configuration.");return s}function b(){return"0.0.9"}class S{constructor(){this.events={},this.subscribe=(e,t)=>(this.events[e]||(this.events[e]=[]),this.events[e].push(t),()=>{this.events[e]=this.events[e].filter(i=>i!==t)}),this.emit=(e,t)=>{this.events[e]&&this.events[e].forEach(i=>i(t))}}}const o=new S,f={log:s=>{console.log(`[Insight Health Aura Widget]: ${s}`)},warn:s=>{console.warn(`[Insight Health Aura Widget]: ${s}`)},error:s=>{console.error(`[Insight Health Aura Widget]: ${s}`)}},m={opacity:"0",pointerEvents:"none",width:"0",height:"0",maxWidth:"0",maxHeight:"0"},U={border:"none",borderRadius:"10px",boxShadow:"0 0 10px 0 rgba(0, 0, 0, 0.1)",overflow:"hidden",background:"#fff",position:"fixed",bottom:"20px",right:"20px",transition:"opacity 0.2s ease-in-out, width 0.2s ease-in-out, height 0.2s ease-in-out, max-width 0.2s ease-in-out, max-height 0.2s ease-in-out",zIndex:"9999"};class v{constructor(){this.config=null,this.widgetFrame=null,this.unsubsciptions=[],this.messageQueue=[],this.isQueueingEnabled=!1,this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.postMessage=e=>{var i;if(!((i=this.widgetFrame)!=null&&i.contentWindow)){f.warn("No widget iframe to communicate with");return}const t=g();this.widgetFrame.contentWindow.postMessage(e,{targetOrigin:t.insightBaseUrl})},this.enableQueue=()=>{this.isQueueingEnabled=!0},this.disableQueue=(e=!1)=>{this.isQueueingEnabled=!1,e&&this.flushQueue()},this.flushQueue=()=>{const e=[...this.messageQueue];this.clearQueue(),e.forEach(t=>{this.postMessage(t)})},this.clearQueue=()=>{this.messageQueue=[]},this.sendOrQueue=e=>{if(this.isQueueingEnabled){this.messageQueue.push(e);return}this.postMessage(e)},this.init=e=>new Promise(t=>{if(!this.widgetFrame){this.reset(),this.enableQueue();const i=g(),{tenantId:r,tenantName:a,user:h,language:p,container:d,widgetId:F,widgetStyles:n}=e;this.config=e,this.isFrameReady=!1,this.widgetFrame=document.createElement("iframe");const y=(n==null?void 0:n.width)||"350px",Q=(n==null?void 0:n.height)||"600px",A={...U,...n,...m};Object.assign(this.widgetFrame.style,A),this.widgetFrame.id=F||"aura-widget",this.widgetFrame.setAttribute("allow",`microphone ${i.insightBaseUrl}; camera ${i.insightBaseUrl}; clipboard-read ${i.insightBaseUrl}; clipboard-write ${i.insightBaseUrl};`),this.widgetFrame.src=`${i.insightBaseUrl}`,this.widgetFrame.__desiredWidth=y,this.widgetFrame.__desiredHeight=Q,this.widgetFrame.onerror=()=>{f.error(`Failed to load iframe. Please ensure your Content Security Policy includes:
|
|
2
2
|
frame-src ${i.insightBaseUrl}
|
|
3
3
|
`)},(d&&document.querySelector(d)||document.body).appendChild(this.widgetFrame);const x=o.subscribe("Auth.Ready",()=>{this.isFrameReady=!0,this.setUser({tenantId:r,tenantName:a,user:h,language:p})}),W=o.subscribe("Auth.Complete",l=>{var c;this.isFrameAuthenticated=!0,this.disableQueue(!0),t(l),(c=e.onAuthenticated)==null||c.call(e,l)});this.unsubsciptions.push(x,W)}}),this.setUser=e=>{const t=this.config.partnerKey,{tenantId:i,tenantName:r,user:a,language:h}=e;this.config.tenantId=i,this.config.tenantName=r,this.config.user=a,this.config.language=h,this.isFrameAuthenticated=!1,this.postMessage({type:"Auth.Login",payload:{partnerKey:t,tenantId:i,tenantName:r,user:a,language:h}})},this.show=()=>{if(this.widgetFrame){const e=this.widgetFrame.__desiredWidth||"350px",t=this.widgetFrame.__desiredHeight||"600px",i={opacity:"1",pointerEvents:"auto",width:e,height:t,maxWidth:e,maxHeight:t};Object.assign(this.widgetFrame.style,{...i})}},this.hide=()=>{this.widgetFrame&&Object.assign(this.widgetFrame.style,{...m})},this.reset=()=>{this.widgetFrame&&this.widgetFrame.remove(),this.widgetFrame=null,this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.unsubsciptions.forEach(e=>e==null?void 0:e()),this.unsubsciptions=[],this.disableQueue(),this.clearQueue()},this.command=e=>{this.sendOrQueue(e),this.show()},this.emit=this.command,this.on=(e,t)=>o.subscribe(e,t),this.registerTemplates=e=>{this.sendOrQueue({type:"Template.Register",payload:e})},this.getConfig=()=>this.config,this.getVersion=()=>b(),window.addEventListener("message",e=>{var t;e.source!==((t=this.widgetFrame)==null?void 0:t.contentWindow)||!e.data||o.emit(e.data.type,e.data.payload)})}}let u=null;function H(){return u||(u=new v),u}const $=H();exports.AuraWidget=$;exports.configure=I;exports.getConfig=g;exports.getVersion=b;
|
package/dist/index.js
CHANGED
package/dist/index.umd.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(n,a){typeof exports=="object"&&typeof module<"u"?a(exports):typeof define=="function"&&define.amd?define(["exports"],a):(n=typeof globalThis<"u"?globalThis:n||self,a(n.InsightAura={}))})(this,function(n){"use strict";const a={insightBaseUrl:"https://anywhere.insighthealth.ai"};let c=null;function y(){return c}function Q(s){c={...a,...s}}function A(s){Q(s)}function g(){const s=y();if(!s)throw new Error("Aura SDK not configured. Call configure() first to set global configuration.");return s}function f(){return"0.0.
|
|
1
|
+
(function(n,a){typeof exports=="object"&&typeof module<"u"?a(exports):typeof define=="function"&&define.amd?define(["exports"],a):(n=typeof globalThis<"u"?globalThis:n||self,a(n.InsightAura={}))})(this,function(n){"use strict";const a={insightBaseUrl:"https://anywhere.insighthealth.ai"};let c=null;function y(){return c}function Q(s){c={...a,...s}}function A(s){Q(s)}function g(){const s=y();if(!s)throw new Error("Aura SDK not configured. Call configure() first to set global configuration.");return s}function f(){return"0.0.9"}class x{constructor(){this.events={},this.subscribe=(e,t)=>(this.events[e]||(this.events[e]=[]),this.events[e].push(t),()=>{this.events[e]=this.events[e].filter(i=>i!==t)}),this.emit=(e,t)=>{this.events[e]&&this.events[e].forEach(i=>i(t))}}}const h=new x,m={log:s=>{console.log(`[Insight Health Aura Widget]: ${s}`)},warn:s=>{console.warn(`[Insight Health Aura Widget]: ${s}`)},error:s=>{console.error(`[Insight Health Aura Widget]: ${s}`)}},w={opacity:"0",pointerEvents:"none",width:"0",height:"0",maxWidth:"0",maxHeight:"0"},W={border:"none",borderRadius:"10px",boxShadow:"0 0 10px 0 rgba(0, 0, 0, 0.1)",overflow:"hidden",background:"#fff",position:"fixed",bottom:"20px",right:"20px",transition:"opacity 0.2s ease-in-out, width 0.2s ease-in-out, height 0.2s ease-in-out, max-width 0.2s ease-in-out, max-height 0.2s ease-in-out",zIndex:"9999"};class C{constructor(){this.config=null,this.widgetFrame=null,this.unsubsciptions=[],this.messageQueue=[],this.isQueueingEnabled=!1,this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.postMessage=e=>{var i;if(!((i=this.widgetFrame)!=null&&i.contentWindow)){m.warn("No widget iframe to communicate with");return}const t=g();this.widgetFrame.contentWindow.postMessage(e,{targetOrigin:t.insightBaseUrl})},this.enableQueue=()=>{this.isQueueingEnabled=!0},this.disableQueue=(e=!1)=>{this.isQueueingEnabled=!1,e&&this.flushQueue()},this.flushQueue=()=>{const e=[...this.messageQueue];this.clearQueue(),e.forEach(t=>{this.postMessage(t)})},this.clearQueue=()=>{this.messageQueue=[]},this.sendOrQueue=e=>{if(this.isQueueingEnabled){this.messageQueue.push(e);return}this.postMessage(e)},this.init=e=>new Promise(t=>{if(!this.widgetFrame){this.reset(),this.enableQueue();const i=g(),{tenantId:o,tenantName:u,user:d,language:B,container:p,widgetId:S,widgetStyles:r}=e;this.config=e,this.isFrameReady=!1,this.widgetFrame=document.createElement("iframe");const U=(r==null?void 0:r.width)||"350px",v=(r==null?void 0:r.height)||"600px",H={...W,...r,...w};Object.assign(this.widgetFrame.style,H),this.widgetFrame.id=S||"aura-widget",this.widgetFrame.setAttribute("allow",`microphone ${i.insightBaseUrl}; camera ${i.insightBaseUrl}; clipboard-read ${i.insightBaseUrl}; clipboard-write ${i.insightBaseUrl};`),this.widgetFrame.src=`${i.insightBaseUrl}`,this.widgetFrame.__desiredWidth=U,this.widgetFrame.__desiredHeight=v,this.widgetFrame.onerror=()=>{m.error(`Failed to load iframe. Please ensure your Content Security Policy includes:
|
|
2
2
|
frame-src ${i.insightBaseUrl}
|
|
3
3
|
`)},(p&&document.querySelector(p)||document.body).appendChild(this.widgetFrame);const $=h.subscribe("Auth.Ready",()=>{this.isFrameReady=!0,this.setUser({tenantId:o,tenantName:u,user:d,language:B})}),O=h.subscribe("Auth.Complete",b=>{var F;this.isFrameAuthenticated=!0,this.disableQueue(!0),t(b),(F=e.onAuthenticated)==null||F.call(e,b)});this.unsubsciptions.push($,O)}}),this.setUser=e=>{const t=this.config.partnerKey,{tenantId:i,tenantName:o,user:u,language:d}=e;this.config.tenantId=i,this.config.tenantName=o,this.config.user=u,this.config.language=d,this.isFrameAuthenticated=!1,this.postMessage({type:"Auth.Login",payload:{partnerKey:t,tenantId:i,tenantName:o,user:u,language:d}})},this.show=()=>{if(this.widgetFrame){const e=this.widgetFrame.__desiredWidth||"350px",t=this.widgetFrame.__desiredHeight||"600px",i={opacity:"1",pointerEvents:"auto",width:e,height:t,maxWidth:e,maxHeight:t};Object.assign(this.widgetFrame.style,{...i})}},this.hide=()=>{this.widgetFrame&&Object.assign(this.widgetFrame.style,{...w})},this.reset=()=>{this.widgetFrame&&this.widgetFrame.remove(),this.widgetFrame=null,this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.unsubsciptions.forEach(e=>e==null?void 0:e()),this.unsubsciptions=[],this.disableQueue(),this.clearQueue()},this.command=e=>{this.sendOrQueue(e),this.show()},this.emit=this.command,this.on=(e,t)=>h.subscribe(e,t),this.registerTemplates=e=>{this.sendOrQueue({type:"Template.Register",payload:e})},this.getConfig=()=>this.config,this.getVersion=()=>f(),window.addEventListener("message",e=>{var t;e.source!==((t=this.widgetFrame)==null?void 0:t.contentWindow)||!e.data||h.emit(e.data.type,e.data.payload)})}}let l=null;function E(){return l||(l=new C),l}const I=E();n.AuraWidget=I,n.configure=A,n.getConfig=g,n.getVersion=f,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
|
package/dist/types.d.ts
CHANGED
|
@@ -7,10 +7,10 @@ export type AuraWidgetInitParams = {
|
|
|
7
7
|
tenantId: string | number;
|
|
8
8
|
tenantName?: string;
|
|
9
9
|
user: {
|
|
10
|
+
id: string;
|
|
10
11
|
email: string;
|
|
11
12
|
firstName?: string;
|
|
12
13
|
lastName?: string;
|
|
13
|
-
ehrId?: string | number;
|
|
14
14
|
};
|
|
15
15
|
language?: string;
|
|
16
16
|
container?: string;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,CAAC,CAAC,GAAG,GAAG,IAAI;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,GAAG,MAAM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