From c993e3da6ae9a5c635f7911801a41e82c7ca9803 Mon Sep 17 00:00:00 2001 From: Carl Woffenden Date: Wed, 21 Feb 2024 18:53:01 +0100 Subject: [PATCH] Fixes to build with Closure (--closure 1) --- src/closure-externs/closure-externs.js | 9 +++++++++ src/library_browser.js | 11 ++++++++--- src/library_idbfs.js | 2 ++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/closure-externs/closure-externs.js b/src/closure-externs/closure-externs.js index 9fb433b70a6e..07eb010f5df5 100644 --- a/src/closure-externs/closure-externs.js +++ b/src/closure-externs/closure-externs.js @@ -260,3 +260,12 @@ var moduleArg; */ Navigator.prototype.webkitGetUserMedia = function( constraints, successCallback, errorCallback) {}; + +/** + * Global object for custom event target mappings, see: + * https://emscripten.org/docs/api_reference/html5.h.html#how-to-use-this-api + * + * @type {Object} + * @suppress {duplicate} + */ +var specialHTMLTargets; diff --git a/src/library_browser.js b/src/library_browser.js index c493d8be54dc..f0613644e3e0 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -138,7 +138,9 @@ var LibraryBrowser = { #endif var img = new Image(); img.onload = () => { +#if ASSERTIONS assert(img.complete, `Image ${name} could not be decoded`); +#endif var canvas = /** @type {!HTMLCanvasElement} */ (document.createElement('canvas')); canvas.width = img.width; canvas.height = img.height; @@ -302,8 +304,9 @@ var LibraryBrowser = { if (!ctx) return null; if (setInModule) { +#if ASSERTIONS if (!useWebGL) assert(typeof GLctx == 'undefined', 'cannot set in module if GLctx is used, but we are a non-GL context that would replace it'); - +#endif Module.ctx = ctx; if (useWebGL) GL.makeContextCurrent(contextHandle); Module.useWebGL = useWebGL; @@ -783,8 +786,9 @@ var LibraryBrowser = { return onerror ? onerror() : undefined; } #endif +#if ASSERTIONS assert(runDependencies === 0, 'async_load_script must be run when no other dependencies are active'); - +#endif {{{ runtimeKeepalivePush() }}} var loadDone = () => { @@ -911,8 +915,9 @@ var LibraryBrowser = { * @param {boolean=} noSetTiming */`, $setMainLoop: (browserIterationFunc, fps, simulateInfiniteLoop, arg, noSetTiming) => { +#if ASSERTIONS assert(!Browser.mainLoop.func, 'emscripten_set_main_loop: there can only be one main loop function at once: call emscripten_cancel_main_loop to cancel the previous one before setting a new one with different parameters.'); - +#endif Browser.mainLoop.func = browserIterationFunc; Browser.mainLoop.arg = arg; diff --git a/src/library_idbfs.js b/src/library_idbfs.js index 3f482866b53d..5831fcd40a2e 100644 --- a/src/library_idbfs.js +++ b/src/library_idbfs.js @@ -16,7 +16,9 @@ addToLibrary({ if (typeof indexedDB != 'undefined') return indexedDB; var ret = null; if (typeof window == 'object') ret = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB; +#if ASSERTIONS assert(ret, 'IDBFS used, but indexedDB not supported'); +#endif return ret; }, DB_VERSION: 21,