react-native-windows 0.78.4 → 0.78.6

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 (191) hide show
  1. package/Directory.Build.props +6 -4
  2. package/Folly/Folly.vcxproj +46 -6
  3. package/Folly/Folly.vcxproj.filters +16 -4
  4. package/Folly/TEMP_UntilFollyUpdate/ConstexprMath.h +26 -18
  5. package/Folly/TEMP_UntilFollyUpdate/Conv.cpp +1205 -0
  6. package/Folly/TEMP_UntilFollyUpdate/chrono/Hardware.h +155 -0
  7. package/Folly/TEMP_UntilFollyUpdate/concurrency/CacheLocality.cpp +633 -0
  8. package/Folly/TEMP_UntilFollyUpdate/{dynamic-inl.h → json/dynamic-inl.h} +3 -4
  9. package/Folly/TEMP_UntilFollyUpdate/{json.cpp → json/json.cpp} +14 -10
  10. package/Folly/TEMP_UntilFollyUpdate/lang/SafeAssert.h +7 -14
  11. package/Folly/TEMP_UntilFollyUpdate/lang/ToAscii.h +6 -6
  12. package/Folly/ThreadNameStub.cpp +10 -0
  13. package/Folly/cgmanifest.json +11 -1
  14. package/Libraries/Components/View/View.windows.js +107 -56
  15. package/Libraries/Components/View/ViewAccessibility.d.ts +60 -1
  16. package/Libraries/Image/Image.windows.js +42 -21
  17. package/Libraries/Modal/Modal.d.ts +7 -0
  18. package/Libraries/Modal/Modal.windows.js +7 -1
  19. package/Libraries/NativeComponent/BaseViewConfig.windows.js +3 -0
  20. package/Libraries/Text/Text.d.ts +18 -0
  21. package/Microsoft.ReactNative/AsynchronousEventBeat.cpp +4 -25
  22. package/Microsoft.ReactNative/AsynchronousEventBeat.h +0 -3
  23. package/Microsoft.ReactNative/Base/FollyIncludes.h +1 -0
  24. package/Microsoft.ReactNative/CallInvoker.cpp +42 -0
  25. package/Microsoft.ReactNative/CallInvoker.h +34 -0
  26. package/Microsoft.ReactNative/{JSDispatcherWriter.cpp → CallInvokerWriter.cpp} +35 -47
  27. package/Microsoft.ReactNative/CallInvokerWriter.h +74 -0
  28. package/Microsoft.ReactNative/CompositionComponentView.idl +0 -5
  29. package/Microsoft.ReactNative/CompositionSwitcher.idl +7 -0
  30. package/Microsoft.ReactNative/Fabric/AbiViewProps.cpp +8 -10
  31. package/Microsoft.ReactNative/Fabric/ComponentView.cpp +4 -1
  32. package/Microsoft.ReactNative/Fabric/Composition/ActivityIndicatorComponentView.cpp +12 -2
  33. package/Microsoft.ReactNative/Fabric/Composition/ActivityIndicatorComponentView.h +2 -0
  34. package/Microsoft.ReactNative/Fabric/Composition/CompositionAnnotationProvider.cpp +100 -0
  35. package/Microsoft.ReactNative/Fabric/Composition/CompositionAnnotationProvider.h +31 -0
  36. package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +77 -11
  37. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +43 -1
  38. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.h +7 -0
  39. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +86 -56
  40. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +5 -1
  41. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.cpp +0 -4
  42. package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService.cpp +0 -2
  43. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +118 -63
  44. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +2 -0
  45. package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp +133 -8
  46. package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h +16 -2
  47. package/Microsoft.ReactNative/Fabric/Composition/FocusManager.cpp +4 -2
  48. package/Microsoft.ReactNative/Fabric/Composition/FocusManager.h +9 -1
  49. package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp +34 -11
  50. package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.h +3 -0
  51. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +133 -135
  52. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +9 -6
  53. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +46 -49
  54. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +6 -1
  55. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +13 -8
  56. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +5 -2
  57. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +146 -25
  58. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.h +14 -0
  59. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +160 -12
  60. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +6 -0
  61. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputEventEmitter.cpp +47 -0
  62. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputEventEmitter.h +15 -1
  63. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputProps.cpp +6 -2
  64. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputProps.h +4 -1
  65. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.cpp +7 -9
  66. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.h +4 -1
  67. package/Microsoft.ReactNative/Fabric/Composition/Theme.cpp +5 -0
  68. package/Microsoft.ReactNative/Fabric/Composition/TooltipService.cpp +40 -36
  69. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +68 -0
  70. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +11 -0
  71. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +70 -13
  72. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.h +10 -2
  73. package/Microsoft.ReactNative/Fabric/ImageManager.cpp +5 -5
  74. package/Microsoft.ReactNative/Fabric/ImageRequestParams.cpp +26 -0
  75. package/Microsoft.ReactNative/Fabric/WindowsImageManager.cpp +47 -8
  76. package/Microsoft.ReactNative/Fabric/WindowsImageManager.h +10 -1
  77. package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/CompositionAccessibilityProps.h +67 -0
  78. package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewEventEmitter.cpp +22 -4
  79. package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewEventEmitter.h +15 -2
  80. package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewProps.cpp +20 -0
  81. package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewProps.h +5 -0
  82. package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/MouseEvent.h +20 -0
  83. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/HostPlatformColor.h +5 -8
  84. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorParser.h +1 -2
  85. package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.cpp +247 -45
  86. package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.h +15 -0
  87. package/Microsoft.ReactNative/Fabric/platform/react/threading/MessageQueueThreadImpl.cpp +39 -0
  88. package/Microsoft.ReactNative/Fabric/platform/react/threading/MessageQueueThreadImpl.h +54 -0
  89. package/Microsoft.ReactNative/Fabric/platform/react/threading/TaskDispatchThread.cpp +126 -0
  90. package/Microsoft.ReactNative/Fabric/platform/react/threading/TaskDispatchThread.h +73 -0
  91. package/Microsoft.ReactNative/IReactContext.cpp +17 -0
  92. package/Microsoft.ReactNative/IReactContext.h +1 -0
  93. package/Microsoft.ReactNative/IReactContext.idl +18 -1
  94. package/Microsoft.ReactNative/IReactDispatcher.idl +1 -0
  95. package/Microsoft.ReactNative/IReactModuleBuilder.cpp +12 -0
  96. package/Microsoft.ReactNative/IReactModuleBuilder.h +2 -0
  97. package/Microsoft.ReactNative/IReactModuleBuilder.idl +8 -0
  98. package/Microsoft.ReactNative/JsiApi.cpp +10 -2
  99. package/Microsoft.ReactNative/JsiApi.h +1 -0
  100. package/Microsoft.ReactNative/JsiApi.idl +1 -0
  101. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +0 -3
  102. package/Microsoft.ReactNative/Modules/AccessibilityInfoModule.cpp +2 -3
  103. package/Microsoft.ReactNative/Modules/AlertModule.cpp +7 -12
  104. package/Microsoft.ReactNative/Modules/Animated/AnimationDriver.cpp +2 -1
  105. package/Microsoft.ReactNative/Modules/Animated/NativeAnimatedModule.cpp +4 -8
  106. package/Microsoft.ReactNative/Modules/AppStateModule.cpp +2 -2
  107. package/Microsoft.ReactNative/Modules/ClipboardModule.cpp +6 -8
  108. package/Microsoft.ReactNative/Modules/ClipboardModule.h +1 -1
  109. package/Microsoft.ReactNative/Modules/ImageViewManagerModule.cpp +6 -15
  110. package/Microsoft.ReactNative/Modules/NativeUIManager.cpp +13 -24
  111. package/Microsoft.ReactNative/QuirkSettings.cpp +0 -16
  112. package/Microsoft.ReactNative/QuirkSettings.h +0 -3
  113. package/Microsoft.ReactNative/ReactHost/ReactHost.cpp +11 -1
  114. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +78 -68
  115. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +1 -2
  116. package/Microsoft.ReactNative/ReactInstanceSettings.cpp +12 -0
  117. package/Microsoft.ReactNative/ReactInstanceSettings.h +2 -0
  118. package/Microsoft.ReactNative/ReactInstanceSettings.idl +6 -0
  119. package/Microsoft.ReactNative/ReactNativeIsland.idl +3 -0
  120. package/Microsoft.ReactNative/ReactSupport.cpp +44 -11
  121. package/Microsoft.ReactNative/RedBox.cpp +30 -1
  122. package/Microsoft.ReactNative/SchedulerSettings.cpp +4 -4
  123. package/Microsoft.ReactNative/SchedulerSettings.h +1 -1
  124. package/Microsoft.ReactNative/TurboModulesProvider.cpp +30 -12
  125. package/Microsoft.ReactNative/Utils/ImageUtils.h +1 -0
  126. package/Microsoft.ReactNative/Utils/LocalBundleReader.cpp +37 -31
  127. package/Microsoft.ReactNative.Cxx/ApiLoaders/JSRuntimeApi.cpp +1 -0
  128. package/Microsoft.ReactNative.Cxx/ApiLoaders/JSRuntimeApi.inc +2 -0
  129. package/Microsoft.ReactNative.Cxx/ApiLoaders/NodeApi_posix.cpp +1 -1
  130. package/Microsoft.ReactNative.Cxx/JSI/JsiAbiApi.cpp +94 -27
  131. package/Microsoft.ReactNative.Cxx/JSI/JsiAbiApi.h +27 -6
  132. package/Microsoft.ReactNative.Cxx/JSI/JsiApiContext.cpp +45 -11
  133. package/Microsoft.ReactNative.Cxx/JSI/JsiApiContext.h +6 -0
  134. package/Microsoft.ReactNative.Cxx/JSI/decorator.h +220 -0
  135. package/Microsoft.ReactNative.Cxx/JSI/instrumentation.h +28 -0
  136. package/Microsoft.ReactNative.Cxx/JSI/jsi-inl.h +6 -0
  137. package/Microsoft.ReactNative.Cxx/JSI/jsi.cpp +241 -4
  138. package/Microsoft.ReactNative.Cxx/JSI/jsi.h +207 -19
  139. package/Microsoft.ReactNative.Cxx/JSValue.cpp +19 -3
  140. package/Microsoft.ReactNative.Cxx/JSValue.h +15 -7
  141. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +2 -2
  142. package/Microsoft.ReactNative.Cxx/NativeModules.h +60 -2
  143. package/Microsoft.ReactNative.Cxx/NodeApiJsiRuntime.cpp +1267 -614
  144. package/Microsoft.ReactNative.Cxx/NodeApiJsiRuntime.h +4 -2
  145. package/Microsoft.ReactNative.Cxx/ReactContext.h +7 -0
  146. package/Microsoft.ReactNative.Cxx/TurboModuleProvider.cpp +11 -13
  147. package/Microsoft.ReactNative.Cxx/TurboModuleProvider.h +2 -3
  148. package/Microsoft.ReactNative.Cxx/node-api/js_native_api.h +81 -20
  149. package/Microsoft.ReactNative.Cxx/node-api/js_native_api_types.h +47 -2
  150. package/Microsoft.ReactNative.Cxx/node-api/js_runtime_api.h +13 -0
  151. package/Microsoft.ReactNative.Cxx/stubs/glog/logging.h +1 -1
  152. package/Microsoft.ReactNative.Managed/ReactContext.cs +3 -1
  153. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  154. package/PropertySheets/JSEngine.props +1 -1
  155. package/PropertySheets/React.Cpp.props +2 -1
  156. package/PropertySheets/WebView2.props +1 -1
  157. package/PropertySheets/WinUI.props +2 -2
  158. package/ReactCommon/TEMP_UntilReactCommonUpdate/jserrorhandler/JsErrorHandler.cpp +429 -0
  159. package/ReactCommon/cgmanifest.json +1 -1
  160. package/Shared/HermesRuntimeHolder.cpp +6 -0
  161. package/Shared/JSI/ChakraRuntime.cpp +4 -0
  162. package/Shared/JSI/ChakraRuntime.h +2 -0
  163. package/Shared/Modules/BlobModule.cpp +14 -16
  164. package/Shared/Modules/BlobModule.h +3 -1
  165. package/Shared/Networking/WinRTWebSocketResource.cpp +82 -101
  166. package/Shared/Networking/WinRTWebSocketResource.h +91 -7
  167. package/Shared/Shared.vcxitems +11 -7
  168. package/Shared/Shared.vcxitems.filters +6 -1
  169. package/Shared/TurboModuleManager.cpp +0 -15
  170. package/codegen/react/components/rnwcore/ActivityIndicatorView.g.h +6 -6
  171. package/codegen/react/components/rnwcore/AndroidDrawerLayout.g.h +6 -6
  172. package/codegen/react/components/rnwcore/AndroidHorizontalScrollContentView.g.h +6 -6
  173. package/codegen/react/components/rnwcore/AndroidProgressBar.g.h +6 -6
  174. package/codegen/react/components/rnwcore/AndroidSwipeRefreshLayout.g.h +6 -6
  175. package/codegen/react/components/rnwcore/AndroidSwitch.g.h +6 -6
  176. package/codegen/react/components/rnwcore/DebuggingOverlay.g.h +6 -6
  177. package/codegen/react/components/rnwcore/InputAccessory.g.h +6 -6
  178. package/codegen/react/components/rnwcore/ModalHostView.g.h +11 -7
  179. package/codegen/react/components/rnwcore/Props.cpp +2 -1
  180. package/codegen/react/components/rnwcore/Props.h +1 -0
  181. package/codegen/react/components/rnwcore/PullToRefreshView.g.h +6 -6
  182. package/codegen/react/components/rnwcore/SafeAreaView.g.h +6 -6
  183. package/codegen/react/components/rnwcore/Switch.g.h +6 -6
  184. package/codegen/react/components/rnwcore/UnimplementedNativeView.g.h +6 -6
  185. package/index.windows.js +4 -2
  186. package/package.json +3 -4
  187. package/src/private/specs/components/RCTModalHostViewNativeComponent.js +8 -0
  188. package/stubs/glog/logging.h +1 -1
  189. package/Microsoft.ReactNative/JSDispatcherWriter.h +0 -47
  190. package/Microsoft.ReactNative/SynchronousEventBeat.cpp +0 -51
  191. package/Microsoft.ReactNative/SynchronousEventBeat.h +0 -31
@@ -24,3 +24,4 @@
24
24
  #include <folly/Optional.h>
25
25
  #include <folly/dynamic.h>
26
26
  #include <folly/json.h>
27
+ #include <folly/json/dynamic.h>
@@ -0,0 +1,42 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #include "CallInvoker.h"
5
+
6
+ #include "CallInvoker.g.cpp"
7
+ #include "JsiApi.h"
8
+
9
+ namespace winrt::Microsoft::ReactNative::implementation {
10
+
11
+ static const ReactPropertyId<winrt::Microsoft::ReactNative::CallInvoker> &CallInvokerPropertyId() noexcept {
12
+ static const ReactPropertyId<winrt::Microsoft::ReactNative::CallInvoker> prop{L"ReactNative", L"CallInvoker"};
13
+ return prop;
14
+ }
15
+
16
+ CallInvoker::CallInvoker(
17
+ Mso::React::IReactContext &reactContext,
18
+ std::shared_ptr<facebook::react::CallInvoker> callInvoker) noexcept
19
+ : m_callInvoker(callInvoker), m_context(&reactContext) {}
20
+
21
+ void CallInvoker::InvokeAsync(CallFunc func) noexcept {
22
+ m_callInvoker->invokeAsync(
23
+ [reactContext = m_context, func](facebook::jsi::Runtime & /*runtime*/) { func(reactContext->JsiRuntime()); });
24
+ }
25
+
26
+ void CallInvoker::InvokeSync(CallFunc func) noexcept {
27
+ m_callInvoker->invokeSync(
28
+ [reactContext = m_context, func](facebook::jsi::Runtime & /*runtime*/) { func(reactContext->JsiRuntime()); });
29
+ }
30
+
31
+ winrt::Microsoft::ReactNative::CallInvoker CallInvoker::FromProperties(
32
+ const winrt::Microsoft::ReactNative::ReactPropertyBag &properties) noexcept {
33
+ return properties.Get(CallInvokerPropertyId());
34
+ }
35
+
36
+ void CallInvoker::SetProperties(
37
+ const winrt::Microsoft::ReactNative::ReactPropertyBag &properties,
38
+ winrt::Microsoft::ReactNative::CallInvoker invoker) noexcept {
39
+ properties.Set(CallInvokerPropertyId(), invoker);
40
+ }
41
+
42
+ } // namespace winrt::Microsoft::ReactNative::implementation
@@ -0,0 +1,34 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #pragma once
5
+
6
+ #include <ReactHost/MsoReactContext.h>
7
+ #include <ReactPropertyBag.h>
8
+ #include "ReactHost/React.h"
9
+ #include "winrt/Microsoft.ReactNative.h"
10
+
11
+ #include "CallInvoker.g.h"
12
+
13
+ namespace winrt::Microsoft::ReactNative::implementation {
14
+
15
+ struct CallInvoker : CallInvokerT<CallInvoker> {
16
+ CallInvoker(
17
+ Mso::React::IReactContext &reactContext,
18
+ std::shared_ptr<facebook::react::CallInvoker> callInvoker) noexcept;
19
+
20
+ void InvokeAsync(CallFunc func) noexcept;
21
+ void InvokeSync(CallFunc func) noexcept;
22
+
23
+ static winrt::Microsoft::ReactNative::CallInvoker FromProperties(
24
+ const winrt::Microsoft::ReactNative::ReactPropertyBag &properties) noexcept;
25
+ static void SetProperties(
26
+ const winrt::Microsoft::ReactNative::ReactPropertyBag &properties,
27
+ winrt::Microsoft::ReactNative::CallInvoker invoker) noexcept;
28
+
29
+ private:
30
+ Mso::CntPtr<Mso::React::IReactContext> m_context;
31
+ std::shared_ptr<facebook::react::CallInvoker> m_callInvoker;
32
+ };
33
+
34
+ } // namespace winrt::Microsoft::ReactNative::implementation
@@ -2,47 +2,33 @@
2
2
  // Licensed under the MIT License.
3
3
 
4
4
  #include "pch.h"
5
- #include "JSDispatcherWriter.h"
5
+ #include "CallInvokerWriter.h"
6
6
  #include <JSI/JSIDynamic.h>
7
7
  #include <crash/verifyElseCrash.h>
8
8
 
9
9
  namespace winrt::Microsoft::ReactNative {
10
10
 
11
- // Special IJSValueWriter that does nothing.
12
- // We use it instead of JsiWriter when JSI runtime is not available anymore.
13
- struct JSNoopWriter : winrt::implements<JSNoopWriter, IJSValueWriter> {
14
- public: // IJSValueWriter
15
- void WriteNull() noexcept;
16
- void WriteBoolean(bool value) noexcept;
17
- void WriteInt64(int64_t value) noexcept;
18
- void WriteDouble(double value) noexcept;
19
- void WriteString(const winrt::hstring &value) noexcept;
20
- void WriteObjectBegin() noexcept;
21
- void WritePropertyName(const winrt::hstring &name) noexcept;
22
- void WriteObjectEnd() noexcept;
23
- void WriteArrayBegin() noexcept;
24
- void WriteArrayEnd() noexcept;
25
- };
26
-
27
11
  //===========================================================================
28
- // JSDispatcherWriter implementation
12
+ // CallInvokerWriter implementation
29
13
  //===========================================================================
30
14
 
31
- JSDispatcherWriter::JSDispatcherWriter(
32
- IReactDispatcher const &jsDispatcher,
15
+ CallInvokerWriter::CallInvokerWriter(
16
+ const std::shared_ptr<facebook::react::CallInvoker> &jsInvoker,
33
17
  std::weak_ptr<LongLivedJsiRuntime> jsiRuntimeHolder) noexcept
34
- : m_jsDispatcher(jsDispatcher), m_jsiRuntimeHolder(std::move(jsiRuntimeHolder)) {}
18
+ : m_callInvoker(jsInvoker),
19
+ m_jsiRuntimeHolder(std::move(jsiRuntimeHolder)),
20
+ m_threadId(std::this_thread::get_id()) {}
35
21
 
36
- JSDispatcherWriter::~JSDispatcherWriter() {
22
+ CallInvokerWriter::~CallInvokerWriter() {
37
23
  if (auto jsiRuntimeHolder = m_jsiRuntimeHolder.lock()) {
38
24
  jsiRuntimeHolder->allowRelease();
39
25
  }
40
26
  }
41
27
 
42
- void JSDispatcherWriter::WithResultArgs(
28
+ void CallInvokerWriter::WithResultArgs(
43
29
  Mso::Functor<void(facebook::jsi::Runtime &rt, facebook::jsi::Value const *args, size_t argCount)>
44
30
  handler) noexcept {
45
- if (m_jsDispatcher.HasThreadAccess()) {
31
+ if (m_threadId == std::this_thread::get_id() && m_fastPath) {
46
32
  VerifyElseCrash(!m_dynamicWriter);
47
33
  if (auto jsiRuntimeHolder = m_jsiRuntimeHolder.lock()) {
48
34
  const facebook::jsi::Value *args{nullptr};
@@ -55,64 +41,62 @@ void JSDispatcherWriter::WithResultArgs(
55
41
  VerifyElseCrash(!m_jsiWriter);
56
42
  folly::dynamic dynValue = m_dynamicWriter->TakeValue();
57
43
  VerifyElseCrash(dynValue.isArray());
58
- m_jsDispatcher.Post(
59
- [handler, dynValue = std::move(dynValue), weakJsiRuntimeHolder = m_jsiRuntimeHolder, self = get_strong()]() {
60
- if (auto jsiRuntimeHolder = weakJsiRuntimeHolder.lock()) {
61
- std::vector<facebook::jsi::Value> args;
62
- args.reserve(dynValue.size());
63
- auto &runtime = jsiRuntimeHolder->Runtime();
64
- for (auto const &item : dynValue) {
65
- args.emplace_back(facebook::jsi::valueFromDynamic(runtime, item));
66
- }
67
- handler(runtime, args.data(), args.size());
44
+ m_callInvoker->invokeAsync(
45
+ [handler, dynValue = std::move(dynValue), weakJsiRuntimeHolder = m_jsiRuntimeHolder, self = get_strong()](
46
+ facebook::jsi::Runtime &runtime) {
47
+ std::vector<facebook::jsi::Value> args;
48
+ args.reserve(dynValue.size());
49
+ for (auto const &item : dynValue) {
50
+ args.emplace_back(facebook::jsi::valueFromDynamic(runtime, item));
68
51
  }
52
+ handler(runtime, args.data(), args.size());
69
53
  });
70
54
  }
71
55
  }
72
56
 
73
- void JSDispatcherWriter::WriteNull() noexcept {
57
+ void CallInvokerWriter::WriteNull() noexcept {
74
58
  GetWriter().WriteNull();
75
59
  }
76
60
 
77
- void JSDispatcherWriter::WriteBoolean(bool value) noexcept {
61
+ void CallInvokerWriter::WriteBoolean(bool value) noexcept {
78
62
  GetWriter().WriteBoolean(value);
79
63
  }
80
64
 
81
- void JSDispatcherWriter::WriteInt64(int64_t value) noexcept {
65
+ void CallInvokerWriter::WriteInt64(int64_t value) noexcept {
82
66
  GetWriter().WriteInt64(value);
83
67
  }
84
68
 
85
- void JSDispatcherWriter::WriteDouble(double value) noexcept {
69
+ void CallInvokerWriter::WriteDouble(double value) noexcept {
86
70
  GetWriter().WriteDouble(value);
87
71
  }
88
72
 
89
- void JSDispatcherWriter::WriteString(const winrt::hstring &value) noexcept {
73
+ void CallInvokerWriter::WriteString(const winrt::hstring &value) noexcept {
90
74
  GetWriter().WriteString(value);
91
75
  }
92
76
 
93
- void JSDispatcherWriter::WriteObjectBegin() noexcept {
77
+ void CallInvokerWriter::WriteObjectBegin() noexcept {
94
78
  GetWriter().WriteObjectBegin();
95
79
  }
96
80
 
97
- void JSDispatcherWriter::WritePropertyName(const winrt::hstring &name) noexcept {
81
+ void CallInvokerWriter::WritePropertyName(const winrt::hstring &name) noexcept {
98
82
  GetWriter().WritePropertyName(name);
99
83
  }
100
84
 
101
- void JSDispatcherWriter::WriteObjectEnd() noexcept {
85
+ void CallInvokerWriter::WriteObjectEnd() noexcept {
102
86
  GetWriter().WriteObjectEnd();
103
87
  }
104
88
 
105
- void JSDispatcherWriter::WriteArrayBegin() noexcept {
89
+ void CallInvokerWriter::WriteArrayBegin() noexcept {
106
90
  GetWriter().WriteArrayBegin();
107
91
  }
108
92
 
109
- void JSDispatcherWriter::WriteArrayEnd() noexcept {
93
+ void CallInvokerWriter::WriteArrayEnd() noexcept {
110
94
  GetWriter().WriteArrayEnd();
111
95
  }
112
96
 
113
- IJSValueWriter JSDispatcherWriter::GetWriter() noexcept {
97
+ IJSValueWriter CallInvokerWriter::GetWriter() noexcept {
114
98
  if (!m_writer) {
115
- if (m_jsDispatcher.HasThreadAccess()) {
99
+ if (m_threadId == std::this_thread::get_id() && m_fastPath) {
116
100
  if (auto jsiRuntimeHolder = m_jsiRuntimeHolder.lock()) {
117
101
  m_jsiWriter = winrt::make_self<JsiWriter>(jsiRuntimeHolder->Runtime());
118
102
  m_writer = m_jsiWriter.as<IJSValueWriter>();
@@ -124,10 +108,14 @@ IJSValueWriter JSDispatcherWriter::GetWriter() noexcept {
124
108
  m_writer = m_dynamicWriter.as<IJSValueWriter>();
125
109
  }
126
110
  }
127
- Debug(VerifyElseCrash(m_dynamicWriter != nullptr || m_jsDispatcher.HasThreadAccess()));
111
+ Debug(VerifyElseCrash(m_dynamicWriter != nullptr || (m_threadId == std::this_thread::get_id() && m_fastPath)));
128
112
  return m_writer;
129
113
  }
130
114
 
115
+ void CallInvokerWriter::ExitCurrentCallInvokeScope() noexcept {
116
+ m_fastPath = false;
117
+ }
118
+
131
119
  //===========================================================================
132
120
  // JSNoopWriter implementation
133
121
  //===========================================================================
@@ -0,0 +1,74 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ #pragma once
4
+
5
+ #include <JSI/LongLivedJsiValue.h>
6
+ #include <ReactCommon/CallInvoker.h>
7
+ #include <functional/functor.h>
8
+ #include "DynamicWriter.h"
9
+ #include "JsiWriter.h"
10
+ #include "winrt/Microsoft.ReactNative.h"
11
+
12
+ namespace winrt::Microsoft::ReactNative {
13
+
14
+ // IJSValueWriter to ensure that JsiWriter is always used from a RuntimeExecutor.
15
+ // In case if writing is done outside of RuntimeExecutor, it uses DynamicWriter to create
16
+ // folly::dynamic which then is written to JsiWriter in RuntimeExecutor.
17
+ struct CallInvokerWriter : winrt::implements<CallInvokerWriter, IJSValueWriter> {
18
+ ~CallInvokerWriter();
19
+ CallInvokerWriter(
20
+ const std::shared_ptr<facebook::react::CallInvoker> &jsInvoker,
21
+ std::weak_ptr<LongLivedJsiRuntime> jsiRuntimeHolder) noexcept;
22
+ void WithResultArgs(Mso::Functor<void(facebook::jsi::Runtime &rt, facebook::jsi::Value const *args, size_t argCount)>
23
+ handler) noexcept;
24
+
25
+ public: // IJSValueWriter
26
+ void WriteNull() noexcept;
27
+ void WriteBoolean(bool value) noexcept;
28
+ void WriteInt64(int64_t value) noexcept;
29
+ void WriteDouble(double value) noexcept;
30
+ void WriteString(const winrt::hstring &value) noexcept;
31
+ void WriteObjectBegin() noexcept;
32
+ void WritePropertyName(const winrt::hstring &name) noexcept;
33
+ void WriteObjectEnd() noexcept;
34
+ void WriteArrayBegin() noexcept;
35
+ void WriteArrayEnd() noexcept;
36
+
37
+ // This should be called before the code flow exits the scope of the CallInvoker,
38
+ // thus requiring the CallInokerWriter to call m_callInvoker->invokeAsync to call back into JS.
39
+ void ExitCurrentCallInvokeScope() noexcept;
40
+
41
+ private:
42
+ IJSValueWriter GetWriter() noexcept;
43
+
44
+ private:
45
+ const std::shared_ptr<facebook::react::CallInvoker> m_callInvoker;
46
+ std::weak_ptr<LongLivedJsiRuntime> m_jsiRuntimeHolder;
47
+ winrt::com_ptr<DynamicWriter> m_dynamicWriter;
48
+ winrt::com_ptr<JsiWriter> m_jsiWriter;
49
+ IJSValueWriter m_writer;
50
+
51
+ // If a callback is invoked synchronously we can call the JS callback directly.
52
+ // However, if we post to another thread, or call the callback on the same thread but after we exit the current
53
+ // RuntimeExecutor callback, then we need to save the callback args in a dynamic and post it back to the CallInvoker
54
+ bool m_fastPath{true};
55
+ const std::thread::id m_threadId;
56
+ };
57
+
58
+ // Special IJSValueWriter that does nothing.
59
+ // We use it instead of JsiWriter when JSI runtime is not available anymore.
60
+ struct JSNoopWriter : winrt::implements<JSNoopWriter, IJSValueWriter> {
61
+ public: // IJSValueWriter
62
+ void WriteNull() noexcept;
63
+ void WriteBoolean(bool value) noexcept;
64
+ void WriteInt64(int64_t value) noexcept;
65
+ void WriteDouble(double value) noexcept;
66
+ void WriteString(const winrt::hstring &value) noexcept;
67
+ void WriteObjectBegin() noexcept;
68
+ void WritePropertyName(const winrt::hstring &name) noexcept;
69
+ void WriteObjectEnd() noexcept;
70
+ void WriteArrayBegin() noexcept;
71
+ void WriteArrayEnd() noexcept;
72
+ };
73
+
74
+ } // namespace winrt::Microsoft::ReactNative
@@ -89,11 +89,6 @@ namespace Microsoft.ReactNative.Composition
89
89
  Microsoft.ReactNative.ViewProps ViewProps { get; };
90
90
  };
91
91
 
92
- // Some other interfaces we could consider implementing/exposing
93
- // Use ifdef USE_EXPERIMENTAL_WINUI3 to add these
94
- // Microsoft.UI.Content.IContentLink // Use ifdef USE_EXPERIMENTAL_WINUI3
95
- // Microsoft.UI.Content.IContentSiteBridge
96
- // Microsoft.UI.Content.IContentSiteBridge2 // Use ifdef USE_EXPERIMENTAL_WINUI3
97
92
  [experimental]
98
93
  [webhosthidden]
99
94
  runtimeclass ContentIslandComponentView : ViewComponentView {
@@ -109,11 +109,16 @@ namespace Microsoft.ReactNative.Composition.Experimental
109
109
  void Brush(IBrush brush);
110
110
  void ScrollEnabled(Boolean isScrollEnabled);
111
111
  event Windows.Foundation.EventHandler<IScrollPositionChangedArgs> ScrollPositionChanged;
112
+ event Windows.Foundation.EventHandler<IScrollPositionChangedArgs> ScrollBeginDrag;
113
+ event Windows.Foundation.EventHandler<IScrollPositionChangedArgs> ScrollEndDrag;
112
114
  void ContentSize(Windows.Foundation.Numerics.Vector2 size);
113
115
  Windows.Foundation.Numerics.Vector3 ScrollPosition { get; };
114
116
  void ScrollBy(Windows.Foundation.Numerics.Vector3 offset, Boolean animate);
115
117
  void TryUpdatePosition(Windows.Foundation.Numerics.Vector3 position, Boolean animate);
116
118
  void OnPointerPressed(Microsoft.ReactNative.Composition.Input.PointerRoutedEventArgs args);
119
+ void SetDecelerationRate(Windows.Foundation.Numerics.Vector3 decelerationRate);
120
+ void SetMaximumZoomScale(Single maximumZoomScale);
121
+ void SetMinimumZoomScale(Single minimumZoomScale);
117
122
  Boolean Horizontal;
118
123
  }
119
124
 
@@ -123,6 +128,8 @@ namespace Microsoft.ReactNative.Composition.Experimental
123
128
  {
124
129
  void Size(Single value);
125
130
  void Brush(IBrush brush);
131
+ void StartAnimation();
132
+ void StopAnimation();
126
133
  }
127
134
 
128
135
  [webhosthidden]
@@ -77,14 +77,12 @@ winrt::Microsoft::ReactNative::Color Color::ReadValue(
77
77
  switch (reader.ValueType()) {
78
78
  case JSValueType::Int64: {
79
79
  auto argb = reader.GetInt64();
80
- return winrt::make<Color>(facebook::react::Color{
81
- /*m_isDefined*/ true,
82
- /*color*/
83
- {static_cast<uint8_t>((argb >> 24) & 0xFF),
84
- static_cast<uint8_t>((argb >> 16) & 0xFF),
85
- static_cast<uint8_t>((argb >> 8) & 0xFF),
86
- static_cast<uint8_t>(argb & 0xFF)},
87
- {}});
80
+ return winrt::make<Color>(facebook::react::Color{/*color*/
81
+ {static_cast<uint8_t>((argb >> 24) & 0xFF),
82
+ static_cast<uint8_t>((argb >> 16) & 0xFF),
83
+ static_cast<uint8_t>((argb >> 8) & 0xFF),
84
+ static_cast<uint8_t>(argb & 0xFF)},
85
+ {}});
88
86
  }
89
87
  case JSValueType::Object: {
90
88
  std::vector<std::string> platformColors;
@@ -96,10 +94,10 @@ winrt::Microsoft::ReactNative::Color Color::ReadValue(
96
94
  SkipValue<JSValue>(reader); // Skip this property
97
95
  }
98
96
  }
99
- return winrt::make<Color>(facebook::react::Color{/*m_isDefined*/ true, /*color*/ {}, std::move(platformColors)});
97
+ return winrt::make<Color>(facebook::react::Color{/*color*/ {}, std::move(platformColors)});
100
98
  }
101
99
  default:
102
- return winrt::make<Color>(facebook::react::Color{/*m_isDefined*/ false, /*color*/ {0, 0, 0, 0}, {}});
100
+ return winrt::make<Color>(facebook::react::Color{/*color*/ {0, 0, 0, 0}, {}});
103
101
  }
104
102
  }
105
103
 
@@ -279,7 +279,10 @@ void ComponentView::parent(const winrt::Microsoft::ReactNative::ComponentView &p
279
279
  m_parent = parent;
280
280
  if (!parent) {
281
281
  if (oldRootView && oldRootView->GetFocusedComponent() == *this) {
282
- oldRootView->TrySetFocusedComponent(oldParent, winrt::Microsoft::ReactNative::FocusNavigationDirection::None);
282
+ oldRootView->TrySetFocusedComponent(
283
+ oldParent,
284
+ winrt::Microsoft::ReactNative::FocusNavigationDirection::None,
285
+ true /*forceNoSelectionIfCannotMove*/);
283
286
  }
284
287
  }
285
288
  if (parent) {
@@ -67,8 +67,18 @@ void ActivityIndicatorComponentView::updateProps(
67
67
  updateProgressColor(newViewProps->color);
68
68
  }
69
69
 
70
- if (newViewProps->animating != oldViewProps->animating) {
71
- m_ActivityIndicatorVisual.IsVisible(newViewProps->animating);
70
+ if (newViewProps->animating != oldViewProps->animating ||
71
+ newViewProps->hidesWhenStopped != oldViewProps->hidesWhenStopped) {
72
+ bool setHidden = (newViewProps->hidesWhenStopped && !newViewProps->animating);
73
+ m_ActivityIndicatorVisual.IsVisible(!setHidden);
74
+
75
+ if (!newViewProps->animating && !newViewProps->hidesWhenStopped) {
76
+ m_animationStopped = true;
77
+ m_ActivityIndicatorVisual.StopAnimation();
78
+ } else if (m_animationStopped) {
79
+ m_ActivityIndicatorVisual.StartAnimation();
80
+ m_animationStopped = false;
81
+ }
72
82
  }
73
83
  }
74
84
 
@@ -53,6 +53,8 @@ struct ActivityIndicatorComponentView
53
53
  void updateVisualSize() noexcept;
54
54
  void updateProgressColor(const facebook::react::SharedColor &color) noexcept;
55
55
 
56
+ bool m_animationStopped{false};
57
+
56
58
  winrt::Microsoft::ReactNative::Composition::Experimental::IActivityVisual m_ActivityIndicatorVisual{nullptr};
57
59
  };
58
60
 
@@ -0,0 +1,100 @@
1
+ #include "pch.h"
2
+ #include "CompositionAnnotationProvider.h"
3
+ #include <Fabric/ComponentView.h>
4
+ #include <Unicode.h>
5
+ #include "RootComponentView.h"
6
+ #include "UiaHelpers.h"
7
+
8
+ namespace winrt::Microsoft::ReactNative::implementation {
9
+
10
+ CompositionAnnotationProvider::CompositionAnnotationProvider(
11
+ const winrt::Microsoft::ReactNative::Composition::ComponentView &componentView,
12
+ CompositionDynamicAutomationProvider *parentProvider) noexcept
13
+ : m_view{componentView} {
14
+ m_parentProvider.copy_from(parentProvider);
15
+ }
16
+ HRESULT __stdcall CompositionAnnotationProvider::get_AnnotationTypeId(int *retVal) {
17
+ if (retVal == nullptr)
18
+ return E_POINTER;
19
+ auto strongView = m_view.view();
20
+
21
+ if (!strongView)
22
+ return UIA_E_ELEMENTNOTAVAILABLE;
23
+
24
+ auto props = std::static_pointer_cast<const facebook::react::ViewProps>(
25
+ winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(strongView)->props());
26
+ if (props == nullptr)
27
+ return UIA_E_ELEMENTNOTAVAILABLE;
28
+
29
+ if (props->accessibilityAnnotation.value().typeID.empty()) {
30
+ return E_FAIL;
31
+ }
32
+ *retVal = static_cast<int>(GetAnnotationTypeId(props->accessibilityAnnotation.value().typeID));
33
+ return S_OK;
34
+ }
35
+ HRESULT __stdcall CompositionAnnotationProvider::get_AnnotationTypeName(BSTR *retVal) {
36
+ if (retVal == nullptr)
37
+ return E_POINTER;
38
+ auto strongView = m_view.view();
39
+
40
+ if (!strongView)
41
+ return UIA_E_ELEMENTNOTAVAILABLE;
42
+
43
+ auto props = std::static_pointer_cast<const facebook::react::ViewProps>(
44
+ winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(strongView)->props());
45
+ if (props == nullptr)
46
+ return UIA_E_ELEMENTNOTAVAILABLE;
47
+
48
+ if (props->accessibilityAnnotation.value().typeName.empty()) {
49
+ return E_FAIL;
50
+ }
51
+ auto typeName = ::Microsoft::Common::Unicode::Utf8ToUtf16(props->accessibilityAnnotation.value().typeName);
52
+ *retVal = SysAllocString(typeName.c_str());
53
+ return S_OK;
54
+ }
55
+ HRESULT __stdcall CompositionAnnotationProvider::get_Author(BSTR *retVal) {
56
+ if (retVal == nullptr)
57
+ return E_POINTER;
58
+ auto strongView = m_view.view();
59
+
60
+ if (!strongView)
61
+ return UIA_E_ELEMENTNOTAVAILABLE;
62
+
63
+ auto props = std::static_pointer_cast<const facebook::react::ViewProps>(
64
+ winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(strongView)->props());
65
+ if (props == nullptr)
66
+ return UIA_E_ELEMENTNOTAVAILABLE;
67
+
68
+ if (props->accessibilityAnnotation.value().author.empty()) {
69
+ return E_FAIL;
70
+ }
71
+ auto author = ::Microsoft::Common::Unicode::Utf8ToUtf16(props->accessibilityAnnotation.value().author);
72
+ *retVal = SysAllocString(author.c_str());
73
+ return S_OK;
74
+ }
75
+ HRESULT __stdcall CompositionAnnotationProvider::get_DateTime(BSTR *retVal) {
76
+ if (retVal == nullptr)
77
+ return E_POINTER;
78
+ auto strongView = m_view.view();
79
+
80
+ if (!strongView)
81
+ return UIA_E_ELEMENTNOTAVAILABLE;
82
+
83
+ auto props = std::static_pointer_cast<const facebook::react::ViewProps>(
84
+ winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(strongView)->props());
85
+ if (props == nullptr)
86
+ return UIA_E_ELEMENTNOTAVAILABLE;
87
+
88
+ if (props->accessibilityAnnotation.value().dateTime.empty()) {
89
+ return E_FAIL;
90
+ }
91
+ auto dateTime = ::Microsoft::Common::Unicode::Utf8ToUtf16(props->accessibilityAnnotation.value().dateTime);
92
+ *retVal = SysAllocString(dateTime.c_str());
93
+ return S_OK;
94
+ }
95
+
96
+ HRESULT __stdcall CompositionAnnotationProvider::get_Target(IRawElementProviderSimple **retVal) {
97
+ // no-opt
98
+ return E_NOTIMPL;
99
+ }
100
+ } // namespace winrt::Microsoft::ReactNative::implementation
@@ -0,0 +1,31 @@
1
+ #pragma once
2
+
3
+ #include <Fabric/Composition/CompositionDynamicAutomationProvider.h>
4
+ #include <Fabric/Composition/CompositionViewComponentView.h>
5
+ #include <Fabric/ReactTaggedView.h>
6
+ #include <UIAutomation.h>
7
+ #include <inspectable.h>
8
+ #include <uiautomationcore.h>
9
+
10
+ namespace winrt::Microsoft::ReactNative::implementation {
11
+
12
+ class CompositionAnnotationProvider : public winrt::implements<CompositionAnnotationProvider, IAnnotationProvider> {
13
+ public:
14
+ CompositionAnnotationProvider(
15
+ const winrt::Microsoft::ReactNative::Composition::ComponentView &componentView,
16
+ CompositionDynamicAutomationProvider *parentProvider) noexcept;
17
+
18
+ // inherited via IAnnotationProvider
19
+ virtual HRESULT __stdcall get_AnnotationTypeId(int *retVal) override;
20
+ virtual HRESULT __stdcall get_AnnotationTypeName(BSTR *retVal) override;
21
+ virtual HRESULT __stdcall get_Author(BSTR *retVal) override;
22
+ virtual HRESULT __stdcall get_DateTime(BSTR *retVal) override;
23
+ virtual HRESULT __stdcall get_Target(IRawElementProviderSimple **retVal) override;
24
+
25
+ private:
26
+ ::Microsoft::ReactNative::ReactTaggedView m_view;
27
+ winrt::com_ptr<IAnnotationProvider> m_annotationProvider;
28
+ winrt::com_ptr<CompositionDynamicAutomationProvider> m_parentProvider;
29
+ };
30
+
31
+ } // namespace winrt::Microsoft::ReactNative::implementation