@keymanapp/kmc-package 17.0.85-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/.nyc_output/coverage-4892-1681239251006-0.json +1 -0
- package/Makefile +38 -0
- package/build/src/kmp-compiler.d.ts +18 -0
- package/build/src/kmp-compiler.d.ts.map +1 -0
- package/build/src/kmp-compiler.js +232 -0
- package/build/src/kmp-compiler.js.map +1 -0
- package/build/src/kmp-json-file.d.ts +68 -0
- package/build/src/kmp-json-file.d.ts.map +1 -0
- package/build/src/kmp-json-file.js +2 -0
- package/build/src/kmp-json-file.js.map +1 -0
- package/build/src/kps-file.d.ts +98 -0
- package/build/src/kps-file.d.ts.map +1 -0
- package/build/src/kps-file.js +16 -0
- package/build/src/kps-file.js.map +1 -0
- package/build/test/helpers/index.d.ts +10 -0
- package/build/test/helpers/index.d.ts.map +1 -0
- package/build/test/helpers/index.js +17 -0
- package/build/test/helpers/index.js.map +1 -0
- package/build/test/test-package-compiler.d.ts +2 -0
- package/build/test/test-package-compiler.d.ts.map +1 -0
- package/build/test/test-package-compiler.js +97 -0
- package/build/test/test-package-compiler.js.map +1 -0
- package/build/test/tsconfig.tsbuildinfo +1 -0
- package/build/tsconfig.tsbuildinfo +1 -0
- package/build.sh +66 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +146 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/index.html +116 -0
- package/coverage/lcov-report/src/kmp-compiler.ts.html +904 -0
- package/coverage/lcov-report/test/helpers/index.html +116 -0
- package/coverage/lcov-report/test/helpers/index.ts.html +136 -0
- package/coverage/lcov-report/test/index.html +116 -0
- package/coverage/lcov-report/test/test-package-compiler.ts.html +445 -0
- package/coverage/lcov.info +518 -0
- package/package.json +54 -0
- package/src/kmp-compiler.ts +273 -0
- package/src/kmp-json-file.ts +77 -0
- package/src/kps-file.ts +126 -0
- package/test/fixtures/example.qaa.sencoten/example.qaa.sencoten.model.js +55 -0
- package/test/fixtures/example.qaa.sencoten/example.qaa.sencoten.model.kmp.intermediate.json +48 -0
- package/test/fixtures/example.qaa.sencoten/example.qaa.sencoten.model.kmp.json +48 -0
- package/test/fixtures/example.qaa.sencoten/example.qaa.sencoten.model.kmp.zipped.json +45 -0
- package/test/fixtures/example.qaa.sencoten/example.qaa.sencoten.model.kps +35 -0
- package/test/fixtures/example.qaa.sencoten/example.qaa.sencoten.model.ts +6 -0
- package/test/fixtures/example.qaa.sencoten/wordlist.tsv +10 -0
- package/test/fixtures/khmer_angkor/build/khmer_angkor.js +1 -0
- package/test/fixtures/khmer_angkor/build/khmer_angkor.kmx +0 -0
- package/test/fixtures/khmer_angkor/build/khmer_angkor.kvk +0 -0
- package/test/fixtures/khmer_angkor/ref/kmp.json +110 -0
- package/test/fixtures/khmer_angkor/shared/fonts/khmer/busrakbd/khmer_busra_kbd.ttf +0 -0
- package/test/fixtures/khmer_angkor/shared/fonts/khmer/mondulkiri/FONTLOG.txt +123 -0
- package/test/fixtures/khmer_angkor/shared/fonts/khmer/mondulkiri/Mondulkiri-R.ttf +0 -0
- package/test/fixtures/khmer_angkor/shared/fonts/khmer/mondulkiri/OFL-FAQ.txt +425 -0
- package/test/fixtures/khmer_angkor/shared/fonts/khmer/mondulkiri/OFL.txt +95 -0
- package/test/fixtures/khmer_angkor/source/khmer_angkor.kps +131 -0
- package/test/fixtures/khmer_angkor/source/readme.htm +23 -0
- package/test/fixtures/khmer_angkor/source/splash.gif +0 -0
- package/test/fixtures/khmer_angkor/source/welcome/KAK_Documentation_EN.pdf +0 -0
- package/test/fixtures/khmer_angkor/source/welcome/KAK_Documentation_KH.pdf +0 -0
- package/test/fixtures/khmer_angkor/source/welcome/image002.png +0 -0
- package/test/fixtures/khmer_angkor/source/welcome/keyboard_layout.png +0 -0
- package/test/fixtures/khmer_angkor/source/welcome/welcome.htm +54 -0
- package/test/fixtures/withfolders.qaa.sencoten/build/withfolders.qaa.sencoten.model.js +55 -0
- package/test/fixtures/withfolders.qaa.sencoten/source/welcome.htm +1 -0
- package/test/fixtures/withfolders.qaa.sencoten/source/withfolders.qaa.sencoten.model.kps +41 -0
- package/test/fixtures/withfolders.qaa.sencoten/source/withfolders.qaa.sencoten.model.ts +6 -0
- package/test/fixtures/withfolders.qaa.sencoten/source/wordlist.tsv +10 -0
- package/test/fixtures/withfolders.qaa.sencoten/withfolders.qaa.sencoten.model.kmp.intermediate.json +52 -0
- package/test/fixtures/withfolders.qaa.sencoten/withfolders.qaa.sencoten.model.kmp.zipped.json +50 -0
- package/test/helpers/index.ts +17 -0
- package/test/test-package-compiler.ts +120 -0
- package/test/tsconfig.json +19 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<Package>
|
|
3
|
+
<System>
|
|
4
|
+
<KeymanDeveloperVersion>15.0.266.0</KeymanDeveloperVersion>
|
|
5
|
+
<FileVersion>7.0</FileVersion>
|
|
6
|
+
</System>
|
|
7
|
+
<Options>
|
|
8
|
+
<ExecuteProgram></ExecuteProgram>
|
|
9
|
+
<ReadMeFile>readme.htm</ReadMeFile>
|
|
10
|
+
<GraphicFile>splash.gif</GraphicFile>
|
|
11
|
+
<MSIFileName></MSIFileName>
|
|
12
|
+
<MSIOptions></MSIOptions>
|
|
13
|
+
<FollowKeyboardVersion/>
|
|
14
|
+
</Options>
|
|
15
|
+
<StartMenu>
|
|
16
|
+
<Folder></Folder>
|
|
17
|
+
<Items/>
|
|
18
|
+
</StartMenu>
|
|
19
|
+
<Info>
|
|
20
|
+
<Name URL="">Khmer Angkor</Name>
|
|
21
|
+
<Copyright URL="">© 2015-2022 SIL International</Copyright>
|
|
22
|
+
<Author URL="mailto:makara_sok@sil.org">Makara Sok</Author>
|
|
23
|
+
<Version URL=""></Version>
|
|
24
|
+
<WebSite URL="https://keyman.com/keyboards/khmer_angkor">https://keyman.com/keyboards/khmer_angkor</WebSite>
|
|
25
|
+
</Info>
|
|
26
|
+
<Files>
|
|
27
|
+
<File>
|
|
28
|
+
<Name>..\build\khmer_angkor.js</Name>
|
|
29
|
+
<Description>File khmer_angkor.js</Description>
|
|
30
|
+
<CopyLocation>0</CopyLocation>
|
|
31
|
+
<FileType>.js</FileType>
|
|
32
|
+
</File>
|
|
33
|
+
<File>
|
|
34
|
+
<Name>..\build\khmer_angkor.kvk</Name>
|
|
35
|
+
<Description>File khmer_angkor.kvk</Description>
|
|
36
|
+
<CopyLocation>0</CopyLocation>
|
|
37
|
+
<FileType>.kvk</FileType>
|
|
38
|
+
</File>
|
|
39
|
+
<File>
|
|
40
|
+
<Name>..\build\khmer_angkor.kmx</Name>
|
|
41
|
+
<Description>Keyboard Khmer Angkor</Description>
|
|
42
|
+
<CopyLocation>0</CopyLocation>
|
|
43
|
+
<FileType>.kmx</FileType>
|
|
44
|
+
</File>
|
|
45
|
+
<File>
|
|
46
|
+
<Name>welcome\keyboard_layout.png</Name>
|
|
47
|
+
<Description>File keyboard_layout.png</Description>
|
|
48
|
+
<CopyLocation>0</CopyLocation>
|
|
49
|
+
<FileType>.png</FileType>
|
|
50
|
+
</File>
|
|
51
|
+
<File>
|
|
52
|
+
<Name>welcome\welcome.htm</Name>
|
|
53
|
+
<Description>File welcome.htm</Description>
|
|
54
|
+
<CopyLocation>0</CopyLocation>
|
|
55
|
+
<FileType>.htm</FileType>
|
|
56
|
+
</File>
|
|
57
|
+
<File>
|
|
58
|
+
<Name>..\shared\fonts\khmer\mondulkiri\FONTLOG.txt</Name>
|
|
59
|
+
<Description>File FONTLOG.txt</Description>
|
|
60
|
+
<CopyLocation>0</CopyLocation>
|
|
61
|
+
<FileType>.txt</FileType>
|
|
62
|
+
</File>
|
|
63
|
+
<File>
|
|
64
|
+
<Name>..\shared\fonts\khmer\mondulkiri\Mondulkiri-R.ttf</Name>
|
|
65
|
+
<Description>Font Khmer Mondulkiri</Description>
|
|
66
|
+
<CopyLocation>0</CopyLocation>
|
|
67
|
+
<FileType>.ttf</FileType>
|
|
68
|
+
</File>
|
|
69
|
+
<File>
|
|
70
|
+
<Name>..\shared\fonts\khmer\mondulkiri\OFL.txt</Name>
|
|
71
|
+
<Description>File OFL.txt</Description>
|
|
72
|
+
<CopyLocation>0</CopyLocation>
|
|
73
|
+
<FileType>.txt</FileType>
|
|
74
|
+
</File>
|
|
75
|
+
<File>
|
|
76
|
+
<Name>..\shared\fonts\khmer\mondulkiri\OFL-FAQ.txt</Name>
|
|
77
|
+
<Description>File OFL-FAQ.txt</Description>
|
|
78
|
+
<CopyLocation>0</CopyLocation>
|
|
79
|
+
<FileType>.txt</FileType>
|
|
80
|
+
</File>
|
|
81
|
+
<File>
|
|
82
|
+
<Name>welcome\KAK_Documentation_EN.pdf</Name>
|
|
83
|
+
<Description>File KAK_Documentation_EN.pdf</Description>
|
|
84
|
+
<CopyLocation>0</CopyLocation>
|
|
85
|
+
<FileType>.pdf</FileType>
|
|
86
|
+
</File>
|
|
87
|
+
<File>
|
|
88
|
+
<Name>welcome\KAK_Documentation_KH.pdf</Name>
|
|
89
|
+
<Description>File KAK_Documentation_KH.pdf</Description>
|
|
90
|
+
<CopyLocation>0</CopyLocation>
|
|
91
|
+
<FileType>.pdf</FileType>
|
|
92
|
+
</File>
|
|
93
|
+
<File>
|
|
94
|
+
<Name>readme.htm</Name>
|
|
95
|
+
<Description>File readme.htm</Description>
|
|
96
|
+
<CopyLocation>0</CopyLocation>
|
|
97
|
+
<FileType>.htm</FileType>
|
|
98
|
+
</File>
|
|
99
|
+
<File>
|
|
100
|
+
<Name>welcome\image002.png</Name>
|
|
101
|
+
<Description>File image002.png</Description>
|
|
102
|
+
<CopyLocation>0</CopyLocation>
|
|
103
|
+
<FileType>.png</FileType>
|
|
104
|
+
</File>
|
|
105
|
+
<File>
|
|
106
|
+
<Name>..\shared\fonts\khmer\busrakbd\khmer_busra_kbd.ttf</Name>
|
|
107
|
+
<Description>Font KhmerBusraKbd</Description>
|
|
108
|
+
<CopyLocation>0</CopyLocation>
|
|
109
|
+
<FileType>.ttf</FileType>
|
|
110
|
+
</File>
|
|
111
|
+
<File>
|
|
112
|
+
<Name>splash.gif</Name>
|
|
113
|
+
<Description>File splash.gif</Description>
|
|
114
|
+
<CopyLocation>0</CopyLocation>
|
|
115
|
+
<FileType>.gif</FileType>
|
|
116
|
+
</File>
|
|
117
|
+
</Files>
|
|
118
|
+
<Keyboards>
|
|
119
|
+
<Keyboard>
|
|
120
|
+
<Name>Khmer Angkor</Name>
|
|
121
|
+
<ID>khmer_angkor</ID>
|
|
122
|
+
<Version>1.3</Version>
|
|
123
|
+
<OSKFont>..\shared\fonts\khmer\busrakbd\khmer_busra_kbd.ttf</OSKFont>
|
|
124
|
+
<DisplayFont>..\shared\fonts\khmer\mondulkiri\Mondulkiri-R.ttf</DisplayFont>
|
|
125
|
+
<Languages>
|
|
126
|
+
<Language ID="km">Central Khmer (Khmer, Cambodia)</Language>
|
|
127
|
+
</Languages>
|
|
128
|
+
</Keyboard>
|
|
129
|
+
</Keyboards>
|
|
130
|
+
<Strings/>
|
|
131
|
+
</Package>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>Khmer Angkor Keyboard</title>
|
|
6
|
+
<style type="text/css">
|
|
7
|
+
p { font: 10pt Tahoma; }
|
|
8
|
+
h1 { font: bold 16pt Tahoma; color: #4444cc; margin-bottom: 2px }
|
|
9
|
+
h2 { font: bold 12pt Tahoma; color: #4444cc; }
|
|
10
|
+
</style>
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
|
|
14
|
+
<h1>Khmer Angkor Keyboard</h1>
|
|
15
|
+
|
|
16
|
+
<p>
|
|
17
|
+
With the users' pitfall in typing Khmer words in mind, Khmer Angkor focuses on the unification of the character orders and spelling rules. These make Khmer Angkor uniquely different from any other keyboards. Khmer Angkor's keyboard layouts were adopted from NiDA keyboard which is widely used at the present.
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
<p>© 2015-2022 SIL International</p>
|
|
21
|
+
|
|
22
|
+
</body>
|
|
23
|
+
</html>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
4
|
+
<title>Khmer Angkor Keyboard</title>
|
|
5
|
+
</head>
|
|
6
|
+
<body style="max-width: 600px;">
|
|
7
|
+
<h1>Khmer Angkor Keyboard</h1>
|
|
8
|
+
|
|
9
|
+
<p style="text-align: justify;">
|
|
10
|
+
Khmer Angkor Keyboard is an OpenSource. It is free and more than just a user you can also contribute to the betterment of the keyboard if you would like to.
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<h1>Keyboards</h1>
|
|
14
|
+
<p style="text-align: justify;">
|
|
15
|
+
With the users' pitfall in typing Khmer words in mind, Khmer Angkor focuses on the unification of the character orders and spelling rules. These make Khmer Angkor uniquely different from any other keyboards. Khmer Angkor's keyboard layouts were adopted from NiDA keyboard which is widely used at the present.
|
|
16
|
+
Here is the keyboard layout:
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<img width="100%" src="keyboard_layout.png">
|
|
20
|
+
<img width="100%" src="image002.png">
|
|
21
|
+
|
|
22
|
+
<p>You can simply use Khmer Angkor as you would for any NiDA based keyboard. You may type a word in an order of how it is spelled, not how it appears to be, especially when the vowel is to the left of the consonant. For example, to type the word “តែ” which means ‘tea’, one should type the consonant first and then the vowel (i.e. press key “T” and then “Shift E”).</p>
|
|
23
|
+
|
|
24
|
+
<p>The order of characters is:</p>
|
|
25
|
+
<p><center><b>Consonant + Subscript(s) + Consonant Shifter + Vowel + Diacritic</b></center></p>
|
|
26
|
+
|
|
27
|
+
<p>For more details on the Khmer Angkor Keyboard, please find the documentation included in this package.</p>
|
|
28
|
+
|
|
29
|
+
<h1>Keyboard Documentations</h1>
|
|
30
|
+
<p>For the documentation in English, click <a href="KAK_Documentation_EN.pdf">here</a>.</p>
|
|
31
|
+
<p>For the documentation in Khmer, click <a href="KAK_Documentation_KH.pdf">here</a>.</p>
|
|
32
|
+
|
|
33
|
+
<h1>Fonts</h1>
|
|
34
|
+
<p style="text-align: justify;">
|
|
35
|
+
To get Khmer fonts, you may visit one of the three sources below:
|
|
36
|
+
<ul style="list-style-type:circle">
|
|
37
|
+
<li><a href="https://github.com/KhmerSoftwareInitiative/khmer-unicode-fonts">Khmer Fonts by the Khmer Software Initiative</a></li>
|
|
38
|
+
<li><a href="https://software.sil.org/mondulkiri/">Khmer Font by SIL International</a></li>
|
|
39
|
+
<li><a href="https://fonts.google.com/?subset=khmer">Khmer Fonts by Google</a> </li>
|
|
40
|
+
</ul>
|
|
41
|
+
|
|
42
|
+
<h3>More Information</h3>
|
|
43
|
+
<p style="text-align: justify;">
|
|
44
|
+
|
|
45
|
+
</p>
|
|
46
|
+
|
|
47
|
+
<ul style="list-style-type:circle">
|
|
48
|
+
<li><a href="http://unicode.org/charts/PDF/U1780.pdf">Khmer character chart</a></li>
|
|
49
|
+
<li><a href="https://www.ethnologue.com/country/KH">Cambodia on ethnologue</a></li>
|
|
50
|
+
<li><a href="http://www.unicode.org/versions/latest/ch16.pdf">Khmer Script by Unicode Standard</a> </li>
|
|
51
|
+
</ul>
|
|
52
|
+
|
|
53
|
+
</body>
|
|
54
|
+
</html>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
'use strict';
|
|
3
|
+
var definitions = {
|
|
4
|
+
defaults: {
|
|
5
|
+
version: "16.0.60-alpha",
|
|
6
|
+
applyCasing: function defaultApplyCasing(casing, text) {
|
|
7
|
+
switch (casing) {
|
|
8
|
+
case 'lower':
|
|
9
|
+
return text.toLowerCase();
|
|
10
|
+
case 'upper':
|
|
11
|
+
return text.toUpperCase();
|
|
12
|
+
case 'initial':
|
|
13
|
+
var headCode = text.charCodeAt(0);
|
|
14
|
+
// The length of the first code unit, as measured in code points.
|
|
15
|
+
var headUnitLength = 1;
|
|
16
|
+
// Is the first character a high surrogate, indicating possible use of UTF-16
|
|
17
|
+
// surrogate pairs? Also, is the string long enough for there to BE a pair?
|
|
18
|
+
if (text.length > 1 && headCode >= 0xD800 && headCode <= 0xDBFF) {
|
|
19
|
+
// It's possible, so now we check for low surrogates.
|
|
20
|
+
var lowSurrogateCode = text.charCodeAt(1);
|
|
21
|
+
if (lowSurrogateCode >= 0xDC00 && lowSurrogateCode <= 0xDFFF) {
|
|
22
|
+
// We have a surrogate pair; this pair is the 'first' character.
|
|
23
|
+
headUnitLength++;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// Capitalizes the first code unit of the string, leaving the rest intact.
|
|
27
|
+
return text.substring(0, headUnitLength).toUpperCase() // head - uppercased
|
|
28
|
+
.concat(text.substring(headUnitLength)); // tail - lowercased
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}, model: {
|
|
32
|
+
searchTermToKey: function defaultCasedSearchTermToKey(wordform, applyCasing) {
|
|
33
|
+
// While this is a bit WET, as the basic `defaultSearchTermToKey` exists and performs some of
|
|
34
|
+
// the same functions, repetition is the easiest way to allow the function to be safely compiled
|
|
35
|
+
// with ease by use of `.toString()`.
|
|
36
|
+
return Array.from(wordform
|
|
37
|
+
.normalize('NFKD')
|
|
38
|
+
// Remove any combining diacritics (if input is in NFKD)
|
|
39
|
+
.replace(/[\u0300-\u036F]/g, '')) // end of `Array.from`
|
|
40
|
+
.map(function (c) { return applyCasing('lower', c); })
|
|
41
|
+
.join('');
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
applyCasing: function(caseToApply, text) {
|
|
45
|
+
return definitions.defaults.applyCasing(caseToApply, text);
|
|
46
|
+
},
|
|
47
|
+
searchTermToKey: function(text) {
|
|
48
|
+
return definitions.model.searchTermToKey(text, definitions.applyCasing);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
LMLayerWorker.loadModel(new models.TrieModel({"totalWeight":44103,"root":{"type":"internal","weight":13644,"values":["t","e","s","ȼ","n","u","i"],"children":{"t":{"type":"leaf","weight":13644,"entries":[{"key":"tŧe","weight":13644,"content":"TŦE"}]},"e":{"type":"leaf","weight":9134,"entries":[{"key":"e","weight":9134,"content":"E"}]},"s":{"type":"internal","weight":4816,"values":["e","w"],"children":{"e":{"type":"leaf","weight":4816,"entries":[{"key":"sen","weight":4816,"content":"SEN"}]},"w":{"type":"leaf","weight":2621,"entries":[{"key":"sw","weight":2621,"content":"SW̱"}]}}},"ȼ":{"type":"internal","weight":3479,"values":["","s"],"children":{"":{"type":"leaf","weight":3479,"entries":[{"key":"ȼ","weight":3479,"content":"Ȼ"}]},"s":{"type":"leaf","weight":1925,"entries":[{"key":"ȼse","weight":1925,"content":"ȻSE"}]}}},"n":{"type":"leaf","weight":2314,"entries":[{"key":"niƚ","weight":2314,"content":"NIȽ"}]},"u":{"type":"leaf","weight":2298,"entries":[{"key":"u ","weight":2298,"content":"U¸"}]},"i":{"type":"leaf","weight":1988,"entries":[{"key":"i ","weight":1988,"content":"I¸"},{"key":"i","weight":1884,"content":"I"}]}}}}, {
|
|
52
|
+
wordBreaker: wordBreakers['default'],
|
|
53
|
+
searchTermToKey: definitions.searchTermToKey,
|
|
54
|
+
}));
|
|
55
|
+
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This is a welcome.htm file
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<Package>
|
|
3
|
+
<System>
|
|
4
|
+
<KeymanDeveloperVersion>12.0.1500.0</KeymanDeveloperVersion>
|
|
5
|
+
<FileVersion>12.0</FileVersion>
|
|
6
|
+
</System>
|
|
7
|
+
<Options>
|
|
8
|
+
<FollowKeyboardVersion/>
|
|
9
|
+
</Options>
|
|
10
|
+
<Info>
|
|
11
|
+
<Name URL="">SENĆOŦEN (Saanich Dialect) Lexical Model</Name>
|
|
12
|
+
<Copyright URL="">© 2019 National Research Council Canada</Copyright>
|
|
13
|
+
<Author URL="mailto:Eddie.Santos@nrc-cnrc.gc.ca">Eddie Antonio Santos</Author>
|
|
14
|
+
<Version>1.0.3</Version>
|
|
15
|
+
</Info>
|
|
16
|
+
<Files>
|
|
17
|
+
<File>
|
|
18
|
+
<Name>..\build\withfolders.qaa.sencoten.model.js</Name>
|
|
19
|
+
<Description>Lexical model withfolders.qaa.sencoten.model.js</Description>
|
|
20
|
+
<CopyLocation>0</CopyLocation>
|
|
21
|
+
<FileType>.model.js</FileType>
|
|
22
|
+
</File>
|
|
23
|
+
<File>
|
|
24
|
+
<Name>welcome.htm</Name>
|
|
25
|
+
<Description>Welcome file</Description>
|
|
26
|
+
<CopyLocation>0</CopyLocation>
|
|
27
|
+
<FileType>.htm</FileType>
|
|
28
|
+
</File>
|
|
29
|
+
</Files>
|
|
30
|
+
<LexicalModels>
|
|
31
|
+
<LexicalModel>
|
|
32
|
+
<Name>SENĆOŦEN dictionary</Name>
|
|
33
|
+
<ID>withfolders.qaa.sencoten</ID>
|
|
34
|
+
<Version>1.0.3</Version>
|
|
35
|
+
<Languages>
|
|
36
|
+
<Language ID="qaa">North Straits Salish</Language>
|
|
37
|
+
<Language ID="qaa-Latn">SENĆOŦEN</Language>
|
|
38
|
+
</Languages>
|
|
39
|
+
</LexicalModel>
|
|
40
|
+
</LexicalModels>
|
|
41
|
+
</Package>
|
package/test/fixtures/withfolders.qaa.sencoten/withfolders.qaa.sencoten.model.kmp.intermediate.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"system": {
|
|
3
|
+
"keymanDeveloperVersion": "12.0.1500.0",
|
|
4
|
+
"fileVersion": "12.0"
|
|
5
|
+
},
|
|
6
|
+
"options": {},
|
|
7
|
+
"info": {
|
|
8
|
+
"author": {
|
|
9
|
+
"description": "Eddie Antonio Santos",
|
|
10
|
+
"url": "mailto:Eddie.Santos@nrc-cnrc.gc.ca"
|
|
11
|
+
},
|
|
12
|
+
"copyright": {
|
|
13
|
+
"description": "© 2019 National Research Council Canada"
|
|
14
|
+
},
|
|
15
|
+
"name": {
|
|
16
|
+
"description": "SENĆOŦEN (Saanich Dialect) Lexical Model"
|
|
17
|
+
},
|
|
18
|
+
"version": {
|
|
19
|
+
"description": "0.0.0"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
{
|
|
24
|
+
"name": "..\\build\\withfolders.qaa.sencoten.model.js",
|
|
25
|
+
"description": "Lexical model withfolders.qaa.sencoten.model.js"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"description": "Welcome file",
|
|
29
|
+
"name": "welcome.htm"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"description": "Package information (JSON)",
|
|
33
|
+
"name": "kmp.json"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"lexicalModels": [
|
|
37
|
+
{
|
|
38
|
+
"name": "SENĆOŦEN dictionary",
|
|
39
|
+
"id": "withfolders.qaa.sencoten",
|
|
40
|
+
"languages": [
|
|
41
|
+
{
|
|
42
|
+
"name": "North Straits Salish",
|
|
43
|
+
"id": "qaa"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"name": "SENĆOŦEN",
|
|
47
|
+
"id": "qaa-Latn"
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"system": {
|
|
3
|
+
"keymanDeveloperVersion": "12.0.1500.0",
|
|
4
|
+
"fileVersion": "12.0"
|
|
5
|
+
},
|
|
6
|
+
"options": {},
|
|
7
|
+
"info": {
|
|
8
|
+
"author": {
|
|
9
|
+
"description": "Eddie Antonio Santos",
|
|
10
|
+
"url": "mailto:Eddie.Santos@nrc-cnrc.gc.ca"
|
|
11
|
+
},
|
|
12
|
+
"copyright": {
|
|
13
|
+
"description": "© 2019 National Research Council Canada"
|
|
14
|
+
},
|
|
15
|
+
"name": {
|
|
16
|
+
"description": "SENĆOŦEN (Saanich Dialect) Lexical Model"
|
|
17
|
+
},
|
|
18
|
+
"version": {
|
|
19
|
+
"description": "1.0.3"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
{
|
|
24
|
+
"name": "withfolders.qaa.sencoten.model.js",
|
|
25
|
+
"description": "Lexical model withfolders.qaa.sencoten.model.js",
|
|
26
|
+
"copyLocation": 0
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"copyLocation": 0,
|
|
30
|
+
"description": "Welcome file",
|
|
31
|
+
"name": "welcome.htm"
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"lexicalModels": [
|
|
35
|
+
{
|
|
36
|
+
"name": "SENĆOŦEN dictionary",
|
|
37
|
+
"id": "withfolders.qaa.sencoten",
|
|
38
|
+
"languages": [
|
|
39
|
+
{
|
|
40
|
+
"name": "North Straits Salish",
|
|
41
|
+
"id": "qaa"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "SENĆOŦEN",
|
|
45
|
+
"id": "qaa-Latn"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers and utilities for the Mocha tests.
|
|
3
|
+
*/
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Builds a path to the fixture with the given path components.
|
|
9
|
+
*
|
|
10
|
+
* e.g., makePathToFixture('example.qaa.trivial')
|
|
11
|
+
* e.g., makePathToFixture('example.qaa.trivial', 'model.ts')
|
|
12
|
+
*
|
|
13
|
+
* @param components One or more path components.
|
|
14
|
+
*/
|
|
15
|
+
export function makePathToFixture(...components: string[]): string {
|
|
16
|
+
return fileURLToPath(new URL(path.join('..', '..', '..', 'test', 'fixtures', ...components), import.meta.url));
|
|
17
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import 'mocha';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import {assert} from 'chai';
|
|
4
|
+
|
|
5
|
+
import KmpCompiler from '../src/kmp-compiler.js';
|
|
6
|
+
import {makePathToFixture} from './helpers/index.js';
|
|
7
|
+
import JSZip from 'jszip';
|
|
8
|
+
import KEYMAN_VERSION from "@keymanapp/keyman-version";
|
|
9
|
+
import { type KmpJsonFile } from '../src/kmp-json-file.js';
|
|
10
|
+
|
|
11
|
+
describe('KmpCompiler', function () {
|
|
12
|
+
const MODELS : string[] = [
|
|
13
|
+
'example.qaa.sencoten',
|
|
14
|
+
'withfolders.qaa.sencoten',
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
let kmpCompiler = new KmpCompiler();
|
|
18
|
+
|
|
19
|
+
for (let modelID of MODELS) {
|
|
20
|
+
const kpsPath = modelID.includes('withfolders') ?
|
|
21
|
+
makePathToFixture(modelID, 'source', `${modelID}.model.kps`) : makePathToFixture(modelID, `${modelID}.model.kps`);
|
|
22
|
+
const jsPath = modelID.includes('withfolders') ?
|
|
23
|
+
makePathToFixture(modelID, 'source', `${modelID}.model.js`) : makePathToFixture(modelID, `${modelID}.model.js`);
|
|
24
|
+
const kmpJsonIntermediatePath = makePathToFixture(modelID, `${modelID}.model.kmp.intermediate.json`);
|
|
25
|
+
const kmpJsonZippedPath = makePathToFixture(modelID, `${modelID}.model.kmp.zipped.json`);
|
|
26
|
+
const kmpJsonIntermediateFixture = JSON.parse(fs.readFileSync(kmpJsonIntermediatePath, 'utf-8'));
|
|
27
|
+
const kmpJsonZippedFixture = JSON.parse(fs.readFileSync(kmpJsonZippedPath, 'utf-8'));
|
|
28
|
+
|
|
29
|
+
// We override the fixture version so that we can compare with the compiler output
|
|
30
|
+
kmpJsonIntermediateFixture.system.keymanDeveloperVersion = KEYMAN_VERSION.VERSION;
|
|
31
|
+
|
|
32
|
+
//
|
|
33
|
+
// Test just the transform from kps to kmp.json
|
|
34
|
+
//
|
|
35
|
+
it(`should transform ${modelID}.model.kps to kmp.json`, function () {
|
|
36
|
+
let source = fs.readFileSync(kpsPath, 'utf-8');
|
|
37
|
+
let kmpJson: KmpJsonFile;
|
|
38
|
+
|
|
39
|
+
assert.doesNotThrow(() => {
|
|
40
|
+
kmpJson = kmpCompiler.transformKpsToKmpObject(source, kpsPath);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Test that the kmp.json data is identical
|
|
44
|
+
assert.deepEqual(kmpJson, kmpJsonIntermediateFixture);
|
|
45
|
+
|
|
46
|
+
// Note that in-memory kmp.json still contains paths in the files array.
|
|
47
|
+
// However, when building the .kmp, the final written kmp.json data is
|
|
48
|
+
// modified to strip paths.
|
|
49
|
+
|
|
50
|
+
// This was used when building initial test data
|
|
51
|
+
//fs.writeFileSync(kmpJsonPath, JSON.stringify(kmpJson), 'utf-8');
|
|
52
|
+
});
|
|
53
|
+
it(`should build a full .kmp for ${modelID}`, async function() {
|
|
54
|
+
const source = fs.readFileSync(kpsPath, 'utf-8');
|
|
55
|
+
const zip = JSZip();
|
|
56
|
+
// Build kmp.json in memory
|
|
57
|
+
const kmpJson: KmpJsonFile = kmpCompiler.transformKpsToKmpObject(source, kpsPath);
|
|
58
|
+
// Build file.kmp in memory
|
|
59
|
+
const promise = kmpCompiler.buildKmpFile(kpsPath, kmpJson);
|
|
60
|
+
promise.then(data => {
|
|
61
|
+
// Check that file.kmp contains just 2 files - kmp.json and file.model.js,
|
|
62
|
+
// and that they match exactly what we expect
|
|
63
|
+
return zip.loadAsync(data, {checkCRC32: true}).then(zipFile => {
|
|
64
|
+
assert.equal(zipFile.length, 2);
|
|
65
|
+
return Promise.all([
|
|
66
|
+
zipFile.file("kmp.json").async('uint8array').then(kmpJsonOutput => {
|
|
67
|
+
assert.deepEqual(kmpJsonOutput, kmpJsonZippedFixture);
|
|
68
|
+
}),
|
|
69
|
+
zipFile.file(`${modelID}.model.js`).async('uint8array').then(modelJsFile => {
|
|
70
|
+
assert.deepEqual(modelJsFile, fs.readFileSync(jsPath));
|
|
71
|
+
})
|
|
72
|
+
]);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return promise;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
it('should generates a valid .kmp (zip) file', async function() {
|
|
81
|
+
// const kmpPath = makePathToFixture('khmer_angkor', 'build', 'khmer_angkor.kmp');
|
|
82
|
+
const kpsPath = makePathToFixture('khmer_angkor', 'source', 'khmer_angkor.kps');
|
|
83
|
+
const kmpJsonRefPath = makePathToFixture('khmer_angkor', 'ref', 'kmp.json');
|
|
84
|
+
|
|
85
|
+
const kmpCompiler = new KmpCompiler();
|
|
86
|
+
const source = fs.readFileSync(kpsPath, 'utf-8');
|
|
87
|
+
const kmpJsonFixture: KmpJsonFile = JSON.parse(fs.readFileSync(kmpJsonRefPath, 'utf-8'));
|
|
88
|
+
|
|
89
|
+
// We override the fixture version so that we can compare with the compiler output
|
|
90
|
+
kmpJsonFixture.system.keymanDeveloperVersion = KEYMAN_VERSION.VERSION;
|
|
91
|
+
|
|
92
|
+
let kmpJson = null;
|
|
93
|
+
assert.doesNotThrow(() => {
|
|
94
|
+
kmpJson = kmpCompiler.transformKpsToKmpObject(source, kpsPath);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const kmpData = await kmpCompiler.buildKmpFile(kpsPath, kmpJson);
|
|
98
|
+
|
|
99
|
+
const zip = JSZip();
|
|
100
|
+
|
|
101
|
+
let jszip = await zip.loadAsync(kmpData);
|
|
102
|
+
assert.isNotNull(jszip.file('kmp.json')); // kmp.json should be present
|
|
103
|
+
// kmp file should contain the following files
|
|
104
|
+
const expectedFiles = [
|
|
105
|
+
'FONTLOG.txt', 'image002.png', 'KAK_Documentation_EN.pdf', 'KAK_Documentation_KH.pdf',
|
|
106
|
+
'keyboard_layout.png', 'khmer_angkor.js', 'khmer_angkor.kmx', 'khmer_angkor.kvk',
|
|
107
|
+
'khmer_busra_kbd.ttf', 'Mondulkiri-R.ttf', 'OFL.txt', 'OFL-FAQ.txt', 'readme.htm',
|
|
108
|
+
'splash.gif', 'welcome.htm',
|
|
109
|
+
'kmp.json', // standard .kmp metadata file
|
|
110
|
+
];
|
|
111
|
+
|
|
112
|
+
assert.sameMembers(Object.entries(jszip.files).map(([s, o]) => o.name).sort(),
|
|
113
|
+
expectedFiles.sort(),
|
|
114
|
+
'khmer_angkor.kmp file should have exactly the expected files');
|
|
115
|
+
|
|
116
|
+
let kmpJsonData = JSON.parse(await jszip.file('kmp.json').async('string'));
|
|
117
|
+
assert.deepEqual(kmpJsonData, kmpJsonFixture);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../kmc/tsconfig.kmc-base.json",
|
|
3
|
+
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"rootDir": ".",
|
|
6
|
+
"rootDirs": ["./", "../src/"],
|
|
7
|
+
"outDir": "../build/test",
|
|
8
|
+
"baseUrl": ".",
|
|
9
|
+
"allowSyntheticDefaultImports": true, // for jszip
|
|
10
|
+
},
|
|
11
|
+
"include": [
|
|
12
|
+
"**/test-*.ts",
|
|
13
|
+
"helpers/*.ts"
|
|
14
|
+
],
|
|
15
|
+
"references": [
|
|
16
|
+
{ "path": "../" },
|
|
17
|
+
{ "path": "../../../../common/web/keyman-version/tsconfig.esm.json" },
|
|
18
|
+
]
|
|
19
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../kmc/tsconfig.kmc-base.json",
|
|
3
|
+
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"outDir": "build/src/",
|
|
6
|
+
"rootDir": "src/",
|
|
7
|
+
"allowSyntheticDefaultImports": true, // for jszip
|
|
8
|
+
},
|
|
9
|
+
"include": [
|
|
10
|
+
"src/**/*.ts"
|
|
11
|
+
],
|
|
12
|
+
"references": [
|
|
13
|
+
{ "path": "../../../common/web/keyman-version/tsconfig.esm.json" },
|
|
14
|
+
]
|
|
15
|
+
}
|