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