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

@tvteamup/tvtbridge

v1.0.3

Published

A simple communication bridge allowing self-hosted games to interact with the TV Team Up platform.

Downloads

6

Readme

TVTBridge.js

A class to manage communication between a child window (client or host) and a TV Team Up parent window, using window.postMessage.

TV Team Up games are designed to run within an iframe that is hosted by tvteamup.com.

Receiving messages from the TV Team Up platform

The TVTBridge object will fire several events to notify your game of communications from the TV Team Up platform.

[ALL] initializeGame

Fires when the TV Team Up platform has successfully shaken hands with the Bridge, and passes information about the initial state of the game to your application, including player info.

Example:

const bridge = new TVTBridge();

bridge.addEventListener('gameInitialized', (e)=>{
  const gameInfo = e.detail;
  const mode = gameInfo.mode; // either 'host' or 'client'
  const players = gameInfo.players;
  /* players = [
    {
      id: '123456789012234567890',
      name: 'Player Name',
      avatarHash: '040103020405002020405065040504',
      score: 0,
      data: {}
    },
    ...
  ];*/
  const playerID = gameInfo.playerID; // "12345678901234567890"
  const gameState = initialState;
  startGame(mode);
});

[ALL] endGame

Fires when the game platform requests that the game end.

Example:

bridge.addEventListener('endGame', (e)=>{
  endGame();
});

[ALL] pauseRequested

Fires when the game platform requests that the game be paused.

Example:

bridge.addEventListener('pauseRequested', (e)=>{
  pauseGame();
});

[ALL] resumeRequested

Fires when the game platform requests that the game resume from a paused state.

Example:

bridge.addEventListener('resumeRequested', (e)=>{
  resumeGame();
});

[ALL] muteRequested

Fires when the game platform requests that the game be muted.

Example:

bridge.addEventListener('muteRequested', (e)=>{
  muteGame();
});

[ALL] unmuteRequested

Fires when the game platform requests that the game be muted.

Example:

bridge.addEventListener('unmuteRequested', (e)=>{
  unmuteGame();
});

[CLIENT ONLY] gameState

Fires when the game platform forwards game state from the host to clients. The game state itself is an arbitrary object that can be defined by your game as needed.

Example:

bridge.addEventListener('gameState', (e)=>{
  let state = e.detail;
  processGameState(state);
});

[ALL] playerJoined

Fires when a new player joins the game. The player object, passed in the event details, contains attributes for id, name, avatarHash, score, and an arbitrary data store.

Example:

bridge.addEventListener('playerJoined', (e)=>{
  const detail = e.detail;
  const player = detail.player;
  processAddPlayer(player);
});

[ALL] playerLeft

Fires when a player leaves the game. Passes the playerID in the event details.

Example:

bridge.addEventListener('playerLeft', (e)=>{
  const detail = e.detail;
  const player = detail.playerID;
  processRemovePlayer(playerID);
});

[CLIENT ONLY] playerState

Fires when the game platform forwards a player's state from the host to a client. The player state itself is an arbitrary object that can be defined by your game as needed, but this message will also contain playerID and score.

Example:

bridge.addEventListener('playerState', (e)=>{
  const detail = e.detail;
  const playerID = detail.playerID;
  const playerScore = detail.score;
  const data = detail.data;
  updatePlayerState(playerID, playerScore, data);
});

[CLIENT ONLY] playerActionRequested

Fires when the game platform forwards a request for player action from the host to a client. The prompt is an arbitrary map of strings to values, used to clarify what action is being requested.

Example:

bridge.addEventListener('playerActionRequested', (e)=>{
  const detail = e.detail;
  const prompt = detail.prompt;
  const context = detail.context;
  processPlayerAction(playerID, prompt, context);
});

[HOST ONLY] playerAction

Fires when the game platform forwards a player's action from the client to the host. The player action itself is an arbitrary object that can be defined by your game as needed. Along with the action, the event detail will also include the origin's playerID. Optionally, the event detail may also contain a context string, used to identify what prompt the player is responding to.

Example:

bridge.addEventListener('playerAction', (e)=>{
  const detail = e.detail;
  const playerID = detail.origin;
  const action = detail.action;
  const context = detail.context;
  processPlayerAction(playerID, action, context);
});

[ALL] globalMessageReceived

Fires when the game host forwards a global message from any player or host to all other clients. the event details will contain the origin (playerID or HOST) of the message, as well as the message itself, which is expected to be a string.

Global messages have no explicit intended use in the game platform at the moment, but along with direct messages, they can be used to add any necessary custom communications.

Example:

bridge.addEventListener('globalMessageReceived', (e)=>{
  const detail = e.detail;
  const sender = detail.origin;
  const message = detail.message;
  processGlobalMessage(sender, message);
});

[ALL] directMessageReceived

Fires when the game host forwards a direct message from a specific player or host to another specific client. the event details will contain the origin (playerID or 'host') of the message, as well as the message itself, which is expected to be a string.

Direct messages have no explicit intended use in the game platform at the moment, but along with global messages, they can be used to add any necessary custom communications.

Example:

bridge.addEventListener('directMessageReceived', (e)=>{
  const detail = e.detail;
  const sender = detail.origin;
  const message = detail.message;
  processDirectMessage(sender, message);
});

Sending Messages

The TVTBridge object contains several methods designed to send messages from the client players and host to the game platform.

[ALL] sendGlobalMessage(message)

Passes an arbitrary string to the game platform, to be distributed to all clients.

Example:

bridge.sendGlobalMessage('Hello World!');

[ALL] sendDirectMessage(message, target)

Passes an arbitrary string to the game platform, to be distributed to a specific client, identified by either player ID or the identifier HOST.

Example:

bridge.sendGlobalMessage('Hello World!', 'HOST');

[CLIENT ONLY] sendPlayerAction(action)

Passes a player action object to the game platform, to be forwarded to the host. The player action may be any arbitrary object.

Example:

bridge.sendPlayerAction({ ID: 'Q12', response: 'B' });

[HOST ONLY] sendGameStateUpdate(readable, state)

Passes a game state update from the host to the game platform, to be forwarded to the players. A short human-readable state is also included, for the platform to display to users as needed.

Example:

bridge.sendGameStateUpdate("Question 12", {
  question: 12,
  state: 'AWAITING_INPUT',
  expires: 1757554791,
});

[HOST ONLY] sendPlayerStateUpdate(playerID, score, state)

Passes a player state update from the host to the game platform, to be forwarded to the players. Along with the playerID, also include a simple numberic score. For games using non-traditional scoring, such as golf, the score parameter should contain a ranking of the players. If partial scoring is impossible, all scores should be set to null until the game is over.

Example:

bridge.sendPlayerStateUpdate("12345678901234567890", 500, {
  question: 12,
  state: 'ANSWERED',
  answer: 'B'
});

[HOST ONLY] sendGameEnded()

Notifies the game platform that the game has ended, and all clients should be returned to the game selection lobby.

Example:

bridge.sendGameEnded();