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

@simplix-react-native-ext/capture

v0.3.13

Published

Auto-capture session for simplix-react-native: camera preview, on-device face detection seam, composition judgement, countdown, retake, upload part

Readme

@simplix-react-native-ext/capture

English | 한국어

Auto-capture session for simplix-react-native: camera preview, an on-device face detection seam, composition judgement, sustain window, countdown, retake, a manual fallback, and the form-data part for uploading the photo. The package binds no face detector; the app injects one, and detection stays on the device.

Installation

pnpm add @simplix-react-native-ext/capture

Prerequisites: Peer dependencies: @simplix-react-native/ui, @simplix-react/i18n, expo-camera (>=16), react (>=18), react-native (>=0.76).

Usage

The screen owns the camera permission, wires a detector into the session, and renders the guide frame over the preview until a photo is captured:

import { useCallback, useRef } from "react";
import {
  CameraPreview,
  CapturePreview,
  GuideFrame,
  useAutoCaptureSession,
  useDetectorPolling,
  type CameraPreviewHandle,
  type FaceDetectorAdapter,
} from "@simplix-react-native-ext/capture";

export function ArrivalPhoto({ detector, onUpload }: { detector: FaceDetectorAdapter; onUpload: (uri: string) => void }) {
  const cameraRef = useRef<CameraPreviewHandle | null>(null);
  const takePicture = useCallback(async () => {
    const photo = await cameraRef.current!.takePictureAsync();
    return photo.uri;
  }, []);

  const session = useAutoCaptureSession({ takePhoto: takePicture });

  useDetectorPolling({
    detector,
    takeSnapshot: takePicture,
    onFaces: session.reportFaces,
    onDetectorFailure: session.enterManualMode,
    enabled: session.phase === "searching" || session.phase === "holding",
  });

  if (session.phase === "captured" && session.photoUri) {
    return (
      <CapturePreview
        photoUri={session.photoUri}
        onRetake={session.retake}
        onUse={() => onUpload(session.photoUri!)}
      />
    );
  }

  return (
    <CameraPreview cameraRef={cameraRef}>
      <GuideFrame
        phase={session.phase}
        countdown={session.countdown}
        failure={session.failure}
        onCaptureNow={session.captureNow}
      />
    </CameraPreview>
  );
}

A detector that pushes results (a frame processor) calls session.reportFaces directly and does not use useDetectorPolling. Request the permission with useCameraPermissions() before rendering the preview; when the camera is unavailable the screen can skip the photo.

Session phases

The session moves from searching to holding, countdown, capturing and captured, returns to searching when the composition breaks, and enters manual mode when no detector works

| Phase | Meaning | | --- | --- | | searching | Waiting for a face report that satisfies the composition | | holding | The composition holds; after sustainMs the next passing report starts the countdown | | countdown | Counting down from countdownFrom, one step per countdownTickMs; a failing report aborts to searching | | capturing | takePhoto is running | | captured | photoUri holds the photo; retake() returns to searching | | manual | Face reports are ignored and captureNow() takes the photo |

A failed takePhoto calls onCaptureError and returns the session to searching.

API Reference

useAutoCaptureSession(options)

Options (UseAutoCaptureSessionOptions, which also takes every CompositionConfig field):

| Option | Type | Default | Description | | --- | --- | --- | --- | | takePhoto | () => Promise<string> | required | Takes the photo and resolves its local URI | | sustainMs | number | 1000 | How long the composition must hold before the countdown | | countdownFrom | number | 3 | Countdown start value | | countdownTickMs | number | 1000 | Countdown step length | | onCaptured | (photoUri: string) => void | none | Called after a successful capture | | onCaptureError | (error: unknown) => void | none | Called when takePhoto fails |

Result (UseAutoCaptureSessionResult): phase (AutoCapturePhase), countdown, photoUri, failure (CompositionFailure | null), reportFaces(faces), captureNow(), retake(), enterManualMode().

evaluateComposition(faces, config?)

Pure judgement on the largest face in faces (FaceBox[], values normalized to 0..1 with the origin at the top left). Returns CompositionResult: { ok, reason?, face? }, where reason is a CompositionFailure: "no-face", "off-center", "too-small" or "too-large".

| CompositionConfig field | Default | Description | | --- | --- | --- | | centerTolerance | 0.18 | Maximum distance of the face center from the target point on each axis | | targetX | 0.5 | X of the target point | | targetY | 0.5 | Y of the target point; lower it when the guide sits near the camera at the top of the screen | | minFaceRatio | 0.18 | Minimum of the face box's larger side, as a fraction of the frame | | maxFaceRatio | 0.6 | Maximum of the face box's larger side, as a fraction of the frame |

useDetectorPolling(options)

Samples preview frames on an interval, runs a still-image FaceDetectorAdapter (detect(imageUri): Promise<FaceBox[]>) and passes the faces to onFaces.

| Option | Type | Default | Description | | --- | --- | --- | --- | | detector | FaceDetectorAdapter | required | Detector supplied by the app | | takeSnapshot | () => Promise<string> | required | Grabs a frame and resolves its local URI | | onFaces | (faces: FaceBox[]) => void | required | Usually session.reportFaces | | onDetectorFailure | (error: unknown) => void | none | Called on each failed sample from the failureThreshold-th consecutive failure on; usually session.enterManualMode | | intervalMs | number | 800 | Sampling interval | | failureThreshold | number | 3 | Consecutive failures before onDetectorFailure | | enabled | boolean | true | Pauses sampling when false |

Components

| Component | Props | Description | | --- | --- | --- | | CameraPreview | cameraRef, facing ("front" default, or "back"), mirror (default true for the front camera), onCameraReady, children, className | expo-camera preview; children render as an overlay. CameraPreviewHandle is the ref type for takePictureAsync | | GuideFrame | phase, countdown, failure, onCaptureNow, anchor ("center" default, or "top"), className | Face guide, status text, countdown, and the capture button in manual mode | | CapturePreview | photoUri, onRetake, onUse, busy, className | Captured photo with retake and use-this-photo actions |

useCameraPermissions is re-exported from expo-camera.

capturePhotoFormDataPart(photoUri, fileName?)

Returns { uri, name, type } for a multipart upload. fileName defaults to "arrival-photo.jpg"; the type is image/png for a .png name and image/jpeg otherwise. The upload endpoint belongs to the app's generated domain hooks.

Types

The package exports the prop and option types of the API above: CameraPreviewProps, GuideFrameProps, CapturePreviewProps, UseDetectorPollingOptions, UseAutoCaptureSessionOptions, UseAutoCaptureSessionResult, AutoCapturePhase, FaceBox, FaceDetectorAdapter, CompositionConfig, CompositionFailure, CompositionResult.

Platform notes

  • The package registers its en/ko/ja strings under the simplix/native-capture namespace on import.
  • Its components use NativeWind className utilities, so add the package src folder to the app's Tailwind content.