mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-20 17:03:42 +00:00
refactor: use standard prettier formatting
This commit is contained in:
@@ -1,35 +1,38 @@
|
||||
import type {ActionInfo, KeymapCategory} from "$lib/assets/keymaps/keymap"
|
||||
import type { ActionInfo, KeymapCategory } from "$lib/assets/keymaps/keymap";
|
||||
|
||||
export interface KeyInfo extends Partial<ActionInfo> {
|
||||
code: number
|
||||
category: KeymapCategory
|
||||
code: number;
|
||||
category: KeymapCategory;
|
||||
}
|
||||
|
||||
export const KEYMAP_CATEGORIES = (await Promise.all(
|
||||
Object.values(import.meta.glob("$lib/assets/keymaps/*.yml")).map(async load =>
|
||||
load().then(it => (it as any).default),
|
||||
Object.values(import.meta.glob("$lib/assets/keymaps/*.yml")).map(
|
||||
async (load) => load().then((it) => (it as any).default),
|
||||
),
|
||||
)) as KeymapCategory[]
|
||||
)) as KeymapCategory[];
|
||||
|
||||
export const KEYMAP_CODES: Record<number, KeyInfo> = Object.fromEntries(
|
||||
KEYMAP_CATEGORIES.flatMap(category =>
|
||||
KEYMAP_CATEGORIES.flatMap((category) =>
|
||||
Object.entries(category.actions).map(([code, action]) => [
|
||||
Number(code),
|
||||
{...action, code: Number(code), category},
|
||||
{ ...action, code: Number(code), category },
|
||||
]),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
export const KEYMAP_KEYCODES: Map<string, number> = new Map(
|
||||
KEYMAP_CATEGORIES.flatMap(category =>
|
||||
Object.entries(category.actions).map(([code, action]) => [action.keyCode!, Number(code)] as const),
|
||||
KEYMAP_CATEGORIES.flatMap((category) =>
|
||||
Object.entries(category.actions).map(
|
||||
([code, action]) => [action.keyCode!, Number(code)] as const,
|
||||
),
|
||||
).filter(([keyCode]) => keyCode !== undefined),
|
||||
)
|
||||
);
|
||||
|
||||
export const KEYMAP_IDS: Map<string, KeyInfo> = new Map(
|
||||
KEYMAP_CATEGORIES.flatMap(category =>
|
||||
KEYMAP_CATEGORIES.flatMap((category) =>
|
||||
Object.entries(category.actions).map(
|
||||
([code, action]) => [action.id!, {...action, code: Number(code), category}] as const,
|
||||
([code, action]) =>
|
||||
[action.id!, { ...action, code: Number(code), category }] as const,
|
||||
),
|
||||
).filter(([id]) => id !== undefined),
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user