@polywrap/wasm-js
Advanced tools
Comparing version
@@ -43,2 +43,3 @@ "use strict"; | ||
var msgpack_js_1 = require("@polywrap/msgpack-js"); | ||
var core_js_1 = require("@polywrap/core-js"); | ||
var createImports = function (config) { | ||
@@ -61,3 +62,3 @@ var memory = config.memory, state = config.state, client = config.client, abortWithInvokeAborted = config.abortWithInvokeAborted, abortWithInternalError = config.abortWithInternalError; | ||
return [4 /*yield*/, client.invoke({ | ||
uri: uri, | ||
uri: core_js_1.Uri.from(uri), | ||
method: method, | ||
@@ -124,3 +125,3 @@ args: new Uint8Array(args), | ||
return [4 /*yield*/, client.invoke({ | ||
uri: implUri, | ||
uri: core_js_1.Uri.from(implUri), | ||
method: method, | ||
@@ -198,3 +199,3 @@ args: new Uint8Array(args), | ||
uri = buffer_1.readString(memory.buffer, uriPtr, uriLen); | ||
return [4 /*yield*/, client.getImplementations(uri, {})]; | ||
return [4 /*yield*/, client.getImplementations(core_js_1.Uri.from(uri), {})]; | ||
case 1: | ||
@@ -206,3 +207,3 @@ result = _b.sent(); | ||
} | ||
implementations = result.value; | ||
implementations = result.value.map(function (i) { return i.uri; }); | ||
state.getImplementationsResult = msgpack_js_1.msgpackEncode(implementations); | ||
@@ -209,0 +210,0 @@ return [2 /*return*/, implementations.length > 0]; |
@@ -7,4 +7,4 @@ import { IFileReader } from "./IFileReader"; | ||
export declare class WasmPackage implements IWasmPackage { | ||
private readonly fileReader; | ||
constructor(fileReader: IFileReader); | ||
private readonly _fileReader; | ||
constructor(_fileReader: IFileReader); | ||
static from(manifestBuffer: Uint8Array, wasmModule: Uint8Array): WasmPackage; | ||
@@ -11,0 +11,0 @@ static from(manifestBuffer: Uint8Array, wasmModule: Uint8Array, fileReader: IFileReader): WasmPackage; |
@@ -46,4 +46,4 @@ "use strict"; | ||
var WasmPackage = /** @class */ (function () { | ||
function WasmPackage(fileReader) { | ||
this.fileReader = fileReader; | ||
function WasmPackage(_fileReader) { | ||
this._fileReader = _fileReader; | ||
} | ||
@@ -58,3 +58,3 @@ WasmPackage.from = function (manifestBufferOrFileReader, wasmModuleOrFileReader, fileReader) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, this.fileReader.readFile(constants_1.WRAP_MANIFEST_PATH)]; | ||
case 0: return [4 /*yield*/, this._fileReader.readFile(constants_1.WRAP_MANIFEST_PATH)]; | ||
case 1: | ||
@@ -85,3 +85,3 @@ result = _b.sent(); | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fileReader.readFile(constants_1.WRAP_MODULE_PATH)]; | ||
case 0: return [4 /*yield*/, this._fileReader.readFile(constants_1.WRAP_MODULE_PATH)]; | ||
case 1: | ||
@@ -108,3 +108,3 @@ result = _a.sent(); | ||
} | ||
return [2 /*return*/, result_1.ResultOk(new WasmWrapper_1.WasmWrapper(result.value, this.fileReader))]; | ||
return [2 /*return*/, result_1.ResultOk(new WasmWrapper_1.WasmWrapper(result.value, this._fileReader))]; | ||
} | ||
@@ -111,0 +111,0 @@ }); |
import { IFileReader } from "./IFileReader"; | ||
import { WrapManifest } from "@polywrap/wrap-manifest-types-js"; | ||
import { CoreClient, GetFileOptions, GetManifestOptions, InvocableResult, InvokeOptions, Uri, Wrapper } from "@polywrap/core-js"; | ||
import { CoreClient, GetFileOptions, GetManifestOptions, InvocableResult, InvokeOptions, Wrapper } from "@polywrap/core-js"; | ||
import { Result } from "@polywrap/result"; | ||
@@ -38,5 +38,5 @@ export interface State { | ||
getManifest(): WrapManifest; | ||
invoke(options: InvokeOptions<Uri>, client: CoreClient): Promise<InvocableResult<Uint8Array>>; | ||
invoke(options: InvokeOptions, client: CoreClient): Promise<InvocableResult<Uint8Array>>; | ||
private _processInvokeResult; | ||
private _getWasmModule; | ||
} |
@@ -13,8 +13,2 @@ "use strict"; | ||
}; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -62,3 +56,2 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
var msgpack_js_1 = require("@polywrap/msgpack-js"); | ||
var tracing_js_1 = require("@polywrap/tracing-js"); | ||
var asyncify_js_1 = require("@polywrap/asyncify-js"); | ||
@@ -72,8 +65,2 @@ var core_js_1 = require("@polywrap/core-js"); | ||
this._fileReader = _fileReader; | ||
tracing_js_1.Tracer.startSpan("WasmWrapper: constructor"); | ||
tracing_js_1.Tracer.setAttribute("args", { | ||
manifest: this._manifest, | ||
fileReader: this._fileReader, | ||
}); | ||
tracing_js_1.Tracer.endSpan(); | ||
} | ||
@@ -125,10 +112,7 @@ WasmWrapper.from = function (manifestBufferOrFileReader, wasmModuleOrFileReaderOrManifestOptions, fileReaderOrManifestOptions, manifestOptions) { | ||
case 0: | ||
tracing_js_1.Tracer.setAttribute("label", "WASM Wrapper invoked: " + options.uri.uri + ", with method " + options.method, tracing_js_1.TracingLevel.High); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 5, , 6]); | ||
_a.trys.push([0, 4, , 5]); | ||
method_1 = options.method; | ||
args_1 = options.args || {}; | ||
return [4 /*yield*/, this._getWasmModule()]; | ||
case 2: | ||
case 1: | ||
wasmResult = _a.sent(); | ||
@@ -193,7 +177,7 @@ if (!wasmResult.ok) { | ||
})]; | ||
case 3: | ||
case 2: | ||
instance = _a.sent(); | ||
exports_1 = instance.exports; | ||
return [4 /*yield*/, exports_1._wrap_invoke(state.method.length, state.args.byteLength, state.env.byteLength)]; | ||
case 4: | ||
case 3: | ||
result = _a.sent(); | ||
@@ -213,7 +197,7 @@ invokeResult = this._processInvokeResult(state, result); | ||
} | ||
return [3 /*break*/, 6]; | ||
case 5: | ||
return [3 /*break*/, 5]; | ||
case 4: | ||
error_1 = _a.sent(); | ||
return [2 /*return*/, result_1.ResultErr(error_1)]; | ||
case 6: return [2 /*return*/]; | ||
case 5: return [2 /*return*/]; | ||
} | ||
@@ -258,17 +242,2 @@ }); | ||
WasmWrapper.requiredExports = ["_wrap_invoke"]; | ||
__decorate([ | ||
tracing_js_1.Tracer.traceMethod("WasmWrapper: getFile") | ||
], WasmWrapper.prototype, "getFile", null); | ||
__decorate([ | ||
tracing_js_1.Tracer.traceMethod("WasmWrapper: getManifest") | ||
], WasmWrapper.prototype, "getManifest", null); | ||
__decorate([ | ||
tracing_js_1.Tracer.traceMethod("WasmWrapper: invoke", tracing_js_1.TracingLevel.High) | ||
], WasmWrapper.prototype, "invoke", null); | ||
__decorate([ | ||
tracing_js_1.Tracer.traceMethod("WasmWrapper: _processInvokeResult") | ||
], WasmWrapper.prototype, "_processInvokeResult", null); | ||
__decorate([ | ||
tracing_js_1.Tracer.traceMethod("WasmWrapper: getWasmModule") | ||
], WasmWrapper.prototype, "_getWasmModule", null); | ||
return WasmWrapper; | ||
@@ -275,0 +244,0 @@ }()); |
{ | ||
"name": "@polywrap/wasm-js", | ||
"description": "Polywrap WASM wrappers", | ||
"version": "0.10.0-pre.7", | ||
"version": "0.10.0-pre.8", | ||
"license": "MIT", | ||
@@ -22,8 +22,8 @@ "repository": { | ||
"dependencies": { | ||
"@polywrap/asyncify-js": "0.10.0-pre.7", | ||
"@polywrap/core-js": "0.10.0-pre.7", | ||
"@polywrap/msgpack-js": "0.10.0-pre.7", | ||
"@polywrap/result": "0.10.0-pre.7", | ||
"@polywrap/tracing-js": "0.10.0-pre.7", | ||
"@polywrap/wrap-manifest-types-js": "0.10.0-pre.7" | ||
"@polywrap/asyncify-js": "0.10.0-pre.8", | ||
"@polywrap/core-js": "0.10.0-pre.8", | ||
"@polywrap/msgpack-js": "0.10.0-pre.8", | ||
"@polywrap/result": "0.10.0-pre.8", | ||
"@polywrap/tracing-js": "0.10.0-pre.8", | ||
"@polywrap/wrap-manifest-types-js": "0.10.0-pre.8" | ||
}, | ||
@@ -30,0 +30,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
74058
-2.83%1024
-2.85%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed