ajax-hooker 1.0.3 → 1.0.6

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.
@@ -24,9 +24,14 @@ jobs:
24
24
  uses: actions/setup-node@v3
25
25
  with:
26
26
  node-version: '18'
27
-
27
+
28
+ - name: 安装pnpm
29
+ uses: pnpm/action-setup@v2
30
+ with:
31
+ version: 10
32
+
28
33
  - name: 安装依赖
29
- run: npm ci
34
+ run: pnpm i
30
35
 
31
36
  - name: 更新版本
32
37
  id: version
@@ -65,4 +70,4 @@ jobs:
65
70
  echo "包已发布!"
66
71
  echo "版本: ${{ steps.version.outputs.version }}"
67
72
  echo "类型: ${{ steps.publish.outputs.type }}"
68
- echo "URL: https://www.npmjs.com/package/web-hooker/v/${{ steps.version.outputs.version }}"
73
+ echo "URL: https://www.npmjs.com/package/ajax-hooker/v/${{ steps.version.outputs.version }}"
@@ -3596,7 +3596,7 @@ class XhrInterceptor {
3596
3596
  url: resolveUrl(args[1]),
3597
3597
  async: args[2] || true,
3598
3598
  headers: new Headers(),
3599
- body: null,
3599
+ data: null,
3600
3600
  response: () => { },
3601
3601
  };
3602
3602
  hooker.xhrOpenRestArgs = args.slice(2);
@@ -3610,7 +3610,7 @@ class XhrInterceptor {
3610
3610
  send: function (self, target) {
3611
3611
  return async function (body) {
3612
3612
  const hooker = target[CYCLE_SCHEDULER];
3613
- hooker.request.body = body ?? null;
3613
+ hooker.request.data = body ?? null;
3614
3614
  hooker.request.headers = new Headers(mapValues(hooker.xhrSetRequestHeadersAfterOpen, (val) => val.join(', ')));
3615
3615
  const oldRequest = cloneDeep(hooker.request);
3616
3616
  let newRequest = hooker.request;
@@ -3639,7 +3639,7 @@ class XhrInterceptor {
3639
3639
  target.setRequestHeader(key, val);
3640
3640
  });
3641
3641
  }
3642
- self.nativeXhrPrototype.send.apply(target, [hooker.request.body]);
3642
+ self.nativeXhrPrototype.send.apply(target, [hooker.request.data]);
3643
3643
  };
3644
3644
  },
3645
3645
  setRequestHeader: function (self, target) {
@@ -3788,7 +3788,7 @@ class FetchInterceptor {
3788
3788
  let url = '';
3789
3789
  let method = null;
3790
3790
  let headers = null;
3791
- let body = null;
3791
+ let data = null;
3792
3792
  if (typeof req === 'string') {
3793
3793
  url = resolveUrl(req);
3794
3794
  }
@@ -3799,13 +3799,13 @@ class FetchInterceptor {
3799
3799
  url = resolveUrl(req.url);
3800
3800
  method = req.method ?? null;
3801
3801
  headers = req.headers ?? null;
3802
- body = req.body ?? null;
3802
+ data = req.body ?? null;
3803
3803
  }
3804
3804
  return {
3805
3805
  url,
3806
3806
  method,
3807
3807
  headers,
3808
- body,
3808
+ data,
3809
3809
  };
3810
3810
  }
3811
3811
  resolveRequest(req, newRequest) {
@@ -3827,9 +3827,9 @@ class FetchInterceptor {
3827
3827
  return {
3828
3828
  ...(options ? options : {}),
3829
3829
  ...(newRequest.headers ? { headers: newRequest.headers } : {}),
3830
- ...(newRequest.body ? { body: newRequest.body } : {}),
3830
+ ...(newRequest.data ? { body: newRequest.data } : {}),
3831
3831
  ...(newRequest.method ? { method: newRequest.method } : {}),
3832
- ...(newRequest.body instanceof ReadableStream ? streamOptions : {}),
3832
+ ...(newRequest.data instanceof ReadableStream ? streamOptions : {}),
3833
3833
  };
3834
3834
  }
3835
3835
  _generateProxyFetch() {
@@ -3868,7 +3868,7 @@ class FetchInterceptor {
3868
3868
  method: request.method ?? options.method ?? 'GET',
3869
3869
  // TODO: 这里需要处理 headers 的类型
3870
3870
  headers: resolveHeaders(request.headers ?? options.headers ?? null),
3871
- body: request.body ?? options.body ?? null,
3871
+ data: request.data ?? options.body ?? null,
3872
3872
  response: () => { },
3873
3873
  }, self.hooks);
3874
3874
  }
@@ -3592,7 +3592,7 @@ class XhrInterceptor {
3592
3592
  url: resolveUrl(args[1]),
3593
3593
  async: args[2] || true,
3594
3594
  headers: new Headers(),
3595
- body: null,
3595
+ data: null,
3596
3596
  response: () => { },
3597
3597
  };
3598
3598
  hooker.xhrOpenRestArgs = args.slice(2);
@@ -3606,7 +3606,7 @@ class XhrInterceptor {
3606
3606
  send: function (self, target) {
3607
3607
  return async function (body) {
3608
3608
  const hooker = target[CYCLE_SCHEDULER];
3609
- hooker.request.body = body ?? null;
3609
+ hooker.request.data = body ?? null;
3610
3610
  hooker.request.headers = new Headers(mapValues(hooker.xhrSetRequestHeadersAfterOpen, (val) => val.join(', ')));
3611
3611
  const oldRequest = cloneDeep(hooker.request);
3612
3612
  let newRequest = hooker.request;
@@ -3635,7 +3635,7 @@ class XhrInterceptor {
3635
3635
  target.setRequestHeader(key, val);
3636
3636
  });
3637
3637
  }
3638
- self.nativeXhrPrototype.send.apply(target, [hooker.request.body]);
3638
+ self.nativeXhrPrototype.send.apply(target, [hooker.request.data]);
3639
3639
  };
3640
3640
  },
3641
3641
  setRequestHeader: function (self, target) {
@@ -3784,7 +3784,7 @@ class FetchInterceptor {
3784
3784
  let url = '';
3785
3785
  let method = null;
3786
3786
  let headers = null;
3787
- let body = null;
3787
+ let data = null;
3788
3788
  if (typeof req === 'string') {
3789
3789
  url = resolveUrl(req);
3790
3790
  }
@@ -3795,13 +3795,13 @@ class FetchInterceptor {
3795
3795
  url = resolveUrl(req.url);
3796
3796
  method = req.method ?? null;
3797
3797
  headers = req.headers ?? null;
3798
- body = req.body ?? null;
3798
+ data = req.body ?? null;
3799
3799
  }
3800
3800
  return {
3801
3801
  url,
3802
3802
  method,
3803
3803
  headers,
3804
- body,
3804
+ data,
3805
3805
  };
3806
3806
  }
3807
3807
  resolveRequest(req, newRequest) {
@@ -3823,9 +3823,9 @@ class FetchInterceptor {
3823
3823
  return {
3824
3824
  ...(options ? options : {}),
3825
3825
  ...(newRequest.headers ? { headers: newRequest.headers } : {}),
3826
- ...(newRequest.body ? { body: newRequest.body } : {}),
3826
+ ...(newRequest.data ? { body: newRequest.data } : {}),
3827
3827
  ...(newRequest.method ? { method: newRequest.method } : {}),
3828
- ...(newRequest.body instanceof ReadableStream ? streamOptions : {}),
3828
+ ...(newRequest.data instanceof ReadableStream ? streamOptions : {}),
3829
3829
  };
3830
3830
  }
3831
3831
  _generateProxyFetch() {
@@ -3864,7 +3864,7 @@ class FetchInterceptor {
3864
3864
  method: request.method ?? options.method ?? 'GET',
3865
3865
  // TODO: 这里需要处理 headers 的类型
3866
3866
  headers: resolveHeaders(request.headers ?? options.headers ?? null),
3867
- body: request.body ?? options.body ?? null,
3867
+ data: request.data ?? options.body ?? null,
3868
3868
  response: () => { },
3869
3869
  }, self.hooks);
3870
3870
  }