feat(core): add Electron runtime, services, and app composition

This commit is contained in:
2026-02-22 21:43:43 -08:00
parent 448ce03fd4
commit d3fd47f0ec
562 changed files with 69719 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import {
createHandleMpvCommandFromIpcHandler,
createRunSubsyncManualFromIpcHandler,
} from './ipc-bridge-actions';
test('handle mpv command handler forwards command and built deps', () => {
const calls: string[] = [];
const deps = {
triggerSubsyncFromConfig: () => {},
openRuntimeOptionsPalette: () => {},
cycleRuntimeOption: () => ({ ok: false as const, error: 'x' }),
showMpvOsd: () => {},
replayCurrentSubtitle: () => {},
playNextSubtitle: () => {},
sendMpvCommand: () => {},
isMpvConnected: () => true,
hasRuntimeOptionsManager: () => true,
};
const handle = createHandleMpvCommandFromIpcHandler({
handleMpvCommandFromIpcRuntime: (command, nextDeps) => {
calls.push(`command:${command.join(':')}`);
assert.equal(nextDeps, deps);
},
buildMpvCommandDeps: () => deps,
});
handle(['show-text', 'hello']);
assert.deepEqual(calls, ['command:show-text:hello']);
});
test('run subsync manual handler forwards request and result', async () => {
const calls: string[] = [];
const run = createRunSubsyncManualFromIpcHandler({
runManualFromIpc: async (request: { id: string }) => {
calls.push(`request:${request.id}`);
return { ok: true as const };
},
});
const result = await run({ id: 'job-1' });
assert.deepEqual(result, { ok: true });
assert.deepEqual(calls, ['request:job-1']);
});