@whitesev/utils 1.5.8 → 1.5.9
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 +38 -16
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +38 -16
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +38 -16
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +38 -16
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +38 -16
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +38 -16
- package/dist/index.umd.js.map +1 -1
- package/dist/src/Httpx.d.ts +14 -0
- package/dist/src/Utils.d.ts +1 -1
- package/dist/src/UtilsCommon.d.ts +4 -0
- package/package.json +1 -1
- package/src/Httpx.ts +38 -8
- package/src/Utils.ts +2 -15
- package/src/UtilsCommon.ts +20 -0
package/dist/index.system.js
CHANGED
|
@@ -1535,12 +1535,21 @@ System.register('Utils', [], (function (exports) {
|
|
|
1535
1535
|
}
|
|
1536
1536
|
}
|
|
1537
1537
|
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1538
|
+
/**
|
|
1539
|
+
* 生成uuid
|
|
1540
|
+
*/
|
|
1541
|
+
const GenerateUUID = function () {
|
|
1542
|
+
if (typeof UtilsCore.globalThis?.crypto?.randomUUID === "function") {
|
|
1543
|
+
return UtilsCore.globalThis.crypto.randomUUID();
|
|
1544
|
+
}
|
|
1545
|
+
else {
|
|
1546
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (charStr) {
|
|
1547
|
+
var randomValue = (Math.random() * 16) | 0, randomCharValue = charStr === "x" ? randomValue : (randomValue & 0x3) | 0x8;
|
|
1548
|
+
return randomCharValue.toString(16);
|
|
1549
|
+
});
|
|
1550
|
+
}
|
|
1543
1551
|
};
|
|
1552
|
+
|
|
1544
1553
|
class Httpx {
|
|
1545
1554
|
GM_Api = {
|
|
1546
1555
|
xmlHttpRequest: null,
|
|
@@ -1559,6 +1568,12 @@ System.register('Utils', [], (function (exports) {
|
|
|
1559
1568
|
* @private
|
|
1560
1569
|
*/
|
|
1561
1570
|
beforeRequestCallBack(details) {
|
|
1571
|
+
if (!details.allowInterceptConfig) {
|
|
1572
|
+
return details;
|
|
1573
|
+
}
|
|
1574
|
+
if (!details.allowInterceptConfig.beforeRequest) {
|
|
1575
|
+
return details;
|
|
1576
|
+
}
|
|
1562
1577
|
for (let index = 0; index < this.$config.configList.length; index++) {
|
|
1563
1578
|
let item = this.$config.configList[index];
|
|
1564
1579
|
if (typeof item.fn === "function") {
|
|
@@ -1620,6 +1635,12 @@ System.register('Utils', [], (function (exports) {
|
|
|
1620
1635
|
* @param details 请求的配置
|
|
1621
1636
|
*/
|
|
1622
1637
|
successResponseCallBack(response, details) {
|
|
1638
|
+
if (!details.allowInterceptConfig) {
|
|
1639
|
+
return details;
|
|
1640
|
+
}
|
|
1641
|
+
if (!details.allowInterceptConfig.afterResponseSuccess) {
|
|
1642
|
+
return details;
|
|
1643
|
+
}
|
|
1623
1644
|
for (let index = 0; index < this.$config.configList.length; index++) {
|
|
1624
1645
|
let item = this.$config.configList[index];
|
|
1625
1646
|
if (typeof item.successFn === "function") {
|
|
@@ -1635,6 +1656,12 @@ System.register('Utils', [], (function (exports) {
|
|
|
1635
1656
|
* @param data 配置
|
|
1636
1657
|
*/
|
|
1637
1658
|
errorResponseCallBack(data) {
|
|
1659
|
+
if (!data.details.allowInterceptConfig) {
|
|
1660
|
+
return data;
|
|
1661
|
+
}
|
|
1662
|
+
if (!data.details.allowInterceptConfig.afterResponseError) {
|
|
1663
|
+
return data;
|
|
1664
|
+
}
|
|
1638
1665
|
for (let index = 0; index < this.$config.configList.length; index++) {
|
|
1639
1666
|
let item = this.$config.configList[index];
|
|
1640
1667
|
if (typeof item.errorFn === "function") {
|
|
@@ -2246,6 +2273,11 @@ System.register('Utils', [], (function (exports) {
|
|
|
2246
2273
|
anonymous: void 0,
|
|
2247
2274
|
fetch: void 0,
|
|
2248
2275
|
fetchInit: void 0,
|
|
2276
|
+
allowInterceptConfig: {
|
|
2277
|
+
beforeRequest: true,
|
|
2278
|
+
afterResponseSuccess: true,
|
|
2279
|
+
afterResponseError: true,
|
|
2280
|
+
},
|
|
2249
2281
|
user: void 0,
|
|
2250
2282
|
password: void 0,
|
|
2251
2283
|
onabort() { },
|
|
@@ -6359,17 +6391,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
6359
6391
|
* @example
|
|
6360
6392
|
* Utils.generateUUID()
|
|
6361
6393
|
*/
|
|
6362
|
-
generateUUID
|
|
6363
|
-
if (typeof globalThis?.crypto?.randomUUID === "function") {
|
|
6364
|
-
return globalThis.crypto.randomUUID();
|
|
6365
|
-
}
|
|
6366
|
-
else {
|
|
6367
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (charStr) {
|
|
6368
|
-
var randomValue = (Math.random() * 16) | 0, randomCharValue = charStr === "x" ? randomValue : (randomValue & 0x3) | 0x8;
|
|
6369
|
-
return randomCharValue.toString(16);
|
|
6370
|
-
});
|
|
6371
|
-
}
|
|
6372
|
-
}
|
|
6394
|
+
generateUUID = GenerateUUID;
|
|
6373
6395
|
}
|
|
6374
6396
|
let utils = exports("default", new Utils());
|
|
6375
6397
|
|