WebWorkerMainTemplate.runtime.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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(requestTimeout) { // eslint-disable-line no-unused-vars
  15. requestTimeout = requestTimeout || 10000;
  16. return new Promise(function(resolve, reject) {
  17. if(typeof XMLHttpRequest === "undefined")
  18. return reject(new Error("No browser support"));
  19. try {
  20. var request = new XMLHttpRequest();
  21. var requestPath = $require$.p + $hotMainFilename$;
  22. request.open("GET", requestPath, true);
  23. request.timeout = requestTimeout;
  24. request.send(null);
  25. } catch(err) {
  26. return reject(err);
  27. }
  28. request.onreadystatechange = function() {
  29. if(request.readyState !== 4) return;
  30. if(request.status === 0) {
  31. // timeout
  32. reject(new Error("Manifest request to " + requestPath + " timed out."));
  33. } else if(request.status === 404) {
  34. // no update available
  35. resolve();
  36. } else if(request.status !== 200 && request.status !== 304) {
  37. // other failure
  38. reject(new Error("Manifest request to " + requestPath + " failed."));
  39. } else {
  40. // success
  41. try {
  42. var update = JSON.parse(request.responseText);
  43. } catch(e) {
  44. reject(e);
  45. return;
  46. }
  47. resolve(update);
  48. }
  49. };
  50. });
  51. }
  52. function hotDisposeChunk(chunkId) { //eslint-disable-line no-unused-vars
  53. delete installedChunks[chunkId];
  54. }
  55. };