@wiajs/req 1.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +1023 -0
  2. package/LICENSE +7 -0
  3. package/MIGRATION_GUIDE.md +3 -0
  4. package/README.md +1645 -0
  5. package/SECURITY.md +6 -0
  6. package/dist/node/req.cjs +4397 -0
  7. package/dist/node/req.mjs +3551 -0
  8. package/dist/web/req.mjs +2609 -0
  9. package/index.d.cts +545 -0
  10. package/index.d.ts +565 -0
  11. package/index.js +43 -0
  12. package/lib/adapters/README.md +37 -0
  13. package/lib/adapters/adapters.js +57 -0
  14. package/lib/adapters/fetch.js +229 -0
  15. package/lib/adapters/http.js +552 -0
  16. package/lib/adapters/xhr.js +200 -0
  17. package/lib/axios.js +89 -0
  18. package/lib/cancel/CancelToken.js +106 -0
  19. package/lib/cancel/CanceledError.js +20 -0
  20. package/lib/cancel/isCancel.js +4 -0
  21. package/lib/core/Axios.js +359 -0
  22. package/lib/core/AxiosError.js +89 -0
  23. package/lib/core/AxiosHeaders.js +243 -0
  24. package/lib/core/InterceptorManager.js +59 -0
  25. package/lib/core/README.md +8 -0
  26. package/lib/core/buildFullPath.js +18 -0
  27. package/lib/core/dispatchRequest.js +72 -0
  28. package/lib/core/mergeConfig.js +98 -0
  29. package/lib/core/settle.js +21 -0
  30. package/lib/core/transformData.js +22 -0
  31. package/lib/defaults/index.js +136 -0
  32. package/lib/defaults/transitional.js +6 -0
  33. package/lib/env/README.md +3 -0
  34. package/lib/env/classes/FormData.js +2 -0
  35. package/lib/env/data.js +1 -0
  36. package/lib/helpers/AxiosTransformStream.js +116 -0
  37. package/lib/helpers/AxiosURLSearchParams.js +50 -0
  38. package/lib/helpers/HttpStatusCode.js +69 -0
  39. package/lib/helpers/README.md +7 -0
  40. package/lib/helpers/ZlibHeaderTransformStream.js +22 -0
  41. package/lib/helpers/bind.js +6 -0
  42. package/lib/helpers/buildURL.js +42 -0
  43. package/lib/helpers/callbackify.js +14 -0
  44. package/lib/helpers/combineURLs.js +11 -0
  45. package/lib/helpers/composeSignals.js +37 -0
  46. package/lib/helpers/cookies.js +29 -0
  47. package/lib/helpers/deprecatedMethod.js +18 -0
  48. package/lib/helpers/formDataToJSON.js +78 -0
  49. package/lib/helpers/formDataToStream.js +77 -0
  50. package/lib/helpers/fromDataURI.js +44 -0
  51. package/lib/helpers/isAbsoluteURL.js +13 -0
  52. package/lib/helpers/isAxiosError.js +11 -0
  53. package/lib/helpers/isURLSameOrigin.js +50 -0
  54. package/lib/helpers/null.js +2 -0
  55. package/lib/helpers/parseHeaders.js +61 -0
  56. package/lib/helpers/parseProtocol.js +5 -0
  57. package/lib/helpers/progressEventReducer.js +54 -0
  58. package/lib/helpers/readBlob.js +13 -0
  59. package/lib/helpers/resolveConfig.js +45 -0
  60. package/lib/helpers/speedometer.js +40 -0
  61. package/lib/helpers/spread.js +26 -0
  62. package/lib/helpers/throttle.js +41 -0
  63. package/lib/helpers/toFormData.js +175 -0
  64. package/lib/helpers/toURLEncodedForm.js +15 -0
  65. package/lib/helpers/trackStream.js +75 -0
  66. package/lib/helpers/validator.js +84 -0
  67. package/lib/platform/browser/classes/Blob.js +2 -0
  68. package/lib/platform/browser/classes/FormData.js +2 -0
  69. package/lib/platform/browser/classes/URLSearchParams.js +3 -0
  70. package/lib/platform/browser/index.js +19 -0
  71. package/lib/platform/common/utils.js +37 -0
  72. package/lib/platform/index.js +6 -0
  73. package/lib/platform/node/classes/FormData.js +2 -0
  74. package/lib/platform/node/classes/URLSearchParams.js +3 -0
  75. package/lib/platform/node/index.js +16 -0
  76. package/lib/req.js +67 -0
  77. package/lib/utils.js +635 -0
  78. package/package.json +214 -0
@@ -0,0 +1,13 @@
1
+ const { asyncIterator } = Symbol;
2
+ const readBlob = async function*(blob) {
3
+ if (blob.stream) {
4
+ yield* blob.stream();
5
+ } else if (blob.arrayBuffer) {
6
+ yield await blob.arrayBuffer();
7
+ } else if (blob[asyncIterator]) {
8
+ yield* blob[asyncIterator]();
9
+ } else {
10
+ yield blob;
11
+ }
12
+ };
13
+ export default readBlob;
@@ -0,0 +1,45 @@
1
+ import platform from "../platform/index.js";
2
+ import utils from "../utils.js";
3
+ import isURLSameOrigin from "./isURLSameOrigin.js";
4
+ import cookies from "./cookies.js";
5
+ import buildFullPath from "../core/buildFullPath.js";
6
+ import mergeConfig from "../core/mergeConfig.js";
7
+ import AxiosHeaders from "../core/AxiosHeaders.js";
8
+ import buildURL from "./buildURL.js";
9
+ export default ((config)=>{
10
+ const newConfig = mergeConfig({}, config);
11
+ let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
12
+ newConfig.headers = headers = AxiosHeaders.from(headers);
13
+ newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
14
+ // HTTP basic authentication
15
+ if (auth) {
16
+ headers.set('Authorization', 'Basic ' + btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : '')));
17
+ }
18
+ let contentType;
19
+ if (utils.isFormData(data)) {
20
+ if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
21
+ headers.setContentType(undefined); // Let the browser set it
22
+ } else if ((contentType = headers.getContentType()) !== false) {
23
+ // fix semicolon duplication issue for ReactNative FormData implementation
24
+ const [type, ...tokens] = contentType ? contentType.split(';').map((token)=>token.trim()).filter(Boolean) : [];
25
+ headers.setContentType([
26
+ type || 'multipart/form-data',
27
+ ...tokens
28
+ ].join('; '));
29
+ }
30
+ }
31
+ // Add xsrf header
32
+ // This is only done if running in a standard browser environment.
33
+ // Specifically not if we're in a web worker, or react-native.
34
+ if (platform.hasStandardBrowserEnv) {
35
+ withXSRFToken && utils.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
36
+ if (withXSRFToken || withXSRFToken !== false && isURLSameOrigin(newConfig.url)) {
37
+ // Add xsrf header
38
+ const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
39
+ if (xsrfValue) {
40
+ headers.set(xsrfHeaderName, xsrfValue);
41
+ }
42
+ }
43
+ }
44
+ return newConfig;
45
+ });
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+ /**
3
+ * Calculate data maxRate
4
+ * @param {Number} [samplesCount= 10]
5
+ * @param {Number} [min= 1000]
6
+ * @returns {Function}
7
+ */ function speedometer(samplesCount, min) {
8
+ samplesCount = samplesCount || 10;
9
+ const bytes = new Array(samplesCount);
10
+ const timestamps = new Array(samplesCount);
11
+ let head = 0;
12
+ let tail = 0;
13
+ let firstSampleTS;
14
+ min = min !== undefined ? min : 1000;
15
+ return function push(chunkLength) {
16
+ const now = Date.now();
17
+ const startedAt = timestamps[tail];
18
+ if (!firstSampleTS) {
19
+ firstSampleTS = now;
20
+ }
21
+ bytes[head] = chunkLength;
22
+ timestamps[head] = now;
23
+ let i = tail;
24
+ let bytesCount = 0;
25
+ while(i !== head){
26
+ bytesCount += bytes[i++];
27
+ i = i % samplesCount;
28
+ }
29
+ head = (head + 1) % samplesCount;
30
+ if (head === tail) {
31
+ tail = (tail + 1) % samplesCount;
32
+ }
33
+ if (now - firstSampleTS < min) {
34
+ return;
35
+ }
36
+ const passed = startedAt && now - startedAt;
37
+ return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
38
+ };
39
+ }
40
+ export default speedometer;
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+ /**
3
+ * Syntactic sugar for invoking a function and expanding an array for arguments.
4
+ *
5
+ * Common use case would be to use `Function.prototype.apply`.
6
+ *
7
+ * ```js
8
+ * function f(x, y, z) {}
9
+ * var args = [1, 2, 3];
10
+ * f.apply(null, args);
11
+ * ```
12
+ *
13
+ * With `spread` this example can be re-written.
14
+ *
15
+ * ```js
16
+ * spread(function(x, y, z) {})([1, 2, 3]);
17
+ * ```
18
+ *
19
+ * @param {Function} callback
20
+ *
21
+ * @returns {Function}
22
+ */ export default function spread(callback) {
23
+ return function wrap(arr) {
24
+ return callback.apply(null, arr);
25
+ };
26
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Throttle decorator
3
+ * @param {Function} fn
4
+ * @param {Number} freq
5
+ * @return {Function}
6
+ */ function throttle(fn, freq) {
7
+ let timestamp = 0;
8
+ let threshold = 1000 / freq;
9
+ let lastArgs;
10
+ let timer;
11
+ const invoke = (args, now = Date.now())=>{
12
+ timestamp = now;
13
+ lastArgs = null;
14
+ if (timer) {
15
+ clearTimeout(timer);
16
+ timer = null;
17
+ }
18
+ fn.apply(null, args);
19
+ };
20
+ const throttled = (...args)=>{
21
+ const now = Date.now();
22
+ const passed = now - timestamp;
23
+ if (passed >= threshold) {
24
+ invoke(args, now);
25
+ } else {
26
+ lastArgs = args;
27
+ if (!timer) {
28
+ timer = setTimeout(()=>{
29
+ timer = null;
30
+ invoke(lastArgs);
31
+ }, threshold - passed);
32
+ }
33
+ }
34
+ };
35
+ const flush = ()=>lastArgs && invoke(lastArgs);
36
+ return [
37
+ throttled,
38
+ flush
39
+ ];
40
+ }
41
+ export default throttle;
@@ -0,0 +1,175 @@
1
+ 'use strict';
2
+ import utils from '../utils.js';
3
+ import AxiosError from '../core/AxiosError.js';
4
+ // temporary hotfix to avoid circular references until AxiosURLSearchParams is refactored
5
+ import PlatformFormData from '../platform/node/classes/FormData.js';
6
+ /**
7
+ * Determines if the given thing is a array or js object.
8
+ *
9
+ * @param {string} thing - The object or array to be visited.
10
+ *
11
+ * @returns {boolean}
12
+ */ function isVisitable(thing) {
13
+ return utils.isPlainObject(thing) || utils.isArray(thing);
14
+ }
15
+ /**
16
+ * It removes the brackets from the end of a string
17
+ *
18
+ * @param {string} key - The key of the parameter.
19
+ *
20
+ * @returns {string} the key without the brackets.
21
+ */ function removeBrackets(key) {
22
+ return utils.endsWith(key, '[]') ? key.slice(0, -2) : key;
23
+ }
24
+ /**
25
+ * It takes a path, a key, and a boolean, and returns a string
26
+ *
27
+ * @param {string} path - The path to the current key.
28
+ * @param {string} key - The key of the current object being iterated over.
29
+ * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
30
+ *
31
+ * @returns {string} The path to the current key.
32
+ */ function renderKey(path, key, dots) {
33
+ if (!path) return key;
34
+ return path.concat(key).map(function each(token, i) {
35
+ // eslint-disable-next-line no-param-reassign
36
+ token = removeBrackets(token);
37
+ return !dots && i ? '[' + token + ']' : token;
38
+ }).join(dots ? '.' : '');
39
+ }
40
+ /**
41
+ * If the array is an array and none of its elements are visitable, then it's a flat array.
42
+ *
43
+ * @param {Array<any>} arr - The array to check
44
+ *
45
+ * @returns {boolean}
46
+ */ function isFlatArray(arr) {
47
+ return utils.isArray(arr) && !arr.some(isVisitable);
48
+ }
49
+ const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
50
+ return /^is[A-Z]/.test(prop);
51
+ });
52
+ /**
53
+ * Convert a data object to FormData
54
+ *
55
+ * @param {Object} obj
56
+ * @param {?Object} [formData]
57
+ * @param {?Object} [options]
58
+ * @param {Function} [options.visitor]
59
+ * @param {Boolean} [options.metaTokens = true]
60
+ * @param {Boolean} [options.dots = false]
61
+ * @param {?Boolean} [options.indexes = false]
62
+ *
63
+ * @returns {Object}
64
+ **/ /**
65
+ * It converts an object into a FormData object
66
+ *
67
+ * @param {Object<any, any>} obj - The object to convert to form data.
68
+ * @param {string} formData - The FormData object to append to.
69
+ * @param {Object<string, any>} options
70
+ *
71
+ * @returns
72
+ */ function toFormData(obj, formData, options) {
73
+ if (!utils.isObject(obj)) {
74
+ throw new TypeError('target must be an object');
75
+ }
76
+ // eslint-disable-next-line no-param-reassign
77
+ formData = formData || new (PlatformFormData || FormData)();
78
+ // eslint-disable-next-line no-param-reassign
79
+ options = utils.toFlatObject(options, {
80
+ metaTokens: true,
81
+ dots: false,
82
+ indexes: false
83
+ }, false, function defined(option, source) {
84
+ // eslint-disable-next-line no-eq-null,eqeqeq
85
+ return !utils.isUndefined(source[option]);
86
+ });
87
+ const metaTokens = options.metaTokens;
88
+ // eslint-disable-next-line no-use-before-define
89
+ const visitor = options.visitor || defaultVisitor;
90
+ const dots = options.dots;
91
+ const indexes = options.indexes;
92
+ const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
93
+ const useBlob = _Blob && utils.isSpecCompliantForm(formData);
94
+ if (!utils.isFunction(visitor)) {
95
+ throw new TypeError('visitor must be a function');
96
+ }
97
+ function convertValue(value) {
98
+ if (value === null) return '';
99
+ if (utils.isDate(value)) {
100
+ return value.toISOString();
101
+ }
102
+ if (!useBlob && utils.isBlob(value)) {
103
+ throw new AxiosError('Blob is not supported. Use a Buffer instead.');
104
+ }
105
+ if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
106
+ return useBlob && typeof Blob === 'function' ? new Blob([
107
+ value
108
+ ]) : Buffer.from(value);
109
+ }
110
+ return value;
111
+ }
112
+ /**
113
+ * Default visitor.
114
+ *
115
+ * @param {*} value
116
+ * @param {String|Number} key
117
+ * @param {Array<String|Number>} path
118
+ * @this {FormData}
119
+ *
120
+ * @returns {boolean} return true to visit the each prop of the value recursively
121
+ */ function defaultVisitor(value, key, path) {
122
+ let arr = value;
123
+ if (value && !path && typeof value === 'object') {
124
+ if (utils.endsWith(key, '{}')) {
125
+ // eslint-disable-next-line no-param-reassign
126
+ key = metaTokens ? key : key.slice(0, -2);
127
+ // eslint-disable-next-line no-param-reassign
128
+ value = JSON.stringify(value);
129
+ } else if (utils.isArray(value) && isFlatArray(value) || (utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value))) {
130
+ // eslint-disable-next-line no-param-reassign
131
+ key = removeBrackets(key);
132
+ arr.forEach(function each(el, index) {
133
+ !(utils.isUndefined(el) || el === null) && formData.append(// eslint-disable-next-line no-nested-ternary
134
+ indexes === true ? renderKey([
135
+ key
136
+ ], index, dots) : indexes === null ? key : key + '[]', convertValue(el));
137
+ });
138
+ return false;
139
+ }
140
+ }
141
+ if (isVisitable(value)) {
142
+ return true;
143
+ }
144
+ formData.append(renderKey(path, key, dots), convertValue(value));
145
+ return false;
146
+ }
147
+ const stack = [];
148
+ const exposedHelpers = Object.assign(predicates, {
149
+ defaultVisitor,
150
+ convertValue,
151
+ isVisitable
152
+ });
153
+ function build(value, path) {
154
+ if (utils.isUndefined(value)) return;
155
+ if (stack.indexOf(value) !== -1) {
156
+ throw Error('Circular reference detected in ' + path.join('.'));
157
+ }
158
+ stack.push(value);
159
+ utils.forEach(value, function each(el, key) {
160
+ const result = !(utils.isUndefined(el) || el === null) && visitor.call(formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers);
161
+ if (result === true) {
162
+ build(el, path ? path.concat(key) : [
163
+ key
164
+ ]);
165
+ }
166
+ });
167
+ stack.pop();
168
+ }
169
+ if (!utils.isObject(obj)) {
170
+ throw new TypeError('data must be an object');
171
+ }
172
+ build(obj);
173
+ return formData;
174
+ }
175
+ export default toFormData;
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+ import utils from '../utils.js';
3
+ import toFormData from './toFormData.js';
4
+ import platform from '../platform/index.js';
5
+ export default function toURLEncodedForm(data, options) {
6
+ return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
7
+ visitor: function(value, key, path, helpers) {
8
+ if (platform.isNode && utils.isBuffer(value)) {
9
+ this.append(key, value.toString('base64'));
10
+ return false;
11
+ }
12
+ return helpers.defaultVisitor.apply(this, arguments);
13
+ }
14
+ }, options));
15
+ }
@@ -0,0 +1,75 @@
1
+ export const streamChunk = function*(chunk, chunkSize) {
2
+ let len = chunk.byteLength;
3
+ if (!chunkSize || len < chunkSize) {
4
+ yield chunk;
5
+ return;
6
+ }
7
+ let pos = 0;
8
+ let end;
9
+ while(pos < len){
10
+ end = pos + chunkSize;
11
+ yield chunk.slice(pos, end);
12
+ pos = end;
13
+ }
14
+ };
15
+ export const readBytes = async function*(iterable, chunkSize) {
16
+ for await (const chunk of readStream(iterable)){
17
+ yield* streamChunk(chunk, chunkSize);
18
+ }
19
+ };
20
+ const readStream = async function*(stream) {
21
+ if (stream[Symbol.asyncIterator]) {
22
+ yield* stream;
23
+ return;
24
+ }
25
+ const reader = stream.getReader();
26
+ try {
27
+ for(;;){
28
+ const { done, value } = await reader.read();
29
+ if (done) {
30
+ break;
31
+ }
32
+ yield value;
33
+ }
34
+ } finally{
35
+ await reader.cancel();
36
+ }
37
+ };
38
+ export const trackStream = (stream, chunkSize, onProgress, onFinish)=>{
39
+ const iterator = readBytes(stream, chunkSize);
40
+ let bytes = 0;
41
+ let done;
42
+ let _onFinish = (e)=>{
43
+ if (!done) {
44
+ done = true;
45
+ onFinish && onFinish(e);
46
+ }
47
+ };
48
+ return new ReadableStream({
49
+ async pull (controller) {
50
+ try {
51
+ const { done, value } = await iterator.next();
52
+ if (done) {
53
+ _onFinish();
54
+ controller.close();
55
+ return;
56
+ }
57
+ let len = value.byteLength;
58
+ if (onProgress) {
59
+ let loadedBytes = bytes += len;
60
+ onProgress(loadedBytes);
61
+ }
62
+ controller.enqueue(new Uint8Array(value));
63
+ } catch (err) {
64
+ _onFinish(err);
65
+ throw err;
66
+ }
67
+ },
68
+ cancel (reason) {
69
+ _onFinish(reason);
70
+ return iterator.return();
71
+ }
72
+ }, {
73
+ highWaterMark: 2
74
+ });
75
+ };
@@ -0,0 +1,84 @@
1
+ 'use strict';
2
+ import { VERSION } from '../env/data.js';
3
+ import AxiosError from '../core/AxiosError.js';
4
+ const validators = {};
5
+ // eslint-disable-next-line func-names
6
+ [
7
+ 'object',
8
+ 'boolean',
9
+ 'number',
10
+ 'function',
11
+ 'string',
12
+ 'symbol'
13
+ ].forEach((type, i)=>{
14
+ validators[type] = function validator(thing) {
15
+ return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
16
+ };
17
+ });
18
+ const deprecatedWarnings = {};
19
+ /**
20
+ * Transitional option validator
21
+ *
22
+ * @param {function|boolean?} validator - set to false if the transitional option has been removed
23
+ * @param {string?} version - deprecated version / removed since version
24
+ * @param {string?} message - some message with additional info
25
+ *
26
+ * @returns {function}
27
+ */ validators.transitional = function transitional(validator, version, message) {
28
+ function formatMessage(opt, desc) {
29
+ return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
30
+ }
31
+ // eslint-disable-next-line func-names
32
+ return (value, opt, opts)=>{
33
+ if (validator === false) {
34
+ throw new AxiosError(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')), AxiosError.ERR_DEPRECATED);
35
+ }
36
+ if (version && !deprecatedWarnings[opt]) {
37
+ deprecatedWarnings[opt] = true;
38
+ // eslint-disable-next-line no-console
39
+ console.warn(formatMessage(opt, ' has been deprecated since v' + version + ' and will be removed in the near future'));
40
+ }
41
+ return validator ? validator(value, opt, opts) : true;
42
+ };
43
+ };
44
+ validators.spelling = function spelling(correctSpelling) {
45
+ return (value, opt)=>{
46
+ // eslint-disable-next-line no-console
47
+ console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
48
+ return true;
49
+ };
50
+ };
51
+ /**
52
+ * Assert object's properties type
53
+ *
54
+ * @param {object} options
55
+ * @param {object} schema
56
+ * @param {boolean?} allowUnknown
57
+ *
58
+ * @returns {object}
59
+ */ function assertOptions(options, schema, allowUnknown) {
60
+ if (typeof options !== 'object') {
61
+ throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
62
+ }
63
+ const keys = Object.keys(options);
64
+ let i = keys.length;
65
+ while(i-- > 0){
66
+ const opt = keys[i];
67
+ const validator = schema[opt];
68
+ if (validator) {
69
+ const value = options[opt];
70
+ const result = value === undefined || validator(value, opt, options);
71
+ if (result !== true) {
72
+ throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
73
+ }
74
+ continue;
75
+ }
76
+ if (allowUnknown !== true) {
77
+ throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
78
+ }
79
+ }
80
+ }
81
+ export default {
82
+ assertOptions,
83
+ validators
84
+ };
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+ export default typeof Blob !== 'undefined' ? Blob : null;
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+ export default typeof FormData !== 'undefined' ? FormData : null;
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+ import AxiosURLSearchParams from '../../../helpers/AxiosURLSearchParams.js';
3
+ export default typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
@@ -0,0 +1,19 @@
1
+ import URLSearchParams from './classes/URLSearchParams.js';
2
+ import FormData from './classes/FormData.js';
3
+ import Blob from './classes/Blob.js';
4
+ export default {
5
+ isBrowser: true,
6
+ classes: {
7
+ URLSearchParams,
8
+ FormData,
9
+ Blob
10
+ },
11
+ protocols: [
12
+ 'http',
13
+ 'https',
14
+ 'file',
15
+ 'blob',
16
+ 'url',
17
+ 'data'
18
+ ]
19
+ };
@@ -0,0 +1,37 @@
1
+ const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
2
+ const _navigator = typeof navigator === 'object' && navigator || undefined;
3
+ /**
4
+ * Determine if we're running in a standard browser environment
5
+ *
6
+ * This allows axios to run in a web worker, and react-native.
7
+ * Both environments support XMLHttpRequest, but not fully standard globals.
8
+ *
9
+ * web workers:
10
+ * typeof window -> undefined
11
+ * typeof document -> undefined
12
+ *
13
+ * react-native:
14
+ * navigator.product -> 'ReactNative'
15
+ * nativescript
16
+ * navigator.product -> 'NativeScript' or 'NS'
17
+ *
18
+ * @returns {boolean}
19
+ */ const hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || [
20
+ 'ReactNative',
21
+ 'NativeScript',
22
+ 'NS'
23
+ ].indexOf(_navigator.product) < 0);
24
+ /**
25
+ * Determine if we're running in a standard browser webWorker environment
26
+ *
27
+ * Although the `isStandardBrowserEnv` method indicates that
28
+ * `allows axios to run in a web worker`, the WebWorker will still be
29
+ * filtered out due to its judgment standard
30
+ * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
31
+ * This leads to a problem when axios post `FormData` in webWorker
32
+ */ const hasStandardBrowserWebWorkerEnv = (()=>{
33
+ return typeof WorkerGlobalScope !== 'undefined' && // eslint-disable-next-line no-undef
34
+ self instanceof WorkerGlobalScope && typeof self.importScripts === 'function';
35
+ })();
36
+ const origin = hasBrowserEnv && window.location.href || 'http://localhost';
37
+ export { hasBrowserEnv, hasStandardBrowserWebWorkerEnv, hasStandardBrowserEnv, _navigator as navigator, origin };
@@ -0,0 +1,6 @@
1
+ import platform from './node/index.js';
2
+ import * as utils from './common/utils.js';
3
+ export default {
4
+ ...utils,
5
+ ...platform
6
+ };
@@ -0,0 +1,2 @@
1
+ import FormData from 'form-data';
2
+ export default FormData;
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+ import url from 'url';
3
+ export default url.URLSearchParams;
@@ -0,0 +1,16 @@
1
+ import URLSearchParams from './classes/URLSearchParams.js';
2
+ import FormData from './classes/FormData.js';
3
+ export default {
4
+ isNode: true,
5
+ classes: {
6
+ URLSearchParams,
7
+ FormData,
8
+ Blob: typeof Blob !== 'undefined' && Blob || null
9
+ },
10
+ protocols: [
11
+ 'http',
12
+ 'https',
13
+ 'file',
14
+ 'data'
15
+ ]
16
+ };