Checks and remaining work
On this page
Checking templates
lim check, the Studio check, the VS Code extension, and MCP’s check and check_text check a game’s ui.templates the same way (projectDiagnostics in @liminalia/sdk; the list of diagnostics is “Screen templates” in format.md).
| Reports | code | Severity | Where |
|---|---|---|---|
| A registered file is missing or can’t be read | template-missing | Error | The screen’s line in ui.templates of liminalia.json |
| A screen name that can’t be built from a template | template-unknown-screen | Warning | Same |
A plugin’s screens.* replaces the same screen | template-overridden | Warning | Same |
An unknown part name, a <template> without data-part, or a file with no parts and no <style> | template-unknown-part | Warning | That <template>’s line (line 1 for a file) |
A data-role, data-field, data-text or data-setting that doesn’t work on that screen | template-unknown-value | Warning | That element’s line |
A data-role the screen needs is missing | template-missing-role | Error | The line of the part screen |
A data-list without data-item, or a missing data-item part | template-list-item | Error | That element’s line |
| Things the player removes (the list in “Handling a game’s HTML safely”) | template-unsafe | Warning | That element’s line, or the line inside <style> |
| The copied version is older than the built-in one, or has no version | template-outdated | Warning | That <template>’s line |
- Each screen’s rules aren’t written on the checking side. The owner of the built-in template (
packages/screens/src/<screen>.ts) holds them asStandardScreen(@liminalia/lang), listed inSTANDARD_SCREENSinpackages/screens/src/rules.ts. The rules are the workingdata-rolevalues (roles), thedata-fieldnames (fields), the requireddata-rolevalues (required; per group, any one is enough), the plugin hooks that replace the screen (replacedBy:screens.confirm,systemand so on), and the setting names tied to controls (settings; settings screen only; names starting withcustom.always pass). Part names and versions are read from the built-in template text. A screen rewritten as a template gets checks just by writing and listing its rules. - Keys that can go in
data-textare all text keys of the built-in wording (TEXTinstrings.ts). - Required
data-rolevalues are checked on the whole, with the game’s parts laid over the built-in ones (a template that copied only one part counts the rest from the built-in parts). - Checks read the text without a DOM (
screen-templates.tsin@liminalia/lang). The reading follows the player (the outermost<template data-part>is a part, and the list of removed things is the same). - The rules live on the rendering side (
@liminalia/web/screen-rules), and@liminalia/langand@liminalia/sdkdon’t read them.lim checkand the VS Code extension read them and pass them in, and for Studio, the side that starts the dev server (vite.config.tsofweb, Studio Mobile’s Service Worker,lim mcp) passes them withsetScreenTemplateRules(likesetScreenTablefor the list of built-in screens). - Screens a plugin replaces are read from the text of the plugin’s
./web(pluginScreensin@liminalia/project/screen-templates; the rendering code can’t run in Node). It looks the same way asreplacedScreensin the player (ui-probe.ts): thesystem,titleandscreensentries of an object that has onlynameandWebPluginentries, plusscreensandtitleof the theme chosen inui.system.preset. Contents ofscreensheld in another variable can’t be read, so it leans toward not reporting.
Things to watch when rewriting the remaining screens (learned in the prototype)
-
Write the screen’s rules (
StandardScreen) inpackages/screens/src/<screen>.tsand list them inpackages/screens/src/rules.ts(“Checking templates” above). Therolesof the menu and title include system action names (SYSTEM_ACTIONS). -
First add tests of the screen’s current behaviour (shape, class names, keys, focus, text-to-speech, results, closing), and confirm they pass unchanged after the rewrite. The confirmation kept the same DOM as a template (class names, button order,
type,role). -
Indentation whitespace is dropped, so templates can be indented for readability. Spaces within text (between
<b>name</b> <a>…</a>) stay. -
Write initial focus with
data-autofocus. What screens decide in code today (a saved position, the current page, the previously chosen slot) can’t be written as attributes, so each screen’s code decides it (stage f1’s choices decide “the first pressable choice” in code). -
Screens whose contents change while open rebuild lists with
view.list(added in stage f1: the controls help’s tabs, save and load pages, backlog search). To rewrite only values, useview.update(values)(added in stage f2: the backlog search count). Take care to keep the focus and reading position. -
Learned in stage f2: where the engine builds the contents of a list row (the backlog text’s ruby, color and images), code replaces the contents of the element with
data-field(the game decides the element’s place and look, and the engine puts in the contents). Template checks look atdata-fieldnames, so no new attribute is needed. An input (backlog search) would become a pressable button withdata-role, so it’s marked withdata-inputand the screen’s code watches it. -
Learned in stage f1: a screen laid out inside an existing element (the choice layer) lays the template’s outer frame over the layer. To keep CSS that assumes DOM children (
.choices > button), use<template data-list>. Older attributes (data-kind,data-action,aria-pressed) are written the same withdata-attr-*or in code. -
Learned in stage f3: the sliders, switches and choices of the settings screen use an attribute separate from
data-rolebuttons (data-setting), and tying them to values calls the UI parts (slider,toggle,choiceinui-parts.ts). The unit of showing, hiding and reordering is the row, sodata-settinggoes on the row rather than the control, and the controls inside are told apart by element type (<input>) and attributes (data-value,data-toggle). For things whose action depends on the button pressed, like tabs, the pressed element is passed to thedata-roleaction and the button’s attribute (data-page) is read. -
If the screen’s heading is
.lm-screen-title,h1orh2,aria-labelledbyis added (pushScreenlooks for it). -
The sound is decided by the
data-rolevalue (back-type actions are cancel, pages are page, choices’ choose is choice, others select). Where today’s screens play a different sound, match it withdata-sound(stage f1’s menu “Return to game”, the ending name). -
Measure the export size per screen (“When the built-in templates are loaded” above). Little is left under the total budget, so revisit the budget before the next screen.
-
Menu and title actions work by writing a system action name in
data-role(the same names asSYSTEM_ACTIONS). Conditions for showing and hiding (removed in settings, stopped in a trial version) are written by the engine withdata-lm-disabledorhidden. -
When a game’s template misnames a part (a part not in the built-in one), the player silently doesn’t use it.
lim checkand the Studio check report it (template-unknown-part).
Not built yet
- Rewriting the built-in screens that can’t be built from templates (extras, flowchart, items, content warning and so on). Not rewritten in 0.4.0.
- Theme templates (
PluginTheme.templates), and building template parts from theapiof a plugin’sscreens.*(screen JS’sapi.renderwent in first). - Reading screen JS in Studio Mobile.