VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/libs/absol-full/dist/js/mdls__absol-tutor__js__buildTutorJavaScript.js
/*** module: node_modules/absol-tutor/js/buildTutorJavaScript.js ***/
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = buildTutorJavaScript;

var _runtime = _interopRequireDefault(require("regenerator-runtime/runtime"));

var _TutorNameManager = _interopRequireDefault(require("./scriptor/TutorNameManager"));


var traverse = babel.traverse;
var parse = babel.parse;
var babelTypes = babel.types;
var presetEnv = babel.presetEnv;
var generator = babel.generator;

function moduleTemplate(code, argNames) {
  return 'module.exports = async function exec(' + argNames.join(',') + ') {\n' + code + '\nreturn 0;' + '}';
}

function awaitInject(code, ast, asyncFunctionNames) {
  var dict = asyncFunctionNames.reduce(function (ac, cr) {
    ac[cr] = true;
    return ac;
  }, {});
  traverse(ast, {
    ExpressionStatement: function (path) {
      if (path.node.ignore) return;
      if (path.node.loc.start.line === 1) return;

      var _db = babel.types.callExpression(babel.types.identifier("_db"), [babel.types.numericLiteral(path.node.loc.start.line), babel.types.numericLiteral(path.node.loc.start.column), babel.types.numericLiteral(path.node.start), babel.types.numericLiteral(path.node.end)]);

      _db.ignore = true;
      path.insertBefore(_db);
    },
    CallExpression: function (path) {
      var needUpdate = false;

      if (path.parent.type === 'AwaitExpression') {
        needUpdate = true;
      } else {
        var node = path.node;
        var callee = node.callee;
        var calleeName = code.substr(callee.start, callee.end - callee.start);

        if (dict[calleeName]) {
          var newNode = babelTypes.awaitExpression(node);
          path.replaceWith(newNode);
          needUpdate = true;
        }
      }

      if (needUpdate) {
        var p = path;
        var pNode;

        while (p) {
          pNode = p.node;

          if (pNode.type === 'FunctionDeclaration') {
            pNode.async = true;
            dict[pNode.id.name] = true;
            break;
          }

          p = p.parentPath;
        }
      }
    }
  });
  return ast;
}

function buildTutorJavaScript(code) {
  var argNames = _TutorNameManager.default.getAll();

  code = moduleTemplate(code, argNames);
  var ast = parse(code);
  awaitInject(code, ast, _TutorNameManager.default.getAllAsync());
  var options = {
    presets: [presetEnv]
  };
  var newCode = generator(ast, {}, code).code;
  var transformedCode = babel.transform(newCode, options).code;
  var m = {};
  var execFn = new Function('module', 'regeneratorRuntime', transformedCode);
  execFn(m, _runtime.default);
  return {
    argNames: argNames,
    exec: m.exports,
    code: code,
    es6Code: newCode,
    transformedCode: transformedCode
  };
}

VaKeR 2022