--!strict -- host: the runtime adapter, detected once at load time. Roblox (no file system; toEditableImage), LÖVE -- (love.filesystem + io; toImageData / toSoundData), plain LuaJIT (io), the Luau CLI (no file system). -- -- local host = require("@formats/host") -- print(host.name) -- "roblox" | "love" | "luajit" | "luau" -- local buf, err = host.readFile("a.png") -- every host has readFile / writeFile / exists (failing with Err.IO -- -- where there is no file system) local Err = require("@formats/core/Err") export type Host = { name: string, hasFiles: boolean, readFile: (path: string) -> (buffer?, Err.Err?), writeFile: (path: string, data: buffer) -> (boolean, Err.Err?), exists: (path: string) -> boolean, [string]: any, } local G = _G :: any local name if typeof(game) == "Instance" then name = "roblox" elseif G.love ~= nil and type(G.love) == "table" and G.love.filesystem ~= nil then name = "love" elseif G.jit ~= nil or G.io ~= nil then name = "luajit" else name = "luau" end local host: Host if name == "roblox" then host = require("@formats/host/Roblox") :: any elseif name == "love" then host = require("@formats/host/Love") :: any elseif name == "luajit" then host = require("@formats/host/LuaJIT") :: any else host = require("@formats/host/Luau") :: any end -- LuaJIT (plain or LÖVE): the big decoders (Opus CELT, H.264, ...) outgrow the default 1000 traces / 8 MB of machine -- code and fall back to the interpreter (CELT runs about 2.5x faster with these limits). Raising the limits only -- allows more traces; set _G.FORMATS_NO_JIT_TUNE = true before requiring the library to leave them alone. if G.jit ~= nil and type(G.jit.opt) == "table" and not G.FORMATS_NO_JIT_TUNE then pcall(G.jit.opt.start, "maxtrace=8000", "maxmcode=65536") end local _ = Err return host