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 🙏

© 2024 – Pkg Stats / Ryan Hefner

state-machine-snacks

v1.0.5

Published

A framework built on XState that provides useful state machine plugins and patterns geared toward UI development.

Downloads

2

Readme

State Machine Snacks (🍕)

A framework built on XState that provides bite sized snacks for developing with state machine machines. 🍕 aims to increase state machine adoption in modern day web apps by providing a suite of tools and plugins to inspire development and new ways of thinking.

🐤 @me on Twitter.

What Is XState?

XState is a library that allows us to create and interpret state machines in JavaScript. It is recommended you understand the basics of XState before using State Machine UI.

🚀 Getting Started

For basic usage, 🍕 requires only a XState state machine config as an option. SMS will utilize this config to create a machine and return an XState service.

| Options | Description | | | ----------- | ----------- | ----------- | | config | XState state machine config. | Required | createMachine | By default, the machine is created with createMachine(config). You can overwrite this behavior with a function that will be passed the config and must return a XState machine instance. | Optional | interpret | By default, the service is interpreted via interpret(machine). You can overwrite this behavior with a function that will be passed both the config and machine instance from the createMachine() step. | Optional | plugins | An array of plugins you want to add to the service. | Optional

🍕 w/Default Settings

import sms from "state-machine-snacks";

const config = { /* ...machine config */ };

// Create your service with 🍕.
const service = sms({
    config,
});

service.start();

🍕 w/Advanced Initialization

import sms from "state-machine-snacks";

const config = { /* ...machine config */ };

// Create your service with 🍕 + additional settings.
const service = sms({
    config,

    createMachine : (config) => createMachine(config, { ...actions, ...services }),

    interpret : (config, machine) => interpret(machine).onTransition((state) => {
         console.log(state.value);
    });
});

service.start();

🔌 Plugins

Plugins add additional functionality to an XState config and service. 🍕 provides a plugin runner and you can add plugins to your state machine by simply adding them to the plugins : [] option when initializing your service.

  • Plugins can export helper functions to be used during plugin usage and state machine composition.
  • Plugins are located in their own repositories prefixed with sms-plugin---. You can find a list of currently available plugins below.
  • Plugins can be passed an object containing options for the plugin.
import sms from "state-machine-snacks";
import components from "sms-plugin---components";
import logger from "sms-plugin---logger";

const config = { /* ...machine config */ };

// Create our state machine with stateUI
const service = sms({
    // Required
    config,

    // Example plugin usage:
    plugins : [
       components(),
       logger(),
    ]
});

service.start();

📦 Plugin Components

Conditionally render components as you enter/exit states.

📦 Plugin Logger

Provide useful logging when developing with XState.

[WIP] Plugin Router

Map browser URLs to specific states.

[WIP] Ethereum Blockchain

Plugin for interacting with the Ethereum blockchain.

[WIP] Solana Blockchain

Plugin for interacting with the Ethereum blockchain.

[WIP] Video Call

Plugin for initiating peer to peer video calls via WebRTC + Firebase.

[WIP] WSIO P2P Chat

Plugin for initiating peer to peer text chats. Firebase?

💻 Examples

Simple UI

Example of a simple UI utilizing State Machine Snacks and Plugin Components. See how you can use a state machine to render components.

🛠 Contribute

Resources

Links to Everything