Skip to content

Commit fe6e364

Browse files
Convert IJulia provider to extension
1 parent 5d5b847 commit fe6e364

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

Project.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,16 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
1919
WebSockets = "104b5d7c-a370-577a-8038-80a2059c5097"
2020
Widgets = "cc8bc4a8-27d6-5769-a93b-9d913e69aa62"
2121

22+
[weakdeps]
23+
IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a"
24+
25+
[extensions]
26+
IJuliaExt = "IJulia"
27+
2228
[compat]
2329
AssetRegistry = "0.1.0"
2430
FunctionalCollections = "0.5.0"
31+
IJulia = "1.13"
2532
JSON = "0.18, 0.19, 0.20, 0.21"
2633
Observables = "0.5"
2734
Requires = "0.4.4, 0.5, 1.0.0"

ext/ijulia.jl renamed to ext/IJuliaExt.jl

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
using .AssetRegistry
2-
using .Sockets
3-
using .WebIO
1+
module IJuliaExt
2+
3+
using WebIO
4+
using WebIO: WEBIO_NODE_MIME
5+
using IJulia, Sockets
46

57
struct IJuliaConnection <: AbstractConnection
68
comm::IJulia.CommManager.Comm
@@ -68,16 +70,18 @@ function main()
6870
return
6971
end
7072

71-
# https://github.com/JuliaLang/IJulia.jl/pull/755
72-
if isdefined(IJulia, :register_jsonmime)
73-
IJulia.register_jsonmime(WEBIO_NODE_MIME())
74-
else
75-
@warn "IJulia doesn't have register_mime; WebIO may not work as expected. Please upgrade to IJulia v1.13.0 or greater."
76-
end
73+
IJulia.register_jsonmime(WEBIO_NODE_MIME())
7774

7875
# See comment on _IJuliaInit for what this does
7976
display(_IJuliaInit())
77+
78+
return nothing
8079
end
8180

8281
WebIO.setup_provider(::Val{:ijulia}) = main() # calling setup_provider(Val(:ijulia)) will display the setup javascript
83-
WebIO.setup(:ijulia)
82+
83+
function __init__()
84+
WebIO.setup(:ijulia)
85+
end
86+
87+
end

src/WebIO.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,13 @@ function prefetch_provider_file(basename)
9595
end
9696

9797
provider_mux = prefetch_provider_file("mux.jl")
98-
provider_ijulia = prefetch_provider_file("ijulia.jl")
9998
provider_generic_http = prefetch_provider_file("generic_http.jl")
10099

101100
function __init__()
102101
push!(Observables.addhandler_callbacks, WebIO.setup_comm)
103102
@require Mux="a975b10e-0019-58db-a62f-e48ff68538c9" begin
104103
include_string(@__MODULE__, provider_mux.code, provider_mux.file)
105104
end
106-
@require IJulia="7073ff75-c697-5162-941a-fcdaad2a7d2a" begin
107-
include_string(@__MODULE__, provider_ijulia.code, provider_ijulia.file)
108-
end
109105
@require WebSockets="104b5d7c-a370-577a-8038-80a2059c5097" begin
110106
include_string(@__MODULE__, provider_generic_http.code, provider_generic_http.file)
111107
end

0 commit comments

Comments
 (0)