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

@minimact/core

v0.1.2

Published

Client-side runtime for Minimact framework - Available in lightweight (SignalM) and full (SignalR) versions

Downloads

11

Readme

Minimact Client Runtime

Client-side JavaScript/TypeScript runtime for the Minimact framework. Handles DOM patching, SignalR communication, client state management, and hybrid rendering.

Architecture

┌─────────────────────────────────────────────────────────────┐
│                   Minimact Client Runtime                    │
│                                                             │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐     │
│  │  SignalR     │  │  DOMPatcher  │  │ ClientState  │     │
│  │  Manager     │  │              │  │  Manager     │     │
│  └──────┬───────┘  └──────┬───────┘  └──────┬───────┘     │
│         │                 │                  │              │
│         └─────────┬───────┴──────────────────┘              │
│                   │                                         │
│         ┌─────────▼─────────┐                               │
│         │   Minimact Core    │                               │
│         │  (Orchestrator)   │                               │
│         └─────────┬─────────┘                               │
│                   │                                         │
│         ┌─────────▼─────────┐  ┌──────────────┐            │
│         │   Hydration       │  │    Event     │            │
│         │   Manager         │  │  Delegation  │            │
│         └───────────────────┘  └──────────────┘            │
└─────────────────────────────────────────────────────────────┘

Features

SignalR Integration - Real-time bidirectional communication with server ✅ DOM Patching - Surgical DOM updates from server-generated patches ✅ Client State - Local reactive state (useClientState) without server round-trips ✅ Hybrid Rendering - Smart partitioning of client/server/mixed zones ✅ Event Delegation - Efficient event handling with single root listener ✅ Hydration - Attach interactivity to server-rendered HTML ✅ TypeScript - Full type safety and IDE support

Installation

npm install
npm run build

This generates:

  • dist/minimact.js - IIFE bundle for browsers
  • dist/minimact.esm.js - ES module bundle
  • dist/minimact.d.ts - TypeScript definitions

Usage

Basic Setup

<!DOCTYPE html>
<html>
<body data-minimact-auto-init>
  <!-- Component rendered by server -->
  <div data-minimact-component="counter-1">
    <h1>Count: <span data-bind="count">0</span></h1>
    <button data-onclick="Increment">+</button>
  </div>

  <!-- Include SignalR -->
  <script src="https://cdn.jsdelivr.net/npm/@microsoft/[email protected]/dist/browser/signalr.min.js"></script>

  <!-- Include Minimact -->
  <script src="minimact.js"></script>
</body>
</html>

The data-minimact-auto-init attribute automatically starts Minimact on page load.

Manual Initialization

import Minimact from 'minimact-client';

const minimact = new Minimact(document.body, {
  hubUrl: '/minimact',
  enableDebugLogging: true,
  reconnectInterval: 5000
});

await minimact.start();

Client State (useClientState)

<!-- Client-only zone - no server round-trips -->
<div data-minimact-client-scope>
  <input data-state="username" placeholder="Username" />
  <p>Hello, <span data-bind="username"></span>!</p>
</div>

The input updates instantly on every keystroke, with ~1ms latency.

Server State

<!-- Server-controlled zone -->
<div data-minimact-server-scope>
  <button data-onclick="LoadData">Load</button>
  <p>Items: <span data-bind="itemCount">0</span></p>
</div>

Button clicks trigger server methods, updates arrive via SignalR patches (~47ms latency).

Hybrid Rendering

<!-- Mixed dependencies - smart span splitting -->
<p>
  Found
  <span data-minimact-server-scope data-bind="resultCount">0</span>
  results for
  "<span data-minimact-client-scope data-bind="query"></span>"
</p>

Each span updates independently - client span instantly, server span on data changes.

API Reference

Minimact Class

class Minimact {
  constructor(rootElement: HTMLElement | string, options?: MinimactOptions);

  // Lifecycle
  start(): Promise<void>;
  stop(): Promise<void>;

  // Component management
  hydrateComponent(componentId: string, element: HTMLElement): void;

  // Client state
  getClientState(componentId: string, key: string): any;
  setClientState(componentId: string, key: string, value: any): void;
  subscribeToState(componentId: string, key: string, callback: (value: any) => void): () => void;

  // Connection info
  get connectionState(): string;
  get connectionId(): string | null;
}

Options

interface MinimactOptions {
  hubUrl?: string;                 // Default: '/minimact'
  enableDebugLogging?: boolean;    // Default: false
  reconnectInterval?: number;      // Default: 5000ms
}

Data Attributes

Component Markers

  • data-minimact-component="id" - Marks a component root
  • data-minimact-component-id="id" - Set during hydration

Zone Markers

  • data-minimact-client-scope - Pure client zone (no server communication)
  • data-minimact-server-scope - Pure server zone (patch-controlled)
  • Neither attribute = hybrid zone (contains both)

State Binding

  • data-state="key" - Bind input element to client state key
  • data-bind="key" - Bind element content to state key
  • data-bind-html - Bind using innerHTML instead of textContent

Event Handlers

  • data-onclick="MethodName" - Click event → server method
  • data-oninput="MethodName" - Input event → server method
  • data-onchange="MethodName" - Change event → server method
  • Format: MethodName or MethodName:arg1:arg2

Examples

See examples/ folder:

  1. counter.html - Basic counter with server state
  2. hybrid-rendering.html - Demonstrates client/server/hybrid zones

Performance

| Operation | Latency | Description | |-----------|---------|-------------| | Client state update | ~1ms | Local DOM manipulation only | | Server state update | ~47ms | SignalR round-trip + Rust reconciliation | | Hybrid update | ~1ms + ~47ms | Each zone updates independently |

Development

# Install dependencies
npm install

# Build for production
npm run build

# Watch mode
npm run dev

# Run tests (when implemented)
npm test

Project Structure

client-runtime/
├── src/
│   ├── index.ts                 # Main entry point
│   ├── signalr-manager.ts       # SignalR connection management
│   ├── dom-patcher.ts           # DOM patching engine
│   ├── client-state.ts          # Client state management
│   ├── event-delegation.ts      # Event handling
│   ├── hydration.ts             # Server HTML hydration
│   └── types.ts                 # TypeScript definitions
├── examples/
│   ├── counter.html             # Basic example
│   └── hybrid-rendering.html    # Advanced example
├── dist/                        # Build output
├── package.json
├── tsconfig.json
└── rollup.config.js

Browser Support

  • Modern browsers with ES2020 support
  • SignalR WebSocket or SSE support
  • Tested on Chrome 90+, Firefox 88+, Safari 14+, Edge 90+

Integration with Server

The client runtime expects:

  1. SignalR Hub at /minimact (configurable)
  2. Component registration via RegisterComponent(componentId)
  3. Patch format matching Rust reconciliation engine output
  4. Method invocation via InvokeComponentMethod(componentId, methodName, argsJson)

See Minimact.AspNetCore C# project for server implementation.

Debugging

Enable debug logging:

<body data-minimact-auto-init data-minimact-debug>

Or programmatically:

const minimact = new Minimact(document.body, {
  enableDebugLogging: true
});

Console output includes:

  • SignalR connection events
  • DOM patch operations
  • Client state changes
  • Event delegation triggers
  • Hydration progress

License

MIT