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

@webgazer-ts/core

v0.2.0

Published

TypeScript rewrite of Webgazer.js - Webcam eye tracking for academic research (NOT for production use)

Readme

@webgazer-ts/core

npm version License Documentation

Modern TypeScript rewrite of Webgazer.js - webcam eye tracking for academic research.

📚 Documentation

View Full Documentation →

Features

  • 🎯 Accurate Gaze Tracking - Ridge regression + Kalman filtering
  • 🔧 100% API Compatible - Drop-in replacement for Webgazer.js
  • 📦 TypeScript Native - Full type safety and IntelliSense
  • Modern Build - ES modules, tree-shaking, optimized bundles
  • 🎨 Visual Feedback - Video preview, face overlay, gaze dot
  • 💾 Data Persistence - Optional localStorage for calibration
  • 🔒 Privacy First - All processing happens locally

Installation

npm install @webgazer-ts/core

Quick Start

import webgazer from '@webgazer-ts/core';

// Initialize and start tracking
await webgazer
  .setTracker('TFFacemesh')
  .setRegression('ridge')
  .begin();

// Show video preview
webgazer.showVideoPreview(true);

// Listen for gaze predictions
webgazer.setGazeListener((data, timestamp) => {
  if (data) {
    console.log(`Looking at: (${data.x}, ${data.y})`);
  }
});

Usage

ES Modules (Recommended)

import webgazer from '@webgazer-ts/core';

await webgazer.begin();

CommonJS

const webgazer = require('@webgazer-ts/core').default;

webgazer.begin();

Browser (UMD)

<script src="node_modules/@webgazer-ts/core/dist/webgazer-ts.umd.cjs"></script>
<script>
  // Available as global 'webgazer'
  webgazer.begin();
</script>

CDN

<script type="module">
  import webgazer from 'https://cdn.jsdelivr.net/npm/@webgazer-ts/core/+esm';
  await webgazer.begin();
</script>

API Overview

Lifecycle

await webgazer.begin();        // Initialize and start
await webgazer.end();          // Stop and cleanup
await webgazer.pause();        // Pause tracking
await webgazer.resume();       // Resume tracking

Configuration

webgazer
  .setTracker('TFFacemesh')              // Face tracker
  .setRegression('ridge')                 // Regression model
  .saveDataAcrossSessions(false)          // Data persistence
  .applyKalmanFilter(true)                // Smoothing
  .showVideoPreview(true)                 // Show camera
  .showFaceOverlay(true)                  // Show face mesh
  .showPredictionPoints(true)             // Show gaze dot
  .showFaceFeedbackBox(true);            // Show positioning guide

Predictions

// Listen to predictions (60 FPS)
webgazer.setGazeListener((data, timestamp) => {
  if (data) {
    console.log(`Gaze: (${data.x}, ${data.y})`);
  }
});

// Get current prediction
const prediction = webgazer.getCurrentPrediction();

Calibration

// Add calibration point
webgazer.recordScreenPosition(x, y, 'click');

// Clear calibration data
webgazer.clearData();

// Get calibration count
const count = webgazer.getCalibrationPointCount();

Mouse Events

// Enable automatic calibration from mouse
webgazer.addMouseEventListeners();

// Disable
webgazer.removeMouseEventListeners();

TypeScript

Full type definitions included:

import webgazer, { 
  GazePrediction, 
  WebgazerConfig,
  EyeFeatures 
} from '@webgazer-ts/core';

const handleGaze = (data: GazePrediction | null, timestamp: number) => {
  if (data) {
    const { x, y } = data;
    console.log(`Gaze at (${x}, ${y})`);
  }
};

webgazer.setGazeListener(handleGaze);

Configuration Options

interface WebgazerConfig {
  tracker: 'TFFacemesh';
  regressor: 'ridge' | 'ridgeThreaded' | 'ridgeWeighted';
  saveDataAcrossSessions: boolean;
  videoViewerWidth: number;
  videoViewerHeight: number;
  showVideo: boolean;
  showFaceOverlay: boolean;
  showPredictionPoints: boolean;
  showFaceFeedbackBox: boolean;
  applyKalmanFilter: boolean;
}

Browser Support

Requires:

  • HTTPS or localhost (for camera access)
  • WebRTC support
  • WebGL (for TensorFlow.js)

Supported Browsers:

  • Chrome/Edge 90+
  • Firefox 88+
  • Safari 15+
  • Mobile browsers (limited)

Migration from Webgazer.js

This package is 100% API compatible with Webgazer.js:

// This exact code works in both libraries
webgazer
  .setRegression('ridge')
  .setTracker('TFFacemesh')
  .setGazeListener((data) => console.log(data))
  .begin();

Breaking Changes in v0.2.0:

  • saveDataAcrossSessions now defaults to false (privacy-first)

To keep old behavior:

webgazer.saveDataAcrossSessions(true).begin();

See Migration Guide for details.

React Integration

For React apps, use the React package:

npm install @webgazer-ts/react
import { useWebgazer } from '@webgazer-ts/react';

function App() {
  const { gazeData, isRunning, start } = useWebgazer({
    autoStart: true
  });

  return <div>Gaze: {gazeData?.x}, {gazeData?.y}</div>;
}

See @webgazer-ts/react for full React documentation.

Examples

Basic Setup

import webgazer from '@webgazer-ts/core';

await webgazer.begin();
webgazer.showVideoPreview(true);

webgazer.setGazeListener((data) => {
  if (data) {
    console.log(`Looking at (${data.x}, ${data.y})`);
  }
});

With Calibration

import webgazer from '@webgazer-ts/core';

await webgazer.begin();

// Add calibration points
document.addEventListener('click', (e) => {
  webgazer.recordScreenPosition(e.clientX, e.clientY, 'click');
  console.log('Calibration points:', webgazer.getCalibrationPointCount());
});

Custom Regression

import webgazer, { Regressor, EyeFeatures } from '@webgazer-ts/core';

class MyRegressor implements Regressor {
  predict(eyeFeatures: EyeFeatures) {
    // Your prediction logic
    return { x: 500, y: 300 };
  }
  
  addData(eyeFeatures: EyeFeatures, screenPos: [number, number], type: string) {
    // Your training logic
  }
  
  // ... implement other required methods
}

webgazer.setRegression(new MyRegressor());

Performance

  • Prediction Rate: 60 FPS (16.7ms)
  • Initialization: ~800ms (model loading)
  • Accuracy: ±100-200px (after calibration)
  • Memory: ~50MB typical
  • Bundle Size: ~15KB gzipped (core only)

Privacy

  • ✅ All processing happens locally in your browser
  • ✅ No video or images sent to any server
  • ✅ Optional localStorage (opt-in in v0.2.0+)
  • ✅ User must grant camera permission
  • ✅ Full control over data

Academic Use

This library is designed for academic research. Please cite the original Webgazer.js:

@inproceedings{papoutsaki2016webgazer,
  author = {Alexandra Papoutsaki and Patsorn Sangkloy and James Laskey and Nediyana Daskalova and Jeff Huang and James Hays},
  title = {WebGazer: Scalable Webcam Eye Tracking Using User Interactions},
  booktitle = {Proceedings of the 25th International Joint Conference on Artificial Intelligence (IJCAI)},
  pages = {3839--3845},
  year = {2016}
}

License

GPL-3.0-or-later

For academic research use. See LICENSE.md for details.

Credits

Based on Webgazer.js by Brown HCI Lab.

Original Authors:

  • Alexandra Papoutsaki
  • James Laskey
  • Jeff Huang

TypeScript Rewrite:

  • John Adrian Cruz

Support

Links


Made with ❤️ for academic research