|
71 | 71 | #' provide [input] (and/or [state]) object(s) (which should reference |
72 | 72 | #' layout components) as argument value(s) to `func`. |
73 | 73 | #' } |
74 | | -#' \item{`dependencies_set(dependencies = NULL, add = TRUE)`}{ |
75 | | -#' Adds additional HTML dependencies to your dash application (beyond the 'internal' dependencies). |
76 | | -#' The `dependencies` argument accepts [htmltools::htmlDependency] or |
77 | | -#' [htmltools::htmlDependencies]. The `section` argument determines whether |
78 | | -#' your dependencies are placed inside `<head>` or `<footer>`. |
79 | | -#' } |
80 | | -#' \item{`dependencies_get(all = FALSE)`}{ |
81 | | -#' Retrieve (just user-defined or all) HTML dependencies. |
82 | | -#' } |
83 | 74 | #' \item{`run_server(host = NULL, port = NULL, block = TRUE, showcase = FALSE, ...)`}{ |
84 | 75 | #' Launch the application. If provided, `host`/`port` set |
85 | 76 | #' the `host`/`port` fields of the underlying [fiery::Fire] web |
@@ -346,37 +337,6 @@ Dash <- R6::R6Class( |
346 | 337 | invisible(private$layout_render()) |
347 | 338 | }, |
348 | 339 |
|
349 | | - # ------------------------------------------------------------------------ |
350 | | - # HTML dependency management |
351 | | - # ------------------------------------------------------------------------ |
352 | | - dependencies_get = function() { |
353 | | - c(private$dependencies_user, private$dependencies) |
354 | | - }, |
355 | | - dependencies_get_internal = function() { |
356 | | - private$dependencies_internal |
357 | | - }, |
358 | | - dependencies_set = function(dependencies = list(), add = TRUE) { |
359 | | - |
360 | | - if (!length(dependencies)) return() |
361 | | - |
362 | | - # do a sensible thing if just a single dependency is provided |
363 | | - if (inherits(dependencies, "html_dependency")) { |
364 | | - dependencies <- list(dependencies) |
365 | | - } |
366 | | - |
367 | | - # ensure we have a list of htmltools::htmlDependency |
368 | | - is_dep <- vapply(dependencies, inherits, logical(1), "html_dependency") |
369 | | - if (any(!is_dep)) { |
370 | | - stop("`dependencies` must be a *list* of htmltools::htmlDependency objects", call. = FALSE) |
371 | | - } |
372 | | - |
373 | | - if (add) { |
374 | | - dependencies <- c(private$dependencies_user, dependencies) |
375 | | - } |
376 | | - |
377 | | - private$dependencies_user <- dependencies |
378 | | - }, |
379 | | - |
380 | 340 | react_version_set = function(version) { |
381 | 341 | versions <- private$react_versions() |
382 | 342 | idx <- versions %in% version |
@@ -550,6 +510,38 @@ Dash <- R6::R6Class( |
550 | 510 | # akin to https://github.com/plotly/dash/blob/d2ebc837/dash/dash.py#L338 |
551 | 511 | # note discussion here https://github.com/plotly/dash/blob/d2ebc837/dash/dash.py#L279-L284 |
552 | 512 | .index = NULL, |
| 513 | + |
| 514 | + # ------------------------------------------------------------------------ |
| 515 | + # HTML dependency management |
| 516 | + # ------------------------------------------------------------------------ |
| 517 | + dependencies_get = function() { |
| 518 | + c(private$dependencies_user, private$dependencies) |
| 519 | + }, |
| 520 | + dependencies_get_internal = function() { |
| 521 | + private$dependencies_internal |
| 522 | + }, |
| 523 | + dependencies_set = function(dependencies = list(), add = TRUE) { |
| 524 | + |
| 525 | + if (!length(dependencies)) return() |
| 526 | + |
| 527 | + # do a sensible thing if just a single dependency is provided |
| 528 | + if (inherits(dependencies, "html_dependency")) { |
| 529 | + dependencies <- list(dependencies) |
| 530 | + } |
| 531 | + |
| 532 | + # ensure we have a list of htmltools::htmlDependency |
| 533 | + is_dep <- vapply(dependencies, inherits, logical(1), "html_dependency") |
| 534 | + if (any(!is_dep)) { |
| 535 | + stop("`dependencies` must be a *list* of htmltools::htmlDependency objects", call. = FALSE) |
| 536 | + } |
| 537 | + |
| 538 | + if (add) { |
| 539 | + dependencies <- c(private$dependencies_user, dependencies) |
| 540 | + } |
| 541 | + |
| 542 | + private$dependencies_user <- dependencies |
| 543 | + }, |
| 544 | + |
553 | 545 | index = function() { |
554 | 546 | # collect and resolve dependencies |
555 | 547 | depsAll <- compact(c( |
|
0 commit comments