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

aleatory-embed-renderer

v0.1.0

Published

Aleatory Embeddable Renderer: portable, deterministic renderer and embed component for ALEATORY-001 generative art

Readme

Aleatory Embeddable Renderer (aleatory-embed-renderer)

Portable, deterministic renderer and embed component for ALEATORY-001 generative artworks on Tezos.

Aleatory generators are self-contained HTML files stored immutably on chain, drawing deterministically from a mint operation hash seed. This package handles the execution harness, zero-warmup PRNG, dependency resolution, metadata extraction, and sandboxed iframe isolation for any web application or indexer.

Installation

npm install aleatory-embed-renderer

aleatory-embed-renderer ships dual ESM and CommonJS builds with TypeScript declarations.


Usage

1. React Component

import { AleatoryViewer } from "aleatory-embed-renderer/react";

export function ArtCard({ code, seed, params }) {
  return (
    <div style={{ width: "100%", aspectRatio: "1 / 1" }}>
      <AleatoryViewer
        code={code}
        seed={seed}
        params={params}
        liveClock={true}
        onReady={(detail) => console.log("Piece ready:", detail)}
        onError={(err) => console.error("Piece error:", err)}
      />
    </div>
  );
}

The component parses <meta name="alea:library"> declarations, resolves and verifies external scripts (e.g. p5.js, three.js), and executes the piece inside a sandboxed iframe with connect-src 'none'.

2. Custom Web Component

Zero-framework, works in vanilla HTML, Vue, Svelte, or Angular:

<script type="module" src="aleatory-embed-renderer/viewer"></script>

<aleatory-viewer
  code="<!doctype html>..."
  seed="ooKxY..."
  params='{"density": 120}'
  live-clock="true"
></aleatory-viewer>

<script>
  const viewer = document.querySelector("aleatory-viewer");
  viewer.addEventListener("ready", (e) => {
    console.log("Ready, traits:", e.detail.features);
  });
</script>

3. Core Document Assembler (Headless / Node / Puppeteer)

For static thumbnail captures, CI determinism checks, or headless capture pipelines:

import { buildDocument, createPrng } from "aleatory-embed-renderer/core";

// Generate standalone sandboxed document string with CSP and harness:
const html = buildDocument({
  code: generatorHtml,
  seed: "ooKxY...",
  params: { density: 140 },
  liveClock: false, // Freezes Date.now() and performance.now() at 0
  maxDpr: 1        // Canonical 1000x1000 DPR 1 capture
});

// Or evaluate PRNG numbers directly:
const prng = createPrng("ooKxY...");
console.log(prng.rand()); // Float [0, 1) with canonical zero-warmup sfc32
console.log(prng.randInt(1, 10)); // Inclusive

4. Indexer & Metadata Extraction

Standardized extraction of seed and parameters across TzKT and marketplace indexers:

import { extractPieceMetadata, decodeCode, fetchMintRecord } from "aleatory-embed-renderer/indexer";

// 1. Extract from token metadata JSON:
const { seed, params, features } = extractPieceMetadata(tokenMetadata);

// 2. Fetch mint transfer and seed from TzKT when metadata is pending:
const mint = await fetchMintRecord("KT1...", 0);
console.log("Canonical seed:", mint.hash);

// 3. Decode contract storage code (gzip or identity):
const html = await decodeCode(storageHex, "gzip");

Architectural Rules

  1. Zero-warmup PRNG: The PRNG uses xmur3 seeding into sfc32 directly with 0 warmup cycles. Discarding initial draws shifts the stream and diverges from the canonical render.
  2. String Seed: The seed is the base58 mint operation hash. Parsing it as hex or an integer (parseInt) produces NaN and coerces the seed to 0.
  3. Execution Order: The harness replaces Math.random before any declared libraries (such as p5.js) load, ensuring library noise and internal random states are deterministic.
  4. Clock Modes: Captures run with frozen time (liveClock: false). Interactive viewers run with live time (liveClock: true).

Subpath Exports

  • aleatory-embed-renderer: Everything
  • aleatory-embed-renderer/core: Pure PRNG, harness generator, and document assembler
  • aleatory-embed-renderer/libraries: Dependency coordinate parser, CDN resolver, and blake2b integrity
  • aleatory-embed-renderer/indexer: Metadata parsing, storage code decoder, and TzKT query recipes
  • aleatory-embed-renderer/viewer: Sandboxed iframe manager and <aleatory-viewer> web component
  • aleatory-embed-renderer/react: React <AleatoryViewer /> component