/** * Composable -- ECS Composition over Existing Primitives * * Universal composition API leveraging existing deterministic primitives. * Zero boilerplate, type-safe, content-addressed entity composition. * * @module */ import type { ContentAddress } from './brands.js'; import type { Token } from './token.js'; import type { Style } from './style.js'; import type { World } from './ecs.js'; import { Boundary } from './boundary.js'; import { Part } from './ecs.js'; import { Effect } from 'effect'; /** * Component map for a {@link ComposableEntity} — well-known slots for czap * primitives plus arbitrary user-defined keys. */ export interface EntityComponents { readonly boundary?: Boundary.Shape; readonly token?: Token.Shape; readonly style?: Style.Shape; readonly [key: string]: unknown; } /** * Content-addressed entity: the identity is an FNV-1a hash over its components, * so two entities with structurally equal components share the same `id`. */ export interface ComposableEntity { readonly id: ContentAddress; readonly components: T; readonly _tag: 'ComposableEntity'; } interface ComposableFactory { make(components: T): ComposableEntity; compose(entity1: ComposableEntity, entity2: ComposableEntity): ComposableEntity; merge(...entities: ComposableEntity[]): ComposableEntity; } interface TypedComposableWorld { spawn(components: T): Effect.Effect>; spawnWith(entity: ComposableEntity): Effect.Effect>; query(...componentTypes: K[]): Effect.Effect>[]>; evaluate(entity: ComposableEntity, input: Record): Effect.Effect>; } declare function makeComposableWorld(world: World.Shape): TypedComposableWorld; interface ComposableDenseStore { create(name: string, capacity: number): Effect.Effect; store(entity: ComposableEntity, value: number): Effect.Effect; retrieve(entity: ComposableEntity): Effect.Effect; } declare function makeComposableDenseStore(world: World.Shape): ComposableDenseStore; /** * Composable — content-addressed entity algebra over czap primitives. * * Build entities from a bag of components (boundaries, tokens, styles, …), * merge them associatively via `Composable.compose` / `Composable.merge`, and * rely on the content address to deduplicate structurally-equal entities. */ export declare const Composable: ComposableFactory; /** * Bridge between a raw ECS {@link World} and typed {@link ComposableEntity} * operations (`spawn`, `query`, `evaluate`) plus a thin dense-store integration. */ export declare const ComposableWorld: { /** Wrap a {@link World} with the typed composable-entity API. */ make: typeof makeComposableWorld; /** Build a dense-store bridge over a {@link World} for per-entity numeric data. */ dense: typeof makeComposableDenseStore; }; export declare namespace ComposableWorld { /** Structural shape of the typed world returned by {@link ComposableWorld.make}. */ type Shape = TypedComposableWorld; } export type { TypedComposableWorld as ComposableWorldShape }; //# sourceMappingURL=composable.d.ts.map