UNPKG

choerodon-ui

Version:

An enterprise-class UI design language and React-based implementation

94 lines (81 loc) 2.72 kB
import _objectSpread from "@babel/runtime/helpers/objectSpread2"; import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _createClass from "@babel/runtime/helpers/createClass"; import _inherits from "@babel/runtime/helpers/inherits"; import _createSuper from "@babel/runtime/helpers/createSuper"; import { PureComponent } from 'react'; import TableContext from './TableContext'; import { DataSetStatus } from '../data-set/enum'; var Profiler = /*#__PURE__*/function (_PureComponent) { _inherits(Profiler, _PureComponent); var _super = _createSuper(Profiler); function Profiler(props, context) { var _this; _classCallCheck(this, Profiler); _this = _super.call(this, props, context); var tableStore = context.tableStore, dataSet = context.dataSet; if (tableStore.performanceEnabled) { if (dataSet.status === DataSetStatus.ready && dataSet.length) { tableStore.performanceOn = true; tableStore.timing.renderStart = Date.now(); } } return _this; } _createClass(Profiler, [{ key: "componentWillUpdate", value: function componentWillUpdate() { var tableStore = this.context.tableStore; if (tableStore.performanceEnabled && tableStore.performanceOn) { tableStore.timing.renderStart = Date.now(); } } }, { key: "componentDidMount", value: function componentDidMount() { this.handlePerformance(); } }, { key: "componentDidUpdate", value: function componentDidUpdate() { this.handlePerformance(); } }, { key: "handlePerformance", value: function handlePerformance() { var _this$context = this.context, code = _this$context.code, tableStore = _this$context.tableStore, dataSet = _this$context.dataSet; if (tableStore.performanceEnabled && tableStore.performanceOn) { var timing = tableStore.timing; var performance = dataSet.performance; var onPerformance = tableStore.getConfig('onPerformance'); timing.renderEnd = Date.now(); onPerformance('Table', { name: code, url: performance.url, size: dataSet.length, timing: _objectSpread(_objectSpread({}, performance.timing), timing) }); tableStore.performanceOn = false; } } }, { key: "render", value: function render() { var children = this.props.children; return children; } }], [{ key: "contextType", get: function get() { return TableContext; } }]); return Profiler; }(PureComponent); export { Profiler as default }; Profiler.displayName = 'Profiler'; //# sourceMappingURL=Profiler.js.map