@whitesev/utils 1.0.9 → 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/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.iife.js
CHANGED
|
@@ -2519,11 +2519,15 @@ var Utils = (function () {
|
|
|
2519
2519
|
}
|
|
2520
2520
|
|
|
2521
2521
|
class Log {
|
|
2522
|
-
/**
|
|
2522
|
+
/** 是否禁用输出的flag */
|
|
2523
2523
|
#disable = false;
|
|
2524
|
-
|
|
2524
|
+
/** 前面的TAG标志 */
|
|
2525
|
+
tag = "Utils.Log";
|
|
2526
|
+
/* 使用的console函数 */
|
|
2525
2527
|
#console = null;
|
|
2528
|
+
/* 当前输出的数量 */
|
|
2526
2529
|
#logCount = 0;
|
|
2530
|
+
/* 配置 */
|
|
2527
2531
|
#details = {
|
|
2528
2532
|
tag: true,
|
|
2529
2533
|
successColor: "#0000FF",
|
|
@@ -2534,10 +2538,6 @@ var Utils = (function () {
|
|
|
2534
2538
|
autoClearConsole: false,
|
|
2535
2539
|
logMaxCount: 999,
|
|
2536
2540
|
};
|
|
2537
|
-
/**
|
|
2538
|
-
* 待恢复的函数或对象
|
|
2539
|
-
*/
|
|
2540
|
-
#recoveryList = [];
|
|
2541
2541
|
#msgColorDetails = [
|
|
2542
2542
|
"font-weight: bold; color: cornflowerblue",
|
|
2543
2543
|
"font-weight: bold; color: cornflowerblue",
|
|
@@ -2545,15 +2545,17 @@ var Utils = (function () {
|
|
|
2545
2545
|
"font-weight: bold; color: cornflowerblue",
|
|
2546
2546
|
];
|
|
2547
2547
|
/**
|
|
2548
|
-
* @param _GM_info_ 油猴管理器的API GM_info,或者是一个对象,如{"script":{name:"Utils.Log"}}
|
|
2548
|
+
* @param _GM_info_ 油猴管理器的API GM_info,或者是一个对象,如{"script":{name:"Utils.Log"}},或者直接是一个字符串
|
|
2549
2549
|
* @param console 可指定console对象为unsafeWindow下的console或者是油猴window下的console
|
|
2550
2550
|
*/
|
|
2551
|
-
constructor(_GM_info_ = {
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
}
|
|
2555
|
-
|
|
2556
|
-
|
|
2551
|
+
constructor(_GM_info_, console = globalThis.console) {
|
|
2552
|
+
if (typeof _GM_info_ === "string") {
|
|
2553
|
+
this.tag = _GM_info_;
|
|
2554
|
+
}
|
|
2555
|
+
else if (typeof _GM_info_ === "object" &&
|
|
2556
|
+
typeof _GM_info_?.script?.name === "string") {
|
|
2557
|
+
this.tag = _GM_info_.script.name;
|
|
2558
|
+
}
|
|
2557
2559
|
this.#console = console;
|
|
2558
2560
|
}
|
|
2559
2561
|
/**
|
|
@@ -2575,10 +2577,11 @@ var Utils = (function () {
|
|
|
2575
2577
|
if (stackFunctionNamePositionMatch == null) {
|
|
2576
2578
|
continue;
|
|
2577
2579
|
}
|
|
2580
|
+
/* 获取最后一个,因为第一个是包含了at */
|
|
2578
2581
|
let stackFunctionName = stackFunctionNameMatch[stackFunctionNameMatch.length - 1];
|
|
2579
2582
|
let stackFunctionNamePosition = stackFunctionNamePositionMatch[stackFunctionNamePositionMatch.length - 1];
|
|
2580
2583
|
if (stackFunctionName === "" ||
|
|
2581
|
-
stackFunctionName.match(
|
|
2584
|
+
stackFunctionName.match(/^(Utils\.|)Log(\.|)|.<anonymous>$|^Function.each|^NodeList.forEach|^k.fn.init.each/g)) {
|
|
2582
2585
|
continue;
|
|
2583
2586
|
}
|
|
2584
2587
|
else {
|
|
@@ -2619,7 +2622,7 @@ var Utils = (function () {
|
|
|
2619
2622
|
* @param otherStyle 其它CSS
|
|
2620
2623
|
*/
|
|
2621
2624
|
printContent(msg, color, otherStyle) {
|
|
2622
|
-
this.checkClearConsole
|
|
2625
|
+
this.checkClearConsole();
|
|
2623
2626
|
otherStyle = otherStyle || "";
|
|
2624
2627
|
let stackSplit = new Error().stack.split("\n");
|
|
2625
2628
|
stackSplit.splice(0, 2);
|
|
@@ -2708,7 +2711,7 @@ var Utils = (function () {
|
|
|
2708
2711
|
table(msg, color = this.#details.infoColor, otherStyle = "") {
|
|
2709
2712
|
if (this.#disable)
|
|
2710
2713
|
return;
|
|
2711
|
-
this.checkClearConsole
|
|
2714
|
+
this.checkClearConsole();
|
|
2712
2715
|
let stack = new Error().stack.split("\n");
|
|
2713
2716
|
stack.splice(0, 1);
|
|
2714
2717
|
let errorStackParse = this.parseErrorStack(stack);
|
|
@@ -3077,7 +3080,7 @@ var Utils = (function () {
|
|
|
3077
3080
|
/// <reference path="./ajaxHooker/index.d.ts" />
|
|
3078
3081
|
class Utils {
|
|
3079
3082
|
/** 版本号 */
|
|
3080
|
-
version = "2024.5.
|
|
3083
|
+
version = "2024.5.28";
|
|
3081
3084
|
addStyle(cssText) {
|
|
3082
3085
|
if (typeof cssText !== "string") {
|
|
3083
3086
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|