diff --git a/Artifacts.toml b/Artifacts.toml
new file mode 100644
index 0000000..af53f1d
--- /dev/null
+++ b/Artifacts.toml
@@ -0,0 +1,6 @@
+[plotly-esm-min]
+git-tree-sha1 = "68f1084b42e64a8787e28f1c373476c106ecb448"
+
+ [[plotly-esm-min.download]]
+ sha256 = "807e538be455da123e15999673df98ddcfefd4d610aa4416ba3fa28806f24929"
+ url = "https://github.com/disberd/PlotlyArtifactsESM/releases/download/v2.30.1/plotly-esm-min.tar.gz"
diff --git a/Project.toml b/Project.toml
index d08f1d8..3b922a9 100644
--- a/Project.toml
+++ b/Project.toml
@@ -5,6 +5,7 @@ version = "0.4.6"
[deps]
AbstractPlutoDingetjes = "6e696c72-6542-2067-7265-42206c756150"
+Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
BaseDirs = "18cc8868-cbac-4acf-b575-c8ff214dc66f"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
@@ -28,6 +29,7 @@ UnitfulExt = "Unitful"
[compat]
AbstractPlutoDingetjes = "1"
+Artifacts = "1"
BaseDirs = "1"
Colors = "0.12"
Dates = "1.9"
@@ -38,6 +40,8 @@ LaTeXStrings = "1"
Markdown = "1.9"
Pkg = "1.9"
PlotlyBase = "0.8"
+PlotlyKaleido = "2"
Reexport = "1"
-julia = "1.9"
TOML = "1"
+Unitful = "1"
+julia = "1.9"
diff --git a/README.md b/README.md
index 3ef4d95..586bec9 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,7 @@
# PlutoPlotly.jl
+[![Build Status](https://github.com/disberd/PlutoPlotly.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/disberd/PlutoPlotly.jl/actions/workflows/CI.yml?query=branch%3Amain)
+[![Coverage](https://codecov.io/gh/disberd/PlutoPlotly.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/disberd/PlutoPlotly.jl)
+[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
This package provides a wrapper type `PlutoPlot` around the `Plot` type from [PlotlyBase.jl](https://github.com/sglyon/PlotlyBase.jl) that exposes the [plotly library](https://plotly.com/julia/).
diff --git a/notebooks/basic_tests.jl b/notebooks/basic_tests.jl
index fb71bed..582bdde 100644
--- a/notebooks/basic_tests.jl
+++ b/notebooks/basic_tests.jl
@@ -39,6 +39,9 @@ md"""
# Tests
"""
+# ╔═╡ 51a36d49-1dad-4340-8671-a6a63eb367a2
+enable_plutoplotly_offline()
+
# ╔═╡ c4e4400e-e063-4236-96e5-ca3a60313e37
md"""
## Layout Range
@@ -514,9 +517,9 @@ PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
[compat]
Colors = "~0.12.10"
-PlutoDevMacros = "~0.5.8"
-PlutoExtras = "~0.7.9"
-PlutoUI = "~0.7.52"
+PlutoDevMacros = "~0.7.2"
+PlutoExtras = "~0.7.12"
+PlutoUI = "~0.7.58"
"""
# ╔═╡ 00000000-0000-0000-0000-000000000002
@@ -525,13 +528,13 @@ PLUTO_MANIFEST_TOML_CONTENTS = """
julia_version = "1.10.2"
manifest_format = "2.0"
-project_hash = "becb366eb1628f34a109423203d027d4a184385e"
+project_hash = "b19cebbc09904d344f1a75767d597eb0075f0a44"
[[deps.AbstractPlutoDingetjes]]
deps = ["Pkg"]
-git-tree-sha1 = "91bd53c39b9cbfb5ef4b015e8b582d344532bd0a"
+git-tree-sha1 = "0f748c81756f2e5e6854298f11ad8b2dfae6911a"
uuid = "6e696c72-6542-2067-7265-42206c756150"
-version = "1.2.0"
+version = "1.3.0"
[[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
@@ -564,6 +567,12 @@ version = "1.1.0+0"
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"
@@ -580,21 +589,21 @@ version = "0.8.4"
[[deps.Hyperscript]]
deps = ["Test"]
-git-tree-sha1 = "8d511d5b81240fc8e6802386302675bdf47737b9"
+git-tree-sha1 = "179267cfa5e712760cd43dcae385d7ea90cc25a4"
uuid = "47d2ed2b-36de-50cf-bf87-49c2cf4b8b91"
-version = "0.0.4"
+version = "0.0.5"
[[deps.HypertextLiteral]]
deps = ["Tricks"]
-git-tree-sha1 = "c47c5fa4c5308f27ccaac35504858d8914e102f9"
+git-tree-sha1 = "7134810b1afce04bbc1045ca1985fbe81ce17653"
uuid = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2"
-version = "0.9.4"
+version = "0.9.5"
[[deps.IOCapture]]
deps = ["Logging", "Random"]
-git-tree-sha1 = "d75853a0bdbfb1ac815478bacd89cd27b550ace6"
+git-tree-sha1 = "8b72179abc660bfab5e28472e019392b97d0985c"
uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89"
-version = "0.2.3"
+version = "0.2.4"
[[deps.InteractiveUtils]]
deps = ["Markdown"]
@@ -647,9 +656,9 @@ version = "0.1.4"
[[deps.MacroTools]]
deps = ["Markdown", "Random"]
-git-tree-sha1 = "9ee1618cbf5240e6d4e0371d6f24065083f60c48"
+git-tree-sha1 = "2fa9ee3e63fd3a4f7a9a4f4744a52f4856de82df"
uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
-version = "0.5.11"
+version = "0.5.13"
[[deps.Markdown]]
deps = ["Base64"]
@@ -678,9 +687,9 @@ version = "0.3.23+4"
[[deps.Parsers]]
deps = ["Dates", "PrecompileTools", "UUIDs"]
-git-tree-sha1 = "716e24b21538abc91f6205fd1d8363f39b442851"
+git-tree-sha1 = "8489905bcdbcfac64d1daa51ca07c0d8f0283821"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
-version = "2.7.2"
+version = "2.8.1"
[[deps.Pkg]]
deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
@@ -688,34 +697,34 @@ 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 = "2944f76ac8c11c913a620da0a6b035e2fadf94c1"
uuid = "a0499f29-c39b-4c5c-807c-88074221b949"
-version = "0.5.8"
+version = "0.7.2"
[[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 = "93d8c75734da9192d0639406fe6fb446be0fba4f"
uuid = "ed5d0301-4775-4676-b788-cf71e66ff8ed"
-version = "0.7.9"
+version = "0.7.12"
[[deps.PlutoUI]]
deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "FixedPointNumbers", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "MIMEs", "Markdown", "Random", "Reexport", "URIs", "UUIDs"]
-git-tree-sha1 = "e47cd150dbe0443c3a3651bc5b9cbd5576ab75b7"
+git-tree-sha1 = "71a22244e352aa8c5f0f2adde4150f62368a3f2e"
uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
-version = "0.7.52"
+version = "0.7.58"
[[deps.PrecompileTools]]
deps = ["Preferences"]
-git-tree-sha1 = "03b4c25b43cb84cee5c90aa9b5ea0a78fd848d2f"
+git-tree-sha1 = "5aa36f7049a63a1528fe8f7c3f2113413ffd4e1f"
uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
-version = "1.2.0"
+version = "1.2.1"
[[deps.Preferences]]
deps = ["TOML"]
-git-tree-sha1 = "7eb1686b4f04b82f96ed7a4ea5890a4f0c7a09f1"
+git-tree-sha1 = "9306f6085165d270f7e3db02af26a400d580f5c6"
uuid = "21216c6a-2e73-6563-6e65-726566657250"
-version = "1.4.0"
+version = "1.4.3"
[[deps.Printf]]
deps = ["Unicode"]
@@ -774,14 +783,14 @@ deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[[deps.Tricks]]
-git-tree-sha1 = "aadb748be58b492045b4f56166b5188aa63ce549"
+git-tree-sha1 = "eae1bb484cd63b36999ee58be2de6c178105112f"
uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775"
-version = "0.1.7"
+version = "0.1.8"
[[deps.URIs]]
-git-tree-sha1 = "b7a5e99f24892b6824a954199a45e9ffcc1c70f0"
+git-tree-sha1 = "67db6cc7b3821e19ebe75791a9dd19c9b1188f2b"
uuid = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"
-version = "1.5.0"
+version = "1.5.1"
[[deps.UUIDs]]
deps = ["Random", "SHA"]
@@ -816,6 +825,7 @@ version = "17.4.0+2"
# ╠═72c073fd-5f1b-4af0-901b-aaa901f0f273
# ╠═70dc8fa0-cc32-4ebe-af0d-62b5bb3a82ed
# ╟─acba5003-a456-4c1a-a53f-71a3bec30251
+# ╠═51a36d49-1dad-4340-8671-a6a63eb367a2
# ╟─c4e4400e-e063-4236-96e5-ca3a60313e37
# ╟─e047e1b8-1a41-402b-8ed0-90cccbf0c166
# ╠═7c50f0f4-bc18-4f12-a8b6-5eaba151c923
diff --git a/src/PlutoPlotly.jl b/src/PlutoPlotly.jl
index d615296..c00f379 100644
--- a/src/PlutoPlotly.jl
+++ b/src/PlutoPlotly.jl
@@ -1,7 +1,6 @@
module PlutoPlotly
-using Reexport
-@reexport using PlotlyBase
+using PlotlyBase
using HypertextLiteral
using AbstractPlutoDingetjes
@@ -12,13 +11,28 @@ using Colors
using LaTeXStrings
using Markdown
using Downloads: download
+using Artifacts
+# This is similar to `@reexport` but does not exports undefined names and can
+# also avoid exporting the module name
+function re_export(m::Module; skip_modname = false)
+ mod_name = nameof(m)
+ nms = names(m)
+ exprts = filter(nms) do n
+ isdefined(m, n) && (!skip_modname || n != mod_name)
+ end
+ eval(:(using .$mod_name))
+ eval(:(export $(exprts...)))
+end
+re_export(PlotlyBase; skip_modname = false)
export PlutoPlot, get_plotly_version, change_plotly_version,
-check_plotly_version, force_pluto_mathjax_local, htl_js, add_plotly_listener!,
+force_pluto_mathjax_local, htl_js, add_plotly_listener!,
add_class!, remove_class!, add_js_listener!, default_plotly_template,
get_image_options, change_image_options!, plutoplotly_paste_receiver
export plot, push_script!, prepend_cell_selector
export make_subplots
+export enable_plutoplotly_offline
+
include("local_plotly_library.jl")
diff --git a/src/basics.jl b/src/basics.jl
index 452fe37..9955a57 100644
--- a/src/basics.jl
+++ b/src/basics.jl
@@ -1,4 +1,5 @@
-const PLOTLY_VERSION = Ref("2.26.2")
+const ARTIFACT_VERSION = VersionNumber(read(joinpath(artifact"plotly-esm-min", "VERSION"), String))
+const PLOTLY_VERSION = Ref(ARTIFACT_VERSION)
const DEFAULT_TEMPLATE = Ref(PlotlyBase.templates[PlotlyBase.templates.default])
const JS = HypertextLiteral.JavaScript
@@ -53,31 +54,14 @@ end
## Plotly Version ##
-function change_plotly_version(ver::String)
+function change_plotly_version(v)
+ ver = VersionNumber(v)
maybe_add_plotly_local(ver)
PLOTLY_VERSION[] = ver
end
get_plotly_version() = PLOTLY_VERSION[]
-check_plotly_version() = @htl """
-
-"""
-
## Prepend Cell Selector ##
"""
prepend_cell_selector(selector="")
diff --git a/src/local_plotly_library.jl b/src/local_plotly_library.jl
index ce592a9..147e6ed 100644
--- a/src/local_plotly_library.jl
+++ b/src/local_plotly_library.jl
@@ -1,97 +1,194 @@
const DATA_FOLDER = BaseDirs.User.data("plutoplotly/")
isdir(DATA_FOLDER) || mkpath(DATA_FOLDER)
-const VERSIONS_PATH = joinpath(DATA_FOLDER, "plotly_versions")
-const VERSIONS_DICT = Ref(
- try
- TOML.tryparsefile(VERSIONS_PATH)
- catch
- Dict{String, Any}()
- end
- )
-function pluto_server_folder()
- is_inside_pluto() || return nothing
- ml = methods(Main.PlutoRunner.embed_display)
- m = first(ml)
- plutorunner_path = string(m.file)
- parts = splitpath(plutorunner_path)
- idx = findfirst(x -> x === "Pluto", parts)
- idx !== nothing || error("Could not automatically extract the Pluto root.")
- pluto_root = joinpath(parts[1:idx+1])
-end
-function maybe_put_plotly_in_pluto(v)
- name = get_local_name(v)
- pluto_path = pluto_server_folder()
- pluto_path !== nothing || return false
- maybe_add_plotly_local(v)
- # We check whether the plotly library has been already loaded in this Pluto location, and we copy it otherwise
- for subdir in ("frontend-dist", "frontend")
- dist_path = joinpath(pluto_path, subdir)
- isdir(dist_path) || (subdir === "frontend" ? error("Could not find the `frontend` folder inside pluto root:
-$pluto_path") : continue)
- file_path = joinpath(dist_path, "plotlyjs", "$name.min.js")
- if !isfile(file_path)
- isdir(joinpath(dist_path, "plotlyjs")) || mkpath(joinpath(dist_path, "plotlyjs"))
- cp(get_local_path(v), file_path)
- end
- end
- return true
-end
+get_plotly_esm_url(v) = "https://esm.sh/plotly.js-dist-min@$(VersionNumber(v))"
+get_plotly_cdn_url(v) = "https://cdn.plot.ly/plotly-$(VersionNumber(v)).min.js"
-function update_versions_file()
- write(VERSIONS_PATH, sprint() do io
- TOML.print(io, VERSIONS_DICT[])
- end)
-end
-function get_esm_url(v)
- v = string(v)
- d = VERSIONS_DICT[]
- url = if haskey(d, v)
- d[v]
- else
- line = last(eachline(download("https://esm.sh/plotly.js-dist-min@$(v)")))
- parsed_url = "https://esm.sh$(match(r"\".*\"", line).match[2:end-1])"
- d[v] = parsed_url
- update_versions_file()
- parsed_url
- end
+# We use our custom bundler to download an esm version of the plotly library
+get_plotly_download_url(v) = "https://github.com/disberd/PlotlyArtifactsESM/releases/download/v$(VersionNumber(v))/plotly-esm-min.mjs"
-end
+"""
+mapping a path like "/home/user/.julia/blabla/plotly-1.2.3.min.js" to its contents, read as String
+"""
+const PLOTLY_DEP_CONTENTS = Dict{String, String}()
-get_plotly_cdn_url(v) = "https://cdn.plot.ly/plotly-$(VersionNumber(v)).min.js"
-get_local_pluto_src(v) = let
- try
- maybe_put_plotly_in_pluto(v)
- catch e
- @warn("Encountered the following error while trying to copy the plotly library to the Pluto server's frontend:", e)
+function get_local_plotly_contents(v)
+ maybe_add_plotly_local(v)
+ path = get_local_path(v)
+ get!(PLOTLY_DEP_CONTENTS, path) do
+ read(path, String)
end
- "./plotlyjs/$(get_local_name(v)).min.js"
end
-get_local_path(v) = joinpath(DATA_FOLDER, "$(get_local_name(v)).min.js")
-get_local_name(v) = "plotlyjs-$(VersionNumber(v))"
+get_local_path(v) = if VersionNumber(v) === ARTIFACT_VERSION
+ joinpath(artifact"plotly-esm-min", "plotly-esm-min.mjs")
+else
+ joinpath(DATA_FOLDER, "$(get_local_name(v)).mjs")
+end
+get_local_name(v) = "plotly-esm-min-$(VersionNumber(v))"
function maybe_add_plotly_local(v)
ver = VersionNumber(v)
# Check if the artifact already exists
- path = get_local_path(v)
+ path = get_local_path(ver)
if !isfile(path)
# We download bundle and save locally
@info "Downloading a local version of plotly@$v"
- base_url = get_esm_url(v)
- bundle_url = replace(base_url, r".(\w+)$" => s".bundle.\1")
+ bundle_url = get_plotly_download_url(ver)
download(bundle_url, path)
end
nothing
end
-function get_plotly_src(v, force = "local")
- if lowercase(string(force)) === "esm"
- get_esm_url(v)
- elseif lowercase(string(force)) === "cdn"
- get_plotly_cdn_url(v)
- elseif lowercase(string(force)) === "local"
- get_local_pluto_src(v)
+
+function src_type(type)
+ @assert type in ("hybrid", "esm", "local")
+ type
+end
+
+function get_plotly_import(v, force = "hybrid")
+ force = src_type(force)
+ if force == "hybrid"
+ _ImportedHybridJS(v)
+ elseif force == "esm"
+ _ImportedRemoteJS(get_plotly_esm_url(v))
+ elseif force == "local"
+ import_local_js(get_local_plotly_contents(v))
end
end
-
+
+
+# Identify a remote JS ESM module to be imported when shown in a script. The `extract` argument, if non-empty, will be the name of the property of the remote module to extract
+struct _ImportedRemoteJS
+ src::String
+ extract::String
+end
+_ImportedRemoteJS(src) = _ImportedRemoteJS(src, "")
+
+function Base.show(io, m::MIME"text/javascript", i::_ImportedRemoteJS)
+ write(io,
+ "(await import($(repr(i.src))))"
+ )
+ if !isempty(i.extract)
+ # Extract specific field from the module
+ write(io, ".$(i.extract)")
+ end
+end
+
+
+# Identify a local (on filesystem) JS ESM module to be imported when shown in a script. The `extract` argument, if non-empty, will be the name of the property of the local module to extract
+struct _ImportedLocalJS
+ published
+ extract::String
+ function _ImportedLocalJS(published, extract::AbstractString = "")
+ @nospecialize
+ new(published, extract)
+ end
+end
+
+
+function Base.show(io, m::MIME"text/javascript", i::_ImportedLocalJS)
+ write(io,
+ """
+ (await (() => {
+ window.created_imports = window.created_imports ?? new Map();
+ let code = """
+ )
+ Base.show(io, m, i.published)
+
+ write(io,
+ """;
+ if(created_imports.has(code)){
+ return created_imports.get(code);
+ } else {
+ let blob_promise = new Promise((resolve, reject) => {
+ const reader = new FileReader();
+ reader.onload = async () => {
+ try {
+ resolve(await import(reader.result));
+ } catch(e) {
+ reject();
+ }
+ }
+ reader.onerror = () => reject();
+ reader.onabort = () => reject();
+ reader.readAsDataURL(
+ new Blob([code], {type : "text/javascript"}))
+ });
+ created_imports.set(code, blob_promise);
+ return blob_promise;
+ }
+ })())
+ """
+ )
+ if !isempty(i.extract)
+ # Extract specific field from the module
+ write(io, ".$(i.extract)")
+ end
+ return nothing
+end
+
+function import_local_js(code::AbstractString, extract::AbstractString = "")
+
+ code_js =
+ try
+ AbstractPlutoDingetjes.Display.published_to_js(code)
+ catch e
+ @warn "published_to_js did not work" exception=(e,catch_backtrace()) maxlog=1
+ repr(code)
+ end
+
+ _ImportedLocalJS(code_js, extract)
+end
+
+
+"""
+ enable_plutoplotly_offline(;version = get_plotly_version())
+Creates a script that loads the plotly library on the current browser session so that it is available even when not connected to internet.
+
+Put this in a separate cell so that the plotly JS library is stored in the browser and available for all plots.
+"""
+function enable_plutoplotly_offline(;version = get_plotly_version())
+ _import = import_local_js(get_local_plotly_contents(version), "default")
+ v_str = string(VersionNumber(version))
+ @htl("""
+
+ """)
+end
+
+struct _ImportedHybridJS
+ object::String
+ key::String
+ fallback::_ImportedRemoteJS
+end
+function _ImportedHybridJS(v)
+ object = "plutoplotly_imports"
+ key = string(VersionNumber(v))
+ fallback = _ImportedRemoteJS(get_plotly_esm_url(v), "default")
+ return _ImportedHybridJS(object, key, fallback)
+end
+
+
+function Base.show(io::IO, m::MIME"text/javascript", i::_ImportedHybridJS)
+ write(io, "window.$(i.object)?.['$(i.key)'] ??")
+ show(io, m, i.fallback)
+end
+# function Base.show(io::IO, m::MIME"text/javascript", i::_ImportedHybridJS)
+# write(io, """await (async function() {
+# let Plotly = window.$(i.object)?.['$(i.key)']
+# if (Plotly == undefined) {
+# console.log("Could not find loaded library among offline imports, trying to load from esm.sh")
+# Plotly = """)
+# show(io, m, i.fallback)
+# write(io, """
+# } else {
+# console.log("Loaded plotly from window.plutoplotly_imports")
+# }
+# return Plotly
+# })()""")
+# end
\ No newline at end of file
diff --git a/src/show.jl b/src/show.jl
index f00764b..50c7fec 100644
--- a/src/show.jl
+++ b/src/show.jl
@@ -21,15 +21,7 @@ function _show(pp::PlutoPlot; script_id = "pluto-plotly-div", ver = PLOTLY_VERSI
// Load the plotly library
- let Plotly = undefined
- try {
- let _mod = await import($(get_plotly_src("$ver", "local")))
- Plotly = _mod.default
- } catch (e) {
- console.log("Local load failed, trying with the web esm.sh version")
- let _mod = await import($(get_plotly_src("$ver", "esm")))
- Plotly = _mod.default
- }
+ const Plotly = $(get_plotly_import(ver, "hybrid"))
// Check if we have to force local mathjax font cache
if ($(force_pluto_mathjax_local()) && window?.MathJax?.config?.svg?.fontCache === 'global') {
diff --git a/test/Project.toml b/test/Project.toml
index 6ea334f..22e530c 100644
--- a/test/Project.toml
+++ b/test/Project.toml
@@ -1,4 +1,5 @@
[deps]
+Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Kaleido_jll = "f7e6163d-2fa5-5f23-b69c-1db539e41963"
PlotlyKaleido = "f2990250-8cf9-495f-b13a-cce12b45703c"
@@ -8,4 +9,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
[compat]
-Kaleido_jll = "0.1"
\ No newline at end of file
+Kaleido_jll = "0.1"
diff --git a/test/basic_coverage.jl b/test/basic_coverage.jl
index 7eaf916..aa3c554 100644
--- a/test/basic_coverage.jl
+++ b/test/basic_coverage.jl
@@ -1,6 +1,6 @@
using Test
using PlutoPlotly
-using PlutoPlotly: _preprocess, SKIP_FLOAT32, skip_float32
+using PlutoPlotly: _preprocess, SKIP_FLOAT32, skip_float32, ARTIFACT_VERSION
using PlutoPlotly.PlotlyBase: ColorScheme, Colors, Cycler, templates
@test SKIP_FLOAT32[] == false
@@ -35,4 +35,8 @@ let p = plot(rand(4))
@test_throws "invalid keyword arguments" change_image_options!(p; heights = 400)
end
-@test plutoplotly_paste_receiver() isa PlutoPlotly.HypertextLiteral.Result
\ No newline at end of file
+@test plutoplotly_paste_receiver() isa PlutoPlotly.HypertextLiteral.Result
+
+@test get_plotly_version() === ARTIFACT_VERSION
+@test change_plotly_version("2.30") === VersionNumber("2.30.0")
+@test get_plotly_version() === VersionNumber("2.30.0")
\ No newline at end of file
diff --git a/test/runtests.jl b/test/runtests.jl
index ebc8906..e44df1b 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -1,4 +1,7 @@
using SafeTestsets
+using PlutoPlotly
+using Aqua
+Aqua.test_all(PlutoPlotly)
@safetestset "Coverage Improvements" begin include("basic_coverage.jl") end
@safetestset "Extensions" begin include("extensions.jl") end