migrate layout icons form unicode to material symbols

migrate keymap to yml
This commit is contained in:
2023-07-07 18:40:38 +02:00
parent 83ebbcf7dd
commit ece5b9a000
20 changed files with 2455 additions and 7280 deletions

View File

@@ -1,64 +1,21 @@
import keymapCodes from "$lib/assets/keymap_codes.json"
import keySymbols from "$lib/assets/key-symbols.json"
import type {ActionInfo, KeymapCategory} from "$lib/assets/keymaps/keymap"
export interface KeyInfo {
/**
* Numeric action code
*
* @example 345
*/
export interface KeyInfo extends Partial<ActionInfo> {
code: number
/**
* Long description of the action
*
* @example The space bar inserts a "Space" character, commonly used as a separator between words
*/
description?: string
/**
* Unique ID of the character
*
* @example SPACE
*/
id?: string
/**
* Short text representation of the action
*
* @example: Space Bar
*/
title?: string
/**
* Symbolic representation of the character (an icon)
*
* @example ␣
*/
symbol?: string
/**
* The charset or category the action belongs to
*
* @example ASCII
*/
charset?: CharsetCategory
category: KeymapCategory
}
export type CharsetCategory =
| "None"
| "ASCII"
| "CP-1252"
| "Raw Scancode"
| "Keybard"
| "CharaChorder"
| "CharaChorder One"
const keymaps = (await Promise.all(
Object.values(import.meta.glob("$lib/assets/keymaps/*.yml")).map(async load =>
load().then(it => (it as any).default),
),
)) as KeymapCategory[]
export const KEYMAP_CODES: Record<number, KeyInfo> = Object.fromEntries(
keymapCodes.map(([code, charset, id, title, description]) => [
code,
{
code: Number(code),
title: title || undefined,
charset: (charset || undefined) as CharsetCategory,
id: id || undefined,
symbol: id ? keySymbols[id as keyof typeof keySymbols] || undefined : undefined,
description: description || undefined,
},
]),
keymaps.flatMap(category =>
Object.entries(category.actions).map(([code, action]) => [
Number(code),
{...action, code: Number(code), category},
]),
),
)