npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@nuralogix.ai/web-measurement-embedded-app

v0.1.0-beta.16

Published

Web Measurement Embedded App

Readme

Web Measurement Embedded App

Need deeper integration details? Check the full docs at docs.deepaffex.ai/wmea.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Measurement Embedded App Demo</title>
    <style>
      #measurement-embedded-app-container {
        position: fixed;
        top: 100px;
        left: 0;
        width: 100vw;
        height: calc(100vh - 100px);
      }
    </style>
    <script type="importmap">
      {
        "imports": {
          "@nuralogix.ai/web-measurement-embedded-app": "https://unpkg.com/@nuralogix.ai/web-measurement-embedded-app"
        }
      }
    </script>
  </head>
  <body>
    <div id="measurement-embedded-app-container"></div>
    <script type="module">
      import MeasurementEmbeddedApp, {
        faceAttributeValue,
      } from '@nuralogix.ai/web-measurement-embedded-app';
      const {
        SEX_ASSIGNED_MALE_AT_BIRTH,
        SMOKER_FALSE,
        BLOOD_PRESSURE_MEDICATION_FALSE,
        DIABETES_NONE,
      } = faceAttributeValue;
      const measurementApp = new MeasurementEmbeddedApp();
      const container = document.getElementById('measurement-embedded-app-container');
      if (container) {
        const apiUrl = '/api';
        const studyId = await fetch(`${apiUrl}/studyId`);
        const studyIdResponse = await studyId.json();
        const token = await fetch(`${apiUrl}/token`);
        const tokenResponse = await token.json();
        if (studyIdResponse.status === '200' && tokenResponse.status === '200') {
          measurementApp.on.results = async (results) => {
            console.log('Results received', results);
            const isDestroyed = await measurementApp.destroy();
          };
          measurementApp.on.error = (error) => {
            console.log('error received', error);
          };
          measurementApp.on.event = (appEvent) => {
            console.log('App Event received', appEvent);
          };

          try {
            await measurementApp.init({
              container,
              appPath: 'https://unpkg.com/@nuralogix.ai/web-measurement-embedded-app/dist',
              settings: {
                token: tokenResponse.token,
                refreshToken: tokenResponse.refreshToken,
                studyId: studyIdResponse.studyId,
                // Optional measurement options
                // measurementOptions: {
                //   partnerId: 'your-partner-id',
                //   userProfileId: 'your-user-profile-id',
                // },
              },
              profile: {
                age: 40,
                heightCm: 180,
                weightKg: 60,
                sex: SEX_ASSIGNED_MALE_AT_BIRTH,
                smoking: SMOKER_FALSE,
                bloodPressureMedication: BLOOD_PRESSURE_MEDICATION_FALSE,
                diabetes: DIABETES_NONE,
                bypassProfile: false,
              },
              // Optional configuration overrides (defaults shown)
              config: {
                checkConstraints: true,
                cameraFacingMode: 'user', // or 'environment' for back camera
                cameraAutoStart: false,
                measurementAutoStart: false,
                cancelWhenLowSNR: true,
                debugMode: false,
                downloadPayloads: false,
              },
              // Optional language/api overrides
              // language: 'fr'
              apiUrl: 'api.na-east.deepaffex.ai', // optional for region specific data processing
            });
          } catch (error) {
            console.error('Failed to initialize:', error);
          }
        } else {
          console.error('Failed to get Study ID and Token pair');
        }
      }
    </script>
  </body>
</html>

Notes:

  • Set appPath to '.' when you bundle the assets yourself.
  • Profile handling: when bypassProfile remains true (default) we skip demographic submission and emit an ERROR event with PROFILE_INFO_NOT_SET; set it to false once you supply real profile data.
  • Style the container you pass to init (e.g., position, top, width).
  • Settings options:
    • token (required) – authentication token from DeepAffex API.
    • refreshToken (required) – refresh token for token renewal.
    • studyId (required) – study identifier for the measurement.
    • measurementOptions (optional) – additional options passed to the SDK when starting a measurement:
      • partnerId – partner identifier for tracking.
      • userProfileId – user profile identifier for tracking. Must be a valid UUID.
  • Optional apiUrl enables region-specific processing; omitted values follow the backend token's region automatically. When set explicitly, frontend calls your URL (processing where that endpoint runs) while results continue to store in the token's region—verify the combination suits your deployment.
  • Config options:
    • checkConstraints (default: true) – enables constraint validation pre-measurement
    • cameraFacingMode (default: 'user') – use 'user' for front camera or 'environment' for back camera.
    • cameraAutoStart (default: false) – automatically starts the camera once permission is granted.
    • measurementAutoStart (default: false) – automatically starts the measurement once constraints are satisfied.
    • cancelWhenLowSNR (default: true) – cancels the measurement if signal-to-noise ratio falls below threshold.
    • debugMode (default: false) – enables verbose logging to the console for debugging purposes.
    • downloadPayloads (default: false) – when enabled, saves payload and metadata binary files for each chunk sent to DeepAffex Cloud so you can send them to NuraLogix for debugging. A 30-second measurement emits 6 chunks (every 5 seconds), generating 2 files per chunk. Ensure your browser allows multiple file downloads and does not block popups.
  • Language support: en, ja, zh, es, pt, pt-BR, it, fr, de.
    • Unsupported browser locales fall back to base language (e.g., zh-TWzh), then to English.

Methods:

init(options: MeasurementEmbeddedAppOptions): Promise<void>;
destroy(): Promise<void>;
cancel(reset: boolean): Promise<boolean>;
setTheme(theme: 'light' | 'dark'): void;
setLanguage(language: SupportedLanguage): void;
getLogs(): Promise<Log[]>;

Events:

/**
 * when measurement results are received
 * @param {results} Results - measurement results
 */
results: ((results: Results) => void) | null;

/**
 * when there is an error in the measurement embedded app
 * @param {error} MeasurementEmbeddedAppError - measurement embedded app error
 */
error: ((error: MeasurementEmbeddedAppError) => void) | null;

/**
 * when an AppEvent is received
 * @param {appEvent} AppEvent -  app event
 */
event: ((appEvent: AppEvent) => void) | null;

App events dispatched through measurementApp.on.event:

  • APP_LOADED – the embedded app finished its startup sequence.
  • MEASUREMENT_PREPARED - Measurement has been prepared
  • ASSETS_DOWNLOADED - Assets have been downloaded
  • FACE_TRACKER_LOADED - Face tracker is loaded. Payload: { version } with SDK version info (webSDK, extractionLib, faceTracker).
  • CAMERA_PERMISSION_GRANTED – the user granted camera access.
  • CAMERA_STARTED – a camera stream opened successfully.
  • MEASUREMENT_STARTED – a measurement run begins. Payload: { measurementId, measurementOptions } with the measurement ID and measurement options (empty object {} if none provided).
  • MEASUREMENT_COMPLETED – the measurement finished and results are stable.
  • INTERMEDIATE_RESULTS – partial results are available during an active run. Payload: { points } with intermediate values.
  • RESULTS_RECEIVED – the final measurement results are available.
  • MEASUREMENT_CANCELED – the user canceled the active measurement.
  • CONSTRAINT_VIOLATION – a constraint (e.g., face distance) failed. Payload: { code } with one of: TOO_CLOSE, TOO_FAR, TURN_LEFT, TURN_RIGHT, LOOK_UP, LOOK_DOWN, TILT_LEFT, TILT_RIGHT, NOT_CENTERED, HOLD_STILL.
  • PAGE_VISIBILITY_CHANGE – the page changed visibility (e.g., tab switch or minimize).
  • PAGE_UNLOADED – the page is unloading.

Other runtime helpers:

await measurementApp.cancel(true); // cancel current run
const logs = await measurementApp.getLogs();
measurementApp.setTheme('dark');
measurementApp.setLanguage('es');

Error codes emitted through measurementApp.on.error:

| Code | Meaning | | ----------------------------- | --------------------------------------------------------------------- | | CAMERA_PERMISSION_DENIED | Camera access prompt was rejected. | | CAMERA_START_FAILED | Camera hardware failed to start after permission. | | NO_DEVICES_FOUND | No video input devices detected during enumeration. | | PAGE_NOT_VISIBLE | Measurement was running while the tab or window became hidden. | | MEASUREMENT_LOW_SNR | Signal-to-noise ratio dropped below the acceptable threshold. | | WORKER_ERROR | SDK worker encountered a fatal processing error. | | PROFILE_INFO_NOT_SET | Profile bypass stayed enabled, so demographics were not provided. | | INVALID_PROFILE | Profile is invalid | | COLLECTOR | Frame collection reported an error | | FACE_NONE | Face not detected during measurement (after threshold frames). | | WEBSOCKET_DISCONNECTED | Realtime WebSocket connection closed or dropped. | | MEASUREMENT_PREPARE_FAILED | Measurement preparation failed - invalid or missing credentials | | INVALID_MEASUREMENT_OPTIONS | Invalid measurement options (e.g., userProfileId is not a valid UUID) | | ASSET_DOWNLOAD_FAILED | Failed to download assets and initialize the SDK |