@shockpkg/dir-projector
Version:
Package for creating Shockwave Director projectors
255 lines (254 loc) • 6.18 kB
TypeScript
import { Projector } from '../projector.ts';
/**
* Include Xtra mapping.
*/
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;
}
/**
* Include Xtra mapping, best match.
*/
export interface IIncludeXtraMappingBest {
/**
* Map instance.
*/
map: IIncludeXtraMapping;
/**
* Relative path.
*/
relative: string;
}
/**
* Include Xtras.
*/
export interface IIncludeXtras {
[key: string]: string | null;
}
/**
* File patch.
*/
export interface IFilePatch {
/**
* Check if skeleton file path matches.
*
* @param file File path.
* @returns If matched.
*/
match: (file: string) => boolean;
/**
* Modify data, possibly inplace.
*
* @param data The data to modify.
* @returns Modified data.
*/
modify: (data: Uint8Array) => Promise<Uint8Array> | Uint8Array;
/**
* Run after all patches.
*/
after: () => Promise<void> | void;
}
/**
* ProjectorOtto object.
*/
export declare abstract class ProjectorOtto extends Projector {
/**
* Make a Shockwave projector.
*/
shockwave: boolean;
/**
* Splash image data.
*/
splashImageData: Readonly<Uint8Array> | (() => Readonly<Uint8Array>) | null;
/**
* Splash image file.
*/
splashImageFile: string | null;
/**
* Lingo data.
*/
lingoData: readonly string[] | string | Readonly<Uint8Array> | (() => readonly string[] | string | Readonly<Uint8Array>) | (() => Promise<readonly string[] | string | Readonly<Uint8Array>>) | null;
/**
* Lingo file.
*/
lingoFile: string | null;
/**
* Xtras include map.
*/
includeXtras: Readonly<IIncludeXtras> | null;
/**
* Nest xtras in a Configuration directory.
*/
nestXtrasConfiguration: boolean;
/**
* Skeleton path.
*/
skeleton: string | null;
/**
* Config data.
*/
configData: readonly string[] | string | Readonly<Uint8Array> | (() => readonly string[] | string | Readonly<Uint8Array>) | (() => Promise<readonly string[] | string | Readonly<Uint8Array>>) | null;
/**
* Config file.
*/
configFile: string | null;
/**
* ProjectorOtto constructor.
*
* @param path Output path.
*/
constructor(path: string);
/**
* Config file extension.
*
* @returns File extension.
*/
get configExtension(): string;
/**
* Lingo file name.
*
* @returns File name.
*/
get lingoName(): string;
/**
* 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 config file data.
*
* @returns Config data or null.
*/
getConfigData(): Promise<Readonly<Uint8Array> | null>;
/**
* Get splash image data if any specified, from data or file.
*
* @returns Splash image data or null.
*/
getSplashImageData(): Promise<Readonly<Uint8Array> | null>;
/**
* Get lingo data if any specified, from data or file.
*
* @returns Lingo data or null.
*/
getLingoData(): Promise<Readonly<Uint8Array> | null>;
/**
* 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;
/**
* @inheritdoc
*/
write(): Promise<void>;
/**
* Check that output path is valid, else throws.
*/
protected _checkOutput(): Promise<void>;
/**
* Write out the projector config file.
*/
protected _writeConfig(): 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.
*
* @param skeleton Skeleton path.
*/
protected abstract _writeSkeleton(skeleton: string): Promise<void>;
}