@onekeyfe/cross-inpage-provider-core
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -46,3 +46,2 @@ "use strict"; | ||
}; | ||
let requestPayloadCache = {}; | ||
class JsBridgeBase extends CrossEventEmitter_1.CrossEventEmitter { | ||
@@ -52,2 +51,3 @@ constructor(config = {}) { | ||
super(); | ||
this._requestPayloadCache = {}; | ||
this.isExtUi = false; | ||
@@ -175,5 +175,5 @@ this.isInjected = false; | ||
if (payload && payload.id && payload.type === cross_inpage_provider_types_1.IJsBridgeMessageTypes.REQUEST) { | ||
requestPayloadCache[payload.id] = payload; | ||
this._requestPayloadCache[payload.id] = payload; | ||
if (payload.id % 100 === 0) { | ||
requestPayloadCache = {}; | ||
this._requestPayloadCache = {}; | ||
} | ||
@@ -289,3 +289,3 @@ } | ||
} | ||
const relatedSendPayload = (_c = requestPayloadCache[(_b = payload === null || payload === void 0 ? void 0 : payload.id) !== null && _b !== void 0 ? _b : '']) !== null && _c !== void 0 ? _c : null; | ||
const relatedSendPayload = (_c = this._requestPayloadCache[(_b = payload === null || payload === void 0 ? void 0 : payload.id) !== null && _b !== void 0 ? _b : '']) !== null && _c !== void 0 ? _c : null; | ||
this.debugLogger.jsBridge('receive', payload, { sender }, '\r\n -----> ', (_e = (_d = payload.data) === null || _d === void 0 ? void 0 : _d.result) !== null && _e !== void 0 ? _e : payload.data, '\r\n <----- ', relatedSendPayload === null || relatedSendPayload === void 0 ? void 0 : relatedSendPayload.data); | ||
@@ -292,0 +292,0 @@ const { type, id, data, error, origin, remoteId } = payload; |
@@ -16,2 +16,3 @@ "use strict"; | ||
exports.ProviderBase = void 0; | ||
/* eslint-disable @typescript-eslint/no-unsafe-assignment,@typescript-eslint/ban-ts-comment */ | ||
const isFunction_1 = __importDefault(require("lodash/isFunction")); | ||
@@ -115,2 +116,3 @@ const CrossEventEmitter_1 = require("./CrossEventEmitter"); | ||
bridgeRequest(data, callback) { | ||
var _a, _b, _c, _d; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -128,2 +130,8 @@ let hasCallback = false; | ||
const resData = yield this.bridge.request(payload); | ||
if (resData) { | ||
// @ts-ignore | ||
resData.id = (_b = (_a = data === null || data === void 0 ? void 0 : data.id) !== null && _a !== void 0 ? _a : resData.id) !== null && _b !== void 0 ? _b : undefined; | ||
// @ts-ignore | ||
resData.jsonrpc = (_d = (_c = data === null || data === void 0 ? void 0 : data.jsonrpc) !== null && _c !== void 0 ? _c : resData.jsonrpc) !== null && _d !== void 0 ? _d : '2.0'; | ||
} | ||
const result = resData ? resData.result : undefined; | ||
@@ -130,0 +138,0 @@ if (callback && hasCallback) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const version = '0.0.8'; | ||
const version = '0.0.9'; | ||
const versionBuild = '2020-0101-1'; | ||
@@ -5,0 +5,0 @@ exports.default = { |
@@ -6,2 +6,3 @@ import { CrossEventEmitter } from './CrossEventEmitter'; | ||
constructor(config?: IJsBridgeConfig); | ||
private _requestPayloadCache; | ||
protected isExtUi: boolean; | ||
@@ -8,0 +9,0 @@ protected isInjected: boolean; |
@@ -39,3 +39,2 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
let requestPayloadCache = {}; | ||
class JsBridgeBase extends CrossEventEmitter { | ||
@@ -45,2 +44,3 @@ constructor(config = {}) { | ||
super(); | ||
this._requestPayloadCache = {}; | ||
this.isExtUi = false; | ||
@@ -168,5 +168,5 @@ this.isInjected = false; | ||
if (payload && payload.id && payload.type === IJsBridgeMessageTypes.REQUEST) { | ||
requestPayloadCache[payload.id] = payload; | ||
this._requestPayloadCache[payload.id] = payload; | ||
if (payload.id % 100 === 0) { | ||
requestPayloadCache = {}; | ||
this._requestPayloadCache = {}; | ||
} | ||
@@ -282,3 +282,3 @@ } | ||
} | ||
const relatedSendPayload = (_c = requestPayloadCache[(_b = payload === null || payload === void 0 ? void 0 : payload.id) !== null && _b !== void 0 ? _b : '']) !== null && _c !== void 0 ? _c : null; | ||
const relatedSendPayload = (_c = this._requestPayloadCache[(_b = payload === null || payload === void 0 ? void 0 : payload.id) !== null && _b !== void 0 ? _b : '']) !== null && _c !== void 0 ? _c : null; | ||
this.debugLogger.jsBridge('receive', payload, { sender }, '\r\n -----> ', (_e = (_d = payload.data) === null || _d === void 0 ? void 0 : _d.result) !== null && _e !== void 0 ? _e : payload.data, '\r\n <----- ', relatedSendPayload === null || relatedSendPayload === void 0 ? void 0 : relatedSendPayload.data); | ||
@@ -285,0 +285,0 @@ const { type, id, data, error, origin, remoteId } = payload; |
@@ -10,2 +10,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
/* eslint-disable @typescript-eslint/no-unsafe-assignment,@typescript-eslint/ban-ts-comment */ | ||
import isFunction from 'lodash/isFunction'; | ||
@@ -109,2 +110,3 @@ import { CrossEventEmitter } from './CrossEventEmitter'; | ||
bridgeRequest(data, callback) { | ||
var _a, _b, _c, _d; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -122,2 +124,8 @@ let hasCallback = false; | ||
const resData = yield this.bridge.request(payload); | ||
if (resData) { | ||
// @ts-ignore | ||
resData.id = (_b = (_a = data === null || data === void 0 ? void 0 : data.id) !== null && _a !== void 0 ? _a : resData.id) !== null && _b !== void 0 ? _b : undefined; | ||
// @ts-ignore | ||
resData.jsonrpc = (_d = (_c = data === null || data === void 0 ? void 0 : data.jsonrpc) !== null && _c !== void 0 ? _c : resData.jsonrpc) !== null && _d !== void 0 ? _d : '2.0'; | ||
} | ||
const result = resData ? resData.result : undefined; | ||
@@ -124,0 +132,0 @@ if (callback && hasCallback) { |
@@ -1,2 +0,2 @@ | ||
const version = '0.0.8'; | ||
const version = '0.0.9'; | ||
const versionBuild = '2020-0101-1'; | ||
@@ -3,0 +3,0 @@ export default { |
{ | ||
"name": "@onekeyfe/cross-inpage-provider-core", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"keywords": [ | ||
@@ -32,5 +32,5 @@ "cross-inpage-provider" | ||
"dependencies": { | ||
"@onekeyfe/cross-inpage-provider-errors": "^0.0.8", | ||
"@onekeyfe/cross-inpage-provider-events": "^0.0.8", | ||
"@onekeyfe/cross-inpage-provider-types": "^0.0.8", | ||
"@onekeyfe/cross-inpage-provider-errors": "^0.0.9", | ||
"@onekeyfe/cross-inpage-provider-events": "^0.0.9", | ||
"@onekeyfe/cross-inpage-provider-types": "^0.0.9", | ||
"events": "^3.3.0", | ||
@@ -40,3 +40,3 @@ "lodash": "^4.17.21", | ||
}, | ||
"gitHead": "ceff8e9a3a3600e37b98778fd0736d8cee0f8d10" | ||
"gitHead": "1a531ca7434eca9b6704760cb0221df3cfdbe4d5" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
146031
3569
132
2
6
1
57
+ Added@onekeyfe/cross-inpage-provider-errors@0.0.9(transitive)
+ Added@onekeyfe/cross-inpage-provider-events@0.0.9(transitive)
+ Added@onekeyfe/cross-inpage-provider-types@0.0.9(transitive)
- Removed@onekeyfe/cross-inpage-provider-errors@0.0.8(transitive)
- Removed@onekeyfe/cross-inpage-provider-events@0.0.8(transitive)
- Removed@onekeyfe/cross-inpage-provider-types@0.0.8(transitive)