Skip to content

Commit

Permalink
Remove ElectronDisplay.jl and use Electron directly (#2524)
Browse files Browse the repository at this point in the history
* get rid of electrondisplay

* import

* move electron display

* fixes for old jsserve

* fix electrondisplay

* fix imports
  • Loading branch information
SimonDanisch authored Dec 28, 2022
1 parent 4da0069 commit 4dab995
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 12 deletions.
3 changes: 1 addition & 2 deletions WGLMakie/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ StaticArrays = "0.12, 1.0"
julia = "1.3"

[extras]
ElectronDisplay = "d872a56f-244b-5cc9-b574-2017b5b909a8"
MeshIO = "7269a6da-0436-5bbc-96c2-40638cbb6118"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "ElectronDisplay", "MeshIO"]
test = ["Test", "MeshIO"]
36 changes: 36 additions & 0 deletions WGLMakie/src/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,39 @@ function Base.insert!(td::Screen, scene::Scene, plot::Combined)
disp === nothing && error("Plot needs to be displayed to insert additional plots")
insert!(disp, scene, plot)
end

# Poor mans Require.jl for Electron
const ELECTRON_PKG_ID = Base.PkgId(Base.UUID("a1bb12fb-d4d1-54b4-b10a-ee7951ef7ad3"), "Electron")
function Electron()
if haskey(Base.loaded_modules, ELECTRON_PKG_ID)
return Base.loaded_modules[ELECTRON_PKG_ID]
else
error("Please Load Electron, if you want to use it!")
end
end

struct ElectronDisplay{EWindow} <: Base.Multimedia.AbstractDisplay
window::EWindow # a type parameter here so, that we dont need to depend on Electron Directly!
end

function ElectronDisplay()
w = Electron().Window()
Electron().toggle_devtools(w)
return ElectronDisplay(w)
end

Base.displayable(d::ElectronDisplay, ::MIME{Symbol("text/html")}) = true

function Base.display(ed::ElectronDisplay, app::App)
d = JSServe.BrowserDisplay()
session_url = "/browser-display"
server = JSServe.get_server()
old_app = JSServe.route!(server, Pair{Any,Any}(session_url, app))
url = JSServe.online_url(server, "/browser-display")
E = Electron()
return E.load(ed.window, E.URI(url))
end

function use_electron_display()
Base.Multimedia.pushdisplay(ElectronDisplay())
end
1 change: 0 additions & 1 deletion WGLMakie/test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[deps]
Electron = "a1bb12fb-d4d1-54b4-b10a-ee7951ef7ad3"
ElectronDisplay = "d872a56f-244b-5cc9-b574-2017b5b909a8"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
JSServe = "824d6782-a2ef-11e9-3a09-e5662e0c26f9"
Expand Down
8 changes: 4 additions & 4 deletions WGLMakie/test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using ElectronDisplay
ElectronDisplay.CONFIG.showable = showable
ElectronDisplay.CONFIG.single_window = true
ElectronDisplay.CONFIG.focus = false
using ImageMagick, FileIO
using WGLMakie, Makie, Test
using Pkg
using WGLMakie.JSServe
import Electron
WGLMakie.use_electron_display()

path = normpath(joinpath(dirname(pathof(Makie)), "..", "ReferenceTests"))
Pkg.develop(PackageSpec(path = path))
using ReferenceTests
Expand Down
13 changes: 9 additions & 4 deletions metrics/ttfp/benchmark-ttfp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ function get_colorbuffer(fig)
end

if Package == :WGLMakie
using ElectronDisplay
ElectronDisplay.CONFIG.showable = showable
ElectronDisplay.CONFIG.single_window = true
ElectronDisplay.CONFIG.focus = false
if isdefined(WGLMakie, :use_electron_display)
import Electron
WGLMakie.use_electron_display()
else
using ElectronDisplay
ElectronDisplay.CONFIG.showable = showable
ElectronDisplay.CONFIG.single_window = true
ElectronDisplay.CONFIG.focus = false
end
end

create_time = @ctime fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
Expand Down
2 changes: 1 addition & 1 deletion metrics/ttfp/run-benchmark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ ENV["JULIA_PKG_PRECOMPILE_AUTO"] = 0
project1 = make_project_folder("current-pr")
Pkg.activate(project1)
pkgs = [(; path="./MakieCore"), (; path="."), (; path="./$Package"), (;name="BenchmarkTools")]
Package == "WGLMakie" && push!(pkgs, (; name="ElectronDisplay"))
Package == "WGLMakie" && push!(pkgs, (; name="Electron"))
# cd("dev/Makie")
Pkg.develop(pkgs)
@time Pkg.precompile()
Expand Down

0 comments on commit 4dab995

Please sign in to comment.