Typescript Types for Archetypes
Some checks failed
analysis / Run Luau Analyze (push) Has been cancelled
deploy-docs / build (push) Has been cancelled
publish-npm / publish (push) Has been cancelled
unit-testing / Run Luau Tests (push) Has been cancelled
deploy-docs / Deploy (push) Has been cancelled

* resolves #182 - TS types for Archetypes

* description for archetype query

* updated archetype number type
This commit is contained in:
maeriil 2025-01-31 09:29:32 -05:00 committed by GitHub
parent cc7daa6a06
commit 5c19a3b595
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

29
jecs.d.ts vendored
View file

@ -40,6 +40,23 @@ type FlattenTuple<T extends unknown[]> = T extends [infer U] ? U : LuaTuple<T>;
type Nullable<T extends unknown[]> = { [K in keyof T]: T[K] | undefined };
type InferComponents<A extends Id[]> = { [K in keyof A]: InferComponent<A[K]> };
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<T extends unknown[]> = IterableFunction<LuaTuple<[Entity, ...T]>>;
export type CachedQuery<T extends unknown[]> = {
@ -47,6 +64,12 @@ export type CachedQuery<T extends unknown[]> = {
* Returns an iterator that produces a tuple of [Entity, ...queriedComponents].
*/
iter(): Iter<T>;
/**
* Returns the matched archetypes of the query
* @returns An array of archetypes of the query
*/
archetypes(): Archetype[];
} & Iter<T>;
export type Query<T extends unknown[]> = {
@ -75,6 +98,12 @@ export type Query<T extends unknown[]> = {
* @returns A new Query with the exclusion applied.
*/
without(...components: Id[]): Query<T>;
/**
* Returns the matched archetypes of the query
* @returns An array of archetypes of the query
*/
archetypes(): Archetype[];
} & Iter<T>;
export class World {