emscripten-wasm-loader
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -0,1 +1,6 @@ | ||
<a name="1.1.0"></a> | ||
# [1.1.0](https://github.com/kwonoj/emscripten-wasm-loader/compare/v1.0.0...v1.1.0) (2018-10-17) | ||
<a name="1.0.0"></a> | ||
@@ -2,0 +7,0 @@ # [1.0.0](https://github.com/kwonoj/emscripten-wasm-loader/compare/v0.0.8...v1.0.0) (2017-11-29) |
@@ -14,2 +14,8 @@ import { AsmRuntimeType, StringMap } from './constructModule'; | ||
/** | ||
* Initialization options given to `getModuleLoader` | ||
*/ | ||
interface ModuleInitOption { | ||
timeout: number; | ||
} | ||
/** | ||
* Type of runtime module function. This is node.js asm module loaded via plain `require`, | ||
@@ -26,3 +32,3 @@ * internally emscripten should compile with MODULARIZE=1 option to loaded module via require returns | ||
declare type runtimeModuleType = (moduleObject: StringMap) => AsmRuntimeType; | ||
declare type getModuleLoaderType = <T, R extends AsmRuntimeType>(factoryLoader: (runtime: R, environment: ENVIRONMENT) => T, runtimeModule: runtimeModuleType, module?: StringMap) => moduleLoaderType<T>; | ||
declare type getModuleLoaderType = <T, R extends AsmRuntimeType>(factoryLoader: (runtime: R, environment: ENVIRONMENT) => T, runtimeModule: runtimeModuleType, module?: StringMap, {timeout}?: Partial<ModuleInitOption>) => moduleLoaderType<T>; | ||
/** | ||
@@ -39,5 +45,7 @@ * Creates loader function to load and initialize wasm module. | ||
* | ||
* @param {ModuleInitOption} [initOptions] Configuration used to initialize the module | ||
* | ||
* @returns {moduleLoaderType<T>} Loader function | ||
*/ | ||
declare const getModuleLoader: getModuleLoaderType; | ||
export { runtimeModuleType, moduleLoaderType, getModuleLoaderType, getModuleLoader }; | ||
export { ModuleInitOption, runtimeModuleType, moduleLoaderType, getModuleLoaderType, getModuleLoader }; |
@@ -20,31 +20,36 @@ "use strict"; | ||
* | ||
* @param {ModuleInitOption} [initOptions] Configuration used to initialize the module | ||
* | ||
* @returns {moduleLoaderType<T>} Loader function | ||
*/ | ||
var getModuleLoader = function (factoryLoader, runtimeModule, module) { return function (environment) { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
var env, constructedModule, asmModule, e_1; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
env = environment ? environment : isNode_1.isNode() ? environment_1.ENVIRONMENT.NODE : environment_1.ENVIRONMENT.WEB; | ||
logger_1.log("loadModule: " + (environment ? "using environment override " + environment : "running environment is " + env)); | ||
constructedModule = constructModule_1.constructModule(module || {}, env); | ||
logger_1.log("loadModule: constructed module object for runtime"); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
asmModule = runtimeModule(constructedModule); | ||
return [4 /*yield*/, asmModule.initializeRuntime()]; | ||
case 2: | ||
_a.sent(); | ||
logger_1.log("loadModule: initialized wasm binary Runtime"); | ||
return [2 /*return*/, factoryLoader(asmModule, env)]; | ||
case 3: | ||
e_1 = _a.sent(); | ||
logger_1.log("loadModule: failed to initialize wasm binary runtime"); | ||
throw e_1; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; }; | ||
var getModuleLoader = function (factoryLoader, runtimeModule, module, _a) { | ||
var timeout = (_a === void 0 ? {} : _a).timeout; | ||
return function (environment) { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
var env, constructedModule, asmModule, e_1; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
env = environment ? environment : isNode_1.isNode() ? environment_1.ENVIRONMENT.NODE : environment_1.ENVIRONMENT.WEB; | ||
logger_1.log("loadModule: " + (environment ? "using environment override " + environment : "running environment is " + env)); | ||
constructedModule = constructModule_1.constructModule(module || {}, env); | ||
logger_1.log("loadModule: constructed module object for runtime"); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
asmModule = runtimeModule(constructedModule); | ||
return [4 /*yield*/, asmModule.initializeRuntime(timeout)]; | ||
case 2: | ||
_a.sent(); | ||
logger_1.log("loadModule: initialized wasm binary Runtime"); | ||
return [2 /*return*/, factoryLoader(asmModule, env)]; | ||
case 3: | ||
e_1 = _a.sent(); | ||
logger_1.log("loadModule: failed to initialize wasm binary runtime"); | ||
throw e_1; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
}; | ||
exports.getModuleLoader = getModuleLoader; | ||
//# sourceMappingURL=getModuleLoader.js.map |
{ | ||
"name": "emscripten-wasm-loader", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Common interface to load wasm module into isomorphic environment", | ||
@@ -5,0 +5,0 @@ "main": "./dist/src/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26442
342