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

fortistate

v3.0.0

Published

๐Ÿš€ A powerful state management library with collaborative inspector, real-time debugging, store snapshots, and IDE integration. Features include share snapshots, locate stores in code, and team collaboration tools.

Readme

fortistate

Version 3.0 - Collaborative Inspector Edition ๐Ÿ‘ฅ

A powerful state management library with collaborative inspector, real-time debugging, and IDE integration. Share snapshots ๐Ÿ“ธ, locate stores in code ๐Ÿ”, and collaborate with your team in real-time!

CI npm


๏ฟฝ What's New in v3.0!

Collaborative Inspector Features

๐Ÿ“ธ Share Store Snapshots

  • One-click shareable URLs with encoded state
  • Export as JSON, CSV, Email, or Tweet
  • Perfect for bug reports and team collaboration

๐Ÿ” Locate Store in Code

  • Automatically opens store files in VS Code
  • Intelligent search pattern generation
  • Works with VS Code, WebStorm, and GitHub

๐Ÿ‘ฅ Invite Team to Inspector

  • Share inspector session URLs
  • QR code for mobile access
  • Real-time collaboration and debugging

๐ŸŽจ Aurora White Theme

  • Beautiful, professional interface
  • Improved readability and UX
  • Modern glassmorphism design

See full v3.0 release notes โ†’


๐Ÿš€ Quick Start

Installation

npm install fortistate

Create a Store

import { createStore } from 'fortistate'

const counterStore = createStore('counter', { count: 0 })

Start the Inspector

npx fortistate inspect

Open http://localhost:4000 and enjoy the new collaboration features!

Use New v3.0 Features

  • Click ๐Ÿ“ธ on any store to share snapshots
  • Click ๐Ÿ” to locate store in your code (auto-opens VS Code!)
  • Click ๐Ÿ‘ฅ Invite to share with your team

๐ŸŽฏ Advanced Features (v2.0 - Cosmogenesis Engine)

From Cosmogenesis Engine โ†’ Substrate of Possibility โ€” Evolution into "Figma for State Management" with quantum mechanics and relativity built-in.

๐Ÿš€ Meta-Laws Engine is live! Compose laws with conflict resolution:

Week 7-8: Meta-Laws Engine โš–๏ธ

  • ๐Ÿ”— Law composition: AND/OR/IMPLIES/SEQUENCE/PARALLEL operators
  • โšก Conflict resolution: 7 strategies (priority, voting, frame-dependent, etc.)
  • ๐Ÿงฉ Dynamic mutation: Add/remove laws at runtime
  • ๐ŸŽจ Helper functions: and(), or(), implies(), sequence()
  • ๐ŸŽฏ 157/161 tests passing (97.5% - core functionality 100%)

Meta-laws docs โ†’ | Progress tracker โ†’

Week 5-6: Relativistic Substrate ๐ŸŒŒ

  • ๐Ÿš€ Observer frames: Multiple perspectives with relative velocities
  • โฑ๏ธ Causal ordering: Light cone constraints, no time paradoxes
  • ๐Ÿ”„ Lorentz transformations: Time dilation for distributed systems
  • ๐Ÿ“Š 29 new tests: 133/133 v3.0 tests passing (100%)

Relativistic docs โ†’

Week 3-4: Quantum Substrate โš›๏ธ

  • ๐ŸŒŠ Superposition: States exist in multiple possibilities simultaneously
  • ๐Ÿ”— Entanglement: Spooky action between entities
  • ๐Ÿ‘๏ธ Observer: Collapse superpositions via measurement (Born rule)
  • ๐Ÿ“Š 37 new tests: 104/104 v3.0 tests passing (100%)

Quantum docs โ†’

Week 1-2: Possibility Algebra ๐Ÿ”ค

  • ๐Ÿ—๏ธ Entity primitive: Type-safe entity definitions
  • ๐Ÿ”’ Constraint primitive: Validation with auto-repair
  • โš–๏ธ Law primitive: Universal rules governing behavior
  • ๐Ÿ“Š 67 tests: Foundation complete

Foundation docs โ†’


๐Ÿš€ v3.0 Quick Start

Meta-Law Composition

import { defineMetaLaw, defineLaw, and } from '@fortistate/possibility'

// Define individual laws
const creditCheck = defineLaw({
  name: 'credit-check',
  inputs: ['customer'],
  output: 'approved',
  enforce: (c) => c.creditScore > 650
})

const inventoryCheck = defineLaw({
  name: 'inventory-check',
  inputs: ['product'],
  output: 'available',
  enforce: (p) => p.stock > 0
})

const fraudCheck = defineLaw({
  name: 'fraud-check',
  inputs: ['transaction'],
  output: 'safe',
  enforce: (t) => !t.flagged && t.amount < 10000
})

// Compose into meta-law (ALL must pass)
const orderApproval = and('order-approval', [
  creditCheck,
  inventoryCheck,
  fraudCheck
], {
  conflictResolution: 'error',
  context: { mode: 'strict' }
})

// Execute
const result = orderApproval.execute([customer, product, transaction])

if (result.success) {
  console.log('Order approved! โœ…')
} else {
  console.log('Order denied:', result.error)
  console.log('Failed checks:', 
    Array.from(result.lawResults.entries())
      .filter(([_, r]) => !r.success)
      .map(([name, _]) => name)
  )
}

๐ŸŒŸ What's New in v2.0 (Phase 3D Complete!)

๐Ÿš€ Physics Simulations are live! Latest achievements:

Phase 3D: Physics Simulations ๏ฟฝ

  • โš›๏ธ Classical mechanics substrate: Gravity, friction, momentum, energy
  • ๐Ÿ’ฅ Collision detection & resolution: Elastic collisions with conservation laws
  • ๐Ÿ“ Vector mathematics: 2D physics operations and utilities
  • ๐Ÿ”’ Constraint enforcement: Mass positivity, velocity limits, position bounds
  • ๐Ÿ“Š Energy tracking: Kinetic, potential, and total energy calculations
  • ๐ŸŽฎ Example simulations: Bouncing ball, multi-body collisions

Physics guide โ†’ | Examples โ†’

Phase 3C: Performance Harness โšก

  • ๐Ÿ“Š Statistical benchmarking: P95/P99 analysis with warmup
  • ๐ŸŽฏ Result: 5.6ms average (3x better than 15ms target!)
  • ๐Ÿ’พ Memory tracking: ~38MB for 10k events
  • ๐Ÿ“ˆ Scalability testing: Constraint overhead, repairs, cross-store laws

Performance docs โ†’

Phase 3B: Universe Manager ๐ŸŒŒ

  • ๐ŸŒ Universe orchestration: Manage multiple causal stores as unified realities
  • ๐Ÿ”„ Lifecycle management: Start, pause, resume, destroy universes
  • ๐Ÿ“ธ Snapshots & time travel: Capture and restore complete universe state
  • ๐ŸŒฟ Universe forking: Create alternate timelines with divergent state
  • ๐ŸŒ Multiverse coordination: Manage multiple universes simultaneously

Universe docs โ†’ | Quick reference โ†’ | Full roadmap โ†’

Phase 1 (Temporal Foundation):

  • โฐ Time travel: Jump to any state in history
  • ๐ŸŒฟ Universe branching: Create parallel timelines
  • ๐Ÿ“Š Entropy measurement: Quantify state complexity
  • ๐Ÿ”’ Existence constraints: Define "laws of nature"

Phase 1 summary โ†’ | Migration guide โ†’


Quick install & getting started

npm install fortistate

Basic Usage (v1.x compatible)

import { createStore, useStore } from 'fortistate'

const counter = createStore({ value: 0 })

function Counter() {
  const [state, setState] = useStore(counter)
  return <button onClick={() => setState(s => ({ value: s.value + 1 }))}>
    {state.value}
  </button>
}

New: Temporal State & Universe Management (v2.0+)

import { createUniverse } from 'fortistate'

// Define laws of physics for your universe
const substrate = {
  id: 'my-app',
  name: 'Application Rules',
  constraints: new Map([...]),
  laws: new Map([...]),
}

// Create a universe with multiple stores
const universe = createUniverse({
  id: 'my-app',
  substrate,
})

// Create stores within the universe
const counter = universe.createStore('counter', 0)
const user = universe.createStore('user', { name: 'Alice' })

// Time travel
const pastState = counter.at(Date.now() - 5000)  // 5 seconds ago

// Snapshots
const checkpoint = universe.snapshot()
universe.restore(checkpoint)  // Rollback to checkpoint

// Forking (create parallel realities)
const fork = universe.fork('experiment-a')
fork.getStore('counter')?.set(999)  // Changes don't affect original

// Multiverse coordination
import { Multiverse } from 'fortistate'
const multiverse = new Multiverse()
multiverse.add(universe1)
multiverse.add(universe2)
multiverse.pauseAll()  // Freeze all universes

Full Universe Manager guide โ†’


Quickstarts

React (hooks)

import React from 'react'
import { createStore, useStore } from 'fortistate'

const counter = createStore({ value: 0 })

function Counter(){
	const [state, setState] = useStore(counter)
	return <button onClick={() => setState(s => ({ value: s.value + 1 }))}>{state.value}</button>
}

export default Counter

Vue (composition)

import { createStore, useStore } from 'fortistate'
import { ref } from 'vue'

const counter = createStore({ value: 0 })

export default {
	setup(){
		const [state, setState] = useStore(counter)
		return { state, inc: () => setState(s => ({ value: s.value + 1 })) }
	}
}

Next.js (auto-register example)

See examples/my-nextjs-app for a full Next.js example that auto-registers stores on the client and demonstrates the inspector integration.

Zero-config inspector

Start a local inspector for your project (zero-config):

npm run inspect
# or
npx fortistate inspect

By default the inspector runs an HTTP server that serves a small UI and a WebSocket endpoint. Browser agents (examples included) auto-register client stores and stream updates to the inspector. Use --token and --allow-origin flags to control access in shared environments.

CLI / Inspector flags

The CLI exposes a few useful flags when running npx fortistate inspect or npm run inspect:

  • --port <n>: specify the inspector port (default 4000).
  • --token <token>: provide a legacy shared token (backward compatibility only โ€” use session-based auth for production).
  • --allow-origin <origin>: add an allowed origin for CORS.
  • --quiet: reduce debug logs in tests or CI.
  • FORTISTATE_REQUIRE_SESSIONS=1: require issued sessions for write operations; combine with FORTISTATE_ALLOW_ANON_SESSIONS=1 to keep anonymous read-only access during local testing.

New: Session management via CLI

# Create editor session
fortistate session create --role editor --label "Alice" --ttl 24h

# List active sessions (requires admin token)
fortistate session list --port 4000 --token <admin-token>

# Revoke session
fortistate session revoke <session-id> --token <admin-token>

Run fortistate help for complete command reference and environment variable documentation.

Example:

npx fortistate inspect --port 3333 --allow-origin http://localhost:3000

For comprehensive session workflows, see docs/SESSION_WORKFLOWS.md.

Config-driven presets & plugins

  • The inspector now looks for fortistate.config.{js,cjs,mjs} in its working directory and automatically loads any declared presets or plugins.
  • Presets that return additional plugins are resolved before plugin execution, matching the RFC roadmap for a Tailwind-like ecosystem.
  • Config changes (or updates to string-referenced presets/plugins) trigger a reload via chokidar; the inspector refreshes registered stores in-place and broadcasts updates to connected clients.
  • Use the environment variable FORTISTATE_DISABLE_CONFIG_WATCH=1 to disable file watching when running in environments where filesystem watchers are not desirable.
  • When a plugin/preset is removed from the config, the associated stores are cleaned up from the inspector's remote view so the UI stays in sync with the source of truth.

Developer experience (DX)

  • One-line install and small runtime make adoption trivial.
  • Hooks for React/Vue and an example Next.js app make getting started fast.
  • Inspector provides live remote inspection, persisted registrations across restarts, and simple token/origin controls for basic security.

CI and stability

There is a small CI workflow that runs tests and builds on push and pull requests; it helps keep the package stable. See .github/workflows/ci.yml for details.

Examples and templates

Look in examples/ for working integrations (Next.js example and a small inspector client). Contributing templates and migration recipes are planned to make adoption even easier.

Contributing

See CONTRIBUTING.md for contribution guidelines and release notes.

CI

Small utility-first state library and tooling.

Testing

  • Tests are run with Vitest. There is a global testTimeout configured in vitest.config.ts set to 20000ms to allow network/socket tests (inspector) to be stable in CI.
  • The inspector integration test opens a local WebSocket, requests a snapshot and verifies that stores are included. The test runs quietly in CI by default (the inspector server is created with quiet: true).

Run tests locally:

npm ci
npm run build
npm test

Inspector (dev tooling)

Fortistate ships a lightweight inspector that runs an HTTP + WebSocket server (default port 4000, examples use 4555).

Start the inspector:

# from the fortistate package root
node dist/cli.js inspect 4555

Options:

  • --token โ€” require requests to include header x-fortistate-token for /register and /change
  • --allow-origin โ€” set Access-Control-Allow-Origin for CORS (useful for browser clients)

Dev helper:

  • GET /set-token โ€” small HTML form to set a token for local dev
  • POST /set-token โ€” accepts JSON or form-encoded token and saves .fortistate-inspector-token in working dir (dev only)

Snapshots and persistence:

  • Remote registrations are stored in .fortistate-remote-stores.json and loaded at inspector startup.

Collaboration & security:

  • Set FORTISTATE_REQUIRE_SESSIONS=1 to require session tokens for write endpoints and WebSocket connections. Create sessions via POST /session/create (roles: observer, editor, admin).
  • The inspector issues JWT-based sessions by default; provide FORTISTATE_SESSION_SECRET to persist tokens across restarts (otherwise ephemeral secret is generated).
  • Audit entries are appended to .fortistate-audit.log (JSON Lines). Admin sessions can retrieve recent entries via GET /audit/log?limit=<n>&format=<json|csv|plain>. Logs rotate automatically by size (default: 1 MB) or age (default: 30 days); configure with FORTISTATE_AUDIT_MAX_SIZE (bytes) and FORTISTATE_AUDIT_ROTATE_DAYS.
  • Admins can clean up access with POST /session/revoke, passing either a sessionId or token to invalidate.
  • New: Role-based middleware simplifies endpoint guards. See docs/AUTHENTICATION.md for comprehensive auth documentation and security best practices.

Release notes โ€” v1.0.1

  • Inspector: added persistence for remote-registered stores, token support, CORS/allow-origin support, and a small dev token setter UI.
  • CLI: added --token and --allow-origin flags for inspect command.
  • Example: Next.js example auto-registers demo counter to the inspector for easier testing.

What's new (latest)

  • Embedded inspector client: safer event wiring (no inline onclick code), modernized UI, and a new store filter input for easier navigation.
  • Auto-swap detection: the inspector can now heuristically detect the host app's active store key (URL param, data-active-key, or common names) and swap stores without manual key entry.
  • Presets & CSS: apply presets remotely; installer helper can optionally write a preset's CSS into the project. The inspector UI now has clearer apply / install CSS buttons.
  • Favicon support: inspector serves /favicon.ico from the project root if present (or a packaged fallback), so you can set a custom icon.
  • Example fixes: Next.js demo now reflects the selected store in the header and actions (inc/dec/reset) operate on the selected store.

Publishing a release (npm + GitHub)

  1. Bump the package version in package.json (semver). Example to set v1.0.2:
npm version patch -m "release: v%s"
  1. Build the package and run tests:
npm run build
npm test
  1. Dry-run publish to check packaged files:
npm publish --dry-run
  1. Publish to npm and push a git tag (example using npm to publish):
npm publish
git push origin --follow-tags
  1. Create a GitHub release (optional) and attach the changelog/notes. If you want, I can automatically create a release for you after publishing.

Notes:

  • If your project uses a CI workflow to publish from tags (recommended), consider adding a GitHub Actions workflow to publish on semantic version tags. I can add a sample workflow if you'd like.