@polywrap/asyncify-js
Advanced tools
Comparing version 0.10.0-pre.8 to 0.10.0-pre.10
@@ -1,4 +0,4 @@ | ||
declare type WasmMemory = WebAssembly.Memory; | ||
declare type WasmExports = WebAssembly.Exports; | ||
declare type WasmImports = WebAssembly.Imports; | ||
type WasmMemory = WebAssembly.Memory; | ||
type WasmExports = WebAssembly.Exports; | ||
type WasmImports = WebAssembly.Imports; | ||
export declare class AsyncWasmInstance { | ||
@@ -5,0 +5,0 @@ static requiredExports: readonly string[]; |
@@ -17,3 +17,3 @@ "use strict"; | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -55,5 +55,10 @@ if (y = 0, t) op = [op[0] & 2, t.value]; | ||
}; | ||
var __spread = (this && this.__spread) || function () { | ||
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); | ||
return ar; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
@@ -95,4 +100,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
0x02, | ||
// limits ; https://github.com/sunfishcode/wasm-reference-manual/blob/master/WebAssembly.md#resizable-limits | ||
// limits ; flags | ||
// 0x??, | ||
// limits ; initial | ||
// 0x__, | ||
]); | ||
var sigIdx = utils_1.indexOfArray(config.module, envMemoryImportSignature); | ||
var sigIdx = (0, utils_1.indexOfArray)(config.module, envMemoryImportSignature); | ||
if (sigIdx < 0) { | ||
@@ -127,5 +137,5 @@ throw Error("Unable to find Wasm memory import section. " + | ||
exportKeys = Object.keys(instance._instance.exports); | ||
missingExports = __spread(AsyncWasmInstance.requiredExports, (config.requiredExports || [])).filter(function (name) { return !exportKeys.includes(name); }); | ||
missingExports = __spreadArray(__spreadArray([], __read(AsyncWasmInstance.requiredExports), false), __read((config.requiredExports || [])), false).filter(function (name) { return !exportKeys.includes(name); }); | ||
if (missingExports.length) { | ||
throw new Error("Required Wasm exports were not found: " + missingExports.join(", ")); | ||
throw new Error("Required Wasm exports were not found: ".concat(missingExports.join(", "))); | ||
} | ||
@@ -159,3 +169,3 @@ exports = instance._instance.exports; | ||
if (state !== AsyncifyState.None) { | ||
throw new Error("Invalid asyncify state " + state + ", expected 0."); | ||
throw new Error("Invalid asyncify state ".concat(state, ", expected 0.")); | ||
} | ||
@@ -165,7 +175,7 @@ }; | ||
var _this = this; | ||
return utils_1.proxyGet(imports, function (moduleImports, name) { | ||
return (0, utils_1.proxyGet)(imports, function (moduleImports, name) { | ||
if (moduleImports === undefined) { | ||
throw Error("Unsupported wasm import namespace requested: \"" + name + "\"; " + | ||
("Supported wasm import namespaces: " + Object.keys(imports) | ||
.map(function (x) { return "\"" + x + "\""; }) | ||
throw Error("Unsupported wasm import namespace requested: \"".concat(name, "\"; ") + | ||
"Supported wasm import namespaces: ".concat(Object.keys(imports) | ||
.map(function (x) { return "\"".concat(x, "\""); }) | ||
.join(", "))); | ||
@@ -178,7 +188,7 @@ } | ||
var _this = this; | ||
return utils_1.proxyGet(imports, function (importValue, name) { | ||
return (0, utils_1.proxyGet)(imports, function (importValue, name) { | ||
if (importValue === undefined) { | ||
throw Error("Unsupported wasm import requested: \"" + name + "\"; " + | ||
("Supported wasm imports: " + Object.keys(imports) | ||
.map(function (x) { return "\"" + x + "\""; }) | ||
throw Error("Unsupported wasm import requested: \"".concat(name, "\"; ") + | ||
"Supported wasm imports: ".concat(Object.keys(imports) | ||
.map(function (x) { return "\"".concat(x, "\""); }) | ||
.join(", "))); | ||
@@ -204,4 +214,4 @@ } | ||
_this._assertNoneState(); | ||
var value = importFn.apply(void 0, __spread(args)); | ||
if (!utils_1.isPromise(value)) { | ||
var value = importFn.apply(void 0, __spreadArray([], __read(args), false)); | ||
if (!(0, utils_1.isPromise)(value)) { | ||
return value; | ||
@@ -240,3 +250,3 @@ } | ||
this._assertNoneState(); | ||
result = exportFn.apply(void 0, __spread(args)); | ||
result = exportFn.apply(void 0, __spreadArray([], __read(args), false)); | ||
_b.label = 1; | ||
@@ -243,0 +253,0 @@ case 1: |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
@@ -1,4 +0,4 @@ | ||
export declare type MaybeAsync<T> = Promise<T> | T; | ||
export type MaybeAsync<T> = Promise<T> | T; | ||
export declare function isPromise<T extends unknown>(test?: MaybeAsync<T>): test is Promise<T>; | ||
export declare function proxyGet<T extends Record<string, unknown>>(obj: T, transform: (value: unknown, name: string) => unknown): T; | ||
export declare function indexOfArray(source: Uint8Array, search: Uint8Array): number; |
{ | ||
"name": "@polywrap/asyncify-js", | ||
"description": "Async Wasm Imports Support Using Asyncify", | ||
"version": "0.10.0-pre.8", | ||
"version": "0.10.0-pre.10", | ||
"license": "MIT", | ||
@@ -29,4 +29,4 @@ "repository": { | ||
"ts-loader": "8.0.17", | ||
"ts-node": "8.10.2", | ||
"typescript": "4.1.6" | ||
"ts-node": "10.9.1", | ||
"typescript": "4.9.5" | ||
}, | ||
@@ -33,0 +33,0 @@ "gitHead": "7346adaf5adb7e6bbb70d9247583e995650d390a", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
25017
373