react-native-macos 0.0.0-20e73d546 → 0.0.0-21aeabf4e
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.
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Text/Text/RCTTextView.m +48 -21
- package/Libraries/Text/TextInput/Singleline/RCTUITextField.m +16 -2
- package/React/Base/RCTTouchHandler.h +6 -1
- package/React/Base/RCTTouchHandler.m +31 -1
- package/React/Base/RCTUIKit.h +10 -2
- package/React/Base/RCTVersion.m +1 -1
- package/React/Fabric/Mounting/ComponentViews/InputAccessory/RCTInputAccessoryComponentView.mm +4 -0
- package/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm +3 -3
- package/React/Fabric/Mounting/ComponentViews/Modal/RCTFabricModalHostViewController.h +2 -0
- package/React/Fabric/Mounting/ComponentViews/Modal/RCTFabricModalHostViewController.mm +2 -0
- package/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm +4 -2
- package/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +2 -0
- package/React/Fabric/Mounting/RCTComponentViewDescriptor.h +1 -1
- package/React/Fabric/Mounting/RCTComponentViewRegistry.mm +10 -0
- package/React/Fabric/Mounting/UIView+ComponentViewProtocol.mm +6 -0
- package/React/Fabric/RCTSurfaceTouchHandler.mm +43 -20
- package/React/Views/ScrollView/RCTScrollContentView.m +4 -5
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTFontUtils.mm +4 -0
- package/package.json +3 -1
- package/template/Gemfile +1 -1
- package/template/Gemfile.lock +3 -3
- package/template/_ruby-version +1 -1
- package/template/package.json +1 -1
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
#import <React/RCTFocusChangeEvent.h> // [macOS]
|
|
18
18
|
|
|
19
19
|
#import <React/RCTTextShadowView.h>
|
|
20
|
+
#import <React/RCTTouchHandler.h>
|
|
20
21
|
|
|
21
22
|
#import <QuartzCore/QuartzCore.h>
|
|
22
23
|
|
|
@@ -208,7 +209,6 @@
|
|
|
208
209
|
return;
|
|
209
210
|
}
|
|
210
211
|
|
|
211
|
-
|
|
212
212
|
NSLayoutManager *layoutManager = _textStorage.layoutManagers.firstObject;
|
|
213
213
|
NSTextContainer *textContainer = layoutManager.textContainers.firstObject;
|
|
214
214
|
|
|
@@ -407,36 +407,65 @@
|
|
|
407
407
|
}
|
|
408
408
|
#else // [macOS
|
|
409
409
|
|
|
410
|
+
- (NSView *)hitTest:(NSPoint)point
|
|
411
|
+
{
|
|
412
|
+
// We will forward mouse click events to the NSTextView ourselves to prevent NSTextView from swallowing events that may be handled in JS (e.g. long press).
|
|
413
|
+
NSView *hitView = [super hitTest:point];
|
|
414
|
+
|
|
415
|
+
NSEventType eventType = NSApp.currentEvent.type;
|
|
416
|
+
BOOL isMouseClickEvent = NSEvent.pressedMouseButtons > 0;
|
|
417
|
+
BOOL isMouseMoveEventType = eventType == NSEventTypeMouseMoved || eventType == NSEventTypeMouseEntered || eventType == NSEventTypeMouseExited || eventType == NSEventTypeCursorUpdate;
|
|
418
|
+
BOOL isMouseMoveEvent = !isMouseClickEvent && isMouseMoveEventType;
|
|
419
|
+
BOOL isTextViewClick = (hitView && hitView == _textView) && !isMouseMoveEvent;
|
|
420
|
+
|
|
421
|
+
return isTextViewClick ? self : hitView;
|
|
422
|
+
}
|
|
423
|
+
|
|
410
424
|
- (void)rightMouseDown:(NSEvent *)event
|
|
411
425
|
{
|
|
412
|
-
|
|
426
|
+
|
|
427
|
+
if (self.selectable == NO) {
|
|
413
428
|
[super rightMouseDown:event];
|
|
414
429
|
return;
|
|
415
430
|
}
|
|
416
|
-
NSText *fieldEditor = [self.window fieldEditor:YES forObject:self];
|
|
417
|
-
NSMenu *fieldEditorMenu = [fieldEditor menuForEvent:event];
|
|
418
431
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
NSMenu *menu = [[NSMenu alloc] initWithTitle:@""];
|
|
432
|
+
[[RCTTouchHandler touchHandlerForView:self] cancelTouchWithEvent:event];
|
|
433
|
+
[_textView rightMouseDown:event];
|
|
434
|
+
}
|
|
423
435
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
436
|
+
- (void)mouseDown:(NSEvent *)event
|
|
437
|
+
{
|
|
438
|
+
if (!self.selectable) {
|
|
439
|
+
[super mouseDown:event];
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
427
442
|
|
|
428
|
-
|
|
429
|
-
|
|
443
|
+
// Double/triple-clicks should be forwarded to the NSTextView.
|
|
444
|
+
BOOL shouldForward = event.clickCount > 1;
|
|
430
445
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
446
|
+
if (!shouldForward) {
|
|
447
|
+
// Peek at next event to know if a selection should begin.
|
|
448
|
+
NSEvent *nextEvent = [self.window nextEventMatchingMask:NSEventMaskLeftMouseUp | NSEventMaskLeftMouseDragged
|
|
449
|
+
untilDate:[NSDate distantFuture]
|
|
450
|
+
inMode:NSEventTrackingRunLoopMode
|
|
451
|
+
dequeue:NO];
|
|
452
|
+
shouldForward = nextEvent.type == NSEventTypeLeftMouseDragged;
|
|
453
|
+
}
|
|
434
454
|
|
|
435
|
-
|
|
455
|
+
if (shouldForward) {
|
|
456
|
+
NSView *contentView = self.window.contentView;
|
|
457
|
+
// -[NSView hitTest:] takes coordinates in a view's superview coordinate system.
|
|
458
|
+
NSPoint point = [contentView.superview convertPoint:event.locationInWindow fromView:nil];
|
|
436
459
|
|
|
437
|
-
if
|
|
438
|
-
|
|
460
|
+
// Start selection if we're still selectable and hit-testable.
|
|
461
|
+
if (self.selectable && [contentView hitTest:point] == self) {
|
|
462
|
+
[[RCTTouchHandler touchHandlerForView:self] cancelTouchWithEvent:event];
|
|
463
|
+
[self.window makeFirstResponder:_textView];
|
|
464
|
+
[_textView mouseDown:event];
|
|
439
465
|
}
|
|
466
|
+
} else {
|
|
467
|
+
// Clear selection for single clicks.
|
|
468
|
+
_textView.selectedRange = NSMakeRange(NSNotFound, 0);
|
|
440
469
|
}
|
|
441
470
|
}
|
|
442
471
|
#endif // macOS]
|
|
@@ -533,8 +562,6 @@
|
|
|
533
562
|
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
|
|
534
563
|
pasteboard.items = @[item];
|
|
535
564
|
#else // [macOS
|
|
536
|
-
[_textView copy:sender];
|
|
537
|
-
|
|
538
565
|
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
|
|
539
566
|
[pasteboard clearContents];
|
|
540
567
|
[pasteboard setData:rtf forType:NSPasteboardTypeRTFD];
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
#import <React/RCTBackedTextInputDelegateAdapter.h>
|
|
13
13
|
#import <React/RCTBackedTextInputDelegate.h> // [macOS]
|
|
14
14
|
#import <React/RCTTextAttributes.h>
|
|
15
|
-
|
|
15
|
+
#import <React/RCTTouchHandler.h> // [TODO(macOS GH#774)
|
|
16
16
|
|
|
17
17
|
#if TARGET_OS_OSX // [macOS
|
|
18
18
|
|
|
@@ -124,6 +124,9 @@
|
|
|
124
124
|
#if TARGET_OS_OSX // [macOS
|
|
125
125
|
[self setAttributedText:[[NSAttributedString alloc] initWithString:[self text]
|
|
126
126
|
attributes:[self defaultTextAttributes]]];
|
|
127
|
+
if([[self text] length] == 0) {
|
|
128
|
+
self.font = [[self defaultTextAttributes] objectForKey:NSFontAttributeName];
|
|
129
|
+
}
|
|
127
130
|
#endif // macOS]
|
|
128
131
|
}
|
|
129
132
|
|
|
@@ -322,6 +325,8 @@
|
|
|
322
325
|
#if TARGET_OS_OSX // [macOS
|
|
323
326
|
[self setAttributedText:[[NSAttributedString alloc] initWithString:[self text]
|
|
324
327
|
attributes:[self defaultTextAttributes]]];
|
|
328
|
+
|
|
329
|
+
self.font = [[self defaultTextAttributes] objectForKey:NSFontAttributeName];
|
|
325
330
|
#endif // macOS]
|
|
326
331
|
}
|
|
327
332
|
|
|
@@ -436,7 +441,7 @@
|
|
|
436
441
|
|
|
437
442
|
#else // [macOS
|
|
438
443
|
|
|
439
|
-
#pragma mark -
|
|
444
|
+
#pragma mark - NSTextFieldDelegate methods
|
|
440
445
|
|
|
441
446
|
- (void)textDidChange:(NSNotification *)notification
|
|
442
447
|
{
|
|
@@ -473,6 +478,15 @@
|
|
|
473
478
|
return NO;
|
|
474
479
|
}
|
|
475
480
|
|
|
481
|
+
- (NSMenu *)textView:(NSTextView *)view menu:(NSMenu *)menu forEvent:(NSEvent *)event atIndex:(NSUInteger)charIndex
|
|
482
|
+
{
|
|
483
|
+
if (menu) {
|
|
484
|
+
[[RCTTouchHandler touchHandlerForView:self] willShowMenuWithEvent:event];
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
return menu;
|
|
488
|
+
}
|
|
489
|
+
|
|
476
490
|
#endif // macOS]
|
|
477
491
|
|
|
478
492
|
#pragma mark - Overrides
|
|
@@ -19,8 +19,13 @@
|
|
|
19
19
|
- (void)detachFromView:(RCTUIView *)view; // [macOS]
|
|
20
20
|
|
|
21
21
|
- (void)cancel;
|
|
22
|
+
|
|
22
23
|
#if TARGET_OS_OSX // [macOS
|
|
23
|
-
|
|
24
|
+
+ (instancetype)touchHandlerForEvent:(NSEvent *)event;
|
|
25
|
+
+ (instancetype)touchHandlerForView:(NSView *)view;
|
|
26
|
+
|
|
27
|
+
- (void)willShowMenuWithEvent:(NSEvent *)event;
|
|
28
|
+
- (void)cancelTouchWithEvent:(NSEvent *)event;
|
|
24
29
|
#endif // macOS]
|
|
25
30
|
|
|
26
31
|
@end
|
|
@@ -577,12 +577,42 @@ static BOOL RCTAnyTouchesChanged(NSSet *touches) // [macOS]
|
|
|
577
577
|
}
|
|
578
578
|
|
|
579
579
|
#if TARGET_OS_OSX // [macOS
|
|
580
|
-
|
|
580
|
+
+ (instancetype)touchHandlerForEvent:(NSEvent *)event {
|
|
581
|
+
// The window's frame view must be used for hit testing against `locationInWindow`
|
|
582
|
+
NSView *hitView = [event.window.contentView.superview hitTest:event.locationInWindow];
|
|
583
|
+
return [self touchHandlerForView:hitView];
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
+ (instancetype)touchHandlerForView:(NSView *)view {
|
|
587
|
+
if ([view isKindOfClass:[RCTRootView class]]) {
|
|
588
|
+
// The RCTTouchHandler is attached to the contentView.
|
|
589
|
+
view = ((RCTRootView *)view).contentView;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
while (view) {
|
|
593
|
+
for (NSGestureRecognizer *gestureRecognizer in view.gestureRecognizers) {
|
|
594
|
+
if ([gestureRecognizer isKindOfClass:[self class]]) {
|
|
595
|
+
return (RCTTouchHandler *)gestureRecognizer;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
view = view.superview;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
return nil;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
- (void)willShowMenuWithEvent:(NSEvent *)event
|
|
581
606
|
{
|
|
582
607
|
if (event.type == NSEventTypeRightMouseDown) {
|
|
583
608
|
[self interactionsEnded:[NSSet setWithObject:event] withEvent:event];
|
|
584
609
|
}
|
|
585
610
|
}
|
|
611
|
+
|
|
612
|
+
- (void)cancelTouchWithEvent:(NSEvent *)event
|
|
613
|
+
{
|
|
614
|
+
[self interactionsCancelled:[NSSet setWithObject:event] withEvent:event];
|
|
615
|
+
}
|
|
586
616
|
#endif // macOS]
|
|
587
617
|
|
|
588
618
|
#pragma mark - UIGestureRecognizerDelegate
|
package/React/Base/RCTUIKit.h
CHANGED
|
@@ -61,10 +61,9 @@ UIKIT_STATIC_INLINE CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *path)
|
|
|
61
61
|
//
|
|
62
62
|
|
|
63
63
|
// UIView
|
|
64
|
-
#define RCTPlatformView
|
|
64
|
+
#define RCTPlatformView UIView
|
|
65
65
|
#define RCTUIView UIView
|
|
66
66
|
#define RCTUIScrollView UIScrollView
|
|
67
|
-
|
|
68
67
|
#define RCTPlatformWindow UIWindow
|
|
69
68
|
|
|
70
69
|
UIKIT_STATIC_INLINE RCTPlatformView *RCTUIViewHitTestWithEvent(RCTPlatformView *view, CGPoint point, __unused UIEvent *__nullable event)
|
|
@@ -545,3 +544,12 @@ NS_ASSUME_NONNULL_END
|
|
|
545
544
|
@end
|
|
546
545
|
|
|
547
546
|
#endif
|
|
547
|
+
|
|
548
|
+
// RCTUITouch
|
|
549
|
+
|
|
550
|
+
#if !TARGET_OS_OSX
|
|
551
|
+
typedef UITouch RCTUITouch;
|
|
552
|
+
#else
|
|
553
|
+
@interface RCTUITouch : NSEvent
|
|
554
|
+
@end
|
|
555
|
+
#endif
|
package/React/Base/RCTVersion.m
CHANGED
package/React/Fabric/Mounting/ComponentViews/InputAccessory/RCTInputAccessoryComponentView.mm
CHANGED
|
@@ -66,8 +66,12 @@ static RCTUIView<RCTBackedTextInputViewProtocol> *_Nullable RCTFindTextInputWith
|
|
|
66
66
|
|
|
67
67
|
if (self.window && !_textInput) {
|
|
68
68
|
if (self.nativeId) {
|
|
69
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
69
70
|
_textInput = RCTFindTextInputWithNativeId(self.window, self.nativeId);
|
|
70
71
|
_textInput.inputAccessoryView = _contentView;
|
|
72
|
+
#else // [macOS
|
|
73
|
+
_textInput = RCTFindTextInputWithNativeId(self.window.contentView, self.nativeId);
|
|
74
|
+
#endif // macOS]
|
|
71
75
|
} else {
|
|
72
76
|
_textInput = RCTFindTextInputWithNativeId(_contentView, nil);
|
|
73
77
|
}
|
|
@@ -43,7 +43,7 @@ static NSString *const kRCTLegacyInteropChildIndexKey = @"index";
|
|
|
43
43
|
|
|
44
44
|
- (RCTUIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event // [macOS]
|
|
45
45
|
{
|
|
46
|
-
RCTUIView *result = [super hitTest:point withEvent:event]; // [macOS]
|
|
46
|
+
RCTUIView *result = (RCTUIView *)[super hitTest:point withEvent:event]; // [macOS]
|
|
47
47
|
|
|
48
48
|
if (result == _adapter.paperView) {
|
|
49
49
|
return self;
|
|
@@ -197,9 +197,9 @@ static NSString *const kRCTLegacyInteropChildIndexKey = @"index";
|
|
|
197
197
|
|
|
198
198
|
for (NSDictionary *mountInstruction in _viewsToBeMounted) {
|
|
199
199
|
NSNumber *index = mountInstruction[kRCTLegacyInteropChildIndexKey];
|
|
200
|
-
|
|
200
|
+
RCTUIView *childView = mountInstruction[kRCTLegacyInteropChildComponentKey]; // [macOS]
|
|
201
201
|
if ([childView isKindOfClass:[RCTLegacyViewManagerInteropComponentView class]]) {
|
|
202
|
-
|
|
202
|
+
RCTUIView *target = ((RCTLegacyViewManagerInteropComponentView *)childView).contentView; // [macOS]
|
|
203
203
|
[_adapter.paperView insertReactSubview:target atIndex:index.integerValue];
|
|
204
204
|
} else {
|
|
205
205
|
[_adapter.paperView insertReactSubview:childView atIndex:index.integerValue];
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
return self;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
35
36
|
- (void)viewDidLayoutSubviews
|
|
36
37
|
{
|
|
37
38
|
[super viewDidLayoutSubviews];
|
|
@@ -81,5 +82,6 @@
|
|
|
81
82
|
return _supportedInterfaceOrientations;
|
|
82
83
|
}
|
|
83
84
|
#endif // RCT_DEV
|
|
85
|
+
#endif // [macOS]
|
|
84
86
|
|
|
85
87
|
@end
|
|
@@ -268,7 +268,6 @@ using namespace facebook::react;
|
|
|
268
268
|
return paragraphProps.isSelectable;
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
#if !TARGET_OS_OSX // [macOS]
|
|
272
271
|
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
|
|
273
272
|
{
|
|
274
273
|
auto const ¶graphProps = *std::static_pointer_cast<ParagraphProps const>(_props);
|
|
@@ -277,9 +276,12 @@ using namespace facebook::react;
|
|
|
277
276
|
return YES;
|
|
278
277
|
}
|
|
279
278
|
|
|
279
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
280
280
|
return [self.nextResponder canPerformAction:action withSender:sender];
|
|
281
|
+
#else // [macOS
|
|
282
|
+
return NO;
|
|
283
|
+
#endif // macOS]
|
|
281
284
|
}
|
|
282
|
-
#endif // [macOS]
|
|
283
285
|
|
|
284
286
|
- (void)copy:(id)sender
|
|
285
287
|
{
|
|
@@ -85,7 +85,9 @@ using namespace facebook::react;
|
|
|
85
85
|
if (self.window && !_didMoveToWindow) {
|
|
86
86
|
auto const &props = *std::static_pointer_cast<TextInputProps const>(_props);
|
|
87
87
|
if (props.autoFocus) {
|
|
88
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
88
89
|
[_backedTextInputView becomeFirstResponder];
|
|
90
|
+
#endif // [macOS]
|
|
89
91
|
}
|
|
90
92
|
_didMoveToWindow = YES;
|
|
91
93
|
}
|
|
@@ -22,7 +22,7 @@ class RCTComponentViewDescriptor final {
|
|
|
22
22
|
* Associated (and owned) native view instance.
|
|
23
23
|
*/
|
|
24
24
|
__strong RCTUIView<RCTComponentViewProtocol> *view = nil; // [macOS]
|
|
25
|
-
|
|
25
|
+
NSInteger tag = 0; // [macOS] default is 0
|
|
26
26
|
/*
|
|
27
27
|
* Indicates a requirement to call on the view methods from
|
|
28
28
|
* `RCTMountingTransactionObserving` protocol.
|
|
@@ -40,7 +40,9 @@ const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 1024;
|
|
|
40
40
|
|
|
41
41
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
42
42
|
// Calling this a bit later, when the main thread is probably idle while JavaScript thread is busy.
|
|
43
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
43
44
|
[self preallocateViewComponents];
|
|
45
|
+
#endif // [macOS]
|
|
44
46
|
});
|
|
45
47
|
}
|
|
46
48
|
|
|
@@ -83,7 +85,11 @@ const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 1024;
|
|
|
83
85
|
@"RCTComponentViewRegistry: Attempt to dequeue already registered component.");
|
|
84
86
|
|
|
85
87
|
auto componentViewDescriptor = [self _dequeueComponentViewWithComponentHandle:componentHandle];
|
|
88
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
86
89
|
componentViewDescriptor.view.tag = tag;
|
|
90
|
+
#else // [macOS
|
|
91
|
+
componentViewDescriptor.tag = tag;
|
|
92
|
+
#endif // macOS]
|
|
87
93
|
auto it = _registry.insert({tag, componentViewDescriptor});
|
|
88
94
|
return it.first->second;
|
|
89
95
|
}
|
|
@@ -98,7 +104,11 @@ const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 1024;
|
|
|
98
104
|
_registry.find(tag) != _registry.end(), @"RCTComponentViewRegistry: Attempt to enqueue unregistered component.");
|
|
99
105
|
|
|
100
106
|
_registry.erase(tag);
|
|
107
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
101
108
|
componentViewDescriptor.view.tag = 0;
|
|
109
|
+
#else // [macOS
|
|
110
|
+
componentViewDescriptor.tag = 0;
|
|
111
|
+
#endif // macOS]
|
|
102
112
|
[self _enqueueComponentViewWithComponentHandle:componentHandle componentViewDescriptor:componentViewDescriptor];
|
|
103
113
|
}
|
|
104
114
|
|
|
@@ -103,16 +103,22 @@ using namespace facebook::react;
|
|
|
103
103
|
} else {
|
|
104
104
|
// Note: Changing `frame` when `layer.transform` is not the `identity transform` is undefined behavior.
|
|
105
105
|
// Therefore, we must use `center` and `bounds`.
|
|
106
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
106
107
|
self.center = CGPoint{CGRectGetMidX(frame), CGRectGetMidY(frame)};
|
|
108
|
+
#else // [macOS
|
|
109
|
+
self.frame = frame;
|
|
110
|
+
#endif // macOS]
|
|
107
111
|
self.bounds = CGRect{CGPointZero, frame.size};
|
|
108
112
|
}
|
|
109
113
|
}
|
|
110
114
|
|
|
115
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
111
116
|
if (forceUpdate || (layoutMetrics.layoutDirection != oldLayoutMetrics.layoutDirection)) {
|
|
112
117
|
self.semanticContentAttribute = layoutMetrics.layoutDirection == LayoutDirection::RightToLeft
|
|
113
118
|
? UISemanticContentAttributeForceRightToLeft
|
|
114
119
|
: UISemanticContentAttributeForceLeftToRight;
|
|
115
120
|
}
|
|
121
|
+
#endif // [macOS]
|
|
116
122
|
|
|
117
123
|
if (forceUpdate || (layoutMetrics.displayType != oldLayoutMetrics.displayType)) {
|
|
118
124
|
self.hidden = layoutMetrics.displayType == DisplayType::None;
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
#import "RCTSurfaceTouchHandler.h"
|
|
9
9
|
|
|
10
|
+
#import <React/RCTUIKit.h> // [macOS]
|
|
10
11
|
#import <React/RCTUtils.h>
|
|
11
12
|
#import <React/RCTViewComponentView.h>
|
|
12
13
|
|
|
@@ -79,10 +80,11 @@ struct ActiveTouch {
|
|
|
79
80
|
|
|
80
81
|
static void UpdateActiveTouchWithUITouch(
|
|
81
82
|
ActiveTouch &activeTouch,
|
|
82
|
-
|
|
83
|
+
RCTUITouch *uiTouch, // [macOS]
|
|
83
84
|
RCTUIView *rootComponentView,
|
|
84
85
|
CGPoint rootViewOriginOffset) // [macOS]
|
|
85
86
|
{
|
|
87
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
86
88
|
CGPoint offsetPoint = [uiTouch locationInView:activeTouch.componentView];
|
|
87
89
|
CGPoint screenPoint = [uiTouch locationInView:uiTouch.window];
|
|
88
90
|
CGPoint pagePoint = [uiTouch locationInView:rootComponentView];
|
|
@@ -97,12 +99,14 @@ static void UpdateActiveTouchWithUITouch(
|
|
|
97
99
|
if (RCTForceTouchAvailable()) {
|
|
98
100
|
activeTouch.touch.force = RCTZeroIfNaN(uiTouch.force / uiTouch.maximumPossibleForce);
|
|
99
101
|
}
|
|
102
|
+
#endif // [macOS]
|
|
100
103
|
}
|
|
101
104
|
|
|
102
|
-
static ActiveTouch CreateTouchWithUITouch(
|
|
105
|
+
static ActiveTouch CreateTouchWithUITouch(RCTUITouch *uiTouch, RCTUIView *rootComponentView, CGPoint rootViewOriginOffset) // [macOS]
|
|
103
106
|
{
|
|
104
107
|
ActiveTouch activeTouch = {};
|
|
105
108
|
|
|
109
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
106
110
|
// Find closest Fabric-managed touchable view
|
|
107
111
|
RCTUIView *componentView = uiTouch.view; // [macOS]
|
|
108
112
|
while (componentView) {
|
|
@@ -117,25 +121,30 @@ static ActiveTouch CreateTouchWithUITouch(UITouch *uiTouch, RCTUIView *rootCompo
|
|
|
117
121
|
}
|
|
118
122
|
|
|
119
123
|
UpdateActiveTouchWithUITouch(activeTouch, uiTouch, rootComponentView, rootViewOriginOffset);
|
|
124
|
+
#endif // [macOS]
|
|
120
125
|
return activeTouch;
|
|
121
126
|
}
|
|
122
127
|
|
|
123
|
-
static BOOL AllTouchesAreCancelledOrEnded(NSSet<
|
|
128
|
+
static BOOL AllTouchesAreCancelledOrEnded(NSSet<RCTUITouch *> *touches) // [macOS]
|
|
124
129
|
{
|
|
125
|
-
for (
|
|
130
|
+
for (RCTUITouch *touch in touches) { // [macOS]
|
|
131
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
126
132
|
if (touch.phase == UITouchPhaseBegan || touch.phase == UITouchPhaseMoved || touch.phase == UITouchPhaseStationary) {
|
|
127
133
|
return NO;
|
|
128
134
|
}
|
|
135
|
+
#endif // [macOS]
|
|
129
136
|
}
|
|
130
137
|
return YES;
|
|
131
138
|
}
|
|
132
139
|
|
|
133
|
-
static BOOL AnyTouchesChanged(NSSet<
|
|
140
|
+
static BOOL AnyTouchesChanged(NSSet<RCTUITouch *> *touches) // [macOS]
|
|
134
141
|
{
|
|
135
|
-
for (
|
|
142
|
+
for (RCTUITouch *touch in touches) { // [macOS]
|
|
143
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
136
144
|
if (touch.phase == UITouchPhaseBegan || touch.phase == UITouchPhaseMoved) {
|
|
137
145
|
return YES;
|
|
138
146
|
}
|
|
147
|
+
#endif // [macOS]
|
|
139
148
|
}
|
|
140
149
|
return NO;
|
|
141
150
|
}
|
|
@@ -158,8 +167,8 @@ struct PointerHasher {
|
|
|
158
167
|
@end
|
|
159
168
|
|
|
160
169
|
@implementation RCTSurfaceTouchHandler {
|
|
161
|
-
std::unordered_map<__unsafe_unretained
|
|
162
|
-
_activeTouches;
|
|
170
|
+
std::unordered_map<__unsafe_unretained RCTUITouch *, ActiveTouch, PointerHasher<__unsafe_unretained RCTUITouch *>>
|
|
171
|
+
_activeTouches; // [macOS]
|
|
163
172
|
|
|
164
173
|
/*
|
|
165
174
|
* We hold the view weakly to prevent a retain cycle.
|
|
@@ -175,9 +184,11 @@ struct PointerHasher {
|
|
|
175
184
|
// to be used as a top level event delegated recognizer.
|
|
176
185
|
// Otherwise, lower-level components not built using React Native,
|
|
177
186
|
// will fail to recognize gestures.
|
|
187
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
178
188
|
self.cancelsTouchesInView = NO;
|
|
179
189
|
self.delaysTouchesBegan = NO; // This is default value.
|
|
180
190
|
self.delaysTouchesEnded = NO;
|
|
191
|
+
#endif // [macOS]
|
|
181
192
|
|
|
182
193
|
self.delegate = self;
|
|
183
194
|
}
|
|
@@ -204,18 +215,18 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithTarget : (id)target action : (SEL)act
|
|
|
204
215
|
_rootComponentView = nil;
|
|
205
216
|
}
|
|
206
217
|
|
|
207
|
-
- (void)_registerTouches:(NSSet<
|
|
218
|
+
- (void)_registerTouches:(NSSet<RCTUITouch *> *)touches // [macOS]
|
|
208
219
|
{
|
|
209
|
-
for (
|
|
220
|
+
for (RCTUITouch *touch in touches) { // [macOS]
|
|
210
221
|
auto activeTouch = CreateTouchWithUITouch(touch, _rootComponentView, _viewOriginOffset);
|
|
211
222
|
activeTouch.touch.identifier = _identifierPool.dequeue();
|
|
212
223
|
_activeTouches.emplace(touch, activeTouch);
|
|
213
224
|
}
|
|
214
225
|
}
|
|
215
226
|
|
|
216
|
-
- (void)_updateTouches:(NSSet<
|
|
227
|
+
- (void)_updateTouches:(NSSet<RCTUITouch *> *)touches // [macOS]
|
|
217
228
|
{
|
|
218
|
-
for (
|
|
229
|
+
for (RCTUITouch *touch in touches) { // [macOS]
|
|
219
230
|
auto iterator = _activeTouches.find(touch);
|
|
220
231
|
assert(iterator != _activeTouches.end() && "Inconsistency between local and UIKit touch registries");
|
|
221
232
|
if (iterator == _activeTouches.end()) {
|
|
@@ -226,9 +237,9 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithTarget : (id)target action : (SEL)act
|
|
|
226
237
|
}
|
|
227
238
|
}
|
|
228
239
|
|
|
229
|
-
- (void)_unregisterTouches:(NSSet<
|
|
240
|
+
- (void)_unregisterTouches:(NSSet<RCTUITouch *> *)touches // [macOS]
|
|
230
241
|
{
|
|
231
|
-
for (
|
|
242
|
+
for (RCTUITouch *touch in touches) { // [macOS]
|
|
232
243
|
auto iterator = _activeTouches.find(touch);
|
|
233
244
|
assert(iterator != _activeTouches.end() && "Inconsistency between local and UIKit touch registries");
|
|
234
245
|
if (iterator == _activeTouches.end()) {
|
|
@@ -240,12 +251,12 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithTarget : (id)target action : (SEL)act
|
|
|
240
251
|
}
|
|
241
252
|
}
|
|
242
253
|
|
|
243
|
-
- (std::vector<ActiveTouch>)_activeTouchesFromTouches:(NSSet<
|
|
254
|
+
- (std::vector<ActiveTouch>)_activeTouchesFromTouches:(NSSet<RCTUITouch *> *)touches // [macOS]
|
|
244
255
|
{
|
|
245
256
|
std::vector<ActiveTouch> activeTouches;
|
|
246
257
|
activeTouches.reserve(touches.count);
|
|
247
258
|
|
|
248
|
-
for (
|
|
259
|
+
for (RCTUITouch *touch in touches) { // [macOS]
|
|
249
260
|
auto iterator = _activeTouches.find(touch);
|
|
250
261
|
assert(iterator != _activeTouches.end() && "Inconsistency between local and UIKit touch registries");
|
|
251
262
|
if (iterator == _activeTouches.end()) {
|
|
@@ -314,8 +325,9 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithTarget : (id)target action : (SEL)act
|
|
|
314
325
|
|
|
315
326
|
#pragma mark - `UIResponder`-ish touch-delivery methods
|
|
316
327
|
|
|
317
|
-
- (void)touchesBegan:(NSSet<
|
|
328
|
+
- (void)touchesBegan:(NSSet<RCTUITouch *> *)touches withEvent:(UIEvent *)event // [macOS]
|
|
318
329
|
{
|
|
330
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
319
331
|
[super touchesBegan:touches withEvent:event];
|
|
320
332
|
|
|
321
333
|
[self _registerTouches:touches];
|
|
@@ -326,20 +338,24 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithTarget : (id)target action : (SEL)act
|
|
|
326
338
|
} else if (self.state == UIGestureRecognizerStateBegan) {
|
|
327
339
|
self.state = UIGestureRecognizerStateChanged;
|
|
328
340
|
}
|
|
341
|
+
#endif // [macOS]
|
|
329
342
|
}
|
|
330
343
|
|
|
331
|
-
- (void)touchesMoved:(NSSet<
|
|
344
|
+
- (void)touchesMoved:(NSSet<RCTUITouch *> *)touches withEvent:(UIEvent *)event // [macOS]
|
|
332
345
|
{
|
|
346
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
333
347
|
[super touchesMoved:touches withEvent:event];
|
|
334
348
|
|
|
335
349
|
[self _updateTouches:touches];
|
|
336
350
|
[self _dispatchActiveTouches:[self _activeTouchesFromTouches:touches] eventType:RCTTouchEventTypeTouchMove];
|
|
337
351
|
|
|
338
352
|
self.state = UIGestureRecognizerStateChanged;
|
|
353
|
+
#endif // [macOS]
|
|
339
354
|
}
|
|
340
355
|
|
|
341
|
-
- (void)touchesEnded:(NSSet<
|
|
356
|
+
- (void)touchesEnded:(NSSet<RCTUITouch *> *)touches withEvent:(UIEvent *)event // [macOS]
|
|
342
357
|
{
|
|
358
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
343
359
|
[super touchesEnded:touches withEvent:event];
|
|
344
360
|
|
|
345
361
|
[self _updateTouches:touches];
|
|
@@ -351,10 +367,12 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithTarget : (id)target action : (SEL)act
|
|
|
351
367
|
} else if (AnyTouchesChanged(event.allTouches)) {
|
|
352
368
|
self.state = UIGestureRecognizerStateChanged;
|
|
353
369
|
}
|
|
370
|
+
#endif // [macOS]
|
|
354
371
|
}
|
|
355
372
|
|
|
356
|
-
- (void)touchesCancelled:(NSSet<
|
|
373
|
+
- (void)touchesCancelled:(NSSet<RCTUITouch *> *)touches withEvent:(UIEvent *)event // [macOS]
|
|
357
374
|
{
|
|
375
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
358
376
|
[super touchesCancelled:touches withEvent:event];
|
|
359
377
|
|
|
360
378
|
[self _updateTouches:touches];
|
|
@@ -366,6 +384,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithTarget : (id)target action : (SEL)act
|
|
|
366
384
|
} else if (AnyTouchesChanged(event.allTouches)) {
|
|
367
385
|
self.state = UIGestureRecognizerStateChanged;
|
|
368
386
|
}
|
|
387
|
+
#endif // [macOS]
|
|
369
388
|
}
|
|
370
389
|
|
|
371
390
|
- (void)reset
|
|
@@ -395,9 +414,13 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithTarget : (id)target action : (SEL)act
|
|
|
395
414
|
|
|
396
415
|
- (BOOL)canBePreventedByGestureRecognizer:(UIGestureRecognizer *)preventingGestureRecognizer
|
|
397
416
|
{
|
|
417
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
398
418
|
// We fail in favour of other external gesture recognizers.
|
|
399
419
|
// iOS will ask `delegate`'s opinion about this gesture recognizer little bit later.
|
|
400
420
|
return ![preventingGestureRecognizer.view isDescendantOfView:self.view];
|
|
421
|
+
#else // [macOS
|
|
422
|
+
return NO;
|
|
423
|
+
#endif // macOS]
|
|
401
424
|
}
|
|
402
425
|
|
|
403
426
|
#pragma mark - UIGestureRecognizerDelegate
|
|
@@ -51,13 +51,12 @@
|
|
|
51
51
|
// the contents will overflow causing the scroll indicators to appear unnecessarily.
|
|
52
52
|
NSScrollView *platformScrollView = [scrollView scrollView];
|
|
53
53
|
if ([platformScrollView scrollerStyle] == NSScrollerStyleLegacy) {
|
|
54
|
-
|
|
54
|
+
BOOL contentHasHeight = platformScrollView.contentSize.height > 0;
|
|
55
|
+
CGFloat horizontalScrollerHeight = ([platformScrollView hasHorizontalScroller] && contentHasHeight) ? NSHeight([[platformScrollView horizontalScroller] frame]) : 0;
|
|
55
56
|
CGFloat verticalScrollerWidth = [platformScrollView hasVerticalScroller] ? NSWidth([[platformScrollView verticalScroller] frame]) : 0;
|
|
56
57
|
|
|
57
|
-
RCTScrollContentLocalData *localData =
|
|
58
|
-
|
|
59
|
-
initWithVerticalScrollerWidth:horizontalScrollerHeight
|
|
60
|
-
horizontalScrollerHeight:verticalScrollerWidth];
|
|
58
|
+
RCTScrollContentLocalData *localData = [[RCTScrollContentLocalData alloc] initWithVerticalScrollerWidth:verticalScrollerWidth horizontalScrollerHeight:horizontalScrollerHeight];
|
|
59
|
+
|
|
61
60
|
[[[scrollView bridge] uiManager] setLocalData:localData forView:self];
|
|
62
61
|
}
|
|
63
62
|
|
|
@@ -118,7 +118,11 @@ UIFont *RCTFontWithFontProperties(RCTFontProperties fontProperties)
|
|
|
118
118
|
// the specific metrics of the standard system font as closely as possible.
|
|
119
119
|
font = RCTDefaultFontWithFontProperties(fontProperties);
|
|
120
120
|
} else {
|
|
121
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
121
122
|
NSArray<NSString *> *fontNames = [UIFont fontNamesForFamilyName:fontProperties.family];
|
|
123
|
+
#else // [macOS
|
|
124
|
+
NSArray<NSString *> *fontNames = @[];
|
|
125
|
+
#endif // macOS]
|
|
122
126
|
|
|
123
127
|
if (fontNames.count == 0) {
|
|
124
128
|
// Gracefully handle being given a font name rather than font family, for
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-macos",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-21aeabf4e",
|
|
4
4
|
"bin": "./cli.js",
|
|
5
5
|
"description": "React Native for macOS",
|
|
6
6
|
"license": "MIT",
|
|
@@ -133,6 +133,7 @@
|
|
|
133
133
|
},
|
|
134
134
|
"resolutions": {
|
|
135
135
|
"async": "^3.2.2",
|
|
136
|
+
"debug": ">=3.1.0",
|
|
136
137
|
"es5-ext": "0.10.53",
|
|
137
138
|
"micromatch": "^4.0.0",
|
|
138
139
|
"readable-stream": "^4.0.0",
|
|
@@ -140,6 +141,7 @@
|
|
|
140
141
|
},
|
|
141
142
|
"_justification": {
|
|
142
143
|
"async": "Versions of async prior to 3.2.2 are vulnerable to prototype pollution",
|
|
144
|
+
"debug": "ReDoS vulnerability in older versions, plus the dependents that pull in debug@<1.0.0 haven't been updated in years",
|
|
143
145
|
"es5-ext": "Packages after 0.10.54 and at the moment up until 0.10.59 contain a protest message. A policy prevents us from using packages with protestware, therefore downgrading to the latest release without the message.",
|
|
144
146
|
"micromatch": "Version 3.x.x depends on decode-uri-component 0.2.0, which has a DoS vulnerability",
|
|
145
147
|
"readable-stream": "Eliminates dependency on outdated string_decoder component",
|
package/template/Gemfile
CHANGED
package/template/Gemfile.lock
CHANGED
|
@@ -54,7 +54,7 @@ GEM
|
|
|
54
54
|
netrc (~> 0.11)
|
|
55
55
|
cocoapods-try (1.2.0)
|
|
56
56
|
colored2 (3.1.2)
|
|
57
|
-
concurrent-ruby (1.
|
|
57
|
+
concurrent-ruby (1.2.0)
|
|
58
58
|
escape (0.0.4)
|
|
59
59
|
ethon (0.16.0)
|
|
60
60
|
ffi (>= 1.15.0)
|
|
@@ -94,7 +94,7 @@ DEPENDENCIES
|
|
|
94
94
|
cocoapods (~> 1.11, >= 1.11.2)
|
|
95
95
|
|
|
96
96
|
RUBY VERSION
|
|
97
|
-
ruby 3.0.
|
|
97
|
+
ruby 3.0.5p211
|
|
98
98
|
|
|
99
99
|
BUNDLED WITH
|
|
100
|
-
2.
|
|
100
|
+
2.4.4
|
package/template/_ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.0.
|
|
1
|
+
3.0.5
|