Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: merge master into feature-macos-core 🍕 #9873

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Keyman Version History

## 17.0.199 alpha 2023-10-26

* fix(developer): handle xml errors in package compiler (#9821)
* fix(developer): server download Keyman link (#9822)
* chore(common): handle invalid XML in kpj-file-reader (#9824)
* fix(developer): reduce confusion in Unicode fields in touch layout editor (#9839)

## 17.0.198 alpha 2023-10-25

* chore(common): Add entries from 16.0 HISTORY.md (#9826)
Expand Down
2 changes: 1 addition & 1 deletion VERSION.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
17.0.199
17.0.200
7 changes: 6 additions & 1 deletion common/web/types/src/kpj/kpj-file-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ export class KPJFileReader {
emptyTag: ''
});

parser.parseString(file, (e: unknown, r: unknown) => { data = r as KPJFile });
parser.parseString(file, (e: unknown, r: unknown) => {
if(e) {
throw e;
}
data = r as KPJFile;
});
data = this.boxArrays(data);
for(let file of data.KeymanDeveloperProject?.Files?.File) {
// xml2js imports <Details/> as '' so we will just delete the empty string
Expand Down
13 changes: 11 additions & 2 deletions developer/src/kmc-package/src/compiler/kmp-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class KmpCompiler {
public transformKpsToKmpObject(kpsFilename: string): KmpJsonFile.KmpJsonFile {
const kps = this.loadKpsFile(kpsFilename);
if(!kps) {
// errors will already have been reported by loadKpsFile
return null;
}
return this.transformKpsFileToKmpObject(kpsFilename, kps);
Expand All @@ -48,11 +49,19 @@ export class KmpCompiler {
let parser = new xml2js.Parser({
explicitArray: false
});
// TODO: add unit test for xml errors parsing .kps file
parser.parseString(data, (e: unknown, r: unknown) => { if(e) throw e; a = r as KpsFile.KpsPackage });

try {
parser.parseString(data, (e: unknown, r: unknown) => { if(e) throw e; a = r as KpsFile.KpsPackage });
} catch(e) {
this.callbacks.reportMessage(CompilerMessages.Error_InvalidPackageFile({e}));
}
return a;
})();

if(!kpsPackage) {
return null;
}

const kps: KpsFile.KpsFile = kpsPackage.Package;
return kps;
}
Expand Down
4 changes: 4 additions & 0 deletions developer/src/kmc-package/src/compiler/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,9 @@ export class CompilerMessages {
static Hint_PackageContainsSourceFile = (o:{filename:string}) => m(this.HINT_PackageContainsSourceFile,
`The source file ${o.filename} should not be included in the package; instead include the compiled result.`);
static HINT_PackageContainsSourceFile = SevHint | 0x001D;

static Error_InvalidPackageFile = (o:{e:any}) => m(this.ERROR_InvalidPackageFile,
`Package source file is invalid: ${(o.e ?? 'unknown error').toString()}`);
static ERROR_InvalidPackageFile = SevError | 0x001E;
}

Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export class WindowsPackageInstallerCompiler {

public async compile(kpsFilename: string, sources: WindowsPackageInstallerSources): Promise<Uint8Array> {
const kps = this.kmpCompiler.loadKpsFile(kpsFilename);
if(!kps) {
// errors will already have been reported by loadKpsFile
return null;
}

// Check existence of required files
for(const filename of [sources.licenseFilename, sources.msiFilename, sources.setupExeFilename]) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<Package>
<System>
<KeymanDeveloperVersion>15.0.266.0</KeymanDeveloperVersion>
<FileVersion>7.0</FileVersion>
</System>
<Info>
<Name URL="">SENĆOŦEN (Saanich Dialect) Keyboard</Name>
<!-- error_invalid_package_file -->
<Copyright URL="">© 2019 National Research Council Canada & this test</Copyright>
<Author URL="mailto:[email protected]">Eddie Antonio Santos</Author>
<Version>1.0</Version>
</Info>
<Files>
<File>
<Name>basic.kmx</Name>
<Description>Keyboard Basic</Description>
<CopyLocation>0</CopyLocation>
<FileType>.kmx</FileType>
</File>
</Files>
<Keyboards>
<Keyboard>
<Name>Basic</Name>
<ID>basic</ID>
<Version>1.0</Version>
<Languages>
<Language ID="KM">Khmer</Language>
</Languages>
</Keyboard>
</Keyboards>
</Package>
7 changes: 7 additions & 0 deletions developer/src/kmc-package/test/test-messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,11 @@ describe('CompilerMessages', function () {
CompilerMessages.HINT_PackageContainsSourceFile);
});

// ERROR_InvalidPackageFile

it('should generate ERROR_InvalidPackageFile if package source file contains invalid XML', async function() {
testForMessage(this, ['invalid', 'error_invalid_package_file.kps'],
CompilerMessages.ERROR_InvalidPackageFile);
});

});
3 changes: 2 additions & 1 deletion developer/src/kmc/src/util/projectLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ function loadDefaultProjectFromFolder(infile: string, callbacks: CompilerCallbac
function loadProjectFromFile(infile: string, callbacks: CompilerCallbacks): KeymanDeveloperProject {
const kpjData = callbacks.loadFile(infile);
const reader = new KPJFileReader(callbacks);
const kpj = reader.read(kpjData);
let kpj = null;
try {
kpj = reader.read(kpjData);
reader.validate(kpj);
} catch(e) {
callbacks.reportMessage(InfrastructureMessages.Error_InvalidProjectFile({message: (e??'').toString()}));
Expand Down
12 changes: 6 additions & 6 deletions developer/src/server/src/site/packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ menuDropdown.onclick = (value) => {
menuDropdown.set(''); // we never show an 'active' package
if(value == '#install-keyman') {
let href = '';
switch(keyman.util.device.OS) {
case 'iOS': href = 'https://keyman.com/go/developer/'+versionMajor+'/ios-app'; break;
case 'Android': href = 'https://keyman.com/go/developer/'+versionMajor+'/android-app'; break;
case 'Linux': href = 'https://keyman.com/linux/download'; break;
case 'Windows': href = 'https://keyman.com/go/download/keyman-windows'; break;
case 'MacOSX': href = 'https://keyman.com/go/download/keyman-mac'; break;
switch(keyman.config.hostDevice.OS) { // note: KeymanWeb internal API
case 'ios': href = 'https://keyman.com/go/developer/'+versionMajor+'/ios-app'; break;
case 'android': href = 'https://keyman.com/go/developer/'+versionMajor+'/android-app'; break;
case 'linux': href = 'https://keyman.com/linux/download'; break;
case 'windows': href = 'https://keyman.com/go/download/keyman-windows'; break;
case 'macosx': href = 'https://keyman.com/go/download/keyman-mac'; break;
default: href = 'https://keyman.com/downloads'; break;
}
location.href = href;
Expand Down
14 changes: 7 additions & 7 deletions developer/src/server/src/site/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,14 @@ window.onload = function() {

if(newOSK) {
document.getElementById('osk-host').removeChild(newOSK.element);
keyman.osk = null;
keyman.osk = null; // Note: undocumented KeymanWeb API
}

// Create a new on screen keyboard view and tell KeymanWeb that
// we are using the targetDevice for context input.
newOSK = new keyman.views.InlinedOSKView(keyman, { device: targetDevice });
keyman.core.contextDevice = targetDevice;
keyman.osk = newOSK;
newOSK = new keyman.views.InlinedOSKView(keyman, { device: targetDevice }); // Note: KeymanWeb internal API
keyman.core.contextDevice = targetDevice; // Note: KeymanWeb internal API
keyman.osk = newOSK; // Note: undocumented KeymanWeb API

if(document.body.offsetWidth < targetDevice.dimensions[0]) {
newOSK.setSize('320px', '200px');
Expand All @@ -237,8 +237,8 @@ window.onload = function() {

keyman.addEventListener('keyboardchange', function(keyboardProperties) {
if(newOSK) {
keyman.osk = newOSK;
newOSK.activeKeyboard = keyman.contextManager.activeKeyboard; // Private API refs on both sides
keyman.osk = newOSK; // Note: undocumented KeymanWeb API
newOSK.activeKeyboard = keyman.contextManager.activeKeyboard; // Note: undocumented KeymanWeb API refs on both sides
}
keyboardDropdown.set(keyboardProperties.internalName);
window.sessionStorage.setItem('current-keyboard', keyboardProperties.internalName);
Expand Down Expand Up @@ -284,7 +284,7 @@ function unloadKeyboardsAndModels() {
const lastModel = keyman.core.activeModel;
if(lastModel) {
console.log('Unregistering model '+lastModel.id);
keyman.removeModel(lastModel.id);
keyman.removeModel(lastModel.id); // Note: undocumented KeymanWeb API
}

modelDropdown.removeAll();
Expand Down
6 changes: 3 additions & 3 deletions developer/src/tike/xml/layoutbuilder/builder.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
</div>

<div class='toolbar-item' id='key-cap-unicode-toolbar-item'>
<label for='inpKeyCapUnicode'>Unicode:</label>
<label for='inpKeyCapUnicode'>Text Unicode:</label>
<input id='inpKeyCapUnicode' type='text' size='16' />
</div>

Expand All @@ -118,7 +118,7 @@
</div>

<div class='toolbar-item' id='key-hint-unicode-toolbar-item'>
<label for='inpKeyHintUnicode'>Unicode:</label>
<label for='inpKeyHintUnicode'>Hint Unicode:</label>
<input id='inpKeyHintUnicode' type='text' size='16' />
</div>

Expand Down Expand Up @@ -221,7 +221,7 @@
<input id='inpSubKeyCap' type='text' size='8' />
</div>
<div class='toolbar-item' id='sub-key-cap-unicode-toolbar-item'>
<label>Unicode:</label>
<label>Text Unicode:</label>
<input id='inpSubKeyCapUnicode' type='text' size='16' />
</div>
<div class='toolbar-item'>
Expand Down
Loading