window.common = (function({ Rx: { Observable }, common = { init: [] } }) {
var libraryIncludes = `
`;
const iFrameScript$ =
common.getScriptContent$('/js/iFrameScripts.js').shareReplay();
// runPreviewTests$ should be set up in the preview window
common.runPreviewTests$ =
() => Observable.throw({ err: new Error('run preview not enabled') });
common.updatePreview$ = function updatePreview$(code = '') {
const previewFrame = document.getElementById('preview');
const preview = previewFrame.contentDocument ||
previewFrame.contentWindow.document;
if (!preview) {
return Observable.just(code);
}
return iFrameScript$
.map(script => ``)
.doOnNext(script => {
preview.open();
preview.write(libraryIncludes + code + script);
preview.close();
})
.map(() => code);
};
return common;
}(window));