Files
Wand-Enhancer-k1tbyte/web-panel/src/remote-session/remote-session.protocol.ts
T
kitbyte a0b3968d33 refactor(web-panel): update architecture + cheat i18n
Reorganize the panel around product capabilities and integrate the
remote i18n feature from origin/master into the new structure.

- Restructure src into capability features (app, trainer, library,
  remote-session, appearance, shared); move the bridge to bridge/src.
- Add lingui-based UI localization and wrap remaining user-facing
  strings (Trans / msg macros); fix the 'END В·' mojibake.
- Port WeMod cheat-metadata i18n: capture the access token from the
  snapshot's renderer in the bridge and fetch localized trainer_meta
  in remote-session.i18n; guarantee snapshot sync on token failure.
- Wire vitest to the app's lingui/preact pipeline (mergeConfig).
2026-06-15 00:10:49 +03:00

45 lines
1.7 KiB
TypeScript
Vendored

import { PROTOCOL_VERSION, type IncomingMessage } from '../../protocol/messages';
import type { RemoteSessionAction } from './remote-session.reducer';
export function protocolAction(message: IncomingMessage): RemoteSessionAction | null {
switch (message.type) {
case 'hello_ack':
if (!message.payload.accepted) {
return { type: 'error', message: 'The desktop bridge rejected the connection.' };
}
if (message.payload.protocolVersion !== PROTOCOL_VERSION) {
return {
type: 'error',
message: `Protocol mismatch: bridge=${message.payload.protocolVersion}, panel=${PROTOCOL_VERSION}.`,
};
}
return { type: 'connected' };
case 'trainer_meta':
return { type: 'trainerMeta', payload: message.payload };
case 'game_status':
return { type: 'gameStatus', payload: message.payload };
case 'installed_apps':
return { type: 'installedApps', payload: message.payload };
case 'trainer_values':
return { type: 'trainerValues', payload: message.payload.values };
case 'value_changed':
return { type: 'valueChanged', target: message.payload.target, value: message.payload.value };
case 'trainer_changed':
return { type: 'trainerChanged' };
case 'set_value_result':
return {
type: 'writeResult',
target: message.payload.target,
requestId: message.requestId,
ok: message.payload.ok,
message: message.payload.error?.message,
};
case 'remote_command_result':
return message.payload.ok
? null
: { type: 'error', message: message.payload.error?.message ?? 'The remote game command was rejected.' };
case 'error':
return { type: 'error', message: message.payload.message };
}
}