1+ # @staticimports pkg:staticimports
2+ # is_installed get_package_version
3+ # register_s3_method register_upgrade_message
4+ # %||%
5+
6+
17# Copied from shiny 0.14.2
28toJSON2 <- function (
39 x , ... , dataframe = " columns" , null = " null" , na = " null" , auto_unbox = TRUE ,
@@ -14,17 +20,6 @@ toJSON2 <- function(
1420 )
1521}
1622
17- if (requireNamespace(' shiny' ) && packageVersion(' shiny' ) > = ' 0.12.0' ) local({
18- tryCatch({
19- toJSON <- getFromNamespace(' toJSON' , ' shiny' )
20- args2 <- formals(toJSON2 )
21- args1 <- formals(toJSON )
22- if (! identical(args1 , args2 )) {
23- warning(' Check shiny:::toJSON and make sure htmlwidgets:::toJSON is in sync' )
24- }
25- })
26- })
27-
2823toJSON <- function (x ) {
2924 if (! is.list(x ) || ! (' x' %in% names(x ))) return (toJSON2(x ))
3025 func <- attr(x $ x , ' TOJSON_FUNC' , exact = TRUE )
@@ -49,10 +44,9 @@ getDependency <- function(name, package = name){
4944 # in this cases dependencies should be provided through the
5045 # dependencies argument of createWidget
5146 widgetDep <- list ()
52- if (file.exists(system.file(config , package = package ))) {
53- config = yaml :: yaml.load_file(
54- system.file(config , package = package )
55- )
47+ yaml_file <- system.file(config , package = package )
48+ if (file.exists(yaml_file )) {
49+ config = yaml :: yaml.load_file(yaml_file )
5650 widgetDep <- lapply(config $ dependencies , function (l ) {
5751 l $ package = package
5852 do.call(htmlDependency , l )
@@ -65,7 +59,7 @@ getDependency <- function(name, package = name){
6559 bindingDep <- if (file.exists(system.file(jsfile , package = package ))) {
6660 htmlDependency(
6761 name = paste0(name , " -binding" ),
68- version = packageVersion (package ),
62+ version = get_package_version (package ),
6963 src = " htmlwidgets" ,
7064 package = package ,
7165 script = basename(jsfile ),
@@ -76,7 +70,7 @@ getDependency <- function(name, package = name){
7670 c(
7771 list (htmlDependency(
7872 name = " htmlwidgets" ,
79- version = packageVersion (" htmlwidgets" ),
73+ version = get_package_version (" htmlwidgets" ),
8074 src = " www" ,
8175 package = " htmlwidgets" ,
8276 script = " htmlwidgets.js"
@@ -86,9 +80,6 @@ getDependency <- function(name, package = name){
8680 )
8781}
8882
89- `%||%` <- function (x , y ){
90- if (is.null(x )) y else x
91- }
9283
9384prop <- function (x , path ) {
9485 tryCatch({
0 commit comments