@keymanapp/kmc-model-info
Version:
Keyman Developer .model_info compiler
114 lines • 4.67 kB
TypeScript
/**
* Builds a source .model_info file with metadata extracted from .kps file and
* compiled files to produce a comprehensive .model_info file.
*/
import { KmpJsonFile } from "@keymanapp/common-types";
import { CompilerCallbacks, CompilerOptions, KeymanCompiler, KeymanCompilerArtifact, KeymanCompilerArtifacts, KeymanCompilerResult } from "@keymanapp/developer-utils";
/**
* @public
* Description of sources and metadata required to build a .model_info file
*/
export declare class ModelInfoSources {
/** The identifier for the model */
model_id: string;
/** The data from the .kps file, transformed to kmp.json */
kmpJsonData: KmpJsonFile.KmpJsonFile;
/** The path in the keymanapp/lexical-models repo where this model may be found */
sourcePath: string;
/** The compiled model filename and relative path (.js) */
modelFileName: string;
/** The compiled package filename and relative path (.kmp) */
kmpFileName: string;
/** The source package filename and relative path (.kps) */
kpsFilename: string;
/** Last modification date for files in the project folder 'YYYY-MM-DDThh:mm:ssZ' */
lastCommitDate?: string;
/** Return an error if project does not meet requirements of lexical-models repository */
forPublishing: boolean;
}
/**
* @public
* Options for the .model_info compiler
*/
export interface ModelInfoCompilerOptions extends CompilerOptions {
/**
* Description of sources and metadata required to build a .model_info file
*/
sources: ModelInfoSources;
}
/**
* @public
* Internal in-memory build artifacts from a successful compilation
*/
export interface ModelInfoCompilerArtifacts extends KeymanCompilerArtifacts {
/**
* Binary model info filedata and filename - used by keyman.com
*/
model_info: KeymanCompilerArtifact;
}
/**
* @public
* Build artifacts from the .model_info compiler
*/
export interface ModelInfoCompilerResult extends KeymanCompilerResult {
/**
* Internal in-memory build artifacts from a successful compilation. Caller
* can write these to disk with {@link ModelInfoCompiler.write}
*/
artifacts: ModelInfoCompilerArtifacts;
}
/**
* @public
* Compiles source data from a lexical model project to a .model_info. The
* compiler does not read or write from filesystem or network directly, but
* relies on callbacks for all external IO.
*/
export declare class ModelInfoCompiler implements KeymanCompiler {
private callbacks;
private options;
constructor();
/**
* Initialize the compiler.
* Copies options.
* @param callbacks - Callbacks for external interfaces, including message
* reporting and file io
* @param options - Compiler options
* @returns false if initialization fails
*/
init(callbacks: CompilerCallbacks, options: ModelInfoCompilerOptions): Promise<boolean>;
/**
* Builds .model_info file with metadata from the model and package source
* file. Returns an object containing binary artifacts on success. The files
* are passed in by name, and the compiler will use callbacks as passed to the
* {@link ModelInfoCompiler.init} function to read any input files by disk.
*
* This function is intended for use within the lexical-models repository.
* While many of the parameters could be deduced from each other, they are
* specified here to reduce the number of places the filenames are
* constructed.
*
* @param infile - Path to source file. Path will be parsed to find relative
* references in the .kpj file, such as .model.ts or
* .model.kps file
* @param outfile - Path to output file. The file will not be written to, but
* will be included in the result for use by
* {@link ModelInfoCompiler.write}.
* @returns Binary artifacts on success, null on failure.
*
* @param sources - Details on files from which to extract additional metadata
*/
run(inputFilename: string, outputFilename?: string): Promise<ModelInfoCompilerResult>;
/**
* Write artifacts from a successful compile to disk, via callbacks methods.
* The artifacts written may include:
*
* - .model_info file - metadata file used by keyman.com
*
* @param artifacts - object containing artifact binary data to write out
* @returns true on success
*/
write(artifacts: ModelInfoCompilerArtifacts): Promise<boolean>;
private isLicenseMIT;
private loadJsFile;
}
//# sourceMappingURL=model-info-compiler.d.ts.map