From 45c12a842b29684a088078bc58c6321bd9b2400d Mon Sep 17 00:00:00 2001 From: EncodedVenom <32179912+EncodedVenom@users.noreply.github.com> Date: Thu, 8 May 2025 17:02:23 -0400 Subject: [PATCH 1/4] Update jecs.d.ts --- jecs.d.ts | 69 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 23 deletions(-) diff --git a/jecs.d.ts b/jecs.d.ts index 7e53388..09f959b 100644 --- a/jecs.d.ts +++ b/jecs.d.ts @@ -108,6 +108,13 @@ export class World { */ constructor(); + /** + * Enforces a check for entities to be created within a desired range. + * @param range_begin The starting point + * @param range_end The end point (optional) + */ + range(range_begin: number, range_end?: number): void; + /** * Creates a new entity. * @returns An entity (Tag) with no data. @@ -130,19 +137,6 @@ export class World { */ target(entity: Entity, relation: Entity, index?: number): Entity | undefined; - /** - * Cleans up the world by removing empty archetypes and rebuilding the archetype collections. - * This helps maintain memory efficiency by removing unused archetype definitions. - */ - cleanup(): void; - - /** - * Clears all components and relationships from the given entity, but - * does not delete the entity from the world. - * @param entity The entity to clear. - */ - clear(entity: Entity): void; - /** * Deletes an entity (and its components/relationships) from the world entirely. * @param entity The entity to delete. @@ -164,6 +158,19 @@ export class World { */ set>(entity: Entity, component: E, value: InferComponent): void; + /** + * Cleans up the world by removing empty archetypes and rebuilding the archetype collections. + * This helps maintain memory efficiency by removing unused archetype definitions. + */ + cleanup(): void; + + /** + * Clears all components and relationships from the given entity, but + * does not delete the entity from the world. + * @param entity The entity to clear. + */ + clear(entity: Entity): void; + /** * Removes a component from the given entity. * @param entity The target entity. @@ -191,12 +198,6 @@ export class World { */ has(entity: Entity, ...components: Id[]): boolean; - /** - * Checks if an entity exists in the world. - * @param entity The entity to verify. - */ - contains(entity: Entity): boolean; - /** * Gets the parent (the target of a `ChildOf` relationship) for an entity, * if such a relationship exists. @@ -205,11 +206,17 @@ export class World { parent(entity: Entity): Entity | undefined; /** - * Searches the world for entities that match specified components. - * @param components The list of components to query. - * @returns A Query object to iterate over results. + * Checks if an entity exists in the world. + * @param entity The entity to verify. */ - query(...components: T): Query>; + contains(entity: Entity): boolean; + + /** + * Checks if the entity exists. + * @param entity The entity to verify. + * @returns True if the entity exists + */ + exists(entity: Entity): boolean; /** * Returns an iterator that yields all entities that have the specified component or relationship. @@ -225,8 +232,24 @@ export class World { * @returns An iterator function that yields child entities */ children(parent: Entity): IterableFunction; + + /** + * Searches the world for entities that match specified components. + * @param components The list of components to query. + * @returns A Query object to iterate over results. + */ + query(...components: T): Query>; } +export function component(): Entity; + +export function tag(): Entity; + +// note: original types had id: Entity, id: Id, which does not work with TS. +export function meta(e: Entity, id: Id, value: T): Entity + +export function is_tag(world: World, id: Id): boolean; + /** * Creates a composite key (pair) * @param pred The first entity (predicate) From 98ffef93dfb01d7b07b96078b618e93933e36cc8 Mon Sep 17 00:00:00 2001 From: EncodedVenom Date: Thu, 8 May 2025 17:04:48 -0400 Subject: [PATCH 2/4] Change meta type --- jecs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jecs.d.ts b/jecs.d.ts index 09f959b..959d08b 100644 --- a/jecs.d.ts +++ b/jecs.d.ts @@ -246,7 +246,7 @@ export function component(): Entity; export function tag(): Entity; // note: original types had id: Entity, id: Id, which does not work with TS. -export function meta(e: Entity, id: Id, value: T): Entity +export function meta(e: Entity, id: Id, value?: T): Entity export function is_tag(world: World, id: Id): boolean; From a19a422c17658cf275aa2c3c28617c6e0940e17f Mon Sep 17 00:00:00 2001 From: EncodedVenom Date: Thu, 8 May 2025 17:09:37 -0400 Subject: [PATCH 3/4] Update exists comment --- jecs.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jecs.d.ts b/jecs.d.ts index 959d08b..2b360e8 100644 --- a/jecs.d.ts +++ b/jecs.d.ts @@ -212,9 +212,9 @@ export class World { contains(entity: Entity): boolean; /** - * Checks if the entity exists. + * Checks if there is any entity alive right now, regardless of generation. * @param entity The entity to verify. - * @returns True if the entity exists + * @returns True if the entity is alive. */ exists(entity: Entity): boolean; From 4696fc980a9db63cfac5458fd63e4422019e2ec6 Mon Sep 17 00:00:00 2001 From: EncodedVenom <32179912+EncodedVenom@users.noreply.github.com> Date: Thu, 8 May 2025 21:34:41 -0400 Subject: [PATCH 4/4] Update jecs.d.ts --- jecs.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jecs.d.ts b/jecs.d.ts index 2b360e8..01239fd 100644 --- a/jecs.d.ts +++ b/jecs.d.ts @@ -212,9 +212,9 @@ export class World { contains(entity: Entity): boolean; /** - * Checks if there is any entity alive right now, regardless of generation. + * Checks if an entity with the given ID is currently alive, ignoring its generation. * @param entity The entity to verify. - * @returns True if the entity is alive. + * @returns boolean true if any entity with the given ID exists (ignoring generation), false otherwise */ exists(entity: Entity): boolean;