![]() 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-form/js/fragment/ProjectExplorer.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FMExploreDelegate = FMExploreDelegate; exports.default = void 0; var _EventEmitter = _interopRequireWildcard(require("absol/src/HTML5/EventEmitter")); var _FCore = _interopRequireWildcard(require("../core/FCore")); require("../../css/projectexplorer.css"); var _PluginManager = _interopRequireDefault(require("../core/PluginManager")); var _R = _interopRequireDefault(require("../R")); var _OOP = _interopRequireDefault(require("absol/src/HTML5/OOP")); var _CMDTool = _interopRequireDefault(require("./CMDTool")); var _CMDRunner = _interopRequireDefault(require("absol/src/AppPattern/CMDRunner")); var _Searcher = _interopRequireDefault(require("absol-acomp/js/Searcher")); var _search = _interopRequireWildcard(require("absol-acomp/js/list/search")); var _stringUtils = require("absol/src/String/stringUtils"); var _stringGenerate = require("absol/src/String/stringGenerate"); var _Context = _interopRequireDefault(require("absol/src/AppPattern/Context")); var _FExplorer = _interopRequireDefault(require("../launcher/FExplorer")); function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } 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 _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } 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; } /*** * @augments FExplorer * @augments EventEmitter * @constructor */ function ProjectExplorer() { _EventEmitter.default.call(this); _FExplorer.default.call(this); this.pluginContext = new _Context.default(); Object.assign(this.pluginContext, { isV2: localStorage.getItem("Fv2"), self: this, _: _FCore._, $: _FCore.$ }); this.pluginContext.attach(this); /** * * @type {null|FMExploreDelegate} * @private */ this._delegate = null; this.commands = this.commands.map(it => Object.assign({}, it)); this.commandByName = this.commands.reduce((ac, it) => { ac[it.name] = it; return ac; }, {}); this.cmdTool = new _CMDTool.default(); this.data = { projectName: null }; this.cmdRunner = new _CMDRunner.default(this, this.commands.reduce((ac, cmd) => { ac[cmd.name] = cmd.exec; return ac; }, {})); this.cmdTool.bindWithEditor(this); } _OOP.default.mixClass(ProjectExplorer, _EventEmitter.default, _FExplorer.default); ProjectExplorer.prototype.windowTitle = "Explorer"; ProjectExplorer.prototype.onStart = function () { _PluginManager.default.exec(this, _R.default.PLUGINS.PROJECT_EXPLORER, this.pluginContext); if (this.pluginContext.delegate) { this.delegate = this.pluginContext.delegate; } this.cmdTool.start(true); }; ProjectExplorer.prototype.onResume = function () { this.cmdTool.resume(); }; ProjectExplorer.prototype.createView = function () { var self = this; this.$view = (0, _FCore._)({ class: 'as-form-explorer', style: { height: '100%' }, child: [this.cmdTool.getView(), _Searcher.default, { class: 'as-form-explorer-body', style: { position: 'absolute', left: 0, top: '80px', right: 0, height: 'calc(100% - 80px)', overflowY: 'auto' } // child: { // tag: ExpTree.tag, // props: { // name: this.data.projectName || 'NONE', // status: 'open', // icon: 'span.mdi.mdi-folder-star-multiple-outline' // } // } }] }); this.$searchInput = (0, _FCore.$)(_Searcher.default.tag, this.$view).on('stoptyping', () => { this.searcher.query(this.$searchInput.value); }); this.$body = (0, _FCore.$)('.as-form-explorer-body', this.$view); this.$body.getChildren = function () { return Array.prototype.slice.call(this.childNodes); }; this.$body.name = "NoName"; // this.$droppanel = $('exptree', this.$view); /** before new feature release, I cheated here */ this.searcher = new ExpSearcher(this.$body); this.$cmdCtn = (0, _FCore._)('.absol-drop-panel-head-cmd-button-container'); this.$reloadCmdBtn = (0, _FCore._)({ tag: 'button', child: 'span.mdi.mdi-reload', on: { click: this.redrawExpTree.bind(this) } }).addTo(this.$cmdCtn); setTimeout(this.redrawExpTree.bind(this), 100); }; ProjectExplorer.prototype.openProject = function (value) { if (typeof value == 'string') this.data = { projectName: value || "Unknown" };else { this.data = value || {}; } if (this.$window) { this.windowTitle = this.data.projectName; this.$window.windowTitle = this.windowTitle; this.redrawExpTree(); } }; ProjectExplorer.prototype.getExploreTree = function () { return this._delegate.getTreeData(); }; ProjectExplorer.prototype.loadExpTree = function () { if (!this._delegate && this.pluginContext.loadExpTree) { this.pluginContext.loadExpTree(); return; } }; ProjectExplorer.prototype.openItem = function (type, ident, name, contentArguments, desc) { var formEditor = this.getContext(_R.default.FORM_EDITOR); if (formEditor) { formEditor.openItem(type, ident, name, contentArguments, desc); } }; /***Cmd***/ ProjectExplorer.prototype.commands = [{ name: 'new', icon: 'span.mdi.mdi-file-plus-outline', desc: 'New', /*** * @this {ProjectExplorer} */ exec: function () { console.log(this); } }, { name: 'reload', icon: 'span.mdi.mdi-reload', desc: 'Reload', /*** * @this {ProjectExplorer} */ exec: function () { var sync = this.redrawExpTree(); Promise.resolve(sync).then(() => { this.searcher.query(this.$searchInput.value); }); } }]; ProjectExplorer.prototype.getCmdGroupTree = function () { return this.commands.map(it => it.name); }; ProjectExplorer.prototype.getCmdDescriptor = function (name) { return Object.assign({ type: 'trigger' }, this.commandByName[name]); }; ProjectExplorer.prototype.onTreeAction = function (treeData, action, nodeElt) { var ac; switch (action.cmd) { case 'open': this.openItem.apply(this, _toConsumableArray(treeData.openArgs)); break; case 'rename': /** * @type {Context} */ ac = Object.assign(new _Context.default(), treeData); ac.attach(this); ac.nodeElt = nodeElt; nodeElt.getNode().rename(newName => { ac.newName = newName; if (this._delegate) return this._delegate.onUserRenameCompleted(ac); return true; }); break; default: if (this._delegate) this._delegate.onTreeAction(treeData, action, nodeElt); } }; ProjectExplorer.prototype.getActionContextMenuProps = function (treeData) { if (!this._delegate) return { items: [{ icon: 'span.mdi.mdi-folder-open', text: 'Open', cmd: 'open' }] }; return this._delegate.getActionContextMenuProps(treeData); }; /*** * @param {{type: string,name: string, icon: string, exec: function}} commandDesc * @param {string=} bf before */ ProjectExplorer.prototype.addCommand = function (commandDesc, bf) { var idx = this.commands.findIndex(it => it.name === commandDesc.name); if (idx >= 0) { Object.assign(this.commands[idx], commandDesc); } else { if (bf) { idx = this.commands.findIndex(it => it.name === bf); if (idx < 0) this.commands.push(commandDesc);else { this.commands.splice(idx, 0, commandDesc); } } else { if (idx < 0) this.commands.push(commandDesc); } this.commandByName[commandDesc.name] = commandDesc; } this.cmdRunner.add(commandDesc.name, commandDesc.exec); return this; }; ProjectExplorer.prototype.execCmd = function () { this.cmdRunner.invoke.apply(this.cmdRunner, arguments); }; /** * * @param any * @returns {ExpTree} */ ProjectExplorer.prototype.nodeEltOf = function (any) {}; ProjectExplorer.prototype.userRenameNode = function (any, ac) { var nodeElt = this.nodeEltOf(any); if (!nodeElt) return; /** * @type {Context} */ ac = Object.assign(new _Context.default(), ac); ac.nodeElt = nodeElt; nodeElt.getNode().rename(newName => { ac.newName = newName; if (this._delegate) this._delegate.onUserRenameCompleted(ac); }); }; ProjectExplorer.prototype.removeNode = function (any) { var nodeElt = this.nodeEltOf(any); if (!nodeElt) return; if (nodeElt) { nodeElt.selfRemove(); this.searcher.cache = {}; this.searcher.query(this.$searchInput.value); } }; Object.defineProperty(ProjectExplorer.prototype, 'delegate', { set: function (delegate) { if (this._delegate) this._delegate.explorePartner = null; this._delegate = delegate || null; if (this._delegate) { this._delegate.explorePartner = this; this._delegate.attach(this); } }, get: function () { return this._delegate; } }); var _default = ProjectExplorer; /** * * @param {ExpTree} elt * @constructor */ exports.default = _default; function ExpSearcher(elt) { this.elt = elt; this.cache = {}; this.prevHash = null; this.searching = false; this.state = {}; } ExpSearcher.prototype.reset = function () { if (!this.searching) return; this.searching = false; this.elt.removeClass('as-searching'); var visit = treeNode => { treeNode.removeClass('as-in-search-result').removeStyle('order'); if (this.state[treeNode.id]) { treeNode.status = this.state[treeNode.id]; } treeNode.getChildren().forEach(c => visit(c)); }; visit(this.elt); }; ExpSearcher.prototype.backupState = function () { this.state = {}; var visit = treeNode => { if (!treeNode.id) treeNode.id = (0, _stringGenerate.randomIdent)(5); this.state[treeNode.id] = treeNode.status; treeNode.getChildren().forEach(c => visit(c)); }; visit(this.elt); }; ExpSearcher.prototype.query = function (text) { text = text || ''; text = text.trim(); if (text.length === 0) { this.reset(); return; } if (!this.searching) { this.backupState(); this.searching = true; } var newHash = 0; var makeItem = treeNode => { if (!treeNode.id) treeNode.id = (0, _stringGenerate.randomIdent)(5); if (!treeNode.__searchItem__) { treeNode.__searchItem__ = { text: treeNode.name.replace(/[_-]/g, ' '), value: treeNode.id }; (0, _search.default)(treeNode.__searchItem__); } var item = treeNode.__searchItem__; newHash = (0, _stringUtils.stringHashCode)(newHash + item.text); var children = treeNode.getChildren(); if (children.length > 0) { item.items = children.map(c => makeItem(c)); } else { delete item.items; } return item; }; var items = [makeItem(this.elt)]; if (newHash !== this.prevHash) { this.prevHash = newHash; this.cache = {}; } var searchRes = this.cache[text] || (0, _search.searchTreeListByText)(text, items); var dict = searchRes.reduce(function cb(ac, cr, i) { ac[cr.value] = i; if (cr.items) cr.items.reduce(cb, ac); return ac; }, {}); var visit = treeNode => { if (treeNode.id in dict) { treeNode.addClass('as-in-search-result').addStyle('order', dict[treeNode.id]); } else { treeNode.removeClass('as-in-search-result').removeStyle('order'); } treeNode.getChildren().forEach(c => visit(c)); }; visit(this.elt); this.elt.addClass('as-searching'); }; /** * @extends Context * @constructor */ function FMExploreDelegate() { _Context.default.call(this); /** * * @type {null|ProjectExplorer} */ this.explorePartner = null; } _OOP.default.mixClass(FMExploreDelegate, _Context.default); FMExploreDelegate.prototype.redrawExpTree = function () { if (this.explorePartner) this.explorePartner.redrawExpTree(); }; FMExploreDelegate.prototype.getTreeData = function () { return []; }; FMExploreDelegate.prototype.onClickNode = function () {}; FMExploreDelegate.prototype.removeNode = function (any) { if (!this.explorePartner) return; this.explorePartner.removeNode(any); }; FMExploreDelegate.prototype.renameNode = function (any) {}; FMExploreDelegate.prototype.onTreeAction = function (treeData, action, nodeElt) {}; FMExploreDelegate.prototype.getActionContextMenuProps = function (treeData) { return { items: [{ icon: 'span.mdi.mdi-folder-open', text: 'Open', cmd: 'open' }] }; }; /** * * @param any * @param {Context|{}} ac * @param ac */ FMExploreDelegate.prototype.userRenameNode = function (any, ac) { if (!this.explorePartner) return; this.explorePartner.userRenameNode(any, ac); }; FMExploreDelegate.prototype.onUserRenameCompleted = function (ac) {}; FMExploreDelegate.prototype.openItem = function (...args) { var _this$explorePartner; (_this$explorePartner = this.explorePartner).openItem.apply(_this$explorePartner, args); };