forked from ecsyjs/ecsy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathComponent.d.ts
46 lines (38 loc) · 1.07 KB
/
Component.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { PropType } from "./Types";
/**
* Base class for components.
*/
export type ComponentSchemaProp<T> = {
default?: T;
type: PropType<T, T>;
};
export type ComponentSchema = {
[propName: string]: ComponentSchemaProp<any>;
};
export type SchemaProperties<Schema> =
Partial<Omit<Schema, keyof Component<Schema>>>;
export class AbstractComponent<Properties> {
static isComponent: true;
static getName(): string;
constructor(props?: Properties);
copy(source: this | Properties): this;
clone(): this
setProperties(props?: Properties): this;
reset(): void;
dispose(): void;
}
export class Component<Schema>
extends AbstractComponent<SchemaProperties<Schema>> {
static schema: ComponentSchema;
static isSchemaComponent: true;
constructor(props?: SchemaProperties<Schema>);
}
export interface ComponentConstructor<C extends AbstractComponent<any>> {
isComponent: true;
new (...args: any): C;
}
export interface SchemaConstructable<C extends Component<C>> {
schema: ComponentSchema;
isSchemaComponent: true;
new (props?: SchemaProperties<C>): C;
}