emscripten-wasm-loader
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -0,1 +1,12 @@ | ||
<a name="0.0.7"></a> | ||
## [0.0.7](https://github.com/kwonoj/emscripten-wasm-loader/compare/v0.0.6...v0.0.7) (2017-09-17) | ||
### Features | ||
* **constructmodule:** wire onAbort callback ([6440650](https://github.com/kwonoj/emscripten-wasm-loader/commit/6440650)) | ||
* **loadmodule:** enhance error handling ([4f3004f](https://github.com/kwonoj/emscripten-wasm-loader/commit/4f3004f)) | ||
<a name="0.0.6"></a> | ||
@@ -2,0 +13,0 @@ ## [0.0.6](https://github.com/kwonoj/emscripten-wasm-loader/compare/v0.0.5...v0.0.6) (2017-09-17) |
@@ -23,3 +23,3 @@ import { ENVIRONMENT } from './environment'; | ||
locateFile: (fileName: string) => string; | ||
initializeRuntime: () => Promise<boolean>; | ||
initializeRuntime: (timeout?: number | undefined) => Promise<boolean>; | ||
}; |
@@ -44,10 +44,14 @@ "use strict"; | ||
//export initializeRuntime interface for awaitable runtime initialization | ||
ret.initializeRuntime = function () { | ||
ret.initializeRuntime = function (timeout) { | ||
if (timeout === void 0) { timeout = 3000; } | ||
if (ret.__asm_module_isInitialized__) { | ||
return Promise.resolve(true); | ||
} | ||
return new Promise(function (resolve, _reject) { | ||
var timeoutId = setTimeout(function () { | ||
resolve(false); | ||
}, 3000); | ||
return new Promise(function (resolve, reject) { | ||
var timeoutId = setTimeout(function () { return resolve(false); }, timeout); | ||
ret.onAbort = function (reason) { | ||
clearTimeout(timeoutId); | ||
logger_1.log("initializeRuntime: failed to initialize module", reason); | ||
reject(reason instanceof Error ? reason : new Error(reason)); | ||
}; | ||
ret.onRuntimeInitialized = function () { | ||
@@ -54,0 +58,0 @@ clearTimeout(timeoutId); |
@@ -24,3 +24,3 @@ "use strict"; | ||
var getModuleLoader = function (factoryLoader, asm, module) { return function (binaryEndpoint, environment) { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
var env, asmBinaryDir, constructedModule, asmModule; | ||
var env, asmBinaryDir, constructedModule, asmModule, e_1; | ||
return tslib_1.__generator(this, function (_a) { | ||
@@ -37,9 +37,17 @@ switch (_a.label) { | ||
constructedModule = constructModule_1.constructModule(module || {}, env, asmBinaryDir, binaryEndpoint); | ||
logger_1.log("loadModule: module object for asm runtime constructed"); | ||
logger_1.log("loadModule: constructed module object for runtime"); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
asmModule = asm.runtimeModule(constructedModule); | ||
return [4 /*yield*/, asmModule.initializeRuntime()]; | ||
case 1: | ||
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*/]; | ||
} | ||
@@ -46,0 +54,0 @@ }); |
{ | ||
"name": "emscripten-wasm-loader", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"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
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
29817
374