UNPKG

scratch-vm

Version:
1,320 lines (1,061 loc) • 63.3 kB
/******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = "./node_modules/babel-loader/lib/index.js?!./src/extension-support/extension-worker.js"); /******/ }) /************************************************************************/ /******/ ({ /***/ "./node_modules/babel-loader/lib/index.js?!./src/extension-support/extension-worker.js": /*!*******************************************************************************************!*\ !*** ./node_modules/babel-loader/lib??ref--4!./src/extension-support/extension-worker.js ***! \*******************************************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } /* eslint-env worker */ var ArgumentType = __webpack_require__(/*! ../extension-support/argument-type */ "./src/extension-support/argument-type.js"); var BlockType = __webpack_require__(/*! ../extension-support/block-type */ "./src/extension-support/block-type.js"); var dispatch = __webpack_require__(/*! ../dispatch/worker-dispatch */ "./src/dispatch/worker-dispatch.js"); var TargetType = __webpack_require__(/*! ../extension-support/target-type */ "./src/extension-support/target-type.js"); var ExtensionWorker = /*#__PURE__*/function () { function ExtensionWorker() { var _this = this; _classCallCheck(this, ExtensionWorker); this.nextExtensionId = 0; this.initialRegistrations = []; dispatch.waitForConnection.then(function () { dispatch.call('extensions', 'allocateWorker').then(function (x) { var _x = _slicedToArray(x, 2), id = _x[0], extension = _x[1]; _this.workerId = id; try { importScripts(extension); var initialRegistrations = _this.initialRegistrations; _this.initialRegistrations = null; Promise.all(initialRegistrations).then(function () { return dispatch.call('extensions', 'onWorkerInit', id); }); } catch (e) { dispatch.call('extensions', 'onWorkerInit', id, e); } }); }); this.extensions = []; } _createClass(ExtensionWorker, [{ key: "register", value: function register(extensionObject) { var extensionId = this.nextExtensionId++; this.extensions.push(extensionObject); var serviceName = "extension.".concat(this.workerId, ".").concat(extensionId); var promise = dispatch.setService(serviceName, extensionObject).then(function () { return dispatch.call('extensions', 'registerExtensionService', serviceName); }); if (this.initialRegistrations) { this.initialRegistrations.push(promise); } return promise; } }]); return ExtensionWorker; }(); global.Scratch = global.Scratch || {}; global.Scratch.ArgumentType = ArgumentType; global.Scratch.BlockType = BlockType; global.Scratch.TargetType = TargetType; /** * Expose only specific parts of the worker to extensions. */ var extensionWorker = new ExtensionWorker(); global.Scratch.extensions = { register: extensionWorker.register.bind(extensionWorker) }; /***/ }), /***/ "./node_modules/microee/index.js": /*!***************************************!*\ !*** ./node_modules/microee/index.js ***! \***************************************/ /*! no static exports found */ /***/ (function(module, exports) { function M() { this._events = {}; } M.prototype = { on: function(ev, cb) { this._events || (this._events = {}); var e = this._events; (e[ev] || (e[ev] = [])).push(cb); return this; }, removeListener: function(ev, cb) { var e = this._events[ev] || [], i; for(i = e.length-1; i >= 0 && e[i]; i--){ if(e[i] === cb || e[i].cb === cb) { e.splice(i, 1); } } }, removeAllListeners: function(ev) { if(!ev) { this._events = {}; } else { this._events[ev] && (this._events[ev] = []); } }, listeners: function(ev) { return (this._events ? this._events[ev] || [] : []); }, emit: function(ev) { this._events || (this._events = {}); var args = Array.prototype.slice.call(arguments, 1), i, e = this._events[ev] || []; for(i = e.length-1; i >= 0 && e[i]; i--){ e[i].apply(this, args); } return this; }, when: function(ev, cb) { return this.once(ev, cb, true); }, once: function(ev, cb, when) { if(!cb) return this; function c() { if(!when) this.removeListener(ev, c); if(cb.apply(this, arguments) && when) this.removeListener(ev, c); } c.cb = cb; this.on(ev, c); return this; } }; M.mixin = function(dest) { var o = M.prototype, k; for (k in o) { o.hasOwnProperty(k) && (dest.prototype[k] = o[k]); } }; module.exports = M; /***/ }), /***/ "./node_modules/minilog/lib/common/filter.js": /*!***************************************************!*\ !*** ./node_modules/minilog/lib/common/filter.js ***! \***************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { // default filter var Transform = __webpack_require__(/*! ./transform.js */ "./node_modules/minilog/lib/common/transform.js"); var levelMap = { debug: 1, info: 2, warn: 3, error: 4 }; function Filter() { this.enabled = true; this.defaultResult = true; this.clear(); } Transform.mixin(Filter); // allow all matching, with level >= given level Filter.prototype.allow = function(name, level) { this._white.push({ n: name, l: levelMap[level] }); return this; }; // deny all matching, with level <= given level Filter.prototype.deny = function(name, level) { this._black.push({ n: name, l: levelMap[level] }); return this; }; Filter.prototype.clear = function() { this._white = []; this._black = []; return this; }; function test(rule, name) { // use .test for RegExps return (rule.n.test ? rule.n.test(name) : rule.n == name); }; Filter.prototype.test = function(name, level) { var i, len = Math.max(this._white.length, this._black.length); for(i = 0; i < len; i++) { if(this._white[i] && test(this._white[i], name) && levelMap[level] >= this._white[i].l) { return true; } if(this._black[i] && test(this._black[i], name) && levelMap[level] <= this._black[i].l) { return false; } } return this.defaultResult; }; Filter.prototype.write = function(name, level, args) { if(!this.enabled || this.test(name, level)) { return this.emit('item', name, level, args); } }; module.exports = Filter; /***/ }), /***/ "./node_modules/minilog/lib/common/minilog.js": /*!****************************************************!*\ !*** ./node_modules/minilog/lib/common/minilog.js ***! \****************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { var Transform = __webpack_require__(/*! ./transform.js */ "./node_modules/minilog/lib/common/transform.js"), Filter = __webpack_require__(/*! ./filter.js */ "./node_modules/minilog/lib/common/filter.js"); var log = new Transform(), slice = Array.prototype.slice; exports = module.exports = function create(name) { var o = function() { log.write(name, undefined, slice.call(arguments)); return o; }; o.debug = function() { log.write(name, 'debug', slice.call(arguments)); return o; }; o.info = function() { log.write(name, 'info', slice.call(arguments)); return o; }; o.warn = function() { log.write(name, 'warn', slice.call(arguments)); return o; }; o.error = function() { log.write(name, 'error', slice.call(arguments)); return o; }; o.log = o.debug; // for interface compliance with Node and browser consoles o.suggest = exports.suggest; o.format = log.format; return o; }; // filled in separately exports.defaultBackend = exports.defaultFormatter = null; exports.pipe = function(dest) { return log.pipe(dest); }; exports.end = exports.unpipe = exports.disable = function(from) { return log.unpipe(from); }; exports.Transform = Transform; exports.Filter = Filter; // this is the default filter that's applied when .enable() is called normally // you can bypass it completely and set up your own pipes exports.suggest = new Filter(); exports.enable = function() { if(exports.defaultFormatter) { return log.pipe(exports.suggest) // filter .pipe(exports.defaultFormatter) // formatter .pipe(exports.defaultBackend); // backend } return log.pipe(exports.suggest) // filter .pipe(exports.defaultBackend); // formatter }; /***/ }), /***/ "./node_modules/minilog/lib/common/transform.js": /*!******************************************************!*\ !*** ./node_modules/minilog/lib/common/transform.js ***! \******************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { var microee = __webpack_require__(/*! microee */ "./node_modules/microee/index.js"); // Implements a subset of Node's stream.Transform - in a cross-platform manner. function Transform() {} microee.mixin(Transform); // The write() signature is different from Node's // --> makes it much easier to work with objects in logs. // One of the lessons from v1 was that it's better to target // a good browser rather than the lowest common denominator // internally. // If you want to use external streams, pipe() to ./stringify.js first. Transform.prototype.write = function(name, level, args) { this.emit('item', name, level, args); }; Transform.prototype.end = function() { this.emit('end'); this.removeAllListeners(); }; Transform.prototype.pipe = function(dest) { var s = this; // prevent double piping s.emit('unpipe', dest); // tell the dest that it's being piped to dest.emit('pipe', s); function onItem() { dest.write.apply(dest, Array.prototype.slice.call(arguments)); } function onEnd() { !dest._isStdio && dest.end(); } s.on('item', onItem); s.on('end', onEnd); s.when('unpipe', function(from) { var match = (from === dest) || typeof from == 'undefined'; if(match) { s.removeListener('item', onItem); s.removeListener('end', onEnd); dest.emit('unpipe'); } return match; }); return dest; }; Transform.prototype.unpipe = function(from) { this.emit('unpipe', from); return this; }; Transform.prototype.format = function(dest) { throw new Error([ 'Warning: .format() is deprecated in Minilog v2! Use .pipe() instead. For example:', 'var Minilog = require(\'minilog\');', 'Minilog', ' .pipe(Minilog.backends.console.formatClean)', ' .pipe(Minilog.backends.console);'].join('\n')); }; Transform.mixin = function(dest) { var o = Transform.prototype, k; for (k in o) { o.hasOwnProperty(k) && (dest.prototype[k] = o[k]); } }; module.exports = Transform; /***/ }), /***/ "./node_modules/minilog/lib/index.js": /*!*******************************************!*\ !*** ./node_modules/minilog/lib/index.js ***! \*******************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { module.exports = __webpack_require__(/*! ./common/minilog.js */ "./node_modules/minilog/lib/common/minilog.js"); var consoleLogger = __webpack_require__(/*! ./node/console.js */ "./node_modules/minilog/lib/node/console.js"); // if we are running inside Electron then use the web version of console.js var isElectron = (typeof window !== 'undefined' && window.process && window.process.type === 'renderer'); if (isElectron) { consoleLogger = __webpack_require__(/*! ./web/console.js */ "./node_modules/minilog/lib/web/console.js").minilog; } // intercept the pipe method and transparently wrap the stringifier, if the // destination is a Node core stream module.exports.Stringifier = __webpack_require__(/*! ./node/stringify.js */ "./node_modules/minilog/lib/node/stringify.js"); var oldPipe = module.exports.pipe; module.exports.pipe = function(dest) { if(dest instanceof __webpack_require__(/*! stream */ "stream")) { return oldPipe.call(module.exports, new (module.exports.Stringifier)).pipe(dest); } else { return oldPipe.call(module.exports, dest); } }; module.exports.defaultBackend = consoleLogger; module.exports.defaultFormatter = consoleLogger.formatMinilog; module.exports.backends = { redis: __webpack_require__(/*! ./node/redis.js */ "./node_modules/minilog/lib/node/redis.js"), nodeConsole: consoleLogger, console: consoleLogger }; /***/ }), /***/ "./node_modules/minilog/lib/node/console.js": /*!**************************************************!*\ !*** ./node_modules/minilog/lib/node/console.js ***! \**************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { var Transform = __webpack_require__(/*! ../common/transform.js */ "./node_modules/minilog/lib/common/transform.js"); function ConsoleBackend() { } Transform.mixin(ConsoleBackend); ConsoleBackend.prototype.write = function() { console.log.apply(console, arguments); }; var e = new ConsoleBackend(); var levelMap = __webpack_require__(/*! ./formatters/util.js */ "./node_modules/minilog/lib/node/formatters/util.js").levelMap; e.filterEnv = function() { console.error('Minilog.backends.console.filterEnv is deprecated in Minilog v2.'); // return the instance of Minilog return __webpack_require__(/*! ../common/minilog.js */ "./node_modules/minilog/lib/common/minilog.js"); }; e.formatters = [ 'formatClean', 'formatColor', 'formatNpm', 'formatLearnboost', 'formatMinilog', 'formatWithStack', 'formatTime' ]; e.formatClean = new (__webpack_require__(/*! ./formatters/clean.js */ "./node_modules/minilog/lib/node/formatters/clean.js")); e.formatColor = new (__webpack_require__(/*! ./formatters/color.js */ "./node_modules/minilog/lib/node/formatters/color.js")); e.formatNpm = new (__webpack_require__(/*! ./formatters/npm.js */ "./node_modules/minilog/lib/node/formatters/npm.js")); e.formatLearnboost = new (__webpack_require__(/*! ./formatters/learnboost.js */ "./node_modules/minilog/lib/node/formatters/learnboost.js")); e.formatMinilog = new (__webpack_require__(/*! ./formatters/minilog.js */ "./node_modules/minilog/lib/node/formatters/minilog.js")); e.formatWithStack = new (__webpack_require__(/*! ./formatters/withstack.js */ "./node_modules/minilog/lib/node/formatters/withstack.js")); e.formatTime = new (__webpack_require__(/*! ./formatters/time.js */ "./node_modules/minilog/lib/node/formatters/time.js")); module.exports = e; /***/ }), /***/ "./node_modules/minilog/lib/node/formatters/clean.js": /*!***********************************************************!*\ !*** ./node_modules/minilog/lib/node/formatters/clean.js ***! \***********************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { var Transform = __webpack_require__(/*! ../../common/transform.js */ "./node_modules/minilog/lib/common/transform.js"); function FormatClean() {} Transform.mixin(FormatClean); FormatClean.prototype.write = function(name, level, args) { function pad(s) { return (s.toString().length == 1? '0'+s : s); } this.emit('item', (name ? name + ' ' : '') + (level ? level + ' ' : '') + args.join(' ')); }; module.exports = FormatClean; /***/ }), /***/ "./node_modules/minilog/lib/node/formatters/color.js": /*!***********************************************************!*\ !*** ./node_modules/minilog/lib/node/formatters/color.js ***! \***********************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { var Transform = __webpack_require__(/*! ../../common/transform.js */ "./node_modules/minilog/lib/common/transform.js"), style = __webpack_require__(/*! ./util.js */ "./node_modules/minilog/lib/node/formatters/util.js").style; function FormatColor() {} Transform.mixin(FormatColor); FormatColor.prototype.write = function(name, level, args) { var colors = { debug: 'magenta', info: 'cyan', warn: 'yellow', error: 'red' }; function pad(s) { return (s.toString().length == 4? ' '+s : s); } this.emit('item', (name ? name + ' ' : '') + (level ? style('- ' + pad(level.toUpperCase()) + ' -', colors[level]) + ' ' : '') + args.join(' ')); }; module.exports = FormatColor; /***/ }), /***/ "./node_modules/minilog/lib/node/formatters/learnboost.js": /*!****************************************************************!*\ !*** ./node_modules/minilog/lib/node/formatters/learnboost.js ***! \****************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { var Transform = __webpack_require__(/*! ../../common/transform.js */ "./node_modules/minilog/lib/common/transform.js"), style = __webpack_require__(/*! ./util.js */ "./node_modules/minilog/lib/node/formatters/util.js").style; function FormatLearnboost() {} Transform.mixin(FormatLearnboost); FormatLearnboost.prototype.write = function(name, level, args) { var colors = { debug: 'grey', info: 'cyan', warn: 'yellow', error: 'red' }; this.emit('item', (name ? style(name +' ', 'grey') : '') + (level ? style(level, colors[level]) + ' ' : '') + args.join(' ')); }; module.exports = FormatLearnboost; /***/ }), /***/ "./node_modules/minilog/lib/node/formatters/minilog.js": /*!*************************************************************!*\ !*** ./node_modules/minilog/lib/node/formatters/minilog.js ***! \*************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { var Transform = __webpack_require__(/*! ../../common/transform.js */ "./node_modules/minilog/lib/common/transform.js"), style = __webpack_require__(/*! ./util.js */ "./node_modules/minilog/lib/node/formatters/util.js").style, util = __webpack_require__(/*! util */ "util"); function FormatMinilog() {} Transform.mixin(FormatMinilog); FormatMinilog.prototype.write = function(name, level, args) { var colors = { debug: 'blue', info: 'cyan', warn: 'yellow', error: 'red' }; this.emit('item', (name ? style(name +' ', 'grey') : '') + (level ? style(level, colors[level]) + ' ' : '') + args.map(function(item) { return (typeof item == 'string' ? item : util.inspect(item, null, 3, true)); }).join(' ')); }; module.exports = FormatMinilog; /***/ }), /***/ "./node_modules/minilog/lib/node/formatters/npm.js": /*!*********************************************************!*\ !*** ./node_modules/minilog/lib/node/formatters/npm.js ***! \*********************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { var Transform = __webpack_require__(/*! ../../common/transform.js */ "./node_modules/minilog/lib/common/transform.js"); function FormatNpm() {} Transform.mixin(FormatNpm); FormatNpm.prototype.write = function(name, level, args) { var out = { debug: '\033[34;40m' + 'debug' + '\033[39m ', info: '\033[32m' + 'info' + '\033[39m ', warn: '\033[30;41m' + 'WARN' + '\033[0m ', error: '\033[31;40m' + 'ERR!' + '\033[0m ' }; this.emit('item', (name ? '\033[37;40m'+ name +'\033[0m ' : '') + (level && out[level]? out[level] : '') + args.join(' ')); }; module.exports = FormatNpm; /***/ }), /***/ "./node_modules/minilog/lib/node/formatters/time.js": /*!**********************************************************!*\ !*** ./node_modules/minilog/lib/node/formatters/time.js ***! \**********************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { var Transform = __webpack_require__(/*! ../../common/transform.js */ "./node_modules/minilog/lib/common/transform.js"), style = __webpack_require__(/*! ./util.js */ "./node_modules/minilog/lib/node/formatters/util.js").style, util = __webpack_require__(/*! util */ "util"); function FormatTime() {} function timestamp() { var d = new Date(); return ('0' + d.getDate()).slice(-2) + '-' + ('0' + (d.getMonth() + 1)).slice(-2) + '-' + d.getFullYear() + ' ' + ('0' + d.getHours()).slice(-2) + ':' + ('0' + d.getMinutes()).slice(-2) + ':' + ('0' + d.getSeconds()).slice(-2) + '.' + ('00' + d.getMilliseconds()).slice(-3); } Transform.mixin(FormatTime); FormatTime.prototype.write = function(name, level, args) { var colors = { debug: 'blue', info: 'cyan', warn: 'yellow', error: 'red' }; this.emit('item', style(timestamp() +' ', 'grey') + (name ? style(name +' ', 'grey') : '') + (level ? style(level, colors[level]) + ' ' : '') + args.map(function(item) { return (typeof item == 'string' ? item : util.inspect(item, null, 3, true)); }).join(' ')); }; module.exports = FormatTime; /***/ }), /***/ "./node_modules/minilog/lib/node/formatters/util.js": /*!**********************************************************!*\ !*** ./node_modules/minilog/lib/node/formatters/util.js ***! \**********************************************************/ /*! no static exports found */ /***/ (function(module, exports) { var styles = { //styles 'bold' : ['\033[1m', '\033[22m'], 'italic' : ['\033[3m', '\033[23m'], 'underline' : ['\033[4m', '\033[24m'], 'inverse' : ['\033[7m', '\033[27m'], //grayscale 'white' : ['\033[37m', '\033[39m'], 'grey' : ['\033[90m', '\033[39m'], 'black' : ['\033[30m', '\033[39m'], //colors 'blue' : ['\033[34m', '\033[39m'], 'cyan' : ['\033[36m', '\033[39m'], 'green' : ['\033[32m', '\033[39m'], 'magenta' : ['\033[35m', '\033[39m'], 'red' : ['\033[31m', '\033[39m'], 'yellow' : ['\033[33m', '\033[39m'] }; exports.levelMap = { debug: 1, info: 2, warn: 3, error: 4 }; exports.style = function(str, style) { return styles[style][0] + str + styles[style][1]; } /***/ }), /***/ "./node_modules/minilog/lib/node/formatters/withstack.js": /*!***************************************************************!*\ !*** ./node_modules/minilog/lib/node/formatters/withstack.js ***! \***************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { var Transform = __webpack_require__(/*! ../../common/transform.js */ "./node_modules/minilog/lib/common/transform.js"), style = __webpack_require__(/*! ./util.js */ "./node_modules/minilog/lib/node/formatters/util.js").style; function FormatNpm() {} Transform.mixin(FormatNpm); function noop(a){ return a; } var types = { string: noop, number: noop, default: JSON.stringify.bind(JSON) }; function stringify(args) { return args.map(function(arg) { return (types[typeof arg] || types.default)(arg); }); } FormatNpm.prototype.write = function(name, level, args) { var colors = { debug: 'magenta', info: 'cyan', warn: 'yellow', error: 'red' }; function pad(s) { return (s.toString().length == 4? ' '+s : s); } function getStack() { var orig = Error.prepareStackTrace; Error.prepareStackTrace = function (err, stack) { return stack; }; var err = new Error; Error.captureStackTrace(err, arguments.callee); var stack = err.stack; Error.prepareStackTrace = orig; return stack; } var frame = getStack()[5], fileName = FormatNpm.fullPath ? frame.getFileName() : frame.getFileName().replace(/^.*\/(.+)$/, '/$1'); this.emit('item', (name ? name + ' ' : '') + (level ? style(pad(level), colors[level]) + ' ' : '') + style(fileName + ":" + frame.getLineNumber(), 'grey') + ' ' + stringify(args).join(' ')); }; FormatNpm.fullPath = true; module.exports = FormatNpm; /***/ }), /***/ "./node_modules/minilog/lib/node/redis.js": /*!************************************************!*\ !*** ./node_modules/minilog/lib/node/redis.js ***! \************************************************/ /*! no static exports found */ /***/ (function(module, exports) { function RedisBackend(options) { this.client = options.client; this.key = options.key; } RedisBackend.prototype.write = function(str) { this.client.rpush(this.key, str); }; RedisBackend.prototype.end = function() {}; RedisBackend.prototype.clear = function(cb) { this.client.del(this.key, cb); }; module.exports = RedisBackend; /***/ }), /***/ "./node_modules/minilog/lib/node/stringify.js": /*!****************************************************!*\ !*** ./node_modules/minilog/lib/node/stringify.js ***! \****************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { var Transform = __webpack_require__(/*! ../common/transform.js */ "./node_modules/minilog/lib/common/transform.js"); function Stringify() {} Transform.mixin(Stringify); Stringify.prototype.write = function(name, level, args) { var result = []; if(name) result.push(name); if(level) result.push(level); result = result.concat(args); for(var i = 0; i < result.length; i++) { if(result[i] && typeof result[i] == 'object') { // Buffers in Node.js look bad when stringified if(result[i].constructor && result[i].constructor.isBuffer) { result[i] = result[i].toString(); } else { try { result[i] = JSON.stringify(result[i]); } catch(stringifyError) { // happens when an object has a circular structure // do not throw an error, when printing, the toString() method of the object will be used } } } else { result[i] = result[i]; } } this.emit('item', result.join(' ') + '\n'); }; module.exports = Stringify; /***/ }), /***/ "./node_modules/minilog/lib/web/console.js": /*!*************************************************!*\ !*** ./node_modules/minilog/lib/web/console.js ***! \*************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { var Transform = __webpack_require__(/*! ../common/transform.js */ "./node_modules/minilog/lib/common/transform.js"); var newlines = /\n+$/, logger = new Transform(); logger.write = function(name, level, args) { var i = args.length-1; if (typeof console === 'undefined' || !console.log) { return; } if(console.log.apply) { return console.log.apply(console, [name, level].concat(args)); } else if(JSON && JSON.stringify) { // console.log.apply is undefined in IE8 and IE9 // for IE8/9: make console.log at least a bit less awful if(args[i] && typeof args[i] == 'string') { args[i] = args[i].replace(newlines, ''); } try { for(i = 0; i < args.length; i++) { args[i] = JSON.stringify(args[i]); } } catch(e) {} console.log(args.join(' ')); } }; logger.formatters = ['color', 'minilog']; logger.color = __webpack_require__(/*! ./formatters/color.js */ "./node_modules/minilog/lib/web/formatters/color.js"); logger.minilog = __webpack_require__(/*! ./formatters/minilog.js */ "./node_modules/minilog/lib/web/formatters/minilog.js"); module.exports = logger; /***/ }), /***/ "./node_modules/minilog/lib/web/formatters/color.js": /*!**********************************************************!*\ !*** ./node_modules/minilog/lib/web/formatters/color.js ***! \**********************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { var Transform = __webpack_require__(/*! ../../common/transform.js */ "./node_modules/minilog/lib/common/transform.js"), color = __webpack_require__(/*! ./util.js */ "./node_modules/minilog/lib/web/formatters/util.js"); var colors = { debug: ['cyan'], info: ['purple' ], warn: [ 'yellow', true ], error: [ 'red', true ] }, logger = new Transform(); logger.write = function(name, level, args) { var fn = console.log; if(console[level] && console[level].apply) { fn = console[level]; fn.apply(console, [ '%c'+name+' %c'+level, color('gray'), color.apply(color, colors[level])].concat(args)); } }; // NOP, because piping the formatted logs can only cause trouble. logger.pipe = function() { }; module.exports = logger; /***/ }), /***/ "./node_modules/minilog/lib/web/formatters/minilog.js": /*!************************************************************!*\ !*** ./node_modules/minilog/lib/web/formatters/minilog.js ***! \************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { var Transform = __webpack_require__(/*! ../../common/transform.js */ "./node_modules/minilog/lib/common/transform.js"), color = __webpack_require__(/*! ./util.js */ "./node_modules/minilog/lib/web/formatters/util.js"), colors = { debug: ['gray'], info: ['purple' ], warn: [ 'yellow', true ], error: [ 'red', true ] }, logger = new Transform(); logger.write = function(name, level, args) { var fn = console.log; if(level != 'debug' && console[level]) { fn = console[level]; } var subset = [], i = 0; if(level != 'info') { for(; i < args.length; i++) { if(typeof args[i] != 'string') break; } fn.apply(console, [ '%c'+name +' '+ args.slice(0, i).join(' '), color.apply(color, colors[level]) ].concat(args.slice(i))); } else { fn.apply(console, [ '%c'+name, color.apply(color, colors[level]) ].concat(args)); } }; // NOP, because piping the formatted logs can only cause trouble. logger.pipe = function() { }; module.exports = logger; /***/ }), /***/ "./node_modules/minilog/lib/web/formatters/util.js": /*!*********************************************************!*\ !*** ./node_modules/minilog/lib/web/formatters/util.js ***! \*********************************************************/ /*! no static exports found */ /***/ (function(module, exports) { var hex = { black: '#000', red: '#c23621', green: '#25bc26', yellow: '#bbbb00', blue: '#492ee1', magenta: '#d338d3', cyan: '#33bbc8', gray: '#808080', purple: '#708' }; function color(fg, isInverse) { if(isInverse) { return 'color: #fff; background: '+hex[fg]+';'; } else { return 'color: '+hex[fg]+';'; } } module.exports = color; /***/ }), /***/ "./src/dispatch/shared-dispatch.js": /*!*****************************************!*\ !*** ./src/dispatch/shared-dispatch.js ***! \*****************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var log = __webpack_require__(/*! ../util/log */ "./src/util/log.js"); /** * @typedef {object} DispatchCallMessage - a message to the dispatch system representing a service method call * @property {*} responseId - send a response message with this response ID. See {@link DispatchResponseMessage} * @property {string} service - the name of the service to be called * @property {string} method - the name of the method to be called * @property {Array|undefined} args - the arguments to be passed to the method */ /** * @typedef {object} DispatchResponseMessage - a message to the dispatch system representing the results of a call * @property {*} responseId - a copy of the response ID from the call which generated this response * @property {*|undefined} error - if this is truthy, then it contains results from a failed call (such as an exception) * @property {*|undefined} result - if error is not truthy, then this contains the return value of the call (if any) */ /** * @typedef {DispatchCallMessage|DispatchResponseMessage} DispatchMessage * Any message to the dispatch system. */ /** * The SharedDispatch class is responsible for dispatch features shared by * {@link CentralDispatch} and {@link WorkerDispatch}. */ var SharedDispatch = /*#__PURE__*/function () { function SharedDispatch() { _classCallCheck(this, SharedDispatch); /** * List of callback registrations for promises waiting for a response from a call to a service on another * worker. A callback registration is an array of [resolve,reject] Promise functions. * Calls to local services don't enter this list. * @type {Array.<Function[]>} */ this.callbacks = []; /** * The next response ID to be used. * @type {int} */ this.nextResponseId = 0; } /** * Call a particular method on a particular service, regardless of whether that service is provided locally or on * a worker. If the service is provided by a worker, the `args` will be copied using the Structured Clone * algorithm, except for any items which are also in the `transfer` list. Ownership of those items will be * transferred to the worker, and they should not be used after this call. * @example * dispatcher.call('vm', 'setData', 'cat', 42); * // this finds the worker for the 'vm' service, then on that worker calls: * vm.setData('cat', 42); * @param {string} service - the name of the service. * @param {string} method - the name of the method. * @param {*} [args] - the arguments to be copied to the method, if any. * @returns {Promise} - a promise for the return value of the service method. */ _createClass(SharedDispatch, [{ key: "call", value: function call(service, method) { for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { args[_key - 2] = arguments[_key]; } return this.transferCall.apply(this, [service, method, null].concat(args)); } /** * Call a particular method on a particular service, regardless of whether that service is provided locally or on * a worker. If the service is provided by a worker, the `args` will be copied using the Structured Clone * algorithm, except for any items which are also in the `transfer` list. Ownership of those items will be * transferred to the worker, and they should not be used after this call. * @example * dispatcher.transferCall('vm', 'setData', [myArrayBuffer], 'cat', myArrayBuffer); * // this finds the worker for the 'vm' service, transfers `myArrayBuffer` to it, then on that worker calls: * vm.setData('cat', myArrayBuffer); * @param {string} service - the name of the service. * @param {string} method - the name of the method. * @param {Array} [transfer] - objects to be transferred instead of copied. Must be present in `args` to be useful. * @param {*} [args] - the arguments to be copied to the method, if any. * @returns {Promise} - a promise for the return value of the service method. */ }, { key: "transferCall", value: function transferCall(service, method, transfer) { try { var _this$_getServiceProv = this._getServiceProvider(service), provider = _this$_getServiceProv.provider, isRemote = _this$_getServiceProv.isRemote; if (provider) { for (var _len2 = arguments.length, args = new Array(_len2 > 3 ? _len2 - 3 : 0), _key2 = 3; _key2 < _len2; _key2++) { args[_key2 - 3] = arguments[_key2]; } if (isRemote) { return this._remoteTransferCall.apply(this, [provider, service, method, transfer].concat(args)); } var result = provider[method].apply(provider, args); return Promise.resolve(result); } return Promise.reject(new Error("Service not found: ".concat(service))); } catch (e) { return Promise.reject(e); } } /** * Check if a particular service lives on another worker. * @param {string} service - the service to check. * @returns {boolean} - true if the service is remote (calls must cross a Worker boundary), false otherwise. * @private */ }, { key: "_isRemoteService", value: function _isRemoteService(service) { return this._getServiceProvider(service).isRemote; } /** * Like {@link call}, but force the call to be posted through a particular communication channel. * @param {object} provider - send the call through this object's `postMessage` function. * @param {string} service - the name of the service. * @param {string} method - the name of the method. * @param {*} [args] - the arguments to be copied to the method, if any. * @returns {Promise} - a promise for the return value of the service method. */ }, { key: "_remoteCall", value: function _remoteCall(provider, service, method) { for (var _len3 = arguments.length, args = new Array(_len3 > 3 ? _len3 - 3 : 0), _key3 = 3; _key3 < _len3; _key3++) { args[_key3 - 3] = arguments[_key3]; } return this._remoteTransferCall.apply(this, [provider, service, method, null].concat(args)); } /** * Like {@link transferCall}, but force the call to be posted through a particular communication channel. * @param {object} provider - send the call through this object's `postMessage` function. * @param {string} service - the name of the service. * @param {string} method - the name of the method. * @param {Array} [transfer] - objects to be transferred instead of copied. Must be present in `args` to be useful. * @param {*} [args] - the arguments to be copied to the method, if any. * @returns {Promise} - a promise for the return value of the service method. */ }, { key: "_remoteTransferCall", value: function _remoteTransferCall(provider, service, method, transfer) { var _this = this; for (var _len4 = arguments.length, args = new Array(_len4 > 4 ? _len4 - 4 : 0), _key4 = 4; _key4 < _len4; _key4++) { args[_key4 - 4] = arguments[_key4]; } return new Promise(function (resolve, reject) { var responseId = _this._storeCallbacks(resolve, reject); /** @TODO: remove this hack! this is just here so we don't try to send `util` to a worker */ if (args.length > 0 && typeof args[args.length - 1].yield === 'function') { args.pop(); } if (transfer) { provider.postMessage({ service: service, method: method, responseId: responseId, args: args }, transfer); } else { provider.postMessage({ service: service, method: method, responseId: responseId, args: args }); } }); } /** * Store callback functions pending a response message. * @param {Function} resolve - function to call if the service method returns. * @param {Function} reject - function to call if the service method throws. * @returns {*} - a unique response ID for this set of callbacks. See {@link _deliverResponse}. * @protected */ }, { key: "_storeCallbacks", value: function _storeCallbacks(resolve, reject) { var responseId = this.nextResponseId++; this.callbacks[responseId] = [resolve, reject]; return responseId; } /** * Deliver call response from a worker. This should only be called as the result of a message from a worker. * @param {int} responseId - the response ID of the callback set to call. * @param {DispatchResponseMessage} message - the message containing the response value(s). * @protected */ }, { key: "_deliverResponse", value: function _deliverResponse(responseId, message) { try { var _this$callbacks$respo = _slicedToArray(this.callbacks[responseId], 2), resolve = _this$callbacks$respo[0], reject = _this$callbacks$respo[1]; delete this.callbacks[responseId]; if (message.error) { reject(message.error); } else { resolve(message.result); } } catch (e) { log.error("Dispatch callback failed: ".concat(JSON.stringify(e))); } } /** * Handle a message event received from a connected worker. * @param {Worker} worker - the worker which sent the message, or the global object if running in a worker. * @param {MessageEvent} event - the message event to be handled. * @protected */ }, { key: "_onMessage", value: function _onMessage(worker, event) { /** @type {DispatchMessage} */ var message = event.data; message.args = message.args || []; var promise; if (message.service) { if (message.service === 'dispatch') { promise = this._onDispatchMessage(worker, message); } else { promise = this.call.apply(this, [message.service, message.method].concat(_toConsumableArray(message.args))); } } else if (typeof message.responseId === 'undefined') { log.error("Dispatch caught malformed message from a worker: ".concat(JSON.stringify(event))); } else { this._deliverResponse(message.responseId, message); } if (promise) { if (typeof message.responseId === 'undefined') { log.error("Dispatch messa