Commit 89150107 authored by Alex Beregszaszi's avatar Alex Beregszaszi

Use window.Module to be canonical

parent d568c939
...@@ -7,11 +7,13 @@ module.exports = function (self) { ...@@ -7,11 +7,13 @@ module.exports = function (self) {
var data = e.data; var data = e.data;
switch (data.cmd) { switch (data.cmd) {
case 'loadVersion': case 'loadVersion':
delete Module; delete window.Module;
version = null; version = null;
compileJSON = null; compileJSON = null;
importScripts(data.data); importScripts(data.data);
var Module = window.Module;
version = Module.cwrap('version', 'string', []); version = Module.cwrap('version', 'string', []);
if ('_compileJSONCallback' in Module) { if ('_compileJSONCallback' in Module) {
var compileJSONInternal = Module.cwrap('compileJSONCallback', 'string', ['string', 'number', 'number']); var compileJSONInternal = Module.cwrap('compileJSONCallback', 'string', ['string', 'number', 'number']);
......
...@@ -73,6 +73,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles ...@@ -73,6 +73,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
if (worker === null) { if (worker === null) {
var compile; var compile;
var missingInputs = []; var missingInputs = [];
var Module = window.Module;
if ('_compileJSONCallback' in Module) { if ('_compileJSONCallback' in Module) {
compilerAcceptsMultipleFiles = true; compilerAcceptsMultipleFiles = true;
var missingInputsCallback = Module.Runtime.addFunction(function (path, contents, error) { var missingInputsCallback = Module.Runtime.addFunction(function (path, contents, error) {
...@@ -146,7 +147,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles ...@@ -146,7 +147,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
}; };
function loadInternal (url, setVersionText) { function loadInternal (url, setVersionText) {
Module = null; delete window.Module;
// Set a safe fallback until the new one is loaded // Set a safe fallback until the new one is loaded
compileJSON = function (source, optimize) { compilationFinished('{}'); }; compileJSON = function (source, optimize) { compilationFinished('{}'); };
...@@ -155,7 +156,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles ...@@ -155,7 +156,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
newScript.src = url; newScript.src = url;
document.getElementsByTagName('head')[0].appendChild(newScript); document.getElementsByTagName('head')[0].appendChild(newScript);
var check = window.setInterval(function () { var check = window.setInterval(function () {
if (!Module) { if (!window.Module) {
return; return;
} }
window.clearInterval(check); window.clearInterval(check);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment