"use strict"; import {FilesDriver} from "../Drivers/FilesDriver.ecma.js"; import {PrintTypesManager} from "../Managers/PrintTypesManager.ecma.js"; import {SettingsManager} from "../Managers/SettingsManager.ecma.js"; import {I18NManager} from "../Managers/I18NManager.ecma.js"; import {ThreadsManager} from "../Managers/ThreadsManager.ecma.js"; import {UniqueKeysManager} from "../Managers/UniqueKeysManager.ecma.js"; import {SessionsManager} from "../Managers/SessionsManager.ecma.js"; import {ModelsManager} from "../Managers/ModelsManager.ecma.js"; import {ViewsManager} from "../Managers/ViewsManager.ecma.js"; import {RoutesManager} from "../Managers/RoutesManager.ecma.js"; import {Components} from "./Components.ecma.js"; import {Common} from "../Utils/Common.ecma.js"; import {Check} from "../Utils/Checks.ecma.js"; /** * @class AnP * @constructor * @param {?(Object.|Array)} [inputs = null] * @param {?simple_callback} [callback = null] * @returns {void} * @access private * @static */ export const AnP = (function(){ /** * @callback simple_callback * @returns {void} */ /** * @callback continue_callback * @param {!boolean} ok * @return {boolean} */ /** * @constructs AnP * @param {?(Object.|Array)} [inputs = null] * @param {?simple_callback} [callback = null] * @returns {void} * @access private * @static */ const AnP = function(inputs = null, callback = null){ /** @type {AnP} */ const self = this; /** @type {boolean} */ let started = false; /** @type {FilesDriver} */ this.files = new FilesDriver(self); /** @type {PrintTypesManager} */ this.print_types = new PrintTypesManager(self); /** @type {SettingsManager} */ this.settings = new SettingsManager(self, inputs); /** @type {I18NManager} */ this.i18n = new I18NManager(self); /** @type {ThreadsManager} */ this.threads = new ThreadsManager(self); /** @type {UniqueKeysManager} */ this.unique_keys = new UniqueKeysManager(self); /** @type {SessionsManager} */ this.sessions = new SessionsManager(self); /** @type {ModelsManager} */ this.models = new ModelsManager(self); /** @type {Components} */ this.components = new Components(self); /** @type {ViewsManager} */ this.views = new ViewsManager(self); /** @type {RoutesManager} */ this.routes = new RoutesManager(self); /** * @returns {void} * @access private */ const constructor = () => { self.settings.get("autostart", null, true) && self.start(callback); }; /** * @param {?continue_callback} callback * @returns {boolean} * @access public */ this.update = (callback = null) => { Common.execute_array([ "files", "settings", "print_types", "i18n", "threads", "models", "views", "routes" ], (key, next) => { self[key].update(next); }, callback, true); }; /** * @param {?continue_callback} callback * @returns {boolean} * @access public */ this.reset = (callback = null) => { Common.execute_array([ "files", "settings", "print_types", "i18n", "threads", "models", "views", "routes" ], (key, next) => { self[key].reset(next); }, callback, true); }; /** * @param {?continue_callback} callback * @returns {boolean} * @access public */ this.start = (callback = null) => { /** @type {continue_callback} */ const end = ok => Common.execute(callback, ok); if(started){ end(false); return false; }; started = true; self.update(ok => { if(ok !== false && self.settings.get("build_base_gui")){ Common.preload(self.settings.get("position"), (position, asynchronous, ok) => { if(position){ Common.HTML(position, self.components.base.build()); end(true); }else end(false); }); }else end(ok); }); return true; }; /** * @param {?continue_callback} callback * @returns {boolean} * @access public */ this.close = (callback = null) => { /** @type {continue_callback} */ const end = ok => Common.execute(callback, ok); if(!started){ end(false); return false; }; started = false; end(true); return true; }; /** * @param {!string} type * @param {!(string|Array.)} message * @param {?(Object.|Array)} [inputs = null] * @param {!number} [i = 0] * @return {void} * @access public */ this.print = (type, message, inputs = null, i = 0) => {}; /** * @param {!Error} exception * @param {!(string|Array.)} message * @param {?(Object.|Array)} [inputs = null] * @param {!number} [i = 0] * @return {void} * @access public */ this.exception = (exception, message, inputs = null, i = 0) => {}; constructor(); }; return AnP; })();