@keymanapp/kmc-keyboard-info
Version:
Keyman Developer .keyboard_info compiler
124 lines • 5.17 kB
TypeScript
/**
* Merges a source .keyboard_info file with metadata extracted from .kps file and
* compiled files to produce a comprehensive .keyboard_info file.
*/
import { KeyboardInfoFileLanguageFont } from "./keyboard-info-file.js";
import { CompilerCallbacks, KmpJsonFile, KeymanCompiler, CompilerOptions, KeymanCompilerResult, KeymanCompilerArtifacts, KeymanCompilerArtifact } from "@keymanapp/common-types";
/**
* @public
* Description of sources and metadata required to build a .keyboard_info file
*/
export interface KeyboardInfoSources {
/** The path in the keymanapp/keyboards repo where this keyboard may be found */
sourcePath: string;
/** The compiled keyboard filename and relative path (.js only) */
jsFilename?: 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 keyboards repository */
forPublishing: boolean;
}
/**
* @public
* Options for the .keyboard_info compiler
*/
export interface KeyboardInfoCompilerOptions extends CompilerOptions {
/**
* Description of sources and metadata required to build a .keyboard_info file
*/
sources: KeyboardInfoSources;
}
/**
* @public
* Internal in-memory build artifacts from a successful compilation
*/
export interface KeyboardInfoCompilerArtifacts extends KeymanCompilerArtifacts {
/**
* Binary keyboard info filedata and filename - used by keyman.com
*/
keyboard_info: KeymanCompilerArtifact;
}
/**
* @public
* Build artifacts from the .keyboard_info compiler
*/
export interface KeyboardInfoCompilerResult extends KeymanCompilerResult {
/**
* Internal in-memory build artifacts from a successful compilation. Caller
* can write these to disk with {@link KeyboardInfoCompiler.write}
*/
artifacts: KeyboardInfoCompilerArtifacts;
}
/**
* @public
* Compiles source data from a keyboard project to a .keyboard_info. The
* compiler does not read or write from filesystem or network directly, but
* relies on callbacks for all external IO.
*/
export declare class KeyboardInfoCompiler 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: KeyboardInfoCompilerOptions): Promise<boolean>;
/**
* @public
* Builds a .keyboard_info file with metadata from the keyboard 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 KeyboardInfoCompiler.init} function to read any input files
* by disk.
*
* This function is intended for use within the keyboards 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. For full
* documentation, see: https://help.keyman.com/developer/cloud/keyboard_info/
*
* @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 KeyboardInfoCompiler.write}.
* @returns Binary artifacts on success, null on failure.
*/
run(inputFilename: string, outputFilename?: string): Promise<KeyboardInfoCompilerResult>;
/**
* Write artifacts from a successful compile to disk, via callbacks methods.
* The artifacts written may include:
*
* - .keyboard_info file - metadata file used by keyman.com
*
* @param artifacts - object containing artifact binary data to write out
* @returns true on success
*/
write(artifacts: KeyboardInfoCompilerArtifacts): Promise<boolean>;
private mapKeymanTargetToPlatform;
private kmxFileVersionToString;
private isLicenseMIT;
private loadKmxFiles;
private loadJsFile;
private fillLanguages;
/**
* @internal
*/
fontSourceToKeyboardInfoFont(kpsFilename: string, kmpJsonData: KmpJsonFile.KmpJsonFile, source: string[]): Promise<KeyboardInfoFileLanguageFont>;
}
/**
* these are exported only for unit tests, do not use
*/
export declare const unitTestEndpoints: {
langtagsByTag: {};
};
//# sourceMappingURL=keyboard-info-compiler.d.ts.map