@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.iife.js
CHANGED
|
@@ -458,7 +458,6 @@ var Utils = (function () {
|
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
460
|
|
|
461
|
-
/// <reference path="./index.d.ts" />
|
|
462
461
|
// @name ajaxHooker
|
|
463
462
|
// @author cxxjackie
|
|
464
463
|
// @version 1.4.3
|
|
@@ -1507,13 +1506,14 @@ var Utils = (function () {
|
|
|
1507
1506
|
},
|
|
1508
1507
|
/**
|
|
1509
1508
|
* 成功的回调
|
|
1510
|
-
* @param response
|
|
1509
|
+
* @param response 响应
|
|
1510
|
+
* @param details 请求的配置
|
|
1511
1511
|
*/
|
|
1512
|
-
successResponseCallBack(response) {
|
|
1512
|
+
successResponseCallBack(response, details) {
|
|
1513
1513
|
for (let index = 0; index < this.$config.configList.length; index++) {
|
|
1514
1514
|
let item = this.$config.configList[index];
|
|
1515
1515
|
if (typeof item.successFn === "function") {
|
|
1516
|
-
if (item.successFn(response) == null) {
|
|
1516
|
+
if (item.successFn(response, details) == null) {
|
|
1517
1517
|
return;
|
|
1518
1518
|
}
|
|
1519
1519
|
}
|
|
@@ -1522,7 +1522,7 @@ var Utils = (function () {
|
|
|
1522
1522
|
},
|
|
1523
1523
|
/**
|
|
1524
1524
|
* 失败的回调
|
|
1525
|
-
* @param
|
|
1525
|
+
* @param data 配置
|
|
1526
1526
|
*/
|
|
1527
1527
|
errorResponseCallBack(data) {
|
|
1528
1528
|
for (let index = 0; index < this.$config.configList.length; index++) {
|
|
@@ -1785,6 +1785,7 @@ var Utils = (function () {
|
|
|
1785
1785
|
type: "onabort",
|
|
1786
1786
|
error: new TypeError("request canceled"),
|
|
1787
1787
|
response: null,
|
|
1788
|
+
details: details,
|
|
1788
1789
|
}) == null) {
|
|
1789
1790
|
return;
|
|
1790
1791
|
}
|
|
@@ -1816,6 +1817,7 @@ var Utils = (function () {
|
|
|
1816
1817
|
type: "onerror",
|
|
1817
1818
|
error: new TypeError("request error"),
|
|
1818
1819
|
response: response,
|
|
1820
|
+
details: details,
|
|
1819
1821
|
}) == null) {
|
|
1820
1822
|
return;
|
|
1821
1823
|
}
|
|
@@ -1844,6 +1846,7 @@ var Utils = (function () {
|
|
|
1844
1846
|
type: "ontimeout",
|
|
1845
1847
|
error: new TypeError("request timeout"),
|
|
1846
1848
|
response: (argumentsList || [null])[0],
|
|
1849
|
+
details: details,
|
|
1847
1850
|
}) == null) {
|
|
1848
1851
|
return;
|
|
1849
1852
|
}
|
|
@@ -1927,8 +1930,7 @@ var Utils = (function () {
|
|
|
1927
1930
|
}
|
|
1928
1931
|
/* 状态码2xx都是成功的 */
|
|
1929
1932
|
if (Math.floor(Response.status / 100) === 2) {
|
|
1930
|
-
if (this.context.HttpxResponseHook.successResponseCallBack(Response) ==
|
|
1931
|
-
null) {
|
|
1933
|
+
if (this.context.HttpxResponseHook.successResponseCallBack(Response, details) == null) {
|
|
1932
1934
|
return;
|
|
1933
1935
|
}
|
|
1934
1936
|
resolve({
|
|
@@ -2049,7 +2051,7 @@ var Utils = (function () {
|
|
|
2049
2051
|
let responseText = "";
|
|
2050
2052
|
/** 响应xml文档 */
|
|
2051
2053
|
let responseXML = "";
|
|
2052
|
-
let arrayBuffer = await resp.arrayBuffer;
|
|
2054
|
+
let arrayBuffer = await resp.arrayBuffer();
|
|
2053
2055
|
let encoding = "utf-8";
|
|
2054
2056
|
if (resp.headers.has("Content-Type")) {
|
|
2055
2057
|
let charsetMatched = resp.headers
|
|
@@ -2060,7 +2062,7 @@ var Utils = (function () {
|
|
|
2060
2062
|
}
|
|
2061
2063
|
}
|
|
2062
2064
|
let textDecoder = new TextDecoder(encoding);
|
|
2063
|
-
responseText = textDecoder.decode(
|
|
2065
|
+
responseText = textDecoder.decode(arrayBuffer);
|
|
2064
2066
|
response = responseText;
|
|
2065
2067
|
if (details.responseType === "arraybuffer") {
|
|
2066
2068
|
response = arrayBuffer;
|