UNPKG

react-application-core

Version:

A react-based application core for the business applications.

136 lines 5.03 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.UniversalComponent = void 0; var R = require("ramda"); var util_1 = require("../../util"); var di_1 = require("../../di"); var generic_component_1 = require("./generic.component"); /** * TODO * @deprecated */ var UniversalComponent = /** @class */ (function (_super) { __extends(UniversalComponent, _super); /** * @stable [02.12.2019] * @param {TProps} props */ function UniversalComponent(props) { var _this = _super.call(this, props) || this; _this.plugins = []; _this.initPlugins(); return _this; } /** * @stable [22.09.2019] */ UniversalComponent.prototype.componentDidMount = function () { this.plugins.forEach(function (plugin) { return util_1.isFn(plugin.componentDidMount) && plugin.componentDidMount(); }); }; /** * @stable [22.09.2019] */ UniversalComponent.prototype.componentWillUnmount = function () { this.plugins.forEach(function (plugin) { return util_1.isFn(plugin.componentWillUnmount) && plugin.componentWillUnmount(); }); }; /** * @stable [23.10.2019] * @param {Readonly<TProps extends IUniversalComponentProps>} prevProps * @param {Readonly<TState>} prevState */ UniversalComponent.prototype.getSnapshotBeforeUpdate = function (prevProps, prevState) { this.plugins.forEach(function (plugin) { return util_1.isFn(plugin.getSnapshotBeforeUpdate) && plugin.getSnapshotBeforeUpdate(prevProps, prevState); }); return null; }; /** * @stable [23.04.2018] * @param {Readonly<TProps>} prevProps * @param {Readonly<TState>} prevState * @param {never} prevContext */ UniversalComponent.prototype.componentDidUpdate = function (prevProps, prevState, prevContext) { this.plugins.forEach(function (plugin) { return util_1.isFn(plugin.componentDidUpdate) && plugin.componentDidUpdate(prevProps, prevState, prevContext); }); }; /** * @stable [01.12.2018] * @returns {Element} */ UniversalComponent.prototype.getSelf = function () { return this.selfRef.current || this.refs.self; // TODO any }; Object.defineProperty(UniversalComponent.prototype, "uniqueId", { /** * @react-native-compatible * @stable [17.01.2020] * @returns {IUniqueId} */ get: function () { return null; // getUniqueId(); }, enumerable: false, configurable: true }); Object.defineProperty(UniversalComponent.prototype, "routes", { /** * @stable [] * @returns {IRoutesEntity} */ get: function () { return di_1.staticInjector(di_1.DI_TYPES.Routes); }, enumerable: false, configurable: true }); /** * @stable [18.06.2019] * @param {GenericPluginCtorT | IGenericPlugin} pluginObject */ UniversalComponent.prototype.registerPlugin = function (pluginObject) { if (R.isNil(pluginObject)) { return; } this.plugins.push(util_1.isFn(pluginObject) ? Reflect.construct(pluginObject, [this]) : pluginObject); }; /** * @stable [18.06.2019] */ UniversalComponent.prototype.initPlugins = function () { var _this = this; var plugins = this.uiPlugins; if (R.isNil(plugins)) { return; } var dynamicPluginsFactories = plugins.get(this.constructor); if (util_1.isObjectNotEmpty(dynamicPluginsFactories)) { dynamicPluginsFactories.forEach(function (dynamicPluginFactory) { return _this.registerPlugin(dynamicPluginFactory(_this)); }); } [].concat(this.props.plugins || []).forEach(this.registerPlugin, this); }; Object.defineProperty(UniversalComponent.prototype, "uiPlugins", { get: function () { return di_1.getUiPlugins(); }, enumerable: false, configurable: true }); return UniversalComponent; }(generic_component_1.GenericComponent)); exports.UniversalComponent = UniversalComponent; //# sourceMappingURL=universal.component.js.map