mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 15:25:46 +00:00
a27b26abbd
The shortcut contract (shortcutActions.ts + shortcutTypes.ts) is NOT a
pure-frontend file: src-tauri/src/cli/parse.rs include_str!s
'/../src/config/shortcutActions.ts' at compile time, so moving it to
lib/shortcuts/ (slice 7ad19671) broke the Rust build (couldn't read the file ->
dev build won't start). Revert the contract back to src/config/ — it has a
build-time backend path contract and belongs where Rust anchors it, not in lib/.
No Rust file touched (fix = restore the frontend path the backend expects).
cargo check green (13s), tsc 0, lint 0/0, frontend suite 319/2353 green.
Lesson: grep src-tauri for include_str!/include_bytes! '../src/...' before
moving ANY frontend file — Rust can pin a TS file by path.
41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
import type { ShortcutSlot } from '@/config/shortcutTypes';
|
|
import {
|
|
SHORTCUT_ACTION_REGISTRY,
|
|
type ShortcutAction,
|
|
type KeyAction,
|
|
type GlobalAction,
|
|
} from './shortcutActionRegistry';
|
|
|
|
const ALL_IN_APP_SHORTCUT_ACTIONS = (Object.keys(SHORTCUT_ACTION_REGISTRY) as ShortcutAction[])
|
|
.filter((action): action is KeyAction => 'inApp' in SHORTCUT_ACTION_REGISTRY[action])
|
|
.map(action => {
|
|
const inApp = SHORTCUT_ACTION_REGISTRY[action].inApp as ShortcutSlot;
|
|
return {
|
|
id: action,
|
|
getLabel: SHORTCUT_ACTION_REGISTRY[action].getLabel,
|
|
defaultBinding: inApp.defaultBinding,
|
|
hidden: inApp.hidden === true,
|
|
};
|
|
});
|
|
|
|
export const IN_APP_SHORTCUT_ACTIONS = ALL_IN_APP_SHORTCUT_ACTIONS.filter(action => !action.hidden);
|
|
|
|
export const GLOBAL_SHORTCUT_ACTIONS = (Object.keys(SHORTCUT_ACTION_REGISTRY) as ShortcutAction[])
|
|
.filter((action): action is GlobalAction => 'global' in SHORTCUT_ACTION_REGISTRY[action])
|
|
.map(action => ({
|
|
id: action,
|
|
getLabel: SHORTCUT_ACTION_REGISTRY[action].getLabel,
|
|
defaultBinding: SHORTCUT_ACTION_REGISTRY[action].global.defaultBinding,
|
|
}));
|
|
|
|
export const DEFAULT_IN_APP_BINDINGS = Object.fromEntries(
|
|
ALL_IN_APP_SHORTCUT_ACTIONS.map(action => [action.id, action.defaultBinding])
|
|
) as Record<KeyAction, string | null>;
|
|
|
|
export const DEFAULT_GLOBAL_SHORTCUTS: Partial<Record<GlobalAction, string>> = {};
|
|
for (const action of GLOBAL_SHORTCUT_ACTIONS) {
|
|
if (action.defaultBinding !== null) {
|
|
DEFAULT_GLOBAL_SHORTCUTS[action.id] = action.defaultBinding;
|
|
}
|
|
}
|