What if REPLs were just custom viewers Viewers? Implementing clientside execution via custom !viewer
.
useEffect for execution on load otherwise require button press to exec.
function foo(baz) {
alert("foo II")
return "bar:" + baz
}
export const returns = foo
import confetti from 'https://cdn.skypack.dev/canvas-confetti'
export const returns = run => confetti({
origin: {y: 0},
spread: 55,
particleCount: 100,
ticks: 1000,
})
Setting exec
attribute to onload
function output(num) {
alert("execd onload!")
return "done: " + new Date()
}
export const returns = output()
Cannot yet output raw DOM nodes, due to react setup of viewers.
function output(num) {
const dom = document.createElement("pre")
dom.innerHTML = `Run number ${num}`
return dom
}
export const returns = output
So far so good, the only issue is that output is entirely ephemeral, how would we enable document modification, ie persist the output as an attached cell.
import git from 'https://cdn.skypack.dev/isomorphic-git'
export const returns = git