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

@ocusell/playground-widget

v0.1.1

Published

Embeddable Rulesetta Playground widget for writing and validating RCP-019 rules

Readme

@ocusell/playground-widget

An embeddable iframe widget that lets users write and validate RCP-019 rules inside your own app. When the user clicks Save, the widget emits a rulesetta:save event via postMessage with the rule payload, which your app can persist in its own database.

Install

npm install @ocusell/playground-widget

The package ships three independent entrypoints:

| Import path | What it exports | |---|---| | @ocusell/playground-widget | Framework-agnostic PlaygroundWidget class | | @ocusell/playground-widget/vue | usePlaygroundWidget composable + <PlaygroundWidgetComponent> | | @ocusell/playground-widget/react | <PlaygroundWidget> React component |

Usage

Plain iframe (no JS required)

For static initial state, you can use the iframe directly without any JavaScript:

<iframe
  src="https://api.rulesetta.com/play/widget#<base64-encoded-state>"
  width="100%"
  height="600"
  style="border:none"
></iframe>

Use @ocusell/playground-link's encodeFragment helper to build the fragment, or set the state dynamically via postMessage after load.

Vanilla JS / TypeScript

import { PlaygroundWidget } from "@ocusell/playground-widget";

const widget = new PlaygroundWidget(document.getElementById("container")!, {
  baseUrl: "https://api.rulesetta.com",
  initialState: {
    expression: "ListPrice > 0",
    action: "REJECT",
    fieldName: "ListPrice",
  },
  onSave(state) {
    // { expression, action, fieldName }
    console.log("Rule saved:", state);
  },
  height: "600px",
});

// Update state programmatically after load:
widget.setState({ expression: "ListPrice >= 50000" });

// Clean up (removes the iframe and event listeners):
widget.destroy();

Vue 3

<script setup lang="ts">
import { PlaygroundWidgetComponent } from "@ocusell/playground-widget/vue";

function onSave(state) {
  console.log("Rule saved:", state);
}
</script>

<template>
  <PlaygroundWidgetComponent
    base-url="https://api.rulesetta.com"
    :initial-state="{ expression: 'ListPrice > 0', action: 'REJECT', fieldName: 'ListPrice' }"
    height="600px"
    @save="onSave"
  />
</template>

Or use the composable directly:

import { usePlaygroundWidget } from "@ocusell/playground-widget/vue";

const { containerRef } = usePlaygroundWidget({
  baseUrl: "https://api.rulesetta.com",
  onSave(state) { console.log(state); },
});

React

import { PlaygroundWidget, PlaygroundWidgetHandle } from "@ocusell/playground-widget/react";
import { useRef } from "react";

function RuleEditor() {
  const widgetRef = useRef<PlaygroundWidgetHandle>(null);

  return (
    <PlaygroundWidget
      ref={widgetRef}
      baseUrl="https://api.rulesetta.com"
      initialState={{ expression: "ListPrice > 0", action: "REJECT", fieldName: "ListPrice" }}
      height="600px"
      onSave={(state) => console.log("Saved:", state)}
    />
  );
}

postMessage Protocol

The widget communicates with the host via window.postMessage.

Widget → Host

| Message type | Payload | When | |---|---|---| | rulesetta:ready | {} | After iframe loads | | rulesetta:save | { state: { expression, action, fieldName } } | When user clicks Save |

Host → Widget

| Message type | Payload | Effect | |---|---|---| | rulesetta:set-state | { state: { expression?, action?, fieldName?, data? } } | Updates editor state |

Publishing

See docs/npm-publishing.md for manual publishing instructions.