Skip to content

Commit 50aef01

Browse files
committed
quit when all windows close on mac, added types
1 parent d8cacfd commit 50aef01

2 files changed

Lines changed: 1501 additions & 1998 deletions

File tree

examples/basic-javascript/index.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,18 @@ import { Sandbox } from '@e2b/desktop'
66
const windowFrameHeight = 29
77

88
app.on('window-all-closed', () => {
9-
if (process.platform !== 'darwin') {
10-
app.quit()
11-
}
12-
})
13-
14-
app.on('activate', () => {
15-
if (BrowserWindow.getAllWindows().length === 0) {
16-
console.log('activate event received')
17-
createWindow()
18-
}
9+
app.quit()
1910
})
2011

2112
function wait(ms) {
2213
return new Promise(resolve => setTimeout(resolve, ms))
2314
}
2415

16+
/**
17+
* @param {string} streamUrl - The URL of the stream to load
18+
* @param {number} width - The width of the window
19+
* @param {number} height - The height of the window
20+
*/
2521
async function createWindow(streamUrl, width, height) {
2622
const win = new BrowserWindow({
2723
title: 'E2B Desktop',
@@ -39,6 +35,11 @@ async function createWindow(streamUrl, width, height) {
3935
console.log(' - Stream URL loaded')
4036
}
4137

38+
/**
39+
* @param {import('@e2b/desktop').Sandbox} desktop - E2B desktop sandbox
40+
* @param {number} width - The width of the window
41+
* @param {number} height - The height of the window
42+
*/
4243
async function moveAround(desktop, width, height) {
4344
console.log('\n> Randomly moving mouse and right clicking 5 times...')
4445
for (let i = 0; i < 5; i++) {

0 commit comments

Comments
 (0)