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
@@ -28,7 +28,7 @@ const hasNativePromise = isNativeFunction(Promise);
28
28
  const hasPromiseQueuedToJSVM = hasNativePromise || hasHermesPromiseQueuedToJSVM;
29
29
 
30
30
  // In bridgeless mode, timers are host functions installed from cpp.
31
- if (!global.RN$Bridgeless) {
31
+ if (global.RN$Bridgeless !== true) {
32
32
  /**
33
33
  * Set up timers.
34
34
  * You can use this module directly, or just require InitializeCore.
@@ -65,7 +65,7 @@ if (hasPromiseQueuedToJSVM) {
65
65
  // When promise was polyfilled hence is queued to the RN microtask queue,
66
66
  // we polyfill the immediate APIs as aliases to the ReactNativeMicrotask APIs.
67
67
  // Note that in bridgeless mode, immediate APIs are installed from cpp.
68
- if (!global.RN$Bridgeless) {
68
+ if (global.RN$Bridgeless !== true) {
69
69
  polyfillGlobal(
70
70
  'setImmediate',
71
71
  () => require('./Timers/JSTimers').queueReactNativeMicrotask,
@@ -12,6 +12,7 @@ import DeprecatedImagePropType from '../DeprecatedPropTypes/DeprecatedImagePropT
12
12
  import * as React from 'react';
13
13
  import StyleSheet from '../StyleSheet/StyleSheet';
14
14
 
15
+ import ImageInjection from './ImageInjection';
15
16
  import ImageAnalyticsTagContext from './ImageAnalyticsTagContext';
16
17
  import flattenStyle from '../StyleSheet/flattenStyle';
17
18
  import resolveAssetSource from './resolveAssetSource';
@@ -171,6 +172,11 @@ Image = React.forwardRef<
171
172
  ImagePropsType,
172
173
  React.ElementRef<typeof ImageViewNativeComponent>,
173
174
  >(Image);
175
+
176
+ if (ImageInjection.unstable_createImageComponent != null) {
177
+ Image = ImageInjection.unstable_createImageComponent(Image);
178
+ }
179
+
174
180
  Image.displayName = 'Image';
175
181
 
176
182
  /**
@@ -649,18 +649,12 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
649
649
 
650
650
  - (NSColor *)tintColor
651
651
  {
652
- NSColor *tintColor = nil;
653
- if (@available(macOS 10.14, *)) {
654
- tintColor = _imageView.contentTintColor;
655
- }
656
- return tintColor;
652
+ return _imageView.contentTintColor;
657
653
  }
658
654
 
659
655
  - (void)setTintColor:(NSColor *)tintColor
660
656
  {
661
- if (@available(macOS 10.14, *)) {
662
- _imageView.contentTintColor = tintColor;
663
- }
657
+ _imageView.contentTintColor = tintColor;
664
658
  }
665
659
  #endif // ]TODO(macOS GH#774)
666
660
 
@@ -320,40 +320,40 @@ export function checkWarningFilter(format: string): WarningInfo {
320
320
  return warningFilter(format);
321
321
  }
322
322
 
323
+ export function getIgnorePatterns(): $ReadOnlyArray<IgnorePattern> {
324
+ return Array.from(ignorePatterns);
325
+ }
326
+
323
327
  export function addIgnorePatterns(
324
328
  patterns: $ReadOnlyArray<IgnorePattern>,
325
329
  ): void {
330
+ const existingSize = ignorePatterns.size;
326
331
  // The same pattern may be added multiple times, but adding a new pattern
327
332
  // can be expensive so let's find only the ones that are new.
328
- const newPatterns = patterns.filter((pattern: IgnorePattern) => {
333
+ patterns.forEach((pattern: IgnorePattern) => {
329
334
  if (pattern instanceof RegExp) {
330
- for (const existingPattern of ignorePatterns.entries()) {
335
+ for (const existingPattern of ignorePatterns) {
331
336
  if (
332
337
  existingPattern instanceof RegExp &&
333
338
  existingPattern.toString() === pattern.toString()
334
339
  ) {
335
- return false;
340
+ return;
336
341
  }
337
342
  }
338
- return true;
343
+ ignorePatterns.add(pattern);
339
344
  }
340
- return !ignorePatterns.has(pattern);
345
+ ignorePatterns.add(pattern);
341
346
  });
342
-
343
- if (newPatterns.length === 0) {
347
+ if (ignorePatterns.size === existingSize) {
344
348
  return;
345
349
  }
346
- for (const pattern of newPatterns) {
347
- ignorePatterns.add(pattern);
348
-
349
- // We need to recheck all of the existing logs.
350
- // This allows adding an ignore pattern anywhere in the codebase.
351
- // Without this, if you ignore a pattern after the a log is created,
352
- // then we would keep showing the log.
353
- logs = new Set(
354
- Array.from(logs).filter(log => !isMessageIgnored(log.message.content)),
355
- );
356
- }
350
+ // We need to recheck all of the existing logs.
351
+ // This allows adding an ignore pattern anywhere in the codebase.
352
+ // Without this, if you ignore a pattern after the a log is created,
353
+ // then we would keep showing the log.
354
+ logs = new Set(
355
+ Array.from(logs).filter(log => !isMessageIgnored(log.message.content)),
356
+ );
357
357
  handleUpdate();
358
358
  }
359
359
 
@@ -674,6 +674,7 @@ export default class Pressability {
674
674
  PressabilityPerformanceEventEmitter.emitEvent(() => {
675
675
  return {
676
676
  signal,
677
+ nativeTimestamp: event.nativeEvent.timestamp,
677
678
  touchDelayMs: Date.now() - event.nativeEvent.timestamp,
678
679
  };
679
680
  });
@@ -12,6 +12,7 @@ import {type PressabilityTouchSignal as TouchSignal} from './PressabilityTypes.j
12
12
 
13
13
  export type PressabilityPerformanceEvent = $ReadOnly<{|
14
14
  signal: TouchSignal,
15
+ nativeTimestamp: number,
15
16
  touchDelayMs: number,
16
17
  |}>;
17
18
  export type PressabilityPerformanceEventListener = PressabilityPerformanceEvent => void;
@@ -18,6 +18,8 @@ export opaque type NativeColorValue = {
18
18
  dynamic?: {
19
19
  light: ?(ColorValue | ProcessedColorValue),
20
20
  dark: ?(ColorValue | ProcessedColorValue),
21
+ highContrastLight?: ?(ColorValue | ProcessedColorValue),
22
+ highContrastDark?: ?(ColorValue | ProcessedColorValue),
21
23
  },
22
24
  colorWithSystemEffect?: {
23
25
  baseColor: ?(ColorValue | ProcessedColorValue),
@@ -51,12 +53,21 @@ export const ColorWithSystemEffectMacOSPrivate = (
51
53
  export type DynamicColorMacOSTuplePrivate = {
52
54
  light: ColorValue,
53
55
  dark: ColorValue,
56
+ highContrastLight?: ColorValue,
57
+ highContrastDark?: ColorValue,
54
58
  };
55
59
 
56
60
  export const DynamicColorMacOSPrivate = (
57
61
  tuple: DynamicColorMacOSTuplePrivate,
58
62
  ): ColorValue => {
59
- return {dynamic: {light: tuple.light, dark: tuple.dark}};
63
+ return {
64
+ dynamic: {
65
+ light: tuple.light,
66
+ dark: tuple.dark,
67
+ highContrastLight: tuple.highContrastLight,
68
+ highContrastDark: tuple.highContrastDark,
69
+ },
70
+ };
60
71
  };
61
72
 
62
73
  export const normalizeColorObject = (
@@ -74,6 +85,8 @@ export const normalizeColorObject = (
74
85
  dynamic: {
75
86
  light: normalizeColor(dynamic.light),
76
87
  dark: normalizeColor(dynamic.dark),
88
+ highContrastLight: normalizeColor(dynamic.highContrastLight),
89
+ highContrastDark: normalizeColor(dynamic.highContrastDark),
77
90
  },
78
91
  };
79
92
  return dynamicColor;
@@ -104,6 +117,8 @@ export const processColorObject = (
104
117
  dynamic: {
105
118
  light: processColor(dynamic.light),
106
119
  dark: processColor(dynamic.dark),
120
+ highContrastLight: processColor(dynamic.highContrastLight),
121
+ highContrastDark: processColor(dynamic.highContrastDark),
107
122
  },
108
123
  };
109
124
  return dynamicColor;
@@ -15,6 +15,8 @@ import type {ColorValue} from './StyleSheet';
15
15
  export type DynamicColorMacOSTuple = {
16
16
  light: ColorValue,
17
17
  dark: ColorValue,
18
+ highContrastLight?: ColorValue,
19
+ highContrastDark?: ColorValue,
18
20
  };
19
21
 
20
22
  export const DynamicColorMacOS = (
@@ -19,12 +19,19 @@ import {
19
19
  export type DynamicColorMacOSTuple = {
20
20
  light: ColorValue,
21
21
  dark: ColorValue,
22
+ highContrastLight?: ColorValue,
23
+ highContrastDark?: ColorValue,
22
24
  };
23
25
 
24
26
  export const DynamicColorMacOS = (
25
27
  tuple: DynamicColorMacOSTuple,
26
28
  ): ColorValue => {
27
- return DynamicColorMacOSPrivate({light: tuple.light, dark: tuple.dark});
29
+ return DynamicColorMacOSPrivate({
30
+ light: tuple.light,
31
+ dark: tuple.dark,
32
+ highContrastLight: tuple.highContrastLight,
33
+ highContrastDark: tuple.highContrastDark,
34
+ });
28
35
  };
29
36
 
30
37
  export type SystemEffectMacOS =
@@ -24,10 +24,12 @@
24
24
  [self.superview dirtyLayout];
25
25
  }
26
26
 
27
+ #if DEBUG // TODO(macOS GH#774) description is a debug-only feature
27
28
  - (NSString *)description
28
29
  {
29
30
  NSString *superDescription = super.description;
30
31
  return [[superDescription substringToIndex:superDescription.length - 1] stringByAppendingFormat:@"; text: %@>", self.text];
31
32
  }
33
+ #endif // TODO(macOS GH#774)
32
34
 
33
35
  @end
@@ -55,6 +55,8 @@
55
55
  self.accessibilityTraits |= UIAccessibilityTraitStaticText;
56
56
  #else // [TODO(macOS GH#774)
57
57
  self.accessibilityRole = NSAccessibilityStaticTextRole;
58
+ // Fix blurry text on non-retina displays.
59
+ self.canDrawSubviewsIntoLayer = YES;
58
60
  #endif // ]TODO(macOS GH#774)
59
61
  self.opaque = NO;
60
62
  RCTUIViewSetContentModeRedraw(self); // TODO(macOS GH#774) and TODO(macOS ISS#3536887)
@@ -99,13 +101,15 @@
99
101
  }
100
102
  #endif // ]TODO(macOS GH#774)
101
103
 
104
+ #if DEBUG // TODO(macOS GH#774) description is a debug-only feature
102
105
  - (NSString *)description
103
106
  {
104
- NSString *superDescription = super.description;
105
- NSRange semicolonRange = [superDescription rangeOfString:@";"];
106
- NSString *replacement = [NSString stringWithFormat:@"; reactTag: %@; text: %@", self.reactTag, _textStorage.string];
107
- return [superDescription stringByReplacingCharactersInRange:semicolonRange withString:replacement];
107
+ // [TODO(macOS GH#774): we shouldn't make assumptions on what super's description is. Just append additional content.
108
+ NSString *stringToAppend = [NSString stringWithFormat:@" reactTag: %@; text: %@", self.reactTag, _textStorage.string];
109
+ return [[super description] stringByAppendingString:stringToAppend];
110
+ // TODO(macOS GH#774)]
108
111
  }
112
+ #endif // TODO(macOS GH#774)
109
113
 
110
114
  - (void)setSelectable:(BOOL)selectable
111
115
  {
@@ -49,6 +49,8 @@ static RCTUIColor *defaultPlaceholderColor() // TODO(OSS Candidate ISS#2710739)
49
49
  NSTextCheckingTypes checkingTypes = 0;
50
50
  self.enabledTextCheckingTypes = checkingTypes;
51
51
  self.insertionPointColor = [NSColor selectedControlColor];
52
+ // Fix blurry text on non-retina displays.
53
+ self.canDrawSubviewsIntoLayer = YES;
52
54
  #endif // ]TODO(macOS GH#774)
53
55
 
54
56
  _textInputDelegateAdapter = [[RCTBackedTextViewDelegateAdapter alloc] initWithTextView:self];
@@ -159,6 +161,12 @@ static RCTUIColor *defaultPlaceholderColor() // TODO(OSS Candidate ISS#2710739)
159
161
  self.string = text;
160
162
  }
161
163
 
164
+ - (void)setTypingAttributes:(__unused NSDictionary *)typingAttributes
165
+ {
166
+ // Prevent NSTextView from changing its own typing attributes out from under us.
167
+ [super setTypingAttributes:_defaultTextAttributes];
168
+ }
169
+
162
170
  - (NSAttributedString*)attributedText
163
171
  {
164
172
  return self.textStorage;
@@ -307,13 +315,7 @@ static RCTUIColor *defaultPlaceholderColor() // TODO(OSS Candidate ISS#2710739)
307
315
  if (self.placeholder == nil) {
308
316
  return nil;
309
317
  }
310
- NSMutableDictionary *placeholderAttributes = [self.typingAttributes mutableCopy];
311
- if (placeholderAttributes == nil) {
312
- placeholderAttributes = [NSMutableDictionary dictionary];
313
- }
314
- placeholderAttributes[NSForegroundColorAttributeName] = self.placeholderColor ?: defaultPlaceholderColor();
315
- placeholderAttributes[NSFontAttributeName] = self.font ?: defaultPlaceholderFont();
316
- return [[NSAttributedString alloc] initWithString:self.placeholder attributes:placeholderAttributes];
318
+ return [[NSAttributedString alloc] initWithString:self.placeholder attributes:[self _placeholderTextAttributes]];
317
319
  }
318
320
 
319
321
  - (void)drawRect:(NSRect)dirtyRect
@@ -388,7 +390,7 @@ static RCTUIColor *defaultPlaceholderColor() // TODO(OSS Candidate ISS#2710739)
388
390
  placeholderSize = CGSizeMake(RCTCeilPixelValue(placeholderSize.width), RCTCeilPixelValue(placeholderSize.height));
389
391
  #else // [TODO(macOS GH#774)
390
392
  CGFloat scale = self.window.backingScaleFactor;
391
- CGSize placeholderSize = [placeholder sizeWithAttributes:@{NSFontAttributeName: self.font ?: defaultPlaceholderFont()}];
393
+ CGSize placeholderSize = [placeholder sizeWithAttributes:[self _placeholderTextAttributes]];
392
394
  placeholderSize = CGSizeMake(RCTCeilPixelValue(placeholderSize.width, scale), RCTCeilPixelValue(placeholderSize.height, scale));
393
395
  #endif // ]TODO(macOS GH#774)
394
396
  placeholderSize.width += textContainerInset.left + textContainerInset.right;
@@ -36,6 +36,8 @@ NS_ASSUME_NONNULL_BEGIN
36
36
  - (BOOL)textInputShouldHandleDeleteBackward:(id<RCTBackedTextInputViewProtocol>)sender; // Return `YES` to have the deleteBackward event handled normally. Return `NO` to disallow it and handle it yourself. TODO(OSS Candidate ISS#2710739)
37
37
  #if TARGET_OS_OSX // [TODO(macOS GH#774)
38
38
  - (BOOL)textInputShouldHandleDeleteForward:(id<RCTBackedTextInputViewProtocol>)sender; // Return `YES` to have the deleteForward event handled normally. Return `NO` to disallow it and handle it yourself.
39
+
40
+ - (void)textInputDidCancel; // Handle `Escape` key press.
39
41
  #endif // ]TODO(macOS GH#774)
40
42
 
41
43
  @optional
@@ -187,17 +187,17 @@ static void *TextFieldSelectionObservingContext = &TextFieldSelectionObservingCo
187
187
 
188
188
  - (BOOL)control:(NSControl *)control textView:(NSTextView *)fieldEditor doCommandBySelector:(SEL)commandSelector
189
189
  {
190
+ id<RCTBackedTextInputDelegate> textInputDelegate = [_backedTextInputView textInputDelegate];
190
191
  BOOL commandHandled = NO;
191
192
  // enter/return
192
193
  if (commandSelector == @selector(insertNewline:) || commandSelector == @selector(insertNewlineIgnoringFieldEditor:)) {
193
194
  [self textFieldDidEndEditingOnExit];
194
- if ([[_backedTextInputView textInputDelegate] textInputShouldReturn]) {
195
+ if ([textInputDelegate textInputShouldReturn]) {
195
196
  [[_backedTextInputView window] makeFirstResponder:nil];
196
197
  }
197
198
  commandHandled = YES;
198
199
  //backspace
199
200
  } else if (commandSelector == @selector(deleteBackward:)) {
200
- id<RCTBackedTextInputDelegate> textInputDelegate = [_backedTextInputView textInputDelegate];
201
201
  if (textInputDelegate != nil && ![textInputDelegate textInputShouldHandleDeleteBackward:_backedTextInputView]) {
202
202
  commandHandled = YES;
203
203
  } else {
@@ -214,7 +214,13 @@ static void *TextFieldSelectionObservingContext = &TextFieldSelectionObservingCo
214
214
  //paste
215
215
  } else if (commandSelector == @selector(paste:)) {
216
216
  _backedTextInputView.textWasPasted = YES;
217
- }
217
+ //escape
218
+ } else if (commandSelector == @selector(cancelOperation:)) {
219
+ [textInputDelegate textInputDidCancel];
220
+ [[_backedTextInputView window] makeFirstResponder:nil];
221
+ commandHandled = YES;
222
+ }
223
+
218
224
  return commandHandled;
219
225
  }
220
226
 
@@ -411,6 +417,12 @@ static void *TextFieldSelectionObservingContext = &TextFieldSelectionObservingCo
411
417
  //deleteForward
412
418
  } else if (commandSelector == @selector(deleteForward:)) {
413
419
  commandHandled = textInputDelegate != nil && ![textInputDelegate textInputShouldHandleDeleteForward:_backedTextInputView];
420
+ //escape
421
+ } else if (commandSelector == @selector(cancelOperation:)) {
422
+ [textInputDelegate textInputDidCancel];
423
+ [_backedTextInputView.window makeFirstResponder:nil];
424
+ commandHandled = YES;
425
+
414
426
  }
415
427
 
416
428
  return commandHandled;
@@ -493,7 +493,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
493
493
 
494
494
  if (range.location + range.length > backedTextInputView.attributedText.string.length) {
495
495
  _predictedText = backedTextInputView.attributedText.string;
496
- } else {
496
+ } else if (text != nil) { // TODO(macOS GH#774): -[NSString stringByReplacingCharactersInRange:withString:] doesn't like when the replacement string is nil
497
497
  _predictedText = [backedTextInputView.attributedText.string stringByReplacingCharactersInRange:range withString:text];
498
498
  }
499
499
 
@@ -569,6 +569,15 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
569
569
  - (BOOL)textInputShouldHandleDeleteForward:(__unused id)sender {
570
570
  return YES;
571
571
  }
572
+
573
+ - (void)textInputDidCancel {
574
+ [_eventDispatcher sendTextEventWithType:RCTTextEventTypeKeyPress
575
+ reactTag:self.reactTag
576
+ text:nil
577
+ key:@"Escape"
578
+ eventCount:_nativeEventCount];
579
+ [self textInputDidEndEditing];
580
+ }
572
581
  #endif // ]TODO(macOS GH#774)
573
582
 
574
583
  - (void)updateLocalData
@@ -66,13 +66,7 @@ export type TextProps = $ReadOnly<{|
66
66
  * Set hyphenation strategy on Android.
67
67
  *
68
68
  */
69
- android_hyphenationFrequency?: ?(
70
- | 'normal'
71
- | 'none'
72
- | 'full'
73
- | 'high'
74
- | 'balanced'
75
- ),
69
+ android_hyphenationFrequency?: ?('normal' | 'none' | 'full'),
76
70
  children?: ?Node,
77
71
 
78
72
  /**
@@ -16,7 +16,7 @@ const turboModuleProxy = global.__turboModuleProxy;
16
16
 
17
17
  function requireModule<T: TurboModule>(name: string): ?T {
18
18
  // Bridgeless mode requires TurboModules
19
- if (!global.RN$Bridgeless) {
19
+ if (global.RN$Bridgeless !== true) {
20
20
  // Backward compatibility layer during migration.
21
21
  const legacyModule = NativeModules[name];
22
22
  if (legacyModule != null) {
@@ -0,0 +1,23 @@
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
+ * @flow strict
8
+ * @format
9
+ */
10
+
11
+ <<<<<<< HEAD
12
+ export type {RootTag} from '../ReactNative/RootTag';
13
+ =======
14
+ <<<<<<< HEAD:Libraries/Components/DatePicker/DatePickerIOS.macos.js
15
+ // TODO(macOS GH#774)
16
+
17
+ 'use strict';
18
+
19
+ module.exports = require('../UnimplementedViews/UnimplementedView');
20
+ =======
21
+ export type {RootTag} from '../ReactNative/RootTag';
22
+ >>>>>>> facebook/0.66-stable:Libraries/Types/RootTagTypes.js
23
+ >>>>>>> facebook/0.66-stable
@@ -119,7 +119,7 @@ const HMRClient: HMRClientNativeInterface = {
119
119
  JSON.stringify({
120
120
  type: 'log',
121
121
  level,
122
- mode: global.RN$Bridgeless ? 'NOBRIDGE' : 'BRIDGE',
122
+ mode: global.RN$Bridgeless === true ? 'NOBRIDGE' : 'BRIDGE',
123
123
  data: data.map(item =>
124
124
  typeof item === 'string'
125
125
  ? item
@@ -540,10 +540,33 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
540
540
  // ]TODO(macOS ISS#2323203)
541
541
  }
542
542
 
543
+ // [TODO(macOS GH#774)
544
+ // We've seen a rare ASan crash where _inputStream seems to be invalid. This is just a safety check.
545
+ #if DEBUG
546
+ [self _validateStream:_outputStream name:@"_outputStream"];
547
+ [self _validateStream:_inputStream name:@"_inputStream"];
548
+ #endif
549
+ // ]TODO(macOS GH#774)
550
+
543
551
  [_outputStream open];
544
552
  [_inputStream open];
545
553
  }
546
554
 
555
+ // [TODO(macOS GH#774)
556
+ #if DEBUG
557
+ - (void)_validateStream:(NSStream *)stream name:(NSString *)name {
558
+ NSStreamStatus status = stream.streamStatus;
559
+ if (status != NSStreamStatusNotOpen) {
560
+ RCTLogWarn(@"%@ was already opened, why are we opening it again? status=%@", name, @(status));
561
+ }
562
+
563
+ if (stream.delegate == nil) {
564
+ RCTLogError(@"%@'s delegate is nil, did we clean it up too early?", name);
565
+ }
566
+ }
567
+ #endif
568
+ // ]TODO(macOS GH#774)
569
+
547
570
  - (void)scheduleInRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode
548
571
  {
549
572
  [_outputStream scheduleInRunLoop:aRunLoop forMode:mode];
package/README.md CHANGED
@@ -16,11 +16,11 @@
16
16
  </a>
17
17
  </p>
18
18
 
19
- > See the official [React Native website](https://reactnative.dev/) for an introduction to React Native.
19
+ > See the official [React Native website](https://reactnative.dev/) for an introduction to React Native.
20
20
 
21
21
  [React Native](https://reactnative.dev) is a framework developed by Facebook that enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and [React](https://reactjs.org/). The focus of React Native is on developer efficiency across all the platforms you care about - learn once, write anywhere.
22
22
 
23
- This repository is a working fork of **facebook/react-native** that adds support for the official React Native for macOS implementation from Microsoft.
23
+ This repository is a working fork of **facebook/react-native** that adds support for the official React Native for macOS implementation from Microsoft.
24
24
 
25
25
  [hello-world]: https://snack.expo.io/@hramos/hello,-world!
26
26
  [new-app]: https://reactnative.dev/docs/getting-started
@@ -28,69 +28,44 @@ This repository is a working fork of **facebook/react-native** that adds support
28
28
 
29
29
  You can read more about the macOS implementation in our website - [React Native for Windows + macOS](https://microsoft.github.io/react-native-windows/)
30
30
 
31
- The full documentation for React Native can be found on our [website][docs].
32
-
33
- The React Native documentation discusses components, APIs, and topics that are specific to React Native. For further documentation on the React API that is shared between React Native and React DOM, refer to the [React documentation][r-docs].
34
-
35
- The source for the React Native documentation and website is hosted on a separate repo, [**@facebook/react-native-website**][repo-website].
36
-
37
- [docs]: https://reactnative.dev/docs/getting-started
38
- [r-docs]: https://reactjs.org/docs/getting-started.html
39
- [repo-website]: https://github.com/facebook/react-native-website
40
-
41
- ## 🚀 Upgrading
42
-
43
- Upgrading to new versions of React Native may give you access to more APIs, views, developer tools, and other goodies. See the [Upgrading Guide][u] for instructions.
44
-
45
- React Native releases are discussed in the React Native Community, [**@react-native-community/react-native-releases**][repo-releases].
46
-
47
- [u]: https://reactnative.dev/docs/upgrading
48
- [repo-releases]: https://github.com/react-native-community/react-native-releases
49
-
50
- ## 👏 How to Contribute
51
-
52
- You can read more about the macOS implementation on our website - [React Native for Windows + macOS](https://microsoft.github.io/react-native-windows/)
53
-
54
- ## Contents
55
-
56
- - [Requirements](#requirements)
57
- - [Getting Started](#getting-started)
58
- - [Contributing](#contributing)
59
- - [Documentation](#documentation)
60
- - [License](#license)
61
- - [Code of Conduct](#code-of-conduct)
62
-
63
31
  ## Requirements
64
32
 
65
- You can run React Native for macOS apps on Mac devices with versions Mojave (10.14) or newer.
33
+ You can run React Native for macOS apps on Mac devices with versions Catalina (10.15) or newer.
66
34
 
67
35
  For a full and detailed list of the system requirements and how to set up your development platform, see our [System Requirements](https://microsoft.github.io/react-native-windows/docs/rnm-dependencies) documentation on our website.
68
36
 
69
37
  ## Getting Started
38
+
70
39
  See the [Getting Started Guide](https://microsoft.github.io/react-native-windows/docs/rnm-getting-started) on our React Native for Windows + macOS website to build your first React Native for macOS app.
71
40
 
72
41
  ### Logging Issues
42
+
73
43
  Search the [existing issues](https://github.com/microsoft/react-native-macos/issues) and try to make sure your problem doesn’t already exist before opening a new issue. If your issue doesn't exist yet, try to make sure you provide as much information as possible to us so we can help you sooner. It’s helpful if you include information like:
74
44
 
75
45
  - The version of macOS, React Native, React Native macOS extension where you ran into the issue.
76
46
  - A stack trace and reduced repro case when possible.
77
47
  - Ensure the [appropriate template](https://github.com/microsoft/react-native-macos/issues/new/choose) is used when filing your issue(s).
78
48
 
79
- ## Contributing
49
+ ## Contributing
50
+
80
51
  See [Contributing guidelines](https://github.com/microsoft/react-native-macos/blob/master/CONTRIBUTING.md) for how to set up your fork of the repo and start a PR to contribute to React Native for macOS.
81
52
 
82
53
  [Good First Issue](https://github.com/microsoft/react-native-macos/labels/good%20first%20issue) and [help wanted](https://github.com/microsoft/react-native-macos/labels/help%20wanted) are great starting points for PRs.
83
54
 
84
55
  ## Documentation
85
- [React Native already has great documentation](https://reactnative.dev/docs/getting-started) and we're working to ensure the React Native for Windows + macOS are part of that documentation story.
56
+
57
+ The full documentation for React Native can be found on the [documentation website][docs]. The React Native documentation discusses components, APIs, and topics that are specific to React Native. For further documentation on the React API that is shared between React Native and React DOM, refer to the [React documentation][r-docs].
58
+
59
+ The source for the React Native documentation and website is hosted on a separate repo, [**@facebook/react-native-website**][repo-website].
86
60
 
87
61
  [React Native for Windows + macOS](https://microsoft.github.io/react-native-windows/) has its own separate documentation site where Windows and macOS
88
- specific information, like API docs and blog updates live. We are bootstrapping documentation for macOS at this time, tune in for updates.
62
+ specific information, like API docs and blog updates live. We are still working on the documentation for macOS, contributions are welcome!
63
+
64
+ If you're looking for sample code, just browse the [RNTester folder](https://github.com/microsoft/react-native-macos/tree/master/packages/rn-tester) for examples
89
65
 
90
- ### Examples
66
+ ### Git flow and syncing with upstream
91
67
 
92
- - Using the CLI in the [Getting Started](https://microsoft.github.io/react-native-windows/docs/rnm-getting-started) guide will set you up with a sample React Native for macOS app that you can begin editing right away.
93
- - If you're looking for sample code, just browse the [RNTester folder](https://github.com/microsoft/react-native-macos/tree/master/packages/rn-tester) for examples
68
+ For more details on how this fork handles keeping up with upstream, and how the general git flow works, check out [this dedicated document](./docs/GitFlow.md).
94
69
 
95
70
  ## License
96
71
 
@@ -100,5 +75,6 @@ The React Native for macOS extension, including modifications to the original Fa
100
75
 
101
76
  This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
102
77
 
103
- [l]: https://github.com/facebook/react-native/blob/HEAD/LICENSE
104
- [ld]: https://github.com/facebook/react-native/blob/HEAD/LICENSE-docs
78
+ [docs]: https://reactnative.dev/docs/getting-started
79
+ [r-docs]: https://reactjs.org/docs/getting-started.html
80
+ [repo-website]: https://github.com/facebook/react-native-website
@@ -441,7 +441,7 @@ typedef NSURL * (^RCTBridgelessBundleURLGetter)(void);
441
441
  andSetter:(RCTBridgelessBundleURLSetter)setter
442
442
  andDefaultGetter:(RCTBridgelessBundleURLGetter)defaultGetter;
443
443
  - (void)resetBundleURL;
444
- @property NSURL *bundleURL;
444
+ @property (strong) NSURL *bundleURL; // TODO(macOS GH#774)
445
445
  @end
446
446
 
447
447
  typedef RCTPlatformView * (^RCTBridgelessComponentViewProvider)(NSNumber *); // TODO(macOS GH#774)