From 8040d3be072f20b31a7990442756dd0eaa6a6d8f Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Wed, 29 Jul 2026 23:42:44 +0700 Subject: [PATCH] fix(lib/externals/react-native-safe-area-context): update filters for 341202+ --- .../src/react-native-safe-area-context.ts | 47 ++++++++++++------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/lib/externals/src/react-native-safe-area-context.ts b/lib/externals/src/react-native-safe-area-context.ts index 3758d50..1b4feb1 100644 --- a/lib/externals/src/react-native-safe-area-context.ts +++ b/lib/externals/src/react-native-safe-area-context.ts @@ -9,32 +9,43 @@ import { ReactNativeModuleId, } from '@revenge-mod/react' import { proxify } from '@revenge-mod/utils/proxy' +import type { ComparableDependencyMap } from '@revenge-mod/modules/finders/filters' const { relative, loose } = withDependencies +const withSafeAreaContextModule = ( + /* first dependency's dependencies */ + firstDependencyDependencies: ComparableDependencyMap, +) => + withDependencies( + // first dependency is next to this module, but we also need to check its dependencies + // hence relative.withDependencies(firstDependencyDependencies, 1), + loose([relative.withDependencies(firstDependencyDependencies, 1)]), + ) + export let ReactNativeSafeAreaContext: typeof import('react-native-safe-area-context') = proxify( () => { + // TODO: Slice 1 and use once stable >341202, first dependency is dropped in modern + const oldDeps = [ + null, + null, + ReactModuleId, + ReactNativeModuleId, + ReactJSXRuntimeModuleId, + relative.withDependencies([relative(1)], 1), + ] + const [module] = lookupModule( - withProps( - 'SafeAreaProvider', - ).and( - withDependencies( - loose([ - relative.withDependencies( - [ - null, - null, - ReactModuleId, - ReactNativeModuleId, - ReactJSXRuntimeModuleId, - relative.withDependencies([relative(1)], 1), - ], - 1, - ), - ]), + withProps('SafeAreaProvider') + .and( + withSafeAreaContextModule(oldDeps.slice(1)).or( + withSafeAreaContextModule(oldDeps), + ), + ) + .keyAs( + 'revenge.externals.ReactNativeSafeAreaContext.ReactNativeSafeAreaContext', ), - ), ) if (module) {