@whitesev/utils 1.4.3 → 1.4.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 CHANGED
@@ -460,13 +460,14 @@ define((function () { 'use strict';
460
460
  /// <reference path="./index.d.ts" />
461
461
  // @name ajaxHooker
462
462
  // @author cxxjackie
463
- // @version 1.4.2
464
- // @updateLog 修复了fetch请求的参数为Request类型时body类型不正确的bug。
463
+ // @version 1.4.3
464
+ // @updateLog 修复特殊情况下有部分请求头丢失的问题。
465
+ // @updateLog xhr事件增加currentTarget劫持。
465
466
  // @supportURL https://bbs.tampermonkey.net.cn/thread-3284-1-1.html
466
467
 
467
468
  const AjaxHooker = function () {
468
469
  return function() {
469
- const version = '1.4.2';
470
+ const version = '1.4.3';
470
471
  const hookInst = {
471
472
  hookFns: [],
472
473
  filters: []
@@ -721,6 +722,7 @@ define((function () { 'use strict';
721
722
  dispatchEvent(e) {
722
723
  e.stopImmediatePropagation = stopImmediatePropagation;
723
724
  defineProp(e, 'target', () => this.proxyXhr);
725
+ defineProp(e, 'currentTarget', () => this.proxyXhr);
724
726
  this.proxyEvents[e.type] && this.proxyEvents[e.type].forEach(fn => {
725
727
  this.resThenable.then(() => !e.ajaxHooker_isStopped && fn.call(this.proxyXhr, e));
726
728
  });
@@ -730,7 +732,7 @@ define((function () { 'use strict';
730
732
  }
731
733
  setRequestHeader(header, value) {
732
734
  this.originalXhr.setRequestHeader(header, value);
733
- if (this.originalXhr.readyState !== 1) return;
735
+ if (!this.request) return;
734
736
  const headers = this.request.headers;
735
737
  headers[header] = header in headers ? `${headers[header]}, ${value}` : value;
736
738
  }
@@ -3059,7 +3061,7 @@ define((function () { 'use strict';
3059
3061
  UtilsCore.init(option);
3060
3062
  }
3061
3063
  /** 版本号 */
3062
- version = "2024.6.11";
3064
+ version = "2024.6.14";
3063
3065
  addStyle(cssText) {
3064
3066
  if (typeof cssText !== "string") {
3065
3067
  throw new Error("Utils.addStyle 参数cssText 必须为String类型");