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

luma-sensor-expo

v0.1.2

Published

Luma sensor for brightness

Readme

luma-sensor-expo

An Expo module that measures real-time brightness (luma) from the device camera. It samples camera frames at configurable intervals and calculates perceived brightness using the BT.601 luma formula.

Works on both iOS and Android with physical devices.

How it works

The module taps into the camera video feed and samples pixel brightness at 5 points (center + four 25%-inset corners). Brightness is calculated as:

Y = 0.299 * R + 0.587 * G + 0.114 * B

Returns a value between 0.0 (black) and 1.0 (white).

Installation

npx expo install luma-sensor-expo

For bare React Native projects, run npx pod-install after installing.

Requirements

  • Expo SDK 54+
  • iOS 15.1+ / Android API 26+
  • Physical device (camera required)
  • Camera permission granted (use expo-camera for permission handling)

Usage

import { useEffect, useState, useRef } from 'react';
import { CameraView, useCameraPermissions } from 'expo-camera';
import { LumaSensorExpoModule, startMonitoring, stopMonitoring } from 'luma-sensor-expo';

export default function App() {
  const [permission, requestPermission] = useCameraPermissions();
  const [brightness, setBrightness] = useState<number | null>(null);
  const subscriptionRef = useRef<ReturnType<typeof LumaSensorExpoModule.addListener> | null>(null);

  const start = () => {
    subscriptionRef.current = LumaSensorExpoModule.addListener(
      'onBrightnessChange',
      ({ brightness }) => setBrightness(brightness)
    );
    startMonitoring(5); // process every 5th frame
  };

  const stop = () => {
    stopMonitoring();
    subscriptionRef.current?.remove();
  };

  useEffect(() => () => stop(), []);

  // brightness is 0.0 - 1.0
  const percent = brightness !== null ? Math.round(brightness * 100) : null;

  return (
    <CameraView style={{ flex: 1 }} facing="back">
      {/* Your UI here */}
    </CameraView>
  );
}

API

startMonitoring(frameSkip?: number)

Start continuous brightness monitoring. Emits onBrightnessChange events.

  • frameSkip — process every Nth frame (default: 5). Higher = less CPU usage.

stopMonitoring()

Stop monitoring and clean up resources.

getLuma(): Promise<number>

One-shot brightness reading. Returns a promise that resolves with the current brightness value (0.0 - 1.0).

Events

onBrightnessChange

{ brightness: number } // 0.0 (dark) to 1.0 (bright)

Subscribe via LumaSensorExpoModule.addListener('onBrightnessChange', callback).

Platform notes

| | iOS | Android | |---|---|---| | Camera access | Attaches to existing AVCaptureSession from expo-camera | Uses PixelCopy / Canvas screen capture | | Frame source | AVCaptureVideoDataOutput | Choreographer frame callbacks | | Preset | Uses expo-camera's session | N/A |

iOS: The module finds expo-camera's active AVCaptureSession via the view hierarchy and attaches a video data output to it. No separate camera session is created. Camera must be active (via <CameraView>) before calling startMonitoring().

Android: Captures the screen content (including camera preview) using PixelCopy (API 26+) with a Canvas fallback.

License

MIT