react-native-macos 0.0.0-4c605e93a → 0.0.0-524b5ec20
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/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/TextInput/RCTBackedTextInputDelegate.h +2 -0
- package/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m +15 -3
- package/Libraries/Text/TextInput/RCTBaseTextInputView.m +9 -0
- package/README.md +18 -42
- package/React/Base/RCTBridgeModule.h +1 -1
- package/React/Base/RCTConvert.m +22 -5
- package/React/Base/RCTVersion.m +1 -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/Views/RCTView.h +2 -2
- package/React/Views/RCTView.m +2 -2
- 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;
|
|
@@ -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 =
|
|
@@ -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
|
@@ -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
|
package/React/Base/RCTVersion.m
CHANGED
|
@@ -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
|
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;
|
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;
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-macos",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-524b5ec20",
|
|
4
4
|
"bin": "./cli.js",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "React Native for macOS",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "git@github.com:microsoft/react-native-macos.git",
|
|
8
8
|
"engines": {
|
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
|