lucid-ui
Version:
A UI component library from Xandr.
118 lines • 3.64 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkIsDev = exports.logger = exports.isNode = exports.isDevMode = void 0;
/*eslint no-console: 0*/
var lodash_1 = __importDefault(require("lodash"));
exports.isDevMode = (function isReactInDev() {
// This property gets injected via Webpack.
return process.env.NODE_ENV !== 'production'; // eslint-disable-line no-undef
})();
exports.isNode = typeof process === 'object' && process.title === 'node';
exports.logger = (function () {
return checkIsDev()
? {
log: log,
logOnce: logOnce,
warn: warn,
warnOnce: warnOnce,
error: error,
errorOnce: errorOnce,
resetOnce: resetOnce,
}
: {
log: lodash_1.default.noop,
logOnce: lodash_1.default.noop,
warn: lodash_1.default.noop,
warnOnce: lodash_1.default.noop,
error: lodash_1.default.noop,
errorOnce: lodash_1.default.noop,
resetOnce: lodash_1.default.noop,
};
})();
var onceMap = {};
function once(key, fn) {
if (!lodash_1.default.has(onceMap, key)) {
lodash_1.default.set(onceMap, key, true);
fn();
}
}
function resetOnce(key) {
lodash_1.default.unset(onceMap, key);
}
function checkIsDev() {
return (exports.isDevMode && typeof window !== 'undefined' && typeof console !== 'undefined');
}
exports.checkIsDev = checkIsDev;
function log() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
console.log.apply(console, args);
try {
// --- Welcome to debugging Lucid ---
// 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(args[0]);
}
catch (x) {
/* */
}
}
function logOnce(key) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
once(key, function () { return log.apply(void 0, args); });
}
function warn() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
console.warn.apply(console, args);
try {
// --- Welcome to debugging Lucid ---
// 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(args[0]);
}
catch (x) {
/* */
}
}
function warnOnce(key) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
once(key, function () { return warn.apply(void 0, args); });
}
function error() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
console.error.apply(console, args);
try {
// --- Welcome to debugging Lucid ---
// 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(args[0]);
}
catch (x) {
/* */
}
}
function errorOnce(key) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
once(key, function () { return error.apply(void 0, args); });
}
//# sourceMappingURL=logger.js.map