react-native-macos 0.81.3 → 0.81.5
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/Core/ReactNativeVersion.js +1 -1
- package/Libraries/LinkingIOS/RCTLinkingManager.mm +119 -0
- package/Libraries/LinkingIOS/React-RCTLinking.podspec +0 -4
- package/Libraries/StyleSheet/PlatformColorValueTypes.macos.js +2 -2
- package/React/Base/RCTBridge.mm +118 -69
- package/React/Base/RCTBridgeModule.h +17 -5
- package/React/Base/RCTDefines.h +11 -0
- package/React/Base/RCTRootView.m +7 -0
- package/React/Base/RCTUIKit.h +18 -7
- package/React/Base/RCTVersion.m +1 -1
- package/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.mm +9 -0
- package/React/Base/macOS/RCTUIKit.m +65 -8
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.h +6 -0
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm +77 -1
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.h +4 -0
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +69 -3
- package/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm +306 -8
- package/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +6 -0
- package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +26 -18
- package/React/Modules/RCTUIManager.mm +1 -1
- package/React/Views/RCTCursor.m +0 -1
- package/React/Views/RCTView.m +1 -2
- package/React/Views/ScrollView/RCTScrollView.m +25 -0
- package/React/Views/UIView+React.m +1 -1
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +2 -2
- package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.h +10 -0
- package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.mm +72 -6
- package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/PlatformColorParser.mm +18 -0
- package/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/RCTPlatformColorUtils.mm +144 -3
- package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.h +2 -2
- package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm +3 -3
- package/local-cli/generate-macos.js +0 -3
- package/local-cli/generator-common/index.js +5 -5
- package/local-cli/generator-macos/index.js +7 -22
- package/package.json +2 -2
- package/Libraries/LinkingIOS/macos/RCTLinkingManager.mm +0 -123
|
@@ -20,6 +20,33 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
20
20
|
|
|
21
21
|
namespace facebook::react {
|
|
22
22
|
|
|
23
|
+
#if TARGET_OS_OSX // [macOS
|
|
24
|
+
RCTPlatformColor *_Nullable UIColorFromColorWithSystemEffect(
|
|
25
|
+
RCTUIColor *baseColor,
|
|
26
|
+
const std::string &systemEffectString)
|
|
27
|
+
{
|
|
28
|
+
if (baseColor == nil) {
|
|
29
|
+
return nil;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
NSColor *colorWithEffect = baseColor;
|
|
33
|
+
if (!systemEffectString.empty()) {
|
|
34
|
+
if (systemEffectString == "none") {
|
|
35
|
+
colorWithEffect = [baseColor colorWithSystemEffect:NSColorSystemEffectNone];
|
|
36
|
+
} else if (systemEffectString == "pressed") {
|
|
37
|
+
colorWithEffect = [baseColor colorWithSystemEffect:NSColorSystemEffectPressed];
|
|
38
|
+
} else if (systemEffectString == "deepPressed") {
|
|
39
|
+
colorWithEffect = [baseColor colorWithSystemEffect:NSColorSystemEffectDeepPressed];
|
|
40
|
+
} else if (systemEffectString == "disabled") {
|
|
41
|
+
colorWithEffect = [baseColor colorWithSystemEffect:NSColorSystemEffectDisabled];
|
|
42
|
+
} else if (systemEffectString == "rollover") {
|
|
43
|
+
colorWithEffect = [baseColor colorWithSystemEffect:NSColorSystemEffectRollover];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return colorWithEffect;
|
|
47
|
+
}
|
|
48
|
+
#endif // macOS]
|
|
49
|
+
|
|
23
50
|
namespace {
|
|
24
51
|
|
|
25
52
|
bool UIColorIsP3ColorSpace(const std::shared_ptr<void> &uiColor)
|
|
@@ -104,7 +131,6 @@ RCTUIColor *_Nullable UIColorFromDynamicColor(const facebook::react::DynamicColo
|
|
|
104
131
|
} else {
|
|
105
132
|
return nil;
|
|
106
133
|
}
|
|
107
|
-
|
|
108
134
|
return nil;
|
|
109
135
|
}
|
|
110
136
|
|
|
@@ -120,7 +146,11 @@ int32_t ColorFromColorComponents(const facebook::react::ColorComponents &compone
|
|
|
120
146
|
int32_t ColorFromUIColor(RCTUIColor *color) // [macOS]
|
|
121
147
|
{
|
|
122
148
|
CGFloat rgba[4];
|
|
149
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
123
150
|
[color getRed:&rgba[0] green:&rgba[1] blue:&rgba[2] alpha:&rgba[3]];
|
|
151
|
+
#else // [macOS
|
|
152
|
+
[[color colorUsingColorSpace:[NSColorSpace genericRGBColorSpace]] getRed:&rgba[0] green:&rgba[1] blue:&rgba[2] alpha: &rgba[3]];
|
|
153
|
+
#endif // macOS]
|
|
124
154
|
return ColorFromColorComponents({(float)rgba[0], (float)rgba[1], (float)rgba[2], (float)rgba[3]});
|
|
125
155
|
}
|
|
126
156
|
|
|
@@ -137,6 +167,21 @@ int32_t ColorFromUIColorForSpecificTraitCollection(
|
|
|
137
167
|
|
|
138
168
|
return 0;
|
|
139
169
|
}
|
|
170
|
+
#else // [macOS
|
|
171
|
+
int32_t ColorFromUIColorForSpecificAppearance(
|
|
172
|
+
const std::shared_ptr<void> &uiColor,
|
|
173
|
+
NSAppearance *appearance)
|
|
174
|
+
{
|
|
175
|
+
RCTPlatformColor *color = (RCTPlatformColor *)unwrapManagedObject(uiColor);
|
|
176
|
+
if (color) {
|
|
177
|
+
__block int32_t resolvedColorInt = 0;
|
|
178
|
+
[appearance performAsCurrentDrawingAppearance:^{
|
|
179
|
+
resolvedColorInt = ColorFromUIColor(color);
|
|
180
|
+
}];
|
|
181
|
+
return resolvedColorInt;
|
|
182
|
+
}
|
|
183
|
+
return 0;
|
|
184
|
+
}
|
|
140
185
|
#endif // [macOS]
|
|
141
186
|
|
|
142
187
|
int32_t ColorFromUIColor(const std::shared_ptr<void> &uiColor)
|
|
@@ -144,8 +189,7 @@ int32_t ColorFromUIColor(const std::shared_ptr<void> &uiColor)
|
|
|
144
189
|
#if !TARGET_OS_OSX // [macOS]
|
|
145
190
|
return ColorFromUIColorForSpecificTraitCollection(uiColor, [UITraitCollection currentTraitCollection]);
|
|
146
191
|
#else // [macOS
|
|
147
|
-
|
|
148
|
-
return ColorFromUIColor(color);
|
|
192
|
+
return ColorFromUIColorForSpecificAppearance(uiColor, [NSApp effectiveAppearance]);
|
|
149
193
|
#endif // macOS]
|
|
150
194
|
}
|
|
151
195
|
|
|
@@ -170,9 +214,7 @@ std::size_t hashFromUIColor(const std::shared_ptr<void> &uiColor)
|
|
|
170
214
|
return 0;
|
|
171
215
|
}
|
|
172
216
|
|
|
173
|
-
#if TARGET_OS_OSX // [macOS]
|
|
174
|
-
return ColorFromUIColor(uiColor);
|
|
175
|
-
#else // [macOS
|
|
217
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
176
218
|
static UITraitCollection *darkModeTraitCollection =
|
|
177
219
|
[UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleDark];
|
|
178
220
|
auto darkColor = ColorFromUIColorForSpecificTraitCollection(uiColor, darkModeTraitCollection);
|
|
@@ -202,6 +244,15 @@ std::size_t hashFromUIColor(const std::shared_ptr<void> &uiColor)
|
|
|
202
244
|
darkAccessibilityContrastColor,
|
|
203
245
|
lightAccessibilityContrastColor,
|
|
204
246
|
UIColorIsP3ColorSpace(uiColor));
|
|
247
|
+
#else // [macOS
|
|
248
|
+
// Hash both light and dark appearance colors to properly distinguish
|
|
249
|
+
// dynamic colors that change with appearance.
|
|
250
|
+
auto darkColor = ColorFromUIColorForSpecificAppearance(
|
|
251
|
+
uiColor, [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]);
|
|
252
|
+
auto lightColor = ColorFromUIColorForSpecificAppearance(
|
|
253
|
+
uiColor, [NSAppearance appearanceNamed:NSAppearanceNameAqua]);
|
|
254
|
+
|
|
255
|
+
return facebook::react::hash_combine(darkColor, lightColor);
|
|
205
256
|
#endif // macOS]
|
|
206
257
|
}
|
|
207
258
|
|
|
@@ -224,6 +275,21 @@ Color::Color(const DynamicColor &dynamicColor)
|
|
|
224
275
|
0);
|
|
225
276
|
}
|
|
226
277
|
|
|
278
|
+
#if TARGET_OS_OSX // [macOS
|
|
279
|
+
Color::Color(const ColorWithSystemEffect &colorWithSystemEffect)
|
|
280
|
+
{
|
|
281
|
+
RCTUIColor *baseColor = UIColorFromInt32(colorWithSystemEffect.color);
|
|
282
|
+
RCTUIColor *colorWithEffect =
|
|
283
|
+
UIColorFromColorWithSystemEffect(baseColor, colorWithSystemEffect.effect);
|
|
284
|
+
if (colorWithEffect != nil) {
|
|
285
|
+
uiColor_ = wrapManagedObject(colorWithEffect);
|
|
286
|
+
}
|
|
287
|
+
uiColorHashValue_ = facebook::react::hash_combine(
|
|
288
|
+
colorWithSystemEffect.color,
|
|
289
|
+
std::hash<std::string>{}(colorWithSystemEffect.effect));
|
|
290
|
+
}
|
|
291
|
+
#endif // macOS]
|
|
292
|
+
|
|
227
293
|
Color::Color(const ColorComponents &components)
|
|
228
294
|
{
|
|
229
295
|
uiColor_ = wrapManagedObject(UIColorFromComponentsColor(components));
|
|
@@ -62,6 +62,24 @@ SharedColor parsePlatformColor(const ContextContainer &contextContainer, int32_t
|
|
|
62
62
|
items.at("dynamic").hasType<std::unordered_map<std::string, RawValue>>()) {
|
|
63
63
|
auto dynamicItems = (std::unordered_map<std::string, RawValue>)items.at("dynamic");
|
|
64
64
|
return RCTPlatformColorComponentsFromDynamicItems(contextContainer, surfaceId, dynamicItems);
|
|
65
|
+
#if TARGET_OS_OSX // [macOS
|
|
66
|
+
} else if (
|
|
67
|
+
items.find("colorWithSystemEffect") != items.end() &&
|
|
68
|
+
items.at("colorWithSystemEffect").hasType<std::unordered_map<std::string, RawValue>>()) {
|
|
69
|
+
auto colorWithSystemEffectItems =
|
|
70
|
+
(std::unordered_map<std::string, RawValue>)items.at("colorWithSystemEffect");
|
|
71
|
+
if (colorWithSystemEffectItems.find("baseColor") != colorWithSystemEffectItems.end() &&
|
|
72
|
+
colorWithSystemEffectItems.find("systemEffect") != colorWithSystemEffectItems.end() &&
|
|
73
|
+
colorWithSystemEffectItems.at("systemEffect").hasType<std::string>()) {
|
|
74
|
+
SharedColor baseColorShared{};
|
|
75
|
+
fromRawValue(contextContainer, surfaceId, colorWithSystemEffectItems.at("baseColor"), baseColorShared);
|
|
76
|
+
if (baseColorShared) {
|
|
77
|
+
std::string systemEffect = (std::string)colorWithSystemEffectItems.at("systemEffect");
|
|
78
|
+
auto baseColor = (*baseColorShared).getColor();
|
|
79
|
+
return SharedColor(Color(ColorWithSystemEffect{baseColor, systemEffect}));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
#endif // macOS]
|
|
65
83
|
}
|
|
66
84
|
}
|
|
67
85
|
|
|
@@ -13,17 +13,24 @@
|
|
|
13
13
|
#import <react/utils/ManagedObjectWrapper.h>
|
|
14
14
|
|
|
15
15
|
#include <string>
|
|
16
|
+
#include <vector> // [macOS]
|
|
16
17
|
|
|
17
18
|
NS_ASSUME_NONNULL_BEGIN
|
|
18
19
|
|
|
19
20
|
static NSString *const kColorSuffix = @"Color";
|
|
20
21
|
static NSString *const kFallbackARGBKey = @"fallback-argb";
|
|
22
|
+
#if TARGET_OS_OSX // [macOS
|
|
23
|
+
static NSString *const kFallbackKey = @"fallback";
|
|
24
|
+
static NSString *const kSelectorKey = @"selector";
|
|
25
|
+
static NSString *const kIndexKey = @"index";
|
|
26
|
+
#endif // macOS]
|
|
21
27
|
|
|
22
28
|
static NSDictionary<NSString *, NSDictionary *> *_PlatformColorSelectorsDict()
|
|
23
29
|
{
|
|
24
30
|
static NSDictionary<NSString *, NSDictionary *> *dict;
|
|
25
31
|
static dispatch_once_t once_token;
|
|
26
32
|
dispatch_once(&once_token, ^(void) {
|
|
33
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
27
34
|
dict = @{
|
|
28
35
|
// https://developer.apple.com/documentation/uikit/uicolor/ui_element_colors
|
|
29
36
|
// Label Colors
|
|
@@ -130,6 +137,105 @@ static NSDictionary<NSString *, NSDictionary *> *_PlatformColorSelectorsDict()
|
|
|
130
137
|
kFallbackARGBKey : @(0x00000000) // iOS 13.0
|
|
131
138
|
},
|
|
132
139
|
};
|
|
140
|
+
#else // [macOS
|
|
141
|
+
NSMutableDictionary<NSString *, NSDictionary *> *map = [@{
|
|
142
|
+
// https://developer.apple.com/documentation/appkit/nscolor/ui_element_colors
|
|
143
|
+
// Label Colors
|
|
144
|
+
@"labelColor": @{},
|
|
145
|
+
@"secondaryLabelColor": @{},
|
|
146
|
+
@"tertiaryLabelColor": @{},
|
|
147
|
+
@"quaternaryLabelColor": @{},
|
|
148
|
+
// Text Colors
|
|
149
|
+
@"textColor": @{},
|
|
150
|
+
@"placeholderTextColor": @{},
|
|
151
|
+
@"selectedTextColor": @{},
|
|
152
|
+
@"textBackgroundColor": @{},
|
|
153
|
+
@"selectedTextBackgroundColor": @{},
|
|
154
|
+
@"keyboardFocusIndicatorColor": @{},
|
|
155
|
+
@"unemphasizedSelectedTextColor": @{
|
|
156
|
+
kFallbackKey: @"selectedTextColor"
|
|
157
|
+
},
|
|
158
|
+
@"unemphasizedSelectedTextBackgroundColor": @{
|
|
159
|
+
kFallbackKey: @"textBackgroundColor"
|
|
160
|
+
},
|
|
161
|
+
// Content Colors
|
|
162
|
+
@"linkColor": @{},
|
|
163
|
+
@"separatorColor": @{
|
|
164
|
+
kFallbackKey: @"gridColor"
|
|
165
|
+
},
|
|
166
|
+
@"selectedContentBackgroundColor": @{
|
|
167
|
+
kFallbackKey: @"alternateSelectedControlColor"
|
|
168
|
+
},
|
|
169
|
+
@"unemphasizedSelectedContentBackgroundColor": @{
|
|
170
|
+
kFallbackKey: @"secondarySelectedControlColor"
|
|
171
|
+
},
|
|
172
|
+
// Menu Colors
|
|
173
|
+
@"selectedMenuItemTextColor": @{},
|
|
174
|
+
// Table Colors
|
|
175
|
+
@"gridColor": @{},
|
|
176
|
+
@"headerTextColor": @{},
|
|
177
|
+
@"alternatingEvenContentBackgroundColor": @{
|
|
178
|
+
kSelectorKey: @"alternatingContentBackgroundColors",
|
|
179
|
+
kIndexKey: @0,
|
|
180
|
+
kFallbackKey: @"controlAlternatingRowBackgroundColors"
|
|
181
|
+
},
|
|
182
|
+
@"alternatingOddContentBackgroundColor": @{
|
|
183
|
+
kSelectorKey: @"alternatingContentBackgroundColors",
|
|
184
|
+
kIndexKey: @1,
|
|
185
|
+
kFallbackKey: @"controlAlternatingRowBackgroundColors"
|
|
186
|
+
},
|
|
187
|
+
// Control Colors
|
|
188
|
+
@"controlAccentColor": @{
|
|
189
|
+
kFallbackKey: @"controlColor"
|
|
190
|
+
},
|
|
191
|
+
@"controlColor": @{},
|
|
192
|
+
@"controlBackgroundColor": @{},
|
|
193
|
+
@"controlTextColor": @{},
|
|
194
|
+
@"disabledControlTextColor": @{},
|
|
195
|
+
@"selectedControlColor": @{},
|
|
196
|
+
@"selectedControlTextColor": @{},
|
|
197
|
+
@"alternateSelectedControlTextColor": @{},
|
|
198
|
+
@"scrubberTexturedBackgroundColor": @{},
|
|
199
|
+
// Window Colors
|
|
200
|
+
@"windowBackgroundColor": @{},
|
|
201
|
+
@"windowFrameTextColor": @{},
|
|
202
|
+
@"underPageBackgroundColor": @{},
|
|
203
|
+
// Highlights and Shadows
|
|
204
|
+
@"findHighlightColor": @{
|
|
205
|
+
kFallbackKey: @"highlightColor"
|
|
206
|
+
},
|
|
207
|
+
@"highlightColor": @{},
|
|
208
|
+
@"shadowColor": @{},
|
|
209
|
+
// https://developer.apple.com/documentation/appkit/nscolor/standard_colors
|
|
210
|
+
// Standard Colors
|
|
211
|
+
@"systemBlueColor": @{},
|
|
212
|
+
@"systemBrownColor": @{},
|
|
213
|
+
@"systemGrayColor": @{},
|
|
214
|
+
@"systemGreenColor": @{},
|
|
215
|
+
@"systemOrangeColor": @{},
|
|
216
|
+
@"systemPinkColor": @{},
|
|
217
|
+
@"systemPurpleColor": @{},
|
|
218
|
+
@"systemRedColor": @{},
|
|
219
|
+
@"systemYellowColor": @{},
|
|
220
|
+
// Transparent Color
|
|
221
|
+
@"clearColor" : @{},
|
|
222
|
+
} mutableCopy];
|
|
223
|
+
|
|
224
|
+
NSMutableDictionary<NSString *, NSDictionary *> *aliases = [NSMutableDictionary new];
|
|
225
|
+
for (NSString *objcSelector in map) {
|
|
226
|
+
NSMutableDictionary *entry = [map[objcSelector] mutableCopy];
|
|
227
|
+
if ([entry objectForKey:kSelectorKey] == nil) {
|
|
228
|
+
entry[kSelectorKey] = objcSelector;
|
|
229
|
+
}
|
|
230
|
+
if ([objcSelector hasSuffix:kColorSuffix]) {
|
|
231
|
+
NSString *swiftSelector = [objcSelector substringToIndex:[objcSelector length] - [kColorSuffix length]];
|
|
232
|
+
aliases[swiftSelector] = entry;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
[map addEntriesFromDictionary:aliases];
|
|
236
|
+
|
|
237
|
+
dict = [map copy];
|
|
238
|
+
#endif // macOS]
|
|
133
239
|
});
|
|
134
240
|
return dict;
|
|
135
241
|
}
|
|
@@ -154,6 +260,7 @@ static RCTUIColor *_Nullable _UIColorFromSemanticString(NSString *semanticString
|
|
|
154
260
|
NSDictionary<NSString *, NSDictionary *> *platformColorSelectorsDict = _PlatformColorSelectorsDict();
|
|
155
261
|
NSDictionary<NSString *, id> *colorInfo = platformColorSelectorsDict[platformColorString];
|
|
156
262
|
if (colorInfo) {
|
|
263
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
157
264
|
SEL objcColorSelector = NSSelectorFromString([platformColorString stringByAppendingString:kColorSuffix]);
|
|
158
265
|
if (![RCTUIColor respondsToSelector:objcColorSelector]) { // [macOS]
|
|
159
266
|
NSNumber *fallbackRGB = colorInfo[kFallbackARGBKey];
|
|
@@ -169,6 +276,43 @@ static RCTUIColor *_Nullable _UIColorFromSemanticString(NSString *semanticString
|
|
|
169
276
|
return colorObject;
|
|
170
277
|
}
|
|
171
278
|
}
|
|
279
|
+
#else // [macOS
|
|
280
|
+
NSString *selectorName = colorInfo[kSelectorKey];
|
|
281
|
+
if (selectorName == nil) {
|
|
282
|
+
selectorName = [platformColorString stringByAppendingString:kColorSuffix];
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
SEL objcColorSelector = NSSelectorFromString(selectorName);
|
|
286
|
+
if (![RCTPlatformColor respondsToSelector:objcColorSelector]) {
|
|
287
|
+
NSNumber *fallbackRGB = colorInfo[kFallbackARGBKey];
|
|
288
|
+
if (fallbackRGB) {
|
|
289
|
+
return _UIColorFromHexValue(fallbackRGB);
|
|
290
|
+
}
|
|
291
|
+
NSString *fallbackColorName = colorInfo[kFallbackKey];
|
|
292
|
+
if (fallbackColorName) {
|
|
293
|
+
return _UIColorFromSemanticString(fallbackColorName);
|
|
294
|
+
}
|
|
295
|
+
} else {
|
|
296
|
+
Class colorClass = [RCTPlatformColor class];
|
|
297
|
+
IMP imp = [colorClass methodForSelector:objcColorSelector];
|
|
298
|
+
id (*getColor)(id, SEL) = ((id(*)(id, SEL))imp);
|
|
299
|
+
id colorObject = getColor(colorClass, objcColorSelector);
|
|
300
|
+
if ([colorObject isKindOfClass:[NSArray class]]) {
|
|
301
|
+
NSNumber *index = colorInfo[kIndexKey];
|
|
302
|
+
if (index != nil) {
|
|
303
|
+
NSArray *colors = colorObject;
|
|
304
|
+
NSUInteger idx = [index unsignedIntegerValue];
|
|
305
|
+
if (idx < colors.count) {
|
|
306
|
+
colorObject = colors[idx];
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
if ([colorObject isKindOfClass:[RCTPlatformColor class]]) {
|
|
312
|
+
return colorObject;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
#endif // macOS]
|
|
172
316
|
}
|
|
173
317
|
return nil;
|
|
174
318
|
}
|
|
@@ -183,9 +327,6 @@ static inline NSString *_NSStringFromCString(
|
|
|
183
327
|
static inline facebook::react::ColorComponents _ColorComponentsFromUIColor(RCTUIColor *color) // [macOS]
|
|
184
328
|
{
|
|
185
329
|
CGFloat rgba[4];
|
|
186
|
-
#if TARGET_OS_OSX // [macOS
|
|
187
|
-
color = [color colorUsingColorSpace:[NSColorSpace genericRGBColorSpace]];
|
|
188
|
-
#endif // macOS]
|
|
189
330
|
[color getRed:&rgba[0] green:&rgba[1] blue:&rgba[2] alpha:&rgba[3]];
|
|
190
331
|
return {(float)rgba[0], (float)rgba[1], (float)rgba[2], (float)rgba[3]};
|
|
191
332
|
}
|
|
@@ -59,11 +59,11 @@ using RCTTextLayoutFragmentEnumerationBlock =
|
|
|
59
59
|
frame:(CGRect)frame
|
|
60
60
|
usingBlock:(RCTTextLayoutFragmentEnumerationBlock)block;
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
// [macOS iOS
|
|
63
63
|
- (NSTextStorage *)getTextStorageForAttributedString:(facebook::react::AttributedString)attributedString
|
|
64
64
|
paragraphAttributes:(facebook::react::ParagraphAttributes)paragraphAttributes
|
|
65
65
|
size:(CGSize)size;
|
|
66
|
-
|
|
66
|
+
// macOS iOS]
|
|
67
67
|
|
|
68
68
|
@end
|
|
69
69
|
|
|
@@ -438,7 +438,7 @@ static NSLineBreakMode RCTNSLineBreakModeFromEllipsizeMode(EllipsizeMode ellipsi
|
|
|
438
438
|
return TextMeasurement{{size.width, size.height}, attachments};
|
|
439
439
|
}
|
|
440
440
|
|
|
441
|
-
|
|
441
|
+
// [macOS iOS
|
|
442
442
|
- (NSTextStorage *)getTextStorageForAttributedString:(AttributedString)attributedString
|
|
443
443
|
paragraphAttributes:(ParagraphAttributes)paragraphAttributes
|
|
444
444
|
size:(CGSize)size
|
|
@@ -447,9 +447,9 @@ static NSLineBreakMode RCTNSLineBreakModeFromEllipsizeMode(EllipsizeMode ellipsi
|
|
|
447
447
|
NSTextStorage *textStorage = [self _textStorageAndLayoutManagerWithAttributesString:nsAttributedString
|
|
448
448
|
paragraphAttributes:paragraphAttributes
|
|
449
449
|
size:size];
|
|
450
|
-
|
|
450
|
+
|
|
451
451
|
return textStorage;
|
|
452
452
|
}
|
|
453
|
-
|
|
453
|
+
// macOS iOS]
|
|
454
454
|
|
|
455
455
|
@end
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
const {
|
|
5
5
|
copyProjectTemplateAndReplace,
|
|
6
|
-
installDependencies,
|
|
7
6
|
printFinishMessage,
|
|
8
7
|
} = require('./generator-macos');
|
|
9
8
|
const fs = require('fs');
|
|
@@ -21,8 +20,6 @@ function generateMacOS (projectDir, name, options) {
|
|
|
21
20
|
fs.mkdirSync(projectDir);
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
installDependencies(options);
|
|
25
|
-
|
|
26
23
|
copyProjectTemplateAndReplace(
|
|
27
24
|
path.join(__dirname, 'generator-macos', 'templates'),
|
|
28
25
|
projectDir,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
3
|
// @noflow
|
|
4
|
-
const chalk = require('chalk');
|
|
5
4
|
const fs = require('fs');
|
|
5
|
+
const { styleText } = require('node:util');
|
|
6
6
|
const path = require('path');
|
|
7
7
|
|
|
8
8
|
// Copied from `copyAndReplace` in react-native-community/cli as it's deleted in newer versions
|
|
@@ -330,11 +330,11 @@ function alwaysOverwriteContentChangedCallback(
|
|
|
330
330
|
contentChanged
|
|
331
331
|
) {
|
|
332
332
|
if (contentChanged === 'new') {
|
|
333
|
-
console.log(`${
|
|
333
|
+
console.log(`${styleText('bold','new')} ${relativeDestPath}`);
|
|
334
334
|
return 'overwrite';
|
|
335
335
|
}
|
|
336
336
|
if (contentChanged === 'changed') {
|
|
337
|
-
console.log(`${
|
|
337
|
+
console.log(`${styleText('bold','changed')} ${relativeDestPath} ${styleText('yellow','[overwriting]')}`);
|
|
338
338
|
return 'overwrite';
|
|
339
339
|
}
|
|
340
340
|
if (contentChanged === 'identical') {
|
|
@@ -351,12 +351,12 @@ function upgradeFileContentChangedCallback(
|
|
|
351
351
|
contentChanged
|
|
352
352
|
) {
|
|
353
353
|
if (contentChanged === 'new') {
|
|
354
|
-
console.log(`${
|
|
354
|
+
console.log(`${styleText('bold','new')} ${relativeDestPath}`);
|
|
355
355
|
return 'overwrite';
|
|
356
356
|
}
|
|
357
357
|
if (contentChanged === 'changed') {
|
|
358
358
|
console.log(
|
|
359
|
-
`${
|
|
359
|
+
`${styleText('bold',relativeDestPath)} ` +
|
|
360
360
|
`has changed in the new version.\nDo you want to keep your ${relativeDestPath} or replace it with the ` +
|
|
361
361
|
'latest version?\nIf you ever made any changes ' +
|
|
362
362
|
'to this file, you\'ll probably want to keep it.\n' +
|
|
@@ -7,9 +7,7 @@ const {
|
|
|
7
7
|
copyAndReplaceAll,
|
|
8
8
|
createDir,
|
|
9
9
|
} = require('../generator-common');
|
|
10
|
-
const
|
|
11
|
-
const childProcess = require('child_process');
|
|
12
|
-
const fs = require('fs');
|
|
10
|
+
const { styleText } = require('node:util');
|
|
13
11
|
const path = require('path');
|
|
14
12
|
|
|
15
13
|
const macOSDir = 'macos';
|
|
@@ -102,34 +100,21 @@ function schemePath(basename, platform) {
|
|
|
102
100
|
return path.join(schemesPath(basename), projectName(basename, platform) + '.xcscheme');
|
|
103
101
|
}
|
|
104
102
|
|
|
105
|
-
/**
|
|
106
|
-
* @param {{ verbose?: boolean }=} options
|
|
107
|
-
*/
|
|
108
|
-
function installDependencies(options) {
|
|
109
|
-
const cwd = process.cwd();
|
|
110
|
-
|
|
111
|
-
// Install dependencies using correct package manager
|
|
112
|
-
const isYarn = fs.existsSync(path.join(cwd, 'yarn.lock'));
|
|
113
|
-
|
|
114
|
-
/** @type {{ stdio?: 'inherit' }} */
|
|
115
|
-
const execOptions = options && options.verbose ? { stdio: 'inherit' } : {};
|
|
116
|
-
childProcess.execSync(isYarn ? 'yarn' : 'npm i', execOptions);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
103
|
/**
|
|
120
104
|
* @param {string} newProjectName
|
|
121
105
|
*/
|
|
122
106
|
function printFinishMessage(newProjectName) {
|
|
123
107
|
console.log(`
|
|
124
|
-
${
|
|
125
|
-
• pod install --project-directory=macos
|
|
126
|
-
• npx react-native run-macos
|
|
127
|
-
|
|
108
|
+
${styleText('blue', `Run instructions for ${styleText('bold', 'macOS')}`)}:
|
|
109
|
+
• ${styleText('cyan', 'pod install --project-directory=macos')}
|
|
110
|
+
• ${styleText('cyan', 'npx react-native run-macos')}
|
|
111
|
+
|
|
112
|
+
To start the Metro bundler separately:
|
|
113
|
+
• ${styleText('cyan', 'npx react-native start')}
|
|
128
114
|
`);
|
|
129
115
|
}
|
|
130
116
|
|
|
131
117
|
module.exports = {
|
|
132
118
|
copyProjectTemplateAndReplace,
|
|
133
|
-
installDependencies,
|
|
134
119
|
printFinishMessage,
|
|
135
120
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-macos",
|
|
3
|
-
"version": "0.81.
|
|
3
|
+
"version": "0.81.5",
|
|
4
4
|
"description": "React Native for macOS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -166,7 +166,7 @@
|
|
|
166
166
|
},
|
|
167
167
|
"dependencies": {
|
|
168
168
|
"@jest/create-cache-key-function": "^29.7.0",
|
|
169
|
-
"@react-native-macos/virtualized-lists": "0.81.
|
|
169
|
+
"@react-native-macos/virtualized-lists": "0.81.5",
|
|
170
170
|
"@react-native/assets-registry": "0.81.6",
|
|
171
171
|
"@react-native/codegen": "0.81.6",
|
|
172
172
|
"@react-native/community-cli-plugin": "0.81.6",
|
|
@@ -1,123 +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
|
-
// [macOS]
|
|
9
|
-
|
|
10
|
-
#import "RCTLinkingManager.h"
|
|
11
|
-
|
|
12
|
-
#import <FBReactNativeSpec/FBReactNativeSpec.h>
|
|
13
|
-
|
|
14
|
-
#import <React/RCTBridge.h>
|
|
15
|
-
#import <React/RCTEventDispatcher.h>
|
|
16
|
-
#import <React/RCTUtils.h>
|
|
17
|
-
|
|
18
|
-
#import "RCTLinkingPlugins.h"
|
|
19
|
-
|
|
20
|
-
NSString *const RCTOpenURLNotification = @"RCTOpenURLNotification";
|
|
21
|
-
|
|
22
|
-
static NSString *initialURL = nil;
|
|
23
|
-
static BOOL moduleInitalized = NO;
|
|
24
|
-
static BOOL alwaysForegroundLastWindow = YES;
|
|
25
|
-
|
|
26
|
-
static void postNotificationWithURL(NSString *url, id sender)
|
|
27
|
-
{
|
|
28
|
-
NSDictionary<NSString *, id> *payload = @{@"url": url};
|
|
29
|
-
[[NSNotificationCenter defaultCenter] postNotificationName:RCTOpenURLNotification
|
|
30
|
-
object:sender
|
|
31
|
-
userInfo:payload];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@implementation RCTLinkingManager
|
|
35
|
-
|
|
36
|
-
RCT_EXPORT_MODULE()
|
|
37
|
-
|
|
38
|
-
- (dispatch_queue_t)methodQueue
|
|
39
|
-
{
|
|
40
|
-
return dispatch_get_main_queue();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
- (void)startObserving
|
|
44
|
-
{
|
|
45
|
-
moduleInitalized = YES;
|
|
46
|
-
|
|
47
|
-
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
48
|
-
selector:@selector(handleOpenURLNotification:)
|
|
49
|
-
name:RCTOpenURLNotification
|
|
50
|
-
object:nil];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
- (void)stopObserving
|
|
54
|
-
{
|
|
55
|
-
moduleInitalized = NO;
|
|
56
|
-
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
- (NSArray<NSString *> *)supportedEvents
|
|
60
|
-
{
|
|
61
|
-
return @[@"url"];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
+ (void)setAlwaysForegroundLastWindow:(BOOL)alwaysForeground
|
|
65
|
-
{
|
|
66
|
-
alwaysForegroundLastWindow = alwaysForeground;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
+ (void)getUrlEventHandler:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
|
|
70
|
-
{
|
|
71
|
-
// extract url value from the event
|
|
72
|
-
NSString* url = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
|
|
73
|
-
|
|
74
|
-
// If the application was launched via URL, this handler will be called before
|
|
75
|
-
// the module is initialized by the bridge. Store the initial URL, becase we are not listening to the notification yet.
|
|
76
|
-
if (!moduleInitalized && initialURL == nil) {
|
|
77
|
-
initialURL = url;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
postNotificationWithURL(url, self);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
- (void)handleOpenURLNotification:(NSNotification *)notification
|
|
84
|
-
{
|
|
85
|
-
// Activate app, because [NSApp mainWindow] returns nil when the app is hidden and another app is maximized
|
|
86
|
-
[NSApp activateIgnoringOtherApps:YES];
|
|
87
|
-
// foreground top level window
|
|
88
|
-
if (alwaysForegroundLastWindow) {
|
|
89
|
-
NSWindow *lastWindow = [[NSApp windows] lastObject];
|
|
90
|
-
[lastWindow makeKeyAndOrderFront:nil];
|
|
91
|
-
}
|
|
92
|
-
[self sendEventWithName:@"url" body:notification.userInfo];
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
RCT_EXPORT_METHOD(openURL:(NSURL *)URL
|
|
96
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
97
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
98
|
-
{
|
|
99
|
-
BOOL result = [[NSWorkspace sharedWorkspace] openURL:URL];
|
|
100
|
-
if (result) {
|
|
101
|
-
resolve(@YES);
|
|
102
|
-
} else {
|
|
103
|
-
reject(RCTErrorUnspecified, [NSString stringWithFormat:@"Unable to open URL: %@", URL], nil);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
RCT_EXPORT_METHOD(canOpenURL:(NSURL *)URL
|
|
108
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
109
|
-
reject:(__unused RCTPromiseRejectBlock)reject)
|
|
110
|
-
{
|
|
111
|
-
resolve(@YES);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
RCT_EXPORT_METHOD(getInitialURL:(RCTPromiseResolveBlock)resolve
|
|
115
|
-
reject:(__unused RCTPromiseRejectBlock)reject)
|
|
116
|
-
{
|
|
117
|
-
resolve(RCTNullIfNil(initialURL));
|
|
118
|
-
}
|
|
119
|
-
@end
|
|
120
|
-
|
|
121
|
-
Class RCTLinkingManagerCls(void) {
|
|
122
|
-
return RCTLinkingManager.class;
|
|
123
|
-
}
|