Repository navigation
Expand file tree
/
Copy pathruntime.mjs
More file actions
51 lines (44 loc) · 2.35 KB
/
Copy pathruntime.mjs
File metadata and controls
51 lines (44 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// evoX Toolkit — T1 (trusted-node) giriş noktası.
// Host bu dosyayı fork eder ve 5 sn içinde handshake bekler; bu yüzden burada yalnız hafif
// modüller yüklenir. sharp ilk tuş çiziminde, PowerShell/SendInput katmanı ilk basışta yüklenir.
import { readFileSync } from 'node:fs';
import { EvoxPluginClient } from '@evoxapp/plugin-sdk';
import { createNodeProcessIpcPluginTransport } from '@evoxapp/plugin-sdk/node';
import { createLogger } from './src/util.js';
import { createKeyPainter } from './src/keyimg.js';
import { registerCounter } from './src/actions/counter.js';
import { registerWeather } from './src/actions/weather.js';
import { registerHotkey } from './src/actions/hotkey.js';
import { registerClipboard } from './src/actions/clipboard.js';
import { registerOpenUrl } from './src/actions/openurl.js';
const manifest = JSON.parse(readFileSync(new URL('./manifest.json', import.meta.url), 'utf8'));
const log = createLogger();
// Yakalanmamış bir ret süreci düşürür ve host'un çökme bütçesini (5 dk'da 3) harcar; kaydedip devam et.
process.on('unhandledRejection', (error) => log('unhandledRejection', error));
const client = new EvoxPluginClient(createNodeProcessIpcPluginTransport(), {
// Manifestteki sdkVersion ile birebir aynı olmalı; host handshake'te karşılaştırır.
sdkVersion: manifest.sdkVersion,
onError: (error) => log('sdk', error),
});
let windowsLayer = null;
const loadWindows = () => (windowsLayer ??= import('./src/windows.js')
.then((m) => m.createWindowsLayer())
.catch((error) => { windowsLayer = null; throw error; }));
const win = Object.fromEntries(['sendCombo', 'getClipboard', 'setClipboard', 'typeText', 'openExternal']
.map((name) => [name, async (...args) => (await loadWindows())[name](...args)]));
// Tüm aksiyonlar tek çiziciyi paylaşır: tuş başına son kart hatırlanır, aynısı yeniden gönderilmez.
const painter = createKeyPainter(client, { log });
const counter = registerCounter(client, { log, painter });
const weather = registerWeather(client, { log, painter });
registerHotkey(client, { win, log, painter });
registerClipboard(client, { win, log, painter });
registerOpenUrl(client, { win, log, painter });
let stopped = false;
client.on('plugin.stop', () => {
if (stopped) return;
stopped = true;
counter.stopAll();
weather.stopAll();
client.dispose();
});
await client.start();