From 47cc36724138c9ff630267db568cc6ca3dac40e1 Mon Sep 17 00:00:00 2001 From: Garrick Aden-Buie Date: Thu, 30 May 2024 15:50:20 -0400 Subject: [PATCH] feat: enable client-side dev mode features in R --- src/Components/Viewer.tsx | 4 ++-- src/hooks/useWebR.tsx | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Components/Viewer.tsx b/src/Components/Viewer.tsx index 6eb7b629..1d4444b1 100644 --- a/src/Components/Viewer.tsx +++ b/src/Components/Viewer.tsx @@ -187,8 +187,8 @@ export function Viewer({ env: { files, appDir }, captureStreams: false, }); - await webRProxy.runRAsync(".start_app(appName, appDir)", { - env: { appName, appDir }, + await webRProxy.runRAsync(".start_app(appName, appDir, devMode)", { + env: { appName, appDir, devMode }, captureConditions: false, captureStreams: false, }); diff --git a/src/hooks/useWebR.tsx b/src/hooks/useWebR.tsx index 77a136c4..3fa98328 100644 --- a/src/hooks/useWebR.tsx +++ b/src/hooks/useWebR.tsx @@ -295,7 +295,7 @@ webr::shim_install() lapply(rownames(installed.packages()), function(p) { .webr_pkg_cache[[p]] <<- TRUE }) } -.start_app <- function(appName, appDir) { +.start_app <- function(appName, appDir, devMode = FALSE) { # Mount VFS images provided in Shinylive app assets .mount_vfs_images() @@ -312,6 +312,11 @@ webr::shim_install() } }) + if (isTRUE(devMode)) { + # Enable client-side dev mode features, namely the error console + options(shiny.client_devmode = TRUE) + } + app <- .shiny_to_httpuv(appDir) assign(appName, app, envir = .shiny_app_registry) invisible(0)