Open salmenf opened 1 year ago
Some might be fixed already in Jorik's local version, just listing all I noticed in ww-code@0.2.0
:
Look into Python code execution with Pyodide:
Blob URLs for dependencies of Pyodide?
We need to prepare the code widget for use in the Explorable JS WebTech course:
JS Code execution now uses Function()
instead of eval()
. Therefore to see the result someone has to return it.
To access the global variables, use this
for initial definition
Thanks for the update! I found some issues and have further ideas:
var x = 1
, switch to global execution, run.return x
, switch to global execution, run.x is not defined
.1 + 1
globally or locally produces no output. It should produce 2
in both cases. For the local context, it may be necessary to add a return
to the last line. This could be tricky since the last line may be any kind of code -> detect if it's an expression, if so, add a return. I think you'd need to parse the code snippet for this: https://github.com/acornjs/acorn/tree/master/acorn/Run
(since it's the expected default from Jupyter), running locally could be called Run in isolation
type=module
attribute on script tag (on JS global execution) -> This would allow URL-based imports like import mymodule from 'https://...mysite.../myscript.js'
ts.transpileModule
(not sure if we can get type errors out of this)rollup
+ @rollup/plugin-typescript
<script type="importmap">
in the head and map a code cell name to a blob URL, for example "geometry": "blob:..."
to enable import {Square} from "geometry"
in code cell. It's questionable if this is possible in other languages than JS, though. Maybe this is a special feature for JS code cells?
ww-code
(or originallyww-code-cell
) is the first widget for WebWriter that was made by a student. We still need to do a lot of work to make it usable in WebWriter.Package:
ww-code-cell
toww-code
Integration:
Features:
printable
(force light mode, hide buttons and hide all styling based on interaction, selection, etc.)UI:
part=action
and adjust options layout accordingly