@whitesev/utils 2.3.1 → 2.3.3

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.
@@ -1756,6 +1756,8 @@ var Utils = (function () {
1756
1756
  data: details.data || this.context.#defaultDetails.data,
1757
1757
  redirect: details.redirect || this.context.#defaultDetails.redirect,
1758
1758
  cookie: details.cookie || this.context.#defaultDetails.cookie,
1759
+ cookiePartition: details.cookiePartition ||
1760
+ this.context.#defaultDetails.cookiePartition,
1759
1761
  binary: details.binary || this.context.#defaultDetails.binary,
1760
1762
  nocache: details.nocache || this.context.#defaultDetails.nocache,
1761
1763
  revalidate: details.revalidate || this.context.#defaultDetails.revalidate,
@@ -1857,6 +1859,15 @@ var Utils = (function () {
1857
1859
  else {
1858
1860
  result.fetchInit = details.fetchInit;
1859
1861
  }
1862
+ // 处理新的cookiePartition
1863
+ if (typeof result.cookiePartition === "object" &&
1864
+ result.cookiePartition != null) {
1865
+ if (Reflect.has(result.cookiePartition, "topLevelSite") &&
1866
+ typeof result.cookiePartition.topLevelSite !== "string") {
1867
+ // topLevelSite必须是字符串
1868
+ Reflect.deleteProperty(result.cookiePartition, "topLevelSite");
1869
+ }
1870
+ }
1860
1871
  return result;
1861
1872
  },
1862
1873
  /**
@@ -2346,6 +2357,7 @@ var Utils = (function () {
2346
2357
  data: void 0,
2347
2358
  redirect: void 0,
2348
2359
  cookie: void 0,
2360
+ cookiePartition: void 0,
2349
2361
  binary: void 0,
2350
2362
  nocache: void 0,
2351
2363
  revalidate: void 0,
@@ -3929,7 +3941,7 @@ var Utils = (function () {
3929
3941
  this.windowApi = new WindowApi(option);
3930
3942
  }
3931
3943
  /** 版本号 */
3932
- version = "2024.9.10";
3944
+ version = "2024.9.28";
3933
3945
  addStyle(cssText) {
3934
3946
  if (typeof cssText !== "string") {
3935
3947
  throw new Error("Utils.addStyle 参数cssText 必须为String类型");
@@ -6442,13 +6454,29 @@ var Utils = (function () {
6442
6454
  * > ()=>{throw new Error('测试错误')}出现错误
6443
6455
  */
6444
6456
  tryCatch = TryCatch;
6445
- uniqueArray(uniqueArrayData = [], compareArrayData = [], compareFun = (item, item2) => {
6446
- // @ts-ignore
6457
+ uniqueArray(uniqueArrayData = [], compareArrayData, compareFun = (item, item2) => {
6447
6458
  return item === item2;
6448
6459
  }) {
6449
- return Array.from(uniqueArrayData).filter((item) => !Array.from(compareArrayData).some(function (item2) {
6450
- return compareFun(item, item2);
6451
- }));
6460
+ if (typeof compareArrayData === "function") {
6461
+ const compareFn = compareArrayData;
6462
+ const seen = new Set();
6463
+ const result = [];
6464
+ for (const item of uniqueArrayData) {
6465
+ // 使用compareFn函数来获取当前对象的唯一标识
6466
+ const identfier = compareFn(item);
6467
+ // 如果Set中还没有这个标识,则添加到结果数组中,并将其标识存入Set
6468
+ if (!seen.has(identfier)) {
6469
+ seen.add(identfier);
6470
+ result.push(item);
6471
+ }
6472
+ }
6473
+ return result;
6474
+ }
6475
+ else {
6476
+ return Array.from(uniqueArrayData).filter((item) => !Array.from(compareArrayData).some(function (item2) {
6477
+ return compareFun(item, item2);
6478
+ }));
6479
+ }
6452
6480
  }
6453
6481
  waitArrayLoopToEnd(data, handleFunc) {
6454
6482
  let UtilsContext = this;