aboutsummaryrefslogtreecommitdiff
path: root/javascript/olm_suffix.js
diff options
context:
space:
mode:
authorDavid Baker <dave@matrix.org>2018-10-03 16:22:13 +0100
committerDavid Baker <dave@matrix.org>2018-10-03 16:22:13 +0100
commit877166dedc0d25e9404ff429219e19e940aa80af (patch)
tree62c8db0be9032ab88666413f106c1d2115410aaf /javascript/olm_suffix.js
parent3e775938e50bffdfcb20241d598fea74ddaaf7e0 (diff)
parent00384ba87a5943a8a12c9b8bfcb8903cc9be490f (diff)
Merge branch 'dbkr/wasm' into dbkr/ci2
Diffstat (limited to 'javascript/olm_suffix.js')
-rw-r--r--javascript/olm_suffix.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/javascript/olm_suffix.js b/javascript/olm_suffix.js
new file mode 100644
index 0000000..7f19953
--- /dev/null
+++ b/javascript/olm_suffix.js
@@ -0,0 +1,30 @@
+var olmInitPromise;
+
+olm_exports['init'] = function(opts) {
+ if (olmInitPromise) return olmInitPromise;
+
+ if (opts) OLM_OPTIONS = opts;
+
+ olmInitPromise = new Promise(function(resolve, reject) {
+ onInitSuccess = function() {
+ resolve();
+ };
+ onInitFail = function(err) {
+ reject(err);
+ };
+ Module();
+ });
+ return olmInitPromise;
+};
+
+if (typeof(window) !== 'undefined') {
+ // We've been imported directly into a browser. Define the global 'Olm' object.
+ // (we do this even if module.exports was defined, because it's useful to have
+ // Olm in the global scope for browserified and webpacked apps.)
+ 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;