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