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