aboutsummaryrefslogtreecommitdiff
path: root/javascript/olm_suffix.js
diff options
context:
space:
mode:
authorDavid Baker <dbkr@users.noreply.github.com>2018-10-10 20:07:19 +0100
committerGitHub <noreply@github.com>2018-10-10 20:07:19 +0100
commit3cfcf1615dfe434e1aa10d5c904d537b159e1566 (patch)
treedc1271227d8cef2bf6a687e0b31e288c99d274d6 /javascript/olm_suffix.js
parent713e9aeb4d63732f7671f9c7ac3d9c4897449583 (diff)
parent1dbb060c44423048d9782b9a9977e51cc8f43b8d (diff)
Merge pull request #57 from matrix-org/dbkr/wasm
WebAssembly support
Diffstat (limited to 'javascript/olm_suffix.js')
-rw-r--r--javascript/olm_suffix.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/javascript/olm_suffix.js b/javascript/olm_suffix.js
new file mode 100644
index 0000000..3e2f664
--- /dev/null
+++ b/javascript/olm_suffix.js
@@ -0,0 +1,32 @@
+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;
+}
+
+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;
+}