react-native-windows 0.82.1 → 0.83.0-preview.0

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 (232) hide show
  1. package/.flowconfig +2 -7
  2. package/Libraries/Animated/components/AnimatedFlatList.js +5 -3
  3. package/Libraries/Animated/components/AnimatedImage.js +4 -3
  4. package/Libraries/Animated/components/AnimatedSectionList.js +2 -2
  5. package/Libraries/Animated/components/AnimatedText.js +7 -3
  6. package/Libraries/Animated/components/AnimatedView.js +3 -2
  7. package/Libraries/Animated/createAnimatedComponent.js +24 -12
  8. package/Libraries/Animated/nodes/AnimatedColor.js +26 -10
  9. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +43 -15
  10. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.windows.js +43 -15
  11. package/Libraries/Components/ActivityIndicator/ActivityIndicator.d.ts +2 -2
  12. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.d.ts +2 -2
  13. package/Libraries/Components/Glyph/Glyph.js +4 -1
  14. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.d.ts +2 -2
  15. package/Libraries/Components/RefreshControl/RefreshControl.d.ts +3 -3
  16. package/Libraries/Components/SafeAreaView/SafeAreaView.d.ts +2 -2
  17. package/Libraries/Components/ScrollView/ScrollView.js +1 -0
  18. package/Libraries/Components/ScrollView/ScrollView.windows.js +1 -0
  19. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +6 -6
  20. package/Libraries/Components/Switch/Switch.d.ts +2 -2
  21. package/Libraries/Components/Switch/Switch.windows.js +1 -1
  22. package/Libraries/Components/TextInput/TextInput.d.ts +2 -5
  23. package/Libraries/Components/TextInput/TextInput.js +6 -0
  24. package/Libraries/Components/TextInput/TextInput.windows.js +6 -0
  25. package/Libraries/Components/Touchable/TouchableBounce.js +7 -7
  26. package/Libraries/Components/Touchable/TouchableBounce.windows.js +7 -7
  27. package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +1 -1
  28. package/Libraries/Components/View/ReactNativeStyleAttributes.js +19 -1
  29. package/Libraries/Components/View/View.d.ts +2 -2
  30. package/Libraries/Components/View/View.windows.js +0 -1
  31. package/Libraries/Components/View/ViewNativeComponent.js +13 -1
  32. package/Libraries/Core/ReactNativeVersion.js +3 -3
  33. package/Libraries/Core/setUpPerformance.js +2 -0
  34. package/Libraries/Debugging/DebuggingOverlay.js +14 -14
  35. package/Libraries/Debugging/DebuggingOverlayRegistry.js +8 -2
  36. package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +5 -2
  37. package/Libraries/Image/Image.d.ts +3 -3
  38. package/Libraries/Image/ImageInjection.js +3 -6
  39. package/Libraries/Image/ImageTypes.flow.js +3 -7
  40. package/Libraries/Lists/FlatList.js +8 -8
  41. package/Libraries/Lists/SectionList.d.ts +5 -1
  42. package/Libraries/Lists/ViewabilityHelper.js +1 -1
  43. package/Libraries/Lists/VirtualizedList.js +1 -0
  44. package/Libraries/LogBox/UI/AnsiHighlight.js +4 -1
  45. package/Libraries/NativeComponent/BaseViewConfig.android.js +11 -2
  46. package/Libraries/NativeComponent/NativeComponentRegistry.d.ts +98 -0
  47. package/Libraries/NativeComponent/NativeComponentRegistry.js +2 -0
  48. package/Libraries/NativeComponent/NativeComponentRegistryUnstable.js +3 -1
  49. package/Libraries/NativeComponent/ViewConfigIgnore.windows.js +45 -0
  50. package/Libraries/Network/RCTNetworking.android.js +3 -1
  51. package/Libraries/Network/RCTNetworking.ios.js +3 -0
  52. package/Libraries/Network/RCTNetworking.windows.js +3 -0
  53. package/Libraries/Network/XMLHttpRequest.js +1 -41
  54. package/Libraries/Pressability/usePressability.js +14 -3
  55. package/Libraries/ReactNative/PaperUIManager.windows.js +3 -3
  56. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +20 -82
  57. package/Libraries/ReactNative/getNativeComponentAttributes.js +12 -0
  58. package/Libraries/Renderer/implementations/ReactFabric-dev.js +6759 -4478
  59. package/Libraries/Renderer/implementations/ReactFabric-prod.js +3169 -3119
  60. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +4732 -3535
  61. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +6646 -4070
  62. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +3136 -2825
  63. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +4761 -3312
  64. package/Libraries/Renderer/shims/ReactNative.js +3 -1
  65. package/Libraries/Renderer/shims/ReactNativeTypes.js +2 -1
  66. package/Libraries/Renderer/shims/ReactNativeTypes.windows.js +2 -1
  67. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +1 -1
  68. package/Libraries/StyleSheet/StyleSheetTypes.js +44 -0
  69. package/Libraries/StyleSheet/processBackgroundPosition.js +284 -0
  70. package/Libraries/StyleSheet/processBackgroundRepeat.js +105 -0
  71. package/Libraries/StyleSheet/processBackgroundSize.js +104 -0
  72. package/Libraries/Text/Text.d.ts +2 -2
  73. package/Libraries/Text/TextNativeComponent.js +10 -0
  74. package/Libraries/TurboModule/TurboModuleRegistry.js +3 -9
  75. package/Libraries/Utilities/DevLoadingView.js +14 -6
  76. package/Libraries/Utilities/HMRClient.js +13 -5
  77. package/Microsoft.ReactNative/Base/CxxReactIncludes.h +11 -0
  78. package/Microsoft.ReactNative/CompositionComponentView.idl +2 -0
  79. package/Microsoft.ReactNative/CompositionHwndHost.idl +1 -0
  80. package/Microsoft.ReactNative/Fabric/ComponentView.cpp +1 -1
  81. package/Microsoft.ReactNative/Fabric/ComponentView.h +1 -1
  82. package/Microsoft.ReactNative/Fabric/Composition/CompositionHwndHost.cpp +10 -40
  83. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +3 -80
  84. package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp +45 -12
  85. package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h +8 -0
  86. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +61 -74
  87. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.h +4 -0
  88. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +1 -0
  89. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +4 -3
  90. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +2 -1
  91. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeWindow.cpp +245 -0
  92. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeWindow.h +80 -0
  93. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentDescriptor.h +20 -36
  94. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +70 -49
  95. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +4 -1
  96. package/Microsoft.ReactNative/Fabric/Composition/UriImageManager.cpp +5 -0
  97. package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.cpp +7 -2
  98. package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +1 -0
  99. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +1 -1
  100. package/Microsoft.ReactNative/Modules/ImageViewManagerModule.cpp +1 -1
  101. package/Microsoft.ReactNative/Modules/LogBoxModule.cpp +20 -94
  102. package/Microsoft.ReactNative/Modules/LogBoxModule.h +1 -3
  103. package/Microsoft.ReactNative/Pch/pch.h +2 -0
  104. package/Microsoft.ReactNative/ReactHost/CrashManager.cpp +5 -0
  105. package/Microsoft.ReactNative/ReactHost/ReactNativeHeaders.h +1 -0
  106. package/Microsoft.ReactNative/ReactNativeAppBuilder.cpp +0 -41
  107. package/Microsoft.ReactNative/ReactNativeAppBuilder.idl +0 -11
  108. package/Microsoft.ReactNative/ReactNativeIsland.idl +2 -3
  109. package/Microsoft.ReactNative/ReactNativeWin32App.cpp +31 -101
  110. package/Microsoft.ReactNative/ReactNativeWin32App.h +2 -13
  111. package/Microsoft.ReactNative/ReactNativeWindow.idl +44 -0
  112. package/Microsoft.ReactNative.Cxx/AutoDraw.h +9 -1
  113. package/Microsoft.ReactNative.Cxx/ReactCommon/CallInvoker.h +13 -16
  114. package/Microsoft.ReactNative.Cxx/ReactCommon/TurboModule.h +24 -36
  115. package/Microsoft.ReactNative.Cxx/ReactCommon/TurboModuleUtils.h +5 -8
  116. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/AString.h +8 -6
  117. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Array.h +32 -49
  118. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Base.h +27 -76
  119. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Bool.h +4 -2
  120. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/CallbackWrapper.h +19 -18
  121. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Class.h +25 -48
  122. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Convert.h +38 -31
  123. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Error.h +11 -6
  124. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/EventEmitter.h +47 -45
  125. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Function.h +69 -89
  126. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/HighResTimeStamp.h +8 -8
  127. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/LongLivedObject.h +6 -6
  128. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Number.h +16 -8
  129. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Object.h +17 -24
  130. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Promise.h +17 -17
  131. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Value.h +20 -29
  132. package/Microsoft.ReactNative.Cxx/ReactCommon/react/debug/react_native_assert.h +2 -7
  133. package/Microsoft.ReactNative.Cxx/ReactCommon/react/timing/primitives.h +127 -115
  134. package/PropertySheets/External/Microsoft.ReactNative.Composition.CppLib.props +10 -0
  135. package/PropertySheets/External/Microsoft.ReactNative.Uwp.CppLib.props +10 -0
  136. package/PropertySheets/Generated/PackageVersion.g.props +5 -5
  137. package/PropertySheets/Warnings.props +2 -1
  138. package/ReactCommon/ReactCommon.vcxproj +21 -12
  139. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/CxxNativeModule.cpp +2 -2
  140. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/Instance.cpp +381 -0
  141. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp +49 -0
  142. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSIndexedRAMBundle.cpp +145 -0
  143. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/MethodCall.cpp +100 -0
  144. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ModuleRegistry.cpp +256 -0
  145. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/NativeToJsBridge.cpp +13 -4
  146. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/RAMBundleRegistry.cpp +93 -0
  147. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ReactMarker.cpp +149 -0
  148. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/TraceSection.h +25 -35
  149. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/test/testlib.cpp +86 -67
  150. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsiexecutor/jsireact/JSIExecutor.cpp +629 -0
  151. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsiexecutor/jsireact/JSINativeModules.cpp +123 -0
  152. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.cpp +84 -68
  153. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.h +31 -35
  154. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/Utf8.h +4 -5
  155. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/network/HttpUtils.cpp +2 -1
  156. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModule.h +24 -36
  157. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/dom/NativeDOM.h +28 -66
  158. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/webperformance/NativePerformance.cpp +414 -0
  159. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp +3 -3
  160. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/image/conversions.h +8 -4
  161. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/ParagraphShadowNode.cpp +19 -16
  162. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/platform/android/react/renderer/components/text/ParagraphState.h +8 -9
  163. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/AccessibilityPrimitives.h +25 -95
  164. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/accessibilityPropsConversions.h +85 -42
  165. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventDispatcher.cpp +81 -0
  166. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventQueueProcessor.cpp +140 -0
  167. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/imagemanager/primitives.h +25 -31
  168. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/uimanager/UIManager.cpp +746 -0
  169. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +702 -0
  170. package/Scripts/Tfs/Layout-Desktop-Headers.ps1 +1 -15
  171. package/Scripts/creaternwapp.cmd +1 -1
  172. package/Scripts/perf/compare-results.js +357 -0
  173. package/Scripts/perf/create-perf-test.js +343 -0
  174. package/Scripts/perf/post-pr-comment.js +210 -0
  175. package/Shared/Hermes/HermesRuntimeTargetDelegate.cpp +8 -0
  176. package/Shared/Hermes/HermesRuntimeTargetDelegate.h +3 -0
  177. package/Shared/Shared.vcxitems +24 -12
  178. package/Shared/Shared.vcxitems.filters +11 -3
  179. package/codegen/NativeIntersectionObserverSpec.g.h +2 -0
  180. package/codegen/NativeNetworkingIOSSpec.g.h +2 -0
  181. package/codegen/NativePerformanceSpec.g.h +6 -0
  182. package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +229 -139
  183. package/codegen/react/components/rnwcore/ActivityIndicatorView.g.h +2 -1
  184. package/codegen/react/components/rnwcore/AndroidDrawerLayout.g.h +42 -25
  185. package/codegen/react/components/rnwcore/AndroidHorizontalScrollContentView.g.h +2 -1
  186. package/codegen/react/components/rnwcore/AndroidProgressBar.g.h +2 -1
  187. package/codegen/react/components/rnwcore/AndroidSwipeRefreshLayout.g.h +11 -6
  188. package/codegen/react/components/rnwcore/AndroidSwitch.g.h +11 -6
  189. package/codegen/react/components/rnwcore/DebuggingOverlay.g.h +1 -0
  190. package/codegen/react/components/rnwcore/InputAccessory.g.h +2 -1
  191. package/codegen/react/components/rnwcore/ModalHostView.g.h +40 -23
  192. package/codegen/react/components/rnwcore/Props.cpp +6 -1
  193. package/codegen/react/components/rnwcore/Props.h +1 -0
  194. package/codegen/react/components/rnwcore/PullToRefreshView.g.h +11 -6
  195. package/codegen/react/components/rnwcore/SafeAreaView.g.h +1 -0
  196. package/codegen/react/components/rnwcore/Switch.g.h +11 -6
  197. package/codegen/react/components/rnwcore/UnimplementedNativeView.g.h +2 -1
  198. package/codegen/react/components/rnwcore/VirtualView.g.h +41 -8
  199. package/codegen/react/components/rnwcore/VirtualViewExperimental.g.h +45 -8
  200. package/codegen/rnwcoreJSI.h +3973 -6059
  201. package/index.js +6 -0
  202. package/index.windows.js +6 -0
  203. package/jest/mockComponent.js +6 -6
  204. package/jest/setup.js +15 -10
  205. package/package.json +27 -27
  206. package/src/private/components/virtualview/VirtualView.js +22 -27
  207. package/src/private/components/virtualview/VirtualViewExperimentalNativeComponent.js +6 -0
  208. package/src/private/featureflags/ReactNativeFeatureFlags.js +100 -19
  209. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +18 -3
  210. package/src/private/setup/setUpDefaultReactNativeEnvironment.js +6 -0
  211. package/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js +1 -1
  212. package/src/private/specs_DEPRECATED/modules/NativeNetworkingIOS.js +1 -0
  213. package/src/private/webapis/dom/nodes/ReactNativeElement.js +12 -2
  214. package/src/private/webapis/intersectionobserver/IntersectionObserver.js +76 -15
  215. package/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +1 -0
  216. package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +1 -0
  217. package/src/private/webapis/performance/ResourceTiming.js +31 -4
  218. package/src/private/webapis/performance/internals/RawPerformanceEntry.js +4 -1
  219. package/src/private/webapis/performance/specs/NativePerformance.js +3 -0
  220. package/stubs/double-conversion/double-conversion.h +5 -0
  221. package/templates/cpp-app/template.config.js +1 -1
  222. package/templates/cpp-app/windows/MyApp/MyApp.vcxproj +3 -1
  223. package/templates/cpp-lib/template.config.js +1 -1
  224. package/templates/cpp-lib/windows/MyLib/MyLib.vcxproj +1 -1
  225. package/types/index.d.ts +1 -0
  226. package/types/public/ReactNativeTypes.d.ts +115 -2
  227. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +0 -152
  228. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/conversions.h +0 -1574
  229. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/ShadowNode.cpp +0 -528
  230. package/Scripts/OpenSSL.nuspec +0 -39
  231. package/Scripts/OpenSSL.targets +0 -36
  232. package/codegen/rnwcoreJSI-generated.cpp +0 -3470
@@ -20,19 +20,6 @@ ReactNativeAppBuilder::ReactNativeAppBuilder() {
20
20
 
21
21
  ReactNativeAppBuilder::~ReactNativeAppBuilder() {}
22
22
 
23
- winrt::Microsoft::ReactNative::ReactNativeAppBuilder ReactNativeAppBuilder::SetDispatcherQueueController(
24
- winrt::Microsoft::UI::Dispatching::DispatcherQueueController const &dispatcherQueueController) {
25
- m_reactNativeWin32App.as<implementation::ReactNativeWin32App>().get()->DispatcherQueueController(
26
- dispatcherQueueController);
27
- return *this;
28
- }
29
-
30
- winrt::Microsoft::ReactNative::ReactNativeAppBuilder ReactNativeAppBuilder::SetCompositor(
31
- winrt::Microsoft::UI::Composition::Compositor const &compositor) {
32
- m_reactNativeWin32App.as<implementation::ReactNativeWin32App>().get()->Compositor(compositor);
33
- return *this;
34
- }
35
-
36
23
  winrt::Microsoft::ReactNative::ReactNativeAppBuilder ReactNativeAppBuilder::SetAppWindow(
37
24
  winrt::Microsoft::UI::Windowing::AppWindow const &appWindow) {
38
25
  m_reactNativeWin32App.as<implementation::ReactNativeWin32App>().get()->AppWindow(appWindow);
@@ -41,34 +28,6 @@ winrt::Microsoft::ReactNative::ReactNativeAppBuilder ReactNativeAppBuilder::SetA
41
28
  }
42
29
 
43
30
  winrt::Microsoft::ReactNative::ReactNativeWin32App ReactNativeAppBuilder::Build() {
44
- // Create the DispatcherQueueController if the app developer doesn't provide one
45
- if (m_reactNativeWin32App.as<implementation::ReactNativeWin32App>().get()->DispatcherQueueController() == nullptr) {
46
- assert(m_reactNativeWin32App.as<implementation::ReactNativeWin32App>().get()->Compositor() == nullptr);
47
-
48
- // Create a DispatcherQueue for this thread. This is needed for Composition, Content, and Input APIs.
49
- auto dispatcherQueueController =
50
- winrt::Microsoft::UI::Dispatching::DispatcherQueueController::CreateOnCurrentThread();
51
-
52
- m_reactNativeWin32App.as<implementation::ReactNativeWin32App>().get()->DispatcherQueueController(
53
- dispatcherQueueController);
54
- }
55
-
56
- // Create the Compositor if the app developer doesn't provide one
57
- if (m_reactNativeWin32App.as<implementation::ReactNativeWin32App>().get()->Compositor() == nullptr) {
58
- // Create the compositor on behalf of the App Developer.
59
- auto compositor = winrt::Microsoft::UI::Composition::Compositor();
60
- m_reactNativeWin32App.as<implementation::ReactNativeWin32App>().get()->Compositor(compositor);
61
- }
62
-
63
- // Create the AppWindow if the app developer doesn't provide one
64
- if (m_reactNativeWin32App.AppWindow() == nullptr) {
65
- auto appWindow = winrt::Microsoft::UI::Windowing::AppWindow::Create();
66
- appWindow.Title(L"ReactNativeWin32App");
67
- appWindow.Resize({1000, 1000});
68
-
69
- m_reactNativeWin32App.as<implementation::ReactNativeWin32App>().get()->AppWindow(appWindow);
70
- }
71
-
72
31
  return m_reactNativeWin32App;
73
32
  }
74
33
 
@@ -18,12 +18,6 @@ namespace Microsoft.ReactNative {
18
18
 
19
19
  ReactViewOptions ReactViewOptions {get;};
20
20
 
21
- // TODO: Hide these APIs for now until we're sure we need to expose them and can do so safely
22
- // Microsoft.UI.Composition.Compositor Compositor {get;};
23
- // Microsoft.UI.Content.DesktopChildSiteBridge DesktopChildSiteBridge {get;};
24
- // Microsoft.UI.Dispatching DispatcherQueueController {get;};
25
- // ReactNativeIsland ReactNativeIsland {get;};
26
-
27
21
  // Methods
28
22
  void Start();
29
23
  }
@@ -38,11 +32,6 @@ namespace Microsoft.ReactNative {
38
32
 
39
33
  ReactNativeAppBuilder SetAppWindow(Microsoft.UI.Windowing.AppWindow appWindow);
40
34
 
41
- // TODO: Hide these APIs for now until we're sure we need to expose them and can do so safely
42
- // Compositor depends on the DispatcherQueue created by DispatcherQueueController
43
- // ReactNativeAppBuilder SetCompositor(Microsoft.UI.Composition.Compositor compositor);
44
- // ReactNativeAppBuilder SetDispatcherQueueController(Microsoft.UI.Dispatching DispatcherQueueController);
45
-
46
35
  ReactNativeWin32App Build();
47
36
  }
48
37
  }
@@ -80,9 +80,6 @@ namespace Microsoft.ReactNative
80
80
  DOC_STRING("A windows composition component that hosts React Native UI elements.")
81
81
  runtimeclass ReactNativeIsland
82
82
  {
83
- DOC_STRING("Creates a new instance of @ReactNativeIsland. Can be implemented with a ReactViewHost or a ComponentView with reactContext")
84
- ReactNativeIsland();
85
-
86
83
  ReactNativeIsland(Microsoft.UI.Composition.Compositor compositor);
87
84
 
88
85
  DOC_STRING("Used to create react portals, such as a native modal component.")
@@ -98,6 +95,8 @@ namespace Microsoft.ReactNative
98
95
 
99
96
  Windows.Foundation.Size Size { get; };
100
97
 
98
+ Microsoft.UI.Composition.Compositor Compositor { get; };
99
+
101
100
  DOC_STRING("ScaleFactor for this windows (DPI/96)")
102
101
  Single ScaleFactor {get; set;};
103
102
 
@@ -15,34 +15,10 @@
15
15
  #include "winrt/Microsoft.UI.Interop.h"
16
16
  #include "winrt/Microsoft.UI.Windowing.h"
17
17
 
18
- // Scaling factor for the window's content based on the DPI of the display where the window is located.
19
- float ScaleFactor(HWND hwnd) noexcept {
20
- return GetDpiForWindow(hwnd) / static_cast<float>(USER_DEFAULT_SCREEN_DPI);
21
- }
22
-
23
- void UpdateRootViewSizeToAppWindow(
24
- winrt::Microsoft::ReactNative::ReactNativeIsland const &rootView,
25
- winrt::Microsoft::UI::Windowing::AppWindow const &window) {
26
- auto hwnd = winrt::Microsoft::UI::GetWindowFromWindowId(window.Id());
27
- auto scaleFactor = ScaleFactor(hwnd);
28
- winrt::Windows::Foundation::Size size{
29
- window.ClientSize().Width / scaleFactor, window.ClientSize().Height / scaleFactor};
30
- // Do not relayout when minimized
31
- if (window.Presenter().as<winrt::Microsoft::UI::Windowing::OverlappedPresenter>().State() !=
32
- winrt::Microsoft::UI::Windowing::OverlappedPresenterState::Minimized) {
33
- winrt::Microsoft::ReactNative::LayoutConstraints constraints;
34
- constraints.LayoutDirection = winrt::Microsoft::ReactNative::LayoutDirection::Undefined;
35
- constraints.MaximumSize = constraints.MinimumSize = size;
36
- rootView.Arrange(constraints, {0, 0});
37
- }
38
- }
39
-
40
18
  namespace winrt::Microsoft::ReactNative::implementation {
41
19
  ReactNativeWin32App::ReactNativeWin32App() {}
42
20
 
43
21
  ReactNativeWin32App::~ReactNativeWin32App() {
44
- m_desktopChildSiteBridge = nullptr;
45
-
46
22
  // Destroy all Composition objects
47
23
  if (m_compositor != nullptr) {
48
24
  m_compositor.Close();
@@ -51,7 +27,7 @@ ReactNativeWin32App::~ReactNativeWin32App() {
51
27
  }
52
28
 
53
29
  winrt::Microsoft::UI::Windowing::AppWindow ReactNativeWin32App::AppWindow() {
54
- return m_appWindow;
30
+ return ReactNativeWindow().AppWindow();
55
31
  }
56
32
 
57
33
  void ReactNativeWin32App::AppWindow(winrt::Microsoft::UI::Windowing::AppWindow const &appWindow) {
@@ -59,29 +35,19 @@ void ReactNativeWin32App::AppWindow(winrt::Microsoft::UI::Windowing::AppWindow c
59
35
  }
60
36
 
61
37
  winrt::Microsoft::UI::Composition::Compositor ReactNativeWin32App::Compositor() {
62
- return m_compositor;
63
- }
64
-
65
- void ReactNativeWin32App::Compositor(winrt::Microsoft::UI::Composition::Compositor const &compositor) {
66
- m_compositor = compositor;
67
- }
68
-
69
- void ReactNativeWin32App::DesktopChildSiteBridge(
70
- winrt::Microsoft::UI::Content::DesktopChildSiteBridge const &desktopChildSiteBridge) {
71
- m_desktopChildSiteBridge = desktopChildSiteBridge;
72
- }
73
-
74
- winrt::Microsoft::UI::Content::DesktopChildSiteBridge ReactNativeWin32App::DesktopChildSiteBridge() {
75
- return m_desktopChildSiteBridge;
76
- }
38
+ if (m_compositor == nullptr) {
39
+ // Create a DispatcherQueue for this thread. This is needed for Composition, Content, and Input APIs.
40
+ m_dispatcherQueueController = winrt::Microsoft::UI::Dispatching::DispatcherQueueController::CreateOnCurrentThread();
77
41
 
78
- winrt::Microsoft::UI::Dispatching::DispatcherQueueController ReactNativeWin32App::DispatcherQueueController() {
79
- return m_dispatcherQueueController;
80
- }
42
+ // Currently set the property to use current thread dispatcher as a default UI dispatcher.
43
+ ReactNativeHost().InstanceSettings().Properties().Set(
44
+ ReactDispatcherHelper::UIDispatcherProperty(), ReactDispatcherHelper::UIThreadDispatcher());
81
45
 
82
- void ReactNativeWin32App::DispatcherQueueController(
83
- winrt::Microsoft::UI::Dispatching::DispatcherQueueController const &dispatcherQueueController) {
84
- m_dispatcherQueueController = dispatcherQueueController;
46
+ m_compositor = winrt::Microsoft::UI::Composition::Compositor();
47
+ winrt::Microsoft::ReactNative::Composition::CompositionUIService::SetCompositor(
48
+ ReactNativeHost().InstanceSettings(), m_compositor);
49
+ }
50
+ return m_compositor;
85
51
  }
86
52
 
87
53
  winrt::Microsoft::ReactNative::ReactNativeHost ReactNativeWin32App::ReactNativeHost() {
@@ -91,18 +57,6 @@ winrt::Microsoft::ReactNative::ReactNativeHost ReactNativeWin32App::ReactNativeH
91
57
  return m_host;
92
58
  }
93
59
 
94
- void ReactNativeWin32App::ReactNativeHost(winrt::Microsoft::ReactNative::ReactNativeHost const &host) {
95
- m_host = host;
96
- }
97
-
98
- winrt::Microsoft::ReactNative::ReactNativeIsland ReactNativeWin32App::ReactNativeIsland() {
99
- return m_reactNativeIsland;
100
- }
101
-
102
- void ReactNativeWin32App::ReactNativeIsland(winrt::Microsoft::ReactNative::ReactNativeIsland const &reactNativeIsland) {
103
- m_reactNativeIsland = reactNativeIsland;
104
- }
105
-
106
60
  winrt::Microsoft::ReactNative::ReactViewOptions ReactNativeWin32App::ReactViewOptions() {
107
61
  if (m_reactViewOptions == nullptr) {
108
62
  m_reactViewOptions = winrt::make<winrt::Microsoft::ReactNative::implementation::ReactViewOptions>();
@@ -114,45 +68,36 @@ void ReactNativeWin32App::ReactViewOptions(winrt::Microsoft::ReactNative::ReactV
114
68
  m_reactViewOptions = viewOptions;
115
69
  }
116
70
 
71
+ winrt::Microsoft::ReactNative::ReactNativeWindow ReactNativeWin32App::ReactNativeWindow() noexcept {
72
+ if (!m_rnWindow) {
73
+ if (m_appWindow) {
74
+ m_rnWindow = winrt::Microsoft::ReactNative::ReactNativeWindow::CreateFromWindow(m_appWindow, Compositor());
75
+ } else {
76
+ m_rnWindow = winrt::Microsoft::ReactNative::ReactNativeWindow::CreateFromCompositor(Compositor());
77
+ m_appWindow = m_rnWindow.AppWindow();
78
+ m_appWindow.Title(L"ReactNativeWin32App");
79
+ m_appWindow.Resize({1000, 1000});
80
+ }
81
+ }
82
+
83
+ return m_rnWindow;
84
+ }
85
+
117
86
  void ReactNativeWin32App::Start() {
118
87
  // Show the hosting AppWindow
119
- m_appWindow.Show();
120
-
121
- // Currently set the property to use current thread dispatcher as a default UI dispatcher.
122
- // TODO: Use the correct dispatcher from a developer-provided DispatcherQueueController
123
- ReactNativeHost().InstanceSettings().Properties().Set(
124
- ReactDispatcherHelper::UIDispatcherProperty(), ReactDispatcherHelper::UIThreadDispatcher());
88
+ AppWindow().Show();
125
89
 
126
90
  auto hwnd{winrt::Microsoft::UI::GetWindowFromWindowId(m_appWindow.Id())};
127
91
 
128
92
  winrt::Microsoft::ReactNative::ReactCoreInjection::SetTopLevelWindowId(
129
93
  ReactNativeHost().InstanceSettings().Properties(), reinterpret_cast<uint64_t>(hwnd));
130
94
 
131
- winrt::Microsoft::ReactNative::Composition::CompositionUIService::SetCompositor(
132
- ReactNativeHost().InstanceSettings(), m_compositor);
133
-
134
95
  // Start the react-native instance, which will create a JavaScript runtime and load the applications bundle.
135
96
  ReactNativeHost().ReloadInstance();
136
97
 
137
- // Create a RootView which will present a react-native component
138
- if (m_reactNativeIsland == nullptr) {
139
- m_reactNativeIsland = winrt::Microsoft::ReactNative::ReactNativeIsland(m_compositor);
140
- }
141
-
142
- m_reactNativeIsland.ReactViewHost(
98
+ m_rnWindow.ReactNativeIsland().ReactViewHost(
143
99
  winrt::Microsoft::ReactNative::ReactCoreInjection::MakeViewHost(ReactNativeHost(), ReactViewOptions()));
144
100
 
145
- // Update the size of the RootView when the AppWindow changes size
146
- m_appWindow.Changed([wkRootView = winrt::make_weak(m_reactNativeIsland)](
147
- winrt::Microsoft::UI::Windowing::AppWindow const &window,
148
- winrt::Microsoft::UI::Windowing::AppWindowChangedEventArgs const &args) {
149
- if (args.DidSizeChange() || args.DidVisibilityChange()) {
150
- if (auto rootView = wkRootView.get()) {
151
- UpdateRootViewSizeToAppWindow(rootView, window);
152
- }
153
- }
154
- });
155
-
156
101
  // Quit application when main window is closed
157
102
  m_appWindow.Destroying([this](
158
103
  winrt::Microsoft::UI::Windowing::AppWindow const &window,
@@ -166,28 +111,13 @@ void ReactNativeWin32App::Start() {
166
111
  });
167
112
  });
168
113
 
169
- // DesktopChildSiteBridge create a ContentSite that can host the RootView ContentIsland
170
- m_desktopChildSiteBridge =
171
- winrt::Microsoft::UI::Content::DesktopChildSiteBridge::Create(m_compositor, m_appWindow.Id());
172
-
173
- m_desktopChildSiteBridge.Connect(m_reactNativeIsland.Island());
174
-
175
- m_desktopChildSiteBridge.ResizePolicy(winrt::Microsoft::UI::Content::ContentSizePolicy::ResizeContentToParentWindow);
176
-
177
- auto scaleFactor = ScaleFactor(hwnd);
178
- m_reactNativeIsland.ScaleFactor(scaleFactor);
179
-
180
- UpdateRootViewSizeToAppWindow(m_reactNativeIsland, m_appWindow);
181
-
182
- m_desktopChildSiteBridge.Show();
183
-
184
114
  // Run the main application event loop
185
115
  m_dispatcherQueueController.DispatcherQueue().RunEventLoop();
186
116
 
117
+ m_appWindow.Destroy();
118
+
187
119
  // Rundown the DispatcherQueue. This drains the queue and raises events to let components
188
120
  // know the message loop has finished.
189
121
  m_dispatcherQueueController.ShutdownQueue();
190
-
191
- m_desktopChildSiteBridge.Close();
192
122
  }
193
123
  } // namespace winrt::Microsoft::ReactNative::implementation
@@ -15,20 +15,10 @@ struct ReactNativeWin32App : ReactNativeWin32AppT<ReactNativeWin32App> {
15
15
  winrt::Microsoft::UI::Windowing::AppWindow AppWindow();
16
16
 
17
17
  winrt::Microsoft::UI::Composition::Compositor Compositor();
18
- void Compositor(winrt::Microsoft::UI::Composition::Compositor const &compositor);
19
-
20
- winrt::Microsoft::UI::Content::DesktopChildSiteBridge DesktopChildSiteBridge();
21
- void DesktopChildSiteBridge(winrt::Microsoft::UI::Content::DesktopChildSiteBridge const &desktopChildSiteBridge);
22
-
23
- winrt::Microsoft::UI::Dispatching::DispatcherQueueController DispatcherQueueController();
24
- void DispatcherQueueController(
25
- winrt::Microsoft::UI::Dispatching::DispatcherQueueController const &dispatcherQueueController);
26
18
 
27
19
  winrt::Microsoft::ReactNative::ReactNativeHost ReactNativeHost();
28
- void ReactNativeHost(winrt::Microsoft::ReactNative::ReactNativeHost const &host);
29
20
 
30
- winrt::Microsoft::ReactNative::ReactNativeIsland ReactNativeIsland();
31
- void ReactNativeIsland(winrt::Microsoft::ReactNative::ReactNativeIsland const &reactNativeIsland);
21
+ winrt::Microsoft::ReactNative::ReactNativeWindow ReactNativeWindow() noexcept;
32
22
 
33
23
  winrt::Microsoft::ReactNative::ReactViewOptions ReactViewOptions();
34
24
  void ReactViewOptions(winrt::Microsoft::ReactNative::ReactViewOptions const &reactViewOptions);
@@ -36,12 +26,11 @@ struct ReactNativeWin32App : ReactNativeWin32AppT<ReactNativeWin32App> {
36
26
  void Start();
37
27
 
38
28
  private:
29
+ winrt::Microsoft::ReactNative::ReactNativeWindow m_rnWindow{nullptr};
39
30
  winrt::Microsoft::UI::Windowing::AppWindow m_appWindow{nullptr};
40
31
  winrt::Microsoft::UI::Composition::Compositor m_compositor{nullptr};
41
- winrt::Microsoft::UI::Content::DesktopChildSiteBridge m_desktopChildSiteBridge{nullptr};
42
32
  winrt::Microsoft::UI::Dispatching::DispatcherQueueController m_dispatcherQueueController{nullptr};
43
33
  winrt::Microsoft::ReactNative::ReactNativeHost m_host{nullptr};
44
- winrt::Microsoft::ReactNative::ReactNativeIsland m_reactNativeIsland{nullptr};
45
34
  winrt::Microsoft::ReactNative::ReactViewOptions m_reactViewOptions{nullptr};
46
35
  };
47
36
  } // namespace winrt::Microsoft::ReactNative::implementation
@@ -0,0 +1,44 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ import "ReactNativeIsland.idl";
5
+
6
+ #include "NamespaceRedirect.h"
7
+ #include "DocString.h"
8
+
9
+ namespace Microsoft.ReactNative
10
+ {
11
+
12
+ [experimental]
13
+ enum ContentSizePolicy
14
+ {
15
+ None,
16
+ ResizeContentToParentWindow,
17
+ ResizeParentWindowToContent,
18
+ };
19
+
20
+ [default_interface]
21
+ [webhosthidden]
22
+ [experimental]
23
+ DOC_STRING("Simplifies hosting a ReactNativeIsland inside a Window.")
24
+ runtimeclass ReactNativeWindow : Windows.Foundation.IClosable
25
+ {
26
+ static ReactNativeWindow CreateFromCompositor(Microsoft.UI.Composition.Compositor compositor);
27
+ static ReactNativeWindow CreateFromWindow(Microsoft.UI.Windowing.AppWindow appWindow, Microsoft.UI.Composition.Compositor compositor);
28
+ static ReactNativeWindow CreateFromContentSiteBridgeAndIsland(Microsoft.UI.Content.IContentSiteBridge bridge, Microsoft.ReactNative.ReactNativeIsland island);
29
+ static ReactNativeWindow CreateFromWindowAndIsland(Microsoft.UI.Windowing.AppWindow appWindow, Microsoft.ReactNative.ReactNativeIsland island);
30
+
31
+ ReactNativeIsland ReactNativeIsland { get; };
32
+
33
+ Microsoft.UI.Windowing.AppWindow AppWindow { get; };
34
+
35
+ Microsoft.UI.Content.IContentSiteBridge ContentSiteBridge { get; };
36
+ ContentSizePolicy ResizePolicy { get; set; };
37
+
38
+ DOC_STRING("When the ResizePolicy is set to ResizeParentWindowToContent, these LayoutConstraints will control the layout of the content."
39
+ " When ResizePolicy is set to ResizeContentToParentWindow, these constraints will be ignored. Instead the window can be constrained using"
40
+ " OverlappedPresenter.PreferredMaximumHeight etc.")
41
+ LayoutConstraints LayoutConstraints { get; set; };
42
+ }
43
+
44
+ } // namespace Microsoft.ReactNative
@@ -16,7 +16,10 @@ class AutoDrawDrawingSurface {
16
16
  POINT *offset) noexcept {
17
17
  drawingSurface.as(m_drawingSurfaceInterop);
18
18
  auto dpi = scaleFactor * 96.0f;
19
- m_drawingSurfaceInterop->BeginDraw(m_d2dDeviceContext.put(), dpi, dpi, offset);
19
+ auto hr = m_drawingSurfaceInterop->BeginDraw(m_d2dDeviceContext.put(), dpi, dpi, offset);
20
+ if (FAILED(hr)) {
21
+ m_d2dDeviceContext = nullptr;
22
+ }
20
23
  }
21
24
 
22
25
  ~AutoDrawDrawingSurface() noexcept {
@@ -34,6 +37,11 @@ class AutoDrawDrawingSurface {
34
37
  return m_d2dDeviceContext.get();
35
38
  }
36
39
 
40
+ // Returns true if the device context is valid and safe to use for drawing operations
41
+ bool IsValid() const noexcept {
42
+ return m_d2dDeviceContext != nullptr;
43
+ }
44
+
37
45
  private:
38
46
  winrt::com_ptr<Experimental::ICompositionDrawingSurfaceInterop> m_drawingSurfaceInterop;
39
47
  winrt::com_ptr<ID2D1DeviceContext> m_d2dDeviceContext;
@@ -18,7 +18,7 @@ class Runtime;
18
18
 
19
19
  namespace facebook::react {
20
20
 
21
- using CallFunc = std::function<void(jsi::Runtime&)>;
21
+ using CallFunc = std::function<void(jsi::Runtime &)>;
22
22
 
23
23
  /**
24
24
  * An interface for a generic native-to-JS call invoker. See BridgeJSCallInvoker
@@ -26,23 +26,24 @@ using CallFunc = std::function<void(jsi::Runtime&)>;
26
26
  */
27
27
  class CallInvoker {
28
28
  public:
29
- virtual void invokeAsync(CallFunc&& func) noexcept = 0;
30
- virtual void invokeAsync(
31
- SchedulerPriority /*priority*/,
32
- CallFunc&& func) noexcept {
29
+ virtual void invokeAsync(CallFunc &&func) noexcept = 0;
30
+ virtual void invokeAsync(SchedulerPriority /*priority*/, CallFunc &&func) noexcept
31
+ {
33
32
  // When call with priority is not implemented, fall back to a regular async
34
33
  // execution
35
34
  invokeAsync(std::move(func));
36
35
  }
37
- virtual void invokeSync(CallFunc&& func) = 0;
36
+ virtual void invokeSync(CallFunc &&func) = 0;
38
37
 
39
38
  // Backward compatibility only, prefer the CallFunc methods instead
40
- virtual void invokeAsync(std::function<void()>&& func) noexcept {
41
- invokeAsync([func](jsi::Runtime&) { func(); });
39
+ virtual void invokeAsync(std::function<void()> &&func) noexcept
40
+ {
41
+ invokeAsync([func = std::move(func)](jsi::Runtime &) { func(); });
42
42
  }
43
43
 
44
- virtual void invokeSync(std::function<void()>&& func) {
45
- invokeSync([func](jsi::Runtime&) { func(); });
44
+ virtual void invokeSync(std::function<void()> &&func)
45
+ {
46
+ invokeSync([func = std::move(func)](jsi::Runtime &) { func(); });
46
47
  }
47
48
 
48
49
  virtual ~CallInvoker() = default;
@@ -52,12 +53,8 @@ using NativeMethodCallFunc = std::function<void()>;
52
53
 
53
54
  class NativeMethodCallInvoker {
54
55
  public:
55
- virtual void invokeAsync(
56
- const std::string& methodName,
57
- NativeMethodCallFunc&& func) noexcept = 0;
58
- virtual void invokeSync(
59
- const std::string& methodName,
60
- NativeMethodCallFunc&& func) = 0;
56
+ virtual void invokeAsync(const std::string &methodName, NativeMethodCallFunc &&func) noexcept = 0;
57
+ virtual void invokeSync(const std::string &methodName, NativeMethodCallFunc &&func) = 0;
61
58
  virtual ~NativeMethodCallInvoker() = default;
62
59
  };
63
60
 
@@ -36,9 +36,7 @@ enum TurboModuleMethodValueKind {
36
36
  /**
37
37
  * Determines TurboModuleMethodValueKind based on the jsi::Value type.
38
38
  */
39
- TurboModuleMethodValueKind getTurboModuleMethodValueKind(
40
- jsi::Runtime& rt,
41
- const jsi::Value* value);
39
+ TurboModuleMethodValueKind getTurboModuleMethodValueKind(jsi::Runtime &rt, const jsi::Value *value);
42
40
 
43
41
  class TurboCxxModule;
44
42
  class TurboModuleBinding;
@@ -55,8 +53,8 @@ class JSI_EXPORT TurboModule : public jsi::HostObject {
55
53
  // JS representation. To customize lookup of properties, override `create`.
56
54
  // Note: keep this method declared inline to avoid conflicts
57
55
  // between RTTI and non-RTTI compilation units
58
- jsi::Value get(jsi::Runtime& runtime, const jsi::PropNameID& propName)
59
- override {
56
+ jsi::Value get(jsi::Runtime &runtime, const jsi::PropNameID &propName) override
57
+ {
60
58
  auto prop = create(runtime, propName);
61
59
  // If we have a JS wrapper, cache the result of this lookup
62
60
  // We don't cache misses, to allow for methodMap_ to dynamically be
@@ -64,15 +62,14 @@ class JSI_EXPORT TurboModule : public jsi::HostObject {
64
62
  // [Windows] Reenable once https://github.com/microsoft/react-native-windows/issues/14128 is fixed
65
63
  #ifndef WINAPI_FAMILY
66
64
  if (jsRepresentation_ && !prop.isUndefined()) {
67
- jsRepresentation_->lock(runtime).asObject(runtime).setProperty(
68
- runtime, propName, prop);
65
+ jsRepresentation_->lock(runtime).asObject(runtime).setProperty(runtime, propName, prop);
69
66
  }
70
67
  #endif
71
68
  return prop;
72
69
  }
73
70
 
74
- std::vector<jsi::PropNameID> getPropertyNames(
75
- jsi::Runtime& runtime) override {
71
+ std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &runtime) override
72
+ {
76
73
  std::vector<jsi::PropNameID> result;
77
74
  result.reserve(methodMap_.size());
78
75
  for (auto it = methodMap_.cbegin(); it != methodMap_.cend(); ++it) {
@@ -87,18 +84,14 @@ class JSI_EXPORT TurboModule : public jsi::HostObject {
87
84
 
88
85
  struct MethodMetadata {
89
86
  size_t argCount;
90
- jsi::Value (*invoker)(
91
- jsi::Runtime& rt,
92
- TurboModule& turboModule,
93
- const jsi::Value* args,
94
- size_t count);
87
+ jsi::Value (*invoker)(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value *args, size_t count);
95
88
  };
96
89
  std::unordered_map<std::string, MethodMetadata> methodMap_;
97
- std::unordered_map<std::string, std::shared_ptr<IAsyncEventEmitter>>
98
- eventEmitterMap_;
99
90
 
100
- using ArgFactory =
101
- std::function<void(jsi::Runtime& runtime, std::vector<jsi::Value>& args)>;
91
+ friend class TurboModuleTestFixtureInternal;
92
+ std::unordered_map<std::string, std::shared_ptr<IAsyncEventEmitter>> eventEmitterMap_;
93
+
94
+ using ArgFactory = std::function<void(jsi::Runtime &runtime, std::vector<jsi::Value> &args)>;
102
95
 
103
96
  /**
104
97
  * Calls RCTDeviceEventEmitter.emit to JavaScript, with given event name and
@@ -112,35 +105,31 @@ class JSI_EXPORT TurboModule : public jsi::HostObject {
112
105
  * args.emplace_back(jsi::Value(42));
113
106
  * });
114
107
  */
115
- void emitDeviceEvent(
116
- const std::string& eventName,
117
- ArgFactory&& argFactory = nullptr);
108
+ void emitDeviceEvent(const std::string &eventName, ArgFactory &&argFactory = nullptr);
118
109
 
119
110
  // Backwards compatibility version
120
111
  void emitDeviceEvent(
121
- jsi::Runtime& /*runtime*/,
112
+ jsi::Runtime & /*runtime*/,
122
113
 
123
- const std::string& eventName,
124
- ArgFactory&& argFactory = nullptr) {
114
+ const std::string &eventName,
115
+ ArgFactory &&argFactory = nullptr)
116
+ {
125
117
  emitDeviceEvent(eventName, std::move(argFactory));
126
118
  }
127
119
 
128
- virtual jsi::Value create(
129
- jsi::Runtime& runtime,
130
- const jsi::PropNameID& propName) {
120
+ virtual jsi::Value create(jsi::Runtime &runtime, const jsi::PropNameID &propName)
121
+ {
131
122
  std::string propNameUtf8 = propName.utf8(runtime);
132
- if (auto methodIter = methodMap_.find(propNameUtf8);
133
- methodIter != methodMap_.end()) {
134
- const MethodMetadata& meta = methodIter->second;
123
+ if (auto methodIter = methodMap_.find(propNameUtf8); methodIter != methodMap_.end()) {
124
+ const MethodMetadata &meta = methodIter->second;
135
125
  return jsi::Function::createFromHostFunction(
136
126
  runtime,
137
127
  propName,
138
128
  static_cast<unsigned int>(meta.argCount),
139
129
  [this, meta](
140
- jsi::Runtime& rt,
141
- [[maybe_unused]] const jsi::Value& thisVal,
142
- const jsi::Value* args,
143
- size_t count) { return meta.invoker(rt, *this, args, count); });
130
+ jsi::Runtime &rt, [[maybe_unused]] const jsi::Value &thisVal, const jsi::Value *args, size_t count) {
131
+ return meta.invoker(rt, *this, args, count);
132
+ });
144
133
  } else if (auto eventEmitterIter = eventEmitterMap_.find(propNameUtf8);
145
134
  eventEmitterIter != eventEmitterMap_.end()) {
146
135
  return eventEmitterIter->second->get(runtime, jsInvoker_);
@@ -159,7 +148,6 @@ class JSI_EXPORT TurboModule : public jsi::HostObject {
159
148
  * An app/platform-specific provider function to get an instance of a module
160
149
  * given a name.
161
150
  */
162
- using TurboModuleProviderFunctionType =
163
- std::function<std::shared_ptr<TurboModule>(const std::string& name)>;
151
+ using TurboModuleProviderFunctionType = std::function<std::shared_ptr<TurboModule>(const std::string &name)>;
164
152
 
165
153
  } // namespace facebook::react
@@ -16,19 +16,16 @@
16
16
  namespace facebook::react {
17
17
 
18
18
  struct Promise : public LongLivedObject {
19
- Promise(jsi::Runtime& rt, jsi::Function resolve, jsi::Function reject);
19
+ Promise(jsi::Runtime &rt, jsi::Function resolve, jsi::Function reject);
20
20
 
21
- void resolve(const jsi::Value& result);
22
- void reject(const std::string& message);
21
+ void resolve(const jsi::Value &result);
22
+ void reject(const std::string &message);
23
23
 
24
24
  jsi::Function resolve_;
25
25
  jsi::Function reject_;
26
26
  };
27
27
 
28
- using PromiseSetupFunctionType =
29
- std::function<void(jsi::Runtime& rt, std::shared_ptr<Promise>)>;
30
- jsi::Value createPromiseAsJSIValue(
31
- jsi::Runtime& rt,
32
- PromiseSetupFunctionType&& func);
28
+ using PromiseSetupFunctionType = std::function<void(jsi::Runtime &rt, std::shared_ptr<Promise>)>;
29
+ jsi::Value createPromiseAsJSIValue(jsi::Runtime &rt, PromiseSetupFunctionType &&func);
33
30
 
34
31
  } // namespace facebook::react
@@ -16,25 +16,27 @@ namespace facebook::react {
16
16
 
17
17
  template <>
18
18
  struct Bridging<std::string> {
19
- static std::string fromJs(jsi::Runtime& rt, const jsi::String& value) {
19
+ static std::string fromJs(jsi::Runtime &rt, const jsi::String &value)
20
+ {
20
21
  return value.utf8(rt);
21
22
  }
22
23
 
23
- static jsi::String toJs(jsi::Runtime& rt, const std::string& value) {
24
+ static jsi::String toJs(jsi::Runtime &rt, const std::string &value)
25
+ {
24
26
  return jsi::String::createFromUtf8(rt, value);
25
27
  }
26
28
  };
27
29
 
28
30
  template <>
29
31
  struct Bridging<std::string_view> {
30
- static jsi::String toJs(jsi::Runtime& rt, std::string_view value) {
31
- return jsi::String::createFromUtf8(
32
- rt, reinterpret_cast<const uint8_t*>(value.data()), value.length());
32
+ static jsi::String toJs(jsi::Runtime &rt, std::string_view value)
33
+ {
34
+ return jsi::String::createFromUtf8(rt, reinterpret_cast<const uint8_t *>(value.data()), value.length());
33
35
  }
34
36
  };
35
37
 
36
38
  template <>
37
- struct Bridging<const char*> : Bridging<std::string_view> {};
39
+ struct Bridging<const char *> : Bridging<std::string_view> {};
38
40
 
39
41
  template <size_t N>
40
42
  struct Bridging<char[N]> : Bridging<std::string_view> {};