Skip to content

Commit 0913770

Browse files
authored
Merge pull request #9471 from keymanapp/chore/developer/keyboard-info-font-examples-cleanup
chore(developer): cleanup keyboard_info schema 🎺
2 parents 722f72b + 395b76d commit 0913770

File tree

5 files changed

+18
-51
lines changed

5 files changed

+18
-51
lines changed

common/schemas/keyboard_info/keyboard_info.schema.json

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"properties": {
5353
"font": { "$ref": "#/definitions/KeyboardFontInfo" },
5454
"oskFont": { "$ref": "#/definitions/KeyboardFontInfo" },
55-
"example": { "$ref": "#/definitions/KeyboardExampleInfo" },
55+
"examples": { "type": "array", "items": { "$ref": "#/definitions/KeyboardExampleInfo" } },
5656
"displayName": { "type": "string" },
5757
"languageName": { "type": "string" },
5858
"scriptName": { "type": "string" },
@@ -66,11 +66,7 @@
6666
"type": "object",
6767
"properties": {
6868
"family": { "type": "string" },
69-
"source": { "anyOf": [
70-
{ "type": "string" },
71-
{ "type": "array", "items": { "type": "string" } }
72-
] },
73-
"size": { "type": "string" }
69+
"source": { "type": "array", "items": { "type": "string" } }
7470
},
7571
"required": ["family", "source"],
7672
"additionalProperties": false
@@ -79,55 +75,24 @@
7975
"KeyboardExampleInfo": {
8076
"type": "object",
8177
"properties": {
82-
"keys": { "anyOf": [
83-
{ "type": "string" },
84-
{ "type": "array", "items": {
85-
"anyOf": [
86-
{ "type": "string" },
87-
{ "$ref": "#/definitions/KeyboardExampleKeyInfo" }
88-
] }
89-
}
90-
] },
78+
"keys": {
79+
"type": "array",
80+
"items": { "$ref": "#/definitions/KeyboardExampleKeyInfo" }
81+
},
9182
"text": { "type": "string" },
9283
"note": { "type": "string" }
9384
},
94-
"required": [],
85+
"required": ["keys", "text"],
9586
"additionalProperties": false
9687
},
9788

9889
"KeyboardExampleKeyInfo": {
9990
"type": "object",
10091
"properties": {
101-
"key": { "type": "string", "enum": [
102-
"K_SPACE",
103-
"K_A", "K_B", "K_C", "K_D", "K_E", "K_F", "K_G", "K_H", "K_I", "K_J", "K_K", "K_L", "K_M",
104-
"K_N", "K_O", "K_P", "K_Q", "K_R", "K_S", "K_T", "K_U", "K_V", "K_W", "K_X", "K_Y", "K_Z",
105-
"K_1", "K_2", "K_3", "K_4", "K_5", "K_6", "K_7", "K_8", "K_9", "K_0",
106-
"K_BKQUOTE", "K_HYPHEN", "K_EQUAL", "K_LBRKT", "K_RBRKT", "K_BKSLASH", "K_COLON",
107-
"K_QUOTE", "K_COMMA", "K_PERIOD", "K_SLASH",
108-
"K_oE2", "K_BKSP", "K_TAB", "K_ENTER", "K_ESC",
109-
"K_LEFT", "K_UP", "K_RIGHT", "K_DOWN", "K_PGUP", "K_PGDN", "K_HOME", "K_END", "K_INS", "K_DEL",
110-
"K_F1", "K_F2", "K_F3", "K_F4", "K_F5", "K_F6", "K_F7", "K_F8", "K_F9", "K_F10", "K_F11", "K_F12",
111-
"K_KP5", "K_NP0", "K_NP1", "K_NP2", "K_NP3", "K_NP4", "K_NP5", "K_NP6", "K_NP7", "K_NP8", "K_NP9",
112-
"K_NPSTAR", "K_NPPLUS", "K_NPMINUS", "K_NPDOT", "K_NPSLASH",
113-
"K_SEL", "K_PRINT", "K_EXEC", "K_HELP", "K_SEPARATOR",
114-
"K_F13", "K_F14", "K_F15", "K_F16", "K_F17", "K_F18", "K_F19", "K_F20", "K_F21", "K_F22", "K_F23", "K_F24",
115-
"K_KANJI?15", "K_KANJI?16", "K_KANJI?17", "K_KANJI?18", "K_KANJI?19", "K_KANJI?1C", "K_KANJI?1D", "K_KANJI?1E", "K_KANJI?1F",
116-
"K_oE0", "K_oE1", "K_oE3", "K_oE4", "K_oE6", "K_oE9", "K_oEA", "K_oEB", "K_oEC", "K_oED", "K_oEE", "K_oEF",
117-
"K_oF0", "K_oF1", "K_oF2", "K_oF3", "K_oF4", "K_oF5", "K_?00", "K_?05", "K_NPENTER",
118-
"K_?06", "K_?07", "K_?0A", "K_?0B", "K_?0E", "K_?0F", "K_?1A", "K_?3A", "K_?3B", "K_?3C", "K_?3D", "K_?3E",
119-
"K_?3F", "K_?40", "K_?5B", "K_?5C", "K_?5D", "K_?5E", "K_?5F", "K_?88", "K_?89", "K_?8A", "K_?8B", "K_?8C",
120-
"K_?8D", "K_?8E", "K_?8F", "K_?92", "K_?94", "K_?95", "K_?96", "K_?97", "K_?98", "K_?99", "K_?9A", "K_?9B",
121-
"K_?9C", "K_?9D", "K_?9E", "K_?9F", "K_?A0", "K_?A1", "K_?A2", "K_?A3", "K_?A4", "K_?A5", "K_?A6", "K_?A7",
122-
"K_?A8", "K_?A9", "K_?AA", "K_?AB", "K_?AC", "K_?AD", "K_?AE", "K_?AF", "K_?B0", "K_?B1", "K_?B2", "K_?B3",
123-
"K_?B4", "K_?B5", "K_?B6", "K_?B7", "K_?B8", "K_?B9", "K_?C1", "K_?C2", "K_?C3", "K_?C4", "K_?C5", "K_?C6",
124-
"K_?C7", "K_?C8", "K_?C9", "K_?CA", "K_?CB", "K_?CC", "K_?CD", "K_?CE", "K_?CF", "K_?D0", "K_?D1", "K_?D2",
125-
"K_?D3", "K_?D4", "K_?D5", "K_?D6", "K_?D7", "K_?D8", "K_?D9", "K_?DA", "K_oDF", "K_?E5", "K_?E7", "K_?E8",
126-
"K_?F6", "K_?F7", "K_?F8", "K_?F9", "K_?FA", "K_?FB", "K_?FC", "K_?FD", "K_?FE", "K_?FF"
127-
] },
92+
"key": { "type": "string" },
12893
"modifiers": {
12994
"type": "array",
130-
"items": { "type": "string", "enum": ["shift", "s", "ctrl", "c", "alt", "a", "left-ctrl", "lc", "right-ctrl", "rc", "left-alt", "la", "right-alt", "ra"] }
95+
"items": { "type": "string" }
13196
}
13297
},
13398
"required": ["key"],

common/web/types/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function compile_schemas() {
3737
"$KEYMAN_ROOT/common/schemas/displaymap/displaymap.schema.json"
3838
"$KEYMAN_ROOT/common/schemas/keyman-touch-layout/keyman-touch-layout.spec.json"
3939
"$KEYMAN_ROOT/common/schemas/keyman-touch-layout/keyman-touch-layout.clean.spec.json"
40+
"$KEYMAN_ROOT/common/schemas/keyboard_info/keyboard_info.schema.json"
4041
)
4142

4243
rm -rf "$THIS_SCRIPT_PATH/src/schemas"

common/web/types/src/schemas.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import ldmlKeyboardTest from './schemas/ldml-keyboardtest.schema.js';
77
import displayMap from './schemas/displaymap.schema.js';
88
import touchLayoutClean from './schemas/keyman-touch-layout.clean.spec.js';
99
import touchLayout from './schemas/keyman-touch-layout.spec.js';
10+
import keyboard_info from './schemas/keyboard_info.schema.js';
1011

1112
const Schemas = {
1213
kpj,
@@ -17,6 +18,7 @@ const Schemas = {
1718
displayMap,
1819
touchLayoutClean,
1920
touchLayout,
21+
keyboard_info,
2022
};
2123

2224
export default Schemas;

developer/src/kmc-keyboard-info/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ export class KeyboardInfoCompiler {
104104
return null;
105105
}
106106
keyboard_info = {
107-
// Only two fields that won't be automatically filled if file is not
108-
// present
109-
encodings: ['unicode'],
110-
license: 'mit'
111107
};
112108
}
113109

@@ -131,6 +127,10 @@ export class KeyboardInfoCompiler {
131127
// https://help.keyman.com/developer/cloud/keyboard_info/2.0
132128
//
133129

130+
// TODO: read LicenseFilename from .kps and verify (OR ADD TO KPS?)
131+
// TODO: use mit license validation from feat/developer/compile-without-source-keyboard-info
132+
keyboard_info.license = 'mit';
133+
134134
keyboard_info.isRTL = keyboard_info.isRTL ?? !!jsFile?.match(/this\.KRTL=1/);
135135
if(!keyboard_info.isRTL) {
136136
delete keyboard_info.isRTL;

developer/src/kmc-keyboard-info/src/keyboard-info-file.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export interface KeyboardInfoFile {
1717
jsFilename?: string;
1818
jsFileSize?: number;
1919
isRTL?: boolean;
20-
encodings: KeyboardInfoFileEncodings[];
20+
encodings?: KeyboardInfoFileEncodings[];
2121
packageIncludes?: KeyboardInfoFileIncludes[];
2222
version?: string;
2323
minKeymanVersion?: string;
@@ -45,8 +45,7 @@ export interface KeyboardInfoFileLanguage {
4545

4646
export interface KeyboardInfoFileLanguageFont {
4747
family?: string;
48-
source?: string | string[];
49-
size?: string;
48+
source?: string[];
5049
}
5150

5251
export interface KeyboardInfoFileExample {

0 commit comments

Comments
 (0)