@whitesev/utils 2.5.2 → 2.5.4
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 +48 -40
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +48 -40
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +48 -40
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +48 -40
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +48 -40
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +48 -40
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/UtilsGMCookie.d.ts +8 -8
- package/dist/types/src/types/UtilsGMCookie.d.ts +54 -16
- package/dist/types/src/types/global.d.ts +3 -0
- package/package.json +3 -2
- package/src/Utils.ts +4 -4
- package/src/UtilsGMCookie.ts +44 -42
- package/src/types/UtilsGMCookie.d.ts +54 -16
- package/src/types/global.d.ts +3 -0
package/dist/index.system.js
CHANGED
|
@@ -275,24 +275,24 @@ System.register('Utils', [], (function (exports) {
|
|
|
275
275
|
}
|
|
276
276
|
/**
|
|
277
277
|
* 获取多组Cookie
|
|
278
|
-
* @param
|
|
278
|
+
* @param option 配置
|
|
279
279
|
* @param callback 获取操作后的回调
|
|
280
280
|
* + cookies object[]
|
|
281
281
|
* + error string|undefined
|
|
282
282
|
**/
|
|
283
|
-
list(
|
|
284
|
-
if (
|
|
283
|
+
list(option, callback) {
|
|
284
|
+
if (option == null) {
|
|
285
285
|
throw new Error("Utils.GMCookie.list 参数不能为空");
|
|
286
286
|
}
|
|
287
287
|
let resultData = [];
|
|
288
288
|
try {
|
|
289
|
-
let
|
|
289
|
+
let defaultOption = {
|
|
290
290
|
url: this.windowApi.window.location.href,
|
|
291
291
|
domain: this.windowApi.window.location.hostname,
|
|
292
292
|
name: "",
|
|
293
293
|
path: "/",
|
|
294
294
|
};
|
|
295
|
-
|
|
295
|
+
defaultOption = utils.assign(defaultOption, option);
|
|
296
296
|
let cookies = this.windowApi.document.cookie.split(";");
|
|
297
297
|
cookies.forEach((item) => {
|
|
298
298
|
item = item.trim();
|
|
@@ -300,9 +300,9 @@ System.register('Utils', [], (function (exports) {
|
|
|
300
300
|
let itemName = itemSplit[0];
|
|
301
301
|
itemSplit.splice(0, 1);
|
|
302
302
|
let itemValue = decodeURIComponent(itemSplit.join(""));
|
|
303
|
-
let nameRegexp =
|
|
304
|
-
?
|
|
305
|
-
: new RegExp("^" +
|
|
303
|
+
let nameRegexp = defaultOption.name instanceof RegExp
|
|
304
|
+
? defaultOption.name
|
|
305
|
+
: new RegExp("^" + defaultOption.name, "g");
|
|
306
306
|
if (itemName.match(nameRegexp)) {
|
|
307
307
|
resultData.push({
|
|
308
308
|
domain: this.windowApi.window.location.hostname,
|
|
@@ -330,20 +330,20 @@ System.register('Utils', [], (function (exports) {
|
|
|
330
330
|
}
|
|
331
331
|
/**
|
|
332
332
|
* 获取多组Cookie
|
|
333
|
-
* @param
|
|
333
|
+
* @param option 配置
|
|
334
334
|
**/
|
|
335
|
-
getList(
|
|
336
|
-
if (
|
|
335
|
+
getList(option) {
|
|
336
|
+
if (option == null) {
|
|
337
337
|
throw new Error("Utils.GMCookie.list 参数不能为空");
|
|
338
338
|
}
|
|
339
339
|
let resultData = [];
|
|
340
|
-
let
|
|
340
|
+
let defaultOption = {
|
|
341
341
|
url: this.windowApi.window.location.href,
|
|
342
342
|
domain: this.windowApi.window.location.hostname,
|
|
343
343
|
name: "",
|
|
344
344
|
path: "/",
|
|
345
345
|
};
|
|
346
|
-
|
|
346
|
+
defaultOption = utils.assign(defaultOption, option);
|
|
347
347
|
let cookies = this.windowApi.document.cookie.split(";");
|
|
348
348
|
cookies.forEach((item) => {
|
|
349
349
|
item = item.trim();
|
|
@@ -351,9 +351,9 @@ System.register('Utils', [], (function (exports) {
|
|
|
351
351
|
let itemName = itemSplit[0];
|
|
352
352
|
itemSplit.splice(0, 1);
|
|
353
353
|
let itemValue = decodeURIComponent(itemSplit.join(""));
|
|
354
|
-
let nameRegexp =
|
|
355
|
-
?
|
|
356
|
-
: new RegExp("^" +
|
|
354
|
+
let nameRegexp = defaultOption.name instanceof RegExp
|
|
355
|
+
? defaultOption.name
|
|
356
|
+
: new RegExp("^" + defaultOption.name, "g");
|
|
357
357
|
if (itemName.match(nameRegexp)) {
|
|
358
358
|
resultData.push({
|
|
359
359
|
domain: this.windowApi.window.location.hostname,
|
|
@@ -373,12 +373,13 @@ System.register('Utils', [], (function (exports) {
|
|
|
373
373
|
}
|
|
374
374
|
/**
|
|
375
375
|
* 设置Cookie
|
|
376
|
-
* @param
|
|
376
|
+
* @param option 配置
|
|
377
377
|
* @param callback 设置操作后的回调(成功/失败)
|
|
378
378
|
*/
|
|
379
|
-
set(
|
|
379
|
+
set(option, callback) {
|
|
380
|
+
let errorInfo;
|
|
380
381
|
try {
|
|
381
|
-
let
|
|
382
|
+
let defaultOption = {
|
|
382
383
|
url: this.windowApi.window.location.href,
|
|
383
384
|
name: "",
|
|
384
385
|
value: "",
|
|
@@ -391,43 +392,52 @@ System.register('Utils', [], (function (exports) {
|
|
|
391
392
|
*/
|
|
392
393
|
expirationDate: Math.floor(Date.now()) + 60 * 60 * 24 * 30,
|
|
393
394
|
};
|
|
394
|
-
|
|
395
|
-
let life =
|
|
396
|
-
?
|
|
395
|
+
defaultOption = utils.assign(defaultOption, option);
|
|
396
|
+
let life = defaultOption.expirationDate
|
|
397
|
+
? defaultOption.expirationDate
|
|
397
398
|
: Math.floor(Date.now()) + 60 * 60 * 24 * 30;
|
|
398
|
-
let cookieStr =
|
|
399
|
+
let cookieStr = defaultOption.name +
|
|
399
400
|
"=" +
|
|
400
|
-
decodeURIComponent(
|
|
401
|
+
decodeURIComponent(defaultOption.value) +
|
|
401
402
|
";expires=" +
|
|
402
403
|
new Date(life).toGMTString() +
|
|
403
404
|
"; path=/";
|
|
404
405
|
this.windowApi.document.cookie = cookieStr;
|
|
405
|
-
callback();
|
|
406
406
|
}
|
|
407
407
|
catch (error) {
|
|
408
|
-
|
|
408
|
+
errorInfo = error;
|
|
409
|
+
}
|
|
410
|
+
finally {
|
|
411
|
+
if (typeof callback === "function") {
|
|
412
|
+
callback(errorInfo);
|
|
413
|
+
}
|
|
409
414
|
}
|
|
410
415
|
}
|
|
411
416
|
/**
|
|
412
417
|
* 删除Cookie
|
|
413
|
-
* @param
|
|
418
|
+
* @param option 配置
|
|
414
419
|
* @param callback 删除操作后的回调(成功/失败)
|
|
415
420
|
*/
|
|
416
|
-
delete(
|
|
421
|
+
delete(option, callback) {
|
|
422
|
+
let errorInfo;
|
|
417
423
|
try {
|
|
418
|
-
let
|
|
424
|
+
let defaultOption = {
|
|
419
425
|
url: this.windowApi.window.location.href,
|
|
420
426
|
name: "",
|
|
421
|
-
|
|
422
|
-
firstPartyDomain:
|
|
427
|
+
path: "/",
|
|
428
|
+
firstPartyDomain: this.windowApi.window.location.hostname,
|
|
423
429
|
};
|
|
424
|
-
|
|
425
|
-
let cookieStr =
|
|
430
|
+
defaultOption = utils.assign(defaultOption, option);
|
|
431
|
+
let cookieStr = `${defaultOption.name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${defaultOption.path}; domain=${defaultOption.firstPartyDomain};`;
|
|
426
432
|
this.windowApi.document.cookie = cookieStr;
|
|
427
|
-
callback();
|
|
428
433
|
}
|
|
429
434
|
catch (error) {
|
|
430
|
-
|
|
435
|
+
errorInfo = error;
|
|
436
|
+
}
|
|
437
|
+
finally {
|
|
438
|
+
if (typeof callback === "function") {
|
|
439
|
+
callback(errorInfo);
|
|
440
|
+
}
|
|
431
441
|
}
|
|
432
442
|
}
|
|
433
443
|
}
|
|
@@ -4113,7 +4123,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
4113
4123
|
this.windowApi = new WindowApi(option);
|
|
4114
4124
|
}
|
|
4115
4125
|
/** 版本号 */
|
|
4116
|
-
version = "2024.
|
|
4126
|
+
version = "2024.12.3";
|
|
4117
4127
|
addStyle(cssText) {
|
|
4118
4128
|
if (typeof cssText !== "string") {
|
|
4119
4129
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|
|
@@ -4831,9 +4841,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
4831
4841
|
getMaxZIndexNodeInfo(deviation = 1, target = this.windowApi.document, ignoreCallBack) {
|
|
4832
4842
|
deviation = Number.isNaN(deviation) ? 1 : deviation;
|
|
4833
4843
|
const UtilsContext = this;
|
|
4834
|
-
//
|
|
4835
|
-
const maxZIndex = Math.pow(2, 31) - 1;
|
|
4836
|
-
// 比较值2000000000
|
|
4844
|
+
// 比较值 2000000000
|
|
4837
4845
|
const maxZIndexCompare = 2 * Math.pow(10, 9);
|
|
4838
4846
|
// 当前页面最大的z-index
|
|
4839
4847
|
let zIndex = 0;
|
|
@@ -4885,7 +4893,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
4885
4893
|
zIndex += deviation;
|
|
4886
4894
|
if (zIndex >= maxZIndexCompare) {
|
|
4887
4895
|
// 最好不要超过最大值
|
|
4888
|
-
zIndex =
|
|
4896
|
+
zIndex = maxZIndexCompare;
|
|
4889
4897
|
}
|
|
4890
4898
|
return {
|
|
4891
4899
|
node: maxZIndexNode,
|