fractal-core
Version:
A minimalist and well crafted app, content or component is our conviction
44 lines • 2.15 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("../core");
exports.warn = (source, description) => __awaiter(this, void 0, void 0, function* () { return console.warn(`source: ${source}, description: ${description}`); });
exports.error = (source, description) => {
throw new Error(`source: ${source}, description: ${description}`);
};
exports.beforeInput = (ctx, inputName, data) => {
if (!ctx.global.log)
return;
let state = ctx.components[ctx.id].state;
if (typeof state === 'object') {
state = core_1.clone(state);
}
console.groupCollapsed(`%c input %c${inputName} %cfrom %c${ctx.id}`, 'color: #626060; font-size: 12px;', 'color: #3b3a3a; font-size: 14px;', 'color: #626060; font-size: 12px;', 'color: #3b3a3a; font-size: 14px;');
console.info('%c input data ', 'color: rgb(9, 157, 225); font-weight: bold;', data);
console.info('%c prev state ', 'color: #AFAFAF; font-weight: bold;', state);
};
// color for actions (not yet implemented) #58C6F8
exports.afterInput = (ctx, inputName, data) => {
if (!ctx.global.log)
return;
let state = ctx.components[ctx.id].state;
if (typeof state === 'object') {
state = core_1.clone(state);
}
console.info('%c next state ', 'color: #3CA43F; font-weight: bold;', state);
console.groupEnd();
};
exports.logFns = {
warn: exports.warn,
error: exports.error,
beforeInput: exports.beforeInput,
afterInput: exports.afterInput,
};
//# sourceMappingURL=log.js.map