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

@prismui/core

v0.2.0

Published

Core runtime kernel and type system for PrismUI - Event-driven architecture with module system

Readme

@prismui/core

Framework-agnostic event-driven runtime kernel for modern web applications

npm version License: MIT

Overview

@prismui/core is the runtime kernel of PrismUI - a pure, framework-agnostic state management runtime with comprehensive governance capabilities. It provides event-driven architecture, modular state management, and built-in interaction modules.

Zero dependenciesFull TypeScript supportFramework-agnostic

Installation

npm install @prismui/core

Features

Core Runtime

  • EventBus: Event-driven communication with history tracking
  • RuntimeStore: Immutable state management with snapshots
  • Scheduler: Reducer-based event processing with middleware pipeline
  • Module System: Pluggable architecture with lifecycle hooks

Governance Layer

  • Audit Trail: Complete event and state change tracking
  • Replay System: Time-travel debugging
  • Policy Engine: Rule-based event validation
  • Priority Scheduler: Event prioritization with conflict resolution

Built-in Modules

  • Page Module: Page navigation and transition management
  • Modal Module: Modal stack management
  • Drawer Module: Drawer positioning and stack management
  • Notification Module: Toast notification system
  • Form Module: Form state with validation and submission lifecycle
  • Async Module: Async operation tracking with loading/success/error states

Interaction DSL

  • Unified API: ui.* namespace wrapping all module controllers
  • Promise-based: ui.confirm() returns Promise<boolean>
  • Type-safe: Full TypeScript autocomplete

DevTools & Automation

  • DevTools Module: Optional instrumentation for runtime inspection
  • Event Timeline: Middleware-based event timing with filtering
  • Performance Monitor: Throughput, latency, per-type stats
  • State Snapshots: Capture, compare (diff), and export
  • AI Agent Interface: Programmatic dispatch, sequence execution, state waiting

Quick Start

import {
  createInteractionRuntime,
  createPageModule,
  createModalModule,
  createNotificationModule,
} from "@prismui/core";

// Create runtime with modules
const runtime = createInteractionRuntime({
  modules: [
    createPageModule(),
    createModalModule(),
    createNotificationModule(),
  ],
});

// Use module controllers
runtime.modules.page?.transition("dashboard");
runtime.modules.modal?.open("confirm");
runtime.modules.notification?.notify({
  type: "success",
  message: "Operation completed!",
});

// Or use the unified DSL
import { createInteractionDSL } from "@prismui/core";

const ui = createInteractionDSL(runtime);
ui.page.go("dashboard");
ui.modal.open("confirm");
ui.notify.success("Operation completed!");

// Promise-based confirmation
const confirmed = await ui.confirm("deleteDialog");
if (confirmed) {
  console.log("User confirmed");
}

Module System

Create custom modules to extend the runtime:

import { RuntimeModule } from "@prismui/core";

interface MyModuleState {
  myData: string;
}

const createMyModule = (): RuntimeModule<MyModuleState, any> => ({
  name: "myModule",

  initialState: {
    myData: "initial",
  },

  reducers: {
    MY_EVENT: (state, event) => ({
      ...state,
      myData: event.payload,
    }),
  },

  controller: (runtime) => ({
    updateData: (data: string) => {
      runtime.dispatch({ type: "MY_EVENT", payload: data });
    },
  }),

  onInit: (runtime) => {
    console.log("Module initialized");
  },

  onDestroy: () => {
    console.log("Module destroyed");
  },
});

Governance

Audit Trail

import { createAuditMiddleware } from '@prismui/core';

const audit = createAuditMiddleware();
const runtime = createInteractionRuntime({
  modules: [...],
  middleware: [audit],
});

// Query audit entries
const entries = audit.getEntries({ eventType: 'MODAL_OPEN' });
console.log(entries);

Policy Engine

import { createPolicyMiddleware } from '@prismui/core';

const policy = createPolicyMiddleware();
policy.addRule({
  name: 'preventModalSpam',
  condition: (event) => event.type === 'MODAL_OPEN',
  action: 'block',
  reason: 'Too many modals',
});

const runtime = createInteractionRuntime({
  modules: [...],
  middleware: [createPolicyMiddleware(policy, runtime.store)],
});

State Selectors

Efficiently subscribe to partial state:

import { createSelector } from "@prismui/core";

const selectModalStack = createSelector(
  (state) => state.modalStack,
  (modalStack) => modalStack.length,
);

const unsubscribe = runtime.store.subscribe((state) => {
  const count = selectModalStack(state);
  console.log("Modal count:", count);
});

TypeScript Support

Full TypeScript definitions included:

import type {
  InteractionRuntime,
  RuntimeModule,
  RuntimeEvent,
  RuntimeState,
  EventBus,
  RuntimeStore,
  Scheduler,
  InteractionDSL,
} from "@prismui/core";

React Integration

For React applications, use @prismui/react:

npm install @prismui/react @prismui/core

See @prismui/react for React-specific hooks and components.

API Documentation

Core Exports

  • createInteractionRuntime(config) - Create runtime instance
  • createInteractionDSL(runtime) - Create unified DSL API

Module Factories

  • createPageModule() - Page navigation module
  • createModalModule() - Modal management module
  • createDrawerModule() - Drawer management module
  • createNotificationModule() - Notification module
  • createFormModule() - Form state module
  • createAsyncModule() - Async operation module

Governance

  • createAuditMiddleware() - Audit trail middleware
  • createReplaySystem(audit) - Replay system
  • createPolicyMiddleware(policy, store) - Policy engine middleware
  • createPriorityScheduler() - Priority-based scheduler

Utilities

  • createSelector(selector, transform?) - Memoized state selector
  • waitFor(runtime, condition, options?) - Wait for state condition

DevTools

  • createDevToolsModule(options?) - DevTools instrumentation module
  • createRuntimeInspector(runtime) - Standalone runtime inspector
  • buildStateTree(key, value) - Build structured state tree
  • diffSnapshots(a, b) - Compare two snapshots

Package Info

Links

License

MIT © Fangjun