react-native-macos 0.81.8 → 0.81.12
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/CHANGELOG.md +8 -0
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Text/TextInput/Multiline/RCTUITextView.mm +57 -1
- package/Libraries/Text/TextInput/Multiline/RCTWrappedTextView.m +26 -0
- package/Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h +2 -0
- package/Libraries/Text/TextInput/Singleline/RCTUITextField.mm +28 -4
- package/React/Base/RCTConvert.mm +2 -1
- package/React/Base/RCTUIKit.h +2 -0
- package/React/Base/RCTUtils.h +6 -0
- package/React/Base/RCTUtils.mm +1 -1
- package/React/Base/RCTVersion.m +1 -1
- package/React/Base/macOS/RCTUIKit.m +16 -0
- package/React/CoreModules/RCTDeviceInfo.mm +1 -1
- package/React/CxxBridge/RCTCxxBridge.mm +16 -7
- package/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +32 -3
- package/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm +14 -3
- package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +236 -8
- package/React/Fabric/Mounting/ComponentViews/VirtualView/RCTVirtualViewComponentView.mm +12 -0
- package/React/Fabric/Mounting/RCTMountingManager.mm +6 -1
- package/React/Views/RCTViewManager.m +4 -0
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt +1 -1
- package/ReactCommon/React-FabricComponents.podspec +19 -8
- package/ReactCommon/cxxreact/ReactNativeVersion.h +2 -2
- package/ReactCommon/react/renderer/core/ShadowNode.cpp +29 -19
- package/ReactCommon/react/renderer/core/ShadowNodeFamily.h +2 -0
- package/ReactCommon/react/renderer/uimanager/UIManager.cpp +62 -53
- package/ReactCommon/react/renderer/uimanager/tests/FabricUIManagerTest.cpp +179 -3
- package/package.json +3 -3
- package/react-native.config.js +31 -7
|
@@ -5,13 +5,189 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
// [macOS Adapted from react/react-native@923e7ddcaf4d (#52646).
|
|
9
|
+
#include <atomic>
|
|
8
10
|
#include <memory>
|
|
11
|
+
#include <thread>
|
|
9
12
|
|
|
10
13
|
#include <gtest/gtest.h>
|
|
14
|
+
#include <react/renderer/components/view/ViewShadowNode.h>
|
|
15
|
+
#include <react/renderer/core/ShadowNodeFragment.h>
|
|
16
|
+
#include <react/renderer/element/Element.h>
|
|
17
|
+
#include <react/renderer/element/testUtils.h>
|
|
11
18
|
#include <react/renderer/uimanager/UIManager.h>
|
|
12
19
|
|
|
13
|
-
|
|
20
|
+
namespace facebook::react {
|
|
14
21
|
|
|
15
|
-
|
|
16
|
-
|
|
22
|
+
class FabricUIManagerTest : public ::testing::Test {
|
|
23
|
+
public:
|
|
24
|
+
FabricUIManagerTest() {
|
|
25
|
+
contextContainer_ = std::make_shared<ContextContainer>();
|
|
26
|
+
ComponentDescriptorProviderRegistry providers{};
|
|
27
|
+
auto registry = providers.createComponentDescriptorRegistry(
|
|
28
|
+
{.eventDispatcher = EventDispatcher::Shared{},
|
|
29
|
+
.contextContainer = contextContainer_,
|
|
30
|
+
.flavor = nullptr});
|
|
31
|
+
providers.add(
|
|
32
|
+
concreteComponentDescriptorProvider<RootComponentDescriptor>());
|
|
33
|
+
providers.add(
|
|
34
|
+
concreteComponentDescriptorProvider<ViewComponentDescriptor>());
|
|
35
|
+
builder_ = std::make_unique<ComponentBuilder>(registry);
|
|
36
|
+
|
|
37
|
+
RuntimeExecutor executor =
|
|
38
|
+
[](std::function<void(jsi::Runtime&)>&& /*callback*/) {};
|
|
39
|
+
uiManager_ = std::make_unique<UIManager>(executor, contextContainer_);
|
|
40
|
+
uiManager_->setComponentDescriptorRegistry(registry);
|
|
41
|
+
|
|
42
|
+
std::shared_ptr<RootShadowNode> root;
|
|
43
|
+
// clang-format off
|
|
44
|
+
builder_->build(
|
|
45
|
+
Element<RootShadowNode>()
|
|
46
|
+
.tag(1)
|
|
47
|
+
.surfaceId(surfaceId_)
|
|
48
|
+
.reference(root)
|
|
49
|
+
.props([] {
|
|
50
|
+
auto props = std::make_shared<RootProps>();
|
|
51
|
+
props->layoutConstraints = LayoutConstraints{
|
|
52
|
+
.minimumSize = {.width = 0, .height = 0},
|
|
53
|
+
.maximumSize = {.width = 500, .height = 500}};
|
|
54
|
+
return props;
|
|
55
|
+
})
|
|
56
|
+
.children({
|
|
57
|
+
Element<ViewShadowNode>()
|
|
58
|
+
.tag(42)
|
|
59
|
+
.surfaceId(surfaceId_)
|
|
60
|
+
.props([] {
|
|
61
|
+
auto props = std::make_shared<ViewShadowNodeProps>();
|
|
62
|
+
props->nativeId = "initial";
|
|
63
|
+
props->opacity = 1.0;
|
|
64
|
+
return props;
|
|
65
|
+
})
|
|
66
|
+
}));
|
|
67
|
+
// clang-format on
|
|
68
|
+
|
|
69
|
+
auto tree = std::make_unique<ShadowTree>(
|
|
70
|
+
surfaceId_,
|
|
71
|
+
LayoutConstraints{},
|
|
72
|
+
LayoutContext{},
|
|
73
|
+
*uiManager_,
|
|
74
|
+
*contextContainer_);
|
|
75
|
+
shadowTree_ = tree.get();
|
|
76
|
+
tree->commit([&root](const RootShadowNode&) { return root; }, {true});
|
|
77
|
+
uiManager_->startSurface(
|
|
78
|
+
std::move(tree), "test", folly::dynamic::object, DisplayMode::Visible);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
void TearDown() override {
|
|
82
|
+
uiManager_->stopSurface(surfaceId_);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
protected:
|
|
86
|
+
std::shared_ptr<const ShadowNode> currentViewNode() const {
|
|
87
|
+
return shadowTree_->getCurrentRevision()
|
|
88
|
+
.rootShadowNode->getChildren()
|
|
89
|
+
.front();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const ViewProps& viewPropsInTree() const {
|
|
93
|
+
return static_cast<const ViewProps&>(*currentViewNode()->getProps());
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static const ViewProps& viewProps(const ShadowNode& node) {
|
|
97
|
+
return static_cast<const ViewProps&>(*node.getProps());
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
SurfaceId surfaceId_{0};
|
|
101
|
+
std::shared_ptr<ContextContainer> contextContainer_;
|
|
102
|
+
std::unique_ptr<ComponentBuilder> builder_;
|
|
103
|
+
std::unique_ptr<UIManager> uiManager_;
|
|
104
|
+
ShadowTree* shadowTree_{nullptr};
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
TEST_F(FabricUIManagerTest, SetNativePropsMergesWithReactRender) {
|
|
108
|
+
ASSERT_EQ(viewPropsInTree().nativeId, "initial");
|
|
109
|
+
ASSERT_FLOAT_EQ(viewPropsInTree().opacity, 1.0);
|
|
110
|
+
uiManager_->setNativeProps_DEPRECATED(
|
|
111
|
+
currentViewNode(), RawProps(folly::dynamic::object("opacity", 0.5)));
|
|
112
|
+
EXPECT_EQ(viewPropsInTree().nativeId, "initial");
|
|
113
|
+
EXPECT_FLOAT_EQ(viewPropsInTree().opacity, 0.5);
|
|
114
|
+
|
|
115
|
+
auto rendered = uiManager_->cloneNode(
|
|
116
|
+
*currentViewNode(),
|
|
117
|
+
nullptr,
|
|
118
|
+
RawProps(folly::dynamic::object("nativeID", "from-react")));
|
|
119
|
+
EXPECT_EQ(viewProps(*rendered).nativeId, "from-react");
|
|
120
|
+
EXPECT_FLOAT_EQ(viewProps(*rendered).opacity, 0.5);
|
|
17
121
|
}
|
|
122
|
+
|
|
123
|
+
TEST_F(FabricUIManagerTest, ReactRefreshesNativeOwnedKeysIncludingNull) {
|
|
124
|
+
uiManager_->setNativeProps_DEPRECATED(
|
|
125
|
+
currentViewNode(), RawProps(folly::dynamic::object("opacity", 0.5)));
|
|
126
|
+
auto refreshed = uiManager_->cloneNode(
|
|
127
|
+
*currentViewNode(),
|
|
128
|
+
nullptr,
|
|
129
|
+
RawProps(folly::dynamic::object("opacity", 0.75)));
|
|
130
|
+
EXPECT_FLOAT_EQ(viewProps(*refreshed).opacity, 0.75);
|
|
131
|
+
EXPECT_FLOAT_EQ(viewProps(*refreshed->clone({})).opacity, 0.75);
|
|
132
|
+
|
|
133
|
+
auto reset = uiManager_->cloneNode(
|
|
134
|
+
*refreshed,
|
|
135
|
+
nullptr,
|
|
136
|
+
RawProps(folly::dynamic::object("opacity", nullptr)));
|
|
137
|
+
EXPECT_FLOAT_EQ(viewProps(*reset).opacity, 1.0);
|
|
138
|
+
EXPECT_FLOAT_EQ(viewProps(*reset->clone({})).opacity, 1.0);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
TEST_F(FabricUIManagerTest, ReactOnlyKeysDoNotBecomeNativeOverrides) {
|
|
142
|
+
uiManager_->setNativeProps_DEPRECATED(
|
|
143
|
+
currentViewNode(), RawProps(folly::dynamic::object("opacity", 0.5)));
|
|
144
|
+
auto rendered = uiManager_->cloneNode(
|
|
145
|
+
*currentViewNode(),
|
|
146
|
+
nullptr,
|
|
147
|
+
RawProps(folly::dynamic::object("nativeID", "from-react")));
|
|
148
|
+
auto explicitProps = std::make_shared<ViewShadowNodeProps>();
|
|
149
|
+
explicitProps->nativeId = "explicit";
|
|
150
|
+
explicitProps->opacity = 0.9;
|
|
151
|
+
auto explicitClone = rendered->clone({.props = explicitProps});
|
|
152
|
+
EXPECT_EQ(viewProps(*explicitClone).nativeId, "explicit");
|
|
153
|
+
EXPECT_FLOAT_EQ(viewProps(*explicitClone).opacity, 0.9);
|
|
154
|
+
|
|
155
|
+
auto placeholderClone = explicitClone->clone({});
|
|
156
|
+
EXPECT_EQ(viewProps(*placeholderClone).nativeId, "explicit");
|
|
157
|
+
EXPECT_FLOAT_EQ(viewProps(*placeholderClone).opacity, 0.5);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
TEST_F(
|
|
161
|
+
FabricUIManagerTest,
|
|
162
|
+
ConcurrentReactAndPlaceholderClonesUseOwnedSnapshots) {
|
|
163
|
+
uiManager_->setNativeProps_DEPRECATED(
|
|
164
|
+
currentViewNode(), RawProps(folly::dynamic::object("opacity", 0.5)));
|
|
165
|
+
auto node = currentViewNode();
|
|
166
|
+
std::atomic<bool> start{false};
|
|
167
|
+
std::atomic<int> invalidSnapshots{0};
|
|
168
|
+
std::thread writer([&] {
|
|
169
|
+
while (!start.load()) {
|
|
170
|
+
std::this_thread::yield();
|
|
171
|
+
}
|
|
172
|
+
for (int i = 0; i < 1000; ++i) {
|
|
173
|
+
uiManager_->cloneNode(
|
|
174
|
+
*node,
|
|
175
|
+
nullptr,
|
|
176
|
+
RawProps(folly::dynamic::object("opacity", i % 2 ? 0.75 : 0.25)));
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
start.store(true);
|
|
180
|
+
for (int i = 0; i < 1000; ++i) {
|
|
181
|
+
auto clone = node->clone({});
|
|
182
|
+
auto opacity = viewProps(*clone).opacity;
|
|
183
|
+
if (opacity != 0.25 && opacity != 0.5 && opacity != 0.75) {
|
|
184
|
+
++invalidSnapshots;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
writer.join();
|
|
188
|
+
EXPECT_EQ(invalidSnapshots.load(), 0);
|
|
189
|
+
EXPECT_FLOAT_EQ(viewProps(*node->clone({})).opacity, 0.75);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
} // namespace facebook::react
|
|
193
|
+
// macOS]
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-macos",
|
|
3
|
-
"version": "0.81.
|
|
3
|
+
"version": "0.81.12",
|
|
4
4
|
"description": "React Native for macOS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "
|
|
8
|
+
"url": "https://github.com/microsoft/react-native-macos",
|
|
9
9
|
"directory": "packages/react-native"
|
|
10
10
|
},
|
|
11
11
|
"homepage": "https://reactnative.dev/",
|
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
},
|
|
188
188
|
"dependencies": {
|
|
189
189
|
"@jest/create-cache-key-function": "^29.7.0",
|
|
190
|
-
"@react-native-macos/virtualized-lists": "0.81.
|
|
190
|
+
"@react-native-macos/virtualized-lists": "0.81.12",
|
|
191
191
|
"@react-native/assets-registry": "0.81.6",
|
|
192
192
|
"@react-native/codegen": "0.81.6",
|
|
193
193
|
"@react-native/community-cli-plugin": "0.81.6",
|
package/react-native.config.js
CHANGED
|
@@ -38,7 +38,7 @@ function findCommunityPlatformPackage(
|
|
|
38
38
|
// root. This is also what `@react-native-community/cli` assumes (see
|
|
39
39
|
// https://github.com/react-native-community/cli/blob/14.x/packages/cli-tools/src/findProjectRoot.ts).
|
|
40
40
|
const main = require.resolve(spec, {paths: [startDir]});
|
|
41
|
-
// $
|
|
41
|
+
// $FlowFixMe[unsupported-syntax]
|
|
42
42
|
return require(main);
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -74,6 +74,7 @@ try {
|
|
|
74
74
|
const iosPath = require.resolve('@react-native-community/cli-platform-ios', {
|
|
75
75
|
paths: [process.cwd()],
|
|
76
76
|
});
|
|
77
|
+
// $FlowFixMe[untyped-import]
|
|
77
78
|
apple = findCommunityPlatformPackage(
|
|
78
79
|
'@react-native-community/cli-platform-apple',
|
|
79
80
|
iosPath,
|
|
@@ -86,8 +87,19 @@ try {
|
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
89
|
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
let macosCommands;
|
|
91
|
+
// Loading `runMacOS` requires `@react-native-community/cli`which is an
|
|
92
|
+
// optional peer dependency and is not installed when using Expo CLI.
|
|
93
|
+
try {
|
|
94
|
+
// $FlowFixMe[untyped-import]
|
|
95
|
+
macosCommands = require('./local-cli/runMacOS/runMacOS');
|
|
96
|
+
} catch (e) {
|
|
97
|
+
if (verbose) {
|
|
98
|
+
console.warn(
|
|
99
|
+
`Failed to load runMacOS commands, the react-native.config.js may be unusable: ${e instanceof Error ? e.message : String(e)}`,
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
91
103
|
const {
|
|
92
104
|
bundleCommand,
|
|
93
105
|
startCommand,
|
|
@@ -160,9 +172,17 @@ if (android != null) {
|
|
|
160
172
|
}
|
|
161
173
|
|
|
162
174
|
// [macOS
|
|
163
|
-
|
|
175
|
+
if (macosCommands != null) {
|
|
176
|
+
config.commands.push(...macosCommands);
|
|
177
|
+
}
|
|
164
178
|
if (apple) {
|
|
179
|
+
const {
|
|
180
|
+
REACT_NATIVE: npmPackageName,
|
|
181
|
+
} = require('./scripts/codegen/generate-artifacts-executor/constants.js');
|
|
182
|
+
const macos = {platformName: 'macos'};
|
|
183
|
+
const visionos = {platformName: 'visionos'};
|
|
165
184
|
config.platforms.macos = {
|
|
185
|
+
npmPackageName,
|
|
166
186
|
linkConfig: () => {
|
|
167
187
|
return {
|
|
168
188
|
isInstalled: (
|
|
@@ -186,9 +206,13 @@ if (apple) {
|
|
|
186
206
|
unlinkAssets: (_assets /*: mixed */, _projectConfig /*: mixed */) => {},
|
|
187
207
|
};
|
|
188
208
|
},
|
|
189
|
-
projectConfig: apple.getProjectConfig(
|
|
190
|
-
dependencyConfig: apple.
|
|
191
|
-
|
|
209
|
+
projectConfig: apple.getProjectConfig(macos),
|
|
210
|
+
dependencyConfig: apple.getDependencyConfig(macos),
|
|
211
|
+
};
|
|
212
|
+
config.platforms.visionos = {
|
|
213
|
+
npmPackageName,
|
|
214
|
+
projectConfig: apple.getProjectConfig(visionos),
|
|
215
|
+
dependencyConfig: apple.getDependencyConfig(visionos),
|
|
192
216
|
};
|
|
193
217
|
}
|
|
194
218
|
// macOS]
|