@whitesev/utils 2.3.3 → 2.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.amd.js +55 -43
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +55 -43
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +55 -43
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +55 -43
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +55 -43
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +55 -43
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Log.d.ts +28 -30
- package/dist/types/src/VueObject.d.ts +22 -9
- package/package.json +1 -1
- package/src/Log.ts +72 -60
- package/src/VueObject.ts +22 -9
package/dist/index.system.js
CHANGED
|
@@ -3119,6 +3119,9 @@ System.register('Utils', [], (function (exports) {
|
|
|
3119
3119
|
autoClearConsole: false,
|
|
3120
3120
|
logMaxCount: 999,
|
|
3121
3121
|
};
|
|
3122
|
+
/**
|
|
3123
|
+
* 颜色配置
|
|
3124
|
+
*/
|
|
3122
3125
|
#msgColorDetails = [
|
|
3123
3126
|
"font-weight: bold; color: cornflowerblue",
|
|
3124
3127
|
"font-weight: bold; color: cornflowerblue",
|
|
@@ -3126,16 +3129,16 @@ System.register('Utils', [], (function (exports) {
|
|
|
3126
3129
|
"font-weight: bold; color: cornflowerblue",
|
|
3127
3130
|
];
|
|
3128
3131
|
/**
|
|
3129
|
-
* @param
|
|
3132
|
+
* @param __GM_info 油猴管理器的API GM_info,或者是一个对象,如{"script":{name:"Utils.Log"}},或者直接是一个字符串,用作tag名
|
|
3130
3133
|
* @param console 可指定console对象为unsafeWindow下的console或者是油猴window下的console
|
|
3131
3134
|
*/
|
|
3132
|
-
constructor(
|
|
3133
|
-
if (typeof
|
|
3134
|
-
this.tag =
|
|
3135
|
+
constructor(__GM_info, console = window.console) {
|
|
3136
|
+
if (typeof __GM_info === "string") {
|
|
3137
|
+
this.tag = __GM_info;
|
|
3135
3138
|
}
|
|
3136
|
-
else if (typeof
|
|
3137
|
-
typeof
|
|
3138
|
-
this.tag =
|
|
3139
|
+
else if (typeof __GM_info === "object" &&
|
|
3140
|
+
typeof __GM_info?.script?.name === "string") {
|
|
3141
|
+
this.tag = __GM_info.script.name;
|
|
3139
3142
|
}
|
|
3140
3143
|
this.#console = console;
|
|
3141
3144
|
}
|
|
@@ -3210,24 +3213,33 @@ System.register('Utils', [], (function (exports) {
|
|
|
3210
3213
|
let { name: callerName, position: callerPosition } = this.parseErrorStack(stackSplit);
|
|
3211
3214
|
let tagName = this.tag;
|
|
3212
3215
|
let that = this;
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
+
/** tag的html输出格式 */
|
|
3217
|
+
let tagNameHTML = `%c[${tagName}%c`;
|
|
3218
|
+
/** 调用的函数名的html输出格式 */
|
|
3219
|
+
let callerNameHTML = `%c${callerName}%c]%c`;
|
|
3220
|
+
callerName.trim() !== "" && (callerNameHTML = "-" + callerNameHTML);
|
|
3221
|
+
/**
|
|
3222
|
+
* 输出消息到控制台
|
|
3223
|
+
* @param message
|
|
3224
|
+
*/
|
|
3225
|
+
function consoleMsg(message) {
|
|
3226
|
+
if (typeof message === "string") {
|
|
3227
|
+
that.#console.log(`${tagNameHTML}${callerNameHTML} %s`, ...that.#msgColorDetails, `color: ${color};${otherStyle}`, message);
|
|
3216
3228
|
}
|
|
3217
|
-
else if (typeof
|
|
3218
|
-
that.#console.log(
|
|
3229
|
+
else if (typeof message === "number") {
|
|
3230
|
+
that.#console.log(`${tagNameHTML}${callerNameHTML} %d`, ...that.#msgColorDetails, `color: ${color};${otherStyle}`, message);
|
|
3219
3231
|
}
|
|
3220
|
-
else if (typeof
|
|
3221
|
-
that.#console.log(
|
|
3232
|
+
else if (typeof message === "object") {
|
|
3233
|
+
that.#console.log(`${tagNameHTML}${callerNameHTML} %o`, ...that.#msgColorDetails, `color: ${color};${otherStyle}`, message);
|
|
3222
3234
|
}
|
|
3223
3235
|
else {
|
|
3224
|
-
that.#console.log(
|
|
3236
|
+
that.#console.log(message);
|
|
3225
3237
|
}
|
|
3226
3238
|
}
|
|
3227
3239
|
if (Array.isArray(msg)) {
|
|
3228
|
-
msg.
|
|
3229
|
-
consoleMsg(
|
|
3230
|
-
}
|
|
3240
|
+
for (let index = 0; index < msg.length; index++) {
|
|
3241
|
+
consoleMsg(msg[index]);
|
|
3242
|
+
}
|
|
3231
3243
|
}
|
|
3232
3244
|
else {
|
|
3233
3245
|
consoleMsg(msg);
|
|
@@ -3239,67 +3251,67 @@ System.register('Utils', [], (function (exports) {
|
|
|
3239
3251
|
}
|
|
3240
3252
|
/**
|
|
3241
3253
|
* 控制台-普通输出
|
|
3242
|
-
* @param
|
|
3243
|
-
* @
|
|
3244
|
-
*
|
|
3254
|
+
* @param args 需要输出的内容
|
|
3255
|
+
* @example
|
|
3256
|
+
* log.info("输出信息","输出信息2","输出信息3","输出")
|
|
3245
3257
|
*/
|
|
3246
|
-
info(
|
|
3258
|
+
info(...args) {
|
|
3247
3259
|
if (this.#disable)
|
|
3248
3260
|
return;
|
|
3249
|
-
this.printContent
|
|
3261
|
+
this.printContent(args, this.#details.infoColor);
|
|
3250
3262
|
}
|
|
3251
3263
|
/**
|
|
3252
3264
|
* 控制台-警告输出
|
|
3253
|
-
* @param
|
|
3254
|
-
* @
|
|
3255
|
-
*
|
|
3265
|
+
* @param args 需要输出的内容
|
|
3266
|
+
* @example
|
|
3267
|
+
* log.warn("输出警告","输出警告2","输出警告3","输出警告4")
|
|
3256
3268
|
*/
|
|
3257
|
-
warn(
|
|
3269
|
+
warn(...args) {
|
|
3258
3270
|
if (this.#disable)
|
|
3259
3271
|
return;
|
|
3260
|
-
this.printContent
|
|
3272
|
+
this.printContent(args, this.#details.warnColor, "background: #FEF6D5;padding: 4px 6px 4px 0px;");
|
|
3261
3273
|
}
|
|
3262
3274
|
/**
|
|
3263
3275
|
* 控制台-错误输出
|
|
3264
|
-
* @param
|
|
3265
|
-
* @
|
|
3266
|
-
*
|
|
3276
|
+
* @param args 需要输出的内容
|
|
3277
|
+
* @example
|
|
3278
|
+
* log.error("输出错误","输出错误2","输出错误3","输出错误4")
|
|
3267
3279
|
*/
|
|
3268
|
-
error(
|
|
3280
|
+
error(...args) {
|
|
3269
3281
|
if (this.#disable)
|
|
3270
3282
|
return;
|
|
3271
|
-
this.printContent
|
|
3283
|
+
this.printContent(args, this.#details.errorColor);
|
|
3272
3284
|
}
|
|
3273
3285
|
/**
|
|
3274
3286
|
* 控制台-成功输出
|
|
3275
|
-
* @param
|
|
3276
|
-
* @
|
|
3277
|
-
*
|
|
3287
|
+
* @param args 需要输出的内容
|
|
3288
|
+
* @example
|
|
3289
|
+
* log.success("输出成功")
|
|
3278
3290
|
*/
|
|
3279
|
-
success(
|
|
3291
|
+
success(...args) {
|
|
3280
3292
|
if (this.#disable)
|
|
3281
3293
|
return;
|
|
3282
|
-
this.printContent
|
|
3294
|
+
this.printContent(args, this.#details.successColor);
|
|
3283
3295
|
}
|
|
3284
3296
|
/**
|
|
3285
3297
|
* 控制台-输出表格
|
|
3286
|
-
* @param msg
|
|
3287
|
-
* @param color 输出的颜色
|
|
3288
|
-
* @param otherStyle 其它CSS
|
|
3298
|
+
* @param msg 需要输出的内容
|
|
3289
3299
|
* @example
|
|
3290
3300
|
* log.table([{"名字":"example","值":"123"},{"名字":"example2","值":"345"}])
|
|
3291
3301
|
*/
|
|
3292
|
-
table(msg
|
|
3302
|
+
table(msg) {
|
|
3293
3303
|
if (this.#disable)
|
|
3294
3304
|
return;
|
|
3295
3305
|
this.checkClearConsole();
|
|
3296
3306
|
let stack = new Error().stack.split("\n");
|
|
3297
3307
|
stack.splice(0, 1);
|
|
3298
3308
|
let errorStackParse = this.parseErrorStack(stack);
|
|
3309
|
+
/** 堆栈函数名 */
|
|
3299
3310
|
let stackFunctionName = errorStackParse.name;
|
|
3311
|
+
/** 堆栈位置 */
|
|
3300
3312
|
let stackFunctionNamePosition = errorStackParse.position;
|
|
3301
3313
|
let callerName = stackFunctionName;
|
|
3302
|
-
this.#console.log(`%c[${this.tag}%c-%c${callerName}%c]%c`, ...this.#msgColorDetails, `color: ${
|
|
3314
|
+
this.#console.log(`%c[${this.tag}%c-%c${callerName}%c]%c`, ...this.#msgColorDetails, `color: ${this.#details.infoColor};`);
|
|
3303
3315
|
this.#console.table(msg);
|
|
3304
3316
|
if (this.#details.debug) {
|
|
3305
3317
|
this.#console.log(stackFunctionNamePosition);
|