# Vendored Luau runtime

The `luau-web.js` adapter and `luau.wasm` virtual machine come from [luau-web](https://github.com/xNasuni/luau-web) 1.5.0, by xNasuni and contributors. The package declares the MIT license. Its WebAssembly runtime is built from [luau-interop](https://github.com/xNasuni/luau-interop), a community-maintained fork of [Luau](https://github.com/luau-lang/luau). This is not an official Roblox-distributed WebAssembly release.

Upstream Luau and Lua copyright notices and MIT permission terms are preserved in `LICENSE-luau.txt` and `LICENSE-lua.txt`. The npm package does not ship a separate license file for its JavaScript bindings; its published license field is MIT.

- Package: `luau-web@1.5.0`
- Published repository commit: `a989793b02f002e1915abecd4e33eaca22742802`
- Archive: https://registry.npmjs.org/luau-web/-/luau-web-1.5.0.tgz
- Archive integrity: `sha512-9ED1epPWFQJKgXgwvd+QNepqgkS2i5KUNNU5e3/qWog2FKeaKDop+8eZjcRZzzHFQ3i5Mu7RPxYf69IK/8YXjA==`
- WASM SHA-256: `55447228712809ff36a3a791c5497f095e478f89026aba7a6ae6f702cd6da7fb`
- JavaScript SHA-256: `5358568ed87946514632532aabe7445714e390ffcc007378fe7f0a44484e0b03`

Regenerate with `node scripts/vendor-runtime.js`, or pass `--archive PATH` to use a previously downloaded archive. The generator verifies the pinned archive, extracts the binary, chooses the broadly compatible Asyncify build, converts the wrapper to classic JavaScript/CommonJS, and adds same-origin WASM loading. It removes the generated worker-environment assertion because the new loader supports workers, caps the WebAssembly memory maximum at 256 MiB (initial memory: 64 MiB), and extends compilation transactions to accept byte arrays. JavaScript-to-Lua call arguments use scoped heap allocations rather than the native stack, so large HTTP responses, function arguments, and callback results cannot overwrite stack memory; temporary buffers are released after synchronous/asynchronous completion and on errors. The `createRuntime()` factory isolates upstream native caches; the upstream process exit listener is removed so it cannot retain destroyed heaps. It uses only Node.js built-ins, does not evaluate downloaded code, and requires no npm installation.

Browser API: create a fresh context with `const runtime = TrackerLuau.createRuntime()`, then `runtime.LuauState.createAsync(environment)`, followed by `state.loadstring(source, name, true)` and an awaited function call. CommonJS uses `require("./vendor/luau-web.js")`. Use one state per runtime context: upstream native pointer caches survive `lua_close`, so creating several states in the same context is unsafe. Lua function return values arrive as JavaScript arrays. Injected JavaScript callbacks may return promises. Native Lua `loadstring` is not exposed by this package; the application provides an instrumented compilation bridge.

Keep this runtime in a dedicated worker so the application can terminate infinite loops. Worker loading assumes the application worker is at the site root; set `globalThis.TRACKER_LUAU_WASM_URL` to an absolute URL for other layouts. The runtime requires WebAssembly and CSP `script-src` permission `wasm-unsafe-eval`; it does not use JavaScript `eval` or `new Function`.

Lua strings remain byte-accurate inside the virtual machine. The upstream JavaScript bridge decodes strings as UTF-8, so invalid UTF-8 bytes can be replaced when crossing into JavaScript. Binary analysis output must be encoded inside Lua before crossing this boundary. The application extension `state.loadstringBytes(Uint8Array, name, throwOnCompilationError)` compiles original bytes without UTF-8 replacement. It refuses raw NUL bytes because upstream compilation uses a NUL-terminated source pointer; escaped Lua byte literals such as `\000` work normally.
