The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | // Isolate native screenshot crashes and stalls in a Node-mode child. |
| 2 | import type { RegionSnapShotRequest, RegionSnapShotResult } from "./RegionSnapShot.ts"; |
| 3 | |
| 4 | process.once("disconnect", () => process.exit(0)); |
| 5 | |
| 6 | async function capture() { |
| 7 | const imported = await import("@crowecawcaw/xa11y"); |
| 8 | const xa11y = (imported as unknown as { readonly default?: typeof imported }).default ?? imported; |
| 9 | process.send?.("ready"); |
| 10 | const request = await new Promise<RegionSnapShotRequest>((resolve) => { |
| 11 | process.once("message", resolve); |
| 12 | }); |
| 13 | const shot = await xa11y.screenshot({ region: request.region }); |
| 14 | const result: RegionSnapShotResult = { |
| 15 | type: "result", |
| 16 | width: shot.width, |
| 17 | height: shot.height, |
| 18 | png: shot.toPng().toString("base64"), |
| 19 | }; |
| 20 | process.send?.(result); |
| 21 | } |
| 22 | |
| 23 | void capture().catch((error: unknown) => |
| 24 | process.send?.({ |
| 25 | type: "error", |
| 26 | message: error instanceof Error ? error.message : "Windows window capture failed.", |
| 27 | } satisfies RegionSnapShotResult), |
| 28 | ); |