react-native-macos 0.0.0-a45ffbd53 → 0.0.0-aaa150054
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/Animated/nodes/AnimatedValue.js +0 -1
- package/Libraries/Components/Button.js +1 -1
- package/Libraries/Components/CheckBox/CheckBox.macos.js +8 -4
- package/Libraries/Components/Keyboard/Keyboard.js +2 -2
- package/Libraries/Components/Touchable/TouchableBounce.js +11 -22
- package/Libraries/Components/Touchable/TouchableHighlight.js +19 -30
- package/Libraries/Components/Touchable/TouchableOpacity.js +14 -29
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +8 -18
- package/Libraries/Components/View/ReactNativeViewAttributes.js +8 -7
- package/Libraries/Components/View/ReactNativeViewViewConfigMacOS.js +1 -2
- package/Libraries/Components/View/View.js +8 -10
- package/Libraries/Components/View/ViewAccessibility.js +0 -1
- package/Libraries/Components/View/ViewPropTypes.js +1 -7
- package/Libraries/Core/ReactNativeVersion.js +5 -1
- package/Libraries/Image/RCTImageView.mm +2 -8
- package/Libraries/LogBox/Data/LogBoxData.js +18 -18
- 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 +11 -1
- 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/Libraries/Types/RootTagTypes.js~merged +23 -0
- package/README.md +19 -43
- 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 +5 -1
- package/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.mm +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/RCTAlertController.m +8 -4
- package/React/CoreModules/RCTAppearance.mm +22 -23
- package/React/CoreModules/RCTDevLoadingView.mm +14 -9
- package/React/CxxModule/RCTCxxMethod.mm +2 -0
- package/React/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec-generated.mm +2126 -0
- package/React/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h +2682 -0
- package/React/Modules/RCTEventEmitter.h +2 -2
- package/React/Modules/RCTLayoutAnimation.m +2 -0
- package/React/Modules/RCTLayoutAnimationGroup.m +2 -0
- package/React/Views/RCTShadowView.m +2 -0
- package/React/Views/RCTSwitch.h +1 -1
- package/React/Views/RCTSwitch.m +0 -15
- package/React/Views/RCTView.h +5 -2
- package/React/Views/RCTView.m +20 -15
- package/React/Views/RCTViewManager.m +9 -15
- package/React/Views/SafeAreaView/RCTSafeAreaView.m +2 -0
- package/React-Core.podspec +0 -11
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/ReactActivity.java +7 -0
- package/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java +7 -0
- package/ReactAndroid/src/main/java/com/facebook/react/devsupport/interfaces/BundleLoadCallback.java +3 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/appearance/AppearanceModule.java +10 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +5 -1
- package/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java +0 -8
- package/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java +8 -8
- package/ReactAndroid/src/main/jni/third-party/libevent/event-config.h +339 -339
- package/ReactCommon/cxxreact/ReactNativeVersion.h +5 -1
- package/jest/preprocessor.js +7 -75
- package/local-cli/cli.js +0 -0
- package/local-cli/generator-macos/templates/macos/Podfile +2 -7
- package/package.json +10 -15
- package/scripts/react-native-xcode.sh +1 -1
- package/scripts/react_native_pods.rb +1 -1
- package/template/package.json +3 -1
- package/third-party-podspecs/RCT-Folly.podspec +1 -1
- package/CHANGELOG.json +0 -500
- package/CHANGELOG.md +0 -240
- package/Libraries/.npmignore +0 -1
- package/React/Base/macOS/RCTDynamicColor.h +0 -28
- package/React/Base/macOS/RCTDynamicColor.m +0 -219
- package/ReactAndroid/.npmignore +0 -5
- package/ReactAndroid/src/main/jni/first-party/fbjni/.gitignore +0 -2
- package/ReactCommon/hermes/inspector/tools/msggen/.gitignore +0 -3
- package/scripts/fixmacscripts.sh +0 -9
- package/scripts/postInstall.js +0 -6
|
@@ -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,13 +101,21 @@
|
|
|
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
107
|
NSString *superDescription = super.description;
|
|
105
108
|
NSRange semicolonRange = [superDescription rangeOfString:@";"];
|
|
106
109
|
NSString *replacement = [NSString stringWithFormat:@"; reactTag: %@; text: %@", self.reactTag, _textStorage.string];
|
|
107
|
-
|
|
110
|
+
// [TODO(macOS GH#774): super.description isn't guaranteed to have a semicolon in it on macOS
|
|
111
|
+
if (semicolonRange.location == NSNotFound) {
|
|
112
|
+
return [superDescription stringByAppendingString:replacement];
|
|
113
|
+
} else {
|
|
114
|
+
return [superDescription stringByReplacingCharactersInRange:semicolonRange withString:replacement];
|
|
115
|
+
}
|
|
116
|
+
// TODO(macOS GH#774)]
|
|
108
117
|
}
|
|
118
|
+
#endif // TODO(macOS GH#774)
|
|
109
119
|
|
|
110
120
|
- (void)setSelectable:(BOOL)selectable
|
|
111
121
|
{
|
|
@@ -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
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
* @flow strict
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
<<<<<<< HEAD
|
|
12
|
+
export type {RootTag} from '../ReactNative/RootTag';
|
|
13
|
+
=======
|
|
14
|
+
<<<<<<< HEAD:Libraries/Components/DatePicker/DatePickerIOS.macos.js
|
|
15
|
+
// TODO(macOS GH#774)
|
|
16
|
+
|
|
17
|
+
'use strict';
|
|
18
|
+
|
|
19
|
+
module.exports = require('../UnimplementedViews/UnimplementedView');
|
|
20
|
+
=======
|
|
21
|
+
export type {RootTag} from '../ReactNative/RootTag';
|
|
22
|
+
>>>>>>> facebook/0.66-stable:Libraries/Types/RootTagTypes.js
|
|
23
|
+
>>>>>>> facebook/0.66-stable
|
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,69 +28,44 @@ 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
|
-
You can run React Native for macOS apps on Mac devices with versions
|
|
33
|
+
You can run React Native for macOS apps on Mac devices with versions Catalina (10.15) or newer.
|
|
66
34
|
|
|
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
|
|
|
@@ -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
|
@@ -15,6 +15,10 @@ NSString* const RCTVersionPatch = @"patch";
|
|
|
15
15
|
NSString* const RCTVersionPrerelease = @"prerelease";
|
|
16
16
|
|
|
17
17
|
|
|
18
|
+
// [TODO(macOS GH#944)
|
|
19
|
+
// Note: Be careful not to override these version numbers
|
|
20
|
+
// when we merge upstream stable branches into main
|
|
21
|
+
// TODO(macOS GH#944)]
|
|
18
22
|
NSDictionary* RCTGetReactNativeVersion(void)
|
|
19
23
|
{
|
|
20
24
|
static NSDictionary* __rnVersion;
|
|
@@ -24,7 +28,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
|
|
|
24
28
|
RCTVersionMajor: @(0),
|
|
25
29
|
RCTVersionMinor: @(0),
|
|
26
30
|
RCTVersionPatch: @(0),
|
|
27
|
-
RCTVersionPrerelease: @"
|
|
31
|
+
RCTVersionPrerelease: @"aaa150054",
|
|
28
32
|
};
|
|
29
33
|
});
|
|
30
34
|
return __rnVersion;
|
|
@@ -62,7 +62,7 @@ RCT_NOT_IMPLEMENTED(-(nullable instancetype)initWithCoder : (NSCoder *)coder)
|
|
|
62
62
|
[self _updateViews];
|
|
63
63
|
|
|
64
64
|
// For backward compatibility with RCTRootView, set a color here instead of transparent (OS default).
|
|
65
|
-
self.backgroundColor = [RCTUIColor whiteColor];
|
|
65
|
+
self.backgroundColor = [RCTUIColor whiteColor]; // TODO(macOS GH#774)
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
return self;
|
|
@@ -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
|
|
@@ -32,12 +32,16 @@
|
|
|
32
32
|
|
|
33
33
|
- (void)show:(BOOL)animated completion:(void (^)(void))completion
|
|
34
34
|
{
|
|
35
|
-
[self.alertWindow makeKeyAndVisible];
|
|
36
|
-
|
|
37
35
|
// [TODO(macOS GH#774)
|
|
36
|
+
// Call self.alertWindow to ensure that it gets populated
|
|
37
|
+
UIWindow *alertWindow = self.alertWindow;
|
|
38
|
+
|
|
38
39
|
// If the window is tracked by our application then it will show the alert
|
|
39
|
-
if ([[[UIApplication sharedApplication] windows] containsObject:
|
|
40
|
-
|
|
40
|
+
if ([[[UIApplication sharedApplication] windows] containsObject:alertWindow]) {
|
|
41
|
+
// On iOS 14, makeKeyAndVisible should only be called if alertWindow is tracked by the application.
|
|
42
|
+
// Later versions of iOS appear to already do this check for us behind the scenes.
|
|
43
|
+
[alertWindow makeKeyAndVisible];
|
|
44
|
+
[alertWindow.rootViewController presentViewController:self animated:animated completion:completion];
|
|
41
45
|
} else {
|
|
42
46
|
// When using Scenes, we must present the alert from a view controller associated with a window in the Scene. A fresh window (i.e. _alertWindow) cannot show the alert.
|
|
43
47
|
[RCTPresentedViewController() presentViewController:self animated:animated completion:completion];
|
|
@@ -66,29 +66,28 @@ NSString *RCTColorSchemePreference(UITraitCollection *traitCollection)
|
|
|
66
66
|
#else // [TODO(macOS GH#774)
|
|
67
67
|
NSString *RCTColorSchemePreference(NSAppearance *appearance)
|
|
68
68
|
{
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if
|
|
81
|
-
|
|
82
|
-
return RCTAppearanceColorSchemeLight;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
appearance = appearance ?: [NSAppearance currentAppearance];
|
|
86
|
-
NSAppearanceName appearanceName = [appearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
|
|
87
|
-
return appearances[appearanceName] ?: RCTAppearanceColorSchemeLight;
|
|
69
|
+
static NSDictionary *appearances;
|
|
70
|
+
static dispatch_once_t onceToken;
|
|
71
|
+
|
|
72
|
+
dispatch_once(&onceToken, ^{
|
|
73
|
+
appearances = @{
|
|
74
|
+
NSAppearanceNameAqua: RCTAppearanceColorSchemeLight,
|
|
75
|
+
NSAppearanceNameDarkAqua: RCTAppearanceColorSchemeDark
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
if (!sAppearancePreferenceEnabled) {
|
|
80
|
+
// Return the default if the app doesn't allow different color schemes.
|
|
81
|
+
return RCTAppearanceColorSchemeLight;
|
|
88
82
|
}
|
|
89
83
|
|
|
90
|
-
|
|
91
|
-
|
|
84
|
+
if (@available(macOS 11.0, *)) {
|
|
85
|
+
appearance = appearance ?: [NSAppearance currentDrawingAppearance];
|
|
86
|
+
} else {
|
|
87
|
+
appearance = appearance ?: [NSAppearance currentAppearance];
|
|
88
|
+
}
|
|
89
|
+
NSAppearanceName appearanceName = [appearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
|
|
90
|
+
return appearances[appearanceName] ?: RCTAppearanceColorSchemeLight;
|
|
92
91
|
}
|
|
93
92
|
#endif // ]TODO(macOS GH#774)
|
|
94
93
|
|
|
@@ -165,7 +164,7 @@ RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSString *, getColorScheme)
|
|
|
165
164
|
|
|
166
165
|
- (void)startObserving
|
|
167
166
|
{
|
|
168
|
-
if (@available(
|
|
167
|
+
if (@available(iOS 13.0, *)) {
|
|
169
168
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
170
169
|
selector:@selector(appearanceChanged:)
|
|
171
170
|
name:RCTUserInterfaceStyleDidChangeNotification
|
|
@@ -175,7 +174,7 @@ RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSString *, getColorScheme)
|
|
|
175
174
|
|
|
176
175
|
- (void)stopObserving
|
|
177
176
|
{
|
|
178
|
-
if (@available(
|
|
177
|
+
if (@available(iOS 13.0, *)) {
|
|
179
178
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
180
179
|
}
|
|
181
180
|
}
|