Framework updates
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
9
node_modules/axios/lib/adapters/README.md
generated
vendored
9
node_modules/axios/lib/adapters/README.md
generated
vendored
@@ -12,19 +12,18 @@ module.exports = function myAdapter(config) {
|
||||
// - config has been merged with defaults
|
||||
// - request transformers have already run
|
||||
// - request interceptors have already run
|
||||
|
||||
|
||||
// Make the request using config provided
|
||||
// Upon response settle the Promise
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
var response = {
|
||||
data: responseData,
|
||||
status: request.status,
|
||||
statusText: request.statusText,
|
||||
headers: responseHeaders,
|
||||
config: config,
|
||||
request: request
|
||||
request: request,
|
||||
};
|
||||
|
||||
settle(resolve, reject, response);
|
||||
@@ -33,5 +32,5 @@ module.exports = function myAdapter(config) {
|
||||
// - response transformers will run
|
||||
// - response interceptors will run
|
||||
});
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
32
node_modules/axios/lib/adapters/adapters.js
generated
vendored
32
node_modules/axios/lib/adapters/adapters.js
generated
vendored
@@ -2,7 +2,7 @@ import utils from '../utils.js';
|
||||
import httpAdapter from './http.js';
|
||||
import xhrAdapter from './xhr.js';
|
||||
import * as fetchAdapter from './fetch.js';
|
||||
import AxiosError from "../core/AxiosError.js";
|
||||
import AxiosError from '../core/AxiosError.js';
|
||||
|
||||
/**
|
||||
* Known adapters mapping.
|
||||
@@ -10,7 +10,7 @@ import AxiosError from "../core/AxiosError.js";
|
||||
* - `http` for Node.js
|
||||
* - `xhr` for browsers
|
||||
* - `fetch` for fetch API-based requests
|
||||
*
|
||||
*
|
||||
* @type {Object<string, Function|Object>}
|
||||
*/
|
||||
const knownAdapters = {
|
||||
@@ -18,7 +18,7 @@ const knownAdapters = {
|
||||
xhr: xhrAdapter,
|
||||
fetch: {
|
||||
get: fetchAdapter.getFetch,
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
// Assign adapter names for easier debugging and identification
|
||||
@@ -35,7 +35,7 @@ utils.forEach(knownAdapters, (fn, value) => {
|
||||
|
||||
/**
|
||||
* Render a rejection reason string for unknown or unsupported adapters
|
||||
*
|
||||
*
|
||||
* @param {string} reason
|
||||
* @returns {string}
|
||||
*/
|
||||
@@ -43,17 +43,18 @@ const renderReason = (reason) => `- ${reason}`;
|
||||
|
||||
/**
|
||||
* Check if the adapter is resolved (function, null, or false)
|
||||
*
|
||||
*
|
||||
* @param {Function|null|false} adapter
|
||||
* @returns {boolean}
|
||||
*/
|
||||
const isResolvedHandle = (adapter) => utils.isFunction(adapter) || adapter === null || adapter === false;
|
||||
const isResolvedHandle = (adapter) =>
|
||||
utils.isFunction(adapter) || adapter === null || adapter === false;
|
||||
|
||||
/**
|
||||
* Get the first suitable adapter from the provided list.
|
||||
* Tries each adapter in order until a supported one is found.
|
||||
* Throws an AxiosError if no adapter is suitable.
|
||||
*
|
||||
*
|
||||
* @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
|
||||
* @param {Object} config - Axios request configuration
|
||||
* @throws {AxiosError} If no suitable adapter is available
|
||||
@@ -90,14 +91,17 @@ function getAdapter(adapters, config) {
|
||||
}
|
||||
|
||||
if (!adapter) {
|
||||
const reasons = Object.entries(rejectedReasons)
|
||||
.map(([id, state]) => `adapter ${id} ` +
|
||||
const reasons = Object.entries(rejectedReasons).map(
|
||||
([id, state]) =>
|
||||
`adapter ${id} ` +
|
||||
(state === false ? 'is not supported by the environment' : 'is not available in the build')
|
||||
);
|
||||
);
|
||||
|
||||
let s = length ?
|
||||
(reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
|
||||
'as no adapter specified';
|
||||
let s = length
|
||||
? reasons.length > 1
|
||||
? 'since :\n' + reasons.map(renderReason).join('\n')
|
||||
: ' ' + renderReason(reasons[0])
|
||||
: 'as no adapter specified';
|
||||
|
||||
throw new AxiosError(
|
||||
`There is no suitable adapter to dispatch the request ` + s,
|
||||
@@ -122,5 +126,5 @@ export default {
|
||||
* Exposes all known adapters
|
||||
* @type {Object<string, Function|Object>}
|
||||
*/
|
||||
adapters: knownAdapters
|
||||
adapters: knownAdapters,
|
||||
};
|
||||
|
||||
220
node_modules/axios/lib/adapters/fetch.js
generated
vendored
220
node_modules/axios/lib/adapters/fetch.js
generated
vendored
@@ -1,40 +1,46 @@
|
||||
import platform from "../platform/index.js";
|
||||
import utils from "../utils.js";
|
||||
import AxiosError from "../core/AxiosError.js";
|
||||
import composeSignals from "../helpers/composeSignals.js";
|
||||
import {trackStream} from "../helpers/trackStream.js";
|
||||
import AxiosHeaders from "../core/AxiosHeaders.js";
|
||||
import {progressEventReducer, progressEventDecorator, asyncDecorator} from "../helpers/progressEventReducer.js";
|
||||
import resolveConfig from "../helpers/resolveConfig.js";
|
||||
import settle from "../core/settle.js";
|
||||
import platform from '../platform/index.js';
|
||||
import utils from '../utils.js';
|
||||
import AxiosError from '../core/AxiosError.js';
|
||||
import composeSignals from '../helpers/composeSignals.js';
|
||||
import { trackStream } from '../helpers/trackStream.js';
|
||||
import AxiosHeaders from '../core/AxiosHeaders.js';
|
||||
import {
|
||||
progressEventReducer,
|
||||
progressEventDecorator,
|
||||
asyncDecorator,
|
||||
} from '../helpers/progressEventReducer.js';
|
||||
import resolveConfig from '../helpers/resolveConfig.js';
|
||||
import settle from '../core/settle.js';
|
||||
|
||||
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
||||
|
||||
const {isFunction} = utils;
|
||||
const { isFunction } = utils;
|
||||
|
||||
const globalFetchAPI = (({Request, Response}) => ({
|
||||
Request, Response
|
||||
const globalFetchAPI = (({ Request, Response }) => ({
|
||||
Request,
|
||||
Response,
|
||||
}))(utils.global);
|
||||
|
||||
const {
|
||||
ReadableStream, TextEncoder
|
||||
} = utils.global;
|
||||
|
||||
const { ReadableStream, TextEncoder } = utils.global;
|
||||
|
||||
const test = (fn, ...args) => {
|
||||
try {
|
||||
return !!fn(...args);
|
||||
} catch (e) {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const factory = (env) => {
|
||||
env = utils.merge.call({
|
||||
skipUndefined: true
|
||||
}, globalFetchAPI, env);
|
||||
env = utils.merge.call(
|
||||
{
|
||||
skipUndefined: true,
|
||||
},
|
||||
globalFetchAPI,
|
||||
env
|
||||
);
|
||||
|
||||
const {fetch: envFetch, Request, Response} = env;
|
||||
const { fetch: envFetch, Request, Response } = env;
|
||||
const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
|
||||
const isRequestSupported = isFunction(Request);
|
||||
const isResponseSupported = isFunction(Response);
|
||||
@@ -45,46 +51,61 @@ const factory = (env) => {
|
||||
|
||||
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream);
|
||||
|
||||
const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
|
||||
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
||||
async (str) => new Uint8Array(await new Request(str).arrayBuffer())
|
||||
);
|
||||
const encodeText =
|
||||
isFetchSupported &&
|
||||
(typeof TextEncoder === 'function'
|
||||
? (
|
||||
(encoder) => (str) =>
|
||||
encoder.encode(str)
|
||||
)(new TextEncoder())
|
||||
: async (str) => new Uint8Array(await new Request(str).arrayBuffer()));
|
||||
|
||||
const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
|
||||
let duplexAccessed = false;
|
||||
const supportsRequestStream =
|
||||
isRequestSupported &&
|
||||
isReadableStreamSupported &&
|
||||
test(() => {
|
||||
let duplexAccessed = false;
|
||||
|
||||
const hasContentType = new Request(platform.origin, {
|
||||
body: new ReadableStream(),
|
||||
method: 'POST',
|
||||
get duplex() {
|
||||
duplexAccessed = true;
|
||||
return 'half';
|
||||
},
|
||||
}).headers.has('Content-Type');
|
||||
const hasContentType = new Request(platform.origin, {
|
||||
body: new ReadableStream(),
|
||||
method: 'POST',
|
||||
get duplex() {
|
||||
duplexAccessed = true;
|
||||
return 'half';
|
||||
},
|
||||
}).headers.has('Content-Type');
|
||||
|
||||
return duplexAccessed && !hasContentType;
|
||||
});
|
||||
return duplexAccessed && !hasContentType;
|
||||
});
|
||||
|
||||
const supportsResponseStream = isResponseSupported && isReadableStreamSupported &&
|
||||
const supportsResponseStream =
|
||||
isResponseSupported &&
|
||||
isReadableStreamSupported &&
|
||||
test(() => utils.isReadableStream(new Response('').body));
|
||||
|
||||
const resolvers = {
|
||||
stream: supportsResponseStream && ((res) => res.body)
|
||||
stream: supportsResponseStream && ((res) => res.body),
|
||||
};
|
||||
|
||||
isFetchSupported && ((() => {
|
||||
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
||||
!resolvers[type] && (resolvers[type] = (res, config) => {
|
||||
let method = res && res[type];
|
||||
isFetchSupported &&
|
||||
(() => {
|
||||
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach((type) => {
|
||||
!resolvers[type] &&
|
||||
(resolvers[type] = (res, config) => {
|
||||
let method = res && res[type];
|
||||
|
||||
if (method) {
|
||||
return method.call(res);
|
||||
}
|
||||
if (method) {
|
||||
return method.call(res);
|
||||
}
|
||||
|
||||
throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
|
||||
})
|
||||
});
|
||||
})());
|
||||
throw new AxiosError(
|
||||
`Response type '${type}' is not supported`,
|
||||
AxiosError.ERR_NOT_SUPPORT,
|
||||
config
|
||||
);
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
||||
const getBodyLength = async (body) => {
|
||||
if (body == null) {
|
||||
@@ -114,13 +135,13 @@ const factory = (env) => {
|
||||
if (utils.isString(body)) {
|
||||
return (await encodeText(body)).byteLength;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const resolveBodyLength = async (headers, body) => {
|
||||
const length = utils.toFiniteNumber(headers.getContentLength());
|
||||
|
||||
return length == null ? getBodyLength(body) : length;
|
||||
}
|
||||
};
|
||||
|
||||
return async (config) => {
|
||||
let {
|
||||
@@ -135,38 +156,47 @@ const factory = (env) => {
|
||||
responseType,
|
||||
headers,
|
||||
withCredentials = 'same-origin',
|
||||
fetchOptions
|
||||
fetchOptions,
|
||||
} = resolveConfig(config);
|
||||
|
||||
let _fetch = envFetch || fetch;
|
||||
|
||||
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
||||
|
||||
let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
||||
let composedSignal = composeSignals(
|
||||
[signal, cancelToken && cancelToken.toAbortSignal()],
|
||||
timeout
|
||||
);
|
||||
|
||||
let request = null;
|
||||
|
||||
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
||||
composedSignal.unsubscribe();
|
||||
});
|
||||
const unsubscribe =
|
||||
composedSignal &&
|
||||
composedSignal.unsubscribe &&
|
||||
(() => {
|
||||
composedSignal.unsubscribe();
|
||||
});
|
||||
|
||||
let requestContentLength;
|
||||
|
||||
try {
|
||||
if (
|
||||
onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
|
||||
onUploadProgress &&
|
||||
supportsRequestStream &&
|
||||
method !== 'get' &&
|
||||
method !== 'head' &&
|
||||
(requestContentLength = await resolveBodyLength(headers, data)) !== 0
|
||||
) {
|
||||
let _request = new Request(url, {
|
||||
method: 'POST',
|
||||
body: data,
|
||||
duplex: "half"
|
||||
duplex: 'half',
|
||||
});
|
||||
|
||||
let contentTypeHeader;
|
||||
|
||||
if (utils.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
|
||||
headers.setContentType(contentTypeHeader)
|
||||
headers.setContentType(contentTypeHeader);
|
||||
}
|
||||
|
||||
if (_request.body) {
|
||||
@@ -185,7 +215,7 @@ const factory = (env) => {
|
||||
|
||||
// Cloudflare Workers throws when credentials are defined
|
||||
// see https://github.com/cloudflare/workerd/issues/902
|
||||
const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
|
||||
const isCredentialsSupported = isRequestSupported && 'credentials' in Request.prototype;
|
||||
|
||||
const resolvedOptions = {
|
||||
...fetchOptions,
|
||||
@@ -193,29 +223,35 @@ const factory = (env) => {
|
||||
method: method.toUpperCase(),
|
||||
headers: headers.normalize().toJSON(),
|
||||
body: data,
|
||||
duplex: "half",
|
||||
credentials: isCredentialsSupported ? withCredentials : undefined
|
||||
duplex: 'half',
|
||||
credentials: isCredentialsSupported ? withCredentials : undefined,
|
||||
};
|
||||
|
||||
request = isRequestSupported && new Request(url, resolvedOptions);
|
||||
|
||||
let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
|
||||
let response = await (isRequestSupported
|
||||
? _fetch(request, fetchOptions)
|
||||
: _fetch(url, resolvedOptions));
|
||||
|
||||
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
||||
const isStreamResponse =
|
||||
supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
||||
|
||||
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
||||
const options = {};
|
||||
|
||||
['status', 'statusText', 'headers'].forEach(prop => {
|
||||
['status', 'statusText', 'headers'].forEach((prop) => {
|
||||
options[prop] = response[prop];
|
||||
});
|
||||
|
||||
const responseContentLength = utils.toFiniteNumber(response.headers.get('content-length'));
|
||||
|
||||
const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
|
||||
responseContentLength,
|
||||
progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
||||
) || [];
|
||||
const [onProgress, flush] =
|
||||
(onDownloadProgress &&
|
||||
progressEventDecorator(
|
||||
responseContentLength,
|
||||
progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
||||
)) ||
|
||||
[];
|
||||
|
||||
response = new Response(
|
||||
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
||||
@@ -228,7 +264,10 @@ const factory = (env) => {
|
||||
|
||||
responseType = responseType || 'text';
|
||||
|
||||
let responseData = await resolvers[utils.findKey(resolvers, responseType) || 'text'](response, config);
|
||||
let responseData = await resolvers[utils.findKey(resolvers, responseType) || 'text'](
|
||||
response,
|
||||
config
|
||||
);
|
||||
|
||||
!isStreamResponse && unsubscribe && unsubscribe();
|
||||
|
||||
@@ -239,43 +278,50 @@ const factory = (env) => {
|
||||
status: response.status,
|
||||
statusText: response.statusText,
|
||||
config,
|
||||
request
|
||||
})
|
||||
})
|
||||
request,
|
||||
});
|
||||
});
|
||||
} catch (err) {
|
||||
unsubscribe && unsubscribe();
|
||||
|
||||
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
||||
throw Object.assign(
|
||||
new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, err && err.response),
|
||||
new AxiosError(
|
||||
'Network Error',
|
||||
AxiosError.ERR_NETWORK,
|
||||
config,
|
||||
request,
|
||||
err && err.response
|
||||
),
|
||||
{
|
||||
cause: err.cause || err
|
||||
cause: err.cause || err,
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
throw AxiosError.from(err, err && err.code, config, request, err && err.response);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const seedCache = new Map();
|
||||
|
||||
export const getFetch = (config) => {
|
||||
let env = (config && config.env) || {};
|
||||
const {fetch, Request, Response} = env;
|
||||
const seeds = [
|
||||
Request, Response, fetch
|
||||
];
|
||||
const { fetch, Request, Response } = env;
|
||||
const seeds = [Request, Response, fetch];
|
||||
|
||||
let len = seeds.length, i = len,
|
||||
seed, target, map = seedCache;
|
||||
let len = seeds.length,
|
||||
i = len,
|
||||
seed,
|
||||
target,
|
||||
map = seedCache;
|
||||
|
||||
while (i--) {
|
||||
seed = seeds[i];
|
||||
target = map.get(seed);
|
||||
|
||||
target === undefined && map.set(seed, target = (i ? new Map() : factory(env)))
|
||||
target === undefined && map.set(seed, (target = i ? new Map() : factory(env)));
|
||||
|
||||
map = target;
|
||||
}
|
||||
|
||||
1267
node_modules/axios/lib/adapters/http.js
generated
vendored
1267
node_modules/axios/lib/adapters/http.js
generated
vendored
File diff suppressed because it is too large
Load Diff
362
node_modules/axios/lib/adapters/xhr.js
generated
vendored
362
node_modules/axios/lib/adapters/xhr.js
generated
vendored
@@ -6,195 +6,217 @@ import CanceledError from '../cancel/CanceledError.js';
|
||||
import parseProtocol from '../helpers/parseProtocol.js';
|
||||
import platform from '../platform/index.js';
|
||||
import AxiosHeaders from '../core/AxiosHeaders.js';
|
||||
import {progressEventReducer} from '../helpers/progressEventReducer.js';
|
||||
import resolveConfig from "../helpers/resolveConfig.js";
|
||||
import { progressEventReducer } from '../helpers/progressEventReducer.js';
|
||||
import resolveConfig from '../helpers/resolveConfig.js';
|
||||
|
||||
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
||||
|
||||
export default isXHRAdapterSupported && function (config) {
|
||||
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
||||
const _config = resolveConfig(config);
|
||||
let requestData = _config.data;
|
||||
const requestHeaders = AxiosHeaders.from(_config.headers).normalize();
|
||||
let {responseType, onUploadProgress, onDownloadProgress} = _config;
|
||||
let onCanceled;
|
||||
let uploadThrottled, downloadThrottled;
|
||||
let flushUpload, flushDownload;
|
||||
export default isXHRAdapterSupported &&
|
||||
function (config) {
|
||||
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
||||
const _config = resolveConfig(config);
|
||||
let requestData = _config.data;
|
||||
const requestHeaders = AxiosHeaders.from(_config.headers).normalize();
|
||||
let { responseType, onUploadProgress, onDownloadProgress } = _config;
|
||||
let onCanceled;
|
||||
let uploadThrottled, downloadThrottled;
|
||||
let flushUpload, flushDownload;
|
||||
|
||||
function done() {
|
||||
flushUpload && flushUpload(); // flush events
|
||||
flushDownload && flushDownload(); // flush events
|
||||
function done() {
|
||||
flushUpload && flushUpload(); // flush events
|
||||
flushDownload && flushDownload(); // flush events
|
||||
|
||||
_config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
|
||||
_config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
|
||||
|
||||
_config.signal && _config.signal.removeEventListener('abort', onCanceled);
|
||||
}
|
||||
|
||||
let request = new XMLHttpRequest();
|
||||
|
||||
request.open(_config.method.toUpperCase(), _config.url, true);
|
||||
|
||||
// Set the request timeout in MS
|
||||
request.timeout = _config.timeout;
|
||||
|
||||
function onloadend() {
|
||||
if (!request) {
|
||||
return;
|
||||
}
|
||||
// Prepare the response
|
||||
const responseHeaders = AxiosHeaders.from(
|
||||
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
||||
);
|
||||
const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
|
||||
request.responseText : request.response;
|
||||
const response = {
|
||||
data: responseData,
|
||||
status: request.status,
|
||||
statusText: request.statusText,
|
||||
headers: responseHeaders,
|
||||
config,
|
||||
request
|
||||
};
|
||||
|
||||
settle(function _resolve(value) {
|
||||
resolve(value);
|
||||
done();
|
||||
}, function _reject(err) {
|
||||
reject(err);
|
||||
done();
|
||||
}, response);
|
||||
|
||||
// Clean up request
|
||||
request = null;
|
||||
}
|
||||
|
||||
if ('onloadend' in request) {
|
||||
// Use onloadend if available
|
||||
request.onloadend = onloadend;
|
||||
} else {
|
||||
// Listen for ready state to emulate onloadend
|
||||
request.onreadystatechange = function handleLoad() {
|
||||
if (!request || request.readyState !== 4) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The request errored out and we didn't get a response, this will be
|
||||
// handled by onerror instead
|
||||
// With one exception: request that using file: protocol, most browsers
|
||||
// will return status as 0 even though it's a successful request
|
||||
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
|
||||
return;
|
||||
}
|
||||
// readystate handler is calling before onerror or ontimeout handlers,
|
||||
// so we should call onloadend on the next 'tick'
|
||||
setTimeout(onloadend);
|
||||
};
|
||||
}
|
||||
|
||||
// Handle browser request cancellation (as opposed to a manual cancellation)
|
||||
request.onabort = function handleAbort() {
|
||||
if (!request) {
|
||||
return;
|
||||
_config.signal && _config.signal.removeEventListener('abort', onCanceled);
|
||||
}
|
||||
|
||||
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
|
||||
let request = new XMLHttpRequest();
|
||||
|
||||
// Clean up request
|
||||
request = null;
|
||||
};
|
||||
request.open(_config.method.toUpperCase(), _config.url, true);
|
||||
|
||||
// Handle low level network errors
|
||||
request.onerror = function handleError(event) {
|
||||
// Browsers deliver a ProgressEvent in XHR onerror
|
||||
// (message may be empty; when present, surface it)
|
||||
// See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
|
||||
const msg = event && event.message ? event.message : 'Network Error';
|
||||
const err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
|
||||
// attach the underlying event for consumers who want details
|
||||
err.event = event || null;
|
||||
reject(err);
|
||||
request = null;
|
||||
};
|
||||
|
||||
// Handle timeout
|
||||
request.ontimeout = function handleTimeout() {
|
||||
let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
|
||||
const transitional = _config.transitional || transitionalDefaults;
|
||||
if (_config.timeoutErrorMessage) {
|
||||
timeoutErrorMessage = _config.timeoutErrorMessage;
|
||||
}
|
||||
reject(new AxiosError(
|
||||
timeoutErrorMessage,
|
||||
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
|
||||
config,
|
||||
request));
|
||||
// Set the request timeout in MS
|
||||
request.timeout = _config.timeout;
|
||||
|
||||
// Clean up request
|
||||
request = null;
|
||||
};
|
||||
|
||||
// Remove Content-Type if data is undefined
|
||||
requestData === undefined && requestHeaders.setContentType(null);
|
||||
|
||||
// Add headers to the request
|
||||
if ('setRequestHeader' in request) {
|
||||
utils.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
||||
request.setRequestHeader(key, val);
|
||||
});
|
||||
}
|
||||
|
||||
// Add withCredentials to request if needed
|
||||
if (!utils.isUndefined(_config.withCredentials)) {
|
||||
request.withCredentials = !!_config.withCredentials;
|
||||
}
|
||||
|
||||
// Add responseType to request if needed
|
||||
if (responseType && responseType !== 'json') {
|
||||
request.responseType = _config.responseType;
|
||||
}
|
||||
|
||||
// Handle progress if needed
|
||||
if (onDownloadProgress) {
|
||||
([downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true));
|
||||
request.addEventListener('progress', downloadThrottled);
|
||||
}
|
||||
|
||||
// Not all browsers support upload events
|
||||
if (onUploadProgress && request.upload) {
|
||||
([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
|
||||
|
||||
request.upload.addEventListener('progress', uploadThrottled);
|
||||
|
||||
request.upload.addEventListener('loadend', flushUpload);
|
||||
}
|
||||
|
||||
if (_config.cancelToken || _config.signal) {
|
||||
// Handle cancellation
|
||||
// eslint-disable-next-line func-names
|
||||
onCanceled = cancel => {
|
||||
function onloadend() {
|
||||
if (!request) {
|
||||
return;
|
||||
}
|
||||
reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
|
||||
request.abort();
|
||||
// Prepare the response
|
||||
const responseHeaders = AxiosHeaders.from(
|
||||
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
||||
);
|
||||
const responseData =
|
||||
!responseType || responseType === 'text' || responseType === 'json'
|
||||
? request.responseText
|
||||
: request.response;
|
||||
const response = {
|
||||
data: responseData,
|
||||
status: request.status,
|
||||
statusText: request.statusText,
|
||||
headers: responseHeaders,
|
||||
config,
|
||||
request,
|
||||
};
|
||||
|
||||
settle(
|
||||
function _resolve(value) {
|
||||
resolve(value);
|
||||
done();
|
||||
},
|
||||
function _reject(err) {
|
||||
reject(err);
|
||||
done();
|
||||
},
|
||||
response
|
||||
);
|
||||
|
||||
// Clean up request
|
||||
request = null;
|
||||
}
|
||||
|
||||
if ('onloadend' in request) {
|
||||
// Use onloadend if available
|
||||
request.onloadend = onloadend;
|
||||
} else {
|
||||
// Listen for ready state to emulate onloadend
|
||||
request.onreadystatechange = function handleLoad() {
|
||||
if (!request || request.readyState !== 4) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The request errored out and we didn't get a response, this will be
|
||||
// handled by onerror instead
|
||||
// With one exception: request that using file: protocol, most browsers
|
||||
// will return status as 0 even though it's a successful request
|
||||
if (
|
||||
request.status === 0 &&
|
||||
!(request.responseURL && request.responseURL.indexOf('file:') === 0)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
// readystate handler is calling before onerror or ontimeout handlers,
|
||||
// so we should call onloadend on the next 'tick'
|
||||
setTimeout(onloadend);
|
||||
};
|
||||
}
|
||||
|
||||
// Handle browser request cancellation (as opposed to a manual cancellation)
|
||||
request.onabort = function handleAbort() {
|
||||
if (!request) {
|
||||
return;
|
||||
}
|
||||
|
||||
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
|
||||
|
||||
// Clean up request
|
||||
request = null;
|
||||
};
|
||||
|
||||
_config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
||||
if (_config.signal) {
|
||||
_config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
|
||||
// Handle low level network errors
|
||||
request.onerror = function handleError(event) {
|
||||
// Browsers deliver a ProgressEvent in XHR onerror
|
||||
// (message may be empty; when present, surface it)
|
||||
// See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
|
||||
const msg = event && event.message ? event.message : 'Network Error';
|
||||
const err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
|
||||
// attach the underlying event for consumers who want details
|
||||
err.event = event || null;
|
||||
reject(err);
|
||||
request = null;
|
||||
};
|
||||
|
||||
// Handle timeout
|
||||
request.ontimeout = function handleTimeout() {
|
||||
let timeoutErrorMessage = _config.timeout
|
||||
? 'timeout of ' + _config.timeout + 'ms exceeded'
|
||||
: 'timeout exceeded';
|
||||
const transitional = _config.transitional || transitionalDefaults;
|
||||
if (_config.timeoutErrorMessage) {
|
||||
timeoutErrorMessage = _config.timeoutErrorMessage;
|
||||
}
|
||||
reject(
|
||||
new AxiosError(
|
||||
timeoutErrorMessage,
|
||||
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
|
||||
config,
|
||||
request
|
||||
)
|
||||
);
|
||||
|
||||
// Clean up request
|
||||
request = null;
|
||||
};
|
||||
|
||||
// Remove Content-Type if data is undefined
|
||||
requestData === undefined && requestHeaders.setContentType(null);
|
||||
|
||||
// Add headers to the request
|
||||
if ('setRequestHeader' in request) {
|
||||
utils.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
||||
request.setRequestHeader(key, val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const protocol = parseProtocol(_config.url);
|
||||
// Add withCredentials to request if needed
|
||||
if (!utils.isUndefined(_config.withCredentials)) {
|
||||
request.withCredentials = !!_config.withCredentials;
|
||||
}
|
||||
|
||||
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
||||
reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
|
||||
return;
|
||||
}
|
||||
// Add responseType to request if needed
|
||||
if (responseType && responseType !== 'json') {
|
||||
request.responseType = _config.responseType;
|
||||
}
|
||||
|
||||
// Handle progress if needed
|
||||
if (onDownloadProgress) {
|
||||
[downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
|
||||
request.addEventListener('progress', downloadThrottled);
|
||||
}
|
||||
|
||||
// Send the request
|
||||
request.send(requestData || null);
|
||||
});
|
||||
}
|
||||
// Not all browsers support upload events
|
||||
if (onUploadProgress && request.upload) {
|
||||
[uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress);
|
||||
|
||||
request.upload.addEventListener('progress', uploadThrottled);
|
||||
|
||||
request.upload.addEventListener('loadend', flushUpload);
|
||||
}
|
||||
|
||||
if (_config.cancelToken || _config.signal) {
|
||||
// Handle cancellation
|
||||
// eslint-disable-next-line func-names
|
||||
onCanceled = (cancel) => {
|
||||
if (!request) {
|
||||
return;
|
||||
}
|
||||
reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
|
||||
request.abort();
|
||||
request = null;
|
||||
};
|
||||
|
||||
_config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
||||
if (_config.signal) {
|
||||
_config.signal.aborted
|
||||
? onCanceled()
|
||||
: _config.signal.addEventListener('abort', onCanceled);
|
||||
}
|
||||
}
|
||||
|
||||
const protocol = parseProtocol(_config.url);
|
||||
|
||||
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
||||
reject(
|
||||
new AxiosError(
|
||||
'Unsupported protocol ' + protocol + ':',
|
||||
AxiosError.ERR_BAD_REQUEST,
|
||||
config
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Send the request
|
||||
request.send(requestData || null);
|
||||
});
|
||||
};
|
||||
|
||||
12
node_modules/axios/lib/axios.js
generated
vendored
12
node_modules/axios/lib/axios.js
generated
vendored
@@ -9,12 +9,12 @@ import formDataToJSON from './helpers/formDataToJSON.js';
|
||||
import CanceledError from './cancel/CanceledError.js';
|
||||
import CancelToken from './cancel/CancelToken.js';
|
||||
import isCancel from './cancel/isCancel.js';
|
||||
import {VERSION} from './env/data.js';
|
||||
import { VERSION } from './env/data.js';
|
||||
import toFormData from './helpers/toFormData.js';
|
||||
import AxiosError from './core/AxiosError.js';
|
||||
import spread from './helpers/spread.js';
|
||||
import isAxiosError from './helpers/isAxiosError.js';
|
||||
import AxiosHeaders from "./core/AxiosHeaders.js";
|
||||
import AxiosHeaders from './core/AxiosHeaders.js';
|
||||
import adapters from './adapters/adapters.js';
|
||||
import HttpStatusCode from './helpers/HttpStatusCode.js';
|
||||
|
||||
@@ -30,10 +30,10 @@ function createInstance(defaultConfig) {
|
||||
const instance = bind(Axios.prototype.request, context);
|
||||
|
||||
// Copy axios.prototype to instance
|
||||
utils.extend(instance, Axios.prototype, context, {allOwnKeys: true});
|
||||
utils.extend(instance, Axios.prototype, context, { allOwnKeys: true });
|
||||
|
||||
// Copy context to instance
|
||||
utils.extend(instance, context, null, {allOwnKeys: true});
|
||||
utils.extend(instance, context, null, { allOwnKeys: true });
|
||||
|
||||
// Factory for creating new instances
|
||||
instance.create = function create(instanceConfig) {
|
||||
@@ -77,7 +77,7 @@ axios.mergeConfig = mergeConfig;
|
||||
|
||||
axios.AxiosHeaders = AxiosHeaders;
|
||||
|
||||
axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
|
||||
axios.formToJSON = (thing) => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
|
||||
|
||||
axios.getAdapter = adapters.getAdapter;
|
||||
|
||||
@@ -86,4 +86,4 @@ axios.HttpStatusCode = HttpStatusCode;
|
||||
axios.default = axios;
|
||||
|
||||
// this module should only have a default export
|
||||
export default axios
|
||||
export default axios;
|
||||
|
||||
8
node_modules/axios/lib/cancel/CancelToken.js
generated
vendored
8
node_modules/axios/lib/cancel/CancelToken.js
generated
vendored
@@ -24,7 +24,7 @@ class CancelToken {
|
||||
const token = this;
|
||||
|
||||
// eslint-disable-next-line func-names
|
||||
this.promise.then(cancel => {
|
||||
this.promise.then((cancel) => {
|
||||
if (!token._listeners) return;
|
||||
|
||||
let i = token._listeners.length;
|
||||
@@ -36,10 +36,10 @@ class CancelToken {
|
||||
});
|
||||
|
||||
// eslint-disable-next-line func-names
|
||||
this.promise.then = onfulfilled => {
|
||||
this.promise.then = (onfulfilled) => {
|
||||
let _resolve;
|
||||
// eslint-disable-next-line func-names
|
||||
const promise = new Promise(resolve => {
|
||||
const promise = new Promise((resolve) => {
|
||||
token.subscribe(resolve);
|
||||
_resolve = resolve;
|
||||
}).then(onfulfilled);
|
||||
@@ -127,7 +127,7 @@ class CancelToken {
|
||||
});
|
||||
return {
|
||||
token,
|
||||
cancel
|
||||
cancel,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
100
node_modules/axios/lib/core/Axios.js
generated
vendored
100
node_modules/axios/lib/core/Axios.js
generated
vendored
@@ -24,7 +24,7 @@ class Axios {
|
||||
this.defaults = instanceConfig || {};
|
||||
this.interceptors = {
|
||||
request: new InterceptorManager(),
|
||||
response: new InterceptorManager()
|
||||
response: new InterceptorManager(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class Axios {
|
||||
err.stack = stack;
|
||||
// match without the 2 top stack lines
|
||||
} else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
|
||||
err.stack += '\n' + stack
|
||||
err.stack += '\n' + stack;
|
||||
}
|
||||
} catch (e) {
|
||||
// ignore the case where "stack" is an un-writable property
|
||||
@@ -75,27 +75,35 @@ class Axios {
|
||||
|
||||
config = mergeConfig(this.defaults, config);
|
||||
|
||||
const {transitional, paramsSerializer, headers} = config;
|
||||
const { transitional, paramsSerializer, headers } = config;
|
||||
|
||||
if (transitional !== undefined) {
|
||||
validator.assertOptions(transitional, {
|
||||
silentJSONParsing: validators.transitional(validators.boolean),
|
||||
forcedJSONParsing: validators.transitional(validators.boolean),
|
||||
clarifyTimeoutError: validators.transitional(validators.boolean),
|
||||
legacyInterceptorReqResOrdering: validators.transitional(validators.boolean)
|
||||
}, false);
|
||||
validator.assertOptions(
|
||||
transitional,
|
||||
{
|
||||
silentJSONParsing: validators.transitional(validators.boolean),
|
||||
forcedJSONParsing: validators.transitional(validators.boolean),
|
||||
clarifyTimeoutError: validators.transitional(validators.boolean),
|
||||
legacyInterceptorReqResOrdering: validators.transitional(validators.boolean),
|
||||
},
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
if (paramsSerializer != null) {
|
||||
if (utils.isFunction(paramsSerializer)) {
|
||||
config.paramsSerializer = {
|
||||
serialize: paramsSerializer
|
||||
}
|
||||
serialize: paramsSerializer,
|
||||
};
|
||||
} else {
|
||||
validator.assertOptions(paramsSerializer, {
|
||||
encode: validators.function,
|
||||
serialize: validators.function
|
||||
}, true);
|
||||
validator.assertOptions(
|
||||
paramsSerializer,
|
||||
{
|
||||
encode: validators.function,
|
||||
serialize: validators.function,
|
||||
},
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,26 +116,25 @@ class Axios {
|
||||
config.allowAbsoluteUrls = true;
|
||||
}
|
||||
|
||||
validator.assertOptions(config, {
|
||||
baseUrl: validators.spelling('baseURL'),
|
||||
withXsrfToken: validators.spelling('withXSRFToken')
|
||||
}, true);
|
||||
validator.assertOptions(
|
||||
config,
|
||||
{
|
||||
baseUrl: validators.spelling('baseURL'),
|
||||
withXsrfToken: validators.spelling('withXSRFToken'),
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
// Set config.method
|
||||
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
||||
|
||||
// Flatten headers
|
||||
let contextHeaders = headers && utils.merge(
|
||||
headers.common,
|
||||
headers[config.method]
|
||||
);
|
||||
let contextHeaders = headers && utils.merge(headers.common, headers[config.method]);
|
||||
|
||||
headers && utils.forEach(
|
||||
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
||||
(method) => {
|
||||
headers &&
|
||||
utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], (method) => {
|
||||
delete headers[method];
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
config.headers = AxiosHeaders.concat(contextHeaders, headers);
|
||||
|
||||
@@ -142,7 +149,8 @@ class Axios {
|
||||
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
||||
|
||||
const transitional = config.transitional || transitionalDefaults;
|
||||
const legacyInterceptorReqResOrdering = transitional && transitional.legacyInterceptorReqResOrdering;
|
||||
const legacyInterceptorReqResOrdering =
|
||||
transitional && transitional.legacyInterceptorReqResOrdering;
|
||||
|
||||
if (legacyInterceptorReqResOrdering) {
|
||||
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
||||
@@ -216,12 +224,14 @@ class Axios {
|
||||
// Provide aliases for supported request methods
|
||||
utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
||||
/*eslint func-names:0*/
|
||||
Axios.prototype[method] = function(url, config) {
|
||||
return this.request(mergeConfig(config || {}, {
|
||||
method,
|
||||
url,
|
||||
data: (config || {}).data
|
||||
}));
|
||||
Axios.prototype[method] = function (url, config) {
|
||||
return this.request(
|
||||
mergeConfig(config || {}, {
|
||||
method,
|
||||
url,
|
||||
data: (config || {}).data,
|
||||
})
|
||||
);
|
||||
};
|
||||
});
|
||||
|
||||
@@ -230,14 +240,18 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
||||
|
||||
function generateHTTPMethod(isForm) {
|
||||
return function httpMethod(url, data, config) {
|
||||
return this.request(mergeConfig(config || {}, {
|
||||
method,
|
||||
headers: isForm ? {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
} : {},
|
||||
url,
|
||||
data
|
||||
}));
|
||||
return this.request(
|
||||
mergeConfig(config || {}, {
|
||||
method,
|
||||
headers: isForm
|
||||
? {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
}
|
||||
: {},
|
||||
url,
|
||||
data,
|
||||
})
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
87
node_modules/axios/lib/core/AxiosError.js
generated
vendored
87
node_modules/axios/lib/core/AxiosError.js
generated
vendored
@@ -3,14 +3,20 @@
|
||||
import utils from '../utils.js';
|
||||
|
||||
class AxiosError extends Error {
|
||||
static from(error, code, config, request, response, customProps) {
|
||||
const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
|
||||
axiosError.cause = error;
|
||||
axiosError.name = error.name;
|
||||
customProps && Object.assign(axiosError, customProps);
|
||||
return axiosError;
|
||||
static from(error, code, config, request, response, customProps) {
|
||||
const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
|
||||
axiosError.cause = error;
|
||||
axiosError.name = error.name;
|
||||
|
||||
// Preserve status from the original error if not already set from response
|
||||
if (error.status != null && axiosError.status == null) {
|
||||
axiosError.status = error.status;
|
||||
}
|
||||
|
||||
customProps && Object.assign(axiosError, customProps);
|
||||
return axiosError;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an Error with the specified message, config, error code, request and response.
|
||||
*
|
||||
@@ -23,37 +29,48 @@ class AxiosError extends Error {
|
||||
* @returns {Error} The created error.
|
||||
*/
|
||||
constructor(message, code, config, request, response) {
|
||||
super(message);
|
||||
this.name = 'AxiosError';
|
||||
this.isAxiosError = true;
|
||||
code && (this.code = code);
|
||||
config && (this.config = config);
|
||||
request && (this.request = request);
|
||||
if (response) {
|
||||
this.response = response;
|
||||
this.status = response.status;
|
||||
}
|
||||
super(message);
|
||||
|
||||
// Make message enumerable to maintain backward compatibility
|
||||
// The native Error constructor sets message as non-enumerable,
|
||||
// but axios < v1.13.3 had it as enumerable
|
||||
Object.defineProperty(this, 'message', {
|
||||
value: message,
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
this.name = 'AxiosError';
|
||||
this.isAxiosError = true;
|
||||
code && (this.code = code);
|
||||
config && (this.config = config);
|
||||
request && (this.request = request);
|
||||
if (response) {
|
||||
this.response = response;
|
||||
this.status = response.status;
|
||||
}
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return {
|
||||
// Standard
|
||||
message: this.message,
|
||||
name: this.name,
|
||||
// Microsoft
|
||||
description: this.description,
|
||||
number: this.number,
|
||||
// Mozilla
|
||||
fileName: this.fileName,
|
||||
lineNumber: this.lineNumber,
|
||||
columnNumber: this.columnNumber,
|
||||
stack: this.stack,
|
||||
// Axios
|
||||
config: utils.toJSONObject(this.config),
|
||||
code: this.code,
|
||||
status: this.status,
|
||||
};
|
||||
}
|
||||
toJSON() {
|
||||
return {
|
||||
// Standard
|
||||
message: this.message,
|
||||
name: this.name,
|
||||
// Microsoft
|
||||
description: this.description,
|
||||
number: this.number,
|
||||
// Mozilla
|
||||
fileName: this.fileName,
|
||||
lineNumber: this.lineNumber,
|
||||
columnNumber: this.columnNumber,
|
||||
stack: this.stack,
|
||||
// Axios
|
||||
config: utils.toJSONObject(this.config),
|
||||
code: this.code,
|
||||
status: this.status,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
|
||||
|
||||
78
node_modules/axios/lib/core/AxiosHeaders.js
generated
vendored
78
node_modules/axios/lib/core/AxiosHeaders.js
generated
vendored
@@ -52,8 +52,10 @@ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
||||
}
|
||||
|
||||
function formatHeader(header) {
|
||||
return header.trim()
|
||||
.toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
||||
return header
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
||||
return char.toUpperCase() + str;
|
||||
});
|
||||
}
|
||||
@@ -61,12 +63,12 @@ function formatHeader(header) {
|
||||
function buildAccessors(obj, header) {
|
||||
const accessorName = utils.toCamelCase(' ' + header);
|
||||
|
||||
['get', 'set', 'has'].forEach(methodName => {
|
||||
['get', 'set', 'has'].forEach((methodName) => {
|
||||
Object.defineProperty(obj, methodName + accessorName, {
|
||||
value: function(arg1, arg2, arg3) {
|
||||
value: function (arg1, arg2, arg3) {
|
||||
return this[methodName].call(this, header, arg1, arg2, arg3);
|
||||
},
|
||||
configurable: true
|
||||
configurable: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -88,7 +90,12 @@ class AxiosHeaders {
|
||||
|
||||
const key = utils.findKey(self, lHeader);
|
||||
|
||||
if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
|
||||
if (
|
||||
!key ||
|
||||
self[key] === undefined ||
|
||||
_rewrite === true ||
|
||||
(_rewrite === undefined && self[key] !== false)
|
||||
) {
|
||||
self[key || _header] = normalizeValue(_value);
|
||||
}
|
||||
}
|
||||
@@ -97,21 +104,26 @@ class AxiosHeaders {
|
||||
utils.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
||||
|
||||
if (utils.isPlainObject(header) || header instanceof this.constructor) {
|
||||
setHeaders(header, valueOrRewrite)
|
||||
} else if(utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
||||
setHeaders(header, valueOrRewrite);
|
||||
} else if (utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
||||
setHeaders(parseHeaders(header), valueOrRewrite);
|
||||
} else if (utils.isObject(header) && utils.isIterable(header)) {
|
||||
let obj = {}, dest, key;
|
||||
let obj = {},
|
||||
dest,
|
||||
key;
|
||||
for (const entry of header) {
|
||||
if (!utils.isArray(entry)) {
|
||||
throw TypeError('Object iterator must return a key-value pair');
|
||||
}
|
||||
|
||||
obj[key = entry[0]] = (dest = obj[key]) ?
|
||||
(utils.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]]) : entry[1];
|
||||
obj[(key = entry[0])] = (dest = obj[key])
|
||||
? utils.isArray(dest)
|
||||
? [...dest, entry[1]]
|
||||
: [dest, entry[1]]
|
||||
: entry[1];
|
||||
}
|
||||
|
||||
setHeaders(obj, valueOrRewrite)
|
||||
setHeaders(obj, valueOrRewrite);
|
||||
} else {
|
||||
header != null && setHeader(valueOrRewrite, header, rewrite);
|
||||
}
|
||||
@@ -155,7 +167,11 @@ class AxiosHeaders {
|
||||
if (header) {
|
||||
const key = utils.findKey(this, header);
|
||||
|
||||
return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
||||
return !!(
|
||||
key &&
|
||||
this[key] !== undefined &&
|
||||
(!matcher || matchHeaderValue(this, this[key], key, matcher))
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -195,7 +211,7 @@ class AxiosHeaders {
|
||||
|
||||
while (i--) {
|
||||
const key = keys[i];
|
||||
if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
||||
if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
||||
delete this[key];
|
||||
deleted = true;
|
||||
}
|
||||
@@ -239,7 +255,9 @@ class AxiosHeaders {
|
||||
const obj = Object.create(null);
|
||||
|
||||
utils.forEach(this, (value, header) => {
|
||||
value != null && value !== false && (obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value);
|
||||
value != null &&
|
||||
value !== false &&
|
||||
(obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value);
|
||||
});
|
||||
|
||||
return obj;
|
||||
@@ -250,11 +268,13 @@ class AxiosHeaders {
|
||||
}
|
||||
|
||||
toString() {
|
||||
return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
|
||||
return Object.entries(this.toJSON())
|
||||
.map(([header, value]) => header + ': ' + value)
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
getSetCookie() {
|
||||
return this.get("set-cookie") || [];
|
||||
return this.get('set-cookie') || [];
|
||||
}
|
||||
|
||||
get [Symbol.toStringTag]() {
|
||||
@@ -274,9 +294,12 @@ class AxiosHeaders {
|
||||
}
|
||||
|
||||
static accessor(header) {
|
||||
const internals = this[$internals] = (this[$internals] = {
|
||||
accessors: {}
|
||||
});
|
||||
const internals =
|
||||
(this[$internals] =
|
||||
this[$internals] =
|
||||
{
|
||||
accessors: {},
|
||||
});
|
||||
|
||||
const accessors = internals.accessors;
|
||||
const prototype = this.prototype;
|
||||
@@ -296,17 +319,24 @@ class AxiosHeaders {
|
||||
}
|
||||
}
|
||||
|
||||
AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
|
||||
AxiosHeaders.accessor([
|
||||
'Content-Type',
|
||||
'Content-Length',
|
||||
'Accept',
|
||||
'Accept-Encoding',
|
||||
'User-Agent',
|
||||
'Authorization',
|
||||
]);
|
||||
|
||||
// reserved names hotfix
|
||||
utils.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
|
||||
utils.reduceDescriptors(AxiosHeaders.prototype, ({ value }, key) => {
|
||||
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
||||
return {
|
||||
get: () => value,
|
||||
set(headerValue) {
|
||||
this[mapped] = headerValue;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
utils.freezeMethods(AxiosHeaders);
|
||||
|
||||
2
node_modules/axios/lib/core/InterceptorManager.js
generated
vendored
2
node_modules/axios/lib/core/InterceptorManager.js
generated
vendored
@@ -21,7 +21,7 @@ class InterceptorManager {
|
||||
fulfilled,
|
||||
rejected,
|
||||
synchronous: options ? options.synchronous : false,
|
||||
runWhen: options ? options.runWhen : null
|
||||
runWhen: options ? options.runWhen : null,
|
||||
});
|
||||
return this.handlers.length - 1;
|
||||
}
|
||||
|
||||
58
node_modules/axios/lib/core/dispatchRequest.js
generated
vendored
58
node_modules/axios/lib/core/dispatchRequest.js
generated
vendored
@@ -5,7 +5,7 @@ import isCancel from '../cancel/isCancel.js';
|
||||
import defaults from '../defaults/index.js';
|
||||
import CanceledError from '../cancel/CanceledError.js';
|
||||
import AxiosHeaders from '../core/AxiosHeaders.js';
|
||||
import adapters from "../adapters/adapters.js";
|
||||
import adapters from '../adapters/adapters.js';
|
||||
|
||||
/**
|
||||
* Throws a `CanceledError` if cancellation has been requested.
|
||||
@@ -37,10 +37,7 @@ export default function dispatchRequest(config) {
|
||||
config.headers = AxiosHeaders.from(config.headers);
|
||||
|
||||
// Transform request data
|
||||
config.data = transformData.call(
|
||||
config,
|
||||
config.transformRequest
|
||||
);
|
||||
config.data = transformData.call(config, config.transformRequest);
|
||||
|
||||
if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
|
||||
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
||||
@@ -48,34 +45,33 @@ export default function dispatchRequest(config) {
|
||||
|
||||
const adapter = adapters.getAdapter(config.adapter || defaults.adapter, config);
|
||||
|
||||
return adapter(config).then(function onAdapterResolution(response) {
|
||||
throwIfCancellationRequested(config);
|
||||
|
||||
// Transform response data
|
||||
response.data = transformData.call(
|
||||
config,
|
||||
config.transformResponse,
|
||||
response
|
||||
);
|
||||
|
||||
response.headers = AxiosHeaders.from(response.headers);
|
||||
|
||||
return response;
|
||||
}, function onAdapterRejection(reason) {
|
||||
if (!isCancel(reason)) {
|
||||
return adapter(config).then(
|
||||
function onAdapterResolution(response) {
|
||||
throwIfCancellationRequested(config);
|
||||
|
||||
// Transform response data
|
||||
if (reason && reason.response) {
|
||||
reason.response.data = transformData.call(
|
||||
config,
|
||||
config.transformResponse,
|
||||
reason.response
|
||||
);
|
||||
reason.response.headers = AxiosHeaders.from(reason.response.headers);
|
||||
}
|
||||
}
|
||||
response.data = transformData.call(config, config.transformResponse, response);
|
||||
|
||||
return Promise.reject(reason);
|
||||
});
|
||||
response.headers = AxiosHeaders.from(response.headers);
|
||||
|
||||
return response;
|
||||
},
|
||||
function onAdapterRejection(reason) {
|
||||
if (!isCancel(reason)) {
|
||||
throwIfCancellationRequested(config);
|
||||
|
||||
// Transform response data
|
||||
if (reason && reason.response) {
|
||||
reason.response.data = transformData.call(
|
||||
config,
|
||||
config.transformResponse,
|
||||
reason.response
|
||||
);
|
||||
reason.response.headers = AxiosHeaders.from(reason.response.headers);
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.reject(reason);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
32
node_modules/axios/lib/core/mergeConfig.js
generated
vendored
32
node_modules/axios/lib/core/mergeConfig.js
generated
vendored
@@ -1,10 +1,9 @@
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
import utils from "../utils.js";
|
||||
import AxiosHeaders from "./AxiosHeaders.js";
|
||||
import utils from '../utils.js';
|
||||
import AxiosHeaders from './AxiosHeaders.js';
|
||||
|
||||
const headersToObject = (thing) =>
|
||||
thing instanceof AxiosHeaders ? { ...thing } : thing;
|
||||
const headersToObject = (thing) => (thing instanceof AxiosHeaders ? { ...thing } : thing);
|
||||
|
||||
/**
|
||||
* Config-specific merge-function which creates a new config-object
|
||||
@@ -97,23 +96,12 @@ export default function mergeConfig(config1, config2) {
|
||||
mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
|
||||
};
|
||||
|
||||
utils.forEach(
|
||||
Object.keys({ ...config1, ...config2 }),
|
||||
function computeConfigValue(prop) {
|
||||
if (
|
||||
prop === "__proto__" ||
|
||||
prop === "constructor" ||
|
||||
prop === "prototype"
|
||||
)
|
||||
return;
|
||||
const merge = utils.hasOwnProp(mergeMap, prop)
|
||||
? mergeMap[prop]
|
||||
: mergeDeepProperties;
|
||||
const configValue = merge(config1[prop], config2[prop], prop);
|
||||
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) ||
|
||||
(config[prop] = configValue);
|
||||
},
|
||||
);
|
||||
utils.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
|
||||
if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
|
||||
const merge = utils.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
|
||||
const configValue = merge(config1[prop], config2[prop], prop);
|
||||
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
||||
});
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
18
node_modules/axios/lib/core/settle.js
generated
vendored
18
node_modules/axios/lib/core/settle.js
generated
vendored
@@ -16,12 +16,16 @@ export default function settle(resolve, reject, response) {
|
||||
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
||||
resolve(response);
|
||||
} else {
|
||||
reject(new AxiosError(
|
||||
'Request failed with status code ' + response.status,
|
||||
[AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
||||
response.config,
|
||||
response.request,
|
||||
response
|
||||
));
|
||||
reject(
|
||||
new AxiosError(
|
||||
'Request failed with status code ' + response.status,
|
||||
[AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][
|
||||
Math.floor(response.status / 100) - 4
|
||||
],
|
||||
response.config,
|
||||
response.request,
|
||||
response
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
167
node_modules/axios/lib/defaults/index.js
generated
vendored
167
node_modules/axios/lib/defaults/index.js
generated
vendored
@@ -34,96 +34,107 @@ function stringifySafely(rawValue, parser, encoder) {
|
||||
}
|
||||
|
||||
const defaults = {
|
||||
|
||||
transitional: transitionalDefaults,
|
||||
|
||||
adapter: ['xhr', 'http', 'fetch'],
|
||||
|
||||
transformRequest: [function transformRequest(data, headers) {
|
||||
const contentType = headers.getContentType() || '';
|
||||
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
||||
const isObjectPayload = utils.isObject(data);
|
||||
transformRequest: [
|
||||
function transformRequest(data, headers) {
|
||||
const contentType = headers.getContentType() || '';
|
||||
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
||||
const isObjectPayload = utils.isObject(data);
|
||||
|
||||
if (isObjectPayload && utils.isHTMLForm(data)) {
|
||||
data = new FormData(data);
|
||||
}
|
||||
|
||||
const isFormData = utils.isFormData(data);
|
||||
|
||||
if (isFormData) {
|
||||
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
||||
}
|
||||
|
||||
if (utils.isArrayBuffer(data) ||
|
||||
utils.isBuffer(data) ||
|
||||
utils.isStream(data) ||
|
||||
utils.isFile(data) ||
|
||||
utils.isBlob(data) ||
|
||||
utils.isReadableStream(data)
|
||||
) {
|
||||
return data;
|
||||
}
|
||||
if (utils.isArrayBufferView(data)) {
|
||||
return data.buffer;
|
||||
}
|
||||
if (utils.isURLSearchParams(data)) {
|
||||
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
||||
return data.toString();
|
||||
}
|
||||
|
||||
let isFileList;
|
||||
|
||||
if (isObjectPayload) {
|
||||
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
||||
return toURLEncodedForm(data, this.formSerializer).toString();
|
||||
if (isObjectPayload && utils.isHTMLForm(data)) {
|
||||
data = new FormData(data);
|
||||
}
|
||||
|
||||
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
||||
const _FormData = this.env && this.env.FormData;
|
||||
const isFormData = utils.isFormData(data);
|
||||
|
||||
return toFormData(
|
||||
isFileList ? {'files[]': data} : data,
|
||||
_FormData && new _FormData(),
|
||||
this.formSerializer
|
||||
);
|
||||
if (isFormData) {
|
||||
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
||||
}
|
||||
}
|
||||
|
||||
if (isObjectPayload || hasJSONContentType ) {
|
||||
headers.setContentType('application/json', false);
|
||||
return stringifySafely(data);
|
||||
}
|
||||
if (
|
||||
utils.isArrayBuffer(data) ||
|
||||
utils.isBuffer(data) ||
|
||||
utils.isStream(data) ||
|
||||
utils.isFile(data) ||
|
||||
utils.isBlob(data) ||
|
||||
utils.isReadableStream(data)
|
||||
) {
|
||||
return data;
|
||||
}
|
||||
if (utils.isArrayBufferView(data)) {
|
||||
return data.buffer;
|
||||
}
|
||||
if (utils.isURLSearchParams(data)) {
|
||||
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
||||
return data.toString();
|
||||
}
|
||||
|
||||
return data;
|
||||
}],
|
||||
let isFileList;
|
||||
|
||||
transformResponse: [function transformResponse(data) {
|
||||
const transitional = this.transitional || defaults.transitional;
|
||||
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
||||
const JSONRequested = this.responseType === 'json';
|
||||
if (isObjectPayload) {
|
||||
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
||||
return toURLEncodedForm(data, this.formSerializer).toString();
|
||||
}
|
||||
|
||||
if (utils.isResponse(data) || utils.isReadableStream(data)) {
|
||||
return data;
|
||||
}
|
||||
if (
|
||||
(isFileList = utils.isFileList(data)) ||
|
||||
contentType.indexOf('multipart/form-data') > -1
|
||||
) {
|
||||
const _FormData = this.env && this.env.FormData;
|
||||
|
||||
if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
||||
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
||||
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
||||
|
||||
try {
|
||||
return JSON.parse(data, this.parseReviver);
|
||||
} catch (e) {
|
||||
if (strictJSONParsing) {
|
||||
if (e.name === 'SyntaxError') {
|
||||
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
||||
}
|
||||
throw e;
|
||||
return toFormData(
|
||||
isFileList ? { 'files[]': data } : data,
|
||||
_FormData && new _FormData(),
|
||||
this.formSerializer
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}],
|
||||
if (isObjectPayload || hasJSONContentType) {
|
||||
headers.setContentType('application/json', false);
|
||||
return stringifySafely(data);
|
||||
}
|
||||
|
||||
return data;
|
||||
},
|
||||
],
|
||||
|
||||
transformResponse: [
|
||||
function transformResponse(data) {
|
||||
const transitional = this.transitional || defaults.transitional;
|
||||
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
||||
const JSONRequested = this.responseType === 'json';
|
||||
|
||||
if (utils.isResponse(data) || utils.isReadableStream(data)) {
|
||||
return data;
|
||||
}
|
||||
|
||||
if (
|
||||
data &&
|
||||
utils.isString(data) &&
|
||||
((forcedJSONParsing && !this.responseType) || JSONRequested)
|
||||
) {
|
||||
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
||||
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
||||
|
||||
try {
|
||||
return JSON.parse(data, this.parseReviver);
|
||||
} catch (e) {
|
||||
if (strictJSONParsing) {
|
||||
if (e.name === 'SyntaxError') {
|
||||
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
},
|
||||
],
|
||||
|
||||
/**
|
||||
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
||||
@@ -139,7 +150,7 @@ const defaults = {
|
||||
|
||||
env: {
|
||||
FormData: platform.classes.FormData,
|
||||
Blob: platform.classes.Blob
|
||||
Blob: platform.classes.Blob,
|
||||
},
|
||||
|
||||
validateStatus: function validateStatus(status) {
|
||||
@@ -148,10 +159,10 @@ const defaults = {
|
||||
|
||||
headers: {
|
||||
common: {
|
||||
'Accept': 'application/json, text/plain, */*',
|
||||
'Content-Type': undefined
|
||||
}
|
||||
}
|
||||
Accept: 'application/json, text/plain, */*',
|
||||
'Content-Type': undefined,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
||||
|
||||
2
node_modules/axios/lib/defaults/transitional.js
generated
vendored
2
node_modules/axios/lib/defaults/transitional.js
generated
vendored
@@ -4,5 +4,5 @@ export default {
|
||||
silentJSONParsing: true,
|
||||
forcedJSONParsing: true,
|
||||
clarifyTimeoutError: false,
|
||||
legacyInterceptorReqResOrdering: true
|
||||
legacyInterceptorReqResOrdering: true,
|
||||
};
|
||||
|
||||
2
node_modules/axios/lib/env/data.js
generated
vendored
2
node_modules/axios/lib/env/data.js
generated
vendored
@@ -1 +1 @@
|
||||
export const VERSION = "1.13.5";
|
||||
export const VERSION = "1.13.6";
|
||||
61
node_modules/axios/lib/helpers/AxiosTransformStream.js
generated
vendored
61
node_modules/axios/lib/helpers/AxiosTransformStream.js
generated
vendored
@@ -5,24 +5,29 @@ import utils from '../utils.js';
|
||||
|
||||
const kInternals = Symbol('internals');
|
||||
|
||||
class AxiosTransformStream extends stream.Transform{
|
||||
class AxiosTransformStream extends stream.Transform {
|
||||
constructor(options) {
|
||||
options = utils.toFlatObject(options, {
|
||||
maxRate: 0,
|
||||
chunkSize: 64 * 1024,
|
||||
minChunkSize: 100,
|
||||
timeWindow: 500,
|
||||
ticksRate: 2,
|
||||
samplesCount: 15
|
||||
}, null, (prop, source) => {
|
||||
return !utils.isUndefined(source[prop]);
|
||||
});
|
||||
options = utils.toFlatObject(
|
||||
options,
|
||||
{
|
||||
maxRate: 0,
|
||||
chunkSize: 64 * 1024,
|
||||
minChunkSize: 100,
|
||||
timeWindow: 500,
|
||||
ticksRate: 2,
|
||||
samplesCount: 15,
|
||||
},
|
||||
null,
|
||||
(prop, source) => {
|
||||
return !utils.isUndefined(source[prop]);
|
||||
}
|
||||
);
|
||||
|
||||
super({
|
||||
readableHighWaterMark: options.chunkSize
|
||||
readableHighWaterMark: options.chunkSize,
|
||||
});
|
||||
|
||||
const internals = this[kInternals] = {
|
||||
const internals = (this[kInternals] = {
|
||||
timeWindow: options.timeWindow,
|
||||
chunkSize: options.chunkSize,
|
||||
maxRate: options.maxRate,
|
||||
@@ -32,10 +37,10 @@ class AxiosTransformStream extends stream.Transform{
|
||||
notifiedBytesLoaded: 0,
|
||||
ts: Date.now(),
|
||||
bytes: 0,
|
||||
onReadCallback: null
|
||||
};
|
||||
onReadCallback: null,
|
||||
});
|
||||
|
||||
this.on('newListener', event => {
|
||||
this.on('newListener', (event) => {
|
||||
if (event === 'progress') {
|
||||
if (!internals.isCaptured) {
|
||||
internals.isCaptured = true;
|
||||
@@ -63,8 +68,11 @@ class AxiosTransformStream extends stream.Transform{
|
||||
const timeWindow = internals.timeWindow;
|
||||
|
||||
const divider = 1000 / timeWindow;
|
||||
const bytesThreshold = (maxRate / divider);
|
||||
const minChunkSize = internals.minChunkSize !== false ? Math.max(internals.minChunkSize, bytesThreshold * 0.01) : 0;
|
||||
const bytesThreshold = maxRate / divider;
|
||||
const minChunkSize =
|
||||
internals.minChunkSize !== false
|
||||
? Math.max(internals.minChunkSize, bytesThreshold * 0.01)
|
||||
: 0;
|
||||
|
||||
const pushChunk = (_chunk, _callback) => {
|
||||
const bytes = Buffer.byteLength(_chunk);
|
||||
@@ -81,7 +89,7 @@ class AxiosTransformStream extends stream.Transform{
|
||||
process.nextTick(_callback);
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const transformChunk = (_chunk, _callback) => {
|
||||
const chunkSize = Buffer.byteLength(_chunk);
|
||||
@@ -93,7 +101,7 @@ class AxiosTransformStream extends stream.Transform{
|
||||
if (maxRate) {
|
||||
const now = Date.now();
|
||||
|
||||
if (!internals.ts || (passed = (now - internals.ts)) >= timeWindow) {
|
||||
if (!internals.ts || (passed = now - internals.ts) >= timeWindow) {
|
||||
internals.ts = now;
|
||||
bytesLeft = bytesThreshold - internals.bytes;
|
||||
internals.bytes = bytesLeft < 0 ? -bytesLeft : 0;
|
||||
@@ -116,14 +124,19 @@ class AxiosTransformStream extends stream.Transform{
|
||||
}
|
||||
}
|
||||
|
||||
if (maxChunkSize && chunkSize > maxChunkSize && (chunkSize - maxChunkSize) > minChunkSize) {
|
||||
if (maxChunkSize && chunkSize > maxChunkSize && chunkSize - maxChunkSize > minChunkSize) {
|
||||
chunkRemainder = _chunk.subarray(maxChunkSize);
|
||||
_chunk = _chunk.subarray(0, maxChunkSize);
|
||||
}
|
||||
|
||||
pushChunk(_chunk, chunkRemainder ? () => {
|
||||
process.nextTick(_callback, null, chunkRemainder);
|
||||
} : _callback);
|
||||
pushChunk(
|
||||
_chunk,
|
||||
chunkRemainder
|
||||
? () => {
|
||||
process.nextTick(_callback, null, chunkRemainder);
|
||||
}
|
||||
: _callback
|
||||
);
|
||||
};
|
||||
|
||||
transformChunk(chunk, function transformNextChunk(err, _chunk) {
|
||||
|
||||
18
node_modules/axios/lib/helpers/AxiosURLSearchParams.js
generated
vendored
18
node_modules/axios/lib/helpers/AxiosURLSearchParams.js
generated
vendored
@@ -18,7 +18,7 @@ function encode(str) {
|
||||
')': '%29',
|
||||
'~': '%7E',
|
||||
'%20': '+',
|
||||
'%00': '\x00'
|
||||
'%00': '\x00',
|
||||
};
|
||||
return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
|
||||
return charMap[match];
|
||||
@@ -46,13 +46,17 @@ prototype.append = function append(name, value) {
|
||||
};
|
||||
|
||||
prototype.toString = function toString(encoder) {
|
||||
const _encode = encoder ? function(value) {
|
||||
return encoder.call(this, value, encode);
|
||||
} : encode;
|
||||
const _encode = encoder
|
||||
? function (value) {
|
||||
return encoder.call(this, value, encode);
|
||||
}
|
||||
: encode;
|
||||
|
||||
return this._pairs.map(function each(pair) {
|
||||
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
||||
}, '').join('&');
|
||||
return this._pairs
|
||||
.map(function each(pair) {
|
||||
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
||||
}, '')
|
||||
.join('&');
|
||||
};
|
||||
|
||||
export default AxiosURLSearchParams;
|
||||
|
||||
9
node_modules/axios/lib/helpers/ZlibHeaderTransformStream.js
generated
vendored
9
node_modules/axios/lib/helpers/ZlibHeaderTransformStream.js
generated
vendored
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
import stream from "stream";
|
||||
import stream from 'stream';
|
||||
|
||||
class ZlibHeaderTransformStream extends stream.Transform {
|
||||
__transform(chunk, encoding, callback) {
|
||||
@@ -13,10 +13,11 @@ class ZlibHeaderTransformStream extends stream.Transform {
|
||||
this._transform = this.__transform;
|
||||
|
||||
// Add Default Compression headers if no zlib headers are present
|
||||
if (chunk[0] !== 120) { // Hex: 78
|
||||
if (chunk[0] !== 120) {
|
||||
// Hex: 78
|
||||
const header = Buffer.alloc(2);
|
||||
header[0] = 120; // Hex: 78
|
||||
header[1] = 156; // Hex: 9C
|
||||
header[1] = 156; // Hex: 9C
|
||||
this.push(header, encoding);
|
||||
}
|
||||
}
|
||||
|
||||
28
node_modules/axios/lib/helpers/buildURL.js
generated
vendored
28
node_modules/axios/lib/helpers/buildURL.js
generated
vendored
@@ -12,11 +12,11 @@ import AxiosURLSearchParams from '../helpers/AxiosURLSearchParams.js';
|
||||
* @returns {string} The encoded value.
|
||||
*/
|
||||
function encode(val) {
|
||||
return encodeURIComponent(val).
|
||||
replace(/%3A/gi, ':').
|
||||
replace(/%24/g, '$').
|
||||
replace(/%2C/gi, ',').
|
||||
replace(/%20/g, '+');
|
||||
return encodeURIComponent(val)
|
||||
.replace(/%3A/gi, ':')
|
||||
.replace(/%24/g, '$')
|
||||
.replace(/%2C/gi, ',')
|
||||
.replace(/%20/g, '+');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,11 +33,13 @@ export default function buildURL(url, params, options) {
|
||||
return url;
|
||||
}
|
||||
|
||||
const _encode = options && options.encode || encode;
|
||||
const _encode = (options && options.encode) || encode;
|
||||
|
||||
const _options = utils.isFunction(options) ? {
|
||||
serialize: options
|
||||
} : options;
|
||||
const _options = utils.isFunction(options)
|
||||
? {
|
||||
serialize: options,
|
||||
}
|
||||
: options;
|
||||
|
||||
const serializeFn = _options && _options.serialize;
|
||||
|
||||
@@ -46,13 +48,13 @@ export default function buildURL(url, params, options) {
|
||||
if (serializeFn) {
|
||||
serializedParams = serializeFn(params, _options);
|
||||
} else {
|
||||
serializedParams = utils.isURLSearchParams(params) ?
|
||||
params.toString() :
|
||||
new AxiosURLSearchParams(params, _options).toString(_encode);
|
||||
serializedParams = utils.isURLSearchParams(params)
|
||||
? params.toString()
|
||||
: new AxiosURLSearchParams(params, _options).toString(_encode);
|
||||
}
|
||||
|
||||
if (serializedParams) {
|
||||
const hashmarkIndex = url.indexOf("#");
|
||||
const hashmarkIndex = url.indexOf('#');
|
||||
|
||||
if (hashmarkIndex !== -1) {
|
||||
url = url.slice(0, hashmarkIndex);
|
||||
|
||||
24
node_modules/axios/lib/helpers/callbackify.js
generated
vendored
24
node_modules/axios/lib/helpers/callbackify.js
generated
vendored
@@ -1,16 +1,18 @@
|
||||
import utils from "../utils.js";
|
||||
import utils from '../utils.js';
|
||||
|
||||
const callbackify = (fn, reducer) => {
|
||||
return utils.isAsyncFn(fn) ? function (...args) {
|
||||
const cb = args.pop();
|
||||
fn.apply(this, args).then((value) => {
|
||||
try {
|
||||
reducer ? cb(null, ...reducer(value)) : cb(null, value);
|
||||
} catch (err) {
|
||||
cb(err);
|
||||
return utils.isAsyncFn(fn)
|
||||
? function (...args) {
|
||||
const cb = args.pop();
|
||||
fn.apply(this, args).then((value) => {
|
||||
try {
|
||||
reducer ? cb(null, ...reducer(value)) : cb(null, value);
|
||||
} catch (err) {
|
||||
cb(err);
|
||||
}
|
||||
}, cb);
|
||||
}
|
||||
}, cb);
|
||||
} : fn;
|
||||
}
|
||||
: fn;
|
||||
};
|
||||
|
||||
export default callbackify;
|
||||
|
||||
36
node_modules/axios/lib/helpers/composeSignals.js
generated
vendored
36
node_modules/axios/lib/helpers/composeSignals.js
generated
vendored
@@ -1,9 +1,9 @@
|
||||
import CanceledError from "../cancel/CanceledError.js";
|
||||
import AxiosError from "../core/AxiosError.js";
|
||||
import CanceledError from '../cancel/CanceledError.js';
|
||||
import AxiosError from '../core/AxiosError.js';
|
||||
import utils from '../utils.js';
|
||||
|
||||
const composeSignals = (signals, timeout) => {
|
||||
const {length} = (signals = signals ? signals.filter(Boolean) : []);
|
||||
const { length } = (signals = signals ? signals.filter(Boolean) : []);
|
||||
|
||||
if (timeout || length) {
|
||||
let controller = new AbortController();
|
||||
@@ -15,34 +15,42 @@ const composeSignals = (signals, timeout) => {
|
||||
aborted = true;
|
||||
unsubscribe();
|
||||
const err = reason instanceof Error ? reason : this.reason;
|
||||
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
||||
controller.abort(
|
||||
err instanceof AxiosError
|
||||
? err
|
||||
: new CanceledError(err instanceof Error ? err.message : err)
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let timer = timeout && setTimeout(() => {
|
||||
timer = null;
|
||||
onabort(new AxiosError(`timeout of ${timeout}ms exceeded`, AxiosError.ETIMEDOUT))
|
||||
}, timeout)
|
||||
let timer =
|
||||
timeout &&
|
||||
setTimeout(() => {
|
||||
timer = null;
|
||||
onabort(new AxiosError(`timeout of ${timeout}ms exceeded`, AxiosError.ETIMEDOUT));
|
||||
}, timeout);
|
||||
|
||||
const unsubscribe = () => {
|
||||
if (signals) {
|
||||
timer && clearTimeout(timer);
|
||||
timer = null;
|
||||
signals.forEach(signal => {
|
||||
signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
|
||||
signals.forEach((signal) => {
|
||||
signal.unsubscribe
|
||||
? signal.unsubscribe(onabort)
|
||||
: signal.removeEventListener('abort', onabort);
|
||||
});
|
||||
signals = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
||||
|
||||
const {signal} = controller;
|
||||
const { signal } = controller;
|
||||
|
||||
signal.unsubscribe = () => utils.asap(unsubscribe);
|
||||
|
||||
return signal;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default composeSignals;
|
||||
|
||||
83
node_modules/axios/lib/helpers/cookies.js
generated
vendored
83
node_modules/axios/lib/helpers/cookies.js
generated
vendored
@@ -1,53 +1,48 @@
|
||||
import utils from '../utils.js';
|
||||
import platform from '../platform/index.js';
|
||||
|
||||
export default platform.hasStandardBrowserEnv ?
|
||||
export default platform.hasStandardBrowserEnv
|
||||
? // Standard browser envs support document.cookie
|
||||
{
|
||||
write(name, value, expires, path, domain, secure, sameSite) {
|
||||
if (typeof document === 'undefined') return;
|
||||
|
||||
// Standard browser envs support document.cookie
|
||||
{
|
||||
write(name, value, expires, path, domain, secure, sameSite) {
|
||||
if (typeof document === 'undefined') return;
|
||||
const cookie = [`${name}=${encodeURIComponent(value)}`];
|
||||
|
||||
const cookie = [`${name}=${encodeURIComponent(value)}`];
|
||||
if (utils.isNumber(expires)) {
|
||||
cookie.push(`expires=${new Date(expires).toUTCString()}`);
|
||||
}
|
||||
if (utils.isString(path)) {
|
||||
cookie.push(`path=${path}`);
|
||||
}
|
||||
if (utils.isString(domain)) {
|
||||
cookie.push(`domain=${domain}`);
|
||||
}
|
||||
if (secure === true) {
|
||||
cookie.push('secure');
|
||||
}
|
||||
if (utils.isString(sameSite)) {
|
||||
cookie.push(`SameSite=${sameSite}`);
|
||||
}
|
||||
|
||||
if (utils.isNumber(expires)) {
|
||||
cookie.push(`expires=${new Date(expires).toUTCString()}`);
|
||||
}
|
||||
if (utils.isString(path)) {
|
||||
cookie.push(`path=${path}`);
|
||||
}
|
||||
if (utils.isString(domain)) {
|
||||
cookie.push(`domain=${domain}`);
|
||||
}
|
||||
if (secure === true) {
|
||||
cookie.push('secure');
|
||||
}
|
||||
if (utils.isString(sameSite)) {
|
||||
cookie.push(`SameSite=${sameSite}`);
|
||||
}
|
||||
document.cookie = cookie.join('; ');
|
||||
},
|
||||
|
||||
document.cookie = cookie.join('; ');
|
||||
},
|
||||
read(name) {
|
||||
if (typeof document === 'undefined') return null;
|
||||
const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
|
||||
return match ? decodeURIComponent(match[1]) : null;
|
||||
},
|
||||
|
||||
read(name) {
|
||||
if (typeof document === 'undefined') return null;
|
||||
const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
|
||||
return match ? decodeURIComponent(match[1]) : null;
|
||||
},
|
||||
|
||||
remove(name) {
|
||||
this.write(name, '', Date.now() - 86400000, '/');
|
||||
remove(name) {
|
||||
this.write(name, '', Date.now() - 86400000, '/');
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
:
|
||||
|
||||
// Non-standard browser env (web workers, react-native) lack needed support.
|
||||
{
|
||||
write() {},
|
||||
read() {
|
||||
return null;
|
||||
},
|
||||
remove() {}
|
||||
};
|
||||
|
||||
: // Non-standard browser env (web workers, react-native) lack needed support.
|
||||
{
|
||||
write() {},
|
||||
read() {
|
||||
return null;
|
||||
},
|
||||
remove() {},
|
||||
};
|
||||
|
||||
13
node_modules/axios/lib/helpers/deprecatedMethod.js
generated
vendored
13
node_modules/axios/lib/helpers/deprecatedMethod.js
generated
vendored
@@ -15,12 +15,17 @@
|
||||
export default function deprecatedMethod(method, instead, docs) {
|
||||
try {
|
||||
console.warn(
|
||||
'DEPRECATED method `' + method + '`.' +
|
||||
(instead ? ' Use `' + instead + '` instead.' : '') +
|
||||
' This method will be removed in a future release.');
|
||||
'DEPRECATED method `' +
|
||||
method +
|
||||
'`.' +
|
||||
(instead ? ' Use `' + instead + '` instead.' : '') +
|
||||
' This method will be removed in a future release.'
|
||||
);
|
||||
|
||||
if (docs) {
|
||||
console.warn('For more information about usage see ' + docs);
|
||||
}
|
||||
} catch (e) { /* Ignore */ }
|
||||
} catch (e) {
|
||||
/* Ignore */
|
||||
}
|
||||
}
|
||||
|
||||
2
node_modules/axios/lib/helpers/formDataToJSON.js
generated
vendored
2
node_modules/axios/lib/helpers/formDataToJSON.js
generated
vendored
@@ -14,7 +14,7 @@ function parsePropPath(name) {
|
||||
// foo.x.y.z
|
||||
// foo-x-y-z
|
||||
// foo x y z
|
||||
return utils.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
|
||||
return utils.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
|
||||
return match[0] === '[]' ? '' : match[1] || match[0];
|
||||
});
|
||||
}
|
||||
|
||||
58
node_modules/axios/lib/helpers/formDataToStream.js
generated
vendored
58
node_modules/axios/lib/helpers/formDataToStream.js
generated
vendored
@@ -1,8 +1,8 @@
|
||||
import util from 'util';
|
||||
import {Readable} from 'stream';
|
||||
import utils from "../utils.js";
|
||||
import readBlob from "./readBlob.js";
|
||||
import platform from "../platform/index.js";
|
||||
import { Readable } from 'stream';
|
||||
import utils from '../utils.js';
|
||||
import readBlob from './readBlob.js';
|
||||
import platform from '../platform/index.js';
|
||||
|
||||
const BOUNDARY_ALPHABET = platform.ALPHABET.ALPHA_DIGIT + '-_';
|
||||
|
||||
@@ -14,7 +14,7 @@ const CRLF_BYTES_COUNT = 2;
|
||||
|
||||
class FormDataPart {
|
||||
constructor(name, value) {
|
||||
const {escapeName} = this.constructor;
|
||||
const { escapeName } = this.constructor;
|
||||
const isStringValue = utils.isString(value);
|
||||
|
||||
let headers = `Content-Disposition: form-data; name="${escapeName(name)}"${
|
||||
@@ -24,7 +24,7 @@ class FormDataPart {
|
||||
if (isStringValue) {
|
||||
value = textEncoder.encode(String(value).replace(/\r?\n|\r\n?/g, CRLF));
|
||||
} else {
|
||||
headers += `Content-Type: ${value.type || "application/octet-stream"}${CRLF}`
|
||||
headers += `Content-Type: ${value.type || 'application/octet-stream'}${CRLF}`;
|
||||
}
|
||||
|
||||
this.headers = textEncoder.encode(headers + CRLF);
|
||||
@@ -37,12 +37,12 @@ class FormDataPart {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
async *encode(){
|
||||
async *encode() {
|
||||
yield this.headers;
|
||||
|
||||
const {value} = this;
|
||||
const { value } = this;
|
||||
|
||||
if(utils.isTypedArray(value)) {
|
||||
if (utils.isTypedArray(value)) {
|
||||
yield value;
|
||||
} else {
|
||||
yield* readBlob(value);
|
||||
@@ -52,11 +52,15 @@ class FormDataPart {
|
||||
}
|
||||
|
||||
static escapeName(name) {
|
||||
return String(name).replace(/[\r\n"]/g, (match) => ({
|
||||
'\r' : '%0D',
|
||||
'\n' : '%0A',
|
||||
'"' : '%22',
|
||||
}[match]));
|
||||
return String(name).replace(
|
||||
/[\r\n"]/g,
|
||||
(match) =>
|
||||
({
|
||||
'\r': '%0D',
|
||||
'\n': '%0A',
|
||||
'"': '%22',
|
||||
})[match]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,15 +68,15 @@ const formDataToStream = (form, headersHandler, options) => {
|
||||
const {
|
||||
tag = 'form-data-boundary',
|
||||
size = 25,
|
||||
boundary = tag + '-' + platform.generateString(size, BOUNDARY_ALPHABET)
|
||||
boundary = tag + '-' + platform.generateString(size, BOUNDARY_ALPHABET),
|
||||
} = options || {};
|
||||
|
||||
if(!utils.isFormData(form)) {
|
||||
if (!utils.isFormData(form)) {
|
||||
throw TypeError('FormData instance required');
|
||||
}
|
||||
|
||||
if (boundary.length < 1 || boundary.length > 70) {
|
||||
throw Error('boundary must be 10-70 characters long')
|
||||
throw Error('boundary must be 10-70 characters long');
|
||||
}
|
||||
|
||||
const boundaryBytes = textEncoder.encode('--' + boundary + CRLF);
|
||||
@@ -90,8 +94,8 @@ const formDataToStream = (form, headersHandler, options) => {
|
||||
contentLength = utils.toFiniteNumber(contentLength);
|
||||
|
||||
const computedHeaders = {
|
||||
'Content-Type': `multipart/form-data; boundary=${boundary}`
|
||||
}
|
||||
'Content-Type': `multipart/form-data; boundary=${boundary}`,
|
||||
};
|
||||
|
||||
if (Number.isFinite(contentLength)) {
|
||||
computedHeaders['Content-Length'] = contentLength;
|
||||
@@ -99,14 +103,16 @@ const formDataToStream = (form, headersHandler, options) => {
|
||||
|
||||
headersHandler && headersHandler(computedHeaders);
|
||||
|
||||
return Readable.from((async function *() {
|
||||
for(const part of parts) {
|
||||
yield boundaryBytes;
|
||||
yield* part.encode();
|
||||
}
|
||||
return Readable.from(
|
||||
(async function* () {
|
||||
for (const part of parts) {
|
||||
yield boundaryBytes;
|
||||
yield* part.encode();
|
||||
}
|
||||
|
||||
yield footerBytes;
|
||||
})());
|
||||
yield footerBytes;
|
||||
})()
|
||||
);
|
||||
};
|
||||
|
||||
export default formDataToStream;
|
||||
|
||||
4
node_modules/axios/lib/helpers/fromDataURI.js
generated
vendored
4
node_modules/axios/lib/helpers/fromDataURI.js
generated
vendored
@@ -17,7 +17,7 @@ const DATA_URL_PATTERN = /^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;
|
||||
* @returns {Buffer|Blob}
|
||||
*/
|
||||
export default function fromDataURI(uri, asBlob, options) {
|
||||
const _Blob = options && options.Blob || platform.classes.Blob;
|
||||
const _Blob = (options && options.Blob) || platform.classes.Blob;
|
||||
const protocol = parseProtocol(uri);
|
||||
|
||||
if (asBlob === undefined && _Blob) {
|
||||
@@ -43,7 +43,7 @@ export default function fromDataURI(uri, asBlob, options) {
|
||||
throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT);
|
||||
}
|
||||
|
||||
return new _Blob([buffer], {type: mime});
|
||||
return new _Blob([buffer], { type: mime });
|
||||
}
|
||||
|
||||
return buffer;
|
||||
|
||||
1
node_modules/axios/lib/helpers/isAbsoluteURL.js
generated
vendored
1
node_modules/axios/lib/helpers/isAbsoluteURL.js
generated
vendored
@@ -17,4 +17,3 @@ export default function isAbsoluteURL(url) {
|
||||
|
||||
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
||||
}
|
||||
|
||||
|
||||
2
node_modules/axios/lib/helpers/isAxiosError.js
generated
vendored
2
node_modules/axios/lib/helpers/isAxiosError.js
generated
vendored
@@ -10,5 +10,5 @@ import utils from '../utils.js';
|
||||
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
||||
*/
|
||||
export default function isAxiosError(payload) {
|
||||
return utils.isObject(payload) && (payload.isAxiosError === true);
|
||||
return utils.isObject(payload) && payload.isAxiosError === true;
|
||||
}
|
||||
|
||||
24
node_modules/axios/lib/helpers/isURLSameOrigin.js
generated
vendored
24
node_modules/axios/lib/helpers/isURLSameOrigin.js
generated
vendored
@@ -1,14 +1,16 @@
|
||||
import platform from '../platform/index.js';
|
||||
|
||||
export default platform.hasStandardBrowserEnv ? ((origin, isMSIE) => (url) => {
|
||||
url = new URL(url, platform.origin);
|
||||
export default platform.hasStandardBrowserEnv
|
||||
? ((origin, isMSIE) => (url) => {
|
||||
url = new URL(url, platform.origin);
|
||||
|
||||
return (
|
||||
origin.protocol === url.protocol &&
|
||||
origin.host === url.host &&
|
||||
(isMSIE || origin.port === url.port)
|
||||
);
|
||||
})(
|
||||
new URL(platform.origin),
|
||||
platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
|
||||
) : () => true;
|
||||
return (
|
||||
origin.protocol === url.protocol &&
|
||||
origin.host === url.host &&
|
||||
(isMSIE || origin.port === url.port)
|
||||
);
|
||||
})(
|
||||
new URL(platform.origin),
|
||||
platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
|
||||
)
|
||||
: () => true;
|
||||
|
||||
58
node_modules/axios/lib/helpers/parseHeaders.js
generated
vendored
58
node_modules/axios/lib/helpers/parseHeaders.js
generated
vendored
@@ -5,10 +5,23 @@ import utils from '../utils.js';
|
||||
// RawAxiosHeaders whose duplicates are ignored by node
|
||||
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
||||
const ignoreDuplicateOf = utils.toObjectSet([
|
||||
'age', 'authorization', 'content-length', 'content-type', 'etag',
|
||||
'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
|
||||
'last-modified', 'location', 'max-forwards', 'proxy-authorization',
|
||||
'referer', 'retry-after', 'user-agent'
|
||||
'age',
|
||||
'authorization',
|
||||
'content-length',
|
||||
'content-type',
|
||||
'etag',
|
||||
'expires',
|
||||
'from',
|
||||
'host',
|
||||
'if-modified-since',
|
||||
'if-unmodified-since',
|
||||
'last-modified',
|
||||
'location',
|
||||
'max-forwards',
|
||||
'proxy-authorization',
|
||||
'referer',
|
||||
'retry-after',
|
||||
'user-agent',
|
||||
]);
|
||||
|
||||
/**
|
||||
@@ -25,31 +38,32 @@ const ignoreDuplicateOf = utils.toObjectSet([
|
||||
*
|
||||
* @returns {Object} Headers parsed into an object
|
||||
*/
|
||||
export default rawHeaders => {
|
||||
export default (rawHeaders) => {
|
||||
const parsed = {};
|
||||
let key;
|
||||
let val;
|
||||
let i;
|
||||
|
||||
rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
|
||||
i = line.indexOf(':');
|
||||
key = line.substring(0, i).trim().toLowerCase();
|
||||
val = line.substring(i + 1).trim();
|
||||
rawHeaders &&
|
||||
rawHeaders.split('\n').forEach(function parser(line) {
|
||||
i = line.indexOf(':');
|
||||
key = line.substring(0, i).trim().toLowerCase();
|
||||
val = line.substring(i + 1).trim();
|
||||
|
||||
if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === 'set-cookie') {
|
||||
if (parsed[key]) {
|
||||
parsed[key].push(val);
|
||||
} else {
|
||||
parsed[key] = [val];
|
||||
if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
||||
}
|
||||
});
|
||||
|
||||
if (key === 'set-cookie') {
|
||||
if (parsed[key]) {
|
||||
parsed[key].push(val);
|
||||
} else {
|
||||
parsed[key] = [val];
|
||||
}
|
||||
} else {
|
||||
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
||||
}
|
||||
});
|
||||
|
||||
return parsed;
|
||||
};
|
||||
|
||||
2
node_modules/axios/lib/helpers/parseProtocol.js
generated
vendored
2
node_modules/axios/lib/helpers/parseProtocol.js
generated
vendored
@@ -2,5 +2,5 @@
|
||||
|
||||
export default function parseProtocol(url) {
|
||||
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
||||
return match && match[1] || '';
|
||||
return (match && match[1]) || '';
|
||||
}
|
||||
|
||||
35
node_modules/axios/lib/helpers/progressEventReducer.js
generated
vendored
35
node_modules/axios/lib/helpers/progressEventReducer.js
generated
vendored
@@ -1,12 +1,12 @@
|
||||
import speedometer from "./speedometer.js";
|
||||
import throttle from "./throttle.js";
|
||||
import utils from "../utils.js";
|
||||
import speedometer from './speedometer.js';
|
||||
import throttle from './throttle.js';
|
||||
import utils from '../utils.js';
|
||||
|
||||
export const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
||||
let bytesNotified = 0;
|
||||
const _speedometer = speedometer(50, 250);
|
||||
|
||||
return throttle(e => {
|
||||
return throttle((e) => {
|
||||
const loaded = e.loaded;
|
||||
const total = e.lengthComputable ? e.total : undefined;
|
||||
const progressBytes = loaded - bytesNotified;
|
||||
@@ -18,27 +18,34 @@ export const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
||||
const data = {
|
||||
loaded,
|
||||
total,
|
||||
progress: total ? (loaded / total) : undefined,
|
||||
progress: total ? loaded / total : undefined,
|
||||
bytes: progressBytes,
|
||||
rate: rate ? rate : undefined,
|
||||
estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
|
||||
event: e,
|
||||
lengthComputable: total != null,
|
||||
[isDownloadStream ? 'download' : 'upload']: true
|
||||
[isDownloadStream ? 'download' : 'upload']: true,
|
||||
};
|
||||
|
||||
listener(data);
|
||||
}, freq);
|
||||
}
|
||||
};
|
||||
|
||||
export const progressEventDecorator = (total, throttled) => {
|
||||
const lengthComputable = total != null;
|
||||
|
||||
return [(loaded) => throttled[0]({
|
||||
lengthComputable,
|
||||
total,
|
||||
loaded
|
||||
}), throttled[1]];
|
||||
}
|
||||
return [
|
||||
(loaded) =>
|
||||
throttled[0]({
|
||||
lengthComputable,
|
||||
total,
|
||||
loaded,
|
||||
}),
|
||||
throttled[1],
|
||||
];
|
||||
};
|
||||
|
||||
export const asyncDecorator = (fn) => (...args) => utils.asap(() => fn(...args));
|
||||
export const asyncDecorator =
|
||||
(fn) =>
|
||||
(...args) =>
|
||||
utils.asap(() => fn(...args));
|
||||
|
||||
8
node_modules/axios/lib/helpers/readBlob.js
generated
vendored
8
node_modules/axios/lib/helpers/readBlob.js
generated
vendored
@@ -1,15 +1,15 @@
|
||||
const {asyncIterator} = Symbol;
|
||||
const { asyncIterator } = Symbol;
|
||||
|
||||
const readBlob = async function* (blob) {
|
||||
if (blob.stream) {
|
||||
yield* blob.stream()
|
||||
yield* blob.stream();
|
||||
} else if (blob.arrayBuffer) {
|
||||
yield await blob.arrayBuffer()
|
||||
yield await blob.arrayBuffer();
|
||||
} else if (blob[asyncIterator]) {
|
||||
yield* blob[asyncIterator]();
|
||||
} else {
|
||||
yield blob;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default readBlob;
|
||||
|
||||
37
node_modules/axios/lib/helpers/resolveConfig.js
generated
vendored
37
node_modules/axios/lib/helpers/resolveConfig.js
generated
vendored
@@ -1,11 +1,11 @@
|
||||
import platform from "../platform/index.js";
|
||||
import utils from "../utils.js";
|
||||
import isURLSameOrigin from "./isURLSameOrigin.js";
|
||||
import cookies from "./cookies.js";
|
||||
import buildFullPath from "../core/buildFullPath.js";
|
||||
import mergeConfig from "../core/mergeConfig.js";
|
||||
import AxiosHeaders from "../core/AxiosHeaders.js";
|
||||
import buildURL from "./buildURL.js";
|
||||
import platform from '../platform/index.js';
|
||||
import utils from '../utils.js';
|
||||
import isURLSameOrigin from './isURLSameOrigin.js';
|
||||
import cookies from './cookies.js';
|
||||
import buildFullPath from '../core/buildFullPath.js';
|
||||
import mergeConfig from '../core/mergeConfig.js';
|
||||
import AxiosHeaders from '../core/AxiosHeaders.js';
|
||||
import buildURL from './buildURL.js';
|
||||
|
||||
export default (config) => {
|
||||
const newConfig = mergeConfig({}, config);
|
||||
@@ -14,12 +14,22 @@ export default (config) => {
|
||||
|
||||
newConfig.headers = headers = AxiosHeaders.from(headers);
|
||||
|
||||
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
|
||||
newConfig.url = buildURL(
|
||||
buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls),
|
||||
config.params,
|
||||
config.paramsSerializer
|
||||
);
|
||||
|
||||
// HTTP basic authentication
|
||||
if (auth) {
|
||||
headers.set('Authorization', 'Basic ' +
|
||||
btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : ''))
|
||||
headers.set(
|
||||
'Authorization',
|
||||
'Basic ' +
|
||||
btoa(
|
||||
(auth.username || '') +
|
||||
':' +
|
||||
(auth.password ? unescape(encodeURIComponent(auth.password)) : '')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -37,7 +47,7 @@ export default (config) => {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add xsrf header
|
||||
// This is only done if running in a standard browser environment.
|
||||
@@ -57,5 +67,4 @@ export default (config) => {
|
||||
}
|
||||
|
||||
return newConfig;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
2
node_modules/axios/lib/helpers/speedometer.js
generated
vendored
2
node_modules/axios/lib/helpers/speedometer.js
generated
vendored
@@ -48,7 +48,7 @@ function speedometer(samplesCount, min) {
|
||||
|
||||
const passed = startedAt && now - startedAt;
|
||||
|
||||
return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
|
||||
return passed ? Math.round((bytesCount * 1000) / passed) : undefined;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
8
node_modules/axios/lib/helpers/throttle.js
generated
vendored
8
node_modules/axios/lib/helpers/throttle.js
generated
vendored
@@ -18,23 +18,23 @@ function throttle(fn, freq) {
|
||||
timer = null;
|
||||
}
|
||||
fn(...args);
|
||||
}
|
||||
};
|
||||
|
||||
const throttled = (...args) => {
|
||||
const now = Date.now();
|
||||
const passed = now - timestamp;
|
||||
if ( passed >= threshold) {
|
||||
if (passed >= threshold) {
|
||||
invoke(args, now);
|
||||
} else {
|
||||
lastArgs = args;
|
||||
if (!timer) {
|
||||
timer = setTimeout(() => {
|
||||
timer = null;
|
||||
invoke(lastArgs)
|
||||
invoke(lastArgs);
|
||||
}, threshold - passed);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const flush = () => lastArgs && invoke(lastArgs);
|
||||
|
||||
|
||||
68
node_modules/axios/lib/helpers/toFormData.js
generated
vendored
68
node_modules/axios/lib/helpers/toFormData.js
generated
vendored
@@ -38,11 +38,14 @@ function removeBrackets(key) {
|
||||
*/
|
||||
function renderKey(path, key, dots) {
|
||||
if (!path) return key;
|
||||
return path.concat(key).map(function each(token, i) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
token = removeBrackets(token);
|
||||
return !dots && i ? '[' + token + ']' : token;
|
||||
}).join(dots ? '.' : '');
|
||||
return path
|
||||
.concat(key)
|
||||
.map(function each(token, i) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
token = removeBrackets(token);
|
||||
return !dots && i ? '[' + token + ']' : token;
|
||||
})
|
||||
.join(dots ? '.' : '');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,21 +95,26 @@ function toFormData(obj, formData, options) {
|
||||
formData = formData || new (PlatformFormData || FormData)();
|
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
options = utils.toFlatObject(options, {
|
||||
metaTokens: true,
|
||||
dots: false,
|
||||
indexes: false
|
||||
}, false, function defined(option, source) {
|
||||
// eslint-disable-next-line no-eq-null,eqeqeq
|
||||
return !utils.isUndefined(source[option]);
|
||||
});
|
||||
options = utils.toFlatObject(
|
||||
options,
|
||||
{
|
||||
metaTokens: true,
|
||||
dots: false,
|
||||
indexes: false,
|
||||
},
|
||||
false,
|
||||
function defined(option, source) {
|
||||
// eslint-disable-next-line no-eq-null,eqeqeq
|
||||
return !utils.isUndefined(source[option]);
|
||||
}
|
||||
);
|
||||
|
||||
const metaTokens = options.metaTokens;
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
const visitor = options.visitor || defaultVisitor;
|
||||
const dots = options.dots;
|
||||
const indexes = options.indexes;
|
||||
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
||||
const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
|
||||
const useBlob = _Blob && utils.isSpecCompliantForm(formData);
|
||||
|
||||
if (!utils.isFunction(visitor)) {
|
||||
@@ -148,6 +156,11 @@ function toFormData(obj, formData, options) {
|
||||
function defaultVisitor(value, key, path) {
|
||||
let arr = value;
|
||||
|
||||
if (utils.isReactNative(formData) && utils.isReactNativeBlob(value)) {
|
||||
formData.append(renderKey(path, key, dots), convertValue(value));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value && !path && typeof value === 'object') {
|
||||
if (utils.endsWith(key, '{}')) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
@@ -156,17 +169,22 @@ function toFormData(obj, formData, options) {
|
||||
value = JSON.stringify(value);
|
||||
} else if (
|
||||
(utils.isArray(value) && isFlatArray(value)) ||
|
||||
((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value))
|
||||
)) {
|
||||
((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value)))
|
||||
) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
key = removeBrackets(key);
|
||||
|
||||
arr.forEach(function each(el, index) {
|
||||
!(utils.isUndefined(el) || el === null) && formData.append(
|
||||
// eslint-disable-next-line no-nested-ternary
|
||||
indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
|
||||
convertValue(el)
|
||||
);
|
||||
!(utils.isUndefined(el) || el === null) &&
|
||||
formData.append(
|
||||
// eslint-disable-next-line no-nested-ternary
|
||||
indexes === true
|
||||
? renderKey([key], index, dots)
|
||||
: indexes === null
|
||||
? key
|
||||
: key + '[]',
|
||||
convertValue(el)
|
||||
);
|
||||
});
|
||||
return false;
|
||||
}
|
||||
@@ -186,7 +204,7 @@ function toFormData(obj, formData, options) {
|
||||
const exposedHelpers = Object.assign(predicates, {
|
||||
defaultVisitor,
|
||||
convertValue,
|
||||
isVisitable
|
||||
isVisitable,
|
||||
});
|
||||
|
||||
function build(value, path) {
|
||||
@@ -199,9 +217,9 @@ function toFormData(obj, formData, options) {
|
||||
stack.push(value);
|
||||
|
||||
utils.forEach(value, function each(el, key) {
|
||||
const result = !(utils.isUndefined(el) || el === null) && visitor.call(
|
||||
formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers
|
||||
);
|
||||
const result =
|
||||
!(utils.isUndefined(el) || el === null) &&
|
||||
visitor.call(formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers);
|
||||
|
||||
if (result === true) {
|
||||
build(el, path ? path.concat(key) : [key]);
|
||||
|
||||
4
node_modules/axios/lib/helpers/toURLEncodedForm.js
generated
vendored
4
node_modules/axios/lib/helpers/toURLEncodedForm.js
generated
vendored
@@ -6,7 +6,7 @@ import platform from '../platform/index.js';
|
||||
|
||||
export default function toURLEncodedForm(data, options) {
|
||||
return toFormData(data, new platform.classes.URLSearchParams(), {
|
||||
visitor: function(value, key, path, helpers) {
|
||||
visitor: function (value, key, path, helpers) {
|
||||
if (platform.isNode && utils.isBuffer(value)) {
|
||||
this.append(key, value.toString('base64'));
|
||||
return false;
|
||||
@@ -14,6 +14,6 @@ export default function toURLEncodedForm(data, options) {
|
||||
|
||||
return helpers.defaultVisitor.apply(this, arguments);
|
||||
},
|
||||
...options
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
66
node_modules/axios/lib/helpers/trackStream.js
generated
vendored
66
node_modules/axios/lib/helpers/trackStream.js
generated
vendored
@@ -1,4 +1,3 @@
|
||||
|
||||
export const streamChunk = function* (chunk, chunkSize) {
|
||||
let len = chunk.byteLength;
|
||||
|
||||
@@ -15,13 +14,13 @@ export const streamChunk = function* (chunk, chunkSize) {
|
||||
yield chunk.slice(pos, end);
|
||||
pos = end;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const readBytes = async function* (iterable, chunkSize) {
|
||||
for await (const chunk of readStream(iterable)) {
|
||||
yield* streamChunk(chunk, chunkSize);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const readStream = async function* (stream) {
|
||||
if (stream[Symbol.asyncIterator]) {
|
||||
@@ -32,7 +31,7 @@ const readStream = async function* (stream) {
|
||||
const reader = stream.getReader();
|
||||
try {
|
||||
for (;;) {
|
||||
const {done, value} = await reader.read();
|
||||
const { done, value } = await reader.read();
|
||||
if (done) {
|
||||
break;
|
||||
}
|
||||
@@ -41,7 +40,7 @@ const readStream = async function* (stream) {
|
||||
} finally {
|
||||
await reader.cancel();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
||||
const iterator = readBytes(stream, chunkSize);
|
||||
@@ -53,35 +52,38 @@ export const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
||||
done = true;
|
||||
onFinish && onFinish(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return new ReadableStream({
|
||||
async pull(controller) {
|
||||
try {
|
||||
const {done, value} = await iterator.next();
|
||||
return new ReadableStream(
|
||||
{
|
||||
async pull(controller) {
|
||||
try {
|
||||
const { done, value } = await iterator.next();
|
||||
|
||||
if (done) {
|
||||
_onFinish();
|
||||
controller.close();
|
||||
return;
|
||||
if (done) {
|
||||
_onFinish();
|
||||
controller.close();
|
||||
return;
|
||||
}
|
||||
|
||||
let len = value.byteLength;
|
||||
if (onProgress) {
|
||||
let loadedBytes = (bytes += len);
|
||||
onProgress(loadedBytes);
|
||||
}
|
||||
controller.enqueue(new Uint8Array(value));
|
||||
} catch (err) {
|
||||
_onFinish(err);
|
||||
throw err;
|
||||
}
|
||||
|
||||
let len = value.byteLength;
|
||||
if (onProgress) {
|
||||
let loadedBytes = bytes += len;
|
||||
onProgress(loadedBytes);
|
||||
}
|
||||
controller.enqueue(new Uint8Array(value));
|
||||
} catch (err) {
|
||||
_onFinish(err);
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
cancel(reason) {
|
||||
_onFinish(reason);
|
||||
return iterator.return();
|
||||
},
|
||||
},
|
||||
cancel(reason) {
|
||||
_onFinish(reason);
|
||||
return iterator.return();
|
||||
{
|
||||
highWaterMark: 2,
|
||||
}
|
||||
}, {
|
||||
highWaterMark: 2
|
||||
})
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
21
node_modules/axios/lib/helpers/validator.js
generated
vendored
21
node_modules/axios/lib/helpers/validator.js
generated
vendored
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
import {VERSION} from '../env/data.js';
|
||||
import { VERSION } from '../env/data.js';
|
||||
import AxiosError from '../core/AxiosError.js';
|
||||
|
||||
const validators = {};
|
||||
@@ -25,7 +25,15 @@ const deprecatedWarnings = {};
|
||||
*/
|
||||
validators.transitional = function transitional(validator, version, message) {
|
||||
function formatMessage(opt, desc) {
|
||||
return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
|
||||
return (
|
||||
'[Axios v' +
|
||||
VERSION +
|
||||
"] Transitional option '" +
|
||||
opt +
|
||||
"'" +
|
||||
desc +
|
||||
(message ? '. ' + message : '')
|
||||
);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line func-names
|
||||
@@ -57,7 +65,7 @@ validators.spelling = function spelling(correctSpelling) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -83,7 +91,10 @@ function assertOptions(options, schema, allowUnknown) {
|
||||
const value = options[opt];
|
||||
const result = value === undefined || validator(value, opt, options);
|
||||
if (result !== true) {
|
||||
throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
|
||||
throw new AxiosError(
|
||||
'option ' + opt + ' must be ' + result,
|
||||
AxiosError.ERR_BAD_OPTION_VALUE
|
||||
);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -95,5 +106,5 @@ function assertOptions(options, schema, allowUnknown) {
|
||||
|
||||
export default {
|
||||
assertOptions,
|
||||
validators
|
||||
validators,
|
||||
};
|
||||
|
||||
4
node_modules/axios/lib/platform/browser/classes/Blob.js
generated
vendored
4
node_modules/axios/lib/platform/browser/classes/Blob.js
generated
vendored
@@ -1,3 +1,3 @@
|
||||
'use strict'
|
||||
'use strict';
|
||||
|
||||
export default typeof Blob !== 'undefined' ? Blob : null
|
||||
export default typeof Blob !== 'undefined' ? Blob : null;
|
||||
|
||||
10
node_modules/axios/lib/platform/browser/index.js
generated
vendored
10
node_modules/axios/lib/platform/browser/index.js
generated
vendored
@@ -1,13 +1,13 @@
|
||||
import URLSearchParams from './classes/URLSearchParams.js'
|
||||
import FormData from './classes/FormData.js'
|
||||
import Blob from './classes/Blob.js'
|
||||
import URLSearchParams from './classes/URLSearchParams.js';
|
||||
import FormData from './classes/FormData.js';
|
||||
import Blob from './classes/Blob.js';
|
||||
|
||||
export default {
|
||||
isBrowser: true,
|
||||
classes: {
|
||||
URLSearchParams,
|
||||
FormData,
|
||||
Blob
|
||||
Blob,
|
||||
},
|
||||
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
||||
protocols: ['http', 'https', 'file', 'blob', 'url', 'data'],
|
||||
};
|
||||
|
||||
11
node_modules/axios/lib/platform/common/utils.js
generated
vendored
11
node_modules/axios/lib/platform/common/utils.js
generated
vendored
@@ -1,6 +1,6 @@
|
||||
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
||||
|
||||
const _navigator = typeof navigator === 'object' && navigator || undefined;
|
||||
const _navigator = (typeof navigator === 'object' && navigator) || undefined;
|
||||
|
||||
/**
|
||||
* Determine if we're running in a standard browser environment
|
||||
@@ -19,7 +19,8 @@ const _navigator = typeof navigator === 'object' && navigator || undefined;
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
const hasStandardBrowserEnv = hasBrowserEnv &&
|
||||
const hasStandardBrowserEnv =
|
||||
hasBrowserEnv &&
|
||||
(!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
||||
|
||||
/**
|
||||
@@ -40,12 +41,12 @@ const hasStandardBrowserWebWorkerEnv = (() => {
|
||||
);
|
||||
})();
|
||||
|
||||
const origin = hasBrowserEnv && window.location.href || 'http://localhost';
|
||||
const origin = (hasBrowserEnv && window.location.href) || 'http://localhost';
|
||||
|
||||
export {
|
||||
hasBrowserEnv,
|
||||
hasStandardBrowserWebWorkerEnv,
|
||||
hasStandardBrowserEnv,
|
||||
_navigator as navigator,
|
||||
origin
|
||||
}
|
||||
origin,
|
||||
};
|
||||
|
||||
4
node_modules/axios/lib/platform/index.js
generated
vendored
4
node_modules/axios/lib/platform/index.js
generated
vendored
@@ -3,5 +3,5 @@ import * as utils from './common/utils.js';
|
||||
|
||||
export default {
|
||||
...utils,
|
||||
...platform
|
||||
}
|
||||
...platform,
|
||||
};
|
||||
|
||||
19
node_modules/axios/lib/platform/node/index.js
generated
vendored
19
node_modules/axios/lib/platform/node/index.js
generated
vendored
@@ -1,20 +1,20 @@
|
||||
import crypto from 'crypto';
|
||||
import URLSearchParams from './classes/URLSearchParams.js'
|
||||
import FormData from './classes/FormData.js'
|
||||
import URLSearchParams from './classes/URLSearchParams.js';
|
||||
import FormData from './classes/FormData.js';
|
||||
|
||||
const ALPHA = 'abcdefghijklmnopqrstuvwxyz'
|
||||
const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
|
||||
|
||||
const DIGIT = '0123456789';
|
||||
|
||||
const ALPHABET = {
|
||||
DIGIT,
|
||||
ALPHA,
|
||||
ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
|
||||
}
|
||||
ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT,
|
||||
};
|
||||
|
||||
const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
|
||||
let str = '';
|
||||
const {length} = alphabet;
|
||||
const { length } = alphabet;
|
||||
const randomValues = new Uint32Array(size);
|
||||
crypto.randomFillSync(randomValues);
|
||||
for (let i = 0; i < size; i++) {
|
||||
@@ -22,17 +22,16 @@ const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
export default {
|
||||
isNode: true,
|
||||
classes: {
|
||||
URLSearchParams,
|
||||
FormData,
|
||||
Blob: typeof Blob !== 'undefined' && Blob || null
|
||||
Blob: (typeof Blob !== 'undefined' && Blob) || null,
|
||||
},
|
||||
ALPHABET,
|
||||
generateString,
|
||||
protocols: [ 'http', 'https', 'file', 'data' ]
|
||||
protocols: ['http', 'https', 'file', 'data'],
|
||||
};
|
||||
|
||||
242
node_modules/axios/lib/utils.js
generated
vendored
242
node_modules/axios/lib/utils.js
generated
vendored
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
import bind from "./helpers/bind.js";
|
||||
import bind from './helpers/bind.js';
|
||||
|
||||
// utils is a library of generic helper functions non-specific to axios
|
||||
|
||||
@@ -36,7 +36,7 @@ const { isArray } = Array;
|
||||
*
|
||||
* @returns {boolean} True if the value is undefined, otherwise false
|
||||
*/
|
||||
const isUndefined = typeOfTest("undefined");
|
||||
const isUndefined = typeOfTest('undefined');
|
||||
|
||||
/**
|
||||
* Determine if a value is a Buffer
|
||||
@@ -63,7 +63,7 @@ function isBuffer(val) {
|
||||
*
|
||||
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
||||
*/
|
||||
const isArrayBuffer = kindOfTest("ArrayBuffer");
|
||||
const isArrayBuffer = kindOfTest('ArrayBuffer');
|
||||
|
||||
/**
|
||||
* Determine if a value is a view on an ArrayBuffer
|
||||
@@ -74,7 +74,7 @@ const isArrayBuffer = kindOfTest("ArrayBuffer");
|
||||
*/
|
||||
function isArrayBufferView(val) {
|
||||
let result;
|
||||
if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
|
||||
if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
|
||||
result = ArrayBuffer.isView(val);
|
||||
} else {
|
||||
result = val && val.buffer && isArrayBuffer(val.buffer);
|
||||
@@ -89,7 +89,7 @@ function isArrayBufferView(val) {
|
||||
*
|
||||
* @returns {boolean} True if value is a String, otherwise false
|
||||
*/
|
||||
const isString = typeOfTest("string");
|
||||
const isString = typeOfTest('string');
|
||||
|
||||
/**
|
||||
* Determine if a value is a Function
|
||||
@@ -97,7 +97,7 @@ const isString = typeOfTest("string");
|
||||
* @param {*} val The value to test
|
||||
* @returns {boolean} True if value is a Function, otherwise false
|
||||
*/
|
||||
const isFunction = typeOfTest("function");
|
||||
const isFunction = typeOfTest('function');
|
||||
|
||||
/**
|
||||
* Determine if a value is a Number
|
||||
@@ -106,7 +106,7 @@ const isFunction = typeOfTest("function");
|
||||
*
|
||||
* @returns {boolean} True if value is a Number, otherwise false
|
||||
*/
|
||||
const isNumber = typeOfTest("number");
|
||||
const isNumber = typeOfTest('number');
|
||||
|
||||
/**
|
||||
* Determine if a value is an Object
|
||||
@@ -115,7 +115,7 @@ const isNumber = typeOfTest("number");
|
||||
*
|
||||
* @returns {boolean} True if value is an Object, otherwise false
|
||||
*/
|
||||
const isObject = (thing) => thing !== null && typeof thing === "object";
|
||||
const isObject = (thing) => thing !== null && typeof thing === 'object';
|
||||
|
||||
/**
|
||||
* Determine if a value is a Boolean
|
||||
@@ -133,7 +133,7 @@ const isBoolean = (thing) => thing === true || thing === false;
|
||||
* @returns {boolean} True if value is a plain Object, otherwise false
|
||||
*/
|
||||
const isPlainObject = (val) => {
|
||||
if (kindOf(val) !== "object") {
|
||||
if (kindOf(val) !== 'object') {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -161,10 +161,7 @@ const isEmptyObject = (val) => {
|
||||
}
|
||||
|
||||
try {
|
||||
return (
|
||||
Object.keys(val).length === 0 &&
|
||||
Object.getPrototypeOf(val) === Object.prototype
|
||||
);
|
||||
return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
||||
} catch (e) {
|
||||
// Fallback for any other objects that might cause RangeError with Object.keys()
|
||||
return false;
|
||||
@@ -178,7 +175,7 @@ const isEmptyObject = (val) => {
|
||||
*
|
||||
* @returns {boolean} True if value is a Date, otherwise false
|
||||
*/
|
||||
const isDate = kindOfTest("Date");
|
||||
const isDate = kindOfTest('Date');
|
||||
|
||||
/**
|
||||
* Determine if a value is a File
|
||||
@@ -187,7 +184,32 @@ const isDate = kindOfTest("Date");
|
||||
*
|
||||
* @returns {boolean} True if value is a File, otherwise false
|
||||
*/
|
||||
const isFile = kindOfTest("File");
|
||||
const isFile = kindOfTest('File');
|
||||
|
||||
/**
|
||||
* Determine if a value is a React Native Blob
|
||||
* React Native "blob": an object with a `uri` attribute. Optionally, it can
|
||||
* also have a `name` and `type` attribute to specify filename and content type
|
||||
*
|
||||
* @see https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L68-L71
|
||||
*
|
||||
* @param {*} value The value to test
|
||||
*
|
||||
* @returns {boolean} True if value is a React Native Blob, otherwise false
|
||||
*/
|
||||
const isReactNativeBlob = (value) => {
|
||||
return !!(value && typeof value.uri !== 'undefined');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if environment is React Native
|
||||
* ReactNative `FormData` has a non-standard `getParts()` method
|
||||
*
|
||||
* @param {*} formData The formData to test
|
||||
*
|
||||
* @returns {boolean} True if environment is React Native, otherwise false
|
||||
*/
|
||||
const isReactNative = (formData) => formData && typeof formData.getParts !== 'undefined';
|
||||
|
||||
/**
|
||||
* Determine if a value is a Blob
|
||||
@@ -196,7 +218,7 @@ const isFile = kindOfTest("File");
|
||||
*
|
||||
* @returns {boolean} True if value is a Blob, otherwise false
|
||||
*/
|
||||
const isBlob = kindOfTest("Blob");
|
||||
const isBlob = kindOfTest('Blob');
|
||||
|
||||
/**
|
||||
* Determine if a value is a FileList
|
||||
@@ -205,7 +227,7 @@ const isBlob = kindOfTest("Blob");
|
||||
*
|
||||
* @returns {boolean} True if value is a File, otherwise false
|
||||
*/
|
||||
const isFileList = kindOfTest("FileList");
|
||||
const isFileList = kindOfTest('FileList');
|
||||
|
||||
/**
|
||||
* Determine if a value is a Stream
|
||||
@@ -223,17 +245,27 @@ const isStream = (val) => isObject(val) && isFunction(val.pipe);
|
||||
*
|
||||
* @returns {boolean} True if value is an FormData, otherwise false
|
||||
*/
|
||||
function getGlobal() {
|
||||
if (typeof globalThis !== 'undefined') return globalThis;
|
||||
if (typeof self !== 'undefined') return self;
|
||||
if (typeof window !== 'undefined') return window;
|
||||
if (typeof global !== 'undefined') return global;
|
||||
return {};
|
||||
}
|
||||
|
||||
const G = getGlobal();
|
||||
const FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
|
||||
|
||||
const isFormData = (thing) => {
|
||||
let kind;
|
||||
return (
|
||||
thing &&
|
||||
((typeof FormData === "function" && thing instanceof FormData) ||
|
||||
(isFunction(thing.append) &&
|
||||
((kind = kindOf(thing)) === "formdata" ||
|
||||
// detect form-data instance
|
||||
(kind === "object" &&
|
||||
isFunction(thing.toString) &&
|
||||
thing.toString() === "[object FormData]"))))
|
||||
return thing && (
|
||||
(FormDataCtor && thing instanceof FormDataCtor) || (
|
||||
isFunction(thing.append) && (
|
||||
(kind = kindOf(thing)) === 'formdata' ||
|
||||
// detect form-data instance
|
||||
(kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
|
||||
)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
@@ -244,13 +276,13 @@ const isFormData = (thing) => {
|
||||
*
|
||||
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
|
||||
*/
|
||||
const isURLSearchParams = kindOfTest("URLSearchParams");
|
||||
const isURLSearchParams = kindOfTest('URLSearchParams');
|
||||
|
||||
const [isReadableStream, isRequest, isResponse, isHeaders] = [
|
||||
"ReadableStream",
|
||||
"Request",
|
||||
"Response",
|
||||
"Headers",
|
||||
'ReadableStream',
|
||||
'Request',
|
||||
'Response',
|
||||
'Headers',
|
||||
].map(kindOfTest);
|
||||
|
||||
/**
|
||||
@@ -260,9 +292,9 @@ const [isReadableStream, isRequest, isResponse, isHeaders] = [
|
||||
*
|
||||
* @returns {String} The String freed of excess whitespace
|
||||
*/
|
||||
const trim = (str) =>
|
||||
str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
||||
|
||||
const trim = (str) => {
|
||||
return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
||||
};
|
||||
/**
|
||||
* Iterate over an Array or an Object invoking a function for each item.
|
||||
*
|
||||
@@ -281,7 +313,7 @@ const trim = (str) =>
|
||||
*/
|
||||
function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
||||
// Don't bother if no value provided
|
||||
if (obj === null || typeof obj === "undefined") {
|
||||
if (obj === null || typeof obj === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -289,7 +321,7 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
||||
let l;
|
||||
|
||||
// Force an array if not already something iterable
|
||||
if (typeof obj !== "object") {
|
||||
if (typeof obj !== 'object') {
|
||||
/*eslint no-param-reassign:0*/
|
||||
obj = [obj];
|
||||
}
|
||||
@@ -306,9 +338,7 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
||||
}
|
||||
|
||||
// Iterate over object keys
|
||||
const keys = allOwnKeys
|
||||
? Object.getOwnPropertyNames(obj)
|
||||
: Object.keys(obj);
|
||||
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
||||
const len = keys.length;
|
||||
let key;
|
||||
|
||||
@@ -319,6 +349,14 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a key in an object, case-insensitive, returning the actual key name.
|
||||
* Returns null if the object is a Buffer or if no match is found.
|
||||
*
|
||||
* @param {Object} obj - The object to search.
|
||||
* @param {string} key - The key to find (case-insensitive).
|
||||
* @returns {?string} The actual key name if found, otherwise null.
|
||||
*/
|
||||
function findKey(obj, key) {
|
||||
if (isBuffer(obj)) {
|
||||
return null;
|
||||
@@ -339,16 +377,11 @@ function findKey(obj, key) {
|
||||
|
||||
const _global = (() => {
|
||||
/*eslint no-undef:0*/
|
||||
if (typeof globalThis !== "undefined") return globalThis;
|
||||
return typeof self !== "undefined"
|
||||
? self
|
||||
: typeof window !== "undefined"
|
||||
? window
|
||||
: global;
|
||||
if (typeof globalThis !== 'undefined') return globalThis;
|
||||
return typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : global;
|
||||
})();
|
||||
|
||||
const isContextDefined = (context) =>
|
||||
!isUndefined(context) && context !== _global;
|
||||
const isContextDefined = (context) => !isUndefined(context) && context !== _global;
|
||||
|
||||
/**
|
||||
* Accepts varargs expecting each argument to be an object, then
|
||||
@@ -373,7 +406,7 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
||||
const result = {};
|
||||
const assignValue = (val, key) => {
|
||||
// Skip dangerous property names to prevent prototype pollution
|
||||
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
||||
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -426,7 +459,7 @@ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
|
||||
});
|
||||
}
|
||||
},
|
||||
{ allOwnKeys },
|
||||
{ allOwnKeys }
|
||||
);
|
||||
return a;
|
||||
};
|
||||
@@ -455,17 +488,14 @@ const stripBOM = (content) => {
|
||||
* @returns {void}
|
||||
*/
|
||||
const inherits = (constructor, superConstructor, props, descriptors) => {
|
||||
constructor.prototype = Object.create(
|
||||
superConstructor.prototype,
|
||||
descriptors,
|
||||
);
|
||||
Object.defineProperty(constructor.prototype, "constructor", {
|
||||
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
||||
Object.defineProperty(constructor.prototype, 'constructor', {
|
||||
value: constructor,
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
||||
Object.defineProperty(constructor, "super", {
|
||||
Object.defineProperty(constructor, 'super', {
|
||||
value: superConstructor.prototype,
|
||||
});
|
||||
props && Object.assign(constructor.prototype, props);
|
||||
@@ -495,20 +525,13 @@ const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
|
||||
i = props.length;
|
||||
while (i-- > 0) {
|
||||
prop = props[i];
|
||||
if (
|
||||
(!propFilter || propFilter(prop, sourceObj, destObj)) &&
|
||||
!merged[prop]
|
||||
) {
|
||||
if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
|
||||
destObj[prop] = sourceObj[prop];
|
||||
merged[prop] = true;
|
||||
}
|
||||
}
|
||||
sourceObj = filter !== false && getPrototypeOf(sourceObj);
|
||||
} while (
|
||||
sourceObj &&
|
||||
(!filter || filter(sourceObj, destObj)) &&
|
||||
sourceObj !== Object.prototype
|
||||
);
|
||||
} while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
|
||||
|
||||
return destObj;
|
||||
};
|
||||
@@ -565,7 +588,7 @@ const isTypedArray = ((TypedArray) => {
|
||||
return (thing) => {
|
||||
return TypedArray && thing instanceof TypedArray;
|
||||
};
|
||||
})(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));
|
||||
})(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
|
||||
|
||||
/**
|
||||
* For each entry in the object, call the function with the key and value.
|
||||
@@ -608,14 +631,12 @@ const matchAll = (regExp, str) => {
|
||||
};
|
||||
|
||||
/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
|
||||
const isHTMLForm = kindOfTest("HTMLFormElement");
|
||||
const isHTMLForm = kindOfTest('HTMLFormElement');
|
||||
|
||||
const toCamelCase = (str) => {
|
||||
return str
|
||||
.toLowerCase()
|
||||
.replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
|
||||
return p1.toUpperCase() + p2;
|
||||
});
|
||||
return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
|
||||
return p1.toUpperCase() + p2;
|
||||
});
|
||||
};
|
||||
|
||||
/* Creating a function that will check if an object has a property. */
|
||||
@@ -632,7 +653,7 @@ const hasOwnProperty = (
|
||||
*
|
||||
* @returns {boolean} True if value is a RegExp object, otherwise false
|
||||
*/
|
||||
const isRegExp = kindOfTest("RegExp");
|
||||
const isRegExp = kindOfTest('RegExp');
|
||||
|
||||
const reduceDescriptors = (obj, reducer) => {
|
||||
const descriptors = Object.getOwnPropertyDescriptors(obj);
|
||||
@@ -656,10 +677,7 @@ const reduceDescriptors = (obj, reducer) => {
|
||||
const freezeMethods = (obj) => {
|
||||
reduceDescriptors(obj, (descriptor, name) => {
|
||||
// skip restricted props in strict mode
|
||||
if (
|
||||
isFunction(obj) &&
|
||||
["arguments", "caller", "callee"].indexOf(name) !== -1
|
||||
) {
|
||||
if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -669,7 +687,7 @@ const freezeMethods = (obj) => {
|
||||
|
||||
descriptor.enumerable = false;
|
||||
|
||||
if ("writable" in descriptor) {
|
||||
if ('writable' in descriptor) {
|
||||
descriptor.writable = false;
|
||||
return;
|
||||
}
|
||||
@@ -682,6 +700,14 @@ const freezeMethods = (obj) => {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts an array or a delimited string into an object set with values as keys and true as values.
|
||||
* Useful for fast membership checks.
|
||||
*
|
||||
* @param {Array|string} arrayOrString - The array or string to convert.
|
||||
* @param {string} delimiter - The delimiter to use if input is a string.
|
||||
* @returns {Object} An object with keys from the array or string, values set to true.
|
||||
*/
|
||||
const toObjectSet = (arrayOrString, delimiter) => {
|
||||
const obj = {};
|
||||
|
||||
@@ -691,9 +717,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
|
||||
});
|
||||
};
|
||||
|
||||
isArray(arrayOrString)
|
||||
? define(arrayOrString)
|
||||
: define(String(arrayOrString).split(delimiter));
|
||||
isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
|
||||
|
||||
return obj;
|
||||
};
|
||||
@@ -701,9 +725,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
|
||||
const noop = () => {};
|
||||
|
||||
const toFiniteNumber = (value, defaultValue) => {
|
||||
return value != null && Number.isFinite((value = +value))
|
||||
? value
|
||||
: defaultValue;
|
||||
return value != null && Number.isFinite((value = +value)) ? value : defaultValue;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -717,11 +739,17 @@ function isSpecCompliantForm(thing) {
|
||||
return !!(
|
||||
thing &&
|
||||
isFunction(thing.append) &&
|
||||
thing[toStringTag] === "FormData" &&
|
||||
thing[toStringTag] === 'FormData' &&
|
||||
thing[iterator]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively converts an object to a JSON-compatible object, handling circular references and Buffers.
|
||||
*
|
||||
* @param {Object} obj - The object to convert.
|
||||
* @returns {Object} The JSON-compatible object.
|
||||
*/
|
||||
const toJSONObject = (obj) => {
|
||||
const stack = new Array(10);
|
||||
|
||||
@@ -736,7 +764,7 @@ const toJSONObject = (obj) => {
|
||||
return source;
|
||||
}
|
||||
|
||||
if (!("toJSON" in source)) {
|
||||
if (!('toJSON' in source)) {
|
||||
stack[i] = source;
|
||||
const target = isArray(source) ? [] : {};
|
||||
|
||||
@@ -757,8 +785,20 @@ const toJSONObject = (obj) => {
|
||||
return visit(obj, 0);
|
||||
};
|
||||
|
||||
const isAsyncFn = kindOfTest("AsyncFunction");
|
||||
/**
|
||||
* Determines if a value is an async function.
|
||||
*
|
||||
* @param {*} thing - The value to test.
|
||||
* @returns {boolean} True if value is an async function, otherwise false.
|
||||
*/
|
||||
const isAsyncFn = kindOfTest('AsyncFunction');
|
||||
|
||||
/**
|
||||
* Determines if a value is thenable (has then and catch methods).
|
||||
*
|
||||
* @param {*} thing - The value to test.
|
||||
* @returns {boolean} True if value is thenable, otherwise false.
|
||||
*/
|
||||
const isThenable = (thing) =>
|
||||
thing &&
|
||||
(isObject(thing) || isFunction(thing)) &&
|
||||
@@ -768,6 +808,14 @@ const isThenable = (thing) =>
|
||||
// original code
|
||||
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
||||
|
||||
/**
|
||||
* Provides a cross-platform setImmediate implementation.
|
||||
* Uses native setImmediate if available, otherwise falls back to postMessage or setTimeout.
|
||||
*
|
||||
* @param {boolean} setImmediateSupported - Whether setImmediate is supported.
|
||||
* @param {boolean} postMessageSupported - Whether postMessage is supported.
|
||||
* @returns {Function} A function to schedule a callback asynchronously.
|
||||
*/
|
||||
const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
||||
if (setImmediateSupported) {
|
||||
return setImmediate;
|
||||
@@ -776,27 +824,33 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
||||
return postMessageSupported
|
||||
? ((token, callbacks) => {
|
||||
_global.addEventListener(
|
||||
"message",
|
||||
'message',
|
||||
({ source, data }) => {
|
||||
if (source === _global && data === token) {
|
||||
callbacks.length && callbacks.shift()();
|
||||
}
|
||||
},
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
return (cb) => {
|
||||
callbacks.push(cb);
|
||||
_global.postMessage(token, "*");
|
||||
_global.postMessage(token, '*');
|
||||
};
|
||||
})(`axios@${Math.random()}`, [])
|
||||
: (cb) => setTimeout(cb);
|
||||
})(typeof setImmediate === "function", isFunction(_global.postMessage));
|
||||
})(typeof setImmediate === 'function', isFunction(_global.postMessage));
|
||||
|
||||
/**
|
||||
* Schedules a microtask or asynchronous callback as soon as possible.
|
||||
* Uses queueMicrotask if available, otherwise falls back to process.nextTick or _setImmediate.
|
||||
*
|
||||
* @type {Function}
|
||||
*/
|
||||
const asap =
|
||||
typeof queueMicrotask !== "undefined"
|
||||
typeof queueMicrotask !== 'undefined'
|
||||
? queueMicrotask.bind(_global)
|
||||
: (typeof process !== "undefined" && process.nextTick) || _setImmediate;
|
||||
: (typeof process !== 'undefined' && process.nextTick) || _setImmediate;
|
||||
|
||||
// *********************
|
||||
|
||||
@@ -821,6 +875,8 @@ export default {
|
||||
isUndefined,
|
||||
isDate,
|
||||
isFile,
|
||||
isReactNativeBlob,
|
||||
isReactNative,
|
||||
isBlob,
|
||||
isRegExp,
|
||||
isFunction,
|
||||
|
||||
Reference in New Issue
Block a user