@impui/imp 1.0.15 → 1.0.16-beta.0
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/axios/index.es.js +143 -0
- package/dist/config/index.es.js +127 -0
- package/dist/core/index.es.js +34 -0
- package/dist/gotool/go2/index.es.js +510 -0
- package/dist/gotool/index/index.es.js +164 -0
- package/dist/imph5/index.es.js +324 -0
- package/dist/index.es.js +49 -1
- package/dist/login/index.es.js +711 -0
- package/dist/node_modules/axios/index/index.es.js +38 -0
- package/dist/node_modules/axios/lib/adapters/adapters/index.es.js +71 -0
- package/dist/node_modules/axios/lib/adapters/fetch/index.es.js +219 -0
- package/dist/node_modules/axios/lib/adapters/xhr/index.es.js +141 -0
- package/dist/node_modules/axios/lib/axios/index.es.js +50 -0
- package/dist/node_modules/axios/lib/cancel/CancelToken/index.es.js +99 -0
- package/dist/node_modules/axios/lib/cancel/CanceledError/index.es.js +12 -0
- package/dist/node_modules/axios/lib/cancel/isCancel/index.es.js +6 -0
- package/dist/node_modules/axios/lib/core/Axios/index.es.js +180 -0
- package/dist/node_modules/axios/lib/core/AxiosError/index.es.js +80 -0
- package/dist/node_modules/axios/lib/core/AxiosHeaders/index.es.js +231 -0
- package/dist/node_modules/axios/lib/core/InterceptorManager/index.es.js +65 -0
- package/dist/node_modules/axios/lib/core/buildFullPath/index.es.js +12 -0
- package/dist/node_modules/axios/lib/core/dispatchRequest/index.es.js +52 -0
- package/dist/node_modules/axios/lib/core/mergeConfig/index.es.js +83 -0
- package/dist/node_modules/axios/lib/core/settle/index.es.js +18 -0
- package/dist/node_modules/axios/lib/core/transformData/index.es.js +17 -0
- package/dist/node_modules/axios/lib/defaults/index/index.es.js +116 -0
- package/dist/node_modules/axios/lib/defaults/transitional/index.es.js +8 -0
- package/dist/node_modules/axios/lib/env/data/index.es.js +4 -0
- package/dist/node_modules/axios/lib/helpers/AxiosURLSearchParams/index.es.js +34 -0
- package/dist/node_modules/axios/lib/helpers/HttpStatusCode/index.es.js +77 -0
- package/dist/node_modules/axios/lib/helpers/bind/index.es.js +8 -0
- package/dist/node_modules/axios/lib/helpers/buildURL/index.es.js +34 -0
- package/dist/node_modules/axios/lib/helpers/combineURLs/index.es.js +6 -0
- package/dist/node_modules/axios/lib/helpers/composeSignals/index.es.js +39 -0
- package/dist/node_modules/axios/lib/helpers/cookies/index.es.js +49 -0
- package/dist/node_modules/axios/lib/helpers/formDataToJSON/index.es.js +54 -0
- package/dist/node_modules/axios/lib/helpers/isAbsoluteURL/index.es.js +6 -0
- package/dist/node_modules/axios/lib/helpers/isAxiosError/index.es.js +7 -0
- package/dist/node_modules/axios/lib/helpers/isURLSameOrigin/index.es.js +11 -0
- package/dist/node_modules/axios/lib/helpers/null/index.es.js +4 -0
- package/dist/node_modules/axios/lib/helpers/parseHeaders/index.es.js +47 -0
- package/dist/node_modules/axios/lib/helpers/parseProtocol/index.es.js +7 -0
- package/dist/node_modules/axios/lib/helpers/progressEventReducer/index.es.js +41 -0
- package/dist/node_modules/axios/lib/helpers/resolveConfig/index.es.js +46 -0
- package/dist/node_modules/axios/lib/helpers/speedometer/index.es.js +36 -0
- package/dist/node_modules/axios/lib/helpers/spread/index.es.js +8 -0
- package/dist/node_modules/axios/lib/helpers/throttle/index.es.js +35 -0
- package/dist/node_modules/axios/lib/helpers/toFormData/index.es.js +117 -0
- package/dist/node_modules/axios/lib/helpers/toURLEncodedForm/index.es.js +18 -0
- package/dist/node_modules/axios/lib/helpers/trackStream/index.es.js +80 -0
- package/dist/node_modules/axios/lib/helpers/validator/index.es.js +67 -0
- package/dist/node_modules/axios/lib/platform/browser/classes/Blob/index.es.js +4 -0
- package/dist/node_modules/axios/lib/platform/browser/classes/FormData/index.es.js +4 -0
- package/dist/node_modules/axios/lib/platform/browser/classes/URLSearchParams/index.es.js +5 -0
- package/dist/node_modules/axios/lib/platform/browser/index/index.es.js +15 -0
- package/dist/node_modules/axios/lib/platform/common/utils/index.es.js +15 -0
- package/dist/node_modules/axios/lib/platform/index/index.es.js +9 -0
- package/dist/node_modules/axios/lib/utils/index.es.js +387 -0
- package/dist/packages/com/dist/browser/index.es/index.es.js +1 -0
- package/dist/packages/com/dist/cache/index.es/index.es.js +145 -0
- package/dist/packages/com/dist/core/index.es/index.es.js +154 -0
- package/dist/packages/com/dist/data/index.es/index.es.js +26 -0
- package/dist/packages/com/dist/date/index.es/index.es.js +194 -0
- package/dist/packages/com/dist/log/index.es/index.es.js +110 -0
- package/dist/packages/com/dist/message/index.es/index.es.js +90 -0
- package/dist/packages/com/dist/req/index.es/index.es.js +35 -0
- package/dist/packages/com/dist/str/index.es/index.es.js +25 -0
- package/dist/packages/com/dist/typetool/index.es/index.es.js +53 -0
- package/dist/packages/com/dist/url/index.es/index.es.js +238 -0
- package/dist/restool/index/index.es.js +266 -0
- package/dist/restool/index.css/index.es.js +4 -0
- package/package.json +2 -3
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import AxiosError from "../AxiosError/index.es.js";
|
|
2
|
+
function settle(resolve, reject, response) {
|
|
3
|
+
const validateStatus = response.config.validateStatus;
|
|
4
|
+
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
5
|
+
resolve(response);
|
|
6
|
+
} else {
|
|
7
|
+
reject(new AxiosError(
|
|
8
|
+
"Request failed with status code " + response.status,
|
|
9
|
+
[AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
|
10
|
+
response.config,
|
|
11
|
+
response.request,
|
|
12
|
+
response
|
|
13
|
+
));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
settle as default
|
|
18
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import utils from "../../utils/index.es.js";
|
|
2
|
+
import defaults from "../../defaults/index/index.es.js";
|
|
3
|
+
import AxiosHeaders from "../AxiosHeaders/index.es.js";
|
|
4
|
+
function transformData(fns, response) {
|
|
5
|
+
const config = this || defaults;
|
|
6
|
+
const context = response || config;
|
|
7
|
+
const headers = AxiosHeaders.from(context.headers);
|
|
8
|
+
let data = context.data;
|
|
9
|
+
utils.forEach(fns, function transform(fn) {
|
|
10
|
+
data = fn.call(config, data, headers.normalize(), response ? response.status : void 0);
|
|
11
|
+
});
|
|
12
|
+
headers.normalize();
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
transformData as default
|
|
17
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import utils from "../../utils/index.es.js";
|
|
2
|
+
import AxiosError from "../../core/AxiosError/index.es.js";
|
|
3
|
+
import transitionalDefaults from "../transitional/index.es.js";
|
|
4
|
+
import toFormData from "../../helpers/toFormData/index.es.js";
|
|
5
|
+
import toURLEncodedForm from "../../helpers/toURLEncodedForm/index.es.js";
|
|
6
|
+
import platform from "../../platform/index/index.es.js";
|
|
7
|
+
import formDataToJSON from "../../helpers/formDataToJSON/index.es.js";
|
|
8
|
+
function stringifySafely(rawValue, parser, encoder) {
|
|
9
|
+
if (utils.isString(rawValue)) {
|
|
10
|
+
try {
|
|
11
|
+
(parser || JSON.parse)(rawValue);
|
|
12
|
+
return utils.trim(rawValue);
|
|
13
|
+
} catch (e) {
|
|
14
|
+
if (e.name !== "SyntaxError") {
|
|
15
|
+
throw e;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return (encoder || JSON.stringify)(rawValue);
|
|
20
|
+
}
|
|
21
|
+
const defaults = {
|
|
22
|
+
transitional: transitionalDefaults,
|
|
23
|
+
adapter: ["xhr", "http", "fetch"],
|
|
24
|
+
transformRequest: [function transformRequest(data, headers) {
|
|
25
|
+
const contentType = headers.getContentType() || "";
|
|
26
|
+
const hasJSONContentType = contentType.indexOf("application/json") > -1;
|
|
27
|
+
const isObjectPayload = utils.isObject(data);
|
|
28
|
+
if (isObjectPayload && utils.isHTMLForm(data)) {
|
|
29
|
+
data = new FormData(data);
|
|
30
|
+
}
|
|
31
|
+
const isFormData = utils.isFormData(data);
|
|
32
|
+
if (isFormData) {
|
|
33
|
+
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
34
|
+
}
|
|
35
|
+
if (utils.isArrayBuffer(data) || utils.isBuffer(data) || utils.isStream(data) || utils.isFile(data) || utils.isBlob(data) || utils.isReadableStream(data)) {
|
|
36
|
+
return data;
|
|
37
|
+
}
|
|
38
|
+
if (utils.isArrayBufferView(data)) {
|
|
39
|
+
return data.buffer;
|
|
40
|
+
}
|
|
41
|
+
if (utils.isURLSearchParams(data)) {
|
|
42
|
+
headers.setContentType("application/x-www-form-urlencoded;charset=utf-8", false);
|
|
43
|
+
return data.toString();
|
|
44
|
+
}
|
|
45
|
+
let isFileList;
|
|
46
|
+
if (isObjectPayload) {
|
|
47
|
+
if (contentType.indexOf("application/x-www-form-urlencoded") > -1) {
|
|
48
|
+
return toURLEncodedForm(data, this.formSerializer).toString();
|
|
49
|
+
}
|
|
50
|
+
if ((isFileList = utils.isFileList(data)) || contentType.indexOf("multipart/form-data") > -1) {
|
|
51
|
+
const _FormData = this.env && this.env.FormData;
|
|
52
|
+
return toFormData(
|
|
53
|
+
isFileList ? { "files[]": data } : data,
|
|
54
|
+
_FormData && new _FormData(),
|
|
55
|
+
this.formSerializer
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (isObjectPayload || hasJSONContentType) {
|
|
60
|
+
headers.setContentType("application/json", false);
|
|
61
|
+
return stringifySafely(data);
|
|
62
|
+
}
|
|
63
|
+
return data;
|
|
64
|
+
}],
|
|
65
|
+
transformResponse: [function transformResponse(data) {
|
|
66
|
+
const transitional = this.transitional || defaults.transitional;
|
|
67
|
+
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
68
|
+
const JSONRequested = this.responseType === "json";
|
|
69
|
+
if (utils.isResponse(data) || utils.isReadableStream(data)) {
|
|
70
|
+
return data;
|
|
71
|
+
}
|
|
72
|
+
if (data && utils.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
|
|
73
|
+
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
74
|
+
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
75
|
+
try {
|
|
76
|
+
return JSON.parse(data, this.parseReviver);
|
|
77
|
+
} catch (e) {
|
|
78
|
+
if (strictJSONParsing) {
|
|
79
|
+
if (e.name === "SyntaxError") {
|
|
80
|
+
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
|
81
|
+
}
|
|
82
|
+
throw e;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return data;
|
|
87
|
+
}],
|
|
88
|
+
/**
|
|
89
|
+
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
90
|
+
* timeout is not created.
|
|
91
|
+
*/
|
|
92
|
+
timeout: 0,
|
|
93
|
+
xsrfCookieName: "XSRF-TOKEN",
|
|
94
|
+
xsrfHeaderName: "X-XSRF-TOKEN",
|
|
95
|
+
maxContentLength: -1,
|
|
96
|
+
maxBodyLength: -1,
|
|
97
|
+
env: {
|
|
98
|
+
FormData: platform.classes.FormData,
|
|
99
|
+
Blob: platform.classes.Blob
|
|
100
|
+
},
|
|
101
|
+
validateStatus: function validateStatus(status) {
|
|
102
|
+
return status >= 200 && status < 300;
|
|
103
|
+
},
|
|
104
|
+
headers: {
|
|
105
|
+
common: {
|
|
106
|
+
"Accept": "application/json, text/plain, */*",
|
|
107
|
+
"Content-Type": void 0
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
utils.forEach(["delete", "get", "head", "post", "put", "patch"], (method) => {
|
|
112
|
+
defaults.headers[method] = {};
|
|
113
|
+
});
|
|
114
|
+
export {
|
|
115
|
+
defaults as default
|
|
116
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import toFormData from "../toFormData/index.es.js";
|
|
2
|
+
function encode(str) {
|
|
3
|
+
const charMap = {
|
|
4
|
+
"!": "%21",
|
|
5
|
+
"'": "%27",
|
|
6
|
+
"(": "%28",
|
|
7
|
+
")": "%29",
|
|
8
|
+
"~": "%7E",
|
|
9
|
+
"%20": "+",
|
|
10
|
+
"%00": "\0"
|
|
11
|
+
};
|
|
12
|
+
return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
|
|
13
|
+
return charMap[match];
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function AxiosURLSearchParams(params, options) {
|
|
17
|
+
this._pairs = [];
|
|
18
|
+
params && toFormData(params, this, options);
|
|
19
|
+
}
|
|
20
|
+
const prototype = AxiosURLSearchParams.prototype;
|
|
21
|
+
prototype.append = function append(name, value) {
|
|
22
|
+
this._pairs.push([name, value]);
|
|
23
|
+
};
|
|
24
|
+
prototype.toString = function toString(encoder) {
|
|
25
|
+
const _encode = encoder ? function(value) {
|
|
26
|
+
return encoder.call(this, value, encode);
|
|
27
|
+
} : encode;
|
|
28
|
+
return this._pairs.map(function each(pair) {
|
|
29
|
+
return _encode(pair[0]) + "=" + _encode(pair[1]);
|
|
30
|
+
}, "").join("&");
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
AxiosURLSearchParams as default
|
|
34
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const HttpStatusCode = {
|
|
2
|
+
Continue: 100,
|
|
3
|
+
SwitchingProtocols: 101,
|
|
4
|
+
Processing: 102,
|
|
5
|
+
EarlyHints: 103,
|
|
6
|
+
Ok: 200,
|
|
7
|
+
Created: 201,
|
|
8
|
+
Accepted: 202,
|
|
9
|
+
NonAuthoritativeInformation: 203,
|
|
10
|
+
NoContent: 204,
|
|
11
|
+
ResetContent: 205,
|
|
12
|
+
PartialContent: 206,
|
|
13
|
+
MultiStatus: 207,
|
|
14
|
+
AlreadyReported: 208,
|
|
15
|
+
ImUsed: 226,
|
|
16
|
+
MultipleChoices: 300,
|
|
17
|
+
MovedPermanently: 301,
|
|
18
|
+
Found: 302,
|
|
19
|
+
SeeOther: 303,
|
|
20
|
+
NotModified: 304,
|
|
21
|
+
UseProxy: 305,
|
|
22
|
+
Unused: 306,
|
|
23
|
+
TemporaryRedirect: 307,
|
|
24
|
+
PermanentRedirect: 308,
|
|
25
|
+
BadRequest: 400,
|
|
26
|
+
Unauthorized: 401,
|
|
27
|
+
PaymentRequired: 402,
|
|
28
|
+
Forbidden: 403,
|
|
29
|
+
NotFound: 404,
|
|
30
|
+
MethodNotAllowed: 405,
|
|
31
|
+
NotAcceptable: 406,
|
|
32
|
+
ProxyAuthenticationRequired: 407,
|
|
33
|
+
RequestTimeout: 408,
|
|
34
|
+
Conflict: 409,
|
|
35
|
+
Gone: 410,
|
|
36
|
+
LengthRequired: 411,
|
|
37
|
+
PreconditionFailed: 412,
|
|
38
|
+
PayloadTooLarge: 413,
|
|
39
|
+
UriTooLong: 414,
|
|
40
|
+
UnsupportedMediaType: 415,
|
|
41
|
+
RangeNotSatisfiable: 416,
|
|
42
|
+
ExpectationFailed: 417,
|
|
43
|
+
ImATeapot: 418,
|
|
44
|
+
MisdirectedRequest: 421,
|
|
45
|
+
UnprocessableEntity: 422,
|
|
46
|
+
Locked: 423,
|
|
47
|
+
FailedDependency: 424,
|
|
48
|
+
TooEarly: 425,
|
|
49
|
+
UpgradeRequired: 426,
|
|
50
|
+
PreconditionRequired: 428,
|
|
51
|
+
TooManyRequests: 429,
|
|
52
|
+
RequestHeaderFieldsTooLarge: 431,
|
|
53
|
+
UnavailableForLegalReasons: 451,
|
|
54
|
+
InternalServerError: 500,
|
|
55
|
+
NotImplemented: 501,
|
|
56
|
+
BadGateway: 502,
|
|
57
|
+
ServiceUnavailable: 503,
|
|
58
|
+
GatewayTimeout: 504,
|
|
59
|
+
HttpVersionNotSupported: 505,
|
|
60
|
+
VariantAlsoNegotiates: 506,
|
|
61
|
+
InsufficientStorage: 507,
|
|
62
|
+
LoopDetected: 508,
|
|
63
|
+
NotExtended: 510,
|
|
64
|
+
NetworkAuthenticationRequired: 511,
|
|
65
|
+
WebServerIsDown: 521,
|
|
66
|
+
ConnectionTimedOut: 522,
|
|
67
|
+
OriginIsUnreachable: 523,
|
|
68
|
+
TimeoutOccurred: 524,
|
|
69
|
+
SslHandshakeFailed: 525,
|
|
70
|
+
InvalidSslCertificate: 526
|
|
71
|
+
};
|
|
72
|
+
Object.entries(HttpStatusCode).forEach(([key, value]) => {
|
|
73
|
+
HttpStatusCode[value] = key;
|
|
74
|
+
});
|
|
75
|
+
export {
|
|
76
|
+
HttpStatusCode as default
|
|
77
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import utils from "../../utils/index.es.js";
|
|
2
|
+
import AxiosURLSearchParams from "../AxiosURLSearchParams/index.es.js";
|
|
3
|
+
function encode(val) {
|
|
4
|
+
return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+");
|
|
5
|
+
}
|
|
6
|
+
function buildURL(url, params, options) {
|
|
7
|
+
if (!params) {
|
|
8
|
+
return url;
|
|
9
|
+
}
|
|
10
|
+
const _encode = options && options.encode || encode;
|
|
11
|
+
if (utils.isFunction(options)) {
|
|
12
|
+
options = {
|
|
13
|
+
serialize: options
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const serializeFn = options && options.serialize;
|
|
17
|
+
let serializedParams;
|
|
18
|
+
if (serializeFn) {
|
|
19
|
+
serializedParams = serializeFn(params, options);
|
|
20
|
+
} else {
|
|
21
|
+
serializedParams = utils.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, options).toString(_encode);
|
|
22
|
+
}
|
|
23
|
+
if (serializedParams) {
|
|
24
|
+
const hashmarkIndex = url.indexOf("#");
|
|
25
|
+
if (hashmarkIndex !== -1) {
|
|
26
|
+
url = url.slice(0, hashmarkIndex);
|
|
27
|
+
}
|
|
28
|
+
url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
|
|
29
|
+
}
|
|
30
|
+
return url;
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
buildURL as default
|
|
34
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import CanceledError from "../../cancel/CanceledError/index.es.js";
|
|
2
|
+
import AxiosError from "../../core/AxiosError/index.es.js";
|
|
3
|
+
import utils from "../../utils/index.es.js";
|
|
4
|
+
const composeSignals = (signals, timeout) => {
|
|
5
|
+
const { length } = signals = signals ? signals.filter(Boolean) : [];
|
|
6
|
+
if (timeout || length) {
|
|
7
|
+
let controller = new AbortController();
|
|
8
|
+
let aborted;
|
|
9
|
+
const onabort = function(reason) {
|
|
10
|
+
if (!aborted) {
|
|
11
|
+
aborted = true;
|
|
12
|
+
unsubscribe();
|
|
13
|
+
const err = reason instanceof Error ? reason : this.reason;
|
|
14
|
+
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
let timer = timeout && setTimeout(() => {
|
|
18
|
+
timer = null;
|
|
19
|
+
onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
|
|
20
|
+
}, timeout);
|
|
21
|
+
const unsubscribe = () => {
|
|
22
|
+
if (signals) {
|
|
23
|
+
timer && clearTimeout(timer);
|
|
24
|
+
timer = null;
|
|
25
|
+
signals.forEach((signal2) => {
|
|
26
|
+
signal2.unsubscribe ? signal2.unsubscribe(onabort) : signal2.removeEventListener("abort", onabort);
|
|
27
|
+
});
|
|
28
|
+
signals = null;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
signals.forEach((signal2) => signal2.addEventListener("abort", onabort));
|
|
32
|
+
const { signal } = controller;
|
|
33
|
+
signal.unsubscribe = () => utils.asap(unsubscribe);
|
|
34
|
+
return signal;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
composeSignals as default
|
|
39
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import utils from "../../utils/index.es.js";
|
|
2
|
+
import platform from "../../platform/index/index.es.js";
|
|
3
|
+
const cookies = platform.hasStandardBrowserEnv ? (
|
|
4
|
+
// Standard browser envs support document.cookie
|
|
5
|
+
{
|
|
6
|
+
write(name, value, expires, path, domain, secure, sameSite) {
|
|
7
|
+
if (typeof document === "undefined") return;
|
|
8
|
+
const cookie = [`${name}=${encodeURIComponent(value)}`];
|
|
9
|
+
if (utils.isNumber(expires)) {
|
|
10
|
+
cookie.push(`expires=${new Date(expires).toUTCString()}`);
|
|
11
|
+
}
|
|
12
|
+
if (utils.isString(path)) {
|
|
13
|
+
cookie.push(`path=${path}`);
|
|
14
|
+
}
|
|
15
|
+
if (utils.isString(domain)) {
|
|
16
|
+
cookie.push(`domain=${domain}`);
|
|
17
|
+
}
|
|
18
|
+
if (secure === true) {
|
|
19
|
+
cookie.push("secure");
|
|
20
|
+
}
|
|
21
|
+
if (utils.isString(sameSite)) {
|
|
22
|
+
cookie.push(`SameSite=${sameSite}`);
|
|
23
|
+
}
|
|
24
|
+
document.cookie = cookie.join("; ");
|
|
25
|
+
},
|
|
26
|
+
read(name) {
|
|
27
|
+
if (typeof document === "undefined") return null;
|
|
28
|
+
const match = document.cookie.match(new RegExp("(?:^|; )" + name + "=([^;]*)"));
|
|
29
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
30
|
+
},
|
|
31
|
+
remove(name) {
|
|
32
|
+
this.write(name, "", Date.now() - 864e5, "/");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
) : (
|
|
36
|
+
// Non-standard browser env (web workers, react-native) lack needed support.
|
|
37
|
+
{
|
|
38
|
+
write() {
|
|
39
|
+
},
|
|
40
|
+
read() {
|
|
41
|
+
return null;
|
|
42
|
+
},
|
|
43
|
+
remove() {
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
export {
|
|
48
|
+
cookies as default
|
|
49
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import utils from "../../utils/index.es.js";
|
|
2
|
+
function parsePropPath(name) {
|
|
3
|
+
return utils.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
|
|
4
|
+
return match[0] === "[]" ? "" : match[1] || match[0];
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
function arrayToObject(arr) {
|
|
8
|
+
const obj = {};
|
|
9
|
+
const keys = Object.keys(arr);
|
|
10
|
+
let i;
|
|
11
|
+
const len = keys.length;
|
|
12
|
+
let key;
|
|
13
|
+
for (i = 0; i < len; i++) {
|
|
14
|
+
key = keys[i];
|
|
15
|
+
obj[key] = arr[key];
|
|
16
|
+
}
|
|
17
|
+
return obj;
|
|
18
|
+
}
|
|
19
|
+
function formDataToJSON(formData) {
|
|
20
|
+
function buildPath(path, value, target, index) {
|
|
21
|
+
let name = path[index++];
|
|
22
|
+
if (name === "__proto__") return true;
|
|
23
|
+
const isNumericKey = Number.isFinite(+name);
|
|
24
|
+
const isLast = index >= path.length;
|
|
25
|
+
name = !name && utils.isArray(target) ? target.length : name;
|
|
26
|
+
if (isLast) {
|
|
27
|
+
if (utils.hasOwnProp(target, name)) {
|
|
28
|
+
target[name] = [target[name], value];
|
|
29
|
+
} else {
|
|
30
|
+
target[name] = value;
|
|
31
|
+
}
|
|
32
|
+
return !isNumericKey;
|
|
33
|
+
}
|
|
34
|
+
if (!target[name] || !utils.isObject(target[name])) {
|
|
35
|
+
target[name] = [];
|
|
36
|
+
}
|
|
37
|
+
const result = buildPath(path, value, target[name], index);
|
|
38
|
+
if (result && utils.isArray(target[name])) {
|
|
39
|
+
target[name] = arrayToObject(target[name]);
|
|
40
|
+
}
|
|
41
|
+
return !isNumericKey;
|
|
42
|
+
}
|
|
43
|
+
if (utils.isFormData(formData) && utils.isFunction(formData.entries)) {
|
|
44
|
+
const obj = {};
|
|
45
|
+
utils.forEachEntry(formData, (name, value) => {
|
|
46
|
+
buildPath(parsePropPath(name), value, obj, 0);
|
|
47
|
+
});
|
|
48
|
+
return obj;
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
formDataToJSON as default
|
|
54
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import platform from "../../platform/index/index.es.js";
|
|
2
|
+
const isURLSameOrigin = platform.hasStandardBrowserEnv ? /* @__PURE__ */ ((origin, isMSIE) => (url) => {
|
|
3
|
+
url = new URL(url, platform.origin);
|
|
4
|
+
return origin.protocol === url.protocol && origin.host === url.host && (isMSIE || origin.port === url.port);
|
|
5
|
+
})(
|
|
6
|
+
new URL(platform.origin),
|
|
7
|
+
platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
|
|
8
|
+
) : () => true;
|
|
9
|
+
export {
|
|
10
|
+
isURLSameOrigin as default
|
|
11
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import utils from "../../utils/index.es.js";
|
|
2
|
+
const ignoreDuplicateOf = utils.toObjectSet([
|
|
3
|
+
"age",
|
|
4
|
+
"authorization",
|
|
5
|
+
"content-length",
|
|
6
|
+
"content-type",
|
|
7
|
+
"etag",
|
|
8
|
+
"expires",
|
|
9
|
+
"from",
|
|
10
|
+
"host",
|
|
11
|
+
"if-modified-since",
|
|
12
|
+
"if-unmodified-since",
|
|
13
|
+
"last-modified",
|
|
14
|
+
"location",
|
|
15
|
+
"max-forwards",
|
|
16
|
+
"proxy-authorization",
|
|
17
|
+
"referer",
|
|
18
|
+
"retry-after",
|
|
19
|
+
"user-agent"
|
|
20
|
+
]);
|
|
21
|
+
const parseHeaders = (rawHeaders) => {
|
|
22
|
+
const parsed = {};
|
|
23
|
+
let key;
|
|
24
|
+
let val;
|
|
25
|
+
let i;
|
|
26
|
+
rawHeaders && rawHeaders.split("\n").forEach(function parser(line) {
|
|
27
|
+
i = line.indexOf(":");
|
|
28
|
+
key = line.substring(0, i).trim().toLowerCase();
|
|
29
|
+
val = line.substring(i + 1).trim();
|
|
30
|
+
if (!key || parsed[key] && ignoreDuplicateOf[key]) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (key === "set-cookie") {
|
|
34
|
+
if (parsed[key]) {
|
|
35
|
+
parsed[key].push(val);
|
|
36
|
+
} else {
|
|
37
|
+
parsed[key] = [val];
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return parsed;
|
|
44
|
+
};
|
|
45
|
+
export {
|
|
46
|
+
parseHeaders as default
|
|
47
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import speedometer from "../speedometer/index.es.js";
|
|
2
|
+
import throttle from "../throttle/index.es.js";
|
|
3
|
+
import utils from "../../utils/index.es.js";
|
|
4
|
+
const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
5
|
+
let bytesNotified = 0;
|
|
6
|
+
const _speedometer = speedometer(50, 250);
|
|
7
|
+
return throttle((e) => {
|
|
8
|
+
const loaded = e.loaded;
|
|
9
|
+
const total = e.lengthComputable ? e.total : void 0;
|
|
10
|
+
const progressBytes = loaded - bytesNotified;
|
|
11
|
+
const rate = _speedometer(progressBytes);
|
|
12
|
+
const inRange = loaded <= total;
|
|
13
|
+
bytesNotified = loaded;
|
|
14
|
+
const data = {
|
|
15
|
+
loaded,
|
|
16
|
+
total,
|
|
17
|
+
progress: total ? loaded / total : void 0,
|
|
18
|
+
bytes: progressBytes,
|
|
19
|
+
rate: rate ? rate : void 0,
|
|
20
|
+
estimated: rate && total && inRange ? (total - loaded) / rate : void 0,
|
|
21
|
+
event: e,
|
|
22
|
+
lengthComputable: total != null,
|
|
23
|
+
[isDownloadStream ? "download" : "upload"]: true
|
|
24
|
+
};
|
|
25
|
+
listener(data);
|
|
26
|
+
}, freq);
|
|
27
|
+
};
|
|
28
|
+
const progressEventDecorator = (total, throttled) => {
|
|
29
|
+
const lengthComputable = total != null;
|
|
30
|
+
return [(loaded) => throttled[0]({
|
|
31
|
+
lengthComputable,
|
|
32
|
+
total,
|
|
33
|
+
loaded
|
|
34
|
+
}), throttled[1]];
|
|
35
|
+
};
|
|
36
|
+
const asyncDecorator = (fn) => (...args) => utils.asap(() => fn(...args));
|
|
37
|
+
export {
|
|
38
|
+
asyncDecorator,
|
|
39
|
+
progressEventDecorator,
|
|
40
|
+
progressEventReducer
|
|
41
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import platform from "../../platform/index/index.es.js";
|
|
2
|
+
import utils from "../../utils/index.es.js";
|
|
3
|
+
import isURLSameOrigin from "../isURLSameOrigin/index.es.js";
|
|
4
|
+
import cookies from "../cookies/index.es.js";
|
|
5
|
+
import buildFullPath from "../../core/buildFullPath/index.es.js";
|
|
6
|
+
import mergeConfig from "../../core/mergeConfig/index.es.js";
|
|
7
|
+
import AxiosHeaders from "../../core/AxiosHeaders/index.es.js";
|
|
8
|
+
import buildURL from "../buildURL/index.es.js";
|
|
9
|
+
const resolveConfig = (config) => {
|
|
10
|
+
const newConfig = mergeConfig({}, config);
|
|
11
|
+
let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
|
|
12
|
+
newConfig.headers = headers = AxiosHeaders.from(headers);
|
|
13
|
+
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
|
|
14
|
+
if (auth) {
|
|
15
|
+
headers.set(
|
|
16
|
+
"Authorization",
|
|
17
|
+
"Basic " + btoa((auth.username || "") + ":" + (auth.password ? unescape(encodeURIComponent(auth.password)) : ""))
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
if (utils.isFormData(data)) {
|
|
21
|
+
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
|
22
|
+
headers.setContentType(void 0);
|
|
23
|
+
} else if (utils.isFunction(data.getHeaders)) {
|
|
24
|
+
const formHeaders = data.getHeaders();
|
|
25
|
+
const allowedHeaders = ["content-type", "content-length"];
|
|
26
|
+
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
27
|
+
if (allowedHeaders.includes(key.toLowerCase())) {
|
|
28
|
+
headers.set(key, val);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (platform.hasStandardBrowserEnv) {
|
|
34
|
+
withXSRFToken && utils.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
|
|
35
|
+
if (withXSRFToken || withXSRFToken !== false && isURLSameOrigin(newConfig.url)) {
|
|
36
|
+
const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
|
|
37
|
+
if (xsrfValue) {
|
|
38
|
+
headers.set(xsrfHeaderName, xsrfValue);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return newConfig;
|
|
43
|
+
};
|
|
44
|
+
export {
|
|
45
|
+
resolveConfig as default
|
|
46
|
+
};
|