@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.amd.js +49 -6
- package/dist/index.amd.js.map +1 -1
- package/dist/index.amd.min.js +1 -1
- package/dist/index.amd.min.js.map +1 -1
- package/dist/index.cjs.js +49 -6
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +49 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +49 -6
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.system.js +49 -6
- package/dist/index.system.js.map +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/dist/index.umd.js +49 -6
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/src/Utils.d.ts +64 -22
- package/package.json +1 -1
- package/src/Utils.ts +89 -41
package/dist/index.system.js
CHANGED
|
@@ -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.
|
|
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:
|
|
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
|
-
* @
|
|
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
|
|
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
|
|
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) => {
|