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

@driftengine/script

v4.3.0

Published

The drift/* capability bindings: what this engine provides to DriftScript, and the only place the two are coupled

Readme

@driftengine/script

The drift/* capability bindings: what this engine provides to DriftScript, and the only place the two are coupled.

Cost: 36.9 KB gzipped on top of core. Measured by scripts/size-gate.test.mjs, which fails if it drifts more than 3% — the number is derived from the same floors that gate asserts, so a README quoting a stale one is a red suite rather than a thing somebody notices.

What it is

driftscript is a language and knows nothing about this engine: no scene, no mesh, no mix bus. This package is the other half — it describes each engine subsystem as capabilities a script may call, and supplies the implementations at link time.

Twelve modules are bound: drift/animation, audio, camera, ecs, events, input, persistence, physics, prefab, random, scene and time. drift/core is deliberately unbound, because its provider is startLoop, which drives a script rather than being called by one.

Four of drift/ecs's capabilities are ones nobody writes by hand. query, next, view and without are what a for … in query<…>() loop compiles to, so their documentation describes the shape of generated code rather than how to call them. They are capabilities rather than a second bind hook, so generated code reaches them exactly as it reaches everything else.

registerEntityModule turns a compiled module's declarations into the engine's own objects — a ComponentType per component, a Prefab per prefab, a SystemDefinition per system — and assertHostShapes checks every component X from host against what this host registered.

Reaching this package from a bundler config — you cannot, and do not need to

import { engineRegistry } from '@driftengine/script' fails inside a vite.config.ts, with ERR_MODULE_NOT_FOUND on a path like @driftengine/audio/src/registry. A bundler config is loaded by Node; engine packages use extensionless relative imports that only a bundler resolves. That is this engine's module layout and not a bug in the config.

Pass the data instead. This package ships it:

import { fileURLToPath } from 'node:url';
import { driftScript } from 'driftscript/vite';

driftScript({
  capabilities: fileURLToPath(import.meta.resolve('@driftengine/script/capabilities.json')),
  manifest: { name: 'my-game', provides: ['drift/ecs', 'drift/audio'] },
});

capabilities.json is regenerated by npm run capabilities and gated by npm run capabilities:check, so it cannot drift from the bindings above it. The DriftScript language server reads the same file for the same reason — see the next section for why a registry can cross a process boundary at all.

The registry describes and never invokes

A definition names its implementation as a string. The host supplies the functions when a module links. That is what keeps the language package host-neutral, and it is also what lets the language server read capabilities.json in a process that cannot import this engine at all.

Adding a binding

The five steps are at the top of src/host.ts, beside the code that does them. Two of them are the ones that get missed:

A capability that lands unbound is one DriftScript cannot reach, and nothing fails to say so. The linker refuses an unbound module by naming the track it waits on — so a script author hits a refusal that reads exactly like a track that has not shipped, and concludes it has not. The capability exists, is finished, is tested, and is unreachable.

Check whether an optional parameter must become required at the language boundary. A TypeScript signature may make one optional because its caller has the context to know when to pass it. A script author is further from the subsystem, meets the trap first, and gets a wrong result rather than an error. src/bindings/animation.ts is the worked example.

Write a binding from the source, never from a description of it. Two were written from a paraphrase and both were wrong — one named two methods the class does not have, reached through an optional-call cast, so a script calling it compiled, linked, ran and did nothing. src/host.test.ts now refuses ?.( and as unknown as anywhere under bindings/.

Part of DriftEngine. See docs/ARCHITECTURE.md for how the packages divide, and why some features are compiled into core on demand instead.