From 2551aee4b074a8b932f2d0c1998de0fd27de028c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Mon, 22 Jul 2024 04:45:02 -0700 Subject: [PATCH] Expose PerformanceObserver related classes in the global scope (#45539) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45539 Changelog: [internal] This exposes several classes (interfaces in the spec lingo) related to the Performance API to the global scope, so users can access them directly to do things like refinements using `instanceof`. This also prevents the need from importing the modules from `react-native` directly, which would prevent code sharing with Web. Reviewed By: rshest Differential Revision: D59859654 fbshipit-source-id: e1f7afb0c98b394b1f97c3790db2e570e6ba0cd9 --- .../Core/setUpPerformanceObserver.js | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/packages/react-native/Libraries/Core/setUpPerformanceObserver.js b/packages/react-native/Libraries/Core/setUpPerformanceObserver.js index 47ed15546c2a05..f182ebc2e37c72 100644 --- a/packages/react-native/Libraries/Core/setUpPerformanceObserver.js +++ b/packages/react-native/Libraries/Core/setUpPerformanceObserver.js @@ -16,3 +16,51 @@ polyfillGlobal( require('../../src/private/webapis/performance/PerformanceObserver') .default, ); + +polyfillGlobal( + 'PerformanceObserverEntryList', + () => + require('../../src/private/webapis/performance/PerformanceObserver') + .PerformanceObserverEntryList, +); + +polyfillGlobal( + 'PerformanceEntry', + () => + require('../../src/private/webapis/performance/PerformanceEntry') + .PerformanceEntry, +); + +polyfillGlobal( + 'PerformanceMark', + () => + require('../../src/private/webapis/performance/UserTiming').PerformanceMark, +); + +polyfillGlobal( + 'PerformanceMeasure', + () => + require('../../src/private/webapis/performance/UserTiming') + .PerformanceMeasure, +); + +polyfillGlobal( + 'PerformanceEventTiming', + () => + require('../../src/private/webapis/performance/EventTiming') + .PerformanceEventTiming, +); + +polyfillGlobal( + 'TaskAttributionTiming', + () => + require('../../src/private/webapis/performance/LongTasks') + .TaskAttributionTiming, +); + +polyfillGlobal( + 'PerformanceLongTaskTiming', + () => + require('../../src/private/webapis/performance/LongTasks') + .PerformanceLongTaskTiming, +);