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

green-screen-react

v1.3.8

Published

Multi-protocol legacy terminal React component (TN5250, TN3270, VT, HP 6530)

Downloads

531

Readme

green-screen-react

Multi-protocol legacy terminal React component. Connects to TN5250 (IBM i / AS/400), TN3270 (z/OS mainframe), VT220 (OpenVMS, Unix), and HP 6530 (NonStop) hosts.

Live Preview

v1.2.0: per-field MDT state, readMdt() for cheap post-write verification, pluggable session store with session.lost/session.resumed lifecycle events, lower-level sign-on primitives. See the feature section below. Python integrators can use the new green-screen-client PyPI package.

Install

npm install green-screen-react green-screen-proxy

Quick Start

Start the proxy (separate terminal):

npx green-screen-proxy

Or start it programmatically from your app:

import { createProxy } from 'green-screen-proxy';
await createProxy({ port: 3001 });

Render the component:

import { GreenScreenTerminal } from 'green-screen-react';
import 'green-screen-react/styles.css';

function App() {
  return <GreenScreenTerminal />;
}

Connects to localhost:3001 automatically. Use the sign-in form to connect to a real host.

Adapters

WebSocketAdapter (recommended)

Real-time bidirectional WebSocket. Works with both the Node.js proxy and the Cloudflare Worker.

import { WebSocketAdapter } from 'green-screen-react';

// Local proxy (default)
const adapter = new WebSocketAdapter({ workerUrl: 'http://localhost:3001' });

// Cloudflare Worker
const adapter = new WebSocketAdapter({
  workerUrl: 'https://green-screen-worker.your-subdomain.workers.dev'
});

<GreenScreenTerminal adapter={adapter} />

RestAdapter

For backends that expose a REST API:

import { RestAdapter } from 'green-screen-react';

const adapter = new RestAdapter({
  baseUrl: 'https://your-server.com/api/terminal',
  headers: { Authorization: 'Bearer your-token' },
});

Custom Adapter

Implement TerminalAdapter to connect to any backend:

import type { TerminalAdapter } from 'green-screen-react';

class MyAdapter implements TerminalAdapter {
  async getScreen() { /* ... */ }
  async getStatus() { /* ... */ }
  async sendText(text: string) { /* ... */ }
  async sendKey(key: string) { /* ... */ }
  async setCursor?(row: number, col: number) { /* ... */ }
  async readMdt?(modifiedOnly?: boolean) { /* ... */ }  // v1.2.0
  async connect(config?) { /* ... */ }
  async disconnect() { /* ... */ }
  async reconnect() { /* ... */ }
}

v1.2.0 features

Post-write verification with readMdt()

Instead of diffing the entire screen after a batch of writes, ask the proxy which fields actually captured input:

import { WebSocketAdapter } from 'green-screen-react';

const adapter = new WebSocketAdapter({ workerUrl: 'http://localhost:3001' });

// ... after typing into several fields ...
const modified = await adapter.readMdt();       // only fields with MDT bit set
const all = await adapter.readMdt(false);       // all input fields

for (const f of modified) {
  console.log(`row ${f.row} col ${f.col}: "${f.value}"`);
}

readMdt is optional on the TerminalAdapter contract — protocols without a per-field modified concept (VT, HP6530) return [].

Session lifecycle events

WebSocketAdapter now exposes hooks for session-level transitions. Use them to prompt reconnect UX or surface a clean "session expired" state without string-matching errors:

const adapter = new WebSocketAdapter({ workerUrl: 'http://localhost:3001' });

adapter.onSessionLost((sessionId, status) => {
  console.log('lost:', sessionId, status.error);
  // show "Session expired, click to reconnect" UI
});

adapter.onSessionResumed((sessionId) => {
  console.log('reattached:', sessionId);
});

On page reload, reattach to a session that survived the refresh:

const sessionId = localStorage.getItem('tn5250-session-id');
if (sessionId) {
  await adapter.reattach(sessionId);
}

The proxy keeps the TCP connection alive across WebSocket drops within its idle timeout — reattach reconnects the WS and replays the current screen.

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | adapter | TerminalAdapter | auto | Backend adapter | | protocol | 'tn5250' \| 'tn3270' \| 'vt' \| 'hp6530' | 'tn5250' | Terminal protocol | | inlineSignIn | boolean | true | Show sign-in form when disconnected | | defaultProtocol | TerminalProtocol | 'tn5250' | Pre-selected protocol in sign-in | | readOnly | boolean | false | Disable keyboard input | | pollInterval | number | 2000 | Screen polling interval (ms) | | autoReconnect | boolean | true | Auto-reconnect on disconnect | | embedded | boolean | false | Compact embedded mode | | showHeader | boolean | true | Show header bar | | typingAnimation | boolean | true | Enable typing animation | | bootLoader | ReactNode \| false | default | Custom boot loader | | onSignIn | (config) => void | - | Sign-in callback | | onScreenChange | (screen) => void | - | Screen change callback | | bootLoaderReady | boolean | - | Explicit boot-loader dismissal (overrides default "dismiss on first screen"). | | headerRight | ReactNode | - | Custom content in the header's right slot. | | statusActions | ReactNode | - | Custom buttons rendered after connection status groups (e.g. disconnect button). | | className | string | - | CSS class | | style | CSSProperties | - | Inline styles |

Theming

:root {
  --terminal-green: #10b981;
  --terminal-white: #FFFFFF;
  --terminal-blue: #7B93FF;
  --terminal-bg: #000000;
  --terminal-card-bg: #0e1422;
  --terminal-card-border: #1e293b;
  --terminal-header-bg: #090e1a;
  --terminal-font: 'JetBrains Mono', 'Courier New', monospace;
}

License

MIT