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__src__JSMaker__TemplateXML.js
/*** module: node_modules/absol/src/JSMaker/TemplateXML.js ***/
"use strict";

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

var _XML = _interopRequireDefault(require("../XML/XML"));

var _XMLConstant = _interopRequireDefault(require("../XML/XMLConstant"));

var _TemplateString = _interopRequireDefault(require("./TemplateString"));


function TemplateXML(props) {
  this.xml = props.xml;
}

TemplateXML.prototype._xmlNodeToJSCode = function (node) {
  var body = [];

  if (node.nodeType == _XMLConstant.default.TYPE_ELEMENT) {
    body.push('tag:' + JSON.stringify(node.tagName));
    var attributeKeys = Object.keys(node.attributes).filter(function (x) {
      return x != 'class' && x != 'style' && !x.startsWith('az-');
    });

    if (attributeKeys && attributeKeys.length > 0) {
      body.push('attr: {' + attributeKeys.map(function (key) {
        return JSON.stringify(key) + ': ' + _TemplateString.default.parse(node.attributes[key]).toJSCode();
      }).join(', ') + '}');
    }

    if (node.attributes['az-props']) {
      body.push('props: ' + _TemplateString.default.parse(node.attributes['az-props']).toJSCode());
    }

    if (node.attributes['az-data']) {
      body.push('data: ' + _TemplateString.default.parse(node.attributes['az-data']).toJSCode());
    }

    if (node.attributes.style) {
      var styleSheet = node.attributes.style.split(';').map(function (s) {
        var t = s.split(':').map(function (text) {
          return text.trim();
        });

        if (t.length == 2) {
          return JSON.stringify(t[0]) + ': ' + JSON.stringify(t[1]);
        } else return false;
      }).filter(function (e) {
        return !!e;
      });

      if (styleSheet.length > 0) {
        body.push('style:{' + styleSheet.join(',') + '}');
      }
    }

    if (node.attributes.class) {
      var classList = node.attributes.class.trim().split(/\s+/);
      if (classList.length > 0) body.push('class:' + JSON.stringify(classList));
    }

    if (node.childNodes && node.childNodes.length > 0) {
      var childList = '[' + node.childNodes.filter(function (e) {
        return e.nodeType == _XMLConstant.default.TYPE_ELEMENT || e.nodeType == _XMLConstant.default.TYPE_TEXT;
      }).map(function (e) {
        return this._xmlNodeToJSCode(e);
      }.bind(this)).filter(function (e) {
        return !!e;
      }).join(', ') + ']';
      if (childList && childList.length > 0) body.push('child: ' + childList);
    }
  } else if (node.nodeType == _XMLConstant.default.TYPE_TEXT) {
    body.push('text: ' + _TemplateString.default.parse(node.data).toJSCode());
  } else return undefined;

  var res = '{' + body.join(', ') + '}';
  return res;
};

TemplateXML.prototype.toJSCode = function () {
  var res = this._xmlNodeToJSCode(this.xml);

  return res;
};
/**
 * 
 * @param  {...any} args 
 * @returns {Function}
 */


TemplateXML.compileToFunction = function () {
  var innerCode = 'return ' + this.parse(arguments[arguments.length - 1]).toJSCode() + ';';
  var fParam = Array.prototype.slice.call(arguments, 0, arguments.length - 1);
  fParam.push(innerCode);
  return Function.apply(null, fParam);
};

TemplateXML.parse = function (text) {
  var xml = _XML.default.parse(text);

  if (xml) {
    return new TemplateXML({
      xml: xml
    });
  } else return undefined;
};

var _default = TemplateXML;
exports.default = _default;

VaKeR 2022