@imgly/plugin-ai-generation-web
Version:
AI generation plugin for the CE.SDK editor
72 lines (71 loc) • 2.99 kB
TypeScript
import CreativeEditorSDK, { AssetResult } from '@cesdk/cesdk-js';
import { GenerationResult, Output } from '../core/provider';
export declare const AI_PANEL_ID_PREFIX = "ly.img.ai";
/**
* Adding asset to the scene.
*
* NOTE: Will use a temporary asset source so that
* our asset source middleware trigger. This is necessary since there is
* a lot of extra logic in the video middlewares regarding trim, position etc.
*
* These will only trigger via an asset source, not by calling
* `defaultApplyAsset` directly.
*/
export declare function addAssetToScene(cesdk: CreativeEditorSDK, assetResult: AssetResult): Promise<number | undefined>;
/**
* Returns a consistent panel ID for a provider ID
*/
export declare function getPanelId(providerId: string): string;
export default getPanelId;
/**
* Extracts a readable error message from an unknown error
*
* @param error The error caught in a try/catch block
* @param fallbackMessage Optional fallback message if error is not an Error object
* @returns A string representation of the error
*/
export declare function extractErrorMessage(error: unknown, fallbackMessage?: string): string;
/**
* Generates a random UUID v4
*/
export declare function uuid4(): string;
/**
* Gets the duration of a video from a URL
* @param url - The URL of the video
* @returns A promise that resolves to the duration of the video in seconds
*/
export declare function getDurationForVideo(url: string): Promise<number>;
/**
* Gets a thumbnail image from a video URL
* @param url - The URL of the video
* @param seekTime - Time in seconds to capture the thumbnail (default: 0)
* @param format - Image format for the thumbnail (default: 'image/jpeg')
* @param quality - Image quality between 0 and 1 (default: 0.8)
* @returns A promise that resolves to the thumbnail data URL
*/
export declare function getThumbnailForVideo(url: string, seekTime?: number, format?: string, quality?: number): Promise<string>;
/**
* Converts an ID string to a human-readable label
* @param id - The ID string to convert
* @returns A human-readable label derived from the ID
*
* Examples:
* - snake_case_id → Snake Case Id
* - kebab-case-id → Kebab Case Id
* - camelCaseId → Camel Case Id
* - PascalCaseId → Pascal Case Id
*/
export declare function getLabelFromId(id: string): string;
/**
* Type guard to check if a value is an AsyncGenerator rather than a Promise
*
* @param value - Value of type Promise<O> | AsyncGenerator<O, C>
* @returns Boolean indicating if the value is an AsyncGenerator
*/
export declare function isAsyncGenerator<O extends Output, C>(value: GenerationResult<O, C>): value is AsyncGenerator<O, C>;
export declare function isAbortError(error: unknown): error is Error;
/**
* Adds an icon set to the CreativeEditorSDK UI only once. Marks
* it as added in the global state to prevent multiple additions.
*/
export declare function addIconSetOnce(cesdk: CreativeEditorSDK, id: string, icons: string): void;