react-native-macos 0.0.0-a45ffbd53 → 0.0.0-a818b5ac1

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 (161) hide show
  1. package/Libraries/AddressSanitizerCrash/RCTAddressSanitizerCrash.js +25 -0
  2. package/Libraries/Animated/NativeAnimatedHelper.js +1 -1
  3. package/Libraries/Animated/nodes/AnimatedValue.js +0 -1
  4. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +22 -12
  5. package/Libraries/Components/Button.js +1 -1
  6. package/Libraries/Components/CheckBox/CheckBox.macos.js +8 -4
  7. package/Libraries/Components/DatePicker/DatePickerIOS.ios.js +3 -6
  8. package/Libraries/Components/Keyboard/Keyboard.js +2 -2
  9. package/Libraries/Components/Touchable/TouchableBounce.js +11 -22
  10. package/Libraries/Components/Touchable/TouchableHighlight.js +19 -30
  11. package/Libraries/Components/Touchable/TouchableOpacity.js +14 -29
  12. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +8 -18
  13. package/Libraries/Components/View/ReactNativeViewAttributes.js +8 -7
  14. package/Libraries/Components/View/ReactNativeViewViewConfigMacOS.js +1 -2
  15. package/Libraries/Components/View/View.js +8 -10
  16. package/Libraries/Components/View/ViewAccessibility.js +0 -1
  17. package/Libraries/Components/View/ViewPropTypes.js +1 -7
  18. package/Libraries/Core/ExceptionsManager.js +3 -1
  19. package/Libraries/Core/ReactNativeVersion.js +5 -1
  20. package/Libraries/Core/setUpBatchedBridge.js +1 -1
  21. package/Libraries/Core/setUpGlobals.js +2 -0
  22. package/Libraries/Core/setUpTimers.js +2 -2
  23. package/Libraries/Image/Image.ios.js +6 -0
  24. package/Libraries/Image/RCTImageView.mm +2 -8
  25. package/Libraries/LogBox/Data/LogBoxData.js +18 -18
  26. package/Libraries/Pressability/Pressability.js +1 -0
  27. package/Libraries/Pressability/PressabilityPerformanceEventEmitter.js +1 -0
  28. package/Libraries/StyleSheet/PlatformColorValueTypes.macos.js +16 -1
  29. package/Libraries/StyleSheet/PlatformColorValueTypesMacOS.js +2 -0
  30. package/Libraries/StyleSheet/PlatformColorValueTypesMacOS.macos.js +8 -1
  31. package/Libraries/Text/RawText/RCTRawTextShadowView.m +2 -0
  32. package/Libraries/Text/Text/RCTTextView.m +8 -4
  33. package/Libraries/Text/TextInput/Multiline/RCTUITextView.m +10 -8
  34. package/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h +2 -0
  35. package/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m +15 -3
  36. package/Libraries/Text/TextInput/RCTBaseTextInputView.m +10 -1
  37. package/Libraries/Text/TextProps.js +1 -7
  38. package/Libraries/TurboModule/TurboModuleRegistry.js +1 -1
  39. package/Libraries/Types/RootTagTypes.js~merged +23 -0
  40. package/Libraries/Utilities/HMRClient.js +1 -1
  41. package/Libraries/WebSocket/RCTSRWebSocket.m +23 -0
  42. package/README.md +19 -43
  43. package/React/Base/RCTBridgeModule.h +1 -1
  44. package/React/Base/RCTConvert.m +23 -6
  45. package/React/Base/RCTImageSource.m +2 -0
  46. package/React/Base/RCTJSStackFrame.m +2 -0
  47. package/React/Base/RCTJavaScriptLoader.mm +2 -0
  48. package/React/Base/RCTKeyCommands.m +2 -0
  49. package/React/Base/RCTModuleData.mm +2 -0
  50. package/React/Base/RCTModuleMethod.mm +2 -0
  51. package/React/Base/RCTTouchEvent.m +2 -0
  52. package/React/Base/RCTVersion.m +5 -1
  53. package/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.mm +1 -1
  54. package/React/Base/macOS/RCTPlatformDisplayLink.m +4 -1
  55. package/React/CoreModules/RCTActionSheetManager.mm +4 -0
  56. package/React/CoreModules/RCTAddressSanitizerCrashManager.h +12 -0
  57. package/React/CoreModules/RCTAddressSanitizerCrashManager.mm +18 -0
  58. package/React/CoreModules/RCTAlertController.m +8 -4
  59. package/React/CoreModules/RCTAppearance.mm +22 -23
  60. package/React/CoreModules/RCTDevLoadingView.mm +14 -9
  61. package/React/CxxModule/RCTCxxMethod.mm +2 -0
  62. package/React/DevSupport/RCTInspectorDevServerHelper.mm +12 -0
  63. package/React/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec-generated.mm +2126 -0
  64. package/React/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h +2682 -0
  65. package/React/FBReactNativeSpec/FBReactNativeSpec.podspec +12 -2
  66. package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +9 -0
  67. package/React/Modules/RCTEventEmitter.h +2 -2
  68. package/React/Modules/RCTLayoutAnimation.m +2 -0
  69. package/React/Modules/RCTLayoutAnimationGroup.m +2 -0
  70. package/React/Views/RCTFont.mm +58 -47
  71. package/React/Views/RCTShadowView.m +3 -1
  72. package/React/Views/RCTSwitch.h +1 -1
  73. package/React/Views/RCTSwitch.m +0 -15
  74. package/React/Views/RCTView.h +5 -2
  75. package/React/Views/RCTView.m +22 -23
  76. package/React/Views/RCTViewManager.m +12 -17
  77. package/React/Views/SafeAreaView/RCTSafeAreaView.m +2 -0
  78. package/React/Views/ScrollView/MacOS/RCTScrollContentLocalData.h +2 -2
  79. package/React/Views/ScrollView/MacOS/RCTScrollContentLocalData.m +4 -4
  80. package/React/Views/ScrollView/RCTScrollContentView.m +10 -24
  81. package/React/Views/ScrollView/RCTScrollView.m +1 -5
  82. package/React-Core.podspec +0 -11
  83. package/ReactAndroid/build.gradle +9 -3
  84. package/ReactAndroid/gradle.properties +1 -1
  85. package/ReactAndroid/src/androidTest/java/com/facebook/react/tests/BUCK +0 -1
  86. package/ReactAndroid/src/androidTest/js/TestBundle.js +0 -7
  87. package/ReactAndroid/src/main/java/com/facebook/react/ReactActivity.java +7 -0
  88. package/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java +7 -0
  89. package/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +47 -15
  90. package/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java +12 -0
  91. package/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java +6 -0
  92. package/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactCxxErrorHandler.java +39 -0
  93. package/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +6 -0
  94. package/ReactAndroid/src/main/java/com/facebook/react/devsupport/interfaces/BundleLoadCallback.java +3 -1
  95. package/ReactAndroid/src/main/java/com/facebook/react/modules/appearance/AppearanceModule.java +10 -1
  96. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +5 -1
  97. package/ReactAndroid/src/main/java/com/facebook/react/shell/BUCK +0 -1
  98. package/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.java +0 -5
  99. package/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java +0 -4
  100. package/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java +16 -0
  101. package/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java +20 -1
  102. package/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java +25 -6
  103. package/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java +25 -5
  104. package/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditTextInputConnectionWrapper.java +3 -0
  105. package/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java +0 -8
  106. package/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java +8 -8
  107. package/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp +2 -0
  108. package/ReactAndroid/src/main/jni/react/jni/JReactCxxErrorHandler.cpp +18 -0
  109. package/ReactAndroid/src/main/jni/react/jni/JReactCxxErrorHandler.h +25 -0
  110. package/ReactAndroid/src/main/jni/third-party/libevent/event-config.h +339 -339
  111. package/ReactAndroid/src/main/third-party/android/androidx/BUCK +6 -6
  112. package/ReactCommon/cxxreact/ReactNativeVersion.h +5 -1
  113. package/ReactCommon/hermes/inspector/tools/msggen/package.json +1 -1
  114. package/ReactCommon/hermes/inspector/tools/msggen/yarn.lock +1225 -1481
  115. package/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +20 -28
  116. package/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp +7 -3
  117. package/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h +12 -2
  118. package/ReactCommon/react/renderer/attributedstring/conversions.h +58 -3
  119. package/ReactCommon/react/renderer/attributedstring/primitives.h +18 -1
  120. package/ReactCommon/react/renderer/components/view/ViewShadowNode.h +1 -1
  121. package/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h +4 -0
  122. package/ReactCommon/react/renderer/core/RawPropsKey.cpp +10 -2
  123. package/ReactCommon/react/renderer/scheduler/SurfaceHandler.h +4 -4
  124. package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.h +2 -0
  125. package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm +19 -0
  126. package/ReactCommon/react/test_utils/BUCK +3 -0
  127. package/ReactCommon/react/test_utils/MockSurfaceHandler.h +25 -0
  128. package/ReactCommon/react/utils/ContextContainer.h +0 -27
  129. package/flow/global.js +45 -0
  130. package/index.js +15 -10
  131. package/jest/preprocessor.js +7 -75
  132. package/local-cli/cli.js +0 -0
  133. package/local-cli/generator-macos/templates/macos/Podfile +2 -7
  134. package/package.json +28 -25
  135. package/scripts/generate-specs.sh +62 -29
  136. package/scripts/react-native-xcode.sh +1 -1
  137. package/scripts/react_native_pods.rb +30 -30
  138. package/template/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  139. package/template/ios/HelloWorld.xcodeproj/project.pbxproj +2 -0
  140. package/template/package.json +4 -2
  141. package/third-party-podspecs/RCT-Folly.podspec +1 -1
  142. package/CHANGELOG.json +0 -500
  143. package/CHANGELOG.md +0 -240
  144. package/Libraries/.npmignore +0 -1
  145. package/Libraries/Components/DatePickerAndroid/DatePickerAndroid.android.js +0 -87
  146. package/Libraries/Components/DatePickerAndroid/DatePickerAndroid.ios.js +0 -30
  147. package/Libraries/Components/DatePickerAndroid/DatePickerAndroidTypes.js +0 -30
  148. package/React/Base/macOS/RCTDynamicColor.h +0 -28
  149. package/React/Base/macOS/RCTDynamicColor.m +0 -219
  150. package/ReactAndroid/.npmignore +0 -5
  151. package/ReactAndroid/src/androidTest/java/com/facebook/react/tests/DatePickerDialogTestCase.java +0 -172
  152. package/ReactAndroid/src/androidTest/js/DatePickerDialogTestModule.js +0 -45
  153. package/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/BUCK +0 -27
  154. package/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerDialogFragment.java +0 -137
  155. package/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerDialogModule.java +0 -153
  156. package/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerMode.java +0 -15
  157. package/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DismissableDatePickerDialog.java +0 -117
  158. package/ReactAndroid/src/main/jni/first-party/fbjni/.gitignore +0 -2
  159. package/ReactCommon/hermes/inspector/tools/msggen/.gitignore +0 -3
  160. package/scripts/fixmacscripts.sh +0 -9
  161. package/scripts/postInstall.js +0 -6
@@ -56,7 +56,6 @@ task downloadBoost(dependsOn: createNativeDepsDirectories, type: Download) {
56
56
 
57
57
  task prepareBoost(dependsOn: boostPath ? [] : [downloadBoost], type: Copy) {
58
58
  from(boostPath ?: tarTree(resources.gzip(downloadBoost.dest)))
59
- from("src/main/jni/third-party/boost/Android.mk")
60
59
  from("src/main/jni/third-party/boost")
61
60
  include("Android.mk", "boost_${BOOST_VERSION}/boost/**/*.hpp", "boost/boost/**/*.hpp", "asm/**/*.S")
62
61
  includeEmptyDirs = false
@@ -171,6 +170,7 @@ task downloadGlog(dependsOn: createNativeDepsDirectories, type: Download) {
171
170
  // Prepare glog sources to be compiled, this task will perform steps that normally should've been
172
171
  // executed by automake. This way we can avoid dependencies on make/automake
173
172
  task prepareGlog(dependsOn: dependenciesPath ? [] : [downloadGlog], type: Copy) {
173
+ duplicatesStrategy("warn")
174
174
  from(dependenciesPath ?: tarTree(downloadGlog.dest))
175
175
  from("src/main/jni/third-party/glog/")
176
176
  include("glog-${GLOG_VERSION}/src/**/*", "Android.mk", "config.h")
@@ -362,7 +362,8 @@ def buildReactNdkLib = tasks.register("buildReactNdkLib", Exec) {
362
362
  inputs.dir("src/main/java/com/facebook/react/turbomodule/core/jni")
363
363
  inputs.dir("src/main/java/com/facebook/react/modules/blob")
364
364
  outputs.dir("$buildDir/react-ndk/all")
365
- commandLine(getNdkBuildFullPath(),
365
+ def commandLineArgs = [
366
+ getNdkBuildFullPath(),
366
367
  "APP_ABI=${reactNativeArchitectures()}",
367
368
  "NDK_DEBUG=" + (nativeBuildType.equalsIgnoreCase("debug") ? "1" : "0"),
368
369
  "NDK_PROJECT_PATH=null",
@@ -375,7 +376,12 @@ def buildReactNdkLib = tasks.register("buildReactNdkLib", Exec) {
375
376
  "REACT_SRC_DIR=$projectDir/src/main/java/com/facebook/react",
376
377
  "-C", file("src/main/jni/react/jni").absolutePath,
377
378
  "--jobs", project.findProperty("jobs") ?: Runtime.runtime.availableProcessors()
378
- )
379
+ ]
380
+ if (Os.isFamily(Os.FAMILY_MAC)) {
381
+ // This flag will suppress "fcntl(): Bad file descriptor" warnings on local builds.
382
+ commandLineArgs.add("--output-sync=none")
383
+ }
384
+ commandLine(commandLineArgs)
379
385
  }
380
386
 
381
387
  def cleanReactNdkLib = tasks.register("cleanReactNdkLib", Exec) {
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.0.0-a45ffbd53
1
+ VERSION_NAME=0.0.0-a818b5ac1
2
2
  GROUP=com.facebook.react
3
3
 
4
4
  POM_NAME=ReactNative
@@ -25,7 +25,6 @@ rn_android_library(
25
25
  react_native_target("java/com/facebook/react/module/annotations:annotations"),
26
26
  react_native_target("java/com/facebook/react/modules/appstate:appstate"),
27
27
  react_native_target("java/com/facebook/react/modules/core:core"),
28
- react_native_target("java/com/facebook/react/modules/datepicker:datepicker"),
29
28
  react_native_target("java/com/facebook/react/modules/deviceinfo:deviceinfo"),
30
29
  react_native_target("java/com/facebook/react/modules/share:share"),
31
30
  react_native_target("java/com/facebook/react/modules/systeminfo:systeminfo"),
@@ -20,9 +20,7 @@ require('./TestJSLocaleModule');
20
20
  require('./TestJSToJavaParametersModule');
21
21
  require('./TestJavaToJSReturnValuesModule');
22
22
  require('./UIManagerTestModule');
23
-
24
23
  require('./CatalystRootViewTestModule');
25
- require('./DatePickerDialogTestModule');
26
24
  require('./MeasureLayoutTestModule');
27
25
  require('./ScrollViewTestModule');
28
26
  require('./ShareTestModule');
@@ -43,11 +41,6 @@ const apps = [
43
41
  component: () =>
44
42
  require('./CatalystRootViewTestModule').CatalystRootViewTestApp,
45
43
  },
46
- {
47
- appKey: 'DatePickerDialogTestApp',
48
- component: () =>
49
- require('./DatePickerDialogTestModule').DatePickerDialogTestApp,
50
- },
51
44
  {
52
45
  appKey: 'JSResponderTestApp',
53
46
  component: () => require('./JSResponderTestApp'),
@@ -8,6 +8,7 @@
8
8
  package com.facebook.react;
9
9
 
10
10
  import android.content.Intent;
11
+ import android.content.res.Configuration;
11
12
  import android.os.Bundle;
12
13
  import android.view.KeyEvent;
13
14
  import androidx.annotation.Nullable;
@@ -121,6 +122,12 @@ public abstract class ReactActivity extends AppCompatActivity
121
122
  mDelegate.onWindowFocusChanged(hasFocus);
122
123
  }
123
124
 
125
+ @Override
126
+ public void onConfigurationChanged(Configuration newConfig) {
127
+ super.onConfigurationChanged(newConfig);
128
+ mDelegate.onConfigurationChanged(newConfig);
129
+ }
130
+
124
131
  protected final ReactNativeHost getReactNativeHost() {
125
132
  return mDelegate.getReactNativeHost();
126
133
  }
@@ -11,6 +11,7 @@ import android.annotation.TargetApi;
11
11
  import android.app.Activity;
12
12
  import android.content.Context;
13
13
  import android.content.Intent;
14
+ import android.content.res.Configuration;
14
15
  import android.os.Build;
15
16
  import android.os.Bundle;
16
17
  import android.view.KeyEvent;
@@ -154,6 +155,12 @@ public class ReactActivityDelegate {
154
155
  }
155
156
  }
156
157
 
158
+ public void onConfigurationChanged(Configuration newConfig) {
159
+ if (getReactNativeHost().hasInstance()) {
160
+ getReactInstanceManager().onConfigurationChanged(getContext(), newConfig);
161
+ }
162
+ }
163
+
157
164
  @TargetApi(Build.VERSION_CODES.M)
158
165
  public void requestPermissions(
159
166
  String[] permissions, int requestCode, PermissionListener listener) {
@@ -65,6 +65,7 @@ import com.facebook.react.bridge.NotThreadSafeBridgeIdleDebugListener;
65
65
  import com.facebook.react.bridge.ProxyJavaScriptExecutor;
66
66
  import com.facebook.react.bridge.ReactApplicationContext;
67
67
  import com.facebook.react.bridge.ReactContext;
68
+ import com.facebook.react.bridge.ReactCxxErrorHandler;
68
69
  import com.facebook.react.bridge.ReactMarker;
69
70
  import com.facebook.react.bridge.ReactMarkerConstants;
70
71
  import com.facebook.react.bridge.ReactNoCrashSoftException;
@@ -107,6 +108,7 @@ import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper;
107
108
  import com.facebook.soloader.SoLoader;
108
109
  import com.facebook.systrace.Systrace;
109
110
  import com.facebook.systrace.SystraceMessage;
111
+ import java.lang.reflect.Method;
110
112
  import java.util.ArrayList;
111
113
  import java.util.Collection;
112
114
  import java.util.Collections;
@@ -156,12 +158,14 @@ public class ReactInstanceManager {
156
158
  /* accessed from any thread */
157
159
  private final JavaScriptExecutorFactory mJavaScriptExecutorFactory;
158
160
 
161
+ // See {@code ReactInstanceManagerBuilder} for description of all flags here.
159
162
  private @Nullable List<String> mViewManagerNames = null;
160
163
  private final @Nullable JSBundleLoader mBundleLoader;
161
164
  private final @Nullable String mJSMainModulePath; /* path to JS bundle root on Metro */
162
165
  private final List<ReactPackage> mPackages;
163
166
  private final DevSupportManager mDevSupportManager;
164
167
  private final boolean mUseDeveloperSupport;
168
+ private final boolean mRequireActivity;
165
169
  private @Nullable ComponentNameResolverManager mComponentNameResolverManager;
166
170
  private @Nullable RuntimeSchedulerManager mRuntimeSchedulerManager;
167
171
  private final @Nullable NotThreadSafeBridgeIdleDebugListener mBridgeIdleDebugListener;
@@ -216,6 +220,7 @@ public class ReactInstanceManager {
216
220
  @Nullable String jsMainModulePath,
217
221
  List<ReactPackage> packages,
218
222
  boolean useDeveloperSupport,
223
+ boolean requireActivity,
219
224
  @Nullable NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener,
220
225
  LifecycleState initialLifecycleState,
221
226
  @Nullable UIImplementationProvider mUIImplementationProvider,
@@ -233,6 +238,7 @@ public class ReactInstanceManager {
233
238
 
234
239
  DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(applicationContext);
235
240
 
241
+ // See {@code ReactInstanceManagerBuilder} for description of all flags here.
236
242
  mApplicationContext = applicationContext;
237
243
  mCurrentActivity = currentActivity;
238
244
  mDefaultBackButtonImpl = defaultHardwareBackBtnHandler;
@@ -241,6 +247,7 @@ public class ReactInstanceManager {
241
247
  mJSMainModulePath = jsMainModulePath;
242
248
  mPackages = new ArrayList<>();
243
249
  mUseDeveloperSupport = useDeveloperSupport;
250
+ mRequireActivity = requireActivity;
244
251
  Systrace.beginSection(
245
252
  Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ReactInstanceManager.initDevSupportManager");
246
253
  mDevSupportManager =
@@ -286,6 +293,8 @@ public class ReactInstanceManager {
286
293
  if (mUseDeveloperSupport) {
287
294
  mDevSupportManager.startInspector();
288
295
  }
296
+
297
+ registerCxxErrorHandlerFunc();
289
298
  }
290
299
 
291
300
  private ReactInstanceDevHelper createDevHelperInterface() {
@@ -359,6 +368,22 @@ public class ReactInstanceManager {
359
368
  return new ArrayList<>(mPackages);
360
369
  }
361
370
 
371
+ public void handleCxxError(Exception e) {
372
+ mDevSupportManager.handleException(e);
373
+ }
374
+
375
+ public void registerCxxErrorHandlerFunc() {
376
+ Class[] parameterTypes = new Class[1];
377
+ parameterTypes[0] = Exception.class;
378
+ Method handleCxxErrorFunc = null;
379
+ try {
380
+ handleCxxErrorFunc = ReactInstanceManager.class.getMethod("handleCxxError", parameterTypes);
381
+ } catch (NoSuchMethodException e) {
382
+ FLog.e("ReactInstanceHolder", "Failed to set cxx error hanlder function", e);
383
+ }
384
+ ReactCxxErrorHandler.setHandleErrorFunc(this, handleCxxErrorFunc);
385
+ }
386
+
362
387
  static void initializeSoLoaderIfNecessary(Context applicationContext) {
363
388
  // Call SoLoader.initialize here, this is required for apps that does not use exopackage and
364
389
  // does not use SoLoader for loading other native code except from the one used by React Native
@@ -558,16 +583,20 @@ public class ReactInstanceManager {
558
583
  * @param activity the activity being paused
559
584
  */
560
585
  @ThreadConfined(UI)
561
- public void onHostPause(Activity activity) {
562
- Assertions.assertNotNull(mCurrentActivity);
563
- Assertions.assertCondition(
564
- activity == mCurrentActivity,
565
- "Pausing an activity that is not the current activity, this is incorrect! "
566
- + "Current activity: "
567
- + mCurrentActivity.getClass().getSimpleName()
568
- + " "
569
- + "Paused activity: "
570
- + activity.getClass().getSimpleName());
586
+ public void onHostPause(@Nullable Activity activity) {
587
+ if (mRequireActivity) {
588
+ Assertions.assertCondition(mCurrentActivity != null);
589
+ }
590
+ if (mCurrentActivity != null) {
591
+ Assertions.assertCondition(
592
+ activity == mCurrentActivity,
593
+ "Pausing an activity that is not the current activity, this is incorrect! "
594
+ + "Current activity: "
595
+ + mCurrentActivity.getClass().getSimpleName()
596
+ + " "
597
+ + "Paused activity: "
598
+ + activity.getClass().getSimpleName());
599
+ }
571
600
  onHostPause();
572
601
  }
573
602
 
@@ -583,7 +612,8 @@ public class ReactInstanceManager {
583
612
  * this instance of {@link ReactInstanceManager}.
584
613
  */
585
614
  @ThreadConfined(UI)
586
- public void onHostResume(Activity activity, DefaultHardwareBackBtnHandler defaultBackButtonImpl) {
615
+ public void onHostResume(
616
+ @Nullable Activity activity, DefaultHardwareBackBtnHandler defaultBackButtonImpl) {
587
617
  UiThreadUtil.assertOnUiThread();
588
618
 
589
619
  mDefaultBackButtonImpl = defaultBackButtonImpl;
@@ -592,7 +622,7 @@ public class ReactInstanceManager {
592
622
 
593
623
  /** Use this method when the activity resumes. */
594
624
  @ThreadConfined(UI)
595
- public void onHostResume(Activity activity) {
625
+ public void onHostResume(@Nullable Activity activity) {
596
626
  UiThreadUtil.assertOnUiThread();
597
627
 
598
628
  mCurrentActivity = activity;
@@ -631,8 +661,8 @@ public class ReactInstanceManager {
631
661
  // activity is attached to window, we can enable dev support immediately
632
662
  mDevSupportManager.setDevSupportEnabled(true);
633
663
  }
634
- } else {
635
- // there is no activity, we can enable dev support
664
+ } else if (!mRequireActivity) {
665
+ // there is no activity, but we can enable dev support
636
666
  mDevSupportManager.setDevSupportEnabled(true);
637
667
  }
638
668
  }
@@ -666,7 +696,9 @@ public class ReactInstanceManager {
666
696
  * @param activity the activity being destroyed
667
697
  */
668
698
  @ThreadConfined(UI)
669
- public void onHostDestroy(Activity activity) {
699
+ public void onHostDestroy(@Nullable Activity activity) {
700
+ // In some cases, Activity may (correctly) be null.
701
+ // See mRequireActivity flag.
670
702
  if (activity == mCurrentActivity) {
671
703
  onHostDestroy();
672
704
  }
@@ -45,6 +45,7 @@ public class ReactInstanceManagerBuilder {
45
45
  private @Nullable NotThreadSafeBridgeIdleDebugListener mBridgeIdleDebugListener;
46
46
  private @Nullable Application mApplication;
47
47
  private boolean mUseDeveloperSupport;
48
+ private boolean mRequireActivity;
48
49
  private @Nullable LifecycleState mInitialLifecycleState;
49
50
  private @Nullable UIImplementationProvider mUIImplementationProvider;
50
51
  private @Nullable NativeModuleCallExceptionHandler mNativeModuleCallExceptionHandler;
@@ -171,6 +172,16 @@ public class ReactInstanceManagerBuilder {
171
172
  return this;
172
173
  }
173
174
 
175
+ /**
176
+ * When {@code false}, indicates that correct usage of React Native will NOT involve an Activity.
177
+ * For the vast majority of Android apps in the ecosystem, this will not need to change. Unless
178
+ * you really know what you're doing, you should probably not change this!
179
+ */
180
+ public ReactInstanceManagerBuilder setRequireActivity(boolean requireActivity) {
181
+ mRequireActivity = requireActivity;
182
+ return this;
183
+ }
184
+
174
185
  /**
175
186
  * Sets the initial lifecycle state of the host. For example, if the host is already resumed at
176
187
  * creation time, we wouldn't expect an onResume call until we get an onPause call.
@@ -283,6 +294,7 @@ public class ReactInstanceManagerBuilder {
283
294
  mJSMainModulePath,
284
295
  mPackages,
285
296
  mUseDeveloperSupport,
297
+ mRequireActivity,
286
298
  mBridgeIdleDebugListener,
287
299
  Assertions.assertNotNull(mInitialLifecycleState, "Initial lifecycle state was not set"),
288
300
  mUIImplementationProvider,
@@ -68,6 +68,7 @@ public abstract class ReactNativeHost {
68
68
  .setApplication(mApplication)
69
69
  .setJSMainModulePath(getJSMainModuleName())
70
70
  .setUseDeveloperSupport(getUseDeveloperSupport())
71
+ .setRequireActivity(getShouldRequireActivity())
71
72
  .setRedBoxHandler(getRedBoxHandler())
72
73
  .setJavaScriptExecutorFactory(getJavaScriptExecutorFactory())
73
74
  .setUIImplementationProvider(getUIImplementationProvider())
@@ -124,6 +125,11 @@ public abstract class ReactNativeHost {
124
125
  return null;
125
126
  }
126
127
 
128
+ /** Returns whether or not to treat it as normal if Activity is null. */
129
+ public boolean getShouldRequireActivity() {
130
+ return true;
131
+ }
132
+
127
133
  /**
128
134
  * Returns the name of the main module. Determines the URL used to fetch the JS bundle from Metro.
129
135
  * It is only used when dev support is enabled. This is the first file to be executed once the
@@ -0,0 +1,39 @@
1
+ /*
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ package com.facebook.react.bridge;
9
+
10
+ import com.facebook.common.logging.FLog;
11
+ import com.facebook.proguard.annotations.DoNotStrip;
12
+ import java.lang.reflect.Method;
13
+
14
+ @DoNotStrip
15
+ public class ReactCxxErrorHandler {
16
+
17
+ private static Method mHandleErrorFunc;
18
+ private static Object mObject;
19
+
20
+ @DoNotStrip
21
+ public static void setHandleErrorFunc(Object object, Method handleErrorFunc) {
22
+ mObject = object;
23
+ mHandleErrorFunc = handleErrorFunc;
24
+ }
25
+
26
+ @DoNotStrip
27
+ // For use from within the C++ JReactCxxErrorHandler
28
+ private static void handleError(final String message) {
29
+ if (mHandleErrorFunc != null) {
30
+ try {
31
+ Object[] parameters = new Object[1];
32
+ parameters[0] = new Exception(message);
33
+ mHandleErrorFunc.invoke(mObject, parameters);
34
+ } catch (Exception e) {
35
+ FLog.e("ReactCxxErrorHandler", "Failed to invole error hanlder function", e);
36
+ }
37
+ }
38
+ }
39
+ }
@@ -25,6 +25,12 @@ public class ReactFeatureFlags {
25
25
  */
26
26
  public static volatile boolean useTurboModules = false;
27
27
 
28
+ /**
29
+ * Should this application use the new (Fabric) Renderer? If yes, all rendering in this app will
30
+ * use Fabric instead of the legacy renderer.
31
+ */
32
+ public static volatile boolean enableFabricRenderer = false;
33
+
28
34
  /**
29
35
  * After TurboModules and Fabric are enabled, we need to ensure that the legacy NativeModule isn't
30
36
  * isn't used. So, turn this flag on to trigger warnings whenever the legacy NativeModule system
@@ -5,8 +5,10 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
+ // TODO(macOS GH#774)
9
+
8
10
  package com.facebook.react.devsupport.interfaces;
9
11
 
10
12
  public interface BundleLoadCallback {
11
13
  void onSuccess();
12
- }
14
+ }
@@ -7,6 +7,7 @@
7
7
 
8
8
  package com.facebook.react.modules.appearance;
9
9
 
10
+ import android.app.Activity;
10
11
  import android.content.Context;
11
12
  import android.content.res.Configuration;
12
13
  import androidx.annotation.Nullable;
@@ -74,7 +75,15 @@ public class AppearanceModule extends NativeAppearanceSpec {
74
75
 
75
76
  @Override
76
77
  public String getColorScheme() {
77
- mColorScheme = colorSchemeForCurrentConfiguration(getReactApplicationContext());
78
+ // Attempt to use the Activity context first in order to get the most up to date
79
+ // scheme. This covers the scenario when AppCompatDelegate.setDefaultNightMode()
80
+ // is called directly (which can occur in Brownfield apps for example).
81
+ Activity activity = getCurrentActivity();
82
+
83
+ mColorScheme =
84
+ colorSchemeForCurrentConfiguration(
85
+ activity != null ? activity : getReactApplicationContext());
86
+
78
87
  return mColorScheme;
79
88
  }
80
89
 
@@ -13,10 +13,14 @@ import com.facebook.react.common.MapBuilder;
13
13
 
14
14
  import java.util.Map;
15
15
 
16
+ // [TODO(macOS GH#944)
17
+ // Note: Be careful not to override these version numbers
18
+ // when we merge upstream stable branches into main
19
+ // TODO(macOS GH#944)]
16
20
  public class ReactNativeVersion {
17
21
  public static final Map<String, Object> VERSION = MapBuilder.<String, Object>of(
18
22
  "major", 0,
19
23
  "minor", 0,
20
24
  "patch", 0,
21
- "prerelease", "a45ffbd53");
25
+ "prerelease", "a818b5ac1");
22
26
  }
@@ -34,7 +34,6 @@ rn_android_library(
34
34
  react_native_target("java/com/facebook/react/modules/camera:camera"),
35
35
  react_native_target("java/com/facebook/react/modules/clipboard:clipboard"),
36
36
  react_native_target("java/com/facebook/react/modules/core:core"),
37
- react_native_target("java/com/facebook/react/modules/datepicker:datepicker"),
38
37
  react_native_target("java/com/facebook/react/modules/debug:debug"),
39
38
  react_native_target("java/com/facebook/react/modules/dialog:dialog"),
40
39
  react_native_target("java/com/facebook/react/modules/fresco:fresco"),
@@ -23,7 +23,6 @@ import com.facebook.react.modules.blob.BlobModule;
23
23
  import com.facebook.react.modules.blob.FileReaderModule;
24
24
  import com.facebook.react.modules.camera.ImageStoreManager;
25
25
  import com.facebook.react.modules.clipboard.ClipboardModule;
26
- import com.facebook.react.modules.datepicker.DatePickerDialogModule;
27
26
  import com.facebook.react.modules.dialog.DialogModule;
28
27
  import com.facebook.react.modules.fresco.FrescoModule;
29
28
  import com.facebook.react.modules.i18nmanager.I18nManagerModule;
@@ -72,7 +71,6 @@ import java.util.Map;
72
71
  FileReaderModule.class,
73
72
  AsyncStorageModule.class,
74
73
  ClipboardModule.class,
75
- DatePickerDialogModule.class,
76
74
  DialogModule.class,
77
75
  FrescoModule.class,
78
76
  I18nManagerModule.class,
@@ -117,8 +115,6 @@ public class MainReactPackage extends TurboReactPackage {
117
115
  return new AsyncStorageModule(context);
118
116
  case ClipboardModule.NAME:
119
117
  return new ClipboardModule(context);
120
- case DatePickerDialogModule.FRAGMENT_TAG:
121
- return new DatePickerDialogModule(context);
122
118
  case DialogModule.NAME:
123
119
  return new DialogModule(context);
124
120
  case FrescoModule.NAME:
@@ -199,7 +195,6 @@ public class MainReactPackage extends TurboReactPackage {
199
195
  FileReaderModule.class,
200
196
  AsyncStorageModule.class,
201
197
  ClipboardModule.class,
202
- DatePickerDialogModule.class,
203
198
  DialogModule.class,
204
199
  FrescoModule.class,
205
200
  I18nManagerModule.class,
@@ -110,10 +110,6 @@ public abstract class ReactTextAnchorViewManager<T extends View, C extends React
110
110
  view.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE);
111
111
  } else if (frequency.equals("full")) {
112
112
  view.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_FULL);
113
- } else if (frequency.equals("balanced")) {
114
- view.setHyphenationFrequency(Layout.BREAK_STRATEGY_BALANCED);
115
- } else if (frequency.equals("high")) {
116
- view.setHyphenationFrequency(Layout.BREAK_STRATEGY_HIGH_QUALITY);
117
113
  } else if (frequency.equals("normal")) {
118
114
  view.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL);
119
115
  } else {
@@ -32,6 +32,7 @@ import com.facebook.react.uimanager.ThemedReactContext;
32
32
  import com.facebook.react.uimanager.UIViewOperationQueue;
33
33
  import com.facebook.react.uimanager.annotations.ReactProp;
34
34
  import com.facebook.react.uimanager.events.RCTEventEmitter;
35
+ import com.facebook.yoga.YogaBaselineFunction;
35
36
  import com.facebook.yoga.YogaConstants;
36
37
  import com.facebook.yoga.YogaDirection;
37
38
  import com.facebook.yoga.YogaMeasureFunction;
@@ -159,6 +160,20 @@ public class ReactTextShadowNode extends ReactBaseTextShadowNode {
159
160
  }
160
161
  };
161
162
 
163
+ private final YogaBaselineFunction mTextBaselineFunction =
164
+ new YogaBaselineFunction() {
165
+ @Override
166
+ public float baseline(YogaNode node, float width, float height) {
167
+ Spannable text =
168
+ Assertions.assertNotNull(
169
+ mPreparedSpannableText,
170
+ "Spannable element has not been prepared in onBeforeLayout");
171
+
172
+ Layout layout = measureSpannedText(text, width, YogaMeasureMode.EXACTLY);
173
+ return layout.getLineBaseline(layout.getLineCount() - 1);
174
+ }
175
+ };
176
+
162
177
  public ReactTextShadowNode() {
163
178
  this(null);
164
179
  }
@@ -171,6 +186,7 @@ public class ReactTextShadowNode extends ReactBaseTextShadowNode {
171
186
  private void initMeasureFunction() {
172
187
  if (!isVirtual()) {
173
188
  setMeasureFunction(mTextMeasureFunction);
189
+ setBaselineFunction(mTextBaselineFunction);
174
190
  }
175
191
  }
176
192
 
@@ -68,9 +68,10 @@ public class TextAttributeProps {
68
68
  private static final int DEFAULT_TEXT_SHADOW_COLOR = 0x55000000;
69
69
  private static final int DEFAULT_JUSTIFICATION_MODE =
70
70
  (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) ? 0 : Layout.JUSTIFICATION_MODE_NONE;
71
-
72
71
  private static final int DEFAULT_BREAK_STRATEGY =
73
72
  (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) ? 0 : Layout.BREAK_STRATEGY_HIGH_QUALITY;
73
+ private static final int DEFAULT_HYPHENATION_FREQUENCY =
74
+ (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) ? 0 : Layout.HYPHENATION_FREQUENCY_NONE;
74
75
 
75
76
  protected float mLineHeight = Float.NaN;
76
77
  protected boolean mIsColorSet = false;
@@ -568,4 +569,22 @@ public class TextAttributeProps {
568
569
  }
569
570
  return androidTextBreakStrategy;
570
571
  }
572
+
573
+ public static int getHyphenationFrequency(@Nullable String hyphenationFrequency) {
574
+ int androidHyphenationFrequency = DEFAULT_HYPHENATION_FREQUENCY;
575
+ if (hyphenationFrequency != null) {
576
+ switch (hyphenationFrequency) {
577
+ case "none":
578
+ androidHyphenationFrequency = Layout.HYPHENATION_FREQUENCY_NONE;
579
+ break;
580
+ case "normal":
581
+ androidHyphenationFrequency = Layout.HYPHENATION_FREQUENCY_NORMAL;
582
+ break;
583
+ default:
584
+ androidHyphenationFrequency = Layout.HYPHENATION_FREQUENCY_FULL;
585
+ break;
586
+ }
587
+ }
588
+ return androidHyphenationFrequency;
589
+ }
571
590
  }
@@ -64,6 +64,7 @@ public class TextLayoutManager {
64
64
  private static final boolean DEFAULT_INCLUDE_FONT_PADDING = true;
65
65
  private static final String INCLUDE_FONT_PADDING_KEY = "includeFontPadding";
66
66
  private static final String TEXT_BREAK_STRATEGY_KEY = "textBreakStrategy";
67
+ private static final String HYPHENATION_FREQUENCY_KEY = "android_hyphenationFrequency";
67
68
  private static final String MAXIMUM_NUMBER_OF_LINES_KEY = "maximumNumberOfLines";
68
69
  private static final LruCache<ReadableNativeMap, Spannable> sSpannableCache =
69
70
  new LruCache<>(spannableCacheSize);
@@ -250,7 +251,8 @@ public class TextLayoutManager {
250
251
  float width,
251
252
  YogaMeasureMode widthYogaMeasureMode,
252
253
  boolean includeFontPadding,
253
- int textBreakStrategy) {
254
+ int textBreakStrategy,
255
+ int hyphenationFrequency) {
254
256
  Layout layout;
255
257
  int spanLength = text.length();
256
258
  boolean unconstrainedWidth = widthYogaMeasureMode == YogaMeasureMode.UNDEFINED || width < 0;
@@ -281,10 +283,9 @@ public class TextLayoutManager {
281
283
  .setLineSpacing(0.f, 1.f)
282
284
  .setIncludePad(includeFontPadding)
283
285
  .setBreakStrategy(textBreakStrategy)
284
- .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL)
286
+ .setHyphenationFrequency(hyphenationFrequency)
285
287
  .build();
286
288
  }
287
-
288
289
  } else if (boring != null && (unconstrainedWidth || boring.width <= width)) {
289
290
  int boringLayoutWidth = boring.width;
290
291
  if (boring.width < 0) {
@@ -325,7 +326,7 @@ public class TextLayoutManager {
325
326
  .setLineSpacing(0.f, 1.f)
326
327
  .setIncludePad(includeFontPadding)
327
328
  .setBreakStrategy(textBreakStrategy)
328
- .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL);
329
+ .setHyphenationFrequency(hyphenationFrequency);
329
330
 
330
331
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
331
332
  builder.setUseLineSpacingFromFallbacks(true);
@@ -378,6 +379,9 @@ public class TextLayoutManager {
378
379
  paragraphAttributes.hasKey(INCLUDE_FONT_PADDING_KEY)
379
380
  ? paragraphAttributes.getBoolean(INCLUDE_FONT_PADDING_KEY)
380
381
  : DEFAULT_INCLUDE_FONT_PADDING;
382
+ int hyphenationFrequency =
383
+ TextAttributeProps.getHyphenationFrequency(
384
+ paragraphAttributes.getString(HYPHENATION_FREQUENCY_KEY));
381
385
 
382
386
  if (text == null) {
383
387
  throw new IllegalStateException("Spannable element has not been prepared in onBeforeLayout");
@@ -387,7 +391,13 @@ public class TextLayoutManager {
387
391
 
388
392
  Layout layout =
389
393
  createLayout(
390
- text, boring, width, widthYogaMeasureMode, includeFontPadding, textBreakStrategy);
394
+ text,
395
+ boring,
396
+ width,
397
+ widthYogaMeasureMode,
398
+ includeFontPadding,
399
+ textBreakStrategy,
400
+ hyphenationFrequency);
391
401
 
392
402
  int maximumNumberOfLines =
393
403
  paragraphAttributes.hasKey(MAXIMUM_NUMBER_OF_LINES_KEY)
@@ -539,10 +549,19 @@ public class TextLayoutManager {
539
549
  paragraphAttributes.hasKey(INCLUDE_FONT_PADDING_KEY)
540
550
  ? paragraphAttributes.getBoolean(INCLUDE_FONT_PADDING_KEY)
541
551
  : DEFAULT_INCLUDE_FONT_PADDING;
552
+ int hyphenationFrequency =
553
+ TextAttributeProps.getTextBreakStrategy(
554
+ paragraphAttributes.getString(HYPHENATION_FREQUENCY_KEY));
542
555
 
543
556
  Layout layout =
544
557
  createLayout(
545
- text, boring, width, YogaMeasureMode.EXACTLY, includeFontPadding, textBreakStrategy);
558
+ text,
559
+ boring,
560
+ width,
561
+ YogaMeasureMode.EXACTLY,
562
+ includeFontPadding,
563
+ textBreakStrategy,
564
+ hyphenationFrequency);
546
565
  return FontMetricsUtil.getFontMetrics(text, layout, sTextPaintInstance, context);
547
566
  }
548
567