percival
percival copied to clipboard
Plot cell: allow async, multiple inputs, one output
This PR updates Plot cells to work as more fully-featured JS cells.
- Plot cells can take multiple input dependencies:
(dep1, dep2) => ...or no inputs,() => .... - Plot cells can be async, allowing them to access modules with
await import(...):async dep => (await import('https://esm.sh/...'))(dep). - Plot cells can write a reactive result, using assignment syntax:
resultName = () => [{ x: 1 }, { x: 2 }]. Currently this emits one relation, not a set of relations like code cells. A future change could use syntax like{ table1, table2 } = () => ...to emit multiple relation outputs. - Cell outputs with
outerHTMLare rendered as HTML (as before). Array outputs are rendered as relations. Otherwise, the output is rendered as JSON. If #16 is merged, I'll replace the simple JSON renderer with the JSON tree inspector used there.
After these changes "plot" vs "code" seem like misnomers - perhaps we should rename these concepts to "datalog" and "js". However, that's a bigger policy/design change.