/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ const isDecorator = Symbol("isDecorator"); /** * Mark a function as a decorator. */ export function Decorator(decorate: T): T { (decorate as any)[isDecorator] = true; return decorate; } /** * A function that may act as a tc39 decorator. */ export type Decorator = Decorator.Class | Decorator.Property; export namespace Decorator { /** * Determine if a function is marked as a decorator. */ export function is(fn: Function): fn is Decorator { return !!(fn as any)[isDecorator]; } export interface Class any = abstract new (...args: any) => any> { (target: T, context: ClassDecoratorContext): T | void; } export interface ClassMethod< This = unknown, T extends (this: This, ...args: any) => any = (this: This, ...args: any) => any, > { (target: T, context: ClassMethodDecoratorContext): T | void; } export interface ClassGetter void> { (target: T, context: ClassGetterDecoratorContext): T | void; } export interface ClassSetter Value> { (target: T, context: ClassSetterDecoratorContext): T | void; } export interface ClassField { (target: undefined, context: ClassFieldDecoratorContext): ((initialValue: Value) => Value) | void; } export type ClassAccessor = { ( target: ClassAccessorDecoratorTarget, context: ClassAccessorDecoratorContext, ): ClassAccessorDecoratorResult<{}, unknown>; }; export type Property = | ClassGetter | ClassSetter | ClassField | ClassAccessor; export type PropertyContext = | ClassGetterDecoratorContext | ClassSetterDecoratorContext | ClassFieldDecoratorContext | ClassAccessorDecoratorContext; export interface ClassCollector { (target: NewableFunction, context: ClassDecoratorContext): void; } export interface MethodCollector { (target: CallableFunction, context: ClassMethodDecoratorContext): void; } export interface PropertyCollector { (target: CallableFunction | undefined, context: PropertyContext): void; } export interface Collector { (target: NewableFunction | CallableFunction | undefined, context: DecoratorContext): void; } }