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

@kubohiroya/turbowarp-runtime-adapter

v0.5.0

Published

App-neutral adapters for interacting with the TurboWarp runtime.

Readme

turbowarp-runtime-adapter

日本語

@kubohiroya/turbowarp-runtime-adapter provides app-neutral adapters for interacting with the TurboWarp runtime from unsandboxed extensions and packaged TurboWarp apps.

This package intentionally does not define app-specific DSL semantics, block metadata, story/navigation behavior, pose handling, or 3D scene graph policy. Those remain in the app package @kubohiroya/turbowarp-kamishibai-app (repository: tm-kamishibai) or domain libraries such as @kubohiroya/turbowarp-3d-scene-dsl.

Scope

  • Resolve a runtime from Scratch.vm.runtime or an explicit runtime object.
  • Subscribe to runtime events with disposable listeners.
  • Start hats through a small validated host adapter.
  • Read the Stage target, the sprite targets, the renderer, and the monitor stores.
  • Provide a generic broadcastMessageAndWait port for exact Stage broadcast names.
  • Build the repetitive parts of an extension getInfo() block list.
  • Keep Scratch VM access behind a narrow interface.

Runtime surface

createTurboWarpRuntimeHost returns one adapter per session. Inject it rather than passing a raw runtime around: a consumer that only needs the Stage then depends on getStageTarget() alone, not on the whole runtime shape.

| Member | Reads | | --- | --- | | runtime | the validated runtime, for anything this package does not own yet | | onRuntimeEvent(event, listener) | subscribes and returns a disposer | | startHats(opcode, matchFields?) | always an array, never undefined | | stopThread(thread) / currentThreads() | _stopThread / threads | | getStageTarget() | getTargetForStage() | | targets() / spriteTargets() | targets, copied; spriteTargets drops the Stage | | getRenderer() / requestRedraw() | renderer; requestRedraw is a no-op when absent | | getMonitorBlocks() / getMonitorState() | the validated monitor block store and record map |

Block surfaces

createBlockSurfaceBuilder takes the Scratch.BlockType / Scratch.ArgumentType pair an extension already has and builds block records from it. It owns record shape, palette visibility, reporter monitor defaults, and duplicate-opcode detection. Opcodes, block text, and menu items stay with the caller, so no app vocabulary enters this package.

import {coerceScalarBlockValue, createBlockSurfaceBuilder} from '@kubohiroya/turbowarp-runtime-adapter';

const build = createBlockSurfaceBuilder({ArgumentType, BlockType}, {visible: stateVisible});
const surface = build.surface(
  [
    build.reporter({opcode: 'sceneId', text: 'current scene id'}),
    ...build.reporters([
      ['status', 'story status'],
      ['version', 'runtime version']
    ]),
    build.command({
      opcode: 'setVariable',
      text: 'set [NAME] to [VALUE] as [TYPE]',
      arguments: {
        NAME: build.stringArgument(),
        VALUE: build.stringArgument(),
        TYPE: build.menuArgument('scalarTypes')
      },
      visible: writeVisible
    })
  ],
  {scalarTypes: build.menu(['string', 'number', 'boolean'])}
);

const written = coerceScalarBlockValue(args.VALUE, args.TYPE, {errorCodePrefix: 'K4'});

Compatibility

Consumers that already expose stable app-specific diagnostics can pass errorCodePrefix. For example, tm-kamishibai can keep K4-BROADCAST-* errors while delegating the runtime interaction mechanics to this package.

Example

import {
  createTurboWarpBroadcastPort,
  createTurboWarpRuntimeHost
} from '@kubohiroya/turbowarp-runtime-adapter';

const host = createTurboWarpRuntimeHost({Scratch});
const broadcast = createTurboWarpBroadcastPort({
  runtime: host.runtime,
  errorCodePrefix: 'K4'
});

const dispose = host.onRuntimeEvent('PROJECT_STOP_ALL', () => {
  console.log('stopped');
});

await broadcast.broadcastMessageAndWait(
  {message: 'openScene'},
  {signal: new AbortController().signal}
);

dispose();

Development

npm install --global corepack@latest
corepack enable
pnpm install --frozen-lockfile
pnpm run check
pnpm run release:check