// Generated by dts-bundle-generator v9.5.1 import { AssetAPI, BlockAPI, EditorAPI, Font, FontStyle, FontWeight, SceneAPI, Typeface } from '@cesdk/engine'; type WarningSeverity = "error" | "warning" | "info"; interface WarningDefinition { /** Default + sole severity. Call sites do not override. */ severity: WarningSeverity; /** * Template with `{name}` placeholders. Renderer throws if a placeholder * has no matching key in `params` — guards against silent typos. */ template: string; } interface LogMessage { /** Stable machine-readable identifier — never rename once shipped. */ code: TCode; /** Inherited from the code definition. */ type: WarningSeverity; /** Human-readable rendered string. */ message: string; /** Raw structured fields — superset of all `{name}` placeholders. */ params: Record; } declare class Logger> { private readonly registry; private messages; constructor(registry: R); emit(code: K, params?: Record): void; getMessages(): LogMessage[]; } type AssetQueryAPI = Pick; type AssetEngine = { asset: AssetQueryAPI; }; export interface TypefaceParams { family: string; style?: Font["style"]; weight?: Font["weight"]; } interface FontResolverOptions { /** * When the requested weight is not available in the matched typeface, * pick the closest available weight using the CSS Font Matching algorithm. * Defaults to false — return null instead so the caller can decide what * to do (e.g. log a warning, use a different font). * * Only enable when the typeface name is known to be a good match. The * typeface query uses fuzzy matching, so applying weight fallback to a * poor name match can silently produce wildly wrong results. */ closestWeightMatch?: boolean; } export interface FontResolverResult { typeface: Typeface; font: Font; /** * Set to the originally requested family name when the typeface came from * the proprietary-fallbacks source (e.g. requested "Helvetica", got Roboto). * Undefined when the family matched the main Google Fonts catalog directly. * Always populated when applicable; consumers may ignore it. */ substitutedFrom?: string; } export type TypefaceResolver = (params: TypefaceParams, engine: AssetEngine, options?: FontResolverOptions) => Promise; /** * Register the @imgly/gfonts asset sources (Google Fonts catalog + proprietary * font fallbacks) with the CE.SDK engine. * * Adds two sources: * - `ly.img.gfonts` — 1,394 Google Fonts typefaces (fuzzy-matched). * - `ly.img.gfonts-fallbacks` — 16 proprietary-font alias entries * (e.g. Helvetica → Roboto), strict-matched. */ export declare function addGfontsAssetLibrary(engine: AssetEngine): Promise; /** * The default font resolver for IMG.LY importers. * * Resolves a requested family/style/weight to a concrete Typeface + Font from * the gfonts asset sources registered via `addGfontsAssetLibrary()`. Tries * the proprietary-fallbacks source first (strict match for known aliases like * Helvetica → Roboto), then the full Google Fonts catalog (fuzzy match with * PascalCase decomposition). */ export declare function fontResolver(params: TypefaceParams, engine: AssetEngine, options?: FontResolverOptions): Promise; /** * Map a font weight string or number (e.g. "700", 400, "bold", "Bold") to the * canonical CE.SDK FontWeight value. Returns "normal" when the input is empty * or undefined; returns the input cast to FontWeight when no alias matches. */ export declare function mapFontWeight(weight?: string | number): Font["weight"] | undefined; declare const WARNING_CODES: { readonly DOC_IMPORT_SUCCESS: { readonly severity: "info"; readonly template: "Successfully imported {count} slide(s)"; }; readonly SLIDE_EMPTY: { readonly severity: "info"; readonly template: "Slide has no content"; }; readonly SLIDE_BLANK: { readonly severity: "warning"; readonly template: "Blank slide detected: {slideKey}"; }; readonly SLIDE_ATTACH_FAILED: { readonly severity: "warning"; readonly template: "Could not attach slide to scene"; }; readonly SLIDE_REL_MISMATCH: { readonly severity: "warning"; readonly template: "Resolved {orderedCount} of {totalCount} slide relationships \u2014 some slides may be missing"; }; readonly PAGE_BG_GRADIENT_FAILED: { readonly severity: "warning"; readonly template: "Could not apply slide background gradient"; }; readonly PAGE_BG_IMAGE_FAILED: { readonly severity: "warning"; readonly template: "Could not apply slide background image"; }; readonly PAGE_BG_COLOR_FAILED: { readonly severity: "warning"; readonly template: "Could not apply slide background color"; }; readonly PAGE_SLIDE_EMPTY: { readonly severity: "info"; readonly template: "Slide {slideKey} has no elements"; }; readonly PAGE_UNKNOWN_ELEMENT: { readonly severity: "warning"; readonly template: "Unknown element type '{elementType}' - skipping"; }; readonly PAGE_ELEMENT_CREATE_FAILED: { readonly severity: "warning"; readonly template: "Could not create element on slide: {error}"; }; readonly GROUP_NO_VALID_CHILDREN: { readonly severity: "warning"; readonly template: "Group '{name}' has no valid children - skipping"; }; readonly GROUP_UNKNOWN_ELEMENT: { readonly severity: "warning"; readonly template: "Unknown element type '{elementType}' in group - skipping"; }; readonly GROUP_ELEMENT_CREATE_FAILED: { readonly severity: "warning"; readonly template: "Could not create element in group"; }; readonly THEME_NOT_FOUND: { readonly severity: "warning"; readonly template: "No theme found - using default colors"; }; readonly THEME_COLORS_DEFAULT: { readonly severity: "warning"; readonly template: "No theme colors found - using defaults"; }; readonly THEME_COLOR_SCHEME_MISSING: { readonly severity: "warning"; readonly template: "No color scheme in theme - using default colors"; }; readonly THEME_PARSE_FAILED: { readonly severity: "warning"; readonly template: "Could not parse theme - using default colors"; }; readonly THEME_COLOR_NOT_FOUND: { readonly severity: "warning"; readonly template: "Theme color '{colorName}' not found - using black"; }; readonly THEME_COLOR_INCOMPLETE: { readonly severity: "warning"; readonly template: "Theme missing required color '{colorName}' - using black"; }; readonly COLOR_UNKNOWN_FORMAT: { readonly severity: "warning"; readonly template: "Unknown color format - using black"; }; readonly COLOR_NO_SCHEME: { readonly severity: "warning"; readonly template: "No color scheme found in theme - colors may not match original"; }; readonly COLOR_PARSE_FAILED: { readonly severity: "warning"; readonly template: "Could not parse theme colors - colors may not match original"; }; readonly COLOR_INVALID_VALUE: { readonly severity: "warning"; readonly template: "Invalid color value '{hex}' - using black"; }; readonly FONT_NOT_FOUND: { readonly severity: "warning"; readonly template: "Font '{family}' not found - using Roboto instead, text may look different"; }; readonly FONT_RESOLVE_FAILED: { readonly severity: "warning"; readonly template: "Font '{family}' could not be resolved - using Roboto instead, text may look different"; }; readonly FONT_ROBOTO_MISSING: { readonly severity: "warning"; readonly template: "Roboto fallback font not found in library"; }; readonly TEXT_OVERFLOW_AUTO_CORRECTED: { readonly severity: "info"; readonly template: "Auto-corrected {count} text block(s) with overflow"; }; readonly TEXT_POSITION_CORRECTION_FAILED: { readonly severity: "warning"; readonly template: "Could not apply text positioning correction"; }; readonly TEXT_UNDERLINE_STYLE_UNKNOWN: { readonly severity: "warning"; readonly template: "Underline style '{style}' is not supported. The closest dashed style will be used."; }; readonly TEXT_STRIKE_DOUBLE_FALLBACK: { readonly severity: "warning"; readonly template: "Double strikethrough is not supported. A single strikethrough will be used."; }; readonly TEXT_LIST_LEVEL_CLAMPED: { readonly severity: "warning"; readonly template: "List nesting level {level} exceeds the maximum (4). Using level 4 instead."; }; readonly TEXT_LIST_PARAGRAPH_MISMATCH: { readonly severity: "warning"; readonly template: "List styles for '{name}' could not be applied: paragraph counts disagree (pptx={pptxCount}, scene={sceneCount})."; }; readonly SHAPE_CREATE_FAILED: { readonly severity: "warning"; readonly template: "Could not create shape '{shapeType}' - using rectangle instead"; }; readonly SHAPE_TYPE_UNSUPPORTED: { readonly severity: "warning"; readonly template: "Shape type '{shapeType}' is not supported - using rectangle instead"; }; readonly SHAPE_GEOMETRY_FAILED: { readonly severity: "warning"; readonly template: "Custom shape geometry could not be converted - using rectangle instead"; }; readonly SHAPE_VECTOR_FAILED: { readonly severity: "warning"; readonly template: "Error creating custom vector shape - using rectangle instead"; }; readonly SHAPE_ROUNDED_CORNERS_FAILED: { readonly severity: "warning"; readonly template: "Could not apply rounded corners"; }; readonly IMAGE_FILL_FAILED: { readonly severity: "warning"; readonly template: "Could not apply image fill - shape may appear without background"; }; readonly IMAGE_CROP_INVALID: { readonly severity: "warning"; readonly template: "Invalid crop values - image may not be cropped correctly"; }; readonly IMAGE_CROP_ROTATION_FAILED: { readonly severity: "warning"; readonly template: "Could not apply crop rotation"; }; readonly IMAGE_EXTRACT_FAILED: { readonly severity: "warning"; readonly template: "Could not extract embedded image"; }; readonly SHADOW_INNER_CONVERTED: { readonly severity: "warning"; readonly template: "Inner shadows are not supported - converted to outer shadow, which may look different"; }; readonly SHADOW_APPLY_FAILED: { readonly severity: "warning"; readonly template: "Could not apply shadow effect"; }; readonly GRADIENT_FILL_FAILED: { readonly severity: "warning"; readonly template: "Gradient fill failed - using solid color instead"; }; readonly GRADIENT_PATH_FALLBACK: { readonly severity: "warning"; readonly template: "Gradient type 'path' is not supported - using radial gradient instead, which may look different"; }; readonly GRADIENT_RECT_FALLBACK: { readonly severity: "warning"; readonly template: "Gradient type 'rect' is not supported - using radial gradient instead, which may look different"; }; readonly GRADIENT_TYPE_UNKNOWN: { readonly severity: "warning"; readonly template: "Unknown gradient type '{type}' - using linear gradient"; }; readonly STROKE_STYLE_UNKNOWN: { readonly severity: "warning"; readonly template: "Unknown stroke style '{dashType}' - using solid line"; }; readonly STROKE_CORNER_STYLE_FAILED: { readonly severity: "warning"; readonly template: "Could not set stroke corner style"; }; readonly VECTOR_ARC_APPROX: { readonly severity: "warning"; readonly template: "Arc curves are not fully supported - shape may look different"; }; }; type LogMessage$1 = LogMessage; /** * PPTX importer logger. Wraps the shared `@imgly/importer-exporter-utils` * `Logger` with this package's `WARNING_CODES` registry baked in, so call * sites use `new Logger()` without re-passing the registry. */ type Logger$1 = Logger; declare const Logger$1: new () => Logger$1; type Public = { [K in keyof T]: T[K]; }; export interface CreativeEngine { block: Public; scene: Public; asset: Public; editor: Public; } /** * Parser configuration options */ export interface PPTXParserOptions { /** * Tolerance percentage for numeric property validation in tests * @default 5 */ tolerancePercent?: number; /** * Apply font metrics-based vertical position correction for text blocks. * When enabled, loads font metrics from font URLs and adjusts text Y position * to better match the source baseline positioning. * @default false */ applyFontMetricsCorrection?: boolean; /** * Auto-correct text blocks that overflow their bounds due to kerning differences. * Uses CE.SDK's native `text/hasClippedLines` detection to find overflowing text, * then reduces letter spacing minimally to make text fit. * @default true */ autoCorrectTextOverflow?: boolean; /** * Options for text overflow correction algorithm. * Only applies when autoCorrectTextOverflow is true. */ textOverflowCorrectionOptions?: { /** Letter spacing reduction step size in em units. @default 0.001 */ step?: number; /** Maximum letter spacing reduction steps to try. @default 500 */ maxSteps?: number; }; } /** * Result from parse() operation * Matches PSD importer API pattern */ export interface ParseResult { /** Logger instance with parsing messages and warnings */ logger: any; } /** * PPTX Parser for CE.SDK * * Converts PowerPoint presentations to CE.SDK block structure. * Supports text, graphic, image, and page blocks. * * @example * ```typescript * const engine = await CreativeEngine.create(); * const pptxBuffer = await fetch('presentation.pptx').then(r => r.arrayBuffer()); * * const parser = await PPTXParser.fromFile(engine, pptxBuffer); * const result = await parser.parse(); * * const messages = result.logger.getMessages(); * const warnings = messages.filter(m => m.type === 'warning'); * if (warnings.length > 0) { * console.warn('Unsupported features:', warnings); * } * ``` */ export declare class PPTXParser { private engine; private pptxData; private pptxBuffer; private options; private logger; private themeMap?; private fontResolver; private slideParser; private themeParser; private pageHandler; /** * Private constructor - use PPTXParser.fromFile() to create instances */ private constructor(); /** * Create parser instance from PPTX file buffer * * Loads PPTX using pptx2json library and validates structure. * * @param engine - CE.SDK engine instance * @param fileBuffer - PPTX file as ArrayBuffer * @param options - Parser configuration options * @returns Promise resolving to parser instance * * @throws {Error} If PPTX file invalid or has no slides */ static fromFile(engine: CreativeEngine, fileBuffer: ArrayBuffer, options?: Partial): Promise; /** * Parse PPTX file and create CE.SDK blocks * * Parses all slides in the PPTX file and automatically attaches them to the scene. * Creates page blocks with slide dimensions and all element blocks. * Preserves z-order from PPTX. Logs warnings for unsupported features. * * This method matches the PSD importer API pattern: * - No parameters required * - Returns ParseResult with logger * - Automatically attaches all pages to scene * - Use engine.block.findByType('//ly.img.ubq/page') to retrieve created pages * * @returns Promise that resolves to ParseResult with logger containing warnings * * @throws {Error} If parsing fails or PPTX has no slides * * @example * ```typescript * const parser = await PPTXParser.fromFile(engine, buffer); * const result = await parser.parse(); * const messages = result.logger.getMessages(); * const pages = engine.block.findByType('//ly.img.ubq/page'); * ``` */ parse(): Promise; /** * Ensure theme colors are loaded (lazy initialization) * @internal */ private ensureThemeLoaded; /** * Get existing scene or create a new one with correct DPI * @internal */ private getOrCreateScene; /** * Parse all slides and return their page IDs * @internal */ private parseAllSlides; /** * Run all post-processing steps after pages are attached to scene * @internal */ private runPostProcessing; /** * Auto-correct overflowing text by reducing letter spacing * @internal */ private applyTextOverflowCorrections; /** * Parse a single slide and create CE.SDK page block * * @param slideKey - Slide file key (e.g., "ppt/slides/slide1.xml") * @returns Promise resolving to CE.SDK page block ID * @internal */ private parseSingleSlide; /** * Apply crop rotations after blocks are attached to scene * * Internal method to apply crop rotations that couldn't be set during block creation. * setCropRotation requires blocks to be attached to a scene. * * @internal */ private applyCropRotations; /** * Apply text position corrections after blocks are laid out. * Adjusts Y position of top-aligned text blocks to match PPTX baseline positioning. * @internal */ private applyTextPositionCorrections; /** * Apply position correction to a single text block * @internal */ private applyTextBlockCorrection; /** * Get expected block Y from metadata, or null if not set * @internal */ private getExpectedBlockY; /** * Find the parent page's global Y offset * @internal */ private getPageOffsetY; /** * Calculate Y correction needed to align text baseline with PPTX expectations * @internal */ private calculateTextCorrection; /** * Font metrics parsed from block metadata */ private getFontMetricsFromMetadata; /** * Calculate baseline-accurate Y correction using font metrics * * PPTX baseline formula: blockTop + ascenderHeight + (lineHeight - 1) × fontSize * @internal */ private calculateBaselineCorrection; /** * Handle errors during text correction (ignore "not found" metadata errors) * @internal */ private handleTextCorrectionError; /** Metadata keys used for text position correction */ private static readonly TEXT_CORRECTION_METADATA_KEYS; /** * Clean up text correction metadata from a block * @internal */ private cleanupTextMetadata; /** * Find the appropriate parent block for pages (stack if exists, otherwise scene) * @internal */ private findPageParent; /** * Attach page blocks to scene * @internal */ private attachPagesToScene; /** * Get number of slides in PPTX file * * Counts slide{n}.xml entries in parsed PPTX data. * * @returns Number of slides */ getSlideCount(): number; /** * Get ordered slide keys by resolving presentation.xml relationships. * Falls back to sorted regex-discovered keys if rels parsing fails. * @internal */ private getOrderedSlideKeys; /** * Extract raw XML from PPTX file * * Extracts raw XML string for a specific file in the PPTX archive. * Used for parsing elements where order matters (e.g., path commands). * * @param filePath - Path to file in PPTX archive (e.g., "ppt/slides/slide1.xml") * @returns Promise resolving to XML string or null if not found */ getRawXml(filePath: string): Promise; } /** * Options for text overflow correction */ export interface FitTextOptions { /** * Letter spacing reduction step size in em units. * Smaller values = more precise but slower. * @default 0.001 */ step?: number; /** * Maximum number of letter spacing reduction steps to try. * Higher values allow fixing larger overflows but take longer. * @default 500 */ maxSteps?: number; } /** * Result from fitTextByReducingLetterSpacing() */ export interface FitTextResult { /** Whether the text was corrected (overflow was detected and fixed) */ corrected: boolean; /** Original letter spacing value before correction */ originalSpacing: number; /** New letter spacing value after correction (same as original if not corrected) */ newSpacing: number; /** The adjustment made (originalSpacing - newSpacing), positive means spacing was reduced */ adjustment: number; } /** * Result from fitAllTextBlocks() */ export interface FitAllTextBlocksResult { /** Total number of text blocks checked */ totalBlocks: number; /** Number of blocks that were corrected */ correctedCount: number; /** Details for each corrected block */ corrections: Array<{ blockId: number; adjustment: number; }>; } /** * Attempts to fit text within its block by reducing letter spacing. * * Uses the same approach as the PSD importer: * 1. Wait for block to be ready (state != Pending) * 2. Set height mode to "Auto" to allow natural text flow * 3. Compare auto-computed frame height against original height * 4. Use binary search to find minimal letter spacing adjustment * * This function is useful for correcting minor text overflow issues caused by * differences in font metrics or kerning between the source application * (e.g., PowerPoint) and CE.SDK's text rendering. * * @param engine - CE.SDK CreativeEngine instance * @param blockId - The text block ID to correct * @param options - Configuration options * @returns Object indicating if text was corrected and the adjustment made * * @example * ```typescript * // Correct a single text block * const result = await fitTextByReducingLetterSpacing(engine, textBlockId); * if (result.corrected) { * console.log(`Reduced letter spacing by ${result.adjustment.toFixed(4)} em`); * } * ``` * * @example * ```typescript * // With custom options for finer control * const result = await fitTextByReducingLetterSpacing(engine, textBlockId, { * step: 0.0005, // Finer step for more precision * maxSteps: 1000, // Allow more reduction for large overflows * }); * ``` */ export declare function fitTextByReducingLetterSpacing(engine: CreativeEngine, blockId: number, options?: FitTextOptions): Promise; /** * Applies text fitting to all text blocks in the scene. * * Iterates through all text blocks found via `findByType('//ly.img.ubq/text')` * and attempts to fit each one by reducing letter spacing. * * @param engine - CE.SDK CreativeEngine instance * @param options - Configuration options (same as fitTextByReducingLetterSpacing) * @returns Summary of corrections made * * @example * ```typescript * // After importing a PPTX, correct any overflowing text * const result = await fitAllTextBlocks(engine); * console.log(`Corrected ${result.correctedCount} of ${result.totalBlocks} text blocks`); * ``` */ export declare function fitAllTextBlocks(engine: CreativeEngine, options?: FitTextOptions): Promise; export { Font, LogMessage$1 as LogMessage, Logger$1 as Logger, Typeface, }; export {};