Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yach-jsapi

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yach-jsapi - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

6

lib/api/biz/navigation/setMenu.d.ts

@@ -6,8 +6,12 @@ declare type item = {

};
export interface IBizNavigationSetMenuParams {
interface IBizNavigationSetMenuResult {
id: string;
}
interface IBizNavigationSetMenuParams {
backgroundColor?: string;
textColor?: string;
item?: item[];
onSuccess?: (data: IBizNavigationSetMenuResult) => void;
}
declare function setMenu(p: IBizNavigationSetMenuParams): void;
export { setMenu };

10

lib/api/biz/navigation/setMenu.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var apiHelper_1 = require("../../../lib/sdk/apiHelper");
var apiName = "biz.navigation.setMenu";
var yachSdk_1 = require("../../../lib/yachSdk");
var paramsDeal = apiHelper_1.genDefaultParamsDealFn({
control: true
});
var ios = {
vs: "0.0.0"
vs: "0.0.0",
paramsDeal: paramsDeal
};
var android = {
vs: "0.0.0"
vs: "0.0.0",
paramsDeal: paramsDeal
};

@@ -11,0 +17,0 @@ function setMenu(p) {

"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -24,15 +35,29 @@ function setupWebViewJavascriptBridge(callback) {

return new Promise(function (resolve, reject) {
var onSuccess = param.onSuccess, onFail = param.onFail;
var p = __assign({}, param);
setupWebViewJavascriptBridge(function (bridge) {
if (param.control) {
bridge.registerHandler(method, function (data) {
var onSuccess = param.onSuccess;
delete p.onSuccess;
if ("function" === typeof onSuccess) {
onSuccess(data);
resolve({ errorCode: "0", errorMessage: "success" });
}
});
}
bridge.callHandler(method, param, function () { return function (e) {
var code = e.code, message = e.message;
if (code === 0) {
onSuccess(message);
resolve(message);
}
else if (code === -1) {
var errorCode = e.errorCode, errorMessage = e.errorMessage, data = e.data;
if (errorCode === '0') {
// 调用成功,返回消息
onFail(message);
reject(message);
if ("function" === typeof p.onSuccess) {
p.onSuccess(data);
}
resolve({ errorCode: errorCode, errorMessage: errorMessage });
}
else {
if ("function" === typeof p.onFail) {
p.onFail(data);
}
reject({ errorCode: errorCode, errorMessage: errorMessage });
}
}; });

@@ -39,0 +64,0 @@ });

@@ -11,8 +11,10 @@ "use strict";

return new Promise(function (resolve, reject) {
return pc_iframe_1.default.invokeAPI(method, param).result.then(function (e) {
onSuccess(e);
resolve(e);
}, function (e) {
onFail(e);
reject(e);
return pc_iframe_1.default.invokeAPI(method, param).result.then(function (_a) {
var data = _a.data, errorCode = _a.errorCode, errorMessage = _a.errorMessage;
onSuccess(data);
resolve({ errorCode: errorCode, errorMessage: errorMessage });
}, function (_a) {
var data = _a.data, errorCode = _a.errorCode, errorMessage = _a.errorMessage;
onFail(data);
reject({ errorCode: errorCode, errorMessage: errorMessage });
});

@@ -19,0 +21,0 @@ });

@@ -21,3 +21,3 @@ export default frame;

genid: () => string;
receiveResponse: (value: any, result: any) => void;
receiveResponse: (data: any) => void;
getPayload: () => {

@@ -24,0 +24,0 @@ msgId: string;

@@ -12,4 +12,5 @@ "use strict";

};
this.receiveResponse = function (value, result) {
result ? _this.PromiseObj.resolve(value) : _this.PromiseObj.reject(value);
this.receiveResponse = function (data) {
// 判断是否success
data.errorCode === '0' ? _this.PromiseObj.resolve(data) : _this.PromiseObj.reject(data);
};

@@ -63,4 +64,4 @@ this.getPayload = function () {

console.log(msg, 'recieve');
var data = msg.data || {};
var type = data.type;
var datas = msg.data || {};
var type = datas.type;
switch (type) {

@@ -75,3 +76,3 @@ case 'request':

}*/
var methodName = data.methodName;
var methodName = datas.methodName;
if (methodName === 'refresh') {

@@ -95,5 +96,5 @@ window.location.reload();

}*/
var msgId = data.msgId, body = data.body, success = data.success;
var msgId = datas.msgId, data = datas.data, errorCode = datas.errorCode, errorMessage = datas.errorMessage;
var i = _this.getMsyById(msgId);
i && i.receiveResponse(body, success);
i && i.receiveResponse({ data: data, errorCode: errorCode, errorMessage: errorMessage });
_this.deletePending(msgId);

@@ -100,0 +101,0 @@ }

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

}).catch(function (error) {
// 调用失败(方法错误,未鉴权,上层返回的)
// 调用失败
});

@@ -94,0 +94,0 @@ });

@@ -37,6 +37,7 @@ export declare enum ENV_ENUM {

}
/** jsbridgehui回调函数 TODO:之后会全部统一 */
/** jsbridgehui回调函数 */
export declare type mobileCallback = (e: {
code: number;
message: string;
errorCode: string;
errorMessage: string;
data?: Object;
}) => void;

@@ -43,0 +44,0 @@ /** 定义主方法 */

{
"name": "yach-jsapi",
"version": "1.0.8",
"version": "1.0.9",
"description": "",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc