@insight-health/aura 0.0.1

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.
@@ -0,0 +1,29 @@
1
+ type AuraWidgetEmitEvent<T = any> = {
2
+ type: string;
3
+ data: T;
4
+ };
5
+ type AuraWidgetOpenParams = {
6
+ id?: string;
7
+ styles?: Partial<Pick<CSSStyleDeclaration, "width" | "height" | "borderRadius" | "boxShadow" | "top" | "bottom" | "left" | "right">>;
8
+ };
9
+ /**
10
+ * Aura service class
11
+ * Singleton pattern - all imports reference the same instance
12
+ */
13
+ declare class AuraWidgetService {
14
+ private widgetFrame;
15
+ constructor();
16
+ init: (params: AuraWidgetOpenParams) => Promise<void>;
17
+ show: () => void;
18
+ hide: () => void;
19
+ destroy: () => void;
20
+ emit: (event: AuraWidgetEmitEvent) => void;
21
+ on: (event: string, callback: (data: any) => void) => () => void;
22
+ /**
23
+ * Get SDK version
24
+ */
25
+ getVersion: () => string;
26
+ }
27
+ export declare const AuraWidget: AuraWidgetService;
28
+ export {};
29
+ //# sourceMappingURL=auraWidget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auraWidget.d.ts","sourceRoot":"","sources":["../src/auraWidget.ts"],"names":[],"mappings":"AAMA,KAAK,mBAAmB,CAAC,CAAC,GAAG,GAAG,IAAI;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,CAAC,CAAC;CACT,CAAC;AAEF,KAAK,oBAAoB,GAAG;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,OAAO,CACd,IAAI,CACF,mBAAmB,EACjB,OAAO,GACP,QAAQ,GACR,cAAc,GACd,WAAW,GACX,KAAK,GACL,QAAQ,GACR,MAAM,GACN,OAAO,CACV,CACF,CAAC;CACH,CAAC;AA8BF;;;GAGG;AACH,cAAM,iBAAiB;IACrB,OAAO,CAAC,WAAW,CAAkC;;IAcrD,IAAI,GAAU,QAAQ,oBAAoB,mBA2BxC;IAEF,IAAI,aAeF;IAEF,IAAI,aAIF;IAEF,OAAO,aAKL;IAEF,IAAI,GAAI,OAAO,mBAAmB,UAUhC;IAEF,EAAE,GAAI,OAAO,MAAM,EAAE,UAAU,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,gBAEhD;IAEF;;OAEG;IACH,UAAU,eAER;CACH;AAgBD,eAAO,MAAM,UAAU,mBAAgB,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Global storage for Aura SDK configuration
3
+ */
4
+ /**
5
+ * Root-level global configuration
6
+ * Shared across all services/interfaces
7
+ */
8
+ export interface GlobalConfig {
9
+ insightBaseUrl?: string;
10
+ clientToken: string;
11
+ }
12
+ /**
13
+ * Get the global configuration
14
+ */
15
+ export declare function getGlobalConfig(): GlobalConfig | null;
16
+ /**
17
+ * Set the global configuration
18
+ */
19
+ export declare function setGlobalConfig(config: GlobalConfig): void;
20
+ /**
21
+ * Clear the global configuration
22
+ */
23
+ export declare function clearGlobalConfig(): void;
24
+ /**
25
+ * Check if global configuration is set
26
+ */
27
+ export declare function hasGlobalConfig(): boolean;
28
+ //# sourceMappingURL=globalConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globalConfig.d.ts","sourceRoot":"","sources":["../src/globalConfig.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;CAErB;AAQD;;GAEG;AACH,wBAAgB,eAAe,IAAI,YAAY,GAAG,IAAI,CAErD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAE1D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAEzC"}
package/dist/index.cjs ADDED
@@ -0,0 +1,4 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f={insightBaseUrl:"https://app.lumi.build"};let h=null;function m(){return h}function b(i){h={...f,...i}}function p(i){b(i)}function o(){const i=m();if(!i)throw new Error("Aura SDK not configured. Call configure() first to set global configuration.");return i}function c(){return"0.0.1"}class F{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(s=>s!==e)}),this.emit=(t,e)=>{this.events[t]&&this.events[t].forEach(s=>s(e))}}}const a=new F,d={log:i=>{console.log(`[Insight Health Aura Widget]: ${i}`)},warn:i=>{console.warn(`[Insight Health Aura Widget]: ${i}`)},error:i=>{console.error(`[Insight Health Aura Widget]: ${i}`)}},g={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 y{constructor(){this.widgetFrame=null,this.init=async t=>{const e=o(),{id:s,styles:n}=t;if(!this.widgetFrame){this.widgetFrame=document.createElement("iframe");const u=(n==null?void 0:n.width)||"350px",l=(n==null?void 0:n.height)||"600px",w={...x,...n,...g};Object.assign(this.widgetFrame.style,w),this.widgetFrame.id=s||"aura-widget",this.widgetFrame.src=`${e.insightBaseUrl}`,this.widgetFrame.__desiredWidth=u,this.widgetFrame.__desiredHeight=l,this.widgetFrame.onerror=()=>{d.error(`Failed to load iframe. Please ensure your Content Security Policy includes:
2
+ frame-src ${e.insightBaseUrl}
3
+ `)},document.body.appendChild(this.widgetFrame)}},this.show=()=>{if(this.widgetFrame){const t=this.widgetFrame.__desiredWidth||"350px",e=this.widgetFrame.__desiredHeight||"600px",s={opacity:"1",pointerEvents:"auto",width:t,height:e,maxWidth:t,maxHeight:e};Object.assign(this.widgetFrame.style,s)}},this.hide=()=>{this.widgetFrame&&Object.assign(this.widgetFrame.style,{...g})},this.destroy=()=>{this.widgetFrame&&(this.widgetFrame.remove(),this.widgetFrame=null)},this.emit=t=>{var s;if(!((s=this.widgetFrame)!=null&&s.contentWindow)){d.warn("No widget iframe to communicate with");return}const e=o();this.widgetFrame.contentWindow.postMessage(t,{targetOrigin:e.insightBaseUrl}),this.show()},this.on=(t,e)=>a.subscribe(t,e),this.getVersion=()=>c(),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.data)})}}let r=null;function W(){return r||(r=new y),r}const C=W();exports.AuraWidget=C;exports.configure=p;exports.getConfig=o;exports.getVersion=c;
4
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/globalConfig.ts","../src/root.ts","../src/utils/eventBus.ts","../src/utils/logger.ts","../src/auraWidget.ts"],"sourcesContent":["/**\n * Global storage for Aura SDK configuration\n */\n\n/**\n * Root-level global configuration\n * Shared across all services/interfaces\n */\nexport interface GlobalConfig {\n insightBaseUrl?: string;\n clientToken: string;\n // Add other global config options here\n}\n\nconst defaultConfig: Partial<GlobalConfig> = {\n insightBaseUrl: \"https://app.lumi.build\",\n};\n\nlet globalConfig: GlobalConfig | null = null;\n\n/**\n * Get the global configuration\n */\nexport function getGlobalConfig(): GlobalConfig | null {\n return globalConfig;\n}\n\n/**\n * Set the global configuration\n */\nexport function setGlobalConfig(config: GlobalConfig): void {\n globalConfig = { ...defaultConfig, ...config };\n}\n\n/**\n * Clear the global configuration\n */\nexport function clearGlobalConfig(): void {\n globalConfig = null;\n}\n\n/**\n * Check if global configuration is set\n */\nexport function hasGlobalConfig(): boolean {\n return globalConfig !== null;\n}\n","/// <reference types=\"vite/client\" />\n\nimport { getGlobalConfig, GlobalConfig, setGlobalConfig } from './globalConfig'\n\n/**\n * Configure the Aura SDK globally (root-level)\n * Sets base configuration like baseUrl, apiKey, etc.\n * This configuration is shared across all services\n */\nexport function configure(config: GlobalConfig): void {\n setGlobalConfig(config)\n}\n\nexport function getConfig(): GlobalConfig {\n const globalConfig = getGlobalConfig()\n if (!globalConfig) {\n throw new Error(\n 'Aura SDK not configured. Call configure() first to set global configuration.'\n )\n }\n return globalConfig\n}\n\nexport function getVersion(): string {\n return import.meta.env.PACKAGE_VERSION\n}\n","class EventBus {\n private events: Record<string, ((data: any) => void)[]> = {};\n\n subscribe = (event: string, callback: (data: any) => void) => {\n if (!this.events[event]) {\n this.events[event] = [];\n }\n this.events[event].push(callback);\n\n return () => {\n this.events[event] = this.events[event].filter((cb) => cb !== callback);\n };\n };\n\n emit = (event: string, data: any) => {\n if (!this.events[event]) {\n return;\n }\n this.events[event].forEach((callback) => callback(data));\n };\n}\n\nexport const eventBus = new EventBus();","export const logger = {\n log: (message: string) => {\n console.log(`[Insight Health Aura Widget]: ${message}`);\n },\n warn: (message: string) => {\n console.warn(`[Insight Health Aura Widget]: ${message}`);\n },\n error: (message: string) => {\n console.error(`[Insight Health Aura Widget]: ${message}`);\n },\n};","/**\n * Aura SDK for Insight Health AI\n */\nimport { getVersion, getConfig } from \"./root\";\nimport { eventBus, logger } from \"./utils\";\n\ntype AuraWidgetEmitEvent<T = any> = {\n type: string;\n data: T;\n};\n\ntype AuraWidgetOpenParams = {\n id?: string;\n styles?: Partial<\n Pick<\n CSSStyleDeclaration,\n | \"width\"\n | \"height\"\n | \"borderRadius\"\n | \"boxShadow\"\n | \"top\"\n | \"bottom\"\n | \"left\"\n | \"right\"\n >\n >;\n};\n\ntype AuraWidgetMessageEvent<T = any> = {\n type: string;\n data: T;\n};\n\nconst hiddenStyles: Partial<CSSStyleDeclaration> = {\n opacity: \"0\",\n pointerEvents: \"none\",\n width: \"0\",\n height: \"0\",\n maxWidth: \"0\",\n maxHeight: \"0\",\n};\n\nconst defaultStyles: Partial<CSSStyleDeclaration> = {\n border: \"none\",\n borderRadius: \"10px\",\n boxShadow: \"0 0 10px 0 rgba(0, 0, 0, 0.1)\",\n overflow: \"hidden\",\n background: \"#fff\",\n position: \"fixed\",\n bottom: \"20px\",\n right: \"20px\",\n transition:\n \"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\",\n zIndex: \"9999\",\n};\n\n/**\n * Aura service class\n * Singleton pattern - all imports reference the same instance\n */\nclass AuraWidgetService {\n private widgetFrame: HTMLIFrameElement | null = null;\n\n constructor() {\n window.addEventListener(\n \"message\",\n (event: MessageEvent<AuraWidgetMessageEvent>) => {\n if (event.source !== this.widgetFrame?.contentWindow || !event.data) {\n return;\n }\n eventBus.emit(event.data.type, event.data.data);\n }\n );\n }\n\n init = async (params: AuraWidgetOpenParams) => {\n const globalConfig = getConfig();\n const { id, styles } = params;\n if (!this.widgetFrame) {\n this.widgetFrame = document.createElement(\"iframe\");\n // Store the desired dimensions from styles or use defaults\n const desiredWidth = styles?.width || \"350px\";\n const desiredHeight = styles?.height || \"600px\";\n const initialStyles = { ...defaultStyles, ...styles, ...hiddenStyles };\n Object.assign(this.widgetFrame.style, initialStyles);\n this.widgetFrame.id = id || `aura-widget`;\n this.widgetFrame.src = `${globalConfig.insightBaseUrl}`;\n\n // Store desired dimensions for show/hide\n (this.widgetFrame as any).__desiredWidth = desiredWidth;\n (this.widgetFrame as any).__desiredHeight = desiredHeight;\n\n // Add error handler for CSP violations\n this.widgetFrame.onerror = () => {\n logger.error(\n `Failed to load iframe. Please ensure your Content Security Policy includes:\\n` +\n ` frame-src ${globalConfig.insightBaseUrl}\\n`\n );\n };\n\n document.body.appendChild(this.widgetFrame);\n }\n };\n\n show = () => {\n if (this.widgetFrame) {\n const desiredWidth = (this.widgetFrame as any).__desiredWidth || \"350px\";\n const desiredHeight =\n (this.widgetFrame as any).__desiredHeight || \"600px\";\n const showStyles = {\n opacity: \"1\",\n pointerEvents: \"auto\",\n width: desiredWidth,\n height: desiredHeight,\n maxWidth: desiredWidth,\n maxHeight: desiredHeight,\n };\n Object.assign(this.widgetFrame.style, showStyles);\n }\n };\n\n hide = () => {\n if (this.widgetFrame) {\n Object.assign(this.widgetFrame.style, { ...hiddenStyles });\n }\n };\n\n destroy = () => {\n if (this.widgetFrame) {\n this.widgetFrame.remove();\n this.widgetFrame = null;\n }\n };\n\n emit = (event: AuraWidgetEmitEvent) => {\n if (!this.widgetFrame?.contentWindow) {\n logger.warn(\"No widget iframe to communicate with\");\n return;\n }\n const globalConfig = getConfig();\n this.widgetFrame.contentWindow.postMessage(event, {\n targetOrigin: globalConfig.insightBaseUrl,\n });\n this.show();\n };\n\n on = (event: string, callback: (data: any) => void) => {\n return eventBus.subscribe(event, callback);\n };\n\n /**\n * Get SDK version\n */\n getVersion = () => {\n return getVersion();\n };\n}\n\n// Singleton instance\nlet auraWidgetServiceInstance: AuraWidgetService | null = null;\n\n/**\n * Get the singleton Aura instance\n * All imports will reference the same instance\n */\nfunction getInstance(): AuraWidgetService {\n if (!auraWidgetServiceInstance) {\n auraWidgetServiceInstance = new AuraWidgetService();\n }\n return auraWidgetServiceInstance;\n}\n\nexport const AuraWidget = getInstance();\n"],"names":["defaultConfig","globalConfig","getGlobalConfig","setGlobalConfig","config","configure","getConfig","getVersion","EventBus","event","callback","cb","data","eventBus","logger","message","hiddenStyles","defaultStyles","AuraWidgetService","params","id","styles","desiredWidth","desiredHeight","initialStyles","showStyles","_a","auraWidgetServiceInstance","getInstance","AuraWidget"],"mappings":"gFAcA,MAAMA,EAAuC,CAC3C,eAAgB,wBAClB,EAEA,IAAIC,EAAoC,KAKjC,SAASC,GAAuC,CACrD,OAAOD,CACT,CAKO,SAASE,EAAgBC,EAA4B,CAC1DH,EAAe,CAAE,GAAGD,EAAe,GAAGI,CAAA,CACxC,CCvBO,SAASC,EAAUD,EAA4B,CACpDD,EAAgBC,CAAM,CACxB,CAEO,SAASE,GAA0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,EAAeC,IACZG,EAAS,UAAUJ,EAAOC,CAAQ,EAM3C,KAAA,WAAa,IACJH,EAAA,EA1FP,OAAO,iBACL,UACCE,GAAgD,OAC3CA,EAAM,WAAWiB,EAAA,KAAK,cAAL,YAAAA,EAAkB,gBAAiB,CAACjB,EAAM,MAG/DI,EAAS,KAAKJ,EAAM,KAAK,KAAMA,EAAM,KAAK,IAAI,CAChD,CAAA,CAEJ,CAmFF,CAGA,IAAIkB,EAAsD,KAM1D,SAASC,GAAiC,CACxC,OAAKD,IACHA,EAA4B,IAAIT,GAE3BS,CACT,CAEO,MAAME,EAAaD,EAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './root';
2
+ export * from './auraWidget';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,cAAc,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,124 @@
1
+ const w = {
2
+ insightBaseUrl: "https://app.lumi.build"
3
+ };
4
+ let g = null;
5
+ function m() {
6
+ return g;
7
+ }
8
+ function f(i) {
9
+ g = { ...w, ...i };
10
+ }
11
+ function y(i) {
12
+ f(i);
13
+ }
14
+ function o() {
15
+ const i = m();
16
+ if (!i)
17
+ throw new Error(
18
+ "Aura SDK not configured. Call configure() first to set global configuration."
19
+ );
20
+ return i;
21
+ }
22
+ function p() {
23
+ return "0.0.1";
24
+ }
25
+ class F {
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((s) => s !== e);
29
+ }), this.emit = (t, e) => {
30
+ this.events[t] && this.events[t].forEach((s) => s(e));
31
+ };
32
+ }
33
+ }
34
+ const a = new F(), d = {
35
+ log: (i) => {
36
+ console.log(`[Insight Health Aura Widget]: ${i}`);
37
+ },
38
+ warn: (i) => {
39
+ console.warn(`[Insight Health Aura Widget]: ${i}`);
40
+ },
41
+ error: (i) => {
42
+ console.error(`[Insight Health Aura Widget]: ${i}`);
43
+ }
44
+ }, h = {
45
+ opacity: "0",
46
+ pointerEvents: "none",
47
+ width: "0",
48
+ height: "0",
49
+ maxWidth: "0",
50
+ maxHeight: "0"
51
+ }, b = {
52
+ border: "none",
53
+ borderRadius: "10px",
54
+ boxShadow: "0 0 10px 0 rgba(0, 0, 0, 0.1)",
55
+ overflow: "hidden",
56
+ background: "#fff",
57
+ position: "fixed",
58
+ bottom: "20px",
59
+ right: "20px",
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
+ zIndex: "9999"
62
+ };
63
+ class x {
64
+ constructor() {
65
+ this.widgetFrame = null, this.init = async (t) => {
66
+ const e = o(), { id: s, styles: n } = t;
67
+ if (!this.widgetFrame) {
68
+ this.widgetFrame = document.createElement("iframe");
69
+ const c = (n == null ? void 0 : n.width) || "350px", u = (n == null ? void 0 : n.height) || "600px", l = { ...b, ...n, ...h };
70
+ Object.assign(this.widgetFrame.style, l), this.widgetFrame.id = s || "aura-widget", this.widgetFrame.src = `${e.insightBaseUrl}`, this.widgetFrame.__desiredWidth = c, this.widgetFrame.__desiredHeight = u, this.widgetFrame.onerror = () => {
71
+ d.error(
72
+ `Failed to load iframe. Please ensure your Content Security Policy includes:
73
+ frame-src ${e.insightBaseUrl}
74
+ `
75
+ );
76
+ }, document.body.appendChild(this.widgetFrame);
77
+ }
78
+ }, this.show = () => {
79
+ if (this.widgetFrame) {
80
+ const t = this.widgetFrame.__desiredWidth || "350px", e = this.widgetFrame.__desiredHeight || "600px", s = {
81
+ opacity: "1",
82
+ pointerEvents: "auto",
83
+ width: t,
84
+ height: e,
85
+ maxWidth: t,
86
+ maxHeight: e
87
+ };
88
+ Object.assign(this.widgetFrame.style, s);
89
+ }
90
+ }, this.hide = () => {
91
+ this.widgetFrame && Object.assign(this.widgetFrame.style, { ...h });
92
+ }, this.destroy = () => {
93
+ this.widgetFrame && (this.widgetFrame.remove(), this.widgetFrame = null);
94
+ }, this.emit = (t) => {
95
+ var s;
96
+ if (!((s = this.widgetFrame) != null && s.contentWindow)) {
97
+ d.warn("No widget iframe to communicate with");
98
+ return;
99
+ }
100
+ const e = o();
101
+ this.widgetFrame.contentWindow.postMessage(t, {
102
+ targetOrigin: e.insightBaseUrl
103
+ }), this.show();
104
+ }, this.on = (t, e) => a.subscribe(t, e), this.getVersion = () => p(), window.addEventListener(
105
+ "message",
106
+ (t) => {
107
+ var e;
108
+ t.source !== ((e = this.widgetFrame) == null ? void 0 : e.contentWindow) || !t.data || a.emit(t.data.type, t.data.data);
109
+ }
110
+ );
111
+ }
112
+ }
113
+ let r = null;
114
+ function W() {
115
+ return r || (r = new x()), r;
116
+ }
117
+ const C = W();
118
+ export {
119
+ C as AuraWidget,
120
+ y as configure,
121
+ o as getConfig,
122
+ p as getVersion
123
+ };
124
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/globalConfig.ts","../src/root.ts","../src/utils/eventBus.ts","../src/utils/logger.ts","../src/auraWidget.ts"],"sourcesContent":["/**\n * Global storage for Aura SDK configuration\n */\n\n/**\n * Root-level global configuration\n * Shared across all services/interfaces\n */\nexport interface GlobalConfig {\n insightBaseUrl?: string;\n clientToken: string;\n // Add other global config options here\n}\n\nconst defaultConfig: Partial<GlobalConfig> = {\n insightBaseUrl: \"https://app.lumi.build\",\n};\n\nlet globalConfig: GlobalConfig | null = null;\n\n/**\n * Get the global configuration\n */\nexport function getGlobalConfig(): GlobalConfig | null {\n return globalConfig;\n}\n\n/**\n * Set the global configuration\n */\nexport function setGlobalConfig(config: GlobalConfig): void {\n globalConfig = { ...defaultConfig, ...config };\n}\n\n/**\n * Clear the global configuration\n */\nexport function clearGlobalConfig(): void {\n globalConfig = null;\n}\n\n/**\n * Check if global configuration is set\n */\nexport function hasGlobalConfig(): boolean {\n return globalConfig !== null;\n}\n","/// <reference types=\"vite/client\" />\n\nimport { getGlobalConfig, GlobalConfig, setGlobalConfig } from './globalConfig'\n\n/**\n * Configure the Aura SDK globally (root-level)\n * Sets base configuration like baseUrl, apiKey, etc.\n * This configuration is shared across all services\n */\nexport function configure(config: GlobalConfig): void {\n setGlobalConfig(config)\n}\n\nexport function getConfig(): GlobalConfig {\n const globalConfig = getGlobalConfig()\n if (!globalConfig) {\n throw new Error(\n 'Aura SDK not configured. Call configure() first to set global configuration.'\n )\n }\n return globalConfig\n}\n\nexport function getVersion(): string {\n return import.meta.env.PACKAGE_VERSION\n}\n","class EventBus {\n private events: Record<string, ((data: any) => void)[]> = {};\n\n subscribe = (event: string, callback: (data: any) => void) => {\n if (!this.events[event]) {\n this.events[event] = [];\n }\n this.events[event].push(callback);\n\n return () => {\n this.events[event] = this.events[event].filter((cb) => cb !== callback);\n };\n };\n\n emit = (event: string, data: any) => {\n if (!this.events[event]) {\n return;\n }\n this.events[event].forEach((callback) => callback(data));\n };\n}\n\nexport const eventBus = new EventBus();","export const logger = {\n log: (message: string) => {\n console.log(`[Insight Health Aura Widget]: ${message}`);\n },\n warn: (message: string) => {\n console.warn(`[Insight Health Aura Widget]: ${message}`);\n },\n error: (message: string) => {\n console.error(`[Insight Health Aura Widget]: ${message}`);\n },\n};","/**\n * Aura SDK for Insight Health AI\n */\nimport { getVersion, getConfig } from \"./root\";\nimport { eventBus, logger } from \"./utils\";\n\ntype AuraWidgetEmitEvent<T = any> = {\n type: string;\n data: T;\n};\n\ntype AuraWidgetOpenParams = {\n id?: string;\n styles?: Partial<\n Pick<\n CSSStyleDeclaration,\n | \"width\"\n | \"height\"\n | \"borderRadius\"\n | \"boxShadow\"\n | \"top\"\n | \"bottom\"\n | \"left\"\n | \"right\"\n >\n >;\n};\n\ntype AuraWidgetMessageEvent<T = any> = {\n type: string;\n data: T;\n};\n\nconst hiddenStyles: Partial<CSSStyleDeclaration> = {\n opacity: \"0\",\n pointerEvents: \"none\",\n width: \"0\",\n height: \"0\",\n maxWidth: \"0\",\n maxHeight: \"0\",\n};\n\nconst defaultStyles: Partial<CSSStyleDeclaration> = {\n border: \"none\",\n borderRadius: \"10px\",\n boxShadow: \"0 0 10px 0 rgba(0, 0, 0, 0.1)\",\n overflow: \"hidden\",\n background: \"#fff\",\n position: \"fixed\",\n bottom: \"20px\",\n right: \"20px\",\n transition:\n \"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\",\n zIndex: \"9999\",\n};\n\n/**\n * Aura service class\n * Singleton pattern - all imports reference the same instance\n */\nclass AuraWidgetService {\n private widgetFrame: HTMLIFrameElement | null = null;\n\n constructor() {\n window.addEventListener(\n \"message\",\n (event: MessageEvent<AuraWidgetMessageEvent>) => {\n if (event.source !== this.widgetFrame?.contentWindow || !event.data) {\n return;\n }\n eventBus.emit(event.data.type, event.data.data);\n }\n );\n }\n\n init = async (params: AuraWidgetOpenParams) => {\n const globalConfig = getConfig();\n const { id, styles } = params;\n if (!this.widgetFrame) {\n this.widgetFrame = document.createElement(\"iframe\");\n // Store the desired dimensions from styles or use defaults\n const desiredWidth = styles?.width || \"350px\";\n const desiredHeight = styles?.height || \"600px\";\n const initialStyles = { ...defaultStyles, ...styles, ...hiddenStyles };\n Object.assign(this.widgetFrame.style, initialStyles);\n this.widgetFrame.id = id || `aura-widget`;\n this.widgetFrame.src = `${globalConfig.insightBaseUrl}`;\n\n // Store desired dimensions for show/hide\n (this.widgetFrame as any).__desiredWidth = desiredWidth;\n (this.widgetFrame as any).__desiredHeight = desiredHeight;\n\n // Add error handler for CSP violations\n this.widgetFrame.onerror = () => {\n logger.error(\n `Failed to load iframe. Please ensure your Content Security Policy includes:\\n` +\n ` frame-src ${globalConfig.insightBaseUrl}\\n`\n );\n };\n\n document.body.appendChild(this.widgetFrame);\n }\n };\n\n show = () => {\n if (this.widgetFrame) {\n const desiredWidth = (this.widgetFrame as any).__desiredWidth || \"350px\";\n const desiredHeight =\n (this.widgetFrame as any).__desiredHeight || \"600px\";\n const showStyles = {\n opacity: \"1\",\n pointerEvents: \"auto\",\n width: desiredWidth,\n height: desiredHeight,\n maxWidth: desiredWidth,\n maxHeight: desiredHeight,\n };\n Object.assign(this.widgetFrame.style, showStyles);\n }\n };\n\n hide = () => {\n if (this.widgetFrame) {\n Object.assign(this.widgetFrame.style, { ...hiddenStyles });\n }\n };\n\n destroy = () => {\n if (this.widgetFrame) {\n this.widgetFrame.remove();\n this.widgetFrame = null;\n }\n };\n\n emit = (event: AuraWidgetEmitEvent) => {\n if (!this.widgetFrame?.contentWindow) {\n logger.warn(\"No widget iframe to communicate with\");\n return;\n }\n const globalConfig = getConfig();\n this.widgetFrame.contentWindow.postMessage(event, {\n targetOrigin: globalConfig.insightBaseUrl,\n });\n this.show();\n };\n\n on = (event: string, callback: (data: any) => void) => {\n return eventBus.subscribe(event, callback);\n };\n\n /**\n * Get SDK version\n */\n getVersion = () => {\n return getVersion();\n };\n}\n\n// Singleton instance\nlet auraWidgetServiceInstance: AuraWidgetService | null = null;\n\n/**\n * Get the singleton Aura instance\n * All imports will reference the same instance\n */\nfunction getInstance(): AuraWidgetService {\n if (!auraWidgetServiceInstance) {\n auraWidgetServiceInstance = new AuraWidgetService();\n }\n return auraWidgetServiceInstance;\n}\n\nexport const AuraWidget = getInstance();\n"],"names":["defaultConfig","globalConfig","getGlobalConfig","setGlobalConfig","config","configure","getConfig","getVersion","EventBus","event","callback","cb","data","eventBus","logger","message","hiddenStyles","defaultStyles","AuraWidgetService","params","id","styles","desiredWidth","desiredHeight","initialStyles","showStyles","_a","auraWidgetServiceInstance","getInstance","AuraWidget"],"mappings":"AAcA,MAAMA,IAAuC;AAAA,EAC3C,gBAAgB;AAClB;AAEA,IAAIC,IAAoC;AAKjC,SAASC,IAAuC;AACrD,SAAOD;AACT;AAKO,SAASE,EAAgBC,GAA4B;AAC1D,E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OAAO,MAAM;AACX,MAAI,KAAK,eACP,OAAO,OAAO,KAAK,YAAY,OAAO,EAAE,GAAGT,GAAc;AAAA,IAE7D,GAEA,KAAA,UAAU,MAAM;AACd,MAAI,KAAK,gBACP,KAAK,YAAY,OAAA,GACjB,KAAK,cAAc;AAAA,IAEvB,GAEA,KAAA,OAAO,CAACP,MAA+B;AJxHzC,UAAAiB;AIyHI,UAAI,GAACA,IAAA,KAAK,gBAAL,QAAAA,EAAkB,gBAAe;AACpC,QAAAZ,EAAO,KAAK,sCAAsC;AAClD;AAAA,MACF;AACA,YAAMb,IAAeK,EAAA;AACrB,WAAK,YAAY,cAAc,YAAYG,GAAO;AAAA,QAChD,cAAcR,EAAa;AAAA,MAAA,CAC5B,GACD,KAAK,KAAA;AAAA,IACP,GAEA,KAAA,KAAK,CAACQ,GAAeC,MACZG,EAAS,UAAUJ,GAAOC,CAAQ,GAM3C,KAAA,aAAa,MACJH,EAAA,GA1FP,OAAO;AAAA,MACL;AAAA,MACA,CAACE,MAAgD;AJpDvD,YAAAiB;AIqDQ,QAAIjB,EAAM,aAAWiB,IAAA,KAAK,gBAAL,gBAAAA,EAAkB,kBAAiB,CAACjB,EAAM,QAG/DI,EAAS,KAAKJ,EAAM,KAAK,MAAMA,EAAM,KAAK,IAAI;AAAA,MAChD;AAAA,IAAA;AAAA,EAEJ;AAmFF;AAGA,IAAIkB,IAAsD;AAM1D,SAASC,IAAiC;AACxC,SAAKD,MACHA,IAA4B,IAAIT,EAAA,IAE3BS;AACT;AAEO,MAAME,IAAaD,EAAA;"}
@@ -0,0 +1,4 @@
1
+ (function(n,r){typeof exports=="object"&&typeof module<"u"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(n=typeof globalThis<"u"?globalThis:n||self,r(n.InsightAura={}))})(this,function(n){"use strict";const r={insightBaseUrl:"https://app.lumi.build"};let h=null;function f(){return h}function m(i){h={...r,...i}}function w(i){m(i)}function a(){const i=f();if(!i)throw new Error("Aura SDK not configured. Call configure() first to set global configuration.");return i}function g(){return"0.0.1"}class p{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(s=>s!==e)}),this.emit=(t,e)=>{this.events[t]&&this.events[t].forEach(s=>s(e))}}}const u=new p,c={log:i=>{console.log(`[Insight Health Aura Widget]: ${i}`)},warn:i=>{console.warn(`[Insight Health Aura Widget]: ${i}`)},error:i=>{console.error(`[Insight Health Aura Widget]: ${i}`)}},l={opacity:"0",pointerEvents:"none",width:"0",height:"0",maxWidth:"0",maxHeight:"0"},b={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 F{constructor(){this.widgetFrame=null,this.init=async t=>{const e=a(),{id:s,styles:o}=t;if(!this.widgetFrame){this.widgetFrame=document.createElement("iframe");const W=(o==null?void 0:o.width)||"350px",C=(o==null?void 0:o.height)||"600px",S={...b,...o,...l};Object.assign(this.widgetFrame.style,S),this.widgetFrame.id=s||"aura-widget",this.widgetFrame.src=`${e.insightBaseUrl}`,this.widgetFrame.__desiredWidth=W,this.widgetFrame.__desiredHeight=C,this.widgetFrame.onerror=()=>{c.error(`Failed to load iframe. Please ensure your Content Security Policy includes:
2
+ frame-src ${e.insightBaseUrl}
3
+ `)},document.body.appendChild(this.widgetFrame)}},this.show=()=>{if(this.widgetFrame){const t=this.widgetFrame.__desiredWidth||"350px",e=this.widgetFrame.__desiredHeight||"600px",s={opacity:"1",pointerEvents:"auto",width:t,height:e,maxWidth:t,maxHeight:e};Object.assign(this.widgetFrame.style,s)}},this.hide=()=>{this.widgetFrame&&Object.assign(this.widgetFrame.style,{...l})},this.destroy=()=>{this.widgetFrame&&(this.widgetFrame.remove(),this.widgetFrame=null)},this.emit=t=>{var s;if(!((s=this.widgetFrame)!=null&&s.contentWindow)){c.warn("No widget iframe to communicate with");return}const e=a();this.widgetFrame.contentWindow.postMessage(t,{targetOrigin:e.insightBaseUrl}),this.show()},this.on=(t,e)=>u.subscribe(t,e),this.getVersion=()=>g(),window.addEventListener("message",t=>{var e;t.source!==((e=this.widgetFrame)==null?void 0:e.contentWindow)||!t.data||u.emit(t.data.type,t.data.data)})}}let d=null;function y(){return d||(d=new F),d}const x=y();n.AuraWidget=x,n.configure=w,n.getConfig=a,n.getVersion=g,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
4
+ //# sourceMappingURL=index.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.umd.js","sources":["../src/globalConfig.ts","../src/root.ts","../src/utils/eventBus.ts","../src/utils/logger.ts","../src/auraWidget.ts"],"sourcesContent":["/**\n * Global storage for Aura SDK configuration\n */\n\n/**\n * Root-level global configuration\n * Shared across all services/interfaces\n */\nexport interface GlobalConfig {\n insightBaseUrl?: string;\n clientToken: string;\n // Add other global config options here\n}\n\nconst defaultConfig: Partial<GlobalConfig> = {\n insightBaseUrl: \"https://app.lumi.build\",\n};\n\nlet globalConfig: GlobalConfig | null = null;\n\n/**\n * Get the global configuration\n */\nexport function getGlobalConfig(): GlobalConfig | null {\n return globalConfig;\n}\n\n/**\n * Set the global configuration\n */\nexport function setGlobalConfig(config: GlobalConfig): void {\n globalConfig = { ...defaultConfig, ...config };\n}\n\n/**\n * Clear the global configuration\n */\nexport function clearGlobalConfig(): void {\n globalConfig = null;\n}\n\n/**\n * Check if global configuration is set\n */\nexport function hasGlobalConfig(): boolean {\n return globalConfig !== null;\n}\n","/// <reference types=\"vite/client\" />\n\nimport { getGlobalConfig, GlobalConfig, setGlobalConfig } from './globalConfig'\n\n/**\n * Configure the Aura SDK globally (root-level)\n * Sets base configuration like baseUrl, apiKey, etc.\n * This configuration is shared across all services\n */\nexport function configure(config: GlobalConfig): void {\n setGlobalConfig(config)\n}\n\nexport function getConfig(): GlobalConfig {\n const globalConfig = getGlobalConfig()\n if (!globalConfig) {\n throw new Error(\n 'Aura SDK not configured. Call configure() first to set global configuration.'\n )\n }\n return globalConfig\n}\n\nexport function getVersion(): string {\n return import.meta.env.PACKAGE_VERSION\n}\n","class EventBus {\n private events: Record<string, ((data: any) => void)[]> = {};\n\n subscribe = (event: string, callback: (data: any) => void) => {\n if (!this.events[event]) {\n this.events[event] = [];\n }\n this.events[event].push(callback);\n\n return () => {\n this.events[event] = this.events[event].filter((cb) => cb !== callback);\n };\n };\n\n emit = (event: string, data: any) => {\n if (!this.events[event]) {\n return;\n }\n this.events[event].forEach((callback) => callback(data));\n };\n}\n\nexport const eventBus = new EventBus();","export const logger = {\n log: (message: string) => {\n console.log(`[Insight Health Aura Widget]: ${message}`);\n },\n warn: (message: string) => {\n console.warn(`[Insight Health Aura Widget]: ${message}`);\n },\n error: (message: string) => {\n console.error(`[Insight Health Aura Widget]: ${message}`);\n },\n};","/**\n * Aura SDK for Insight Health AI\n */\nimport { getVersion, getConfig } from \"./root\";\nimport { eventBus, logger } from \"./utils\";\n\ntype AuraWidgetEmitEvent<T = any> = {\n type: string;\n data: T;\n};\n\ntype AuraWidgetOpenParams = {\n id?: string;\n styles?: Partial<\n Pick<\n CSSStyleDeclaration,\n | \"width\"\n | \"height\"\n | \"borderRadius\"\n | \"boxShadow\"\n | \"top\"\n | \"bottom\"\n | \"left\"\n | \"right\"\n >\n >;\n};\n\ntype AuraWidgetMessageEvent<T = any> = {\n type: string;\n data: T;\n};\n\nconst hiddenStyles: Partial<CSSStyleDeclaration> = {\n opacity: \"0\",\n pointerEvents: \"none\",\n width: \"0\",\n height: \"0\",\n maxWidth: \"0\",\n maxHeight: \"0\",\n};\n\nconst defaultStyles: Partial<CSSStyleDeclaration> = {\n border: \"none\",\n borderRadius: \"10px\",\n boxShadow: \"0 0 10px 0 rgba(0, 0, 0, 0.1)\",\n overflow: \"hidden\",\n background: \"#fff\",\n position: \"fixed\",\n bottom: \"20px\",\n right: \"20px\",\n transition:\n \"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\",\n zIndex: \"9999\",\n};\n\n/**\n * Aura service class\n * Singleton pattern - all imports reference the same instance\n */\nclass AuraWidgetService {\n private widgetFrame: HTMLIFrameElement | null = null;\n\n constructor() {\n window.addEventListener(\n \"message\",\n (event: MessageEvent<AuraWidgetMessageEvent>) => {\n if (event.source !== this.widgetFrame?.contentWindow || !event.data) {\n return;\n }\n eventBus.emit(event.data.type, event.data.data);\n }\n );\n }\n\n init = async (params: AuraWidgetOpenParams) => {\n const globalConfig = getConfig();\n const { id, styles } = params;\n if (!this.widgetFrame) {\n this.widgetFrame = document.createElement(\"iframe\");\n // Store the desired dimensions from styles or use defaults\n const desiredWidth = styles?.width || \"350px\";\n const desiredHeight = styles?.height || \"600px\";\n const initialStyles = { ...defaultStyles, ...styles, ...hiddenStyles };\n Object.assign(this.widgetFrame.style, initialStyles);\n this.widgetFrame.id = id || `aura-widget`;\n this.widgetFrame.src = `${globalConfig.insightBaseUrl}`;\n\n // Store desired dimensions for show/hide\n (this.widgetFrame as any).__desiredWidth = desiredWidth;\n (this.widgetFrame as any).__desiredHeight = desiredHeight;\n\n // Add error handler for CSP violations\n this.widgetFrame.onerror = () => {\n logger.error(\n `Failed to load iframe. Please ensure your Content Security Policy includes:\\n` +\n ` frame-src ${globalConfig.insightBaseUrl}\\n`\n );\n };\n\n document.body.appendChild(this.widgetFrame);\n }\n };\n\n show = () => {\n if (this.widgetFrame) {\n const desiredWidth = (this.widgetFrame as any).__desiredWidth || \"350px\";\n const desiredHeight =\n (this.widgetFrame as any).__desiredHeight || \"600px\";\n const showStyles = {\n opacity: \"1\",\n pointerEvents: \"auto\",\n width: desiredWidth,\n height: desiredHeight,\n maxWidth: desiredWidth,\n maxHeight: desiredHeight,\n };\n Object.assign(this.widgetFrame.style, showStyles);\n }\n };\n\n hide = () => {\n if (this.widgetFrame) {\n Object.assign(this.widgetFrame.style, { ...hiddenStyles });\n }\n };\n\n destroy = () => {\n if (this.widgetFrame) {\n this.widgetFrame.remove();\n this.widgetFrame = null;\n }\n };\n\n emit = (event: AuraWidgetEmitEvent) => {\n if (!this.widgetFrame?.contentWindow) {\n logger.warn(\"No widget iframe to communicate with\");\n return;\n }\n const globalConfig = getConfig();\n this.widgetFrame.contentWindow.postMessage(event, {\n targetOrigin: globalConfig.insightBaseUrl,\n });\n this.show();\n };\n\n on = (event: string, callback: (data: any) => void) => {\n return eventBus.subscribe(event, callback);\n };\n\n /**\n * Get SDK version\n */\n getVersion = () => {\n return getVersion();\n };\n}\n\n// Singleton instance\nlet auraWidgetServiceInstance: AuraWidgetService | null = null;\n\n/**\n * Get the singleton Aura instance\n * All imports will reference the same instance\n */\nfunction getInstance(): AuraWidgetService {\n if (!auraWidgetServiceInstance) {\n auraWidgetServiceInstance = new AuraWidgetService();\n }\n return auraWidgetServiceInstance;\n}\n\nexport const AuraWidget = getInstance();\n"],"names":["defaultConfig","globalConfig","getGlobalConfig","setGlobalConfig","config","configure","getConfig","getVersion","EventBus","event","callback","cb","data","eventBus","logger","message","hiddenStyles","defaultStyles","AuraWidgetService","params","id","styles","desiredWidth","desiredHeight","initialStyles","showStyles","_a","auraWidgetServiceInstance","getInstance","AuraWidget"],"mappings":"mOAcA,MAAMA,EAAuC,CAC3C,eAAgB,wBAClB,EAEA,IAAIC,EAAoC,KAKjC,SAASC,GAAuC,CACrD,OAAOD,CACT,CAKO,SAASE,EAAgBC,EAA4B,CAC1DH,EAAe,CAAE,GAAGD,EAAe,GAAGI,CAAA,CACxC,CCvBO,SAASC,EAAUD,EAA4B,CACpDD,EAAgBC,CAAM,CACxB,CAEO,SAASE,GAA0B,CACxC,MAAML,EAAeC,EAAA,EACrB,GAAI,CAACD,EACH,MAAM,IAAI,MACR,8EAAA,EAGJ,OAAOA,CACT,CAEO,SAASM,GAAqB,CACnC,MAAO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AAWiB,EAAA,KAAK,cAAL,YAAAA,EAAkB,gBAAiB,CAACjB,EAAM,MAG/DI,EAAS,KAAKJ,EAAM,KAAK,KAAMA,EAAM,KAAK,IAAI,CAChD,CAAA,CAEJ,CAmFF,CAGA,IAAIkB,EAAsD,KAM1D,SAASC,GAAiC,CACxC,OAAKD,IACHA,EAA4B,IAAIT,GAE3BS,CACT,CAEO,MAAME,EAAaD,EAAA"}
package/dist/root.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { GlobalConfig } from './globalConfig';
2
+
3
+ /**
4
+ * Configure the Aura SDK globally (root-level)
5
+ * Sets base configuration like baseUrl, apiKey, etc.
6
+ * This configuration is shared across all services
7
+ */
8
+ export declare function configure(config: GlobalConfig): void;
9
+ export declare function getConfig(): GlobalConfig;
10
+ export declare function getVersion(): string;
11
+ //# sourceMappingURL=root.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../src/root.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,YAAY,EAAmB,MAAM,gBAAgB,CAAA;AAE/E;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAEpD;AAED,wBAAgB,SAAS,IAAI,YAAY,CAQxC;AAED,wBAAgB,UAAU,IAAI,MAAM,CAEnC"}
@@ -0,0 +1,8 @@
1
+ declare class EventBus {
2
+ private events;
3
+ subscribe: (event: string, callback: (data: any) => void) => () => void;
4
+ emit: (event: string, data: any) => void;
5
+ }
6
+ export declare const eventBus: EventBus;
7
+ export {};
8
+ //# sourceMappingURL=eventBus.d.ts.map
@@ -0,0 +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,MAAM,GAAG,UAK9B;CACH;AAED,eAAO,MAAM,QAAQ,UAAiB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './eventBus';
2
+ export * from './logger';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const logger: {
2
+ log: (message: string) => void;
3
+ warn: (message: string) => void;
4
+ error: (message: string) => void;
5
+ };
6
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;mBACF,MAAM;oBAGL,MAAM;qBAGL,MAAM;CAGxB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@insight-health/aura",
3
+ "version": "0.0.1",
4
+ "description": "Aura SDK package for Insight Health AI",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs",
14
+ "browser": "./dist/index.umd.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "keywords": [
21
+ "insight",
22
+ "health",
23
+ "ai",
24
+ "aura",
25
+ "sdk"
26
+ ],
27
+ "author": "",
28
+ "license": "ISC",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/insight-health-ai/insight-sdk-web.git",
32
+ "directory": "packages/aura"
33
+ },
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "scripts": {
38
+ "build": "vite build",
39
+ "type-check": "tsc --noEmit",
40
+ "clean": "rm -rf dist"
41
+ }
42
+ }