@keymanapp/common-types
Version:
Keyman Developer keyboard file types
325 lines • 10 kB
TypeScript
import { ElementString } from './element-string.js';
import { ListItem } from '../../ldml-keyboard/string-list.js';
import * as KMX from '../kmx.js';
import { UnicodeSetParser, UnicodeSet } from '../../ldml-keyboard/unicodeset-parser-api.js';
import KMXFile = KMX.KMXFile;
export declare class Section {
}
/**
* Sections which are needed as dependencies.
*/
export interface DependencySections extends KMXPlusData {
/** needed for UnicodeSet parsing */
usetparser?: UnicodeSetParser;
}
export declare class Sect extends Section {
}
export declare class Elem extends Section {
strings: ElementString[];
constructor(sections: DependencySections);
/**
* @param source if a string array, does not get reinterpreted as UnicodeSet. This is used with vars, etc. Or pass `["str"]` for an explicit 1-element elem.
* If it is a string, will be interpreted per reorder element ruls.
*/
allocElementString(sections: DependencySections, source: string | string[], order?: string, tertiary?: string, tertiary_base?: string, prebase?: string): ElementString;
}
export declare class Loca extends Section {
locales: StrsItem[];
}
export declare enum KeyboardSettings {
none = 0,
normalizationDisabled
}
export declare class Meta extends Section {
author: StrsItem;
conform: StrsItem;
layout: StrsItem;
name: StrsItem;
indicator: StrsItem;
version: StrsItem;
settings: KeyboardSettings;
/** convenience for checking settings */
get normalizationDisabled(): number;
}
/**
* A string item in memory. This will be replaced with an index
* into the string table at finalization.
*/
export declare class StrsItem {
/** string value */
readonly value: string;
/** char value if this is a single-char placeholder item (CharStrsItem) */
readonly char?: number;
constructor(value: string, char?: number);
compareTo(o: StrsItem): number;
static binaryStringCompare(a: string, b: string): number;
get isOneChar(): boolean;
isEqual(a: StrsItem): boolean;
}
/**
* A StrsItem for a single char. Used as a placeholder and hint to the builder
*/
export declare class CharStrsItem extends StrsItem {
constructor(value: string);
}
/** class for string manipulation options. These are in order of the pipeline. */
export interface StrsOptions {
/** apply string variables (requires sections) */
stringVariables?: boolean;
/** apply markers (requires sections) */
markers?: boolean;
/** unescape with unescapeString */
unescape?: boolean;
/** apply (possibly marker safe) nfd. Not for regex use. */
nfd?: boolean;
/** string can be stored as a single CharStrsItem, not in strs table. */
singleOk?: boolean;
}
export declare class Strs extends Section {
/** the in-memory string table */
strings: StrsItem[];
/** for validating */
allProcessedStrings: Set<string>;
/**
* Allocate a StrsItem given the string, unescaping if necessary.
* @param s escaped string
* @param opts options for allocation
* @param sections other sections, if needed
* @returns StrsItem
*/
allocString(s?: string, opts?: StrsOptions, sections?: DependencySections): StrsItem;
/** process everything according to opts, and add the string to this.allProcessedStrings */
private processString;
}
/**
* See LKVariables
*/
export declare class Vars extends Section {
totalCount(): number;
markers: ListItem;
strings: StringVarItem[];
sets: SetVarItem[];
usets: UnicodeSetItem[];
/**
*
* @returns false if any invalid variables
*/
valid(): boolean;
substituteSets(str: string, sections: DependencySections): string;
substituteUnicodeSets(value: string, sections: DependencySections): string;
substituteStrings(str: string, sections: DependencySections, forMatch?: boolean): string;
findStringVariableValue(id: string): string;
substituteSetRegex(str: string, sections: DependencySections): string;
/**
* Variable locator facility
* @param array
* @param id
* @returns
*/
private static findVariable;
substituteMarkerString(s: string, forMatch?: boolean): string;
}
/**
* Common base for variable sections
* See Variable
*/
export declare class VarsItem extends Section {
id: StrsItem;
value: StrsItem;
constructor(id: string, value: string, sections: DependencySections);
valid(): boolean;
}
export declare class UnicodeSetItem extends VarsItem {
constructor(id: string, value: string, sections: DependencySections, usetparser: UnicodeSetParser);
unicodeSet?: UnicodeSet;
valid(): boolean;
}
export declare class SetVarItem extends VarsItem {
constructor(id: string, value: string[], sections: DependencySections, rawItems: string[]);
items: ElementString;
rawItems: string[];
valid(): boolean;
}
export declare class StringVarItem extends VarsItem {
constructor(id: string, value: string, sections: DependencySections);
}
export declare class TranTransform {
from: StrsItem;
to: StrsItem;
mapFrom: StrsItem;
mapTo: StrsItem;
}
export declare class TranGroup {
type: number;
transforms: TranTransform[];
reorders: TranReorder[];
}
export declare class TranReorder {
elements: ElementString;
before: ElementString;
}
export declare class Tran extends Section {
groups: TranGroup[];
get id(): import("@keymanapp/ldml-keyboard-constants").SectionIdent;
}
export declare class UsetItem {
uset: UnicodeSet;
str: StrsItem;
constructor(uset: UnicodeSet, str: StrsItem);
compareTo(other: UsetItem): number;
}
export declare class Uset extends Section {
usets: UsetItem[];
allocUset(set: UnicodeSet, sections: DependencySections): UsetItem;
}
export declare class Bksp extends Tran {
get id(): import("@keymanapp/ldml-keyboard-constants").SectionIdent;
}
export declare class DispItem {
to: StrsItem;
id: StrsItem;
display: StrsItem;
}
export declare class Disp extends Section {
baseCharacter: StrsItem;
disps: DispItem[];
}
/**
* In-memory `<layers>`
*/
export declare class LayrList {
hardware: StrsItem;
layers: LayrEntry[];
minDeviceWidth: number;
}
/**
* In-memory `<layer>`
*/
export declare class LayrEntry {
id: StrsItem;
mod: number;
rows: LayrRow[];
}
/**
* In-memory `<row>`
*/
export declare class LayrRow {
keys: StrsItem[];
}
export declare class Layr extends Section {
lists: LayrList[];
}
export declare class KeysKeys {
flags: number;
flicks: string;
id: StrsItem;
longPress: ListItem;
longPressDefault: StrsItem;
multiTap: ListItem;
switch: StrsItem;
to: StrsItem;
width: number;
}
export declare class KeysKmap {
vkey: number;
mod: number;
key: string;
}
export declare class KeysFlicks {
flicks: KeysFlick[];
id: StrsItem;
compareTo(b: KeysFlicks): number;
constructor(id: StrsItem);
}
export declare class KeysFlick {
directions: ListItem;
keyId: StrsItem;
}
export declare class Keys extends Section {
keys: KeysKeys[];
flicks: KeysFlicks[];
kmap: KeysKmap[];
constructor(strs: Strs);
}
export declare class List extends Section {
/**
* Allocate a list from a space-separated list of items.
* Note that passing undefined or null or `''` will
* end up being the same as the empty list `[]`
* @param s space-separated list of items
* @param opts string options
* @param sections sections
* @returns a List object
*/
allocListFromSpaces(s: string, opts: StrsOptions, sections: DependencySections): ListItem;
/**
* Return a List object referring to the string list.
* Note that a falsy list, or a list containing only an empty string
* `['']` will be stored as an empty list `[]`.
* @param strs Strs section for allocation
* @param s string list to allocate
* @returns
*/
allocList(s: string[], opts: StrsOptions, sections: DependencySections): ListItem;
constructor(strs: Strs);
lists: ListItem[];
}
export { ListItem as ListItem };
export interface KMXPlusData {
sect?: Strs;
bksp?: Bksp;
disp?: Disp;
elem?: Elem;
keys?: Keys;
layr?: Layr;
list?: List;
loca?: Loca;
meta?: Meta;
strs?: Strs;
tran?: Tran;
uset?: Uset;
vars?: Vars;
}
export declare class KMXPlusFile extends KMXFile {
readonly COMP_PLUS_SECT_ITEM: any;
readonly COMP_PLUS_SECT: any;
readonly COMP_PLUS_BKSP_ITEM: any;
readonly COMP_PLUS_BKSP: any;
readonly COMP_PLUS_DISP_ITEM: any;
readonly COMP_PLUS_DISP: any;
readonly COMP_PLUS_ELEM_ELEMENT: any;
readonly COMP_PLUS_ELEM_STRING: any;
readonly COMP_PLUS_ELEM: any;
readonly COMP_PLUS_LAYR_ENTRY: any;
readonly COMP_PLUS_LAYR_KEY: any;
readonly COMP_PLUS_LAYR_LIST: any;
readonly COMP_PLUS_LAYR_ROW: any;
readonly COMP_PLUS_LAYR: any;
readonly COMP_PLUS_KEYS_FLICK: any;
readonly COMP_PLUS_KEYS_FLICKS: any;
readonly COMP_PLUS_KEYS_KEY: any;
readonly COMP_PLUS_KEYS_KMAP: any;
readonly COMP_PLUS_KEYS: any;
readonly COMP_PLUS_LIST_LIST: any;
readonly COMP_PLUS_LIST_INDEX: any;
readonly COMP_PLUS_LIST: any;
readonly COMP_PLUS_LOCA_ITEM: any;
readonly COMP_PLUS_LOCA: any;
readonly COMP_PLUS_META: any;
readonly COMP_PLUS_STRS_ITEM: any;
readonly COMP_PLUS_STRS: any;
readonly COMP_PLUS_TRAN_GROUP: any;
readonly COMP_PLUS_TRAN_TRANSFORM: any;
readonly COMP_PLUS_TRAN_REORDER: any;
readonly COMP_PLUS_TRAN: any;
readonly COMP_PLUS_USET_USET: any;
readonly COMP_PLUS_USET_RANGE: any;
readonly COMP_PLUS_USET: any;
readonly COMP_PLUS_VKEY_ITEM: any;
readonly COMP_PLUS_VKEY: any;
readonly COMP_PLUS_VARS: any;
readonly COMP_PLUS_VARS_ITEM: any;
kmxplus: KMXPlusData;
constructor();
}
//# sourceMappingURL=kmx-plus.d.ts.map