@nuralogix.ai/web-measurement-embedded-app 0.1.0-alpha.2 → 0.1.0-alpha.3
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/README.md +15 -2
- package/dist/app.mjs +24 -23
- package/lib/index.d.ts +2 -0
- package/lib/index.mjs +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -907,12 +907,14 @@ interface AppSettings {
|
|
|
907
907
|
refreshToken: string;
|
|
908
908
|
studyId: string;
|
|
909
909
|
}
|
|
910
|
+
type SupportedLanguage = 'en' | 'fr';
|
|
910
911
|
interface MeasurementEmbeddedAppOptions {
|
|
911
912
|
container: HTMLDivElement;
|
|
912
913
|
top?: string;
|
|
913
914
|
appPath: string;
|
|
914
915
|
settings: AppSettings;
|
|
915
916
|
profile?: Demographics;
|
|
917
|
+
language?: SupportedLanguage;
|
|
916
918
|
loadError?: (error: string) => void;
|
|
917
919
|
}
|
|
918
920
|
interface MeasurementEmbedded {
|
package/lib/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const h={RESULTS:"results",ERROR:"error",WEBHOOK:"webhook",CANCEL:"cancel"},O={DESTROY:"destroy",SET_THEME:"setTheme"};var R=s=>{throw TypeError(s)},_=(s,e,n)=>e.has(s)||R("Cannot "+n),t=(s,e,n)=>(_(s,e,"read from private field"),n?n.call(s):e.get(s)),m=(s,e,n)=>e.has(s)?R("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,n),
|
|
1
|
+
const h={RESULTS:"results",ERROR:"error",WEBHOOK:"webhook",CANCEL:"cancel"},O={DESTROY:"destroy",SET_THEME:"setTheme"};var R=s=>{throw TypeError(s)},_=(s,e,n)=>e.has(s)||R("Cannot "+n),t=(s,e,n)=>(_(s,e,"read from private field"),n?n.call(s):e.get(s)),m=(s,e,n)=>e.has(s)?R("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,n),I=(s,e,n,r)=>(_(s,e,"write to private field"),e.set(s,n),n),i,l,c,a;const S=class o{constructor(e){m(this,a),I(this,a,new Int32Array(e))}lock(){for(;;){if(Atomics.compareExchange(t(this,a),t(o,c),t(o,l),t(o,i))==t(o,l))return;Atomics.wait(t(this,a),t(o,c),t(o,i))}}unlock(){if(Atomics.compareExchange(t(this,a),t(o,c),t(o,i),t(o,l))!=t(o,i))throw new Error("Tried to unlock while not holding the mutex");Atomics.notify(t(this,a),t(o,c))}AsyncLock(e){const n=this;async function r(){for(;;){if(Atomics.compareExchange(t(n,a),t(o,c),t(o,l),t(o,i))==t(o,l)){e(),n.unlock();return}await Atomics.waitAsync(t(n,a),t(o,c),t(o,i)).value}}r()}};i=new WeakMap,l=new WeakMap,c=new WeakMap,a=new WeakMap,m(S,i,1),m(S,l,0),m(S,c,0);const $={SEX_NOT_PROVIDED:1,SEX_ASSIGNED_MALE_AT_BIRTH:2,SEX_ASSIGNED_FEMALE_AT_BIRTH:3,DIABETES_NONE:4,DIABETES_TYPE1:5,DIABETES_TYPE2:6,SMOKER_TRUE:0,SMOKER_FALSE:1,BLOOD_PRESSURE_MEDICATION_TRUE:1,BLOOD_PRESSURE_MEDICATION_FALSE:0},N=document.documentElement.style.overflow;class g{#e=document.createElement("div");#t=document.createElement("div");on={results:null,error:null,webhook:null,cancel:null};constructor(){this.#e.style.height="100%"}init(e){const{container:n,appPath:r,settings:w,profile:T,loadError:u,top:f=0,language:k}=e;this.#t=n,Object.assign(n.style,{position:"fixed",top:f,left:"0",width:"100vw",height:`calc(100vh - ${f})`}),document.body.appendChild(n);const p=n.attachShadow({mode:"open"});document.documentElement.style.overflow="hidden";const y="app",v=document.createElement("link");v.rel="stylesheet",v.href=`${r}/stylex.css`,p.appendChild(v);const A=document.createElement("link");A.rel="stylesheet",A.href=`${r}/${y}.css`,p.appendChild(A);const C=d=>{this.on.results&&this.on.results({...d.detail})},L=d=>{this.on.error&&this.on.error({...d.detail})},D=d=>{this.on.webhook&&this.on.webhook({...d.detail})},M=()=>{this.on.cancel&&this.on.cancel()};this.#e.addEventListener(h.RESULTS,C),this.#e.addEventListener(h.ERROR,L),this.#e.addEventListener(h.WEBHOOK,D),this.#e.addEventListener(h.CANCEL,M),p.appendChild(this.#e);const E=document.createElement("script");E.type="module",E.src=`${r}/${y}.mjs`,E.onload=()=>{import(E.src).then(d=>{d.app.init(this.#e,r,w,T,k)}).catch(()=>{u&&u("Failed to initialize Measurement Embedded React app")})},E.onerror=()=>{u&&u("Failed to load the measurement embedded app script")},p.appendChild(E)}destroy(){const e=new CustomEvent("measurement-embedded-app-action",{detail:{action:O.DESTROY,data:{}}});this.#e.dispatchEvent(e),document.documentElement.style.overflow=N,this.#t&&document.body.contains(this.#t)&&document.body.removeChild(this.#t)}setTheme(e){const n=new CustomEvent("measurement-embedded-app-action",{detail:{action:O.SET_THEME,data:{theme:e}}});this.#e.dispatchEvent(n)}}export{g as default,$ as faceAttributeValue,h as measurementEmbeddedAppEvents};
|