@nuralogix.ai/web-measurement-embedded-app 0.1.0-alpha.1 → 0.1.0-alpha.11

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.
@@ -1,24 +1,42 @@
1
1
  {
2
- "BTN_START_MEASUREMENT": "Démarrer la mesure",
2
+ "CAMERA_START_ERROR": "Impossible de démarrer la caméra. Veuillez vous assurer que la caméra est connectée et qu’elle n’est pas utilisée par une autre application.",
3
3
  "CANCEL": "Annuler",
4
- "ERR_FACE_NONE": "Veuillez garder votre visage centré dans le contour pendant toute la mesure",
4
+ "CENTER_YOUR_FACE": "Centrez votre visage",
5
5
  "ERROR_TAB_SWITCHED_OR_WINDOW_MINIMIZED": "La mesure a échoué car l’onglet a été changé ou la fenêtre du navigateur a été minimisée. Veuillez vous assurer que l’onglet reste ouvert et actif.",
6
- "KIOSK_HELP_CAMERA": "Veuillez faire face à l'appareil photo et positionner votre visage dans le cercle pendant toute la durée de la mesure.",
7
- "KIOSK_HELP_ACCESSORIES": "Veuillez retirer tous les accessoires de votre visage avant la mesure, par exemple des lunettes, un chapeau ou le maquillage.",
8
- "KIOSK_HELP_STAY": "Lorsque la mesure a commencé, gardez la même position pendant 30 secondes, jusqu'à la fin de l'opération.",
6
+ "ERR_FACE_NONE": "Veuillez garder votre visage centré dans le contour pendant toute la mesure",
7
+ "ERR_LOADING_CONFIGURATIONS": "Vous ne pouvez pas accéder à ce service en raison d'une erreur de chargement de la configuration. Veuillez contacter votre administrateur système pour obtenir de l'aide.",
8
+ "ERR_MSG_SNR": "Le mesure du flux sanguin n'est pas fiable.\nVeuillez rester immobile et ajuster l'éclairage afin que la lumière soit uniformément répartie sur votre visage",
9
+ "ERR_TAB_SWITCHED_OR_WINDOW_MINIMIZED": "La mesure a échoué car l’onglet a été changé ou la fenêtre du navigateur a été minimisée. Veuillez vous assurer que l’onglet reste ouvert et actif.",
10
+ "FACE_NOT_DETECTED": "Visage non détecté",
11
+ "HELP_ACCESSORIES": "Veuillez retirer tous les accessoires de votre visage avant la mesure, par exemple des lunettes, un chapeau ou le maquillage.",
12
+ "HELP_CAMERA": "Veuillez faire face à l'appareil photo et positionner votre visage dans le cercle pendant toute la durée de la mesure.",
13
+ "HELP_STAY": "Lorsque la mesure a commencé, gardez la même position pendant 30 secondes, jusqu'à la fin de l'opération.",
9
14
  "HELP_TITLE": "Aide",
15
+ "LOOK_DOWN": "Baissez les yeux",
16
+ "LOOK_UP": "Levez les yeux",
17
+ "MEASURE_INSTRUCTIONS_NO_FACE": "Veuillez centrer votre visage dans le cercle",
18
+ "MOVE_BACK": "Reculez",
19
+ "MOVE_CLOSER": "Rapprochez-vous",
10
20
  "NO_DEVICES_FOUND": "Aucun appareil détecté",
21
+ "PLEASE_HOLD_STILL": "Veuillez rester immobile",
22
+ "PLEASE_WAIT": "Veuillez patienter, la mesure va bientôt commencer…",
23
+ "READY_TO_MEASURE": "Prêt à mesurer",
24
+ "SELECT_CAMERA": "Sélectionner une caméra pour commencer",
25
+ "START_CAMERA": "Démarrer la caméra",
26
+ "START_MEASUREMENT": "Démarrer la mesure",
11
27
  "STOP_CAMERA": "Arrêter la caméra",
28
+ "TILT_YOUR_FACE_LEFT": "Inclinez votre visage vers la gauche",
29
+ "TILT_YOUR_FACE_RIGHT": "Inclinez votre visage vers la droite",
30
+ "TURN_LEFT": "Tournez la tête à gauche",
31
+ "TURN_RIGHT": "Tournez la tête à droite",
32
+ "WAITING_FOR_RESULTS": "Dans l’attente des résultats",
33
+ "WARNING_CONSTRAINT_DISTANCE": "Votre visage est trop éloigné. Essayez de vous rapprocher de la caméra",
34
+ "WARNING_CONSTRAINT_GAZE": "Veuillez regarder directement l'appareil photo",
35
+ "WARNING_FACE_NOT_DETECTED": "Visage non détecté. Centrez votre visage dans le cadre avant de commencer.",
12
36
  "WEB_BTN_SELECT_CAMERA": "Sélectionner une caméra pour commencer",
13
37
  "WEB_BTN_START_CAMERA": "Démarrer la caméra",
14
- "WEB_CAMERA_START_ERROR": "Impossible de démarrer la caméra. Veuillez vous assurer que la caméra est connectée et qu’elle n’est pas utilisée par une autre application.",
15
38
  "WEB_CAMERA_PERMISSION_REQUIRED_TITLE": "Autorisation requise pour utiliser la caméra",
16
- "WEB_PLEASE_WAIT": "Veuillez patienter, la mesure va bientôt commencer…",
39
+ "WEB_CAMERA_START_ERROR": "Impossible de démarrer la caméra. Veuillez vous assurer que la caméra est connectée et qu’elle n’est pas utilisée par une autre application.",
17
40
  "WEB_MEASURE_INSTRUCTIONS_NO_FACE": "Veuillez centrer votre visage dans le cercle",
18
- "WARNING_CONSTRAINT_GAZE": "Veuillez regarder directement l'appareil photo",
19
- "WARNING_CONSTRAINT_DISTANCE": "Votre visage est trop éloigné. Essayez de vous rapprocher de la caméra",
20
- "PLEASE_HOLD_STILL": "Veuillez rester immobile",
21
- "WAITING_FOR_RESULTS": "Dans l’attente des résultats",
22
- "ERR_LOADING_CONFIGURATIONS": "Vous ne pouvez pas accéder à ce service en raison d'une erreur de chargement de la configuration. Veuillez contacter votre administrateur système pour obtenir de l'aide.",
23
- "ERR_MSG_SNR": "Le mesure du flux sanguin n'est pas fiable.\nVeuillez rester immobile et ajuster l'éclairage afin que la lumière soit uniformément répartie sur votre visage"
24
- }
41
+ "WEB_PLEASE_WAIT": "Veuillez patienter, la mesure va bientôt commencer…"
42
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "CAMERA_START_ERROR": "Impossibile avviare la fotocamera, assicurati che sia correttamente collegata e che non la stia utilizzando nessun'altra applicazione.",
3
+ "CENTER_YOUR_FACE": "Centra il viso",
4
+ "FACE_NOT_DETECTED": "Volto non rilevato",
5
+ "HELP_ACCESSORIES": "Prima della misurazione togliere tutti gli accessori come occhiali e cappelli, compresi i prodotti di make up dal viso.",
6
+ "HELP_CAMERA": "Posizionarsi davanti alla fotocamera con il viso all'interno del cerchio per tutta la durata della misurazione.",
7
+ "HELP_STAY": "Iniziata la misurazione, rimanere in posizione per 30 secondi fino al completamento della misurazione.",
8
+ "HELP_TITLE": "Guida",
9
+ "LOOK_DOWN": "Guarda in basso",
10
+ "LOOK_UP": "Guarda in alto",
11
+ "MEASURE_INSTRUCTION1": "Sei pregato di rimanere immobile",
12
+ "MEASURE_INSTRUCTION2": "Pronto per iniziare la misurazione",
13
+ "MEASURE_INSTRUCTIONS_NO_FACE": "Centra il tuo volto nel cerchio",
14
+ "MOVE_BACK": "Fai un passo indietro",
15
+ "MOVE_CLOSER": "Avvicinati",
16
+ "PLEASE_WAIT": "Per favore, aspetta, la misurazione inizierà presto…",
17
+ "SELECT_CAMERA": "Selezionare una fotocamera per iniziare",
18
+ "START_CAMERA": "Avviare Fotocamera",
19
+ "START_MEASUREMENT": "Inizia la misurazione",
20
+ "TILT_YOUR_FACE_LEFT": "Inclina il viso a sinistra",
21
+ "TILT_YOUR_FACE_RIGHT": "Inclina il viso a destra",
22
+ "TURN_LEFT": "Gira a sinistra",
23
+ "TURN_RIGHT": "Gira a destra",
24
+ "WAITING_FOR_RESULTS": "In attesa dei risultati",
25
+ "WARNING_CONSTRAINT_DISTANCE": "Il tuo volto è troppo lontano\nPer favore avvicinati alla fotocamera",
26
+ "WARNING_CONSTRAINT_GAZE": "Per favore guarda direttamente in camera",
27
+ "WARNING_FACE_NOT_DETECTED": "Volto non rilevato. Centra il tuo volto nell'inquadratura prima di iniziare."
28
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "CAMERA_START_ERROR": "カメラを起動できません。カメラが接続されており、別のアプリケーションによって使用中でないことを確認してください。",
3
+ "CENTER_YOUR_FACE": "顔を中央に合わせてください",
4
+ "FACE_NOT_DETECTED": "顔が検出されません",
5
+ "HELP_ACCESSORIES": "メガネや帽子などのアクセサリを外し、お顔の化粧を落としてから測定してください。",
6
+ "HELP_CAMERA": "カメラに顔を向け、測定中は顔が円の中に収まるように位置を合わせてください。",
7
+ "HELP_STAY": "測定が開始したら、測定が完了するまで30秒間は動かないでください。",
8
+ "HELP_TITLE": "ヘルプ",
9
+ "LOOK_DOWN": "下を見てください",
10
+ "LOOK_UP": "上を見てください",
11
+ "MEASURE_INSTRUCTION1": "身体を動かさないでください",
12
+ "MEASURE_INSTRUCTION2": "測定準備完了",
13
+ "MEASURE_INSTRUCTIONS_NO_FACE": "顔の位置を円の中心に合わせてください",
14
+ "MOVE_BACK": "後ろに下がってください",
15
+ "MOVE_CLOSER": "もう少し近づいてください",
16
+ "PLEASE_WAIT": "お待ちください、測定がまもなく開始されます…",
17
+ "SELECT_CAMERA": "カメラを選択して開始",
18
+ "START_CAMERA": "カメラを起動",
19
+ "START_MEASUREMENT": "測定を開始する",
20
+ "TILT_YOUR_FACE_LEFT": "顔を左に傾けてください",
21
+ "TILT_YOUR_FACE_RIGHT": "顔を右に傾けてください",
22
+ "TURN_LEFT": "左を向いてください",
23
+ "TURN_RIGHT": "右を向いてください",
24
+ "WAITING_FOR_RESULTS": "結果が出るまで待機しています",
25
+ "WARNING_CONSTRAINT_DISTANCE": "顔が離れすぎています\nカメラにもっと近付いてみてください",
26
+ "WARNING_CONSTRAINT_GAZE": "カメラの方を真っ直ぐ見てください",
27
+ "WARNING_FACE_NOT_DETECTED": "顔が検出されません。開始前にフレーム内で顔を中央に配置してください。"
28
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "CAMERA_START_ERROR": "Não é possível iniciar a câmara, certifique-se de que a câmara está ligada e não está a ser utilizada por outra aplicação.",
3
+ "CENTER_YOUR_FACE": "Centre o seu rosto",
4
+ "FACE_NOT_DETECTED": "Rosto não detectado",
5
+ "HELP_ACCESSORIES": "Remova todos os acessórios, tais como óculos e chapéus, incluindo todos os produtos de maquilhagem do seu rosto, antes de medir.",
6
+ "HELP_CAMERA": "Olhe para a câmara e posicione o seu rosto dentro do círculo durante a medição.",
7
+ "HELP_STAY": "Assim que a medição começar, mantenha a sua posição durante 30 segundos até que a medição seja concluída.",
8
+ "HELP_TITLE": "Ajuda",
9
+ "LOOK_DOWN": "Olhe para baixo",
10
+ "LOOK_UP": "Olhe para cima",
11
+ "MEASURE_INSTRUCTION1": "Não se mexa",
12
+ "MEASURE_INSTRUCTION2": "Pronto para realizar a medição",
13
+ "MEASURE_INSTRUCTIONS_NO_FACE": "Centre a sua cara no círculo",
14
+ "MOVE_BACK": "Afaste-se",
15
+ "MOVE_CLOSER": "Aproxime-se",
16
+ "PLEASE_WAIT": "Por favor, espere, a medição começará em breve…",
17
+ "SELECT_CAMERA": "Selecionar câmara para começar",
18
+ "START_CAMERA": "Iniciar câmara",
19
+ "START_MEASUREMENT": "Iniciar medição",
20
+ "TILT_YOUR_FACE_LEFT": "Incline o rosto para a esquerda",
21
+ "TILT_YOUR_FACE_RIGHT": "Incline o rosto para a direita",
22
+ "TURN_LEFT": "Vire à esquerda",
23
+ "TURN_RIGHT": "Vire à direita",
24
+ "WAITING_FOR_RESULTS": "À espera de resultados",
25
+ "WARNING_CONSTRAINT_DISTANCE": "O seu rosto está demasiado longe\nTente aproximar-se da câmara",
26
+ "WARNING_CONSTRAINT_GAZE": "Olhe diretamente para a câmara",
27
+ "WARNING_FACE_NOT_DETECTED": "Rosto não detectado. Centre o seu rosto na moldura antes de começar."
28
+ }
package/dist/stylex.css CHANGED
@@ -1,4 +1,12 @@
1
1
  @layer priority1 {
2
+ .border-x7vd2ds {
3
+ border: 1px solid #dee2e6;
4
+ }
5
+
6
+ .border-x1gs6z28 {
7
+ border: none;
8
+ }
9
+
2
10
  .margin-x1rz42sk {
3
11
  margin: .5rem auto;
4
12
  }
@@ -18,9 +26,25 @@
18
26
  .padding-x7gbtqy {
19
27
  padding: .5rem;
20
28
  }
29
+
30
+ .padding-xc7ga6q {
31
+ padding: 12px;
32
+ }
33
+
34
+ .padding-x1qhigcl {
35
+ padding: 20px;
36
+ }
37
+
38
+ .padding-x1ff1495 {
39
+ padding: 8px 16px;
40
+ }
21
41
  }
22
42
 
23
43
  @layer priority2 {
44
+ .borderRadius-x12oqio5 {
45
+ border-radius: 4px;
46
+ }
47
+
24
48
  .gap-x13z6uf9 {
25
49
  gap: .5rem;
26
50
  }
@@ -29,6 +53,10 @@
29
53
  margin-inline: auto;
30
54
  }
31
55
 
56
+ .overflow-xysyzu8 {
57
+ overflow: auto;
58
+ }
59
+
32
60
  .overflow-xb3r6kr {
33
61
  overflow: hidden;
34
62
  }
@@ -39,6 +67,14 @@
39
67
  align-items: center;
40
68
  }
41
69
 
70
+ .backgroundColor-x1lh7yn1 {
71
+ background-color: #007bff;
72
+ }
73
+
74
+ .backgroundColor-xmiktxe {
75
+ background-color: #f8f9fa;
76
+ }
77
+
42
78
  .backgroundColor-x12peec7 {
43
79
  background-color: #fff;
44
80
  }
@@ -47,10 +83,26 @@
47
83
  box-sizing: border-box;
48
84
  }
49
85
 
86
+ .color-x36lisw {
87
+ color: #6c757d;
88
+ }
89
+
90
+ .color-x10bj97 {
91
+ color: #dc3545;
92
+ }
93
+
94
+ .color-x1awj2ng {
95
+ color: #fff;
96
+ }
97
+
50
98
  .containerType-xpqogu8 {
51
99
  container-type: size;
52
100
  }
53
101
 
102
+ .cursor-x1ypdohk {
103
+ cursor: pointer;
104
+ }
105
+
54
106
  .display-x78zum5 {
55
107
  display: flex;
56
108
  }
@@ -63,12 +115,28 @@
63
115
  flex-grow: 1;
64
116
  }
65
117
 
118
+ .fontFamily-x6n8kwa {
119
+ font-family: system-ui, -apple-system, sans-serif;
120
+ }
121
+
122
+ .fontSize-xfifm61 {
123
+ font-size: 12px;
124
+ }
125
+
126
+ .fontSize-xif65rj {
127
+ font-size: 14px;
128
+ }
129
+
66
130
  .justifyContent-xl56j7k {
67
131
  justify-content: center;
68
132
  }
69
133
 
70
- .justifyContent-x1qughib {
71
- justify-content: space-between;
134
+ .justifyContent-x1nhvcw1 {
135
+ justify-content: flex-start;
136
+ }
137
+
138
+ .position-x10l6tqk {
139
+ position: absolute;
72
140
  }
73
141
 
74
142
  .position-x1n2onr6 {
@@ -79,6 +147,14 @@
79
147
  text-align: center;
80
148
  }
81
149
 
150
+ .textAlign-xdpxx8g {
151
+ text-align: left;
152
+ }
153
+
154
+ .transform-xuuh30 {
155
+ transform: translateX(-50%);
156
+ }
157
+
82
158
  .visibility-xlshs6z {
83
159
  visibility: hidden;
84
160
  }
@@ -89,14 +165,46 @@
89
165
  height: 100%;
90
166
  }
91
167
 
168
+ .left-x1nrll8i {
169
+ left: 50%;
170
+ }
171
+
172
+ .marginBottom-x1yztbdb {
173
+ margin-bottom: 16px;
174
+ }
175
+
176
+ .marginBottom-x1hq5gj4 {
177
+ margin-bottom: 24px;
178
+ }
179
+
180
+ .marginBottom-x1e56ztr {
181
+ margin-bottom: 8px;
182
+ }
183
+
92
184
  .marginTop-x1mjqqkp {
93
185
  margin-top: .5rem;
94
186
  }
95
187
 
188
+ .marginTop-xqui205 {
189
+ margin-top: 24px;
190
+ }
191
+
96
192
  .marginTop-x1hpjnmm {
97
193
  margin-top: 3rem;
98
194
  }
99
195
 
196
+ .maxWidth-x1j9u4d2 {
197
+ max-width: 400px;
198
+ }
199
+
200
+ .maxWidth-xrlsmeg {
201
+ max-width: 600px;
202
+ }
203
+
204
+ .minHeight-xg6iff7 {
205
+ min-height: 100vh;
206
+ }
207
+
100
208
  .minHeight-xe8gcm {
101
209
  min-height: 3rem;
102
210
  }
package/lib/index.d.ts CHANGED
@@ -826,14 +826,20 @@ declare const DFX_POINTS: {
826
826
  };
827
827
  type DfxPointId = keyof typeof DFX_POINTS;
828
828
  interface Demographics {
829
+ /** age: 13-120 years */
829
830
  age: number;
831
+ /** height: 120-220 cm */
830
832
  height: number;
833
+ /** weight: 30-300 kg */
831
834
  weight: number;
835
+ /** sex: 0 (not provided), 2 (male), 3 (female) */
832
836
  sex: number;
837
+ /** smoking: 1 (non-smoker), 0 (smoker) */
833
838
  smoking: number;
839
+ /** bloodPressureMedication: 0 (not on medication), 1 (on medication) */
834
840
  bloodPressureMedication: number;
841
+ /** diabetes: 4 (none), 5 (type 1), 6 (type 2) */
835
842
  diabetes: number;
836
- unit: 'Metric' | 'Imperial';
837
843
  }
838
844
  interface ResultsError {
839
845
  code: RealtimeResultErrors | 'OK';
@@ -843,6 +849,18 @@ interface ResultsError {
843
849
  };
844
850
  };
845
851
  }
852
+ /**
853
+ * "metadata" |
854
+ * "physical" |
855
+ * "generalRisks" |
856
+ * "vitals" |
857
+ * "physiological" |
858
+ * "metabolicRisks" |
859
+ * "bloodBiomarkers" |
860
+ * "overall" |
861
+ * "mental" |
862
+ * "surveys"
863
+ */
846
864
  type PointGroupType = typeof pointGroup[keyof typeof pointGroup];
847
865
  type BandColors = ('YELLOW' | 'LIGHT_GREEN' | 'GREEN' | 'LIGHT_RED' | 'RED')[];
848
866
  interface IMeta {
@@ -899,26 +917,60 @@ interface Results {
899
917
  declare const measurementEmbeddedAppEvents: {
900
918
  readonly RESULTS: "results";
901
919
  readonly ERROR: "error";
902
- readonly WEBHOOK: "webhook";
903
- readonly CANCEL: "cancel";
920
+ readonly APPEVENT: "appEvent";
921
+ readonly CANCELLED: "cancelled";
922
+ readonly LOGS: "logs";
904
923
  };
905
924
  interface AppSettings {
906
925
  token: string;
907
926
  refreshToken: string;
908
927
  studyId: string;
909
928
  }
929
+ type SupportedLanguage = 'en' | 'ja' | 'cn' | 'es' | 'pt' | 'it' | 'fr' | 'de' | 'br';
930
+ interface Config {
931
+ checkConstraints?: boolean;
932
+ cameraFacingMode?: 'user' | 'environment';
933
+ cameraAutoStart?: boolean;
934
+ measurementAutoStart?: boolean;
935
+ }
936
+ interface Profile extends Demographics {
937
+ bypassProfile: boolean;
938
+ }
910
939
  interface MeasurementEmbeddedAppOptions {
911
940
  container: HTMLDivElement;
912
941
  top?: string;
913
942
  appPath: string;
914
943
  settings: AppSettings;
915
- profile?: Demographics;
944
+ profile: Profile;
945
+ language?: SupportedLanguage;
946
+ config?: Config;
947
+ apiUrl?: string;
916
948
  loadError?: (error: string) => void;
917
949
  }
950
+ declare enum logCategory {
951
+ measurement = "Measurement",
952
+ collector = "Collector",
953
+ camera = "Camera",
954
+ app = "App"
955
+ }
956
+ interface Log {
957
+ timestamp: string;
958
+ category: logCategory;
959
+ message: string;
960
+ meta?: any;
961
+ }
918
962
  interface MeasurementEmbedded {
919
963
  init(options: MeasurementEmbeddedAppOptions): void;
920
964
  destroy(): void;
965
+ /**
966
+ * Cancel the measurement
967
+ * @param {boolean} reset - whether to reset the Web SDK or just close the camera and hide the mask
968
+ * @returns {Promise<boolean>} - whether the cancellation was successful
969
+ */
970
+ cancel(reset: boolean): Promise<boolean>;
971
+ getLogs: () => Promise<Log[]>;
921
972
  setTheme(theme: 'light' | 'dark'): void;
973
+ setLanguage(language: SupportedLanguage): void;
922
974
  on: {
923
975
  /**
924
976
  * when measurement results are received
@@ -931,34 +983,96 @@ interface MeasurementEmbedded {
931
983
  */
932
984
  error: ((error: MeasurementEmbeddedAppError) => void) | null;
933
985
  /**
934
- * when webhook event is received
935
- * @param {webhook} WebhookEvent - webhook event
936
- */
937
- webhook: ((webhook: WebhookEvent) => void) | null;
938
- /**
939
- * when measurement is cancelled
986
+ * when an AppEvent is received
987
+ * @param {appEvent} AppEvent - app event
940
988
  */
941
- cancel: (() => void) | null;
989
+ event: ((appEvent: AppEvent) => void) | null;
942
990
  };
943
991
  }
944
992
  interface MeasurementEmbeddedAppError {
945
- error: keyof typeof measurementError;
993
+ code: ErrorCodes;
994
+ message: string;
946
995
  }
947
- declare const webhookEventSeverity: {
996
+ declare const appEventSeverity: {
948
997
  readonly INFO: "INFO";
949
998
  readonly WARN: "WARN";
950
999
  readonly ERROR: "ERROR";
951
1000
  };
952
- declare const webhookEvent: {
1001
+ declare const appEvent: {
953
1002
  readonly CAMERA_STARTED: "CAMERA_STARTED";
1003
+ readonly APP_LOADED: "APP_LOADED";
1004
+ readonly MEASUREMENT_STARTED: "MEASUREMENT_STARTED";
1005
+ readonly MEASUREMENT_COMPLETED: "MEASUREMENT_COMPLETED";
1006
+ readonly CAMERA_PERMISSION_GRANTED: "CAMERA_PERMISSION_GRANTED";
1007
+ readonly INTERMEDIATE_RESULTS: "INTERMEDIATE_RESULTS";
1008
+ readonly RESULTS_RECEIVED: "RESULTS_RECEIVED";
1009
+ readonly MEASUREMENT_CANCELED: "MEASUREMENT_CANCELED";
1010
+ readonly CONSTRAINT_VIOLATION: "CONSTRAINT_VIOLATION";
1011
+ readonly PAGE_UNLOADED: "PAGE_UNLOADED";
1012
+ readonly PAGE_VISIBILITY_CHANGE: "PAGE_VISIBILITY_CHANGE";
954
1013
  };
955
- interface WebhookEvent {
956
- event: keyof typeof webhookEvent;
957
- level: keyof typeof webhookEventSeverity;
958
- }
959
- declare const measurementError: {
960
- readonly WORKER_ERROR: "WORKER_ERROR";
1014
+ declare const appEvents: {
1015
+ readonly CAMERA_STARTED: {
1016
+ readonly event: "CAMERA_STARTED";
1017
+ readonly level: "INFO";
1018
+ };
1019
+ readonly APP_LOADED: {
1020
+ readonly event: "APP_LOADED";
1021
+ readonly level: "INFO";
1022
+ };
1023
+ readonly MEASUREMENT_STARTED: {
1024
+ readonly event: "MEASUREMENT_STARTED";
1025
+ readonly level: "INFO";
1026
+ };
1027
+ readonly MEASUREMENT_COMPLETED: {
1028
+ readonly event: "MEASUREMENT_COMPLETED";
1029
+ readonly level: "INFO";
1030
+ };
1031
+ readonly CAMERA_PERMISSION_GRANTED: {
1032
+ readonly event: "CAMERA_PERMISSION_GRANTED";
1033
+ readonly level: "INFO";
1034
+ };
1035
+ readonly INTERMEDIATE_RESULTS: {
1036
+ readonly event: "INTERMEDIATE_RESULTS";
1037
+ readonly level: "INFO";
1038
+ };
1039
+ readonly RESULTS_RECEIVED: {
1040
+ readonly event: "RESULTS_RECEIVED";
1041
+ readonly level: "INFO";
1042
+ };
1043
+ readonly MEASUREMENT_CANCELED: {
1044
+ readonly event: "MEASUREMENT_CANCELED";
1045
+ readonly level: "WARN";
1046
+ };
1047
+ readonly CONSTRAINT_VIOLATION: {
1048
+ readonly event: "CONSTRAINT_VIOLATION";
1049
+ readonly level: "ERROR";
1050
+ };
1051
+ readonly PAGE_UNLOADED: {
1052
+ readonly event: "PAGE_UNLOADED";
1053
+ readonly level: "INFO";
1054
+ };
1055
+ readonly PAGE_VISIBILITY_CHANGE: {
1056
+ readonly event: "PAGE_VISIBILITY_CHANGE";
1057
+ readonly level: "INFO";
1058
+ };
961
1059
  };
1060
+ interface AppEvent {
1061
+ event: keyof typeof appEvent;
1062
+ level: keyof typeof appEventSeverity;
1063
+ }
1064
+ declare enum ErrorCodes {
1065
+ CAMERA_PERMISSION_DENIED = "CAMERA_PERMISSION_DENIED",
1066
+ WORKER_ERROR = "WORKER_ERROR",
1067
+ PROFILE_INFO_NOT_SET = "PROFILE_INFO_NOT_SET",
1068
+ NO_DEVICES_FOUND = "NO_DEVICES_FOUND",
1069
+ PAGE_NOT_VISIBLE = "PAGE_NOT_VISIBLE",
1070
+ CAMERA_START_FAILED = "CAMERA_START_FAILED",
1071
+ MEASUREMENT_LOW_SNR = "MEASUREMENT_LOW_SNR",
1072
+ COLLECTOR = "COLLECTOR",
1073
+ WEBSOCKET_DISCONNECTED = "WEBSOCKET_DISCONNECTED"
1074
+ }
1075
+ type MeasurementErrorCodes = ErrorCodes.WORKER_ERROR | ErrorCodes.PROFILE_INFO_NOT_SET;
962
1076
 
963
1077
  declare class MeasurementEmbeddedApp implements MeasurementEmbedded {
964
1078
  #private;
@@ -969,25 +1083,24 @@ declare class MeasurementEmbeddedApp implements MeasurementEmbedded {
969
1083
  */
970
1084
  results: ((results: Results) => void) | null;
971
1085
  /**
972
- * when measurement results are received
973
- * @param {results} Results - measurement results
1086
+ * when there is an error in the measurement embedded app
1087
+ * @param {error} MeasurementEmbeddedAppError - measurement embedded app error
974
1088
  */
975
1089
  error: ((error: MeasurementEmbeddedAppError) => void) | null;
976
1090
  /**
977
- * when webhook event is received
978
- * @param {webhook} WebhookEvent - webhook event
979
- */
980
- webhook: ((webhook: WebhookEvent) => void) | null;
981
- /**
982
- * when measurement is cancelled
1091
+ * when an appEvent is received
1092
+ * @param {appEvent} AppEvent - appEvent
983
1093
  */
984
- cancel: (() => void) | null;
1094
+ event: ((appEvent: AppEvent) => void) | null;
985
1095
  };
986
1096
  constructor();
987
1097
  init(options: MeasurementEmbeddedAppOptions): void;
988
1098
  destroy(): void;
989
1099
  setTheme(theme: 'light' | 'dark'): void;
1100
+ setLanguage(language: SupportedLanguage): void;
1101
+ cancel(reset: boolean): Promise<boolean>;
1102
+ getLogs(): Promise<Log[]>;
990
1103
  }
991
1104
 
992
- export { MeasurementEmbeddedApp as default, faceAttributeValue, measurementEmbeddedAppEvents };
993
- export type { AppSettings, Demographics, DfxPointId, MeasurementEmbeddedAppOptions, Results };
1105
+ export { ErrorCodes, appEvents, MeasurementEmbeddedApp as default, faceAttributeValue, measurementEmbeddedAppEvents };
1106
+ export type { AppSettings, DfxPointId, MeasurementEmbeddedAppError, MeasurementEmbeddedAppOptions, MeasurementErrorCodes, Point, Profile, Results };
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),M=(s,e,n,l)=>(_(s,e,"write to private field"),e.set(s,n),n),i,d,c,a;const A=class o{constructor(e){m(this,a),M(this,a,new Int32Array(e))}lock(){for(;;){if(Atomics.compareExchange(t(this,a),t(o,c),t(o,d),t(o,i))==t(o,d))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,d))!=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 l(){for(;;){if(Atomics.compareExchange(t(n,a),t(o,c),t(o,d),t(o,i))==t(o,d)){e(),n.unlock();return}await Atomics.waitAsync(t(n,a),t(o,c),t(o,i)).value}}l()}};i=new WeakMap,d=new WeakMap,c=new WeakMap,a=new WeakMap,m(A,i,1),m(A,d,0),m(A,c,0);const I={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},$=document.documentElement.style.overflow;class N{#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:l,settings:S,profile:T,loadError:u,top:y=0}=e;this.#t=n,Object.assign(n.style,{position:"fixed",top:y,left:"0",width:"100vw",height:`calc(100vh - ${y})`}),document.body.appendChild(n);const p=n.attachShadow({mode:"open"});document.documentElement.style.overflow="hidden";const f="app",v=document.createElement("link");v.rel="stylesheet",v.href=`${l}/stylex.css`,p.appendChild(v);const w=document.createElement("link");w.rel="stylesheet",w.href=`${l}/${f}.css`,p.appendChild(w);const k=r=>{this.on.results&&this.on.results({...r.detail})},C=r=>{this.on.error&&this.on.error({...r.detail})},L=r=>{this.on.webhook&&this.on.webhook({...r.detail})},D=()=>{this.on.cancel&&this.on.cancel()};this.#e.addEventListener(h.RESULTS,k),this.#e.addEventListener(h.ERROR,C),this.#e.addEventListener(h.WEBHOOK,L),this.#e.addEventListener(h.CANCEL,D),p.appendChild(this.#e);const E=document.createElement("script");E.type="module",E.src=`${l}/${f}.mjs`,E.onload=()=>{import(E.src).then(r=>{r.app.init(this.#e,S,T)}).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=$,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{N as default,I as faceAttributeValue,h as measurementEmbeddedAppEvents};
1
+ const r={RESULTS:"results",ERROR:"error",APPEVENT:"appEvent",CANCELLED:"cancelled",LOGS:"logs"};var f=(e=>(e.measurement="Measurement",e.collector="Collector",e.camera="Camera",e.app="App",e))(f||{});const o={INFO:"INFO",WARN:"WARN",ERROR:"ERROR"},i={CAMERA_STARTED:"CAMERA_STARTED",APP_LOADED:"APP_LOADED",MEASUREMENT_STARTED:"MEASUREMENT_STARTED",MEASUREMENT_COMPLETED:"MEASUREMENT_COMPLETED",CAMERA_PERMISSION_GRANTED:"CAMERA_PERMISSION_GRANTED",INTERMEDIATE_RESULTS:"INTERMEDIATE_RESULTS",RESULTS_RECEIVED:"RESULTS_RECEIVED",MEASUREMENT_CANCELED:"MEASUREMENT_CANCELED",CONSTRAINT_VIOLATION:"CONSTRAINT_VIOLATION",PAGE_UNLOADED:"PAGE_UNLOADED",PAGE_VISIBILITY_CHANGE:"PAGE_VISIBILITY_CHANGE"},g={CAMERA_STARTED:{event:i.CAMERA_STARTED,level:o.INFO},APP_LOADED:{event:i.APP_LOADED,level:o.INFO},MEASUREMENT_STARTED:{event:i.MEASUREMENT_STARTED,level:o.INFO},MEASUREMENT_COMPLETED:{event:i.MEASUREMENT_COMPLETED,level:o.INFO},CAMERA_PERMISSION_GRANTED:{event:i.CAMERA_PERMISSION_GRANTED,level:o.INFO},INTERMEDIATE_RESULTS:{event:i.INTERMEDIATE_RESULTS,level:o.INFO},RESULTS_RECEIVED:{event:i.RESULTS_RECEIVED,level:o.INFO},MEASUREMENT_CANCELED:{event:i.MEASUREMENT_CANCELED,level:o.WARN},CONSTRAINT_VIOLATION:{event:i.CONSTRAINT_VIOLATION,level:o.ERROR},PAGE_UNLOADED:{event:i.PAGE_UNLOADED,level:o.INFO},PAGE_VISIBILITY_CHANGE:{event:i.PAGE_VISIBILITY_CHANGE,level:o.INFO}},_={DESTROY:"destroy",CANCEL:"cancel",SET_THEME:"setTheme",SET_LANGUAGE:"setLanguage",GET_LOGS:"getLogs"};var v=(e=>(e.CAMERA_PERMISSION_DENIED="CAMERA_PERMISSION_DENIED",e.WORKER_ERROR="WORKER_ERROR",e.PROFILE_INFO_NOT_SET="PROFILE_INFO_NOT_SET",e.NO_DEVICES_FOUND="NO_DEVICES_FOUND",e.PAGE_NOT_VISIBLE="PAGE_NOT_VISIBLE",e.CAMERA_START_FAILED="CAMERA_START_FAILED",e.MEASUREMENT_LOW_SNR="MEASUREMENT_LOW_SNR",e.COLLECTOR="COLLECTOR",e.WEBSOCKET_DISCONNECTED="WEBSOCKET_DISCONNECTED",e))(v||{}),M=e=>{throw TypeError(e)},u=(e,t,E)=>t.has(e)||M("Cannot "+E),n=(e,t,E)=>(u(e,t,"read from private field"),E?E.call(e):t.get(e)),L=(e,t,E)=>t.has(e)?M("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,E),F=(e,t,E,s)=>(u(e,t,"write to private field"),t.set(e,E),E),l,T,d,A;const h=class a{constructor(t){L(this,A),F(this,A,new Int32Array(t))}lock(){for(;;){if(Atomics.compareExchange(n(this,A),n(a,d),n(a,T),n(a,l))==n(a,T))return;Atomics.wait(n(this,A),n(a,d),n(a,l))}}unlock(){if(Atomics.compareExchange(n(this,A),n(a,d),n(a,l),n(a,T))!=n(a,l))throw new Error("Tried to unlock while not holding the mutex");Atomics.notify(n(this,A),n(a,d))}AsyncLock(t){const E=this;async function s(){for(;;){if(Atomics.compareExchange(n(E,A),n(a,d),n(a,T),n(a,l))==n(a,T)){t(),E.unlock();return}await Atomics.waitAsync(n(E,A),n(a,d),n(a,l)).value}}s()}};l=new WeakMap,T=new WeakMap,d=new WeakMap,A=new WeakMap,L(h,l,1),L(h,T,0),L(h,d,0);const B={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},k=document.documentElement.style.overflow;class W{#e=document.createElement("div");#t=document.createElement("div");on={results:null,error:null,event:null};constructor(){this.#e.style.height="100%"}init(t){const{container:E,appPath:s,settings:R,profile:N,config:P,loadError:I,top:D=0,language:U,apiUrl:G="api.deepaffex.ai"}=t;this.#t=E,Object.assign(E.style,{position:"fixed",top:D,left:"0",width:"100vw",height:`calc(100vh - ${D})`}),document.body.appendChild(E);const O=E.attachShadow({mode:"open"});document.documentElement.style.overflow="hidden";const m="app",p=document.createElement("link");p.rel="stylesheet",p.href=`${s}/stylex.css`,O.appendChild(p);const C=document.createElement("link");C.rel="stylesheet",C.href=`${s}/${m}.css`,O.appendChild(C);const w=c=>{this.on.results&&this.on.results({...c.detail})},V=c=>{this.on.error&&this.on.error({...c.detail})},y=c=>{this.on.event&&this.on.event({...c.detail})};this.#e.addEventListener(r.RESULTS,w),this.#e.addEventListener(r.ERROR,V),this.#e.addEventListener(r.APPEVENT,y),O.appendChild(this.#e);const S=document.createElement("script");S.type="module",S.src=`${s}/${m}.mjs`,S.onload=()=>{import(S.src).then(c=>{c.app.init(this.#e,s,R,N,G,P,U)}).catch(()=>{I&&I("Failed to initialize Measurement Embedded React app")})},S.onerror=()=>{I&&I("Failed to load the measurement embedded app script")},O.appendChild(S)}destroy(){const t=new CustomEvent("measurement-embedded-app-action",{detail:{action:_.DESTROY,data:{}}});this.#e.dispatchEvent(t),document.documentElement.style.overflow=k,this.#t&&document.body.contains(this.#t)&&document.body.removeChild(this.#t)}setTheme(t){const E=new CustomEvent("measurement-embedded-app-action",{detail:{action:_.SET_THEME,data:{theme:t}}});this.#e.dispatchEvent(E)}setLanguage(t){const E=new CustomEvent("measurement-embedded-app-action",{detail:{action:_.SET_LANGUAGE,data:{language:t}}});this.#e.dispatchEvent(E)}async cancel(t){return new Promise(E=>{const s=N=>{this.#e.removeEventListener(r.CANCELLED,s),E(N.detail.reset)};this.#e.addEventListener(r.CANCELLED,s);const R=new CustomEvent("measurement-embedded-app-action",{detail:{action:_.CANCEL,data:{reset:t}}});this.#e.dispatchEvent(R)})}getLogs(){return new Promise(t=>{const E=R=>{this.#e.removeEventListener(r.LOGS,E),t(R.detail.logs)};this.#e.addEventListener(r.LOGS,E);const s=new CustomEvent("measurement-embedded-app-action",{detail:{action:_.GET_LOGS,data:{}}});this.#e.dispatchEvent(s)})}}export{v as ErrorCodes,g as appEvents,W as default,B as faceAttributeValue,r as measurementEmbeddedAppEvents};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuralogix.ai/web-measurement-embedded-app",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0-alpha.11",
4
4
  "description": "Web Measurement Embedded App",
5
5
  "contributors": [
6
6
  "Hamed Hassanzadeh Amin",