-
Notifications
You must be signed in to change notification settings - Fork 3.7k
TC39 migration: flip experimentalDecorators to Stage 3 decorators (atomic) #18647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
379ca64
80ef7f0
35c1d7c
2f29f1f
02ed4a4
3ca425d
f3cce2f
15837ed
692eb09
a28f28c
67febed
2e7536f
d8d307f
1b73d6c
1637c9d
37e1149
48a3f0f
bd10f12
b820cc8
4547aee
2fbc6b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,7 +98,10 @@ export class FlyCamera extends TargetCamera { | |
| * inherited {@link TargetCamera.movement} to {@link TargetCameraMovement}; the instance is | ||
| * created by the {@link TargetCamera} constructor. | ||
| */ | ||
| public override movement: TargetCameraMovement; | ||
| // `declare`, not `override`: the value is created by the base TargetCamera constructor. Under TC39 | ||
| // decorators a plain field redeclaration is materialized as a constructor field-init that runs after | ||
| // super() and would clobber that value back to undefined; `declare` keeps this a type-only narrowing. | ||
|
Comment on lines
+101
to
+103
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe include this comment on the other similar ones? I don't think ppl will understand the syntax.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only two declare sites exist (freeCamera.pure.ts:64 and flyCamera.pure.ts:101) and both already carry the identical comment block. |
||
| declare public movement: TargetCameraMovement; | ||
|
|
||
| /** | ||
| * Gets the input sensibility for mouse input. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import { type Nullable } from "../types"; | ||
| import { type Scene } from "../scene"; | ||
| import { MetadataSymbol } from "../Misc/decorators.functions"; | ||
|
|
||
| /** | ||
| * Enum defining the type of properties that can be edited in the property pages in the node editor | ||
|
|
@@ -107,19 +108,59 @@ export function editableInPropertyPage( | |
| groupName: string = "PROPERTIES", | ||
| options?: IEditablePropertyOption | ||
| ) { | ||
| return (target: any, propertyKey: string) => { | ||
| let propStore: IPropertyDescriptionForEdition[] = target._propStore; | ||
| if (!propStore) { | ||
| return (_value: unknown, context: { name: string | symbol; metadata: DecoratorMetadataObject }) => { | ||
| const meta = context.metadata as DecoratorMetadataObject | undefined; | ||
| if (!meta) { | ||
| // `context.metadata` is `void 0` when `Symbol.metadata` was not installed before this class | ||
| // was evaluated. Importing `MetadataSymbol` from decorators.functions runs the polyfill at | ||
| // module load (before this class body), so this should never happen; referencing it here also | ||
| // keeps that module-load polyfill anchored against bundler tree-shaking. | ||
| throw new Error( | ||
| `editableInPropertyPage: decorator metadata is unavailable; the Symbol.metadata (${String(MetadataSymbol)}) polyfill must run before decorated classes are evaluated.` | ||
| ); | ||
| } | ||
| let propStore: IPropertyDescriptionForEdition[]; | ||
| if (Object.prototype.hasOwnProperty.call(meta, __bjsPropStoreKey)) { | ||
| propStore = meta[__bjsPropStoreKey] as IPropertyDescriptionForEdition[]; | ||
| } else { | ||
| propStore = []; | ||
| target._propStore = propStore; | ||
| meta[__bjsPropStoreKey] = propStore; | ||
| } | ||
| propStore.push({ | ||
| propertyName: propertyKey, | ||
| propertyName: String(context.name), | ||
| displayName: displayName, | ||
| type: propertyType, | ||
| groupName: groupName, | ||
| options: options ?? {}, | ||
| className: target.getClassName(), | ||
| className: "", | ||
| }); | ||
| }; | ||
| } | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/naming-convention | ||
| const __bjsPropStoreKey = "__bjs_prop_store__"; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be cleaner to use a
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Staing consistent with |
||
|
|
||
| /** | ||
| * Gets the editable properties for a given target using TC39 decorator metadata. | ||
| * Walks the metadata prototype chain to include properties from parent classes. | ||
| * @param target - the target object (instance or constructor) | ||
| * @returns array of property descriptions | ||
| */ | ||
| export function GetEditableProperties(target: any): IPropertyDescriptionForEdition[] { | ||
| const ctor = typeof target === "function" ? target : target?.constructor; | ||
| const metadata: DecoratorMetadataObject | undefined = ctor?.[MetadataSymbol]; | ||
| if (!metadata) { | ||
| return []; | ||
| } | ||
|
|
||
| const result: IPropertyDescriptionForEdition[] = []; | ||
| let currentMeta: any = metadata; | ||
| while (currentMeta) { | ||
| if (Object.prototype.hasOwnProperty.call(currentMeta, __bjsPropStoreKey)) { | ||
| const store = currentMeta[__bjsPropStoreKey] as IPropertyDescriptionForEdition[]; | ||
| result.push(...store); | ||
| } | ||
| currentMeta = Object.getPrototypeOf(currentMeta); | ||
| } | ||
| return result; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.