refactor shared utils to more obviously separate contexts

This commit is contained in:
Vendicated 2024-03-13 21:59:09 +01:00
parent 9aa205b5ec
commit afdcf0edb9
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18
21 changed files with 32 additions and 33 deletions

View file

@ -6,7 +6,7 @@
import { PluginIpcMappings } from "@main/ipcPlugins"; import { PluginIpcMappings } from "@main/ipcPlugins";
import type { UserThemeHeader } from "@main/themes"; import type { UserThemeHeader } from "@main/themes";
import { IpcEvents } from "@utils/IpcEvents"; import { IpcEvents } from "@shared/IpcEvents";
import { IpcRes } from "@utils/types"; import { IpcRes } from "@utils/types";
import type { Settings } from "api/Settings"; import type { Settings } from "api/Settings";
import { ipcRenderer } from "electron"; import { ipcRenderer } from "electron";

View file

@ -16,8 +16,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { debounce } from "@shared/debounce";
import { SettingsStore as SettingsStoreClass } from "@shared/SettingsStore"; import { SettingsStore as SettingsStoreClass } from "@shared/SettingsStore";
import { debounce } from "@utils/debounce";
import { localStorage } from "@utils/localStorage"; import { localStorage } from "@utils/localStorage";
import { Logger } from "@utils/Logger"; import { Logger } from "@utils/Logger";
import { mergeDefaults } from "@utils/misc"; import { mergeDefaults } from "@utils/misc";

View file

@ -18,7 +18,7 @@
import { CheckedTextInput } from "@components/CheckedTextInput"; import { CheckedTextInput } from "@components/CheckedTextInput";
import { CodeBlock } from "@components/CodeBlock"; import { CodeBlock } from "@components/CodeBlock";
import { debounce } from "@utils/debounce"; import { debounce } from "@shared/debounce";
import { Margins } from "@utils/margins"; import { Margins } from "@utils/margins";
import { canonicalizeMatch, canonicalizeReplace } from "@utils/patches"; import { canonicalizeMatch, canonicalizeReplace } from "@utils/patches";
import { makeCodeblock } from "@utils/text"; import { makeCodeblock } from "@utils/text";

View file

@ -20,8 +20,8 @@ import "./updater";
import "./ipcPlugins"; import "./ipcPlugins";
import "./settings"; import "./settings";
import { debounce } from "@utils/debounce"; import { debounce } from "@shared/debounce";
import { IpcEvents } from "@utils/IpcEvents"; import { IpcEvents } from "@shared/IpcEvents";
import { BrowserWindow, ipcMain, shell, systemPreferences } from "electron"; import { BrowserWindow, ipcMain, shell, systemPreferences } from "electron";
import { FSWatcher, mkdirSync, watch, writeFileSync } from "fs"; import { FSWatcher, mkdirSync, watch, writeFileSync } from "fs";
import { open, readdir, readFile } from "fs/promises"; import { open, readdir, readFile } from "fs/promises";

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { IpcEvents } from "@utils/IpcEvents"; import { IpcEvents } from "@shared/IpcEvents";
import { ipcMain } from "electron"; import { ipcMain } from "electron";
import PluginNatives from "~pluginNatives"; import PluginNatives from "~pluginNatives";

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { onceDefined } from "@utils/onceDefined"; import { onceDefined } from "@shared/onceDefined";
import electron, { app, BrowserWindowConstructorOptions, Menu } from "electron"; import electron, { app, BrowserWindowConstructorOptions, Menu } from "electron";
import { dirname, join } from "path"; import { dirname, join } from "path";

View file

@ -5,8 +5,8 @@
*/ */
import type { Settings } from "@api/Settings"; import type { Settings } from "@api/Settings";
import { IpcEvents } from "@shared/IpcEvents";
import { SettingsStore } from "@shared/SettingsStore"; import { SettingsStore } from "@shared/SettingsStore";
import { IpcEvents } from "@utils/IpcEvents";
import { ipcMain } from "electron"; import { ipcMain } from "electron";
import { mkdirSync, readFileSync, writeFileSync } from "fs"; import { mkdirSync, readFileSync, writeFileSync } from "fs";

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { IpcEvents } from "@utils/IpcEvents"; import { IpcEvents } from "@shared/IpcEvents";
import { execFile as cpExecFile } from "child_process"; import { execFile as cpExecFile } from "child_process";
import { ipcMain } from "electron"; import { ipcMain } from "electron";
import { join } from "path"; import { join } from "path";

View file

@ -16,8 +16,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { VENCORD_USER_AGENT } from "@utils/constants"; import { IpcEvents } from "@shared/IpcEvents";
import { IpcEvents } from "@utils/IpcEvents"; import { VENCORD_USER_AGENT } from "@shared/vencordUserAgent";
import { ipcMain } from "electron"; import { ipcMain } from "electron";
import { writeFile } from "fs/promises"; import { writeFile } from "fs/promises";
import { join } from "path"; import { join } from "path";

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
*/ */
import { debounce } from "@utils/debounce"; import { debounce } from "@shared/debounce";
import { proxyLazy } from "@utils/lazy"; import { proxyLazy } from "@utils/lazy";
import { useEffect, useState, zustandCreate } from "@webpack/common"; import { useEffect, useState, zustandCreate } from "@webpack/common";
import { User } from "discord-types/general"; import { User } from "discord-types/general";

View file

@ -20,8 +20,8 @@ import { NavContextMenuPatchCallback } from "@api/ContextMenu";
import { definePluginSettings } from "@api/Settings"; import { definePluginSettings } from "@api/Settings";
import { disableStyle, enableStyle } from "@api/Styles"; import { disableStyle, enableStyle } from "@api/Styles";
import { makeRange } from "@components/PluginSettings/components"; import { makeRange } from "@components/PluginSettings/components";
import { debounce } from "@shared/debounce";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import { debounce } from "@utils/debounce";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { Menu, React, ReactDOM } from "@webpack/common"; import { Menu, React, ReactDOM } from "@webpack/common";
import type { Root } from "react-dom/client"; import type { Root } from "react-dom/client";

View file

@ -26,7 +26,7 @@ import { getPinAt, isPinned, settings, snapshotArray, sortedSnapshot, usePinnedD
export default definePlugin({ export default definePlugin({
name: "PinDMs", name: "PinDMs",
description: "Allows you to pin private channels to the top of your DM list. To pin/unpin or reorder pins, right click DMs", description: "Allows you to pin private channels to the top of your DM list. To pin/unpin or reorder pins, right click DMs",
authors: [Devs.Ven, Devs.Strencher], authors: [Devs.Ven],
settings, settings,
contextMenus, contextMenus,

View file

@ -17,8 +17,8 @@
*/ */
import { Settings } from "@api/Settings"; import { Settings } from "@api/Settings";
import { VENCORD_USER_AGENT } from "@utils/constants"; import { debounce } from "@shared/debounce";
import { debounce } from "@utils/debounce"; import { VENCORD_USER_AGENT } from "@shared/vencordUserAgent";
import { getCurrentChannel } from "@utils/discord"; import { getCurrentChannel } from "@utils/discord";
import { useAwaiter } from "@utils/react"; import { useAwaiter } from "@utils/react";
import { UserProfileStore, UserStore } from "@webpack/common"; import { UserProfileStore, UserStore } from "@webpack/common";

View file

@ -21,7 +21,7 @@ import "./spotifyStyles.css";
import ErrorBoundary from "@components/ErrorBoundary"; import ErrorBoundary from "@components/ErrorBoundary";
import { Flex } from "@components/Flex"; import { Flex } from "@components/Flex";
import { ImageIcon, LinkIcon, OpenExternalIcon } from "@components/Icons"; import { ImageIcon, LinkIcon, OpenExternalIcon } from "@components/Icons";
import { debounce } from "@utils/debounce"; import { debounce } from "@shared/debounce";
import { openImageModal } from "@utils/discord"; import { openImageModal } from "@utils/discord";
import { classes, copyWithToast } from "@utils/misc"; import { classes, copyWithToast } from "@utils/misc";
import { ContextMenuApi, FluxDispatcher, Forms, Menu, React, useEffect, useState, useStateFromStores } from "@webpack/common"; import { ContextMenuApi, FluxDispatcher, Forms, Menu, React, useEffect, useState, useStateFromStores } from "@webpack/common";

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { debounce } from "@utils/debounce"; import { debounce } from "@shared/debounce";
import { contextBridge, webFrame } from "electron"; import { contextBridge, webFrame } from "electron";
import { readFileSync, watch } from "fs"; import { readFileSync, watch } from "fs";
import { join } from "path"; import { join } from "path";

View file

@ -0,0 +1,12 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import gitHash from "~git-hash";
import gitRemote from "~git-remote";
export { gitHash, gitRemote };
export const VENCORD_USER_AGENT = `Vencord/${gitHash}${gitRemote ? ` (https://github.com/${gitRemote})` : ""}`;

View file

@ -16,17 +16,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import gitHash from "~git-hash";
import gitRemote from "~git-remote";
export {
gitHash,
gitRemote
};
export const WEBPACK_CHUNK = "webpackChunkdiscord_app"; export const WEBPACK_CHUNK = "webpackChunkdiscord_app";
export const REACT_GLOBAL = "Vencord.Webpack.Common.React"; export const REACT_GLOBAL = "Vencord.Webpack.Common.React";
export const VENCORD_USER_AGENT = `Vencord/${gitHash}${gitRemote ? ` (https://github.com/${gitRemote})` : ""}`;
export const SUPPORT_CHANNEL_ID = "1026515880080842772"; export const SUPPORT_CHANNEL_ID = "1026515880080842772";
export interface Dev { export interface Dev {
@ -291,10 +282,6 @@ export const Devs = /* #__PURE__*/ Object.freeze({
name: "RyanCaoDev", name: "RyanCaoDev",
id: 952235800110694471n, id: 952235800110694471n,
}, },
Strencher: {
name: "Strencher",
id: 415849376598982656n
},
FieryFlames: { FieryFlames: {
name: "Fiery", name: "Fiery",
id: 890228870559698955n id: 890228870559698955n

View file

@ -16,9 +16,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
export * from "../shared/debounce";
export * from "../shared/onceDefined";
export * from "./ChangeList"; export * from "./ChangeList";
export * from "./constants"; export * from "./constants";
export * from "./debounce";
export * from "./discord"; export * from "./discord";
export * from "./guards"; export * from "./guards";
export * from "./lazy"; export * from "./lazy";
@ -27,7 +28,6 @@ export * from "./Logger";
export * from "./margins"; export * from "./margins";
export * from "./misc"; export * from "./misc";
export * from "./modal"; export * from "./modal";
export * from "./onceDefined";
export * from "./onlyOnce"; export * from "./onlyOnce";
export * from "./patches"; export * from "./patches";
export * from "./Queue"; export * from "./Queue";