tp-react-elements-dev 1.14.14 → 1.15.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/_virtual/index.esm11.js +2 -2
- package/dist/_virtual/index.esm12.js +2 -2
- package/dist/_virtual/index.esm13.js +2 -2
- package/dist/_virtual/index.esm4.js +2 -2
- package/dist/_virtual/index.esm5.js +2 -2
- package/dist/_virtual/index.esm6.js +2 -2
- package/dist/_virtual/index.esm7.js +2 -2
- package/dist/components/Form/FormConstants.esm.js +6 -0
- package/dist/components/Form/FormRender.esm.js +3 -0
- package/dist/components/FormComponents/Select/SingleSelectSearchApi.d.ts +6 -2
- package/dist/components/FormComponents/Select/SingleSelectSearchApi.esm.js +82 -199
- package/dist/components/FormComponents/index.esm.js +2 -2
- package/dist/node_modules/axios/index.esm.js +25 -0
- package/dist/node_modules/axios/lib/adapters/adapters.esm.js +128 -0
- package/dist/node_modules/axios/lib/adapters/fetch.esm.js +288 -0
- package/dist/node_modules/axios/lib/adapters/xhr.esm.js +202 -0
- package/dist/node_modules/axios/lib/axios.esm.js +86 -0
- package/dist/node_modules/axios/lib/cancel/CancelToken.esm.js +133 -0
- package/dist/node_modules/axios/lib/cancel/CanceledError.esm.js +23 -0
- package/dist/node_modules/axios/lib/cancel/isCancel.esm.js +5 -0
- package/dist/node_modules/axios/lib/core/Axios.esm.js +236 -0
- package/dist/node_modules/axios/lib/core/AxiosError.esm.js +108 -0
- package/dist/node_modules/axios/lib/core/AxiosHeaders.esm.js +312 -0
- package/dist/node_modules/axios/lib/core/InterceptorManager.esm.js +69 -0
- package/dist/node_modules/axios/lib/core/buildFullPath.esm.js +22 -0
- package/dist/node_modules/axios/lib/core/dispatchRequest.esm.js +81 -0
- package/dist/node_modules/axios/lib/core/mergeConfig.esm.js +106 -0
- package/dist/node_modules/axios/lib/core/settle.esm.js +27 -0
- package/dist/node_modules/axios/lib/core/transformData.esm.js +28 -0
- package/dist/node_modules/axios/lib/defaults/index.esm.js +159 -0
- package/dist/node_modules/axios/lib/defaults/transitional.esm.js +7 -0
- package/dist/node_modules/axios/lib/env/data.esm.js +3 -0
- package/dist/node_modules/axios/lib/helpers/AxiosURLSearchParams.esm.js +56 -0
- package/dist/node_modules/axios/lib/helpers/HttpStatusCode.esm.js +77 -0
- package/dist/node_modules/axios/lib/helpers/bind.esm.js +14 -0
- package/dist/node_modules/axios/lib/helpers/buildURL.esm.js +67 -0
- package/dist/node_modules/axios/lib/helpers/combineURLs.esm.js +15 -0
- package/dist/node_modules/axios/lib/helpers/composeSignals.esm.js +48 -0
- package/dist/node_modules/axios/lib/helpers/cookies.esm.js +54 -0
- package/dist/node_modules/axios/lib/helpers/formDataToJSON.esm.js +93 -0
- package/dist/node_modules/axios/lib/helpers/isAbsoluteURL.esm.js +15 -0
- package/dist/node_modules/axios/lib/helpers/isAxiosError.esm.js +14 -0
- package/dist/node_modules/axios/lib/helpers/isURLSameOrigin.esm.js +16 -0
- package/dist/node_modules/axios/lib/helpers/null.esm.js +4 -0
- package/dist/node_modules/axios/lib/helpers/parseHeaders.esm.js +55 -0
- package/dist/node_modules/axios/lib/helpers/parseProtocol.esm.js +6 -0
- package/dist/node_modules/axios/lib/helpers/progressEventReducer.esm.js +46 -0
- package/dist/node_modules/axios/lib/helpers/resolveConfig.esm.js +62 -0
- package/dist/node_modules/axios/lib/helpers/speedometer.esm.js +53 -0
- package/dist/node_modules/axios/lib/helpers/spread.esm.js +28 -0
- package/dist/node_modules/axios/lib/helpers/throttle.esm.js +44 -0
- package/dist/node_modules/axios/lib/helpers/toFormData.esm.js +219 -0
- package/dist/node_modules/axios/lib/helpers/toURLEncodedForm.esm.js +19 -0
- package/dist/node_modules/axios/lib/helpers/trackStream.esm.js +88 -0
- package/dist/node_modules/axios/lib/helpers/validator.esm.js +99 -0
- package/dist/node_modules/axios/lib/platform/browser/classes/Blob.esm.js +3 -0
- package/dist/node_modules/axios/lib/platform/browser/classes/FormData.esm.js +3 -0
- package/dist/node_modules/axios/lib/platform/browser/classes/URLSearchParams.esm.js +5 -0
- package/dist/node_modules/axios/lib/platform/browser/index.esm.js +15 -0
- package/dist/node_modules/axios/lib/platform/common/utils.esm.js +45 -0
- package/dist/node_modules/axios/lib/platform/index.esm.js +9 -0
- package/dist/node_modules/axios/lib/utils.esm.js +782 -0
- package/dist/node_modules/react-date-range/dist/components/Calendar/index.esm.js +1 -1
- package/dist/node_modules/react-date-range/dist/components/DateInput/index.esm.js +1 -1
- package/dist/node_modules/react-date-range/dist/components/DateRange/index.esm.js +1 -1
- package/dist/node_modules/react-date-range/dist/components/DateRangePicker/index.esm.js +1 -1
- package/dist/node_modules/react-date-range/dist/components/DayCell/index.esm.js +1 -1
- package/dist/node_modules/react-date-range/dist/components/DefinedRange/index.esm.js +1 -1
- package/dist/node_modules/react-date-range/dist/components/InputRangeField/index.esm.js +1 -1
- package/dist/utils/Interface/FormInterface.d.ts +7 -1
- package/package.json +2 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import utils from '../utils.esm.js';
|
|
2
|
+
import AxiosURLSearchParams from './AxiosURLSearchParams.esm.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
|
|
6
|
+
* URI encoded counterparts
|
|
7
|
+
*
|
|
8
|
+
* @param {string} val The value to be encoded.
|
|
9
|
+
*
|
|
10
|
+
* @returns {string} The encoded value.
|
|
11
|
+
*/
|
|
12
|
+
function encode(val) {
|
|
13
|
+
return encodeURIComponent(val).
|
|
14
|
+
replace(/%3A/gi, ':').
|
|
15
|
+
replace(/%24/g, '$').
|
|
16
|
+
replace(/%2C/gi, ',').
|
|
17
|
+
replace(/%20/g, '+');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Build a URL by appending params to the end
|
|
22
|
+
*
|
|
23
|
+
* @param {string} url The base of the url (e.g., http://www.google.com)
|
|
24
|
+
* @param {object} [params] The params to be appended
|
|
25
|
+
* @param {?(object|Function)} options
|
|
26
|
+
*
|
|
27
|
+
* @returns {string} The formatted url
|
|
28
|
+
*/
|
|
29
|
+
function buildURL(url, params, options) {
|
|
30
|
+
/*eslint no-param-reassign:0*/
|
|
31
|
+
if (!params) {
|
|
32
|
+
return url;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const _encode = options && options.encode || encode;
|
|
36
|
+
|
|
37
|
+
if (utils.isFunction(options)) {
|
|
38
|
+
options = {
|
|
39
|
+
serialize: options
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const serializeFn = options && options.serialize;
|
|
44
|
+
|
|
45
|
+
let serializedParams;
|
|
46
|
+
|
|
47
|
+
if (serializeFn) {
|
|
48
|
+
serializedParams = serializeFn(params, options);
|
|
49
|
+
} else {
|
|
50
|
+
serializedParams = utils.isURLSearchParams(params) ?
|
|
51
|
+
params.toString() :
|
|
52
|
+
new AxiosURLSearchParams(params, options).toString(_encode);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (serializedParams) {
|
|
56
|
+
const hashmarkIndex = url.indexOf("#");
|
|
57
|
+
|
|
58
|
+
if (hashmarkIndex !== -1) {
|
|
59
|
+
url = url.slice(0, hashmarkIndex);
|
|
60
|
+
}
|
|
61
|
+
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return url;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { buildURL as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new URL by combining the specified URLs
|
|
3
|
+
*
|
|
4
|
+
* @param {string} baseURL The base URL
|
|
5
|
+
* @param {string} relativeURL The relative URL
|
|
6
|
+
*
|
|
7
|
+
* @returns {string} The combined URL
|
|
8
|
+
*/
|
|
9
|
+
function combineURLs(baseURL, relativeURL) {
|
|
10
|
+
return relativeURL
|
|
11
|
+
? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
|
12
|
+
: baseURL;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { combineURLs as default };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import CanceledError from '../cancel/CanceledError.esm.js';
|
|
2
|
+
import AxiosError from '../core/AxiosError.esm.js';
|
|
3
|
+
import utils from '../utils.esm.js';
|
|
4
|
+
|
|
5
|
+
const composeSignals = (signals, timeout) => {
|
|
6
|
+
const {length} = (signals = signals ? signals.filter(Boolean) : []);
|
|
7
|
+
|
|
8
|
+
if (timeout || length) {
|
|
9
|
+
let controller = new AbortController();
|
|
10
|
+
|
|
11
|
+
let aborted;
|
|
12
|
+
|
|
13
|
+
const onabort = function (reason) {
|
|
14
|
+
if (!aborted) {
|
|
15
|
+
aborted = true;
|
|
16
|
+
unsubscribe();
|
|
17
|
+
const err = reason instanceof Error ? reason : this.reason;
|
|
18
|
+
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
let timer = timeout && setTimeout(() => {
|
|
23
|
+
timer = null;
|
|
24
|
+
onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
|
|
25
|
+
}, timeout);
|
|
26
|
+
|
|
27
|
+
const unsubscribe = () => {
|
|
28
|
+
if (signals) {
|
|
29
|
+
timer && clearTimeout(timer);
|
|
30
|
+
timer = null;
|
|
31
|
+
signals.forEach(signal => {
|
|
32
|
+
signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
|
|
33
|
+
});
|
|
34
|
+
signals = null;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
|
39
|
+
|
|
40
|
+
const {signal} = controller;
|
|
41
|
+
|
|
42
|
+
signal.unsubscribe = () => utils.asap(unsubscribe);
|
|
43
|
+
|
|
44
|
+
return signal;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { composeSignals as default };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import utils from '../utils.esm.js';
|
|
2
|
+
import platform from '../platform/index.esm.js';
|
|
3
|
+
|
|
4
|
+
var cookies = platform.hasStandardBrowserEnv ?
|
|
5
|
+
|
|
6
|
+
// Standard browser envs support document.cookie
|
|
7
|
+
{
|
|
8
|
+
write(name, value, expires, path, domain, secure, sameSite) {
|
|
9
|
+
if (typeof document === 'undefined') return;
|
|
10
|
+
|
|
11
|
+
const cookie = [`${name}=${encodeURIComponent(value)}`];
|
|
12
|
+
|
|
13
|
+
if (utils.isNumber(expires)) {
|
|
14
|
+
cookie.push(`expires=${new Date(expires).toUTCString()}`);
|
|
15
|
+
}
|
|
16
|
+
if (utils.isString(path)) {
|
|
17
|
+
cookie.push(`path=${path}`);
|
|
18
|
+
}
|
|
19
|
+
if (utils.isString(domain)) {
|
|
20
|
+
cookie.push(`domain=${domain}`);
|
|
21
|
+
}
|
|
22
|
+
if (secure === true) {
|
|
23
|
+
cookie.push('secure');
|
|
24
|
+
}
|
|
25
|
+
if (utils.isString(sameSite)) {
|
|
26
|
+
cookie.push(`SameSite=${sameSite}`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
document.cookie = cookie.join('; ');
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
read(name) {
|
|
33
|
+
if (typeof document === 'undefined') return null;
|
|
34
|
+
const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
|
|
35
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
remove(name) {
|
|
39
|
+
this.write(name, '', Date.now() - 86400000, '/');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
:
|
|
44
|
+
|
|
45
|
+
// Non-standard browser env (web workers, react-native) lack needed support.
|
|
46
|
+
{
|
|
47
|
+
write() {},
|
|
48
|
+
read() {
|
|
49
|
+
return null;
|
|
50
|
+
},
|
|
51
|
+
remove() {}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export { cookies as default };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import utils from '../utils.esm.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
|
|
5
|
+
*
|
|
6
|
+
* @param {string} name - The name of the property to get.
|
|
7
|
+
*
|
|
8
|
+
* @returns An array of strings.
|
|
9
|
+
*/
|
|
10
|
+
function parsePropPath(name) {
|
|
11
|
+
// foo[x][y][z]
|
|
12
|
+
// foo.x.y.z
|
|
13
|
+
// foo-x-y-z
|
|
14
|
+
// foo x y z
|
|
15
|
+
return utils.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
|
|
16
|
+
return match[0] === '[]' ? '' : match[1] || match[0];
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Convert an array to an object.
|
|
22
|
+
*
|
|
23
|
+
* @param {Array<any>} arr - The array to convert to an object.
|
|
24
|
+
*
|
|
25
|
+
* @returns An object with the same keys and values as the array.
|
|
26
|
+
*/
|
|
27
|
+
function arrayToObject(arr) {
|
|
28
|
+
const obj = {};
|
|
29
|
+
const keys = Object.keys(arr);
|
|
30
|
+
let i;
|
|
31
|
+
const len = keys.length;
|
|
32
|
+
let key;
|
|
33
|
+
for (i = 0; i < len; i++) {
|
|
34
|
+
key = keys[i];
|
|
35
|
+
obj[key] = arr[key];
|
|
36
|
+
}
|
|
37
|
+
return obj;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* It takes a FormData object and returns a JavaScript object
|
|
42
|
+
*
|
|
43
|
+
* @param {string} formData The FormData object to convert to JSON.
|
|
44
|
+
*
|
|
45
|
+
* @returns {Object<string, any> | null} The converted object.
|
|
46
|
+
*/
|
|
47
|
+
function formDataToJSON(formData) {
|
|
48
|
+
function buildPath(path, value, target, index) {
|
|
49
|
+
let name = path[index++];
|
|
50
|
+
|
|
51
|
+
if (name === '__proto__') return true;
|
|
52
|
+
|
|
53
|
+
const isNumericKey = Number.isFinite(+name);
|
|
54
|
+
const isLast = index >= path.length;
|
|
55
|
+
name = !name && utils.isArray(target) ? target.length : name;
|
|
56
|
+
|
|
57
|
+
if (isLast) {
|
|
58
|
+
if (utils.hasOwnProp(target, name)) {
|
|
59
|
+
target[name] = [target[name], value];
|
|
60
|
+
} else {
|
|
61
|
+
target[name] = value;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return !isNumericKey;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (!target[name] || !utils.isObject(target[name])) {
|
|
68
|
+
target[name] = [];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const result = buildPath(path, value, target[name], index);
|
|
72
|
+
|
|
73
|
+
if (result && utils.isArray(target[name])) {
|
|
74
|
+
target[name] = arrayToObject(target[name]);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return !isNumericKey;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (utils.isFormData(formData) && utils.isFunction(formData.entries)) {
|
|
81
|
+
const obj = {};
|
|
82
|
+
|
|
83
|
+
utils.forEachEntry(formData, (name, value) => {
|
|
84
|
+
buildPath(parsePropPath(name), value, obj, 0);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return obj;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export { formDataToJSON as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines whether the specified URL is absolute
|
|
3
|
+
*
|
|
4
|
+
* @param {string} url The URL to test
|
|
5
|
+
*
|
|
6
|
+
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
|
7
|
+
*/
|
|
8
|
+
function isAbsoluteURL(url) {
|
|
9
|
+
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
|
10
|
+
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
|
11
|
+
// by any combination of letters, digits, plus, period, or hyphen.
|
|
12
|
+
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { isAbsoluteURL as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import utils from '../utils.esm.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Determines whether the payload is an error thrown by Axios
|
|
5
|
+
*
|
|
6
|
+
* @param {*} payload The value to test
|
|
7
|
+
*
|
|
8
|
+
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
|
9
|
+
*/
|
|
10
|
+
function isAxiosError(payload) {
|
|
11
|
+
return utils.isObject(payload) && (payload.isAxiosError === true);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { isAxiosError as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import platform from '../platform/index.esm.js';
|
|
2
|
+
|
|
3
|
+
var isURLSameOrigin = platform.hasStandardBrowserEnv ? ((origin, isMSIE) => (url) => {
|
|
4
|
+
url = new URL(url, platform.origin);
|
|
5
|
+
|
|
6
|
+
return (
|
|
7
|
+
origin.protocol === url.protocol &&
|
|
8
|
+
origin.host === url.host &&
|
|
9
|
+
(isMSIE || origin.port === url.port)
|
|
10
|
+
);
|
|
11
|
+
})(
|
|
12
|
+
new URL(platform.origin),
|
|
13
|
+
platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
|
|
14
|
+
) : () => true;
|
|
15
|
+
|
|
16
|
+
export { isURLSameOrigin as default };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import utils from '../utils.esm.js';
|
|
2
|
+
|
|
3
|
+
// RawAxiosHeaders whose duplicates are ignored by node
|
|
4
|
+
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
5
|
+
const ignoreDuplicateOf = utils.toObjectSet([
|
|
6
|
+
'age', 'authorization', 'content-length', 'content-type', 'etag',
|
|
7
|
+
'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
|
|
8
|
+
'last-modified', 'location', 'max-forwards', 'proxy-authorization',
|
|
9
|
+
'referer', 'retry-after', 'user-agent'
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Parse headers into an object
|
|
14
|
+
*
|
|
15
|
+
* ```
|
|
16
|
+
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
|
17
|
+
* Content-Type: application/json
|
|
18
|
+
* Connection: keep-alive
|
|
19
|
+
* Transfer-Encoding: chunked
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @param {String} rawHeaders Headers needing to be parsed
|
|
23
|
+
*
|
|
24
|
+
* @returns {Object} Headers parsed into an object
|
|
25
|
+
*/
|
|
26
|
+
var parseHeaders = rawHeaders => {
|
|
27
|
+
const parsed = {};
|
|
28
|
+
let key;
|
|
29
|
+
let val;
|
|
30
|
+
let i;
|
|
31
|
+
|
|
32
|
+
rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
|
|
33
|
+
i = line.indexOf(':');
|
|
34
|
+
key = line.substring(0, i).trim().toLowerCase();
|
|
35
|
+
val = line.substring(i + 1).trim();
|
|
36
|
+
|
|
37
|
+
if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (key === 'set-cookie') {
|
|
42
|
+
if (parsed[key]) {
|
|
43
|
+
parsed[key].push(val);
|
|
44
|
+
} else {
|
|
45
|
+
parsed[key] = [val];
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return parsed;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export { parseHeaders as default };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import speedometer from './speedometer.esm.js';
|
|
2
|
+
import throttle from './throttle.esm.js';
|
|
3
|
+
import utils from '../utils.esm.js';
|
|
4
|
+
|
|
5
|
+
const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
6
|
+
let bytesNotified = 0;
|
|
7
|
+
const _speedometer = speedometer(50, 250);
|
|
8
|
+
|
|
9
|
+
return throttle(e => {
|
|
10
|
+
const loaded = e.loaded;
|
|
11
|
+
const total = e.lengthComputable ? e.total : undefined;
|
|
12
|
+
const progressBytes = loaded - bytesNotified;
|
|
13
|
+
const rate = _speedometer(progressBytes);
|
|
14
|
+
const inRange = loaded <= total;
|
|
15
|
+
|
|
16
|
+
bytesNotified = loaded;
|
|
17
|
+
|
|
18
|
+
const data = {
|
|
19
|
+
loaded,
|
|
20
|
+
total,
|
|
21
|
+
progress: total ? (loaded / total) : undefined,
|
|
22
|
+
bytes: progressBytes,
|
|
23
|
+
rate: rate ? rate : undefined,
|
|
24
|
+
estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
|
|
25
|
+
event: e,
|
|
26
|
+
lengthComputable: total != null,
|
|
27
|
+
[isDownloadStream ? 'download' : 'upload']: true
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
listener(data);
|
|
31
|
+
}, freq);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const progressEventDecorator = (total, throttled) => {
|
|
35
|
+
const lengthComputable = total != null;
|
|
36
|
+
|
|
37
|
+
return [(loaded) => throttled[0]({
|
|
38
|
+
lengthComputable,
|
|
39
|
+
total,
|
|
40
|
+
loaded
|
|
41
|
+
}), throttled[1]];
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const asyncDecorator = (fn) => (...args) => utils.asap(() => fn(...args));
|
|
45
|
+
|
|
46
|
+
export { asyncDecorator, progressEventDecorator, progressEventReducer };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import platform from '../platform/index.esm.js';
|
|
2
|
+
import utils from '../utils.esm.js';
|
|
3
|
+
import isURLSameOrigin from './isURLSameOrigin.esm.js';
|
|
4
|
+
import cookies from './cookies.esm.js';
|
|
5
|
+
import buildFullPath from '../core/buildFullPath.esm.js';
|
|
6
|
+
import mergeConfig from '../core/mergeConfig.esm.js';
|
|
7
|
+
import AxiosHeaders from '../core/AxiosHeaders.esm.js';
|
|
8
|
+
import buildURL from './buildURL.esm.js';
|
|
9
|
+
|
|
10
|
+
var resolveConfig = (config) => {
|
|
11
|
+
const newConfig = mergeConfig({}, config);
|
|
12
|
+
|
|
13
|
+
let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
|
|
14
|
+
|
|
15
|
+
newConfig.headers = headers = AxiosHeaders.from(headers);
|
|
16
|
+
|
|
17
|
+
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
|
|
18
|
+
|
|
19
|
+
// HTTP basic authentication
|
|
20
|
+
if (auth) {
|
|
21
|
+
headers.set('Authorization', 'Basic ' +
|
|
22
|
+
btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : ''))
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (utils.isFormData(data)) {
|
|
27
|
+
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
|
28
|
+
headers.setContentType(undefined); // browser handles it
|
|
29
|
+
} else if (utils.isFunction(data.getHeaders)) {
|
|
30
|
+
// Node.js FormData (like form-data package)
|
|
31
|
+
const formHeaders = data.getHeaders();
|
|
32
|
+
// Only set safe headers to avoid overwriting security headers
|
|
33
|
+
const allowedHeaders = ['content-type', 'content-length'];
|
|
34
|
+
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
35
|
+
if (allowedHeaders.includes(key.toLowerCase())) {
|
|
36
|
+
headers.set(key, val);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Add xsrf header
|
|
43
|
+
// This is only done if running in a standard browser environment.
|
|
44
|
+
// Specifically not if we're in a web worker, or react-native.
|
|
45
|
+
|
|
46
|
+
if (platform.hasStandardBrowserEnv) {
|
|
47
|
+
withXSRFToken && utils.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
|
|
48
|
+
|
|
49
|
+
if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
|
|
50
|
+
// Add xsrf header
|
|
51
|
+
const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
|
|
52
|
+
|
|
53
|
+
if (xsrfValue) {
|
|
54
|
+
headers.set(xsrfHeaderName, xsrfValue);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return newConfig;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export { resolveConfig as default };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculate data maxRate
|
|
3
|
+
* @param {Number} [samplesCount= 10]
|
|
4
|
+
* @param {Number} [min= 1000]
|
|
5
|
+
* @returns {Function}
|
|
6
|
+
*/
|
|
7
|
+
function speedometer(samplesCount, min) {
|
|
8
|
+
samplesCount = samplesCount || 10;
|
|
9
|
+
const bytes = new Array(samplesCount);
|
|
10
|
+
const timestamps = new Array(samplesCount);
|
|
11
|
+
let head = 0;
|
|
12
|
+
let tail = 0;
|
|
13
|
+
let firstSampleTS;
|
|
14
|
+
|
|
15
|
+
min = min !== undefined ? min : 1000;
|
|
16
|
+
|
|
17
|
+
return function push(chunkLength) {
|
|
18
|
+
const now = Date.now();
|
|
19
|
+
|
|
20
|
+
const startedAt = timestamps[tail];
|
|
21
|
+
|
|
22
|
+
if (!firstSampleTS) {
|
|
23
|
+
firstSampleTS = now;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
bytes[head] = chunkLength;
|
|
27
|
+
timestamps[head] = now;
|
|
28
|
+
|
|
29
|
+
let i = tail;
|
|
30
|
+
let bytesCount = 0;
|
|
31
|
+
|
|
32
|
+
while (i !== head) {
|
|
33
|
+
bytesCount += bytes[i++];
|
|
34
|
+
i = i % samplesCount;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
head = (head + 1) % samplesCount;
|
|
38
|
+
|
|
39
|
+
if (head === tail) {
|
|
40
|
+
tail = (tail + 1) % samplesCount;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (now - firstSampleTS < min) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const passed = startedAt && now - startedAt;
|
|
48
|
+
|
|
49
|
+
return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { speedometer as default };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Syntactic sugar for invoking a function and expanding an array for arguments.
|
|
3
|
+
*
|
|
4
|
+
* Common use case would be to use `Function.prototype.apply`.
|
|
5
|
+
*
|
|
6
|
+
* ```js
|
|
7
|
+
* function f(x, y, z) {}
|
|
8
|
+
* var args = [1, 2, 3];
|
|
9
|
+
* f.apply(null, args);
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* With `spread` this example can be re-written.
|
|
13
|
+
*
|
|
14
|
+
* ```js
|
|
15
|
+
* spread(function(x, y, z) {})([1, 2, 3]);
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @param {Function} callback
|
|
19
|
+
*
|
|
20
|
+
* @returns {Function}
|
|
21
|
+
*/
|
|
22
|
+
function spread(callback) {
|
|
23
|
+
return function wrap(arr) {
|
|
24
|
+
return callback.apply(null, arr);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { spread as default };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throttle decorator
|
|
3
|
+
* @param {Function} fn
|
|
4
|
+
* @param {Number} freq
|
|
5
|
+
* @return {Function}
|
|
6
|
+
*/
|
|
7
|
+
function throttle(fn, freq) {
|
|
8
|
+
let timestamp = 0;
|
|
9
|
+
let threshold = 1000 / freq;
|
|
10
|
+
let lastArgs;
|
|
11
|
+
let timer;
|
|
12
|
+
|
|
13
|
+
const invoke = (args, now = Date.now()) => {
|
|
14
|
+
timestamp = now;
|
|
15
|
+
lastArgs = null;
|
|
16
|
+
if (timer) {
|
|
17
|
+
clearTimeout(timer);
|
|
18
|
+
timer = null;
|
|
19
|
+
}
|
|
20
|
+
fn(...args);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const throttled = (...args) => {
|
|
24
|
+
const now = Date.now();
|
|
25
|
+
const passed = now - timestamp;
|
|
26
|
+
if ( passed >= threshold) {
|
|
27
|
+
invoke(args, now);
|
|
28
|
+
} else {
|
|
29
|
+
lastArgs = args;
|
|
30
|
+
if (!timer) {
|
|
31
|
+
timer = setTimeout(() => {
|
|
32
|
+
timer = null;
|
|
33
|
+
invoke(lastArgs);
|
|
34
|
+
}, threshold - passed);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const flush = () => lastArgs && invoke(lastArgs);
|
|
40
|
+
|
|
41
|
+
return [throttled, flush];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { throttle as default };
|