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

@flayerlabs/gamemode-client

v0.2.0

Published

Browser and mock-room client for Flaunch Game Modes

Downloads

321

Readme

@flayerlabs/gamemode-client

Use the SDK room while building offline or connecting a browser to a live Game Mode gate.

Requirements

Install the package with Node.js 20 or later:

pnpm add @flayerlabs/gamemode-client @flayerlabs/gamemode-spec

The package runs in the browser. It has no React dependency.

Build against the offline room

Pass your real rules and config to createMockRoom. This example uses the number game created by the Game Mode CLI:

import { createMockRoom } from '@flayerlabs/gamemode-client'
import { rules, type Action, type Config } from './game/rules.js'

const config: Config = {
  rounds: 3,
  ceiling: 10,
  points: 500,
  roundMs: 10_000,
}

const room = createMockRoom(rules, { config })

const unsubscribe = room.subscribe(({ publicView, playerView }) => {
  console.log({ publicView, playerView })
})

await room.send({ guess: 7 } satisfies Action)

The mock drives the same rules module as a live gate. It replaces only the network, wallet, chain and real spending. Call unsubscribe(), then room.dispose() when the game closes.

Join from an embedded game

An embedded game first receives its context and restricted host services from the trusted parent:

import { connectEmbeddedGame, joinRoom } from '@flayerlabs/gamemode-client'

const embedded = await connectEmbeddedGame({
  parentOrigin: 'https://flaunch.gg',
})

const room = await joinRoom({
  gateUrl: embedded.context.gateUrl,
  roundId: embedded.context.roundId,
  launch: embedded.context.launch,
  host: embedded.host,
  platform: embedded.platform,
})

Creator code sends game actions and reads room state. It cannot send a wallet transaction or create Flaunch calldata. The trusted parent uses serveEmbeddedGame to provide the permitted wallet, market and identity operations to one known iframe.

Call room.dispose() and embedded.dispose() when the iframe closes.

Connect a game with its own server

Use joinEconomy() when your existing server owns gameplay and scoring:

import { connectEmbeddedGame, joinEconomy } from '@flayerlabs/gamemode-client'

const embedded = await connectEmbeddedGame({
  parentOrigin: 'https://flaunch.gg',
})

const gameMode = await joinEconomy({
  gateUrl: embedded.context.gateUrl,
  roundId: embedded.context.roundId,
  launch: embedded.context.launch,
  host: embedded.host,
  platform: embedded.platform,
})

const stop = gameMode.economy.subscribe(renderAllowance)

joinEconomy() signs the player into the SDK gate and provides launch and spending capabilities. It does not send gameplay to your server or let the browser add points. Your game server must authenticate its players and use the gate's internal award route.

The SDK does not give its gate session token to your game server. Keep your existing player and wallet authentication.

Call stop(), gameMode.dispose() and embedded.dispose() when the iframe closes.

Use room capabilities

Room provides:

  • subscribe for public and player-specific game views
  • send for proposed game actions
  • now for the server-corrected clock
  • launch for fixed launch details
  • economy for earned, held, spent and available allowance
  • market and identity for data supplied by the trusted parent
  • presence and social for connected-player counts and cosmetic reactions

EconomyRoom provides the same launch, connection, economy, market, identity, presence and social capabilities. It leaves out gameplay views and send().

Use replayMarket to build market presentation without a live chain.

Integrate the trusted parent

Read the trusted platform integration guide before implementing serveEmbeddedGame, Host or a production joinRoom call.

The quiz example shows a live room with a stand-in wallet.

The generated game source shows the offline room.