<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

*   [ComponentRef][1]
*   [ComponentData][2]
    *   [Properties][3]
*   [registerComponent][4]
    *   [Parameters][5]
*   [registerComponents][6]
    *   [Parameters][7]
*   [hasComponent][8]
    *   [Parameters][9]
*   [getComponent][10]
    *   [Parameters][11]
*   [set][12]
    *   [Parameters][13]
*   [recursivelyInherit][14]
    *   [Parameters][15]
*   [ComponentSetter][16]
    *   [Properties][17]
*   [setComponent][18]
    *   [Parameters][19]
*   [addComponent][20]
    *   [Parameters][21]
*   [addComponents][22]
    *   [Parameters][23]
*   [removeComponent][24]
    *   [Parameters][25]
*   [removeComponents][26]
    *   [Parameters][27]
*   [addPrefab][28]
    *   [Parameters][29]
*   [addEntity][30]
    *   [Parameters][31]
*   [removeEntity][32]
    *   [Parameters][33]
*   [getEntityComponents][34]
    *   [Parameters][35]
*   [entityExists][36]
    *   [Parameters][37]
*   [EntityIndex][38]
    *   [Properties][39]
    *   [aliveCount][40]
    *   [dense][41]
    *   [sparse][42]
    *   [maxId][43]
    *   [versioning][44]
    *   [versionBits][45]
    *   [entityMask][46]
    *   [versionShift][47]
    *   [versionMask][48]
*   [getId][49]
    *   [Parameters][50]
*   [getVersion][51]
    *   [Parameters][52]
*   [incrementVersion][53]
    *   [Parameters][54]
*   [withVersioning][55]
    *   [Parameters][56]
*   [createEntityIndex][57]
    *   [Parameters][58]
*   [addEntityId][59]
    *   [Parameters][60]
*   [removeEntityId][61]
    *   [Parameters][62]
*   [isEntityIdAlive][63]
    *   [Parameters][64]
*   [growDepthsArray][65]
    *   [Parameters][66]
*   [updateDepthCache][67]
    *   [Parameters][68]
*   [updateMaxDepth][69]
    *   [Parameters][70]
*   [setEntityDepth][71]
    *   [Parameters][72]
*   [invalidateQueryCache][73]
    *   [Parameters][74]
*   [getHierarchyData][75]
    *   [Parameters][76]
*   [populateExistingDepths][77]
    *   [Parameters][78]
*   [ensureDepthTracking][79]
    *   [Parameters][80]
*   [calculateEntityDepth][81]
    *   [Parameters][82]
*   [getEntityDepthWithVisited][83]
    *   [Parameters][84]
*   [getEntityDepth][85]
    *   [Parameters][86]
*   [markChildrenDirty][87]
    *   [Parameters][88]
*   [updateHierarchyDepth][89]
    *   [Parameters][90]
*   [invalidateHierarchyDepth][91]
    *   [Parameters][92]
*   [invalidateSubtree][93]
    *   [Parameters][94]
*   [flushDirtyDepths][95]
    *   [Parameters][96]
*   [queryHierarchy][97]
    *   [Parameters][98]
*   [queryHierarchyDepth][99]
    *   [Parameters][100]
*   [getHierarchyDepth][101]
    *   [Parameters][102]
*   [getMaxHierarchyDepth][103]
    *   [Parameters][104]
*   [QueryResult][105]
*   [QueryOptions][106]
    *   [Properties][107]
*   [Query][108]
    *   [Properties][109]
*   [QueryOperatorType][110]
*   [$opType][111]
*   [$opTerms][112]
*   [OpReturnType][113]
    *   [Properties][114]
*   [QueryOperator][115]
    *   [Parameters][116]
*   [QueryTerm][117]
*   [HierarchyTerm][118]
    *   [Properties][119]
*   [Hierarchy][120]
    *   [Parameters][121]
*   [Cascade][122]
    *   [Parameters][123]
*   [QueryModifier][124]
    *   [Properties][125]
*   [ObservableHook][126]
    *   [Parameters][127]
*   [observe][128]
    *   [Parameters][129]
*   [queryHash][130]
    *   [Parameters][131]
*   [registerQuery][132]
    *   [Parameters][133]
*   [queryInternal][134]
    *   [Parameters][135]
*   [query][136]
    *   [Parameters][137]
*   [queryCheckEntity][138]
    *   [Parameters][139]
*   [queryCheckComponent][140]
    *   [Parameters][141]
*   [queryAddEntity][142]
    *   [Parameters][143]
*   [queryCommitRemovals][144]
    *   [Parameters][145]
*   [commitRemovals][146]
    *   [Parameters][147]
*   [queryRemoveEntity][148]
    *   [Parameters][149]
*   [removeQuery][150]
    *   [Parameters][151]
*   [OnTargetRemovedCallback][152]
    *   [Parameters][153]
*   [RelationTarget][154]
*   [$relation][155]
*   [$pairTarget][156]
*   [$isPairComponent][157]
*   [$relationData][158]
*   [RelationData][159]
*   [Relation][160]
    *   [Parameters][161]
*   [createBaseRelation][162]
*   [withStore][163]
    *   [Parameters][164]
*   [makeExclusive][165]
    *   [Parameters][166]
*   [withAutoRemoveSubject][167]
    *   [Parameters][168]
*   [withOnTargetRemoved][169]
    *   [Parameters][170]
*   [withValidation][171]
    *   [Parameters][172]
*   [Pair][173]
    *   [Parameters][174]
*   [getRelationTargets][175]
    *   [Parameters][176]
*   [createRelation][177]
    *   [Parameters][178]
*   [createRelation][179]
    *   [Parameters][180]
*   [$wildcard][181]
*   [createWildcardRelation][182]
*   [getWildcard][183]
*   [Wildcard][184]
*   [createIsARelation][185]
*   [getIsA][186]
*   [IsA][187]
*   [isWildcard][188]
    *   [Parameters][189]
*   [isRelation][190]
    *   [Parameters][191]
*   [createWorld][192]
    *   [Parameters][193]
*   [resetWorld][194]
    *   [Parameters][195]
*   [deleteWorld][196]
    *   [Parameters][197]
*   [getWorldComponents][198]
    *   [Parameters][199]
*   [getAllEntities][200]
    *   [Parameters][201]

## ComponentRef

Represents a reference to a component.

Type: any

## ComponentData

Represents the data associated with a component.

### Properties

*   `id` **[number][202]** The unique identifier for the component.
*   `generationId` **[number][202]** The generation ID of the component.
*   `bitflag` **[number][202]** The bitflag used for component masking.
*   `ref` **[ComponentRef][1]** Reference to the component.
*   `queries` **[Set][203]<[Query][108]>** Set of queries associated with the component.
*   `setObservable` **Observable** Observable for component changes.

## registerComponent

Registers a component with the world.

### Parameters

*   `world` **World** The world object.
*   `component` **[ComponentRef][1]** The component to register.

<!---->

*   Throws **[Error][204]** If the component is null or undefined.

Returns **[ComponentData][2]** The registered component data.

## registerComponents

Registers multiple components with the world.

### Parameters

*   `world` **World** The world object.
*   `components` **[Array][205]<[ComponentRef][1]>** Array of components to register.

## hasComponent

Checks if an entity has a specific component.

### Parameters

*   `world` **World** The world object.
*   `eid` **[number][202]** The entity ID.
*   `component` **[ComponentRef][1]** The component to check for.

Returns **[boolean][206]** True if the entity has the component, false otherwise.

## getComponent

Retrieves the data associated with a component for a specific entity.

### Parameters

*   `world` **World** The world object.
*   `eid` **EntityId** The entity ID.
*   `component` **[ComponentRef][1]** The component to retrieve data for.

Returns **any** The component data, or undefined if the component is not found or the entity doesn't have the component.

## set

Helper function to set component data.

### Parameters

*   `component` **[ComponentRef][1]** The component to set.
*   `data` **any** The data to set for the component.

Returns **{component: [ComponentRef][1], data: any}** An object containing the component and its data.

## recursivelyInherit

Recursvely inherits components from one entity to another.

### Parameters

*   `ctx` **WorldContext**&#x20;
*   `world` **World** The world object.
*   `baseEid` **[number][202]** The ID of the entity inheriting components.
*   `inheritedEid` **[number][202]** The ID of the entity being inherited from.
*   `visited`   (optional, default `new Set<EntityId>()`)
*   `isFirstSuper` **[boolean][206]** Whether this is the first super in the inheritance chain.

Returns **void**&#x20;

## ComponentSetter

Represents a component with data to be set on an entity.

Type: {component: [ComponentRef][1], data: T}

### Properties

*   `component` **[ComponentRef][1]**&#x20;
*   `data` **T**&#x20;

## setComponent

Sets component data on an entity. Always calls the setter observable even if entity already has the component.

### Parameters

*   `world` **World** The world object.
*   `eid` **EntityId** The entity ID.
*   `component` **[ComponentRef][1]** The component to set.
*   `data` **any** The data to set for the component.

<!---->

*   Throws **[Error][204]** If the entity does not exist in the world.

Returns **void**&#x20;

## addComponent

Adds a single component to an entity.

### Parameters

*   `world` **World** The world object.
*   `eid` **EntityId** The entity ID.
*   `componentOrSet` **([ComponentRef][1] | [ComponentSetter][16])** Component to add or set.

<!---->

*   Throws **[Error][204]** If the entity does not exist in the world.

Returns **[boolean][206]** True if component was added, false if it already existed.

## addComponents

Adds multiple components to an entity.

### Parameters

*   `world` **World** The world object.
*   `eid` **EntityId** The entity ID.
*   `components` **([Array][205]<([ComponentRef][1] | [ComponentSetter][16])> | [ComponentRef][1] | [ComponentSetter][16])** Components to add or set (array or spread args).

<!---->

*   Throws **[Error][204]** If the entity does not exist in the world.

Returns **void**&#x20;

## removeComponent

Removes one or more components from an entity.

### Parameters

*   `world` **World** The world object.
*   `eid` **[number][202]** The entity ID.
*   `components` **...[ComponentRef][1]** Components to remove.

<!---->

*   Throws **[Error][204]** If the entity does not exist in the world.

## removeComponents

Removes one or more components from an entity. This is an alias for removeComponent.

### Parameters

*   `world` **World** The world object.
*   `eid` **EntityId** The entity ID.
*   `components` **...[ComponentRef][1]** Components to remove.

<!---->

*   Throws **[Error][204]** If the entity does not exist in the world.

## addPrefab

Creates a new prefab entity in the world. Prefabs are special entities marked with the Prefab component
that are excluded from normal queries and can be used as templates for creating other entities.

### Parameters

*   `world` **World** The world object to create the prefab in.

Returns **EntityId** The entity ID of the created prefab.

## addEntity

Adds a new entity to the specified world.

### Parameters

*   `world` **World**&#x20;

Returns **[number][202]** eid

## removeEntity

Removes an existing entity from the specified world.

### Parameters

*   `world` **World**&#x20;
*   `eid` **[number][202]**&#x20;

## getEntityComponents

Returns an array of components that an entity possesses.

### Parameters

*   `world` **any**&#x20;
*   `eid` **any**&#x20;

Returns **[Array][205]<[ComponentRef][1]>**&#x20;

## entityExists

Checks the existence of an entity in a world

### Parameters

*   `world` **World**&#x20;
*   `eid` **[number][202]**&#x20;

## EntityIndex

Represents the structure for managing entity IDs.

Type: {aliveCount: [number][202], dense: [Array][205]<[number][202]>, sparse: [Array][205]<[number][202]>, maxId: [number][202], versioning: [boolean][206], versionBits: [number][202], entityMask: [number][202], versionShift: [number][202], versionMask: [number][202]}

### Properties

*   `aliveCount` **[number][202]**&#x20;
*   `dense` **[Array][205]<[number][202]>**&#x20;
*   `sparse` **[Array][205]<[number][202]>**&#x20;
*   `maxId` **[number][202]**&#x20;
*   `versioning` **[boolean][206]**&#x20;
*   `versionBits` **[number][202]**&#x20;
*   `entityMask` **[number][202]**&#x20;
*   `versionShift` **[number][202]**&#x20;
*   `versionMask` **[number][202]**&#x20;

### aliveCount

The number of currently alive entities.

Type: [number][202]

### dense

Array of entity IDs, densely packed.

Type: [Array][205]<[number][202]>

### sparse

Sparse array mapping entity IDs to their index in the dense array.

Type: [Array][205]<[number][202]>

### maxId

The highest entity ID that has been assigned.

Type: [number][202]

### versioning

Flag indicating if versioning is enabled.

Type: [boolean][206]

### versionBits

Number of bits used for versioning.

Type: [number][202]

### entityMask

Bit mask for entity ID.

Type: [number][202]

### versionShift

Bit shift for version.

Type: [number][202]

### versionMask

Bit mask for version.

Type: [number][202]

## getId

Extracts the entity ID from a versioned entity ID by stripping off the version.

### Parameters

*   `index` **[EntityIndex][38]** The EntityIndex containing the masks.
*   `id` **[number][202]** The versioned entity ID.

Returns **[number][202]** The entity ID without the version.

## getVersion

Extracts the version from an entity ID.

### Parameters

*   `index` **[EntityIndex][38]** The EntityIndex containing the masks and shifts.
*   `id` **[number][202]** The entity ID.

Returns **[number][202]** The version.

## incrementVersion

Increments the version of an entity ID.

### Parameters

*   `index` **[EntityIndex][38]** The EntityIndex containing the masks and shifts.
*   `id` **[number][202]** The entity ID.

Returns **[number][202]** The new entity ID with incremented version.

## withVersioning

Creates configuration options for entity ID recycling with versioning.

### Parameters

*   `versionBits` **[number][202]?** Optional number of bits to use for version numbers. Defaults to 8 if not specified.

Returns **[object][207]** Configuration object with versioning enabled and specified version bits.

## createEntityIndex

Creates and initializes a new EntityIndex.

### Parameters

*   `options` **([object][207] | [function][208])?** Optional configuration object from withVersioning() or withVersioning function.

    *   `options.versioning` **[boolean][206]** Flag to enable versioning for recycled IDs.
    *   `options.versionBits` **[number][202]** Number of bits to use for versioning (default: 8).

Returns **[EntityIndex][38]** A new EntityIndex object.

## addEntityId

Adds a new entity ID to the index or recycles an existing one.

### Parameters

*   `index` **[EntityIndex][38]** The EntityIndex to add to.

Returns **[number][202]** The new or recycled entity ID.

## removeEntityId

Removes an entity ID from the index.

### Parameters

*   `index` **[EntityIndex][38]** The EntityIndex to remove from.
*   `id` **[number][202]** The entity ID to remove.

Returns **void**&#x20;

## isEntityIdAlive

Checks if an entity ID is currently alive in the index.

### Parameters

*   `index` **[EntityIndex][38]** The EntityIndex to check.
*   `id` **[number][202]** The entity ID to check.

Returns **[boolean][206]** True if the entity ID is alive, false otherwise.

## growDepthsArray

Grows the depths array to accommodate a specific entity

### Parameters

*   `hierarchyData` **HierarchyData**&#x20;
*   `entity` **EntityId**&#x20;

Returns **[Uint32Array][209]**&#x20;

## updateDepthCache

Updates the depthToEntities cache when an entity's depth changes

### Parameters

*   `hierarchyData` **HierarchyData**&#x20;
*   `entity` **EntityId**&#x20;
*   `newDepth` **[number][202]**&#x20;
*   `oldDepth` **[number][202]?**&#x20;

Returns **void**&#x20;

## updateMaxDepth

Updates max depth if the new depth is greater

### Parameters

*   `hierarchyData` **HierarchyData**&#x20;
*   `depth` **[number][202]**&#x20;

Returns **void**&#x20;

## setEntityDepth

Sets entity depth and updates all related caches

### Parameters

*   `hierarchyData` **HierarchyData**&#x20;
*   `entity` **EntityId**&#x20;
*   `newDepth` **[number][202]**&#x20;
*   `oldDepth` **[number][202]?**&#x20;

Returns **void**&#x20;

## invalidateQueryCache

Invalidates hierarchy query cache for a relation

### Parameters

*   `world` **World**&#x20;
*   `relation` **[ComponentRef][1]**&#x20;

Returns **void**&#x20;

## getHierarchyData

Gets hierarchy data for a relation, activating tracking if needed

### Parameters

*   `world` **World**&#x20;
*   `relation` **[ComponentRef][1]**&#x20;

Returns **HierarchyData**&#x20;

## populateExistingDepths

Populates depth calculations for all existing entities with this relation

### Parameters

*   `world` **World**&#x20;
*   `relation` **[ComponentRef][1]**&#x20;

Returns **void**&#x20;

## ensureDepthTracking

Ensures depth tracking is initialized for a relation. This must be called before
using hierarchy features for a specific relation component.

### Parameters

*   `world` **World** The world object.
*   `relation` **[ComponentRef][1]** The relation component to initialize tracking for.

Returns **void**&#x20;

## calculateEntityDepth

Calculates the hierarchy depth of an entity for a given relation. Depth is measured
as the distance from the root entities (entities with no parent relations).

### Parameters

*   `world` **World** The world object.
*   `relation` **[ComponentRef][1]** The relation component to calculate depth for.
*   `entity` **EntityId** The entity ID to calculate depth for.
*   `visited` **[Set][203]\<EntityId>?** Internal set to track visited entities for cycle detection. (optional, default `new Set<EntityId>()`)

Returns **[number][202]** The hierarchy depth of the entity.

## getEntityDepthWithVisited

Internal helper to get entity depth with cycle detection

### Parameters

*   `world` **World**&#x20;
*   `relation` **[ComponentRef][1]**&#x20;
*   `entity` **EntityId**&#x20;
*   `visited` **[Set][203]\<EntityId>**&#x20;

Returns **[number][202]**&#x20;

## getEntityDepth

Gets the cached depth of an entity, calculating if needed

### Parameters

*   `world` **World**&#x20;
*   `relation` **[ComponentRef][1]**&#x20;
*   `entity` **EntityId**&#x20;

Returns **[number][202]**&#x20;

## markChildrenDirty

Marks an entity and its children as needing depth recalculation. This is used
internally when hierarchy changes occur.

### Parameters

*   `world` **World** The world object.
*   `relation` **[ComponentRef][1]** The relation component.
*   `parent` **EntityId** The parent entity ID.
*   `dirty` **SparseSet** The set to mark dirty entities in.
*   `visited` **SparseSet?** Internal set to track visited entities for cycle detection. (optional, default `createSparseSet()`)

Returns **void**&#x20;

## updateHierarchyDepth

Updates hierarchy depth when a relation is added. This function is called automatically
when components are added to maintain accurate depth tracking.

### Parameters

*   `world` **World** The world object.
*   `relation` **[ComponentRef][1]** The relation component.
*   `entity` **EntityId** The entity ID that had a relation added.
*   `parent` **EntityId?** The parent entity ID in the relation.
*   `updating` **[Set][203]\<EntityId>?** Internal set to track entities being updated. (optional, default `new Set<EntityId>()`)

Returns **void**&#x20;

## invalidateHierarchyDepth

Invalidates hierarchy depth when a relation is removed. This function is called automatically
when components are removed to maintain accurate depth tracking.

### Parameters

*   `world` **World** The world object.
*   `relation` **[ComponentRef][1]** The relation component.
*   `entity` **EntityId** The entity ID that had a relation removed.

Returns **void**&#x20;

## invalidateSubtree

Recursively invalidates an entire subtree

### Parameters

*   `world` **World**&#x20;
*   `relation` **[ComponentRef][1]**&#x20;
*   `entity` **EntityId**&#x20;
*   `depths` **[Uint32Array][209]**&#x20;
*   `visited` **SparseSet**&#x20;

Returns **void**&#x20;

## flushDirtyDepths

Processes all dirty depth calculations for a relation. This ensures all cached
depth values are up to date before performing hierarchy operations.

### Parameters

*   `world` **World** The world object.
*   `relation` **[ComponentRef][1]** The relation component to flush dirty depths for.

Returns **void**&#x20;

## queryHierarchy

Query entities in hierarchical order (depth-based ordering). Returns entities grouped by depth:
all depth 0, then depth 1, then depth 2, etc. This ensures parents always come before their children.

### Parameters

*   `world` **World** The world object.
*   `relation` **[ComponentRef][1]** The relation component that defines the hierarchy.
*   `components` **[Array][205]<[ComponentRef][1]>** Additional components to filter by.
*   `options` **[Object][207]?** Query options. (optional, default `{}`)

    *   `options.buffered` **[boolean][206]?** Whether to return results as Uint32Array instead of number\[].

Returns **[QueryResult][105]** Array or Uint32Array of entity IDs in hierarchical order.

## queryHierarchyDepth

Get all entities at a specific depth level in the hierarchy.

### Parameters

*   `world` **World** The world object.
*   `relation` **[ComponentRef][1]** The relation component that defines the hierarchy.
*   `depth` **[number][202]** The specific depth level to query (0 = root level).
*   `options` **[Object][207]?** Query options. (optional, default `{}`)

    *   `options.buffered` **[boolean][206]?** Whether to return results as Uint32Array instead of number\[].

Returns **[QueryResult][105]** Array or Uint32Array of entity IDs at the specified depth.

## getHierarchyDepth

Get the hierarchy depth of a specific entity for a given relation.

### Parameters

*   `world` **World** The world object.
*   `entity` **EntityId** The entity ID to get depth for.
*   `relation` **[ComponentRef][1]** The relation component that defines the hierarchy.

Returns **[number][202]** The depth of the entity (0 = root level, higher numbers = deeper).

## getMaxHierarchyDepth

Get the maximum depth in the hierarchy for a given relation.

### Parameters

*   `world` **World** The world object.
*   `relation` **[ComponentRef][1]** The relation component that defines the hierarchy.

Returns **[number][202]** The maximum depth found in the hierarchy.

## QueryResult

The result of a query, either as a Uint32Array or a readonly array of numbers.

Type: ([Uint32Array][209] | any)

## QueryOptions

Options for configuring query behavior.

Type: [Object][207]

### Properties

*   `commit` **[boolean][206]?** Whether to commit pending entity removals before querying.
*   `buffered` **[boolean][206]?** Whether to return results as Uint32Array instead of number\[].

## Query

Represents a query in the ECS using original blazing-fast bitmask evaluation.

Type: [Object][207]

### Properties

*   `allComponents` **[Array][205]<[ComponentRef][1]>** All components referenced in the query.
*   `orComponents` **[Array][205]<[ComponentRef][1]>** Components in an OR relationship.
*   `notComponents` **[Array][205]<[ComponentRef][1]>** Components that should not be present.
*   `masks` **Record<[number][202], [number][202]>** Bitmasks for each component generation.
*   `orMasks` **Record<[number][202], [number][202]>** OR bitmasks for each component generation.
*   `notMasks` **Record<[number][202], [number][202]>** NOT bitmasks for each component generation.
*   `hasMasks` **Record<[number][202], [number][202]>** HAS bitmasks for each component generation.
*   `generations` **[Array][205]<[number][202]>** Component generations.
*   `toRemove` **SparseSet** Set of entities to be removed.

## QueryOperatorType

Types of query operators.

Type: (`"Or"` | `"And"` | `"Not"`)

## $opType

Symbol for query operator type.

Type: [Symbol][210]

## $opTerms

Symbol for query operator terms.

Type: [Symbol][210]

## OpReturnType

Type: [Object][207]

### Properties

*   `$opType` **[symbol][210]?** The type of the operator.
*   `$opTerms` **[symbol][210]?** The components involved in the operation.

## QueryOperator

A function that creates a query operator.

Type: [Function][208]

### Parameters

*   `components` **...[ComponentRef][1]** The components to apply the operator to.

Returns **[OpReturnType][113]** The result of the operator.

## QueryTerm

A term in a query, either a component reference, query operator, or hierarchy term.

Type: ([ComponentRef][1] | [QueryOperator][115] | [HierarchyTerm][118])

## HierarchyTerm

Represents a hierarchy query term for topological ordering.

Type: [Object][207]

### Properties

*   `$hierarchyType` **[symbol][210]?** Always 'Hierarchy'.
*   `$hierarchyRel` **[ComponentRef][1]?** The relation component for hierarchy.
*   `$hierarchyDepth` **[number][202]?** Optional depth limit.

## Hierarchy

Creates a hierarchy query term for topological ordering (parents before children).

### Parameters

*   `relation` **[ComponentRef][1]** The relation component (e.g., ChildOf).
*   `depth` **[number][202]?** Optional depth limit.

Returns **[HierarchyTerm][118]** The hierarchy term.

## Cascade

Alias for Hierarchy - creates a hierarchy query term for topological ordering.

### Parameters

*   `relation` **[ComponentRef][1]** The relation component (e.g., ChildOf).
*   `depth` **[number][202]?** Optional depth limit.

Returns **[HierarchyTerm][118]** The hierarchy term.

## QueryModifier

Represents a query modifier that can be mixed into query terms.

Type: [Object][207]

### Properties

*   `$modifierType` **[symbol][210]?** The type of modifier ('buffer' | 'nested').

## ObservableHook

A function that creates an observable hook for queries.

Type: [Function][208]

### Parameters

*   `terms` **...[QueryTerm][117]** The query terms to observe.

## observe

Observes changes in entities based on specified components.

### Parameters

*   `world` **World** The world object.
*   `hook` **[ObservableHook][126]** The observable hook.
*   `callback` **function ([number][202]): any** The callback function to execute when changes occur.

Returns **function (): void** A function to unsubscribe from the observation.

## queryHash

Generates a hash for a query based on its terms.

### Parameters

*   `world` **World** The world object.
*   `terms` **[Array][205]<[QueryTerm][117]>** The query terms.

Returns **[string][211]** The generated hash.

## registerQuery

Registers a new query in the world using unified clause-mask compilation.

### Parameters

*   `world` **World** The world object.
*   `terms` **[Array][205]<[QueryTerm][117]>** The query terms.
*   `options` **[Object][207]?** Additional options.

    *   `options.buffered` **[boolean][206]?** Whether the query should be buffered.

Returns **[Query][108]** The registered query.

## queryInternal

Internal implementation for nested queries.

### Parameters

*   `world` **World** The world object.
*   `terms` **[Array][205]<[QueryTerm][117]>** The query terms.
*   `options` **[Object][207]?** Additional options.

    *   `options.buffered` **[boolean][206]?** Whether the query should be buffered.

Returns **[QueryResult][105]** The result of the query.

## query

Performs a unified query operation with configurable options.

### Parameters

*   `world` **World** The world object.
*   `terms` **[Array][205]<[QueryTerm][117]>** The query terms.
*   `modifiers` **...[QueryModifier][124]** Query modifiers (asBuffer, isNested, etc.).

Returns **[QueryResult][105]** The result of the query.

## queryCheckEntity

Original blazing-fast query evaluation using simple bitmasks.

### Parameters

*   `world` **World** The world object.
*   `query` **[Query][108]** The query to check against.
*   `eid` **[number][202]** The entity ID to check.

Returns **[boolean][206]** True if the entity matches the query, false otherwise.

## queryCheckComponent

Checks if a component matches a query.

### Parameters

*   `query` **[Query][108]** The query to check against.
*   `c` **[ComponentData][2]** The component data to check.

Returns **[boolean][206]** True if the component matches the query, false otherwise.

## queryAddEntity

Adds an entity to a query.

### Parameters

*   `query` **[Query][108]** The query to add the entity to.
*   `eid` **[number][202]** The entity ID to add.

## queryCommitRemovals

Commits removals for a query.

### Parameters

*   `query` **[Query][108]** The query to commit removals for.

## commitRemovals

Commits all pending removals for queries in the world.

### Parameters

*   `world` **World** The world object.

## queryRemoveEntity

Removes an entity from a query.

### Parameters

*   `world` **World** The world object.
*   `query` **[Query][108]** The query to remove the entity from.
*   `eid` **[number][202]** The entity ID to remove.

## removeQuery

Removes a query from the world.

### Parameters

*   `world` **World** The world object.
*   `terms` **[Array][205]<[QueryTerm][117]>** The query terms of the query to remove.

## OnTargetRemovedCallback

Callback function type for when a target is removed from a relation.

Type: [Function][208]

### Parameters

*   `subject` **[number][202]** The subject entity ID.
*   `target` **[number][202]** The target entity ID.

## RelationTarget

Possible types for a relation target.

Type: ([number][202] | `"*"` | any)

## $relation

Symbol for accessing the relation of a component.

Type: [Symbol][210]

## $pairTarget

Symbol for accessing the pair target of a component.

Type: [Symbol][210]

## $isPairComponent

Symbol for checking if a component is a pair component.

Type: [Symbol][210]

## $relationData

Symbol for accessing the relation data of a component.

Type: [Symbol][210]

## RelationData

Interface for relation data.

## Relation

Type definition for a Relation function.

Type: [function][208]

### Parameters

*   `target` **[RelationTarget][154]** The target of the relation.

Returns **T** The relation component.

## createBaseRelation

Creates a base relation.

Returns **[Relation][155]\<T>** The created base relation.

## withStore

Adds a store to a relation.

### Parameters

*   `createStore` **function (): T** Function to create the store.

Returns **function ([Relation][155]\<T>): [Relation][155]\<T>** A function that modifies the relation.

## makeExclusive

Makes a relation exclusive.

### Parameters

*   `relation` **[Relation][155]\<T>** The relation to make exclusive.

Returns **[Relation][155]\<T>** The modified relation.

## withAutoRemoveSubject

Adds auto-remove subject behavior to a relation.

### Parameters

*   `relation` **[Relation][155]\<T>** The relation to modify.

Returns **[Relation][155]\<T>** The modified relation.

## withOnTargetRemoved

Adds an onTargetRemoved callback to a relation.

### Parameters

*   `onRemove` **[OnTargetRemovedCallback][152]** The callback to add.

Returns **function ([Relation][155]\<T>): [Relation][155]\<T>** A function that modifies the relation.

## withValidation

Adds validation to a relation.

### Parameters

*   `validateFn` **function (T): [boolean][206]** The validation function.

Returns **function ([Relation][155]\<T>): [Relation][155]\<T>** A function that modifies the relation.

## Pair

Creates a pair from a relation and a target.

### Parameters

*   `relation` **[Relation][155]\<T>** The relation.
*   `target` **[RelationTarget][154]** The target.

<!---->

*   Throws **[Error][204]** If the relation is undefined.

Returns **T** The created pair.

## getRelationTargets

Gets the relation targets for an entity.

### Parameters

*   `world` **World** The world object.
*   `eid` **[number][202]** The entity ID.
*   `relation` **[Relation][155]\<any>** The relation to get targets for.

Returns **[Array][205]\<any>** An array of relation targets.

## createRelation

Creates a new relation.

### Parameters

*   `modifiers` **...[Array][205]\<function ([Relation][155]\<T>): [Relation][155]\<T>>** Modifier functions for the relation.

Returns **[Relation][155]\<T>** The created relation.

## createRelation

Creates a new relation with options.

### Parameters

*   `options` **[Object][207]** Options for creating the relation.

    *   `options.store` **function (): T?** Function to create the store.
    *   `options.exclusive` **[boolean][206]?** Whether the relation is exclusive.
    *   `options.autoRemoveSubject` **[boolean][206]?** Whether to auto-remove the subject.
    *   `options.onTargetRemoved` **[OnTargetRemovedCallback][152]?** Callback for when a target is removed.

Returns **[Relation][155]\<T>** The created relation.

## $wildcard

Symbol used to mark a relation as a wildcard relation

## createWildcardRelation

Creates a wildcard relation that matches any target.

Returns **[Relation][155]\<T>** The created wildcard relation.

## getWildcard

Gets the singleton wildcard instance.

Returns **[Relation][155]\<any>** The global wildcard relation instance.

## Wildcard

Wildcard relation.

Type: [Relation][155]\<any>

## createIsARelation

Creates an IsA relation.

Returns **[Relation][155]\<T>** The created IsA relation.

## getIsA

Gets the singleton IsA instance.

Returns **[Relation][155]\<any>** The global IsA relation instance.

## IsA

IsA relation.

Type: [Relation][155]\<any>

## isWildcard

Checks if a relation is a wildcard relation.

### Parameters

*   `relation` **any** The relation to check.

Returns **[boolean][206]** True if the relation is a wildcard relation, false otherwise.

## isRelation

Checks if a component is a relation.

### Parameters

*   `component` **any** The component to check.

Returns **[boolean][206]** True if the component is a relation, false otherwise.

## createWorld

Creates a new world with various configurations.

### Parameters

*   `args` **...[Array][205]<([EntityIndex][38] | [object][207])>** EntityIndex, context object, or both.

Returns **World\<T>** The created world.

## resetWorld

Resets a world.

### Parameters

*   `world` **World**&#x20;

Returns **[object][207]**&#x20;

## deleteWorld

Deletes a world by removing its internal data.

### Parameters

*   `world` **World** The world to be deleted.

## getWorldComponents

Returns all components registered to a world

### Parameters

*   `world` **World**&#x20;

Returns **any** Array

## getAllEntities

Returns all existing entities in a world

### Parameters

*   `world` **World**&#x20;

Returns **any** Array

[1]: #componentref

[2]: #componentdata

[3]: #properties

[4]: #registercomponent

[5]: #parameters

[6]: #registercomponents

[7]: #parameters-1

[8]: #hascomponent

[9]: #parameters-2

[10]: #getcomponent

[11]: #parameters-3

[12]: #set

[13]: #parameters-4

[14]: #recursivelyinherit

[15]: #parameters-5

[16]: #componentsetter

[17]: #properties-1

[18]: #setcomponent

[19]: #parameters-6

[20]: #addcomponent

[21]: #parameters-7

[22]: #addcomponents

[23]: #parameters-8

[24]: #removecomponent

[25]: #parameters-9

[26]: #removecomponents

[27]: #parameters-10

[28]: #addprefab

[29]: #parameters-11

[30]: #addentity

[31]: #parameters-12

[32]: #removeentity

[33]: #parameters-13

[34]: #getentitycomponents

[35]: #parameters-14

[36]: #entityexists

[37]: #parameters-15

[38]: #entityindex

[39]: #properties-2

[40]: #alivecount

[41]: #dense

[42]: #sparse

[43]: #maxid

[44]: #versioning

[45]: #versionbits

[46]: #entitymask

[47]: #versionshift

[48]: #versionmask

[49]: #getid

[50]: #parameters-16

[51]: #getversion

[52]: #parameters-17

[53]: #incrementversion

[54]: #parameters-18

[55]: #withversioning

[56]: #parameters-19

[57]: #createentityindex

[58]: #parameters-20

[59]: #addentityid

[60]: #parameters-21

[61]: #removeentityid

[62]: #parameters-22

[63]: #isentityidalive

[64]: #parameters-23

[65]: #growdepthsarray

[66]: #parameters-24

[67]: #updatedepthcache

[68]: #parameters-25

[69]: #updatemaxdepth

[70]: #parameters-26

[71]: #setentitydepth

[72]: #parameters-27

[73]: #invalidatequerycache

[74]: #parameters-28

[75]: #gethierarchydata

[76]: #parameters-29

[77]: #populateexistingdepths

[78]: #parameters-30

[79]: #ensuredepthtracking

[80]: #parameters-31

[81]: #calculateentitydepth

[82]: #parameters-32

[83]: #getentitydepthwithvisited

[84]: #parameters-33

[85]: #getentitydepth

[86]: #parameters-34

[87]: #markchildrendirty

[88]: #parameters-35

[89]: #updatehierarchydepth

[90]: #parameters-36

[91]: #invalidatehierarchydepth

[92]: #parameters-37

[93]: #invalidatesubtree

[94]: #parameters-38

[95]: #flushdirtydepths

[96]: #parameters-39

[97]: #queryhierarchy

[98]: #parameters-40

[99]: #queryhierarchydepth

[100]: #parameters-41

[101]: #gethierarchydepth

[102]: #parameters-42

[103]: #getmaxhierarchydepth

[104]: #parameters-43

[105]: #queryresult

[106]: #queryoptions

[107]: #properties-3

[108]: #query

[109]: #properties-4

[110]: #queryoperatortype

[111]: #optype

[112]: #opterms

[113]: #opreturntype

[114]: #properties-5

[115]: #queryoperator

[116]: #parameters-44

[117]: #queryterm

[118]: #hierarchyterm

[119]: #properties-6

[120]: #hierarchy

[121]: #parameters-45

[122]: #cascade

[123]: #parameters-46

[124]: #querymodifier

[125]: #properties-7

[126]: #observablehook

[127]: #parameters-47

[128]: #observe

[129]: #parameters-48

[130]: #queryhash

[131]: #parameters-49

[132]: #registerquery

[133]: #parameters-50

[134]: #queryinternal

[135]: #parameters-51

[136]: #query-1

[137]: #parameters-52

[138]: #querycheckentity

[139]: #parameters-53

[140]: #querycheckcomponent

[141]: #parameters-54

[142]: #queryaddentity

[143]: #parameters-55

[144]: #querycommitremovals

[145]: #parameters-56

[146]: #commitremovals

[147]: #parameters-57

[148]: #queryremoveentity

[149]: #parameters-58

[150]: #removequery

[151]: #parameters-59

[152]: #ontargetremovedcallback

[153]: #parameters-60

[154]: #relationtarget

[155]: #relation

[156]: #pairtarget

[157]: #ispaircomponent

[158]: #relationdata

[159]: #relationdata-1

[160]: #relation-1

[161]: #parameters-61

[162]: #createbaserelation

[163]: #withstore

[164]: #parameters-62

[165]: #makeexclusive

[166]: #parameters-63

[167]: #withautoremovesubject

[168]: #parameters-64

[169]: #withontargetremoved

[170]: #parameters-65

[171]: #withvalidation

[172]: #parameters-66

[173]: #pair

[174]: #parameters-67

[175]: #getrelationtargets

[176]: #parameters-68

[177]: #createrelation

[178]: #parameters-69

[179]: #createrelation-1

[180]: #parameters-70

[181]: #wildcard

[182]: #createwildcardrelation

[183]: #getwildcard

[184]: #wildcard-1

[185]: #createisarelation

[186]: #getisa

[187]: #isa

[188]: #iswildcard

[189]: #parameters-71

[190]: #isrelation

[191]: #parameters-72

[192]: #createworld

[193]: #parameters-73

[194]: #resetworld

[195]: #parameters-74

[196]: #deleteworld

[197]: #parameters-75

[198]: #getworldcomponents

[199]: #parameters-76

[200]: #getallentities

[201]: #parameters-77

[202]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number

[203]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set

[204]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error

[205]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array

[206]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean

[207]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object

[208]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function

[209]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array

[210]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol

[211]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
