@whitesev/utils 2.8.1 → 2.9.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.
Files changed (74) hide show
  1. package/README.md +176 -176
  2. package/dist/index.amd.js +271 -777
  3. package/dist/index.amd.js.map +1 -1
  4. package/dist/index.amd.min.js +2 -0
  5. package/dist/index.amd.min.js.map +1 -0
  6. package/dist/index.cjs.js +271 -777
  7. package/dist/index.cjs.js.map +1 -1
  8. package/dist/index.cjs.min.js +2 -0
  9. package/dist/index.cjs.min.js.map +1 -0
  10. package/dist/index.esm.js +271 -777
  11. package/dist/index.esm.js.map +1 -1
  12. package/dist/index.esm.min.js +2 -0
  13. package/dist/index.esm.min.js.map +1 -0
  14. package/dist/index.iife.js +271 -777
  15. package/dist/index.iife.js.map +1 -1
  16. package/dist/index.iife.min.js +2 -0
  17. package/dist/index.iife.min.js.map +1 -0
  18. package/dist/index.system.js +271 -777
  19. package/dist/index.system.js.map +1 -1
  20. package/dist/index.system.min.js +2 -0
  21. package/dist/index.system.min.js.map +1 -0
  22. package/dist/index.umd.js +271 -777
  23. package/dist/index.umd.js.map +1 -1
  24. package/dist/index.umd.min.js +2 -0
  25. package/dist/index.umd.min.js.map +1 -0
  26. package/dist/types/src/Utils.d.ts +103 -450
  27. package/dist/types/src/UtilsGMCookie.d.ts +4 -0
  28. package/dist/types/src/UtilsGMMenu.d.ts +3 -6
  29. package/dist/types/src/types/Httpx.d.ts +1344 -1344
  30. package/dist/types/src/types/Log.d.ts +19 -19
  31. package/dist/types/src/types/Progress.d.ts +20 -20
  32. package/dist/types/src/types/React.d.ts +119 -119
  33. package/dist/types/src/types/TryCatch.d.ts +9 -9
  34. package/dist/types/src/types/UtilsGMCookie.d.ts +93 -93
  35. package/dist/types/src/types/UtilsGMMenu.d.ts +77 -77
  36. package/dist/types/src/types/Vue2.d.ts +166 -166
  37. package/dist/types/src/types/WindowApi.d.ts +14 -14
  38. package/dist/types/src/types/ajaxHooker.d.ts +151 -151
  39. package/dist/types/src/types/env.d.ts +7 -7
  40. package/dist/types/src/types/global.d.ts +31 -31
  41. package/index.ts +3 -0
  42. package/package.json +16 -10
  43. package/src/ColorConversion.ts +105 -105
  44. package/src/CommonUtil.ts +280 -280
  45. package/src/DOMUtils.ts +251 -251
  46. package/src/Dictionary.ts +153 -153
  47. package/src/GBKEncoder.ts +108 -108
  48. package/src/Hooks.ts +73 -73
  49. package/src/Httpx.ts +1457 -1457
  50. package/src/LockFunction.ts +62 -62
  51. package/src/Log.ts +258 -258
  52. package/src/Progress.ts +108 -108
  53. package/src/TryCatch.ts +86 -86
  54. package/src/Utils.ts +3778 -4772
  55. package/src/UtilsCommon.ts +14 -14
  56. package/src/UtilsGMCookie.ts +272 -254
  57. package/src/UtilsGMMenu.ts +441 -445
  58. package/src/Vue.ts +233 -233
  59. package/src/WindowApi.ts +59 -59
  60. package/src/indexedDB.ts +497 -497
  61. package/src/types/Httpx.d.ts +1344 -1344
  62. package/src/types/Log.d.ts +19 -19
  63. package/src/types/Progress.d.ts +20 -20
  64. package/src/types/React.d.ts +119 -119
  65. package/src/types/TryCatch.d.ts +9 -9
  66. package/src/types/UtilsGMCookie.d.ts +93 -93
  67. package/src/types/UtilsGMMenu.d.ts +77 -77
  68. package/src/types/Vue2.d.ts +166 -166
  69. package/src/types/WindowApi.d.ts +14 -14
  70. package/src/types/ajaxHooker.d.ts +151 -151
  71. package/src/types/env.d.ts +7 -7
  72. package/src/types/global.d.ts +31 -31
  73. package/dist/types/src/types/Event.d.ts +0 -188
  74. package/src/types/Event.d.ts +0 -188
@@ -524,18 +524,12 @@ System.register('Utils', [], (function (exports) {
524
524
  }
525
525
  return findValue;
526
526
  }
527
- /**
528
- * 获取多组Cookie
529
- * @param option 配置
530
- * @param callback 获取操作后的回调
531
- * + cookies object[]
532
- * + error string|undefined
533
- **/
534
527
  list(option, callback) {
535
528
  if (option == null) {
536
529
  throw new Error("Utils.GMCookie.list 参数不能为空");
537
530
  }
538
531
  const resultData = [];
532
+ let error;
539
533
  try {
540
534
  let defaultOption = {
541
535
  url: this.windowApi.window.location.href,
@@ -569,14 +563,18 @@ System.register('Utils', [], (function (exports) {
569
563
  });
570
564
  }
571
565
  });
572
- if (typeof callback === "function") {
573
- callback(resultData);
574
- }
575
566
  }
576
- catch (error) {
577
- if (typeof callback === "function") {
578
- callback(resultData, error);
579
- }
567
+ catch (e) {
568
+ error = e;
569
+ }
570
+ if (typeof callback === "function") {
571
+ callback(resultData, error);
572
+ }
573
+ else {
574
+ return {
575
+ cookies: resultData,
576
+ error: error,
577
+ };
580
578
  }
581
579
  }
582
580
  /**
@@ -1785,7 +1783,7 @@ System.register('Utils', [], (function (exports) {
1785
1783
  },
1786
1784
  /**
1787
1785
  * 注册油猴菜单
1788
- * @param menuOptions 如果存在,使用它
1786
+ * @param menuOptions (可选)菜单配置
1789
1787
  */
1790
1788
  register(menuOptions) {
1791
1789
  const that = this;
@@ -1809,7 +1807,8 @@ System.register('Utils', [], (function (exports) {
1809
1807
  },
1810
1808
  /**
1811
1809
  * 获取本地存储菜单键值
1812
- * @param {string} key 键
1810
+ * @param key 键
1811
+ * @param defaultValue 默认值
1813
1812
  */
1814
1813
  getLocalMenuData(key, defaultValue) {
1815
1814
  const localData = this.context.GM_Api.getValue(this.$data.key, {});
@@ -1832,7 +1831,7 @@ System.register('Utils', [], (function (exports) {
1832
1831
  },
1833
1832
  /**
1834
1833
  * 处理初始化配置
1835
- * @param menuOption
1834
+ * @param menuOption 菜单配置
1836
1835
  */
1837
1836
  handleInitDetail(menuOption) {
1838
1837
  menuOption.enable = Boolean(this.getLocalMenuData(menuOption.key, menuOption.enable));
@@ -1850,7 +1849,7 @@ System.register('Utils', [], (function (exports) {
1850
1849
  },
1851
1850
  /**
1852
1851
  * 对菜单数据进行处理
1853
- * @param menuOption
1852
+ * @param menuOption 菜单配置
1854
1853
  */
1855
1854
  handleMenuData(menuOption) {
1856
1855
  const that = this;
@@ -1938,6 +1937,9 @@ System.register('Utils', [], (function (exports) {
1938
1937
  return this.$data.data.find((item) => item.handleData.key === menuKey)?.handleData;
1939
1938
  },
1940
1939
  };
1940
+ /**
1941
+ * @param details 菜单配置
1942
+ */
1941
1943
  constructor(details) {
1942
1944
  this.GM_Api.getValue = details.GM_getValue;
1943
1945
  this.GM_Api.setValue = details.GM_setValue;
@@ -2025,14 +2027,6 @@ System.register('Utils', [], (function (exports) {
2025
2027
  delete(menuId) {
2026
2028
  this.GM_Api.unregisterMenuCommand(menuId);
2027
2029
  }
2028
- /**
2029
- * 根据键值获取enable值
2030
- * @param menuKey 菜单-键key
2031
- * @deprecated
2032
- */
2033
- get(menuKey) {
2034
- return this.getEnable(menuKey);
2035
- }
2036
2030
  /**
2037
2031
  * 根据键值获取enable值
2038
2032
  * @param menuKey 菜单-键key
@@ -2190,11 +2184,11 @@ System.register('Utils', [], (function (exports) {
2190
2184
  return "";
2191
2185
  }
2192
2186
  try {
2193
- new Function("_context", "_funcName", "hookFunc", `_context[_funcName] = function ${_funcName}() {
2194
- let args = Array.prototype.slice.call(arguments, 0);
2195
- let obj = this;
2196
- hookFunc.apply(obj, args);
2197
- return _context['realFunc_${_funcName}'].apply(obj, args);
2187
+ new Function("_context", "_funcName", "hookFunc", `_context[_funcName] = function ${_funcName}() {
2188
+ let args = Array.prototype.slice.call(arguments, 0);
2189
+ let obj = this;
2190
+ hookFunc.apply(obj, args);
2191
+ return _context['realFunc_${_funcName}'].apply(obj, args);
2198
2192
  };`)(_context, _funcName, hookFunc);
2199
2193
  _context[_funcName].prototype.isHooked = true;
2200
2194
  return true;
@@ -5483,38 +5477,15 @@ System.register('Utils', [], (function (exports) {
5483
5477
  }
5484
5478
  const domUtils = new DOMUtils();
5485
5479
 
5480
+ const version = "2.9.0";
5481
+
5486
5482
  class Utils {
5487
5483
  windowApi;
5488
5484
  constructor(option) {
5489
5485
  this.windowApi = new WindowApi(option);
5490
5486
  }
5491
5487
  /** 版本号 */
5492
- version = "2025.9.14";
5493
- addStyle(cssText) {
5494
- if (typeof cssText !== "string") {
5495
- throw new Error("Utils.addStyle 参数cssText 必须为String类型");
5496
- }
5497
- const cssNode = this.windowApi.document.createElement("style");
5498
- cssNode.setAttribute("type", "text/css");
5499
- cssNode.innerHTML = cssText;
5500
- if (this.windowApi.document.head) {
5501
- /* 插入head最后 */
5502
- this.windowApi.document.head.appendChild(cssNode);
5503
- }
5504
- else if (this.windowApi.document.body) {
5505
- /* 插入body后 */
5506
- this.windowApi.document.body.appendChild(cssNode);
5507
- }
5508
- else if (this.windowApi.document.documentElement.childNodes.length === 0) {
5509
- /* 插入#html第一个元素后 */
5510
- this.windowApi.document.documentElement.appendChild(cssNode);
5511
- }
5512
- else {
5513
- /* 插入head前面 */
5514
- this.windowApi.document.documentElement.insertBefore(cssNode, this.windowApi.document.documentElement.childNodes[0]);
5515
- }
5516
- return cssNode;
5517
- }
5488
+ version = version;
5518
5489
  /**
5519
5490
  * JSON数据从源端替换到目标端中,如果目标端存在该数据则替换,不添加,返回结果为目标端替换完毕的结果
5520
5491
  * @param target 目标数据
@@ -5532,7 +5503,7 @@ System.register('Utils', [], (function (exports) {
5532
5503
  */
5533
5504
  assign = commonUtil.assign.bind(commonUtil);
5534
5505
  async asyncReplaceAll(string, pattern, asyncFn) {
5535
- const UtilsContext = this;
5506
+ const that = this;
5536
5507
  if (typeof string !== "string") {
5537
5508
  throw new TypeError("string必须是字符串");
5538
5509
  }
@@ -5541,7 +5512,7 @@ System.register('Utils', [], (function (exports) {
5541
5512
  }
5542
5513
  let reg;
5543
5514
  if (typeof pattern === "string") {
5544
- reg = new RegExp(UtilsContext.parseStringToRegExpString(pattern), "g");
5515
+ reg = new RegExp(that.toRegExpStr(pattern), "g");
5545
5516
  }
5546
5517
  else if (pattern instanceof RegExp) {
5547
5518
  if (!pattern.global) {
@@ -5573,7 +5544,7 @@ System.register('Utils', [], (function (exports) {
5573
5544
  * ajax劫持库,支持xhr和fetch劫持。
5574
5545
  * + 来源:https://bbs.tampermonkey.net.cn/thread-3284-1-1.html
5575
5546
  * + 作者:cxxjackie
5576
- * + 版本:1.4.7
5547
+ * + 版本:1.4.8
5577
5548
  * + 旧版本:1.2.4
5578
5549
  * + 文档:https://scriptcat.org/zh-CN/script-show-page/637/
5579
5550
  * @param useOldVersion 是否使用旧版本,默认false
@@ -5603,41 +5574,6 @@ System.register('Utils', [], (function (exports) {
5603
5574
  canvasElement.dispatchEvent(new MouseEvent("mousedown", eventInit));
5604
5575
  canvasElement.dispatchEvent(new MouseEvent("mouseup", eventInit));
5605
5576
  }
5606
- checkUserClickInNode(element) {
5607
- const UtilsContext = this;
5608
- if (!UtilsContext.isDOM(element)) {
5609
- throw new Error("Utils.checkUserClickInNode 参数 targetNode 必须为 Element|Node 类型");
5610
- }
5611
- const clickEvent = UtilsContext.windowApi.window.event;
5612
- const touchEvent = UtilsContext.windowApi.window.event;
5613
- const $click = clickEvent?.composedPath()?.[0];
5614
- // 点击的x坐标
5615
- const clickPosX = clickEvent?.clientX != null ? clickEvent.clientX : touchEvent.touches[0].clientX;
5616
- // 点击的y坐标
5617
- const clickPosY = clickEvent?.clientY != null ? clickEvent.clientY : touchEvent.touches[0].clientY;
5618
- const {
5619
- /* 要检测的元素的相对屏幕的横坐标最左边 */
5620
- left: elementPosXLeft,
5621
- /* 要检测的元素的相对屏幕的横坐标最右边 */
5622
- right: elementPosXRight,
5623
- /* 要检测的元素的相对屏幕的纵坐标最上边 */
5624
- top: elementPosYTop,
5625
- /* 要检测的元素的相对屏幕的纵坐标最下边 */
5626
- bottom: elementPosYBottom, } = element.getBoundingClientRect();
5627
- if (clickPosX >= elementPosXLeft &&
5628
- clickPosX <= elementPosXRight &&
5629
- clickPosY >= elementPosYTop &&
5630
- clickPosY <= elementPosYBottom) {
5631
- return true;
5632
- }
5633
- else if (($click && element.contains($click)) || $click == element) {
5634
- /* 这种情况是应对在界面中隐藏的元素,getBoundingClientRect获取的都是0 */
5635
- return true;
5636
- }
5637
- else {
5638
- return false;
5639
- }
5640
- }
5641
5577
  /**
5642
5578
  * 复制formData数据
5643
5579
  * @param formData 需要clone的数据
@@ -5685,33 +5621,14 @@ System.register('Utils', [], (function (exports) {
5685
5621
  deepClone = commonUtil.deepClone.bind(commonUtil);
5686
5622
  debounce(fn, delay = 0) {
5687
5623
  let timer = null;
5688
- const UtilsContext = this;
5624
+ const that = this;
5689
5625
  return function (...args) {
5690
- UtilsContext.workerClearTimeout(timer);
5691
- timer = UtilsContext.workerSetTimeout(function () {
5692
- fn.apply(UtilsContext, args);
5626
+ that.workerClearTimeout(timer);
5627
+ timer = that.workerSetTimeout(function () {
5628
+ fn.apply(that, args);
5693
5629
  }, delay);
5694
5630
  };
5695
5631
  }
5696
- deleteParentNode(element, targetSelector) {
5697
- const UtilsContext = this;
5698
- if (element == null) {
5699
- return;
5700
- }
5701
- if (!UtilsContext.isDOM(element)) {
5702
- throw new Error("Utils.deleteParentNode 参数 target 必须为 Node|HTMLElement 类型");
5703
- }
5704
- if (typeof targetSelector !== "string") {
5705
- throw new Error("Utils.deleteParentNode 参数 targetSelector 必须为 string 类型");
5706
- }
5707
- let result = false;
5708
- const needRemoveDOM = domUtils.closest(element, targetSelector);
5709
- if (needRemoveDOM) {
5710
- needRemoveDOM.remove();
5711
- result = true;
5712
- }
5713
- return result;
5714
- }
5715
5632
  /**
5716
5633
  * 字典
5717
5634
  * @example
@@ -5725,25 +5642,8 @@ System.register('Utils', [], (function (exports) {
5725
5642
  * dictionary.concat(dictionary2);
5726
5643
  **/
5727
5644
  Dictionary = UtilsDictionary;
5728
- dispatchEvent(element, eventName, details) {
5729
- // let UtilsContext = this;
5730
- let eventNameList = [];
5731
- if (typeof eventName === "string") {
5732
- eventNameList = [eventName];
5733
- }
5734
- if (Array.isArray(eventName)) {
5735
- eventNameList = [...eventName];
5736
- }
5737
- eventNameList.forEach((_eventName_) => {
5738
- const event = new Event(_eventName_);
5739
- if (details) {
5740
- Object.assign(event, details);
5741
- }
5742
- element.dispatchEvent(event);
5743
- });
5744
- }
5745
5645
  downloadBase64(base64Data, fileName, isIFrame = false) {
5746
- const UtilsContext = this;
5646
+ const that = this;
5747
5647
  if (typeof base64Data !== "string") {
5748
5648
  throw new Error("Utils.downloadBase64 参数 base64Data 必须为 string 类型");
5749
5649
  }
@@ -5752,13 +5652,13 @@ System.register('Utils', [], (function (exports) {
5752
5652
  }
5753
5653
  if (isIFrame) {
5754
5654
  /* 使用iframe */
5755
- const iframeElement = this.windowApi.document.createElement("iframe");
5756
- iframeElement.style.display = "none";
5757
- iframeElement.src = base64Data;
5758
- this.windowApi.document.body.appendChild(iframeElement);
5759
- UtilsContext.workerSetTimeout(() => {
5760
- iframeElement.contentWindow.document.execCommand("SaveAs", true, fileName);
5761
- this.windowApi.document.body.removeChild(iframeElement);
5655
+ const $iframe = this.windowApi.document.createElement("iframe");
5656
+ $iframe.style.display = "none";
5657
+ $iframe.src = base64Data;
5658
+ (this.windowApi.document.body || this.windowApi.document.documentElement).appendChild($iframe);
5659
+ that.workerSetTimeout(() => {
5660
+ $iframe.contentWindow.document.execCommand("SaveAs", true, fileName);
5661
+ (this.windowApi.document.body || this.windowApi.document.documentElement).removeChild($iframe);
5762
5662
  }, 100);
5763
5663
  }
5764
5664
  else {
@@ -5808,50 +5708,6 @@ System.register('Utils', [], (function (exports) {
5808
5708
  }
5809
5709
  return strFound ? true : false;
5810
5710
  }
5811
- *findElementsWithText(element, text, filter) {
5812
- const that = this;
5813
- if (element.outerHTML.includes(text)) {
5814
- if (element.children.length === 0) {
5815
- const filterResult = typeof filter === "function" ? filter(element) : false;
5816
- if (!filterResult) {
5817
- yield element;
5818
- }
5819
- }
5820
- else {
5821
- const textElement = Array.from(element.childNodes).filter((ele) => ele.nodeType === Node.TEXT_NODE);
5822
- for (const $child of textElement) {
5823
- if ($child.textContent.includes(text)) {
5824
- const filterResult = typeof filter === "function" ? filter(element) : false;
5825
- if (!filterResult) {
5826
- yield $child;
5827
- }
5828
- }
5829
- }
5830
- }
5831
- }
5832
- for (let index = 0; index < element.children.length; index++) {
5833
- const $child = element.children[index];
5834
- yield* that.findElementsWithText($child, text, filter);
5835
- }
5836
- }
5837
- /**
5838
- * 判断该元素是否可见,如果不可见,向上找它的父元素直至找到可见的元素
5839
- * @param element
5840
- * @example
5841
- * let visibleElement = Utils.findVisibleElement(document.querySelector("a.xx"));
5842
- * > <HTMLElement>
5843
- */
5844
- findVisibleElement(element) {
5845
- let currentElement = element;
5846
- while (currentElement) {
5847
- const elementRect = currentElement.getBoundingClientRect();
5848
- if (elementRect.length) {
5849
- return currentElement;
5850
- }
5851
- currentElement = currentElement.parentElement;
5852
- }
5853
- return null;
5854
- }
5855
5711
  formatByteToSize(byteSize, addType = true) {
5856
5712
  byteSize = parseInt(byteSize.toString());
5857
5713
  if (isNaN(byteSize)) {
@@ -5900,9 +5756,9 @@ System.register('Utils', [], (function (exports) {
5900
5756
  }
5901
5757
  getNonNullValue(...args) {
5902
5758
  let resultValue = args[args.length - 1];
5903
- const UtilsContext = this;
5759
+ const that = this;
5904
5760
  for (const argValue of args) {
5905
- if (UtilsContext.isNotNull(argValue)) {
5761
+ if (that.isNotNull(argValue)) {
5906
5762
  resultValue = argValue;
5907
5763
  break;
5908
5764
  }
@@ -5976,20 +5832,8 @@ System.register('Utils', [], (function (exports) {
5976
5832
  * > 测试
5977
5833
  */
5978
5834
  GBKEncoder = GBKEncoder;
5979
- /**
5980
- * 获取 transitionend 的在各个浏览器的兼容名
5981
- */
5982
- getTransitionEndNameList() {
5983
- return ["webkitTransitionEnd", "mozTransitionEnd", "MSTransitionEnd", "otransitionend", "transitionend"];
5984
- }
5985
- /**
5986
- * 获取 animationend 的在各个浏览器的兼容名
5987
- */
5988
- getAnimationEndNameList() {
5989
- return ["webkitAnimationEnd", "mozAnimationEnd", "MSAnimationEnd", "oanimationend", "animationend"];
5990
- }
5991
- getArrayLastValue(targetObj) {
5992
- return targetObj[targetObj.length - 1];
5835
+ getArrayLastValue(target) {
5836
+ return target[target.length - 1];
5993
5837
  }
5994
5838
  getArrayRealValue(...args) {
5995
5839
  let result = null;
@@ -6074,30 +5918,6 @@ System.register('Utils', [], (function (exports) {
6074
5918
  }
6075
5919
  return diffValue;
6076
5920
  }
6077
- getElementSelector(element) {
6078
- const UtilsContext = this;
6079
- if (!element)
6080
- return void 0;
6081
- if (!element.parentElement)
6082
- return void 0;
6083
- /* 如果元素有id属性,则直接返回id选择器 */
6084
- if (element.id)
6085
- return `#${element.id}`;
6086
- /* 递归地获取父元素的选择器 */
6087
- let selector = UtilsContext.getElementSelector(element.parentElement);
6088
- if (!selector) {
6089
- return element.tagName.toLowerCase();
6090
- }
6091
- /* 如果有多个相同类型的兄弟元素,则需要添加索引 */
6092
- if (element.parentElement.querySelectorAll(element.tagName).length > 1) {
6093
- const index = Array.prototype.indexOf.call(element.parentElement.children, element) + 1;
6094
- selector += ` > ${element.tagName.toLowerCase()}:nth-child(${index})`;
6095
- }
6096
- else {
6097
- selector += ` > ${element.tagName.toLowerCase()}`;
6098
- }
6099
- return selector;
6100
- }
6101
5921
  /**
6102
5922
  * 获取最大值
6103
5923
  * @example
@@ -6138,7 +5958,7 @@ System.register('Utils', [], (function (exports) {
6138
5958
  }
6139
5959
  getMaxZIndexNodeInfo(deviation = 1, target = this.windowApi.document, ignoreCallBack) {
6140
5960
  deviation = Number.isNaN(deviation) ? 1 : deviation;
6141
- const UtilsContext = this;
5961
+ const that = this;
6142
5962
  // 最大值 2147483647
6143
5963
  // const maxZIndex = Math.pow(2, 31) - 1;
6144
5964
  // 比较值 2000000000
@@ -6167,7 +5987,7 @@ System.register('Utils', [], (function (exports) {
6167
5987
  }
6168
5988
  }
6169
5989
  /** 元素的样式 */
6170
- const nodeStyle = UtilsContext.windowApi.window.getComputedStyle($ele);
5990
+ const nodeStyle = that.windowApi.window.getComputedStyle($ele);
6171
5991
  /* 不对position为static和display为none的元素进行获取它们的z-index */
6172
5992
  if (isVisibleNode(nodeStyle)) {
6173
5993
  const nodeZIndex = parseInt(nodeStyle.zIndex);
@@ -6241,7 +6061,7 @@ System.register('Utils', [], (function (exports) {
6241
6061
  * > 'Mozilla/5.0 (Linux; Android 10; MI 13 Build/OPR1.170623.027; wv) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.3490.40 Mobile Safari/537.36'
6242
6062
  **/
6243
6063
  getRandomAndroidUA() {
6244
- const UtilsContext = this;
6064
+ const that = this;
6245
6065
  const mobileNameList = [
6246
6066
  "LDN-LX3",
6247
6067
  "RNE-L03",
@@ -6259,14 +6079,14 @@ System.register('Utils', [], (function (exports) {
6259
6079
  "MI 13 Build/OPR1.170623.027; wv",
6260
6080
  ];
6261
6081
  /* 安卓版本 */
6262
- const androidVersion = UtilsContext.getRandomValue(12, 14);
6082
+ const androidVersion = that.getRandomValue(12, 14);
6263
6083
  /* 手机型号 */
6264
- const randomMobile = UtilsContext.getRandomValue(mobileNameList);
6084
+ const randomMobile = that.getRandomValue(mobileNameList);
6265
6085
  /* chrome大版本号 */
6266
- const chromeVersion1 = UtilsContext.getRandomValue(120, 132);
6267
- const chromeVersion2 = UtilsContext.getRandomValue(0, 0);
6268
- const chromeVersion3 = UtilsContext.getRandomValue(2272, 6099);
6269
- const chromeVersion4 = UtilsContext.getRandomValue(1, 218);
6086
+ const chromeVersion1 = that.getRandomValue(130, 140);
6087
+ const chromeVersion2 = that.getRandomValue(0, 0);
6088
+ const chromeVersion3 = that.getRandomValue(2272, 6099);
6089
+ const chromeVersion4 = that.getRandomValue(1, 218);
6270
6090
  return `Mozilla/5.0 (Linux; Android ${androidVersion}; ${randomMobile}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${chromeVersion1}.${chromeVersion2}.${chromeVersion3}.${chromeVersion4} Mobile Safari/537.36`;
6271
6091
  }
6272
6092
  /**
@@ -6288,12 +6108,12 @@ System.register('Utils', [], (function (exports) {
6288
6108
  * > 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.5068.19 Safari/537.36'
6289
6109
  **/
6290
6110
  getRandomPCUA() {
6291
- const UtilsContext = this;
6111
+ const that = this;
6292
6112
  /* chrome大版本号 */
6293
- const chromeVersion1 = UtilsContext.getRandomValue(120, 132);
6294
- const chromeVersion2 = UtilsContext.getRandomValue(0, 0);
6295
- const chromeVersion3 = UtilsContext.getRandomValue(2272, 6099);
6296
- const chromeVersion4 = UtilsContext.getRandomValue(1, 218);
6113
+ const chromeVersion1 = that.getRandomValue(130, 140);
6114
+ const chromeVersion2 = that.getRandomValue(0, 0);
6115
+ const chromeVersion3 = that.getRandomValue(2272, 6099);
6116
+ const chromeVersion4 = that.getRandomValue(1, 218);
6297
6117
  return `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${chromeVersion1}.${chromeVersion2}.${chromeVersion3}.${chromeVersion4} Safari/537.36`;
6298
6118
  }
6299
6119
  getRandomValue(...args) {
@@ -6327,9 +6147,9 @@ System.register('Utils', [], (function (exports) {
6327
6147
  * @param element 需要获取的目标元素
6328
6148
  * @returns
6329
6149
  * @example
6330
- * Utils.getReactObj(document.querySelector("input"))?.reactProps?.onChange({target:{value:"123"}});
6150
+ * Utils.getReactInstance(document.querySelector("input"))?.reactProps?.onChange({target:{value:"123"}});
6331
6151
  */
6332
- getReactObj(element) {
6152
+ getReactInstance(element) {
6333
6153
  const result = {};
6334
6154
  if (element == null) {
6335
6155
  return result;
@@ -6339,7 +6159,9 @@ System.register('Utils', [], (function (exports) {
6339
6159
  if (domPropsName.startsWith("__react")) {
6340
6160
  const propsName = domPropsName.replace(/__(.+)\$.+/i, "$1");
6341
6161
  const propsValue = Reflect.get(element, domPropsName);
6342
- if (propsName in result) ;
6162
+ if (propsName in result) {
6163
+ console.error(`重复属性 ${domPropsName}`);
6164
+ }
6343
6165
  else {
6344
6166
  Reflect.set(result, propsName, propsValue);
6345
6167
  }
@@ -6394,8 +6216,8 @@ System.register('Utils', [], (function (exports) {
6394
6216
  return bytes.length;
6395
6217
  }
6396
6218
  getTextStorageSize(text, addType = true) {
6397
- const UtilsContext = this;
6398
- return UtilsContext.formatByteToSize(UtilsContext.getTextLength(text), addType);
6219
+ const that = this;
6220
+ return that.formatByteToSize(that.getTextLength(text), addType);
6399
6221
  }
6400
6222
  getThunderUrl(url) {
6401
6223
  if (url == null) {
@@ -6969,12 +6791,12 @@ System.register('Utils', [], (function (exports) {
6969
6791
  }
6970
6792
  isWebView_Via() {
6971
6793
  let result = true;
6972
- const UtilsContext = this;
6794
+ const that = this;
6973
6795
  if (typeof this.windowApi.top.window.via === "object") {
6974
6796
  for (const key in Object.values(this.windowApi.top.window.via)) {
6975
6797
  if (Reflect.has(this.windowApi.top.window.via, key)) {
6976
6798
  const objValueFunc = this.windowApi.top.window.via[key];
6977
- if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
6799
+ if (typeof objValueFunc === "function" && that.isNativeFunc(objValueFunc)) {
6978
6800
  result = true;
6979
6801
  }
6980
6802
  else {
@@ -6991,12 +6813,12 @@ System.register('Utils', [], (function (exports) {
6991
6813
  }
6992
6814
  isWebView_X() {
6993
6815
  let result = true;
6994
- const UtilsContext = this;
6816
+ const that = this;
6995
6817
  if (typeof this.windowApi.top.window.mbrowser === "object") {
6996
6818
  for (const key in Object.values(this.windowApi.top.window.mbrowser)) {
6997
6819
  if (Reflect.has(this.windowApi.top.window.mbrowser, key)) {
6998
6820
  const objValueFunc = this.windowApi.top.window.mbrowser[key];
6999
- if (typeof objValueFunc === "function" && UtilsContext.isNativeFunc(objValueFunc)) {
6821
+ if (typeof objValueFunc === "function" && that.isNativeFunc(objValueFunc)) {
7000
6822
  result = true;
7001
6823
  }
7002
6824
  else {
@@ -7016,8 +6838,10 @@ System.register('Utils', [], (function (exports) {
7016
6838
  throw new Error("Utils.parseObjectToArray 参数 target 必须为 object 类型");
7017
6839
  }
7018
6840
  let result = [];
7019
- Object.keys(target).forEach(function (keyName) {
7020
- result = result.concat(target[keyName]);
6841
+ const keys = Object.keys(target);
6842
+ keys.forEach(function (keyName) {
6843
+ const value = Reflect.get(target, keyName);
6844
+ result = result.concat(value);
7021
6845
  });
7022
6846
  return result;
7023
6847
  }
@@ -7090,7 +6914,7 @@ System.register('Utils', [], (function (exports) {
7090
6914
  return content;
7091
6915
  }
7092
6916
  mutationObserver(target, observer_config) {
7093
- const UtilsContext = this;
6917
+ const that = this;
7094
6918
  const default_obverser_config = {
7095
6919
  /* 监听到元素有反馈,需执行的函数 */
7096
6920
  callback: () => { },
@@ -7132,7 +6956,7 @@ System.register('Utils', [], (function (exports) {
7132
6956
  },
7133
6957
  immediate: false,
7134
6958
  };
7135
- observer_config = UtilsContext.assign(default_obverser_config, observer_config);
6959
+ observer_config = that.assign(default_obverser_config, observer_config);
7136
6960
  const windowMutationObserver = this.windowApi.window.MutationObserver ||
7137
6961
  this.windowApi.window.webkitMutationObserver ||
7138
6962
  this.windowApi.window.MozMutationObserver;
@@ -7148,7 +6972,7 @@ System.register('Utils', [], (function (exports) {
7148
6972
  mutationObserver.observe(item, observer_config.config);
7149
6973
  });
7150
6974
  }
7151
- else if (UtilsContext.isJQuery(target)) {
6975
+ else if (that.isJQuery(target)) {
7152
6976
  /* 传入的参数是jQuery对象 */
7153
6977
  target.each((_, item) => {
7154
6978
  mutationObserver.observe(item, observer_config.config);
@@ -7218,7 +7042,7 @@ System.register('Utils', [], (function (exports) {
7218
7042
  return utils;
7219
7043
  }
7220
7044
  noConflictFunc(needReleaseObject, needReleaseName, functionNameList = [], release = true) {
7221
- const UtilsContext = this;
7045
+ const that = this;
7222
7046
  if (typeof needReleaseObject !== "object") {
7223
7047
  throw new Error("Utils.noConflictFunc 参数 needReleaseObject 必须为 object 类型");
7224
7048
  }
@@ -7233,11 +7057,11 @@ System.register('Utils', [], (function (exports) {
7233
7057
  * 释放所有
7234
7058
  */
7235
7059
  function releaseAll() {
7236
- if (typeof UtilsContext.windowApi.window[needReleaseKey] !== "undefined") {
7060
+ if (typeof that.windowApi.window[needReleaseKey] !== "undefined") {
7237
7061
  /* 已存在 */
7238
7062
  return;
7239
7063
  }
7240
- UtilsContext.windowApi.window[needReleaseKey] = UtilsContext.deepClone(needReleaseObject);
7064
+ that.windowApi.window[needReleaseKey] = that.deepClone(needReleaseObject);
7241
7065
  Object.values(needReleaseObject).forEach((value) => {
7242
7066
  if (typeof value === "function") {
7243
7067
  needReleaseObject[value.name] = () => { };
@@ -7251,11 +7075,11 @@ System.register('Utils', [], (function (exports) {
7251
7075
  Array.from(functionNameList).forEach((item) => {
7252
7076
  Object.values(needReleaseObject).forEach((value) => {
7253
7077
  if (typeof value === "function") {
7254
- if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
7255
- UtilsContext.windowApi.window[needReleaseKey] = {};
7078
+ if (typeof that.windowApi.window[needReleaseKey] === "undefined") {
7079
+ that.windowApi.window[needReleaseKey] = {};
7256
7080
  }
7257
7081
  if (item === value.name) {
7258
- UtilsContext.windowApi.window[needReleaseKey][value.name] = needReleaseObject[value.name];
7082
+ that.windowApi.window[needReleaseKey][value.name] = needReleaseObject[value.name];
7259
7083
  needReleaseObject[value.name] = () => { };
7260
7084
  }
7261
7085
  }
@@ -7266,26 +7090,26 @@ System.register('Utils', [], (function (exports) {
7266
7090
  * 恢复所有
7267
7091
  */
7268
7092
  function recoveryAll() {
7269
- if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
7093
+ if (typeof that.windowApi.window[needReleaseKey] === "undefined") {
7270
7094
  /* 未存在 */
7271
7095
  return;
7272
7096
  }
7273
- Object.assign(needReleaseObject, UtilsContext.windowApi.window[needReleaseKey]);
7274
- Reflect.deleteProperty(UtilsContext.windowApi.window, "needReleaseKey");
7097
+ Object.assign(needReleaseObject, that.windowApi.window[needReleaseKey]);
7098
+ Reflect.deleteProperty(that.windowApi.window, "needReleaseKey");
7275
7099
  }
7276
7100
  /**
7277
7101
  * 恢复单个
7278
7102
  */
7279
7103
  function recoveryOne() {
7280
- if (typeof UtilsContext.windowApi.window[needReleaseKey] === "undefined") {
7104
+ if (typeof that.windowApi.window[needReleaseKey] === "undefined") {
7281
7105
  /* 未存在 */
7282
7106
  return;
7283
7107
  }
7284
7108
  Array.from(functionNameList).forEach((item) => {
7285
- if (UtilsContext.windowApi.window[needReleaseKey][item]) {
7286
- needReleaseObject[item] = UtilsContext.windowApi.window[needReleaseKey][item];
7287
- Reflect.deleteProperty(UtilsContext.windowApi.window[needReleaseKey], item);
7288
- if (Object.keys(UtilsContext.windowApi.window[needReleaseKey]).length === 0) {
7109
+ if (that.windowApi.window[needReleaseKey][item]) {
7110
+ needReleaseObject[item] = that.windowApi.window[needReleaseKey][item];
7111
+ Reflect.deleteProperty(that.windowApi.window[needReleaseKey], item);
7112
+ if (Object.keys(that.windowApi.window[needReleaseKey]).length === 0) {
7289
7113
  Reflect.deleteProperty(window, needReleaseKey);
7290
7114
  }
7291
7115
  }
@@ -7389,39 +7213,44 @@ System.register('Utils', [], (function (exports) {
7389
7213
  const parser = new DOMParser();
7390
7214
  return parser.parseFromString(text, mimeType);
7391
7215
  }
7392
- parseStringToRegExpString(text) {
7393
- if (typeof text !== "string") {
7394
- throw new TypeError("string必须是字符串");
7395
- }
7396
- const regString = text.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&");
7397
- return regString;
7398
- }
7399
- preventEvent(element, eventNameList = [], capture) {
7400
- function stopEvent(event) {
7401
- /* 阻止事件的默认行为发生。例如,当点击一个链接时,浏览器会默认打开链接的URL */
7402
- event?.preventDefault();
7403
- /* 停止事件的传播,阻止它继续向更上层的元素冒泡,事件将不会再传播给其他的元素 */
7404
- event?.stopPropagation();
7405
- /* 阻止事件传播,并且还能阻止元素上的其他事件处理程序被触发 */
7406
- event?.stopImmediatePropagation();
7407
- return false;
7216
+ /**
7217
+ * 字符串转正则,用于把字符串中不规范的字符进行转义
7218
+ * @param text 需要进行转换的字符串
7219
+ * @param flags (可选)正则标志,默认`gi`
7220
+ * @example
7221
+ * Utils.toRegExp("^替换$");
7222
+ * > /^替换$/gi
7223
+ */
7224
+ toRegExp(text, flags = "gi") {
7225
+ let regExp;
7226
+ flags = flags.toLowerCase();
7227
+ if (typeof text === "string") {
7228
+ const pattern = this.toRegExpStr(text);
7229
+ regExp = new RegExp(pattern, flags);
7408
7230
  }
7409
- if (arguments.length === 1) {
7410
- /* 直接阻止事件 */
7411
- // eslint-disable-next-line prefer-rest-params
7412
- return stopEvent(arguments[0]);
7231
+ else if (text instanceof RegExp) {
7232
+ regExp = text;
7413
7233
  }
7414
7234
  else {
7415
- /* 添加对应的事件来阻止触发 */
7416
- if (typeof eventNameList === "string") {
7417
- eventNameList = [eventNameList];
7418
- }
7419
- eventNameList.forEach((eventName) => {
7420
- element.addEventListener(eventName, stopEvent, {
7421
- capture: Boolean(capture),
7422
- });
7423
- });
7235
+ throw new Error("Utils.toRegExp 参数text必须是string|Regexp类型");
7236
+ }
7237
+ return regExp;
7238
+ }
7239
+ /**
7240
+ * 将字符串进行正则转义
7241
+ * 例如:^替换$
7242
+ * 转换:\^替换\$
7243
+ * @param text 需要转义的字符串
7244
+ * @example
7245
+ * Utils.toRegExpStr("^替换$");
7246
+ * > \^替换\$
7247
+ */
7248
+ toRegExpStr(text) {
7249
+ if (typeof text !== "string") {
7250
+ throw new TypeError("toRegExpStr 参数text必须是string类型");
7424
7251
  }
7252
+ const regExpStr = text.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&");
7253
+ return regExpStr;
7425
7254
  }
7426
7255
  /**
7427
7256
  * 在canvas元素节点上绘制进度圆圈
@@ -7430,7 +7259,7 @@ System.register('Utils', [], (function (exports) {
7430
7259
  progress.draw();
7431
7260
  * **/
7432
7261
  Progress = Progress;
7433
- registerTrustClickEvent(isTrustValue = true, filter) {
7262
+ hookEvent_isTrusted(isTrustValue = true, filter) {
7434
7263
  function trustEvent(event) {
7435
7264
  return new Proxy(event, {
7436
7265
  get: function (target, property) {
@@ -7493,25 +7322,7 @@ System.register('Utils', [], (function (exports) {
7493
7322
  }
7494
7323
  return isNegative ? -reversedNum : reversedNum;
7495
7324
  }
7496
- selectElementText(element, childTextNode, startIndex, endIndex) {
7497
- const range = this.windowApi.document.createRange();
7498
- range.selectNodeContents(element);
7499
- if (childTextNode) {
7500
- if (childTextNode.nodeType !== Node.TEXT_NODE) {
7501
- throw new TypeError("childTextNode必须是#text元素");
7502
- }
7503
- if (startIndex != null && endIndex != null) {
7504
- range.setStart(childTextNode, startIndex);
7505
- range.setEnd(childTextNode, endIndex);
7506
- }
7507
- }
7508
- const selection = this.windowApi.globalThis.getSelection();
7509
- if (selection) {
7510
- selection.removeAllRanges();
7511
- selection.addRange(range);
7512
- }
7513
- }
7514
- setClip(data, info = {
7325
+ copy(data, info = {
7515
7326
  type: "text",
7516
7327
  mimetype: "text/plain",
7517
7328
  }) {
@@ -7533,7 +7344,7 @@ System.register('Utils', [], (function (exports) {
7533
7344
  else {
7534
7345
  textType = "text/plain";
7535
7346
  }
7536
- const UtilsContext = this;
7347
+ const that = this;
7537
7348
  class UtilsClipboard {
7538
7349
  #resolve;
7539
7350
  #copyData;
@@ -7584,15 +7395,15 @@ System.register('Utils', [], (function (exports) {
7584
7395
  */
7585
7396
  copyTextByTextArea() {
7586
7397
  try {
7587
- const copyElement = UtilsContext.windowApi.document.createElement("textarea");
7398
+ const copyElement = that.windowApi.document.createElement("textarea");
7588
7399
  copyElement.value = this.#copyData;
7589
7400
  copyElement.setAttribute("type", "text");
7590
7401
  copyElement.setAttribute("style", "opacity:0;position:absolute;");
7591
7402
  copyElement.setAttribute("readonly", "readonly");
7592
- UtilsContext.windowApi.document.body.appendChild(copyElement);
7403
+ that.windowApi.document.body.appendChild(copyElement);
7593
7404
  copyElement.select();
7594
- UtilsContext.windowApi.document.execCommand("copy");
7595
- UtilsContext.windowApi.document.body.removeChild(copyElement);
7405
+ that.windowApi.document.execCommand("copy");
7406
+ that.windowApi.document.body.removeChild(copyElement);
7596
7407
  return true;
7597
7408
  }
7598
7409
  catch (error) {
@@ -7662,18 +7473,88 @@ System.register('Utils', [], (function (exports) {
7662
7473
  }
7663
7474
  return new Promise((resolve) => {
7664
7475
  const utilsClipboard = new UtilsClipboard(resolve, data, textType);
7665
- if (UtilsContext.windowApi.document.hasFocus()) {
7476
+ if (that.windowApi.document.hasFocus()) {
7666
7477
  utilsClipboard.init();
7667
7478
  }
7668
7479
  else {
7669
- UtilsContext.windowApi.window.addEventListener("focus", () => {
7480
+ that.windowApi.window.addEventListener("focus", () => {
7670
7481
  utilsClipboard.init();
7671
7482
  }, { once: true });
7672
7483
  }
7673
7484
  });
7674
7485
  }
7486
+ /**
7487
+ * 获取剪贴板信息
7488
+ * @example
7489
+ * await Utils.getClipboardInfo();
7490
+ * > { error: null, content: "剪贴板内容" }
7491
+ */
7492
+ async getClipboardInfo() {
7493
+ return new Promise((resolve) => {
7494
+ /** 读取剪贴板 */
7495
+ function readClipboardText() {
7496
+ navigator.clipboard
7497
+ .readText()
7498
+ .then((clipboardText) => {
7499
+ resolve({
7500
+ error: null,
7501
+ content: clipboardText,
7502
+ });
7503
+ })
7504
+ .catch((error) => {
7505
+ resolve({
7506
+ error: error,
7507
+ content: "",
7508
+ });
7509
+ });
7510
+ }
7511
+ /** 申请读取剪贴板的权限 */
7512
+ function requestPermissionsWithClipboard() {
7513
+ navigator.permissions
7514
+ .query({
7515
+ name: "clipboard-read",
7516
+ })
7517
+ .then(() => {
7518
+ readClipboardText();
7519
+ })
7520
+ .catch(() => {
7521
+ /* 该权限申请Api可能在该环境下不生效,尝试直接读取剪贴板 */
7522
+ readClipboardText();
7523
+ });
7524
+ }
7525
+ /**
7526
+ * 检查当前环境是否支持读取剪贴板Api
7527
+ */
7528
+ function checkClipboardApi() {
7529
+ if (typeof navigator?.clipboard?.readText !== "function") {
7530
+ return false;
7531
+ }
7532
+ if (typeof navigator?.permissions?.query !== "function") {
7533
+ return false;
7534
+ }
7535
+ return true;
7536
+ }
7537
+ if (!checkClipboardApi()) {
7538
+ resolve({
7539
+ error: new Error("当前环境不支持读取剪贴板Api"),
7540
+ content: "",
7541
+ });
7542
+ return;
7543
+ }
7544
+ if (document.hasFocus()) {
7545
+ requestPermissionsWithClipboard();
7546
+ }
7547
+ else {
7548
+ window.addEventListener("focus", () => {
7549
+ requestPermissionsWithClipboard();
7550
+ }, {
7551
+ once: true,
7552
+ });
7553
+ }
7554
+ });
7555
+ }
7675
7556
  setTimeout(callback, delayTime = 0) {
7676
- const UtilsContext = this;
7557
+ const that = this;
7677
7558
  if (typeof callback !== "function" && typeof callback !== "string") {
7678
7559
  throw new TypeError("Utils.setTimeout 参数 callback 必须为 function|string 类型");
7679
7560
  }
@@ -7681,27 +7562,27 @@ System.register('Utils', [], (function (exports) {
7681
7562
  throw new TypeError("Utils.setTimeout 参数 delayTime 必须为 number 类型");
7682
7563
  }
7683
7564
  return new Promise((resolve) => {
7684
- UtilsContext.workerSetTimeout(() => {
7685
- resolve(UtilsContext.tryCatch().run(callback));
7565
+ that.workerSetTimeout(() => {
7566
+ resolve(that.tryCatch().run(callback));
7686
7567
  }, delayTime);
7687
7568
  });
7688
7569
  }
7689
7570
  sleep(delayTime = 0) {
7690
- const UtilsContext = this;
7571
+ const that = this;
7691
7572
  if (typeof delayTime !== "number") {
7692
7573
  throw new Error("Utils.sleep 参数 delayTime 必须为 number 类型");
7693
7574
  }
7694
7575
  return new Promise((resolve) => {
7695
- UtilsContext.workerSetTimeout(() => {
7576
+ that.workerSetTimeout(() => {
7696
7577
  resolve(void 0);
7697
7578
  }, delayTime);
7698
7579
  });
7699
7580
  }
7700
7581
  dragSlider(selector, offsetX = this.windowApi.window.innerWidth) {
7701
- const UtilsContext = this;
7582
+ const that = this;
7702
7583
  function initMouseEvent(eventName, offSetX, offSetY) {
7703
7584
  const win = typeof unsafeWindow === "undefined" ? globalThis : unsafeWindow;
7704
- const mouseEvent = UtilsContext.windowApi.document.createEvent("MouseEvents");
7585
+ const mouseEvent = that.windowApi.document.createEvent("MouseEvents");
7705
7586
  mouseEvent.initMouseEvent(eventName, true, true, win, 0, offSetX, offSetY, offSetX, offSetY, false, false, false, false, 0, null);
7706
7587
  return mouseEvent;
7707
7588
  }
@@ -7757,7 +7638,7 @@ System.register('Utils', [], (function (exports) {
7757
7638
  }
7758
7639
  }
7759
7640
  sortListByProperty(data, getPropertyValueFunc, sortByDesc = true) {
7760
- const UtilsContext = this;
7641
+ const that = this;
7761
7642
  if (typeof getPropertyValueFunc !== "function" && typeof getPropertyValueFunc !== "string") {
7762
7643
  throw new Error("Utils.sortListByProperty 参数 getPropertyValueFunc 必须为 function|string 类型");
7763
7644
  }
@@ -7769,9 +7650,8 @@ System.register('Utils', [], (function (exports) {
7769
7650
  };
7770
7651
  /**
7771
7652
  * 排序方法
7772
- * @param {any} after_obj
7773
- * @param {any} before_obj
7774
- * @returns
7653
+ * @param after_obj
7654
+ * @param before_obj
7775
7655
  */
7776
7656
  const sortFunc = function (after_obj, before_obj) {
7777
7657
  const beforeValue = getObjValue(before_obj); /* 前 */
@@ -7801,7 +7681,7 @@ System.register('Utils', [], (function (exports) {
7801
7681
  };
7802
7682
  /**
7803
7683
  * 排序元素方法
7804
- * @param nodeList 元素列表
7684
+ * @param nodeList 元素列表
7805
7685
  * @param getNodeListFunc 获取元素列表的函数
7806
7686
  */
7807
7687
  const sortNodeFunc = function (nodeList, getNodeListFunc) {
@@ -7839,7 +7719,7 @@ System.register('Utils', [], (function (exports) {
7839
7719
  if (Array.isArray(data)) {
7840
7720
  data.sort(sortFunc);
7841
7721
  }
7842
- else if (data instanceof NodeList || UtilsContext.isJQuery(data)) {
7722
+ else if (data instanceof NodeList || that.isJQuery(data)) {
7843
7723
  sortNodeFunc(data, getDataFunc);
7844
7724
  result = getDataFunc();
7845
7725
  }
@@ -7848,20 +7728,6 @@ System.register('Utils', [], (function (exports) {
7848
7728
  }
7849
7729
  return result;
7850
7730
  }
7851
- stringToRegular(targetString, flags = "ig") {
7852
- let reg;
7853
- flags = flags.toLowerCase();
7854
- if (typeof targetString === "string") {
7855
- reg = new RegExp(targetString.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"), flags);
7856
- }
7857
- else if (targetString instanceof RegExp) {
7858
- reg = targetString;
7859
- }
7860
- else {
7861
- throw new Error("Utils.stringToRegular 参数targetString必须是string|Regexp类型");
7862
- }
7863
- return reg;
7864
- }
7865
7731
  stringTitleToUpperCase(targetString, otherStrToLowerCase = false) {
7866
7732
  let newTargetString = targetString.slice(0, 1).toUpperCase();
7867
7733
  if (otherStrToLowerCase) {
@@ -7873,7 +7739,7 @@ System.register('Utils', [], (function (exports) {
7873
7739
  return newTargetString;
7874
7740
  }
7875
7741
  startsWith(target, searchString, position = 0) {
7876
- const UtilsContext = this;
7742
+ const that = this;
7877
7743
  if (position > target.length) {
7878
7744
  /* 超出目标字符串的长度 */
7879
7745
  return false;
@@ -7888,7 +7754,7 @@ System.register('Utils', [], (function (exports) {
7888
7754
  else if (Array.isArray(searchString)) {
7889
7755
  let flag = false;
7890
7756
  for (const searcStr of searchString) {
7891
- if (!UtilsContext.startsWith(target, searcStr, position)) {
7757
+ if (!that.startsWith(target, searcStr, position)) {
7892
7758
  flag = true;
7893
7759
  break;
7894
7760
  }
@@ -7897,13 +7763,18 @@ System.register('Utils', [], (function (exports) {
7897
7763
  }
7898
7764
  return Boolean(target.match(searchStringRegexp));
7899
7765
  }
7900
- stringTitleToLowerCase(targetString, otherStrToUpperCase = false) {
7901
- let newTargetString = targetString.slice(0, 1).toLowerCase();
7902
- if (otherStrToUpperCase) {
7903
- newTargetString = newTargetString + targetString.slice(1).toUpperCase();
7766
+ /**
7767
+ * 字符串首字母转小写
7768
+ * @param text 目标字符串
7769
+ * @param otherStrToLowerCase (可选)剩余部分字符串转大写,默认false
7770
+ */
7771
+ firstLetterToLowercase(text, otherToUpperCase = false) {
7772
+ let newTargetString = text.slice(0, 1).toLowerCase();
7773
+ if (otherToUpperCase) {
7774
+ newTargetString = newTargetString + text.slice(1).toUpperCase();
7904
7775
  }
7905
7776
  else {
7906
- newTargetString = newTargetString + targetString.slice(1);
7777
+ newTargetString = newTargetString + text.slice(1);
7907
7778
  }
7908
7779
  return newTargetString;
7909
7780
  }
@@ -7917,15 +7788,15 @@ System.register('Utils', [], (function (exports) {
7917
7788
  */
7918
7789
  toJSON = commonUtil.toJSON.bind(commonUtil);
7919
7790
  toSearchParamsStr(obj, addPrefix) {
7920
- const UtilsContext = this;
7791
+ const that = this;
7921
7792
  let searhParamsStr = "";
7922
7793
  if (Array.isArray(obj)) {
7923
7794
  obj.forEach((item) => {
7924
7795
  if (searhParamsStr === "") {
7925
- searhParamsStr += UtilsContext.toSearchParamsStr(item);
7796
+ searhParamsStr += that.toSearchParamsStr(item);
7926
7797
  }
7927
7798
  else {
7928
- searhParamsStr += `&${UtilsContext.toSearchParamsStr(item)}`;
7799
+ searhParamsStr += `&${that.toSearchParamsStr(item)}`;
7929
7800
  }
7930
7801
  });
7931
7802
  }
@@ -7980,341 +7851,33 @@ System.register('Utils', [], (function (exports) {
7980
7851
  }));
7981
7852
  }
7982
7853
  }
7854
+ /**
7855
+ * 等待函数数组全部执行完毕,注意,每个函数的顺序不是同步
7856
+ * @param data 需要遍历的数组
7857
+ * @param handleFunc 对该数组进行操作的函数,该函数的参数为数组格式的参数,[数组下标,数组项]
7858
+ * @example
7859
+ * await Utils.waitArrayLoopToEnd([callback,callback,callback],xxxcallback);
7860
+ **/
7983
7861
  waitArrayLoopToEnd(data, handleFunc) {
7984
- const UtilsContext = this;
7862
+ const that = this;
7985
7863
  if (typeof handleFunc !== "function" && typeof handleFunc !== "string") {
7986
7864
  throw new Error("Utils.waitArrayLoopToEnd 参数 handleDataFunction 必须为 function|string 类型");
7987
7865
  }
7988
7866
  return Promise.all(Array.from(data).map(async (item, index) => {
7989
- await UtilsContext.tryCatch(index, item).run(handleFunc);
7867
+ await that.tryCatch(index, item).run(handleFunc);
7990
7868
  }));
7991
7869
  }
7992
- wait(checkFn, timeout, parent) {
7993
- const UtilsContext = this;
7994
- const __timeout__ = typeof timeout === "number" ? timeout : 0;
7870
+ waitProperty(target, propertyName) {
7995
7871
  return new Promise((resolve) => {
7996
- const observer = UtilsContext.mutationObserver(parent || UtilsContext.windowApi.document, {
7997
- config: {
7998
- subtree: true,
7999
- childList: true,
8000
- attributes: true,
8001
- },
8002
- immediate: true,
8003
- callback(_, __observer__) {
8004
- const result = checkFn();
8005
- if (result.success) {
8006
- // 取消观察器
8007
- if (typeof __observer__?.disconnect === "function") {
8008
- __observer__.disconnect();
8009
- }
8010
- resolve(result.data);
8011
- }
8012
- },
8013
- });
8014
- if (__timeout__ > 0) {
8015
- UtilsContext.workerSetTimeout(() => {
8016
- // 取消观察器
8017
- if (typeof observer?.disconnect === "function") {
8018
- observer.disconnect();
8019
- }
8020
- resolve(null);
8021
- }, __timeout__);
8022
- }
8023
- });
8024
- }
8025
- waitNode(...args) {
8026
- // 过滤掉undefined
8027
- args = args.filter((arg) => arg !== void 0);
8028
- const UtilsContext = this;
8029
- // 选择器
8030
- const selector = args[0];
8031
- // 父元素(监听的元素)
8032
- let parent = UtilsContext.windowApi.document;
8033
- // 超时时间
8034
- let timeout = 0;
8035
- if (typeof args[0] !== "string" && !Array.isArray(args[0]) && typeof args[0] !== "function") {
8036
- throw new TypeError("Utils.waitNode 第一个参数必须是string|string[]|Function");
8037
- }
8038
- if (args.length === 1) ;
8039
- else if (args.length === 2) {
8040
- const secondParam = args[1];
8041
- if (typeof secondParam === "number") {
8042
- // "div",10000
8043
- timeout = secondParam;
8044
- }
8045
- else if (typeof secondParam === "object" && secondParam instanceof Node) {
8046
- // "div",document
8047
- parent = secondParam;
8048
- }
8049
- else {
8050
- throw new TypeError("Utils.waitNode 第二个参数必须是number|Node");
8051
- }
8052
- }
8053
- else if (args.length === 3) {
8054
- // "div",document,10000
8055
- // 第二个参数,parent
8056
- const secondParam = args[1];
8057
- // 第三个参数,timeout
8058
- const thirdParam = args[2];
8059
- if (typeof secondParam === "object" && secondParam instanceof Node) {
8060
- parent = secondParam;
8061
- if (typeof thirdParam === "number") {
8062
- timeout = thirdParam;
8063
- }
8064
- else {
8065
- throw new TypeError("Utils.waitNode 第三个参数必须是number");
8066
- }
8067
- }
8068
- else {
8069
- throw new TypeError("Utils.waitNode 第二个参数必须是Node");
8070
- }
8071
- }
8072
- else {
8073
- throw new TypeError("Utils.waitNode 参数个数错误");
8074
- }
8075
- function getNode() {
8076
- if (Array.isArray(selector)) {
8077
- const result = [];
8078
- for (let index = 0; index < selector.length; index++) {
8079
- const node = domUtils.selector(selector[index]);
8080
- if (node) {
8081
- result.push(node);
8082
- }
8083
- }
8084
- if (result.length === selector.length) {
8085
- return result;
8086
- }
8087
- }
8088
- else if (typeof selector === "function") {
8089
- return selector();
8090
- }
8091
- else {
8092
- return domUtils.selector(selector, parent);
8093
- }
8094
- }
8095
- return UtilsContext.wait(() => {
8096
- const node = getNode();
8097
- if (node) {
8098
- return {
8099
- success: true,
8100
- data: node,
8101
- };
8102
- }
8103
- else {
8104
- return {
8105
- success: false,
8106
- data: node,
8107
- };
8108
- }
8109
- }, timeout, parent);
8110
- }
8111
- waitAnyNode(...args) {
8112
- // 过滤掉undefined
8113
- args = args.filter((arg) => arg !== void 0);
8114
- const UtilsContext = this;
8115
- // 选择器
8116
- const selectorList = args[0];
8117
- // 父元素(监听的元素)
8118
- let parent = UtilsContext.windowApi.document;
8119
- // 超时时间
8120
- let timeout = 0;
8121
- if (typeof args[0] !== "object" && !Array.isArray(args[0])) {
8122
- throw new TypeError("Utils.waitAnyNode 第一个参数必须是string[]");
8123
- }
8124
- if (args.length === 1) ;
8125
- else if (args.length === 2) {
8126
- const secondParam = args[1];
8127
- if (typeof secondParam === "number") {
8128
- // "div",10000
8129
- timeout = secondParam;
8130
- }
8131
- else if (typeof secondParam === "object" && secondParam instanceof Node) {
8132
- // "div",document
8133
- parent = secondParam;
8134
- }
8135
- else {
8136
- throw new TypeError("Utils.waitAnyNode 第二个参数必须是number|Node");
8137
- }
8138
- }
8139
- else if (args.length === 3) {
8140
- // "div",document,10000
8141
- // 第二个参数,parent
8142
- const secondParam = args[1];
8143
- // 第三个参数,timeout
8144
- const thirdParam = args[2];
8145
- if (typeof secondParam === "object" && secondParam instanceof Node) {
8146
- parent = secondParam;
8147
- if (typeof thirdParam === "number") {
8148
- timeout = thirdParam;
8149
- }
8150
- else {
8151
- throw new TypeError("Utils.waitAnyNode 第三个参数必须是number");
8152
- }
8153
- }
8154
- else {
8155
- throw new TypeError("Utils.waitAnyNode 第二个参数必须是Node");
8156
- }
8157
- }
8158
- else {
8159
- throw new TypeError("Utils.waitAnyNode 参数个数错误");
8160
- }
8161
- const promiseList = selectorList.map((selector) => {
8162
- return UtilsContext.waitNode(selector, parent, timeout);
8163
- });
8164
- return Promise.any(promiseList);
8165
- }
8166
- waitNodeList(...args) {
8167
- // 过滤掉undefined
8168
- args = args.filter((arg) => arg !== void 0);
8169
- const UtilsContext = this;
8170
- // 选择器数组
8171
- const selector = args[0];
8172
- // 父元素(监听的元素)
8173
- let parent = UtilsContext.windowApi.document;
8174
- // 超时时间
8175
- let timeout = 0;
8176
- if (typeof args[0] !== "string" && !Array.isArray(args[0])) {
8177
- throw new TypeError("Utils.waitNodeList 第一个参数必须是string|string[]");
8178
- }
8179
- if (args.length === 1) ;
8180
- else if (args.length === 2) {
8181
- const secondParam = args[1];
8182
- if (typeof secondParam === "number") {
8183
- // "div",10000
8184
- timeout = secondParam;
8185
- }
8186
- else if (typeof secondParam === "object" && secondParam instanceof Node) {
8187
- // "div",document
8188
- parent = secondParam;
7872
+ let obj = target;
7873
+ if (typeof target === "function") {
7874
+ obj = target();
8189
7875
  }
8190
- else {
8191
- throw new TypeError("Utils.waitNodeList 第二个参数必须是number|Node");
8192
- }
8193
- }
8194
- else if (args.length === 3) {
8195
- // "div",document,10000
8196
- // 第二个参数,parent
8197
- const secondParam = args[1];
8198
- // 第三个参数,timeout
8199
- const thirdParam = args[2];
8200
- if (typeof secondParam === "object" && secondParam instanceof Node) {
8201
- parent = secondParam;
8202
- if (typeof thirdParam === "number") {
8203
- timeout = thirdParam;
8204
- }
8205
- else {
8206
- throw new TypeError("Utils.waitNodeList 第三个参数必须是number");
8207
- }
7876
+ if (Reflect.has(obj, propertyName)) {
7877
+ resolve(obj[propertyName]);
8208
7878
  }
8209
7879
  else {
8210
- throw new TypeError("Utils.waitNodeList 第二个参数必须是Node");
8211
- }
8212
- }
8213
- else {
8214
- throw new TypeError("Utils.waitNodeList 参数个数错误");
8215
- }
8216
- function getNodeList() {
8217
- if (Array.isArray(selector)) {
8218
- const result = [];
8219
- for (let index = 0; index < selector.length; index++) {
8220
- const nodeList = domUtils.selectorAll(selector[index], parent);
8221
- if (nodeList.length) {
8222
- result.push(nodeList);
8223
- }
8224
- }
8225
- if (result.length === selector.length) {
8226
- return result;
8227
- }
8228
- }
8229
- else {
8230
- const nodeList = domUtils.selectorAll(selector, parent);
8231
- if (nodeList.length) {
8232
- return nodeList;
8233
- }
8234
- }
8235
- }
8236
- return UtilsContext.wait(() => {
8237
- const node = getNodeList();
8238
- if (node) {
8239
- return {
8240
- success: true,
8241
- data: node,
8242
- };
8243
- }
8244
- else {
8245
- return {
8246
- success: false,
8247
- data: node,
8248
- };
8249
- }
8250
- }, timeout, parent);
8251
- }
8252
- waitAnyNodeList(...args) {
8253
- // 过滤掉undefined
8254
- args = args.filter((arg) => arg !== void 0);
8255
- const UtilsContext = this;
8256
- // 选择器数组
8257
- const selectorList = args[0];
8258
- // 父元素(监听的元素)
8259
- let parent = UtilsContext.windowApi.document;
8260
- // 超时时间
8261
- let timeout = 0;
8262
- if (!Array.isArray(args[0])) {
8263
- throw new TypeError("Utils.waitAnyNodeList 第一个参数必须是string[]");
8264
- }
8265
- if (args.length === 1) ;
8266
- else if (args.length === 2) {
8267
- const secondParam = args[1];
8268
- if (typeof secondParam === "number") {
8269
- // "div",10000
8270
- timeout = secondParam;
8271
- }
8272
- else if (typeof secondParam === "object" && secondParam instanceof Node) {
8273
- // "div",document
8274
- parent = secondParam;
8275
- }
8276
- else {
8277
- throw new TypeError("Utils.waitAnyNodeList 第二个参数必须是number|Node");
8278
- }
8279
- }
8280
- else if (args.length === 3) {
8281
- // "div",document,10000
8282
- // 第二个参数,parent
8283
- const secondParam = args[1];
8284
- // 第三个参数,timeout
8285
- const thirdParam = args[2];
8286
- if (typeof secondParam === "object" && secondParam instanceof Node) {
8287
- parent = secondParam;
8288
- if (typeof thirdParam === "number") {
8289
- timeout = thirdParam;
8290
- }
8291
- else {
8292
- throw new TypeError("Utils.waitAnyNodeList 第三个参数必须是number");
8293
- }
8294
- }
8295
- else {
8296
- throw new TypeError("Utils.waitAnyNodeList 第二个参数必须是Node");
8297
- }
8298
- }
8299
- else {
8300
- throw new TypeError("Utils.waitAnyNodeList 参数个数错误");
8301
- }
8302
- const promiseList = selectorList.map((selector) => {
8303
- return UtilsContext.waitNodeList(selector, parent, timeout);
8304
- });
8305
- return Promise.any(promiseList);
8306
- }
8307
- waitProperty(checkObj, checkPropertyName) {
8308
- return new Promise((resolve) => {
8309
- let obj = checkObj;
8310
- if (typeof checkObj === "function") {
8311
- obj = checkObj();
8312
- }
8313
- if (Reflect.has(obj, checkPropertyName)) {
8314
- resolve(obj[checkPropertyName]);
8315
- }
8316
- else {
8317
- Object.defineProperty(obj, checkPropertyName, {
7880
+ Object.defineProperty(obj, propertyName, {
8318
7881
  set: function (value) {
8319
7882
  try {
8320
7883
  resolve(value);
@@ -8327,49 +7890,48 @@ System.register('Utils', [], (function (exports) {
8327
7890
  }
8328
7891
  });
8329
7892
  }
8330
- waitPropertyByInterval(checkObj, checkPropertyName, intervalTimer = 250, maxTime = -1) {
8331
- const UtilsContext = this;
8332
- if (checkObj == null) {
7893
+ waitPropertyByInterval(checkFn, propertyName, intervalTimer = 250, maxTime = -1) {
7894
+ const that = this;
7895
+ if (checkFn == null) {
8333
7896
  throw new TypeError("checkObj 不能为空对象 ");
8334
7897
  }
8335
7898
  let isResolve = false;
8336
7899
  return new Promise((resolve, reject) => {
8337
- const interval = UtilsContext.workerSetInterval(() => {
8338
- let obj = checkObj;
8339
- if (typeof checkObj === "function") {
8340
- obj = checkObj();
7900
+ const interval = that.workerSetInterval(() => {
7901
+ let inst = checkFn;
7902
+ if (typeof checkFn === "function") {
7903
+ inst = checkFn();
8341
7904
  }
8342
- if (typeof obj !== "object") {
7905
+ if (typeof inst !== "object") {
8343
7906
  return;
8344
7907
  }
8345
- if (obj == null) {
7908
+ if (inst == null) {
8346
7909
  return;
8347
7910
  }
8348
- if ((typeof checkPropertyName === "function" && checkPropertyName(obj)) ||
8349
- Reflect.has(obj, checkPropertyName)) {
7911
+ if ((typeof propertyName === "function" && propertyName(inst)) || Reflect.has(inst, propertyName)) {
8350
7912
  isResolve = true;
8351
- UtilsContext.workerClearInterval(interval);
8352
- resolve(obj[checkPropertyName]);
7913
+ that.workerClearInterval(interval);
7914
+ resolve(inst[propertyName]);
8353
7915
  }
8354
7916
  }, intervalTimer);
8355
7917
  if (maxTime !== -1) {
8356
- UtilsContext.workerSetTimeout(() => {
7918
+ that.workerSetTimeout(() => {
8357
7919
  if (!isResolve) {
8358
- UtilsContext.workerClearInterval(interval);
7920
+ that.workerClearInterval(interval);
8359
7921
  reject();
8360
7922
  }
8361
7923
  }, maxTime);
8362
7924
  }
8363
7925
  });
8364
7926
  }
8365
- async waitVueByInterval(element, propertyName, timer = 250, maxTime = -1, vueName = "__vue__") {
8366
- if (element == null) {
7927
+ async waitVueByInterval($el, propertyName, timer = 250, maxTime = -1, vueName = "__vue__") {
7928
+ if ($el == null) {
8367
7929
  throw new Error("Utils.waitVueByInterval 参数element 不能为空");
8368
7930
  }
8369
7931
  let flag = false;
8370
- const UtilsContext = this;
7932
+ const that = this;
8371
7933
  try {
8372
- await UtilsContext.waitPropertyByInterval(element, function (targetElement) {
7934
+ await that.waitPropertyByInterval($el, function (targetElement) {
8373
7935
  if (targetElement == null) {
8374
7936
  return false;
8375
7937
  }
@@ -8379,25 +7941,24 @@ System.register('Utils', [], (function (exports) {
8379
7941
  if (propertyName == null) {
8380
7942
  return true;
8381
7943
  }
8382
- const vueObject = targetElement[vueName];
7944
+ const $vueEl = targetElement[vueName];
8383
7945
  if (typeof propertyName === "string") {
8384
- if (propertyName in vueObject) {
7946
+ if (propertyName in $vueEl) {
8385
7947
  flag = true;
8386
7948
  return true;
8387
7949
  }
8388
7950
  }
8389
7951
  else {
8390
7952
  /* Function */
8391
- if (propertyName(vueObject)) {
7953
+ if (propertyName($vueEl)) {
8392
7954
  flag = true;
8393
7955
  return true;
8394
7956
  }
8395
7957
  }
8396
7958
  return false;
8397
7959
  }, timer, maxTime);
8398
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
8399
7960
  }
8400
- catch (error) {
7961
+ catch {
8401
7962
  return flag;
8402
7963
  }
8403
7964
  return flag;
@@ -8634,73 +8195,6 @@ System.register('Utils', [], (function (exports) {
8634
8195
  this.windowApi.clearInterval(timeId);
8635
8196
  }
8636
8197
  }
8637
- /**
8638
- * 获取剪贴板信息
8639
- */
8640
- async getClipboardInfo() {
8641
- return new Promise((resolve) => {
8642
- /** 读取剪贴板 */
8643
- function readClipboardText() {
8644
- navigator.clipboard
8645
- .readText()
8646
- .then((clipboardText) => {
8647
- resolve({
8648
- error: null,
8649
- content: clipboardText,
8650
- });
8651
- })
8652
- .catch((error) => {
8653
- resolve({
8654
- error: error,
8655
- content: "",
8656
- });
8657
- });
8658
- }
8659
- /** 申请读取剪贴板的权限 */
8660
- function requestPermissionsWithClipboard() {
8661
- navigator.permissions
8662
- .query({
8663
- name: "clipboard-read",
8664
- })
8665
- .then(() => {
8666
- readClipboardText();
8667
- })
8668
- .catch(() => {
8669
- /* 该权限申请Api可能在该环境下不生效,尝试直接读取剪贴板 */
8670
- readClipboardText();
8671
- });
8672
- }
8673
- /**
8674
- * 检查当前环境是否支持读取剪贴板Api
8675
- */
8676
- function checkClipboardApi() {
8677
- if (typeof navigator?.clipboard?.readText !== "function") {
8678
- return false;
8679
- }
8680
- if (typeof navigator?.permissions?.query !== "function") {
8681
- return false;
8682
- }
8683
- return true;
8684
- }
8685
- if (!checkClipboardApi()) {
8686
- resolve({
8687
- error: new Error("当前环境不支持读取剪贴板Api"),
8688
- content: "",
8689
- });
8690
- return;
8691
- }
8692
- if (document.hasFocus()) {
8693
- requestPermissionsWithClipboard();
8694
- }
8695
- else {
8696
- window.addEventListener("focus", () => {
8697
- requestPermissionsWithClipboard();
8698
- }, {
8699
- once: true,
8700
- });
8701
- }
8702
- });
8703
- }
8704
8198
  }
8705
8199
  const utils = exports("default", new Utils());
8706
8200