UNPKG

@keymanapp/kmc-model

Version:

Keyman Developer lexical model compiler

72 lines 3.13 kB
import { LexicalModelSource, WordformToKeySpec } from "./lexical-model.js"; import { LexicalModelTypes } from '@keymanapp/common-types'; import CasingFunction = LexicalModelTypes.CasingFunction; /** * Processes certain defined model behaviors in such a way that the needed closures * may be safely compiled to a JS file and loaded within the LMLayer. * * This is accomplished by writing out a 'pseudoclosure' within the model's IIFE, * then used to build _actual_ closures at LMLayer load time. This 'pseudoclosure' * will very closely match the organizational patterns of this class in order to * facilitate the maintenance of this approach. */ export declare class ModelDefinitions { static readonly COMPILED_NAME = "definitions"; /** * A closure fully implementing the model's defined `applyCasing` behavior with * the function parameter preset to the version-appropriate default. * `defaults.applyCasing` is captured as part of the closure. * * During compilation of some models (such as Trie-based wordlist templated models), * this closure will be directly used as part of searchTermToKey. * * In compiled code, this will instead be defined in-line as an autogenerated closure * using the other properties of the pseudoclosure. */ applyCasing?: CasingFunction; /** * A closure fully implementing the model's defined `searchTermToKey` behavior * based upon the model's specified casing rules. The `applyCasing` closure is * itself captured within this closure. * * During compilation of some models (such as Trie-based wordlist templated models), * this closure will be directly utilized when compiling the lexicon. * * In compiled code, this will instead be defined in-line as an autogenerated closure * using the other properties of the pseudoclosure. */ searchTermToKey?: WordformToKeySpec; /** * Contains embedded 'default' implementations that may be needed for * closures in the compiled version, annotated with the current version * of Developer. */ private defaults; /** * Contains the model-specific definitions specified in the model's source. * * These definitions may expect `defaults.applyCasing` as a parameter in * their final closures. */ private model; constructor(modelSource: LexicalModelSource); /** * Writes out a compiled JS version of the pseudoclosure, preserving all function * implementations. * * This should be written to the file within the same IIFE as the model but BEFORE * the model itself, as the model will need to refer to the definitions herein. */ compileDefinitions(): string; /** * Compiles the model-options entry for `searchTermToKey` in reference to the * compiled pseudoclosure. */ compileSearchTermToKey(): string; /** * Compiles the model-options entry for `applyCasing` in reference to the * compiled pseudoclosure. */ compileApplyCasing(): string; } //# sourceMappingURL=model-definitions.d.ts.map