The simplest stop-gap solution to rerender on width changes (after all remaining hard references have been removed):
Replace the following:
const render = (inputValue) => {
// Get the updated code
const plotCode = config.plot(inputValue);
with
const render = () => {
// Get the updated code
const plotCode = config.plot(form.value);
Then replace
form.on("input", function () {
render(this.value);
});
with
form.on("input", render);
Finally, add:
window.addEventListener("resize", render);
invalidation.then(() => window.removeEventListener("resize", render));