@whitesev/utils 2.11.8 → 2.11.10

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.
@@ -240,7 +240,7 @@ var Utils = (function () {
240
240
  const setInterval$1 = (...args) => loadOrReturnBroker().setInterval(...args);
241
241
  const setTimeout$1 = (...args) => loadOrReturnBroker().setTimeout(...args);
242
242
 
243
- const version = "2.11.8";
243
+ const version = "2.11.10";
244
244
 
245
245
  /* eslint-disable */
246
246
  // ==UserScript==
@@ -6209,6 +6209,10 @@ var Utils = (function () {
6209
6209
  if (typeof deviation !== "number" || Number.isNaN(deviation)) {
6210
6210
  deviation = 10;
6211
6211
  }
6212
+ // 最大值 2147483647
6213
+ // const maxZIndex = Math.pow(2, 31) - 1;
6214
+ // 比较值 2000000000
6215
+ const maxZIndexCompare = 2 * Math.pow(10, 9);
6212
6216
  /** 坐标偏移 */
6213
6217
  const positionDistance = 10;
6214
6218
  const defaultCalcPostion = [];
@@ -6303,9 +6307,14 @@ var Utils = (function () {
6303
6307
  left: maxRect.left,
6304
6308
  };
6305
6309
  }
6310
+ let calcZIndex = zIndex + deviation;
6311
+ if (calcZIndex >= maxZIndexCompare) {
6312
+ // 不要超过最大值
6313
+ calcZIndex = maxZIndexCompare;
6314
+ }
6306
6315
  return {
6307
6316
  /** 计算偏移量后的z-index值 */
6308
- zIndex: zIndex + deviation,
6317
+ zIndex: calcZIndex,
6309
6318
  /** 获取到的最大的z-index值 */
6310
6319
  originZIndex: zIndex,
6311
6320
  /** 拥有最大z-index的元素 */
@@ -8342,6 +8351,20 @@ var Utils = (function () {
8342
8351
  * 深度获取对象的某个属性
8343
8352
  * @param target 待获取的对象
8344
8353
  * @param handler 获取属性的回调
8354
+ * @example
8355
+ * Utils.queryProperty(window,(target)=>{
8356
+ * if(target.xxx){
8357
+ * return {
8358
+ * isFind: true,
8359
+ * data: target.xxx,
8360
+ * }
8361
+ * }else{
8362
+ * return {
8363
+ * isFind: false,
8364
+ * data: target.aabbcc,
8365
+ * }
8366
+ * }
8367
+ * })
8345
8368
  */
8346
8369
  queryProperty(target, handler) {
8347
8370
  if (target == null) {
@@ -8357,10 +8380,23 @@ var Utils = (function () {
8357
8380
  * 异步-深度获取对象属性
8358
8381
  * @param target 待获取的对象
8359
8382
  * @param handler 获取属性的回调
8383
+ * @example
8384
+ * Utils.asyncQueryProperty(window, async (target)=>{
8385
+ * if(target.xxx){
8386
+ * return {
8387
+ * isFind: true,
8388
+ * data: target.xxx,
8389
+ * }
8390
+ * }else{
8391
+ * return {
8392
+ * isFind: false,
8393
+ * data: target.aabbcc,
8394
+ * }
8395
+ * }
8396
+ * })
8360
8397
  */
8361
8398
  async asyncQueryProperty(target, handler) {
8362
8399
  if (target == null) {
8363
- // @ts-expect-error 空返回
8364
8400
  return;
8365
8401
  }
8366
8402
  const handleResult = await handler(target);
@@ -8372,7 +8408,8 @@ var Utils = (function () {
8372
8408
  /**
8373
8409
  * 创建一个新的Utils实例
8374
8410
  * @param option
8375
- * @returns
8411
+ * @example
8412
+ * Utils.createUtils();
8376
8413
  */
8377
8414
  createUtils(option) {
8378
8415
  return new Utils(option);
@@ -8440,7 +8477,9 @@ var Utils = (function () {
8440
8477
  /**
8441
8478
  * 覆盖对象中的函数this指向
8442
8479
  * @param target 需要覆盖的对象
8443
- * @param [objectThis] 覆盖的this指向,如果为传入,则默认为对象本身
8480
+ * @param objectThis 覆盖的this指向,如果为传入,则默认为对象本身
8481
+ * @example
8482
+ * Utils.coverObjectFunctionThis({})
8444
8483
  */
8445
8484
  coverObjectFunctionThis = commonUtil.coverObjectFunctionThis.bind(commonUtil);
8446
8485
  /**
@@ -8491,7 +8530,7 @@ var Utils = (function () {
8491
8530
  /**
8492
8531
  * 自动使用 Worker 执行 setTimeout
8493
8532
  * @param callback 回调函数
8494
- * @param [timeout=0] 延迟时间,默认为0
8533
+ * @param timeout 延迟时间,默认为0
8495
8534
  */
8496
8535
  workerSetTimeout(callback, timeout = 0) {
8497
8536
  try {
@@ -8562,6 +8601,10 @@ var Utils = (function () {
8562
8601
  /**
8563
8602
  * 判断页面中是否存在`worker-src`的CSP规则
8564
8603
  * @param timeout 超时时间,默认为`1500ms`
8604
+ * @example
8605
+ * Utils.hasWorkerCSP().then((hasCSP) => {
8606
+ * console.log(hasCSP);
8607
+ * })
8565
8608
  */
8566
8609
  hasWorkerCSP(timeout = 1500) {
8567
8610
  return new Promise((resolve) => {