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 🙏

© 2024 – Pkg Stats / Ryan Hefner

vt

v0.1.1

Published

terminal emulation library for javascript.

Downloads

155

Readme

terminal.js

Terminal.js is a rendering engine for vt100-like terminals. It is written from scratch and supports most commonly used escape sequences.

Build Status

Benefits

  • it can be used both in nodejs and as a javascript library in the browser
  • it avoids any dependencies like pty, html outputting etc so you can provide your own
  • it does not use an html dom to store it's state, this makes it server state compatible
  • clean separation of different escape codes
  • has a test framework

Usage

TermWriter Usage

var TermWriter = require('terminal').TermWriter;
var TermBuffer = require('terminal').TermBuffer;

var buffer = new TermBuffer(80,24);
var terminal = new TermWriter(termBuffer);
terminal.write("first test\n");
// termWriter.buffer is accessible

TermBuffer Usage

var TermBuffer = require('terminal').TermBuffer;
var buffer = new TermBuffer(80,24);
buffer.inject("first test\n");

TermDiff Usage

var TermDiff = require('terminal').TermDiff;
var TermBuffer = require('terminal').TermBuffer;

var buffer1 = new TermBuffer(80,24);
var buffer2 = new TermBuffer(80,24);

var terminal1 = new TermWriter(buffer1);
var terminal2 = new TermWriter(buffer2);

terminal1.write("test me");
var diff = new TermDiff(terminal1.buffer,terminal2.buffer);

diff.apply(terminal1);

TermBuffer Functions

  • createChar

  • createLine

  • getLine

  • write

  • escapeWrite

  • inject

  • lineFeed

  • mvCur : moves to relative coordinates

  • setCur : move to absolute coordinates

  • mvTab

  • tabSet

  • tabClear

  • saveCursor

  • restoreCursor

  • deleteCharacters

  • eraseCharacters

  • setScrollRegion

  • eraseInDisplay

  • eraseInLine

  • deleteLines

  • resetAttr

  • chAttr

  • insertBlanks

  • resize

  • insertLines

  • toString

  • setLed

  • scroll

  • eventToKey

TermBuffer Object structure

TermDiff structure

diff = {
  changes: [
    { l: 0, '.': { // On line0 replace the line
      str: 'test', // With string test
      attr{
      '0': { fg: null, bg:null, bold:false , underline: false, blink: false, inverse: false }, // Change Attributes on Pos0
      '2': { fg: null, bg:null, bold:false , underline: false, blink: false, inverse: true  }  // Change Attributes on Pos2
      }
    },
    { l: 1, '+': { // Online 1 add a line
      str: 'test', // With String test
      attr{
      '0': { fg: null, bg:null, bold:false , underline: false, blink: false, inverse: false }, // Change Attributes on Pos0
      '2': { fg: null, bg:null, bold:false , underline: false, blink: false, inverse: true  }  // Change Attributes on Pos2
      }
    },
    { l: 2, '-': 3 }, // On line2 remove 3 lines
  ],
  cursor: [ { from: { 'x': 0, 'y':10 }, to: { 'x': 0, 'y':12 } } ],
  savedcursor: [ { from: { 'x': 0, 'y':10 }, to: { 'x': 0, 'y':12 } } ],
  size: [ { from: { 'height': 80, 'width':24 }, to: { 'height': 30, 'width':12 } } ],
  scrollregion: [ {from: [ 0, 10 ], to: [ 0, 12 ] } ],
  modes: [ { 'graphic': true }, { 'insert': false } ],
  tabs: [ { from: [] , to: [ 1 ] }]
}

Alternatives & Related

Jquery/Server side:

Expose local shell in a browser:

Simulate a pseudo shell in browser:

Reference docs for vt100, csi , ... codes

Remarks

  • we should clone the defaultBuffer instead of equalling it (see reset function)
  • attrCommited? always after changr of attr?
  • this.attr = this.defaultAttr (again it should copy it not equal the object)
  • Termdiff.diff() - should it not be an array instead of a hash?