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(resources): ldml: update to keyboard3 🙀 #9588

Merged
merged 7 commits into from
Sep 21, 2023
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
4 changes: 2 additions & 2 deletions common/web/types/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ builder_parse "$@"
function compile_schemas() {
# We need the schema files at runtime and bundled, so always copy it for all actions except `clean`
local schemas=(
"$KEYMAN_ROOT/resources/standards-data/ldml-keyboards/techpreview/ldml-keyboard.schema.json"
"$KEYMAN_ROOT/resources/standards-data/ldml-keyboards/techpreview/ldml-keyboardtest.schema.json"
"$KEYMAN_ROOT/resources/standards-data/ldml-keyboards/techpreview/ldml-keyboard3.schema.json"
"$KEYMAN_ROOT/resources/standards-data/ldml-keyboards/techpreview/ldml-keyboardtest3.schema.json"
"$KEYMAN_ROOT/common/schemas/kvks/kvks.schema.json"
"$KEYMAN_ROOT/common/schemas/kpj/kpj.schema.json"
"$KEYMAN_ROOT/common/schemas/kpj-9.0/kpj-9.0.schema.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface LDMLKeyboardTestDataXMLSourceFile {
/**
* <keyboardTest> -- the root element.
*/
keyboardTest: LKTKeyboardTest;
keyboardTest3: LKTKeyboardTest;
}

export interface LKTKeyboardTest {
Expand Down
60 changes: 30 additions & 30 deletions common/web/types/src/ldml-keyboard/ldml-keyboard-xml-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,27 @@ export class LDMLKeyboardXMLSourceFileReader {
* @returns true on success, false on failure
*/
private boxArrays(source: any) : boolean {
if (source?.keyboard) {
if (!source.keyboard.keys) {
source.keyboard.keys = {
if (source?.keyboard3) {
if (!source.keyboard3.keys) {
source.keyboard3.keys = {
key: [],
flicks: [],
};
}
if (!source.keyboard.keys.import) {
source.keyboard.keys.import = [];
if (!source.keyboard3.keys.import) {
source.keyboard3.keys.import = [];
}
}
boxXmlArray(source?.keyboard, 'layers');
boxXmlArray(source?.keyboard?.displays, 'display');
boxXmlArray(source?.keyboard?.names, 'name');
boxXmlArray(source?.keyboard?.vkeys, 'vkey');
boxXmlArray(source?.keyboard?.keys, 'key');
boxXmlArray(source?.keyboard?.keys, 'flicks');
boxXmlArray(source?.keyboard?.locales, 'locale');
boxXmlArray(source?.keyboard, 'transforms');
if(source?.keyboard?.layers) {
for(let layers of source?.keyboard?.layers) {
boxXmlArray(source?.keyboard3, 'layers');
boxXmlArray(source?.keyboard3?.displays, 'display');
boxXmlArray(source?.keyboard3?.names, 'name');
boxXmlArray(source?.keyboard3?.vkeys, 'vkey');
boxXmlArray(source?.keyboard3?.keys, 'key');
boxXmlArray(source?.keyboard3?.keys, 'flicks');
boxXmlArray(source?.keyboard3?.locales, 'locale');
boxXmlArray(source?.keyboard3, 'transforms');
if(source?.keyboard3?.layers) {
for(let layers of source?.keyboard3?.layers) {
boxXmlArray(layers, 'layer');
if(layers?.layer) {
for(let layer of layers?.layer) {
Expand All @@ -68,18 +68,18 @@ export class LDMLKeyboardXMLSourceFileReader {
}
}
}
if(source?.keyboard?.keys?.flicks) {
for(let flicks of source?.keyboard?.keys?.flicks) {
if(source?.keyboard3?.keys?.flicks) {
for(let flicks of source?.keyboard3?.keys?.flicks) {
boxXmlArray(flicks, 'flick');
}
}
if(source?.keyboard?.variables) {
boxXmlArray(source?.keyboard?.variables, 'set');
boxXmlArray(source?.keyboard?.variables, 'string');
boxXmlArray(source?.keyboard?.variables, 'unicodeSet');
if(source?.keyboard3?.variables) {
boxXmlArray(source?.keyboard3?.variables, 'set');
boxXmlArray(source?.keyboard3?.variables, 'string');
boxXmlArray(source?.keyboard3?.variables, 'unicodeSet');
}
if(source?.keyboard?.transforms) {
for(let transforms of source.keyboard.transforms) {
if(source?.keyboard3?.transforms) {
for(let transforms of source.keyboard3.transforms) {
boxXmlArray(transforms, 'transformGroup');
for (let transformGroup of transforms.transformGroup) {
boxXmlArray(transformGroup, 'transform');
Expand Down Expand Up @@ -208,7 +208,7 @@ export class LDMLKeyboardXMLSourceFileReader {
*/
public validate(source: LDMLKeyboardXMLSourceFile | LDMLKeyboardTestDataXMLSourceFile): boolean {
const ajv = new Ajv();
if(!ajv.validate(Schemas.ldmlKeyboard, source)) {
if(!ajv.validate(Schemas.ldmlKeyboard3, source)) {
for (let err of ajv.errors) {
this.callbacks.reportMessage(CommonTypesMessages.Error_SchemaValidationError({
instancePath: err.instancePath,
Expand Down Expand Up @@ -345,16 +345,16 @@ export class LDMLKeyboardXMLSourceFileReader {
boxTestDataArrays(raw: any) : LDMLKeyboardTestDataXMLSourceFile | null {
if (!raw) return null;
const a : LDMLKeyboardTestDataXMLSourceFile = {
keyboardTest: {
conformsTo: raw?.keyboardTest?.$?.conformsTo,
keyboardTest3: {
conformsTo: raw?.keyboardTest3?.$?.conformsTo,
}
};

const $$ : NameAndProps[] = raw?.keyboardTest?.$$;
const $$ : NameAndProps[] = raw?.keyboardTest3?.$$;

this.stuffBoxes(a.keyboardTest, $$, 'info');
this.stuffBoxes(a.keyboardTest, $$, 'repertoire', true);
this.stuffBoxes(a.keyboardTest, $$, 'tests', true, (o, r) => {
this.stuffBoxes(a.keyboardTest3, $$, 'info');
this.stuffBoxes(a.keyboardTest3, $$, 'repertoire', true);
this.stuffBoxes(a.keyboardTest3, $$, 'tests', true, (o, r) => {
// start with basic unpack
const tests : LKTTests = LDMLKeyboardXMLSourceFileReader.defaultMapper(o, r);
// add ingredients
Expand Down
2 changes: 1 addition & 1 deletion common/web/types/src/ldml-keyboard/ldml-keyboard-xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface LDMLKeyboardXMLSourceFile {
/**
* <keyboard> -- the root element.
*/
keyboard: LKKeyboard;
keyboard3: LKKeyboard;
}

export interface LKKeyboard {
Expand Down
10 changes: 5 additions & 5 deletions common/web/types/src/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import kpj from './schemas/kpj.schema.js';
import kpj90 from './schemas/kpj-9.0.schema.js';
import kvks from './schemas/kvks.schema.js';
import ldmlKeyboard from './schemas/ldml-keyboard.schema.js';
import ldmlKeyboardTest from './schemas/ldml-keyboardtest.schema.js';
import ldmlKeyboard3 from './schemas/ldml-keyboard3.schema.js';
import ldmlKeyboardTest3 from './schemas/ldml-keyboardtest3.schema.js';
import displayMap from './schemas/displaymap.schema.js';
import touchLayoutClean from './schemas/keyman-touch-layout.clean.spec.js';
import touchLayout from './schemas/keyman-touch-layout.spec.js';
Expand All @@ -12,11 +12,11 @@ const Schemas = {
kpj,
kpj90,
kvks,
ldmlKeyboard,
ldmlKeyboardTest,
ldmlKeyboard3,
ldmlKeyboardTest3,
displayMap,
touchLayoutClean,
touchLayout,
};

export default Schemas;
export default Schemas;
6 changes: 3 additions & 3 deletions common/web/types/test/fixtures/import-minimal.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE keyboard SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard.dtd">
<keyboard locale="und" conformsTo="techpreview">
<!DOCTYPE keyboard3 SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard3.dtd">
<keyboard3 locale="und" conformsTo="techpreview">
<info author="srl295" indicator="🙀" layout="qwerty" normalization="NFC" />
<names>
<name value="Test Minimal Keyboard" />
</names>
</keyboard>
</keyboard3>
6 changes: 3 additions & 3 deletions common/web/types/test/fixtures/import-minimal1.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE keyboard SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard.dtd">
<keyboard locale="und" conformsTo="techpreview">
<!DOCTYPE keyboard3 SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard3.dtd">
<keyboard3 locale="und" conformsTo="techpreview">
<info author="srl295" indicator="🙀" layout="qwerty" normalization="NFC" />
<names>
<name value="Test Minimal Keyboard" />
</names>
<keys>

</keys>
</keyboard>
</keyboard3>
6 changes: 3 additions & 3 deletions common/web/types/test/fixtures/import-minimal2.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE keyboard SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard.dtd">
<keyboard locale="und" conformsTo="techpreview">
<!DOCTYPE keyboard3 SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard3.dtd">
<keyboard3 locale="und" conformsTo="techpreview">
<info author="srl295" indicator="🙀" layout="qwerty" normalization="NFC" />
<names>
<name value="Test Minimal Keyboard" />
</names>
<keys>
<key id="a" to="å"/> <!-- override -->
</keys>
</keyboard>
</keyboard3>
6 changes: 3 additions & 3 deletions common/web/types/test/fixtures/import-symbols.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE keyboard SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard.dtd">
<keyboard locale="und" conformsTo="techpreview">
<!DOCTYPE keyboard3 SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard3.dtd">
<keyboard3 locale="und" conformsTo="techpreview">
<info author="srl295" indicator="🙀" layout="qwerty" normalization="NFC" />
<names>
<name value="Test Minimal Keyboard" />
Expand All @@ -10,4 +10,4 @@
<key id="zz" to="zz"/>
<key id="hash" to="##"/> <!-- override -->
</keys>
</keyboard>
</keyboard3>
4 changes: 2 additions & 2 deletions common/web/types/test/fixtures/invalid-conforms-to.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
DOCTYPE keyboard SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard.dtd"
Disabling doctype for this invalid file, not used by compiler, and avoids complaints in IDEs etc.
-->
<keyboard locale="mt" conformsTo="nothing-anyone-ever-heard-of"> <!-- invalid -->
<keyboard3 locale="mt" conformsTo="nothing-anyone-ever-heard-of"> <!-- invalid -->
<info author="srl295" indicator="🙀" layout="qwerty" normalization="NFC" />

<names>
Expand All @@ -16,4 +16,4 @@
<key id="that" to="ថា" />
</keys>

</keyboard>
</keyboard3>
6 changes: 3 additions & 3 deletions common/web/types/test/fixtures/invalid-import-base.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE keyboard SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard.dtd">
<keyboard locale="mt" conformsTo="techpreview">
<!DOCTYPE keyboard3 SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard3.dtd">
<keyboard3 locale="mt" conformsTo="techpreview">
<info author="srl295" indicator="🙀" layout="qwerty" normalization="NFC" />

<names>
Expand All @@ -13,4 +13,4 @@
<key id="that" to="ថា" />
</keys>

</keyboard>
</keyboard3>
6 changes: 3 additions & 3 deletions common/web/types/test/fixtures/invalid-import-path.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE keyboard SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard.dtd">
<keyboard locale="mt" conformsTo="techpreview">
<!DOCTYPE keyboard3 SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard3.dtd">
<keyboard3 locale="mt" conformsTo="techpreview">
<info author="srl295" indicator="🙀" layout="qwerty" normalization="NFC" />

<names>
Expand All @@ -13,4 +13,4 @@
<key id="that" to="ថា" />
</keys>

</keyboard>
</keyboard3>
6 changes: 3 additions & 3 deletions common/web/types/test/fixtures/invalid-import-readfail.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE keyboard SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard.dtd">
<keyboard locale="mt" conformsTo="techpreview">
<!DOCTYPE keyboard3 SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard3.dtd">
<keyboard3 locale="mt" conformsTo="techpreview">
<info author="srl295" indicator="🙀" layout="qwerty" normalization="NFC" />

<names>
Expand All @@ -13,4 +13,4 @@
<key id="that" to="ថា" />
</keys>

</keyboard>
</keyboard3>
6 changes: 3 additions & 3 deletions common/web/types/test/fixtures/invalid-import-wrongroot.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE keyboard SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard.dtd">
<keyboard locale="mt" conformsTo="techpreview">
<!DOCTYPE keyboard3 SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard3.dtd">
<keyboard3 locale="mt" conformsTo="techpreview">
<info author="srl295" indicator="🙀" layout="qwerty" normalization="NFC" />

<names>
Expand All @@ -13,4 +13,4 @@
<key id="that" to="ថា" />
</keys>

</keyboard>
</keyboard3>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
DOCTYPE keyboard SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard.dtd"
DOCTYPE keyboard SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboard3.dtd"
Disabling doctype for this invalid file, not used by compiler, and avoids complaints in IDEs etc.
-->
<keyboard locale="mt" conformsTo="techpreview">
</keyboard>
<keyboard3 locale="mt" conformsTo="techpreview">
</keyboard3>
6 changes: 3 additions & 3 deletions common/web/types/test/fixtures/test-fr.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE keyboardTest SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboardTest.dtd">
<keyboardTest conformsTo="techpreview">
<!DOCTYPE keyboardTest3 SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboardTest3.dtd">
<keyboardTest3 conformsTo="techpreview">
<info keyboard="fr-t-k0-azerty.xml" author="Team Keyboard" name="fr-test" />
<repertoire name="simple-repertoire" chars="[a b c d e \u{22}]" type="simple" /> <!-- verify that these outputs are all available from simple keys on any layer, for all form factors -->
<repertoire name="chars-repertoire" chars="[á é ó]" type="gesture" /> <!-- verify that these outputs are all available from simple or gesture keys on any layer, for touch -->
Expand All @@ -19,4 +19,4 @@
<check result="abc\u0022...stuv" />
</test>
</tests>
</keyboardTest>
</keyboardTest3>
2 changes: 1 addition & 1 deletion common/web/types/test/helpers/reader-callback-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export function testReaderCases(cases : CompilationCase[]) {
assert.includeDeepMembers(callbacks.messages, testcase.warnings, 'expected warnings to be included');
} else if (!expectFailure) {
// no warnings, so expect zero messages
assert.strictEqual(callbacks.messages.length, 0, 'expected zero messages');
assert.deepEqual(callbacks.messages, [], 'expected zero messages');
}

// run the user-supplied callback if any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ describe('ldml keyboard xml reader tests', function () {
subpath: 'test-fr.xml',
callback: (data, source) => {
assert.ok(source);
assert.ok(source.keyboardTest);
assert.equal(source.keyboardTest.conformsTo, constants.cldr_version_latest);
assert.ok(source.keyboardTest3);
assert.equal(source.keyboardTest3.conformsTo, constants.cldr_version_latest);

assert.deepEqual(source.keyboardTest.info, {
assert.deepEqual(source.keyboardTest3.info, {
keyboard: 'fr-t-k0-azerty.xml',
author: 'Team Keyboard',
name: 'fr-test'
});

assert.sameDeepMembers(source.keyboardTest.repertoire, [
assert.sameDeepMembers(source.keyboardTest3.repertoire, [
{
name: 'simple-repertoire',
chars: '[a b c d e \\u{22}]',
Expand All @@ -29,10 +29,10 @@ describe('ldml keyboard xml reader tests', function () {
{ name: 'chars-repertoire', chars: '[á é ó]', type: 'gesture' }
]);

assert.equal(1, source.keyboardTest.tests?.length);
assert.equal('key-tests', source.keyboardTest.tests[0].name);
assert.equal(1, source.keyboardTest.tests[0].test?.length);
const test0 = source.keyboardTest.tests[0].test[0];
assert.equal(1, source.keyboardTest3.tests?.length);
assert.equal('key-tests', source.keyboardTest3.tests[0].name);
assert.equal(1, source.keyboardTest3.tests[0].test?.length);
const test0 = source.keyboardTest3.tests[0].test[0];
assert.equal('key-test', test0.name);
assert.equal('abc\\u0022...', test0.startContext?.to);
assert.sameDeepOrderedMembers([
Expand Down
Loading