![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /var/www/html/libs/absol-full/dist/js/ |
Upload File : |
/*** module: node_modules/absol/src/Network/Thread.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _IFrameBridge = _interopRequireDefault(require("./IFrameBridge")); var _OOP = _interopRequireDefault(require("../HTML5/OOP")); var _RemoteThread = _interopRequireDefault(require("./RemoteThread.tpl")); var _noop = _interopRequireDefault(require("../Code/noop")); /*** * * @param {{methods?:Object, extendCode: string}} opt * @constructor */ function Thread(opt) { this.worker = new Worker(this._makeCodeUrl(opt)); _IFrameBridge.default.call(this, this.worker); this._attachClientMethods(opt.methods); } Thread.prototype._makeCodeUrl = function (opt) { var code = [this._makeLibCode(opt.libs), _RemoteThread.default, this._makeMethodCode(opt.methods), this._makePropCode(opt.props), opt.extendCode || ''].join('\n\n'); var blob = new Blob([code], { type: 'application/javascript' }); var url = URL.createObjectURL(blob); return url; }; Thread.prototype._makePropCode = function (props) { if (!props) return ''; return 'Object.assign(self, ' + JSON.stringify(props) + ');'; }; Thread.prototype._makeLibCode = function (libs) { if (!libs) return ''; return libs.map(function (lib) { return 'self.importScripts(' + JSON.stringify(lib) + ');'; }).join('\n'); }; Thread.prototype._makeMethodCode = function (methods) { if (!methods) return ''; return Object.keys(methods).map(function (key) { var fx = methods[key]; if (typeof fx === "function") { fx = fx.toString(); return 'self[' + JSON.stringify(key) + '] = ' + fx; } }).join('\n\n'); }; Thread.prototype._attachClientMethods = function (methods) { if (!methods) return ''; Object.keys(methods).reduce(function (ac, name) { ac[name] = function () { return this.invoke.apply(this, [name].concat(Array.prototype.slice.call(arguments))); }; return ac; }, this); }; Thread.prototype.destroy = function () { if (this.worker) { this.worker.terminate(); delete this.worker; } }; Thread.prototype.revokeResource = function () { this.destroy(); this.revokeResource = _noop.default; }; _OOP.default.mixClass(Thread, _IFrameBridge.default); var _default = Thread; exports.default = _default;