From 06a574c77e8c8e33b34d7cd7ed6dd02709e0a2fb Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Wed, 1 Apr 2026 13:32:19 +0700 Subject: [PATCH] feat(lib/externals): add `react-native-safe-area-context` --- bun.lock | 1 + lib/externals/package.json | 3 ++ .../src/react-native-safe-area-context.ts | 47 +++++++++++++++++++ lib/externals/src/types.ts | 1 + package.json | 1 + src/plugins/init/api.externals/index.ts | 4 ++ 6 files changed, 57 insertions(+) create mode 100644 lib/externals/src/react-native-safe-area-context.ts diff --git a/bun.lock b/bun.lock index 071732f..3e7a7a4 100644 --- a/bun.lock +++ b/bun.lock @@ -28,6 +28,7 @@ "@parcel/watcher": "^2.5.6", "@react-native-clipboard/clipboard": "^1.16.3", "@types/bun": "^1.3.9", + "react-native-safe-area-context": "^5.7.0", "rolldown-plugin-dts": "^0.22.1", }, "peerDependencies": { diff --git a/lib/externals/package.json b/lib/externals/package.json index dbe8914..a44e4bf 100644 --- a/lib/externals/package.json +++ b/lib/externals/package.json @@ -9,6 +9,9 @@ "./react-native-clipboard": { "default": "./src/react-native-clipboard.ts" }, + "./react-native-safe-area-context": { + "default": "./src/react-native-safe-area-context.ts" + }, "./react-navigation": { "default": "./src/react-navigation.ts" }, diff --git a/lib/externals/src/react-native-safe-area-context.ts b/lib/externals/src/react-native-safe-area-context.ts new file mode 100644 index 0000000..3758d50 --- /dev/null +++ b/lib/externals/src/react-native-safe-area-context.ts @@ -0,0 +1,47 @@ +import { lookupModule } from '@revenge-mod/modules/finders' +import { + withDependencies, + withProps, +} from '@revenge-mod/modules/finders/filters' +import { + ReactJSXRuntimeModuleId, + ReactModuleId, + ReactNativeModuleId, +} from '@revenge-mod/react' +import { proxify } from '@revenge-mod/utils/proxy' + +const { relative, loose } = withDependencies + +export let ReactNativeSafeAreaContext: typeof import('react-native-safe-area-context') = + proxify( + () => { + const [module] = lookupModule( + withProps( + 'SafeAreaProvider', + ).and( + withDependencies( + loose([ + relative.withDependencies( + [ + null, + null, + ReactModuleId, + ReactNativeModuleId, + ReactJSXRuntimeModuleId, + relative.withDependencies([relative(1)], 1), + ], + 1, + ), + ]), + ), + ), + ) + + if (module) { + return (ReactNativeSafeAreaContext = module) + } + }, + { + hint: {}, + }, + )! diff --git a/lib/externals/src/types.ts b/lib/externals/src/types.ts index c7f40ea..f5d95f2 100644 --- a/lib/externals/src/types.ts +++ b/lib/externals/src/types.ts @@ -1,6 +1,7 @@ export interface PluginApiExternals { Browserify: typeof import('@revenge-mod/externals/browserify') ReactNativeClipboard: typeof import('@revenge-mod/externals/react-native-clipboard') + ReactNativeSafeAreaContext: typeof import('@revenge-mod/externals/react-native-safe-area-context') ReactNavigation: typeof import('@revenge-mod/externals/react-navigation') Shopify: typeof import('@revenge-mod/externals/shopify') } diff --git a/package.json b/package.json index 1c14807..4a20f2a 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "@parcel/watcher": "^2.5.6", "@react-native-clipboard/clipboard": "^1.16.3", "@types/bun": "^1.3.9", + "react-native-safe-area-context": "^5.7.0", "rolldown-plugin-dts": "^0.22.1" }, "peerDependencies": { diff --git a/src/plugins/init/api.externals/index.ts b/src/plugins/init/api.externals/index.ts index c7bb08a..d10f470 100644 --- a/src/plugins/init/api.externals/index.ts +++ b/src/plugins/init/api.externals/index.ts @@ -1,5 +1,6 @@ import defer * as Browserify from '@revenge-mod/externals/browserify' import defer * as ReactNativeClipboard from '@revenge-mod/externals/react-native-clipboard' +import defer * as ReactNativeSafeAreaContext from '@revenge-mod/externals/react-native-safe-area-context' import defer * as ReactNavigation from '@revenge-mod/externals/react-navigation' import defer * as Shopify from '@revenge-mod/externals/shopify' import { InternalPluginFlags, registerPlugin } from '@revenge-mod/plugins/_' @@ -26,6 +27,9 @@ registerPlugin( ReactNativeClipboard: () => { return ReactNativeClipboard }, + ReactNativeSafeAreaContext: () => { + return ReactNativeSafeAreaContext + }, ReactNavigation: () => { return ReactNavigation },