react-native-macos 0.79.0 → 0.79.1

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.
@@ -16,6 +16,6 @@ export const version: $ReadOnly<{
16
16
  }> = {
17
17
  major: 0,
18
18
  minor: 79,
19
- patch: 0,
19
+ patch: 1,
20
20
  prerelease: null,
21
21
  };
@@ -155,6 +155,8 @@ RCT_EXPORT_METHOD(canOpenURL
155
155
  RCT_EXPORT_METHOD(getInitialURL : (RCTPromiseResolveBlock)resolve reject : (__unused RCTPromiseRejectBlock)reject)
156
156
  {
157
157
  NSURL *initialURL = nil;
158
+ #pragma clang diagnostic push // [macOS]
159
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations" // [macOS]
158
160
  if (self.bridge.launchOptions[UIApplicationLaunchOptionsURLKey]) {
159
161
  initialURL = self.bridge.launchOptions[UIApplicationLaunchOptionsURLKey];
160
162
  } else {
@@ -164,6 +166,7 @@ RCT_EXPORT_METHOD(getInitialURL : (RCTPromiseResolveBlock)resolve reject : (__un
164
166
  initialURL = ((NSUserActivity *)userActivityDictionary[@"UIApplicationLaunchOptionsUserActivityKey"]).webpageURL;
165
167
  }
166
168
  }
169
+ #pragma clang diagnostic pop // [macOS]
167
170
  resolve(RCTNullIfNil(initialURL.absoluteString));
168
171
  }
169
172
 
@@ -23,7 +23,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
23
23
  __rnVersion = @{
24
24
  RCTVersionMajor: @(0),
25
25
  RCTVersionMinor: @(79),
26
- RCTVersionPatch: @(0),
26
+ RCTVersionPatch: @(1),
27
27
  RCTVersionPrerelease: [NSNull null],
28
28
  };
29
29
  });
@@ -0,0 +1,28 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation.
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
+ #if TARGET_OS_OSX // [macOS
9
+ #import <AppKit/AppKit.h>
10
+
11
+ NS_ASSUME_NONNULL_BEGIN
12
+
13
+ @interface RCTAppearanceProxy : NSObject
14
+
15
+ + (instancetype)sharedInstance;
16
+
17
+ /*
18
+ * Property to access the current appearance.
19
+ * Thread safe.
20
+ */
21
+ @property (nonatomic, readonly) NSAppearance *currentAppearance;
22
+
23
+ - (void)startObservingAppearance;
24
+
25
+ @end
26
+
27
+ NS_ASSUME_NONNULL_END
28
+ #endif // macOS]
@@ -0,0 +1,92 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation.
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
+ #if TARGET_OS_OSX // [macOS
9
+ #import "RCTAppearanceProxy.h"
10
+
11
+ #import <React/RCTConstants.h>
12
+ #import <React/RCTUtils.h>
13
+
14
+ #import <mutex>
15
+
16
+ @implementation RCTAppearanceProxy {
17
+ BOOL _isObserving;
18
+ std::mutex _mutex;
19
+ NSAppearance *_currentAppearance;
20
+ }
21
+
22
+ + (instancetype)sharedInstance
23
+ {
24
+ static RCTAppearanceProxy *sharedInstance = nil;
25
+ static dispatch_once_t onceToken;
26
+ dispatch_once(&onceToken, ^{
27
+ sharedInstance = [RCTAppearanceProxy new];
28
+ });
29
+ return sharedInstance;
30
+ }
31
+
32
+ - (instancetype)init
33
+ {
34
+ self = [super init];
35
+ if (self) {
36
+ _isObserving = NO;
37
+ _currentAppearance = [NSApp effectiveAppearance];
38
+ }
39
+ return self;
40
+ }
41
+
42
+ - (void)startObservingAppearance
43
+ {
44
+ RCTAssertMainQueue();
45
+ std::lock_guard<std::mutex> lock(_mutex);
46
+ if (!_isObserving) {
47
+ _isObserving = YES;
48
+ [[NSNotificationCenter defaultCenter] addObserver:self
49
+ selector:@selector(_appearanceDidChange:)
50
+ name:RCTUserInterfaceStyleDidChangeNotification
51
+ object:nil];
52
+ }
53
+ }
54
+
55
+ - (NSAppearance *)currentAppearance
56
+ {
57
+ {
58
+ std::lock_guard<std::mutex> lock(_mutex);
59
+ if (_isObserving) {
60
+ return _currentAppearance;
61
+ }
62
+ }
63
+
64
+ __block NSAppearance *appearance = nil;
65
+ if (RCTIsMainQueue()) {
66
+ appearance = [NSApp effectiveAppearance];
67
+ } else {
68
+ dispatch_sync(dispatch_get_main_queue(), ^{
69
+ appearance = [NSApp effectiveAppearance];
70
+ });
71
+ }
72
+ return appearance;
73
+ }
74
+
75
+ - (void)_appearanceDidChange:(NSNotification *)notification
76
+ {
77
+ std::lock_guard<std::mutex> lock(_mutex);
78
+
79
+ NSDictionary *userInfo = [notification userInfo];
80
+ if (userInfo) {
81
+ NSAppearance *appearance = userInfo[RCTUserInterfaceStyleDidChangeNotificationAppearanceKey];
82
+ if (appearance != nil) {
83
+ _currentAppearance = appearance;
84
+ return;
85
+ }
86
+ }
87
+
88
+ _currentAppearance = [NSApp effectiveAppearance];
89
+ }
90
+
91
+ @end
92
+ #endif // macOS]
@@ -10,6 +10,9 @@
10
10
  #import "RCTKeyWindowValuesProxy.h"
11
11
  #import "RCTTraitCollectionProxy.h"
12
12
  #import "RCTWindowSafeAreaProxy.h"
13
+ #if TARGET_OS_OSX // [macOS
14
+ #import "RCTAppearanceProxy.h"
15
+ #endif // macOS]
13
16
 
14
17
  void RCTInitializeUIKitProxies(void)
15
18
  {
@@ -19,7 +22,9 @@ void RCTInitializeUIKitProxies(void)
19
22
  #if !TARGET_OS_OSX // [macOS]
20
23
  [[RCTTraitCollectionProxy sharedInstance] startObservingTraitCollection];
21
24
  [[RCTInitialAccessibilityValuesProxy sharedInstance] recordAccessibilityValues];
22
- #endif // [macOS]
25
+ #else // [macOS
26
+ [[RCTAppearanceProxy sharedInstance] startObservingAppearance];
27
+ #endif // macOS]
23
28
  [[RCTKeyWindowValuesProxy sharedInstance] startObservingWindowSizeIfNecessary];
24
29
  });
25
30
  }
@@ -14,6 +14,12 @@
14
14
 
15
15
  #import "CoreModulesPlugins.h"
16
16
 
17
+ #if TARGET_OS_OSX // [macOS
18
+ #import <React/RCTUtils.h>
19
+
20
+ #import "RCTAppearanceProxy.h"
21
+ #endif // macOS]
22
+
17
23
  using namespace facebook::react;
18
24
 
19
25
  NSString *const RCTAppearanceColorSchemeLight = @"light";
@@ -119,7 +125,7 @@ NSString *RCTColorSchemePreference(NSAppearance *appearance)
119
125
  UITraitCollection *traitCollection = [RCTTraitCollectionProxy sharedInstance].currentTraitCollection;
120
126
  _currentColorScheme = RCTColorSchemePreference(traitCollection);
121
127
  #else // [macOS
122
- NSAppearance *appearance = RCTSharedApplication().appearance;
128
+ NSAppearance *appearance = [RCTAppearanceProxy sharedInstance].currentAppearance;
123
129
  _currentColorScheme = RCTColorSchemePreference(appearance);
124
130
  #endif // macOS]
125
131
  [[NSNotificationCenter defaultCenter] addObserver:self
@@ -134,7 +140,11 @@ RCT_EXPORT_MODULE(Appearance)
134
140
 
135
141
  + (BOOL)requiresMainQueueSetup
136
142
  {
143
+ #if !TARGET_OS_OSX // [macOS]
137
144
  return NO;
145
+ #else // [macOS
146
+ return YES;
147
+ #endif // macOS]
138
148
  }
139
149
 
140
150
  - (dispatch_queue_t)methodQueue
@@ -160,13 +170,15 @@ RCT_EXPORT_METHOD(setColorScheme : (NSString *)style)
160
170
  window.overrideUserInterfaceStyle = userInterfaceStyle;
161
171
  }
162
172
  #else // [macOS
163
- NSAppearance *appearance = nil;
164
- if ([style isEqualToString:@"light"]) {
165
- appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
166
- } else if ([style isEqualToString:@"dark"]) {
167
- appearance = [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua];
168
- }
169
- RCTSharedApplication().appearance = appearance;
173
+ RCTExecuteOnMainQueue(^{
174
+ NSAppearance *appearance = nil;
175
+ if ([style isEqualToString:@"light"]) {
176
+ appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
177
+ } else if ([style isEqualToString:@"dark"]) {
178
+ appearance = [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua];
179
+ }
180
+ RCTSharedApplication().appearance = appearance;
181
+ });
170
182
  #endif // macOS]
171
183
  }
172
184
 
@@ -177,10 +189,7 @@ RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSString *, getColorScheme)
177
189
  UITraitCollection *traitCollection = [RCTTraitCollectionProxy sharedInstance].currentTraitCollection;
178
190
  _currentColorScheme = RCTColorSchemePreference(traitCollection);
179
191
  #else // [macOS
180
- __block NSAppearance *appearance = nil;
181
- RCTUnsafeExecuteOnMainQueueSync(^{
182
- appearance = RCTKeyWindow().appearance;
183
- });
192
+ NSAppearance *appearance = [RCTAppearanceProxy sharedInstance].currentAppearance;
184
193
  _currentColorScheme = RCTColorSchemePreference(appearance);
185
194
  #endif // macOS]
186
195
  }
@@ -190,23 +199,19 @@ RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSString *, getColorScheme)
190
199
 
191
200
  - (void)appearanceChanged:(NSNotification *)notification
192
201
  {
202
+ #if !TARGET_OS_OSX // [macOS
193
203
  NSDictionary *userInfo = [notification userInfo];
194
- #if !TARGET_OS_OSX // [macOS]
195
204
  UITraitCollection *traitCollection = nil;
196
205
  if (userInfo) {
197
206
  traitCollection = userInfo[RCTUserInterfaceStyleDidChangeNotificationTraitCollectionKey];
198
207
  }
199
208
  NSString *newColorScheme = RCTColorSchemePreference(traitCollection);
200
209
  #else // [macOS
201
- NSAppearance *appearance = nil;
202
- if (userInfo) {
203
- appearance = userInfo[RCTUserInterfaceStyleDidChangeNotificationAppearanceKey];
204
- }
205
- NSString *newColorScheme = RCTColorSchemePreference(appearance);
210
+ NSString *newColorScheme = RCTColorSchemePreference([RCTAppearanceProxy sharedInstance].currentAppearance);
206
211
  #endif // macOS]
207
212
  if (![_currentColorScheme isEqualToString:newColorScheme]) {
208
213
  _currentColorScheme = newColorScheme;
209
- [self sendEventWithName:@"appearanceChanged" body:@{@"colorScheme" : newColorScheme}];
214
+ [self sendEventWithName:@"appearanceChanged" body:@{ @"colorScheme" : newColorScheme }];
210
215
  }
211
216
  }
212
217
 
@@ -150,7 +150,7 @@ RCT_EXPORT_MODULE()
150
150
  #if !TARGET_OS_OSX // [macOS]
151
151
  [self->_window.rootViewController.view addSubview:self->_container];
152
152
  #else // [macOS
153
- [self->_window.contentViewController.view addSubview:self->_container];
153
+ [self->_window.contentView addSubview:self->_container];
154
154
  #endif // macOS]
155
155
  [self->_container addSubview:self->_label];
156
156
 
@@ -175,6 +175,20 @@ RCT_EXPORT_MODULE()
175
175
  [self->_label.bottomAnchor constraintEqualToAnchor:self->_container.bottomAnchor constant:-5],
176
176
  ]];
177
177
  #else // [macOS
178
+ // Container constraints
179
+ [NSLayoutConstraint activateConstraints:@[
180
+ [self->_container.topAnchor constraintEqualToAnchor:self->_window.contentView.topAnchor],
181
+ [self->_container.leadingAnchor constraintEqualToAnchor:self->_window.contentView.leadingAnchor],
182
+ [self->_container.trailingAnchor constraintEqualToAnchor:self->_window.contentView.trailingAnchor],
183
+ [self->_container.bottomAnchor constraintEqualToAnchor:self->_window.contentView.bottomAnchor],
184
+
185
+ // Label constraints
186
+ [self->_label.centerXAnchor constraintEqualToAnchor:self->_container.centerXAnchor],
187
+ [self->_label.centerYAnchor constraintEqualToAnchor:self->_container.centerYAnchor],
188
+ [self->_label.leadingAnchor constraintGreaterThanOrEqualToAnchor:self->_container.leadingAnchor constant:10],
189
+ [self->_label.trailingAnchor constraintLessThanOrEqualToAnchor:self->_container.trailingAnchor constant:-10],
190
+ ]];
191
+
178
192
  if (![[RCTKeyWindow() sheets] doesContain:self->_window]) {
179
193
  [RCTKeyWindow() beginSheet:self->_window completionHandler:^(NSModalResponse returnCode) {
180
194
  [self->_window orderOut:self];
@@ -64,7 +64,11 @@ RCT_EXPORT_MODULE()
64
64
 
65
65
  + (BOOL)requiresMainQueueSetup
66
66
  {
67
+ #if !TARGET_OS_OSX // [macOS]
68
+ return NO;
69
+ #else // [macOS
67
70
  return YES;
71
+ #endif // macOS]
68
72
  }
69
73
 
70
74
  - (dispatch_queue_t)methodQueue
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.79.0
1
+ VERSION_NAME=0.79.1
2
2
  react.internal.publishingGroup=com.facebook.react
3
3
 
4
4
  android.useAndroidX=true
@@ -17,6 +17,6 @@ public class ReactNativeVersion {
17
17
  public static final Map<String, Object> VERSION = MapBuilder.<String, Object>of(
18
18
  "major", 0,
19
19
  "minor", 79,
20
- "patch", 0,
20
+ "patch", 1,
21
21
  "prerelease", null);
22
22
  }
@@ -14,14 +14,14 @@
14
14
 
15
15
  #define REACT_NATIVE_VERSION_MAJOR 0
16
16
  #define REACT_NATIVE_VERSION_MINOR 79
17
- #define REACT_NATIVE_VERSION_PATCH 0
17
+ #define REACT_NATIVE_VERSION_PATCH 1
18
18
 
19
19
  namespace facebook::react {
20
20
 
21
21
  constexpr struct {
22
22
  int32_t Major = 0;
23
23
  int32_t Minor = 79;
24
- int32_t Patch = 0;
24
+ int32_t Patch = 1;
25
25
  std::string_view Prerelease = "";
26
26
  } ReactNativeVersion;
27
27
 
@@ -1,10 +1,15 @@
1
- require_relative '../node_modules/react-native-macos/scripts/react_native_pods'
2
- require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
1
+ require 'pathname'
2
+
3
+ ws_dir = Pathname.new(__dir__)
4
+ ws_dir = ws_dir.parent until
5
+ File.exist?("#{ws_dir}/node_modules/react-native-macos/scripts/react_native_pods.rb") ||
6
+ ws_dir.expand_path.to_s == '/'
7
+ require "#{ws_dir}/node_modules/react-native-macos/scripts/react_native_pods.rb"
3
8
 
4
9
  prepare_react_native_project!
5
10
 
6
11
  target 'HelloWorld-macOS' do
7
- platform :macos, '11.0'
12
+ platform :macos, '14.0'
8
13
  use_native_modules!
9
14
 
10
15
  # Flags change depending on the env values.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-macos",
3
- "version": "0.79.0",
3
+ "version": "0.79.1",
4
4
  "description": "React Native for macOS",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -113,7 +113,7 @@
113
113
  },
114
114
  "dependencies": {
115
115
  "@jest/create-cache-key-function": "^29.7.0",
116
- "@react-native-macos/virtualized-lists": "0.79.0",
116
+ "@react-native-macos/virtualized-lists": "0.79.1",
117
117
  "@react-native/assets-registry": "0.79.6",
118
118
  "@react-native/codegen": "0.79.6",
119
119
  "@react-native/community-cli-plugin": "0.79.6",