@loom-dev/luau 0.0.0-stage → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mount-2LXSpSYv.js","names":[],"sources":["../src/prelude.ts","../src/project.ts","../src/vm.ts","../src/bindings.ts","../src/mount.ts"],"sourcesContent":["/**\n * `prelude.ts` — the Luau half of the globals.\n *\n * Runs once on the main state before the globals freeze, with a table of host\n * primitives as its argument (see `install` in `bindings.ts`). What lives here\n * is what is simplest to say in Luau itself: the `task` library on top of\n * `coroutine` and the host's resume points, and the `print`/`warn` that\n * `tostring` their arguments the way the engine does.\n */\nexport const PRELUDE = `\nlocal host = ...\n\nlocal function thread(f)\n\treturn if type(f) == \"thread\" then f else coroutine.create(f)\nend\n\nlocal task = {}\n\nfunction task.spawn(f, ...)\n\tlocal co = thread(f)\n\tlocal ok, err = coroutine.resume(co, ...)\n\tif not ok then\n\t\thost.report(tostring(err), debug.traceback(co))\n\tend\n\treturn co\nend\n\nfunction task.defer(f, ...)\n\tlocal co = thread(f)\n\thost.defer(co, ...)\n\treturn co\nend\n\nfunction task.delay(seconds, f, ...)\n\tlocal co = thread(f)\n\thost.delay(seconds or 0, co, ...)\n\treturn co\nend\n\ntask.wait = host.wait\n\nfunction task.cancel(co)\n\tcoroutine.close(co)\nend\n\nfunction task.synchronize() end\nfunction task.desynchronize() end\n\n_G.task = task\n\n-- The engine's additions to \\`debug\\`: the MicroProfiler labels and the memory\n-- categories. loom has neither profiler, so they record nothing. Ripple wraps\n-- every Heartbeat step in a profile label.\nfunction debug.profilebegin(_label) end\nfunction debug.profileend() end\nfunction debug.setmemorycategory(_tag) return \"\" end\nfunction debug.resetmemorycategory() end\nfunction debug.getmemorycategory() return \"\" end\nwait = task.wait\nspawn = task.defer\ndelay = task.delay\ntick = host.tick\ntime = host.time\nelapsedTime = host.time\n\nlocal function join(...)\n\tlocal n = select(\"#\", ...)\n\tlocal parts = table.create(n)\n\tfor i = 1, n do\n\t\tparts[i] = tostring((select(i, ...)))\n\tend\n\treturn table.concat(parts, \" \")\nend\n\nfunction print(...)\n\thost.print(join(...))\nend\n\nfunction warn(...)\n\thost.warn(join(...))\nend\n\nfunction require(module)\n\t-- A string path resolves from the requiring script: the caller's own\n\t-- environment holds it as \\`script\\`.\n\tlocal from = if type(module) == \"string\" then getfenv(2).script else nil\n\tlocal ok, value = host.require(module, from)\n\tif not ok then\n\t\terror(value, 2)\n\tend\n\treturn value\nend\n`;\n","/**\n * `project.ts` — a Rojo project as live instances, and the client's startup.\n *\n * The preview plugin reads a project from disk (`default.project.json`, or the\n * Rojo template's `src/{client,server,shared}` when there is none) and hands it\n * over as a `LuauProjectNode` tree with every script's source inlined. Here it\n * becomes real instances under the runtime's `game`: Folders, ModuleScripts,\n * LocalScripts and Scripts in their services, with each script's source kept\n * beside it — Roblox does not let a LocalScript read `Source`, and neither\n * does loom.\n *\n * `startClient` then does what a joining client does: run the LocalScripts in\n * ReplicatedFirst, copy StarterGui into PlayerGui and StarterPlayerScripts into\n * PlayerScripts, and run the LocalScripts that land there. Server Scripts are\n * instantiated (so `require` and `FindFirstChild` see them) but never run — a\n * preview is one client.\n */\nimport { createInstance, game, type LoomInstance } from \"@loom-dev/runtime\";\n\n/** One instance of a project tree, as the preview plugin emits it. */\nexport interface LuauProjectNode {\n\treadonly name: string;\n\treadonly className: string;\n\t/** A script's source. */\n\treadonly source?: string;\n\treadonly children?: readonly LuauProjectNode[];\n}\n\nexport interface LuauProject {\n\t/** The `DataModel` root; its children are services. */\n\treadonly tree: LuauProjectNode;\n}\n\nconst SOURCES = new WeakMap<LoomInstance, string>();\n\n/** Attach `source` to a script instance (what `require` and `startClient` run). */\nexport function setScriptSource(script: LoomInstance, source: string): void {\n\tSOURCES.set(script, source);\n}\n\n/** The source behind a script instance, if loom has one for it. */\nexport function getScriptSource(script: LoomInstance): string | undefined {\n\treturn SOURCES.get(script);\n}\n\n/**\n * `Clone`, keeping every script's source. The runtime copies instances but\n * knows nothing about loom's source registry, so the two trees are walked side\n * by side — `Clone` keeps child order and drops the non-Archivable ones.\n */\nexport function cloneWithSources(\n\toriginal: LoomInstance,\n): LoomInstance | undefined {\n\tconst copy = original.Clone();\n\tif (copy !== undefined) copySources(original, copy);\n\treturn copy;\n}\n\nfunction copySources(from: LoomInstance, to: LoomInstance): void {\n\tconst source = SOURCES.get(from);\n\tif (source !== undefined) SOURCES.set(to, source);\n\tconst kept = from.GetChildren().filter((child) => child.Archivable !== false);\n\tconst copies = to.GetChildren();\n\tkept.forEach((child, i) => {\n\t\tconst copy = copies[i];\n\t\tif (copy !== undefined) copySources(child, copy);\n\t});\n}\n\nconst instantiated = new WeakSet<LuauProject>();\n\n/**\n * Build `project` into the runtime's `game`, once per project object. A node\n * whose name and class match an instance that already exists (a service,\n * `StarterPlayerScripts`) is merged into it rather than duplicated.\n */\nexport function instantiateProject(project: LuauProject): void {\n\tif (instantiated.has(project)) return;\n\tinstantiated.add(project);\n\tfor (const child of project.tree.children ?? []) {\n\t\tconst service = game.GetService(child.name);\n\t\tpopulate(service, child);\n\t}\n}\n\nfunction populate(parent: LoomInstance, node: LuauProjectNode): void {\n\tfor (const child of node.children ?? []) {\n\t\tconst existing = parent.FindFirstChild(child.name);\n\t\tconst instance =\n\t\t\texisting?.ClassName === child.className\n\t\t\t\t? existing\n\t\t\t\t: createInstance(child.className, child.name);\n\t\tif (child.source !== undefined) setScriptSource(instance, child.source);\n\t\tpopulate(instance, child);\n\t\tinstance.Parent = parent;\n\t}\n}\n\n/** A LocalScript to run, and the name errors should give it. */\nexport interface ClientScript {\n\treadonly script: LoomInstance;\n\treadonly source: string;\n}\n\n/**\n * The client's startup, in Roblox order: ReplicatedFirst's LocalScripts, then\n * StarterGui copied into PlayerGui, then StarterPlayerScripts copied into\n * PlayerScripts. Returns every LocalScript that should run, in that order.\n */\nexport function startClient(): ClientScript[] {\n\tconst player = game.GetService(\"Players\").LocalPlayer as LoomInstance;\n\tconst playerGui = player.WaitForChild(\"PlayerGui\") as LoomInstance;\n\tlet playerScripts = player.FindFirstChildOfClass(\"PlayerScripts\");\n\tif (playerScripts === undefined) {\n\t\tplayerScripts = createInstance(\"PlayerScripts\", \"PlayerScripts\");\n\t\tplayerScripts.Parent = player;\n\t}\n\n\tconst scripts: ClientScript[] = [];\n\tcollect(game.GetService(\"ReplicatedFirst\"), scripts);\n\tfor (const child of game.GetService(\"StarterGui\").GetChildren()) {\n\t\tconst copy = cloneWithSources(child);\n\t\tif (copy === undefined) continue;\n\t\tcopy.Parent = playerGui;\n\t\tcollect(copy, scripts);\n\t}\n\tconst starterScripts = game\n\t\t.GetService(\"StarterPlayer\")\n\t\t.FindFirstChild(\"StarterPlayerScripts\");\n\tfor (const child of starterScripts?.GetChildren() ?? []) {\n\t\tconst copy = cloneWithSources(child);\n\t\tif (copy === undefined) continue;\n\t\tcopy.Parent = playerScripts;\n\t\tcollect(copy, scripts);\n\t}\n\treturn scripts;\n}\n\n/** `root` and its descendants' runnable LocalScripts, in tree order. */\nfunction collect(root: LoomInstance, into: ClientScript[]): void {\n\tfor (const instance of [root, ...root.GetDescendants()]) {\n\t\tif (instance.ClassName !== \"LocalScript\" || instance.Disabled === true)\n\t\t\tcontinue;\n\t\tconst source = SOURCES.get(instance);\n\t\tif (source !== undefined) into.push({ script: instance, source });\n\t}\n}\n","/**\n * `vm.ts` — `LuauVM`, the Luau virtual machine (upstream Luau compiled to\n * WASM, see `native/`) with a JavaScript-shaped API on top of its stack.\n *\n * The VM knows nothing about Roblox. It moves values across the boundary and\n * runs threads; `bindings.ts`-style layers decide what Luau sees:\n *\n * - Luau → JS: nil is `undefined`, booleans/numbers/strings are themselves, a\n * host userdata is the JS object it was made from, and tables, functions and\n * threads arrive as `LuauTable`/`LuauFunction`/`LuauThread` references.\n * - JS → Luau: a JS function becomes a host function; an object the\n * classifier recognises becomes host userdata dispatched through its\n * `HostClass` (the same object is always the same userdata, so `==` and\n * table keys behave); plain arrays and objects are copied into new tables.\n *\n * Yielding is Roblox's model: a host function that returns a `Suspend` yields\n * the calling thread, and the thread runs again when the `Suspend` resumes it —\n * whoever resumed the thread in the first place.\n */\nimport createLuauModule, { type LuauModule } from \"../wasm/luau-vm.mjs\";\n\n// Stable value kinds reported by `lb_kind` (bridge.cpp `Kind`).\nconst KIND_NIL = 0;\nconst KIND_BOOLEAN = 1;\nconst KIND_NUMBER = 2;\nconst KIND_STRING = 3;\nconst KIND_TABLE = 4;\nconst KIND_FUNCTION = 5;\nconst KIND_HOST = 6;\nconst KIND_THREAD = 7;\n\nconst LUA_OK = 0;\nconst LUA_YIELD = 1;\n/** `LUA_GLOBALSINDEX`: `-LUAI_MAXCSTACK - 2002`, with Luau's default 8000. */\nconst LUA_GLOBALSINDEX = -10002;\n\n// `lua_costatus`: a thread that has not started, or is parked in a yield.\nconst LUA_COSUS = 1;\n\n// Host-call sentinels (bridge.cpp `LB_ERROR` / `LB_YIELD`).\nconst LB_ERROR = -1;\nconst LB_YIELD = -2;\n\n/** An error raised in Luau, or by a host function on Luau's behalf. */\nexport class LuauError extends Error {\n\toverride readonly name = \"LuauError\";\n\n\tconstructor(\n\t\tmessage: string,\n\t\t/** The raised value itself (`error({ code = 1 })` keeps its table). */\n\t\treadonly value: unknown = message,\n\t\t/** The Luau stack at the point of the error, when known. */\n\t\treadonly traceback?: string,\n\t) {\n\t\tsuper(message);\n\t}\n}\n\n/** Several return values from a host function. */\nexport class Tuple {\n\tconstructor(readonly values: readonly unknown[]) {}\n}\n\n/** Return several values from a host function. */\nexport function tuple(...values: unknown[]): Tuple {\n\treturn new Tuple(values);\n}\n\n/**\n * Returned by a host function to yield the thread that called it. `wait` runs\n * once the thread has actually suspended and receives the function that\n * resumes it with the host function's results.\n */\nexport class Suspend {\n\tconstructor(\n\t\treadonly wait: (resume: (...values: unknown[]) => void) => void,\n\t) {}\n}\n\n/**\n * How Luau sees one kind of host object. Every hook is optional: a missing\n * `index` makes every field read an error, a missing `namecall` every method\n * call. Arithmetic hooks receive both operands, either of which may be the\n * host object.\n */\nexport interface HostClass<T extends object = object> {\n\t/** What `typeof` returns. */\n\treadonly name: string;\n\tindex?(self: T, key: unknown): unknown;\n\tnewindex?(self: T, key: unknown, value: unknown): void;\n\tnamecall?(self: T, method: string, args: unknown[]): unknown;\n\tcall?(self: T, args: unknown[]): unknown;\n\ttostring?(self: T): string;\n\teq?(a: T, b: unknown): boolean;\n\tlt?(a: unknown, b: unknown): boolean;\n\tle?(a: unknown, b: unknown): boolean;\n\tlen?(self: T): number;\n\tunm?(self: T): unknown;\n\tadd?(a: unknown, b: unknown): unknown;\n\tsub?(a: unknown, b: unknown): unknown;\n\tmul?(a: unknown, b: unknown): unknown;\n\tdiv?(a: unknown, b: unknown): unknown;\n\tidiv?(a: unknown, b: unknown): unknown;\n\tmod?(a: unknown, b: unknown): unknown;\n\tpow?(a: unknown, b: unknown): unknown;\n}\n\n/** Picks the `HostClass` for a JS object, or `undefined` to copy it as a table. */\nexport type Classifier = (value: object) => HostClass | undefined;\n\nexport interface LuauVMOptions {\n\t/** Decides which JS objects cross as host userdata. */\n\tclassify?: Classifier;\n\t/** Where an error that escapes a thread goes. Defaults to `console.error`. */\n\tonError?: (error: LuauError) => void;\n\t/** Wall-clock milliseconds one entry into Luau may run. 0 disables. */\n\tbudgetMs?: number;\n\t/** Passed to emscripten — for loading the `.wasm` from somewhere unusual. */\n\tlocateFile?: (path: string, prefix: string) => string;\n\t/** The `.wasm` bytes themselves, skipping the fetch (tests, Node). */\n\twasmBinary?: ArrayBuffer | Uint8Array;\n\t/**\n\t * Globals that stay writable tables after the freeze, one table each that\n\t * every script shares — Roblox's `_G` and `shared`. The sandbox freezes\n\t * every table it finds, so these are made fresh once it has run.\n\t */\n\tsharedTables?: readonly string[];\n}\n\n/** How a resumed thread came back. */\nexport type ThreadResult =\n\t| { readonly status: \"done\"; readonly values: unknown[] }\n\t| { readonly status: \"yielded\" }\n\t| { readonly status: \"error\"; readonly error: LuauError };\n\ntype HostEntry = (L: number, args: unknown[]) => unknown;\n\ninterface HostHandle {\n\treadonly value: object;\n\treadonly cls: HostClass;\n\t/** Live userdata holding this handle (normally 1; see `lbHostRelease`). */\n\tcount: number;\n}\n\nconst METAMETHODS = [\n\t\"__index\",\n\t\"__newindex\",\n\t\"__namecall\",\n\t\"__call\",\n\t\"__tostring\",\n\t\"__eq\",\n\t\"__lt\",\n\t\"__le\",\n\t\"__len\",\n\t\"__unm\",\n\t\"__add\",\n\t\"__sub\",\n\t\"__mul\",\n\t\"__div\",\n\t\"__idiv\",\n\t\"__mod\",\n\t\"__pow\",\n] as const;\n\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\n\n/** A reference that keeps a Luau value alive until the JS side is collected. */\nabstract class LuauRef {\n\tconstructor(\n\t\t/** @internal */ readonly vm: LuauVM,\n\t\t/** @internal */ readonly ref: number,\n\t) {\n\t\tvm.track(this, ref);\n\t}\n}\n\n/** A Luau function. `call` runs it to completion; `spawn` gives it a thread. */\nexport class LuauFunction extends LuauRef {\n\tcall(...args: unknown[]): unknown[] {\n\t\treturn this.vm.call(this, args);\n\t}\n\n\tspawn(...args: unknown[]): ThreadResult {\n\t\treturn this.vm.spawn(this, args);\n\t}\n}\n\n/** A Luau table, read and written raw (no metamethods). */\nexport class LuauTable extends LuauRef {\n\tget(key: unknown): unknown {\n\t\treturn this.vm.tableGet(this, key);\n\t}\n\n\tset(key: unknown, value: unknown): void {\n\t\tthis.vm.tableSet(this, key, value);\n\t}\n\n\t/** `#t`. */\n\tget length(): number {\n\t\treturn this.vm.tableLength(this);\n\t}\n\n\t/** Every key/value pair, in `next` order. */\n\tentries(): [unknown, unknown][] {\n\t\treturn this.vm.tableEntries(this);\n\t}\n\n\t/** `t[1]` … `t[#t]`. */\n\tarray(): unknown[] {\n\t\tconst out: unknown[] = [];\n\t\tconst n = this.length;\n\t\tfor (let i = 1; i <= n; i++) out.push(this.get(i));\n\t\treturn out;\n\t}\n}\n\n/** A Luau coroutine. */\nexport class LuauThread extends LuauRef {}\n\n/** A Luau value JS has no use for beyond handing it back (vector, buffer, …). */\nexport class LuauOpaque extends LuauRef {\n\tconstructor(\n\t\tvm: LuauVM,\n\t\tref: number,\n\t\treadonly typeName: string,\n\t) {\n\t\tsuper(vm, ref);\n\t}\n}\n\nexport class LuauVM {\n\t/** Instantiate the WASM module and open a fresh Luau state. */\n\tstatic async create(options: LuauVMOptions = {}): Promise<LuauVM> {\n\t\tlet vm: LuauVM | undefined;\n\t\tconst module = await createLuauModule({\n\t\t\tlbHostCall: (L, id) => (vm as LuauVM).hostCall(L, id),\n\t\t\tlbHostRelease: (handle) => vm?.hostRelease(handle),\n\t\t\t...(options.locateFile ? { locateFile: options.locateFile } : {}),\n\t\t\t...(options.wasmBinary ? { wasmBinary: options.wasmBinary } : {}),\n\t\t});\n\t\tvm = new LuauVM(module, options);\n\t\treturn vm;\n\t}\n\n\tprivate readonly M: LuauModule;\n\tprivate readonly L: number;\n\tprivate readonly classify: Classifier;\n\tprivate readonly onError: (error: LuauError) => void;\n\tprivate readonly budgetMs: number;\n\tprivate readonly sharedTables: readonly string[];\n\n\tprivate readonly entries: HostEntry[] = [];\n\tprivate readonly functionIds = new Map<\n\t\t(...args: never[]) => unknown,\n\t\tnumber\n\t>();\n\tprivate readonly debugNames = new Map<string, number>();\n\tprivate readonly handles = new Map<number, HostHandle>();\n\tprivate readonly handleOf = new Map<object, number>();\n\tprivate nextHandle = 1;\n\tprivate readonly metatables = new Map<HostClass, number>();\n\tprivate readonly metamethodIds = new Map<string, number>();\n\tprivate readonly refs = new FinalizationRegistry<number>((ref) => {\n\t\tif (!this.closed) this.M._lb_unref(this.L, ref);\n\t});\n\n\tprivate scratch = 0;\n\tprivate scratchSize = 0;\n\tprivate readonly lenPtr: number;\n\tprivate depth = 0;\n\tprivate frozen = false;\n\tprivate closed = false;\n\t/** `run`'s `onFinish` for each thread still on its way to the end. */\n\tprivate readonly finishers = new Map<\n\t\tnumber,\n\t\t(result: ThreadResult) => void\n\t>();\n\n\tprivate constructor(module: LuauModule, options: LuauVMOptions) {\n\t\tthis.M = module;\n\t\tthis.L = module._lb_open();\n\t\tthis.classify = options.classify ?? (() => undefined);\n\t\tthis.onError = options.onError ?? ((error) => console.error(error.message));\n\t\tthis.budgetMs = options.budgetMs ?? 0;\n\t\tthis.sharedTables = options.sharedTables ?? [];\n\t\tthis.lenPtr = module._malloc(4);\n\t\tfor (const name of METAMETHODS) {\n\t\t\tthis.metamethodIds.set(name, this.register(this.metamethod(name)));\n\t\t}\n\t}\n\n\t// --- globals and scripts ---------------------------------------------------\n\n\t/** Define a global. Only before the first script runs (globals freeze then). */\n\tsetGlobal(name: string, value: unknown): void {\n\t\tif (this.frozen)\n\t\t\tthrow new Error(`loom luau: globals are frozen; cannot set ${name}`);\n\t\tthis.push(this.L, value);\n\t\tthis.M._lb_setglobal(this.L, this.cstr(name));\n\t}\n\n\tgetGlobal(name: string): unknown {\n\t\tconst base = this.M._lb_gettop(this.L);\n\t\tthis.M._lb_getglobal(this.L, this.cstr(name));\n\t\tconst value = this.read(this.L, -1);\n\t\tthis.M._lb_settop(this.L, base);\n\t\treturn value;\n\t}\n\n\t/**\n\t * Freeze the globals and the standard libraries, Roblox style. Runs on its\n\t * own before the first script; scripts then see the frozen set through\n\t * their own writable environment.\n\t */\n\tfreeze(): void {\n\t\tif (this.frozen) return;\n\t\tthis.frozen = true;\n\t\tthis.M._lb_sandbox(this.L);\n\t\tif (this.sharedTables.length === 0) return;\n\t\t// The sandbox froze the globals table too: unlock it just long enough.\n\t\tthis.M._lb_setreadonly(this.L, LUA_GLOBALSINDEX, 0);\n\t\tfor (const name of this.sharedTables) {\n\t\t\tthis.M._lb_newtable(this.L, 0, 0);\n\t\t\tthis.M._lb_setglobal(this.L, this.cstr(name));\n\t\t}\n\t\tthis.M._lb_setreadonly(this.L, LUA_GLOBALSINDEX, 1);\n\t}\n\n\t/** Compile `source` into a function, or throw the syntax error. */\n\tload(source: string, chunkname = \"=loom\"): LuauFunction {\n\t\tconst base = this.M._lb_gettop(this.L);\n\t\tconst status = this.loadOnto(this.L, source, chunkname);\n\t\tconst value = this.read(this.L, -1);\n\t\tthis.M._lb_settop(this.L, base);\n\t\tif (status !== LUA_OK) throw new LuauError(String(value));\n\t\treturn value as LuauFunction;\n\t}\n\n\t/**\n\t * Run `source` as a script: its own thread with its own global environment\n\t * (the frozen globals plus `globals`), the way Roblox runs a Script or\n\t * LocalScript. Returns how the thread first came back; `onFinish` hears how\n\t * it ended, after however many yields (`require` of a module that yields).\n\t */\n\trun(\n\t\tsource: string,\n\t\toptions: {\n\t\t\tchunkname?: string;\n\t\t\tglobals?: Record<string, unknown>;\n\t\t\tonFinish?: (result: ThreadResult) => void;\n\t\t} = {},\n\t): ThreadResult {\n\t\tthis.freeze();\n\t\tconst co = this.M._lb_newthread(this.L);\n\t\tconst ref = this.M._lb_ref(this.L, -1);\n\t\tthis.M._lb_settop(this.L, -2);\n\t\ttry {\n\t\t\tthis.M._lb_sandboxthread(co);\n\t\t\tfor (const [name, value] of Object.entries(options.globals ?? {})) {\n\t\t\t\tthis.push(co, value);\n\t\t\t\tthis.M._lb_setglobal(co, this.cstr(name));\n\t\t\t}\n\t\t\tif (this.loadOnto(co, source, options.chunkname ?? \"=loom\") !== LUA_OK) {\n\t\t\t\tconst error = new LuauError(String(this.read(co, -1)));\n\t\t\t\tthis.M._lb_settop(co, 0);\n\t\t\t\tthis.onError(error);\n\t\t\t\tconst result: ThreadResult = { status: \"error\", error };\n\t\t\t\toptions.onFinish?.(result);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tif (options.onFinish) this.finishers.set(co, options.onFinish);\n\t\t\treturn this.resume(co, 0);\n\t\t} finally {\n\t\t\tthis.M._lb_unref(this.L, ref);\n\t\t}\n\t}\n\n\t// --- calling ---------------------------------------------------------------\n\n\t/**\n\t * Call a Luau function to completion and return its results. A function\n\t * that yields throws here — give it a thread with `spawn` instead.\n\t */\n\tcall(fn: LuauFunction, args: readonly unknown[] = []): unknown[] {\n\t\tconst L = this.L;\n\t\tconst base = this.M._lb_gettop(L);\n\t\tthis.ensureStack(L, args.length + 1);\n\t\tthis.M._lb_getref(L, fn.ref);\n\t\tfor (const arg of args) this.push(L, arg);\n\t\tconst status = this.enter(() => this.M._lb_pcall(L, args.length, -1));\n\t\tif (status !== LUA_OK) {\n\t\t\tconst message = this.read(L, -1);\n\t\t\tthis.M._lb_settop(L, base);\n\t\t\tthrow new LuauError(String(message), message);\n\t\t}\n\t\tconst results = this.readRange(L, base + 1, this.M._lb_gettop(L));\n\t\tthis.M._lb_settop(L, base);\n\t\treturn results;\n\t}\n\n\t/** Run a Luau function in a new thread (`task.spawn`). */\n\tspawn(fn: LuauFunction, args: readonly unknown[] = []): ThreadResult {\n\t\tconst co = this.M._lb_newthread(this.L);\n\t\tconst ref = this.M._lb_ref(this.L, -1);\n\t\tthis.M._lb_settop(this.L, -2);\n\t\ttry {\n\t\t\tthis.ensureStack(co, args.length + 1);\n\t\t\tthis.M._lb_getref(co, fn.ref);\n\t\t\tfor (const arg of args) this.push(co, arg);\n\t\t\treturn this.resume(co, args.length);\n\t\t} finally {\n\t\t\tthis.M._lb_unref(this.L, ref);\n\t\t}\n\t}\n\n\t/**\n\t * Resume a Luau thread (`task.defer`'s and `task.delay`'s, made with\n\t * `coroutine.create`). A thread that cannot be resumed — finished, running,\n\t * or closed by `task.cancel` — is left alone and gives `undefined`.\n\t */\n\tresumeThread(\n\t\tthread: LuauThread,\n\t\targs: readonly unknown[] = [],\n\t): ThreadResult | undefined {\n\t\tconst co = this.threadOf(thread);\n\t\tif (this.M._lb_costatus(this.L, co) !== LUA_COSUS) return undefined;\n\t\tthis.ensureStack(co, args.length);\n\t\tfor (const arg of args) this.push(co, arg);\n\t\treturn this.resume(co, args.length);\n\t}\n\n\t/** Hand an error to `onError`, as if it had escaped a thread. */\n\treport(error: LuauError): void {\n\t\tthis.onError(error);\n\t}\n\n\t/** Collect garbage now (tests use it to observe userdata release). */\n\tcollect(): void {\n\t\tthis.M._lb_gc(this.L);\n\t}\n\n\t/** Close the state. Every reference into it is dead afterwards. */\n\tclose(): void {\n\t\tif (this.closed) return;\n\t\tthis.M._lb_close(this.L);\n\t\tthis.closed = true;\n\t}\n\n\t/** Whether `close` has run: every entry into Luau throws afterwards. */\n\tget isClosed(): boolean {\n\t\treturn this.closed;\n\t}\n\n\t/** How many JS objects Luau currently holds as userdata. */\n\tget liveHostObjects(): number {\n\t\treturn this.handles.size;\n\t}\n\n\t// --- internals used by the reference classes -------------------------------\n\n\t/** @internal */\n\ttrack(owner: LuauRef, ref: number): void {\n\t\tthis.refs.register(owner, ref);\n\t}\n\n\t/** @internal */\n\ttableGet(table: LuauTable, key: unknown): unknown {\n\t\tconst L = this.L;\n\t\tconst base = this.M._lb_gettop(L);\n\t\tthis.M._lb_getref(L, table.ref);\n\t\tthis.push(L, key);\n\t\tthis.M._lb_rawget(L, -2);\n\t\tconst value = this.read(L, -1);\n\t\tthis.M._lb_settop(L, base);\n\t\treturn value;\n\t}\n\n\t/** @internal */\n\ttableSet(table: LuauTable, key: unknown, value: unknown): void {\n\t\tconst L = this.L;\n\t\tconst base = this.M._lb_gettop(L);\n\t\tthis.M._lb_getref(L, table.ref);\n\t\tthis.push(L, key);\n\t\tthis.push(L, value);\n\t\tthis.M._lb_rawset(L, -3);\n\t\tthis.M._lb_settop(L, base);\n\t}\n\n\t/** @internal */\n\ttableLength(table: LuauTable): number {\n\t\tconst L = this.L;\n\t\tthis.M._lb_getref(L, table.ref);\n\t\tconst n = this.M._lb_objlen(L, -1);\n\t\tthis.M._lb_settop(L, -2);\n\t\treturn n;\n\t}\n\n\t/** @internal */\n\ttableEntries(table: LuauTable): [unknown, unknown][] {\n\t\tconst L = this.L;\n\t\tconst base = this.M._lb_gettop(L);\n\t\tthis.M._lb_getref(L, table.ref);\n\t\tthis.M._lb_pushnil(L);\n\t\tconst out: [unknown, unknown][] = [];\n\t\twhile (this.M._lb_next(L, base + 1) !== 0) {\n\t\t\tout.push([this.read(L, -2), this.read(L, -1)]);\n\t\t\tthis.M._lb_settop(L, -2);\n\t\t}\n\t\tthis.M._lb_settop(L, base);\n\t\treturn out;\n\t}\n\n\t// --- threads ---------------------------------------------------------------\n\n\t/** Resume `co` with the top `nargs` values of its stack. */\n\tprivate resume(co: number, nargs: number): ThreadResult {\n\t\tconst result = this.resumeOnce(co, nargs);\n\t\tif (result.status !== \"yielded\") {\n\t\t\tconst finish = this.finishers.get(co);\n\t\t\tif (finish) {\n\t\t\t\tthis.finishers.delete(co);\n\t\t\t\tfinish(result);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\tprivate resumeOnce(co: number, nargs: number): ThreadResult {\n\t\tconst status = this.enter(() => this.M._lb_resume(co, 0, nargs));\n\t\tif (status === LUA_OK) {\n\t\t\tconst values = this.readRange(co, 1, this.M._lb_gettop(co));\n\t\t\tthis.M._lb_settop(co, 0);\n\t\t\treturn { status: \"done\", values };\n\t\t}\n\t\tif (status === LUA_YIELD) {\n\t\t\tthis.M._lb_settop(co, 0);\n\t\t\treturn { status: \"yielded\" };\n\t\t}\n\t\tconst value = this.read(co, -1);\n\t\tconst traceback = this.M.UTF8ToString(this.M._lb_debugtrace(co));\n\t\tthis.M._lb_settop(co, 0);\n\t\tconst error = new LuauError(String(value), value, traceback);\n\t\tthis.onError(error);\n\t\treturn { status: \"error\", error };\n\t}\n\n\t/**\n\t * A host function returned `suspend` on thread `co`. Keep the thread alive\n\t * and hand `wait` its resume function once Luau has unwound — only then is\n\t * the thread really suspended, whoever resumed it.\n\t */\n\t/** The `lua_State*` behind a thread reference. */\n\tprivate threadOf(thread: LuauThread): number {\n\t\tif (thread.vm !== this)\n\t\t\tthrow new TypeError(\"loom luau: a thread from another VM\");\n\t\tthis.M._lb_getref(this.L, thread.ref);\n\t\tconst co = this.M._lb_tothread(this.L, -1);\n\t\tthis.M._lb_settop(this.L, -2);\n\t\treturn co;\n\t}\n\n\tprivate suspend(co: number, suspend: Suspend): void {\n\t\tconst ref = this.M._lb_refthread(co);\n\t\tlet resumed = false;\n\t\tqueueMicrotask(() => {\n\t\t\tsuspend.wait((...values) => {\n\t\t\t\tif (resumed || this.closed) return;\n\t\t\t\tresumed = true;\n\t\t\t\ttry {\n\t\t\t\t\t// `task.cancel` may have closed it in the meantime.\n\t\t\t\t\tif (this.M._lb_costatus(this.L, co) !== LUA_COSUS) return;\n\t\t\t\t\tthis.ensureStack(co, values.length);\n\t\t\t\t\tfor (const value of values) this.push(co, value);\n\t\t\t\t\tthis.resume(co, values.length);\n\t\t\t\t} finally {\n\t\t\t\t\tthis.M._lb_unref(this.L, ref);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\t/** Run `fn` as one entry into Luau, under the run-time budget. */\n\tprivate enter<T>(fn: () => T): T {\n\t\tif (this.closed) throw new Error(\"loom luau: the VM is closed\");\n\t\tif (this.depth === 0 && this.budgetMs > 0) this.M._lb_budget(this.budgetMs);\n\t\tthis.depth++;\n\t\ttry {\n\t\t\treturn fn();\n\t\t} finally {\n\t\t\tthis.depth--;\n\t\t\tif (this.depth === 0) this.M._lb_budget(0);\n\t\t}\n\t}\n\n\t// --- host calls ------------------------------------------------------------\n\n\tprivate register(entry: HostEntry): number {\n\t\tthis.entries.push(entry);\n\t\treturn this.entries.length - 1;\n\t}\n\n\tprivate hostCall(L: number, id: number): number {\n\t\tconst entry = this.entries[id];\n\t\tconst args = this.readRange(L, 1, this.M._lb_gettop(L));\n\t\ttry {\n\t\t\tconst result = (entry as HostEntry)(L, args);\n\t\t\tif (result instanceof Suspend) {\n\t\t\t\tthis.suspend(L, result);\n\t\t\t\treturn LB_YIELD;\n\t\t\t}\n\t\t\treturn this.pushResults(L, result);\n\t\t} catch (error) {\n\t\t\tthis.push(L, errorValue(error));\n\t\t\treturn LB_ERROR;\n\t\t}\n\t}\n\n\tprivate pushResults(L: number, result: unknown): number {\n\t\tif (result === undefined) return 0;\n\t\tif (result instanceof Tuple) {\n\t\t\tthis.ensureStack(L, result.values.length);\n\t\t\tfor (const value of result.values) this.push(L, value);\n\t\t\treturn result.values.length;\n\t\t}\n\t\tthis.push(L, result);\n\t\treturn 1;\n\t}\n\n\tprivate hostRelease(handle: number): void {\n\t\tconst entry = this.handles.get(handle);\n\t\tif (entry === undefined) return;\n\t\tentry.count--;\n\t\tif (entry.count > 0) return;\n\t\tthis.handles.delete(handle);\n\t\tthis.handleOf.delete(entry.value);\n\t}\n\n\t/** The host function behind metamethod `name`, shared by every class. */\n\tprivate metamethod(name: (typeof METAMETHODS)[number]): HostEntry {\n\t\tconst self = (args: unknown[]): [object, HostClass] => {\n\t\t\tconst value = args[0] as object;\n\t\t\treturn [value, this.classOf(value) as HostClass];\n\t\t};\n\t\tconst binary =\n\t\t\t(\n\t\t\t\top:\n\t\t\t\t\t| \"add\"\n\t\t\t\t\t| \"sub\"\n\t\t\t\t\t| \"mul\"\n\t\t\t\t\t| \"div\"\n\t\t\t\t\t| \"idiv\"\n\t\t\t\t\t| \"mod\"\n\t\t\t\t\t| \"pow\"\n\t\t\t\t\t| \"lt\"\n\t\t\t\t\t| \"le\",\n\t\t\t) =>\n\t\t\t(_: number, args: unknown[]) => {\n\t\t\t\tconst cls = this.classOf(args[0]) ?? this.classOf(args[1]);\n\t\t\t\tconst hook = cls?.[op];\n\t\t\t\tif (hook === undefined) {\n\t\t\t\t\tthrow new LuauError(\n\t\t\t\t\t\t`attempt to perform arithmetic (${op}) on ${cls?.name ?? \"userdata\"}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn hook.call(cls, args[0], args[1]);\n\t\t\t};\n\t\tswitch (name) {\n\t\t\tcase \"__index\":\n\t\t\t\treturn (_, args) => {\n\t\t\t\t\tconst [value, cls] = self(args);\n\t\t\t\t\tif (cls.index === undefined)\n\t\t\t\t\t\tthrow new LuauError(\n\t\t\t\t\t\t\t`${String(args[1])} is not a valid member of ${cls.name}`,\n\t\t\t\t\t\t);\n\t\t\t\t\treturn cls.index(value, args[1]);\n\t\t\t\t};\n\t\t\tcase \"__newindex\":\n\t\t\t\treturn (_, args) => {\n\t\t\t\t\tconst [value, cls] = self(args);\n\t\t\t\t\tif (cls.newindex === undefined)\n\t\t\t\t\t\tthrow new LuauError(`${String(args[1])} cannot be assigned to`);\n\t\t\t\t\tcls.newindex(value, args[1], args[2]);\n\t\t\t\t\treturn undefined;\n\t\t\t\t};\n\t\t\tcase \"__namecall\":\n\t\t\t\treturn (L, args) => {\n\t\t\t\t\tconst method = this.M.UTF8ToString(this.M._lb_namecall(L));\n\t\t\t\t\tconst [value, cls] = self(args);\n\t\t\t\t\tif (cls.namecall === undefined)\n\t\t\t\t\t\tthrow new LuauError(\n\t\t\t\t\t\t\t`${method} is not a valid member of ${cls.name}`,\n\t\t\t\t\t\t);\n\t\t\t\t\treturn cls.namecall(value, method, args.slice(1));\n\t\t\t\t};\n\t\t\tcase \"__call\":\n\t\t\t\treturn (_, args) => {\n\t\t\t\t\tconst [value, cls] = self(args);\n\t\t\t\t\tif (cls.call === undefined)\n\t\t\t\t\t\tthrow new LuauError(`attempt to call a ${cls.name} value`);\n\t\t\t\t\treturn cls.call(value, args.slice(1));\n\t\t\t\t};\n\t\t\tcase \"__tostring\":\n\t\t\t\treturn (_, args) => {\n\t\t\t\t\tconst [value, cls] = self(args);\n\t\t\t\t\treturn cls.tostring?.(value) ?? cls.name;\n\t\t\t\t};\n\t\t\tcase \"__eq\":\n\t\t\t\treturn (_, args) => {\n\t\t\t\t\tconst [value, cls] = self(args);\n\t\t\t\t\treturn cls.eq?.(value, args[1]) ?? value === args[1];\n\t\t\t\t};\n\t\t\tcase \"__len\":\n\t\t\t\treturn (_, args) => {\n\t\t\t\t\tconst [value, cls] = self(args);\n\t\t\t\t\tif (cls.len === undefined)\n\t\t\t\t\t\tthrow new LuauError(`attempt to get length of a ${cls.name} value`);\n\t\t\t\t\treturn cls.len(value);\n\t\t\t\t};\n\t\t\tcase \"__unm\":\n\t\t\t\treturn (_, args) => {\n\t\t\t\t\tconst [value, cls] = self(args);\n\t\t\t\t\tif (cls.unm === undefined)\n\t\t\t\t\t\tthrow new LuauError(\n\t\t\t\t\t\t\t`attempt to perform arithmetic (unm) on ${cls.name}`,\n\t\t\t\t\t\t);\n\t\t\t\t\treturn cls.unm(value);\n\t\t\t\t};\n\t\t\tdefault:\n\t\t\t\treturn binary(name.slice(2) as Parameters<typeof binary>[0]);\n\t\t}\n\t}\n\n\tprivate classOf(value: unknown): HostClass | undefined {\n\t\tif (typeof value !== \"object\" || value === null) return undefined;\n\t\tconst handle = this.handleOf.get(value);\n\t\treturn handle === undefined ? undefined : this.handles.get(handle)?.cls;\n\t}\n\n\tprivate metatableFor(cls: HostClass): number {\n\t\tconst existing = this.metatables.get(cls);\n\t\tif (existing !== undefined) return existing;\n\t\tconst L = this.L;\n\t\tthis.M._lb_newtable(L, 0, METAMETHODS.length + 2);\n\t\tfor (const name of METAMETHODS) {\n\t\t\tthis.M._lb_pushfunction(\n\t\t\t\tL,\n\t\t\t\tthis.metamethodIds.get(name) as number,\n\t\t\t\tthis.debugName(name),\n\t\t\t);\n\t\t\tthis.M._lb_setfield(L, -2, this.cstr(name));\n\t\t}\n\t\tthis.pushString(L, cls.name);\n\t\tthis.M._lb_setfield(L, -2, this.cstr(\"__type\"));\n\t\tthis.pushString(L, \"The metatable is locked\");\n\t\tthis.M._lb_setfield(L, -2, this.cstr(\"__metatable\"));\n\t\tthis.M._lb_setreadonly(L, -1, 1);\n\t\tconst ref = this.M._lb_ref(L, -1);\n\t\tthis.M._lb_settop(L, -2);\n\t\tthis.metatables.set(cls, ref);\n\t\treturn ref;\n\t}\n\n\t// --- marshaling ------------------------------------------------------------\n\n\tprivate read(L: number, idx: number): unknown {\n\t\tswitch (this.M._lb_kind(L, idx)) {\n\t\t\tcase KIND_NIL:\n\t\t\t\treturn undefined;\n\t\t\tcase KIND_BOOLEAN:\n\t\t\t\treturn this.M._lb_toboolean(L, idx) !== 0;\n\t\t\tcase KIND_NUMBER:\n\t\t\t\treturn this.M._lb_tonumber(L, idx);\n\t\t\tcase KIND_STRING: {\n\t\t\t\tconst ptr = this.M._lb_tostring(L, idx, this.lenPtr);\n\t\t\t\tconst len = this.M.HEAPU32[this.lenPtr >> 2] as number;\n\t\t\t\treturn decoder.decode(this.M.HEAPU8.subarray(ptr, ptr + len));\n\t\t\t}\n\t\t\tcase KIND_HOST:\n\t\t\t\treturn this.handles.get(this.M._lb_tohost(L, idx))?.value;\n\t\t\tcase KIND_TABLE:\n\t\t\t\treturn new LuauTable(this, this.M._lb_ref(L, idx));\n\t\t\tcase KIND_FUNCTION:\n\t\t\t\treturn new LuauFunction(this, this.M._lb_ref(L, idx));\n\t\t\tcase KIND_THREAD:\n\t\t\t\treturn new LuauThread(this, this.M._lb_ref(L, idx));\n\t\t\tdefault:\n\t\t\t\treturn new LuauOpaque(\n\t\t\t\t\tthis,\n\t\t\t\t\tthis.M._lb_ref(L, idx),\n\t\t\t\t\tthis.M.UTF8ToString(this.M._lb_typeof(L, idx)),\n\t\t\t\t);\n\t\t}\n\t}\n\n\tprivate readRange(L: number, from: number, to: number): unknown[] {\n\t\tconst out: unknown[] = [];\n\t\tfor (let i = from; i <= to; i++) out.push(this.read(L, i));\n\t\treturn out;\n\t}\n\n\tprivate push(L: number, value: unknown): void {\n\t\tthis.ensureStack(L, 3);\n\t\tswitch (typeof value) {\n\t\t\tcase \"undefined\":\n\t\t\t\tthis.M._lb_pushnil(L);\n\t\t\t\treturn;\n\t\t\tcase \"boolean\":\n\t\t\t\tthis.M._lb_pushboolean(L, value ? 1 : 0);\n\t\t\t\treturn;\n\t\t\tcase \"number\":\n\t\t\t\tthis.M._lb_pushnumber(L, value);\n\t\t\t\treturn;\n\t\t\tcase \"bigint\":\n\t\t\t\tthis.M._lb_pushnumber(L, Number(value));\n\t\t\t\treturn;\n\t\t\tcase \"string\":\n\t\t\t\tthis.pushString(L, value);\n\t\t\t\treturn;\n\t\t\tcase \"function\":\n\t\t\t\tthis.M._lb_pushfunction(\n\t\t\t\t\tL,\n\t\t\t\t\tthis.functionId(value as (...args: never[]) => unknown),\n\t\t\t\t\tthis.debugName(value.name || \"host\"),\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\tcase \"symbol\":\n\t\t\t\tthrow new TypeError(\"loom luau: a symbol cannot cross into Luau\");\n\t\t}\n\t\tif (value === null) {\n\t\t\tthis.M._lb_pushnil(L);\n\t\t\treturn;\n\t\t}\n\t\tif (value instanceof LuauRef) {\n\t\t\tif (value.vm !== this)\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t\"loom luau: a value from another VM cannot cross into this one\",\n\t\t\t\t);\n\t\t\tthis.M._lb_getref(L, value.ref);\n\t\t\treturn;\n\t\t}\n\t\tconst cls = this.classify(value as object);\n\t\tif (cls !== undefined) {\n\t\t\tthis.pushHost(L, value as object, cls);\n\t\t\treturn;\n\t\t}\n\t\tif (Array.isArray(value)) {\n\t\t\tthis.M._lb_newtable(L, value.length, 0);\n\t\t\tvalue.forEach((item, i) => {\n\t\t\t\tthis.push(L, item);\n\t\t\t\tthis.M._lb_rawseti(L, -2, i + 1);\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tconst proto = Object.getPrototypeOf(value);\n\t\tif (proto === Object.prototype || proto === null) {\n\t\t\tconst fields = Object.entries(value as object);\n\t\t\tthis.M._lb_newtable(L, 0, fields.length);\n\t\t\tfor (const [key, item] of fields) {\n\t\t\t\tthis.pushString(L, key);\n\t\t\t\tthis.push(L, item);\n\t\t\t\tthis.M._lb_rawset(L, -3);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tthrow new TypeError(\n\t\t\t`loom luau: no HostClass for ${proto?.constructor?.name ?? \"object\"}; cannot cross into Luau`,\n\t\t);\n\t}\n\n\tprivate pushHost(L: number, value: object, cls: HostClass): void {\n\t\tlet handle = this.handleOf.get(value);\n\t\tif (handle === undefined) {\n\t\t\thandle = this.nextHandle++;\n\t\t\tthis.handleOf.set(value, handle);\n\t\t\tthis.handles.set(handle, { value, cls, count: 0 });\n\t\t}\n\t\t// Count the new userdata before it exists: allocating it can run a GC\n\t\t// step that finalizes this object's previous userdata (already gone from\n\t\t// the weak cache), and that release must not drop the handle to zero and\n\t\t// delete it out from under this push.\n\t\tconst entry = this.handles.get(handle) as HostHandle;\n\t\tentry.count++;\n\t\tconst created = this.M._lb_pushhost(L, handle, this.metatableFor(cls));\n\t\tif (created === 0) entry.count--;\n\t}\n\n\tprivate functionId(fn: (...args: never[]) => unknown): number {\n\t\tlet id = this.functionIds.get(fn);\n\t\tif (id === undefined) {\n\t\t\tid = this.register((_, args) =>\n\t\t\t\t(fn as (...args: unknown[]) => unknown)(...args),\n\t\t\t);\n\t\t\tthis.functionIds.set(fn, id);\n\t\t}\n\t\treturn id;\n\t}\n\n\tprivate ensureStack(L: number, n: number): void {\n\t\tif (this.M._lb_checkstack(L, n) === 0)\n\t\t\tthrow new LuauError(\"stack overflow\");\n\t}\n\n\tprivate loadOnto(L: number, source: string, chunkname: string): number {\n\t\tconst name = encoder.encode(`${chunkname}\\0`);\n\t\tconst namePtr = this.M._malloc(name.length);\n\t\tthis.M.HEAPU8.set(name, namePtr);\n\t\ttry {\n\t\t\tconst bytes = encoder.encode(source);\n\t\t\tconst ptr = this.reserve(bytes.length);\n\t\t\tthis.M.HEAPU8.set(bytes, ptr);\n\t\t\treturn this.M._lb_load(L, namePtr, ptr, bytes.length);\n\t\t} finally {\n\t\t\tthis.M._free(namePtr);\n\t\t}\n\t}\n\n\tprivate pushString(L: number, value: string): void {\n\t\tconst bytes = encoder.encode(value);\n\t\tconst ptr = this.reserve(bytes.length);\n\t\tthis.M.HEAPU8.set(bytes, ptr);\n\t\tthis.M._lb_pushstring(L, ptr, bytes.length);\n\t}\n\n\t/** A NUL-terminated copy of `value` in the scratch buffer (overwritten by the next use). */\n\tprivate cstr(value: string): number {\n\t\tconst bytes = encoder.encode(`${value}\\0`);\n\t\tconst ptr = this.reserve(bytes.length);\n\t\tthis.M.HEAPU8.set(bytes, ptr);\n\t\treturn ptr;\n\t}\n\n\t/** A permanent NUL-terminated string: Luau keeps C function debug names by pointer. */\n\tprivate debugName(name: string): number {\n\t\tlet ptr = this.debugNames.get(name);\n\t\tif (ptr === undefined) {\n\t\t\tconst bytes = encoder.encode(`${name}\\0`);\n\t\t\tptr = this.M._malloc(bytes.length);\n\t\t\tthis.M.HEAPU8.set(bytes, ptr);\n\t\t\tthis.debugNames.set(name, ptr);\n\t\t}\n\t\treturn ptr;\n\t}\n\n\tprivate reserve(size: number): number {\n\t\tif (size > this.scratchSize) {\n\t\t\tif (this.scratch !== 0) this.M._free(this.scratch);\n\t\t\tthis.scratchSize = Math.max(size, 256, this.scratchSize * 2);\n\t\t\tthis.scratch = this.M._malloc(this.scratchSize);\n\t\t}\n\t\treturn this.scratch;\n\t}\n}\n\n/** What a JS exception becomes when it is raised into Luau. */\nfunction errorValue(error: unknown): unknown {\n\tif (error instanceof LuauError) return error.value;\n\tif (error instanceof Error) return error.message;\n\treturn error;\n}\n","/**\n * `bindings.ts` — Roblox, as Luau sees it, over `@loom-dev/runtime`.\n *\n * Nothing here re-implements Roblox: every Instance, datatype, enum and signal\n * a Luau script touches is the same JS object the react and vide adapters use,\n * reached through a `HostClass`. What this file decides is only the Luau shape\n * of each — which members are visible, what a method's result becomes, and\n * which calls yield — plus the `task` library and the globals around it.\n */\nimport {\n\tCFrame,\n\tColor3,\n\tColorSequence,\n\tColorSequenceKeypoint,\n\tContent,\n\tcreateInstance,\n\tDateTime,\n\tEnum,\n\tEnumItem,\n\tenumTypeName,\n\tFont,\n\tgame,\n\theartbeat,\n\tisLoomInstance,\n\tisLuaTuple,\n\ttype LoomConnection,\n\ttype LoomInstance,\n\tLoomSignal,\n\tNumberRange,\n\tNumberSequence,\n\tNumberSequenceKeypoint,\n\tRandom,\n\tRect,\n\tRobloxEnum,\n\trobloxEquals,\n\tTweenInfo,\n\tUDim,\n\tUDim2,\n\tVector2,\n\tVector3,\n} from \"@loom-dev/runtime\";\nimport { PRELUDE } from \"./prelude.ts\";\nimport { getScriptSource } from \"./project.ts\";\nimport {\n\ttype Classifier,\n\ttype HostClass,\n\tLuauError,\n\tLuauFunction,\n\ttype LuauThread,\n\ttype LuauVM,\n\tSuspend,\n\ttype ThreadResult,\n\tTuple,\n\ttuple,\n} from \"./vm.ts\";\n\ntype Datatype = Record<string, unknown>;\n/** A datatype class, compared by identity and read for its static members. */\ntype Constructor = object;\n\n/** Every runtime datatype class, under its Roblox name. */\nconst DATATYPES: Readonly<Record<string, Constructor>> = {\n\tUDim,\n\tUDim2,\n\tVector2,\n\tVector3,\n\tColor3,\n\tColorSequence,\n\tColorSequenceKeypoint,\n\tNumberSequence,\n\tNumberSequenceKeypoint,\n\tNumberRange,\n\tContent,\n\tRect,\n\tCFrame,\n\tTweenInfo,\n\tFont,\n\tRandom,\n\tDateTime,\n};\n\n/** Roblox members are PascalCase; the JS-side `add`, `toString`, … are not members. */\nconst isMember = (key: unknown): key is string =>\n\ttypeof key === \"string\" && /^[A-Z]/.test(key);\n\n/**\n * The Roblox class surface, bound to one VM. `classify` is what the VM is\n * created with; `install` defines the globals once the VM exists.\n */\nexport interface RobloxBindings {\n\treadonly classify: Classifier;\n\tinstall(vm: LuauVM): void;\n}\n\nexport function createRobloxBindings(): RobloxBindings {\n\tlet vm: LuauVM | undefined;\n\tconst current = (): LuauVM => {\n\t\tif (vm === undefined)\n\t\t\tthrow new Error(\"loom luau: bindings used before install\");\n\t\treturn vm;\n\t};\n\tconst connections = new WeakSet<LoomConnection>();\n\n\t// One wrapper per member name, so `inst.Destroy` is the same function every\n\t// time — the VM keeps every JS function it is handed, so a fresh closure per\n\t// read would grow without bound.\n\tconst methodWrappers = new Map<\n\t\tstring,\n\t\t(self: object, ...args: unknown[]) => unknown\n\t>();\n\tconst method = (cls: HostClass, name: string) => {\n\t\tconst key = `${cls.name}.${name}`;\n\t\tlet wrapper = methodWrappers.get(key);\n\t\tif (wrapper === undefined) {\n\t\t\twrapper = (self, ...args) => cls.namecall?.(self, name, args);\n\t\t\tmethodWrappers.set(key, wrapper);\n\t\t}\n\t\treturn wrapper;\n\t};\n\n\t// --- datatypes -------------------------------------------------------------\n\n\tconst datatypeClasses = new Map<Constructor, HostClass<Datatype>>();\n\tfor (const [name, ctor] of Object.entries(DATATYPES)) {\n\t\tdatatypeClasses.set(ctor, datatypeClass(name));\n\t}\n\n\tfunction datatypeClass(name: string): HostClass<Datatype> {\n\t\tconst cls: HostClass<Datatype> = {\n\t\t\tname,\n\t\t\tindex(self, key) {\n\t\t\t\tif (!isMember(key) || !(key in self)) {\n\t\t\t\t\tthrow new LuauError(\n\t\t\t\t\t\t`${String(key)} is not a valid member of ${name}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst value = self[key];\n\t\t\t\treturn typeof value === \"function\" ? method(cls, key) : value;\n\t\t\t},\n\t\t\tnewindex(_, key) {\n\t\t\t\tthrow new LuauError(`${String(key)} cannot be assigned to`);\n\t\t\t},\n\t\t\tnamecall(self, member, args) {\n\t\t\t\tconst fn = isMember(member) ? self[member] : undefined;\n\t\t\t\tif (typeof fn !== \"function\") {\n\t\t\t\t\tthrow new LuauError(`${member} is not a valid member of ${name}`);\n\t\t\t\t}\n\t\t\t\t// A Luau method that returns several values is a tuple in roblox-ts\n\t\t\t\t// (`ToHSV`, `GetComponents`), so an array result spreads.\n\t\t\t\tconst result = fn.apply(self, args);\n\t\t\t\treturn Array.isArray(result) ? new Tuple(result) : result;\n\t\t\t},\n\t\t\ttostring: (self) => String(self),\n\t\t\teq: (a, b) => robloxEquals(a, b),\n\t\t\tunm(self) {\n\t\t\t\tif (typeof self.mul !== \"function\")\n\t\t\t\t\treturn arithmeticError(\"unm\", self, undefined);\n\t\t\t\treturn (self.mul as (n: number) => unknown)(-1);\n\t\t\t},\n\t\t\tadd: (a, b) => arithmetic(\"add\", a, b),\n\t\t\tsub: (a, b) => arithmetic(\"sub\", a, b),\n\t\t\tmul: (a, b) => arithmetic(\"mul\", a, b),\n\t\t\tdiv: (a, b) => arithmetic(\"div\", a, b),\n\t\t};\n\t\treturn cls;\n\t}\n\n\tfunction arithmetic(\n\t\top: \"add\" | \"sub\" | \"mul\" | \"div\",\n\t\ta: unknown,\n\t\tb: unknown,\n\t): unknown {\n\t\tconst left = a as Datatype | undefined;\n\t\tif (typeof left?.[op] === \"function\")\n\t\t\treturn (left[op] as (b: unknown) => unknown)(b);\n\t\t// `2 * v`: only multiplication commutes with a number on the left.\n\t\tconst right = b as Datatype | undefined;\n\t\tif (\n\t\t\top === \"mul\" &&\n\t\t\ttypeof a === \"number\" &&\n\t\t\ttypeof right?.mul === \"function\"\n\t\t) {\n\t\t\treturn (right.mul as (n: number) => unknown)(a);\n\t\t}\n\t\treturn arithmeticError(op, a, b);\n\t}\n\n\tfunction arithmeticError(op: string, a: unknown, b: unknown): never {\n\t\tthrow new LuauError(\n\t\t\t`attempt to perform arithmetic (${op}) on ${typeName(a)} and ${typeName(b)}`,\n\t\t);\n\t}\n\n\t/** `UDim2.new`, `Color3.fromRGB`, `Vector2.zero`, … as a plain table. */\n\tfunction library(ctor: Constructor): Record<string, unknown> {\n\t\tconst lib: Record<string, unknown> = {};\n\t\tfor (const key of Object.getOwnPropertyNames(ctor)) {\n\t\t\tif (key === \"length\" || key === \"name\" || key === \"prototype\") continue;\n\t\t\tconst value = (ctor as unknown as Record<string, unknown>)[key];\n\t\t\tlib[key] =\n\t\t\t\ttypeof value === \"function\"\n\t\t\t\t\t? (...args: unknown[]) =>\n\t\t\t\t\t\t\t(value as (...a: unknown[]) => unknown).apply(ctor, args)\n\t\t\t\t\t: value;\n\t\t}\n\t\treturn lib;\n\t}\n\n\t// --- Enum ------------------------------------------------------------------\n\n\tconst EnumsClass: HostClass<typeof Enum> = {\n\t\tname: \"Enums\",\n\t\tindex(self, key) {\n\t\t\tconst value =\n\t\t\t\ttypeof key === \"string\"\n\t\t\t\t\t? (self as Record<string, unknown>)[key]\n\t\t\t\t\t: undefined;\n\t\t\tif (value instanceof RobloxEnum) return value;\n\t\t\tif (key === \"GetEnums\") return method(EnumsClass, key);\n\t\t\tthrow new LuauError(`${String(key)} is not a valid member of \"Enum\"`);\n\t\t},\n\t\tnamecall(self, member) {\n\t\t\tif (member === \"GetEnums\") return self.GetEnums();\n\t\t\tthrow new LuauError(`${member} is not a valid member of \"Enum\"`);\n\t\t},\n\t\ttostring: () => \"Enums\",\n\t};\n\n\tconst EnumClass: HostClass<RobloxEnum> = {\n\t\tname: \"Enum\",\n\t\tindex(self, key) {\n\t\t\tconst value =\n\t\t\t\ttypeof key === \"string\"\n\t\t\t\t\t? (self as unknown as Record<string, unknown>)[key]\n\t\t\t\t\t: undefined;\n\t\t\tif (value instanceof EnumItem) return value;\n\t\t\tif (key === \"GetEnumItems\" || key === \"FromName\" || key === \"FromValue\") {\n\t\t\t\treturn method(EnumClass, key);\n\t\t\t}\n\t\t\tthrow new LuauError(`${String(key)} is not a valid EnumItem`);\n\t\t},\n\t\tnamecall(self, member, args) {\n\t\t\tswitch (member) {\n\t\t\t\tcase \"GetEnumItems\":\n\t\t\t\t\treturn self.GetEnumItems();\n\t\t\t\tcase \"FromName\":\n\t\t\t\t\treturn self.FromName(args[0] as string);\n\t\t\t\tcase \"FromValue\":\n\t\t\t\t\treturn self.FromValue(args[0] as number);\n\t\t\t}\n\t\t\tthrow new LuauError(`${member} is not a valid member of ${String(self)}`);\n\t\t},\n\t\ttostring: (self) => String(self),\n\t};\n\n\tconst EnumItemClass: HostClass<EnumItem> = {\n\t\tname: \"EnumItem\",\n\t\tindex(self, key) {\n\t\t\tif (key === \"Name\" || key === \"Value\" || key === \"EnumType\")\n\t\t\t\treturn self[key];\n\t\t\tif (key === \"IsA\") return method(EnumItemClass, key);\n\t\t\tthrow new LuauError(\n\t\t\t\t`${String(key)} is not a valid member of \"${String(self)}\"`,\n\t\t\t);\n\t\t},\n\t\tnamecall(self, member, args) {\n\t\t\tif (member === \"IsA\") return enumTypeName(self) === args[0];\n\t\t\tthrow new LuauError(\n\t\t\t\t`${member} is not a valid member of \"${String(self)}\"`,\n\t\t\t);\n\t\t},\n\t\ttostring: (self) => String(self),\n\t};\n\n\t// --- signals ---------------------------------------------------------------\n\n\tconst SignalClass: HostClass<LoomSignal<unknown[]>> = {\n\t\tname: \"RBXScriptSignal\",\n\t\tindex(_, key) {\n\t\t\tif (\n\t\t\t\tkey === \"Connect\" ||\n\t\t\t\tkey === \"ConnectParallel\" ||\n\t\t\t\tkey === \"Once\" ||\n\t\t\t\tkey === \"Wait\"\n\t\t\t) {\n\t\t\t\treturn method(SignalClass, key);\n\t\t\t}\n\t\t\tthrow new LuauError(\n\t\t\t\t`${String(key)} is not a valid member of RBXScriptSignal`,\n\t\t\t);\n\t\t},\n\t\tnamecall(self, member, args) {\n\t\t\tswitch (member) {\n\t\t\t\tcase \"Connect\":\n\t\t\t\tcase \"ConnectParallel\":\n\t\t\t\tcase \"Once\": {\n\t\t\t\t\tconst fn = args[0] as LuauFunction;\n\t\t\t\t\t// Every handler runs in its own thread, so it may yield. A VM that\n\t\t\t\t\t// has been unmounted has no threads left to give it.\n\t\t\t\t\tconst handler = (...values: unknown[]) => {\n\t\t\t\t\t\tconst vm = current();\n\t\t\t\t\t\tif (!vm.isClosed) vm.spawn(fn, values);\n\t\t\t\t\t};\n\t\t\t\t\tconst connection =\n\t\t\t\t\t\tmember === \"Once\" ? self.Once(handler) : self.Connect(handler);\n\t\t\t\t\tconnections.add(connection);\n\t\t\t\t\treturn connection;\n\t\t\t\t}\n\t\t\t\tcase \"Wait\":\n\t\t\t\t\treturn new Suspend((resume) => {\n\t\t\t\t\t\tself.Once((...values) => resume(...values));\n\t\t\t\t\t});\n\t\t\t}\n\t\t\tthrow new LuauError(`${member} is not a valid member of RBXScriptSignal`);\n\t\t},\n\t\ttostring: () => \"Signal\",\n\t};\n\n\tconst ConnectionClass: HostClass<LoomConnection> = {\n\t\tname: \"RBXScriptConnection\",\n\t\tindex(self, key) {\n\t\t\tif (key === \"Connected\") return self.Connected;\n\t\t\tif (key === \"Disconnect\") return method(ConnectionClass, key);\n\t\t\tthrow new LuauError(\n\t\t\t\t`${String(key)} is not a valid member of RBXScriptConnection`,\n\t\t\t);\n\t\t},\n\t\tnamecall(self, member) {\n\t\t\tif (member === \"Disconnect\") return self.Disconnect();\n\t\t\tthrow new LuauError(\n\t\t\t\t`${member} is not a valid member of RBXScriptConnection`,\n\t\t\t);\n\t\t},\n\t\ttostring: () => \"Connection\",\n\t};\n\n\t// --- Instance --------------------------------------------------------------\n\n\tconst InstanceClass: HostClass<LoomInstance> = {\n\t\tname: \"Instance\",\n\t\tindex(self, key) {\n\t\t\tif (typeof key !== \"string\") {\n\t\t\t\tthrow new LuauError(\n\t\t\t\t\t`${String(key)} is not a valid member of ${self.ClassName}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst value = self[key];\n\t\t\tif (typeof value === \"function\") return method(InstanceClass, key);\n\t\t\tif (value !== undefined) return value;\n\t\t\t// `script.Parent.Frame`: a property wins over a child of the same name.\n\t\t\treturn self.FindFirstChild(key);\n\t\t},\n\t\tnewindex(self, key, value) {\n\t\t\t(self as Record<string, unknown>)[key as string] = value;\n\t\t},\n\t\tnamecall(self, member, args) {\n\t\t\tif (member === \"WaitForChild\")\n\t\t\t\treturn waitForChild(\n\t\t\t\t\tself,\n\t\t\t\t\targs[0] as string,\n\t\t\t\t\targs[1] as number | undefined,\n\t\t\t\t);\n\t\t\tif (member === \"GetAttributes\")\n\t\t\t\treturn Object.fromEntries(self.GetAttributes());\n\t\t\tconst fn = self[member];\n\t\t\tif (typeof fn !== \"function\") {\n\t\t\t\tthrow new LuauError(\n\t\t\t\t\t`${member} is not a valid member of ${self.ClassName} \"${self.Name}\"`,\n\t\t\t\t);\n\t\t\t}\n\t\t\t// A Luau function handed to an engine method (`BindToRenderStep`,\n\t\t\t// `BindAction`, …) is a callback the engine calls later: give it one\n\t\t\t// that runs in its own thread, as a signal handler does. What it\n\t\t\t// returns without yielding goes back to the engine, which is how a\n\t\t\t// `BindAction` handler sinks its input.\n\t\t\tconst hostArgs = args.map((arg) =>\n\t\t\t\targ instanceof LuauFunction\n\t\t\t\t\t? (...values: unknown[]) => {\n\t\t\t\t\t\t\tconst vm = current();\n\t\t\t\t\t\t\tif (vm.isClosed) return undefined;\n\t\t\t\t\t\t\tconst ended = vm.spawn(arg, values);\n\t\t\t\t\t\t\treturn ended.status === \"done\" ? ended.values[0] : undefined;\n\t\t\t\t\t\t}\n\t\t\t\t\t: arg,\n\t\t\t);\n\t\t\tconst result = (fn as (...a: unknown[]) => unknown)(...hostArgs);\n\t\t\t// `GetGuiInset` and the like return several values; a plain array\n\t\t\t// (`GetChildren`) is one table.\n\t\t\tif (isLuaTuple(result)) return new Tuple(result);\n\t\t\tif (result instanceof Promise) {\n\t\t\t\treturn new Suspend((resume) => {\n\t\t\t\t\tresult.then((value) => resume(value));\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn result;\n\t\t},\n\t\ttostring: (self) => self.Name,\n\t};\n\n\t// --- require ---------------------------------------------------------------\n\n\ttype Loaded =\n\t\t| { state: \"running\" }\n\t\t| { state: \"waiting\"; waiters: Array<() => void> }\n\t\t| { state: \"done\"; value: unknown }\n\t\t| { state: \"failed\" };\n\tconst modules = new Map<LoomInstance, Loaded>();\n\n\t/**\n\t * `require(moduleScript)`, as `(ok, valueOrMessage)` for the prelude's\n\t * `require` to raise from. A module runs once per VM, in its own thread, with\n\t * itself as `script`. Whoever requires it while it is still yielding waits\n\t * for it; requiring it again from inside its own first run is the recursion\n\t * Roblox reports.\n\t */\n\tfunction requireModule(module: unknown, from?: unknown): unknown {\n\t\tif (typeof module === \"string\") {\n\t\t\tconst resolved = resolveRequirePath(module, from);\n\t\t\tif (typeof resolved === \"string\") return tuple(false, resolved);\n\t\t\tmodule = resolved;\n\t\t}\n\t\tif (!isLoomInstance(module) || !module.IsA(\"ModuleScript\")) {\n\t\t\treturn tuple(\n\t\t\t\tfalse,\n\t\t\t\t\"Attempted to call require with invalid argument(s).\",\n\t\t\t);\n\t\t}\n\t\tconst loaded = modules.get(module);\n\t\tif (loaded !== undefined) return settle(module, loaded);\n\t\tconst source = getScriptSource(module);\n\t\tif (source === undefined) {\n\t\t\treturn tuple(false, `${module.GetFullName()} has no source loom can run`);\n\t\t}\n\t\tmodules.set(module, { state: \"running\" });\n\t\tconst result = current().run(source, {\n\t\t\tchunkname: `=${module.GetFullName()}`,\n\t\t\tglobals: { script: module },\n\t\t\tonFinish: (ended) => finishModule(module, ended),\n\t\t});\n\t\t// Still running means it yielded: `onFinish` settles it later.\n\t\tif (result.status === \"yielded\")\n\t\t\tmodules.set(module, { state: \"waiting\", waiters: [] });\n\t\treturn settle(module, modules.get(module) as Loaded);\n\t}\n\n\t/** `module`'s thread ended: keep what it returned and wake whoever waits on it. */\n\tfunction finishModule(module: LoomInstance, result: ThreadResult): void {\n\t\tconst before = modules.get(module);\n\t\tlet after: Loaded = { state: \"failed\" };\n\t\tif (result.status === \"done\") {\n\t\t\tif (result.values.length === 1)\n\t\t\t\tafter = { state: \"done\", value: result.values[0] };\n\t\t\telse {\n\t\t\t\tcurrent().report(\n\t\t\t\t\tnew LuauError(\n\t\t\t\t\t\t`${module.GetFullName()}: Module code did not return exactly one value`,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tmodules.set(module, after);\n\t\tif (before?.state === \"waiting\") for (const wake of before.waiters) wake();\n\t}\n\n\t/** What a `require` of `module`, currently `loaded`, hands back. */\n\tfunction settle(module: LoomInstance, loaded: Loaded): unknown {\n\t\tswitch (loaded.state) {\n\t\t\tcase \"done\":\n\t\t\t\treturn tuple(true, loaded.value);\n\t\t\tcase \"failed\":\n\t\t\t\treturn tuple(\n\t\t\t\t\tfalse,\n\t\t\t\t\t\"Requested module experienced an error while loading\",\n\t\t\t\t);\n\t\t\tcase \"running\":\n\t\t\t\treturn tuple(false, \"Requested module was required recursively\");\n\t\t\tcase \"waiting\":\n\t\t\t\treturn new Suspend((resume) => {\n\t\t\t\t\tloaded.waiters.push(() => {\n\t\t\t\t\t\tconst now = settle(module, modules.get(module) as Loaded) as Tuple;\n\t\t\t\t\t\tresume(...now.values);\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t}\n\t}\n\n\t/** The real `WaitForChild`: yield until the child turns up, or `timeout` runs out. */\n\tfunction waitForChild(\n\t\tparent: LoomInstance,\n\t\tname: string,\n\t\ttimeout?: number,\n\t): unknown {\n\t\tconst existing = parent.FindFirstChild(name);\n\t\tif (existing !== undefined) return existing;\n\t\treturn new Suspend((resume) => {\n\t\t\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\t\t\tconst connection = parent.ChildAdded.Connect((child) => {\n\t\t\t\tif (child.Name !== name) return;\n\t\t\t\tconnection.Disconnect();\n\t\t\t\tif (timer !== undefined) clearTimeout(timer);\n\t\t\t\tresume(child);\n\t\t\t});\n\t\t\tif (timeout !== undefined) {\n\t\t\t\ttimer = setTimeout(() => {\n\t\t\t\t\tconnection.Disconnect();\n\t\t\t\t\tresume(undefined);\n\t\t\t\t}, timeout * 1000);\n\t\t\t}\n\t\t});\n\t}\n\n\t// --- classify + globals ----------------------------------------------------\n\n\tconst classify: Classifier = (value) => {\n\t\tif (isLoomInstance(value)) return InstanceClass as HostClass;\n\t\tif (value instanceof LoomSignal) return SignalClass as HostClass;\n\t\tif (connections.has(value as LoomConnection))\n\t\t\treturn ConnectionClass as HostClass;\n\t\tif (value instanceof EnumItem) return EnumItemClass as HostClass;\n\t\tif (value instanceof RobloxEnum) return EnumClass as HostClass;\n\t\tif (value === Enum) return EnumsClass as HostClass;\n\t\treturn datatypeClasses.get(value.constructor as Constructor) as\n\t\t\t| HostClass\n\t\t\t| undefined;\n\t};\n\n\tfunction install(target: LuauVM): void {\n\t\tvm = target;\n\t\tfor (const [name, ctor] of Object.entries(DATATYPES))\n\t\t\ttarget.setGlobal(name, library(ctor));\n\t\ttarget.setGlobal(\"Enum\", Enum);\n\t\ttarget.setGlobal(\"game\", game);\n\t\ttarget.setGlobal(\"workspace\", game.Workspace);\n\t\ttarget.setGlobal(\"Instance\", {\n\t\t\tnew: (className: string, parent?: LoomInstance) => {\n\t\t\t\tconst instance = createInstance(className);\n\t\t\t\tif (parent !== undefined) instance.Parent = parent;\n\t\t\t\treturn instance;\n\t\t\t},\n\t\t});\n\t\tconst started = performance.now();\n\t\ttarget.load(PRELUDE, \"=loom.prelude\").call({\n\t\t\twait,\n\t\t\tdefer: (thread: LuauThread, ...args: unknown[]) => {\n\t\t\t\tqueueMicrotask(() => target.resumeThread(thread, args));\n\t\t\t},\n\t\t\tdelay: (seconds: number, thread: LuauThread, ...args: unknown[]) => {\n\t\t\t\tafterSeconds(seconds, () => target.resumeThread(thread, args));\n\t\t\t},\n\t\t\treport: (message: string, traceback: string) => {\n\t\t\t\ttarget.report(new LuauError(message, message, traceback));\n\t\t\t},\n\t\t\tprint: (line: string) => console.log(line),\n\t\t\twarn: (line: string) => console.warn(line),\n\t\t\trequire: requireModule,\n\t\t\ttick: () => Date.now() / 1000,\n\t\t\ttime: () => (performance.now() - started) / 1000,\n\t\t});\n\t}\n\n\treturn { classify, install };\n}\n\n/**\n * Require-by-string, the engine's way: `@self/x` starts at the requiring\n * script itself, `./x` at its parent, `../x` one above that (each further\n * `..` climbs one more), and `@game/x` at the DataModel. Returns the instance\n * the path names, or the error message when it names none.\n */\nfunction resolveRequirePath(\n\tpath: string,\n\tfrom: unknown,\n): LoomInstance | string {\n\tconst parts = path.split(\"/\");\n\tconst head = parts.shift();\n\tif (head === \"@game\")\n\t\treturn walkPath(game as unknown as LoomInstance, parts, path, \"game\");\n\tif (head !== \"@self\" && head !== \".\" && head !== \"..\")\n\t\treturn `require(\"${path}\"): a path must start with \"./\", \"../\", \"@self/\" or \"@game/\"`;\n\tif (!isLoomInstance(from))\n\t\treturn `require(\"${path}\"): cannot resolve a path outside a script`;\n\tconst parent = from.Parent as LoomInstance | undefined;\n\tconst start =\n\t\thead === \"@self\"\n\t\t\t? from\n\t\t\t: head === \".\"\n\t\t\t\t? parent\n\t\t\t\t: (parent?.Parent as LoomInstance | undefined);\n\treturn walkPath(start, parts, path, from.GetFullName());\n}\n\n/** Follow `parts` (child names, or `..` for a parent) down from `at`. */\nfunction walkPath(\n\tat: LoomInstance | undefined,\n\tparts: readonly string[],\n\tpath: string,\n\torigin: string,\n): LoomInstance | string {\n\tfor (const part of parts) {\n\t\tif (at === undefined) break;\n\t\tif (part === \"\" || part === \".\") continue;\n\t\tat =\n\t\t\tpart === \"..\"\n\t\t\t\t? (at.Parent as LoomInstance | undefined)\n\t\t\t\t: (at.FindFirstChild(part) as LoomInstance | undefined);\n\t}\n\treturn at ?? `require(\"${path}\"): no module at that path from ${origin}`;\n}\n\n/** `task.wait`: yield until the first Heartbeat after `seconds`, return the time waited. */\nfunction wait(seconds?: number): Suspend {\n\tconst started = performance.now();\n\treturn new Suspend((resume) => {\n\t\tafterSeconds(seconds ?? 0, () =>\n\t\t\tresume((performance.now() - started) / 1000),\n\t\t);\n\t});\n}\n\n/** Run `fn` on the first Heartbeat at least `seconds` from now — Roblox's resume point. */\nfunction afterSeconds(seconds: number, fn: () => void): void {\n\tconst deadline = performance.now() + Math.max(seconds, 0) * 1000;\n\tconst connection = heartbeat.Connect(() => {\n\t\tif (performance.now() < deadline) return;\n\t\tconnection.Disconnect();\n\t\tfn();\n\t});\n}\n\nfunction typeName(value: unknown): string {\n\tif (value === undefined || value === null) return \"nil\";\n\tif (typeof value !== \"object\") return typeof value;\n\tconst entry = Object.entries(DATATYPES).find(\n\t\t([, ctor]) => value.constructor === ctor,\n\t);\n\treturn entry?.[0] ?? \"userdata\";\n}\n","/**\n * `mount.ts` — run a Luau LocalScript into a live loom preview.\n *\n * A Luau script builds instances imperatively and parents them under\n * `PlayerGui`, so what it needs from loom is exactly the react adapter's\n * world: the runtime PlayerGui as root, encoded → laid out → painted on every\n * dirty frame. `createWorld` is reused as-is; nothing in the layout engine or\n * the renderer knows the tree came from Luau.\n */\nimport { initLayout } from \"@loom-dev/layout\";\nimport { createWorld, type World, type WorldOptions } from \"@loom-dev/react\";\nimport { createInstance, type LoomInstance } from \"@loom-dev/runtime\";\nimport { createRobloxBindings } from \"./bindings.ts\";\nimport {\n\tinstantiateProject,\n\ttype LuauProject,\n\tstartClient,\n} from \"./project.ts\";\nimport { type LuauError, LuauVM, type ThreadResult } from \"./vm.ts\";\n\n/** How a Roblox-flavoured Luau VM is made: shared by every entry point. */\nexport interface LuauVMSetup {\n\t/** Where an error that escapes a script thread goes. Defaults to `console.error`. */\n\tonError?: (error: LuauError) => void;\n\t/** Wall-clock milliseconds one entry into Luau may run. Defaults to 5000. */\n\tbudgetMs?: number;\n\t/** The Luau VM's `.wasm` bytes, skipping the fetch (tests). */\n\twasmBinary?: ArrayBuffer | Uint8Array;\n}\n\nexport interface MountLuauOptions extends LuauVMSetup, WorldOptions {\n\t/** The element to paint into; defaults to a fresh container under `#loom-root`. */\n\ttarget?: HTMLElement;\n\t/** The script's `Name`, which is also its chunk name in errors. */\n\tname?: string;\n}\n\n/** Print an escaped error the way the engine's output does: message, then stack. */\nfunction printError(error: LuauError): void {\n\tconsole.error(\n\t\t`${error.message}${error.traceback ? `\\n${error.traceback}` : \"\"}`,\n\t);\n}\n\n/** A fresh VM with Roblox's globals installed, ready to run scripts. */\nexport async function createLuauVM(setup: LuauVMSetup = {}): Promise<LuauVM> {\n\tconst bindings = createRobloxBindings();\n\tconst vm = await LuauVM.create({\n\t\tclassify: bindings.classify,\n\t\tbudgetMs: setup.budgetMs ?? 5000,\n\t\t// Roblox's script-shared tables (roblox-ts's RuntimeLib registers in `_G`).\n\t\tsharedTables: [\"_G\", \"shared\"],\n\t\t...(setup.wasmBinary ? { wasmBinary: setup.wasmBinary } : {}),\n\t\tonError: setup.onError ?? printError,\n\t});\n\tbindings.install(vm);\n\treturn vm;\n}\n\nexport interface LuauMount {\n\treadonly vm: LuauVM;\n\treadonly world: World;\n\t/** The `LocalScript` the source runs as (`script` inside it). */\n\treadonly script: LoomInstance;\n\t/** How the script's thread first came back. */\n\treadonly result: ThreadResult;\n\tunmount(): void;\n}\n\nconst HOST_ID = \"loom-root\";\n\n/**\n * Where the world paints. An explicit `target` is the mount itself, as with\n * react's `render`; without one each mount gets its own container under the\n * preview viewport (`#loom-root`, created if the page lacks it), as react's\n * `createRoot` and vide's `mount` do, so independent mounts don't clobber.\n */\nfunction resolveMount(target?: HTMLElement): {\n\tmount: HTMLElement;\n\towned: boolean;\n} {\n\tif (target) return { mount: target, owned: false };\n\tlet viewport = document.getElementById(HOST_ID);\n\tif (!viewport) {\n\t\tviewport = document.createElement(\"div\");\n\t\tviewport.id = HOST_ID;\n\t\tviewport.style.position = \"relative\";\n\t\tviewport.style.width = \"100vw\";\n\t\tviewport.style.height = \"100vh\";\n\t\tviewport.style.overflow = \"hidden\";\n\t\tdocument.body.appendChild(viewport);\n\t}\n\tconst mount = document.createElement(\"div\");\n\tmount.style.position = \"absolute\";\n\tmount.style.inset = \"0\";\n\tviewport.appendChild(mount);\n\treturn { mount, owned: true };\n}\n\n/**\n * Run `source` as a LocalScript in a fresh VM and paint what it builds. The\n * script sits inside the world's default ScreenGui, so the common\n * `script.Parent` idiom lands its UI on screen, and anything it parents to\n * `Players.LocalPlayer.PlayerGui` renders as its own layer.\n */\nexport async function mountLuau(\n\tsource: string,\n\toptions: MountLuauOptions = {},\n): Promise<LuauMount> {\n\tif (options.computeLayout === undefined) await initLayout();\n\tconst vm = await createLuauVM(options);\n\n\tconst { mount, owned } = resolveMount(options.target);\n\tconst world = createWorld(mount, options);\n\n\tconst name = options.name ?? \"LocalScript\";\n\tconst script = createInstance(\"LocalScript\", name);\n\tscript.Parent = world.defaultGui;\n\tconst result = vm.run(source, { chunkname: `=${name}`, globals: { script } });\n\tworld.flushSync();\n\n\treturn {\n\t\tvm,\n\t\tworld,\n\t\tscript,\n\t\tresult,\n\t\tunmount() {\n\t\t\tworld.dispose();\n\t\t\tvm.close();\n\t\t\tif (owned) mount.remove();\n\t\t},\n\t};\n}\n\nexport interface RunLuauProjectOptions extends LuauVMSetup, WorldOptions {\n\t/** The element to paint into; defaults to a fresh container under `#loom-root`. */\n\ttarget?: HTMLElement;\n}\n\nexport interface LuauProjectMount {\n\treadonly vm: LuauVM;\n\treadonly world: World;\n\t/** Every LocalScript the client started, with how its thread first came back. */\n\treadonly scripts: ReadonlyArray<{\n\t\treadonly script: LoomInstance;\n\t\treadonly result: ThreadResult;\n\t}>;\n\tunmount(): void;\n}\n\n/**\n * Start a Rojo project the way a client joins a place: build the tree into\n * `game`, then run every LocalScript a client runs (ReplicatedFirst, the\n * StarterGui copy in PlayerGui, the StarterPlayerScripts copy in\n * PlayerScripts) in one VM, so `require` shares each module between them.\n */\nexport async function runLuauProject(\n\tproject: LuauProject,\n\toptions: RunLuauProjectOptions = {},\n): Promise<LuauProjectMount> {\n\tif (options.computeLayout === undefined) await initLayout();\n\tconst vm = await createLuauVM(options);\n\tconst { mount, owned } = resolveMount(options.target);\n\tconst world = createWorld(mount, options);\n\n\tinstantiateProject(project);\n\tconst scripts = startClient().map(({ script, source }) => ({\n\t\tscript,\n\t\tresult: vm.run(source, {\n\t\t\tchunkname: `=${script.GetFullName()}`,\n\t\t\tglobals: { script },\n\t\t}),\n\t}));\n\tworld.flushSync();\n\n\treturn {\n\t\tvm,\n\t\tworld,\n\t\tscripts,\n\t\tunmount() {\n\t\t\tworld.dispose();\n\t\t\tvm.close();\n\t\t\tif (owned) mount.remove();\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;AASA,MAAa,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACwBvB,MAAM,0BAAU,IAAI,QAA8B;;AAGlD,SAAgB,gBAAgB,QAAsB,QAAsB;CAC3E,QAAQ,IAAI,QAAQ,MAAM;AAC3B;;AAGA,SAAgB,g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AAQ;GACd,GAAG,MAAM;GACT,IAAI,OAAO,MAAM,OAAO;EACzB;CACD;AACD"}
package/package.json CHANGED
@@ -1,6 +1,65 @@
1
1
  {
2
2
  "name": "@loom-dev/luau",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.14.0",
4
+ "description": "Luau adapter for loom — upstream Luau compiled to WASM, running Luau UI scripts against the loom runtime.",
5
+ "keywords": [
6
+ "loom",
7
+ "roblox",
8
+ "luau",
9
+ "wasm",
10
+ "ui"
11
+ ],
12
+ "license": "MIT",
13
+ "author": "astra-void",
14
+ "homepage": "https://github.com/astra-void/loom#readme",
15
+ "bugs": "https://github.com/astra-void/loom/issues",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/astra-void/loom.git",
19
+ "directory": "packages/luau"
20
+ },
21
+ "type": "module",
22
+ "sideEffects": [
23
+ "./src/entry.ts",
24
+ "./dist/entry.js"
25
+ ],
26
+ "files": [
27
+ "dist",
28
+ "wasm"
29
+ ],
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.js"
34
+ },
35
+ "./entry": {
36
+ "types": "./dist/entry.d.ts",
37
+ "default": "./dist/entry.js"
38
+ }
39
+ },
40
+ "types": "./dist/index.d.ts",
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "dependencies": {
45
+ "@loom-dev/layout": "0.14.0",
46
+ "@loom-dev/runtime": "0.14.0",
47
+ "@loom-dev/react": "0.14.0"
48
+ },
49
+ "peerDependencies": {
50
+ "react": "^18.3.1"
51
+ },
52
+ "devDependencies": {
53
+ "@types/node": "^22.0.0",
54
+ "@types/react": "^18.3.12",
55
+ "react": "^18.3.1",
56
+ "tsdown": "^0.22.12",
57
+ "typescript": "^5.7.0",
58
+ "@loom-dev/scene": "0.14.0"
59
+ },
60
+ "scripts": {
61
+ "build": "tsdown",
62
+ "build:vm": "bash native/build.sh",
63
+ "typecheck": "tsc -p tsconfig.json --noEmit"
64
+ }
6
65
  }
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Types for the emscripten module `native/build.sh` emits next to this file.
3
+ * Pointers (`lua_State*`, `char*`) are plain wasm32 addresses.
4
+ */
5
+ export interface LuauModule {
6
+ readonly HEAPU8: Uint8Array;
7
+ readonly HEAPU32: Uint32Array;
8
+ UTF8ToString(ptr: number): string;
9
+ _malloc(size: number): number;
10
+ _free(ptr: number): void;
11
+
12
+ _lb_open(): number;
13
+ _lb_close(L: number): void;
14
+ _lb_sandbox(L: number): void;
15
+ _lb_sandboxthread(L: number): void;
16
+ _lb_budget(ms: number): void;
17
+ _lb_gc(L: number): void;
18
+
19
+ _lb_kind(L: number, idx: number): number;
20
+ _lb_gettop(L: number): number;
21
+ _lb_settop(L: number, idx: number): void;
22
+ _lb_pushvalue(L: number, idx: number): void;
23
+ _lb_remove(L: number, idx: number): void;
24
+ _lb_insert(L: number, idx: number): void;
25
+ _lb_rawequal(L: number, a: number, b: number): number;
26
+ _lb_xmove(from: number, to: number, n: number): void;
27
+ _lb_checkstack(L: number, n: number): number;
28
+
29
+ _lb_tonumber(L: number, idx: number): number;
30
+ _lb_toboolean(L: number, idx: number): number;
31
+ _lb_tostring(L: number, idx: number, len: number): number;
32
+ _lb_tostringmeta(L: number, idx: number, len: number): number;
33
+ _lb_tohost(L: number, idx: number): number;
34
+ _lb_tothread(L: number, idx: number): number;
35
+ _lb_typeof(L: number, idx: number): number;
36
+
37
+ _lb_pushnil(L: number): void;
38
+ _lb_pushboolean(L: number, b: number): void;
39
+ _lb_pushnumber(L: number, n: number): void;
40
+ _lb_pushstring(L: number, s: number, len: number): void;
41
+ _lb_pushfunction(L: number, id: number, name: number): void;
42
+ _lb_pushhost(L: number, handle: number, metatableRef: number): number;
43
+
44
+ _lb_ref(L: number, idx: number): number;
45
+ _lb_getref(L: number, ref: number): void;
46
+ _lb_unref(L: number, ref: number): void;
47
+
48
+ _lb_newtable(L: number, narr: number, nrec: number): void;
49
+ _lb_rawget(L: number, idx: number): void;
50
+ _lb_rawset(L: number, idx: number): void;
51
+ _lb_rawseti(L: number, idx: number, n: number): void;
52
+ _lb_rawgeti(L: number, idx: number, n: number): void;
53
+ _lb_setfield(L: number, idx: number, k: number): void;
54
+ _lb_getfield(L: number, idx: number, k: number): void;
55
+ _lb_next(L: number, idx: number): number;
56
+ _lb_objlen(L: number, idx: number): number;
57
+ _lb_setmetatable(L: number, idx: number): number;
58
+ _lb_setreadonly(L: number, idx: number, enabled: number): void;
59
+ _lb_getglobal(L: number, name: number): void;
60
+ _lb_setglobal(L: number, name: number): void;
61
+
62
+ _lb_load(L: number, chunkname: number, source: number, len: number): number;
63
+ _lb_pcall(L: number, nargs: number, nresults: number): number;
64
+
65
+ _lb_newthread(L: number): number;
66
+ _lb_refthread(L: number): number;
67
+ _lb_resume(co: number, from: number, nargs: number): number;
68
+ _lb_status(L: number): number;
69
+ _lb_costatus(L: number, co: number): number;
70
+ _lb_debugtrace(L: number): number;
71
+ _lb_namecall(L: number): number;
72
+ }
73
+
74
+ export interface LuauModuleOptions {
75
+ /** Runs host function `id` against `L`'s stack; see `bridge.cpp`. */
76
+ lbHostCall(L: number, id: number): number;
77
+ /** Luau collected a userdata holding `handle`. */
78
+ lbHostRelease(handle: number): void;
79
+ locateFile?(path: string, prefix: string): string;
80
+ wasmBinary?: ArrayBuffer | Uint8Array;
81
+ }
82
+
83
+ export default function createLuauModule(
84
+ options: LuauModuleOptions,
85
+ ): Promise<LuauModule>;
@@ -0,0 +1,2 @@
1
+ async function createLuauModule(moduleArg={}){var Module=moduleArg;var ENVIRONMENT_IS_WEB=!!globalThis.window;var ENVIRONMENT_IS_WORKER=!!globalThis.WorkerGlobalScope;var ENVIRONMENT_IS_NODE=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";if(ENVIRONMENT_IS_NODE){const{createRequire}=await(import("node:module"));var require=createRequire(import.meta.url)}var _scriptName=import.meta.url;var scriptDirectory="";function locateFile(path){if(Module["locateFile"])return Module["locateFile"](path,scriptDirectory);return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("node:fs");if(_scriptName.startsWith("file:"))scriptDirectory=require("node:path").dirname(require("node:url").fileURLToPath(_scriptName))+"/";readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret};readAsync=async(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary?void 0:"utf8");return ret};if(process.argv.length>1)process.argv[1].replace(/\\/g,"/");process.argv.slice(2);0}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}readAsync=async url=>{var response=await fetch(url,{credentials:"same-origin"});if(response.ok)return response.arrayBuffer();throw new Error(response.status+" : "+response.url)}}var out=console.log.bind(console);var err=console.error.bind(console);var wasmBinary;var ABORT=false;var isFileURI=filename=>filename.startsWith("file://");var runtimeInitialized=false;function getMemoryBuffer(){return wasmMemory.buffer}function updateMemoryViews(){if(HEAP8?.buffer?.resizable)return;var b=getMemoryBuffer();HEAP8=new Int8Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);HEAP32=new Int32Array(b);Module["HEAPU32"]=HEAPU32=new Uint32Array(b);HEAP64=new BigInt64Array(b)}function preRun(){}function initRuntime(){runtimeInitialized=true;wasmExports["__wasm_call_ctors"]()}function postRun(){}function abort(what){what=`Aborted(${what})`;err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";if(runtimeInitialized)___trap();throw new WebAssembly.RuntimeError(what)}var wasmBinaryFile;function findWasmBinary(){if(Module["locateFile"])return locateFile("luau-vm.wasm");return new URL("luau-vm.wasm",import.meta.url).href}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary)return new Uint8Array(wasmBinary);if(readBinary)return readBinary(file);throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary)try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary&&!ENVIRONMENT_IS_NODE)try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){var imports={env:wasmImports,wasi_snapshot_preview1:wasmImports};return imports}var HEAP8;var bigintToI53Checked=num=>num<-9007199254740992||num>9007199254740992?NaN:Number(num);var HEAP32;var isLeapYear=year=>year%4===0&&(year%100!==0||year%400===0);var MONTH_DAYS_LEAP_CUMULATIVE=[0,31,60,91,121,152,182,213,244,274,305,335];var MONTH_DAYS_REGULAR_CUMULATIVE=[0,31,59,90,120,151,181,212,243,273,304,334];var ydayFromDate=date=>{var leap=isLeapYear(date.getFullYear());var monthDaysCumulative=leap?MONTH_DAYS_LEAP_CUMULATIVE:MONTH_DAYS_REGULAR_CUMULATIVE;var yday=monthDaysCumulative[date.getMonth()]+date.getDate()-1;return yday};var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.codePointAt(i);if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63;i++}}heap[outIdx]=0;return outIdx-startIdx};var HEAPU8;var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);var HEAPU32;var _emscripten_get_now=()=>performance.now();var _emscripten_date_now=()=>Date.now();var checkWasiClock=clock_id=>clock_id>=0&&clock_id<=3;var HEAP64;var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var oldHeapSize=wasmMemory.buffer.byteLength;var pages=(size-oldHeapSize+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var printCharBuffers=[null,[],[]];var UTF8Decoder=globalThis.TextDecoder&&new TextDecoder;var findStringEnd=(heapOrArray,idx,maxBytesToRead,ignoreNul)=>{var maxIdx=idx+maxBytesToRead;if(ignoreNul)return maxIdx;while(heapOrArray[idx]&&!(idx>=maxIdx))++idx;return idx};var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead,ignoreNul)=>{var endPtr=findStringEnd(heapOrArray,idx,maxBytesToRead,ignoreNul);if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder)return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr));var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224)u0=(u0&15)<<12|u1<<6|u2;else u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63;if(u0<65536)str+=String.fromCharCode(u0);else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str};var printChar=(stream,curr)=>{var buffer=printCharBuffers[stream];if(!curr||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer));buffer.length=0}else buffer.push(curr)};if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];Module["UTF8ToString"]=(ptr,maxBytesToRead,ignoreNul)=>ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead,ignoreNul):"";var ___trap,wasmMemory;function assignWasmExports(wasmExports){Module["_lb_open"]=wasmExports["lb_open"];Module["_lb_close"]=wasmExports["lb_close"];Module["_lb_sandbox"]=wasmExports["lb_sandbox"];Module["_lb_sandboxthread"]=wasmExports["lb_sandboxthread"];Module["_lb_budget"]=wasmExports["lb_budget"];Module["_lb_gc"]=wasmExports["lb_gc"];Module["_lb_kind"]=wasmExports["lb_kind"];Module["_lb_gettop"]=wasmExports["lb_gettop"];Module["_lb_settop"]=wasmExports["lb_settop"];Module["_lb_pushvalue"]=wasmExports["lb_pushvalue"];Module["_lb_remove"]=wasmExports["lb_remove"];Module["_lb_insert"]=wasmExports["lb_insert"];Module["_lb_rawequal"]=wasmExports["lb_rawequal"];Module["_lb_xmove"]=wasmExports["lb_xmove"];Module["_lb_checkstack"]=wasmExports["lb_checkstack"];Module["_lb_tonumber"]=wasmExports["lb_tonumber"];Module["_lb_toboolean"]=wasmExports["lb_toboolean"];Module["_lb_tostring"]=wasmExports["lb_tostring"];Module["_lb_tostringmeta"]=wasmExports["lb_tostringmeta"];Module["_lb_tohost"]=wasmExports["lb_tohost"];Module["_lb_tothread"]=wasmExports["lb_tothread"];Module["_lb_typeof"]=wasmExports["lb_typeof"];Module["_lb_pushnil"]=wasmExports["lb_pushnil"];Module["_lb_pushboolean"]=wasmExports["lb_pushboolean"];Module["_lb_pushnumber"]=wasmExports["lb_pushnumber"];Module["_lb_pushstring"]=wasmExports["lb_pushstring"];Module["_lb_pushfunction"]=wasmExports["lb_pushfunction"];Module["_lb_pushhost"]=wasmExports["lb_pushhost"];Module["_lb_ref"]=wasmExports["lb_ref"];Module["_lb_getref"]=wasmExports["lb_getref"];Module["_lb_unref"]=wasmExports["lb_unref"];Module["_lb_newtable"]=wasmExports["lb_newtable"];Module["_lb_rawget"]=wasmExports["lb_rawget"];Module["_lb_rawset"]=wasmExports["lb_rawset"];Module["_lb_rawseti"]=wasmExports["lb_rawseti"];Module["_lb_rawgeti"]=wasmExports["lb_rawgeti"];Module["_lb_setfield"]=wasmExports["lb_setfield"];Module["_lb_getfield"]=wasmExports["lb_getfield"];Module["_lb_next"]=wasmExports["lb_next"];Module["_lb_objlen"]=wasmExports["lb_objlen"];Module["_lb_setmetatable"]=wasmExports["lb_setmetatable"];Module["_lb_setreadonly"]=wasmExports["lb_setreadonly"];Module["_lb_getglobal"]=wasmExports["lb_getglobal"];Module["_lb_setglobal"]=wasmExports["lb_setglobal"];Module["_lb_load"]=wasmExports["lb_load"];Module["_free"]=wasmExports["free"];Module["_lb_pcall"]=wasmExports["lb_pcall"];Module["_lb_newthread"]=wasmExports["lb_newthread"];Module["_lb_refthread"]=wasmExports["lb_refthread"];Module["_lb_resume"]=wasmExports["lb_resume"];Module["_lb_status"]=wasmExports["lb_status"];Module["_lb_costatus"]=wasmExports["lb_costatus"];Module["_lb_debugtrace"]=wasmExports["lb_debugtrace"];Module["_lb_namecall"]=wasmExports["lb_namecall"];Module["_malloc"]=wasmExports["malloc"];___trap=wasmExports["__trap"];wasmExports["_emscripten_stack_alloc"];wasmMemory=wasmExports["memory"];wasmExports["__indirect_function_table"]}var wasmImports={_abort_js:()=>abort(""),_gmtime_js:function(time,tmPtr){time=bigintToI53Checked(time);var date=new Date(time*1e3);if(isNaN(date.getTime()))return 1;HEAP32[tmPtr>>2]=date.getUTCSeconds();HEAP32[tmPtr+4>>2]=date.getUTCMinutes();HEAP32[tmPtr+8>>2]=date.getUTCHours();HEAP32[tmPtr+12>>2]=date.getUTCDate();HEAP32[tmPtr+16>>2]=date.getUTCMonth();HEAP32[tmPtr+20>>2]=date.getUTCFullYear()-1900;HEAP32[tmPtr+24>>2]=date.getUTCDay();var start=Date.UTC(date.getUTCFullYear(),0,1,0,0,0,0);var yday=(date.getTime()-start)/864e5|0;HEAP32[tmPtr+28>>2]=yday;return 0},_localtime_js:function(time,tmPtr){time=bigintToI53Checked(time);var date=new Date(time*1e3);if(isNaN(date.getTime()))return 1;HEAP32[tmPtr>>2]=date.getSeconds();HEAP32[tmPtr+4>>2]=date.getMinutes();HEAP32[tmPtr+8>>2]=date.getHours();HEAP32[tmPtr+12>>2]=date.getDate();HEAP32[tmPtr+16>>2]=date.getMonth();HEAP32[tmPtr+20>>2]=date.getFullYear()-1900;HEAP32[tmPtr+24>>2]=date.getDay();var yday=ydayFromDate(date)|0;HEAP32[tmPtr+28>>2]=yday;HEAP32[tmPtr+36>>2]=-date.getTimezoneOffset()*60;var start=new Date(date.getFullYear(),0,1);var summerOffset=new Date(date.getFullYear(),6,1).getTimezoneOffset();var winterOffset=start.getTimezoneOffset();var dst=(summerOffset!=winterOffset&&date.getTimezoneOffset()==Math.min(winterOffset,summerOffset))|0;HEAP32[tmPtr+32>>2]=dst;return 0},_tzset_js:(timezone,daylight,std_name,dst_name)=>{var currentYear=(new Date).getFullYear();var winter=new Date(currentYear,0,1);var summer=new Date(currentYear,6,1);var winterOffset=winter.getTimezoneOffset();var summerOffset=summer.getTimezoneOffset();var stdTimezoneOffset=Math.max(winterOffset,summerOffset);HEAPU32[timezone>>2]=stdTimezoneOffset*60;HEAP32[daylight>>2]=Number(winterOffset!=summerOffset);var extractZone=timezoneOffset=>{var sign=timezoneOffset>=0?"-":"+";var absOffset=Math.abs(timezoneOffset);var hours=String(Math.floor(absOffset/60)).padStart(2,"0");var minutes=String(absOffset%60).padStart(2,"0");return`UTC${sign}${hours}${minutes}`};var winterName=extractZone(winterOffset);var summerName=extractZone(summerOffset);if(summerOffset<winterOffset){stringToUTF8(winterName,std_name,17);stringToUTF8(summerName,dst_name,17)}else{stringToUTF8(winterName,dst_name,17);stringToUTF8(summerName,std_name,17)}},clock_time_get:function(clk_id,ignored_precision,ptime){ignored_precision=bigintToI53Checked(ignored_precision);if(!checkWasiClock(clk_id))return 28;var now;if(clk_id===0)now=_emscripten_date_now();else if(1)now=_emscripten_get_now();else return 52;var nsec=Math.round(now*1e6);HEAP64[ptime>>3]=BigInt(nsec);return 0},emscripten_date_now:_emscripten_date_now,emscripten_get_now:_emscripten_get_now,emscripten_resize_heap:requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize)return false;for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement)return true}return false},fd_write:(fd,iov,iovcnt,pnum)=>{var num=0;for(var i=0;i<iovcnt;i++){var ptr=HEAPU32[iov>>2];var len=HEAPU32[iov+4>>2];iov+=8;for(var j=0;j<len;j++)printChar(fd,HEAPU8[ptr+j]);num+=len}HEAPU32[pnum>>2]=num;return 0},lb_js_call:function(L,id){return Module.lbHostCall(L,id)},lb_js_release:function(handle){Module.lbHostRelease(handle)}};var wasmExports;wasmExports=await async function(){function receiveInstance(instance){wasmExports=instance.exports;assignWasmExports(wasmExports);updateMemoryViews();return wasmExports}var info=getWasmImports();wasmBinaryFile??=findWasmBinary();var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=function(result){return receiveInstance(result["instance"])}(result);return exports}();await async function(){preRun();if(ABORT)return;initRuntime();postRun()}();
2
+ ;return Module}export default createLuauModule;
Binary file
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.