Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Q&A]: Will quarto html parameter 'embed-resources' include js-files needed to run webR-extension chunks when using channel type "automatic"? #62

Closed
mskyttner opened this issue Oct 2, 2023 · 5 comments
Labels
s: question-answered Question has been answered. t: discussion Question & Answer

Comments

@mskyttner
Copy link

What's your question?

I read here about 'embed-resources' not always being able to include .js-files. Often my goal is to have a standalone .html rendered from quarto, that can be sent as one file to recipients or web servers / buckets. To understand whether the extension works seemlessly with the 'embed-resources' flag is my goal / reason for asking the question.

I also wonder if there is a way to have regular chunks write data that webR chunks can read over http(s) ie pastebin style data access... what would be a good pattern/strategy without installing too many webR packages?

@mskyttner mskyttner added the t: discussion Question & Answer label Oct 2, 2023
@mskyttner mskyttner changed the title [Q&A]: Will 'embed-resources' include js-files when using channel type "automatic"? [Q&A]: Will quarto html parameter 'embed-resources' include js-files needed to run webR-extension chunks when using channel type "automatic"? Oct 2, 2023
@coatless
Copy link
Owner

coatless commented Oct 3, 2023

@mskyttner

Regarding the first question, I do not believe that we'll see the embed-resources option work for the quarto-webr as I'm not sure we can embed the WASM files. If the 'service-worker' communication channel is being used, no matter what we'll need to have at least two external files present.

For the second question, could you clarify a bit more what you mean? Is it reflecting persistent storage of input values or?

@coatless coatless added the s: question-answered Question has been answered. label Oct 3, 2023
@mskyttner
Copy link
Author

mskyttner commented Oct 3, 2023

Here is some clarification for the second question: if a "build time" chunk embeds a blob of data in the HTML document using data URIs, could a "run time" webr-r chunk read this data?

Here is an illustration (.qmd and .html in a zip) and more attempts at clarification.

webr_read_embedded.zip

The .qmd in a gist: https://gist.github.com/mskyttner/2b5f01180a91f1cfd3117ed19497c332

Screenshot:

image

@coatless
Copy link
Owner

coatless commented Oct 3, 2023

For the equation render issue, this is because the document YAML uses the embed-resources: true key. This has nothing to do with quarto-webr.

Regarding including embedded document data, the webr-r code cell only handles R code. You would have to write some custom JS inside of a raw HTML code cell to load the exported document data into webR's virtual file system (VFS) system, e.g. webR.FS.writeFile() & webR.FS.readFile(). From there, it could be loaded using regular R code. Or, you could load the data directly into the global environment while placing it in the VFS system.

@coatless
Copy link
Owner

coatless commented Oct 4, 2023

I'm going to close out the question as being answered. If you end up writing the raw code cell, feel free to let me know!

I would suggest at this point creating a repository that contains the data sets, c.f.

https://github.com/coatless/raw-data

Enable the "GitHub Pages" option with default settings so that each data set is available at a URL like:

https://<username>.github.io/<repository>/<dataset>.csv

Then, using the read.csv() inside of a {webr-r} code cell to read in the data, e.g.

```{webr-r}
df = read.csv("https://coatless.github.io/raw-data/pima.csv")
```

@coatless
Copy link
Owner

With #168, you can use embed-resources if you are not using the service-worker communication channel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s: question-answered Question has been answered. t: discussion Question & Answer
Projects
None yet
Development

No branches or pull requests

2 participants