docs: rosetta naming in README, docs, guide, licenses

This commit is contained in:
4DBug committed 2026-11-01 01:19:16 -05:00
1 parent 22ddcd78fa
commit 753ae98d4a
20 files changed
+123 -123

No files matched your search

+16 -16
View File
@@ -1,6 +1,6 @@
# formats-luau guide
# rosetta guide
formats-luau reads, writes and converts file formats in pure Luau. One source tree runs on Roblox, on LuaJIT / LÖVE
rosetta reads, writes and converts file formats in pure Luau. One source tree runs on Roblox, on LuaJIT / LÖVE
and in the luau CLI. Each format maps onto the standard type of its category, so a PNG and a WebP both load as the
same `Image`, and every audio format opens as the same streaming `Decoder`.
@@ -44,15 +44,15 @@ as `F`, and its input files as variables such as `pngBytes` (a buffer) or `srtTe
**Roblox (Rojo).** Build the Roblox tree, then let Rojo turn it into a model or sync it into Studio:
```sh
python3 -I tools/build.py roblox # writes build/roblox/Formats (requires become instance paths)
rojo build -o Formats.rbxm # default.project.json mounts build/roblox/Formats; or: rojo serve
python3 -I tools/build.py roblox # writes build/roblox/Rosetta (requires become instance paths)
rojo build -o Rosetta.rbxm # default.project.json mounts build/roblox/Rosetta; or: rojo serve
```
Put the `Formats` ModuleScript somewhere both client and server can see it, for example ReplicatedStorage:
Put the `Rosetta` ModuleScript somewhere both client and server can see it, for example ReplicatedStorage:
<!-- doc:display needs Roblox -->
```luau
local F = require(game:GetService("ReplicatedStorage").Formats)
local F = require(game:GetService("ReplicatedStorage").Rosetta)
```
Roblox has no file system: pass buffers or strings, for example from `HttpService:GetAsync` or a `buffer` you built.
@@ -60,27 +60,27 @@ Roblox has no file system: pass buffers or strings, for example from `HttpServic
**LuaJIT and LÖVE.** Build the Lua 5.1 tree:
```sh
python3 -I tools/build.py luajit # writes build/luajit/formats/ (plain Lua 5.1 + the LuaJIT FFI)
python3 -I tools/build.py luajit # writes build/luajit/rosetta/ (plain Lua 5.1 + the LuaJIT FFI)
```
Then either copy `build/luajit/formats` into your game, or put the build on `package.path`:
Then either copy `build/luajit/rosetta` into your game, or put the build on `package.path`:
<!-- doc:display plain LuaJIT code -->
```lua
package.path = "build/luajit/?.lua;build/luajit/?/init.lua;" .. package.path
local F = require("formats")
local F = require("rosetta")
```
The library carries its own copy of the Luau standard library pieces it uses (`buffer`, `bit32`, `utf8`, ...).
Your own code gets them as globals with `require("formats._compat").install()`, which is useful when you read the
Your own code gets them as globals with `require("rosetta._compat").install()`, which is useful when you read the
pixel buffers yourself. [examples/love](../../examples/love/main.lua) is a runnable LÖVE example.
**luau CLI.** The repository's `.luaurc` defines the alias `@formats` for `src/Formats`, so a script run from the
**luau CLI.** The repository's `.luaurc` defines the alias `@rosetta` for `src/Rosetta`, so a script run from the
repository root can require the sources directly. The CLI has no file system.
<!-- doc:display a top-level require -->
```luau
local F = require("@formats")
local F = require("@rosetta")
```
The runnable programs in [examples/](../../examples) work this way: `luau examples/image.luau`.
@@ -336,7 +336,7 @@ and `toSoundData` turns an `Audio` or a `Decoder` (read to its end) into 16-bit
<!-- doc:display needs LÖVE -->
```lua
local F = require("formats")
local F = require("rosetta")
local img = assert(F.load("sprite.png")) -- love.filesystem path
local texture = love.graphics.newImage(F.host.toImageData(img))
local music = love.audio.newSource(F.host.toSoundData(F.audio.open("music.ogg")), "static")
@@ -347,13 +347,13 @@ F.save(shot, "shot.png") -- to the save directory
**LuaJIT trace limits.** When the library loads on LuaJIT it raises the JIT's trace limits
(`jit.opt.start("maxtrace=8000", "maxmcode=65536")`). The big decoders (Opus CELT, VP8, H.264, MPEG-1) outgrow the
defaults and fall back to the interpreter, which is 2x or more slower. Set `FORMATS_NO_JIT_TUNE` before the first
defaults and fall back to the interpreter, which is 2x or more slower. Set `ROSETTA_NO_JIT_TUNE` before the first
`require` to leave the JIT settings alone:
<!-- doc:display plain LuaJIT code -->
```lua
FORMATS_NO_JIT_TUNE = true -- a global, read once when the library loads
local F = require("formats")
ROSETTA_NO_JIT_TUNE = true -- a global, read once when the library loads
local F = require("rosetta")
```
## Conventions