react-native-windows 0.75.4 → 0.76.0-preview.1

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 (310) hide show
  1. package/.flowconfig +6 -4
  2. package/Directory.Build.props +4 -0
  3. package/Directory.Build.targets +5 -0
  4. package/Libraries/Alert/Alert.js +3 -0
  5. package/Libraries/Alert/Alert.windows.js +3 -0
  6. package/Libraries/Animated/AnimatedEvent.js +1 -1
  7. package/Libraries/Animated/AnimatedImplementation.js +7 -7
  8. package/Libraries/Animated/NativeAnimatedAllowlist.js +111 -0
  9. package/Libraries/Animated/animations/Animation.js +11 -1
  10. package/Libraries/Animated/animations/DecayAnimation.js +1 -1
  11. package/Libraries/Animated/animations/SpringAnimation.js +1 -1
  12. package/Libraries/Animated/animations/TimingAnimation.js +2 -1
  13. package/Libraries/Animated/components/AnimatedScrollView.js +3 -2
  14. package/Libraries/Animated/createAnimatedComponent.js +10 -9
  15. package/Libraries/Animated/nodes/AnimatedColor.js +1 -1
  16. package/Libraries/Animated/nodes/AnimatedInterpolation.js +3 -2
  17. package/Libraries/Animated/nodes/AnimatedNode.js +42 -33
  18. package/Libraries/Animated/nodes/AnimatedObject.js +56 -50
  19. package/Libraries/Animated/nodes/AnimatedProps.js +77 -40
  20. package/Libraries/Animated/nodes/AnimatedStyle.js +103 -59
  21. package/Libraries/Animated/nodes/AnimatedTracking.js +1 -1
  22. package/Libraries/Animated/nodes/AnimatedTransform.js +102 -67
  23. package/Libraries/Animated/nodes/AnimatedValue.js +2 -1
  24. package/Libraries/Animated/nodes/AnimatedWithChildren.js +21 -22
  25. package/Libraries/Animated/useAnimatedProps.js +142 -7
  26. package/Libraries/BatchedBridge/NativeModules.js +2 -0
  27. package/Libraries/Blob/FileReader.js +1 -1
  28. package/Libraries/Blob/URL.js +2 -62
  29. package/Libraries/Blob/URLSearchParams.js +71 -0
  30. package/Libraries/Components/Button.windows.js +0 -1
  31. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +1 -1
  32. package/Libraries/Components/Keyboard/KeyboardExt.js.map +1 -1
  33. package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +1 -1
  34. package/Libraries/Components/ScrollView/ScrollView.js +131 -169
  35. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
  36. package/Libraries/Components/StatusBar/StatusBar.js +3 -1
  37. package/Libraries/Components/TextInput/TextInput.d.ts +32 -2
  38. package/Libraries/Components/TextInput/TextInput.js +230 -94
  39. package/Libraries/Components/TextInput/TextInput.windows.js +230 -105
  40. package/Libraries/Components/View/ReactNativeStyleAttributes.js +22 -0
  41. package/Libraries/Components/View/ReactNativeViewAttributes.js +2 -0
  42. package/Libraries/Components/View/ReactNativeViewAttributes.windows.js +2 -0
  43. package/Libraries/Components/View/View.windows.js +32 -30
  44. package/Libraries/Components/View/ViewAccessibility.d.ts +15 -0
  45. package/Libraries/Components/View/ViewNativeComponent.js +0 -1
  46. package/Libraries/Components/View/ViewPropTypes.js +14 -0
  47. package/Libraries/Components/View/ViewPropTypes.windows.js +14 -0
  48. package/Libraries/Core/ExceptionsManager.js +2 -0
  49. package/Libraries/Core/InitializeCore.js +3 -1
  50. package/Libraries/Core/ReactFiberErrorDialog.js +3 -0
  51. package/Libraries/Core/ReactNativeVersion.js +4 -4
  52. package/Libraries/Core/setUpErrorHandling.js +7 -1
  53. package/Libraries/Core/setUpGlobals.js +1 -0
  54. package/Libraries/Core/setUpReactRefresh.js +0 -4
  55. package/Libraries/Image/AssetSourceResolver.js +28 -1
  56. package/Libraries/Image/AssetSourceResolver.windows.js +28 -1
  57. package/Libraries/Image/Image.android.js +9 -14
  58. package/Libraries/Image/Image.ios.js +11 -22
  59. package/Libraries/Image/Image.windows.js +11 -22
  60. package/Libraries/Image/ImageBackground.js +1 -8
  61. package/Libraries/Image/ImageUtils.js +9 -9
  62. package/Libraries/Image/ImageViewNativeComponent.js +1 -0
  63. package/Libraries/Inspector/Inspector.js +3 -2
  64. package/Libraries/Inspector/InspectorPanel.js +16 -10
  65. package/Libraries/Inspector/NetworkOverlay.js +1 -1
  66. package/Libraries/Interaction/TaskQueue.js +1 -0
  67. package/Libraries/Lists/FlatList.js +1 -1
  68. package/Libraries/Lists/SectionList.js +2 -2
  69. package/Libraries/Lists/SectionListModern.js +3 -3
  70. package/Libraries/LogBox/Data/LogBoxData.js +24 -3
  71. package/Libraries/LogBox/LogBoxNotificationContainer.js +3 -2
  72. package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +9 -8
  73. package/Libraries/LogBox/UI/LogBoxInspectorHeader.windows.js +9 -8
  74. package/Libraries/Modal/Modal.js +0 -1
  75. package/Libraries/NativeComponent/BaseViewConfig.android.js +8 -0
  76. package/Libraries/NativeComponent/BaseViewConfig.ios.js +7 -0
  77. package/Libraries/NativeComponent/BaseViewConfig.windows.js +7 -0
  78. package/Libraries/NativeComponent/NativeComponentRegistry.js +22 -22
  79. package/Libraries/NativeComponent/StaticViewConfigValidator.js +0 -21
  80. package/Libraries/Network/XMLHttpRequest.js +4 -2
  81. package/Libraries/ReactNative/AppContainer-dev.js +1 -5
  82. package/Libraries/ReactNative/AppContainer-prod.js +1 -5
  83. package/Libraries/ReactNative/AppContainer.js +1 -2
  84. package/Libraries/ReactNative/AppRegistry.d.ts +0 -4
  85. package/Libraries/ReactNative/AppRegistry.js +1 -7
  86. package/Libraries/ReactNative/BridgelessUIManager.js +1 -0
  87. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +1 -1
  88. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +5 -5
  89. package/Libraries/ReactNative/RendererImplementation.js +26 -4
  90. package/Libraries/ReactNative/getNativeComponentAttributes.js +8 -0
  91. package/Libraries/ReactNative/renderApplication.js +1 -3
  92. package/Libraries/Renderer/shims/ReactNativeTypes.js +11 -4
  93. package/Libraries/StyleSheet/StyleSheet.js +1 -1
  94. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +57 -0
  95. package/Libraries/StyleSheet/StyleSheetTypes.js +60 -5
  96. package/Libraries/StyleSheet/processBackgroundImage.js +384 -0
  97. package/Libraries/StyleSheet/processBoxShadow.js +211 -0
  98. package/Libraries/StyleSheet/processFilter.js +231 -42
  99. package/Libraries/Text/Text.js +394 -196
  100. package/Libraries/Text/Text.windows.js +476 -300
  101. package/Libraries/Text/TextNativeComponent.js +2 -1
  102. package/Libraries/TurboModule/TurboModuleRegistry.js +13 -50
  103. package/Libraries/Types/CodegenTypes.js +3 -1
  104. package/Libraries/Utilities/Appearance.js +108 -84
  105. package/Libraries/Utilities/DevLoadingView.js +2 -4
  106. package/Libraries/Utilities/HMRClient.js +2 -1
  107. package/Libraries/Utilities/ReactNativeTestTools.js +1 -1
  108. package/Libraries/Utilities/createPerformanceLogger.js +0 -9
  109. package/Libraries/Utilities/stringifyViewConfig.js +22 -0
  110. package/Libraries/Utilities/useColorScheme.js +3 -3
  111. package/Libraries/WebSocket/WebSocket.js +1 -1
  112. package/Libraries/promiseRejectionTrackingOptions.js +1 -1
  113. package/Libraries/vendor/emitter/EventEmitter.js +6 -5
  114. package/Microsoft.ReactNative/ComponentView.idl +11 -0
  115. package/Microsoft.ReactNative/Composition.Input.idl +1 -0
  116. package/Microsoft.ReactNative/CompositionSwitcher.idl +3 -0
  117. package/Microsoft.ReactNative/Fabric/AbiComponentDescriptor.cpp +9 -9
  118. package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.cpp +9 -9
  119. package/Microsoft.ReactNative/Fabric/ComponentView.cpp +7 -9
  120. package/Microsoft.ReactNative/Fabric/ComponentView.h +5 -6
  121. package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.cpp +4 -0
  122. package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h +1 -0
  123. package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +44 -13
  124. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +42 -5
  125. package/Microsoft.ReactNative/Fabric/Composition/CompositionHwndHost.cpp +1 -0
  126. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +81 -63
  127. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +2 -3
  128. package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.cpp +8 -6
  129. package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.h +1 -2
  130. package/Microsoft.ReactNative/Fabric/Composition/FocusManager.cpp +20 -6
  131. package/Microsoft.ReactNative/Fabric/Composition/FocusManager.h +13 -6
  132. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +2 -3
  133. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.h +1 -2
  134. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +72 -54
  135. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +14 -4
  136. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +26 -8
  137. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +5 -2
  138. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +18 -7
  139. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.h +1 -2
  140. package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.cpp +6 -6
  141. package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.h +1 -2
  142. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +97 -140
  143. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +8 -4
  144. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.cpp +18 -11
  145. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.h +5 -4
  146. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputState.cpp +0 -13
  147. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputState.h +0 -3
  148. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +29 -4
  149. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +2 -0
  150. package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.cpp +1 -2
  151. package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.h +1 -2
  152. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +28 -12
  153. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/HostPlatformColor.h +33 -0
  154. package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.cpp +26 -9
  155. package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.h +10 -4
  156. package/Microsoft.ReactNative/IReactModuleBuilder.cpp +5 -0
  157. package/Microsoft.ReactNative/IReactModuleBuilder.h +1 -0
  158. package/Microsoft.ReactNative/IReactModuleBuilder.idl +9 -0
  159. package/Microsoft.ReactNative/IReactViewComponentBuilder.idl +8 -1
  160. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +2 -0
  161. package/Microsoft.ReactNative/Modules/AlertModule.cpp +3 -1
  162. package/Microsoft.ReactNative/Modules/AppearanceModule.cpp +1 -1
  163. package/Microsoft.ReactNative/Modules/AppearanceModule.h +7 -1
  164. package/Microsoft.ReactNative/Modules/DevSettingsModule.cpp +3 -3
  165. package/Microsoft.ReactNative/Modules/DevSettingsModule.h +1 -1
  166. package/Microsoft.ReactNative/Modules/LinkingManagerModule.cpp +2 -2
  167. package/Microsoft.ReactNative/Modules/LinkingManagerModule.h +1 -1
  168. package/Microsoft.ReactNative/Modules/LogBoxModule.cpp +9 -0
  169. package/Microsoft.ReactNative/Modules/LogBoxModule.h +2 -0
  170. package/Microsoft.ReactNative/Modules/SampleTurboModule.cpp +121 -0
  171. package/Microsoft.ReactNative/Modules/SampleTurboModule.h +90 -0
  172. package/Microsoft.ReactNative/ReactHost/MsoReactContext.cpp +0 -7
  173. package/Microsoft.ReactNative/ReactHost/MsoReactContext.h +0 -5
  174. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +5 -1
  175. package/Microsoft.ReactNative/ReactInstanceSettingsBuilder.cpp +59 -0
  176. package/Microsoft.ReactNative/ReactInstanceSettingsBuilder.h +23 -0
  177. package/Microsoft.ReactNative/ReactNativeAppBuilder.cpp +179 -0
  178. package/Microsoft.ReactNative/ReactNativeAppBuilder.h +35 -0
  179. package/Microsoft.ReactNative/ReactNativeAppBuilder.idl +69 -0
  180. package/Microsoft.ReactNative/ReactNativeIsland.idl +2 -0
  181. package/Microsoft.ReactNative/ReactNativeWin32App.cpp +82 -0
  182. package/Microsoft.ReactNative/ReactNativeWin32App.h +38 -0
  183. package/Microsoft.ReactNative/TurboModulesProvider.cpp +45 -0
  184. package/Microsoft.ReactNative/Views/DynamicAutomationPeer.cpp +2 -1
  185. package/Microsoft.ReactNative/Views/FlyoutViewManager.cpp +25 -16
  186. package/Microsoft.ReactNative/packages.fabric.lock.json +159 -0
  187. package/Microsoft.ReactNative/packages.lock.json +11 -12
  188. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +3 -4
  189. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems.filters +3 -0
  190. package/Microsoft.ReactNative.Cxx/ModuleRegistration.cpp +2 -2
  191. package/Microsoft.ReactNative.Cxx/ModuleRegistration.h +62 -4
  192. package/Microsoft.ReactNative.Cxx/NativeModules.h +131 -14
  193. package/Microsoft.ReactNative.Managed/packages.lock.json +9 -9
  194. package/Microsoft.ReactNative.Managed.CodeGen/ReactNativeNames.cs +10 -2
  195. package/PropertySheets/Autolink.props +1 -1
  196. package/PropertySheets/Bundle.props +1 -1
  197. package/PropertySheets/Codegen.props +1 -1
  198. package/PropertySheets/Generated/PackageVersion.g.props +4 -4
  199. package/PropertySheets/NuGet.LockFile.props +18 -0
  200. package/README.md +29 -29
  201. package/ReactCommon/ReactCommon.vcxproj +5 -1
  202. package/ReactCommon/ReactCommon.vcxproj.filters +11 -2
  203. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp +2 -7
  204. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.cpp +441 -0
  205. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.h +266 -0
  206. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/Utf8.h +56 -0
  207. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Base.h +3 -1
  208. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Bridging.h +2 -2
  209. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/CallbackWrapper.h +1 -1
  210. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Convert.h +172 -0
  211. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/EventEmitter.h +4 -5
  212. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Function.h +2 -2
  213. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModule.h +1 -1
  214. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModuleUtils.h +3 -2
  215. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/scrollview/ScrollViewProps.cpp +9 -0
  216. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/LayoutableShadowNode.cpp +363 -0
  217. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/JSRuntimeFactory.h +22 -2
  218. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +118 -51
  219. package/ReactCommon/packages.lock.json +2 -2
  220. package/Scripts/NuGetRestoreForceEvaluateAllSolutions.ps1 +8 -1
  221. package/Scripts/Tfs/Layout-MSRN-Headers.ps1 +2 -2
  222. package/Shared/Modules/WebSocketModule.cpp +1 -2
  223. package/Shared/Networking/WinRTWebSocketResource.cpp +4 -1
  224. package/Shared/Shared.vcxitems +38 -2
  225. package/Shared/Shared.vcxitems.filters +6 -1
  226. package/Shared/TurboModuleManager.cpp +0 -3
  227. package/codegen/NativeLinkingManagerSpec.g.h +3 -3
  228. package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +198 -54
  229. package/codegen/NativeSampleTurboModuleSpec.g.h +35 -0
  230. package/codegen/rnwcoreJSI-generated.cpp +245 -101
  231. package/codegen/rnwcoreJSI.h +847 -548
  232. package/index.js +3 -1
  233. package/index.windows.js +3 -1
  234. package/jest/mockComponent.js +4 -1
  235. package/jest/mockModal.js +1 -3
  236. package/jest/mockScrollView.js +1 -1
  237. package/jest/renderer.js +2 -2
  238. package/jest/setup.js +16 -13
  239. package/package.json +29 -29
  240. package/src/private/animated/NativeAnimatedHelper.js +438 -0
  241. package/src/private/animated/NativeAnimatedValidation.js +64 -0
  242. package/src/private/components/HScrollViewNativeComponents.js +56 -0
  243. package/src/private/components/SafeAreaView_INTERNAL_DO_NOT_USE.js +27 -0
  244. package/src/private/components/VScrollViewNativeComponents.js +48 -0
  245. package/src/private/components/useSyncOnScroll.js +48 -0
  246. package/src/private/featureflags/ReactNativeFeatureFlags.js +166 -16
  247. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +29 -5
  248. package/src/private/fusebox/FuseboxSessionObserver.js +42 -0
  249. package/{Libraries/Core → src/private/renderer/errorhandling}/ErrorHandlers.js +14 -4
  250. package/src/private/setup/setUpDOM.js +28 -0
  251. package/src/private/setup/setUpIntersectionObserver.js +27 -0
  252. package/src/private/setup/setUpMutationObserver.js +26 -0
  253. package/src/private/setup/setUpPerformanceObserver.js +64 -0
  254. package/src/private/specs/modules/NativeAppearance.js +3 -3
  255. package/src/private/specs/modules/NativeLinkingManager.js +1 -1
  256. package/src/private/specs/modules/NativePlatformConstantsWindows.js +7 -0
  257. package/src/private/specs/modules/NativeSampleTurboModule.js +14 -1
  258. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +6 -4
  259. package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserver.js +5 -3
  260. package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverEntry.js +3 -3
  261. package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverManager.js +14 -17
  262. package/src/private/{specs/modules → webapis/intersectionobserver/specs}/NativeIntersectionObserver.js +2 -2
  263. package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver/specs}/__mocks__/NativeIntersectionObserver.js +4 -4
  264. package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserver.js +5 -3
  265. package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserverManager.js +24 -15
  266. package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationRecord.js +4 -6
  267. package/src/private/{specs/modules → webapis/mutationobserver/specs}/NativeMutationObserver.js +2 -2
  268. package/{Libraries/MutationObserver → src/private/webapis/mutationobserver/specs}/__mocks__/NativeMutationObserver.js +5 -5
  269. package/src/private/webapis/performance/{EventCounts.js → EventTiming.js} +65 -3
  270. package/src/private/webapis/performance/LongTasks.js +39 -0
  271. package/src/private/webapis/performance/Performance.js +22 -9
  272. package/src/private/webapis/performance/PerformanceEntry.js +36 -18
  273. package/src/private/webapis/performance/PerformanceObserver.js +29 -43
  274. package/src/private/webapis/performance/RawPerformanceEntry.js +24 -1
  275. package/src/private/webapis/performance/UserTiming.js +17 -12
  276. package/src/private/webapis/performance/specs/NativePerformanceObserver.js +1 -1
  277. package/template/cpp-app/src/AutolinkedNativeModules.g.cpp +1 -1
  278. package/template/cpp-app/src/AutolinkedNativeModules.g.h +1 -1
  279. package/template/cs-app/src/AutolinkedNativeModules.g.cs +1 -1
  280. package/template/index.windows.bundle +1 -1
  281. package/template/metro.config.js +2 -2
  282. package/template/shared-app/src/AutolinkedNativeModules.g.props +1 -1
  283. package/template/shared-app/src/AutolinkedNativeModules.g.targets +1 -1
  284. package/templates/cpp-app/metro.config.js +2 -2
  285. package/templates/cpp-app/template.config.js +5 -5
  286. package/templates/cpp-app/windows/MyApp/AutolinkedNativeModules.g.cpp +1 -1
  287. package/templates/cpp-app/windows/MyApp/AutolinkedNativeModules.g.h +1 -1
  288. package/templates/cpp-app/windows/MyApp/MyApp.cpp +2 -0
  289. package/templates/cpp-app/windows/MyApp/MyApp.vcxproj +1 -1
  290. package/templates/cpp-lib/example/metro.config.js +2 -2
  291. package/templates/cpp-lib/template.config.js +3 -3
  292. package/templates/cpp-lib/windows/MyLib/MyLib.h +3 -3
  293. package/templates/cpp-lib/windows/MyLib/MyLib.vcxproj +1 -1
  294. package/types/experimental.d.ts +20 -1
  295. package/Libraries/Animated/NativeAnimatedHelper.js +0 -615
  296. package/Libraries/Core/setUpIntersectionObserver.js +0 -16
  297. package/Libraries/Core/setUpMutationObserver.js +0 -16
  298. package/Libraries/Core/setUpPerformanceObserver.js +0 -18
  299. package/Libraries/IntersectionObserver/NativeIntersectionObserver.js +0 -13
  300. package/Libraries/MutationObserver/NativeMutationObserver.js +0 -13
  301. package/Libraries/Utilities/verifyComponentAttributeEquivalence.js +0 -135
  302. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/algorithm/CalculateLayout.cpp +0 -2396
  303. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/config/Config.cpp +0 -136
  304. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/config/Config.h +0 -92
  305. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/LayoutResults.cpp +0 -48
  306. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/LayoutResults.h +0 -122
  307. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/Node.cpp +0 -388
  308. package/src/private/core/setUpDOM.js +0 -18
  309. package/src/private/webapis/performance/PerformanceEventTiming.js +0 -55
  310. /package/src/private/{core → styles}/composeStyles.js +0 -0
package/.flowconfig CHANGED
@@ -38,6 +38,7 @@
38
38
  <PROJECT_ROOT>/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js
39
39
  <PROJECT_ROOT>/Libraries/Utilities/Platform.flow.js
40
40
 
41
+
41
42
  ; Ignore react-native files in node_modules since they are copied into project root
42
43
  .*/node_modules/react-native/.*
43
44
 
@@ -53,8 +54,6 @@
53
54
  .*/node_modules/sample-apps/.*
54
55
  .*/node_modules/playground/.*
55
56
 
56
- ; Ignore templates for 'react-native init'
57
- <PROJECT_ROOT>/packages/react-native/template/.*
58
57
  <PROJECT_ROOT>/packages/react-native/sdks/.*
59
58
 
60
59
  ; Ignore the codegen e2e tests
@@ -66,6 +65,9 @@
66
65
  ; Ignore "BUCK" generated dirs
67
66
  <PROJECT_ROOT>/\.buckd/
68
67
 
68
+ ; Ignore cache files
69
+ .*/node_modules/.cache*
70
+
69
71
  ; Ignore the src-win folder - flow files are combined with ones from react-native into the root Libraries folder
70
72
  .*/vnext/src-win/.*
71
73
 
@@ -121,7 +123,7 @@ module.name_mapper='^react-native-windows$' -> '<PROJECT_ROOT>/index.windows.js'
121
123
  module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/\1'
122
124
  module.name_mapper='^react-native-windows/\(.*\)$' -> '<PROJECT_ROOT>/\1'
123
125
  module.name_mapper='^@react-native/dev-middleware$' -> '<PROJECT_ROOT>/\1'
124
- module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/Libraries/Image/RelativeImageStub'
126
+ module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\|xml\)$' -> '<PROJECT_ROOT>/Libraries/Image/RelativeImageStub'
125
127
 
126
128
  suppress_type=$FlowIssue
127
129
  suppress_type=$FlowFixMe
@@ -152,4 +154,4 @@ untyped-import
152
154
  untyped-type-import
153
155
 
154
156
  [version]
155
- ^0.238.0
157
+ ^0.245.2
@@ -7,6 +7,9 @@
7
7
  <PropertyGroup>
8
8
  <SolutionDir Condition="'$(SolutionDir)' == '' OR '$(SolutionDir)' == '*Undefined*'">$(MSBuildThisFileDirectory)</SolutionDir>
9
9
 
10
+ <!-- This property can be used to affect project builds in-repo (as opposed to by customers) -->
11
+ <BuildingInRnwRepo Condition="'$(BuildingInRnwRepo)' == '' AND Exists('$(MSBuildThisFileDirectory)\src-win')">true</BuildingInRnwRepo>
12
+
10
13
  <!-- This property sets the CscTask to print the full path of the csharp file on errors and warnings rather than just the filename. -->
11
14
  <GenerateFullPaths>true</GenerateFullPaths>
12
15
 
@@ -14,6 +17,7 @@
14
17
  SourceLink is disabled by default since customer projects are still building our projects and therefore we don't want to force customers to use this.
15
18
  The PR (windows-vs-pr.yml) and CI (publish.yml() turn it back on.
16
19
  -->
20
+ <EnableSourceLink Condition="'$(EnableSourceLink)' == '' AND '$(BuildingInRnwRepo)' == 'true'">true</EnableSourceLink>
17
21
  <EnableSourceLink Condition="'$(EnableSourceLink)' == ''">false</EnableSourceLink>
18
22
  <!-- When bumping the Folly version, be sure to bump the git hash of that version's commit and build Folly.vcxproj (to update its cgmanifest.json) too. -->
19
23
  <FollyVersion>2023.11.06.00</FollyVersion>
@@ -21,6 +21,11 @@
21
21
  <MSBuild Projects="$(MSBuildProjectFile)" Targets="Restore" Properties="RestoreProjectStyle=PackagesConfig;RestorePackagesConfig=true;RestoreUseStaticGraphEvaluation=false" />
22
22
  </Target>
23
23
 
24
+ <!-- This ensures NuGet restores use the nuget config's feed and not any pre-installed files. -->
25
+ <PropertyGroup>
26
+ <RestoreAdditionalProjectFallbackFolders></RestoreAdditionalProjectFallbackFolders>
27
+ </PropertyGroup>
28
+
24
29
  <PropertyGroup Label="WindowsAppSDKOverrides" Condition="'$(Platform)' == 'ARM64EC'">
25
30
  <Ixp-Platform>win10-x64</Ixp-Platform>
26
31
  <_WindowsAppSDKFoundationPlatform>x64</_WindowsAppSDKFoundationPlatform>
@@ -98,10 +98,13 @@ class Alert {
98
98
  const onAction = (action, buttonKey) => {
99
99
  if (action === constants.buttonClicked) {
100
100
  if (buttonKey === constants.buttonNeutral) {
101
+ // $FlowFixMe[incompatible-type]
101
102
  buttonNeutral.onPress && buttonNeutral.onPress();
102
103
  } else if (buttonKey === constants.buttonNegative) {
104
+ // $FlowFixMe[incompatible-type]
103
105
  buttonNegative.onPress && buttonNegative.onPress();
104
106
  } else if (buttonKey === constants.buttonPositive) {
107
+ // $FlowFixMe[incompatible-type]
105
108
  buttonPositive.onPress && buttonPositive.onPress();
106
109
  }
107
110
  } else if (action === constants.dismissed) {
@@ -96,10 +96,13 @@ class Alert {
96
96
  const onAction = (action, buttonKey) => {
97
97
  if (action === constants.buttonClicked) {
98
98
  if (buttonKey === constants.buttonNeutral) {
99
+ // $FlowFixMe[incompatible-type]
99
100
  buttonNeutral.onPress && buttonNeutral.onPress();
100
101
  } else if (buttonKey === constants.buttonNegative) {
102
+ // $FlowFixMe[incompatible-type]
101
103
  buttonNegative.onPress && buttonNegative.onPress();
102
104
  } else if (buttonKey === constants.buttonPositive) {
105
+ // $FlowFixMe[incompatible-type]
103
106
  buttonPositive.onPress && buttonPositive.onPress();
104
107
  }
105
108
  } else if (action === constants.dismissed) {
@@ -13,7 +13,7 @@
13
13
  import type {PlatformConfig} from './AnimatedPlatformConfig';
14
14
 
15
15
  import {findNodeHandle} from '../ReactNative/RendererProxy';
16
- import NativeAnimatedHelper from './NativeAnimatedHelper';
16
+ import NativeAnimatedHelper from '../../src/private/animated/NativeAnimatedHelper';
17
17
  import AnimatedValue from './nodes/AnimatedValue';
18
18
  import AnimatedValueXY from './nodes/AnimatedValueXY';
19
19
  import invariant from 'invariant';
@@ -39,7 +39,7 @@ import AnimatedValue from './nodes/AnimatedValue';
39
39
  import AnimatedValueXY from './nodes/AnimatedValueXY';
40
40
 
41
41
  export type CompositeAnimation = {
42
- start: (callback?: ?EndCallback) => void,
42
+ start: (callback?: ?EndCallback, isLooping?: boolean) => void,
43
43
  stop: () => void,
44
44
  reset: () => void,
45
45
  _startNativeLoop: (iterations?: number) => void,
@@ -234,8 +234,8 @@ const timing = function (
234
234
 
235
235
  return (
236
236
  maybeVectorAnim(value, config, timing) || {
237
- start: function (callback?: ?EndCallback): void {
238
- start(value, config, callback);
237
+ start: function (callback?: ?EndCallback, isLooping?: boolean): void {
238
+ start(value, {...config, isLooping}, callback);
239
239
  },
240
240
 
241
241
  stop: function (): void {
@@ -305,7 +305,7 @@ const sequence = function (
305
305
  ): CompositeAnimation {
306
306
  let current = 0;
307
307
  return {
308
- start: function (callback?: ?EndCallback) {
308
+ start: function (callback?: ?EndCallback, isLooping?: boolean) {
309
309
  const onComplete = function (result: EndResult) {
310
310
  if (!result.finished) {
311
311
  callback && callback(result);
@@ -321,13 +321,13 @@ const sequence = function (
321
321
  return;
322
322
  }
323
323
 
324
- animations[current].start(onComplete);
324
+ animations[current].start(onComplete, isLooping);
325
325
  };
326
326
 
327
327
  if (animations.length === 0) {
328
328
  callback && callback({finished: true});
329
329
  } else {
330
- animations[current].start(onComplete);
330
+ animations[current].start(onComplete, isLooping);
331
331
  }
332
332
  },
333
333
 
@@ -477,7 +477,7 @@ const loop = function (
477
477
  } else {
478
478
  iterationsSoFar++;
479
479
  resetBeforeIteration && animation.reset();
480
- animation.start(restart);
480
+ animation.start(restart, iterations === -1);
481
481
  }
482
482
  };
483
483
  if (!animation || iterations === 0) {
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ */
10
+
11
+ import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags';
12
+
13
+ /**
14
+ * Styles allowed by the native animated implementation.
15
+ *
16
+ * In general native animated implementation should support any numeric or color property that
17
+ * doesn't need to be updated through the shadow view hierarchy (all non-layout properties).
18
+ */
19
+ const SUPPORTED_COLOR_STYLES: {[string]: boolean} = {
20
+ backgroundColor: true,
21
+ borderBottomColor: true,
22
+ borderColor: true,
23
+ borderEndColor: true,
24
+ borderLeftColor: true,
25
+ borderRightColor: true,
26
+ borderStartColor: true,
27
+ borderTopColor: true,
28
+ color: true,
29
+ tintColor: true,
30
+ };
31
+
32
+ const SUPPORTED_STYLES: {[string]: boolean} = {
33
+ ...SUPPORTED_COLOR_STYLES,
34
+ borderBottomEndRadius: true,
35
+ borderBottomLeftRadius: true,
36
+ borderBottomRightRadius: true,
37
+ borderBottomStartRadius: true,
38
+ borderEndEndRadius: true,
39
+ borderEndStartRadius: true,
40
+ borderRadius: true,
41
+ borderTopEndRadius: true,
42
+ borderTopLeftRadius: true,
43
+ borderTopRightRadius: true,
44
+ borderTopStartRadius: true,
45
+ borderStartEndRadius: true,
46
+ borderStartStartRadius: true,
47
+ elevation: true,
48
+ opacity: true,
49
+ transform: true,
50
+ zIndex: true,
51
+ /* ios styles */
52
+ shadowOpacity: true,
53
+ shadowRadius: true,
54
+ /* legacy android transform properties */
55
+ scaleX: true,
56
+ scaleY: true,
57
+ translateX: true,
58
+ translateY: true,
59
+ };
60
+
61
+ const SUPPORTED_TRANSFORMS: {[string]: boolean} = {
62
+ translateX: true,
63
+ translateY: true,
64
+ scale: true,
65
+ scaleX: true,
66
+ scaleY: true,
67
+ rotate: true,
68
+ rotateX: true,
69
+ rotateY: true,
70
+ rotateZ: true,
71
+ perspective: true,
72
+ skewX: true,
73
+ skewY: true,
74
+ matrix: ReactNativeFeatureFlags.shouldUseAnimatedObjectForTransform(),
75
+ };
76
+
77
+ const SUPPORTED_INTERPOLATION_PARAMS: {[string]: boolean} = {
78
+ inputRange: true,
79
+ outputRange: true,
80
+ extrapolate: true,
81
+ extrapolateRight: true,
82
+ extrapolateLeft: true,
83
+ };
84
+
85
+ export function allowInterpolationParam(param: string): void {
86
+ SUPPORTED_INTERPOLATION_PARAMS[param] = true;
87
+ }
88
+
89
+ export function allowStyleProp(prop: string): void {
90
+ SUPPORTED_STYLES[prop] = true;
91
+ }
92
+
93
+ export function allowTransformProp(prop: string): void {
94
+ SUPPORTED_TRANSFORMS[prop] = true;
95
+ }
96
+
97
+ export function isSupportedColorStyleProp(prop: string): boolean {
98
+ return SUPPORTED_COLOR_STYLES[prop] === true;
99
+ }
100
+
101
+ export function isSupportedInterpolationParam(param: string): boolean {
102
+ return SUPPORTED_INTERPOLATION_PARAMS[param] === true;
103
+ }
104
+
105
+ export function isSupportedStyleProp(prop: string): boolean {
106
+ return SUPPORTED_STYLES[prop] === true;
107
+ }
108
+
109
+ export function isSupportedTransformProp(prop: string): boolean {
110
+ return SUPPORTED_TRANSFORMS[prop] === true;
111
+ }
@@ -14,7 +14,8 @@ import type {PlatformConfig} from '../AnimatedPlatformConfig';
14
14
  import type AnimatedNode from '../nodes/AnimatedNode';
15
15
  import type AnimatedValue from '../nodes/AnimatedValue';
16
16
 
17
- import NativeAnimatedHelper from '../NativeAnimatedHelper';
17
+ import * as ReactNativeFeatureFlags from '../../../src/private/featureflags/ReactNativeFeatureFlags';
18
+ import NativeAnimatedHelper from '../../../src/private/animated/NativeAnimatedHelper';
18
19
  import AnimatedProps from '../nodes/AnimatedProps';
19
20
 
20
21
  export type EndResult = {finished: boolean, value?: number, ...};
@@ -26,6 +27,7 @@ export type AnimationConfig = {
26
27
  platformConfig?: PlatformConfig,
27
28
  onComplete?: ?EndCallback,
28
29
  iterations?: number,
30
+ isLooping?: boolean,
29
31
  };
30
32
 
31
33
  let startNativeAnimationNextId = 1;
@@ -38,6 +40,7 @@ export default class Animation {
38
40
  __isInteraction: boolean;
39
41
  __onEnd: ?EndCallback;
40
42
  __iterations: number;
43
+ __isLooping: ?boolean;
41
44
 
42
45
  _nativeId: number;
43
46
 
@@ -107,6 +110,13 @@ export default class Animation {
107
110
  if (value != null) {
108
111
  animatedValue.__onAnimatedValueUpdateReceived(value);
109
112
 
113
+ if (
114
+ ReactNativeFeatureFlags.shouldSkipStateUpdatesForLoopingAnimations() &&
115
+ this.__isLooping
116
+ ) {
117
+ return;
118
+ }
119
+
110
120
  // Once the JS side node is synced with the updated values, trigger an
111
121
  // update on the AnimatedProps nodes to call any registered callbacks.
112
122
  this.__findAnimatedPropsNodes(animatedValue).forEach(node =>
@@ -14,7 +14,7 @@ import type {PlatformConfig} from '../AnimatedPlatformConfig';
14
14
  import type AnimatedValue from '../nodes/AnimatedValue';
15
15
  import type {AnimationConfig, EndCallback} from './Animation';
16
16
 
17
- import NativeAnimatedHelper from '../NativeAnimatedHelper';
17
+ import NativeAnimatedHelper from '../../../src/private/animated/NativeAnimatedHelper';
18
18
  import Animation from './Animation';
19
19
 
20
20
  export type DecayAnimationConfig = {
@@ -16,7 +16,7 @@ import type AnimatedValue from '../nodes/AnimatedValue';
16
16
  import type AnimatedValueXY from '../nodes/AnimatedValueXY';
17
17
  import type {AnimationConfig, EndCallback} from './Animation';
18
18
 
19
- import NativeAnimatedHelper from '../NativeAnimatedHelper';
19
+ import NativeAnimatedHelper from '../../../src/private/animated/NativeAnimatedHelper';
20
20
  import AnimatedColor from '../nodes/AnimatedColor';
21
21
  import * as SpringConfig from '../SpringConfig';
22
22
  import Animation from './Animation';
@@ -17,7 +17,7 @@ import type AnimatedValue from '../nodes/AnimatedValue';
17
17
  import type AnimatedValueXY from '../nodes/AnimatedValueXY';
18
18
  import type {AnimationConfig, EndCallback} from './Animation';
19
19
 
20
- import NativeAnimatedHelper from '../NativeAnimatedHelper';
20
+ import NativeAnimatedHelper from '../../../src/private/animated/NativeAnimatedHelper';
21
21
  import AnimatedColor from '../nodes/AnimatedColor';
22
22
  import Animation from './Animation';
23
23
 
@@ -80,6 +80,7 @@ export default class TimingAnimation extends Animation {
80
80
  this._useNativeDriver = NativeAnimatedHelper.shouldUseNativeDriver(config);
81
81
  this._platformConfig = config.platformConfig;
82
82
  this.__isInteraction = config.isInteraction ?? !this._useNativeDriver;
83
+ this.__isLooping = config.isLooping;
83
84
  }
84
85
 
85
86
  __getNativeAnimationConfig(): any {
@@ -46,6 +46,7 @@ const AnimatedScrollView: AnimatedComponentType<Props, Instance> =
46
46
  props.style != null
47
47
  ) {
48
48
  return (
49
+ // $FlowFixMe[prop-missing]
49
50
  <AnimatedScrollViewWithInvertedRefreshControl
50
51
  scrollEventThrottle={0.0001}
51
52
  {...props}
@@ -71,7 +72,7 @@ const AnimatedScrollViewWithInvertedRefreshControl = React.forwardRef(
71
72
  props: {
72
73
  ...React.ElementConfig<typeof ScrollView>,
73
74
  // $FlowFixMe[unclear-type] Same Flow type as `refreshControl` in ScrollView
74
- refreshControl: React.Element<any>,
75
+ refreshControl: ExactReactElement_DEPRECATED<any>,
75
76
  },
76
77
  forwardedRef:
77
78
  | {current: Instance | null, ...}
@@ -97,7 +98,7 @@ const AnimatedScrollViewWithInvertedRefreshControl = React.forwardRef(
97
98
  >(intermediatePropsForRefreshControl);
98
99
  // NOTE: Assumes that refreshControl.ref` and `refreshControl.style` can be
99
100
  // safely clobbered.
100
- const refreshControl: React.Element<typeof RefreshControl> =
101
+ const refreshControl: ExactReactElement_DEPRECATED<typeof RefreshControl> =
101
102
  React.cloneElement(props.refreshControl, {
102
103
  ...refreshControlAnimatedProps,
103
104
  ref: refreshControlRef,
@@ -8,21 +8,22 @@
8
8
  * @format
9
9
  */
10
10
 
11
- import composeStyles from '../../src/private/core/composeStyles';
11
+ import composeStyles from '../../src/private/styles/composeStyles';
12
12
  import View from '../Components/View/View';
13
13
  import useMergeRefs from '../Utilities/useMergeRefs';
14
14
  import useAnimatedProps from './useAnimatedProps';
15
15
  import * as React from 'react';
16
16
  import {useMemo} from 'react';
17
17
 
18
- // $FlowFixMe[deprecated-type]
19
- export type AnimatedProps<Props: {...}> = $ObjMap<
20
- Props &
21
- $ReadOnly<{
22
- passthroughAnimatedPropExplicitValues?: React.ElementConfig<typeof View>,
23
- }>,
24
- () => any,
25
- >;
18
+ export type AnimatedProps<Props: {...}> = {
19
+ // eslint-disable-next-line no-unused-vars
20
+ +[_K in keyof (Props &
21
+ $ReadOnly<{
22
+ passthroughAnimatedPropExplicitValues?: React.ElementConfig<
23
+ typeof View,
24
+ >,
25
+ }>)]: any,
26
+ };
26
27
 
27
28
  export type AnimatedComponentType<
28
29
  Props: {...},
@@ -17,7 +17,7 @@ import type {PlatformConfig} from '../AnimatedPlatformConfig';
17
17
 
18
18
  import normalizeColor from '../../StyleSheet/normalizeColor';
19
19
  import {processColorObject} from '../../StyleSheet/PlatformColorValueTypes';
20
- import NativeAnimatedHelper from '../NativeAnimatedHelper';
20
+ import NativeAnimatedHelper from '../../../src/private/animated/NativeAnimatedHelper';
21
21
  import AnimatedValue, {flushValue} from './AnimatedValue';
22
22
  import AnimatedWithChildren from './AnimatedWithChildren';
23
23
 
@@ -15,10 +15,11 @@
15
15
  import type {PlatformConfig} from '../AnimatedPlatformConfig';
16
16
  import type AnimatedNode from './AnimatedNode';
17
17
 
18
+ import {validateInterpolation} from '../../../src/private/animated/NativeAnimatedValidation';
18
19
  import normalizeColor from '../../StyleSheet/normalizeColor';
19
20
  import processColor from '../../StyleSheet/processColor';
20
21
  import Easing from '../Easing';
21
- import NativeAnimatedHelper from '../NativeAnimatedHelper';
22
+ import NativeAnimatedHelper from '../../../src/private/animated/NativeAnimatedHelper';
22
23
  import AnimatedWithChildren from './AnimatedWithChildren';
23
24
  import invariant from 'invariant';
24
25
 
@@ -382,7 +383,7 @@ export default class AnimatedInterpolation<
382
383
 
383
384
  __getNativeConfig(): any {
384
385
  if (__DEV__) {
385
- NativeAnimatedHelper.validateInterpolation(this._config);
386
+ validateInterpolation(this._config);
386
387
  }
387
388
 
388
389
  // Only the `outputRange` can contain strings so we don't need to transform `inputRange` here
@@ -10,23 +10,31 @@
10
10
 
11
11
  'use strict';
12
12
 
13
+ import type {EventSubscription} from '../../vendor/emitter/EventEmitter';
13
14
  import type {PlatformConfig} from '../AnimatedPlatformConfig';
14
15
 
15
- import NativeAnimatedHelper from '../NativeAnimatedHelper';
16
+ import NativeAnimatedHelper from '../../../src/private/animated/NativeAnimatedHelper';
16
17
  import invariant from 'invariant';
17
18
 
18
- const NativeAnimatedAPI = NativeAnimatedHelper.API;
19
+ const {startListeningToAnimatedNodeValue, stopListeningToAnimatedNodeValue} =
20
+ NativeAnimatedHelper.API;
19
21
 
20
22
  type ValueListenerCallback = (state: {value: number, ...}) => mixed;
21
23
 
22
24
  let _uniqueId = 1;
25
+ let _assertNativeAnimatedModule: ?() => void = () => {
26
+ NativeAnimatedHelper.assertNativeAnimatedModule();
27
+ // We only have to assert that the module exists once. After we've asserted
28
+ // this, clear out the function so we know to skip it in the future.
29
+ _assertNativeAnimatedModule = null;
30
+ };
23
31
 
24
32
  // Note(vjeux): this would be better as an interface but flow doesn't
25
33
  // support them yet
26
34
  export default class AnimatedNode {
27
- _listeners: {[key: string]: ValueListenerCallback, ...};
28
- _platformConfig: ?PlatformConfig;
29
- __nativeAnimatedValueListener: ?any;
35
+ #listeners: Map<string, ValueListenerCallback> = new Map();
36
+ _platformConfig: ?PlatformConfig = undefined;
37
+ __nativeAnimatedValueListener: ?EventSubscription = null;
30
38
  __attach(): void {}
31
39
  __detach(): void {
32
40
  this.removeAllListeners();
@@ -46,13 +54,9 @@ export default class AnimatedNode {
46
54
  }
47
55
 
48
56
  /* Methods and props used by native Animated impl */
49
- __isNative: boolean;
50
- __nativeTag: ?number;
51
- __shouldUpdateListenersForNewNativeTag: boolean;
52
-
53
- constructor() {
54
- this._listeners = {};
55
- }
57
+ __isNative: boolean = false;
58
+ __nativeTag: ?number = undefined;
59
+ __shouldUpdateListenersForNewNativeTag: boolean = false;
56
60
 
57
61
  __makeNative(platformConfig: ?PlatformConfig): void {
58
62
  if (!this.__isNative) {
@@ -60,7 +64,7 @@ export default class AnimatedNode {
60
64
  }
61
65
 
62
66
  this._platformConfig = platformConfig;
63
- if (this.hasListeners()) {
67
+ if (this.#listeners.size > 0) {
64
68
  this._startListeningToNativeValueUpdates();
65
69
  }
66
70
  }
@@ -74,7 +78,7 @@ export default class AnimatedNode {
74
78
  */
75
79
  addListener(callback: (value: any) => mixed): string {
76
80
  const id = String(_uniqueId++);
77
- this._listeners[id] = callback;
81
+ this.#listeners.set(id, callback);
78
82
  if (this.__isNative) {
79
83
  this._startListeningToNativeValueUpdates();
80
84
  }
@@ -88,8 +92,8 @@ export default class AnimatedNode {
88
92
  * See https://reactnative.dev/docs/animatedvalue#removelistener
89
93
  */
90
94
  removeListener(id: string): void {
91
- delete this._listeners[id];
92
- if (this.__isNative && !this.hasListeners()) {
95
+ this.#listeners.delete(id);
96
+ if (this.__isNative && this.#listeners.size === 0) {
93
97
  this._stopListeningForNativeValueUpdates();
94
98
  }
95
99
  }
@@ -100,14 +104,14 @@ export default class AnimatedNode {
100
104
  * See https://reactnative.dev/docs/animatedvalue#removealllisteners
101
105
  */
102
106
  removeAllListeners(): void {
103
- this._listeners = {};
107
+ this.#listeners.clear();
104
108
  if (this.__isNative) {
105
109
  this._stopListeningForNativeValueUpdates();
106
110
  }
107
111
  }
108
112
 
109
113
  hasListeners(): boolean {
110
- return !!Object.keys(this._listeners).length;
114
+ return this.#listeners.size > 0;
111
115
  }
112
116
 
113
117
  _startListeningToNativeValueUpdates() {
@@ -123,7 +127,7 @@ export default class AnimatedNode {
123
127
  this._stopListeningForNativeValueUpdates();
124
128
  }
125
129
 
126
- NativeAnimatedAPI.startListeningToAnimatedNodeValue(this.__getNativeTag());
130
+ startListeningToAnimatedNodeValue(this.__getNativeTag());
127
131
  this.__nativeAnimatedValueListener =
128
132
  NativeAnimatedHelper.nativeEventEmitter.addListener(
129
133
  'onAnimatedValueUpdate',
@@ -141,9 +145,10 @@ export default class AnimatedNode {
141
145
  }
142
146
 
143
147
  __callListeners(value: number): void {
144
- for (const key in this._listeners) {
145
- this._listeners[key]({value});
146
- }
148
+ const event = {value};
149
+ this.#listeners.forEach(listener => {
150
+ listener(event);
151
+ });
147
152
  }
148
153
 
149
154
  _stopListeningForNativeValueUpdates() {
@@ -153,21 +158,24 @@ export default class AnimatedNode {
153
158
 
154
159
  this.__nativeAnimatedValueListener.remove();
155
160
  this.__nativeAnimatedValueListener = null;
156
- NativeAnimatedAPI.stopListeningToAnimatedNodeValue(this.__getNativeTag());
161
+ stopListeningToAnimatedNodeValue(this.__getNativeTag());
157
162
  }
158
163
 
159
164
  __getNativeTag(): number {
160
- NativeAnimatedHelper.assertNativeAnimatedModule();
161
- invariant(
162
- this.__isNative,
163
- 'Attempt to get native tag from node not marked as "native"',
164
- );
165
-
166
- const nativeTag =
167
- this.__nativeTag ?? NativeAnimatedHelper.generateNewNodeTag();
165
+ let nativeTag = this.__nativeTag;
166
+ if (nativeTag == null) {
167
+ _assertNativeAnimatedModule?.();
168
+
169
+ // `__isNative` is initialized as false and only ever set to true. So we
170
+ // only need to check it once here when initializing `__nativeTag`.
171
+ invariant(
172
+ this.__isNative,
173
+ 'Attempt to get native tag from node not marked as "native"',
174
+ );
168
175
 
169
- if (this.__nativeTag == null) {
176
+ nativeTag = NativeAnimatedHelper.generateNewNodeTag();
170
177
  this.__nativeTag = nativeTag;
178
+
171
179
  const config = this.__getNativeConfig();
172
180
  if (this._platformConfig) {
173
181
  config.platformConfig = this._platformConfig;
@@ -175,9 +183,9 @@ export default class AnimatedNode {
175
183
  NativeAnimatedHelper.API.createAnimatedNode(nativeTag, config);
176
184
  this.__shouldUpdateListenersForNewNativeTag = true;
177
185
  }
178
-
179
186
  return nativeTag;
180
187
  }
188
+
181
189
  __getNativeConfig(): Object {
182
190
  throw new Error(
183
191
  'This JS animated node type cannot be used as native animated node',
@@ -191,6 +199,7 @@ export default class AnimatedNode {
191
199
  __getPlatformConfig(): ?PlatformConfig {
192
200
  return this._platformConfig;
193
201
  }
202
+
194
203
  __setPlatformConfig(platformConfig: ?PlatformConfig) {
195
204
  this._platformConfig = platformConfig;
196
205
  }