@insight-health/aura 0.0.4 → 0.0.6
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/auraWidget.d.ts +5 -4
- package/dist/auraWidget.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +64 -62
- package/dist/index.umd.js +2 -2
- package/dist/types.d.ts +5 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/eventBus.d.ts +1 -1
- package/dist/utils/eventBus.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/auraWidget.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuraRegisterTemplatePayload, AuraWidgetInitParams, AuraWidgetEmitEvent } from './types';
|
|
1
|
+
import { AuraRegisterTemplatePayload, AuraWidgetInitParams, AuraWidgetEmitEvent, AuthParams } from './types';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Aura service class
|
|
@@ -13,13 +13,14 @@ declare class AuraWidgetService {
|
|
|
13
13
|
constructor();
|
|
14
14
|
private postMessage;
|
|
15
15
|
init: (params: AuraWidgetInitParams) => Promise<void>;
|
|
16
|
-
|
|
17
|
-
setUser: (params: Pick<AuraWidgetInitParams, "user" | "subTenantId" | "language">) => void;
|
|
16
|
+
setUser: (params: AuthParams) => void;
|
|
18
17
|
show: () => void;
|
|
19
18
|
hide: () => void;
|
|
20
19
|
reset: () => void;
|
|
20
|
+
command: (event: AuraWidgetEmitEvent) => void;
|
|
21
21
|
emit: (event: AuraWidgetEmitEvent) => void;
|
|
22
|
-
on: (
|
|
22
|
+
on: (type: string, callback: (payload: unknown) => void) => (() => void);
|
|
23
|
+
registerTemplates: (payload: AuraRegisterTemplatePayload) => void;
|
|
23
24
|
/**
|
|
24
25
|
* Get SDK version
|
|
25
26
|
*/
|
package/dist/auraWidget.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auraWidget.d.ts","sourceRoot":"","sources":["../src/auraWidget.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,EAEpB,mBAAmB,
|
|
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"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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.6"}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:
|
|
2
2
|
frame-src ${i.insightBaseUrl}
|
|
3
|
-
`)},(
|
|
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;
|
package/dist/index.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
const
|
|
1
|
+
const C = {
|
|
2
2
|
insightBaseUrl: "https://anywhere.insighthealth.ai"
|
|
3
3
|
};
|
|
4
|
-
let
|
|
5
|
-
function
|
|
6
|
-
return
|
|
4
|
+
let w = null;
|
|
5
|
+
function B() {
|
|
6
|
+
return w;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
|
|
8
|
+
function I(s) {
|
|
9
|
+
w = { ...C, ...s };
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
11
|
+
function R(s) {
|
|
12
|
+
I(s);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
const s =
|
|
14
|
+
function l() {
|
|
15
|
+
const s = B();
|
|
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
|
|
23
|
-
return "0.0.
|
|
22
|
+
function U() {
|
|
23
|
+
return "0.0.6";
|
|
24
24
|
}
|
|
25
|
-
class
|
|
25
|
+
class v {
|
|
26
26
|
constructor() {
|
|
27
27
|
this.events = {}, this.subscribe = (t, e) => (this.events[t] || (this.events[t] = []), this.events[t].push(e), () => {
|
|
28
28
|
this.events[t] = this.events[t].filter((i) => i !== e);
|
|
@@ -31,7 +31,7 @@ class I {
|
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
const
|
|
34
|
+
const h = new v(), m = {
|
|
35
35
|
log: (s) => {
|
|
36
36
|
console.log(`[Insight Health Aura Widget]: ${s}`);
|
|
37
37
|
},
|
|
@@ -41,14 +41,14 @@ const a = new I(), c = {
|
|
|
41
41
|
error: (s) => {
|
|
42
42
|
console.error(`[Insight Health Aura Widget]: ${s}`);
|
|
43
43
|
}
|
|
44
|
-
},
|
|
44
|
+
}, f = {
|
|
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
|
-
},
|
|
51
|
+
}, H = {
|
|
52
52
|
border: "none",
|
|
53
53
|
borderRadius: "10px",
|
|
54
54
|
boxShadow: "0 0 10px 0 rgba(0, 0, 0, 0.1)",
|
|
@@ -60,70 +60,67 @@ const a = new I(), c = {
|
|
|
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 $ {
|
|
64
64
|
constructor() {
|
|
65
65
|
this.config = null, this.widgetFrame = null, this.unsubsciptions = [], this.isFrameReady = !1, this.isFrameAuthenticated = !1, this.postMessage = (t) => {
|
|
66
66
|
var i;
|
|
67
67
|
if (!((i = this.widgetFrame) != null && i.contentWindow)) {
|
|
68
|
-
|
|
68
|
+
m.warn("No widget iframe to communicate with");
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
const e =
|
|
71
|
+
const e = l();
|
|
72
72
|
this.widgetFrame.contentWindow.postMessage(t, {
|
|
73
73
|
targetOrigin: e.insightBaseUrl
|
|
74
74
|
});
|
|
75
75
|
}, this.init = (t) => new Promise((e) => {
|
|
76
76
|
if (!this.widgetFrame) {
|
|
77
77
|
this.reset();
|
|
78
|
-
const i =
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
const i = l(), {
|
|
79
|
+
tenantId: r,
|
|
80
|
+
tenantName: o,
|
|
81
|
+
user: a,
|
|
82
|
+
language: p,
|
|
83
|
+
container: g,
|
|
84
|
+
widgetId: F,
|
|
84
85
|
widgetStyles: n
|
|
85
86
|
} = t;
|
|
86
87
|
this.config = t, this.isFrameReady = !1, this.widgetFrame = document.createElement("iframe");
|
|
87
|
-
const
|
|
88
|
-
...
|
|
88
|
+
const b = (n == null ? void 0 : n.width) || "350px", y = (n == null ? void 0 : n.height) || "600px", x = {
|
|
89
|
+
...H,
|
|
89
90
|
...n,
|
|
90
|
-
...
|
|
91
|
+
...f
|
|
91
92
|
};
|
|
92
|
-
Object.assign(this.widgetFrame.style,
|
|
93
|
+
Object.assign(this.widgetFrame.style, x), this.widgetFrame.id = F || "aura-widget", this.widgetFrame.setAttribute(
|
|
93
94
|
"allow",
|
|
94
95
|
`microphone ${i.insightBaseUrl}; camera ${i.insightBaseUrl}; clipboard-read ${i.insightBaseUrl}; clipboard-write ${i.insightBaseUrl};`
|
|
95
|
-
), this.widgetFrame.src = `${i.insightBaseUrl}`, this.widgetFrame.__desiredWidth =
|
|
96
|
-
|
|
96
|
+
), this.widgetFrame.src = `${i.insightBaseUrl}`, this.widgetFrame.__desiredWidth = b, this.widgetFrame.__desiredHeight = y, this.widgetFrame.onerror = () => {
|
|
97
|
+
m.error(
|
|
97
98
|
`Failed to load iframe. Please ensure your Content Security Policy includes:
|
|
98
99
|
frame-src ${i.insightBaseUrl}
|
|
99
100
|
`
|
|
100
101
|
);
|
|
101
|
-
}, (
|
|
102
|
-
const
|
|
103
|
-
this.isFrameReady = !0, this.setUser({
|
|
104
|
-
}),
|
|
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(
|
|
105
106
|
"Auth.Complete",
|
|
106
|
-
() => {
|
|
107
|
-
var
|
|
108
|
-
this.isFrameAuthenticated = !0, e(), (
|
|
107
|
+
(c) => {
|
|
108
|
+
var u;
|
|
109
|
+
this.isFrameAuthenticated = !0, e(c), (u = t.onAuthenticated) == null || u.call(t, c);
|
|
109
110
|
}
|
|
110
111
|
);
|
|
111
|
-
this.unsubsciptions.push(
|
|
112
|
+
this.unsubsciptions.push(A, W);
|
|
112
113
|
}
|
|
113
|
-
}), this.
|
|
114
|
-
this.
|
|
115
|
-
|
|
116
|
-
payload: t
|
|
117
|
-
});
|
|
118
|
-
}, this.setUser = (t) => {
|
|
119
|
-
const e = this.config.partnerKey, { subTenantId: i, user: r, language: o } = t;
|
|
120
|
-
this.config.subTenantId = i, this.config.user = r, this.config.language = o, this.isFrameAuthenticated = !1, this.postMessage({
|
|
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({
|
|
121
117
|
type: "Auth.Login",
|
|
122
118
|
payload: {
|
|
123
119
|
partnerKey: e,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
120
|
+
tenantId: i,
|
|
121
|
+
tenantName: r,
|
|
122
|
+
user: o,
|
|
123
|
+
language: a
|
|
127
124
|
}
|
|
128
125
|
});
|
|
129
126
|
}, this.show = () => {
|
|
@@ -139,28 +136,33 @@ class v {
|
|
|
139
136
|
Object.assign(this.widgetFrame.style, { ...i });
|
|
140
137
|
}
|
|
141
138
|
}, this.hide = () => {
|
|
142
|
-
this.widgetFrame && Object.assign(this.widgetFrame.style, { ...
|
|
139
|
+
this.widgetFrame && Object.assign(this.widgetFrame.style, { ...f });
|
|
143
140
|
}, this.reset = () => {
|
|
144
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 = [];
|
|
145
|
-
}, this.
|
|
142
|
+
}, this.command = (t) => {
|
|
146
143
|
this.postMessage(t), this.show();
|
|
147
|
-
}, this.on = (t, e) =>
|
|
144
|
+
}, this.emit = this.command, this.on = (t, e) => h.subscribe(t, e), this.registerTemplates = (t) => {
|
|
145
|
+
this.postMessage({
|
|
146
|
+
type: "Template.Register",
|
|
147
|
+
payload: t
|
|
148
|
+
});
|
|
149
|
+
}, this.getConfig = () => this.config, this.getVersion = () => U(), window.addEventListener(
|
|
148
150
|
"message",
|
|
149
151
|
(t) => {
|
|
150
152
|
var e;
|
|
151
|
-
t.source !== ((e = this.widgetFrame) == null ? void 0 : e.contentWindow) || !t.data ||
|
|
153
|
+
t.source !== ((e = this.widgetFrame) == null ? void 0 : e.contentWindow) || !t.data || h.emit(t.data.type, t.data.payload);
|
|
152
154
|
}
|
|
153
155
|
);
|
|
154
156
|
}
|
|
155
157
|
}
|
|
156
|
-
let
|
|
157
|
-
function
|
|
158
|
-
return
|
|
158
|
+
let d = null;
|
|
159
|
+
function E() {
|
|
160
|
+
return d || (d = new $()), d;
|
|
159
161
|
}
|
|
160
|
-
const
|
|
162
|
+
const _ = E();
|
|
161
163
|
export {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
_ as AuraWidget,
|
|
165
|
+
R as configure,
|
|
166
|
+
l as getConfig,
|
|
167
|
+
U as getVersion
|
|
166
168
|
};
|
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
|
|
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.6"}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:
|
|
2
2
|
frame-src ${i.insightBaseUrl}
|
|
3
|
-
`)},(
|
|
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"})});
|
package/dist/types.d.ts
CHANGED
|
@@ -4,18 +4,21 @@ export type AuraWidgetEmitEvent<T = any> = {
|
|
|
4
4
|
};
|
|
5
5
|
export type AuraWidgetInitParams = {
|
|
6
6
|
partnerKey: string;
|
|
7
|
-
|
|
7
|
+
tenantId: string | number;
|
|
8
|
+
tenantName?: string;
|
|
8
9
|
user: {
|
|
9
10
|
email: string;
|
|
10
11
|
firstName?: string;
|
|
11
12
|
lastName?: string;
|
|
13
|
+
ehr_id?: string | number;
|
|
12
14
|
};
|
|
13
15
|
language?: string;
|
|
14
16
|
container?: string;
|
|
15
17
|
widgetId?: string;
|
|
16
18
|
widgetStyles?: Partial<Pick<CSSStyleDeclaration, 'width' | 'height' | 'borderRadius' | 'boxShadow' | 'top' | 'bottom' | 'left' | 'right'>>;
|
|
17
|
-
onAuthenticated?: () => void;
|
|
19
|
+
onAuthenticated?: (data: AuthParams) => void;
|
|
18
20
|
};
|
|
21
|
+
export type AuthParams = Pick<AuraWidgetInitParams, 'tenantId' | 'tenantName' | 'user' | 'language'>;
|
|
19
22
|
export type AuraWidgetMessageEvent<T = any> = {
|
|
20
23
|
type: string;
|
|
21
24
|
payload: T;
|
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,
|
|
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,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KAC1B,CAAC;IACF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CACpB,IAAI,CACF,mBAAmB,EACjB,OAAO,GACP,QAAQ,GACR,cAAc,GACd,WAAW,GACX,KAAK,GACL,QAAQ,GACR,MAAM,GACN,OAAO,CACV,CACF,CAAC;IACF,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,IAAI,CAC3B,oBAAoB,EACpB,UAAU,GAAG,YAAY,GAAG,MAAM,GAAG,UAAU,CAChD,CAAC;AAEF,MAAM,MAAM,sBAAsB,CAAC,CAAC,GAAG,GAAG,IAAI;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE;QACJ,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;KACjC,CAAC;IACF,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,WAAW,GAAG,UAAU,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,SAAS,EAAE,YAAY,EAAE,CAAC;CAC3B,CAAC"}
|
package/dist/utils/eventBus.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare class EventBus {
|
|
2
2
|
private events;
|
|
3
3
|
subscribe: (event: string, callback: (data: any) => void) => () => void;
|
|
4
|
-
emit: (event: string,
|
|
4
|
+
emit: (event: string, payload: any) => void;
|
|
5
5
|
}
|
|
6
6
|
export declare const eventBus: EventBus;
|
|
7
7
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventBus.d.ts","sourceRoot":"","sources":["../../src/utils/eventBus.ts"],"names":[],"mappings":"AAAA,cAAM,QAAQ;IACZ,OAAO,CAAC,MAAM,CAA+C;IAE7D,SAAS,GAAI,OAAO,MAAM,EAAE,UAAU,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,gBASvD;IAEF,IAAI,GAAI,OAAO,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"eventBus.d.ts","sourceRoot":"","sources":["../../src/utils/eventBus.ts"],"names":[],"mappings":"AAAA,cAAM,QAAQ;IACZ,OAAO,CAAC,MAAM,CAA+C;IAE7D,SAAS,GAAI,OAAO,MAAM,EAAE,UAAU,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,gBASvD;IAEF,IAAI,GAAI,OAAO,MAAM,EAAE,SAAS,GAAG,UAKjC;CACH;AAED,eAAO,MAAM,QAAQ,UAAiB,CAAC"}
|