Skip to content

Commit

Permalink
macro @unsafe refactoring. ↑v0.1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Eben60 committed Jan 11, 2025
1 parent 84211b6 commit 297219f
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 36 deletions.
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PackageMaker"
uuid = "29c12bd1-d721-479e-9f19-f3213c237221"
authors = ["Eben60"]
version = "0.1.5"
version = "0.1.6"

[deps]
Blink = "ad839575-38b3-5650-b840-f874b8c74a25"
Expand All @@ -13,6 +13,7 @@ LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
NativeFileDialog = "e1fe445b-aa65-4df4-81c1-2041507f0fd4"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PkgTemplates = "14b8a8f1-9102-5b29-a752-f990bacb7fe1"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

Expand All @@ -33,6 +34,7 @@ LibGit2 = "<0.0.1, 1"
NativeFileDialog = "0.2.1"
Pkg = "1.10"
PkgTemplates = "=0.7.53"
Sockets = "<0.0.1, 1"
TOML = "1.0.3"
UUIDs = "<0.0.1, 1"
julia = "1.10"
4 changes: 4 additions & 0 deletions src/PackageMaker.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ include("html.jl")
include("blink_interactions.jl")
include("handleinput.jl")

include("macro_unsafe.jl")
using .MacroUnsafe
export @unsafe

include("jld2_to_extend.jl")

export gogui
Expand Down
41 changes: 41 additions & 0 deletions src/macro_unsafe.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module MacroUnsafe

using Blink, Blink.AtomShell
using Sockets: @ip_str

using Blink.AtomShell: port, inspector, try_connect, electron, initcbs, mainjs

"""
@unsafe
A workaround for an upstream bug on Ubuntu 24. It disables sandboxing in Electron.
Run this macro before calling `gogui()`.
The recommended way of using PackageMaker on Ubuntu 24 is however to use from VSCode, as
in this case it works OK without calling `@unsafe`
# Examples
```julia-repl
julia> @unsafe;
julia> gogui()
```
"""
macro unsafe() # https://github.com/JuliaGizmos/Blink.jl/issues/325#issuecomment-2252670794
return quote
function Blink.AtomShell.init(; debug = false)
electron() # Check path exists
p, dp = port(), port()
debug && inspector(dp)
dbg = debug ? "--debug=$dp" : []
proc = (debug ? run_rdr : run)(
`$(electron()) --no-sandbox $dbg $mainjs port $p`; wait=false)
conn = try_connect(ip"127.0.0.1", p)
shell = Electron(proc, conn)
initcbs(shell)
return shell
end
end
end
export @unsafe

end
35 changes: 0 additions & 35 deletions src/processvals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -326,41 +326,6 @@ Starts the GUI. If `exitjulia` is `true`, then after the GUI is exited and the p
"""
gogui(exitjulia=true) = (_gogui(exitjulia); return nothing)

"""
@unsafe
A workaround for an upstream bug on Ubuntu 24. It disables sandboxing in Electron.
Run this macro before calling `gogui()`.
The recommended way of using PackageMaker on Ubuntu 24 is however to use from VSCode, as
in this case it works OK without calling `@unsafe`
# Examples
```julia-repl
julia> @unsafe;
julia> gogui()
```
"""
macro unsafe() # https://github.com/JuliaGizmos/Blink.jl/issues/325#issuecomment-2252670794
return @eval AtomShell begin
function init(; debug = false)
electron() # Check path exists
p, dp = port(), port()
debug && inspector(dp)
dbg = debug ? "--debug=$dp" : []
proc = (debug ? run_rdr : run)(
`$(electron()) --no-sandbox $dbg $mainjs port $p`; wait=false)
conn = try_connect(ip"127.0.0.1", p)
shell = Electron(proc, conn)
initcbs(shell)
return shell
end
end
end
export @unsafe



startyourpk(args...; kwargs...) = @warn "Function startyourpk is deprecated as of v.0.0.9. Please use gogui instead"
export startyourpk

Expand Down

0 comments on commit 297219f

Please sign in to comment.