fix(developer): ldml add KeysCompiler.hardwareLayers()

This commit is contained in:
Steven R. Loomis 2023-03-14 18:14:24 -05:00
parent 275c310e79
commit 0f99a62a4e

View file

@ -15,6 +15,14 @@ export class KeysCompiler extends SectionCompiler {
return constants.section.keys;
}
/**
*
* @returns just the non-touch layers.
*/
public hardwareLayers() {
return this.keyboard.layers?.filter(({form}) => form !== 'touch');
}
public validate() {
let valid = true;
@ -40,7 +48,7 @@ export class KeysCompiler extends SectionCompiler {
// the layr compiler does more extensive validation of the layer attributes.
// Kmap validation
const hardwareLayers = this.keyboard.layers?.filter(({form}) => form !== 'touch');
const hardwareLayers = this.hardwareLayers();
if (hardwareLayers.length >= 1) {
// validate all errors
@ -72,7 +80,7 @@ export class KeysCompiler extends SectionCompiler {
// Finally, kmap
// Use LayerMap + keys to generate compiled keys for hardware
const hardwareLayers = this.keyboard.layers?.filter(({form}) => form !== 'touch');
const hardwareLayers = this.hardwareLayers();
if (hardwareLayers.length > 1) {
// validation should have already caught this
throw Error(`Internal error: Expected 0 or 1 hardware layer, not ${hardwareLayers.length}`);