JsonpMainTemplate.runtime.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. // eslint-disable-next-line no-unused-vars
  6. var hotAddUpdateChunk = undefined;
  7. var parentHotUpdateCallback = undefined;
  8. var $require$ = undefined;
  9. var $hotMainFilename$ = undefined;
  10. var $hotChunkFilename$ = undefined;
  11. var $crossOriginLoading$ = undefined;
  12. module.exports = function() {
  13. // eslint-disable-next-line no-unused-vars
  14. function webpackHotUpdateCallback(chunkId, moreModules) {
  15. hotAddUpdateChunk(chunkId, moreModules);
  16. if (parentHotUpdateCallback) parentHotUpdateCallback(chunkId, moreModules);
  17. } //$semicolon
  18. // eslint-disable-next-line no-unused-vars
  19. function hotDownloadUpdateChunk(chunkId) {
  20. var script = document.createElement("script");
  21. script.charset = "utf-8";
  22. script.src = $require$.p + $hotChunkFilename$;
  23. if ($crossOriginLoading$) script.crossOrigin = $crossOriginLoading$;
  24. document.head.appendChild(script);
  25. }
  26. // eslint-disable-next-line no-unused-vars
  27. function hotDownloadManifest(requestTimeout) {
  28. requestTimeout = requestTimeout || 10000;
  29. return new Promise(function(resolve, reject) {
  30. if (typeof XMLHttpRequest === "undefined") {
  31. return reject(new Error("No browser support"));
  32. }
  33. try {
  34. var request = new XMLHttpRequest();
  35. var requestPath = $require$.p + $hotMainFilename$;
  36. request.open("GET", requestPath, true);
  37. request.timeout = requestTimeout;
  38. request.send(null);
  39. } catch (err) {
  40. return reject(err);
  41. }
  42. request.onreadystatechange = function() {
  43. if (request.readyState !== 4) return;
  44. if (request.status === 0) {
  45. // timeout
  46. reject(
  47. new Error("Manifest request to " + requestPath + " timed out.")
  48. );
  49. } else if (request.status === 404) {
  50. // no update available
  51. resolve();
  52. } else if (request.status !== 200 && request.status !== 304) {
  53. // other failure
  54. reject(new Error("Manifest request to " + requestPath + " failed."));
  55. } else {
  56. // success
  57. try {
  58. var update = JSON.parse(request.responseText);
  59. } catch (e) {
  60. reject(e);
  61. return;
  62. }
  63. resolve(update);
  64. }
  65. };
  66. });
  67. }
  68. };