diff --git a/v2/Gruntfile.js b/v2/Gruntfile.js index e8a09c3..0120ada 100644 --- a/v2/Gruntfile.js +++ b/v2/Gruntfile.js @@ -9,7 +9,11 @@ module.exports = grunt => { options: { include: ['src/js/core'], out: 'intermediate/requirejs.js', - optimize: 'none' + optimize: 'none', + paths: { + 'events': 'empty:', + 'electron': 'empty:' + } } } }, diff --git a/v2/dist/js/main.js b/v2/dist/js/main.js index 36ed707..a9f5b8e 100644 --- a/v2/dist/js/main.js +++ b/v2/dist/js/main.js @@ -3,7 +3,7 @@ "use strict"; var electron = require("electron"); - var src_js_modules_modules, src_js_utils, src_js_api, src_js_core; + var src_js_modules_modules, src_js_utils, src_js_api, src_js_event, src_js_core; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { @@ -44,12 +44,39 @@ }; return new Api(); }(); - src_js_core = function (modules, utils, api) { + src_js_event = function () { + var eventEmitter = new require('events').EventEmitter; + var event = function () { + function event() { + _classCallCheck(this, event); + } + _createClass(event, [ + { + key: 'on', + value: function on(eventName, callback) { + eventEmitter.on(eventName, callback); + } + }, + { + key: 'emit', + value: function emit() { + return 'Not allowed'; + } + } + ]); + return event; + }(); + return new event(); + }(); + src_js_core = function (modules, utils, api, plugin, event) { var Core = function () { function Core(args) { _classCallCheck(this, Core); this.beta = true; this.alpha = true; + this.plugin = plugin; + this.event = event; + this.eventEmitter = event.eventEmitter; } _createClass(Core, [ { @@ -76,8 +103,8 @@ window.$B = function (s) { return $('[data-bd=' + s); }; - window.BD = new Core(); - window.BD.init(); - }(src_js_modules_modules, src_js_utils, src_js_api); + var BD = new Core(); + BD.init(); + }(src_js_modules_modules, src_js_utils, src_js_api, src_js_event); }()); \ No newline at end of file diff --git a/v2/lib/core.js b/v2/lib/core.js index 5191758..aa24aad 100644 --- a/v2/lib/core.js +++ b/v2/lib/core.js @@ -82,8 +82,14 @@ class Core { domReady() { for(var key in _resources) { var resource = _resources[key]; - _utils.requireJs(`${_cfg.dataPath}/${resource.path}/${resource.filename}`, resource.var, _self.mainWindow); + _utils.requireJs(`${_cfg.installPath}/${resource.path}/${resource.filename}`, resource.var, _self.mainWindow); } + + _self.pluginLoader(); + } + + pluginLoader() { + } exit(reason, severity) { diff --git a/v2/src/js/core.js b/v2/src/js/core.js index 56523f9..55ab403 100644 --- a/v2/src/js/core.js +++ b/v2/src/js/core.js @@ -12,14 +12,18 @@ define([ "./modules/modules", "./utils", - "./api" -], (modules, utils, api) => { + "./api", + "./event" +], (modules, utils, api, plugin, event) => { class Core { constructor(args) { this.beta = true; this.alpha = true; + this.plugin = plugin; + this.event = event; + this.eventEmitter = event.eventEmitter; } init() { @@ -37,8 +41,8 @@ define([ } window.$B = s => { return $(`[data-bd=${s}`); }; - window.BD = new Core(); - window.BD.init(); + const BD = new Core(); + BD.init(); }); \ No newline at end of file diff --git a/v2/src/js/event.js b/v2/src/js/event.js new file mode 100644 index 0000000..c67a6af --- /dev/null +++ b/v2/src/js/event.js @@ -0,0 +1,29 @@ +/* BetterDiscordApp Event emitter + * Version: 2:1.0 + * Author: Jiiks | https://jiiks.net + * Date: 31/10/2016 + * Last Update: 31/10/2016 + * Github: https://github.com/Jiiks/BetterDiscordApp + * Git: https://github.com/Jiiks/BetterDiscordApp.git + * License: MIT + */ + + +define(() => { + + const eventEmitter = new require('events').EventEmitter; + + class event { + + on(eventName, callback) { + eventEmitter.on(eventName, callback); + } + + emit() { + return "Not allowed"; + } + + } + + return new event(); +}); \ No newline at end of file diff --git a/v2/src/js/plugin.js b/v2/src/js/plugin.js new file mode 100644 index 0000000..b88fb16 --- /dev/null +++ b/v2/src/js/plugin.js @@ -0,0 +1,33 @@ +/* BetterDiscordApp Plugin base class + * Version: 2:1.0 + * Author: Jiiks | https://jiiks.net + * Date: 31/10/2016 + * Last Update: 31/10/2016 + * Github: https://github.com/Jiiks/BetterDiscordApp + * Git: https://github.com/Jiiks/BetterDiscordApp.git + * License: MIT + */ + + +define(() => { + + class Plugin { + + constructor(args) { + this.author = args.author; + this.version = args.version; + } + + get author() { + return this.author; + } + + get version() { + return this.version; + } + + } + + return Plugin; + +}); \ No newline at end of file