about summary refs log tree commit diff
path: root/extra/js/index.tpl.html
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2020-07-15T07·20+0100
committerVincent Ambo <mail@tazj.in>2020-07-15T07·20+0100
commit7f19d641647ac4ef313ed88d6b5c140983ce5436 (patch)
tree31b66c81465293da5c093c5dde3e419758c0d6cc /extra/js/index.tpl.html
Squashed 'third_party/immer/' content from commit ad3e3556d
git-subtree-dir: third_party/immer
git-subtree-split: ad3e3556d38bb75966dd24c61a774970a7c7957e
Diffstat (limited to 'extra/js/index.tpl.html')
-rw-r--r--extra/js/index.tpl.html77
1 files changed, 77 insertions, 0 deletions
diff --git a/extra/js/index.tpl.html b/extra/js/index.tpl.html
new file mode 100644
index 000000000000..fdbd40a86a10
--- /dev/null
+++ b/extra/js/index.tpl.html
@@ -0,0 +1,77 @@
+<!--
+    immer: immutable data structures for C++
+    Copyright (C) 2016, 2017, 2018 Juan Pedro Bolivar Puente
+
+    This software is distributed under the Boost Software License, Version 1.0.
+    See accompanying file LICENSE or copy at http://boost.org/LICENSE_1_0.txt
+-->
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="UTF-8">
+    <script src="../lib/lodash.js"></script>
+    <script src="../lib/platform.js"></script>
+    <script src="../lib/benchmark.js"></script>
+    <script src="../lib/immutable.min.js"></script>
+    <script src="../lib/mori.js"></script>
+    <script>
+    </script>
+  </head>
+  <body>
+    <script>
+     var IMMER_WASM_HAS_MEM = false;
+     var IMMER_JS_FILE = '%IMMER_JS%'
+     var Module = {};
+
+     if (IMMER_JS_FILE.endsWith('wasm.js'))
+         loadWasm()
+     else if (IMMER_JS_FILE.endsWith('asmjs.js'))
+         loadAsmjs()
+     else
+         throw Error('Wrong format')
+
+     function loadAsync(u, c) {
+         var d = document, t = 'script',
+             o = d.createElement(t),
+             s = d.getElementsByTagName(t)[0];
+         o.src = u;
+         if (c) { o.addEventListener('load', function (e) { c(null, e); }, false); }
+         s.parentNode.insertBefore(o, s);
+     }
+
+     function loadAsmjs() {
+         loadAsync(IMMER_JS_FILE, function () {
+             loadAsync('../index.js')
+         });
+     }
+
+     function loadWasm() {
+         var xhr = new XMLHttpRequest();
+         var basename = IMMER_JS_FILE.substring(0, IMMER_JS_FILE.length-3)
+         xhr.open('GET', basename + '.wasm', true);
+         xhr.responseType = 'arraybuffer';
+         xhr.onload = function() {
+             Module.wasmBinary = xhr.response;
+             if (IMMER_WASM_HAS_MEM) {
+                 (function() {
+                     var memoryInitializer = IMMER_JS_FILE + '.mem';
+                     if (typeof Module['locateFile'] === 'function') {
+                         memoryInitializer = Module['locateFile'](memoryInitializer);
+                     } else if (Module['memoryInitializerPrefixURL']) {
+                         memoryInitializer = Module['memoryInitializerPrefixURL'] + memoryInitializer;
+                     }
+                     var xhr = Module['memoryInitializerRequest'] = new XMLHttpRequest();
+                     xhr.open('GET', memoryInitializer, true);
+                     xhr.responseType = 'arraybuffer';
+                     xhr.send(null);
+                 })();
+             }
+             loadAsync(IMMER_JS_FILE, function () {
+                 loadAsync('../index.js')
+             });
+         };
+         xhr.send(null);
+     }
+    </script>
+  </body>
+</html>