UNPKG

@imgly/plugin-ai-video-generation-web

Version:

AI video generation plugin for the CE.SDK editor

110 lines (109 loc) 3.43 kB
import { type OpenAPIV3 } from 'openapi-types'; import type CreativeEditorSDK from '@cesdk/cesdk-js'; import type { CreativeEngine } from '@cesdk/cesdk-js'; import { VideoOutput, RenderCustomProperty, GetBlockInput, Provider, Middleware } from '@imgly/plugin-ai-generation-web'; import { VideoQuickActionSupportMap } from '../types'; /** * Configuration for Runware video providers. */ type VideoProviderConfiguration = { /** * HTTP endpoint URL for the Runware proxy. The proxy handles API key injection. */ proxyUrl: string; /** * Enable debug logging for provider creation and API calls. */ debug?: boolean; /** * Middleware functions to process inputs/outputs. */ middlewares?: Middleware<any, any>[]; /** * @deprecated Use `middlewares` instead. */ middleware?: Middleware<any, any>[]; /** * Override provider's default history asset source. */ history?: false | '@imgly/local' | '@imgly/indexedDB' | (string & {}); /** * Configure supported quick actions. */ supportedQuickActions?: { [quickActionId: string]: Partial<VideoQuickActionSupportMap<any>[string]> | false | null; }; }; /** * Options for creating a Runware video provider. */ interface CreateProviderOptions<I extends Record<string, any>> { /** * Runware model identifier (AIR format, e.g., 'openai:sora-2@1'). */ modelId: string; /** * Unique provider identifier for registration. */ providerId: string; /** * Human-readable provider name displayed in the UI. */ name: string; /** * OpenAPI schema document describing the input parameters. */ schema: OpenAPIV3.Document; /** * JSON reference to the input schema (e.g., '#/components/schemas/Input'). */ inputReference: string; /** * User flow mode for the provider panel. */ useFlow?: 'placeholder' | 'generation-only'; /** * Initialization callback when the provider is registered. */ initialize?: (context: { cesdk?: CreativeEditorSDK; engine: CreativeEngine; }) => void; /** * Custom property renderers for the input panel. */ renderCustomProperty?: RenderCustomProperty; /** * Quick actions this provider supports. */ supportedQuickActions?: VideoQuickActionSupportMap<I>; /** * Get block dimensions from input parameters. */ getBlockInput: GetBlockInput<'video', I>; /** * Transform input parameters to Runware API format. */ mapInput: (input: I) => Record<string, any>; /** * Provider-specific middleware functions. */ middleware?: Middleware<I, VideoOutput>[]; /** * Custom headers to include in API requests. */ headers?: Record<string, string>; /** * CE.SDK instance for image URL conversion. */ cesdk?: CreativeEditorSDK; } /** * Creates a Runware video provider from schema. This should work out of the box * but may be rough around the edges and should/can be further customized. */ declare function createVideoProvider<I extends Record<string, any> & { image_url?: string; }>(options: CreateProviderOptions<I>, config: VideoProviderConfiguration): Provider<'video', I, VideoOutput>; export default createVideoProvider; export type { VideoProviderConfiguration as RunwareProviderConfiguration };