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

@ifc-lite/sandbox

v2.2.2

Published

QuickJS-in-WASM sandboxed script execution for ifc-lite

Readme

@ifc-lite/sandbox

QuickJS-in-WASM sandboxed script execution for ifc-lite. Runs user or LLM-generated scripts in a secure, isolated interpreter with only the bim.* API exposed: no DOM, no fetch, no network access. Permissions and resource limits (timeout, memory) are configurable per sandbox, and TypeScript input is transpiled on the fly.

Install

npm install @ifc-lite/sandbox

Usage

import { createSandbox } from '@ifc-lite/sandbox';
import { createBimContext, type BimBackend } from '@ifc-lite/sdk';

// Your BimBackend — the viewer's store adapter, a server client, ...
declare const backend: BimBackend;

const bim = createBimContext({ backend });
const sandbox = await createSandbox(bim, {
  permissions: { mutate: true },
  limits: { timeoutMs: 10_000 },
});

const result = await sandbox.eval(`
  const walls = bim.query.byType('IfcWall');
  console.log('Found', walls.length, 'walls');
  walls.length;
`);

console.log(result.value); // number of walls
console.log(result.logs);  // captured console output

sandbox.dispose();

Recovering from a teardown abort

A script that exhausts the memory limit inside a drained promise job — the post-await body of an async function run() that nothing awaits — trips an upstream assertion in JS_FreeRuntime, so dispose() comes back as an emscripten abort (#1922). Two consequences a consumer has to handle:

dispose() can throw, and that throw is the run's verdict. It rejects with SandboxAbortError. The eval() that caused it already resolved normally — the reproducer returns "started" — so teardown is the only place the failure is observable. Treat a throwing dispose() as that run having failed, and settle the run's outcome after teardown rather than before it:

import { SandboxAbortError, type Sandbox, type ScriptResult } from '@ifc-lite/sandbox';

declare const sandbox: Sandbox;
declare const code: string;

let result: ScriptResult | null = await sandbox.eval(code);
try {
  sandbox.dispose();
} catch (err) {
  if (err instanceof SandboxAbortError) {
    result = null; // the run died; whatever it "returned" is incomplete
  }
}

A long-lived sandbox must be discarded once moduleRetired is true. The abort poisons the whole WASM module, so this package retires it and builds the next sandbox on a fresh one — 1-5 ms, no page reload, and nothing for a caller to do. But a host that keeps one sandbox across many runs (an extension runtime, a REPL) can be holding one whose module was retired by some other sandbox's abort. That sandbox still executes scripts, yet emscripten's ABORT latch is per module and has already fired on it: its own teardown can no longer report a failure, and it will silently leak whatever JS_FreeRuntime does not reach. Check before running, and replace rather than reuse:

import { createSandbox, type Sandbox, type SandboxConfig } from '@ifc-lite/sandbox';

declare let sandbox: Sandbox;
declare const config: SandboxConfig;

if (sandbox.moduleRetired) {
  sandbox.dispose();
  sandbox = await createSandbox(bim, config); // built on a fresh module
}

moduleRetired is always false after dispose(), which releases the module reference — so check it while the sandbox is live. Sandboxes created per run (the viewer's script panel) never observe it: they are already gone by then.

isSandboxRuntimeAborted() reports whether any teardown abort has happened in this process. It is a diagnostic, latched for the process lifetime; it is not a health check, and a true does not mean scripting is dead.

Features

  • QuickJS interpreter compiled to WASM: full isolation from the host page
  • Only the bridged bim.* API is reachable from scripts
  • Configurable SandboxPermissions and SandboxLimits (with DEFAULT_PERMISSIONS / DEFAULT_LIMITS)
  • Captured console logs and structured ScriptResult / ScriptError
  • TypeScript support via transpileTypeScript (esbuild-wasm)
  • Machine-readable bridge schema (NAMESPACE_SCHEMAS, exported at @ifc-lite/sandbox/schema) for LLM tool integration
  • Survives the upstream QuickJS teardown abort by retiring the WASM module it poisons (SandboxAbortError, Sandbox.moduleRetired — see above)

Links

  • Docs: https://ifclite.dev/docs/
  • Source: https://github.com/LTplus-AG/ifc-lite

License

MPL-2.0