diff --git a/src/def.d.ts b/src/def.d.ts index 35a34c9..cd2d1dc 100644 --- a/src/def.d.ts +++ b/src/def.d.ts @@ -346,6 +346,8 @@ interface VendettaObject { findByNameAll: (name: string, defaultExp?: boolean) => any[]; findByDisplayName: (displayName: string, defaultExp?: boolean) => any; findByDisplayNameAll: (displayName: string, defaultExp?: boolean) => any[]; + findByTypeName: (typeName: string, defaultExp?: boolean) => any; + findByTypeNameAll: (typeName: string, defaultExp?: boolean) => any[]; findByStoreName: (name: string) => any; common: { constants: PropIntellisense<"API_HOST">; diff --git a/src/lib/metro/filters.ts b/src/lib/metro/filters.ts index a1bc1d1..59df4d1 100644 --- a/src/lib/metro/filters.ts +++ b/src/lib/metro/filters.ts @@ -66,6 +66,7 @@ export const findAll = filterModules(modules); const propsFilter = (props: (string | symbol)[]) => (m: any) => props.every((p) => m[p] !== undefined); const nameFilter = (name: string, defaultExp: boolean) => (defaultExp ? (m: any) => m?.name === name : (m: any) => m?.default?.name === name); const dNameFilter = (displayName: string, defaultExp: boolean) => (defaultExp ? (m: any) => m?.displayName === displayName : (m: any) => m?.default?.displayName === displayName); +const tNameFilter = (typeName: string, defaultExp: boolean) => (defaultExp ? (m: any) => m?.type?.name === typeName : (m: any) => m?.default?.type?.name === typeName); const storeFilter = (name: string) => (m: any) => m.getName && m.getName.length === 0 && m.getName() === name; export const findByProps: PropsFinder = (...props) => find(propsFilter(props)); @@ -74,4 +75,6 @@ export const findByName = (name: string, defaultExp = true) => find(nameFilter(n export const findByNameAll = (name: string, defaultExp = true) => findAll(nameFilter(name, defaultExp)); export const findByDisplayName = (displayName: string, defaultExp = true) => find(dNameFilter(displayName, defaultExp)); export const findByDisplayNameAll = (displayName: string, defaultExp = true) => findAll(dNameFilter(displayName, defaultExp)); +export const findByTypeName = (typeName: string, defaultExp = true) => find(tNameFilter(typeName, defaultExp)); +export const findByTypeNameAll = (typeName: string, defaultExp = true) => findAll(tNameFilter(typeName, defaultExp)); export const findByStoreName = (name: string) => find(storeFilter(name)); \ No newline at end of file