vueonrails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +70 -0
- data/app/controllers/vue_controller.rb +2 -0
- data/app/helpers/syntax_helper.rb +28 -0
- data/app/views/vue/index.html.erb +1 -0
- data/config/routes.rb +5 -0
- data/lib/generators/generator_templates/packs/index.css +4 -0
- data/lib/generators/generator_templates/packs/index.js +30 -0
- data/lib/generators/generator_templates/packs/index.vue +13 -0
- data/lib/generators/generator_templates/packs/pack.js.erb +18 -0
- data/lib/generators/generator_templates/sfc/single-file-component.vue +45 -0
- data/lib/generators/generator_templates/tests/unit.test.js.erb +17 -0
- data/lib/generators/generator_templates/turbolinks/turbolinks-pack.js.erb +23 -0
- data/lib/generators/options/click.rb +10 -0
- data/lib/generators/options/form.rb +19 -0
- data/lib/generators/options/list.rb +32 -0
- data/lib/generators/options/modal.rb +26 -0
- data/lib/generators/options/seperate.rb +5 -0
- data/lib/generators/options/single.rb +3 -0
- data/lib/generators/options/table.rb +10 -0
- data/lib/generators/options/test.rb +2 -0
- data/lib/generators/options/turbolinks-seperate.rb +5 -0
- data/lib/generators/options/turbolinks-single.rb +3 -0
- data/lib/generators/options/vuex.rb +10 -0
- data/lib/generators/vue/USAGE +17 -0
- data/lib/generators/vue/vue_generator.rb +60 -0
- data/lib/install/Procfile +2 -0
- data/lib/install/config/alias.js +9 -0
- data/lib/install/setup.rb +78 -0
- data/lib/install/spv.rb +20 -0
- data/lib/install/test.rb +46 -0
- data/lib/install/turbolinks.rb +3 -0
- data/lib/install/ui.rb +4 -0
- data/lib/install/vuex.rb +12 -0
- data/lib/tasks/assets.rake +12 -0
- data/lib/tasks/info.rake +21 -0
- data/lib/tasks/vue.rake +27 -0
- data/lib/vueonrails.rb +13 -0
- data/lib/vueonrails/post_message.rb +4 -0
- data/lib/vueonrails/version.rb +3 -0
- data/vendor/assets/javascripts/axios.js +1545 -0
- data/vendor/assets/javascripts/axios.map +1 -0
- data/vendor/assets/javascripts/element-ui.js +12 -0
- data/vendor/assets/javascripts/vue-resource.js +1531 -0
- data/vendor/assets/javascripts/vue-router.js +2709 -0
- data/vendor/assets/javascripts/vue-router2.js +2284 -0
- data/vendor/assets/javascripts/vue-validator.js +910 -0
- data/vendor/assets/javascripts/vue-validator2.js +2615 -0
- data/vendor/assets/javascripts/vue-validator3.js +2054 -0
- data/vendor/assets/javascripts/vue.js +10237 -0
- data/vendor/assets/javascripts/vue.min.js +9 -0
- data/vendor/assets/javascripts/vue2.js +8568 -0
- data/vendor/assets/javascripts/vue2.min.js +8 -0
- data/vendor/assets/javascripts/vueonrails.js +39 -0
- data/vendor/assets/javascripts/vuex.js +722 -0
- data/vendor/assets/javascripts/vuex2.js +805 -0
- data/vendor/assets/stylesheets/element-ui.css +1 -0
- metadata +128 -0
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
class VueGenerator < Rails::Generators::NamedBase
|
4
|
+
source_root File.expand_path('../../generator_templates', __FILE__)
|
5
|
+
|
6
|
+
argument :name, type: :string, default: ""
|
7
|
+
|
8
|
+
PACKS_PATH = "app/javascript/packs"
|
9
|
+
PARTS_PATH = "app/javascript/parts"
|
10
|
+
TESTS_PATH = "app/javascript/tests"
|
11
|
+
|
12
|
+
OPTIONS = {
|
13
|
+
test: {type: :boolean, default: false},
|
14
|
+
vuex: {type: :boolean, default: false},
|
15
|
+
form: {type: :boolean, default: false},
|
16
|
+
tab: {type: :boolean, default: false},
|
17
|
+
list: {type: :boolean, default: false},
|
18
|
+
table: {type: :boolean, default: false},
|
19
|
+
modal: {type: :boolean, default: false},
|
20
|
+
click: {type: :boolean, default: false},
|
21
|
+
}.freeze
|
22
|
+
|
23
|
+
class_option :seperate, type: :boolean, default: false
|
24
|
+
class_option :turbolinks, type: :boolean, default: false
|
25
|
+
|
26
|
+
OPTIONS.each do |each_option, value|
|
27
|
+
class_option each_option, type: :boolean, default: false
|
28
|
+
end
|
29
|
+
|
30
|
+
def vue
|
31
|
+
return if name.empty?
|
32
|
+
|
33
|
+
if options[:seperate]
|
34
|
+
if options[:turbolinks]
|
35
|
+
add_to_component("turbolinks-seperate", name)
|
36
|
+
else
|
37
|
+
add_to_component("seperate", name)
|
38
|
+
end
|
39
|
+
else
|
40
|
+
if options[:turbolinks]
|
41
|
+
add_to_component("turbolinks-single", name)
|
42
|
+
else
|
43
|
+
add_to_component("single", name)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
OPTIONS.each do |each_option, value|
|
48
|
+
options[each_option] ? add_to_component(each_option, name) : nil
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
def add_to_component(example, name)
|
54
|
+
puts "add to component #{name} running #{example}"
|
55
|
+
namespace = OpenStruct.new(TESTS_PATH: TESTS_PATH, PARTS_PATH: PARTS_PATH, PACKS_PATH: PACKS_PATH, name: name)
|
56
|
+
template = File.read(File.expand_path("../options/#{example}.rb", __dir__))
|
57
|
+
erbtemplate = ERB.new(template).result(namespace.instance_eval { binding })
|
58
|
+
eval erbtemplate
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
say "Adding @vue/test-utils and other Jest devdependencies"
|
2
|
+
run "yarn add vueonrails"
|
3
|
+
run "yarn add @vue/test-utils jest jest-serializer-vue vue-jest babel-jest --dev"
|
4
|
+
|
5
|
+
# Copy alias.js into Vue on Rails project
|
6
|
+
copy_file "#{__dir__}/config/alias.js", Rails.root.join("config/webpack/alias/alias.js").to_s
|
7
|
+
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
8
|
+
"const alias = require('./alias/alias')\n", after: "require('@rails/webpacker')\n"
|
9
|
+
|
10
|
+
# Add *_pack_tag into application.html.erb This is essential for specific-page vue setup.
|
11
|
+
pack_tag = <<-eos
|
12
|
+
<%= javascript_pack_tag 'application' %>
|
13
|
+
<%= stylesheet_pack_tag 'application' %>
|
14
|
+
eos
|
15
|
+
insert_into_file Rails.root.join("app/views/layouts/application.html.erb").to_s,
|
16
|
+
pack_tag, before: " </head>\n"
|
17
|
+
|
18
|
+
insert_into_file Rails.root.join("app/javascript/packs/application.js").to_s,
|
19
|
+
"\nrequire('./hello_vue')\n", after: "console.log('Hello World from Webpacker')\n"
|
20
|
+
|
21
|
+
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
22
|
+
"environment.config.merge(alias)\n", before: "module.exports"
|
23
|
+
|
24
|
+
# Jest and scripts configuration. Essential for Jest test and Vue Ui
|
25
|
+
scripts = <<-eos
|
26
|
+
"scripts": {
|
27
|
+
"yarn test": "jest",
|
28
|
+
"yarn install": "yarn install",
|
29
|
+
"rails assets:precompile": "yarn install; rails assets:precompile",
|
30
|
+
"rails server": "rails server",
|
31
|
+
"webpack-dev-server": "./bin/webpack-dev-server"
|
32
|
+
},
|
33
|
+
"jest": {
|
34
|
+
"moduleFileExtensions": [
|
35
|
+
"js",
|
36
|
+
"vue"
|
37
|
+
],
|
38
|
+
"moduleNameMapper": {
|
39
|
+
"^@/(.*)$": "<rootDir>/app/javascript/parts/$1"
|
40
|
+
},
|
41
|
+
"transform": {
|
42
|
+
"^.+\\\\\\.js$": "<rootDir>/node_modules/babel-jest",
|
43
|
+
".*\\\\\\.(vue)$": "<rootDir>/node_modules/vue-jest"
|
44
|
+
},
|
45
|
+
"transformIgnorePatterns": [
|
46
|
+
"node_modules/(?!(vueonrails)/)"
|
47
|
+
],
|
48
|
+
"testPathIgnorePatterns": [
|
49
|
+
"<rootDir>/config/webpack/"
|
50
|
+
],
|
51
|
+
"snapshotSerializers": [
|
52
|
+
"<rootDir>/node_modules/jest-serializer-vue"
|
53
|
+
]
|
54
|
+
},
|
55
|
+
eos
|
56
|
+
|
57
|
+
insert_into_file Rails.root.join("package.json").to_s,
|
58
|
+
scripts, after: "\"private\": true,\n"
|
59
|
+
|
60
|
+
babelrc = <<-eos
|
61
|
+
"env": {
|
62
|
+
"test": {
|
63
|
+
"presets": [
|
64
|
+
["env", { "targets": { "node": "current" }}]
|
65
|
+
]
|
66
|
+
}
|
67
|
+
},
|
68
|
+
eos
|
69
|
+
|
70
|
+
insert_into_file Rails.root.join(".babelrc").to_s,
|
71
|
+
babelrc, before: " \"presets\": ["
|
72
|
+
|
73
|
+
# Add Procfile for foreman
|
74
|
+
template "#{__dir__}/Procfile", Rails.root.join("Procfile").to_s
|
75
|
+
|
76
|
+
# Add specific_page_vue helper to enable Specific-page Vue
|
77
|
+
gsub_file Rails.root.join("app/views/layouts/application.html.erb").to_s,
|
78
|
+
/<body>/, '<body class="<%= specific_page_vue %>">'
|
data/lib/install/spv.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
gsub_file Rails.root.join("app/views/layouts/application.html.erb").to_s,
|
2
|
+
/<body>/, '<body class="<%= specific_page_vue %>">'
|
3
|
+
|
4
|
+
pack_tag = <<-eos
|
5
|
+
<%= javascript_pack_tag 'application' %>
|
6
|
+
<%= stylesheet_pack_tag 'application' %>
|
7
|
+
eos
|
8
|
+
|
9
|
+
# say "Added javascript_packs_tag and stylesheet_packs_tag into head"
|
10
|
+
insert_into_file Rails.root.join("app/views/layouts/application.html.erb").to_s,
|
11
|
+
pack_tag,
|
12
|
+
before: " </head>\n"
|
13
|
+
|
14
|
+
vue_on_rails = <<-eos
|
15
|
+
//= vue-on-rails
|
16
|
+
eos
|
17
|
+
|
18
|
+
insert_into_file Rails.root.join("app/assets/javascripts/application.js").to_s,
|
19
|
+
vue_on_rails,
|
20
|
+
before: "//= require_tree ."
|
data/lib/install/test.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
scripts = <<-eos
|
2
|
+
"scripts": {
|
3
|
+
"test": "jest",
|
4
|
+
"assets:precompile": "yarn install; rails assets:precompile",
|
5
|
+
"webpack-dev-server": "./bin/webpack-dev-server",
|
6
|
+
"rails server": "rails server",
|
7
|
+
"yarn install": "yarn install"
|
8
|
+
},
|
9
|
+
"jest": {
|
10
|
+
"moduleFileExtensions": [
|
11
|
+
"js",
|
12
|
+
"vue"
|
13
|
+
],
|
14
|
+
"moduleNameMapper": {
|
15
|
+
"^@/(.*)$": "<rootDir>/app/javascript/parts/$1"
|
16
|
+
},
|
17
|
+
"transform": {
|
18
|
+
"^.+\\\\\\.js$": "<rootDir>/node_modules/babel-jest",
|
19
|
+
".*\\\\\\.(vue)$": "<rootDir>/node_modules/vue-jest"
|
20
|
+
},
|
21
|
+
"snapshotSerializers": [
|
22
|
+
"<rootDir>/node_modules/jest-serializer-vue"
|
23
|
+
]
|
24
|
+
},
|
25
|
+
eos
|
26
|
+
|
27
|
+
say "Adding scripts and jest configuration to package.json"
|
28
|
+
insert_into_file Rails.root.join("package.json").to_s,
|
29
|
+
"#{scripts}",
|
30
|
+
after: "\"private\": true,\n"
|
31
|
+
|
32
|
+
say "Adding test presets to .babelrc"
|
33
|
+
babelrc = <<-eos
|
34
|
+
"test": {
|
35
|
+
"presets": [
|
36
|
+
["env", { "targets": { "node": "current" }}]
|
37
|
+
]
|
38
|
+
},
|
39
|
+
eos
|
40
|
+
|
41
|
+
insert_into_file Rails.root.join(".babelrc").to_s,
|
42
|
+
"#{babelrc}",
|
43
|
+
before: " \"presets\": ["
|
44
|
+
|
45
|
+
say "Adding @vue/test-util and other Jest dependencies"
|
46
|
+
run "yarn add jest-serializer-vue vue-jest babel-jest --no-progress --silent"
|
data/lib/install/ui.rb
ADDED
data/lib/install/vuex.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# say "Adding Vuex & Vuex Rails Plugins to Vue on Rails"
|
2
|
+
# run "yarn add vuex vuex-rails-plugins"
|
3
|
+
|
4
|
+
# insert_into_file "#{PACKS_PATH}/#{name}.js" ,
|
5
|
+
# "import Vuex from 'vuex'",
|
6
|
+
# after: "import Vue from 'vue'\n"
|
7
|
+
|
8
|
+
# insert_into_file "#{PACKS_PATH}/#{name}.js",
|
9
|
+
# "Vue.use(Vuex)\n",
|
10
|
+
# before: "document.addEventListener"
|
11
|
+
|
12
|
+
puts "vuex"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
|
3
|
+
namespace :vue do
|
4
|
+
desc "Install Vue.js into assets pipeline"
|
5
|
+
task :assets do
|
6
|
+
version = "2.5.16"
|
7
|
+
source = "https://cdnjs.cloudflare.com/ajax/libs/vue/#{version}/vue.js"
|
8
|
+
output = "app/assets/javascripts/vue.js"
|
9
|
+
done = File.write output, open(source).read
|
10
|
+
$stdout.puts "Added Vue.js #{version} (#{source}) into assets pipeline (#{output})" if done != nil
|
11
|
+
end
|
12
|
+
end
|
data/lib/tasks/info.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
namespace :vue do
|
2
|
+
desc "Provide information on Webpacker's environment"
|
3
|
+
task :info do
|
4
|
+
$stdout.puts "Ruby: #{`ruby --version`}"
|
5
|
+
$stdout.puts "Rails: #{Rails.version}"
|
6
|
+
begin
|
7
|
+
$stdout.puts "Webpacker: #{Webpacker::VERSION}"
|
8
|
+
rescue NameError
|
9
|
+
$stdout.puts "Webpacker: Not installed"
|
10
|
+
end
|
11
|
+
$stdout.puts "Node: #{`node --version`}"
|
12
|
+
$stdout.puts "Yarn: #{`yarn --version`}"
|
13
|
+
$stdout.puts "\n"
|
14
|
+
$stdout.puts "#{`yarn list @rails/webpacker vue vue-loader vuex vue-template-compiler webpack-dev-server @vue/test-utils babel-jest jest jest-serializer-vue vue-jest`}"
|
15
|
+
$stdout.puts "\n"
|
16
|
+
|
17
|
+
$stdout.puts "Is bin/webpack present?: #{File.exist? 'bin/webpack'}"
|
18
|
+
$stdout.puts "Is bin/webpack-dev-server present?: #{File.exist? 'bin/webpack-dev-server'}"
|
19
|
+
$stdout.puts "Is bin/yarn present?: #{File.exist? 'bin/yarn'}"
|
20
|
+
end
|
21
|
+
end
|
data/lib/tasks/vue.rake
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
bin_path = ENV["BUNDLE_BIN"] || "./bin"
|
2
|
+
|
3
|
+
TASKS = {
|
4
|
+
turbolinks: "Check Vue-turbolinks ready",
|
5
|
+
setup: "Check Vue on Rails ready",
|
6
|
+
test: "Check Jest tests ready",
|
7
|
+
vuex: "Check Vuex ready",
|
8
|
+
ui: "Check Vue-ui ready",
|
9
|
+
spv: "Check Specific-page Vue ready?"
|
10
|
+
}.freeze
|
11
|
+
|
12
|
+
namespace :vue do
|
13
|
+
TASKS.each do |task_name, description|
|
14
|
+
desc description
|
15
|
+
task task_name do
|
16
|
+
template = File.expand_path("../install/#{task_name}.rb", __dir__)
|
17
|
+
base_path =
|
18
|
+
if Rails::VERSION::MAJOR >= 5
|
19
|
+
"#{RbConfig.ruby} #{bin_path}/rails app:template"
|
20
|
+
else
|
21
|
+
"#{RbConfig.ruby} #{bin_path}/rake rails:template"
|
22
|
+
end
|
23
|
+
|
24
|
+
exec "#{base_path} LOCATION=#{template}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/vueonrails.rb
ADDED
@@ -0,0 +1,1545 @@
|
|
1
|
+
/* axios v0.15.3 | (c) 2016 by Matt Zabriskie */
|
2
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
3
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
4
|
+
module.exports = factory();
|
5
|
+
else if(typeof define === 'function' && define.amd)
|
6
|
+
define([], factory);
|
7
|
+
else if(typeof exports === 'object')
|
8
|
+
exports["axios"] = factory();
|
9
|
+
else
|
10
|
+
root["axios"] = factory();
|
11
|
+
})(this, function() {
|
12
|
+
return /******/ (function(modules) { // webpackBootstrap
|
13
|
+
/******/ // The module cache
|
14
|
+
/******/ var installedModules = {};
|
15
|
+
/******/
|
16
|
+
/******/ // The require function
|
17
|
+
/******/ function __webpack_require__(moduleId) {
|
18
|
+
/******/
|
19
|
+
/******/ // Check if module is in cache
|
20
|
+
/******/ if(installedModules[moduleId])
|
21
|
+
/******/ return installedModules[moduleId].exports;
|
22
|
+
/******/
|
23
|
+
/******/ // Create a new module (and put it into the cache)
|
24
|
+
/******/ var module = installedModules[moduleId] = {
|
25
|
+
/******/ exports: {},
|
26
|
+
/******/ id: moduleId,
|
27
|
+
/******/ loaded: false
|
28
|
+
/******/ };
|
29
|
+
/******/
|
30
|
+
/******/ // Execute the module function
|
31
|
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
32
|
+
/******/
|
33
|
+
/******/ // Flag the module as loaded
|
34
|
+
/******/ module.loaded = true;
|
35
|
+
/******/
|
36
|
+
/******/ // Return the exports of the module
|
37
|
+
/******/ return module.exports;
|
38
|
+
/******/ }
|
39
|
+
/******/
|
40
|
+
/******/
|
41
|
+
/******/ // expose the modules object (__webpack_modules__)
|
42
|
+
/******/ __webpack_require__.m = modules;
|
43
|
+
/******/
|
44
|
+
/******/ // expose the module cache
|
45
|
+
/******/ __webpack_require__.c = installedModules;
|
46
|
+
/******/
|
47
|
+
/******/ // __webpack_public_path__
|
48
|
+
/******/ __webpack_require__.p = "";
|
49
|
+
/******/
|
50
|
+
/******/ // Load entry module and return exports
|
51
|
+
/******/ return __webpack_require__(0);
|
52
|
+
/******/ })
|
53
|
+
/************************************************************************/
|
54
|
+
/******/ ([
|
55
|
+
/* 0 */
|
56
|
+
/***/ function(module, exports, __webpack_require__) {
|
57
|
+
|
58
|
+
module.exports = __webpack_require__(1);
|
59
|
+
|
60
|
+
/***/ },
|
61
|
+
/* 1 */
|
62
|
+
/***/ function(module, exports, __webpack_require__) {
|
63
|
+
|
64
|
+
'use strict';
|
65
|
+
|
66
|
+
var utils = __webpack_require__(2);
|
67
|
+
var bind = __webpack_require__(3);
|
68
|
+
var Axios = __webpack_require__(4);
|
69
|
+
var defaults = __webpack_require__(5);
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Create an instance of Axios
|
73
|
+
*
|
74
|
+
* @param {Object} defaultConfig The default config for the instance
|
75
|
+
* @return {Axios} A new instance of Axios
|
76
|
+
*/
|
77
|
+
function createInstance(defaultConfig) {
|
78
|
+
var context = new Axios(defaultConfig);
|
79
|
+
var instance = bind(Axios.prototype.request, context);
|
80
|
+
|
81
|
+
// Copy axios.prototype to instance
|
82
|
+
utils.extend(instance, Axios.prototype, context);
|
83
|
+
|
84
|
+
// Copy context to instance
|
85
|
+
utils.extend(instance, context);
|
86
|
+
|
87
|
+
return instance;
|
88
|
+
}
|
89
|
+
|
90
|
+
// Create the default instance to be exported
|
91
|
+
var axios = createInstance(defaults);
|
92
|
+
|
93
|
+
// Expose Axios class to allow class inheritance
|
94
|
+
axios.Axios = Axios;
|
95
|
+
|
96
|
+
// Factory for creating new instances
|
97
|
+
axios.create = function create(instanceConfig) {
|
98
|
+
return createInstance(utils.merge(defaults, instanceConfig));
|
99
|
+
};
|
100
|
+
|
101
|
+
// Expose Cancel & CancelToken
|
102
|
+
axios.Cancel = __webpack_require__(22);
|
103
|
+
axios.CancelToken = __webpack_require__(23);
|
104
|
+
axios.isCancel = __webpack_require__(19);
|
105
|
+
|
106
|
+
// Expose all/spread
|
107
|
+
axios.all = function all(promises) {
|
108
|
+
return Promise.all(promises);
|
109
|
+
};
|
110
|
+
axios.spread = __webpack_require__(24);
|
111
|
+
|
112
|
+
module.exports = axios;
|
113
|
+
|
114
|
+
// Allow use of default import syntax in TypeScript
|
115
|
+
module.exports.default = axios;
|
116
|
+
|
117
|
+
|
118
|
+
/***/ },
|
119
|
+
/* 2 */
|
120
|
+
/***/ function(module, exports, __webpack_require__) {
|
121
|
+
|
122
|
+
'use strict';
|
123
|
+
|
124
|
+
var bind = __webpack_require__(3);
|
125
|
+
|
126
|
+
/*global toString:true*/
|
127
|
+
|
128
|
+
// utils is a library of generic helper functions non-specific to axios
|
129
|
+
|
130
|
+
var toString = Object.prototype.toString;
|
131
|
+
|
132
|
+
/**
|
133
|
+
* Determine if a value is an Array
|
134
|
+
*
|
135
|
+
* @param {Object} val The value to test
|
136
|
+
* @returns {boolean} True if value is an Array, otherwise false
|
137
|
+
*/
|
138
|
+
function isArray(val) {
|
139
|
+
return toString.call(val) === '[object Array]';
|
140
|
+
}
|
141
|
+
|
142
|
+
/**
|
143
|
+
* Determine if a value is an ArrayBuffer
|
144
|
+
*
|
145
|
+
* @param {Object} val The value to test
|
146
|
+
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
147
|
+
*/
|
148
|
+
function isArrayBuffer(val) {
|
149
|
+
return toString.call(val) === '[object ArrayBuffer]';
|
150
|
+
}
|
151
|
+
|
152
|
+
/**
|
153
|
+
* Determine if a value is a FormData
|
154
|
+
*
|
155
|
+
* @param {Object} val The value to test
|
156
|
+
* @returns {boolean} True if value is an FormData, otherwise false
|
157
|
+
*/
|
158
|
+
function isFormData(val) {
|
159
|
+
return (typeof FormData !== 'undefined') && (val instanceof FormData);
|
160
|
+
}
|
161
|
+
|
162
|
+
/**
|
163
|
+
* Determine if a value is a view on an ArrayBuffer
|
164
|
+
*
|
165
|
+
* @param {Object} val The value to test
|
166
|
+
* @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
|
167
|
+
*/
|
168
|
+
function isArrayBufferView(val) {
|
169
|
+
var result;
|
170
|
+
if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
|
171
|
+
result = ArrayBuffer.isView(val);
|
172
|
+
} else {
|
173
|
+
result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
|
174
|
+
}
|
175
|
+
return result;
|
176
|
+
}
|
177
|
+
|
178
|
+
/**
|
179
|
+
* Determine if a value is a String
|
180
|
+
*
|
181
|
+
* @param {Object} val The value to test
|
182
|
+
* @returns {boolean} True if value is a String, otherwise false
|
183
|
+
*/
|
184
|
+
function isString(val) {
|
185
|
+
return typeof val === 'string';
|
186
|
+
}
|
187
|
+
|
188
|
+
/**
|
189
|
+
* Determine if a value is a Number
|
190
|
+
*
|
191
|
+
* @param {Object} val The value to test
|
192
|
+
* @returns {boolean} True if value is a Number, otherwise false
|
193
|
+
*/
|
194
|
+
function isNumber(val) {
|
195
|
+
return typeof val === 'number';
|
196
|
+
}
|
197
|
+
|
198
|
+
/**
|
199
|
+
* Determine if a value is undefined
|
200
|
+
*
|
201
|
+
* @param {Object} val The value to test
|
202
|
+
* @returns {boolean} True if the value is undefined, otherwise false
|
203
|
+
*/
|
204
|
+
function isUndefined(val) {
|
205
|
+
return typeof val === 'undefined';
|
206
|
+
}
|
207
|
+
|
208
|
+
/**
|
209
|
+
* Determine if a value is an Object
|
210
|
+
*
|
211
|
+
* @param {Object} val The value to test
|
212
|
+
* @returns {boolean} True if value is an Object, otherwise false
|
213
|
+
*/
|
214
|
+
function isObject(val) {
|
215
|
+
return val !== null && typeof val === 'object';
|
216
|
+
}
|
217
|
+
|
218
|
+
/**
|
219
|
+
* Determine if a value is a Date
|
220
|
+
*
|
221
|
+
* @param {Object} val The value to test
|
222
|
+
* @returns {boolean} True if value is a Date, otherwise false
|
223
|
+
*/
|
224
|
+
function isDate(val) {
|
225
|
+
return toString.call(val) === '[object Date]';
|
226
|
+
}
|
227
|
+
|
228
|
+
/**
|
229
|
+
* Determine if a value is a File
|
230
|
+
*
|
231
|
+
* @param {Object} val The value to test
|
232
|
+
* @returns {boolean} True if value is a File, otherwise false
|
233
|
+
*/
|
234
|
+
function isFile(val) {
|
235
|
+
return toString.call(val) === '[object File]';
|
236
|
+
}
|
237
|
+
|
238
|
+
/**
|
239
|
+
* Determine if a value is a Blob
|
240
|
+
*
|
241
|
+
* @param {Object} val The value to test
|
242
|
+
* @returns {boolean} True if value is a Blob, otherwise false
|
243
|
+
*/
|
244
|
+
function isBlob(val) {
|
245
|
+
return toString.call(val) === '[object Blob]';
|
246
|
+
}
|
247
|
+
|
248
|
+
/**
|
249
|
+
* Determine if a value is a Function
|
250
|
+
*
|
251
|
+
* @param {Object} val The value to test
|
252
|
+
* @returns {boolean} True if value is a Function, otherwise false
|
253
|
+
*/
|
254
|
+
function isFunction(val) {
|
255
|
+
return toString.call(val) === '[object Function]';
|
256
|
+
}
|
257
|
+
|
258
|
+
/**
|
259
|
+
* Determine if a value is a Stream
|
260
|
+
*
|
261
|
+
* @param {Object} val The value to test
|
262
|
+
* @returns {boolean} True if value is a Stream, otherwise false
|
263
|
+
*/
|
264
|
+
function isStream(val) {
|
265
|
+
return isObject(val) && isFunction(val.pipe);
|
266
|
+
}
|
267
|
+
|
268
|
+
/**
|
269
|
+
* Determine if a value is a URLSearchParams object
|
270
|
+
*
|
271
|
+
* @param {Object} val The value to test
|
272
|
+
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
|
273
|
+
*/
|
274
|
+
function isURLSearchParams(val) {
|
275
|
+
return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
|
276
|
+
}
|
277
|
+
|
278
|
+
/**
|
279
|
+
* Trim excess whitespace off the beginning and end of a string
|
280
|
+
*
|
281
|
+
* @param {String} str The String to trim
|
282
|
+
* @returns {String} The String freed of excess whitespace
|
283
|
+
*/
|
284
|
+
function trim(str) {
|
285
|
+
return str.replace(/^\s*/, '').replace(/\s*$/, '');
|
286
|
+
}
|
287
|
+
|
288
|
+
/**
|
289
|
+
* Determine if we're running in a standard browser environment
|
290
|
+
*
|
291
|
+
* This allows axios to run in a web worker, and react-native.
|
292
|
+
* Both environments support XMLHttpRequest, but not fully standard globals.
|
293
|
+
*
|
294
|
+
* web workers:
|
295
|
+
* typeof window -> undefined
|
296
|
+
* typeof document -> undefined
|
297
|
+
*
|
298
|
+
* react-native:
|
299
|
+
* typeof document.createElement -> undefined
|
300
|
+
*/
|
301
|
+
function isStandardBrowserEnv() {
|
302
|
+
return (
|
303
|
+
typeof window !== 'undefined' &&
|
304
|
+
typeof document !== 'undefined' &&
|
305
|
+
typeof document.createElement === 'function'
|
306
|
+
);
|
307
|
+
}
|
308
|
+
|
309
|
+
/**
|
310
|
+
* Iterate over an Array or an Object invoking a function for each item.
|
311
|
+
*
|
312
|
+
* If `obj` is an Array callback will be called passing
|
313
|
+
* the value, index, and complete array for each item.
|
314
|
+
*
|
315
|
+
* If 'obj' is an Object callback will be called passing
|
316
|
+
* the value, key, and complete object for each property.
|
317
|
+
*
|
318
|
+
* @param {Object|Array} obj The object to iterate
|
319
|
+
* @param {Function} fn The callback to invoke for each item
|
320
|
+
*/
|
321
|
+
function forEach(obj, fn) {
|
322
|
+
// Don't bother if no value provided
|
323
|
+
if (obj === null || typeof obj === 'undefined') {
|
324
|
+
return;
|
325
|
+
}
|
326
|
+
|
327
|
+
// Force an array if not already something iterable
|
328
|
+
if (typeof obj !== 'object' && !isArray(obj)) {
|
329
|
+
/*eslint no-param-reassign:0*/
|
330
|
+
obj = [obj];
|
331
|
+
}
|
332
|
+
|
333
|
+
if (isArray(obj)) {
|
334
|
+
// Iterate over array values
|
335
|
+
for (var i = 0, l = obj.length; i < l; i++) {
|
336
|
+
fn.call(null, obj[i], i, obj);
|
337
|
+
}
|
338
|
+
} else {
|
339
|
+
// Iterate over object keys
|
340
|
+
for (var key in obj) {
|
341
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
342
|
+
fn.call(null, obj[key], key, obj);
|
343
|
+
}
|
344
|
+
}
|
345
|
+
}
|
346
|
+
}
|
347
|
+
|
348
|
+
/**
|
349
|
+
* Accepts varargs expecting each argument to be an object, then
|
350
|
+
* immutably merges the properties of each object and returns result.
|
351
|
+
*
|
352
|
+
* When multiple objects contain the same key the later object in
|
353
|
+
* the arguments list will take precedence.
|
354
|
+
*
|
355
|
+
* Example:
|
356
|
+
*
|
357
|
+
* ```js
|
358
|
+
* var result = merge({foo: 123}, {foo: 456});
|
359
|
+
* console.log(result.foo); // outputs 456
|
360
|
+
* ```
|
361
|
+
*
|
362
|
+
* @param {Object} obj1 Object to merge
|
363
|
+
* @returns {Object} Result of all merge properties
|
364
|
+
*/
|
365
|
+
function merge(/* obj1, obj2, obj3, ... */) {
|
366
|
+
var result = {};
|
367
|
+
function assignValue(val, key) {
|
368
|
+
if (typeof result[key] === 'object' && typeof val === 'object') {
|
369
|
+
result[key] = merge(result[key], val);
|
370
|
+
} else {
|
371
|
+
result[key] = val;
|
372
|
+
}
|
373
|
+
}
|
374
|
+
|
375
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
376
|
+
forEach(arguments[i], assignValue);
|
377
|
+
}
|
378
|
+
return result;
|
379
|
+
}
|
380
|
+
|
381
|
+
/**
|
382
|
+
* Extends object a by mutably adding to it the properties of object b.
|
383
|
+
*
|
384
|
+
* @param {Object} a The object to be extended
|
385
|
+
* @param {Object} b The object to copy properties from
|
386
|
+
* @param {Object} thisArg The object to bind function to
|
387
|
+
* @return {Object} The resulting value of object a
|
388
|
+
*/
|
389
|
+
function extend(a, b, thisArg) {
|
390
|
+
forEach(b, function assignValue(val, key) {
|
391
|
+
if (thisArg && typeof val === 'function') {
|
392
|
+
a[key] = bind(val, thisArg);
|
393
|
+
} else {
|
394
|
+
a[key] = val;
|
395
|
+
}
|
396
|
+
});
|
397
|
+
return a;
|
398
|
+
}
|
399
|
+
|
400
|
+
module.exports = {
|
401
|
+
isArray: isArray,
|
402
|
+
isArrayBuffer: isArrayBuffer,
|
403
|
+
isFormData: isFormData,
|
404
|
+
isArrayBufferView: isArrayBufferView,
|
405
|
+
isString: isString,
|
406
|
+
isNumber: isNumber,
|
407
|
+
isObject: isObject,
|
408
|
+
isUndefined: isUndefined,
|
409
|
+
isDate: isDate,
|
410
|
+
isFile: isFile,
|
411
|
+
isBlob: isBlob,
|
412
|
+
isFunction: isFunction,
|
413
|
+
isStream: isStream,
|
414
|
+
isURLSearchParams: isURLSearchParams,
|
415
|
+
isStandardBrowserEnv: isStandardBrowserEnv,
|
416
|
+
forEach: forEach,
|
417
|
+
merge: merge,
|
418
|
+
extend: extend,
|
419
|
+
trim: trim
|
420
|
+
};
|
421
|
+
|
422
|
+
|
423
|
+
/***/ },
|
424
|
+
/* 3 */
|
425
|
+
/***/ function(module, exports) {
|
426
|
+
|
427
|
+
'use strict';
|
428
|
+
|
429
|
+
module.exports = function bind(fn, thisArg) {
|
430
|
+
return function wrap() {
|
431
|
+
var args = new Array(arguments.length);
|
432
|
+
for (var i = 0; i < args.length; i++) {
|
433
|
+
args[i] = arguments[i];
|
434
|
+
}
|
435
|
+
return fn.apply(thisArg, args);
|
436
|
+
};
|
437
|
+
};
|
438
|
+
|
439
|
+
|
440
|
+
/***/ },
|
441
|
+
/* 4 */
|
442
|
+
/***/ function(module, exports, __webpack_require__) {
|
443
|
+
|
444
|
+
'use strict';
|
445
|
+
|
446
|
+
var defaults = __webpack_require__(5);
|
447
|
+
var utils = __webpack_require__(2);
|
448
|
+
var InterceptorManager = __webpack_require__(16);
|
449
|
+
var dispatchRequest = __webpack_require__(17);
|
450
|
+
var isAbsoluteURL = __webpack_require__(20);
|
451
|
+
var combineURLs = __webpack_require__(21);
|
452
|
+
|
453
|
+
/**
|
454
|
+
* Create a new instance of Axios
|
455
|
+
*
|
456
|
+
* @param {Object} instanceConfig The default config for the instance
|
457
|
+
*/
|
458
|
+
function Axios(instanceConfig) {
|
459
|
+
this.defaults = instanceConfig;
|
460
|
+
this.interceptors = {
|
461
|
+
request: new InterceptorManager(),
|
462
|
+
response: new InterceptorManager()
|
463
|
+
};
|
464
|
+
}
|
465
|
+
|
466
|
+
/**
|
467
|
+
* Dispatch a request
|
468
|
+
*
|
469
|
+
* @param {Object} config The config specific for this request (merged with this.defaults)
|
470
|
+
*/
|
471
|
+
Axios.prototype.request = function request(config) {
|
472
|
+
/*eslint no-param-reassign:0*/
|
473
|
+
// Allow for axios('example/url'[, config]) a la fetch API
|
474
|
+
if (typeof config === 'string') {
|
475
|
+
config = utils.merge({
|
476
|
+
url: arguments[0]
|
477
|
+
}, arguments[1]);
|
478
|
+
}
|
479
|
+
|
480
|
+
config = utils.merge(defaults, this.defaults, { method: 'get' }, config);
|
481
|
+
|
482
|
+
// Support baseURL config
|
483
|
+
if (config.baseURL && !isAbsoluteURL(config.url)) {
|
484
|
+
config.url = combineURLs(config.baseURL, config.url);
|
485
|
+
}
|
486
|
+
|
487
|
+
// Hook up interceptors middleware
|
488
|
+
var chain = [dispatchRequest, undefined];
|
489
|
+
var promise = Promise.resolve(config);
|
490
|
+
|
491
|
+
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
492
|
+
chain.unshift(interceptor.fulfilled, interceptor.rejected);
|
493
|
+
});
|
494
|
+
|
495
|
+
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
496
|
+
chain.push(interceptor.fulfilled, interceptor.rejected);
|
497
|
+
});
|
498
|
+
|
499
|
+
while (chain.length) {
|
500
|
+
promise = promise.then(chain.shift(), chain.shift());
|
501
|
+
}
|
502
|
+
|
503
|
+
return promise;
|
504
|
+
};
|
505
|
+
|
506
|
+
// Provide aliases for supported request methods
|
507
|
+
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
508
|
+
/*eslint func-names:0*/
|
509
|
+
Axios.prototype[method] = function(url, config) {
|
510
|
+
return this.request(utils.merge(config || {}, {
|
511
|
+
method: method,
|
512
|
+
url: url
|
513
|
+
}));
|
514
|
+
};
|
515
|
+
});
|
516
|
+
|
517
|
+
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
518
|
+
/*eslint func-names:0*/
|
519
|
+
Axios.prototype[method] = function(url, data, config) {
|
520
|
+
return this.request(utils.merge(config || {}, {
|
521
|
+
method: method,
|
522
|
+
url: url,
|
523
|
+
data: data
|
524
|
+
}));
|
525
|
+
};
|
526
|
+
});
|
527
|
+
|
528
|
+
module.exports = Axios;
|
529
|
+
|
530
|
+
|
531
|
+
/***/ },
|
532
|
+
/* 5 */
|
533
|
+
/***/ function(module, exports, __webpack_require__) {
|
534
|
+
|
535
|
+
'use strict';
|
536
|
+
|
537
|
+
var utils = __webpack_require__(2);
|
538
|
+
var normalizeHeaderName = __webpack_require__(6);
|
539
|
+
|
540
|
+
var PROTECTION_PREFIX = /^\)\]\}',?\n/;
|
541
|
+
var DEFAULT_CONTENT_TYPE = {
|
542
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
543
|
+
};
|
544
|
+
|
545
|
+
function setContentTypeIfUnset(headers, value) {
|
546
|
+
if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
|
547
|
+
headers['Content-Type'] = value;
|
548
|
+
}
|
549
|
+
}
|
550
|
+
|
551
|
+
function getDefaultAdapter() {
|
552
|
+
var adapter;
|
553
|
+
if (typeof XMLHttpRequest !== 'undefined') {
|
554
|
+
// For browsers use XHR adapter
|
555
|
+
adapter = __webpack_require__(7);
|
556
|
+
} else if (typeof process !== 'undefined') {
|
557
|
+
// For node use HTTP adapter
|
558
|
+
adapter = __webpack_require__(7);
|
559
|
+
}
|
560
|
+
return adapter;
|
561
|
+
}
|
562
|
+
|
563
|
+
var defaults = {
|
564
|
+
adapter: getDefaultAdapter(),
|
565
|
+
|
566
|
+
transformRequest: [function transformRequest(data, headers) {
|
567
|
+
normalizeHeaderName(headers, 'Content-Type');
|
568
|
+
if (utils.isFormData(data) ||
|
569
|
+
utils.isArrayBuffer(data) ||
|
570
|
+
utils.isStream(data) ||
|
571
|
+
utils.isFile(data) ||
|
572
|
+
utils.isBlob(data)
|
573
|
+
) {
|
574
|
+
return data;
|
575
|
+
}
|
576
|
+
if (utils.isArrayBufferView(data)) {
|
577
|
+
return data.buffer;
|
578
|
+
}
|
579
|
+
if (utils.isURLSearchParams(data)) {
|
580
|
+
setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
|
581
|
+
return data.toString();
|
582
|
+
}
|
583
|
+
if (utils.isObject(data)) {
|
584
|
+
setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
|
585
|
+
return JSON.stringify(data);
|
586
|
+
}
|
587
|
+
return data;
|
588
|
+
}],
|
589
|
+
|
590
|
+
transformResponse: [function transformResponse(data) {
|
591
|
+
/*eslint no-param-reassign:0*/
|
592
|
+
if (typeof data === 'string') {
|
593
|
+
data = data.replace(PROTECTION_PREFIX, '');
|
594
|
+
try {
|
595
|
+
data = JSON.parse(data);
|
596
|
+
} catch (e) { /* Ignore */ }
|
597
|
+
}
|
598
|
+
return data;
|
599
|
+
}],
|
600
|
+
|
601
|
+
timeout: 0,
|
602
|
+
|
603
|
+
xsrfCookieName: 'XSRF-TOKEN',
|
604
|
+
xsrfHeaderName: 'X-XSRF-TOKEN',
|
605
|
+
|
606
|
+
maxContentLength: -1,
|
607
|
+
|
608
|
+
validateStatus: function validateStatus(status) {
|
609
|
+
return status >= 200 && status < 300;
|
610
|
+
}
|
611
|
+
};
|
612
|
+
|
613
|
+
defaults.headers = {
|
614
|
+
common: {
|
615
|
+
'Accept': 'application/json, text/plain, */*'
|
616
|
+
}
|
617
|
+
};
|
618
|
+
|
619
|
+
utils.forEach(['delete', 'get', 'head'], function forEachMehtodNoData(method) {
|
620
|
+
defaults.headers[method] = {};
|
621
|
+
});
|
622
|
+
|
623
|
+
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
624
|
+
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
625
|
+
});
|
626
|
+
|
627
|
+
module.exports = defaults;
|
628
|
+
|
629
|
+
|
630
|
+
/***/ },
|
631
|
+
/* 6 */
|
632
|
+
/***/ function(module, exports, __webpack_require__) {
|
633
|
+
|
634
|
+
'use strict';
|
635
|
+
|
636
|
+
var utils = __webpack_require__(2);
|
637
|
+
|
638
|
+
module.exports = function normalizeHeaderName(headers, normalizedName) {
|
639
|
+
utils.forEach(headers, function processHeader(value, name) {
|
640
|
+
if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
|
641
|
+
headers[normalizedName] = value;
|
642
|
+
delete headers[name];
|
643
|
+
}
|
644
|
+
});
|
645
|
+
};
|
646
|
+
|
647
|
+
|
648
|
+
/***/ },
|
649
|
+
/* 7 */
|
650
|
+
/***/ function(module, exports, __webpack_require__) {
|
651
|
+
|
652
|
+
'use strict';
|
653
|
+
|
654
|
+
var utils = __webpack_require__(2);
|
655
|
+
var settle = __webpack_require__(8);
|
656
|
+
var buildURL = __webpack_require__(11);
|
657
|
+
var parseHeaders = __webpack_require__(12);
|
658
|
+
var isURLSameOrigin = __webpack_require__(13);
|
659
|
+
var createError = __webpack_require__(9);
|
660
|
+
var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || __webpack_require__(14);
|
661
|
+
|
662
|
+
module.exports = function xhrAdapter(config) {
|
663
|
+
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
664
|
+
var requestData = config.data;
|
665
|
+
var requestHeaders = config.headers;
|
666
|
+
|
667
|
+
if (utils.isFormData(requestData)) {
|
668
|
+
delete requestHeaders['Content-Type']; // Let the browser set it
|
669
|
+
}
|
670
|
+
|
671
|
+
var request = new XMLHttpRequest();
|
672
|
+
var loadEvent = 'onreadystatechange';
|
673
|
+
var xDomain = false;
|
674
|
+
|
675
|
+
// For IE 8/9 CORS support
|
676
|
+
// Only supports POST and GET calls and doesn't returns the response headers.
|
677
|
+
// DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.
|
678
|
+
if (("production") !== 'test' &&
|
679
|
+
typeof window !== 'undefined' &&
|
680
|
+
window.XDomainRequest && !('withCredentials' in request) &&
|
681
|
+
!isURLSameOrigin(config.url)) {
|
682
|
+
request = new window.XDomainRequest();
|
683
|
+
loadEvent = 'onload';
|
684
|
+
xDomain = true;
|
685
|
+
request.onprogress = function handleProgress() {};
|
686
|
+
request.ontimeout = function handleTimeout() {};
|
687
|
+
}
|
688
|
+
|
689
|
+
// HTTP basic authentication
|
690
|
+
if (config.auth) {
|
691
|
+
var username = config.auth.username || '';
|
692
|
+
var password = config.auth.password || '';
|
693
|
+
requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
|
694
|
+
}
|
695
|
+
|
696
|
+
request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);
|
697
|
+
|
698
|
+
// Set the request timeout in MS
|
699
|
+
request.timeout = config.timeout;
|
700
|
+
|
701
|
+
// Listen for ready state
|
702
|
+
request[loadEvent] = function handleLoad() {
|
703
|
+
if (!request || (request.readyState !== 4 && !xDomain)) {
|
704
|
+
return;
|
705
|
+
}
|
706
|
+
|
707
|
+
// The request errored out and we didn't get a response, this will be
|
708
|
+
// handled by onerror instead
|
709
|
+
// With one exception: request that using file: protocol, most browsers
|
710
|
+
// will return status as 0 even though it's a successful request
|
711
|
+
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
|
712
|
+
return;
|
713
|
+
}
|
714
|
+
|
715
|
+
// Prepare the response
|
716
|
+
var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
|
717
|
+
var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
|
718
|
+
var response = {
|
719
|
+
data: responseData,
|
720
|
+
// IE sends 1223 instead of 204 (https://github.com/mzabriskie/axios/issues/201)
|
721
|
+
status: request.status === 1223 ? 204 : request.status,
|
722
|
+
statusText: request.status === 1223 ? 'No Content' : request.statusText,
|
723
|
+
headers: responseHeaders,
|
724
|
+
config: config,
|
725
|
+
request: request
|
726
|
+
};
|
727
|
+
|
728
|
+
settle(resolve, reject, response);
|
729
|
+
|
730
|
+
// Clean up request
|
731
|
+
request = null;
|
732
|
+
};
|
733
|
+
|
734
|
+
// Handle low level network errors
|
735
|
+
request.onerror = function handleError() {
|
736
|
+
// Real errors are hidden from us by the browser
|
737
|
+
// onerror should only fire if it's a network error
|
738
|
+
reject(createError('Network Error', config));
|
739
|
+
|
740
|
+
// Clean up request
|
741
|
+
request = null;
|
742
|
+
};
|
743
|
+
|
744
|
+
// Handle timeout
|
745
|
+
request.ontimeout = function handleTimeout() {
|
746
|
+
reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED'));
|
747
|
+
|
748
|
+
// Clean up request
|
749
|
+
request = null;
|
750
|
+
};
|
751
|
+
|
752
|
+
// Add xsrf header
|
753
|
+
// This is only done if running in a standard browser environment.
|
754
|
+
// Specifically not if we're in a web worker, or react-native.
|
755
|
+
if (utils.isStandardBrowserEnv()) {
|
756
|
+
var cookies = __webpack_require__(15);
|
757
|
+
|
758
|
+
// Add xsrf header
|
759
|
+
var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?
|
760
|
+
cookies.read(config.xsrfCookieName) :
|
761
|
+
undefined;
|
762
|
+
|
763
|
+
if (xsrfValue) {
|
764
|
+
requestHeaders[config.xsrfHeaderName] = xsrfValue;
|
765
|
+
}
|
766
|
+
}
|
767
|
+
|
768
|
+
// Add headers to the request
|
769
|
+
if ('setRequestHeader' in request) {
|
770
|
+
utils.forEach(requestHeaders, function setRequestHeader(val, key) {
|
771
|
+
if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
|
772
|
+
// Remove Content-Type if data is undefined
|
773
|
+
delete requestHeaders[key];
|
774
|
+
} else {
|
775
|
+
// Otherwise add header to the request
|
776
|
+
request.setRequestHeader(key, val);
|
777
|
+
}
|
778
|
+
});
|
779
|
+
}
|
780
|
+
|
781
|
+
// Add withCredentials to request if needed
|
782
|
+
if (config.withCredentials) {
|
783
|
+
request.withCredentials = true;
|
784
|
+
}
|
785
|
+
|
786
|
+
// Add responseType to request if needed
|
787
|
+
if (config.responseType) {
|
788
|
+
try {
|
789
|
+
request.responseType = config.responseType;
|
790
|
+
} catch (e) {
|
791
|
+
if (request.responseType !== 'json') {
|
792
|
+
throw e;
|
793
|
+
}
|
794
|
+
}
|
795
|
+
}
|
796
|
+
|
797
|
+
// Handle progress if needed
|
798
|
+
if (typeof config.onDownloadProgress === 'function') {
|
799
|
+
request.addEventListener('progress', config.onDownloadProgress);
|
800
|
+
}
|
801
|
+
|
802
|
+
// Not all browsers support upload events
|
803
|
+
if (typeof config.onUploadProgress === 'function' && request.upload) {
|
804
|
+
request.upload.addEventListener('progress', config.onUploadProgress);
|
805
|
+
}
|
806
|
+
|
807
|
+
if (config.cancelToken) {
|
808
|
+
// Handle cancellation
|
809
|
+
config.cancelToken.promise.then(function onCanceled(cancel) {
|
810
|
+
if (!request) {
|
811
|
+
return;
|
812
|
+
}
|
813
|
+
|
814
|
+
request.abort();
|
815
|
+
reject(cancel);
|
816
|
+
// Clean up request
|
817
|
+
request = null;
|
818
|
+
});
|
819
|
+
}
|
820
|
+
|
821
|
+
if (requestData === undefined) {
|
822
|
+
requestData = null;
|
823
|
+
}
|
824
|
+
|
825
|
+
// Send the request
|
826
|
+
request.send(requestData);
|
827
|
+
});
|
828
|
+
};
|
829
|
+
|
830
|
+
|
831
|
+
/***/ },
|
832
|
+
/* 8 */
|
833
|
+
/***/ function(module, exports, __webpack_require__) {
|
834
|
+
|
835
|
+
'use strict';
|
836
|
+
|
837
|
+
var createError = __webpack_require__(9);
|
838
|
+
|
839
|
+
/**
|
840
|
+
* Resolve or reject a Promise based on response status.
|
841
|
+
*
|
842
|
+
* @param {Function} resolve A function that resolves the promise.
|
843
|
+
* @param {Function} reject A function that rejects the promise.
|
844
|
+
* @param {object} response The response.
|
845
|
+
*/
|
846
|
+
module.exports = function settle(resolve, reject, response) {
|
847
|
+
var validateStatus = response.config.validateStatus;
|
848
|
+
// Note: status is not exposed by XDomainRequest
|
849
|
+
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
850
|
+
resolve(response);
|
851
|
+
} else {
|
852
|
+
reject(createError(
|
853
|
+
'Request failed with status code ' + response.status,
|
854
|
+
response.config,
|
855
|
+
null,
|
856
|
+
response
|
857
|
+
));
|
858
|
+
}
|
859
|
+
};
|
860
|
+
|
861
|
+
|
862
|
+
/***/ },
|
863
|
+
/* 9 */
|
864
|
+
/***/ function(module, exports, __webpack_require__) {
|
865
|
+
|
866
|
+
'use strict';
|
867
|
+
|
868
|
+
var enhanceError = __webpack_require__(10);
|
869
|
+
|
870
|
+
/**
|
871
|
+
* Create an Error with the specified message, config, error code, and response.
|
872
|
+
*
|
873
|
+
* @param {string} message The error message.
|
874
|
+
* @param {Object} config The config.
|
875
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
876
|
+
@ @param {Object} [response] The response.
|
877
|
+
* @returns {Error} The created error.
|
878
|
+
*/
|
879
|
+
module.exports = function createError(message, config, code, response) {
|
880
|
+
var error = new Error(message);
|
881
|
+
return enhanceError(error, config, code, response);
|
882
|
+
};
|
883
|
+
|
884
|
+
|
885
|
+
/***/ },
|
886
|
+
/* 10 */
|
887
|
+
/***/ function(module, exports) {
|
888
|
+
|
889
|
+
'use strict';
|
890
|
+
|
891
|
+
/**
|
892
|
+
* Update an Error with the specified config, error code, and response.
|
893
|
+
*
|
894
|
+
* @param {Error} error The error to update.
|
895
|
+
* @param {Object} config The config.
|
896
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
897
|
+
@ @param {Object} [response] The response.
|
898
|
+
* @returns {Error} The error.
|
899
|
+
*/
|
900
|
+
module.exports = function enhanceError(error, config, code, response) {
|
901
|
+
error.config = config;
|
902
|
+
if (code) {
|
903
|
+
error.code = code;
|
904
|
+
}
|
905
|
+
error.response = response;
|
906
|
+
return error;
|
907
|
+
};
|
908
|
+
|
909
|
+
|
910
|
+
/***/ },
|
911
|
+
/* 11 */
|
912
|
+
/***/ function(module, exports, __webpack_require__) {
|
913
|
+
|
914
|
+
'use strict';
|
915
|
+
|
916
|
+
var utils = __webpack_require__(2);
|
917
|
+
|
918
|
+
function encode(val) {
|
919
|
+
return encodeURIComponent(val).
|
920
|
+
replace(/%40/gi, '@').
|
921
|
+
replace(/%3A/gi, ':').
|
922
|
+
replace(/%24/g, '$').
|
923
|
+
replace(/%2C/gi, ',').
|
924
|
+
replace(/%20/g, '+').
|
925
|
+
replace(/%5B/gi, '[').
|
926
|
+
replace(/%5D/gi, ']');
|
927
|
+
}
|
928
|
+
|
929
|
+
/**
|
930
|
+
* Build a URL by appending params to the end
|
931
|
+
*
|
932
|
+
* @param {string} url The base of the url (e.g., http://www.google.com)
|
933
|
+
* @param {object} [params] The params to be appended
|
934
|
+
* @returns {string} The formatted url
|
935
|
+
*/
|
936
|
+
module.exports = function buildURL(url, params, paramsSerializer) {
|
937
|
+
/*eslint no-param-reassign:0*/
|
938
|
+
if (!params) {
|
939
|
+
return url;
|
940
|
+
}
|
941
|
+
|
942
|
+
var serializedParams;
|
943
|
+
if (paramsSerializer) {
|
944
|
+
serializedParams = paramsSerializer(params);
|
945
|
+
} else if (utils.isURLSearchParams(params)) {
|
946
|
+
serializedParams = params.toString();
|
947
|
+
} else {
|
948
|
+
var parts = [];
|
949
|
+
|
950
|
+
utils.forEach(params, function serialize(val, key) {
|
951
|
+
if (val === null || typeof val === 'undefined') {
|
952
|
+
return;
|
953
|
+
}
|
954
|
+
|
955
|
+
if (utils.isArray(val)) {
|
956
|
+
key = key + '[]';
|
957
|
+
}
|
958
|
+
|
959
|
+
if (!utils.isArray(val)) {
|
960
|
+
val = [val];
|
961
|
+
}
|
962
|
+
|
963
|
+
utils.forEach(val, function parseValue(v) {
|
964
|
+
if (utils.isDate(v)) {
|
965
|
+
v = v.toISOString();
|
966
|
+
} else if (utils.isObject(v)) {
|
967
|
+
v = JSON.stringify(v);
|
968
|
+
}
|
969
|
+
parts.push(encode(key) + '=' + encode(v));
|
970
|
+
});
|
971
|
+
});
|
972
|
+
|
973
|
+
serializedParams = parts.join('&');
|
974
|
+
}
|
975
|
+
|
976
|
+
if (serializedParams) {
|
977
|
+
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
978
|
+
}
|
979
|
+
|
980
|
+
return url;
|
981
|
+
};
|
982
|
+
|
983
|
+
|
984
|
+
/***/ },
|
985
|
+
/* 12 */
|
986
|
+
/***/ function(module, exports, __webpack_require__) {
|
987
|
+
|
988
|
+
'use strict';
|
989
|
+
|
990
|
+
var utils = __webpack_require__(2);
|
991
|
+
|
992
|
+
/**
|
993
|
+
* Parse headers into an object
|
994
|
+
*
|
995
|
+
* ```
|
996
|
+
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
997
|
+
* Content-Type: application/json
|
998
|
+
* Connection: keep-alive
|
999
|
+
* Transfer-Encoding: chunked
|
1000
|
+
* ```
|
1001
|
+
*
|
1002
|
+
* @param {String} headers Headers needing to be parsed
|
1003
|
+
* @returns {Object} Headers parsed into an object
|
1004
|
+
*/
|
1005
|
+
module.exports = function parseHeaders(headers) {
|
1006
|
+
var parsed = {};
|
1007
|
+
var key;
|
1008
|
+
var val;
|
1009
|
+
var i;
|
1010
|
+
|
1011
|
+
if (!headers) { return parsed; }
|
1012
|
+
|
1013
|
+
utils.forEach(headers.split('\n'), function parser(line) {
|
1014
|
+
i = line.indexOf(':');
|
1015
|
+
key = utils.trim(line.substr(0, i)).toLowerCase();
|
1016
|
+
val = utils.trim(line.substr(i + 1));
|
1017
|
+
|
1018
|
+
if (key) {
|
1019
|
+
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
1020
|
+
}
|
1021
|
+
});
|
1022
|
+
|
1023
|
+
return parsed;
|
1024
|
+
};
|
1025
|
+
|
1026
|
+
|
1027
|
+
/***/ },
|
1028
|
+
/* 13 */
|
1029
|
+
/***/ function(module, exports, __webpack_require__) {
|
1030
|
+
|
1031
|
+
'use strict';
|
1032
|
+
|
1033
|
+
var utils = __webpack_require__(2);
|
1034
|
+
|
1035
|
+
module.exports = (
|
1036
|
+
utils.isStandardBrowserEnv() ?
|
1037
|
+
|
1038
|
+
// Standard browser envs have full support of the APIs needed to test
|
1039
|
+
// whether the request URL is of the same origin as current location.
|
1040
|
+
(function standardBrowserEnv() {
|
1041
|
+
var msie = /(msie|trident)/i.test(navigator.userAgent);
|
1042
|
+
var urlParsingNode = document.createElement('a');
|
1043
|
+
var originURL;
|
1044
|
+
|
1045
|
+
/**
|
1046
|
+
* Parse a URL to discover it's components
|
1047
|
+
*
|
1048
|
+
* @param {String} url The URL to be parsed
|
1049
|
+
* @returns {Object}
|
1050
|
+
*/
|
1051
|
+
function resolveURL(url) {
|
1052
|
+
var href = url;
|
1053
|
+
|
1054
|
+
if (msie) {
|
1055
|
+
// IE needs attribute set twice to normalize properties
|
1056
|
+
urlParsingNode.setAttribute('href', href);
|
1057
|
+
href = urlParsingNode.href;
|
1058
|
+
}
|
1059
|
+
|
1060
|
+
urlParsingNode.setAttribute('href', href);
|
1061
|
+
|
1062
|
+
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
1063
|
+
return {
|
1064
|
+
href: urlParsingNode.href,
|
1065
|
+
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
1066
|
+
host: urlParsingNode.host,
|
1067
|
+
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
1068
|
+
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
1069
|
+
hostname: urlParsingNode.hostname,
|
1070
|
+
port: urlParsingNode.port,
|
1071
|
+
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
|
1072
|
+
urlParsingNode.pathname :
|
1073
|
+
'/' + urlParsingNode.pathname
|
1074
|
+
};
|
1075
|
+
}
|
1076
|
+
|
1077
|
+
originURL = resolveURL(window.location.href);
|
1078
|
+
|
1079
|
+
/**
|
1080
|
+
* Determine if a URL shares the same origin as the current location
|
1081
|
+
*
|
1082
|
+
* @param {String} requestURL The URL to test
|
1083
|
+
* @returns {boolean} True if URL shares the same origin, otherwise false
|
1084
|
+
*/
|
1085
|
+
return function isURLSameOrigin(requestURL) {
|
1086
|
+
var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
1087
|
+
return (parsed.protocol === originURL.protocol &&
|
1088
|
+
parsed.host === originURL.host);
|
1089
|
+
};
|
1090
|
+
})() :
|
1091
|
+
|
1092
|
+
// Non standard browser envs (web workers, react-native) lack needed support.
|
1093
|
+
(function nonStandardBrowserEnv() {
|
1094
|
+
return function isURLSameOrigin() {
|
1095
|
+
return true;
|
1096
|
+
};
|
1097
|
+
})()
|
1098
|
+
);
|
1099
|
+
|
1100
|
+
|
1101
|
+
/***/ },
|
1102
|
+
/* 14 */
|
1103
|
+
/***/ function(module, exports) {
|
1104
|
+
|
1105
|
+
'use strict';
|
1106
|
+
|
1107
|
+
// btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js
|
1108
|
+
|
1109
|
+
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
1110
|
+
|
1111
|
+
function E() {
|
1112
|
+
this.message = 'String contains an invalid character';
|
1113
|
+
}
|
1114
|
+
E.prototype = new Error;
|
1115
|
+
E.prototype.code = 5;
|
1116
|
+
E.prototype.name = 'InvalidCharacterError';
|
1117
|
+
|
1118
|
+
function btoa(input) {
|
1119
|
+
var str = String(input);
|
1120
|
+
var output = '';
|
1121
|
+
for (
|
1122
|
+
// initialize result and counter
|
1123
|
+
var block, charCode, idx = 0, map = chars;
|
1124
|
+
// if the next str index does not exist:
|
1125
|
+
// change the mapping table to "="
|
1126
|
+
// check if d has no fractional digits
|
1127
|
+
str.charAt(idx | 0) || (map = '=', idx % 1);
|
1128
|
+
// "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
|
1129
|
+
output += map.charAt(63 & block >> 8 - idx % 1 * 8)
|
1130
|
+
) {
|
1131
|
+
charCode = str.charCodeAt(idx += 3 / 4);
|
1132
|
+
if (charCode > 0xFF) {
|
1133
|
+
throw new E();
|
1134
|
+
}
|
1135
|
+
block = block << 8 | charCode;
|
1136
|
+
}
|
1137
|
+
return output;
|
1138
|
+
}
|
1139
|
+
|
1140
|
+
module.exports = btoa;
|
1141
|
+
|
1142
|
+
|
1143
|
+
/***/ },
|
1144
|
+
/* 15 */
|
1145
|
+
/***/ function(module, exports, __webpack_require__) {
|
1146
|
+
|
1147
|
+
'use strict';
|
1148
|
+
|
1149
|
+
var utils = __webpack_require__(2);
|
1150
|
+
|
1151
|
+
module.exports = (
|
1152
|
+
utils.isStandardBrowserEnv() ?
|
1153
|
+
|
1154
|
+
// Standard browser envs support document.cookie
|
1155
|
+
(function standardBrowserEnv() {
|
1156
|
+
return {
|
1157
|
+
write: function write(name, value, expires, path, domain, secure) {
|
1158
|
+
var cookie = [];
|
1159
|
+
cookie.push(name + '=' + encodeURIComponent(value));
|
1160
|
+
|
1161
|
+
if (utils.isNumber(expires)) {
|
1162
|
+
cookie.push('expires=' + new Date(expires).toGMTString());
|
1163
|
+
}
|
1164
|
+
|
1165
|
+
if (utils.isString(path)) {
|
1166
|
+
cookie.push('path=' + path);
|
1167
|
+
}
|
1168
|
+
|
1169
|
+
if (utils.isString(domain)) {
|
1170
|
+
cookie.push('domain=' + domain);
|
1171
|
+
}
|
1172
|
+
|
1173
|
+
if (secure === true) {
|
1174
|
+
cookie.push('secure');
|
1175
|
+
}
|
1176
|
+
|
1177
|
+
document.cookie = cookie.join('; ');
|
1178
|
+
},
|
1179
|
+
|
1180
|
+
read: function read(name) {
|
1181
|
+
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
1182
|
+
return (match ? decodeURIComponent(match[3]) : null);
|
1183
|
+
},
|
1184
|
+
|
1185
|
+
remove: function remove(name) {
|
1186
|
+
this.write(name, '', Date.now() - 86400000);
|
1187
|
+
}
|
1188
|
+
};
|
1189
|
+
})() :
|
1190
|
+
|
1191
|
+
// Non standard browser env (web workers, react-native) lack needed support.
|
1192
|
+
(function nonStandardBrowserEnv() {
|
1193
|
+
return {
|
1194
|
+
write: function write() {},
|
1195
|
+
read: function read() { return null; },
|
1196
|
+
remove: function remove() {}
|
1197
|
+
};
|
1198
|
+
})()
|
1199
|
+
);
|
1200
|
+
|
1201
|
+
|
1202
|
+
/***/ },
|
1203
|
+
/* 16 */
|
1204
|
+
/***/ function(module, exports, __webpack_require__) {
|
1205
|
+
|
1206
|
+
'use strict';
|
1207
|
+
|
1208
|
+
var utils = __webpack_require__(2);
|
1209
|
+
|
1210
|
+
function InterceptorManager() {
|
1211
|
+
this.handlers = [];
|
1212
|
+
}
|
1213
|
+
|
1214
|
+
/**
|
1215
|
+
* Add a new interceptor to the stack
|
1216
|
+
*
|
1217
|
+
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
1218
|
+
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
1219
|
+
*
|
1220
|
+
* @return {Number} An ID used to remove interceptor later
|
1221
|
+
*/
|
1222
|
+
InterceptorManager.prototype.use = function use(fulfilled, rejected) {
|
1223
|
+
this.handlers.push({
|
1224
|
+
fulfilled: fulfilled,
|
1225
|
+
rejected: rejected
|
1226
|
+
});
|
1227
|
+
return this.handlers.length - 1;
|
1228
|
+
};
|
1229
|
+
|
1230
|
+
/**
|
1231
|
+
* Remove an interceptor from the stack
|
1232
|
+
*
|
1233
|
+
* @param {Number} id The ID that was returned by `use`
|
1234
|
+
*/
|
1235
|
+
InterceptorManager.prototype.eject = function eject(id) {
|
1236
|
+
if (this.handlers[id]) {
|
1237
|
+
this.handlers[id] = null;
|
1238
|
+
}
|
1239
|
+
};
|
1240
|
+
|
1241
|
+
/**
|
1242
|
+
* Iterate over all the registered interceptors
|
1243
|
+
*
|
1244
|
+
* This method is particularly useful for skipping over any
|
1245
|
+
* interceptors that may have become `null` calling `eject`.
|
1246
|
+
*
|
1247
|
+
* @param {Function} fn The function to call for each interceptor
|
1248
|
+
*/
|
1249
|
+
InterceptorManager.prototype.forEach = function forEach(fn) {
|
1250
|
+
utils.forEach(this.handlers, function forEachHandler(h) {
|
1251
|
+
if (h !== null) {
|
1252
|
+
fn(h);
|
1253
|
+
}
|
1254
|
+
});
|
1255
|
+
};
|
1256
|
+
|
1257
|
+
module.exports = InterceptorManager;
|
1258
|
+
|
1259
|
+
|
1260
|
+
/***/ },
|
1261
|
+
/* 17 */
|
1262
|
+
/***/ function(module, exports, __webpack_require__) {
|
1263
|
+
|
1264
|
+
'use strict';
|
1265
|
+
|
1266
|
+
var utils = __webpack_require__(2);
|
1267
|
+
var transformData = __webpack_require__(18);
|
1268
|
+
var isCancel = __webpack_require__(19);
|
1269
|
+
var defaults = __webpack_require__(5);
|
1270
|
+
|
1271
|
+
/**
|
1272
|
+
* Throws a `Cancel` if cancellation has been requested.
|
1273
|
+
*/
|
1274
|
+
function throwIfCancellationRequested(config) {
|
1275
|
+
if (config.cancelToken) {
|
1276
|
+
config.cancelToken.throwIfRequested();
|
1277
|
+
}
|
1278
|
+
}
|
1279
|
+
|
1280
|
+
/**
|
1281
|
+
* Dispatch a request to the server using the configured adapter.
|
1282
|
+
*
|
1283
|
+
* @param {object} config The config that is to be used for the request
|
1284
|
+
* @returns {Promise} The Promise to be fulfilled
|
1285
|
+
*/
|
1286
|
+
module.exports = function dispatchRequest(config) {
|
1287
|
+
throwIfCancellationRequested(config);
|
1288
|
+
|
1289
|
+
// Ensure headers exist
|
1290
|
+
config.headers = config.headers || {};
|
1291
|
+
|
1292
|
+
// Transform request data
|
1293
|
+
config.data = transformData(
|
1294
|
+
config.data,
|
1295
|
+
config.headers,
|
1296
|
+
config.transformRequest
|
1297
|
+
);
|
1298
|
+
|
1299
|
+
// Flatten headers
|
1300
|
+
config.headers = utils.merge(
|
1301
|
+
config.headers.common || {},
|
1302
|
+
config.headers[config.method] || {},
|
1303
|
+
config.headers || {}
|
1304
|
+
);
|
1305
|
+
|
1306
|
+
utils.forEach(
|
1307
|
+
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
1308
|
+
function cleanHeaderConfig(method) {
|
1309
|
+
delete config.headers[method];
|
1310
|
+
}
|
1311
|
+
);
|
1312
|
+
|
1313
|
+
var adapter = config.adapter || defaults.adapter;
|
1314
|
+
|
1315
|
+
return adapter(config).then(function onAdapterResolution(response) {
|
1316
|
+
throwIfCancellationRequested(config);
|
1317
|
+
|
1318
|
+
// Transform response data
|
1319
|
+
response.data = transformData(
|
1320
|
+
response.data,
|
1321
|
+
response.headers,
|
1322
|
+
config.transformResponse
|
1323
|
+
);
|
1324
|
+
|
1325
|
+
return response;
|
1326
|
+
}, function onAdapterRejection(reason) {
|
1327
|
+
if (!isCancel(reason)) {
|
1328
|
+
throwIfCancellationRequested(config);
|
1329
|
+
|
1330
|
+
// Transform response data
|
1331
|
+
if (reason && reason.response) {
|
1332
|
+
reason.response.data = transformData(
|
1333
|
+
reason.response.data,
|
1334
|
+
reason.response.headers,
|
1335
|
+
config.transformResponse
|
1336
|
+
);
|
1337
|
+
}
|
1338
|
+
}
|
1339
|
+
|
1340
|
+
return Promise.reject(reason);
|
1341
|
+
});
|
1342
|
+
};
|
1343
|
+
|
1344
|
+
|
1345
|
+
/***/ },
|
1346
|
+
/* 18 */
|
1347
|
+
/***/ function(module, exports, __webpack_require__) {
|
1348
|
+
|
1349
|
+
'use strict';
|
1350
|
+
|
1351
|
+
var utils = __webpack_require__(2);
|
1352
|
+
|
1353
|
+
/**
|
1354
|
+
* Transform the data for a request or a response
|
1355
|
+
*
|
1356
|
+
* @param {Object|String} data The data to be transformed
|
1357
|
+
* @param {Array} headers The headers for the request or response
|
1358
|
+
* @param {Array|Function} fns A single function or Array of functions
|
1359
|
+
* @returns {*} The resulting transformed data
|
1360
|
+
*/
|
1361
|
+
module.exports = function transformData(data, headers, fns) {
|
1362
|
+
/*eslint no-param-reassign:0*/
|
1363
|
+
utils.forEach(fns, function transform(fn) {
|
1364
|
+
data = fn(data, headers);
|
1365
|
+
});
|
1366
|
+
|
1367
|
+
return data;
|
1368
|
+
};
|
1369
|
+
|
1370
|
+
|
1371
|
+
/***/ },
|
1372
|
+
/* 19 */
|
1373
|
+
/***/ function(module, exports) {
|
1374
|
+
|
1375
|
+
'use strict';
|
1376
|
+
|
1377
|
+
module.exports = function isCancel(value) {
|
1378
|
+
return !!(value && value.__CANCEL__);
|
1379
|
+
};
|
1380
|
+
|
1381
|
+
|
1382
|
+
/***/ },
|
1383
|
+
/* 20 */
|
1384
|
+
/***/ function(module, exports) {
|
1385
|
+
|
1386
|
+
'use strict';
|
1387
|
+
|
1388
|
+
/**
|
1389
|
+
* Determines whether the specified URL is absolute
|
1390
|
+
*
|
1391
|
+
* @param {string} url The URL to test
|
1392
|
+
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
1393
|
+
*/
|
1394
|
+
module.exports = function isAbsoluteURL(url) {
|
1395
|
+
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
1396
|
+
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
1397
|
+
// by any combination of letters, digits, plus, period, or hyphen.
|
1398
|
+
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
|
1399
|
+
};
|
1400
|
+
|
1401
|
+
|
1402
|
+
/***/ },
|
1403
|
+
/* 21 */
|
1404
|
+
/***/ function(module, exports) {
|
1405
|
+
|
1406
|
+
'use strict';
|
1407
|
+
|
1408
|
+
/**
|
1409
|
+
* Creates a new URL by combining the specified URLs
|
1410
|
+
*
|
1411
|
+
* @param {string} baseURL The base URL
|
1412
|
+
* @param {string} relativeURL The relative URL
|
1413
|
+
* @returns {string} The combined URL
|
1414
|
+
*/
|
1415
|
+
module.exports = function combineURLs(baseURL, relativeURL) {
|
1416
|
+
return baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '');
|
1417
|
+
};
|
1418
|
+
|
1419
|
+
|
1420
|
+
/***/ },
|
1421
|
+
/* 22 */
|
1422
|
+
/***/ function(module, exports) {
|
1423
|
+
|
1424
|
+
'use strict';
|
1425
|
+
|
1426
|
+
/**
|
1427
|
+
* A `Cancel` is an object that is thrown when an operation is canceled.
|
1428
|
+
*
|
1429
|
+
* @class
|
1430
|
+
* @param {string=} message The message.
|
1431
|
+
*/
|
1432
|
+
function Cancel(message) {
|
1433
|
+
this.message = message;
|
1434
|
+
}
|
1435
|
+
|
1436
|
+
Cancel.prototype.toString = function toString() {
|
1437
|
+
return 'Cancel' + (this.message ? ': ' + this.message : '');
|
1438
|
+
};
|
1439
|
+
|
1440
|
+
Cancel.prototype.__CANCEL__ = true;
|
1441
|
+
|
1442
|
+
module.exports = Cancel;
|
1443
|
+
|
1444
|
+
|
1445
|
+
/***/ },
|
1446
|
+
/* 23 */
|
1447
|
+
/***/ function(module, exports, __webpack_require__) {
|
1448
|
+
|
1449
|
+
'use strict';
|
1450
|
+
|
1451
|
+
var Cancel = __webpack_require__(22);
|
1452
|
+
|
1453
|
+
/**
|
1454
|
+
* A `CancelToken` is an object that can be used to request cancellation of an operation.
|
1455
|
+
*
|
1456
|
+
* @class
|
1457
|
+
* @param {Function} executor The executor function.
|
1458
|
+
*/
|
1459
|
+
function CancelToken(executor) {
|
1460
|
+
if (typeof executor !== 'function') {
|
1461
|
+
throw new TypeError('executor must be a function.');
|
1462
|
+
}
|
1463
|
+
|
1464
|
+
var resolvePromise;
|
1465
|
+
this.promise = new Promise(function promiseExecutor(resolve) {
|
1466
|
+
resolvePromise = resolve;
|
1467
|
+
});
|
1468
|
+
|
1469
|
+
var token = this;
|
1470
|
+
executor(function cancel(message) {
|
1471
|
+
if (token.reason) {
|
1472
|
+
// Cancellation has already been requested
|
1473
|
+
return;
|
1474
|
+
}
|
1475
|
+
|
1476
|
+
token.reason = new Cancel(message);
|
1477
|
+
resolvePromise(token.reason);
|
1478
|
+
});
|
1479
|
+
}
|
1480
|
+
|
1481
|
+
/**
|
1482
|
+
* Throws a `Cancel` if cancellation has been requested.
|
1483
|
+
*/
|
1484
|
+
CancelToken.prototype.throwIfRequested = function throwIfRequested() {
|
1485
|
+
if (this.reason) {
|
1486
|
+
throw this.reason;
|
1487
|
+
}
|
1488
|
+
};
|
1489
|
+
|
1490
|
+
/**
|
1491
|
+
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
1492
|
+
* cancels the `CancelToken`.
|
1493
|
+
*/
|
1494
|
+
CancelToken.source = function source() {
|
1495
|
+
var cancel;
|
1496
|
+
var token = new CancelToken(function executor(c) {
|
1497
|
+
cancel = c;
|
1498
|
+
});
|
1499
|
+
return {
|
1500
|
+
token: token,
|
1501
|
+
cancel: cancel
|
1502
|
+
};
|
1503
|
+
};
|
1504
|
+
|
1505
|
+
module.exports = CancelToken;
|
1506
|
+
|
1507
|
+
|
1508
|
+
/***/ },
|
1509
|
+
/* 24 */
|
1510
|
+
/***/ function(module, exports) {
|
1511
|
+
|
1512
|
+
'use strict';
|
1513
|
+
|
1514
|
+
/**
|
1515
|
+
* Syntactic sugar for invoking a function and expanding an array for arguments.
|
1516
|
+
*
|
1517
|
+
* Common use case would be to use `Function.prototype.apply`.
|
1518
|
+
*
|
1519
|
+
* ```js
|
1520
|
+
* function f(x, y, z) {}
|
1521
|
+
* var args = [1, 2, 3];
|
1522
|
+
* f.apply(null, args);
|
1523
|
+
* ```
|
1524
|
+
*
|
1525
|
+
* With `spread` this example can be re-written.
|
1526
|
+
*
|
1527
|
+
* ```js
|
1528
|
+
* spread(function(x, y, z) {})([1, 2, 3]);
|
1529
|
+
* ```
|
1530
|
+
*
|
1531
|
+
* @param {Function} callback
|
1532
|
+
* @returns {Function}
|
1533
|
+
*/
|
1534
|
+
module.exports = function spread(callback) {
|
1535
|
+
return function wrap(arr) {
|
1536
|
+
return callback.apply(null, arr);
|
1537
|
+
};
|
1538
|
+
};
|
1539
|
+
|
1540
|
+
|
1541
|
+
/***/ }
|
1542
|
+
/******/ ])
|
1543
|
+
});
|
1544
|
+
;
|
1545
|
+
//# sourceMappingURL=axios.map
|