declare type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor | BigInt64ArrayConstructor | BigUint64ArrayConstructor; declare type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array; declare function custom(init: () => T): [() => T]; declare function custom(): T[]; declare const types: { custom: typeof custom; any: ArrayConstructor; int8: Int8ArrayConstructor; i8: Int8ArrayConstructor; char: Int8ArrayConstructor; uint8: Uint8ArrayConstructor; u8: Uint8ArrayConstructor; uchar: Uint8ArrayConstructor; int16: Int16ArrayConstructor; i16: Int16ArrayConstructor; short: Int16ArrayConstructor; uint16: Uint16ArrayConstructor; u16: Uint16ArrayConstructor; ushort: Uint16ArrayConstructor; int32: Int32ArrayConstructor; i32: Int32ArrayConstructor; int: Int32ArrayConstructor; uint32: Uint32ArrayConstructor; u32: Uint32ArrayConstructor; uint: Uint32ArrayConstructor; float32: Float32ArrayConstructor; f32: Float32ArrayConstructor; float: Float32ArrayConstructor; float64: Float64ArrayConstructor; f64: Float64ArrayConstructor; double: Float64ArrayConstructor; int64: BigInt64ArrayConstructor; bigint64: BigInt64ArrayConstructor; i64: BigInt64ArrayConstructor; long: BigInt64ArrayConstructor; uint64: BigUint64ArrayConstructor; biguint64: BigUint64ArrayConstructor; u64: BigUint64ArrayConstructor; ulong: BigUint64ArrayConstructor; }; declare type Tree = LeafType | { [key: string]: Tree; }; declare type InitFunc = () => unknown; declare type Type = TypedArrayConstructor | ArrayConstructor | [InitFunc] | unknown[]; declare type ComponentArray = Tree> = (T extends [InitFunc] ? ReturnType[] : T extends unknown[] ? T : T extends ArrayConstructor ? any[] : T extends Exclude ? InstanceType : { [key in keyof T]: T[key] extends Tree ? ComponentArray : never; }); declare class SparseSet { packed: number[]; sparse: number[]; has(x: number): boolean; add(x: number): void; remove(x: number): void; } declare class Archetype { sset: SparseSet; entities: number[]; mask: Uint32Array; change: Archetype[]; constructor(mask: Uint32Array); has(x: number): boolean; } declare function all(...cmps: Q[]): { op: typeof all; dt: Q[]; }; declare function not(cmp: Q): { op: typeof not; dt: Q | { op: typeof all; dt: Q[]; }; }; declare function any(...cmps: Q[]): { op: typeof any; dt: Q[]; }; declare type MLeaf = { op: typeof all | typeof any; dt: Uint32Array; }; declare type Group = { op: typeof all | typeof any; dt: [MLeaf, ...QueryMask[]]; }; declare type Not = { op: typeof not; dt: QueryMask; }; declare type QueryMask = Group | Not | MLeaf; declare type RawQuery = { op: typeof all | typeof any; dt: (RawQuery | ComponentArray)[]; } | { op: typeof not; dt: RawQuery | ComponentArray; }; declare class Query { mask: QueryMask; archetypes: Archetype[]; ecs: ECS; constructor(ecs: ECS, q: RawQuery | undefined); forEach(callbackfn: (id: number, ecs: ECS) => void): void; _forEach(callbackfn: (id: number, ecs: ECS) => void): void; static match(target: Uint32Array, mask: QueryMask): boolean; protected static partial(target: Uint32Array, mask: MLeaf): boolean; } declare class ECS { protected _arch: Map; protected _ent: Archetype[]; protected _queries: Query[]; protected _destroy: SparseSet; protected _mcmp: { addrm: boolean[]; ent: number[]; cmp: number[]; }; protected _rm: SparseSet; protected _empty: Archetype; protected cmpID: number; protected entID: number; readonly MAX_ENTITIES: number; readonly DEFAULT_DEFER: boolean; constructor(max?: number, defer?: boolean); bind(): Pick>; defineComponent>(def: T): ComponentArray; defineComponent(): {}; registerComponent(cmp: T): T; protected _initEmpty(): void; createQuery(...raw: RawQuery[]): Query; protected _validID(id: unknown): boolean; protected _getArch(mask: Uint32Array): Archetype; protected _hasComponent(mask: Uint32Array, i: number): number; protected _archChange(id: number, i: number): void; protected _crEnt(id: number): void; createEntity(): number; destroyEntity(id: number, defer?: boolean): void; destroyPending(): void; protected _addcmp(id: number, cmp: number): void; addComponent(id: number, cmp: ComponentArray, defer?: boolean): this; protected _rmcmp(id: number, cmp: number): void; removeComponent(id: number, cmp: ComponentArray, defer?: boolean): this; updatePending(): void; } export { ComponentArray, ECS, Tree, TypedArray, TypedArrayConstructor, all, any, not, types };