mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-10 10:55:33 +00:00
chore(web): type-related prep for touch-spec process deferral
This commit is contained in:
parent
44c178f94b
commit
326eaa2700
3 changed files with 16 additions and 14 deletions
|
|
@ -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.");
|
||||
|
|
|
|||
|
|
@ -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<LayoutFormFactorSpec, 'layer'> {
|
||||
};
|
||||
|
||||
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<layers.length; n++) {
|
||||
var layer=layers[n], kx, shiftKey: LayoutKey = null, nextKey=null, allText='';
|
||||
var layer=layers[n] as LayoutLayer, kx, shiftKey: LayoutKey = null, nextKey=null, allText='';
|
||||
var capsKey: LayoutKey = null, numKey: LayoutKey = null, scrollKey: LayoutKey = null; // null if not in the OSK layout.
|
||||
var layerSpec = keyLabels[layer['id']];
|
||||
var isShift = layer['id'] == 'shift' ? 1 : 0;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ import { Layouts, type LayoutFormFactor } from "./defaultLayouts.js";
|
|||
import { ActiveKey, ActiveLayout, ActiveSubKey } from "./activeLayout.js";
|
||||
import KeyEvent from "../text/keyEvent.js";
|
||||
import type OutputTarget from "../text/outputTarget.js";
|
||||
import { TouchLayout } from "@keymanapp/common-types";
|
||||
import TouchLayoutSpec = TouchLayout.TouchLayoutPlatform;
|
||||
|
||||
import type { ComplexKeyboardStore } from "../text/kbdInterface.js";
|
||||
|
||||
|
|
@ -147,7 +149,7 @@ export default class Keyboard {
|
|||
}
|
||||
|
||||
// May return null if no layouts exist or have been initialized.
|
||||
private get _layouts(): {[formFactor: string]: LayoutFormFactor} {
|
||||
private get _layouts(): {[formFactor: string]: TouchLayoutSpec } {
|
||||
return this.scriptObject['KVKL']; // This one is compiled by Developer's visual keyboard layout editor.
|
||||
}
|
||||
|
||||
|
|
@ -357,7 +359,7 @@ export default class Keyboard {
|
|||
}
|
||||
}
|
||||
|
||||
private findOrConstructLayout(formFactor: DeviceSpec.FormFactor): LayoutFormFactor {
|
||||
private findOrConstructLayout(formFactor: DeviceSpec.FormFactor): TouchLayoutSpec {
|
||||
if(this._layouts) {
|
||||
// Search for viable layouts. `null` is allowed for desktop form factors when help text is available,
|
||||
// so we check explicitly against `undefined`.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue