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

@statedelta/engine-registry

v0.1.1

Published

Engine acquisition registry for StateDelta - resolves engineKey to a runnable EngineFactory from a versioned bundle manifest

Readme

@statedelta/engine-registry

O registry de aquisição de engines do StateDelta — resolve uma chave de engine para um EngineFactory executável a partir de um manifest de bundles versionados.

É a implementação do contrato EngineRegistry declarado em @statedelta/protocol — o eixo paralelo ao Gateway: o Gateway resolve uri → Artifact (documentos); este resolve engineKey → EngineFactory (engines).

O que faz

registry.resolve("[email protected]")
  │  1. lê o manifest          (objeto in-memory · arquivo local · URL opt-in)
  │  2. resolve o channel "0.4" → versão exata "0.4.0"
  │  3. acha a entry de "0.4.0" → { url, sha256 }
  │  4. obtém o bundle .cjs    (download remoto + cache · ou leitura local)
  │  5. valida o sha256
  │  6. carrega o módulo → o `create` exportado
  │  7. checa o handshake de protocolo
  ▼
ResolvedEngine { factory, version, integrity, protocol? }

Instalação

pnpm add @statedelta/engine-registry

Modos

A fonte do manifest é sempre explícita — não há endpoint default. As engines que um launcher serve são decisão do operador, não um recurso que muda pelas costas dele.

| Modo | Como | Quando | |---|---|---| | In-memory | { manifest } — objeto já carregado | testes, embedding | | Arquivo local | { manifestPath } — JSON no disco | o padrão — versionado com o deploy | | URL (opt-in) | { manifestUrl } — endpoint que o operador controla | quando explicitamente desejado |

E o bundle (a url de cada entry do manifest) pode ser remoto (http(s), baixado + cacheado por hash) ou local (path / file:, lido do disco). Manifest local + bundles locais = air-gapped, zero rede — e o sha256 é verificado nos dois casos.

Manter um manifest remoto atualizado (refresh periódico, download em massa de bundles) é um processo fora do registry — ele só consome.

Uso

import { createEngineRegistry } from "@statedelta/engine-registry";
import { createEnvironment } from "@statedelta/protocol";
import { createLauncher } from "@statedelta/launcher";

// Manifest local — o operador declara quais engines este launcher serve.
const registry = createEngineRegistry({ manifestPath: "./engines.json" });

const environment = createEnvironment({
  engines: {},     // mapa in-memory (mocks/dev) — opcional
  registry,        // aquisição de engines reais
}).freeze();

const launcher = createLauncher({ environment });
const engine = await launcher.launch("./save.json");

createEngine do environment usa o mapa engines quando a chave está nele (source in-memory); senão cai no registry.

API

createEngineRegistry(options): EngineRegistry

Declare uma fonte de manifest — sem nenhuma, lança.

| Opção | Descrição | |---|---| | manifest | Manifest in-memory (objeto) | | manifestPath | Caminho de um arquivo JSON local — a fonte idiomática | | manifestUrl | URL do manifest — opt-in explícito, nunca default | | cacheDir | Cache dos bundles remotos verificados (default ~/.statedelta/engines) | | fetchImpl | fetch injetável (manifest + bundle remotos) | | loadBundleImpl | Loader de bundle injetável — para testes sem download/require |

Precedência quando mais de uma é dada: manifestmanifestPathmanifestUrl. Paths de bundle relativos no manifest resolvem contra o diretório do manifestPath.

Chave de engine

Erros

Falhas são ResolutionError (de @statedelta/protocol):

  • ENGINE_NOT_AVAILABLE — manifest/channel/versão ausente, manifest ilegível, download/leitura do bundle falho, ou sha256 não bate (details.reason discrimina).
  • ENGINE_PROTOCOL_INCOMPATIBLE — o range de protocolo declarado pelo bundle não cobre o PROTOCOL_VERSION do launcher.

Testes

pnpm test       # unit — manifest, loader, registry (sem rede)
pnpm test:e2e   # integração — baixa o [email protected] real e roda

Os testes unitários cobrem parse de chave, resolução de channel/pin, carga de bundle remoto (download + cache) e local (air-gapped), a verificação sha256, e o handshake de protocolo — sem rede.

O test:e2e é a prova ponta-a-ponta: resolve [email protected], baixa o bundle real engine-0.4.0.cjs, verifica o sha256, carrega, e via launcher.launch() boota um mundo tic-tac-toe — depois simula uma jogada (X em (0,0)) e confirma que o runtime avançou o estado.

Segurança

Carregar um bundle é executar código. As defesas: a fonte do manifest é sempre explícita (sem endpoint default), o sha256 é verificado contra o manifest antes de carregar — remoto ou local, defesa em profundidade — e o caminho air-gapped (manifest + bundles locais) elimina a rede por completo.

Node-only nesta fase — bundles são .cjs, carregados via createRequire.

Licença

MIT