Merge upstream

This incorporates all of the upstream changes since the last commit on master except the automatic build of main.js and related changes, and the output ref drag-and-drop feature.