react-native-windows 0.78.3 → 0.78.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/Modal/Modal.windows.js +4 -1
- package/Microsoft.ReactNative/Fabric/AbiPortalShadowNode.cpp +97 -0
- package/Microsoft.ReactNative/Fabric/AbiPortalShadowNode.h +53 -0
- package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.h +160 -17
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +182 -14
- package/Microsoft.ReactNative/Fabric/Composition/PortalComponentView.cpp +12 -0
- package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp +2 -1
- package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +0 -1
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +16 -14
- package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +10 -1
- package/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/Shared/Networking/WinRTWebSocketResource.cpp +82 -96
- package/Shared/Networking/WinRTWebSocketResource.h +91 -7
- package/Shared/Shared.vcxitems +3 -3
- package/Shared/Shared.vcxitems.filters +1 -1
- package/codegen/react/components/rnwcore/ActivityIndicatorView.g.h +1 -1
- package/codegen/react/components/rnwcore/AndroidDrawerLayout.g.h +1 -1
- package/codegen/react/components/rnwcore/AndroidHorizontalScrollContentView.g.h +1 -1
- package/codegen/react/components/rnwcore/AndroidProgressBar.g.h +1 -1
- package/codegen/react/components/rnwcore/AndroidSwipeRefreshLayout.g.h +1 -1
- package/codegen/react/components/rnwcore/AndroidSwitch.g.h +1 -1
- package/codegen/react/components/rnwcore/DebuggingOverlay.g.h +1 -1
- package/codegen/react/components/rnwcore/InputAccessory.g.h +1 -1
- package/codegen/react/components/rnwcore/ModalHostView.g.h +1 -1
- package/codegen/react/components/rnwcore/PullToRefreshView.g.h +1 -1
- package/codegen/react/components/rnwcore/SafeAreaView.g.h +1 -1
- package/codegen/react/components/rnwcore/Switch.g.h +1 -1
- package/codegen/react/components/rnwcore/UnimplementedNativeView.g.h +1 -1
- package/package.json +3 -3
- package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.cpp +0 -191
|
@@ -18,17 +18,101 @@ namespace Microsoft::React::Networking {
|
|
|
18
18
|
|
|
19
19
|
class WinRTWebSocketResource2 : public IWebSocketResource,
|
|
20
20
|
public std::enable_shared_from_this<WinRTWebSocketResource2> {
|
|
21
|
-
winrt::Windows::Networking::Sockets::IMessageWebSocket m_socket;
|
|
22
|
-
|
|
23
21
|
///
|
|
24
|
-
//
|
|
22
|
+
// See https://devblogs.microsoft.com/oldnewthing/20250328-00/?p=111016
|
|
25
23
|
///
|
|
26
|
-
|
|
24
|
+
struct TaskSequencer {
|
|
25
|
+
TaskSequencer() = default;
|
|
26
|
+
TaskSequencer(const TaskSequencer &) = delete;
|
|
27
|
+
void operator=(const TaskSequencer &) = delete;
|
|
28
|
+
|
|
29
|
+
private:
|
|
30
|
+
using CoroHandle = std::experimental::coroutine_handle<>;
|
|
31
|
+
|
|
32
|
+
struct Suspender {
|
|
33
|
+
CoroHandle m_handle;
|
|
34
|
+
|
|
35
|
+
bool await_ready() const noexcept {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
void await_suspend(CoroHandle h) noexcept {
|
|
40
|
+
m_handle = h;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
void await_resume() const noexcept {}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
static void *Completed() {
|
|
47
|
+
return reinterpret_cast<void *>(1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
struct ChainedTask {
|
|
51
|
+
private:
|
|
52
|
+
std::atomic<void *> m_next;
|
|
53
|
+
|
|
54
|
+
public:
|
|
55
|
+
ChainedTask(void *state = nullptr) : m_next(state) {}
|
|
56
|
+
|
|
57
|
+
void ContinueWith(CoroHandle h) {
|
|
58
|
+
if (m_next.exchange(h.address(), std::memory_order_acquire) != nullptr) {
|
|
59
|
+
h();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
void Complete() {
|
|
64
|
+
auto resumeAddress = m_next.exchange(Completed());
|
|
65
|
+
if (resumeAddress) {
|
|
66
|
+
CoroHandle::from_address(resumeAddress).resume();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
27
70
|
|
|
71
|
+
struct Completer {
|
|
72
|
+
std::shared_ptr<ChainedTask> m_chain;
|
|
73
|
+
|
|
74
|
+
~Completer() {
|
|
75
|
+
m_chain->Complete();
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
winrt::slim_mutex m_mutex;
|
|
80
|
+
std::shared_ptr<ChainedTask> m_latest = std::make_shared<ChainedTask>(Completed());
|
|
81
|
+
|
|
82
|
+
public:
|
|
83
|
+
template <typename Maker>
|
|
84
|
+
auto QueueTaskAsync(Maker &&maker) -> decltype(maker()) {
|
|
85
|
+
auto node = std::make_shared<ChainedTask>();
|
|
86
|
+
Suspender suspend;
|
|
87
|
+
|
|
88
|
+
using Async = decltype(maker());
|
|
89
|
+
auto task = [&node, &suspend, &maker]() -> Async {
|
|
90
|
+
Completer completer{node};
|
|
91
|
+
auto localMaker = std::forward<Maker>(maker);
|
|
92
|
+
auto context = winrt::apartment_context();
|
|
93
|
+
|
|
94
|
+
co_await suspend;
|
|
95
|
+
co_await context;
|
|
96
|
+
|
|
97
|
+
co_return co_await localMaker();
|
|
98
|
+
}();
|
|
99
|
+
|
|
100
|
+
{
|
|
101
|
+
winrt::slim_lock_guard guard(m_mutex);
|
|
102
|
+
m_latest.swap(node);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
node->ContinueWith(suspend.m_handle);
|
|
106
|
+
|
|
107
|
+
return task;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
winrt::Windows::Networking::Sockets::IMessageWebSocket m_socket;
|
|
28
112
|
ReadyState m_readyState;
|
|
113
|
+
TaskSequencer m_sequencer;
|
|
29
114
|
Mso::DispatchQueue m_callingQueue;
|
|
30
115
|
Mso::DispatchQueue m_backgroundQueue;
|
|
31
|
-
std::queue<std::pair<std::string, bool>> m_outgoingMessages;
|
|
32
116
|
CloseCode m_closeCode{CloseCode::Normal};
|
|
33
117
|
std::string m_closeReason;
|
|
34
118
|
|
|
@@ -52,9 +136,9 @@ class WinRTWebSocketResource2 : public IWebSocketResource,
|
|
|
52
136
|
winrt::Windows::Networking::Sockets::IWebSocketClosedEventArgs const &args);
|
|
53
137
|
|
|
54
138
|
winrt::fire_and_forget PerformConnect(winrt::Windows::Foundation::Uri &&uri) noexcept;
|
|
55
|
-
winrt::fire_and_forget
|
|
139
|
+
winrt::fire_and_forget EnqueueWrite(std::string &&message, bool isBinary) noexcept;
|
|
140
|
+
winrt::Windows::Foundation::IAsyncAction PerformWrite(std::string &&message, bool isBinary) noexcept;
|
|
56
141
|
winrt::fire_and_forget PerformClose() noexcept;
|
|
57
|
-
winrt::Windows::Foundation::IAsyncAction SendPendingMessages() noexcept;
|
|
58
142
|
|
|
59
143
|
WinRTWebSocketResource2(
|
|
60
144
|
winrt::Windows::Networking::Sockets::IMessageWebSocket &&socket,
|
package/Shared/Shared.vcxitems
CHANGED
|
@@ -168,9 +168,6 @@
|
|
|
168
168
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiComponentDescriptor.cpp">
|
|
169
169
|
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
|
|
170
170
|
</ClCompile>
|
|
171
|
-
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiViewComponentDescriptor.cpp">
|
|
172
|
-
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
|
|
173
|
-
</ClCompile>
|
|
174
171
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiEventEmitter.cpp">
|
|
175
172
|
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
|
|
176
173
|
</ClCompile>
|
|
@@ -180,6 +177,9 @@
|
|
|
180
177
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiShadowNode.cpp">
|
|
181
178
|
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
|
|
182
179
|
</ClCompile>
|
|
180
|
+
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiPortalShadowNode.cpp">
|
|
181
|
+
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
|
|
182
|
+
</ClCompile>
|
|
183
183
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiViewShadowNode.cpp">
|
|
184
184
|
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true'">true</ExcludedFromBuild>
|
|
185
185
|
</ClCompile>
|
|
@@ -239,7 +239,6 @@
|
|
|
239
239
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\PortalComponentView.cpp" />
|
|
240
240
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\RootComponentView.cpp" />
|
|
241
241
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\UnimplementedNativeViewComponentView.cpp" />
|
|
242
|
-
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiViewComponentDescriptor.cpp" />
|
|
243
242
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiViewProps.cpp" />
|
|
244
243
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\WindowsComponentDescriptorRegistry.cpp" />
|
|
245
244
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\Composition\UiaHelpers.cpp" />
|
|
@@ -293,6 +292,7 @@
|
|
|
293
292
|
<ClCompile Include="$(ReactNativeDir)\ReactCommon\react\renderer\runtimescheduler\Task.cpp" />
|
|
294
293
|
<ClCompile Include="$(ReactNativeDir)\ReactCommon\react\renderer\components\scrollview\ScrollEvent.cpp" />
|
|
295
294
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\platform\react\renderer\graphics\PlatformColorUtils.cpp" />
|
|
295
|
+
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiPortalShadowNode.cpp" />
|
|
296
296
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiViewShadowNode.cpp" />
|
|
297
297
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Fabric\AbiState.cpp" />
|
|
298
298
|
<ClCompile Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\Utils\ThemeUtils.cpp" />
|
|
@@ -165,7 +165,7 @@ void RegisterActivityIndicatorViewNativeComponent(
|
|
|
165
165
|
builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
|
|
166
166
|
const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
|
|
167
167
|
auto userData = view.UserData().as<TUserData>();
|
|
168
|
-
userData->
|
|
168
|
+
userData->UpdateState(view, newState);
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
171
|
|
|
@@ -242,7 +242,7 @@ void RegisterAndroidDrawerLayoutNativeComponent(
|
|
|
242
242
|
builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
|
|
243
243
|
const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
|
|
244
244
|
auto userData = view.UserData().as<TUserData>();
|
|
245
|
-
userData->
|
|
245
|
+
userData->UpdateState(view, newState);
|
|
246
246
|
});
|
|
247
247
|
}
|
|
248
248
|
|
|
@@ -153,7 +153,7 @@ void RegisterAndroidHorizontalScrollContentViewNativeComponent(
|
|
|
153
153
|
builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
|
|
154
154
|
const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
|
|
155
155
|
auto userData = view.UserData().as<TUserData>();
|
|
156
|
-
userData->
|
|
156
|
+
userData->UpdateState(view, newState);
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
159
|
|
|
@@ -177,7 +177,7 @@ void RegisterAndroidProgressBarNativeComponent(
|
|
|
177
177
|
builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
|
|
178
178
|
const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
|
|
179
179
|
auto userData = view.UserData().as<TUserData>();
|
|
180
|
-
userData->
|
|
180
|
+
userData->UpdateState(view, newState);
|
|
181
181
|
});
|
|
182
182
|
}
|
|
183
183
|
|
|
@@ -197,7 +197,7 @@ void RegisterAndroidSwipeRefreshLayoutNativeComponent(
|
|
|
197
197
|
builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
|
|
198
198
|
const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
|
|
199
199
|
auto userData = view.UserData().as<TUserData>();
|
|
200
|
-
userData->
|
|
200
|
+
userData->UpdateState(view, newState);
|
|
201
201
|
});
|
|
202
202
|
}
|
|
203
203
|
|
|
@@ -214,7 +214,7 @@ void RegisterAndroidSwitchNativeComponent(
|
|
|
214
214
|
builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
|
|
215
215
|
const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
|
|
216
216
|
auto userData = view.UserData().as<TUserData>();
|
|
217
|
-
userData->
|
|
217
|
+
userData->UpdateState(view, newState);
|
|
218
218
|
});
|
|
219
219
|
}
|
|
220
220
|
|
|
@@ -181,7 +181,7 @@ void RegisterDebuggingOverlayNativeComponent(
|
|
|
181
181
|
builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
|
|
182
182
|
const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
|
|
183
183
|
auto userData = view.UserData().as<TUserData>();
|
|
184
|
-
userData->
|
|
184
|
+
userData->UpdateState(view, newState);
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
187
|
|
|
@@ -153,7 +153,7 @@ void RegisterInputAccessoryNativeComponent(
|
|
|
153
153
|
builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
|
|
154
154
|
const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
|
|
155
155
|
auto userData = view.UserData().as<TUserData>();
|
|
156
|
-
userData->
|
|
156
|
+
userData->UpdateState(view, newState);
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
159
|
|
|
@@ -236,7 +236,7 @@ void RegisterModalHostViewNativeComponent(
|
|
|
236
236
|
builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
|
|
237
237
|
const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
|
|
238
238
|
auto userData = view.UserData().as<TUserData>();
|
|
239
|
-
userData->
|
|
239
|
+
userData->UpdateState(view, newState);
|
|
240
240
|
});
|
|
241
241
|
}
|
|
242
242
|
|
|
@@ -193,7 +193,7 @@ void RegisterPullToRefreshViewNativeComponent(
|
|
|
193
193
|
builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
|
|
194
194
|
const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
|
|
195
195
|
auto userData = view.UserData().as<TUserData>();
|
|
196
|
-
userData->
|
|
196
|
+
userData->UpdateState(view, newState);
|
|
197
197
|
});
|
|
198
198
|
}
|
|
199
199
|
|
|
@@ -150,7 +150,7 @@ void RegisterSafeAreaViewNativeComponent(
|
|
|
150
150
|
builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
|
|
151
151
|
const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
|
|
152
152
|
auto userData = view.UserData().as<TUserData>();
|
|
153
|
-
userData->
|
|
153
|
+
userData->UpdateState(view, newState);
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
156
|
|
|
@@ -210,7 +210,7 @@ void RegisterSwitchNativeComponent(
|
|
|
210
210
|
builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
|
|
211
211
|
const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
|
|
212
212
|
auto userData = view.UserData().as<TUserData>();
|
|
213
|
-
userData->
|
|
213
|
+
userData->UpdateState(view, newState);
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
216
|
|
|
@@ -153,7 +153,7 @@ void RegisterUnimplementedNativeViewNativeComponent(
|
|
|
153
153
|
builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
|
|
154
154
|
const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
|
|
155
155
|
auto userData = view.UserData().as<TUserData>();
|
|
156
|
-
userData->
|
|
156
|
+
userData->UpdateState(view, newState);
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
159
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-windows",
|
|
3
|
-
"version": "0.78.
|
|
3
|
+
"version": "0.78.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@react-native-community/cli": "^15.0.0",
|
|
27
27
|
"@react-native-community/cli-platform-android": "^15.0.0",
|
|
28
28
|
"@react-native-community/cli-platform-ios": "^15.0.0",
|
|
29
|
-
"@react-native-windows/cli": "0.78.
|
|
29
|
+
"@react-native-windows/cli": "0.78.2",
|
|
30
30
|
"@react-native/assets": "1.0.0",
|
|
31
31
|
"@react-native/assets-registry": "0.78.0",
|
|
32
32
|
"@react-native/codegen": "0.78.0",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"yargs": "^17.6.2"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@react-native-windows/codegen": "0.78.
|
|
71
|
+
"@react-native-windows/codegen": "0.78.1",
|
|
72
72
|
"@react-native/metro-config": "0.78.0-nightly-20241231-a3c8e2137",
|
|
73
73
|
"@rnw-scripts/babel-react-native-config": "0.0.0",
|
|
74
74
|
"@rnw-scripts/eslint-config": "1.2.32",
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
|
|
4
|
-
#include "pch.h"
|
|
5
|
-
|
|
6
|
-
#include "AbiViewComponentDescriptor.h"
|
|
7
|
-
|
|
8
|
-
#include <Fabric/WindowsComponentDescriptorRegistry.h>
|
|
9
|
-
#include <ReactContext.h>
|
|
10
|
-
#include <react/renderer/components/view/ViewPropsInterpolation.h>
|
|
11
|
-
#include <type_traits>
|
|
12
|
-
#include "DynamicReader.h"
|
|
13
|
-
|
|
14
|
-
namespace Microsoft::ReactNative {
|
|
15
|
-
|
|
16
|
-
AbiViewComponentDescriptor::AbiViewComponentDescriptor(facebook::react::ComponentDescriptorParameters const ¶meters)
|
|
17
|
-
: ComponentDescriptor(parameters) {
|
|
18
|
-
auto flavor = std::static_pointer_cast<std::string const>(this->flavor_);
|
|
19
|
-
m_builder = WindowsComponentDescriptorRegistry::FromProperties(
|
|
20
|
-
parameters.contextContainer->at<winrt::Microsoft::ReactNative::ReactContext>("MSRN.ReactContext")
|
|
21
|
-
.Properties())
|
|
22
|
-
->GetDescriptor(flavor);
|
|
23
|
-
|
|
24
|
-
rawPropsParser_.prepare<ConcreteProps>();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
facebook::react::ComponentHandle AbiViewComponentDescriptor::getComponentHandle() const {
|
|
28
|
-
return reinterpret_cast<facebook::react::ComponentHandle>(getComponentName());
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
facebook::react::ComponentName AbiViewComponentDescriptor::getComponentName() const {
|
|
32
|
-
return std::static_pointer_cast<std::string const>(this->flavor_)->c_str();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
facebook::react::ShadowNodeTraits AbiViewComponentDescriptor::getTraits() const {
|
|
36
|
-
auto traits = ShadowNodeT::BaseTraits();
|
|
37
|
-
if (winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(m_builder)
|
|
38
|
-
->MeasureContentHandler()) {
|
|
39
|
-
traits.set(facebook::react::ShadowNodeTraits::LeafYogaNode);
|
|
40
|
-
traits.set(facebook::react::ShadowNodeTraits::MeasurableYogaNode);
|
|
41
|
-
}
|
|
42
|
-
return traits;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
std::shared_ptr<facebook::react::ShadowNode> AbiViewComponentDescriptor::createShadowNode(
|
|
46
|
-
const facebook::react::ShadowNodeFragment &fragment,
|
|
47
|
-
facebook::react::ShadowNodeFamily::Shared const &family) const {
|
|
48
|
-
auto shadowNode = std::make_shared<ShadowNodeT>(fragment, family, getTraits());
|
|
49
|
-
|
|
50
|
-
shadowNode->Proxy(winrt::make<winrt::Microsoft::ReactNative::implementation::YogaLayoutableShadowNode>(shadowNode));
|
|
51
|
-
winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(m_builder)
|
|
52
|
-
->CreateShadowNode(shadowNode->Proxy());
|
|
53
|
-
|
|
54
|
-
adopt(*shadowNode);
|
|
55
|
-
return shadowNode;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
facebook::react::ShadowNode::Unshared AbiViewComponentDescriptor::cloneShadowNode(
|
|
59
|
-
const facebook::react::ShadowNode &sourceShadowNode,
|
|
60
|
-
const facebook::react::ShadowNodeFragment &fragment) const {
|
|
61
|
-
auto shadowNode = std::make_shared<ShadowNodeT>(sourceShadowNode, fragment);
|
|
62
|
-
|
|
63
|
-
shadowNode->Proxy(winrt::make<winrt::Microsoft::ReactNative::implementation::YogaLayoutableShadowNode>(shadowNode));
|
|
64
|
-
winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(m_builder)
|
|
65
|
-
->CloneShadowNode(shadowNode->Proxy(), static_cast<const ShadowNodeT &>(sourceShadowNode).Proxy());
|
|
66
|
-
|
|
67
|
-
adopt(*shadowNode);
|
|
68
|
-
return shadowNode;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
void AbiViewComponentDescriptor::appendChild(
|
|
72
|
-
const facebook::react::ShadowNode::Shared &parentShadowNode,
|
|
73
|
-
const facebook::react::ShadowNode::Shared &childShadowNode) const {
|
|
74
|
-
auto concreteParentShadowNode = std::static_pointer_cast<const ShadowNodeT>(parentShadowNode);
|
|
75
|
-
auto concreteNonConstParentShadowNode = std::const_pointer_cast<ShadowNodeT>(concreteParentShadowNode);
|
|
76
|
-
concreteNonConstParentShadowNode->appendChild(childShadowNode);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
facebook::react::Props::Shared AbiViewComponentDescriptor::cloneProps(
|
|
80
|
-
const facebook::react::PropsParserContext &context,
|
|
81
|
-
const facebook::react::Props::Shared &props,
|
|
82
|
-
facebook::react::RawProps rawProps) const {
|
|
83
|
-
// Optimization:
|
|
84
|
-
// Quite often nodes are constructed with default/empty props: the base
|
|
85
|
-
// `props` object is `null` (there no base because it's not cloning) and the
|
|
86
|
-
// `rawProps` is empty. In this case, we can return the default props object
|
|
87
|
-
// of a concrete type entirely bypassing parsing.
|
|
88
|
-
if (!props && rawProps.isEmpty()) {
|
|
89
|
-
return ShadowNodeT::defaultSharedProps();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if constexpr (facebook::react::RawPropsFilterable<ShadowNodeT>) {
|
|
93
|
-
ShadowNodeT::filterRawProps(rawProps);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
rawProps.parse(rawPropsParser_);
|
|
97
|
-
|
|
98
|
-
// Call old-style constructor
|
|
99
|
-
// auto shadowNodeProps = std::make_shared<ShadowNodeT::Props>(context, rawProps, props);
|
|
100
|
-
auto shadowNodeProps = std::make_shared<AbiViewProps>(
|
|
101
|
-
context, props ? static_cast<AbiViewProps const &>(*props) : *ShadowNodeT::defaultSharedProps(), rawProps);
|
|
102
|
-
auto viewProps =
|
|
103
|
-
winrt::make<winrt::Microsoft::ReactNative::implementation::ViewProps>(shadowNodeProps, false /*holdRef*/);
|
|
104
|
-
auto userProps =
|
|
105
|
-
winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(m_builder)
|
|
106
|
-
->CreateProps(viewProps, props ? static_cast<AbiViewProps const &>(*props).UserProps() : nullptr);
|
|
107
|
-
shadowNodeProps->SetUserProps(userProps, viewProps);
|
|
108
|
-
|
|
109
|
-
const auto &dynamic = static_cast<folly::dynamic>(rawProps);
|
|
110
|
-
for (const auto &pair : dynamic.items()) {
|
|
111
|
-
const auto &propName = pair.first.getString();
|
|
112
|
-
auto hash = RAW_PROPS_KEY_HASH(propName);
|
|
113
|
-
shadowNodeProps.get()->setProp(context, hash, propName.c_str(), facebook::react::RawValue(pair.second));
|
|
114
|
-
userProps.SetProp(
|
|
115
|
-
hash, winrt::to_hstring(propName), winrt::make<winrt::Microsoft::ReactNative::DynamicReader>(pair.second));
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return shadowNodeProps;
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
AbiViewComponentDescriptor::ConcreteStateData AbiViewComponentDescriptor::initialStateData(
|
|
122
|
-
const facebook::react::Props::Shared &props,
|
|
123
|
-
const facebook::react::ShadowNodeFamily::Shared & /*family*/,
|
|
124
|
-
const facebook::react::ComponentDescriptor &componentDescriptor) noexcept {
|
|
125
|
-
return {winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(
|
|
126
|
-
static_cast<const AbiViewComponentDescriptor &>(componentDescriptor).m_builder)
|
|
127
|
-
->InitialStateData(std::static_pointer_cast<AbiViewProps const>(props)->UserProps())};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
facebook::react::State::Shared AbiViewComponentDescriptor::createInitialState(
|
|
131
|
-
facebook::react::Props::Shared const &props,
|
|
132
|
-
facebook::react::ShadowNodeFamily::Shared const &family) const {
|
|
133
|
-
if (std::is_same<ConcreteStateData, facebook::react::StateData>::value) {
|
|
134
|
-
// Default case: Returning `null` for nodes that don't use `State`.
|
|
135
|
-
return nullptr;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return std::make_shared<ConcreteState>(
|
|
139
|
-
std::make_shared<ConcreteStateData const>(AbiViewComponentDescriptor::initialStateData(props, family, *this)),
|
|
140
|
-
family);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
facebook::react::State::Shared AbiViewComponentDescriptor::createState(
|
|
144
|
-
facebook::react::ShadowNodeFamily const &family,
|
|
145
|
-
facebook::react::StateData::Shared const &data) const {
|
|
146
|
-
if (std::is_same<ConcreteStateData, facebook::react::StateData>::value) {
|
|
147
|
-
// Default case: Returning `null` for nodes that don't use `State`.
|
|
148
|
-
return nullptr;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
react_native_assert(data && "Provided `data` is nullptr.");
|
|
152
|
-
|
|
153
|
-
return std::make_shared<ConcreteState const>(
|
|
154
|
-
std::static_pointer_cast<ConcreteStateData const>(data), *family.getMostRecentState());
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
facebook::react::ShadowNodeFamily::Shared AbiViewComponentDescriptor::createFamily(
|
|
158
|
-
facebook::react::ShadowNodeFamilyFragment const &fragment) const {
|
|
159
|
-
auto eventEmitter = std::make_shared<const ConcreteEventEmitter>(
|
|
160
|
-
std::make_shared<facebook::react::EventTarget>(fragment.instanceHandle, fragment.surfaceId), eventDispatcher_);
|
|
161
|
-
return std::make_shared<facebook::react::ShadowNodeFamily>(
|
|
162
|
-
fragment, std::move(eventEmitter), eventDispatcher_, *this);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/*
|
|
166
|
-
* Called immediately after `ShadowNode` is created or cloned.
|
|
167
|
-
*
|
|
168
|
-
* Override this method to pass information from custom `ComponentDescriptor`
|
|
169
|
-
* to new instance of `ShadowNode`.
|
|
170
|
-
*
|
|
171
|
-
* Example usages:
|
|
172
|
-
* - Inject image manager to `ImageShadowNode` in
|
|
173
|
-
* `ImageComponentDescriptor`.
|
|
174
|
-
* - Set `ShadowNode`'s size from state in
|
|
175
|
-
* `ModalHostViewComponentDescriptor`.
|
|
176
|
-
*/
|
|
177
|
-
void AbiViewComponentDescriptor::adopt(facebook::react::ShadowNode &shadowNode) const {
|
|
178
|
-
react_native_assert(shadowNode.getComponentHandle() == getComponentHandle());
|
|
179
|
-
|
|
180
|
-
auto &abiViewShadowNode = static_cast<AbiViewShadowNode &>(shadowNode);
|
|
181
|
-
|
|
182
|
-
abiViewShadowNode.Builder(m_builder);
|
|
183
|
-
|
|
184
|
-
if (winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(m_builder)
|
|
185
|
-
->MeasureContentHandler()) {
|
|
186
|
-
abiViewShadowNode.dirtyLayout();
|
|
187
|
-
abiViewShadowNode.enableMeasurement();
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
} // namespace Microsoft::ReactNative
|