From 326eaa27005e90a8b2cb0fd3985bbc469a3d2f43 Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Fri, 19 Apr 2024 10:02:24 +0700 Subject: [PATCH] chore(web): type-related prep for touch-spec process deferral --- .../src/keyboards/activeLayout.ts | 6 ++++-- .../src/keyboards/defaultLayouts.ts | 18 ++++++++---------- .../src/keyboards/keyboard.ts | 6 ++++-- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/common/web/keyboard-processor/src/keyboards/activeLayout.ts b/common/web/keyboard-processor/src/keyboards/activeLayout.ts index 89156f8d9b..115171d7be 100644 --- a/common/web/keyboard-processor/src/keyboards/activeLayout.ts +++ b/common/web/keyboard-processor/src/keyboards/activeLayout.ts @@ -9,6 +9,8 @@ import type Keyboard from "./keyboard.js"; import { TouchLayout } from "@keymanapp/common-types"; import TouchLayoutDefaultHint = TouchLayout.TouchLayoutDefaultHint; import TouchLayoutFlick = TouchLayout.TouchLayoutFlick; +import TouchLayoutSpec = TouchLayout.TouchLayoutPlatform; +import TouchLayerSpec = TouchLayout.TouchLayoutLayer; import { type DeviceSpec } from "@keymanapp/web-utils"; // TS 3.9 changed behavior of getters to make them @@ -806,7 +808,7 @@ export class ActiveLayout implements LayoutFormFactor{ } } - static sanitize(rawLayout: LayoutFormFactor) { + static sanitize(rawLayout: TouchLayoutSpec) { ActiveLayout.correctLayerEmptyRowBug(rawLayout.layer); for(const layer of rawLayout.layer) { @@ -819,7 +821,7 @@ export class ActiveLayout implements LayoutFormFactor{ * @param layout * @param formFactor */ - static polyfill(layout: LayoutFormFactor, keyboard: Keyboard, formFactor: DeviceSpec.FormFactor): ActiveLayout { + static polyfill(layout: TouchLayoutSpec, keyboard: Keyboard, formFactor: DeviceSpec.FormFactor): ActiveLayout { /* c8 ignore start */ if(layout == null) { throw new Error("Cannot build an ActiveLayout for a null specification."); diff --git a/common/web/keyboard-processor/src/keyboards/defaultLayouts.ts b/common/web/keyboard-processor/src/keyboards/defaultLayouts.ts index 2aa96db209..e1efa9847c 100644 --- a/common/web/keyboard-processor/src/keyboards/defaultLayouts.ts +++ b/common/web/keyboard-processor/src/keyboards/defaultLayouts.ts @@ -6,7 +6,7 @@ import { Version, deepCopy } from "@keymanapp/web-utils"; import { TouchLayout } from "@keymanapp/common-types"; -import LayoutFormFactorBase = TouchLayout.TouchLayoutPlatform; +import LayoutFormFactorSpec = TouchLayout.TouchLayoutPlatform; import LayoutLayerBase = TouchLayout.TouchLayoutLayer; export type LayoutRow = TouchLayout.TouchLayoutRow; export type LayoutKey = TouchLayout.TouchLayoutKey; @@ -33,15 +33,13 @@ export interface LayoutLayer extends LayoutLayerBase { aligned?: boolean }; -export interface LayoutFormFactor extends LayoutFormFactorBase { - // To facilitate those post-processing elements. - layer: LayoutLayer[] +export interface LayoutFormFactor extends Omit { }; export type LayoutSpec = { - "desktop"?: LayoutFormFactor, - "phone"?: LayoutFormFactor, - "tablet"?: LayoutFormFactor + "desktop"?: LayoutFormFactorSpec, + "phone"?: LayoutFormFactorSpec, + "tablet"?: LayoutFormFactorSpec } const KEY_102_WIDTH = 200; @@ -93,7 +91,7 @@ export class Layouts { * @param {string} formFactor (really utils.FormFactor) * @return {LayoutFormFactor} */ - static buildDefaultLayout(PVK, keyboard: Keyboard, formFactor: string): LayoutFormFactor { + static buildDefaultLayout(PVK, keyboard: Keyboard, formFactor: string): LayoutFormFactorSpec { // Build a layout using the default for the device var layoutType=formFactor; @@ -114,7 +112,7 @@ export class Layouts { } // Clone the default layout object for this device - var layout: LayoutFormFactor = deepCopy(Layouts.dfltLayout[layoutType]); + var layout: LayoutFormFactorSpec = deepCopy(Layouts.dfltLayout[layoutType]); var n,layers=layout['layer'], keyLabels: KLS=PVK['KLS'], key102=PVK['K102']; var i, j, k, m, row, rows: LayoutRow[], key: LayoutKey, keys: LayoutKey[]; @@ -236,7 +234,7 @@ export class Layouts { // *** Step 2: Layer objects now exist; time to fill them with the appropriate key labels and key styles *** for(n=0; n