axios 1.0.0-alpha.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of axios might be problematic. Click here for more details.

Files changed (70) hide show
  1. package/CHANGELOG.md +74 -1
  2. package/README.md +59 -48
  3. package/SECURITY.md +3 -2
  4. package/bin/ssl_hotfix.js +1 -1
  5. package/dist/axios.js +1564 -981
  6. package/dist/axios.js.map +1 -1
  7. package/dist/axios.min.js +1 -1
  8. package/dist/axios.min.js.map +1 -1
  9. package/dist/esm/axios.js +1472 -866
  10. package/dist/esm/axios.js.map +1 -1
  11. package/dist/esm/axios.min.js +1 -1
  12. package/dist/esm/axios.min.js.map +1 -1
  13. package/dist/node/axios.cjs +3761 -0
  14. package/dist/node/axios.cjs.map +1 -0
  15. package/gulpfile.js +88 -0
  16. package/index.d.ts +213 -67
  17. package/index.js +2 -1
  18. package/karma.conf.cjs +250 -0
  19. package/lib/adapters/http.js +256 -131
  20. package/lib/adapters/index.js +33 -0
  21. package/lib/adapters/xhr.js +79 -56
  22. package/lib/axios.js +41 -25
  23. package/lib/cancel/CancelToken.js +91 -88
  24. package/lib/cancel/CanceledError.js +5 -4
  25. package/lib/cancel/isCancel.js +2 -2
  26. package/lib/core/Axios.js +127 -100
  27. package/lib/core/AxiosError.js +10 -7
  28. package/lib/core/AxiosHeaders.js +274 -0
  29. package/lib/core/InterceptorManager.js +61 -53
  30. package/lib/core/buildFullPath.js +5 -4
  31. package/lib/core/dispatchRequest.js +21 -39
  32. package/lib/core/mergeConfig.js +8 -7
  33. package/lib/core/settle.js +6 -4
  34. package/lib/core/transformData.js +15 -10
  35. package/lib/defaults/index.js +46 -39
  36. package/lib/defaults/transitional.js +1 -1
  37. package/lib/env/classes/FormData.js +2 -2
  38. package/lib/env/data.js +1 -3
  39. package/lib/helpers/AxiosTransformStream.js +191 -0
  40. package/lib/helpers/AxiosURLSearchParams.js +23 -7
  41. package/lib/helpers/bind.js +2 -2
  42. package/lib/helpers/buildURL.js +16 -7
  43. package/lib/helpers/combineURLs.js +3 -2
  44. package/lib/helpers/cookies.js +43 -44
  45. package/lib/helpers/deprecatedMethod.js +4 -2
  46. package/lib/helpers/formDataToJSON.js +36 -15
  47. package/lib/helpers/fromDataURI.js +15 -13
  48. package/lib/helpers/isAbsoluteURL.js +3 -2
  49. package/lib/helpers/isAxiosError.js +4 -3
  50. package/lib/helpers/isURLSameOrigin.js +55 -56
  51. package/lib/helpers/null.js +1 -1
  52. package/lib/helpers/parseHeaders.js +24 -22
  53. package/lib/helpers/parseProtocol.js +3 -3
  54. package/lib/helpers/speedometer.js +55 -0
  55. package/lib/helpers/spread.js +3 -2
  56. package/lib/helpers/throttle.js +33 -0
  57. package/lib/helpers/toFormData.js +68 -18
  58. package/lib/helpers/toURLEncodedForm.js +5 -5
  59. package/lib/helpers/validator.js +20 -15
  60. package/lib/platform/browser/classes/FormData.js +1 -1
  61. package/lib/platform/browser/classes/URLSearchParams.js +2 -3
  62. package/lib/platform/browser/index.js +38 -6
  63. package/lib/platform/index.js +2 -2
  64. package/lib/platform/node/classes/FormData.js +2 -2
  65. package/lib/platform/node/classes/URLSearchParams.js +2 -3
  66. package/lib/platform/node/index.js +5 -4
  67. package/lib/utils.js +294 -192
  68. package/package.json +55 -22
  69. package/rollup.config.js +37 -7
  70. package/lib/helpers/normalizeHeaderName.js +0 -12
package/package.json CHANGED
@@ -1,14 +1,35 @@
1
1
  {
2
2
  "name": "axios",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.1.0",
4
4
  "description": "Promise based HTTP client for the browser and node.js",
5
5
  "main": "index.js",
6
+ "exports": {
7
+ ".": {
8
+ "browser": {
9
+ "require": "./index.js",
10
+ "default": "./index.js"
11
+ },
12
+ "default": {
13
+ "require": "./dist/node/axios.cjs",
14
+ "default": "./index.js"
15
+ }
16
+ }
17
+ },
18
+ "type": "module",
6
19
  "types": "index.d.ts",
7
20
  "scripts": {
8
- "test": "node bin/ssl_hotfix.js grunt test && node bin/ssl_hotfix.js dtslint",
21
+ "test": "npm run test:eslint && npm run test:mocha && npm run test:karma && npm run test:dtslint",
22
+ "test:eslint": "node bin/ssl_hotfix.js eslint lib/**/*.js",
23
+ "test:dtslint": "node bin/ssl_hotfix.js dtslint",
24
+ "test:mocha": "node bin/ssl_hotfix.js mocha test/unit/**/*.js --timeout 30000 --exit",
25
+ "test:karma": "node bin/ssl_hotfix.js cross-env LISTEN_ADDR=:: karma start karma.conf.cjs --single-run",
26
+ "test:karma:server": "node bin/ssl_hotfix.js cross-env karma start karma.conf.cjs",
9
27
  "start": "node ./sandbox/server.js",
10
- "preversion": "grunt version && npm test",
11
- "build": "cross-env NODE_ENV=production grunt build",
28
+ "preversion": "gulp version && npm test",
29
+ "version": "npm run build && git add dist && git add package.json",
30
+ "prepublishOnly": "npm test",
31
+ "postpublish": "git push && git push --tags",
32
+ "build": "gulp clear && cross-env NODE_ENV=production rollup -c -m",
12
33
  "examples": "node ./examples/server.js",
13
34
  "coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
14
35
  "fix": "eslint --fix lib/**/*.js"
@@ -31,7 +52,8 @@
31
52
  },
32
53
  "homepage": "https://axios-http.com",
33
54
  "devDependencies": {
34
- "@rollup/plugin-babel": "^5.3.0",
55
+ "@babel/preset-env": "^7.18.2",
56
+ "@rollup/plugin-babel": "^5.3.1",
35
57
  "@rollup/plugin-commonjs": "^15.1.0",
36
58
  "@rollup/plugin-json": "^4.1.0",
37
59
  "@rollup/plugin-multi-entry": "^4.0.0",
@@ -40,20 +62,15 @@
40
62
  "body-parser": "^1.20.0",
41
63
  "coveralls": "^3.1.1",
42
64
  "cross-env": "^7.0.3",
65
+ "dev-null": "^0.1.1",
43
66
  "dtslint": "^4.2.1",
44
67
  "es6-promise": "^4.2.8",
68
+ "eslint": "^8.17.0",
45
69
  "express": "^4.18.1",
46
70
  "formidable": "^2.0.1",
47
- "grunt": "^1.4.1",
48
- "grunt-banner": "^0.6.0",
49
- "grunt-cli": "^1.4.3",
50
- "grunt-contrib-clean": "^2.0.0",
51
- "grunt-contrib-watch": "^1.1.0",
52
- "grunt-eslint": "^24.0.0",
53
- "grunt-karma": "^4.0.2",
54
- "grunt-mocha-test": "^0.13.3",
55
- "grunt-shell": "^3.0.1",
56
- "grunt-webpack": "^5.0.0",
71
+ "fs-extra": "^10.1.0",
72
+ "get-stream": "^3.0.0",
73
+ "gulp": "^4.0.2",
57
74
  "istanbul-instrumenter-loader": "^3.0.1",
58
75
  "jasmine-core": "^2.4.1",
59
76
  "karma": "^6.3.17",
@@ -61,23 +78,23 @@
61
78
  "karma-firefox-launcher": "^2.1.2",
62
79
  "karma-jasmine": "^1.1.1",
63
80
  "karma-jasmine-ajax": "^0.1.13",
81
+ "karma-rollup-preprocessor": "^7.0.8",
64
82
  "karma-safari-launcher": "^1.0.0",
65
83
  "karma-sauce-launcher": "^4.3.6",
66
84
  "karma-sinon": "^1.0.5",
67
85
  "karma-sourcemap-loader": "^0.3.8",
68
- "karma-webpack": "^4.0.2",
69
- "load-grunt-tasks": "^5.1.0",
70
86
  "minimist": "^1.2.6",
71
- "mocha": "^8.2.1",
87
+ "mocha": "^10.0.0",
72
88
  "multer": "^1.4.4",
73
89
  "rollup": "^2.67.0",
90
+ "rollup-plugin-auto-external": "^2.0.0",
91
+ "rollup-plugin-bundle-size": "^1.0.3",
74
92
  "rollup-plugin-terser": "^7.0.2",
75
93
  "sinon": "^4.5.0",
94
+ "stream-throttle": "^0.1.3",
76
95
  "terser-webpack-plugin": "^4.2.3",
77
96
  "typescript": "^4.6.3",
78
- "url-search-params": "^0.10.0",
79
- "webpack": "^4.44.2",
80
- "webpack-dev-server": "^3.11.0"
97
+ "url-search-params": "^0.10.0"
81
98
  },
82
99
  "browser": {
83
100
  "./lib/adapters/http.js": "./lib/adapters/xhr.js",
@@ -96,5 +113,21 @@
96
113
  "path": "./dist/axios.min.js",
97
114
  "threshold": "5kB"
98
115
  }
116
+ ],
117
+ "contributors": [
118
+ "Matt Zabriskie (https://github.com/mzabriskie)",
119
+ "Nick Uraltsev (https://github.com/nickuraltsev)",
120
+ "Jay (https://github.com/jasonsaayman)",
121
+ "Dmitriy Mozgovoy (https://github.com/DigitalBrainJS)",
122
+ "Emily Morehouse (https://github.com/emilyemorehouse)",
123
+ "Rubén Norte (https://github.com/rubennorte)",
124
+ "Justin Beckwith (https://github.com/JustinBeckwith)",
125
+ "Martti Laine (https://github.com/codeclown)",
126
+ "Xianming Zhong (https://github.com/chinesedfan)",
127
+ "Rikki Gibson (https://github.com/RikkiGibson)",
128
+ "Remco Haszing (https://github.com/remcohaszing)",
129
+ "Yasu Flores (https://github.com/yasuf)",
130
+ "Ben Carp (https://github.com/carpben)",
131
+ "Daniel Lopretto (https://github.com/timemachine3030)"
99
132
  ]
100
- }
133
+ }
package/rollup.config.js CHANGED
@@ -2,13 +2,16 @@ import resolve from '@rollup/plugin-node-resolve';
2
2
  import commonjs from '@rollup/plugin-commonjs';
3
3
  import {terser} from "rollup-plugin-terser";
4
4
  import json from '@rollup/plugin-json';
5
+ import { babel } from '@rollup/plugin-babel';
6
+ import autoExternal from 'rollup-plugin-auto-external';
7
+ import bundleSize from 'rollup-plugin-bundle-size'
5
8
 
6
9
  const lib = require("./package.json");
7
10
  const outputFileName = 'axios';
8
11
  const name = "axios";
9
12
  const input = './lib/axios.js';
10
13
 
11
- const buildConfig = (config) => {
14
+ const buildConfig = ({es5, browser = true, minifiedVersion = true, ...config}) => {
12
15
 
13
16
  const build = ({minified}) => ({
14
17
  input,
@@ -19,30 +22,41 @@ const buildConfig = (config) => {
19
22
  },
20
23
  plugins: [
21
24
  json(),
22
- resolve({browser: true}),
25
+ resolve({browser}),
23
26
  commonjs(),
24
27
  minified && terser(),
28
+ minified && bundleSize(),
29
+ ...(es5 ? [babel({
30
+ babelHelpers: 'bundled',
31
+ presets: ['@babel/preset-env']
32
+ })] : []),
25
33
  ...(config.plugins || []),
26
34
  ]
27
35
  });
28
36
 
29
- return [
37
+ const configs = [
30
38
  build({minified: false}),
31
- build({minified: true}),
32
39
  ];
40
+
41
+ if (minifiedVersion) {
42
+ configs.push(build({minified: true}))
43
+ }
44
+
45
+ return configs;
33
46
  };
34
47
 
35
48
  export default async () => {
36
49
  const year = new Date().getFullYear();
37
- const banner = `// ${lib.name} v${lib.version} Copyright (c) ${year} ${lib.author}`;
50
+ const banner = `// Axios v${lib.version} Copyright (c) ${year} ${lib.author} and contributors`;
38
51
 
39
52
  return [
40
53
  ...buildConfig({
54
+ es5: true,
41
55
  output: {
42
56
  file: `dist/${outputFileName}`,
43
57
  name,
44
58
  format: "umd",
45
- exports: "default",
59
+ exports: "named",
46
60
  banner
47
61
  }
48
62
  }),
@@ -55,6 +69,22 @@ export default async () => {
55
69
  exports: "named",
56
70
  banner
57
71
  }
58
- })
72
+ }),
73
+ // Node.js commonjs build
74
+ {
75
+ input,
76
+ output: {
77
+ file: `dist/node/${name}.cjs`,
78
+ format: "cjs",
79
+ preferConst: true,
80
+ exports: "named",
81
+ banner
82
+ },
83
+ plugins: [
84
+ autoExternal(),
85
+ resolve(),
86
+ commonjs()
87
+ ]
88
+ }
59
89
  ]
60
90
  };
@@ -1,12 +0,0 @@
1
- 'use strict';
2
-
3
- var utils = require('../utils');
4
-
5
- module.exports = function normalizeHeaderName(headers, normalizedName) {
6
- utils.forEach(headers, function processHeader(value, name) {
7
- if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
8
- headers[normalizedName] = value;
9
- delete headers[name];
10
- }
11
- });
12
- };