@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.
package/dist/index.umd.js CHANGED
@@ -243,7 +243,7 @@
243
243
  const setInterval$1 = (...args) => loadOrReturnBroker().setInterval(...args);
244
244
  const setTimeout$1 = (...args) => loadOrReturnBroker().setTimeout(...args);
245
245
 
246
- const version = "2.11.8";
246
+ const version = "2.11.10";
247
247
 
248
248
  /* eslint-disable */
249
249
  // ==UserScript==
@@ -6212,6 +6212,10 @@
6212
6212
  if (typeof deviation !== "number" || Number.isNaN(deviation)) {
6213
6213
  deviation = 10;
6214
6214
  }
6215
+ // 最大值 2147483647
6216
+ // const maxZIndex = Math.pow(2, 31) - 1;
6217
+ // 比较值 2000000000
6218
+ const maxZIndexCompare = 2 * Math.pow(10, 9);
6215
6219
  /** 坐标偏移 */
6216
6220
  const positionDistance = 10;
6217
6221
  const defaultCalcPostion = [];
@@ -6306,9 +6310,14 @@
6306
6310
  left: maxRect.left,
6307
6311
  };
6308
6312
  }
6313
+ let calcZIndex = zIndex + deviation;
6314
+ if (calcZIndex >= maxZIndexCompare) {
6315
+ // 不要超过最大值
6316
+ calcZIndex = maxZIndexCompare;
6317
+ }
6309
6318
  return {
6310
6319
  /** 计算偏移量后的z-index值 */
6311
- zIndex: zIndex + deviation,
6320
+ zIndex: calcZIndex,
6312
6321
  /** 获取到的最大的z-index值 */
6313
6322
  originZIndex: zIndex,
6314
6323
  /** 拥有最大z-index的元素 */
@@ -8345,6 +8354,20 @@
8345
8354
  * 深度获取对象的某个属性
8346
8355
  * @param target 待获取的对象
8347
8356
  * @param handler 获取属性的回调
8357
+ * @example
8358
+ * Utils.queryProperty(window,(target)=>{
8359
+ * if(target.xxx){
8360
+ * return {
8361
+ * isFind: true,
8362
+ * data: target.xxx,
8363
+ * }
8364
+ * }else{
8365
+ * return {
8366
+ * isFind: false,
8367
+ * data: target.aabbcc,
8368
+ * }
8369
+ * }
8370
+ * })
8348
8371
  */
8349
8372
  queryProperty(target, handler) {
8350
8373
  if (target == null) {
@@ -8360,10 +8383,23 @@
8360
8383
  * 异步-深度获取对象属性
8361
8384
  * @param target 待获取的对象
8362
8385
  * @param handler 获取属性的回调
8386
+ * @example
8387
+ * Utils.asyncQueryProperty(window, async (target)=>{
8388
+ * if(target.xxx){
8389
+ * return {
8390
+ * isFind: true,
8391
+ * data: target.xxx,
8392
+ * }
8393
+ * }else{
8394
+ * return {
8395
+ * isFind: false,
8396
+ * data: target.aabbcc,
8397
+ * }
8398
+ * }
8399
+ * })
8363
8400
  */
8364
8401
  async asyncQueryProperty(target, handler) {
8365
8402
  if (target == null) {
8366
- // @ts-expect-error 空返回
8367
8403
  return;
8368
8404
  }
8369
8405
  const handleResult = await handler(target);
@@ -8375,7 +8411,8 @@
8375
8411
  /**
8376
8412
  * 创建一个新的Utils实例
8377
8413
  * @param option
8378
- * @returns
8414
+ * @example
8415
+ * Utils.createUtils();
8379
8416
  */
8380
8417
  createUtils(option) {
8381
8418
  return new Utils(option);
@@ -8443,7 +8480,9 @@
8443
8480
  /**
8444
8481
  * 覆盖对象中的函数this指向
8445
8482
  * @param target 需要覆盖的对象
8446
- * @param [objectThis] 覆盖的this指向,如果为传入,则默认为对象本身
8483
+ * @param objectThis 覆盖的this指向,如果为传入,则默认为对象本身
8484
+ * @example
8485
+ * Utils.coverObjectFunctionThis({})
8447
8486
  */
8448
8487
  coverObjectFunctionThis = commonUtil.coverObjectFunctionThis.bind(commonUtil);
8449
8488
  /**
@@ -8494,7 +8533,7 @@
8494
8533
  /**
8495
8534
  * 自动使用 Worker 执行 setTimeout
8496
8535
  * @param callback 回调函数
8497
- * @param [timeout=0] 延迟时间,默认为0
8536
+ * @param timeout 延迟时间,默认为0
8498
8537
  */
8499
8538
  workerSetTimeout(callback, timeout = 0) {
8500
8539
  try {
@@ -8565,6 +8604,10 @@
8565
8604
  /**
8566
8605
  * 判断页面中是否存在`worker-src`的CSP规则
8567
8606
  * @param timeout 超时时间,默认为`1500ms`
8607
+ * @example
8608
+ * Utils.hasWorkerCSP().then((hasCSP) => {
8609
+ * console.log(hasCSP);
8610
+ * })
8568
8611
  */
8569
8612
  hasWorkerCSP(timeout = 1500) {
8570
8613
  return new Promise((resolve) => {