UNPKG

@shockpkg/dir-projector

Version:

Package for creating Shockwave Director projectors

414 lines (413 loc) 9.46 kB
/// <reference types="node" /> import { Archive } from '@shockpkg/archive-files'; export interface IIncludeXtraMapping { /** * Source path, case insensitive. * Does not need to match the full path. */ src: string; /** * Destination path, case sensitive. * Only matches same amount of the full path as src. */ dest: string | null; } export interface IIncludeXtraMappingBest { /** * Map instance. */ map: IIncludeXtraMapping; /** * Relative path. */ relative: string; } export interface IIncludeXtras { [key: string]: string | null; } export interface IProjectorOptions { /** * Skeleton file or directory. * * @default null */ skeleton?: string | null; /** * Movie file. * * @default null */ movieFile?: string | null; /** * Movie data. * * @default null */ movieData?: Buffer | null; /** * Movie name. * * @default null */ movieName?: string | null; /** * Movie data. * * @default false */ shockwave?: boolean; /** * Config file. * * @default null */ configFile?: string | null; /** * Config data. * * @default null */ configData?: string[] | string | Buffer | null; /** * Lingo file. * * @default null */ lingoFile?: string | null; /** * Lingo data. * * @default null */ lingoData?: string[] | string | Buffer | null; /** * Splash image file. * * @default null */ splashImageFile?: string | null; /** * Splash image data. * * @default null */ splashImageData?: Buffer | null; /** * Xtras include map. * * @default null */ includeXtras?: IIncludeXtras | null; /** * Nest xtras in a Configuration directory. * * @default false */ nestXtrasConfiguration?: boolean; /** * Path to hdiutil binary. * * @default null */ pathToHdiutil?: string | null; } /** * Projector constructor. * * @param options Options object. */ export declare abstract class Projector extends Object { /** * Skeleton file or directory. * * @default null */ skeleton: string | null; /** * Movie file. * * @default null */ movieFile: string | null; /** * Movie data. * * @default null */ movieData: Buffer | null; /** * Movie name. * * @default null */ movieName: string | null; /** * Movie data. * * @default false */ shockwave: boolean; /** * Config file. * * @default null */ configFile: string | null; /** * Config data. * * @default null */ configData: string[] | string | Buffer | null; /** * Lingo file. * * @default null */ lingoFile: string | null; /** * Lingo data. * * @default null */ lingoData: string[] | string | Buffer | null; /** * Splash image file. * * @default null */ splashImageFile: string | null; /** * Splash image data. * * @default null */ splashImageData: Buffer | null; /** * Xtras include map. * * @default null */ includeXtras: IIncludeXtras | null; /** * Nest xtras in a Configuration directory. * * @default false */ nestXtrasConfiguration: boolean; /** * Path to hdiutil binary. * * @default null */ pathToHdiutil: string | null; constructor(options?: IProjectorOptions); /** * Config file extension. * * @returns File extension. */ readonly configExtension: string; /** * Config file encoding. * * @returns File encoding. */ readonly configEncoding: BufferEncoding; /** * Lingo file name. * * @returns File name. */ readonly lingoName: string; /** * Lingo file encoding. * * @returns File encoding. */ readonly lingoEncoding: BufferEncoding; /** * Xtras directory name. * * @returns Directory encoding. */ readonly xtrasDirectoryName: string; /** * Configuration directory name. * * @returns Directory encoding. */ readonly configurationDirectoryName: string; /** * Get movie data if any specified, from data or file. * * @returns Movie data or null. */ getMovieData(): Promise<Buffer | null>; /** * Get config data if any specified, from data or file. * * @returns Config data or null. */ getConfigData(): Promise<Buffer | null>; /** * Get lingo data if any specified, from data or file. * * @returns Lingo data or null. */ getLingoData(): Promise<Buffer | null>; /** * Get splash image data if any specified, from data or file. * * @returns Splash image data or null. */ getSplashImageData(): Promise<Buffer | null>; /** * Get the name of a projector trimming the extension, case insensitive. * * @param name Projector name. * @returns Projector name without extension. */ getProjectorNameNoExtension(name: string): string; /** * Get the Xtras path. * * @param name Save name. * @returns Xtras path. */ getXtrasPath(name: string): string; /** * Get the config path. * * @param name Save name. * @returns Config path. */ getConfigPath(name: string): string; /** * Get the splash image path. * * @param name Save name. * @returns Config path. */ getSplashImagePath(name: string): string; /** * Get the skeleton file or directory as an Archive instance. * * @returns Archive instance. */ getSkeletonArchive(): Promise<Archive>; /** * Get include Xtras as a list of mappings. * * @returns Mappings list. */ getIncludeXtrasMappings(): IIncludeXtraMapping[]; /** * Find the best match for a path in a list of Xtras mappings. * Path search is case-insensitive. * * @param mappings Mappings list. * @param path Path to search for. * @returns Best match or null. */ findIncludeXtrasMappingsBestMatch(mappings: IIncludeXtraMapping[], path: string): IIncludeXtraMappingBest | null; /** * Find output path for an Xtra. * * @param mappings Mappings list. * @param path Path to search for. * @returns Output path or null. */ includeXtrasMappingsDest(mappings: IIncludeXtraMapping[], path: string): string | null; /** * Write out the projector. * * @param path Save path. * @param name Save name. */ write(path: string, name: string): Promise<void>; /** * Write out the projector movie file. * * @param path Save path. * @param name Save name. */ protected _writeMovie(path: string, name: string): Promise<void>; /** * Write out the projector config file. * * @param path Save path. * @param name Save name. */ protected _writeConfig(path: string, name: string): Promise<void>; /** * Write out the projector splash image file. * * @param path Save path. * @param name Save name. */ protected _writeSplashImage(path: string, name: string): Promise<void>; /** * Write out the projector lingo file. * * @param path Save path. * @param name Save name. */ protected _writeLingo(path: string, name: string): Promise<void>; /** * Get data from buffer or file. * * @param data Data buffer. * @param file File path. * @returns Data buffer. */ protected _dataFromBufferOrFile(data: Buffer | null, file: string | null): Promise<Buffer | null>; /** * Get data from value or file. * * @param data Data value. * @param file File path. * @param newline Newline string. * @param encoding String encoding. * @returns Data buffer. */ protected _dataFromValueOrFile(data: string[] | string | Buffer | null, file: string | null, newline: string | null, encoding: BufferEncoding | null): Promise<Buffer | null>; /** * Maybe write file if data is not null. * * @param data Data to maybe write. * @param path Output path. */ protected _maybeWriteFile(data: Buffer | null, path: string): Promise<void>; /** * Splash image file extension. * * @returns File extension. */ abstract readonly splashImageExtension: string; /** * Projector file extension. * * @returns File extension. */ abstract readonly projectorExtension: string; /** * Config file newline characters. * * @returns Newline characters. */ abstract readonly configNewline: string; /** * Config file newline characters. * * @returns Newline characters. */ abstract readonly lingoNewline: string; /** * Write the projector skeleton from archive. * * @param path Save path. * @param name Save name. */ protected abstract _writeSkeleton(path: string, name: string): Promise<void>; }