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

@mr_hugo/boredom

v0.25.25

Published

Another boring JavaScript framework.

Readme

boreDOM

A JavaScript framework for building reactive web components with template-based architecture and automatic state synchronization.

Features

  • 🥱 Reactive State Management - Automatic DOM updates when state changes
  • 🥱 Template-based Components - Define components using HTML templates with data-component attributes
  • 🥱 Hot Module Reloading - Built-in dev server with file watching and auto-reload
  • 🥱 Zero Configuration - Works out of the box with sensible defaults
  • 🥱 CLI Tools - Development server and build tools included
  • 🥱 TypeScript Support - Full TypeScript definitions included
  • 🥱 Project Generator - Quick project scaffolding with create-boredom

Quick Start

Installation

# Install the framework
pnpm install @mr_hugo/boredom

# Or create a new project
npx create-boredom my-app
cd my-app
pnpm dev

Basic Usage

  1. Create an HTML file with component templates:
<!DOCTYPE html>
<html>
  <head>
    <title>My boreDOM App</title>
  </head>
  <body>
    <h1>Counter Example</h1>
    <simple-counter></simple-counter>

    <template data-component="simple-counter">
      <div>
        <p>Count: <slot name="counter">0</slot></p>
        <button onclick="['increase']">+</button>
        <button onclick="['decrease']">-</button>
      </div>
    </template>

    <script src="main.js" type="module"></script>
  </body>
</html>
  1. Create the component logic in JavaScript:
// main.js
import { inflictBoreDOM, webComponent } from "@mr_hugo/boredom";

// Initialize with state
const uiState = await inflictBoreDOM({ count: 0 });

// simple-counter.js (or inline)
export const SimpleCounter = webComponent(({ on }) => {
  on("increase", ({ state }) => {
    state.count += 1;
  });

  on("decrease", ({ state }) => {
    state.count -= 1;
  });

  return ({ state, slots }) => {
    slots.counter = state.count;
  };
});

Development Server

boreDOM includes a built-in development server with hot reloading:

# Start dev server (watches for changes)
npx boredom

# Custom options
npx boredom --index ./src/index.html --html ./components --static ./public

The CLI will:

  • Watch for file changes in components, HTML, and static files
  • Automatically rebuild and inject components
  • Serve your app with hot reloading
  • Copy static files to the build directory

API Reference

Core Functions

inflictBoreDOM(initialState, componentsLogic?)

Initializes the boreDOM framework and creates reactive state.

  • initialState - Initial application state object
  • componentsLogic - Optional inline component definitions
  • Returns - Proxified reactive state object
const state = await inflictBoreDOM({
  users: [],
  selectedUser: null,
});

webComponent(initFunction)

Creates a web component with reactive behavior.

  • initFunction - Component initialization function
  • Returns - Component definition for use with boreDOM
const MyComponent = webComponent(({ on, state, refs, self }) => {
  // Setup event handlers
  on("click", ({ state }) => {
    state.clicked = true;
  });

  // Return render function
  return ({ state, slots, refs }) => {
    slots.content = `Clicked: ${state.clicked}`;
  };
});

Component API

Components receive these parameters:

Initialization Phase

  • on(eventName, handler) - Register event listeners
  • state - Reactive state accessor
  • refs - DOM element references
  • self - Component instance
  • detail - Component-specific data

Render Phase

  • state - Current state (read-only in render)
  • slots - Named content slots for the template
  • refs - DOM element references
  • makeComponent(tag, options) - Create child components

Template Syntax

Templates use standard HTML with special attributes:

<template data-component="my-component">
  <!-- Named slots for dynamic content -->
  <div>
    <h2><slot name="title">Default Title</slot></h2>
    <p><slot name="content">Default content</slot></p>
  </div>

  <!-- Event dispatching -->
  <button onclick="['save']">Save</button>
  <button onclick="['cancel']">Cancel</button>

  <!-- Reference elements -->
  <input ref="userInput" type="text">
</template>

How Templates Become Components

  1. Declare a template with a tag name
<simple-counter></simple-counter>

<template data-component="simple-counter" data-aria-label="Counter">
  <p>Count: <slot name="count">0</slot></p>
  <button onclick="['increment']">+</button>
  <button onclick="['decrement']">-</button>
  <!-- Any other data-* on the template is mirrored to the element -->
  <!-- e.g., data-aria-label -> aria-label on <simple-counter> -->
  <!-- Add shadowrootmode="open" to render into a ShadowRoot -->
  <!-- <template data-component=\"simple-counter\" shadowrootmode=\"open\"> -->

  <!-- Optional: external script for behavior -->
  <script type="module" src="/simple-counter.js"></script>
</template>
  1. Provide behavior (first export is used)
// /simple-counter.js
import { webComponent } from "@mr_hugo/boredom";

export const SimpleCounter = webComponent(({ on }) => {
  on("increment", ({ state }) => {
    state.count += 1;
  });
  on("decrement", ({ state }) => {
    state.count -= 1;
  });
  return ({ state, slots }) => {
    slots.count = String(state.count);
  };
});
  1. Initialize once
import { inflictBoreDOM } from "@mr_hugo/boredom";
await inflictBoreDOM({ count: 0 });

What happens under the hood

  • The runtime scans <template data-component> and registers custom elements.
  • It mirrors template data-* to host attributes and wires inline onclick="['...']" to custom events ("[]" is the dispatch action).
  • Scripts are dynamically imported and run for every matching instance in the DOM (including multiple instances).
  • Subsequent instances created programmatically use the same initialization via makeComponent().

State and Subscriptions

Rendering subscribes to the state paths it reads, and mutations trigger batched updates.

import { inflictBoreDOM, webComponent } from "@mr_hugo/boredom";

export const Counter = webComponent(({ on }) => {
  on("inc", ({ state }) => {
    state.count++;
  }); // mutable state in handlers
  return ({ state, slots }) => { // read-only during render
    slots.value = String(state.count); // reading subscribes to `count`
  };
});

await inflictBoreDOM({ count: 0 });
  • Subscriptions: Any property read in render (e.g., state.count) registers that render as a subscriber to that path.
  • Mutations: Changing arrays/objects (e.g., state.todos.push(...), state.user.name = 'X') schedules a single rAF to call subscribed renders.
  • Scope: Subscriptions are per component instance; only components that read a path re-render when that path changes.

Project Structure

A typical boreDOM project structure:

my-app/
├── index.html              # Main HTML file
├── main.js                 # App initialization
├── components/             # Component files
│   ├── user-card.html      # Component template
│   ├── user-card.js        # Component logic
│   └── user-card.css       # Component styles
├── public/                 # Static assets
│   └── assets/
└── build/                  # Generated build files

Examples

Counter Component

const Counter = webComponent(({ on }) => {
  on("increment", ({ state }) => state.count++);
  on("decrement", ({ state }) => state.count--);

  return ({ state, slots }) => {
    slots.value = state.count;
  };
});

Todo List Component

const TodoList = webComponent(({ on }) => {
  on("add-todo", ({ state, e }) => {
    state.todos.push({ id: Date.now(), text: e.text, done: false });
  });

  on("toggle-todo", ({ state, e }) => {
    const todo = state.todos.find((t) => t.id === e.id);
    if (todo) todo.done = !todo.done;
  });

  return ({ state, slots, makeComponent }) => {
    slots.items = state.todos.map((todo) =>
      makeComponent("todo-item", { detail: { todo } })
    ).join("");
  };
});

CLI Reference

# Development server with file watching
npx boredom [options]

Options:
  --index <path>     Base HTML file (default: index.html)
  --html <folder>    Components folder (default: components)  
  --static <folder>  Static files folder (default: public)

TypeScript Support

boreDOM includes full TypeScript definitions:

import { inflictBoreDOM, webComponent } from "@mr_hugo/boredom";

interface AppState {
  count: number;
  users: User[];
}

const state = await inflictBoreDOM<AppState>({
  count: 0,
  users: [],
});

const MyComponent = webComponent<AppState>(({ on, state }) => {
  // TypeScript will infer correct types
  on("increment", ({ state }) => {
    state.count++; // ✓ Type-safe
  });

  return ({ state, slots }) => {
    slots.count = state.count.toString();
  };
});

Resources

License