@whitesev/utils 1.5.4 → 1.5.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.
- package/dist/index.amd.js +11 -9
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +11 -9
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +11 -9
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +11 -9
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +11 -9
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +11 -9
- package/dist/index.umd.js.map +1 -1
- package/dist/src/Httpx.d.ts +1 -1
- package/dist/src/Utils.d.ts +3 -3
- package/package.json +1 -1
- package/src/Httpx.ts +18 -8
- package/src/Utils.ts +1 -0
- package/src/ajaxHooker/ajaxHooker.js +0 -1
- package/src/ajaxHooker/index.d.ts +4 -4
package/dist/index.esm.js
CHANGED
|
@@ -455,7 +455,6 @@ class UtilsGMCookie {
|
|
|
455
455
|
}
|
|
456
456
|
}
|
|
457
457
|
|
|
458
|
-
/// <reference path="./index.d.ts" />
|
|
459
458
|
// @name ajaxHooker
|
|
460
459
|
// @author cxxjackie
|
|
461
460
|
// @version 1.4.3
|
|
@@ -1504,13 +1503,14 @@ class Httpx {
|
|
|
1504
1503
|
},
|
|
1505
1504
|
/**
|
|
1506
1505
|
* 成功的回调
|
|
1507
|
-
* @param response
|
|
1506
|
+
* @param response 响应
|
|
1507
|
+
* @param details 请求的配置
|
|
1508
1508
|
*/
|
|
1509
|
-
successResponseCallBack(response) {
|
|
1509
|
+
successResponseCallBack(response, details) {
|
|
1510
1510
|
for (let index = 0; index < this.$config.configList.length; index++) {
|
|
1511
1511
|
let item = this.$config.configList[index];
|
|
1512
1512
|
if (typeof item.successFn === "function") {
|
|
1513
|
-
if (item.successFn(response) == null) {
|
|
1513
|
+
if (item.successFn(response, details) == null) {
|
|
1514
1514
|
return;
|
|
1515
1515
|
}
|
|
1516
1516
|
}
|
|
@@ -1519,7 +1519,7 @@ class Httpx {
|
|
|
1519
1519
|
},
|
|
1520
1520
|
/**
|
|
1521
1521
|
* 失败的回调
|
|
1522
|
-
* @param
|
|
1522
|
+
* @param data 配置
|
|
1523
1523
|
*/
|
|
1524
1524
|
errorResponseCallBack(data) {
|
|
1525
1525
|
for (let index = 0; index < this.$config.configList.length; index++) {
|
|
@@ -1782,6 +1782,7 @@ class Httpx {
|
|
|
1782
1782
|
type: "onabort",
|
|
1783
1783
|
error: new TypeError("request canceled"),
|
|
1784
1784
|
response: null,
|
|
1785
|
+
details: details,
|
|
1785
1786
|
}) == null) {
|
|
1786
1787
|
return;
|
|
1787
1788
|
}
|
|
@@ -1813,6 +1814,7 @@ class Httpx {
|
|
|
1813
1814
|
type: "onerror",
|
|
1814
1815
|
error: new TypeError("request error"),
|
|
1815
1816
|
response: response,
|
|
1817
|
+
details: details,
|
|
1816
1818
|
}) == null) {
|
|
1817
1819
|
return;
|
|
1818
1820
|
}
|
|
@@ -1841,6 +1843,7 @@ class Httpx {
|
|
|
1841
1843
|
type: "ontimeout",
|
|
1842
1844
|
error: new TypeError("request timeout"),
|
|
1843
1845
|
response: (argumentsList || [null])[0],
|
|
1846
|
+
details: details,
|
|
1844
1847
|
}) == null) {
|
|
1845
1848
|
return;
|
|
1846
1849
|
}
|
|
@@ -1924,8 +1927,7 @@ class Httpx {
|
|
|
1924
1927
|
}
|
|
1925
1928
|
/* 状态码2xx都是成功的 */
|
|
1926
1929
|
if (Math.floor(Response.status / 100) === 2) {
|
|
1927
|
-
if (this.context.HttpxResponseHook.successResponseCallBack(Response) ==
|
|
1928
|
-
null) {
|
|
1930
|
+
if (this.context.HttpxResponseHook.successResponseCallBack(Response, details) == null) {
|
|
1929
1931
|
return;
|
|
1930
1932
|
}
|
|
1931
1933
|
resolve({
|
|
@@ -2046,7 +2048,7 @@ class Httpx {
|
|
|
2046
2048
|
let responseText = "";
|
|
2047
2049
|
/** 响应xml文档 */
|
|
2048
2050
|
let responseXML = "";
|
|
2049
|
-
let arrayBuffer = await resp.arrayBuffer;
|
|
2051
|
+
let arrayBuffer = await resp.arrayBuffer();
|
|
2050
2052
|
let encoding = "utf-8";
|
|
2051
2053
|
if (resp.headers.has("Content-Type")) {
|
|
2052
2054
|
let charsetMatched = resp.headers
|
|
@@ -2057,7 +2059,7 @@ class Httpx {
|
|
|
2057
2059
|
}
|
|
2058
2060
|
}
|
|
2059
2061
|
let textDecoder = new TextDecoder(encoding);
|
|
2060
|
-
responseText = textDecoder.decode(
|
|
2062
|
+
responseText = textDecoder.decode(arrayBuffer);
|
|
2061
2063
|
response = responseText;
|
|
2062
2064
|
if (details.responseType === "arraybuffer") {
|
|
2063
2065
|
response = arrayBuffer;
|