formats-luau foundation: build (darklua + token passes) for Roblox and LuaJIT, compat prelude, core, Types, host adapters, API + registry, lint, tests on both runtimes; absorb deflate (codecs/Deflate + new compressor) and png (image/png + new encoder)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
commit
ccb06775c5
226 files changed
+8409
No files matched your search
@@ -0,0 +1,43 @@
|
||||
--!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")
|
||||
elseif name == "love" then
|
||||
host = require("@formats/host/Love")
|
||||
elseif name == "luajit" then
|
||||
host = require("@formats/host/LuaJIT")
|
||||
else
|
||||
host = require("@formats/host/Luau")
|
||||
end
|
||||
local _ = Err
|
||||
return host
|
||||
Reference in new issue
Block a user