react-native-macos 0.78.1 → 0.78.3
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/Components/TextInput/TextInput.d.ts +16 -0
- package/Libraries/Components/TextInput/TextInput.flow.js +2 -0
- package/Libraries/Components/TextInput/TextInput.js +7 -3
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Network/RCTDataRequestHandler.mm +24 -13
- package/Libraries/Network/RCTFileRequestHandler.mm +25 -14
- package/Libraries/Text/TextInput/RCTBaseTextInputView.mm +7 -0
- package/React/Base/RCTVersion.m +1 -1
- package/React/CoreModules/RCTDevLoadingView.mm +11 -4
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +13 -8
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java +0 -3
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.mm +24 -13
- package/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm +5 -1
- package/package.json +10 -11
|
@@ -1089,6 +1089,22 @@ interface TextInputState {
|
|
|
1089
1089
|
* noop if it wasn't focused
|
|
1090
1090
|
*/
|
|
1091
1091
|
blurTextInput(textField?: HostInstance): void;
|
|
1092
|
+
|
|
1093
|
+
// [macOS
|
|
1094
|
+
/**
|
|
1095
|
+
* @param textField ref of the text field that was focused
|
|
1096
|
+
* Call on custom implementations of TextInput to notify the control was focused
|
|
1097
|
+
* noop if it was already focused
|
|
1098
|
+
*/
|
|
1099
|
+
onTextInputFocus(textField?: HostInstance): void;
|
|
1100
|
+
|
|
1101
|
+
/**
|
|
1102
|
+
* @param textField ref of the text field that was blurred
|
|
1103
|
+
* Call on custom implementations of TextInput to notify the control was blurred
|
|
1104
|
+
* noop if it wasn't focused
|
|
1105
|
+
*/
|
|
1106
|
+
onTextInputBlur(textField?: HostInstance): void;
|
|
1107
|
+
// macOS]
|
|
1092
1108
|
}
|
|
1093
1109
|
|
|
1094
1110
|
/**
|
|
@@ -1255,6 +1255,8 @@ export type TextInputComponentStatics = $ReadOnly<{|
|
|
|
1255
1255
|
currentlyFocusedField: () => ?number,
|
|
1256
1256
|
focusTextInput: (textField: ?HostInstance) => void,
|
|
1257
1257
|
blurTextInput: (textField: ?HostInstance) => void,
|
|
1258
|
+
onTextInputFocus: (textField: ?HostInstance) => void, // [macOS]
|
|
1259
|
+
onTextInputBlur: (textField: ?HostInstance) => void, // [macOS]
|
|
1258
1260
|
|}>,
|
|
1259
1261
|
|}>;
|
|
1260
1262
|
|
|
@@ -1166,7 +1166,7 @@ function useTextInputStateSynchronization_STATE({
|
|
|
1166
1166
|
mostRecentEventCount: number,
|
|
1167
1167
|
selection: ?Selection,
|
|
1168
1168
|
inputRef: React.RefObject<null | HostInstance>,
|
|
1169
|
-
text
|
|
1169
|
+
text?: string,
|
|
1170
1170
|
viewCommands: ViewCommands,
|
|
1171
1171
|
}): {
|
|
1172
1172
|
setLastNativeText: string => void,
|
|
@@ -1247,7 +1247,7 @@ function useTextInputStateSynchronization_REFS({
|
|
|
1247
1247
|
mostRecentEventCount: number,
|
|
1248
1248
|
selection: ?Selection,
|
|
1249
1249
|
inputRef: React.RefObject<null | HostInstance>,
|
|
1250
|
-
text
|
|
1250
|
+
text?: string,
|
|
1251
1251
|
viewCommands: ViewCommands,
|
|
1252
1252
|
}): {
|
|
1253
1253
|
setLastNativeText: string => void,
|
|
@@ -1474,7 +1474,7 @@ function InternalTextInput(props: Props): React.Node {
|
|
|
1474
1474
|
? props.value
|
|
1475
1475
|
: typeof props.defaultValue === 'string'
|
|
1476
1476
|
? props.defaultValue
|
|
1477
|
-
:
|
|
1477
|
+
: undefined;
|
|
1478
1478
|
|
|
1479
1479
|
const viewCommands =
|
|
1480
1480
|
AndroidTextInputCommands ||
|
|
@@ -2045,6 +2045,8 @@ ExportedForwardRef.State = {
|
|
|
2045
2045
|
currentlyFocusedField: TextInputState.currentlyFocusedField,
|
|
2046
2046
|
focusTextInput: TextInputState.focusTextInput,
|
|
2047
2047
|
blurTextInput: TextInputState.blurTextInput,
|
|
2048
|
+
onTextInputFocus: TextInputState.focusInput, // [macOS]
|
|
2049
|
+
onTextInputBlur: TextInputState.blurInput, // [macOS]
|
|
2048
2050
|
};
|
|
2049
2051
|
|
|
2050
2052
|
export type TextInputComponentStatics = $ReadOnly<{|
|
|
@@ -2053,6 +2055,8 @@ export type TextInputComponentStatics = $ReadOnly<{|
|
|
|
2053
2055
|
currentlyFocusedField: typeof TextInputState.currentlyFocusedField,
|
|
2054
2056
|
focusTextInput: typeof TextInputState.focusTextInput,
|
|
2055
2057
|
blurTextInput: typeof TextInputState.blurTextInput,
|
|
2058
|
+
onTextInputFocus: typeof TextInputState.focusInput, // [macOS]
|
|
2059
|
+
onTextInputBlur: typeof TextInputState.blurInput, // [macOS]
|
|
2056
2060
|
|}>,
|
|
2057
2061
|
|}>;
|
|
2058
2062
|
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
#import <React/RCTDataRequestHandler.h>
|
|
9
9
|
#import <ReactCommon/RCTTurboModule.h>
|
|
10
10
|
|
|
11
|
+
#import <mutex>
|
|
12
|
+
|
|
11
13
|
#import "RCTNetworkPlugins.h"
|
|
12
14
|
|
|
13
15
|
@interface RCTDataRequestHandler () <RCTTurboModule>
|
|
@@ -15,14 +17,22 @@
|
|
|
15
17
|
|
|
16
18
|
@implementation RCTDataRequestHandler {
|
|
17
19
|
NSOperationQueue *_queue;
|
|
20
|
+
std::mutex _operationHandlerMutexLock;
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
RCT_EXPORT_MODULE()
|
|
21
24
|
|
|
22
25
|
- (void)invalidate
|
|
23
26
|
{
|
|
24
|
-
|
|
25
|
-
_queue
|
|
27
|
+
std::lock_guard<std::mutex> lock(_operationHandlerMutexLock);
|
|
28
|
+
if (_queue) {
|
|
29
|
+
for (NSOperation *operation in _queue.operations) {
|
|
30
|
+
if (!operation.isCancelled && !operation.isFinished) {
|
|
31
|
+
[operation cancel];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
_queue = nil;
|
|
35
|
+
}
|
|
26
36
|
}
|
|
27
37
|
|
|
28
38
|
- (BOOL)canHandleRequest:(NSURLRequest *)request
|
|
@@ -32,21 +42,20 @@ RCT_EXPORT_MODULE()
|
|
|
32
42
|
|
|
33
43
|
- (NSOperation *)sendRequest:(NSURLRequest *)request withDelegate:(id<RCTURLRequestDelegate>)delegate
|
|
34
44
|
{
|
|
45
|
+
std::lock_guard<std::mutex> lock(_operationHandlerMutexLock);
|
|
35
46
|
// Lazy setup
|
|
36
47
|
if (!_queue) {
|
|
37
48
|
_queue = [NSOperationQueue new];
|
|
38
49
|
_queue.maxConcurrentOperationCount = 2;
|
|
39
50
|
}
|
|
40
51
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
NSBlockOperation *strongOp = weakOp;
|
|
52
|
+
NSBlockOperation *op = [NSBlockOperation new];
|
|
53
|
+
__weak NSBlockOperation *weakOp = op;
|
|
54
|
+
[op addExecutionBlock:^{
|
|
55
|
+
NSBlockOperation *strongOp = weakOp; // Strong reference to avoid deallocation during execution
|
|
45
56
|
if (strongOp == nil || [strongOp isCancelled]) {
|
|
46
57
|
return;
|
|
47
58
|
}
|
|
48
|
-
// macOS]
|
|
49
|
-
|
|
50
59
|
// Get mime type
|
|
51
60
|
NSRange firstSemicolon = [request.URL.resourceSpecifier rangeOfString:@";"];
|
|
52
61
|
NSString *mimeType =
|
|
@@ -58,25 +67,27 @@ RCT_EXPORT_MODULE()
|
|
|
58
67
|
expectedContentLength:-1
|
|
59
68
|
textEncodingName:nil];
|
|
60
69
|
|
|
61
|
-
[delegate URLRequest:strongOp didReceiveResponse:response];
|
|
70
|
+
[delegate URLRequest:strongOp didReceiveResponse:response];
|
|
62
71
|
|
|
63
72
|
// Load data
|
|
64
73
|
NSError *error;
|
|
65
74
|
NSData *data = [NSData dataWithContentsOfURL:request.URL options:NSDataReadingMappedIfSafe error:&error];
|
|
66
75
|
if (data) {
|
|
67
|
-
[delegate URLRequest:strongOp didReceiveData:data];
|
|
76
|
+
[delegate URLRequest:strongOp didReceiveData:data];
|
|
68
77
|
}
|
|
69
|
-
[delegate URLRequest:strongOp didCompleteWithError:error];
|
|
78
|
+
[delegate URLRequest:strongOp didCompleteWithError:error];
|
|
70
79
|
}];
|
|
71
80
|
|
|
72
|
-
weakOp = op;
|
|
73
81
|
[_queue addOperation:op];
|
|
74
82
|
return op;
|
|
75
83
|
}
|
|
76
84
|
|
|
77
85
|
- (void)cancelRequest:(NSOperation *)op
|
|
78
86
|
{
|
|
79
|
-
|
|
87
|
+
std::lock_guard<std::mutex> lock(_operationHandlerMutexLock);
|
|
88
|
+
if (!op.isCancelled && !op.isFinished) {
|
|
89
|
+
[op cancel];
|
|
90
|
+
}
|
|
80
91
|
}
|
|
81
92
|
|
|
82
93
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
#import <React/RCTFileRequestHandler.h>
|
|
9
9
|
|
|
10
|
+
#import <mutex>
|
|
11
|
+
|
|
10
12
|
#if !TARGET_OS_OSX // [macOS]
|
|
11
13
|
#import <MobileCoreServices/MobileCoreServices.h>
|
|
12
14
|
#else // [macOS
|
|
@@ -23,14 +25,22 @@
|
|
|
23
25
|
|
|
24
26
|
@implementation RCTFileRequestHandler {
|
|
25
27
|
NSOperationQueue *_fileQueue;
|
|
28
|
+
std::mutex _operationHandlerMutexLock;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
RCT_EXPORT_MODULE()
|
|
29
32
|
|
|
30
33
|
- (void)invalidate
|
|
31
34
|
{
|
|
32
|
-
|
|
33
|
-
_fileQueue
|
|
35
|
+
std::lock_guard<std::mutex> lock(_operationHandlerMutexLock);
|
|
36
|
+
if (_fileQueue) {
|
|
37
|
+
for (NSOperation *operation in _fileQueue.operations) {
|
|
38
|
+
if (!operation.isCancelled && !operation.isFinished) {
|
|
39
|
+
[operation cancel];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
_fileQueue = nil;
|
|
43
|
+
}
|
|
34
44
|
}
|
|
35
45
|
|
|
36
46
|
- (BOOL)canHandleRequest:(NSURLRequest *)request
|
|
@@ -40,27 +50,26 @@ RCT_EXPORT_MODULE()
|
|
|
40
50
|
|
|
41
51
|
- (NSOperation *)sendRequest:(NSURLRequest *)request withDelegate:(id<RCTURLRequestDelegate>)delegate
|
|
42
52
|
{
|
|
53
|
+
std::lock_guard<std::mutex> lock(_operationHandlerMutexLock);
|
|
43
54
|
// Lazy setup
|
|
44
55
|
if (!_fileQueue) {
|
|
45
56
|
_fileQueue = [NSOperationQueue new];
|
|
46
57
|
_fileQueue.maxConcurrentOperationCount = 4;
|
|
47
58
|
}
|
|
48
59
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
NSBlockOperation *strongOp = weakOp;
|
|
60
|
+
NSBlockOperation *op = [NSBlockOperation new];
|
|
61
|
+
__weak NSBlockOperation *weakOp = op;
|
|
62
|
+
[op addExecutionBlock:^{
|
|
63
|
+
NSBlockOperation *strongOp = weakOp; // Strong reference to avoid deallocation during execution
|
|
53
64
|
if (strongOp == nil || [strongOp isCancelled]) {
|
|
54
65
|
return;
|
|
55
66
|
}
|
|
56
|
-
// macOS]
|
|
57
|
-
|
|
58
67
|
// Get content length
|
|
59
68
|
NSError *error = nil;
|
|
60
69
|
NSFileManager *fileManager = [NSFileManager new];
|
|
61
70
|
NSDictionary<NSString *, id> *fileAttributes = [fileManager attributesOfItemAtPath:request.URL.path error:&error];
|
|
62
71
|
if (!fileAttributes) {
|
|
63
|
-
[delegate URLRequest:strongOp didCompleteWithError:error];
|
|
72
|
+
[delegate URLRequest:strongOp didCompleteWithError:error];
|
|
64
73
|
return;
|
|
65
74
|
}
|
|
66
75
|
|
|
@@ -77,24 +86,26 @@ RCT_EXPORT_MODULE()
|
|
|
77
86
|
expectedContentLength:[fileAttributes[NSFileSize] ?: @-1 integerValue]
|
|
78
87
|
textEncodingName:nil];
|
|
79
88
|
|
|
80
|
-
[delegate URLRequest:strongOp didReceiveResponse:response];
|
|
89
|
+
[delegate URLRequest:strongOp didReceiveResponse:response];
|
|
81
90
|
|
|
82
91
|
// Load data
|
|
83
92
|
NSData *data = [NSData dataWithContentsOfURL:request.URL options:NSDataReadingMappedIfSafe error:&error];
|
|
84
93
|
if (data) {
|
|
85
|
-
[delegate URLRequest:strongOp didReceiveData:data];
|
|
94
|
+
[delegate URLRequest:strongOp didReceiveData:data];
|
|
86
95
|
}
|
|
87
|
-
[delegate URLRequest:strongOp didCompleteWithError:error];
|
|
96
|
+
[delegate URLRequest:strongOp didCompleteWithError:error];
|
|
88
97
|
}];
|
|
89
98
|
|
|
90
|
-
weakOp = op;
|
|
91
99
|
[_fileQueue addOperation:op];
|
|
92
100
|
return op;
|
|
93
101
|
}
|
|
94
102
|
|
|
95
103
|
- (void)cancelRequest:(NSOperation *)op
|
|
96
104
|
{
|
|
97
|
-
|
|
105
|
+
std::lock_guard<std::mutex> lock(_operationHandlerMutexLock);
|
|
106
|
+
if (!op.isCancelled && !op.isFinished) {
|
|
107
|
+
[op cancel];
|
|
108
|
+
}
|
|
98
109
|
}
|
|
99
110
|
|
|
100
111
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
@@ -513,6 +513,13 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)decoder)
|
|
|
513
513
|
|
|
514
514
|
- (void)textInputDidBeginEditing
|
|
515
515
|
{
|
|
516
|
+
#if TARGET_OS_OSX // [macOS
|
|
517
|
+
if (_isCurrentlyEditing) {
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
_isCurrentlyEditing = YES;
|
|
521
|
+
#endif // macOS]
|
|
522
|
+
|
|
516
523
|
[_eventDispatcher sendTextEventWithType:RCTTextEventTypeFocus
|
|
517
524
|
reactTag:self.reactTag
|
|
518
525
|
text:[self.backedTextInputView.attributedText.string copy]
|
package/React/Base/RCTVersion.m
CHANGED
|
@@ -24,6 +24,8 @@
|
|
|
24
24
|
|
|
25
25
|
using namespace facebook::react;
|
|
26
26
|
|
|
27
|
+
static NSString *sRCTDevLoadingViewWindowIdentifier = @"RCTDevLoadingViewWindow";
|
|
28
|
+
|
|
27
29
|
@interface RCTDevLoadingView () <NativeDevLoadingViewSpec>
|
|
28
30
|
@end
|
|
29
31
|
|
|
@@ -121,16 +123,17 @@ RCT_EXPORT_MODULE()
|
|
|
121
123
|
|
|
122
124
|
self->_showDate = [NSDate date];
|
|
123
125
|
|
|
124
|
-
RCTPlatformWindow *mainWindow = RCTKeyWindow(); // [macOS]
|
|
125
126
|
#if !TARGET_OS_OSX // [macOS]
|
|
127
|
+
UIWindow *mainWindow = RCTKeyWindow();
|
|
126
128
|
self->_window = [[UIWindow alloc] initWithWindowScene:mainWindow.windowScene];
|
|
127
129
|
self->_window.windowLevel = UIWindowLevelStatusBar + 1;
|
|
128
130
|
self->_window.rootViewController = [UIViewController new];
|
|
129
131
|
#else // [macOS
|
|
130
|
-
self->_window = [[
|
|
132
|
+
self->_window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 375, 20)
|
|
131
133
|
styleMask:NSWindowStyleMaskBorderless
|
|
132
134
|
backing:NSBackingStoreBuffered
|
|
133
135
|
defer:YES];
|
|
136
|
+
[self->_window setIdentifier:sRCTDevLoadingViewWindowIdentifier];
|
|
134
137
|
#endif // macOS]
|
|
135
138
|
|
|
136
139
|
self->_container = [[RCTUIView alloc] init]; // [macOS]
|
|
@@ -220,7 +223,11 @@ RCT_EXPORT_METHOD(hide)
|
|
|
220
223
|
self->_hiding = false;
|
|
221
224
|
}];
|
|
222
225
|
#else // [macOS]
|
|
223
|
-
[RCTKeyWindow()
|
|
226
|
+
for (NSWindow *window in [RCTKeyWindow() sheets]) {
|
|
227
|
+
if ([[window identifier] isEqualToString:sRCTDevLoadingViewWindowIdentifier]) {
|
|
228
|
+
[RCTKeyWindow() endSheet:window];
|
|
229
|
+
}
|
|
230
|
+
}
|
|
224
231
|
self->_window = nil;
|
|
225
232
|
self->_hiding = false;
|
|
226
233
|
#endif // macOS]
|
|
@@ -350,4 +357,4 @@ RCT_EXPORT_METHOD(hide)
|
|
|
350
357
|
Class RCTDevLoadingViewCls(void)
|
|
351
358
|
{
|
|
352
359
|
return RCTDevLoadingView.class;
|
|
353
|
-
}
|
|
360
|
+
}
|
|
@@ -173,7 +173,7 @@ public class FabricUIManager
|
|
|
173
173
|
private final CopyOnWriteArrayList<UIManagerListener> mListeners = new CopyOnWriteArrayList<>();
|
|
174
174
|
|
|
175
175
|
private boolean mMountNotificationScheduled = false;
|
|
176
|
-
private
|
|
176
|
+
private List<Integer> mSurfaceIdsWithPendingMountNotification = new ArrayList<>();
|
|
177
177
|
|
|
178
178
|
@ThreadConfined(UI)
|
|
179
179
|
@NonNull
|
|
@@ -1250,12 +1250,15 @@ public class FabricUIManager
|
|
|
1250
1250
|
|
|
1251
1251
|
// Collect surface IDs for all the mount items
|
|
1252
1252
|
for (MountItem mountItem : mountItems) {
|
|
1253
|
-
if (mountItem != null
|
|
1254
|
-
|
|
1253
|
+
if (mountItem != null
|
|
1254
|
+
&& !mSurfaceIdsWithPendingMountNotification.contains(mountItem.getSurfaceId())) {
|
|
1255
|
+
mSurfaceIdsWithPendingMountNotification.add(mountItem.getSurfaceId());
|
|
1255
1256
|
}
|
|
1256
1257
|
}
|
|
1257
1258
|
|
|
1258
|
-
if (!mMountNotificationScheduled && !
|
|
1259
|
+
if (!mMountNotificationScheduled && !mSurfaceIdsWithPendingMountNotification.isEmpty()) {
|
|
1260
|
+
mMountNotificationScheduled = true;
|
|
1261
|
+
|
|
1259
1262
|
// Notify mount when the effects are visible and prevent mount hooks to
|
|
1260
1263
|
// delay paint.
|
|
1261
1264
|
UiThreadUtil.getUiThreadHandler()
|
|
@@ -1265,17 +1268,19 @@ public class FabricUIManager
|
|
|
1265
1268
|
public void run() {
|
|
1266
1269
|
mMountNotificationScheduled = false;
|
|
1267
1270
|
|
|
1271
|
+
// Create a copy in case mount hooks trigger more mutations
|
|
1272
|
+
final List<Integer> surfaceIdsToReportMount =
|
|
1273
|
+
mSurfaceIdsWithPendingMountNotification;
|
|
1274
|
+
mSurfaceIdsWithPendingMountNotification = new ArrayList<>();
|
|
1275
|
+
|
|
1268
1276
|
final @Nullable FabricUIManagerBinding binding = mBinding;
|
|
1269
1277
|
if (binding == null || mDestroyed) {
|
|
1270
|
-
mMountedSurfaceIds.clear();
|
|
1271
1278
|
return;
|
|
1272
1279
|
}
|
|
1273
1280
|
|
|
1274
|
-
for (int surfaceId :
|
|
1281
|
+
for (int surfaceId : surfaceIdsToReportMount) {
|
|
1275
1282
|
binding.reportMount(surfaceId);
|
|
1276
1283
|
}
|
|
1277
|
-
|
|
1278
|
-
mMountedSurfaceIds.clear();
|
|
1279
1284
|
}
|
|
1280
1285
|
});
|
|
1281
1286
|
}
|
|
@@ -588,9 +588,6 @@ public class ReactViewGroup extends ViewGroup
|
|
|
588
588
|
UiThreadUtil.assertOnUiThread();
|
|
589
589
|
checkViewClippingTag(child, Boolean.TRUE);
|
|
590
590
|
if (!customDrawOrderDisabled()) {
|
|
591
|
-
if (indexOfChild(child) == -1) {
|
|
592
|
-
return;
|
|
593
|
-
}
|
|
594
591
|
getDrawingOrderHelper().handleRemoveView(child);
|
|
595
592
|
setChildrenDrawingOrderEnabled(getDrawingOrderHelper().shouldEnableCustomDrawingOrder());
|
|
596
593
|
} else {
|
|
@@ -57,7 +57,7 @@ static jsi::Value convertNSNumberToJSINumber(jsi::Runtime &runtime, NSNumber *va
|
|
|
57
57
|
|
|
58
58
|
static jsi::String convertNSStringToJSIString(jsi::Runtime &runtime, NSString *value)
|
|
59
59
|
{
|
|
60
|
-
return jsi::String::createFromUtf8(runtime, [value UTF8String]
|
|
60
|
+
return jsi::String::createFromUtf8(runtime, [value UTF8String] ? [value UTF8String] : "");
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
static jsi::Object convertNSDictionaryToJSIObject(jsi::Runtime &runtime, NSDictionary *value)
|
|
@@ -203,7 +203,11 @@ static jsi::Value createJSRuntimeError(jsi::Runtime &runtime, const std::string
|
|
|
203
203
|
/**
|
|
204
204
|
* Creates JSError with current JS runtime and NSException stack trace.
|
|
205
205
|
*/
|
|
206
|
-
static jsi::JSError convertNSExceptionToJSError(
|
|
206
|
+
static jsi::JSError convertNSExceptionToJSError(
|
|
207
|
+
jsi::Runtime &runtime,
|
|
208
|
+
NSException *exception,
|
|
209
|
+
const std::string &moduleName,
|
|
210
|
+
const std::string &methodName)
|
|
207
211
|
{
|
|
208
212
|
std::string reason = [exception.reason UTF8String];
|
|
209
213
|
|
|
@@ -214,7 +218,8 @@ static jsi::JSError convertNSExceptionToJSError(jsi::Runtime &runtime, NSExcepti
|
|
|
214
218
|
cause.setProperty(
|
|
215
219
|
runtime, "stackReturnAddresses", convertNSArrayToJSIArray(runtime, exception.callStackReturnAddresses));
|
|
216
220
|
|
|
217
|
-
|
|
221
|
+
std::string message = moduleName + "." + methodName + " raised an exception: " + reason;
|
|
222
|
+
jsi::Value error = createJSRuntimeError(runtime, message);
|
|
218
223
|
error.asObject(runtime).setProperty(runtime, "cause", std::move(cause));
|
|
219
224
|
return {runtime, std::move(error)};
|
|
220
225
|
}
|
|
@@ -346,28 +351,34 @@ id ObjCTurboModule::performMethodInvocation(
|
|
|
346
351
|
}
|
|
347
352
|
|
|
348
353
|
if (isSync) {
|
|
349
|
-
TurboModulePerfLogger::syncMethodCallExecutionStart(moduleName,
|
|
354
|
+
TurboModulePerfLogger::syncMethodCallExecutionStart(moduleName, methodName);
|
|
350
355
|
} else {
|
|
351
|
-
TurboModulePerfLogger::asyncMethodCallExecutionStart(moduleName,
|
|
356
|
+
TurboModulePerfLogger::asyncMethodCallExecutionStart(moduleName, methodName, asyncCallCounter);
|
|
352
357
|
}
|
|
353
358
|
|
|
354
359
|
@try {
|
|
355
360
|
[inv invokeWithTarget:strongModule];
|
|
356
361
|
} @catch (NSException *exception) {
|
|
357
|
-
|
|
362
|
+
if (isSync) {
|
|
363
|
+
// We can only convert NSException to JSError in sync method calls.
|
|
364
|
+
// See https://github.com/reactwg/react-native-new-architecture/discussions/276#discussioncomment-12567155
|
|
365
|
+
throw convertNSExceptionToJSError(runtime, exception, std::string{moduleName}, methodNameStr);
|
|
366
|
+
} else {
|
|
367
|
+
@throw exception;
|
|
368
|
+
}
|
|
358
369
|
} @finally {
|
|
359
370
|
[retainedObjectsForInvocation removeAllObjects];
|
|
360
371
|
}
|
|
361
372
|
|
|
362
373
|
if (!isSync) {
|
|
363
|
-
TurboModulePerfLogger::asyncMethodCallExecutionEnd(moduleName,
|
|
374
|
+
TurboModulePerfLogger::asyncMethodCallExecutionEnd(moduleName, methodName, asyncCallCounter);
|
|
364
375
|
return;
|
|
365
376
|
}
|
|
366
377
|
|
|
367
378
|
void *rawResult;
|
|
368
379
|
[inv getReturnValue:&rawResult];
|
|
369
380
|
result = (__bridge id)rawResult;
|
|
370
|
-
TurboModulePerfLogger::syncMethodCallExecutionEnd(moduleName,
|
|
381
|
+
TurboModulePerfLogger::syncMethodCallExecutionEnd(moduleName, methodName);
|
|
371
382
|
};
|
|
372
383
|
|
|
373
384
|
if (isSync) {
|
|
@@ -409,23 +420,23 @@ void ObjCTurboModule::performVoidMethodInvocation(
|
|
|
409
420
|
}
|
|
410
421
|
|
|
411
422
|
if (shouldVoidMethodsExecuteSync_) {
|
|
412
|
-
TurboModulePerfLogger::syncMethodCallExecutionStart(moduleName,
|
|
423
|
+
TurboModulePerfLogger::syncMethodCallExecutionStart(moduleName, methodName);
|
|
413
424
|
} else {
|
|
414
|
-
TurboModulePerfLogger::asyncMethodCallExecutionStart(moduleName,
|
|
425
|
+
TurboModulePerfLogger::asyncMethodCallExecutionStart(moduleName, methodName, asyncCallCounter);
|
|
415
426
|
}
|
|
416
427
|
|
|
417
428
|
@try {
|
|
418
429
|
[inv invokeWithTarget:strongModule];
|
|
419
430
|
} @catch (NSException *exception) {
|
|
420
|
-
throw convertNSExceptionToJSError(runtime, exception);
|
|
431
|
+
throw convertNSExceptionToJSError(runtime, exception, std::string{moduleName}, methodNameStr);
|
|
421
432
|
} @finally {
|
|
422
433
|
[retainedObjectsForInvocation removeAllObjects];
|
|
423
434
|
}
|
|
424
435
|
|
|
425
436
|
if (shouldVoidMethodsExecuteSync_) {
|
|
426
|
-
TurboModulePerfLogger::syncMethodCallExecutionEnd(moduleName,
|
|
437
|
+
TurboModulePerfLogger::syncMethodCallExecutionEnd(moduleName, methodName);
|
|
427
438
|
} else {
|
|
428
|
-
TurboModulePerfLogger::asyncMethodCallExecutionEnd(moduleName,
|
|
439
|
+
TurboModulePerfLogger::asyncMethodCallExecutionEnd(moduleName, methodName, asyncCallCounter);
|
|
429
440
|
}
|
|
430
441
|
|
|
431
442
|
return;
|
|
@@ -524,7 +524,11 @@ void RCTInstanceSetRuntimeDiagnosticFlags(NSString *flags)
|
|
|
524
524
|
name:errorData[@"name"]
|
|
525
525
|
componentStack:errorData[@"componentStack"]
|
|
526
526
|
exceptionId:error.id
|
|
527
|
-
|
|
527
|
+
#if TARGET_OS_OSX // [macOS Use boolValue for isFatal to ensure type safety
|
|
528
|
+
isFatal:[errorData[@"isFatal"] boolValue] // Explicitly convert to BOOL to avoid compiler errors on macOS
|
|
529
|
+
#else
|
|
530
|
+
isFatal:errorData[@"isFatal"]
|
|
531
|
+
#endif // macOS]
|
|
528
532
|
extraData:errorData[@"extraData"]]) {
|
|
529
533
|
JS::NativeExceptionsManager::ExceptionData jsErrorData{errorData};
|
|
530
534
|
id<NativeExceptionsManagerSpec> exceptionsManager = [_turboModuleManager moduleForName:"ExceptionsManager"];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-macos",
|
|
3
|
-
"version": "0.78.
|
|
3
|
+
"version": "0.78.3",
|
|
4
4
|
"description": "React Native for macOS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -110,14 +110,13 @@
|
|
|
110
110
|
},
|
|
111
111
|
"dependencies": {
|
|
112
112
|
"@jest/create-cache-key-function": "^29.6.3",
|
|
113
|
-
"@react-native-mac/virtualized-lists": "0.78.
|
|
114
|
-
"@react-native/assets-registry": "0.78.
|
|
115
|
-
"@react-native/codegen": "0.78.
|
|
116
|
-
"@react-native/community-cli-plugin": "0.78.
|
|
117
|
-
"@react-native/gradle-plugin": "0.78.
|
|
118
|
-
"@react-native/js-polyfills": "0.78.
|
|
119
|
-
"@react-native/normalize-colors": "0.78.
|
|
120
|
-
"@react-native/virtualized-lists": "0.78.1",
|
|
113
|
+
"@react-native-mac/virtualized-lists": "0.78.2",
|
|
114
|
+
"@react-native/assets-registry": "0.78.2",
|
|
115
|
+
"@react-native/codegen": "0.78.2",
|
|
116
|
+
"@react-native/community-cli-plugin": "0.78.2",
|
|
117
|
+
"@react-native/gradle-plugin": "0.78.2",
|
|
118
|
+
"@react-native/js-polyfills": "0.78.2",
|
|
119
|
+
"@react-native/normalize-colors": "0.78.2",
|
|
121
120
|
"abort-controller": "^3.0.0",
|
|
122
121
|
"anser": "^1.4.9",
|
|
123
122
|
"ansi-regex": "^5.0.0",
|
|
@@ -132,8 +131,8 @@
|
|
|
132
131
|
"invariant": "^2.2.4",
|
|
133
132
|
"jest-environment-node": "^29.6.3",
|
|
134
133
|
"memoize-one": "^5.0.0",
|
|
135
|
-
"metro-runtime": "^0.81.
|
|
136
|
-
"metro-source-map": "^0.81.
|
|
134
|
+
"metro-runtime": "^0.81.3",
|
|
135
|
+
"metro-source-map": "^0.81.3",
|
|
137
136
|
"nullthrows": "^1.1.1",
|
|
138
137
|
"pretty-format": "^29.7.0",
|
|
139
138
|
"promise": "^8.3.0",
|