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
|
@@ -290,8 +290,11 @@ class Modal extends React.Component<Props, State> {
|
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
+
// [Windows] - apply empty rootViewStyle to AppContainer to prevent modal from always expanding to fill available space
|
|
293
294
|
const innerChildren = __DEV__ ? (
|
|
294
|
-
<AppContainer rootTag={this.context}
|
|
295
|
+
<AppContainer rootTag={this.context} rootViewStyle={{}}>
|
|
296
|
+
{this.props.children}
|
|
297
|
+
</AppContainer>
|
|
295
298
|
) : (
|
|
296
299
|
this.props.children
|
|
297
300
|
);
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#include "AbiPortalShadowNode.h"
|
|
5
|
+
|
|
6
|
+
#include <Fabric/Composition/ReactCompositionViewComponentBuilder.h>
|
|
7
|
+
#include <react/debug/react_native_assert.h>
|
|
8
|
+
#include <react/renderer/core/LayoutConstraints.h>
|
|
9
|
+
#include <react/renderer/core/LayoutContext.h>
|
|
10
|
+
#include <react/renderer/core/conversions.h>
|
|
11
|
+
|
|
12
|
+
#include <utility>
|
|
13
|
+
|
|
14
|
+
namespace Microsoft::ReactNative {
|
|
15
|
+
|
|
16
|
+
extern const char AbiPortalComponentName[] = "AbiPortal";
|
|
17
|
+
|
|
18
|
+
facebook::react::Size AbiPortalShadowNode::measureContent(
|
|
19
|
+
const facebook::react::LayoutContext &layoutContext,
|
|
20
|
+
const facebook::react::LayoutConstraints &layoutConstraints) const {
|
|
21
|
+
return {0, 0}; // The portal placeholder node shouldn't take up any space
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
void AbiPortalShadowNode::layout(facebook::react::LayoutContext layoutContext) {
|
|
25
|
+
ensureUnsealed();
|
|
26
|
+
auto layoutMetrics = getLayoutMetrics();
|
|
27
|
+
|
|
28
|
+
auto portalOwningShadowNode = ShadowNode::Unshared{};
|
|
29
|
+
|
|
30
|
+
if (getChildren().empty()) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// A Portal should only have a single child
|
|
35
|
+
react_native_assert(getChildren().size() == 1);
|
|
36
|
+
|
|
37
|
+
const auto &childNode = getChildren()[0];
|
|
38
|
+
|
|
39
|
+
auto clonedShadowNode = ShadowNode::Unshared{};
|
|
40
|
+
|
|
41
|
+
portalOwningShadowNode = cloneTree(childNode->getFamily(), [&](const ShadowNode &oldShadowNode) {
|
|
42
|
+
clonedShadowNode = oldShadowNode.clone({});
|
|
43
|
+
return clonedShadowNode;
|
|
44
|
+
});
|
|
45
|
+
auto portalShadowNode = static_cast<AbiPortalShadowNode *>(portalOwningShadowNode.get());
|
|
46
|
+
|
|
47
|
+
auto &layoutableShadowNode = dynamic_cast<LayoutableShadowNode &>(*clonedShadowNode);
|
|
48
|
+
|
|
49
|
+
auto &state = getStateData();
|
|
50
|
+
|
|
51
|
+
facebook::react::LayoutConstraints layoutConstraints;
|
|
52
|
+
layoutConstraints.layoutDirection = layoutMetrics.layoutDirection;
|
|
53
|
+
|
|
54
|
+
if (state.userdata) {
|
|
55
|
+
// If the portal component set a state of type IPortalStateData,
|
|
56
|
+
// extract constraint information from it, and use that for layout
|
|
57
|
+
if (auto portalState = state.userdata.try_as<winrt::Microsoft::ReactNative::Composition::IPortalStateData>()) {
|
|
58
|
+
auto stateConstraints = portalState.LayoutConstraints();
|
|
59
|
+
|
|
60
|
+
layoutConstraints.minimumSize = {stateConstraints.MinimumSize.Width, stateConstraints.MinimumSize.Height};
|
|
61
|
+
layoutConstraints.maximumSize = {stateConstraints.MaximumSize.Width, stateConstraints.MaximumSize.Height};
|
|
62
|
+
if (stateConstraints.LayoutDirection == winrt::Microsoft::ReactNative::LayoutDirection::LeftToRight) {
|
|
63
|
+
layoutConstraints.layoutDirection = facebook::react::LayoutDirection::LeftToRight;
|
|
64
|
+
} else if (stateConstraints.LayoutDirection == winrt::Microsoft::ReactNative::LayoutDirection::RightToLeft) {
|
|
65
|
+
layoutConstraints.layoutDirection = facebook::react::LayoutDirection::RightToLeft;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Laying out the `ShadowNode` and the subtree starting from it.
|
|
71
|
+
layoutableShadowNode.layoutTree(layoutContext, layoutConstraints);
|
|
72
|
+
|
|
73
|
+
auto childLayoutMetrics = layoutableShadowNode.getLayoutMetrics();
|
|
74
|
+
childLayoutMetrics.frame.origin = {0, 0};
|
|
75
|
+
layoutableShadowNode.setLayoutMetrics(childLayoutMetrics);
|
|
76
|
+
|
|
77
|
+
// Update the list of children to reflect the changes that we made.
|
|
78
|
+
this->children_ = static_cast<AbiPortalShadowNode *>(portalOwningShadowNode.get())->children_;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
void AbiPortalShadowNode::Builder(winrt::Microsoft::ReactNative::IReactViewComponentBuilder builder) noexcept {
|
|
82
|
+
m_builder = builder;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
winrt::Microsoft::ReactNative::IReactViewComponentBuilder AbiPortalShadowNode::Builder() const noexcept {
|
|
86
|
+
return m_builder;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
void AbiPortalShadowNode::Proxy(winrt::Microsoft::ReactNative::ShadowNode proxy) noexcept {
|
|
90
|
+
m_proxy = proxy;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
winrt::Microsoft::ReactNative::ShadowNode AbiPortalShadowNode::Proxy() const noexcept {
|
|
94
|
+
return m_proxy;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
} // namespace Microsoft::ReactNative
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#pragma once
|
|
5
|
+
|
|
6
|
+
#include <react/components/rnwcore/EventEmitters.h>
|
|
7
|
+
#include <unordered_map>
|
|
8
|
+
#include "AbiShadowNode.h"
|
|
9
|
+
#include "AbiState.h"
|
|
10
|
+
#include "AbiViewProps.h"
|
|
11
|
+
|
|
12
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
13
|
+
#include <react/renderer/core/LayoutContext.h>
|
|
14
|
+
|
|
15
|
+
namespace Microsoft::ReactNative {
|
|
16
|
+
|
|
17
|
+
extern const char AbiPortalComponentName[];
|
|
18
|
+
|
|
19
|
+
class AbiPortalShadowNode final : public facebook::react::ConcreteViewShadowNode<
|
|
20
|
+
AbiPortalComponentName,
|
|
21
|
+
AbiViewProps,
|
|
22
|
+
facebook::react::ViewEventEmitter,
|
|
23
|
+
Microsoft::ReactNative::AbiStateData> {
|
|
24
|
+
public:
|
|
25
|
+
using ConcreteViewShadowNode::ConcreteViewShadowNode;
|
|
26
|
+
|
|
27
|
+
static facebook::react::ShadowNodeTraits BaseTraits() {
|
|
28
|
+
auto traits = facebook::react::ShadowNode::BaseTraits();
|
|
29
|
+
traits.set(facebook::react::ShadowNodeTraits::Trait::FormsStackingContext);
|
|
30
|
+
traits.set(facebook::react::ShadowNodeTraits::Trait::FormsView);
|
|
31
|
+
traits.set(facebook::react::ShadowNodeTraits::Trait::RootNodeKind);
|
|
32
|
+
traits.set(facebook::react::ShadowNodeTraits::Trait::LeafYogaNode);
|
|
33
|
+
traits.set(facebook::react::ShadowNodeTraits::Trait::MeasurableYogaNode);
|
|
34
|
+
return traits;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
facebook::react::Size measureContent(
|
|
38
|
+
const facebook::react::LayoutContext &layoutContext,
|
|
39
|
+
const facebook::react::LayoutConstraints &layoutConstraints) const override;
|
|
40
|
+
void layout(facebook::react::LayoutContext layoutContext) override;
|
|
41
|
+
|
|
42
|
+
void OnClone(const facebook::react::ShadowNode &sourceShadowNode) noexcept;
|
|
43
|
+
void Builder(winrt::Microsoft::ReactNative::IReactViewComponentBuilder builder) noexcept;
|
|
44
|
+
winrt::Microsoft::ReactNative::IReactViewComponentBuilder Builder() const noexcept;
|
|
45
|
+
void Proxy(winrt::Microsoft::ReactNative::ShadowNode handle) noexcept;
|
|
46
|
+
winrt::Microsoft::ReactNative::ShadowNode Proxy() const noexcept;
|
|
47
|
+
|
|
48
|
+
private:
|
|
49
|
+
winrt::Microsoft::ReactNative::ShadowNode m_proxy{nullptr};
|
|
50
|
+
winrt::Microsoft::ReactNative::IReactViewComponentBuilder m_builder{nullptr};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
} // namespace Microsoft::ReactNative
|
|
@@ -3,16 +3,22 @@
|
|
|
3
3
|
|
|
4
4
|
#pragma once
|
|
5
5
|
|
|
6
|
+
#include <Fabric/Composition/ReactCompositionViewComponentBuilder.h>
|
|
7
|
+
#include <Fabric/WindowsComponentDescriptorRegistry.h>
|
|
8
|
+
#include <ReactContext.h>
|
|
6
9
|
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
7
10
|
#include <react/renderer/core/ComponentDescriptor.h>
|
|
11
|
+
#include "AbiPortalShadowNode.h"
|
|
8
12
|
#include "AbiViewProps.h"
|
|
9
13
|
#include "AbiViewShadowNode.h"
|
|
14
|
+
#include "DynamicReader.h"
|
|
10
15
|
#include "winrt/Microsoft.ReactNative.h"
|
|
11
16
|
|
|
12
17
|
namespace Microsoft::ReactNative {
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
template <typename ShadowNodeT>
|
|
20
|
+
class ConcreteAbiViewComponentDescriptor : public facebook::react::ComponentDescriptor {
|
|
21
|
+
protected:
|
|
16
22
|
using SharedShadowNodeT = std::shared_ptr<const ShadowNodeT>;
|
|
17
23
|
|
|
18
24
|
public:
|
|
@@ -24,34 +30,142 @@ class AbiViewComponentDescriptor : public facebook::react::ComponentDescriptor {
|
|
|
24
30
|
using ConcreteState = typename ShadowNodeT::ConcreteState;
|
|
25
31
|
using ConcreteStateData = typename ShadowNodeT::ConcreteState::Data;
|
|
26
32
|
|
|
27
|
-
|
|
33
|
+
ConcreteAbiViewComponentDescriptor(facebook::react::ComponentDescriptorParameters const ¶meters)
|
|
34
|
+
: ComponentDescriptor(parameters) {
|
|
35
|
+
auto flavor = std::static_pointer_cast<std::string const>(this->flavor_);
|
|
36
|
+
m_builder = WindowsComponentDescriptorRegistry::FromProperties(
|
|
37
|
+
parameters.contextContainer->at<winrt::Microsoft::ReactNative::ReactContext>("MSRN.ReactContext")
|
|
38
|
+
.Properties())
|
|
39
|
+
->GetDescriptor(flavor);
|
|
40
|
+
|
|
41
|
+
rawPropsParser_.prepare<ConcreteProps>();
|
|
42
|
+
}
|
|
43
|
+
facebook::react::ComponentHandle getComponentHandle() const override {
|
|
44
|
+
return reinterpret_cast<facebook::react::ComponentHandle>(getComponentName());
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
facebook::react::ComponentName getComponentName() const override {
|
|
48
|
+
return std::static_pointer_cast<std::string const>(this->flavor_)->c_str();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
facebook::react::ShadowNodeTraits getTraits() const override {
|
|
52
|
+
auto traits = ShadowNodeT::BaseTraits();
|
|
53
|
+
if (winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(m_builder)
|
|
54
|
+
->MeasureContentHandler()) {
|
|
55
|
+
traits.set(facebook::react::ShadowNodeTraits::LeafYogaNode);
|
|
56
|
+
traits.set(facebook::react::ShadowNodeTraits::MeasurableYogaNode);
|
|
57
|
+
}
|
|
58
|
+
return traits;
|
|
59
|
+
}
|
|
28
60
|
|
|
29
|
-
facebook::react::ComponentHandle getComponentHandle() const override;
|
|
30
|
-
facebook::react::ComponentName getComponentName() const override;
|
|
31
|
-
facebook::react::ShadowNodeTraits getTraits() const override;
|
|
32
61
|
std::shared_ptr<facebook::react::ShadowNode> createShadowNode(
|
|
33
62
|
const facebook::react::ShadowNodeFragment &fragment,
|
|
34
|
-
facebook::react::ShadowNodeFamily::Shared const &family) const override
|
|
63
|
+
facebook::react::ShadowNodeFamily::Shared const &family) const override {
|
|
64
|
+
auto shadowNode = std::make_shared<ShadowNodeT>(fragment, family, getTraits());
|
|
65
|
+
shadowNode->Proxy(winrt::make<winrt::Microsoft::ReactNative::implementation::YogaLayoutableShadowNode>(shadowNode));
|
|
66
|
+
winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(m_builder)
|
|
67
|
+
->CreateShadowNode(shadowNode->Proxy());
|
|
68
|
+
|
|
69
|
+
adopt(*shadowNode);
|
|
70
|
+
return shadowNode;
|
|
71
|
+
}
|
|
72
|
+
|
|
35
73
|
facebook::react::ShadowNode::Unshared cloneShadowNode(
|
|
36
74
|
const facebook::react::ShadowNode &sourceShadowNode,
|
|
37
|
-
const facebook::react::ShadowNodeFragment &fragment) const override
|
|
75
|
+
const facebook::react::ShadowNodeFragment &fragment) const override {
|
|
76
|
+
auto shadowNode = std::make_shared<ShadowNodeT>(sourceShadowNode, fragment);
|
|
77
|
+
shadowNode->Proxy(winrt::make<winrt::Microsoft::ReactNative::implementation::YogaLayoutableShadowNode>(shadowNode));
|
|
78
|
+
winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(m_builder)
|
|
79
|
+
->CloneShadowNode(shadowNode->Proxy(), static_cast<const ShadowNodeT &>(sourceShadowNode).Proxy());
|
|
80
|
+
|
|
81
|
+
adopt(*shadowNode);
|
|
82
|
+
return shadowNode;
|
|
83
|
+
}
|
|
38
84
|
|
|
39
85
|
void appendChild(
|
|
40
86
|
const facebook::react::ShadowNode::Shared &parentShadowNode,
|
|
41
|
-
const facebook::react::ShadowNode::Shared &childShadowNode) const override
|
|
87
|
+
const facebook::react::ShadowNode::Shared &childShadowNode) const override {
|
|
88
|
+
auto concreteParentShadowNode = std::static_pointer_cast<const ShadowNodeT>(parentShadowNode);
|
|
89
|
+
auto concreteNonConstParentShadowNode = std::const_pointer_cast<ShadowNodeT>(concreteParentShadowNode);
|
|
90
|
+
concreteNonConstParentShadowNode->appendChild(childShadowNode);
|
|
91
|
+
}
|
|
92
|
+
|
|
42
93
|
virtual facebook::react::Props::Shared cloneProps(
|
|
43
94
|
const facebook::react::PropsParserContext &context,
|
|
44
95
|
const facebook::react::Props::Shared &props,
|
|
45
|
-
facebook::react::RawProps rawProps) const override
|
|
96
|
+
facebook::react::RawProps rawProps) const override {
|
|
97
|
+
// Optimization:
|
|
98
|
+
// Quite often nodes are constructed with default/empty props: the base
|
|
99
|
+
// `props` object is `null` (there no base because it's not cloning) and the
|
|
100
|
+
// `rawProps` is empty. In this case, we can return the default props object
|
|
101
|
+
// of a concrete type entirely bypassing parsing.
|
|
102
|
+
if (!props && rawProps.isEmpty()) {
|
|
103
|
+
return ShadowNodeT::defaultSharedProps();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if constexpr (facebook::react::RawPropsFilterable<ShadowNodeT>) {
|
|
107
|
+
ShadowNodeT::filterRawProps(rawProps);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
rawProps.parse(rawPropsParser_);
|
|
111
|
+
|
|
112
|
+
// Call old-style constructor
|
|
113
|
+
// auto shadowNodeProps = std::make_shared<ShadowNodeT::Props>(context, rawProps, props);
|
|
114
|
+
auto shadowNodeProps = std::make_shared<AbiViewProps>(
|
|
115
|
+
context, props ? static_cast<AbiViewProps const &>(*props) : *ShadowNodeT::defaultSharedProps(), rawProps);
|
|
116
|
+
auto viewProps =
|
|
117
|
+
winrt::make<winrt::Microsoft::ReactNative::implementation::ViewProps>(shadowNodeProps, false /*holdRef*/);
|
|
118
|
+
auto userProps =
|
|
119
|
+
winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(m_builder)
|
|
120
|
+
->CreateProps(viewProps, props ? static_cast<AbiViewProps const &>(*props).UserProps() : nullptr);
|
|
121
|
+
shadowNodeProps->SetUserProps(userProps, viewProps);
|
|
122
|
+
|
|
123
|
+
const auto &dynamic = static_cast<folly::dynamic>(rawProps);
|
|
124
|
+
for (const auto &pair : dynamic.items()) {
|
|
125
|
+
const auto &propName = pair.first.getString();
|
|
126
|
+
auto hash = RAW_PROPS_KEY_HASH(propName);
|
|
127
|
+
shadowNodeProps.get()->setProp(context, hash, propName.c_str(), facebook::react::RawValue(pair.second));
|
|
128
|
+
userProps.SetProp(
|
|
129
|
+
hash, winrt::to_hstring(propName), winrt::make<winrt::Microsoft::ReactNative::DynamicReader>(pair.second));
|
|
130
|
+
}
|
|
131
|
+
return shadowNodeProps;
|
|
132
|
+
}
|
|
133
|
+
|
|
46
134
|
virtual facebook::react::State::Shared createInitialState(
|
|
47
135
|
facebook::react::Props::Shared const &props,
|
|
48
|
-
facebook::react::ShadowNodeFamily::Shared const &family) const override
|
|
136
|
+
facebook::react::ShadowNodeFamily::Shared const &family) const override {
|
|
137
|
+
if (std::is_same<ConcreteStateData, facebook::react::StateData>::value) {
|
|
138
|
+
// Default case: Returning `null` for nodes that don't use `State`.
|
|
139
|
+
return nullptr;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return std::make_shared<ConcreteState>(
|
|
143
|
+
std::make_shared<ConcreteStateData const>(
|
|
144
|
+
ConcreteAbiViewComponentDescriptor<ShadowNodeT>::initialStateData(props, family, *this)),
|
|
145
|
+
family);
|
|
146
|
+
}
|
|
147
|
+
|
|
49
148
|
virtual facebook::react::State::Shared createState(
|
|
50
149
|
facebook::react::ShadowNodeFamily const &family,
|
|
51
|
-
facebook::react::StateData::Shared const &data) const override
|
|
150
|
+
facebook::react::StateData::Shared const &data) const override {
|
|
151
|
+
if (std::is_same<ConcreteStateData, facebook::react::StateData>::value) {
|
|
152
|
+
// Default case: Returning `null` for nodes that don't use `State`.
|
|
153
|
+
return nullptr;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
react_native_assert(data && "Provided `data` is nullptr.");
|
|
157
|
+
|
|
158
|
+
return std::make_shared<ConcreteState const>(
|
|
159
|
+
std::static_pointer_cast<ConcreteStateData const>(data), *family.getMostRecentState());
|
|
160
|
+
}
|
|
52
161
|
|
|
53
162
|
facebook::react::ShadowNodeFamily::Shared createFamily(
|
|
54
|
-
facebook::react::ShadowNodeFamilyFragment const &fragment) const override
|
|
163
|
+
facebook::react::ShadowNodeFamilyFragment const &fragment) const override {
|
|
164
|
+
auto eventEmitter = std::make_shared<const ConcreteEventEmitter>(
|
|
165
|
+
std::make_shared<facebook::react::EventTarget>(fragment.instanceHandle, fragment.surfaceId), eventDispatcher_);
|
|
166
|
+
return std::make_shared<facebook::react::ShadowNodeFamily>(
|
|
167
|
+
fragment, std::move(eventEmitter), eventDispatcher_, *this);
|
|
168
|
+
}
|
|
55
169
|
|
|
56
170
|
protected:
|
|
57
171
|
/*
|
|
@@ -66,15 +180,44 @@ class AbiViewComponentDescriptor : public facebook::react::ComponentDescriptor {
|
|
|
66
180
|
* - Set `ShadowNode`'s size from state in
|
|
67
181
|
* `ModalHostViewComponentDescriptor`.
|
|
68
182
|
*/
|
|
69
|
-
virtual void adopt(facebook::react::ShadowNode &shadowNode) const
|
|
183
|
+
virtual void adopt(facebook::react::ShadowNode &shadowNode) const {
|
|
184
|
+
react_native_assert(shadowNode.getComponentHandle() == getComponentHandle());
|
|
185
|
+
|
|
186
|
+
auto &abiViewShadowNode = static_cast<AbiViewShadowNode &>(shadowNode);
|
|
187
|
+
|
|
188
|
+
abiViewShadowNode.Builder(m_builder);
|
|
189
|
+
|
|
190
|
+
if (winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(m_builder)
|
|
191
|
+
->MeasureContentHandler()) {
|
|
192
|
+
abiViewShadowNode.dirtyLayout();
|
|
193
|
+
abiViewShadowNode.enableMeasurement();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
70
196
|
|
|
71
197
|
private:
|
|
72
198
|
static ConcreteStateData initialStateData(
|
|
73
|
-
const facebook::react::Props::Shared &
|
|
199
|
+
const facebook::react::Props::Shared &props,
|
|
74
200
|
const facebook::react::ShadowNodeFamily::Shared & /*family*/,
|
|
75
|
-
const facebook::react::ComponentDescriptor &
|
|
201
|
+
const facebook::react::ComponentDescriptor &componentDescriptor) noexcept {
|
|
202
|
+
return {winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(
|
|
203
|
+
static_cast<const ConcreteAbiViewComponentDescriptor<ShadowNodeT> &>(componentDescriptor).m_builder)
|
|
204
|
+
->InitialStateData(std::static_pointer_cast<AbiViewProps const>(props)->UserProps())};
|
|
205
|
+
return {};
|
|
206
|
+
}
|
|
76
207
|
|
|
77
|
-
winrt::Microsoft::ReactNative::IReactViewComponentBuilder m_builder;
|
|
208
|
+
winrt::Microsoft::ReactNative::IReactViewComponentBuilder m_builder{nullptr};
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
class AbiViewComponentDescriptor : public ConcreteAbiViewComponentDescriptor<AbiViewShadowNode> {
|
|
212
|
+
public:
|
|
213
|
+
AbiViewComponentDescriptor(facebook::react::ComponentDescriptorParameters const ¶meters)
|
|
214
|
+
: ConcreteAbiViewComponentDescriptor<AbiViewShadowNode>(parameters) {}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
class AbiPortalComponentDescriptor : public ConcreteAbiViewComponentDescriptor<AbiPortalShadowNode> {
|
|
218
|
+
public:
|
|
219
|
+
AbiPortalComponentDescriptor(facebook::react::ComponentDescriptorParameters const ¶meters)
|
|
220
|
+
: ConcreteAbiViewComponentDescriptor<AbiPortalShadowNode>(parameters) {}
|
|
78
221
|
};
|
|
79
222
|
|
|
80
223
|
} // namespace Microsoft::ReactNative
|