b9f7c9347c
The runtime has always called fields on the table main.lua returns, but @lua-global declared them as loose functions, so the stubs type-checked something that does not exist and read as "define a global". Callbacks are now @lua-app blocks that generate a class: App for the core contract, TouchHandlers and ButtonHandlers beside the namespaces they belong to. An app composes what it implements: ---@class PaintApp : App, TouchHandlers Names follow the rest of the surface: onTouchDown rather than on_touch_down, with the field names the runtime looks up renamed to match. @lua-field carries the plain fields (home, data) that were prose in a preamble before.
21 lines
1.0 KiB
Lua
21 lines
1.0 KiB
Lua
---@meta
|
|
|
|
-- Generated from native/src/runtime/runtime.cpp. Do not edit.
|
|
|
|
-- The firmware loads /.lua/main.lua into every fresh state and calls these on the
|
|
-- table it returns. Where apps live, what surrounds them and which of these an app
|
|
-- itself sees are all main.lua's to decide, which is why an app composes the
|
|
-- classes for the features it handles:
|
|
--
|
|
-- ---@class PaintApp : App, TouchHandlers
|
|
--
|
|
-- The firmware does not clear the frame before calling draw(), and commits changed
|
|
-- display content after each callback batch using the panel's own refresh policy.
|
|
-- Timer callbacks are registered directly with timer.after/every.
|
|
|
|
---@class App
|
|
---@field home? string The route sys.back() lands on once history is empty.
|
|
---@field data? string The sys.getAppDataPath() template whose ? is the app id.
|
|
---@field start fun(route: string, arg?: string) Required. Mounts the route; failing here leaves no app running.
|
|
---@field draw? fun(deltaMs: integer) Optional frame loop, called once after start and then at most 30 FPS, best effort.
|