@shockpkg/dir-projector
Version:
Package for creating Shockwave Director projectors
263 lines (262 loc) • 6.42 kB
TypeScript
/// <reference types="node" />
import { TranscodeEncoding } from 'buffer';
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;
}
/**
* Projector constructor.
*
* @param path Output path.
*/
export declare abstract class Projector extends Object {
/**
* Make a Shockwave projector.
*
* @default false
*/
shockwave: boolean;
/**
* Splash image file.
*
* @default null
*/
splashImageFile: string | null;
/**
* Splash image data.
*
* @default null
*/
splashImageData: Readonly<Buffer> | null;
/**
* Lingo file.
*
* @default null
*/
lingoFile: string | null;
/**
* Lingo data.
*
* @default null
*/
lingoData: (Readonly<string[]> | string | Readonly<Buffer> | null);
/**
* Xtras include map.
*
* @default null
*/
includeXtras: Readonly<IIncludeXtras> | null;
/**
* Nest xtras in a Configuration directory.
*
* @default false
*/
nestXtrasConfiguration: boolean;
/**
* Path to hdiutil binary.
*
* @default null
*/
pathToHdiutil: string | null;
/**
* Output path.
*/
readonly path: string;
constructor(path: string);
/**
* Config file extension.
*
* @returns File extension.
*/
get configExtension(): string;
/**
* Config file encoding.
*
* @returns File encoding.
*/
get configEncoding(): TranscodeEncoding;
/**
* Lingo file name.
*
* @returns File name.
*/
get lingoName(): string;
/**
* Lingo file encoding.
*
* @returns File encoding.
*/
get lingoEncoding(): TranscodeEncoding;
/**
* Xtras directory name.
*
* @returns Directory encoding.
*/
get xtrasName(): string;
/**
* Configuration directory name.
*
* @returns Directory encoding.
*/
get configurationName(): string;
/**
* Name of a projector trimming the extension, case insensitive.
*
* @returns Projector name without extension.
*/
get name(): string;
/**
* Config file path.
*
* @returns Config path.
*/
get configPath(): string;
/**
* Splash image file path.
*
* @returns Splash image path.
*/
get splashImagePath(): string;
/**
* Lingo file path.
*
* @returns Lingo file path.
*/
get lingoPath(): string;
/**
* Get outout Xtras path.
*
* @returns Output path.
*/
get xtrasPath(): string;
/**
* Get splash image data if any specified, from data or file.
*
* @returns Splash image data or null.
*/
getSplashImageData(): Promise<Buffer | Readonly<Buffer> | null>;
/**
* Get lingo data if any specified, from data or file.
*
* @returns Lingo data or null.
*/
getLingoData(): Promise<Readonly<Buffer> | null>;
/**
* Get the skeleton file or directory as an Archive instance.
*
* @param skeleton Skeleton path.
* @returns Archive instance.
*/
getSkeletonArchive(skeleton: string): 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: Readonly<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: Readonly<IIncludeXtraMapping[]>, path: string): string | null;
/**
* Write out projector with skeleton and config file.
*
* @param skeleton Skeleton path.
* @param configFile Config file.
*/
withFile(skeleton: string, configFile: string | null): Promise<void>;
/**
* Write out projector with skeleton and config data.
*
* @param skeleton Skeleton path.
* @param configData Config data.
*/
withData(skeleton: string, configData: Readonly<string[]> | string | Readonly<Buffer> | null): Promise<void>;
/**
* Check that output path is valid, else throws.
*/
protected _checkOutput(): Promise<void>;
/**
* Write out the projector config file.
*
* @param configData Config data.
*/
protected _writeConfig(configData: Readonly<string[]> | string | Readonly<Buffer> | null): Promise<void>;
/**
* Write out the projector splash image file.
*/
protected _writeSplashImage(): Promise<void>;
/**
* Write out the projector lingo file.
*/
protected _writeLingo(): Promise<void>;
/**
* Projector file extension.
*
* @returns File extension.
*/
abstract get extension(): string;
/**
* Splash image file extension.
*
* @returns File extension.
*/
abstract get splashImageExtension(): string;
/**
* Config file newline characters.
*
* @returns Newline characters.
*/
abstract get configNewline(): string;
/**
* Lingo file newline characters.
*
* @returns Newline characters.
*/
abstract get lingoNewline(): string;
/**
* Write the projector skeleton from archive.
*
* @param skeleton Skeleton path.
*/
protected abstract _writeSkeleton(skeleton: string): Promise<void>;
/**
* Modify the projector skeleton.
*/
protected abstract _modifySkeleton(): Promise<void>;
}