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.
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Network/RCTDataRequestHandler.mm +10 -3
- package/Libraries/Network/RCTFileRequestHandler.mm +11 -4
- package/React/Base/RCTRootView.m +58 -0
- package/React/Base/RCTVersion.m +1 -1
- 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/package.json +1 -1
|
@@ -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:
|
|
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:
|
|
67
|
+
[delegate URLRequest:strongOp didReceiveData:data]; // [macOS]
|
|
61
68
|
}
|
|
62
|
-
[delegate URLRequest:
|
|
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:
|
|
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:
|
|
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:
|
|
85
|
+
[delegate URLRequest:strongOp didReceiveData:data]; // [macOS]
|
|
79
86
|
}
|
|
80
|
-
[delegate URLRequest:
|
|
87
|
+
[delegate URLRequest:strongOp didCompleteWithError:error]; // [macOS]
|
|
81
88
|
}];
|
|
82
89
|
|
|
83
90
|
weakOp = op;
|
package/React/Base/RCTRootView.m
CHANGED
|
@@ -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
|
{
|
package/React/Base/RCTVersion.m
CHANGED