import { r as Immutable } from "./types-Bbmnq4ni.cjs"; //#region src/pipelines/pipeline-context.d.ts /** * Base interface for all pipeline context objects. * Provides hooks for runtime state and control flow during pipeline execution. */ interface IPipelineContext { /** * The runtime state and control interface for the pipeline. * Allows middleware to query and influence pipeline behavior. */ readonly runtime?: PipelineRuntime; } /** * Runtime state and control interface for pipeline execution. * Allows middleware to query status and influence pipeline flow. */ type PipelineRuntime = { /** * Flag to request pipeline halt. * Set to true to stop executing remaining middleware (cleanup still runs). */ shouldStop?: boolean; /** * Optional error state if an exception occurred during execution. */ error?: any; }; //#endregion //#region src/pipelines/middleware.d.ts /** * The basic unit of work in a pipeline. * Middleware are chained together to form processing pipelines. * Each middleware can inspect/modify context during dispatch and perform cleanup on their changes. * * @template TContext The context type passed through the middleware chain. */ interface IMiddleware { /** * Optional name for debugging and logging purposes. */ readonly name?: string; /** * Optional guard condition before running the action. * Allows middleware to skip execution based on context state. * @param context The current pipeline context. * @returns True to execute action, false to skip. */ shouldRun?(context: TContext): boolean; /** * The main unit of work executed as part of the pipeline. * Middlewares execute in registration order during dispatch phase. * Can read and modify the context to influence downstream middleware and results. * @param context The pipeline context containing all relevant state. */ action(context: TContext): void | Promise; /** * Optional cleanup function executed during pipeline teardown. * Middlewares execute in reverse registration order during cleanup phase. * Used to release resources, clear temporary state, and perform final operations. * @param context The pipeline context (may be in modified state from action phases). */ cleanup?(context: TContext): void | Promise; } //#endregion //#region src/pipelines/middleware-runner.d.ts /** * Customizes how middleware is executed within a pipeline. * Allows decorators to wrap, intercept, or modify middleware execution behavior. * Useful for implementing middleware decorators (logging, timing, error handling, etc.). * * @template TContext The type of context passed to middleware. */ interface IMiddlewareRunner { /** * Decides how to execute a middleware's action. * Can add pre/post processing, error handling, or performance tracking around the middleware. * @param context The current pipeline context. * @param middleware The middleware whose action should be executed. */ dispatch(context: TContext, middleware: IMiddleware): void | Promise; /** * Decides how to execute a middleware's cleanup. * Can add pre/post processing or error handling around cleanup operations. * @param context The current pipeline context. * @param middleware The middleware whose cleanup should be executed. */ cleanup(context: TContext, middleware: IMiddleware): void | Promise; } //#endregion //#region src/pipelines/pipeline.d.ts /** * A composable middleware chain for ordered execution of operations. * Pipelines provide a framework for registering and executing middleware with dispatch and cleanup phases. * Used throughout the ECS system for entity initialization, updates, rendering, and synchronization. * * @template TContext - The context type passed to all registered middleware. */ interface IPipeline { /** * The pipeline's name, useful for debugging and logging. */ readonly name?: string; /** * The number of middleware currently registered in this pipeline. */ readonly length?: number; /** * Direct access to the ordered list of registered middleware. * Allows inspection of the execution chain. */ readonly middleware?: Immutable[]>; /** * Registers middleware to be executed as part of this pipeline. * Middleware is added to the end of the chain and executed in registration order during dispatch. * @param middleware - The middleware to register. * @returns This instance for method chaining. */ use(middleware: Immutable>): this; /** * Executes the dispatch phase with all registered middleware in order. * Each middleware's action is called, allowing modifications to context state. * Execution continues until all middleware complete or a middleware requests early termination. * @param context - The context object passed to all middleware. */ dispatch(context: Partial): void | Promise; /** * Executes the cleanup phase with all registered middleware in reverse order. * Allows middleware to perform resource cleanup and final operations. * Typically called after dispatch to ensure proper teardown. * * @param context - The context object that will be passed to each middleware function. */ cleanup(context: Partial): void | Promise; } //#endregion //#region src/pipelines/pipeline-nested.d.ts /** * Context for a parent pipeline containing nested pipelines. * Allows coordination between outer and inner pipeline execution. * * @template N - The context type for the nested pipelines. */ interface IParentContext extends IPipelineContext { /** * The nested pipeline to execute for each context in nestedContexts. */ readonly nestedPipeline: IPipeline>; /** * Contexts to pass to the nested pipeline. * The parent pipeline iterates these and executes the nested pipeline for each. */ readonly nestedContexts: Partial[]; } /** * Context for a nested pipeline. * Provides access to both current and previous nested context data plus the parent context. * * @template P - The context type of the parent pipeline. */ interface INestedContext

> extends IPipelineContext { /** * The current context item being processed in the nested pipeline. */ readonly current: P extends IParentContext ? N : never; /** * The previous context item (if this is not the first iteration). */ readonly previous?: P extends IParentContext ? N : never; /** * Reference back to the parent pipeline context. */ readonly parent: P; } /** * Middleware executing within a nested pipeline. * * @template P - The context type of the parent pipeline. */ type INestedMiddleware

> = IMiddleware>; /** * Middleware executing within a parent pipeline (containing nested pipelines). * * @template P - The context type of the parent pipeline. */ type IParentMiddleware

> = IMiddleware

; //#endregion //#region src/pipelines/pipeline-runner.d.ts /** * Executes an array of middleware in a controlled sequence. * Supports custom execution strategies through implementation flexibility. * Used by pipelines to manage complex middleware chains with features like early termination and nested pipelines. * * @template TContext - The context type passed to all middleware. */ interface IPipelineRunner { /** * Executes the action phase of all middleware in sequence. * Middleware at startIndex and onward are executed in order. * Execution may terminate early if middleware requests it via context.runtime.shouldStop. * @param context - The context passed to each middleware action. * @param middleware - The ordered middleware array to execute. * @param startIndex - Optional starting position in the middleware array (default: 0). */ dispatch(context: Partial, middleware: IMiddleware[], startIndex?: number): void | Promise; /** * Executes the cleanup phase of all middleware in reverse order. * All middleware cleanup functions are called (if defined), regardless of errors. * Allows proper resource release and final state management. * @param context - The context passed to each middleware cleanup. * @param middleware - The ordered middleware array for cleanup (reversed during execution). */ cleanup(context: Partial, middleware: IMiddleware[]): void | Promise; } //#endregion export { IParentMiddleware as a, IMiddleware as c, IParentContext as i, IPipelineContext as l, INestedContext as n, IPipeline as o, INestedMiddleware as r, IMiddlewareRunner as s, IPipelineRunner as t, PipelineRuntime as u }; //# sourceMappingURL=index-DMTkNY1e.d.cts.map