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

mikesir87-pwd-sdk

v0.1.7

Published

An alternative approach to a PWD SDK

Downloads

54

Readme

PWD SDK, Take Two

This SDK/library was developed as a thought experiment and as an alternative way to work with PWD (Play with Docker).

Installation

npm install --save mikesir87-pwd-sdk

Usage

The SDK can be used directly in the browser. Simply add the script to your page.

API

This area is still being flushed out, but is enough to get you started.

The starting point is the PWD object. From here, you can create a new Session.

PWD

PWD.newSession(sessionOptions: SessionOptions, pwdOptions?: PwdOptions) => Session

Creates a new Session object. The new Session, however, may not be initialized yet (may require a ReCAPTCHA challenge to be completed).

Example

const session = PWD.newSession({ instanceOptions: [ { terminalSelector: '.term1' } ] }, { pwdHost: 'localhost' });

Session

The Session is the object that will let you create new instances, delete instances (eventually), and more. You can also listen to events to hook in your own code.

API

  • getId() => string - get the session identifier
  • getHostname() => string - get the hostname for the session
  • getInstances() => Instance[] - get all instances in the session
  • on(eventName, callback) => Session - register an event listener (see below for events)
  • off(eventName, callback) => Session - remove an event listener (see below for events)

Events

| Name | Arguments | Description | |------------------|----------------|----------------------------------------------------------------------------------------------------------| | initialized | Session | Invoked once the session has been created and has an id and remote reference (safe to add instances now) |

All Instance events (noted below) are also rebroadcasted through the Session, with a instance. prefix and the instance provided as the first argument.

PWD.newSession({ instanceOptions: [ { terminalSelector: '.term1' } ] })
    .on('instance.port.new', function(instance, newPort) {
        console.log('Instance ' + instance.getName() + ' has a new port exposed: ' + newPort.getPort());
    });

Instance

The Instance object represents a single instance/node in PWD.

API

  • getName() => string - get the name of the instance
  • getIp() => string - get the IP address for the instance (not a globally routed address)
  • getCpuMetrics() => string - get the current CPU metrics for this instance
  • getMemoryMetrics() => string - get the current memory metrics for this instance
  • getExposedPorts() => ExposedPort[] - get the exposed ports for this instance
  • on(eventName, callback) => Instance - register an event listener (see below for events)
  • off(eventName, callback) => Instance - remove an event listener (see below for events)

Events

| Event Name | Arguments | Description | |------------------|------------------------|---------------------------------------------------------------------------------------------------------| | metrics.cpu | string | Notified whenever the cpu metrics changes for the instance | | metrics.memory | string | Notified whenever the memory metrics changes for the instance | | port.new | ExposedPort | Notified whenever a new port is exposed from the instance | | port.removed | ExposedPort | Notified whenever a port is no longer exposed from the instance | | terminal.data | string | Notified upon every data entry made into the terminal | | terminal.keydown | terminal, keyDownEvent | Attached as a "customKeydownHandler" to the xterm console. Allows for custom keyboard shortcut bindings |

As a reminder, ALL instance events are rebroadcasted at the Session level, where it's easier to hear events across all instances.

Examples

Adding a keyboard shortcut to clear the console

PWD.newSession({ instanceOptions: [ { terminalSelector: '.term1' } ] })
  .on('instance.terminal.keydown', function(terminal, event) {
    if (event.metaKey && event.keyCode === 75)
      terminal.clear();
  });

License

This is created solely as a proof of concept is available for anyone to use.