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

term-web

v1.1.11

Published

:pager: A simple Terminal UI that run on the web

Downloads

41

Readme

Term-Web

:pager: A Simple Terminal UI That Run On The Web

version license size npm Downloads

Screenshot

Demo

Checkout the demo from Github Pages

Install

Install with npm:

$ npm install term-web

Or install with yarn:

$ yarn add term-web
import Term from 'term-web';

Or umd builds are also available:

<script src="path/to/term-web.js"></script>

Or from jsDelivr CDN:

<script src="https://cdn.jsdelivr.net/npm/term-web/dist/term-web.js"></script>

Will expose the global variable to window.Term.

Usage

<div id="term"></div>
var term = new Term({
    // ... options
    container: '#term',
});

Options

{
    // Mounted dom element
    container: '#term',

    // Debug mode
    debug: false,

    // Initial size
    width: 600,
    height: 500,

    // Custom actions
    actions: [],

    // Use the display recorder button
    recorder: true,

    // Is it draggable
    draggable: true,

    // Font size
    fontSize: 13,

    // Font family
    fontFamily: 'monospace',

    // Watermark image url
    watermark: '',

    // Font color
    color: '#b0b2b6',

    // Background color
    background: 'rgb(42, 39, 52)',

    // Title on the topbar
    title: 'Term Web',

    // Entered prefix
    prefix: 'root@linux: ~ <d color="#00f501">$</d> ',

    // Welcome Message
    welcome: `Last login: ${new Date()}`,

    // Loading tips
    loading: (val) => '<d color="yellow">Loading...</d>',

    // Pixel ratio
    pixelRatio: window.devicePixelRatio,

    // Callback when command is not found
    notFound: (val) => `-bash: <d color='red'>${val}</d>: command not found`,
}

API

term.input(text, isReplace)

  • text is the string to be displayed.
  • isReplace indicates whether to replace the previous record, default is false;

term.output(text, isReplace)

  • text is the string to be displayed.
  • isReplace indicates whether to replace the previous record, default is false;

term.type(text, isExecute)

  • text is the string to be displayed.
  • isExecute Whether to execute immediately after typing, default is true;

term.clear()

Clear all log

term.ask(text)

  • text is the question string to be displayed.
term.ask('How are you ?').then((answer) => console.log(answer));

term.radio(list)

Output radio list

term.radio([
    {
        key: 1,
        text: 'hi',
    },
    {
        key: 0,
        text: 'bye',
    },
]).then((key) => {
    console.log(key);
});

term.checkbox(list)

Output checkbox list

term.checkbox([
    {
        key: 1,
        text: 'hi',
    },
    {
        key: 0,
        text: 'bye',
    },
]).then((key) => {
    console.log(key);
});

Dynamically modify the UI

term.color

Modify font color

term.color = '#fff';

term.background

Modify background color

term.background = '#000';

term.watermark

Modify watermark image

term.watermark = 'img.png';

term.width

Modify terminal width

term.width = 500;

term.height

Modify terminal height

term.height = 500;

Style attribute

The output interface supports multiple styles through a html tag, currently does not support tag nesting effect

color

term.output('<d color="#666">some text</d>');

background

term.output('<d color="#fff" background="red">some text</d>');

border

Select the color attribute or fontColor attribute of the option by default

term.output('<d color="yellow" border>some text</d>');

underline

Select the color attribute or fontColor attribute of the option by default

term.output('<d color="yellow" underline>some text</d>');

del

Select the color attribute or fontColor attribute of the option by default

term.output('<d color="yellow" del>some text</d>');

href

Link jump behavior

term.output('<d href="www.google.com">google</d>');

Common problem

How to use the font after the font file is loaded?

MDN Web Docs - FontFace

Term.font('Font Name', 'path/to/font.ttf').then((font) => {
    var term = new Term({
        fontFamily: font.family,
        // ... options
    });
});

Donations

We accept donations through these channels:

QQ Group

QQ Group

License

MIT © Harvey Zack