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

@fractal-mcp/oai-preview

v2.2.5

Published

React component for previewing OpenAI Apps SDK widgets in development

Readme

@fractal-mcp/oai-preview

⚠️ Development/Testing Tool Only - Use this in your mcp preview applications, but NOT in your chats.

React component for previewing and testing OpenAI Apps SDK widgets during development.

Installation

npm install --save-dev @fractal-mcp/oai-preview

Usage

import { WidgetDisplayComponent } from "@fractal-mcp/oai-preview";

function WidgetPreview() {
  const htmlSnippet = `
    <div id="root"></div>
    <script>
      const root = document.getElementById("root");
      root.innerHTML = '<h1>Hello Widget</h1>';
    </script>
  `;

  return (
    <WidgetDisplayComponent
      htmlSnippet={htmlSnippet}
      toolInput={{ name: "World" }}
      toolOutput={{ greeting: "Hello, World!" }}
      theme="dark"
      displayMode="inline"
      maxHeight={800}
      onToolCall={async (toolName, params) => {
        console.log("Tool called:", toolName, params);
        return { success: true };
      }}
      onOpenExternal={(href) => {
        console.log("Opening external URL:", href);
        // Custom handling - could show modal, log analytics, etc.
        window.open(href, '_blank');
      }}
      onRequestDisplayMode={(mode) => {
        console.log("Display mode requested:", mode);
      }}
    />
  );
}

Props

| Prop | Type | Required | Description | |------|------|----------|-------------| | htmlSnippet | string | Yes | The HTML snippet to render in an iframe | | toolInput | Record<string, any> | No | Input args, available as window.openai.toolInput | | toolOutput | any | No | Output data, available as window.openai.toolOutput | | toolId | string | No | Unique ID for state persistence | | onToolCall | (name, params) => Promise<any> | No | Called when widget calls window.openai.callTool() | | onSendFollowup | (message) => void | No | Called when widget calls window.openai.sendFollowupTurn() | | onSetWidgetState | (state) => void | No | Called when widget calls window.openai.setWidgetState() | | onRequestDisplayMode | (mode) => void | No | Called when widget calls window.openai.requestDisplayMode() | | onOpenExternal | (href) => void | No | Called when widget calls window.openai.openExternal() | | className | string | No | CSS class for container | | displayMode | DisplayMode | No | Display mode: "inline", "pip", "fullscreen" (default: "inline") | | maxHeight | number | No | Maximum height constraint in pixels (default: 600) | | theme | Theme | No | Theme: "light" or "dark" (default: "light") | | locale | string | No | Locale string (default: "en-US") | | safeArea | SafeArea | No | Safe area insets for mobile (default: zero insets) | | userAgent | UserAgent | No | Device and capability info (default: desktop with hover) |

What It Does

The component:

  • Renders your widget HTML in a sandboxed iframe
  • Injects window.openai and window.webplus APIs
  • Handles postMessage communication between iframe and parent
  • Simulates the ChatGPT widget runtime

Testing

npm test

Tests use Playwright to verify rendering, messaging, and data access.

Credits

This package was built by studying and learning from:

Special thanks to the MCPJam team for making their code open source and advancing the MCP ecosystem!

License

MIT