Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor with PlutoDevMacros 0.6.0 #31

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ AbstractPlutoDingetjes = "6e696c72-6542-2067-7265-42206c756150"
BaseDirs = "18cc8868-cbac-4acf-b575-c8ff214dc66f"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
HypertextLiteral = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PlotlyBase = "a03496cd-edff-5a9b-9e67-9cda94a718b5"
PlutoDevMacros = "a0499f29-c39b-4c5c-807c-88074221b949"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"

Expand All @@ -27,7 +29,7 @@ PlotlyKaleidoExt = "PlotlyKaleido"
UnitfulExt = "Unitful"

[compat]
AbstractPlutoDingetjes = "1"
AbstractPlutoDingetjes = "1.2"
BaseDirs = "1"
Colors = "0.12"
HypertextLiteral = "0.9.4"
Expand Down
58 changes: 31 additions & 27 deletions notebooks/basic_tests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### A Pluto.jl notebook ###
# v0.19.27
# v0.19.29

#> custom_attrs = ["hide-enabled"]

Expand Down Expand Up @@ -136,7 +136,7 @@ pp = Plot(scatter3d(x = rand(N), y = rand(N), z = rand(N), mode="markers"), Layo
# ╔═╡ ccf62e33-8fcf-45d9-83ed-c7de80800b76
let
p = PlutoPlot(pp)
add_plotly_listener!(p, "plotly_relayout", htl_js("""
add_plotly_listener!(p, "plotly_relayout", """
(e) => {

console.log(e)
Expand All @@ -154,8 +154,7 @@ let
console.log('plot_obj: ',plot_obj.layout.scene?.camera?.eye)

}
"""))
PlutoPlotly._show(p)
""")
end

# ╔═╡ 1460ece1-7828-4e93-ac37-e979b874b492
Expand Down Expand Up @@ -228,40 +227,39 @@ md"""
# ╔═╡ c3b1a198-ef19-4a54-9c32-d9ea32a63812
let
p = PlutoPlot(Plot(rand(10), Layout(uirevision = 1)))
add_plotly_listener!(p, "plotly_relayout", htl_js("""
add_plotly_listener!(p, "plotly_relayout", """
function(e) {

console.log('listener 1')

}
"""))
add_plotly_listener!(p, "plotly_relayout", htl_js("""
""")
add_plotly_listener!(p, "plotly_relayout", """
function(e) {

console.log('listener 2')

}
"""))
@htl "$p"
""")
end

# ╔═╡ e9fc2030-c2f0-48e9-a807-424039e796b2
let
p = PlutoPlot(Plot(rand(10), Layout(uirevision = 1)))
add_plotly_listener!(p, "plotly_relayout", htl_js("""
add_plotly_listener!(p, "plotly_relayout", """
function(e) {

console.log('listener 1')

}
"""))
add_plotly_listener!(p, "plotly_relayout", htl_js("""
""")
add_plotly_listener!(p, "plotly_relayout", """
function(e) {

console.log('listener 2')

}
"""))
""")
p.plotly_listeners
end

Expand All @@ -277,13 +275,13 @@ lololol = 1
let
lololol
p = PlutoPlot(Plot(rand(10), Layout(uirevision = 1)))
add_js_listener!(p, "mousedown", htl_js("""
add_js_listener!(p, "mousedown", """
function(e) {

console.log('MOUSEDOWN!')

}
"""))
""")
end

# ╔═╡ 6128ff76-3f1f-4144-bb3d-f44678210013
Expand Down Expand Up @@ -518,8 +516,8 @@ PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8"

[compat]
Colors = "~0.12.10"
PlutoDevMacros = "~0.5.8"
PlutoExtras = "~0.7.9"
PlutoDevMacros = "0.6"
PlutoExtras = "0.7"
PlutoUI = "~0.7.52"
"""

Expand All @@ -529,7 +527,7 @@ PLUTO_MANIFEST_TOML_CONTENTS = """

julia_version = "1.10.0-beta2"
manifest_format = "2.0"
project_hash = "becb366eb1628f34a109423203d027d4a184385e"
project_hash = "6b1e8a02b00ef43bc0119f5085df2925b6e55084"

[[deps.AbstractPlutoDingetjes]]
deps = ["Pkg"]
Expand Down Expand Up @@ -568,6 +566,12 @@ version = "1.0.5+1"
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"

[[deps.DocStringExtensions]]
deps = ["LibGit2"]
git-tree-sha1 = "2fb1e02f2b635d0845df5d7c167fec4dd739b00d"
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
version = "0.9.3"

[[deps.Downloads]]
deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"]
uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
Expand Down Expand Up @@ -687,16 +691,16 @@ uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
version = "1.10.0"

[[deps.PlutoDevMacros]]
deps = ["HypertextLiteral", "InteractiveUtils", "MacroTools", "Markdown", "Pkg", "Random", "TOML"]
git-tree-sha1 = "6ce1d9f7c078b493812161349c48735dee275466"
deps = ["AbstractPlutoDingetjes", "DocStringExtensions", "HypertextLiteral", "InteractiveUtils", "MacroTools", "Markdown", "Pkg", "Random", "TOML"]
git-tree-sha1 = "06fa4aa7a8f2239eec99cf54eeddd34f3d4359be"
uuid = "a0499f29-c39b-4c5c-807c-88074221b949"
version = "0.5.8"
version = "0.6.0"

[[deps.PlutoExtras]]
deps = ["AbstractPlutoDingetjes", "HypertextLiteral", "InteractiveUtils", "Markdown", "PlutoDevMacros", "PlutoUI", "REPL", "Reexport"]
git-tree-sha1 = "aad38509250eaa0840d2aadd73ef23c2a89bdb4a"
deps = ["AbstractPlutoDingetjes", "HypertextLiteral", "InteractiveUtils", "Markdown", "PlutoDevMacros", "PlutoUI", "REPL"]
git-tree-sha1 = "382b530c2ebe31f4a44cb055642bbd71197fbd20"
uuid = "ed5d0301-4775-4676-b788-cf71e66ff8ed"
version = "0.7.9"
version = "0.7.11"

[[deps.PlutoUI]]
deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "FixedPointNumbers", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "MIMEs", "Markdown", "Random", "Reexport", "URIs", "UUIDs"]
Expand All @@ -712,9 +716,9 @@ version = "1.2.0"

[[deps.Preferences]]
deps = ["TOML"]
git-tree-sha1 = "7eb1686b4f04b82f96ed7a4ea5890a4f0c7a09f1"
git-tree-sha1 = "00805cd429dcb4870060ff49ef443486c262e38e"
uuid = "21216c6a-2e73-6563-6e65-726566657250"
version = "1.4.0"
version = "1.4.1"

[[deps.Printf]]
deps = ["Unicode"]
Expand Down Expand Up @@ -833,7 +837,7 @@ version = "17.4.0+2"
# ╠═de0cb780-ff4e-4236-89c4-4c3163337cfc
# ╠═dd23fe10-a8d5-461a-85a8-e03468cdcd97
# ╠═ccf62e33-8fcf-45d9-83ed-c7de80800b76
# ╠═1460ece1-7828-4e93-ac37-e979b874b492
# ╟─1460ece1-7828-4e93-ac37-e979b874b492
# ╠═18c80ea2-0df4-40ea-bd87-f8fee463161e
# ╠═ce29fa1f-0c52-4d38-acbd-0a96cb3b9ce6
# ╟─c3e29c94-941d-4a52-a358-c4ffbfc8cab8
Expand Down
24 changes: 15 additions & 9 deletions notebooks/make_subplots_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ PlutoExtras = "ed5d0301-4775-4676-b788-cf71e66ff8ed"
PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8"

[compat]
PlutoDevMacros = "~0.5.8"
PlutoExtras = "~0.7.10"
PlutoDevMacros = "~0.6.0"
PlutoExtras = "~0.7.11"
PlutoUI = "~0.7.52"
"""

Expand All @@ -181,7 +181,7 @@ PLUTO_MANIFEST_TOML_CONTENTS = """

julia_version = "1.10.0-beta2"
manifest_format = "2.0"
project_hash = "f50c3104111b5d594359e3dd1628a076c5fe269d"
project_hash = "46f2e02ace855d54b6bc9494b62148b187ae7606"

[[deps.AbstractPlutoDingetjes]]
deps = ["Pkg"]
Expand Down Expand Up @@ -214,6 +214,12 @@ version = "1.0.5+1"
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"

[[deps.DocStringExtensions]]
deps = ["LibGit2"]
git-tree-sha1 = "2fb1e02f2b635d0845df5d7c167fec4dd739b00d"
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
version = "0.9.3"

[[deps.Downloads]]
deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"]
uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
Expand Down Expand Up @@ -333,16 +339,16 @@ uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
version = "1.10.0"

[[deps.PlutoDevMacros]]
deps = ["HypertextLiteral", "InteractiveUtils", "MacroTools", "Markdown", "Pkg", "Random", "TOML"]
git-tree-sha1 = "6ce1d9f7c078b493812161349c48735dee275466"
deps = ["AbstractPlutoDingetjes", "DocStringExtensions", "HypertextLiteral", "InteractiveUtils", "MacroTools", "Markdown", "Pkg", "Random", "TOML"]
git-tree-sha1 = "06fa4aa7a8f2239eec99cf54eeddd34f3d4359be"
uuid = "a0499f29-c39b-4c5c-807c-88074221b949"
version = "0.5.8"
version = "0.6.0"

[[deps.PlutoExtras]]
deps = ["AbstractPlutoDingetjes", "HypertextLiteral", "InteractiveUtils", "Markdown", "PlutoDevMacros", "PlutoUI", "REPL", "Reexport"]
git-tree-sha1 = "beedecb30d8ed0874773d5641f5ce5ee2bfeeded"
deps = ["AbstractPlutoDingetjes", "HypertextLiteral", "InteractiveUtils", "Markdown", "PlutoDevMacros", "PlutoUI", "REPL"]
git-tree-sha1 = "382b530c2ebe31f4a44cb055642bbd71197fbd20"
uuid = "ed5d0301-4775-4676-b788-cf71e66ff8ed"
version = "0.7.10"
version = "0.7.11"

[[deps.PlutoUI]]
deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "FixedPointNumbers", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "MIMEs", "Markdown", "Random", "Reexport", "URIs", "UUIDs"]
Expand Down
6 changes: 6 additions & 0 deletions src/PlutoPlotly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ using Reexport

using HypertextLiteral
using AbstractPlutoDingetjes
using AbstractPlutoDingetjes.Display
using Dates
using BaseDirs
using TOML
Expand All @@ -13,6 +14,10 @@ using LaTeXStrings
using Markdown
using Downloads: download

using PlutoDevMacros.PlutoCombineHTL.WithTypes
using PlutoDevMacros.PlutoCombineHTL: plutodefault, print_javascript, print_html
using Dictionaries

export PlutoPlot, get_plotly_version, change_plotly_version,
check_plotly_version, force_pluto_mathjax_local, htl_js, add_plotly_listener!,
add_class!, remove_class!, add_js_listener!
Expand All @@ -22,6 +27,7 @@ export make_subplots
include("local_plotly_library.jl")

include("main_struct.jl")
include("default_scriptcontents.jl")
include("basics.jl")
include("mathjax.jl")
include("preprocess.jl")
Expand Down
17 changes: 2 additions & 15 deletions src/basics.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
maybe_publish_to_js(x) = if is_inside_pluto()
if isdefined(Main.PlutoRunner, :core_published_to_js)
Main.PlutoRunner.PublishedToJavascript(x)
else
Main.PlutoRunner.publish_to_js(x)
end
published_to_js(x)

Check warning on line 2 in src/basics.jl

View check run for this annotation

Codecov / codecov/patch

src/basics.jl#L2

Added line #L2 was not covered by tests
else
x
end
Expand All @@ -14,15 +10,6 @@
Base.UUID(zero(UInt128))
end

function Base.show(io::IO, mime::MIME"text/html", s::JS)
if is_inside_pluto()
show(io, mime, Markdown.MD(Markdown.Code("js",s.content)))
else
show(io, MIME"text/plain",s)
end
end


## Plotly Version ##
function change_plotly_version(ver::String)
maybe_add_plotly_local(ver)
Expand Down Expand Up @@ -99,7 +86,7 @@

## Unique Counter ##
function unique_io_counter(io::IO, identifier = "script_id")
!get(io, :is_pluto, false) && return -1 # We simply return -1 if not inside pluto
is_inside_pluto(io) || return -1 # We simply return -1 if not inside pluto
# We extract (or create if not existing) a dictionary that will keep track of instances of the same script name
dict = get_IO_DICT(io)
# We use the objectid as the key
Expand Down
Loading