Skip to content

Commit

Permalink
add: versioning to module
Browse files Browse the repository at this point in the history
  • Loading branch information
doubleactii committed Dec 13, 2023
1 parent 7085ea0 commit 9b6b341
Show file tree
Hide file tree
Showing 8 changed files with 3,401 additions and 3,127 deletions.
2 changes: 1 addition & 1 deletion dist/pulse.min.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ var __webpack_modules__=[,(e,t,s)=>{s.r(t),s.d(t,{Logger:()=>r});
* @copyright Copyright (c) 2022 Evitca Studio
* @license Logger does not have a license at this time. For licensing contact the author
*/
class r{constructor(e){this.RESET="",this.BRIGHT="",this.DIM="",this.UNDERSCORE="",this.BLINK="",this.REVERSE="",this.HIDDEN="",this.FG_BLACK="",this.FG_RED="",this.FG_GREEN="",this.FG_YELLOW="",this.FG_BLUE="",this.FG_MAGENTA="",this.FG_CYAN="",this.FG_WHITE="",this.FG_GRAY="",this.BG_BLACK="",this.BG_RED="",this.BG_GREEN="",this.BG_YELLOW="",this.BG_BLUE="",this.BG_MAGENTA="",this.BG_CYAN="",this.BG_WHITE="",this.BG_GRAY="",this.TYPE_SPACER_LENGTH=13,this.types={default:this.FG_WHITE},this.currentType="",this.SPACE_CHAR=" ",this.FG_COLORS={};for(let e=0;e<=255;e++)this.FG_COLORS[e]="[38;5;"+e+"m";this.BG_COLORS={};for(let e=0;e<=255;e++)this.BG_COLORS[e]="[48;5;"+e+"m";Array.isArray(e)&&this.registerTypes(e)}prefix(e){return"string"==typeof e&&(this.currentType=e),this}message(e="log",...t){var s,r,o,i=this.currentType||"";0===i.length?console[e](...t):(s=i.length>=this.TYPE_SPACER_LENGTH,o=(r=this.types[i.toLowerCase()]?this.types[i.toLowerCase()]:this.types.default).includes(""),!globalThis.window||o?console[e](r+i+this.SPACE_CHAR.repeat(Math.max(this.TYPE_SPACER_LENGTH-i.length,s?1:0))+"|"+this.RESET,...t):console[e]("%c"+i+this.SPACE_CHAR.repeat(Math.max(this.TYPE_SPACER_LENGTH-i.length,s?1:0))+"|",r,...t)),this.currentType=""}log(...e){this.message("log",...e)}info(...e){this.message("info",...e)}error(...e){this.message("error",...e)}warn(...e){this.message("warn",...e)}assert(...e){console.assert(...e)}debug(...e){this.message("debug",...e)}count(e){console.count(e)}countReset(e){console.countReset(e)}table(e,t){console.table(e,t)}time(e){this.message("time",e)}timeLog(e){this.message("timeLog",e)}timeEnd(e){this.message("timeEnd",e)}trace(...e){this.message("trace",...e)}group(e){this.message("group",e)}groupCollapsed(e){console.groupCollapsed(e)}groupEnd(){console.groupEnd()}clear(){console.clear()}registerType(e,t){this.types[e]||"string"==typeof e&&"string"==typeof t&&(this.types[e.toLowerCase()]=t)}registerTypes(t){if(Array.isArray(t))for(let e=0;e<t.length;e++)this.registerType(t[e].type,t[e].ansi)}unregisterType(e){this.types[e]&&delete this.types[e]}}}],__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];return void 0!==t||(t=__webpack_module_cache__[e]={exports:{}},__webpack_modules__[e](t,t.exports,__webpack_require__)),t.exports}__webpack_require__.d=(e,t)=>{for(var s in t)__webpack_require__.o(t,s)&&!__webpack_require__.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={},__webpack_exports__Pulse=((()=>{__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{Pulse:()=>t});var e=__webpack_require__(1);class o{static tracker={ids:[]};static storedIDs=[];constructor(){this.logger=new e.Logger,this.logger.registerType("PulseComponent-Module",this.logger.FG_BLUE),this.logger.prefix("PulseComponent-Module").log("PulseComponent module loaded")}generateID(s=7){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function e(){let t="";for(let e=0;e<s;e++)t+=r.charAt(Math.floor(Math.random()*r.length));return t}let t=e();for(;o.storedIDs.includes(t);)t=e();return o.storedIDs.push(t),t}on(e,t,s){var r;"function"!=typeof s?this.logger.prefix("PulseComponent-Module").error("pFunction argument is missing or it is not of the function type!"):(e.pulseComponentListenerID||(r=this.generateID(),e.pulseComponentListenerID=r,o.tracker.ids.push(r),o.tracker[e.pulseComponentListenerID]={},o.tracker[e.pulseComponentListenerID].listened={}),o.tracker[e.pulseComponentListenerID][t]||(o.tracker[e.pulseComponentListenerID][t]={counter:0}),r=++o.tracker[e.pulseComponentListenerID][t].counter,o.tracker[e.pulseComponentListenerID].listened[t]||this.listenForEvent(e,t),o.tracker[e.pulseComponentListenerID][t][r]=s,"onNew"===t&&o.tracker[e.pulseComponentListenerID][t][r].bind(e)())}off(e,t,s){if("function"!=typeof s)this.logger.prefix("PulseComponent-Module").error("pFunction argument is missing or it is not of the function type!");else{for(const r in o.tracker[e.pulseComponentListenerID][t])if(o.tracker[e.pulseComponentListenerID][t][r]===s)return void delete o.tracker[e.pulseComponentListenerID][t][r];this.logger.prefix("PulseComponent-Module").error("This function is not being tracked.")}}listenForEvent(t,s){let r=t[s];t[s]=function(){"function"==typeof r&&r.apply(t,arguments);for(const e in o.tracker[t.pulseComponentListenerID][s])"function"==typeof o.tracker[t.pulseComponentListenerID][s][e]&&o.tracker[t.pulseComponentListenerID][s][e].apply(t,arguments)},o.tracker[t.pulseComponentListenerID].listened[s]=!0}}const t=new o})(),__webpack_exports__.Pulse);export{__webpack_exports__Pulse as Pulse};
class r{constructor(e){this.RESET="",this.BRIGHT="",this.DIM="",this.UNDERSCORE="",this.BLINK="",this.REVERSE="",this.HIDDEN="",this.FG_BLACK="",this.FG_RED="",this.FG_GREEN="",this.FG_YELLOW="",this.FG_BLUE="",this.FG_MAGENTA="",this.FG_CYAN="",this.FG_WHITE="",this.FG_GRAY="",this.BG_BLACK="",this.BG_RED="",this.BG_GREEN="",this.BG_YELLOW="",this.BG_BLUE="",this.BG_MAGENTA="",this.BG_CYAN="",this.BG_WHITE="",this.BG_GRAY="",this.TYPE_SPACER_LENGTH=13,this.types={default:this.FG_WHITE},this.currentType="",this.SPACE_CHAR=" ",this.FG_COLORS={};for(let e=0;e<=255;e++)this.FG_COLORS[e]="[38;5;"+e+"m";this.BG_COLORS={};for(let e=0;e<=255;e++)this.BG_COLORS[e]="[48;5;"+e+"m";Array.isArray(e)&&this.registerTypes(e)}prefix(e){return"string"==typeof e&&(this.currentType=e),this}message(e="log",...t){var s,r,o,i=this.currentType||"";0===i.length?console[e](...t):(s=i.length>=this.TYPE_SPACER_LENGTH,o=(r=this.types[i.toLowerCase()]?this.types[i.toLowerCase()]:this.types.default).includes(""),!globalThis.window||o?console[e](r+i+this.SPACE_CHAR.repeat(Math.max(this.TYPE_SPACER_LENGTH-i.length,s?1:0))+"|"+this.RESET,...t):console[e]("%c"+i+this.SPACE_CHAR.repeat(Math.max(this.TYPE_SPACER_LENGTH-i.length,s?1:0))+"|",r,...t)),this.currentType=""}log(...e){this.message("log",...e)}info(...e){this.message("info",...e)}error(...e){this.message("error",...e)}warn(...e){this.message("warn",...e)}assert(...e){console.assert(...e)}debug(...e){this.message("debug",...e)}count(e){console.count(e)}countReset(e){console.countReset(e)}table(e,t){console.table(e,t)}time(e){this.message("time",e)}timeLog(e){this.message("timeLog",e)}timeEnd(e){this.message("timeEnd",e)}trace(...e){this.message("trace",...e)}group(e){this.message("group",e)}groupCollapsed(e){console.groupCollapsed(e)}groupEnd(){console.groupEnd()}clear(){console.clear()}registerType(e,t){this.types[e]||"string"==typeof e&&"string"==typeof t&&(this.types[e.toLowerCase()]=t)}registerTypes(t){if(Array.isArray(t))for(let e=0;e<t.length;e++)this.registerType(t[e].type,t[e].ansi)}unregisterType(e){this.types[e]&&delete this.types[e]}}}],__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];return void 0!==t||(t=__webpack_module_cache__[e]={exports:{}},__webpack_modules__[e](t,t.exports,__webpack_require__)),t.exports}__webpack_require__.d=(e,t)=>{for(var s in t)__webpack_require__.o(t,s)&&!__webpack_require__.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={},__webpack_exports__Pulse=((()=>{__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{Pulse:()=>t});var e=__webpack_require__(1);class o{static tracker={ids:[]};static storedIDs=[];constructor(){this.logger=new e.Logger,this.logger.registerType("PulseComponent-Module",this.logger.FG_MAGENTA),this.logger.prefix("PulseComponent-Module").log("✅@v1.0.0")}generateID(s=7){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function e(){let t="";for(let e=0;e<s;e++)t+=r.charAt(Math.floor(Math.random()*r.length));return t}let t=e();for(;o.storedIDs.includes(t);)t=e();return o.storedIDs.push(t),t}on(e,t,s){var r;"function"!=typeof s?this.logger.prefix("PulseComponent-Module").error("pFunction argument is missing or it is not of the function type!"):(e.pulseComponentListenerID||(r=this.generateID(),e.pulseComponentListenerID=r,o.tracker.ids.push(r),o.tracker[e.pulseComponentListenerID]={},o.tracker[e.pulseComponentListenerID].listened={}),o.tracker[e.pulseComponentListenerID][t]||(o.tracker[e.pulseComponentListenerID][t]={counter:0}),r=++o.tracker[e.pulseComponentListenerID][t].counter,o.tracker[e.pulseComponentListenerID].listened[t]||this.listenForEvent(e,t),o.tracker[e.pulseComponentListenerID][t][r]=s,"onNew"===t&&o.tracker[e.pulseComponentListenerID][t][r].bind(e)())}off(e,t,s){if("function"!=typeof s)this.logger.prefix("PulseComponent-Module").error("pFunction argument is missing or it is not of the function type!");else{for(const r in o.tracker[e.pulseComponentListenerID][t])if(o.tracker[e.pulseComponentListenerID][t][r]===s)return void delete o.tracker[e.pulseComponentListenerID][t][r];this.logger.prefix("PulseComponent-Module").error("This function is not being tracked.")}}listenForEvent(t,s){let r=t[s];t[s]=function(){"function"==typeof r&&r.apply(t,arguments);for(const e in o.tracker[t.pulseComponentListenerID][s])"function"==typeof o.tracker[t.pulseComponentListenerID][s][e]&&o.tracker[t.pulseComponentListenerID][s][e].apply(t,arguments)},o.tracker[t.pulseComponentListenerID].listened[s]=!0}}const t=new o})(),__webpack_exports__.Pulse);export{__webpack_exports__Pulse as Pulse};
Loading

0 comments on commit 9b6b341

Please sign in to comment.