{"version":3,"sources":["../src/query.ts","../src/component.ts","../src/aspect.ts","../src/mask.ts"],"sourcesContent":["import { Aspect, HasAspect, WithoutAspect } from './aspect';\nimport { Component, ComponentConstructor } from './component';\nimport { Entity, EntityId } from './entity';\nimport { v4 as uuidv4 } from 'uuid';\nimport { Mask } from './mask';\n\nexport type QueryId = string;\n\ntype ChangeSet = {\n    added: Array<Entity>;\n    removed: Array<Entity>;\n};\n\nexport class Query {\n    public id: QueryId;\n\n    private _aspects: Aspect[] = [];\n\n    private declare _includeMask: Mask;\n    private declare _excludeMask: Mask;\n\n    /**\n     * Flat array of entities matched by this query. Deletions tombstone the\n     * slot (set to null) and `compact` repacks during flushQuery, so iteration\n     * order is stable insertion order and the array tolerates concurrent\n     * removals (e.g. an entity destroying itself mid-forEach).\n     */\n    private _entityList: Array<Entity | null> = [];\n    private _entityListIndex: Map<EntityId, number> = new Map();\n    private _holes = 0;\n\n    /**\n     * If non-null, parallel arrays of component instances kept in sync with\n     * _entityList so forEachWith can hand component refs to the callback\n     * without an entity.get() per iteration. _boundComponentArrays[k][i] is\n     * the instance of _boundComponents[k] on _entityList[i] (null when the\n     * slot is tombstoned).\n     */\n    private _boundComponents: ComponentConstructor[] | null = null;\n    private _boundComponentArrays: Array<Array<Component | null>> | null =\n        null;\n\n    /**\n     * Used by World.refreshQueriesForEntity to dedupe per-entity work without\n     * allocating a Set on every entity build. World stamps a fresh tick into\n     * this field; queries skip themselves when stamped.\n     */\n    public _visitedTick = -1;\n\n    private currentChangeSet: 0 | 1 = 0;\n    private changeSets: [ChangeSet, ChangeSet] = [\n        {\n            added: [],\n            removed: []\n        },\n        {\n            added: [],\n            removed: []\n        }\n    ];\n\n    constructor(aspects: Aspect[]) {\n        this._aspects = aspects;\n        this.initializeMasks();\n        this.id = uuidv4();\n    }\n\n    get nextChangeSetIndex(): 0 | 1 {\n        // 0 becomes 1, 1 becomes 0\n        return ((this.currentChangeSet + 1) % 2) as 0 | 1;\n    }\n\n    get added() {\n        return this.changeSets[this.currentChangeSet].added;\n    }\n\n    get removed() {\n        return this.changeSets[this.currentChangeSet].removed;\n    }\n\n    get nextAdded() {\n        return this.changeSets[this.nextChangeSetIndex].added;\n    }\n\n    get nextRemoved() {\n        return this.changeSets[this.nextChangeSetIndex].removed;\n    }\n\n    get current() {\n        if (this._holes === 0) return this._entityList.slice() as Entity[];\n        const out: Entity[] = [];\n        for (const e of this._entityList) if (e !== null) out.push(e);\n        return out;\n    }\n\n    get aspects() {\n        return this._aspects;\n    }\n\n    get includeMask(): Mask {\n        return this._includeMask;\n    }\n\n    get excludeMask(): Mask {\n        return this._excludeMask;\n    }\n\n    /**\n     * Snapshot of currently-matched entities as a Map. Built on demand from\n     * the internal flat list — held only for backward compat with consumers\n     * that want Map iteration; prefer `current` (Array) or `forEach` for hot\n     * paths.\n     */\n    get entities(): Map<EntityId, Entity> {\n        const map = new Map<EntityId, Entity>();\n        const list = this._entityList;\n        for (let i = 0; i < list.length; i++) {\n            const e = list[i];\n            if (e !== null) map.set(e.id, e);\n        }\n        return map;\n    }\n\n    initializeMasks(): void {\n        this._includeMask = new Mask();\n\n        this._excludeMask = new Mask();\n        this._excludeMask.flipAllToOne();\n\n        this.aspects.forEach((aspect) => {\n            switch (aspect.constructor) {\n                case HasAspect: {\n                    this._includeMask.flipOn(aspect.bitFlag);\n                    this._includeMask.enable();\n                    break;\n                }\n                case WithoutAspect: {\n                    this._excludeMask.flipOff(aspect.bitFlag);\n                    this._excludeMask.enable();\n                    break;\n                }\n            }\n        });\n\n        if (this._includeMask.empty) {\n            this._includeMask.flipAllToOne();\n        }\n    }\n\n    /**\n     * True for queries built only from Without aspects (no Has). The world\n     * needs to route entity changes to these queries via a separate path,\n     * because they don't appear in queryRegistry under any component.\n     */\n    get hasOnlyExclusiveAspects(): boolean {\n        return !this._includeMask.enabled && this._excludeMask.enabled;\n    }\n\n    checkIncludeMask = (entity: Entity): boolean =>\n        !this._includeMask.enabled ||\n        this._includeMask.fulfilledBy(entity.componentMask);\n\n    checkExcludeMask = (entity: Entity): boolean =>\n        !this._excludeMask.enabled ||\n        this._excludeMask.fulfills(entity.componentMask);\n\n    /**\n     * Check whether an entity is currently being tracked by this query\n     * @param entity Entity to check\n     * @returns whether the entity is in the query's entity list\n     */\n    hasEntity(entity: Entity): boolean {\n        return this._entityListIndex.has(entity.id);\n    }\n\n    /**\n     * Adds an entity to this query's entity track list\n     * @param entity Entity to add\n     */\n    registerEntity(entity: Entity): void {\n        this.nextAdded.push(entity);\n\n        if (!this.hasEntity(entity)) {\n            this._entityListIndex.set(entity.id, this._entityList.length);\n            this._entityList.push(entity);\n            if (this._boundComponentArrays !== null) {\n                const ctors = this._boundComponents!;\n                for (let k = 0; k < ctors.length; k++) {\n                    this._boundComponentArrays[k].push(\n                        entity.getComponent(ctors[k]) ?? null\n                    );\n                }\n            }\n            entity.registerQuery(this);\n        }\n    }\n\n    /**\n     * Remove an entity from this query's entity track list\n     * @param entity Entity to remove\n     */\n    unregisterEntity(entity: Entity): void {\n        this.nextRemoved.push(entity);\n        const idx = this._entityListIndex.get(entity.id);\n        if (idx !== undefined) {\n            this._entityList[idx] = null;\n            if (this._boundComponentArrays !== null) {\n                for (const arr of this._boundComponentArrays) {\n                    arr[idx] = null;\n                }\n            }\n            this._entityListIndex.delete(entity.id);\n            this._holes++;\n        }\n        entity.unregisterQuery(this);\n    }\n\n    shouldRegisterEntity(entity: Entity) {\n        const doesInclude = this.checkIncludeMask(entity);\n        const doesntExclude = this.checkExcludeMask(entity);\n        return doesInclude && doesntExclude;\n    }\n\n    updateRegistry = (entity: Entity) => {\n        const registerThisEntity = this.shouldRegisterEntity(entity);\n\n        if (this.hasEntity(entity) && !registerThisEntity) {\n            this.unregisterEntity(entity);\n        } else if (registerThisEntity) {\n            this.registerEntity(entity);\n        }\n    };\n\n    /**\n     * Iterate the entities currently matching this query. Re-reads list length\n     * each iteration so entities registered mid-forEach are visited (matching\n     * Map.forEach semantics); tombstoned slots from concurrent removals are\n     * skipped.\n     */\n    forEach(callbackfn: (entity: Entity) => void) {\n        const list = this._entityList;\n        for (let i = 0; i < list.length; i++) {\n            const e = list[i];\n            if (e !== null) callbackfn(e);\n        }\n    }\n\n    /**\n     * Repack _entityList (and any bound component arrays) in place so\n     * tombstoned slots don't accumulate. Called from flushQuery — at most once\n     * per world tick — keeping per-iteration null-check overhead bounded.\n     */\n    private compact() {\n        const list = this._entityList;\n        const bound = this._boundComponentArrays;\n        let write = 0;\n        for (let read = 0; read < list.length; read++) {\n            const e = list[read];\n            if (e === null) continue;\n            if (write !== read) {\n                list[write] = e;\n                this._entityListIndex.set(e.id, write);\n                if (bound !== null) {\n                    for (const arr of bound) arr[write] = arr[read];\n                }\n            }\n            write++;\n        }\n        list.length = write;\n        if (bound !== null) for (const arr of bound) arr.length = write;\n        this._holes = 0;\n    }\n\n    /**\n     * Bind a fixed list of components to this query so forEachWith can deliver\n     * them directly to the callback. Call once before the query starts being\n     * used; subsequent calls throw. Components don't have to overlap with the\n     * query's aspects — but the entities must actually have them, otherwise\n     * the callback receives null in that slot.\n     */\n    bindComponents(components: ComponentConstructor[]): this {\n        if (this._boundComponents !== null) {\n            throw new Error('Query already has bound components.');\n        }\n        this._boundComponents = components.slice();\n        this._boundComponentArrays = components.map(() => []);\n        // Backfill any entities already registered.\n        const list = this._entityList;\n        for (let i = 0; i < list.length; i++) {\n            const e = list[i];\n            for (let k = 0; k < components.length; k++) {\n                this._boundComponentArrays[k].push(\n                    e === null ? null : (e.getComponent(components[k]) ?? null)\n                );\n            }\n        }\n        return this;\n    }\n\n    /**\n     * Iterate, handing each entity its bound component instances directly —\n     * no entity.get() per element. Specialized fast paths for 1/2/3\n     * components cover the typical system-loop shapes; longer tuples fall\n     * through to a generic loop.\n     */\n    forEachWith(\n        // eslint-disable-next-line @typescript-eslint/no-explicit-any\n        callback: (entity: Entity, ...components: any[]) => void\n    ): void {\n        const list = this._entityList;\n        const bound = this._boundComponentArrays;\n        if (bound === null) {\n            throw new Error(\n                'forEachWith called before bindComponents — bind components first.'\n            );\n        }\n        switch (bound.length) {\n            case 1: {\n                const a0 = bound[0];\n                for (let i = 0; i < list.length; i++) {\n                    const e = list[i];\n                    if (e !== null) callback(e, a0[i]);\n                }\n                return;\n            }\n            case 2: {\n                const a0 = bound[0];\n                const a1 = bound[1];\n                for (let i = 0; i < list.length; i++) {\n                    const e = list[i];\n                    if (e !== null) callback(e, a0[i], a1[i]);\n                }\n                return;\n            }\n            case 3: {\n                const a0 = bound[0];\n                const a1 = bound[1];\n                const a2 = bound[2];\n                for (let i = 0; i < list.length; i++) {\n                    const e = list[i];\n                    if (e !== null) callback(e, a0[i], a1[i], a2[i]);\n                }\n                return;\n            }\n            default: {\n                for (let i = 0; i < list.length; i++) {\n                    const e = list[i];\n                    if (e === null) continue;\n                    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n                    const comps: any[] = new Array(bound.length);\n                    for (let k = 0; k < bound.length; k++) {\n                        comps[k] = bound[k][i];\n                    }\n                    callback(e, ...comps);\n                }\n            }\n        }\n    }\n\n    flushQuery = () => {\n        this.currentChangeSet = this.nextChangeSetIndex;\n        this.nextAdded.length = 0;\n        this.nextRemoved.length = 0;\n        if (this._holes > 0) this.compact();\n    };\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Entity } from './entity';\nimport { pendingFields, pendingInitializers } from './decorators';\n\nexport type ComponentId = number;\nexport type ComponentName = string;\nexport type ComponentField = {\n    fieldName: string;\n    defaultValue?: unknown;\n};\n\n/**\n * Component that can be attached to entities.\n */\nexport abstract class Component {\n    /**\n     * Bitflag id assigned to a component class at registration time.\n     * Keyed by the class reference itself, not by class name, so the ECS\n     * survives identifier mangling by minifiers and obfuscators.\n     */\n    static ComponentIdMap: Map<ComponentConstructor, ComponentId> = new Map();\n\n    static ComponentFieldMap: Map<\n        ComponentConstructor,\n        Map<string, ComponentField>\n    > = new Map();\n\n    static ComponentFieldInitializeMap: Map<\n        ComponentConstructor,\n        Map<string, Array<string>>\n    > = new Map();\n\n    static maxId = 0;\n\n    declare componentId: ComponentId;\n\n    private declare entity: Entity;\n\n    setValues(values: Record<string, any>): void {\n        const ctor = this.constructor as ComponentConstructor;\n        const fields = Component.ComponentFieldMap.get(ctor);\n        const initializers = Component.ComponentFieldInitializeMap.get(ctor);\n\n        if (!fields) {\n            return;\n        }\n\n        fields.forEach(({ fieldName }) => {\n            if (typeof values[fieldName] === 'undefined') {\n                throw new Error(\n                    `Value not provided for ${fieldName} on component ${this.constructor.name}.`\n                );\n            } else {\n                (this as any)[fieldName] = values[fieldName];\n\n                if (initializers && initializers.has(fieldName)) {\n                    initializers.get(fieldName)?.forEach((otherField) => {\n                        (this as any)[otherField] = values[fieldName];\n                    });\n                }\n            }\n        });\n    }\n    setEntity(entity: Entity): void {\n        this.entity = entity;\n    }\n\n    getEntity(): Entity {\n        if (!this.entity) {\n            throw new Error(\n                \"Component tried to fetch it's entity, but none was found\"\n            );\n        }\n        return this.entity;\n    }\n\n    onComponentRemoved() {\n        // no-op\n    }\n\n    toString(): string {\n        return `${this.constructor.name}`;\n    }\n}\n\ntype NonFunctionPropertyNames<T> = {\n    // eslint-disable-next-line @typescript-eslint/ban-types\n    [K in keyof T]: T[K] extends Function ? never : K;\n}[keyof T];\n\nexport type ComponentArgs<C> = {\n    [Property in Exclude<\n        NonFunctionPropertyNames<C>,\n        keyof Component\n    >]: C[Property];\n};\nexport type ComponentConstructor = { new (...args: any[]): Component };\n\nexport const registerComponentWithSpecificId = <T extends ComponentConstructor>(\n    constructor: T,\n    id: number\n) => {\n    registerComponent(constructor, id);\n};\n\nexport function RegisterComponent<T extends ComponentConstructor>(\n    value: T,\n    _context: ClassDecoratorContext\n): void {\n    Component.maxId++;\n    const newComponentId = Component.maxId;\n    registerComponent(value, newComponentId);\n\n    const fields = pendingFields.splice(0);\n    const fieldMap = Component.ComponentFieldMap.get(value);\n    if (fieldMap) {\n        for (const f of fields) {\n            fieldMap.set(f.fieldName, f);\n        }\n    }\n\n    const initializers = pendingInitializers.splice(0);\n    if (initializers.length > 0) {\n        let initMap = Component.ComponentFieldInitializeMap.get(value);\n        if (!initMap) {\n            initMap = new Map();\n            Component.ComponentFieldInitializeMap.set(value, initMap);\n        }\n        for (const init of initializers) {\n            if (!initMap.has(init.initFrom)) {\n                initMap.set(init.initFrom, []);\n            }\n            initMap.get(init.initFrom)?.push(init.field);\n        }\n    }\n}\n\nconst registerComponent = (\n    constructor: ComponentConstructor,\n    newComponentId: number\n) => {\n    constructor.prototype.componentId = newComponentId;\n    Component.ComponentIdMap.set(constructor, newComponentId);\n\n    if (!Component.ComponentFieldMap.has(constructor)) {\n        Component.ComponentFieldMap.set(constructor, new Map());\n    }\n};\n","import { Component, ComponentConstructor } from './component';\n\nexport class Aspect {\n    public bitFlag: number;\n    public component: ComponentConstructor;\n\n    constructor(component: { new (...args: never): Component }) {\n        this.component = component as unknown as ComponentConstructor;\n        const id = Component.ComponentIdMap.get(this.component);\n        this.bitFlag = (id ?? 0) - 1;\n    }\n}\n\nexport class HasAspect extends Aspect {}\nexport class WithoutAspect extends Aspect {}\n\nexport const Has = <T extends { new (...args: never): Component }>(\n    component: T\n): Aspect => {\n    return new HasAspect(component);\n};\n\nexport const Without = <T extends { new (...args: never): Component }>(\n    component: T\n): Aspect => {\n    return new WithoutAspect(component);\n};\n","import { Component } from './component';\n\nexport class Mask {\n    private _mask: Uint32Array;\n    private _enabled = false;\n\n    constructor(size = Component.maxId) {\n        // Uint32Array holds 32 bits for every unit of size, so we need the no. of components\n        // divided by 32 to mask all components\n        this._mask = new Uint32Array(Math.ceil(size / 32));\n    }\n\n    enable(): void {\n        this._enabled = true;\n    }\n\n    get enabled(): boolean {\n        return this._enabled;\n    }\n\n    get mask(): Uint32Array {\n        return this._mask;\n    }\n\n    get empty(): boolean {\n        return this._mask.every((m) => m === 0);\n    }\n\n    /**\n     * Checks another mask to see it is fulfilled by the flags in this mask\n     * @param otherMask Uint32Array to be compared with this mask\n     * @returns True if the provided mask is satisfied by this mask\n     */\n    public fulfills = (otherMask: Mask): boolean => {\n        if (otherMask.mask.length !== this._mask.length) {\n            throw new Error('Comparing masks of different sizes not allowed.');\n        }\n        return this._mask.every((m, index) =>\n            this.checkMask(m, otherMask.mask[index])\n        );\n    };\n\n    /**\n     * Checks another mask to see it contains all flags in this mask\n     * @param otherMask Uint32Array to be compared with this mask\n     * @returns True if the provided mask is satisfied by this mask\n     */\n    public fulfilledBy = (otherMask: Mask): boolean => {\n        if (otherMask.mask.length !== this._mask.length) {\n            throw new Error('Comparing masks of different sizes not allowed.');\n        }\n        return this._mask.every((m, index) =>\n            this.checkMask(otherMask.mask[index], m)\n        );\n    };\n\n    /**\n     * @param checkingMask The mask that needs to be met to fulfill the condition\n     * @param requiredMask The other mask that needs to match up with the first mask\n     * @returns Whether the masks match or not\n     */\n    private checkMask = (\n        checkingMask: number,\n        requiredMask: number\n    ): boolean => {\n        return (\n            (checkingMask & requiredMask) >>> 0 === requiredMask ||\n            checkingMask === requiredMask // second condition checking if they're both 0\n        );\n    };\n\n    /**\n     * Flips all bits in the mask to 1\n     */\n    flipAllToOne = () => {\n        this._mask.fill(~0 >>> 0);\n    };\n\n    /**\n     * Flip on a flag in this mask\n     * @param bitPosition The bit flag to flip, typically a componentId.\n     */\n    flipOn = (bitPosition: number) => {\n        this._mask[Math.floor(bitPosition / 32)] |=\n            (1 << bitPosition % 32) >>> 0;\n    };\n\n    /**\n     * Flip off a flag on this mask\n     * @param bitPosition The bit flag to flip, typically a componentId.\n     */\n    flipOff = (bitPosition: number) => {\n        this._mask[Math.floor(bitPosition / 32)] &= ~(\n            (1 << bitPosition % 32) >>>\n            0\n        );\n    };\n\n    toString(): string {\n        const decToBin = (dec: number) => {\n            return (dec >>> 0).toString(2);\n        };\n        let string = '|';\n        for (const mask of this.mask) {\n            const stringMask = decToBin(mask);\n            string += stringMask.padEnd(32, '0');\n            string += '|';\n        }\n        return string;\n    }\n\n    get maskString() {\n        return this.toString();\n    }\n}\n"],"mappings":";;;;;;;;;;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