Builtin Library
README.md
tabApp
Layer 5 shell — visibility-driven tabbed app. Wraps Z.app with a
per-tab refresh scheduler that gates ALL data fetches on
(window_visible AND tab_active AND refresh_due), so the panel costs
zero engine work when hidden / closed / minimized and only the active
tab's build() is invoked when open. Lifted from system_tools.module
(the original consumer) so future live-data tools compose against this
surface instead of re-implementing the scheduler.
Exports
M.create(opts: TabAppOpts) -> TabAppHandle— build and mount a tab app. Required:name,tabs,tabOrder.M(opts)— the module table is callable; equivalent toM.create(opts).
Types:
TabSpec = { label?, refresh?, build?, onMount?, onCallback?, tick? }ChromeOpts = { title?, layout?, minimizable?, closable?, minWidth?, minHeight?, maxWidth? }ExtraScreenSpec = { build?, refresh?, layer?, tags?, onCallback? }AppOpts = { layer?, tags?, ctx? }TabAppOpts = { name, tabs, tabOrder, tabAliases?, statusClock?, onStatusTick?, chrome?, extraScreens?, appOpts?, initialState?, callbackPrefix?, windowId?, closedWidth?, closedHeight?, minimizedWidth?, tabGap?, tabPadding? }TabAppHandle = { app, state, update, onCallback, destroy, setVisible, screenName }
Usage
local TabApp = require("@builtin::modules.zui.shell.tabApp")
local handle = TabApp {
name = "system_tools",
tabs = TABS,
tabOrder = { "entities", "logs" },
statusClock = 0.1,
onStatusTick = function(state) ... end,
}
-- Per-frame
handle.update(dt)
Notes
- The scheduler keeps a single shared
schedClockplus per-timerlastFiretimestamps. SteppinglastFireby the refresh interval (rather than tonow) keeps timers phase-locked to their mount time forever — timers with matching intervals fire on the same frame. extraScreensmay use either afunction(state)shorthand or a{ build, refresh, layer, tags, onCallback }table. The handle'sonCallbackdispatches into App handlers first, then per-tabonCallback, then extraScreenonCallback.- The default chrome ships three shells (closed / minimized / open).
Pass
chrome.layout(state, opts) -> widgetto override entirely. setVisibleflipswindowVisibleAND callsui.showScreen/ui.hideScreenfor the bound screen name.destroyunmounts the App and resets the shared DataSource cache.