UNPKG

@keymanapp/kmc-model

Version:

Keyman Developer lexical model compiler

88 lines 3.86 kB
import { LexicalModelSource } from "./lexical-model.js"; import { CompilerCallbacks, CompilerOptions, KeymanCompiler, KeymanCompilerArtifact, KeymanCompilerArtifacts, KeymanCompilerResult } from "@keymanapp/developer-utils"; /** * @public * Internal in-memory build artifacts from a successful compilation */ export interface LexicalModelCompilerArtifacts extends KeymanCompilerArtifacts { /** * Javascript model filedata and filename - installable into KeymanWeb, * Keyman mobile products */ js: KeymanCompilerArtifact; } /** * @public * Build artifacts from the lexical model compiler */ export interface LexicalModelCompilerResult extends KeymanCompilerResult { /** * Internal in-memory build artifacts from a successful compilation. Caller * can write these to disk with {@link LexicalModelCompiler.write} */ artifacts: LexicalModelCompilerArtifacts; } /** * @public * Compiles a .model.ts file to a .model.js. The compiler does not read or write * from filesystem or network directly, but relies on callbacks for all external * IO. */ export declare class LexicalModelCompiler implements KeymanCompiler { /** * Initialize the compiler. There are currently no options * specific to the lexical model compiler * @param callbacks - Callbacks for external interfaces, including message * reporting and file io * @param options - Compiler options * @returns always succeeds and returns true */ init(callbacks: CompilerCallbacks, _options: CompilerOptions): Promise<boolean>; /** * Compiles a .model.ts file to .model.js. 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 LexicalModelCompiler.init} * function to read any input files by disk. * @param infile - Path to source file. Path will be parsed to find relative * references in the .kmn file, such as icon or On Screen * Keyboard 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 LexicalModelCompiler.write}. * @returns Binary artifacts on success, null on failure. */ run(inputFilename: string, outputFilename?: string): Promise<LexicalModelCompilerResult>; /** * Write artifacts from a successful compile to disk, via callbacks methods. * The artifacts written may include: * * - .model.js file - Javascript lexical model for web and touch platforms * * @param artifacts - object containing artifact binary data to write out * @returns always returns true */ write(artifacts: LexicalModelCompilerArtifacts): Promise<boolean>; /** * @internal * Loads a lexical model's source module from the given filename. * * @param filename - path to the model source file. */ loadFromFilename(filename: string): LexicalModelSource; /** * @internal * Returns the generated code for the model that will ultimately be loaded by * the LMLayer worker. This code contains all model parameters, and specifies * word breakers and auxilary functions that may be required. * * @param model_id - The model ID. TODO: not sure if this is actually required! * @param modelSource - A specification of the model to compile * @param sourcePath - Where to find auxilary sources files */ generateLexicalModelCode(model_id: string, modelSource: LexicalModelSource, sourcePath: string): string; /** * @internal */ transpileSources(sources: Array<string>): Array<string>; } //# sourceMappingURL=lexical-model-compiler.d.ts.map