Skip to content

Commit

Permalink
Followup changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Saadnajmi committed Feb 6, 2025
1 parent 24d0ddf commit fb97b38
Show file tree
Hide file tree
Showing 32 changed files with 205 additions and 196 deletions.
6 changes: 3 additions & 3 deletions .ado/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ variables:
- group: InfoSec-SecurityResults
- name: tags
value: production,externalfacing
# CodeQL Still has not fixed their bug running on Apple ARM64 jobs where they inject x64 binaries into arm64 processes and just make it crash :(
# Only workaround for now is to disable CodeQL on Apple jobs.
- name Codeql.Enabled
# CodeQL Still has not fixed their bug running on Apple ARM64 jobs where they inject x64 binaries into arm64 processes and just make it crash :(
# Only workaround for now is to disable CodeQL on Apple jobs.
- name: Codeql.Enabled
value: false
- template: /.ado/variables/vars.yml@self

Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ PLATFORMS
DEPENDENCIES
activesupport (>= 6.1.7.5, < 7.1.0)
cocoapods (~> 1.13, != 1.15.1, != 1.15.0)
concurrent-ruby (< 1.3.4)
xcodeproj (< 1.26.0)

RUBY VERSION
ruby 3.3.0p0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,4 @@ NS_ASSUME_NONNULL_BEGIN

@end

NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void RCTAppSetupPrepareApp(UIApplication *application, BOOL turboModuleEnabled)
id<RCTSurfaceProtocol> surface = [[RCTFabricSurface alloc] initWithBridge:bridge
moduleName:moduleName
initialProperties:initialProperties];
UIView *rootView = [[RCTSurfaceHostingProxyRootView alloc] initWithSurface:surface];
RCTUIView *rootView = [[RCTSurfaceHostingProxyRootView alloc] initWithSurface:surface]; // [macOS]
[surface start];
return rootView;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

#import <React/RCTConvert.h>
#import <UIKit/UIKit.h>
#import <React/RCTUIKit.h>

@protocol RCTArchConfiguratorProtocol
/// This method controls whether the `turboModules` feature of the New Architecture is turned on or off.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

#import <React/RCTConvert.h>
#import <UIKit/UIKit.h>
#import <React/RCTUIKit.h>

@class RCTRootView;

Expand Down Expand Up @@ -52,5 +52,5 @@
* If you are not using a simple UIViewController, then there could be other methods to use to setup the rootView.
* For example: UISplitViewController requires `setViewController(_:for:)`
*/
- (void)setRootView:(UIView *)rootView toRootViewController:(UIViewController *)rootViewController;
- (void)setRootView:(RCTPlatformView *)rootView toRootViewController:(RCTPlatformViewController *)rootViewController; // [macOS]
@end
15 changes: 0 additions & 15 deletions packages/react-native/Libraries/Utilities/LoadingView.macos.js

This file was deleted.

15 changes: 7 additions & 8 deletions packages/react-native/React/Base/RCTUIKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ UIKIT_STATIC_INLINE CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *path)
#define RCTPlatformView UIView
#define RCTUIView UIView
#define RCTUIScrollView UIScrollView
#define RCTPlatformWindow UIWindow

UIKIT_STATIC_INLINE RCTPlatformView *RCTUIViewHitTestWithEvent(RCTPlatformView *view, CGPoint point, __unused UIEvent *__nullable event)
{
Expand Down Expand Up @@ -218,6 +217,7 @@ typedef NS_ENUM(NSInteger, UIViewContentMode) {
UIViewContentModeScaleAspectFit = NSViewLayerContentsPlacementScaleProportionallyToFit,
UIViewContentModeScaleToFill = NSViewLayerContentsPlacementScaleAxesIndependently,
UIViewContentModeCenter = NSViewLayerContentsPlacementCenter,
UIViewContentModeTopLeft = NSViewLayerContentsPlacementTopLeft,
};

// UIInterface.h/NSUserInterfaceLayout.h
Expand Down Expand Up @@ -378,8 +378,6 @@ CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *path);
// UIView
#define RCTPlatformView NSView

#define RCTPlatformWindow NSWindow

@interface RCTUIView : RCTPlatformView

@property (nonatomic, readonly) BOOL canBecomeFirstResponder;
Expand Down Expand Up @@ -410,7 +408,7 @@ CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *path);
- (void)sendMouseEventWithBlock:(RCTDirectEventBlock)block
locationInfo:(NSDictionary*)locationInfo
modifierFlags:(NSEventModifierFlags)modifierFlags
additionalData:(NSDictionary*)additionalData;
additionalData:(NSDictionary* __nullable)additionalData;

// FUTURE: When Xcode 14 is no longer supported (CI is building with Xcode 15), we can remove this override since it's now declared on NSView
@property BOOL clipsToBounds;
Expand Down Expand Up @@ -524,12 +522,12 @@ NS_ASSUME_NONNULL_END

#if !TARGET_OS_OSX
typedef UIApplication RCTUIApplication;
typedef UIWindow RCTUIWindow;
typedef UIViewController RCTUIViewController;
typedef UIWindow RCTPlatformWindow;
typedef UIViewController RCTPlatformViewController;
#else
typedef NSApplication RCTUIApplication;
typedef NSWindow RCTUIWindow;
typedef NSViewController RCTUIViewController;
typedef NSWindow RCTPlatformWindow;
typedef NSViewController RCTPlatformViewController;
#endif

//
Expand Down Expand Up @@ -660,6 +658,7 @@ typedef void (^RCTUIGraphicsImageDrawingActions)(RCTUIGraphicsImageRendererConte

@interface RCTUIGraphicsImageRenderer : NSObject

- (instancetype)initWithSize:(CGSize)size;
- (instancetype)initWithSize:(CGSize)size format:(RCTUIGraphicsImageRendererFormat *)format;
- (NSImage *)imageWithActions:(NS_NOESCAPE RCTUIGraphicsImageDrawingActions)actions;

Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/React/Base/RCTUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ RCT_EXTERN RCTUIApplication *__nullable RCTSharedApplication(void); // [macOS]

// Returns the current main window, useful if you need to access the root view
// or view controller
RCT_EXTERN RCTUIWindow *__nullable RCTKeyWindow(void); // [macOS]
RCT_EXTERN RCTPlatformWindow *__nullable RCTKeyWindow(void); // [macOS]

#if !TARGET_OS_OSX // [macOS]
// Returns UIStatusBarManager to get it's configuration info.
Expand All @@ -109,10 +109,10 @@ RCT_EXTERN UIViewController *__nullable RCTPresentedViewController(void);

// Retrieve current window UIStatusBarManager
RCT_EXTERN UIStatusBarManager *__nullable RCTUIStatusBarManager(void) API_AVAILABLE(ios(13));
#endif // [macOS]

// Does this device support force touch (aka 3D Touch)?
RCT_EXTERN BOOL RCTForceTouchAvailable(void);
#endif // [macOS]

// Create an NSError in the RCTErrorDomain
RCT_EXTERN NSError *RCTErrorWithMessage(NSString *message);
Expand Down
12 changes: 8 additions & 4 deletions packages/react-native/React/Base/RCTUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ CGSize RCTScreenSize(void)

CGSize RCTViewportSize(void)
{
RCTUIWindow *window = RCTKeyWindow(); // [macOS]
RCTPlatformWindow *window = RCTKeyWindow(); // [macOS]
#if !TARGET_OS_OSX // [macOS]
return window ? window.bounds.size : RCTScreenSize();
#else // [macOS
Expand Down Expand Up @@ -595,7 +595,7 @@ BOOL RCTRunningInAppExtension(void)
#endif // macOS]
}

RCTUIWindow *__nullable RCTKeyWindow(void) // [macOS]
RCTPlatformWindow *__nullable RCTKeyWindow(void) // [macOS]
{
#if !TARGET_OS_OSX // [macOS]
if (RCTRunningInAppExtension()) {
Expand Down Expand Up @@ -659,18 +659,22 @@ BOOL RCTRunningInAppExtension(void)

return controller;
}
#endif // [macOS]

BOOL RCTForceTouchAvailable(void)
{
static BOOL forceSupported;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
#if !TARGET_OS_OSX // [macOS]
forceSupported = [UITraitCollection currentTraitCollection].forceTouchCapability == UIForceTouchCapabilityAvailable;
#else // [macOS
forceSupported = NO;
#endif // macOS]
});

return forceSupported;
}
#endif // [macOS]

NSError *RCTErrorWithMessage(NSString *message)
{
Expand Down Expand Up @@ -885,7 +889,7 @@ BOOL RCTIsLocalAssetURL(NSURL *__nullable imageURL)
}

#if TARGET_OS_OSX // [macOS
static NSCache<NSURL *, UIImage *> *RCTLocalImageCache()
static NSCache<NSURL *, UIImage *> *RCTLocalImageCache(void)
{
static NSCache *imageCache;
static dispatch_once_t onceToken;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ @interface RCTSurfaceHostingView ()
@end

@implementation RCTSurfaceHostingView {
RCTUIView *_Nullable _activityIndicatorView; // [macOS]
RCTUIView *_Nullable _surfaceView; // [macOS]
RCTPlatformView *_Nullable _activityIndicatorView; // [macOS]
RCTPlatformView *_Nullable _surfaceView; // [macOS]
RCTSurfaceStage _stage;
BOOL _autoHideDisabled;
}
Expand Down
42 changes: 0 additions & 42 deletions packages/react-native/React/Base/macOS/RCTPlatform.m

This file was deleted.

24 changes: 18 additions & 6 deletions packages/react-native/React/Base/macOS/RCTUIKit.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ CGFloat UIImageGetScale(NSImage *image)
return 1.0;
}

CGImageRef UIImageGetCGImageRef(NSImage *image)
CGImageRef __nullable UIImageGetCGImageRef(NSImage *image)
{
return [image CGImageForProposedRect:NULL context:NULL hints:NULL];
}
Expand Down Expand Up @@ -132,23 +132,23 @@ CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *bezierPath)
{
switch ([bezierPath elementAtIndex:i associatedPoints:points])
{
case NSMoveToBezierPathElement:
case NSBezierPathElementMoveTo:
CGPathMoveToPoint(path, NULL, points[0].x, points[0].y);
break;

case NSLineToBezierPathElement:
case NSBezierPathElementLineTo:
CGPathAddLineToPoint(path, NULL, points[0].x, points[0].y);
didClosePath = NO;
break;

case NSCurveToBezierPathElement:
case NSBezierPathElementCurveTo:
CGPathAddCurveToPoint(path, NULL, points[0].x, points[0].y,
points[1].x, points[1].y,
points[2].x, points[2].y);
didClosePath = NO;
break;

case NSClosePathBezierPathElement:
case NSBezierPathElementClosePath:
CGPathCloseSubpath(path);
didClosePath = YES;
break;
Expand Down Expand Up @@ -364,7 +364,7 @@ - (void)mouseExited:(NSEvent *)event
- (void)sendMouseEventWithBlock:(RCTDirectEventBlock)block
locationInfo:(NSDictionary*)locationInfo
modifierFlags:(NSEventModifierFlags)modifierFlags
additionalData:(NSDictionary*)additionalData
additionalData:(NSDictionary* __nullable)additionalData
{
if (block == nil) {
return;
Expand Down Expand Up @@ -781,6 +781,11 @@ - (instancetype)initWithFrame:(NSRect)frameRect
return self;
}

- (void)setText:(NSString *)text
{
[self setStringValue:text];
}

@end

@implementation RCTUISwitch
Expand Down Expand Up @@ -1018,6 +1023,13 @@ @implementation RCTUIGraphicsImageRenderer
RCTUIGraphicsImageRendererFormat *_format;
}

- (nonnull instancetype)initWithSize:(CGSize)size {
if (self = [super init]) {
self->_size = size;
}
return self;
}

- (nonnull instancetype)initWithSize:(CGSize)size format:(nonnull RCTUIGraphicsImageRendererFormat *)format {
if (self = [super init]) {
self->_size = size;
Expand Down
4 changes: 4 additions & 0 deletions packages/react-native/React/CoreModules/RCTFPSGraph.mm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

#if !TARGET_OS_OSX // [macOS

#import <React/RCTFPSGraph.h>

#import <React/RCTAssert.h>
Expand Down Expand Up @@ -126,3 +128,5 @@ - (void)onTick:(NSTimeInterval)timestamp
@end

#endif

#endif // macOS]
4 changes: 2 additions & 2 deletions packages/react-native/React/CoreModules/RCTLogBoxView.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

- (void)createRootViewController:(RCTUIView *)view; // [macOS]

- (instancetype)initWithWindow:(RCTUIWindow *)window bridge:(RCTBridge *)bridge; // [macOS]
- (instancetype)initWithWindow:(RCTUIWindow *)window surfacePresenter:(id<RCTSurfacePresenterStub>)surfacePresenter; // [macOS]
- (instancetype)initWithWindow:(RCTPlatformWindow *)window bridge:(RCTBridge *)bridge; // [macOS]
- (instancetype)initWithWindow:(RCTPlatformWindow *)window surfacePresenter:(id<RCTSurfacePresenterStub>)surfacePresenter; // [macOS]

- (void)show;
#if TARGET_OS_OSX // [macOS
Expand Down
6 changes: 3 additions & 3 deletions packages/react-native/React/CoreModules/RCTLogBoxView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ - (instancetype)initWithFrame:(CGRect)frame

- (void)createRootViewController:(RCTUIView *)view // [macOS]
{
RCTUIViewController *_rootViewController = [RCTUIViewController new]; // [macOS]
RCTPlatformViewController *_rootViewController = [RCTPlatformViewController new]; // [macOS]
_rootViewController.view = view;
#if !TARGET_OS_OSX // [macOS]
_rootViewController.view.backgroundColor = [UIColor clearColor];
Expand All @@ -44,7 +44,7 @@ - (void)createRootViewController:(RCTUIView *)view // [macOS]
#endif // macOS]
}

- (instancetype)initWithWindow:(RCTUIWindow *)window bridge:(RCTBridge *)bridge // [macOS]
- (instancetype)initWithWindow:(RCTPlatformWindow *)window bridge:(RCTBridge *)bridge // [macOS]
{
RCTErrorNewArchitectureValidation(RCTNotAllowedInFabricWithoutLegacy, @"RCTLogBoxView", nil);

Expand Down Expand Up @@ -74,7 +74,7 @@ - (instancetype)initWithWindow:(RCTUIWindow *)window bridge:(RCTBridge *)bridge
return self;
}

- (instancetype)initWithWindow:(RCTUIWindow *)window surfacePresenter:(id<RCTSurfacePresenterStub>)surfacePresenter // [macOS]
- (instancetype)initWithWindow:(RCTPlatformWindow *)window surfacePresenter:(id<RCTSurfacePresenterStub>)surfacePresenter // [macOS]
{
#if !TARGET_OS_OSX // [macOS]
self = [super initWithWindowScene:window.windowScene];
Expand Down
Loading

0 comments on commit fb97b38

Please sign in to comment.