coatless / quarto-webr

Community developed Quarto Extension to Embed webR for HTML Documents, RevealJS, Websites, Blogs, and Books.
https://quarto-webr.thecoatlessprofessor.com/
395 stars 19 forks source link

Cell state manager #120

Closed coatless closed 10 months ago

coatless commented 11 months ago

In this PR, we introduce a cell state manager that:

  1. Stores each cell and code inside of JS; and,
  2. Allows for consistent execution of output and setup code cells with values in packages.

Implementation status: In progress


Q: Why are there so many instances of globalThis.* =?

A: We're trying to avoid needing to register standalone HTML dependencies like a JavaScript file. Thus, we have multiple "module" files setup in <script type="module"> JS HERE </script>.

If we registered a JS file, this would require us to be able to have the JS persist to the publish phase. In this case, we could then do:

<script
  src="./qwebr-module.js"
  type="module"
></script>

<script type="module">
  import { initWebR } from "./qwebr-module.js";
  ...
</script>

Once resolved, this should address:

Close #114, Close #105, Close #88