refactor: move types into relevant places #62

Merged
abart27 merged 5 commits from disperse-types into main 2026-03-15 14:06:35 +00:00
abart27 commented 2026-03-15 13:21:56 +00:00 (Migrated from github.com)

Deletes the centralized types.lua and moves the type definitions to more relevant places.

Deletes the centralized `types.lua` and moves the type definitions to more relevant places.
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2026-03-15 13:26:42 +00:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull request overview

This PR removes the centralized src/ugui/types.lua and redistributes ugui’s EmmyLua/LuaLS type annotations (and a few runtime enums/tables) into the modules where they’re most relevant.

Changes:

  • Deleted src/ugui/types.lua and moved shared aliases/enums into core.lua, scene entry typing into internal.lua, and control-specific types into each control module.
  • Introduced src/ugui/environment/keycode.lua for ugui.keycodes + key event types.
  • Updated build.py amalgamation list to include the new files and stop including types.lua.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/ugui/types.lua Deleted centralized type/enums file.
src/ugui/internal.lua Added SceneEntry alias near scene state.
src/ugui/environment/keycode.lua New module defining ugui.keycodes and UguiKeyEventArgs.
src/ugui/core.lua Moved shared aliases/enums (UID, RichText, ControlRegistryEntry, visual/signal states) here.
src/ugui/controls/control.lua New file hosting the base Control class annotation.
src/ugui/controls/button.lua Added Button class annotation.
src/ugui/controls/toggle_button.lua Added ToggleButton class annotation.
src/ugui/controls/carrousel_button.lua Added CarrouselButton class annotation.
src/ugui/controls/combobox.lua Added ComboBox class annotation.
src/ugui/controls/textbox.lua Added TextBox class annotation.
src/ugui/controls/joystick.lua Added Joystick class annotation.
src/ugui/controls/trackbar.lua Added Trackbar class annotation.
src/ugui/controls/listbox.lua Added ListBox class annotation.
src/ugui/controls/scrollbar.lua Added ScrollBar class annotation.
src/ugui/controls/menu.lua Added MenuItem, MenuResult, and Menu class annotations.
src/ugui/controls/numberbox.lua Added NumberBox class annotation.
src/ugui/controls/tabcontrol.lua Added TabControl/TabControlResult class annotations.
src/ugui/controls/spinner.lua Added Spinner class annotation.
build.py Removed src/ugui/types.lua from ugui job; added environment/keycode.lua and controls/control.lua.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

## Pull request overview This PR removes the centralized `src/ugui/types.lua` and redistributes ugui’s EmmyLua/LuaLS type annotations (and a few runtime enums/tables) into the modules where they’re most relevant. **Changes:** - Deleted `src/ugui/types.lua` and moved shared aliases/enums into `core.lua`, scene entry typing into `internal.lua`, and control-specific types into each control module. - Introduced `src/ugui/environment/keycode.lua` for `ugui.keycodes` + key event types. - Updated `build.py` amalgamation list to include the new files and stop including `types.lua`. ### Reviewed changes Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments. <details> <summary>Show a summary per file</summary> | File | Description | | ---- | ----------- | | src/ugui/types.lua | Deleted centralized type/enums file. | | src/ugui/internal.lua | Added `SceneEntry` alias near scene state. | | src/ugui/environment/keycode.lua | New module defining `ugui.keycodes` and `UguiKeyEventArgs`. | | src/ugui/core.lua | Moved shared aliases/enums (`UID`, `RichText`, `ControlRegistryEntry`, visual/signal states) here. | | src/ugui/controls/control.lua | New file hosting the base `Control` class annotation. | | src/ugui/controls/button.lua | Added `Button` class annotation. | | src/ugui/controls/toggle_button.lua | Added `ToggleButton` class annotation. | | src/ugui/controls/carrousel_button.lua | Added `CarrouselButton` class annotation. | | src/ugui/controls/combobox.lua | Added `ComboBox` class annotation. | | src/ugui/controls/textbox.lua | Added `TextBox` class annotation. | | src/ugui/controls/joystick.lua | Added `Joystick` class annotation. | | src/ugui/controls/trackbar.lua | Added `Trackbar` class annotation. | | src/ugui/controls/listbox.lua | Added `ListBox` class annotation. | | src/ugui/controls/scrollbar.lua | Added `ScrollBar` class annotation. | | src/ugui/controls/menu.lua | Added `MenuItem`, `MenuResult`, and `Menu` class annotations. | | src/ugui/controls/numberbox.lua | Added `NumberBox` class annotation. | | src/ugui/controls/tabcontrol.lua | Added `TabControl`/`TabControlResult` class annotations. | | src/ugui/controls/spinner.lua | Added `Spinner` class annotation. | | build.py | Removed `src/ugui/types.lua` from ugui job; added `environment/keycode.lua` and `controls/control.lua`. | </details> --- 💡 <a href="/mupen64/ugui/new/main?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.<br><br>You can also share your feedback on Copilot code review. [Take the survey](https://www.surveymonkey.com/r/XP6L3XJ).
@ -29,14 +29,15 @@ JOBS: list[tuple[list[Path], Path]] = [
(
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-03-15 13:26:42 +00:00

In the ugui amalgamation order, environment/env.lua annotates Environment.key_events as UguiKeyEventArgs[], but UguiKeyEventArgs is currently defined later in environment/keycode.lua. If consumers rely on the generated build/ugui-amalgamated.lua for LuaLS/EmmyLua type info, this ordering can make UguiKeyEventArgs unresolved. Consider moving keycode.lua earlier than env.lua in the JOBS list (or moving the UguiKeyEventArgs type to env.lua).

In the ugui amalgamation order, `environment/env.lua` annotates `Environment.key_events` as `UguiKeyEventArgs[]`, but `UguiKeyEventArgs` is currently defined later in `environment/keycode.lua`. If consumers rely on the generated `build/ugui-amalgamated.lua` for LuaLS/EmmyLua type info, this ordering can make `UguiKeyEventArgs` unresolved. Consider moving `keycode.lua` earlier than `env.lua` in the JOBS list (or moving the `UguiKeyEventArgs` type to `env.lua`).
@ -39,3 +39,4 @@
Path("src/ugui/styler.lua"),
Path("src/ugui/controls/control.lua"),
Path("src/ugui/controls/label.lua"),
Path("src/ugui/controls/button.lua"),
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2026-03-15 13:26:42 +00:00

core.lua defines ControlRegistryEntry using the Control type, but the Control class annotation was moved to src/ugui/controls/control.lua, which is concatenated after core.lua (and after internal.lua) in the amalgamation order. This can cause Control to be unresolved in the generated amalgamated file’s type annotations. Consider relocating the Control type definition to core.lua (near the other shared types) or introducing an earlier-loaded shared types file so Control is defined before any references in core.lua/internal.lua.

`core.lua` defines `ControlRegistryEntry` using the `Control` type, but the `Control` class annotation was moved to `src/ugui/controls/control.lua`, which is concatenated after `core.lua` (and after `internal.lua`) in the amalgamation order. This can cause `Control` to be unresolved in the generated amalgamated file’s type annotations. Consider relocating the `Control` type definition to `core.lua` (near the other shared types) or introducing an earlier-loaded shared types file so `Control` is defined before any references in `core.lua`/`internal.lua`.
Sign in to join this conversation.
No description provided.