// Generated by dts-bundle-generator v9.5.1 import CreativeEngine from '@cesdk/engine'; import { AssetAPI, Font, FontStyle, FontWeight, 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"]; } export 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; interface EncodeBufferToPNG { (rawImageBuffer: Uint8ClampedArray, imageWidth: number, imageHeight: number, backgroundColor?: { r: number; g: number; b: number; a: number; }): Promise; } declare const WARNING_CODES: { readonly DOC_ANALYZE_STARTED: { readonly severity: "info"; readonly template: "Started analyzing the .PSD File"; }; readonly LAYER_ZERO_DIMENSIONS: { readonly severity: "warning"; readonly template: "Layer \"{name}\" has zero dimensions ({width}x{height}) and was skipped."; }; readonly LAYER_CREATE_FAILED: { readonly severity: "warning"; readonly template: "Layer \"{name}\" could not be created as a design block and was skipped."; }; readonly LAYER_EFFECTS_REMOVED: { readonly severity: "warning"; readonly template: "Layer \"{name}\" has layer effects (e.g., shadows, glows), which are not supported. The effects were removed."; }; readonly LAYER_EFFECT_STROKE_FILL_GRADIENT_UNSUPPORTED: { readonly severity: "warning"; readonly template: "Layer \"{name}\" has a gradient stroke layer effect. CE.SDK only supports solid-color strokes \u2014 the gradient stroke was removed."; }; readonly LAYER_EFFECT_STROKE_FILL_PATTERN_UNSUPPORTED: { readonly severity: "warning"; readonly template: "Layer \"{name}\" has a pattern stroke layer effect. CE.SDK only supports solid-color strokes \u2014 the pattern stroke was removed."; }; readonly LAYER_EFFECT_STROKE_BLEND_MODE_UNSUPPORTED: { readonly severity: "warning"; readonly template: "Stroke layer effect on layer \"{name}\" uses blend mode \"{blendMode}\", which CE.SDK strokes do not support. The stroke was applied with Normal blending instead."; }; readonly LAYER_EFFECT_STROKE_OPACITY_BAKED_INTO_ALPHA: { readonly severity: "warning"; readonly template: "Stroke layer effect on layer \"{name}\" uses opacity {strokeOpacity}% on a layer with opacity {layerOpacity}%. CE.SDK has no independent stroke opacity, so the values were combined into the stroke color's alpha; the visual result may differ slightly from Photoshop."; }; readonly LAYER_EFFECT_STROKE_POSITION_UNKNOWN: { readonly severity: "warning"; readonly template: "Stroke layer effect on layer \"{name}\" uses an unrecognized position value \"{position}\". Falling back to Center."; }; readonly LAYER_EFFECT_STROKE_MULTIPLE_UNSUPPORTED: { readonly severity: "warning"; readonly template: "Layer \"{name}\" has {count} stroke layer effects stacked. CE.SDK supports only one stroke per block \u2014 the first was applied, the rest were dropped."; }; readonly LAYER_EFFECT_STROKE_NON_VECTOR_GLYPH_FIDELITY: { readonly severity: "info"; readonly template: "Stroke layer effect on text layer \"{name}\" may render slightly differently for emoji or bitmap glyphs. CE.SDK strokes glyph outlines (vector); Photoshop strokes the rasterized layer."; }; readonly LAYER_EFFECT_STROKE_OVERRODE_CHARACTER_STROKE: { readonly severity: "info"; readonly template: "Layer \"{name}\" had both a character-level outline and a layer-effect stroke. The layer-effect stroke wins, matching Photoshop's rendering order."; }; readonly LAYER_EFFECT_KIND_UNSUPPORTED: { readonly severity: "warning"; readonly template: "Layer \"{name}\" has a \"{kind}\" layer effect, which is not supported. The effect was removed."; }; readonly LAYER_MASK_REMOVED: { readonly severity: "warning"; readonly template: "Layer \"{name}\" has a layer mask, which is not supported. The mask was removed and the full layer is visible."; }; readonly LAYER_MASK_TOO_LARGE: { readonly severity: "warning"; readonly template: "Layer \"{name}\" has a very large layer mask that cannot be processed. The mask was removed."; }; readonly LAYER_MASK_FAILED: { readonly severity: "warning"; readonly template: "Layer \"{name}\" has a layer mask that could not be processed. The mask was removed."; }; readonly LAYER_MASK_FEATHER_IGNORED: { readonly severity: "info"; readonly template: "Layer \"{name}\" has a feathered layer mask. The mask was applied with a hard edge."; }; readonly LAYER_CLIPPING_REMOVED: { readonly severity: "warning"; readonly template: "Layer \"{name}\" has a clipping mask, which is not supported. The clipping was removed."; }; readonly LAYER_GROUP_FAILED: { readonly severity: "warning"; readonly template: "A group of {count} layers could not be created. The layers were imported without grouping."; }; readonly LAYER_GRADIENT_FILL_REMOVED: { readonly severity: "warning"; readonly template: "Layer \"{name}\" has a gradient fill, which is not supported. The fill was removed."; }; readonly LAYER_STROKE_COLOR_DEFAULT: { readonly severity: "warning"; readonly template: "Stroke color for layer \"{name}\" could not be determined. Using black as the default."; }; readonly LAYER_SKEW_REMOVED: { readonly severity: "warning"; readonly template: "Layer \"{name}\" has a skew/shear transform, which is not supported. The layer will be rendered without the skew."; }; readonly LAYER_FILL_OPACITY_RESET: { readonly severity: "warning"; readonly template: "Layer \"{name}\" has a fill opacity of 0, which would make it invisible. The opacity was reset to fully visible for easier editing."; }; readonly LAYER_BLEND_MODE_DEFAULT: { readonly severity: "warning"; readonly template: "Blend mode \"{blendMode}\" is not supported. Using \"Normal\" as the default."; }; readonly FONT_METRICS_LOAD_FAILED: { readonly severity: "warning"; readonly template: "Font metrics for \"{fontUri}\" could not be loaded. Text spacing may be inaccurate."; }; readonly FONT_SUBSTITUTED_ROBOTO: { readonly severity: "warning"; readonly template: "Font \"{family}\" ({weight}, {style}) is not available. Substituting with \"Roboto\". To preserve the original font, add it to the font library."; }; readonly FONT_AND_FALLBACK_FAILED: { readonly severity: "error"; readonly template: "Font \"{family}\" ({weight}, {style}) is not available and the \"Roboto\" fallback could not be loaded. The text will be imported without a valid font."; }; readonly FONT_LOAD_FAILED_DEFAULT: { readonly severity: "warning"; readonly template: "Font \"{family}\" could not be loaded. The default font will be used for this text."; }; readonly FONT_RANGE_DEFAULT: { readonly severity: "warning"; readonly template: "Font \"{family}\" ({weight}, {style}) is not available. The default font will be used for this text segment."; }; readonly FONT_RANGE_APPLY_FAILED: { readonly severity: "warning"; readonly template: "Font \"{family}\" could not be applied to a text segment. The default font will be used for that segment."; }; readonly FONT_BOLD_UNAVAILABLE: { readonly severity: "warning"; readonly template: "A bold variant is not available for the font used in text \"{snippet}\". The text will be rendered in the regular weight."; }; readonly FONT_ITALIC_UNAVAILABLE: { readonly severity: "warning"; readonly template: "An italic variant is not available for the font used in text \"{snippet}\". The text will be rendered in the regular style."; }; readonly FONT_SET_MISSING: { readonly severity: "warning"; readonly template: "No font set was found in the document. Using the default font \"Roboto\"."; }; readonly TEXT_LAYER_READ_FAILED: { readonly severity: "error"; readonly template: "Text layer \"{name}\" could not be read and was skipped."; }; readonly TEXT_BOUNDS_READ_FAILED: { readonly severity: "error"; readonly template: "Bounds could not be read from text block \"{name}\". This may indicate an issue with the file. Try re-saving it from Photoshop."; }; readonly TEXT_COLOR_DEFAULT: { readonly severity: "warning"; readonly template: "Text color for \"{snippet}\" could not be determined. Using the default color."; }; readonly TEXT_AUTO_LEADING_DEFAULT: { readonly severity: "warning"; readonly template: "Auto-leading could not be read for text \"{snippet}\". Using the default line height of {defaultLineHeight}."; }; readonly TEXT_LINE_HEIGHT_DEFAULT: { readonly severity: "warning"; readonly template: "Line height could not be read for text \"{snippet}\". Using the default line height of {defaultLineHeight}."; }; }; /** * PSD 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; export interface Flags { applyClipMasks: boolean; enableTextFitting: boolean; enableTextVerticalAlignmentFix: boolean; enableTextTypefaceReachableCheck: boolean; enableCreateHiddenLayers: boolean; enableTopLevelGroupsArePages: boolean; groupsEnabled: boolean; /** * Bake raster layer masks into the alpha channel of the exported layer * pixels. Off by default: CE.SDK has no equivalent of a Photoshop layer * mask, so baking is destructive — the mask can no longer be edited or * removed after import. When off, masked layers import unmasked and a * LAYER_MASK_REMOVED warning is emitted. */ bakeLayerMasks: boolean; } export interface Options { fontResolver: TypefaceResolver; flags: Partial; } export declare class PSDParser { private engine; private scene; private stack; private width; private height; private psd; private logger; private fontResolver; private fontMetricsCache; private encodeBufferToPNG; private flags; private groups; private constructor(); private loadFontMetrics; static fromFile(engine: CreativeEngine, fileBuffer: ArrayBuffer, encodeBufferToPNG: EncodeBufferToPNG, options?: Partial): Promise; private traverseNode; private checkUnsupportedLayerFeatures; private applyParentClipMasks; /** * Adjust an image-fill block's crop so the bitmap stays anchored to * `oldRect` in scene coordinates after the block itself has been * resized/relocated to `newRect`. Used in two places: * * 1. `applyParentClipMasks` — after `engine.block.combine(...)` shrinks * the block to the intersection with parent clip masks, the * bitmap needs to be re-positioned so the visible portion still * lines up with the original layer rect. * * 2. `createVectorBlock` — when a `kind=shape` block has to be * expanded to absorb a vmsk whose path bbox exceeds the layer's * bbox (otherwise CE.SDK renders the image fill across the path's * extent and the bitmap bleeds past the block). * * Rectangles are in scene-space (inch/page-pixel) coordinates. No-op * when called on a block without an image fill, so it's safe to call * unconditionally. */ private setImageFillCropForBlockReshape; /** * Creates a graphic block with the shape of the vector mask of the PSD node * @param psdNode The PSD node to extract the clip mask from * @returns A graphic block with the shape of the clip mask or null if no clip mask is present */ private createClipMaskLayer; private createGroups; parse(): Promise<{ scene: number; logger: Logger$1; }>; private initScene; private createPage; private applyTreeOpacity; private createTextBlock; private moveTextInTextDirection; private textVerticalAlignmentFix; /** * Vertically align imported point text with Photoshop's rendered glyphs. * * Photoshop anchors point text at the first baseline inside an oversized * edit box, while CE.SDK lays out from the frame's top edge, so the first * line lands too high — worst for superscript-styled runs, which Photoshop * raises but CE.SDK cannot. The PSD records the visible glyph extent * (`boundingBox`) next to the edit box (`bounds`); aligning the engine's * measured first-line ink top with that extent reproduces Photoshop's * placement for any font, size mix, or baseline styling. * * Returns false when the required data is missing or the block is rotated * (the global-space measurement is axis-aligned), so the caller can fall * back to the legacy metric-based correction. */ private alignPointTextToInkBounds; private autoSizePointText; private fitTextToBounds; private getTextFontSet; private getStyleSheetColor; private getTextValue; private getTextStrokeColor; /** * `engine.block.isStrokeEnabled` throws for block subtypes that don't * carry a stroke (e.g. nested pages). We probe it before applying the * layer-effect stroke purely to decide whether to log an "override" * diagnostic; treat any failure as "no prior stroke". */ private safeIsStrokeEnabled; /** * This function scales a text attribute based on the scaling factor of the PSD file * @param textAttribute The text attribute to scale * @param TySh The TypeToolObjectSettingAliBlock object * @param dpi The DPI of the PSD file. Default is 72 * @returns returns the scaled text attribute */ private scaleTextNumber; private getLineHeight; /** True when the layer's pixels are PNG-exported (image or vmsk path). */ private canBakeRasterMask; /** * Picks the raster mask record to apply, or null. When a layer has both a * vector and a raster mask, `realData` holds the user's raster mask and the * primary record is derived from the vector mask * (`userMaskFromRenderingOtherData`) — derived records are skipped because * the vector path is applied as shape geometry already. */ private selectRasterMask; /** * Bakes the layer's raster mask into the alpha channel of the `composite()` * buffer. Returns true when applied — the caller must then pass no * background color to the PNG encoder (a solid fill is pre-blended here so * the mask cuts it too). No-op unless the `bakeLayerMasks` flag opted in * (baking is destructive; see the flag's doc). */ private applyRasterLayerMask; private createImageBlock; private getSvgMoveTo; private getSvgCurve; private createVectorBlock; private buildShapeFromPathRecords; private applyRotationFromTransform; private getBlendModeFillOpacity; private getBlendMode; } export declare function createWebEncodeBufferToPNG(): EncodeBufferToPNG; export declare function createPNGJSEncodeBufferToPNG(PNG: typeof import("pngjs/browser").PNG): EncodeBufferToPNG; export { Logger$1 as Logger, }; export {};