not-react-native-macos 0.87.1-rc.1 → 0.87.1-rc.10

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 (137) hide show
  1. package/Libraries/Alert/RCTAlertManager.macos.js +21 -0
  2. package/Libraries/AppState/AppState.js +5 -1
  3. package/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.macos.js +23 -0
  4. package/Libraries/Components/Button.js +2 -1
  5. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.macos.js +23 -0
  6. package/Libraries/Components/Keyboard/Keyboard.js +5 -1
  7. package/Libraries/Components/ScrollView/ScrollView.js +5 -1
  8. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +8 -0
  9. package/Libraries/Components/TextInput/TextInput.js +7 -2
  10. package/Libraries/Components/TextInput/TextInputState.js +9 -3
  11. package/Libraries/Components/ToastAndroid/ToastAndroid.macos.js +23 -0
  12. package/Libraries/Components/View/ViewPropTypes.js +158 -0
  13. package/Libraries/EventEmitter/NativeEventEmitter.js +6 -1
  14. package/Libraries/Image/Image.macos.js +23 -0
  15. package/Libraries/Linking/Linking.js +6 -1
  16. package/Libraries/Modal/Modal.js +5 -1
  17. package/Libraries/NativeComponent/BaseViewConfig.macos.js +87 -0
  18. package/Libraries/NativeComponent/ViewConfigIgnore.js +5 -1
  19. package/Libraries/Network/RCTNetworking.macos.js +23 -0
  20. package/Libraries/Pressability/HoverState.js +5 -0
  21. package/Libraries/PushNotificationIOS/PushNotificationIOS.js +5 -1
  22. package/Libraries/ReactNative/PaperUIManager.js +2 -1
  23. package/Libraries/Settings/Settings.macos.js +33 -0
  24. package/Libraries/StyleSheet/PlatformColorValueTypes.macos.js +158 -0
  25. package/Libraries/StyleSheet/PlatformColorValueTypesMacOS.js +34 -0
  26. package/Libraries/StyleSheet/PlatformColorValueTypesMacOS.macos.js +55 -0
  27. package/Libraries/Text/TextNativeComponent.js +7 -0
  28. package/Libraries/Text/TextProps.js +13 -0
  29. package/Libraries/Types/CoreEventTypes.js +11 -0
  30. package/Libraries/Utilities/BackHandler.macos.js +23 -0
  31. package/Libraries/Utilities/DevSettings.js +5 -1
  32. package/Libraries/Utilities/HMRClient.js +4 -2
  33. package/Libraries/Utilities/Platform.macos.js +90 -0
  34. package/Libraries/WebSocket/WebSocket.js +5 -1
  35. package/Libraries/WebSocket/WebSocketInterceptor.js +5 -1
  36. package/React/Base/RCTConvert.mm +49 -0
  37. package/React/Base/RCTRootView.h +1 -1
  38. package/React/Base/RCTTextView.h +31 -0
  39. package/React/Base/RCTUIKit.h +121 -0
  40. package/React/Base/RCTUIKit.m +29 -0
  41. package/React/Base/Surface/RCTSurfaceView.h +1 -1
  42. package/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.h +1 -1
  43. package/React/CoreModules/RCTDevLoadingView.mm +1 -1
  44. package/React/CoreModules/RCTFPSGraph.h +1 -1
  45. package/React/CoreModules/RCTPerfMonitor.mm +1 -1
  46. package/React/CoreModules/RCTRedBox2Controller.mm +4 -4
  47. package/React/CoreModules/RCTRedBoxController.mm +2 -2
  48. package/React/CoreModules/React-CoreModules.podspec +0 -6
  49. package/React/DevSupport/RCTPausedInDebuggerOverlayController.mm +2 -2
  50. package/React/Fabric/Mounting/ComponentViews/InputAccessory/RCTInputAccessoryContentView.h +1 -1
  51. package/React/Fabric/Mounting/ComponentViews/InputAccessory/RCTInputAccessoryContentView.mm +1 -1
  52. package/React/Fabric/Mounting/ComponentViews/Modal/RCTFabricModalHostViewController.mm +1 -1
  53. package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +1 -1
  54. package/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm +1 -1
  55. package/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +1 -1
  56. package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.h +15 -1
  57. package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +477 -2
  58. package/React/Fabric/Mounting/RCTComponentViewDescriptor.h +1 -1
  59. package/React/Fabric/Mounting/RCTComponentViewRegistry.h +1 -1
  60. package/React/Modules/RCTRedBoxExtraDataViewController.m +1 -1
  61. package/React/React-RCTFabric.podspec +4 -0
  62. package/React/Views/RCTDebuggingOverlay.m +2 -2
  63. package/React/Views/RCTView.h +1 -1
  64. package/React/Views/RCTWrapperViewController.m +1 -1
  65. package/React-Core.podspec +0 -2
  66. package/ReactCommon/React-Fabric.podspec +9 -0
  67. package/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/HostPlatformTouch.h +16 -0
  68. package/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/HostPlatformViewEventEmitter.cpp +134 -0
  69. package/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/HostPlatformViewEventEmitter.h +48 -0
  70. package/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/HostPlatformViewEvents.h +64 -0
  71. package/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/HostPlatformViewProps.cpp +129 -0
  72. package/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/HostPlatformViewProps.h +84 -0
  73. package/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/HostPlatformViewTraitsInitializer.h +38 -0
  74. package/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/KeyEvent.h +100 -0
  75. package/ReactCommon/react/renderer/components/view/platform/macos/react/renderer/components/view/MouseEvent.h +81 -0
  76. package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.h +6 -0
  77. package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.mm +31 -0
  78. package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/PlatformColorParser.mm +34 -0
  79. package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/RCTPlatformColorUtils.mm +23 -0
  80. package/index.js +10 -0
  81. package/macos/UIKitCompat/RCTPlatformViewCompat.h +9 -4
  82. package/macos/UIKitCompat/React-UIKitCompat.podspec +10 -2
  83. package/macos/UIKitCompat/UIKit/UIAlertController.h +20 -3
  84. package/macos/UIKitCompat/UIKit/UIAlertController.m +4 -4
  85. package/macos/UIKitCompat/UIKit/UIApplicationDelegate.h +27 -1
  86. package/macos/UIKitCompat/UIKit/UIApplicationDelegate.m +1 -1
  87. package/macos/UIKitCompat/UIKit/UIColor.m +7 -1
  88. package/macos/UIKitCompat/UIKit/UIControls.h +59 -18
  89. package/macos/UIKitCompat/UIKit/UIControls.m +16 -16
  90. package/macos/UIKitCompat/UIKit/UIEvent.h +26 -1
  91. package/macos/UIKitCompat/UIKit/UIEvent.m +5 -2
  92. package/macos/UIKitCompat/UIKit/UIGraphics.h +20 -3
  93. package/macos/UIKitCompat/UIKit/UIGraphics.m +3 -3
  94. package/macos/UIKitCompat/UIKit/UIImage.m +4 -4
  95. package/macos/UIKitCompat/UIKit/UIKeyCommand.h +23 -4
  96. package/macos/UIKitCompat/UIKit/UIKeyCommand.m +4 -4
  97. package/macos/UIKitCompat/UIKit/UIKitDefines.h +17 -2
  98. package/macos/UIKitCompat/UIKit/UIPlatformGaps.h +23 -6
  99. package/macos/UIKitCompat/UIKit/UIPlatformGaps.m +21 -7
  100. package/macos/UIKitCompat/UIKit/UIScrollView.h +18 -3
  101. package/macos/UIKitCompat/UIKit/UIScrollView.m +2 -2
  102. package/macos/UIKitCompat/UIKit/UIStatusBar.h +14 -1
  103. package/macos/UIKitCompat/UIKit/UIStatusBar.m +1 -1
  104. package/macos/UIKitCompat/UIKit/UIText.h +90 -7
  105. package/macos/UIKitCompat/UIKit/UIText.m +681 -13
  106. package/macos/UIKitCompat/UIKit/UITouch.h +24 -0
  107. package/macos/UIKitCompat/UIKit/UITraitCollection.h +14 -1
  108. package/macos/UIKitCompat/UIKit/UITraitCollection.m +1 -1
  109. package/macos/UIKitCompat/UIKit/UIView.h +18 -5
  110. package/macos/UIKitCompat/UIKit/UIView.m +24 -6
  111. package/macos/UIKitCompat/UIKit/UIViewAnimation.h +23 -4
  112. package/macos/UIKitCompat/UIKit/UIViewAnimation.m +4 -4
  113. package/macos/UIKitCompat/UIKit/UIViewController.h +24 -0
  114. package/macos/UIKitCompat/UIKit/UIWindow.h +24 -0
  115. package/macos/UIKitCompat/macos-excludes.txt +12 -33
  116. package/macos/metro-config.js +47 -25
  117. package/macos/scripts/init.js +244 -0
  118. package/macos/template/Podfile +60 -0
  119. package/macos/template/README.md +51 -0
  120. package/macos/template/app/AppDelegate.h +12 -0
  121. package/macos/template/app/AppDelegate.mm +167 -0
  122. package/macos/template/app/Info.plist +33 -0
  123. package/macos/template/app/PrivacyInfo.xcprivacy +37 -0
  124. package/macos/template/app/__APP_NAME__.entitlements +8 -0
  125. package/macos/template/app/main.m +22 -0
  126. package/macos/template/generate-project.rb +42 -0
  127. package/macos/template/metro.config.js +21 -0
  128. package/package.json +3 -2
  129. package/scripts/cocoapods/autolinking.rb +11 -2
  130. package/scripts/cocoapods/codegen.rb +3 -1
  131. package/scripts/cocoapods/codegen_utils.rb +7 -2
  132. package/scripts/codegen/generate-artifacts-executor/generateRCTThirdPartyComponents.js +3 -1
  133. package/scripts/codegen/generate-artifacts-executor/index.js +52 -4
  134. package/scripts/codegen/templates/RCTThirdPartyComponentsProviderMM.template +22 -1
  135. package/src/private/animated/NativeAnimatedHelper.js +5 -1
  136. package/src/private/devsupport/rndevtools/ReactDevToolsSettingsManager.macos.js +17 -0
  137. package/src/private/specs_DEPRECATED/modules/NativeExceptionsManager.js +6 -1
@@ -0,0 +1,21 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and 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-local
8
+ * @format
9
+ */
10
+
11
+ // [macOS] macOS resolves as `.macos` -> `.native` -> shared, so without this
12
+ // file `RCTAlertManager` re-exports itself: the shared file is a
13
+ // stub that expects a platform-suffixed sibling to answer. Point it at the iOS
14
+ // implementation, which is what this fork uses on macOS wherever upstream has
15
+ // no platform-neutral one. macOS]
16
+
17
+ // NOTE: This file supports backwards compatibility of subpath (deep) imports
18
+ // from 'react-native' with platform-specific extensions. It can be deleted
19
+ // once we remove the "./*" mapping from package.json "exports".
20
+
21
+ export * from './RCTAlertManager.ios';
@@ -88,7 +88,11 @@ class AppStateImpl {
88
88
  new NativeEventEmitter(
89
89
  // T88715063: NativeEventEmitter only used this parameter on iOS. Now it uses it on all platforms, so this code was modified automatically to preserve its behavior
90
90
  // If you want to use the native module on other platforms, please remove this condition and test its behavior
91
- Platform.OS !== 'ios' ? null : NativeAppState,
91
+ // [macOS] macOS uses this parameter too: the module is an
92
+ // RCTEventEmitter subclass here, exactly as it is on iOS.
93
+ Platform.OS !== 'ios' && Platform.OS !== 'macos'
94
+ ? null
95
+ : NativeAppState,
92
96
  );
93
97
  this._emitter = emitter;
94
98
 
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and 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-local
8
+ * @format
9
+ */
10
+
11
+ // [macOS] macOS resolves as `.macos` -> `.native` -> shared, so without this
12
+ // file `legacySendAccessibilityEvent` re-exports itself: the shared file is a
13
+ // stub that expects a platform-suffixed sibling to answer. Point it at the iOS
14
+ // implementation, which is what this fork uses on macOS wherever upstream has
15
+ // no platform-neutral one. macOS]
16
+
17
+ // NOTE: This file supports backwards compatibility of subpath (deep) imports
18
+ // from 'react-native' with platform-specific extensions. It can be deleted
19
+ // once we remove the "./*" mapping from package.json "exports".
20
+
21
+ import legacySendAccessibilityEvent from './legacySendAccessibilityEvent.ios';
22
+
23
+ export default legacySendAccessibilityEvent;
@@ -234,7 +234,8 @@ const Button: component(
234
234
  const buttonStyles: Array<ViewStyleProp> = [styles.button];
235
235
  const textStyles: Array<TextStyleProp> = [styles.text];
236
236
  if (color) {
237
- if (Platform.OS === 'ios') {
237
+ // [macOS] Apple platforms tint the label; Android tints the background.
238
+ if (Platform.OS === 'ios' || Platform.OS === 'macos') {
238
239
  textStyles.push({color: color});
239
240
  } else {
240
241
  buttonStyles.push({backgroundColor: color});
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and 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-local
8
+ * @format
9
+ */
10
+
11
+ // [macOS] macOS resolves as `.macos` -> `.native` -> shared, so without this
12
+ // file `DrawerLayoutAndroid` re-exports itself: the shared file is a
13
+ // stub that expects a platform-suffixed sibling to answer. Point it at the iOS
14
+ // implementation, which is what this fork uses on macOS wherever upstream has
15
+ // no platform-neutral one. macOS]
16
+
17
+ // NOTE: This file supports backwards compatibility of subpath (deep) imports
18
+ // from 'react-native' with platform-specific extensions. It can be deleted
19
+ // once we remove the "./*" mapping from package.json "exports".
20
+
21
+ import DrawerLayoutAndroid from './DrawerLayoutAndroid.ios';
22
+
23
+ export default DrawerLayoutAndroid;
@@ -77,7 +77,11 @@ class KeyboardImpl {
77
77
  new NativeEventEmitter(
78
78
  // T88715063: NativeEventEmitter only used this parameter on iOS. Now it uses it on all platforms, so this code was modified automatically to preserve its behavior
79
79
  // If you want to use the native module on other platforms, please remove this condition and test its behavior
80
- Platform.OS !== 'ios' ? null : NativeKeyboardObserver,
80
+ // [macOS] macOS uses this parameter too: the module is an
81
+ // RCTEventEmitter subclass here, exactly as it is on iOS.
82
+ Platform.OS !== 'ios' && Platform.OS !== 'macos'
83
+ ? null
84
+ : NativeKeyboardObserver,
81
85
  );
82
86
 
83
87
  constructor() {
@@ -1101,7 +1101,11 @@ class ScrollView extends React.Component<ScrollViewProps, ScrollViewState> {
1101
1101
  },
1102
1102
  animated?: boolean, // deprecated, put this inside the rect argument instead
1103
1103
  ) => {
1104
- invariant(Platform.OS === 'ios', 'zoomToRect is not implemented');
1104
+ // [macOS] The AppKit scroll view zooms as well.
1105
+ invariant(
1106
+ Platform.OS === 'ios' || Platform.OS === 'macos',
1107
+ 'zoomToRect is not implemented',
1108
+ );
1105
1109
  if ('animated' in rect) {
1106
1110
  this._animated = rect.animated;
1107
1111
  delete rect.animated;
@@ -91,6 +91,14 @@ const RCTTextInputViewConfig: PartialViewConfigWithoutName = {
91
91
  },
92
92
  },
93
93
  validAttributes: {
94
+ // [macOS] TextInput is a view too: BaseTextInputProps derives from
95
+ // ViewProps, which on macOS is already HostPlatformViewProps. The props
96
+ // were being parsed and then dropped for want of an entry here.
97
+ tooltip: true,
98
+ enableFocusRing: true,
99
+ keyDownEvents: true,
100
+ keyUpEvents: true,
101
+ // macOS]
94
102
  acceptDragAndDropTypes: true,
95
103
  dynamicTypeRamp: true,
96
104
  fontSize: true,
@@ -75,7 +75,11 @@ if (Platform.OS === 'android') {
75
75
  AndroidTextInput = require('./AndroidTextInputNativeComponent').default;
76
76
  AndroidTextInputCommands =
77
77
  require('./AndroidTextInputNativeComponent').Commands;
78
- } else if (Platform.OS === 'ios') {
78
+ // [macOS] macOS uses the same two Apple-platform components. Without this
79
+ // branch neither module is ever required, both locals stay undefined, and
80
+ // the render below -- also gated on `ios` -- returns nothing at all: a
81
+ // TextInput silently renders as empty space, with no error anywhere.
82
+ } else if (Platform.OS === 'ios' || Platform.OS === 'macos') {
79
83
  RCTSinglelineTextInputView =
80
84
  require('./RCTSingelineTextInputNativeComponent').default;
81
85
  RCTSinglelineTextInputNativeCommands =
@@ -564,7 +568,8 @@ function InternalTextInput(props: TextInputProps): React.Node {
564
568
  }
565
569
  }
566
570
 
567
- if (Platform.OS === 'ios') {
571
+ // [macOS] The Apple-platform render path; see the require above.
572
+ if (Platform.OS === 'ios' || Platform.OS === 'macos') {
568
573
  const RCTTextInputView =
569
574
  props.multiline === true
570
575
  ? RCTMultilineTextInputView
@@ -87,7 +87,9 @@ function focusTextInput(textField: ?HostInstance) {
87
87
 
88
88
  if (textField != null) {
89
89
  const fieldCanBeFocused =
90
- currentlyFocusedInputRef !== textField &&
90
+ // [macOS] On a desktop any view can hold focus, so the currently focused
91
+ // *input* is not a reliable answer to whether this field already has it.
92
+ (Platform.OS === 'macos' || currentlyFocusedInputRef !== textField) &&
91
93
  // $FlowFixMe[prop-missing] - `currentProps` is missing in `NativeMethods`
92
94
  textField.currentProps?.editable !== false;
93
95
 
@@ -95,7 +97,9 @@ function focusTextInput(textField: ?HostInstance) {
95
97
  return;
96
98
  }
97
99
  focusInput(textField);
98
- if (Platform.OS === 'ios') {
100
+ // [macOS] The commands are declared by the Apple-platform native
101
+ // components, which macOS shares.
102
+ if (Platform.OS === 'ios' || Platform.OS === 'macos') {
99
103
  // This isn't necessarily a single line text input
100
104
  // But commands don't actually care as long as the thing being passed in
101
105
  // actually has a command with that name. So this should work with single
@@ -126,7 +130,9 @@ function blurTextInput(textField: ?HostInstance) {
126
130
 
127
131
  if (currentlyFocusedInputRef === textField && textField != null) {
128
132
  blurInput(textField);
129
- if (Platform.OS === 'ios') {
133
+ // [macOS] The commands are declared by the Apple-platform native
134
+ // components, which macOS shares.
135
+ if (Platform.OS === 'ios' || Platform.OS === 'macos') {
130
136
  // This isn't necessarily a single line text input
131
137
  // But commands don't actually care as long as the thing being passed in
132
138
  // actually has a command with that name. So this should work with single
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and 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-local
8
+ * @format
9
+ */
10
+
11
+ // [macOS] macOS resolves as `.macos` -> `.native` -> shared, so without this
12
+ // file `ToastAndroid` re-exports itself: the shared file is a
13
+ // stub that expects a platform-suffixed sibling to answer. Point it at the iOS
14
+ // implementation, which is what this fork uses on macOS wherever upstream has
15
+ // no platform-neutral one. macOS]
16
+
17
+ // NOTE: This file supports backwards compatibility of subpath (deep) imports
18
+ // from 'react-native' with platform-specific extensions. It can be deleted
19
+ // once we remove the "./*" mapping from package.json "exports".
20
+
21
+ import ToastAndroid from './ToastAndroid.ios';
22
+
23
+ export default ToastAndroid;
@@ -22,6 +22,7 @@ import type {
22
22
  LayoutChangeEvent,
23
23
  LayoutRectangle,
24
24
  MouseEvent,
25
+ NativeSyntheticEvent, // [macOS] DragEvent below is built on it
25
26
  PointerEvent,
26
27
  } from '../../Types/CoreEventTypes';
27
28
  import type {
@@ -128,6 +129,162 @@ type FocusEventProps = Readonly<{
128
129
  onFocusCapture?: ?(event: FocusEvent) => void,
129
130
  }>;
130
131
 
132
+ // [macOS] Props that only exist on macOS. They are declared here rather than in
133
+ // a .macos file because ViewPropTypes is shared, and a prop that is simply
134
+ // absent on other platforms costs them nothing. The native side is
135
+ // HostPlatformViewProps under components/view/platform/macos. macOS]
136
+ /**
137
+ * A key the view means to act on itself. A modifier left out is a wildcard:
138
+ * `{key: 'c'}` matches Cmd-C and a bare c alike.
139
+ *
140
+ * @platform macos
141
+ */
142
+ export type HandledKeyEvent = Readonly<{
143
+ key: string,
144
+ altKey?: ?boolean,
145
+ ctrlKey?: ?boolean,
146
+ metaKey?: ?boolean,
147
+ shiftKey?: ?boolean,
148
+ }>;
149
+
150
+ /**
151
+ * A dragged file, or dragged image data with no file behind it -- in which case
152
+ * `uri` is a data: URL rather than a path.
153
+ *
154
+ * @platform macos
155
+ */
156
+ export type DataTransferFile = Readonly<{
157
+ name: string,
158
+ type: string,
159
+ uri: string,
160
+ size?: number,
161
+ width?: number,
162
+ height?: number,
163
+ }>;
164
+
165
+ /**
166
+ * The pasteboard contents of a drag, shaped like the DOM DataTransfer.
167
+ *
168
+ * @platform macos
169
+ */
170
+ export type DataTransfer = Readonly<{
171
+ files: $ReadOnlyArray<DataTransferFile>,
172
+ items: $ReadOnlyArray<Readonly<{kind: string, type: string}>>,
173
+ types: $ReadOnlyArray<string>,
174
+ }>;
175
+
176
+ export type DragEvent = NativeSyntheticEvent<
177
+ Readonly<{
178
+ clientX: number,
179
+ clientY: number,
180
+ pageX: number,
181
+ pageY: number,
182
+ screenX: number,
183
+ screenY: number,
184
+ altKey: boolean,
185
+ ctrlKey: boolean,
186
+ metaKey: boolean,
187
+ shiftKey: boolean,
188
+ button: number,
189
+ dataTransfer: DataTransfer,
190
+ }>,
191
+ >;
192
+
193
+ type MacOSViewProps = Readonly<{
194
+ /**
195
+ * What kinds of dragged content the view accepts: 'fileUrl', 'image',
196
+ * 'string'. Required for the drag handlers to fire at all -- AppKit routes a
197
+ * drag only to views that registered for one of the pasteboard types it
198
+ * carries.
199
+ *
200
+ * @platform macos
201
+ */
202
+ draggedTypes?: ?$ReadOnlyArray<'fileUrl' | 'image' | 'string'>,
203
+
204
+ /**
205
+ * Called as a drag enters, leaves, or is released over the view.
206
+ *
207
+ * @platform macos
208
+ */
209
+ onDragEnter?: ?(event: DragEvent) => void,
210
+
211
+ /** @platform macos */
212
+ onDragLeave?: ?(event: DragEvent) => void,
213
+
214
+ /** @platform macos */
215
+ onDrop?: ?(event: DragEvent) => void,
216
+
217
+ /**
218
+ * Keys this view handles itself, suppressing AppKit's own interpretation of
219
+ * them -- Tab moving focus, Escape cancelling, an unclaimed key beeping.
220
+ *
221
+ * Separate from `onKeyDown`, deliberately: listening to a key does not change
222
+ * what it does, so a view that observes Tab still lets Tab move focus. Only
223
+ * listing a key here claims it.
224
+ *
225
+ * @platform macos
226
+ */
227
+ keyDownEvents?: ?$ReadOnlyArray<HandledKeyEvent>,
228
+
229
+ /**
230
+ * As `keyDownEvents`, for key release.
231
+ *
232
+ * @platform macos
233
+ */
234
+ keyUpEvents?: ?$ReadOnlyArray<HandledKeyEvent>,
235
+
236
+ /**
237
+ * The view's help tag, shown when the pointer rests over it.
238
+ *
239
+ * @platform macos
240
+ */
241
+ tooltip?: ?string,
242
+
243
+ /**
244
+ * Receive the click that activates a background window, rather than letting
245
+ * it be swallowed to bring the window forward.
246
+ *
247
+ * @platform macos
248
+ */
249
+ acceptsFirstMouse?: ?boolean,
250
+
251
+ /**
252
+ * Let the view blend with what is behind it when inside a vibrancy effect.
253
+ *
254
+ * @platform macos
255
+ */
256
+ allowsVibrancy?: ?boolean,
257
+
258
+ /**
259
+ * Draw the focus ring while the view is first responder. Defaults to true.
260
+ *
261
+ * @platform macos
262
+ */
263
+ enableFocusRing?: ?boolean,
264
+
265
+ /**
266
+ * Whether dragging the view moves the window. AppKit defaults this to true;
267
+ * set it false for a view that should handle its own drags.
268
+ *
269
+ * @platform macos
270
+ */
271
+ mouseDownCanMoveWindow?: ?boolean,
272
+
273
+ /**
274
+ * Called on a double click.
275
+ *
276
+ * @platform macos
277
+ */
278
+ onDoubleClick?: ?(event: MouseEvent) => void,
279
+
280
+ /**
281
+ * Called on a secondary (right) click.
282
+ *
283
+ * @platform macos
284
+ */
285
+ onAuxClick?: ?(event: MouseEvent) => void,
286
+ }>;
287
+
131
288
  type KeyEventProps = Readonly<{
132
289
  onKeyDown?: ?(event: KeyDownEvent) => void,
133
290
  onKeyDownCapture?: ?(event: KeyDownEvent) => void,
@@ -566,6 +723,7 @@ export type ViewProps = Readonly<{
566
723
  ...DirectEventProps,
567
724
  ...GestureResponderHandlers,
568
725
  ...MouseEventProps,
726
+ ...MacOSViewProps, // [macOS]
569
727
  ...PointerEventProps,
570
728
  ...FocusEventProps,
571
729
  ...KeyEventProps,
@@ -71,7 +71,12 @@ export default class NativeEventEmitter<
71
71
  * an invariant error if undefined.
72
72
  */
73
73
  constructor(nativeModule?: ?NativeModule) {
74
- if (Platform.OS === 'ios') {
74
+ // [macOS] Same requirement on macOS: the module backing the emitter is an
75
+ // RCTEventEmitter subclass here too, so a null one is a bug rather than a
76
+ // platform difference. This only holds because the callers that used to
77
+ // pass `Platform.OS !== 'ios' ? null : NativeX` now pass the module on
78
+ // macOS as well -- widening this without those is an import-time crash.
79
+ if (Platform.OS === 'ios' || Platform.OS === 'macos') {
75
80
  invariant(
76
81
  nativeModule != null,
77
82
  '`new NativeEventEmitter()` requires a non-null argument.',
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and 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-local
8
+ * @format
9
+ */
10
+
11
+ // [macOS] macOS resolves as `.macos` -> `.native` -> shared, so without this
12
+ // file `Image` re-exports itself: the shared file is a
13
+ // stub that expects a platform-suffixed sibling to answer. Point it at the iOS
14
+ // implementation, which is what this fork uses on macOS wherever upstream has
15
+ // no platform-neutral one. macOS]
16
+
17
+ // NOTE: This file supports backwards compatibility of subpath (deep) imports
18
+ // from 'react-native' with platform-specific extensions. It can be deleted
19
+ // once we remove the "./*" mapping from package.json "exports".
20
+
21
+ import Image from './Image.ios';
22
+
23
+ export default Image;
@@ -23,7 +23,12 @@ type LinkingEventDefinitions = {
23
23
 
24
24
  class LinkingImpl extends NativeEventEmitter<LinkingEventDefinitions> {
25
25
  constructor() {
26
- super(Platform.OS === 'ios' ? nullthrows(NativeLinkingManager) : undefined);
26
+ // [macOS] RCTLinkingManager is built for macOS too.
27
+ super(
28
+ Platform.OS === 'ios' || Platform.OS === 'macos'
29
+ ? nullthrows(NativeLinkingManager)
30
+ : undefined,
31
+ );
27
32
  }
28
33
 
29
34
  /**
@@ -43,7 +43,11 @@ const ModalEventEmitter =
43
43
  ? new NativeEventEmitter<ModalEventDefinitions>(
44
44
  // T88715063: NativeEventEmitter only used this parameter on iOS. Now it uses it on all platforms, so this code was modified automatically to preserve its behavior
45
45
  // If you want to use the native module on other platforms, please remove this condition and test its behavior
46
- Platform.OS !== 'ios' ? null : NativeModalManager,
46
+ // [macOS] macOS uses this parameter too: the module is an
47
+ // RCTEventEmitter subclass here, exactly as it is on iOS.
48
+ Platform.OS !== 'ios' && Platform.OS !== 'macos'
49
+ ? null
50
+ : NativeModalManager,
47
51
  )
48
52
  : null;
49
53
 
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and 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-local
8
+ * @format
9
+ */
10
+
11
+ // [macOS] The view config decides which props reach native at all: anything
12
+ // missing from `validAttributes` is dropped before it ever gets to C++. So the
13
+ // macOS-only props declared in HostPlatformViewProps have to be listed here as
14
+ // well, or setting them does nothing.
15
+ //
16
+ // Everything iOS declares still applies, so this extends that config rather
17
+ // than replacing it. Names match microsoft/react-native-macos. macOS]
18
+
19
+ import type {PartialViewConfigWithoutName} from './PlatformBaseViewConfig';
20
+
21
+ // $FlowFixMe[cannot-resolve-module] macOS shares the iOS base config.
22
+ import PlatformBaseViewConfigIOS from './BaseViewConfig.ios';
23
+ import {ConditionallyIgnoredEventHandlers} from './ViewConfigIgnore';
24
+
25
+ const bubblingEventTypes = {
26
+ ...PlatformBaseViewConfigIOS.bubblingEventTypes,
27
+ topKeyDown: {
28
+ phasedRegistrationNames: {
29
+ captured: 'onKeyDownCapture',
30
+ bubbled: 'onKeyDown',
31
+ },
32
+ },
33
+ topKeyUp: {
34
+ phasedRegistrationNames: {
35
+ captured: 'onKeyUpCapture',
36
+ bubbled: 'onKeyUp',
37
+ },
38
+ },
39
+ };
40
+
41
+ const directEventTypes = {
42
+ ...PlatformBaseViewConfigIOS.directEventTypes,
43
+ topDoubleClick: {registrationName: 'onDoubleClick'},
44
+ topAuxClick: {registrationName: 'onAuxClick'},
45
+ topMouseEnter: {registrationName: 'onMouseEnter'},
46
+ topMouseLeave: {registrationName: 'onMouseLeave'},
47
+ topDragEnter: {registrationName: 'onDragEnter'},
48
+ topDragLeave: {registrationName: 'onDragLeave'},
49
+ topDrop: {registrationName: 'onDrop'},
50
+ };
51
+
52
+ const validAttributesForNonEventProps = {
53
+ acceptsFirstMouse: true,
54
+ allowsVibrancy: true,
55
+ draggedTypes: true,
56
+ enableFocusRing: true,
57
+ focusable: true,
58
+ keyDownEvents: true,
59
+ keyUpEvents: true,
60
+ mouseDownCanMoveWindow: true,
61
+ tooltip: true,
62
+ };
63
+
64
+ const validAttributesForEventProps = ConditionallyIgnoredEventHandlers({
65
+ onAuxClick: true,
66
+ onDoubleClick: true,
67
+ onDragEnter: true,
68
+ onDragLeave: true,
69
+ onDrop: true,
70
+ onKeyDown: true,
71
+ onKeyUp: true,
72
+ onMouseEnter: true,
73
+ onMouseLeave: true,
74
+ });
75
+
76
+ const PlatformBaseViewConfigMacOS: PartialViewConfigWithoutName = {
77
+ bubblingEventTypes,
78
+ directEventTypes,
79
+ validAttributes: {
80
+ ...PlatformBaseViewConfigIOS.validAttributes,
81
+ ...validAttributesForNonEventProps,
82
+ // $FlowFixMe[exponential-spread]
83
+ ...validAttributesForEventProps,
84
+ },
85
+ };
86
+
87
+ export default PlatformBaseViewConfigMacOS;
@@ -39,7 +39,11 @@ export function DynamicallyInjectedByGestureHandler<T extends {...}>(
39
39
  export function ConditionallyIgnoredEventHandlers<
40
40
  const T extends {readonly [name: string]: true},
41
41
  >(value: T): T | void {
42
- if (Platform.OS === 'ios') {
42
+ // [macOS] macOS declares its view props the same way iOS does, so it keeps
43
+ // these too. Reporting Platform.OS as 'macos' without this drops every event
44
+ // handler in the base view config -- including iOS's own -- and nothing that
45
+ // depends on them ever fires. macOS]
46
+ if (Platform.OS === 'ios' || Platform.OS === 'macos') {
43
47
  return value;
44
48
  }
45
49
  return undefined;
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and 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-local
8
+ * @format
9
+ */
10
+
11
+ // [macOS] macOS resolves as `.macos` -> `.native` -> shared, so without this
12
+ // file `RCTNetworking` re-exports itself: the shared file is a
13
+ // stub that expects a platform-suffixed sibling to answer. Point it at the iOS
14
+ // implementation, which is what this fork uses on macOS wherever upstream has
15
+ // no platform-neutral one. macOS]
16
+
17
+ // NOTE: This file supports backwards compatibility of subpath (deep) imports
18
+ // from 'react-native' with platform-specific extensions. It can be deleted
19
+ // once we remove the "./*" mapping from package.json "exports".
20
+
21
+ import RCTNetworking from './RCTNetworking.ios';
22
+
23
+ export default RCTNetworking;
@@ -53,6 +53,11 @@ if (Platform.OS === 'web') {
53
53
  document.addEventListener('touchstart', disableHover, true);
54
54
  document.addEventListener('touchmove', disableHover, true);
55
55
  document.addEventListener('mousemove', enableHover, true);
56
+ // [macOS] A Mac always has a pointer, and unlike the web there is no touch
57
+ // input to disable hover for. Without this `onHoverIn` / `onHoverOut` never
58
+ // fire on Pressable, because Pressability checks this flag first.
59
+ } else if (Platform.OS === 'macos') {
60
+ isEnabled = true;
56
61
  }
57
62
  }
58
63
 
@@ -67,7 +67,11 @@ const PushNotificationEmitter =
67
67
  new NativeEventEmitter<NativePushNotificationIOSEventDefinitions>(
68
68
  // T88715063: NativeEventEmitter only used this parameter on iOS. Now it uses it on all platforms, so this code was modified automatically to preserve its behavior
69
69
  // If you want to use the native module on other platforms, please remove this condition and test its behavior
70
- Platform.OS !== 'ios' ? null : NativePushNotificationManagerIOS,
70
+ // [macOS] macOS uses this parameter too: the module is an
71
+ // RCTEventEmitter subclass here, exactly as it is on iOS.
72
+ Platform.OS !== 'ios' && Platform.OS !== 'macos'
73
+ ? null
74
+ : NativePushNotificationManagerIOS,
71
75
  );
72
76
 
73
77
  const _notifHandlers = new Map<string, void | EventSubscription>();
@@ -155,7 +155,8 @@ function lazifyViewManagerConfig(viewName: string) {
155
155
  * only needed for iOS, which puts the constants in the ViewManager
156
156
  * namespace instead of UIManager, unlike Android.
157
157
  */
158
- if (Platform.OS === 'ios') {
158
+ // [macOS] Apple platforms namespace view-manager constants the same way.
159
+ if (Platform.OS === 'ios' || Platform.OS === 'macos') {
159
160
  Object.keys(getConstants()).forEach(viewName => {
160
161
  lazifyViewManagerConfig(viewName);
161
162
  });
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and 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-local
8
+ * @format
9
+ */
10
+
11
+ // [macOS] macOS resolves as `.macos` -> `.native` -> shared, so without this
12
+ // file `Settings` re-exports itself: the shared file is a
13
+ // stub that expects a platform-suffixed sibling to answer. Point it at the iOS
14
+ // implementation, which is what this fork uses on macOS wherever upstream has
15
+ // no platform-neutral one. macOS]
16
+
17
+ import Platform from '../Utilities/Platform';
18
+
19
+ let Settings: {
20
+ get(key: string): any,
21
+ set(settings: Object): void,
22
+ watchKeys(keys: string | Array<string>, callback: () => void): number,
23
+ clearWatch(watchId: number): void,
24
+ ...
25
+ };
26
+
27
+ if (Platform.OS === 'ios') {
28
+ Settings = require('./Settings.ios').default;
29
+ } else {
30
+ Settings = require('./SettingsFallback').default;
31
+ }
32
+
33
+ export default Settings;