esbuild-android-64
Advanced tools
Comparing version
{ | ||
"name": "esbuild-android-64", | ||
"version": "0.14.27", | ||
"version": "0.14.28", | ||
"description": "A WebAssembly shim for esbuild on Android x64.", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/evanw/esbuild", |
144
wasm_exec.js
@@ -5,59 +5,5 @@ // Copyright 2018 The Go Authors. All rights reserved. | ||
"use strict"; | ||
(() => { | ||
// Map multiple JavaScript environments to a single common API, | ||
// preferring web standards over Node.js API. | ||
// | ||
// Environments considered: | ||
// - Browsers | ||
// - Node.js | ||
// - Electron | ||
// - Parcel | ||
// - Webpack | ||
if (typeof global !== "undefined") { | ||
// global already exists | ||
} else if (typeof window !== "undefined") { | ||
window.global = window; | ||
} else if (typeof self !== "undefined") { | ||
self.global = self; | ||
} else { | ||
throw new Error("cannot export Go (neither global, window nor self is defined)"); | ||
} | ||
if (!global.require && typeof require !== "undefined") { | ||
global.require = require; | ||
} | ||
if (!global.fs && global.require) { | ||
const fs = require("fs"); | ||
if (typeof fs === "object" && fs !== null && Object.keys(fs).length !== 0) { | ||
global.fs = Object.assign({}, fs, { | ||
// Hack around a Unicode bug in node: https://github.com/nodejs/node/issues/24550 | ||
write(fd, buf, offset, length, position, callback) { | ||
if (offset === 0 && length === buf.length && position === null) { | ||
if (fd === process.stdout.fd) { | ||
try { | ||
process.stdout.write(buf, err => err ? callback(err, 0, null) : callback(null, length, buf)); | ||
} catch (err) { | ||
callback(err, 0, null); | ||
} | ||
return; | ||
} | ||
if (fd === process.stderr.fd) { | ||
try { | ||
process.stderr.write(buf, err => err ? callback(err, 0, null) : callback(null, length, buf)); | ||
} catch (err) { | ||
callback(err, 0, null); | ||
} | ||
return; | ||
} | ||
} | ||
fs.write(fd, buf, offset, length, position, callback); | ||
}, | ||
}); | ||
} | ||
} | ||
const enosys = () => { | ||
@@ -69,5 +15,5 @@ const err = new Error("not implemented"); | ||
if (!global.fs) { | ||
if (!globalThis.fs) { | ||
let outputBuf = ""; | ||
global.fs = { | ||
globalThis.fs = { | ||
constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 }, // unused | ||
@@ -117,4 +63,4 @@ writeSync(fd, buf) { | ||
if (!global.process) { | ||
global.process = { | ||
if (!globalThis.process) { | ||
globalThis.process = { | ||
getuid() { return -1; }, | ||
@@ -133,46 +79,22 @@ getgid() { return -1; }, | ||
if (!global.crypto && global.require) { | ||
const nodeCrypto = require("crypto"); | ||
global.crypto = { | ||
getRandomValues(b) { | ||
nodeCrypto.randomFillSync(b); | ||
}, | ||
}; | ||
if (!globalThis.crypto) { | ||
throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)"); | ||
} | ||
if (!global.crypto) { | ||
throw new Error("global.crypto is not available, polyfill required (getRandomValues only)"); | ||
} | ||
if (!global.performance) { | ||
global.performance = { | ||
now() { | ||
const [sec, nsec] = process.hrtime(); | ||
return sec * 1000 + nsec / 1000000; | ||
}, | ||
}; | ||
if (!globalThis.performance) { | ||
throw new Error("globalThis.performance is not available, polyfill required (performance.now only)"); | ||
} | ||
if (!global.TextEncoder && global.require) { | ||
global.TextEncoder = require("util").TextEncoder; | ||
if (!globalThis.TextEncoder) { | ||
throw new Error("globalThis.TextEncoder is not available, polyfill required"); | ||
} | ||
if (!global.TextEncoder) { | ||
throw new Error("global.TextEncoder is not available, polyfill required"); | ||
} | ||
if (!global.TextDecoder && global.require) { | ||
global.TextDecoder = require("util").TextDecoder; | ||
if (!globalThis.TextDecoder) { | ||
throw new Error("globalThis.TextDecoder is not available, polyfill required"); | ||
} | ||
if (!global.TextDecoder) { | ||
throw new Error("global.TextDecoder is not available, polyfill required"); | ||
} | ||
// Make sure Go sees the shadowed "fs" global | ||
const { fs } = global; | ||
const encoder = new TextEncoder("utf-8"); | ||
const decoder = new TextDecoder("utf-8"); | ||
global.Go = class { | ||
globalThis.Go = class { | ||
constructor() { | ||
@@ -552,3 +474,3 @@ this.argv = ["js"]; | ||
false, | ||
global, | ||
globalThis, | ||
this, | ||
@@ -562,3 +484,3 @@ ]; | ||
[false, 4], | ||
[global, 5], | ||
[globalThis, 5], | ||
[this, 6], | ||
@@ -638,34 +560,2 @@ ]); | ||
} | ||
if ( | ||
typeof module !== "undefined" && | ||
global.require && | ||
global.require.main === module && | ||
global.process && | ||
global.process.versions && | ||
!global.process.versions.electron | ||
) { | ||
if (process.argv.length < 3) { | ||
console.error("usage: go_js_wasm_exec [wasm binary] [arguments]"); | ||
process.exit(1); | ||
} | ||
const go = new Go(); | ||
go.argv = process.argv.slice(2); | ||
go.env = Object.assign({ TMPDIR: require("os").tmpdir() }, process.env); | ||
go.exit = process.exit; | ||
WebAssembly.instantiate(fs.readFileSync(process.argv[2]), go.importObject).then((result) => { | ||
process.on("exit", (code) => { // Node.js exits if no event handler is pending | ||
if (code === 0 && !go.exited) { | ||
// deadlock, make Go print error and stack traces | ||
go._pendingEvent = { id: 0 }; | ||
go._resume(); | ||
} | ||
}); | ||
return go.run(result.instance); | ||
}).catch((err) => { | ||
console.error(err); | ||
process.exit(1); | ||
}); | ||
} | ||
})(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
9774737
2.06%7
16.67%574
-9.18%5
25%