mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-29 04:35:36 +08:00
[react_native] JS files from D2027955: [react_native] Add bridge 'spy mode' to watch bridge traffic
This commit is contained in:
@@ -21,6 +21,9 @@ var JSTimersExecution = require('JSTimersExecution');
|
|||||||
|
|
||||||
var INTERNAL_ERROR = 'Error in MessageQueue implementation';
|
var INTERNAL_ERROR = 'Error in MessageQueue implementation';
|
||||||
|
|
||||||
|
// Prints all bridge traffic to console.log
|
||||||
|
var DEBUG_SPY_MODE = false;
|
||||||
|
|
||||||
type ModulesConfig = {
|
type ModulesConfig = {
|
||||||
[key:string]: {
|
[key:string]: {
|
||||||
moduleID: number;
|
moduleID: number;
|
||||||
@@ -263,6 +266,9 @@ var MessageQueueMixin = {
|
|||||||
'both the success callback and the error callback.',
|
'both the success callback and the error callback.',
|
||||||
cbID
|
cbID
|
||||||
);
|
);
|
||||||
|
if (DEBUG_SPY_MODE) {
|
||||||
|
console.log('N->JS: Callback#' + cbID + '(' + JSON.stringify(args) + ')');
|
||||||
|
}
|
||||||
cb.apply(scope, args);
|
cb.apply(scope, args);
|
||||||
} catch(ie_requires_catch) {
|
} catch(ie_requires_catch) {
|
||||||
throw ie_requires_catch;
|
throw ie_requires_catch;
|
||||||
@@ -292,6 +298,11 @@ var MessageQueueMixin = {
|
|||||||
var moduleName = this._localModuleIDToModuleName[moduleID];
|
var moduleName = this._localModuleIDToModuleName[moduleID];
|
||||||
|
|
||||||
var methodName = this._localModuleNameToMethodIDToName[moduleName][methodID];
|
var methodName = this._localModuleNameToMethodIDToName[moduleName][methodID];
|
||||||
|
if (DEBUG_SPY_MODE) {
|
||||||
|
console.log(
|
||||||
|
'N->JS: ' + moduleName + '.' + methodName +
|
||||||
|
'(' + JSON.stringify(params) + ')');
|
||||||
|
}
|
||||||
var ret = jsCall(this._requireFunc(moduleName), methodName, params);
|
var ret = jsCall(this._requireFunc(moduleName), methodName, params);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -460,6 +471,17 @@ var MessageQueueMixin = {
|
|||||||
var ret = currentOutgoingItems[REQUEST_MODULE_IDS].length ||
|
var ret = currentOutgoingItems[REQUEST_MODULE_IDS].length ||
|
||||||
currentOutgoingItems[RESPONSE_RETURN_VALUES].length ? currentOutgoingItems : null;
|
currentOutgoingItems[RESPONSE_RETURN_VALUES].length ? currentOutgoingItems : null;
|
||||||
|
|
||||||
|
if (DEBUG_SPY_MODE && ret) {
|
||||||
|
for (var i = 0; i < currentOutgoingItems[0].length; i++) {
|
||||||
|
var moduleName = this._remoteModuleIDToModuleName[currentOutgoingItems[0][i]];
|
||||||
|
var methodName =
|
||||||
|
this._remoteModuleNameToMethodIDToName[moduleName][currentOutgoingItems[1][i]];
|
||||||
|
console.log(
|
||||||
|
'JS->N: ' + moduleName + '.' + methodName +
|
||||||
|
'(' + JSON.stringify(currentOutgoingItems[2][i]) + ')');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user