# asyncmachine-inspector

> Inspector and a debugger for AsyncMachine

Latest version **0.3.23** (published 2018-06-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install asyncmachine-inspector
pnpm add asyncmachine-inspector
yarn add asyncmachine-inspector
bun add asyncmachine-inspector
```

Provides the command `am-inspector`.

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.23 |
| Published | 2018-06-23 |
| First published | 2017-11-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 3 |
| Unpacked size | 2.1 MB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Tobiasz Cudnik |
| Maintainers | tobiasz.cudnik |
| Keywords | async, statemachine, asyncmachine, states, transition, eventloop, declarative, relational, inspector, debugger, logger, graphs |

## Links

- npm: https://www.npmjs.com/package/asyncmachine-inspector
- Repository: https://github.com/TobiaszCudnik/asyncmachine-inspector
- Homepage: https://github.com/TobiaszCudnik/asyncmachine-inspector#readme
- Issues: https://github.com/TobiaszCudnik/asyncmachine-inspector/issues
- npm.io page: https://npm.io/package/asyncmachine-inspector

## Dependencies (3)

- [open](https://npm.io/package/open.md) 0.0.5
- [commander](https://npm.io/package/commander.md) ^2.12.2
- [graphs-tob](https://npm.io/package/graphs-tob.md) ^2.0.0

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 0.3.23 (latest) — 2018-06-23
- 0.3.22 — 2018-05-22
- 0.3.21 — 2018-05-17
- 0.3.20 — 2018-05-17
- 0.3.19 — 2018-05-07
- 0.3.18 — 2018-05-07
- 0.3.17 — 2018-05-07
- 0.3.16 — 2018-05-04
- 0.3.15 — 2018-05-03
- 0.3.14 — 2018-05-03
- 0.3.13 — 2018-05-02
- 0.3.12 — 2018-05-02
- 0.3.11 — 2018-05-02
- 0.3.10 — 2018-04-19
- 0.3.9-2 — 2018-03-28
- … 17 more at https://npm.io/package/asyncmachine-inspector/versions

## README

# AsyncMachine Inspector

Inspector and a debugger for [AsyncMachine](https://github.com/TobiaszCudnik/asyncmachine).

[![Preview](http://tobiaszcudnik.github.io/asyncmachine-inspector/sample.png)](http://tobiaszcudnik.github.io/asyncmachine-inspector/sample.mp4)

## Features
- shows a graph of [AsyncMachines](https://github.com/TobiaszCudnik/asyncmachine) with their states and relations
- rendered with [JointJS](https://github.com/clientIO/joint) (drag-drop, drag-scroll, zooming)
- automatically layout the graph ([dagre](https://github.com/dagrejs/dagre) in a worker, diff repaints)
- supports multiple machines and pipes between them
- live updates
- log view
- machines view
- transitions view
- minimap
- scrolling through the history
- step by state changes, transitions or everything
- highlight transition-related elements
- highlighting and scrolling to states
- preserve the UI settings to localstorage
- export / import of snapshots to json
- remote logger support via [socket.io](https://github.com/socketio/socket.io)
- automatic colors
- keyboard navigation
- legend
- workerpool for logger diffs
- still [work in progress](https://github.com/TobiaszCudnik/asyncmachine-inspector/blob/master/docs/TODO.md)

## [Live demo](https://stackblitz.com/edit/asyncmachine-inspector-restaurant)

## Install

```bash
# UI
npm install -g asyncmachine-inspector
# Logger module
npm install ami-logger
# Server component
# (connects the logger directly to the UI)
npm install -g ami-server
```

## Example

```typescript
// main logger class
import { Logger, Network } from 'ami-logger'
// mixin to save files using the fs module
import FileFSMixin from 'ami-logger/mixins/snapshot/fs'
import { machine } from 'asyncmachine'
// example machine
const state = {
  Wet: { require: ['Water'] },
  Dry: { drop: ['Wet'] },
  Water: { add: ['Wet'], drop: ['Dry'] }
}
const example = machine(state)
// construct the logger class
const LoggerClass = FileFSMixin(Logger)
// instantiate the logger
const network = new Network(example)
const logger = new LoggerClass(network)
logger.start()
// make changes
example.add('Dry')
example.add('Water')
// save a snapshot
logger.saveFile('./snapshot.json')
```

## Usage

**Using snapshots**

1. Generate a snapshot using one of the following mixins
   - `ami-logger/mixins/file-fs` (node)
   - `ami-logger/mixins/file-http` (browser)
1. `$ am-inspector`
1. Load the snapshot using the toolbar

**Using the server**

1. `$ ami-server`
1. Use one of the following mixins
   - `ami-logger/mixins/remote-node`
   - `ami-logger/mixins/remote-browser`
1. `$ am-inspector -s`

**Browser bundles**

- `import { Logger, Network } from 'ami-logger/browser`
- `import { Logger, Network } from 'ami-logger/browser-remote`
- Both are bundled UMD modules, so the following will also work
  - `<script src='ami-logger/browser.js'><script>`

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