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__AppPattern__Context.js
/*** module: node_modules/absol/src/AppPattern/Context.js ***/
"use strict";

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

var _noop = _interopRequireDefault(require("../Code/noop"));


function Context() {
  /****
   *
   * @type {"CREATE"|"PAUSE"|"RUNNING"|"STANDBY"|"DIE"|"STOP"}
   */
  this.state = "CREATE";
  /**
   * @type {Context}
   */

  this.parent = null;
  /***
   *
   * @type {null|ContextManager}
   */

  this.ctxMng = null;
}
/**
 * @returns {*}
 */


Context.prototype.getContext = function (key) {
  var ctx = this;
  var res;

  while (ctx && !res) {
    if (ctx.ctxMng) {
      res = ctx.ctxMng.get(key);
    }

    ctx = ctx.parent;
  }

  return res;
};
/**
 * @param {string} key
 * @param {*} value
 * @returns {*}
 */


Context.prototype.setContext = function (key, value) {
  return this.getContextManager().set(key, value);
};
/**
 * @returns {ContextManager}
 */


Context.prototype.getContextManager = function () {
  var ctx = this;
  var res;

  while (ctx && !res) {
    if (ctx.ctxMng) {
      res = ctx.ctxMng;
    }

    ctx = ctx.parent;
  }

  return res;
};
/**
 * @param {Context} parent
 */


Context.prototype.attach = function (parent) {
  //stop before attach to new context
  this.stop();
  /**
   * @type {Application}
   */

  this.parent = parent;
  this.onAttached && this.onAttached();
};

Context.prototype.detach = function () {
  this.stop();
  this.onDetached && this.onDetached();
  this.parent = null;
};

Context.prototype.pause = function () {
  if (this.state.match(/RUNNING|PAUSE/)) {
    if (this.state === "RUNNING") {
      this.state = "PAUSE";
      this.onPause && this.onPause();
    }
  } else {// console.warn(this, "NOT RUNNING");
  }
};

Context.prototype.resume = function () {
  if (!this.state.match(/STANDBY|PAUSE|RUNNING/)) {
    // console.warn(this, 'NOT READY!', this.state);
    return;
  }

  if (this.state === "RUNNING") return;
  this.state = "RUNNING";
  this.onResume && this.onResume();
};
/***
 * @param {boolean=} standBy start but waiting for resume()
 */


Context.prototype.start = function (standBy) {
  if (this.state.match(/DIE/)) {
    // console.warn(this, 'DIED!');
    return;
  }

  if (this.state.match(/RUNNING/)) return;

  if (this.state.match(/STOP|CREATE/)) {
    this.state = "STANDBY";
    this.onStart && this.onStart();
  }

  if (!standBy && this.state.match(/STANDBY|PAUSE/)) {
    this.resume();
  }
};

Context.prototype.stop = function () {
  if (this.state.match(/STOP|DIE|CREATE/)) return;
  if (this.state.match(/RUNNING/)) this.pause();
  this.state = "STOP";
  this.onStop && this.onStop();
};

Context.prototype.destroy = function () {
  if (this.state.match(/DIE/)) return;
  if (this.state.match(/RUNNING|PAUSE/)) this.stop();
  this.state = "DIE";
  this.onDestroy && this.onDestroy();
};

Context.prototype.onDestroy = _noop.default;
Context.prototype.onStop = _noop.default;
Context.prototype.onStart = _noop.default;
Context.prototype.onResume = _noop.default;
Context.prototype.onPause = _noop.default;
Context.prototype.onDetached = _noop.default;
Context.prototype.onAttached = _noop.default;
var _default = Context;
exports.default = _default;

VaKeR 2022