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

@morten-olsen/nova-script-runner

v1.0.0

Published

QuickJS android script sandbox, shared by the CLI and the browser

Downloads

352

Readme

@morten-olsen/nova-script-runner

The sandbox android scripts run in — QuickJS compiled to WebAssembly, driven identically from Node and from the browser.

It replaces the two sandboxes this repo used to carry: node:vm in the CLI and eval-in-a-Worker in the IDE. Those agreed on the script contract by convention and testing; this one agrees by being the same interpreter, down to which language features exist and where a runaway loop is cut off.

Using it

In Node, or anywhere blocking the calling thread for a millisecond is fine:

import { createQuickJsScriptRunner } from '@morten-olsen/nova-script-runner';

const loop = new Loop({ ruleset, scriptRunner: createQuickJsScriptRunner() });

In a browser, where a script should not compete with the UI for the main thread:

import { createWorkerScriptRunner } from '@morten-olsen/nova-script-runner/worker';

// Constructing it spawns the worker, which starts loading the interpreter.
// Do this at boot, not at the first turn.
const scriptRunner = createWorkerScriptRunner();

Neither is given resource limits: a turn's CPU, wall-clock and heap budget is a game rule, and arrives with the rules the engine hands to every execute call. Both are ScriptRunners as far as the engine is concerned.

Bundler requirements

The worker entry loads its interpreter through a dynamic import, so it must be built as a module worker. In Vite that means:

// vite.config.ts
export default defineConfig({
  worker: { format: 'es' },
});

Without it the build fails with Invalid value "iife" for option "worker.format". Hosts that bundle their workers some other way can pass createWorker instead of relying on the default entry.

Why it is fast

Instantiating the WebAssembly module is the only expensive step — single-digit milliseconds from Node's disk cache, a few hundred in a browser that has to fetch the .wasm. Everything after it is cheap, so the design is built around paying that cost exactly once:

  • The module is cached process-wide and shared by every runner in it.
  • warmUpQuickJs() (and constructing either runner) starts the load early, so it overlaps with app startup instead of delaying the first turn.
  • The worker runner is long-lived. Turns are messages to a worker that is already warm.
  • The world crosses into the interpreter as a JSON string and the action comes back as one, rather than being rebuilt property by property across the FFI boundary.

Measured by pnpm bench on a 400-tile map: 0.7ms for a whole turn's runtime and teardown, 1.5ms for a turn that actually runs the starter bot.

Isolation and limits

Every turn builds a fresh QuickJS runtime and destroys it afterwards. That is what makes the limits in ScriptLimits per turn rather than per match: a script that spends its entire memory budget hands none of that debt to the next android, and the script contract's "cannot retain state between turns" rule holds by construction.

Three of the four come from rules.script — the game's own budget for a turn, read per turn rather than fixed when the runner is built, so a recording replays under the budget it was played with and a script can read its own allowance. The fourth, stackBytes, is a runner option rather than a rule, because its ceiling is a property of the WebAssembly build; maxStackBytes clamps it, and exceeding it aborts the module rather than failing a turn.

CPU is budgeted in interpreter ticks rather than milliseconds, so a script is interrupted at the same instruction regardless of how fast the machine is — two peers replaying a match agree on the result. A wall-clock deadline sits behind it as a backstop for work that burns time without burning operations.

This is an isolation boundary, not a security one. A script cannot reach the host, but nothing here is hardened against a determined attacker.