@@ -368,7 +368,7 @@ Dash <- R6::R6Class(
368
368
version , paste(unique(versions ), collapse = " ', '" )
369
369
), call. = FALSE )
370
370
}
371
- private $ react_version <- version
371
+ private $ react_version_enabled <- version
372
372
},
373
373
374
374
# ------------------------------------------------------------------------
@@ -450,7 +450,8 @@ Dash <- R6::R6Class(
450
450
# fields for tracking HTML dependencies
451
451
dependencies = list (),
452
452
dependencies_user = list (),
453
-
453
+ dependencies_internal = list (),
454
+
454
455
# layout stuff
455
456
layout = welcome_page(),
456
457
layout_ids = NULL ,
@@ -494,7 +495,7 @@ Dash <- R6::R6Class(
494
495
495
496
# load package-level HTML dependencies
496
497
pkgs <- unique(layout_flat [grepl(" package$" , layout_nms )])
497
- dashR_deps <- lapply(pkgs , function (pkg ) {
498
+ deps_layout <- lapply(pkgs , function (pkg ) {
498
499
# the objective is to identify JS dependencies
499
500
# without requiring that a proprietary R format
500
501
# file is loaded at object initialization to
@@ -527,7 +528,7 @@ Dash <- R6::R6Class(
527
528
}
528
529
})
529
530
530
- dashR_deps <- unlist(dashR_deps , recursive = FALSE )
531
+ deps_layout <- unlist(deps_layout , recursive = FALSE )
531
532
532
533
# if core components are used, but no coreGraph() exists,
533
534
# don't include the plotly.js bundle
@@ -536,13 +537,16 @@ Dash <- R6::R6Class(
536
537
hasGraph <- component_contains_type(layout , " dashCoreComponents" , " Graph" )
537
538
if (hasCore && ! hasGraph ) {
538
539
idx <- which(pkgs %in% " dashCoreComponents" )
539
- scripts <- dashR_deps [[idx ]][[" script" ]]
540
- dashR_deps [[idx ]][[" script" ]] <- scripts [! grepl(" ^plotly-*" , scripts )]
540
+ scripts <- deps_layout [[idx ]][[" script" ]]
541
+ deps_layout [[idx ]][[" script" ]] <- scripts [! grepl(" ^plotly-*" , scripts )]
541
542
}
542
543
}
543
544
544
545
# add on HTML dependencies we've identified by crawling the layout
545
- private $ dependencies <- c(private $ dependencies , dashR_deps )
546
+ private $ dependencies <- c(private $ dependencies , deps_layout )
547
+
548
+ # DashR's own dependencies
549
+ private $ dependencies_internal <- dashR ::: .dashR_js_metadata()
546
550
547
551
# return the computed layout
548
552
oldClass(layout ) <- c(" dash_layout" , oldClass(layout ))
@@ -586,18 +590,24 @@ Dash <- R6::R6Class(
586
590
},
587
591
588
592
# akin to https://github.com/plotly/dash-renderer/blob/master/dash_renderer/__init__.py
589
- react_version = " 15.4.2" ,
590
- react_deps = function () deps [grepl(" ^react" , names(deps ))],
591
- react_versions = function () vapply(private $ react_deps(), " [[" , character (1 ), " version" ),
592
-
593
+ react_version_enabled = function () {
594
+ version <- private $ dependencies_internal $ react $ version
595
+ },
596
+ react_deps = function () {
597
+ deps <- private $ dependencies_internal
598
+ deps [grepl(" ^react" , names(deps ))]
599
+ },
600
+ react_versions = function () {
601
+ vapply(private $ react_deps(), " [[" , character (1 ), " version" )
602
+ },
603
+
593
604
# akin to https://github.com/plotly/dash/blob/d2ebc837/dash/dash.py#L338
594
605
# note discussion here https://github.com/plotly/dash/blob/d2ebc837/dash/dash.py#L279-L284
595
606
.index = NULL ,
596
607
index = function () {
597
-
598
608
# collect and resolve dependencies
599
609
depsAll <- compact(c(
600
- private $ react_deps()[private $ react_versions() %in% private $ react_version ],
610
+ private $ react_deps()[private $ react_versions() %in% private $ react_version_enabled() ],
601
611
private $ dependencies ,
602
612
private $ dependencies_user ,
603
613
deps [" dash-renderer" ]
0 commit comments