react-native-macos 0.0.0-081d66e4e → 0.0.0-08d0c3b4f

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 (84) hide show
  1. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -0
  2. package/Libraries/Components/TextInput/TextInput.js +77 -1
  3. package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
  4. package/Libraries/Core/ReactNativeVersion.js +1 -1
  5. package/Libraries/Image/RCTImageView.mm +14 -10
  6. package/Libraries/Lists/VirtualizedList.js +13 -1
  7. package/Libraries/Text/BaseText/RCTBaseTextViewManager.m +1 -0
  8. package/Libraries/Text/RCTTextAttributes.h +2 -0
  9. package/Libraries/Text/RCTTextAttributes.m +9 -0
  10. package/Libraries/Text/Text/RCTDynamicTypeRamp.h +40 -0
  11. package/Libraries/Text/Text/RCTDynamicTypeRamp.m +77 -0
  12. package/Libraries/Text/Text/RCTTextView.m +118 -47
  13. package/Libraries/Text/Text.js +0 -8
  14. package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.h +8 -0
  15. package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.m +57 -4
  16. package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputViewManager.m +13 -0
  17. package/Libraries/Text/TextInput/Multiline/RCTUITextView.h +2 -1
  18. package/Libraries/Text/TextInput/Multiline/RCTUITextView.m +36 -4
  19. package/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h +2 -0
  20. package/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m +6 -1
  21. package/Libraries/Text/TextInput/RCTBaseTextInputView.h +4 -1
  22. package/Libraries/Text/TextInput/RCTBaseTextInputView.m +57 -0
  23. package/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m +6 -1
  24. package/Libraries/Text/TextInput/Singleline/RCTUITextField.m +16 -0
  25. package/Libraries/Text/TextNativeComponent.js +2 -0
  26. package/Libraries/Text/TextProps.js +29 -0
  27. package/React/Base/RCTAssert.h +4 -3
  28. package/React/Base/RCTAssert.m +11 -2
  29. package/React/Base/RCTBridge.m +1 -1
  30. package/React/Base/RCTConstants.h +6 -0
  31. package/React/Base/RCTConstants.m +15 -0
  32. package/React/Base/RCTConvert.m +7 -4
  33. package/React/Base/RCTTouchHandler.m +4 -0
  34. package/React/Base/RCTUIKit.h +8 -13
  35. package/React/Base/RCTUtils.m +6 -3
  36. package/React/Base/RCTVersion.m +1 -1
  37. package/React/Base/macOS/RCTUIKit.m +33 -0
  38. package/React/CoreModules/RCTPerfMonitor.mm +1 -1
  39. package/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm +6 -2
  40. package/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm +2 -1
  41. package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm +1 -1
  42. package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +35 -9
  43. package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +8 -1
  44. package/React/Fabric/Mounting/RCTComponentViewFactory.mm +2 -2
  45. package/React/Fabric/Mounting/RCTMountingManager.h +1 -1
  46. package/React/Fabric/Mounting/RCTMountingManager.mm +10 -9
  47. package/React/Fabric/Mounting/RCTMountingTransactionObserverCoordinator.h +5 -3
  48. package/React/Fabric/Mounting/RCTMountingTransactionObserverCoordinator.mm +10 -8
  49. package/React/Fabric/Mounting/RCTMountingTransactionObserving.h +5 -3
  50. package/React/Fabric/RCTConversions.h +9 -1
  51. package/React/Fabric/RCTLocalizationProvider.mm +10 -4
  52. package/React/Fabric/RCTScheduler.h +5 -0
  53. package/React/Fabric/RCTScheduler.mm +10 -0
  54. package/React/Fabric/RCTSurfacePresenter.h +2 -0
  55. package/React/Fabric/RCTSurfacePresenter.mm +12 -11
  56. package/React/Fabric/RCTSurfaceTouchHandler.mm +0 -1
  57. package/React/React-RCTFabric.podspec +1 -1
  58. package/React/Views/RCTView.h +1 -0
  59. package/React/Views/RCTView.m +47 -16
  60. package/React/Views/RCTViewManager.m +1 -1
  61. package/React/Views/ScrollView/RCTScrollView.m +1 -1
  62. package/ReactAndroid/gradle.properties +1 -1
  63. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
  64. package/ReactCommon/React-Fabric.podspec +1 -1
  65. package/ReactCommon/React-rncore.podspec +1 -1
  66. package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
  67. package/ReactCommon/react/renderer/core/EventDispatcher.cpp +21 -0
  68. package/ReactCommon/react/renderer/core/EventDispatcher.h +15 -0
  69. package/ReactCommon/react/renderer/core/EventListener.cpp +39 -0
  70. package/ReactCommon/react/renderer/core/EventListener.h +44 -0
  71. package/ReactCommon/react/renderer/graphics/React-graphics.podspec +1 -1
  72. package/ReactCommon/react/renderer/mounting/TelemetryController.cpp +6 -9
  73. package/ReactCommon/react/renderer/mounting/TelemetryController.h +7 -7
  74. package/ReactCommon/react/renderer/scheduler/Scheduler.cpp +14 -0
  75. package/ReactCommon/react/renderer/scheduler/Scheduler.h +6 -0
  76. package/ReactCommon/react/utils/ManagedObjectWrapper.h +1 -1
  77. package/ReactCommon/react/utils/ManagedObjectWrapper.mm +1 -3
  78. package/package.json +1 -1
  79. package/scripts/react_native_pods.rb +0 -3
  80. package/template/Gemfile.lock +4 -4
  81. package/template/package.json +1 -1
  82. package/ReactCommon/react/renderer/mounting/MountingTransactionMetadata.cpp +0 -12
  83. package/ReactCommon/react/renderer/mounting/MountingTransactionMetadata.h +0 -32
  84. package/third-party-podspecs/boost-for-react-native.podspec +0 -20
@@ -82,7 +82,6 @@ static BackgroundExecutor RCTGetBackgroundExecutor()
82
82
  butter::shared_mutex _observerListMutex;
83
83
  NSMutableArray<id<RCTSurfacePresenterObserver>> *_observers;
84
84
  RCTImageLoader *_imageLoader;
85
- RuntimeExecutor _runtimeExecutor;
86
85
  }
87
86
 
88
87
  - (instancetype)initWithContextContainer:(ContextContainer::Shared)contextContainer
@@ -111,7 +110,7 @@ static BackgroundExecutor RCTGetBackgroundExecutor()
111
110
  return _mountingManager;
112
111
  }
113
112
 
114
- - (RCTScheduler *_Nullable)_scheduler
113
+ - (RCTScheduler *_Nullable)scheduler
115
114
  {
116
115
  std::lock_guard<std::mutex> lock(_schedulerAccessMutex);
117
116
  return _scheduler;
@@ -147,7 +146,7 @@ static BackgroundExecutor RCTGetBackgroundExecutor()
147
146
  - (void)registerSurface:(RCTFabricSurface *)surface
148
147
  {
149
148
  [_surfaceRegistry registerSurface:surface];
150
- RCTScheduler *scheduler = [self _scheduler];
149
+ RCTScheduler *scheduler = [self scheduler];
151
150
  if (scheduler) {
152
151
  [scheduler registerSurface:surface.surfaceHandler];
153
152
  }
@@ -155,7 +154,7 @@ static BackgroundExecutor RCTGetBackgroundExecutor()
155
154
 
156
155
  - (void)unregisterSurface:(RCTFabricSurface *)surface
157
156
  {
158
- RCTScheduler *scheduler = [self _scheduler];
157
+ RCTScheduler *scheduler = [self scheduler];
159
158
  if (scheduler) {
160
159
  [scheduler unregisterSurface:surface.surfaceHandler];
161
160
  }
@@ -176,7 +175,7 @@ static BackgroundExecutor RCTGetBackgroundExecutor()
176
175
 
177
176
  - (BOOL)synchronouslyUpdateViewOnUIThread:(NSNumber *)reactTag props:(NSDictionary *)props
178
177
  {
179
- RCTScheduler *scheduler = [self _scheduler];
178
+ RCTScheduler *scheduler = [self scheduler];
180
179
  if (!scheduler) {
181
180
  return NO;
182
181
  }
@@ -200,7 +199,7 @@ static BackgroundExecutor RCTGetBackgroundExecutor()
200
199
 
201
200
  - (void)setupAnimationDriverWithSurfaceHandler:(facebook::react::SurfaceHandler const &)surfaceHandler
202
201
  {
203
- [[self _scheduler] setupAnimationDriver:surfaceHandler];
202
+ [[self scheduler] setupAnimationDriver:surfaceHandler];
204
203
  }
205
204
 
206
205
  - (BOOL)suspend
@@ -257,6 +256,10 @@ static BackgroundExecutor RCTGetBackgroundExecutor()
257
256
  RCTExperimentSetPreemptiveViewAllocationDisabled(YES);
258
257
  }
259
258
 
259
+ if (reactNativeConfig && reactNativeConfig->getBool("rn_convergence:dispatch_pointer_events")) {
260
+ RCTSetDispatchW3CPointerEvents(YES);
261
+ }
262
+
260
263
  auto componentRegistryFactory =
261
264
  [factory = wrapManagedObject(_mountingManager.componentViewRegistry.componentViewFactory)](
262
265
  EventDispatcher::Weak const &eventDispatcher, ContextContainer::Shared const &contextContainer) {
@@ -342,7 +345,7 @@ static BackgroundExecutor RCTGetBackgroundExecutor()
342
345
  NSString *commandStr = [[NSString alloc] initWithUTF8String:commandName.c_str()];
343
346
  NSArray *argsArray = convertFollyDynamicToId(args);
344
347
 
345
- [self->_mountingManager dispatchCommand:tag commandName:commandStr args:argsArray];
348
+ [_mountingManager dispatchCommand:tag commandName:commandStr args:argsArray];
346
349
  }
347
350
 
348
351
  - (void)schedulerDidSendAccessibilityEvent:(const facebook::react::ShadowView &)shadowView
@@ -351,16 +354,14 @@ static BackgroundExecutor RCTGetBackgroundExecutor()
351
354
  ReactTag tag = shadowView.tag;
352
355
  NSString *eventTypeStr = [[NSString alloc] initWithUTF8String:eventType.c_str()];
353
356
 
354
- [self->_mountingManager sendAccessibilityEvent:tag eventType:eventTypeStr];
357
+ [_mountingManager sendAccessibilityEvent:tag eventType:eventTypeStr];
355
358
  }
356
359
 
357
360
  - (void)schedulerDidSetIsJSResponder:(BOOL)isJSResponder
358
361
  blockNativeResponder:(BOOL)blockNativeResponder
359
362
  forShadowView:(facebook::react::ShadowView const &)shadowView;
360
363
  {
361
- [self->_mountingManager setIsJSResponder:isJSResponder
362
- blockNativeResponder:blockNativeResponder
363
- forShadowView:shadowView];
364
+ [_mountingManager setIsJSResponder:isJSResponder blockNativeResponder:blockNativeResponder forShadowView:shadowView];
364
365
  }
365
366
 
366
367
  - (void)addObserver:(id<RCTSurfacePresenterObserver>)observer
@@ -9,7 +9,6 @@
9
9
 
10
10
  #import <React/RCTUtils.h>
11
11
  #import <React/RCTViewComponentView.h>
12
- #import <UIKit/UIGestureRecognizerSubclass.h>
13
12
 
14
13
  #import "RCTConversions.h"
15
14
  #import "RCTTouchableComponentViewProtocol.h"
@@ -28,7 +28,7 @@ Pod::Spec.new do |s|
28
28
  s.homepage = "https://reactnative.dev/"
29
29
  s.license = package["license"]
30
30
  s.author = "Facebook, Inc. and its affiliates"
31
- s.platforms = { :ios => "11.0" }
31
+ s.platforms = { :ios => "11.0", :osx => "10.15" } # TODO(macOS GH#774)
32
32
  s.source = source
33
33
  s.source_files = "Fabric/**/*.{c,h,m,mm,S,cpp}"
34
34
  s.exclude_files = "**/tests/*",
@@ -31,6 +31,7 @@ extern const UIAccessibilityTraits SwitchAccessibilityTrait;
31
31
  - (BOOL)resignFirstResponder;
32
32
 
33
33
  #if TARGET_OS_OSX
34
+ - (NSDictionary*)dataTransferInfoFromPasteboard:(NSPasteboard*)pasteboard;
34
35
  - (BOOL)handleKeyboardEvent:(NSEvent *)event;
35
36
  #endif
36
37
  // ]TODO(OSS Candidate ISS#2710739)
@@ -1440,9 +1440,14 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1440
1440
  }
1441
1441
  }
1442
1442
 
1443
+ - (BOOL)needsPanelToBecomeKey {
1444
+ // We need to override this so that mouse clicks don't move keyboard focus on focusable views by default.
1445
+ return false;
1446
+ }
1447
+
1443
1448
  - (BOOL)acceptsFirstResponder
1444
1449
  {
1445
- return ([self focusable] && [NSApp isFullKeyboardAccessEnabled]) || [super acceptsFirstResponder];
1450
+ return [self focusable] || [super acceptsFirstResponder];
1446
1451
  }
1447
1452
 
1448
1453
  - (void)updateTrackingAreas
@@ -1527,13 +1532,9 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1527
1532
  block(body);
1528
1533
  }
1529
1534
 
1530
- - (NSDictionary*)dataTransferInfoFromPastboard:(NSPasteboard*)pastboard
1535
+ - (NSDictionary*)dataTransferInfoFromPasteboard:(NSPasteboard*)pasteboard
1531
1536
  {
1532
- if (![pastboard.types containsObject:NSFilenamesPboardType]) {
1533
- return @{};
1534
- }
1535
-
1536
- NSArray *fileNames = [pastboard propertyListForType:NSFilenamesPboardType];
1537
+ NSArray *fileNames = [pasteboard propertyListForType:NSFilenamesPboardType] ?: @[];
1537
1538
  NSMutableArray *files = [[NSMutableArray alloc] initWithCapacity:fileNames.count];
1538
1539
  NSMutableArray *items = [[NSMutableArray alloc] initWithCapacity:fileNames.count];
1539
1540
  NSMutableArray *types = [[NSMutableArray alloc] initWithCapacity:fileNames.count];
@@ -1559,11 +1560,21 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1559
1560
  BOOL success = [fileURL getResourceValue:&fileSizeValue
1560
1561
  forKey:NSURLFileSizeKey
1561
1562
  error:&fileSizeError];
1562
-
1563
+
1564
+ NSNumber *width = nil;
1565
+ NSNumber *height = nil;
1566
+ if ([MIMETypeString hasPrefix:@"image/"]) {
1567
+ NSImage *image = [[NSImage alloc] initWithContentsOfURL:fileURL];
1568
+ width = @(image.size.width);
1569
+ height = @(image.size.height);
1570
+ }
1571
+
1563
1572
  [files addObject:@{@"name": RCTNullIfNil(fileURL.lastPathComponent),
1564
1573
  @"type": RCTNullIfNil(MIMETypeString),
1565
- @"uri": RCTNullIfNil(fileURL.absoluteString),
1566
- @"size": success ? fileSizeValue : (id)kCFNull
1574
+ @"uri": RCTNullIfNil(fileURL.path),
1575
+ @"size": success ? fileSizeValue : (id)kCFNull,
1576
+ @"width": RCTNullIfNil(width),
1577
+ @"height": RCTNullIfNil(height)
1567
1578
  }];
1568
1579
 
1569
1580
  [items addObject:@{@"kind": @"file",
@@ -1573,7 +1584,27 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1573
1584
  [types addObject:RCTNullIfNil(MIMETypeString)];
1574
1585
  }
1575
1586
  }
1576
-
1587
+
1588
+ NSPasteboardType imageType = [pasteboard availableTypeFromArray:@[NSPasteboardTypePNG, NSPasteboardTypeTIFF]];
1589
+ if (imageType && fileNames.count == 0) {
1590
+ NSString *MIMETypeString = imageType == NSPasteboardTypePNG ? @"image/png" : @"image/tiff";
1591
+ NSData *imageData = [pasteboard dataForType:imageType];
1592
+ NSImage *image = [[NSImage alloc] initWithData:imageData];
1593
+
1594
+ [files addObject:@{@"type": RCTNullIfNil(MIMETypeString),
1595
+ @"uri": RCTDataURL(MIMETypeString, imageData).absoluteString,
1596
+ @"size": @(imageData.length),
1597
+ @"width": @(image.size.width),
1598
+ @"height": @(image.size.height),
1599
+ }];
1600
+
1601
+ [items addObject:@{@"kind": @"image",
1602
+ @"type": RCTNullIfNil(MIMETypeString),
1603
+ }];
1604
+
1605
+ [types addObject:RCTNullIfNil(MIMETypeString)];
1606
+ }
1607
+
1577
1608
  return @{@"dataTransfer": @{@"files": files,
1578
1609
  @"items": items,
1579
1610
  @"types": types}};
@@ -1598,9 +1629,9 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1598
1629
  [self sendMouseEventWithBlock:self.onDragEnter
1599
1630
  locationInfo:[self locationInfoFromDraggingLocation:sender.draggingLocation]
1600
1631
  modifierFlags:0
1601
- additionalData:[self dataTransferInfoFromPastboard:pboard]];
1602
-
1603
- if ([pboard.types containsObject:NSFilenamesPboardType]) {
1632
+ additionalData:[self dataTransferInfoFromPasteboard:pboard]];
1633
+
1634
+ if ([pboard availableTypeFromArray:self.registeredDraggedTypes]) {
1604
1635
  if (sourceDragMask & NSDragOperationLink) {
1605
1636
  return NSDragOperationLink;
1606
1637
  } else if (sourceDragMask & NSDragOperationCopy) {
@@ -1615,7 +1646,7 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1615
1646
  [self sendMouseEventWithBlock:self.onDragLeave
1616
1647
  locationInfo:[self locationInfoFromDraggingLocation:sender.draggingLocation]
1617
1648
  modifierFlags:0
1618
- additionalData:[self dataTransferInfoFromPastboard:sender.draggingPasteboard]];
1649
+ additionalData:[self dataTransferInfoFromPasteboard:sender.draggingPasteboard]];
1619
1650
  }
1620
1651
 
1621
1652
  - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
@@ -1623,7 +1654,7 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
1623
1654
  [self sendMouseEventWithBlock:self.onDrop
1624
1655
  locationInfo:[self locationInfoFromDraggingLocation:sender.draggingLocation]
1625
1656
  modifierFlags:0
1626
- additionalData:[self dataTransferInfoFromPastboard:[sender draggingPasteboard]]];
1657
+ additionalData:[self dataTransferInfoFromPasteboard:sender.draggingPasteboard]];
1627
1658
  return YES;
1628
1659
  }
1629
1660
  #endif // ]TODO(macOS GH#774)
@@ -95,7 +95,7 @@ RCT_EXPORT_MODULE()
95
95
 
96
96
  - (void)setBridge:(RCTBridge *)bridge
97
97
  {
98
- RCTWarnNotAllowedForNewArchitecture(self, @"RCTViewManager must not be initialized for the new architecture");
98
+ RCTErrorNotAllowedForNewArchitecture(self, @"RCTViewManager must not be initialized for the new architecture");
99
99
  _bridge = bridge;
100
100
  }
101
101
 
@@ -116,7 +116,7 @@
116
116
 
117
117
  - (void)scrollWheel:(NSEvent *)theEvent
118
118
  {
119
- if (!self.scrollEnabled) {
119
+ if (!self.isScrollEnabled) {
120
120
  [[self nextResponder] scrollWheel:theEvent];
121
121
  return;
122
122
  }
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.0.0-081d66e4e
1
+ VERSION_NAME=0.0.0-08d0c3b4f
2
2
  GROUP=com.facebook.react
3
3
 
4
4
  POM_NAME=ReactNative
@@ -22,5 +22,5 @@ public class ReactNativeVersion {
22
22
  "major", 0,
23
23
  "minor", 0,
24
24
  "patch", 0,
25
- "prerelease", "081d66e4e");
25
+ "prerelease", "08d0c3b4f");
26
26
  }
@@ -29,7 +29,7 @@ Pod::Spec.new do |s|
29
29
  s.homepage = "https://reactnative.dev/"
30
30
  s.license = package["license"]
31
31
  s.author = "Facebook, Inc. and its affiliates"
32
- s.platforms = { :ios => "11.0" }
32
+ s.platforms = { :ios => "11.0", :osx => "10.15" } # TODO(macOS GH#774)
33
33
  s.source = source
34
34
  s.source_files = "dummyFile.cpp"
35
35
  s.pod_target_xcconfig = { "USE_HEADERMAP" => "YES",
@@ -25,7 +25,7 @@ Pod::Spec.new do |s|
25
25
  s.homepage = "https://reactnative.dev/"
26
26
  s.license = package["license"]
27
27
  s.author = "Facebook, Inc. and its affiliates"
28
- s.platforms = { :ios => "11.0" }
28
+ s.platforms = { :ios => "11.0", :osx => "10.15" } # TODO(macOS GH#774)
29
29
  s.source = source
30
30
  s.source_files = "dummyFile.cpp"
31
31
  s.pod_target_xcconfig = { "USE_HEADERMAP" => "YES",
@@ -22,7 +22,7 @@ constexpr struct {
22
22
  int32_t Major = 0;
23
23
  int32_t Minor = 0;
24
24
  int32_t Patch = 0;
25
- std::string_view Prerelease = "081d66e4e";
25
+ std::string_view Prerelease = "08d0c3b4f";
26
26
  } ReactNativeVersion;
27
27
 
28
28
  } // namespace facebook::react
@@ -36,6 +36,10 @@ EventDispatcher::EventDispatcher(
36
36
 
37
37
  void EventDispatcher::dispatchEvent(RawEvent &&rawEvent, EventPriority priority)
38
38
  const {
39
+ // Allows the event listener to interrupt default event dispatch
40
+ if (eventListeners_.willDispatchEvent(rawEvent)) {
41
+ return;
42
+ }
39
43
  getEventQueue(priority).enqueueEvent(std::move(rawEvent));
40
44
  }
41
45
 
@@ -46,6 +50,10 @@ void EventDispatcher::dispatchStateUpdate(
46
50
  }
47
51
 
48
52
  void EventDispatcher::dispatchUniqueEvent(RawEvent &&rawEvent) const {
53
+ // Allows the event listener to interrupt default event dispatch
54
+ if (eventListeners_.willDispatchEvent(rawEvent)) {
55
+ return;
56
+ }
49
57
  asynchronousBatchedQueue_->enqueueUniqueEvent(std::move(rawEvent));
50
58
  }
51
59
 
@@ -62,5 +70,18 @@ const EventQueue &EventDispatcher::getEventQueue(EventPriority priority) const {
62
70
  }
63
71
  }
64
72
 
73
+ void EventDispatcher::addListener(
74
+ const std::shared_ptr<EventListener const> &listener) const {
75
+ eventListeners_.addListener(listener);
76
+ }
77
+
78
+ /*
79
+ * Removes provided event listener to the event dispatcher.
80
+ */
81
+ void EventDispatcher::removeListener(
82
+ const std::shared_ptr<EventListener const> &listener) const {
83
+ eventListeners_.removeListener(listener);
84
+ }
85
+
65
86
  } // namespace react
66
87
  } // namespace facebook
@@ -9,6 +9,7 @@
9
9
 
10
10
  #include <react/renderer/core/BatchedEventQueue.h>
11
11
  #include <react/renderer/core/EventBeat.h>
12
+ #include <react/renderer/core/EventListener.h>
12
13
  #include <react/renderer/core/EventPriority.h>
13
14
  #include <react/renderer/core/EventQueueProcessor.h>
14
15
  #include <react/renderer/core/StateUpdate.h>
@@ -52,6 +53,18 @@ class EventDispatcher {
52
53
  void dispatchStateUpdate(StateUpdate &&stateUpdate, EventPriority priority)
53
54
  const;
54
55
 
56
+ #pragma mark - Event listeners
57
+ /*
58
+ * Adds provided event listener to the event dispatcher.
59
+ */
60
+ void addListener(const std::shared_ptr<EventListener const> &listener) const;
61
+
62
+ /*
63
+ * Removes provided event listener to the event dispatcher.
64
+ */
65
+ void removeListener(
66
+ const std::shared_ptr<EventListener const> &listener) const;
67
+
55
68
  private:
56
69
  EventQueue const &getEventQueue(EventPriority priority) const;
57
70
 
@@ -59,6 +72,8 @@ class EventDispatcher {
59
72
  std::unique_ptr<BatchedEventQueue> synchronousBatchedQueue_;
60
73
  std::unique_ptr<UnbatchedEventQueue> asynchronousUnbatchedQueue_;
61
74
  std::unique_ptr<BatchedEventQueue> asynchronousBatchedQueue_;
75
+
76
+ mutable EventListenerContainer eventListeners_;
62
77
  };
63
78
 
64
79
  } // namespace react
@@ -0,0 +1,39 @@
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
+
8
+ #include "EventListener.h"
9
+
10
+ namespace facebook::react {
11
+
12
+ bool EventListenerContainer::willDispatchEvent(const RawEvent &event) {
13
+ std::shared_lock<butter::shared_mutex> lock(mutex_);
14
+
15
+ bool handled = false;
16
+ for (auto const &listener : eventListeners_) {
17
+ handled = handled || listener->operator()(event);
18
+ }
19
+ return handled;
20
+ }
21
+
22
+ void EventListenerContainer::addListener(
23
+ const std::shared_ptr<EventListener const> &listener) {
24
+ std::unique_lock<butter::shared_mutex> lock(mutex_);
25
+
26
+ eventListeners_.push_back(listener);
27
+ }
28
+
29
+ void EventListenerContainer::removeListener(
30
+ const std::shared_ptr<EventListener const> &listener) {
31
+ std::unique_lock<butter::shared_mutex> lock(mutex_);
32
+
33
+ auto it = std::find(eventListeners_.begin(), eventListeners_.end(), listener);
34
+ if (it != eventListeners_.end()) {
35
+ eventListeners_.erase(it);
36
+ }
37
+ }
38
+
39
+ } // namespace facebook::react
@@ -0,0 +1,44 @@
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
+
8
+ #pragma once
9
+
10
+ #include <string>
11
+
12
+ #include <react/renderer/core/RawEvent.h>
13
+
14
+ #include <butter/mutex.h>
15
+
16
+ namespace facebook {
17
+ namespace react {
18
+
19
+ /**
20
+ * Listener for events dispatched to JS runtime.
21
+ * Return `true` to interrupt default dispatch to JS event emitter, `false` to
22
+ * pass through to default handlers.
23
+ */
24
+ using EventListener = std::function<bool(const RawEvent &event)>;
25
+
26
+ class EventListenerContainer {
27
+ public:
28
+ /*
29
+ * Invoke listeners in this container with the event.
30
+ * Returns true if event was handled by the listener, false to continue
31
+ * default dispatch.
32
+ */
33
+ bool willDispatchEvent(const RawEvent &event);
34
+
35
+ void addListener(const std::shared_ptr<EventListener const> &listener);
36
+ void removeListener(const std::shared_ptr<EventListener const> &listener);
37
+
38
+ private:
39
+ butter::shared_mutex mutex_;
40
+ std::vector<std::shared_ptr<EventListener const>> eventListeners_;
41
+ };
42
+
43
+ } // namespace react
44
+ } // namespace facebook
@@ -27,7 +27,7 @@ Pod::Spec.new do |s|
27
27
  s.homepage = "https://reactnative.dev/"
28
28
  s.license = package["license"]
29
29
  s.author = "Facebook, Inc. and its affiliates"
30
- s.platforms = { :ios => "11.0", :tvos => "11.0" }
30
+ s.platforms = { :ios => "11.0", :osx => "10.15" } # TODO(macOS GH#774)
31
31
  s.source = source
32
32
  s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
33
33
  s.source_files = "**/*.{m,mm,cpp,h}"
@@ -17,10 +17,9 @@ TelemetryController::TelemetryController(
17
17
  : mountingCoordinator_(mountingCoordinator) {}
18
18
 
19
19
  bool TelemetryController::pullTransaction(
20
- std::function<void(MountingTransactionMetadata metadata)> const &willMount,
21
- std::function<void(ShadowViewMutationList const &mutations)> const &doMount,
22
- std::function<void(MountingTransactionMetadata metadata)> const &didMount)
23
- const {
20
+ MountingTransactionCallback const &willMount,
21
+ MountingTransactionCallback const &doMount,
22
+ MountingTransactionCallback const &didMount) const {
24
23
  auto optional = mountingCoordinator_.pullTransaction();
25
24
  if (!optional.has_value()) {
26
25
  return false;
@@ -28,8 +27,6 @@ bool TelemetryController::pullTransaction(
28
27
 
29
28
  auto transaction = std::move(*optional);
30
29
 
31
- auto surfaceId = transaction.getSurfaceId();
32
- auto number = transaction.getNumber();
33
30
  auto telemetry = transaction.getTelemetry();
34
31
  auto numberOfMutations = static_cast<int>(transaction.getMutations().size());
35
32
 
@@ -37,15 +34,15 @@ bool TelemetryController::pullTransaction(
37
34
  auto compoundTelemetry = compoundTelemetry_;
38
35
  mutex_.unlock();
39
36
 
40
- willMount({surfaceId, number, telemetry, compoundTelemetry});
37
+ willMount(transaction, compoundTelemetry);
41
38
 
42
39
  telemetry.willMount();
43
- doMount(transaction.getMutations());
40
+ doMount(transaction, compoundTelemetry);
44
41
  telemetry.didMount();
45
42
 
46
43
  compoundTelemetry.incorporate(telemetry, numberOfMutations);
47
44
 
48
- didMount({surfaceId, number, telemetry, compoundTelemetry});
45
+ didMount(transaction, compoundTelemetry);
49
46
 
50
47
  mutex_.lock();
51
48
  compoundTelemetry_ = compoundTelemetry;
@@ -11,7 +11,6 @@
11
11
  #include <mutex>
12
12
 
13
13
  #include <react/renderer/mounting/MountingTransaction.h>
14
- #include <react/renderer/mounting/MountingTransactionMetadata.h>
15
14
  #include <react/renderer/telemetry/TransactionTelemetry.h>
16
15
 
17
16
  namespace facebook {
@@ -19,6 +18,10 @@ namespace react {
19
18
 
20
19
  class MountingCoordinator;
21
20
 
21
+ using MountingTransactionCallback = std::function<void(
22
+ MountingTransaction const &transaction,
23
+ SurfaceTelemetry const &surfaceTelemetry)>;
24
+
22
25
  /*
23
26
  * Provides convenient tools for aggregating and accessing telemetry data
24
27
  * associated with running Surface.
@@ -43,12 +46,9 @@ class TelemetryController final {
43
46
  * Calls `MountingCoordinator::pullTransaction()` and aggregates telemetry.
44
47
  */
45
48
  bool pullTransaction(
46
- std::function<void(MountingTransactionMetadata metadata)> const
47
- &willMount,
48
- std::function<void(ShadowViewMutationList const &mutations)> const
49
- &doMount,
50
- std::function<void(MountingTransactionMetadata metadata)> const &didMount)
51
- const;
49
+ MountingTransactionCallback const &willMount,
50
+ MountingTransactionCallback const &doMount,
51
+ MountingTransactionCallback const &didMount) const;
52
52
 
53
53
  private:
54
54
  MountingCoordinator const &mountingCoordinator_;
@@ -351,5 +351,19 @@ ContextContainer::Shared Scheduler::getContextContainer() const {
351
351
  return contextContainer_;
352
352
  }
353
353
 
354
+ void Scheduler::addEventListener(
355
+ const std::shared_ptr<EventListener const> &listener) {
356
+ if (eventDispatcher_->has_value()) {
357
+ eventDispatcher_->value().addListener(listener);
358
+ }
359
+ }
360
+
361
+ void Scheduler::removeEventListener(
362
+ const std::shared_ptr<EventListener const> &listener) {
363
+ if (eventDispatcher_->has_value()) {
364
+ eventDispatcher_->value().removeListener(listener);
365
+ }
366
+ }
367
+
354
368
  } // namespace react
355
369
  } // namespace facebook
@@ -16,6 +16,7 @@
16
16
  #include <react/renderer/components/root/RootComponentDescriptor.h>
17
17
  #include <react/renderer/core/ComponentDescriptor.h>
18
18
  #include <react/renderer/core/EventEmitter.h>
19
+ #include <react/renderer/core/EventListener.h>
19
20
  #include <react/renderer/core/LayoutConstraints.h>
20
21
  #include <react/renderer/mounting/MountingOverrideDelegate.h>
21
22
  #include <react/renderer/scheduler/InspectorData.h>
@@ -107,6 +108,11 @@ class Scheduler final : public UIManagerDelegate {
107
108
  #pragma mark - ContextContainer
108
109
  ContextContainer::Shared getContextContainer() const;
109
110
 
111
+ #pragma mark - Event listeners
112
+ void addEventListener(const std::shared_ptr<EventListener const> &listener);
113
+ void removeEventListener(
114
+ const std::shared_ptr<EventListener const> &listener);
115
+
110
116
  private:
111
117
  friend class SurfaceHandler;
112
118
 
@@ -10,7 +10,7 @@
10
10
  #include <react/debug/react_native_assert.h>
11
11
 
12
12
  #if defined(__OBJC__) && defined(__cplusplus)
13
- #if TARGET_OS_MAC && TARGET_OS_IPHONE
13
+ #if TARGET_OS_MAC
14
14
 
15
15
  #include <memory>
16
16
 
@@ -7,8 +7,7 @@
7
7
 
8
8
  #include "ManagedObjectWrapper.h"
9
9
 
10
- #if defined(__OBJC__) && defined(__cplusplus)
11
- #if TARGET_OS_MAC && TARGET_OS_IPHONE
10
+ #if TARGET_OS_MAC
12
11
 
13
12
  namespace facebook {
14
13
  namespace react {
@@ -35,4 +34,3 @@ void wrappedManagedObjectDeleter(void *cfPointer) noexcept
35
34
  @end
36
35
 
37
36
  #endif
38
- #endif
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-macos",
3
- "version": "0.0.0-081d66e4e",
3
+ "version": "0.0.0-08d0c3b4f",
4
4
  "bin": "./cli.js",
5
5
  "description": "React Native for macOS",
6
6
  "license": "MIT",
@@ -79,9 +79,6 @@ def use_react_native! (options={})
79
79
  pod 'boost', :podspec => "#{prefix}/third-party-podspecs/boost.podspec"
80
80
  pod 'RCT-Folly', :podspec => "#{prefix}/third-party-podspecs/RCT-Folly.podspec"
81
81
 
82
- # TODO(macOS GH#214)
83
- pod 'boost-for-react-native', :podspec => "#{prefix}/third-party-podspecs/boost-for-react-native.podspec"
84
-
85
82
  if ENV['USE_CODEGEN_DISCOVERY'] == '1'
86
83
  app_path = options[:app_path]
87
84
  config_file_dir = options[:config_file_dir]