about summary refs log tree commit diff
path: root/third_party/immer/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·23+0100
commit1213b086a1015a662ab7ebd658f784534fd3116a (patch)
treed3bc8f3b7f40b8b60f0ef6fbd649cf765f4fdfb6 /third_party/immer/extra/js/index.tpl.html
parent1390827b9ea1e04bc9863e48930bfd16db3b716e (diff)
parent7f19d641647ac4ef313ed88d6b5c140983ce5436 (diff)
merge(3p/immer): Subtree merge at 'ad3e3556d' as 'third_party/immer' r/1299
Change-Id: I9636a41ad44b4218293833fd3e9456d9b07c731b
Diffstat (limited to 'third_party/immer/extra/js/index.tpl.html')
-rw-r--r--third_party/immer/extra/js/index.tpl.html77
1 files changed, 77 insertions, 0 deletions
diff --git a/third_party/immer/extra/js/index.tpl.html b/third_party/immer/extra/js/index.tpl.html
new file mode 100644
index 000000000000..fdbd40a86a10
--- /dev/null
+++ b/third_party/immer/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>