@loaders.gl/worker-utils
Advanced tools
Comparing version 3.0.0-alpha.21 to 3.0.0-beta.1
@@ -132,3 +132,3 @@ "use strict"; | ||
var VERSION = typeof "3.0.0-alpha.21" !== 'undefined' ? "3.0.0-alpha.21" : 'latest'; | ||
var VERSION = typeof "3.0.0-beta.1" !== 'undefined' ? "3.0.0-beta.1" : 'latest'; | ||
var NullWorker = { | ||
@@ -135,0 +135,0 @@ id: 'null', |
@@ -14,5 +14,14 @@ "use strict"; | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _Symbol$asyncIterator; | ||
_Symbol$asyncIterator = Symbol.asyncIterator; | ||
var AsyncQueue = function () { | ||
function AsyncQueue() { | ||
(0, _classCallCheck2.default)(this, AsyncQueue); | ||
(0, _defineProperty2.default)(this, "_values", void 0); | ||
(0, _defineProperty2.default)(this, "_settlers", void 0); | ||
(0, _defineProperty2.default)(this, "_closed", void 0); | ||
this._values = []; | ||
@@ -24,3 +33,3 @@ this._settlers = []; | ||
(0, _createClass2.default)(AsyncQueue, [{ | ||
key: Symbol.asyncIterator, | ||
key: _Symbol$asyncIterator, | ||
value: function value() { | ||
@@ -96,3 +105,4 @@ return this; | ||
return Promise.resolve({ | ||
done: true | ||
done: true, | ||
value: undefined | ||
}); | ||
@@ -99,0 +109,0 @@ } |
@@ -18,7 +18,7 @@ "use strict"; | ||
}; | ||
var self_ = globals.self || globals.window || globals.global; | ||
var self_ = globals.self || globals.window || globals.global || {}; | ||
exports.self = self_; | ||
var window_ = globals.window || globals.self || globals.global; | ||
var window_ = globals.window || globals.self || globals.global || {}; | ||
exports.window = window_; | ||
var global_ = globals.global || globals.self || globals.window; | ||
var global_ = globals.global || globals.self || globals.window || {}; | ||
exports.global = global_; | ||
@@ -33,5 +33,5 @@ var document_ = globals.document || {}; | ||
exports.isMobile = isMobile; | ||
var matches = typeof process !== 'undefined' && process.version && process.version.match(/v([0-9]*)/); | ||
var matches = typeof process !== 'undefined' && process.version && /v([0-9]*)/.exec(process.version); | ||
var nodeVersion = matches && parseFloat(matches[1]) || 0; | ||
exports.nodeVersion = nodeVersion; | ||
//# sourceMappingURL=globals.js.map |
@@ -28,3 +28,3 @@ "use strict"; | ||
var LATEST = 'beta'; | ||
var VERSION = typeof "3.0.0-alpha.21" !== 'undefined' ? "3.0.0-alpha.21" : LATEST; | ||
var VERSION = typeof "3.0.0-beta.1" !== 'undefined' ? "3.0.0-beta.1" : LATEST; | ||
var loadLibraryPromises = {}; | ||
@@ -31,0 +31,0 @@ |
@@ -14,4 +14,2 @@ "use strict"; | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); | ||
@@ -23,5 +21,5 @@ | ||
var _child_process = _interopRequireDefault(require("child_process")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _assert = require("../env-utils/assert"); | ||
var _child_process = require("child_process"); | ||
@@ -34,14 +32,10 @@ var _processUtils = require("./process-utils"); | ||
var DEFAULT_PROCESS_OPTIONS = { | ||
command: null, | ||
var DEFAULT_PROPS = { | ||
command: '', | ||
arguments: [], | ||
portArg: null, | ||
port: 'auto', | ||
basePort: 5000, | ||
port: 5000, | ||
autoPort: true, | ||
wait: 2000, | ||
nodeSpawnOptions: { | ||
maxBuffer: 5000 * 1024 | ||
}, | ||
onSuccess: function onSuccess(processProxy) { | ||
console.log("Started ".concat(processProxy.options.command)); | ||
console.log("Started ".concat(processProxy.props.command)); | ||
} | ||
@@ -57,7 +51,8 @@ }; | ||
(0, _classCallCheck2.default)(this, ChildProcessProxy); | ||
(0, _defineProperty2.default)(this, "id", void 0); | ||
(0, _defineProperty2.default)(this, "props", _objectSpread({}, DEFAULT_PROPS)); | ||
(0, _defineProperty2.default)(this, "childProcess", null); | ||
(0, _defineProperty2.default)(this, "port", 0); | ||
(0, _defineProperty2.default)(this, "successTimer", void 0); | ||
this.id = id; | ||
this.childProcess = null; | ||
this.port = null; | ||
this.successTimer = null; | ||
this.options = {}; | ||
} | ||
@@ -68,8 +63,6 @@ | ||
value: function () { | ||
var _start = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee() { | ||
var _start = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(props) { | ||
var _this = this; | ||
var options, | ||
args, | ||
_args = arguments; | ||
var args; | ||
return _regenerator.default.wrap(function _callee$(_context) { | ||
@@ -79,35 +72,33 @@ while (1) { | ||
case 0: | ||
options = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}; | ||
options = _objectSpread(_objectSpread({}, DEFAULT_PROCESS_OPTIONS), options); | ||
(0, _assert.assert)(options.command && typeof options.command === 'string'); | ||
this.options = options; | ||
args = (0, _toConsumableArray2.default)(options.arguments); | ||
this.port = options.port; | ||
props = _objectSpread(_objectSpread({}, DEFAULT_PROPS), props); | ||
this.props = props; | ||
args = (0, _toConsumableArray2.default)(props.arguments); | ||
this.port = Number(props.port); | ||
if (!options.portArg) { | ||
_context.next = 12; | ||
if (!props.portArg) { | ||
_context.next = 10; | ||
break; | ||
} | ||
if (!(this.port === 'auto')) { | ||
_context.next = 11; | ||
if (!props.autoPort) { | ||
_context.next = 9; | ||
break; | ||
} | ||
_context.next = 10; | ||
return (0, _processUtils.getAvailablePort)(options.basePort); | ||
_context.next = 8; | ||
return (0, _processUtils.getAvailablePort)(props.port); | ||
case 10: | ||
case 8: | ||
this.port = _context.sent; | ||
case 11: | ||
args.push(options.portArg, this.port); | ||
case 9: | ||
args.push(props.portArg, String(this.port)); | ||
case 12: | ||
_context.next = 14; | ||
case 10: | ||
_context.next = 12; | ||
return new Promise(function (resolve, reject) { | ||
try { | ||
_this._setTimeout(function () { | ||
if (options.onSuccess) { | ||
options.onSuccess(_this); | ||
if (props.onSuccess) { | ||
props.onSuccess(_this); | ||
} | ||
@@ -118,10 +109,9 @@ | ||
console.log("Spawning ".concat(options.command, " ").concat(options.arguments.join(' '))); | ||
_this.childProcess = _child_process.default.spawn(options.command, args, options.spawn); | ||
_this.childProcess.stdout.on('data', function (data) { | ||
console.log("Spawning ".concat(props.command, " ").concat(props.arguments.join(' '))); | ||
var childProcess = (0, _child_process.spawn)(props.command, args, props.spawn); | ||
_this.childProcess = childProcess; | ||
childProcess.stdout.on('data', function (data) { | ||
console.log(data.toString()); | ||
}); | ||
_this.childProcess.stderr.on('data', function (data) { | ||
childProcess.stderr.on('data', function (data) { | ||
console.log("Child process wrote to stderr: \"".concat(data, "\".")); | ||
@@ -133,4 +123,3 @@ | ||
}); | ||
_this.childProcess.on('error', function (error) { | ||
childProcess.on('error', function (error) { | ||
console.log("Child process errored with ".concat(error)); | ||
@@ -142,4 +131,3 @@ | ||
}); | ||
_this.childProcess.on('close', function (code) { | ||
childProcess.on('close', function (code) { | ||
console.log("Child process exited with ".concat(code)); | ||
@@ -157,6 +145,6 @@ _this.childProcess = null; | ||
case 14: | ||
case 12: | ||
return _context.abrupt("return", _context.sent); | ||
case 15: | ||
case 13: | ||
case "end": | ||
@@ -169,3 +157,3 @@ return _context.stop(); | ||
function start() { | ||
function start(_x) { | ||
return _start.apply(this, arguments); | ||
@@ -246,4 +234,4 @@ } | ||
value: function _setTimeout(callback) { | ||
if (this.options.wait > 0) { | ||
this.successTimer = setTimeout(callback, this.options.wait); | ||
if (Number(this.props.wait) > 0) { | ||
this.successTimer = setTimeout(callback, this.props.wait); | ||
} | ||
@@ -250,0 +238,0 @@ } |
@@ -14,4 +14,4 @@ "use strict"; | ||
var defaultPort = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 3000; | ||
return new Promise(function (resolve, reject) { | ||
_child_process.default.exec('lsof -i -P -n | grep LISTEN', function (error, stdout, stderr) { | ||
return new Promise(function (resolve) { | ||
_child_process.default.exec('lsof -i -P -n | grep LISTEN', function (error, stdout) { | ||
if (error) { | ||
@@ -25,3 +25,3 @@ resolve(defaultPort); | ||
stdout.split('\n').forEach(function (line) { | ||
var match = line.match(regex); | ||
var match = regex.exec(line); | ||
@@ -28,0 +28,0 @@ if (match) { |
@@ -51,3 +51,3 @@ "use strict"; | ||
_context.next = 8; | ||
return process(payload.input, payload.options || {}, payload); | ||
return process(payload.input, payload.options || {}); | ||
@@ -54,0 +54,0 @@ case 8: |
@@ -38,3 +38,3 @@ "use strict"; | ||
options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {}; | ||
name = (0, _workerObjectUtils.getWorkerObjectName)(worker, options); | ||
name = (0, _workerObjectUtils.getWorkerObjectName)(worker); | ||
url = (0, _workerObjectUtils.getWorkerObjectURL)(worker, options); | ||
@@ -41,0 +41,0 @@ workerFarm = _workerFarm.default.getWorkerFarm(options); |
@@ -18,3 +18,3 @@ "use strict"; | ||
var NPM_TAG = 'beta'; | ||
var VERSION = typeof "3.0.0-alpha.21" !== 'undefined' ? "3.0.0-alpha.21" : NPM_TAG; | ||
var VERSION = typeof "3.0.0-beta.1" !== 'undefined' ? "3.0.0-beta.1" : NPM_TAG; | ||
@@ -57,7 +57,6 @@ function getWorkerObjectURL(worker, options) { | ||
if (!coreVersion || !workerVersion) { | ||
return; | ||
return false; | ||
} | ||
coreVersion = parseVersion(coreVersion); | ||
workerVersion = parseVersion(workerVersion); | ||
return true; | ||
} | ||
@@ -64,0 +63,0 @@ |
@@ -12,17 +12,15 @@ "use strict"; | ||
function buildWorkerURL(_ref) { | ||
var source = _ref.source, | ||
url = _ref.url; | ||
(0, _assert.assert)(source && !url || !source && url); | ||
var workerURL = workerURLCache.get(source || url); | ||
function buildWorkerURL(props) { | ||
(0, _assert.assert)(props.source && !props.url || !props.source && props.url); | ||
var workerURL = workerURLCache.get(props.source || props.url); | ||
if (!workerURL) { | ||
if (url) { | ||
workerURL = getWorkerURLFromURL(url); | ||
workerURLCache.set(url, workerURL); | ||
if (props.url) { | ||
workerURL = getWorkerURLFromURL(props.url); | ||
workerURLCache.set(props.url, workerURL); | ||
} | ||
if (source) { | ||
workerURL = getWorkerURLFromSource(source); | ||
workerURLCache.set(source, workerURL); | ||
if (props.source) { | ||
workerURL = getWorkerURLFromSource(props.source); | ||
workerURLCache.set(props.source, workerURL); | ||
} | ||
@@ -45,3 +43,2 @@ } | ||
function getWorkerURLFromSource(workerSource) { | ||
(0, _assert.assert)(typeof workerSource === 'string', 'worker source'); | ||
var blob = new Blob([workerSource], { | ||
@@ -48,0 +45,0 @@ type: 'application/javascript' |
@@ -10,4 +10,2 @@ "use strict"; | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
@@ -17,3 +15,3 @@ | ||
var _globals = require("../env-utils/globals"); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
@@ -24,2 +22,8 @@ var _workerPool = _interopRequireDefault(require("./worker-pool")); | ||
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } | ||
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 ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } | ||
@@ -35,3 +39,2 @@ | ||
}; | ||
var _workerFarm = null; | ||
@@ -41,2 +44,4 @@ var WorkerFarm = function () { | ||
(0, _classCallCheck2.default)(this, WorkerFarm); | ||
(0, _defineProperty2.default)(this, "props", void 0); | ||
(0, _defineProperty2.default)(this, "workerPools", new Map()); | ||
this.props = _objectSpread({}, DEFAULT_PROPS); | ||
@@ -50,5 +55,15 @@ this.setProps(props); | ||
value: function destroy() { | ||
this.workerPools.forEach(function (workerPool) { | ||
return workerPool.destroy(); | ||
}); | ||
var _iterator = _createForOfIteratorHelper(this.workerPools.values()), | ||
_step; | ||
try { | ||
for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
var workerPool = _step.value; | ||
workerPool.destroy(); | ||
} | ||
} catch (err) { | ||
_iterator.e(err); | ||
} finally { | ||
_iterator.f(); | ||
} | ||
} | ||
@@ -59,9 +74,23 @@ }, { | ||
this.props = _objectSpread(_objectSpread({}, this.props), props); | ||
var _iterator2 = _createForOfIteratorHelper(this.workerPools.values()), | ||
_step2; | ||
try { | ||
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { | ||
var workerPool = _step2.value; | ||
workerPool.setProps(this._getWorkerPoolProps()); | ||
} | ||
} catch (err) { | ||
_iterator2.e(err); | ||
} finally { | ||
_iterator2.f(); | ||
} | ||
} | ||
}, { | ||
key: "getWorkerPool", | ||
value: function getWorkerPool(_ref) { | ||
var name = _ref.name, | ||
source = _ref.source, | ||
url = _ref.url; | ||
value: function getWorkerPool(options) { | ||
var name = options.name, | ||
source = options.source, | ||
url = options.url; | ||
var workerPool = this.workerPools.get(name); | ||
@@ -73,7 +102,5 @@ | ||
source: source, | ||
url: url, | ||
maxConcurrency: _globals.isMobile ? this.props.maxMobileConcurrency : this.props.maxConcurrency, | ||
onDebug: this.props.onDebug, | ||
reuseWorkers: this.props.reuseWorkers | ||
url: url | ||
}); | ||
workerPool.setProps(this._getWorkerPoolProps()); | ||
this.workerPools.set(name, workerPool); | ||
@@ -84,2 +111,12 @@ } | ||
} | ||
}, { | ||
key: "_getWorkerPoolProps", | ||
value: function _getWorkerPoolProps() { | ||
return { | ||
maxConcurrency: this.props.maxConcurrency, | ||
maxMobileConcurrency: this.props.maxMobileConcurrency, | ||
reuseWorkers: this.props.reuseWorkers, | ||
onDebug: this.props.onDebug | ||
}; | ||
} | ||
}], [{ | ||
@@ -94,7 +131,7 @@ key: "isSupported", | ||
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
_workerFarm = _workerFarm || new WorkerFarm({}); | ||
WorkerFarm._workerFarm = WorkerFarm._workerFarm || new WorkerFarm({}); | ||
_workerFarm.setProps(props); | ||
WorkerFarm._workerFarm.setProps(props); | ||
return _workerFarm; | ||
return WorkerFarm._workerFarm; | ||
} | ||
@@ -106,2 +143,3 @@ }]); | ||
exports.default = WorkerFarm; | ||
(0, _defineProperty2.default)(WorkerFarm, "_workerFarm", void 0); | ||
//# sourceMappingURL=worker-farm.js.map |
@@ -14,2 +14,4 @@ "use strict"; | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _assert = require("../env-utils/assert"); | ||
@@ -22,5 +24,16 @@ | ||
(0, _classCallCheck2.default)(this, WorkerJob); | ||
(0, _defineProperty2.default)(this, "name", void 0); | ||
(0, _defineProperty2.default)(this, "workerThread", void 0); | ||
(0, _defineProperty2.default)(this, "isRunning", void 0); | ||
(0, _defineProperty2.default)(this, "result", void 0); | ||
(0, _defineProperty2.default)(this, "_resolve", void 0); | ||
(0, _defineProperty2.default)(this, "_reject", void 0); | ||
this.name = jobName; | ||
this.workerThread = workerThread; | ||
this.isRunning = true; | ||
this._resolve = function () {}; | ||
this._reject = function () {}; | ||
this.result = new Promise(function (resolve, reject) { | ||
@@ -27,0 +40,0 @@ _this._resolve = resolve; |
@@ -18,4 +18,6 @@ "use strict"; | ||
var _assert = require("../env-utils/assert"); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _globals = require("../env-utils/globals"); | ||
var _workerThread = _interopRequireDefault(require("./worker-thread")); | ||
@@ -25,28 +27,24 @@ | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
var WorkerPool = function () { | ||
function WorkerPool(_ref) { | ||
var source = _ref.source, | ||
url = _ref.url, | ||
_ref$name = _ref.name, | ||
name = _ref$name === void 0 ? 'unnamed' : _ref$name, | ||
_ref$maxConcurrency = _ref.maxConcurrency, | ||
maxConcurrency = _ref$maxConcurrency === void 0 ? 1 : _ref$maxConcurrency, | ||
onMessage = _ref.onMessage, | ||
_ref$onDebug = _ref.onDebug, | ||
onDebug = _ref$onDebug === void 0 ? function () {} : _ref$onDebug, | ||
_ref$reuseWorkers = _ref.reuseWorkers, | ||
reuseWorkers = _ref$reuseWorkers === void 0 ? true : _ref$reuseWorkers; | ||
function WorkerPool(props) { | ||
(0, _classCallCheck2.default)(this, WorkerPool); | ||
(0, _assert.assert)(source || url); | ||
this.source = source; | ||
this.url = url; | ||
this.name = name; | ||
this.maxConcurrency = maxConcurrency; | ||
this.onMessage = onMessage; | ||
this.onDebug = onDebug; | ||
this.reuseWorkers = reuseWorkers; | ||
this.jobQueue = []; | ||
this.idleQueue = []; | ||
this.count = 0; | ||
this.isDestroyed = false; | ||
(0, _defineProperty2.default)(this, "name", 'unnamed'); | ||
(0, _defineProperty2.default)(this, "source", void 0); | ||
(0, _defineProperty2.default)(this, "url", void 0); | ||
(0, _defineProperty2.default)(this, "maxConcurrency", 1); | ||
(0, _defineProperty2.default)(this, "maxMobileConcurrency", 1); | ||
(0, _defineProperty2.default)(this, "onDebug", function () {}); | ||
(0, _defineProperty2.default)(this, "reuseWorkers", true); | ||
(0, _defineProperty2.default)(this, "props", {}); | ||
(0, _defineProperty2.default)(this, "jobQueue", []); | ||
(0, _defineProperty2.default)(this, "idleQueue", []); | ||
(0, _defineProperty2.default)(this, "count", 0); | ||
(0, _defineProperty2.default)(this, "isDestroyed", false); | ||
this.source = props.source; | ||
this.url = props.url; | ||
this.setProps(props); | ||
} | ||
@@ -63,2 +61,27 @@ | ||
}, { | ||
key: "setProps", | ||
value: function setProps(props) { | ||
this.props = _objectSpread(_objectSpread({}, this.props), props); | ||
if (props.name !== undefined) { | ||
this.name = props.name; | ||
} | ||
if (props.maxConcurrency !== undefined) { | ||
this.maxConcurrency = props.maxConcurrency; | ||
} | ||
if (props.maxMobileConcurrency !== undefined) { | ||
this.maxMobileConcurrency = props.maxMobileConcurrency; | ||
} | ||
if (props.reuseWorkers !== undefined) { | ||
this.reuseWorkers = props.reuseWorkers; | ||
} | ||
if (props.onDebug !== undefined) { | ||
this.onDebug = props.onDebug; | ||
} | ||
} | ||
}, { | ||
key: "startJob", | ||
@@ -90,2 +113,4 @@ value: function () { | ||
}); | ||
return _this; | ||
}); | ||
@@ -95,5 +120,9 @@ | ||
return _context.abrupt("return", startPromise); | ||
_context.next = 6; | ||
return startPromise; | ||
case 5: | ||
case 6: | ||
return _context.abrupt("return", _context.sent); | ||
case 7: | ||
case "end": | ||
@@ -116,3 +145,4 @@ return _context.stop(); | ||
var _startQueuedJob2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2() { | ||
var workerThread, queuedJob, job; | ||
var workerThread, queuedJob, _job; | ||
return _regenerator.default.wrap(function _callee2$(_context2) { | ||
@@ -149,20 +179,20 @@ while (1) { | ||
message: 'Starting job', | ||
jobName: queuedJob.name, | ||
name: queuedJob.name, | ||
workerThread: workerThread, | ||
backlog: this.jobQueue.length | ||
}); | ||
job = new _workerJob.default(queuedJob.name, workerThread); | ||
_job = new _workerJob.default(queuedJob.name, workerThread); | ||
workerThread.onMessage = function (data) { | ||
return queuedJob.onMessage(job, data.type, data.payload); | ||
return queuedJob.onMessage(_job, data.type, data.payload); | ||
}; | ||
workerThread.onError = function (error) { | ||
return queuedJob.onError(job, error); | ||
return queuedJob.onError(_job, error); | ||
}; | ||
queuedJob.onStart(job); | ||
queuedJob.onStart(_job); | ||
_context2.prev = 12; | ||
_context2.next = 15; | ||
return job.result; | ||
return _job.result; | ||
@@ -191,15 +221,14 @@ case 15: | ||
value: function returnWorkerToQueue(worker) { | ||
if (this.isDestroyed) { | ||
worker.destroy(); | ||
return; | ||
} | ||
var shouldDestroyWorker = this.isDestroyed || !this.reuseWorkers || this.count > this._getMaxConcurrency(); | ||
if (this.reuseWorkers) { | ||
this.idleQueue.push(worker); | ||
} else { | ||
if (shouldDestroyWorker) { | ||
worker.destroy(); | ||
this.count--; | ||
} else { | ||
this.idleQueue.push(worker); | ||
} | ||
this._startQueuedJob(); | ||
if (!this.isDestroyed) { | ||
this._startQueuedJob(); | ||
} | ||
} | ||
@@ -213,3 +242,3 @@ }, { | ||
if (this.count < this.maxConcurrency) { | ||
if (this.count < this._getMaxConcurrency()) { | ||
this.count++; | ||
@@ -226,2 +255,7 @@ var name = "".concat(this.name.toLowerCase(), " (#").concat(this.count, " of ").concat(this.maxConcurrency, ")"); | ||
} | ||
}, { | ||
key: "_getMaxConcurrency", | ||
value: function _getMaxConcurrency() { | ||
return _globals.isMobile ? this.maxMobileConcurrency : this.maxConcurrency; | ||
} | ||
}]); | ||
@@ -228,0 +262,0 @@ return WorkerPool; |
@@ -14,2 +14,4 @@ "use strict"; | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _assert = require("../env-utils/assert"); | ||
@@ -21,3 +23,3 @@ | ||
var NOOP = function NOOP(_) {}; | ||
var NOOP = function NOOP() {}; | ||
@@ -27,2 +29,10 @@ var WorkerThread = function () { | ||
(0, _classCallCheck2.default)(this, WorkerThread); | ||
(0, _defineProperty2.default)(this, "name", void 0); | ||
(0, _defineProperty2.default)(this, "source", void 0); | ||
(0, _defineProperty2.default)(this, "url", void 0); | ||
(0, _defineProperty2.default)(this, "terminated", false); | ||
(0, _defineProperty2.default)(this, "worker", void 0); | ||
(0, _defineProperty2.default)(this, "onMessage", void 0); | ||
(0, _defineProperty2.default)(this, "onError", void 0); | ||
(0, _defineProperty2.default)(this, "_loadableURL", ''); | ||
var name = props.name, | ||
@@ -41,3 +51,2 @@ source = props.source, | ||
this.terminated = false; | ||
this.worker = this._createBrowserWorker(); | ||
@@ -68,3 +77,3 @@ } | ||
value: function _getErrorFromErrorEvent(event) { | ||
var message = "Failed to load "; | ||
var message = 'Failed to load '; | ||
message += "worker ".concat(this.name, ". "); | ||
@@ -97,3 +106,3 @@ | ||
if (!event.data) { | ||
_this.onError('No data received'); | ||
_this.onError(new Error('No data received')); | ||
} else { | ||
@@ -100,0 +109,0 @@ _this.onMessage(event.data); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
//# sourceMappingURL=protocol.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
//# sourceMappingURL=types.js.map |
@@ -1,6 +0,31 @@ | ||
import {createWorker} from '../lib/worker-api/create-worker'; | ||
"use strict"; | ||
createWorker(async (data, options) => { | ||
// @ts-ignore | ||
return data; | ||
}); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); | ||
var _createWorker = require("../lib/worker-api/create-worker"); | ||
(0, _createWorker.createWorker)(function () { | ||
var _ref = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(data) { | ||
return _regenerator.default.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
return _context.abrupt("return", data); | ||
case 1: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee); | ||
})); | ||
return function (_x) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}()); | ||
//# sourceMappingURL=null-worker.js.map |
@@ -14,3 +14,3 @@ export { assert } from './lib/env-utils/assert'; | ||
export { default as ChildProcessProxy } from './lib/process-utils/child-process-proxy'; | ||
var VERSION = typeof "3.0.0-alpha.21" !== 'undefined' ? "3.0.0-alpha.21" : 'latest'; | ||
var VERSION = typeof "3.0.0-beta.1" !== 'undefined' ? "3.0.0-beta.1" : 'latest'; | ||
export var NullWorker = { | ||
@@ -17,0 +17,0 @@ id: 'null', |
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
import _createClass from "@babel/runtime/helpers/esm/createClass"; | ||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
var _Symbol$asyncIterator; | ||
_Symbol$asyncIterator = Symbol.asyncIterator; | ||
var AsyncQueue = function () { | ||
@@ -8,2 +13,8 @@ function AsyncQueue() { | ||
_defineProperty(this, "_values", void 0); | ||
_defineProperty(this, "_settlers", void 0); | ||
_defineProperty(this, "_closed", void 0); | ||
this._values = []; | ||
@@ -15,3 +26,3 @@ this._settlers = []; | ||
_createClass(AsyncQueue, [{ | ||
key: Symbol.asyncIterator, | ||
key: _Symbol$asyncIterator, | ||
value: function value() { | ||
@@ -87,3 +98,4 @@ return this; | ||
return Promise.resolve({ | ||
done: true | ||
done: true, | ||
value: undefined | ||
}); | ||
@@ -90,0 +102,0 @@ } |
@@ -8,5 +8,5 @@ import _typeof from "@babel/runtime/helpers/esm/typeof"; | ||
}; | ||
var self_ = globals.self || globals.window || globals.global; | ||
var window_ = globals.window || globals.self || globals.global; | ||
var global_ = globals.global || globals.self || globals.window; | ||
var self_ = globals.self || globals.window || globals.global || {}; | ||
var window_ = globals.window || globals.self || globals.global || {}; | ||
var global_ = globals.global || globals.self || globals.window || {}; | ||
var document_ = globals.document || {}; | ||
@@ -17,4 +17,4 @@ export { self_ as self, window_ as window, global_ as global, document_ as document }; | ||
export var isMobile = typeof window !== 'undefined' && typeof window.orientation !== 'undefined'; | ||
var matches = typeof process !== 'undefined' && process.version && process.version.match(/v([0-9]*)/); | ||
var matches = typeof process !== 'undefined' && process.version && /v([0-9]*)/.exec(process.version); | ||
export var nodeVersion = matches && parseFloat(matches[1]) || 0; | ||
//# sourceMappingURL=globals.js.map |
@@ -7,3 +7,3 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator"; | ||
var LATEST = 'beta'; | ||
var VERSION = typeof "3.0.0-alpha.21" !== 'undefined' ? "3.0.0-alpha.21" : LATEST; | ||
var VERSION = typeof "3.0.0-beta.1" !== 'undefined' ? "3.0.0-beta.1" : LATEST; | ||
var loadLibraryPromises = {}; | ||
@@ -10,0 +10,0 @@ export function loadLibrary(_x) { |
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray"; | ||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator"; | ||
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
import _createClass from "@babel/runtime/helpers/esm/createClass"; | ||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
@@ -12,17 +12,12 @@ | ||
import ChildProcess from 'child_process'; | ||
import { assert } from '../env-utils/assert'; | ||
import { spawn } from 'child_process'; | ||
import { getAvailablePort } from './process-utils'; | ||
var DEFAULT_PROCESS_OPTIONS = { | ||
command: null, | ||
var DEFAULT_PROPS = { | ||
command: '', | ||
arguments: [], | ||
portArg: null, | ||
port: 'auto', | ||
basePort: 5000, | ||
port: 5000, | ||
autoPort: true, | ||
wait: 2000, | ||
nodeSpawnOptions: { | ||
maxBuffer: 5000 * 1024 | ||
}, | ||
onSuccess: function onSuccess(processProxy) { | ||
console.log("Started ".concat(processProxy.options.command)); | ||
console.log("Started ".concat(processProxy.props.command)); | ||
} | ||
@@ -39,7 +34,13 @@ }; | ||
_defineProperty(this, "id", void 0); | ||
_defineProperty(this, "props", _objectSpread({}, DEFAULT_PROPS)); | ||
_defineProperty(this, "childProcess", null); | ||
_defineProperty(this, "port", 0); | ||
_defineProperty(this, "successTimer", void 0); | ||
this.id = id; | ||
this.childProcess = null; | ||
this.port = null; | ||
this.successTimer = null; | ||
this.options = {}; | ||
} | ||
@@ -50,8 +51,6 @@ | ||
value: function () { | ||
var _start = _asyncToGenerator(_regeneratorRuntime.mark(function _callee() { | ||
var _start = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(props) { | ||
var _this = this; | ||
var options, | ||
args, | ||
_args = arguments; | ||
var args; | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -61,35 +60,33 @@ while (1) { | ||
case 0: | ||
options = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}; | ||
options = _objectSpread(_objectSpread({}, DEFAULT_PROCESS_OPTIONS), options); | ||
assert(options.command && typeof options.command === 'string'); | ||
this.options = options; | ||
args = _toConsumableArray(options.arguments); | ||
this.port = options.port; | ||
props = _objectSpread(_objectSpread({}, DEFAULT_PROPS), props); | ||
this.props = props; | ||
args = _toConsumableArray(props.arguments); | ||
this.port = Number(props.port); | ||
if (!options.portArg) { | ||
_context.next = 12; | ||
if (!props.portArg) { | ||
_context.next = 10; | ||
break; | ||
} | ||
if (!(this.port === 'auto')) { | ||
_context.next = 11; | ||
if (!props.autoPort) { | ||
_context.next = 9; | ||
break; | ||
} | ||
_context.next = 10; | ||
return getAvailablePort(options.basePort); | ||
_context.next = 8; | ||
return getAvailablePort(props.port); | ||
case 10: | ||
case 8: | ||
this.port = _context.sent; | ||
case 11: | ||
args.push(options.portArg, this.port); | ||
case 9: | ||
args.push(props.portArg, String(this.port)); | ||
case 12: | ||
_context.next = 14; | ||
case 10: | ||
_context.next = 12; | ||
return new Promise(function (resolve, reject) { | ||
try { | ||
_this._setTimeout(function () { | ||
if (options.onSuccess) { | ||
options.onSuccess(_this); | ||
if (props.onSuccess) { | ||
props.onSuccess(_this); | ||
} | ||
@@ -100,10 +97,9 @@ | ||
console.log("Spawning ".concat(options.command, " ").concat(options.arguments.join(' '))); | ||
_this.childProcess = ChildProcess.spawn(options.command, args, options.spawn); | ||
_this.childProcess.stdout.on('data', function (data) { | ||
console.log("Spawning ".concat(props.command, " ").concat(props.arguments.join(' '))); | ||
var childProcess = spawn(props.command, args, props.spawn); | ||
_this.childProcess = childProcess; | ||
childProcess.stdout.on('data', function (data) { | ||
console.log(data.toString()); | ||
}); | ||
_this.childProcess.stderr.on('data', function (data) { | ||
childProcess.stderr.on('data', function (data) { | ||
console.log("Child process wrote to stderr: \"".concat(data, "\".")); | ||
@@ -115,4 +111,3 @@ | ||
}); | ||
_this.childProcess.on('error', function (error) { | ||
childProcess.on('error', function (error) { | ||
console.log("Child process errored with ".concat(error)); | ||
@@ -124,4 +119,3 @@ | ||
}); | ||
_this.childProcess.on('close', function (code) { | ||
childProcess.on('close', function (code) { | ||
console.log("Child process exited with ".concat(code)); | ||
@@ -139,6 +133,6 @@ _this.childProcess = null; | ||
case 14: | ||
case 12: | ||
return _context.abrupt("return", _context.sent); | ||
case 15: | ||
case 13: | ||
case "end": | ||
@@ -151,3 +145,3 @@ return _context.stop(); | ||
function start() { | ||
function start(_x) { | ||
return _start.apply(this, arguments); | ||
@@ -228,4 +222,4 @@ } | ||
value: function _setTimeout(callback) { | ||
if (this.options.wait > 0) { | ||
this.successTimer = setTimeout(callback, this.options.wait); | ||
if (Number(this.props.wait) > 0) { | ||
this.successTimer = setTimeout(callback, this.props.wait); | ||
} | ||
@@ -232,0 +226,0 @@ } |
import ChildProcess from 'child_process'; | ||
export function getAvailablePort() { | ||
var defaultPort = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 3000; | ||
return new Promise(function (resolve, reject) { | ||
ChildProcess.exec('lsof -i -P -n | grep LISTEN', function (error, stdout, stderr) { | ||
return new Promise(function (resolve) { | ||
ChildProcess.exec('lsof -i -P -n | grep LISTEN', function (error, stdout) { | ||
if (error) { | ||
@@ -14,3 +14,3 @@ resolve(defaultPort); | ||
stdout.split('\n').forEach(function (line) { | ||
var match = line.match(regex); | ||
var match = regex.exec(line); | ||
@@ -17,0 +17,0 @@ if (match) { |
@@ -36,3 +36,3 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator"; | ||
_context.next = 8; | ||
return process(payload.input, payload.options || {}, payload); | ||
return process(payload.input, payload.options || {}); | ||
@@ -39,0 +39,0 @@ case 8: |
@@ -25,3 +25,3 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator"; | ||
options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {}; | ||
name = getWorkerObjectName(worker, options); | ||
name = getWorkerObjectName(worker); | ||
url = getWorkerObjectURL(worker, options); | ||
@@ -28,0 +28,0 @@ workerFarm = WorkerFarm.getWorkerFarm(options); |
import _typeof from "@babel/runtime/helpers/esm/typeof"; | ||
import { assert } from '../env-utils/assert'; | ||
var NPM_TAG = 'beta'; | ||
var VERSION = typeof "3.0.0-alpha.21" !== 'undefined' ? "3.0.0-alpha.21" : NPM_TAG; | ||
var VERSION = typeof "3.0.0-beta.1" !== 'undefined' ? "3.0.0-beta.1" : NPM_TAG; | ||
export function getWorkerObjectURL(worker, options) { | ||
@@ -39,7 +39,6 @@ var topOptions = options || {}; | ||
if (!coreVersion || !workerVersion) { | ||
return; | ||
return false; | ||
} | ||
coreVersion = parseVersion(coreVersion); | ||
workerVersion = parseVersion(workerVersion); | ||
return true; | ||
} | ||
@@ -46,0 +45,0 @@ |
import { assert } from '../env-utils/assert'; | ||
var workerURLCache = new Map(); | ||
export function buildWorkerURL(_ref) { | ||
var source = _ref.source, | ||
url = _ref.url; | ||
assert(source && !url || !source && url); | ||
var workerURL = workerURLCache.get(source || url); | ||
export function buildWorkerURL(props) { | ||
assert(props.source && !props.url || !props.source && props.url); | ||
var workerURL = workerURLCache.get(props.source || props.url); | ||
if (!workerURL) { | ||
if (url) { | ||
workerURL = getWorkerURLFromURL(url); | ||
workerURLCache.set(url, workerURL); | ||
if (props.url) { | ||
workerURL = getWorkerURLFromURL(props.url); | ||
workerURLCache.set(props.url, workerURL); | ||
} | ||
if (source) { | ||
workerURL = getWorkerURLFromSource(source); | ||
workerURLCache.set(source, workerURL); | ||
if (props.source) { | ||
workerURL = getWorkerURLFromSource(props.source); | ||
workerURLCache.set(props.source, workerURL); | ||
} | ||
@@ -35,3 +33,2 @@ } | ||
function getWorkerURLFromSource(workerSource) { | ||
assert(typeof workerSource === 'string', 'worker source'); | ||
var blob = new Blob([workerSource], { | ||
@@ -38,0 +35,0 @@ type: 'application/javascript' |
@@ -1,5 +0,11 @@ | ||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
import _createClass from "@babel/runtime/helpers/esm/createClass"; | ||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } | ||
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 ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } | ||
@@ -9,3 +15,2 @@ | ||
import { isMobile } from '../env-utils/globals'; | ||
import WorkerPool from './worker-pool'; | ||
@@ -19,3 +24,2 @@ import WorkerThread from './worker-thread'; | ||
}; | ||
var _workerFarm = null; | ||
@@ -26,2 +30,6 @@ var WorkerFarm = function () { | ||
_defineProperty(this, "props", void 0); | ||
_defineProperty(this, "workerPools", new Map()); | ||
this.props = _objectSpread({}, DEFAULT_PROPS); | ||
@@ -35,5 +43,15 @@ this.setProps(props); | ||
value: function destroy() { | ||
this.workerPools.forEach(function (workerPool) { | ||
return workerPool.destroy(); | ||
}); | ||
var _iterator = _createForOfIteratorHelper(this.workerPools.values()), | ||
_step; | ||
try { | ||
for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
var workerPool = _step.value; | ||
workerPool.destroy(); | ||
} | ||
} catch (err) { | ||
_iterator.e(err); | ||
} finally { | ||
_iterator.f(); | ||
} | ||
} | ||
@@ -44,9 +62,23 @@ }, { | ||
this.props = _objectSpread(_objectSpread({}, this.props), props); | ||
var _iterator2 = _createForOfIteratorHelper(this.workerPools.values()), | ||
_step2; | ||
try { | ||
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { | ||
var workerPool = _step2.value; | ||
workerPool.setProps(this._getWorkerPoolProps()); | ||
} | ||
} catch (err) { | ||
_iterator2.e(err); | ||
} finally { | ||
_iterator2.f(); | ||
} | ||
} | ||
}, { | ||
key: "getWorkerPool", | ||
value: function getWorkerPool(_ref) { | ||
var name = _ref.name, | ||
source = _ref.source, | ||
url = _ref.url; | ||
value: function getWorkerPool(options) { | ||
var name = options.name, | ||
source = options.source, | ||
url = options.url; | ||
var workerPool = this.workerPools.get(name); | ||
@@ -58,7 +90,5 @@ | ||
source: source, | ||
url: url, | ||
maxConcurrency: isMobile ? this.props.maxMobileConcurrency : this.props.maxConcurrency, | ||
onDebug: this.props.onDebug, | ||
reuseWorkers: this.props.reuseWorkers | ||
url: url | ||
}); | ||
workerPool.setProps(this._getWorkerPoolProps()); | ||
this.workerPools.set(name, workerPool); | ||
@@ -69,2 +99,12 @@ } | ||
} | ||
}, { | ||
key: "_getWorkerPoolProps", | ||
value: function _getWorkerPoolProps() { | ||
return { | ||
maxConcurrency: this.props.maxConcurrency, | ||
maxMobileConcurrency: this.props.maxMobileConcurrency, | ||
reuseWorkers: this.props.reuseWorkers, | ||
onDebug: this.props.onDebug | ||
}; | ||
} | ||
}], [{ | ||
@@ -79,7 +119,7 @@ key: "isSupported", | ||
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
_workerFarm = _workerFarm || new WorkerFarm({}); | ||
WorkerFarm._workerFarm = WorkerFarm._workerFarm || new WorkerFarm({}); | ||
_workerFarm.setProps(props); | ||
WorkerFarm._workerFarm.setProps(props); | ||
return _workerFarm; | ||
return WorkerFarm._workerFarm; | ||
} | ||
@@ -91,3 +131,5 @@ }]); | ||
_defineProperty(WorkerFarm, "_workerFarm", void 0); | ||
export { WorkerFarm as default }; | ||
//# sourceMappingURL=worker-farm.js.map |
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
import _createClass from "@babel/runtime/helpers/esm/createClass"; | ||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import { assert } from '../env-utils/assert'; | ||
@@ -11,5 +12,22 @@ | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "workerThread", void 0); | ||
_defineProperty(this, "isRunning", void 0); | ||
_defineProperty(this, "result", void 0); | ||
_defineProperty(this, "_resolve", void 0); | ||
_defineProperty(this, "_reject", void 0); | ||
this.name = jobName; | ||
this.workerThread = workerThread; | ||
this.isRunning = true; | ||
this._resolve = function () {}; | ||
this._reject = function () {}; | ||
this.result = new Promise(function (resolve, reject) { | ||
@@ -16,0 +34,0 @@ _this._resolve = resolve; |
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator"; | ||
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
import _createClass from "@babel/runtime/helpers/esm/createClass"; | ||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
import { assert } from '../env-utils/assert'; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
import { isMobile } from '../env-utils/globals'; | ||
import WorkerThread from './worker-thread'; | ||
@@ -10,29 +16,32 @@ import WorkerJob from './worker-job'; | ||
var WorkerPool = function () { | ||
function WorkerPool(_ref) { | ||
var source = _ref.source, | ||
url = _ref.url, | ||
_ref$name = _ref.name, | ||
name = _ref$name === void 0 ? 'unnamed' : _ref$name, | ||
_ref$maxConcurrency = _ref.maxConcurrency, | ||
maxConcurrency = _ref$maxConcurrency === void 0 ? 1 : _ref$maxConcurrency, | ||
onMessage = _ref.onMessage, | ||
_ref$onDebug = _ref.onDebug, | ||
onDebug = _ref$onDebug === void 0 ? function () {} : _ref$onDebug, | ||
_ref$reuseWorkers = _ref.reuseWorkers, | ||
reuseWorkers = _ref$reuseWorkers === void 0 ? true : _ref$reuseWorkers; | ||
function WorkerPool(props) { | ||
_classCallCheck(this, WorkerPool); | ||
assert(source || url); | ||
this.source = source; | ||
this.url = url; | ||
this.name = name; | ||
this.maxConcurrency = maxConcurrency; | ||
this.onMessage = onMessage; | ||
this.onDebug = onDebug; | ||
this.reuseWorkers = reuseWorkers; | ||
this.jobQueue = []; | ||
this.idleQueue = []; | ||
this.count = 0; | ||
this.isDestroyed = false; | ||
_defineProperty(this, "name", 'unnamed'); | ||
_defineProperty(this, "source", void 0); | ||
_defineProperty(this, "url", void 0); | ||
_defineProperty(this, "maxConcurrency", 1); | ||
_defineProperty(this, "maxMobileConcurrency", 1); | ||
_defineProperty(this, "onDebug", function () {}); | ||
_defineProperty(this, "reuseWorkers", true); | ||
_defineProperty(this, "props", {}); | ||
_defineProperty(this, "jobQueue", []); | ||
_defineProperty(this, "idleQueue", []); | ||
_defineProperty(this, "count", 0); | ||
_defineProperty(this, "isDestroyed", false); | ||
this.source = props.source; | ||
this.url = props.url; | ||
this.setProps(props); | ||
} | ||
@@ -49,2 +58,27 @@ | ||
}, { | ||
key: "setProps", | ||
value: function setProps(props) { | ||
this.props = _objectSpread(_objectSpread({}, this.props), props); | ||
if (props.name !== undefined) { | ||
this.name = props.name; | ||
} | ||
if (props.maxConcurrency !== undefined) { | ||
this.maxConcurrency = props.maxConcurrency; | ||
} | ||
if (props.maxMobileConcurrency !== undefined) { | ||
this.maxMobileConcurrency = props.maxMobileConcurrency; | ||
} | ||
if (props.reuseWorkers !== undefined) { | ||
this.reuseWorkers = props.reuseWorkers; | ||
} | ||
if (props.onDebug !== undefined) { | ||
this.onDebug = props.onDebug; | ||
} | ||
} | ||
}, { | ||
key: "startJob", | ||
@@ -76,2 +110,4 @@ value: function () { | ||
}); | ||
return _this; | ||
}); | ||
@@ -81,5 +117,9 @@ | ||
return _context.abrupt("return", startPromise); | ||
_context.next = 6; | ||
return startPromise; | ||
case 5: | ||
case 6: | ||
return _context.abrupt("return", _context.sent); | ||
case 7: | ||
case "end": | ||
@@ -102,3 +142,4 @@ return _context.stop(); | ||
var _startQueuedJob2 = _asyncToGenerator(_regeneratorRuntime.mark(function _callee2() { | ||
var workerThread, queuedJob, job; | ||
var workerThread, queuedJob, _job; | ||
return _regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
@@ -135,20 +176,20 @@ while (1) { | ||
message: 'Starting job', | ||
jobName: queuedJob.name, | ||
name: queuedJob.name, | ||
workerThread: workerThread, | ||
backlog: this.jobQueue.length | ||
}); | ||
job = new WorkerJob(queuedJob.name, workerThread); | ||
_job = new WorkerJob(queuedJob.name, workerThread); | ||
workerThread.onMessage = function (data) { | ||
return queuedJob.onMessage(job, data.type, data.payload); | ||
return queuedJob.onMessage(_job, data.type, data.payload); | ||
}; | ||
workerThread.onError = function (error) { | ||
return queuedJob.onError(job, error); | ||
return queuedJob.onError(_job, error); | ||
}; | ||
queuedJob.onStart(job); | ||
queuedJob.onStart(_job); | ||
_context2.prev = 12; | ||
_context2.next = 15; | ||
return job.result; | ||
return _job.result; | ||
@@ -177,15 +218,14 @@ case 15: | ||
value: function returnWorkerToQueue(worker) { | ||
if (this.isDestroyed) { | ||
worker.destroy(); | ||
return; | ||
} | ||
var shouldDestroyWorker = this.isDestroyed || !this.reuseWorkers || this.count > this._getMaxConcurrency(); | ||
if (this.reuseWorkers) { | ||
this.idleQueue.push(worker); | ||
} else { | ||
if (shouldDestroyWorker) { | ||
worker.destroy(); | ||
this.count--; | ||
} else { | ||
this.idleQueue.push(worker); | ||
} | ||
this._startQueuedJob(); | ||
if (!this.isDestroyed) { | ||
this._startQueuedJob(); | ||
} | ||
} | ||
@@ -199,3 +239,3 @@ }, { | ||
if (this.count < this.maxConcurrency) { | ||
if (this.count < this._getMaxConcurrency()) { | ||
this.count++; | ||
@@ -212,2 +252,7 @@ var name = "".concat(this.name.toLowerCase(), " (#").concat(this.count, " of ").concat(this.maxConcurrency, ")"); | ||
} | ||
}, { | ||
key: "_getMaxConcurrency", | ||
value: function _getMaxConcurrency() { | ||
return isMobile ? this.maxMobileConcurrency : this.maxConcurrency; | ||
} | ||
}]); | ||
@@ -214,0 +259,0 @@ |
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
import _createClass from "@babel/runtime/helpers/esm/createClass"; | ||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import { assert } from '../env-utils/assert'; | ||
@@ -7,3 +8,3 @@ import { buildWorkerURL } from './build-worker-url'; | ||
var NOOP = function NOOP(_) {}; | ||
var NOOP = function NOOP() {}; | ||
@@ -14,2 +15,18 @@ var WorkerThread = function () { | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "source", void 0); | ||
_defineProperty(this, "url", void 0); | ||
_defineProperty(this, "terminated", false); | ||
_defineProperty(this, "worker", void 0); | ||
_defineProperty(this, "onMessage", void 0); | ||
_defineProperty(this, "onError", void 0); | ||
_defineProperty(this, "_loadableURL", ''); | ||
var name = props.name, | ||
@@ -28,3 +45,2 @@ source = props.source, | ||
this.terminated = false; | ||
this.worker = this._createBrowserWorker(); | ||
@@ -55,3 +71,3 @@ } | ||
value: function _getErrorFromErrorEvent(event) { | ||
var message = "Failed to load "; | ||
var message = 'Failed to load '; | ||
message += "worker ".concat(this.name, ". "); | ||
@@ -84,3 +100,3 @@ | ||
if (!event.data) { | ||
_this.onError('No data received'); | ||
_this.onError(new Error('No data received')); | ||
} else { | ||
@@ -87,0 +103,0 @@ _this.onMessage(event.data); |
@@ -1,2 +0,2 @@ | ||
export {}; | ||
//# sourceMappingURL=protocol.js.map |
@@ -1,2 +0,2 @@ | ||
export {}; | ||
//# sourceMappingURL=types.js.map |
@@ -1,6 +0,24 @@ | ||
import {createWorker} from '../lib/worker-api/create-worker'; | ||
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator"; | ||
import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
import { createWorker } from '../lib/worker-api/create-worker'; | ||
createWorker(function () { | ||
var _ref = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(data) { | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
return _context.abrupt("return", data); | ||
createWorker(async (data, options) => { | ||
// @ts-ignore | ||
return data; | ||
}); | ||
case 1: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee); | ||
})); | ||
return function (_x) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}()); | ||
//# sourceMappingURL=null-worker.js.map |
@@ -84,3 +84,3 @@ /******/ (function(modules) { // webpackBootstrap | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = "./src/workers/null-worker.js"); | ||
/******/ return __webpack_require__(__webpack_require__.s = "./src/workers/null-worker.ts"); | ||
/******/ }) | ||
@@ -90,5 +90,32 @@ /************************************************************************/ | ||
/***/ "./src/lib/async-queue/async-queue.js": | ||
/***/ "../../node_modules/@babel/runtime/helpers/defineProperty.js": | ||
/*!**************************************************************************************************!*\ | ||
!*** /home/user/apps/loaders.gl_duplicate/node_modules/@babel/runtime/helpers/defineProperty.js ***! | ||
\**************************************************************************************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports) { | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
module.exports = _defineProperty; | ||
module.exports["default"] = module.exports, module.exports.__esModule = true; | ||
/***/ }), | ||
/***/ "./src/lib/async-queue/async-queue.ts": | ||
/*!********************************************!*\ | ||
!*** ./src/lib/async-queue/async-queue.js ***! | ||
!*** ./src/lib/async-queue/async-queue.ts ***! | ||
\********************************************/ | ||
@@ -101,6 +128,32 @@ /*! exports provided: default */ | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return AsyncQueue; }); | ||
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../../node_modules/@babel/runtime/helpers/defineProperty.js"); | ||
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__); | ||
let _Symbol$asyncIterator; | ||
_Symbol$asyncIterator = Symbol.asyncIterator; | ||
// From https://github.com/rauschma/async-iter-demo/tree/master/src under MIT license | ||
// http://2ality.com/2016/10/asynchronous-iteration.html | ||
/** | ||
* Async Queue | ||
* - AsyncIterable: An async iterator can be | ||
* - Values can be pushed onto the queue | ||
* @example | ||
* const asyncQueue = new AsyncQueue(); | ||
* setTimeout(() => asyncQueue.enqueue('tick'), 1000); | ||
* setTimeout(() => asyncQueue.enqueue(new Error('done')), 10000); | ||
* for await (const value of asyncQueue) { | ||
* console.log(value); // tick | ||
* } | ||
*/ | ||
class AsyncQueue { | ||
constructor() { | ||
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(this, "_values", void 0); | ||
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(this, "_settlers", void 0); | ||
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(this, "_closed", void 0); | ||
this._values = []; // enqueues > dequeues | ||
@@ -112,11 +165,20 @@ | ||
} | ||
/** Return an async iterator for this queue */ | ||
[Symbol.asyncIterator]() { | ||
[_Symbol$asyncIterator]() { | ||
return this; | ||
} | ||
/** Push a new value - the async iterator will yield a promise resolved to this value */ | ||
push(value) { | ||
return this.enqueue(value); | ||
} | ||
/** | ||
* Push a new value - the async iterator will yield a promise resolved to this value | ||
* Add an error - the async iterator will yield a promise rejected with this value | ||
*/ | ||
enqueue(value) { | ||
@@ -145,3 +207,5 @@ if (this._closed) { | ||
} | ||
/** Indicate that we not waiting for more values - The async iterator will be done */ | ||
close() { | ||
@@ -159,5 +223,3 @@ while (this._settlers.length > 0) { | ||
/** | ||
* @returns a Promise for an IteratorResult | ||
*/ | ||
/** @returns a Promise for an IteratorResult */ | ||
@@ -187,3 +249,4 @@ | ||
return Promise.resolve({ | ||
done: true | ||
done: true, | ||
value: undefined | ||
}); | ||
@@ -205,5 +268,5 @@ } // Yield a promise that waits for new values to be enqueued | ||
/***/ "./src/lib/worker-api/create-worker.js": | ||
/***/ "./src/lib/worker-api/create-worker.ts": | ||
/*!*********************************************!*\ | ||
!*** ./src/lib/worker-api/create-worker.js ***! | ||
!*** ./src/lib/worker-api/create-worker.ts ***! | ||
\*********************************************/ | ||
@@ -216,15 +279,12 @@ /*! exports provided: createWorker */ | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createWorker", function() { return createWorker; }); | ||
/* harmony import */ var _async_queue_async_queue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../async-queue/async-queue */ "./src/lib/async-queue/async-queue.js"); | ||
/* harmony import */ var _worker_farm_worker_body__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../worker-farm/worker-body */ "./src/lib/worker-farm/worker-body.js"); | ||
/* eslint-disable no-restricted-globals */ | ||
/* harmony import */ var _async_queue_async_queue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../async-queue/async-queue */ "./src/lib/async-queue/async-queue.ts"); | ||
/* harmony import */ var _worker_farm_worker_body__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../worker-farm/worker-body */ "./src/lib/worker-farm/worker-body.ts"); | ||
/** @typedef {import('../worker-protocol/protocol').WorkerMessageType} WorkerMessageType */ | ||
/** @typedef {import('../worker-protocol/protocol').WorkerMessagePayload} WorkerMessagePayload */ | ||
// /** @typedef {import('../worker-protocol/protocol').WorkerMessageData} WorkerMessageData */ | ||
// /** @typedef {import('../worker-protocol/protocol').WorkerMessage} WorkerMessage */ | ||
let inputBatches; | ||
let options; | ||
/** | ||
* Set up a WebWorkerGlobalScope to talk with the main thread | ||
*/ | ||
function createWorker(process, processInBatches) { | ||
@@ -235,9 +295,3 @@ // Check that we are actually in a worker thread | ||
} | ||
/** | ||
* | ||
* @param {WorkerMessageType} type | ||
* @param {WorkerMessagePayload} payload | ||
*/ | ||
_worker_farm_worker_body__WEBPACK_IMPORTED_MODULE_1__["default"].onmessage = async (type, payload) => { | ||
@@ -251,3 +305,3 @@ try { | ||
const result = await process(payload.input, payload.options || {}, payload); | ||
const result = await process(payload.input, payload.options || {}); | ||
_worker_farm_worker_body__WEBPACK_IMPORTED_MODULE_1__["default"].postMessage('done', { | ||
@@ -296,5 +350,5 @@ result | ||
/***/ "./src/lib/worker-farm/get-transfer-list.js": | ||
/***/ "./src/lib/worker-farm/get-transfer-list.ts": | ||
/*!**************************************************!*\ | ||
!*** ./src/lib/worker-farm/get-transfer-list.js ***! | ||
!*** ./src/lib/worker-farm/get-transfer-list.ts ***! | ||
\**************************************************/ | ||
@@ -309,4 +363,11 @@ /*! exports provided: getTransferList */ | ||
// core does not need all the utils in loader-utils, just this one. | ||
// Returns an array of Transferrable objects that can be used with postMessage | ||
// https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage | ||
/** | ||
* Returns an array of Transferrable objects that can be used with postMessage | ||
* https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage | ||
* @param object data to be sent via postMessage | ||
* @param recursive - not for application use | ||
* @param transfers - not for application use | ||
* @returns a transfer list that can be passed to postMessage | ||
*/ | ||
function getTransferList(object, recursive = true, transfers) { | ||
@@ -362,5 +423,5 @@ // Make sure that items in the transfer list is unique | ||
/***/ "./src/lib/worker-farm/worker-body.js": | ||
/***/ "./src/lib/worker-farm/worker-body.ts": | ||
/*!********************************************!*\ | ||
!*** ./src/lib/worker-farm/worker-body.js ***! | ||
!*** ./src/lib/worker-farm/worker-body.ts ***! | ||
\********************************************/ | ||
@@ -373,11 +434,5 @@ /*! exports provided: default */ | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return WorkerBody; }); | ||
/* harmony import */ var _worker_farm_get_transfer_list__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../worker-farm/get-transfer-list */ "./src/lib/worker-farm/get-transfer-list.js"); | ||
/* harmony import */ var _worker_farm_get_transfer_list__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../worker-farm/get-transfer-list */ "./src/lib/worker-farm/get-transfer-list.ts"); | ||
/* eslint-disable no-restricted-globals */ | ||
/** @typedef {import('../worker-protocol/protocol').WorkerMessageData} WorkerMessageData */ | ||
/** @typedef {import('../worker-protocol/protocol').WorkerMessageType} WorkerMessageType */ | ||
/** @typedef {import('../worker-protocol/protocol').WorkerMessagePayload} WorkerMessagePayload */ | ||
const onMessageWrapperMap = new Map(); | ||
@@ -434,4 +489,5 @@ /** | ||
/** | ||
* @param {WorkerMessageType} type; | ||
* @param {WorkerMessagePayload} payload | ||
* Send a message from a worker to creating thread (main thread) | ||
* @param type | ||
* @param payload | ||
*/ | ||
@@ -442,3 +498,2 @@ | ||
if (self) { | ||
/** @type {WorkerMessageData} */ | ||
const data = { | ||
@@ -467,5 +522,5 @@ source: 'loaders.gl', | ||
/***/ "./src/workers/null-worker.js": | ||
/***/ "./src/workers/null-worker.ts": | ||
/*!************************************!*\ | ||
!*** ./src/workers/null-worker.js ***! | ||
!*** ./src/workers/null-worker.ts ***! | ||
\************************************/ | ||
@@ -477,5 +532,5 @@ /*! no exports provided */ | ||
__webpack_require__.r(__webpack_exports__); | ||
/* harmony import */ var _lib_worker_api_create_worker__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../lib/worker-api/create-worker */ "./src/lib/worker-api/create-worker.js"); | ||
/* harmony import */ var _lib_worker_api_create_worker__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../lib/worker-api/create-worker */ "./src/lib/worker-api/create-worker.ts"); | ||
Object(_lib_worker_api_create_worker__WEBPACK_IMPORTED_MODULE_0__["createWorker"])(async (data, options) => { | ||
Object(_lib_worker_api_create_worker__WEBPACK_IMPORTED_MODULE_0__["createWorker"])(async data => { | ||
// @ts-ignore | ||
@@ -482,0 +537,0 @@ return data; |
{ | ||
"name": "@loaders.gl/worker-utils", | ||
"version": "3.0.0-alpha.21", | ||
"version": "3.0.0-beta.1", | ||
"description": "Utilities for running tasks on worker threads", | ||
@@ -38,4 +38,4 @@ "license": "MIT", | ||
"pre-build-disabled": "npm run build-bundle && npm run build-workers", | ||
"build-bundle": "webpack --display=minimal --config ../../scripts/webpack/bundle.js", | ||
"build-workers": "webpack --entry ./src/workers/null-worker.js --output ./dist/null-worker.js --env.dev --config ../../scripts/webpack/worker.js" | ||
"build-bundle": "webpack --config ../../scripts/webpack/bundle.ts", | ||
"build-workers": "webpack --entry ./src/workers/null-worker.ts --output ./dist/null-worker.js --env.dev --config ../../scripts/webpack/worker.js" | ||
}, | ||
@@ -45,3 +45,3 @@ "dependencies": { | ||
}, | ||
"gitHead": "c1f7d7bec911c704a190dbcf6b392a07a555771b" | ||
"gitHead": "2fb06018114d18a86143d10a8a02341a0b9a01a9" | ||
} |
@@ -0,6 +1,10 @@ | ||
import type {WorkerObject} from './types'; | ||
// TYPES | ||
export type WorkerObject = import('./types').WorkerObject; | ||
export type WorkerMessage = import('./lib/worker-protocol/protocol').WorkerMessage; | ||
export type WorkerMessageData = import('./lib/worker-protocol/protocol').WorkerMessageData; | ||
export type WorkerMessagePayload = import('./lib/worker-protocol/protocol').WorkerMessagePayload; | ||
export type {WorkerObject} from './types'; | ||
export type { | ||
WorkerMessage, | ||
WorkerMessageData, | ||
WorkerMessagePayload | ||
} from './lib/worker-protocol/protocol'; | ||
@@ -7,0 +11,0 @@ // GENERAL UTILS |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
381401
13
115
4999