@whitesev/utils 1.0.8 → 1.1.0
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 +20 -17
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +20 -17
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +20 -17
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +20 -17
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +20 -17
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +20 -17
- package/dist/index.umd.js.map +1 -1
- package/dist/src/Event.d.ts +156 -0
- package/dist/src/Httpx.d.ts +1 -1
- package/dist/src/Log.d.ts +4 -3
- package/dist/src/{index.d.ts → Utils.d.ts} +12 -166
- package/dist/src/UtilsGMMenu.d.ts +4 -4
- package/index.ts +1 -1
- package/package.json +1 -1
- package/src/Dictionary.ts +1 -1
- package/src/Event.ts +189 -0
- package/src/GBKEncoder.ts +1 -1
- package/src/Httpx.ts +1 -1
- package/src/LockFunction.ts +1 -1
- package/src/Log.ts +28 -25
- package/src/Progress.ts +1 -1
- package/src/{tryCatch.ts → TryCatch.ts} +1 -1
- package/src/{index.ts → Utils.ts} +16 -205
- package/src/UtilsGMCookie.ts +1 -1
- package/src/UtilsGMMenu.ts +1 -1
- package/src/indexedDB.ts +2 -4
- /package/dist/src/{tryCatch.d.ts → TryCatch.d.ts} +0 -0
package/dist/index.umd.js
CHANGED
|
@@ -2522,11 +2522,15 @@
|
|
|
2522
2522
|
}
|
|
2523
2523
|
|
|
2524
2524
|
class Log {
|
|
2525
|
-
/**
|
|
2525
|
+
/** 是否禁用输出的flag */
|
|
2526
2526
|
#disable = false;
|
|
2527
|
-
|
|
2527
|
+
/** 前面的TAG标志 */
|
|
2528
|
+
tag = "Utils.Log";
|
|
2529
|
+
/* 使用的console函数 */
|
|
2528
2530
|
#console = null;
|
|
2531
|
+
/* 当前输出的数量 */
|
|
2529
2532
|
#logCount = 0;
|
|
2533
|
+
/* 配置 */
|
|
2530
2534
|
#details = {
|
|
2531
2535
|
tag: true,
|
|
2532
2536
|
successColor: "#0000FF",
|
|
@@ -2537,10 +2541,6 @@
|
|
|
2537
2541
|
autoClearConsole: false,
|
|
2538
2542
|
logMaxCount: 999,
|
|
2539
2543
|
};
|
|
2540
|
-
/**
|
|
2541
|
-
* 待恢复的函数或对象
|
|
2542
|
-
*/
|
|
2543
|
-
#recoveryList = [];
|
|
2544
2544
|
#msgColorDetails = [
|
|
2545
2545
|
"font-weight: bold; color: cornflowerblue",
|
|
2546
2546
|
"font-weight: bold; color: cornflowerblue",
|
|
@@ -2548,15 +2548,17 @@
|
|
|
2548
2548
|
"font-weight: bold; color: cornflowerblue",
|
|
2549
2549
|
];
|
|
2550
2550
|
/**
|
|
2551
|
-
* @param _GM_info_ 油猴管理器的API GM_info,或者是一个对象,如{"script":{name:"Utils.Log"}}
|
|
2551
|
+
* @param _GM_info_ 油猴管理器的API GM_info,或者是一个对象,如{"script":{name:"Utils.Log"}},或者直接是一个字符串
|
|
2552
2552
|
* @param console 可指定console对象为unsafeWindow下的console或者是油猴window下的console
|
|
2553
2553
|
*/
|
|
2554
|
-
constructor(_GM_info_ = {
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
}
|
|
2558
|
-
|
|
2559
|
-
|
|
2554
|
+
constructor(_GM_info_, console = globalThis.console) {
|
|
2555
|
+
if (typeof _GM_info_ === "string") {
|
|
2556
|
+
this.tag = _GM_info_;
|
|
2557
|
+
}
|
|
2558
|
+
else if (typeof _GM_info_ === "object" &&
|
|
2559
|
+
typeof _GM_info_?.script?.name === "string") {
|
|
2560
|
+
this.tag = _GM_info_.script.name;
|
|
2561
|
+
}
|
|
2560
2562
|
this.#console = console;
|
|
2561
2563
|
}
|
|
2562
2564
|
/**
|
|
@@ -2578,10 +2580,11 @@
|
|
|
2578
2580
|
if (stackFunctionNamePositionMatch == null) {
|
|
2579
2581
|
continue;
|
|
2580
2582
|
}
|
|
2583
|
+
/* 获取最后一个,因为第一个是包含了at */
|
|
2581
2584
|
let stackFunctionName = stackFunctionNameMatch[stackFunctionNameMatch.length - 1];
|
|
2582
2585
|
let stackFunctionNamePosition = stackFunctionNamePositionMatch[stackFunctionNamePositionMatch.length - 1];
|
|
2583
2586
|
if (stackFunctionName === "" ||
|
|
2584
|
-
stackFunctionName.match(
|
|
2587
|
+
stackFunctionName.match(/^(Utils\.|)Log(\.|)|.<anonymous>$|^Function.each|^NodeList.forEach|^k.fn.init.each/g)) {
|
|
2585
2588
|
continue;
|
|
2586
2589
|
}
|
|
2587
2590
|
else {
|
|
@@ -2622,7 +2625,7 @@
|
|
|
2622
2625
|
* @param otherStyle 其它CSS
|
|
2623
2626
|
*/
|
|
2624
2627
|
printContent(msg, color, otherStyle) {
|
|
2625
|
-
this.checkClearConsole
|
|
2628
|
+
this.checkClearConsole();
|
|
2626
2629
|
otherStyle = otherStyle || "";
|
|
2627
2630
|
let stackSplit = new Error().stack.split("\n");
|
|
2628
2631
|
stackSplit.splice(0, 2);
|
|
@@ -2711,7 +2714,7 @@
|
|
|
2711
2714
|
table(msg, color = this.#details.infoColor, otherStyle = "") {
|
|
2712
2715
|
if (this.#disable)
|
|
2713
2716
|
return;
|
|
2714
|
-
this.checkClearConsole
|
|
2717
|
+
this.checkClearConsole();
|
|
2715
2718
|
let stack = new Error().stack.split("\n");
|
|
2716
2719
|
stack.splice(0, 1);
|
|
2717
2720
|
let errorStackParse = this.parseErrorStack(stack);
|
|
@@ -3080,7 +3083,7 @@
|
|
|
3080
3083
|
/// <reference path="./ajaxHooker/index.d.ts" />
|
|
3081
3084
|
class Utils {
|
|
3082
3085
|
/** 版本号 */
|
|
3083
|
-
version = "2024.5.
|
|
3086
|
+
version = "2024.5.28";
|
|
3084
3087
|
addStyle(cssText) {
|
|
3085
3088
|
if (typeof cssText !== "string") {
|
|
3086
3089
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|