diff options
author | Ven <vendicated@riseup.net> | 2022-11-28 13:37:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-28 13:37:55 +0100 |
commit | bad96b78879f296d5b9e7adacb03756b0f58427a (patch) | |
tree | 4ddbc57a29e9b201bee1317f18110e8e1ad320e5 /src/utils | |
parent | 7a4402f1425ea9fdc6d2b3c985a4ce831f405937 (diff) | |
download | Vencord-bad96b78879f296d5b9e7adacb03756b0f58427a.tar.gz Vencord-bad96b78879f296d5b9e7adacb03756b0f58427a.tar.bz2 Vencord-bad96b78879f296d5b9e7adacb03756b0f58427a.zip |
Path aliases, better lazyWebpack (#268)
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/discord.ts | 3 | ||||
-rw-r--r-- | src/utils/misc.tsx | 14 | ||||
-rw-r--r-- | src/utils/modal.tsx | 3 | ||||
-rw-r--r-- | src/utils/proxyLazy.ts | 2 | ||||
-rw-r--r-- | src/utils/quickCss.ts | 3 | ||||
-rw-r--r-- | src/utils/settingsSync.ts | 3 | ||||
-rw-r--r-- | src/utils/types.ts | 3 |
7 files changed, 9 insertions, 22 deletions
diff --git a/src/utils/discord.ts b/src/utils/discord.ts index 7fc5064..f1a1f8a 100644 --- a/src/utils/discord.ts +++ b/src/utils/discord.ts @@ -16,10 +16,9 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ +import { ChannelStore, GuildStore, PrivateChannelsStore, SelectedChannelStore } from "@webpack/common"; import { Guild } from "discord-types/general"; -import { ChannelStore, GuildStore, PrivateChannelsStore, SelectedChannelStore } from "../webpack/common"; - export function getCurrentChannel() { return ChannelStore.getChannel(SelectedChannelStore.getChannelId()); } diff --git a/src/utils/misc.tsx b/src/utils/misc.tsx index 7389cc2..4ae3fd5 100644 --- a/src/utils/misc.tsx +++ b/src/utils/misc.tsx @@ -16,9 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import { FilterFn, find } from "../webpack"; -import { React } from "../webpack/common"; -import { proxyLazy } from "./proxyLazy"; +import { React } from "@webpack/common"; /** * Makes a lazy function. On first call, the value is computed. @@ -29,16 +27,6 @@ export function makeLazy<T>(factory: () => T): () => T { let cache: T; return () => cache ?? (cache = factory()); } -export const lazy = makeLazy; - -/** - * Do a lazy webpack search. Searches the module on first property access - * @param filter Filter function - * @returns A proxy to the webpack module. Not all traps are implemented, may produce unexpected results. - */ -export function lazyWebpack<T = any>(filter: FilterFn): T { - return proxyLazy(() => find(filter)); -} type AwaiterRes<T> = [T, any, boolean, () => void]; /** diff --git a/src/utils/modal.tsx b/src/utils/modal.tsx index 886e325..9a90460 100644 --- a/src/utils/modal.tsx +++ b/src/utils/modal.tsx @@ -16,8 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import { filters } from "../webpack"; -import { mapMangledModuleLazy } from "../webpack/webpack"; +import { filters, mapMangledModuleLazy } from "@webpack"; export enum ModalSize { SMALL = "small", diff --git a/src/utils/proxyLazy.ts b/src/utils/proxyLazy.ts index 364dd56..42b5a91 100644 --- a/src/utils/proxyLazy.ts +++ b/src/utils/proxyLazy.ts @@ -63,7 +63,7 @@ handler.getOwnPropertyDescriptor = (target, p) => { * @param factory lazy factory * @returns Proxy * - * Note that the example below exists already as an api, see {@link lazyWebpack} + * Note that the example below exists already as an api, see {@link findByPropsLazy} * @example const mod = proxyLazy(() => findByProps("blah")); console.log(mod.blah); */ export function proxyLazy<T>(factory: () => T): T { diff --git a/src/utils/quickCss.ts b/src/utils/quickCss.ts index 0ce1f58..1f9f235 100644 --- a/src/utils/quickCss.ts +++ b/src/utils/quickCss.ts @@ -16,7 +16,8 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import { addSettingsListener, Settings } from "../api/settings"; +import { addSettingsListener, Settings } from "@api/settings"; + import IpcEvents from "./IpcEvents"; let style: HTMLStyleElement; diff --git a/src/utils/settingsSync.ts b/src/utils/settingsSync.ts index ecf6665..5cd81e7 100644 --- a/src/utils/settingsSync.ts +++ b/src/utils/settingsSync.ts @@ -16,7 +16,8 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import { Toasts } from "../webpack/common"; +import { Toasts } from "@webpack/common"; + import IpcEvents from "./IpcEvents"; import Logger from "./Logger"; diff --git a/src/utils/types.ts b/src/utils/types.ts index 30c603f..310fbea 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -16,10 +16,9 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ +import { Command } from "@api/Commands"; import { Promisable } from "type-fest"; -import { Command } from "../api/Commands"; - // exists to export default definePlugin({...}) export default function definePlugin<P extends PluginDef>(p: P & Record<string, any>) { return p; |