revert patch, just do debugging part

This commit is contained in:
Samuel Newman
2025-09-12 08:14:40 +03:00
parent 2682989f3c
commit e326694c1f
2 changed files with 12 additions and 67 deletions
+12 -64
View File
@@ -1,91 +1,39 @@
diff --git a/node_modules/react-native-mmkv/lib/commonjs/createMMKV.js b/node_modules/react-native-mmkv/lib/commonjs/createMMKV.js
index b9b9d69..9ec36f9 100644
index b9b9d69..e85a178 100644
--- a/node_modules/react-native-mmkv/lib/commonjs/createMMKV.js
+++ b/node_modules/react-native-mmkv/lib/commonjs/createMMKV.js
@@ -38,8 +38,8 @@ const createMMKV = config => {
}
@@ -39,7 +39,7 @@ const createMMKV = config => {
// Check if we are running on-device (JSI)
- if (global.nativeCallSyncHook == null || MMKVModule.install == null) {
if (global.nativeCallSyncHook == null || 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.');
+ 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. isRemoteDebuggingInChrome(): ${isRemoteDebuggingInChrome()}; MMKVModule.install == null: ${MMKVModule.install == null}`);
+ throw new Error(`Failed to create a new MMKV instance: React Native is not running on-device etc etc. typeof global.nativeCallSyncHook: ${typeof global.nativeCallSyncHook}, typeof MMKVModule.install: ${typeof MMKVModule.install} (CJS)`);
}
// Call the synchronous blocking install() function
@@ -51,5 +51,13 @@ const createMMKV = config => {
}
return global.mmkvCreateNewInstance(config);
};
+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';
+}
exports.createMMKV = createMMKV;
//# sourceMappingURL=createMMKV.js.map
diff --git a/node_modules/react-native-mmkv/lib/module/createMMKV.js b/node_modules/react-native-mmkv/lib/module/createMMKV.js
index 644840d..6e704d6 100644
index 644840d..8ebb03e 100644
--- a/node_modules/react-native-mmkv/lib/module/createMMKV.js
+++ b/node_modules/react-native-mmkv/lib/module/createMMKV.js
@@ -32,8 +32,8 @@ export const createMMKV = config => {
}
@@ -33,7 +33,7 @@ export const createMMKV = config => {
// Check if we are running on-device (JSI)
- if (global.nativeCallSyncHook == null || MMKVModule.install == null) {
if (global.nativeCallSyncHook == null || 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.');
+ 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. isRemoteDebuggingInChrome(): ${isRemoteDebuggingInChrome()}; MMKVModule.install == null: ${MMKVModule.install == null}`);
+ throw new Error(`Failed to create a new MMKV instance: React Native is not running on-device etc etc. typeof global.nativeCallSyncHook: ${typeof global.nativeCallSyncHook}, typeof MMKVModule.install: ${typeof MMKVModule.install} (MJS)`);
}
// Call the synchronous blocking install() function
@@ -45,4 +45,13 @@ export const createMMKV = config => {
}
return global.mmkvCreateNewInstance(config);
};
+
+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';
+}
//# sourceMappingURL=createMMKV.js.map
diff --git a/node_modules/react-native-mmkv/src/createMMKV.ts b/node_modules/react-native-mmkv/src/createMMKV.ts
index 15d29a0..55675fd 100644
index 15d29a0..150e53e 100644
--- a/node_modules/react-native-mmkv/src/createMMKV.ts
+++ b/node_modules/react-native-mmkv/src/createMMKV.ts
@@ -46,9 +46,9 @@ export const createMMKV = (config: MMKVConfiguration): NativeMMKV => {
}
@@ -48,7 +48,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) {
if (global.nativeCallSyncHook == null || 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.'
+ `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. isRemoteDebuggingInChrome(): ${isRemoteDebuggingInChrome()}; MMKVModule.install == null: ${MMKVModule.install == null}`
+ `Failed to create a new MMKV instance: React Native is not running on-device etc etc. typeof global.nativeCallSyncHook: ${typeof global.nativeCallSyncHook}, typeof MMKVModule.install: ${typeof MMKVModule.install}`
);
}
@@ -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';
+}
@@ -1,3 +0,0 @@
# react-native-mmkv+2.12.2.patch.md
Patch of https://github.com/mrousavy/react-native-mmkv/pull/778