import type { ComponentDef, ComponentId, QueryTerm, Schema } from '@ecsia/schema'; /** One packed membership-bit reference within the fixed-stride signature words. */ export interface Word { readonly wordIndex: number; readonly mask: number; } /** A residual (large pair-ID) term tested by sigHas binary search, not a sigWords AND. */ export interface ResidualTerm { readonly componentId: ComponentId; readonly negate: boolean; } export type ValueRole = 'read' | 'write' | 'optional' | 'pairRead' | 'pairWrite'; /** * An exclusive-relation specific-target term (relations ): the target is a * COLUMN value, not a signature bit, so the archetype is matched by `presenceId(R)` and iteration * filters rows by `targetColumn[row] === target`. Carried on the CompiledQuery; the engine applies it. */ export interface RowFilterTerm { readonly presenceId: ComponentId; /** The full target EntityHandle (encoded eid value stored in the column) to compare each row against. */ readonly targetEid: number; /** Field index of the exclusive `eid` target column within the presence component's ColumnSet. */ readonly targetFieldIndex: number; } /** * The relations-owned resolution of a Pair(...) term to a concrete ComponentId. * Injected by relations into the world's CompileContext (core never imports relations).: a * query must NOT mint — `mintedOnly` resolution returns `unsatisfiable` when the pair never existed. */ export interface ResolvedPair { /** The signature bit to AND-match (presence id for wildcard/exclusive; pair id for tag/overflow). */ readonly componentId: ComponentId; /** True iff the pair id was never minted → the query matches nothing without mutating the id space. */ readonly unsatisfiable: boolean; /** Present for exclusive specific-target pairs: the post-presence row filter. */ readonly rowFilter?: RowFilterTerm; } /** Value terms in declaration order (drives the pooled element + cursor binding). */ export interface CompiledValueTerm { readonly componentId: ComponentId; readonly role: ValueRole; readonly key: string; } export interface CompiledQuery { readonly withWords: readonly Word[]; readonly notWords: readonly Word[]; readonly optionalIds: readonly ComponentId[]; readonly residualWith: readonly ResidualTerm[]; readonly valueTerms: readonly CompiledValueTerm[]; readonly referencedIds: readonly ComponentId[]; /** Exclusive specific-target pair filters: match by presence bit, then filter rows by target. */ readonly rowFilters: readonly RowFilterTerm[]; readonly hash: string; /** True iff a specific-pair term resolved to a never-minted pair id → matches nothing. */ readonly unsatisfiable: boolean; } /** The seam the compiler uses to resolve component (and, later, pair) ids — owned by the world. */ export interface CompileContext { /** ComponentId for a registered ComponentDef, or throws if the def is not in this world. */ idOf(def: ComponentDef): ComponentId; /** Fixed bitmask bit count: ids below this go in the packed words, larger pair ids are residual. */ readonly fixedBitCount: number; /** * Resolve a Pair(R, target | Wildcard) term to a ComponentId. Injected by the * relations module via the world; absent in a relation-free world (every pair term is then * unsatisfiable, the behavior).: this NEVER mints — it only looks up already-minted ids. */ resolvePair?(relationId: number, target: number | symbol): ResolvedPair; /** * The `Prefab` tag's id when the world was created with `prefabs: true`; undefined otherwise. * When set, compilation injects this bit into `notWords` (default prefab exclusion) unless the * query mentions Prefab in any term or passes `{ matchPrefabs: true }`. Zero per-row cost — one * more bit in a mask that is already ANDed. */ readonly prefabId?: ComponentId; } declare const WILDCARD_TAG: unique symbol; export declare function compileQuery(terms: readonly QueryTerm[], ctx: CompileContext): CompiledQuery; export { WILDCARD_TAG }; //# sourceMappingURL=compile.d.ts.map