From 602c00a8d658e8510e37e841dd06c70f276d0f00 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 4 Oct 2018 20:09:54 +0100 Subject: Dual-build wasm and asm.js olm --- javascript/olm_post.js | 9 --------- javascript/olm_pre.js | 9 +++++++++ javascript/olm_suffix.js | 10 ++++++---- 3 files changed, 15 insertions(+), 13 deletions(-) (limited to 'javascript') diff --git a/javascript/olm_post.js b/javascript/olm_post.js index 9e0294a..21ea890 100644 --- a/javascript/olm_post.js +++ b/javascript/olm_post.js @@ -463,12 +463,3 @@ olm_exports["get_library_version"] = restore_stack(function() { getValue(buf+2, 'i8'), ]; }); - -Module['onRuntimeInitialized'] = function() { - OLM_ERROR = Module['_olm_error'](); - if (onInitSuccess) onInitSuccess(); -}; - -Module['onAbort'] = function(err) { - if (onInitFail) onInitFail(err); -}; diff --git a/javascript/olm_pre.js b/javascript/olm_pre.js index 4feff97..18d836d 100644 --- a/javascript/olm_pre.js +++ b/javascript/olm_pre.js @@ -37,3 +37,12 @@ if (typeof(OLM_OPTIONS) !== 'undefined') { * use UTF8ToString. */ var NULL_BYTE_PADDING_LENGTH = 1; + +Module['onRuntimeInitialized'] = function() { + OLM_ERROR = Module['_olm_error'](); + if (onInitSuccess) onInitSuccess(); +}; + +Module['onAbort'] = function(err) { + if (onInitFail) onInitFail(err); +}; diff --git a/javascript/olm_suffix.js b/javascript/olm_suffix.js index 7f19953..3e2f664 100644 --- a/javascript/olm_suffix.js +++ b/javascript/olm_suffix.js @@ -24,7 +24,9 @@ if (typeof(window) !== 'undefined') { window["Olm"] = olm_exports; } -// Emscripten sets the module exports to be its module -// with wrapped c functions. Clobber it with our higher -// level wrapper class. -module.exports = olm_exports; +if (typeof module === 'object') { + // Emscripten sets the module exports to be its module + // with wrapped c functions. Clobber it with our higher + // level wrapper class. + module.exports = olm_exports; +} -- cgit v1.2.3