@keymanapp/kmc-ldml 17.0.104-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/compiler/compiler-options.d.ts +11 -0
- package/build/src/compiler/compiler-options.d.ts.map +1 -0
- package/build/src/compiler/compiler-options.js +3 -0
- package/build/src/compiler/compiler-options.js.map +1 -0
- package/build/src/compiler/compiler.d.ts +38 -0
- package/build/src/compiler/compiler.d.ts.map +1 -0
- package/build/src/compiler/compiler.js +144 -0
- package/build/src/compiler/compiler.js.map +1 -0
- package/build/src/compiler/disp.d.ts +10 -0
- package/build/src/compiler/disp.d.ts.map +1 -0
- package/build/src/compiler/disp.js +37 -0
- package/build/src/compiler/disp.js.map +1 -0
- package/build/src/compiler/keymanweb-compiler.d.ts +16 -0
- package/build/src/compiler/keymanweb-compiler.d.ts.map +1 -0
- package/build/src/compiler/keymanweb-compiler.js +96 -0
- package/build/src/compiler/keymanweb-compiler.js.map +1 -0
- package/build/src/compiler/keys.d.ts +26 -0
- package/build/src/compiler/keys.d.ts.map +1 -0
- package/build/src/compiler/keys.js +207 -0
- package/build/src/compiler/keys.js.map +1 -0
- package/build/src/compiler/layr.d.ts +10 -0
- package/build/src/compiler/layr.d.ts.map +1 -0
- package/build/src/compiler/layr.js +79 -0
- package/build/src/compiler/layr.js.map +1 -0
- package/build/src/compiler/loca.d.ts +16 -0
- package/build/src/compiler/loca.d.ts.map +1 -0
- package/build/src/compiler/loca.js +58 -0
- package/build/src/compiler/loca.js.map +1 -0
- package/build/src/compiler/messages.d.ts +93 -0
- package/build/src/compiler/messages.d.ts.map +1 -0
- package/build/src/compiler/messages.js +54 -0
- package/build/src/compiler/messages.js.map +1 -0
- package/build/src/compiler/meta.d.ts +12 -0
- package/build/src/compiler/meta.d.ts.map +1 -0
- package/build/src/compiler/meta.js +58 -0
- package/build/src/compiler/meta.js.map +1 -0
- package/build/src/compiler/metadata-compiler.d.ts +13 -0
- package/build/src/compiler/metadata-compiler.d.ts.map +1 -0
- package/build/src/compiler/metadata-compiler.js +47 -0
- package/build/src/compiler/metadata-compiler.js.map +1 -0
- package/build/src/compiler/name.d.ts +10 -0
- package/build/src/compiler/name.d.ts.map +1 -0
- package/build/src/compiler/name.js +20 -0
- package/build/src/compiler/name.js.map +1 -0
- package/build/src/compiler/ordr.d.ts +12 -0
- package/build/src/compiler/ordr.d.ts.map +1 -0
- package/build/src/compiler/ordr.js +35 -0
- package/build/src/compiler/ordr.js.map +1 -0
- package/build/src/compiler/section-compiler.d.ts +12 -0
- package/build/src/compiler/section-compiler.d.ts.map +1 -0
- package/build/src/compiler/section-compiler.js +22 -0
- package/build/src/compiler/section-compiler.js.map +1 -0
- package/build/src/compiler/touch-layout-compiler.d.ts +8 -0
- package/build/src/compiler/touch-layout-compiler.d.ts.map +1 -0
- package/build/src/compiler/touch-layout-compiler.js +87 -0
- package/build/src/compiler/touch-layout-compiler.js.map +1 -0
- package/build/src/compiler/tran.d.ts +41 -0
- package/build/src/compiler/tran.d.ts.map +1 -0
- package/build/src/compiler/tran.js +102 -0
- package/build/src/compiler/tran.js.map +1 -0
- package/build/src/compiler/visual-keyboard-compiler.d.ts +7 -0
- package/build/src/compiler/visual-keyboard-compiler.d.ts.map +1 -0
- package/build/src/compiler/visual-keyboard-compiler.js +51 -0
- package/build/src/compiler/visual-keyboard-compiler.js.map +1 -0
- package/build/src/compiler/vkey.d.ts +10 -0
- package/build/src/compiler/vkey.d.ts.map +1 -0
- package/build/src/compiler/vkey.js +59 -0
- package/build/src/compiler/vkey.js.map +1 -0
- package/build/src/kpj.schema.json +127 -0
- package/build/src/kvks.schema.json +182 -0
- package/build/src/ldml-keyboard.schema.json +702 -0
- package/build/src/ldml-keyboardtest.schema.json +221 -0
- package/build/src/main.d.ts +9 -0
- package/build/src/main.d.ts.map +1 -0
- package/build/src/main.js +8 -0
- package/build/src/main.js.map +1 -0
- package/build/src/util/util.d.ts +32 -0
- package/build/src/util/util.d.ts.map +1 -0
- package/build/src/util/util.js +85 -0
- package/build/src/util/util.js.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LDMLKeyboard, KMXPlus, CompilerCallbacks } from "@keymanapp/common-types";
|
|
2
|
+
import { SectionIdent } from '@keymanapp/ldml-keyboard-constants';
|
|
3
|
+
export declare class SectionCompiler {
|
|
4
|
+
protected readonly keyboard: LDMLKeyboard.LKKeyboard;
|
|
5
|
+
protected readonly callbacks: CompilerCallbacks;
|
|
6
|
+
constructor(source: LDMLKeyboard.LDMLKeyboardXMLSourceFile, callbacks: CompilerCallbacks);
|
|
7
|
+
get id(): SectionIdent;
|
|
8
|
+
get required(): boolean;
|
|
9
|
+
compile(sections: KMXPlus.GlobalSections): KMXPlus.Section;
|
|
10
|
+
validate(): boolean;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=section-compiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-compiler.d.ts","sourceRoot":"","sources":["../../../src/compiler/section-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAGlE,qBAAa,eAAe;IAC1B,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,UAAU,CAAC;IACrD,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;gBAEpC,MAAM,EAAE,YAAY,CAAC,yBAAyB,EAAE,SAAS,EAAE,iBAAiB;IAKxF,IAAW,EAAE,IAAI,YAAY,CAE5B;IAED,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAEM,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,OAAO;IAI1D,QAAQ,IAAI,OAAO;CAG3B"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* istanbul ignore next */
|
|
2
|
+
export class SectionCompiler {
|
|
3
|
+
keyboard;
|
|
4
|
+
callbacks;
|
|
5
|
+
constructor(source, callbacks) {
|
|
6
|
+
this.keyboard = source.keyboard;
|
|
7
|
+
this.callbacks = callbacks;
|
|
8
|
+
}
|
|
9
|
+
get id() {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
get required() {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
compile(sections) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
validate() {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=section-compiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-compiler.js","sourceRoot":"","sources":["../../../src/compiler/section-compiler.ts"],"names":[],"mappings":"AAGA,0BAA0B;AAC1B,MAAM,OAAO,eAAe;IACP,QAAQ,CAA0B;IAClC,SAAS,CAAoB;IAEhD,YAAY,MAA8C,EAAE,SAA4B;QACtF,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,IAAW,EAAE;QACX,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,OAAO,CAAC,QAAgC;QAC7C,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,QAAQ;QACb,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TouchLayout, LDMLKeyboard } from "@keymanapp/common-types";
|
|
2
|
+
export declare class TouchLayoutCompiler {
|
|
3
|
+
compileToJavascript(source: LDMLKeyboard.LDMLKeyboardXMLSourceFile): TouchLayout.TouchLayoutFile;
|
|
4
|
+
private compileHardwareLayer;
|
|
5
|
+
private translateLayerIdToTouchLayoutLayerId;
|
|
6
|
+
private translateKeyIdentifierToTouch;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=touch-layout-compiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"touch-layout-compiler.d.ts","sourceRoot":"","sources":["../../../src/compiler/touch-layout-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEpE,qBAAa,mBAAmB;IACvB,mBAAmB,CAAC,MAAM,EAAE,YAAY,CAAC,yBAAyB,GAAG,WAAW,CAAC,eAAe;IAkBvG,OAAO,CAAC,oBAAoB;IAuC5B,OAAO,CAAC,oCAAoC;IAmC5C,OAAO,CAAC,6BAA6B;CAatC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export class TouchLayoutCompiler {
|
|
2
|
+
compileToJavascript(source) {
|
|
3
|
+
let result = {};
|
|
4
|
+
// start with desktop to mimic vk emit
|
|
5
|
+
result.desktop = {
|
|
6
|
+
defaultHint: "none",
|
|
7
|
+
layer: []
|
|
8
|
+
};
|
|
9
|
+
for (let layers of source.keyboard.layers) {
|
|
10
|
+
for (let layer of layers.layer) {
|
|
11
|
+
const resultLayer = this.compileHardwareLayer(source, result, layer);
|
|
12
|
+
result.desktop.layer.push(resultLayer);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
compileHardwareLayer(source, file, layer) {
|
|
18
|
+
// TODO-LDML: consider consolidation with keys.ts?
|
|
19
|
+
let fileLayer = {
|
|
20
|
+
id: this.translateLayerIdToTouchLayoutLayerId(layer.id, layer.modifier),
|
|
21
|
+
row: []
|
|
22
|
+
};
|
|
23
|
+
let y = -1;
|
|
24
|
+
for (let row of layer.row) {
|
|
25
|
+
y++;
|
|
26
|
+
let fileRow = { id: y, key: [] };
|
|
27
|
+
fileLayer.row.push(fileRow);
|
|
28
|
+
const keys = row.keys.split(' ');
|
|
29
|
+
for (let key of keys) {
|
|
30
|
+
const keydef = source.keyboard.keys?.key?.find(x => x.id == key);
|
|
31
|
+
if (keydef) {
|
|
32
|
+
const fileKey = {
|
|
33
|
+
id: this.translateKeyIdentifierToTouch(keydef.id),
|
|
34
|
+
text: keydef.to || '',
|
|
35
|
+
// TODO-LDML: additional properties
|
|
36
|
+
};
|
|
37
|
+
fileRow.key.push(fileKey);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// TODO-LDML: consider logging missing keys
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return fileLayer;
|
|
45
|
+
}
|
|
46
|
+
translateLayerIdToTouchLayoutLayerId(id, modifier) {
|
|
47
|
+
// Touch layout layers have a set of reserved names that correspond to
|
|
48
|
+
// hardware modifiers. We want to map these identifiers first before falling
|
|
49
|
+
// back to the layer ids
|
|
50
|
+
// The set of recognized layer identifiers is:
|
|
51
|
+
//
|
|
52
|
+
// touch | LDML
|
|
53
|
+
// ---------------+-------------
|
|
54
|
+
// default | none
|
|
55
|
+
// shift | shift
|
|
56
|
+
// caps | caps
|
|
57
|
+
// rightalt | altR
|
|
58
|
+
// rightalt-shift | altR shift
|
|
59
|
+
//
|
|
60
|
+
const map = {
|
|
61
|
+
none: 'default',
|
|
62
|
+
shift: 'shift',
|
|
63
|
+
caps: 'caps',
|
|
64
|
+
altR: 'rightalt',
|
|
65
|
+
"altR shift": 'rightalt-shift'
|
|
66
|
+
};
|
|
67
|
+
// canonicalize modifier string, alphabetical
|
|
68
|
+
modifier = (modifier || '').split(/\b/).sort().join(' ').trim();
|
|
69
|
+
if (Object.hasOwn(map, modifier)) {
|
|
70
|
+
return map[modifier];
|
|
71
|
+
}
|
|
72
|
+
// TODO-LDML: Other layer names will be used unmodified, is this sufficient?
|
|
73
|
+
return id;
|
|
74
|
+
}
|
|
75
|
+
translateKeyIdentifierToTouch(id) {
|
|
76
|
+
// Note: keys identifiers in kmx were traditionally case-insensitive, but we
|
|
77
|
+
// are going to use them as case-insensitive for LDML keyboards. The set of
|
|
78
|
+
// standard key identifiers a-z, A-Z, 0-9 will be used, where possible, and
|
|
79
|
+
// all other keys will be mapped to `T_key`.
|
|
80
|
+
if (id.match(/^[0-9a-zA-Z]$/)) {
|
|
81
|
+
return 'K_' + id;
|
|
82
|
+
}
|
|
83
|
+
// Not a standard key
|
|
84
|
+
return 'T_' + id;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=touch-layout-compiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"touch-layout-compiler.js","sourceRoot":"","sources":["../../../src/compiler/touch-layout-compiler.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,mBAAmB;IACvB,mBAAmB,CAAC,MAA8C;QACvE,IAAI,MAAM,GAAgC,EAAE,CAAC;QAE7C,sCAAsC;QACtC,MAAM,CAAC,OAAO,GAAG;YACf,WAAW,EAAE,MAAM;YACnB,KAAK,EAAE,EAAE;SACV,CAAC;QAEF,KAAI,IAAI,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE;YACxC,KAAI,IAAI,KAAK,IAAI,MAAM,CAAC,KAAK,EAAE;gBAC7B,MAAM,WAAW,GAAG,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;gBACrE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;aACxC;SACF;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,oBAAoB,CAC1B,MAA8C,EAC9C,IAAiC,EACjC,KAA2B;QAE3B,kDAAkD;QAElD,IAAI,SAAS,GAAiC;YAC5C,EAAE,EAAE,IAAI,CAAC,oCAAoC,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,QAAQ,CAAC;YACvE,GAAG,EAAE,EAAE;SACR,CAAC;QAEF,IAAI,CAAC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gBAAgB;SAC/B,CAAC;QAEF,6CAA6C;QAC7C,QAAQ,GAAG,CAAC,QAAQ,IAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QAE9D,IAAG,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAE;YAC/B,OAAQ,GAAW,CAAC,QAAQ,CAAC,CAAC;SAC/B;QAED,4EAA4E;QAC5E,OAAO,EAAE,CAAC;IACZ,CAAC;IAEO,6BAA6B,CAAC,EAAU;QAC9C,4EAA4E;QAC5E,2EAA2E;QAC3E,2EAA2E;QAC3E,4CAA4C;QAE5C,IAAG,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE;YAC5B,OAAO,IAAI,GAAC,EAAE,CAAC;SAChB;QAED,qBAAqB;QACrB,OAAO,IAAI,GAAC,EAAE,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { KMXPlus, LDMLKeyboard, CompilerCallbacks } from '@keymanapp/common-types';
|
|
2
|
+
import { SectionCompiler } from "./section-compiler.js";
|
|
3
|
+
import Finl = KMXPlus.Finl;
|
|
4
|
+
import FinlItem = KMXPlus.FinlItem;
|
|
5
|
+
import Bksp = KMXPlus.Bksp;
|
|
6
|
+
import BkspItem = KMXPlus.BkspItem;
|
|
7
|
+
import GlobalSections = KMXPlus.GlobalSections;
|
|
8
|
+
import Tran = KMXPlus.Tran;
|
|
9
|
+
import TranItem = KMXPlus.TranItem;
|
|
10
|
+
import LDMLKeyboardXMLSourceFile = LDMLKeyboard.LDMLKeyboardXMLSourceFile;
|
|
11
|
+
type TransformCompilerType = 'simple' | 'final' | 'backspace';
|
|
12
|
+
declare class TransformCompiler<T extends TransformCompilerType, TranBase extends Tran, TranItemBase extends TranItem> extends SectionCompiler {
|
|
13
|
+
protected type: T;
|
|
14
|
+
constructor(source: LDMLKeyboardXMLSourceFile, callbacks: CompilerCallbacks);
|
|
15
|
+
validate(): boolean;
|
|
16
|
+
protected newTranItem(): TranItemBase;
|
|
17
|
+
protected newTran(): TranBase;
|
|
18
|
+
private compileTransform;
|
|
19
|
+
private compileTransforms;
|
|
20
|
+
compile(sections: GlobalSections): TranBase;
|
|
21
|
+
}
|
|
22
|
+
export declare class TranCompiler extends TransformCompiler<'simple', Tran, TranItem> {
|
|
23
|
+
constructor(source: LDMLKeyboardXMLSourceFile, callbacks: CompilerCallbacks);
|
|
24
|
+
protected newTranItem(): TranItem;
|
|
25
|
+
protected newTran(): Tran;
|
|
26
|
+
get id(): import("@keymanapp/ldml-keyboard-constants").SectionIdent;
|
|
27
|
+
}
|
|
28
|
+
export declare class FinlCompiler extends TransformCompiler<'final', Finl, FinlItem> {
|
|
29
|
+
constructor(source: LDMLKeyboardXMLSourceFile, callbacks: CompilerCallbacks);
|
|
30
|
+
protected newTranItem(): FinlItem;
|
|
31
|
+
protected newTran(): Finl;
|
|
32
|
+
get id(): import("@keymanapp/ldml-keyboard-constants").SectionIdent;
|
|
33
|
+
}
|
|
34
|
+
export declare class BkspCompiler extends TransformCompiler<'backspace', Bksp, BkspItem> {
|
|
35
|
+
constructor(source: LDMLKeyboardXMLSourceFile, callbacks: CompilerCallbacks);
|
|
36
|
+
protected newTranItem(): BkspItem;
|
|
37
|
+
protected newTran(): Bksp;
|
|
38
|
+
get id(): import("@keymanapp/ldml-keyboard-constants").SectionIdent;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=tran.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tran.d.ts","sourceRoot":"","sources":["../../../src/compiler/tran.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,O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BAAyB,EAAE,SAAS,EAAE,iBAAiB;IAI3E,SAAS,CAAC,WAAW,IAAI,QAAQ;IAGjC,SAAS,CAAC,OAAO,IAAI,IAAI;IAGzB,IAAW,EAAE,8DAEZ;CACF;AAED,qBAAa,YAAa,SAAQ,iBAAiB,CAAC,WAAW,EAAE,IAAI,EAAE,QAAQ,CAAC;gBAClE,MAAM,EAAE,yBAAyB,EAAE,SAAS,EAAE,iBAAiB;IAI3E,SAAS,CAAC,WAAW,IAAI,QAAQ;IAGjC,SAAS,CAAC,OAAO,IAAI,IAAI;IAGzB,IAAW,EAAE,8DAEZ;CACF"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { constants } from "@keymanapp/ldml-keyboard-constants";
|
|
2
|
+
import { KMXPlus } from '@keymanapp/common-types';
|
|
3
|
+
import { SectionCompiler } from "./section-compiler.js";
|
|
4
|
+
var Finl = KMXPlus.Finl;
|
|
5
|
+
var FinlItem = KMXPlus.FinlItem;
|
|
6
|
+
var Bksp = KMXPlus.Bksp;
|
|
7
|
+
var BkspItem = KMXPlus.BkspItem;
|
|
8
|
+
var Tran = KMXPlus.Tran;
|
|
9
|
+
var TranItem = KMXPlus.TranItem;
|
|
10
|
+
var TranItemFlags = KMXPlus.TranItemFlags;
|
|
11
|
+
class TransformCompiler extends SectionCompiler {
|
|
12
|
+
type;
|
|
13
|
+
constructor(source, callbacks) {
|
|
14
|
+
super(source, callbacks);
|
|
15
|
+
}
|
|
16
|
+
validate() {
|
|
17
|
+
let valid = true;
|
|
18
|
+
// TODO-LDML: linting here should check for identical before+from, but this involves a double-parse which is ugly
|
|
19
|
+
// TODO-LDML: unicodesets means that either we fully parse them and verify conflicting rules or the linting is imperfect
|
|
20
|
+
return valid;
|
|
21
|
+
}
|
|
22
|
+
newTranItem() {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
newTran() {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
compileTransform(sections, transform) {
|
|
29
|
+
let result = this.newTranItem();
|
|
30
|
+
result.from = sections.elem.allocElementString(sections.strs, transform.from);
|
|
31
|
+
result.to = sections.strs.allocAndUnescapeString(transform.to);
|
|
32
|
+
result.before = sections.elem.allocElementString(sections.strs, transform.before);
|
|
33
|
+
result.flags = transform.error == 'fail' ? TranItemFlags.error : TranItemFlags.none;
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
compileTransforms(sections, transforms) {
|
|
37
|
+
let result = this.newTran();
|
|
38
|
+
if (transforms?.transform) {
|
|
39
|
+
for (let transform of transforms.transform) {
|
|
40
|
+
result.items.push(this.compileTransform(sections, transform));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
compile(sections) {
|
|
46
|
+
for (let t of this.keyboard.transforms) {
|
|
47
|
+
if (t.type == this.type) {
|
|
48
|
+
return this.compileTransforms(sections, t);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return this.newTran();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export class TranCompiler extends TransformCompiler {
|
|
55
|
+
constructor(source, callbacks) {
|
|
56
|
+
super(source, callbacks);
|
|
57
|
+
this.type = 'simple';
|
|
58
|
+
}
|
|
59
|
+
newTranItem() {
|
|
60
|
+
return new TranItem();
|
|
61
|
+
}
|
|
62
|
+
newTran() {
|
|
63
|
+
return new Tran();
|
|
64
|
+
}
|
|
65
|
+
get id() {
|
|
66
|
+
return constants.section.tran;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
;
|
|
70
|
+
export class FinlCompiler extends TransformCompiler {
|
|
71
|
+
constructor(source, callbacks) {
|
|
72
|
+
super(source, callbacks);
|
|
73
|
+
this.type = 'final';
|
|
74
|
+
}
|
|
75
|
+
newTranItem() {
|
|
76
|
+
return new FinlItem();
|
|
77
|
+
}
|
|
78
|
+
newTran() {
|
|
79
|
+
return new Finl();
|
|
80
|
+
}
|
|
81
|
+
get id() {
|
|
82
|
+
return constants.section.finl;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
;
|
|
86
|
+
export class BkspCompiler extends TransformCompiler {
|
|
87
|
+
constructor(source, callbacks) {
|
|
88
|
+
super(source, callbacks);
|
|
89
|
+
this.type = 'backspace';
|
|
90
|
+
}
|
|
91
|
+
newTranItem() {
|
|
92
|
+
return new BkspItem();
|
|
93
|
+
}
|
|
94
|
+
newTran() {
|
|
95
|
+
return new Bksp();
|
|
96
|
+
}
|
|
97
|
+
get id() {
|
|
98
|
+
return constants.section.bksp;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
;
|
|
102
|
+
//# sourceMappingURL=tran.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tran.js","sourceRoot":"","sources":["../../../src/compiler/tran.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAmC,MAAM,yBAAyB,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,IAAO,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;AAC3B,IAAO,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;AACnC,IAAO,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;AAC3B,IAAO,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;AAEnC,IAAO,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;AAC3B,IAAO,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;AACnC,IAAO,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;AAO7C,MAAM,iBAAyG,SAAQ,eAAe;IAE1H,IAAI,CAAI;IAElB,YAAY,MAAiC,EAAE,SAA4B;QACzE,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC3B,CAAC;IAEM,QAAQ;QACb,IAAI,KAAK,GAAG,IAAI,CAAC;QACjB,iHAA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AC;IACD,IAAW,EAAE;QACX,OAAO,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;IAChC,CAAC;CACF;AAAA,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { VisualKeyboard, LDMLKeyboard } from "@keymanapp/common-types";
|
|
2
|
+
export default class VisualKeyboardCompiler {
|
|
3
|
+
compile(source: LDMLKeyboard.LDMLKeyboardXMLSourceFile): VisualKeyboard.VisualKeyboard;
|
|
4
|
+
private compileHardwareLayer;
|
|
5
|
+
private translateLayerIdToVisualKeyboardShift;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=visual-keyboard-compiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visual-keyboard-compiler.d.ts","sourceRoot":"","sources":["../../../src/compiler/visual-keyboard-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,cAAc,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAElF,MAAM,CAAC,OAAO,OAAO,sBAAsB;IAClC,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,yBAAyB,GAAG,cAAc,CAAC,cAAc;IAwB7F,OAAO,CAAC,oBAAoB;IA6B5B,OAAO,CAAC,qCAAqC;CAO9C"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Constants, VisualKeyboard } from "@keymanapp/common-types";
|
|
2
|
+
export default class VisualKeyboardCompiler {
|
|
3
|
+
compile(source) {
|
|
4
|
+
let result = new VisualKeyboard.VisualKeyboard();
|
|
5
|
+
/* TODO-LDML: consider VisualKeyboardHeaderFlags.kvkhUseUnderlying kvkhDisplayUnderlying kvkhAltGr kvkh102 */
|
|
6
|
+
result.header.flags = 0;
|
|
7
|
+
result.header.version = 0x0600;
|
|
8
|
+
/* TODO-LDML: consider font, associatedKeyboard */
|
|
9
|
+
result.header.associatedKeyboard = '';
|
|
10
|
+
result.header.ansiFont.name = 'Arial';
|
|
11
|
+
result.header.ansiFont.size = 10;
|
|
12
|
+
result.header.ansiFont.color = 0;
|
|
13
|
+
result.header.unicodeFont.name = 'Arial';
|
|
14
|
+
result.header.unicodeFont.size = 10;
|
|
15
|
+
result.header.unicodeFont.color = 0;
|
|
16
|
+
for (let layers of source.keyboard.layers) {
|
|
17
|
+
for (let layer of layers.layer) {
|
|
18
|
+
this.compileHardwareLayer(source, result, layer);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
compileHardwareLayer(source, vk, layer) {
|
|
24
|
+
// TODO-LDML: consider consolidation with keys.ts?
|
|
25
|
+
const shift = this.translateLayerIdToVisualKeyboardShift(layer.id);
|
|
26
|
+
let y = -1;
|
|
27
|
+
for (let row of layer.row) {
|
|
28
|
+
y++;
|
|
29
|
+
const keys = row.keys.split(' ');
|
|
30
|
+
let x = -1;
|
|
31
|
+
for (let key of keys) {
|
|
32
|
+
x++;
|
|
33
|
+
let keydef = source.keyboard.keys?.key?.find(x => x.id == key);
|
|
34
|
+
vk.keys.push({
|
|
35
|
+
flags: 2 /* VisualKeyboard.VisualKeyboardKeyFlags.kvkkUnicode */,
|
|
36
|
+
shift: shift,
|
|
37
|
+
text: keydef.to,
|
|
38
|
+
vkey: Constants.USVirtualKeyMap[y][x] // TODO-LDML: #7965 US-only
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
translateLayerIdToVisualKeyboardShift(id) {
|
|
44
|
+
if (id == 'base') {
|
|
45
|
+
return 0;
|
|
46
|
+
}
|
|
47
|
+
// TODO-LDML: other modifiers
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=visual-keyboard-compiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visual-keyboard-compiler.js","sourceRoot":"","sources":["../../../src/compiler/visual-keyboard-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SA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AAI,KAAK,CAAC,GAAG,EAAE;YACxB,CAAC,EAAE,CAAC;YAEJ,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACjC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YACX,KAAI,IAAI,GAAG,IAAI,IAAI,EAAE;gBACnB,CAAC,EAAE,CAAC;gBAEJ,IAAI,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC;gBAE/D,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;oBACX,KAAK,2DAAmD;oBACxD,KAAK,EAAE,KAAK;oBACZ,IAAI,EAAE,MAAM,CAAC,EAAE;oBACf,IAAI,EAAE,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,4BAA4B;iBACnE,CAAC,CAAC;aACJ;SACF;IACH,CAAC;IAEO,qCAAqC,CAAC,EAAU;QACtD,IAAG,EAAE,IAAI,MAAM,EAAE;YACf,OAAO,CAAC,CAAC;SACV;QACD,6BAA6B;QAC7B,OAAO,CAAC,CAAC;IACX,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { KMXPlus } from '@keymanapp/common-types';
|
|
2
|
+
import { SectionCompiler } from "./section-compiler.js";
|
|
3
|
+
import Vkey = KMXPlus.Vkey;
|
|
4
|
+
export declare class VkeyCompiler extends SectionCompiler {
|
|
5
|
+
get id(): import("@keymanapp/ldml-keyboard-constants").SectionIdent;
|
|
6
|
+
get required(): boolean;
|
|
7
|
+
validate(): boolean;
|
|
8
|
+
compile(): Vkey;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=vkey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vkey.d.ts","sourceRoot":"","sources":["../../../src/compiler/vkey.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAa,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;AAG3B,qBAAa,YAAa,SAAQ,eAAe;IAE/C,IAAW,EAAE,8DAEZ;IAED,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAEM,QAAQ,IAAI,OAAO;IAmCnB,OAAO,IAAI,IAAI;CAgBvB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { constants } from "@keymanapp/ldml-keyboard-constants";
|
|
2
|
+
import { KMXPlus, Constants } from '@keymanapp/common-types';
|
|
3
|
+
import { CompilerMessages } from "./messages.js";
|
|
4
|
+
import { SectionCompiler } from "./section-compiler.js";
|
|
5
|
+
var Vkey = KMXPlus.Vkey;
|
|
6
|
+
var LdmlVkeyNames = Constants.LdmlVkeyNames;
|
|
7
|
+
export class VkeyCompiler extends SectionCompiler {
|
|
8
|
+
get id() {
|
|
9
|
+
return constants.section.vkey;
|
|
10
|
+
}
|
|
11
|
+
get required() {
|
|
12
|
+
return !!this.keyboard.vkeys;
|
|
13
|
+
}
|
|
14
|
+
validate() {
|
|
15
|
+
let valid = true;
|
|
16
|
+
if (this.keyboard.vkeys) {
|
|
17
|
+
let from = [], to = [];
|
|
18
|
+
this.keyboard.vkeys.vkey.forEach(vk => {
|
|
19
|
+
if (LdmlVkeyNames[vk.from] === undefined) {
|
|
20
|
+
this.callbacks.reportMessage(CompilerMessages.Error_VkeyIsNotValid({ vkey: vk.from }));
|
|
21
|
+
valid = false;
|
|
22
|
+
}
|
|
23
|
+
if (LdmlVkeyNames[vk.to] === undefined) {
|
|
24
|
+
this.callbacks.reportMessage(CompilerMessages.Error_VkeyIsNotValid({ vkey: vk.to }));
|
|
25
|
+
valid = false;
|
|
26
|
+
}
|
|
27
|
+
if (vk.from == vk.to) {
|
|
28
|
+
this.callbacks.reportMessage(CompilerMessages.Hint_VkeyIsRedundant({ vkey: vk.from }));
|
|
29
|
+
}
|
|
30
|
+
if (from.find(svk => svk == vk.from)) {
|
|
31
|
+
this.callbacks.reportMessage(CompilerMessages.Error_VkeyIsRepeated({ vkey: vk.from }));
|
|
32
|
+
valid = false;
|
|
33
|
+
}
|
|
34
|
+
from.push(vk.from);
|
|
35
|
+
if (to.find(svk => svk == vk.to)) {
|
|
36
|
+
this.callbacks.reportMessage(CompilerMessages.Info_MultipleVkeysHaveSameTarget({ vkey: vk.to }));
|
|
37
|
+
}
|
|
38
|
+
to.push(vk.to);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return valid;
|
|
42
|
+
}
|
|
43
|
+
compile() {
|
|
44
|
+
let result = new Vkey();
|
|
45
|
+
if (!this.keyboard.vkeys) {
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
result.vkeys = this.keyboard.vkeys?.vkey.map(vk => {
|
|
49
|
+
return {
|
|
50
|
+
vkey: LdmlVkeyNames[vk.from],
|
|
51
|
+
target: LdmlVkeyNames[vk.to]
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
// Sort according to vkey binary order, per C7043
|
|
55
|
+
result.vkeys.sort((a, b) => a.vkey - b.vkey);
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=vkey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vkey.js","sourceRoot":"","sources":["../../../src/compiler/vkey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,IAAO,IAAI,GAAG,OAAO,CAA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AAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "kpj.xsd",
|
|
3
|
+
"$schema": "http://json-schema.org/schema#",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"KeymanDeveloperProject": {
|
|
7
|
+
"properties": {
|
|
8
|
+
"Options": {
|
|
9
|
+
"$ref": "#/definitions/Options"
|
|
10
|
+
},
|
|
11
|
+
"Files": {
|
|
12
|
+
"$ref": "#/definitions/Files"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"required": [
|
|
16
|
+
"Options"
|
|
17
|
+
],
|
|
18
|
+
"additionalProperties": false,
|
|
19
|
+
"type": "object"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"required": [
|
|
23
|
+
"KeymanDeveloperProject"
|
|
24
|
+
],
|
|
25
|
+
"additionalProperties": false,
|
|
26
|
+
"definitions": {
|
|
27
|
+
"Options": {
|
|
28
|
+
"type": "object",
|
|
29
|
+
"properties": {
|
|
30
|
+
"BuildPath": {
|
|
31
|
+
"type": "string"
|
|
32
|
+
},
|
|
33
|
+
"SourcePath": {
|
|
34
|
+
"type": "string"
|
|
35
|
+
},
|
|
36
|
+
"CompilerWarningsAsErrors": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"pattern": "^(True|False)$"
|
|
39
|
+
},
|
|
40
|
+
"WarnDeprecatedCode": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"pattern": "^(True|False)$"
|
|
43
|
+
},
|
|
44
|
+
"CheckFilenameConventions": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"pattern": "^(True|False)$"
|
|
47
|
+
},
|
|
48
|
+
"ProjectType": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"pattern": "^(keyboard|lexicalmodel)$"
|
|
51
|
+
},
|
|
52
|
+
"Version": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"pattern": "^(1\\.0|2\\.0)$"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"required": [
|
|
58
|
+
],
|
|
59
|
+
"additionalProperties": false
|
|
60
|
+
},
|
|
61
|
+
"Files": {
|
|
62
|
+
"type": "object",
|
|
63
|
+
"properties": {
|
|
64
|
+
"File": {
|
|
65
|
+
"type": "array",
|
|
66
|
+
"items": {
|
|
67
|
+
"$ref": "#/definitions/File"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"additionalProperties": false,
|
|
72
|
+
"required": [
|
|
73
|
+
"File"
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
"File": {
|
|
77
|
+
"type": "object",
|
|
78
|
+
"properties": {
|
|
79
|
+
"ID": {
|
|
80
|
+
"type": "string"
|
|
81
|
+
},
|
|
82
|
+
"Filename": {
|
|
83
|
+
"type": "string"
|
|
84
|
+
},
|
|
85
|
+
"Filepath": {
|
|
86
|
+
"type": "string"
|
|
87
|
+
},
|
|
88
|
+
"FileVersion": {
|
|
89
|
+
"type": "string"
|
|
90
|
+
},
|
|
91
|
+
"FileType": {
|
|
92
|
+
"type": "string"
|
|
93
|
+
},
|
|
94
|
+
"Details": {
|
|
95
|
+
"$ref": "#/definitions/FileDetails"
|
|
96
|
+
},
|
|
97
|
+
"ParentFileID": {
|
|
98
|
+
"type": "string"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"required": [
|
|
102
|
+
"Filename"
|
|
103
|
+
],
|
|
104
|
+
"additionalProperties": false
|
|
105
|
+
},
|
|
106
|
+
"FileDetails": {
|
|
107
|
+
"type": "object",
|
|
108
|
+
"properties": {
|
|
109
|
+
"Name": {
|
|
110
|
+
"type": "string"
|
|
111
|
+
},
|
|
112
|
+
"Copyright": {
|
|
113
|
+
"type": "string"
|
|
114
|
+
},
|
|
115
|
+
"Message": {
|
|
116
|
+
"type": "string"
|
|
117
|
+
},
|
|
118
|
+
"Version": {
|
|
119
|
+
"type": "string"
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"required": [
|
|
123
|
+
],
|
|
124
|
+
"additionalProperties": false
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|