diff --git a/Project.toml b/Project.toml index d4e1b21..9c5b8d1 100644 --- a/Project.toml +++ b/Project.toml @@ -9,7 +9,6 @@ Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" JSExpr = "97c1335a-c9c5-57fe-bc5d-ec35cebe8660" JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" -Lazy = "50d2b5c4-7a5e-59d5-8109-a42b560f39c0" Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" Mustache = "ffc61752-8dc7-55ee-8c37-f3e9cdd09e70" @@ -23,7 +22,6 @@ WebIO = "0f1e0344-ec1d-5b48-a673-e5cf874b6c29" HTTP = "1.5.0" JSExpr = "0.5" JSON = "0.21, 1.0" -Lazy = "0.13, 0.14, 0.15" MacroTools = "0.4, 0.5" Mustache = "0.5, 1.0" Mux = "1.0" diff --git a/src/AtomShell/AtomShell.jl b/src/AtomShell/AtomShell.jl index 9d9377d..e6262c0 100644 --- a/src/AtomShell/AtomShell.jl +++ b/src/AtomShell/AtomShell.jl @@ -1,6 +1,6 @@ module AtomShell -using ..Blink: resource +using ..Blink: resource, @init, @errs using Sockets using WebIO diff --git a/src/AtomShell/process.jl b/src/AtomShell/process.jl index 83839ec..44a798f 100644 --- a/src/AtomShell/process.jl +++ b/src/AtomShell/process.jl @@ -1,4 +1,4 @@ -using Lazy, JSON, MacroTools, Pkg.Artifacts +using JSON, MacroTools, Pkg.Artifacts hascommand(c) = try read(`which $c`, String); true catch e false end diff --git a/src/Blink.jl b/src/Blink.jl index 05b856d..b39e4bd 100644 --- a/src/Blink.jl +++ b/src/Blink.jl @@ -9,6 +9,7 @@ using Logging using Base64: stringmime using WebIO +include("lazy/lazy.jl") include("rpc/rpc.jl") include("content/content.jl") diff --git a/src/content/content.jl b/src/content/content.jl index 112e365..e534750 100644 --- a/src/content/content.jl +++ b/src/content/content.jl @@ -1,4 +1,4 @@ -using Mux, JSON, Lazy, Mustache +using Mux, JSON, Mustache import HTTP: WebSocket import HTTP.WebSockets: isclosed diff --git a/src/lazy/lazy.jl b/src/lazy/lazy.jl new file mode 100644 index 0000000..e82505d --- /dev/null +++ b/src/lazy/lazy.jl @@ -0,0 +1,33 @@ +# Stuff to replace Lazy.jl with +function initm(ex) + quote + if !isdefined(@__MODULE__, :__inits__) + const $(esc(:__inits__)) = Function[] + end + if !isdefined(@__MODULE__, :__init__) + function $(esc(:__init__))() + for f in $(esc(:__inits__)) + f() + end + end + end + + push!($(esc(:__inits__)), () -> $(esc(ex))) + nothing + end +end + +macro init(args...) + initm(args...) +end + +macro errs(ex) + :( + try + $(esc(ex)) + catch e + showerror(stderr, e, catch_backtrace()) + println(stderr) + end + ) +end diff --git a/src/rpc/rpc.jl b/src/rpc/rpc.jl index 2fc3b47..e645d39 100644 --- a/src/rpc/rpc.jl +++ b/src/rpc/rpc.jl @@ -1,5 +1,4 @@ import JSExpr: @js, @js_str, JSString, jsstring, jsexpr, @var, @new -using Lazy export js, @js, @js_, @var, @new