UNPKG

@alilc/lowcode-renderer-core

Version:
139 lines 5.5 kB
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator"; import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose"; import _regeneratorRuntime from "@babel/runtime/regenerator"; import logger from '../utils/logger'; import baseRendererFactory from './base'; export default function tempRendererFactory() { var _TempRenderer; var BaseRenderer = baseRendererFactory(); 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; } _inheritsLoose(TempRenderer, _BaseRenderer); var _proto = TempRenderer.prototype; _proto.__init = function __init() { this.state = {}; this.cacheSetState = {}; }; _proto.componentDidMount = /*#__PURE__*/function () { var _componentDidMount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() { var _this2 = this; var ctx, setState; return _regeneratorRuntime.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 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() { return _regeneratorRuntime.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 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() { var ctx; return _regeneratorRuntime.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 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(e) { return _regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: logger.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; }