Skip to content

refactor(components): migrate ZoneComponent and ScreenComponent to class fields#8671

Merged
willeastcott merged 5 commits into
mainfrom
refactor/zone-screen-class-fields
May 3, 2026
Merged

refactor(components): migrate ZoneComponent and ScreenComponent to class fields#8671
willeastcott merged 5 commits into
mainfrom
refactor/zone-screen-class-fields

Conversation

@willeastcott
Copy link
Copy Markdown
Contributor

Summary

Migrates the constructor-initialised instance state of ZoneComponent and ScreenComponent to ES2022 public class field declarations, continuing the modernisation pass applied earlier to component data and several other components.

  • ZoneComponent: moves _oldState and _size out of the constructor; the set_enabled listener wiring stays in the constructor.
  • ScreenComponent: moves 10 instance fields out of the constructor. The graphicsDevice.on('resizecanvas', ...) wiring stays in the constructor. One minor simplification: this.cull = this._screenSpace; becomes cull = false; — the original value was always false at that point (_screenSpace had just been assigned false on the line above), so the default is unchanged.
  • /** @private */ tags added to the newly-declared underscore-prefixed fields to match the convention already used elsewhere in the codebase (e.g. button/component.js, layout-child/component.js).

Pure internal refactor. No behavioral change, no public API change.

Test plan

  • npm run lint — clean.
  • npm test — 1672 tests passing.

…ass fields

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR continues the component modernisation work by moving constructor-initialized instance state for ZoneComponent and ScreenComponent into ES2022 class field declarations. In the framework, that keeps component defaults closer to their declarations while leaving runtime wiring in the constructors.

Changes:

  • Moved ZoneComponent’s _oldState and _size defaults from the constructor to class fields.
  • Moved ScreenComponent’s per-instance defaults (Vec2, Mat4, Set, scalar flags, and cull) from the constructor to class fields.
  • Kept constructor side effects intact, including set_enabled binding for zones and resizecanvas subscription for screens.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/framework/components/zone/component.js Declares zone private instance state as class fields instead of assigning it in the constructor.
src/framework/components/screen/component.js Declares screen default instance state as class fields and preserves constructor event wiring.

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

Comment thread src/framework/components/screen/component.js Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@willeastcott willeastcott merged commit c96acf6 into main May 3, 2026
8 checks passed
@willeastcott willeastcott deleted the refactor/zone-screen-class-fields branch May 3, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Request for a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants