@insight-health/aura 0.0.7 → 0.0.8

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.
@@ -8,10 +8,17 @@ declare class AuraWidgetService {
8
8
  private config;
9
9
  private widgetFrame;
10
10
  private unsubsciptions;
11
+ private messageQueue;
12
+ private isQueueingEnabled;
11
13
  isFrameReady: boolean;
12
14
  isFrameAuthenticated: boolean;
13
15
  constructor();
14
16
  private postMessage;
17
+ private enableQueue;
18
+ private disableQueue;
19
+ private flushQueue;
20
+ private clearQueue;
21
+ private sendOrQueue;
15
22
  init: (params: AuraWidgetInitParams) => Promise<void>;
16
23
  setUser: (params: AuthParams) => void;
17
24
  show: () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"auraWidget.d.ts","sourceRoot":"","sources":["../src/auraWidget.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,EAEpB,mBAAmB,EACnB,UAAU,EACX,MAAM,SAAS,CAAC;AA0BjB;;;GAGG;AACH,cAAM,iBAAiB;IACrB,OAAO,CAAC,MAAM,CAAqC;IACnD,OAAO,CAAC,WAAW,CAAkC;IACrD,OAAO,CAAC,cAAc,CAAsB;IAC5C,YAAY,EAAE,OAAO,CAAS;IAC9B,oBAAoB,EAAE,OAAO,CAAS;;IAatC,OAAO,CAAC,WAAW,CASjB;IAEF,IAAI,GAAI,QAAQ,oBAAoB,mBAiElC;IAEF,OAAO,GAAI,QAAQ,UAAU,UAkB3B;IAEF,IAAI,aAeF;IAEF,IAAI,aAIF;IAEF,KAAK,aASH;IAEF,OAAO,GAAI,OAAO,mBAAmB,UAGnC;IAGF,IAAI,UANc,mBAAmB,UAMjB;IAEpB,EAAE,GAAI,MAAM,MAAM,EAAE,UAAU,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,KAAG,CAAC,MAAM,IAAI,CAAC,CAErE;IAEF,iBAAiB,GAAI,SAAS,2BAA2B,UAKvD;IAEF;;OAEG;IACH,SAAS,oCAEP;IACF,UAAU,eAER;CACH;AAgBD,eAAO,MAAM,UAAU,mBAAgB,CAAC"}
1
+ {"version":3,"file":"auraWidget.d.ts","sourceRoot":"","sources":["../src/auraWidget.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,EAEpB,mBAAmB,EACnB,UAAU,EACX,MAAM,SAAS,CAAC;AA0BjB;;;GAGG;AACH,cAAM,iBAAiB;IACrB,OAAO,CAAC,MAAM,CAAqC;IACnD,OAAO,CAAC,WAAW,CAAkC;IACrD,OAAO,CAAC,cAAc,CAAsB;IAC5C,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,iBAAiB,CAAkB;IAC3C,YAAY,EAAE,OAAO,CAAS;IAC9B,oBAAoB,EAAE,OAAO,CAAS;;IAatC,OAAO,CAAC,WAAW,CASjB;IAEF,OAAO,CAAC,WAAW,CAEjB;IAEF,OAAO,CAAC,YAAY,CAKlB;IAEF,OAAO,CAAC,UAAU,CAMhB;IAEF,OAAO,CAAC,UAAU,CAEhB;IAEF,OAAO,CAAC,WAAW,CAMjB;IAEF,IAAI,GAAI,QAAQ,oBAAoB,mBAqElC;IAEF,OAAO,GAAI,QAAQ,UAAU,UAkB3B;IAEF,IAAI,aAeF;IAEF,IAAI,aAIF;IAEF,KAAK,aAWH;IAEF,OAAO,GAAI,OAAO,mBAAmB,UAGnC;IAGF,IAAI,UANc,mBAAmB,UAMjB;IAEpB,EAAE,GAAI,MAAM,MAAM,EAAE,UAAU,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,KAAG,CAAC,MAAM,IAAI,CAAC,CAErE;IAEF,iBAAiB,GAAI,SAAS,2BAA2B,UAKvD;IAEF;;OAEG;IACH,SAAS,oCAEP;IACF,UAAU,eAER;CACH;AAgBD,eAAO,MAAM,UAAU,mBAAgB,CAAC"}
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v={insightBaseUrl:"https://anywhere.insighthealth.ai"};let w=null;function B(){return w}function I(s){w={...v,...s}}function U(s){I(s)}function d(){const s=B();if(!s)throw new Error("Aura SDK not configured. Call configure() first to set global configuration.");return s}function p(){return"0.0.7"}class H{constructor(){this.events={},this.subscribe=(t,e)=>(this.events[t]||(this.events[t]=[]),this.events[t].push(e),()=>{this.events[t]=this.events[t].filter(i=>i!==e)}),this.emit=(t,e)=>{this.events[t]&&this.events[t].forEach(i=>i(e))}}}const h=new H,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}`)}},f={opacity:"0",pointerEvents:"none",width:"0",height:"0",maxWidth:"0",maxHeight:"0"},S={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 ${constructor(){this.config=null,this.widgetFrame=null,this.unsubsciptions=[],this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.postMessage=t=>{var i;if(!((i=this.widgetFrame)!=null&&i.contentWindow)){m.warn("No widget iframe to communicate with");return}const e=d();this.widgetFrame.contentWindow.postMessage(t,{targetOrigin:e.insightBaseUrl})},this.init=t=>new Promise(e=>{if(!this.widgetFrame){this.reset();const i=d(),{tenantId:r,tenantName:o,user:a,language:F,container:c,widgetId:b,widgetStyles:n}=t;this.config=t,this.isFrameReady=!1,this.widgetFrame=document.createElement("iframe");const y=(n==null?void 0:n.width)||"350px",A=(n==null?void 0:n.height)||"600px",x={...S,...n,...f};Object.assign(this.widgetFrame.style,x),this.widgetFrame.id=b||"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=A,this.widgetFrame.onerror=()=>{m.error(`Failed to load iframe. Please ensure your Content Security Policy includes:
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.8"}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
- `)},(c&&document.querySelector(c)||document.body).appendChild(this.widgetFrame);const W=h.subscribe("Auth.Ready",()=>{this.isFrameReady=!0,this.setUser({tenantId:r,tenantName:o,user:a,language:F})}),C=h.subscribe("Auth.Complete",u=>{var l;this.isFrameAuthenticated=!0,e(u),(l=t.onAuthenticated)==null||l.call(t,u)});this.unsubsciptions.push(W,C)}}),this.setUser=t=>{const e=this.config.partnerKey,{tenantId:i,tenantName:r,user:o,language:a}=t;this.config.tenantId=i,this.config.tenantName=r,this.config.user=o,this.config.language=a,this.isFrameAuthenticated=!1,this.postMessage({type:"Auth.Login",payload:{partnerKey:e,tenantId:i,tenantName:r,user:o,language:a}})},this.show=()=>{if(this.widgetFrame){const t=this.widgetFrame.__desiredWidth||"350px",e=this.widgetFrame.__desiredHeight||"600px",i={opacity:"1",pointerEvents:"auto",width:t,height:e,maxWidth:t,maxHeight:e};Object.assign(this.widgetFrame.style,{...i})}},this.hide=()=>{this.widgetFrame&&Object.assign(this.widgetFrame.style,{...f})},this.reset=()=>{this.widgetFrame&&this.widgetFrame.remove(),this.widgetFrame=null,this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.unsubsciptions.forEach(t=>t==null?void 0:t()),this.unsubsciptions=[]},this.command=t=>{this.postMessage(t),this.show()},this.emit=this.command,this.on=(t,e)=>h.subscribe(t,e),this.registerTemplates=t=>{this.postMessage({type:"Template.Register",payload:t})},this.getConfig=()=>this.config,this.getVersion=()=>p(),window.addEventListener("message",t=>{var e;t.source!==((e=this.widgetFrame)==null?void 0:e.contentWindow)||!t.data||h.emit(t.data.type,t.data.payload)})}}let g=null;function E(){return g||(g=new $),g}const R=E();exports.AuraWidget=R;exports.configure=U;exports.getConfig=d;exports.getVersion=p;
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
@@ -1,37 +1,37 @@
1
- const C = {
1
+ const W = {
2
2
  insightBaseUrl: "https://anywhere.insighthealth.ai"
3
3
  };
4
4
  let w = null;
5
- function B() {
5
+ function C() {
6
6
  return w;
7
7
  }
8
- function I(s) {
9
- w = { ...C, ...s };
8
+ function E(s) {
9
+ w = { ...W, ...s };
10
10
  }
11
- function R(s) {
12
- I(s);
11
+ function v(s) {
12
+ E(s);
13
13
  }
14
- function l() {
15
- const s = B();
14
+ function c() {
15
+ const s = C();
16
16
  if (!s)
17
17
  throw new Error(
18
18
  "Aura SDK not configured. Call configure() first to set global configuration."
19
19
  );
20
20
  return s;
21
21
  }
22
- function U() {
23
- return "0.0.7";
22
+ function B() {
23
+ return "0.0.8";
24
24
  }
25
- class v {
25
+ class I {
26
26
  constructor() {
27
- this.events = {}, this.subscribe = (t, e) => (this.events[t] || (this.events[t] = []), this.events[t].push(e), () => {
28
- this.events[t] = this.events[t].filter((i) => i !== e);
29
- }), this.emit = (t, e) => {
30
- this.events[t] && this.events[t].forEach((i) => i(e));
27
+ this.events = {}, this.subscribe = (e, t) => (this.events[e] || (this.events[e] = []), this.events[e].push(t), () => {
28
+ this.events[e] = this.events[e].filter((i) => i !== t);
29
+ }), this.emit = (e, t) => {
30
+ this.events[e] && this.events[e].forEach((i) => i(t));
31
31
  };
32
32
  }
33
33
  }
34
- const h = new v(), m = {
34
+ const o = new I(), f = {
35
35
  log: (s) => {
36
36
  console.log(`[Insight Health Aura Widget]: ${s}`);
37
37
  },
@@ -41,14 +41,14 @@ const h = new v(), m = {
41
41
  error: (s) => {
42
42
  console.error(`[Insight Health Aura Widget]: ${s}`);
43
43
  }
44
- }, f = {
44
+ }, m = {
45
45
  opacity: "0",
46
46
  pointerEvents: "none",
47
47
  width: "0",
48
48
  height: "0",
49
49
  maxWidth: "0",
50
50
  maxHeight: "0"
51
- }, H = {
51
+ }, U = {
52
52
  border: "none",
53
53
  borderRadius: "10px",
54
54
  boxShadow: "0 0 10px 0 rgba(0, 0, 0, 0.1)",
@@ -60,109 +60,126 @@ const h = new v(), m = {
60
60
  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",
61
61
  zIndex: "9999"
62
62
  };
63
- class $ {
63
+ class H {
64
64
  constructor() {
65
- this.config = null, this.widgetFrame = null, this.unsubsciptions = [], this.isFrameReady = !1, this.isFrameAuthenticated = !1, this.postMessage = (t) => {
65
+ this.config = null, this.widgetFrame = null, this.unsubsciptions = [], this.messageQueue = [], this.isQueueingEnabled = !1, this.isFrameReady = !1, this.isFrameAuthenticated = !1, this.postMessage = (e) => {
66
66
  var i;
67
67
  if (!((i = this.widgetFrame) != null && i.contentWindow)) {
68
- m.warn("No widget iframe to communicate with");
68
+ f.warn("No widget iframe to communicate with");
69
69
  return;
70
70
  }
71
- const e = l();
72
- this.widgetFrame.contentWindow.postMessage(t, {
73
- targetOrigin: e.insightBaseUrl
71
+ const t = c();
72
+ this.widgetFrame.contentWindow.postMessage(e, {
73
+ targetOrigin: t.insightBaseUrl
74
74
  });
75
- }, this.init = (t) => new Promise((e) => {
75
+ }, this.enableQueue = () => {
76
+ this.isQueueingEnabled = !0;
77
+ }, this.disableQueue = (e = !1) => {
78
+ this.isQueueingEnabled = !1, e && this.flushQueue();
79
+ }, this.flushQueue = () => {
80
+ const e = [...this.messageQueue];
81
+ this.clearQueue(), e.forEach((t) => {
82
+ this.postMessage(t);
83
+ });
84
+ }, this.clearQueue = () => {
85
+ this.messageQueue = [];
86
+ }, this.sendOrQueue = (e) => {
87
+ if (this.isQueueingEnabled) {
88
+ this.messageQueue.push(e);
89
+ return;
90
+ }
91
+ this.postMessage(e);
92
+ }, this.init = (e) => new Promise((t) => {
76
93
  if (!this.widgetFrame) {
77
- this.reset();
78
- const i = l(), {
79
- tenantId: r,
80
- tenantName: o,
81
- user: a,
94
+ this.reset(), this.enableQueue();
95
+ const i = c(), {
96
+ tenantId: a,
97
+ tenantName: r,
98
+ user: h,
82
99
  language: p,
83
- container: g,
84
- widgetId: F,
100
+ container: d,
101
+ widgetId: b,
85
102
  widgetStyles: n
86
- } = t;
87
- this.config = t, this.isFrameReady = !1, this.widgetFrame = document.createElement("iframe");
88
- const b = (n == null ? void 0 : n.width) || "350px", y = (n == null ? void 0 : n.height) || "600px", x = {
89
- ...H,
103
+ } = e;
104
+ this.config = e, this.isFrameReady = !1, this.widgetFrame = document.createElement("iframe");
105
+ const F = (n == null ? void 0 : n.width) || "350px", y = (n == null ? void 0 : n.height) || "600px", Q = {
106
+ ...U,
90
107
  ...n,
91
- ...f
108
+ ...m
92
109
  };
93
- Object.assign(this.widgetFrame.style, x), this.widgetFrame.id = F || "aura-widget", this.widgetFrame.setAttribute(
110
+ Object.assign(this.widgetFrame.style, Q), this.widgetFrame.id = b || "aura-widget", this.widgetFrame.setAttribute(
94
111
  "allow",
95
112
  `microphone ${i.insightBaseUrl}; camera ${i.insightBaseUrl}; clipboard-read ${i.insightBaseUrl}; clipboard-write ${i.insightBaseUrl};`
96
- ), this.widgetFrame.src = `${i.insightBaseUrl}`, this.widgetFrame.__desiredWidth = b, this.widgetFrame.__desiredHeight = y, this.widgetFrame.onerror = () => {
97
- m.error(
113
+ ), this.widgetFrame.src = `${i.insightBaseUrl}`, this.widgetFrame.__desiredWidth = F, this.widgetFrame.__desiredHeight = y, this.widgetFrame.onerror = () => {
114
+ f.error(
98
115
  `Failed to load iframe. Please ensure your Content Security Policy includes:
99
116
  frame-src ${i.insightBaseUrl}
100
117
  `
101
118
  );
102
- }, (g && document.querySelector(g) || document.body).appendChild(this.widgetFrame);
103
- const A = h.subscribe("Auth.Ready", () => {
104
- this.isFrameReady = !0, this.setUser({ tenantId: r, tenantName: o, user: a, language: p });
105
- }), W = h.subscribe(
119
+ }, (d && document.querySelector(d) || document.body).appendChild(this.widgetFrame);
120
+ const x = o.subscribe("Auth.Ready", () => {
121
+ this.isFrameReady = !0, this.setUser({ tenantId: a, tenantName: r, user: h, language: p });
122
+ }), A = o.subscribe(
106
123
  "Auth.Complete",
107
- (c) => {
108
- var u;
109
- this.isFrameAuthenticated = !0, e(c), (u = t.onAuthenticated) == null || u.call(t, c);
124
+ (g) => {
125
+ var l;
126
+ this.isFrameAuthenticated = !0, this.disableQueue(!0), t(g), (l = e.onAuthenticated) == null || l.call(e, g);
110
127
  }
111
128
  );
112
- this.unsubsciptions.push(A, W);
129
+ this.unsubsciptions.push(x, A);
113
130
  }
114
- }), this.setUser = (t) => {
115
- const e = this.config.partnerKey, { tenantId: i, tenantName: r, user: o, language: a } = t;
116
- this.config.tenantId = i, this.config.tenantName = r, this.config.user = o, this.config.language = a, this.isFrameAuthenticated = !1, this.postMessage({
131
+ }), this.setUser = (e) => {
132
+ const t = this.config.partnerKey, { tenantId: i, tenantName: a, user: r, language: h } = e;
133
+ this.config.tenantId = i, this.config.tenantName = a, this.config.user = r, this.config.language = h, this.isFrameAuthenticated = !1, this.postMessage({
117
134
  type: "Auth.Login",
118
135
  payload: {
119
- partnerKey: e,
136
+ partnerKey: t,
120
137
  tenantId: i,
121
- tenantName: r,
122
- user: o,
123
- language: a
138
+ tenantName: a,
139
+ user: r,
140
+ language: h
124
141
  }
125
142
  });
126
143
  }, this.show = () => {
127
144
  if (this.widgetFrame) {
128
- const t = this.widgetFrame.__desiredWidth || "350px", e = this.widgetFrame.__desiredHeight || "600px", i = {
145
+ const e = this.widgetFrame.__desiredWidth || "350px", t = this.widgetFrame.__desiredHeight || "600px", i = {
129
146
  opacity: "1",
130
147
  pointerEvents: "auto",
131
- width: t,
132
- height: e,
133
- maxWidth: t,
134
- maxHeight: e
148
+ width: e,
149
+ height: t,
150
+ maxWidth: e,
151
+ maxHeight: t
135
152
  };
136
153
  Object.assign(this.widgetFrame.style, { ...i });
137
154
  }
138
155
  }, this.hide = () => {
139
- this.widgetFrame && Object.assign(this.widgetFrame.style, { ...f });
156
+ this.widgetFrame && Object.assign(this.widgetFrame.style, { ...m });
140
157
  }, this.reset = () => {
141
- this.widgetFrame && this.widgetFrame.remove(), this.widgetFrame = null, this.isFrameReady = !1, this.isFrameAuthenticated = !1, this.unsubsciptions.forEach((t) => t == null ? void 0 : t()), this.unsubsciptions = [];
142
- }, this.command = (t) => {
143
- this.postMessage(t), this.show();
144
- }, this.emit = this.command, this.on = (t, e) => h.subscribe(t, e), this.registerTemplates = (t) => {
145
- this.postMessage({
158
+ 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();
159
+ }, this.command = (e) => {
160
+ this.sendOrQueue(e), this.show();
161
+ }, this.emit = this.command, this.on = (e, t) => o.subscribe(e, t), this.registerTemplates = (e) => {
162
+ this.sendOrQueue({
146
163
  type: "Template.Register",
147
- payload: t
164
+ payload: e
148
165
  });
149
- }, this.getConfig = () => this.config, this.getVersion = () => U(), window.addEventListener(
166
+ }, this.getConfig = () => this.config, this.getVersion = () => B(), window.addEventListener(
150
167
  "message",
151
- (t) => {
152
- var e;
153
- t.source !== ((e = this.widgetFrame) == null ? void 0 : e.contentWindow) || !t.data || h.emit(t.data.type, t.data.payload);
168
+ (e) => {
169
+ var t;
170
+ e.source !== ((t = this.widgetFrame) == null ? void 0 : t.contentWindow) || !e.data || o.emit(e.data.type, e.data.payload);
154
171
  }
155
172
  );
156
173
  }
157
174
  }
158
- let d = null;
159
- function E() {
160
- return d || (d = new $()), d;
175
+ let u = null;
176
+ function $() {
177
+ return u || (u = new H()), u;
161
178
  }
162
- const _ = E();
179
+ const R = $();
163
180
  export {
164
- _ as AuraWidget,
165
- R as configure,
166
- l as getConfig,
167
- U as getVersion
181
+ R as AuraWidget,
182
+ v as configure,
183
+ c as getConfig,
184
+ B as getVersion
168
185
  };
package/dist/index.umd.js CHANGED
@@ -1,3 +1,3 @@
1
- (function(n,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(n=typeof globalThis<"u"?globalThis:n||self,o(n.InsightAura={}))})(this,function(n){"use strict";const o={insightBaseUrl:"https://anywhere.insighthealth.ai"};let l=null;function y(){return l}function A(s){l={...o,...s}}function x(s){A(s)}function u(){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.7"}class W{constructor(){this.events={},this.subscribe=(t,e)=>(this.events[t]||(this.events[t]=[]),this.events[t].push(e),()=>{this.events[t]=this.events[t].filter(i=>i!==e)}),this.emit=(t,e)=>{this.events[t]&&this.events[t].forEach(i=>i(e))}}}const a=new W,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"},C={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 I{constructor(){this.config=null,this.widgetFrame=null,this.unsubsciptions=[],this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.postMessage=t=>{var i;if(!((i=this.widgetFrame)!=null&&i.contentWindow)){m.warn("No widget iframe to communicate with");return}const e=u();this.widgetFrame.contentWindow.postMessage(t,{targetOrigin:e.insightBaseUrl})},this.init=t=>new Promise(e=>{if(!this.widgetFrame){this.reset();const i=u(),{tenantId:h,tenantName:d,user:g,language:U,container:p,widgetId:H,widgetStyles:r}=t;this.config=t,this.isFrameReady=!1,this.widgetFrame=document.createElement("iframe");const S=(r==null?void 0:r.width)||"350px",$=(r==null?void 0:r.height)||"600px",E={...C,...r,...w};Object.assign(this.widgetFrame.style,E),this.widgetFrame.id=H||"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=S,this.widgetFrame.__desiredHeight=$,this.widgetFrame.onerror=()=>{m.error(`Failed to load iframe. Please ensure your Content Security Policy includes:
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.8"}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
- `)},(p&&document.querySelector(p)||document.body).appendChild(this.widgetFrame);const R=a.subscribe("Auth.Ready",()=>{this.isFrameReady=!0,this.setUser({tenantId:h,tenantName:d,user:g,language:U})}),_=a.subscribe("Auth.Complete",F=>{var b;this.isFrameAuthenticated=!0,e(F),(b=t.onAuthenticated)==null||b.call(t,F)});this.unsubsciptions.push(R,_)}}),this.setUser=t=>{const e=this.config.partnerKey,{tenantId:i,tenantName:h,user:d,language:g}=t;this.config.tenantId=i,this.config.tenantName=h,this.config.user=d,this.config.language=g,this.isFrameAuthenticated=!1,this.postMessage({type:"Auth.Login",payload:{partnerKey:e,tenantId:i,tenantName:h,user:d,language:g}})},this.show=()=>{if(this.widgetFrame){const t=this.widgetFrame.__desiredWidth||"350px",e=this.widgetFrame.__desiredHeight||"600px",i={opacity:"1",pointerEvents:"auto",width:t,height:e,maxWidth:t,maxHeight:e};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(t=>t==null?void 0:t()),this.unsubsciptions=[]},this.command=t=>{this.postMessage(t),this.show()},this.emit=this.command,this.on=(t,e)=>a.subscribe(t,e),this.registerTemplates=t=>{this.postMessage({type:"Template.Register",payload:t})},this.getConfig=()=>this.config,this.getVersion=()=>f(),window.addEventListener("message",t=>{var e;t.source!==((e=this.widgetFrame)==null?void 0:e.contentWindow)||!t.data||a.emit(t.data.type,t.data.payload)})}}let c=null;function v(){return c||(c=new I),c}const B=v();n.AuraWidget=B,n.configure=x,n.getConfig=u,n.getVersion=f,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insight-health/aura",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Aura SDK package for Insight Health AI",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",