# pwd-sdk

> PWD sdk

Latest version **0.0.12** (published 2020-11-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install pwd-sdk
pnpm add pwd-sdk
yarn add pwd-sdk
bun add pwd-sdk
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.12 |
| Published | 2020-11-13 |
| First published | 2020-07-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 1.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Maintainers | marcosnils |

## Links

- npm: https://www.npmjs.com/package/pwd-sdk
- Repository: https://github.com/play-with-docker/sdk
- Homepage: https://github.com/play-with-docker/sdk#readme
- Issues: https://github.com/play-with-docker/sdk/issues
- npm.io page: https://npm.io/package/pwd-sdk

## Dependencies (5)

- [xterm](https://npm.io/package/xterm.md) ^4.7.0
- [xterm-addon-fit](https://npm.io/package/xterm-addon-fit.md) ^0.4.0
- [wolfy87-eventemitter](https://npm.io/package/wolfy87-eventemitter.md) ^5.2.4
- [reconnecting-websocket](https://npm.io/package/reconnecting-websocket.md) ^3.2.2
- [rollup-plugin-typescript2](https://npm.io/package/rollup-plugin-typescript2.md) ^0.27.1

## Recent versions

- 0.0.12 (latest) — 2020-11-13
- 0.0.11 — 2020-11-12
- 0.0.10 — 2020-11-12
- 0.0.9 — 2020-11-09
- 0.0.8 — 2020-11-04
- 0.0.7 — 2020-10-31
- 0.0.6 — 2020-10-31
- 0.0.5 — 2020-10-31
- 0.0.4 — 2020-10-02
- 0.0.3 — 2020-09-25
- 0.0.2 — 2020-07-27
- 0.0.1 — 2020-07-27

## README

# Play with docker javascript SDK

This is the client side JS of PWD that allows to run terminals and attach them to your site

## Using the SDK

Here's a minimal example of the SDK usage:

```html
<html>
  <head>
    <title>PWD SDK Demo</title>
  </head>
  <body>
    <div id="myTerm" style="width 500px; height: 500px;"></div>
    <link rel="stylesheet" href="./dist/styled.css" />
    <script src="./dist/pwd.js"></script>
    <script>
      pwd = new PWD();
      pwd.newSession([{ selector: "#myTerm" }]);
    </script>
  </body>
</html>
```

If you are running [Play with Docker](https://github.com/play-with-docker/play-with-docker) locally (which saves resources on our production machines) create the new session with an additional option:

```
pwd.newSession([{selector: '#myTerm'}], {baseUrl: 'http://localhost'});
```

You can easily test your page with the SDK by running the following from the root directory of this project on Linux or Mac:

```
docker run --name sdktest -v $PWD:/usr/share/nginx/html:ro -d -it -p 8080:80 nginx
```

and then browse to [localhost:8080](http://localhost:8080).

## Using it with Vanilla JS

```html
<html>
  <head>
    <title>PWD SDK</title>
  </head>
  <body>
    <div id="myTerm" style="width: 500px; height: 500px;"></div>
    <link
      rel="stylesheet"
      href="https://unpkg.com/pwd-sdk@{version}/dist/styles.css"
    />
    <script src="https://unpkg.com/pwd-sdk@{version}/dist/pwd.min.js"></script>
    <script>
      pwd = new PWD();
      pwd.newSession([{ selector: "#myTerm" }]);
    </script>
  </body>
</html>
```

## Using it with React

```jsx
import { useEffect, useState } from "react";
import PWD from "pwd-sdk";
import ReactPWD, { usePWD } from "pwd-sdk/react";
import "pwd-sdk/dist/styles.css";

export default () => {
  const pwd = usePWD(new PWD());

  return (
    <div>
      <div>
        <ReactPWD pwd={pwd} name="1" />
      </div>
      <div>
        <ReactPWD pwd={pwd} name="2" />
      </div>
    </div>
  );
};
```

## Building the SDK

Requires an installation of [`yarn`](https://yarnpkg.com/).

Clone this repo and run `yarn install && yarn run build`

---
_Source: https://npm.io/package/pwd-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
