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

@tinyactors/scxmljs

v0.6.0

Published

A correctness-first SCXML 1.0 interpreter (ECMAScript data model) for the browser and Node, with custom elements for interactive statechart diagrams.

Readme

@tinyactors/scxmljs

Run SCXML statecharts in the browser, in Node and in Bun, and show them running. The interpreter implements SCXML 1.0 with the ECMAScript data model and passes all 160 automatic mandatory W3C conformance tests. Two custom elements draw running charts: <scxml-view> shows a whole chart and needs no JavaScript, and <scxml-explorer> explores large, multi-machine systems one level at a time. They are plain custom elements, so they work with any framework.

<scxml-explorer> following a running order-fulfilment system: the order machine's tree, the focus on its current state, the events it accepts, and the System level with the payment and shipment machines

Full-resolution video (WebM, 2880×1800) · High-resolution screenshot (PNG) · the explorer with the optional Tinyactors theme

Docs & demos: https://scxmljs.tinyactors.dev: guides, live demos and the API reference.

Install

npm install @tinyactors/scxmljs

Node 22.3 or later, Bun, or any current browser. The package is ESM only.

Quick start

A chart, traffic-light.scxml:

<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" datamodel="ecmascript" name="traffic-light" initial="on">
  <datamodel>
    <data id="cycles" expr="0"/>
  </datamodel>
  <state id="on" initial="red">
    <transition event="power.off" target="off"/>
    <state id="red">
      <onentry><send id="timer" event="timer" delay="3s"/></onentry>
      <onexit><cancel sendid="timer"/></onexit>
      <transition event="timer" target="green"/>
    </state>
    <state id="green">
      <onentry><send id="timer" event="timer" delay="3s"/></onentry>
      <onexit><cancel sendid="timer"/></onexit>
      <transition event="timer" target="yellow"/>
    </state>
    <state id="yellow">
      <onentry><send id="timer" event="timer" delay="1s"/></onentry>
      <onexit><cancel sendid="timer"/></onexit>
      <transition event="timer" target="red">
        <assign location="cycles" expr="cycles + 1"/>
      </transition>
    </state>
  </state>
  <final id="off">
    <donedata><param name="cycles" expr="cycles"/></donedata>
  </final>
</scxml>

Draw it and run it, with no JavaScript of your own. Import the element once (through your bundler, or an import map):

<script type="module">import "@tinyactors/scxmljs/view";</script>

<scxml-view src="traffic-light.scxml"></scxml-view>

The element loads, validates, runs and draws the chart. Active states are highlighted, and each transition label is a button that sends its event.

A media player chart drawn by <scxml-view>: the "playing" and "audible" states are active

Explore a running system with <scxml-explorer>: a tree of states, a focus on one level of the chart (each state with what it does, how it leaves, and buttons to send its events while it's active), the events the machine accepts right now, and playback controls.

import { createSession, PlaybackClock } from "@tinyactors/scxmljs/trusted";
import "@tinyactors/scxmljs/explorer";

const source = await (await fetch("traffic-light.scxml")).text();
const clock = new PlaybackClock({ speed: 0.5 }); // adds pause, step and speed controls
const session = await createSession(source, { clock });
document.querySelector("scxml-explorer")!.attach({ session, clock });
session.start();

Run it headless, for example in Node or in tests:

import { readFile } from "node:fs/promises";
import { createSession } from "@tinyactors/scxmljs";

const source = await readFile("traffic-light.scxml", "utf8");
const session = await createSession(source); // outside browsers, the library parses the XML itself

session.start();
console.log(session.activeStateIds().join(" "));
session.send("timer");
await session.settled();
console.log(session.activeStateIds().join(" "));
session.send("power.off");
console.log(JSON.stringify(await session.done));
session.dispose();
on red
on green
{"cycles":0}

The getting-started guide walks through all three.

Entry points

| Import | What | Size (min + gzip) | |---|---|---| | @tinyactors/scxmljs | the interpreter, sandboxed: chart code runs in QuickJS (WebAssembly) | 25 KB, then 290 KB loaded on demand | | @tinyactors/scxmljs/trusted | the same API, trusted: chart code runs in the host's own JavaScript engine | 23 KB | | @tinyactors/scxmljs/view | <scxml-view>: a whole chart, drawn and running, zero-JS | 57 KB, plus the engine it loads | | @tinyactors/scxmljs/explorer | <scxml-explorer> and its view-model: explore a running system | 30 KB | | @tinyactors/scxmljs/data | <scxml-data>: show, edit and compose a value an XML Schema describes (the view's event forms) | 9 KB | | @tinyactors/scxmljs/themes/tinyactors.css | an optional theme stylesheet | 0.3 KB |

Sizes are for a browser bundle of each entry on its own (mise run size in the repository).

Sandboxed or trusted?

Both interpreter entry points have the same API and pass the same conformance suite. They differ in where the chart's ECMAScript (<script>, expr, cond) runs:

  • Sandboxed (@tinyactors/scxmljs, the default): one QuickJS context per session. The chart can't see the page or other sessions, runaway scripts are interrupted, and memory is capped. Use it for charts that users write, paste or upload.
  • Trusted (@tinyactors/scxmljs/trusted): a separate realm of the host engine per session (a hidden iframe in browsers, a node:vm context in Node and Bun). No WebAssembly to download, but the chart can reach the page and a loop can't be interrupted. Use it for charts you wrote.

Details: sandboxed vs trusted and SECURITY.md.

Documentation

Support

| | Status | |---|---| | Chrome / Edge (Chromium) | tested in CI (Chromium 153) | | Firefox | tested in CI (Firefox 155) | | Safari | tested in CI with WebKit 26.6 (Safari's engine, not Safari itself) | | Node | 22.3 or later; tested in CI on 26.10, by hand on 22.3 | | Bun | tested in CI (1.4) | | Deno | tested in CI (2.9) |

The support table lists what each environment needs.

Stability

The package is at 0.x. Breaking changes can happen in minor versions until 1.0, and every one is listed in the changelog. Everything the entry points export is public API; anything else (and anything marked @internal) is not.

Contributions

This project doesn't accept outside contributions. Please report security problems as described in SECURITY.md.

License

MIT. QuickJS and quickjs-emscripten are MIT-licensed too; see THIRD_PARTY_NOTICES.