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

@textmode/runner-protocol

v0.1.0

Published

Shared message protocol and validators for the hosted textmode runner iframe.

Downloads

127

Readme

@textmode/runner-protocol

Shared TypeScript message contract for the hosted textmode runner iframe.

This package is the single source of truth for the wire messages exchanged by the runner and browser host apps in the textmode.js ecosystem. It contains the public message types, capability model, runtime settings, export/playback/font payloads, and runtime validators used on both sides of the iframe boundary.

Install

npm install @textmode/runner-protocol

Usage

import {
	createRunnerCapabilities,
	isParentMessage,
	isRunnerMessage,
	type ParentToRunnerMessage,
	type RunnerToParentMessage,
} from '@textmode/runner-protocol';

const capabilities = createRunnerCapabilities();

function handleParentMessage(message: unknown): void {
	if (!isParentMessage(message)) {
		return;
	}

	runMessage(message);
}

function sendRunnerMessage(message: RunnerToParentMessage): void {
	if (isRunnerMessage(message)) {
		port.postMessage(message);
	}
}

function runMessage(message: ParentToRunnerMessage): void {
	switch (message.type) {
		case 'RUN_CODE':
			runCode(message.code, message.requestId);
			break;
		case 'PING':
			port.postMessage({ type: 'PONG', nonce: message.nonce, timestamp: Date.now() });
			break;
	}
}

Public API

Import from the package root only:

import { isRunnerMessage, type RuntimeSettings } from '@textmode/runner-protocol';

Public subpath imports are intentionally not supported. This keeps the protocol package free to reorganize internal modules without breaking consumers.

The main exports are grouped around:

  • capabilities: RunnerCapabilities, ExportFormat, createRunnerCapabilities
  • runtime settings: RuntimeSettings
  • exports: image, SVG, TXT, GIF, and WebM option/result/progress types
  • playback: PlaybackAction, PlaybackState
  • messages: InitMessage, ParentToRunnerMessage, RunnerToParentMessage, Message
  • guards: isInitMessage, isParentMessage, isRunnerMessage, isRunnerCapabilities

Protocol Model

The runner protocol has one current message shape. Runtime protocol version negotiation is intentionally absent: npm package semver describes source compatibility, while runner feature availability is described through capabilities.

The initial window message is generic for every host app:

{ type: 'INIT' }

After a successful handshake, the runner responds with:

{ type: 'READY', capabilities: RunnerCapabilities }

Messages sent after that point use the ParentToRunnerMessage and RunnerToParentMessage unions.

Validation

The exported guards are strict runtime validators for untrusted postMessage payloads. Use them before dispatching messages across the iframe boundary:

if (!isRunnerMessage(event.data)) {
	return;
}

The guards reject retired app-identity and protocol-version fields such as client, v, clients, and protocolVersions.

API Docs

Generated TypeDoc Markdown lives in api/runner-protocol.

License

CC0-1.0. See LICENSE.