graphql-voyager-rails 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +44 -0
  4. data/Rakefile +32 -0
  5. data/app/assets/config/graphql_voyager_rails_manifest.js +1 -0
  6. data/app/assets/javascripts/graphql/voyager/rails/application.js +4 -0
  7. data/app/assets/javascripts/graphql/voyager/rails/fetch-3.0.0.js +531 -0
  8. data/app/assets/javascripts/graphql/voyager/rails/react-16.8.6.js +33 -0
  9. data/app/assets/javascripts/graphql/voyager/rails/react-dom-16.8.6.js +220 -0
  10. data/app/assets/javascripts/graphql/voyager/rails/voyager-1.0.0-rc.27.js +82 -0
  11. data/app/assets/javascripts/graphql/voyager/rails/voyager.js +1 -0
  12. data/app/assets/javascripts/graphql/voyager/rails/voyager.worker-1.0.0-rc.27.js +90 -0
  13. data/app/assets/stylesheets/graphql/voyager/rails/application.css +14 -0
  14. data/app/assets/stylesheets/graphql/voyager/rails/voyager-1.0.0-rc.27.css +847 -0
  15. data/app/controllers/graphql/voyager/rails/explorers_controller.rb +18 -0
  16. data/app/helpers/graphql/voyager/rails/application_helper.rb +8 -0
  17. data/app/jobs/graphql/voyager/rails/application_job.rb +8 -0
  18. data/app/mailers/graphql/voyager/rails/application_mailer.rb +10 -0
  19. data/app/models/graphql/voyager/rails/application_record.rb +9 -0
  20. data/app/views/graphql/voyager/rails/explorers/show.html.erb +34 -0
  21. data/config/initializers/assets.rb +3 -0
  22. data/config/routes.rb +5 -0
  23. data/lib/graphql/voyager/rails.rb +14 -0
  24. data/lib/graphql/voyager/rails/config.rb +45 -0
  25. data/lib/graphql/voyager/rails/engine.rb +9 -0
  26. data/lib/graphql/voyager/rails/version.rb +7 -0
  27. data/lib/tasks/graphql/voyager/rails_tasks.rake +4 -0
  28. data/test/controllers/graphql/voyager/rails/explorers_controller_test.rb +36 -0
  29. data/test/dummy/Rakefile +6 -0
  30. data/test/dummy/app/assets/config/manifest.js +3 -0
  31. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  32. data/test/dummy/app/channels/application_cable/channel.rb +4 -0
  33. data/test/dummy/app/channels/application_cable/connection.rb +4 -0
  34. data/test/dummy/app/controllers/application_controller.rb +2 -0
  35. data/test/dummy/app/helpers/application_helper.rb +2 -0
  36. data/test/dummy/app/javascript/packs/application.js +15 -0
  37. data/test/dummy/app/jobs/application_job.rb +7 -0
  38. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  39. data/test/dummy/app/models/application_record.rb +3 -0
  40. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  41. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  42. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  43. data/test/dummy/bin/rails +4 -0
  44. data/test/dummy/bin/rake +4 -0
  45. data/test/dummy/bin/setup +33 -0
  46. data/test/dummy/config.ru +5 -0
  47. data/test/dummy/config/application.rb +19 -0
  48. data/test/dummy/config/boot.rb +5 -0
  49. data/test/dummy/config/cable.yml +10 -0
  50. data/test/dummy/config/database.yml +25 -0
  51. data/test/dummy/config/environment.rb +5 -0
  52. data/test/dummy/config/environments/development.rb +62 -0
  53. data/test/dummy/config/environments/production.rb +112 -0
  54. data/test/dummy/config/environments/test.rb +48 -0
  55. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  56. data/test/dummy/config/initializers/assets.rb +12 -0
  57. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  58. data/test/dummy/config/initializers/content_security_policy.rb +25 -0
  59. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  60. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  61. data/test/dummy/config/initializers/inflections.rb +16 -0
  62. data/test/dummy/config/initializers/mime_types.rb +4 -0
  63. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  64. data/test/dummy/config/locales/en.yml +33 -0
  65. data/test/dummy/config/puma.rb +35 -0
  66. data/test/dummy/config/routes.rb +3 -0
  67. data/test/dummy/config/spring.rb +6 -0
  68. data/test/dummy/config/storage.yml +34 -0
  69. data/test/dummy/db/test.sqlite3 +0 -0
  70. data/test/dummy/log/test.log +225 -0
  71. data/test/dummy/public/404.html +67 -0
  72. data/test/dummy/public/422.html +67 -0
  73. data/test/dummy/public/500.html +66 -0
  74. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  75. data/test/dummy/public/apple-touch-icon.png +0 -0
  76. data/test/dummy/public/favicon.ico +0 -0
  77. data/test/dummy/tmp/cache/assets/sprockets/v3.0/-L/-LgBrhDMmzlYc5y7PZBz-jB3gZtMw9zXlIOQuJpcO5k.cache +1 -0
  78. data/test/dummy/tmp/cache/assets/sprockets/v3.0/0a/0arWfKbETvMJnjsc7VCRd4StD7zHnRsl490vQofS-kI.cache +1 -0
  79. data/test/dummy/tmp/cache/assets/sprockets/v3.0/23/23GwWp3MsuKldcLgr_v-6LsEX8AwkLotiQ8XKLBdvMY.cache +1 -0
  80. data/test/dummy/tmp/cache/assets/sprockets/v3.0/31/31pOaAAGKosY5PeTUloQaRXYxXJkQh8-06gGzNwLzjU.cache +0 -0
  81. data/test/dummy/tmp/cache/assets/sprockets/v3.0/38/38HwsGJAKo1lFFRdwn961vkOpIktrRn59IzxnxGVle4.cache +0 -0
  82. data/test/dummy/tmp/cache/assets/sprockets/v3.0/46/461GqH0WK0GnjYJkKulRjeIP_zpJW7DWKjY5lR5i1ys.cache +0 -0
  83. data/test/dummy/tmp/cache/assets/sprockets/v3.0/6w/6wB3YjyrXfC4Rn9tSoXPquB3f2-CPl8UhScQKq3OHic.cache +1 -0
  84. data/test/dummy/tmp/cache/assets/sprockets/v3.0/9E/9Ee04zUpTRdLsDBfcytkZ69m1i2SdUuZgV2-6lGIu1M.cache +1 -0
  85. data/test/dummy/tmp/cache/assets/sprockets/v3.0/C7/C7sxwGxvxEA6isvV50r6gv7yOtmPMMQmJSi-dyxgCz4.cache +0 -0
  86. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Do/DoYIq8aUQf6iOlLXzL2pB4WVJm97bEsBAkX0wRTKSWM.cache +1 -0
  87. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Hn/Hn0Dir2Qre1dPpKlHTmQgxuD8qludN0lmBruCYM4TTc.cache +2 -0
  88. data/test/dummy/tmp/cache/assets/sprockets/v3.0/J0/J0pk2EEIbPh09R00H97DDK7_iToFnUfcaPw9SHC6R-Y.cache +1 -0
  89. data/test/dummy/tmp/cache/assets/sprockets/v3.0/JI/JICb7HnCp5lkTc4k2vK8pd3DlmB7KhJhuQuxciGT7Kk.cache +1 -0
  90. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Jc/JcS8opULi6eX1vbG3HmtzPSqlTMafS_iBQvf34aR8l4.cache +0 -0
  91. data/test/dummy/tmp/cache/assets/sprockets/v3.0/KC/KCWWfVN-SFDA8k8UnvtZgGgsgvJSyHd3iIuZKqn0ko8.cache +0 -0
  92. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Mw/Mw0AOXURNQOmuxJirEXvj8Rq_oi6uAHOE3vtlH7u-Fw.cache +1 -0
  93. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Pn/PnFYfKd-pPBGY4FtMnibkYqt2OiEXfnzJZYRdWTxctE.cache +1 -0
  94. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Qc/QcIajxKDzSGoWgu9yOM7fwlbv7Tgo6g16YSh_Dgh6Wc.cache +1 -0
  95. data/test/dummy/tmp/cache/assets/sprockets/v3.0/RJ/RJNZrMhE6yksN5Vue0m1ID9zE207y_4bFRapsiq0vAU.cache +1 -0
  96. data/test/dummy/tmp/cache/assets/sprockets/v3.0/RN/RNmjelpbwuDkCtazWKp7-Zrl5W8VxTQ6nlAGxMKFwDM.cache +1 -0
  97. data/test/dummy/tmp/cache/assets/sprockets/v3.0/SD/SDBbfvTfI2AyEZAV064Nir17NRt4hD0iVb12Aqk8ywM.cache +1 -0
  98. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Sr/SrPbTIVWV2JTBMu84pLDAttN1DIS_DVIOMaAovbMbxg.cache +2 -0
  99. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Tg/TgjwvIfsj0OewsOyWCswjBOHbM_JZDJsG_oXty7PABk.cache +2 -0
  100. data/test/dummy/tmp/cache/assets/sprockets/v3.0/UY/UY1iCdbGcvX3mrkSOAtJBzcrYjUo3m9mdCLbi9BpKr8.cache +0 -0
  101. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Ve/VesnakHSrVqrJzcdqBcg6r6o_62NamiE5cqu7cM-8Kg.cache +1 -0
  102. data/test/dummy/tmp/cache/assets/sprockets/v3.0/ZK/ZKO1w-GMI7dF-iETsubYNhyKMeTDJi38zK5GyrlgarM.cache +3 -0
  103. data/test/dummy/tmp/cache/assets/sprockets/v3.0/ZN/ZNJWRapZXTDgjhsC5lmV98x7yJhGTcWQUBanr8JTu0M.cache +0 -0
  104. data/test/dummy/tmp/cache/assets/sprockets/v3.0/c9/c9wvFO9IiujJfKWrHGcboYdbo3zWTao08hj7OLPp2qY.cache +2 -0
  105. data/test/dummy/tmp/cache/assets/sprockets/v3.0/c_/c_4zcUUg5Raxheggo7oPNrkvmaZxWrwGoqeJPjCuYbk.cache +0 -0
  106. data/test/dummy/tmp/cache/assets/sprockets/v3.0/d0/d0C_Yf2uWnuUIVtRk9JIHm3EPypQjxRJ2ZhVS_d8q9E.cache +0 -0
  107. data/test/dummy/tmp/cache/assets/sprockets/v3.0/eR/eRZre7dVJcr8dZjm2kwTh5DN526mPSPitecUgSGgW6g.cache +0 -0
  108. data/test/dummy/tmp/cache/assets/sprockets/v3.0/f3/f330_OiEhbT4mo-cKYRkm_u6IkxoUyDlr8McIhePMgg.cache +3 -0
  109. data/test/dummy/tmp/cache/assets/sprockets/v3.0/gO/gOSQQUbnu8-aEUxfNHjzdU3Q0xa3CbTT8CI0ArfrGk8.cache +2 -0
  110. data/test/dummy/tmp/cache/assets/sprockets/v3.0/gv/gv3E5XN6MpWeJ1wPawSX32pZ0-BrwS5VonWd9z0Yl2I.cache +0 -0
  111. data/test/dummy/tmp/cache/assets/sprockets/v3.0/hA/hAVlAiubzIMyxSE_45AMzA-Rnln8QFvgsWmdgvBgT8Q.cache +1 -0
  112. data/test/dummy/tmp/cache/assets/sprockets/v3.0/jw/jwXtlggMzNp8KtzoRZTf_f-O0jpv0xf2peHabqI2qo8.cache +1 -0
  113. data/test/dummy/tmp/cache/assets/sprockets/v3.0/kH/kHFmhZsd51wI3bn7tsj0VrCFDD4vXVhHoioWI9jPTEo.cache +3 -0
  114. data/test/dummy/tmp/cache/assets/sprockets/v3.0/ly/lynqx7g2h3JAI4LO-mdONn5kqkSsh7-4YwWiUYYpzXo.cache +1 -0
  115. data/test/dummy/tmp/cache/assets/sprockets/v3.0/m8/m8FHrWL34tXn_QbxB37YQ9QgpdY8nz8UGrOj9jBtlEA.cache +0 -0
  116. data/test/dummy/tmp/cache/assets/sprockets/v3.0/mT/mTakZR2CUokGQFZniZzL6aN_iHqgCKqROf1VPKVz5RE.cache +0 -0
  117. data/test/dummy/tmp/cache/assets/sprockets/v3.0/n_/n_xYqQYhwEMQknb3jFQnjlxxBE9TzMNHCdJ-bEyZFIw.cache +2 -0
  118. data/test/dummy/tmp/cache/assets/sprockets/v3.0/nc/nczjjC46sYc081vUb6Bbl_LKcfhD_6wUwawwBiso-bY.cache +2 -0
  119. data/test/dummy/tmp/cache/assets/sprockets/v3.0/ne/neFhocrothF_JPf22LdYgUz8oCpUI2qODBCftbV2lP0.cache +1 -0
  120. data/test/dummy/tmp/cache/assets/sprockets/v3.0/nx/nxTv3sKVUQZADJyM3dPaVmUA78MIsMLD_K279yN_GsI.cache +2 -0
  121. data/test/dummy/tmp/cache/assets/sprockets/v3.0/ow/owB2YQYvII2hIPfhZIKTvjP1JEUwvFVEzlbPDuLQV6I.cache +1 -0
  122. data/test/dummy/tmp/cache/assets/sprockets/v3.0/sL/sLcAwFNqNCjcoYYdPrkJ5ib22YwWDjRYkgYCTgr2I9g.cache +1 -0
  123. data/test/dummy/tmp/cache/assets/sprockets/v3.0/sX/sXn6HtT4X4u50oCdGycXrjpJv_0nAgNVl4uee8YxWFM.cache +1 -0
  124. data/test/dummy/tmp/cache/assets/sprockets/v3.0/tL/tLw2JNRDnFqlxlH3j9FPElYKr-dlWzYd21XelFYn6MQ.cache +1 -0
  125. data/test/dummy/tmp/cache/assets/sprockets/v3.0/uv/uVTZlhUlPFkEdsEicN3XShxTQTpEAOAbRBHx8jGiSiw.cache +2 -0
  126. data/test/dummy/tmp/cache/assets/sprockets/v3.0/uv/uvoTsqYP2RAHZsSGzMLgeRdQ-24LGbJi2mKMacMGbW4.cache +1 -0
  127. data/test/dummy/tmp/cache/assets/sprockets/v3.0/v_/v_qs0XuAAs-BrsCeJ948wTXHlbCmAwVPV3oDRCLHLrE.cache +3 -0
  128. data/test/dummy/tmp/cache/assets/sprockets/v3.0/w6/w6-bOcal92_FVycXYG9H_RuDP3oS2FHRg0OLjD7H6yw.cache +1 -0
  129. data/test/dummy/tmp/cache/assets/sprockets/v3.0/xE/xE27JowT8qDp7wND3Y1urntWOI3xOD8RqB95fK5D_dM.cache +1 -0
  130. data/test/dummy/tmp/cache/assets/sprockets/v3.0/z7/z7_Qw6EopSoxIc_kDbNCSpjs3agHMawg8z1KsFLIyvk.cache +3 -0
  131. data/test/dummy/tmp/cache/assets/sprockets/v3.0/zD/zDm8YoPN8R5NzVC4mvxnO-9eRF5b_hRCdg5tp2ebifc.cache +3 -0
  132. data/test/dummy/tmp/development_secret.txt +1 -0
  133. data/test/graphql/voyager/config_test.rb +32 -0
  134. data/test/graphql/voyager/engine_test.rb +15 -0
  135. data/test/graphql/voyager/rails_test.rb +13 -0
  136. data/test/integration/navigation_test.rb +7 -0
  137. data/test/test_helper.rb +19 -0
  138. metadata +401 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7bcaf21d589719f347b9b142b434fd7cb7d5f6a6b4c3cf3c11c3a066fe48f4d7
4
+ data.tar.gz: 06fac95f85d8eaeaf20ac2b7fb0ddea010a7b4c7d6a5e349e767cb20dd256e91
5
+ SHA512:
6
+ metadata.gz: 2a5b5f851d873ef4b6e232b9814fcc1d6521aaed8887f44a338e95df782805c64c82b3718f26607246fd75f7326a2a86aaa63b7a562694c2fa6b9ddfe63baa43
7
+ data.tar.gz: 340716e98ad217d292577b68c6edd90a47a445305cf87252366edfe4dfcf2eaba4e0ffec6290b6ecbd2517b1c163928ff2c26d9398eeffcae3ff92fcf8717913
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Thomas McGoey-Smith
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # GraphQL Voyager Rails
2
+
3
+ Easily mount [GraphQL Voyager](https://github.com/APIs-guru/graphql-voyager) on your rails app.
4
+
5
+ ![image](https://user-images.githubusercontent.com/1266229/60472004-1cafe500-9c35-11e9-93c0-189af3a6aee7.png)
6
+
7
+ ## Usage
8
+
9
+ Simply mount GraphQL Voyager in your `config/routes.rb`:
10
+
11
+ ```ruby
12
+ if Rails.env.development?
13
+ mount Graphql::Voyager::Rails::Engine, at: "/graphql-voyager", graphql_path: "/graphql"
14
+ end
15
+ ```
16
+
17
+ Now you should be able to access GraphQL Voyager at: `http://localhost:3000/graphql-voyager`.
18
+
19
+ ## Installation
20
+ Add this line to your application's Gemfile:
21
+
22
+ ```ruby
23
+ gem 'graphql-voyager-rails'
24
+ ```
25
+
26
+ And then execute:
27
+ ```bash
28
+ $ bundle
29
+ ```
30
+
31
+ Or install it yourself as:
32
+ ```bash
33
+ $ gem install graphql-voyager-rails
34
+ ```
35
+
36
+ ## Contributing
37
+ Pull requests are always welcome.
38
+
39
+ ## License
40
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
41
+
42
+ ## Thanks
43
+
44
+ Gem originally based off on [GraphiQL Rails](https://github.com/rmosolgo/graphiql-rails) and of course [GraphQL Voyager](https://github.com/APIs-guru/graphql-voyager).
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Graphql::Voyager::Rails'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+ load 'rails/tasks/statistics.rake'
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'test'
28
+ t.pattern = 'test/**/*_test.rb'
29
+ t.verbose = false
30
+ end
31
+
32
+ task default: :test
@@ -0,0 +1 @@
1
+ //= link_directory ../stylesheets/graphql/voyager/rails .css
@@ -0,0 +1,4 @@
1
+ //= require ./react-16.8.6
2
+ //= require ./react-dom-16.8.6
3
+ //= require ./fetch-3.0.0
4
+ //= require ./voyager-1.0.0-rc.27
@@ -0,0 +1,531 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
+ (factory((global.WHATWGFetch = {})));
5
+ }(this, (function (exports) { 'use strict';
6
+
7
+ var support = {
8
+ searchParams: 'URLSearchParams' in self,
9
+ iterable: 'Symbol' in self && 'iterator' in Symbol,
10
+ blob:
11
+ 'FileReader' in self &&
12
+ 'Blob' in self &&
13
+ (function() {
14
+ try {
15
+ new Blob();
16
+ return true
17
+ } catch (e) {
18
+ return false
19
+ }
20
+ })(),
21
+ formData: 'FormData' in self,
22
+ arrayBuffer: 'ArrayBuffer' in self
23
+ };
24
+
25
+ function isDataView(obj) {
26
+ return obj && DataView.prototype.isPrototypeOf(obj)
27
+ }
28
+
29
+ if (support.arrayBuffer) {
30
+ var viewClasses = [
31
+ '[object Int8Array]',
32
+ '[object Uint8Array]',
33
+ '[object Uint8ClampedArray]',
34
+ '[object Int16Array]',
35
+ '[object Uint16Array]',
36
+ '[object Int32Array]',
37
+ '[object Uint32Array]',
38
+ '[object Float32Array]',
39
+ '[object Float64Array]'
40
+ ];
41
+
42
+ var isArrayBufferView =
43
+ ArrayBuffer.isView ||
44
+ function(obj) {
45
+ return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
46
+ };
47
+ }
48
+
49
+ function normalizeName(name) {
50
+ if (typeof name !== 'string') {
51
+ name = String(name);
52
+ }
53
+ if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name)) {
54
+ throw new TypeError('Invalid character in header field name')
55
+ }
56
+ return name.toLowerCase()
57
+ }
58
+
59
+ function normalizeValue(value) {
60
+ if (typeof value !== 'string') {
61
+ value = String(value);
62
+ }
63
+ return value
64
+ }
65
+
66
+ // Build a destructive iterator for the value list
67
+ function iteratorFor(items) {
68
+ var iterator = {
69
+ next: function() {
70
+ var value = items.shift();
71
+ return {done: value === undefined, value: value}
72
+ }
73
+ };
74
+
75
+ if (support.iterable) {
76
+ iterator[Symbol.iterator] = function() {
77
+ return iterator
78
+ };
79
+ }
80
+
81
+ return iterator
82
+ }
83
+
84
+ function Headers(headers) {
85
+ this.map = {};
86
+
87
+ if (headers instanceof Headers) {
88
+ headers.forEach(function(value, name) {
89
+ this.append(name, value);
90
+ }, this);
91
+ } else if (Array.isArray(headers)) {
92
+ headers.forEach(function(header) {
93
+ this.append(header[0], header[1]);
94
+ }, this);
95
+ } else if (headers) {
96
+ Object.getOwnPropertyNames(headers).forEach(function(name) {
97
+ this.append(name, headers[name]);
98
+ }, this);
99
+ }
100
+ }
101
+
102
+ Headers.prototype.append = function(name, value) {
103
+ name = normalizeName(name);
104
+ value = normalizeValue(value);
105
+ var oldValue = this.map[name];
106
+ this.map[name] = oldValue ? oldValue + ', ' + value : value;
107
+ };
108
+
109
+ Headers.prototype['delete'] = function(name) {
110
+ delete this.map[normalizeName(name)];
111
+ };
112
+
113
+ Headers.prototype.get = function(name) {
114
+ name = normalizeName(name);
115
+ return this.has(name) ? this.map[name] : null
116
+ };
117
+
118
+ Headers.prototype.has = function(name) {
119
+ return this.map.hasOwnProperty(normalizeName(name))
120
+ };
121
+
122
+ Headers.prototype.set = function(name, value) {
123
+ this.map[normalizeName(name)] = normalizeValue(value);
124
+ };
125
+
126
+ Headers.prototype.forEach = function(callback, thisArg) {
127
+ for (var name in this.map) {
128
+ if (this.map.hasOwnProperty(name)) {
129
+ callback.call(thisArg, this.map[name], name, this);
130
+ }
131
+ }
132
+ };
133
+
134
+ Headers.prototype.keys = function() {
135
+ var items = [];
136
+ this.forEach(function(value, name) {
137
+ items.push(name);
138
+ });
139
+ return iteratorFor(items)
140
+ };
141
+
142
+ Headers.prototype.values = function() {
143
+ var items = [];
144
+ this.forEach(function(value) {
145
+ items.push(value);
146
+ });
147
+ return iteratorFor(items)
148
+ };
149
+
150
+ Headers.prototype.entries = function() {
151
+ var items = [];
152
+ this.forEach(function(value, name) {
153
+ items.push([name, value]);
154
+ });
155
+ return iteratorFor(items)
156
+ };
157
+
158
+ if (support.iterable) {
159
+ Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
160
+ }
161
+
162
+ function consumed(body) {
163
+ if (body.bodyUsed) {
164
+ return Promise.reject(new TypeError('Already read'))
165
+ }
166
+ body.bodyUsed = true;
167
+ }
168
+
169
+ function fileReaderReady(reader) {
170
+ return new Promise(function(resolve, reject) {
171
+ reader.onload = function() {
172
+ resolve(reader.result);
173
+ };
174
+ reader.onerror = function() {
175
+ reject(reader.error);
176
+ };
177
+ })
178
+ }
179
+
180
+ function readBlobAsArrayBuffer(blob) {
181
+ var reader = new FileReader();
182
+ var promise = fileReaderReady(reader);
183
+ reader.readAsArrayBuffer(blob);
184
+ return promise
185
+ }
186
+
187
+ function readBlobAsText(blob) {
188
+ var reader = new FileReader();
189
+ var promise = fileReaderReady(reader);
190
+ reader.readAsText(blob);
191
+ return promise
192
+ }
193
+
194
+ function readArrayBufferAsText(buf) {
195
+ var view = new Uint8Array(buf);
196
+ var chars = new Array(view.length);
197
+
198
+ for (var i = 0; i < view.length; i++) {
199
+ chars[i] = String.fromCharCode(view[i]);
200
+ }
201
+ return chars.join('')
202
+ }
203
+
204
+ function bufferClone(buf) {
205
+ if (buf.slice) {
206
+ return buf.slice(0)
207
+ } else {
208
+ var view = new Uint8Array(buf.byteLength);
209
+ view.set(new Uint8Array(buf));
210
+ return view.buffer
211
+ }
212
+ }
213
+
214
+ function Body() {
215
+ this.bodyUsed = false;
216
+
217
+ this._initBody = function(body) {
218
+ this._bodyInit = body;
219
+ if (!body) {
220
+ this._bodyText = '';
221
+ } else if (typeof body === 'string') {
222
+ this._bodyText = body;
223
+ } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
224
+ this._bodyBlob = body;
225
+ } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
226
+ this._bodyFormData = body;
227
+ } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
228
+ this._bodyText = body.toString();
229
+ } else if (support.arrayBuffer && support.blob && isDataView(body)) {
230
+ this._bodyArrayBuffer = bufferClone(body.buffer);
231
+ // IE 10-11 can't handle a DataView body.
232
+ this._bodyInit = new Blob([this._bodyArrayBuffer]);
233
+ } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
234
+ this._bodyArrayBuffer = bufferClone(body);
235
+ } else {
236
+ this._bodyText = body = Object.prototype.toString.call(body);
237
+ }
238
+
239
+ if (!this.headers.get('content-type')) {
240
+ if (typeof body === 'string') {
241
+ this.headers.set('content-type', 'text/plain;charset=UTF-8');
242
+ } else if (this._bodyBlob && this._bodyBlob.type) {
243
+ this.headers.set('content-type', this._bodyBlob.type);
244
+ } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
245
+ this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
246
+ }
247
+ }
248
+ };
249
+
250
+ if (support.blob) {
251
+ this.blob = function() {
252
+ var rejected = consumed(this);
253
+ if (rejected) {
254
+ return rejected
255
+ }
256
+
257
+ if (this._bodyBlob) {
258
+ return Promise.resolve(this._bodyBlob)
259
+ } else if (this._bodyArrayBuffer) {
260
+ return Promise.resolve(new Blob([this._bodyArrayBuffer]))
261
+ } else if (this._bodyFormData) {
262
+ throw new Error('could not read FormData body as blob')
263
+ } else {
264
+ return Promise.resolve(new Blob([this._bodyText]))
265
+ }
266
+ };
267
+
268
+ this.arrayBuffer = function() {
269
+ if (this._bodyArrayBuffer) {
270
+ return consumed(this) || Promise.resolve(this._bodyArrayBuffer)
271
+ } else {
272
+ return this.blob().then(readBlobAsArrayBuffer)
273
+ }
274
+ };
275
+ }
276
+
277
+ this.text = function() {
278
+ var rejected = consumed(this);
279
+ if (rejected) {
280
+ return rejected
281
+ }
282
+
283
+ if (this._bodyBlob) {
284
+ return readBlobAsText(this._bodyBlob)
285
+ } else if (this._bodyArrayBuffer) {
286
+ return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
287
+ } else if (this._bodyFormData) {
288
+ throw new Error('could not read FormData body as text')
289
+ } else {
290
+ return Promise.resolve(this._bodyText)
291
+ }
292
+ };
293
+
294
+ if (support.formData) {
295
+ this.formData = function() {
296
+ return this.text().then(decode)
297
+ };
298
+ }
299
+
300
+ this.json = function() {
301
+ return this.text().then(JSON.parse)
302
+ };
303
+
304
+ return this
305
+ }
306
+
307
+ // HTTP methods whose capitalization should be normalized
308
+ var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'];
309
+
310
+ function normalizeMethod(method) {
311
+ var upcased = method.toUpperCase();
312
+ return methods.indexOf(upcased) > -1 ? upcased : method
313
+ }
314
+
315
+ function Request(input, options) {
316
+ options = options || {};
317
+ var body = options.body;
318
+
319
+ if (input instanceof Request) {
320
+ if (input.bodyUsed) {
321
+ throw new TypeError('Already read')
322
+ }
323
+ this.url = input.url;
324
+ this.credentials = input.credentials;
325
+ if (!options.headers) {
326
+ this.headers = new Headers(input.headers);
327
+ }
328
+ this.method = input.method;
329
+ this.mode = input.mode;
330
+ this.signal = input.signal;
331
+ if (!body && input._bodyInit != null) {
332
+ body = input._bodyInit;
333
+ input.bodyUsed = true;
334
+ }
335
+ } else {
336
+ this.url = String(input);
337
+ }
338
+
339
+ this.credentials = options.credentials || this.credentials || 'same-origin';
340
+ if (options.headers || !this.headers) {
341
+ this.headers = new Headers(options.headers);
342
+ }
343
+ this.method = normalizeMethod(options.method || this.method || 'GET');
344
+ this.mode = options.mode || this.mode || null;
345
+ this.signal = options.signal || this.signal;
346
+ this.referrer = null;
347
+
348
+ if ((this.method === 'GET' || this.method === 'HEAD') && body) {
349
+ throw new TypeError('Body not allowed for GET or HEAD requests')
350
+ }
351
+ this._initBody(body);
352
+ }
353
+
354
+ Request.prototype.clone = function() {
355
+ return new Request(this, {body: this._bodyInit})
356
+ };
357
+
358
+ function decode(body) {
359
+ var form = new FormData();
360
+ body
361
+ .trim()
362
+ .split('&')
363
+ .forEach(function(bytes) {
364
+ if (bytes) {
365
+ var split = bytes.split('=');
366
+ var name = split.shift().replace(/\+/g, ' ');
367
+ var value = split.join('=').replace(/\+/g, ' ');
368
+ form.append(decodeURIComponent(name), decodeURIComponent(value));
369
+ }
370
+ });
371
+ return form
372
+ }
373
+
374
+ function parseHeaders(rawHeaders) {
375
+ var headers = new Headers();
376
+ // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
377
+ // https://tools.ietf.org/html/rfc7230#section-3.2
378
+ var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ');
379
+ preProcessedHeaders.split(/\r?\n/).forEach(function(line) {
380
+ var parts = line.split(':');
381
+ var key = parts.shift().trim();
382
+ if (key) {
383
+ var value = parts.join(':').trim();
384
+ headers.append(key, value);
385
+ }
386
+ });
387
+ return headers
388
+ }
389
+
390
+ Body.call(Request.prototype);
391
+
392
+ function Response(bodyInit, options) {
393
+ if (!options) {
394
+ options = {};
395
+ }
396
+
397
+ this.type = 'default';
398
+ this.status = options.status === undefined ? 200 : options.status;
399
+ this.ok = this.status >= 200 && this.status < 300;
400
+ this.statusText = 'statusText' in options ? options.statusText : 'OK';
401
+ this.headers = new Headers(options.headers);
402
+ this.url = options.url || '';
403
+ this._initBody(bodyInit);
404
+ }
405
+
406
+ Body.call(Response.prototype);
407
+
408
+ Response.prototype.clone = function() {
409
+ return new Response(this._bodyInit, {
410
+ status: this.status,
411
+ statusText: this.statusText,
412
+ headers: new Headers(this.headers),
413
+ url: this.url
414
+ })
415
+ };
416
+
417
+ Response.error = function() {
418
+ var response = new Response(null, {status: 0, statusText: ''});
419
+ response.type = 'error';
420
+ return response
421
+ };
422
+
423
+ var redirectStatuses = [301, 302, 303, 307, 308];
424
+
425
+ Response.redirect = function(url, status) {
426
+ if (redirectStatuses.indexOf(status) === -1) {
427
+ throw new RangeError('Invalid status code')
428
+ }
429
+
430
+ return new Response(null, {status: status, headers: {location: url}})
431
+ };
432
+
433
+ exports.DOMException = self.DOMException;
434
+ try {
435
+ new exports.DOMException();
436
+ } catch (err) {
437
+ exports.DOMException = function(message, name) {
438
+ this.message = message;
439
+ this.name = name;
440
+ var error = Error(message);
441
+ this.stack = error.stack;
442
+ };
443
+ exports.DOMException.prototype = Object.create(Error.prototype);
444
+ exports.DOMException.prototype.constructor = exports.DOMException;
445
+ }
446
+
447
+ function fetch(input, init) {
448
+ return new Promise(function(resolve, reject) {
449
+ var request = new Request(input, init);
450
+
451
+ if (request.signal && request.signal.aborted) {
452
+ return reject(new exports.DOMException('Aborted', 'AbortError'))
453
+ }
454
+
455
+ var xhr = new XMLHttpRequest();
456
+
457
+ function abortXhr() {
458
+ xhr.abort();
459
+ }
460
+
461
+ xhr.onload = function() {
462
+ var options = {
463
+ status: xhr.status,
464
+ statusText: xhr.statusText,
465
+ headers: parseHeaders(xhr.getAllResponseHeaders() || '')
466
+ };
467
+ options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
468
+ var body = 'response' in xhr ? xhr.response : xhr.responseText;
469
+ resolve(new Response(body, options));
470
+ };
471
+
472
+ xhr.onerror = function() {
473
+ reject(new TypeError('Network request failed'));
474
+ };
475
+
476
+ xhr.ontimeout = function() {
477
+ reject(new TypeError('Network request failed'));
478
+ };
479
+
480
+ xhr.onabort = function() {
481
+ reject(new exports.DOMException('Aborted', 'AbortError'));
482
+ };
483
+
484
+ xhr.open(request.method, request.url, true);
485
+
486
+ if (request.credentials === 'include') {
487
+ xhr.withCredentials = true;
488
+ } else if (request.credentials === 'omit') {
489
+ xhr.withCredentials = false;
490
+ }
491
+
492
+ if ('responseType' in xhr && support.blob) {
493
+ xhr.responseType = 'blob';
494
+ }
495
+
496
+ request.headers.forEach(function(value, name) {
497
+ xhr.setRequestHeader(name, value);
498
+ });
499
+
500
+ if (request.signal) {
501
+ request.signal.addEventListener('abort', abortXhr);
502
+
503
+ xhr.onreadystatechange = function() {
504
+ // DONE (success or failure)
505
+ if (xhr.readyState === 4) {
506
+ request.signal.removeEventListener('abort', abortXhr);
507
+ }
508
+ };
509
+ }
510
+
511
+ xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);
512
+ })
513
+ }
514
+
515
+ fetch.polyfill = true;
516
+
517
+ if (!self.fetch) {
518
+ self.fetch = fetch;
519
+ self.Headers = Headers;
520
+ self.Request = Request;
521
+ self.Response = Response;
522
+ }
523
+
524
+ exports.Headers = Headers;
525
+ exports.Request = Request;
526
+ exports.Response = Response;
527
+ exports.fetch = fetch;
528
+
529
+ Object.defineProperty(exports, '__esModule', { value: true });
530
+
531
+ })));