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-client

v0.1.0

Published

Browser iframe runtime client for the hosted textmode runner.

Readme

@textmode/runner-client

Browser iframe runtime client for the hosted textmode runner.

This package gives any browser host app a typed runtime API for mounting the runner iframe, performing the current generic protocol handshake, routing request/response messages, monitoring heartbeat status, loading fonts, controlling playback, running code, exporting output, reconnecting, and disposing the transport.

It does not execute textmode.js sketches directly. It controls a runner app at the runnerUrl you provide.

Install

npm install @textmode/runner-client

@textmode/runner-protocol is installed as a dependency and is also available for consumers that need the protocol types directly.

Usage

import {
	IframeTextmodeRuntime,
	RunnerRequestError,
	type RunnerRuntimeStatus,
} from '@textmode/runner-client';

const container = document.querySelector<HTMLElement>('#runner');

if (!container) {
	throw new Error('missing runner container');
}

const runtime = new IframeTextmodeRuntime({
	runnerUrl: 'https://runner.textmode.art/',
	onStatusChange(status: RunnerRuntimeStatus, reason) {
		console.info('runner status changed', status, reason);
	},
	onExportProgress(requestId, format, progress) {
		console.info('export progress', requestId, format, progress);
	},
});

await runtime.init(container, {
	width: 640,
	height: 640,
	fontSize: 16,
	frameRate: 60,
});

try {
	await runtime.runCode(`
		t.draw(() => {
			t.print('textmode', 0, 0);
		});
	`);
} catch (error) {
	if (error instanceof RunnerRequestError) {
		console.error(error.message, error.line, error.column);
	}
}

const image = await runtime.export('image', {
	format: 'png',
	scale: 2,
});

console.info(image.filename, image.mimeType, image.blob);
runtime.dispose();

Public API

Import from the package root only:

import { IframeTextmodeRuntime } from '@textmode/runner-client';

Public subpath imports are intentionally not supported. Internal modules such as request routing, heartbeat control, iframe mounting, and sandbox policy may change without a semver-major release.

The main exports are:

  • IframeTextmodeRuntime
  • RunnerRuntimeStatus
  • RunnerExecutionError
  • RunnerRequestError
  • FontLoadResult
  • IframeTextmodeRuntimeOptions
  • IframeMountMode
  • IframeSandboxToken
  • DEFAULT_IFRAME_SANDBOX_TOKENS

Runtime Lifecycle

Typical host apps follow this lifecycle:

  1. Create an IframeTextmodeRuntime with a trusted runnerUrl.
  2. Call init(container, settings) from a browser context.
  3. Use runCode, configure, setSettings, export, loadFont, and playback as needed.
  4. Call reconnect after a recoverable runner failure.
  5. Call dispose when the host view is unmounted.

The runtime exposes status, isReady, and frame getters for host UI state.

Sandbox Policy

The default iframe sandbox tokens are:

['allow-scripts', 'allow-same-origin']

allow-downloads is not included by default. Export downloads should be initiated by the host app after it receives an export result from the runner.

The runtime refuses to start a runner that combines allow-scripts and allow-same-origin on the same origin as the parent page.

API Docs

Generated TypeDoc Markdown lives in api/runner-client.

License

AGPL-3.0-or-later. See LICENSE.