mirror of
https://github.com/k1tbyte/Wand-Enhancer.git
synced 2026-08-29 05:01:53 +00:00
13759b1db6
- reduce ASAR IO overhead with streamed archive reads, buffered copies, faster relative-path handling and placeholder integrity records - fix in-place app.asar.unpacked packing/extraction self-copy cases that caused locked-file failures - tighten JS patch discovery with candidate bundle filters and search hints - require prebuilt remote-panel dist artifacts and clean up embedded bridge/script packaging - add unified build entrypoints for PowerShell, cmd and bash and move native CMake output under .tmp - add release metadata validation, changelog section extraction, pre-commit hook and GitHub Actions validation/release pipelines - make CHANGELOG the source of truth for release notes and document the tag-driven release flow - add updater release notes UI with latest/full changelog loading and localize the new update strings - modularize bridge renderer scripts, add installed apps and game status sync, and support remote launch/stop commands - centralize bridge protocol, IPC and WebSocket constants and improve LAN IP selection for QR pairing - refactor remote panel controls/state enums, persist accent color, polish library/session UI and refresh assets
62 lines
2.6 KiB
TypeScript
62 lines
2.6 KiB
TypeScript
import type { IncomingMessage, TrainerMetaPayload } from './protocol';
|
|
import { normalizeIncomingValue } from './protocol';
|
|
import type { PanelAction } from './state';
|
|
|
|
type Dispatch = (action: PanelAction) => void;
|
|
|
|
export function handleProtocolMessage(dispatch: Dispatch, message: IncomingMessage, trainerMeta: TrainerMetaPayload | null): void {
|
|
switch (message.type) {
|
|
case 'hello_ack':
|
|
handleHelloAck(dispatch, message.payload.accepted, message.payload.remoteUrl);
|
|
return;
|
|
case 'trainer_meta':
|
|
dispatch({ type: 'trainerMeta', payload: message.payload });
|
|
return;
|
|
case 'game_status':
|
|
dispatch({ type: 'gameStatus', payload: message.payload });
|
|
return;
|
|
case 'installed_apps':
|
|
dispatch({ type: 'installedApps', payload: message.payload });
|
|
return;
|
|
case 'trainer_values':
|
|
dispatch({ type: 'trainerValues', payload: message.payload.values });
|
|
return;
|
|
case 'value_changed':
|
|
handleValueChanged(dispatch, message, trainerMeta);
|
|
return;
|
|
case 'trainer_changed':
|
|
dispatch({ type: 'trainerChanged' });
|
|
return;
|
|
case 'set_value_result':
|
|
if (!message.payload.ok) {
|
|
dispatch({ type: 'error', message: message.payload.error?.message ?? 'The trainer rejected the requested value.' });
|
|
}
|
|
return;
|
|
case 'remote_command_result':
|
|
if (!message.payload.ok) {
|
|
dispatch({ type: 'error', message: message.payload.error?.message ?? 'The remote game command was rejected.' });
|
|
}
|
|
return;
|
|
case 'error':
|
|
dispatch({ type: 'error', message: message.payload.message });
|
|
return;
|
|
}
|
|
}
|
|
|
|
function handleHelloAck(dispatch: Dispatch, accepted: boolean, remoteUrl?: string): void {
|
|
if (!accepted) {
|
|
dispatch({ type: 'error', message: 'The desktop bridge rejected the connection.' });
|
|
return;
|
|
}
|
|
|
|
if (remoteUrl) {
|
|
dispatch({ type: 'setRemoteUrl', remoteUrl });
|
|
}
|
|
}
|
|
|
|
function handleValueChanged(dispatch: Dispatch, message: Extract<IncomingMessage, { type: 'value_changed' }>, trainerMeta: TrainerMetaPayload | null): void {
|
|
const cheat = trainerMeta?.schema.cheats.find((item) => item.target === message.payload.target || item.uuid === message.payload.cheatId);
|
|
const nextValue = cheat ? normalizeIncomingValue(cheat, message.payload.value) : message.payload.value;
|
|
dispatch({ type: 'valueChanged', target: message.payload.target, value: nextValue });
|
|
}
|