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