merge master

This commit is contained in:
4DBug committed 2026-11-02 22:17:13 -06:00
commit f9e2e6a455
18 files changed
+16515 -1468

No files matched your search

+1 -1
View File
@@ -24,7 +24,7 @@ come back as a third value `{ [file name] = buffer }` (or in the caller's `opts.
| `F.save(value, dest?, opts?)` | `buffer` / `true` (+ the extra files, see above) |
| `F.saveString(value, opts?)` | the encoded bytes as a string |
| `F.convert(src, format, opts?)` | load + save (`opts` go to both; `opts.out = path` writes a file) |
| `F.detect(src, opts?)` | the format name (content sniffing first, then the extension); a format's optional `variant(r)` can name the flavour (`"webm"` for a WebM file read by mkv) |
| `F.detect(src, opts?)` | the format name (content sniffing first, then the extension); a format's optional `variant(r)` can name the flavour (`"webm"` for a WebM file read by mkv). Sniffing loads no format module (the generated `Sniffs.luau`); `load` / `open` / `save` load only the format they use |
| `F.formats(category?)` | `{ { name, category, extensions, mime, caps } }` without loading any format (also [FORMATS.md](FORMATS.md)) |
| `F.format(name)` | the format module itself (`sniff` / `decode` / `encode` / `open` and extras such as `png.info`) |
+8 -3
View File
@@ -18,7 +18,7 @@ The reference implementation to copy is **PNG**:
```
src/Rosetta/
init.luau Registry.luau (generated) api (layer 6)
init.luau Registry.luau Sniffs.luau (gen.) api (layer 6)
ops/ ops (layer 5.5) editing on the standard types (F.ops.image /
mesh / layers / audio / music; ImageOps, ...)
<category>/<fmt>/ formats (layer 5) image audio video model cad font archive data
@@ -156,6 +156,11 @@ Rules:
inside a bigger buffer; never assume offset 0). It returns the category's standard type from `Types.luau`
(`Types.Image.new(w, h)`, `Types.Scene.new()`, ...), `rgba8` for images unless `opts.native` asks for the source layout.
Fill `meta.source = { format = "<name>", ... }` with the source facts (bit depth, colour type, codec, ...).
- `sniff(r)` scores 0..1 and is copied, with the top-level locals, types and loops it reaches, into the generated
`Sniffs.luau`, so detection requires no format module (requires outside `core/` become proxies loaded at sniff time).
A sniff that reaches its module table (`Png.info(r)`), a forward-declared local or a load-time read of a non-core
module is not copied: its module then loads on every detection that gets that far. `tests/detect.luau` checks the
copies against the modules.
- `encode(value, opts)` returns a buffer. Validate the value first and return `Err.ARG` for anything wrong.
- `open(r, opts)` (audio / video) returns the streaming Decoder / VideoDecoder / Demuxer from `Types.luau`. If a format
has `open` but no `decode`, `F.load` decodes the whole stream through it.
@@ -312,8 +317,8 @@ t:done()
2. Shared code (a codec two formats need, a container) goes to `codecs/<domain>/` or `containers/` instead, with its
own test in `tests/codecs/` / `tests/containers/`.
3. `deps = { ... }` = the requires outside the folder.
4. `python3 -I tools/gen_registry.py` (regenerates `src/Rosetta/Registry.luau` and `docs/FORMATS.md`; never edit those
by hand; after a merge, just rerun it).
4. `python3 -I tools/gen_registry.py` (regenerates `src/Rosetta/Registry.luau`, `Sniffs.luau` and `docs/FORMATS.md`;
never edit those by hand; after a merge, just rerun it).
5. `tools/fixtures/<fmt>.py` + `tests/<category>/<fmt>.luau`.
6. `bash tools/test.sh <fmt>` while working (both runtimes), then `bash tools/test.sh` (everything + lint).
7. The docs line comes from the contract (`docs/FORMATS.md`); put format notes (limits, spec deviations, bench numbers)