diff --git a/BetterDiscordApp/src/modules/bdApi.js b/BetterDiscordApp/src/modules/bdApi.js index 41e52e4..c5b9271 100644 --- a/BetterDiscordApp/src/modules/bdApi.js +++ b/BetterDiscordApp/src/modules/bdApi.js @@ -1,4 +1,12 @@ -import {pluginCookie, themeCookie, bdplugins, bdthemes, settingsCookie, settings} from "../0globals"; +import { + pluginCookie, + themeCookie, + bdplugins, + bdthemes, + settingsCookie, + settings, + bdEmotes, +} from "../0globals"; import mainCore from "./core"; import Utils from "./utils"; import BDV2 from "./v2"; @@ -9,67 +17,96 @@ import settingsPanel from "./settingsPanel"; import DOM from "./domtools"; const BdApi = { - get React() { return BDV2.React; }, - get ReactDOM() { return BDV2.ReactDom; }, - get ReactComponent() {return BDV2.ReactComponent;}, - get WindowConfigFile() {return Utils.WindowConfigFile;}, - get settings() {return settings;}, - get emotes() {return null}, // deprecated, deleted all emotes from betterdiscord. - get screenWidth() { return Math.max(document.documentElement.clientWidth, window.innerWidth || 0); }, - get screenHeight() { return Math.max(document.documentElement.clientHeight, window.innerHeight || 0); } + get React() { + return BDV2.React; + }, + get ReactDOM() { + return BDV2.ReactDom; + }, + get ReactComponent() { + return BDV2.ReactComponent; + }, + get WindowConfigFile() { + return Utils.WindowConfigFile; + }, + get settings() { + return settings; + }, + get emotes() { + return bdEmotes; + }, + get screenWidth() { + return Math.max( + document.documentElement.clientWidth, + window.innerWidth || 0 + ); + }, + get screenHeight() { + return Math.max( + document.documentElement.clientHeight, + window.innerHeight || 0 + ); + }, }; -BdApi.getAllWindowPreferences = function() { - return Utils.getAllWindowPreferences(); +BdApi.getAllWindowPreferences = function () { + return Utils.getAllWindowPreferences(); }; -BdApi.getWindowPreference = function(key) { - return Utils.getWindowPreference(key); +BdApi.getWindowPreference = function (key) { + return Utils.getWindowPreference(key); }; -BdApi.setWindowPreference = function(key, value) { - return Utils.setWindowPreference(key, value); +BdApi.setWindowPreference = function (key, value) { + return Utils.setWindowPreference(key, value); }; //Inject CSS to document head //id = id of element //css = custom css BdApi.injectCSS = function (id, css) { - DOM.addStyle(DOM.escapeID(id), css); + DOM.addStyle(DOM.escapeID(id), css); }; //Clear css/remove any element //id = id of element BdApi.clearCSS = function (id) { - DOM.removeStyle(DOM.escapeID(id)); + DOM.removeStyle(DOM.escapeID(id)); }; //Inject CSS to document head //id = id of element //css = custom css BdApi.linkJS = function (id, url) { - DOM.addScript(DOM.escapeID(id), url); + DOM.addScript(DOM.escapeID(id), url); }; //Clear css/remove any element //id = id of element BdApi.unlinkJS = function (id) { - DOM.removeScript(DOM.escapeID(id)); + DOM.removeScript(DOM.escapeID(id)); }; //Get another plugin //name = name of plugin BdApi.getPlugin = function (name) { - if (bdplugins.hasOwnProperty(name)) { - return bdplugins[name].plugin; - } - return null; + Utils.warn( + "Deprecation Notice", + `BdApi.getPlugin() will be removed in future versions. Please use the BdApi.Plugins API` + ); + if (bdplugins.hasOwnProperty(name)) { + return bdplugins[name].plugin; + } + return null; }; //Get BetterDiscord Core BdApi.getCore = function () { - Utils.warn("Deprecation Notice", `BdApi.getCore() will be removed in future versions.`); - return mainCore; + Utils.warn( + "Deprecation Notice", + `BdApi.getCore() will be removed in future versions.` + ); + return mainCore; }; /** @@ -78,7 +115,7 @@ BdApi.getCore = function () { * @param {string} content - a string of text to display in the modal */ BdApi.alert = function (title, content) { - return Utils.showConfirmationModal(title, content, {cancelText: null}); + return Utils.showConfirmationModal(title, content, { cancelText: null }); }; /** @@ -95,160 +132,169 @@ BdApi.alert = function (title, content) { * @returns {string} - the key used for this modal */ BdApi.showConfirmationModal = function (title, content, options = {}) { - return Utils.showConfirmationModal(title, content, options); + return Utils.showConfirmationModal(title, content, options); }; //Show toast alert -BdApi.showToast = function(content, options = {}) { - Utils.showToast(content, options); +BdApi.showToast = function (content, options = {}) { + Utils.showToast(content, options); }; // Finds module -BdApi.findModule = function(filter) { - return BDV2.WebpackModules.find(filter); +BdApi.findModule = function (filter) { + return BDV2.WebpackModules.find(filter); }; // Finds module -BdApi.findAllModules = function(filter) { - return BDV2.WebpackModules.findAll(filter); +BdApi.findAllModules = function (filter) { + return BDV2.WebpackModules.findAll(filter); }; // Finds module -BdApi.findModuleByProps = function(...props) { - return BDV2.WebpackModules.findByUniqueProperties(props); +BdApi.findModuleByProps = function (...props) { + return BDV2.WebpackModules.findByUniqueProperties(props); }; -BdApi.findModuleByPrototypes = function(...protos) { - return BDV2.WebpackModules.findByPrototypes(protos); +BdApi.findModuleByPrototypes = function (...protos) { + return BDV2.WebpackModules.findByPrototypes(protos); }; -BdApi.findModuleByDisplayName = function(name) { - return BDV2.WebpackModules.findByDisplayName(name); +BdApi.findModuleByDisplayName = function (name) { + return BDV2.WebpackModules.findByDisplayName(name); }; // Gets react instance -BdApi.getInternalInstance = function(node) { - if (!(node instanceof window.jQuery) && !(node instanceof Element)) return undefined; - if (node instanceof jQuery) node = node[0]; - return BDV2.getInternalInstance(node); +BdApi.getInternalInstance = function (node) { + if (!(node instanceof window.jQuery) && !(node instanceof Element)) + return undefined; + if (node instanceof jQuery) node = node[0]; + return BDV2.getInternalInstance(node); }; // Gets data -BdApi.loadData = function(pluginName, key) { - return DataStore.getPluginData(pluginName, key); +BdApi.loadData = function (pluginName, key) { + return DataStore.getPluginData(pluginName, key); }; BdApi.getData = BdApi.loadData; // Sets data -BdApi.saveData = function(pluginName, key, data) { - return DataStore.setPluginData(pluginName, key, data); +BdApi.saveData = function (pluginName, key, data) { + return DataStore.setPluginData(pluginName, key, data); }; BdApi.setData = BdApi.saveData; // Deletes data -BdApi.deleteData = function(pluginName, key) { - return DataStore.deletePluginData(pluginName, key); +BdApi.deleteData = function (pluginName, key) { + return DataStore.deletePluginData(pluginName, key); }; // Patches other functions -BdApi.monkeyPatch = function(what, methodName, options) { - return Utils.monkeyPatch(what, methodName, options); +BdApi.monkeyPatch = function (what, methodName, options) { + return Utils.monkeyPatch(what, methodName, options); }; // Event when element is removed -BdApi.onRemoved = function(node, callback) { - return Utils.onRemoved(node, callback); +BdApi.onRemoved = function (node, callback) { + return Utils.onRemoved(node, callback); }; // Wraps function in try..catch -BdApi.suppressErrors = function(method, message) { - return Utils.suppressErrors(method, message); +BdApi.suppressErrors = function (method, message) { + return Utils.suppressErrors(method, message); }; // Tests for valid JSON -BdApi.testJSON = function(data) { - return Utils.testJSON(data); +BdApi.testJSON = function (data) { + return Utils.testJSON(data); }; -BdApi.isPluginEnabled = function(name) { - return !!pluginCookie[name]; +BdApi.isPluginEnabled = function (name) { + Utils.warn( + "Deprecation Notice", + `BdApi.isPluginEnabled() will be removed in future versions. Please use the BdApi.Plugins API` + ); + return !!pluginCookie[name]; }; -BdApi.isThemeEnabled = function(name) { - return !!themeCookie[name]; +BdApi.isThemeEnabled = function (name) { + Utils.warn( + "Deprecation Notice", + `BdApi.isThemeEnabled() will be removed in future versions. Please use the BdApi.Themes API` + ); + return !!themeCookie[name]; }; -BdApi.isSettingEnabled = function(id) { - return !!settingsCookie[id]; +BdApi.isSettingEnabled = function (id) { + return !!settingsCookie[id]; }; -BdApi.enableSetting = function(id) { - return settingsPanel.onChange(id, true); +BdApi.enableSetting = function (id) { + return settingsPanel.onChange(id, true); }; -BdApi.disableSetting = function(id) { - return settingsPanel.onChange(id, false); +BdApi.disableSetting = function (id) { + return settingsPanel.onChange(id, false); }; -BdApi.toggleSetting = function(id) { - return settingsPanel.onChange(id, !settingsCookie[id]); +BdApi.toggleSetting = function (id) { + return settingsPanel.onChange(id, !settingsCookie[id]); }; // Gets data -BdApi.getBDData = function(key) { - return DataStore.getBDData(key); +BdApi.getBDData = function (key) { + return DataStore.getBDData(key); }; // Sets data -BdApi.setBDData = function(key, data) { - return DataStore.setBDData(key, data); +BdApi.setBDData = function (key, data) { + return DataStore.setBDData(key, data); }; - - -const makeAddonAPI = (cookie, list, manager) => new class AddonAPI { - - get folder() {return manager.folder;} +const makeAddonAPI = (cookie, list, manager) => + new (class AddonAPI { + get folder() { + return manager.folder; + } isEnabled(name) { - return !!cookie[name]; + return !!cookie[name]; } enable(name) { - return manager.enable(name); + return manager.enable(name); } disable(name) { - return manager.disable(name); + return manager.disable(name); } toggle(name) { - if (cookie[name]) this.disable(name); - else this.enable(name); + if (cookie[name]) this.disable(name); + else this.enable(name); } reload(name) { - return manager.reload(name); + return manager.reload(name); } get(name) { - if (list.hasOwnProperty(name)) { - if (list[name].plugin) return list[name].plugin; - return list[name]; - } - return null; + if (list.hasOwnProperty(name)) { + if (list[name].plugin) return list[name].plugin; + return list[name]; + } + return null; } getAll() { - return Object.keys(list).map(k => this.get(k)).filter(a => a); + return Object.keys(list) + .map((k) => this.get(k)) + .filter((a) => a); } -}; + })(); BdApi.Plugins = makeAddonAPI(pluginCookie, bdplugins, pluginModule); BdApi.Themes = makeAddonAPI(themeCookie, bdthemes, themeModule); export default BdApi; - -window.Lightcord.BetterDiscord.BdApi = BdApi \ No newline at end of file diff --git a/BetterDiscordApp/src/modules/contentManager.js b/BetterDiscordApp/src/modules/contentManager.js index c4d234f..bbc0229 100644 --- a/BetterDiscordApp/src/modules/contentManager.js +++ b/BetterDiscordApp/src/modules/contentManager.js @@ -1,351 +1,478 @@ -import {bdConfig, bdplugins, bdthemes, settingsCookie} from "../0globals"; +import { bdConfig, bdplugins, bdthemes, settingsCookie } from "../0globals"; import pluginModule from "./pluginModule"; import themeModule from "./themeModule"; import Utils from "./utils"; import dataStore from "./dataStore"; -import { encryptSettingsCache, decryptSettingsCache, processFile } from "./pluginCertifier"; -import * as electron from "electron" +import { + encryptSettingsCache, + decryptSettingsCache, + processFile, +} from "./pluginCertifier"; +import * as electron from "electron"; const path = require("path"); const fs = require("fs"); const Module = require("module").Module; -Module.globalPaths.push(path.resolve(electron.ipcRenderer.sendSync("LIGHTCORD_GET_APP_PATH"), "node_modules")); +Module.globalPaths.push( + path.resolve( + electron.ipcRenderer.sendSync("LIGHTCORD_GET_APP_PATH"), + "node_modules" + ) +); class MetaError extends Error { - constructor(message) { - super(message); - this.name = "MetaError"; - } + constructor(message) { + super(message); + this.name = "MetaError"; + } } const originalJSRequire = Module._extensions[".js"]; -const originalCSSRequire = Module._extensions[".css"] ? Module._extensions[".css"] : () => {return null;}; +const originalCSSRequire = Module._extensions[".css"] + ? Module._extensions[".css"] + : () => { + return null; + }; const splitRegex = /[^\S\r\n]*?(?:\r\n|\n)[^\S\r\n]*?\*[^\S\r\n]?/; const escapedAtRegex = /^\\@/; -export let addonCache = {} +export let addonCache = {}; -let hasPatched = false -export default new class ContentManager { +let hasPatched = false; +export default new (class ContentManager { + constructor() { + this.timeCache = {}; + this.watchers = {}; + } - constructor() { - this.timeCache = {}; - this.watchers = {}; + patchExtensions() { + if (hasPatched) return; + hasPatched = true; + Module._extensions[".js"] = this.getContentRequire("plugin"); + Module._extensions[".css"] = this.getContentRequire("theme"); + } + + get pluginsFolder() { + return ( + this._pluginsFolder || + (this._pluginsFolder = fs.realpathSync( + path.resolve(bdConfig.dataPath + "plugins/") + )) + ); + } + get themesFolder() { + return ( + this._themesFolder || + (this._themesFolder = fs.realpathSync( + path.resolve(bdConfig.dataPath + "themes/") + )) + ); + } + + loadAddonCertifierCache() { + if ( + typeof dataStore.getSettingGroup("PluginCertifierHashes") !== "string" + ) { + dataStore.setSettingGroup( + "PluginCertifierHashes", + encryptSettingsCache("{}") + ); + } else { + try { + addonCache = JSON.parse( + decryptSettingsCache( + dataStore.getSettingGroup("PluginCertifierHashes") + ) + ); + } catch (e) { + dataStore.setSettingGroup( + "PluginCertifierHashes", + encryptSettingsCache("{}") + ); + addonCache = {}; + } } + Object.keys(addonCache).forEach((key) => { + let value = addonCache[key]; + if (!value || typeof value !== "object" || Array.isArray(value)) + return delete addonCache[key]; - patchExtensions(){ - if(hasPatched)return - hasPatched = true - Module._extensions[".js"] = this.getContentRequire("plugin"); - Module._extensions[".css"] = this.getContentRequire("theme"); - } - - get pluginsFolder() {return this._pluginsFolder || (this._pluginsFolder = fs.realpathSync(path.resolve(bdConfig.dataPath + "plugins/")));} - get themesFolder() {return this._themesFolder || (this._themesFolder = fs.realpathSync(path.resolve(bdConfig.dataPath + "themes/")));} - - loadAddonCertifierCache(){ - if(typeof dataStore.getSettingGroup("PluginCertifierHashes") !== "string"){ - dataStore.setSettingGroup("PluginCertifierHashes", encryptSettingsCache("{}")) - }else{ - try{ - addonCache = JSON.parse(decryptSettingsCache(dataStore.getSettingGroup("PluginCertifierHashes"))) - }catch(e){ - dataStore.setSettingGroup("PluginCertifierHashes", encryptSettingsCache("{}")) - addonCache = {} - } + let props = [ + { + key: "timestamp", + type: "number", + }, + { + key: "result", + type: "object", + }, + { + key: "hash", + type: "string", + }, + ]; + for (let prop of props) { + if (!(prop.key in value) || typeof value[prop.key] !== prop.type) { + delete addonCache[key]; + return; } - Object.keys(addonCache) - .forEach(key => { - let value = addonCache[key] - if(!value || typeof value !== "object" || Array.isArray(value))return delete addonCache[key] + } + if (value.hash !== key) { + delete addonCache[key]; + return; + } + if (value.result.suspect) { + // refetch from remote to be sure you're up to date. + delete addonCache[key]; + return; + } + }); + this.saveAddonCache(); + } - let props = [{ - key: "timestamp", - type: "number" - }, { - key: "result", - type: "object" - }, { - key: "hash", - type: "string" - }] - for(let prop of props){ - if(!(prop.key in value) || typeof value[prop.key] !== prop.type){ - delete addonCache[key] - return - } - } - if(value.hash !== key){ - delete addonCache[key] - return - } - if(value.result.suspect){ // refetch from remote to be sure you're up to date. - delete addonCache[key] - return - } - }) - this.saveAddonCache() - } + saveAddonCache() { + dataStore.setSettingGroup( + "PluginCertifierHashes", + encryptSettingsCache(JSON.stringify(addonCache)) + ); + } - saveAddonCache(){ - dataStore.setSettingGroup("PluginCertifierHashes", encryptSettingsCache(JSON.stringify(addonCache))) - } + resetAddonCache() { + Object.keys(addonCache).forEach((key) => { + delete addonCache[key]; + }); + console.log(addonCache); + this.saveAddonCache(); + } - resetAddonCache(){ - Object.keys(addonCache).forEach(key => { - delete addonCache[key] - }) - console.log(addonCache) - this.saveAddonCache() - } - - watchContent(contentType) { - if (this.watchers[contentType]) return; - const isPlugin = contentType === "plugin"; - const baseFolder = isPlugin ? this.pluginsFolder : this.themesFolder; - const fileEnding = isPlugin ? ".plugin.js" : ".theme.css"; - this.watchers[contentType] = fs.watch(baseFolder, {persistent: false}, async (eventType, filename) => { - if (!eventType || !filename || !filename.endsWith(fileEnding)) return; - await new Promise(r => setTimeout(r, 50)); - try {fs.statSync(path.resolve(baseFolder, filename));} - catch (err) { - if (err.code !== "ENOENT") return; - delete this.timeCache[filename]; - if (isPlugin) return pluginModule.unloadPlugin(filename); - return themeModule.unloadTheme(filename); - } - if (!fs.statSync(path.resolve(baseFolder, filename)).isFile()) return; - const stats = fs.statSync(path.resolve(baseFolder, filename)); - if (!stats || !stats.mtime || !stats.mtime.getTime()) return; - if (typeof(stats.mtime.getTime()) !== "number") return; - if (this.timeCache[filename] == stats.mtime.getTime()) return; - this.timeCache[filename] = stats.mtime.getTime(); - if (eventType == "rename") { - if (isPlugin) await pluginModule.loadPlugin(filename); - else await themeModule.loadTheme(filename); - } - if (eventType == "change") { - if (isPlugin) await pluginModule.reloadPlugin(filename); - else await themeModule.reloadTheme(filename); - } - }); - } - - unwatchContent(contentType) { - if (!this.watchers[contentType]) return; - this.watchers[contentType].close(); - delete this.watchers[contentType]; - } - - extractMeta(content) { - const firstLine = content.split("\n")[0]; - const hasOldMeta = firstLine.includes("//META"); - if (hasOldMeta) return this.parseOldMeta(content); - const hasNewMeta = firstLine.includes("/**"); - if (hasNewMeta) return this.parseNewMeta(content); - throw new MetaError("META was not found."); - } - - parseOldMeta(content) { - const meta = content.split("\n")[0]; - const rawMeta = meta.substring(meta.lastIndexOf("//META") + 6, meta.lastIndexOf("*//")); - if (meta.indexOf("META") < 0) throw new MetaError("META was not found."); - const parsed = Utils.testJSON(rawMeta); - if (!parsed) throw new MetaError("META could not be parsed."); - if (!parsed.name) throw new MetaError("META missing name data."); - parsed.format = "json"; - return parsed; - } - - parseNewMeta(content) { - const block = content.split("/**", 2)[1].split("*/", 1)[0]; - const out = {}; - let field = ""; - let accum = ""; - for (const line of block.split(splitRegex)) { - if (line.length === 0) continue; - if (line.charAt(0) === "@" && line.charAt(1) !== " ") { - out[field] = accum; - const l = line.indexOf(" "); - field = line.substr(1, l - 1); - accum = line.substr(l + 1); - } - else { - accum += " " + line.replace("\\n", "\n").replace(escapedAtRegex, "@"); - } - } - out[field] = accum.trim(); - delete out[""]; - out.format = "jsdoc"; - return out; - } - - getContentRequire(type) { - const isPlugin = type === "plugin"; - const self = this; - const originalRequire = isPlugin ? originalJSRequire : originalCSSRequire; - return function(module, filename) { - const baseFolder = isPlugin ? self.pluginsFolder : self.themesFolder; - const possiblePath = path.resolve(baseFolder, path.basename(filename)); - if (!fs.existsSync(possiblePath) || filename !== fs.realpathSync(possiblePath)) return Reflect.apply(originalRequire, this, arguments); - let content = fs.readFileSync(filename, "utf8"); - content = Utils.stripBOM(content); - - const stats = fs.statSync(filename); - const meta = self.extractMeta(content); - meta.filename = path.basename(filename); - meta.added = stats.atimeMs; - meta.modified = stats.mtimeMs; - meta.size = stats.size; - if (!isPlugin) { - meta.css = content; - if (meta.format == "json") meta.css = meta.css.split("\n").slice(1).join("\n"); - content = `module.exports = ${JSON.stringify(meta)};`; - } - if (isPlugin) { - module._compile(content, module.filename); - const didExport = !Utils.isEmpty(module.exports); - if (didExport) { - meta.type = module.exports; - module.exports = meta; - content = ""; - } - else { - Utils.warn("Module Not Exported", `${meta.name}, please start setting module.exports`); - content += `\nmodule.exports = ${JSON.stringify(meta)};\nmodule.exports.type = ${meta.exports || meta.name};`; - } - } - module._compile(content, filename); - }; - } - - makePlaceholderPlugin(data) { - return {plugin: { - start: () => {}, - getName: () => {return data.name || data.filename;}, - getAuthor: () => {return "???";}, - getDescription: () => {return data.message ? data.message : "This plugin was unable to be loaded. Check the author's page for updates.";}, - getVersion: () => {return "???";} - }, - name: data.name || data.filename, - filename: data.filename, - source: data.source ? data.source : "", - website: data.website ? data.website : "" - }; - } - - async loadContent(filename, type) { - if (typeof(filename) === "undefined" || typeof(type) === "undefined") return; - const isPlugin = type === "plugin"; - const baseFolder = isPlugin ? this.pluginsFolder : this.themesFolder; - - if(settingsCookie["fork-ps-6"]){ - let result = await new Promise(resolve => { - processFile(path.resolve(baseFolder, filename), (result) => { - console.log(result) - resolve(result) - }, (hash) => { - resolve({ - suspect: false, - hash: hash, - filename: filename, - name: filename - }) - }, true) - }) - if(result){ - addonCache[result.hash] = { - timestamp: Date.now(), - hash: result.hash, - result: result - } - this.saveAddonCache() - if(result.suspect){ - return { - name: filename, - file: filename, - message: "This plugin might be dangerous ("+result.harm+").", - error: new Error("This plugin might be dangerous ("+result.harm+").") - } - } - } - } - - try {__non_webpack_require__(path.resolve(baseFolder, filename));} - catch (error) {return {name: filename, file: filename, message: "Could not be compiled.", error: {message: error.message, stack: error.stack}};} - const content = __non_webpack_require__(path.resolve(baseFolder, filename)); - if(!content.name)return {name: filename, file: filename, message: "Cannot escape the ID.", error: new Error("Cannot read property 'replace' of undefined")} - content.id = Utils.escapeID(content.name); - //if(!id)return {name: filename, file: filename, message: "Invalid ID", error: new Error("Please fix the name of "+filename+". BetterDiscord can't escape an ID.")} - if (isPlugin) { - if (!content.type) return; - try { - content.plugin = new content.type(); - delete bdplugins[content.plugin.getName()]; - bdplugins[content.plugin.getName()] = content; - } - catch (error) {return {name: filename, file: filename, message: "Could not be constructed.", error: {message: error.message, stack: error.stack}};} - } - else { - delete bdthemes[content.name]; - bdthemes[content.name] = content; - } - } - - unloadContent(filename, type) { - if (typeof(filename) === "undefined" || typeof(type) === "undefined") return; - const isPlugin = type === "plugin"; - const baseFolder = isPlugin ? this.pluginsFolder : this.themesFolder; + watchContent(contentType) { + if (this.watchers[contentType]) return; + const isPlugin = contentType === "plugin"; + const baseFolder = isPlugin ? this.pluginsFolder : this.themesFolder; + const fileEnding = isPlugin ? ".plugin.js" : ".theme.css"; + this.watchers[contentType] = fs.watch( + baseFolder, + { persistent: false }, + async (eventType, filename) => { + if (!eventType || !filename || !filename.endsWith(fileEnding)) return; + await new Promise((r) => setTimeout(r, 50)); try { - delete __non_webpack_require__.cache[__non_webpack_require__.resolve(path.resolve(baseFolder, filename))]; + fs.statSync(path.resolve(baseFolder, filename)); + } catch (err) { + if (err.code !== "ENOENT") return; + delete this.timeCache[filename]; + if (isPlugin) return pluginModule.unloadPlugin(filename); + return themeModule.unloadTheme(filename); } - catch (err) {return {name: filename, file: filename, message: "Could not be unloaded.", error: {message: err.message, stack: err.stack}};} - } - - isLoaded(filename, type) { - const isPlugin = type === "plugin"; - const baseFolder = isPlugin ? this.pluginsFolder : this.themesFolder; - try {__non_webpack_require__.cache[__non_webpack_require__.resolve(path.resolve(baseFolder, filename))];} - catch (err) {return false;} - return true; - } - - async reloadContent(filename, type) { - const cantUnload = this.unloadContent(filename, type); - if (cantUnload) return cantUnload; - return await this.loadContent(filename, type); - } - - loadNewContent(type) { - const isPlugin = type === "plugin"; - const fileEnding = isPlugin ? ".plugin.js" : ".theme.css"; - const basedir = isPlugin ? this.pluginsFolder : this.themesFolder; - const files = fs.readdirSync(basedir); - const contentList = Object.values(isPlugin ? bdplugins : bdthemes); - const removed = contentList.filter(t => !files.includes(t.filename)).map(c => isPlugin ? c.plugin.getName() : c.name); - const added = files.filter(f => !contentList.find(t => t.filename == f) && f.endsWith(fileEnding) && fs.statSync(path.resolve(basedir, f)).isFile()); - return {added, removed}; - } - - async loadAllContent(type) { - this.patchExtensions() - const isPlugin = type === "plugin"; - const fileEnding = isPlugin ? ".plugin.js" : ".theme.css"; - const basedir = isPlugin ? this.pluginsFolder : this.themesFolder; - const errors = []; - const files = fs.readdirSync(basedir); - - for (const filename of files) { - if (!fs.statSync(path.resolve(basedir, filename)).isFile() || !filename.endsWith(fileEnding)) continue; - const error = await this.loadContent(filename, type); - if (error) errors.push(error); + if (!fs.statSync(path.resolve(baseFolder, filename)).isFile()) return; + const stats = fs.statSync(path.resolve(baseFolder, filename)); + if (!stats || !stats.mtime || !stats.mtime.getTime()) return; + if (typeof stats.mtime.getTime() !== "number") return; + if (this.timeCache[filename] == stats.mtime.getTime()) return; + this.timeCache[filename] = stats.mtime.getTime(); + if (eventType == "rename") { + if (isPlugin) await pluginModule.loadPlugin(filename); + else await themeModule.loadTheme(filename); } + if (eventType == "change") { + if (isPlugin) await pluginModule.reloadPlugin(filename); + else await themeModule.reloadTheme(filename); + } + } + ); + } - return errors; + unwatchContent(contentType) { + if (!this.watchers[contentType]) return; + this.watchers[contentType].close(); + delete this.watchers[contentType]; + } + + extractMeta(content) { + const firstLine = content.split("\n")[0]; + const hasOldMeta = firstLine.includes("//META"); + if (hasOldMeta) return this.parseOldMeta(content); + const hasNewMeta = firstLine.includes("/**"); + if (hasNewMeta) return this.parseNewMeta(content); + throw new MetaError("META was not found."); + } + + parseOldMeta(content) { + const meta = content.split("\n")[0]; + const rawMeta = meta.substring( + meta.lastIndexOf("//META") + 6, + meta.lastIndexOf("*//") + ); + if (meta.indexOf("META") < 0) throw new MetaError("META was not found."); + const parsed = Utils.testJSON(rawMeta); + if (!parsed) throw new MetaError("META could not be parsed."); + if (!parsed.name) throw new MetaError("META missing name data."); + parsed.format = "json"; + return parsed; + } + + parseNewMeta(content) { + const block = content.split("/**", 2)[1].split("*/", 1)[0]; + const out = {}; + let field = ""; + let accum = ""; + for (const line of block.split(splitRegex)) { + if (line.length === 0) continue; + if (line.charAt(0) === "@" && line.charAt(1) !== " ") { + out[field] = accum; + const l = line.indexOf(" "); + field = line.substr(1, l - 1); + accum = line.substr(l + 1); + } else { + accum += " " + line.replace("\\n", "\n").replace(escapedAtRegex, "@"); + } + } + out[field] = accum.trim(); + delete out[""]; + out.format = "jsdoc"; + return out; + } + + getContentRequire(type) { + const isPlugin = type === "plugin"; + const self = this; + const originalRequire = isPlugin ? originalJSRequire : originalCSSRequire; + return function (module, filename) { + const baseFolder = isPlugin ? self.pluginsFolder : self.themesFolder; + const possiblePath = path.resolve(baseFolder, path.basename(filename)); + if ( + !fs.existsSync(possiblePath) || + filename !== fs.realpathSync(possiblePath) + ) + return Reflect.apply(originalRequire, this, arguments); + let content = fs.readFileSync(filename, "utf8"); + content = Utils.stripBOM(content); + + const stats = fs.statSync(filename); + const meta = self.extractMeta(content); + meta.filename = path.basename(filename); + meta.added = stats.atimeMs; + meta.modified = stats.mtimeMs; + meta.size = stats.size; + if (!isPlugin) { + meta.css = content; + if (meta.format == "json") + meta.css = meta.css.split("\n").slice(1).join("\n"); + content = `module.exports = ${JSON.stringify(meta)};`; + } + if (isPlugin) { + module._compile(content, module.filename); + const didExport = !Utils.isEmpty(module.exports); + if (didExport) { + meta.type = module.exports; + module.exports = meta; + content = ""; + } else { + Utils.warn( + "Module Not Exported", + `${meta.name}, please start setting module.exports` + ); + content += `\nmodule.exports = ${JSON.stringify( + meta + )};\nmodule.exports.type = ${meta.exports || meta.name};`; + } + } + module._compile(content, filename); + }; + } + + makePlaceholderPlugin(data) { + return { + plugin: { + start: () => {}, + getName: () => { + return data.name || data.filename; + }, + getAuthor: () => { + return "???"; + }, + getDescription: () => { + return data.message + ? data.message + : "This plugin was unable to be loaded. Check the author's page for updates."; + }, + getVersion: () => { + return "???"; + }, + }, + name: data.name || data.filename, + filename: data.filename, + source: data.source ? data.source : "", + website: data.website ? data.website : "", + }; + } + + async loadContent(filename, type) { + if (typeof filename === "undefined" || typeof type === "undefined") return; + const isPlugin = type === "plugin"; + const baseFolder = isPlugin ? this.pluginsFolder : this.themesFolder; + + if (settingsCookie["fork-ps-6"]) { + let result = await new Promise((resolve) => { + processFile( + path.resolve(baseFolder, filename), + (result) => { + console.log(result); + resolve(result); + }, + (hash) => { + resolve({ + suspect: false, + hash: hash, + filename: filename, + name: filename, + }); + }, + true + ); + }); + if (result) { + addonCache[result.hash] = { + timestamp: Date.now(), + hash: result.hash, + result: result, + }; + this.saveAddonCache(); + if (result.suspect) { + return { + name: filename, + file: filename, + message: "This plugin might be dangerous (" + result.harm + ").", + error: new Error( + "This plugin might be dangerous (" + result.harm + ")." + ), + }; + } + } } - loadPlugins() {return this.loadAllContent("plugin");} - loadThemes() {return this.loadAllContent("theme");} -}; + try { + __non_webpack_require__(path.resolve(baseFolder, filename)); + } catch (error) { + return { + name: filename, + file: filename, + message: "Could not be compiled.", + error: { message: error.message, stack: error.stack }, + }; + } + const content = __non_webpack_require__(path.resolve(baseFolder, filename)); + if (!content.name) + return { + name: filename, + file: filename, + message: "Cannot escape the ID.", + error: new Error("Cannot read property 'replace' of undefined"), + }; + content.id = Utils.escapeID(content.name); + //if(!id)return {name: filename, file: filename, message: "Invalid ID", error: new Error("Please fix the name of "+filename+". BetterDiscord can't escape an ID.")} + if (isPlugin) { + if (!content.type) return; + try { + content.plugin = new content.type(); + delete bdplugins[content.plugin.getName()]; + bdplugins[content.plugin.getName()] = content; + } catch (error) { + return { + name: filename, + file: filename, + message: "Could not be constructed.", + error: { message: error.message, stack: error.stack }, + }; + } + } else { + delete bdthemes[content.name]; + bdthemes[content.name] = content; + } + } + + unloadContent(filename, type) { + if (typeof filename === "undefined" || typeof type === "undefined") return; + const isPlugin = type === "plugin"; + const baseFolder = isPlugin ? this.pluginsFolder : this.themesFolder; + try { + delete __non_webpack_require__.cache[ + __non_webpack_require__.resolve(path.resolve(baseFolder, filename)) + ]; + } catch (err) { + return { + name: filename, + file: filename, + message: "Could not be unloaded.", + error: { message: err.message, stack: err.stack }, + }; + } + } + + isLoaded(filename, type) { + const isPlugin = type === "plugin"; + const baseFolder = isPlugin ? this.pluginsFolder : this.themesFolder; + try { + __non_webpack_require__.cache[ + __non_webpack_require__.resolve(path.resolve(baseFolder, filename)) + ]; + } catch (err) { + return false; + } + return true; + } + + async reloadContent(filename, type) { + const cantUnload = this.unloadContent(filename, type); + if (cantUnload) return cantUnload; + return await this.loadContent(filename, type); + } + + loadNewContent(type) { + const isPlugin = type === "plugin"; + const fileEnding = isPlugin ? ".plugin.js" : ".theme.css"; + const basedir = isPlugin ? this.pluginsFolder : this.themesFolder; + const files = fs.readdirSync(basedir); + const contentList = Object.values(isPlugin ? bdplugins : bdthemes); + const removed = contentList + .filter((t) => !files.includes(t.filename)) + .map((c) => (isPlugin ? c.plugin.getName() : c.name)); + const added = files.filter( + (f) => + !contentList.find((t) => t.filename == f) && + f.endsWith(fileEnding) && + fs.statSync(path.resolve(basedir, f)).isFile() + ); + return { added, removed }; + } + + async loadAllContent(type) { + this.patchExtensions(); + const isPlugin = type === "plugin"; + const fileEnding = isPlugin ? ".plugin.js" : ".theme.css"; + const basedir = isPlugin ? this.pluginsFolder : this.themesFolder; + const errors = []; + const files = fs.readdirSync(basedir); + + for (const filename of files) { + if ( + !fs.statSync(path.resolve(basedir, filename)).isFile() || + !filename.endsWith(fileEnding) + ) + continue; + const error = await this.loadContent(filename, type); + if (error) errors.push(error); + } + + return errors; + } + + loadPlugins() { + return this.loadAllContent("plugin"); + } + loadThemes() { + return this.loadAllContent("theme"); + } +})(); /** * Don't expose contentManager - could be dangerous for now - */ \ No newline at end of file + */ diff --git a/BetterDiscordApp/src/modules/publicServers.js b/BetterDiscordApp/src/modules/publicServers.js index eb72d96..1cfed5d 100644 --- a/BetterDiscordApp/src/modules/publicServers.js +++ b/BetterDiscordApp/src/modules/publicServers.js @@ -1,58 +1,87 @@ -import {settingsCookie} from "../0globals"; +import { settingsCookie } from "../0globals"; import BDV2 from "./v2"; import webpackModules from "./webpackModules"; import Utils from "./utils"; import DOM from "./domtools"; import V2C_PublicServers from "../ui/publicservers/publicServers"; -import Layers from "./Layers"; +import Layer from "../ui/publicservers/layer"; -export default new class V2_PublicServers { +export default new (class V2_PublicServers { + constructor() { + this._appendButton = this._appendButton.bind(this); + } - constructor() { - this._appendButton = this._appendButton.bind(this); - window.Lightcord.BetterDiscord.V2_PublicServers = this + get component() { + return BDV2.react.createElement( + Layer, + { rootId: "pubslayerroot", id: "pubslayer" }, + BDV2.react.createElement(V2C_PublicServers, { rootId: "pubslayerroot" }) + ); + } + + get root() { + const _root = document.getElementById("pubslayerroot"); + if (!_root) { + if (!this.injectRoot()) return null; + return this.root; } + return _root; + } - render() { - Layers.createLayer((close) => { - return BDV2.react.createElement(V2C_PublicServers, {rootId: "pubslayerroot", close}) - }) + injectRoot() { + const layers = DOM.query(".layers, .layers-3iHuyZ"); + if (!layers) return false; + layers.append(DOM.createElement("
")); + return true; + } + + render() { + const root = this.root; + if (!root) { + console.log("FAILED TO LOCATE ROOT: .layers"); + return; } + BDV2.reactDom.render(this.component, root); + } - get button() { - const btn = DOM.createElement(`
`); - if (!settingsCookie["bda-gs-1"]) btn.style.display = "none"; - const label = DOM.createElement(`
public
`); - label.addEventListener("click", () => {this.render();}); - btn.append(label); - return btn; - } + get button() { + const btn = DOM.createElement( + `
` + ); + if (!settingsCookie["bda-gs-1"]) btn.style.display = "none"; + const label = DOM.createElement( + `
public
` + ); + label.addEventListener("click", () => { + this.render(); + }); + btn.append(label); + return btn; + } - _appendButton() { - let [ - classNametutorialContainer - ] = [ - Utils.removeDa(BDModules.get(e => e.downloadProgress && e.tutorialContainer)[0].tutorialContainer) - ] - if (DOM.query("#bd-pub-li")) return; - const guilds = DOM.query(`div.${classNametutorialContainer} > div`); - DOM.after(guilds, this.button); - } + _appendButton() { + /*if (DOM.query("#bd-pub-li")) return; + const wrapper = BDV2.guildClasses.wrapper.split(" ")[0]; + const guilds = DOM.query(`.${wrapper} .scroller-2TZvBN >:first-child`); + if (guilds) DOM.after(guilds, this.button);*/ + } - addButton() { - if (this.guildPatch) return; + addButton() { + /*if (this.guildPatch) return; const GuildList = webpackModules.find(m => m.default && m.default.displayName == "NavigableGuilds"); const GuildListOld = webpackModules.findByDisplayName("Guilds"); if (!GuildList && !GuildListOld) Utils.warn("PublicServer", "Can't find GuildList component"); this.guildPatch = Utils.monkeyPatch(GuildList ? GuildList : GuildListOld.prototype, GuildList ? "default" : "render", {after: this._appendButton}); - this._appendButton(); - } + this._appendButton();*/ + } - removeButton() { - this.guildPatch(); + removeButton() { + /*this.guildPatch(); delete this.guildPatch; const button = DOM.query("#bd-pub-li"); - if (button) button.remove(); - } -}; \ No newline at end of file + if (button) button.remove();*/ + } +})(); diff --git a/BetterDiscordApp/src/modules/v2.js b/BetterDiscordApp/src/modules/v2.js index 7843711..d95ecd1 100644 --- a/BetterDiscordApp/src/modules/v2.js +++ b/BetterDiscordApp/src/modules/v2.js @@ -1,167 +1,272 @@ -import {settings} from "../0globals"; -import themeModule from "./themeModule"; +import { settings } from "../0globals"; -export default new class V2 { +export default new (class V2 { + constructor() { + this.editorDetached = false; + this.WebpackModules = (() => { + const req = webpackJsonp.push([ + [], + { __extra_id__: (module, exports, req) => (module.exports = req) }, + [["__extra_id__"]], + ]); + delete req.m.__extra_id__; + delete req.c.__extra_id__; - constructor() { - this.editorDetached = false; - this.WebpackModules = (() => { - const req = webpackJsonp.push([[], {__extra_id__: (module, exports, req) => module.exports = req}, [["__extra_id__"]]]); - delete req.m.__extra_id__; - delete req.c.__extra_id__; + const shouldProtect = (theModule) => { + if ( + theModule.remove && + theModule.set && + theModule.clear && + theModule.get && + !theModule.sort + ) + return true; + if (theModule.getToken || theModule.getEmail || theModule.showToken) + return true; + return false; + }; - const shouldProtect = theModule => { - if (theModule.remove && theModule.set && theModule.clear && theModule.get && !theModule.sort) return true; - if (theModule.getToken || theModule.getEmail || theModule.showToken) return true; - return false; - }; + const protect = (theModule) => { + if ( + theModule.remove && + theModule.set && + theModule.clear && + theModule.get && + !theModule.sort + ) + return null; + if (!theModule.getToken && !theModule.getEmail && !theModule.showToken) + return theModule; + const proxy = new Proxy(theModule, { + getOwnPropertyDescriptor: function (obj, prop) { + if ( + prop === "getToken" || + prop === "getEmail" || + prop === "showToken" + ) + return undefined; + return Object.getOwnPropertyDescriptor(obj, prop); + }, + get: function (obj, func) { + if (func == "getToken") + return () => + "mfa.XCnbKzo0CLIqdJzBnL0D8PfDruqkJNHjwHXtr39UU3F8hHx43jojISyi5jdjO52e9_e9MjmafZFFpc-seOMa"; + if (func == "getEmail") return () => "puppet11112@gmail.com"; + if (func == "showToken") return () => true; + // if (func == "__proto__") return proxy; + return obj[func]; + }, + }); + return proxy; + }; - const protect = (theModule, isDefault) => { - let mod = !isDefault ? theModule.default : theModule - if(!mod)return theModule - if (mod.remove && mod.set && mod.clear && mod.get && !mod.sort) return null; - if (!mod.getToken && !mod.getEmail && !mod.showToken)return theModule + const find = (filter) => { + for (const i in req.c) { + if (req.c.hasOwnProperty(i)) { + const m = req.c[i].exports; + if (m && m.__esModule && m.default && filter(m.default)) + return protect(m.default); + if (m && filter(m)) return protect(m); + } + } + // console.warn("Cannot find loaded module in cache"); + return null; + }; - const proxy = new Proxy(mod, { - getOwnPropertyDescriptor: function(obj, prop) { - if (prop === "getToken" || prop === "getEmail" || prop === "showToken") return undefined; - return Object.getOwnPropertyDescriptor(obj, prop); - }, - get: function(obj, func) { - if (func == "getToken" && obj.getToken) return () => "mfa.XCnbKzo0CLIqdJzBnL0D8PfDruqkJNHjwHXtr39UU3F8hHx43jojISyi5jdjO52e9_e9MjmafZFFpc-seOMa"; - if (func == "getEmail" && obj.getEmail) return () => "puppet11112@gmail.com"; - if (func == "showToken" && obj.showToken) return () => true; - if (func == "__proto__" && obj.__proto__) return proxy; - - return obj[func]; - } - }); + const findAll = (filter) => { + const modules = []; + for (const i in req.c) { + if (req.c.hasOwnProperty(i)) { + const m = req.c[i].exports; + if (m && m.__esModule && m.default && filter(m.default)) + modules.push(protect(m.default)); + else if (m && filter(m)) modules.push(protect(m)); + } + } + return modules; + }; - if(!isDefault){ - return Object.assign({}, theModule, {default: proxy}) - } + const findByUniqueProperties = (propNames) => + find((module) => propNames.every((prop) => module[prop] !== undefined)); + const findByPrototypes = (protoNames) => + find( + (module) => + module.prototype && + protoNames.every( + (protoProp) => module.prototype[protoProp] !== undefined + ) + ); + const findByDisplayName = (displayName) => + find((module) => module.displayName === displayName); - return proxy; - }; + return { + find, + findAll, + findByUniqueProperties, + findByPrototypes, + findByDisplayName, + }; + })(); - const find = (filter) => { - for (const i in req.c) { - if (req.c.hasOwnProperty(i)) { - const m = req.c[i].exports; - if (m && m.__esModule && m.default && filter(m.default)) return protect(m.default, true); - if (m && filter(m)) return protect(m, false); - } - } - // console.warn("Cannot find loaded module in cache"); - return null; - }; + this.internal = { + react: this.WebpackModules.findByUniqueProperties([ + "Component", + "PureComponent", + "Children", + "createElement", + "cloneElement", + ]), + reactDom: this.WebpackModules.findByUniqueProperties(["findDOMNode"]), + }; + this.getInternalInstance = (e) => + e[Object.keys(e).find((k) => k.startsWith("__reactInternalInstance"))]; + } - const findAll = (filter) => { - const modules = []; - for (const i in req.c) { - if (req.c.hasOwnProperty(i)) { - const m = req.c[i].exports; - if (m && m.__esModule && m.default && filter(m.default)) modules.push(protect(m.default, true)); - else if (m && filter(m)) modules.push(protect(m, false)); - } - } - return modules; - }; + initialize() {} - const findByUniqueProperties = (propNames) => find(module => propNames.every(prop => module[prop] !== undefined)); - const findByPrototypes = (protoNames) => find(module => module.prototype && protoNames.every(protoProp => module.prototype[protoProp] !== undefined)); - const findByDisplayName = (displayName) => find(module => module.displayName === displayName); + joinBD1() { + this.InviteActions.acceptInviteAndTransitionToInviteChannel( + "0Tmfo5ZbORCRqbAd" + ); + } + leaveBD1() { + this.GuildActions.leaveGuild("86004744966914048"); + } - return {find, findAll, findByUniqueProperties, findByPrototypes, findByDisplayName}; - })(); + joinBD2() { + this.InviteActions.acceptInviteAndTransitionToInviteChannel("2HScm8j"); + } + leaveBD2() { + this.GuildActions.leaveGuild("280806472928198656"); + } - this.internal = { - react: this.WebpackModules.findByUniqueProperties(["Component", "PureComponent", "Children", "createElement", "cloneElement"]), - reactDom: this.WebpackModules.findByUniqueProperties(["findDOMNode"]) - }; - this.getInternalInstance = e => e[Object.keys(e).find(k => k.startsWith("__reactInternalInstance"))]; - window.Lightcord.BetterDiscord.V2 = this - } + get react() { + return this.internal.react; + } + get React() { + return this.internal.react; + } + get reactDom() { + return this.internal.reactDom; + } + get ReactDom() { + return this.internal.reactDom; + } + get reactComponent() { + return this.internal.react.Component; + } + get ReactComponent() { + return this.internal.react.Component; + } - initialize() { + get anchorClasses() { + return ( + this.WebpackModules.findByUniqueProperties([ + "anchorUnderlineOnHover", + ]) || { + anchor: "anchor-3Z-8Bb", + anchorUnderlineOnHover: "anchorUnderlineOnHover-2ESHQB", + } + ); + } + get slateEditorClasses() { + return this.WebpackModules.findByUniqueProperties(["slateTextArea"]); + } + get messageClasses() { + return this.WebpackModules.findByUniqueProperties([ + "message", + "containerCozy", + ]); + } + get guildClasses() { + const guildsWrapper = this.WebpackModules.findByUniqueProperties([ + "wrapper", + "unreadMentionsBar", + ]); + const guilds = this.WebpackModules.findByUniqueProperties([ + "guildsError", + "selected", + ]); + const pill = this.WebpackModules.findByUniqueProperties(["blobContainer"]); + return Object.assign({}, guildsWrapper, guilds, pill); + } - } + get MessageContentComponent() { + return this.WebpackModules.find( + (m) => m.defaultProps && m.defaultProps.hasOwnProperty("disableButtons") + ); + } + get MessageComponent() { + return this.WebpackModules.find( + (m) => + m.default && m.default.toString().search("childrenRepliedMessage") > -1 + ); + } + get TimeFormatter() { + return this.WebpackModules.findByUniqueProperties(["dateFormat"]); + } + get TooltipWrapper() { + return this.WebpackModules.findByDisplayName("Tooltip"); + } + get NativeModule() { + return this.WebpackModules.findByUniqueProperties(["setBadge"]); + } + get InviteActions() { + return this.WebpackModules.findByUniqueProperties(["acceptInvite"]); + } + get GuildActions() { + return this.WebpackModules.findByUniqueProperties(["leaveGuild"]); + } + get Tooltips() { + return this.WebpackModules.find( + (m) => + m.hide && + m.show && + !m.search && + !m.submit && + !m.search && + !m.activateRagingDemon && + !m.dismiss + ); + } + get KeyGenerator() { + return this.WebpackModules.find( + (m) => m.toString && /"binary"/.test(m.toString()) + ); + } + get LayerStack() { + return this.WebpackModules.findByUniqueProperties(["popLayer"]); + } + get UserStore() { + return this.WebpackModules.findByUniqueProperties(["getCurrentUser"]); + } + get ChannelStore() { + return this.WebpackModules.findByUniqueProperties(["getChannel"]); + } + get ChannelActions() { + return this.WebpackModules.findByUniqueProperties(["openPrivateChannel"]); + } + get PrivateChannelActions() { + return this.WebpackModules.findByUniqueProperties(["selectPrivateChannel"]); + } - joinBD1() {this.InviteActions.acceptInviteAndTransitionToInviteChannel("0Tmfo5ZbORCRqbAd");} - leaveBD1() {this.GuildActions.leaveGuild("86004744966914048");} + openDM(userId) { + const selfId = this.UserStore.getCurrentUser().id; + if (selfId == userId) return; + const privateChannelId = this.ChannelStore.getDMFromUserId(userId); + if (privateChannelId) + return this.PrivateChannelActions.selectPrivateChannel(privateChannelId); + this.ChannelActions.openPrivateChannel(selfId, userId); + } - joinBD2() {this.InviteActions.acceptInviteAndTransitionToInviteChannel("2HScm8j");} - leaveBD2() {this.GuildActions.leaveGuild("280806472928198656");} - - joinLC() {this.InviteActions.acceptInviteAndTransitionToInviteChannel("7eFff2A");} - leaveLC() {this.GuildActions.leaveGuild("705908350218666117");} - - /** - * @type {typeof React} - */ - get react() {return this.internal.react;} - /** - * @type {typeof React} - */ - get React() {return this.internal.react;} - /** - * @type {typeof import("react-dom")} - */ - get reactDom() {return this.internal.reactDom;} - /** - * @type {typeof import("react-dom")} - */ - get ReactDom() {return this.internal.reactDom;} - /** - * @type {typeof React.Component} - */ - get reactComponent() {return this.internal.react.Component;} - /** - * @type {typeof React.Component} - */ - get ReactComponent() {return this.internal.react.Component;} - - get anchorClasses() {return this.WebpackModules.findByUniqueProperties(["anchorUnderlineOnHover"]) || {anchor: "anchor-3Z-8Bb", anchorUnderlineOnHover: "anchorUnderlineOnHover-2ESHQB"};} - get slateEditorClasses() {return this.WebpackModules.findByUniqueProperties(["slateTextArea"]);} - get messageClasses() {return this.WebpackModules.findByUniqueProperties(["message", "containerCozy"]);} - get guildClasses() { - const guildsWrapper = BDModules.get(e => e.wrapper && e.unreadMentionsBar)[0]; - const guilds = BDModules.get(e => e.guildsError && e.selected)[0] - const pill = BDModules.get(e => e.blobContainer)[0] - return Object.assign({}, guildsWrapper, guilds, pill); - } - - get MessageContentComponent() {return this.WebpackModules.find(m => m.defaultProps && m.defaultProps.hasOwnProperty("disableButtons"));} - get MessageComponent() {return this.WebpackModules.find(m => m.default && m.default.displayName && m.default.displayName == "Message");} - get TimeFormatter() {return this.WebpackModules.findByUniqueProperties(["dateFormat"]);} - get TooltipWrapper() {return this.WebpackModules.findByDisplayName("Tooltip");} - get NativeModule() {return this.WebpackModules.findByUniqueProperties(["setBadge"]);} - get InviteActions() {return this.WebpackModules.findByUniqueProperties(["acceptInvite"]);} - get GuildActions() {return this.WebpackModules.findByUniqueProperties(["leaveGuild"]);} - get Tooltips() {return this.WebpackModules.find(m => m.hide && m.show && !m.search && !m.submit && !m.search && !m.activateRagingDemon && !m.dismiss);} - get KeyGenerator() {return this.WebpackModules.find(m => m.toString && /"binary"/.test(m.toString()));} - get LayerStack() {return this.WebpackModules.findByUniqueProperties(["popLayer"]);} - get UserStore() {return this.WebpackModules.findByUniqueProperties(["getCurrentUser"]);} - get ChannelStore() {return this.WebpackModules.findByUniqueProperties(["getChannel"]);} - get ChannelActions() {return this.WebpackModules.findByUniqueProperties(["openPrivateChannel"]);} - get PrivateChannelActions() {return this.WebpackModules.findByUniqueProperties(["selectPrivateChannel"]);} - - openDM(userId) { - const selfId = this.UserStore.getCurrentUser().id; - if (selfId == userId) return; - const privateChannelId = this.ChannelStore.getDMFromUserId(userId); - if (privateChannelId) return this.PrivateChannelActions.selectPrivateChannel(privateChannelId); - this.ChannelActions.openPrivateChannel(selfId, userId); - } - - parseSettings(cat) { - return Object.keys(settings).reduce((arr, key) => { - const setting = settings[key]; - if (setting.cat === cat && setting.implemented && !setting.hidden) { - setting.text = key; - arr.push(setting); - } return arr; - }, []); - } - -}; \ No newline at end of file + parseSettings(cat) { + return Object.keys(settings).reduce((arr, key) => { + const setting = settings[key]; + if (setting.cat === cat && setting.implemented && !setting.hidden) { + setting.text = key; + arr.push(setting); + } + return arr; + }, []); + } +})(); diff --git a/BetterDiscordApp/src/ui/bdEmote.js b/BetterDiscordApp/src/ui/bdEmote.js new file mode 100644 index 0000000..158d2ea --- /dev/null +++ b/BetterDiscordApp/src/ui/bdEmote.js @@ -0,0 +1,87 @@ +import {settingsCookie} from "../0globals"; +import quickEmoteMenu from "../modules/quickEmoteMenu"; +import BDV2 from "../modules/v2"; + +export default class BDEmote extends BDV2.reactComponent { + constructor(props) { + super(props); + + const isFav = quickEmoteMenu && quickEmoteMenu.favoriteEmotes && quickEmoteMenu.favoriteEmotes[this.label] ? true : false; + this.state = { + shouldAnimate: !this.animateOnHover, + isFavorite: isFav + }; + + this.onMouseEnter = this.onMouseEnter.bind(this); + this.onMouseLeave = this.onMouseLeave.bind(this); + this.onClick = this.onClick.bind(this); + } + + get animateOnHover() { + return settingsCookie["fork-es-2"]; + } + + get label() { + return this.props.modifier ? `${this.props.name}:${this.props.modifier}` : this.props.name; + } + + get modifierClass() { + return this.props.modifier ? ` emote${this.props.modifier}` : ""; + } + + onMouseEnter() { + if (!this.state.shouldAnimate && this.animateOnHover) this.setState({shouldAnimate: true}); + if (!this.state.isFavorite && quickEmoteMenu.favoriteEmotes[this.label]) this.setState({isFavorite: true}); + else if (this.state.isFavorite && !quickEmoteMenu.favoriteEmotes[this.label]) this.setState({isFavorite: false}); + } + + onMouseLeave() { + if (this.state.shouldAnimate && this.animateOnHover) this.setState({shouldAnimate: false}); + } + + onClick(e) { + if (this.props.onClick) this.props.onClick(e); + } + + render() { + return BDV2.react.createElement(BDV2.TooltipWrapper, { + color: "black", + position: "top", + text: this.label, + delay: 750 + }, + (childProps) => { + return BDV2.react.createElement("div", Object.assign({ + className: "emotewrapper" + (this.props.jumboable ? " jumboable" : ""), + onMouseEnter: this.onMouseEnter, + onMouseLeave: this.onMouseLeave, + onClick: this.onClick + }, childProps), + BDV2.react.createElement("img", { + draggable: false, + className: "emote" + this.modifierClass + (this.props.jumboable ? " jumboable" : "") + (!this.state.shouldAnimate ? " stop-animation" : ""), + dataModifier: this.props.modifier, + alt: this.label, + src: this.props.url + }), + BDV2.react.createElement("input", { + className: "fav" + (this.state.isFavorite ? " active" : ""), + title: "Favorite!", + type: "button", + onClick: (e) => { + e.preventDefault(); + e.stopPropagation(); + if (this.state.isFavorite) { + delete quickEmoteMenu.favoriteEmotes[this.label]; + quickEmoteMenu.updateFavorites(); + } + else { + quickEmoteMenu.favorite(this.label, this.props.url); + } + this.setState({isFavorite: !this.state.isFavorite}); + } + }) + ); + }); + } +} \ No newline at end of file diff --git a/BetterDiscordApp/src/ui/publicservers/layer.js b/BetterDiscordApp/src/ui/publicservers/layer.js new file mode 100644 index 0000000..4a5b72e --- /dev/null +++ b/BetterDiscordApp/src/ui/publicservers/layer.js @@ -0,0 +1,89 @@ +import BDV2 from "../../modules/v2"; +import DOM from "../../modules/domtools"; + +export default class V2C_Layer extends BDV2.reactComponent { + + constructor(props) { + super(props); + this.keyupListener = this.keyupListener.bind(this); + } + + keyupListener(e) { + if (e.which === 27) { + BDV2.reactDom.unmountComponentAtNode(this.refs.root.parentNode); + } + } + + componentDidMount() { + window.addEventListener("keyup", this.keyupListener); + + const thisNode = DOM.query(`#${this.props.id}`); + DOM.animate({ + duration: 200, + update: function(progress) { + thisNode.style.transform = `scale(${1.1 - 0.1 * progress}) translateZ(0px)`; + thisNode.style.opacity = progress; + if (progress == 1) { + setImmediate(() => { + thisNode.style.transform = ""; + thisNode.style.opacity = ""; + }); + } + } + }); + } + + componentWillUnmount() { + window.removeEventListener("keyup", this.keyupListener); + + const thisNode = DOM.query(`#${this.props.id}`); + DOM.animate({ + duration: 200, + update: function(progress) { + thisNode.style.transform = `scale(${1.1 - 0.1 * (1 - progress)}) translateZ(0px)`; + thisNode.style.opacity = 1 - progress; + if (progress == 1) { + setImmediate(() => { + thisNode.remove(); + }); + } + } + }); + + const layer = DOM.query(".publicServersOpen"); + layer.classList.remove("publicServersOpen"); + DOM.animate({ + duration: 200, + update: function(progress) { + layer.style.transform = `scale(${0.07 * progress + 0.93}) translateZ(0px)`; + layer.style.opacity = progress; + if (progress == 1) { + setImmediate(() => { + layer.style.transform = ""; + layer.style.opacity = ""; + }); + } + } + }); + } + + componentWillMount() { + const layer = DOM.query("[class*=\"layer-\"]"); + layer.classList.add("publicServersOpen"); + DOM.animate({ + duration: 200, + update: function(progress) { + layer.style.transform = `scale(${0.07 * (1 - progress) + 0.93}) translateZ(0px)`; + layer.style.opacity = 1 - progress; + } + }); + } + + render() { + return BDV2.react.createElement( + "div", + {className: "layer bd-layer layer-3QrUeG", id: this.props.id, ref: "root", style: {opacity: 0, transform: "scale(1.1) translateZ(0px)"}}, + this.props.children + ); + } +} \ No newline at end of file diff --git a/BetterDiscordApp/src/ui/publicservers/sidebarView.js b/BetterDiscordApp/src/ui/publicservers/sidebarView.js new file mode 100644 index 0000000..3410ce7 --- /dev/null +++ b/BetterDiscordApp/src/ui/publicservers/sidebarView.js @@ -0,0 +1,32 @@ +import BDV2 from "../../modules/v2"; + +import Scroller from "../scroller"; + +export default class V2C_SidebarView extends BDV2.reactComponent { + + constructor(props) { + super(props); + } + + render() { + const {sidebar, content, tools} = this.props.children; + return BDV2.react.createElement( + "div", + {className: "standardSidebarView-3F1I7i ui-standard-sidebar-view"}, + BDV2.react.createElement( + "div", + {className: "sidebarRegion-VFTUkN sidebar-region"}, + BDV2.react.createElement(Scroller, {key: "sidebarScroller", ref: "sidebarScroller", sidebar: true, fade: sidebar.fade || true, dark: sidebar.dark || true}, sidebar.component) + ), + BDV2.react.createElement("div", {className: "contentRegion-3nDuYy content-region"}, + BDV2.react.createElement("div", {className: "contentTransitionWrap-3hqOEW content-transition-wrap"}, + BDV2.react.createElement("div", {className: "scroller-2FKFPG firefoxFixScrollFlex-cnI2ix contentRegionScroller-26nc1e content-region-scroller scroller", ref: "contentScroller"}, + + BDV2.react.createElement("div", {className: "contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"}, content.component), + tools.component + ) + ) + ) + ); + } +} \ No newline at end of file diff --git a/BetterDiscordApp/src/ui/settingsGroup.js b/BetterDiscordApp/src/ui/settingsGroup.js new file mode 100644 index 0000000..8c18ff9 --- /dev/null +++ b/BetterDiscordApp/src/ui/settingsGroup.js @@ -0,0 +1,24 @@ +import {settingsCookie} from "../0globals"; +import BDV2 from "../modules/v2"; + +import SettingsTitle from "./settingsTitle"; +import Switch from "./switch"; + +export default class V2C_SettingsGroup extends BDV2.reactComponent { + + constructor(props) { + super(props); + } + + render() { + const {title, settings, button} = this.props; + const buttonComponent = button ? BDV2.react.createElement("button", {key: "title-button", className: "bd-pfbtn", onClick: button.onClick}, button.title) : null; + return [BDV2.react.createElement(SettingsTitle, {text: title}), + buttonComponent, + settings.map(setting => { + return BDV2.react.createElement(Switch, {id: setting.id, key: setting.id, data: setting, checked: settingsCookie[setting.id], onChange: (id, checked) => { + this.props.onChange(id, checked); + }}); + })]; + } +} \ No newline at end of file diff --git a/BetterDiscordApp/src/ui/sidebar.js b/BetterDiscordApp/src/ui/sidebar.js new file mode 100644 index 0000000..0f99814 --- /dev/null +++ b/BetterDiscordApp/src/ui/sidebar.js @@ -0,0 +1,77 @@ +import BDV2 from "../modules/v2"; + +import TabBarSeparator from "./tabBarSeparator"; +import TabBarHeader from "./tabBarHeader"; +import TabBarItem from "./tabBarItem"; + +export default class V2C_SideBar extends BDV2.reactComponent { + + constructor(props) { + super(props); + const si = document.querySelector("[class*=side-] > [class*=selected]"); + if (si) this.scn = si.className; + const ns = document.querySelector("[class*=side-] > [class*='item-']:not([class*=selected])"); + if (ns) this.nscn = ns.className; + const tabs = document.querySelectorAll("[class*='side-'] > [class*='item-']"); + for (const element of tabs) { + element.addEventListener("click", () => { + this.setState({ + selected: null + }); + }); + } + + this.setInitialState(); + this.onClick = this.onClick.bind(this); + this.setSelected = this.setSelected.bind(this); + } + + setInitialState() { + const self = this; + self.state = { + selected: null, + items: self.props.items + }; + + const initialSelection = self.props.items.find(item => { + return item.selected; + }); + if (initialSelection) { + self.state.selected = initialSelection.id; + } + } + + render() { + const self = this; + const {headerText} = self.props; + const {items, selected} = self.state; + return BDV2.react.createElement( + "div", + null, + BDV2.react.createElement(TabBarSeparator, null), + BDV2.react.createElement(TabBarHeader, {text: headerText, button: this.props.headerButton}), + items.map(item => { + const {id, text} = item; + return BDV2.react.createElement(TabBarItem, {key: id, selected: selected === id, text: text, id: id, onClick: self.onClick}); + }) + ); + } + + setSelected(e) { + e.target.className = this.scn; + } + + onClick(id) { + const si = document.querySelector("[class*=side] > [class*=selected]"); + if (si) { + si.removeEventListener("click", this.setSelected); + si.addEventListener("click", this.setSelected); + si.className = this.nscn; + } + + this.setState({selected: null}); + this.setState({selected: id}); + + if (this.props.onClick) this.props.onClick(id); + } +} \ No newline at end of file diff --git a/DiscordJS/package-lock.json b/DiscordJS/package-lock.json index 1fafb4f..159a19b 100644 --- a/DiscordJS/package-lock.json +++ b/DiscordJS/package-lock.json @@ -1,373 +1,8 @@ { "name": "discord.js-lightcord", "version": "11.6.4", - "lockfileVersion": 2, + "lockfileVersion": 1, "requires": true, - "packages": { - "": { - "name": "discord.js-lightcord", - "version": "11.6.4", - "license": "ISC", - "dependencies": { - "@discordjs/collection": "0.1.5" - }, - "devDependencies": { - "ts-loader": "^7.0.5", - "typescript": "^3.9.5" - } - }, - "node_modules/@discordjs/collection": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.5.tgz", - "integrity": "sha512-CU1q0UXQUpFNzNB7gufgoisDHP7n+T3tkqTsp3MNUkVJ5+hS3BCvME8uCXAUFlz+6T2FbTCu75A+yQ7HMKqRKw==" - }, - "node_modules/ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "dependencies": { - "color-convert": "^1.9.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/big.js": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", - "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", - "dev": true, - "engines": { - "node": "*" - } - }, - "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "dev": true, - "dependencies": { - "fill-range": "^7.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "dependencies": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "dependencies": { - "color-name": "1.1.3" - } - }, - "node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true - }, - "node_modules/core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, - "node_modules/emojis-list": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz", - "integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==", - "dev": true, - "engines": { - "node": ">= 4" - } - }, - "node_modules/enhanced-resolve": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-4.2.0.tgz", - "integrity": "sha512-S7eiFb/erugyd1rLb6mQ3Vuq+EXHv5cpCkNqqIkYkBgN2QdFnyCZzFBleqwGEx4lgNGYij81BWnCrFNK7vxvjQ==", - "dev": true, - "dependencies": { - "graceful-fs": "^4.1.2", - "memory-fs": "^0.5.0", - "tapable": "^1.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/errno": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz", - "integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==", - "dev": true, - "dependencies": { - "prr": "~1.0.1" - }, - "bin": { - "errno": "cli.js" - } - }, - "node_modules/escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "dev": true, - "dependencies": { - "to-regex-range": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/graceful-fs": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", - "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", - "dev": true - }, - "node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true - }, - "node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true, - "engines": { - "node": ">=0.12.0" - } - }, - "node_modules/isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "node_modules/json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", - "dev": true, - "dependencies": { - "minimist": "^1.2.0" - }, - "bin": { - "json5": "lib/cli.js" - } - }, - "node_modules/loader-utils": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.0.tgz", - "integrity": "sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA==", - "dev": true, - "dependencies": { - "big.js": "^5.2.2", - "emojis-list": "^3.0.0", - "json5": "^1.0.1" - }, - "engines": { - "node": ">=4.0.0" - } - }, - "node_modules/memory-fs": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.5.0.tgz", - "integrity": "sha512-jA0rdU5KoQMC0e6ppoNRtpp6vjFq6+NY7r8hywnC7V+1Xj/MtHwGIbB1QaK/dunyjWteJzmkpd7ooeWg10T7GA==", - "dev": true, - "dependencies": { - "errno": "^0.1.3", - "readable-stream": "^2.0.1" - }, - "engines": { - "node": ">=4.3.0 <5.0.0 || >=5.10" - } - }, - "node_modules/micromatch": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz", - "integrity": "sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==", - "dev": true, - "dependencies": { - "braces": "^3.0.1", - "picomatch": "^2.0.5" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true - }, - "node_modules/picomatch": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", - "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", - "dev": true, - "engines": { - "node": ">=8.6" - } - }, - "node_modules/process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", - "dev": true - }, - "node_modules/prr": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", - "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=", - "dev": true - }, - "node_modules/readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, - "node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true, - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "dependencies": { - "safe-buffer": "~5.1.0" - } - }, - "node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/tapable": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz", - "integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, - "dependencies": { - "is-number": "^7.0.0" - }, - "engines": { - "node": ">=8.0" - } - }, - "node_modules/ts-loader": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-7.0.5.tgz", - "integrity": "sha512-zXypEIT6k3oTc+OZNx/cqElrsbBtYqDknf48OZos0NQ3RTt045fBIU8RRSu+suObBzYB355aIPGOe/3kj9h7Ig==", - "dev": true, - "dependencies": { - "chalk": "^2.3.0", - "enhanced-resolve": "^4.0.0", - "loader-utils": "^1.0.2", - "micromatch": "^4.0.0", - "semver": "^6.0.0" - }, - "engines": { - "node": ">=10.0.0" - } - }, - "node_modules/typescript": { - "version": "3.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.5.tgz", - "integrity": "sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, - "node_modules/util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - } - }, "dependencies": { "@discordjs/collection": { "version": "0.1.5", diff --git a/modules/discord_rpc/package-lock.json b/modules/discord_rpc/package-lock.json index 5134b17..e281836 100644 --- a/modules/discord_rpc/package-lock.json +++ b/modules/discord_rpc/package-lock.json @@ -1,26 +1,8 @@ { "name": "discord_rpc", "version": "1.0.0", - "lockfileVersion": 2, + "lockfileVersion": 1, "requires": true, - "packages": { - "": { - "version": "1.0.0", - "license": "ISC", - "dependencies": { - "ws": "^7.2.3" - }, - "devDependencies": {} - }, - "node_modules/ws": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.2.3.tgz", - "integrity": "sha512-HTDl9G9hbkNDk98naoR/cHDws7+EyYMOdL1BmjsZXRUjf7d+MficC4B7HLUPlSiho0vg+CWKrGIt/VJBd1xunQ==", - "engines": { - "node": ">=8.3.0" - } - } - }, "dependencies": { "ws": { "version": "7.2.3", diff --git a/modules/discord_voice/package-lock.json b/modules/discord_voice/package-lock.json index f3f8916..bff6a4f 100644 --- a/modules/discord_voice/package-lock.json +++ b/modules/discord_voice/package-lock.json @@ -1,169 +1,8 @@ { "name": "discord_voice", "version": "1.0.0", - "lockfileVersion": 2, + "lockfileVersion": 1, "requires": true, - "packages": { - "": { - "version": "1.0.0", - "license": "ISC", - "dependencies": { - "yargs": "^16.2.0" - } - }, - "node_modules/ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", - "engines": { - "node": ">=8" - } - }, - "node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^7.0.0" - } - }, - "node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" - }, - "node_modules/escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", - "engines": { - "node": ">=6" - } - }, - "node_modules/get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, - "node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "engines": { - "node": ">=8" - } - }, - "node_modules/require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/string-width": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", - "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "dependencies": { - "ansi-regex": "^5.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/y18n": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.5.tgz", - "integrity": "sha512-hsRUr4FFrvhhRH12wOdfs38Gy7k2FFzB9qgN9v3aLykRq0dRcdcpz5C9FxdS2NuhOrI/628b/KSTJ3rwHysYSg==", - "engines": { - "node": ">=10" - } - }, - "node_modules/yargs": { - "version": "16.2.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", - "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", - "dependencies": { - "cliui": "^7.0.2", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.0", - "y18n": "^5.0.5", - "yargs-parser": "^20.2.2" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/yargs-parser": { - "version": "20.2.6", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.6.tgz", - "integrity": "sha512-AP1+fQIWSM/sMiET8fyayjx/J+JmTPt2Mr0FkrgqB4todtfa53sOsrSAcIrJRD5XS20bKUwaDIuMkWKCEiQLKA==", - "engines": { - "node": ">=10" - } - } - }, "dependencies": { "ansi-regex": { "version": "5.0.0",