mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-19 19:25:56 +00:00
Verified in the native window against a disposable fixture: import writes only <folder>.manager + registry; start surfaces a human 'database update required' message; stop returns to Offline. Live install untouched throughout. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
25 lines
950 B
JavaScript
25 lines
950 B
JavaScript
// Drives the real Tauri window over WebView2's DevTools protocol. Usage: node cdp.mjs <expression>
|
|
const port = process.env.CDP_PORT ?? "9222";
|
|
const targets = await (await fetch(`http://127.0.0.1:${port}/json`)).json();
|
|
const page = targets.find((t) => t.type === "page");
|
|
const ws = new WebSocket(page.webSocketDebuggerUrl);
|
|
await new Promise((r) => (ws.onopen = r));
|
|
let id = 0;
|
|
const pending = new Map();
|
|
ws.onmessage = (m) => {
|
|
const d = JSON.parse(m.data);
|
|
if (d.id && pending.has(d.id)) pending.get(d.id)(d);
|
|
};
|
|
export function evaluate(expression) {
|
|
return new Promise((resolve) => {
|
|
const n = ++id;
|
|
pending.set(n, resolve);
|
|
ws.send(JSON.stringify({ id: n, method: "Runtime.evaluate", params: { expression, awaitPromise: true, returnByValue: true } }));
|
|
});
|
|
}
|
|
if (process.argv[2]) {
|
|
const r = await evaluate(process.argv[2]);
|
|
console.log(JSON.stringify(r.result?.result?.value ?? r.result, null, 2));
|
|
ws.close();
|
|
}
|