@tarojs/plugin-http 3.6.13-alpha.2 → 3.6.13

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/runtime.d.ts CHANGED
@@ -58,10 +58,7 @@ declare class XMLHttpRequest extends Events {
58
58
  // 欺骗一些库让其认为是原生的xhr
59
59
  static toString(): string;
60
60
  toString(): string;
61
- // 事件正常流转: loadstart => progress(可能多次) => load => loadend
62
- // error 流转: loadstart => error => loadend
63
- // abort 流转: loadstart => abort => loadend
64
- // web在线测试: https://developer.mozilla.org/zh-CN/play
61
+ // 事件
65
62
  /** 当 request 被停止时触发,例如当程序调用 XMLHttpRequest.abort() 时 */
66
63
  onabort: ((e: XMLHttpRequestEvent) => void) | null;
67
64
  /** 当 request 遭遇错误时触发 */
package/dist/runtime.js CHANGED
@@ -406,10 +406,7 @@ class XMLHttpRequest extends Events {
406
406
  _XMLHttpRequest_timeout.set(this, void 0);
407
407
  _XMLHttpRequest_withCredentials.set(this, void 0);
408
408
  _XMLHttpRequest_requestTask.set(this, void 0);
409
- // 事件正常流转: loadstart => progress(可能多次) => load => loadend
410
- // error 流转: loadstart => error => loadend
411
- // abort 流转: loadstart => abort => loadend
412
- // web在线测试: https://developer.mozilla.org/zh-CN/play
409
+ // 事件
413
410
  /** 当 request 被停止时触发,例如当程序调用 XMLHttpRequest.abort() 时 */
414
411
  this.onabort = null;
415
412
  /** 当 request 遭遇错误时触发 */
@@ -646,30 +643,8 @@ _XMLHttpRequest_method = new WeakMap(), _XMLHttpRequest_url = new WeakMap(), _XM
646
643
  isFunction(this.onload) && this.onload(loadEvent);
647
644
  }
648
645
  }, _XMLHttpRequest_requestFail = function _XMLHttpRequest_requestFail(err) {
649
- // 微信小程序,无论接口返回200还是其他,响应无论是否有错误,都会进入 success 回调;只有类似超时这种请求错误才会进入 fail 回调
650
- //
651
- /**
652
- * 阿里系小程序,接口返回非200状态码,会进入 fail 回调, 此时 err 对象结构如下(当错误码为 14 或 19 时,会多返回 status、data、headers。可通过这些字段获取服务端相关错误信息):
653
- {
654
- data: "{\"code\": 401,\"msg\":\"登录过期,请重新登录\"}"
655
- error: 19
656
- errorMessage: "http status error"
657
- headers: {date: 'Mon, 14 Aug 2023 08:54:58 GMT', content-type: 'application/json;charset=UTF-8', content-length: '52', connection: 'close', access-control-allow-credentials: 'true', …}
658
- originalData: "{\"code\": 401,\"msg\":\"登录过期,请重新登录\"}"
659
- status: 401
660
- }
661
- */
662
- // 统一行为,能正常响应的,都算 success.
663
- if (err.status) {
664
- __classPrivateFieldGet(this, _XMLHttpRequest_instances, "m", _XMLHttpRequest_requestSuccess).call(this, {
665
- data: err,
666
- statusCode: err.status,
667
- header: err.headers
668
- });
669
- return;
670
- }
671
646
  __classPrivateFieldSet(this, _XMLHttpRequest_status, 0, "f");
672
- __classPrivateFieldSet(this, _XMLHttpRequest_statusText, err.errMsg || err.errorMessage, "f");
647
+ __classPrivateFieldSet(this, _XMLHttpRequest_statusText, err.errMsg, "f");
673
648
  const errorEvent = createXMLHttpRequestEvent('error', this, 0);
674
649
  this.trigger('error', errorEvent);
675
650
  isFunction(this.onerror) && this.onerror(errorEvent);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarojs/plugin-http",
3
- "version": "3.6.13-alpha.2",
3
+ "version": "3.6.13",
4
4
  "description": "Taro 小程序端支持使用 web 请求 的插件",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -23,9 +23,9 @@
23
23
  },
24
24
  "homepage": "https://github.com/NervJS/taro#readme",
25
25
  "dependencies": {
26
- "@tarojs/runtime": "3.6.13-alpha.2",
27
- "@tarojs/service": "3.6.13-alpha.2",
28
- "@tarojs/shared": "3.6.13-alpha.2"
26
+ "@tarojs/runtime": "3.6.13",
27
+ "@tarojs/service": "3.6.13",
28
+ "@tarojs/shared": "3.6.13"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@rollup/plugin-json": "^4.1.0",
@@ -118,10 +118,7 @@ export class XMLHttpRequest extends Events {
118
118
  #withCredentials: boolean
119
119
  #requestTask: null | Taro.RequestTask<any>
120
120
 
121
- // 事件正常流转: loadstart => progress(可能多次) => load => loadend
122
- // error 流转: loadstart => error => loadend
123
- // abort 流转: loadstart => abort => loadend
124
- // web在线测试: https://developer.mozilla.org/zh-CN/play
121
+ // 事件
125
122
 
126
123
  /** 当 request 被停止时触发,例如当程序调用 XMLHttpRequest.abort() 时 */
127
124
  onabort: ((e: XMLHttpRequestEvent) => void) | null = null
@@ -312,30 +309,8 @@ export class XMLHttpRequest extends Events {
312
309
  * 请求失败
313
310
  */
314
311
  #requestFail (err) {
315
- // 微信小程序,无论接口返回200还是其他,响应无论是否有错误,都会进入 success 回调;只有类似超时这种请求错误才会进入 fail 回调
316
- //
317
- /**
318
- * 阿里系小程序,接口返回非200状态码,会进入 fail 回调, 此时 err 对象结构如下(当错误码为 14 或 19 时,会多返回 status、data、headers。可通过这些字段获取服务端相关错误信息):
319
- {
320
- data: "{\"code\": 401,\"msg\":\"登录过期,请重新登录\"}"
321
- error: 19
322
- errorMessage: "http status error"
323
- headers: {date: 'Mon, 14 Aug 2023 08:54:58 GMT', content-type: 'application/json;charset=UTF-8', content-length: '52', connection: 'close', access-control-allow-credentials: 'true', …}
324
- originalData: "{\"code\": 401,\"msg\":\"登录过期,请重新登录\"}"
325
- status: 401
326
- }
327
- */
328
- // 统一行为,能正常响应的,都算 success.
329
- if (err.status) {
330
- this.#requestSuccess({
331
- data: err,
332
- statusCode: err.status,
333
- header: err.headers
334
- })
335
- return
336
- }
337
- this.#status = 0
338
- this.#statusText = err.errMsg || err.errorMessage
312
+ this.#status = 0
313
+ this.#statusText = err.errMsg
339
314
  const errorEvent = createXMLHttpRequestEvent('error', this, 0)
340
315
  this.trigger('error', errorEvent)
341
316
  isFunction(this.onerror) && this.onerror(errorEvent)