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

@luna-editor/embedded-sdk

v0.3.0

Published

Embedded SDK for Luna Editor - integrate scenario player into your applications

Readme

@luna-editor/embedded-sdk

Embedded SDK for Luna Editor - integrate scenario player into your applications.

Installation

npm install @luna-editor/embedded-sdk @luna-editor/engine
# or
yarn add @luna-editor/embedded-sdk @luna-editor/engine
# or
bun add @luna-editor/embedded-sdk @luna-editor/engine

Quick Start

1. Wrap your app with LunaProvider

import { LunaProvider } from '@luna-editor/embedded-sdk';

function App() {
  return (
    <LunaProvider
      config={{
        workId: "your-work-id",
        token: "emb_your_token_here",
        apiUrl: "https://your-luna-instance.com"
      }}
    >
      <YourApp />
    </LunaProvider>
  );
}

2. Use hooks to fetch data

import { usePublishedScenario } from '@luna-editor/embedded-sdk';
import { Player } from '@luna-editor/engine';

function ScenarioPlayer({ scenarioId }: { scenarioId: string }) {
  const { data: scenario, isLoading, error } = usePublishedScenario(scenarioId);

  if (isLoading) return <div>Loading...</div>;
  if (error) return <div>Error: {error.message}</div>;
  if (!scenario) return <div>Scenario not found</div>;

  return <Player scenario={scenario} />;
}

API Reference

LunaProvider

Provider component that must wrap your application.

Props:

  • config: LunaSdkConfig - SDK configuration
    • workId: string - Your work ID
    • token: string - Embedded API token (starts with emb_)
    • apiUrl?: string - Luna Editor API URL (default: http://localhost:3000)
  • queryClient?: QueryClient - Optional React Query client
  • children: ReactNode - Your app components

Hooks

usePublishedScenario(scenarioId: string)

Fetch a published scenario by ID.

Returns: UseQueryResult<PublishedScenario>

usePublishedScenarios()

Fetch all published scenarios for the work.

Returns: UseQueryResult<PublishedScenarioListItem[]>

useInstalledPlugins()

Fetch installed plugins for the work.

Returns: UseQueryResult<InstalledPlugin[]>

useSettings(schema, key, defaultValue)

Manage settings with Zod validation and localStorage persistence.

Parameters:

  • schema: ZodType - Zod schema for validation
  • key: string - Storage key
  • defaultValue: T - Default settings value

Returns: [settings, setSettings, resetSettings]

Example:

import { useSettings } from '@luna-editor/embedded-sdk';
import { z } from 'zod';

const playerSettingsSchema = z.object({
  volume: z.number().min(0).max(1),
  autoPlay: z.boolean(),
  textSpeed: z.number().min(1).max(10),
});

function PlayerSettings() {
  const [settings, setSettings, resetSettings] = useSettings(
    playerSettingsSchema,
    'player-settings',
    { volume: 0.8, autoPlay: false, textSpeed: 5 }
  );

  return (
    <div>
      <label>
        Volume: {settings.volume}
        <input
          type="range"
          min="0"
          max="1"
          step="0.1"
          value={settings.volume}
          onChange={(e) => setSettings({ 
            ...settings, 
            volume: parseFloat(e.target.value) 
          })}
        />
      </label>
      <button onClick={resetSettings}>Reset to Defaults</button>
    </div>
  );
}

useSettingsUpdate(schema, key, defaultValue)

Similar to useSettings but returns an update function for partial updates.

Returns: [settings, updateSettings, resetSettings]

Example:

const [settings, updateSettings] = useSettingsUpdate(
  playerSettingsSchema,
  'player-settings',
  { volume: 0.8, autoPlay: false }
);

// Partial update
updateSettings({ volume: 0.5 });

LunaSdk Class

Low-level SDK class for non-React usage.

import { LunaSdk } from '@luna-editor/embedded-sdk';

const sdk = new LunaSdk({
  workId: "your-work-id",
  token: "emb_your_token_here",
  apiUrl: "https://your-luna-instance.com"
});

// Fetch scenario
const scenario = await sdk.getPublishedScenario("scenario-id");

// List scenarios
const scenarios = await sdk.listPublishedScenarios();

// Get plugins
const plugins = await sdk.getInstalledPlugins();

TypeScript Support

This package includes full TypeScript definitions.

License

MIT