-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic chrome debugger support (#2197)
## Description #### Problem Reanimated uses JSI and this makes impossible remote debugging by chrome inspector. #### Solution If someone uses chrome inspector debugging, Reanimated replaces JSI bindings with pure JS implementation from the web version. This allows using chrome debugger in an application whose contains reanimated. #### Known limitation - reanimated 1 #### TODO: - [x] gesture handler - [x] fast reload - [x] test ios - [x] test web - [x] test jest
- Loading branch information
Showing
13 changed files
with
188 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
import { NativeModules } from 'react-native'; | ||
import ReanimatedModuleCompat from './ReanimatedModuleCompat'; | ||
import { nativeShouldBeMock } from './reanimated2/PlatformChecker'; | ||
|
||
const { ReanimatedModule } = NativeModules; | ||
let exportedModule; | ||
if (nativeShouldBeMock()) { | ||
exportedModule = ReanimatedModuleCompat; | ||
} else { | ||
const { ReanimatedModule } = NativeModules; | ||
exportedModule = ReanimatedModule; | ||
} | ||
|
||
export default ReanimatedModule; | ||
export default exportedModule; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,70 @@ | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-nocheck | ||
import { Platform } from 'react-native'; | ||
import reanimatedJS from './js-reanimated'; | ||
import { nativeShouldBeMock } from './PlatformChecker'; | ||
|
||
export default reanimatedJS; | ||
let exportedModule; | ||
if (nativeShouldBeMock()) { | ||
exportedModule = reanimatedJS; | ||
} else { | ||
const InnerNativeModule = global.__reanimatedModuleProxy; | ||
|
||
const NativeReanimated = { | ||
native: true, | ||
useOnlyV1: InnerNativeModule == null, | ||
|
||
installCoreFunctions(valueSetter) { | ||
return InnerNativeModule.installCoreFunctions(valueSetter); | ||
}, | ||
|
||
makeShareable(value) { | ||
return InnerNativeModule.makeShareable(value); | ||
}, | ||
|
||
makeMutable(value) { | ||
return InnerNativeModule.makeMutable(value); | ||
}, | ||
|
||
makeRemote(object) { | ||
return InnerNativeModule.makeRemote(object); | ||
}, | ||
|
||
startMapper(mapper, inputs = [], outputs = [], updater, tag, name) { | ||
return InnerNativeModule.startMapper( | ||
mapper, | ||
inputs, | ||
outputs, | ||
updater, | ||
tag, | ||
name | ||
); | ||
}, | ||
|
||
stopMapper(mapperId) { | ||
return InnerNativeModule.stopMapper(mapperId); | ||
}, | ||
|
||
registerEventHandler(eventHash, eventHandler) { | ||
return InnerNativeModule.registerEventHandler(eventHash, eventHandler); | ||
}, | ||
|
||
unregisterEventHandler(registrationId) { | ||
return InnerNativeModule.unregisterEventHandler(registrationId); | ||
}, | ||
|
||
getViewProp(viewTag, propName, callback) { | ||
return InnerNativeModule.getViewProp(viewTag, propName, callback); | ||
}, | ||
}; | ||
|
||
if (NativeReanimated.useOnlyV1 && Platform.OS === 'android') { | ||
console.warn( | ||
`If you want to use Reanimated 2 then go through our installation steps https://docs.swmansion.com/react-native-reanimated/docs/installation` | ||
); | ||
} | ||
|
||
exportedModule = NativeReanimated; | ||
} | ||
|
||
export default exportedModule; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Platform } from 'react-native'; | ||
|
||
export function isJest(): boolean { | ||
return !!process.env.JEST_WORKER_ID; | ||
} | ||
|
||
export function isChromeDebugger(): boolean { | ||
return !(global as any).nativeCallSyncHook || (global as any).__REMOTEDEV__; | ||
} | ||
|
||
export function isWeb(): boolean { | ||
return Platform.OS === 'web'; | ||
} | ||
|
||
export function shouldBeUseWeb() { | ||
return isJest() || isChromeDebugger() || isWeb(); | ||
} | ||
|
||
export function nativeShouldBeMock() { | ||
return isJest() || isChromeDebugger(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.