@keymanapp/kmc-ldml 17.0.155-alpha → 17.0.156-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.d.ts +57 -55
- package/build/src/compiler/compiler.d.ts.map +1 -1
- package/build/src/compiler/compiler.js +198 -198
- package/build/src/compiler/compiler.js.map +1 -1
- package/build/src/compiler/disp.d.ts +14 -12
- package/build/src/compiler/disp.d.ts.map +1 -1
- package/build/src/compiler/disp.js +45 -43
- package/build/src/compiler/disp.js.map +1 -1
- package/build/src/compiler/empty-compiler.d.ts +39 -37
- package/build/src/compiler/empty-compiler.d.ts.map +1 -1
- package/build/src/compiler/empty-compiler.js +71 -69
- package/build/src/compiler/empty-compiler.js.map +1 -1
- package/build/src/compiler/keymanweb-compiler.d.ts +16 -16
- package/build/src/compiler/keymanweb-compiler.d.ts.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.d.ts +30 -28
- package/build/src/compiler/keys.d.ts.map +1 -1
- package/build/src/compiler/keys.js +240 -238
- package/build/src/compiler/keys.js.map +1 -1
- package/build/src/compiler/layr.d.ts +12 -10
- package/build/src/compiler/layr.d.ts.map +1 -1
- package/build/src/compiler/layr.js +83 -81
- package/build/src/compiler/layr.js.map +1 -1
- package/build/src/compiler/ldml-compiler-options.d.ts +10 -0
- package/build/src/compiler/ldml-compiler-options.d.ts.map +1 -0
- package/build/src/compiler/ldml-compiler-options.js +5 -0
- package/build/src/compiler/ldml-compiler-options.js.map +1 -0
- package/build/src/compiler/loca.d.ts +18 -16
- package/build/src/compiler/loca.d.ts.map +1 -1
- package/build/src/compiler/loca.js +61 -59
- package/build/src/compiler/loca.js.map +1 -1
- package/build/src/compiler/marker-tracker.d.ts +36 -34
- package/build/src/compiler/marker-tracker.d.ts.map +1 -1
- package/build/src/compiler/marker-tracker.js +75 -73
- package/build/src/compiler/marker-tracker.js.map +1 -1
- package/build/src/compiler/messages.d.ts +135 -133
- package/build/src/compiler/messages.d.ts.map +1 -1
- package/build/src/compiler/messages.js +79 -77
- package/build/src/compiler/messages.js.map +1 -1
- package/build/src/compiler/meta.d.ts +14 -12
- package/build/src/compiler/meta.d.ts.map +1 -1
- package/build/src/compiler/meta.js +60 -58
- package/build/src/compiler/meta.js.map +1 -1
- package/build/src/compiler/metadata-compiler.d.ts +15 -13
- package/build/src/compiler/metadata-compiler.d.ts.map +1 -1
- package/build/src/compiler/metadata-compiler.js +49 -47
- package/build/src/compiler/metadata-compiler.js.map +1 -1
- package/build/src/compiler/name.d.ts +12 -10
- package/build/src/compiler/name.d.ts.map +1 -1
- package/build/src/compiler/name.js +22 -20
- package/build/src/compiler/name.js.map +1 -1
- package/build/src/compiler/section-compiler.d.ts +18 -16
- package/build/src/compiler/section-compiler.d.ts.map +1 -1
- package/build/src/compiler/section-compiler.js +36 -34
- package/build/src/compiler/section-compiler.js.map +1 -1
- package/build/src/compiler/touch-layout-compiler.d.ts +10 -8
- package/build/src/compiler/touch-layout-compiler.d.ts.map +1 -1
- package/build/src/compiler/touch-layout-compiler.js +89 -87
- package/build/src/compiler/touch-layout-compiler.js.map +1 -1
- package/build/src/compiler/tran.d.ts +39 -37
- package/build/src/compiler/tran.d.ts.map +1 -1
- package/build/src/compiler/tran.js +187 -185
- package/build/src/compiler/tran.js.map +1 -1
- package/build/src/compiler/vars.d.ts +23 -21
- package/build/src/compiler/vars.d.ts.map +1 -1
- package/build/src/compiler/vars.js +221 -219
- package/build/src/compiler/vars.js.map +1 -1
- package/build/src/compiler/visual-keyboard-compiler.d.ts +9 -7
- package/build/src/compiler/visual-keyboard-compiler.d.ts.map +1 -1
- package/build/src/compiler/visual-keyboard-compiler.js +52 -54
- package/build/src/compiler/visual-keyboard-compiler.js.map +1 -1
- package/build/src/compiler/vkey.d.ts +11 -9
- package/build/src/compiler/vkey.d.ts.map +1 -1
- package/build/src/compiler/vkey.js +61 -59
- package/build/src/compiler/vkey.js.map +1 -1
- package/build/src/main.d.ts +11 -9
- package/build/src/main.d.ts.map +1 -1
- package/build/src/main.js +10 -8
- package/build/src/main.js.map +1 -1
- package/build/src/util/util.d.ts +44 -42
- package/build/src/util/util.d.ts.map +1 -1
- package/build/src/util/util.js +122 -120
- package/build/src/util/util.js.map +1 -1
- package/package.json +8 -8
- package/build/src/compiler/compiler-options.d.ts +0 -16
- package/build/src/compiler/compiler-options.d.ts.map +0 -1
- package/build/src/compiler/compiler-options.js +0 -6
- package/build/src/compiler/compiler-options.js.map +0 -1
- package/build/src/kpj.schema.json +0 -127
- package/build/src/kvks.schema.json +0 -182
- package/build/src/ldml-keyboard.schema.json +0 -702
- package/build/src/ldml-keyboardtest.schema.json +0 -221
|
@@ -1,55 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
export declare
|
|
16
|
-
|
|
17
|
-
private readonly
|
|
18
|
-
private
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* @
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* @
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* @
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* @
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
1
|
+
!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]="bbad84b1-d211-555b-af5a-8b1acd488164")}catch(e){}}();
|
|
2
|
+
import { LDMLKeyboard, KMXPlus, CompilerCallbacks, LDMLKeyboardTestDataXMLSourceFile, UnicodeSetParser } from '@keymanapp/common-types';
|
|
3
|
+
import { LdmlCompilerOptions } from './ldml-compiler-options.js';
|
|
4
|
+
import { BkspCompiler, TranCompiler } from './tran.js';
|
|
5
|
+
import { DispCompiler } from './disp.js';
|
|
6
|
+
import { KeysCompiler } from './keys.js';
|
|
7
|
+
import { LayrCompiler } from './layr.js';
|
|
8
|
+
import { LocaCompiler } from './loca.js';
|
|
9
|
+
import { MetaCompiler } from './meta.js';
|
|
10
|
+
import { NameCompiler } from './name.js';
|
|
11
|
+
import { VkeyCompiler } from './vkey.js';
|
|
12
|
+
import { VarsCompiler } from './vars.js';
|
|
13
|
+
import { StrsCompiler } from './empty-compiler.js';
|
|
14
|
+
import LDMLKeyboardXMLSourceFile = LDMLKeyboard.LDMLKeyboardXMLSourceFile;
|
|
15
|
+
export declare const SECTION_COMPILERS: (typeof TranCompiler | typeof BkspCompiler | typeof DispCompiler | typeof KeysCompiler | typeof LayrCompiler | typeof LocaCompiler | typeof MetaCompiler | typeof NameCompiler | typeof VkeyCompiler | typeof VarsCompiler | typeof StrsCompiler)[];
|
|
16
|
+
export declare class LdmlKeyboardCompiler {
|
|
17
|
+
private readonly callbacks;
|
|
18
|
+
private readonly options;
|
|
19
|
+
private usetparser?;
|
|
20
|
+
constructor(callbacks: CompilerCallbacks, options: LdmlCompilerOptions);
|
|
21
|
+
/**
|
|
22
|
+
* Construct or return a UnicodeSetParser, aka KmnCompiler
|
|
23
|
+
* @returns the held UnicodeSetParser
|
|
24
|
+
*/
|
|
25
|
+
getUsetParser(): Promise<UnicodeSetParser>;
|
|
26
|
+
private buildSections;
|
|
27
|
+
/**
|
|
28
|
+
* Loads a LDML Keyboard xml file and compiles into in-memory xml
|
|
29
|
+
* structures.
|
|
30
|
+
* @param filename input filename, will use callback to load from disk
|
|
31
|
+
* @returns the source file, or null if invalid
|
|
32
|
+
*/
|
|
33
|
+
load(filename: string): LDMLKeyboardXMLSourceFile | null;
|
|
34
|
+
/**
|
|
35
|
+
* Loads a LDML Keyboard test data xml file and compiles into in-memory xml
|
|
36
|
+
* structures.
|
|
37
|
+
* @param filename input filename, will use callback to load from disk
|
|
38
|
+
* @returns the source file, or null if invalid
|
|
39
|
+
*/
|
|
40
|
+
loadTestData(filename: string): LDMLKeyboardTestDataXMLSourceFile | null;
|
|
41
|
+
/**
|
|
42
|
+
* Validates that the LDML keyboard source file and lints. Actually just
|
|
43
|
+
* compiles the keyboard and returns `true` if everything is good...
|
|
44
|
+
* @param source
|
|
45
|
+
* @returns true if the file validates
|
|
46
|
+
*/
|
|
47
|
+
validate(source: LDMLKeyboardXMLSourceFile): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Transforms in-memory LDML keyboard xml file to an intermediate
|
|
50
|
+
* representation of a .kmx file.
|
|
51
|
+
* @param source in-memory representation of LDML keyboard xml file
|
|
52
|
+
* @returns KMXPlusFile intermediate file
|
|
53
|
+
*/
|
|
54
|
+
compile(source: LDMLKeyboardXMLSourceFile): Promise<KMXPlus.KMXPlusFile>;
|
|
55
|
+
}
|
|
56
|
+
//# debugId=bbad84b1-d211-555b-af5a-8b1acd488164
|
|
57
|
+
//# sourceMappingURL=compiler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"debug_id":"bbad84b1-d211-555b-af5a-8b1acd488164","file":"compiler.d.ts","mappings":";AAAA,OAAO,EAAmC,YAAY,EAAE,OAAO,EAAE,iBAAiB,EAAE,iCAAiC,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACzK,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AAC,OAAO,CAAC,WAAW,CAAC;CAoDtF","names":[],"sourceRoot":"","sources":["../../../src/compiler/compiler.ts"],"version":3}
|
|
@@ -1,198 +1,198 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
*
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* @
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
* @
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
//
|
|
123
|
-
//
|
|
124
|
-
//
|
|
125
|
-
//
|
|
126
|
-
//
|
|
127
|
-
//
|
|
128
|
-
//
|
|
129
|
-
//
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
* @
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
*
|
|
144
|
-
* representation of
|
|
145
|
-
* @
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
//
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
//
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
//# sourceMappingURL=compiler.js.map
|
|
1
|
+
!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]="4e3d1809-18d8-5297-8fa0-4f1418f31976")}catch(e){}}();
|
|
2
|
+
import { LDMLKeyboardXMLSourceFileReader, KMXPlus } from '@keymanapp/common-types';
|
|
3
|
+
import { CompilerMessages } from './messages.js';
|
|
4
|
+
import { BkspCompiler, TranCompiler } from './tran.js';
|
|
5
|
+
import { DispCompiler } from './disp.js';
|
|
6
|
+
import { KeysCompiler } from './keys.js';
|
|
7
|
+
import { LayrCompiler } from './layr.js';
|
|
8
|
+
import { LocaCompiler } from './loca.js';
|
|
9
|
+
import { MetaCompiler } from './meta.js';
|
|
10
|
+
import { NameCompiler } from './name.js';
|
|
11
|
+
import { VkeyCompiler } from './vkey.js';
|
|
12
|
+
import { VarsCompiler } from './vars.js';
|
|
13
|
+
import { StrsCompiler, ElemCompiler, ListCompiler, UsetCompiler } from './empty-compiler.js';
|
|
14
|
+
var KMXPlusFile = KMXPlus.KMXPlusFile;
|
|
15
|
+
import { constants } from '@keymanapp/ldml-keyboard-constants';
|
|
16
|
+
import { KmnCompiler } from '@keymanapp/kmc-kmn';
|
|
17
|
+
export const SECTION_COMPILERS = [
|
|
18
|
+
// These are in dependency order.
|
|
19
|
+
// First the former 'global' sections
|
|
20
|
+
StrsCompiler,
|
|
21
|
+
ListCompiler,
|
|
22
|
+
ElemCompiler,
|
|
23
|
+
UsetCompiler,
|
|
24
|
+
// Next, Vars, which depends on others
|
|
25
|
+
VarsCompiler,
|
|
26
|
+
// Now all others:
|
|
27
|
+
BkspCompiler,
|
|
28
|
+
DispCompiler,
|
|
29
|
+
KeysCompiler,
|
|
30
|
+
LayrCompiler,
|
|
31
|
+
LocaCompiler,
|
|
32
|
+
MetaCompiler,
|
|
33
|
+
NameCompiler,
|
|
34
|
+
TranCompiler,
|
|
35
|
+
VkeyCompiler,
|
|
36
|
+
];
|
|
37
|
+
export class LdmlKeyboardCompiler {
|
|
38
|
+
callbacks;
|
|
39
|
+
options;
|
|
40
|
+
// uset parser
|
|
41
|
+
usetparser = undefined;
|
|
42
|
+
constructor(callbacks, options) {
|
|
43
|
+
this.options = {
|
|
44
|
+
...options
|
|
45
|
+
};
|
|
46
|
+
this.callbacks = callbacks;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Construct or return a UnicodeSetParser, aka KmnCompiler
|
|
50
|
+
* @returns the held UnicodeSetParser
|
|
51
|
+
*/
|
|
52
|
+
async getUsetParser() {
|
|
53
|
+
if (this.usetparser === undefined) {
|
|
54
|
+
// initialize
|
|
55
|
+
const compiler = new KmnCompiler();
|
|
56
|
+
const ok = await compiler.init(this.callbacks);
|
|
57
|
+
if (ok) {
|
|
58
|
+
this.usetparser = compiler;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
/* c8 ignore next 2 */
|
|
62
|
+
this.usetparser = null; // Store null on failure
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return this.usetparser;
|
|
66
|
+
}
|
|
67
|
+
buildSections(source) {
|
|
68
|
+
return SECTION_COMPILERS.map(c => new c(source, this.callbacks));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Loads a LDML Keyboard xml file and compiles into in-memory xml
|
|
72
|
+
* structures.
|
|
73
|
+
* @param filename input filename, will use callback to load from disk
|
|
74
|
+
* @returns the source file, or null if invalid
|
|
75
|
+
*/
|
|
76
|
+
load(filename) {
|
|
77
|
+
const reader = new LDMLKeyboardXMLSourceFileReader(this.options.readerOptions, this.callbacks);
|
|
78
|
+
// load the file from disk into a string
|
|
79
|
+
const data = this.callbacks.loadFile(filename);
|
|
80
|
+
if (!data) {
|
|
81
|
+
this.callbacks.reportMessage(CompilerMessages.Error_InvalidFile({ errorText: 'Unable to read XML file' }));
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
// parse (load) the string into an object tree
|
|
85
|
+
const source = reader.load(data);
|
|
86
|
+
if (!source) {
|
|
87
|
+
this.callbacks.reportMessage(CompilerMessages.Error_InvalidFile({ errorText: 'Unable to load XML file' }));
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
// validate the object tree against the .xsd schema
|
|
92
|
+
if (!reader.validate(source)) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch (e) {
|
|
97
|
+
this.callbacks.reportMessage(CompilerMessages.Error_InvalidFile({ errorText: e.toString() }));
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
return source;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Loads a LDML Keyboard test data xml file and compiles into in-memory xml
|
|
104
|
+
* structures.
|
|
105
|
+
* @param filename input filename, will use callback to load from disk
|
|
106
|
+
* @returns the source file, or null if invalid
|
|
107
|
+
*/
|
|
108
|
+
loadTestData(filename) {
|
|
109
|
+
const reader = new LDMLKeyboardXMLSourceFileReader(this.options.readerOptions, this.callbacks);
|
|
110
|
+
const data = this.callbacks.loadFile(filename);
|
|
111
|
+
if (!data) {
|
|
112
|
+
this.callbacks.reportMessage(CompilerMessages.Error_InvalidFile({ errorText: 'Unable to read XML file' }));
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
const source = reader.loadTestData(data);
|
|
116
|
+
/* c8 ignore next 4 */
|
|
117
|
+
if (!source) {
|
|
118
|
+
this.callbacks.reportMessage(CompilerMessages.Error_InvalidFile({ errorText: 'Unable to load XML file' }));
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
// TODO-LDML: The unboxed data doesn't match the schema anymore. Skipping validation, for now.
|
|
122
|
+
// try {
|
|
123
|
+
// if (!reader.validate(source)) {
|
|
124
|
+
// return null;
|
|
125
|
+
// }
|
|
126
|
+
// } catch(e) {
|
|
127
|
+
// this.callbacks.reportMessage(CompilerMessages.Error_InvalidFile({errorText: e.toString()}));
|
|
128
|
+
// return null;
|
|
129
|
+
// }
|
|
130
|
+
return source;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Validates that the LDML keyboard source file and lints. Actually just
|
|
134
|
+
* compiles the keyboard and returns `true` if everything is good...
|
|
135
|
+
* @param source
|
|
136
|
+
* @returns true if the file validates
|
|
137
|
+
*/
|
|
138
|
+
validate(source) {
|
|
139
|
+
return !!this.compile(source);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Transforms in-memory LDML keyboard xml file to an intermediate
|
|
143
|
+
* representation of a .kmx file.
|
|
144
|
+
* @param source in-memory representation of LDML keyboard xml file
|
|
145
|
+
* @returns KMXPlusFile intermediate file
|
|
146
|
+
*/
|
|
147
|
+
async compile(source) {
|
|
148
|
+
const sections = this.buildSections(source);
|
|
149
|
+
let passed = true;
|
|
150
|
+
const kmx = new KMXPlusFile();
|
|
151
|
+
for (let section of sections) {
|
|
152
|
+
if (!section.validate()) {
|
|
153
|
+
// TODO-LDML: coverage
|
|
154
|
+
passed = false;
|
|
155
|
+
// We'll keep validating other sections anyway, so we get a full set of
|
|
156
|
+
// errors for the keyboard developer.
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
// clone
|
|
160
|
+
const globalSections = Object.assign({}, kmx.kmxplus);
|
|
161
|
+
// pre-initialize the usetparser
|
|
162
|
+
globalSections.usetparser = await this.getUsetParser();
|
|
163
|
+
const dependencies = section.dependencies;
|
|
164
|
+
Object.keys(constants.section).forEach((sectstr) => {
|
|
165
|
+
const sectid = constants.section[sectstr];
|
|
166
|
+
if (dependencies.has(sectid)) {
|
|
167
|
+
/* c8 ignore next 4 */
|
|
168
|
+
if (!kmx.kmxplus[sectid]) {
|
|
169
|
+
// Internal error useful during section bring-up
|
|
170
|
+
throw new Error(`Internal error: section ${section.id} depends on uninitialized dependency ${sectid}, check ordering`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
// delete dependencies that aren't referenced
|
|
175
|
+
delete globalSections[sectid];
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
const sect = section.compile(globalSections);
|
|
179
|
+
/* c8 ignore next 7 */
|
|
180
|
+
if (!sect) {
|
|
181
|
+
// This should not happen -- validate() should have told us
|
|
182
|
+
// if something is going to fail to compile
|
|
183
|
+
this.callbacks.reportMessage(CompilerMessages.Fatal_SectionCompilerFailed({ sect: section.id }));
|
|
184
|
+
passed = false;
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
/* c8 ignore next 4 */
|
|
188
|
+
if (kmx.kmxplus[section.id]) {
|
|
189
|
+
// Internal error useful during section bring-up
|
|
190
|
+
throw new Error(`Internal error: section ${section.id} would be assigned twice`);
|
|
191
|
+
}
|
|
192
|
+
kmx.kmxplus[section.id] = sect;
|
|
193
|
+
}
|
|
194
|
+
return passed ? kmx : null;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
//# debugId=4e3d1809-18d8-5297-8fa0-4f1418f31976
|
|
198
|
+
//# sourceMappingURL=compiler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"debug_id":"4e3d1809-18d8-5297-8fa0-4f1418f31976","file":"compiler.js","mappings":";AAAA,OAAO,EAAE,+BAA+B,EAAgB,OAAO,EAA0E,MAAM,yBAAyB,CAAC;AAEzK,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;A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AC3D,2CAA2C;gBAC3C,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,gBAAgB,CAAC,2BAA2B,CAAC,EAAC,IAAI,EAAC,OAAO,CAAC,EAAE,EAAC,CAAC,CAAC,CAAC;gBAC9F,MAAM,GAAG,KAAK,CAAC;gBACf,SAAS;aACV;YACD,sBAAsB;YACtB,IAAG,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;gBAC1B,gDAAgD;gBAChD,MAAM,IAAI,KAAK,CAAC,2BAA2B,OAAO,CAAC,EAAE,0BAA0B,CAAC,CAAC;aAClF;YACD,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,IAAW,CAAC;SACvC;QAED,OAAO,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7B,CAAC;CACF","names":[],"sourceRoot":"","sources":["../../../src/compiler/compiler.ts"],"version":3}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
!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]="173fb484-340b-5d86-9c83-d1d18b16f9f4")}catch(e){}}();
|
|
2
|
+
import { KMXPlus, LDMLKeyboard } from '@keymanapp/common-types';
|
|
3
|
+
import { SectionCompiler } from "./section-compiler.js";
|
|
4
|
+
import DependencySections = KMXPlus.DependencySections;
|
|
5
|
+
import Disp = KMXPlus.Disp;
|
|
6
|
+
import { MarkerTracker } from "./marker-tracker.js";
|
|
7
|
+
export declare class DispCompiler extends SectionCompiler {
|
|
8
|
+
static validateMarkers(keyboard: LDMLKeyboard.LKKeyboard, mt: MarkerTracker): boolean;
|
|
9
|
+
get id(): import("@keymanapp/ldml-keyboard-constants").SectionIdent;
|
|
10
|
+
validate(): boolean;
|
|
11
|
+
compile(sections: DependencySections): Disp;
|
|
12
|
+
}
|
|
13
|
+
//# debugId=173fb484-340b-5d86-9c83-d1d18b16f9f4
|
|
14
|
+
//# sourceMappingURL=disp.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"debug_id":"173fb484-340b-5d86-9c83-d1d18b16f9f4","file":"disp.d.ts","mappings":";AACA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAgB,MAAM,yBAAyB,CAAC;AAG9E,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;AACvD,OAAO,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;AAE3B,OAAO,EAAE,aAAa,EAAa,MAAM,qBAAqB,CAAC;AAE/D,qBAAa,YAAa,SAAQ,eAAe;IAC/C,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,YAAY,CAAC,UAAU,EAAE,EAAE,EAAG,aAAa,GAAG,OAAO;IAMtF,IAAW,EAAE,8DAEZ;IAEM,QAAQ,IAAI,OAAO;IAkBnB,OAAO,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;CAkBnD","names":[],"sourceRoot":"","sources":["../../../src/compiler/disp.ts"],"version":3}
|