react-native-macos 0.0.0-291c44ded → 0.0.0-2cebba997
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 +9 -0
- package/README.md +4 -3
- 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/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/Modules/RCTLayoutAnimation.m +2 -0
- package/React/Modules/RCTLayoutAnimationGroup.m +2 -0
- package/React/Views/RCTShadowView.m +2 -0
- 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/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 +2 -2
- package/template/package.json +1 -1
- 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;
|
|
@@ -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
|
package/README.md
CHANGED
|
@@ -61,10 +61,11 @@ The source for the React Native documentation and website is hosted on a separat
|
|
|
61
61
|
[React Native for Windows + macOS](https://microsoft.github.io/react-native-windows/) has its own separate documentation site where Windows and macOS
|
|
62
62
|
specific information, like API docs and blog updates live. We are still working on the documentation for macOS, contributions are welcome!
|
|
63
63
|
|
|
64
|
-
|
|
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
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
### Git flow and syncing with upstream
|
|
67
|
+
|
|
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).
|
|
68
69
|
|
|
69
70
|
## License
|
|
70
71
|
|
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
|
|
|
@@ -74,6 +74,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
|
|
74
74
|
return [_key isEqual:input] && (_flags == flags || flags == 0);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
#if DEBUG // TODO(macOS GH#774) description is a debug-only feature
|
|
77
78
|
- (NSString *)description
|
|
78
79
|
{
|
|
79
80
|
return [NSString stringWithFormat:@"<%@:%p input=\"%@\" flags=%lld hasBlock=%@>",
|
|
@@ -83,6 +84,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
|
|
83
84
|
(long long)_flags,
|
|
84
85
|
_block ? @"YES" : @"NO"];
|
|
85
86
|
}
|
|
87
|
+
#endif // TODO(macOS GH#774)
|
|
86
88
|
|
|
87
89
|
@end
|
|
88
90
|
|
|
@@ -570,9 +570,11 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init);
|
|
|
570
570
|
_methodQueue = nil;
|
|
571
571
|
}
|
|
572
572
|
|
|
573
|
+
#if DEBUG // TODO(macOS GH#774) description is a debug-only feature
|
|
573
574
|
- (NSString *)description
|
|
574
575
|
{
|
|
575
576
|
return [NSString stringWithFormat:@"<%@: %p; name=\"%@\">", [self class], self, self.name];
|
|
576
577
|
}
|
|
578
|
+
#endif // TODO(macOS GH#774)
|
|
577
579
|
|
|
578
580
|
@end
|
|
@@ -602,6 +602,7 @@ RCT_EXTERN_C_END
|
|
|
602
602
|
return [NSString stringWithFormat:@"-[%@ %s]", _moduleClass, sel_getName(_selector)];
|
|
603
603
|
}
|
|
604
604
|
|
|
605
|
+
#if DEBUG // TODO(macOS GH#774) description is a debug-only feature
|
|
605
606
|
- (NSString *)description
|
|
606
607
|
{
|
|
607
608
|
return [NSString stringWithFormat:@"<%@: %p; exports %@ as %s(); type: %s>",
|
|
@@ -611,5 +612,6 @@ RCT_EXTERN_C_END
|
|
|
611
612
|
self.JSMethodName,
|
|
612
613
|
RCTFunctionDescriptorFromType(self.functionType)];
|
|
613
614
|
}
|
|
615
|
+
#endif // TODO(macOS GH#774)
|
|
614
616
|
|
|
615
617
|
@end
|
|
@@ -98,10 +98,12 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
|
|
98
98
|
return _coalescingKey;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
#if DEBUG // TODO(macOS GH#774) description is a debug-only feature
|
|
101
102
|
- (NSString *)description
|
|
102
103
|
{
|
|
103
104
|
return [NSString
|
|
104
105
|
stringWithFormat:@"<%@: %p; name = %@; coalescing key = %hu>", [self class], self, _eventName, _coalescingKey];
|
|
105
106
|
}
|
|
107
|
+
#endif // TODO(macOS GH#774)
|
|
106
108
|
|
|
107
109
|
@end
|
package/React/Base/RCTVersion.m
CHANGED
|
@@ -50,7 +50,7 @@ static CVReturn RCTPlatformDisplayLinkCallBack(__unused CVDisplayLinkRef display
|
|
|
50
50
|
os_unfair_lock_lock(&rctDisplayLink->_lock);
|
|
51
51
|
if (rctDisplayLink->_runLoop != nil) {
|
|
52
52
|
CFRunLoopRef cfRunLoop = [rctDisplayLink->_runLoop getCFRunLoop];
|
|
53
|
-
CFRunLoopPerformBlock(cfRunLoop,
|
|
53
|
+
CFRunLoopPerformBlock(cfRunLoop, (__bridge CFArrayRef)rctDisplayLink->_modes, ^{
|
|
54
54
|
[rctDisplayLink tick];
|
|
55
55
|
});
|
|
56
56
|
CFRunLoopWakeUp(cfRunLoop);
|
|
@@ -71,14 +71,17 @@ static CVReturn RCTPlatformDisplayLinkCallBack(__unused CVDisplayLinkRef display
|
|
|
71
71
|
|
|
72
72
|
- (void)addToRunLoop:(NSRunLoop *)runloop forMode:(NSRunLoopMode)mode
|
|
73
73
|
{
|
|
74
|
+
os_unfair_lock_lock(&_lock);
|
|
74
75
|
_runLoop = runloop;
|
|
75
76
|
|
|
76
77
|
if (_displayLink != NULL) {
|
|
77
78
|
[_modes addObject:mode];
|
|
79
|
+
os_unfair_lock_unlock(&_lock);
|
|
78
80
|
return;
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
_modes = @[mode].mutableCopy;
|
|
84
|
+
os_unfair_lock_unlock(&_lock);
|
|
82
85
|
CVReturn ret = CVDisplayLinkCreateWithActiveCGDisplays(&_displayLink);
|
|
83
86
|
if (ret != kCVReturnSuccess) {
|
|
84
87
|
ret = CVDisplayLinkCreateWithCGDisplay(CGMainDisplayID(), &_displayLink);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* This source code is licensed under the MIT license found in the
|
|
4
|
+
* LICENSE file in the root directory of this source tree.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
#import <React/RCTUIKit.h>
|
|
8
|
+
#import <React/RCTBridge.h>
|
|
9
|
+
|
|
10
|
+
@interface RCTAddressSanitizerCrashManager : NSObject <RCTBridgeModule>
|
|
11
|
+
|
|
12
|
+
@end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RCTAddressSanitizerCrashManager.mm
|
|
3
|
+
// Pods
|
|
4
|
+
//
|
|
5
|
+
|
|
6
|
+
#import "RCTAddressSanitizerCrashManager.h"
|
|
7
|
+
|
|
8
|
+
@implementation RCTAddressSanitizerCrashManager
|
|
9
|
+
|
|
10
|
+
RCT_EXPORT_MODULE(ASANCrash)
|
|
11
|
+
|
|
12
|
+
RCT_EXPORT_METHOD(invokeMemoryCrash) {
|
|
13
|
+
char *s = (char*)malloc(100);
|
|
14
|
+
free(s);
|
|
15
|
+
strcpy(s, "Hello world!"); // AddressSanitizer: heap-use-after-free
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@end
|
|
@@ -81,7 +81,11 @@ NSString *RCTColorSchemePreference(NSAppearance *appearance)
|
|
|
81
81
|
return RCTAppearanceColorSchemeLight;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
if (@available(macOS 11.0, *)) {
|
|
85
|
+
appearance = appearance ?: [NSAppearance currentDrawingAppearance];
|
|
86
|
+
} else {
|
|
87
|
+
appearance = appearance ?: [NSAppearance currentAppearance];
|
|
88
|
+
}
|
|
85
89
|
NSAppearanceName appearanceName = [appearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
|
|
86
90
|
return appearances[appearanceName] ?: RCTAppearanceColorSchemeLight;
|
|
87
91
|
}
|
|
@@ -266,16 +266,21 @@ RCT_EXPORT_METHOD(hide)
|
|
|
266
266
|
|
|
267
267
|
- (void)showOfflineMessage
|
|
268
268
|
{
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
269
|
+
// [TODO(macOS GH#774) - isDarkModeEnabled should only be run on the main thread
|
|
270
|
+
__weak __typeof(self) weakSelf = self;
|
|
271
|
+
RCTExecuteOnMainQueue(^{
|
|
272
|
+
RCTUIColor *color = [RCTUIColor whiteColor]; // TODO(macOS GH#774)
|
|
273
|
+
RCTUIColor *backgroundColor = [RCTUIColor blackColor]; // TODO(macOS GH#774)
|
|
274
|
+
|
|
275
|
+
if ([weakSelf isDarkModeEnabled]) {
|
|
276
|
+
color = [RCTUIColor blackColor]; // TODO(macOS GH#774)
|
|
277
|
+
backgroundColor = [RCTUIColor whiteColor]; // TODO(macOS GH#774)
|
|
278
|
+
}
|
|
276
279
|
|
|
277
|
-
|
|
278
|
-
|
|
280
|
+
NSString *message = [NSString stringWithFormat:@"Connect to %@ to develop JavaScript.", RCT_PACKAGER_NAME];
|
|
281
|
+
[weakSelf showMessage:message color:color backgroundColor:backgroundColor];
|
|
282
|
+
});
|
|
283
|
+
// ]TODO(macOS GH#774)
|
|
279
284
|
}
|
|
280
285
|
|
|
281
286
|
- (BOOL)isDarkModeEnabled
|
|
@@ -131,9 +131,11 @@ using namespace facebook::react;
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
#if DEBUG // TODO(macOS GH#774) description is a debug-only feature
|
|
134
135
|
- (NSString *)description
|
|
135
136
|
{
|
|
136
137
|
return [NSString stringWithFormat:@"<%@: %p; name = %s>", [self class], self, self.JSMethodName];
|
|
137
138
|
}
|
|
139
|
+
#endif // TODO(macOS GH#774)
|
|
138
140
|
|
|
139
141
|
@end
|
|
@@ -190,6 +190,7 @@ static NSString *CAMediaTimingFunctionNameFromRCTAnimationType(RCTAnimationType
|
|
|
190
190
|
_animationType == animation.animationType;
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
#if DEBUG // TODO(macOS GH#774) description is a debug-only feature
|
|
193
194
|
- (NSString *)description
|
|
194
195
|
{
|
|
195
196
|
return [NSString
|
|
@@ -204,5 +205,6 @@ static NSString *CAMediaTimingFunctionNameFromRCTAnimationType(RCTAnimationType
|
|
|
204
205
|
_initialVelocity,
|
|
205
206
|
(long)_animationType];
|
|
206
207
|
}
|
|
208
|
+
#endif // TODO(macOS GH#774)
|
|
207
209
|
|
|
208
210
|
@end
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
[_deletingLayoutAnimation isEqual:deletingLayoutAnimation]);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
#if DEBUG // TODO(macOS GH#774) description is a debug-only feature
|
|
67
68
|
- (NSString *)description
|
|
68
69
|
{
|
|
69
70
|
return
|
|
@@ -75,5 +76,6 @@
|
|
|
75
76
|
[_updatingLayoutAnimation description],
|
|
76
77
|
[_deletingLayoutAnimation description]];
|
|
77
78
|
}
|
|
79
|
+
#endif // TODO(macOS GH#774)
|
|
78
80
|
|
|
79
81
|
@end
|
|
@@ -393,6 +393,7 @@ static void RCTProcessMetaPropsBorder(const YGValue metaProps[META_PROP_COUNT],
|
|
|
393
393
|
return self.reactTag;
|
|
394
394
|
}
|
|
395
395
|
|
|
396
|
+
#if DEBUG // TODO(macOS GH#774) description is a debug-only feature
|
|
396
397
|
- (NSString *)description
|
|
397
398
|
{
|
|
398
399
|
NSString *description = super.description;
|
|
@@ -403,6 +404,7 @@ static void RCTProcessMetaPropsBorder(const YGValue metaProps[META_PROP_COUNT],
|
|
|
403
404
|
NSStringFromCGRect(self.layoutMetrics.frame)];
|
|
404
405
|
return description;
|
|
405
406
|
}
|
|
407
|
+
#endif // TODO(macOS GH#774)
|
|
406
408
|
|
|
407
409
|
- (void)addRecursiveDescriptionToString:(NSMutableString *)string atLevel:(NSUInteger)level
|
|
408
410
|
{
|
package/React/Views/RCTView.h
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
#import <React/RCTBorderStyle.h>
|
|
11
11
|
#import <React/RCTComponent.h>
|
|
12
|
-
#import <React/
|
|
12
|
+
#import <React/RCTEventDispatcherProtocol.h> // TODO(OSS Candidate ISS#2710739)
|
|
13
13
|
#import <React/RCTPointerEvents.h>
|
|
14
14
|
|
|
15
15
|
#if !TARGET_OS_OSX // TODO(macOS GH#774)
|
|
@@ -23,7 +23,7 @@ extern const UIAccessibilityTraits SwitchAccessibilityTrait;
|
|
|
23
23
|
@interface RCTView : RCTUIView // TODO(macOS ISS#3536887)
|
|
24
24
|
|
|
25
25
|
// [TODO(OSS Candidate ISS#2710739)
|
|
26
|
-
- (instancetype)initWithEventDispatcher:(
|
|
26
|
+
- (instancetype)initWithEventDispatcher:(id<RCTEventDispatcherProtocol>)eventDispatcher;
|
|
27
27
|
|
|
28
28
|
- (BOOL)becomeFirstResponder;
|
|
29
29
|
- (BOOL)resignFirstResponder;
|
|
@@ -128,6 +128,9 @@ extern const UIAccessibilityTraits SwitchAccessibilityTrait;
|
|
|
128
128
|
/**
|
|
129
129
|
* macOS Properties
|
|
130
130
|
*/
|
|
131
|
+
|
|
132
|
+
@property (nonatomic, assign) CATransform3D transform3D;
|
|
133
|
+
|
|
131
134
|
@property (nonatomic, copy) RCTDirectEventBlock onDoubleClick;
|
|
132
135
|
@property (nonatomic, copy) RCTDirectEventBlock onClick;
|
|
133
136
|
@property (nonatomic, copy) RCTDirectEventBlock onMouseEnter;
|
package/React/Views/RCTView.m
CHANGED
|
@@ -123,7 +123,7 @@ static NSString *RCTRecursiveAccessibilityLabel(RCTUIView *view) // TODO(macOS I
|
|
|
123
123
|
|
|
124
124
|
@implementation RCTView {
|
|
125
125
|
RCTUIColor *_backgroundColor; // TODO(OSS Candidate ISS#2710739)
|
|
126
|
-
|
|
126
|
+
id<RCTEventDispatcherProtocol> _eventDispatcher; // TODO(OSS Candidate ISS#2710739)
|
|
127
127
|
#if TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
128
128
|
NSTrackingArea *_trackingArea;
|
|
129
129
|
BOOL _hasMouseOver;
|
|
@@ -133,7 +133,7 @@ static NSString *RCTRecursiveAccessibilityLabel(RCTUIView *view) // TODO(macOS I
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
// [TODO(OSS Candidate ISS#2710739)
|
|
136
|
-
- (instancetype)initWithEventDispatcher:(
|
|
136
|
+
- (instancetype)initWithEventDispatcher:(id<RCTEventDispatcherProtocol>)eventDispatcher
|
|
137
137
|
{
|
|
138
138
|
if ((self = [self initWithFrame:CGRectZero])) {
|
|
139
139
|
_eventDispatcher = eventDispatcher;
|
|
@@ -162,6 +162,9 @@ static NSString *RCTRecursiveAccessibilityLabel(RCTUIView *view) // TODO(macOS I
|
|
|
162
162
|
_borderBottomEndRadius = -1;
|
|
163
163
|
_borderStyle = RCTBorderStyleSolid;
|
|
164
164
|
_hitTestEdgeInsets = UIEdgeInsetsZero;
|
|
165
|
+
#if TARGET_OS_OSX // TODO(macOS GH#774)
|
|
166
|
+
_transform3D = CATransform3DIdentity;
|
|
167
|
+
#endif // TODO(macOS GH#774)
|
|
165
168
|
|
|
166
169
|
_backgroundColor = super.backgroundColor;
|
|
167
170
|
}
|
|
@@ -708,17 +711,13 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : unused)
|
|
|
708
711
|
}
|
|
709
712
|
#endif // ]TODO(macOS GH#774)
|
|
710
713
|
|
|
714
|
+
#if DEBUG // TODO(macOS GH#774) description is a debug-only feature
|
|
711
715
|
- (NSString *)description
|
|
712
716
|
{
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
if (semicolonRange.location == NSNotFound) { // [TODO(macOS GH#774)
|
|
716
|
-
return [[superDescription substringToIndex:superDescription.length - 1] stringByAppendingFormat:@"; reactTag: %@; frame = %@; layer = %@>", self.reactTag, NSStringFromCGRect(self.frame), self.layer];
|
|
717
|
-
} else { // ]TODO(macOS GH#774)
|
|
718
|
-
NSString *replacement = [NSString stringWithFormat:@"; reactTag: %@;", self.reactTag];
|
|
719
|
-
return [superDescription stringByReplacingCharactersInRange:semicolonRange withString:replacement];
|
|
720
|
-
} // TODO(macOS GH#774)
|
|
717
|
+
// TODO(macOS GH#774): we shouldn't make assumptions on what super's description is. Just append additional content.
|
|
718
|
+
return [[super description] stringByAppendingFormat:@" reactTag: %@; frame = %@; layer = %@", self.reactTag, NSStringFromCGRect(self.frame), self.layer];
|
|
721
719
|
}
|
|
720
|
+
#endif // TODO(macOS GH#774)
|
|
722
721
|
|
|
723
722
|
#if TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
724
723
|
- (void)viewDidMoveToWindow
|
|
@@ -1169,6 +1168,19 @@ static CGFloat RCTDefaultIfNegativeTo(CGFloat defaultValue, CGFloat x)
|
|
|
1169
1168
|
backgroundColor = _backgroundColor.CGColor;
|
|
1170
1169
|
#endif
|
|
1171
1170
|
|
|
1171
|
+
#if TARGET_OS_OSX // [TODO(macOS GH#1035)
|
|
1172
|
+
CATransform3D transform = [self transform3D];
|
|
1173
|
+
CGPoint anchorPoint = [layer anchorPoint];
|
|
1174
|
+
if (CGPointEqualToPoint(anchorPoint, CGPointZero) && !CATransform3DEqualToTransform(transform, CATransform3DIdentity)) {
|
|
1175
|
+
// https://developer.apple.com/documentation/quartzcore/calayer/1410817-anchorpoint
|
|
1176
|
+
// This compensates for the fact that layer.anchorPoint is {0, 0} instead of {0.5, 0.5} on macOS for some reason.
|
|
1177
|
+
CATransform3D originAdjust = CATransform3DTranslate(CATransform3DIdentity, self.frame.size.width / 2, self.frame.size.height / 2, 0);
|
|
1178
|
+
transform = CATransform3DConcat(CATransform3DConcat(CATransform3DInvert(originAdjust), transform), originAdjust);
|
|
1179
|
+
// Enable edge antialiasing in perspective transforms
|
|
1180
|
+
[layer setAllowsEdgeAntialiasing:!(transform.m34 == 0.0f)];
|
|
1181
|
+
}
|
|
1182
|
+
[layer setTransform:transform];
|
|
1183
|
+
#endif // ]TODO(macOS GH#1035)
|
|
1172
1184
|
if (useIOSBorderRendering) {
|
|
1173
1185
|
layer.cornerRadius = cornerRadii.topLeft;
|
|
1174
1186
|
layer.borderColor = borderColors.left;
|
|
@@ -215,15 +215,16 @@ RCT_CUSTOM_VIEW_PROPERTY(shouldRasterizeIOS, BOOL, RCTView)
|
|
|
215
215
|
|
|
216
216
|
RCT_CUSTOM_VIEW_PROPERTY(transform, CATransform3D, RCTView)
|
|
217
217
|
{
|
|
218
|
-
#if
|
|
218
|
+
#if TARGET_OS_OSX // [TODO(macOS GH#460)
|
|
219
|
+
CATransform3D transform = json ? [RCTConvert CATransform3D:json] : defaultView.layer.transform;
|
|
220
|
+
[view setTransform3D:transform];
|
|
221
|
+
[view setNeedsDisplay];
|
|
222
|
+
#else // ]TODO(macOS GH#460)]
|
|
219
223
|
view.layer.transform = json ? [RCTConvert CATransform3D:json] : defaultView.layer.transform;
|
|
220
|
-
// Enable edge antialiasing in perspective transforms
|
|
221
|
-
view.layer.allowsEdgeAntialiasing =
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
// TODO: Improve this by enabling edge antialiasing only for transforms with rotation or skewing
|
|
225
|
-
view.layer.edgeAntialiasingMask = !CATransform3DIsIdentity(view.layer.sublayerTransform) ? kCALayerLeftEdge | kCALayerRightEdge | kCALayerBottomEdge | kCALayerTopEdge : 0;
|
|
226
|
-
#endif // ]TODO(macOS GH#774)
|
|
224
|
+
// Enable edge antialiasing in rotation, skew, or perspective transforms
|
|
225
|
+
view.layer.allowsEdgeAntialiasing =
|
|
226
|
+
view.layer.transform.m12 != 0.0f || view.layer.transform.m21 != 0.0f || view.layer.transform.m34 != 0.0f;
|
|
227
|
+
#endif // [TODO(macOS GH#460)]
|
|
227
228
|
}
|
|
228
229
|
|
|
229
230
|
RCT_CUSTOM_VIEW_PROPERTY(accessibilityRole, UIAccessibilityTraits, RCTView)
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)decoder)
|
|
31
31
|
RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame)
|
|
32
32
|
|
|
33
|
+
#if DEBUG // TODO(macOS GH#774) description is a debug-only feature
|
|
33
34
|
- (NSString *)description
|
|
34
35
|
{
|
|
35
36
|
NSString *superDescription = [super description];
|
|
@@ -44,6 +45,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame)
|
|
|
44
45
|
NSStringFromUIEdgeInsets([self safeAreaInsetsIfSupportedAndEnabled]),
|
|
45
46
|
NSStringFromUIEdgeInsets(_currentSafeAreaInsets)];
|
|
46
47
|
}
|
|
48
|
+
#endif // TODO(macOS GH#774)
|
|
47
49
|
|
|
48
50
|
- (BOOL)isSupportedByOS
|
|
49
51
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-macos",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-2cebba997",
|
|
4
4
|
"bin": "./cli.js",
|
|
5
5
|
"description": "React Native for macOS",
|
|
6
6
|
"license": "MIT",
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
"eslint-plugin-jest": "22.4.1",
|
|
145
145
|
"eslint-plugin-jsx-a11y": "6.2.1",
|
|
146
146
|
"eslint-plugin-prettier": "2.6.2",
|
|
147
|
-
"eslint-plugin-react": "7.
|
|
147
|
+
"eslint-plugin-react": "7.28.0",
|
|
148
148
|
"eslint-plugin-react-hooks": "^4.2.0",
|
|
149
149
|
"eslint-plugin-react-native": "3.10.0",
|
|
150
150
|
"eslint-plugin-relay": "1.8.1",
|
package/template/package.json
CHANGED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2015-present, Facebook, Inc.
|
|
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
|
-
// TODO(macOS GH#774)
|
|
9
|
-
|
|
10
|
-
#include <AppKit/AppKit.h>
|
|
11
|
-
|
|
12
|
-
/** A dynamic, theme aware subclass of NSColor.
|
|
13
|
-
* It is a tuple that contains two NSColors for light and dark
|
|
14
|
-
* theme appearances. Like a semantic NSColor or an
|
|
15
|
-
* asset catalog named NSColor, the effective color values
|
|
16
|
-
* returned by the various methods and properties vary
|
|
17
|
-
* depending on the current [NSAppearance currentAppearance].
|
|
18
|
-
*/
|
|
19
|
-
@interface RCTDynamicColor : NSColor
|
|
20
|
-
|
|
21
|
-
/** Inits a RCTDynamicColor with a pair of NSColors
|
|
22
|
-
* @param aquaColor the color to use when the current appearance is not dark
|
|
23
|
-
* @param darkAquaColor the color to use when the current appearance is dark
|
|
24
|
-
*/
|
|
25
|
-
- (instancetype)initWithAquaColor:(NSColor *)aquaColor
|
|
26
|
-
darkAquaColor:(nullable NSColor *)darkAquaColor;
|
|
27
|
-
|
|
28
|
-
@end
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2015-present, Facebook, Inc.
|
|
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
|
-
// TODO(macOS GH#774)
|
|
9
|
-
|
|
10
|
-
#import "RCTDynamicColor.h"
|
|
11
|
-
|
|
12
|
-
#define RCT_FORWARD_PROPERTY( PROP, TYPE ) \
|
|
13
|
-
- (TYPE)PROP { return [[self effectiveColor] PROP]; }
|
|
14
|
-
|
|
15
|
-
static NSString *const RCTAquaColor = @"aquaColor";
|
|
16
|
-
static NSString *const RCTDarkAquaColor = @"darkAquaColor";
|
|
17
|
-
|
|
18
|
-
@implementation RCTDynamicColor
|
|
19
|
-
{
|
|
20
|
-
NSColor *_aquaColor;
|
|
21
|
-
NSColor *_darkAquaColor;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
- (instancetype)initWithAquaColor:(NSColor *)aquaColor
|
|
25
|
-
darkAquaColor:(NSColor *)darkAquaColor
|
|
26
|
-
{
|
|
27
|
-
self = [super init];
|
|
28
|
-
if (self) {
|
|
29
|
-
_aquaColor = [aquaColor copy];
|
|
30
|
-
_darkAquaColor = [darkAquaColor copy];
|
|
31
|
-
}
|
|
32
|
-
return self;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
+ (BOOL)supportsSecureCoding
|
|
36
|
-
{
|
|
37
|
-
return YES;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
- (instancetype)initWithCoder:(NSCoder *)coder
|
|
41
|
-
{
|
|
42
|
-
self = [super initWithCoder:coder];
|
|
43
|
-
if (self) {
|
|
44
|
-
_aquaColor = [coder decodeObjectOfClass:[NSColor class] forKey:RCTAquaColor];
|
|
45
|
-
_darkAquaColor = [coder decodeObjectOfClass:[NSColor class] forKey:RCTDarkAquaColor];
|
|
46
|
-
}
|
|
47
|
-
return self;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
- (void)encodeWithCoder:(NSCoder *)aCoder
|
|
51
|
-
{
|
|
52
|
-
[super encodeWithCoder:aCoder];
|
|
53
|
-
[aCoder encodeObject:_aquaColor forKey:RCTAquaColor];
|
|
54
|
-
if (_darkAquaColor) {
|
|
55
|
-
[aCoder encodeObject:_darkAquaColor forKey:RCTDarkAquaColor];
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
- (NSColor *)effectiveColor
|
|
60
|
-
{
|
|
61
|
-
NSColor *effectiveColor = _aquaColor;
|
|
62
|
-
NSAppearance *appearance = [NSAppearance currentAppearance] ?: [NSApp effectiveAppearance];
|
|
63
|
-
|
|
64
|
-
NSAppearanceName appearanceName = [appearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
|
|
65
|
-
|
|
66
|
-
if (_darkAquaColor != nil && [appearanceName isEqualToString:NSAppearanceNameDarkAqua]) {
|
|
67
|
-
effectiveColor = _darkAquaColor;
|
|
68
|
-
}
|
|
69
|
-
return effectiveColor;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
RCT_FORWARD_PROPERTY(colorSpace, NSColorSpace *)
|
|
73
|
-
- (NSColor *)colorUsingColorSpace:(NSColorSpace *)space
|
|
74
|
-
{
|
|
75
|
-
return [[self effectiveColor] colorUsingColorSpace:space];
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
RCT_FORWARD_PROPERTY(colorSpaceName, NSColorSpaceName)
|
|
79
|
-
- (NSColor *)colorUsingColorSpaceName:(NSColorSpaceName)name
|
|
80
|
-
{
|
|
81
|
-
return [[self effectiveColor] colorUsingColorSpaceName:name];
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
RCT_FORWARD_PROPERTY(numberOfComponents, NSInteger)
|
|
85
|
-
- (void)getComponents:(CGFloat *)components
|
|
86
|
-
{
|
|
87
|
-
return [[self effectiveColor] getComponents:components];
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
#pragma mark - RGB colorspace
|
|
91
|
-
|
|
92
|
-
RCT_FORWARD_PROPERTY(redComponent, CGFloat)
|
|
93
|
-
RCT_FORWARD_PROPERTY(greenComponent, CGFloat)
|
|
94
|
-
RCT_FORWARD_PROPERTY(blueComponent, CGFloat)
|
|
95
|
-
|
|
96
|
-
- (void)getRed:(nullable CGFloat *)red green:(nullable CGFloat *)green blue:(nullable CGFloat *)blue alpha:(nullable CGFloat *)alpha
|
|
97
|
-
{
|
|
98
|
-
return [[self effectiveColor] getRed:red green:green blue:blue alpha:alpha];
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
#pragma mark - HSB colorspace
|
|
102
|
-
|
|
103
|
-
RCT_FORWARD_PROPERTY(hueComponent, CGFloat)
|
|
104
|
-
RCT_FORWARD_PROPERTY(saturationComponent, CGFloat)
|
|
105
|
-
RCT_FORWARD_PROPERTY(brightnessComponent, CGFloat)
|
|
106
|
-
|
|
107
|
-
- (void)getHue:(nullable CGFloat *)hue saturation:(nullable CGFloat *)saturation brightness:(nullable CGFloat *)brightness alpha:(nullable CGFloat *)alpha
|
|
108
|
-
{
|
|
109
|
-
return [[self effectiveColor] getHue:hue saturation:saturation brightness:brightness alpha:alpha];
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
#pragma mark - Gray colorspace
|
|
113
|
-
|
|
114
|
-
RCT_FORWARD_PROPERTY(whiteComponent, CGFloat)
|
|
115
|
-
|
|
116
|
-
- (void)getWhite:(CGFloat *)white alpha:(CGFloat *)alpha
|
|
117
|
-
{
|
|
118
|
-
return [[self effectiveColor] getWhite:white alpha:alpha];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
#pragma mark - CMYK colorspace
|
|
122
|
-
|
|
123
|
-
RCT_FORWARD_PROPERTY(cyanComponent, CGFloat)
|
|
124
|
-
RCT_FORWARD_PROPERTY(magentaComponent, CGFloat)
|
|
125
|
-
RCT_FORWARD_PROPERTY(yellowComponent, CGFloat)
|
|
126
|
-
RCT_FORWARD_PROPERTY(blackComponent, CGFloat)
|
|
127
|
-
|
|
128
|
-
- (void)getCyan:(nullable CGFloat *)cyan magenta:(nullable CGFloat *)magenta yellow:(nullable CGFloat *)yellow black:(nullable CGFloat *)black alpha:(nullable CGFloat *)alpha
|
|
129
|
-
{
|
|
130
|
-
return [[self effectiveColor] getCyan:cyan magenta:magenta yellow:yellow black:black alpha:alpha];
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
#pragma mark - Others
|
|
134
|
-
|
|
135
|
-
RCT_FORWARD_PROPERTY(alphaComponent, CGFloat)
|
|
136
|
-
RCT_FORWARD_PROPERTY(CGColor, CGColorRef)
|
|
137
|
-
RCT_FORWARD_PROPERTY(catalogNameComponent, NSColorListName)
|
|
138
|
-
RCT_FORWARD_PROPERTY(colorNameComponent, NSColorName)
|
|
139
|
-
RCT_FORWARD_PROPERTY(localizedCatalogNameComponent, NSColorListName)
|
|
140
|
-
RCT_FORWARD_PROPERTY(localizedColorNameComponent, NSString *)
|
|
141
|
-
|
|
142
|
-
- (void)setStroke
|
|
143
|
-
{
|
|
144
|
-
[[self effectiveColor] setStroke];
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
- (void)setFill
|
|
148
|
-
{
|
|
149
|
-
[[self effectiveColor] setFill];
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
- (void)set
|
|
153
|
-
{
|
|
154
|
-
[[self effectiveColor] set];
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
- (nullable NSColor *)highlightWithLevel:(CGFloat)val
|
|
158
|
-
{
|
|
159
|
-
return [[self effectiveColor] highlightWithLevel:val];
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
- (NSColor *)shadowWithLevel:(CGFloat)val
|
|
163
|
-
{
|
|
164
|
-
return [[self effectiveColor] shadowWithLevel:val];
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
- (NSColor *)colorWithAlphaComponent:(CGFloat)alpha
|
|
168
|
-
{
|
|
169
|
-
return [[self effectiveColor] colorWithAlphaComponent:alpha];
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
- (nullable NSColor *)blendedColorWithFraction:(CGFloat)fraction ofColor:(NSColor *)color
|
|
173
|
-
{
|
|
174
|
-
return [[self effectiveColor] blendedColorWithFraction:fraction ofColor:color];
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
- (NSColor *)colorWithSystemEffect:(NSColorSystemEffect)systemEffect NS_AVAILABLE_MAC(10_14)
|
|
178
|
-
{
|
|
179
|
-
NSColor *aquaColorWithSystemEffect = [_aquaColor colorWithSystemEffect:systemEffect];
|
|
180
|
-
NSColor *darkAquaColorWithSystemEffect = [_darkAquaColor colorWithSystemEffect:systemEffect];
|
|
181
|
-
return [[RCTDynamicColor alloc] initWithAquaColor:aquaColorWithSystemEffect darkAquaColor:darkAquaColorWithSystemEffect];
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
- (NSUInteger)hash
|
|
185
|
-
{
|
|
186
|
-
const NSUInteger prime = 31;
|
|
187
|
-
NSUInteger result = 1;
|
|
188
|
-
result = prime * result + [_aquaColor hash];
|
|
189
|
-
result = prime * result + [_darkAquaColor hash];
|
|
190
|
-
return result;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
- (BOOL)isEqual:(id)other {
|
|
194
|
-
if (other == self) {
|
|
195
|
-
return YES;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
return other != nil && [other isKindOfClass:[self class]] && [self isEqualToDynamicColor:other];
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
- (BOOL)isEqualToDynamicColor:(RCTDynamicColor *)other {
|
|
202
|
-
if (self == other) {
|
|
203
|
-
return YES;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if ([_aquaColor isNotEqualTo:other->_aquaColor]) {
|
|
207
|
-
return NO;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
if ([_darkAquaColor isNotEqualTo:other->_darkAquaColor]) {
|
|
211
|
-
return NO;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
return YES;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
@end
|