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

be-hive

v0.1.15

Published

Specify that ShadowDOM should inherit be-hiviors from the Custom Element Registry Scope

Readme

be-hive

Published on webcomponents.org How big is this package in your project? NPM version

Overview

be-hive lets it snow in August.

be-hive is the coordination layer for the family of HTML enhancements that follow the "be-enhanced" pattern. It extends the mount-observer Synthesizer class, providing a declarative custom element (<be-hive>) for registering and managing element enhancements within Shadow DOM scopes.

In the modern architecture, be-hive serves as:

  1. A custom element (<be-hive>) that acts as a registry point inside a Shadow DOM realm
  2. A host for EMC (Enhancement Mount Configuration) scripts that declare which enhancements are active
  3. A parser host for registering attribute parsers used by enhancements
  4. A utility provider (e.g. findAdjacentElement) for enhancement implementations

How It Works

The BeHive class extends Synthesizer from mount-observer:

import {Synthesizer} from 'mount-observer/Synthesizer.js';

export class BeHive extends Synthesizer{}

customElements.define('be-hive', BeHive);

When placed inside a Shadow DOM realm, <be-hive> processes its child <script> elements to configure which enhancements are active in that scope.

Registering Enhancements

Enhancements are registered declaratively using <script type=emc> tags inside <be-hive>:

<be-hive>
    <script type=emc src="be-clonable/emc.json"></script>
    <script type=emc src="be-committed/emc.json"></script>
</be-hive>
<script type=module>
    import 'be-hive/be-hive.js';
</script>

Each <script type=emc> points to a JSON configuration file (generated from an emc.mjs build script) that tells be-hive how to observe, parse, and spawn the enhancement.

The EMC (Enhancement Mount Configuration)

Each enhancement project provides an EMC that defines:

  • enhKey: The unique identifier / attribute name for the enhancement
  • spawn: The module path to lazily import the enhancement class
  • withAttrs: How to map HTML attributes to enhancement properties

Example emc.mjs:

export const emc = {
    enhConfig: {
        enhKey: 'BeClonable',
        spawn: 'be-clonable/be-clonable.js',
        withAttrs: {
            base: 'be-clonable',
            triggerInsertPosition: '${base}-trigger-insert-position',
        }
    },
    customData: {
        weakRef: {
            properties: ['enhancedElement']
        },
        actions: {
            addCloneBtn: { ifAllOf: ['triggerInsertPosition', 'enhancedElement'] }
        },
        defaultPropVals: {
            triggerInsertPosition: 'beforebegin'
        }
    }
};

export function render(){
    return JSON.stringify(emc, null, 4);
}

console.log(render());

Running node emc.mjs > emc.json generates the static JSON configuration that <be-hive> loads at runtime.

Custom Parsers

For enhancements with complex attribute syntax, be-hive provides built-in parser wrappers that integrate with the nested-regex-groups library:

  • be-hive/parsers/parse-pattern-statements.js — for nested object structures using dot notation in capture groups
  • be-hive/parsers/parse-grouped-capture-statements.js — for flat objects parsed from multiple statements

Register parsers in HTML before loading EMC scripts that depend on them:

<be-hive>
    <script type=emc-parser 
            src="be-hive/parsers/parse-pattern-statements.js" 
            parser-name=parse-pattern-statements></script>
    <script type=emc 
            src="do-invoke/emc.json" 
            wait-for-parsers=parse-pattern-statements></script>
</be-hive>
<script type=module>
    import 'be-hive/be-hive.js';
</script>

Emoji Shorthand

Many enhancements support both a full name and an emoji shorthand (e.g. be-clonable / ). A separate .mjs file generates a variant JSON that overrides the enhKey and base attribute:

<!-- Full name -->
<div be-clonable>...</div>

<!-- Emoji shorthand -->
<div ⿻>...</div>

Both resolve to the same enhancement class; only the observed attribute name differs.

Utilities

be-hive also provides utilities used by enhancement implementations:

findAdjacentElement

Finds an element adjacent to a given element based on an InsertPosition and CSS selector:

import {findAdjacentElement} from 'be-hive/findAdjacentElement.js';

const trigger = findAdjacentElement('beforebegin', element, '.my-trigger');

Exports

| Path | Description | |------|-------------| | be-hive/be-hive.js | The BeHive custom element (extends Synthesizer) | | be-hive/findAdjacentElement.js | Adjacent element lookup utility | | be-hive/parsers/parse-pattern-statements.js | Parser for nested object structures | | be-hive/parsers/parse-grouped-capture-statements.js | Parser for flat object structures |

Dependencies

  • mount-observer — Provides the Synthesizer base class and the MountObserver infrastructure for watching DOM mutations and spawning enhancements
  • nested-regex-groups — Regex-based attribute parsing library used by the built-in parsers

Related Projects

Key packages in the enhancement ecosystem:

Example enhancements built on this architecture:

Viewing Locally

  1. Install git
  2. Fork/clone this repo
  3. Install node.js
  4. Open command window to folder where you cloned this repo
  5. > git submodule update --init --recursive
  6. > npm install
  7. > npm run serve (requires a static file server with SSI support)
  8. Open http://localhost:8000/demo/ in a modern browser (Chrome 146+ recommended for JSON import assertions)