refactor(components): migrate ZoneComponent and ScreenComponent to class fields#8671
Merged
Conversation
…ass fields Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
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_oldStateand_sizedefaults from the constructor to class fields. - Moved
ScreenComponent’s per-instance defaults (Vec2,Mat4,Set, scalar flags, andcull) from the constructor to class fields. - Kept constructor side effects intact, including
set_enabledbinding for zones andresizecanvassubscription 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.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates the constructor-initialised instance state of
ZoneComponentandScreenComponentto ES2022 public class field declarations, continuing the modernisation pass applied earlier to component data and several other components.ZoneComponent: moves_oldStateand_sizeout of the constructor; theset_enabledlistener wiring stays in the constructor.ScreenComponent: moves 10 instance fields out of the constructor. ThegraphicsDevice.on('resizecanvas', ...)wiring stays in the constructor. One minor simplification:this.cull = this._screenSpace;becomescull = false;— the original value was alwaysfalseat that point (_screenSpacehad just been assignedfalseon 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.