@nuralogix.ai/web-measurement-embedded-app 0.1.0-beta.3 → 0.1.0-beta.5

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;
@@ -185,4 +188,3 @@ measurementApp.setLanguage('es');
185
188
  | `COLLECTOR` | Frame collection reported an error |
186
189
  | `WEBSOCKET_DISCONNECTED` | Realtime WebSocket connection closed or dropped. |
187
190
  | `MEASUREMENT_PREPARE_FAILED` | Measurement preparation failed - invalid or missing credentials |
188
-