Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·part ofpackage threezero.package·originates fromworld 7767c52c-9…

runner

A module script.

byzero-proxy @ DESKTOP-DB3UJOJ·posted 3mo ago
What it does

runner

A module script.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

module threezero.runner Runs a three.js project inside a ZeroJS VM. `start` builds the VM, installs the `__ZERO` host bridge, `requestAnimationFrame`, and a browser prelude (window/document/performance), then evaluates the project's ES module graph with a VFS-path resolver: 'three' and 'three/addons/...' map to the ThreeZero shim assets, relative './file.js' specifiers resolve against the importing file's folder. `pump` drives animation-frame callbacks, timers, and microtasks once per engine frame.

addEventListener(type: ?, fn: ?) → void

argtypedescription
type?
fn?

removeEventListener(type: ?, fn: ?) → void

argtypedescription
type?
fn?

dispatchEvent(ev: ?) → void

argtypedescription
ev?

__fanOut(type: ?, ev: ?) → void

argtypedescription
type?
ev?

__keyFromCode(code: ?) → void

argtypedescription
code?

__noop( ) → void

__dispatchEngineEvents( ) → void

__makeElement(tag: ?) → void

argtypedescription
tag?

__make2dContext(canvas: ?) → void

argtypedescription
canvas?

__makeGlContext( ) → void

__domClass(name: ?) → void

argtypedescription
name?

__makeElement(tag: ?) → void

argtypedescription
tag?

addEventListener(type: ?, fn: ?) → void

argtypedescription
type?
fn?

removeEventListener(type: ?, fn: ?) → void

argtypedescription
type?
fn?

dispatchEvent(ev: ?) → void

argtypedescription
ev?

click( ) → void

appendChild(c: ?) → void

argtypedescription
c?

insertBefore(c: ?, ref: ?) → void

argtypedescription
c?
ref?

removeChild(c: ?) → void

argtypedescription
c?

remove( ) → void

contains( ) → void

closest( ) → void

matches( ) → void

cloneNode( ) → void

setAttribute(k: ?, v: ?) → void

argtypedescription
k?
v?

getAttribute(k: ?) → void

argtypedescription
k?

removeAttribute(k: ?) → void

argtypedescription
k?

hasAttribute(k: ?) → void

argtypedescription
k?

toggleAttribute(k: ?, force: ?) → void

argtypedescription
k?
force?

append( ) → void

replaceChildren( ) → void

insertAdjacentHTML( ) → void

insertAdjacentText( ) → void

insertAdjacentElement(pos: ?, other: ?) → void

argtypedescription
pos?
other?

before( ) → void

after( ) → void

replaceWith( ) → void

querySelector(sel: ?) → void

argtypedescription
sel?

querySelectorAll( ) → void

getElementsByTagName( ) → void

getElementsByClassName( ) → void

getBoundingClientRect( ) → void

getContext(kind: ?) → void

argtypedescription
kind?

toDataURL( ) → void

toBlob(cb: ?) → void

argtypedescription
cb?

requestFullscreen( ) → void

animate( ) → void

play( ) → void

__elementFor(key: ?, tag: ?) → void

argtypedescription
key?
tag?

hasFocus( ) → void

createTextNode(t: ?) → void

argtypedescription
t?

createElement(tag: ?) → void

argtypedescription
tag?

createElementNS(ns: ?, tag: ?) → void

argtypedescription
ns?
tag?

getElementById(id: ?) → void

argtypedescription
id?

querySelector(sel: ?) → void

argtypedescription
sel?

querySelectorAll( ) → void

getElementsByTagName( ) → void

getElementsByClassName( ) → void

exitFullscreen( ) → void

dispatchEvent(ev: ?) → void

argtypedescription
ev?

matchMedia(media: ?) → void

argtypedescription
media?

getComputedStyle( ) → void

requestIdleCallback(fn: ?) → void

argtypedescription
fn?

cancelIdleCallback(id: ?) → void

argtypedescription
id?

Image( ) → void

Audio(src: ?) → void

argtypedescription
src?

canPlayType( ) → void

__makeResponse(url: ?, okFlag: ?, status: ?, body: ?) → void

argtypedescription
url?
okFlag?
status?
body?

__formatNumberEn(n: ?, opts: ?) → void

argtypedescription
n?
opts?

BigInt(v: ?) → void

argtypedescription
v?

asIntN(bits: ?, v: ?) → void

argtypedescription
bits?
v?

asUintN(bits: ?, v: ?) → void

argtypedescription
bits?
v?

confirm( ) → void

prompt( ) → void

open( ) → void

btoa(s: ?) → void

argtypedescription
s?

atob(s: ?) → void

argtypedescription
s?

dirname(path: string) → string

argtypedescription
pathstring

joinPath(baseDir: string, rel: string) → string

Join and normalize a relative specifier against a base directory, collapsing `.` and `..` segments.

argtypedescription
baseDirstring
relstring

tryRead(path: string) → string

argtypedescription
pathstring

resolveSpecifier(spec: string, importerId: string) → any

Resolve an import specifier to { id = <vfs path>, source } or nil.

argtypedescription
specstring
importerIdstring

renderErr(vm: any, err: any) → string

Render a pcall failure from module evaluation / a JS callback into one line, unwrapping a JS throw into its name/message/stack.

argtypedescription
vmany
errany

start(entry: string, opts: any?) → App

Build the VM + host session and evaluate the project's module graph rooted at `entry` (a VFS path to the main module). Top-level requestAnimationFrame / setAnimationLoop registrations land in the app's queue; the first pump runs them.

argtypedescription
entrystring
optsany?

pump(self: any, dt: number) → void

argtypedescription
selfany
dtnumber

stop(self: any) → void

argtypedescription
selfany
⌬ Types
App = {

Sub-parts

Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.

Showing up to 3 levels deep. Open a part to see what it holds further down.

24+items
❒
package · pulled in
❒asset
ZeroJS is a JavaScript interpreter for the Zero engine, written in Luau. It parses and executes ES2017-practical JavaScript entirely inside the Luau VM — no native code, no WebAssembly, no external dependency — and marshals values back to Luau transparently. ## Importing ```luau local zerojs = require("~zerojs.api") ``` `~zerojs` is this package's alias, registered from the `name` in its `package.yaml` wherever the package sits. The same spelling therefore works from the world that authors the package and from a world that installed it, at any depth. Every module is reachable the same way — `~zerojs.parser`, `~zerojs.stdlib.promise` — and the package's own modules reference each other with those ids. ## API surface ### Module-level | Symbol | Type | Description | |--------|------|-------------| | `zerojs.eval(src)` | `(string) -> any` | Parse and execute `src` in a fresh one-shot VM. Returns the marshaled JS completion value. Raises a Luau error on a JS exception. | | `zerojs.new(opts?)` | `(table?) -> VM` | Create a persistent VM. `opts.env` seeds additional JS globals from a Luau table. `opts.engine` picks the tier (`"auto"`, `"compiled"`, `"interp"`). `opts.console` is a table of writers by level (`log`, `info`, `debug`, `warn`, `error`): each receives the formatted text of one console call, untagged, and a level without a writer uses `log`'s. With no `opts.console`, the console writes `[zerojs]`-tagged lines to the engine log. | | `zerojs.null` | sentinel | The JS `null` value (distinct from Luau `nil`). | | `zerojs.undefined` | sentinel | The JS `undefined` value, which marshals to Luau `nil` when returned. | | `zerojs.version` | `string` | Version string of this package. | | `zerojs.lastError(vm)` | `(VM) -> table?` | Returns the structured payload `{ name, message, stack }` from the most recent JS exception on `vm`. `nil` if no exception has occurred on that VM. | ### VM instance | Method | Description | |--------|-------------| | `vm:run(src, opts?)` | Execute `src` in this VM's persistent realm. `opts.sourceName` names the source for error messages and stack frames. Returns the marshaled completion value. Raises directing to `runAsync` when the script leaves a timer armed or a coroutine suspended across a frame. | | `vm:runAsync(src, opts?)` | Execute `src`, driving its event loop across engine frames until it settles. Returns a `RunHandle` immediately. `opts.timeoutMs` rejects the run if it outlasts that many milliseconds. Only one `runAsync` may be in flight per VM at a time; a second call while the first is unsettled raises. | | `vm:get(name)` | Read a global from the VM's realm. | | `vm:set(name, value)` | Write a marshaled Luau value as a JS global in the VM's realm. | ### `RunHandle` (returned by `vm:runAsync`) | Field | Description | |-------|-------------| | `done` | `false` until the run reaches a terminal state, then `true`. | | `ok` | Once `done`, `true` for a resolved run and `false` for a rejection or timeout. | | `value` | The marshaled completion value on a resolved run. A run that timed out after its script had already completed with a value (an armed `setInterval`, say, kept the run open) keeps that value here; every other failure leaves it `nil`. | | `error` | The rendered message text on a rejected or timed-out run. | | `lastError` | The structured `{ name, message, stack }` payload for a failed run. | | `thread` | The engine `task.spawn` driver pumping the loop each frame — present only while the run is still pumping, and `nil` once the run settles on its arming frame (a synchronous or microtask-only completion needs no per-frame driver). | | `handle:await(maxFrames?)` | From a yieldable Luau context, poll `done` frame-by-frame until the handle settles, then return it. | A `runAsync` stays pending while the loop has work: an armed `setInterval` keeps it pending exactly as an un-`unref`'d handle keeps Node alive — clear the interval or bound the run with `timeoutMs`. ## Marshaling Luau values passed to `opts.env` or `vm:set` are converted to JS values. JS values returned from `run`/`eval` are converted back to Luau: numbers, strings, and booleans are transparent; arrays become 1-based Luau tables; objects become string-keyed Luau tables; JS functions become callable Luau closures; `undefined` becomes `nil`; `null` becomes `zerojs.null`. ## Step-budget sandbox Each VM runs with a default execution budget of 1,000,000 interpreter steps. A script that exceeds the budget raises a JS `RangeError: step budget exceeded`, which surfaces as a Luau error. The budget resets on each `run`/`eval` call. ## Language scope - Variable declarations: `var` (function-scoped hoisting), `let` and `const` with full TDZ enforcement - Functions: declarations, expressions, arrow functions, closures, rest parameters, default parameters - Classes: declarations and expressions, inheritance via `extends`, `super()` in constructors and methods, getter and setter accessors, instance fields, static fields and methods, computed method keys, named class expressions, TDZ before declaration - Destructuring: object and array patterns in declarations, assignment, and function parameters; nested patterns; rename, default, rest; computed keys in object patterns; elision in array patterns - Spread: array literals, call arguments, `new` arguments, object literals - Template literals (untagged) - Optional chaining: `a?.b`, `a?.[k]`, `f?.(x)`. A `null` or `undefined` base ends the whole chain with `undefined` and skips every later link and argument; parentheses end the chain; the chain is not an assignment, update or `new` target - Nullish coalescing `??` and the logical assignments `??=`, `||=` and `&&=`, which evaluate the right side and write only when the current value calls for it. `??` does not mix with `||` or `&&` without parentheses - Full coercion and equality semantics: `==`/`!=` abstract equality, `===`/`!==` strict equality, `typeof`, `instanceof` - `try`/`catch`/`finally`, `throw` - All loop forms: `for`, `while`, `do-while`, `for-in`, `for-of`; `switch` with fallthrough - `async`/`await` — real event-loop semantics: an async function returns a promise, runs synchronously up to the first `await`, and resumes from a microtask when its awaited operand settles - Property enumerability: `for-in` yields only own enumerable keys; object rest excludes prototype methods ### Asynchrony and the event loop - `Promise` with the full ES surface: `then`/`catch`/`finally`, `resolve`/`reject`, and the combinators `all`, `allSettled`, `race`, and `any` (with `AggregateError` when every input to `any` rejects) - `queueMicrotask` for scheduling a microtask directly - Timers: `setTimeout`/`clearTimeout` and `setInterval`/`clearInterval`, with extra arguments forwarded to the callback - `vm:runAsync(src, opts?)` drives a script's timers, microtasks, and promise settlements across engine frames and returns a `RunHandle` (see the VM table above) - A long synchronous loop under `runAsync` yields at each step-budget boundary and resumes on a later frame instead of raising `RangeError`; the same script under `vm:run` still raises ### Standard library - `Object`: callable coercion plus `keys`, `values`, `entries`, `assign`, `freeze`, `isFrozen`, `create`, `getPrototypeOf`, `defineProperty`, `fromEntries`, `hasOwn`, and the `Object.prototype` methods (`hasOwnProperty`, `toString`, `isPrototypeOf`) - `Function.prototype`: `call`, `apply`, `bind` - Global conversions and predicates: `parseInt`, `parseFloat`, `isNaN`, `isFinite`, `String`, `Number`, `Boolean` - `Array` and `Array.prototype`: construction, `isArray`, `from`, `of`, and the iteration/mutation/query methods (`map`, `filter`, `reduce`, `forEach`, `find`, `some`, `every`, `slice`, `splice`, `concat`, `join`, `indexOf`, `includes`, `sort`, `reverse`, `push`, `pop`, `shift`, `unshift`, `flat`, `fill`, `keys`, `values`, `entries`) - `String.prototype`: `slice`, `substring`, `substr`, `split`, `indexOf`, `includes`, `startsWith`, `endsWith`, `repeat`, `padStart`, `padEnd`, `trim`, `trimStart`, `trimEnd`, `toUpperCase`, `toLowerCase`, `charAt`, `charCodeAt`, `codePointAt`, `at`, `concat`, `replace`, `replaceAll`, `match`, `matchAll`, `search` - `Number`: `isInteger`, `isSafeInteger`, `isFinite`, `isNaN`, `parseFloat`, `parseInt`, `MAX_SAFE_INTEGER`, `MIN_SAFE_INTEGER`, `MAX_VALUE`, `MIN_VALUE`, `EPSILON`, `POSITIVE_INFINITY`, `NEGATIVE_INFINITY`, `NaN`, and `Number.prototype` (`toFixed`, `toString`, `toPrecision`) - `Math`: the constants and functions (`abs`, `floor`, `ceil`, `round`, `trunc`, `sign`, `min`, `max`, `pow`, `sqrt`, `cbrt`, `hypot`, `exp`, `log`, `log2`, `log10`, the trig family, `random`) - `Date`: construction as `new Date()` (now) and `new Date(ms)` (epoch milliseconds), `now` (the wall clock at the moment of the call, never ahead of it and never moving backwards; whole-second readings of the wall clock bound it until a reading crosses a second boundary), `getTime`, `getFullYear`, `getMonth`, `getDate`, `getHours`, `getMinutes`, `getSeconds`, `getMilliseconds`, `getDay`, `toISOString`, `toJSON` - `JSON`: `parse` and `stringify` (indent argument and array replacer whitelist) - `Map` and `Set`: construction from iterables, `get`/`set`/`has`/`delete`/`clear`, `add`, `size`, `forEach`, `keys`, `values`, `entries`, insertion-order iteration - `RegExp`: literals and the constructor, `test`, `exec`, `lastIndex`, `source`, `flags`, `global`, `ignoreCase`, `multiline`, `dotAll`, and the `String` regex methods above - Errors: `Error`, `TypeError`, `RangeError`, `ReferenceError`, `SyntaxError` constructors and inheritance; `Error.prototype.name`, `message` and `toString`, so `String(e)`, `${e}` and `"" + e` read `<name>: <message>` - `console`: `log`, `info`, `debug`, `warn`, `error`, `dir` and `assert`. Values print the way a JavaScript console prints them: strings bare at the top and quoted inside, `{ a: 1, b: [ 1, 2 ] }`, `Map(1) { 'a' => 1 }`, `[Function: f]`, errors as `Error: message`, nested values below depth 2 as `[Object]` and `[Array]`, arrays and collections cut after 100 entries, a self-containing value as `<ref *1> { self: [Circular *1] }`, and a rendering wider than 80 characters across lines. A leading `%s`, `%d`, `%i`, `%f`, `%j`, `%o`, `%O`, `%c` or `%%` formats the arguments after it - `performance.now()` (milliseconds on a monotonic clock since the VM was created) and `performance.timeOrigin` - `globalThis`, `NaN`, `Infinity` ### Out of scope by design - Generators and iterators (`function*`, `yield`) - `Proxy` and `Reflect` - Labeled statements and `with` - Tagged template literals The full divergence list — where ZeroJS behavior differs from a browser engine — lives in the guide's divergence section. ## Test suites Eleven suites ship with the package, in its `tests/` folder, run via `tools.tests.run`: ```luau tools.tests.run({ suite = "zerojs_lexer" }) -- tokenization tools.tests.run({ suite = "zerojs_parser" }) -- AST construction and error recovery tools.tests.run({ suite = "zerojs_semantics" }) -- runtime semantics end-to-end tools.tests.run({ suite = "zerojs_language" }) -- ?., ??, logical assignment, error text, console, Date.now, performance.now tools.tests.run({ suite = "zerojs_stdlib" }) -- the standard-library surface tools.tests.run({ suite = "zerojs_typed_arrays" }) -- typed arrays, ArrayBuffer, DataView tools.tests.run({ suite = "zerojs_regex" }) -- the regex engine and RegExp methods tools.tests.run({ suite = "zerojs_async" }) -- the event loop, promises, and timers tools.tests.run({ suite = "zerojs_modules" }) -- the module graph tools.tests.run({ suite = "zerojs_assettype" }) -- the zJs asset type tools.tests.run({ suite = "zerojs_smoke" }) -- unmodified real-world JS programs ```
▲ 1↓ import
▣
module · born here
❒asset
# host A module script.
▲ 0↑ born
▣
module · pulled in
❒asset
# api The ZeroJS public API: zerojs.new/eval, VM run/get/set, sentinels, and version. The package root init.luau re-exports this module.
▲ 0↓ import
▣
module · pulled in
❒asset
# modules.module The ES module graph for zerojs: evaluate-once semantics, namespace objects, and cycle detection, parameterized by a host resolver so it stays asset-agnostic. `evaluate` walks the dependency graph depth-first from a root id, evaluating each module body once through the interpreter's module entry and caching the frozen namespace in a per-VM registry keyed by id. `vm:evalModule` is the public entry.
▲ 0↓ import
▣
module · pulled in
❒asset
# errors Construction and propagation of JavaScript errors: `makeError` builds a JS Error object, `throwJs`/`throwError` raise a thrown JS value across the Luau boundary, and `isJsThrow` recovers it, so JS exceptions round-trip as Luau errors.
▲ 0↓ import
❒
package · born here
❒asset
# ThreeZero A three.js runtime for the Zero engine, built on the ZeroJS JavaScript interpreter. Drop an existing three.js project into the world's VFS, point a `ThreeApp` component at its entry module, and the project runs unmodified — `import * as THREE from 'three'` resolves to a THREE-compatible API whose scene graph renders through Zero's real renderer, GLTF models spawn through the engine's import pipeline, and keyboard/mouse events reach game code as DOM events. ## Pieces - `host.module` — the `__ZERO` host bridge: entity pools mirroring the THREE scene graph 1:1 (world composition happens in the native hierarchy), change-set-only batched transform sync, runtime meshes from BufferGeometry vertex data, GLTF bundle spawning, lights, the viewport camera, input snapshots/events, and screen/time queries. - `runner.module` — builds a ZeroJS VM per app: installs the browser prelude (window, document, performance, typed arrays, a real event registry), resolves ES imports (`three`, `three/addons/...`, relative `./file.js` paths), dispatches engine input as DOM `keydown`/`keyup`/mouse/touch events each frame, and pumps the VM event loop plus animation-frame callbacks with a self-healing loop. - `three.zJs` — the THREE API surface: math, the Object3D graph with mutation tracking (only changed transforms cross the bridge), geometries (parametric + real-vertex BufferGeometry), materials, lights, cameras, Clock, AnimationMixer, and a WebGLRenderer whose `render(scene, camera)` diffs arrivals/departures/dirty objects into host calls. - `OrbitControls.zJs` — `three/addons/controls/OrbitControls.js`: drag-orbit, scroll zoom, pan, damping, auto-rotate, from the engine input snapshot. - `GLTFLoader.zJs` — `three/addons/loaders/GLTFLoader.js`: binds models to imported bundles by URL basename; DRACOLoader/KTX2Loader accepted inert. - `ThreeApp.component` — attach to an entity, set `entry` to the project's main module VFS path; the app boots on play and tears down on edit. ## Running a project ThreeZero builds on the `zerojs` package and reaches it by the package alias `~zerojs`, which a package registers from the `name` in its `package.yaml` wherever it sits. Installing ThreeZero brings `zerojs` along as a dependency, so nothing has to be wired up by hand; `~threezero.runner` and `~threezero.host` address this package's own modules the same way. ``` /zero/source/projects/myapp/main.js ← unmodified three.js sources /zero/source/projects/myapp/models/*.glb ← model files (imported to bundles on upload) ``` ```luau entity.spawn("MyApp").component.add("ThreeApp", { entry = "/zero/source/projects/myapp/main.js" }) ``` Flip to play mode. `requestAnimationFrame` / `setAnimationLoop` run once per engine frame, and `addEventListener('keydown' | 'mousedown' | ...)` receives live input — playable games work end to end (see `/zero/source/projects/crossing`). ## Limitations - No optional chaining (`?.`), `#private` fields, or `Symbol` in project code. - Textures load as inert handles; material color/emissive/opacity drive the visual. - Points/Line/Sprite objects are skipped with a one-time warning. - Skinned-mesh submeshes from imported models render at bind pose or are hidden (engine importer limitation); AnimationMixer plays clips through the engine's ClipPlayer where the rig supports it.
▲ 0↑ born
▣
module · pulled in
❒asset
# values The JavaScript value model: the `undefined` and `null` sentinels, their predicates, and `jsTypeof`, which classify the primitive and reference values the interpreter operates on.
▲ 0↓ import
▣
module · pulled in
❒asset
# stdlib The JavaScript standard-library surface installed onto a realm's global object. `stdlib.install(rt, globalObj)` applies each submodule installer. `object.luau` owns the `Object` callable and its statics, `Object.prototype`, `Function.prototype` (call/apply/bind), a minimal `Number.prototype.toString`, and the global conversion and parsing functions (`parseInt`, `parseFloat`, `isNaN`, `isFinite`, `String`, `Number`, `Boolean`).
▲ 0↓ import
backing path · threezero.package/runner.module

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported on this asset or on the parts this page shows. Parts it leaves out are not counted here.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.