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

@tribe-nest/media-client

v0.4.0

Published

Client SDK for the media network. `./core` is the HEADLESS half: a WebSocket client speaking media-protocol frames, backoff-with-jitter reconnection and a pure room-state reducer. Zero DOM, zero mediasoup-client, zero React, because the load harness, the

Readme

@tribe-nest/media-client

The client SDK for the media network: the headless core (P3a), the room API over mediasoup-client, and the React hooks (P3b).

src/core/     the ./core subpath. ISOMORPHIC: no DOM, no mediasoup-client,
              no React.
  signal.ts     one socket, media-protocol frames, request/reply correlation,
                and the reason a connection ended
  reconnect.ts  backoff with jitter, and what to do about a draining node
  state.ts      a pure reducer: peers, producers, active speakers, recording
  socket.ts     the WebSocketLike shape and the injected factory

src/room/     the `.` export. `MediaRoom` over mediasoup-client: the device,
              one transport per direction, publish/subscribe, the reconnect
              ladder driven by `decideReconnect`, and the derived room state.
src/react/    the ./react subpath. `MediaRoomProvider` and the hooks Forge's
              `CallStage` is built on.
src/protocol.ts   the ./protocol subpath: a re-export of @tribe-nest/media-protocol.

package.json carries top-level main/types pointing at the . build as well as the exports map, for tooling that reads only the former.

mediasoup-client is a hard dependency because the . and ./react subpaths need it and @tribe-nest/forge depends on this package unconditionally. A core-only consumer (the load harness, the egress client, the SIP gateway) still installs it but never loads it: nothing reachable from ./core imports it, and src/core/_tests/coreBoundary.spec.ts is what holds that line.

Why ./core is not a browser SDK

The load harness, the egress client and the SIP gateway all need a protocol client, and none of them is a browser. Without a headless subpath each of them hand-rolls a socket, and three hand-rolled clients drift from each other and from the node. src/core/_tests/coreBoundary.spec.ts and the DOM-free lib in tsconfig.json are what hold the line.

The room API and mediasoup-client live at ., the React hooks at ./react, and Forge's call UI at @tribe-nest/forge/media. None of them is reachable from ./core.

The three things the core owns

Correlation. A request carries an id and gets exactly one reply with that id; an event carries no id. That is the whole protocol, so it is the whole of MediaSignal.

The handshake. join is the first frame on the socket and carries the token. Never a query parameter: a query string lands in load-balancer access logs, and a join ticket in a log is a join ticket for anyone who can read logs. connect() resolves only when both the join reply and the joined event have arrived, in either order, because the reply says the node accepted the token and the event carries the room.

Why the connection ended. A bare socket close tells a caller nothing, and draining, roomClosed and a refusal need three different responses. The DisconnectCause is what decideReconnect decides on.

Credentials are a callback, never a value

const signal = new MediaSignal({
  getCredentials: async () => {
    const { mediaUrl, token } = await mintJoinToken();
    return { mediaUrl, token };
  },
});

A join ticket expires in minutes and a call lasts an hour. A token passed once is not a naming choice, it is a first-reconnect failure.

Testing

npm run test runs everything against an in-process fake node (src/core/_tests/fakeSignalServer.ts). No network, no mediasoup, no browser. The fake parses every frame the client sends with the contract's own requestFrameSchema, so the question the suite answers is "does this client emit frames the frozen schema accepts", not "does this client talk to this fake".

Integration against a real node (P1) is not here and is not stubbed.