event and plugin bases

This commit is contained in:
Jiiks 2016-11-01 05:42:15 +02:00
parent 1a7d84a14c
commit 6d58d8f2f8
6 changed files with 114 additions and 11 deletions

View File

@ -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:'
}
}
}
},

37
v2/dist/js/main.js vendored
View File

@ -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);
}());

View File

@ -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) {

View File

@ -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();
});

29
v2/src/js/event.js Normal file
View File

@ -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();
});

33
v2/src/js/plugin.js Normal file
View File

@ -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;
});