2018-01-19 20:34:23 +00:00
|
|
|
/**
|
2018-09-11 22:27:47 +00:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2018-01-19 20:34:23 +00:00
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2018-01-19 20:34:23 +00:00
|
|
|
*
|
2018-05-11 02:06:46 +00:00
|
|
|
* @format
|
2018-08-09 15:32:04 +00:00
|
|
|
* @flow strict-local
|
2018-01-19 20:34:23 +00:00
|
|
|
*/
|
2018-05-11 02:06:46 +00:00
|
|
|
|
2018-01-19 20:34:23 +00:00
|
|
|
'use strict';
|
|
|
|
|
2018-04-18 00:17:12 +00:00
|
|
|
const JSDevSupport = require('NativeModules').JSDevSupport;
|
|
|
|
const ReactNative = require('ReactNative');
|
2018-01-19 20:34:23 +00:00
|
|
|
|
2018-04-18 00:17:12 +00:00
|
|
|
const JSDevSupportModule = {
|
2018-05-11 02:06:46 +00:00
|
|
|
getJSHierarchy: function(tag: number) {
|
2018-04-18 00:17:12 +00:00
|
|
|
try {
|
2018-05-11 02:06:46 +00:00
|
|
|
const {
|
|
|
|
computeComponentStackForErrorReporting,
|
|
|
|
} = ReactNative.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
2018-04-18 00:17:12 +00:00
|
|
|
const componentStack = computeComponentStackForErrorReporting(tag);
|
|
|
|
if (!componentStack) {
|
|
|
|
JSDevSupport.onFailure(
|
|
|
|
JSDevSupport.ERROR_CODE_VIEW_NOT_FOUND,
|
2018-05-11 02:06:46 +00:00
|
|
|
"Component stack doesn't exist for tag " + tag,
|
|
|
|
);
|
2018-04-18 00:17:12 +00:00
|
|
|
} else {
|
|
|
|
JSDevSupport.onSuccess(componentStack);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
JSDevSupport.onFailure(JSDevSupport.ERROR_CODE_EXCEPTION, e.message);
|
|
|
|
}
|
2018-01-19 20:34:23 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = JSDevSupportModule;
|