diff --git a/jecs.d.ts b/jecs.d.ts index 136dcb9..c5288de 100644 --- a/jecs.d.ts +++ b/jecs.d.ts @@ -40,6 +40,23 @@ type FlattenTuple = T extends [infer U] ? U : LuaTuple; type Nullable = { [K in keyof T]: T[K] | undefined }; type InferComponents = { [K in keyof A]: InferComponent }; +type ArchetypeId = number +type Column = unknown[]; + +type ArchetypeRecord = { + count: number; + column: number; +} + +export type Archetype = { + id: number; + types: number[]; + type: string; + entities: number[]; + columns: Column[]; + records: ArchetypeRecord[]; +} + type Iter = IterableFunction>; export type CachedQuery = { @@ -47,6 +64,12 @@ export type CachedQuery = { * Returns an iterator that produces a tuple of [Entity, ...queriedComponents]. */ iter(): Iter; + + /** + * Returns the matched archetypes of the query + * @returns An array of archetypes of the query + */ + archetypes(): Archetype[]; } & Iter; export type Query = { @@ -75,6 +98,12 @@ export type Query = { * @returns A new Query with the exclusion applied. */ without(...components: Id[]): Query; + + /** + * Returns the matched archetypes of the query + * @returns An array of archetypes of the query + */ + archetypes(): Archetype[]; } & Iter; export class World {