react-native-macos 0.0.0-dd8ec0d8a → 0.0.0-ddcc38f1b
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/AddressSanitizerCrash/RCTAddressSanitizerCrash.js +25 -0
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +22 -12
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/StyleSheet/PlatformColorValueTypes.macos.js +16 -1
- package/Libraries/StyleSheet/PlatformColorValueTypesMacOS.js +2 -0
- package/Libraries/StyleSheet/PlatformColorValueTypesMacOS.macos.js +8 -1
- package/Libraries/Text/RawText/RCTRawTextShadowView.m +2 -0
- package/Libraries/Text/Text/RCTTextView.m +7 -9
- package/Libraries/Text/TextInput/Multiline/RCTUITextView.m +10 -8
- package/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h +2 -0
- package/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m +15 -3
- package/Libraries/Text/TextInput/RCTBaseTextInputView.m +10 -1
- package/Libraries/WebSocket/RCTSRWebSocket.m +23 -0
- package/README.md +18 -42
- package/React/Base/RCTBridgeModule.h +1 -1
- package/React/Base/RCTConvert.m +23 -6
- package/React/Base/RCTImageSource.m +2 -0
- package/React/Base/RCTJSStackFrame.m +2 -0
- package/React/Base/RCTJavaScriptLoader.mm +2 -0
- package/React/Base/RCTKeyCommands.m +2 -0
- package/React/Base/RCTModuleData.mm +2 -0
- package/React/Base/RCTModuleMethod.mm +2 -0
- package/React/Base/RCTTouchEvent.m +2 -0
- package/React/Base/RCTVersion.m +1 -1
- package/React/Base/macOS/RCTPlatformDisplayLink.m +4 -1
- package/React/CoreModules/RCTActionSheetManager.mm +4 -0
- package/React/CoreModules/RCTAddressSanitizerCrashManager.h +12 -0
- package/React/CoreModules/RCTAddressSanitizerCrashManager.mm +18 -0
- package/React/CoreModules/RCTAppearance.mm +5 -1
- package/React/CoreModules/RCTDevLoadingView.mm +14 -9
- package/React/CxxModule/RCTCxxMethod.mm +2 -0
- package/React/DevSupport/RCTInspectorDevServerHelper.mm +12 -0
- package/React/Modules/RCTLayoutAnimation.m +2 -0
- package/React/Modules/RCTLayoutAnimationGroup.m +2 -0
- package/React/Views/RCTShadowView.m +3 -1
- package/React/Views/RCTView.h +5 -2
- package/React/Views/RCTView.m +22 -10
- package/React/Views/RCTViewManager.m +9 -8
- package/React/Views/SafeAreaView/RCTSafeAreaView.m +2 -0
- package/React/Views/ScrollView/MacOS/RCTScrollContentLocalData.h +2 -2
- package/React/Views/ScrollView/MacOS/RCTScrollContentLocalData.m +4 -4
- package/React/Views/ScrollView/RCTScrollContentView.m +10 -24
- package/React/Views/ScrollView/RCTScrollView.m +1 -5
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +27 -15
- package/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java +12 -0
- package/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java +6 -0
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/ReactCommon/hermes/inspector/tools/msggen/package.json +1 -1
- package/ReactCommon/hermes/inspector/tools/msggen/yarn.lock +1225 -1481
- package/package.json +20 -12
- package/template/ios/HelloWorld.xcodeproj/project.pbxproj +2 -0
- package/template/package.json +2 -2
- package/React/Base/macOS/RCTDynamicColor.h +0 -28
- package/React/Base/macOS/RCTDynamicColor.m +0 -217
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
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
|
+
* @format
|
|
8
|
+
* @flow
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
import type {HostComponent} from '../Renderer/shims/ReactNativeTypes';
|
|
13
|
+
import type {ViewProps} from '../Components/View/ViewPropTypes';
|
|
14
|
+
|
|
15
|
+
const {requireNativeComponent} = require('react-native');
|
|
16
|
+
|
|
17
|
+
type NativeProps = $ReadOnly<{|
|
|
18
|
+
...ViewProps,
|
|
19
|
+
|}>;
|
|
20
|
+
|
|
21
|
+
const RCTAddressSanitizerCrash: HostComponent<NativeProps> = requireNativeComponent<NativeProps>(
|
|
22
|
+
'RCTAddressSanitizerCrash',
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
module.exports = RCTAddressSanitizerCrash;
|
|
@@ -77,9 +77,8 @@ const AccessibilityInfo = {
|
|
|
77
77
|
* See https://reactnative.dev/docs/accessibilityinfo.html#isBoldTextEnabled
|
|
78
78
|
*/
|
|
79
79
|
isBoldTextEnabled(): Promise<boolean> {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
} else {
|
|
80
|
+
// [TODO(macOS GH#774) - rework logic to return Promise.resolve(false) on macOS
|
|
81
|
+
if (Platform.OS === 'ios') {
|
|
83
82
|
return new Promise((resolve, reject) => {
|
|
84
83
|
if (NativeAccessibilityManagerApple != null) {
|
|
85
84
|
NativeAccessibilityManagerApple.getCurrentBoldTextState(
|
|
@@ -90,7 +89,10 @@ const AccessibilityInfo = {
|
|
|
90
89
|
reject(null);
|
|
91
90
|
}
|
|
92
91
|
});
|
|
92
|
+
} else {
|
|
93
|
+
return Promise.resolve(false);
|
|
93
94
|
}
|
|
95
|
+
// ]TODO(macOS GH#774)
|
|
94
96
|
},
|
|
95
97
|
|
|
96
98
|
/**
|
|
@@ -102,9 +104,8 @@ const AccessibilityInfo = {
|
|
|
102
104
|
* See https://reactnative.dev/docs/accessibilityinfo.html#isGrayscaleEnabled
|
|
103
105
|
*/
|
|
104
106
|
isGrayscaleEnabled(): Promise<boolean> {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
} else {
|
|
107
|
+
// [TODO(macOS GH#774) - rework logic to return Promise.resolve(false) on macOS
|
|
108
|
+
if (Platform.OS === 'ios') {
|
|
108
109
|
return new Promise((resolve, reject) => {
|
|
109
110
|
if (NativeAccessibilityManagerApple != null) {
|
|
110
111
|
NativeAccessibilityManagerApple.getCurrentGrayscaleState(
|
|
@@ -115,12 +116,16 @@ const AccessibilityInfo = {
|
|
|
115
116
|
reject(null);
|
|
116
117
|
}
|
|
117
118
|
});
|
|
119
|
+
} else {
|
|
120
|
+
return Promise.resolve(false);
|
|
118
121
|
}
|
|
122
|
+
// ]TODO(macOS GH#774)
|
|
119
123
|
},
|
|
120
124
|
|
|
121
125
|
/**
|
|
122
126
|
* macOS only
|
|
123
127
|
*/
|
|
128
|
+
// [TODO(macOS GH#774)
|
|
124
129
|
isHighContrastEnabled: function(): Promise<boolean> {
|
|
125
130
|
if (Platform.OS === 'macos') {
|
|
126
131
|
return new Promise((resolve, reject) => {
|
|
@@ -137,6 +142,7 @@ const AccessibilityInfo = {
|
|
|
137
142
|
return Promise.resolve(false);
|
|
138
143
|
}
|
|
139
144
|
},
|
|
145
|
+
// ]TODO(macOS GH#774)
|
|
140
146
|
|
|
141
147
|
/**
|
|
142
148
|
* Query whether inverted colors are currently enabled.
|
|
@@ -147,9 +153,8 @@ const AccessibilityInfo = {
|
|
|
147
153
|
* See https://reactnative.dev/docs/accessibilityinfo.html#isInvertColorsEnabled
|
|
148
154
|
*/
|
|
149
155
|
isInvertColorsEnabled(): Promise<boolean> {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
} else {
|
|
156
|
+
// [TODO(macOS GH#774) - rework logic to return Promise.resolve(false) on macOS
|
|
157
|
+
if (Platform.OS === 'ios') {
|
|
153
158
|
return new Promise((resolve, reject) => {
|
|
154
159
|
if (NativeAccessibilityManagerApple != null) {
|
|
155
160
|
NativeAccessibilityManagerApple.getCurrentInvertColorsState(
|
|
@@ -160,7 +165,10 @@ const AccessibilityInfo = {
|
|
|
160
165
|
reject(null);
|
|
161
166
|
}
|
|
162
167
|
});
|
|
168
|
+
} else {
|
|
169
|
+
return Promise.resolve(false);
|
|
163
170
|
}
|
|
171
|
+
// ]TODO(macOS GH#774)
|
|
164
172
|
},
|
|
165
173
|
|
|
166
174
|
/**
|
|
@@ -201,9 +209,8 @@ const AccessibilityInfo = {
|
|
|
201
209
|
* See https://reactnative.dev/docs/accessibilityinfo.html#isReduceTransparencyEnabled
|
|
202
210
|
*/
|
|
203
211
|
isReduceTransparencyEnabled(): Promise<boolean> {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
} else {
|
|
212
|
+
// [TODO(macOS GH#774) - rework logic to return Promise.resolve(false) on macOS
|
|
213
|
+
if (Platform.OS === 'ios') {
|
|
207
214
|
return new Promise((resolve, reject) => {
|
|
208
215
|
if (NativeAccessibilityManagerApple != null) {
|
|
209
216
|
NativeAccessibilityManagerApple.getCurrentReduceTransparencyState(
|
|
@@ -214,7 +221,10 @@ const AccessibilityInfo = {
|
|
|
214
221
|
reject(null);
|
|
215
222
|
}
|
|
216
223
|
});
|
|
224
|
+
} else {
|
|
225
|
+
return Promise.resolve(false);
|
|
217
226
|
}
|
|
227
|
+
// ]TODO(macOS GH#774)
|
|
218
228
|
},
|
|
219
229
|
|
|
220
230
|
/**
|
|
@@ -18,6 +18,8 @@ export opaque type NativeColorValue = {
|
|
|
18
18
|
dynamic?: {
|
|
19
19
|
light: ?(ColorValue | ProcessedColorValue),
|
|
20
20
|
dark: ?(ColorValue | ProcessedColorValue),
|
|
21
|
+
highContrastLight?: ?(ColorValue | ProcessedColorValue),
|
|
22
|
+
highContrastDark?: ?(ColorValue | ProcessedColorValue),
|
|
21
23
|
},
|
|
22
24
|
colorWithSystemEffect?: {
|
|
23
25
|
baseColor: ?(ColorValue | ProcessedColorValue),
|
|
@@ -51,12 +53,21 @@ export const ColorWithSystemEffectMacOSPrivate = (
|
|
|
51
53
|
export type DynamicColorMacOSTuplePrivate = {
|
|
52
54
|
light: ColorValue,
|
|
53
55
|
dark: ColorValue,
|
|
56
|
+
highContrastLight?: ColorValue,
|
|
57
|
+
highContrastDark?: ColorValue,
|
|
54
58
|
};
|
|
55
59
|
|
|
56
60
|
export const DynamicColorMacOSPrivate = (
|
|
57
61
|
tuple: DynamicColorMacOSTuplePrivate,
|
|
58
62
|
): ColorValue => {
|
|
59
|
-
return {
|
|
63
|
+
return {
|
|
64
|
+
dynamic: {
|
|
65
|
+
light: tuple.light,
|
|
66
|
+
dark: tuple.dark,
|
|
67
|
+
highContrastLight: tuple.highContrastLight,
|
|
68
|
+
highContrastDark: tuple.highContrastDark,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
60
71
|
};
|
|
61
72
|
|
|
62
73
|
export const normalizeColorObject = (
|
|
@@ -74,6 +85,8 @@ export const normalizeColorObject = (
|
|
|
74
85
|
dynamic: {
|
|
75
86
|
light: normalizeColor(dynamic.light),
|
|
76
87
|
dark: normalizeColor(dynamic.dark),
|
|
88
|
+
highContrastLight: normalizeColor(dynamic.highContrastLight),
|
|
89
|
+
highContrastDark: normalizeColor(dynamic.highContrastDark),
|
|
77
90
|
},
|
|
78
91
|
};
|
|
79
92
|
return dynamicColor;
|
|
@@ -104,6 +117,8 @@ export const processColorObject = (
|
|
|
104
117
|
dynamic: {
|
|
105
118
|
light: processColor(dynamic.light),
|
|
106
119
|
dark: processColor(dynamic.dark),
|
|
120
|
+
highContrastLight: processColor(dynamic.highContrastLight),
|
|
121
|
+
highContrastDark: processColor(dynamic.highContrastDark),
|
|
107
122
|
},
|
|
108
123
|
};
|
|
109
124
|
return dynamicColor;
|
|
@@ -19,12 +19,19 @@ import {
|
|
|
19
19
|
export type DynamicColorMacOSTuple = {
|
|
20
20
|
light: ColorValue,
|
|
21
21
|
dark: ColorValue,
|
|
22
|
+
highContrastLight?: ColorValue,
|
|
23
|
+
highContrastDark?: ColorValue,
|
|
22
24
|
};
|
|
23
25
|
|
|
24
26
|
export const DynamicColorMacOS = (
|
|
25
27
|
tuple: DynamicColorMacOSTuple,
|
|
26
28
|
): ColorValue => {
|
|
27
|
-
return DynamicColorMacOSPrivate({
|
|
29
|
+
return DynamicColorMacOSPrivate({
|
|
30
|
+
light: tuple.light,
|
|
31
|
+
dark: tuple.dark,
|
|
32
|
+
highContrastLight: tuple.highContrastLight,
|
|
33
|
+
highContrastDark: tuple.highContrastDark,
|
|
34
|
+
});
|
|
28
35
|
};
|
|
29
36
|
|
|
30
37
|
export type SystemEffectMacOS =
|
|
@@ -24,10 +24,12 @@
|
|
|
24
24
|
[self.superview dirtyLayout];
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
#if DEBUG // TODO(macOS GH#774) description is a debug-only feature
|
|
27
28
|
- (NSString *)description
|
|
28
29
|
{
|
|
29
30
|
NSString *superDescription = super.description;
|
|
30
31
|
return [[superDescription substringToIndex:superDescription.length - 1] stringByAppendingFormat:@"; text: %@>", self.text];
|
|
31
32
|
}
|
|
33
|
+
#endif // TODO(macOS GH#774)
|
|
32
34
|
|
|
33
35
|
@end
|
|
@@ -55,6 +55,8 @@
|
|
|
55
55
|
self.accessibilityTraits |= UIAccessibilityTraitStaticText;
|
|
56
56
|
#else // [TODO(macOS GH#774)
|
|
57
57
|
self.accessibilityRole = NSAccessibilityStaticTextRole;
|
|
58
|
+
// Fix blurry text on non-retina displays.
|
|
59
|
+
self.canDrawSubviewsIntoLayer = YES;
|
|
58
60
|
#endif // ]TODO(macOS GH#774)
|
|
59
61
|
self.opaque = NO;
|
|
60
62
|
RCTUIViewSetContentModeRedraw(self); // TODO(macOS GH#774) and TODO(macOS ISS#3536887)
|
|
@@ -99,19 +101,15 @@
|
|
|
99
101
|
}
|
|
100
102
|
#endif // ]TODO(macOS GH#774)
|
|
101
103
|
|
|
104
|
+
#if DEBUG // TODO(macOS GH#774) description is a debug-only feature
|
|
102
105
|
- (NSString *)description
|
|
103
106
|
{
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
// [TODO(macOS GH#774): super.description isn't guaranteed to have a semicolon in it on macOS
|
|
108
|
-
if (semicolonRange.location == NSNotFound) {
|
|
109
|
-
return [superDescription stringByAppendingString:replacement];
|
|
110
|
-
} else {
|
|
111
|
-
return [superDescription stringByReplacingCharactersInRange:semicolonRange withString:replacement];
|
|
112
|
-
}
|
|
107
|
+
// [TODO(macOS GH#774): we shouldn't make assumptions on what super's description is. Just append additional content.
|
|
108
|
+
NSString *stringToAppend = [NSString stringWithFormat:@" reactTag: %@; text: %@", self.reactTag, _textStorage.string];
|
|
109
|
+
return [[super description] stringByAppendingString:stringToAppend];
|
|
113
110
|
// TODO(macOS GH#774)]
|
|
114
111
|
}
|
|
112
|
+
#endif // TODO(macOS GH#774)
|
|
115
113
|
|
|
116
114
|
- (void)setSelectable:(BOOL)selectable
|
|
117
115
|
{
|
|
@@ -49,6 +49,8 @@ static RCTUIColor *defaultPlaceholderColor() // TODO(OSS Candidate ISS#2710739)
|
|
|
49
49
|
NSTextCheckingTypes checkingTypes = 0;
|
|
50
50
|
self.enabledTextCheckingTypes = checkingTypes;
|
|
51
51
|
self.insertionPointColor = [NSColor selectedControlColor];
|
|
52
|
+
// Fix blurry text on non-retina displays.
|
|
53
|
+
self.canDrawSubviewsIntoLayer = YES;
|
|
52
54
|
#endif // ]TODO(macOS GH#774)
|
|
53
55
|
|
|
54
56
|
_textInputDelegateAdapter = [[RCTBackedTextViewDelegateAdapter alloc] initWithTextView:self];
|
|
@@ -159,6 +161,12 @@ static RCTUIColor *defaultPlaceholderColor() // TODO(OSS Candidate ISS#2710739)
|
|
|
159
161
|
self.string = text;
|
|
160
162
|
}
|
|
161
163
|
|
|
164
|
+
- (void)setTypingAttributes:(__unused NSDictionary *)typingAttributes
|
|
165
|
+
{
|
|
166
|
+
// Prevent NSTextView from changing its own typing attributes out from under us.
|
|
167
|
+
[super setTypingAttributes:_defaultTextAttributes];
|
|
168
|
+
}
|
|
169
|
+
|
|
162
170
|
- (NSAttributedString*)attributedText
|
|
163
171
|
{
|
|
164
172
|
return self.textStorage;
|
|
@@ -307,13 +315,7 @@ static RCTUIColor *defaultPlaceholderColor() // TODO(OSS Candidate ISS#2710739)
|
|
|
307
315
|
if (self.placeholder == nil) {
|
|
308
316
|
return nil;
|
|
309
317
|
}
|
|
310
|
-
|
|
311
|
-
if (placeholderAttributes == nil) {
|
|
312
|
-
placeholderAttributes = [NSMutableDictionary dictionary];
|
|
313
|
-
}
|
|
314
|
-
placeholderAttributes[NSForegroundColorAttributeName] = self.placeholderColor ?: defaultPlaceholderColor();
|
|
315
|
-
placeholderAttributes[NSFontAttributeName] = self.font ?: defaultPlaceholderFont();
|
|
316
|
-
return [[NSAttributedString alloc] initWithString:self.placeholder attributes:placeholderAttributes];
|
|
318
|
+
return [[NSAttributedString alloc] initWithString:self.placeholder attributes:[self _placeholderTextAttributes]];
|
|
317
319
|
}
|
|
318
320
|
|
|
319
321
|
- (void)drawRect:(NSRect)dirtyRect
|
|
@@ -388,7 +390,7 @@ static RCTUIColor *defaultPlaceholderColor() // TODO(OSS Candidate ISS#2710739)
|
|
|
388
390
|
placeholderSize = CGSizeMake(RCTCeilPixelValue(placeholderSize.width), RCTCeilPixelValue(placeholderSize.height));
|
|
389
391
|
#else // [TODO(macOS GH#774)
|
|
390
392
|
CGFloat scale = self.window.backingScaleFactor;
|
|
391
|
-
CGSize placeholderSize = [placeholder sizeWithAttributes
|
|
393
|
+
CGSize placeholderSize = [placeholder sizeWithAttributes:[self _placeholderTextAttributes]];
|
|
392
394
|
placeholderSize = CGSizeMake(RCTCeilPixelValue(placeholderSize.width, scale), RCTCeilPixelValue(placeholderSize.height, scale));
|
|
393
395
|
#endif // ]TODO(macOS GH#774)
|
|
394
396
|
placeholderSize.width += textContainerInset.left + textContainerInset.right;
|
|
@@ -36,6 +36,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
36
36
|
- (BOOL)textInputShouldHandleDeleteBackward:(id<RCTBackedTextInputViewProtocol>)sender; // Return `YES` to have the deleteBackward event handled normally. Return `NO` to disallow it and handle it yourself. TODO(OSS Candidate ISS#2710739)
|
|
37
37
|
#if TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
38
38
|
- (BOOL)textInputShouldHandleDeleteForward:(id<RCTBackedTextInputViewProtocol>)sender; // Return `YES` to have the deleteForward event handled normally. Return `NO` to disallow it and handle it yourself.
|
|
39
|
+
|
|
40
|
+
- (void)textInputDidCancel; // Handle `Escape` key press.
|
|
39
41
|
#endif // ]TODO(macOS GH#774)
|
|
40
42
|
|
|
41
43
|
@optional
|
|
@@ -187,17 +187,17 @@ static void *TextFieldSelectionObservingContext = &TextFieldSelectionObservingCo
|
|
|
187
187
|
|
|
188
188
|
- (BOOL)control:(NSControl *)control textView:(NSTextView *)fieldEditor doCommandBySelector:(SEL)commandSelector
|
|
189
189
|
{
|
|
190
|
+
id<RCTBackedTextInputDelegate> textInputDelegate = [_backedTextInputView textInputDelegate];
|
|
190
191
|
BOOL commandHandled = NO;
|
|
191
192
|
// enter/return
|
|
192
193
|
if (commandSelector == @selector(insertNewline:) || commandSelector == @selector(insertNewlineIgnoringFieldEditor:)) {
|
|
193
194
|
[self textFieldDidEndEditingOnExit];
|
|
194
|
-
if ([
|
|
195
|
+
if ([textInputDelegate textInputShouldReturn]) {
|
|
195
196
|
[[_backedTextInputView window] makeFirstResponder:nil];
|
|
196
197
|
}
|
|
197
198
|
commandHandled = YES;
|
|
198
199
|
//backspace
|
|
199
200
|
} else if (commandSelector == @selector(deleteBackward:)) {
|
|
200
|
-
id<RCTBackedTextInputDelegate> textInputDelegate = [_backedTextInputView textInputDelegate];
|
|
201
201
|
if (textInputDelegate != nil && ![textInputDelegate textInputShouldHandleDeleteBackward:_backedTextInputView]) {
|
|
202
202
|
commandHandled = YES;
|
|
203
203
|
} else {
|
|
@@ -214,7 +214,13 @@ static void *TextFieldSelectionObservingContext = &TextFieldSelectionObservingCo
|
|
|
214
214
|
//paste
|
|
215
215
|
} else if (commandSelector == @selector(paste:)) {
|
|
216
216
|
_backedTextInputView.textWasPasted = YES;
|
|
217
|
-
|
|
217
|
+
//escape
|
|
218
|
+
} else if (commandSelector == @selector(cancelOperation:)) {
|
|
219
|
+
[textInputDelegate textInputDidCancel];
|
|
220
|
+
[[_backedTextInputView window] makeFirstResponder:nil];
|
|
221
|
+
commandHandled = YES;
|
|
222
|
+
}
|
|
223
|
+
|
|
218
224
|
return commandHandled;
|
|
219
225
|
}
|
|
220
226
|
|
|
@@ -411,6 +417,12 @@ static void *TextFieldSelectionObservingContext = &TextFieldSelectionObservingCo
|
|
|
411
417
|
//deleteForward
|
|
412
418
|
} else if (commandSelector == @selector(deleteForward:)) {
|
|
413
419
|
commandHandled = textInputDelegate != nil && ![textInputDelegate textInputShouldHandleDeleteForward:_backedTextInputView];
|
|
420
|
+
//escape
|
|
421
|
+
} else if (commandSelector == @selector(cancelOperation:)) {
|
|
422
|
+
[textInputDelegate textInputDidCancel];
|
|
423
|
+
[_backedTextInputView.window makeFirstResponder:nil];
|
|
424
|
+
commandHandled = YES;
|
|
425
|
+
|
|
414
426
|
}
|
|
415
427
|
|
|
416
428
|
return commandHandled;
|
|
@@ -493,7 +493,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
|
|
|
493
493
|
|
|
494
494
|
if (range.location + range.length > backedTextInputView.attributedText.string.length) {
|
|
495
495
|
_predictedText = backedTextInputView.attributedText.string;
|
|
496
|
-
} else {
|
|
496
|
+
} else if (text != nil) { // TODO(macOS GH#774): -[NSString stringByReplacingCharactersInRange:withString:] doesn't like when the replacement string is nil
|
|
497
497
|
_predictedText = [backedTextInputView.attributedText.string stringByReplacingCharactersInRange:range withString:text];
|
|
498
498
|
}
|
|
499
499
|
|
|
@@ -569,6 +569,15 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
|
|
|
569
569
|
- (BOOL)textInputShouldHandleDeleteForward:(__unused id)sender {
|
|
570
570
|
return YES;
|
|
571
571
|
}
|
|
572
|
+
|
|
573
|
+
- (void)textInputDidCancel {
|
|
574
|
+
[_eventDispatcher sendTextEventWithType:RCTTextEventTypeKeyPress
|
|
575
|
+
reactTag:self.reactTag
|
|
576
|
+
text:nil
|
|
577
|
+
key:@"Escape"
|
|
578
|
+
eventCount:_nativeEventCount];
|
|
579
|
+
[self textInputDidEndEditing];
|
|
580
|
+
}
|
|
572
581
|
#endif // ]TODO(macOS GH#774)
|
|
573
582
|
|
|
574
583
|
- (void)updateLocalData
|
|
@@ -540,10 +540,33 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
|
|
540
540
|
// ]TODO(macOS ISS#2323203)
|
|
541
541
|
}
|
|
542
542
|
|
|
543
|
+
// [TODO(macOS GH#774)
|
|
544
|
+
// We've seen a rare ASan crash where _inputStream seems to be invalid. This is just a safety check.
|
|
545
|
+
#if DEBUG
|
|
546
|
+
[self _validateStream:_outputStream name:@"_outputStream"];
|
|
547
|
+
[self _validateStream:_inputStream name:@"_inputStream"];
|
|
548
|
+
#endif
|
|
549
|
+
// ]TODO(macOS GH#774)
|
|
550
|
+
|
|
543
551
|
[_outputStream open];
|
|
544
552
|
[_inputStream open];
|
|
545
553
|
}
|
|
546
554
|
|
|
555
|
+
// [TODO(macOS GH#774)
|
|
556
|
+
#if DEBUG
|
|
557
|
+
- (void)_validateStream:(NSStream *)stream name:(NSString *)name {
|
|
558
|
+
NSStreamStatus status = stream.streamStatus;
|
|
559
|
+
if (status != NSStreamStatusNotOpen) {
|
|
560
|
+
RCTLogWarn(@"%@ was already opened, why are we opening it again? status=%@", name, @(status));
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
if (stream.delegate == nil) {
|
|
564
|
+
RCTLogError(@"%@'s delegate is nil, did we clean it up too early?", name);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
#endif
|
|
568
|
+
// ]TODO(macOS GH#774)
|
|
569
|
+
|
|
547
570
|
- (void)scheduleInRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode
|
|
548
571
|
{
|
|
549
572
|
[_outputStream scheduleInRunLoop:aRunLoop forMode:mode];
|
package/README.md
CHANGED
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
</a>
|
|
17
17
|
</p>
|
|
18
18
|
|
|
19
|
-
> See the official [React Native website](https://reactnative.dev/) for an introduction to React Native.
|
|
19
|
+
> See the official [React Native website](https://reactnative.dev/) for an introduction to React Native.
|
|
20
20
|
|
|
21
21
|
[React Native](https://reactnative.dev) is a framework developed by Facebook that enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and [React](https://reactjs.org/). The focus of React Native is on developer efficiency across all the platforms you care about - learn once, write anywhere.
|
|
22
22
|
|
|
23
|
-
This repository is a working fork of **facebook/react-native** that adds support for the official React Native for macOS implementation from Microsoft.
|
|
23
|
+
This repository is a working fork of **facebook/react-native** that adds support for the official React Native for macOS implementation from Microsoft.
|
|
24
24
|
|
|
25
25
|
[hello-world]: https://snack.expo.io/@hramos/hello,-world!
|
|
26
26
|
[new-app]: https://reactnative.dev/docs/getting-started
|
|
@@ -28,38 +28,6 @@ This repository is a working fork of **facebook/react-native** that adds support
|
|
|
28
28
|
|
|
29
29
|
You can read more about the macOS implementation in our website - [React Native for Windows + macOS](https://microsoft.github.io/react-native-windows/)
|
|
30
30
|
|
|
31
|
-
The full documentation for React Native can be found on our [website][docs].
|
|
32
|
-
|
|
33
|
-
The React Native documentation discusses components, APIs, and topics that are specific to React Native. For further documentation on the React API that is shared between React Native and React DOM, refer to the [React documentation][r-docs].
|
|
34
|
-
|
|
35
|
-
The source for the React Native documentation and website is hosted on a separate repo, [**@facebook/react-native-website**][repo-website].
|
|
36
|
-
|
|
37
|
-
[docs]: https://reactnative.dev/docs/getting-started
|
|
38
|
-
[r-docs]: https://reactjs.org/docs/getting-started.html
|
|
39
|
-
[repo-website]: https://github.com/facebook/react-native-website
|
|
40
|
-
|
|
41
|
-
## 🚀 Upgrading
|
|
42
|
-
|
|
43
|
-
Upgrading to new versions of React Native may give you access to more APIs, views, developer tools, and other goodies. See the [Upgrading Guide][u] for instructions.
|
|
44
|
-
|
|
45
|
-
React Native releases are discussed in the React Native Community, [**@react-native-community/react-native-releases**][repo-releases].
|
|
46
|
-
|
|
47
|
-
[u]: https://reactnative.dev/docs/upgrading
|
|
48
|
-
[repo-releases]: https://github.com/react-native-community/react-native-releases
|
|
49
|
-
|
|
50
|
-
## 👏 How to Contribute
|
|
51
|
-
|
|
52
|
-
You can read more about the macOS implementation on our website - [React Native for Windows + macOS](https://microsoft.github.io/react-native-windows/)
|
|
53
|
-
|
|
54
|
-
## Contents
|
|
55
|
-
|
|
56
|
-
- [Requirements](#requirements)
|
|
57
|
-
- [Getting Started](#getting-started)
|
|
58
|
-
- [Contributing](#contributing)
|
|
59
|
-
- [Documentation](#documentation)
|
|
60
|
-
- [License](#license)
|
|
61
|
-
- [Code of Conduct](#code-of-conduct)
|
|
62
|
-
|
|
63
31
|
## Requirements
|
|
64
32
|
|
|
65
33
|
You can run React Native for macOS apps on Mac devices with versions Catalina (10.15) or newer.
|
|
@@ -67,30 +35,37 @@ You can run React Native for macOS apps on Mac devices with versions Catalina (1
|
|
|
67
35
|
For a full and detailed list of the system requirements and how to set up your development platform, see our [System Requirements](https://microsoft.github.io/react-native-windows/docs/rnm-dependencies) documentation on our website.
|
|
68
36
|
|
|
69
37
|
## Getting Started
|
|
38
|
+
|
|
70
39
|
See the [Getting Started Guide](https://microsoft.github.io/react-native-windows/docs/rnm-getting-started) on our React Native for Windows + macOS website to build your first React Native for macOS app.
|
|
71
40
|
|
|
72
41
|
### Logging Issues
|
|
42
|
+
|
|
73
43
|
Search the [existing issues](https://github.com/microsoft/react-native-macos/issues) and try to make sure your problem doesn’t already exist before opening a new issue. If your issue doesn't exist yet, try to make sure you provide as much information as possible to us so we can help you sooner. It’s helpful if you include information like:
|
|
74
44
|
|
|
75
45
|
- The version of macOS, React Native, React Native macOS extension where you ran into the issue.
|
|
76
46
|
- A stack trace and reduced repro case when possible.
|
|
77
47
|
- Ensure the [appropriate template](https://github.com/microsoft/react-native-macos/issues/new/choose) is used when filing your issue(s).
|
|
78
48
|
|
|
79
|
-
##
|
|
49
|
+
## Contributing
|
|
50
|
+
|
|
80
51
|
See [Contributing guidelines](https://github.com/microsoft/react-native-macos/blob/master/CONTRIBUTING.md) for how to set up your fork of the repo and start a PR to contribute to React Native for macOS.
|
|
81
52
|
|
|
82
53
|
[Good First Issue](https://github.com/microsoft/react-native-macos/labels/good%20first%20issue) and [help wanted](https://github.com/microsoft/react-native-macos/labels/help%20wanted) are great starting points for PRs.
|
|
83
54
|
|
|
84
55
|
## Documentation
|
|
85
|
-
|
|
56
|
+
|
|
57
|
+
The full documentation for React Native can be found on the [documentation website][docs]. The React Native documentation discusses components, APIs, and topics that are specific to React Native. For further documentation on the React API that is shared between React Native and React DOM, refer to the [React documentation][r-docs].
|
|
58
|
+
|
|
59
|
+
The source for the React Native documentation and website is hosted on a separate repo, [**@facebook/react-native-website**][repo-website].
|
|
86
60
|
|
|
87
61
|
[React Native for Windows + macOS](https://microsoft.github.io/react-native-windows/) has its own separate documentation site where Windows and macOS
|
|
88
|
-
specific information, like API docs and blog updates live. We are
|
|
62
|
+
specific information, like API docs and blog updates live. We are still working on the documentation for macOS, contributions are welcome!
|
|
63
|
+
|
|
64
|
+
If you're looking for sample code, just browse the [RNTester folder](https://github.com/microsoft/react-native-macos/tree/master/packages/rn-tester) for examples
|
|
89
65
|
|
|
90
|
-
###
|
|
66
|
+
### Git flow and syncing with upstream
|
|
91
67
|
|
|
92
|
-
|
|
93
|
-
- If you're looking for sample code, just browse the [RNTester folder](https://github.com/microsoft/react-native-macos/tree/master/packages/rn-tester) for examples
|
|
68
|
+
For more details on how this fork handles keeping up with upstream, and how the general git flow works, check out [this dedicated document](./docs/GitFlow.md).
|
|
94
69
|
|
|
95
70
|
## License
|
|
96
71
|
|
|
@@ -100,5 +75,6 @@ The React Native for macOS extension, including modifications to the original Fa
|
|
|
100
75
|
|
|
101
76
|
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
|
102
77
|
|
|
103
|
-
[
|
|
104
|
-
[
|
|
78
|
+
[docs]: https://reactnative.dev/docs/getting-started
|
|
79
|
+
[r-docs]: https://reactjs.org/docs/getting-started.html
|
|
80
|
+
[repo-website]: https://github.com/facebook/react-native-website
|
|
@@ -441,7 +441,7 @@ typedef NSURL * (^RCTBridgelessBundleURLGetter)(void);
|
|
|
441
441
|
andSetter:(RCTBridgelessBundleURLSetter)setter
|
|
442
442
|
andDefaultGetter:(RCTBridgelessBundleURLGetter)defaultGetter;
|
|
443
443
|
- (void)resetBundleURL;
|
|
444
|
-
@property NSURL *bundleURL;
|
|
444
|
+
@property (strong) NSURL *bundleURL; // TODO(macOS GH#774)
|
|
445
445
|
@end
|
|
446
446
|
|
|
447
447
|
typedef RCTPlatformView * (^RCTBridgelessComponentViewProvider)(NSNumber *); // TODO(macOS GH#774)
|
package/React/Base/RCTConvert.m
CHANGED
|
@@ -16,10 +16,6 @@
|
|
|
16
16
|
#import "RCTParserUtils.h"
|
|
17
17
|
#import "RCTUtils.h"
|
|
18
18
|
|
|
19
|
-
#if TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
20
|
-
#import "RCTDynamicColor.h"
|
|
21
|
-
#endif // ]TODO(macOS GH#774)
|
|
22
|
-
|
|
23
19
|
@implementation RCTConvert
|
|
24
20
|
|
|
25
21
|
RCT_CONVERTER(id, id, self)
|
|
@@ -1043,7 +1039,28 @@ static NSColor *RCTColorWithSystemEffect(NSColor* color, NSString *systemEffectS
|
|
|
1043
1039
|
RCTUIColor *highContrastDarkColor = [RCTConvert UIColor:highContrastDark]; // TODO(macOS GH#750)
|
|
1044
1040
|
if (lightColor != nil && darkColor != nil) {
|
|
1045
1041
|
#if TARGET_OS_OSX
|
|
1046
|
-
|
|
1042
|
+
NSColor *color = [NSColor colorWithName:nil dynamicProvider:^NSColor * _Nonnull(NSAppearance * _Nonnull appearance) {
|
|
1043
|
+
NSMutableArray<NSAppearanceName> *appearances = [NSMutableArray arrayWithArray:@[NSAppearanceNameAqua,NSAppearanceNameDarkAqua]];
|
|
1044
|
+
if (highContrastLightColor != nil) {
|
|
1045
|
+
[appearances addObject:NSAppearanceNameAccessibilityHighContrastAqua];
|
|
1046
|
+
}
|
|
1047
|
+
if (highContrastDarkColor != nil) {
|
|
1048
|
+
[appearances addObject:NSAppearanceNameAccessibilityHighContrastDarkAqua];
|
|
1049
|
+
}
|
|
1050
|
+
NSAppearanceName bestMatchingAppearance = [appearance bestMatchFromAppearancesWithNames:appearances];
|
|
1051
|
+
if (bestMatchingAppearance == NSAppearanceNameAqua) {
|
|
1052
|
+
return lightColor;
|
|
1053
|
+
} else if (bestMatchingAppearance == NSAppearanceNameDarkAqua) {
|
|
1054
|
+
return darkColor;
|
|
1055
|
+
} else if (bestMatchingAppearance == NSAppearanceNameAccessibilityHighContrastAqua) {
|
|
1056
|
+
return highContrastLightColor;
|
|
1057
|
+
} else if (bestMatchingAppearance == NSAppearanceNameAccessibilityHighContrastDarkAqua) {
|
|
1058
|
+
return highContrastDarkColor;
|
|
1059
|
+
} else {
|
|
1060
|
+
RCTLogConvertError(json, @"an NSColorColor. Could not resolve current appearance. Defaulting to light.");
|
|
1061
|
+
return lightColor;
|
|
1062
|
+
}
|
|
1063
|
+
}];
|
|
1047
1064
|
return color;
|
|
1048
1065
|
#else
|
|
1049
1066
|
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
|
|
@@ -1406,7 +1423,7 @@ RCT_ENUM_CONVERTER(
|
|
|
1406
1423
|
@"link": NSAccessibilityLinkRole, // also a legacy iOS accessibilityTraits
|
|
1407
1424
|
@"menu": NSAccessibilityMenuRole,
|
|
1408
1425
|
@"menubar": NSAccessibilityMenuBarRole,
|
|
1409
|
-
@"menuitem":
|
|
1426
|
+
@"menuitem": NSAccessibilityMenuItemRole,
|
|
1410
1427
|
@"none": NSAccessibilityUnknownRole,
|
|
1411
1428
|
@"progressbar": NSAccessibilityProgressIndicatorRole,
|
|
1412
1429
|
@"radio": NSAccessibilityRadioButtonRole,
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
(CGSizeEqualToSize(_size, object.size) || CGSizeEqualToSize(object.size, CGSizeZero));
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
#if DEBUG // TODO(macOS GH#774) description is a debug-only feature
|
|
45
46
|
- (NSString *)description
|
|
46
47
|
{
|
|
47
48
|
return [NSString stringWithFormat:@"<RCTImageSource: %p URL=%@, size=%@, scale=%0.f>",
|
|
@@ -50,6 +51,7 @@
|
|
|
50
51
|
NSStringFromCGSize(_size),
|
|
51
52
|
_scale];
|
|
52
53
|
}
|
|
54
|
+
#endif // TODO(macOS GH#774)
|
|
53
55
|
|
|
54
56
|
@end
|
|
55
57
|
|
|
@@ -136,6 +136,7 @@ static NSRegularExpression *RCTJSStackFrameRegex()
|
|
|
136
136
|
return stack;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
#if DEBUG // TODO(macOS GH#774) description is a debug-only feature
|
|
139
140
|
- (NSString *)description
|
|
140
141
|
{
|
|
141
142
|
return [NSString stringWithFormat:@"<%@: %p method name: %@; file name: %@; line: %ld; column: %ld>",
|
|
@@ -146,5 +147,6 @@ static NSRegularExpression *RCTJSStackFrameRegex()
|
|
|
146
147
|
(long)self.lineNumber,
|
|
147
148
|
(long)self.column];
|
|
148
149
|
}
|
|
150
|
+
#endif // TODO(macOS GH#774)
|
|
149
151
|
|
|
150
152
|
@end
|
|
@@ -62,6 +62,7 @@ static RCTSource *RCTSourceCreate(NSURL *url, NSData *data, int64_t length) NS_R
|
|
|
62
62
|
|
|
63
63
|
@implementation RCTLoadingProgress
|
|
64
64
|
|
|
65
|
+
#if DEBUG // TODO(macOS GH#774) description is a debug-only feature
|
|
65
66
|
- (NSString *)description
|
|
66
67
|
{
|
|
67
68
|
NSMutableString *desc = [NSMutableString new];
|
|
@@ -77,6 +78,7 @@ static RCTSource *RCTSourceCreate(NSURL *url, NSData *data, int64_t length) NS_R
|
|
|
77
78
|
[desc appendString:@"\u2026"];
|
|
78
79
|
return desc;
|
|
79
80
|
}
|
|
81
|
+
#endif // TODO(macOS GH#774)
|
|
80
82
|
|
|
81
83
|
@end
|
|
82
84
|
|