not really known
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.

187 lines
6.4 KiB

  1. /******/ (function(modules) { // webpackBootstrap
  2. /******/ // The module cache
  3. /******/ var installedModules = {};
  4. /******/
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/
  8. /******/ // Check if module is in cache
  9. /******/ if(installedModules[moduleId]) {
  10. /******/ return installedModules[moduleId].exports;
  11. /******/ }
  12. /******/ // Create a new module (and put it into the cache)
  13. /******/ var module = installedModules[moduleId] = {
  14. /******/ i: moduleId,
  15. /******/ l: false,
  16. /******/ exports: {}
  17. /******/ };
  18. /******/
  19. /******/ // Execute the module function
  20. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  21. /******/
  22. /******/ // Flag the module as loaded
  23. /******/ module.l = true;
  24. /******/
  25. /******/ // Return the exports of the module
  26. /******/ return module.exports;
  27. /******/ }
  28. /******/
  29. /******/
  30. /******/ // expose the modules object (__webpack_modules__)
  31. /******/ __webpack_require__.m = modules;
  32. /******/
  33. /******/ // expose the module cache
  34. /******/ __webpack_require__.c = installedModules;
  35. /******/
  36. /******/ // define getter function for harmony exports
  37. /******/ __webpack_require__.d = function(exports, name, getter) {
  38. /******/ if(!__webpack_require__.o(exports, name)) {
  39. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  40. /******/ }
  41. /******/ };
  42. /******/
  43. /******/ // define __esModule on exports
  44. /******/ __webpack_require__.r = function(exports) {
  45. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  46. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  47. /******/ }
  48. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  49. /******/ };
  50. /******/
  51. /******/ // create a fake namespace object
  52. /******/ // mode & 1: value is a module id, require it
  53. /******/ // mode & 2: merge all properties of value into the ns
  54. /******/ // mode & 4: return value when already ns object
  55. /******/ // mode & 8|1: behave like require
  56. /******/ __webpack_require__.t = function(value, mode) {
  57. /******/ if(mode & 1) value = __webpack_require__(value);
  58. /******/ if(mode & 8) return value;
  59. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  60. /******/ var ns = Object.create(null);
  61. /******/ __webpack_require__.r(ns);
  62. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  63. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  64. /******/ return ns;
  65. /******/ };
  66. /******/
  67. /******/ // getDefaultExport function for compatibility with non-harmony modules
  68. /******/ __webpack_require__.n = function(module) {
  69. /******/ var getter = module && module.__esModule ?
  70. /******/ function getDefault() { return module['default']; } :
  71. /******/ function getModuleExports() { return module; };
  72. /******/ __webpack_require__.d(getter, 'a', getter);
  73. /******/ return getter;
  74. /******/ };
  75. /******/
  76. /******/ // Object.prototype.hasOwnProperty.call
  77. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  78. /******/
  79. /******/ // __webpack_public_path__
  80. /******/ __webpack_require__.p = "";
  81. /******/
  82. /******/
  83. /******/ // Load entry module and return exports
  84. /******/ return __webpack_require__(__webpack_require__.s = "./node_modules/babel-loader/lib/index.js?!./node_modules/scratch-storage/src/FetchWorkerTool.worker.js");
  85. /******/ })
  86. /************************************************************************/
  87. /******/ ({
  88. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/scratch-storage/src/FetchWorkerTool.worker.js":
  89. /*!************************************************************************************************************!*\
  90. !*** ./node_modules/babel-loader/lib??ref--4!./node_modules/scratch-storage/src/FetchWorkerTool.worker.js ***!
  91. \************************************************************************************************************/
  92. /*! no static exports found */
  93. /***/ (function(module, exports) {
  94. /* eslint-env worker */
  95. var jobsActive = 0;
  96. var complete = [];
  97. var intervalId = null;
  98. /**
  99. * Register a step function.
  100. *
  101. * Step checks if there are completed jobs and if there are sends them to the
  102. * parent. Then it checks the jobs count. If there are no further jobs, clear
  103. * the step.
  104. */
  105. var registerStep = function registerStep() {
  106. intervalId = setInterval(function () {
  107. if (complete.length) {
  108. // Send our chunk of completed requests and instruct postMessage to
  109. // transfer the buffers instead of copying them.
  110. postMessage(complete.slice(), // Instruct postMessage that these buffers in the sent message
  111. // should use their Transferable trait. After the postMessage
  112. // call the "buffers" will still be in complete if you looked,
  113. // but they will all be length 0 as the data they reference has
  114. // been sent to the window. This lets us send a lot of data
  115. // without the normal postMessage behaviour of making a copy of
  116. // all of the data for the window.
  117. complete.map(function (response) {
  118. return response.buffer;
  119. }).filter(Boolean));
  120. complete.length = 0;
  121. }
  122. if (jobsActive === 0) {
  123. clearInterval(intervalId);
  124. intervalId = null;
  125. }
  126. }, 1);
  127. };
  128. /**
  129. * Receive a job from the parent and fetch the requested data.
  130. * @param {object} options.job A job id, url, and options descriptor to perform.
  131. */
  132. var onMessage = function onMessage(_ref) {
  133. var job = _ref.data;
  134. if (jobsActive === 0 && !intervalId) {
  135. registerStep();
  136. }
  137. jobsActive++;
  138. fetch(job.url, job.options).then(function (response) {
  139. return response.arrayBuffer();
  140. }).then(function (buffer) {
  141. return complete.push({
  142. id: job.id,
  143. buffer: buffer
  144. });
  145. }).catch(function (error) {
  146. return complete.push({
  147. id: job.id,
  148. error: error
  149. });
  150. }).then(function () {
  151. return jobsActive--;
  152. });
  153. };
  154. if (self.fetch) {
  155. postMessage({
  156. support: {
  157. fetch: true
  158. }
  159. });
  160. self.addEventListener('message', onMessage);
  161. } else {
  162. postMessage({
  163. support: {
  164. fetch: false
  165. }
  166. });
  167. self.addEventListener('message', function (_ref2) {
  168. var job = _ref2.data;
  169. postMessage([{
  170. id: job.id,
  171. error: new Error('fetch is unavailable')
  172. }]);
  173. });
  174. }
  175. /***/ })
  176. /******/ });
  177. //# sourceMappingURL=326c5f98902ccd335b5b.worker.js.map