Skip to content

Commit 61dbd73

Browse files
Merge pull request #13 from vue-r/dev
add vue3
2 parents c8dec5a + 36dc8f1 commit 61dbd73

39 files changed

+28366
-12763
lines changed

.github/workflows/R-CMD-check.yaml

+10-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
22
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
33
on:
44
push:
@@ -18,7 +18,7 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
config:
21-
- {os: macOS-latest, r: 'release'}
21+
- {os: macos-latest, r: 'release'}
2222
- {os: windows-latest, r: 'release'}
2323
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
2424
- {os: ubuntu-latest, r: 'release'}
@@ -29,30 +29,21 @@ jobs:
2929
R_KEEP_PKG_SOURCE: yes
3030

3131
steps:
32-
- uses: actions/checkout@v2
32+
- uses: actions/checkout@v3
3333

34-
- uses: r-lib/actions/setup-pandoc@v1
34+
- uses: r-lib/actions/setup-pandoc@v2
3535

36-
- uses: r-lib/actions/setup-r@v1
36+
- uses: r-lib/actions/setup-r@v2
3737
with:
3838
r-version: ${{ matrix.config.r }}
3939
http-user-agent: ${{ matrix.config.http-user-agent }}
4040
use-public-rspm: true
4141

42-
- uses: r-lib/actions/setup-r-dependencies@v1
42+
- uses: r-lib/actions/setup-r-dependencies@v2
4343
with:
44-
extra-packages: rcmdcheck
44+
extra-packages: any::rcmdcheck
45+
needs: check
4546

46-
- uses: r-lib/actions/check-r-package@v1
47-
48-
- name: Show testthat output
49-
if: always()
50-
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
51-
shell: bash
52-
53-
- name: Upload check results
54-
if: failure()
55-
uses: actions/upload-artifact@main
47+
- uses: r-lib/actions/check-r-package@v2
5648
with:
57-
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
58-
path: check
49+
upload-snapshots: true

CRAN-RELEASE

-2
This file was deleted.

DESCRIPTION

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: vueR
22
Type: Package
33
Title: 'Vuejs' Helpers and 'Htmlwidget'
4-
Version: 0.5.3
5-
Date: 2021-11-25
4+
Version: 0.6.0
5+
Date: 2023-10-01
66
Authors@R: c(
77
person(
88
"Evan","You"
@@ -31,5 +31,5 @@ Suggests:
3131
rmarkdown,
3232
shiny,
3333
testthat
34-
RoxygenNote: 7.1.2
34+
RoxygenNote: 7.2.3
3535
VignetteBuilder: knitr

NAMESPACE

+4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Generated by roxygen2: do not edit by hand
22

33
export(html_dependency_vue)
4+
export(html_dependency_vue3)
45
export(renderVue)
6+
export(renderVue3)
57
export(vue)
8+
export(vue3)
9+
export(vue3Output)
610
export(vueOutput)
711
import(htmlwidgets)
812
importFrom(htmltools,htmlDependency)

NEWS.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# vueR 0.6.0
2+
3+
* add `vue3` set of functions with vue3 @ `3.3.4`; see [issue 10](https://github.com/vue-r/vueR/issues/10)
4+
* update vue2 to 2.7.14
5+
16
# vueR 0.5.3
27

38
* update vue to 2.6.14

R/dependencies.R

+62
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#'
88
#' @return \code{\link[htmltools]{htmlDependency}}
99
#' @importFrom htmltools htmlDependency
10+
#' @family dependencies
1011
#' @export
1112
#'
1213
#' @examples
@@ -53,3 +54,64 @@ html_dependency_vue <- function(offline=TRUE, minified=TRUE){
5354

5455
hd
5556
}
57+
58+
59+
#' Dependencies for 'Vue3'
60+
#'
61+
#' @param offline \code{logical} to use local file dependencies. If \code{FALSE},
62+
#' then the dependencies use cdn as its \code{src}.
63+
#' @param minified \code{logical} to use minified (production) version. Use
64+
#' \code{minified = FALSE} for debugging or working with Vue devtools.
65+
#'
66+
#' @return \code{\link[htmltools]{htmlDependency}}
67+
#' @importFrom htmltools htmlDependency
68+
#' @family dependencies
69+
#' @export
70+
#'
71+
#' @examples
72+
#' if(interactive()){
73+
#'
74+
#' library(vueR)
75+
#' library(htmltools)
76+
#'
77+
#' browsable(
78+
#' tagList(
79+
#' tags$div(id="app","{{message}}"),
80+
#' tags$script(
81+
#' "
82+
#' var app = {
83+
#' data: function() {
84+
#' return {
85+
#' message: 'Hello Vue!'
86+
#' }
87+
#' }
88+
#' };
89+
#'
90+
#' Vue.createApp(app).mount('#app');
91+
#' "
92+
#' ),
93+
#' html_dependency_vue3()
94+
#' )
95+
#' )
96+
#' }
97+
html_dependency_vue3 <- function(offline=TRUE, minified=TRUE){
98+
hd <- htmltools::htmlDependency(
99+
name = "vue",
100+
version = vue3_version(),
101+
src = system.file("www/vue3/dist",package="vueR"),
102+
script = "vue.global.prod.js"
103+
)
104+
105+
if(!minified) {
106+
hd$script <- "vue.global.js"
107+
}
108+
109+
if(!offline) {
110+
hd$src <- list(href=sprintf(
111+
"https://unpkg.com/vue@%s/dist/",
112+
vue3_version()
113+
))
114+
}
115+
116+
hd
117+
}

R/meta.R

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
#'@keywords internal
2-
vue_version <- function(){'2.6.14'}
2+
vue_version <- function(){'2.7.14'}
3+
#'@keywords internal
4+
vue3_version <- function(){'3.3.4'}

R/vue.R

+81
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#'
1616
#' @import htmlwidgets
1717
#'
18+
#' @family htmlwidget
1819
#' @export
1920
#' @example ./inst/examples/vue_widget_examples.R
2021
#' @return vue htmlwidget
@@ -45,6 +46,56 @@ vue <- function(
4546
hw
4647
}
4748

49+
#' 'Vue.js 3' 'htmlwidget'
50+
#'
51+
#' Use 'Vue.js 3' with the convenience and flexibility of 'htmlwidgets'.
52+
#' \code{vue3} is a little different from other 'htmlwidgets' though
53+
#' since it requires specification of the HTML tags/elements separately.
54+
#'
55+
#' @param app \code{list} with \code{el} and \code{data} and other pieces
56+
#' of a 'Vue.js 3' app
57+
#' @param width,height any valid \code{CSS} size unit, but in reality
58+
#' this will not currently have any impact
59+
#' @param elementId \code{character} id of the htmlwidget container
60+
#' element
61+
#' @param minified \code{logical} to indicate minified (\code{minified=TRUE}) or
62+
#' non-minified (\code{minified=FALSE}) Vue.js
63+
#'
64+
#' @import htmlwidgets
65+
#'
66+
#' @family htmlwidget
67+
#' @export
68+
#' @example ./inst/examples/vue3_widget_examples.R
69+
#' @return vue htmlwidget
70+
71+
vue3 <- function(
72+
app = list(),
73+
width = NULL, height = NULL, elementId = NULL,
74+
minified = TRUE
75+
) {
76+
77+
# forward options using x
78+
x = app
79+
80+
# will try to convert data that is not a function in widget JS
81+
82+
# create widget
83+
hw <- htmlwidgets::createWidget(
84+
name = 'vue3',
85+
x,
86+
width = width,
87+
height = height,
88+
package = 'vueR',
89+
elementId = elementId
90+
)
91+
92+
hw$dependencies <- list(
93+
html_dependency_vue3(offline=TRUE, minified=minified)
94+
)
95+
96+
hw
97+
}
98+
4899
#' Shiny bindings for vue
49100
#'
50101
#' Output and render functions for using vue within Shiny
@@ -62,6 +113,7 @@ vue <- function(
62113
#' @name vue-shiny
63114
#'
64115
#' @export
116+
#' @example ./inst/examples/vue3_shiny_examples.R
65117
vueOutput <- function(outputId, width = '100%', height = '400px'){
66118
htmlwidgets::shinyWidgetOutput(outputId, 'vue', width, height, package = 'vueR')
67119
}
@@ -72,3 +124,32 @@ renderVue <- function(expr, env = parent.frame(), quoted = FALSE) {
72124
if (!quoted) { expr <- substitute(expr) } # force quoted
73125
htmlwidgets::shinyRenderWidget(expr, vueOutput, env, quoted = TRUE)
74126
}
127+
128+
129+
#' Shiny bindings for 'vue 3'
130+
#'
131+
#' Output and render functions for using 'vue 3' within Shiny
132+
#' applications and interactive Rmd documents.
133+
#'
134+
#' @param outputId output variable to read from
135+
#' @param width,height Must be a valid CSS unit (like \code{'100\%'},
136+
#' \code{'400px'}, \code{'auto'}) or a number, which will be coerced to a
137+
#' string and have \code{'px'} appended.
138+
#' @param expr An expression that generates a vue
139+
#' @param env The environment in which to evaluate \code{expr}.
140+
#' @param quoted Is \code{expr} a quoted expression (with \code{quote()})? This
141+
#' is useful if you want to save an expression in a variable.
142+
#'
143+
#' @name vue-shiny
144+
#'
145+
#' @export
146+
vue3Output <- function(outputId, width = '100%', height = '400px'){
147+
htmlwidgets::shinyWidgetOutput(outputId, 'vue3', width, height, package = 'vueR')
148+
}
149+
150+
#' @rdname vue-shiny
151+
#' @export
152+
renderVue3 <- function(expr, env = parent.frame(), quoted = FALSE) {
153+
if (!quoted) { expr <- substitute(expr) } # force quoted
154+
htmlwidgets::shinyRenderWidget(expr, vueOutput, env, quoted = TRUE)
155+
}

README.Rmd

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ knitr::opts_chunk$set(
1515
<!-- badges: start -->
1616
[![R-CMD-check](https://github.com/vue-r/vueR/workflows/R-CMD-check/badge.svg)](https://github.com/vue-r/vueR/actions)
1717
[![CRAN status](https://www.r-pkg.org/badges/version/vueR)](https://CRAN.R-project.org/package=vueR)
18+
[![R-CMD-check](https://github.com/vue-r/vueR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/vue-r/vueR/actions/workflows/R-CMD-check.yaml)
1819
<!-- badges: end -->
1920

2021
[Vue.js](https://vuejs.org) is a quiet, very popular JavaScript framework with an impressive set of features, a solid community, and MIT license. Don't tell anybody, but I think I might even like it better than React. With all this, Vue deserves its own set of helpers for `R`, just like [`d3r`](https://github.com/timelyportfolio/d3r) and [`reactR`](https://github.com/react-r/reactR).

build/getvue.R

+29-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,16 @@ get_vue_latest <- function(){
99
)
1010
}
1111

12+
get_vue3_latest <- function(){
13+
gsub(
14+
x=github::get.latest.release("vuejs", "core")$content$tag_name,
15+
pattern="v",
16+
replacement=""
17+
)
18+
}
1219

13-
# get newest vue
20+
21+
# get newest vue2
1422
download.file(
1523
url=sprintf(
1624
"https://unpkg.com/vue@%s/dist/vue.min.js",
@@ -27,12 +35,30 @@ download.file(
2735
destfile="./inst/www/vue/dist/vue.js"
2836
)
2937

38+
# get newest vue3
39+
download.file(
40+
url=sprintf(
41+
"https://unpkg.com/vue@%s/dist/vue.global.prod.js",
42+
get_vue3_latest()
43+
),
44+
destfile="./inst/www/vue3/dist/vue.global.prod.js"
45+
)
46+
47+
download.file(
48+
url=sprintf(
49+
"https://unpkg.com/vue@%s/dist/vue.global.js",
50+
get_vue3_latest()
51+
),
52+
destfile="./inst/www/vue3/dist/vue.global.js"
53+
)
54+
3055
# write function with newest version
3156
# for use when creating dependencies
3257
cat(
3358
sprintf(
34-
"#'@keywords internal\nvue_version <- function(){'%s'}\n",
35-
get_vue_latest()
59+
"#'@keywords internal\nvue_version <- function(){'%s'}\n#'@keywords internal\nvue3_version <- function(){'%s'}\n",
60+
get_vue_latest(),
61+
get_vue3_latest()
3662
),
3763
file = "./R/meta.R"
3864
)

cran-comments.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Comments
22

3-
Second submission resolving license issue...
3+
Second submission resolving license issue by using CRAN template.
44

55
```
66
Thanks, we see:

0 commit comments

Comments
 (0)