aboutsummaryrefslogtreecommitdiff
path: root/public/wg2nd
diff options
context:
space:
mode:
Diffstat (limited to 'public/wg2nd')
-rw-r--r--public/wg2nd/wg2nd_bindings.js120
1 files changed, 19 insertions, 101 deletions
diff --git a/public/wg2nd/wg2nd_bindings.js b/public/wg2nd/wg2nd_bindings.js
index 8d0d94c..27365af 100644
--- a/public/wg2nd/wg2nd_bindings.js
+++ b/public/wg2nd/wg2nd_bindings.js
@@ -1,3 +1,14 @@
+var Module = {
+ onRuntimeInitialized: function() {
+ window.Wg2ndModule = Module;
+
+
+ if (typeof window.wg2ndOnLoad === "function") {
+ window.wg2ndOnLoad(Module);
+ }
+ }
+};
+
// include: shell.js
// The Module object: Our interface to the outside world. We import
// and export values on it. There are various ways Module can be used:
@@ -34,13 +45,10 @@ var quit_ = (status, toThrow) => {
// Determine the runtime environment we are in. You can customize this by
// setting the ENVIRONMENT setting at compile time (see settings.js).
-// Attempt to auto-detect the environment
-var ENVIRONMENT_IS_WEB = typeof window == 'object';
-var ENVIRONMENT_IS_WORKER = typeof importScripts == 'function';
-// N.b. Electron.js environment is simultaneously a NODE-environment, but
-// also a web environment.
-var ENVIRONMENT_IS_NODE = typeof process == 'object' && typeof process.versions == 'object' && typeof process.versions.node == 'string';
-var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
+var ENVIRONMENT_IS_WEB = true;
+var ENVIRONMENT_IS_WORKER = false;
+var ENVIRONMENT_IS_NODE = false;
+var ENVIRONMENT_IS_SHELL = false;
if (Module['ENVIRONMENT']) {
throw new Error('Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)');
@@ -61,83 +69,6 @@ var read_,
readBinary,
setWindowTitle;
-if (ENVIRONMENT_IS_NODE) {
- if (typeof process == 'undefined' || !process.release || process.release.name !== 'node') throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
-
- var nodeVersion = process.versions.node;
- var numericVersion = nodeVersion.split('.').slice(0, 3);
- numericVersion = (numericVersion[0] * 10000) + (numericVersion[1] * 100) + (numericVersion[2].split('-')[0] * 1);
- var minVersion = 160000;
- if (numericVersion < 160000) {
- throw new Error('This emscripten-generated code requires node v16.0.0 (detected v' + nodeVersion + ')');
- }
-
- // `require()` is no-op in an ESM module, use `createRequire()` to construct
- // the require()` function. This is only necessary for multi-environment
- // builds, `-sENVIRONMENT=node` emits a static import declaration instead.
- // TODO: Swap all `require()`'s with `import()`'s?
- // These modules will usually be used on Node.js. Load them eagerly to avoid
- // the complexity of lazy-loading.
- var fs = require('fs');
- var nodePath = require('path');
-
- if (ENVIRONMENT_IS_WORKER) {
- scriptDirectory = nodePath.dirname(scriptDirectory) + '/';
- } else {
- scriptDirectory = __dirname + '/';
- }
-
-// include: node_shell_read.js
-read_ = (filename, binary) => {
- // We need to re-wrap `file://` strings to URLs. Normalizing isn't
- // necessary in that case, the path should already be absolute.
- filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
- return fs.readFileSync(filename, binary ? undefined : 'utf8');
-};
-
-readBinary = (filename) => {
- var ret = read_(filename, true);
- if (!ret.buffer) {
- ret = new Uint8Array(ret);
- }
- assert(ret.buffer);
- return ret;
-};
-
-readAsync = (filename, onload, onerror, binary = true) => {
- // See the comment in the `read_` function.
- filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
- fs.readFile(filename, binary ? undefined : 'utf8', (err, data) => {
- if (err) onerror(err);
- else onload(binary ? data.buffer : data);
- });
-};
-// end include: node_shell_read.js
- if (!Module['thisProgram'] && process.argv.length > 1) {
- thisProgram = process.argv[1].replace(/\\/g, '/');
- }
-
- arguments_ = process.argv.slice(2);
-
- if (typeof module != 'undefined') {
- module['exports'] = Module;
- }
-
- process.on('uncaughtException', (ex) => {
- // suppress ExitStatus exceptions from showing an error
- if (ex !== 'unwind' && !(ex instanceof ExitStatus) && !(ex.context instanceof ExitStatus)) {
- throw ex;
- }
- });
-
- quit_ = (status, toThrow) => {
- process.exitCode = status;
- throw toThrow;
- };
-
- Module['inspect'] = () => '[Emscripten Module object]';
-
-} else
if (ENVIRONMENT_IS_SHELL) {
if ((typeof process == 'object' && typeof require === 'function') || typeof window == 'object' || typeof importScripts == 'function') throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
@@ -318,6 +249,10 @@ var PROXYFS = 'PROXYFS is no longer included by default; build with -lproxyfs.js
var WORKERFS = 'WORKERFS is no longer included by default; build with -lworkerfs.js';
var NODEFS = 'NODEFS is no longer included by default; build with -lnodefs.js';
+assert(!ENVIRONMENT_IS_WORKER, "worker environment detected but not enabled at build time. Add 'worker' to `-sENVIRONMENT` to enable.");
+
+assert(!ENVIRONMENT_IS_NODE, "node environment detected but not enabled at build time. Add 'node' to `-sENVIRONMENT` to enable.");
+
assert(!ENVIRONMENT_IS_SHELL, "shell environment detected but not enabled at build time. Add 'shell' to `-sENVIRONMENT` to enable.");
@@ -742,7 +677,6 @@ function getBinaryPromise(binaryFile) {
if (!wasmBinary
&& (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) {
if (typeof fetch == 'function'
- && !isFileURI(binaryFile)
) {
return fetch(binaryFile, { credentials: 'same-origin' }).then((response) => {
if (!response['ok']) {
@@ -751,12 +685,6 @@ function getBinaryPromise(binaryFile) {
return response['arrayBuffer']();
}).catch(() => getBinarySync(binaryFile));
}
- else if (readAsync) {
- // fetch is not available or url is file => try XHR (readAsync uses XHR internally)
- return new Promise((resolve, reject) => {
- readAsync(binaryFile, (response) => resolve(new Uint8Array(/** @type{!ArrayBuffer} */(response))), reject)
- });
- }
}
// Otherwise, getBinarySync should be able to get it synchronously
@@ -783,15 +711,6 @@ function instantiateAsync(binary, binaryFile, imports, callback) {
if (!binary &&
typeof WebAssembly.instantiateStreaming == 'function' &&
!isDataURI(binaryFile) &&
- // Don't use streaming for file:// delivered objects in a webview, fetch them synchronously.
- !isFileURI(binaryFile) &&
- // Avoid instantiateStreaming() on Node.js environment for now, as while
- // Node.js v18.1.0 implements it, it does not have a full fetch()
- // implementation yet.
- //
- // Reference:
- // https://github.com/emscripten-core/emscripten/pull/16917
- !ENVIRONMENT_IS_NODE &&
typeof fetch == 'function') {
return fetch(binaryFile, { credentials: 'same-origin' }).then((response) => {
// Suppress closure warning here since the upstream definition for
@@ -1190,7 +1109,6 @@ function dbg(text) {
if (!warnOnce.shown) warnOnce.shown = {};
if (!warnOnce.shown[text]) {
warnOnce.shown[text] = 1;
- if (ENVIRONMENT_IS_NODE) text = 'warning: ' + text;
err(text);
}
};