Skip to content

Plugins

DownDraft has a runtime plugin system for user-authored extensions and mods, distinct from the compile-time module system. Plugins are discovered under <app>/plugins/*/, described by a plugin.json or mod.json manifest, and loaded by a per-thread PluginHost (core/src/plugin).

|| Format | Description | |---|---| || worker-js | JavaScript plugin running in a dedicated Web Worker | || wasm | WASM module — always runs in its own worker for crash isolation | || quickjs | Script evaluated in a QuickJS VM (legacy plugin.json compat, instruction-budgeted) | || asset | Declarative content pack — no code; assets/maps/physics/shader extensions only |

Only install plugins you trust — the isolation tiers differ substantially:

  • wasm and quickjs run inside their respective VM/interpreter with no ambient host capabilities beyond the granted permissions — these are hard isolation boundaries.
  • worker-js is not a security sandbox. The plugin runs as a worker thread in the host JS runtime (Bun/Node/Deno). The engine strips or traps dangerous globals on a best-effort basis and gates engine APIs behind the manifest permissions, but plugin code can still import runtime builtins (node:fs, FFI, network) unless the host runtime itself is launched with restrictions (e.g. Deno --deny-* flags). Treat worker-js plugins like any other dependency: they run with the privileges of the app process.
  • Remote workshop packs fetched via BlobStore are content pulled over the network — pin trusted stores and treat untrusted remote packs as a supply-chain risk, especially when they carry worker-js logic.

Each manifest declares a capability tier (data / script / native) and a target thread (sim / renderer / own-worker). The tier bounds which permissions a plugin may request — ecs, gpu, physics, assets, and similar — and the host intersects the request against the tier’s allowlist and the app’s allowlist before loading. WASM plugins are always forced to own-worker.

  • sim — inside the app’s sim worker (ECS system/component registration)
  • renderer — in-process on the main thread (render passes, UI)
  • own-worker — a dedicated Web Worker spawned per plugin

mod.json (scaffolded via draft mod) is the pack-style manifest: a logic extension plus declarative extensions (assets, maps, physics, shaders). plugin.json is the legacy single-format shape; both are normalized to the same internal model.

// <app>/plugins/my-plugin/plugin.json
{
"name": "My Plugin",
"version": "1.0.0",
"format": "worker-js",
"tier": "script",
"thread": "sim",
"entry": "index.js",
"permissions": ["ecs"],
"requires": ["app:weather/state"],
"dependencies": ["other-plugin@^1.0"]
}

The PluginHost validates the manifest, resolves permissions, computes a topological load order from dependencies, then invokes the format-specific loader with a tiered PluginContext facade.

Terminal window
draft plugin list # discovered plugins/mods in apps/*/plugins/
draft plugin new my-plugin --app=my-app # scaffold plugin.json (default: worker-js)
draft plugin new my-plugin --app=my-app --format=wasm
draft mod new my-mod --app=my-app # scaffold mod.json (default: asset)

See the CLI reference for the full flag list.