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

@bedrock-server-manager/storage

v0.1.0

Published

Validated, versioned Bedrock Server Manager preferences with injectable persistence

Readme

BSM preference storage

A reusable package for validated, versioned preferences. Persistence and change notifications are injected; the package does not use browser globals. It does not manage credentials.

npm install @bedrock-server-manager/storage

Basic usage

This example uses instance-local memory:

import { createPreferenceStore } from "@bedrock-server-manager/storage";

const store = createPreferenceStore(undefined, {
  density: {
    version: 1,
    validate: (value) =>
      typeof value === "string" && ["comfortable", "compact"].includes(value),
  },
});
const identity = JSON.stringify(["https://bsm.example", "user-1"]);

store.write(identity, "density", "compact");
console.log(store.read(identity, "density", "comfortable")); // compact

Use an identity containing both backend and account information when values must be isolated between connections. getSessionStorageKey is also exported for consistent key construction. Empty identities do not produce preference keys.

Persistence and subscriptions

createPreferenceStore(storage, definitions, events) accepts these adapters:

| Adapter | Methods | | --------- | ----------------------------------------------------------------------------------- | | storage | Synchronous getItem(key), setItem(key, value), and removeItem(key) | | events | Optional addEventListener("storage", callback) and matching removeEventListener |

Stored values use a JSON envelope containing version and value. The frontend supplies browser persistence through its frontend/src/app/preferenceStore.js adapter. If storage is omitted or a persistence operation fails, values fall back to memory within that store instance. They do not survive creating a new instance.

subscribe(identity, name, callback) returns an unsubscribe function. Local writes notify subscribers. External storage events provide a key; a null key indicates a full clear. The store attaches an external listener only while subscribers exist and removes it after the final subscription ends.

Validation and migrations

A preference definition may provide:

  • version: the current stored version, defaulting to 1.
  • validate(value): validation applied before writes and when reading values.
  • migrations: functions indexed by the previous version number.

A migration transforms the previous value into the next version's value. The store applies migrations one version at a time, validates the result, and writes the updated envelope. Invalid data, missing migration steps, or an unsupported stored version return the caller's fallback value.

read can also receive a caller-specific validator. write and remove return whether the operation was accepted; a successful write may have used memory fallback rather than persistent storage. Subscriber failures are isolated so a completed write still returns normally and other observers are notified.

Workspace commands

From the repository root:

npm run build --workspace=@bedrock-server-manager/storage
npm run check --workspace=@bedrock-server-manager/storage

Installation prepares dist/; rebuild it after changing source. The package owns its tests, lint, and consumer type checks. GitHub releases tagged storage-v<SemVer> publish this package independently; prereleases use npm's next distribution tag.