feat(launcher): cache manifest.launcher.md per module on init

manifest_loader.load_for(id) reads <install>/modules/<id>/
manifest.launcher.md via engine.module.read_file, runs the JSON
frontmatter through frontmatter.parse, and pre-parses the body via
markdown.parse. Cached on the shared ctx so the detail-panel render
loop does not pay the parse cost per frame. Missing files degrade to
{_missing=true} and the list falls back to the module's name/id.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Calic
2026-06-11 01:58:38 +02:00
parent f2b2a8859b
commit d63dd91bb6
2 changed files with 42 additions and 1 deletions

31
manifest_loader.lua Normal file
View File

@@ -0,0 +1,31 @@
local M = {}
local fm
local function ensure_deps()
if not fm then
fm = dofile(engine.module.dir_of("lib-management.launcher") .. "/frontmatter.lua")
end
end
-- Returns:
-- meta = { summary, description_md, author, tags, teaser_images,
-- carousel_interval_seconds, ... }
-- body_blocks = output of markdown.parse(body) — pre-parsed for cache reuse
-- On any failure (file missing, parse error): meta = {}, body_blocks = {}.
function M.load_for(module_id)
ensure_deps()
local content, err = engine.module.read_file(module_id, "manifest.launcher.md")
if not content then
return { _missing = true, _err = err }, {}
end
local meta, body, perr = fm.parse(content)
if not meta then
return { _missing = false, _err = perr }, {}
end
local md = dofile(engine.module.dir_of("lib-management.launcher") .. "/markdown.lua")
local blocks = md.parse(body)
return meta, blocks
end
return M