mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-05-29 15:44:31 +00:00
emscripten: update module api to 1.37.10 (#16310)
* Add type aliases for imports and exports * Update emscripten Module API to 1.37.10
This commit is contained in:
committed by
Mohamed Hegazy
parent
c4a2a2a976
commit
5fc2f8c670
@@ -1,8 +1,20 @@
|
||||
|
||||
|
||||
|
||||
/// Module
|
||||
function ModuleTest(): void {
|
||||
Module.environment = "WEB";
|
||||
Module.environment = "NODE";
|
||||
Module.noInitialRun = false;
|
||||
Module.logReadFiles = false;
|
||||
Module.filePackagePrefixURL = "http://www.example.org/";
|
||||
Module.preinitializedWebGLContext = new WebGLRenderingContext();
|
||||
|
||||
let package: ArrayBuffer = Module.getPreloadedPackage("package-name", 100);
|
||||
let exports: WebAssembly.Exports = Module.instantiateWasm(
|
||||
[{name: "func-name", kind: "function"}],
|
||||
(module: WebAssembly.Module) => {}
|
||||
);
|
||||
let memFile: string = Module.locateFile("http://www.example.org/file.mem");
|
||||
Module.onCustomMessage(new MessageEvent("TestType"));
|
||||
|
||||
Module.print = function(text) { alert('stdout: ' + text) };
|
||||
|
||||
var int_sqrt = Module.cwrap('int_sqrt', 'number', ['number'])
|
||||
@@ -16,6 +28,7 @@ function ModuleTest(): void {
|
||||
Module.HEAPU8.set(myTypedArray, buf);
|
||||
Module.ccall('my_function', 'number', ['number'], [buf]);
|
||||
Module._free(buf);
|
||||
Module.destroy({});
|
||||
}
|
||||
|
||||
/// FS
|
||||
|
||||
23
types/emscripten/index.d.ts
vendored
23
types/emscripten/index.d.ts
vendored
@@ -1,7 +1,11 @@
|
||||
// Type definitions for Emscripten
|
||||
// Project: http://kripken.github.io/emscripten-site/index.html
|
||||
// Definitions by: Kensuke Matsuzaki <https://github.com/zakki>
|
||||
// Periklis Tsirakidis <https://github.com/periklis>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/// <reference types="webassembly-js-api" />
|
||||
|
||||
declare namespace Emscripten {
|
||||
interface FileSystemType {
|
||||
@@ -9,13 +13,30 @@ declare namespace Emscripten {
|
||||
}
|
||||
|
||||
declare namespace Module {
|
||||
type EnvironmentType = "WEB" | "NODE" | "SHELL" | "WORKER";
|
||||
|
||||
function print(str: string): void;
|
||||
function printErr(str: string): void;
|
||||
var arguments: string[];
|
||||
var environment: EnvironmentType;
|
||||
var preInit: { (): void }[];
|
||||
var preRun: { (): void }[];
|
||||
var postRun: { (): void }[];
|
||||
var preinitializedWebGLContext: WebGLRenderingContext;
|
||||
var noInitialRun: boolean;
|
||||
var noExitRuntime: boolean;
|
||||
var logReadFiles: boolean;
|
||||
var filePackagePrefixURL: string;
|
||||
var wasmBinary: ArrayBuffer;
|
||||
|
||||
function destroy(object: object): void;
|
||||
function getPreloadedPackage(remotePackageName: string, remotePackageSize: number): ArrayBuffer;
|
||||
function instantiateWasm(
|
||||
imports: WebAssembly.Imports,
|
||||
successCallback: (module: WebAssembly.Module) => void
|
||||
): WebAssembly.Exports;
|
||||
function locateFile(url: string): string;
|
||||
function onCustomMessage(event: MessageEvent): void;
|
||||
|
||||
var Runtime: any;
|
||||
|
||||
@@ -65,7 +86,7 @@ declare namespace Module {
|
||||
function addOnExit(cb: () => any): void;
|
||||
function addOnPostRun(cb: () => any): void;
|
||||
|
||||
// Tools
|
||||
// Tools
|
||||
function intArrayFromString(stringy: string, dontAddNull?: boolean, length?: number): number[];
|
||||
function intArrayToString(array: number[]): string;
|
||||
function writeStringToMemory(str: string, buffer: number, dontAddNull: boolean): void;
|
||||
|
||||
26
types/webassembly-js-api/index.d.ts
vendored
26
types/webassembly-js-api/index.d.ts
vendored
@@ -1,6 +1,8 @@
|
||||
// Type definitions for WebAssembly v1 (MVP)
|
||||
// Project: https://github.com/winksaville/test-webassembly-js-ts
|
||||
// Definitions by: 01alchemist <https://twitter.com/01alchemist>, Wink Saville <wink@saville.com>
|
||||
// Definitions by: 01alchemist <https://twitter.com/01alchemist>
|
||||
// Wink Saville <wink@saville.com>
|
||||
// Periklis Tsirakidis <https://github.com/periklis>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
@@ -9,21 +11,25 @@
|
||||
* for more information.
|
||||
*/
|
||||
declare namespace WebAssembly {
|
||||
type Imports = Array<{
|
||||
name: string;
|
||||
kind: string;
|
||||
}>;
|
||||
|
||||
type Exports = Array<{
|
||||
module: string;
|
||||
name: string;
|
||||
kind: string;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* WebAssembly.Module
|
||||
*/
|
||||
class Module {
|
||||
constructor(bufferSource: ArrayBuffer | Uint8Array);
|
||||
static customSections(module: Module, sectionName: string): ArrayBuffer[];
|
||||
static exports(module: Module): Array<{
|
||||
name: string;
|
||||
kind: string;
|
||||
}>;
|
||||
static imports(module: Module): Array<{
|
||||
module: string;
|
||||
name: string;
|
||||
kind: string;
|
||||
}>;
|
||||
static exports(module: Module): Imports;
|
||||
static imports(module: Module): Exports;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user