UNPKG

@imgly/psd-importer

Version:

Import PSD files into the Creative Editor Ecosystem

110 lines (106 loc) 3.31 kB
// Generated by dts-bundle-generator v9.5.1 import CreativeEngine from '@cesdk/engine'; import { Font, Typeface } from '@cesdk/engine'; export interface TypefaceParams { family: string; style: Font["style"]; weight: Font["weight"]; } export type TypefaceResolver = (fontParameters: TypefaceParams, engine: CreativeEngine) => Promise<FontResolverResult | null>; export declare function addGoogleFontsAssetLibrary(engine: CreativeEngine, url?: string): Promise<boolean | void>; export interface FontResolverResult { typeface: Typeface; font: Font; } export interface EncodeBufferToPNG { (rawImageBuffer: Uint8ClampedArray, imageWidth: number, imageHeight: number, backgroundColor?: { r: number; g: number; b: number; a: number; }): Promise<Blob>; } export type LogMessage = { message: string; type: "error" | "warning" | "info"; }; export declare class Logger { private static instance; constructor(); private messages; log(message: string, type?: "error" | "warning" | "info"): void; getMessages(): LogMessage[]; } export interface Flags { applyClipMasks: boolean; enableTextFitting: boolean; enableTextVerticalAlignmentFix: boolean; enableTextTypefaceReachableCheck: boolean; enableCreateHiddenLayers: boolean; enableTopLevelGroupsArePages: boolean; groupsEnabled: boolean; } export interface Options { fontResolver: TypefaceResolver; flags: Flags; } export declare class PSDParser { private engine; private scene; private stack; private width; private height; private psd; private logger; private fontResolver; private encodeBufferToPNG; private flags; private groups; private constructor(); static fromFile(engine: CreativeEngine, fileBuffer: ArrayBuffer, encodeBufferToPNG: EncodeBufferToPNG, options?: Partial<Options>): Promise<PSDParser>; private traverseNode; private checkUnsupportedLayerFeatures; private applyParentClipMasks; /** * 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; }>; private initScene; private createPage; private applyTreeOpacity; private createTextBlock; private moveTextInTextDirection; private textVerticalAlignmentFix; private textFitting; private getTextFontSet; private getStyleSheetColor; private getTextValue; private getTextStrokeColor; /** * 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; private createImageBlock; private getSvgMoveTo; private getSvgCurve; private createVectorBlock; private buildShapeFromPathRecords; private rotateBlock; private getBlendModeFillOpacity; private getBlendMode; } export declare function createWebEncodeBufferToPNG(): EncodeBufferToPNG; export declare function createPNGJSEncodeBufferToPNG(PNG: typeof import("pngjs/browser").PNG): EncodeBufferToPNG; export {};