![]() 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-sheet/js/fx/TSFunction.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var ExcelFx = _interopRequireWildcard(require("./ExcelFx")); function TSFunction(propertyNames, body) { this.propertyNames = propertyNames; this.body = body; this.dependents = []; this.ast = null; this.func = null; this._compile(); } TSFunction.prototype.localConstants = {}; Object.assign(TSFunction.prototype.localConstants, ExcelFx); TSFunction.prototype._isAsync = function (jsCode) { if (!window.babel) return false; var scriptCode = 'async function fx(){\n' + jsCode + '\n}'; var result = false; var ast = babel.parseSync(scriptCode, {}); babel.traverse(ast, { AwaitExpression: function () { result = true; } }); return result; }; TSFunction.prototype._makeConstCode = function (localConstants) { return Object.keys(localConstants).map(function (key) { return 'const ' + key + ' = localConstants[' + JSON.stringify(key) + '];'; }).join('\n') + '\n'; }; TSFunction.prototype._compile = function () { var types = babel && babel.types; var scriptCode; if (this.body.startsWith('=')) { scriptCode = 'RET' + this.body; } else scriptCode = this.body; if (!window.babel) return; var variableDict = this.propertyNames.reduce(function (ac, cr) { ac[cr] = true; return ac; }, {}); try { var isAsync = this._isAsync(scriptCode); scriptCode = (isAsync ? 'async ' : '') + 'function fx(RC){\n' + 'var RET;\n' + scriptCode + '\nreturn RET;' + '\n}'; this.ast = babel.parseSync(scriptCode, {}); var variables = {}; babel.traverse(this.ast, { Program: function (path) {}, Identifier: function (path) { var node = path.node; var name = node.name; if (path.container.type === "MemberExpression" && path.container.object !== node) return; var newNode; if (variableDict[name]) { variables[name] = true; newNode = types.memberExpression(types.identifier('RC'), types.identifier(name)); newNode.ignore = true; path.replaceWith(newNode); } }, MemberExpression: function (path) { if (path.node.ignore) path.skip(); } }); this.dependents = Object.keys(variables); this.jsCode = 'module.exports = ' + babel.generate(this.ast).code; var options = { presets: [babel.presetEnv] }; this.transformedCode = babel.transform(this.jsCode, options).code; var mdl = {}; new Function('module', 'regeneratorRuntime', 'localConstants', this._makeConstCode(this.localConstants) + this.transformedCode)(mdl, babel.regeneratorRuntime, this.localConstants); this.func = mdl.exports; } catch (err) { setTimeout(function () { throw err; }, 0); } }; TSFunction.prototype.invoke = function (_this, record) { try { return this.func.call(_this, record); } catch (err) { // if (window["ABSOL_DEBUG"]) safeThrow(err); return undefined; } }; var _default = TSFunction; exports.default = _default;