| 57 | } |
| 58 | |
| 59 | export async function runChromeNativeHost(): Promise<void> { |
| 60 | log('Initializing...') |
| 61 | |
| 62 | const host = new ChromeNativeHost() |
| 63 | const messageReader = new ChromeMessageReader() |
| 64 | |
| 65 | // Start the native host server |
| 66 | await host.start() |
| 67 | |
| 68 | // Process messages from Chrome until stdin closes |
| 69 | // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition |
| 70 | while (true) { |
| 71 | const message = await messageReader.read() |
| 72 | if (message === null) { |
| 73 | // stdin closed, Chrome disconnected |
| 74 | break |
| 75 | } |
| 76 | |
| 77 | await host.handleMessage(message) |
| 78 | } |
| 79 | |
| 80 | // Stop the server |
| 81 | await host.stop() |
| 82 | } |
| 83 | |
| 84 | const messageSchema = lazySchema(() => |
| 85 | z |