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

@magfur-alam/core

v0.1.0

Published

Framework-agnostic builder engine: node tree, registry, history, state, serialization. No UI, no React.

Downloads

184

Readme

@magfur-alam/core

Framework-agnostic builder engine: the node tree, undo/redo history, the element registry, Zod-based serialization, style resolution, and URL sanitization. No React, no DOM — this package is safe to import from a Node script, a server realm, or any other JS environment, and it's what makes the engine reusable outside React someday without a rewrite.

Part of the Next.js Database-Backed Visual Page Builder monorepo — see the root README for the full architecture and PLAN.md for how this package was built, phase by phase.

Install

npm install @magfur-alam/core

What's in here

  • Tree ops (addNode, removeNode, moveNode, duplicateNode, pasteNode, replaceNode) — pure, Immer-backed functions operating on a PageDocument. Structural sharing means an edit to one node leaves every other node's object reference untouched, which is what lets consumers (like @magfur-alam/react's <PageRenderer>) skip re-rendering unaffected subtrees.
  • createPageBuilderStore() — a Zustand vanilla store (not React-bound) wrapping the tree ops with selection-independent state, undo/redo (100-step history, rapid same-node edits coalesced into one step), and clipboard actions.
  • The element registry (registerElement, getElement, defaultElementRegistry) — a globalThis-keyed singleton so it survives being imported from more than one bundle/realm (CJS+ESM, server+browser) without silently duplicating itself.
  • Serialization (parsePageDocument, serializePageDocument, deserializePageDocument) — Zod schemas validating every incoming page JSON blob, including a guard that rejects any props bag containing a dangerouslySetInnerHTML or bare __html key at any nesting depth (there is no raw-HTML element in this model).
  • Styling (stylesToCss, resolveStyleValue, GlobalStyleTokens) — a responsive (desktop/tablet/mobile, with fallback) style schema and a resolver that turns it into inline CSS.
  • Security (isSafeUrl, sanitizeUrl) — a URL scheme allowlist (http:/https:/mailto:/tel:/relative), with data:image/* allowed only opt-in and data:image/svg+xml excluded even then (SVG can carry <script>/onload= even served as an "image").

Usage

import { createEmptyDocument, createNode, addNode, createPageBuilderStore, registerElement } from "@magfur-alam/core";

registerElement({
  type: "heading",
  label: "Heading",
  category: "Basic",
  component: MyHeadingComponent, // from @magfur-alam/elements, or your own
});

const store = createPageBuilderStore({ document: createEmptyDocument() });
const node = createNode("heading", { props: { text: "Hello" } });
store.getState().addNode(node, store.getState().document.root.id);

Most apps won't call this package directly — @magfur-alam/react renders its documents, @magfur-alam/editor provides the editing UI, and @magfur-alam/next persists them. This package is the shared foundation underneath all three.