1
1
"use strict" ;
2
- const electron_1 = require ( "electron" ) ;
3
- let browserViews = [ ] ;
4
- let browserView , electronSocket ;
5
- module . exports = ( socket ) => {
2
+ var __assign = ( this && this . __assign ) || function ( ) {
3
+ __assign = Object . assign || function ( t ) {
4
+ for ( var s , i = 1 , n = arguments . length ; i < n ; i ++ ) {
5
+ s = arguments [ i ] ;
6
+ for ( var p in s ) if ( Object . prototype . hasOwnProperty . call ( s , p ) )
7
+ t [ p ] = s [ p ] ;
8
+ }
9
+ return t ;
10
+ } ;
11
+ return __assign . apply ( this , arguments ) ;
12
+ } ;
13
+ var electron_1 = require ( "electron" ) ;
14
+ var browserViews = ( global [ 'browserViews' ] = global [ 'browserViews' ] || [ ] ) ;
15
+ var browserView , electronSocket ;
16
+ module . exports = function ( socket ) {
6
17
electronSocket = socket ;
7
- socket . on ( 'createBrowserView' , ( options ) => {
18
+ socket . on ( 'createBrowserView' , function ( options ) {
8
19
if ( ! hasOwnChildreen ( options , 'webPreferences' , 'nodeIntegration' ) ) {
9
- options = { ... options , webPreferences : { nodeIntegration : true } } ;
20
+ options = __assign ( __assign ( { } , options ) , { webPreferences : { nodeIntegration : true } } ) ;
10
21
}
11
22
browserView = new electron_1 . BrowserView ( options ) ;
12
23
browserViews . push ( browserView ) ;
13
24
electronSocket . emit ( 'BrowserViewCreated' , browserView . id ) ;
14
25
} ) ;
15
- socket . on ( 'browserView-isDestroyed' , ( id ) => {
16
- const isDestroyed = getBrowserViewById ( id ) . isDestroyed ( ) ;
26
+ socket . on ( 'browserView-isDestroyed' , function ( id ) {
27
+ var isDestroyed = getBrowserViewById ( id ) . isDestroyed ( ) ;
17
28
electronSocket . emit ( 'browserView-isDestroyed-reply' , isDestroyed ) ;
18
29
} ) ;
19
- socket . on ( 'browserView-getBounds' , ( id ) => {
20
- const bounds = getBrowserViewById ( id ) . getBounds ( ) ;
30
+ socket . on ( 'browserView-getBounds' , function ( id ) {
31
+ var bounds = getBrowserViewById ( id ) . getBounds ( ) ;
21
32
electronSocket . emit ( 'browserView-getBounds-reply' , bounds ) ;
22
33
} ) ;
23
- socket . on ( 'browserView-setBounds' , ( id , bounds ) => {
34
+ socket . on ( 'browserView-setBounds' , function ( id , bounds ) {
24
35
getBrowserViewById ( id ) . setBounds ( bounds ) ;
25
36
} ) ;
26
- socket . on ( 'browserView-destroy' , ( id ) => {
27
- const browserViewIndex = browserViews . findIndex ( b => b . id === id ) ;
37
+ socket . on ( 'browserView-destroy' , function ( id ) {
38
+ var browserViewIndex = browserViews . findIndex ( function ( b ) { return b . id === id ; } ) ;
28
39
getBrowserViewById ( id ) . destroy ( ) ;
29
40
browserViews . splice ( browserViewIndex , 1 ) ;
30
41
} ) ;
31
- socket . on ( 'browserView-setAutoResize' , ( id , options ) => {
42
+ socket . on ( 'browserView-setAutoResize' , function ( id , options ) {
32
43
getBrowserViewById ( id ) . setAutoResize ( options ) ;
33
44
} ) ;
34
- socket . on ( 'browserView-setBackgroundColor' , ( id , color ) => {
45
+ socket . on ( 'browserView-setBackgroundColor' , function ( id , color ) {
35
46
getBrowserViewById ( id ) . setBackgroundColor ( color ) ;
36
47
} ) ;
37
- function hasOwnChildreen ( obj , ...childNames ) {
38
- for ( let i = 0 ; i < childNames . length ; i ++ ) {
48
+ function hasOwnChildreen ( obj ) {
49
+ var childNames = [ ] ;
50
+ for ( var _i = 1 ; _i < arguments . length ; _i ++ ) {
51
+ childNames [ _i - 1 ] = arguments [ _i ] ;
52
+ }
53
+ for ( var i = 0 ; i < childNames . length ; i ++ ) {
39
54
if ( ! obj || ! obj . hasOwnProperty ( childNames [ i ] ) ) {
40
55
return false ;
41
56
}
@@ -44,12 +59,11 @@ module.exports = (socket) => {
44
59
return true ;
45
60
}
46
61
function getBrowserViewById ( id ) {
47
- for ( let index = 0 ; index < browserViews . length ; index ++ ) {
48
- const browserViewItem = browserViews [ index ] ;
62
+ for ( var index = 0 ; index < browserViews . length ; index ++ ) {
63
+ var browserViewItem = browserViews [ index ] ;
49
64
if ( browserViewItem . id === id ) {
50
65
return browserViewItem ;
51
66
}
52
67
}
53
68
}
54
69
} ;
55
- //# sourceMappingURL=browserView.js.map
0 commit comments