react-native-windows 0.82.3 → 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 (224) 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/CompositionComponentView.idl +2 -0
  78. package/Microsoft.ReactNative/CompositionHwndHost.idl +1 -0
  79. package/Microsoft.ReactNative/Fabric/ComponentView.cpp +1 -1
  80. package/Microsoft.ReactNative/Fabric/ComponentView.h +1 -1
  81. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +2 -52
  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/UriImageManager.cpp +5 -0
  95. package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +1 -0
  96. package/Microsoft.ReactNative/Modules/ImageViewManagerModule.cpp +1 -1
  97. package/Microsoft.ReactNative/Modules/LogBoxModule.cpp +20 -94
  98. package/Microsoft.ReactNative/Modules/LogBoxModule.h +1 -3
  99. package/Microsoft.ReactNative/ReactNativeAppBuilder.cpp +0 -41
  100. package/Microsoft.ReactNative/ReactNativeAppBuilder.idl +0 -11
  101. package/Microsoft.ReactNative/ReactNativeIsland.idl +2 -3
  102. package/Microsoft.ReactNative/ReactNativeWin32App.cpp +31 -101
  103. package/Microsoft.ReactNative/ReactNativeWin32App.h +2 -13
  104. package/Microsoft.ReactNative/ReactNativeWindow.idl +44 -0
  105. package/Microsoft.ReactNative.Cxx/AutoDraw.h +9 -1
  106. package/Microsoft.ReactNative.Cxx/ReactCommon/CallInvoker.h +13 -16
  107. package/Microsoft.ReactNative.Cxx/ReactCommon/TurboModule.h +24 -36
  108. package/Microsoft.ReactNative.Cxx/ReactCommon/TurboModuleUtils.h +5 -8
  109. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/AString.h +8 -6
  110. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Array.h +32 -49
  111. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Base.h +27 -76
  112. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Bool.h +4 -2
  113. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/CallbackWrapper.h +19 -18
  114. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Class.h +25 -48
  115. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Convert.h +38 -31
  116. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Error.h +11 -6
  117. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/EventEmitter.h +47 -45
  118. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Function.h +69 -89
  119. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/HighResTimeStamp.h +8 -8
  120. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/LongLivedObject.h +6 -6
  121. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Number.h +16 -8
  122. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Object.h +17 -24
  123. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Promise.h +17 -17
  124. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Value.h +20 -29
  125. package/Microsoft.ReactNative.Cxx/ReactCommon/react/debug/react_native_assert.h +2 -7
  126. package/Microsoft.ReactNative.Cxx/ReactCommon/react/timing/primitives.h +127 -115
  127. package/PropertySheets/Generated/PackageVersion.g.props +5 -5
  128. package/PropertySheets/Warnings.props +2 -1
  129. package/ReactCommon/ReactCommon.vcxproj +11 -2
  130. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/CxxNativeModule.cpp +2 -2
  131. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/Instance.cpp +4 -2
  132. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp +4 -2
  133. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSIndexedRAMBundle.cpp +4 -2
  134. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/MethodCall.cpp +4 -2
  135. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ModuleRegistry.cpp +5 -3
  136. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/NativeToJsBridge.cpp +4 -4
  137. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/RAMBundleRegistry.cpp +6 -4
  138. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ReactMarker.cpp +2 -0
  139. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/TraceSection.h +25 -35
  140. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/test/testlib.cpp +86 -67
  141. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsiexecutor/jsireact/JSIExecutor.cpp +15 -8
  142. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsiexecutor/jsireact/JSINativeModules.cpp +4 -2
  143. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.cpp +84 -68
  144. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.h +31 -35
  145. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/Utf8.h +4 -5
  146. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/network/HttpUtils.cpp +2 -1
  147. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModule.h +24 -36
  148. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/dom/NativeDOM.h +28 -66
  149. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/webperformance/NativePerformance.cpp +5 -0
  150. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp +3 -3
  151. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/image/conversions.h +8 -4
  152. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/ParagraphShadowNode.cpp +19 -16
  153. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/platform/android/react/renderer/components/text/ParagraphState.h +8 -9
  154. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/AccessibilityPrimitives.h +25 -95
  155. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/accessibilityPropsConversions.h +85 -42
  156. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventDispatcher.cpp +2 -0
  157. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventQueueProcessor.cpp +2 -0
  158. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/imagemanager/primitives.h +25 -31
  159. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/uimanager/UIManager.cpp +19 -5
  160. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +16 -1
  161. package/Scripts/Tfs/Layout-Desktop-Headers.ps1 +1 -15
  162. package/Scripts/creaternwapp.cmd +1 -1
  163. package/Scripts/perf/compare-results.js +357 -0
  164. package/Scripts/perf/create-perf-test.js +343 -0
  165. package/Scripts/perf/post-pr-comment.js +210 -0
  166. package/Shared/Hermes/HermesRuntimeTargetDelegate.cpp +8 -0
  167. package/Shared/Hermes/HermesRuntimeTargetDelegate.h +3 -0
  168. package/Shared/Shared.vcxitems +15 -3
  169. package/Shared/Shared.vcxitems.filters +11 -3
  170. package/codegen/NativeIntersectionObserverSpec.g.h +2 -0
  171. package/codegen/NativeNetworkingIOSSpec.g.h +2 -0
  172. package/codegen/NativePerformanceSpec.g.h +6 -0
  173. package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +229 -139
  174. package/codegen/react/components/rnwcore/ActivityIndicatorView.g.h +2 -1
  175. package/codegen/react/components/rnwcore/AndroidDrawerLayout.g.h +42 -25
  176. package/codegen/react/components/rnwcore/AndroidHorizontalScrollContentView.g.h +2 -1
  177. package/codegen/react/components/rnwcore/AndroidProgressBar.g.h +2 -1
  178. package/codegen/react/components/rnwcore/AndroidSwipeRefreshLayout.g.h +11 -6
  179. package/codegen/react/components/rnwcore/AndroidSwitch.g.h +11 -6
  180. package/codegen/react/components/rnwcore/DebuggingOverlay.g.h +1 -0
  181. package/codegen/react/components/rnwcore/InputAccessory.g.h +2 -1
  182. package/codegen/react/components/rnwcore/ModalHostView.g.h +40 -23
  183. package/codegen/react/components/rnwcore/Props.cpp +6 -1
  184. package/codegen/react/components/rnwcore/Props.h +1 -0
  185. package/codegen/react/components/rnwcore/PullToRefreshView.g.h +11 -6
  186. package/codegen/react/components/rnwcore/SafeAreaView.g.h +1 -0
  187. package/codegen/react/components/rnwcore/Switch.g.h +11 -6
  188. package/codegen/react/components/rnwcore/UnimplementedNativeView.g.h +2 -1
  189. package/codegen/react/components/rnwcore/VirtualView.g.h +41 -8
  190. package/codegen/react/components/rnwcore/VirtualViewExperimental.g.h +45 -8
  191. package/codegen/rnwcoreJSI.h +3973 -6059
  192. package/index.js +6 -0
  193. package/index.windows.js +6 -0
  194. package/jest/mockComponent.js +6 -6
  195. package/jest/setup.js +15 -10
  196. package/package.json +27 -27
  197. package/src/private/components/virtualview/VirtualView.js +22 -27
  198. package/src/private/components/virtualview/VirtualViewExperimentalNativeComponent.js +6 -0
  199. package/src/private/featureflags/ReactNativeFeatureFlags.js +100 -19
  200. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +18 -3
  201. package/src/private/setup/setUpDefaultReactNativeEnvironment.js +6 -0
  202. package/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js +1 -1
  203. package/src/private/specs_DEPRECATED/modules/NativeNetworkingIOS.js +1 -0
  204. package/src/private/webapis/dom/nodes/ReactNativeElement.js +12 -2
  205. package/src/private/webapis/intersectionobserver/IntersectionObserver.js +76 -15
  206. package/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +1 -0
  207. package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +1 -0
  208. package/src/private/webapis/performance/ResourceTiming.js +31 -4
  209. package/src/private/webapis/performance/internals/RawPerformanceEntry.js +4 -1
  210. package/src/private/webapis/performance/specs/NativePerformance.js +3 -0
  211. package/stubs/double-conversion/double-conversion.h +5 -0
  212. package/templates/cpp-app/template.config.js +1 -1
  213. package/templates/cpp-app/windows/MyApp/MyApp.vcxproj +1 -1
  214. package/templates/cpp-lib/template.config.js +1 -1
  215. package/templates/cpp-lib/windows/MyLib/MyLib.vcxproj +1 -1
  216. package/types/index.d.ts +1 -0
  217. package/types/public/ReactNativeTypes.d.ts +115 -2
  218. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +0 -152
  219. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/BaseViewProps.cpp +0 -628
  220. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/conversions.h +0 -1574
  221. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/ShadowNode.cpp +0 -528
  222. package/Scripts/OpenSSL.nuspec +0 -39
  223. package/Scripts/OpenSSL.targets +0 -36
  224. package/codegen/rnwcoreJSI-generated.cpp +0 -3470
@@ -32,36 +32,29 @@ virtual State::Shared createInitialState(
32
32
 
33
33
  ThemePadding theme;
34
34
  // TODO: figure out RTL/start/end/left/right stuff here
35
- if (surfaceIdToThemePaddingMap_.find(surfaceId) !=
36
- surfaceIdToThemePaddingMap_.end()) {
35
+ if (surfaceIdToThemePaddingMap_.find(surfaceId) != surfaceIdToThemePaddingMap_.end()) {
37
36
  theme = surfaceIdToThemePaddingMap_[surfaceId];
38
37
  } else {
39
- const jni::global_ref<jobject>& fabricUIManager =
38
+ const jni::global_ref<jobject> &fabricUIManager =
40
39
  contextContainer_->at<jni::global_ref<jobject>>("FabricUIManager");
41
40
 
42
41
  auto env = jni::Environment::current();
43
42
  auto defaultTextInputPaddingArray = env->NewFloatArray(4);
44
43
  static auto getThemeData =
45
- jni::findClassStatic(UIManagerJavaDescriptor)
46
- ->getMethod<jboolean(jint, jfloatArray)>("getThemeData");
44
+ jni::findClassStatic(UIManagerJavaDescriptor)->getMethod<jboolean(jint, jfloatArray)>("getThemeData");
47
45
 
48
- if (getThemeData(
49
- fabricUIManager, surfaceId, defaultTextInputPaddingArray)) {
50
- jfloat* defaultTextInputPadding =
51
- env->GetFloatArrayElements(defaultTextInputPaddingArray, nullptr);
46
+ if (getThemeData(fabricUIManager, surfaceId, defaultTextInputPaddingArray) != 0u) {
47
+ jfloat *defaultTextInputPadding = env->GetFloatArrayElements(defaultTextInputPaddingArray, nullptr);
52
48
  theme.start = defaultTextInputPadding[0];
53
49
  theme.end = defaultTextInputPadding[1];
54
50
  theme.top = defaultTextInputPadding[2];
55
51
  theme.bottom = defaultTextInputPadding[3];
56
52
  surfaceIdToThemePaddingMap_.emplace(std::make_pair(surfaceId, theme));
57
- env->ReleaseFloatArrayElements(
58
- defaultTextInputPaddingArray, defaultTextInputPadding, JNI_ABORT);
53
+ env->ReleaseFloatArrayElements(defaultTextInputPaddingArray, defaultTextInputPadding, JNI_ABORT);
59
54
  }
60
55
 
61
56
  return std::make_shared<AndroidTextInputShadowNode::ConcreteState>(
62
- std::make_shared<const AndroidTextInputState>(
63
- AndroidTextInputState({}, {}, {}, 0)),
64
- family);
57
+ std::make_shared<const AndroidTextInputState>(AndroidTextInputState({}, {}, {}, 0)), family);
65
58
  }
66
59
  */
67
60
 
@@ -74,43 +67,36 @@ virtual State::Shared createInitialState(
74
67
  textInputShadowNode.setTextLayoutManager(textLayoutManager_);
75
68
 
76
69
  /*
77
- int surfaceId = textInputShadowNode.getSurfaceId();
78
- if (surfaceIdToThemePaddingMap_.find(surfaceId) !=
79
- surfaceIdToThemePaddingMap_.end()) {
80
- const auto& theme = surfaceIdToThemePaddingMap_[surfaceId];
70
+ int surfaceId = textInputShadowNode.getSurfaceId();
71
+ if (surfaceIdToThemePaddingMap_.find(surfaceId) != surfaceIdToThemePaddingMap_.end()) {
72
+ const auto &theme = surfaceIdToThemePaddingMap_[surfaceId];
81
73
 
82
- auto& textInputProps = textInputShadowNode.getConcreteProps();
74
+ auto &textInputProps = textInputShadowNode.getConcreteProps();
83
75
 
84
76
  // Override padding
85
77
  // Node is still unsealed during adoption, before layout is complete
86
78
  // TODO: T62959168 account for RTL and paddingLeft when setting default
87
79
  // paddingStart, and vice-versa with paddingRight/paddingEnd.
88
80
  // For now this assumes no RTL.
89
- auto& style = const_cast<yoga::Style&>(textInputProps.yogaStyle);
81
+ auto &style = const_cast<yoga::Style &>(textInputProps.yogaStyle);
90
82
  bool changedPadding = false;
91
- if (!textInputProps.hasPadding && !textInputProps.hasPaddingStart &&
92
- !textInputProps.hasPaddingLeft &&
83
+ if (!textInputProps.hasPadding && !textInputProps.hasPaddingStart && !textInputProps.hasPaddingLeft &&
93
84
  !textInputProps.hasPaddingHorizontal) {
94
85
  changedPadding = true;
95
- style.setPadding(
96
- yoga::Edge::Start, yoga::StyleLength::points(theme.start));
86
+ style.setPadding(yoga::Edge::Start, yoga::StyleLength::points(theme.start));
97
87
  }
98
- if (!textInputProps.hasPadding && !textInputProps.hasPaddingEnd &&
99
- !textInputProps.hasPaddingRight &&
88
+ if (!textInputProps.hasPadding && !textInputProps.hasPaddingEnd && !textInputProps.hasPaddingRight &&
100
89
  !textInputProps.hasPaddingHorizontal) {
101
90
  changedPadding = true;
102
91
  style.setPadding(yoga::Edge::End, yoga::StyleLength::points(theme.end));
103
92
  }
104
- if (!textInputProps.hasPadding && !textInputProps.hasPaddingTop &&
105
- !textInputProps.hasPaddingVertical) {
93
+ if (!textInputProps.hasPadding && !textInputProps.hasPaddingTop && !textInputProps.hasPaddingVertical) {
106
94
  changedPadding = true;
107
95
  style.setPadding(yoga::Edge::Top, yoga::StyleLength::points(theme.top));
108
96
  }
109
- if (!textInputProps.hasPadding && !textInputProps.hasPaddingBottom &&
110
- !textInputProps.hasPaddingVertical) {
97
+ if (!textInputProps.hasPadding && !textInputProps.hasPaddingBottom && !textInputProps.hasPaddingVertical) {
111
98
  changedPadding = true;
112
- style.setPadding(
113
- yoga::Edge::Bottom, yoga::StyleLength::points(theme.bottom));
99
+ style.setPadding(yoga::Edge::Bottom, yoga::StyleLength::points(theme.bottom));
114
100
  }
115
101
 
116
102
  // If the TextInput initially does not have paddingLeft or paddingStart, a
@@ -118,13 +104,11 @@ virtual State::Shared createInitialState(
118
104
  // paddingLeft update, we must explicitly unset paddingStart... (same with
119
105
  // paddingEnd)
120
106
  // TODO: support RTL
121
- if ((textInputProps.hasPadding || textInputProps.hasPaddingLeft ||
122
- textInputProps.hasPaddingHorizontal) &&
107
+ if ((textInputProps.hasPadding || textInputProps.hasPaddingLeft || textInputProps.hasPaddingHorizontal) &&
123
108
  !textInputProps.hasPaddingStart) {
124
109
  style.setPadding(yoga::Edge::Start, yoga::StyleLength::undefined());
125
110
  }
126
- if ((textInputProps.hasPadding || textInputProps.hasPaddingRight ||
127
- textInputProps.hasPaddingHorizontal) &&
111
+ if ((textInputProps.hasPadding || textInputProps.hasPaddingRight || textInputProps.hasPaddingHorizontal) &&
128
112
  !textInputProps.hasPaddingEnd) {
129
113
  style.setPadding(yoga::Edge::End, yoga::StyleLength::undefined());
130
114
  }
@@ -104,6 +104,11 @@ struct SvgDataImageHandler
104
104
  ::Microsoft::ReactNative::Composition::AutoDrawDrawingSurface autoDraw(drawingBrush, 1.0, &pt);
105
105
  auto renderTarget = autoDraw.GetRenderTarget();
106
106
 
107
+ // Defensive check: ensure device context is valid before D2D operations
108
+ if (!renderTarget) {
109
+ return nullptr;
110
+ }
111
+
107
112
  winrt::com_ptr<ID2D1DeviceContext5> deviceContext5;
108
113
  winrt::check_hresult(renderTarget->QueryInterface(IID_ID2D1DeviceContext5, deviceContext5.put_void()));
109
114
 
@@ -21,6 +21,7 @@ namespace Microsoft.ReactNative.Composition
21
21
  [experimental]
22
22
  delegate void ComponentIslandComponentViewInitializer(ContentIslandComponentView view);
23
23
 
24
+
24
25
  [webhosthidden]
25
26
  [experimental]
26
27
  delegate void PortalComponentViewInitializer(PortalComponentView view);
@@ -157,4 +157,4 @@ void ImageLoader::queryCache(
157
157
  result.Resolve(React::JSValueObject{});
158
158
  }
159
159
 
160
- } // namespace Microsoft::ReactNative
160
+ } // namespace Microsoft::ReactNative
@@ -11,19 +11,18 @@
11
11
 
12
12
  #include <Fabric/Composition/CompositionContextHelper.h>
13
13
  #include <Fabric/Composition/CompositionUIService.h>
14
+ #include <winrt/Microsoft.UI.Windowing.h>
14
15
  #include <winrt/Windows.UI.Composition.h>
15
16
 
16
17
  namespace Microsoft::ReactNative {
17
18
 
18
19
  LogBox::~LogBox() {
19
- if (m_hwnd) {
20
- m_context.UIDispatcher().Post([hwnd = m_hwnd]() { DestroyWindow(hwnd); });
21
- m_hwnd = nullptr;
20
+ if (m_rnWindow) {
21
+ m_context.UIDispatcher().Post([rnWindow = m_rnWindow]() { rnWindow.Close(); });
22
+ m_rnWindow = nullptr;
22
23
  }
23
24
  }
24
25
 
25
- constexpr PCWSTR c_logBoxWindowClassName = L"MS_REACTNATIVE_LOGBOX";
26
- constexpr auto CompHostProperty = L"CompHost";
27
26
  const int LOGBOX_DEFAULT_WIDTH = 700;
28
27
  const int LOGBOX_DEFAULT_HEIGHT = 1000;
29
28
 
@@ -47,108 +46,35 @@ void LogBox::Hide() noexcept {
47
46
  });
48
47
  }
49
48
 
50
- LRESULT CALLBACK LogBoxWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) noexcept {
51
- auto data = reinterpret_cast<::IUnknown *>(GetProp(hwnd, CompHostProperty));
52
- winrt::com_ptr<winrt::IUnknown> spunk;
53
- React::CompositionHwndHost host{nullptr};
54
-
55
- if (data) {
56
- winrt::check_hresult(data->QueryInterface(winrt::guid_of<React::CompositionHwndHost>(), winrt::put_abi(host)));
57
- auto result = static_cast<LRESULT>(host.TranslateMessage(message, wparam, lparam));
58
- if (result)
59
- return result;
60
- }
61
-
62
- switch (message) {
63
- case WM_NCCREATE: {
64
- auto cs = reinterpret_cast<CREATESTRUCT *>(lparam);
65
- auto windowData = static_cast<::IUnknown *>(cs->lpCreateParams);
66
- SetProp(hwnd, CompHostProperty, reinterpret_cast<::IUnknown *>(windowData));
67
- break;
68
- }
69
- case WM_CREATE: {
70
- host.Initialize((uint64_t)hwnd);
71
- break;
72
- }
73
- case WM_CLOSE: {
74
- // Just hide the window instead of destroying it
75
- ::ShowWindow(hwnd, SW_HIDE);
76
- return 0;
77
- }
78
- case WM_DESTROY: {
79
- data->Release();
80
- SetProp(hwnd, CompHostProperty, nullptr);
81
- }
82
- }
83
-
84
- return DefWindowProc(hwnd, message, wparam, lparam);
85
- }
86
-
87
- void LogBox::RegisterWndClass() noexcept {
88
- static bool registered = false;
89
- if (registered)
90
- return;
91
-
92
- HINSTANCE hInstance = GetModuleHandle(NULL);
93
-
94
- WNDCLASSEXW wcex = {};
95
- wcex.cbSize = sizeof(WNDCLASSEX);
96
- wcex.style = CS_HREDRAW | CS_VREDRAW;
97
- wcex.lpfnWndProc = &LogBoxWndProc;
98
- wcex.cbClsExtra = DLGWINDOWEXTRA;
99
- wcex.cbWndExtra = sizeof(winrt::impl::abi<winrt::Microsoft::ReactNative::ICompositionHwndHost>::type *);
100
- wcex.hInstance = hInstance;
101
- wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
102
- wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
103
- wcex.lpszClassName = c_logBoxWindowClassName;
104
- ATOM classId = RegisterClassEx(&wcex);
105
- WINRT_VERIFY(classId);
106
- winrt::check_win32(!classId);
107
-
108
- registered = true;
109
- }
110
-
111
49
  void LogBox::ShowOnUIThread() noexcept {
112
50
  auto host = React::implementation::ReactNativeHost::GetReactNativeHost(m_context.Properties());
113
51
  if (!host)
114
52
  return;
115
53
 
116
- RegisterWndClass();
117
-
118
- if (!m_hwnd) {
119
- auto CompositionHwndHost = React::CompositionHwndHost();
54
+ if (!m_rnWindow) {
55
+ m_rnWindow = winrt::Microsoft::ReactNative::ReactNativeWindow::CreateFromCompositor(
56
+ winrt::Microsoft::ReactNative::Composition::CompositionUIService::GetCompositor(
57
+ host.InstanceSettings().Properties()));
120
58
  winrt::Microsoft::ReactNative::ReactViewOptions viewOptions;
121
59
  viewOptions.ComponentName(L"LogBox");
122
- CompositionHwndHost.ReactViewHost(
60
+ m_rnWindow.AppWindow().Title(L"LogBox");
61
+ m_rnWindow.AppWindow().Closing([](winrt::Microsoft::UI::Windowing::AppWindow const & /*appWindow*/,
62
+ winrt::Microsoft::UI::Windowing::AppWindowClosingEventArgs const &args) {
63
+ // Prevent default close behavior - as JS will never try to show the logbox again if it isn't hidden through JS
64
+ args.Cancel(true);
65
+ });
66
+ m_rnWindow.ReactNativeIsland().ReactViewHost(
123
67
  winrt::Microsoft::ReactNative::ReactCoreInjection::MakeViewHost(host, viewOptions));
124
- HINSTANCE hInstance = GetModuleHandle(NULL);
125
- winrt::impl::abi<winrt::Microsoft::ReactNative::ICompositionHwndHost>::type *pHost{nullptr};
126
- winrt::com_ptr<::IUnknown> spunk;
127
- CompositionHwndHost.as(spunk);
128
- spunk->AddRef(); // Will be stored in windowData
129
-
130
- m_hwnd = CreateWindow(
131
- c_logBoxWindowClassName,
132
- L"React-Native LogBox",
133
- WS_OVERLAPPEDWINDOW,
134
- CW_USEDEFAULT,
135
- CW_USEDEFAULT,
136
- LOGBOX_DEFAULT_WIDTH,
137
- LOGBOX_DEFAULT_HEIGHT,
138
- nullptr,
139
- nullptr,
140
- hInstance,
141
- spunk.get());
68
+ m_rnWindow.AppWindow().ResizeClient({LOGBOX_DEFAULT_WIDTH, LOGBOX_DEFAULT_HEIGHT});
142
69
  }
143
70
 
144
- ShowWindow(m_hwnd, SW_NORMAL);
145
- BringWindowToTop(m_hwnd);
146
- SetFocus(m_hwnd);
71
+ m_rnWindow.AppWindow().Show(true);
72
+ m_rnWindow.AppWindow().MoveInZOrderAtTop();
147
73
  }
148
74
 
149
75
  void LogBox::HideOnUIThread() noexcept {
150
- if (m_hwnd) {
151
- ::ShowWindow(m_hwnd, SW_HIDE);
76
+ if (m_rnWindow) {
77
+ m_rnWindow.AppWindow().Hide();
152
78
  }
153
79
  }
154
80
 
@@ -28,9 +28,7 @@ struct LogBox : public std::enable_shared_from_this<LogBox> {
28
28
  void HideOnUIThread() noexcept;
29
29
 
30
30
  winrt::Microsoft::ReactNative::ReactContext m_context;
31
- HWND m_hwnd{nullptr};
32
- xaml::FrameworkElement::SizeChanged_revoker m_sizeChangedRevoker;
33
- winrt::event_token m_tokenClosed;
31
+ winrt::Microsoft::ReactNative::ReactNativeWindow m_rnWindow{nullptr};
34
32
  };
35
33
 
36
34
  } // namespace Microsoft::ReactNative
@@ -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