@domir/react-native-measure-text 0.1.0 → 0.1.2

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.
Files changed (115) hide show
  1. package/android/src/main/java/expo/modules.measuretext/ReactNativeMeasureTextModule.kt +2 -5
  2. package/build/ReactNativeMeasureTextModule.web.d.ts +1 -1
  3. package/build/ReactNativeMeasureTextModule.web.js +1 -1
  4. package/build/ReactNativeMeasureTextModule.web.js.map +1 -1
  5. package/package.json +9 -1
  6. package/.eslintrc.js +0 -5
  7. package/example/.expo-shared/assets.json +0 -4
  8. package/example/App.tsx +0 -45
  9. package/example/android/app/BUCK +0 -55
  10. package/example/android/app/build.gradle +0 -376
  11. package/example/android/app/build_defs.bzl +0 -19
  12. package/example/android/app/debug.keystore +0 -0
  13. package/example/android/app/proguard-rules.pro +0 -14
  14. package/example/android/app/src/debug/AndroidManifest.xml +0 -7
  15. package/example/android/app/src/debug/java/expo/modules/measuretext/example/ReactNativeFlipper.java +0 -69
  16. package/example/android/app/src/main/AndroidManifest.xml +0 -34
  17. package/example/android/app/src/main/java/expo/modules/measuretext/example/MainActivity.java +0 -83
  18. package/example/android/app/src/main/java/expo/modules/measuretext/example/MainApplication.java +0 -106
  19. package/example/android/app/src/main/java/expo/modules/measuretext/example/newarchitecture/MainApplicationReactNativeHost.java +0 -117
  20. package/example/android/app/src/main/java/expo/modules/measuretext/example/newarchitecture/components/MainComponentsRegistry.java +0 -36
  21. package/example/android/app/src/main/java/expo/modules/measuretext/example/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java +0 -48
  22. package/example/android/app/src/main/jni/Android.mk +0 -48
  23. package/example/android/app/src/main/jni/MainApplicationModuleProvider.cpp +0 -24
  24. package/example/android/app/src/main/jni/MainApplicationModuleProvider.h +0 -16
  25. package/example/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp +0 -45
  26. package/example/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h +0 -38
  27. package/example/android/app/src/main/jni/MainComponentsRegistry.cpp +0 -61
  28. package/example/android/app/src/main/jni/MainComponentsRegistry.h +0 -32
  29. package/example/android/app/src/main/jni/OnLoad.cpp +0 -11
  30. package/example/android/app/src/main/res/drawable/rn_edit_text_material.xml +0 -36
  31. package/example/android/app/src/main/res/drawable/splashscreen.xml +0 -3
  32. package/example/android/app/src/main/res/drawable-hdpi/splashscreen_image.png +0 -0
  33. package/example/android/app/src/main/res/drawable-mdpi/splashscreen_image.png +0 -0
  34. package/example/android/app/src/main/res/drawable-xhdpi/splashscreen_image.png +0 -0
  35. package/example/android/app/src/main/res/drawable-xxhdpi/splashscreen_image.png +0 -0
  36. package/example/android/app/src/main/res/drawable-xxxhdpi/splashscreen_image.png +0 -0
  37. package/example/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +0 -5
  38. package/example/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +0 -5
  39. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  40. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png +0 -0
  41. package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  42. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  43. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png +0 -0
  44. package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  45. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  46. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png +0 -0
  47. package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  48. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  49. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png +0 -0
  50. package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  51. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  52. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png +0 -0
  53. package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  54. package/example/android/app/src/main/res/values/colors.xml +0 -6
  55. package/example/android/app/src/main/res/values/strings.xml +0 -5
  56. package/example/android/app/src/main/res/values/styles.xml +0 -17
  57. package/example/android/app/src/main/res/values-night/colors.xml +0 -1
  58. package/example/android/build.gradle +0 -59
  59. package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  60. package/example/android/gradle/wrapper/gradle-wrapper.properties +0 -5
  61. package/example/android/gradle.properties +0 -53
  62. package/example/android/gradlew +0 -234
  63. package/example/android/gradlew.bat +0 -89
  64. package/example/android/settings.gradle +0 -17
  65. package/example/app.json +0 -35
  66. package/example/assets/adaptive-icon.png +0 -0
  67. package/example/assets/favicon.png +0 -0
  68. package/example/assets/icon.png +0 -0
  69. package/example/assets/splash.png +0 -0
  70. package/example/babel.config.js +0 -19
  71. package/example/index.js +0 -8
  72. package/example/ios/.xcode.env +0 -11
  73. package/example/ios/Podfile +0 -59
  74. package/example/ios/Podfile.lock +0 -482
  75. package/example/ios/Podfile.properties.json +0 -3
  76. package/example/ios/reactnativemeasuretextexample/AppDelegate.h +0 -9
  77. package/example/ios/reactnativemeasuretextexample/AppDelegate.mm +0 -166
  78. package/example/ios/reactnativemeasuretextexample/Images.xcassets/AppIcon.appiconset/App-Icon-20x20@1x.png +0 -0
  79. package/example/ios/reactnativemeasuretextexample/Images.xcassets/AppIcon.appiconset/App-Icon-20x20@2x.png +0 -0
  80. package/example/ios/reactnativemeasuretextexample/Images.xcassets/AppIcon.appiconset/App-Icon-20x20@3x.png +0 -0
  81. package/example/ios/reactnativemeasuretextexample/Images.xcassets/AppIcon.appiconset/App-Icon-29x29@1x.png +0 -0
  82. package/example/ios/reactnativemeasuretextexample/Images.xcassets/AppIcon.appiconset/App-Icon-29x29@2x.png +0 -0
  83. package/example/ios/reactnativemeasuretextexample/Images.xcassets/AppIcon.appiconset/App-Icon-29x29@3x.png +0 -0
  84. package/example/ios/reactnativemeasuretextexample/Images.xcassets/AppIcon.appiconset/App-Icon-40x40@1x.png +0 -0
  85. package/example/ios/reactnativemeasuretextexample/Images.xcassets/AppIcon.appiconset/App-Icon-40x40@2x.png +0 -0
  86. package/example/ios/reactnativemeasuretextexample/Images.xcassets/AppIcon.appiconset/App-Icon-40x40@3x.png +0 -0
  87. package/example/ios/reactnativemeasuretextexample/Images.xcassets/AppIcon.appiconset/App-Icon-60x60@2x.png +0 -0
  88. package/example/ios/reactnativemeasuretextexample/Images.xcassets/AppIcon.appiconset/App-Icon-60x60@3x.png +0 -0
  89. package/example/ios/reactnativemeasuretextexample/Images.xcassets/AppIcon.appiconset/App-Icon-76x76@1x.png +0 -0
  90. package/example/ios/reactnativemeasuretextexample/Images.xcassets/AppIcon.appiconset/App-Icon-76x76@2x.png +0 -0
  91. package/example/ios/reactnativemeasuretextexample/Images.xcassets/AppIcon.appiconset/App-Icon-83.5x83.5@2x.png +0 -0
  92. package/example/ios/reactnativemeasuretextexample/Images.xcassets/AppIcon.appiconset/Contents.json +0 -122
  93. package/example/ios/reactnativemeasuretextexample/Images.xcassets/AppIcon.appiconset/ItunesArtwork@2x.png +0 -0
  94. package/example/ios/reactnativemeasuretextexample/Images.xcassets/Contents.json +0 -6
  95. package/example/ios/reactnativemeasuretextexample/Images.xcassets/SplashScreen.imageset/Contents.json +0 -21
  96. package/example/ios/reactnativemeasuretextexample/Images.xcassets/SplashScreen.imageset/image.png +0 -0
  97. package/example/ios/reactnativemeasuretextexample/Images.xcassets/SplashScreenBackground.imageset/Contents.json +0 -21
  98. package/example/ios/reactnativemeasuretextexample/Images.xcassets/SplashScreenBackground.imageset/image.png +0 -0
  99. package/example/ios/reactnativemeasuretextexample/Info.plist +0 -76
  100. package/example/ios/reactnativemeasuretextexample/SplashScreen.storyboard +0 -51
  101. package/example/ios/reactnativemeasuretextexample/Supporting/Expo.plist +0 -16
  102. package/example/ios/reactnativemeasuretextexample/main.m +0 -10
  103. package/example/ios/reactnativemeasuretextexample/noop-file.swift +0 -4
  104. package/example/ios/reactnativemeasuretextexample/reactnativemeasuretextexample.entitlements +0 -8
  105. package/example/ios/reactnativemeasuretextexample.xcodeproj/project.pbxproj +0 -497
  106. package/example/ios/reactnativemeasuretextexample.xcodeproj/xcshareddata/xcschemes/reactnativemeasuretextexample.xcscheme +0 -88
  107. package/example/ios/reactnativemeasuretextexample.xcworkspace/contents.xcworkspacedata +0 -10
  108. package/example/ios/reactnativemeasuretextexample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  109. package/example/metro.config.js +0 -14
  110. package/example/package-lock.json +0 -21620
  111. package/example/package.json +0 -29
  112. package/example/tsconfig.json +0 -10
  113. package/example/webpack.config.js +0 -20
  114. package/example/yarn.lock +0 -6664
  115. package/tsconfig.json +0 -9
@@ -1,69 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * <p>This source code is licensed under the MIT license found in the LICENSE file in the root
5
- * directory of this source tree.
6
- */
7
- package expo.modules.measuretext.example;
8
-
9
- import android.content.Context;
10
- import com.facebook.flipper.android.AndroidFlipperClient;
11
- import com.facebook.flipper.android.utils.FlipperUtils;
12
- import com.facebook.flipper.core.FlipperClient;
13
- import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
14
- import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
15
- import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
16
- import com.facebook.flipper.plugins.inspector.DescriptorMapping;
17
- import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
18
- import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
19
- import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
20
- import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
21
- import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
22
- import com.facebook.react.ReactInstanceManager;
23
- import com.facebook.react.bridge.ReactContext;
24
- import com.facebook.react.modules.network.NetworkingModule;
25
- import okhttp3.OkHttpClient;
26
-
27
- public class ReactNativeFlipper {
28
- public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
29
- if (FlipperUtils.shouldEnableFlipper(context)) {
30
- final FlipperClient client = AndroidFlipperClient.getInstance(context);
31
- client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
32
- client.addPlugin(new ReactFlipperPlugin());
33
- client.addPlugin(new DatabasesFlipperPlugin(context));
34
- client.addPlugin(new SharedPreferencesFlipperPlugin(context));
35
- client.addPlugin(CrashReporterPlugin.getInstance());
36
- NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
37
- NetworkingModule.setCustomClientBuilder(
38
- new NetworkingModule.CustomClientBuilder() {
39
- @Override
40
- public void apply(OkHttpClient.Builder builder) {
41
- builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
42
- }
43
- });
44
- client.addPlugin(networkFlipperPlugin);
45
- client.start();
46
- // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
47
- // Hence we run if after all native modules have been initialized
48
- ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
49
- if (reactContext == null) {
50
- reactInstanceManager.addReactInstanceEventListener(
51
- new ReactInstanceManager.ReactInstanceEventListener() {
52
- @Override
53
- public void onReactContextInitialized(ReactContext reactContext) {
54
- reactInstanceManager.removeReactInstanceEventListener(this);
55
- reactContext.runOnNativeModulesQueueThread(
56
- new Runnable() {
57
- @Override
58
- public void run() {
59
- client.addPlugin(new FrescoFlipperPlugin());
60
- }
61
- });
62
- }
63
- });
64
- } else {
65
- client.addPlugin(new FrescoFlipperPlugin());
66
- }
67
- }
68
- }
69
- }
@@ -1,34 +0,0 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="expo.modules.measuretext.example">
2
- <uses-permission android:name="android.permission.INTERNET"/>
3
- <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
4
- <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
5
- <uses-permission android:name="android.permission.VIBRATE"/>
6
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
7
- <queries>
8
- <intent>
9
- <action android:name="android.intent.action.VIEW"/>
10
- <category android:name="android.intent.category.BROWSABLE"/>
11
- <data android:scheme="https"/>
12
- </intent>
13
- </queries>
14
- <application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true">
15
- <meta-data android:name="expo.modules.updates.ENABLED" android:value="true"/>
16
- <meta-data android:name="expo.modules.updates.EXPO_SDK_VERSION" android:value="46.0.0"/>
17
- <meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
18
- <meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
19
- <meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://exp.host/@domir/react-native-measure-text-example"/>
20
- <activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="portrait">
21
- <intent-filter>
22
- <action android:name="android.intent.action.MAIN"/>
23
- <category android:name="android.intent.category.LAUNCHER"/>
24
- </intent-filter>
25
- <intent-filter>
26
- <action android:name="android.intent.action.VIEW"/>
27
- <category android:name="android.intent.category.DEFAULT"/>
28
- <category android:name="android.intent.category.BROWSABLE"/>
29
- <data android:scheme="expo.modules.measuretext.example"/>
30
- </intent-filter>
31
- </activity>
32
- <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false"/>
33
- </application>
34
- </manifest>
@@ -1,83 +0,0 @@
1
- package expo.modules.measuretext.example;
2
-
3
- import android.os.Build;
4
- import android.os.Bundle;
5
-
6
- import com.facebook.react.ReactActivity;
7
- import com.facebook.react.ReactActivityDelegate;
8
- import com.facebook.react.ReactRootView;
9
-
10
- import expo.modules.ReactActivityDelegateWrapper;
11
-
12
- public class MainActivity extends ReactActivity {
13
- @Override
14
- protected void onCreate(Bundle savedInstanceState) {
15
- // Set the theme to AppTheme BEFORE onCreate to support
16
- // coloring the background, status bar, and navigation bar.
17
- // This is required for expo-splash-screen.
18
- setTheme(R.style.AppTheme);
19
- super.onCreate(null);
20
- }
21
-
22
- /**
23
- * Returns the name of the main component registered from JavaScript.
24
- * This is used to schedule rendering of the component.
25
- */
26
- @Override
27
- protected String getMainComponentName() {
28
- return "main";
29
- }
30
-
31
- /**
32
- * Returns the instance of the {@link ReactActivityDelegate}. There the RootView is created and
33
- * you can specify the renderer you wish to use - the new renderer (Fabric) or the old renderer
34
- * (Paper).
35
- */
36
- @Override
37
- protected ReactActivityDelegate createReactActivityDelegate() {
38
- return new ReactActivityDelegateWrapper(this, BuildConfig.IS_NEW_ARCHITECTURE_ENABLED,
39
- new MainActivityDelegate(this, getMainComponentName())
40
- );
41
- }
42
-
43
- /**
44
- * Align the back button behavior with Android S
45
- * where moving root activities to background instead of finishing activities.
46
- * @see <a href="https://developer.android.com/reference/android/app/Activity#onBackPressed()">onBackPressed</a>
47
- */
48
- @Override
49
- public void invokeDefaultOnBackPressed() {
50
- if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
51
- if (!moveTaskToBack(false)) {
52
- // For non-root activities, use the default implementation to finish them.
53
- super.invokeDefaultOnBackPressed();
54
- }
55
- return;
56
- }
57
-
58
- // Use the default back button implementation on Android S
59
- // because it's doing more than {@link Activity#moveTaskToBack} in fact.
60
- super.invokeDefaultOnBackPressed();
61
- }
62
-
63
- public static class MainActivityDelegate extends ReactActivityDelegate {
64
- public MainActivityDelegate(ReactActivity activity, String mainComponentName) {
65
- super(activity, mainComponentName);
66
- }
67
-
68
- @Override
69
- protected ReactRootView createRootView() {
70
- ReactRootView reactRootView = new ReactRootView(getContext());
71
- // If you opted-in for the New Architecture, we enable the Fabric Renderer.
72
- reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
73
- return reactRootView;
74
- }
75
-
76
- @Override
77
- protected boolean isConcurrentRootEnabled() {
78
- // If you opted-in for the New Architecture, we enable Concurrent Root (i.e. React 18).
79
- // More on this on https://reactjs.org/blog/2022/03/29/react-v18.html
80
- return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
81
- }
82
- }
83
- }
@@ -1,106 +0,0 @@
1
- package expo.modules.measuretext.example;
2
-
3
- import android.app.Application;
4
- import android.content.Context;
5
- import android.content.res.Configuration;
6
- import androidx.annotation.NonNull;
7
-
8
- import com.facebook.react.PackageList;
9
- import com.facebook.react.ReactApplication;
10
- import com.facebook.react.ReactInstanceManager;
11
- import com.facebook.react.ReactNativeHost;
12
- import com.facebook.react.ReactPackage;
13
- import com.facebook.react.config.ReactFeatureFlags;
14
- import com.facebook.soloader.SoLoader;
15
- import expo.modules.measuretext.example.newarchitecture.MainApplicationReactNativeHost;
16
-
17
- import expo.modules.ApplicationLifecycleDispatcher;
18
- import expo.modules.ReactNativeHostWrapper;
19
-
20
- import java.lang.reflect.InvocationTargetException;
21
- import java.util.List;
22
-
23
- public class MainApplication extends Application implements ReactApplication {
24
- private final ReactNativeHost mReactNativeHost = new ReactNativeHostWrapper(
25
- this,
26
- new ReactNativeHost(this) {
27
- @Override
28
- public boolean getUseDeveloperSupport() {
29
- return BuildConfig.DEBUG;
30
- }
31
-
32
- @Override
33
- protected List<ReactPackage> getPackages() {
34
- @SuppressWarnings("UnnecessaryLocalVariable")
35
- List<ReactPackage> packages = new PackageList(this).getPackages();
36
- // Packages that cannot be autolinked yet can be added manually here, for example:
37
- // packages.add(new MyReactNativePackage());
38
- return packages;
39
- }
40
-
41
- @Override
42
- protected String getJSMainModuleName() {
43
- return "index";
44
- }
45
- });
46
-
47
- private final ReactNativeHost mNewArchitectureNativeHost =
48
- new ReactNativeHostWrapper(this, new MainApplicationReactNativeHost(this));
49
-
50
- @Override
51
- public ReactNativeHost getReactNativeHost() {
52
- if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
53
- return mNewArchitectureNativeHost;
54
- } else {
55
- return mReactNativeHost;
56
- }
57
- }
58
-
59
- @Override
60
- public void onCreate() {
61
- super.onCreate();
62
- // If you opted-in for the New Architecture, we enable the TurboModule system
63
- ReactFeatureFlags.useTurboModules = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
64
- SoLoader.init(this, /* native exopackage */ false);
65
-
66
- initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
67
- ApplicationLifecycleDispatcher.onApplicationCreate(this);
68
- }
69
-
70
- @Override
71
- public void onConfigurationChanged(@NonNull Configuration newConfig) {
72
- super.onConfigurationChanged(newConfig);
73
- ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig);
74
- }
75
-
76
- /**
77
- * Loads Flipper in React Native templates. Call this in the onCreate method with something like
78
- * initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
79
- *
80
- * @param context
81
- * @param reactInstanceManager
82
- */
83
- private static void initializeFlipper(
84
- Context context, ReactInstanceManager reactInstanceManager) {
85
- if (BuildConfig.DEBUG) {
86
- try {
87
- /*
88
- We use reflection here to pick up the class that initializes Flipper,
89
- since Flipper library is not available in release mode
90
- */
91
- Class<?> aClass = Class.forName("expo.modules.measuretext.example.ReactNativeFlipper");
92
- aClass
93
- .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
94
- .invoke(null, context, reactInstanceManager);
95
- } catch (ClassNotFoundException e) {
96
- e.printStackTrace();
97
- } catch (NoSuchMethodException e) {
98
- e.printStackTrace();
99
- } catch (IllegalAccessException e) {
100
- e.printStackTrace();
101
- } catch (InvocationTargetException e) {
102
- e.printStackTrace();
103
- }
104
- }
105
- }
106
- }
@@ -1,117 +0,0 @@
1
- package expo.modules.measuretext.example.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.fabric.ReactNativeConfig;
22
- import com.facebook.react.uimanager.ViewManagerRegistry;
23
- import expo.modules.measuretext.example.BuildConfig;
24
- import expo.modules.measuretext.example.newarchitecture.components.MainComponentsRegistry;
25
- import expo.modules.measuretext.example.newarchitecture.modules.MainApplicationTurboModuleManagerDelegate;
26
- import java.util.ArrayList;
27
- import java.util.List;
28
-
29
- /**
30
- * A {@link ReactNativeHost} that helps you load everything needed for the New Architecture, both
31
- * TurboModule delegates and the Fabric Renderer.
32
- *
33
- * <p>Please note that this class is used ONLY if you opt-in for the New Architecture (see the
34
- * `newArchEnabled` property). Is ignored otherwise.
35
- */
36
- public class MainApplicationReactNativeHost extends ReactNativeHost {
37
- public MainApplicationReactNativeHost(Application application) {
38
- super(application);
39
- }
40
-
41
- @Override
42
- public boolean getUseDeveloperSupport() {
43
- return BuildConfig.DEBUG;
44
- }
45
-
46
- @Override
47
- protected List<ReactPackage> getPackages() {
48
- List<ReactPackage> packages = new PackageList(this).getPackages();
49
- // Packages that cannot be autolinked yet can be added manually here, for example:
50
- // packages.add(new MyReactNativePackage());
51
- // TurboModules must also be loaded here providing a valid TurboReactPackage implementation:
52
- // packages.add(new TurboReactPackage() { ... });
53
- // If you have custom Fabric Components, their ViewManagers should also be loaded here
54
- // inside a ReactPackage.
55
- return packages;
56
- }
57
-
58
- @Override
59
- protected String getJSMainModuleName() {
60
- return "index";
61
- }
62
-
63
- @NonNull
64
- @Override
65
- protected ReactPackageTurboModuleManagerDelegate.Builder
66
- getReactPackageTurboModuleManagerDelegateBuilder() {
67
- // Here we provide the ReactPackageTurboModuleManagerDelegate Builder. This is necessary
68
- // for the new architecture and to use TurboModules correctly.
69
- return new MainApplicationTurboModuleManagerDelegate.Builder();
70
- }
71
-
72
- @Override
73
- protected JSIModulePackage getJSIModulePackage() {
74
- return new JSIModulePackage() {
75
- @Override
76
- public List<JSIModuleSpec> getJSIModules(
77
- final ReactApplicationContext reactApplicationContext,
78
- final JavaScriptContextHolder jsContext) {
79
- final List<JSIModuleSpec> specs = new ArrayList<>();
80
-
81
- // Here we provide a new JSIModuleSpec that will be responsible of providing the
82
- // custom Fabric Components.
83
- specs.add(
84
- new JSIModuleSpec() {
85
- @Override
86
- public JSIModuleType getJSIModuleType() {
87
- return JSIModuleType.UIManager;
88
- }
89
-
90
- @Override
91
- public JSIModuleProvider<UIManager> getJSIModuleProvider() {
92
- final ComponentFactory componentFactory = new ComponentFactory();
93
- CoreComponentsRegistry.register(componentFactory);
94
-
95
- // Here we register a Components Registry.
96
- // The one that is generated with the template contains no components
97
- // and just provides you the one from React Native core.
98
- MainComponentsRegistry.register(componentFactory);
99
-
100
- final ReactInstanceManager reactInstanceManager = getReactInstanceManager();
101
-
102
- ViewManagerRegistry viewManagerRegistry =
103
- new ViewManagerRegistry(
104
- reactInstanceManager.getOrCreateViewManagers(reactApplicationContext));
105
-
106
- return new FabricJSIModuleProvider(
107
- reactApplicationContext,
108
- componentFactory,
109
- ReactNativeConfig.DEFAULT_CONFIG,
110
- viewManagerRegistry);
111
- }
112
- });
113
- return specs;
114
- }
115
- };
116
- }
117
- }
@@ -1,36 +0,0 @@
1
- package expo.modules.measuretext.example.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
- }
@@ -1,48 +0,0 @@
1
- package expo.modules.measuretext.example.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("reactnativemeasuretextexample_appmodules");
45
- sIsSoLibraryLoaded = true;
46
- }
47
- }
48
- }
@@ -1,48 +0,0 @@
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 := reactnativemeasuretextexample_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_runtime \
32
- libglog \
33
- libjsi \
34
- libreact_codegen_rncore \
35
- libreact_debug \
36
- libreact_nativemodule_core \
37
- libreact_render_componentregistry \
38
- libreact_render_core \
39
- libreact_render_debug \
40
- libreact_render_graphics \
41
- librrc_view \
42
- libruntimeexecutor \
43
- libturbomodulejsijni \
44
- libyoga
45
-
46
- LOCAL_CFLAGS := -DLOG_TAG=\"ReactNative\" -fexceptions -frtti -std=c++17 -Wall
47
-
48
- include $(BUILD_SHARED_LIBRARY)
@@ -1,24 +0,0 @@
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 &params) {
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
@@ -1,16 +0,0 @@
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 &params);
14
-
15
- } // namespace react
16
- } // namespace facebook
@@ -1,45 +0,0 @@
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 &params) {
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
@@ -1,38 +0,0 @@
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
- "Lexpo/modules/measuretext/example/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 &params) 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