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