react-native-windows 0.82.1 → 0.83.0-preview.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/Base/CxxReactIncludes.h +11 -0
- 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/TextInput/WindowsTextInputComponentView.cpp +70 -49
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +4 -1
- package/Microsoft.ReactNative/Fabric/Composition/UriImageManager.cpp +5 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.cpp +7 -2
- package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +1 -0
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +1 -1
- 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/Pch/pch.h +2 -0
- package/Microsoft.ReactNative/ReactHost/CrashManager.cpp +5 -0
- package/Microsoft.ReactNative/ReactHost/ReactNativeHeaders.h +1 -0
- 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/External/Microsoft.ReactNative.Composition.CppLib.props +10 -0
- package/PropertySheets/External/Microsoft.ReactNative.Uwp.CppLib.props +10 -0
- package/PropertySheets/Generated/PackageVersion.g.props +5 -5
- package/PropertySheets/Warnings.props +2 -1
- package/ReactCommon/ReactCommon.vcxproj +21 -12
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/CxxNativeModule.cpp +2 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/Instance.cpp +381 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp +49 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSIndexedRAMBundle.cpp +145 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/MethodCall.cpp +100 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ModuleRegistry.cpp +256 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/NativeToJsBridge.cpp +13 -4
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/RAMBundleRegistry.cpp +93 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ReactMarker.cpp +149 -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 +629 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsiexecutor/jsireact/JSINativeModules.cpp +123 -0
- 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 +414 -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/accessibilityPropsConversions.h +85 -42
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventDispatcher.cpp +81 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventQueueProcessor.cpp +140 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/imagemanager/primitives.h +25 -31
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/uimanager/UIManager.cpp +746 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +702 -0
- 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 +24 -12
- 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 +3 -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
package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModule.h
CHANGED
|
@@ -36,9 +36,7 @@ enum TurboModuleMethodValueKind {
|
|
|
36
36
|
/**
|
|
37
37
|
* Determines TurboModuleMethodValueKind based on the jsi::Value type.
|
|
38
38
|
*/
|
|
39
|
-
TurboModuleMethodValueKind getTurboModuleMethodValueKind(
|
|
40
|
-
jsi::Runtime& rt,
|
|
41
|
-
const jsi::Value* value);
|
|
39
|
+
TurboModuleMethodValueKind getTurboModuleMethodValueKind(jsi::Runtime &rt, const jsi::Value *value);
|
|
42
40
|
|
|
43
41
|
class TurboCxxModule;
|
|
44
42
|
class TurboModuleBinding;
|
|
@@ -55,8 +53,8 @@ class JSI_EXPORT TurboModule : public jsi::HostObject {
|
|
|
55
53
|
// JS representation. To customize lookup of properties, override `create`.
|
|
56
54
|
// Note: keep this method declared inline to avoid conflicts
|
|
57
55
|
// between RTTI and non-RTTI compilation units
|
|
58
|
-
jsi::Value get(jsi::Runtime&
|
|
59
|
-
|
|
56
|
+
jsi::Value get(jsi::Runtime &runtime, const jsi::PropNameID &propName) override
|
|
57
|
+
{
|
|
60
58
|
auto prop = create(runtime, propName);
|
|
61
59
|
// If we have a JS wrapper, cache the result of this lookup
|
|
62
60
|
// We don't cache misses, to allow for methodMap_ to dynamically be
|
|
@@ -64,15 +62,14 @@ class JSI_EXPORT TurboModule : public jsi::HostObject {
|
|
|
64
62
|
// [Windows] Reenable once https://github.com/microsoft/react-native-windows/issues/14128 is fixed
|
|
65
63
|
#ifndef WINAPI_FAMILY
|
|
66
64
|
if (jsRepresentation_ && !prop.isUndefined()) {
|
|
67
|
-
jsRepresentation_->lock(runtime).asObject(runtime).setProperty(
|
|
68
|
-
runtime, propName, prop);
|
|
65
|
+
jsRepresentation_->lock(runtime).asObject(runtime).setProperty(runtime, propName, prop);
|
|
69
66
|
}
|
|
70
67
|
#endif
|
|
71
68
|
return prop;
|
|
72
69
|
}
|
|
73
70
|
|
|
74
|
-
std::vector<jsi::PropNameID> getPropertyNames(
|
|
75
|
-
|
|
71
|
+
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &runtime) override
|
|
72
|
+
{
|
|
76
73
|
std::vector<jsi::PropNameID> result;
|
|
77
74
|
result.reserve(methodMap_.size());
|
|
78
75
|
for (auto it = methodMap_.cbegin(); it != methodMap_.cend(); ++it) {
|
|
@@ -87,18 +84,14 @@ class JSI_EXPORT TurboModule : public jsi::HostObject {
|
|
|
87
84
|
|
|
88
85
|
struct MethodMetadata {
|
|
89
86
|
size_t argCount;
|
|
90
|
-
jsi::Value (*invoker)(
|
|
91
|
-
jsi::Runtime& rt,
|
|
92
|
-
TurboModule& turboModule,
|
|
93
|
-
const jsi::Value* args,
|
|
94
|
-
size_t count);
|
|
87
|
+
jsi::Value (*invoker)(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value *args, size_t count);
|
|
95
88
|
};
|
|
96
89
|
std::unordered_map<std::string, MethodMetadata> methodMap_;
|
|
97
|
-
std::unordered_map<std::string, std::shared_ptr<IAsyncEventEmitter>>
|
|
98
|
-
eventEmitterMap_;
|
|
99
90
|
|
|
100
|
-
|
|
101
|
-
|
|
91
|
+
friend class TurboModuleTestFixtureInternal;
|
|
92
|
+
std::unordered_map<std::string, std::shared_ptr<IAsyncEventEmitter>> eventEmitterMap_;
|
|
93
|
+
|
|
94
|
+
using ArgFactory = std::function<void(jsi::Runtime &runtime, std::vector<jsi::Value> &args)>;
|
|
102
95
|
|
|
103
96
|
/**
|
|
104
97
|
* Calls RCTDeviceEventEmitter.emit to JavaScript, with given event name and
|
|
@@ -112,35 +105,31 @@ class JSI_EXPORT TurboModule : public jsi::HostObject {
|
|
|
112
105
|
* args.emplace_back(jsi::Value(42));
|
|
113
106
|
* });
|
|
114
107
|
*/
|
|
115
|
-
void emitDeviceEvent(
|
|
116
|
-
const std::string& eventName,
|
|
117
|
-
ArgFactory&& argFactory = nullptr);
|
|
108
|
+
void emitDeviceEvent(const std::string &eventName, ArgFactory &&argFactory = nullptr);
|
|
118
109
|
|
|
119
110
|
// Backwards compatibility version
|
|
120
111
|
void emitDeviceEvent(
|
|
121
|
-
jsi::Runtime& /*runtime*/,
|
|
112
|
+
jsi::Runtime & /*runtime*/,
|
|
122
113
|
|
|
123
|
-
const std::string&
|
|
124
|
-
ArgFactory&&
|
|
114
|
+
const std::string &eventName,
|
|
115
|
+
ArgFactory &&argFactory = nullptr)
|
|
116
|
+
{
|
|
125
117
|
emitDeviceEvent(eventName, std::move(argFactory));
|
|
126
118
|
}
|
|
127
119
|
|
|
128
|
-
virtual jsi::Value create(
|
|
129
|
-
|
|
130
|
-
const jsi::PropNameID& propName) {
|
|
120
|
+
virtual jsi::Value create(jsi::Runtime &runtime, const jsi::PropNameID &propName)
|
|
121
|
+
{
|
|
131
122
|
std::string propNameUtf8 = propName.utf8(runtime);
|
|
132
|
-
if (auto methodIter = methodMap_.find(propNameUtf8);
|
|
133
|
-
|
|
134
|
-
const MethodMetadata& meta = methodIter->second;
|
|
123
|
+
if (auto methodIter = methodMap_.find(propNameUtf8); methodIter != methodMap_.end()) {
|
|
124
|
+
const MethodMetadata &meta = methodIter->second;
|
|
135
125
|
return jsi::Function::createFromHostFunction(
|
|
136
126
|
runtime,
|
|
137
127
|
propName,
|
|
138
128
|
static_cast<unsigned int>(meta.argCount),
|
|
139
129
|
[this, meta](
|
|
140
|
-
jsi::Runtime&
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
size_t count) { return meta.invoker(rt, *this, args, count); });
|
|
130
|
+
jsi::Runtime &rt, [[maybe_unused]] const jsi::Value &thisVal, const jsi::Value *args, size_t count) {
|
|
131
|
+
return meta.invoker(rt, *this, args, count);
|
|
132
|
+
});
|
|
144
133
|
} else if (auto eventEmitterIter = eventEmitterMap_.find(propNameUtf8);
|
|
145
134
|
eventEmitterIter != eventEmitterMap_.end()) {
|
|
146
135
|
return eventEmitterIter->second->get(runtime, jsInvoker_);
|
|
@@ -159,7 +148,6 @@ class JSI_EXPORT TurboModule : public jsi::HostObject {
|
|
|
159
148
|
* An app/platform-specific provider function to get an instance of a module
|
|
160
149
|
* given a name.
|
|
161
150
|
*/
|
|
162
|
-
using TurboModuleProviderFunctionType =
|
|
163
|
-
std::function<std::shared_ptr<TurboModule>(const std::string& name)>;
|
|
151
|
+
using TurboModuleProviderFunctionType = std::function<std::shared_ptr<TurboModule>(const std::string &name)>;
|
|
164
152
|
|
|
165
153
|
} // namespace facebook::react
|
|
@@ -23,14 +23,11 @@
|
|
|
23
23
|
|
|
24
24
|
namespace facebook::react {
|
|
25
25
|
|
|
26
|
-
using MeasureOnSuccessCallback =
|
|
27
|
-
SyncCallback<void(double, double, double, double, double, double)>;
|
|
26
|
+
using MeasureOnSuccessCallback = SyncCallback<void(double, double, double, double, double, double)>;
|
|
28
27
|
|
|
29
|
-
using MeasureInWindowOnSuccessCallback =
|
|
30
|
-
SyncCallback<void(double, double, double, double)>;
|
|
28
|
+
using MeasureInWindowOnSuccessCallback = SyncCallback<void(double, double, double, double)>;
|
|
31
29
|
|
|
32
|
-
using MeasureLayoutOnSuccessCallback =
|
|
33
|
-
SyncCallback<void(double, double, double, double)>;
|
|
30
|
+
using MeasureLayoutOnSuccessCallback = SyncCallback<void(double, double, double, double)>;
|
|
34
31
|
|
|
35
32
|
class NativeDOM : public NativeDOMCxxSpec<NativeDOM> {
|
|
36
33
|
public:
|
|
@@ -38,21 +35,15 @@ class NativeDOM : public NativeDOMCxxSpec<NativeDOM> {
|
|
|
38
35
|
|
|
39
36
|
#pragma mark - Methods from the Node interface (for ReadOnlyNode).
|
|
40
37
|
|
|
41
|
-
double compareDocumentPosition(
|
|
42
|
-
jsi::Runtime& rt,
|
|
43
|
-
jsi::Value nativeNodeReference,
|
|
44
|
-
jsi::Value otherNativeNodeReference);
|
|
38
|
+
double compareDocumentPosition(jsi::Runtime &rt, jsi::Value nativeNodeReference, jsi::Value otherNativeNodeReference);
|
|
45
39
|
|
|
46
|
-
std::vector<jsi::Value> getChildNodes(
|
|
47
|
-
jsi::Runtime& rt,
|
|
48
|
-
jsi::Value nativeNodeReference);
|
|
40
|
+
std::vector<jsi::Value> getChildNodes(jsi::Runtime &rt, jsi::Value nativeNodeReference);
|
|
49
41
|
|
|
50
|
-
jsi::Value
|
|
51
|
-
getElementById(jsi::Runtime& rt, SurfaceId surfaceId, const std::string& id);
|
|
42
|
+
jsi::Value getElementById(jsi::Runtime &rt, SurfaceId surfaceId, const std::string &id);
|
|
52
43
|
|
|
53
|
-
jsi::Value getParentNode(jsi::Runtime&
|
|
44
|
+
jsi::Value getParentNode(jsi::Runtime &rt, jsi::Value nativeNodeReference);
|
|
54
45
|
|
|
55
|
-
bool isConnected(jsi::Runtime&
|
|
46
|
+
bool isConnected(jsi::Runtime &rt, jsi::Value nativeNodeReference);
|
|
56
47
|
|
|
57
48
|
#pragma mark - Methods from the Element interface (for ReactNativeElement).
|
|
58
49
|
|
|
@@ -60,99 +51,70 @@ class NativeDOM : public NativeDOMCxxSpec<NativeDOM> {
|
|
|
60
51
|
/* topWidth: */ int,
|
|
61
52
|
/* rightWidth: */ int,
|
|
62
53
|
/* bottomWidth: */ int,
|
|
63
|
-
/* leftWidth: */ int>
|
|
64
|
-
getBorderWidth(
|
|
65
|
-
jsi::Runtime& rt,
|
|
66
|
-
std::shared_ptr<const ShadowNode> shadowNode);
|
|
54
|
+
/* leftWidth: */ int> getBorderWidth(jsi::Runtime &rt, std::shared_ptr<const ShadowNode> shadowNode);
|
|
67
55
|
|
|
68
56
|
std::tuple<
|
|
69
57
|
/* x: */ double,
|
|
70
58
|
/* y: */ double,
|
|
71
59
|
/* width: */ double,
|
|
72
60
|
/* height: */ double>
|
|
73
|
-
getBoundingClientRect(
|
|
74
|
-
jsi::Runtime& rt,
|
|
75
|
-
std::shared_ptr<const ShadowNode> shadowNode,
|
|
76
|
-
bool includeTransform);
|
|
61
|
+
getBoundingClientRect(jsi::Runtime &rt, std::shared_ptr<const ShadowNode> shadowNode, bool includeTransform);
|
|
77
62
|
|
|
78
63
|
std::tuple</* width: */ int, /* height: */ int> getInnerSize(
|
|
79
|
-
jsi::Runtime&
|
|
64
|
+
jsi::Runtime &rt,
|
|
80
65
|
std::shared_ptr<const ShadowNode> shadowNode);
|
|
81
66
|
|
|
82
|
-
std::tuple</* scrollLeft: */ double, /* scrollTop: */ double>
|
|
83
|
-
|
|
84
|
-
jsi::Runtime& rt,
|
|
67
|
+
std::tuple</* scrollLeft: */ double, /* scrollTop: */ double> getScrollPosition(
|
|
68
|
+
jsi::Runtime &rt,
|
|
85
69
|
std::shared_ptr<const ShadowNode> shadowNode);
|
|
86
70
|
|
|
87
71
|
std::tuple</* scrollWidth: */ int, /* scrollHeight */ int> getScrollSize(
|
|
88
|
-
jsi::Runtime&
|
|
72
|
+
jsi::Runtime &rt,
|
|
89
73
|
std::shared_ptr<const ShadowNode> shadowNode);
|
|
90
74
|
|
|
91
|
-
std::string getTagName(
|
|
92
|
-
jsi::Runtime& rt,
|
|
93
|
-
std::shared_ptr<const ShadowNode> shadowNode);
|
|
75
|
+
std::string getTagName(jsi::Runtime &rt, std::shared_ptr<const ShadowNode> shadowNode);
|
|
94
76
|
|
|
95
|
-
std::string getTextContent(
|
|
96
|
-
jsi::Runtime& rt,
|
|
97
|
-
std::shared_ptr<const ShadowNode> shadowNode);
|
|
77
|
+
std::string getTextContent(jsi::Runtime &rt, std::shared_ptr<const ShadowNode> shadowNode);
|
|
98
78
|
|
|
99
|
-
bool hasPointerCapture(
|
|
100
|
-
jsi::Runtime& rt,
|
|
101
|
-
std::shared_ptr<const ShadowNode> shadowNode,
|
|
102
|
-
double pointerId);
|
|
79
|
+
bool hasPointerCapture(jsi::Runtime &rt, std::shared_ptr<const ShadowNode> shadowNode, double pointerId);
|
|
103
80
|
|
|
104
|
-
void releasePointerCapture(
|
|
105
|
-
jsi::Runtime& rt,
|
|
106
|
-
std::shared_ptr<const ShadowNode> shadowNode,
|
|
107
|
-
double pointerId);
|
|
81
|
+
void releasePointerCapture(jsi::Runtime &rt, std::shared_ptr<const ShadowNode> shadowNode, double pointerId);
|
|
108
82
|
|
|
109
|
-
void setPointerCapture(
|
|
110
|
-
jsi::Runtime& rt,
|
|
111
|
-
std::shared_ptr<const ShadowNode> shadowNode,
|
|
112
|
-
double pointerId);
|
|
83
|
+
void setPointerCapture(jsi::Runtime &rt, std::shared_ptr<const ShadowNode> shadowNode, double pointerId);
|
|
113
84
|
|
|
114
85
|
#pragma mark - Methods from the HTMLElement interface (for ReactNativeElement).
|
|
115
86
|
|
|
116
87
|
std::tuple<
|
|
117
88
|
/* offsetParent: */ jsi::Value,
|
|
118
89
|
/* top: */ double,
|
|
119
|
-
/* left: */ double>
|
|
120
|
-
getOffset(jsi::Runtime& rt, std::shared_ptr<const ShadowNode> shadowNode);
|
|
90
|
+
/* left: */ double> getOffset(jsi::Runtime &rt, std::shared_ptr<const ShadowNode> shadowNode);
|
|
121
91
|
|
|
122
92
|
#pragma mark - Special methods to handle the root node.
|
|
123
93
|
|
|
124
|
-
jsi::Value linkRootNode(
|
|
125
|
-
jsi::Runtime& rt,
|
|
126
|
-
SurfaceId surfaceId,
|
|
127
|
-
jsi::Value instanceHandle);
|
|
94
|
+
jsi::Value linkRootNode(jsi::Runtime &rt, SurfaceId surfaceId, jsi::Value instanceHandle);
|
|
128
95
|
|
|
129
96
|
#pragma mark - Legacy layout APIs (for ReactNativeElement).
|
|
130
97
|
|
|
131
|
-
void
|
|
132
|
-
|
|
133
|
-
std::shared_ptr<const ShadowNode> shadowNode,
|
|
134
|
-
const MeasureOnSuccessCallback& callback);
|
|
98
|
+
void
|
|
99
|
+
measure(jsi::Runtime &rt, std::shared_ptr<const ShadowNode> shadowNode, const MeasureOnSuccessCallback &callback);
|
|
135
100
|
|
|
136
101
|
void measureInWindow(
|
|
137
|
-
jsi::Runtime&
|
|
102
|
+
jsi::Runtime &rt,
|
|
138
103
|
std::shared_ptr<const ShadowNode> shadowNode,
|
|
139
|
-
const MeasureInWindowOnSuccessCallback&
|
|
104
|
+
const MeasureInWindowOnSuccessCallback &callback);
|
|
140
105
|
|
|
141
106
|
void measureLayout(
|
|
142
|
-
jsi::Runtime&
|
|
107
|
+
jsi::Runtime &rt,
|
|
143
108
|
std::shared_ptr<const ShadowNode> shadowNode,
|
|
144
109
|
std::shared_ptr<const ShadowNode> relativeToShadowNode,
|
|
145
110
|
jsi::Function onFail,
|
|
146
|
-
const MeasureLayoutOnSuccessCallback&
|
|
111
|
+
const MeasureLayoutOnSuccessCallback &onSuccess);
|
|
147
112
|
|
|
148
113
|
// [windows MSVC cant handle backtick character in a preprocessor line
|
|
149
114
|
#pragma mark - Legacy direct manipulation APIs (for ReactNativeElement).
|
|
150
115
|
// windows]
|
|
151
116
|
|
|
152
|
-
void setNativeProps(
|
|
153
|
-
jsi::Runtime& rt,
|
|
154
|
-
std::shared_ptr<const ShadowNode> shadowNode,
|
|
155
|
-
jsi::Value updatePayload);
|
|
117
|
+
void setNativeProps(jsi::Runtime &rt, std::shared_ptr<const ShadowNode> shadowNode, jsi::Value updatePayload);
|
|
156
118
|
};
|
|
157
119
|
|
|
158
120
|
} // namespace facebook::react
|
|
@@ -0,0 +1,414 @@
|
|
|
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 "NativePerformance.h"
|
|
14
|
+
|
|
15
|
+
#include <memory>
|
|
16
|
+
#include <unordered_map>
|
|
17
|
+
#include <variant>
|
|
18
|
+
|
|
19
|
+
#include <cxxreact/JSExecutor.h>
|
|
20
|
+
#include <cxxreact/ReactMarker.h>
|
|
21
|
+
#include <jsi/JSIDynamic.h>
|
|
22
|
+
#include <jsi/instrumentation.h>
|
|
23
|
+
#include <react/performance/timeline/PerformanceEntryReporter.h>
|
|
24
|
+
#include <react/performance/timeline/PerformanceObserver.h>
|
|
25
|
+
|
|
26
|
+
#include "NativePerformance.h"
|
|
27
|
+
|
|
28
|
+
#ifdef RN_DISABLE_OSS_PLUGIN_HEADER
|
|
29
|
+
#include "Plugins.h"
|
|
30
|
+
#endif
|
|
31
|
+
|
|
32
|
+
std::shared_ptr<facebook::react::TurboModule> NativePerformanceModuleProvider(
|
|
33
|
+
std::shared_ptr<facebook::react::CallInvoker> jsInvoker) {
|
|
34
|
+
return std::make_shared<facebook::react::NativePerformance>(
|
|
35
|
+
std::move(jsInvoker));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
namespace facebook::react {
|
|
39
|
+
|
|
40
|
+
namespace {
|
|
41
|
+
|
|
42
|
+
class PerformanceObserverWrapper : public jsi::NativeState {
|
|
43
|
+
public:
|
|
44
|
+
explicit PerformanceObserverWrapper(
|
|
45
|
+
const std::shared_ptr<PerformanceObserver> observer)
|
|
46
|
+
: observer(observer) {}
|
|
47
|
+
|
|
48
|
+
const std::shared_ptr<PerformanceObserver> observer;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
void sortEntries(std::vector<PerformanceEntry>& entries) {
|
|
52
|
+
return std::stable_sort(
|
|
53
|
+
entries.begin(), entries.end(), PerformanceEntrySorter{});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
NativePerformanceEntry toNativePerformanceEntry(const PerformanceEntry& entry) {
|
|
57
|
+
auto nativeEntry = std::visit(
|
|
58
|
+
[](const auto& entryData) -> NativePerformanceEntry {
|
|
59
|
+
return {
|
|
60
|
+
.name = entryData.name,
|
|
61
|
+
.entryType = entryData.entryType,
|
|
62
|
+
.startTime = entryData.startTime,
|
|
63
|
+
.duration = entryData.duration,
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
entry);
|
|
67
|
+
|
|
68
|
+
if (std::holds_alternative<PerformanceEventTiming>(entry)) {
|
|
69
|
+
auto eventEntry = std::get<PerformanceEventTiming>(entry);
|
|
70
|
+
nativeEntry.processingStart = eventEntry.processingStart;
|
|
71
|
+
nativeEntry.processingEnd = eventEntry.processingEnd;
|
|
72
|
+
nativeEntry.interactionId = eventEntry.interactionId;
|
|
73
|
+
}
|
|
74
|
+
if (std::holds_alternative<PerformanceResourceTiming>(entry)) {
|
|
75
|
+
auto resourceEntry = std::get<PerformanceResourceTiming>(entry);
|
|
76
|
+
nativeEntry.fetchStart = resourceEntry.fetchStart;
|
|
77
|
+
nativeEntry.requestStart = resourceEntry.requestStart;
|
|
78
|
+
nativeEntry.connectStart = resourceEntry.connectStart;
|
|
79
|
+
nativeEntry.connectEnd = resourceEntry.connectEnd;
|
|
80
|
+
nativeEntry.responseStart = resourceEntry.responseStart;
|
|
81
|
+
nativeEntry.responseEnd = resourceEntry.responseEnd;
|
|
82
|
+
nativeEntry.responseStatus = resourceEntry.responseStatus;
|
|
83
|
+
nativeEntry.contentType = resourceEntry.contentType;
|
|
84
|
+
nativeEntry.encodedBodySize = resourceEntry.encodedBodySize;
|
|
85
|
+
nativeEntry.decodedBodySize = resourceEntry.decodedBodySize;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return nativeEntry;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
std::vector<NativePerformanceEntry> toNativePerformanceEntries(
|
|
92
|
+
std::vector<PerformanceEntry>& entries) {
|
|
93
|
+
std::vector<NativePerformanceEntry> result;
|
|
94
|
+
result.reserve(entries.size());
|
|
95
|
+
|
|
96
|
+
for (auto& entry : entries) {
|
|
97
|
+
result.emplace_back(toNativePerformanceEntry(entry));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const std::array<PerformanceEntryType, 2> ENTRY_TYPES_AVAILABLE_FROM_TIMELINE{
|
|
104
|
+
{PerformanceEntryType::MARK, PerformanceEntryType::MEASURE}};
|
|
105
|
+
|
|
106
|
+
bool isAvailableFromTimeline(PerformanceEntryType entryType) {
|
|
107
|
+
return entryType == PerformanceEntryType::MARK ||
|
|
108
|
+
entryType == PerformanceEntryType::MEASURE;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
std::shared_ptr<PerformanceObserver> tryGetObserver(
|
|
112
|
+
jsi::Runtime& rt,
|
|
113
|
+
jsi::Object& observerObj) {
|
|
114
|
+
if (!observerObj.hasNativeState(rt)) {
|
|
115
|
+
return nullptr;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
auto observerWrapper = std::dynamic_pointer_cast<PerformanceObserverWrapper>(
|
|
119
|
+
observerObj.getNativeState(rt));
|
|
120
|
+
return observerWrapper ? observerWrapper->observer : nullptr;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
PerformanceEntryReporter::UserTimingDetailProvider getDetailProviderFromEntry(
|
|
124
|
+
jsi::Runtime& rt,
|
|
125
|
+
jsi::Value& entry) {
|
|
126
|
+
return [&rt, &entry]() -> folly::dynamic {
|
|
127
|
+
try {
|
|
128
|
+
auto detail = entry.asObject(rt).getProperty(rt, "detail");
|
|
129
|
+
return jsi::dynamicFromValue(rt, detail);
|
|
130
|
+
} catch (jsi::JSIException&) {
|
|
131
|
+
return nullptr;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
} // namespace
|
|
137
|
+
|
|
138
|
+
NativePerformance::NativePerformance(std::shared_ptr<CallInvoker> jsInvoker)
|
|
139
|
+
: NativePerformanceCxxSpec(std::move(jsInvoker)) {}
|
|
140
|
+
|
|
141
|
+
HighResTimeStamp NativePerformance::now(jsi::Runtime& /*rt*/) {
|
|
142
|
+
// This is not spec-compliant, as this is the duration from system boot to
|
|
143
|
+
// now, instead of from app startup to now.
|
|
144
|
+
// This should be carefully changed eventually.
|
|
145
|
+
return HighResTimeStamp::now();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
HighResDuration NativePerformance::timeOrigin(jsi::Runtime& /*rt*/) {
|
|
149
|
+
// This is not spec-compliant, as this is an approximation from Unix epoch to
|
|
150
|
+
// system boot, instead of a precise duration from Unix epoch to app startup.
|
|
151
|
+
return HighResTimeStamp::unsafeOriginFromUnixTimeStamp();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
void NativePerformance::reportMark(
|
|
155
|
+
jsi::Runtime& rt,
|
|
156
|
+
const std::string& name,
|
|
157
|
+
HighResTimeStamp startTime,
|
|
158
|
+
jsi::Value entry) {
|
|
159
|
+
PerformanceEntryReporter::getInstance()->reportMark(
|
|
160
|
+
name, startTime, getDetailProviderFromEntry(rt, entry));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
void NativePerformance::reportMeasure(
|
|
164
|
+
jsi::Runtime& rt,
|
|
165
|
+
const std::string& name,
|
|
166
|
+
HighResTimeStamp startTime,
|
|
167
|
+
HighResDuration duration,
|
|
168
|
+
jsi::Value entry) {
|
|
169
|
+
PerformanceEntryReporter::getInstance()->reportMeasure(
|
|
170
|
+
name, startTime, duration, getDetailProviderFromEntry(rt, entry));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
std::optional<double> NativePerformance::getMarkTime(
|
|
174
|
+
jsi::Runtime& /*rt*/,
|
|
175
|
+
const std::string& name) {
|
|
176
|
+
auto markTime = PerformanceEntryReporter::getInstance()->getMarkTime(name);
|
|
177
|
+
return markTime ? std::optional{(*markTime).toDOMHighResTimeStamp()}
|
|
178
|
+
: std::nullopt;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
void NativePerformance::clearMarks(
|
|
182
|
+
jsi::Runtime& /*rt*/,
|
|
183
|
+
std::optional<std::string> entryName) {
|
|
184
|
+
if (entryName) {
|
|
185
|
+
PerformanceEntryReporter::getInstance()->clearEntries(
|
|
186
|
+
PerformanceEntryType::MARK, *entryName);
|
|
187
|
+
} else {
|
|
188
|
+
PerformanceEntryReporter::getInstance()->clearEntries(
|
|
189
|
+
PerformanceEntryType::MARK);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
void NativePerformance::clearMeasures(
|
|
194
|
+
jsi::Runtime& /*rt*/,
|
|
195
|
+
std::optional<std::string> entryName) {
|
|
196
|
+
if (entryName) {
|
|
197
|
+
PerformanceEntryReporter::getInstance()->clearEntries(
|
|
198
|
+
PerformanceEntryType::MEASURE, *entryName);
|
|
199
|
+
} else {
|
|
200
|
+
PerformanceEntryReporter::getInstance()->clearEntries(
|
|
201
|
+
PerformanceEntryType::MEASURE);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
std::vector<NativePerformanceEntry> NativePerformance::getEntries(
|
|
206
|
+
jsi::Runtime& /*rt*/) {
|
|
207
|
+
std::vector<PerformanceEntry> entries;
|
|
208
|
+
|
|
209
|
+
for (auto entryType : ENTRY_TYPES_AVAILABLE_FROM_TIMELINE) {
|
|
210
|
+
PerformanceEntryReporter::getInstance()->getEntries(entries, entryType);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
sortEntries(entries);
|
|
214
|
+
|
|
215
|
+
return toNativePerformanceEntries(entries);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
std::vector<NativePerformanceEntry> NativePerformance::getEntriesByName(
|
|
219
|
+
jsi::Runtime& /*rt*/,
|
|
220
|
+
const std::string& entryName,
|
|
221
|
+
std::optional<PerformanceEntryType> entryType) {
|
|
222
|
+
std::vector<PerformanceEntry> entries;
|
|
223
|
+
|
|
224
|
+
if (entryType) {
|
|
225
|
+
if (isAvailableFromTimeline(*entryType)) {
|
|
226
|
+
PerformanceEntryReporter::getInstance()->getEntries(
|
|
227
|
+
entries, *entryType, entryName);
|
|
228
|
+
}
|
|
229
|
+
} else {
|
|
230
|
+
for (auto type : ENTRY_TYPES_AVAILABLE_FROM_TIMELINE) {
|
|
231
|
+
PerformanceEntryReporter::getInstance()->getEntries(
|
|
232
|
+
entries, type, entryName);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
sortEntries(entries);
|
|
237
|
+
|
|
238
|
+
return toNativePerformanceEntries(entries);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
std::vector<NativePerformanceEntry> NativePerformance::getEntriesByType(
|
|
242
|
+
jsi::Runtime& /*rt*/,
|
|
243
|
+
PerformanceEntryType entryType) {
|
|
244
|
+
std::vector<PerformanceEntry> entries;
|
|
245
|
+
|
|
246
|
+
if (isAvailableFromTimeline(entryType)) {
|
|
247
|
+
PerformanceEntryReporter::getInstance()->getEntries(entries, entryType);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
sortEntries(entries);
|
|
251
|
+
|
|
252
|
+
return toNativePerformanceEntries(entries);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
std::vector<std::pair<std::string, uint32_t>> NativePerformance::getEventCounts(
|
|
256
|
+
jsi::Runtime& /*rt*/) {
|
|
257
|
+
const auto& eventCounts =
|
|
258
|
+
PerformanceEntryReporter::getInstance()->getEventCounts();
|
|
259
|
+
return {eventCounts.begin(), eventCounts.end()};
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
std::unordered_map<std::string, double> NativePerformance::getSimpleMemoryInfo(
|
|
263
|
+
jsi::Runtime& rt) {
|
|
264
|
+
auto heapInfo = rt.instrumentation().getHeapInfo(false);
|
|
265
|
+
std::unordered_map<std::string, double> heapInfoToJs;
|
|
266
|
+
for (auto& entry : heapInfo) {
|
|
267
|
+
heapInfoToJs[entry.first] = static_cast<double>(entry.second);
|
|
268
|
+
}
|
|
269
|
+
return heapInfoToJs;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
std::unordered_map<std::string, double>
|
|
273
|
+
NativePerformance::getReactNativeStartupTiming(jsi::Runtime& /*rt*/) {
|
|
274
|
+
std::unordered_map<std::string, double> result;
|
|
275
|
+
|
|
276
|
+
ReactMarker::StartupLogger& startupLogger =
|
|
277
|
+
ReactMarker::StartupLogger::getInstance();
|
|
278
|
+
if (!std::isnan(startupLogger.getAppStartupStartTime())) {
|
|
279
|
+
result["startTime"] = startupLogger.getAppStartupStartTime();
|
|
280
|
+
} else if (!std::isnan(startupLogger.getInitReactRuntimeStartTime())) {
|
|
281
|
+
result["startTime"] = startupLogger.getInitReactRuntimeStartTime();
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if (!std::isnan(startupLogger.getInitReactRuntimeStartTime())) {
|
|
285
|
+
result["initializeRuntimeStart"] =
|
|
286
|
+
startupLogger.getInitReactRuntimeStartTime();
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (!std::isnan(startupLogger.getRunJSBundleStartTime())) {
|
|
290
|
+
result["executeJavaScriptBundleEntryPointStart"] =
|
|
291
|
+
startupLogger.getRunJSBundleStartTime();
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (!std::isnan(startupLogger.getAppStartupEndTime())) {
|
|
295
|
+
result["endTime"] = startupLogger.getAppStartupEndTime();
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return result;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
jsi::Object NativePerformance::createObserver(
|
|
302
|
+
jsi::Runtime& rt,
|
|
303
|
+
NativePerformancePerformanceObserverCallback callback) {
|
|
304
|
+
// The way we dispatch performance observer callbacks is a bit different from
|
|
305
|
+
// the spec. The specification requires us to queue a single task that
|
|
306
|
+
// dispatches observer callbacks. Instead, we are queuing all callbacks as
|
|
307
|
+
// separate tasks in the scheduler.
|
|
308
|
+
PerformanceObserverCallback cb = [callback = std::move(callback)]() {
|
|
309
|
+
callback.callWithPriority(SchedulerPriority::IdlePriority);
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
auto& registry =
|
|
313
|
+
PerformanceEntryReporter::getInstance()->getObserverRegistry();
|
|
314
|
+
|
|
315
|
+
auto observer = PerformanceObserver::create(registry, std::move(cb));
|
|
316
|
+
auto observerWrapper = std::make_shared<PerformanceObserverWrapper>(observer);
|
|
317
|
+
jsi::Object observerObj{rt};
|
|
318
|
+
observerObj.setNativeState(rt, observerWrapper);
|
|
319
|
+
return observerObj;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
double NativePerformance::getDroppedEntriesCount(
|
|
323
|
+
jsi::Runtime& rt,
|
|
324
|
+
jsi::Object observerObj) {
|
|
325
|
+
auto observer = tryGetObserver(rt, observerObj);
|
|
326
|
+
|
|
327
|
+
if (!observer) {
|
|
328
|
+
return 0;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
return observer->getDroppedEntriesCount();
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
void NativePerformance::observe(
|
|
335
|
+
jsi::Runtime& rt,
|
|
336
|
+
jsi::Object observerObj,
|
|
337
|
+
NativePerformancePerformanceObserverObserveOptions options) {
|
|
338
|
+
auto observer = tryGetObserver(rt, observerObj);
|
|
339
|
+
|
|
340
|
+
if (!observer) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
auto durationThreshold =
|
|
345
|
+
options.durationThreshold.value_or(HighResDuration::zero());
|
|
346
|
+
|
|
347
|
+
// observer of type multiple
|
|
348
|
+
if (options.entryTypes.has_value()) {
|
|
349
|
+
std::unordered_set<PerformanceEntryType> entryTypes;
|
|
350
|
+
auto rawTypes = options.entryTypes.value();
|
|
351
|
+
|
|
352
|
+
for (auto rawType : rawTypes) {
|
|
353
|
+
entryTypes.insert(Bridging<PerformanceEntryType>::fromJs(rt, rawType));
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
observer->observe(entryTypes);
|
|
357
|
+
} else { // single
|
|
358
|
+
auto buffered = options.buffered.value_or(false);
|
|
359
|
+
if (options.type.has_value()) {
|
|
360
|
+
observer->observe(
|
|
361
|
+
static_cast<PerformanceEntryType>(options.type.value()),
|
|
362
|
+
{.buffered = buffered, .durationThreshold = durationThreshold});
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
void NativePerformance::disconnect(jsi::Runtime& rt, jsi::Object observerObj) {
|
|
368
|
+
auto observerWrapper = std::dynamic_pointer_cast<PerformanceObserverWrapper>(
|
|
369
|
+
observerObj.getNativeState(rt));
|
|
370
|
+
|
|
371
|
+
if (!observerWrapper) {
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
auto observer = observerWrapper->observer;
|
|
376
|
+
observer->disconnect();
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
std::vector<NativePerformanceEntry> NativePerformance::takeRecords(
|
|
380
|
+
jsi::Runtime& rt,
|
|
381
|
+
jsi::Object observerObj,
|
|
382
|
+
bool sort) {
|
|
383
|
+
auto observerWrapper = std::dynamic_pointer_cast<PerformanceObserverWrapper>(
|
|
384
|
+
observerObj.getNativeState(rt));
|
|
385
|
+
|
|
386
|
+
if (!observerWrapper) {
|
|
387
|
+
return {};
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
auto observer = observerWrapper->observer;
|
|
391
|
+
auto records = observer->takeRecords();
|
|
392
|
+
if (sort) {
|
|
393
|
+
sortEntries(records);
|
|
394
|
+
}
|
|
395
|
+
return toNativePerformanceEntries(records);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
std::vector<PerformanceEntryType>
|
|
399
|
+
NativePerformance::getSupportedPerformanceEntryTypes(jsi::Runtime& /*rt*/) {
|
|
400
|
+
auto supportedEntryTypes = PerformanceEntryReporter::getSupportedEntryTypes();
|
|
401
|
+
return {supportedEntryTypes.begin(), supportedEntryTypes.end()};
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
#pragma mark - Testing
|
|
405
|
+
|
|
406
|
+
void NativePerformance::clearEventCountsForTesting(jsi::Runtime& /*rt*/) {
|
|
407
|
+
PerformanceEntryReporter::getInstance()->clearEventCounts();
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
} // namespace facebook::react
|
|
411
|
+
|
|
412
|
+
#if _MSC_VER
|
|
413
|
+
#pragma warning(pop)
|
|
414
|
+
#endif
|