aboutsummaryrefslogtreecommitdiff
path: root/javascript/olm_post.js
diff options
context:
space:
mode:
authorRichard van der Hoff <github@rvanderhoff.org.uk>2016-12-14 14:34:39 +0000
committerGitHub <noreply@github.com>2016-12-14 14:34:39 +0000
commit2e04868c468ba4d0362a209f8f261df649598a07 (patch)
tree9a3a2f60fed411f9e6fca867691fa63a1db39d79 /javascript/olm_post.js
parentf6c05be8c5d35e725a8a2ed5ad661398ac9f8cd2 (diff)
parent51b141ecb6b473dd4fd8425ca08f8dbc590a01c0 (diff)
Merge pull request #38 from matrix-org/rav/handle_load_exceptions
Better handling of exceptions during loading, and import OLM_OPTIONS
Diffstat (limited to 'javascript/olm_post.js')
-rw-r--r--javascript/olm_post.js20
1 files changed, 19 insertions, 1 deletions
diff --git a/javascript/olm_post.js b/javascript/olm_post.js
index 8951c11..54e42c5 100644
--- a/javascript/olm_post.js
+++ b/javascript/olm_post.js
@@ -419,4 +419,22 @@ olm_exports["get_library_version"] = restore_stack(function() {
getValue(buf+2, 'i8'),
];
});
-}();
+
+})();
+
+// export the olm functions into the environment.
+//
+// make sure that we do this *after* populating olm_exports, so that we don't
+// get a half-built window.Olm if there is an exception.
+
+if (typeof module !== 'undefined' && module.exports) {
+ // node / browserify
+ module.exports = olm_exports;
+}
+
+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;
+}