@nrwl/react-native 14.0.0-beta.3 → 14.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/migrations.json +58 -0
- package/package.json +8 -8
- package/plugins/metro-resolver.js +16 -20
- package/plugins/metro-resolver.js.map +1 -1
- package/plugins/with-nx-metro.d.ts +2 -0
- package/plugins/with-nx-metro.js +16 -3
- package/plugins/with-nx-metro.js.map +1 -1
- package/src/generators/application/files/app/android/app/build.gradle.template +111 -22
- package/src/generators/application/files/app/android/app/src/androidTest/java/com/__lowerCaseName__/DetoxTest.java.template +1 -1
- package/src/generators/application/files/app/android/app/src/debug/AndroidManifest.xml.template +4 -3
- package/src/generators/application/files/app/android/app/src/debug/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +4 -3
- package/src/generators/application/files/app/android/app/src/main/AndroidManifest.xml.template +26 -46
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.java.template +27 -2
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.java.template +13 -2
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/newarchitecture/MainApplicationReactNativeHost.java.template +116 -0
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/newarchitecture/components/MainComponentsRegistry.java.template +36 -0
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java.template +48 -0
- package/src/generators/application/files/app/android/app/src/main/jni/Android.mk.template +49 -0
- package/src/generators/application/files/app/android/app/src/main/jni/MainApplicationModuleProvider.cpp +24 -0
- package/src/generators/application/files/app/android/app/src/main/jni/MainApplicationModuleProvider.h +16 -0
- package/src/generators/application/files/app/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp +45 -0
- package/src/generators/application/files/app/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h.template +38 -0
- package/src/generators/application/files/app/android/app/src/main/jni/MainComponentsRegistry.cpp +61 -0
- package/src/generators/application/files/app/android/app/src/main/jni/MainComponentsRegistry.h.template +32 -0
- package/src/generators/application/files/app/android/app/src/main/jni/OnLoad.cpp +11 -0
- package/src/generators/application/files/app/android/build.gradle.template +22 -9
- package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.properties +2 -2
- package/src/generators/application/files/app/android/gradle.properties +15 -10
- package/src/generators/application/files/app/android/gradlew.bat +234 -89
- package/src/generators/application/files/app/android/gradlew.template +154 -105
- package/src/generators/application/files/app/android/settings.gradle.template +6 -0
- package/src/generators/application/files/app/ios/Podfile.template +9 -2
- package/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template +108 -0
- package/src/generators/application/files/app/ios/__className__/Images.xcassets/AppIcon.appiconset/Contents.json +29 -14
- package/src/generators/application/files/app/ios/__className__/main.m +3 -3
- package/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template +48 -37
- package/src/generators/application/files/app/metro.config.js.template +5 -1
- package/src/generators/application/files/app/src/app/App.spec.tsx.template +1 -1
- package/src/generators/application/files/app/src/main.tsx.template +1 -1
- package/src/generators/application/files/app/tsconfig.app.json.template +1 -1
- package/src/generators/application/lib/add-project.js +2 -2
- package/src/generators/application/lib/add-project.js.map +1 -1
- package/src/generators/application/lib/create-application-files.js +1 -1
- package/src/generators/application/lib/create-application-files.js.map +1 -1
- package/src/generators/application/lib/nomalize-options.spec.ts +5 -10
- package/src/generators/application/lib/normalize-options.d.ts +0 -1
- package/src/generators/application/lib/normalize-options.js +2 -4
- package/src/generators/application/lib/normalize-options.js.map +1 -1
- package/src/generators/init/init.js +2 -8
- package/src/generators/init/init.js.map +1 -1
- package/src/generators/init/init.spec.ts +0 -25
- package/src/generators/init/lib/gitignore-entries.d.ts +1 -1
- package/src/generators/init/lib/gitignore-entries.js +25 -17
- package/src/generators/init/lib/gitignore-entries.js.map +1 -1
- package/src/generators/library/library.spec.ts +1 -1
- package/src/migrations/update-14-0-0/add-project-root-metro-config-14-0-0.d.ts +6 -0
- package/src/migrations/update-14-0-0/add-project-root-metro-config-14-0-0.js +35 -0
- package/src/migrations/update-14-0-0/add-project-root-metro-config-14-0-0.js.map +1 -0
- package/src/migrations/update-14-0-0/add-project-root-metro-config-14-0-0.spec.ts +188 -0
- package/src/migrations/update-14-0-0/update-entry-file-bundle-14-0-0.d.ts +5 -0
- package/src/migrations/update-14-0-0/update-entry-file-bundle-14-0-0.js +39 -0
- package/src/migrations/update-14-0-0/update-entry-file-bundle-14-0-0.js.map +1 -0
- package/src/migrations/update-14-0-0/update-entry-file-bundle-14-0-0.spec.ts +84 -0
- package/src/utils/add-jest.js +2 -2
- package/src/utils/versions.d.ts +7 -8
- package/src/utils/versions.js +9 -13
- package/src/utils/versions.js.map +1 -1
- package/src/generators/application/files/app/ios/__className__/AppDelegate.m.template +0 -62
|
@@ -8,7 +8,9 @@ import com.lugg.ReactNativeConfig.ReactNativeConfigPackage;
|
|
|
8
8
|
import com.facebook.react.ReactInstanceManager;
|
|
9
9
|
import com.facebook.react.ReactNativeHost;
|
|
10
10
|
import com.facebook.react.ReactPackage;
|
|
11
|
+
import com.facebook.react.config.ReactFeatureFlags;
|
|
11
12
|
import com.facebook.soloader.SoLoader;
|
|
13
|
+
import com.<%= lowerCaseName %>.newarchitecture.MainApplicationReactNativeHost;
|
|
12
14
|
import java.lang.reflect.InvocationTargetException;
|
|
13
15
|
import java.util.List;
|
|
14
16
|
|
|
@@ -32,18 +34,27 @@ public class MainApplication extends Application implements ReactApplication {
|
|
|
32
34
|
|
|
33
35
|
@Override
|
|
34
36
|
protected String getJSMainModuleName() {
|
|
35
|
-
return "<%=
|
|
37
|
+
return "<%= entryFile %>";
|
|
36
38
|
}
|
|
37
39
|
};
|
|
38
40
|
|
|
41
|
+
private final ReactNativeHost mNewArchitectureNativeHost =
|
|
42
|
+
new MainApplicationReactNativeHost(this);
|
|
43
|
+
|
|
39
44
|
@Override
|
|
40
45
|
public ReactNativeHost getReactNativeHost() {
|
|
41
|
-
|
|
46
|
+
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
|
|
47
|
+
return mNewArchitectureNativeHost;
|
|
48
|
+
} else {
|
|
49
|
+
return mReactNativeHost;
|
|
50
|
+
}
|
|
42
51
|
}
|
|
43
52
|
|
|
44
53
|
@Override
|
|
45
54
|
public void onCreate() {
|
|
46
55
|
super.onCreate();
|
|
56
|
+
// If you opted-in for the New Architecture, we enable the TurboModule system
|
|
57
|
+
ReactFeatureFlags.useTurboModules = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
|
|
47
58
|
SoLoader.init(this, /* native exopackage */ false);
|
|
48
59
|
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
|
|
49
60
|
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
package com.<%= lowerCaseName %>.newarchitecture;
|
|
2
|
+
|
|
3
|
+
import android.app.Application;
|
|
4
|
+
import androidx.annotation.NonNull;
|
|
5
|
+
import com.facebook.react.PackageList;
|
|
6
|
+
import com.facebook.react.ReactInstanceManager;
|
|
7
|
+
import com.facebook.react.ReactNativeHost;
|
|
8
|
+
import com.facebook.react.ReactPackage;
|
|
9
|
+
import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
|
|
10
|
+
import com.facebook.react.bridge.JSIModulePackage;
|
|
11
|
+
import com.facebook.react.bridge.JSIModuleProvider;
|
|
12
|
+
import com.facebook.react.bridge.JSIModuleSpec;
|
|
13
|
+
import com.facebook.react.bridge.JSIModuleType;
|
|
14
|
+
import com.facebook.react.bridge.JavaScriptContextHolder;
|
|
15
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
16
|
+
import com.facebook.react.bridge.UIManager;
|
|
17
|
+
import com.facebook.react.fabric.ComponentFactory;
|
|
18
|
+
import com.facebook.react.fabric.CoreComponentsRegistry;
|
|
19
|
+
import com.facebook.react.fabric.EmptyReactNativeConfig;
|
|
20
|
+
import com.facebook.react.fabric.FabricJSIModuleProvider;
|
|
21
|
+
import com.facebook.react.uimanager.ViewManagerRegistry;
|
|
22
|
+
import com.<%= lowerCaseName %>.BuildConfig;
|
|
23
|
+
import com.<%= lowerCaseName %>.newarchitecture.components.MainComponentsRegistry;
|
|
24
|
+
import com.<%= lowerCaseName %>.newarchitecture.modules.MainApplicationTurboModuleManagerDelegate;
|
|
25
|
+
import java.util.ArrayList;
|
|
26
|
+
import java.util.List;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A {@link ReactNativeHost} that helps you load everything needed for the New Architecture, both
|
|
30
|
+
* TurboModule delegates and the Fabric Renderer.
|
|
31
|
+
*
|
|
32
|
+
* <p>Please note that this class is used ONLY if you opt-in for the New Architecture (see the
|
|
33
|
+
* `newArchEnabled` property). Is ignored otherwise.
|
|
34
|
+
*/
|
|
35
|
+
public class MainApplicationReactNativeHost extends ReactNativeHost {
|
|
36
|
+
public MainApplicationReactNativeHost(Application application) {
|
|
37
|
+
super(application);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@Override
|
|
41
|
+
public boolean getUseDeveloperSupport() {
|
|
42
|
+
return BuildConfig.DEBUG;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@Override
|
|
46
|
+
protected List<ReactPackage> getPackages() {
|
|
47
|
+
List<ReactPackage> packages = new PackageList(this).getPackages();
|
|
48
|
+
// Packages that cannot be autolinked yet can be added manually here, for example:
|
|
49
|
+
// packages.add(new MyReactNativePackage());
|
|
50
|
+
// TurboModules must also be loaded here providing a valid TurboReactPackage implementation:
|
|
51
|
+
// packages.add(new TurboReactPackage() { ... });
|
|
52
|
+
// If you have custom Fabric Components, their ViewManagers should also be loaded here
|
|
53
|
+
// inside a ReactPackage.
|
|
54
|
+
return packages;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@Override
|
|
58
|
+
protected String getJSMainModuleName() {
|
|
59
|
+
return "<%= entryFile %>";
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@NonNull
|
|
63
|
+
@Override
|
|
64
|
+
protected ReactPackageTurboModuleManagerDelegate.Builder
|
|
65
|
+
getReactPackageTurboModuleManagerDelegateBuilder() {
|
|
66
|
+
// Here we provide the ReactPackageTurboModuleManagerDelegate Builder. This is necessary
|
|
67
|
+
// for the new architecture and to use TurboModules correctly.
|
|
68
|
+
return new MainApplicationTurboModuleManagerDelegate.Builder();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@Override
|
|
72
|
+
protected JSIModulePackage getJSIModulePackage() {
|
|
73
|
+
return new JSIModulePackage() {
|
|
74
|
+
@Override
|
|
75
|
+
public List<JSIModuleSpec> getJSIModules(
|
|
76
|
+
final ReactApplicationContext reactApplicationContext,
|
|
77
|
+
final JavaScriptContextHolder jsContext) {
|
|
78
|
+
final List<JSIModuleSpec> specs = new ArrayList<>();
|
|
79
|
+
|
|
80
|
+
// Here we provide a new JSIModuleSpec that will be responsible of providing the
|
|
81
|
+
// custom Fabric Components.
|
|
82
|
+
specs.add(
|
|
83
|
+
new JSIModuleSpec() {
|
|
84
|
+
@Override
|
|
85
|
+
public JSIModuleType getJSIModuleType() {
|
|
86
|
+
return JSIModuleType.UIManager;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@Override
|
|
90
|
+
public JSIModuleProvider<UIManager> getJSIModuleProvider() {
|
|
91
|
+
final ComponentFactory componentFactory = new ComponentFactory();
|
|
92
|
+
CoreComponentsRegistry.register(componentFactory);
|
|
93
|
+
|
|
94
|
+
// Here we register a Components Registry.
|
|
95
|
+
// The one that is generated with the template contains no components
|
|
96
|
+
// and just provides you the one from React Native core.
|
|
97
|
+
MainComponentsRegistry.register(componentFactory);
|
|
98
|
+
|
|
99
|
+
final ReactInstanceManager reactInstanceManager = getReactInstanceManager();
|
|
100
|
+
|
|
101
|
+
ViewManagerRegistry viewManagerRegistry =
|
|
102
|
+
new ViewManagerRegistry(
|
|
103
|
+
reactInstanceManager.getOrCreateViewManagers(reactApplicationContext));
|
|
104
|
+
|
|
105
|
+
return new FabricJSIModuleProvider(
|
|
106
|
+
reactApplicationContext,
|
|
107
|
+
componentFactory,
|
|
108
|
+
new EmptyReactNativeConfig(),
|
|
109
|
+
viewManagerRegistry);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
return specs;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
package com.<%= lowerCaseName %>.newarchitecture.components;
|
|
2
|
+
|
|
3
|
+
import com.facebook.jni.HybridData;
|
|
4
|
+
import com.facebook.proguard.annotations.DoNotStrip;
|
|
5
|
+
import com.facebook.react.fabric.ComponentFactory;
|
|
6
|
+
import com.facebook.soloader.SoLoader;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Class responsible to load the custom Fabric Components. This class has native methods and needs a
|
|
10
|
+
* corresponding C++ implementation/header file to work correctly (already placed inside the jni/
|
|
11
|
+
* folder for you).
|
|
12
|
+
*
|
|
13
|
+
* <p>Please note that this class is used ONLY if you opt-in for the New Architecture (see the
|
|
14
|
+
* `newArchEnabled` property). Is ignored otherwise.
|
|
15
|
+
*/
|
|
16
|
+
@DoNotStrip
|
|
17
|
+
public class MainComponentsRegistry {
|
|
18
|
+
static {
|
|
19
|
+
SoLoader.loadLibrary("fabricjni");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@DoNotStrip private final HybridData mHybridData;
|
|
23
|
+
|
|
24
|
+
@DoNotStrip
|
|
25
|
+
private native HybridData initHybrid(ComponentFactory componentFactory);
|
|
26
|
+
|
|
27
|
+
@DoNotStrip
|
|
28
|
+
private MainComponentsRegistry(ComponentFactory componentFactory) {
|
|
29
|
+
mHybridData = initHybrid(componentFactory);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@DoNotStrip
|
|
33
|
+
public static MainComponentsRegistry register(ComponentFactory componentFactory) {
|
|
34
|
+
return new MainComponentsRegistry(componentFactory);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
package com.<%= lowerCaseName %>.newarchitecture.modules;
|
|
2
|
+
|
|
3
|
+
import com.facebook.jni.HybridData;
|
|
4
|
+
import com.facebook.react.ReactPackage;
|
|
5
|
+
import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
+
import com.facebook.soloader.SoLoader;
|
|
8
|
+
import java.util.List;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Class responsible to load the TurboModules. This class has native methods and needs a
|
|
12
|
+
* corresponding C++ implementation/header file to work correctly (already placed inside the jni/
|
|
13
|
+
* folder for you).
|
|
14
|
+
*
|
|
15
|
+
* <p>Please note that this class is used ONLY if you opt-in for the New Architecture (see the
|
|
16
|
+
* `newArchEnabled` property). Is ignored otherwise.
|
|
17
|
+
*/
|
|
18
|
+
public class MainApplicationTurboModuleManagerDelegate
|
|
19
|
+
extends ReactPackageTurboModuleManagerDelegate {
|
|
20
|
+
|
|
21
|
+
private static volatile boolean sIsSoLibraryLoaded;
|
|
22
|
+
|
|
23
|
+
protected MainApplicationTurboModuleManagerDelegate(
|
|
24
|
+
ReactApplicationContext reactApplicationContext, List<ReactPackage> packages) {
|
|
25
|
+
super(reactApplicationContext, packages);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
protected native HybridData initHybrid();
|
|
29
|
+
|
|
30
|
+
native boolean canCreateTurboModule(String moduleName);
|
|
31
|
+
|
|
32
|
+
public static class Builder extends ReactPackageTurboModuleManagerDelegate.Builder {
|
|
33
|
+
protected MainApplicationTurboModuleManagerDelegate build(
|
|
34
|
+
ReactApplicationContext context, List<ReactPackage> packages) {
|
|
35
|
+
return new MainApplicationTurboModuleManagerDelegate(context, packages);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Override
|
|
40
|
+
protected synchronized void maybeLoadOtherSoLibraries() {
|
|
41
|
+
if (!sIsSoLibraryLoaded) {
|
|
42
|
+
// If you change the name of your application .so file in the Android.mk file,
|
|
43
|
+
// make sure you update the name here as well.
|
|
44
|
+
SoLoader.loadLibrary("<%= lowerCaseName %>_appmodules");
|
|
45
|
+
sIsSoLibraryLoaded = true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
THIS_DIR := $(call my-dir)
|
|
2
|
+
|
|
3
|
+
include $(REACT_ANDROID_DIR)/Android-prebuilt.mk
|
|
4
|
+
|
|
5
|
+
# If you wish to add a custom TurboModule or Fabric component in your app you
|
|
6
|
+
# will have to include the following autogenerated makefile.
|
|
7
|
+
# include $(GENERATED_SRC_DIR)/codegen/jni/Android.mk
|
|
8
|
+
include $(CLEAR_VARS)
|
|
9
|
+
|
|
10
|
+
LOCAL_PATH := $(THIS_DIR)
|
|
11
|
+
|
|
12
|
+
# You can customize the name of your application .so file here.
|
|
13
|
+
LOCAL_MODULE := <%= lowerCaseName %>_appmodules
|
|
14
|
+
|
|
15
|
+
LOCAL_C_INCLUDES := $(LOCAL_PATH)
|
|
16
|
+
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp)
|
|
17
|
+
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
|
|
18
|
+
|
|
19
|
+
# If you wish to add a custom TurboModule or Fabric component in your app you
|
|
20
|
+
# will have to uncomment those lines to include the generated source
|
|
21
|
+
# files from the codegen (placed in $(GENERATED_SRC_DIR)/codegen/jni)
|
|
22
|
+
#
|
|
23
|
+
# LOCAL_C_INCLUDES += $(GENERATED_SRC_DIR)/codegen/jni
|
|
24
|
+
# LOCAL_SRC_FILES += $(wildcard $(GENERATED_SRC_DIR)/codegen/jni/*.cpp)
|
|
25
|
+
# LOCAL_EXPORT_C_INCLUDES += $(GENERATED_SRC_DIR)/codegen/jni
|
|
26
|
+
|
|
27
|
+
# Here you should add any native library you wish to depend on.
|
|
28
|
+
LOCAL_SHARED_LIBRARIES := \
|
|
29
|
+
libfabricjni \
|
|
30
|
+
libfbjni \
|
|
31
|
+
libfolly_futures \
|
|
32
|
+
libfolly_json \
|
|
33
|
+
libglog \
|
|
34
|
+
libjsi \
|
|
35
|
+
libreact_codegen_rncore \
|
|
36
|
+
libreact_debug \
|
|
37
|
+
libreact_nativemodule_core \
|
|
38
|
+
libreact_render_componentregistry \
|
|
39
|
+
libreact_render_core \
|
|
40
|
+
libreact_render_debug \
|
|
41
|
+
libreact_render_graphics \
|
|
42
|
+
librrc_view \
|
|
43
|
+
libruntimeexecutor \
|
|
44
|
+
libturbomodulejsijni \
|
|
45
|
+
libyoga
|
|
46
|
+
|
|
47
|
+
LOCAL_CFLAGS := -DLOG_TAG=\"ReactNative\" -fexceptions -frtti -std=c++17 -Wall
|
|
48
|
+
|
|
49
|
+
include $(BUILD_SHARED_LIBRARY)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#include "MainApplicationModuleProvider.h"
|
|
2
|
+
|
|
3
|
+
#include <rncore.h>
|
|
4
|
+
|
|
5
|
+
namespace facebook {
|
|
6
|
+
namespace react {
|
|
7
|
+
|
|
8
|
+
std::shared_ptr<TurboModule> MainApplicationModuleProvider(
|
|
9
|
+
const std::string moduleName,
|
|
10
|
+
const JavaTurboModule::InitParams ¶ms) {
|
|
11
|
+
// Here you can provide your own module provider for TurboModules coming from
|
|
12
|
+
// either your application or from external libraries. The approach to follow
|
|
13
|
+
// is similar to the following (for a library called `samplelibrary`:
|
|
14
|
+
//
|
|
15
|
+
// auto module = samplelibrary_ModuleProvider(moduleName, params);
|
|
16
|
+
// if (module != nullptr) {
|
|
17
|
+
// return module;
|
|
18
|
+
// }
|
|
19
|
+
// return rncore_ModuleProvider(moduleName, params);
|
|
20
|
+
return rncore_ModuleProvider(moduleName, params);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
} // namespace react
|
|
24
|
+
} // namespace facebook
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
#include <ReactCommon/JavaTurboModule.h>
|
|
7
|
+
|
|
8
|
+
namespace facebook {
|
|
9
|
+
namespace react {
|
|
10
|
+
|
|
11
|
+
std::shared_ptr<TurboModule> MainApplicationModuleProvider(
|
|
12
|
+
const std::string moduleName,
|
|
13
|
+
const JavaTurboModule::InitParams ¶ms);
|
|
14
|
+
|
|
15
|
+
} // namespace react
|
|
16
|
+
} // namespace facebook
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#include "MainApplicationTurboModuleManagerDelegate.h"
|
|
2
|
+
#include "MainApplicationModuleProvider.h"
|
|
3
|
+
|
|
4
|
+
namespace facebook {
|
|
5
|
+
namespace react {
|
|
6
|
+
|
|
7
|
+
jni::local_ref<MainApplicationTurboModuleManagerDelegate::jhybriddata>
|
|
8
|
+
MainApplicationTurboModuleManagerDelegate::initHybrid(
|
|
9
|
+
jni::alias_ref<jhybridobject>) {
|
|
10
|
+
return makeCxxInstance();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
void MainApplicationTurboModuleManagerDelegate::registerNatives() {
|
|
14
|
+
registerHybrid({
|
|
15
|
+
makeNativeMethod(
|
|
16
|
+
"initHybrid", MainApplicationTurboModuleManagerDelegate::initHybrid),
|
|
17
|
+
makeNativeMethod(
|
|
18
|
+
"canCreateTurboModule",
|
|
19
|
+
MainApplicationTurboModuleManagerDelegate::canCreateTurboModule),
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
std::shared_ptr<TurboModule>
|
|
24
|
+
MainApplicationTurboModuleManagerDelegate::getTurboModule(
|
|
25
|
+
const std::string name,
|
|
26
|
+
const std::shared_ptr<CallInvoker> jsInvoker) {
|
|
27
|
+
// Not implemented yet: provide pure-C++ NativeModules here.
|
|
28
|
+
return nullptr;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
std::shared_ptr<TurboModule>
|
|
32
|
+
MainApplicationTurboModuleManagerDelegate::getTurboModule(
|
|
33
|
+
const std::string name,
|
|
34
|
+
const JavaTurboModule::InitParams ¶ms) {
|
|
35
|
+
return MainApplicationModuleProvider(name, params);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
bool MainApplicationTurboModuleManagerDelegate::canCreateTurboModule(
|
|
39
|
+
std::string name) {
|
|
40
|
+
return getTurboModule(name, nullptr) != nullptr ||
|
|
41
|
+
getTurboModule(name, {.moduleName = name}) != nullptr;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
} // namespace react
|
|
45
|
+
} // namespace facebook
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#include <memory>
|
|
2
|
+
#include <string>
|
|
3
|
+
|
|
4
|
+
#include <ReactCommon/TurboModuleManagerDelegate.h>
|
|
5
|
+
#include <fbjni/fbjni.h>
|
|
6
|
+
|
|
7
|
+
namespace facebook {
|
|
8
|
+
namespace react {
|
|
9
|
+
|
|
10
|
+
class MainApplicationTurboModuleManagerDelegate
|
|
11
|
+
: public jni::HybridClass<
|
|
12
|
+
MainApplicationTurboModuleManagerDelegate,
|
|
13
|
+
TurboModuleManagerDelegate> {
|
|
14
|
+
public:
|
|
15
|
+
// Adapt it to the package you used for your Java class.
|
|
16
|
+
static constexpr auto kJavaDescriptor =
|
|
17
|
+
"Lcom/<%= lowerCaseName %>/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate;";
|
|
18
|
+
|
|
19
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject>);
|
|
20
|
+
|
|
21
|
+
static void registerNatives();
|
|
22
|
+
|
|
23
|
+
std::shared_ptr<TurboModule> getTurboModule(
|
|
24
|
+
const std::string name,
|
|
25
|
+
const std::shared_ptr<CallInvoker> jsInvoker) override;
|
|
26
|
+
std::shared_ptr<TurboModule> getTurboModule(
|
|
27
|
+
const std::string name,
|
|
28
|
+
const JavaTurboModule::InitParams ¶ms) override;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Test-only method. Allows user to verify whether a TurboModule can be
|
|
32
|
+
* created by instances of this class.
|
|
33
|
+
*/
|
|
34
|
+
bool canCreateTurboModule(std::string name);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
} // namespace react
|
|
38
|
+
} // namespace facebook
|
package/src/generators/application/files/app/android/app/src/main/jni/MainComponentsRegistry.cpp
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#include "MainComponentsRegistry.h"
|
|
2
|
+
|
|
3
|
+
#include <CoreComponentsRegistry.h>
|
|
4
|
+
#include <fbjni/fbjni.h>
|
|
5
|
+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
|
6
|
+
#include <react/renderer/components/rncore/ComponentDescriptors.h>
|
|
7
|
+
|
|
8
|
+
namespace facebook {
|
|
9
|
+
namespace react {
|
|
10
|
+
|
|
11
|
+
MainComponentsRegistry::MainComponentsRegistry(ComponentFactory *delegate) {}
|
|
12
|
+
|
|
13
|
+
std::shared_ptr<ComponentDescriptorProviderRegistry const>
|
|
14
|
+
MainComponentsRegistry::sharedProviderRegistry() {
|
|
15
|
+
auto providerRegistry = CoreComponentsRegistry::sharedProviderRegistry();
|
|
16
|
+
|
|
17
|
+
// Custom Fabric Components go here. You can register custom
|
|
18
|
+
// components coming from your App or from 3rd party libraries here.
|
|
19
|
+
//
|
|
20
|
+
// providerRegistry->add(concreteComponentDescriptorProvider<
|
|
21
|
+
// AocViewerComponentDescriptor>());
|
|
22
|
+
return providerRegistry;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
jni::local_ref<MainComponentsRegistry::jhybriddata>
|
|
26
|
+
MainComponentsRegistry::initHybrid(
|
|
27
|
+
jni::alias_ref<jclass>,
|
|
28
|
+
ComponentFactory *delegate) {
|
|
29
|
+
auto instance = makeCxxInstance(delegate);
|
|
30
|
+
|
|
31
|
+
auto buildRegistryFunction =
|
|
32
|
+
[](EventDispatcher::Weak const &eventDispatcher,
|
|
33
|
+
ContextContainer::Shared const &contextContainer)
|
|
34
|
+
-> ComponentDescriptorRegistry::Shared {
|
|
35
|
+
auto registry = MainComponentsRegistry::sharedProviderRegistry()
|
|
36
|
+
->createComponentDescriptorRegistry(
|
|
37
|
+
{eventDispatcher, contextContainer});
|
|
38
|
+
|
|
39
|
+
auto mutableRegistry =
|
|
40
|
+
std::const_pointer_cast<ComponentDescriptorRegistry>(registry);
|
|
41
|
+
|
|
42
|
+
mutableRegistry->setFallbackComponentDescriptor(
|
|
43
|
+
std::make_shared<UnimplementedNativeViewComponentDescriptor>(
|
|
44
|
+
ComponentDescriptorParameters{
|
|
45
|
+
eventDispatcher, contextContainer, nullptr}));
|
|
46
|
+
|
|
47
|
+
return registry;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
delegate->buildRegistryFunction = buildRegistryFunction;
|
|
51
|
+
return instance;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
void MainComponentsRegistry::registerNatives() {
|
|
55
|
+
registerHybrid({
|
|
56
|
+
makeNativeMethod("initHybrid", MainComponentsRegistry::initHybrid),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
} // namespace react
|
|
61
|
+
} // namespace facebook
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <ComponentFactory.h>
|
|
4
|
+
#include <fbjni/fbjni.h>
|
|
5
|
+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
|
6
|
+
#include <react/renderer/componentregistry/ComponentDescriptorRegistry.h>
|
|
7
|
+
|
|
8
|
+
namespace facebook {
|
|
9
|
+
namespace react {
|
|
10
|
+
|
|
11
|
+
class MainComponentsRegistry
|
|
12
|
+
: public facebook::jni::HybridClass<MainComponentsRegistry> {
|
|
13
|
+
public:
|
|
14
|
+
// Adapt it to the package you used for your Java class.
|
|
15
|
+
constexpr static auto kJavaDescriptor =
|
|
16
|
+
"Lcom/<%= lowerCaseName %>/newarchitecture/components/MainComponentsRegistry;";
|
|
17
|
+
|
|
18
|
+
static void registerNatives();
|
|
19
|
+
|
|
20
|
+
MainComponentsRegistry(ComponentFactory *delegate);
|
|
21
|
+
|
|
22
|
+
private:
|
|
23
|
+
static std::shared_ptr<ComponentDescriptorProviderRegistry const>
|
|
24
|
+
sharedProviderRegistry();
|
|
25
|
+
|
|
26
|
+
static jni::local_ref<jhybriddata> initHybrid(
|
|
27
|
+
jni::alias_ref<jclass>,
|
|
28
|
+
ComponentFactory *delegate);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
} // namespace react
|
|
32
|
+
} // namespace facebook
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#include <fbjni/fbjni.h>
|
|
2
|
+
#include "MainApplicationTurboModuleManagerDelegate.h"
|
|
3
|
+
#include "MainComponentsRegistry.h"
|
|
4
|
+
|
|
5
|
+
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
|
|
6
|
+
return facebook::jni::initialize(vm, [] {
|
|
7
|
+
facebook::react::MainApplicationTurboModuleManagerDelegate::
|
|
8
|
+
registerNatives();
|
|
9
|
+
facebook::react::MainComponentsRegistry::registerNatives();
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -1,19 +1,34 @@
|
|
|
1
|
+
import org.apache.tools.ant.taskdefs.condition.Os
|
|
2
|
+
|
|
1
3
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
|
2
4
|
|
|
3
5
|
buildscript {
|
|
4
6
|
ext {
|
|
5
|
-
buildToolsVersion = "
|
|
7
|
+
buildToolsVersion = "31.0.0"
|
|
6
8
|
minSdkVersion = 21
|
|
7
|
-
compileSdkVersion =
|
|
8
|
-
targetSdkVersion =
|
|
9
|
-
|
|
9
|
+
compileSdkVersion = 31
|
|
10
|
+
targetSdkVersion = 31
|
|
11
|
+
|
|
12
|
+
if (System.properties['os.arch'] == "aarch64") {
|
|
13
|
+
// For M1 Users we need to use the NDK 24 which added support for aarch64
|
|
14
|
+
ndkVersion = "24.0.8215888"
|
|
15
|
+
} else if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
|
16
|
+
// For Android Users, we need to use NDK 23, otherwise the build will
|
|
17
|
+
// fail due to paths longer than the OS limit
|
|
18
|
+
ndkVersion = "23.1.7779620"
|
|
19
|
+
} else {
|
|
20
|
+
// Otherwise we default to the side-by-side NDK version from AGP.
|
|
21
|
+
ndkVersion = "21.4.7075529"
|
|
22
|
+
}
|
|
10
23
|
}
|
|
11
24
|
repositories {
|
|
12
25
|
google()
|
|
13
26
|
mavenCentral()
|
|
14
27
|
}
|
|
15
28
|
dependencies {
|
|
16
|
-
classpath("com.android.tools.build:gradle:
|
|
29
|
+
classpath("com.android.tools.build:gradle:7.0.4")
|
|
30
|
+
classpath("com.facebook.react:react-native-gradle-plugin")
|
|
31
|
+
classpath("de.undercouch:gradle-download-task:4.1.2")
|
|
17
32
|
// NOTE: Do not place your application dependencies here; they belong
|
|
18
33
|
// in the individual module build.gradle files
|
|
19
34
|
}
|
|
@@ -39,13 +54,11 @@ allprojects {
|
|
|
39
54
|
google()
|
|
40
55
|
maven { url 'https://www.jitpack.io' }
|
|
41
56
|
|
|
42
|
-
|
|
43
57
|
<% if (e2eTestRunner === 'detox') { %>
|
|
44
58
|
maven {
|
|
45
|
-
// All of
|
|
46
|
-
url
|
|
59
|
+
// All of Detox' artifacts are provided via the npm module
|
|
60
|
+
url "$rootDir/../node_modules/detox/Detox-android"
|
|
47
61
|
}
|
|
48
62
|
<% } %>
|
|
49
|
-
|
|
50
63
|
}
|
|
51
64
|
}
|
|
Binary file
|
package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.properties
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
distributionBase=GRADLE_USER_HOME
|
|
2
2
|
distributionPath=wrapper/dists
|
|
3
|
-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.
|
|
3
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
|
|
4
4
|
zipStoreBase=GRADLE_USER_HOME
|
|
5
|
-
zipStorePath=wrapper/dists
|
|
5
|
+
zipStorePath=wrapper/dists
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
# Specifies the JVM arguments used for the daemon process.
|
|
11
11
|
# The setting is particularly useful for tweaking memory settings.
|
|
12
|
-
# Default value: -
|
|
13
|
-
|
|
12
|
+
# Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
|
|
13
|
+
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
|
|
14
14
|
|
|
15
15
|
# When configured, Gradle will run in incubating parallel mode.
|
|
16
16
|
# This option should only be used with decoupled projects. More details, visit
|
|
@@ -25,11 +25,16 @@ android.useAndroidX=true
|
|
|
25
25
|
android.enableJetifier=true
|
|
26
26
|
|
|
27
27
|
# Version of flipper SDK to use with React Native
|
|
28
|
-
FLIPPER_VERSION=0.
|
|
29
|
-
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
#
|
|
28
|
+
FLIPPER_VERSION=0.125.0
|
|
29
|
+
|
|
30
|
+
# Use this property to specify which architecture you want to build.
|
|
31
|
+
# You can also override it from the CLI using
|
|
32
|
+
# ./gradlew <task> -PreactNativeArchitectures=x86_64
|
|
33
|
+
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
|
|
34
|
+
|
|
35
|
+
# Use this property to enable support to the new architecture.
|
|
36
|
+
# This will allow you to use TurboModules and the Fabric render in
|
|
37
|
+
# your application. You should enable this flag either if you want
|
|
38
|
+
# to write custom TurboModules/Fabric components OR use libraries that
|
|
39
|
+
# are providing them.
|
|
40
|
+
newArchEnabled=false
|