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

@hylid/call

Package Overview
Dependencies
Maintainers
0
Versions
125
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hylid/call - npm Package Compare versions

Comparing version 3.2.0-alpha.2 to 3.2.0-alpha.4

lib/webviewBridge.d.ts

2

lib/mpWebCall.js

@@ -10,3 +10,3 @@ import { mpWebOnMessage, mpWebPostMessage } from "./mpWebBridge";

// 不是 jsapi 的调用的消息
if (message.type !== 'apiCall') return;
if (message.type && message.type !== 'apiCall') return;
if (!serialId) return;

@@ -13,0 +13,0 @@ if (!callMap[serialId]) return;

@@ -11,2 +11,3 @@ var __assign = this && this.__assign || function () {

};
import { __hy_internal__ } from "./internal";
import { callbackApi, getApiResult, isAllowed } from "./utils";

@@ -36,2 +37,3 @@ import { createMessage, createError } from "../utils";

this.jsApiHandler = function (data) {
var _a;
if (data.type !== 'apiCall') return;

@@ -45,8 +47,11 @@ var config = data.config,

}
var jsapi = ((_a = _this.config.customApi) === null || _a === void 0 ? void 0 : _a[api]) || {
__hy_internal__: __hy_internal__
}[api] || my[api];
if (type === 'callback') {
callbackApi(api, data, function (result) {
callbackApi(jsapi, data, function (result) {
return _this.sendMessage(data, result);
});
} else {
getApiResult(_this.config.customApi, data).then(function (result) {
getApiResult(jsapi, data).then(function (result) {
_this.sendMessage(data, result);

@@ -82,3 +87,3 @@ });

_this.bindCtxEvent(event, function (payload) {
return _this.sendMessage(data, createMessage(payload));
return _this.sendMessage(data, payload);
});

@@ -85,0 +90,0 @@ _this.context[event]._hy_listener_ = true;

@@ -1,4 +0,4 @@

import { MpWebJsApiMessage, CustomApi, MpWebMessageResult, WebviewBridgeConfig } from '../types';
export declare function callbackApi(apiName: string, jsapi: any, cb: (msg: MpWebMessageResult) => void): void;
export declare const getApiResult: (customApi: CustomApi | undefined, data: MpWebJsApiMessage) => Promise<MpWebMessageResult>;
import { MpWebJsApiMessage, MpWebMessageResult, WebviewBridgeConfig } from '../types';
export declare function callbackApi(jsapi: any, data: MpWebJsApiMessage, cb: (msg: MpWebMessageResult) => void): void;
export declare const getApiResult: (jsapi: any, data: MpWebJsApiMessage) => Promise<MpWebMessageResult>;
export declare function isAllowed(config: WebviewBridgeConfig, api: string): boolean;

@@ -127,3 +127,2 @@ var __assign = this && this.__assign || function () {

import { createMessage, createError } from "../utils";
import { __hy_internal__ } from "./internal";
function getSyncApi(apiName, jsapi, options) {

@@ -158,10 +157,11 @@ // 同步场景无该 API

}
export function callbackApi(apiName, jsapi, cb) {
export function callbackApi(jsapi, data, cb) {
var api = (data || {}).api;
// 无该 API
if (!jsapi) {
return cb(createMessage(createError('NOTFOUND', apiName), 'fail'));
return cb(createMessage(createError('NOTFOUND', api), 'fail'));
}
// 传进来的 API 不是函数
if (typeof jsapi !== 'function') {
return cb(createMessage(createError('INVALID', apiName), 'fail'));
return cb(createMessage(createError('INVALID', api), 'fail'));
}

@@ -172,14 +172,8 @@ jsapi(function (result) {

}
export var getApiResult = function getApiResult(customApi, data) {
if (customApi === void 0) {
customApi = {};
}
export var getApiResult = function getApiResult(jsapi, data) {
return __awaiter(void 0, void 0, void 0, function () {
var api, options, config, _a, type, jsapi;
var api, options, config, _a, type;
return __generator(this, function (_b) {
api = data.api, options = data.options, config = data.config;
_a = (config || {}).type, type = _a === void 0 ? 'async' : _a;
jsapi = customApi[api] || {
__hy_internal__: __hy_internal__
}[api] || my[api];
if (type === 'sync') {

@@ -186,0 +180,0 @@ return [2 /*return*/, getSyncApi(api, jsapi, options)];

{
"name": "@hylid/call",
"version": "3.2.0-alpha.2",
"version": "3.2.0-alpha.4",
"main": "lib/index.js",

@@ -9,4 +9,4 @@ "files": [

"dependencies": {
"@hylid/env": "^3.2.0-alpha.2",
"@hylid/types": "^3.2.0-alpha.2"
"@hylid/env": "^3.2.0-alpha.4",
"@hylid/types": "^3.2.0-alpha.4"
},

@@ -13,0 +13,0 @@ "publishConfig": {

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