Client side skeleton and grunt config for js

This commit is contained in:
Jiiks 2016-10-31 19:20:34 +02:00
parent 9416be4105
commit 3eea2eacc3
8 changed files with 292 additions and 0 deletions

5
v2/.babelrc Normal file
View File

@ -0,0 +1,5 @@
{
plugins: ["transform-remove-strict-mode"],
presets: ["es2015"],
sourceMap: false
}

91
v2/Gruntfile.js Normal file
View File

@ -0,0 +1,91 @@
module.exports = grunt => {
'use strict';
require('load-grunt-tasks')(grunt);
grunt.initConfig({
requirejs: {
compileProject: {
options: {
include: ['src/js/core'],
out: 'intermediate/requirejs.js',
optimize: 'none'
}
}
},
babel: {
dist: {
files: [{
src: ['intermediate/requirejs.js'],
dest: 'intermediate/babel.js'
}]
}
},
replace: {
dist: {
options: {
patterns: [{
match: /\\n +/g,
replacement: ''
},{
match: / +/g,
replacement: ' '
},{
match: /\/*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g,
replacement: ''
}]
},
files: [{
expand: true, src: ['intermediate/babel.js'], dest: ''
}]
},
nongreedy: {
options: {
patterns: [{
match: /\\n +/g,
replacement: ''
},{
match: / +/g,
replacement: ' '
},{
match: /\/\*(.|[\r\n])*?\*\//g,
replacement: ''
}]
},
files: [{
expand: true, src: ['intermediate/babel.js'], dest: ''
}]
}
},
amdclean: {
options: {
wrap: {
start: '(function() {\n\n "use strict";\n\n var electron = require("electron");\n',
end: '\n\n}());'
},
escodegen: {
format: {
indent: {
style: ' ',
base: 1
}
}
},
aggressiveOptimizations: true,
transformAMDChecks: false
},
dist: {
src: 'intermediate/babel.js',
dest: 'dist/js/main.js'
}
},
clean: [
'intermediate'
]
});
grunt.registerTask("fastjs", ["requirejs", "babel", "replace:nongreedy", "amdclean", "clean" ]);
grunt.registerTask("default", [ "requirejs", "babel", "replace", "amdclean", "clean" ]);
};

83
v2/dist/js/main.js vendored Normal file
View File

@ -0,0 +1,83 @@
(function() {
"use strict";
var electron = require("electron");
var src_js_modules_modules, src_js_utils, src_js_api, src_js_core;
var _createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor)
descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps)
defineProperties(Constructor.prototype, protoProps);
if (staticProps)
defineProperties(Constructor, staticProps);
return Constructor;
};
}();
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
src_js_modules_modules = function () {
var modules = {};
return modules;
}();
src_js_utils = function () {
var Utils = function Utils() {
_classCallCheck(this, Utils);
};
return new Utils();
}();
src_js_api = function () {
var Api = function Api() {
_classCallCheck(this, Api);
};
return new Api();
}();
src_js_core = function (modules, utils, api) {
var Core = function () {
function Core(args) {
_classCallCheck(this, Core);
this.beta = true;
this.alpha = true;
}
_createClass(Core, [
{
key: 'init',
value: function init() {
console.log('Initialized');
}
},
{
key: '__version',
get: function get() {
return '2.0.0';
}
},
{
key: '__versionString',
get: function get() {
return '' + this.__version + (this.alpha ? 'A' : this.beta ? 'B' : '');
}
}
]);
return Core;
}();
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);
}());

View File

@ -6,5 +6,18 @@
"license": "MIT", "license": "MIT",
"main": "lib/main.js", "main": "lib/main.js",
"devDependencies": { "devDependencies": {
"grunt": "^0.4.5",
"load-grunt-tasks": "^3.5.0",
"grunt-requirejs": "^0.4.2",
"grunt-amdclean": "^0.1.2",
"grunt-babel": "^6.0.0",
"babel-preset-es2015": "^6.9.0",
"babel-plugin-transform-remove-strict-mode": "^0.0.2",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-sass": "^1.0.0",
"grunt-contrib-uglify": "^1.0.1",
"grunt-contrib-cssmin": "^1.0.1",
"grunt-contrib-clean": "^1.0.0",
"grunt-replace": "^1.0.1"
} }
} }

20
v2/src/js/api.js Normal file
View File

@ -0,0 +1,20 @@
/* BetterDiscordApp Client Api
* 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 Api {
}
return new Api();
});

44
v2/src/js/core.js Normal file
View File

@ -0,0 +1,44 @@
/* BetterDiscordApp Client Core
* 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([
"./modules/modules",
"./utils",
"./api"
], (modules, utils, api) => {
class Core {
constructor(args) {
this.beta = true;
this.alpha = true;
}
init() {
console.log("Initialized");
}
get __version() {
return "2.0.0";
}
get __versionString() {
return `${this.__version}${this.alpha ? "A" : this.beta ? "B" : ""}`;
}
}
window.$B = s => { return $(`[data-bd=${s}`); };
window.BD = new Core();
window.BD.init();
});

View File

@ -0,0 +1,16 @@
/* BetterDiscordApp Client Module Defines
* 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([], () => {
var modules = {};
return modules;
});

20
v2/src/js/utils.js Normal file
View File

@ -0,0 +1,20 @@
/* BetterDiscordApp Client Utilities
* 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 Utils {
}
return new Utils();
});