Socket
Socket
Sign inDemoInstall

@assemblyscript/loader

Package Overview
Dependencies
Maintainers
1
Versions
254
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@assemblyscript/loader - npm Package Compare versions

Comparing version 0.21.6 to 0.21.7

2

package.json

@@ -12,3 +12,3 @@ {

],
"version": "0.21.6",
"version": "0.21.7",
"author": "Daniel Wirtz <dcode+assemblyscript@dcode.io>",

@@ -15,0 +15,0 @@ "contributors": [

@@ -15,19 +15,22 @@ // GENERATED FILE. DO NOT EDIT.

const ID_OFFSET = -8;
const SIZE_OFFSET = -4; // Runtime ids
const SIZE_OFFSET = -4;
// Runtime ids
const ARRAYBUFFER_ID = 0;
const STRING_ID = 1; // const ARRAYBUFFERVIEW_ID = 2;
const STRING_ID = 1;
// const ARRAYBUFFERVIEW_ID = 2;
// Runtime type information
const ARRAYBUFFERVIEW = 1 << 0;
const ARRAY = 1 << 1;
const STATICARRAY = 1 << 2; // const SET = 1 << 3;
const STATICARRAY = 1 << 2;
// const SET = 1 << 3;
// const MAP = 1 << 4;
const VAL_ALIGN_OFFSET = 6; // const VAL_ALIGN = 1 << VAL_ALIGN_OFFSET;
const VAL_ALIGN_OFFSET = 6;
// const VAL_ALIGN = 1 << VAL_ALIGN_OFFSET;
const VAL_SIGNED = 1 << 11;
const VAL_FLOAT = 1 << 12; // const VAL_NULLABLE = 1 << 13;
const VAL_MANAGED = 1 << 14; // const KEY_ALIGN_OFFSET = 15;
const VAL_FLOAT = 1 << 12;
// const VAL_NULLABLE = 1 << 13;
const VAL_MANAGED = 1 << 14;
// const KEY_ALIGN_OFFSET = 15;
// const KEY_ALIGN = 1 << KEY_ALIGN_OFFSET;

@@ -38,4 +41,4 @@ // const KEY_SIGNED = 1 << 20;

// const KEY_MANAGED = 1 << 23;
// Array(BufferView) layout
const ARRAYBUFFERVIEW_BUFFER_OFFSET = 0;

@@ -49,13 +52,9 @@ const ARRAYBUFFERVIEW_DATASTART_OFFSET = 4;

const E_NO_EXPORT_RUNTIME = "Operation requires compiling with --exportRuntime";
const F_NO_EXPORT_RUNTIME = () => {
throw Error(E_NO_EXPORT_RUNTIME);
};
const BIGINT = typeof BigUint64Array !== "undefined";
const THIS = Symbol();
const STRING_SMALLSIZE = 192; // break-even point in V8
const STRING_CHUNKSIZE = 1024; // mitigate stack overflow
const utf16 = new TextDecoder("utf-16le", {

@@ -66,9 +65,7 @@ fatal: true

/** polyfill for Object.hasOwn */
Object.hasOwn = Object.hasOwn || function (obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
};
/** Gets a string from memory. */
function getStringImpl(buffer, ptr) {

@@ -78,3 +75,2 @@ let len = new Uint32Array(buffer)[ptr + SIZE_OFFSET >>> 2] >>> 1;

if (len <= STRING_SMALLSIZE) return String.fromCharCode(...wtf16);
try {

@@ -84,31 +80,24 @@ return utf16.decode(wtf16);

let str = "",
off = 0;
off = 0;
while (len - off > STRING_CHUNKSIZE) {
str += String.fromCharCode(...wtf16.subarray(off, off += STRING_CHUNKSIZE));
}
return str + String.fromCharCode(...wtf16.subarray(off));
}
}
/** Prepares the base module prior to instantiation. */
function preInstantiate(imports) {
const extendedExports = {};
function getString(memory, ptr) {
if (!memory) return "<yet unknown>";
return getStringImpl(memory.buffer, ptr);
} // add common imports used by stdlib for convenience
}
// add common imports used by stdlib for convenience
const env = imports.env = imports.env || {};
env.abort = env.abort || function abort(msg, file, line, colm) {
const memory = extendedExports.memory || env.memory; // prefer exported, otherwise try imported
throw Error(`abort: ${getString(memory, msg)} at ${getString(memory, file)}:${line}:${colm}`);
};
env.trace = env.trace || function trace(msg, n, ...args) {

@@ -118,3 +107,2 @@ const memory = extendedExports.memory || env.memory;

};
env.seed = env.seed || Date.now;

@@ -125,5 +113,4 @@ imports.Math = imports.Math || Math;

}
/** Prepares the final module once instantiation is complete. */
function postInstantiate(extendedExports, instance) {

@@ -133,11 +120,6 @@ const exports = instance.exports;

const table = exports.table;
const __new = exports.__new || F_NO_EXPORT_RUNTIME;
const __pin = exports.__pin || F_NO_EXPORT_RUNTIME;
const __unpin = exports.__unpin || F_NO_EXPORT_RUNTIME;
const __collect = exports.__collect || F_NO_EXPORT_RUNTIME;
const __rtti_base = exports.__rtti_base;

@@ -149,4 +131,4 @@ const getRttiCount = __rtti_base ? arr => arr[__rtti_base >>> 2] : F_NO_EXPORT_RUNTIME;

extendedExports.__collect = __collect;
/** Gets the runtime type info for the given id. */
function getRttInfo(id) {

@@ -157,5 +139,4 @@ const U32 = new Uint32Array(memory.buffer);

}
/** Gets the runtime base id for the given id. */
function getRttBase(id) {

@@ -166,5 +147,4 @@ const U32 = new Uint32Array(memory.buffer);

}
/** Gets and validate runtime type info for the given id for array like objects */
function getArrayInfo(id) {

@@ -175,8 +155,8 @@ const info = getRttInfo(id);

}
/** Gets the runtime alignment of a collection's values. */
function getValueAlign(info) {
return 31 - Math.clz32(info >>> VAL_ALIGN_OFFSET & 31); // -1 if none
}
/** Gets the runtime alignment of a collection's keys. */

@@ -188,26 +168,17 @@ // function getKeyAlign(info) {

/** Allocates a new string in the module's memory and returns its pointer. */
function __newString(str) {
if (str == null) return 0;
const length = str.length;
const ptr = __new(length << 1, STRING_ID);
const U16 = new Uint16Array(memory.buffer);
for (var i = 0, p = ptr >>> 1; i < length; ++i) U16[p + i] = str.charCodeAt(i);
return ptr;
}
extendedExports.__newString = __newString;
extendedExports.__newString = __newString;
/** Allocates a new ArrayBuffer in the module's memory and returns its pointer. */
function __newArrayBuffer(buf) {
if (buf == null) return 0;
const bufview = new Uint8Array(buf);
const ptr = __new(bufview.length, ARRAYBUFFER_ID);
const U8 = new Uint8Array(memory.buffer);

@@ -217,6 +188,5 @@ U8.set(bufview, ptr);

}
extendedExports.__newArrayBuffer = __newArrayBuffer;
extendedExports.__newArrayBuffer = __newArrayBuffer;
/** Reads a string from the module's memory by its pointer. */
function __getString(ptr) {

@@ -229,9 +199,7 @@ if (!ptr) return null;

}
extendedExports.__getString = __getString;
extendedExports.__getString = __getString;
/** Gets the view matching the specified alignment, signedness and floatness. */
function getView(alignLog2, signed, float) {
const buffer = memory.buffer;
if (float) {

@@ -241,3 +209,2 @@ switch (alignLog2) {

return new Float32Array(buffer);
case 3:

@@ -250,9 +217,6 @@ return new Float64Array(buffer);

return new (signed ? Int8Array : Uint8Array)(buffer);
case 1:
return new (signed ? Int16Array : Uint16Array)(buffer);
case 2:
return new (signed ? Int32Array : Uint32Array)(buffer);
case 3:

@@ -262,8 +226,6 @@ return new (signed ? BigInt64Array : BigUint64Array)(buffer);

}
throw Error(`unsupported align: ${alignLog2}`);
}
/** Allocates a new array in the module's memory and returns its pointer. */
function __newArray(id, valuesOrCapacity = 0) {

@@ -275,7 +237,4 @@ const input = valuesOrCapacity;

const length = isArrayLike ? input.length : input;
const buf = __new(length << align, info & STATICARRAY ? id : ARRAYBUFFER_ID);
let result;
if (info & STATICARRAY) {

@@ -285,7 +244,4 @@ result = buf;

__pin(buf);
const arr = __new(info & ARRAY ? ARRAY_SIZE : ARRAYBUFFERVIEW_SIZE, id);
__unpin(buf);
const U32 = new Uint32Array(memory.buffer);

@@ -298,7 +254,5 @@ U32[arr + ARRAYBUFFERVIEW_BUFFER_OFFSET >>> 2] = buf;

}
if (isArrayLike) {
const view = getView(align, info & VAL_SIGNED, info & VAL_FLOAT);
const start = buf >>> align;
if (info & VAL_MANAGED) {

@@ -312,9 +266,7 @@ for (let i = 0; i < length; ++i) {

}
return result;
}
extendedExports.__newArray = __newArray;
extendedExports.__newArray = __newArray;
/** Gets a live view on an array's values in the module's memory. Infers the array type from RTTI. */
function __getArrayView(arr) {

@@ -329,20 +281,15 @@ const U32 = new Uint32Array(memory.buffer);

}
extendedExports.__getArrayView = __getArrayView;
extendedExports.__getArrayView = __getArrayView;
/** Copies an array's values from the module's memory. Infers the array type from RTTI. */
function __getArray(arr) {
const input = __getArrayView(arr);
const len = input.length;
const out = new Array(len);
for (let i = 0; i < len; i++) out[i] = input[i];
return out;
}
extendedExports.__getArray = __getArray;
extendedExports.__getArray = __getArray;
/** Copies an ArrayBuffer's value from the module's memory. */
function __getArrayBuffer(ptr) {

@@ -353,6 +300,5 @@ const buffer = memory.buffer;

}
extendedExports.__getArrayBuffer = __getArrayBuffer;
extendedExports.__getArrayBuffer = __getArrayBuffer;
/** Gets a function from poiner which contain table's index. */
function __getFunction(ptr) {

@@ -363,12 +309,10 @@ if (!table) throw Error(E_NO_EXPORT_TABLE);

}
extendedExports.__getFunction = __getFunction;
extendedExports.__getFunction = __getFunction;
/** Copies a typed array's values from the module's memory. */
function getTypedArray(Type, alignLog2, ptr) {
return new Type(getTypedArrayView(Type, alignLog2, ptr));
}
/** Gets a live view on a typed array's values in the module's memory. */
function getTypedArrayView(Type, alignLog2, ptr) {

@@ -379,5 +323,4 @@ const buffer = memory.buffer;

}
/** Attach a set of get TypedArray and View functions to the exports. */
function attachTypedArrayFunctions(ctor, name, align) {

@@ -387,7 +330,5 @@ extendedExports[`__get${name}`] = getTypedArray.bind(null, ctor, align);

}
[Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array].forEach(ctor => {
attachTypedArrayFunctions(ctor, ctor.name, 31 - Math.clz32(ctor.BYTES_PER_ELEMENT));
});
if (BIGINT) {

@@ -398,9 +339,7 @@ [BigUint64Array, BigInt64Array].forEach(ctor => {

}
/** Tests whether an object is an instance of the class represented by the specified base id. */
function __instanceof(ptr, baseId) {
const U32 = new Uint32Array(memory.buffer);
let id = U32[ptr + ID_OFFSET >>> 2];
if (id <= getRttiCount(U32)) {

@@ -412,24 +351,21 @@ do {

}
return false;
}
extendedExports.__instanceof = __instanceof;
extendedExports.__instanceof = __instanceof; // Pull basic exports to extendedExports so code in preInstantiate can use them
// Pull basic exports to extendedExports so code in preInstantiate can use them
extendedExports.memory = extendedExports.memory || memory;
extendedExports.table = extendedExports.table || table; // Demangle exports and provide the usual utility on the prototype
extendedExports.table = extendedExports.table || table;
// Demangle exports and provide the usual utility on the prototype
return demangle(exports, extendedExports);
}
function isResponse(src) {
return typeof Response !== "undefined" && src instanceof Response;
}
function isModule(src) {
return src instanceof WebAssembly.Module;
}
/** Asynchronously instantiates an AssemblyScript module from anything that can be instantiated. */
async function instantiate(source, imports = {}) {

@@ -447,5 +383,4 @@ if (isResponse(source = await source)) return instantiateStreaming(source, imports);

}
/** Synchronously instantiates an AssemblyScript module from a WebAssembly.Module or binary buffer. */
function instantiateSync(source, imports = {}) {

@@ -462,5 +397,4 @@ const module = isModule(source) ? source : new WebAssembly.Module(source);

}
/** Asynchronously instantiates an AssemblyScript module from a response, i.e. as obtained by `fetch`. */
async function instantiateStreaming(source, imports = {}) {

@@ -470,20 +404,16 @@ if (!WebAssembly.instantiateStreaming) {

}
const extended = preInstantiate(imports);
const result = await WebAssembly.instantiateStreaming(source, imports);
const exports = postInstantiate(extended, result.instance);
return { ...result,
return {
...result,
exports
};
}
/** Demangles an AssemblyScript module's exports to a friendly object structure. */
function demangle(exports, extendedExports = {}) {
const setArgumentsLength = exports["__argumentsLength"] ? length => {
exports["__argumentsLength"].value = length;
} : exports["__setArgumentsLength"] || exports["__setargc"] || (() => {
/* nop */
});
} : exports["__setArgumentsLength"] || exports["__setargc"] || (() => {/* nop */});
for (let internalName of Object.keys(exports)) {

@@ -493,3 +423,2 @@ const elem = exports[internalName];

let curr = extendedExports;
while (parts.length > 1) {

@@ -500,10 +429,7 @@ let part = parts.shift();

}
let name = parts[0];
let hash = name.indexOf("#");
if (hash >= 0) {
const className = name.substring(0, hash);
const classElem = curr[className];
if (typeof classElem === "undefined" || !classElem.prototype) {

@@ -513,3 +439,2 @@ const ctor = function (...args) {

};
ctor.prototype = {

@@ -519,5 +444,3 @@ valueOf() {

}
};
ctor.wrap = function (thisValue) {

@@ -531,10 +454,7 @@ return Object.create(ctor.prototype, {

};
if (classElem) Object.getOwnPropertyNames(classElem).forEach(name => Object.defineProperty(ctor, name, Object.getOwnPropertyDescriptor(classElem, name)));
curr[className] = ctor;
}
name = name.substring(hash + 1);
curr = curr[className].prototype;
if (/^(get|set):/.test(name)) {

@@ -548,7 +468,5 @@ if (!Object.hasOwn(curr, name = name.substring(4))) {

},
set(value) {
setter(this[THIS], value);
},
enumerable: true

@@ -591,6 +509,4 @@ });

}
return extendedExports;
}
var _default = {

@@ -597,0 +513,0 @@ instantiate,

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