JS side implementation of PerformanceObserver API

Summary:
[Changelog][Internal]

This adds module specs for the native part of PerformanceObserver, as well as the interaction logic vs the NativePerformanceObserver API.

See https://fb.quip.com/MdqgAk1Eb2dV for more detail.

Reviewed By: rubennorte

Differential Revision: D40897006

fbshipit-source-id: 77475f21dad9ee9dbe15df5a989eb08d314e6db2
This commit is contained in:
Ruslan Shestopalyuk
2022-11-22 11:13:38 +00:00
committed by Lorenzo Sciandra
parent d02b51332e
commit ea0cd5b7ca
2 changed files with 159 additions and 8 deletions
@@ -0,0 +1,44 @@
/**
* 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 type RawTimeStamp = number;
export const RawPerformanceEntryTypeValues = {
UNDEFINED: 0,
};
export type RawPerformanceEntryType = number;
export type RawPerformanceEntry = $ReadOnly<{
name: string,
entryType: RawPerformanceEntryType,
startTime: RawTimeStamp,
duration: number,
// For "event" entries only:
processingStart?: RawTimeStamp,
processingEnd?: RawTimeStamp,
interactionId?: RawTimeStamp,
}>;
export type RawPerformanceEntryList = $ReadOnlyArray<RawPerformanceEntry>;
export interface Spec extends TurboModule {
+startReporting: (entryType: string) => void;
+stopReporting: (entryType: string) => void;
+getPendingEntries: () => RawPerformanceEntryList;
+setOnPerformanceEntryCallback: (callback?: () => void) => void;
}
export default (TurboModuleRegistry.get<Spec>('PerformanceObserver'): ?Spec);