-
Notifications
You must be signed in to change notification settings - Fork 631
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patch plotly.js source to support phantomjs/shinytest
reverts part of plotly/plotly.js#5380
- Loading branch information
Showing
12 changed files
with
139 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+25.3 KB
(190%)
inst/examples/shiny/event_data/tests/shinytest/mytest-expected/001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+27 KB
(200%)
inst/examples/shiny/event_data/tests/shinytest/mytest-expected/002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+28.9 KB
(190%)
inst/examples/shiny/event_data/tests/shinytest/mytest-expected/003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+26.1 KB
(200%)
inst/examples/shiny/event_data/tests/shinytest/mytest-expected/004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
diff --git a/src/lib/array.js b/src/lib/array.js | ||
index 19463675a..470d3d6bf 100644 | ||
--- a/src/lib/array.js | ||
+++ b/src/lib/array.js | ||
@@ -2,8 +2,15 @@ | ||
|
||
var isArray = Array.isArray; | ||
|
||
-var ab = ArrayBuffer; | ||
-var dv = DataView; | ||
+// IE9 fallbacks | ||
+ | ||
+var ab = (typeof ArrayBuffer === 'undefined' || !ArrayBuffer.isView) ? | ||
+ {isView: function() { return false; }} : | ||
+ ArrayBuffer; | ||
+ | ||
+var dv = (typeof DataView === 'undefined') ? | ||
+ function() {} : | ||
+ DataView; | ||
|
||
function isTypedArray(a) { | ||
return ab.isView(a) && !(a instanceof dv); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
library(httr) | ||
library(rprojroot) | ||
|
||
# get zip URL to latest plotly.js release | ||
x <- RETRY( | ||
verb = "GET", | ||
url = 'https://api.github.com/repos/plotly/plotly.js/releases/latest', | ||
times = 5, | ||
terminate_on = c(400, 401, 403, 404), | ||
terminate_on_success = TRUE | ||
) | ||
zip <- content(x)$zipball_url | ||
|
||
# remember where to copy over assets | ||
pkg_dir <- find_package_root_file() | ||
lib_dir <- find_package_root_file("inst/htmlwidgets/lib/plotlyjs") | ||
patches <- list.files( | ||
find_package_root_file("tools/patches"), | ||
full.names = TRUE | ||
) | ||
|
||
# download, patch, and build plotly.js in temp dir | ||
tmpdir <- tempfile() | ||
dir.create(tmpdir) | ||
|
||
withr::with_dir(tmpdir, { | ||
# download source | ||
download.file(zip, "plotly-js.zip") | ||
unzip("plotly-js.zip", exdir = "plotly-js") | ||
|
||
withr::with_dir( | ||
dir("plotly-js", full.names = TRUE), { | ||
|
||
# apply patches | ||
for (patch in patches) { | ||
tryCatch({ | ||
message(sprintf("Applying %s", basename(patch))) | ||
system(sprintf("git apply %s", patch)) | ||
}, | ||
error = function(e) quit(save = "no", status = 1) | ||
) | ||
} | ||
|
||
# build | ||
system("yarn install") | ||
system("yarn build") | ||
|
||
# copy assets to R package source | ||
file.copy( | ||
"dist/plotly.min.js", | ||
file.path(lib_dir, "plotly-latest.min.js"), | ||
overwrite = TRUE | ||
) | ||
file.copy( | ||
"LICENSE", | ||
file.path(lib_dir, "LICENSE"), | ||
overwrite = TRUE | ||
) | ||
|
||
locales <- Sys.glob("dist/plotly-locale-*.js") | ||
file.copy( | ||
locales, | ||
file.path(lib_dir, "locales", sub("^plotly-locale-", "", basename(locales))), | ||
overwrite = TRUE | ||
) | ||
# update plot schema | ||
Schema <- jsonlite::fromJSON(Sys.glob("dist/plot-schema.json")) | ||
withr::with_dir( | ||
pkg_dir, usethis::use_data(Schema, overwrite = TRUE, internal = TRUE) | ||
) | ||
|
||
# plotly.js used to bundle a typedarray polyfill to support older browsers, | ||
# but v2 drops support for them, so it no longer includes this polyfill | ||
# Hopefully, we can continue to get away with using the pre-v2 polyfill | ||
# to support shinytest/phantomjs | ||
#download.file( | ||
# "dist/extras/typedarray.min.js", | ||
# "inst/htmlwidgets/lib/typedarray/typedarray.min.js" | ||
#) | ||
|
||
message("Update plotlyMainBundle()'s version with ", basename(zip)) | ||
|
||
}) | ||
|
||
}) |