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

@magnaboy/whep

v0.0.1

Published

Browser WHEP viewer lifecycle, authenticated transports, and shared sessions.

Readme

@magnaboy/whep

Browser WHEP viewer connections without a React dependency. Module imports also work outside a browser; starting a session reports unsupported WebRTC through its snapshot.

import { createHttpWhepTransport, WhepSession } from '@magnaboy/whep';

const session = new WhepSession({
  transport: createHttpWhepTransport('https://media.example/live/whep'),
  rtcConfiguration: { iceServers: [{ urls: 'stun:stun.example:3478' }] },
  iceTimeoutMs: 2000,
  retryDelayMs: 4000,
});
const unsubscribe = session.subscribe(snapshot => {
  video.srcObject = snapshot.stream;
});
session.start();
// On unmount:
unsubscribe();
session.close();

The transport implements the MediaMTX SDP offer/answer profile: receive-only audio/video, bounded ICE gathering, POST SDP, resolve Location, and DELETE the allocated session. It does not implement trickle ICE, ICE restarts, or the counter-offer extension in the WHEP draft. Reconnection creates a fresh session.

WhepTransport lets applications retain authenticated HTTP routes. offer receives an abort signal. It must return the allocated location with the answer, or release that location itself if reading the answer fails. The session releases late answers after cancellation and ignores stale peer events. DELETE is best effort, with an independent five-second timeout in the HTTP transport. Servers still need expiry for allocations whose response never reaches the client.

Defaults: two-second ICE gathering, 25-second connection timeout, no disconnect grace, and no automatic retry. retryDelayMs enables retries after connection/negotiation failures; unsupported browser/setup failures remain errors. disconnectGraceMs permits temporary outages. hasAudioTrack tracks live, unmuted audio; setAudioEnabled controls ducking independently and persists across retries. Autoplay policy remains with the application.

Sessions pause and release resources on pagehide, and reconnect on pageshow. Pass lifecycleTarget: false to manage page lifecycle yourself. close is permanent; restart replaces the current attempt while keeping subscribers.

WhepSessionPool shares connections by key within one caller-owned authentication/configuration context. Each acquisition returns an idempotent release function. The default two-second release grace supports remounts. Restarting a pooled connection keeps all active viewers subscribed. Scope separate pools to different users or credentials.

CX uses a pool retained across hot reloads, four-second retries, Cloudflare STUN, and a 100 ms jitter target. IronStream injects its authenticated media routes, configured ICE servers, a five-second ICE timeout, and three-second disconnect grace. Its UI retains manual retries and missing-audio fallback.

Build this package before installing the consumers' sibling file: dependencies. Run pnpm build, pnpm test:types, and pnpm test:unit to verify the package.

pnpm test:browser runs real Chromium peers with synthetic audio and video on localhost for both consumer profiles. Install the test browser with pnpm exec playwright install chromium if needed. This verifies SDP negotiation, received media, ducking, and teardown without contacting a deployed media server. Production authentication, TURN, and server reachability need the corresponding deployment environment.