mirror of
https://github.com/Lightcord/Lightcord.git
synced 2025-04-12 00:55:40 +02:00
so uhhh
This commit is contained in:
parent
46b2f02af1
commit
04dbcb20a0
File diff suppressed because one or more lines are too long
2
BetterDiscordApp/js/main.min.js
vendored
2
BetterDiscordApp/js/main.min.js
vendored
File diff suppressed because one or more lines are too long
@ -89,13 +89,14 @@ export const settings = {
|
|||||||
|
|
||||||
/** Lightcord */
|
/** Lightcord */
|
||||||
"Disable BetterDiscord": {id: "bd-disable", info: "Disable Betterdiscord (plugins, themes, etc) (Not implemented).", implemented: false, hidden: false, cat: "lightcord", category: "Lightcord"},
|
"Disable BetterDiscord": {id: "bd-disable", info: "Disable Betterdiscord (plugins, themes, etc) (Not implemented).", implemented: false, hidden: false, cat: "lightcord", category: "Lightcord"},
|
||||||
"Blur Personnal Informations":{id: "lightcord-6", info: "Blur sensitive informations like email, payment infos and more.", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
|
"Blur Personal Information": {id: "lightcord-6", info: "Blur sensitive informations like email, payment infos and more.", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
|
||||||
"Calling Ring Beat": {id: "lightcord-2", info: "Enable Discord's special calling beat.", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
|
"Calling Ring Beat": {id: "lightcord-2", info: "Enable Discord's special calling beat.", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
|
||||||
"Developer Options": {id: "lightcord-1", info: "Enable Discord's & Lightcord's Internal Developer Options. This allow the \"Experiments\" tab, the \"Developer Options\" tab and the \"Api Components\" tab.", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
|
"Developer Options": {id: "lightcord-1", info: "Enable Discord's & Lightcord's Internal Developer Options. This allow the \"Experiments\" tab, the \"Developer Options\" tab and the \"Api Components\" tab.", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
|
||||||
"Ad Block": {id: "lightcord-4", info: "Block any BOT that dms you with an invite link. Even in an embed.", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
|
"Ad Block": {id: "lightcord-4", info: "Block any BOT that dms you with an invite link. Even in an embed.", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
|
||||||
"Enable Lightcord Servers": {id: "lightcord-5", info: "Enable Lightcord's servers. Disabling this will disable custom badges.", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
|
"Enable Lightcord Servers": {id: "lightcord-5", info: "Enable Lightcord's servers. Disabling this will disable custom badges.", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
|
||||||
"Disable typing": {id: "lightcord-7", info: "Don't let other see you're typing.", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
|
"Disable typing": {id: "lightcord-7", info: "Don't let other see you're typing.", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
|
||||||
"Lightcord Tabs": {id: "lightcord-8", info: "Allows you to launch multiple instances of Lightcord in the same window (EXPERIMENTAL).", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
|
"Lightcord Tabs": {id: "lightcord-8", info: "Allows you to launch multiple instances of Lightcord in the same window (EXPERIMENTAL).", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
|
||||||
|
"No Window Bounds": {id: "no_window_bound", info: "Disable Window Bounds. Can be useful if you use a window manager.", implemented: true, hidden: process.platform == "linux", cat: "lightcord", category: "Lightcord"},
|
||||||
|
|
||||||
/** Lightcord Window */
|
/** Lightcord Window */
|
||||||
"Always-on-Top": {id: "lightcord-3", info: "Enable window's Always-on-Top mode, where Lightcord stays on top of other applications.", implemented: true, hidden: false, cat: "lightcord", category: "Window"},
|
"Always-on-Top": {id: "lightcord-3", info: "Enable window's Always-on-Top mode, where Lightcord stays on top of other applications.", implemented: true, hidden: false, cat: "lightcord", category: "Window"},
|
||||||
@ -147,6 +148,7 @@ export const defaultCookie = {
|
|||||||
"lightcord-6": true,
|
"lightcord-6": true,
|
||||||
"lightcord-7": false,
|
"lightcord-7": false,
|
||||||
"lightcord-8": false,
|
"lightcord-8": false,
|
||||||
|
"no_window_bound": false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ export default new class V2_SettingsPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateSettings(id, enabled, sidebar) {
|
updateSettings(id, enabled, sidebar) {
|
||||||
if(!["lightcord-8"].includes(id))settingsCookie[id] = enabled;
|
if(!["lightcord-8", "no_window_bound"].includes(id))settingsCookie[id] = enabled;
|
||||||
|
|
||||||
if (id == "bda-gs-2") {
|
if (id == "bda-gs-2") {
|
||||||
if (enabled) DOM.addClass(document.body, "bd-minimal");
|
if (enabled) DOM.addClass(document.body, "bd-minimal");
|
||||||
@ -266,6 +266,13 @@ export default new class V2_SettingsPanel {
|
|||||||
remote.app.relaunch()
|
remote.app.relaunch()
|
||||||
remote.app.exit()
|
remote.app.exit()
|
||||||
}
|
}
|
||||||
|
if (id === "no_window_bound"){
|
||||||
|
let appSettings = remote.getGlobal("appSettings")
|
||||||
|
appSettings.set("NO_WINDOWS_BOUND", enabled)
|
||||||
|
appSettings.save()
|
||||||
|
remote.app.relaunch()
|
||||||
|
remote.app.exit()
|
||||||
|
}
|
||||||
|
|
||||||
this.saveSettings();
|
this.saveSettings();
|
||||||
}
|
}
|
||||||
@ -327,6 +334,7 @@ export default new class V2_SettingsPanel {
|
|||||||
section.settings.map(setting => {
|
section.settings.map(setting => {
|
||||||
let isChecked = settingsCookie[setting.id]
|
let isChecked = settingsCookie[setting.id]
|
||||||
if(setting.id === "lightcord-8")isChecked = appSettings.get("isTabs", false);
|
if(setting.id === "lightcord-8")isChecked = appSettings.get("isTabs", false);
|
||||||
|
if(setting.id === "no_window_bound")isChecked = appSettings.get("NO_WINDOWS_BOUND", false)
|
||||||
let returnValue = BDV2.react.createElement(Switch, {id: setting.id, key: setting.id, data: setting, checked: isChecked, onChange: (id, checked) => {
|
let returnValue = BDV2.react.createElement(Switch, {id: setting.id, key: setting.id, data: setting, checked: isChecked, onChange: (id, checked) => {
|
||||||
this.onChange(id, checked, sidebar);
|
this.onChange(id, checked, sidebar);
|
||||||
}})
|
}})
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,7 +1,11 @@
|
|||||||
export default function cloneNullProto<Obj=any>(obj:Obj):Obj{ // recreate object without __proto__
|
/**
|
||||||
let o = Object.create(null)
|
* Recreate the given object without the __proto__. Useful for better formatting when output in console.
|
||||||
Object.keys(obj).forEach(k => {
|
* @param obj The object to recreate
|
||||||
o[k] = obj[k]
|
*/
|
||||||
})
|
export default function cloneNullProto<Obj=any>(obj:Obj):Obj{
|
||||||
return o
|
let o = Object.create(null)
|
||||||
|
Object.keys(obj).forEach(k => {
|
||||||
|
o[k] = obj[k]
|
||||||
|
})
|
||||||
|
return o
|
||||||
}
|
}
|
@ -19,12 +19,19 @@ async function processNextDir(dir, zip, bpath, platform){
|
|||||||
.map(async file => {
|
.map(async file => {
|
||||||
let path = __path.join(dir, file.name)
|
let path = __path.join(dir, file.name)
|
||||||
if(file.isDirectory()){
|
if(file.isDirectory()){
|
||||||
return await processNextDir(path, zip, bpath)
|
return await processNextDir(path, zip, bpath, platform)
|
||||||
}else if(file.isFile()){
|
}else if(file.isFile()){
|
||||||
console.log(file.name)
|
if(!path.includes("node_modules")){
|
||||||
if((file.name.endsWith("_linux.node") && platform === "win") || (file.name.endsWith(".node") && !file.name.endsWith("_linux.node") && platform === "lin")){
|
if(platform === "win"){
|
||||||
return
|
if(file.name.endsWith("_linux.node"))return
|
||||||
|
}else if(platform === "lin"){
|
||||||
|
if(file.name.endsWith(".node")){
|
||||||
|
if(!file.name.endsWith("_linux.node"))return
|
||||||
|
}
|
||||||
|
if(file.name.endsWith(".dll"))return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
console.log("Adding "+file.name+" to "+platform)
|
||||||
let stat = fs.statSync(path)
|
let stat = fs.statSync(path)
|
||||||
zip.addBuffer(await fsAsync.readFile(path), __path.relative(bpath, path), {
|
zip.addBuffer(await fsAsync.readFile(path), __path.relative(bpath, path), {
|
||||||
mode: stat.mode,
|
mode: stat.mode,
|
||||||
|
53
build.js
53
build.js
@ -3,7 +3,6 @@ const path = require("path")
|
|||||||
const terser = require("terser")
|
const terser = require("terser")
|
||||||
const util = require("util")
|
const util = require("util")
|
||||||
|
|
||||||
/** Super noisy if production is on. */
|
|
||||||
const production = true
|
const production = true
|
||||||
|
|
||||||
let fs = require("fs")
|
let fs = require("fs")
|
||||||
@ -23,14 +22,15 @@ async function main(){
|
|||||||
await fs.promises.mkdir(__dirname+"/distApp/dist", {"recursive": true})
|
await fs.promises.mkdir(__dirname+"/distApp/dist", {"recursive": true})
|
||||||
|
|
||||||
console.info("Executing command `npm run compile`")
|
console.info("Executing command `npm run compile`")
|
||||||
//console.log(child_process.execSync("npm run compile", {encoding: "binary"}))
|
console.log(child_process.execSync("npm run compile", {encoding: "binary"}))
|
||||||
|
|
||||||
let startDir = path.join(__dirname, "./dist")
|
let startDir = path.join(__dirname, "./dist")
|
||||||
let newDir = path.join(__dirname, "./distApp/dist")
|
let newDir = path.join(__dirname, "./distApp/dist")
|
||||||
console.info("No error detected. Copying files from "+startDir+".")
|
console.info("No error detected. Copying files from "+startDir+".")
|
||||||
await fs.promises.mkdir(startDir, {recursive: true})
|
await fs.promises.mkdir(startDir, {recursive: true})
|
||||||
|
|
||||||
async function processNextDir(folder, folders, predicate, compile){
|
async function processNextDir(folder, folders, predicate, compile, ignoreModules){
|
||||||
|
if(typeof ignoreModules === "undefined")ignoreModules = false
|
||||||
for(let file of fs.readdirSync(folder, {withFileTypes: true})){
|
for(let file of fs.readdirSync(folder, {withFileTypes: true})){
|
||||||
if(file.isFile()){
|
if(file.isFile()){
|
||||||
let filepath = path.join(folder, file.name)
|
let filepath = path.join(folder, file.name)
|
||||||
@ -40,6 +40,7 @@ async function main(){
|
|||||||
await fs.promises.copyFile(filepath, filepath.replace(folders.startDir, folders.newDir))
|
await fs.promises.copyFile(filepath, filepath.replace(folders.startDir, folders.newDir))
|
||||||
}
|
}
|
||||||
}else if(file.isDirectory()){
|
}else if(file.isDirectory()){
|
||||||
|
if(ignoreModules && file.name === "node_modules")continue
|
||||||
await fs.promises.mkdir(path.join(folder, file.name).replace(folders.startDir, folders.newDir), {recursive: true})
|
await fs.promises.mkdir(path.join(folder, file.name).replace(folders.startDir, folders.newDir), {recursive: true})
|
||||||
await processNextDir(path.join(folder, file.name), ...Array.from(arguments).slice(1))
|
await processNextDir(path.join(folder, file.name), ...Array.from(arguments).slice(1))
|
||||||
}
|
}
|
||||||
@ -66,16 +67,36 @@ async function main(){
|
|||||||
startDir: path.join(__dirname, "modules"),
|
startDir: path.join(__dirname, "modules"),
|
||||||
newDir: path.join(__dirname, "distApp", "modules")
|
newDir: path.join(__dirname, "distApp", "modules")
|
||||||
}, ((filepath) => filepath.endsWith(".js") && (!production ? !filepath.includes("node_modules") : true)), async (filepath, newpath) => {
|
}, ((filepath) => filepath.endsWith(".js") && (!production ? !filepath.includes("node_modules") : true)), async (filepath, newpath) => {
|
||||||
|
if(filepath.includes("node_modules"))return // don't minify node_modules, and don't include them at all. Installing later
|
||||||
console.info(`Minifying ${filepath} to ${newpath}`)
|
console.info(`Minifying ${filepath} to ${newpath}`)
|
||||||
await fs.promises.writeFile(newpath, terser.minify(await fs.promises.readFile(filepath, "utf8")).code, "utf8")
|
await fs.promises.writeFile(newpath, terser.minify(await fs.promises.readFile(filepath, "utf8")).code, "utf8")
|
||||||
}).then(() => {
|
}, true).then(() => {
|
||||||
console.info(`Copied files and minified them from ${path.join(__dirname, "modules")}.`)
|
console.info(`Copied files and minified them from ${path.join(__dirname, "modules")}.`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
await Promise.all((await fs.promises.readdir(path.join(__dirname, "distApp", "modules"))).map(async mdl => {
|
||||||
|
let dir = path.join(__dirname, "distApp", "modules", mdl)
|
||||||
|
|
||||||
|
if(!fs.existsSync(path.join(dir, "package.json"))){
|
||||||
|
if(mdl === "discord_desktop_core"){
|
||||||
|
dir = path.join(dir, "core")
|
||||||
|
}else{
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.info(`Installing modules for ${mdl}`)
|
||||||
|
console.log(child_process.execSync("npm install --only=prod", {
|
||||||
|
encoding: "binary",
|
||||||
|
cwd: dir
|
||||||
|
}))
|
||||||
|
}))
|
||||||
|
|
||||||
await processNextDir(path.join(__dirname, "LightcordApi"), {
|
await processNextDir(path.join(__dirname, "LightcordApi"), {
|
||||||
startDir: path.join(__dirname, "LightcordApi"),
|
startDir: path.join(__dirname, "LightcordApi"),
|
||||||
newDir: path.join(__dirname, "distApp", "LightcordApi")
|
newDir: path.join(__dirname, "distApp", "LightcordApi")
|
||||||
}, ((filepath) => filepath.endsWith(".js") && (!production ? !filepath.includes("node_modules") : true)), async (filepath, newpath) => {
|
}, ((filepath) => filepath.endsWith(".js") && (!production ? !filepath.includes("node_modules") : true)), async (filepath, newpath) => {
|
||||||
|
if(filepath.includes("node_modules"))return // don't minify node_modules, and don't include them at all. Installing later
|
||||||
console.info(`Minifying ${filepath} to ${newpath}`)
|
console.info(`Minifying ${filepath} to ${newpath}`)
|
||||||
await fs.promises.writeFile(newpath, terser.minify(await fs.promises.readFile(filepath, "utf8")).code, "utf8")
|
await fs.promises.writeFile(newpath, terser.minify(await fs.promises.readFile(filepath, "utf8")).code, "utf8")
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
@ -83,13 +104,20 @@ async function main(){
|
|||||||
})
|
})
|
||||||
|
|
||||||
await fs.promises.rmdir(path.join(__dirname, "distApp", "LightcordApi", "src"), {"recursive": true})
|
await fs.promises.rmdir(path.join(__dirname, "distApp", "LightcordApi", "src"), {"recursive": true})
|
||||||
|
await fs.promises.rmdir(path.join(__dirname, "distApp", "LightcordApi", "dist"), {"recursive": true})
|
||||||
await fs.promises.unlink(path.join(__dirname, "distApp", "LightcordApi", "webpack.config.js"))
|
await fs.promises.unlink(path.join(__dirname, "distApp", "LightcordApi", "webpack.config.js"))
|
||||||
await fs.promises.unlink(path.join(__dirname, "distApp", "LightcordApi", "tsconfig.json"))
|
await fs.promises.unlink(path.join(__dirname, "distApp", "LightcordApi", "tsconfig.json"))
|
||||||
|
|
||||||
|
console.log(child_process.execSync("npm install --only=prod", {
|
||||||
|
encoding: "binary",
|
||||||
|
cwd: path.join(__dirname, "distApp", "LightcordApi")
|
||||||
|
}))
|
||||||
|
|
||||||
await processNextDir(path.join(__dirname, "DiscordJS"), {
|
await processNextDir(path.join(__dirname, "DiscordJS"), {
|
||||||
startDir: path.join(__dirname, "DiscordJS"),
|
startDir: path.join(__dirname, "DiscordJS"),
|
||||||
newDir: path.join(__dirname, "distApp", "DiscordJS")
|
newDir: path.join(__dirname, "distApp", "DiscordJS")
|
||||||
}, ((filepath) => filepath.endsWith(".js") && (!production ? !filepath.includes("node_modules") : true)), async (filepath, newpath) => {
|
}, ((filepath) => filepath.endsWith(".js") && (!production ? !filepath.includes("node_modules") : true)), async (filepath, newpath) => {
|
||||||
|
if(filepath.includes("node_modules"))return // don't minify node_modules, and don't include them at all
|
||||||
console.info(`Minifying ${filepath} to ${newpath}`)
|
console.info(`Minifying ${filepath} to ${newpath}`)
|
||||||
await fs.promises.writeFile(newpath, terser.minify(await fs.promises.readFile(filepath, "utf8")).code, "utf8")
|
await fs.promises.writeFile(newpath, terser.minify(await fs.promises.readFile(filepath, "utf8")).code, "utf8")
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
@ -100,6 +128,11 @@ async function main(){
|
|||||||
await fs.promises.unlink(path.join(__dirname, "distApp", "DiscordJS", "webpack.config.js"))
|
await fs.promises.unlink(path.join(__dirname, "distApp", "DiscordJS", "webpack.config.js"))
|
||||||
await fs.promises.unlink(path.join(__dirname, "distApp", "DiscordJS", "tsconfig.json"))
|
await fs.promises.unlink(path.join(__dirname, "distApp", "DiscordJS", "tsconfig.json"))
|
||||||
|
|
||||||
|
console.log(child_process.execSync("npm install --only=prod", {
|
||||||
|
encoding: "binary",
|
||||||
|
cwd: path.join(__dirname, "distApp", "LightcordApi")
|
||||||
|
}))
|
||||||
|
|
||||||
fs.mkdirSync(path.join(__dirname, "distApp", "BetterDiscordApp", "js"), {recursive: true})
|
fs.mkdirSync(path.join(__dirname, "distApp", "BetterDiscordApp", "js"), {recursive: true})
|
||||||
fs.mkdirSync(path.join(__dirname, "distApp", "BetterDiscordApp", "css"), {recursive: true})
|
fs.mkdirSync(path.join(__dirname, "distApp", "BetterDiscordApp", "css"), {recursive: true})
|
||||||
const BDPackageJSON = require("./BetterDiscordApp/package.json")
|
const BDPackageJSON = require("./BetterDiscordApp/package.json")
|
||||||
@ -122,22 +155,14 @@ async function main(){
|
|||||||
}).then(() => {
|
}).then(() => {
|
||||||
console.info(`Copied files and minified them from ${path.join(__dirname, "splash")}.`)
|
console.info(`Copied files and minified them from ${path.join(__dirname, "splash")}.`)
|
||||||
})
|
})
|
||||||
|
|
||||||
/*
|
|
||||||
await processNextDir(startDir, {
|
|
||||||
startDir,
|
|
||||||
newDir
|
|
||||||
}, ((filepath) => false), ()=>{}).then(() => {
|
|
||||||
console.info(`Copied files and minified them from ${startDir}.`)
|
|
||||||
}).catch(console.error)*/
|
|
||||||
|
|
||||||
let packageJSON = require("./package.json")
|
let packageJSON = require("./package.json")
|
||||||
packageJSON.scripts.build = packageJSON.scripts.build.replace("./distApp", ".")
|
packageJSON.scripts.build = packageJSON.scripts.build.replace("./distApp", ".")
|
||||||
|
|
||||||
fs.writeFileSync(path.join(__dirname, "distApp", "package.json"), JSON.stringify(packageJSON), "utf8")
|
fs.writeFileSync(path.join(__dirname, "distApp", "package.json"), JSON.stringify(packageJSON), "utf8")
|
||||||
|
|
||||||
console.info(`Installing ${Object.keys(packageJSON.dependencies).length + Object.keys(packageJSON.devDependencies).length} packages...`)
|
console.info(`Installing ${Object.keys(packageJSON.dependencies).length} packages...`)
|
||||||
console.log(child_process.execSync("npm i", {
|
console.log(child_process.execSync("npm install --only=prod", {
|
||||||
encoding: "binary",
|
encoding: "binary",
|
||||||
cwd: path.join(__dirname, "distApp")
|
cwd: path.join(__dirname, "distApp")
|
||||||
}))
|
}))
|
||||||
|
@ -369,7 +369,7 @@ function launchMainAppWindow(isVisible) {
|
|||||||
mainWindowOptions.frame = false;
|
mainWindowOptions.frame = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
applyWindowBoundsToConfig(mainWindowOptions);
|
if(!settings.get("NO_WINDOWS_BOUND", false))applyWindowBoundsToConfig(mainWindowOptions);
|
||||||
|
|
||||||
mainWindow = new electron.BrowserWindow(mainWindowOptions);
|
mainWindow = new electron.BrowserWindow(mainWindowOptions);
|
||||||
mainWindowId = mainWindow.id;
|
mainWindowId = mainWindow.id;
|
||||||
@ -389,12 +389,14 @@ function launchMainAppWindow(isVisible) {
|
|||||||
|
|
||||||
mainWindow.setMenuBarVisibility(false);
|
mainWindow.setMenuBarVisibility(false);
|
||||||
|
|
||||||
if (settings.get('IS_MAXIMIZED')) {
|
if(!settings.get("NO_WINDOWS_BOUND", false)){
|
||||||
mainWindow.maximize();
|
if (settings.get('IS_MAXIMIZED')) {
|
||||||
}
|
mainWindow.maximize();
|
||||||
|
}
|
||||||
if (settings.get('IS_MINIMIZED')) {
|
|
||||||
mainWindow.minimize();
|
if (settings.get('IS_MINIMIZED')) {
|
||||||
|
mainWindow.minimize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mainWindow.webContents.on('new-window', (e, windowURL, frameName, disposition, options) => {
|
mainWindow.webContents.on('new-window', (e, windowURL, frameName, disposition, options) => {
|
||||||
|
5
modules/discord_spellcheck/package-lock.json
generated
Normal file
5
modules/discord_spellcheck/package-lock.json
generated
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"name": "discord_spellcheck",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 1
|
||||||
|
}
|
@ -3,8 +3,7 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {},
|
||||||
},
|
|
||||||
"devDependencies": {},
|
"devDependencies": {},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
"run": "electron .",
|
"run": "electron .",
|
||||||
"build": "npm run build:minify && npm run build:electron && npm run build:after",
|
"build": "npm run build:minify && npm run build:electron && npm run build:after",
|
||||||
"build:electron": "npm run build:electron_win && npm run build:electron_linux",
|
"build:electron": "npm run build:electron_win && npm run build:electron_linux",
|
||||||
"build:electron_win": "electron-packager ./distApp --ignore=\"(distApp|builds|\\.ts)\" --arch=ia32 --win32metadata.ProductName=\"Lightcord\" --win32metadata.CompanyName=\"Lightcord\" --protocol=discord --platform=\"win32\" --out=builds --icon=app.ico --executable-name=\"Lightcord\" --asar.unpack=*.{node,dll} --overwrite",
|
"build:electron_win": "electron-packager ./distApp --ignore=\"(distApp|builds|\\.ts|\\.so\\.4)\" --arch=ia32 --win32metadata.ProductName=\"Lightcord\" --win32metadata.CompanyName=\"Lightcord\" --protocol=discord --platform=\"win32\" --out=builds --icon=app.ico --executable-name=\"Lightcord\" --asar.unpack=*.{node,dll} --overwrite",
|
||||||
"build:electron_linux": "electron-packager ./distApp --ignore=\"(distApp|builds|\\.ts)\" --arch=x64 --protocol=discord --platform=\"linux\" --out=builds --icon=app.ico --executable-name=\"Lightcord\" --asar.unpack=*.{node,dll,so.4} --overwrite",
|
"build:electron_linux": "electron-packager ./distApp --ignore=\"(distApp|builds|\\.ts|\\.dll)\" --arch=x64 --protocol=discord --platform=\"linux\" --out=builds --icon=app.ico --executable-name=\"Lightcord\" --asar.unpack=*.{node,so.4} --overwrite",
|
||||||
"build:minify": "node build.js",
|
"build:minify": "node build.js",
|
||||||
"build:after": "node afterbuild.js",
|
"build:after": "node afterbuild.js",
|
||||||
"devInstall": "npm i -g --arch=ia32 electron@8.4.0 && npm i -g typescript && npm i --save-dev @types/node@12.12.39 && npm i --save-dev --arch=ia32 electron@8.4.0 && node installSubModules.js && echo \"Everything is installed. You should be able to do `npm run test` to compile everything and launch.\"",
|
"devInstall": "npm i -g --arch=ia32 electron@8.4.0 && npm i -g typescript && npm i --save-dev @types/node@12.12.39 && npm i --save-dev --arch=ia32 electron@8.4.0 && node installSubModules.js && echo \"Everything is installed. You should be able to do `npm run test` to compile everything and launch.\"",
|
||||||
|
181
src/index.ts
181
src/index.ts
@ -1,89 +1,94 @@
|
|||||||
/** Glasstron */
|
/** Glasstron */
|
||||||
import * as glasstron from "glasstron"
|
import * as glasstron from "glasstron"
|
||||||
glasstron.init()
|
glasstron.init()
|
||||||
|
|
||||||
/** Modules */
|
/** Modules */
|
||||||
import * as electron from "electron"
|
import * as electron from "electron"
|
||||||
import requireNativeDiscordModule from "./requireNative";
|
import requireNativeDiscordModule from "./requireNative";
|
||||||
import appSettings from "./appSettings"
|
import appSettings from "./appSettings"
|
||||||
import autoStart from "./autoStart"
|
import autoStart from "./autoStart"
|
||||||
import * as buildInfo from "./buildInfo"
|
import * as buildInfo from "./buildInfo"
|
||||||
import * as Constants from "./Constants"
|
import * as Constants from "./Constants"
|
||||||
import * as GPUSettings from "./GPUSettings"
|
import * as GPUSettings from "./GPUSettings"
|
||||||
import * as moduleUpdater from "./common/moduleUpdater"
|
import * as moduleUpdater from "./common/moduleUpdater"
|
||||||
import * as paths from "./common/paths"
|
import * as paths from "./common/paths"
|
||||||
import { create } from "./singleInstance";
|
import { create } from "./singleInstance";
|
||||||
import * as splashScreen from "./splashScreen"
|
import * as splashScreen from "./splashScreen"
|
||||||
|
|
||||||
if (process.platform === 'linux') {
|
if (process.platform === 'linux') {
|
||||||
// Some people are reporting audio problems on Linux that are fixed by setting
|
// Some people are reporting audio problems on Linux that are fixed by setting
|
||||||
// an environment variable PULSE_LATENCY_MSEC=30 -- the "real" fix is to see
|
// an environment variable PULSE_LATENCY_MSEC=30 -- the "real" fix is to see
|
||||||
// what conditions require this and set this then (also to set it directly in
|
// what conditions require this and set this then (also to set it directly in
|
||||||
// our webrtc setup code rather than here) but this should fix the bug for now.
|
// our webrtc setup code rather than here) but this should fix the bug for now.
|
||||||
if (process.env.PULSE_LATENCY_MSEC === undefined) {
|
if (process.env.PULSE_LATENCY_MSEC === undefined) {
|
||||||
process.env.PULSE_LATENCY_MSEC = "30";
|
process.env.PULSE_LATENCY_MSEC = "30";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
paths.init(buildInfo)
|
paths.init(buildInfo)
|
||||||
electron.app.commandLine.appendSwitch('autoplay-policy', 'no-user-gesture-required');
|
electron.app.commandLine.appendSwitch('autoplay-policy', 'no-user-gesture-required');
|
||||||
electron.app.commandLine.appendSwitch("no-force-async-hooks-checks");
|
electron.app.commandLine.appendSwitch("no-force-async-hooks-checks");
|
||||||
|
|
||||||
function setupHardwareAcceleration() {
|
function setupHardwareAcceleration() {
|
||||||
const settings = appSettings.getSettings();
|
const settings = appSettings.getSettings();
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
const electronMajor = parseInt(process.versions.electron.split('.')[0]);
|
const electronMajor = parseInt(process.versions.electron.split('.')[0]);
|
||||||
const allowed = process.env.DISCORD_ENABLE_HARDWARE_ACCELERATION || buildInfo.releaseChannel === 'development' || !(electronMajor === 7 && process.platform === 'darwin');
|
const allowed = process.env.DISCORD_ENABLE_HARDWARE_ACCELERATION || buildInfo.releaseChannel === 'development' || !(electronMajor === 7 && process.platform === 'darwin');
|
||||||
// TODO: this is a copy of gpuSettings.getEnableHardwareAcceleration
|
// TODO: this is a copy of gpuSettings.getEnableHardwareAcceleration
|
||||||
if (!allowed || !settings.get('enableHardwareAcceleration', true)) {
|
if (!allowed || !settings.get('enableHardwareAcceleration', true)) {
|
||||||
electron.app.disableHardwareAcceleration();
|
electron.app.disableHardwareAcceleration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
global["releaseChannel"] = "stable"
|
global["releaseChannel"] = "stable"
|
||||||
|
|
||||||
setupHardwareAcceleration();
|
setupHardwareAcceleration();
|
||||||
function hasArgvFlag(flag) {
|
function hasArgvFlag(flag) {
|
||||||
return (process.argv || []).slice(1).includes(flag);
|
return (process.argv || []).slice(1).includes(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Transform main thread into async
|
//Transform main thread into async
|
||||||
(async function Main(){
|
(async function Main(){
|
||||||
await electron.app.whenReady()
|
await electron.app.whenReady()
|
||||||
|
|
||||||
console.log(`Initializing Lightcord.`)
|
console.log(`Initializing Lightcord.`)
|
||||||
console.log(`Version: ${buildInfo.version}
|
console.log(`Version: ${buildInfo.version}
|
||||||
releaseChannel: ${buildInfo.releaseChannel}
|
releaseChannel: ${buildInfo.releaseChannel}
|
||||||
commit: ${buildInfo.commit}`)
|
commit: ${buildInfo.commit}`)
|
||||||
|
|
||||||
if(!electron.app.commandLine.hasSwitch('enable-transparent-visuals'))electron.app.commandLine.appendSwitch('enable-transparent-visuals');
|
if(!electron.app.commandLine.hasSwitch('enable-transparent-visuals'))electron.app.commandLine.appendSwitch('enable-transparent-visuals');
|
||||||
electron.app.setAppUserModelId(Constants.APP_ID);
|
electron.app.setAppUserModelId(Constants.APP_ID);
|
||||||
|
|
||||||
let coreModule
|
let coreModule
|
||||||
create(() => {
|
create(() => {
|
||||||
const startMinimized = hasArgvFlag('--start-minimized');
|
const startMinimized = hasArgvFlag('--start-minimized');
|
||||||
|
|
||||||
coreModule = requireNativeDiscordModule('discord_desktop_core');
|
coreModule = requireNativeDiscordModule('discord_desktop_core');
|
||||||
coreModule.startup({
|
coreModule.startup({
|
||||||
paths,
|
paths,
|
||||||
splashScreen,
|
splashScreen,
|
||||||
moduleUpdater,
|
moduleUpdater,
|
||||||
autoStart,
|
autoStart,
|
||||||
buildInfo,
|
buildInfo,
|
||||||
appSettings,
|
appSettings,
|
||||||
Constants,
|
Constants,
|
||||||
GPUSettings
|
GPUSettings
|
||||||
});
|
});
|
||||||
|
|
||||||
coreModule.setMainWindowVisible(!startMinimized)
|
coreModule.setMainWindowVisible(!startMinimized)
|
||||||
}, (args) => {
|
}, (args) => {
|
||||||
if (args != null && args.length > 0 && args[0] === '--squirrel-uninstall') {
|
if (args != null && args.length > 0 && args[0] === '--squirrel-uninstall') {
|
||||||
electron.app.quit();
|
electron.app.quit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (coreModule) {
|
if(args.length === 1 && args[0] === "--overlay-host"){ // this is a patch for Lightcord that focus itself
|
||||||
coreModule.handleSingleInstance(args);
|
//console.warn("OVERLAY HOST DÉTECTÉ. EVENNEMENT IGNORÉ MAIS POURRAIT CAUSER UN PROBLÈME.")
|
||||||
}
|
return
|
||||||
})
|
}
|
||||||
|
|
||||||
|
if (coreModule) {
|
||||||
|
coreModule.handleSingleInstance(args);
|
||||||
|
}
|
||||||
|
})
|
||||||
})()
|
})()
|
Loading…
x
Reference in New Issue
Block a user