From 2c2b32712bdef99f3b101e976e90f031ba3dca10 Mon Sep 17 00:00:00 2001 From: maeriil Date: Fri, 31 Jan 2025 00:54:39 -0500 Subject: [PATCH] resolves #182 - TS types for Archetypes --- jecs.d.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/jecs.d.ts b/jecs.d.ts index 136dcb9..7dea49f 100644 --- a/jecs.d.ts +++ b/jecs.d.ts @@ -40,6 +40,26 @@ 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 i53 = number +type i24 = number +type Ty = i53[]; +type ArchetypeId = number +type Column = unknown[]; + +type ArchetypeRecord = { + count: number; + column: number; +} + +export type Archetype = { + id: number; + types: Ty; + type: string; + entities: number[]; + columns: Column[]; + records: ArchetypeRecord[]; +} + type Iter = IterableFunction>; export type CachedQuery = { @@ -47,6 +67,12 @@ export type CachedQuery = { * Returns an iterator that produces a tuple of [Entity, ...queriedComponents]. */ iter(): Iter; + + /** + * Returns the archetype of the query + * @returns An array of archetype of the query + */ + archetypes(): Archetype[]; } & Iter; export type Query = { @@ -75,6 +101,12 @@ export type Query = { * @returns A new Query with the exclusion applied. */ without(...components: Id[]): Query; + + /** + * Returns the archetype of the query + * @returns An array of archetype of the query + */ + archetypes(): Archetype[]; } & Iter; export class World {