@@ -5,18 +5,34 @@ using Electron: Electron, windows
5
5
using Bonito: Bonito, HTTPServer
6
6
7
7
const ELECTRON_APP = Ref {Any} (nothing )
8
+ const ELECTRON_DISP = Ref {Any} (nothing )
8
9
9
- function NDI. display_electron_app (restart)
10
- restart && close_windows ()
11
- webapp = NDI. get_webapp ()
10
+ function NDI. serve_app (:: NDI.ElectronDisp , app)
12
11
disp = get_electron_display ()
13
- display (disp, webapp )
12
+ display (disp, app )
14
13
nothing
15
14
end
16
15
16
+ function NDI. close_display (:: NDI.ElectronDisp ; strict)
17
+ if haswindow ()
18
+ @info " Close existing Windows"
19
+ close .(windows (ELECTRON_APP[]))
20
+ end
21
+ if strict
22
+ close_application ()
23
+ end
24
+ end
25
+
17
26
function get_electron_display ()
18
27
window = get_electron_window ()
19
- disp = HTTPServer. ElectronDisplay (window, HTTPServer. BrowserDisplay (; open_browser= false ))
28
+ # BUG: Electron display cannot be reused
29
+ # if isnothing(ELECTRON_DISP[]) || window != ELECTRON_DISP[].window
30
+ # disp = HTTPServer.ElectronDisplay(window, HTTPServer.BrowserDisplay(; open_browser=false))
31
+ # ELECTRON_DISP[] = disp
32
+ # else
33
+ # ELECTRON_DISP[]
34
+ # end
35
+ return HTTPServer. ElectronDisplay (window, HTTPServer. BrowserDisplay (; open_browser= false ))
20
36
end
21
37
22
38
function get_electron_window ()
@@ -50,13 +66,6 @@ function get_electron_app()
50
66
end
51
67
hasapp () = ! isnothing (ELECTRON_APP[]) && ELECTRON_APP[]. exists
52
68
53
- function close_windows ()
54
- if haswindow ()
55
- @info " Close existing Windows"
56
- close .(windows (ELECTRON_APP[]))
57
- end
58
- end
59
-
60
69
function close_application ()
61
70
if hasapp ()
62
71
@info " Close Electron Application"
0 commit comments