Skip to content

Commit

Permalink
Use consistent obj / class names
Browse files Browse the repository at this point in the history
  • Loading branch information
schloerke committed Sep 8, 2023
1 parent 038897f commit 7d4d3fd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
12 changes: 6 additions & 6 deletions R/app_json.R
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# This is the same as the FileContentJson type in TypeScript.
FILE_CONTENT_JSON_CLASS <- "file_content_json"
file_content_json <- function(name, content, type = c("text", "binary")) {
FILE_CONTENT_CLASS <- "shinylive_file_content"
file_content_obj <- function(name, content, type = c("text", "binary")) {
structure(
list(
name = name,
content = content,
type = match.arg(type)
),
class = c(FILE_CONTENT_JSON_CLASS, "list")
class = c(FILE_CONTENT_CLASS, "list")
)
}

APP_INFO_CLASS <- "app_info"
APP_INFO_CLASS <- "shinylive_app_info"
app_info_obj <- function(appdir, subdir, files) {
stopifnot(inherits(files, "list"))
lapply(files, function(file) {
stopifnot(inherits(file, FILE_CONTENT_JSON_CLASS))
stopifnot(inherits(file, FILE_CONTENT_CLASS))
})
structure(
list(
Expand Down Expand Up @@ -57,7 +57,7 @@ read_app_files <- function(
# Add an app file entry from anywhere in `read_app_files` to avoid handling data from the bottom up
add_file <- function(name, content, type) {
app_files[[length(app_files) + 1]] <<-
file_content_json(
file_content_obj(
name = name,
content = content,
type = type
Expand Down
28 changes: 14 additions & 14 deletions R/deps.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
HTML_DEP_ITEM_CLASS <- "html_dep_item"
html_dep_item <- function(
HTML_DEP_ITEM_CLASS <- "shinylive_html_dep"
html_dep_obj <- function(
...,
name,
path,
Expand All @@ -18,8 +18,8 @@ html_dep_item <- function(
)
}

HTML_DEP_SERVICEWORKER_ITEM_CLASS <- "html_dep_serviceworker_item"
html_dep_serviceworker_item <- function(
HTML_DEP_SERVICEWORKER_CLASS <- "shinylive_html_dep_serviceworker"
html_dep_serviceworker_obj <- function(
...,
source,
destination) {
Expand All @@ -31,12 +31,12 @@ html_dep_serviceworker_item <- function(
source = source,
destination = destination
),
class = c(HTML_DEP_SERVICEWORKER_ITEM_CLASS, "list")
class = c(HTML_DEP_SERVICEWORKER_CLASS, "list")
)
}

QUARTO_HTML_DEPENDENCY_CLASS <- "quarto_html_dependency"
quarto_html_dependency <- function(
QUARTO_HTML_DEPENDENCY_CLASS <- "shinylive_quarto_html_dependency"
quarto_html_dependency_obj <- function(
...,
name,
version = NULL,
Expand All @@ -53,7 +53,7 @@ quarto_html_dependency <- function(
is.null(resources) || assert_list_items(resources, HTML_DEP_ITEM_CLASS)
is.null(meta) || assert_list(meta)
is.null(serviceworkers) ||
assert_list_items(serviceworkers, HTML_DEP_SERVICEWORKER_ITEM_CLASS)
assert_list_items(serviceworkers, HTML_DEP_SERVICEWORKER_CLASS)

structure(
list(
Expand All @@ -77,19 +77,19 @@ shinylive_base_deps_htmldep <- function(sw_dir = NULL) {
}

serviceworker_dep <- function(sw_dir) {
quarto_html_dependency(
quarto_html_dependency_obj(
name = "shinylive-serviceworker",
version = SHINYLIVE_ASSETS_VERSION,
serviceworkers = list(
html_dep_serviceworker_item(
html_dep_serviceworker_obj(
source = file.path(shinylive_assets_dir(), "shinylive-sw.js"),
destination = "/shinylive-sw.js"
),
html_dep_serviceworker_item(
html_dep_serviceworker_obj(
source = file.path(shinylive_assets_dir(), "shinylive", "webr", "webr-serviceworker.js"),
destination = "/webr-serviceworker.js"
),
html_dep_serviceworker_item(
html_dep_serviceworker_obj(
source = file.path(shinylive_assets_dir(), "shinylive", "webr", "webr-worker.js"),
destination = "/webr-worker.js"
)
Expand Down Expand Up @@ -123,7 +123,7 @@ shinylive_common_dep_htmldep <- function() {
name,
path,
attribs = NULL) {
dep_item <- html_dep_item(name = name, path = path, attribs = attribs)
dep_item <- html_dep_obj(name = name, path = path, attribs = attribs)
switch(match.arg(type),
"script" = {
scripts[[length(scripts) + 1]] <<- dep_item
Expand Down Expand Up @@ -184,7 +184,7 @@ shinylive_common_dep_htmldep <- function() {
scripts[scripts_names == "run-python-blocks.js"]
)

quarto_html_dependency(
quarto_html_dependency_obj(
name = "shinylive",
version = SHINYLIVE_ASSETS_VERSION,
scripts = scripts,
Expand Down

0 comments on commit 7d4d3fd

Please sign in to comment.