@insight-health/aura 0.0.3 → 0.0.4
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 +58 -49
- package/dist/index.umd.js +3 -3
- package/dist/types.d.ts +35 -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, "user" | "subTenantId" | "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,mBAgElC;IAEF,iBAAiB,GAAI,SAAS,2BAA2B,UAKvD;IAEF,OAAO,GACL,QAAQ,IAAI,CAAC,oBAAoB,EAAE,MAAM,GAAG,aAAa,GAAG,UAAU,CAAC,UAiBvE;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 W={insightBaseUrl:"https://anywhere.insighthealth.ai"};let f=null;function C(){return f}function v(
|
|
2
|
-
frame-src ${
|
|
3
|
-
`)},(
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W={insightBaseUrl:"https://anywhere.insighthealth.ai"};let f=null;function C(){return f}function v(s){f={...W,...s}}function B(s){v(s)}function g(){const s=C();if(!s)throw new Error("Aura SDK not configured. Call configure() first to set global configuration.");return s}function m(){return"0.0.4"}class I{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 I,c={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}`)}},l={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 H{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)){c.warn("No widget iframe to communicate with");return}const e=g();this.widgetFrame.contentWindow.postMessage(t,{targetOrigin:e.insightBaseUrl})},this.init=t=>new Promise(e=>{if(!this.widgetFrame){this.reset();const i=g(),{subTenantId:r,user:o,language:w,container:d,widgetId:p,widgetStyles:n}=t;this.config=t,this.isFrameReady=!1,this.widgetFrame=document.createElement("iframe");const b=(n==null?void 0:n.width)||"350px",F=(n==null?void 0:n.height)||"600px",y={...U,...n,...l};Object.assign(this.widgetFrame.style,y),this.widgetFrame.id=p||"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=F,this.widgetFrame.onerror=()=>{c.error(`Failed to load iframe. Please ensure your Content Security Policy includes:
|
|
2
|
+
frame-src ${i.insightBaseUrl}
|
|
3
|
+
`)},(d&&document.querySelector(d)||document.body).appendChild(this.widgetFrame);const A=a.subscribe("Auth.Ready",()=>{this.isFrameReady=!0,this.setUser({subTenantId:r,user:o,language:w})}),x=a.subscribe("Auth.Complete",()=>{var u;this.isFrameAuthenticated=!0,e(),(u=t.onAuthenticated)==null||u.call(t)});this.unsubsciptions.push(A,x)}}),this.registerTemplates=t=>{this.postMessage({type:"Template.Register",payload:t})},this.setUser=t=>{const e=this.config.partnerKey,{subTenantId:i,user:r,language:o}=t;this.config.subTenantId=i,this.config.user=r,this.config.language=o,this.isFrameAuthenticated=!1,this.postMessage({type:"Auth.Login",payload:{partnerKey:e,subTenantId:i,user:r,language:o}})},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,{...l})},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=()=>m(),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 h=null;function S(){return h||(h=new H),h}const $=S();exports.AuraWidget=$;exports.configure=B;exports.getConfig=g;exports.getVersion=m;
|
package/dist/index.js
CHANGED
|
@@ -5,41 +5,41 @@ let f = null;
|
|
|
5
5
|
function W() {
|
|
6
6
|
return f;
|
|
7
7
|
}
|
|
8
|
-
function C(
|
|
9
|
-
f = { ...A, ...
|
|
8
|
+
function C(s) {
|
|
9
|
+
f = { ...A, ...s };
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
C(
|
|
11
|
+
function $(s) {
|
|
12
|
+
C(s);
|
|
13
13
|
}
|
|
14
14
|
function u() {
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
15
|
+
const s = W();
|
|
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 B() {
|
|
23
|
+
return "0.0.4";
|
|
24
24
|
}
|
|
25
|
-
class
|
|
25
|
+
class I {
|
|
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 a = new I(), c = {
|
|
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
|
}, l = {
|
|
45
45
|
opacity: "0",
|
|
@@ -48,7 +48,7 @@ const r = new H(), c = {
|
|
|
48
48
|
height: "0",
|
|
49
49
|
maxWidth: "0",
|
|
50
50
|
maxHeight: "0"
|
|
51
|
-
},
|
|
51
|
+
}, U = {
|
|
52
52
|
border: "none",
|
|
53
53
|
borderRadius: "10px",
|
|
54
54
|
boxShadow: "0 0 10px 0 rgba(0, 0, 0, 0.1)",
|
|
@@ -60,11 +60,11 @@ 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 v {
|
|
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 (!((
|
|
66
|
+
var i;
|
|
67
|
+
if (!((i = this.widgetFrame) != null && i.contentWindow)) {
|
|
68
68
|
c.warn("No widget iframe to communicate with");
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
@@ -74,30 +74,34 @@ class E {
|
|
|
74
74
|
});
|
|
75
75
|
}, this.init = (t) => new Promise((e) => {
|
|
76
76
|
if (!this.widgetFrame) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
this.reset();
|
|
78
|
+
const i = u(), {
|
|
79
|
+
subTenantId: r,
|
|
80
|
+
user: o,
|
|
80
81
|
language: m,
|
|
81
82
|
container: d,
|
|
82
83
|
widgetId: w,
|
|
83
84
|
widgetStyles: n
|
|
84
85
|
} = t;
|
|
85
86
|
this.config = t, this.isFrameReady = !1, this.widgetFrame = document.createElement("iframe");
|
|
86
|
-
const
|
|
87
|
-
...
|
|
87
|
+
const p = (n == null ? void 0 : n.width) || "350px", F = (n == null ? void 0 : n.height) || "600px", b = {
|
|
88
|
+
...U,
|
|
88
89
|
...n,
|
|
89
90
|
...l
|
|
90
91
|
};
|
|
91
|
-
Object.assign(this.widgetFrame.style, b), this.widgetFrame.id = w || "aura-widget", this.widgetFrame.
|
|
92
|
+
Object.assign(this.widgetFrame.style, b), this.widgetFrame.id = w || "aura-widget", this.widgetFrame.setAttribute(
|
|
93
|
+
"allow",
|
|
94
|
+
`microphone ${i.insightBaseUrl}; camera ${i.insightBaseUrl}; clipboard-read ${i.insightBaseUrl}; clipboard-write ${i.insightBaseUrl};`
|
|
95
|
+
), this.widgetFrame.src = `${i.insightBaseUrl}`, this.widgetFrame.__desiredWidth = p, this.widgetFrame.__desiredHeight = F, this.widgetFrame.onerror = () => {
|
|
92
96
|
c.error(
|
|
93
97
|
`Failed to load iframe. Please ensure your Content Security Policy includes:
|
|
94
|
-
frame-src ${
|
|
98
|
+
frame-src ${i.insightBaseUrl}
|
|
95
99
|
`
|
|
96
100
|
);
|
|
97
101
|
}, (d && document.querySelector(d) || document.body).appendChild(this.widgetFrame);
|
|
98
|
-
const y =
|
|
99
|
-
this.isFrameReady = !0, this.setUser({ subTenantId:
|
|
100
|
-
}), x =
|
|
102
|
+
const y = a.subscribe("Auth.Ready", () => {
|
|
103
|
+
this.isFrameReady = !0, this.setUser({ subTenantId: r, user: o, language: m });
|
|
104
|
+
}), x = a.subscribe(
|
|
101
105
|
"Auth.Complete",
|
|
102
106
|
() => {
|
|
103
107
|
var g;
|
|
@@ -106,20 +110,25 @@ class E {
|
|
|
106
110
|
);
|
|
107
111
|
this.unsubsciptions.push(y, x);
|
|
108
112
|
}
|
|
109
|
-
}), this.
|
|
110
|
-
|
|
111
|
-
|
|
113
|
+
}), this.registerTemplates = (t) => {
|
|
114
|
+
this.postMessage({
|
|
115
|
+
type: "Template.Register",
|
|
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({
|
|
112
121
|
type: "Auth.Login",
|
|
113
122
|
payload: {
|
|
114
123
|
partnerKey: e,
|
|
115
|
-
subTenantId:
|
|
116
|
-
user:
|
|
117
|
-
language:
|
|
124
|
+
subTenantId: i,
|
|
125
|
+
user: r,
|
|
126
|
+
language: o
|
|
118
127
|
}
|
|
119
128
|
});
|
|
120
129
|
}, this.show = () => {
|
|
121
130
|
if (this.widgetFrame) {
|
|
122
|
-
const t = this.widgetFrame.__desiredWidth || "350px", e = this.widgetFrame.__desiredHeight || "600px",
|
|
131
|
+
const t = this.widgetFrame.__desiredWidth || "350px", e = this.widgetFrame.__desiredHeight || "600px", i = {
|
|
123
132
|
opacity: "1",
|
|
124
133
|
pointerEvents: "auto",
|
|
125
134
|
width: t,
|
|
@@ -127,7 +136,7 @@ class E {
|
|
|
127
136
|
maxWidth: t,
|
|
128
137
|
maxHeight: e
|
|
129
138
|
};
|
|
130
|
-
Object.assign(this.widgetFrame.style, { ...
|
|
139
|
+
Object.assign(this.widgetFrame.style, { ...i });
|
|
131
140
|
}
|
|
132
141
|
}, this.hide = () => {
|
|
133
142
|
this.widgetFrame && Object.assign(this.widgetFrame.style, { ...l });
|
|
@@ -135,23 +144,23 @@ class E {
|
|
|
135
144
|
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
145
|
}, this.emit = (t) => {
|
|
137
146
|
this.postMessage(t), this.show();
|
|
138
|
-
}, this.on = (t, e) =>
|
|
147
|
+
}, this.on = (t, e) => a.subscribe(t, e), this.getConfig = () => this.config, this.getVersion = () => B(), window.addEventListener(
|
|
139
148
|
"message",
|
|
140
149
|
(t) => {
|
|
141
150
|
var e;
|
|
142
|
-
t.source !== ((e = this.widgetFrame) == null ? void 0 : e.contentWindow) || !t.data ||
|
|
151
|
+
t.source !== ((e = this.widgetFrame) == null ? void 0 : e.contentWindow) || !t.data || a.emit(t.data.type, t.data.payload);
|
|
143
152
|
}
|
|
144
153
|
);
|
|
145
154
|
}
|
|
146
155
|
}
|
|
147
156
|
let h = null;
|
|
148
|
-
function
|
|
149
|
-
return h || (h = new
|
|
157
|
+
function H() {
|
|
158
|
+
return h || (h = new v()), h;
|
|
150
159
|
}
|
|
151
|
-
const
|
|
160
|
+
const E = H();
|
|
152
161
|
export {
|
|
153
|
-
|
|
154
|
-
|
|
162
|
+
E as AuraWidget,
|
|
163
|
+
$ as configure,
|
|
155
164
|
u as getConfig,
|
|
156
|
-
|
|
165
|
+
B as getVersion
|
|
157
166
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(n,
|
|
2
|
-
frame-src ${
|
|
3
|
-
`)},(w&&document.querySelector(w)||document.body).appendChild(this.widgetFrame);const
|
|
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 c=null;function b(){return c}function F(s){c={...o,...s}}function y(s){F(s)}function g(){const s=b();if(!s)throw new Error("Aura SDK not configured. Call configure() first to set global configuration.");return s}function l(){return"0.0.4"}class A{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 a=new A,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"},x={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 W{constructor(){this.config=null,this.widgetFrame=null,this.unsubsciptions=[],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.init=e=>new Promise(t=>{if(!this.widgetFrame){this.reset();const i=g(),{subTenantId:h,user:d,language:v,container:w,widgetId:B,widgetStyles:r}=e;this.config=e,this.isFrameReady=!1,this.widgetFrame=document.createElement("iframe");const U=(r==null?void 0:r.width)||"350px",H=(r==null?void 0:r.height)||"600px",S={...x,...r,...m};Object.assign(this.widgetFrame.style,S),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=U,this.widgetFrame.__desiredHeight=H,this.widgetFrame.onerror=()=>{f.error(`Failed to load iframe. Please ensure your Content Security Policy includes:
|
|
2
|
+
frame-src ${i.insightBaseUrl}
|
|
3
|
+
`)},(w&&document.querySelector(w)||document.body).appendChild(this.widgetFrame);const $=a.subscribe("Auth.Ready",()=>{this.isFrameReady=!0,this.setUser({subTenantId:h,user:d,language:v})}),E=a.subscribe("Auth.Complete",()=>{var p;this.isFrameAuthenticated=!0,t(),(p=e.onAuthenticated)==null||p.call(e)});this.unsubsciptions.push($,E)}}),this.registerTemplates=e=>{this.postMessage({type:"Template.Register",payload:e})},this.setUser=e=>{const t=this.config.partnerKey,{subTenantId:i,user:h,language:d}=e;this.config.subTenantId=i,this.config.user=h,this.config.language=d,this.isFrameAuthenticated=!1,this.postMessage({type:"Auth.Login",payload:{partnerKey:t,subTenantId:i,user:h,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,{...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.emit=e=>{this.postMessage(e),this.show()},this.on=(e,t)=>a.subscribe(e,t),this.getConfig=()=>this.config,this.getVersion=()=>l(),window.addEventListener("message",e=>{var t;e.source!==((t=this.widgetFrame)==null?void 0:t.contentWindow)||!e.data||a.emit(e.data.type,e.data.payload)})}}let u=null;function C(){return u||(u=new W),u}const I=C();n.AuraWidget=I,n.configure=y,n.getConfig=g,n.getVersion=l,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type AuraWidgetEmitEvent<T = any> = {
|
|
2
|
+
type: string;
|
|
3
|
+
payload: T;
|
|
4
|
+
};
|
|
5
|
+
export type AuraWidgetInitParams = {
|
|
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
|
+
};
|
|
19
|
+
export type AuraWidgetMessageEvent<T = any> = {
|
|
20
|
+
type: string;
|
|
21
|
+
payload: T;
|
|
22
|
+
};
|
|
23
|
+
export type AuraTemplate = {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
body: {
|
|
27
|
+
sections: Record<string, any>[];
|
|
28
|
+
};
|
|
29
|
+
description: string;
|
|
30
|
+
encounterPhase: 'pre-chart' | 'in-visit';
|
|
31
|
+
};
|
|
32
|
+
export type AuraRegisterTemplatePayload = {
|
|
33
|
+
templates: AuraTemplate[];
|
|
34
|
+
};
|
|
35
|
+
//# 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,WAAW,EAAE,MAAM,CAAC;IACpB,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"}
|