UNPKG

react-application-core

Version:

A react-based application core for the business applications.

363 lines 12.2 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Environment = void 0; var inversify_1 = require("inversify"); var P = require("platform"); var ts_smart_logger_1 = require("ts-smart-logger"); var util_1 = require("../util"); var definition_1 = require("../definition"); var Environment = /** @class */ (function () { /** * @stable [08.10.2019] */ function Environment() { this.appProfile = definition_1.DefaultEntities.ENVIRONMENT_ENTITY.appProfile; this.appVersion = definition_1.DefaultEntities.ENVIRONMENT_ENTITY.appVersion; this.basePath = definition_1.DefaultEntities.ENVIRONMENT_ENTITY.basePath; this.devMode = definition_1.DefaultEntities.ENVIRONMENT_ENTITY.devMode; this.document = definition_1.DefaultEntities.ENVIRONMENT_ENTITY.document; this.host = definition_1.DefaultEntities.ENVIRONMENT_ENTITY.host; this.normalizedBasePath = definition_1.DefaultEntities.ENVIRONMENT_ENTITY.normalizedBasePath; this.port = definition_1.DefaultEntities.ENVIRONMENT_ENTITY.port; this.prodMode = definition_1.DefaultEntities.ENVIRONMENT_ENTITY.prodMode; this.window = definition_1.DefaultEntities.ENVIRONMENT_ENTITY.window; var payload = { androidPlatform: this.androidPlatform, appNamespace: this.appNamespace, browserName: this.browserName, browserVersion: this.browserVersion, chromePlatform: this.chromePlatform, googleKey: this.googleKey, ios13Platform: this.ios13Platform, iosPlatform: this.iosPlatform, macPlatform: this.macPlatform, mobilePlatform: this.mobilePlatform, passwordPlaceholder: this.passwordPlaceholder, platformName: this.platformName, platformType: this.platformType, platformVersion: this.platformVersion, safariPlatform: this.safariPlatform, windowsPhonePlatform: this.windowsPhonePlatform, windowsPlatform: this.windowsPlatform, }; Environment_1.logger.info("[$Environment] " + util_1.JsonUtils.formatJson(payload)); this.setVariable(definition_1.EnvironmentGlobalVariablesEnum.ENVIRONMENT, this); } Environment_1 = Environment; Object.defineProperty(Environment.prototype, "googleMapsKey", { /** * @stable [09.01.2020] * @returns {string} */ get: function () { return process.env.GOOGLE_MAPS_KEY; }, enumerable: false, configurable: true }); Object.defineProperty(Environment.prototype, "path", { /** * @stable [19.12.2019] * @returns {string} */ get: function () { return util_1.getCurrentUrlPath(); }, enumerable: false, configurable: true }); Object.defineProperty(Environment.prototype, "fullPath", { /** * @stable [13.03.2020] * @returns {string} */ get: function () { return util_1.getFullPath(); }, enumerable: false, configurable: true }); Object.defineProperty(Environment.prototype, "platformType", { /** * @stable [08.10.2019] * @returns {string} */ get: function () { return this.mobilePlatform ? 'M' : 'D'; }, enumerable: false, configurable: true }); Object.defineProperty(Environment.prototype, "appNamespace", { /** * @stable [08.10.2019] * @returns {string} */ get: function () { return process.env.APP_NAMESPACE; }, enumerable: false, configurable: true }); Object.defineProperty(Environment.prototype, "googleKey", { /** * @stable [08.10.2019] * @returns {string} */ get: function () { return process.env.GOOGLE_KEY; }, enumerable: false, configurable: true }); Object.defineProperty(Environment.prototype, "browserVersion", { /** * @stable [08.10.2019] * @returns {string} */ get: function () { return String(P.version); }, enumerable: false, configurable: true }); Object.defineProperty(Environment.prototype, "browserName", { /** * @stable [08.10.2019] * @returns {string} */ get: function () { return P.name; }, enumerable: false, configurable: true }); Object.defineProperty(Environment.prototype, "platformVersion", { /** * @stable [08.10.2019] * @returns {string} */ get: function () { return this.ios13Platform ? '13.x' : P.os.version; }, enumerable: false, configurable: true }); Object.defineProperty(Environment.prototype, "platformName", { /** * @stable [08.10.2019] * @returns {string} */ get: function () { return this.ios13Platform ? 'iOS' : this.osFamily; }, enumerable: false, configurable: true }); Object.defineProperty(Environment.prototype, "passwordPlaceholder", { /** * @stable [08.10.2019] * @returns {string} */ get: function () { return this.safariPlatform && this.iosPlatform ? '●' : '•'; }, enumerable: false, configurable: true }); Object.defineProperty(Environment.prototype, "mobilePlatform", { /** * @stable [08.10.2019] * @returns {boolean} */ get: function () { return this.androidPlatform || this.iosPlatform || this.windowsPhonePlatform; }, enumerable: false, configurable: true }); Object.defineProperty(Environment.prototype, "windowsPhonePlatform", { /** * @stable [08.10.2019] * @returns {boolean} */ get: function () { return this.osFamily === 'Windows Phone'; }, enumerable: false, configurable: true }); Object.defineProperty(Environment.prototype, "safariPlatform", { /** * @stable [08.10.2019] * @returns {boolean} */ get: function () { return this.browserName === 'Safari'; }, enumerable: false, configurable: true }); Object.defineProperty(Environment.prototype, "safariMobilePlatform", { /** * @stable [21.01.2020] * @returns {boolean} */ get: function () { return this.browserName === 'Safari Mobile'; }, enumerable: false, configurable: true }); Object.defineProperty(Environment.prototype, "safariOrSafariMobilePlatform", { /** * @stable [21.01.2020] * @returns {boolean} */ get: function () { return this.safariMobilePlatform || this.safariPlatform; }, enumerable: false, configurable: true }); Object.defineProperty(Environment.prototype, "touchedPlatform", { /** * @stable [16.01.2020] * @returns {boolean} */ get: function () { return 'ontouchstart' in this.window; }, enumerable: false, configurable: true }); Object.defineProperty(Environment.prototype, "chromePlatform", { /** * @stable [08.10.2019] * @returns {boolean} */ get: function () { return this.browserName === 'Chrome'; }, enumerable: false, configurable: true }); Object.defineProperty(Environment.prototype, "windowsPlatform", { /** * @stable [08.10.2019] * @returns {boolean} */ get: function () { return this.osFamily === 'Windows'; }, enumerable: false, configurable: true }); Object.defineProperty(Environment.prototype, "macPlatform", { /** * @stable [08.10.2019] * @returns {boolean} */ get: function () { return this.isMacPlatform && !this.ios13Platform; }, enumerable: false, configurable: true }); Object.defineProperty(Environment.prototype, "androidPlatform", { /** * @stable [08.10.2019] * @returns {boolean} */ get: function () { return this.osFamily === 'Android'; }, enumerable: false, configurable: true }); Object.defineProperty(Environment.prototype, "ios13Platform", { /** * @stable [08.10.2019] * @returns {boolean} */ get: function () { return this.isMacPlatform && this.safariOrSafariMobilePlatform && this.touchedPlatform; }, enumerable: false, configurable: true }); Object.defineProperty(Environment.prototype, "iosPlatform", { /** * @stable [08.10.2019] * @returns {boolean} */ get: function () { return this.osFamily === 'iOS' || this.ios13Platform; }, enumerable: false, configurable: true }); /** * @stable [08.10.2019] * @param {string} name * @param {AnyT} scope */ Environment.prototype.setVariable = function (name, scope) { Reflect.set(this.window, name, scope); }; /** * @stable [13.03.2020] * @param {string} sectionRoute * @returns {string} */ Environment.prototype.getSectionFullPath = function (sectionRoute) { return util_1.getSectionFullPath(sectionRoute); }; /** * @stable [13.03.2020] * @returns {TParams} */ Environment.prototype.getUrlQueryParams = function () { return util_1.getUrlQueryParams(); }; Object.defineProperty(Environment.prototype, "isMacPlatform", { /** * @stable [08.10.2019] * @returns {boolean} */ get: function () { return this.osFamily === 'OS X'; }, enumerable: false, configurable: true }); Object.defineProperty(Environment.prototype, "osFamily", { /** * @stable [08.10.2019] * @returns {string} */ get: function () { return P.os.family; }, enumerable: false, configurable: true }); var Environment_1; Environment.logger = ts_smart_logger_1.LoggerFactory.makeLogger('Environment'); Environment = Environment_1 = __decorate([ inversify_1.injectable(), __metadata("design:paramtypes", []) ], Environment); return Environment; }()); exports.Environment = Environment; //# sourceMappingURL=env.service.js.map