New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@polywrap/wasm-js

Package Overview
Dependencies
Maintainers
2
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@polywrap/wasm-js - npm Package Compare versions

Comparing version

to
0.9.5

5

build/imports.d.ts
import { WrapImports } from "./types";
import { State } from "./WasmWrapper";
import { Client } from "@polywrap/core-js";
import { Client, ErrorSource } from "@polywrap/core-js";
export declare const createImports: (config: {

@@ -8,3 +8,4 @@ client: Client;

state: State;
abort: (message: string) => never;
abortWithInvokeAborted: (message: string, source: ErrorSource) => never;
abortWithInternalError: (message: string) => never;
}) => WrapImports;

34

build/imports.js

@@ -44,3 +44,3 @@ "use strict";

var createImports = function (config) {
var memory = config.memory, state = config.state, client = config.client, abort = config.abort;
var memory = config.memory, state = config.state, client = config.client, abortWithInvokeAborted = config.abortWithInvokeAborted, abortWithInternalError = config.abortWithInternalError;
return {

@@ -81,3 +81,3 @@ wrap: {

if (!state.subinvoke.result) {
abort("__wrap_subinvoke_result_len: subinvoke.result is not set");
abortWithInternalError("__wrap_subinvoke_result_len: subinvoke.result is not set");
return 0;

@@ -90,3 +90,3 @@ }

if (!state.subinvoke.result) {
abort("__wrap_subinvoke_result: subinvoke.result is not set");
abortWithInternalError("__wrap_subinvoke_result: subinvoke.result is not set");
return;

@@ -99,3 +99,3 @@ }

if (!state.subinvoke.error) {
abort("__wrap_subinvoke_error_len: subinvoke.error is not set");
abortWithInternalError("__wrap_subinvoke_error_len: subinvoke.error is not set");
return 0;

@@ -108,3 +108,3 @@ }

if (!state.subinvoke.error) {
abort("__wrap_subinvoke_error: subinvoke.error is not set");
abortWithInternalError("__wrap_subinvoke_error: subinvoke.error is not set");
return;

@@ -146,3 +146,3 @@ }

if (!state.subinvokeImplementation.result) {
abort("__wrap_subinvokeImplementation_result_len: subinvokeImplementation.result is not set");
abortWithInternalError("__wrap_subinvokeImplementation_result_len: subinvokeImplementation.result is not set");
return 0;

@@ -154,3 +154,3 @@ }

if (!state.subinvokeImplementation.result) {
abort("__wrap_subinvokeImplementation_result: subinvokeImplementation.result is not set");
abortWithInternalError("__wrap_subinvokeImplementation_result: subinvokeImplementation.result is not set");
return;

@@ -162,3 +162,3 @@ }

if (!state.subinvokeImplementation.error) {
abort("__wrap_subinvokeImplementation_error_len: subinvokeImplementation.error is not set");
abortWithInternalError("__wrap_subinvokeImplementation_error_len: subinvokeImplementation.error is not set");
return 0;

@@ -170,3 +170,3 @@ }

if (!state.subinvokeImplementation.error) {
abort("__wrap_subinvokeImplementation_error: subinvokeImplementation.error is not set");
abortWithInternalError("__wrap_subinvokeImplementation_error: subinvokeImplementation.error is not set");
return;

@@ -179,7 +179,7 @@ }

if (!state.method) {
abort("__wrap_invoke_args: method is not set");
abortWithInternalError("__wrap_invoke_args: method is not set");
return;
}
if (!state.args) {
abort("__wrap_invoke_args: args is not set");
abortWithInternalError("__wrap_invoke_args: args is not set");
return;

@@ -203,3 +203,3 @@ }

if (!result.ok) {
abort((_a = result.error) === null || _a === void 0 ? void 0 : _a.message);
abortWithInternalError((_a = result.error) === null || _a === void 0 ? void 0 : _a.message);
return false;

@@ -213,3 +213,3 @@ }

if (!state.getImplementationsResult) {
abort("__wrap_getImplementations_result_len: result is not set");
abortWithInternalError("__wrap_getImplementations_result_len: result is not set");
return 0;

@@ -221,3 +221,3 @@ }

if (!state.getImplementationsResult) {
abort("__wrap_getImplementations_result: result is not set");
abortWithInternalError("__wrap_getImplementations_result: result is not set");
return;

@@ -233,3 +233,7 @@ }

var file = buffer_1.readString(memory.buffer, filePtr, fileLen);
abort("__wrap_abort: " + msg + "\nFile: " + file + "\nLocation: [" + line + "," + column + "]");
abortWithInvokeAborted("__wrap_abort: " + msg, {
file: file,
row: line,
col: column,
});
},

@@ -236,0 +240,0 @@ __wrap_debug_log: function (ptr, len) {

@@ -54,3 +54,3 @@ "use strict";

return __awaiter(this, void 0, void 0, function () {
var result, wrapManifest, _a;
var result, wrapManifest, _a, e_1;
return __generator(this, function (_b) {

@@ -65,5 +65,12 @@ switch (_b.label) {

wrapManifest = result.value;
_b.label = 2;
case 2:
_b.trys.push([2, 4, , 5]);
_a = result_1.ResultOk;
return [4 /*yield*/, wrap_manifest_types_js_1.deserializeWrapManifest(wrapManifest, options)];
case 2: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];
case 3: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];
case 4:
e_1 = _b.sent();
return [2 /*return*/, result_1.ResultErr(e_1)];
case 5: return [2 /*return*/];
}

@@ -70,0 +77,0 @@ });

@@ -117,12 +117,11 @@ "use strict";

WasmWrapper.prototype.invoke = function (options, client) {
var _a;
return __awaiter(this, void 0, void 0, function () {
var method_1, args_1, wasmResult, wasm, state, abort, memory, instance, exports_1, result, invokeResult, error, error_1;
return __generator(this, function (_b) {
switch (_b.label) {
var method_1, args_1, wasmResult, error, wasm, state, abortWithInvokeAborted, abortWithInternalError, memory, instance, exports_1, result, invokeResult, error, error_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
tracing_js_1.Tracer.setAttribute("label", "WASM Wrapper invoked: " + options.uri.uri + ", with method " + options.method, tracing_js_1.TracingLevel.High);
_b.label = 1;
_a.label = 1;
case 1:
_b.trys.push([1, 5, , 6]);
_a.trys.push([1, 5, , 6]);
method_1 = options.method;

@@ -132,5 +131,11 @@ args_1 = options.args || {};

case 2:
wasmResult = _b.sent();
wasmResult = _a.sent();
if (!wasmResult.ok) {
return [2 /*return*/, wasmResult];
error = new core_js_1.WrapError(wasmResult.error, {
code: core_js_1.WrapErrorCode.WRAPPER_READ_FAIL,
uri: options.uri.uri,
method: method_1,
args: JSON.stringify(args_1, null, 2),
});
return [2 /*return*/, result_1.ResultErr(error)];
}

@@ -154,7 +159,22 @@ wasm = wasmResult.value;

};
abort = function (message) {
throw Error("WasmWrapper: Wasm module aborted execution.\nURI: " + options.uri.uri + "\n" +
("Method: " + method_1 + "\n") +
("Args: " + JSON.stringify(args_1, null, 2) + "\nMessage: " + message + ".\n"));
abortWithInvokeAborted = function (message, source) {
var prev = core_js_1.WrapError.parse(message);
var text = prev ? "SubInvocation exception encountered" : message;
throw new core_js_1.WrapError(text, {
code: core_js_1.WrapErrorCode.WRAPPER_INVOKE_ABORTED,
uri: options.uri.uri,
method: method_1,
args: JSON.stringify(args_1, null, 2),
source: source,
innerError: prev,
});
};
abortWithInternalError = function (message) {
throw new core_js_1.WrapError(message, {
code: core_js_1.WrapErrorCode.WRAPPER_INTERNAL_ERROR,
uri: options.uri.uri,
method: method_1,
args: JSON.stringify(args_1, null, 2),
});
};
memory = asyncify_js_1.AsyncWasmInstance.createMemory({ module: wasm });

@@ -167,3 +187,4 @@ return [4 /*yield*/, asyncify_js_1.AsyncWasmInstance.createInstance({

memory: memory,
abort: abort,
abortWithInvokeAborted: abortWithInvokeAborted,
abortWithInternalError: abortWithInternalError,
}),

@@ -173,8 +194,8 @@ requiredExports: WasmWrapper.requiredExports,

case 3:
instance = _b.sent();
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:
result = _b.sent();
invokeResult = this._processInvokeResult(state, result, abort);
result = _a.sent();
invokeResult = this._processInvokeResult(state, result);
if (invokeResult.ok) {

@@ -184,7 +205,8 @@ return [2 /*return*/, __assign(__assign({}, invokeResult), { encoded: true })];

else {
error = Error("WasmWrapper: invocation exception encountered.\n" +
("uri: " + options.uri.uri + "\n") +
("method: " + method_1 + "\n") +
("args: " + JSON.stringify(args_1, null, 2) + "\n") +
("exception: " + ((_a = invokeResult.error) === null || _a === void 0 ? void 0 : _a.message)));
error = new core_js_1.WrapError(invokeResult.error, {
code: core_js_1.WrapErrorCode.WRAPPER_INVOKE_FAIL,
uri: options.uri.uri,
method: method_1,
args: JSON.stringify(args_1, null, 2),
});
return [2 /*return*/, result_1.ResultErr(error)];

@@ -194,3 +216,3 @@ }

case 5:
error_1 = _b.sent();
error_1 = _a.sent();
return [2 /*return*/, result_1.ResultErr(error_1)];

@@ -202,6 +224,6 @@ case 6: return [2 /*return*/];

};
WasmWrapper.prototype._processInvokeResult = function (state, result, abort) {
WasmWrapper.prototype._processInvokeResult = function (state, result) {
if (result) {
if (!state.invoke.result) {
abort("Invoke result is missing.");
return result_1.ResultErr("Invoke result is missing.");
}

@@ -212,5 +234,5 @@ return result_1.ResultOk(state.invoke.result);

if (!state.invoke.error) {
abort("Invoke error is missing.");
return result_1.ResultErr("Invoke error is missing.");
}
return result_1.ResultErr(Error(state.invoke.error));
return result_1.ResultErr(state.invoke.error);
}

@@ -229,3 +251,3 @@ };

if (!result.ok) {
return [2 /*return*/, result_1.ResultErr(Error("Wrapper does not contain a wasm module"))];
return [2 /*return*/, result_1.ResultErr("Wrapper does not contain a wasm module")];
}

@@ -232,0 +254,0 @@ this._wasmModule = result.value;

{
"name": "@polywrap/wasm-js",
"description": "Polywrap WASM wrappers",
"version": "0.9.4",
"version": "0.9.5",
"license": "MIT",

@@ -22,11 +22,11 @@ "repository": {

"dependencies": {
"@polywrap/asyncify-js": "0.9.4",
"@polywrap/core-js": "0.9.4",
"@polywrap/msgpack-js": "0.9.4",
"@polywrap/result": "0.9.4",
"@polywrap/tracing-js": "0.9.4",
"@polywrap/wrap-manifest-types-js": "0.9.4"
"@polywrap/asyncify-js": "0.9.5",
"@polywrap/core-js": "0.9.5",
"@polywrap/msgpack-js": "0.9.5",
"@polywrap/result": "0.9.5",
"@polywrap/tracing-js": "0.9.5",
"@polywrap/wrap-manifest-types-js": "0.9.5"
},
"devDependencies": {
"@polywrap/os-js": "0.9.4",
"@polywrap/os-js": "0.9.5",
"@types/jest": "26.0.8",

@@ -33,0 +33,0 @@ "jest": "26.6.3",

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