@@ -2,47 +2,44 @@ import { config } from 'dotenv'
22
33config ( )
44import { Sandbox } from './dist'
5- import { writeFileSync } from 'fs' ;
5+ import { writeFileSync } from 'fs'
66
7+ console . log ( 'Starting desktop sandbox...' )
78
8- console . log ( "Starting desktop sandbox..." )
9+ console . time ( '--> Sandbox creation time' )
10+ const desktop = await Sandbox . create ( )
11+ console . timeEnd ( '--> Sandbox creation time' )
912
10- console . time ( '--> Sandbox creation time' ) ;
11- const desktop = await Sandbox . create ( ) ;
12- console . timeEnd ( '--> Sandbox creation time' ) ;
13-
14- console . log ( "Desktop Sandbox started, ID:" , desktop . sandboxId )
15- console . log ( "Screen size:" , await desktop . getScreenSize ( ) )
13+ console . log ( 'Desktop Sandbox started, ID:' , desktop . sandboxId )
14+ console . log ( 'Screen size:' , await desktop . getScreenSize ( ) )
1615
1716await desktop . stream . start ( {
18- requireAuth : true
17+ requireAuth : true ,
1918} )
2019
2120const authKey = await desktop . stream . getAuthKey ( )
22- console . log ( " Stream URL:" , desktop . stream . getUrl ( { authKey } ) )
21+ console . log ( ' Stream URL:' , desktop . stream . getUrl ( { authKey } ) )
2322
24- await new Promise ( resolve => setTimeout ( resolve , 5000 ) ) ;
23+ await new Promise ( ( resolve ) => setTimeout ( resolve , 5000 ) )
2524
2625console . log ( "Moving mouse to 'Applications' and clicking..." )
2726await desktop . moveMouse ( 100 , 100 )
2827await desktop . leftClick ( )
29- console . log ( "Cursor position:" , await desktop . getCursorPosition ( ) )
30-
31- await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ;
28+ console . log ( 'Cursor position:' , await desktop . getCursorPosition ( ) )
3229
33- const screenshot = await desktop . screenshot ( "bytes" )
34- writeFileSync ( '1.png' , Buffer . from ( screenshot ) ) ;
30+ await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) )
3531
32+ const screenshot = await desktop . screenshot ( 'bytes' )
33+ writeFileSync ( '1.png' , Buffer . from ( screenshot ) )
3634
3735for ( let i = 0 ; i < 20 ; i ++ ) {
38- const x = Math . floor ( Math . random ( ) * 1024 ) ;
39- const y = Math . floor ( Math . random ( ) * 768 ) ;
40- await desktop . moveMouse ( x , y ) ;
41- await new Promise ( resolve => setTimeout ( resolve , 2000 ) ) ;
42- await desktop . rightClick ( ) ;
36+ const x = Math . floor ( Math . random ( ) * 1024 )
37+ const y = Math . floor ( Math . random ( ) * 768 )
38+ await desktop . moveMouse ( x , y )
39+ await new Promise ( ( resolve ) => setTimeout ( resolve , 2000 ) )
40+ await desktop . rightClick ( )
4341 console . log ( 'right clicked' , i )
4442}
4543
46-
4744await desktop . stream . stop ( )
4845await desktop . kill ( )
0 commit comments