react-native-windows 0.75.3 → 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.
- package/.flowconfig +6 -4
- package/Directory.Build.props +4 -0
- package/Directory.Build.targets +5 -0
- package/Libraries/Alert/Alert.js +3 -0
- package/Libraries/Alert/Alert.windows.js +3 -0
- package/Libraries/Animated/AnimatedEvent.js +1 -1
- package/Libraries/Animated/AnimatedImplementation.js +7 -7
- package/Libraries/Animated/NativeAnimatedAllowlist.js +111 -0
- package/Libraries/Animated/animations/Animation.js +11 -1
- package/Libraries/Animated/animations/DecayAnimation.js +1 -1
- package/Libraries/Animated/animations/SpringAnimation.js +1 -1
- package/Libraries/Animated/animations/TimingAnimation.js +2 -1
- package/Libraries/Animated/components/AnimatedScrollView.js +3 -2
- package/Libraries/Animated/createAnimatedComponent.js +10 -9
- package/Libraries/Animated/nodes/AnimatedColor.js +1 -1
- package/Libraries/Animated/nodes/AnimatedInterpolation.js +3 -2
- package/Libraries/Animated/nodes/AnimatedNode.js +42 -33
- package/Libraries/Animated/nodes/AnimatedObject.js +56 -50
- package/Libraries/Animated/nodes/AnimatedProps.js +77 -40
- package/Libraries/Animated/nodes/AnimatedStyle.js +103 -59
- package/Libraries/Animated/nodes/AnimatedTracking.js +1 -1
- package/Libraries/Animated/nodes/AnimatedTransform.js +102 -67
- package/Libraries/Animated/nodes/AnimatedValue.js +2 -1
- package/Libraries/Animated/nodes/AnimatedWithChildren.js +21 -22
- package/Libraries/Animated/useAnimatedProps.js +142 -7
- package/Libraries/BatchedBridge/NativeModules.js +2 -0
- package/Libraries/Blob/FileReader.js +1 -1
- package/Libraries/Blob/URL.js +2 -62
- package/Libraries/Blob/URLSearchParams.js +71 -0
- package/Libraries/Components/Button.windows.js +0 -1
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +1 -1
- package/Libraries/Components/Keyboard/KeyboardExt.js.map +1 -1
- package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +1 -1
- package/Libraries/Components/ScrollView/ScrollView.js +131 -169
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
- package/Libraries/Components/StatusBar/StatusBar.js +3 -1
- package/Libraries/Components/TextInput/TextInput.d.ts +32 -2
- package/Libraries/Components/TextInput/TextInput.js +230 -94
- package/Libraries/Components/TextInput/TextInput.windows.js +230 -105
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +22 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.js +2 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.windows.js +2 -0
- package/Libraries/Components/View/View.windows.js +32 -30
- package/Libraries/Components/View/ViewAccessibility.d.ts +15 -0
- package/Libraries/Components/View/ViewNativeComponent.js +0 -1
- package/Libraries/Components/View/ViewPropTypes.js +14 -0
- package/Libraries/Components/View/ViewPropTypes.windows.js +14 -0
- package/Libraries/Core/ExceptionsManager.js +2 -0
- package/Libraries/Core/InitializeCore.js +3 -1
- package/Libraries/Core/ReactFiberErrorDialog.js +3 -0
- package/Libraries/Core/ReactNativeVersion.js +4 -4
- package/Libraries/Core/setUpErrorHandling.js +7 -1
- package/Libraries/Core/setUpGlobals.js +1 -0
- package/Libraries/Core/setUpReactRefresh.js +0 -4
- package/Libraries/Image/AssetSourceResolver.js +28 -1
- package/Libraries/Image/AssetSourceResolver.windows.js +28 -1
- package/Libraries/Image/Image.android.js +9 -14
- package/Libraries/Image/Image.ios.js +11 -22
- package/Libraries/Image/Image.windows.js +11 -22
- package/Libraries/Image/ImageBackground.js +1 -8
- package/Libraries/Image/ImageUtils.js +9 -9
- package/Libraries/Image/ImageViewNativeComponent.js +1 -0
- package/Libraries/Inspector/Inspector.js +3 -2
- package/Libraries/Inspector/InspectorPanel.js +16 -10
- package/Libraries/Inspector/NetworkOverlay.js +1 -1
- package/Libraries/Interaction/TaskQueue.js +1 -0
- package/Libraries/Lists/FlatList.js +1 -1
- package/Libraries/Lists/SectionList.js +2 -2
- package/Libraries/Lists/SectionListModern.js +3 -3
- package/Libraries/LogBox/Data/LogBoxData.js +24 -3
- package/Libraries/LogBox/LogBoxNotificationContainer.js +3 -2
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +9 -8
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.windows.js +9 -8
- package/Libraries/Modal/Modal.js +0 -1
- package/Libraries/NativeComponent/BaseViewConfig.android.js +8 -0
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +7 -0
- package/Libraries/NativeComponent/BaseViewConfig.windows.js +7 -0
- package/Libraries/NativeComponent/NativeComponentRegistry.js +22 -22
- package/Libraries/NativeComponent/StaticViewConfigValidator.js +0 -21
- package/Libraries/Network/XMLHttpRequest.js +4 -2
- package/Libraries/ReactNative/AppContainer-dev.js +1 -5
- package/Libraries/ReactNative/AppContainer-prod.js +1 -5
- package/Libraries/ReactNative/AppContainer.js +1 -2
- package/Libraries/ReactNative/AppRegistry.d.ts +0 -4
- package/Libraries/ReactNative/AppRegistry.js +1 -7
- package/Libraries/ReactNative/BridgelessUIManager.js +1 -0
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +1 -1
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +5 -5
- package/Libraries/ReactNative/RendererImplementation.js +26 -4
- package/Libraries/ReactNative/getNativeComponentAttributes.js +8 -0
- package/Libraries/ReactNative/renderApplication.js +1 -3
- package/Libraries/Renderer/shims/ReactNativeTypes.js +11 -4
- package/Libraries/StyleSheet/StyleSheet.js +1 -1
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +74 -15
- package/Libraries/StyleSheet/StyleSheetTypes.js +60 -5
- package/Libraries/StyleSheet/processBackgroundImage.js +384 -0
- package/Libraries/StyleSheet/processBoxShadow.js +211 -0
- package/Libraries/StyleSheet/processFilter.js +231 -42
- package/Libraries/Text/Text.js +394 -196
- package/Libraries/Text/Text.windows.js +476 -300
- package/Libraries/Text/TextNativeComponent.js +2 -1
- package/Libraries/TurboModule/TurboModuleRegistry.js +13 -50
- package/Libraries/Types/CodegenTypes.js +3 -1
- package/Libraries/Utilities/Appearance.js +108 -84
- package/Libraries/Utilities/DevLoadingView.js +2 -4
- package/Libraries/Utilities/HMRClient.js +2 -1
- package/Libraries/Utilities/ReactNativeTestTools.js +1 -1
- package/Libraries/Utilities/createPerformanceLogger.js +0 -9
- package/Libraries/Utilities/stringifyViewConfig.js +22 -0
- package/Libraries/Utilities/useColorScheme.js +3 -3
- package/Libraries/WebSocket/WebSocket.js +1 -1
- package/Libraries/promiseRejectionTrackingOptions.js +1 -1
- package/Libraries/vendor/emitter/EventEmitter.js +6 -5
- package/Microsoft.ReactNative/ComponentView.idl +11 -0
- package/Microsoft.ReactNative/Composition.Input.idl +1 -0
- package/Microsoft.ReactNative/CompositionSwitcher.idl +3 -0
- package/Microsoft.ReactNative/Fabric/AbiComponentDescriptor.cpp +9 -9
- package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.cpp +9 -9
- package/Microsoft.ReactNative/Fabric/ComponentView.cpp +7 -9
- package/Microsoft.ReactNative/Fabric/ComponentView.h +5 -6
- package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.cpp +4 -0
- package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h +1 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +44 -13
- package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +42 -5
- package/Microsoft.ReactNative/Fabric/Composition/CompositionHwndHost.cpp +1 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +81 -63
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +2 -3
- package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.cpp +8 -6
- package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.h +1 -2
- package/Microsoft.ReactNative/Fabric/Composition/FocusManager.cpp +20 -6
- package/Microsoft.ReactNative/Fabric/Composition/FocusManager.h +13 -6
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +2 -3
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.h +1 -2
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +72 -54
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +14 -4
- package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +26 -8
- package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +5 -2
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +18 -7
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.h +1 -2
- package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.cpp +6 -6
- package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.h +1 -2
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +97 -140
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +8 -4
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.cpp +18 -11
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.h +5 -4
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputState.cpp +0 -13
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputState.h +0 -3
- package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +29 -4
- package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +2 -0
- package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.cpp +1 -2
- package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.h +1 -2
- package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +28 -12
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/HostPlatformColor.h +33 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.cpp +26 -9
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.h +10 -4
- package/Microsoft.ReactNative/IReactModuleBuilder.cpp +5 -0
- package/Microsoft.ReactNative/IReactModuleBuilder.h +1 -0
- package/Microsoft.ReactNative/IReactModuleBuilder.idl +9 -0
- package/Microsoft.ReactNative/IReactViewComponentBuilder.idl +8 -1
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +2 -0
- package/Microsoft.ReactNative/Modules/AlertModule.cpp +3 -1
- package/Microsoft.ReactNative/Modules/AppearanceModule.cpp +1 -1
- package/Microsoft.ReactNative/Modules/AppearanceModule.h +7 -1
- package/Microsoft.ReactNative/Modules/DevSettingsModule.cpp +3 -3
- package/Microsoft.ReactNative/Modules/DevSettingsModule.h +1 -1
- package/Microsoft.ReactNative/Modules/LinkingManagerModule.cpp +2 -2
- package/Microsoft.ReactNative/Modules/LinkingManagerModule.h +1 -1
- package/Microsoft.ReactNative/Modules/LogBoxModule.cpp +9 -0
- package/Microsoft.ReactNative/Modules/LogBoxModule.h +2 -0
- package/Microsoft.ReactNative/Modules/SampleTurboModule.cpp +121 -0
- package/Microsoft.ReactNative/Modules/SampleTurboModule.h +90 -0
- package/Microsoft.ReactNative/ReactHost/MsoReactContext.cpp +0 -7
- package/Microsoft.ReactNative/ReactHost/MsoReactContext.h +0 -5
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +5 -1
- package/Microsoft.ReactNative/ReactInstanceSettingsBuilder.cpp +59 -0
- package/Microsoft.ReactNative/ReactInstanceSettingsBuilder.h +23 -0
- package/Microsoft.ReactNative/ReactNativeAppBuilder.cpp +179 -0
- package/Microsoft.ReactNative/ReactNativeAppBuilder.h +35 -0
- package/Microsoft.ReactNative/ReactNativeAppBuilder.idl +69 -0
- package/Microsoft.ReactNative/ReactNativeIsland.idl +2 -0
- package/Microsoft.ReactNative/ReactNativeWin32App.cpp +82 -0
- package/Microsoft.ReactNative/ReactNativeWin32App.h +38 -0
- package/Microsoft.ReactNative/TurboModulesProvider.cpp +45 -0
- package/Microsoft.ReactNative/Views/DynamicAutomationPeer.cpp +2 -1
- package/Microsoft.ReactNative/Views/FlyoutViewManager.cpp +25 -16
- package/Microsoft.ReactNative/packages.fabric.lock.json +159 -0
- package/Microsoft.ReactNative/packages.lock.json +11 -12
- package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +3 -4
- package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems.filters +3 -0
- package/Microsoft.ReactNative.Cxx/ModuleRegistration.cpp +2 -2
- package/Microsoft.ReactNative.Cxx/ModuleRegistration.h +62 -4
- package/Microsoft.ReactNative.Cxx/NativeModules.h +131 -14
- package/Microsoft.ReactNative.Managed/packages.lock.json +9 -9
- package/Microsoft.ReactNative.Managed.CodeGen/ReactNativeNames.cs +10 -2
- package/PropertySheets/Autolink.props +1 -1
- package/PropertySheets/Bundle.props +1 -1
- package/PropertySheets/Codegen.props +1 -1
- package/PropertySheets/Generated/PackageVersion.g.props +4 -4
- package/PropertySheets/NuGet.LockFile.props +18 -0
- package/README.md +29 -29
- package/ReactCommon/ReactCommon.vcxproj +5 -1
- package/ReactCommon/ReactCommon.vcxproj.filters +11 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp +2 -7
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.cpp +441 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.h +266 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/Utf8.h +56 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Base.h +3 -1
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Bridging.h +2 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/CallbackWrapper.h +1 -1
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Convert.h +172 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/EventEmitter.h +4 -5
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Function.h +2 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModule.h +1 -1
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModuleUtils.h +3 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/scrollview/ScrollViewProps.cpp +9 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/LayoutableShadowNode.cpp +363 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/JSRuntimeFactory.h +22 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +118 -51
- package/ReactCommon/packages.lock.json +2 -2
- package/Scripts/NuGetRestoreForceEvaluateAllSolutions.ps1 +8 -1
- package/Scripts/Tfs/Layout-MSRN-Headers.ps1 +2 -2
- package/Shared/Modules/WebSocketModule.cpp +1 -2
- package/Shared/Networking/WinRTWebSocketResource.cpp +4 -1
- package/Shared/Shared.vcxitems +38 -2
- package/Shared/Shared.vcxitems.filters +6 -1
- package/Shared/TurboModuleManager.cpp +0 -3
- package/codegen/NativeLinkingManagerSpec.g.h +3 -3
- package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +198 -54
- package/codegen/NativeSampleTurboModuleSpec.g.h +35 -0
- package/codegen/rnwcoreJSI-generated.cpp +245 -101
- package/codegen/rnwcoreJSI.h +847 -548
- package/index.js +3 -1
- package/index.windows.js +3 -1
- package/jest/mockComponent.js +4 -1
- package/jest/mockModal.js +1 -3
- package/jest/mockScrollView.js +1 -1
- package/jest/renderer.js +2 -2
- package/jest/setup.js +16 -13
- package/package.json +26 -25
- package/src/private/animated/NativeAnimatedHelper.js +438 -0
- package/src/private/animated/NativeAnimatedValidation.js +64 -0
- package/src/private/components/HScrollViewNativeComponents.js +56 -0
- package/src/private/components/SafeAreaView_INTERNAL_DO_NOT_USE.js +27 -0
- package/src/private/components/VScrollViewNativeComponents.js +48 -0
- package/src/private/components/useSyncOnScroll.js +48 -0
- package/src/private/featureflags/ReactNativeFeatureFlags.js +166 -16
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +29 -5
- package/src/private/fusebox/FuseboxSessionObserver.js +42 -0
- package/{Libraries/Core → src/private/renderer/errorhandling}/ErrorHandlers.js +14 -4
- package/src/private/setup/setUpDOM.js +28 -0
- package/src/private/setup/setUpIntersectionObserver.js +27 -0
- package/src/private/setup/setUpMutationObserver.js +26 -0
- package/src/private/setup/setUpPerformanceObserver.js +64 -0
- package/src/private/specs/modules/NativeAppearance.js +3 -3
- package/src/private/specs/modules/NativeLinkingManager.js +1 -1
- package/src/private/specs/modules/NativePlatformConstantsWindows.js +7 -0
- package/src/private/specs/modules/NativeSampleTurboModule.js +14 -1
- package/src/private/webapis/dom/nodes/ReadOnlyNode.js +6 -4
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserver.js +5 -3
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverEntry.js +3 -3
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverManager.js +14 -17
- package/src/private/{specs/modules → webapis/intersectionobserver/specs}/NativeIntersectionObserver.js +2 -2
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver/specs}/__mocks__/NativeIntersectionObserver.js +4 -4
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserver.js +5 -3
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserverManager.js +24 -15
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationRecord.js +4 -6
- package/src/private/{specs/modules → webapis/mutationobserver/specs}/NativeMutationObserver.js +2 -2
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver/specs}/__mocks__/NativeMutationObserver.js +5 -5
- package/src/private/webapis/performance/{EventCounts.js → EventTiming.js} +65 -3
- package/src/private/webapis/performance/LongTasks.js +39 -0
- package/src/private/webapis/performance/Performance.js +22 -9
- package/src/private/webapis/performance/PerformanceEntry.js +36 -18
- package/src/private/webapis/performance/PerformanceObserver.js +29 -43
- package/src/private/webapis/performance/RawPerformanceEntry.js +24 -1
- package/src/private/webapis/performance/UserTiming.js +17 -12
- package/src/private/webapis/performance/specs/NativePerformanceObserver.js +1 -1
- package/template/cpp-app/src/AutolinkedNativeModules.g.cpp +1 -1
- package/template/cpp-app/src/AutolinkedNativeModules.g.h +1 -1
- package/template/cs-app/src/AutolinkedNativeModules.g.cs +1 -1
- package/template/index.windows.bundle +1 -1
- package/template/metro.config.js +2 -2
- package/template/shared-app/src/AutolinkedNativeModules.g.props +1 -1
- package/template/shared-app/src/AutolinkedNativeModules.g.targets +1 -1
- package/templates/cpp-app/metro.config.js +2 -2
- package/templates/cpp-app/template.config.js +5 -5
- package/templates/cpp-app/windows/MyApp/AutolinkedNativeModules.g.cpp +1 -1
- package/templates/cpp-app/windows/MyApp/AutolinkedNativeModules.g.h +1 -1
- package/templates/cpp-app/windows/MyApp/MyApp.cpp +2 -0
- package/templates/cpp-app/windows/MyApp/MyApp.vcxproj +1 -1
- package/templates/cpp-lib/example/metro.config.js +2 -2
- package/templates/cpp-lib/template.config.js +3 -3
- package/templates/cpp-lib/windows/MyLib/MyLib.h +3 -3
- package/templates/cpp-lib/windows/MyLib/MyLib.vcxproj +1 -1
- package/types/experimental.d.ts +20 -1
- package/Libraries/Animated/NativeAnimatedHelper.js +0 -615
- package/Libraries/Core/setUpIntersectionObserver.js +0 -16
- package/Libraries/Core/setUpMutationObserver.js +0 -16
- package/Libraries/Core/setUpPerformanceObserver.js +0 -18
- package/Libraries/IntersectionObserver/NativeIntersectionObserver.js +0 -13
- package/Libraries/MutationObserver/NativeMutationObserver.js +0 -13
- package/Libraries/Utilities/verifyComponentAttributeEquivalence.js +0 -135
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/algorithm/CalculateLayout.cpp +0 -2396
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/config/Config.cpp +0 -136
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/config/Config.h +0 -92
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/LayoutResults.cpp +0 -48
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/LayoutResults.h +0 -122
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/Node.cpp +0 -388
- package/src/private/core/setUpDOM.js +0 -18
- package/src/private/webapis/performance/PerformanceEventTiming.js +0 -55
- /package/src/private/{core → styles}/composeStyles.js +0 -0
|
@@ -118,7 +118,6 @@
|
|
|
118
118
|
<ClInclude Include="$(ReactNativeDir)\ReactCommon\jsiexecutor\jsireact\JSIExecutor.h" />
|
|
119
119
|
<ClInclude Include="$(ReactNativeDir)\ReactCommon\jsiexecutor\jsireact\JSINativeModules.h" />
|
|
120
120
|
<ClInclude Include="$(ReactNativeDir)\ReactCommon\jsinspector-modern\InspectorInterfaces.h" />
|
|
121
|
-
<ClInclude Include="$(ReactNativeDir)\ReactCommon\jsinspector-modern\ConsoleMessage.h" />
|
|
122
121
|
<ClInclude Include="$(ReactNativeDir)\ReactCommon\logger\react_native_log.h" />
|
|
123
122
|
<ClInclude Include="$(YogaDir)\yoga\YGEnums.h" />
|
|
124
123
|
<ClInclude Include="$(YogaDir)\yoga\YGMacros.h" />
|
|
@@ -142,6 +141,7 @@
|
|
|
142
141
|
<ClCompile Include="$(ReactNativeDir)\ReactCommon\jsiexecutor\jsireact\JSINativeModules.cpp" />
|
|
143
142
|
<ClCompile Include="$(ReactNativeDir)\ReactCommon\jsinspector-modern\InspectorInterfaces.cpp" />
|
|
144
143
|
<ClCompile Include="$(ReactNativeDir)\ReactCommon\logger\react_native_log.cpp" />
|
|
144
|
+
<CLCompile Include="$(ReactNativeDir)\ReactCommon\reactperflogger\fusebox\FuseboxTracer.cpp" />
|
|
145
145
|
<CLCompile Include="$(ReactNativeDir)\ReactCommon\reactperflogger\reactperflogger\BridgeNativeModulePerfLogger.cpp" />
|
|
146
146
|
<ClCompile Include="$(YogaDir)\yoga\YGConfig.cpp" />
|
|
147
147
|
<ClCompile Include="$(YogaDir)\yoga\YGEnums.cpp" />
|
|
@@ -167,6 +167,7 @@
|
|
|
167
167
|
<ClCompile Include="$(ReactNativeDir)\ReactCommon\react\renderer\mapbuffer\MapBuffer.cpp" />
|
|
168
168
|
<ClCompile Include="$(ReactNativeDir)\ReactCommon\react\renderer\mapbuffer\MapBufferBuilder.cpp" />
|
|
169
169
|
<ClCompile Include="$(ReactNativeDir)\ReactCommon\react\renderer\telemetry\TransactionTelemetry.cpp" />
|
|
170
|
+
<CLCompile Include="$(ReactNativeDir)\ReactCommon\react\performance\timeline\PerformanceEntryReporter.cpp" />
|
|
170
171
|
<ClCompile Include="$(YogaDir)\yoga\event\event.cpp" />
|
|
171
172
|
<ClCompile Include="pch.cpp">
|
|
172
173
|
<PrecompiledHeader>Create</PrecompiledHeader>
|
|
@@ -176,6 +177,9 @@
|
|
|
176
177
|
<ClInclude Include="$(ReactNativeDir)\ReactCommon\react\nativemodule\core\ReactCommon\LongLivedObject.h" />
|
|
177
178
|
<ClInclude Include="$(ReactNativeDir)\ReactCommon\react\bridging\CallbackWrapper.h" />
|
|
178
179
|
<ClInclude Include="$(ReactNativeDir)\ReactCommon\react\bridging\EventEmitter.h" />
|
|
180
|
+
<ClInclude Include="$(ReactNativeDir)\ReactCommon\react\bridging\Function.h" />
|
|
181
|
+
<ClInclude Include="$(ReactNativeDir)\ReactCommon\react\bridging\Base.h" />
|
|
182
|
+
<ClInclude Include="$(ReactNativeDir)\ReactCommon\react\bridging\Convert.h" />
|
|
179
183
|
<ClInclude Include="$(ReactNativeDir)\ReactCommon\react\nativemodule\core\ReactCommon\TurboCxxModule.h" />
|
|
180
184
|
<ClInclude Include="$(ReactNativeDir)\ReactCommon\react\nativemodule\core\ReactCommon\TurboModule.h" />
|
|
181
185
|
<ClInclude Include="$(ReactNativeDir)\ReactCommon\react\nativemodule\core\ReactCommon\TurboModuleBinding.h" />
|
|
@@ -324,11 +324,20 @@
|
|
|
324
324
|
</ClInclude>
|
|
325
325
|
<ClInclude Include="$(ReactNativeDir)\ReactCommon\react\bridging\CallbackWrapper.h">
|
|
326
326
|
<Filter>react\bridging</Filter>
|
|
327
|
-
</ClInclude
|
|
327
|
+
</ClInclude>
|
|
328
|
+
<ClInclude Include="$(ReactNativeDir)\ReactCommon\react\bridging\EventEmitter.h" >
|
|
329
|
+
<Filter>react\bridging</Filter>
|
|
330
|
+
</ClInclude>
|
|
331
|
+
<ClInclude Include="$(ReactNativeDir)\ReactCommon\react\bridging\Function.h" >
|
|
332
|
+
<Filter>react\bridging</Filter>
|
|
333
|
+
</ClInclude>
|
|
334
|
+
<ClInclude Include="$(ReactNativeDir)\ReactCommon\react\bridging\Base.h" >
|
|
335
|
+
<Filter>react\bridging</Filter>
|
|
336
|
+
</ClInclude>
|
|
337
|
+
<ClInclude Include="$(ReactNativeDir)\ReactCommon\react\bridging\Convert.h" >
|
|
328
338
|
<Filter>react\bridging</Filter>
|
|
329
339
|
</ClInclude>
|
|
330
340
|
<ClInclude Include="$(ReactNativeDir)\ReactCommon\jsinspector-modern\InspectorInterfaces.h" />
|
|
331
|
-
<ClInclude Include="$(ReactNativeDir)\ReactCommon\jsinspector-modern\ConsoleMessage.h" />
|
|
332
341
|
<ClInclude Include="$(ReactNativeDir)\ReactCommon\react\renderer\runtimescheduler\RuntimeScheduler_Legacy.h" />
|
|
333
342
|
<ClInclude Include="$(ReactNativeDir)\ReactCommon\react\renderer\runtimescheduler\RuntimeScheduler_Modern.h" />
|
|
334
343
|
<ClInclude Include="$(ReactNativeDir)\ReactCommon\react\renderer\core\PropsParserContext.h" />
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
#include <jsinspector-modern/ReactCdp.h>
|
|
14
14
|
#include <jsinspector-modern/ConsoleMessage.h>
|
|
15
15
|
|
|
16
|
+
#include <react/timing/primitives.h>
|
|
16
17
|
#include <chrono>
|
|
17
18
|
|
|
18
19
|
namespace facebook::react {
|
|
@@ -27,13 +28,7 @@ std::string JSExecutor::getSyntheticBundlePath(
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
double JSExecutor::performanceNow() {
|
|
30
|
-
|
|
31
|
-
auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(
|
|
32
|
-
time.time_since_epoch())
|
|
33
|
-
.count();
|
|
34
|
-
|
|
35
|
-
constexpr double NANOSECONDS_IN_MILLISECOND = 1000000.0;
|
|
36
|
-
return duration / NANOSECONDS_IN_MILLISECOND;
|
|
31
|
+
return chronoToDOMHighResTimeStamp(std::chrono::steady_clock::now());
|
|
37
32
|
}
|
|
38
33
|
|
|
39
34
|
void JSExecutor::addConsoleMessage(jsi::Runtime& runtime, jsinspector_modern::ConsoleMessage message){
|
|
@@ -0,0 +1,441 @@
|
|
|
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 "NetworkIOAgent.h"
|
|
9
|
+
#include <utility>
|
|
10
|
+
#include "Base64.h"
|
|
11
|
+
#include "Utf8.h"
|
|
12
|
+
|
|
13
|
+
namespace facebook::react::jsinspector_modern {
|
|
14
|
+
|
|
15
|
+
static constexpr long DEFAULT_BYTES_PER_READ =
|
|
16
|
+
1048576; // 1MB (Chrome v112 default)
|
|
17
|
+
|
|
18
|
+
// https://github.com/chromium/chromium/blob/128.0.6593.1/content/browser/devtools/devtools_io_context.cc#L71-L73
|
|
19
|
+
static constexpr std::array kTextMIMETypePrefixes{
|
|
20
|
+
"text/",
|
|
21
|
+
"application/x-javascript",
|
|
22
|
+
"application/json",
|
|
23
|
+
"application/xml",
|
|
24
|
+
"application/javascript" // Not in Chromium but emitted by Metro
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// namespace { [Windows #13587]
|
|
28
|
+
|
|
29
|
+
struct InitStreamResult {
|
|
30
|
+
int httpStatusCode;
|
|
31
|
+
Headers headers;
|
|
32
|
+
std::shared_ptr<Stream> stream;
|
|
33
|
+
};
|
|
34
|
+
using InitStreamError = const std::string;
|
|
35
|
+
|
|
36
|
+
using StreamInitCallback =
|
|
37
|
+
std::function<void(std::variant<InitStreamError, InitStreamResult>)>;
|
|
38
|
+
using IOReadCallback =
|
|
39
|
+
std::function<void(std::variant<IOReadError, IOReadResult>)>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Private class owning state and implementing the listener for a particular
|
|
43
|
+
* request
|
|
44
|
+
*
|
|
45
|
+
* NetworkRequestListener overrides are thread safe, all other methods must be
|
|
46
|
+
* called from the same thread.
|
|
47
|
+
*/
|
|
48
|
+
class Stream : public NetworkRequestListener,
|
|
49
|
+
public EnableExecutorFromThis<Stream> {
|
|
50
|
+
public:
|
|
51
|
+
Stream(const Stream& other) = delete;
|
|
52
|
+
Stream& operator=(const Stream& other) = delete;
|
|
53
|
+
Stream(Stream&& other) = default;
|
|
54
|
+
Stream& operator=(Stream&& other) = default;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Factory method to create a Stream with a callback for the initial result
|
|
58
|
+
* of a network request.
|
|
59
|
+
* \param executor An executor on which all processing of callbacks from
|
|
60
|
+
* the platform will be performed, and on which the passed callback will be
|
|
61
|
+
* called.
|
|
62
|
+
* \param initCb Will be called once either on receipt of HTTP headers or
|
|
63
|
+
* any prior error, using the given executor.
|
|
64
|
+
*/
|
|
65
|
+
static std::shared_ptr<Stream> create(
|
|
66
|
+
VoidExecutor executor,
|
|
67
|
+
StreamInitCallback initCb) {
|
|
68
|
+
std::shared_ptr<Stream> stream{new Stream(initCb)};
|
|
69
|
+
stream->setExecutor(executor);
|
|
70
|
+
return stream;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Agent-facing API. Enqueue a read request for up to maxBytesToRead
|
|
75
|
+
* bytes, starting from the end of the previous read.
|
|
76
|
+
* \param maxBytesToRead The maximum number of bytes to read from the
|
|
77
|
+
* source stream.
|
|
78
|
+
* \param callback Will be called using the executor passed to create()
|
|
79
|
+
* with the result of the read, or an error string.
|
|
80
|
+
*/
|
|
81
|
+
void read(long maxBytesToRead, const IOReadCallback& callback) {
|
|
82
|
+
pendingReadRequests_.emplace_back(
|
|
83
|
+
std::make_tuple(maxBytesToRead, callback));
|
|
84
|
+
processPending();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Agent-facing API. Call the platform-provided cancelFunction, if any,
|
|
89
|
+
* call the error callbacks of any in-flight read requests, and the initial
|
|
90
|
+
* error callback if it has not already fulfilled with success or error.
|
|
91
|
+
*/
|
|
92
|
+
void cancel() {
|
|
93
|
+
if (cancelFunction_) {
|
|
94
|
+
(*cancelFunction_)();
|
|
95
|
+
}
|
|
96
|
+
error_ = "Cancelled";
|
|
97
|
+
if (initCb_) {
|
|
98
|
+
auto cb = std::move(initCb_);
|
|
99
|
+
(*cb)(InitStreamError{"Cancelled"});
|
|
100
|
+
}
|
|
101
|
+
// Respond to any in-flight read requests with an error.
|
|
102
|
+
processPending();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Begin implementation of NetworkRequestListener, to be called by platform
|
|
107
|
+
* HostTargetDelegate. Any of these methods may be called from any thread.
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
void onData(std::string_view data) override {
|
|
111
|
+
data_ << data;
|
|
112
|
+
bytesReceived_ += data.length();
|
|
113
|
+
processPending();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
void onHeaders(int httpStatusCode, const Headers& headers) override {
|
|
117
|
+
// Find content-type through case-insensitive search of headers.
|
|
118
|
+
for (const auto& [name, value] : headers) {
|
|
119
|
+
std::string lowerName = name;
|
|
120
|
+
std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), [](unsigned char c) { // [Windows #13587]
|
|
121
|
+
return static_cast<char>(::tolower(c)); // [Windows #13587]
|
|
122
|
+
});
|
|
123
|
+
if (lowerName == "content-type") {
|
|
124
|
+
isText_ = isTextMimeType(value);
|
|
125
|
+
break;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// If we've already seen an error, the initial callback as already been
|
|
130
|
+
// called with it.
|
|
131
|
+
if (initCb_) {
|
|
132
|
+
auto cb = std::move(initCb_);
|
|
133
|
+
(*cb)(
|
|
134
|
+
InitStreamResult{httpStatusCode, headers, this->shared_from_this()});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
void onError(const std::string& message) override {
|
|
139
|
+
// Only call the error callback once.
|
|
140
|
+
if (!error_) {
|
|
141
|
+
error_ = message;
|
|
142
|
+
if (initCb_) {
|
|
143
|
+
auto cb = std::move(initCb_);
|
|
144
|
+
(*cb)(InitStreamError{message});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
processPending();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
void onCompletion() override {
|
|
151
|
+
completed_ = true;
|
|
152
|
+
processPending();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
void setCancelFunction(std::function<void()> cancelFunction) override {
|
|
156
|
+
cancelFunction_ = std::move(cancelFunction);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
~Stream() override {
|
|
160
|
+
// Cancel any incoming request, if the platform has provided a cancel
|
|
161
|
+
// callback.
|
|
162
|
+
if (cancelFunction_) {
|
|
163
|
+
(*cancelFunction_)();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/* End NetworkRequestListener */
|
|
168
|
+
|
|
169
|
+
private:
|
|
170
|
+
/**
|
|
171
|
+
* Private constructor. The caller must call setExecutor immediately
|
|
172
|
+
* afterwards.
|
|
173
|
+
*/
|
|
174
|
+
explicit Stream(const StreamInitCallback& initCb)
|
|
175
|
+
: initCb_(std::make_unique<StreamInitCallback>(initCb)) {}
|
|
176
|
+
|
|
177
|
+
void processPending() {
|
|
178
|
+
// Go through each pending request in insertion order - execute the
|
|
179
|
+
// callback and remove it from pending if it can be satisfied.
|
|
180
|
+
for (auto it = pendingReadRequests_.begin();
|
|
181
|
+
it != pendingReadRequests_.end();) {
|
|
182
|
+
auto maxBytesToRead = std::get<0>(*it);
|
|
183
|
+
auto callback = std::get<1>(*it);
|
|
184
|
+
|
|
185
|
+
if (error_) {
|
|
186
|
+
callback(IOReadError{*error_});
|
|
187
|
+
} else if (
|
|
188
|
+
completed_ || (bytesReceived_ - data_.tellg() >= maxBytesToRead)) {
|
|
189
|
+
try {
|
|
190
|
+
callback(respond(maxBytesToRead));
|
|
191
|
+
} catch (const std::runtime_error& error) {
|
|
192
|
+
callback(IOReadError{error.what()});
|
|
193
|
+
}
|
|
194
|
+
} else {
|
|
195
|
+
// Not yet received enough data
|
|
196
|
+
++it;
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
it = pendingReadRequests_.erase(it);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
IOReadResult respond(long maxBytesToRead) {
|
|
204
|
+
std::vector<char> buffer(maxBytesToRead);
|
|
205
|
+
data_.read(buffer.data(), maxBytesToRead);
|
|
206
|
+
auto bytesRead = data_.gcount();
|
|
207
|
+
std::string output;
|
|
208
|
+
|
|
209
|
+
buffer.resize(static_cast<size_t>(bytesRead)); // [Windows #13587]
|
|
210
|
+
if (isText_) {
|
|
211
|
+
auto originalSize = buffer.size();
|
|
212
|
+
// Maybe resize to drop the last 1-3 bytes so that buffer is valid.
|
|
213
|
+
truncateToValidUTF8(buffer);
|
|
214
|
+
if (buffer.size() < originalSize) {
|
|
215
|
+
// Rewind the stream so that the next read starts from the start of
|
|
216
|
+
// the code point we're removing from this chunk.
|
|
217
|
+
data_.seekg(buffer.size() - originalSize, std::ios_base::cur);
|
|
218
|
+
}
|
|
219
|
+
output = std::string(buffer.begin(), buffer.begin() + buffer.size());
|
|
220
|
+
} else {
|
|
221
|
+
// Encode the slice as a base64 string.
|
|
222
|
+
output = base64Encode(std::string_view(buffer.data(), buffer.size()));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return IOReadResult{
|
|
226
|
+
.data = output,
|
|
227
|
+
.eof = output.length() == 0 && completed_,
|
|
228
|
+
.base64Encoded = !isText_};
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// https://github.com/chromium/chromium/blob/128.0.6593.1/content/browser/devtools/devtools_io_context.cc#L70-L80
|
|
232
|
+
static bool isTextMimeType(const std::string& mimeType) {
|
|
233
|
+
for (auto& kTextMIMETypePrefix : kTextMIMETypePrefixes) {
|
|
234
|
+
if (mimeType.starts_with(kTextMIMETypePrefix)) {
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
bool completed_{false};
|
|
242
|
+
bool isText_{false};
|
|
243
|
+
std::optional<std::string> error_;
|
|
244
|
+
std::stringstream data_;
|
|
245
|
+
size_t bytesReceived_{0}; // [Windows #13587]
|
|
246
|
+
std::optional<std::function<void()>> cancelFunction_{std::nullopt};
|
|
247
|
+
std::unique_ptr<StreamInitCallback> initCb_;
|
|
248
|
+
std::vector<std::tuple<long /* bytesToRead */, IOReadCallback>>
|
|
249
|
+
pendingReadRequests_;
|
|
250
|
+
};
|
|
251
|
+
// } // namespace [Windows #13587]
|
|
252
|
+
|
|
253
|
+
bool NetworkIOAgent::handleRequest(
|
|
254
|
+
const cdp::PreparsedRequest& req,
|
|
255
|
+
LoadNetworkResourceDelegate& delegate) {
|
|
256
|
+
if (req.method == "Network.loadNetworkResource") {
|
|
257
|
+
handleLoadNetworkResource(req, delegate);
|
|
258
|
+
return true;
|
|
259
|
+
} else if (req.method == "IO.read") {
|
|
260
|
+
handleIoRead(req);
|
|
261
|
+
return true;
|
|
262
|
+
} else if (req.method == "IO.close") {
|
|
263
|
+
handleIoClose(req);
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
void NetworkIOAgent::handleLoadNetworkResource(
|
|
270
|
+
const cdp::PreparsedRequest& req,
|
|
271
|
+
LoadNetworkResourceDelegate& delegate) {
|
|
272
|
+
long long requestId = req.id;
|
|
273
|
+
|
|
274
|
+
LoadNetworkResourceRequest params;
|
|
275
|
+
|
|
276
|
+
if (!req.params.isObject()) {
|
|
277
|
+
frontendChannel_(cdp::jsonError(
|
|
278
|
+
req.id,
|
|
279
|
+
cdp::ErrorCode::InvalidParams,
|
|
280
|
+
"Invalid params: not an object."));
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
if ((req.params.count("url") == 0u) || !req.params.at("url").isString()) {
|
|
284
|
+
frontendChannel_(cdp::jsonError(
|
|
285
|
+
requestId,
|
|
286
|
+
cdp::ErrorCode::InvalidParams,
|
|
287
|
+
"Invalid params: url is missing or not a string."));
|
|
288
|
+
return;
|
|
289
|
+
} else {
|
|
290
|
+
params.url = req.params.at("url").asString();
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// This is an opaque identifier, but an incrementing integer in a string is
|
|
294
|
+
// consistent with Chrome.
|
|
295
|
+
StreamID streamId = std::to_string(nextStreamId_++);
|
|
296
|
+
|
|
297
|
+
auto stream = Stream::create(
|
|
298
|
+
executor_,
|
|
299
|
+
[streamId,
|
|
300
|
+
requestId,
|
|
301
|
+
frontendChannel = frontendChannel_,
|
|
302
|
+
streamsWeak = std::weak_ptr(streams_)](auto resultOrError) {
|
|
303
|
+
NetworkResource resource;
|
|
304
|
+
std::string cdpError;
|
|
305
|
+
if (auto* error = std::get_if<InitStreamError>(&resultOrError)) {
|
|
306
|
+
resource = NetworkResource{.success = false, .netErrorName = *error};
|
|
307
|
+
} else if (
|
|
308
|
+
auto* result = std::get_if<InitStreamResult>(&resultOrError)) {
|
|
309
|
+
if (result->httpStatusCode >= 200 && result->httpStatusCode < 300) {
|
|
310
|
+
resource = NetworkResource{
|
|
311
|
+
.success = true,
|
|
312
|
+
.stream = streamId,
|
|
313
|
+
.httpStatusCode = result->httpStatusCode,
|
|
314
|
+
.headers = result->headers};
|
|
315
|
+
} else if (result->httpStatusCode >= 400) {
|
|
316
|
+
resource = NetworkResource{
|
|
317
|
+
.success = false,
|
|
318
|
+
.httpStatusCode = result->httpStatusCode,
|
|
319
|
+
.headers = result->headers};
|
|
320
|
+
} else {
|
|
321
|
+
// We can't deal with <200 or 3xx reponses here (though they may be
|
|
322
|
+
// transparently handled by the delegate). Return a CDP error (not
|
|
323
|
+
// an unsuccesful resource) to the frontend so that it falls back to
|
|
324
|
+
// a direct fetch.
|
|
325
|
+
cdpError = "Handling of status " +
|
|
326
|
+
std::to_string(result->httpStatusCode) + " not implemented.";
|
|
327
|
+
}
|
|
328
|
+
} else {
|
|
329
|
+
assert(false && "Unhandled IO init result type");
|
|
330
|
+
}
|
|
331
|
+
if (cdpError.length() > 0 || !resource.success) {
|
|
332
|
+
// Release and destroy the stream after the calling executor returns.
|
|
333
|
+
// ~Stream will handle cancelling any download in progress.
|
|
334
|
+
if (auto streams = streamsWeak.lock()) {
|
|
335
|
+
streams->erase(streamId);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
frontendChannel(
|
|
339
|
+
cdpError.length()
|
|
340
|
+
? cdp::jsonError(
|
|
341
|
+
requestId, cdp::ErrorCode::InternalError, cdpError)
|
|
342
|
+
: cdp::jsonResult(
|
|
343
|
+
requestId,
|
|
344
|
+
folly::dynamic::object(
|
|
345
|
+
"resource", resource.toDynamic())));
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
// Begin the network request on the platform, passing an executor scoped to
|
|
349
|
+
// a Stream (a NetworkRequestListener), which the implementation will call
|
|
350
|
+
// back into.
|
|
351
|
+
delegate.loadNetworkResource(params, stream->executorFromThis());
|
|
352
|
+
|
|
353
|
+
// Retain the stream only if delegate.loadNetworkResource does not throw.
|
|
354
|
+
streams_->emplace(streamId, stream);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
void NetworkIOAgent::handleIoRead(const cdp::PreparsedRequest& req) {
|
|
358
|
+
long long requestId = req.id;
|
|
359
|
+
if (!req.params.isObject()) {
|
|
360
|
+
frontendChannel_(cdp::jsonError(
|
|
361
|
+
requestId,
|
|
362
|
+
cdp::ErrorCode::InvalidParams,
|
|
363
|
+
"Invalid params: not an object."));
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
if ((req.params.count("handle") == 0u) ||
|
|
367
|
+
!req.params.at("handle").isString()) {
|
|
368
|
+
frontendChannel_(cdp::jsonError(
|
|
369
|
+
requestId,
|
|
370
|
+
cdp::ErrorCode::InvalidParams,
|
|
371
|
+
"Invalid params: handle is missing or not a string."));
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
std::optional<int64_t> size = std::nullopt; // [Windows #13587]
|
|
375
|
+
if ((req.params.count("size") != 0u) && req.params.at("size").isInt()) {
|
|
376
|
+
size = req.params.at("size").asInt();
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
auto streamId = req.params.at("handle").asString();
|
|
380
|
+
auto it = streams_->find(streamId);
|
|
381
|
+
if (it == streams_->end()) {
|
|
382
|
+
frontendChannel_(cdp::jsonError(
|
|
383
|
+
requestId,
|
|
384
|
+
cdp::ErrorCode::InternalError,
|
|
385
|
+
"Stream not found with handle " + streamId));
|
|
386
|
+
return;
|
|
387
|
+
} else {
|
|
388
|
+
it->second->read(
|
|
389
|
+
size ? static_cast<unsigned long>(*size) : DEFAULT_BYTES_PER_READ, // [Windows #13587]
|
|
390
|
+
[requestId,
|
|
391
|
+
frontendChannel = frontendChannel_,
|
|
392
|
+
streamId,
|
|
393
|
+
streamsWeak = std::weak_ptr(streams_)](auto resultOrError) {
|
|
394
|
+
if (auto* error = std::get_if<IOReadError>(&resultOrError)) {
|
|
395
|
+
// NB: Chrome DevTools calls IO.close after a read error, so any
|
|
396
|
+
// continuing download or retained data is cleaned up at that point.
|
|
397
|
+
frontendChannel(cdp::jsonError(
|
|
398
|
+
requestId, cdp::ErrorCode::InternalError, *error));
|
|
399
|
+
} else if (auto* result = std::get_if<IOReadResult>(&resultOrError)) {
|
|
400
|
+
frontendChannel(cdp::jsonResult(requestId, result->toDynamic()));
|
|
401
|
+
} else {
|
|
402
|
+
assert(false && "Unhandled IO read result type");
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
void NetworkIOAgent::handleIoClose(const cdp::PreparsedRequest& req) {
|
|
410
|
+
long long requestId = req.id;
|
|
411
|
+
if (!req.params.isObject()) {
|
|
412
|
+
frontendChannel_(cdp::jsonError(
|
|
413
|
+
requestId,
|
|
414
|
+
cdp::ErrorCode::InvalidParams,
|
|
415
|
+
"Invalid params: not an object."));
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
if ((req.params.count("handle") == 0u) ||
|
|
419
|
+
!req.params.at("handle").isString()) {
|
|
420
|
+
frontendChannel_(cdp::jsonError(
|
|
421
|
+
requestId,
|
|
422
|
+
cdp::ErrorCode::InvalidParams,
|
|
423
|
+
"Invalid params: handle is missing or not a string."));
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
auto streamId = req.params.at("handle").asString();
|
|
427
|
+
|
|
428
|
+
auto it = streams_->find(streamId);
|
|
429
|
+
if (it == streams_->end()) {
|
|
430
|
+
frontendChannel_(cdp::jsonError(
|
|
431
|
+
requestId,
|
|
432
|
+
cdp::ErrorCode::InternalError,
|
|
433
|
+
"Stream not found: " + streamId));
|
|
434
|
+
} else {
|
|
435
|
+
it->second->cancel();
|
|
436
|
+
streams_->erase(it->first);
|
|
437
|
+
frontendChannel_(cdp::jsonResult(requestId));
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
} // namespace facebook::react::jsinspector_modern
|