UNPKG

@alilc/lowcode-renderer-core

Version:
144 lines (143 loc) 5.91 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); exports.__esModule = true; exports["default"] = tempRendererFactory; var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose")); var _logger = _interopRequireDefault(require("../utils/logger")); var _base = _interopRequireDefault(require("./base")); function tempRendererFactory() { var _TempRenderer; var BaseRenderer = (0, _base["default"])(); return _TempRenderer = /*#__PURE__*/function (_BaseRenderer) { function TempRenderer() { var _this; for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _BaseRenderer.call.apply(_BaseRenderer, [this].concat(args)) || this; _this.__namespace = 'temp'; _this.cacheSetState = void 0; return _this; } (0, _inheritsLoose2["default"])(TempRenderer, _BaseRenderer); var _proto = TempRenderer.prototype; _proto.__init = function __init() { this.state = {}; this.cacheSetState = {}; }; _proto.componentDidMount = /*#__PURE__*/function () { var _componentDidMount = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() { var _this2 = this; var ctx, setState; return _regenerator["default"].wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: ctx = this.props.__ctx; if (ctx) { _context.next = 3; break; } return _context.abrupt("return"); case 3: setState = ctx.setState; this.cacheSetState = setState; ctx.setState = function () { for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } setState.call.apply(setState, [ctx].concat(args)); setTimeout(function () { return _this2.forceUpdate(); }, 0); }; this.__debug("componentDidMount - " + this.props.__schema.fileName); case 7: case "end": return _context.stop(); } }, _callee, this); })); function componentDidMount() { return _componentDidMount.apply(this, arguments); } return componentDidMount; }(); _proto.componentDidUpdate = /*#__PURE__*/function () { var _componentDidUpdate = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2() { return _regenerator["default"].wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: this.__debug("componentDidUpdate - " + this.props.__schema.fileName); case 1: case "end": return _context2.stop(); } }, _callee2, this); })); function componentDidUpdate() { return _componentDidUpdate.apply(this, arguments); } return componentDidUpdate; }(); _proto.componentWillUnmount = /*#__PURE__*/function () { var _componentWillUnmount = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3() { var ctx; return _regenerator["default"].wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: ctx = this.props.__ctx; if (!(!ctx || !this.cacheSetState)) { _context3.next = 3; break; } return _context3.abrupt("return"); case 3: ctx.setState = this.cacheSetState; delete this.cacheSetState; this.__debug("componentWillUnmount - " + this.props.__schema.fileName); case 6: case "end": return _context3.stop(); } }, _callee3, this); })); function componentWillUnmount() { return _componentWillUnmount.apply(this, arguments); } return componentWillUnmount; }(); _proto.componentDidCatch = /*#__PURE__*/function () { var _componentDidCatch = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4(e) { return _regenerator["default"].wrap(function _callee4$(_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: _logger["default"].warn(e); this.__debug("componentDidCatch - " + this.props.__schema.fileName); case 2: case "end": return _context4.stop(); } }, _callee4, this); })); function componentDidCatch(_x) { return _componentDidCatch.apply(this, arguments); } return componentDidCatch; }(); _proto.render = function render() { var _this$props = this.props, __schema = _this$props.__schema, __ctx = _this$props.__ctx; if (this.__checkSchema(__schema)) { return '下钻编辑 schema 结构异常!'; } this.__debug(TempRenderer.displayName + " render - " + (__schema === null || __schema === void 0 ? void 0 : __schema.fileName)); return this.__renderContent(this.__renderContextProvider({ __ctx: __ctx })); }; return TempRenderer; }(BaseRenderer), _TempRenderer.displayName = 'TempRenderer', _TempRenderer; }