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

@miadi/stateloom-client

v0.1.2

Published

Framework-agnostic socket.io-client wrapper for the smcraft real-time design bridge (join/patch/full/presence + auto-resync)

Readme

@miadi/stateloom-client

npm

Framework-agnostic socket.io-client wrapper for the stateloom real-time design bridge: join, patch, full, presence, and sequence-gap auto-resync.

Install

npm install @miadi/stateloom-client

What it is

One thin object that owns the client side of the bridge conversation: connect and join a document room, send and receive patch/full frames, track who else is in the room, and notice when a sequence number skips — which means a frame was missed — and ask the hub for a resync automatically.

It is not the hub (that is @miadi/stateloom) and it does not know React (that is @miadi/stateloom-react, built on this). It is what the CLI, the MCP server and the React hook all reach for, so all three behave identically on the wire.

Usage

import { createBridgeClient } from "@miadi/stateloom-client";
import type { PatchOp } from "@miadi/stateloom-protocol";

const client = createBridgeClient({
  url: "http://127.0.0.1:4599",
  role: "cli",                                   // 'agent' | 'cli' | 'web' | 'runtime'
  docId: "/abs/path/to/statemachine.smdf.json",  // rooms are keyed by absolute path
  name: "guillaume@terminal",
});

const off = client.on("patch", (env) => {
  console.log(`seq ${env.seq}:`, env.ops);
});
client.on("presence", (peers) => console.log(peers.map((p) => p.name)));
client.on("status", (s) => console.log(s));      // connecting | connected | disconnected | error

const { selfId, snapshot, presence } = await client.join();
let def = snapshot.def;

const ops: PatchOp[] = [
  { op: "state.add", parent: "Root", state: { name: "Shipped", kind: "final" } },
];
client.emitPatch(ops, mtimeMs, client.lastSeq);

off();
client.disconnect();

Behaviour worth knowing

  • The hub echoes your own frames back, so the sender learns its hub-assigned seq. The client advances lastSeq from that echo but does not re-deliver it to your patch/full handlers — an optimistic local edit is never applied twice.
  • Auto-resync is on by default. When an incoming seq skips ahead of lastSeq + 1, the client calls request(lastSeq) before advancing. Pass autoResync: false to handle gaps yourself.
  • The hub never writes disk. Whoever mutates persists through its own durable channel and stamps the resulting mtimeMs on the frame it emits; the hub uses that stamp to dedup the writer's own file-watcher echo.
  • Presence is bookkept for you. client.presence is always the current roster; join/leave/update frames are merged before your handler fires.

API

| Member | Purpose | |---|---| | connect() | Open the socket (resolves once connected) | | join() | Join the docId room; resolves { selfId, snapshot, presence } | | emitPatch(ops, mtime?, baseSeq?) | Send granular ops | | emitFull(def, mtime?) | Send a whole definition | | request(sinceSeq?) | Ask for a resync | | updatePresence({ cursor, selection }) | Publish this client's pointer/selection | | on(event, handler) | patch | full | ack | presence | error | status; returns an unsubscribe | | status / lastSeq / presence | Current state, read-only | | disconnect() | Leave the room and close the socket |

Part of the stateloom stack

| Package | Role | |---|---| | @miadi/stateloom-engine | State machine engine: parser, validator, interpreter, code generators | | @miadi/stateloom-protocol | Patch ops, diff/apply, layout, renderers — zero runtime deps | | @miadi/stateloom | socket.io hub holding the live document | | @miadi/stateloom-client | Framework-agnostic client for the hub — this package | | @miadi/stateloom-react | React binding over the client | | @miadi/stateloom-cli | smcx — terminal design surface and renderers | | @miadi/stateloom-mcp | MCP server so LLM agents can design machines |

License

MIT © Guillaume Isabelle