Skip to content

Commit 25e9e58

Browse files
authored
Merge branch 'main' into transparent
2 parents e0b73fe + 5abeee1 commit 25e9e58

File tree

7 files changed

+107
-78
lines changed

7 files changed

+107
-78
lines changed

i18n/en-US.messages.d.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export declare const messages: {
6969
*
7070
* ### Problems
7171
*
72-
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `en-GB`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `it`, `ja`, `ko`, `lt`, `nl`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
72+
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `ja`, `ko`, `lt`, `nl`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
7373
*/
7474
'REPLUGGED_ADDON_AUTHORS': TypedIntlMessageGetter<{author1: any, author2: any, author3: any, count: any | number, others: any | number | string}>,
7575
/**
@@ -238,7 +238,7 @@ export declare const messages: {
238238
*
239239
* ### Problems
240240
*
241-
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `en-GB`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `it`, `ja`, `ko`, `lt`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
241+
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `it`, `ja`, `ko`, `lt`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
242242
*/
243243
'REPLUGGED_ADDON_SETTINGS_THEME_PRESET': TypedIntlMessageGetter<{}>,
244244
/**
@@ -1408,7 +1408,7 @@ export declare const messages: {
14081408
*
14091409
* ### Problems
14101410
*
1411-
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `en-GB`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `it`, `ja`, `ko`, `lt`, `nl`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
1411+
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `ja`, `ko`, `lt`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
14121412
*/
14131413
'REPLUGGED_SETTINGS_DEVELOPMENT_TOOLS': TypedIntlMessageGetter<{}>,
14141414
/**
@@ -1421,7 +1421,7 @@ export declare const messages: {
14211421
*
14221422
* ### Problems
14231423
*
1424-
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `en-GB`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `it`, `ja`, `ko`, `lt`, `nl`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
1424+
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `ja`, `ko`, `lt`, `nl`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
14251425
*/
14261426
'REPLUGGED_SETTINGS_DISABLE_MIN_SIZE': TypedIntlMessageGetter<{}>,
14271427
/**
@@ -1434,7 +1434,7 @@ export declare const messages: {
14341434
*
14351435
* ### Problems
14361436
*
1437-
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `en-GB`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `it`, `ja`, `ko`, `lt`, `nl`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
1437+
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `ja`, `ko`, `lt`, `nl`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
14381438
*/
14391439
'REPLUGGED_SETTINGS_DISABLE_MIN_SIZE_DESC': TypedIntlMessageGetter<{$b?: HookFunction}>,
14401440
/**
@@ -1486,7 +1486,7 @@ export declare const messages: {
14861486
*
14871487
* ### Problems
14881488
*
1489-
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `en-GB`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `it`, `ja`, `ko`, `lt`, `nl`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
1489+
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `ja`, `ko`, `lt`, `nl`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
14901490
*/
14911491
'REPLUGGED_SETTINGS_DISCORD_EXPERIMENTS_DESC': TypedIntlMessageGetter<{$b?: HookFunction}>,
14921492
/**
@@ -1629,7 +1629,7 @@ export declare const messages: {
16291629
*
16301630
* ### Problems
16311631
*
1632-
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `en-GB`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `it`, `ja`, `ko`, `lt`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
1632+
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `ja`, `ko`, `lt`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
16331633
*/
16341634
'REPLUGGED_SETTINGS_QUICKCSS_ENABLE': TypedIntlMessageGetter<{}>,
16351635
/**
@@ -1642,7 +1642,7 @@ export declare const messages: {
16421642
*
16431643
* ### Problems
16441644
*
1645-
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `en-GB`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `it`, `ja`, `ko`, `lt`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
1645+
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `ja`, `ko`, `lt`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
16461646
*/
16471647
'REPLUGGED_SETTINGS_QUICKCSS_ENABLE_DESC': TypedIntlMessageGetter<{}>,
16481648
/**
@@ -1720,7 +1720,7 @@ export declare const messages: {
17201720
*
17211721
* ### Problems
17221722
*
1723-
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `en-GB`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `it`, `ja`, `ko`, `lt`, `nl`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
1723+
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `it`, `ja`, `ko`, `lt`, `nl`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
17241724
*/
17251725
'REPLUGGED_SETTINGS_TRANSPARENCY_BG_MATERIAL': TypedIntlMessageGetter<{}>,
17261726
/**
@@ -1733,7 +1733,7 @@ export declare const messages: {
17331733
*
17341734
* ### Problems
17351735
*
1736-
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `en-GB`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `it`, `ja`, `ko`, `lt`, `nl`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
1736+
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `it`, `ja`, `ko`, `lt`, `nl`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
17371737
*/
17381738
'REPLUGGED_SETTINGS_TRANSPARENCY_VIBRANCY': TypedIntlMessageGetter<{}>,
17391739
/**
@@ -1798,7 +1798,7 @@ export declare const messages: {
17981798
*
17991799
* ### Problems
18001800
*
1801-
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `en-GB`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `it`, `ja`, `ko`, `lt`, `nl`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
1801+
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `ja`, `ko`, `lt`, `nl`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
18021802
*/
18031803
'REPLUGGED_SETTINGS_WINDOW': TypedIntlMessageGetter<{}>,
18041804
/**
@@ -1811,7 +1811,7 @@ export declare const messages: {
18111811
*
18121812
* ### Problems
18131813
*
1814-
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `en-GB`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `it`, `ja`, `ko`, `lt`, `nl`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
1814+
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `ja`, `ko`, `lt`, `nl`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
18151815
*/
18161816
'REPLUGGED_SETTINGS_WINDOW_DESC': TypedIntlMessageGetter<{}>,
18171817
/**
@@ -1824,7 +1824,7 @@ export declare const messages: {
18241824
*
18251825
* ### Problems
18261826
*
1827-
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `en-GB`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `it`, `ja`, `ko`, `lt`, `nl`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
1827+
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `ja`, `ko`, `lt`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
18281828
*/
18291829
'REPLUGGED_SETTINGS_WIN_UPDATER': TypedIntlMessageGetter<{}>,
18301830
/**
@@ -1837,7 +1837,7 @@ export declare const messages: {
18371837
*
18381838
* ### Problems
18391839
*
1840-
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `en-GB`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `it`, `ja`, `ko`, `lt`, `nl`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
1840+
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `ja`, `ko`, `lt`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
18411841
*/
18421842
'REPLUGGED_SETTINGS_WIN_UPDATER_DESC': TypedIntlMessageGetter<{}>,
18431843
/**
@@ -2162,7 +2162,7 @@ export declare const messages: {
21622162
*
21632163
* ### Problems
21642164
*
2165-
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `en-GB`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `it`, `ja`, `ko`, `lt`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
2165+
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `it`, `ja`, `ko`, `lt`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
21662166
*/
21672167
'REPLUGGED_TOAST_THEME_PRESET_CHANGED': TypedIntlMessageGetter<{name: any}>,
21682168
/**
@@ -2175,7 +2175,7 @@ export declare const messages: {
21752175
*
21762176
* ### Problems
21772177
*
2178-
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `en-GB`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `it`, `ja`, `ko`, `lt`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
2178+
* Missing translations: `bg`, `cs`, `da`, `de`, `el`, `es-419`, `es-ES`, `fi`, `fr`, `hi`, `hr`, `hu`, `it`, `ja`, `ko`, `lt`, `no`, `pl`, `pt-BR`, `ro`, `ru`, `sv-SE`, `th`, `tr`, `uk`, `vi`, `zh-CN`, `zh-TW`
21792179
*/
21802180
'REPLUGGED_TOAST_THEME_PRESET_FAILED': TypedIntlMessageGetter<{name: any}>,
21812181
/**

src/renderer/apis/commands.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import type {
2222
} from "../modules/common/messages";
2323
import { t } from "../modules/i18n";
2424
import { Logger } from "../modules/logger";
25-
import { filters, getByStoreName, getFunctionBySource, waitForModule } from "../modules/webpack";
25+
import { getByStoreName, waitForPrototype } from "../modules/webpack";
2626

2727
const logger = Logger.api("Commands");
2828

@@ -33,8 +33,8 @@ interface CommandsAndSection {
3333
commands: Map<string, AnyRepluggedCommand>;
3434
}
3535

36-
void waitForModule(filters.bySource("hasHadPremium(){")).then((mod) => {
37-
const UserRecord = getFunctionBySource<typeof User>(mod, "username");
36+
void waitForPrototype<typeof User>("isSystemUser", "isPhoneVerified").then((UserRecord) => {
37+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
3838
if (!UserRecord) {
3939
logger.error("Could not find UserRecord");
4040
return;

src/renderer/managers/updater.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { i18n } from "@common";
2+
import semver from "semver";
23
import type { RepluggedPlugin, RepluggedTheme } from "src/types";
34
import type { AnyAddonManifest, RepluggedEntity } from "src/types/addon";
45
import notices from "../apis/notices";
@@ -64,6 +65,17 @@ const updaterState = init<Record<string, UpdateSettings>>("dev.replugged.Updater
6465

6566
const completedUpdates = new Set<string>();
6667

68+
function isUpToDate(local: string, remote: string): boolean {
69+
if (local === remote) return true;
70+
71+
const localVersion = semver.clean(local) ?? semver.coerce(local)?.version ?? null;
72+
const remoteVersion = semver.clean(remote) ?? semver.coerce(remote)?.version ?? null;
73+
74+
if (!localVersion || !remoteVersion) return false;
75+
76+
return semver.gte(localVersion, remoteVersion);
77+
}
78+
6779
export function getUpdateState(id: string): UpdateSettings | null {
6880
const setting = updaterState.get(id);
6981
if (!setting) return null;
@@ -136,7 +148,7 @@ export async function checkUpdate(id: string, verbose = true): Promise<void> {
136148

137149
const newVersion = res.manifest.version;
138150

139-
if (newVersion === version) {
151+
if (isUpToDate(version, newVersion)) {
140152
if (verbose) logger.log(`Entity ${id} is up to date`);
141153
updaterState.set(id, {
142154
available: false,

src/renderer/modules/common/components.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ import { waitForProps } from "@webpack";
33
import type * as Design from "discord-client-types/discord_app/design/web";
44

55
export type DiscordComponents = {
6+
Anchor: Design.Anchor;
7+
Button: Design.Button;
8+
ButtonGroup: Design.ButtonGroup;
9+
Checkbox: Design.Checkbox;
10+
ConfirmModal: Design.ConfirmModal;
11+
H: Design.H;
12+
Heading: Design.Heading;
613
Text: Design.Text;
714
ToastPosition: typeof Design.ToastPosition;
815
ToastType: typeof Design.ToastType;
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
import { getFunctionBySource } from "@webpack";
21
import components from "../common/components";
32

4-
import type * as Design from "discord-client-types/discord_app/design/web";
5-
6-
export default getFunctionBySource<Design.Checkbox>(
7-
components,
8-
/return\(0,\i\.\i\)\("Checkbox"\)/,
9-
)!;
3+
export default components.Checkbox;

src/renderer/modules/webpack/helpers.ts

Lines changed: 65 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { GetModuleOptions, RawModule, WaitForOptions } from "src/types";
1+
import type { AbstractConstructor, GetModuleOptions, RawModule, WaitForOptions } from "src/types";
22
import { flux } from "../common";
33
import type { Store } from "../common/flux";
44
import * as filters from "./filters";
@@ -182,45 +182,52 @@ export async function waitForProps<T, P extends PropertyKey = keyof T>(
182182

183183
// Get by prototype
184184

185-
export function getByPrototype<T, P extends PropertyKey = keyof T>(
186-
props: P[],
187-
options?: { all?: false; raw?: false },
188-
): T | undefined;
189-
export function getByPrototype<T, P extends PropertyKey = keyof T>(
190-
props: P[],
191-
options: { all: true; raw?: false },
192-
): T[];
193-
export function getByPrototype<T, P extends PropertyKey = keyof T>(
194-
props: P[],
195-
options: { all?: false; raw: true },
196-
): RawModule<T> | undefined;
197-
export function getByPrototype<T, P extends PropertyKey = keyof T>(
198-
props: P[],
199-
options: { all: true; raw: true },
200-
): Array<RawModule<T>>;
201-
export function getByPrototype<T, P extends PropertyKey = keyof T>(
202-
props: P[],
203-
options?: { all: true; raw?: boolean },
204-
): T[] | Array<RawModule<T>>;
205-
export function getByPrototype<T, P extends PropertyKey = keyof T>(
206-
props: P[],
207-
options: { all?: false; raw?: boolean },
208-
): T | RawModule<T> | undefined;
209-
export function getByPrototype<T, P extends PropertyKey = keyof T>(
185+
export function getByPrototype<
186+
T extends AbstractConstructor,
187+
P extends PropertyKey = keyof InstanceType<T>,
188+
>(props: P[], options?: { all?: false; raw?: false }): T | undefined;
189+
export function getByPrototype<
190+
T extends AbstractConstructor,
191+
P extends PropertyKey = keyof InstanceType<T>,
192+
>(props: P[], options: { all: true; raw?: false }): T[];
193+
export function getByPrototype<
194+
T extends AbstractConstructor,
195+
P extends PropertyKey = keyof InstanceType<T>,
196+
>(props: P[], options: { all?: false; raw: true }): RawModule<T> | undefined;
197+
export function getByPrototype<
198+
T extends AbstractConstructor,
199+
P extends PropertyKey = keyof InstanceType<T>,
200+
>(props: P[], options: { all: true; raw: true }): Array<RawModule<T>>;
201+
export function getByPrototype<
202+
T extends AbstractConstructor,
203+
P extends PropertyKey = keyof InstanceType<T>,
204+
>(props: P[], options?: { all: true; raw?: boolean }): T[] | Array<RawModule<T>>;
205+
export function getByPrototype<
206+
T extends AbstractConstructor,
207+
P extends PropertyKey = keyof InstanceType<T>,
208+
>(props: P[], options: { all?: false; raw?: boolean }): T | RawModule<T> | undefined;
209+
export function getByPrototype<
210+
T extends AbstractConstructor,
211+
P extends PropertyKey = keyof InstanceType<T>,
212+
>(
210213
props: P[],
211214
options: { all?: boolean; raw: true },
212215
): RawModule<T> | Array<RawModule<T>> | undefined;
213-
export function getByPrototype<T, P extends PropertyKey = keyof T>(
214-
props: P[],
215-
options: { all?: boolean; raw?: false },
216-
): T | T[] | undefined;
217-
export function getByPrototype<T, P extends PropertyKey = keyof T>(
216+
export function getByPrototype<
217+
T extends AbstractConstructor,
218+
P extends PropertyKey = keyof InstanceType<T>,
219+
>(props: P[], options: { all?: boolean; raw?: false }): T | T[] | undefined;
220+
export function getByPrototype<
221+
T extends AbstractConstructor,
222+
P extends PropertyKey = keyof InstanceType<T>,
223+
>(
218224
props: P[],
219225
options?: { all?: boolean; raw?: boolean },
220226
): T | T[] | RawModule<T> | Array<RawModule<T>> | undefined;
221-
export function getByPrototype<T, P extends PropertyKey[] = Array<keyof T>>(
222-
...props: P
223-
): T | undefined;
227+
export function getByPrototype<
228+
T extends AbstractConstructor,
229+
P extends PropertyKey[] = Array<keyof InstanceType<T>>,
230+
>(...props: P): T | undefined;
224231

225232
/**
226233
* Retrieves a module(s) by matching properties on their prototype.
@@ -234,7 +241,10 @@ export function getByPrototype<T, P extends PropertyKey[] = Array<keyof T>>(
234241
* @see {@link filters.byPrototype}
235242
* @see {@link getModule}
236243
*/
237-
export function getByPrototype<T, P extends PropertyKey = keyof T>(
244+
export function getByPrototype<
245+
T extends AbstractConstructor,
246+
P extends PropertyKey = keyof InstanceType<T>,
247+
>(
238248
...args: [P[], GetModuleOptions] | P[]
239249
): T | T[] | RawModule<T> | Array<RawModule<T>> | undefined {
240250
const props = (typeof args[0] === "string" ? args : args[0]) as P[];
@@ -259,19 +269,22 @@ export function getByPrototype<T, P extends PropertyKey = keyof T>(
259269

260270
// Wait for prototype
261271

262-
export function waitForPrototype<T, P extends PropertyKey = keyof T>(
263-
props: P[],
264-
options: WaitForOptions & { raw?: false },
265-
): Promise<T>;
266-
export function waitForPrototype<T, P extends PropertyKey = keyof T>(
267-
props: P[],
268-
options: WaitForOptions & { raw: true },
269-
): Promise<RawModule<T>>;
270-
export function waitForPrototype<T, P extends PropertyKey = keyof T>(
271-
props: P[],
272-
options?: WaitForOptions,
273-
): Promise<T | RawModule<T>>;
274-
export function waitForPrototype<T, P extends PropertyKey = keyof T>(...props: P[]): Promise<T>;
272+
export function waitForPrototype<
273+
T extends AbstractConstructor,
274+
P extends PropertyKey = keyof InstanceType<T>,
275+
>(props: P[], options: WaitForOptions & { raw?: false }): Promise<T>;
276+
export function waitForPrototype<
277+
T extends AbstractConstructor,
278+
P extends PropertyKey = keyof InstanceType<T>,
279+
>(props: P[], options: WaitForOptions & { raw: true }): Promise<RawModule<T>>;
280+
export function waitForPrototype<
281+
T extends AbstractConstructor,
282+
P extends PropertyKey = keyof InstanceType<T>,
283+
>(props: P[], options?: WaitForOptions): Promise<T | RawModule<T>>;
284+
export function waitForPrototype<
285+
T extends AbstractConstructor,
286+
P extends PropertyKey = keyof InstanceType<T>,
287+
>(...props: P[]): Promise<T>;
275288

276289
/**
277290
* Waits for a module that contains the specified prototype properties and returns it.
@@ -285,9 +298,10 @@ export function waitForPrototype<T, P extends PropertyKey = keyof T>(...props: P
285298
* @see {@link getByPrototype}
286299
* @see {@link waitForModule}
287300
*/
288-
export async function waitForPrototype<T, P extends PropertyKey = keyof T>(
289-
...args: [P[], WaitForOptions] | P[]
290-
): Promise<T | RawModule<T>> {
301+
export async function waitForPrototype<
302+
T extends AbstractConstructor,
303+
P extends PropertyKey = keyof InstanceType<T>,
304+
>(...args: [P[], WaitForOptions] | P[]): Promise<T | RawModule<T>> {
291305
const props = (typeof args[0] === "string" ? args : args[0]) as P[];
292306
const raw = typeof args[0] === "string" ? false : (args[1] as WaitForOptions | undefined)?.raw;
293307

src/types/webpack.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,5 @@ export interface WaitForOptions {
8181
/** If nothing is found after this delay (ms), stop and throw an error. */
8282
timeout?: number;
8383
}
84+
85+
export type AbstractConstructor<T = unknown> = abstract new (args: unknown[]) => T;

0 commit comments

Comments
 (0)