From 994faf94d6cbbed0fe1deb94a0aaad0612b5173a Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Tue, 20 Mar 2018 21:11:11 +0000 Subject: [PATCH 01/23] Refactor Vue injector and sparkplug and move contributors to data --- client/package.json | 3 - client/src/builtin/EmoteComponent.vue | 5 +- client/src/builtin/EmoteModule.js | 11 ++-- client/src/data/contributors.json | 65 +++++++++++++++++++ client/src/data/user.settings.default.json | 1 - client/src/index.js | 40 +++++------- client/src/modules/globals.js | 57 +++++++++++----- client/src/modules/modulemanager.js | 8 ++- client/src/modules/modules.js | 22 ++++--- client/src/ui/automanip.js | 24 +++---- client/src/ui/components/bd/BdBadge.vue | 8 +-- .../src/ui/components/bd/BdMessageBadge.vue | 6 +- .../src/ui/components/common/Autocomplete.vue | 3 +- client/src/ui/profilebadges.js | 56 ++++++---------- client/src/ui/vueinjector.js | 13 +++- client/webpack.config.js | 7 +- core/src/sparkplug.js | 26 ++++++-- 17 files changed, 219 insertions(+), 136 deletions(-) create mode 100644 client/src/data/contributors.json diff --git a/client/package.json b/client/package.json index 6e536f09..aee1ddf3 100644 --- a/client/package.json +++ b/client/package.json @@ -15,9 +15,6 @@ "url": "https://github.com/Jiiks/BetterDiscordApp.git" }, "private": false, - "devDependencies": { - - }, "scripts": { "build": "webpack --progress --colors", "watch": "webpack --progress --colors --watch" diff --git a/client/src/builtin/EmoteComponent.vue b/client/src/builtin/EmoteComponent.vue index 3561ad70..98cd63a1 100644 --- a/client/src/builtin/EmoteComponent.vue +++ b/client/src/builtin/EmoteComponent.vue @@ -9,11 +9,10 @@ data() { return { favourite: false - } + }; }, props: ['src', 'name'], - methods: { - }, + methods: {}, beforeMount() { // Check favourite state } diff --git a/client/src/builtin/EmoteModule.js b/client/src/builtin/EmoteModule.js index 0a02c41a..7c901607 100644 --- a/client/src/builtin/EmoteModule.js +++ b/client/src/builtin/EmoteModule.js @@ -131,12 +131,11 @@ export default class { } const { bdemoteName, bdemoteSrc } = root.dataset; if (!bdemoteName || !bdemoteSrc) return; - VueInjector.inject( - root, - DOM.createElement('span'), - { EmoteComponent }, - `` - ); + VueInjector.inject(root, { + components: { EmoteComponent }, + data: { src: bdemoteSrc, name: bdemoteName }, + template: '' + }, DOM.createElement('span')); root.classList.add('bd-is-emote'); } diff --git a/client/src/data/contributors.json b/client/src/data/contributors.json new file mode 100644 index 00000000..bcdd89ec --- /dev/null +++ b/client/src/data/contributors.json @@ -0,0 +1,65 @@ +[ + { + "__user": "Jiiks#5000", + "id": "81388395867156480", + "developer": true, + "webdev": true, + "contributor": true + }, + { + "__user": "Pohky#0156", + "id": "98003542823944192", + "developer": true, + "webdev": false, + "contributor": true + }, + { + "__user": "Hammock#3110", + "id": "138850472541814784", + "developer": false, + "webdev": true, + "contributor": true + }, + { + "__user": "Zerebos#7790", + "id": "249746236008169473", + "developer": true, + "webdev": false, + "contributor": true + }, + { + "__user": "Pierce#1337", + "id": "125367412370440192", + "developer": true, + "webdev": false, + "contributor": true + }, + { + "__user": "Samuel Elliott#2764", + "id": "284056145272766465", + "developer": true, + "webdev": false, + "contributor": true + }, + { + "__user": "Lilian Tedone#6223", + "id": "184021060562321419", + "developer": false, + "webdev": false, + "contributor": true + }, + { + "__user": "samfun123#8972", + "id": "76052829285916672", + "developer": false, + "webdev": false, + "contributor": true + }, + { + "__user": "samogot#4379", + "id": "171005991272316937", + "developer": false, + "webdev": false, + "contributor": true + } +] diff --git a/client/src/data/user.settings.default.json b/client/src/data/user.settings.default.json index 49efdfdc..2b49c23a 100644 --- a/client/src/data/user.settings.default.json +++ b/client/src/data/user.settings.default.json @@ -91,7 +91,6 @@ { "id": "css", "text": "CSS Editor", - "hidden": true, "settings": [ { "category": "default", diff --git a/client/src/index.js b/client/src/index.js index 94307dc5..f7a74b6e 100644 --- a/client/src/index.js +++ b/client/src/index.js @@ -10,9 +10,10 @@ import { DOM, BdUI, Modals, Reflection } from 'ui'; import BdCss from './styles/index.scss'; -import { Patcher, MonkeyPatch, Vendor, Events, CssEditor, Globals, ExtModuleManager, PluginManager, ThemeManager, ModuleManager, WebpackModules, Settings, Database, ReactComponents, ReactAutoPatcher, DiscordApi } from 'modules'; +import { Events, CssEditor, Globals, Settings, Database, Updater, ModuleManager, PluginManager, ThemeManager, ExtModuleManager, Vendor, WebpackModules, Patcher, MonkeyPatch, ReactComponents, ReactAutoPatcher, DiscordApi } from 'modules'; import { ClientLogger as Logger, ClientIPC, Utils } from 'common'; import { EmoteModule } from 'builtin'; + const ignoreExternal = false; const DEV = true; @@ -20,29 +21,16 @@ class BetterDiscord { constructor() { this._bd = { - DOM, - BdUI, - Modals, - Reflection, - Patcher, - MonkeyPatch, + DOM, BdUI, Modals, Reflection, + + Events, CssEditor, Globals, Settings, Database, Updater, + ModuleManager, PluginManager, ThemeManager, ExtModuleManager, Vendor, - Events, - CssEditor, - Globals, - ExtModuleManager, - PluginManager, - ThemeManager, - ModuleManager, - WebpackModules, - Settings, - Database, - ReactComponents, - DiscordApi, - Logger, - ClientIPC, - Utils, - EmoteModule + + WebpackModules, Patcher, MonkeyPatch, ReactComponents, DiscordApi, + EmoteModule, + + Logger, ClientIPC, Utils }; const developermode = Settings.getSetting('core', 'advanced', 'developer-mode'); @@ -63,14 +51,16 @@ class BetterDiscord { await Database.init(); await Settings.loadSettings(); await ModuleManager.initModules(); - Modals.showContentManagerErrors(); + if (!ignoreExternal) { await ExtModuleManager.loadAllModules(true); await PluginManager.loadAllPlugins(true); await ThemeManager.loadAllThemes(true); } + if (!Settings.get('core', 'advanced', 'ignore-content-manager-errors')) Modals.showContentManagerErrors(); + Events.emit('ready'); Events.emit('discord-ready'); EmoteModule.observe(); @@ -90,7 +80,7 @@ class BetterDiscord { if (window.BetterDiscord) { Logger.log('main', 'Attempting to inject again?'); } else { - let instance = null; + let instance; Events.on('autopatcher', () => instance = new BetterDiscord()); ReactAutoPatcher.autoPatch().then(() => Events.emit('autopatcher')); } diff --git a/client/src/modules/globals.js b/client/src/modules/globals.js index 50b3dbb8..4971ec2a 100644 --- a/client/src/modules/globals.js +++ b/client/src/modules/globals.js @@ -8,9 +8,10 @@ * LICENSE file in the root directory of this source tree. */ +import sparkplug from 'sparkplug'; +import { ClientIPC } from 'bdipc'; import Module from './module'; import Events from './events'; -import { ClientIPC } from 'bdipc'; export default new class extends Module { @@ -31,20 +32,18 @@ export default new class extends Module { first() { (async() => { const config = await ClientIPC.send('getConfig'); - this.setState(config); + this.setState({ config }); // This is for Discord to stop error reporting :3 window.BetterDiscord = { - 'version': config.version, - 'v': config.version + version: config.version, + v: config.version }; window.jQuery = {}; - if (window.__bd) { - this.setState(window.__bd); - window.__bd = { - setWS: this.setWS - } + if (sparkplug.bd) { + this.setState({ bd: sparkplug.bd }); + sparkplug.bd.setWS = this.setWS; } Events.emit('global-ready'); @@ -60,19 +59,43 @@ export default new class extends Module { } getObject(name) { - return this.state[name]; + return this.config[name] || this.bd[name]; + } + + get bd() { + return this.state.bd; + } + + get localStorage() { + return this.bd.localStorage; + } + + get webSocket() { + return this.bd.wsHook; + } + + get WebSocket() { + return this.bd.wsOrig; + } + + get ignited() { + return this.bd.ignited; + } + + get config() { + return this.state.config; + } + + get paths() { + return this.config.paths; } getPath(id) { - return this.state.paths.find(path => path.id === id).path; + return this.paths.find(path => path.id === id).path; } - static get paths() { - return this.state.paths; - } - - static get version() { - return this.state.version; + get version() { + return this.config.version; } } diff --git a/client/src/modules/modulemanager.js b/client/src/modules/modulemanager.js index 209f32bf..c1f69d51 100644 --- a/client/src/modules/modulemanager.js +++ b/client/src/modules/modulemanager.js @@ -8,12 +8,14 @@ * LICENSE file in the root directory of this source tree. */ -/*Module Manager initializes all modules when everything is ready*/ - +import { ClientLogger as Logger } from 'common'; import { Events, SocketProxy, EventHook, CssEditor } from 'modules'; import { ProfileBadges } from 'ui'; import Updater from './updater'; +/** + * Module Manager initializes all modules when everything is ready + */ export default class { static get modules() { @@ -31,7 +33,7 @@ export default class { try { if (module.init && module.init instanceof Function) module.init(); } catch (err) { - console.log(`Failed to initialize module: ${err}`); + Logger.err('Module Manager', ['Failed to initialize module:', err]); } } return true; diff --git a/client/src/modules/modules.js b/client/src/modules/modules.js index 8bd1b7eb..f885fcdb 100644 --- a/client/src/modules/modules.js +++ b/client/src/modules/modules.js @@ -1,19 +1,23 @@ export { default as Events } from './events'; -export { default as Settings } from './settings'; export { default as CssEditor } from './csseditor'; -export { default as ExtModuleManager } from './extmodulemanager'; +export { default as Globals } from './globals'; +export { default as Settings } from './settings'; +export { default as Database } from './database'; +export { default as Updater } from './updater'; + +export { default as ModuleManager } from './modulemanager'; export { default as PluginManager } from './pluginmanager'; export { default as ThemeManager } from './thememanager'; -export { default as Globals } from './globals'; +export { default as ExtModuleManager } from './extmodulemanager'; +export { default as Permissions } from './permissionmanager'; + +export { default as EventsWrapper } from './eventswrapper'; export { default as Vendor } from './vendor'; + export * from './webpackmodules'; -export { default as ModuleManager } from './modulemanager'; +export * from './patcher'; +export * from './reactcomponents'; export { default as EventListener } from './eventlistener'; export { default as SocketProxy } from './socketproxy'; export { default as EventHook } from './eventhook'; -export { default as Permissions } from './permissionmanager'; -export { default as Database } from './database'; -export { default as EventsWrapper } from './eventswrapper'; export { default as DiscordApi } from './discordapi'; -export * from './patcher'; -export * from './reactcomponents'; diff --git a/client/src/ui/automanip.js b/client/src/ui/automanip.js index 0eb69629..7331f66c 100644 --- a/client/src/ui/automanip.js +++ b/client/src/ui/automanip.js @@ -128,13 +128,11 @@ export default class extends EventListener { if (markup.ets) { const etsRoot = document.createElement('span'); markup.clone.appendChild(etsRoot); - VueInjector.inject( - etsRoot, - DOM.createElement('span', null, 'test'), - { EditedTimeStamp }, - ``, - true - ); + VueInjector.inject(etsRoot, { + components: { EditedTimeStamp }, + data: { ets: markup.ets }, + template: '' + }); } Events.emit('ui:mutable:.markup', markup.clone); @@ -214,12 +212,10 @@ export default class extends EventListener { const parent = document.querySelector('[class*="channelTextArea"] > [class*="inner"]'); if (!parent) return; parent.append(root); - VueInjector.inject( - root, - DOM.createElement('span'), - { Autocomplete }, - ``, - true - ); + VueInjector.inject(root, { + components: { Autocomplete }, + data: { initial: e.target.value }, + template: '' + }); } } diff --git a/client/src/ui/components/bd/BdBadge.vue b/client/src/ui/components/bd/BdBadge.vue index 2c82a62d..969f8692 100644 --- a/client/src/ui/components/bd/BdBadge.vue +++ b/client/src/ui/components/bd/BdBadge.vue @@ -9,11 +9,11 @@ */ diff --git a/client/src/ui/components/bd/BdMessageBadge.vue b/client/src/ui/components/bd/BdMessageBadge.vue index c4258d5b..29e88adc 100644 --- a/client/src/ui/components/bd/BdMessageBadge.vue +++ b/client/src/ui/components/bd/BdMessageBadge.vue @@ -10,9 +10,9 @@ - - - - - - - - - - - - diff --git a/tests/csseditor/main.css b/tests/csseditor/main.css deleted file mode 100644 index 5124957f..00000000 --- a/tests/csseditor/main.css +++ /dev/null @@ -1,294 +0,0 @@ -html, body { - margin: 0; - padding: 0; - max-height: 100%; - height: 100%; - background: #2c383e; - min-width: 700px; - min-height: 400px; -} - -* { - outline: none; -} - -.flex-spacer { - flex-grow: 1; -} - -.flex-row { - display: flex; - flex-direction: row; -} - -.valign { - position: absolute; - left: 50%; - top: 50%; - transform: translate(-50%, -50%); -} - -.container { - display: flex; - flex-grow: 1; - flex-direction: column; - height: 100%; -} - -.titlebar { - display: flex; - height: 25px; - padding: 4px 5px; - background: #292b2f; - border-bottom: 1px solid hsla(218,5%,47%,.3); - user-select: none; - cursor: default; -} - -.titlebar .icon { - width: 31px; - height: 25px; -} - -.titlebar .icon .inner { - width: 25px; - height: 25px; - background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iQ2FscXVlXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IiB2aWV3Qm94PSIwIDAgMjAwMCAyMDAwIiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCAyMDAwIDIwMDAiIHhtbDpzcGFjZT0icHJlc2VydmUiPjxnPjxwYXRoIGZpbGw9IiMzRTgyRTUiIGQ9Ik0xNDAyLjIsNjMxLjdjLTkuNy0zNTMuNC0yODYuMi00OTYtNjQyLjYtNDk2SDY4LjR2NzE0LjFsNDQyLDM5OFY0OTAuN2gyNTdjMjc0LjUsMCwyNzQuNSwzNDQuOSwwLDM0NC45SDU5Ny42djMyOS41aDE2OS44YzI3NC41LDAsMjc0LjUsMzQ0LjgsMCwzNDQuOGgtNjk5djM1NC45aDY5MS4yYzM1Ni4zLDAsNjMyLjgtMTQyLjYsNjQyLjYtNDk2YzAtMTYyLjYtNDQuNS0yODQuMS0xMjIuOS0zNjguNkMxMzU3LjcsOTE1LjgsMTQwMi4yLDc5NC4zLDE0MDIuMiw2MzEuN3oiLz48cGF0aCBmaWxsPSIjRkZGRkZGIiBkPSJNMTI2Mi41LDEzNS4yTDEyNjIuNSwxMzUuMmwtNzYuOCwwYzI2LjYsMTMuMyw1MS43LDI4LjEsNzUsNDQuM2M3MC43LDQ5LjEsMTI2LjEsMTExLjUsMTY0LjYsMTg1LjNjMzkuOSw3Ni42LDYxLjUsMTY1LjYsNjQuMywyNjQuNmwwLDEuMnYxLjJjMCwxNDEuMSwwLDU5Ni4xLDAsNzM3LjF2MS4ybDAsMS4yYy0yLjcsOTktMjQuMywxODgtNjQuMywyNjQuNmMtMzguNSw3My44LTkzLjgsMTM2LjItMTY0LjYsMTg1LjNjLTIyLjYsMTUuNy00Ni45LDMwLjEtNzIuNiw0My4xaDcyLjVjMzQ2LjIsMS45LDY3MS0xNzEuMiw2NzEtNTY3LjlWNzE2LjdDMTkzMy41LDMxMi4yLDE2MDguNywxMzUuMiwxMjYyLjUsMTM1LjJ6Ii8+PC9nPjwvc3ZnPg==); - background-size: 22px 22px; - background-repeat: no-repeat; - background-position: center; -} - -.titlebar .title { - color: #bac9d2; - font-family: Whitney,Helvetica Neue,Helvetica,Arial,sans-serif; - line-height: 25px; - font-size: 15px; -} - -.titlebar .controls { - margin: 0 0 0 2px; - font-size: 0; -} - -.titlebar .controls button { - -webkit-app-region: no-drag; - border-radius: 3px; - width: 25px; - font-size: 12px; - font-weight: 600; - /*background: #263238;*/ - background: #36393f; - color: #bac9d2; - font-family: Whitney,Helvetica Neue,Helvetica,Arial,sans-serif; - transition: background-color .2s ease; - cursor: default; - border: 0; - height: 25px; - z-index: 900062; - padding: 0; - margin: 0 0 0 4px; -} - -.titlebar .controls button:hover { - background: #44474e; - color: #FFF; -} - -.titlebar .controls button.active { - background: #3a71c1; -} - -.titlebar .draggable { - top: 0; - left: 0; - right: 63px; - position: absolute; - height: 33px; - -webkit-app-region: drag; -} - -#spinner { - background: rgba(51, 48, 48, 0.41); - position: absolute; - top: 34px; - left: 0; - right: 0; - bottom: 0; - color: #bac9d2; - font-family: Whitney,Helvetica Neue,Helvetica,Arial,sans-serif; - font-weight: 600; - font-size: 2em; - z-index: 90000; - user-select: none; -} - -.editor { - display: flex; - flex-direction: column; - flex-grow: 1; - overflow: hidden; -} - -.editor .CodeMirror { - flex-grow: 1; -} - -.tools { - height: 36px; - background: #292b2f; - border-top: 1px solid hsla(218,5%,47%,.3); - display: flex; - flex-direction: column; - user-select: none; -} - -.tools .flex-row { - flex-grow: 1; - padding: 4px 5px; -} - -.tools button { - border-radius: 3px; - width: 100px; - padding: 3px 10px; - font-size: 12px; - font-weight: 600; - background: #36393f; - color: #bac9d2; - font-family: Whitney,Helvetica Neue,Helvetica,Arial,sans-serif; - transition: background-color .2s ease; - cursor: pointer; - border: 0; - margin-right: 4px; -} - -.tools button:hover { - background: #44474e; - color: #FFF; -} - -.tools #chkboxLiveUpdate { - padding: 3px 10px; - line-height: 22px; -} - -.tools #chkboxLiveUpdate input[type="checkbox"] { - margin: 0 6px 0 0; - cursor: pointer; -} - -.tools #chkboxLiveUpdate span { - font-size: 12px; - font-weight: 500; - color: #bac9d2; - font-family: Whitney,Helvetica Neue,Helvetica,Arial,sans-serif; - cursor: default; -} - -/*CodeMirror styling*/ -.CodeMirror-scroll { - cursor: text; -} - -.CodeMirror-overlayscroll .CodeMirror-scrollbar-filler { - background: #38444a; -} - -.CodeMirror-overlayscroll-horizontal div, -.CodeMirror-overlayscroll-vertical div { - background: rgb(41, 43, 47); -} - -.CodeMirror-overlayscroll-horizontal, -.CodeMirror-overlayscroll-horizontal div { - height: 10px; -} - -.CodeMirror-overlayscroll-vertical, -.CodeMirror-overlayscroll-vertical div { - width: 10px; -} - -.CodeMirror-scrollbar-filler { - width: 10px; - height: 10px; - background: rgb(41, 43, 47); -} - -.cm-s-material.CodeMirror { - background: #36393f; -} - -.CodeMirror-scroll { - cursor: text; -} - -.cm-s-material .CodeMirror-gutters { - background: #292b2f; -} - -.CodeMirror-gutter { - min-width: 34px; - border-right: 1px solid hsla(218,5%,47%,.3); - cursor: default; -} - -.CodeMirror-hints { - /*background: #1e262a;*/ - background: #292b2f; - box-shadow: 2px 3px 5px rgba(4, 4, 4, 0.22); - border: 1px solid #262f33; -} - -.CodeMirror-hints::-webkit-scrollbar { - background: transparent; -} - -.CodeMirror-hints::-webkit-scrollbar-thumb { - background-color: rgba(0,0,0,.4); - border-color: transparent; -} - -.CodeMirror-hints::-webkit-scrollbar-thumb, -.CodeMirror-hints::-webkit-scrollbar-track { - background-clip: padding-box; - border-width: 3px; - border-style: solid; - border-radius: 7px; -} - -.CodeMirror-hints::-webkit-scrollbar-track { - background-color: transparent; - border-color: transparent; -} - -.CodeMirror-linenumber, -.CodeMirror-line { - padding: 0 5px !important; -} - -.CodeMirror-linenumber { - cursor: text; -} - -.cm-s-material .CodeMirror-linenumber { - color: #f6f6f7; -} - -.CodeMirror-hint { - color: #bac9d2; -} - -li.CodeMirror-hint-active { - color: #bac9d2; - /*background: #3b4950;*/ - background: #36393f; -} - -.CodeMirror-dialog-top { - bottom: 0; - top: auto; - border: none; - background: #1e262a; -} diff --git a/tests/csseditor/main.js b/tests/csseditor/main.js deleted file mode 100644 index a9f23d58..00000000 --- a/tests/csseditor/main.js +++ /dev/null @@ -1,123 +0,0 @@ -const { remote, ipcRenderer } = require('electron'); -const { BDIpc } = require('../frontend/main.js'); - -//Options -const options = { - alwaysOnTop: false, - liveUpdate: false -}; - -function sendToDiscord(channel, message) { - BDIpc.send('bd-sendToDiscord', {channel, message}); -} - -//Elements -const - $spinner = $('#spinner'), - $toggleaot = $('#toggleaot'), - $closeeditor = $('#closeeditor'), - $editor = $('#editor'), - $btnSave = $('#btnSave'), - $btnUpdate = $('#btnUpdate'), - $chkboxLiveUpdate = $("#chkboxLiveUpdate input"); - -$toggleaot.on('click', e => { - $toggleaot.toggleClass("active"); - remote.getCurrentWindow().setAlwaysOnTop(options.alwaysOnTop = !options.alwaysOnTop); -}); -$closeeditor.on('click', e => window.close()); - -$btnSave.on('click', () => sendToDiscord("save-css", codeMirror.getValue())); -$btnUpdate.on('click', () => sendToDiscord("update-css", codeMirror.getValue())); -$chkboxLiveUpdate.on('change', () => options.liveUpdate = $chkboxLiveUpdate[0].checked); - -BDIpc.on("set-css", (_, data) => { - if (data.error) { - alert(data.error); - return; - } - - setCss(data.css); - $spinner.hide(); -}); - -function setCss(css) { - codeMirror.setValue(css); -} - -function alert(message) {} - -const codeMirror = CodeMirror($editor[0], { - lineNumbers: true, - mode: 'css', - indentUnit: 4, - theme: 'material', - scrollbarStyle: 'overlay', - extraKeys: { 'Ctrl-Space': 'autocomplete' }, - dialog: { 'position': 'bottom' } -}); - -codeMirror.on('change', () => { - if (options.liveUpdate) - sendToDiscord("update-css", codeMirror.getValue()); -}); - -codeMirror.on('keyup', function (editor, event) { - if (window.controlDown) return; - if (ExcludedIntelliSenseTriggerKeys[event.keyCode]) return; - CodeMirror.commands.autocomplete(editor, null, { completeSingle: false }); -}); - -const ExcludedIntelliSenseTriggerKeys = { - '8': 'backspace', - '9': 'tab', - '13': 'enter', - '16': 'shift', - '17': 'ctrl', - '18': 'alt', - '19': 'pause', - '20': 'capslock', - '27': 'escape', - '33': 'pageup', - '34': 'pagedown', - '35': 'end', - '36': 'home', - '37': 'left', - '38': 'up', - '39': 'right', - '40': 'down', - '45': 'insert', - '46': 'delete', - '91': 'left window key', - '92': 'right window key', - '93': 'select', - '107': 'add', - '109': 'subtract', - '110': 'decimal point', - '111': 'divide', - '112': 'f1', - '113': 'f2', - '114': 'f3', - '115': 'f4', - '116': 'f5', - '117': 'f6', - '118': 'f7', - '119': 'f8', - '120': 'f9', - '121': 'f10', - '122': 'f11', - '123': 'f12', - '144': 'numlock', - '145': 'scrolllock', - '186': 'semicolon', - '187': 'equalsign', - '188': 'comma', - '189': 'dash', - '190': 'period', - '191': 'slash', - '192': 'graveaccent', - '220': 'backslash', - '222': 'quote' -}; - -BDIpc.send('bd-get-css'); diff --git a/tests/csseditor/mainold.css b/tests/csseditor/mainold.css deleted file mode 100644 index 753690c4..00000000 --- a/tests/csseditor/mainold.css +++ /dev/null @@ -1,448 +0,0 @@ -html, body { - margin: 0; - padding: 0; - max-height: 100%; - background: #2c383e; - min-width: 700px; - min-height: 400px; -} - -.titlebg { - z-index: 0; - position: absolute; - left: 0; - right: 0; - top: 0; - height: 40px; - /*background: #2c383e;*/ - background: #292b2f; - /*border-bottom: 1px solid #303e46;*/ - border-bottom: 1px solid hsla(218,5%,47%,.3); -} - -.titlebar { - z-index: 1; - display: flex; - height: 23px; - /*background: #2c383e;*/ - background: #292b2f; - -webkit-app-region: drag; - /*border-bottom: 1px solid #303e46;*/ - border-bottom: 1px solid hsla(218,5%,47%,.3); - padding: 10px; - margin-right: 70px; - max-height: 20px; - min-height: 20px; -} - - .titlebar .title { - color: #bac9d2; - font-family: Whitney,Helvetica Neue,Helvetica,Arial,sans-serif; - line-height: 18px; - display: inline-block; - margin-left: 10px; - margin-top: 2px; - } - - .titlebar .icon { - width: 16px; - height: 16px; - background-size: 100% 100%; - display: block; - margin-top: 2px; - background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAARCAYAAADUryzEAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAABGFJREFUeAEAUQSu+wH///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAACo4PeOYsD0cSgTBPkAAAAAAAAAAAAAAAAAAAAAAP4AAAD/AAAAAAAAAAAAAAAAAAD8/wAB6vn+BJU6C3EEAAAAAPz9/vr3+f4Az+v7BwD8/wAA/gAAAAEAAAD/AAAABgEAAAQAAAD/AAAA/wAAAAMAAAABAQAA+P8ABgH+9AQAAAAAFAkE2gADAAAAAQAACwoCAP8AAAAAAAAAAP0AAAEPAQD/CgEAAP0AAAEAAAD/AQAA9vf/AA4BAQAQBgXaBAAAAAD3+/3dAAQBAAD0/gC5VhIAOxYGAAAAAAAAAAAA/wAAAPj9/gD/AAAACgMCAKXm+ABcuPEAGA8D/vX8/d8EAAAAAAgDBOAaCgL/5vL8AcPp+gAeDAQAy+z8AOL0/ABLHQYAJQ0EAAAAAAAAAAAA4/b+AAD9/wAUBgH7wOX35QIAAAAAyuz04RYHAfwADwYAeb/zAB6I5ABTtewA2PP7ABYIAQAAAP8AreX4ACG47AB5zvQAAAoDABkKA/YhDgUABAAAAAAXCgUAGgv9+tDk+AUMEgMAjkgOAGUmCgAAAAEAAAAAAPD7/QDP8f0AXR8KALTr+gDP2foAEwcA8/gA+QAEAAAAAAL5AQATBQH0APb+C1kxCgBlJgsAAAAAAAAAAAAAAAAAEAUDAIQqCwAAAAAAyfL8AAD3/QAdDAXuMhUJAAQAAAAA4vsAAAoGAfEACwIXsOH5AN3z7wDt+P4A+PwAAAMLAQDj/v8AuTgOADkSBQDl9/0AAAQBAAgCAOrj8f4ABAAAAAApEwUA3fH87QD5AAAWCAIAvUcRALTi+ABNmekAABUGAAAG/wANOgAAAAAAAOr4/wAAAwEA/v8A587p+wAEAAAAAPH19wAMAgTnAAEAAPP8/wAAAAAATB4IAI1ZEwC37fsASx0HACwQBQD4/f8A7Pn+AAAA/wAWCwHkCwkCAAQAAAAAGQwHAPX7AeUABAAA4vP9ALDh9wBMHQcAciwMAHIAAAAAAAAA+v7/AJ7i9wD//P8AAAEAABgKAuH+BAEABAAAAADD6fsAJw0E4gAEAQAAAAIAUbLwAAAMAgA/GAUANhsGAL70/QDN6foAAPj/AAACAgAA/wEAAv4B3ubu/gAEAAAAACERAwAiCwPIDg0BAPL2/gAAAQIAAPUAAMHZ+QDB4vkAAAcCAAD5/wAA/QAAAAL+AC4aBfwQCgHN5f4BAAH///8AAADsAPv+AwCQ0wUAJg4EV+P4/GW96Pw1tOP6Dvz7AAALBAEATx8F7DsXBsUaDAOW5PP7ukgpCwACAQEABAAAAAAAAPwA+/7/AAoDBgDw9vypLRMAqTQWCiY7FgV80+38NlEhCLgYCgKG5fP66uf4/QAEAf8AA/8BAAkBAAABAAD//6/RP29a9e2vAAAAAElFTkSuQmCC"); - } - -button.close, -button.aot { - position: absolute; - border-radius: 3px; - width: 25px; - font-size: 12px; - font-weight: 600; - /*background: #263238;*/ - background: #36393f; - color: #bac9d2; - font-family: Whitney,Helvetica Neue,Helvetica,Arial,sans-serif; - transition: background-color .2s ease; - cursor: pointer; - border: 0; - height: 25px; - z-index: 900062; - padding: 0; - margin: 0; -} - - button.close:hover, - button.aot:hover { - /* background: #303f46;*/ - background: #44474e; - color: #FFF; - } - -button.close { - right: 8px; - top: 8px; -} - -button.aot { - right: 38px; - top: 8px; -} - - button.aot.enabled { - /*background: #376982;*/ - background: #3a71c1; - } - -.spacer { - flex-grow: 1; -} - -.container { - display: flex; - flex-direction: column; - max-height: 100%; -} - -#cm-container { - flex-grow: 1; - display: flex; - flex-direction: column; -} - -.CodeMirror { - height: 100%; -} - -.controls { - display: flex; - padding: 5px; - height: 40px; - min-height: 40px; - /*background: #2c383e;*/ - /*border-top: 1px solid #38444a;*/ - overflow: hidden; - background: #292b2f; - border-top: 1px solid hsla(218,5%,47%,.3); -} - - .controls button { - border-radius: 3px; - width: 100px; - padding: 10px 20px; - font-size: 16px; - font-weight: 600; - /* background: #263238;*/ - background: #36393f; - color: #bac9d2; - font-family: Whitney,Helvetica Neue,Helvetica,Arial,sans-serif; - transition: background-color .2s ease; - cursor: pointer; - border: 0; - margin-left: 5px; - } - - .controls button:hover { - /*background: #303f46;*/ - background: #44474e; - color: #FFF; - } - - .controls .checkbox-container { - display: flex; - cursor: pointer; - margin-left: 5px; - margin-top: 10px; - } - - .controls .checkbox-container:hover .checkbox + span { - color: #FFF; - } - - .controls .checkbox-container:hover .checkbox { - /*background: #303f46;*/ - background: #44474e; - border-color: #44474e; - /*border-color: #303f46;*/ - } - - .controls .checkbox-container .checkbox { - position: relative; - width: 15px; - height: 15px; - /*background: #263238;*/ - background: #36393f; - /*border: 3px solid #263238;*/ - border: 3px solid #36393f; - border-radius: 3px; - margin-right: 5px; - -webkit-transition: 0.2s all ease; - -moz-transition: 0.2s all ease; - transition: 0.2s all ease; - } - - .controls .checkbox-container.checked .checkbox { - /*background: #376982;*/ - /*border: 3px solid #376982;*/ - background: #3a71c1; - border: 3px solid #3a71c1; - } - - .controls .checkbox-container.checked .checkbox::after { - opacity: 1; - } - - .controls .checkbox-container .checkbox + span { - color: #bac9d2; - font-family: Whitney,Helvetica Neue,Helvetica,Arial,sans-serif; - line-height: 20px; - font-size: 16px; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - } - - .controls .checkbox-container .checkbox::after { - content: ""; - position: absolute; - top: -2px; - left: 3px; - width: 8px; - height: 13px; - border: 2px solid #bac9d2; - border-top-width: 0; - border-left-width: 0; - -webkit-transform: rotate(40deg); - transform: rotate(40deg); - opacity: 0; - */ -webkit-transition: 0.2s all ease; - -moz-transition: 0.2s all ease; - transition: 0.2s all ease; - } - -button:focus, button:active { - outline: none; -} - -.CodeMirror-overlayscroll .CodeMirror-scrollbar-filler { - background: #38444a; -} - -.CodeMirror-overlayscroll-horizontal div, -.CodeMirror-overlayscroll-vertical div { - background: rgb(56, 68, 74); -} - -.cm-s-material.CodeMirror { - background: #36393f; -} - -.cm-s-material .CodeMirror-gutters { - background: #292b2f; -} - -#hints { - position: fixed; - z-index: 90000; - bottom: 100px; - /*background: rgba(34, 44, 49, 0.4);*/ - background: #292b2f; - border-radius: 5px; - left: 10px; - padding: 10px; - color: #bac9d2; - -webkit-transition: 0.2s all ease; - -moz-transition: 0.2s all ease; - transition: 0.2s all ease; - opacity: 0; - font-family: Whitney,Helvetica Neue,Helvetica,Arial,sans-serif; - pointer-events: none; -} - - #hints.visible { - opacity: 1; - } - - #hints h3 { - margin: 0; - margin-bottom: 10px; - border-bottom: 1px solid hsla(218,5%,47%,.3); - /*border-bottom: 1px solid #38444a;*/ - } - - #hints table { - color: #bac9d2; - } - -#cmhints { - position: fixed; - z-index: 90000; - bottom: 100px; - /*background: rgba(34, 44, 49, 0.4);*/ - background: #292b2f; - border-radius: 5px; - right: 10px; - padding: 10px; - color: #bac9d2; - -webkit-transition: 0.2s all ease; - -moz-transition: 0.2s all ease; - transition: 0.2s all ease; - opacity: 0; - font-family: Whitney,Helvetica Neue,Helvetica,Arial,sans-serif; - pointer-events: none; -} - - #cmhints.visible { - opacity: 1; - } - - #cmhints h3 { - margin: 0; - margin-bottom: 10px; - border-bottom: 1px solid hsla(218,5%,47%,.3); - /*border-bottom: 1px solid #38444a;*/ - } - - #cmhints table { - color: #bac9d2; - } - -.CodeMirror-hints { - /*background: #1e262a;*/ - background: #292b2f; - box-shadow: 2px 3px 5px rgba(4, 4, 4, 0.22); - border: 1px solid #262f33; -} - - .CodeMirror-hints::-webkit-scrollbar { - background: transparent; - } - - .CodeMirror-hints::-webkit-scrollbar-thumb { - background-color: rgba(0,0,0,.4); - border-color: transparent; - } - - .CodeMirror-hints::-webkit-scrollbar-thumb, - .CodeMirror-hints::-webkit-scrollbar-track { - background-clip: padding-box; - border-width: 3px; - border-style: solid; - border-radius: 7px; - } - - .CodeMirror-hints::-webkit-scrollbar-track { - background-color: transparent; - border-color: transparent; - } - -.cm-s-material .CodeMirror-linenumber { - color: #f6f6f7; -} - -.CodeMirror-hint { - color: #bac9d2; -} - -li.CodeMirror-hint-active { - color: #bac9d2; - /*background: #3b4950;*/ - background: #36393f; -} - -#eehint { - position: absolute; - z-index: 9000; - top: 70px; - left: 0; - right: 0; - text-align: center; - color: #FFF; - font-family: Whitney,Helvetica Neue,Helvetica,Arial,sans-serif; - -webkit-transition: 0.2s all ease; - -moz-transition: 0.2s all ease; - transition: 0.2s all ease; - opacity: 0; - pointer-events: none; -} - - #eehint span { - /* background: rgba(44, 56, 62, 0.51);*/ - background: #292b2f; - padding: 10px; - border-radius: 10px; - pointer-events: none; - -webkit-user-select: none; - user-select: none; - } - - #eehint.visible { - opacity: 1; - } - -.CodeMirror-dialog-top { - bottom: 0; - top: auto; - border: none; - background: #1e262a; -} - -#spinner { - background: rgba(51, 48, 48, 0.41); - position: absolute; - top: 41px; - left: 0; - right: 0; - bottom: 0; - z-index: 90000; -} - - #spinner.hidden { - display: none; - } - - #spinner .valign { - position: absolute; - left: 50%; - top: 50%; - transform: translate(-50%, -50%); - color: #bac9d2; - font-family: Whitney,Helvetica Neue,Helvetica,Arial,sans-serif; - font-weight: 600; - font-size: 2em; - } - -.checkbox-container.hidden, -button.hidden { - display: none; -} - -#alert { - position: absolute; - bottom: 55px; - z-index: 9; - left: 50px; - font-family: Whitney,Helvetica Neue,Helvetica,Arial,sans-serif; - color: #FFF; - padding: 2px 15px; - border-radius: 5px; - pointer-events: none; - opacity: 0; - -webkit-transition: 0.2s all ease; - -moz-transition: 0.2s all ease; - transition: 0.2s all ease; -} - - #alert.success { - background: rgba(77, 255, 77, 0.15); - } - - #alert.danger { - background: rgba(255, 77, 77, 0.15); - } - - #alert.visible { - opacity: 1; - } diff --git a/tests/frontend/index.html b/tests/frontend/index.html deleted file mode 100644 index a99e496b..00000000 --- a/tests/frontend/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/tests/frontend/main.js b/tests/frontend/main.js deleted file mode 100644 index 78d0cf79..00000000 --- a/tests/frontend/main.js +++ /dev/null @@ -1,26 +0,0 @@ -const { ipcRenderer } = require('electron'); - -class BDIpc { - - static on(channel, cb) { - ipcRenderer.on(channel, (event, args) => cb(event, args)); - } - - static async send(channel, message) { - const __eid = Date.now().toString(); - ipcRenderer.send( - channel.startsWith('bd-') ? channel: `bd-${channel}`, - message === undefined ? { __eid } : Object.assign(message, { __eid }) - ); - - return new Promise((resolve, reject) => { - ipcRenderer.once(__eid, (event, arg) => { - if (arg.err) return reject(arg); - resolve(arg); - }); - }); - } - -} - -module.exports = { BDIpc }; \ No newline at end of file diff --git a/tests/index.js b/tests/index.js deleted file mode 100644 index 0c1a74a0..00000000 --- a/tests/index.js +++ /dev/null @@ -1,21 +0,0 @@ -const { app, BrowserWindow } = require('electron'); -const { BetterDiscord } = require('../core/dist/main.js'); -const path = require('path'); -const url = require('url'); - -const config = require('./config.json'); - -let bw; -const bd = new BetterDiscord(Object.assign(config)); -app.on('ready', () => { - - bw = new BrowserWindow({ width: 1920, height: 1080 }); - bw.webContents.openDevTools(); - bw.loadURL(url.format({ - pathname: path.join(__dirname, 'frontend', 'index.html'), - protocol: 'file', - slashes: true - })); - bw.on('closed', () => app.quit()); - -}); \ No newline at end of file diff --git a/tests/run.bat b/tests/run.bat deleted file mode 100644 index 0d495882..00000000 --- a/tests/run.bat +++ /dev/null @@ -1 +0,0 @@ -..\core\node_modules\.bin\electron.cmd .\ \ No newline at end of file From 2fb5d8fe11cfaf722e82cd453d18a382ffe3217d Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Wed, 21 Mar 2018 00:16:42 +0000 Subject: [PATCH 04/23] Pause all keybinds while recording and add debugger keybind --- client/src/data/user.settings.default.json | 6 ++++ client/src/index.js | 9 ++++++ client/src/structs/settings/index.js | 1 + client/src/structs/settings/types/index.js | 12 ++++++++ client/src/structs/settings/types/keybind.js | 28 +++++++++++++++++-- .../src/ui/components/bd/setting/Keybind.vue | 4 ++- 6 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 client/src/structs/settings/types/index.js diff --git a/client/src/data/user.settings.default.json b/client/src/data/user.settings.default.json index 2b49c23a..3cf0ddda 100644 --- a/client/src/data/user.settings.default.json +++ b/client/src/data/user.settings.default.json @@ -51,6 +51,12 @@ "hint": "Adds some of BetterDiscord's internal modules to `global._bd`.", "value": false }, + { + "id": "debugger-keybind", + "type": "keybind", + "text": "Debugger keybind", + "hint": "When this keybind is activated the developer tools will be opened and Discord will be paused." + }, { "id": "ignore-content-manager-errors", "type": "bool", diff --git a/client/src/index.js b/client/src/index.js index f7a74b6e..3c4e0348 100644 --- a/client/src/index.js +++ b/client/src/index.js @@ -13,6 +13,7 @@ import BdCss from './styles/index.scss'; import { Events, CssEditor, Globals, Settings, Database, Updater, ModuleManager, PluginManager, ThemeManager, ExtModuleManager, Vendor, WebpackModules, Patcher, MonkeyPatch, ReactComponents, ReactAutoPatcher, DiscordApi } from 'modules'; import { ClientLogger as Logger, ClientIPC, Utils } from 'common'; import { EmoteModule } from 'builtin'; +import electron from 'electron'; const ignoreExternal = false; const DEV = true; @@ -40,6 +41,14 @@ class BetterDiscord { else if (window._bd) delete window._bd; }); + const debuggerkeybind = Settings.getSetting('core', 'advanced', 'debugger-keybind'); + debuggerkeybind.on('keybind-activated', () => { + const currentWindow = electron.remote.getCurrentWindow(); + if (currentWindow.isDevToolsOpened()) return eval('debugger;'); + currentWindow.openDevTools(); + setTimeout(() => eval('debugger;'), 1000); + }); + DOM.injectStyle(BdCss, 'bdmain'); this.globalReady = this.globalReady.bind(this); Events.on('global-ready', this.globalReady); diff --git a/client/src/structs/settings/index.js b/client/src/structs/settings/index.js index 7a7f50df..da66c0ec 100644 --- a/client/src/structs/settings/index.js +++ b/client/src/structs/settings/index.js @@ -2,3 +2,4 @@ export { default as SettingsSet } from './settingsset'; export { default as SettingsCategory } from './settingscategory'; export { default as Setting } from './setting'; export { default as SettingsScheme } from './settingsscheme'; +export * from './types'; diff --git a/client/src/structs/settings/types/index.js b/client/src/structs/settings/types/index.js new file mode 100644 index 00000000..8a212c1c --- /dev/null +++ b/client/src/structs/settings/types/index.js @@ -0,0 +1,12 @@ +export { default as BoolSetting } from './bool'; +export { default as StringSetting } from './text'; +export { default as NumberSetting } from './number'; +export { default as DropdownSetting } from './dropdown'; +export { default as RadioSetting } from './radio'; +export { default as SliderSetting } from './slider'; +export { default as ColourSetting } from './colour'; +export { default as KeybindSetting } from './keybind'; +export { default as FileSetting } from './file'; +export { default as GuildSetting } from './guild'; +export { default as ArraySetting } from './array'; +export { default as CustomSetting } from './custom'; diff --git a/client/src/structs/settings/types/keybind.js b/client/src/structs/settings/types/keybind.js index efbe3f90..f98371c4 100644 --- a/client/src/structs/settings/types/keybind.js +++ b/client/src/structs/settings/types/keybind.js @@ -11,18 +11,42 @@ import Setting from './basesetting'; import Combokeys from 'combokeys'; +let keybindsPaused = false; + export default class KeybindSetting extends Setting { constructor(args, ...merge) { super(args, ...merge); + this.__keybind_activated = this.__keybind_activated.bind(this); + this.combokeys = new Combokeys(document); - this.combokeys.bind(this.value, event => this.emit('keybind-activated', event)); + this.combokeys.bind(this.value, this.__keybind_activated); + } + + /** + * The value to use when the setting doesn't have a value. + */ + get defaultValue() { + return ''; } setValueHook() { this.combokeys.reset(); - this.combokeys.bind(this.value, event => this.emit('keybind-activated', event)); + this.combokeys.bind(this.value, this.__keybind_activated); + } + + __keybind_activated(event) { + if (KeybindSetting.paused) return; + this.emit('keybind-activated', event); + } + + static get paused() { + return keybindsPaused; + } + + static set paused(paused) { + keybindsPaused = paused; } } diff --git a/client/src/ui/components/bd/setting/Keybind.vue b/client/src/ui/components/bd/setting/Keybind.vue index e5258eb2..53498084 100644 --- a/client/src/ui/components/bd/setting/Keybind.vue +++ b/client/src/ui/components/bd/setting/Keybind.vue @@ -24,8 +24,9 @@ diff --git a/client/src/ui/components/bd/index.js b/client/src/ui/components/bd/index.js index 0c460f6d..532c5478 100644 --- a/client/src/ui/components/bd/index.js +++ b/client/src/ui/components/bd/index.js @@ -3,5 +3,6 @@ export { default as SettingsPanel } from './SettingsPanel.vue'; export { default as CssEditorView } from './CssEditor.vue'; export { default as PluginsView } from './PluginsView.vue'; export { default as ThemesView } from './ThemesView.vue'; +export { default as UpdaterView } from './UpdaterView.vue'; export { default as BdBadge } from './BdBadge.vue'; export { default as BdMessageBadge } from './BdMessageBadge.vue'; From 0f805d57e3835f92cb355d314607b99c87eae443 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Thu, 22 Mar 2018 02:13:32 +0000 Subject: [PATCH 12/23] More comments --- client/src/builtin/EmoteModule.js | 22 +++++-- client/src/modules/content.js | 27 ++++----- client/src/modules/contentmanager.js | 82 ++++++++++----------------- client/src/modules/csseditor.js | 51 +++++++++-------- client/src/modules/eventhook.js | 2 +- client/src/modules/globals.js | 32 +++++------ client/src/modules/pluginmanager.js | 36 ++++++------ client/src/modules/reactcomponents.js | 16 +++++- client/src/modules/thememanager.js | 4 +- client/src/modules/webpackmodules.js | 4 -- client/src/plugins/TimeStamps.js | 3 - client/src/plugins/index.js | 0 12 files changed, 134 insertions(+), 145 deletions(-) delete mode 100644 client/src/plugins/TimeStamps.js delete mode 100644 client/src/plugins/index.js diff --git a/client/src/builtin/EmoteModule.js b/client/src/builtin/EmoteModule.js index df3e2337..6de5693b 100644 --- a/client/src/builtin/EmoteModule.js +++ b/client/src/builtin/EmoteModule.js @@ -8,27 +8,33 @@ * LICENSE file in the root directory of this source tree. */ -import { FileUtils, ClientLogger as Logger } from 'common'; import { Events, Globals, WebpackModules, ReactComponents, MonkeyPatch } from 'modules'; import { DOM, VueInjector, Reflection } from 'ui'; +import { FileUtils, ClientLogger as Logger } from 'common'; +import path from 'path'; import EmoteComponent from './EmoteComponent.vue'; let emotes = null; const emotesEnabled = true; export default class { + static get searchCache() { return this._searchCache || (this._searchCache = {}); } + static get emoteDb() { return emotes; } + static get React() { return WebpackModules.getModuleByName('React'); } + static get ReactDOM() { return WebpackModules.getModuleByName('ReactDOM'); } + static processMarkup(markup) { if (!emotesEnabled) return markup; // TODO Get it from setttings const newMarkup = []; @@ -94,13 +100,20 @@ export default class { } static async observe() { - const dataPath = Globals.getObject('paths').find(path => path.id === 'data').path; + const dataPath = Globals.getPath('data'); + try { + emotes = await FileUtils.readJsonFromFile(path.join(dataPath, 'emotes.json')); + } catch (err) { + Logger.err('EmoteModule', [`Failed to load emote data. Make sure you've downloaded the emote data and placed it in ${dataPath}:`, err]); + return; + } + try { - emotes = await FileUtils.readJsonFromFile(dataPath + '/emotes.json'); const Message = await ReactComponents.getComponent('Message'); this.unpatchRender = MonkeyPatch('BD:EmoteModule', Message.component.prototype).after('render', (component, args, retVal) => { try { - const markup = this.findByProp(retVal, 'className', 'markup'); // First child has all the actual text content, second is the edited timestamp + // First child has all the actual text content, second is the edited timestamp + const markup = this.findByProp(retVal, 'className', 'markup'); if (!markup) return; markup.children[0] = this.processMarkup(markup.children[0]); } catch (err) { @@ -180,4 +193,5 @@ export default class { } }); } + } diff --git a/client/src/modules/content.js b/client/src/modules/content.js index fdc6c463..ce2047fd 100644 --- a/client/src/modules/content.js +++ b/client/src/modules/content.js @@ -59,6 +59,7 @@ export default class Content { /** * Opens a settings modal for this content. + * @return {Modal} */ showSettingsModal() { return Modals.contentSettings(this); @@ -73,16 +74,10 @@ export default class Content { /** * Saves the content's current configuration. + * @return {Promise} */ async saveConfiguration() { try { - /* - await FileUtils.writeFile(`${this.contentPath}/user.config.json`, JSON.stringify({ - enabled: this.enabled, - config: this.settings.strip().settings, - data: this.data - })); - */ Database.insertOrUpdate({ type: 'contentconfig', $or: [{ id: this.id }, { name: this.name }] }, { type: 'contentconfig', id: this.id, @@ -143,15 +138,6 @@ export default class Content { return this.events.on(...args); } - /** - * Removes an event listener. - * @param {String} event The event to remove the listener from - * @param {Function} callback The bound callback (optional) - */ - off(...args) { - return this.events.removeListener(...args); - } - /** * Adds an event listener that removes itself when called, therefore only being called once. * @param {String} event The event to add the listener to @@ -162,6 +148,15 @@ export default class Content { return this.events.once(...args); } + /** + * Removes an event listener. + * @param {String} event The event to remove the listener from + * @param {Function} callback The bound callback (optional) + */ + off(...args) { + return this.events.removeListener(...args); + } + /** * Emits an event. * @param {String} event The event to emit diff --git a/client/src/modules/contentmanager.js b/client/src/modules/contentmanager.js index 2826120c..55fcb18e 100644 --- a/client/src/modules/contentmanager.js +++ b/client/src/modules/contentmanager.js @@ -24,31 +24,31 @@ import Combokeys from 'combokeys'; export default class { /** - * Any errors that happened - * returns {Array} + * Any errors that happened. + * @return {Array} */ static get errors() { return this._errors || (this._errors = []); } /** - * Locallly stored content - * returns {Array} + * Locally stored content. + * @return {Array} */ static get localContent() { return this._localContent ? this._localContent : (this._localContent = []); } /** - * Local path for content - * returns {String} + * Local path for content. + * @return {String} */ static get contentPath() { return Globals.getPath(this.pathId); } /** - * Load all locally stored content + * Load all locally stored content. * @param {bool} suppressErrors Suppress any errors that occur during loading of content */ static async loadAllContent(suppressErrors = false) { @@ -83,8 +83,6 @@ export default class { }); this._errors = []; } - - return this.localContent; } catch (err) { throw err; } @@ -150,8 +148,6 @@ export default class { }); this._errors = []; } - - return this.localContent; } catch (err) { throw err; } @@ -169,15 +165,12 @@ export default class { await FileUtils.directoryExists(contentPath); - if (!reload) { - const loaded = this.localContent.find(content => content.contentPath === contentPath); - if (loaded) { - throw { 'message': `Attempted to load already loaded user content: ${path}` }; - } - } + if (!reload && this.getContentByPath(contentPath)) + throw { 'message': `Attempted to load already loaded user content: ${path}` }; - const readConfig = await this.readConfig(contentPath); - const mainPath = path.join(contentPath, readConfig.main); + const configPath = path.resolve(contentPath, 'config.json'); + const readConfig = await FileUtils.readJsonFromFile(configPath); + const mainPath = path.join(contentPath, readConfig.main || 'index.js'); const defaultConfig = new SettingsSet({ settings: readConfig.defaultConfig, @@ -191,17 +184,15 @@ export default class { }; try { - //const readUserConfig = await this.readUserConfig(contentPath); - const readUserConfig = await Database.find({ type: 'contentconfig', name: readConfig.info.name }); + const id = readConfig.info.id || readConfig.info.name.toLowerCase().replace(/[^a-zA-Z0-9-]/g, '-').replace(/--/g, '-'); + const readUserConfig = await Database.find({ type: 'contentconfig', id }); if (readUserConfig.length) { userConfig.enabled = readUserConfig[0].enabled || false; - // await userConfig.config.merge({ settings: readUserConfig.config }); - // userConfig.config.setSaved(); - // userConfig.config = userConfig.config.clone({ settings: readUserConfig.config }); userConfig.config = readUserConfig[0].config; userConfig.data = readUserConfig[0].data || {}; } - } catch (err) { /*We don't care if this fails it either means that user config doesn't exist or there's something wrong with it so we revert to default config*/ + } catch (err) { + // We don't care if this fails it either means that user config doesn't exist or there's something wrong with it so we revert to default config Logger.info(this.moduleName, `Failed reading config for ${this.contentType} ${readConfig.info.name} in ${dirName}`); Logger.err(this.moduleName, err); } @@ -244,9 +235,10 @@ export default class { } /** - * Unload content - * @param {any} content Content to unload - * @param {bool} reload Whether to reload the content after + * Unload content. + * @param {Content|String} content Content to unload + * @param {Boolean} reload Whether to reload the content after + * @return {Content} */ static async unloadContent(content, reload) { content = this.findContent(content); @@ -275,34 +267,18 @@ export default class { } /** - * Reload content - * @param {any} content Content to reload + * Reload content. + * @param {Content|String} content Content to reload + * @return {Content} */ static reloadContent(content) { return this.unloadContent(content, true); } - /** - * Read content config file - * @param {any} configPath Config file path - */ - static async readConfig(configPath) { - configPath = path.resolve(configPath, 'config.json'); - return FileUtils.readJsonFromFile(configPath); - } - - /** - * Read content user config file - * @param {any} configPath User config file path - */ - static async readUserConfig(configPath) { - configPath = path.resolve(configPath, 'user.config.json'); - return FileUtils.readJsonFromFile(configPath); - } - /** * Checks if the passed object is an instance of this content type. - * @param {any} content Object to check + * @param {Any} content Object to check + * @return {Boolean} */ static isThisContent(content) { return content instanceof Content; @@ -318,8 +294,9 @@ export default class { /** * Wildcard content finder - * @param {any} wild Content ID / directory name / path / name - * @param {bool} nonunique Allow searching attributes that may not be unique + * @param {String} wild Content ID / directory name / path / name + * @param {Boolean} nonunique Allow searching attributes that may not be unique + * @return {Content} */ static findContent(wild, nonunique) { if (this.isThisContent(wild)) return wild; @@ -338,7 +315,8 @@ export default class { /** * Wait for content to load - * @param {any} content_id + * @param {String} content_id + * @return {Promise} */ static waitForContent(content_id) { return new Promise((resolve, reject) => { diff --git a/client/src/modules/csseditor.js b/client/src/modules/csseditor.js index ebc17c16..5dbd1846 100644 --- a/client/src/modules/csseditor.js +++ b/client/src/modules/csseditor.js @@ -32,7 +32,7 @@ export default new class { } /** - * Init css editor + * Init css editor. */ init() { ClientIPC.on('bd-get-scss', () => this.scss, true); @@ -60,16 +60,16 @@ export default new class { } /** - * Show css editor, flashes if already visible + * Show css editor, flashes if already visible. */ async show() { await ClientIPC.send('openCssEditor', this.editor_bounds); } /** - * Update css in client - * @param {String} scss scss to compile - * @param {bool} sendSource send to css editor instance + * Update css in client. + * @param {String} scss SCSS to compile + * @param {bool} sendSource Whether to send to css editor instance */ async updateScss(scss, sendSource) { if (sendSource) @@ -97,15 +97,15 @@ export default new class { } /** - * Save css to file + * Save css to file. */ async save() { Settings.saveSettings(); } /** - * Save current editor bounds - * @param {Rectangle} bounds editor bounds + * Save current editor bounds. + * @param {Rectangle} bounds Editor bounds */ saveEditorBounds(bounds) { this.editor_bounds = bounds; @@ -113,8 +113,8 @@ export default new class { } /** - * Send scss to core for compilation - * @param {String} scss scss string + * Send SCSS to core for compilation. + * @param {String} scss SCSS string */ async compile(scss) { return await ClientIPC.send('bd-compileSass', { @@ -124,7 +124,7 @@ export default new class { } /** - * Recompile the current SCSS + * Recompile the current SCSS. * @return {Promise} */ async recompile() { @@ -132,16 +132,18 @@ export default new class { } /** - * Send data to open editor - * @param {any} channel - * @param {any} data + * Send data to open editor. + * @param {String} channel + * @param {Any} data + * @return {Promise} */ async sendToEditor(channel, data) { return ClientIPC.sendToCssEditor(channel, data); } /** - * Opens an SCSS file in a system editor + * Opens an SCSS file in a system editor. + * @return {Promise} */ async openSystemEditor() { try { @@ -160,7 +162,8 @@ export default new class { throw {message: 'Failed to open system editor.'}; } - /** Set current state + /** + * Set current state * @param {String} scss Current uncompiled SCSS * @param {String} css Current compiled CSS * @param {String} files Files imported in the SCSS @@ -175,29 +178,28 @@ export default new class { } /** - * Current uncompiled scss + * Current uncompiled scss. */ get scss() { return this._scss || ''; } /** - * Set current scss + * Set current scss. */ set scss(scss) { this.updateScss(scss, true); } /** - * Current compiled css + * Current compiled css. */ get css() { return this._css || ''; } /** - * Inject compiled css to head - * {DOM} + * Inject compiled css to head. */ set css(css) { this._css = css; @@ -205,15 +207,14 @@ export default new class { } /** - * Current error + * Current error. */ get error() { return this._error || undefined; } /** - * Set current error - * {DOM} + * Set current error. */ set error(err) { this._error = err; @@ -293,7 +294,7 @@ export default new class { /** * Checks if the system editor's file exists. - * @return {Boolean} + * @return {Promise} */ async fileExists() { try { diff --git a/client/src/modules/eventhook.js b/client/src/modules/eventhook.js index d6ba83b4..c2665e18 100644 --- a/client/src/modules/eventhook.js +++ b/client/src/modules/eventhook.js @@ -52,7 +52,7 @@ export default class extends EventListener { /** * Discord emit overload - * @param {any} e + * @param {any} event * @param {any} action * @param {any} data */ diff --git a/client/src/modules/globals.js b/client/src/modules/globals.js index bb4792b4..6b0312f4 100644 --- a/client/src/modules/globals.js +++ b/client/src/modules/globals.js @@ -29,26 +29,24 @@ export default new class extends Module { this.getObject = this.getObject.bind(this); } - first() { - (async() => { - const config = await ClientIPC.send('getConfig'); - this.setState({ config }); + async first() { + const config = await ClientIPC.send('getConfig'); + this.setState({ config }); - // This is for Discord to stop error reporting :3 - window.BetterDiscord = { - version: config.version, - v: config.version - }; - window.jQuery = {}; + // This is for Discord to stop error reporting :3 + window.BetterDiscord = { + version: config.version, + v: config.version + }; + window.jQuery = {}; - if (sparkplug.bd) { - this.setState({ bd: sparkplug.bd }); - sparkplug.bd.setWS = this.setWS; - } + if (sparkplug.bd) { + this.setState({ bd: sparkplug.bd }); + sparkplug.bd.setWS = this.setWS; + } - Events.emit('global-ready'); - Events.emit('socket-created', this.state.wsHook); - })(); + Events.emit('global-ready'); + Events.emit('socket-created', this.state.wsHook); } setWS(wSocket) { diff --git a/client/src/modules/pluginmanager.js b/client/src/modules/pluginmanager.js index 9275eda2..181335a0 100644 --- a/client/src/modules/pluginmanager.js +++ b/client/src/modules/pluginmanager.js @@ -90,9 +90,7 @@ export default class extends ContentManager { for (const [key, value] of Object.entries(dependencies)) { const extModule = ExtModuleManager.findModule(key); if (!extModule) { - throw { - 'message': `Dependency: ${key}:${value} is not loaded` - }; + throw {message: `Dependency ${key}:${value} is not loaded.`}; } deps[key] = extModule.__require; } @@ -121,24 +119,24 @@ export default class extends ContentManager { static get unloadPlugin() { return this.unloadContent } static get reloadPlugin() { return this.reloadContent } - static stopPlugin(name) { - const plugin = name instanceof Plugin ? name : this.getPluginByName(name); - try { - if (plugin) return plugin.stop(); - } catch (err) { - // Logger.err('PluginManager', err); - } - return true; //Return true anyways since plugin doesn't exist + /** + * Stops a plugin. + * @param {Plugin|String} plugin + * @return {Promise} + */ + static stopPlugin(plugin) { + plugin = this.isPlugin(plugin) ? plugin : this.getPluginById(plugin); + return plugin.stop(); } - static startPlugin(name) { - const plugin = name instanceof Plugin ? name : this.getPluginByName(name); - try { - if (plugin) return plugin.start(); - } catch (err) { - // Logger.err('PluginManager', err); - } - return true; //Return true anyways since plugin doesn't exist + /** + * Starts a plugin. + * @param {Plugin|String} plugin + * @return {Promise} + */ + static startPlugin(plugin) { + plugin = this.isPlugin(plugin) ? plugin : this.getPluginById(plugin); + return plugin.start(); } static get isPlugin() { return this.isThisContent } diff --git a/client/src/modules/reactcomponents.js b/client/src/modules/reactcomponents.js index c0ed473c..4ba8137b 100644 --- a/client/src/modules/reactcomponents.js +++ b/client/src/modules/reactcomponents.js @@ -6,7 +6,7 @@ * https://github.com/JsSucks - https://betterdiscord.net * * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * LICENSE file in the root directory of this source tree. */ import { MonkeyPatch, Patcher } from './patcher'; @@ -19,6 +19,7 @@ class Helpers { static get plannedActions() { return this._plannedActions || (this._plannedActions = new Map()); } + static recursiveArray(parent, key, count = 1) { let index = 0; function* innerCall(parent, key) { @@ -34,13 +35,15 @@ class Helpers { return innerCall(parent, key); } + static recursiveArrayCount(parent, key) { let count = 0; // eslint-disable-next-line no-empty-pattern - for (let { } of this.recursiveArray(parent, key)) + for (let {} of this.recursiveArray(parent, key)) ++count; return this.recursiveArray(parent, key, count); } + static get recursiveChildren() { return function* (parent, key, index = 0, count = 1) { const item = parent[key]; @@ -52,12 +55,14 @@ class Helpers { } } } + static returnFirst(iterator, process) { for (let child of iterator) { const retVal = process(child); if (retVal !== undefined) return retVal; } } + static getFirstChild(rootParent, rootKey, selector) { const getDirectChild = (item, selector) => { if (item && item.props && item.props.children) { @@ -116,11 +121,13 @@ class Helpers { }; return this.returnFirst(this.recursiveChildren(rootParent, rootKey), checkFilter.bind(null, selector)) || {}; } + static parseSelector(selector) { if (selector.startsWith('.')) return { className: selector.substr(1) } if (selector.startsWith('#')) return { id: selector.substr(1) } return {} } + static findByProp(obj, what, value) { if (obj.hasOwnProperty(what) && obj[what] === value) return obj; if (obj.props && !obj.children) return this.findByProp(obj.props, what, value); @@ -132,6 +139,7 @@ class Helpers { } return null; } + static findProp(obj, what) { if (obj.hasOwnProperty(what)) return obj[what]; if (obj.props && !obj.children) return this.findProp(obj.props, what); @@ -144,6 +152,7 @@ class Helpers { } return null; } + static get ReactDOM() { return WebpackModules.getModuleByName('ReactDOM'); } @@ -155,12 +164,15 @@ class ReactComponent { this._component = component; this._retVal = retVal; } + get id() { return this._id; } + get component() { return this._component; } + get retVal() { return this._retVal; } diff --git a/client/src/modules/thememanager.js b/client/src/modules/thememanager.js index dfaf7a37..2ddf8bd8 100644 --- a/client/src/modules/thememanager.js +++ b/client/src/modules/thememanager.js @@ -62,11 +62,11 @@ export default class ThemeManager extends ContentManager { } static enableTheme(theme) { - theme.enable(); + return theme.enable(); } static disableTheme(theme) { - theme.disable(); + return theme.disable(); } static get isTheme() { return this.isThisContent } diff --git a/client/src/modules/webpackmodules.js b/client/src/modules/webpackmodules.js index 71b03ecd..59bcf371 100644 --- a/client/src/modules/webpackmodules.js +++ b/client/src/modules/webpackmodules.js @@ -91,7 +91,6 @@ const KnownModules = { UserActivityStore: Filters.byProperties(['getActivity']), UserNameResolver: Filters.byProperties(['getName']), - /* Emoji Store and Utils */ EmojiInfo: Filters.byProperties(['isEmojiDisabled']), EmojiUtils: Filters.byProperties(['getGuildEmoji']), @@ -102,7 +101,6 @@ const KnownModules = { InviteResolver: Filters.byProperties(['findInvite']), InviteActions: Filters.byProperties(['acceptInvite']), - /* Discord Objects & Utils */ DiscordConstants: Filters.byProperties(["Permissions", "ActivityTypes", "StatusTypes"]), Permissions: Filters.byProperties(['getHighestRole']), @@ -128,7 +126,6 @@ const KnownModules = { ExperimentsManager: Filters.byProperties(['isDeveloper']), CurrentExperiment: Filters.byProperties(['getExperimentId']), - /* Images, Avatars and Utils */ ImageResolver: Filters.byProperties(["getUserAvatarURL"]), ImageUtils: Filters.byProperties(['getSizedImageSrc']), @@ -182,7 +179,6 @@ const KnownModules = { URLParser: Filters.byProperties(['Url', 'parse']), ExtraURLs: Filters.byProperties(['getArticleURL']), - /* DOM/React Components */ /* ==================== */ UserSettingsWindow: Filters.byProperties(['open', 'updateAccount']), diff --git a/client/src/plugins/TimeStamps.js b/client/src/plugins/TimeStamps.js deleted file mode 100644 index 3509c96a..00000000 --- a/client/src/plugins/TimeStamps.js +++ /dev/null @@ -1,3 +0,0 @@ -export default class { - -} diff --git a/client/src/plugins/index.js b/client/src/plugins/index.js deleted file mode 100644 index e69de29b..00000000 From ebff286c31767f48742f62fdcd934316b73439b1 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Thu, 22 Mar 2018 02:19:25 +0000 Subject: [PATCH 13/23] Add release build configuration --- client/package.json | 3 +- client/src/index.js | 4 +- client/webpack.config.js | 10 - client/webpack.production.config.js | 65 +++ core/src/main.js | 2 +- csseditor/package.json | 3 +- csseditor/webpack.production.config.js | 44 ++ gulpfile.js | 4 +- package-lock.json | 712 +++++++++++++++++++++++-- package.json | 5 +- 10 files changed, 791 insertions(+), 61 deletions(-) create mode 100644 client/webpack.production.config.js create mode 100644 csseditor/webpack.production.config.js diff --git a/client/package.json b/client/package.json index 237c6e98..6fb49e30 100644 --- a/client/package.json +++ b/client/package.json @@ -17,6 +17,7 @@ "private": false, "scripts": { "build": "webpack --progress --colors", - "watch": "webpack --progress --colors --watch" + "watch": "webpack --progress --colors --watch", + "release": "webpack --progress --colors --config=webpack.production.config.js" } } diff --git a/client/src/index.js b/client/src/index.js index 58c3da93..9e2f3ab3 100644 --- a/client/src/index.js +++ b/client/src/index.js @@ -16,13 +16,13 @@ import { EmoteModule } from 'builtin'; import electron from 'electron'; import path from 'path'; -const tests = true; +const tests = typeof PRODUCTION !== 'undefined'; const ignoreExternal = false; class BetterDiscord { constructor() { - Logger.file = tests ? path.join(__dirname, '..', '..', 'tests', 'log.txt') : path.join(__dirname, 'log.txt'); + Logger.file = tests ? path.resolve(__dirname, '..', '..', 'tests', 'log.txt') : path.join(__dirname, 'log.txt'); Logger.log('main', 'BetterDiscord starting'); this._bd = { diff --git a/client/webpack.config.js b/client/webpack.config.js index 3bca7afb..e88c1cea 100644 --- a/client/webpack.config.js +++ b/client/webpack.config.js @@ -55,14 +55,4 @@ module.exports = { __filename: false, __dirname: false } - /* resolve: { - alias: { - 'momentjs': 'vendor/moment.min.js' - }, - modules: [ - path.resolve('./node_modules'), - path.resolve(__dirname, '..'), - path.resolve(__dirname, '..', 'node_modules') - ] - } */ }; diff --git a/client/webpack.production.config.js b/client/webpack.production.config.js new file mode 100644 index 00000000..1c9c4a76 --- /dev/null +++ b/client/webpack.production.config.js @@ -0,0 +1,65 @@ +const path = require('path'); +const webpack = require('webpack'); +const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); + +const jsLoader = { + test: /\.(js|jsx)$/, + exclude: /node_modules/, + loader: 'babel-loader', + query: { + presets: ['react'] + } +}; + +const vueLoader = { + test: /\.(vue)$/, + loader: 'vue-loader' +}; + +const scssLoader = { + test: /\.scss$/, + exclude: /node_modules/, + loader: ['css-loader', 'sass-loader'] +}; + +module.exports = { + entry: './src/index.js', + output: { + path: path.resolve(__dirname, 'dist'), + filename: 'betterdiscord.client-release.js' + }, + module: { + loaders: [jsLoader, vueLoader, scssLoader] + }, + externals: { + electron: 'window.require("electron")', + fs: 'window.require("fs")', + path: 'window.require("path")', + sparkplug: 'require("./sparkplug")' + }, + resolve: { + alias: { + vue$: path.resolve('..', 'node_modules', 'vue', 'dist', 'vue.esm.js') + }, + modules: [ + path.resolve('..', 'node_modules'), + path.resolve('..', 'common', 'modules'), + path.resolve('src', 'modules'), + path.resolve('src', 'ui'), + path.resolve('src', 'plugins'), + path.resolve('src', 'structs'), + path.resolve('src', 'builtin') + ] + }, + node: { + process: false, + __filename: false, + __dirname: false + }, + plugins: [ + new webpack.DefinePlugin({ + PRODUCTION: JSON.stringify(true) + }), + new UglifyJsPlugin() + ] +}; diff --git a/core/src/main.js b/core/src/main.js index baf0f5f3..d66c5465 100644 --- a/core/src/main.js +++ b/core/src/main.js @@ -14,7 +14,7 @@ const { BrowserWindow, dialog } = require('electron'); const { FileUtils, BDIpc, Config, WindowUtils, CSSEditor, Database } = require('./modules'); -const tests = true; +const tests = typeof PRODUCTION === 'undefined'; const _basePath = tests ? path.resolve(__dirname, '..', '..') : __dirname; const _baseDataPath = tests ? path.resolve(_basePath, 'tests') : _basePath; diff --git a/csseditor/package.json b/csseditor/package.json index 98d964ba..acdd5935 100644 --- a/csseditor/package.json +++ b/csseditor/package.json @@ -17,6 +17,7 @@ "private": false, "scripts": { "build": "webpack --progress --colors", - "watch": "webpack --progress --colors --watch" + "watch": "webpack --progress --colors --watch", + "release": "webpack --progress --colors --config=webpack.production.config.js" } } diff --git a/csseditor/webpack.production.config.js b/csseditor/webpack.production.config.js new file mode 100644 index 00000000..c7bba6f8 --- /dev/null +++ b/csseditor/webpack.production.config.js @@ -0,0 +1,44 @@ +const path = require('path'); +const webpack = require('webpack'); +const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); + +const vueLoader = { + test: /\.(vue)$/, + exclude: /node_modules/, + loader: 'vue-loader' +}; + +const scssLoader = { + test: /\.(css|scss)$/, + loader: ['css-loader', 'sass-loader'] +}; + +module.exports = { + entry: './src/index.js', + output: { + path: path.resolve(__dirname, 'dist'), + filename: 'csseditor.js' + }, + module: { + loaders: [vueLoader, scssLoader] + }, + externals: { + electron: 'window.require("electron")', + fs: 'window.require("fs")' + }, + resolve: { + alias: { + vue$: path.resolve('..', 'node_modules', 'vue', 'dist', 'vue.esm.js') + }, + modules: [ + path.resolve('..', 'node_modules'), + path.resolve('..', 'common', 'modules') + ] + }, + plugins: [ + new webpack.DefinePlugin({ + PRODUCTION: JSON.stringify(true) + }), + new UglifyJsPlugin() + ] +}; diff --git a/gulpfile.js b/gulpfile.js index 1640468f..1335ff61 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -6,6 +6,7 @@ const merge = require('gulp-merge'), copy = require('gulp-copy'), rename = require('gulp-rename'), + inject = require('gulp-inject-string'), copydeps = require('gulp-npm-copy-deps'); const mainpkg = require('./package.json'); @@ -22,7 +23,7 @@ const releasepkg = function() { const client = function() { return pump([ - gulp.src('./client/dist/*.client.js'), + gulp.src('./client/dist/*.client-release.js'), rename(`client.${clientpkg.version}.js`), gulp.dest('./release') ]); @@ -31,6 +32,7 @@ const client = function() { const core = function() { return pump([ gulp.src('./core/dist/main.js'), + inject.after("'use strict';\n", 'const PRODUCTION = true;\n'), rename(`core.${corepkg.version}.js`), gulp.dest('./release') ]); diff --git a/package-lock.json b/package-lock.json index 72858dc1..429ea27f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1496,6 +1496,45 @@ "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", "dev": true }, + "cacache": { + "version": "10.0.4", + "resolved": "https://registry.npmjs.org/cacache/-/cacache-10.0.4.tgz", + "integrity": "sha512-Dph0MzuH+rTQzGPNT9fAnrPmMmjKfST6trxJeK7NQuHRaVw24VzPRWTmg9MpcwOVQZO0E1FBICUlFeNaKPIfHA==", + "dev": true, + "requires": { + "bluebird": "3.5.1", + "chownr": "1.0.1", + "glob": "7.1.2", + "graceful-fs": "4.1.11", + "lru-cache": "4.1.2", + "mississippi": "2.0.0", + "mkdirp": "0.5.1", + "move-concurrently": "1.0.1", + "promise-inflight": "1.0.1", + "rimraf": "2.6.2", + "ssri": "5.3.0", + "unique-filename": "1.1.0", + "y18n": "4.0.0" + }, + "dependencies": { + "lru-cache": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.2.tgz", + "integrity": "sha512-wgeVXhrDwAWnIF/yZARsFnMBtdFXOg1b8RIrhilp+0iDYN4mdQcNZElDZ0e4B64BhaxeQ5zN7PMyvu7we1kPeQ==", + "dev": true, + "requires": { + "pseudomap": "1.0.2", + "yallist": "2.1.2" + } + }, + "y18n": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", + "dev": true + } + } + }, "cache-base": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", @@ -1670,6 +1709,12 @@ } } }, + "chownr": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.0.1.tgz", + "integrity": "sha1-4qdQQqlVGQi+vSW4Uj1fl2nXkYE=", + "dev": true + }, "cipher-base": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", @@ -2136,6 +2181,20 @@ "integrity": "sha1-uCeAl7m8IpNl3lxiz1/K7YtVmeU=", "dev": true }, + "copy-concurrently": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/copy-concurrently/-/copy-concurrently-1.0.5.tgz", + "integrity": "sha512-f2domd9fsVDFtaFcbaRZuYXwtdmnzqbADSwhSWYxYB/Q8zsdUUFMXVRwXGDMWmbEzAn1kdRrtI1T/KTFOL4X2A==", + "dev": true, + "requires": { + "aproba": "1.2.0", + "fs-write-stream-atomic": "1.0.10", + "iferr": "0.1.5", + "mkdirp": "0.5.1", + "rimraf": "2.6.2", + "run-queue": "1.0.3" + } + }, "copy-descriptor": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", @@ -2403,6 +2462,12 @@ "array-find-index": "1.0.2" } }, + "cyclist": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/cyclist/-/cyclist-0.2.2.tgz", + "integrity": "sha1-GzN5LhHpFKL9bW7WRHRkRE5fpkA=", + "dev": true + }, "d": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz", @@ -2671,6 +2736,12 @@ "domelementtype": "1.3.0" } }, + "duplexer": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", + "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", + "dev": true + }, "duplexer2": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", @@ -2680,6 +2751,65 @@ "readable-stream": "1.1.14" } }, + "duplexify": { + "version": "3.5.4", + "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.5.4.tgz", + "integrity": "sha512-JzYSLYMhoVVBe8+mbHQ4KgpvHpm0DZpJuL8PY93Vyv1fW7jYJ90LoXa1di/CVbJM+TgMs91rbDapE/RNIfnJsA==", + "dev": true, + "requires": { + "end-of-stream": "1.4.1", + "inherits": "2.0.3", + "readable-stream": "2.3.5", + "stream-shift": "1.0.0" + }, + "dependencies": { + "end-of-stream": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", + "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", + "dev": true, + "requires": { + "once": "1.4.0" + } + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", + "dev": true + }, + "readable-stream": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.5.tgz", + "integrity": "sha512-tK0yDhrkygt/knjowCUiWP9YdV7c5R+8cR0r/kt9ZhBU906Fs6RpQJCEilamRJj1Nx2rWI6LkW9gKqjTkshhEw==", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "2.0.0", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + } + } + }, "ecc-jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", @@ -3204,6 +3334,21 @@ "es5-ext": "0.10.38" } }, + "event-stream": { + "version": "3.3.4", + "resolved": "http://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", + "integrity": "sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE=", + "dev": true, + "requires": { + "duplexer": "0.1.1", + "from": "0.1.7", + "map-stream": "0.1.0", + "pause-stream": "0.0.11", + "split": "0.3.3", + "stream-combiner": "0.0.4", + "through": "2.3.8" + } + }, "events": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", @@ -3688,6 +3833,54 @@ "integrity": "sha1-2uRqnXj74lKSJYzB54CkHZXAN4I=", "dev": true }, + "flush-write-stream": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.0.3.tgz", + "integrity": "sha512-calZMC10u0FMUqoiunI2AiGIIUtUIvifNwkHhNupZH4cbNnW1Itkoh/Nf5HFYmDrwWPjrUxpkZT0KhuCq0jmGw==", + "dev": true, + "requires": { + "inherits": "2.0.3", + "readable-stream": "2.3.5" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", + "dev": true + }, + "readable-stream": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.5.tgz", + "integrity": "sha512-tK0yDhrkygt/knjowCUiWP9YdV7c5R+8cR0r/kt9ZhBU906Fs6RpQJCEilamRJj1Nx2rWI6LkW9gKqjTkshhEw==", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "2.0.0", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + } + } + }, "for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", @@ -3733,6 +3926,60 @@ "map-cache": "0.2.2" } }, + "from": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/from/-/from-0.1.7.tgz", + "integrity": "sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=", + "dev": true + }, + "from2": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz", + "integrity": "sha1-i/tVAr3kpNNs/e6gB/zKIdfjgq8=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "readable-stream": "2.3.5" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", + "dev": true + }, + "readable-stream": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.5.tgz", + "integrity": "sha512-tK0yDhrkygt/knjowCUiWP9YdV7c5R+8cR0r/kt9ZhBU906Fs6RpQJCEilamRJj1Nx2rWI6LkW9gKqjTkshhEw==", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "2.0.0", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + } + } + }, "fs-extra": { "version": "0.30.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz", @@ -3746,6 +3993,18 @@ "rimraf": "2.6.2" } }, + "fs-write-stream-atomic": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz", + "integrity": "sha1-tH31NJPvkR33VzHnCp3tAYnbQMk=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "iferr": "0.1.5", + "imurmurhash": "0.1.4", + "readable-stream": "1.1.14" + } + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -5315,6 +5574,16 @@ } } }, + "gulp-inject-string": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/gulp-inject-string/-/gulp-inject-string-1.1.1.tgz", + "integrity": "sha512-Q25r/25DMxCEknj4nqHhpDWFGvQQNcZwnheiDIOWhOqcSUtagbidEGe3HANUdokiiIjqkTVIyIg9hP64LKh5Tw==", + "dev": true, + "requires": { + "event-stream": "3.3.4", + "plugin-error": "0.1.2" + } + }, "gulp-merge": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/gulp-merge/-/gulp-merge-0.1.1.tgz", @@ -5986,6 +6255,12 @@ "integrity": "sha1-vjPUCsEO8ZJnAfbwii2G+/0a0+Q=", "dev": true }, + "iferr": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/iferr/-/iferr-0.1.5.tgz", + "integrity": "sha1-xg7taebY/bazEEofy8ocGS3FtQE=", + "dev": true + }, "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", @@ -7022,6 +7297,12 @@ "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=" }, + "map-stream": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", + "integrity": "sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=", + "dev": true + }, "map-visit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", @@ -7221,6 +7502,87 @@ "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" }, + "mississippi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mississippi/-/mississippi-2.0.0.tgz", + "integrity": "sha512-zHo8v+otD1J10j/tC+VNoGK9keCuByhKovAvdn74dmxJl9+mWHnx6EMsDN4lgRoMI/eYo2nchAxniIbUPb5onw==", + "dev": true, + "requires": { + "concat-stream": "1.6.0", + "duplexify": "3.5.4", + "end-of-stream": "1.4.1", + "flush-write-stream": "1.0.3", + "from2": "2.3.0", + "parallel-transform": "1.1.0", + "pump": "2.0.1", + "pumpify": "1.4.0", + "stream-each": "1.2.2", + "through2": "2.0.3" + }, + "dependencies": { + "end-of-stream": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", + "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", + "dev": true, + "requires": { + "once": "1.4.0" + } + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", + "dev": true + }, + "readable-stream": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.5.tgz", + "integrity": "sha512-tK0yDhrkygt/knjowCUiWP9YdV7c5R+8cR0r/kt9ZhBU906Fs6RpQJCEilamRJj1Nx2rWI6LkW9gKqjTkshhEw==", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "2.0.0", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, + "through2": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", + "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", + "dev": true, + "requires": { + "readable-stream": "2.3.5", + "xtend": "4.0.1" + } + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + } + } + }, "mixin-deep": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.0.tgz", @@ -7268,6 +7630,20 @@ "minimist": "0.0.8" } }, + "move-concurrently": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz", + "integrity": "sha1-viwAX9oy4LKa8fBdfEszIUxwH5I=", + "dev": true, + "requires": { + "aproba": "1.2.0", + "copy-concurrently": "1.0.5", + "fs-write-stream-atomic": "1.0.10", + "mkdirp": "0.5.1", + "rimraf": "2.6.2", + "run-queue": "1.0.3" + } + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -8086,6 +8462,55 @@ "integrity": "sha1-AQEhG6pwxLykoPY/Igbpe3368lg=", "dev": true }, + "parallel-transform": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/parallel-transform/-/parallel-transform-1.1.0.tgz", + "integrity": "sha1-1BDwZbBdojCB/NEPKIVMKb2jOwY=", + "dev": true, + "requires": { + "cyclist": "0.2.2", + "inherits": "2.0.3", + "readable-stream": "2.3.5" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", + "dev": true + }, + "readable-stream": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.5.tgz", + "integrity": "sha512-tK0yDhrkygt/knjowCUiWP9YdV7c5R+8cR0r/kt9ZhBU906Fs6RpQJCEilamRJj1Nx2rWI6LkW9gKqjTkshhEw==", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "2.0.0", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + } + } + }, "param-case": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/param-case/-/param-case-2.1.1.tgz", @@ -8241,6 +8666,15 @@ } } }, + "pause-stream": { + "version": "0.0.11", + "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", + "integrity": "sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=", + "dev": true, + "requires": { + "through": "2.3.8" + } + }, "pbkdf2": { "version": "3.0.14", "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.14.tgz", @@ -9096,6 +9530,12 @@ "through2": "0.2.3" } }, + "promise-inflight": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", + "integrity": "sha1-mEcocL8igTL8vdhoEputEsPAKeM=", + "dev": true + }, "prr": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", @@ -9141,6 +9581,17 @@ } } }, + "pumpify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/pumpify/-/pumpify-1.4.0.tgz", + "integrity": "sha512-2kmNR9ry+Pf45opRVirpNuIFotsxUGLaYqxIwuR77AYrYRMuFCz9eryHBS52L360O+NcR383CL4QYlMKPq4zYA==", + "dev": true, + "requires": { + "duplexify": "3.5.4", + "inherits": "2.0.3", + "pump": "2.0.1" + } + }, "punycode": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", @@ -9653,6 +10104,15 @@ "is-promise": "2.1.0" } }, + "run-queue": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.3.tgz", + "integrity": "sha1-6Eg5bwV9Ij8kOGkkYY4laUFh7Ec=", + "dev": true, + "requires": { + "aproba": "1.2.0" + } + }, "rx-lite": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", @@ -9712,6 +10172,35 @@ "integrity": "sha1-KBYjTiN4vdxOU1T6tcqold9xANk=", "dev": true }, + "schema-utils": { + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-0.4.5.tgz", + "integrity": "sha512-yYrjb9TX2k/J1Y5UNy3KYdZq10xhYcF8nMpAW6o3hy6Q8WSIEf9lJHG/ePnOBfziPM3fvQwfOwa13U/Fh8qTfA==", + "dev": true, + "requires": { + "ajv": "6.3.0", + "ajv-keywords": "3.1.0" + }, + "dependencies": { + "ajv": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.3.0.tgz", + "integrity": "sha1-FlCkERTvAFdMrBC4Ay2PTBSBLac=", + "dev": true, + "requires": { + "fast-deep-equal": "1.0.0", + "fast-json-stable-stringify": "2.0.0", + "json-schema-traverse": "0.3.1" + } + }, + "ajv-keywords": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.1.0.tgz", + "integrity": "sha1-rCsnk5xUPpXSwG5/f1wnvkqlQ74=", + "dev": true + } + } + }, "scss-tokenizer": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/scss-tokenizer/-/scss-tokenizer-0.2.3.tgz", @@ -9742,6 +10231,12 @@ "integrity": "sha1-kM/xnQLgcCf9dn9erT57ldHnOAw=", "dev": true }, + "serialize-javascript": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.4.0.tgz", + "integrity": "sha1-fJWFFNtqwkQ6irwGLcn3iGp/YAU=", + "dev": true + }, "set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", @@ -10090,6 +10585,15 @@ "integrity": "sha1-mHbb0qFp0xFUAtSObqYynIgWpQ0=", "dev": true }, + "split": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", + "integrity": "sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8=", + "dev": true, + "requires": { + "through": "2.3.8" + } + }, "split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", @@ -10141,6 +10645,15 @@ "tweetnacl": "0.14.5" } }, + "ssri": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/ssri/-/ssri-5.3.0.tgz", + "integrity": "sha512-XRSIPqLij52MtgoQavH/x/dU1qVKtWUAAZeOHsR9c2Ddi4XerFy3mc1alf+dLJKl9EUIm/Ht+EowFkTUOA6GAQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, "static-extend": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", @@ -10304,12 +10817,42 @@ } } }, + "stream-combiner": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz", + "integrity": "sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ=", + "dev": true, + "requires": { + "duplexer": "0.1.1" + } + }, "stream-consume": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/stream-consume/-/stream-consume-0.1.0.tgz", "integrity": "sha1-pB6tGm1ggc63n2WwYZAbbY89HQ8=", "dev": true }, + "stream-each": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/stream-each/-/stream-each-1.2.2.tgz", + "integrity": "sha512-mc1dbFhGBxvTM3bIWmAAINbqiuAk9TATcfIQC8P+/+HJefgaiTlMn2dHvkX8qlI12KeYKSQ1Ua9RrIqrn1VPoA==", + "dev": true, + "requires": { + "end-of-stream": "1.4.1", + "stream-shift": "1.0.0" + }, + "dependencies": { + "end-of-stream": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", + "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", + "dev": true, + "requires": { + "once": "1.4.0" + } + } + } + }, "stream-http": { "version": "2.8.0", "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.8.0.tgz", @@ -10367,6 +10910,12 @@ } } }, + "stream-shift": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz", + "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=", + "dev": true + }, "strict-uri-encode": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz", @@ -10885,51 +11434,27 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, - "uglify-js": { - "version": "2.8.29", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", - "integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=", + "uglify-es": { + "version": "3.3.9", + "resolved": "https://registry.npmjs.org/uglify-es/-/uglify-es-3.3.9.tgz", + "integrity": "sha512-r+MU0rfv4L/0eeW3xZrd16t4NZfK8Ld4SWVglYBb7ez5uXFWHuVRs6xCTrf1yirs9a4j4Y27nn7SRfO6v67XsQ==", "dev": true, "requires": { - "source-map": "0.5.7", - "uglify-to-browserify": "1.0.2", - "yargs": "3.10.0" + "commander": "2.13.0", + "source-map": "0.6.1" }, "dependencies": { - "camelcase": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", - "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", + "commander": { + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.13.0.tgz", + "integrity": "sha512-MVuS359B+YzaWqjCL/c+22gfryv+mCBPHAv3zyVI2GN8EY6IRP8VwtasXn8jyyhvvq84R4ImN1OKRtcbIasjYA==", "dev": true }, - "cliui": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", - "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", - "dev": true, - "requires": { - "center-align": "0.1.3", - "right-align": "0.1.3", - "wordwrap": "0.0.2" - } - }, - "wordwrap": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", - "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true - }, - "yargs": { - "version": "3.10.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", - "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", - "dev": true, - "requires": { - "camelcase": "1.2.1", - "cliui": "2.1.0", - "decamelize": "1.2.0", - "window-size": "0.1.0" - } } } }, @@ -10941,14 +11466,27 @@ "optional": true }, "uglifyjs-webpack-plugin": { - "version": "0.4.6", - "resolved": "https://registry.npmjs.org/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-0.4.6.tgz", - "integrity": "sha1-uVH0q7a9YX5m9j64kUmOORdj4wk=", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.2.4.tgz", + "integrity": "sha512-z0IbjpW8b3O/OVn+TTZN4pI29RN1zktFBXLIzzfZ+++cUtZ1ERSlLWgpE/5OERuEUs1ijVQnpYAkSlpoVmQmSQ==", "dev": true, "requires": { - "source-map": "0.5.7", - "uglify-js": "2.8.29", - "webpack-sources": "1.1.0" + "cacache": "10.0.4", + "find-cache-dir": "1.0.0", + "schema-utils": "0.4.5", + "serialize-javascript": "1.4.0", + "source-map": "0.6.1", + "uglify-es": "3.3.9", + "webpack-sources": "1.1.0", + "worker-farm": "1.6.0" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } } }, "unc-path-regex": { @@ -11009,6 +11547,24 @@ "integrity": "sha1-/+3ks2slKQaW5uFl1KWe25mOawI=", "dev": true }, + "unique-filename": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-1.1.0.tgz", + "integrity": "sha1-0F8v5AMlYIcfMOk8vnNe6iAVFPM=", + "dev": true, + "requires": { + "unique-slug": "2.0.0" + } + }, + "unique-slug": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unique-slug/-/unique-slug-2.0.0.tgz", + "integrity": "sha1-22Z258fMBimHj/GWCXx4hVrp9Ks=", + "dev": true, + "requires": { + "imurmurhash": "0.1.4" + } + }, "unique-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-1.0.0.tgz", @@ -11775,12 +12331,71 @@ "has-flag": "2.0.0" } }, + "uglify-js": { + "version": "2.8.29", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", + "integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=", + "dev": true, + "requires": { + "source-map": "0.5.7", + "uglify-to-browserify": "1.0.2", + "yargs": "3.10.0" + }, + "dependencies": { + "camelcase": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", + "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", + "dev": true + }, + "cliui": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", + "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", + "dev": true, + "requires": { + "center-align": "0.1.3", + "right-align": "0.1.3", + "wordwrap": "0.0.2" + } + }, + "yargs": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", + "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", + "dev": true, + "requires": { + "camelcase": "1.2.1", + "cliui": "2.1.0", + "decamelize": "1.2.0", + "window-size": "0.1.0" + } + } + } + }, + "uglifyjs-webpack-plugin": { + "version": "0.4.6", + "resolved": "https://registry.npmjs.org/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-0.4.6.tgz", + "integrity": "sha1-uVH0q7a9YX5m9j64kUmOORdj4wk=", + "dev": true, + "requires": { + "source-map": "0.5.7", + "uglify-js": "2.8.29", + "webpack-sources": "1.1.0" + } + }, "which-module": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", "dev": true }, + "wordwrap": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", + "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", + "dev": true + }, "yargs": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/yargs/-/yargs-8.0.2.tgz", @@ -11870,6 +12485,15 @@ "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", "dev": true }, + "worker-farm": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/worker-farm/-/worker-farm-1.6.0.tgz", + "integrity": "sha512-6w+3tHbM87WnSWnENBUvA2pxJPLhQUg5LKwUQHq3r+XPhIM+Gh2R5ycbwPCyuGbNg+lPgdcnQUhuC02kJCvffQ==", + "dev": true, + "requires": { + "errno": "0.1.7" + } + }, "wrap-ansi": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", diff --git a/package.json b/package.json index b61b6ec9..29c6f837 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "gulp": "^3.9.1", "gulp-babel": "^7.0.0", "gulp-copy": "^1.1.0", + "gulp-inject-string": "^1.1.1", "gulp-merge": "^0.1.1", "gulp-npm-copy-deps": "^1.0.2", "gulp-plumber": "^1.2.0", @@ -49,6 +50,7 @@ "node-gyp": "^3.6.2", "pump": "^2.0.0", "sass-loader": "^6.0.6", + "uglifyjs-webpack-plugin": "^1.2.4", "v-tooltip": "^2.0.0-rc.30", "vue": "^2.5.13", "vue-codemirror": "^4.0.3", @@ -71,6 +73,7 @@ "lint": "eslint -f unix client/src core/src csseditor/src", "test": "npm run build && npm run lint", "build_node-sass": "node scripts/build-node-sass.js", - "release": "npm run lint && npm run build && gulp release" + "build_release": "npm run release --prefix client && npm run build --prefix core && npm run release --prefix csseditor && npm run build --prefix installer", + "release": "npm run lint && npm run build_release && gulp release" } } From 5e8e9fa19fa8e804efb8fd556091109ad164e978 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Thu, 22 Mar 2018 02:37:30 +0000 Subject: [PATCH 14/23] CSS editor fixes --- common/modules/bdipc.js | 4 +++- csseditor/src/BDIpc.js | 28 -------------------------- csseditor/webpack.production.config.js | 2 +- gulpfile.js | 3 ++- 4 files changed, 6 insertions(+), 31 deletions(-) delete mode 100644 csseditor/src/BDIpc.js diff --git a/common/modules/bdipc.js b/common/modules/bdipc.js index 02ab2caf..09b808af 100644 --- a/common/modules/bdipc.js +++ b/common/modules/bdipc.js @@ -12,7 +12,7 @@ import { ipcRenderer } from 'electron'; const callbacks = new WeakMap(); -export default new class ClientIPC { +const ClientIPC = new class ClientIPC { constructor() { this.on('ping', () => 'pong', true); @@ -114,6 +114,8 @@ export default new class ClientIPC { } +export default ClientIPC; + /** * An IPC event. */ diff --git a/csseditor/src/BDIpc.js b/csseditor/src/BDIpc.js deleted file mode 100644 index 711a669b..00000000 --- a/csseditor/src/BDIpc.js +++ /dev/null @@ -1,28 +0,0 @@ -const { ipcRenderer } = window.require('electron'); - -export default class { - - static on(channel, cb) { - ipcRenderer.on(channel, (event, args) => cb(event, args)); - } - - static async send(channel, message) { - const __eid = Date.now().toString(); - ipcRenderer.send( - channel.startsWith('bd-') ? channel: `bd-${channel}`, - message === undefined ? { __eid } : Object.assign(message, { __eid }) - ); - - return new Promise((resolve, reject) => { - ipcRenderer.once(__eid, (event, arg) => { - if (arg.err) return reject(arg); - resolve(arg); - }); - }); - } - - static sendToDiscord(channel, message) { - this.send('bd-sendToDiscord', { channel, message }); - } - -} diff --git a/csseditor/webpack.production.config.js b/csseditor/webpack.production.config.js index c7bba6f8..8d2cd354 100644 --- a/csseditor/webpack.production.config.js +++ b/csseditor/webpack.production.config.js @@ -17,7 +17,7 @@ module.exports = { entry: './src/index.js', output: { path: path.resolve(__dirname, 'dist'), - filename: 'csseditor.js' + filename: 'csseditor-release.js' }, module: { loaders: [vueLoader, scssLoader] diff --git a/gulpfile.js b/gulpfile.js index 1335ff61..a6d5a2d2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -58,7 +58,8 @@ const index = function() { const cssEditor = function() { return pump([ - gulp.src('./csseditor/dist/**/*'), + gulp.src('./csseditor/dist/csseditor-release.js'), + rename('csseditor.js'), copy('release/csseditor', { prefix: 2 }) ]); }; From db6be20864b1c6c19a6107058b25aba78d17c5cf Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Thu, 22 Mar 2018 16:25:06 +0000 Subject: [PATCH 15/23] Use correct path for logs --- client/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/index.js b/client/src/index.js index 9e2f3ab3..759ed8ce 100644 --- a/client/src/index.js +++ b/client/src/index.js @@ -16,7 +16,7 @@ import { EmoteModule } from 'builtin'; import electron from 'electron'; import path from 'path'; -const tests = typeof PRODUCTION !== 'undefined'; +const tests = typeof PRODUCTION === 'undefined'; const ignoreExternal = false; class BetterDiscord { From 6d46ac67de1ef4d3253231e8ee6b11d255da8afc Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Thu, 22 Mar 2018 16:27:53 +0000 Subject: [PATCH 16/23] Remove SimplerFlat --- tests/ext/themes/SimplerFlat/.DS_Store | Bin 6148 -> 0 bytes tests/ext/themes/SimplerFlat/config.json | 198 ---------- tests/ext/themes/SimplerFlat/index.scss | 479 ----------------------- tests/ext/themes/SimplerFlat/vars.scss | 40 -- 4 files changed, 717 deletions(-) delete mode 100644 tests/ext/themes/SimplerFlat/.DS_Store delete mode 100644 tests/ext/themes/SimplerFlat/config.json delete mode 100644 tests/ext/themes/SimplerFlat/index.scss delete mode 100644 tests/ext/themes/SimplerFlat/vars.scss diff --git a/tests/ext/themes/SimplerFlat/.DS_Store b/tests/ext/themes/SimplerFlat/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0.content, .chat form, .chat div[class^="titleWrapper"]>div, div[class^="typing"] { - background-color: $color-medium!important; -} - - /* User list panel */ - -.channel-members-wrap, .channel-members { - background-color: $color-dark!important; -} - - /* Channel list panel */ - -div[class^="channels"], div[class^="channels"]>div[class^="flex"] { - background-color: $color-dark!important; -} - -.guild { - background-color: transparent!important; -} - -.guilds-add { - background-color: $color-very-dark!important; -} - -.guilds-add, .guilds-add-inner { - color: $color-light!important; - border-color: $color-light!important; -} - - /* Guilds list panel */ - -div#app-mount[class^="appMount"], div.guilds-wrapper { - background-color: $color-very-dark; -} - -.app.flex-vertical>div[class^="layers-"], -.app.flex-vertical>div[class^="layers-"]>div[class^="layer-"], -.app.flex-vertical>div[class^="layers-"]>div[class^="layer-"]>div[class^="flex-"] { - background-color: $color-very-dark; -} - - - /* Right settings panel */ - -.ui-standard-sidebar-view .content-region { - background-color: $color-medium!important; -} - - /* Left settings panel */ - -.ui-standard-sidebar-view .sidebar-region { - background-color: $color-dark!important; -} - - /* Friends panel */ - -#friends, #friends>div { - background-color: $color-medium!important; -} - - /* Context menus */ - -div[class^="contextMenu"] { - background-color: $color-dark!important; -} - -div[class^="contextMenu"] div[class^="itemGroup"] div[class^="item"] { - background-color: $color-dark!important; -} - -div[class^="contextMenu"] div[class^="itemGroup"] div[class^="item"]:hover { - background-color: $color-very-dark!important; -} - - /* nochannel */ - -div[class^="noChannel"] { - background-color: $color-medium!important; -} - - /* cards */ - -div[class^="row"]>div[class^="flex"]:before { - background-color: $color-dark!important; - border-color: $color-very-dark!important; -} - - /* modals */ - -div[class^="theme-light wrapper"] { - background: transparent; -} - -.form-header header, div[class^="blurb"], div[class^="expireText"] { - color: $main-text-color!important; -} - -div[class^="modal-"] form { - border-radius: 5px; -} - -div[class^="modal-"] form, .form-header, .form-inner { - background-color: $color-medium!important; -} - -div[class^="modal-"] form>div:last-child, .form-actions { - background-color: $color-dark!important; -} - - /* themed popouts */ - -.themed-popout { - background-color: $color-dark!important; -} - -.themed-popout .header, .messages-popout .message-group { - background-color: $color-medium!important; -} - - /* search results */ - -.search-results-wrap { - background-color: $color-medium!important; -} - -.search-header { - background-color: $color-dark!important; -} - -.search-result-message.hit { - background-color: $color-dark!important; - box-shadow: none!important; -} - -.search-results-wrap .channel-separator .channel-name, .search-result:before, .search-result:after { - background: transparent!important; -} - -.message-group:hover .action-buttons { - background: transparent!important; - box-shadow: none!important; -} - -.action-buttons>div { - background-color: $color-light!important; - color: $color-very-dark!important; - border-radius: 3px; -} - -.action-buttons>div>.text { - color: $color-very-dark!important; -} - - /* Various other things */ - -.popout>div>div[class^="body"], .popout>div>div[class^="footer"] { - background-color: $color-dark!important; -} - - /* Scroll bars */ - -.scroller-wrap .scroller::-webkit-scrollbar-track-piece, .bd-scroller-wrap .bd-scroller::-webkit-scrollbar-track-piece { - background-color: $color-medium!important; - background-clip:padding-box; - border:3px solid $color-light!important; - border-radius:7px; -} - -.scroller-wrap .scroller::-webkit-scrollbar-thumb, .bd-scroller-wrap .bd-scroller::-webkit-scrollbar-thumb { - background-clip:padding-box; - background-color:$color-dark!important; - border:3px solid $color-light!important; - border-radius:7px; -} - - -/* Other bits and bobs */ - -div[class^="searchBar"], .searchBar-YMJBu9 { - background-color: $color-light!important; -} - -/* message inside modal */ - -form div[class^="message"] { - background-color: $color-dark!important; -} - -/* new messages divider */ - -.messages .divider span { - background-color: $color-medium!important; -} - -/* Command autosuggest */ - -div[class^="autocomplete-"] { - background-color: $color-dark!important; -} - -div[class^="selectorSelected"] { - background-color: $color-medium!important; -} - -/* Code blocks */ - -.markup pre, .markup code { - background-color: $color-dark!important; - border-color: $color-very-dark!important; -} - -/* message accessories */ - -.message .accessory>div { - background-color: $color-dark; -} - - -/* Text stuff */ - -.app :not(div[class^="channels"]) :not(code):not(.kawaii-linenumbers):not(li):not(span):not(.user-name):not(.member-username):not(.markup):not(form):not(textarea):not(button):not(.guild):not(a):not(.discord-tag):not(.username):not(.discriminator):not(.ui-button-contents) { - color:$main-text-color!important; -} - -:not(code):not(kawaii-linenumbers):not(li):not(span):not(.markup):not(form):not(textarea) { - font-family:$global-font, Whitney, Helvetica Neue, Helvetica, Arial, sans-serif; -} - -.markup,form,textarea { - color:$chat-text-color!important; - font-family:$chat-font, Whitney, Helvetica Neue, Helvetica, Arial, sans-serif; -} - -.markup { -font-size:$chat-font-size!important; -} - -div[class^="ace_"] { - font-family: $code-font, monospace!important; -} - -code,code span,.kawaii-linenumbers,.kawaii-linenumbers li { - font-family: $code-font, Whitney, Helvetica Neue, Helvetica, Arial, sans-serif!important; - font-size: $code-font-size!important; - font-weight: $code-font-weight!important; -} - -code,.kawaii-linenumbers { - color:$code-text-color!important; -} - - -/* Emoji Picker */ - -div[class^="emojiPicker-"] div[class^="stickyHeader-"] { - background: transparent; -} - -div[class^="emojiPicker-"] { - background-color: $color-light; -} - -.search-bar.search-bar-light { - background-color: $color-light; -} - -.search-bar.search-bar-light input, .search-bar.search-bar-light input::-webkit-input-placeholder { - color: $main-text-color; -} - -.search-bar.search-bar-light input::-webkit-input-placeholder { - opacity: 0.6; -} - -.search-bar-light .search-bar-icon .icon { - filter: invert(100%); -} - -div[class^="emojiPicker-"] div[class^="scroller-"]::-webkit-scrollbar-track-piece { - background-color: $color-medium; - background-clip:padding-box; - border-radius:7px; -} - -div[class^="emojiPicker-"] div[class^="scroller-"]::-webkit-scrollbar-thumb { - background-clip:padding-box; - background-color:$color-dark!important; - border: none!important; - border-radius:7px; -} - -/* Emoji drop shadow so that dark emojis are visible on the dark background */ - -.message-group .emoji { - filter: drop-shadow(0px 0px 1px #FFF); -} - - -/* BD button */ - -.bd-settings-wrapper .bd-settings-button:not(.bd-active) { - background-color: $color-very-dark; -} - -/* BD interface */ - - - /*sidebar*/ - -.bd-sidebar-view .bd-sidebar-region { - background-color: $color-dark; -} - - /*content*/ - -.bd-sidebar-view .bd-content-region { - background-color: $color-medium; -} - - /*modals*/ - -.bd-modal .bd-modal-inner { - background-color: $color-medium; -} - - /*color picker*/ - -.bd-form-colourpicker .vc-chrome { - z-index: 1; - - & .vc-chrome-body { - background-color: $color-medium; - } -} - - - -/* Channel List stuff */ - -*[class^="colorUnread"] { - color: $main-color; -} - -div[class^="wrapperHovered"] div[class^="content"] { - background-color: $color-very-dark; -} - -*[class^="colorHovered"], *[class^="colorSelected"] { - color: #FFFFFF; - opacity: 0.8; -} - -div[class^="nameUnread"] { - color: $main-color; -} - - -/** Collapsing stuff **/ - -@if $collapsing-panels { - - /* Channels list */ - - div[class^="channels"]:not(:hover) { - width: 3em; - } - - .channel.private a { - padding-left: 0.4em; - margin-left: 0px; - } - - .private-channels .search-bar, .private-channels .btn-friends, .private-channels header { - overflow: hidden; - transition: height 0.3s; - } - - .private-channels:not(:hover) .search-bar, .private-channels:not(:hover) .btn-friends, .private-channels:not(:hover) header { - height: 0px; - font-size: 0px; - } - - div[class^="wrapperDefaultVoice"]+div, div[class^="wrapperHoveredVoice"]+div, div[class^="wrapperSelectedVoice"]+div { - padding-left: 0.5em; - } - - -/* Foldaway channel members sidebar */ - - .channel-members-wrap { - min-width:1px; - } - - .channel-members-wrap:not(:hover) { - width: 1px; - } - - .channel-members { - padding-top:0; - padding-bottom:0; - width: 100%; - } -} - -/* Compact Server List */ - -@if $compact-server-list { - - .guilds-wrapper .guilds .guild.selected:before { - margin-top: -10px; - } - - .guilds-wrapper .guilds .guild.selected { - z-index: 2; - transform: scale(1.2); - margin: 10px; - margin-left: 5px; - } - - .guilds-wrapper .guilds .guild.unread:not(.selected)::before { - margin-top: 1px; - height: 15px; - border-radius: 10px; - } - - .guilds-wrapper .guilds .guild:not(.guilds-add) { - height: 30px; - } - - .guilds-wrapper .guilds .guild:first-child { - height: 50px; - } - - .guilds-wrapper .guilds .guild.selected::before { - animation: selectserver 0.4s cubic-bezier(1, 0, 1, 0); - -webkit-animation: selectserver 0.4s cubic-bezier(1, 0, 1, 0); - } - - .guilds-wrapper .guilds .guild:not(:first-child):not(.selected) div:not(.badge) { - transition: height 0.5s; - -webkit-transition: height 0.5s; - } - - .guilds-wrapper .guilds .guild:not(:first-child):not(.selected):hover div:not(.badge) { - height: 50px; - transform: scale(1.2); - -webkit-transform: scale(1.2); - transition: height 0.5s; - -webkit-transition: height 0.5s; - margin-bottom: 0px; - } - - .guilds-wrapper .guilds .guild:not(:first-child):not(.selected):hover { - z-index: 3; - } - - .guilds-wrapper .guilds .guild .badge { - bottom: 14px; - } - - .guilds-wrapper .guilds .guild:not(:first-child):not(.selected):hover .badge { - transform:scale(1.35); - bottom: 19px; - right: -7px; - } -} diff --git a/tests/ext/themes/SimplerFlat/vars.scss b/tests/ext/themes/SimplerFlat/vars.scss deleted file mode 100644 index 994ba0f4..00000000 --- a/tests/ext/themes/SimplerFlat/vars.scss +++ /dev/null @@ -1,40 +0,0 @@ - - -/* Theme */ -$main-color: #00FAFA !default; /*Main general theme color (#00FAFA Light Cyan by default)*/ - -/* Text */ -$main-text-color: #FAFAFA !default; /*The colour of text onscreen in most places (#FAFAFA light grey by default)*/ -$chat-text-color: #FFFFFF !default; /*The chat will be this color*/ -$code-text-color: #CCCCCC !default; /*The non-syntax hilighted bits in code blocks will be this color*/ - -/* Background */ -$color-light: #3E3E3E !default; /*These are all colors used in the background*/ -$color-medium: #2E2E2E !default; -$color-dark: #1E1E1E !default; -$color-very-dark: #0E0E0E !default; - -/* Tinting */ - -$tint-color: $main-color !default; -$tint-strength: 0% !default; - -/* Font */ -$global-font: 'Whitney' !default; /*This font will appear most places*/ -$chat-font: 'Whitney' !default; /*This font will appear in the main chat*/ -$chat-font-size: 15px !default; -$code-font: monospace !default; /*This will appear in code blocks*/ -$code-font-size: 14px !default; -$code-font-weight: 700 !default; - -/* other */ - -$collapsing-panels: false !default; -$compact-server-list: false !default; - -/* do some stuff with the vars */ - -$color-light: mix($tint-color, $color-light, $tint-strength); -$color-medium: mix($tint-color, $color-medium, $tint-strength); -$color-dark: mix($tint-color, $color-dark, $tint-strength); -$color-very-dark: mix($tint-color, $color-very-dark, $tint-strength); From a3eeee9b57221c10ebf8c1da88262b252deca108 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Thu, 22 Mar 2018 16:38:09 +0000 Subject: [PATCH 17/23] =?UTF-8?q?Store=20content=20config=20with=20it?= =?UTF-8?q?=E2=80=99s=20type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/modules/content.js | 5 ++--- client/src/modules/contentmanager.js | 25 +++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/client/src/modules/content.js b/client/src/modules/content.js index ce2047fd..ebd85c33 100644 --- a/client/src/modules/content.js +++ b/client/src/modules/content.js @@ -78,10 +78,9 @@ export default class Content { */ async saveConfiguration() { try { - Database.insertOrUpdate({ type: 'contentconfig', $or: [{ id: this.id }, { name: this.name }] }, { - type: 'contentconfig', + Database.insertOrUpdate({ type: `${this.type}-config`, id: this.id }, { + type: `${this.type}-config`, id: this.id, - name: this.name, enabled: this.enabled, config: this.settings.strip().settings, data: this.data diff --git a/client/src/modules/contentmanager.js b/client/src/modules/contentmanager.js index 55fcb18e..8316da2d 100644 --- a/client/src/modules/contentmanager.js +++ b/client/src/modules/contentmanager.js @@ -39,6 +39,27 @@ export default class { return this._localContent ? this._localContent : (this._localContent = []); } + /** + * The type of content this content manager manages. + */ + static get contentType() { + return undefined; + } + + /** + * The name of this content manager. + */ + static get moduleName() { + return undefined; + } + + /** + * The path used to store this content manager's content. + */ + static get pathId() { + return undefined; + } + /** * Local path for content. * @return {String} @@ -100,7 +121,7 @@ export default class { const directories = await FileUtils.listDirectory(this.contentPath); for (let dir of directories) { - // If content is already loaded this should resolve. + // If content is already loaded this should resolve if (this.getContentByDirName(dir)) continue; try { @@ -185,7 +206,7 @@ export default class { try { const id = readConfig.info.id || readConfig.info.name.toLowerCase().replace(/[^a-zA-Z0-9-]/g, '-').replace(/--/g, '-'); - const readUserConfig = await Database.find({ type: 'contentconfig', id }); + const readUserConfig = await Database.find({ type: `${this.contentType}-config`, id }); if (readUserConfig.length) { userConfig.enabled = readUserConfig[0].enabled || false; userConfig.config = readUserConfig[0].config; From eaeae7ad9808da3d3e4e3c13ba709df296ddec8a Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Thu, 22 Mar 2018 16:41:20 +0000 Subject: [PATCH 18/23] Use a warning when settings failed to load --- client/src/modules/contentmanager.js | 3 +-- client/src/modules/settings.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/client/src/modules/contentmanager.js b/client/src/modules/contentmanager.js index 8316da2d..88771d21 100644 --- a/client/src/modules/contentmanager.js +++ b/client/src/modules/contentmanager.js @@ -214,8 +214,7 @@ export default class { } } catch (err) { // We don't care if this fails it either means that user config doesn't exist or there's something wrong with it so we revert to default config - Logger.info(this.moduleName, `Failed reading config for ${this.contentType} ${readConfig.info.name} in ${dirName}`); - Logger.err(this.moduleName, err); + Logger.warn(this.moduleName, [`Failed reading config for ${this.contentType} ${readConfig.info.name} in ${dirName}`, err]); } userConfig.config = defaultConfig.clone({ settings: userConfig.config }); diff --git a/client/src/modules/settings.js b/client/src/modules/settings.js index f382ec0d..88d4269c 100644 --- a/client/src/modules/settings.js +++ b/client/src/modules/settings.js @@ -61,7 +61,7 @@ export default new class Settings { } catch (err) { // There was an error loading settings // This probably means that the user doesn't have any settings yet - Logger.err('Settings', err); + Logger.warn('Settings', ['Failed to load internal settings', err]); } } From 66eee86eb3f2aa244390bcc011d240c6ec2000bc Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Thu, 22 Mar 2018 16:46:42 +0000 Subject: [PATCH 19/23] Fix cloning settings sets with schemes --- client/src/structs/settings/settingsscheme.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/client/src/structs/settings/settingsscheme.js b/client/src/structs/settings/settingsscheme.js index 2d4a14f6..d0201660 100644 --- a/client/src/structs/settings/settingsscheme.js +++ b/client/src/structs/settings/settingsscheme.js @@ -15,12 +15,6 @@ export default class SettingsScheme { constructor(args) { this.args = args.args || args; - this.args.settings = this.settings.map(({ category, settings }) => ({ - category, settings: settings.map(({ id, value }) => ({ - id, value - })) - })); - Object.freeze(this); } From 6bb8c1885763916bb2723d6a4bf792a2cc4ffedc Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Thu, 22 Mar 2018 17:13:47 +0000 Subject: [PATCH 20/23] Update repository URL --- client/package.json | 2 +- core/package.json | 2 +- csseditor/package.json | 2 +- installer/package.json | 2 +- package.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/package.json b/client/package.json index 6fb49e30..e1d5d03c 100644 --- a/client/package.json +++ b/client/package.json @@ -12,7 +12,7 @@ ], "repository": { "type": "git", - "url": "https://github.com/Jiiks/BetterDiscordApp.git" + "url": "https://github.com/JsSucks/BetterDiscordApp.git" }, "private": false, "scripts": { diff --git a/core/package.json b/core/package.json index 99f75df3..a6151d2d 100644 --- a/core/package.json +++ b/core/package.json @@ -12,7 +12,7 @@ ], "repository": { "type": "git", - "url": "https://github.com/Jiiks/BetterDiscordApp.git" + "url": "https://github.com/JsSucks/BetterDiscordApp.git" }, "private": false, "scripts": { diff --git a/csseditor/package.json b/csseditor/package.json index acdd5935..1692bb58 100644 --- a/csseditor/package.json +++ b/csseditor/package.json @@ -12,7 +12,7 @@ ], "repository": { "type": "git", - "url": "https://github.com/Jiiks/BetterDiscordApp.git" + "url": "https://github.com/JsSucks/BetterDiscordApp.git" }, "private": false, "scripts": { diff --git a/installer/package.json b/installer/package.json index 0cfd724f..89ba35ff 100644 --- a/installer/package.json +++ b/installer/package.json @@ -12,7 +12,7 @@ ], "repository": { "type": "git", - "url": "https://github.com/Jiiks/BetterDiscordApp.git" + "url": "https://github.com/JsSucks/BetterDiscordApp.git" }, "private": false, "scripts": { diff --git a/package.json b/package.json index 29c6f837..7d86c9fd 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ ], "repository": { "type": "git", - "url": "https://github.com/Jiiks/BetterDiscordApp.git" + "url": "https://github.com/JsSucks/BetterDiscordApp.git" }, "private": false, "dependencies": { From ddfd0653acece76040f800e8f563d25e56ad4912 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Sat, 24 Mar 2018 16:06:34 +0000 Subject: [PATCH 21/23] Fix emote injection --- client/src/ui/vueinjector.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/ui/vueinjector.js b/client/src/ui/vueinjector.js index 97371af9..e1703f99 100644 --- a/client/src/ui/vueinjector.js +++ b/client/src/ui/vueinjector.js @@ -16,7 +16,7 @@ export default class { * Creates a new Vue object and mounts it in the passed element. * @param {HTMLElement} root The element to mount the new Vue object at * @param {Object} options Options to pass to Vue - * @param {BdNode} bdnode The element to append to + * @param {BdNode} bdnode The element to append * @return {Vue} */ static inject(root, options, bdnode) { @@ -24,7 +24,7 @@ export default class { const vue = new Vue(options); - vue.$mount(bdnode || root); + vue.$mount(bdnode ? bdnode.element : root); return vue; } From 9e229a1c0f467367e15cb6f60767a9439c2e2dcf Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Sat, 24 Mar 2018 16:13:24 +0000 Subject: [PATCH 22/23] Cleanup profile badges --- client/src/ui/profilebadges.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/client/src/ui/profilebadges.js b/client/src/ui/profilebadges.js index 008bb448..41905b79 100644 --- a/client/src/ui/profilebadges.js +++ b/client/src/ui/profilebadges.js @@ -64,11 +64,10 @@ export default class extends EventListener { const wrapperParent = usernameWrapper.parentElement; if (!wrapperParent || wrapperParent.children.length < 2) return; wrapperParent.insertBefore(root, wrapperParent.children[1]); - const { developer, contributor, webdev } = c; VueInjector.inject(root, { components: { BdMessageBadge }, - data: { developer, contributor, webdev }, - template: '' + data: { c }, + template: '' }); } @@ -79,11 +78,10 @@ export default class extends EventListener { if (!memberUsername) return; const root = document.createElement('span'); memberUsername.append(root); - const { developer, contributor, webdev } = c; VueInjector.inject(root, { components: { BdMessageBadge }, - data: { developer, contributor, webdev }, - template: '' + data: { c }, + template: '' }); } @@ -100,8 +98,6 @@ export default class extends EventListener { root = document.querySelector('[class*="headerInfo"]'); } - const { developer, contributor, webdev } = c; - VueInjector.inject(root, { components: { BdBadge }, data: { hasBadges, c }, From 545b72cc3ee0223b116426e542b04b37f3257569 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Sun, 25 Mar 2018 02:18:40 +0100 Subject: [PATCH 23/23] Refactor logger (use util.inspect) and fix CSS editor not awaiting settings saving --- client/src/modules/csseditor.js | 10 ++++++---- client/webpack.config.js | 1 + client/webpack.production.config.js | 1 + common/modules/logger.js | 20 +++++--------------- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/client/src/modules/csseditor.js b/client/src/modules/csseditor.js index 5dbd1846..ac3fdbc4 100644 --- a/client/src/modules/csseditor.js +++ b/client/src/modules/csseditor.js @@ -42,7 +42,7 @@ export default new class { ClientIPC.on('bd-save-scss', async (e, scss) => { await this.updateScss(scss); await this.save(); - }); + }, true); this.liveupdate = Settings.getSetting('css', 'default', 'live-update'); this.liveupdate.on('setting-updated', event => { @@ -98,18 +98,20 @@ export default new class { /** * Save css to file. + * @return {Promise} */ - async save() { - Settings.saveSettings(); + save() { + return Settings.saveSettings(); } /** * Save current editor bounds. * @param {Rectangle} bounds Editor bounds + * @return {Promise} */ saveEditorBounds(bounds) { this.editor_bounds = bounds; - Settings.saveSettings(); + return Settings.saveSettings(); } /** diff --git a/client/webpack.config.js b/client/webpack.config.js index e88c1cea..8821001e 100644 --- a/client/webpack.config.js +++ b/client/webpack.config.js @@ -34,6 +34,7 @@ module.exports = { electron: 'window.require("electron")', fs: 'window.require("fs")', path: 'window.require("path")', + node_utils: 'window.require("util")', sparkplug: 'require("../../core/dist/sparkplug")' }, resolve: { diff --git a/client/webpack.production.config.js b/client/webpack.production.config.js index 1c9c4a76..e200a115 100644 --- a/client/webpack.production.config.js +++ b/client/webpack.production.config.js @@ -35,6 +35,7 @@ module.exports = { electron: 'window.require("electron")', fs: 'window.require("fs")', path: 'window.require("path")', + node_utils: 'window.require("util")', sparkplug: 'require("./sparkplug")' }, resolve: { diff --git a/common/modules/logger.js b/common/modules/logger.js index 6f21848d..8c12fef8 100644 --- a/common/modules/logger.js +++ b/common/modules/logger.js @@ -10,6 +10,7 @@ import { Vendor } from 'modules'; import { FileUtils } from './utils'; +import node_utils from 'node_utils'; export const logLevels = { 'log': 'log', @@ -35,26 +36,15 @@ export default class Logger { log(module, message, level = 'log') { level = Logger.parseLevel(level); - if (typeof message === 'object' && !(message instanceof Array)) { - console[level]('[%cBetter%cDiscord:%s]', 'color: #3E82E5', '', `${module}${level === 'debug' ? '|DBG' : ''}`, message); - let message_string = message.toString(); - if (message_string === '[object Object]') - message_string += ' ' + JSON.stringify(message, null, 4); - - this.logs.push(`${level.toUpperCase()} : [${Logger.timestamp}|${module}] ${message_string}${message_string === '[object Object]' ? ' ' + JSON.stringify(message, null, 4) : ''}`); - - if (this.file) - FileUtils.appendToFile(this.file, `${level.toUpperCase()} : [${Logger.timestamp}|${module}] ${message_string}${message_string === '[object Object]' ? ' ' + JSON.stringify(message, null, 4) : ''}\n`); - - return; - } message = typeof message === 'object' && message instanceof Array ? message : [message]; console[level]('[%cBetter%cDiscord:%s]', 'color: #3E82E5', '', `${module}${level === 'debug' ? '|DBG' : ''}`, ...message); - this.logs.push(`${level.toUpperCase()} : [${Logger.timestamp}|${module}] ${message.join(' ')}`); + + const message_string = message.map(m => typeof m === 'string' ? m : node_utils.inspect(m)).join(' '); + this.logs.push(`${level.toUpperCase()} : [${Logger.timestamp}|${module}] ${message_string}`); if (this.file) - FileUtils.appendToFile(this.file, `${level.toUpperCase()} : [${Logger.timestamp}|${module}] ${message.join(' ')}\n`); + FileUtils.appendToFile(this.file, `${level.toUpperCase()} : [${Logger.timestamp}|${module}] ${message_string}\n`); } logError(err) {