()
| 55 | } |
| 56 | |
| 57 | async function main() { |
| 58 | console.log('> Waiting for electron app to be ready...') |
| 59 | await app.whenReady() |
| 60 | console.log(' - Electron app is ready') |
| 61 | |
| 62 | console.log('\n> Starting desktop sandbox...') |
| 63 | const desktop = await Sandbox.create() |
| 64 | console.log(' - Desktop sandbox started, ID:', desktop.sandboxId) |
| 65 | |
| 66 | const size = await desktop.getScreenSize() |
| 67 | console.log(' - Desktop sandbox screen size:', size) |
| 68 | |
| 69 | console.log('\n> Starting desktop stream...') |
| 70 | await desktop.stream.start({ |
| 71 | requireAuth: true |
| 72 | }) |
| 73 | |
| 74 | console.log('\n> Waiting 5 seconds for the stream to load...') |
| 75 | for (let i = 5; i > 0; i--) { |
| 76 | console.log(` - ${i} seconds remaining until the next step...`) |
| 77 | await wait(1000) |
| 78 | } |
| 79 | |
| 80 | const authKey = await desktop.stream.getAuthKey() |
| 81 | const url = desktop.stream.getUrl({ authKey }) |
| 82 | console.log(' - Stream URL:', url) |
| 83 | |
| 84 | console.log('\n> Creating browser window...') |
| 85 | createWindow(url, size.width, size.height) |
| 86 | console.log(' - Browser window created') |
| 87 | |
| 88 | await moveAround(desktop, size.width, size.height) |
| 89 | |
| 90 | console.log('\nPress enter to kill the sandbox and close the window...') |
| 91 | process.stdin.once('data', async () => { |
| 92 | console.log('\n> Stopping desktop stream...') |
| 93 | await desktop.stream.stop() |
| 94 | console.log(' - Desktop stream stopped') |
| 95 | |
| 96 | console.log('\n> Closing browser window...') |
| 97 | console.log(' - Browser window closed') |
| 98 | |
| 99 | console.log('\n> Killing desktop sandbox...') |
| 100 | await desktop.kill() |
| 101 | console.log(' - Desktop sandbox killed') |
| 102 | |
| 103 | app.quit() |
| 104 | }) |
| 105 | } |
| 106 | |
| 107 | main().then().catch(console.error) |
no test coverage detected