-
Notifications
You must be signed in to change notification settings - Fork 37
feat: add new arch #119
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: add new arch #119
Changes from all commits
4e25fe8
be3e166
2648f0f
5c0c2a2
6a5f7d3
29ae306
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,22 +3,89 @@ | |
| import androidx.annotation.NonNull; | ||
|
|
||
| import com.facebook.react.ReactPackage; | ||
| import com.facebook.react.TurboReactPackage; | ||
| import com.facebook.react.bridge.NativeModule; | ||
| import com.facebook.react.bridge.ReactApplicationContext; | ||
| import com.facebook.react.module.annotations.ReactModule; | ||
| import com.facebook.react.module.annotations.ReactModuleList; | ||
| import com.facebook.react.module.model.ReactModuleInfo; | ||
| import com.facebook.react.module.model.ReactModuleInfoProvider; | ||
| import com.facebook.react.turbomodule.core.interfaces.TurboModule; | ||
| import com.facebook.react.uimanager.ViewManager; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.Collections; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| import javax.annotation.Nonnull; | ||
|
|
||
| public class SequelPackage implements ReactPackage { | ||
|
|
||
| @ReactModuleList( | ||
| nativeModules = { | ||
| SequelModule.class, | ||
| }) | ||
| public class SequelPackage extends TurboReactPackage { | ||
| @NonNull | ||
| @Override | ||
| public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) { | ||
| return Collections.singletonList(new SequelModule(reactContext)); | ||
| } | ||
|
|
||
| @Override | ||
| public NativeModule getModule(String name, @Nonnull ReactApplicationContext reactContext) { | ||
| switch (name) { | ||
| case SequelModule.NAME: | ||
| return new SequelModule(reactContext); | ||
| default: | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public ReactModuleInfoProvider getReactModuleInfoProvider() { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks complex, I guess it is necessary to register the turbomodule, can you explain a bit what it does? It looks like some kind of description
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you look deeper into that method, it is a kind of a description of the module. I didn't debug where it is used exactly though. |
||
| try { | ||
| Class<?> reactModuleInfoProviderClass = | ||
| Class.forName("com.reactnativequicksqlite.SequelPackage$$ReactModuleInfoProvider"); | ||
| return (ReactModuleInfoProvider) reactModuleInfoProviderClass.newInstance(); | ||
| } catch (ClassNotFoundException e) { | ||
| // ReactModuleSpecProcessor does not run at build-time. Create this ReactModuleInfoProvider by | ||
| // hand. | ||
| return new ReactModuleInfoProvider() { | ||
| @Override | ||
| public Map<String, ReactModuleInfo> getReactModuleInfos() { | ||
| final Map<String, ReactModuleInfo> reactModuleInfoMap = new HashMap<>(); | ||
|
|
||
| Class<? extends NativeModule>[] moduleList = | ||
| new Class[] { | ||
| SequelModule.class, | ||
| }; | ||
|
|
||
| for (Class<? extends NativeModule> moduleClass : moduleList) { | ||
| ReactModule reactModule = moduleClass.getAnnotation(ReactModule.class); | ||
|
|
||
| reactModuleInfoMap.put( | ||
| reactModule.name(), | ||
| new ReactModuleInfo( | ||
| reactModule.name(), | ||
| moduleClass.getName(), | ||
| reactModule.canOverrideExistingModule(), | ||
| reactModule.needsEagerInit(), | ||
| reactModule.hasConstants(), | ||
| reactModule.isCxxModule(), | ||
| TurboModule.class.isAssignableFrom(moduleClass))); | ||
| } | ||
|
|
||
| return reactModuleInfoMap; | ||
| } | ||
| }; | ||
| } catch (InstantiationException | IllegalAccessException e) { | ||
| throw new RuntimeException( | ||
| "No ReactModuleInfoProvider for com.reactnativequicksqlite.SequelPackage$$ReactModuleInfoProvider", e); | ||
| } | ||
| } | ||
|
|
||
| @NonNull | ||
| @Override | ||
| public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
|
|
||
| /** | ||
| * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). | ||
| * | ||
| * Do not edit this file as changes may cause incorrect behavior and will be lost | ||
| * once the code is regenerated. | ||
| * | ||
| * @generated by codegen project: GenerateModuleJavaSpec.js | ||
| * | ||
| * @nolint | ||
| */ | ||
|
|
||
| package com.reactnativequicksqlite; | ||
|
|
||
| import com.facebook.proguard.annotations.DoNotStrip; | ||
| import com.facebook.react.bridge.ReactApplicationContext; | ||
| import com.facebook.react.bridge.ReactContextBaseJavaModule; | ||
| import com.facebook.react.bridge.ReactMethod; | ||
| import com.facebook.react.bridge.ReactModuleWithSpec; | ||
| import com.facebook.react.turbomodule.core.interfaces.TurboModule; | ||
|
|
||
| public abstract class NativeQuickSQLiteModuleSpec extends ReactContextBaseJavaModule implements ReactModuleWithSpec, TurboModule { | ||
| public NativeQuickSQLiteModuleSpec(ReactApplicationContext reactContext) { | ||
| super(reactContext); | ||
| } | ||
|
|
||
| @ReactMethod(isBlockingSynchronousMethod = true) | ||
| @DoNotStrip | ||
| public abstract boolean install(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when I was adding support for 0.71 this caused errors regarding duplicate symbols and caused conflicts with other libraries, is this correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't see anything like this to be honest, and if I removed it, it seems like the codegen does not generate specs, so it is necessary 😅 You can see this step here too: https://github.com/react-native-community/RNNewArchitectureLibraries/tree/feat/back-turbomodule-070#turbomodule-set-up-buildgradle