import { Reference } from "./Reference"; /** * Descriptors are dictionary-like data structures that Photoshop uses to store * arbitrary key-value data. */ export interface Descriptor { name: string; classId: string; items: Map; } /** * Descriptor with an associated version. */ export interface VersionedDescriptor { descriptorVersion: 16; descriptor: Descriptor; } export type DescriptorValue = AliasDescriptorValue | BooleanDescriptorValue | ClassDescriptorValue | DescriptorDescriptorValue | DoubleDescriptorValue | EnumeratedDescriptorValue | IntegerDescriptorValue | LargeIntegerDescriptorValue | ListDescriptorValue | RawDataDescriptorValue | ReferenceDescriptorValue | StringDescriptorValue | UnitFloatDescriptorValue | ObjectArrayDescriptorValue | UnitFloatsDescriptorValue; interface DescriptorValueBase { type: Type; } /** Possible values for the `type` field in `DescriptorValue` objects. */ export declare enum DescriptorValueType { Alias = "alis", Boolean = "bool", Class = "type", Descriptor = "Objc", Double = "doub", Enumerated = "enum", /** Effectively the same as `DescriptorValueType.Class` */ GlobalClass = "GlbC", /** Effectively the same as `DescriptorValueType.Descriptor` */ GlobalObject = "GlbO", Integer = "long", LargeInteger = "comp", List = "VlLs", RawData = "tdta", Reference = "obj ", String = "TEXT", UnitFloat = "UntF", UnitFloats = "UnFl", ObjectArray = "ObAr" } export interface AliasDescriptorValue extends DescriptorValueBase { /** * Adobe's documentation says: * "FSSpec for Macintosh or a handle to a string to the full path on Windows". * * Since it's unclear what this means, we provide the raw data rather than * attempting to parse it. */ data: Uint8Array; } export interface BooleanDescriptorValue extends DescriptorValueBase { value: boolean; } export interface ClassDescriptorValue extends DescriptorValueBase { name: string; classId: string; } export interface DescriptorDescriptorValue extends DescriptorValueBase { descriptor: Descriptor; } export interface DoubleDescriptorValue extends DescriptorValueBase { /** 64-bit floating-point number */ value: number; } export interface EnumeratedDescriptorValue extends DescriptorValueBase { enumType: string; enumValue: string; } export interface IntegerDescriptorValue extends DescriptorValueBase { /** 32-bit integer */ value: number; } export interface LargeIntegerDescriptorValue extends DescriptorValueBase { /** 64-bit integer */ value: number; } export interface ListDescriptorValue extends DescriptorValueBase { values: DescriptorValue[]; } export interface RawDataDescriptorValue extends DescriptorValueBase { data: Uint8Array; } export interface ReferenceDescriptorValue extends DescriptorValueBase { references: Reference[]; } export interface StringDescriptorValue extends DescriptorValueBase { value: string; } export interface UnitFloatDescriptorValue extends DescriptorValueBase { unitType: UnitFloatType; /** 64-bit floating-point number */ value: number; } export interface ObjectArrayDescriptorValue extends DescriptorValueBase { classObj: { name: string; classId: string; }; items: { key: string; value: DescriptorValue; }[]; } export interface UnitFloatsDescriptorValue extends DescriptorValueBase { unitType: UnitFloatType; /** 64-bit floating-point number */ values: number[]; } /** Valid measurement unit types used by `UnitFloatDescriptorValue` */ export declare enum UnitFloatType { /** Base degrees */ Angle = "#Ang", /** Base per inch */ Density = "#Rsl", /** Base 72ppi */ Distance = "#Rlt", /** Tagged unit value */ Millimeters = "#Mlm", /** None */ None = "#Nne", /** Unit value */ Percent = "#Prc", /** Tagged unit value */ Pixels = "#Pxl", /** Tagged unit value */ Points = "#Pnt" } /** * Helper type that maps a `DescriptorValueType` to a `DescriptorValue` subtype */ type DescriptorValueWithType = D extends unknown ? (Type extends D["type"] ? D : never) : never; /** * Retrieves an item in `descriptor` with the `key` as the given `valueType`. * @param descriptor * @param key * @param valueType Desired value type * @throws {MissingDescriptorKey} If the key does not exist * @throws {UnexpectedDescriptorValueType} If the value type does not match * `valueType` */ export declare function getDescriptorValueAsType(descriptor: Descriptor, key: string, valueType: Type): DescriptorValueWithType; export {}; //# sourceMappingURL=Descriptor.d.ts.map