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

shadowboxin

v0.1.0-beta.8

Published

Shadowboxin: Utils for real-time streamed LLM-generated UIs.

Downloads

35

Readme

Shadowboxin

Shadowboxin: Utils for real-time streamed LLM-generated UIs.
Bring your own component registry (BYO) and let an engine render UI described by model output.

Beta

This is an active WIP, and probably unrealiable right now

Modules (public subpaths)

  • shadowboxin/client – prompt + adapter/provider wiring
  • shadowboxin/engine – runtime that renders model-emitted UI
  • shadowboxin/template-models – schema helpers/validators
  • shadowboxin/template-utils – registry helpers and component bindings

Install

npm install shadowboxin zod react react-dom

Assumes a React app (Vite recommended). Shadowboxin ships ESM with subpath exports only (no root entry).


Quick Start

1) Create a tiny component registry (Container, Paragraph, Button)

Create src/sbx/registry.tsx:

import { z } from "zod"
import type { ComponentType, ReactNode } from "react"

import { createTemplateRegistry } from "shadowboxin/template-utils"
import { templateValidatorFor, parentValidatorFor } from "shadowboxin/template-models"

/** ───────── Paragraph ───────── */
type ParagraphProps = { content: string }
const Paragraph: ComponentType<ParagraphProps> = ({ content }) => <p>{content}</p>

export const ParagraphSet = {
  type: "paragraph",
  component: Paragraph,
  templateValidator: templateValidatorFor("paragraph", { content: z.string().min(1) }),
  instructions: {
    generalUsage: "Use for body copy.",
    fields: { content: "The paragraph text." }
  }
}

/** ───────── Container ───────── */
type ContainerProps = { children?: ReactNode }
const Container: ComponentType<ContainerProps> = ({ children }) => (
  <div data-sbx="container">{children}</div>
)

export const ContainerSet = {
  type: "container",
  component: Container,
  templateValidator: parentValidatorFor("container"),
  instructions: { generalUsage: "Groups other elements." }
}

/** ───────── Button ───────── */
type ButtonProps = { label: string; onSubmit: (payloads: unknown[]) => void }
const Button: ComponentType<ButtonProps> = ({ label, onSubmit }) => (
  <button type="button" onClick={() => onSubmit([])}>{label}</button>
)

export const ButtonSet = {
  type: "button",
  component: Button,
  templateValidator: templateValidatorFor("button", { label: z.string().min(1) }),
  instructions: {
    generalUsage: "Simple submit button; no fields.",
    fields: { label: "Button text." }
  }
}

/** ───────── Registry ───────── */
export const registry = createTemplateRegistry(ContainerSet, ParagraphSet, ButtonSet)

2) Wire the engine and a tiny local provider (no network)

Create src/sbx/setup.ts:

import {
  createAgentsProvider,
  createEngineAdapter,
  generateSystemPrompt,
  type ChatMessage,
  type EnginePort
} from "shadowboxin/client"

import { createEngine } from "shadowboxin/engine"
import { registry } from "./registry"

// Minimal example JSON the assistant could emit (Container → Paragraph + Button)
export const minimalExample = {
  id: "container",
  children: [
    { id: "paragraph", content: "Hello from Shadowboxin." },
    { id: "button", label: "Continue" }
  ]
} as const

// Build a system prompt using your registry instructions and the example JSON
const SYSTEM_PROMPT = generateSystemPrompt(
  "You respond by emitting UI templates only.",
  registry.instructions,
  { exampleJSON: minimalExample }
)

/** Local demo provider that yields one JSON response (no network). */
const provider = createAgentsProvider(async function* (_messages: ChatMessage[]) {
  // In production, plug in your streamed LLM responses here and yield deltas.
  yield JSON.stringify(minimalExample)
})

export async function startShadowboxin(root: HTMLElement) {
  let adapter!: ReturnType<typeof createEngineAdapter>

  const engine = await createEngine({
    registry,
    rootNode: root,
    onSubmit: (payloads) => adapter.submit(payloads),
    debug: false
  })

  const port: EnginePort = {
    next: (d) => engine.push(d),
    reset: () => engine.reset()
  }

  adapter = createEngineAdapter(port, provider, {
    systemPrompt: SYSTEM_PROMPT,
    initialUserMessage: "Render the minimal example."
  })

  await adapter.run()
}

3) Mount it in your app

Create src/main.tsx:

import { StrictMode, useEffect, useRef } from "react"
import { createRoot } from "react-dom/client"
import { startShadowboxin } from "./sbx/setup"

function App() {
  const ref = useRef<HTMLDivElement>(null)
  useEffect(() => {
    if (ref.current) startShadowboxin(ref.current)
  }, [])
  return <div ref={ref} id="gen-ui-root" />
}

createRoot(document.getElementById("root")!).render(
  <StrictMode>
    <App />
  </StrictMode>
)

Example UI JSON (what the assistant/provider can emit)

Create src/sbx/example.json (optional, for reference):

{
  "id": "container",
  "children": [
    { "id": "paragraph", "content": "Hello from Shadowboxin." },
    { "id": "button", "label": "Continue" }
  ]
}

How it works

  • Registry exposes types/instructions/validators for your components.
  • System Prompt is generated from registry instructions + an example JSON.
  • Provider yields model output (as JSON strings); swap in your streamed LLM.
  • Adapter + Engine connect the stream to the renderer and handle user onSubmit.