mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-20 11:57:02 -04:00
Path aliases, better lazyWebpack (#268)
This commit is contained in:
parent
7a4402f142
commit
bad96b7887
138 changed files with 572 additions and 547 deletions
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
/**
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue