chore(developer): Merge branch 'beta' into fix/developer/font-family-returns-null-if-ttfMeta-promise-errors

This commit is contained in:
Dr Mark C. Sinclair 2024-03-13 10:04:33 +00:00
commit 9ee45b9306
13 changed files with 5938 additions and 296 deletions

View file

@ -1,5 +1,10 @@
# Keyman Version History
## 17.0.287 beta 2024-03-12
* chore(developer): resolve excessive-fatal-exception issue (#10949)
* fix(linux): Remove `ibus-keyman.post{inst,rm}` and verify that `ibus-daemon` is running when we start km-config (#10788)
## 17.0.286 beta 2024-03-11
* chore(web): improve the clarity of hints on OSK for Android (#10971)

View file

@ -1 +1 @@
17.0.287
17.0.288

View file

@ -271,6 +271,7 @@ export class KeyboardInfoCompiler implements KeymanCompiler {
if(sources.jsFilename) {
keyboard_info.jsFilename = this.callbacks.path.basename(sources.jsFilename);
// Always overwrite with actual file size
/* c8 ignore next 5 */
keyboard_info.jsFileSize = this.callbacks.fileSize(sources.jsFilename);
if(keyboard_info.jsFileSize === undefined) {
this.callbacks.reportMessage(KeyboardInfoCompilerMessages.Error_FileDoesNotExist({filename:sources.jsFilename}));

View file

@ -0,0 +1 @@
This is a file used to test the license is not valid error (see keyboard-info-compiler-messages.ts)

View file

@ -1,63 +0,0 @@
{
"license": "mit",
"languages": {
"km": {
"oskFont": {
"family": "Khmer Busra Kbd",
"source": [
"khmer_busra_kbd.ttf"
]
},
"font": {
"family": "Khmer Mondulkiri",
"source": [
"Mondulkiri-R.ttf"
]
},
"examples": [{
"keys": "x j m E r",
"text": "\u1781\u17D2\u1798\u17C2\u179A",
"note": "Name of language"
}],
"displayName": "Khmer",
"languageName": "Khmer"
}
},
"description": "<p>Khmer Unicode keyboard layout based on the NiDA keyboard layout. Automatically corrects many common keying errors.</p>",
"related": {
"khmer10": {
"deprecates": true
}
},
"id": "khmer_angkor",
"name": "Khmer Angkor",
"authorName": "Makara Sok",
"authorEmail": "makara_sok@sil.org",
"lastModifiedDate": "2022-09-20T19:44:08Z",
"sourcePath": "release/k/khmer_angkor",
"version": "1.3",
"packageFilename": "khmer_angkor.kmp",
"jsFilename": "khmer_angkor.js",
"encodings": [
"unicode"
],
"jsFileSize": 159640,
"packageFileSize": 4291221,
"packageIncludes": [
"visualKeyboard",
"welcome",
"fonts",
"documentation"
],
"minKeymanVersion": "10.0",
"helpLink": "https://help.keyman.com/keyboard/khmer_angkor",
"platformSupport": {
"windows": "full",
"macos": "full",
"linux": "full",
"android": "full",
"ios": "full",
"desktopWeb": "full",
"mobileWeb": "full"
}
}

View file

@ -1,187 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<KeymanDeveloperProject>
<Options>
<BuildPath>$PROJECTPATH\build</BuildPath>
<CompilerWarningsAsErrors>True</CompilerWarningsAsErrors>
<WarnDeprecatedCode>True</WarnDeprecatedCode>
<CheckFilenameConventions>False</CheckFilenameConventions>
<ProjectType>keyboard</ProjectType>
</Options>
<Files>
<File>
<ID>id_f347675c33d2e6b1c705c787fad4941a</ID>
<Filename>khmer_angkor.kmn</Filename>
<Filepath>source\khmer_angkor.kmn</Filepath>
<FileVersion>1.3</FileVersion>
<FileType>.kmn</FileType>
<Details>
<Name>Khmer Angkor</Name>
<Copyright>© 2015-2022 SIL International</Copyright>
<Message>More than just a Khmer Unicode keyboard.</Message>
</Details>
</File>
<File>
<ID>id_8d4eb765f80c9f2b0f769cf4e4aaa456</ID>
<Filename>khmer_angkor.kps</Filename>
<Filepath>source\khmer_angkor.kps</Filepath>
<FileVersion></FileVersion>
<FileType>.kps</FileType>
<Details>
<Name>Khmer Angkor</Name>
<Copyright>© 2015-2022 SIL International</Copyright>
</Details>
</File>
<File>
<ID>id_8a1efc7c4ab7cfece8aedd847679ca27</ID>
<Filename>khmer_angkor.ico</Filename>
<Filepath>source\khmer_angkor.ico</Filepath>
<FileVersion></FileVersion>
<FileType>.ico</FileType>
<ParentFileID>id_f347675c33d2e6b1c705c787fad4941a</ParentFileID>
</File>
<File>
<ID>id_8dc195db32d1fd0514de0ad51fff5df0</ID>
<Filename>khmer_angkor.js</Filename>
<Filepath>source\..\build\khmer_angkor.js</Filepath>
<FileVersion></FileVersion>
<FileType>.js</FileType>
<ParentFileID>id_8d4eb765f80c9f2b0f769cf4e4aaa456</ParentFileID>
</File>
<File>
<ID>id_10596632fcbf4138d24bcccf53e6ae01</ID>
<Filename>khmer_angkor.kvk</Filename>
<Filepath>source\..\build\khmer_angkor.kvk</Filepath>
<FileVersion></FileVersion>
<FileType>.kvk</FileType>
<ParentFileID>id_8d4eb765f80c9f2b0f769cf4e4aaa456</ParentFileID>
</File>
<File>
<ID>id_0a851f95ce553ecd62cbee6c32ced68f</ID>
<Filename>khmer_angkor.kmx</Filename>
<Filepath>source\..\build\khmer_angkor.kmx</Filepath>
<FileVersion></FileVersion>
<FileType>.kmx</FileType>
<ParentFileID>id_8d4eb765f80c9f2b0f769cf4e4aaa456</ParentFileID>
</File>
<File>
<ID>id_d8b6eb05f4b7e2945c10e04c1f49e4c8</ID>
<Filename>keyboard_layout.png</Filename>
<Filepath>source\welcome\keyboard_layout.png</Filepath>
<FileVersion></FileVersion>
<FileType>.png</FileType>
<ParentFileID>id_8d4eb765f80c9f2b0f769cf4e4aaa456</ParentFileID>
</File>
<File>
<ID>id_724e5b4c63f10bc0abf7077f7c3172fc</ID>
<Filename>welcome.htm</Filename>
<Filepath>source\welcome\welcome.htm</Filepath>
<FileVersion></FileVersion>
<FileType>.htm</FileType>
<ParentFileID>id_8d4eb765f80c9f2b0f769cf4e4aaa456</ParentFileID>
</File>
<File>
<ID>id_35857cb2b54f123612735ec948400082</ID>
<Filename>FONTLOG.txt</Filename>
<Filepath>source\..\..\..\shared\fonts\khmer\mondulkiri\FONTLOG.txt</Filepath>
<FileVersion></FileVersion>
<FileType>.txt</FileType>
<ParentFileID>id_8d4eb765f80c9f2b0f769cf4e4aaa456</ParentFileID>
</File>
<File>
<ID>id_7e3afe5bb59b888b08b48cd5817d8de4</ID>
<Filename>Mondulkiri-B.ttf</Filename>
<Filepath>source\..\..\..\shared\fonts\khmer\mondulkiri\Mondulkiri-B.ttf</Filepath>
<FileVersion></FileVersion>
<FileType>.ttf</FileType>
<ParentFileID>id_8d4eb765f80c9f2b0f769cf4e4aaa456</ParentFileID>
</File>
<File>
<ID>id_b9734e80f86c69ea5ae4dfa9f0083d09</ID>
<Filename>Mondulkiri-BI.ttf</Filename>
<Filepath>source\..\..\..\shared\fonts\khmer\mondulkiri\Mondulkiri-BI.ttf</Filepath>
<FileVersion></FileVersion>
<FileType>.ttf</FileType>
<ParentFileID>id_8d4eb765f80c9f2b0f769cf4e4aaa456</ParentFileID>
</File>
<File>
<ID>id_25abe4d2b0abc03a5be5b666a8de776e</ID>
<Filename>Mondulkiri-I.ttf</Filename>
<Filepath>source\..\..\..\shared\fonts\khmer\mondulkiri\Mondulkiri-I.ttf</Filepath>
<FileVersion></FileVersion>
<FileType>.ttf</FileType>
<ParentFileID>id_8d4eb765f80c9f2b0f769cf4e4aaa456</ParentFileID>
</File>
<File>
<ID>id_b766568498108eee46ed1601ff69c47d</ID>
<Filename>Mondulkiri-R.ttf</Filename>
<Filepath>source\..\..\..\shared\fonts\khmer\mondulkiri\Mondulkiri-R.ttf</Filepath>
<FileVersion></FileVersion>
<FileType>.ttf</FileType>
<ParentFileID>id_8d4eb765f80c9f2b0f769cf4e4aaa456</ParentFileID>
</File>
<File>
<ID>id_84544d04133cab3dbfc86b91ad1a4e17</ID>
<Filename>OFL.txt</Filename>
<Filepath>source\..\..\..\shared\fonts\khmer\mondulkiri\OFL.txt</Filepath>
<FileVersion></FileVersion>
<FileType>.txt</FileType>
<ParentFileID>id_8d4eb765f80c9f2b0f769cf4e4aaa456</ParentFileID>
</File>
<File>
<ID>id_0c33fbefd1c20f487b1bea2343b3bb2c</ID>
<Filename>OFL-FAQ.txt</Filename>
<Filepath>source\..\..\..\shared\fonts\khmer\mondulkiri\OFL-FAQ.txt</Filepath>
<FileVersion></FileVersion>
<FileType>.txt</FileType>
<ParentFileID>id_8d4eb765f80c9f2b0f769cf4e4aaa456</ParentFileID>
</File>
<File>
<ID>id_a59d89fca36a310147645fa2604e521b</ID>
<Filename>KAK_Documentation_EN.pdf</Filename>
<Filepath>source\welcome\KAK_Documentation_EN.pdf</Filepath>
<FileVersion></FileVersion>
<FileType>.pdf</FileType>
<ParentFileID>id_8d4eb765f80c9f2b0f769cf4e4aaa456</ParentFileID>
</File>
<File>
<ID>id_5643c4cd3933b3ada0b4af6579305ec4</ID>
<Filename>KAK_Documentation_KH.pdf</Filename>
<Filepath>source\welcome\KAK_Documentation_KH.pdf</Filepath>
<FileVersion></FileVersion>
<FileType>.pdf</FileType>
<ParentFileID>id_8d4eb765f80c9f2b0f769cf4e4aaa456</ParentFileID>
</File>
<File>
<ID>id_8da344c4cea6f467013357fe099006f5</ID>
<Filename>readme.htm</Filename>
<Filepath>source\readme.htm</Filepath>
<FileVersion></FileVersion>
<FileType>.htm</FileType>
<ParentFileID>id_8d4eb765f80c9f2b0f769cf4e4aaa456</ParentFileID>
</File>
<File>
<ID>id_acb0dd94c60e345d999670e999cbd159</ID>
<Filename>image002.png</Filename>
<Filepath>source\welcome\image002.png</Filepath>
<FileVersion></FileVersion>
<FileType>.png</FileType>
<ParentFileID>id_8d4eb765f80c9f2b0f769cf4e4aaa456</ParentFileID>
</File>
<File>
<ID>id_4edf70bc019f05b5ad39a2ea727ad547</ID>
<Filename>khmer_busra_kbd.ttf</Filename>
<Filepath>source\..\..\..\shared\fonts\khmer\busrakbd\khmer_busra_kbd.ttf</Filepath>
<FileVersion></FileVersion>
<FileType>.ttf</FileType>
<ParentFileID>id_8d4eb765f80c9f2b0f769cf4e4aaa456</ParentFileID>
</File>
<File>
<ID>id_bc823844e4399751e1867016801f7327</ID>
<Filename>splash.gif</Filename>
<Filepath>source\splash.gif</Filepath>
<FileVersion></FileVersion>
<FileType>.gif</FileType>
<ParentFileID>id_8d4eb765f80c9f2b0f769cf4e4aaa456</ParentFileID>
</File>
</Files>
</KeymanDeveloperProject>

View file

@ -0,0 +1 @@
khmer_angkor.js -text

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,163 @@
<?xml version="1.0" encoding="utf-8"?>
<Package>
<System>
<KeymanDeveloperVersion>15.0.266.0</KeymanDeveloperVersion>
<FileVersion>7.0</FileVersion>
</System>
<Options>
<ExecuteProgram></ExecuteProgram>
<ReadMeFile>readme.htm</ReadMeFile>
<GraphicFile>splash.gif</GraphicFile>
<MSIFileName></MSIFileName>
<MSIOptions></MSIOptions>
<!-- ERROR_NoLicenseFound -->
<FollowKeyboardVersion/>
</Options>
<StartMenu>
<Folder></Folder>
<Items/>
</StartMenu>
<Info>
<Name URL="">Khmer Angkor</Name>
<Copyright URL="">© 2015-2022 SIL International</Copyright>
<Author URL="mailto:makara_sok@sil.org">Makara Sok</Author>
<Version URL=""></Version>
<WebSite URL="https://keyman.com/keyboards/khmer_angkor">https://keyman.com/keyboards/khmer_angkor</WebSite>
<Description URL="">Khmer Unicode keyboard layout based on the NiDA keyboard layout. Automatically corrects many common keying errors.</Description>
</Info>
<RelatedPackages>
<RelatedPackage ID="khmer10" Relationship="deprecates" />
</RelatedPackages>
<Files>
<File>
<Name>..\LICENSE.md</Name>
<Description>File LICENSE.md</Description>
<CopyLocation>0</CopyLocation>
<FileType>.md</FileType>
</File>
<File>
<Name>..\build\khmer_angkor.js</Name>
<Description>File khmer_angkor.js</Description>
<CopyLocation>0</CopyLocation>
<FileType>.js</FileType>
</File>
<File>
<Name>..\build\khmer_angkor.kvk</Name>
<Description>File khmer_angkor.kvk</Description>
<CopyLocation>0</CopyLocation>
<FileType>.kvk</FileType>
</File>
<File>
<Name>..\build\khmer_angkor.kmx</Name>
<Description>Keyboard Khmer Angkor</Description>
<CopyLocation>0</CopyLocation>
<FileType>.kmx</FileType>
</File>
<File>
<Name>welcome\keyboard_layout.png</Name>
<Description>File keyboard_layout.png</Description>
<CopyLocation>0</CopyLocation>
<FileType>.png</FileType>
</File>
<File>
<Name>welcome\welcome.htm</Name>
<Description>File welcome.htm</Description>
<CopyLocation>0</CopyLocation>
<FileType>.htm</FileType>
</File>
<File>
<Name>..\shared\fonts\khmer\mondulkiri\FONTLOG.txt</Name>
<Description>File FONTLOG.txt</Description>
<CopyLocation>0</CopyLocation>
<FileType>.txt</FileType>
</File>
<File>
<Name>..\shared\fonts\khmer\mondulkiri\Mondulkiri-B.ttf</Name>
<Description>Font Khmer Mondulkiri Bold</Description>
<CopyLocation>0</CopyLocation>
<FileType>.ttf</FileType>
</File>
<File>
<Name>..\shared\fonts\khmer\mondulkiri\Mondulkiri-BI.ttf</Name>
<Description>Font Khmer Mondulkiri Bold Italic</Description>
<CopyLocation>0</CopyLocation>
<FileType>.ttf</FileType>
</File>
<File>
<Name>..\shared\fonts\khmer\mondulkiri\Mondulkiri-I.ttf</Name>
<Description>Font Khmer Mondulkiri Italic</Description>
<CopyLocation>0</CopyLocation>
<FileType>.ttf</FileType>
</File>
<File>
<Name>..\shared\fonts\khmer\mondulkiri\Mondulkiri-R.ttf</Name>
<Description>Font Khmer Mondulkiri</Description>
<CopyLocation>0</CopyLocation>
<FileType>.ttf</FileType>
</File>
<File>
<Name>..\shared\fonts\khmer\mondulkiri\OFL.txt</Name>
<Description>File OFL.txt</Description>
<CopyLocation>0</CopyLocation>
<FileType>.txt</FileType>
</File>
<File>
<Name>..\shared\fonts\khmer\mondulkiri\OFL-FAQ.txt</Name>
<Description>File OFL-FAQ.txt</Description>
<CopyLocation>0</CopyLocation>
<FileType>.txt</FileType>
</File>
<File>
<Name>welcome\KAK_Documentation_EN.pdf</Name>
<Description>File KAK_Documentation_EN.pdf</Description>
<CopyLocation>0</CopyLocation>
<FileType>.pdf</FileType>
</File>
<File>
<Name>welcome\KAK_Documentation_KH.pdf</Name>
<Description>File KAK_Documentation_KH.pdf</Description>
<CopyLocation>0</CopyLocation>
<FileType>.pdf</FileType>
</File>
<File>
<Name>readme.htm</Name>
<Description>File readme.htm</Description>
<CopyLocation>0</CopyLocation>
<FileType>.htm</FileType>
</File>
<File>
<Name>welcome\image002.png</Name>
<Description>File image002.png</Description>
<CopyLocation>0</CopyLocation>
<FileType>.png</FileType>
</File>
<File>
<Name>..\shared\fonts\khmer\busrakbd\khmer_busra_kbd.ttf</Name>
<Description>Font KhmerBusraKbd</Description>
<CopyLocation>0</CopyLocation>
<FileType>.ttf</FileType>
</File>
<File>
<Name>splash.gif</Name>
<Description>File splash.gif</Description>
<CopyLocation>0</CopyLocation>
<FileType>.gif</FileType>
</File>
</Files>
<Keyboards>
<Keyboard>
<Name>Khmer Angkor</Name>
<ID>khmer_angkor</ID>
<Version>1.3</Version>
<OSKFont>..\shared\fonts\khmer\busrakbd\khmer_busra_kbd.ttf</OSKFont>
<DisplayFont>..\shared\fonts\khmer\mondulkiri\Mondulkiri-R.ttf</DisplayFont>
<Languages>
<Language ID="km">Central Khmer (Khmer, Cambodia)</Language>
</Languages>
<Examples>
<Example ID="km" Keys="x j m E r" Text="ខ្មែរ" Note="Name of language" />
</Examples>
</Keyboard>
</Keyboards>
<Strings/>
</Package>

View file

@ -2,9 +2,10 @@ import { assert } from 'chai';
import 'mocha';
import { KeyboardInfoCompilerMessages } from '../src/keyboard-info-compiler-messages.js';
import { TestCompilerCallbacks, verifyCompilerMessagesObject } from '@keymanapp/developer-test-helpers';
import { CompilerErrorNamespace, KmpJsonFile } from '@keymanapp/common-types';
import { CompilerErrorNamespace, KmpJsonFile, KeymanFileTypes } from '@keymanapp/common-types';
import { makePathToFixture } from './helpers/index.js';
import { KeyboardInfoCompiler } from '../src/keyboard-info-compiler.js';
import { KeyboardInfoCompiler, KeyboardInfoCompilerResult } from '../src/keyboard-info-compiler.js';
import { KeyboardInfoFile } from '../src/keyboard-info-file.js';
const callbacks = new TestCompilerCallbacks();
@ -17,6 +18,306 @@ describe('KeyboardInfoCompilerMessages', function () {
return verifyCompilerMessagesObject(KeyboardInfoCompilerMessages, CompilerErrorNamespace.KeyboardInfoCompiler);
});
// ERROR_FileDoesNotExist (loadJsFile)
it('should generate ERROR_FileDoesNotExist error if .js file does not exist', async function() {
const jsFilename = makePathToFixture('khmer_angkor', 'build', 'xxx.js');
const kpsFilename = makePathToFixture('khmer_angkor', 'source', 'khmer_angkor.kps');
const kmpFilename = makePathToFixture('khmer_angkor', 'build', 'khmer_angkor.kmp');
const sources = {
kmpFilename,
sourcePath: 'release/k/khmer_angkor',
kpsFilename,
jsFilename: jsFilename,
forPublishing: true,
};
const compiler = new KeyboardInfoCompiler();
assert.isTrue(await compiler.init(callbacks, {sources}));
let result: KeyboardInfoCompilerResult = null;
try {
result = await compiler.run(kmpFilename, null);
} catch(e) {
callbacks.printMessages();
throw e;
}
assert.isNull(result);
assert.isTrue(callbacks.hasMessage(KeyboardInfoCompilerMessages.ERROR_FileDoesNotExist),
`ERROR_FileDoesNotExist not generated, instead got: `+JSON.stringify(callbacks.messages,null,2));
assert.isTrue(nodeCompilerMessage(callbacks, KeyboardInfoCompilerMessages.ERROR_FileDoesNotExist).includes(KeymanFileTypes.Binary.WebKeyboard),
KeymanFileTypes.Binary.WebKeyboard+' not found in the message');
});
// ERROR_FileDoesNotExist (.kmp fileSize)
it('should generate ERROR_FileDoesNotExist error if .kmp file does not exist', async function() {
const jsFilename = makePathToFixture('no-kmp', 'build', 'khmer_angkor.js');
const kpsFilename = makePathToFixture('no-kmp', 'source', 'khmer_angkor.kps');
const kmpFilename = makePathToFixture('no-kmp', 'build', 'khmer_angkor.kmp');
const sources = {
kmpFilename,
sourcePath: 'release/k/no-kmp',
kpsFilename,
jsFilename: jsFilename,
forPublishing: true,
};
const compiler = new KeyboardInfoCompiler();
assert.isTrue(await compiler.init(callbacks, {sources}));
// stubbing fillLanguages internal function to avoid pulling in font resources in fixture
compiler['fillLanguages'] = async (_kpsFilename: string, _keyboard_info: KeyboardInfoFile, _kmpJsonData: KmpJsonFile.KmpJsonFile): Promise<boolean> => true;
let result: KeyboardInfoCompilerResult = null;
try {
result = await compiler.run(kmpFilename, null);
} catch(e) {
callbacks.printMessages();
throw e;
}
assert.isNull(result);
assert.isTrue(callbacks.hasMessage(KeyboardInfoCompilerMessages.ERROR_FileDoesNotExist),
`ERROR_FileDoesNotExist not generated, instead got: `+JSON.stringify(callbacks.messages,null,2));
assert.isTrue(nodeCompilerMessage(callbacks, KeyboardInfoCompilerMessages.ERROR_FileDoesNotExist).includes(KeymanFileTypes.Binary.Package),
KeymanFileTypes.Binary.Package+' not found in the message');
});
// ERROR_FileDoesNotExist (font file not in package)
it('should generate ERROR_FileDoesNotExist error if font file is missing from package', async function() {
const jsFilename = makePathToFixture('khmer_angkor', 'build', 'khmer_angkor.js');
const kpsFilename = makePathToFixture('khmer_angkor', 'source', 'khmer_angkor.kps');
const kmpFilename = makePathToFixture('khmer_angkor', 'build', 'khmer_angkor.kmp');
const sources = {
kmpFilename,
sourcePath: 'release/k/khmer_angkor',
kpsFilename,
jsFilename: jsFilename,
forPublishing: true,
};
const compiler = new KeyboardInfoCompiler();
assert.isTrue(await compiler.init(callbacks, {sources}));
const kmpJsonData: KmpJsonFile.KmpJsonFile = {system: {fileVersion: "7.0", keymanDeveloperVersion: "17.0.204"},
options: {},
files: []}
const source = ["Mondulkiri-R.ttf"]
const result = await compiler['fontSourceToKeyboardInfoFont'](kpsFilename, kmpJsonData, source)
assert.isNull(result);
assert.isTrue(callbacks.hasMessage(KeyboardInfoCompilerMessages.ERROR_FileDoesNotExist),
`ERROR_FileDoesNotExist not generated, instead got: `+JSON.stringify(callbacks.messages,null,2));
assert.isTrue(nodeCompilerMessage(callbacks, KeyboardInfoCompilerMessages.ERROR_FileDoesNotExist).includes(source[0]),
source[0]+' not found in the message');
});
// ERROR_FileDoesNotExist (font file not on disk)
it('should generate ERROR_FileDoesNotExist error if font file is missing from disk', async function() {
const jsFilename = makePathToFixture('khmer_angkor', 'build', 'khmer_angkor.js');
const kpsFilename = makePathToFixture('khmer_angkor', 'source', 'khmer_angkor.kps');
const kmpFilename = makePathToFixture('khmer_angkor', 'build', 'khmer_angkor.kmp');
const sources = {
kmpFilename,
sourcePath: 'release/k/khmer_angkor',
kpsFilename,
jsFilename: jsFilename,
forPublishing: true,
};
const compiler = new KeyboardInfoCompiler();
assert.isTrue(await compiler.init(callbacks, {sources}));
const kmpJsonData: KmpJsonFile.KmpJsonFile = {system: {fileVersion: "7.0", keymanDeveloperVersion: "17.0.204"},
options: {},
files: [{name: "../shared/fonts/khmer/mondulkiri/xxx.ttf", description: "Font not on disk"}]}
const source = ["xxx.ttf"]
const result = await compiler['fontSourceToKeyboardInfoFont'](kpsFilename, kmpJsonData, source)
assert.isNull(result);
assert.isTrue(callbacks.hasMessage(KeyboardInfoCompilerMessages.ERROR_FileDoesNotExist),
`ERROR_FileDoesNotExist not generated, instead got: `+JSON.stringify(callbacks.messages,null,2));
assert.isTrue(nodeCompilerMessage(callbacks, KeyboardInfoCompilerMessages.ERROR_FileDoesNotExist).includes(kmpJsonData.files[0].name),
kmpJsonData.files[0].name+' not found in the message');
});
// ERROR_LicenseFileIsMissing
it('should generate ERROR_LicenseFileIsMissing error if license file is missing from disk', async function() {
const jsFilename = makePathToFixture('khmer_angkor', 'build', 'khmer_angkor.js');
const kpsFilename = makePathToFixture('khmer_angkor', 'source', 'khmer_angkor.kps');
const kmpFilename = makePathToFixture('khmer_angkor', 'build', 'khmer_angkor.kmp');
const sources = {
kmpFilename,
sourcePath: 'release/k/khmer_angkor',
kpsFilename,
jsFilename: jsFilename,
forPublishing: true,
};
const compiler = new KeyboardInfoCompiler();
assert.isTrue(await compiler.init(callbacks, {sources}));
const licenseFilename = makePathToFixture('khmer_angkor', 'xxx.md');
const result = compiler['isLicenseMIT'](licenseFilename)
assert.isFalse(result);
assert.isTrue(callbacks.hasMessage(KeyboardInfoCompilerMessages.ERROR_LicenseFileIsMissing),
`ERROR_LicenseFileIsMissing not generated, instead got: `+JSON.stringify(callbacks.messages,null,2));
assert.isTrue(nodeCompilerMessage(callbacks, KeyboardInfoCompilerMessages.ERROR_LicenseFileIsMissing).includes(licenseFilename),
licenseFilename+' not found in the message');
});
// ERROR_LicenseFileIsDamaged (error on decode)
it('should generate ERROR_LicenseFileIsDamaged error if license file throws error on decode', async function() {
const jsFilename = makePathToFixture('khmer_angkor', 'build', 'khmer_angkor.js');
const kpsFilename = makePathToFixture('khmer_angkor', 'source', 'khmer_angkor.kps');
const kmpFilename = makePathToFixture('khmer_angkor', 'build', 'khmer_angkor.kmp');
const sources = {
kmpFilename,
sourcePath: 'release/k/khmer_angkor',
kpsFilename,
jsFilename: jsFilename,
forPublishing: true,
};
const compiler = new KeyboardInfoCompiler();
assert.isTrue(await compiler.init(callbacks, {sources}));
const licenseFilename = makePathToFixture('khmer_angkor', 'LICENSE.md');
const originalDecode = TextDecoder.prototype.decode
TextDecoder.prototype.decode = () => { throw new Error() }
const result = compiler['isLicenseMIT'](licenseFilename)
TextDecoder.prototype.decode = originalDecode
assert.isFalse(result);
assert.isTrue(callbacks.hasMessage(KeyboardInfoCompilerMessages.ERROR_LicenseFileIsDamaged),
`ERROR_LicenseFileIsDamaged not generated, instead got: `+JSON.stringify(callbacks.messages,null,2));
assert.isTrue(nodeCompilerMessage(callbacks, KeyboardInfoCompilerMessages.ERROR_LicenseFileIsDamaged).includes(licenseFilename),
licenseFilename+' not found in the message');
});
// ERROR_LicenseFileIsDamaged (null on decode)
it('should generate ERROR_LicenseFileIsDamaged error if license file returns null on decode', async function() {
const jsFilename = makePathToFixture('khmer_angkor', 'build', 'khmer_angkor.js');
const kpsFilename = makePathToFixture('khmer_angkor', 'source', 'khmer_angkor.kps');
const kmpFilename = makePathToFixture('khmer_angkor', 'build', 'khmer_angkor.kmp');
const sources = {
kmpFilename,
sourcePath: 'release/k/khmer_angkor',
kpsFilename,
jsFilename: jsFilename,
forPublishing: true,
};
const compiler = new KeyboardInfoCompiler();
assert.isTrue(await compiler.init(callbacks, {sources}));
const licenseFilename = makePathToFixture('khmer_angkor', 'LICENSE.md');
const originalDecode = TextDecoder.prototype.decode
TextDecoder.prototype.decode = () => { return null }
const result = compiler['isLicenseMIT'](licenseFilename)
TextDecoder.prototype.decode = originalDecode
assert.isFalse(result);
assert.isTrue(callbacks.hasMessage(KeyboardInfoCompilerMessages.ERROR_LicenseFileIsDamaged),
`ERROR_LicenseFileIsDamaged not generated, instead got: `+JSON.stringify(callbacks.messages,null,2));
assert.isTrue(nodeCompilerMessage(callbacks, KeyboardInfoCompilerMessages.ERROR_LicenseFileIsDamaged).includes(licenseFilename),
licenseFilename+' not found in the message');
});
// ERROR_LicenseIsNotValid
it('should generate ERROR_LicenseIsNotValid error if license file is invalid', async function() {
const jsFilename = makePathToFixture('khmer_angkor', 'build', 'khmer_angkor.js');
const kpsFilename = makePathToFixture('khmer_angkor', 'source', 'khmer_angkor.kps');
const kmpFilename = makePathToFixture('khmer_angkor', 'build', 'khmer_angkor.kmp');
const sources = {
kmpFilename,
sourcePath: 'release/k/invalid-license',
kpsFilename,
jsFilename: jsFilename,
forPublishing: true,
};
const compiler = new KeyboardInfoCompiler();
assert.isTrue(await compiler.init(callbacks, {sources}));
const licenseFilename = makePathToFixture('invalid-license', 'invalid_license.md');
const result = compiler['isLicenseMIT'](licenseFilename)
assert.isFalse(result);
assert.isTrue(callbacks.hasMessage(KeyboardInfoCompilerMessages.ERROR_LicenseIsNotValid),
`ERROR_LicenseIsNotValid not generated, instead got: `+JSON.stringify(callbacks.messages,null,2));
assert.isTrue(nodeCompilerMessage(callbacks, KeyboardInfoCompilerMessages.ERROR_LicenseIsNotValid).includes(licenseFilename),
licenseFilename+' not found in the message');
});
// ERROR_CannotBuildWithoutKmpFile
it('should generate ERROR_CannotBuildWithoutKmpFile error if .kmp file is not in sources', async function() {
const jsFilename = makePathToFixture('no-kmp', 'build', 'khmer_angkor.js');
const kpsFilename = makePathToFixture('no-kmp', 'source', 'khmer_angkor.kps');
const kmpFilename = makePathToFixture('no-kmp', 'build', 'khmer_angkor.kmp');
const sources = {
kmpFilename: '',
sourcePath: 'release/k/no-kmp',
kpsFilename,
jsFilename: jsFilename,
forPublishing: true,
};
const compiler = new KeyboardInfoCompiler();
assert.isTrue(await compiler.init(callbacks, {sources}));
let result: KeyboardInfoCompilerResult = null;
try {
result = await compiler.run(kmpFilename, null);
} catch(e) {
callbacks.printMessages();
throw e;
}
assert.isNull(result);
assert.isTrue(callbacks.hasMessage(KeyboardInfoCompilerMessages.ERROR_CannotBuildWithoutKmpFile),
`ERROR_CannotBuildWithoutKmpFile not generated, instead got: `+JSON.stringify(callbacks.messages,null,2));
});
// ERROR_NoLicenseFound
it('should generate ERROR_NoLicenseFound error if licence file is not in .kps options', async function() {
const jsFilename = makePathToFixture('no-license-in-kps-sources', 'build', 'khmer_angkor.js');
const kpsFilename = makePathToFixture('no-license-in-kps-sources', 'source', 'khmer_angkor.kps');
const kmpFilename = makePathToFixture('no-license-in-kps-sources', 'build', 'khmer_angkor.kmp');
const sources = {
kmpFilename,
sourcePath: 'release/k/no-license-in-kps-sources',
kpsFilename,
jsFilename: jsFilename,
forPublishing: true,
};
const compiler = new KeyboardInfoCompiler();
assert.isTrue(await compiler.init(callbacks, {sources}));
let result: KeyboardInfoCompilerResult = null;
try {
result = await compiler.run(kmpFilename, null);
} catch(e) {
callbacks.printMessages();
throw e;
}
assert.isNull(result);
assert.isTrue(callbacks.hasMessage(KeyboardInfoCompilerMessages.ERROR_NoLicenseFound),
`ERROR_NoLicenseFound not generated, instead got: `+JSON.stringify(callbacks.messages,null,2));
});
// ERROR_FontFileCannotBeRead
it('should generate ERROR_FontFileCannotBeRead error if font family cannot be obtained from file', async function() {
@ -44,7 +345,7 @@ describe('KeyboardInfoCompilerMessages', function () {
`ERROR_FontFileCannotBeRead not generated, instead got: `+JSON.stringify(callbacks.messages,null,2));
assert.isTrue(nodeCompilerMessage(callbacks, KeyboardInfoCompilerMessages.ERROR_FontFileCannotBeRead).includes(kmpJsonData.files[0].name),
kmpJsonData.files[0].name+' not found in the message');
});
});
});
function nodeCompilerMessage(ncb: TestCompilerCallbacks, code: number): string {

View file

@ -4,9 +4,6 @@ import 'mocha';
import { TestCompilerCallbacks } from '@keymanapp/developer-test-helpers';
import { makePathToFixture } from './helpers/index.js';
import { KeyboardInfoCompiler, KeyboardInfoCompilerResult } from '../src/keyboard-info-compiler.js';
import { KeyboardInfoCompilerMessages } from '../src/keyboard-info-compiler-messages.js';
import { KeymanFileTypes, KmpJsonFile } from '@keymanapp/common-types';
import { KeyboardInfoFile } from './keyboard-info-file.js';
const callbacks = new TestCompilerCallbacks();
@ -53,43 +50,4 @@ describe('keyboard-info-compiler', function () {
assert.deepEqual(actual, expected);
});
// ERROR_FileDoesNotExist (.kmp fileSize)
it('should generate FileDoesNotExist error if .kmp file does not exist', async function() {
const jsFilename = makePathToFixture('no-kmp', 'build', 'khmer_angkor.js');
const kpsFilename = makePathToFixture('no-kmp', 'source', 'khmer_angkor.kps');
const kmpFilename = makePathToFixture('no-kmp', 'build', 'khmer_angkor.kmp');
const sources = {
kmpFilename,
sourcePath: 'release/k/no-kmp',
kpsFilename,
jsFilename: jsFilename,
forPublishing: true,
};
const compiler = new KeyboardInfoCompiler();
assert.isTrue(await compiler.init(callbacks, {sources}));
// stubbing fillLanguages internal function to avoid pulling in font resources in fixture
compiler['fillLanguages'] = async (_kpsFilename: string, _keyboard_info: KeyboardInfoFile, _kmpJsonData: KmpJsonFile.KmpJsonFile): Promise<boolean> => true;
let result: KeyboardInfoCompilerResult = null;
try {
result = await compiler.run(kmpFilename, null);
} catch(e) {
callbacks.printMessages();
throw e;
}
assert.isNull(result);
assert.isTrue(callbacks.hasMessage(KeyboardInfoCompilerMessages.ERROR_FileDoesNotExist),
`ERROR_FileDoesNotExist not generated, instead got: `+JSON.stringify(callbacks.messages,null,2));
assert.isTrue(nodeCompilerMessage(callbacks, KeyboardInfoCompilerMessages.ERROR_FileDoesNotExist).includes(KeymanFileTypes.Binary.Package),
KeymanFileTypes.Binary.Package+' not found in the message');
});
});
function nodeCompilerMessage(ncb: TestCompilerCallbacks, code: number): string {
return ncb.messages.find((item) => item.code == code).message ?? '';
}