source: trip-planner-front/node_modules/@assemblyscript/loader/index.d.ts@ 8d391a1

Last change on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 6.1 KB
RevLine 
[6a3a178]1/// <reference lib="esnext.bigint" />
2
3export interface ResultObject {
4 module: WebAssembly.Module;
5 instance: WebAssembly.Instance;
6}
7
8
9/** WebAssembly imports with an optional env object and two levels of nesting. */
10export type Imports = {
11 [key: string]: Record<string,unknown>;
12 env?: {
13 memory?: WebAssembly.Memory;
14 table?: WebAssembly.Table;
15 seed?(): number;
16 abort?(msg: number, file: number, line: number, column: number): void;
17 trace?(msg: number, numArgs?: number, ...args: number[]): void;
18 };
19};
20
21/** Utility mixed in by the loader. */
22export interface ASUtil {
23 memory?: WebAssembly.Memory;
24 table?: WebAssembly.Table;
25
26 /** Explicit start function, if requested. */
27 _start(): void;
28 /** Allocates a new string in the module's memory and returns a reference (pointer) to it. */
29 __allocString(str: string): number;
30 /** Allocates a new array in the module's memory and returns a reference (pointer) to it. */
31 __allocArray(id: number, values: ArrayLike<number>): number;
32
33 /** Copies a string's value from the module's memory. */
34 __getString(ptr: number): string;
35 /** Copies an ArrayBuffer's value from the module's memory. */
36 __getArrayBuffer(ptr: number): ArrayBuffer;
37
38 /** Copies an array's values from the module's memory. Infers the array type from RTTI. */
39 __getArray(ptr: number): number[];
40 /** Copies an Int8Array's values from the module's memory. */
41 __getInt8Array(ptr: number): Int8Array;
42 /** Copies an Uint8Array's values from the module's memory. */
43 __getUint8Array(ptr: number): Uint8Array;
44 /** Copies an Uint8ClampedArray's values from the module's memory. */
45 __getUint8ClampedArray(ptr: number): Uint8ClampedArray;
46 /** Copies an Int16Array's values from the module's memory. */
47 __getInt16Array(ptr: number): Int16Array;
48 /** Copies an Uint16Array's values from the module's memory. */
49 __getUint16Array(ptr: number): Uint16Array;
50 /** Copies an Int32Array's values from the module's memory. */
51 __getInt32Array(ptr: number): Int32Array;
52 /** Copies an Uint32Array's values from the module's memory. */
53 __getUint32Array(ptr: number): Uint32Array;
54 /** Copies an Int32Array's values from the module's memory. */
55 __getInt64Array?(ptr: number): BigInt64Array;
56 /** Copies an Uint32Array's values from the module's memory. */
57 __getUint64Array?(ptr: number): BigUint64Array;
58 /** Copies a Float32Array's values from the module's memory. */
59 __getFloat32Array(ptr: number): Float32Array;
60 /** Copies a Float64Array's values from the module's memory. */
61 __getFloat64Array(ptr: number): Float64Array;
62
63 /** Gets a live view on an array's values in the module's memory. Infers the array type from RTTI. */
64 __getArrayView(ptr: number): ArrayBufferView;
65 /** Gets a live view on an Int8Array's values in the module's memory. */
66 __getInt8ArrayView(ptr: number): Int8Array;
67 /** Gets a live view on an Uint8Array's values in the module's memory. */
68 __getUint8ArrayView(ptr: number): Uint8Array;
69 /** Gets a live view on an Uint8ClampedArray's values in the module's memory. */
70 __getUint8ClampedArrayView(ptr: number): Uint8ClampedArray;
71 /** Gets a live view on an Int16Array's values in the module's memory. */
72 __getInt16ArrayView(ptr: number): Int16Array;
73 /** Gets a live view on an Uint16Array's values in the module's memory. */
74 __getUint16ArrayView(ptr: number): Uint16Array;
75 /** Gets a live view on an Int32Array's values in the module's memory. */
76 __getInt32ArrayView(ptr: number): Int32Array;
77 /** Gets a live view on an Uint32Array's values in the module's memory. */
78 __getUint32ArrayView(ptr: number): Uint32Array;
79 /** Gets a live view on an Int32Array's values in the module's memory. */
80 __getInt64ArrayView?(ptr: number): BigInt64Array;
81 /** Gets a live view on an Uint32Array's values in the module's memory. */
82 __getUint64ArrayView?(ptr: number): BigUint64Array;
83 /** Gets a live view on a Float32Array's values in the module's memory. */
84 __getFloat32ArrayView(ptr: number): Float32Array;
85 /** Gets a live view on a Float64Array's values in the module's memory. */
86 __getFloat64ArrayView(ptr: number): Float64Array;
87
88 /** Retains a reference to a managed object externally, making sure that it doesn't become collected prematurely. Returns the pointer. */
89 __retain(ptr: number): number;
90 /** Releases a previously retained reference to a managed object, allowing the runtime to collect it once its reference count reaches zero. */
91 __release(ptr: number): void;
92 /** Forcefully resets the heap to its initial offset, effectively clearing dynamic memory. Stub runtime only. */
93 __reset?(): void;
94 /** Allocates an instance of the class represented by the specified id. */
95 __alloc(size: number, id: number): number;
96 /** Tests whether a managed object is an instance of the class represented by the specified base id. */
97 __instanceof(ptr: number, baseId: number): boolean;
98 /** Forces a cycle collection. Only relevant if objects potentially forming reference cycles are used. */
99 __collect(): void;
100}
101
102/** Asynchronously instantiates an AssemblyScript module from anything that can be instantiated. */
103export declare function instantiate<T extends Record<string,unknown>>(
104 source: WebAssembly.Module | BufferSource | Response | PromiseLike<WebAssembly.Module | BufferSource | Response>,
105 imports?: Imports
106): Promise<ResultObject & { exports: ASUtil & T }>;
107
108/** Synchronously instantiates an AssemblyScript module from a WebAssembly.Module or binary buffer. */
109export declare function instantiateSync<T extends Record<string,unknown>>(
110 source: WebAssembly.Module | BufferSource,
111 imports?: Imports
112): ResultObject & { exports: ASUtil & T };
113
114/** Asynchronously instantiates an AssemblyScript module from a response, i.e. as obtained by `fetch`. */
115export declare function instantiateStreaming<T extends Record<string,unknown>>(
116 source: Response | PromiseLike<Response>,
117 imports?: Imports
118): Promise<ResultObject & { exports: ASUtil & T }>;
119
120/** Demangles an AssemblyScript module's exports to a friendly object structure. */
121export declare function demangle<T extends Record<string,unknown>>(
122 exports: Record<string,unknown>,
123 extendedExports?: Record<string,unknown>
124): T;
Note: See TracBrowser for help on using the repository browser.