You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
data<-jsonlite::fromJSON("data.json") # Pre-bundled data
100
+
```
69
101
70
102
### Step 2: Conversion Process
71
103
72
-
The conversion to Shinylive is automated by the
104
+
The conversion to Shinylive is automated by either the [{py-shinylive}][pyshinylive] or
105
+
[{r-shinylive}][rshinylive] packages.
106
+
107
+
Specifically, we can convert a shiny application found in `myapp/` directory to
108
+
a shinylive application via either:
109
+
110
+
For R Shiny application, please type in the **R console**:
111
+
112
+
```r
113
+
# install.packages("shinylive")
114
+
shinylive::export("myapp", "_site")
115
+
```
116
+
117
+
For Python Shiny application, please type in the **Terminal**:
118
+
119
+
```sh
120
+
# pip install shinylive
121
+
shinylive export myapp _site
122
+
```
123
+
124
+
Behind the scenes, the `export` command is performing the following steps:
73
125
74
126
1.**File Bundling**: All application files are collected and bundled together:
75
127
- R/Python source code
76
128
- Data files
77
129
- Static assets (images, CSS, etc.)
78
130
79
-
2.**Metadata Generation**: A `app.json` file is created containing:
131
+
2.**Metadata Generation**: A `app.json` file is created containing the source:
80
132
```json
81
133
[
82
134
{
@@ -85,63 +137,86 @@ The conversion to Shinylive is automated by the
85
137
"type": "text"
86
138
},
87
139
{
88
-
"name": "data.csv",
140
+
"name": "data/dataset.csv",
89
141
"content": "col1,col2\n...",
90
142
"type": "text"
143
+
},
144
+
{
145
+
"name": "www/image.png",
146
+
"content": "iVBORw0KGgo...",
147
+
"type": "binary"
148
+
},
149
+
{
150
+
"name": "www/custom.css",
151
+
"content": ".custom-class { ... }",
152
+
"type": "text"
91
153
}
92
154
]
93
155
```
94
156
95
-
3.**Runtime Preparation**:
157
+
3.**Runtime Preparation**: The converted application is integrated into a
158
+
viewer and/or editor alongside of the underlying language distribution.
96
159
- For R: WebR environment is configured
97
160
- For Python: Pyodide environment is set up
98
161
99
162
### Step 3: Browser Deployment
100
163
101
-
The converted application now runs entirely in the browser:
164
+
From here, the Shinylive application can be run locally through a Live Server
165
+
or it can be placed on any static web server host that supports HTTPS URLs.
166
+
Some common web server hosts for this kind of application are GitHub Pages or Netlify.
167
+
168
+
Feel free to consult the following GitHub Pages Deployment tutorials:
169
+
170
+
1.[Creating an R Shinylive App inside a Quarto Document](https://github.com/coatless-quarto/r-shinylive-demo)
171
+
2.[Deploying an **R** Shinylive App via GitHub Pages through GitHub Actions](https://github.com/coatless-tutorials/convert-shiny-app-r-shinylive)
172
+
3.[Deploying a **Python** Shinylive App via GitHub Pages through GitHub Actions](https://github.com/coatless-tutorials/convert-py-shiny-app-to-py-shinylive-app)
173
+
174
+
With this being said, the converted application is now running entirely in the browser!
175
+
Specifically, we have:
102
176
103
177
1. WebR/Pyodide runtime initializes
104
178
2. Application files are loaded from `app.json`
105
179
3. UI renders and connects to a local runtime
106
-
4. All computation happens client-side
180
+
4. All computation in app happens client-side in their web browser
107
181
108
182
## Source Code Transparency
109
183
110
-
Unlike traditional Shiny applications, Shinylive apps are inherently transparent. This transparency is a fundamental characteristic due to several factors:
184
+
Unlike traditional Shiny applications, Shinylive apps are inherently transparent.
185
+
This transparency is a fundamental characteristic due to several factors:
111
186
112
187
1.**Client-Side Execution**: All code must be available in the browser
113
188
2.**Bundled Resources**: All files are packaged in accessible formats
114
189
3.**No Server Privacy**: No server-side code protection exists
115
190
191
+
116
192
## Extracting Source Code with `peeky`
117
193
118
194
The `peeky` package leverages this transparency to extract source code from
119
-
Shinylive applications. Here's how it works:
120
-
121
-
### Detection
122
-
123
-
TODO: Clarify
124
-
125
-
```r
126
-
# URL of the Shinylive application
127
-
url<-""
128
-
129
-
# Auto-detect and handle both standalone and Quarto-embedded apps
130
-
peeky::peek_shinylive_app(url)
131
-
```
132
-
133
-
### Content Retrieval
134
-
135
-
TODO: Clarify
195
+
Shinylive applications through the following functions:
136
196
137
-
1. Downloads the webpage or app.json
138
-
2. Identifies Shinylive components
139
-
3. Extracts embedded code and resources
197
+
-`peeky::peek_shinylive_app()`: Automatically retrieve either a standalone or
198
+
Quarto embedded Shinylive application.
199
+
-`peeky::peek_standalone_shinylive_app()`: Retrieve a standalone Shinylive
0 commit comments