@@ -33,15 +33,12 @@ r$run(function() {
33
33
dev.control(displaylist = " enable" )
34
34
},
35
35
viewer = function (url , ... ) {
36
- write_log(" viewer: " , url )
37
36
viewer_file <<- url
38
37
},
39
38
page_viewer = function (url , ... ) {
40
- write_log(" page_viewer: " , url )
41
39
viewer_file <<- url
42
40
},
43
41
browser = function (url , ... ) {
44
- write_log(" browser: " , url )
45
42
browser_url <<- url
46
43
}
47
44
)
@@ -52,7 +49,9 @@ r$run(function() {
52
49
}
53
50
54
51
evaluate <- function (id , uri , expr ) {
55
- tryCatch({
52
+ viewer_file <<- NULL
53
+ browser_url <<- NULL
54
+ res <- tryCatch({
56
55
expr <- parse(text = expr )
57
56
out <- withVisible(eval(expr , globalenv()))
58
57
text <- utils :: capture.output(print(out $ value , view = TRUE ))
@@ -62,33 +61,33 @@ r$run(function() {
62
61
svglite :: svglite(plot_file , width = 12 , height = 8 )
63
62
replayPlot(record )
64
63
graphics.off()
65
- res <- list (
64
+ list (
66
65
type = " plot" ,
67
66
result = plot_file
68
67
)
69
68
} else if (! is.null(viewer_file )) {
70
- res <- list (
69
+ list (
71
70
type = " viewer" ,
72
71
result = viewer_file
73
72
)
74
73
} else if (! is.null(browser_url )) {
75
- res <- list (
74
+ list (
76
75
type = " browser" ,
77
76
result = browser_url
78
77
)
79
78
} else if (out $ visible ) {
80
- res <- list (
79
+ list (
81
80
type = " text" ,
82
81
result = paste0(text , collapse = " \n " )
83
82
)
84
83
} else {
85
- res <- list (
84
+ list (
86
85
type = " text" ,
87
86
result = " "
88
87
)
89
88
}
90
89
}, error = function (e ) {
91
- res <- list (
90
+ list (
92
91
type = " error" ,
93
92
result = conditionMessage(e )
94
93
)
0 commit comments