UNPKG

@imgly/plugin-ai-generation-web

Version:

AI generation plugin for the CE.SDK editor

36 lines (35 loc) 1.68 kB
import { GenerationOptions, GenerationResult, Output } from '../core/provider'; /** * Result of the generation with a dispose function to clean up */ export interface DisposableGenerationResult<O extends Output> { /** * The actual generation result */ result: GenerationResult<O>; /** * Function to dispose/clean up resources created during generation * This should be called when the generation is cancelled or completely * finished including the confirmation of the generation if applicable. */ dispose: () => Promise<void>; } /** * Define the type for middleware functions */ export type Middleware<I, O extends Output> = (input: I, options: GenerationOptions & { /** * The block ids the generation is applied on * If this value is undefined, the selected blocks will be used. * Setting this value to null will explicitly tell every * middleware that no block shall be used. */ blockIds?: number[] | null; /** * Adds a disposer function to this genereation which is called * when the generation is cancelled or completely finished * including the confirmation of the generation if applicable. */ addDisposer: (dispose: () => Promise<void>) => void; }, next: (input: I, options: GenerationOptions) => Promise<GenerationResult<O>>) => Promise<GenerationResult<O>>; export declare function composeMiddlewares<I, O extends Output>(middlewares: (Middleware<I, O> | false | undefined | null)[]): (baseHandler: (input: I, options: GenerationOptions) => Promise<GenerationResult<O>>) => (input: I, options: GenerationOptions) => Promise<DisposableGenerationResult<O>>;