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 ldml-editor 🗼 #12779

Merged
merged 30 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c27ac9e
chore(common): rename test files
ermshiperete Nov 26, 2024
44f2047
feat(android): Enhance how ENTER key is handled for FV and KMSample2
darcywong00 Nov 29, 2024
8e19508
feat(common): isDenormalized() function for checking strings that are…
srl295 Nov 29, 2024
add502e
feat(common,developer): tests and warning on denormalized content
srl295 Nov 29, 2024
f4b7e0a
Apply suggestions from code review
srl295 Nov 30, 2024
f3191b9
feat(developer): report on mismatching lang tag scripts when building…
mcdurdin Dec 2, 2024
42ba0a4
refactor(mac): pass kmx data blob to keyman core instead of file path
sgschantz Dec 2, 2024
6f2a6b2
feat(common,developer): tests and warning on denormalized content per…
srl295 Dec 2, 2024
17185d7
Merge branch 'master' into feat/developer/7394-verify-normalization-e…
srl295 Dec 2, 2024
a169da7
auto: increment master version to 18.0.151
keyman-server Dec 2, 2024
8dc62e7
Merge pull request #12755 from keymanapp/auto/version-master-18.0.151
keyman-server Dec 2, 2024
8bc144b
refactor(mac): raise exception when unable to read kmx data
sgschantz Dec 3, 2024
7794d2d
Merge pull request #12745 from keymanapp/feat/fv/enter-key
darcywong00 Dec 3, 2024
c233208
Merge pull request #12753 from keymanapp/feat/developer/12752-hint-on…
mcdurdin Dec 3, 2024
cbbb643
chore(common): rename `common/web/types/test` to `.../tests`
ermshiperete Dec 3, 2024
f1f0260
auto: increment master version to 18.0.152
keyman-server Dec 3, 2024
00815e3
Merge pull request #12763 from keymanapp/auto/version-master-18.0.152
keyman-server Dec 3, 2024
4ddcfc9
Merge pull request #12760 from keymanapp/refactor/mac/12499-load-keyb…
sgschantz Dec 4, 2024
148938e
fix(developer): honour provided script when checking for matching scr…
mcdurdin Dec 4, 2024
0eea6b4
Merge pull request #12768 from keymanapp/fix/developer/12765-improve-…
mcdurdin Dec 4, 2024
9a6e336
Merge pull request #12709 from keymanapp/chore/common/rename-tests
ermshiperete Dec 4, 2024
ed22cc0
fix(common): rename test file
ermshiperete Dec 4, 2024
82d7255
Merge pull request #12770 from keymanapp/fix/common/tests
ermshiperete Dec 4, 2024
917cae3
auto: increment master version to 18.0.153
keyman-server Dec 4, 2024
1c62c47
Merge pull request #12771 from keymanapp/auto/version-master-18.0.153
keyman-server Dec 4, 2024
c380774
Merge remote-tracking branch 'upstream/master' into feat/developer/73…
srl295 Dec 4, 2024
41f47b8
Merge pull request #12748 from keymanapp/feat/developer/7394-verify-n…
srl295 Dec 4, 2024
b7990d1
chore(core): Add link to Keyman Glossary
SabineSIL Dec 5, 2024
1fd2a1b
Merge pull request #12774 from keymanapp/chore/core/link/glossary
SabineSIL Dec 5, 2024
cbce5a4
Merge branch 'epic/ldml-editor' into chore/merge-master-into-ldml-editor
mcdurdin Dec 5, 2024
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
16 changes: 16 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Keyman Version History

## 18.0.152 alpha 2024-12-04

* refactor(mac): pass kmx data blob to keyman core instead of file path (#12760)
* fix(developer): honour provided script when checking for matching scripts (#12768)
* chore(common): rename test files (#12709)
* fix(common): rename test file (#12770)

## 18.0.151 alpha 2024-12-03

* feat(android): Enhance how ENTER key is handled for FV and KMSample2 (#12745)
* feat(developer): report on mismatching lang tag scripts when building keyboard-info (#12753)

## 18.0.150 alpha 2024-12-02

* fix(core,developer): use `NDEBUG` flag to disable assertions in release build (#12715)

## 18.0.149 alpha 2024-12-01

* refactor(developer): unify test action (#12736)
Expand Down
2 changes: 1 addition & 1 deletion VERSION.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.0.150
18.0.153
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ public void onStartInput(EditorInfo attribute, boolean restarting) {
super.onStartInput(attribute, restarting);
KMManager.onStartInput(attribute, restarting);
KMManager.resetContext(KeyboardType.KEYBOARD_TYPE_SYSTEM);

// Determine special handling for ENTER key
int inputType = attribute.inputType;
KMManager.setEnterMode(attribute.imeOptions, inputType);

// User switched to a new input field so we should extract the text from input field
// and pass it to Keyman Engine together with selection range
InputConnection ic = getCurrentInputConnection();
Expand Down
4 changes: 2 additions & 2 deletions common/web/types/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module.exports = {
parserOptions: {
project: ["./tsconfig.json", "./test/tsconfig.json"],
project: ["./tsconfig.json", "./tests/tsconfig.json"],
},
ignorePatterns: [
".*/*",
"build/*",
"coverage/*",
"node_modules/*",
"test/fixtures/*",
"tests/fixtures/*",
"tools/*",
"src/schemas/*"
],
Expand Down
2 changes: 1 addition & 1 deletion common/web/types/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function do_test() {
fi

eslint .
tsc --build test
tsc --build tests

readonly C8_THRESHOLD=60

Expand Down
6 changes: 3 additions & 3 deletions common/web/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"build": "tsc -b",
"build:schema": "ajv compile",
"lint": "eslint .",
"test": "npm run lint && cd test && tsc -b && cd .. && c8 --skip-full --reporter=lcov --reporter=text mocha"
"test": "npm run lint && cd tests && tsc -b && cd .. && c8 --skip-full --reporter=lcov --reporter=text mocha"
},
"author": "Marc Durdin <[email protected]> (https://github.com/mcdurdin)",
"license": "MIT",
Expand All @@ -48,7 +48,7 @@
"typescript": "^5.4.5"
},
"mocha": {
"spec": "build/test/**/test-*.js",
"spec": "build/tests/**/*.tests.js",
"require": [
"source-map-support/register"
]
Expand Down Expand Up @@ -76,7 +76,7 @@
"src/keyman-touch-layout/keyman-touch-layout-file-writer.ts",
"src/osk/osk.ts",
"src/schemas/*",
"test/"
"tests/"
]
},
"sideEffects": false
Expand Down
17 changes: 9 additions & 8 deletions common/web/types/src/kmx/kmx-plus/kmx-plus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,7 @@ export class Strs extends Section {
*/
allocString(s?: string, opts?: StrsOptions, sections?: DependencySections): StrsItem {
// Run the string processing pipeline
s = Strs.processString(s, opts, sections);

// add to the set, for testing
if (s) {
this.allProcessedStrings.add(s);
}
s = this.processString(s, opts, sections);

// if it's a single char, don't push it into the strs table
if (opts?.singleOk && isOneChar(s)) {
Expand All @@ -196,8 +191,8 @@ export class Strs extends Section {
return result;
}

/** process everything according to opts */
static processString(s: string, opts: StrsOptions, sections: DependencySections) {
/** process everything according to opts, and add the string to this.allProcessedStrings */
private processString(s: string, opts: StrsOptions, sections: DependencySections) {
s = s ?? '';
// type check everything else
if (typeof s !== 'string') {
Expand All @@ -215,6 +210,12 @@ export class Strs extends Section {
if (opts?.unescape) {
s = unescapeString(s);
}

if (s) {
// add all processed strings here, so that we catch denormalized strings in the input
this.allProcessedStrings.add(s);
}

// nfd
if (opts?.nfd) {
if (!sections?.meta?.normalizationDisabled) {
Expand Down
9 changes: 9 additions & 0 deletions common/web/types/src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,15 @@ export function isPUA(ch: number) {
(ch >= Uni_PUA_16_START && ch <= Uni_PUA_16_END));
}

/** @returns false if s is NEITHER NFC nor NFD. (Returns true for falsy) */
export function isNormalized(s: string) : boolean {
if(!s) return true; // empty or null
const nfc = s.normalize("NFC");
const nfd = s.normalize("NFD");
if (s !== nfc && s !== nfd) return false;
return true;
}

class BadStringMap extends Map<BadStringType, Set<number>> {
public toString() : string {
if (!this.size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ import { fileURLToPath } from "url";
* @param components One or more path components.
*/
export function makePathToFixture(...components: string[]): string {
return fileURLToPath(new URL(path.join('..', '..', '..', 'test', 'fixtures', ...components), import.meta.url));
return fileURLToPath(new URL(path.join('..', '..', '..', 'tests', 'fixtures', ...components), import.meta.url));
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as fs from 'fs';
import 'mocha';
import { makePathToFixture } from '../helpers/index.js';
import KvkFileReader from "../../src/kvk/kvk-file-reader.js";
import { verify_balochi_inpage, verify_khmer_angkor } from './test-kvk-utils.js';
import { verify_balochi_inpage, verify_khmer_angkor } from './kvk-utils.tests.js';

describe('kvk-file-reader', function () {
it('kvk-file-reader should read a valid file', function() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Keyman is copyright (C) SIL Global. MIT License.
*
*
* Created by Dr Mark C. Sinclair on 2024-11-29
*
*
* Test code for unicodeset-parser-api.ts
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
"compilerOptions": {
"rootDir": ".",
"rootDirs": ["./", "../src/"],
"outDir": "../build/test",
"outDir": "../build/tests",
"baseUrl": ".",
"strictNullChecks": false, // TODO: get rid of this as some point
"allowSyntheticDefaultImports": true
},
"include": [
"**/test-*.ts",
"**/*.tests.ts",
"./helpers/*.ts",
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'mocha';
import {assert} from 'chai';
import {unescapeString, UnescapeError, isOneChar, toOneChar, unescapeOneQuadString, BadStringAnalyzer, isValidUnicode, describeCodepoint, isPUA, BadStringType, unescapeStringToRegex, unescapeQuadString, NFDAnalyzer} from '../../src/util/util.js';
import {unescapeString, UnescapeError, isOneChar, toOneChar, unescapeOneQuadString, BadStringAnalyzer, isValidUnicode, describeCodepoint, isPUA, BadStringType, unescapeStringToRegex, unescapeQuadString, NFDAnalyzer, isNormalized} from '../../src/util/util.js';

describe('test UTF32 functions()', function() {
it('should properly categorize strings', () => {
Expand Down Expand Up @@ -186,6 +186,24 @@ describe('test bad char functions', () => {
assert.isTrue(isPUA(ch), describeCodepoint(ch));
}
});
describe('test isDenormalized()', () => {
it('should correctly categorize strings', () => {
[
undefined,
null,
'',
'ABC',
'fa\u1E69cinating', // NFC
'fas\u0323\u0307cinating', // NFD
'd\u0323\u0307', // NFD
'\u1e0d\u0307', // NFC
].map(s => assert.isTrue(isNormalized(s), `for string ${s}`));
[
'd\u0307\u0323', // NFD but reversed marks
'fas\u0307\u0323cinating', // not-NFD
].map(s => assert.isFalse(isNormalized(s), `for string ${s}`));
});
});
});

describe('test BadStringAnalyzer', () => {
Expand Down
1 change: 1 addition & 0 deletions core/docs/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ modifiers such as Windows key are excluded from this set. Some modifiers are
transient, such as Control, and others have long-lasting state, such as
Caps Lock.

- __See more in__ [Keyman Glossary](https://github.com/keymanapp/keyman/wiki/Keyman-glossary)

[km_core_cp]: background#km_core_cp "km_core_cp type"
[km_core_usv]: background#km_core_usv "km_core_usv type"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { CompilerErrorNamespace, CompilerErrorSeverity, CompilerMessageSpec as m

const Namespace = CompilerErrorNamespace.KeyboardInfoCompiler;
// const SevInfo = CompilerErrorSeverity.Info | Namespace;
// const SevHint = CompilerErrorSeverity.Hint | Namespace;
const SevHint = CompilerErrorSeverity.Hint | Namespace;
// const SevWarn = CompilerErrorSeverity.Warn | Namespace;
const SevError = CompilerErrorSeverity.Error | Namespace;
const SevFatal = CompilerErrorSeverity.Fatal | Namespace;
Expand Down Expand Up @@ -61,5 +61,10 @@ export class KeyboardInfoCompilerMessages {
static Error_DescriptionIsMissing = (o:{filename:string}) => m(
this.ERROR_DescriptionIsMissing,
`The Info.Description field in the package ${def(o.filename)} is required, but is missing or empty.`);

static HINT_ScriptDoesNotMatch = SevHint | 0x0011;
static Hint_ScriptDoesNotMatch = (o:{script: string, bcp47:string, commonScript: string}) => m(
this.HINT_ScriptDoesNotMatch,
`The script '${def(o.script)}' associated with language tag '${def(o.bcp47)}' does not match the script '${def(o.commonScript)}' for the first language in the package.`);
}

11 changes: 11 additions & 0 deletions developer/src/kmc-keyboard-info/src/keyboard-info-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,8 @@ export class KeyboardInfoCompiler implements KeymanCompiler {
const fontSource = [].concat(...kmpJsonData.keyboards.map(e => e.displayFont ? [e.displayFont] : []), ...kmpJsonData.keyboards.map(e => e.webDisplayFonts ?? []));
const oskFontSource = [].concat(...kmpJsonData.keyboards.map(e => e.oskFont ? [e.oskFont] : []), ...kmpJsonData.keyboards.map(e => e.webOskFonts ?? []));

let commonScript = null;

for(const bcp47 of Object.keys(keyboard_info.languages)) {
const language = keyboard_info.languages[bcp47];

Expand Down Expand Up @@ -572,6 +574,15 @@ export class KeyboardInfoCompiler implements KeymanCompiler {
` (${language.regionName})` :
''
);

const resolvedScript = locale.script ?? langtagsByTag[bcp47]?.script ?? langtagsByTag[locale.language]?.script ?? undefined;
if(commonScript === null) {
commonScript = resolvedScript;
} else {
if(resolvedScript !== commonScript) {
this.callbacks.reportMessage(KeyboardInfoCompilerMessages.Hint_ScriptDoesNotMatch({commonScript, bcp47, script: resolvedScript}))
}
}
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015-2022 SIL International

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
khmer_angkor.js -text
Loading
Loading