mirror of
https://github.com/Equicord/Equicord.git
synced 2025-03-14 14:10:26 -04:00
Merge Dev
This commit is contained in:
commit
4c5dc32a0b
7 changed files with 70 additions and 30 deletions
|
@ -23,7 +23,7 @@ import { existsSync, readdirSync } from "fs";
|
||||||
import { readdir, rm, writeFile } from "fs/promises";
|
import { readdir, rm, writeFile } from "fs/promises";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
|
|
||||||
import { addBuild, BUILD_TIMESTAMP, buildOrWatchAll, commonOpts, exists, globPlugins, IS_DEV, IS_REPORTER, IS_STANDALONE, IS_UPDATER_DISABLED, resolvePluginName, VERSION, watch } from "./common.mjs";
|
import { addBuild, BUILD_TIMESTAMP, buildOrWatchAll, commonOpts, commonRendererPlugins, exists, globPlugins, IS_DEV, IS_REPORTER, IS_STANDALONE, IS_UPDATER_DISABLED, resolvePluginName, VERSION, watch } from "./common.mjs";
|
||||||
|
|
||||||
const defines = {
|
const defines = {
|
||||||
IS_STANDALONE: String(IS_STANDALONE),
|
IS_STANDALONE: String(IS_STANDALONE),
|
||||||
|
@ -128,7 +128,7 @@ await Promise.all([
|
||||||
sourcemap,
|
sourcemap,
|
||||||
plugins: [
|
plugins: [
|
||||||
globPlugins("discordDesktop"),
|
globPlugins("discordDesktop"),
|
||||||
...commonOpts.plugins
|
...commonRendererPlugins
|
||||||
],
|
],
|
||||||
define: {
|
define: {
|
||||||
...defines,
|
...defines,
|
||||||
|
@ -180,7 +180,7 @@ await Promise.all([
|
||||||
sourcemap,
|
sourcemap,
|
||||||
plugins: [
|
plugins: [
|
||||||
globPlugins("vencordDesktop"),
|
globPlugins("vencordDesktop"),
|
||||||
...commonOpts.plugins
|
...commonRendererPlugins
|
||||||
],
|
],
|
||||||
define: {
|
define: {
|
||||||
...defines,
|
...defines,
|
||||||
|
@ -232,7 +232,7 @@ await Promise.all([
|
||||||
sourcemap,
|
sourcemap,
|
||||||
plugins: [
|
plugins: [
|
||||||
globPlugins("equicordDesktop"),
|
globPlugins("equicordDesktop"),
|
||||||
...commonOpts.plugins
|
...commonRendererPlugins
|
||||||
],
|
],
|
||||||
define: {
|
define: {
|
||||||
...defines,
|
...defines,
|
||||||
|
|
|
@ -23,7 +23,7 @@ import { appendFile, mkdir, readdir, readFile, rm, writeFile } from "fs/promises
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import Zip from "zip-local";
|
import Zip from "zip-local";
|
||||||
|
|
||||||
import { addBuild, BUILD_TIMESTAMP, buildOrWatchAll, commonOpts, globPlugins, IS_DEV, IS_REPORTER, VERSION } from "./common.mjs";
|
import { addBuild, BUILD_TIMESTAMP, buildOrWatchAll, commonOpts, commonRendererPlugins, globPlugins, IS_DEV, IS_REPORTER, VERSION } from "./common.mjs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {esbuild.BuildOptions}
|
* @type {esbuild.BuildOptions}
|
||||||
|
@ -36,7 +36,7 @@ const commonOptions: esbuild.BuildOptions = {
|
||||||
external: ["~plugins", "~git-hash", "/assets/*"],
|
external: ["~plugins", "~git-hash", "/assets/*"],
|
||||||
plugins: [
|
plugins: [
|
||||||
globPlugins("web"),
|
globPlugins("web"),
|
||||||
...commonOpts.plugins,
|
...commonRendererPlugins
|
||||||
],
|
],
|
||||||
target: ["esnext"],
|
target: ["esnext"],
|
||||||
define: {
|
define: {
|
||||||
|
|
|
@ -28,6 +28,7 @@ import { join, relative } from "path";
|
||||||
import { promisify } from "util";
|
import { promisify } from "util";
|
||||||
|
|
||||||
import { getPluginTarget } from "../utils.mjs";
|
import { getPluginTarget } from "../utils.mjs";
|
||||||
|
import { builtinModules } from "module";
|
||||||
|
|
||||||
const PackageJSON: typeof import("../../package.json") = JSON.parse(readFileSync("package.json", "utf-8"));
|
const PackageJSON: typeof import("../../package.json") = JSON.parse(readFileSync("package.json", "utf-8"));
|
||||||
|
|
||||||
|
@ -262,6 +263,15 @@ export const stylePlugin: Plugin = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const banImportPlugin = (filter: RegExp, message: string) => ({
|
||||||
|
name: "ban-imports",
|
||||||
|
setup: build => {
|
||||||
|
build.onResolve({ filter }, () => {
|
||||||
|
return { errors: [{ text: message }] };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
export const commonOpts = {
|
export const commonOpts = {
|
||||||
logLevel: "info",
|
logLevel: "info",
|
||||||
bundle: true,
|
bundle: true,
|
||||||
|
@ -302,3 +312,15 @@ export async function buildOrWatchAll() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const escapedBuiltinModules = builtinModules
|
||||||
|
.map(m => m.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"))
|
||||||
|
.join("|");
|
||||||
|
const builtinModuleRegex = new RegExp(`^(node:)?(${escapedBuiltinModules})$`);
|
||||||
|
|
||||||
|
export const commonRendererPlugins = [
|
||||||
|
banImportPlugin(builtinModuleRegex, "Cannot import node inbuilt modules in browser code. You need to use a native.ts file"),
|
||||||
|
banImportPlugin(/^react$/, "Cannot import from react. React and hooks should be imported from @webpack/common"),
|
||||||
|
banImportPlugin(/^electron(\/.*)?$/, "Cannot import electron in browser code. You need to use a native.ts file"),
|
||||||
|
...commonOpts.plugins
|
||||||
|
];
|
||||||
|
|
|
@ -21,7 +21,7 @@ import { Devs } from "@utils/constants";
|
||||||
import { isNonNullish } from "@utils/guards";
|
import { isNonNullish } from "@utils/guards";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByPropsLazy } from "@webpack";
|
||||||
import { Avatar, ChannelStore, Clickable, IconUtils, RelationshipStore, ScrollerThin, UserStore } from "@webpack/common";
|
import { Avatar, ChannelStore, Clickable, IconUtils, RelationshipStore, ScrollerThin, useMemo, UserStore } from "@webpack/common";
|
||||||
import { Channel, User } from "discord-types/general";
|
import { Channel, User } from "discord-types/general";
|
||||||
|
|
||||||
const SelectedChannelActionCreators = findByPropsLazy("selectPrivateChannel");
|
const SelectedChannelActionCreators = findByPropsLazy("selectPrivateChannel");
|
||||||
|
@ -39,6 +39,19 @@ function getGroupDMName(channel: Channel) {
|
||||||
.join(", ");
|
.join(", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getMutualGroupDms = (userId: string) =>
|
||||||
|
ChannelStore.getSortedPrivateChannels()
|
||||||
|
.filter(c => c.isGroupDM() && c.recipients.includes(userId));
|
||||||
|
|
||||||
|
const isBotOrSelf = (user: User) => user.bot || user.id === UserStore.getCurrentUser().id;
|
||||||
|
|
||||||
|
function getMutualGDMCountText(user: User) {
|
||||||
|
const count = getMutualGroupDms(user.id).length;
|
||||||
|
return `${count === 0 ? "No" : count} Mutual Group${count !== 1 ? "s" : ""}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const IS_PATCHED = Symbol("MutualGroupDMs.Patched");
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "MutualGroupDMs",
|
name: "MutualGroupDMs",
|
||||||
description: "Shows mutual group dms in profiles",
|
description: "Shows mutual group dms in profiles",
|
||||||
|
@ -63,8 +76,8 @@ export default definePlugin({
|
||||||
find: ".MUTUAL_FRIENDS?(",
|
find: ".MUTUAL_FRIENDS?(",
|
||||||
replacement: [
|
replacement: [
|
||||||
{
|
{
|
||||||
match: /(?<=onItemSelect:\i,children:)(\i)\.map/,
|
match: /\i\.useEffect.{0,100}(\i)\[0\]\.section/,
|
||||||
replace: "[...$1, ...($self.isBotOrSelf(arguments[0].user) ? [] : [{section:'MUTUAL_GDMS',text:$self.getMutualGDMCountText(arguments[0].user)}])].map"
|
replace: "$self.pushSection($1, arguments[0].user);$&"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
match: /\(0,\i\.jsx\)\(\i,\{items:\i,section:(\i)/,
|
match: /\(0,\i\.jsx\)\(\i,\{items:\i,section:(\i)/,
|
||||||
|
@ -74,15 +87,23 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
isBotOrSelf: (user: User) => user.bot || user.id === UserStore.getCurrentUser().id,
|
isBotOrSelf,
|
||||||
|
getMutualGDMCountText,
|
||||||
|
|
||||||
getMutualGDMCountText: (user: User) => {
|
pushSection(sections: any[], user: User) {
|
||||||
const count = ChannelStore.getSortedPrivateChannels().filter(c => c.isGroupDM() && c.recipients.includes(user.id)).length;
|
if (isBotOrSelf(user) || sections[IS_PATCHED]) return;
|
||||||
return `${count === 0 ? "No" : count} Mutual Group${count !== 1 ? "s" : ""}`;
|
|
||||||
|
sections[IS_PATCHED] = true;
|
||||||
|
sections.push({
|
||||||
|
section: "MUTUAL_GDMS",
|
||||||
|
text: getMutualGDMCountText(user)
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
renderMutualGDMs: ErrorBoundary.wrap(({ user, onClose }: { user: User, onClose: () => void; }) => {
|
renderMutualGDMs: ErrorBoundary.wrap(({ user, onClose }: { user: User, onClose: () => void; }) => {
|
||||||
const entries = ChannelStore.getSortedPrivateChannels().filter(c => c.isGroupDM() && c.recipients.includes(user.id)).map(c => (
|
const mutualDms = useMemo(() => getMutualGroupDms(user.id), [user.id]);
|
||||||
|
|
||||||
|
const entries = mutualDms.map(c => (
|
||||||
<Clickable
|
<Clickable
|
||||||
className={ProfileListClasses.listRow}
|
className={ProfileListClasses.listRow}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|
|
@ -55,6 +55,7 @@ interface PlayerState {
|
||||||
|
|
||||||
// added by patch
|
// added by patch
|
||||||
actual_repeat: Repeat;
|
actual_repeat: Repeat;
|
||||||
|
shuffle: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Device {
|
interface Device {
|
||||||
|
@ -182,6 +183,7 @@ export const SpotifyStore = proxyLazyWebpack(() => {
|
||||||
store.isPlaying = e.isPlaying ?? false;
|
store.isPlaying = e.isPlaying ?? false;
|
||||||
store.volume = e.volumePercent ?? 0;
|
store.volume = e.volumePercent ?? 0;
|
||||||
store.repeat = e.actual_repeat || "off";
|
store.repeat = e.actual_repeat || "off";
|
||||||
|
store.shuffle = e.shuffle ?? false;
|
||||||
store.position = e.position ?? 0;
|
store.position = e.position ?? 0;
|
||||||
store.isSettingPosition = false;
|
store.isSettingPosition = false;
|
||||||
store.emitChange();
|
store.emitChange();
|
||||||
|
|
|
@ -70,21 +70,20 @@ export default definePlugin({
|
||||||
replace: "false",
|
replace: "false",
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
// Discord doesn't give you the repeat kind, only a boolean
|
|
||||||
{
|
{
|
||||||
find: 'repeat:"off"!==',
|
find: 'repeat:"off"!==',
|
||||||
replacement: {
|
replacement: [
|
||||||
match: /repeat:"off"!==(.{1,3}),/,
|
{
|
||||||
replace: "actual_repeat:$1,$&"
|
// Discord doesn't give you shuffle state and the repeat kind, only a boolean
|
||||||
}
|
match: /repeat:"off"!==(\i),/,
|
||||||
|
replace: "shuffle:arguments[2]?.shuffle_state??false,actual_repeat:$1,$&"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
match: /(?<=artists.filter\(\i=>).{0,10}\i\.id\)&&/,
|
||||||
|
replace: ""
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
find: "artists.filter",
|
|
||||||
replacement: {
|
|
||||||
match: /(?<=artists.filter\(\i=>).{0,10}\i\.id\)&&/,
|
|
||||||
replace: ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
|
|
||||||
start: () => toggleHoverControls(Settings.plugins.SpotifyControls.hoverControls),
|
start: () => toggleHoverControls(Settings.plugins.SpotifyControls.hoverControls),
|
||||||
|
|
|
@ -35,10 +35,6 @@ export interface Dev {
|
||||||
* If you are fine with attribution but don't want the badge, add badge: false
|
* If you are fine with attribution but don't want the badge, add badge: false
|
||||||
*/
|
*/
|
||||||
export const Devs = /* #__PURE__*/ Object.freeze({
|
export const Devs = /* #__PURE__*/ Object.freeze({
|
||||||
Nobody: {
|
|
||||||
name: "Nobody",
|
|
||||||
id: 0n,
|
|
||||||
},
|
|
||||||
Ven: {
|
Ven: {
|
||||||
name: "Vee",
|
name: "Vee",
|
||||||
id: 343383572805058560n
|
id: 343383572805058560n
|
||||||
|
|
Loading…
Add table
Reference in a new issue