UNPKG

wix-style-react

Version:
70 lines (53 loc) 2.3 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var noop = function noop() {}; var depLogger = { log: noop }; var LOG_PREFIX = 'Wix-Style-React: [WARNING] '; if (process.env.NODE_ENV !== 'production') { var DeprecationLogger = function () { function DeprecationLogger() { _classCallCheck(this, DeprecationLogger); this.reportedMessages = new Set(); this.printWarning = function (msg) { var message = '' + LOG_PREFIX + msg; if (console) { console.warn(message); // eslint-disable-line } try { // --- Welcome to debugging wix-style-react --- // This error was thrown as a convenience so that you can use this stack // to find the callsite that caused this warning to fire. throw new Error(message); } catch (x) {} }; this.log = this.log.bind(this); } _createClass(DeprecationLogger, [{ key: 'log', /** * Log a warning message, once per key. (Calling `log` twice with same key would result in one log) * * @param {*} message * @memberof DeprecationLogger */ value: function log(message) { if (!this.reportedMessages.has(message)) { this.reportedMessages.add(message); this.printWarning(message); } } }]); return DeprecationLogger; }(); exports.depLogger = depLogger = new DeprecationLogger(); } exports.depLogger = depLogger; exports.default = function (msg) { return depLogger.log(msg); };