@nuralogix.ai/web-measurement-embedded-app 0.1.0-beta.2 → 0.1.0-beta.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/README.md CHANGED
@@ -29,23 +29,37 @@ Need deeper integration details? Check the full docs at [docs.deepaffex.ai/wmea]
29
29
  <body>
30
30
  <div id="measurement-embedded-app-container"></div>
31
31
  <script type="module">
32
- import MeasurementEmbeddedApp, { faceAttributeValue } from '@nuralogix.ai/web-measurement-embedded-app';
32
+ import MeasurementEmbeddedApp, {
33
+ faceAttributeValue,
34
+ } from '@nuralogix.ai/web-measurement-embedded-app';
33
35
  const {
34
36
  SEX_ASSIGNED_MALE_AT_BIRTH,
35
37
  SMOKER_FALSE,
36
38
  BLOOD_PRESSURE_MEDICATION_FALSE,
37
- DIABETES_NONE
39
+ DIABETES_NONE,
38
40
  } = faceAttributeValue;
39
41
  const measurementApp = new MeasurementEmbeddedApp();
40
42
  const container = document.getElementById('measurement-embedded-app-container');
41
43
  if (container) {
42
- const apiUrl = '/api';
43
- const studyId = await fetch(`${apiUrl}/studyId`);
44
- const studyIdResponse = await studyId.json();
45
- const token = await fetch(`${apiUrl}/token`);
46
- const tokenResponse = await token.json();
47
- if (studyIdResponse.status === '200' && tokenResponse.status === '200') {
48
- measurementApp.init({
44
+ const apiUrl = '/api';
45
+ const studyId = await fetch(`${apiUrl}/studyId`);
46
+ const studyIdResponse = await studyId.json();
47
+ const token = await fetch(`${apiUrl}/token`);
48
+ const tokenResponse = await token.json();
49
+ if (studyIdResponse.status === '200' && tokenResponse.status === '200') {
50
+ measurementApp.on.results = (results) => {
51
+ console.log('Results received', results);
52
+ measurementApp.destroy();
53
+ };
54
+ measurementApp.on.error = (error) => {
55
+ console.log('error received', error);
56
+ };
57
+ measurementApp.on.event = (appEvent) => {
58
+ console.log('App Event received', appEvent);
59
+ };
60
+
61
+ try {
62
+ await measurementApp.init({
49
63
  container,
50
64
  appPath: 'https://unpkg.com/@nuralogix.ai/web-measurement-embedded-app/dist',
51
65
  settings: {
@@ -70,27 +84,17 @@ Need deeper integration details? Check the full docs at [docs.deepaffex.ai/wmea]
70
84
  cameraAutoStart: false,
71
85
  measurementAutoStart: false,
72
86
  cancelWhenLowSNR: true,
73
- }
87
+ },
74
88
  // Optional language/api overrides
75
89
  // language: 'fr'
76
90
  apiUrl: 'api.na-east.deepaffex.ai', // optional for region specific data processing
77
- loadError: function(error) {
78
- console.error("load error", error);
79
- }
80
91
  });
81
- measurementApp.on.results = (results) => {
82
- console.log("Results received", results);
83
- measurementApp.destroy();
84
- };
85
- measurementApp.on.error = (error) => {
86
- console.log("error received", error);
87
- };
88
- measurementApp.on.event = (appEvent) => {
89
- console.log("App Event received", appEvent);
90
- };
91
- } else {
92
- console.error('Failed to get Study ID and Token pair');
92
+ } catch (error) {
93
+ console.error('Failed to initialize:', error);
93
94
  }
95
+ } else {
96
+ console.error('Failed to get Study ID and Token pair');
97
+ }
94
98
  }
95
99
  </script>
96
100
  </body>
@@ -111,13 +115,12 @@ Need deeper integration details? Check the full docs at [docs.deepaffex.ai/wmea]
111
115
  - `cancelWhenLowSNR` (default: `true`) – cancels the measurement if signal-to-noise ratio falls below threshold.
112
116
  - Language support: `en`, `ja`, `zh`, `es`, `pt`, `pt-BR`, `it`, `fr`, `de`.
113
117
  - Unsupported browser locales fall back to base language (e.g., `zh-TW` → `zh`), then to English.
114
- - `loadError` is called if assets fail to download or the app cannot initialize.
115
118
 
116
119
  **Methods:**
117
120
 
118
121
  ```typescript
119
- init(options: MeasurementEmbeddedAppOptions): void;
120
- destroy(): void;
122
+ init(options: MeasurementEmbeddedAppOptions): Promise<void>;
123
+ destroy(): Promise<void>;
121
124
  cancel(reset: boolean): Promise<boolean>;
122
125
  setTheme(theme: 'light' | 'dark'): void;
123
126
  setLanguage(language: SupportedLanguage): void;
@@ -149,6 +152,8 @@ event: ((appEvent: AppEvent) => void) | null;
149
152
  **App events dispatched through `measurementApp.on.event`:**
150
153
 
151
154
  - `APP_LOADED` – the embedded app finished its startup sequence.
155
+ - `MEASUREMENT_PREPARED` - Measurement has been prepared
156
+ - `ASSETS_DOWNLOADED` - Assets have been downloaded
152
157
  - `CAMERA_PERMISSION_GRANTED` – the user granted camera access.
153
158
  - `CAMERA_STARTED` – a camera stream opened successfully.
154
159
  - `MEASUREMENT_STARTED` – a measurement run begins.
@@ -171,14 +176,15 @@ measurementApp.setLanguage('es');
171
176
 
172
177
  **Error codes emitted through `measurementApp.on.error`:**
173
178
 
174
- | Code | Meaning |
175
- | -------------------------- | ----------------------------------------------------------------- |
176
- | `CAMERA_PERMISSION_DENIED` | Camera access prompt was rejected. |
177
- | `CAMERA_START_FAILED` | Camera hardware failed to start after permission. |
178
- | `NO_DEVICES_FOUND` | No video input devices detected during enumeration. |
179
- | `PAGE_NOT_VISIBLE` | Measurement was running while the tab or window became hidden. |
180
- | `MEASUREMENT_LOW_SNR` | Signal-to-noise ratio dropped below the acceptable threshold. |
181
- | `WORKER_ERROR` | SDK worker encountered a fatal processing error. |
182
- | `PROFILE_INFO_NOT_SET` | Profile bypass stayed enabled, so demographics were not provided. |
183
- | `COLLECTOR` | Frame collection reported an error |
184
- | `WEBSOCKET_DISCONNECTED` | Realtime WebSocket connection closed or dropped. |
179
+ | Code | Meaning |
180
+ | ---------------------------- | ----------------------------------------------------------------- |
181
+ | `CAMERA_PERMISSION_DENIED` | Camera access prompt was rejected. |
182
+ | `CAMERA_START_FAILED` | Camera hardware failed to start after permission. |
183
+ | `NO_DEVICES_FOUND` | No video input devices detected during enumeration. |
184
+ | `PAGE_NOT_VISIBLE` | Measurement was running while the tab or window became hidden. |
185
+ | `MEASUREMENT_LOW_SNR` | Signal-to-noise ratio dropped below the acceptable threshold. |
186
+ | `WORKER_ERROR` | SDK worker encountered a fatal processing error. |
187
+ | `PROFILE_INFO_NOT_SET` | Profile bypass stayed enabled, so demographics were not provided. |
188
+ | `COLLECTOR` | Frame collection reported an error |
189
+ | `WEBSOCKET_DISCONNECTED` | Realtime WebSocket connection closed or dropped. |
190
+ | `MEASUREMENT_PREPARE_FAILED` | Measurement preparation failed - invalid or missing credentials |