Skip to content

Commit

Permalink
chore(developer): kmc-package working
Browse files Browse the repository at this point in the history
Fixes: #12208
  • Loading branch information
srl295 committed Sep 1, 2024
1 parent a1f1bf7 commit 877522c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 43 deletions.
70 changes: 32 additions & 38 deletions developer/src/common/web/utils/src/types/kps/kps-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,11 @@ export interface KpsFileRelatedPackages {
}

export interface KpsFileRelatedPackage {
$: {
ID: string;
/**
* relationship between this package and the related package, "related" is default if not specified
*/
Relationship?: "deprecates";
}
ID: string;
/**
* relationship between this package and the related package, "related" is default if not specified
*/
Relationship?: "deprecates";
}

export interface KpsFileKeyboard {
Expand All @@ -133,9 +131,7 @@ export interface KpsFileFonts {
}

export interface KpsFileFont {
$: {
Filename: string;
}
Filename: string;
}

export interface KpsFileKeyboards {
Expand Down Expand Up @@ -179,32 +175,30 @@ export interface KpsFileLanguageExamples {
* An example key sequence intended to demonstrate how the keyboard works
*/
export interface KpsFileLanguageExample {
$: {
/**
* BCP 47 identifier for the example
*/
ID: string;
/**
* A space-separated list of keys.
* - modifiers indicated with "+"
* - spacebar is "space"
* - plus key is "shift+=" or "plus" on US English (all other punctuation as per key cap).
* - Hardware modifiers are: "shift", "ctrl", "alt", "left-ctrl",
* "right-ctrl", "left-alt", "right-alt"
* - Key caps should generally be their character for desktop (Latin script
* case insensitive), or the actual key cap for touch
* - Caps Lock should be indicated with "caps-on", "caps-off"
*
* e.g. "shift+a b right-alt+c space plus z z z" represents something like: "Ab{AltGr+C} +zzz"
*/
Keys: string;
/**
* The text that would be generated by typing those keys
*/
Text?: string;
/**
* A short description of what the text means or represents
*/
Note?: string;
}
/**
* BCP 47 identifier for the example
*/
ID: string;
/**
* A space-separated list of keys.
* - modifiers indicated with "+"
* - spacebar is "space"
* - plus key is "shift+=" or "plus" on US English (all other punctuation as per key cap).
* - Hardware modifiers are: "shift", "ctrl", "alt", "left-ctrl",
* "right-ctrl", "left-alt", "right-alt"
* - Key caps should generally be their character for desktop (Latin script
* case insensitive), or the actual key cap for touch
* - Caps Lock should be indicated with "caps-on", "caps-off"
*
* e.g. "shift+a b right-alt+c space plus z z z" represents something like: "Ab{AltGr+C} +zzz"
*/
Keys: string;
/**
* The text that would be generated by typing those keys
*/
Text?: string;
/**
* A short description of what the text means or represents
*/
Note?: string;
}
10 changes: 5 additions & 5 deletions developer/src/kmc-package/src/compiler/kmp-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export class KmpCompiler implements KeymanCompiler {
});

try {
const r = parser.parse(data);
const r = parser.parse(data, true);
delete r['?xml'];
a = r as KpsFile.KpsPackage;
} catch(e) {
Expand Down Expand Up @@ -267,7 +267,7 @@ export class KmpCompiler implements KeymanCompiler {
// Note: 'relationship' field is required for kmp.json but optional for .kps, only
// two values are supported -- deprecates or related.
kmp.relatedPackages = (this.arrayWrap(kps.RelatedPackages.RelatedPackage) as KpsFile.KpsFileRelatedPackage[]).map(p =>
({id: p.$.ID, relationship: p.$.Relationship == 'deprecates' ? 'deprecates' : 'related'})
({id: p.ID, relationship: p.Relationship == 'deprecates' ? 'deprecates' : 'related'})
);
}

Expand Down Expand Up @@ -329,17 +329,17 @@ export class KmpCompiler implements KeymanCompiler {
[],
examples: keyboard.Examples ?
(this.arrayWrap(keyboard.Examples.Example) as KpsFile.KpsFileLanguageExample[]).map(
e => ({id: e.$.ID, keys: e.$.Keys, text: e.$.Text, note: e.$.Note})
e => ({id: e.ID, keys: e.Keys, text: e.Text, note: e.Note})
) as KmpJsonFile.KmpJsonFileExample[] :
undefined,
webDisplayFonts: keyboard.WebDisplayFonts ?
(this.arrayWrap(keyboard.WebDisplayFonts.Font) as KpsFile.KpsFileFont[]).map(
e => (this.callbacks.path.basename(this.normalizePath(e.$.Filename)))
e => (this.callbacks.path.basename(this.normalizePath(e.Filename)))
) :
undefined,
webOskFonts: keyboard.WebOSKFonts ?
(this.arrayWrap(keyboard.WebOSKFonts.Font) as KpsFile.KpsFileFont[]).map(
e => (this.callbacks.path.basename(this.normalizePath(e.$.Filename)))
e => (this.callbacks.path.basename(this.normalizePath(e.Filename)))
) :
undefined,
}));
Expand Down

0 comments on commit 877522c

Please sign in to comment.