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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@webwriter/automaton

v3.0.1

Published

Build, visualize, and interact with different kinds of automata (DFA, NFA, PDA).

Downloads

174

Readme

Automaton (@webwriter/[email protected])

License: MIT | Version: 3.0.1

Build, visualize, and interact with different kinds of automata (DFA, NFA, PDA).

Snippets

Snippets are examples and templates using the package's widgets.

| Name | Import Path | | :--: | :---------: | | Dfa Simple | @webwriter/automaton/snippets/dfa-simple.html | | Dfa Complex | @webwriter/automaton/snippets/dfa-complex.html | | Nfa Simple | @webwriter/automaton/snippets/nfa-simple.html | | Nfa Complex | @webwriter/automaton/snippets/nfa-complex.html | | Pda Simple | @webwriter/automaton/snippets/pda-simple.html | | Pda Complex | @webwriter/automaton/snippets/pda-complex.html |

AutomatonComponent (<webwriter-automaton>)

Represents an Automaton Component. This component is responsible for rendering and managing the automaton editor and simulator.

Usage

Use with a CDN (e.g. jsdelivr):

<link href="https://cdn.jsdelivr.net/npm/@webwriter/automaton/widgets/webwriter-automaton.css" rel="stylesheet">
<script type="module" src="https://cdn.jsdelivr.net/npm/@webwriter/automaton/widgets/webwriter-automaton.js"></script>
<webwriter-automaton></webwriter-automaton>

Or use with a bundler (e.g. Vite):

npm install @webwriter/automaton
<link href="@webwriter/automaton/widgets/webwriter-automaton.css" rel="stylesheet">
<script type="module" src="@webwriter/automaton/widgets/webwriter-automaton.js"></script>
<webwriter-automaton></webwriter-automaton>

Fields

| Name (Attribute Name) | Type | Description | Default | Reflects | | :-------------------: | :--: | :---------: | :-----: | :------: | | nodes (nodes) | Node[] | Each automaton state is encoded as a string using the following format:[#][%]<id>[<label>](<x>\|<y>)Regex:^(#)?(%)?(\d+)(?:\[([^\]]*(?:\\.[^\]]*)*)\])?\((-?\d+)\\|(-?\d+)\)$Explanation:#: Optional - marks the initial state.%: Optional - marks the final (accepting) state.<id>: Required non-negative integer - unique state ID.[<label>]: Optional - URI-encoded label. Defaults to q<id> if omitted.(<x>\|<y>): Required coordinates - signed integers representing the node's position.Multiple nodes are separated by semicolons (;). Example:#0(-150\|0);%1[accept](0\|0);2[sink](150\|0)Requirements:Coordinates are mandatory, and there must be at least 150 units of distance between any two nodes.In the case of DFAs, the automaton MUST be complete, i.e. every node MUST have EXACTLY one transition for every input symbol. Correspondingly, a sink should be non-final and have self-loops on all inputs. Implicit sinks are NOT allowed. | [] | ✓ | | transitions (transitions) | Transition[] | Each automaton transition is encoded as:<from>-<to>[<symbolsOrStackOps>][~<roundness>][@<angle>]Multiple transitions are separated by semicolons (;).Regex:^(?:;\d+-\d+(?:\[(?:[^,\{\]\\|]+(?:,[^,\{\]\\|]+)*\|[^,\{\]\\|]*\{(?:p\|o\|e\|n)\\|[^,\{\]\\|]*\\|[^,\{\]\\|]*\}(?:,[^,\{\]\\|]*\{(?:p\|o\|e\|n)\\|[^,\{\]\\|]*\\|[^,\{\]\\|]*\})*)\])?(?:~(-?)(\d+(?:\.\d+)?))?(?:@(-?\d+))?)*$Explanation:<from>-<to>: Required - origin and destination state IDs (non-negative integers).[<symbolsOrStackOps>]: Required - DFA or NFA -> Symbols only: one or more URI-encoded symbols, separated by commas. PDA -> Stack operations: {||}, with one of: p (push), o (pop), e (empty check), or n (no-op); being the optional symbol to push or pop, and being an optional symbol the stack must have on top.~<roundness>: Optional - curvature of the arc, negative sign means counter-clockwise. 0.2 is recommended if there is a circle between two states.@<angle>: Optional - integer degrees for self-loop placement. Defaults to 45°.Multiple transitions must be separated by semicolons, no trailing ;.Examples:0-1[a]1-2[a,b]~0.52-2[a{p\|X\|},b{o\|\|}]@45;0-1[c]~1.2 | [] | ✓ | | type (type) | AutomatonType | The type of the automaton. Can be 'dfa', 'nfa', or 'pda'. | "dfa" | ✓ | | mode (mode) | "edit" \| "simulate" | The current mode. Can be 'edit', or 'simulate'. | "edit" | ✓ | | testLanguage (testLanguage) | string | A regular expression to check the language of the automaton against. | "" | ✓ | | forcedAlphabet (forcedAlphabet) | string[] | The alphabet that the automaton is forced to use as characters separated by spaces. | [] | ✓ | | testWords (testWords) | string[] | Words used for automatically testing the automaton as a string separated by spaces. | [] | ✓ | | verbose (verbose) | boolean | Enables logging of numerous events to the console. | - | ✓ | | permissions (permissions) | string | The encoded permissions for the editor. | "777" | ✓ | | showHelp (showHelp) | string | If true, the widget displays automaton error messages. | "true" | ✓ | | showFormalDefinition (showFormalDefinition) | string | If true, the widget allows viewing the automaton's formal definition. | "true" | ✓ | | showTransitionsTable (showTransitionsTable) | string | If true, the widget allows viewing the automaton's transition table. | "true" | ✓ | | allowedTypes (allowedTypes) | string[] | The types of automata that are allowed in the editor. | ["dfa", "nfa", "pda"] | ✓ | | allowedModes (allowedModes) | string[] | The modes that are allowed in the editor. | ["edit", "simulate"] | ✓ | | allowedTransformations (allowedTransformations) | string[] | The transformations that are allowed in the editor. | ["sink"] | ✓ |

Fields including properties and attributes define the current state of the widget and offer customization options.

Editing config

| Name | Value | | :--: | :---------: |

The editing config defines how explorable authoring tools such as WebWriter treat the widget.

No public methods, slots, events, custom CSS properties, or CSS parts.


Generated with @webwriter/[email protected]