react-native-windows 0.81.37 → 0.81.40

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.
Files changed (52) hide show
  1. package/Microsoft.ReactNative/Fabric/AbiComponentDescriptor.cpp +6 -2
  2. package/Microsoft.ReactNative/Fabric/AbiShadowNode.cpp +0 -47
  3. package/Microsoft.ReactNative/Fabric/AbiShadowNode.h +40 -8
  4. package/Microsoft.ReactNative/Fabric/AbiState.h +26 -8
  5. package/Microsoft.ReactNative/Fabric/AbiTextInputProps.h +51 -0
  6. package/Microsoft.ReactNative/Fabric/AbiTextInputShadowNode.cpp +88 -0
  7. package/Microsoft.ReactNative/Fabric/AbiTextInputShadowNode.h +65 -0
  8. package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.h +52 -18
  9. package/Microsoft.ReactNative/Fabric/AbiViewShadowNode.cpp +0 -18
  10. package/Microsoft.ReactNative/Fabric/AbiViewShadowNode.h +16 -4
  11. package/Microsoft.ReactNative/Fabric/ComponentView.cpp +2 -1
  12. package/Microsoft.ReactNative/Fabric/Composition/ComponentViewRegistry.cpp +1 -2
  13. package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +1 -1
  14. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +3 -2
  15. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +6 -4
  16. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +6 -4
  17. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +2 -1
  18. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp +22 -0
  19. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +2 -1
  20. package/Microsoft.ReactNative/Fabric/Composition/TextInput/AbiTextInputState.h +38 -0
  21. package/Microsoft.ReactNative/Fabric/Composition/TextInput/ConcreteTextInputShadowNode.h +272 -0
  22. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentDescriptor.h +21 -14
  23. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +345 -90
  24. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +24 -4
  25. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputProps.h +1 -1
  26. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.cpp +0 -205
  27. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.h +22 -65
  28. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputState.h +2 -1
  29. package/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.cpp +0 -1
  30. package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +5 -0
  31. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +0 -1
  32. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +60 -5
  33. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +3 -0
  34. package/Microsoft.ReactNative/ViewProps.idl +11 -0
  35. package/Microsoft.ReactNative/Views/ViewViewManager.cpp +2 -2
  36. package/Microsoft.ReactNative.Cxx/ComponentView.Experimental.interop.h +12 -0
  37. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  38. package/PropertySheets/JSEngine.props +1 -1
  39. package/PropertySheets/React.Cpp.props +0 -1
  40. package/PropertySheets/WinUI.props +2 -1
  41. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/Instance.cpp +386 -0
  42. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/NativeToJsBridge.h +148 -0
  43. package/Scripts/EnableInternalWinAppSDKFeed.ps1 +12 -5
  44. package/Scripts/NuGetRestoreForceEvaluateAllSolutions.ps1 +2 -2
  45. package/Shared/Networking/WinRTWebSocketResource.h +1 -5
  46. package/Shared/OInstance.cpp +13 -8
  47. package/Shared/Shared.vcxitems +3 -3
  48. package/Shared/Shared.vcxitems.filters +1 -1
  49. package/external/folly/folly.vcxitems +10 -0
  50. package/index.windows.js +5 -0
  51. package/package.json +4 -4
  52. package/Microsoft.ReactNative/Fabric/AbiState.cpp +0 -29
@@ -47,7 +47,9 @@ std::shared_ptr<facebook::react::ShadowNode> AbiComponentDescriptor::createShado
47
47
  facebook::react::ShadowNodeFamily::Shared const &family) const {
48
48
  auto shadowNode = std::make_shared<ShadowNodeT>(fragment, family, getTraits());
49
49
 
50
- shadowNode->Proxy(winrt::make<winrt::Microsoft::ReactNative::implementation::ShadowNode>(shadowNode));
50
+ shadowNode->Proxy(
51
+ winrt::make<winrt::Microsoft::ReactNative::implementation::ShadowNode<::Microsoft::ReactNative::AbiStateData>>(
52
+ shadowNode));
51
53
  winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(m_builder)
52
54
  ->CreateShadowNode(shadowNode->Proxy());
53
55
 
@@ -60,7 +62,9 @@ std::shared_ptr<facebook::react::ShadowNode> AbiComponentDescriptor::cloneShadow
60
62
  const facebook::react::ShadowNodeFragment &fragment) const {
61
63
  auto shadowNode = std::make_shared<ShadowNodeT>(sourceShadowNode, fragment);
62
64
 
63
- shadowNode->Proxy(winrt::make<winrt::Microsoft::ReactNative::implementation::ShadowNode>(shadowNode));
65
+ shadowNode->Proxy(
66
+ winrt::make<winrt::Microsoft::ReactNative::implementation::ShadowNode<::Microsoft::ReactNative::AbiStateData>>(
67
+ shadowNode));
64
68
  winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(m_builder)
65
69
  ->CloneShadowNode(shadowNode->Proxy(), static_cast<const ShadowNodeT &>(sourceShadowNode).Proxy());
66
70
 
@@ -6,7 +6,6 @@
6
6
  #include <Fabric/Composition/ReactCompositionViewComponentBuilder.h>
7
7
  #include <react/debug/react_native_assert.h>
8
8
  #include <react/renderer/core/conversions.h>
9
-
10
9
  #include <utility>
11
10
 
12
11
  namespace winrt::Microsoft::ReactNative::implementation {
@@ -27,52 +26,6 @@ winrt::Microsoft::ReactNative::IComponentProps AbiProps::UserProps() const noexc
27
26
  return m_componentProps;
28
27
  }
29
28
 
30
- ShadowNode::ShadowNode(std::shared_ptr<const facebook::react::ShadowNode> shadowNode) noexcept
31
- : m_shadowNode(shadowNode) {}
32
-
33
- void ShadowNode::EnsureUnsealed() noexcept {
34
- if (auto shadowNode = m_shadowNode.lock()) {
35
- shadowNode->ensureUnsealed();
36
- }
37
- }
38
-
39
- winrt::Windows::Foundation::IInspectable ShadowNode::Tag() const noexcept {
40
- return m_tag;
41
- }
42
-
43
- void ShadowNode::Tag(winrt::Windows::Foundation::IInspectable tag) noexcept {
44
- m_tag = tag;
45
- }
46
-
47
- winrt::Windows::Foundation::IInspectable ShadowNode::StateData() const noexcept {
48
- if (auto shadowNode = m_shadowNode.lock()) {
49
- auto state = shadowNode->getState();
50
- react_native_assert(state && "State must not be `nullptr`.");
51
- auto abiStateData =
52
- static_cast<const facebook::react::ConcreteState<::Microsoft::ReactNative::AbiStateData> *>(state.get())
53
- ->getData();
54
- return abiStateData.userdata;
55
- }
56
- return nullptr;
57
- }
58
-
59
- void ShadowNode::StateData(winrt::Windows::Foundation::IInspectable tag) noexcept {
60
- if (auto shadowNode = m_shadowNode.lock()) {
61
- shadowNode->ensureUnsealed();
62
-
63
- auto &state = const_cast<facebook::react::State::Shared &>(shadowNode->getState());
64
- state = std::make_shared<const facebook::react::ConcreteState<::Microsoft::ReactNative::AbiStateData>>(
65
- std::make_shared<const ::Microsoft::ReactNative::AbiStateData>(tag), *state);
66
- }
67
- }
68
-
69
- winrt::Microsoft::ReactNative::EventEmitter ShadowNode::EventEmitter() const noexcept {
70
- if (auto shadowNode = m_shadowNode.lock()) {
71
- return winrt::make<winrt::Microsoft::ReactNative::implementation::EventEmitter>(shadowNode->getEventEmitter());
72
- }
73
- return nullptr;
74
- }
75
-
76
29
  } // namespace winrt::Microsoft::ReactNative::implementation
77
30
 
78
31
  namespace Microsoft::ReactNative {
@@ -33,17 +33,49 @@ class AbiProps final : public facebook::react::Props {
33
33
  winrt::Microsoft::ReactNative::IComponentProps m_componentProps{nullptr};
34
34
  };
35
35
 
36
- struct ShadowNode : ShadowNodeT<ShadowNode> {
37
- ShadowNode(std::shared_ptr<const facebook::react::ShadowNode> shadowNode) noexcept;
36
+ template <typename TStateData>
37
+ struct ShadowNode : ShadowNodeT<ShadowNode<TStateData>> {
38
+ ShadowNode(std::shared_ptr<const facebook::react::ShadowNode> shadowNode) noexcept : m_shadowNode(shadowNode) {}
39
+
40
+ void EnsureUnsealed() noexcept {
41
+ if (auto shadowNode = m_shadowNode.lock()) {
42
+ shadowNode->ensureUnsealed();
43
+ }
44
+ }
38
45
 
39
- void EnsureUnsealed() noexcept;
40
- winrt::Windows::Foundation::IInspectable Tag() const noexcept;
41
- void Tag(winrt::Windows::Foundation::IInspectable tag) noexcept;
46
+ winrt::Windows::Foundation::IInspectable Tag() const noexcept {
47
+ return m_tag;
48
+ }
49
+ void Tag(winrt::Windows::Foundation::IInspectable tag) noexcept {
50
+ m_tag = tag;
51
+ }
42
52
 
43
- winrt::Windows::Foundation::IInspectable StateData() const noexcept;
44
- void StateData(winrt::Windows::Foundation::IInspectable tag) noexcept;
53
+ winrt::Windows::Foundation::IInspectable StateData() const noexcept {
54
+ if (auto shadowNode = m_shadowNode.lock()) {
55
+ auto state = shadowNode->getState();
56
+ auto abiStateData = static_cast<const facebook::react::ConcreteState<TStateData> *>(state.get())->getData();
57
+ return abiStateData.userdata;
58
+ }
59
+ return nullptr;
60
+ }
45
61
 
46
- winrt::Microsoft::ReactNative::EventEmitter EventEmitter() const noexcept;
62
+ void StateData(winrt::Windows::Foundation::IInspectable tag) noexcept {
63
+ if (auto shadowNode = m_shadowNode.lock()) {
64
+ shadowNode->ensureUnsealed();
65
+ auto &state = const_cast<facebook::react::State::Shared &>(shadowNode->getState());
66
+ auto data = static_cast<const facebook::react::ConcreteState<TStateData> *>(state.get())->getData();
67
+ data.userdata = tag;
68
+ state = std::make_shared<const facebook::react::ConcreteState<TStateData>>(
69
+ std::make_shared<const TStateData>(std::move(data)), *state);
70
+ }
71
+ }
72
+
73
+ winrt::Microsoft::ReactNative::EventEmitter EventEmitter() const noexcept {
74
+ if (auto shadowNode = m_shadowNode.lock()) {
75
+ return winrt::make<winrt::Microsoft::ReactNative::implementation::EventEmitter>(shadowNode->getEventEmitter());
76
+ }
77
+ return nullptr;
78
+ }
47
79
 
48
80
  protected:
49
81
  std::weak_ptr<const facebook::react::ShadowNode> m_shadowNode;
@@ -11,22 +11,40 @@
11
11
 
12
12
  namespace Microsoft::ReactNative {
13
13
 
14
- class AbiStateData final {
14
+ class AbiStateData {
15
15
  public:
16
16
  AbiStateData() = default;
17
17
  AbiStateData(winrt::Windows::Foundation::IInspectable data) : userdata(data) {}
18
18
  winrt::Windows::Foundation::IInspectable userdata;
19
19
  };
20
20
 
21
- struct AbiComponentState : winrt::implements<AbiComponentState, winrt::Microsoft::ReactNative::IComponentState> {
22
- AbiComponentState(facebook::react::State::Shared const &state);
23
-
24
- winrt::Windows::Foundation::IInspectable Data() noexcept;
25
- void UpdateState(const winrt::Windows::Foundation::IInspectable &data) noexcept;
26
- void UpdateStateWithMutation(const winrt::Microsoft::ReactNative::StateUpdateMutation &mutation) noexcept;
21
+ template <typename TStateData /* = ::Microsoft::ReactNative::AbiStateData */>
22
+ struct AbiComponentState
23
+ : winrt::implements<AbiComponentState<TStateData>, winrt::Microsoft::ReactNative::IComponentState> {
24
+ AbiComponentState(facebook::react::State::Shared const &state) {
25
+ m_state = std::static_pointer_cast<facebook::react::ConcreteState<TStateData> const>(state);
26
+ }
27
+
28
+ winrt::Windows::Foundation::IInspectable Data() noexcept {
29
+ return m_state->getData().userdata;
30
+ }
31
+ void UpdateState(const winrt::Windows::Foundation::IInspectable &data) noexcept {
32
+ m_state->updateState([data](const TStateData &oldData) {
33
+ auto newData = oldData;
34
+ newData.userdata = data;
35
+ return std::make_shared<TStateData const>(std::move(newData));
36
+ });
37
+ }
38
+ void UpdateStateWithMutation(const winrt::Microsoft::ReactNative::StateUpdateMutation &mutation) noexcept {
39
+ m_state->updateState([mutation](const TStateData &oldData) {
40
+ auto newData = oldData;
41
+ newData.userdata = mutation(oldData.userdata);
42
+ return std::make_shared<TStateData const>(std::move(newData));
43
+ });
44
+ }
27
45
 
28
46
  private:
29
- std::shared_ptr<facebook::react::ConcreteState<AbiStateData> const> m_state;
47
+ std::shared_ptr<facebook::react::ConcreteState<TStateData> const> m_state;
30
48
  };
31
49
 
32
50
  } // namespace Microsoft::ReactNative
@@ -0,0 +1,51 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #pragma once
5
+
6
+ #include "TextInputProps.g.h"
7
+
8
+ #include <react/renderer/components/view/ViewProps.h>
9
+ #include <react/renderer/imagemanager/primitives.h>
10
+ #include "Composition/TextInput/WindowsTextInputProps.h"
11
+ #include "winrt/Microsoft.ReactNative.Composition.Experimental.h"
12
+ #include "winrt/Microsoft.ReactNative.h"
13
+
14
+ namespace Microsoft::ReactNative {
15
+
16
+ class AbiTextInputProps final : public facebook::react::WindowsTextInputProps {
17
+ public:
18
+ AbiTextInputProps() = default;
19
+ AbiTextInputProps(
20
+ const facebook::react::PropsParserContext &context,
21
+ const AbiTextInputProps &sourceProps,
22
+ const facebook::react::RawProps &rawProps);
23
+ ~AbiTextInputProps();
24
+
25
+ void SetUserProps(
26
+ winrt::Microsoft::ReactNative::IComponentProps userProps,
27
+ winrt::Microsoft::ReactNative::ViewProps innerProps) noexcept;
28
+ winrt::Microsoft::ReactNative::IComponentProps UserProps() const noexcept;
29
+ winrt::Microsoft::ReactNative::ViewProps ViewProps() const noexcept;
30
+
31
+ private:
32
+ winrt::Microsoft::ReactNative::IComponentProps m_userProps{nullptr};
33
+ winrt::Microsoft::ReactNative::ViewProps m_innerProps{nullptr};
34
+ };
35
+
36
+ } // namespace Microsoft::ReactNative
37
+
38
+ namespace winrt::Microsoft::ReactNative::implementation {
39
+
40
+ struct TextInputProps : TextInputPropsT<TextInputProps, ViewProps> {
41
+ using Super = TextInputPropsT<TextInputProps, ViewProps>;
42
+ TextInputProps(facebook::react::SharedViewProps props, bool holdRef = true) noexcept;
43
+
44
+ winrt::hstring Placeholder() noexcept;
45
+ bool SecureTextEntry() noexcept;
46
+
47
+ protected:
48
+ const facebook::react::WindowsTextInputProps &windowsTextInputProps() const noexcept;
49
+ };
50
+
51
+ } // namespace winrt::Microsoft::ReactNative::implementation
@@ -0,0 +1,88 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #include "AbiTextInputShadowNode.h"
5
+
6
+ #include "AbiTextInputProps.h"
7
+
8
+ namespace Microsoft::ReactNative {
9
+
10
+ extern const char AbiTextInputComponentName[] = "AbiTextInput";
11
+
12
+ facebook::react::Size AbiTextInputShadowNode::measureContent(
13
+ const facebook::react::LayoutContext &layoutContext,
14
+ const facebook::react::LayoutConstraints &layoutConstraints) const {
15
+ return Super::measureContent(layoutContext, layoutConstraints);
16
+ }
17
+
18
+ void AbiTextInputShadowNode::layout(facebook::react::LayoutContext layoutContext) {
19
+ Super::layout(layoutContext);
20
+ }
21
+
22
+ void AbiTextInputShadowNode::OnClone(const facebook::react::ShadowNode &sourceShadowNode) noexcept {
23
+ auto const &source = static_cast<AbiTextInputShadowNode const &>(sourceShadowNode);
24
+ m_proxy = source.m_proxy;
25
+ m_builder = source.m_builder;
26
+ }
27
+
28
+ void AbiTextInputShadowNode::Builder(winrt::Microsoft::ReactNative::IReactViewComponentBuilder builder) noexcept {
29
+ m_builder = builder;
30
+ }
31
+
32
+ winrt::Microsoft::ReactNative::IReactViewComponentBuilder AbiTextInputShadowNode::Builder() const noexcept {
33
+ return m_builder;
34
+ }
35
+
36
+ void AbiTextInputShadowNode::Proxy(winrt::Microsoft::ReactNative::ShadowNode proxy) noexcept {
37
+ m_proxy = proxy;
38
+ }
39
+
40
+ winrt::Microsoft::ReactNative::ShadowNode AbiTextInputShadowNode::Proxy() const noexcept {
41
+ return m_proxy;
42
+ }
43
+
44
+ AbiTextInputProps::AbiTextInputProps(
45
+ const facebook::react::PropsParserContext &context,
46
+ const AbiTextInputProps &sourceProps,
47
+ const facebook::react::RawProps &rawProps)
48
+ : facebook::react::WindowsTextInputProps(context, sourceProps, rawProps) {}
49
+
50
+ AbiTextInputProps::~AbiTextInputProps() {
51
+ if (m_innerProps) {
52
+ winrt::get_self<winrt::Microsoft::ReactNative::implementation::ViewProps>(m_innerProps)->Disconnect();
53
+ }
54
+ }
55
+
56
+ void AbiTextInputProps::SetUserProps(
57
+ winrt::Microsoft::ReactNative::IComponentProps userProps,
58
+ winrt::Microsoft::ReactNative::ViewProps innerProps) noexcept {
59
+ m_userProps = userProps;
60
+ m_innerProps = innerProps;
61
+ }
62
+
63
+ winrt::Microsoft::ReactNative::IComponentProps AbiTextInputProps::UserProps() const noexcept {
64
+ return m_userProps;
65
+ }
66
+
67
+ winrt::Microsoft::ReactNative::ViewProps AbiTextInputProps::ViewProps() const noexcept {
68
+ return m_innerProps;
69
+ }
70
+
71
+ } // namespace Microsoft::ReactNative
72
+
73
+ namespace winrt::Microsoft::ReactNative::implementation {
74
+ TextInputProps::TextInputProps(facebook::react::SharedViewProps props, bool holdRef) noexcept : Super(props, holdRef) {}
75
+
76
+ const facebook::react::WindowsTextInputProps &TextInputProps::windowsTextInputProps() const noexcept {
77
+ return static_cast<const facebook::react::WindowsTextInputProps &>(*m_viewProps);
78
+ }
79
+
80
+ winrt::hstring TextInputProps::Placeholder() noexcept {
81
+ return m_viewProps ? winrt::to_hstring(windowsTextInputProps().placeholder) : winrt::hstring();
82
+ }
83
+
84
+ bool TextInputProps::SecureTextEntry() noexcept {
85
+ return m_viewProps ? windowsTextInputProps().secureTextEntry : false;
86
+ }
87
+
88
+ } // namespace winrt::Microsoft::ReactNative::implementation
@@ -0,0 +1,65 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #pragma once
5
+
6
+ #include "LayoutContext.g.h"
7
+ #include "ShadowNode.g.h"
8
+ #include "YogaLayoutableShadowNode.g.h"
9
+ #include <react/components/rnwcore/EventEmitters.h>
10
+ #include <unordered_map>
11
+ #include "AbiShadowNode.h"
12
+ #include "AbiState.h"
13
+ #include "AbiTextInputProps.h"
14
+
15
+ #include <react/renderer/core/LayoutContext.h>
16
+ #include "Composition/TextInput/AbiTextInputState.h"
17
+ #include "Composition/TextInput/WindowsTextInputShadowNode.h"
18
+
19
+ namespace Microsoft::ReactNative {
20
+
21
+ extern const char AbiTextInputComponentName[];
22
+
23
+ class AbiTextInputShadowNode final : public facebook::react::ConcreteTextInputShadowNode<
24
+ AbiTextInputComponentName,
25
+ AbiTextInputProps,
26
+ facebook::react::WindowsTextInputEventEmitter,
27
+ Microsoft::ReactNative::AbiTextInputStateData> {
28
+ public:
29
+ using Super = facebook::react::ConcreteTextInputShadowNode<
30
+ AbiTextInputComponentName,
31
+ AbiTextInputProps,
32
+ facebook::react::WindowsTextInputEventEmitter,
33
+ Microsoft::ReactNative::AbiTextInputStateData>;
34
+ using Super::Super;
35
+
36
+ facebook::react::Size measureContent(
37
+ const facebook::react::LayoutContext &layoutContext,
38
+ const facebook::react::LayoutConstraints &layoutConstraints) const override;
39
+ void layout(facebook::react::LayoutContext layoutContext) override;
40
+
41
+ void OnClone(const facebook::react::ShadowNode &sourceShadowNode) noexcept;
42
+ void Builder(winrt::Microsoft::ReactNative::IReactViewComponentBuilder builder) noexcept;
43
+ winrt::Microsoft::ReactNative::IReactViewComponentBuilder Builder() const noexcept;
44
+ void Proxy(winrt::Microsoft::ReactNative::ShadowNode handle) noexcept;
45
+ winrt::Microsoft::ReactNative::ShadowNode Proxy() const noexcept;
46
+
47
+ void updateTextInputState(
48
+ facebook::react::AttributedStringBox attributedStringBox,
49
+ facebook::react::AttributedString &reactTreeAttributedString,
50
+ facebook::react::ParagraphAttributes paragraphAttributes,
51
+ int64_t mostRecentEventCount) override {
52
+ Super::setStateData(AbiTextInputStateData{
53
+ attributedStringBox,
54
+ reactTreeAttributedString,
55
+ paragraphAttributes,
56
+ mostRecentEventCount,
57
+ getStateData().userdata});
58
+ }
59
+
60
+ private:
61
+ winrt::Microsoft::ReactNative::ShadowNode m_proxy{nullptr};
62
+ winrt::Microsoft::ReactNative::IReactViewComponentBuilder m_builder{nullptr};
63
+ };
64
+
65
+ } // namespace Microsoft::ReactNative
@@ -9,15 +9,20 @@
9
9
  #include <react/renderer/components/view/ConcreteViewShadowNode.h>
10
10
  #include <react/renderer/core/ComponentDescriptor.h>
11
11
  #include "AbiPortalShadowNode.h"
12
+ #include "AbiTextInputShadowNode.h"
12
13
  #include "AbiViewProps.h"
13
14
  #include "AbiViewShadowNode.h"
15
+ #include "Composition/TextInput/WindowsTextInputComponentDescriptor.h"
14
16
  #include "DynamicReader.h"
15
17
  #include "winrt/Microsoft.ReactNative.h"
16
18
 
17
19
  namespace Microsoft::ReactNative {
18
20
 
19
- template <typename ShadowNodeT>
20
- class ConcreteAbiViewComponentDescriptor : public facebook::react::ComponentDescriptor {
21
+ template <
22
+ typename ShadowNodeT,
23
+ typename AbiPropT = winrt::Microsoft::ReactNative::implementation::ViewProps,
24
+ typename BaseT = facebook::react::ComponentDescriptor>
25
+ class ConcreteAbiViewComponentDescriptor : public BaseT {
21
26
  protected:
22
27
  using SharedShadowNodeT = std::shared_ptr<const ShadowNodeT>;
23
28
 
@@ -31,14 +36,16 @@ class ConcreteAbiViewComponentDescriptor : public facebook::react::ComponentDesc
31
36
  using ConcreteStateData = typename ShadowNodeT::ConcreteState::Data;
32
37
 
33
38
  ConcreteAbiViewComponentDescriptor(facebook::react::ComponentDescriptorParameters const &parameters)
34
- : ComponentDescriptor(parameters) {
39
+ : BaseT(parameters) {
35
40
  auto flavor = std::static_pointer_cast<std::string const>(this->flavor_);
36
41
  m_builder = WindowsComponentDescriptorRegistry::FromProperties(
37
42
  parameters.contextContainer->at<winrt::Microsoft::ReactNative::ReactContext>("MSRN.ReactContext")
38
43
  .Properties())
39
44
  ->GetDescriptor(flavor);
40
45
 
41
- rawPropsParser_.prepare<ConcreteProps>();
46
+ if constexpr (std::is_same<BaseT, facebook::react::ComponentDescriptor>::value) {
47
+ BaseT::rawPropsParser_.template prepare<ConcreteProps>();
48
+ }
42
49
  }
43
50
  facebook::react::ComponentHandle getComponentHandle() const override {
44
51
  return reinterpret_cast<facebook::react::ComponentHandle>(getComponentName());
@@ -62,7 +69,9 @@ class ConcreteAbiViewComponentDescriptor : public facebook::react::ComponentDesc
62
69
  const facebook::react::ShadowNodeFragment &fragment,
63
70
  facebook::react::ShadowNodeFamily::Shared const &family) const override {
64
71
  auto shadowNode = std::make_shared<ShadowNodeT>(fragment, family, getTraits());
65
- shadowNode->Proxy(winrt::make<winrt::Microsoft::ReactNative::implementation::YogaLayoutableShadowNode>(shadowNode));
72
+ shadowNode->Proxy(
73
+ winrt::make<winrt::Microsoft::ReactNative::implementation::YogaLayoutableShadowNode<ConcreteStateData>>(
74
+ shadowNode));
66
75
  winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(m_builder)
67
76
  ->CreateShadowNode(shadowNode->Proxy());
68
77
 
@@ -74,7 +83,9 @@ class ConcreteAbiViewComponentDescriptor : public facebook::react::ComponentDesc
74
83
  const facebook::react::ShadowNode &sourceShadowNode,
75
84
  const facebook::react::ShadowNodeFragment &fragment) const override {
76
85
  auto shadowNode = std::make_shared<ShadowNodeT>(sourceShadowNode, fragment);
77
- shadowNode->Proxy(winrt::make<winrt::Microsoft::ReactNative::implementation::YogaLayoutableShadowNode>(shadowNode));
86
+ shadowNode->Proxy(
87
+ winrt::make<winrt::Microsoft::ReactNative::implementation::YogaLayoutableShadowNode<ConcreteStateData>>(
88
+ shadowNode));
78
89
  winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(m_builder)
79
90
  ->CloneShadowNode(shadowNode->Proxy(), static_cast<const ShadowNodeT &>(sourceShadowNode).Proxy());
80
91
 
@@ -107,17 +118,18 @@ class ConcreteAbiViewComponentDescriptor : public facebook::react::ComponentDesc
107
118
  ShadowNodeT::filterRawProps(rawProps);
108
119
  }
109
120
 
110
- rawProps.parse(rawPropsParser_);
121
+ rawProps.parse(BaseT::rawPropsParser_);
111
122
 
112
123
  // Call old-style constructor
113
124
  // 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);
125
+ auto shadowNodeProps = std::make_shared<ConcreteProps>(
126
+ context, props ? static_cast<ConcreteProps const &>(*props) : *ShadowNodeT::defaultSharedProps(), rawProps);
116
127
  auto viewProps =
117
- winrt::make<winrt::Microsoft::ReactNative::implementation::ViewProps>(shadowNodeProps, false /*holdRef*/);
128
+
129
+ winrt::make<AbiPropT>(shadowNodeProps, false /*holdRef*/);
118
130
  auto userProps =
119
131
  winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(m_builder)
120
- ->CreateProps(viewProps, props ? static_cast<AbiViewProps const &>(*props).UserProps() : nullptr);
132
+ ->CreateProps(viewProps, props ? static_cast<ConcreteProps const &>(*props).UserProps() : nullptr);
121
133
  shadowNodeProps->SetUserProps(userProps, viewProps);
122
134
 
123
135
  const auto &dynamic = static_cast<folly::dynamic>(rawProps);
@@ -141,7 +153,7 @@ class ConcreteAbiViewComponentDescriptor : public facebook::react::ComponentDesc
141
153
 
142
154
  return std::make_shared<ConcreteState>(
143
155
  std::make_shared<ConcreteStateData const>(
144
- ConcreteAbiViewComponentDescriptor<ShadowNodeT>::initialStateData(props, family, *this)),
156
+ ConcreteAbiViewComponentDescriptor<ShadowNodeT, AbiPropT, BaseT>::initialStateData(props, family, *this)),
145
157
  family);
146
158
  }
147
159
 
@@ -162,9 +174,10 @@ class ConcreteAbiViewComponentDescriptor : public facebook::react::ComponentDesc
162
174
  facebook::react::ShadowNodeFamily::Shared createFamily(
163
175
  facebook::react::ShadowNodeFamilyFragment const &fragment) const override {
164
176
  auto eventEmitter = std::make_shared<const ConcreteEventEmitter>(
165
- std::make_shared<facebook::react::EventTarget>(fragment.instanceHandle, fragment.surfaceId), eventDispatcher_);
177
+ std::make_shared<facebook::react::EventTarget>(fragment.instanceHandle, fragment.surfaceId),
178
+ BaseT::eventDispatcher_);
166
179
  return std::make_shared<facebook::react::ShadowNodeFamily>(
167
- fragment, std::move(eventEmitter), eventDispatcher_, *this);
180
+ fragment, std::move(eventEmitter), BaseT::eventDispatcher_, *this);
168
181
  }
169
182
 
170
183
  protected:
@@ -183,7 +196,7 @@ class ConcreteAbiViewComponentDescriptor : public facebook::react::ComponentDesc
183
196
  virtual void adopt(facebook::react::ShadowNode &shadowNode) const {
184
197
  react_native_assert(shadowNode.getComponentHandle() == getComponentHandle());
185
198
 
186
- auto &abiViewShadowNode = static_cast<AbiViewShadowNode &>(shadowNode);
199
+ auto &abiViewShadowNode = static_cast<ShadowNodeT &>(shadowNode);
187
200
 
188
201
  abiViewShadowNode.Builder(m_builder);
189
202
 
@@ -192,6 +205,10 @@ class ConcreteAbiViewComponentDescriptor : public facebook::react::ComponentDesc
192
205
  abiViewShadowNode.dirtyLayout();
193
206
  abiViewShadowNode.enableMeasurement();
194
207
  }
208
+
209
+ if constexpr (!(std::is_same<BaseT, facebook::react::ComponentDescriptor>::value)) {
210
+ BaseT::adopt(shadowNode);
211
+ }
195
212
  }
196
213
 
197
214
  private:
@@ -199,9 +216,11 @@ class ConcreteAbiViewComponentDescriptor : public facebook::react::ComponentDesc
199
216
  const facebook::react::Props::Shared &props,
200
217
  const facebook::react::ShadowNodeFamily::Shared & /*family*/,
201
218
  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())};
219
+ return {
220
+ winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(
221
+ static_cast<const ConcreteAbiViewComponentDescriptor<ShadowNodeT, AbiPropT, BaseT> &>(componentDescriptor)
222
+ .m_builder)
223
+ ->InitialStateData(std::static_pointer_cast<const ConcreteProps>(props)->UserProps())};
205
224
  return {};
206
225
  }
207
226
 
@@ -220,4 +239,19 @@ class AbiPortalComponentDescriptor : public ConcreteAbiViewComponentDescriptor<A
220
239
  : ConcreteAbiViewComponentDescriptor<AbiPortalShadowNode>(parameters) {}
221
240
  };
222
241
 
242
+ class AbiWindowsTextInputComponentDescriptor
243
+ : public ConcreteAbiViewComponentDescriptor<
244
+ AbiTextInputShadowNode,
245
+ winrt::Microsoft::ReactNative::implementation::TextInputProps,
246
+ facebook::react::ConcreteWindowsTextInputComponentDescriptor<AbiTextInputShadowNode>> {
247
+ using Super = ConcreteAbiViewComponentDescriptor<
248
+ AbiTextInputShadowNode,
249
+ winrt::Microsoft::ReactNative::implementation::TextInputProps,
250
+ facebook::react::ConcreteWindowsTextInputComponentDescriptor<AbiTextInputShadowNode>>;
251
+
252
+ public:
253
+ AbiWindowsTextInputComponentDescriptor(facebook::react::ComponentDescriptorParameters const &parameters)
254
+ : Super(parameters) {}
255
+ };
256
+
223
257
  } // namespace Microsoft::ReactNative
@@ -11,24 +11,6 @@
11
11
 
12
12
  #include <utility>
13
13
 
14
- namespace winrt::Microsoft::ReactNative::implementation {
15
-
16
- YogaLayoutableShadowNode::YogaLayoutableShadowNode(
17
- std::shared_ptr<const facebook::react::ShadowNode> shadowNode) noexcept
18
- : base_type(shadowNode) {}
19
-
20
- void YogaLayoutableShadowNode::Layout(winrt::Microsoft::ReactNative::LayoutContext layoutContext) noexcept {
21
- if (auto shadowNode = m_shadowNode.lock()) {
22
- std::const_pointer_cast<facebook::react::YogaLayoutableShadowNode>(
23
- std::dynamic_pointer_cast<const facebook::react::YogaLayoutableShadowNode>(shadowNode))
24
- ->facebook::react::YogaLayoutableShadowNode::layout(
25
- winrt::get_self<winrt::Microsoft::ReactNative::implementation::LayoutContext>(layoutContext)
26
- ->m_layoutContext);
27
- }
28
- }
29
-
30
- } // namespace winrt::Microsoft::ReactNative::implementation
31
-
32
14
  namespace Microsoft::ReactNative {
33
15
 
34
16
  extern const char AbiViewComponentName[] = "AbiView";
@@ -48,10 +48,22 @@ struct LayoutContext : LayoutContextT<LayoutContext> {
48
48
  facebook::react::LayoutContext m_layoutContext;
49
49
  };
50
50
 
51
- struct YogaLayoutableShadowNode : YogaLayoutableShadowNodeT<YogaLayoutableShadowNode, implementation::ShadowNode> {
52
- YogaLayoutableShadowNode(std::shared_ptr<const facebook::react::ShadowNode> shadowNode) noexcept;
53
-
54
- void Layout(winrt::Microsoft::ReactNative::LayoutContext layoutContext) noexcept;
51
+ template <typename TStateData /* = ::Microsoft::ReactNative::AbiStateData */>
52
+ struct YogaLayoutableShadowNode
53
+ : YogaLayoutableShadowNodeT<YogaLayoutableShadowNode<TStateData>, implementation::ShadowNode<TStateData>> {
54
+ using Super = YogaLayoutableShadowNodeT<YogaLayoutableShadowNode<TStateData>, implementation::ShadowNode<TStateData>>;
55
+ YogaLayoutableShadowNode(std::shared_ptr<const facebook::react::ShadowNode> shadowNode) noexcept
56
+ : Super(shadowNode) {}
57
+
58
+ void Layout(winrt::Microsoft::ReactNative::LayoutContext layoutContext) noexcept {
59
+ if (auto shadowNode = Super::m_shadowNode.lock()) {
60
+ std::const_pointer_cast<facebook::react::YogaLayoutableShadowNode>(
61
+ std::dynamic_pointer_cast<const facebook::react::YogaLayoutableShadowNode>(shadowNode))
62
+ ->facebook::react::YogaLayoutableShadowNode::layout(
63
+ winrt::get_self<winrt::Microsoft::ReactNative::implementation::LayoutContext>(layoutContext)
64
+ ->m_layoutContext);
65
+ }
66
+ }
55
67
  };
56
68
 
57
69
  } // namespace winrt::Microsoft::ReactNative::implementation
@@ -168,7 +168,8 @@ void ComponentView::updateState(
168
168
  facebook::react::State::Shared const &oldState) noexcept {
169
169
  // Avoid new-ing up a new AbiComponentState on every state change if we are not a custom component
170
170
  if (m_builder && m_builder->UpdateStateHandler()) {
171
- m_builder->UpdateStateHandler()(*this, winrt::make<::Microsoft::ReactNative::AbiComponentState>(state));
171
+ m_builder->UpdateStateHandler()(
172
+ *this, winrt::make<::Microsoft::ReactNative::AbiComponentState<::Microsoft::ReactNative::AbiStateData>>(state));
172
173
  }
173
174
  }
174
175
 
@@ -84,8 +84,7 @@ ComponentViewDescriptor const &ComponentViewRegistry::dequeueComponentViewWithCo
84
84
  } else {
85
85
  auto descriptor =
86
86
  WindowsComponentDescriptorRegistry::FromProperties(m_context.Properties())->GetDescriptor(componentHandle);
87
- view = winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(
88
- descriptor.as<winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder>())
87
+ view = winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(descriptor)
89
88
  ->CreateView(m_context.Handle(), tag, compContext);
90
89
  }
91
90
 
@@ -1816,7 +1816,7 @@ struct CompActivityVisual : winrt::implements<
1816
1816
  auto innerBrush = TTypeRedirects::CompositionContextHelper::InnerBrush(brush);
1817
1817
  if (brush) {
1818
1818
  _themeProperties.InsertVector4(
1819
- L"Foreground", ColorAsVector4(innerBrush.as<TTypeRedirects::CompositionColorBrush>().Color()));
1819
+ L"Foreground", ColorAsVector4(innerBrush.template as<TTypeRedirects::CompositionColorBrush>().Color()));
1820
1820
  } else {
1821
1821
  _themeProperties.InsertVector4(L"Foreground", ColorAsVector4({0, 0, 0, 0}));
1822
1822
  }
@@ -1044,9 +1044,10 @@ void CompositionEventHandler::UpdateActiveTouch(
1044
1044
  activeTouch.touch.screenPoint.y = ptScaled.y;
1045
1045
  activeTouch.touch.offsetPoint.x = ptLocal.x;
1046
1046
  activeTouch.touch.offsetPoint.y = ptLocal.y;
1047
+ // Restamp on every update; PanResponder ignores moves whose timestamp hasn't advanced.
1048
+ static const auto s_timestampOrigin = std::chrono::steady_clock::now();
1047
1049
  activeTouch.touch.timestamp = static_cast<facebook::react::Float>(
1048
- std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch())
1049
- .count());
1050
+ std::chrono::duration<double>(std::chrono::steady_clock::now() - s_timestampOrigin).count());
1050
1051
  activeTouch.touch.force = 0;
1051
1052
  // activeTouch.touch.isBarrelButton = false;
1052
1053
  // activeTouch.touch.shiftKey = false;