diff --git a/src/library_browser.js b/src/library_browser.js index 2d1e3819de602..8ede8e1f7e1e4 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -124,7 +124,7 @@ var LibraryBrowser = { var imagePlugin = {}; imagePlugin['canHandle'] = function imagePlugin_canHandle(name) { - return !Module.noImageDecoding && /\.(jpg|jpeg|png|bmp|webp)$/i.test(name); + return !Module['noImageDecoding'] && /\.(jpg|jpeg|png|bmp|webp)$/i.test(name); }; imagePlugin['handle'] = function imagePlugin_handle(byteArray, name, onload, onerror) { var b = new Blob([byteArray], { type: Browser.getMimetype(name) }); @@ -160,7 +160,7 @@ var LibraryBrowser = { var audioPlugin = {}; audioPlugin['canHandle'] = function audioPlugin_canHandle(name) { - return !Module.noAudioDecoding && name.substr(-4) in { '.ogg': 1, '.wav': 1, '.mp3': 1 }; + return !Module['noAudioDecoding'] && name.substr(-4) in { '.ogg': 1, '.wav': 1, '.mp3': 1 }; }; audioPlugin['handle'] = function audioPlugin_handle(byteArray, name, onload, onerror) { var done = false; diff --git a/src/library_dylink.js b/src/library_dylink.js index 211f4030ce7e6..b0f672a9578e9 100644 --- a/src/library_dylink.js +++ b/src/library_dylink.js @@ -19,7 +19,7 @@ var LibraryDylink = { var wasmPlugin = { 'promiseChainEnd': Promise.resolve(), 'canHandle': (name) => { - return !Module.noWasmDecoding && name.endsWith('.so') + return !Module['noWasmDecoding'] && name.endsWith('.so') }, 'handle': (byteArray, name, onload, onerror) => { // loadWebAssemblyModule can not load modules out-of-order, so rather diff --git a/src/library_sdl.js b/src/library_sdl.js index bb38f12db4463..160849a38bf17 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -2701,7 +2701,7 @@ var LibrarySDL = { var raw = preloadedAudios[filename]; if (!raw) { if (raw === null) err('Trying to reuse preloaded audio, but freePreloadedMediaOnUse is set!'); - if (!Module.noAudioDecoding) warnOnce('Cannot find preloaded audio ' + filename); + if (!Module['noAudioDecoding']) warnOnce('Cannot find preloaded audio ' + filename); // see if we can read the file-contents from the in-memory FS try { diff --git a/src/shell.js b/src/shell.js index bb50bb8206f18..43b809f925f8b 100644 --- a/src/shell.js +++ b/src/shell.js @@ -25,15 +25,9 @@ var Module = moduleArg; #elif USE_CLOSURE_COMPILER // if (!Module)` is crucial for Closure Compiler here as it will otherwise replace every `Module` occurrence with a string var /** @type {{ - noImageDecoding: boolean, - noAudioDecoding: boolean, - noWasmDecoding: boolean, canvas: HTMLCanvasElement, ctx: Object, - dataFileDownloads: Object, - preloadResults: Object, useWebGL: boolean, - expectedDataFileDownloads: number, }} */ Module; if (!Module) /** @suppress{checkTypes}*/Module = {"__EMSCRIPTEN_PRIVATE_MODULE_EXPORT_NAME_SUBSTITUTION__":1}; diff --git a/tools/file_packager.py b/tools/file_packager.py index 7c668de42dbd6..ed564c10c4cac 100755 --- a/tools/file_packager.py +++ b/tools/file_packager.py @@ -607,11 +607,11 @@ def generate_js(data_target, data_files, metadata): var Module = typeof %(EXPORT_NAME)s != 'undefined' ? %(EXPORT_NAME)s : {};\n''' % {"EXPORT_NAME": options.export_name} ret += ''' - if (!Module.expectedDataFileDownloads) { - Module.expectedDataFileDownloads = 0; + if (!Module['expectedDataFileDownloads']) { + Module['expectedDataFileDownloads'] = 0; } - Module.expectedDataFileDownloads++; + Module['expectedDataFileDownloads']++; (() => { // Do not attempt to redownload the virtual filesystem data when in a pthread or a Wasm Worker context. var isPthread = typeof ENVIRONMENT_IS_PTHREAD != 'undefined' && ENVIRONMENT_IS_PTHREAD; @@ -978,26 +978,26 @@ def generate_js(data_target, data_files, metadata): if (event.loaded) { if (!xhr.addedTotal) { xhr.addedTotal = true; - if (!Module.dataFileDownloads) Module.dataFileDownloads = {}; - Module.dataFileDownloads[url] = { + if (!Module['dataFileDownloads']) Module['dataFileDownloads'] = {}; + Module['dataFileDownloads'][url] = { loaded: event.loaded, total: size }; } else { - Module.dataFileDownloads[url].loaded = event.loaded; + Module['dataFileDownloads'][url].loaded = event.loaded; } var total = 0; var loaded = 0; var num = 0; - for (var download in Module.dataFileDownloads) { - var data = Module.dataFileDownloads[download]; + for (var download in Module['dataFileDownloads']) { + var data = Module['dataFileDownloads'][download]; total += data.total; loaded += data.loaded; num++; } - total = Math.ceil(total * Module.expectedDataFileDownloads/num); + total = Math.ceil(total * Module['expectedDataFileDownloads']/num); Module['setStatus']?.(`Downloading data... (${loaded}/${total})`); - } else if (!Module.dataFileDownloads) { + } else if (!Module['dataFileDownloads']) { Module['setStatus']?.('Downloading data...'); } }; @@ -1032,7 +1032,7 @@ def generate_js(data_target, data_files, metadata): # we need to find the datafile in the same dir as the html file code += ''' - if (!Module.preloadResults) Module.preloadResults = {};\n''' + if (!Module['preloadResults']) Module['preloadResults'] = {};\n''' if options.use_preload_cache: code += ''' @@ -1046,7 +1046,7 @@ def generate_js(data_target, data_files, metadata): function(db) { checkCachedPackage(db, PACKAGE_PATH + PACKAGE_NAME, function(useCached, metadata) { - Module.preloadResults[PACKAGE_NAME] = {fromCache: useCached}; + Module['preloadResults'][PACKAGE_NAME] = {fromCache: useCached}; if (useCached) { fetchCachedPackage(db, PACKAGE_PATH + PACKAGE_NAME, metadata, processPackageData, preloadFallback); } else { @@ -1085,7 +1085,7 @@ def generate_js(data_target, data_files, metadata): }, handleError);\n''' code += ''' - Module.preloadResults[PACKAGE_NAME] = {fromCache: false}; + Module['preloadResults'][PACKAGE_NAME] = {fromCache: false}; if (fetched) { processPackageData(fetched); fetched = null;