From db57b5d9394a0e40b459458c2c72eb8cb02cabd5 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Thu, 11 Sep 2025 21:01:03 +0300 Subject: [PATCH] add speculative react-native-mmkv patch --- patches/react-native-mmkv+2.12.2.patch | 30 +++++++++++++++++++++++ patches/react-native-mmkv+2.12.2.patch.md | 3 +++ 2 files changed, 33 insertions(+) create mode 100644 patches/react-native-mmkv+2.12.2.patch create mode 100644 patches/react-native-mmkv+2.12.2.patch.md diff --git a/patches/react-native-mmkv+2.12.2.patch b/patches/react-native-mmkv+2.12.2.patch new file mode 100644 index 0000000000..f2d49896db --- /dev/null +++ b/patches/react-native-mmkv+2.12.2.patch @@ -0,0 +1,30 @@ +diff --git a/node_modules/react-native-mmkv/src/createMMKV.ts b/node_modules/react-native-mmkv/src/createMMKV.ts +index 15d29a0..e97a879 100644 +--- a/node_modules/react-native-mmkv/src/createMMKV.ts ++++ b/node_modules/react-native-mmkv/src/createMMKV.ts +@@ -46,7 +46,7 @@ export const createMMKV = (config: MMKVConfiguration): NativeMMKV => { + } + + // Check if we are running on-device (JSI) +- if (global.nativeCallSyncHook == null || MMKVModule.install == null) { ++ if (isRemoteDebuggingInChrome() || MMKVModule.install == null) { + throw new Error( + 'Failed to create a new MMKV instance: React Native is not running on-device. MMKV can only be used when synchronous method invocations (JSI) are possible. If you are using a remote debugger (e.g. Chrome), switch to an on-device debugger (e.g. Flipper) instead.' + ); +@@ -68,3 +68,16 @@ export const createMMKV = (config: MMKVConfiguration): NativeMMKV => { + + return global.mmkvCreateNewInstance(config); + }; ++ ++declare global { ++ const RN$Bridgeless: boolean; ++} ++ ++function isRemoteDebuggingInChrome() { ++ // Remote debugging in Chrome is not supported in bridgeless ++ if ('RN$Bridgeless' in global && RN$Bridgeless === true) { ++ return false; ++ } ++ ++ return __DEV__ && typeof global.nativeCallSyncHook === 'undefined'; ++} diff --git a/patches/react-native-mmkv+2.12.2.patch.md b/patches/react-native-mmkv+2.12.2.patch.md new file mode 100644 index 0000000000..8d0a4fe5e0 --- /dev/null +++ b/patches/react-native-mmkv+2.12.2.patch.md @@ -0,0 +1,3 @@ +# react-native-mmkv+2.12.2.patch.md + +Patch of https://github.com/mrousavy/react-native-mmkv/pull/778