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

e-term

v1.2.9

Published

just-add-water javascript terminal

Downloads

9

Readme

e-term

Just-add-water javascript terminal

Installation

npm

npm i e-term --save

yarn

yarn add e-term

CDN

<script src="https://cdn.jsdelivr.net/npm/e-term@^1.2.4/dist/terminal.js"></script>
<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/e-term@^1.2.4/dist/terminal.css"
/>

Features

| Status icon | Description | | ----------- | -------------------------------------------------------------------------------------------------------- | | 📄 | Idea. It is not certain that it will be implemented | | 📆 | Scheduled. These changes are planned to be implemented, but work on the implementation has not yet begun | | 🚀 | In progress | | ✅ | Done |

| Feauture | Status | | -------------------------------------------------- | ------ | | Add plugins docs | 📆 | | Migrate to TypeScript | 📆 | | Log any HTML code as HTML | 📆 | | Added sanitizer config to term config | 📆 | | Added nested commands support (syntax {{ ... }}) | 📆 | | Add node socket (WebSockets) client | 📄 |

Types

class ETerm {
  constructor(
    selector: string,
    commandsList: {
      [key: string]: Command;
    },
    Config
  );
}

// definitions:

type Command = CommandDescriptor;

interface CommandDescriptor {
  // command
  util(api: CommandlineAPI, params: string[]): any;

  // docs
  schema: CommandSchema;
}

interface CommandlineAPI {
  flags: FlagsAPI;

  // exec string as command
  exec(command: string): void;

  // non-parsed command
  source: string;
  commandLine: ETermInstance;

  // log data to screen
  log(logParams: LogParams): void;

  // start dialog
  dialog(dialogParams: DialogParams): Promise<string>;
}

For more types see src/types.ts.

Example (builder)

<!DOCTYPE html>
<html>
  <head>
    ...
  </head>

  <body>
    <div e-term class="selector"></div>
  </body>
</html>
import ETerm from 'e-term';
import 'e-term/terminal.css';

const term = new ETerm(
  // parent node
  // your parent node must have a "e-term" attribute for styles
  '.selector',

  // commands
  {
    // ------
    echo({ log }, params: string[]) {
      log({
        text: params.join(' '),
      });
    },
    // ------
    pss({ dialog, log }) {
      dialog({ text: 'enter password', hideInput: true, defaultValue: '' })
        .then((pass) => {
          log({
            text: `password length: ${pass.length}`,
          });
        })
        .catch((err) => {
          const text = err === 'escape' ? 'you press Esc' : err;

          log({
            text,

            // any css styles
            styles: {
              color: '#f00',
            },
          });
        });
    },
    // ------
    logRed({ log }) {
      log({
        text: '{color: #f00 | red text}, pure text, {color: red | another text}',
      });
    },
    // ------
    xssSafe({ log }) {
      log({
        text: '<img src="1" onerror="alert(1)" /> text', // displays only "text" string
      });
    },
    // ------
    provideDocs: {
      util({ log }) {
        log({
          text: 'provideDocs',
        });
      },
      schema: {
        description: 'awesome utill',
        flags: [
          {
            name: 'c',
            require: false,
            description: 'c flag',
            valueRequire: true,
            valueName: 'c',
          },
        ],
        params: [
          {
            name: 'param',
            description: 'param',
            require: false,
            default: 'null',
          },
        ],
      },
    },
    // ------
    moreAPI({ flags, exec, source, commandLine, pickAFile, downloadFile }) {
      console.log(flags, exec, source, commandLine);
    },
    // ------
  }
);

term.exec('echo param');
term.log({
  text: 'string to {color: red | log}',
});

Example (CDN)

<html>
  <head>
    <script src="https://cdn.jsdelivr.net/npm/e-term@^1.2.4/dist/terminal.js"></script>
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/e-term@^1.2.4/dist/terminal.css"
    />

    <script>
      const main = () => {
        const term = new ETerminal.Terminal('[e-term]', {
          echo({ log }, params: string[]) {
            log({ text: params.join(' ') });
          },
        });
      };

      if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', main);
      } else {
        main();
      }
    </script>
  </head>

  <body>
    <div e-term></div>
  </body>
</html>