Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

esbuild-wasm

Package Overview
Dependencies
Maintainers
1
Versions
464
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esbuild-wasm - npm Package Compare versions

Comparing version 0.1.16 to 0.1.17

README.md

2

package.json
{
"name": "esbuild-wasm",
"version": "0.1.16",
"version": "0.1.17",
"description": "The cross-platform WebAssembly binary for esbuild, a JavaScript bundler.",

@@ -5,0 +5,0 @@ "repository": "https://github.com/evanw/esbuild",

@@ -33,2 +33,8 @@ // Copyright 2018 The Go Authors. All rights reserved.

const enosys = () => {
const err = new Error("not implemented");
err.code = "ENOSYS";
return err;
};
if (!global.fs) {

@@ -49,3 +55,4 @@ let outputBuf = "";

if (offset !== 0 || length !== buf.length || position !== null) {
throw new Error("not implemented");
callback(enosys());
return;
}

@@ -55,18 +62,43 @@ const n = this.writeSync(fd, buf);

},
open(path, flags, mode, callback) {
const err = new Error("not implemented");
err.code = "ENOSYS";
callback(err);
},
read(fd, buffer, offset, length, position, callback) {
const err = new Error("not implemented");
err.code = "ENOSYS";
callback(err);
},
fsync(fd, callback) {
callback(null);
},
chmod(path, mode, callback) { callback(enosys()); },
chown(path, uid, gid, callback) { callback(enosys()); },
close(fd, callback) { callback(enosys()); },
fchmod(fd, mode, callback) { callback(enosys()); },
fchown(fd, uid, gid, callback) { callback(enosys()); },
fstat(fd, callback) { callback(enosys()); },
fsync(fd, callback) { callback(null); },
ftruncate(fd, length, callback) { callback(enosys()); },
lchown(path, uid, gid, callback) { callback(enosys()); },
link(path, link, callback) { callback(enosys()); },
lstat(path, callback) { callback(enosys()); },
mkdir(path, perm, callback) { callback(enosys()); },
open(path, flags, mode, callback) { callback(enosys()); },
read(fd, buffer, offset, length, position, callback) { callback(enosys()); },
readdir(path, callback) { callback(enosys()); },
readlink(path, callback) { callback(enosys()); },
rename(from, to, callback) { callback(enosys()); },
rmdir(path, callback) { callback(enosys()); },
stat(path, callback) { callback(enosys()); },
symlink(path, link, callback) { callback(enosys()); },
truncate(path, length, callback) { callback(enosys()); },
unlink(path, callback) { callback(enosys()); },
utimes(path, atime, mtime, callback) { callback(enosys()); },
};
}
if (!global.process) {
global.process = {
getuid() { return -1; },
getgid() { return -1; },
geteuid() { return -1; },
getegid() { return -1; },
getgroups() { throw enosys(); },
pid: -1,
ppid: -1,
umask() { throw enosys(); },
cwd() { throw enosys(); },
chdir() { throw enosys(); },
}
}
if (!global.crypto) {

@@ -119,15 +151,10 @@ const nodeCrypto = require("crypto");

const mem = () => {
// The buffer may change when requesting more memory.
return new DataView(this._inst.exports.mem.buffer);
}
const setInt64 = (addr, v) => {
mem().setUint32(addr + 0, v, true);
mem().setUint32(addr + 4, Math.floor(v / 4294967296), true);
this.mem.setUint32(addr + 0, v, true);
this.mem.setUint32(addr + 4, Math.floor(v / 4294967296), true);
}
const getInt64 = (addr) => {
const low = mem().getUint32(addr + 0, true);
const high = mem().getInt32(addr + 4, true);
const low = this.mem.getUint32(addr + 0, true);
const high = this.mem.getInt32(addr + 4, true);
return low + high * 4294967296;

@@ -137,3 +164,3 @@ }

const loadValue = (addr) => {
const f = mem().getFloat64(addr, true);
const f = this.mem.getFloat64(addr, true);
if (f === 0) {

@@ -146,3 +173,3 @@ return undefined;

const id = mem().getUint32(addr, true);
const id = this.mem.getUint32(addr, true);
return this._values[id];

@@ -156,12 +183,12 @@ }

if (isNaN(v)) {
mem().setUint32(addr + 4, nanHead, true);
mem().setUint32(addr, 0, true);
this.mem.setUint32(addr + 4, nanHead, true);
this.mem.setUint32(addr, 0, true);
return;
}
if (v === 0) {
mem().setUint32(addr + 4, nanHead, true);
mem().setUint32(addr, 1, true);
this.mem.setUint32(addr + 4, nanHead, true);
this.mem.setUint32(addr, 1, true);
return;
}
mem().setFloat64(addr, v, true);
this.mem.setFloat64(addr, v, true);
return;

@@ -172,38 +199,43 @@ }

case undefined:
mem().setFloat64(addr, 0, true);
this.mem.setFloat64(addr, 0, true);
return;
case null:
mem().setUint32(addr + 4, nanHead, true);
mem().setUint32(addr, 2, true);
this.mem.setUint32(addr + 4, nanHead, true);
this.mem.setUint32(addr, 2, true);
return;
case true:
mem().setUint32(addr + 4, nanHead, true);
mem().setUint32(addr, 3, true);
this.mem.setUint32(addr + 4, nanHead, true);
this.mem.setUint32(addr, 3, true);
return;
case false:
mem().setUint32(addr + 4, nanHead, true);
mem().setUint32(addr, 4, true);
this.mem.setUint32(addr + 4, nanHead, true);
this.mem.setUint32(addr, 4, true);
return;
}
let ref = this._refs.get(v);
if (ref === undefined) {
ref = this._values.length;
this._values.push(v);
this._refs.set(v, ref);
let id = this._ids.get(v);
if (id === undefined) {
id = this._idPool.pop();
if (id === undefined) {
id = this._values.length;
}
this._values[id] = v;
this._goRefCounts[id] = 0;
this._ids.set(v, id);
}
let typeFlag = 0;
this._goRefCounts[id]++;
let typeFlag = 1;
switch (typeof v) {
case "string":
typeFlag = 1;
typeFlag = 2;
break;
case "symbol":
typeFlag = 2;
typeFlag = 3;
break;
case "function":
typeFlag = 3;
typeFlag = 4;
break;
}
mem().setUint32(addr + 4, nanHead | typeFlag, true);
mem().setUint32(addr, ref, true);
this.mem.setUint32(addr + 4, nanHead | typeFlag, true);
this.mem.setUint32(addr, id, true);
}

@@ -243,7 +275,9 @@

"runtime.wasmExit": (sp) => {
const code = mem().getInt32(sp + 8, true);
const code = this.mem.getInt32(sp + 8, true);
this.exited = true;
delete this._inst;
delete this._values;
delete this._refs;
delete this._goRefCounts;
delete this._ids;
delete this._idPool;
this.exit(code);

@@ -256,16 +290,21 @@ },

const p = getInt64(sp + 16);
const n = mem().getInt32(sp + 24, true);
const n = this.mem.getInt32(sp + 24, true);
fs.writeSync(fd, new Uint8Array(this._inst.exports.mem.buffer, p, n));
},
// func nanotime() int64
"runtime.nanotime": (sp) => {
// func resetMemoryDataView()
"runtime.resetMemoryDataView": (sp) => {
this.mem = new DataView(this._inst.exports.mem.buffer);
},
// func nanotime1() int64
"runtime.nanotime1": (sp) => {
setInt64(sp + 8, (timeOrigin + performance.now()) * 1000000);
},
// func walltime() (sec int64, nsec int32)
"runtime.walltime": (sp) => {
// func walltime1() (sec int64, nsec int32)
"runtime.walltime1": (sp) => {
const msec = (new Date).getTime();
setInt64(sp + 8, msec / 1000);
mem().setInt32(sp + 16, (msec % 1000) * 1000000, true);
this.mem.setInt32(sp + 16, (msec % 1000) * 1000000, true);
},

@@ -289,3 +328,3 @@

));
mem().setInt32(sp + 16, id, true);
this.mem.setInt32(sp + 16, id, true);
},

@@ -295,3 +334,3 @@

"runtime.clearTimeoutEvent": (sp) => {
const id = mem().getInt32(sp + 8, true);
const id = this.mem.getInt32(sp + 8, true);
clearTimeout(this._scheduledTimeouts.get(id));

@@ -306,2 +345,14 @@ this._scheduledTimeouts.delete(id);

// func finalizeRef(v ref)
"syscall/js.finalizeRef": (sp) => {
const id = this.mem.getUint32(sp + 8, true);
this._goRefCounts[id]--;
if (this._goRefCounts[id] === 0) {
const v = this._values[id];
this._values[id] = null;
this._ids.delete(v);
this._idPool.push(id);
}
},
// func stringVal(value string) ref

@@ -324,2 +375,7 @@ "syscall/js.stringVal": (sp) => {

// func valueDelete(v ref, p string)
"syscall/js.valueDelete": (sp) => {
Reflect.deleteProperty(loadValue(sp + 8), loadString(sp + 16));
},
// func valueIndex(v ref, i int) ref

@@ -344,6 +400,6 @@ "syscall/js.valueIndex": (sp) => {

storeValue(sp + 56, result);
mem().setUint8(sp + 64, 1);
this.mem.setUint8(sp + 64, 1);
} catch (err) {
storeValue(sp + 56, err);
mem().setUint8(sp + 64, 0);
this.mem.setUint8(sp + 64, 0);
}

@@ -360,6 +416,6 @@ },

storeValue(sp + 40, result);
mem().setUint8(sp + 48, 1);
this.mem.setUint8(sp + 48, 1);
} catch (err) {
storeValue(sp + 40, err);
mem().setUint8(sp + 48, 0);
this.mem.setUint8(sp + 48, 0);
}

@@ -376,6 +432,6 @@ },

storeValue(sp + 40, result);
mem().setUint8(sp + 48, 1);
this.mem.setUint8(sp + 48, 1);
} catch (err) {
storeValue(sp + 40, err);
mem().setUint8(sp + 48, 0);
this.mem.setUint8(sp + 48, 0);
}

@@ -404,3 +460,3 @@ },

"syscall/js.valueInstanceOf": (sp) => {
mem().setUint8(sp + 24, loadValue(sp + 8) instanceof loadValue(sp + 16));
this.mem.setUint8(sp + 24, loadValue(sp + 8) instanceof loadValue(sp + 16));
},

@@ -413,3 +469,3 @@

if (!(src instanceof Uint8Array)) {
mem().setUint8(sp + 48, 0);
this.mem.setUint8(sp + 48, 0);
return;

@@ -420,3 +476,3 @@ }

setInt64(sp + 40, toCopy.length);
mem().setUint8(sp + 48, 1);
this.mem.setUint8(sp + 48, 1);
},

@@ -429,3 +485,3 @@

if (!(dst instanceof Uint8Array)) {
mem().setUint8(sp + 48, 0);
this.mem.setUint8(sp + 48, 0);
return;

@@ -436,3 +492,3 @@ }

setInt64(sp + 40, toCopy.length);
mem().setUint8(sp + 48, 1);
this.mem.setUint8(sp + 48, 1);
},

@@ -449,3 +505,4 @@

this._inst = instance;
this._values = [ // TODO: garbage collection
this.mem = new DataView(this._inst.exports.mem.buffer);
this._values = [ // JS values that Go currently has references to, indexed by reference id
NaN,

@@ -459,7 +516,7 @@ 0,

];
this._refs = new Map();
this.exited = false;
this._goRefCounts = []; // number of references that Go has to a JS value, indexed by reference id
this._ids = new Map(); // mapping from JS values to reference ids
this._idPool = []; // unused ids that have been garbage collected
this.exited = false; // whether the Go program has exited
const mem = new DataView(this._inst.exports.mem.buffer)
// Pass command line arguments and environment variables to WebAssembly by writing them to the linear memory.

@@ -471,3 +528,3 @@ let offset = 4096;

const bytes = encoder.encode(str + "\0");
new Uint8Array(mem.buffer, offset, bytes.length).set(bytes);
new Uint8Array(this.mem.buffer, offset, bytes.length).set(bytes);
offset += bytes.length;

@@ -486,13 +543,14 @@ if (offset % 8 !== 0) {

});
argvPtrs.push(0);
const keys = Object.keys(this.env).sort();
argvPtrs.push(keys.length);
keys.forEach((key) => {
argvPtrs.push(strPtr(`${key}=${this.env[key]}`));
});
argvPtrs.push(0);
const argv = offset;
argvPtrs.forEach((ptr) => {
mem.setUint32(offset, ptr, true);
mem.setUint32(offset + 4, 0, true);
this.mem.setUint32(offset, ptr, true);
this.mem.setUint32(offset + 4, 0, true);
offset += 8;

@@ -499,0 +557,0 @@ });

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc