react-native-windows 0.84.0 → 0.85.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.
- package/.flowconfig +1 -5
- package/Directory.Build.props +1 -16
- package/Directory.Build.targets +12 -4
- package/Folly/ThreadNameStub.cpp +4 -6
- package/Libraries/ActionSheetIOS/ActionSheetIOS.js +3 -3
- package/Libraries/Animated/Animated.d.ts +8 -1
- package/Libraries/Animated/AnimatedEvent.js +4 -4
- package/Libraries/Animated/AnimatedImplementation.js +2 -2
- package/Libraries/Animated/animations/Animation.js +3 -3
- package/Libraries/Animated/animations/DecayAnimation.js +4 -4
- package/Libraries/Animated/animations/SpringAnimation.js +5 -5
- package/Libraries/Animated/animations/TimingAnimation.js +5 -5
- package/Libraries/Animated/createAnimatedComponent.js +7 -7
- package/Libraries/Animated/nodes/AnimatedColor.js +2 -2
- package/Libraries/Animated/nodes/AnimatedInterpolation.js +12 -12
- package/Libraries/Animated/nodes/AnimatedNode.js +3 -3
- package/Libraries/Animated/nodes/AnimatedObject.js +3 -3
- package/Libraries/Animated/nodes/AnimatedProps.js +6 -6
- package/Libraries/Animated/nodes/AnimatedStyle.js +7 -7
- package/Libraries/Animated/nodes/AnimatedTransform.js +13 -13
- package/Libraries/Animated/nodes/AnimatedValue.js +1 -1
- package/Libraries/Animated/nodes/AnimatedValueXY.js +1 -1
- package/Libraries/Animated/nodes/AnimatedWithChildren.js +1 -1
- package/Libraries/Animated/useAnimatedColor.d.ts +15 -0
- package/Libraries/Animated/useAnimatedColor.js +25 -0
- package/Libraries/Animated/useAnimatedValueXY.d.ts +15 -0
- package/Libraries/Animated/useAnimatedValueXY.js +26 -0
- package/Libraries/AppState/AppState.js +1 -1
- package/Libraries/BatchedBridge/MessageQueue.js +3 -3
- package/Libraries/BatchedBridge/NativeModules.js +12 -10
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +30 -26
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.windows.js +34 -30
- package/Libraries/Components/ActivityIndicator/ActivityIndicator.js +2 -2
- package/Libraries/Components/Button.js +2 -2
- package/Libraries/Components/Button.windows.js +2 -2
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidTypes.js +2 -2
- package/Libraries/Components/Keyboard/Keyboard.js +6 -6
- package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +1 -1
- package/Libraries/Components/LayoutConformance/LayoutConformance.js +1 -1
- package/Libraries/Components/LayoutConformance/LayoutConformanceNativeComponent.js +1 -1
- package/Libraries/Components/Pressable/Pressable.d.ts +5 -0
- package/Libraries/Components/Pressable/Pressable.js +3 -3
- package/Libraries/Components/Pressable/Pressable.windows.js +3 -3
- package/Libraries/Components/Pressable/useAndroidRippleForView.js +4 -4
- package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js +1 -1
- package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidTypes.js +3 -3
- package/Libraries/Components/RefreshControl/RefreshControl.js +5 -5
- package/Libraries/Components/RefreshControl/RefreshControl.windows.js +5 -5
- package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +8 -12
- package/Libraries/Components/ScrollView/ScrollView.d.ts +9 -0
- package/Libraries/Components/ScrollView/ScrollView.js +19 -9
- package/Libraries/Components/ScrollView/ScrollView.windows.js +19 -9
- package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +8 -18
- package/Libraries/Components/ScrollView/ScrollViewNativeComponent.windows.js +8 -18
- package/Libraries/Components/ScrollView/ScrollViewNativeComponentType.js +4 -3
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
- package/Libraries/Components/StaticRenderer.js +1 -1
- package/Libraries/Components/StatusBar/StatusBar.js +8 -8
- package/Libraries/Components/Switch/Switch.js +3 -3
- package/Libraries/Components/Switch/Switch.windows.js +3 -3
- package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +33 -48
- package/Libraries/Components/TextInput/InputAccessoryView.js +1 -1
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +6 -11
- package/Libraries/Components/TextInput/TextInput.flow.js +21 -20
- package/Libraries/Components/TextInput/TextInput.flow.windows.js +23 -22
- package/Libraries/Components/TextInput/TextInput.js +8 -4
- package/Libraries/Components/TextInput/TextInput.windows.js +3 -4
- package/Libraries/Components/TextInput/WindowsTextInputNativeComponent.js +33 -48
- package/Libraries/Components/Touchable/PooledClass.js +1 -1
- package/Libraries/Components/Touchable/Touchable.js +2 -2
- package/Libraries/Components/Touchable/Touchable.windows.js +2 -2
- package/Libraries/Components/Touchable/TouchableBounce.js +4 -4
- package/Libraries/Components/Touchable/TouchableBounce.windows.js +4 -4
- package/Libraries/Components/Touchable/TouchableHighlight.js +8 -8
- package/Libraries/Components/Touchable/TouchableHighlight.windows.js +9 -9
- package/Libraries/Components/Touchable/TouchableNativeFeedback.js +7 -7
- package/Libraries/Components/Touchable/TouchableNativeFeedback.windows.js +7 -7
- package/Libraries/Components/Touchable/TouchableOpacity.js +4 -4
- package/Libraries/Components/Touchable/TouchableOpacity.windows.js +4 -4
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +1 -1
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +1 -1
- package/Libraries/Components/UnimplementedViews/UnimplementedView.js +1 -1
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +68 -31
- package/Libraries/Components/View/View.windows.js +1 -1
- package/Libraries/Components/View/ViewAccessibility.js +7 -7
- package/Libraries/Components/View/ViewAccessibility.windows.js +7 -7
- package/Libraries/Components/View/ViewPropTypes.js +14 -14
- package/Libraries/Components/View/ViewPropTypes.windows.js +18 -16
- package/Libraries/Core/Devtools/parseHermesStack.js +8 -8
- package/Libraries/Core/Devtools/symbolicateStackTrace.js +2 -2
- package/Libraries/Core/ExceptionsManager.js +2 -2
- package/Libraries/Core/ExtendedError.js +3 -3
- package/Libraries/Core/RawEventEmitter.js +1 -1
- package/Libraries/Core/ReactNativeVersion.js +2 -2
- package/Libraries/Core/Timers/JSTimers.js +3 -2
- package/Libraries/Core/setUpDeveloperTools.js +1 -1
- package/Libraries/Core/setUpErrorHandling.js +4 -2
- package/Libraries/Core/setUpReactDevTools.js +23 -6
- package/Libraries/Core/setUpSegmentFetcher.js +1 -1
- package/Libraries/Debugging/DebuggingOverlay.js +2 -2
- package/Libraries/EventEmitter/NativeEventEmitter.js +7 -9
- package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +1 -1
- package/Libraries/Image/AssetSourceResolver.js +1 -1
- package/Libraries/Image/AssetSourceResolver.windows.js +1 -1
- package/Libraries/Image/Image.android.js +172 -306
- package/Libraries/Image/ImageProps.js +9 -11
- package/Libraries/Image/ImageSource.js +2 -2
- package/Libraries/Image/ImageSourceUtils.js +8 -4
- package/Libraries/Image/ImageTypes.flow.js +2 -2
- package/Libraries/Image/ImageViewNativeComponent.js +7 -16
- package/Libraries/Image/nativeImageSource.js +1 -1
- package/Libraries/Interaction/InteractionManager.js +5 -4
- package/Libraries/Interaction/PanResponder.js +1 -1
- package/Libraries/LayoutAnimation/LayoutAnimation.js +2 -2
- package/Libraries/Linking/Linking.js +1 -1
- package/Libraries/Lists/FlatList.js +3 -3
- package/Libraries/Lists/SectionList.js +1 -1
- package/Libraries/Lists/SectionListModern.js +2 -2
- package/Libraries/LogBox/Data/LogBoxData.js +38 -24
- package/Libraries/LogBox/Data/LogBoxLog.js +43 -112
- package/Libraries/LogBox/Data/parseLogBoxLog.js +21 -117
- package/Libraries/LogBox/LogBox.js +42 -19
- package/Libraries/LogBox/LogBoxInspectorContainer.js +2 -2
- package/Libraries/LogBox/LogBoxNotificationContainer.js +2 -2
- package/Libraries/LogBox/UI/LogBoxButton.js +14 -16
- package/Libraries/LogBox/UI/LogBoxInspector.js +2 -2
- package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js +6 -9
- package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.windows.js +6 -9
- package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorFooterButton.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.windows.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorHeaderButton.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorMessageHeader.js +10 -15
- package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js +25 -18
- package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.windows.js +15 -16
- package/Libraries/LogBox/UI/LogBoxInspectorSection.js +5 -7
- package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +8 -10
- package/Libraries/LogBox/UI/LogBoxInspectorStackFrame.js +8 -6
- package/Libraries/LogBox/UI/LogBoxInspectorStackFrame.windows.js +3 -5
- package/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js +17 -29
- package/Libraries/LogBox/UI/LogBoxMessage.js +28 -37
- package/Libraries/LogBox/UI/LogBoxNotification.js +1 -1
- package/Libraries/Modal/Modal.d.ts +4 -0
- package/Libraries/Modal/Modal.js +3 -3
- package/Libraries/Modal/Modal.windows.js +7 -3
- package/Libraries/NativeComponent/BaseViewConfig.android.js +28 -52
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +19 -21
- package/Libraries/NativeComponent/BaseViewConfig.windows.js +26 -17
- package/Libraries/Network/RCTNetworking.android.js +1 -1
- package/Libraries/Network/RCTNetworking.ios.js +1 -1
- package/Libraries/Network/RCTNetworking.js.flow +1 -1
- package/Libraries/Network/RCTNetworking.windows.js +1 -1
- package/Libraries/Network/RCTNetworkingEventDefinitions.flow.js +1 -1
- package/Libraries/Network/XMLHttpRequest.js +1 -1
- package/Libraries/PermissionsAndroid/PermissionsAndroid.js +3 -3
- package/Libraries/Pressability/Pressability.js +5 -5
- package/Libraries/Pressability/Pressability.windows.js +5 -5
- package/Libraries/Pressability/PressabilityDebug.js +1 -1
- package/Libraries/Pressability/PressabilityPerformanceEventEmitter.js +1 -1
- package/Libraries/Pressability/usePressability.js +3 -14
- package/Libraries/PushNotificationIOS/PushNotificationIOS.js +2 -2
- package/Libraries/ReactNative/AppContainer-dev.js +18 -1
- package/Libraries/ReactNative/AppContainer.js +1 -1
- package/Libraries/ReactNative/AppRegistry.flow.js +2 -2
- package/Libraries/ReactNative/AppRegistryImpl.js +2 -2
- package/Libraries/ReactNative/FabricUIManager.js +1 -1
- package/Libraries/ReactNative/RendererImplementation.js +4 -4
- package/Libraries/ReactNative/UIManagerProperties.js +1 -1
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +3 -2
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +3 -2
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +3 -2
- package/Libraries/Renderer/shims/ReactFabric.js +1 -3
- package/Libraries/Renderer/shims/ReactFeatureFlags.js +1 -3
- package/Libraries/Renderer/shims/ReactNative.js +3 -2
- package/Libraries/Renderer/shims/ReactNativeTypes.js +1 -3
- package/Libraries/Renderer/shims/ReactNativeTypes.windows.js +1 -3
- package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +1 -3
- package/Libraries/Renderer/shims/createReactNativeComponentClass.js +1 -3
- package/Libraries/StyleSheet/PointPropType.js +1 -1
- package/Libraries/StyleSheet/Rect.js +1 -1
- package/Libraries/StyleSheet/StyleSheet.d.ts +0 -5
- package/Libraries/StyleSheet/StyleSheet.js +1 -1
- package/Libraries/StyleSheet/StyleSheet.js.flow +1 -1
- package/Libraries/StyleSheet/StyleSheetExports.js +16 -25
- package/Libraries/StyleSheet/StyleSheetExports.js.flow +2 -7
- package/Libraries/StyleSheet/StyleSheetTypes.js +33 -35
- package/Libraries/StyleSheet/private/_StyleSheetTypesOverrides.js +5 -5
- package/Libraries/StyleSheet/private/_TransformStyle.js +7 -7
- package/Libraries/StyleSheet/processBackgroundImage.js +7 -7
- package/Libraries/StyleSheet/processBackgroundPosition.js +4 -4
- package/Libraries/StyleSheet/processBackgroundRepeat.js +4 -4
- package/Libraries/StyleSheet/processBackgroundSize.js +4 -4
- package/Libraries/StyleSheet/processBoxShadow.js +44 -4
- package/Libraries/StyleSheet/processColorArray.js +2 -2
- package/Libraries/StyleSheet/processFilter.js +2 -2
- package/Libraries/Text/Text.js +295 -627
- package/Libraries/Text/Text.windows.js +342 -717
- package/Libraries/Text/TextNativeComponent.js +14 -7
- package/Libraries/Text/TextProps.js +4 -4
- package/Libraries/Text/TextProps.windows.js +4 -4
- package/Libraries/Types/CodegenTypes.js +1 -1
- package/Libraries/Types/CoreEventTypes.js +21 -21
- package/Libraries/Types/CoreEventTypes.windows.js +21 -21
- package/Libraries/Types/ReactDevToolsTypes.js +2 -2
- package/Libraries/Utilities/Appearance.js +6 -1
- package/Libraries/Utilities/Dimensions.js +1 -1
- package/Libraries/Utilities/HMRClient.js +32 -5
- package/Libraries/Utilities/IPerformanceLogger.js +4 -4
- package/Libraries/Utilities/codegenNativeCommands.js +4 -4
- package/Libraries/Utilities/codegenNativeComponent.d.ts +2 -0
- package/Libraries/Utilities/codegenNativeComponent.js +2 -2
- package/Libraries/Utilities/logError.js +1 -1
- package/Libraries/Utilities/stringifySafe.js +3 -3
- package/Libraries/Utilities/useMergeRefs.js +2 -2
- package/Libraries/vendor/core/ErrorUtils.js +4 -4
- package/Libraries/vendor/emitter/EventEmitter.js +16 -20
- package/Microsoft.ReactNative/CallInvoker.cpp +14 -4
- package/Microsoft.ReactNative/Fabric/AbiComponentDescriptor.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/AbiPortalShadowNode.cpp +2 -2
- package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.h +1 -1
- package/Microsoft.ReactNative/Fabric/Composition/BorderPrimitive.cpp +73 -97
- package/Microsoft.ReactNative/Fabric/Composition/BorderPrimitive.h +4 -1
- package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +0 -1
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +4 -4
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +135 -18
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +10 -0
- package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp +7 -2
- package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.h +2 -0
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +63 -15
- package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +3 -1
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputState.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +11 -0
- package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.h +1 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/HostPlatformColor.h +3 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.cpp +0 -3
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.cpp +2 -7
- package/Microsoft.ReactNative/IReactPackageBuilder.idl +6 -0
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +1 -61
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters +1 -26
- package/Microsoft.ReactNative/Modules/AlertModule.cpp +2 -1
- package/Microsoft.ReactNative/Modules/AppStateModule.cpp +2 -17
- package/Microsoft.ReactNative/Modules/AppStateModule.h +0 -4
- package/Microsoft.ReactNative/Modules/AppThemeModuleUwp.cpp +0 -2
- package/Microsoft.ReactNative/Modules/AppearanceModule.cpp +16 -15
- package/Microsoft.ReactNative/Modules/AppearanceModule.h +5 -1
- package/Microsoft.ReactNative/Modules/DeviceInfoModule.cpp +2 -7
- package/Microsoft.ReactNative/Modules/DeviceInfoModule.h +0 -1
- package/Microsoft.ReactNative/Modules/I18nManagerModule.h +4 -4
- package/Microsoft.ReactNative/QuirkSettings.cpp +0 -133
- package/Microsoft.ReactNative/QuirkSettings.h +0 -43
- package/Microsoft.ReactNative/QuirkSettings.idl +0 -41
- package/Microsoft.ReactNative/ReactHost/CrashManager.cpp +0 -4
- package/Microsoft.ReactNative/ReactHost/MsoReactContext.cpp +0 -2
- package/Microsoft.ReactNative/ReactHost/React.h +0 -5
- package/Microsoft.ReactNative/ReactHost/ReactHost.cpp +0 -1
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +3 -26
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +0 -5
- package/Microsoft.ReactNative/ReactHost/React_Win.h +0 -2
- package/Microsoft.ReactNative/ReactNativeAppBuilder.idl +3 -0
- package/Microsoft.ReactNative/ReactPackageBuilder.cpp +7 -0
- package/Microsoft.ReactNative/ReactPackageBuilder.h +1 -0
- package/Microsoft.ReactNative/RedBox.cpp +0 -9
- package/Microsoft.ReactNative/RedBoxHandler.cpp +0 -4
- package/Microsoft.ReactNative/TurboModulesProvider.cpp +5 -10
- package/Microsoft.ReactNative/TurboModulesProvider.h +2 -0
- package/Microsoft.ReactNative/Utils/ValueUtils.cpp +1 -1
- package/Microsoft.ReactNative.Cxx/CppWinRTIncludes.h +0 -7
- package/Microsoft.ReactNative.Cxx/DesktopWindowBridge.h +0 -22
- package/Microsoft.ReactNative.Cxx/ModuleRegistration.cpp +8 -2
- package/Microsoft.ReactNative.Cxx/ModuleRegistration.h +36 -20
- package/Microsoft.ReactNative.Cxx/NamespaceRedirect.h +0 -3
- package/Microsoft.ReactNative.Cxx/NativeModules.h +8 -2
- package/Microsoft.ReactNative.Cxx/XamlUtils.h +0 -9
- package/Microsoft.ReactNative.Managed/ReactContext.cs +0 -9
- package/PropertySheets/Autolink.props +1 -1
- package/PropertySheets/Bundle.props +1 -1
- package/PropertySheets/Codegen.props +1 -1
- package/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/PropertySheets/NuGet.LockFile.props +8 -0
- package/PropertySheets/React.Cpp.props +4 -4
- package/PropertySheets/ReactNativeArchitecture.props +6 -24
- package/ReactCommon/ReactCommon.vcxproj +5 -6
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/test/testlib.cpp +1 -1
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.cpp +15 -4
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.h +13 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/defaults/DefaultTurboModules.cpp +69 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/animationbackend/AnimatedPropSerializer.cpp +717 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/ParagraphShadowNode.cpp +10 -10
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/AccessibilityPrimitives.h +2 -21
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/TouchEventEmitter.cpp +151 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/TouchEventEmitter.h +50 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/mapbuffer/MapBuffer.cpp +178 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/uimanager/UIManager.cpp +69 -39
- package/Scripts/OfficeReact.Win32.nuspec +0 -1
- package/Scripts/Tfs/Layout-Desktop-Headers.ps1 +4 -39
- package/Scripts/creaternwapp.cmd +1 -9
- package/Scripts/creaternwlib.cmd +4 -24
- package/Shared/DevSettings.h +0 -3
- package/Shared/Networking/WinRTWebSocketResource.cpp +23 -408
- package/Shared/Networking/WinRTWebSocketResource.h +3 -119
- package/Shared/Shared.vcxitems +63 -38
- package/Shared/Shared.vcxitems.filters +54 -0
- package/Shared/Utils.cpp +0 -88
- package/Shared/Utils.h +0 -14
- package/Shared/WebSocketResourceFactory.cpp +28 -0
- package/Shared/tracing/fbsystrace.h +1 -0
- package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +172 -160
- package/codegen/react/components/rnwcore/ModalHostView.g.h +8 -0
- package/codegen/react/components/rnwcore/Props.cpp +17 -7
- package/codegen/react/components/rnwcore/Props.h +3 -1
- package/codegen/react/components/rnwcore/VirtualViewExperimental.g.h +4 -4
- package/codegen/rnwcoreJSI.h +93 -77
- package/index.js +9 -0
- package/index.windows.js +9 -0
- package/jest/RefreshControlMock.js +2 -2
- package/jest/assetFileTransformer.js +8 -3
- package/jest/mockComponent.js +3 -4
- package/jest/mockNativeComponent.js +1 -1
- package/jest/mocks/ActivityIndicator.js +2 -2
- package/jest/mocks/Image.js +2 -2
- package/jest/mocks/Modal.js +2 -2
- package/jest/mocks/RefreshControl.js +3 -3
- package/jest/mocks/RendererProxy.js +2 -2
- package/jest/mocks/ScrollView.js +5 -5
- package/jest/mocks/Text.js +2 -2
- package/jest/mocks/TextInput.js +2 -2
- package/jest/mocks/View.js +2 -2
- package/jest/mocks/ViewNativeComponent.js +1 -1
- package/jest/mocks/requireNativeComponent.js +1 -1
- package/jest/mocks/useColorScheme.js +1 -1
- package/jest/setup.js +68 -31
- package/package.json +27 -22
- package/src/private/animated/NativeAnimatedHelper.js +2 -2
- package/src/private/animated/createAnimatedPropsMemoHook.js +19 -19
- package/src/private/components/virtualview/VirtualView.js +14 -21
- package/src/private/components/virtualview/VirtualViewExperimentalNativeComponent.js +11 -10
- package/src/private/components/virtualview/VirtualViewNativeComponent.js +4 -4
- package/src/private/devsupport/devmenu/elementinspector/BorderBox.js +2 -2
- package/src/private/devsupport/devmenu/elementinspector/BoxInspector.js +3 -3
- package/src/private/devsupport/devmenu/elementinspector/ElementBox.js +4 -4
- package/src/private/devsupport/devmenu/elementinspector/ElementProperties.js +1 -1
- package/src/private/devsupport/devmenu/elementinspector/Inspector.js +39 -17
- package/src/private/devsupport/devmenu/elementinspector/InspectorOverlay.js +15 -3
- package/src/private/devsupport/devmenu/elementinspector/InspectorPanel.js +2 -2
- package/src/private/devsupport/devmenu/elementinspector/ReactDevToolsOverlay.js +2 -8
- package/src/private/devsupport/devmenu/elementinspector/StyleInspector.js +1 -1
- package/src/private/devsupport/devmenu/elementinspector/resolveBoxStyle.js +1 -1
- package/src/private/devsupport/devmenu/elementinspector/useExternalInspection.js +102 -0
- package/src/private/devsupport/rndevtools/FuseboxSessionObserver.js +12 -25
- package/src/private/devsupport/rndevtools/GlobalStateObserver.js +56 -0
- package/src/private/devsupport/rndevtools/TracingStateObserver.js +28 -0
- package/src/private/featureflags/ReactNativeFeatureFlags.js +71 -79
- package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +2 -2
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +14 -12
- package/src/private/setup/setUpDefaultReactNativeEnvironment.js +6 -0
- package/src/private/specs_DEPRECATED/components/ActivityIndicatorViewNativeComponent.js +1 -1
- package/src/private/specs_DEPRECATED/components/AndroidDrawerLayoutNativeComponent.js +3 -3
- package/src/private/specs_DEPRECATED/components/AndroidHorizontalScrollContentViewNativeComponent.js +1 -1
- package/src/private/specs_DEPRECATED/components/AndroidSwipeRefreshLayoutNativeComponent.js +2 -2
- package/src/private/specs_DEPRECATED/components/AndroidSwitchNativeComponent.js +2 -2
- package/src/private/specs_DEPRECATED/components/DebuggingOverlayNativeComponent.js +3 -3
- package/src/private/specs_DEPRECATED/components/ProgressBarAndroidNativeComponent.js +1 -1
- package/src/private/specs_DEPRECATED/components/PullToRefreshViewNativeComponent.js +1 -1
- package/src/private/specs_DEPRECATED/components/RCTInputAccessoryViewNativeComponent.js +1 -1
- package/src/private/specs_DEPRECATED/components/RCTModalHostViewNativeComponent.js +7 -3
- package/src/private/specs_DEPRECATED/components/RCTSafeAreaViewNativeComponent.js +1 -1
- package/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js +2 -2
- package/src/private/specs_DEPRECATED/components/UnimplementedNativeViewNativeComponent.js +1 -1
- package/src/private/specs_DEPRECATED/modules/NativeImageLoaderIOS.js +1 -1
- package/src/private/styles/composeStyles.js +1 -1
- package/src/private/utilities/toError.js +27 -0
- package/src/private/utilities/toExtendedError.js +30 -0
- package/src/private/webapis/dom/events/Event.js +1 -1
- package/src/private/webapis/dom/events/EventHandlerAttributes.js +2 -2
- package/src/private/webapis/dom/events/EventTarget.js +3 -3
- package/src/private/webapis/dom/events/internals/EventInternals.js +2 -2
- package/src/private/webapis/dom/nodes/ReadOnlyElement.js +1 -1
- package/src/private/webapis/dom/nodes/ReadOnlyNode.js +2 -2
- package/src/private/webapis/dom/nodes/specs/NativeDOM.js +14 -14
- package/src/private/webapis/dom/oldstylecollections/HTMLCollection.js +2 -2
- package/src/private/webapis/dom/oldstylecollections/NodeList.js +2 -2
- package/src/private/webapis/geometry/DOMRectList.js +2 -2
- package/src/private/webapis/intersectionobserver/IntersectionObserver.js +8 -8
- package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +6 -6
- package/src/private/webapis/mutationobserver/MutationObserver.js +2 -2
- package/src/private/webapis/mutationobserver/MutationRecord.js +2 -2
- package/src/private/webapis/mutationobserver/internals/MutationObserverManager.js +1 -1
- package/src/private/webapis/mutationobserver/specs/NativeMutationObserver.js +3 -3
- package/src/private/webapis/performance/LongTasks.js +3 -3
- package/src/private/webapis/performance/Performance.js +4 -4
- package/src/private/webapis/performance/PerformanceEntry.js +1 -1
- package/src/private/webapis/performance/PerformanceObserver.js +2 -2
- package/src/private/webapis/performance/specs/NativePerformance.js +8 -8
- package/src/private/webapis/structuredClone/structuredClone.js +2 -2
- package/src/types/globals.d.ts +4 -4
- package/template/cpp-lib/proj/MyLib.sln +0 -33
- package/template/cpp-lib/proj/MyLib.vcxproj +1 -1
- package/template/cs-lib/proj/MyLib.sln +0 -33
- package/template/metro.config.js +12 -2
- package/templates/cpp-app/metro.config.js +12 -2
- package/templates/cpp-app/windows/MyApp/MyApp.cpp +9 -6
- package/templates/cpp-app/windows/MyApp/MyApp.vcxproj +1 -1
- package/templates/cpp-app/windows/MyApp.sln +0 -33
- package/templates/cpp-lib/example/metro.config.js +12 -2
- package/templates/cpp-lib/windows/MyLib/MyLib.vcxproj +1 -1
- package/templates/cpp-lib/windows/MyLib.sln +0 -33
- package/types/index.d.ts +2 -0
- package/Folly/.clang-format +0 -2
- package/Folly/Folly.natvis +0 -25
- package/Folly/Folly.vcxproj +0 -378
- package/Folly/Folly.vcxproj.filters +0 -558
- package/Folly/TEMP_UntilFollyUpdate/ConstexprMath.h +0 -978
- package/Folly/TEMP_UntilFollyUpdate/Conv.cpp +0 -1205
- package/Folly/TEMP_UntilFollyUpdate/chrono/Hardware.h +0 -155
- package/Folly/TEMP_UntilFollyUpdate/concurrency/CacheLocality.cpp +0 -633
- package/Folly/TEMP_UntilFollyUpdate/json/dynamic-inl.h +0 -1438
- package/Folly/TEMP_UntilFollyUpdate/json/json.cpp +0 -1118
- package/Folly/TEMP_UntilFollyUpdate/lang/SafeAssert.h +0 -188
- package/Folly/TEMP_UntilFollyUpdate/lang/ToAscii.cpp +0 -348
- package/Folly/TEMP_UntilFollyUpdate/lang/ToAscii.h +0 -182
- package/Folly/TEMP_UntilFollyUpdate/portability/Unistd.cpp +0 -33
- package/Folly/cgmanifest.json +0 -25
- package/Libraries/Components/View/ReactNativeViewAttributes.js +0 -60
- package/Libraries/Components/View/ReactNativeViewAttributes.windows.js +0 -64
- package/Libraries/Image/TextInlineImageNativeComponent.js +0 -49
- package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper_emptyimpl.cpp +0 -75
- package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService_emptyimpl.cpp +0 -27
- package/Microsoft.ReactNative/Fabric/Composition/Theme_emptyimpl.cpp +0 -81
- package/Microsoft.ReactNative/Modules/CreateModules.cpp +0 -24
- package/Microsoft.ReactNative/ReactSupport.cpp +0 -221
- package/Microsoft.ReactNative/ReactSupport.h +0 -13
- package/Microsoft.ReactNative/Utils/UwpPreparedScriptStore.cpp +0 -107
- package/Microsoft.ReactNative/Utils/UwpPreparedScriptStore.h +0 -62
- package/Microsoft.ReactNative/Utils/UwpScriptStore.cpp +0 -56
- package/Microsoft.ReactNative/Utils/UwpScriptStore.h +0 -23
- package/Microsoft.ReactNative/XamlUIService.cpp +0 -68
- package/Microsoft.ReactNative/XamlUIService.h +0 -37
- package/Microsoft.ReactNative/XamlUIService.idl +0 -53
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/CxxNativeModule.cpp +0 -259
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/Instance.cpp +0 -381
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSIndexedRAMBundle.cpp +0 -145
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/MethodCall.cpp +0 -100
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ModuleRegistry.cpp +0 -256
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/NativeToJsBridge.cpp +0 -363
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/RAMBundleRegistry.cpp +0 -93
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ReactMarker.cpp +0 -148
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/TraceSection.h +0 -190
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsiexecutor/jsireact/JSINativeModules.cpp +0 -123
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModuleWithJSIBindings.cpp +0 -27
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/webperformance/NativePerformance.cpp +0 -414
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/platform/android/react/renderer/components/text/ParagraphState.h +0 -91
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventDispatcher.cpp +0 -80
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventQueueProcessor.cpp +0 -138
- package/fmt/.clang-format +0 -2
- package/fmt/cgmanifest.json +0 -15
- package/fmt/fmt.vcxproj +0 -153
- package/fmt/fmt.vcxproj.filters +0 -59
- package/fmt/pch.cpp +0 -4
- package/fmt/pch.h +0 -2
|
@@ -1,259 +0,0 @@
|
|
|
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
|
-
|
|
8
|
-
#include "CxxNativeModule.h"
|
|
9
|
-
|
|
10
|
-
#ifndef RCT_REMOVE_LEGACY_ARCH
|
|
11
|
-
|
|
12
|
-
#include "Instance.h"
|
|
13
|
-
|
|
14
|
-
#include <folly/json.h>
|
|
15
|
-
#include <glog/logging.h>
|
|
16
|
-
#include <iterator>
|
|
17
|
-
|
|
18
|
-
#include "JsArgumentHelpers.h"
|
|
19
|
-
#include "MessageQueueThread.h"
|
|
20
|
-
#include "TraceSection.h"
|
|
21
|
-
|
|
22
|
-
#include <logger/react_native_log.h>
|
|
23
|
-
|
|
24
|
-
using facebook::xplat::module::CxxModule;
|
|
25
|
-
namespace facebook::react {
|
|
26
|
-
|
|
27
|
-
std::function<void(folly::dynamic)> makeCallback(
|
|
28
|
-
std::weak_ptr<Instance> instance,
|
|
29
|
-
const folly::dynamic& callbackId) {
|
|
30
|
-
if (!callbackId.isNumber()) {
|
|
31
|
-
throw std::invalid_argument("Expected callback(s) as final argument");
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
auto id = callbackId.asInt();
|
|
35
|
-
return [winstance = std::move(instance), id](folly::dynamic args) {
|
|
36
|
-
if (auto instance = winstance.lock()) {
|
|
37
|
-
instance->callJSCallback(id, std::move(args));
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
namespace {
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* CxxModule::Callback accepts a vector<dynamic>, makeCallback returns
|
|
46
|
-
* a callback that accepts a dynamic, adapt the second into the first.
|
|
47
|
-
* TODO: Callback types should be made equal (preferably
|
|
48
|
-
* function<void(dynamic)>) to avoid the extra copy and indirect call.
|
|
49
|
-
*/
|
|
50
|
-
CxxModule::Callback convertCallback(
|
|
51
|
-
std::function<void(folly::dynamic)> callback) {
|
|
52
|
-
return [callback = std::move(callback)](std::vector<folly::dynamic> args) {
|
|
53
|
-
// after unpinning folly, can use folly::dynamic::array_range
|
|
54
|
-
folly::dynamic obj = folly::dynamic::array;
|
|
55
|
-
for (auto& arg : args) {
|
|
56
|
-
obj.push_back(std::move(arg));
|
|
57
|
-
}
|
|
58
|
-
callback(std::move(obj));
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
} // namespace
|
|
63
|
-
|
|
64
|
-
bool CxxNativeModule::shouldWarnOnUse_ = false;
|
|
65
|
-
|
|
66
|
-
void CxxNativeModule::setShouldWarnOnUse(bool value) {
|
|
67
|
-
shouldWarnOnUse_ = value;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
void CxxNativeModule::emitWarnIfWarnOnUsage(
|
|
71
|
-
const std::string& method_name,
|
|
72
|
-
const std::string& module_name) {
|
|
73
|
-
if (shouldWarnOnUse_) {
|
|
74
|
-
std::string message = "Calling " + method_name +
|
|
75
|
-
" on Cxx NativeModule (name = \"" + module_name + "\").";
|
|
76
|
-
react_native_log_warn(message.c_str());
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
std::string CxxNativeModule::getName() {
|
|
81
|
-
return name_;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
std::string CxxNativeModule::getSyncMethodName(unsigned int reactMethodId) {
|
|
85
|
-
if (reactMethodId >= methods_.size()) {
|
|
86
|
-
throw std::invalid_argument(
|
|
87
|
-
"methodId " + std::to_string(reactMethodId) + " out of range [0.." +
|
|
88
|
-
std::to_string(methods_.size()) + "]");
|
|
89
|
-
}
|
|
90
|
-
return methods_[reactMethodId].name;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
std::vector<MethodDescriptor> CxxNativeModule::getMethods() {
|
|
94
|
-
lazyInit();
|
|
95
|
-
|
|
96
|
-
std::vector<MethodDescriptor> descs;
|
|
97
|
-
descs.reserve(methods_.size());
|
|
98
|
-
for (auto& method : methods_) {
|
|
99
|
-
descs.emplace_back(method.name, method.getType());
|
|
100
|
-
}
|
|
101
|
-
return descs;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
folly::dynamic CxxNativeModule::getConstants() {
|
|
105
|
-
lazyInit();
|
|
106
|
-
|
|
107
|
-
if (!module_) {
|
|
108
|
-
return nullptr;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
emitWarnIfWarnOnUsage("getConstants()", getName());
|
|
112
|
-
|
|
113
|
-
folly::dynamic constants = folly::dynamic::object();
|
|
114
|
-
for (auto& pair : module_->getConstants()) {
|
|
115
|
-
constants.insert(std::move(pair.first), std::move(pair.second));
|
|
116
|
-
}
|
|
117
|
-
return constants;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
void CxxNativeModule::invoke(
|
|
121
|
-
unsigned int reactMethodId,
|
|
122
|
-
folly::dynamic&& params,
|
|
123
|
-
int callId) {
|
|
124
|
-
if (reactMethodId >= methods_.size()) {
|
|
125
|
-
throw std::invalid_argument(
|
|
126
|
-
"methodId " + std::to_string(reactMethodId) + " out of range [0.." +
|
|
127
|
-
std::to_string(methods_.size()) + "]");
|
|
128
|
-
}
|
|
129
|
-
if (!params.isArray()) {
|
|
130
|
-
throw std::invalid_argument(
|
|
131
|
-
std::string("Method parameters should be array, but are ") +
|
|
132
|
-
params.typeName());
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
CxxModule::Callback first;
|
|
136
|
-
CxxModule::Callback second;
|
|
137
|
-
|
|
138
|
-
const auto& method = methods_[reactMethodId];
|
|
139
|
-
|
|
140
|
-
if (!method.func) {
|
|
141
|
-
throw std::runtime_error(
|
|
142
|
-
"Method " + method.name + " is synchronous but invoked asynchronously");
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
emitWarnIfWarnOnUsage(method.name, getName());
|
|
146
|
-
|
|
147
|
-
if (params.size() < method.callbacks) {
|
|
148
|
-
throw std::invalid_argument(
|
|
149
|
-
"Expected " + std::to_string(method.callbacks) +
|
|
150
|
-
" callbacks, but only " + std::to_string(params.size()) +
|
|
151
|
-
" parameters provided");
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (method.callbacks == 1) {
|
|
155
|
-
first = convertCallback(makeCallback(instance_, params[params.size() - 1]));
|
|
156
|
-
} else if (method.callbacks == 2) {
|
|
157
|
-
first = convertCallback(makeCallback(instance_, params[params.size() - 2]));
|
|
158
|
-
second =
|
|
159
|
-
convertCallback(makeCallback(instance_, params[params.size() - 1]));
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
params.resize(params.size() - method.callbacks);
|
|
163
|
-
|
|
164
|
-
// I've got a few flawed options here. I can let the C++ exception
|
|
165
|
-
// propagate, and the registry will log/convert them to java exceptions.
|
|
166
|
-
// This lets all the java and red box handling work ok, but the only info I
|
|
167
|
-
// can capture about the C++ exception is the what() string, not the stack.
|
|
168
|
-
// I can std::terminate() the app. This causes the full, accurate C++
|
|
169
|
-
// stack trace to be added to logcat by debuggerd. The java state is lost,
|
|
170
|
-
// but in practice, the java stack is always the same in this case since
|
|
171
|
-
// the javascript stack is not visible, and the crash is unfriendly to js
|
|
172
|
-
// developers, but crucial to C++ developers. The what() value is also
|
|
173
|
-
// lost. Finally, I can catch, log the java stack, then rethrow the C++
|
|
174
|
-
// exception. In this case I get java and C++ stack data, but the C++
|
|
175
|
-
// stack is as of the rethrow, not the original throw, both the C++ and
|
|
176
|
-
// java stacks always look the same.
|
|
177
|
-
//
|
|
178
|
-
// I am going with option 2, since that seems like the most useful
|
|
179
|
-
// choice. It would be nice to be able to get what() and the C++
|
|
180
|
-
// stack. I'm told that will be possible in the future. TODO
|
|
181
|
-
// mhorowitz #7128529: convert C++ exceptions to Java
|
|
182
|
-
|
|
183
|
-
const auto& moduleName = name_;
|
|
184
|
-
TraceSection s(
|
|
185
|
-
"CxxMethodCallQueue", "module", moduleName, "method", method.name);
|
|
186
|
-
messageQueueThread_->runOnQueue([method,
|
|
187
|
-
moduleName,
|
|
188
|
-
params = std::move(params),
|
|
189
|
-
first,
|
|
190
|
-
second,
|
|
191
|
-
callId]() {
|
|
192
|
-
#ifdef WITH_FBSYSTRACE
|
|
193
|
-
if (callId != -1) {
|
|
194
|
-
//fbsystrace_end_async_flow(TRACE_TAG_REACT, "native", callId);
|
|
195
|
-
fbsystrace_end_async_flow(TRACE_TAG_REACT_CXX_BRIDGE, "native", callId); // [Windows] [issue #14819]
|
|
196
|
-
}
|
|
197
|
-
#else
|
|
198
|
-
(void)(callId);
|
|
199
|
-
#endif
|
|
200
|
-
TraceSection s(
|
|
201
|
-
"CxxMethodCallDispatch", "module", moduleName, "method", method.name);
|
|
202
|
-
try {
|
|
203
|
-
method.func(params, first, second);
|
|
204
|
-
} catch (const facebook::xplat::JsArgumentException&) {
|
|
205
|
-
throw;
|
|
206
|
-
} catch (std::exception& e) {
|
|
207
|
-
LOG(ERROR) << "std::exception. Method call " << method.name.c_str()
|
|
208
|
-
<< " failed: " << e.what();
|
|
209
|
-
std::terminate();
|
|
210
|
-
} catch (std::string& error) {
|
|
211
|
-
LOG(ERROR) << "std::string. Method call " << method.name.c_str()
|
|
212
|
-
<< " failed: " << error.c_str();
|
|
213
|
-
std::terminate();
|
|
214
|
-
} catch (...) {
|
|
215
|
-
LOG(ERROR) << "Method call " << method.name.c_str()
|
|
216
|
-
<< " failed. unknown error";
|
|
217
|
-
std::terminate();
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
MethodCallResult CxxNativeModule::callSerializableNativeHook(
|
|
223
|
-
unsigned int hookId,
|
|
224
|
-
folly::dynamic&& args) {
|
|
225
|
-
if (hookId >= methods_.size()) {
|
|
226
|
-
throw std::invalid_argument(
|
|
227
|
-
"methodId " + std::to_string(hookId) + " out of range [0.." +
|
|
228
|
-
std::to_string(methods_.size()) + "]");
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
const auto& method = methods_[hookId];
|
|
232
|
-
|
|
233
|
-
if (!method.syncFunc) {
|
|
234
|
-
throw std::runtime_error(
|
|
235
|
-
"Method " + method.name + " is asynchronous but invoked synchronously");
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
emitWarnIfWarnOnUsage(method.name, getName());
|
|
239
|
-
|
|
240
|
-
return method.syncFunc(std::move(args));
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
void CxxNativeModule::lazyInit() {
|
|
244
|
-
if (module_ || !provider_) {
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
// TODO 17216751: providers should never return null modules
|
|
249
|
-
module_ = provider_();
|
|
250
|
-
provider_ = nullptr;
|
|
251
|
-
if (module_) {
|
|
252
|
-
module_->setInstance(instance_);
|
|
253
|
-
methods_ = module_->getMethods();
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
} // namespace facebook::react
|
|
258
|
-
|
|
259
|
-
#endif // RCT_REMOVE_LEGACY_ARCH
|
|
@@ -1,381 +0,0 @@
|
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
#if _MSC_VER
|
|
10
|
-
#pragma warning(push)
|
|
11
|
-
#pragma warning(disable : 4996) // deprecated APIs
|
|
12
|
-
#endif
|
|
13
|
-
#include "Instance.h"
|
|
14
|
-
|
|
15
|
-
#ifndef RCT_REMOVE_LEGACY_ARCH
|
|
16
|
-
|
|
17
|
-
#include "ErrorUtils.h"
|
|
18
|
-
#include "JSBigString.h"
|
|
19
|
-
#include "JSBundleType.h"
|
|
20
|
-
#include "JSExecutor.h"
|
|
21
|
-
#include "MessageQueueThread.h"
|
|
22
|
-
#include "MethodCall.h"
|
|
23
|
-
#include "NativeToJsBridge.h"
|
|
24
|
-
#include "RAMBundleRegistry.h"
|
|
25
|
-
#include "RecoverableError.h"
|
|
26
|
-
#include "TraceSection.h"
|
|
27
|
-
|
|
28
|
-
#include <cxxreact/JSIndexedRAMBundle.h>
|
|
29
|
-
#include <folly/json.h>
|
|
30
|
-
#include <react/debug/react_native_assert.h>
|
|
31
|
-
|
|
32
|
-
#include <glog/logging.h>
|
|
33
|
-
|
|
34
|
-
#include <condition_variable>
|
|
35
|
-
#include <exception>
|
|
36
|
-
#include <memory>
|
|
37
|
-
#include <mutex>
|
|
38
|
-
#include <string>
|
|
39
|
-
|
|
40
|
-
namespace facebook::react {
|
|
41
|
-
|
|
42
|
-
Instance::~Instance() {
|
|
43
|
-
if (nativeToJsBridge_) {
|
|
44
|
-
nativeToJsBridge_->destroy();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
void Instance::unregisterFromInspector() {
|
|
49
|
-
if (inspectorTarget_ != nullptr) {
|
|
50
|
-
assert(runtimeInspectorTarget_);
|
|
51
|
-
inspectorTarget_->unregisterRuntime(*runtimeInspectorTarget_);
|
|
52
|
-
assert(parentInspectorTarget_);
|
|
53
|
-
parentInspectorTarget_->unregisterInstance(*inspectorTarget_);
|
|
54
|
-
parentInspectorTarget_ = nullptr;
|
|
55
|
-
inspectorTarget_ = nullptr;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
void Instance::initializeBridge(
|
|
60
|
-
std::unique_ptr<InstanceCallback> callback,
|
|
61
|
-
std::shared_ptr<JSExecutorFactory> jsef,
|
|
62
|
-
std::shared_ptr<MessageQueueThread> jsQueue,
|
|
63
|
-
std::shared_ptr<ModuleRegistry> moduleRegistry,
|
|
64
|
-
jsinspector_modern::HostTarget* parentInspectorTarget) {
|
|
65
|
-
callback_ = std::move(callback);
|
|
66
|
-
moduleRegistry_ = std::move(moduleRegistry);
|
|
67
|
-
parentInspectorTarget_ = parentInspectorTarget;
|
|
68
|
-
|
|
69
|
-
jsQueue->runOnQueueSync([this, &jsef, jsQueue]() mutable {
|
|
70
|
-
nativeToJsBridge_ = std::make_shared<NativeToJsBridge>(
|
|
71
|
-
jsef.get(), moduleRegistry_, jsQueue, callback_);
|
|
72
|
-
|
|
73
|
-
// If a parent inspector HostTarget is provided, perform inspector
|
|
74
|
-
// initialization synchronously.
|
|
75
|
-
if (parentInspectorTarget_ != nullptr) {
|
|
76
|
-
auto inspectorExecutor = parentInspectorTarget_->executorFromThis();
|
|
77
|
-
std::mutex inspectorInitializedMutex;
|
|
78
|
-
std::condition_variable inspectorInitializedCv;
|
|
79
|
-
bool inspectorInitialized = false;
|
|
80
|
-
|
|
81
|
-
// Schedule work on the inspector thread. NOTE: We expect this callback
|
|
82
|
-
// to always execute, given the invariant that `initializeBridge` (this
|
|
83
|
-
// method) completes before `unregisterFromInspector` is called.
|
|
84
|
-
// - On iOS, instance creation and invalidation both run on the main
|
|
85
|
-
// queue (`RCTCxxBridge::start,invalidate` use `RCTAssertMainQueue`).
|
|
86
|
-
// - On Android, `ReactContext` must be initialized with a constructed
|
|
87
|
-
// `CatalystInstance` (in which `Instance::initializeBridge` has
|
|
88
|
-
// completed) before `destroy` can be called.
|
|
89
|
-
inspectorExecutor([this,
|
|
90
|
-
&inspectorInitialized,
|
|
91
|
-
&inspectorInitializedMutex,
|
|
92
|
-
&inspectorInitializedCv](
|
|
93
|
-
jsinspector_modern::HostTarget& hostTarget) {
|
|
94
|
-
// NOTE: By passing *this, we strongly assume the Instance will still
|
|
95
|
-
// be alive by the time this executes.
|
|
96
|
-
// - On iOS, instance creation is done synchronously
|
|
97
|
-
// (`RCTCxxBridge::_initializeBridgeLocked`).
|
|
98
|
-
// - On Android, we explicitly wait for instance creation before
|
|
99
|
-
// destruction (`ReactInstanceManager::mReactContextLock`).
|
|
100
|
-
inspectorTarget_ = &hostTarget.registerInstance(*this);
|
|
101
|
-
RuntimeExecutor runtimeExecutorIfJsi = getRuntimeExecutor();
|
|
102
|
-
runtimeInspectorTarget_ = &inspectorTarget_->registerRuntime(
|
|
103
|
-
nativeToJsBridge_->getInspectorTargetDelegate(),
|
|
104
|
-
runtimeExecutorIfJsi ? runtimeExecutorIfJsi : [](auto) {});
|
|
105
|
-
|
|
106
|
-
// Signal that initialization is complete
|
|
107
|
-
{
|
|
108
|
-
std::lock_guard lock(inspectorInitializedMutex);
|
|
109
|
-
inspectorInitialized = true;
|
|
110
|
-
}
|
|
111
|
-
inspectorInitializedCv.notify_one();
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
// Wait for the initialization work to complete
|
|
115
|
-
{
|
|
116
|
-
std::unique_lock lock(inspectorInitializedMutex);
|
|
117
|
-
inspectorInitializedCv.wait(
|
|
118
|
-
lock, [&inspectorInitialized] { return inspectorInitialized; });
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Initialize the JavaScript runtime after we've initialized the inspector
|
|
123
|
-
nativeToJsBridge_->initializeRuntime();
|
|
124
|
-
|
|
125
|
-
// After NativeToJsBridge is created, the jsi::Runtime should exist. Also,
|
|
126
|
-
// the JS message queue thread exists. So, it's safe to schedule all queued
|
|
127
|
-
// up JS calls.
|
|
128
|
-
jsCallInvoker_->setNativeToJsBridgeAndFlushCalls(nativeToJsBridge_);
|
|
129
|
-
|
|
130
|
-
std::scoped_lock lock(m_syncMutex);
|
|
131
|
-
m_syncReady = true;
|
|
132
|
-
m_syncCV.notify_all();
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
CHECK(nativeToJsBridge_);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
void Instance::loadBundle(
|
|
139
|
-
std::unique_ptr<RAMBundleRegistry> bundleRegistry,
|
|
140
|
-
std::unique_ptr<const JSBigString> startupScript,
|
|
141
|
-
std::string sourceURL) {
|
|
142
|
-
callback_->incrementPendingJSCalls();
|
|
143
|
-
TraceSection s("Instance::loadBundle", "sourceURL", sourceURL);
|
|
144
|
-
nativeToJsBridge_->loadBundle(
|
|
145
|
-
std::move(bundleRegistry),
|
|
146
|
-
std::move(startupScript),
|
|
147
|
-
std::move(sourceURL));
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
void Instance::loadBundleSync(
|
|
151
|
-
std::unique_ptr<RAMBundleRegistry> bundleRegistry,
|
|
152
|
-
std::unique_ptr<const JSBigString> startupScript,
|
|
153
|
-
std::string sourceURL) {
|
|
154
|
-
std::unique_lock<std::mutex> lock(m_syncMutex);
|
|
155
|
-
m_syncCV.wait(lock, [this] { return m_syncReady; });
|
|
156
|
-
|
|
157
|
-
TraceSection s("Instance::loadBundleSync", "sourceURL", sourceURL);
|
|
158
|
-
nativeToJsBridge_->loadBundleSync(
|
|
159
|
-
std::move(bundleRegistry),
|
|
160
|
-
std::move(startupScript),
|
|
161
|
-
std::move(sourceURL));
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
void Instance::setSourceURL(std::string sourceURL) {
|
|
165
|
-
callback_->incrementPendingJSCalls();
|
|
166
|
-
TraceSection s("Instance::setSourceURL", "sourceURL", sourceURL);
|
|
167
|
-
|
|
168
|
-
nativeToJsBridge_->loadBundle(nullptr, nullptr, std::move(sourceURL));
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
void Instance::loadScriptFromString(
|
|
172
|
-
std::unique_ptr<const JSBigString> string,
|
|
173
|
-
std::string sourceURL,
|
|
174
|
-
bool loadSynchronously) {
|
|
175
|
-
TraceSection s("Instance::loadScriptFromString", "sourceURL", sourceURL);
|
|
176
|
-
if (loadSynchronously) {
|
|
177
|
-
loadBundleSync(nullptr, std::move(string), std::move(sourceURL));
|
|
178
|
-
} else {
|
|
179
|
-
loadBundle(nullptr, std::move(string), std::move(sourceURL));
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
void Instance::loadRAMBundleFromString(
|
|
184
|
-
std::unique_ptr<const JSBigString> script,
|
|
185
|
-
const std::string& sourceURL) {
|
|
186
|
-
auto bundle = std::make_unique<JSIndexedRAMBundle>(std::move(script));
|
|
187
|
-
auto startupScript = bundle->getStartupCode();
|
|
188
|
-
auto registry = RAMBundleRegistry::singleBundleRegistry(std::move(bundle));
|
|
189
|
-
loadRAMBundle(std::move(registry), std::move(startupScript), sourceURL, true);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
void Instance::loadRAMBundleFromFile(
|
|
193
|
-
const std::string& sourcePath,
|
|
194
|
-
const std::string& sourceURL,
|
|
195
|
-
bool loadSynchronously) {
|
|
196
|
-
auto bundle = std::make_unique<JSIndexedRAMBundle>(sourcePath.c_str());
|
|
197
|
-
auto startupScript = bundle->getStartupCode();
|
|
198
|
-
auto registry = RAMBundleRegistry::multipleBundlesRegistry(
|
|
199
|
-
std::move(bundle), JSIndexedRAMBundle::buildFactory());
|
|
200
|
-
loadRAMBundle(
|
|
201
|
-
std::move(registry),
|
|
202
|
-
std::move(startupScript),
|
|
203
|
-
sourceURL,
|
|
204
|
-
loadSynchronously);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
void Instance::loadRAMBundle(
|
|
208
|
-
std::unique_ptr<RAMBundleRegistry> bundleRegistry,
|
|
209
|
-
std::unique_ptr<const JSBigString> startupScript,
|
|
210
|
-
std::string startupScriptSourceURL,
|
|
211
|
-
bool loadSynchronously) {
|
|
212
|
-
if (loadSynchronously) {
|
|
213
|
-
loadBundleSync(
|
|
214
|
-
std::move(bundleRegistry),
|
|
215
|
-
std::move(startupScript),
|
|
216
|
-
std::move(startupScriptSourceURL));
|
|
217
|
-
} else {
|
|
218
|
-
loadBundle(
|
|
219
|
-
std::move(bundleRegistry),
|
|
220
|
-
std::move(startupScript),
|
|
221
|
-
std::move(startupScriptSourceURL));
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
void Instance::setGlobalVariable(
|
|
226
|
-
std::string propName,
|
|
227
|
-
std::unique_ptr<const JSBigString> jsonValue) {
|
|
228
|
-
nativeToJsBridge_->setGlobalVariable(
|
|
229
|
-
std::move(propName), std::move(jsonValue));
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
void* Instance::getJavaScriptContext() {
|
|
233
|
-
return nativeToJsBridge_ ? nativeToJsBridge_->getJavaScriptContext()
|
|
234
|
-
: nullptr;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
bool Instance::isInspectable() {
|
|
238
|
-
return nativeToJsBridge_ ? nativeToJsBridge_->isInspectable() : false;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
bool Instance::isBatchActive() {
|
|
242
|
-
return nativeToJsBridge_ ? nativeToJsBridge_->isBatchActive() : false;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
void Instance::callJSFunction(
|
|
246
|
-
std::string&& module,
|
|
247
|
-
std::string&& method,
|
|
248
|
-
folly::dynamic&& params) {
|
|
249
|
-
callback_->incrementPendingJSCalls();
|
|
250
|
-
nativeToJsBridge_->callFunction(
|
|
251
|
-
std::move(module), std::move(method), std::move(params));
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
void Instance::callJSCallback(uint64_t callbackId, folly::dynamic&& params) {
|
|
255
|
-
TraceSection s("Instance::callJSCallback");
|
|
256
|
-
callback_->incrementPendingJSCalls();
|
|
257
|
-
nativeToJsBridge_->invokeCallback((double)callbackId, std::move(params));
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
void Instance::registerBundle(
|
|
261
|
-
uint32_t bundleId,
|
|
262
|
-
const std::string& bundlePath) {
|
|
263
|
-
nativeToJsBridge_->registerBundle(bundleId, bundlePath);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
const ModuleRegistry& Instance::getModuleRegistry() const {
|
|
267
|
-
return *moduleRegistry_;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
ModuleRegistry& Instance::getModuleRegistry() {
|
|
271
|
-
return *moduleRegistry_;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
void Instance::handleMemoryPressure(int pressureLevel) {
|
|
275
|
-
if (nativeToJsBridge_) {
|
|
276
|
-
// This class resets `nativeToJsBridge_` only in the destructor,
|
|
277
|
-
// hence a race is not possible there.
|
|
278
|
-
nativeToJsBridge_->handleMemoryPressure(pressureLevel);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
std::shared_ptr<CallInvoker> Instance::getJSCallInvoker() {
|
|
283
|
-
return std::static_pointer_cast<CallInvoker>(jsCallInvoker_);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
RuntimeExecutor Instance::getRuntimeExecutor() {
|
|
287
|
-
// HACK: RuntimeExecutor is not compatible with non-JSIExecutor, we return
|
|
288
|
-
// a null callback, which the caller should handle.
|
|
289
|
-
if (getJavaScriptContext() == nullptr) {
|
|
290
|
-
return nullptr;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
std::weak_ptr<NativeToJsBridge> weakNativeToJsBridge = nativeToJsBridge_;
|
|
294
|
-
return [weakNativeToJsBridge](
|
|
295
|
-
std::function<void(jsi::Runtime & runtime)>&& callback) {
|
|
296
|
-
if (auto strongNativeToJsBridge = weakNativeToJsBridge.lock()) {
|
|
297
|
-
strongNativeToJsBridge->runOnExecutorQueue(
|
|
298
|
-
[callback = std::move(callback)](JSExecutor* executor) {
|
|
299
|
-
// Assumes the underlying executor is a JSIExecutor
|
|
300
|
-
auto* runtime =
|
|
301
|
-
static_cast<jsi::Runtime*>(executor->getJavaScriptContext());
|
|
302
|
-
try {
|
|
303
|
-
react_native_assert(runtime != nullptr);
|
|
304
|
-
callback(*runtime);
|
|
305
|
-
executor->flush();
|
|
306
|
-
} catch (jsi::JSError& originalError) {
|
|
307
|
-
handleJSError(*runtime, originalError, true);
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
std::shared_ptr<NativeMethodCallInvoker>
|
|
315
|
-
Instance::getDecoratedNativeMethodCallInvoker(
|
|
316
|
-
std::shared_ptr<NativeMethodCallInvoker> nativeMethodCallInvoker) {
|
|
317
|
-
return nativeToJsBridge_->getDecoratedNativeMethodCallInvoker(
|
|
318
|
-
nativeMethodCallInvoker);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
void Instance::JSCallInvoker::setNativeToJsBridgeAndFlushCalls(
|
|
322
|
-
std::weak_ptr<NativeToJsBridge> nativeToJsBridge) {
|
|
323
|
-
std::scoped_lock guard(m_mutex);
|
|
324
|
-
|
|
325
|
-
m_shouldBuffer = false;
|
|
326
|
-
m_nativeToJsBridge = nativeToJsBridge;
|
|
327
|
-
while (!m_workBuffer.empty()) {
|
|
328
|
-
scheduleAsync(std::move(m_workBuffer.front()));
|
|
329
|
-
m_workBuffer.pop_front();
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
void Instance::JSCallInvoker::invokeSync(CallFunc&& /*work*/) {
|
|
334
|
-
// TODO: Replace JS Callinvoker with RuntimeExecutor.
|
|
335
|
-
throw std::runtime_error(
|
|
336
|
-
"Synchronous native -> JS calls are currently not supported.");
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
void Instance::JSCallInvoker::invokeAsync(CallFunc&& work) noexcept {
|
|
340
|
-
std::scoped_lock guard(m_mutex);
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* Why is is necessary to queue up async work?
|
|
344
|
-
*
|
|
345
|
-
* 1. TurboModuleManager must be created synchronously after the Instance,
|
|
346
|
-
* before we load the source code. This is when the NativeModule system
|
|
347
|
-
* is initialized. RCTDevLoadingView shows bundle download progress.
|
|
348
|
-
* 2. TurboModuleManager requires a JS CallInvoker.
|
|
349
|
-
* 3. The JS CallInvoker requires the NativeToJsBridge, which is created on
|
|
350
|
-
* the JS thread in Instance::initializeBridge.
|
|
351
|
-
*
|
|
352
|
-
* Therefore, although we don't call invokeAsync before the JS bundle is
|
|
353
|
-
* executed, this buffering is implemented anyways to ensure that work
|
|
354
|
-
* isn't discarded.
|
|
355
|
-
*/
|
|
356
|
-
if (m_shouldBuffer) {
|
|
357
|
-
m_workBuffer.push_back(std::move(work));
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
scheduleAsync(std::move(work));
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
void Instance::JSCallInvoker::scheduleAsync(CallFunc&& work) noexcept {
|
|
365
|
-
if (auto strongNativeToJsBridge = m_nativeToJsBridge.lock()) {
|
|
366
|
-
strongNativeToJsBridge->runOnExecutorQueue(
|
|
367
|
-
[work = std::move(work)](JSExecutor* executor) {
|
|
368
|
-
auto* runtime = (jsi::Runtime*)executor->getJavaScriptContext();
|
|
369
|
-
work(*runtime);
|
|
370
|
-
executor->flush();
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
} // namespace facebook::react
|
|
376
|
-
|
|
377
|
-
#endif // RCT_REMOVE_LEGACY_ARCH
|
|
378
|
-
|
|
379
|
-
#if _MSC_VER
|
|
380
|
-
#pragma warning(pop)
|
|
381
|
-
#endif
|