diff options
Diffstat (limited to 'replugged.patch')
-rw-r--r-- | replugged.patch | 291 |
1 files changed, 13 insertions, 278 deletions
diff --git a/replugged.patch b/replugged.patch index a242ab6879a6..7d82a99f323f 100644 --- a/replugged.patch +++ b/replugged.patch @@ -1,278 +1,13 @@ -diff --git a/src/Powercord/coremods/moduleManager/components/manage/Base.jsx b/src/Powercord/coremods/moduleManager/components/manage/Base.jsx -index 0b8a45d9..3e69cf77 100644 ---- a/src/Powercord/coremods/moduleManager/components/manage/Base.jsx -+++ b/src/Powercord/coremods/moduleManager/components/manage/Base.jsx -@@ -3,6 +3,7 @@ const { shell } = require('electron'); - const { React, getModule, contextMenu, i18n: { Messages } } = require('powercord/webpack'); - const { Button, Tooltip, ContextMenu, Divider, Icons: { Overflow } } = require('powercord/components'); - const { TextInput } = require('powercord/components/settings'); -+const XDG_DATA_HOME = process.env.XDG_DATA_HOME || join(process.env.HOME, '.local', 'share'); - - class Base extends React.Component { - constructor () { -@@ -91,7 +92,7 @@ class Base extends React.Component { - { - type: 'button', - name: Messages[`REPLUGGED_${this.state.key}_OPEN_FOLDER`], -- onClick: () => shell.openPath(join(__dirname, '..', '..', '..', '..', '..', '..', this.constructor.name.toLowerCase())) -+ onClick: () => shell.openPath(join(XDG_DATA_HOME, 'replugged', this.constructor.name.toLowerCase())) - }, - { - type: 'button', -diff --git a/src/Powercord/coremods/moduleManager/index.js b/src/Powercord/coremods/moduleManager/index.js -index 2c3a2a9d..14b0f77a 100644 ---- a/src/Powercord/coremods/moduleManager/index.js -+++ b/src/Powercord/coremods/moduleManager/index.js -@@ -6,7 +6,7 @@ const { React, getModule, i18n: { Messages } } = require('powercord/webpack'); - const { PopoutWindow } = require('powercord/components'); - const { inject, uninject } = require('powercord/injector'); - const { findInReactTree, forceUpdateElement } = require('powercord/util'); --const { SpecialChannels: { CSS_SNIPPETS, STORE_PLUGINS, STORE_THEMES }, WEBSITE } = require('powercord/constants'); -+const { SpecialChannels: { CSS_SNIPPETS, STORE_PLUGINS, STORE_THEMES }, WEBSITE, SETTINGS_FOLDER } = require('powercord/constants'); - const { join } = require('path'); - const commands = require('./commands'); - const deeplinks = require('./deeplinks'); -@@ -23,7 +23,7 @@ const { injectContextMenu } = require('powercord/util'); - const Menu = getModule([ 'MenuItem' ], false); - - let _quickCSS = ''; --const _quickCSSFile = join(__dirname, '..', '..', '..', '..', 'settings', 'quickcss', 'main.css'); -+const _quickCSSFile = join(SETTINGS_FOLDER, 'quickcss', 'main.css'); - let _quickCSSElement; - - async function _installerInjectCtxMenu () { -diff --git a/src/Powercord/coremods/moduleManager/util/cloneRepo.js b/src/Powercord/coremods/moduleManager/util/cloneRepo.js -index f015ea76..eb058858 100644 ---- a/src/Powercord/coremods/moduleManager/util/cloneRepo.js -+++ b/src/Powercord/coremods/moduleManager/util/cloneRepo.js -@@ -4,16 +4,18 @@ const fs = require('fs'); - const { REPO_URL_REGEX } = require('./misc'); - const { i18n: { Messages } } = require('powercord/webpack'); - -+const XDG_DATA_HOME = process.env.XDG_DATA_HOME || join(process.env.HOME, '.local', 'share'); -+ - module.exports = async function download (url, powercord, type) { - return new Promise((resolve) => { - // const dir = type === 'plugin' ? join(__dirname, '..', '..') : join(__dirname, '..', '..', 'themes'); - let dir; - switch (type) { - case 'plugin': -- dir = join(__dirname, '..', '..', '..', '..', '..', 'plugins'); -+ dir = join(XDG_DATA_HOME, 'replugged', 'plugins'); - break; - case 'theme': -- dir = join(__dirname, '..', '..', '..', '..', '..', 'themes'); -+ dir = join(XDG_DATA_HOME, 'replugged', 'themes'); - break; - } - -diff --git a/src/Powercord/coremods/updater/components/Settings.jsx b/src/Powercord/coremods/updater/components/Settings.jsx -index b915af1c..fbe64da4 100644 ---- a/src/Powercord/coremods/updater/components/Settings.jsx -+++ b/src/Powercord/coremods/updater/components/Settings.jsx -@@ -82,7 +82,7 @@ module.exports = class UpdaterSettings extends React.PureComponent { - <div className="about"> - <div> - <span>{Messages.REPLUGGED_UPDATES_UPSTREAM}</span> -- <span>{powercord.gitInfos.upstream.replace(REPO_URL, Messages.REPLUGGED_UPDATES_UPSTREAM_OFFICIAL)}</span> -+ <span>{powercord.gitInfos.upstream.replace(REPO_URL, Messages.REPLUGGED_UPDATES_UPSTREAM_OFFICIAL+' (AUR)')}</span> - </div> - <div> - <span>{Messages.REPLUGGED_UPDATES_REVISION}</span> -diff --git a/src/Powercord/coremods/updater/components/Update.jsx b/src/Powercord/coremods/updater/components/Update.jsx -index 7d8fbcaa..ab5be0e9 100644 ---- a/src/Powercord/coremods/updater/components/Update.jsx -+++ b/src/Powercord/coremods/updater/components/Update.jsx -@@ -28,6 +28,7 @@ module.exports = class Update extends React.PureComponent { - </div> - </div> - <div className='summary'> -+ {name === 'Powercord' ? <span>Note: Please download the update from the AUR!</span> : ''} - {commits.map(commit => <div key={commit.id}> - <a href={`https://github.com/${repo}/commit/${commit.id}`} target='_blank'> - <code>{commit.id.substring(0, 7)}</code> -diff --git a/src/Powercord/coremods/updater/index.js b/src/Powercord/coremods/updater/index.js -index 770e195a..e542774c 100644 ---- a/src/Powercord/coremods/updater/index.js -+++ b/src/Powercord/coremods/updater/index.js -@@ -44,9 +44,6 @@ class Updater { - const themes = [ ...powercord.styleManager.themes.values() ]; - - const entities = plugins.concat(themes).filter(e => !disabled.includes(e.updateIdentifier) && e.isUpdatable()); -- if (!disabled.includes(powercord.updateIdentifier)) { -- entities.push(powercord); -- } - - let done = 0; - const updates = []; -@@ -232,33 +229,10 @@ class Updater { - } - - async getGitInfos () { -- const branch = await PowercordNative.exec('git branch', this.cwd) -- .then(({ stdout }) => -- stdout -- .toString() -- .split('\n') -- .find(l => l.startsWith('*')) -- .slice(2) -- .trim() -- ); -- -- const revision = await PowercordNative.exec(`git rev-parse ${branch}`, this.cwd) -- .then(r => r.stdout.toString().trim()); -- -- let upstream = '???'; -- -- const remoteBranch = await powercord.getUpstreamBranch(); -- if (remoteBranch) { -- const remote = remoteBranch.split('/')[0]; -- upstream = await PowercordNative.exec(`git remote get-url ${remote}`, this.cwd) -- .then(r => r.stdout.toString().match(/github\.com[:/]([\w-_]+\/[\w-_]+)/)?.[1] || -- r.stdout.toString().trim().match(/(.*):(.*\/.*)/)[2]); -- } -- - return { -- upstream, -- branch, -- revision -+ upstream: "@PKG_UPSTREAM@", -+ branch: "@PKG_BRANCH@", -+ revision: "@PKG_REVISION@" - }; - } - -diff --git a/src/Powercord/index.js b/src/Powercord/index.js -index 019e304c..0de3d47e 100644 ---- a/src/Powercord/index.js -+++ b/src/Powercord/index.js -@@ -253,6 +253,32 @@ class Powercord extends Updatable { - } - return success; - } -+ -+ async _getUpdateCommits () { -+ return []; -+ } -+ async getBranch () {return this.gitInfos.branch;} -+ async getGitRepo () {return this.gitInfos.upstream;} -+ async _checkForUpdates () { -+ const abort = new AbortController(); -+ const timeout = setTimeout(() => { -+ abort.abort(); -+ throw new Error('Timed out.'); -+ }, 10000); -+ -+ try { -+ const latestCommitSha = await exec(`curl https://api.github.com/repos/${this.gitInfos.upstream}/commits/${this.gitInfos.branch} | jq -r .sha`, { -+ cwd: this.entityPath, -+ signal: abort.signal -+ }).then(({ stdout }) => stdout.toString()); -+ -+ clearTimeout(timeout); -+ return !latestCommitSha.includes(this.gitInfos.revision); -+ } catch (e) { -+ clearTimeout(timeout); -+ return false; -+ } -+ } - } - - module.exports = Powercord; -diff --git a/src/Powercord/managers/plugins.js b/src/Powercord/managers/plugins.js -index c45b34fe..f0cd4dea 100644 ---- a/src/Powercord/managers/plugins.js -+++ b/src/Powercord/managers/plugins.js -@@ -1,10 +1,12 @@ --const { resolve } = require('path'); -+const { resolve, join } = require('path'); - const { readdirSync } = require('fs'); - const { rmdirRf } = require('powercord/util'); - -+const XDG_DATA_HOME = process.env.XDG_DATA_HOME || join(process.env.HOME, '.local', 'share'); -+ - module.exports = class PluginManager { - constructor () { -- this.pluginDir = resolve(__dirname, '..', '..', '..', 'plugins'); -+ this.pluginDir = resolve(XDG_DATA_HOME, 'replugged', 'plugins'); - this.plugins = new Map(); - - this.manifestKeys = [ 'name', 'version', 'description', 'author', 'license' ]; -diff --git a/src/Powercord/managers/styles.js b/src/Powercord/managers/styles.js -index c5b184e4..118b5025 100644 ---- a/src/Powercord/managers/styles.js -+++ b/src/Powercord/managers/styles.js -@@ -14,10 +14,12 @@ const ErrorTypes = Object.freeze({ - INVALID_MANIFEST: 'INVALID_MANIFEST' - }); - -+const XDG_DATA_HOME = process.env.XDG_DATA_HOME || join(process.env.HOME, '.local', 'share'); -+ - module.exports = class StyleManager { - constructor () { - this._coreStyles = []; -- this.themesDir = join(__dirname, '..', '..', '..', 'themes'); -+ this.themesDir = join(XDG_DATA_HOME, 'replugged', 'themes'); - this.themes = new Map(); - - if (!window.__SPLASH__) { -diff --git a/src/browserWindow.js b/src/browserWindow.js -index 82620e56..cafc41a0 100644 ---- a/src/browserWindow.js -+++ b/src/browserWindow.js -@@ -28,7 +28,6 @@ class PatchedBrowserWindow extends BrowserWindow { - if (opts.webPreferences.nativeWindowOpen) { - // Discord Client - opts.webPreferences.preload = join(__dirname, './preload.js'); -- opts.webPreferences.contextIsolation = false; // shrug - } else { - // Splash Screen on macOS (Host 0.0.262+) & Windows (Host 0.0.293 / 1.0.17+) - opts.webPreferences.preload = join(__dirname, './preloadSplash.js'); -diff --git a/src/fake_node_modules/powercord/constants.js b/src/fake_node_modules/powercord/constants.js -index 147e02e9..948f2b02 100644 ---- a/src/fake_node_modules/powercord/constants.js -+++ b/src/fake_node_modules/powercord/constants.js -@@ -1,5 +1,9 @@ - const { join } = require('path'); - -+const XDG_CONFIG_HOME = process.env.XDG_CONFIG_HOME || join(process.env.HOME, '.config'); -+const XDG_CACHE_HOME = process.env.XDG_CACHE_HOME || join(process.env.HOME, '.cache'); -+const XDG_DATA_HOME = process.env.XDG_DATA_HOME || join(process.env.HOME, '.local', 'share'); -+ - module.exports = Object.freeze({ - // Replugged - WEBSITE: 'https://replugged.dev', -@@ -7,9 +11,9 @@ module.exports = Object.freeze({ - REPO_URL: 'replugged-org/replugged', - - // Runtime -- SETTINGS_FOLDER: join(__dirname, '..', '..', '..', 'settings'), -- CACHE_FOLDER: join(__dirname, '..', '..', '..', '.cache'), -- LOGS_FOLDER: join(__dirname, '..', '..', '..', '.logs'), -+ SETTINGS_FOLDER: join(XDG_CONFIG_HOME, 'replugged'), -+ CACHE_FOLDER: join(XDG_CACHE_HOME, 'replugged'), -+ LOGS_FOLDER: join(XDG_DATA_HOME, 'replugged', 'logs'), - - // Discord Server - DISCORD_INVITE: 'B2TcnXV9Rg', -diff --git a/src/patcher.js b/src/patcher.js -index 372e41f5..eaace1cf 100644 ---- a/src/patcher.js -+++ b/src/patcher.js -@@ -7,7 +7,7 @@ const { existsSync, unlinkSync } = require('fs'); - - // Restore the classic path; The updater relies on it and it makes Discord go corrupt - const electronPath = require.resolve('electron'); --const discordPath = join(dirname(require.main.filename), '..', 'app.asar'); -+const discordPath = join('/', 'usr', 'lib', 'discord-canary', 'app.asar'); - require.main.filename = join(discordPath, 'app_bootstrap/index.js'); - - const electron = require('electron'); -@@ -30,7 +30,6 @@ function setAppUserModelId (...args) { - appSetAppUserModelId.apply(this, args); - if (!_patched) { - _patched = true; -- require('./updater.win32'); - } - } - +diff --git a/src/main/index.ts b/src/main/index.ts +index f8f225ec..6a18ed4c 100644 +--- a/src/main/index.ts ++++ b/src/main/index.ts +@@ -5,7 +5,7 @@ import type { RepluggedWebContents } from "../types"; + import { CONFIG_PATHS } from "src/util"; + + const electronPath = require.resolve("electron"); +-const discordPath = join(dirname(require.main!.filename), "..", "app.orig.asar"); ++const discordPath = join("/", "usr", "lib", "@DISCORD@", "app.asar"); + // require.main!.filename = discordMain; + + Object.defineProperty(global, "appSettings", { |