Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(#38): make module TurboModule-compatible #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mateusz1913
Copy link

Closes #38

👋 This PR adds TurboModule support

List of changes:

  • create JS Codegen spec
  • use install_modules_dependencies util in podspec if possible, to install React deps
  • migrate Android module class to conform to codegenerated spec when new arch enabled
  • copy codegen-ed to oldarch Android source set to make module work when new arch disabled
  • migrate iOS module class to conform to codegenerated spec when new arch enabled

- create JS Codegen spec
- use install_modules_dependencies util in podspec if possible, to install React deps
- migrate Android module class to conform to codegenerated spec when new arch enabled
- copy codegen-ed to oldarch Android source set to make module work when new arch disabled
- migrate iOS module class to conform to codegenerated spec when new arch enabled
@mateusz1913
Copy link
Author

Hi @LinusU , let me know if there's anything I'd need to improve in this PR

@pinpong
Copy link

pinpong commented Dec 2, 2024

@LinusU lgtm

@pinpong
Copy link

pinpong commented Dec 5, 2024

@mateusz1913 is the android newarch folder missing?

@mateusz1913
Copy link
Author

@pinpong no, the codegen spec class is used by default and if old arch enabled, it uses the class from old arch folder

@brentpi
Copy link

brentpi commented Jan 23, 2025

For some reason; when using the TurboModule implementation - Sentry seems to stop generating its event identifiers correctly for me (only difference is TurboModule/non-TurboModule). When it fails, it falls back to a static ID (10000000100040008000100000000000).

import { TurboModuleRegistry } from 'react-native';

export interface Spec extends TurboModule {
+getRandomBase64: (byteLength: Int32) => string;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mateusz1913 When running this, I needed to change this to 'Double' rather than 'Int32' to make the types match correctly in Obj-C.

For a Uint8Array(10), byteLength in getRandomBase64 was "4621819117588971520" in the debugger, and I was receiving "Error: Exception in HostFunction: Failed to aquire secure random bytes".

Changing this type def resolves this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate to new architecture
3 participants