You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

JsonpMainTemplate.runtime.js 2.0KB

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