Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·part ofmodule theme.module·originates fromworld 07158574-5…

cascade

Pure-Luau `$variable` cascade resolver for theme tokens and styles. Walks a theme table's tokens and styles, expands every `$tokenName` reference into a literal value with cycle detection, and returns a flat result. Used by `Z.theme.register` so the engine receives fully-resolved

byzero-proxy @ DESKTOP-DB3UJOJ·posted 2mo ago
What it does

cascade

Pure-Luau $variable cascade resolver for theme tokens and styles. Walks a theme table's tokens and styles, expands every $tokenName reference into a literal value with cycle detection, and returns a flat result. Used by Z.theme.register so the engine receives fully-resolved (token, value) and (selector, prop, value) pairs — no runtime variable indirection. Cycle detection surfaces broken theme inputs as structured register errors instead of silently leaving Variable(name) in place and producing garbage colors.

Exports

  • M.resolveValue(value, tokens, visited, order) -> (any, string?) — single-value resolver. Exposed for tests; not part of the typed surface.
  • M.resolveTokens(theme: any) -> (TokenMap?, string?) — flatten theme.tokens. Returns (nil, errMsg) on first cycle / unknown reference.
  • M.resolveStyles(theme: any, resolvedTokens: any) -> (StyleMap?, string?) — flatten theme.styles against pre-resolved tokens.

Types:

  • TokenMap = { [string]: any }
  • StyleMap = { [string]: { [string]: any } }
  • Theme = { tokens: TokenMap?, styles: StyleMap? }

Usage

local Cascade = require("@builtin::modules.zui.theme.cascade")

local tokens, err = Cascade.resolveTokens(theme)
if err then error(err) end

local styles, err2 = Cascade.resolveStyles(theme, tokens)
if err2 then error(err2) end

-- `tokens` and `styles` now contain no `$variable` strings.

Notes

  • Pure module — no engine calls, no module state. Safe to invoke during any phase (boot, test, runtime).
  • Error messages include the offending token / selector / prop so cascade failures are diagnosable from the structured error alone.
  • resolveStyles resolves against pre-flattened resolvedTokens (not raw theme.tokens) so chained references ($a → $b → c) are already collapsed by the time style values are walked.
  • Numbers, booleans, and arrays pass through unchanged — only strings beginning with $ are treated as references.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

ZuiThemeCascade Module Pure-Luau `$variable` cascade resolver for theme tokens and styles. Walks a theme table's tokens and styles, expands every `$tokenName` reference into a literal value with cycle detection, and returns a flat result. Used by `Z.theme.register` so the engine receives fully-resolved `(token, value)` and `(selector, prop, value)` pairs — no runtime variable indirection. Cycle detection surfaces broken theme inputs as structured `register` errors instead of silently leaving `Variable(name)` in place and producing a render with garbage colors. Consumers: local Cascade = require("modules.deprecated.zui.theme.cascade") local tokens, err = Cascade.resolveTokens(theme) local styles, err = Cascade.resolveStyles(theme, tokens)

resolveValue(value: any, tokens: TokenMap, visited: { [string]: number }, order: { string }) → void

Internal: resolves one value. * non-string values are returned unchanged (numbers, booleans, arrays stay as-is; only strings can be `$variable` references) * a `$tokenName` string is looked up in `tokens` and recursively resolved; cycles produce `(nil, errMsg)` with the offending chain * a plain literal string (no leading `$`) is returned unchanged

argtypedescription
valueany
tokensTokenMap
visited{ [string]: number }
order{ string }

resolveTokens(theme: any) →

Walk `theme.tokens` and resolve every `$reference` to a literal. Tokens that reference other tokens are flattened — after this pass, every value is a literal string / number / etc. / unknown reference. Errors include the offending key for debugging.

argtypedescription
themeanyA theme-shaped table with a `tokens` field.

examples

local tokens, err = Cascade.resolveTokens({ tokens = { a = "$b", b = "#fff" } })

resolveStyles(theme: any, resolvedTokens: any) →

Walk `theme.styles` and resolve every `$reference` inside style values against `resolvedTokens`. Returns a `{ [selector]: { [prop]: value } }` map with no remaining `$variable` strings. Selector and property keys pass through unchanged (cascade ordering is the caller's concern).

argtypedescription
themeanyA theme-shaped table with a `styles` field.
resolvedTokensanyPre-flattened tokens (output of `resolveTokens`).

examples

local styles, err = Cascade.resolveStyles({ styles = { ["btn"] = { color = "$accent" } } }, tokens)
⌬ Types
TokenMap = { [string]: any }StyleMap = { [string]: { [string]: any } }Theme = { tokens: TokenMap?, styles: StyleMap? }

Sub-parts

Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.

3items
·
other · born here
▤file
▲ 0↑ born
backing path · modules/deprecated/zui.module/theme.module/cascade.module

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.