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

@popcraft/plugins

v1.7.0

Published

The PopCraft plugin SDK: the sandbox runtime the editor injects, and the types plugin authors build against.

Readme

@popcraft/plugins

The PopCraft plugin SDK — and the example plugins that use it.

npm i -D @popcraft/plugins
/// <reference types="@popcraft/plugins" />

const selection = await popcraft.getSelection()
await popcraft.notify(`${selection.length} selected`)
await popcraft.closePlugin()

Full developer guide: https://popcraft.app/docs/plugins.

What is in here

| | | | --- | --- | | src/runtime/ | The popcraft global itself — the RPC client, the main-script API, the UI shim. Compiled to a self-contained IIFE and injected into the plugin sandbox by the editor. | | src/host.ts | buildMainDocument / buildUIDocument: the sandboxed documents, with their CSP. | | src/types.ts, src/widget.ts | The manifest, node and widget types. | | examples/ | One example of every marketplace kind, published to the marketplace by CI. Not in the npm package. | | scripts/publish.mjs | Builds and publishes the examples (see Publishing). |

The types are generated, not written. dist/generated/global.d.ts declares the ambient popcraft global as PopCraftApi, which is ReturnType<typeof createMainApi> — the type of the object the runtime actually builds. Change a method and its published type changes with it; there is no second description to keep in step.

The examples

One folder per marketplace kind:

| Folder | Kind | Examples | | --- | --- | --- | | plugins/ | Plugins | arrange-grid (commands, a UI, storage), rename-layers (UI panel, events, storage), contrast-checker (WCAG checks, findNodes, setSelection), pop-palette (paint styles), storefront-preview (a File → Export format built on getStorefront()) | | widgets/ | Canvas widgets (plugins that register a widget) | vote-counter, poll, checklist (named handlers) | | themes/ | Theme packs (data-only plugins) | comic-themes (two light themes), comic-noir (semi-dark) | | brushes/ | Brush packs | comic-inkers: liner, brush pen, stipple | | shaders/ | Shader packs | pop-shaders: Ben-Day dots, speed burst, misregistration (one .wgsl per shader) | | templates/ | Templates | pop-cover, halftone-quote, comic-kanban, pixel-platformer (a playable game: layers with physics roles) |

Component libraries are the one kind with no example here: a library is published from a cloud file in the editor (Assets → Publish library), not from files in a repo.

Install one from Main menu → Manage plugins… → Install from file…, with either a .zip of the folder (manifest.json at the root) or a single-file .json bundle: { "manifest": { … }, "main": "…code…", "ui": "<html>…" }.

Importers and exporters

A plugin can add a File → Import or File → Export format in its manifest:

"contributes": {
  "importers": [{ "id": "pub", "label": "Publisher (.pub)", "accept": [".pub"] }],
  "exporters": [{ "id": "ai", "label": "Adobe Illustrator (.ai)", "extension": ".ai" }]
}

An importer runs with popcraft.importMode and popcraft.importFile set, and builds the document with the editor methods. An exporter runs with popcraft.exportRequest set, renders what it needs with exportNode, and hands the file back with popcraft.saveExport({ name, bytes }).

An exporter for a store reads the open page as a storefront with popcraft.getStorefront(): each page's HTML with the store's data marked rather than filled ({{page.title}}, {{item.price}}, lists between <!-- pc:each list="Products" schema="commerce.product" as="item" --> and <!-- pc:end -->, forms with data-pc-action), and the collections it reads with their schema and sample records. It turns those marks into its platform's templates; storefront-preview fills them with the samples instead.

Publishing to the marketplace

Each item folder holds one of manifest.json (a plugin, widget or theme pack), pack.json (a brush or shader pack: { meta, payload }, images and .wgsl files referenced by path) or template.json ({ meta, payload }). scripts/publish.mjs turns each folder into what the REST API takes and posts it:

node scripts/publish.mjs --dry-run                     # build and check everything
POPCRAFT_TOKEN=pop_… node scripts/publish.mjs          # publish

The Marketplace workflow runs the dry run on pull requests and publishes on main. It needs:

  • the secret POPCRAFT_TOKEN: a personal access token (Account → Personal access tokens) with the marketplace:publish scope, owned by the account the listings should belong to;
  • optionally the variable POPCRAFT_URL to target another deployment (default https://popcraft.app).

Plugins publish when their version is new: bump it to ship a change (an existing version is skipped). Packs and templates are keyed by meta.localId and update in place when their folder changes. New plugin versions go through marketplace review; new packs and templates start private, and you list them once from the editor (Publish → List on the marketplace). After that, updates stay listed.

Sandbox

Each plugin runs in an opaque-origin iframe (sandbox="allow-scripts"), talks to the editor only over a private MessagePort, and is blocked from the network by CSP unless its manifest asks for network. Users approve the manifest's permissions (read, write, export, network, comments) on first run; calls outside the granted set are rejected. Plugins are stored in IndexedDB and work offline.

Widgets

vote-counter/ is a canvas widget. Call popcraft.widget.register({ initialState, render }) at the top of main.js, then popcraft.widget.insert() from a command. render(state) returns a tree of AutoLayout, Text, Rectangle and Ellipse elements; an element's onClick mutates (or returns) the next state.

The tree and state are stored on the WIDGET node, so the widget renders and syncs for every collaborator, even without the plugin. Clicking needs the plugin installed (it runs in the background with command "widget"), and only file editors can click. Undo reverts widget clicks like any other edit.

Developing

pnpm install
pnpm build       # compile the runtime, emit dist/ + the ambient global
pnpm typecheck   # the package, then the examples against the generated global

Releases: see RELEASING.md.