react-native-macos 0.75.19 → 0.75.21

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,7 +16,7 @@ const version: $ReadOnly<{
16
16
  }> = {
17
17
  major: 0,
18
18
  minor: 75,
19
- patch: 19,
19
+ patch: 21,
20
20
  prerelease: null,
21
21
  };
22
22
 
@@ -40,6 +40,13 @@ RCT_EXPORT_MODULE()
40
40
 
41
41
  __weak __block NSBlockOperation *weakOp;
42
42
  __block NSBlockOperation *op = [NSBlockOperation blockOperationWithBlock:^{
43
+ // [macOS
44
+ NSBlockOperation *strongOp = weakOp; // Strong reference to avoid deallocation during execution
45
+ if (strongOp == nil || [strongOp isCancelled]) {
46
+ return;
47
+ }
48
+ // macOS]
49
+
43
50
  // Get mime type
44
51
  NSRange firstSemicolon = [request.URL.resourceSpecifier rangeOfString:@";"];
45
52
  NSString *mimeType =
@@ -51,15 +58,15 @@ RCT_EXPORT_MODULE()
51
58
  expectedContentLength:-1
52
59
  textEncodingName:nil];
53
60
 
54
- [delegate URLRequest:weakOp didReceiveResponse:response];
61
+ [delegate URLRequest:strongOp didReceiveResponse:response]; // [macOS]
55
62
 
56
63
  // Load data
57
64
  NSError *error;
58
65
  NSData *data = [NSData dataWithContentsOfURL:request.URL options:NSDataReadingMappedIfSafe error:&error];
59
66
  if (data) {
60
- [delegate URLRequest:weakOp didReceiveData:data];
67
+ [delegate URLRequest:strongOp didReceiveData:data]; // [macOS]
61
68
  }
62
- [delegate URLRequest:weakOp didCompleteWithError:error];
69
+ [delegate URLRequest:strongOp didCompleteWithError:error]; // [macOS]
63
70
  }];
64
71
 
65
72
  weakOp = op;
@@ -48,12 +48,19 @@ RCT_EXPORT_MODULE()
48
48
 
49
49
  __weak __block NSBlockOperation *weakOp;
50
50
  __block NSBlockOperation *op = [NSBlockOperation blockOperationWithBlock:^{
51
+ // [macOS
52
+ NSBlockOperation *strongOp = weakOp; // Strong reference to avoid deallocation during execution
53
+ if (strongOp == nil || [strongOp isCancelled]) {
54
+ return;
55
+ }
56
+ // macOS]
57
+
51
58
  // Get content length
52
59
  NSError *error = nil;
53
60
  NSFileManager *fileManager = [NSFileManager new];
54
61
  NSDictionary<NSString *, id> *fileAttributes = [fileManager attributesOfItemAtPath:request.URL.path error:&error];
55
62
  if (!fileAttributes) {
56
- [delegate URLRequest:weakOp didCompleteWithError:error];
63
+ [delegate URLRequest:strongOp didCompleteWithError:error]; // [macOS]
57
64
  return;
58
65
  }
59
66
 
@@ -70,14 +77,14 @@ RCT_EXPORT_MODULE()
70
77
  expectedContentLength:[fileAttributes[NSFileSize] ?: @-1 integerValue]
71
78
  textEncodingName:nil];
72
79
 
73
- [delegate URLRequest:weakOp didReceiveResponse:response];
80
+ [delegate URLRequest:strongOp didReceiveResponse:response]; // [macOS]
74
81
 
75
82
  // Load data
76
83
  NSData *data = [NSData dataWithContentsOfURL:request.URL options:NSDataReadingMappedIfSafe error:&error];
77
84
  if (data) {
78
- [delegate URLRequest:weakOp didReceiveData:data];
85
+ [delegate URLRequest:strongOp didReceiveData:data]; // [macOS]
79
86
  }
80
- [delegate URLRequest:weakOp didCompleteWithError:error];
87
+ [delegate URLRequest:strongOp didCompleteWithError:error]; // [macOS]
81
88
  }];
82
89
 
83
90
  weakOp = op;
@@ -16,6 +16,7 @@
16
16
  #import "RCTBridge.h"
17
17
  #import "RCTConstants.h"
18
18
  #import "RCTDevSettings.h" // [macOS]
19
+ #import "RCTFocusChangeEvent.h" // [macOS]
19
20
  // [macOS] remove #import "RCTKeyCommands.h"
20
21
  #import "RCTLog.h"
21
22
  #import "RCTPerformanceLogger.h"
@@ -432,6 +433,63 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)aDecoder)
432
433
  #endif // macOS]
433
434
 
434
435
 
436
+ #pragma mark - Key window blur/focus
437
+
438
+ #if TARGET_OS_OSX // [macOS
439
+ - (void)viewDidMoveToWindow {
440
+ [super viewDidMoveToWindow];
441
+
442
+ NSWindow *window = [self window];
443
+ if (window == nil) {
444
+ return;
445
+ }
446
+
447
+ [[NSNotificationCenter defaultCenter] addObserver:self
448
+ selector:@selector(containingWindowDidBecomeKey)
449
+ name:NSWindowDidBecomeKeyNotification
450
+ object:window];
451
+
452
+ [[NSNotificationCenter defaultCenter] addObserver:self
453
+ selector:@selector(containingWindowDidResignKey)
454
+ name:NSWindowDidResignKeyNotification
455
+ object:window];
456
+ }
457
+
458
+ + (NSNumber *)reactTagClosestToView:(RCTPlatformView *)view {
459
+ // The first responder may not necessarily have a React tag. For example, if we're focused on
460
+ // a multiline <TextInput>, the RN component whose blur/focus events we need to touch is an
461
+ // RCTMultilineTextInputView, but the first responder will be the underlying RCTUITextView.
462
+ for (RCTPlatformView *testView = view; testView != nil; testView = [testView superview]) {
463
+ NSNumber *reactTag = [testView reactTag];
464
+ if (reactTag != nil) {
465
+ return reactTag;
466
+ }
467
+ }
468
+ return nil;
469
+ }
470
+
471
+ - (void)containingWindowDidBecomeKey {
472
+ NSResponder *firstResponder = [[self window] firstResponder];
473
+ if ([firstResponder isKindOfClass:[RCTPlatformView class]]) {
474
+ NSNumber *reactTag = [RCTRootView reactTagClosestToView:(RCTPlatformView *)firstResponder];
475
+ if (reactTag != nil) {
476
+ [[[self bridge] eventDispatcher] sendEvent:[RCTFocusChangeEvent focusEventWithReactTag:reactTag]];
477
+ }
478
+ }
479
+ }
480
+
481
+ - (void)containingWindowDidResignKey {
482
+ NSResponder *firstResponder = [[self window] firstResponder];
483
+ if ([firstResponder isKindOfClass:[RCTPlatformView class]]) {
484
+ NSNumber *reactTag = [RCTRootView reactTagClosestToView:(RCTPlatformView *)firstResponder];
485
+ if (reactTag != nil) {
486
+ [[[self bridge] eventDispatcher] sendEvent:[RCTFocusChangeEvent blurEventWithReactTag:reactTag]];
487
+ }
488
+ }
489
+ }
490
+ #endif // macOS]
491
+
492
+
435
493
  #if TARGET_OS_OSX // [macOS
436
494
  - (NSMenu *)menuForEvent:(NSEvent *)event
437
495
  {
@@ -23,7 +23,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
23
23
  __rnVersion = @{
24
24
  RCTVersionMajor: @(0),
25
25
  RCTVersionMinor: @(75),
26
- RCTVersionPatch: @(19),
26
+ RCTVersionPatch: @(21),
27
27
  RCTVersionPrerelease: [NSNull null],
28
28
  };
29
29
  });
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.75.19
1
+ VERSION_NAME=0.75.21
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", 75,
20
- "patch", 19,
20
+ "patch", 21,
21
21
  "prerelease", null);
22
22
  }
@@ -17,7 +17,7 @@ namespace facebook::react {
17
17
  constexpr struct {
18
18
  int32_t Major = 0;
19
19
  int32_t Minor = 75;
20
- int32_t Patch = 19;
20
+ int32_t Patch = 21;
21
21
  std::string_view Prerelease = "";
22
22
  } ReactNativeVersion;
23
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-macos",
3
- "version": "0.75.19",
3
+ "version": "0.75.21",
4
4
  "description": "React Native for macOS",
5
5
  "license": "MIT",
6
6
  "repository": {