数通智联化工云平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

80 lines
2.1 KiB

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const consola$1 = require('./shared/consola.46fcabd7.cjs');
class BrowserReporter {
constructor(options) {
this.options = { ...options };
this.defaultColor = "#7f8c8d";
this.levelColorMap = {
0: "#c0392b",
// Red
1: "#f39c12",
// Yellow
3: "#00BCD4"
// Cyan
};
this.typeColorMap = {
success: "#2ecc71"
// Green
};
}
_getLogFn(level) {
if (level < 1) {
return console.__error || console.error;
}
if (level === 1) {
return console.__warn || console.warn;
}
return console.__log || console.log;
}
log(logObj) {
const consoleLogFn = this._getLogFn(logObj.level);
const type = logObj.type !== "log" ? logObj.type : "";
const tag = logObj.tag || "";
const color = this.typeColorMap[logObj.type] || this.levelColorMap[logObj.level] || this.defaultColor;
const style = `
background: ${color};
border-radius: 0.5em;
color: white;
font-weight: bold;
padding: 2px 0.5em;
`;
const badge = `%c${[tag, type].filter(Boolean).join(":")}`;
if (typeof logObj.args[0] === "string") {
consoleLogFn(
`${badge}%c ${logObj.args[0]}`,
style,
// Empty string as style resets to default console style
"",
...logObj.args.slice(1)
);
} else {
consoleLogFn(badge, style, ...logObj.args);
}
}
}
function createConsola(options = {}) {
const consola2 = consola$1.createConsola({
reporters: options.reporters || [new BrowserReporter({})],
prompt(message, options2 = {}) {
if (options2.type === "confirm") {
return Promise.resolve(confirm(message));
}
return Promise.resolve(prompt(message));
},
...options
});
return consola2;
}
const consola = createConsola();
exports.Consola = consola$1.Consola;
exports.LogLevels = consola$1.LogLevels;
exports.LogTypes = consola$1.LogTypes;
exports.consola = consola;
exports.createConsola = createConsola;
exports.default = consola;