@insight-health/aura 0.0.3 → 0.0.5
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 +6 -21
- package/dist/auraWidget.d.ts.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.js +75 -64
- package/dist/index.umd.js +3 -3
- package/dist/types.d.ts +36 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/auraWidget.d.ts
CHANGED
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
payload: T;
|
|
4
|
-
};
|
|
5
|
-
type AuraWidgetOpenParams = {
|
|
6
|
-
partnerKey: string;
|
|
7
|
-
subTenantId: string;
|
|
8
|
-
user: {
|
|
9
|
-
email: string;
|
|
10
|
-
firstName?: string;
|
|
11
|
-
lastName?: string;
|
|
12
|
-
};
|
|
13
|
-
language?: string;
|
|
14
|
-
container?: string;
|
|
15
|
-
widgetId?: string;
|
|
16
|
-
widgetStyles?: Partial<Pick<CSSStyleDeclaration, 'width' | 'height' | 'borderRadius' | 'boxShadow' | 'top' | 'bottom' | 'left' | 'right'>>;
|
|
17
|
-
onAuthenticated?: () => void;
|
|
18
|
-
};
|
|
1
|
+
import { AuraRegisterTemplatePayload, AuraWidgetInitParams, AuraWidgetEmitEvent } from './types';
|
|
2
|
+
|
|
19
3
|
/**
|
|
20
4
|
* Aura service class
|
|
21
5
|
* Singleton pattern - all imports reference the same instance
|
|
@@ -28,8 +12,9 @@ declare class AuraWidgetService {
|
|
|
28
12
|
isFrameAuthenticated: boolean;
|
|
29
13
|
constructor();
|
|
30
14
|
private postMessage;
|
|
31
|
-
init: (params:
|
|
32
|
-
|
|
15
|
+
init: (params: AuraWidgetInitParams) => Promise<void>;
|
|
16
|
+
registerTemplates: (payload: AuraRegisterTemplatePayload) => void;
|
|
17
|
+
setUser: (params: Pick<AuraWidgetInitParams, "tenantId" | "tenantName" | "user" | "language">) => void;
|
|
33
18
|
show: () => void;
|
|
34
19
|
hide: () => void;
|
|
35
20
|
reset: () => void;
|
|
@@ -38,7 +23,7 @@ declare class AuraWidgetService {
|
|
|
38
23
|
/**
|
|
39
24
|
* Get SDK version
|
|
40
25
|
*/
|
|
41
|
-
getConfig: () =>
|
|
26
|
+
getConfig: () => AuraWidgetInitParams | null;
|
|
42
27
|
getVersion: () => string;
|
|
43
28
|
}
|
|
44
29
|
export declare const AuraWidget: AuraWidgetService;
|
package/dist/auraWidget.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auraWidget.d.ts","sourceRoot":"","sources":["../src/auraWidget.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auraWidget.d.ts","sourceRoot":"","sources":["../src/auraWidget.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,EAEpB,mBAAmB,EACpB,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,iBAAiB,GAAI,SAAS,2BAA2B,UAKvD;IAEF,OAAO,GACL,QAAQ,IAAI,CACV,oBAAoB,EACpB,UAAU,GAAG,YAAY,GAAG,MAAM,GAAG,UAAU,CAChD,UAmBD;IAEF,IAAI,aAeF;IAEF,IAAI,aAIF;IAEF,KAAK,aASH;IAEF,IAAI,GAAI,OAAO,mBAAmB,UAGhC;IAEF,EAAE,GAAI,OAAO,MAAM,EAAE,UAAU,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,gBAEhD;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
|
|
2
|
-
frame-src ${
|
|
3
|
-
`)},(
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C={insightBaseUrl:"https://anywhere.insighthealth.ai"};let m=null;function v(){return m}function B(s){m={...C,...s}}function I(s){B(s)}function d(){const s=v();if(!s)throw new Error("Aura SDK not configured. Call configure() first to set global configuration.");return s}function w(){return"0.0.5"}class U{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 U,l={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"},H={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 S{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)){l.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:p,container:c,widgetId:F,widgetStyles:n}=t;this.config=t,this.isFrameReady=!1,this.widgetFrame=document.createElement("iframe");const b=(n==null?void 0:n.width)||"350px",y=(n==null?void 0:n.height)||"600px",A={...H,...n,...f};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=b,this.widgetFrame.__desiredHeight=y,this.widgetFrame.onerror=()=>{l.error(`Failed to load iframe. Please ensure your Content Security Policy includes:
|
|
2
|
+
frame-src ${i.insightBaseUrl}
|
|
3
|
+
`)},(c&&document.querySelector(c)||document.body).appendChild(this.widgetFrame);const x=h.subscribe("Auth.Ready",()=>{this.isFrameReady=!0,this.setUser({tenantId:r,tenantName:o,user:a,language:p})}),W=h.subscribe("Auth.Complete",()=>{var u;this.isFrameAuthenticated=!0,e(),(u=t.onAuthenticated)==null||u.call(t)});this.unsubsciptions.push(x,W)}}),this.registerTemplates=t=>{this.postMessage({type:"Template.Register",payload:t})},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.emit=t=>{this.postMessage(t),this.show()},this.on=(t,e)=>h.subscribe(t,e),this.getConfig=()=>this.config,this.getVersion=()=>w(),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 $(){return g||(g=new S),g}const E=$();exports.AuraWidget=E;exports.configure=I;exports.getConfig=d;exports.getVersion=w;
|
package/dist/index.js
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
const
|
|
1
|
+
const W = {
|
|
2
2
|
insightBaseUrl: "https://anywhere.insighthealth.ai"
|
|
3
3
|
};
|
|
4
|
-
let
|
|
5
|
-
function
|
|
6
|
-
return
|
|
4
|
+
let m = null;
|
|
5
|
+
function C() {
|
|
6
|
+
return m;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
|
|
8
|
+
function B(s) {
|
|
9
|
+
m = { ...W, ...s };
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
11
|
+
function E(s) {
|
|
12
|
+
B(s);
|
|
13
13
|
}
|
|
14
14
|
function u() {
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
15
|
+
const s = C();
|
|
16
|
+
if (!s)
|
|
17
17
|
throw new Error(
|
|
18
18
|
"Aura SDK not configured. Call configure() first to set global configuration."
|
|
19
19
|
);
|
|
20
|
-
return
|
|
20
|
+
return s;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
return "0.0.
|
|
22
|
+
function I() {
|
|
23
|
+
return "0.0.5";
|
|
24
24
|
}
|
|
25
|
-
class
|
|
25
|
+
class U {
|
|
26
26
|
constructor() {
|
|
27
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((
|
|
28
|
+
this.events[t] = this.events[t].filter((i) => i !== e);
|
|
29
29
|
}), this.emit = (t, e) => {
|
|
30
|
-
this.events[t] && this.events[t].forEach((
|
|
30
|
+
this.events[t] && this.events[t].forEach((i) => i(e));
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
const
|
|
35
|
-
log: (
|
|
36
|
-
console.log(`[Insight Health Aura Widget]: ${
|
|
34
|
+
const h = new U(), l = {
|
|
35
|
+
log: (s) => {
|
|
36
|
+
console.log(`[Insight Health Aura Widget]: ${s}`);
|
|
37
37
|
},
|
|
38
|
-
warn: (
|
|
39
|
-
console.warn(`[Insight Health Aura Widget]: ${
|
|
38
|
+
warn: (s) => {
|
|
39
|
+
console.warn(`[Insight Health Aura Widget]: ${s}`);
|
|
40
40
|
},
|
|
41
|
-
error: (
|
|
42
|
-
console.error(`[Insight Health Aura Widget]: ${
|
|
41
|
+
error: (s) => {
|
|
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
|
+
}, v = {
|
|
52
52
|
border: "none",
|
|
53
53
|
borderRadius: "10px",
|
|
54
54
|
boxShadow: "0 0 10px 0 rgba(0, 0, 0, 0.1)",
|
|
@@ -60,12 +60,12 @@ const r = new H(), 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 H {
|
|
64
64
|
constructor() {
|
|
65
65
|
this.config = null, this.widgetFrame = null, this.unsubsciptions = [], this.isFrameReady = !1, this.isFrameAuthenticated = !1, this.postMessage = (t) => {
|
|
66
|
-
var
|
|
67
|
-
if (!((
|
|
68
|
-
|
|
66
|
+
var i;
|
|
67
|
+
if (!((i = this.widgetFrame) != null && i.contentWindow)) {
|
|
68
|
+
l.warn("No widget iframe to communicate with");
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
71
|
const e = u();
|
|
@@ -74,52 +74,63 @@ class E {
|
|
|
74
74
|
});
|
|
75
75
|
}, this.init = (t) => new Promise((e) => {
|
|
76
76
|
if (!this.widgetFrame) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
this.reset();
|
|
78
|
+
const i = u(), {
|
|
79
|
+
tenantId: r,
|
|
80
|
+
tenantName: a,
|
|
81
|
+
user: o,
|
|
82
|
+
language: w,
|
|
81
83
|
container: d,
|
|
82
|
-
widgetId:
|
|
84
|
+
widgetId: p,
|
|
83
85
|
widgetStyles: n
|
|
84
86
|
} = t;
|
|
85
87
|
this.config = t, this.isFrameReady = !1, this.widgetFrame = document.createElement("iframe");
|
|
86
|
-
const F = (n == null ? void 0 : n.width) || "350px",
|
|
87
|
-
...
|
|
88
|
+
const F = (n == null ? void 0 : n.width) || "350px", b = (n == null ? void 0 : n.height) || "600px", y = {
|
|
89
|
+
...v,
|
|
88
90
|
...n,
|
|
89
|
-
...
|
|
91
|
+
...f
|
|
90
92
|
};
|
|
91
|
-
Object.assign(this.widgetFrame.style,
|
|
92
|
-
|
|
93
|
+
Object.assign(this.widgetFrame.style, y), this.widgetFrame.id = p || "aura-widget", this.widgetFrame.setAttribute(
|
|
94
|
+
"allow",
|
|
95
|
+
`microphone ${i.insightBaseUrl}; camera ${i.insightBaseUrl}; clipboard-read ${i.insightBaseUrl}; clipboard-write ${i.insightBaseUrl};`
|
|
96
|
+
), this.widgetFrame.src = `${i.insightBaseUrl}`, this.widgetFrame.__desiredWidth = F, this.widgetFrame.__desiredHeight = b, this.widgetFrame.onerror = () => {
|
|
97
|
+
l.error(
|
|
93
98
|
`Failed to load iframe. Please ensure your Content Security Policy includes:
|
|
94
|
-
frame-src ${
|
|
99
|
+
frame-src ${i.insightBaseUrl}
|
|
95
100
|
`
|
|
96
101
|
);
|
|
97
102
|
}, (d && document.querySelector(d) || document.body).appendChild(this.widgetFrame);
|
|
98
|
-
const
|
|
99
|
-
this.isFrameReady = !0, this.setUser({
|
|
100
|
-
}),
|
|
103
|
+
const x = h.subscribe("Auth.Ready", () => {
|
|
104
|
+
this.isFrameReady = !0, this.setUser({ tenantId: r, tenantName: a, user: o, language: w });
|
|
105
|
+
}), A = h.subscribe(
|
|
101
106
|
"Auth.Complete",
|
|
102
107
|
() => {
|
|
103
|
-
var
|
|
104
|
-
this.isFrameAuthenticated = !0, e(), (
|
|
108
|
+
var c;
|
|
109
|
+
this.isFrameAuthenticated = !0, e(), (c = t.onAuthenticated) == null || c.call(t);
|
|
105
110
|
}
|
|
106
111
|
);
|
|
107
|
-
this.unsubsciptions.push(
|
|
112
|
+
this.unsubsciptions.push(x, A);
|
|
108
113
|
}
|
|
109
|
-
}), this.
|
|
110
|
-
|
|
111
|
-
|
|
114
|
+
}), this.registerTemplates = (t) => {
|
|
115
|
+
this.postMessage({
|
|
116
|
+
type: "Template.Register",
|
|
117
|
+
payload: t
|
|
118
|
+
});
|
|
119
|
+
}, this.setUser = (t) => {
|
|
120
|
+
const e = this.config.partnerKey, { tenantId: i, tenantName: r, user: a, language: o } = t;
|
|
121
|
+
this.config.tenantId = i, this.config.tenantName = r, this.config.user = a, this.config.language = o, this.isFrameAuthenticated = !1, this.postMessage({
|
|
112
122
|
type: "Auth.Login",
|
|
113
123
|
payload: {
|
|
114
124
|
partnerKey: e,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
125
|
+
tenantId: i,
|
|
126
|
+
tenantName: r,
|
|
127
|
+
user: a,
|
|
128
|
+
language: o
|
|
118
129
|
}
|
|
119
130
|
});
|
|
120
131
|
}, this.show = () => {
|
|
121
132
|
if (this.widgetFrame) {
|
|
122
|
-
const t = this.widgetFrame.__desiredWidth || "350px", e = this.widgetFrame.__desiredHeight || "600px",
|
|
133
|
+
const t = this.widgetFrame.__desiredWidth || "350px", e = this.widgetFrame.__desiredHeight || "600px", i = {
|
|
123
134
|
opacity: "1",
|
|
124
135
|
pointerEvents: "auto",
|
|
125
136
|
width: t,
|
|
@@ -127,31 +138,31 @@ class E {
|
|
|
127
138
|
maxWidth: t,
|
|
128
139
|
maxHeight: e
|
|
129
140
|
};
|
|
130
|
-
Object.assign(this.widgetFrame.style, { ...
|
|
141
|
+
Object.assign(this.widgetFrame.style, { ...i });
|
|
131
142
|
}
|
|
132
143
|
}, this.hide = () => {
|
|
133
|
-
this.widgetFrame && Object.assign(this.widgetFrame.style, { ...
|
|
144
|
+
this.widgetFrame && Object.assign(this.widgetFrame.style, { ...f });
|
|
134
145
|
}, this.reset = () => {
|
|
135
146
|
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 = [];
|
|
136
147
|
}, this.emit = (t) => {
|
|
137
148
|
this.postMessage(t), this.show();
|
|
138
|
-
}, this.on = (t, e) =>
|
|
149
|
+
}, this.on = (t, e) => h.subscribe(t, e), this.getConfig = () => this.config, this.getVersion = () => I(), window.addEventListener(
|
|
139
150
|
"message",
|
|
140
151
|
(t) => {
|
|
141
152
|
var e;
|
|
142
|
-
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);
|
|
143
154
|
}
|
|
144
155
|
);
|
|
145
156
|
}
|
|
146
157
|
}
|
|
147
|
-
let
|
|
148
|
-
function
|
|
149
|
-
return
|
|
158
|
+
let g = null;
|
|
159
|
+
function $() {
|
|
160
|
+
return g || (g = new H()), g;
|
|
150
161
|
}
|
|
151
|
-
const
|
|
162
|
+
const R = $();
|
|
152
163
|
export {
|
|
153
|
-
|
|
154
|
-
|
|
164
|
+
R as AuraWidget,
|
|
165
|
+
E as configure,
|
|
155
166
|
u as getConfig,
|
|
156
|
-
|
|
167
|
+
I as getVersion
|
|
157
168
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(n,
|
|
2
|
-
frame-src ${
|
|
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 b(){return l}function y(s){l={...o,...s}}function A(s){y(s)}function u(){const s=b();if(!s)throw new Error("Aura SDK not configured. Call configure() first to set global configuration.");return s}function f(){return"0.0.5"}class x{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 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.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:B,container:p,widgetId:U,widgetStyles:r}=t;this.config=t,this.isFrameReady=!1,this.widgetFrame=document.createElement("iframe");const H=(r==null?void 0:r.width)||"350px",S=(r==null?void 0:r.height)||"600px",$={...W,...r,...w};Object.assign(this.widgetFrame.style,$),this.widgetFrame.id=U||"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=H,this.widgetFrame.__desiredHeight=S,this.widgetFrame.onerror=()=>{m.error(`Failed to load iframe. Please ensure your Content Security Policy includes:
|
|
2
|
+
frame-src ${i.insightBaseUrl}
|
|
3
|
+
`)},(p&&document.querySelector(p)||document.body).appendChild(this.widgetFrame);const E=a.subscribe("Auth.Ready",()=>{this.isFrameReady=!0,this.setUser({tenantId:h,tenantName:d,user:g,language:B})}),R=a.subscribe("Auth.Complete",()=>{var F;this.isFrameAuthenticated=!0,e(),(F=t.onAuthenticated)==null||F.call(t)});this.unsubsciptions.push(E,R)}}),this.registerTemplates=t=>{this.postMessage({type:"Template.Register",payload:t})},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.emit=t=>{this.postMessage(t),this.show()},this.on=(t,e)=>a.subscribe(t,e),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 I(){return c||(c=new C),c}const v=I();n.AuraWidget=v,n.configure=A,n.getConfig=u,n.getVersion=f,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type AuraWidgetEmitEvent<T = any> = {
|
|
2
|
+
type: string;
|
|
3
|
+
payload: T;
|
|
4
|
+
};
|
|
5
|
+
export type AuraWidgetInitParams = {
|
|
6
|
+
partnerKey: string;
|
|
7
|
+
tenantId: string | number;
|
|
8
|
+
tenantName: string;
|
|
9
|
+
user: {
|
|
10
|
+
email: string;
|
|
11
|
+
firstName?: string;
|
|
12
|
+
lastName?: string;
|
|
13
|
+
};
|
|
14
|
+
language?: string;
|
|
15
|
+
container?: string;
|
|
16
|
+
widgetId?: string;
|
|
17
|
+
widgetStyles?: Partial<Pick<CSSStyleDeclaration, 'width' | 'height' | 'borderRadius' | 'boxShadow' | 'top' | 'bottom' | 'left' | 'right'>>;
|
|
18
|
+
onAuthenticated?: () => void;
|
|
19
|
+
};
|
|
20
|
+
export type AuraWidgetMessageEvent<T = any> = {
|
|
21
|
+
type: string;
|
|
22
|
+
payload: T;
|
|
23
|
+
};
|
|
24
|
+
export type AuraTemplate = {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
body: {
|
|
28
|
+
sections: Record<string, any>[];
|
|
29
|
+
};
|
|
30
|
+
description: string;
|
|
31
|
+
encounterPhase: 'pre-chart' | 'in-visit';
|
|
32
|
+
};
|
|
33
|
+
export type AuraRegisterTemplatePayload = {
|
|
34
|
+
templates: AuraTemplate[];
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +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,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,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,MAAM,IAAI,CAAC;CAC9B,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"}
|