|
1 | | -using .JSON |
2 | | -using .AssetRegistry |
3 | | -using .Sockets |
4 | | -using .Base64: stringmime |
5 | | -export webio_serve |
| 1 | +module MuxExt |
| 2 | + |
| 3 | +using WebIO |
| 4 | +using WebIO: MUX_BUNDLE_PATH |
| 5 | + |
| 6 | +using Mux, JSON, AssetRegistry |
| 7 | +using Sockets |
| 8 | +using Base64: stringmime |
6 | 9 |
|
7 | 10 | """ |
8 | 11 | webio_serve(app, port=8000) |
9 | 12 |
|
10 | 13 | Serve a Mux app which might return a WebIO node. |
11 | 14 | """ |
12 | | -function webio_serve(app, args...) |
| 15 | +function WebIO.webio_serve(app, args...) |
13 | 16 | http = Mux.App(Mux.mux( |
14 | 17 | Mux.defaults, |
15 | 18 | app, |
16 | 19 | Mux.notfound() |
17 | 20 | )) |
18 | | - webio_serve(http, args...) |
| 21 | + WebIO.webio_serve(http, args...) |
19 | 22 | end |
20 | | -function webio_serve(app::Mux.App, args...) |
| 23 | +function WebIO.webio_serve(app::Mux.App, args...) |
21 | 24 | websock = Mux.App(Mux.mux( |
22 | 25 | Mux.wdefaults, |
23 | 26 | Mux.route("/webio-socket", create_socket), |
|
53 | 56 |
|
54 | 57 | Base.isopen(p::WebSockConnection) = isopen(p.sock) |
55 | 58 |
|
56 | | -Mux.Response(o::AbstractWidget) = Mux.Response(Widgets.render(o)) |
| 59 | +# TYPE-PIRACY |
| 60 | +# Mux.Response(o::AbstractWidget) = Mux.Response(Widgets.render(o)) |
| 61 | + |
57 | 62 | function Mux.Response(content::Union{Node, Scope}) |
58 | 63 | script_url = try |
59 | 64 | AssetRegistry.register(MUX_BUNDLE_PATH) |
@@ -86,4 +91,9 @@ function WebIO.register_renderable(::Type{T}, ::Val{:mux}) where {T} |
86 | 91 | end |
87 | 92 |
|
88 | 93 | WebIO.setup_provider(::Val{:mux}) = nothing # Mux setup has no side-effects |
89 | | -WebIO.setup(:mux) |
| 94 | + |
| 95 | +function __init__() |
| 96 | + WebIO.setup(:mux) |
| 97 | +end |
| 98 | + |
| 99 | +end |
0 commit comments