WebWorkerMainTemplate.runtime.js 1.9 KB

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