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.8.1 to 0.9.0-nightly.20200127

66

index.d.ts

@@ -19,37 +19,63 @@ /// <reference lib="esnext.bigint" />

/** Explicit start function, if requested. */
__start(): void;
_start(): void;
/** Allocates a new string in the module's memory and returns a reference (pointer) to it. */
__allocString(str: string): number;
/** Reads (copies) the value of a string from the module's memory. */
__getString(ptr: number): string;
/** Allocates a new array in the module's memory and returns a reference (pointer) to it. */
__allocArray(id: number, values: ArrayLike<number>): number;
/** Reads (copies) the values of an array from the module's memory. */
/** Copies a string's value from the module's memory. */
__getString(ptr: number): string;
/** Copies an ArrayBuffer's value from the module's memory. */
__getArrayBuffer(ptr: number): ArrayBuffer;
/** Copies an array's values from the module's memory. Infers the array type from RTTI. */
__getArray(ptr: number): number[];
/** Gets a view on the values of an array in the module's memory. */
__getArrayView(ptr: number): ArrayBufferView;
/** Reads the values of Int8Array from the module's memory. */
/** Copies an Int8Array's values from the module's memory. */
__getInt8Array(ptr: number): Int8Array;
/** Reads the values of Uint8Array from the module's memory. */
/** Copies an Uint8Array's values from the module's memory. */
__getUint8Array(ptr: number): Uint8Array;
/** Reads the values of Uint8Array from the module's memory. */
/** Copies an Uint8ClampedArray's values from the module's memory. */
__getUint8ClampedArray(ptr: number): Uint8ClampedArray;
/** Reads the values of Int16Array from the module's memory. */
/** Copies an Int16Array's values from the module's memory. */
__getInt16Array(ptr: number): Int16Array;
/** Reads the values of Uint16Array from the module's memory. */
/** Copies an Uint16Array's values from the module's memory. */
__getUint16Array(ptr: number): Uint16Array;
/** Reads the values of Int32Array from the module's memory. */
/** Copies an Int32Array's values from the module's memory. */
__getInt32Array(ptr: number): Int32Array;
/** Reads the values of Uint32Array from the module's memory. */
/** Copies an Uint32Array's values from the module's memory. */
__getUint32Array(ptr: number): Uint32Array;
/** Reads the values of Int32Array from the module's memory. */
/** Copies an Int32Array's values from the module's memory. */
__getInt64Array?(ptr: number): BigInt64Array;
/** Reads the values of Uint32Array from the module's memory. */
/** Copies an Uint32Array's values from the module's memory. */
__getUint64Array?(ptr: number): BigUint64Array;
/** Reads the values of Float32Array from the module's memory. */
/** Copies a Float32Array's values from the module's memory. */
__getFloat32Array(ptr: number): Float32Array;
/** Reads the values of Float64Array from the module's memory. */
/** Copies a Float64Array's values from the module's memory. */
__getFloat64Array(ptr: number): Float64Array;
/** Reads (copies) the data of an ArrayBuffer from the module's memory. */
__getArrayBuffer(ptr: number): ArrayBuffer;
/** Gets a live view on an array's values in the module's memory. Infers the array type from RTTI. */
__getArrayView(ptr: number): ArrayBufferView;
/** Gets a live view on an Int8Array's values in the module's memory. */
__getInt8ArrayView(ptr: number): Int8Array;
/** Gets a live view on an Uint8Array's values in the module's memory. */
__getUint8ArrayView(ptr: number): Uint8Array;
/** Gets a live view on an Uint8ClampedArray's values in the module's memory. */
__getUint8ClampedArrayView(ptr: number): Uint8ClampedArray;
/** Gets a live view on an Int16Array's values in the module's memory. */
__getInt16ArrayView(ptr: number): Int16Array;
/** Gets a live view on an Uint16Array's values in the module's memory. */
__getUint16ArrayView(ptr: number): Uint16Array;
/** Gets a live view on an Int32Array's values in the module's memory. */
__getInt32ArrayView(ptr: number): Int32Array;
/** Gets a live view on an Uint32Array's values in the module's memory. */
__getUint32ArrayView(ptr: number): Uint32Array;
/** Gets a live view on an Int32Array's values in the module's memory. */
__getInt64ArrayView?(ptr: number): BigInt64Array;
/** Gets a live view on an Uint32Array's values in the module's memory. */
__getUint64ArrayView?(ptr: number): BigUint64Array;
/** Gets a live view on a Float32Array's values in the module's memory. */
__getFloat32ArrayView(ptr: number): Float32Array;
/** Gets a live view on a Float64Array's values in the module's memory. */
__getFloat64ArrayView(ptr: number): Float64Array;
/** Retains a reference to a managed object externally, making sure that it doesn't become collected prematurely. Returns the pointer. */

@@ -59,2 +85,4 @@ __retain(ptr: number): number;

__release(ptr: number): void;
/** Forcefully resets the heap to its initial offset, effectively clearing dynamic memory. Stub runtime only. */
__reset?(): void;
/** Allocates an instance of the class represented by the specified id. */

@@ -61,0 +89,0 @@ __alloc(size: number, id: number): number;

@@ -183,3 +183,3 @@ "use strict";

/** Gets a view on the values of an array in the module's memory. */
/** Gets a live view on an array's values in the module's memory. Infers the array type from RTTI. */
function __getArrayView(arr) {

@@ -201,3 +201,3 @@ const U32 = new Uint32Array(memory.buffer);

/** Reads (copies) the values of an array from the module's memory. */
/** Copies an array's values from the module's memory. Infers the array type from RTTI. */
function __getArray(arr) {

@@ -213,3 +213,3 @@ const input = __getArrayView(arr);

/** Reads (copies) the data of an ArrayBuffer from the module's memory. */
/** Copies an ArrayBuffer's value from the module's memory. */
function __getArrayBuffer(ptr) {

@@ -223,3 +223,9 @@ const buffer = memory.buffer;

function getTypedArrayImpl(Type, alignLog2, ptr) {
/** 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) {
const buffer = memory.buffer;

@@ -231,26 +237,26 @@ const U32 = new Uint32Array(buffer);

/** Gets a view on the values of a known-to-be Int8Array in the module's memory. */
baseModule.__getInt8Array = getTypedArrayImpl.bind(null, Int8Array, 0);
/** Gets a view on the values of a known-to-be Uint8Array in the module's memory. */
baseModule.__getUint8Array = getTypedArrayImpl.bind(null, Uint8Array, 0);
/** Gets a view on the values of a known-to-be Uint8ClampedArray in the module's memory. */
baseModule.__getUint8ClampedArray = getTypedArrayImpl.bind(null, Uint8ClampedArray, 0);
/** Gets a view on the values of a known-to-be Int16Array in the module's memory. */
baseModule.__getInt16Array = getTypedArrayImpl.bind(null, Int16Array, 1);
/** Gets a view on the values of a known-to-be Uint16Array in the module's memory. */
baseModule.__getUint16Array = getTypedArrayImpl.bind(null, Uint16Array, 1);
/** Gets a view on the values of a known-to-be Int32Array in the module's memory. */
baseModule.__getInt32Array = getTypedArrayImpl.bind(null, Int32Array, 2);
/** Gets a view on the values of a known-to-be Uint32Array in the module's memory. */
baseModule.__getUint32Array = getTypedArrayImpl.bind(null, Uint32Array, 2);
baseModule.__getInt8Array = getTypedArray.bind(null, Int8Array, 0);
baseModule.__getInt8ArrayView = getTypedArrayView.bind(null, Int8Array, 0);
baseModule.__getUint8Array = getTypedArray.bind(null, Uint8Array, 0);
baseModule.__getUint8ArrayView = getTypedArrayView.bind(null, Uint8Array, 0);
baseModule.__getUint8ClampedArray = getTypedArray.bind(null, Uint8ClampedArray, 0);
baseModule.__getUint8ClampedArrayView = getTypedArrayView.bind(null, Uint8ClampedArray, 0);
baseModule.__getInt16Array = getTypedArray.bind(null, Int16Array, 1);
baseModule.__getInt16ArrayView = getTypedArrayView.bind(null, Int16Array, 1);
baseModule.__getUint16Array = getTypedArray.bind(null, Uint16Array, 1);
baseModule.__getUint16ArrayView = getTypedArrayView.bind(null, Uint16Array, 1);
baseModule.__getInt32Array = getTypedArray.bind(null, Int32Array, 2);
baseModule.__getInt32ArrayView = getTypedArrayView.bind(null, Int32Array, 2);
baseModule.__getUint32Array = getTypedArray.bind(null, Uint32Array, 2);
baseModule.__getUint32ArrayView = getTypedArrayView.bind(null, Uint32Array, 2);
if (BIGINT) {
/** Gets a view on the values of a known-to-be-Int64Array in the module's memory. */
baseModule.__getInt64Array = getTypedArrayImpl.bind(null, BigInt64Array, 3);
/** Gets a view on the values of a known-to-be-Uint64Array in the module's memory. */
baseModule.__getUint64Array = getTypedArrayImpl.bind(null, BigUint64Array, 3);
baseModule.__getInt64Array = getTypedArray.bind(null, BigInt64Array, 3);
baseModule.__getInt64ArrayView = getTypedArrayView.bind(null, BigInt64Array, 3);
baseModule.__getUint64Array = getTypedArray.bind(null, BigUint64Array, 3);
baseModule.__getUint64ArrayView = getTypedArrayView.bind(null, BigUint64Array, 3);
}
/** Gets a view on the values of a known-to-be Float32Array in the module's memory. */
baseModule.__getFloat32Array = getTypedArrayImpl.bind(null, Float32Array, 2);
/** Gets a view on the values of a known-to-be Float64Array in the module's memory. */
baseModule.__getFloat64Array = getTypedArrayImpl.bind(null, Float64Array, 3);
baseModule.__getFloat32Array = getTypedArray.bind(null, Float32Array, 2);
baseModule.__getFloat32ArrayView = getTypedArrayView.bind(null, Float32Array, 2);
baseModule.__getFloat64Array = getTypedArray.bind(null, Float64Array, 3);
baseModule.__getFloat64ArrayView = getTypedArrayView.bind(null, Float64Array, 3);

@@ -279,5 +285,5 @@ /** Tests whether an object is an instance of the class represented by the specified base id. */

/** Wraps a WebAssembly function while also taking care of variable arguments. */
function wrapFunction(fn, setargc) {
function wrapFunction(fn, argumentsLength) {
var wrap = (...args) => {
setargc(args.length);
if (argumentsLength) argumentsLength.value = args.length;
return fn(...args);

@@ -345,3 +351,3 @@ }

var module = baseModule ? Object.create(baseModule) : {};
var setargc = exports["__setargc"] || function() {};
var argumentsLength = exports["__argumentsLength"];
function hasOwnProperty(elem, prop) {

@@ -396,7 +402,7 @@ return Object.prototype.hasOwnProperty.call(elem, prop);

if (name === 'constructor') {
curr[name] = wrapFunction(elem, setargc);
curr[name] = wrapFunction(elem, argumentsLength);
} else { // for methods
Object.defineProperty(curr, name, {
value: function (...args) {
setargc(args.length);
if (argumentsLength) argumentsLength.value = args.length;
return elem(this[THIS], ...args);

@@ -417,3 +423,3 @@ }

} else if (typeof elem === "function") {
curr[name] = wrapFunction(elem, setargc);
curr[name] = wrapFunction(elem, argumentsLength);
} else {

@@ -420,0 +426,0 @@ curr[name] = elem;

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

],
"version": "0.8.1",
"version": "0.9.0-nightly.20200127",
"author": "Daniel Wirtz <dcode+assemblyscript@dcode.io>",

@@ -15,0 +15,0 @@ "license": "Apache-2.0",

@@ -33,3 +33,3 @@ ![AS](https://avatars1.githubusercontent.com/u/28916798?s=48) AssemblyScript Loader

* **__start**(): `void`<br />
* **_start**(): `void`<br />
Explicit start function if the `--explicitStart` option is used. Must be called before any other exports if present.

@@ -47,3 +47,3 @@

* **__getString**(ptr: `number`): `string`<br />
Reads (copies) the value of a string from the module's memory.
Copies a string's value from the module's memory.

@@ -55,14 +55,7 @@ ```ts

* **__allocArray**(id: `number`, values: `number[]`): `number`<br />
Allocates a new array in the module's memory and returns a reference (pointer) to it.
Automatically retains interior pointers. The `id` is the unique runtime id of the respective array class. If you are using `Int32Array` for example, the best way to know the id is an `export const INT32ARRAY_ID = idof<Int32Array>()`. When done with the array, make sure to release it.
* **__getArrayBuffer**(ptr: `number`): `ArrayBuffer`<br />
Copies an ArrayBuffer's value from the module's memory.
```ts
var ptr = module.__retain(module.__allocArray(module.INT32ARRAY, [1, 2, 3]));
...
module.__release(ptr);
```
* **__getArray**(ptr: `number`): `number[]`<br />
Reads (copies) the values of an array from the module's memory.
Copies an array's values from the module's memory. Infers the array type from RTTI.

@@ -74,7 +67,4 @@ ```ts

* **__getArrayView**(ptr: `number`): `TypedArray`<br />
Gets a view on the values of an array in the module's memory. This differs from `__getArray` in that the data isn't copied but remains *live* in both directions. That's faster but also unsafe because if the array grows or becomes released, the view will no longer represent the correct memory region and modifying its values in this state will most likely corrupt memory. Use, but use with care.
If the type of the array is known beforehand, the following slightly faster helpers that don't infer the type can be used:
If the type of the array is known beforehand, the following even faster and even more unsafe helpers can be used that don't do any type checking:
**__getInt8Array**(ptr: `number`): `Int8Array`<br />

@@ -92,5 +82,21 @@ **__getUint8Array**(ptr: `number`): `Uint8Array`<br />

* **__getArrayBuffer**(ptr: `number`): `ArrayBuffer`<br />
Reads (copies) the data of an ArrayBuffer from the module's memory.
* **__getArrayView**(ptr: `number`): `TypedArray`<br />
Gets a live view on the values of an array in the module's memory. Infers the array type from RTTI.
This differs from `__getArray` in that the data isn't copied but remains *live* in both directions. That's faster but also unsafe because if the array grows or becomes released, the view will no longer represent the correct memory region and modifying its values in this state will most likely corrupt memory. Use, but use with care.
If the type of the array is known beforehand, the following slightly faster helpers that don't infer the type can be used:
**__getInt8ArrayView**(ptr: `number`): `Int8Array`<br />
**__getUint8ArrayView**(ptr: `number`): `Uint8Array`<br />
**__getUint8ClampedArrayView**(ptr: `number`): `Uint8ClampedArray`<br />
**__getInt16ArrayView**(ptr: `number`): `Int16Array`<br />
**__getUint16ArrayView**(ptr: `number`): `Uint16Array`<br />
**__getInt32ArrayView**(ptr: `number`): `Int32Array`<br />
**__getUint32ArrayView**(ptr: `number`): `Uint32Array`<br />
**__getInt64ArrayView**(ptr: `number`): `BigInt64Array`<br />
**__getUint64ArrayView**(ptr: `number`): `BigUint64Array`<br />
**__getFloat32ArrayView**(ptr: `number`): `Float32Array`<br />
**__getFloat64ArrayView**(ptr: `number`): `Float64Array`
* **__retain**(ptr: `number`): `number`<br />

@@ -115,2 +121,12 @@ Retains a reference to a managed object externally, making sure that it doesn't become collected prematurely. Returns the pointer.

* **__allocArray**(id: `number`, values: `number[]`): `number`<br />
Allocates a new array in the module's memory and returns a reference (pointer) to it.
Automatically retains interior pointers. The `id` is the unique runtime id of the respective array class. If you are using `Int32Array` for example, the best way to know the id is an `export const INT32ARRAY_ID = idof<Int32Array>()`. When done with the array, make sure to release it.
```ts
var ptr = module.__retain(module.__allocArray(module.INT32ARRAY, [1, 2, 3]));
...
module.__release(ptr);
```
* **__instanceof**(ptr: `number`, baseId: `number`): `boolean`<br />

@@ -117,0 +133,0 @@ Tests whether an object is an instance of the class represented by the specified base id.

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