react-native-windows 0.82.3 → 0.83.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 +2 -7
- package/Libraries/Animated/components/AnimatedFlatList.js +5 -3
- package/Libraries/Animated/components/AnimatedImage.js +4 -3
- package/Libraries/Animated/components/AnimatedSectionList.js +2 -2
- package/Libraries/Animated/components/AnimatedText.js +7 -3
- package/Libraries/Animated/components/AnimatedView.js +3 -2
- package/Libraries/Animated/createAnimatedComponent.js +24 -12
- package/Libraries/Animated/nodes/AnimatedColor.js +26 -10
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +43 -15
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.windows.js +43 -15
- package/Libraries/Components/ActivityIndicator/ActivityIndicator.d.ts +2 -2
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.d.ts +2 -2
- package/Libraries/Components/Glyph/Glyph.js +4 -1
- package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.d.ts +2 -2
- package/Libraries/Components/RefreshControl/RefreshControl.d.ts +3 -3
- package/Libraries/Components/SafeAreaView/SafeAreaView.d.ts +2 -2
- package/Libraries/Components/ScrollView/ScrollView.js +1 -0
- package/Libraries/Components/ScrollView/ScrollView.windows.js +1 -0
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +6 -6
- package/Libraries/Components/Switch/Switch.d.ts +2 -2
- package/Libraries/Components/Switch/Switch.windows.js +1 -1
- package/Libraries/Components/TextInput/TextInput.d.ts +2 -5
- package/Libraries/Components/TextInput/TextInput.js +6 -0
- package/Libraries/Components/TextInput/TextInput.windows.js +6 -0
- package/Libraries/Components/Touchable/TouchableBounce.js +7 -7
- package/Libraries/Components/Touchable/TouchableBounce.windows.js +7 -7
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +1 -1
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +19 -1
- package/Libraries/Components/View/View.d.ts +2 -2
- package/Libraries/Components/View/View.windows.js +0 -1
- package/Libraries/Components/View/ViewNativeComponent.js +13 -1
- package/Libraries/Core/ReactNativeVersion.js +3 -3
- package/Libraries/Core/setUpPerformance.js +2 -0
- package/Libraries/Debugging/DebuggingOverlay.js +14 -14
- package/Libraries/Debugging/DebuggingOverlayRegistry.js +8 -2
- package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +5 -2
- package/Libraries/Image/Image.d.ts +3 -3
- package/Libraries/Image/ImageInjection.js +3 -6
- package/Libraries/Image/ImageTypes.flow.js +3 -7
- package/Libraries/Lists/FlatList.js +8 -8
- package/Libraries/Lists/SectionList.d.ts +5 -1
- package/Libraries/Lists/ViewabilityHelper.js +1 -1
- package/Libraries/Lists/VirtualizedList.js +1 -0
- package/Libraries/LogBox/UI/AnsiHighlight.js +4 -1
- package/Libraries/NativeComponent/BaseViewConfig.android.js +11 -2
- package/Libraries/NativeComponent/NativeComponentRegistry.d.ts +98 -0
- package/Libraries/NativeComponent/NativeComponentRegistry.js +2 -0
- package/Libraries/NativeComponent/NativeComponentRegistryUnstable.js +3 -1
- package/Libraries/NativeComponent/ViewConfigIgnore.windows.js +45 -0
- package/Libraries/Network/RCTNetworking.android.js +3 -1
- package/Libraries/Network/RCTNetworking.ios.js +3 -0
- package/Libraries/Network/RCTNetworking.windows.js +3 -0
- package/Libraries/Network/XMLHttpRequest.js +1 -41
- package/Libraries/Pressability/usePressability.js +14 -3
- package/Libraries/ReactNative/PaperUIManager.windows.js +3 -3
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +20 -82
- package/Libraries/ReactNative/getNativeComponentAttributes.js +12 -0
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +6759 -4478
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +3169 -3119
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +4732 -3535
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +6646 -4070
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +3136 -2825
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +4761 -3312
- package/Libraries/Renderer/shims/ReactNative.js +3 -1
- package/Libraries/Renderer/shims/ReactNativeTypes.js +2 -1
- package/Libraries/Renderer/shims/ReactNativeTypes.windows.js +2 -1
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +1 -1
- package/Libraries/StyleSheet/StyleSheetTypes.js +44 -0
- package/Libraries/StyleSheet/processBackgroundPosition.js +284 -0
- package/Libraries/StyleSheet/processBackgroundRepeat.js +105 -0
- package/Libraries/StyleSheet/processBackgroundSize.js +104 -0
- package/Libraries/Text/Text.d.ts +2 -2
- package/Libraries/Text/TextNativeComponent.js +10 -0
- package/Libraries/TurboModule/TurboModuleRegistry.js +3 -9
- package/Libraries/Utilities/DevLoadingView.js +14 -6
- package/Libraries/Utilities/HMRClient.js +13 -5
- package/Microsoft.ReactNative/CompositionComponentView.idl +2 -0
- package/Microsoft.ReactNative/CompositionHwndHost.idl +1 -0
- package/Microsoft.ReactNative/Fabric/ComponentView.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/ComponentView.h +1 -1
- package/Microsoft.ReactNative/Fabric/Composition/CompositionHwndHost.cpp +10 -40
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +3 -80
- package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp +45 -12
- package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h +8 -0
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +61 -74
- package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.h +4 -0
- package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +1 -0
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +4 -3
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +2 -1
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeWindow.cpp +245 -0
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeWindow.h +80 -0
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentDescriptor.h +20 -36
- package/Microsoft.ReactNative/Fabric/Composition/UriImageManager.cpp +5 -0
- package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +1 -0
- package/Microsoft.ReactNative/Modules/ImageViewManagerModule.cpp +1 -1
- package/Microsoft.ReactNative/Modules/LogBoxModule.cpp +20 -94
- package/Microsoft.ReactNative/Modules/LogBoxModule.h +1 -3
- package/Microsoft.ReactNative/ReactNativeAppBuilder.cpp +0 -41
- package/Microsoft.ReactNative/ReactNativeAppBuilder.idl +0 -11
- package/Microsoft.ReactNative/ReactNativeIsland.idl +2 -3
- package/Microsoft.ReactNative/ReactNativeWin32App.cpp +31 -101
- package/Microsoft.ReactNative/ReactNativeWin32App.h +2 -13
- package/Microsoft.ReactNative/ReactNativeWindow.idl +44 -0
- package/Microsoft.ReactNative.Cxx/AutoDraw.h +9 -1
- package/Microsoft.ReactNative.Cxx/ReactCommon/CallInvoker.h +13 -16
- package/Microsoft.ReactNative.Cxx/ReactCommon/TurboModule.h +24 -36
- package/Microsoft.ReactNative.Cxx/ReactCommon/TurboModuleUtils.h +5 -8
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/AString.h +8 -6
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Array.h +32 -49
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Base.h +27 -76
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Bool.h +4 -2
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/CallbackWrapper.h +19 -18
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Class.h +25 -48
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Convert.h +38 -31
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Error.h +11 -6
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/EventEmitter.h +47 -45
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Function.h +69 -89
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/HighResTimeStamp.h +8 -8
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/LongLivedObject.h +6 -6
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Number.h +16 -8
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Object.h +17 -24
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Promise.h +17 -17
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Value.h +20 -29
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/debug/react_native_assert.h +2 -7
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/timing/primitives.h +127 -115
- package/PropertySheets/Generated/PackageVersion.g.props +4 -4
- package/PropertySheets/Warnings.props +2 -1
- package/ReactCommon/ReactCommon.vcxproj +11 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/CxxNativeModule.cpp +2 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/Instance.cpp +4 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp +4 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSIndexedRAMBundle.cpp +4 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/MethodCall.cpp +4 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ModuleRegistry.cpp +5 -3
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/NativeToJsBridge.cpp +4 -4
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/RAMBundleRegistry.cpp +6 -4
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ReactMarker.cpp +2 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/TraceSection.h +25 -35
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/test/testlib.cpp +86 -67
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsiexecutor/jsireact/JSIExecutor.cpp +15 -8
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsiexecutor/jsireact/JSINativeModules.cpp +4 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.cpp +84 -68
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.h +31 -35
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/Utf8.h +4 -5
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/network/HttpUtils.cpp +2 -1
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModule.h +24 -36
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/dom/NativeDOM.h +28 -66
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/webperformance/NativePerformance.cpp +5 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp +3 -3
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/image/conversions.h +8 -4
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/ParagraphShadowNode.cpp +19 -16
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/platform/android/react/renderer/components/text/ParagraphState.h +8 -9
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/AccessibilityPrimitives.h +25 -95
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/BaseViewProps.cpp +36 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/accessibilityPropsConversions.h +85 -42
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventDispatcher.cpp +2 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventQueueProcessor.cpp +2 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/imagemanager/primitives.h +25 -31
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/uimanager/UIManager.cpp +19 -5
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +16 -1
- package/Scripts/Tfs/Layout-Desktop-Headers.ps1 +1 -15
- package/Scripts/creaternwapp.cmd +1 -1
- package/Scripts/perf/compare-results.js +357 -0
- package/Scripts/perf/create-perf-test.js +343 -0
- package/Scripts/perf/post-pr-comment.js +210 -0
- package/Shared/Hermes/HermesRuntimeTargetDelegate.cpp +8 -0
- package/Shared/Hermes/HermesRuntimeTargetDelegate.h +3 -0
- package/Shared/Shared.vcxitems +15 -3
- package/Shared/Shared.vcxitems.filters +11 -3
- package/codegen/NativeIntersectionObserverSpec.g.h +2 -0
- package/codegen/NativeNetworkingIOSSpec.g.h +2 -0
- package/codegen/NativePerformanceSpec.g.h +6 -0
- package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +229 -139
- package/codegen/react/components/rnwcore/ActivityIndicatorView.g.h +2 -1
- package/codegen/react/components/rnwcore/AndroidDrawerLayout.g.h +42 -25
- package/codegen/react/components/rnwcore/AndroidHorizontalScrollContentView.g.h +2 -1
- package/codegen/react/components/rnwcore/AndroidProgressBar.g.h +2 -1
- package/codegen/react/components/rnwcore/AndroidSwipeRefreshLayout.g.h +11 -6
- package/codegen/react/components/rnwcore/AndroidSwitch.g.h +11 -6
- package/codegen/react/components/rnwcore/DebuggingOverlay.g.h +1 -0
- package/codegen/react/components/rnwcore/InputAccessory.g.h +2 -1
- package/codegen/react/components/rnwcore/ModalHostView.g.h +40 -23
- package/codegen/react/components/rnwcore/Props.cpp +6 -1
- package/codegen/react/components/rnwcore/Props.h +1 -0
- package/codegen/react/components/rnwcore/PullToRefreshView.g.h +11 -6
- package/codegen/react/components/rnwcore/SafeAreaView.g.h +1 -0
- package/codegen/react/components/rnwcore/Switch.g.h +11 -6
- package/codegen/react/components/rnwcore/UnimplementedNativeView.g.h +2 -1
- package/codegen/react/components/rnwcore/VirtualView.g.h +41 -8
- package/codegen/react/components/rnwcore/VirtualViewExperimental.g.h +45 -8
- package/codegen/rnwcoreJSI.h +3973 -6059
- package/index.js +6 -0
- package/index.windows.js +6 -0
- package/jest/mockComponent.js +6 -6
- package/jest/setup.js +15 -10
- package/package.json +27 -27
- package/src/private/components/virtualview/VirtualView.js +22 -27
- package/src/private/components/virtualview/VirtualViewExperimentalNativeComponent.js +6 -0
- package/src/private/featureflags/ReactNativeFeatureFlags.js +100 -19
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +18 -3
- package/src/private/setup/setUpDefaultReactNativeEnvironment.js +6 -0
- package/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js +1 -1
- package/src/private/specs_DEPRECATED/modules/NativeNetworkingIOS.js +1 -0
- package/src/private/webapis/dom/nodes/ReactNativeElement.js +12 -2
- package/src/private/webapis/intersectionobserver/IntersectionObserver.js +76 -15
- package/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +1 -0
- package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +1 -0
- package/src/private/webapis/performance/ResourceTiming.js +31 -4
- package/src/private/webapis/performance/internals/RawPerformanceEntry.js +4 -1
- package/src/private/webapis/performance/specs/NativePerformance.js +3 -0
- package/stubs/double-conversion/double-conversion.h +5 -0
- package/templates/cpp-app/template.config.js +1 -1
- package/templates/cpp-app/windows/MyApp/MyApp.vcxproj +1 -1
- package/templates/cpp-lib/template.config.js +1 -1
- package/templates/cpp-lib/windows/MyLib/MyLib.vcxproj +1 -1
- package/types/index.d.ts +1 -0
- package/types/public/ReactNativeTypes.d.ts +115 -2
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +0 -152
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/conversions.h +0 -1574
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/ShadowNode.cpp +0 -528
- package/Scripts/OpenSSL.nuspec +0 -39
- package/Scripts/OpenSSL.targets +0 -36
- package/codegen/rnwcoreJSI-generated.cpp +0 -3470
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
|
|
8
9
|
#if _MSC_VER
|
|
9
10
|
#pragma warning(push)
|
|
10
11
|
#pragma warning(disable : 4996) // deprecated APIs
|
|
@@ -29,7 +30,7 @@ using namespace facebook::jsi;
|
|
|
29
30
|
|
|
30
31
|
namespace facebook::react {
|
|
31
32
|
|
|
32
|
-
#ifndef
|
|
33
|
+
#ifndef RCT_REMOVE_LEGACY_ARCH
|
|
33
34
|
|
|
34
35
|
class JSIExecutor::NativeModuleProxy : public jsi::HostObject {
|
|
35
36
|
public:
|
|
@@ -49,7 +50,10 @@ class JSIExecutor::NativeModuleProxy : public jsi::HostObject {
|
|
|
49
50
|
return nativeModules->getModule(rt, name);
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
void set(
|
|
53
|
+
void set(
|
|
54
|
+
Runtime& /*unused*/,
|
|
55
|
+
const PropNameID& /*name*/,
|
|
56
|
+
const Value& /*value*/) override {
|
|
53
57
|
throw std::runtime_error(
|
|
54
58
|
"Unable to put on NativeModules: Operation unsupported");
|
|
55
59
|
}
|
|
@@ -75,8 +79,9 @@ JSIExecutor::JSIExecutor(
|
|
|
75
79
|
RuntimeInstaller runtimeInstaller)
|
|
76
80
|
: runtime_(runtime),
|
|
77
81
|
delegate_(delegate),
|
|
78
|
-
nativeModules_(
|
|
79
|
-
|
|
82
|
+
nativeModules_(
|
|
83
|
+
std::make_shared<JSINativeModules>(
|
|
84
|
+
delegate ? delegate->getModuleRegistry() : nullptr)),
|
|
80
85
|
moduleRegistry_(delegate ? delegate->getModuleRegistry() : nullptr),
|
|
81
86
|
scopedTimeoutInvoker_(scopedTimeoutInvoker),
|
|
82
87
|
runtimeInstaller_(runtimeInstaller) {
|
|
@@ -269,8 +274,9 @@ void JSIExecutor::invokeCallback(
|
|
|
269
274
|
ret = invokeCallbackAndReturnFlushedQueue_->call(
|
|
270
275
|
*runtime_, callbackId, valueFromDynamic(*runtime_, arguments));
|
|
271
276
|
} catch (...) {
|
|
272
|
-
std::throw_with_nested(
|
|
273
|
-
|
|
277
|
+
std::throw_with_nested(
|
|
278
|
+
std::runtime_error(
|
|
279
|
+
"Error invoking callback " + std::to_string(callbackId)));
|
|
274
280
|
}
|
|
275
281
|
|
|
276
282
|
callNativeModules(ret, true);
|
|
@@ -527,7 +533,7 @@ Value JSIExecutor::globalEvalWithSourceUrl(const Value* args, size_t count) {
|
|
|
527
533
|
std::make_unique<StringBuffer>(std::move(code)), url);
|
|
528
534
|
}
|
|
529
535
|
|
|
530
|
-
#else //
|
|
536
|
+
#else // RCT_REMOVE_LEGACY_ARCH
|
|
531
537
|
|
|
532
538
|
JSIExecutor::JSIExecutor(
|
|
533
539
|
std::shared_ptr<jsi::Runtime> runtime,
|
|
@@ -574,7 +580,7 @@ void JSIExecutor::handleMemoryPressure(int pressureLevel) {}
|
|
|
574
580
|
|
|
575
581
|
void JSIExecutor::flush() {}
|
|
576
582
|
|
|
577
|
-
#endif //
|
|
583
|
+
#endif // RCT_REMOVE_LEGACY_ARCH
|
|
578
584
|
|
|
579
585
|
void bindNativeLogger(Runtime& runtime, Logger logger) {
|
|
580
586
|
runtime.global().setProperty(
|
|
@@ -617,6 +623,7 @@ void bindNativePerformanceNow(Runtime& runtime) {
|
|
|
617
623
|
}
|
|
618
624
|
|
|
619
625
|
} // namespace facebook::react
|
|
626
|
+
|
|
620
627
|
#if _MSC_VER
|
|
621
628
|
#pragma warning(pop)
|
|
622
629
|
#endif
|
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
|
|
8
9
|
#if _MSC_VER
|
|
9
10
|
#pragma warning(push)
|
|
10
11
|
#pragma warning(disable : 4996) // deprecated APIs
|
|
11
12
|
#endif
|
|
12
13
|
#include "jsireact/JSINativeModules.h"
|
|
13
14
|
|
|
14
|
-
#ifndef
|
|
15
|
+
#ifndef RCT_REMOVE_LEGACY_ARCH
|
|
15
16
|
|
|
16
17
|
#include <reactperflogger/BridgeNativeModulePerfLogger.h>
|
|
17
18
|
|
|
@@ -115,7 +116,8 @@ std::optional<Object> JSINativeModules::createModule(
|
|
|
115
116
|
|
|
116
117
|
} // namespace facebook::react
|
|
117
118
|
|
|
118
|
-
#endif //
|
|
119
|
+
#endif // RCT_REMOVE_LEGACY_ARCH
|
|
120
|
+
|
|
119
121
|
#if _MSC_VER
|
|
120
122
|
#pragma warning(pop)
|
|
121
123
|
#endif
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
#include "Base64.h"
|
|
12
12
|
#include "Utf8.h"
|
|
13
13
|
|
|
14
|
-
#include <jsinspector-modern/network/
|
|
14
|
+
#include <jsinspector-modern/network/NetworkHandler.h>
|
|
15
15
|
|
|
16
16
|
#include <sstream>
|
|
17
17
|
#include <tuple>
|
|
@@ -140,8 +140,10 @@ class Stream : public NetworkRequestListener,
|
|
|
140
140
|
// called with it.
|
|
141
141
|
if (initCb_) {
|
|
142
142
|
auto cb = std::move(initCb_);
|
|
143
|
-
(*cb)(
|
|
144
|
-
|
|
143
|
+
(*cb)(InitStreamResult{
|
|
144
|
+
.httpStatusCode = httpStatusCode,
|
|
145
|
+
.headers = headers,
|
|
146
|
+
.stream = this->shared_from_this()});
|
|
145
147
|
}
|
|
146
148
|
}
|
|
147
149
|
|
|
@@ -275,21 +277,21 @@ bool NetworkIOAgent::handleRequest(
|
|
|
275
277
|
}
|
|
276
278
|
|
|
277
279
|
if (InspectorFlags::getInstance().getNetworkInspectionEnabled()) {
|
|
278
|
-
auto&
|
|
280
|
+
auto& networkHandler = NetworkHandler::getInstance();
|
|
279
281
|
|
|
280
282
|
// @cdp Network.enable support is experimental.
|
|
281
283
|
if (req.method == "Network.enable") {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
return
|
|
284
|
+
networkHandler.setFrontendChannel(frontendChannel_);
|
|
285
|
+
networkHandler.enable();
|
|
286
|
+
// NOTE: Domain enable/disable responses are sent by HostAgent.
|
|
287
|
+
return false;
|
|
286
288
|
}
|
|
287
289
|
|
|
288
290
|
// @cdp Network.disable support is experimental.
|
|
289
291
|
if (req.method == "Network.disable") {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
return
|
|
292
|
+
networkHandler.disable();
|
|
293
|
+
// NOTE: Domain enable/disable responses are sent by HostAgent.
|
|
294
|
+
return false;
|
|
293
295
|
}
|
|
294
296
|
|
|
295
297
|
// @cdp Network.getResponseBody support is experimental.
|
|
@@ -310,17 +312,19 @@ void NetworkIOAgent::handleLoadNetworkResource(
|
|
|
310
312
|
LoadNetworkResourceRequest params;
|
|
311
313
|
|
|
312
314
|
if (!req.params.isObject()) {
|
|
313
|
-
frontendChannel_(
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
315
|
+
frontendChannel_(
|
|
316
|
+
cdp::jsonError(
|
|
317
|
+
req.id,
|
|
318
|
+
cdp::ErrorCode::InvalidParams,
|
|
319
|
+
"Invalid params: not an object."));
|
|
317
320
|
return;
|
|
318
321
|
}
|
|
319
322
|
if ((req.params.count("url") == 0u) || !req.params.at("url").isString()) {
|
|
320
|
-
frontendChannel_(
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
323
|
+
frontendChannel_(
|
|
324
|
+
cdp::jsonError(
|
|
325
|
+
requestId,
|
|
326
|
+
cdp::ErrorCode::InvalidParams,
|
|
327
|
+
"Invalid params: url is missing or not a string."));
|
|
324
328
|
return;
|
|
325
329
|
} else {
|
|
326
330
|
params.url = req.params.at("url").asString();
|
|
@@ -393,18 +397,20 @@ void NetworkIOAgent::handleLoadNetworkResource(
|
|
|
393
397
|
void NetworkIOAgent::handleIoRead(const cdp::PreparsedRequest& req) {
|
|
394
398
|
long long requestId = req.id;
|
|
395
399
|
if (!req.params.isObject()) {
|
|
396
|
-
frontendChannel_(
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
+
frontendChannel_(
|
|
401
|
+
cdp::jsonError(
|
|
402
|
+
requestId,
|
|
403
|
+
cdp::ErrorCode::InvalidParams,
|
|
404
|
+
"Invalid params: not an object."));
|
|
400
405
|
return;
|
|
401
406
|
}
|
|
402
407
|
if ((req.params.count("handle") == 0u) ||
|
|
403
408
|
!req.params.at("handle").isString()) {
|
|
404
|
-
frontendChannel_(
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
409
|
+
frontendChannel_(
|
|
410
|
+
cdp::jsonError(
|
|
411
|
+
requestId,
|
|
412
|
+
cdp::ErrorCode::InvalidParams,
|
|
413
|
+
"Invalid params: handle is missing or not a string."));
|
|
408
414
|
return;
|
|
409
415
|
}
|
|
410
416
|
std::optional<int64_t> size = std::nullopt;
|
|
@@ -412,10 +418,11 @@ void NetworkIOAgent::handleIoRead(const cdp::PreparsedRequest& req) {
|
|
|
412
418
|
size = req.params.at("size").asInt();
|
|
413
419
|
|
|
414
420
|
if (size > MAX_BYTES_PER_READ) {
|
|
415
|
-
frontendChannel_(
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
421
|
+
frontendChannel_(
|
|
422
|
+
cdp::jsonError(
|
|
423
|
+
requestId,
|
|
424
|
+
cdp::ErrorCode::InvalidParams,
|
|
425
|
+
"Invalid params: size cannot be greater than 10MB."));
|
|
419
426
|
return;
|
|
420
427
|
}
|
|
421
428
|
}
|
|
@@ -423,10 +430,11 @@ void NetworkIOAgent::handleIoRead(const cdp::PreparsedRequest& req) {
|
|
|
423
430
|
auto streamId = req.params.at("handle").asString();
|
|
424
431
|
auto it = streams_->find(streamId);
|
|
425
432
|
if (it == streams_->end()) {
|
|
426
|
-
frontendChannel_(
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
433
|
+
frontendChannel_(
|
|
434
|
+
cdp::jsonError(
|
|
435
|
+
requestId,
|
|
436
|
+
cdp::ErrorCode::InternalError,
|
|
437
|
+
"Stream not found with handle " + streamId));
|
|
430
438
|
return;
|
|
431
439
|
} else {
|
|
432
440
|
it->second->read(
|
|
@@ -438,8 +446,9 @@ void NetworkIOAgent::handleIoRead(const cdp::PreparsedRequest& req) {
|
|
|
438
446
|
if (auto* error = std::get_if<IOReadError>(&resultOrError)) {
|
|
439
447
|
// NB: Chrome DevTools calls IO.close after a read error, so any
|
|
440
448
|
// continuing download or retained data is cleaned up at that point.
|
|
441
|
-
frontendChannel(
|
|
442
|
-
|
|
449
|
+
frontendChannel(
|
|
450
|
+
cdp::jsonError(
|
|
451
|
+
requestId, cdp::ErrorCode::InternalError, *error));
|
|
443
452
|
} else if (auto* result = std::get_if<IOReadResult>(&resultOrError)) {
|
|
444
453
|
frontendChannel(cdp::jsonResult(requestId, result->toDynamic()));
|
|
445
454
|
} else {
|
|
@@ -453,28 +462,31 @@ void NetworkIOAgent::handleIoRead(const cdp::PreparsedRequest& req) {
|
|
|
453
462
|
void NetworkIOAgent::handleIoClose(const cdp::PreparsedRequest& req) {
|
|
454
463
|
long long requestId = req.id;
|
|
455
464
|
if (!req.params.isObject()) {
|
|
456
|
-
frontendChannel_(
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
465
|
+
frontendChannel_(
|
|
466
|
+
cdp::jsonError(
|
|
467
|
+
requestId,
|
|
468
|
+
cdp::ErrorCode::InvalidParams,
|
|
469
|
+
"Invalid params: not an object."));
|
|
460
470
|
return;
|
|
461
471
|
}
|
|
462
472
|
if ((req.params.count("handle") == 0u) ||
|
|
463
473
|
!req.params.at("handle").isString()) {
|
|
464
|
-
frontendChannel_(
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
474
|
+
frontendChannel_(
|
|
475
|
+
cdp::jsonError(
|
|
476
|
+
requestId,
|
|
477
|
+
cdp::ErrorCode::InvalidParams,
|
|
478
|
+
"Invalid params: handle is missing or not a string."));
|
|
468
479
|
return;
|
|
469
480
|
}
|
|
470
481
|
auto streamId = req.params.at("handle").asString();
|
|
471
482
|
|
|
472
483
|
auto it = streams_->find(streamId);
|
|
473
484
|
if (it == streams_->end()) {
|
|
474
|
-
frontendChannel_(
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
485
|
+
frontendChannel_(
|
|
486
|
+
cdp::jsonError(
|
|
487
|
+
requestId,
|
|
488
|
+
cdp::ErrorCode::InternalError,
|
|
489
|
+
"Stream not found: " + streamId));
|
|
478
490
|
} else {
|
|
479
491
|
it->second->cancel();
|
|
480
492
|
streams_->erase(it->first);
|
|
@@ -485,39 +497,43 @@ void NetworkIOAgent::handleIoClose(const cdp::PreparsedRequest& req) {
|
|
|
485
497
|
void NetworkIOAgent::handleGetResponseBody(const cdp::PreparsedRequest& req) {
|
|
486
498
|
long long requestId = req.id;
|
|
487
499
|
if (!req.params.isObject()) {
|
|
488
|
-
frontendChannel_(
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
500
|
+
frontendChannel_(
|
|
501
|
+
cdp::jsonError(
|
|
502
|
+
requestId,
|
|
503
|
+
cdp::ErrorCode::InvalidParams,
|
|
504
|
+
"Invalid params: not an object."));
|
|
492
505
|
return;
|
|
493
506
|
}
|
|
494
507
|
if ((req.params.count("requestId") == 0u) ||
|
|
495
508
|
!req.params.at("requestId").isString()) {
|
|
496
|
-
frontendChannel_(
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
509
|
+
frontendChannel_(
|
|
510
|
+
cdp::jsonError(
|
|
511
|
+
requestId,
|
|
512
|
+
cdp::ErrorCode::InvalidParams,
|
|
513
|
+
"Invalid params: requestId is missing or not a string."));
|
|
500
514
|
return;
|
|
501
515
|
}
|
|
502
516
|
|
|
503
|
-
auto&
|
|
517
|
+
auto& networkHandler = NetworkHandler::getInstance();
|
|
504
518
|
|
|
505
|
-
if (!
|
|
506
|
-
frontendChannel_(
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
519
|
+
if (!networkHandler.isEnabled()) {
|
|
520
|
+
frontendChannel_(
|
|
521
|
+
cdp::jsonError(
|
|
522
|
+
requestId,
|
|
523
|
+
cdp::ErrorCode::InvalidRequest,
|
|
524
|
+
"Invalid request: The \"Network\" domain is not enabled."));
|
|
510
525
|
return;
|
|
511
526
|
}
|
|
512
527
|
|
|
513
528
|
auto storedResponse =
|
|
514
|
-
|
|
529
|
+
networkHandler.getResponseBody(req.params.at("requestId").asString());
|
|
515
530
|
|
|
516
531
|
if (!storedResponse) {
|
|
517
|
-
frontendChannel_(
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
532
|
+
frontendChannel_(
|
|
533
|
+
cdp::jsonError(
|
|
534
|
+
requestId,
|
|
535
|
+
cdp::ErrorCode::InternalError,
|
|
536
|
+
"Internal error: Could not retrieve response body for the given requestId."));
|
|
521
537
|
return;
|
|
522
538
|
}
|
|
523
539
|
|
|
@@ -40,11 +40,12 @@ struct ReadStreamParams {
|
|
|
40
40
|
|
|
41
41
|
struct NetworkResource {
|
|
42
42
|
bool success{};
|
|
43
|
-
std::optional<std::string> stream;
|
|
44
|
-
std::optional<uint32_t> httpStatusCode;
|
|
45
|
-
std::optional<std::string> netErrorName;
|
|
46
|
-
std::optional<Headers> headers;
|
|
47
|
-
folly::dynamic toDynamic() const
|
|
43
|
+
std::optional<std::string> stream{};
|
|
44
|
+
std::optional<uint32_t> httpStatusCode{};
|
|
45
|
+
std::optional<std::string> netErrorName{};
|
|
46
|
+
std::optional<Headers> headers{};
|
|
47
|
+
folly::dynamic toDynamic() const
|
|
48
|
+
{
|
|
48
49
|
auto dynamicResource = folly::dynamic::object("success", success);
|
|
49
50
|
|
|
50
51
|
if (success) { // stream IFF successful
|
|
@@ -65,7 +66,7 @@ struct NetworkResource {
|
|
|
65
66
|
|
|
66
67
|
if (headers) { // Guaranteed if successful
|
|
67
68
|
auto dynamicHeaders = folly::dynamic::object();
|
|
68
|
-
for (const auto&
|
|
69
|
+
for (const auto &pair : *headers) {
|
|
69
70
|
dynamicHeaders(pair.first, pair.second);
|
|
70
71
|
}
|
|
71
72
|
dynamicResource("headers", std::move(dynamicHeaders));
|
|
@@ -80,7 +81,8 @@ struct IOReadResult {
|
|
|
80
81
|
std::string data;
|
|
81
82
|
bool eof;
|
|
82
83
|
bool base64Encoded;
|
|
83
|
-
folly::dynamic toDynamic() const
|
|
84
|
+
folly::dynamic toDynamic() const
|
|
85
|
+
{
|
|
84
86
|
auto obj = folly::dynamic::object("data", data);
|
|
85
87
|
obj("eof", eof);
|
|
86
88
|
obj("base64Encoded", base64Encoded);
|
|
@@ -91,7 +93,8 @@ struct IOReadResult {
|
|
|
91
93
|
struct GetResponseBodyResult {
|
|
92
94
|
std::string body;
|
|
93
95
|
bool base64Encoded;
|
|
94
|
-
folly::dynamic toDynamic() const
|
|
96
|
+
folly::dynamic toDynamic() const
|
|
97
|
+
{
|
|
95
98
|
folly::dynamic params = folly::dynamic::object;
|
|
96
99
|
params["body"] = body;
|
|
97
100
|
params["base64Encoded"] = base64Encoded;
|
|
@@ -106,11 +109,10 @@ struct GetResponseBodyResult {
|
|
|
106
109
|
class NetworkRequestListener {
|
|
107
110
|
public:
|
|
108
111
|
NetworkRequestListener() = default;
|
|
109
|
-
NetworkRequestListener(const NetworkRequestListener&) = delete;
|
|
110
|
-
NetworkRequestListener&
|
|
111
|
-
NetworkRequestListener(NetworkRequestListener&&) noexcept = default;
|
|
112
|
-
NetworkRequestListener&
|
|
113
|
-
default;
|
|
112
|
+
NetworkRequestListener(const NetworkRequestListener &) = delete;
|
|
113
|
+
NetworkRequestListener &operator=(const NetworkRequestListener &) = delete;
|
|
114
|
+
NetworkRequestListener(NetworkRequestListener &&) noexcept = default;
|
|
115
|
+
NetworkRequestListener &operator=(NetworkRequestListener &&) noexcept = default;
|
|
114
116
|
virtual ~NetworkRequestListener() = default;
|
|
115
117
|
|
|
116
118
|
/**
|
|
@@ -120,7 +122,7 @@ class NetworkRequestListener {
|
|
|
120
122
|
* \param httpStatusCode The HTTP status code received.
|
|
121
123
|
* \param headers Response headers as an unordered_map.
|
|
122
124
|
*/
|
|
123
|
-
virtual void onHeaders(uint32_t httpStatusCode, const Headers&
|
|
125
|
+
virtual void onHeaders(uint32_t httpStatusCode, const Headers &headers) = 0;
|
|
124
126
|
|
|
125
127
|
/**
|
|
126
128
|
* To be called by the delegate on receipt of data chunks.
|
|
@@ -137,7 +139,7 @@ class NetworkRequestListener {
|
|
|
137
139
|
* were not yet received), or as a CDP error in response to a subsequent
|
|
138
140
|
* `IO.read`.
|
|
139
141
|
*/
|
|
140
|
-
virtual void onError(const std::string&
|
|
142
|
+
virtual void onError(const std::string &message) = 0;
|
|
141
143
|
|
|
142
144
|
/**
|
|
143
145
|
* To be called by the delegate on successful completion of the request.
|
|
@@ -163,12 +165,10 @@ class NetworkRequestListener {
|
|
|
163
165
|
class LoadNetworkResourceDelegate {
|
|
164
166
|
public:
|
|
165
167
|
LoadNetworkResourceDelegate() = default;
|
|
166
|
-
LoadNetworkResourceDelegate(const LoadNetworkResourceDelegate&) = delete;
|
|
167
|
-
LoadNetworkResourceDelegate&
|
|
168
|
-
|
|
169
|
-
LoadNetworkResourceDelegate(LoadNetworkResourceDelegate&&) noexcept = delete;
|
|
170
|
-
LoadNetworkResourceDelegate& operator=(
|
|
171
|
-
LoadNetworkResourceDelegate&&) noexcept = delete;
|
|
168
|
+
LoadNetworkResourceDelegate(const LoadNetworkResourceDelegate &) = delete;
|
|
169
|
+
LoadNetworkResourceDelegate &operator=(const LoadNetworkResourceDelegate &) = delete;
|
|
170
|
+
LoadNetworkResourceDelegate(LoadNetworkResourceDelegate &&) noexcept = delete;
|
|
171
|
+
LoadNetworkResourceDelegate &operator=(LoadNetworkResourceDelegate &&) noexcept = delete;
|
|
172
172
|
virtual ~LoadNetworkResourceDelegate() = default;
|
|
173
173
|
|
|
174
174
|
/**
|
|
@@ -185,7 +185,7 @@ class LoadNetworkResourceDelegate {
|
|
|
185
185
|
* called to abort any in-flight network operation that is no longer needed.
|
|
186
186
|
*/
|
|
187
187
|
virtual void loadNetworkResource(
|
|
188
|
-
[[maybe_unused]] const LoadNetworkResourceRequest&
|
|
188
|
+
[[maybe_unused]] const LoadNetworkResourceRequest ¶ms,
|
|
189
189
|
[[maybe_unused]] ScopedExecutor<NetworkRequestListener> executor) = 0;
|
|
190
190
|
};
|
|
191
191
|
|
|
@@ -207,18 +207,16 @@ class NetworkIOAgent {
|
|
|
207
207
|
* processing incoming data or other events from network operations.
|
|
208
208
|
*/
|
|
209
209
|
NetworkIOAgent(FrontendChannel frontendChannel, VoidExecutor executor)
|
|
210
|
-
: frontendChannel_(frontendChannel),
|
|
211
|
-
|
|
212
|
-
|
|
210
|
+
: frontendChannel_(frontendChannel), executor_(executor), streams_(std::make_shared<StreamsMap>())
|
|
211
|
+
{
|
|
212
|
+
}
|
|
213
213
|
|
|
214
214
|
/**
|
|
215
215
|
* Handle a CDP request. The response will be sent over the provided
|
|
216
216
|
* \c FrontendChannel synchronously or asynchronously.
|
|
217
217
|
* \param req The parsed request.
|
|
218
218
|
*/
|
|
219
|
-
bool handleRequest(
|
|
220
|
-
const cdp::PreparsedRequest& req,
|
|
221
|
-
LoadNetworkResourceDelegate& delegate);
|
|
219
|
+
bool handleRequest(const cdp::PreparsedRequest &req, LoadNetworkResourceDelegate &delegate);
|
|
222
220
|
|
|
223
221
|
private:
|
|
224
222
|
/**
|
|
@@ -255,26 +253,24 @@ class NetworkIOAgent {
|
|
|
255
253
|
* Does not catch exceptions thrown by the delegate (such as
|
|
256
254
|
* NotImplementedException).
|
|
257
255
|
*/
|
|
258
|
-
void handleLoadNetworkResource(
|
|
259
|
-
const cdp::PreparsedRequest& req,
|
|
260
|
-
LoadNetworkResourceDelegate& delegate);
|
|
256
|
+
void handleLoadNetworkResource(const cdp::PreparsedRequest &req, LoadNetworkResourceDelegate &delegate);
|
|
261
257
|
|
|
262
258
|
/**
|
|
263
259
|
* Handle an IO.read CDP request. Emit a chunk of data from the stream, once
|
|
264
260
|
* enough has been downloaded, or report an error.
|
|
265
261
|
*/
|
|
266
|
-
void handleIoRead(const cdp::PreparsedRequest&
|
|
262
|
+
void handleIoRead(const cdp::PreparsedRequest &req);
|
|
267
263
|
|
|
268
264
|
/**
|
|
269
265
|
* Handle an IO.close CDP request. Safely aborts any in-flight request.
|
|
270
266
|
* Reports CDP ok if the stream is found, or a CDP error if not.
|
|
271
267
|
*/
|
|
272
|
-
void handleIoClose(const cdp::PreparsedRequest&
|
|
268
|
+
void handleIoClose(const cdp::PreparsedRequest &req);
|
|
273
269
|
|
|
274
270
|
/**
|
|
275
271
|
* Handle a Network.getResponseBody CDP request.
|
|
276
272
|
*/
|
|
277
|
-
void handleGetResponseBody(const cdp::PreparsedRequest&
|
|
273
|
+
void handleGetResponseBody(const cdp::PreparsedRequest &req);
|
|
278
274
|
};
|
|
279
275
|
|
|
280
|
-
} // namespace facebook::react::jsinspector_modern
|
|
276
|
+
} // namespace facebook::react::jsinspector_modern
|
|
@@ -19,7 +19,8 @@ namespace facebook::react::jsinspector_modern {
|
|
|
19
19
|
*
|
|
20
20
|
* \param buffer Buffer to operate on - will be resized if necessary.
|
|
21
21
|
*/
|
|
22
|
-
inline void truncateToValidUTF8(std::vector<char
|
|
22
|
+
inline void truncateToValidUTF8(std::vector<char> &buffer)
|
|
23
|
+
{
|
|
23
24
|
const auto length = buffer.size();
|
|
24
25
|
// Ensure we don't cut a UTF-8 code point in the middle by removing any
|
|
25
26
|
// trailing bytes representing an incomplete UTF-8 code point.
|
|
@@ -31,8 +32,7 @@ inline void truncateToValidUTF8(std::vector<char>& buffer) {
|
|
|
31
32
|
size_t continuationBytes = 0; // [Windows #13587]
|
|
32
33
|
// Find the first byte of the UTF-8 code point (topmost bits 11) and count
|
|
33
34
|
// the number of continuation bytes following it.
|
|
34
|
-
while ((buffer[length - continuationBytes - 1] & 0b11000000) !=
|
|
35
|
-
0b11000000) {
|
|
35
|
+
while ((buffer[length - continuationBytes - 1] & 0b11000000) != 0b11000000) {
|
|
36
36
|
continuationBytes++;
|
|
37
37
|
if (continuationBytes > 3 || continuationBytes >= length - 1) {
|
|
38
38
|
throw std::runtime_error("Invalid UTF-8 sequence");
|
|
@@ -46,8 +46,7 @@ inline void truncateToValidUTF8(std::vector<char>& buffer) {
|
|
|
46
46
|
// by a 0.
|
|
47
47
|
char mask = static_cast<char>(0b11111000 << (3 - continuationBytes));
|
|
48
48
|
char expectedBitsAfterMask = static_cast<char>(mask << 1);
|
|
49
|
-
if (continuationBytes == 0 ||
|
|
50
|
-
(firstByteOfSequence & mask) != expectedBitsAfterMask) {
|
|
49
|
+
if (continuationBytes == 0 || (firstByteOfSequence & mask) != expectedBitsAfterMask) {
|
|
51
50
|
// Remove the trailing continuation bytes, if any, and the first byte.
|
|
52
51
|
buffer.resize(length - (continuationBytes + 1));
|
|
53
52
|
}
|
|
@@ -146,7 +146,8 @@ std::string httpReasonPhrase(uint16_t status) {
|
|
|
146
146
|
return "<Unknown>";
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
std::string mimeTypeFromHeaders(
|
|
149
|
+
std::string mimeTypeFromHeaders(
|
|
150
|
+
const std::map<std::string, std::string>& headers) {
|
|
150
151
|
std::string mimeType = "application/octet-stream";
|
|
151
152
|
|
|
152
153
|
for (const auto& [name, value] : headers) {
|