forked from Jiiks/BetterDiscordApp
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #284 from JsSucks/installer-compliance
Installer compliance
- Loading branch information
Showing
33 changed files
with
5,169 additions
and
3,357 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ user.config.json | |
/.vs | ||
/npm-debug.log | ||
/tests/ext/extensions | ||
/tests/userdata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* BetterDiscord Editor Module | ||
* Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks | ||
* All rights reserved. | ||
* 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. | ||
*/ | ||
|
||
import Module from './imodule'; | ||
import { DOM } from 'ui'; | ||
|
||
export default new class extends Module { | ||
|
||
get name() { return 'Editor' } | ||
get delay() { return false; } | ||
|
||
setInitialState(state) { | ||
return { | ||
editorBounds: undefined | ||
}; | ||
} | ||
|
||
initialize() { | ||
super.initialize(); | ||
(async () => { | ||
try { | ||
// TODO this is temporary | ||
const userScss = await this.send('readDataFile', 'user.scss'); | ||
const compiled = await this.send('compileSass', { data: userScss }); | ||
this.injectStyle('customcss', compiled.css.toString()); | ||
} catch (err) { | ||
console.warn('SCSS Compilation error', err); | ||
} | ||
})(); | ||
} | ||
|
||
events(ipc) { | ||
ipc.on('editor-runScript', (e, script) => { | ||
try { | ||
new Function(script)(); | ||
e.reply('ok'); | ||
} catch (err) { | ||
e.reply({ err: err.stack || err }); | ||
} | ||
}); | ||
|
||
ipc.on('editor-injectStyle', (e, { id, style }) => { | ||
this.injectStyle(id, style); | ||
e.reply('ok'); | ||
}); | ||
} | ||
|
||
injectStyle(id, style) { | ||
return DOM.injectStyle(style, `userstyle-${id}`); | ||
} | ||
|
||
/** | ||
* Show editor, flashes if already visible. | ||
*/ | ||
async show() { | ||
await this.send('editor-open', this.state.editorBounds); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* BetterDiscord Module Base | ||
* Copyright (c) 2015-present JsSucks - https://github.com/JsSucks | ||
* All rights reserved. | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* Base Module that every non-static module should extend | ||
*/ | ||
|
||
import { ClientLogger as Logger, ClientIPC } from 'common'; | ||
|
||
export default class Module { | ||
|
||
constructor(args) { | ||
this.__ = { | ||
state: args || {}, | ||
args | ||
}; | ||
this.setState = this.setState.bind(this); | ||
|
||
if (this.delay) { // If delay is set then module is set to load delayed from modulemanager | ||
this.initialize = this.initialize.bind(this); | ||
this.init = this.initialize; | ||
} else { | ||
this.initialize(); | ||
this.init = () => { }; | ||
} | ||
} | ||
|
||
initialize() { | ||
if (this.bindings) this.bindings(); | ||
if (this.setInitialState) this.setState(this.setInitialState(this.state)); | ||
if (this.events) this.events(ClientIPC); | ||
} | ||
|
||
setState(newState) { | ||
const oldState = this.state; | ||
Object.assign(this.state, newState); | ||
if (this.stateChanged) this.stateChanged(oldState, newState); | ||
} | ||
|
||
set args(t) { } | ||
get args() { return this.__.args; } | ||
|
||
set state(state) { return this.__.state = state; } | ||
get state() { return this.__.state; } | ||
|
||
async send(channel, message) { | ||
return ClientIPC.send(channel, message); | ||
} | ||
|
||
log(msg) { | ||
Logger.log(this.name, msg); | ||
} | ||
|
||
warn(msg) { | ||
Logger.log(this.name, msg); | ||
} | ||
|
||
err(msg) { | ||
Logger.log(this.name, msg); | ||
} | ||
|
||
info(msg) { | ||
Logger.log(this.name, msg); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.