@keymanapp/kmc-ldml 17.0.299-beta → 17.0.301-beta
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.js +309 -308
- package/build/src/compiler/compiler.js.map +1 -1
- package/build/src/compiler/disp.js +84 -83
- package/build/src/compiler/disp.js.map +1 -1
- package/build/src/compiler/empty-compiler.js +116 -115
- package/build/src/compiler/empty-compiler.js.map +1 -1
- package/build/src/compiler/keymanweb-compiler.js +97 -96
- package/build/src/compiler/keymanweb-compiler.js.map +1 -1
- package/build/src/compiler/keys.js +419 -418
- package/build/src/compiler/keys.js.map +1 -1
- package/build/src/compiler/layr.js +83 -82
- package/build/src/compiler/layr.js.map +1 -1
- package/build/src/compiler/ldml-compiler-options.js +5 -4
- package/build/src/compiler/ldml-compiler-options.js.map +1 -1
- package/build/src/compiler/loca.js +61 -60
- package/build/src/compiler/loca.js.map +1 -1
- package/build/src/compiler/messages.js +120 -119
- package/build/src/compiler/messages.js.map +1 -1
- package/build/src/compiler/meta.js +57 -56
- package/build/src/compiler/meta.js.map +1 -1
- package/build/src/compiler/metadata-compiler.js +49 -48
- package/build/src/compiler/metadata-compiler.js.map +1 -1
- package/build/src/compiler/section-compiler.js +42 -41
- package/build/src/compiler/section-compiler.js.map +1 -1
- package/build/src/compiler/substitution-tracker.js +105 -104
- package/build/src/compiler/substitution-tracker.js.map +1 -1
- package/build/src/compiler/touch-layout-compiler.js +93 -92
- package/build/src/compiler/touch-layout-compiler.js.map +1 -1
- package/build/src/compiler/tran.js +382 -381
- package/build/src/compiler/tran.js.map +1 -1
- package/build/src/compiler/vars.js +236 -235
- package/build/src/compiler/vars.js.map +1 -1
- package/build/src/compiler/visual-keyboard-compiler.js +70 -69
- package/build/src/compiler/visual-keyboard-compiler.js.map +1 -1
- package/build/src/main.js +5 -4
- package/build/src/main.js.map +1 -1
- package/build/src/util/util.js +185 -184
- package/build/src/util/util.js.map +1 -1
- package/package.json +6 -6
|
@@ -1,97 +1,98 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
`${tab}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
`
|
|
61
|
-
|
|
62
|
-
// `${tab}this.
|
|
63
|
-
`${tab}this.
|
|
64
|
-
`${tab}this.
|
|
65
|
-
`${tab}this.
|
|
66
|
-
`${tab}this.
|
|
67
|
-
`${tab}this.
|
|
68
|
-
`${tab}this.
|
|
69
|
-
`${tab}this.
|
|
70
|
-
`${tab}this.
|
|
71
|
-
`${tab}this.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
// TODO-LDML:
|
|
87
|
-
//
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
`${tab}};${nl}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f6d80ce6-7f87-5261-8e0f-80ada550e59e")}catch(e){}}();
|
|
3
|
+
import { VisualKeyboard, TouchLayoutFileWriter } from "@keymanapp/common-types";
|
|
4
|
+
import { TouchLayoutCompiler } from "./touch-layout-compiler.js";
|
|
5
|
+
import { LdmlKeyboardVisualKeyboardCompiler } from "./visual-keyboard-compiler.js";
|
|
6
|
+
const MINIMUM_KMW_VERSION = '16.0';
|
|
7
|
+
export class LdmlKeyboardKeymanWebCompiler {
|
|
8
|
+
callbacks;
|
|
9
|
+
options;
|
|
10
|
+
nl;
|
|
11
|
+
tab;
|
|
12
|
+
constructor(callbacks, options) {
|
|
13
|
+
this.callbacks = callbacks;
|
|
14
|
+
this.options = { ...options };
|
|
15
|
+
this.nl = this.options.saveDebug ? "\n" : '';
|
|
16
|
+
this.tab = this.options.saveDebug ? " " : '';
|
|
17
|
+
}
|
|
18
|
+
compileVisualKeyboard(source) {
|
|
19
|
+
const nl = this.nl, tab = this.tab;
|
|
20
|
+
const vkc = new LdmlKeyboardVisualKeyboardCompiler(this.callbacks);
|
|
21
|
+
const vk = vkc.compile(source);
|
|
22
|
+
let result = `{F: ' 1em ${JSON.stringify(vk.header.unicodeFont.name)}', ` +
|
|
23
|
+
`K102: ${vk.header.flags & 1 /* VisualKeyboard.VisualKeyboardHeaderFlags.kvkh102 */ ? 1 : 0}};${nl}` + // TODO-LDML: escape ' and " in font name correctly
|
|
24
|
+
`${tab}this.KV.KLS={${nl}` +
|
|
25
|
+
`${tab}${tab}TODO_LDML: ${vk.keys.length}${nl}` +
|
|
26
|
+
// TODO-LDML: fill in KLS
|
|
27
|
+
`${tab}}`;
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
compileTouchLayout(source) {
|
|
31
|
+
const tlcompiler = new TouchLayoutCompiler();
|
|
32
|
+
const layout = tlcompiler.compileToJavascript(source);
|
|
33
|
+
const writer = new TouchLayoutFileWriter({ formatted: this.options.saveDebug });
|
|
34
|
+
return writer.compile(layout);
|
|
35
|
+
}
|
|
36
|
+
cleanName(name) {
|
|
37
|
+
let result = this.callbacks.path.basename(name, ".xml" /* KeymanFileTypes.Source.LdmlKeyboard */);
|
|
38
|
+
if (!result) {
|
|
39
|
+
throw new Error(`Invalid file name ${name}`);
|
|
40
|
+
}
|
|
41
|
+
result = result.replaceAll(/[^a-z0-9]/g, '_');
|
|
42
|
+
if (result.match(/^[0-9]/)) {
|
|
43
|
+
// Can't have a digit as initial
|
|
44
|
+
result = '_' + result;
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
compile(name, source) {
|
|
49
|
+
const nl = this.nl, tab = this.tab;
|
|
50
|
+
const sName = 'Keyboard_' + this.cleanName(name);
|
|
51
|
+
const displayUnderlying = true; // TODO-LDML
|
|
52
|
+
const modifierBitmask = 0; // TODO-LDML: define the modifiers used by this keyboard
|
|
53
|
+
const vkDictionary = ''; // TODO-LDML: vk dictionary for touch keys
|
|
54
|
+
const hasSupplementaryPlaneChars = false; // TODO-LDML
|
|
55
|
+
const isRTL = false; // TODO-LDML
|
|
56
|
+
let result = `if(typeof keyman === 'undefined') {${nl}` +
|
|
57
|
+
`${tab}console.error('Keyboard requires KeymanWeb ${MINIMUM_KMW_VERSION} or later');${nl}` +
|
|
58
|
+
`} else {${nl}` +
|
|
59
|
+
`${tab}KeymanWeb.KR(new ${sName}());${nl}` +
|
|
60
|
+
`}${nl}` +
|
|
61
|
+
`function ${sName}() {${nl}` +
|
|
62
|
+
// `${tab}${this.setupDebug()}${nl}` + ? we may use this for modifierBitmask in future
|
|
63
|
+
// `${tab}this._v=(typeof keyman!="undefined"&&typeof keyman.version=="string")?parseInt(keyman.version,10):9;${nl}` + ? we probably don't need this, it's for back-compat
|
|
64
|
+
`${tab}this.KI="${sName}";${nl}` +
|
|
65
|
+
`${tab}this.KN=${JSON.stringify(source.keyboard3.info.name)};${nl}` +
|
|
66
|
+
`${tab}this.KMINVER=${JSON.stringify(MINIMUM_KMW_VERSION)};${nl}` +
|
|
67
|
+
`${tab}this.KV=${this.compileVisualKeyboard(source)};${nl}` +
|
|
68
|
+
`${tab}this.KDU=${displayUnderlying ? '1' : '0'};${nl}` +
|
|
69
|
+
`${tab}this.KH="";${nl}` + // TODO-LDML: help text not supported
|
|
70
|
+
`${tab}this.KM=0;${nl}` + // TODO-LDML: mnemonic layout not supported for LDML keyboards
|
|
71
|
+
`${tab}this.KBVER=${JSON.stringify(source.keyboard3.version?.number || '0.0')};${nl}` +
|
|
72
|
+
`${tab}this.KMBM=${modifierBitmask};${nl}`;
|
|
73
|
+
if (isRTL) {
|
|
74
|
+
result += `${tab}this.KRTL=1;${nl}`;
|
|
75
|
+
}
|
|
76
|
+
if (hasSupplementaryPlaneChars) {
|
|
77
|
+
result += `${tab}this.KS=1;${nl}`;
|
|
78
|
+
}
|
|
79
|
+
if (vkDictionary != '') {
|
|
80
|
+
result += `${tab}this.KVKD=${JSON.stringify(vkDictionary)};${nl}`;
|
|
81
|
+
}
|
|
82
|
+
let layoutFile = this.compileTouchLayout(source);
|
|
83
|
+
if (layoutFile != '') {
|
|
84
|
+
result += `${tab}this.KVKL=${layoutFile};${nl}`;
|
|
85
|
+
}
|
|
86
|
+
// TODO-LDML: KCSS not supported
|
|
87
|
+
// TODO-LDML: embed binary keyboard for loading into Core
|
|
88
|
+
// A LDML keyboard has a no-op for its gs() (begin Unicode) function,
|
|
89
|
+
// because the functionality is embedded in Keyman Core
|
|
90
|
+
result += `${tab}this.gs=function(t,e){${nl}` +
|
|
91
|
+
`${tab}${tab}return 0;${nl}` + // TODO-LDML: we will start by embedding call into Keyman Core here
|
|
92
|
+
`${tab}};${nl}`;
|
|
93
|
+
result += `}${nl}`;
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
97
|
//# sourceMappingURL=keymanweb-compiler.js.map
|
|
98
|
+
//# debugId=f6d80ce6-7f87-5261-8e0f-80ada550e59e
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"version":3,"file":"keymanweb-compiler.js","sources":["../../../src/compiler/keymanweb-compiler.ts"],"sourceRoot":"","names":[],"mappings":";;AAAA,OAAO,EAAqB,cAAc,EAAgB,qBAAqB,EAAmB,MAAM,yBAAyB,CAAC;AAElI,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,kCAAkC,EAAE,MAAM,+BAA+B,CAAC;AAEnF,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAEnC,MAAM,OAAO,6BAA6B;IAIpB;IAHH,OAAO,CAAsB;IAC7B,EAAE,CAAS;IACX,GAAG,CAAS;IAC7B,YAAoB,SAA4B,EAAE,OAA6B;QAA3D,cAAS,GAAT,SAAS,CAAmB;QAC9C,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;QAC9B,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7C,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IAChD,CAAC;IAEM,qBAAqB,CAAC,MAA8C;QACzE,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACnC,MAAM,GAAG,GAAG,IAAI,kCAAkC,CAAC,IAAI,CAAC,SAAS,CAAC,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