mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
aef7194996
Summary: [Changelog][Internal] `NativePerformanceObserver` TurboModule API would get the type for performance entries as strings in one direction (`start/stopReporting`) and as integers in another direction (inside `RawPerformanceEntry`, for optimization on the native side). This makes is symmetrical and consistent, all the conversions are now handled on the JS side. Reviewed By: christophpurrer Differential Revision: D43236466 fbshipit-source-id: 08e1b62df90e6d26a11577d6b6b1d91a6bce8339
50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow strict
|
|
* @format
|
|
*/
|
|
|
|
import type {TurboModule} from '../TurboModule/RCTExport';
|
|
|
|
import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';
|
|
|
|
export const RawPerformanceEntryTypeValues = {
|
|
UNDEFINED: 0,
|
|
MARK: 1,
|
|
MEASURE: 2,
|
|
EVENT: 3,
|
|
};
|
|
|
|
export type RawPerformanceEntryType = number;
|
|
|
|
export type RawPerformanceEntry = {|
|
|
name: string,
|
|
entryType: RawPerformanceEntryType,
|
|
startTime: number,
|
|
duration: number,
|
|
// For "event" entries only:
|
|
processingStart?: number,
|
|
processingEnd?: number,
|
|
interactionId?: number,
|
|
|};
|
|
|
|
export type GetPendingEntriesResult = {|
|
|
entries: $ReadOnlyArray<RawPerformanceEntry>,
|
|
droppedEntriesCount: number,
|
|
|};
|
|
|
|
export interface Spec extends TurboModule {
|
|
+startReporting: (entryType: RawPerformanceEntryType) => void;
|
|
+stopReporting: (entryType: RawPerformanceEntryType) => void;
|
|
+popPendingEntries: () => GetPendingEntriesResult;
|
|
+setOnPerformanceEntryCallback: (callback?: () => void) => void;
|
|
}
|
|
|
|
export default (TurboModuleRegistry.get<Spec>(
|
|
'NativePerformanceObserverCxx',
|
|
): ?Spec);
|